From 63f5224c88f58faad876ef04a5aba97ce4fead92 Mon Sep 17 00:00:00 2001 From: Mike Hibler Date: Mon, 4 May 2015 13:34:14 -0600 Subject: [PATCH] I cannot believe I did this...fix the LILO relocation code. No one has used this code in 10 years and not one will ever use it again, but it broke my testing...and PISSED ME OFF! Time for a LILO revival! --- clientside/os/imagezip/extfs/reloc_lilo.c | 22 +++++++++++----------- clientside/os/imagezip/imageunzip.c | 1 + 2 files changed, 12 insertions(+), 11 deletions(-) diff --git a/clientside/os/imagezip/extfs/reloc_lilo.c b/clientside/os/imagezip/extfs/reloc_lilo.c index 5686cfef3..bc3c53dde 100644 --- a/clientside/os/imagezip/extfs/reloc_lilo.c +++ b/clientside/os/imagezip/extfs/reloc_lilo.c @@ -1,5 +1,5 @@ /* - * Copyright (c) 2000-2004, 2009 University of Utah and the Flux Group. + * Copyright (c) 2000-2015 University of Utah and the Flux Group. * * {{{EMULAB-LICENSE * @@ -170,7 +170,8 @@ fixup_lilo(int slice, int stype, u_int32_t start, u_int32_t size, /* * Check for aliases which produce a map entry pointing * to the same sectors as the original. We don't want to - * relocate those sectors multiple times! + * relocate those sectors multiple times! But we do need + * to relocate the pointers. */ s0 = getsector(&ip->start); for (a_ip = dtab.idtab.images; a_ip < ip; a_ip++) { @@ -180,14 +181,6 @@ fixup_lilo(int slice, int stype, u_int32_t start, u_int32_t size, if (s0 == a_s0) break; } - if (a_ip < ip) { - if (debug > 1) - fprintf(stderr, " LILO parse: " - "skipping %s (alias for %s)\n", - ip->name, a_ip->name); - ip++; - continue; - } /* * Fixup initrd (if present) and map sector(s) @@ -202,7 +195,14 @@ fixup_lilo(int slice, int stype, u_int32_t start, u_int32_t size, } fixup_sector(FOFFSET(poff, struct idtab, images[i].start), &ip->start); - fixup_map(infd, s0); + + if (a_ip < ip) { + if (debug > 1) + fprintf(stderr, " LILO parse: " + "skipping %s (alias for %s)\n", + ip->name, a_ip->name); + } else + fixup_map(infd, s0); ip++; } diff --git a/clientside/os/imagezip/imageunzip.c b/clientside/os/imagezip/imageunzip.c index e9dd4f3bc..e3a903394 100644 --- a/clientside/os/imagezip/imageunzip.c +++ b/clientside/os/imagezip/imageunzip.c @@ -2227,6 +2227,7 @@ reloc_lilo(void *addr, int reloctype, uint32_t size) if (sector == 0) break; sector += outputminsec; + assert(outputmaxsec == 0 || sector <= outputmaxsec); putsector(sect, sector, sect->device, sect->nsect); sect++; } -- GitLab