From: H. Peter Anvin Date: Fri, 22 Jan 2010 22:44:53 +0000 (-0800) Subject: extlinux: make installer rewrite the whole file X-Git-Tag: syslinux-4.00-pre18~4 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=5396e250a679c368b3dd353c730358d6c54960c8;p=profile%2Fivi%2Fsyslinux.git 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 --- 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; } /*