if (_iter->type != typedos) {
error("Option 'hide' is only meaningful for legacy partition scheme.");
- goto out;
+ goto bail;
}
if (!(mbr = disk_read_sectors(&_iter->di, 0, 1))) {
error("WARNING: Couldn't read MBR to hide/unhide partitions.\n");
- goto out;
+ goto bail;
}
if (_iter->index < 1 || _iter->index > 4)
if (write_back && disk_write_verify_sector(&_iter->di, 0, mbr))
error("WARNING: failed to write MBR for option 'hide'\n");
-out:
+bail:
free(mbr);
}
error("Unable to find requested MBR signature.\n");
goto bail;
}
-
} else if (!strncmp(opt.drivename, "guid", 4)) {
if (str_to_guid(opt.drivename + 5, &gpt_guid))
goto bail;
error("Unable to find requested GPT disk or partition by guid.\n");
goto bail;
}
-
} else if (!strncmp(opt.drivename, "label", 5)) {
if (!opt.drivename[6]) {
error("No label specified.\n");
error("Unable to find requested GPT partition by label.\n");
goto bail;
}
-
} else if ((opt.drivename[0] == 'h' || opt.drivename[0] == 'f') &&
opt.drivename[1] == 'd') {
hd = opt.drivename[0] == 'h' ? 0x80 : 0;
"'boot' and 'fs' are meaningless.\n");
goto bail;
}
-#if 0
/* offsets match, but in case it changes in the future */
if (sdi->c.filesystem == SYSLINUX_FS_ISOLINUX) {
drive = sdi->iso.drive_number;
fs_lba = *sdi->iso.partoffset;
} else {
-#endif
drive = sdi->disk.drive_number;
fs_lba = *sdi->disk.partoffset;
-#if 0
}
-#endif
-
if (disk_get_params(drive, &diskinfo))
goto bail;
/* this will start iteration over disk emulation, possibly raw */
printf("iter dsk: %d\n", iter->di.disk);
printf("iter idx: %d\n", iter->index);
printf("iter lba: %llu\n", iter->start_lba);
- if (hand_area)
+ if (hidx >= 0)
printf("hand lba: %u\n", hand_area->start_lba);
#endif
unsigned int *off,
unsigned int *ip)
{
- unsigned int segval = 0, offval = 0, ipval = 0, val;
+ unsigned int segval = 0, offval = 0x7c00, ipval = 0x7c00, val;
char *p;
segval = strtoul(ptr, &p, 0);
- if (*p == ':')
+ if (p[0] == ':' && p[1] && p[1] != ':')
offval = strtoul(p+1, &p, 0);
- if (*p == ':')
+ if (p[0] == ':' && p[1] && p[1] != ':')
ipval = strtoul(p+1, NULL, 0);
val = (segval << 4) + offval;
void usage(void)
{
- static const char *const usage[] = { "\
+ unsigned int i;
+ static const char key[] = "Press any key...\n";
+ static const char *const usage[] = {
+"\
Usage:\n\
chain.c32 [options]\n\
chain.c32 {fd|hd}<disk> [<partition>] [options]\n\
chain.c32 label{:|=}<label> [<partition>] [options]\n\
chain.c32 boot{,| }[<partition>] [options]\n\
chain.c32 fs [options]\n\
-\nOptions ('no' prefix specify defaulti value):\n\
+", "\
+\nOptions ('no' prefix specify default value):\n\
file=<loader> Load and execute file\n\
seg=<s[:o[:i]]> Load file at <s:o>, jump to <s:i>\n\
nofilebpb Treat file in memory as BPB compatible\n\
sect[=<s[:o[:i]]>] Load sector at <s:o>, jump to <s:i>\n\
- defaults to 0:0x7C00:0x7C00\n\
+ - ommited o/i values default 0x7C00\n\
maps Map loaded sector into real memory\n\
nosethid[den] Set BPB's hidden sectors field\n\
nosetgeo Set BPB's sectors per track and heads fields\n\
- nosetdrv[@<off>] Set BPB's drive unit field at <o>\n\
+ nosetdrv[@<off>] Set BPB's drive unit field at <off>\n\
- <off> defaults to autodetection\n\
- only 0x24 and 0x40 are accepted\n\
nosetbpb Enable set{hid,geo,drv}\n\
grub=<loader> Load GRUB Legacy stage2\n\
grubcfg=<filename> Set alternative config filename for GRUB Legacy\n\
grldr=<loader> Load GRUB4DOS grldr\n\
-\nPlease see doc/chain.txt for the detailed documentation.\n"
+ bss=<filename> Emulate BSS (see doc/chain.txt for differences)\n\
+\nPlease see doc/chain.txt for the detailed documentation.\n\
+"
};
- error(usage[0]);
- error("Press any key...\n");
- wait_key();
- error(usage[1]);
+ for (i = 0; i < sizeof(usage)/sizeof(usage[0]); i++) {
+ if (i) {
+ error(key);
+ wait_key();
+ }
+ error(usage[i]);
+ }
}
int parse_args(int argc, char *argv[])
} else if (!strncmp(argv[i], "seg=", 4)) {
if (soi_s2n(argv[i] + 4, &opt.fseg, &opt.foff, &opt.fip))
goto bail;
+ } else if (!strncmp(argv[i], "bss=", 4)) {
+ opt.file = argv[i] + 4;
+ opt.maps = false;
+ opt.sethid = true;
+ opt.setgeo = true;
+ opt.setdrv = true;
+ opt.drvoff = ~0u;
+ opt.filebpb = true;
} else if (!strncmp(argv[i], "isolinux=", 9)) {
opt.file = argv[i] + 9;
opt.isolinux = true;