aboutsummaryrefslogtreecommitdiffstats
path: root/libinstaller/syslxmod.c
diff options
context:
space:
mode:
authorAlek Du <alek.du@intel.com>2010-06-08 22:28:33 -0700
committerH. Peter Anvin <hpa@linux.intel.com>2010-06-09 10:57:27 -0700
commit146c34a2632a4295b1aef44ef79e84b4d4b9cf7e (patch)
treeeb744f032eaee413fcff54c3c67ad2f8daab5207 /libinstaller/syslxmod.c
parent0153498e9ce97fbf7329b590ddb7a373e33b12e6 (diff)
downloadsyslinux-146c34a2632a4295b1aef44ef79e84b4d4b9cf7e.tar.gz
syslinux-146c34a2632a4295b1aef44ef79e84b4d4b9cf7e.tar.xz
syslinux-146c34a2632a4295b1aef44ef79e84b4d4b9cf7e.zip
Make syslinux installer real "pathbased"
The previous merging extlinux/syslinux patch is not sufficient, the syslinux is not real "patchbased", hence: * fill currentdir in patcharea * search "extlinux.conf" and "syslinux.cfg" for generic_load_config * define boot_image and boot_sector macro for ldsyslinux this could make further merging extlinux and syslinux possible Signed-off-by: Alek Du <alek.du@intel.com> Signed-off-by: H. Peter Anvin <hpa@linux.intel.com>
Diffstat (limited to 'libinstaller/syslxmod.c')
-rw-r--r--libinstaller/syslxmod.c32
1 files changed, 21 insertions, 11 deletions
diff --git a/libinstaller/syslxmod.c b/libinstaller/syslxmod.c
index 9ab139c6..b28a443b 100644
--- a/libinstaller/syslxmod.c
+++ b/libinstaller/syslxmod.c
@@ -29,7 +29,7 @@ void syslinux_make_bootsect(void *bs)
{
struct boot_sector *bootsect = bs;
const struct boot_sector *sbs =
- (const struct boot_sector *)syslinux_bootsect;
+ (const struct boot_sector *)boot_sector;
memcpy(&bootsect->bsHead, &sbs->bsHead, bsHeadLen);
memcpy(&bootsect->bsCode, &sbs->bsCode, bsCodeLen);
@@ -227,14 +227,15 @@ static __noinline void set_32_sl(uint32_t * p, uint32_t v)
* otherwise -1.
*/
int syslinux_patch(const uint32_t * sectors, int nsectors,
- int stupid, int raid_mode)
+ int stupid, int raid_mode, const char *subdir)
{
struct patch_area *patcharea;
uint32_t *wp;
- int nsect = (syslinux_ldlinux_len + 511) >> 9;
+ int nsect = (boot_image_len + 511) >> 9;
uint32_t csum;
int i, dw, nptrs, rv;
- struct boot_sector *sbs = (struct boot_sector *)syslinux_bootsect;
+ struct boot_sector *sbs = (struct boot_sector *)boot_sector;
+ int diroffset, dirlen;
if (nsectors < nsect)
return -1;
@@ -254,18 +255,29 @@ int syslinux_patch(const uint32_t * sectors, int nsectors,
set_32(&sbs->NextSector, *sectors++);
/* Search for LDLINUX_MAGIC to find the patch area */
- for (wp = (uint32_t *) syslinux_ldlinux; get_32_sl(wp) != LDLINUX_MAGIC;
+ for (wp = (uint32_t *)boot_image; get_32_sl(wp) != LDLINUX_MAGIC;
wp++) ;
patcharea = (struct patch_area *)wp;
/* Set up the totals */
- dw = syslinux_ldlinux_len >> 2; /* COMPLETE dwords, excluding ADV */
+ dw = boot_image_len >> 2; /* COMPLETE dwords, excluding ADV */
set_16_sl(&patcharea->data_sectors, nsect); /* Not including ADVs */
set_16_sl(&patcharea->adv_sectors, 2); /* ADVs need 2 sectors */
set_32_sl(&patcharea->dwords, dw);
+ /* Poke in the base directory path */
+ if (subdir) {
+ diroffset = get_16(&patcharea->diroffset);
+ dirlen = get_16(&patcharea->dirlen);
+ if (dirlen <= strlen(subdir)) {
+ fprintf(stderr, "Subdirectory path too long... aborting install!\n");
+ exit(1);
+ }
+ memcpy((char *)boot_image + diroffset, subdir, strlen(subdir) + 1);
+ }
+
/* Set the sector pointers */
- wp = (uint32_t *) ((char *)syslinux_ldlinux +
+ wp = (uint32_t *) ((char *)boot_image +
get_16_sl(&patcharea->secptroffset));
nptrs = get_16_sl(&patcharea->secptrcnt);
@@ -277,16 +289,14 @@ int syslinux_patch(const uint32_t * sectors, int nsectors,
while (nptrs--)
set_32_sl(wp++, 0);
- rv = (char *)wp - (char *)syslinux_ldlinux;
-
/* Now produce a checksum */
set_32_sl(&patcharea->checksum, 0);
csum = LDLINUX_MAGIC;
- for (i = 0, wp = (uint32_t *) syslinux_ldlinux; i < dw; i++, wp++)
+ for (i = 0, wp = (uint32_t *)boot_image; i < dw; i++, wp++)
csum -= get_32_sl(wp); /* Negative checksum */
set_32_sl(&patcharea->checksum, csum);
- return rv;
+ return dw << 2;
}