[syslinux:pathbased] extlinux: make installer rewrite the whole file

syslinux-bot for H. Peter Anvin hpa at zytor.com
Fri Jan 22 14:48:07 PST 2010


Commit-ID:  5396e250a679c368b3dd353c730358d6c54960c8
Gitweb:     http://syslinux.zytor.com/commit/5396e250a679c368b3dd353c730358d6c54960c8
Author:     H. Peter Anvin <hpa at zytor.com>
AuthorDate: Fri, 22 Jan 2010 14:44:53 -0800
Committer:  H. Peter Anvin <hpa at zytor.com>
CommitDate: Fri, 22 Jan 2010 14:44:53 -0800

extlinux: make installer rewrite the whole file

With the additional patchable areas outside the main patch area, it is
now much more complicated to keep track of a high water mark of what
needs to be modified.  It's easier to just rewrite the whole thing.

Signed-off-by: H. Peter Anvin <hpa at zytor.com>


---
 extlinux/main.c |   19 +++++++++++--------
 1 files changed, 11 insertions(+), 8 deletions(-)

diff --git a/extlinux/main.c b/extlinux/main.c
index b02cfe2..2cfb1ea 100644
--- a/extlinux/main.c
+++ b/extlinux/main.c
@@ -490,27 +490,30 @@ int patch_file_and_bootblock(int fd, const char *dir, int devfd)
     }
     strncpy((char *)boot_image + diroffset, subpath, dirlen);
     free(dirpath);
+  
     /* write subvol info if we have */
-    if (*subvol) {
-	subvoloffset = get_16(&patcharea->subvoloffset);
-	subvollen = get_16(&patcharea->subvollen);
-	if (subvollen <= strlen(subvol)) {
+    subvoloffset = get_16(&patcharea->subvoloffset);
+    subvollen = get_16(&patcharea->subvollen);
+    if (subvollen <= strlen(subvol)) {
 	fprintf(stderr, "Subvol name too long... aborting install!\n");
 	exit(1);
-	}
-	strncpy((char *)boot_image + subvoloffset, subvol, subvollen);
     }
+    strncpy((char *)boot_image + subvoloffset, subvol, subvollen);
 
     /* Now produce a checksum */
     set_32(&patcharea->checksum, 0);
-
+    
     csum = LDLINUX_MAGIC;
     for (i = 0, wp = (uint32_t *) boot_image; i < dw; i++, wp++)
 	csum -= get_32(wp);	/* Negative checksum */
 
     set_32(&patcharea->checksum, csum);
 
-    return secptroffset + nptrs*4;
+    /*
+     * Assume all bytes modified.  This can be optimized at the expense
+     * of keeping track of what the highest modified address ever was.
+     */
+    return dw << 2;
 }
 
 /*



More information about the Syslinux-commits mailing list