com32sys_t regs;
int i;
- /* If installed by extlinux, try the extlinux filename */
+ /* If path filled by installer, then use that to load config*/
if (*CurrentDirName && !generic_load_config())
return 0;
#include <fs.h>
/*
- * Standard version of load_config for extlinux-installed filesystems
+ * Standard version of load_config for extlinux/syslinux filesystems
*/
int generic_load_config(void)
{
com32sys_t regs;
chdir(CurrentDirName);
+ /* try extlinux.conf first */
realpath(ConfigName, "extlinux.conf", FILENAME_MAX);
-
- dprintf("Config = %s\n", ConfigName);
-
+ dprintf("Try config = %s\n", ConfigName);
memset(®s, 0, sizeof regs);
regs.edi.w[0] = OFFS_WRT(ConfigName, 0);
call16(core_open, ®s, ®s);
-
+ /* give syslinux.cfg a chance ? */
+ if (regs.eflags.l & EFLAGS_ZF) {
+ realpath(ConfigName, "syslinux.cfg", FILENAME_MAX);
+ dprintf("Then try config = %s\n", ConfigName);
+ memset(®s, 0, sizeof regs);
+ regs.edi.w[0] = OFFS_WRT(ConfigName, 0);
+ call16(core_open, ®s, ®s);
+ }
return (regs.eflags.l & EFLAGS_ZF) ? -1 : 0;
}
/*
* Patch ldlinux.sys and the boot sector
*/
- i = syslinux_patch(sectors, nsectors, stupid, raid_mode);
+ i = syslinux_patch(sectors, nsectors, stupid, raid_mode, subdir);
patch_sectors = (i + SECTOR_SIZE - 1) >> SECTOR_SHIFT;
/*
extern const unsigned int syslinux_ldlinux_len;
extern const int syslinux_ldlinux_mtime;
+#define boot_sector syslinux_bootsect
+#define boot_sector_len syslinux_bootsect_len
+#define boot_image syslinux_ldlinux
+#define boot_image_len syslinux_ldlinux_len
+
extern unsigned char syslinux_mbr[];
extern const unsigned int syslinux_mbr_len;
extern const int syslinux_mbr_mtime;
/* This patches the boot sector and ldlinux.sys based on a sector map */
int syslinux_patch(const uint32_t * sectors, int nsectors,
- int stupid, int raid_mode);
+ int stupid, int raid_mode, const char *subdir);
#endif
{
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);
* 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;
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);
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;
}
/*
* Patch ldlinux.sys and the boot sector
*/
- i = syslinux_patch(sectors, ldlinux_sectors, opt.stupid_mode, opt.raid_mode);
+ i = syslinux_patch(sectors, ldlinux_sectors, opt.stupid_mode, opt.raid_mode, subdir);
patch_sectors = (i + SECTOR_SIZE - 1) >> SECTOR_SHIFT;
/*
libfat_close(fs);
/* Patch ldlinux.sys and the boot sector */
- i = syslinux_patch(sectors, nsectors, stupid, raid_mode);
+ i = syslinux_patch(sectors, nsectors, stupid, raid_mode, subdir);
patch_sectors = (i + SECTOR_SIZE - 1) >> SECTOR_SHIFT;
/* Write the now-patched first sectors of ldlinux.sys */
/*
* Patch ldlinux.sys and the boot sector
*/
- syslinux_patch(sectors, nsectors, stupid, raid_mode);
+ syslinux_patch(sectors, nsectors, stupid, raid_mode, subdir);
/*
* Rewrite the file