diff options
author | Michal Soltys <soltys@ziu.info> | 2010-10-05 23:27:03 +0200 |
---|---|---|
committer | Michal Soltys <soltys@ziu.info> | 2010-10-08 12:40:51 +0200 |
commit | eadb9947a49e7ddc2ce29e567ae70c2c02e7571a (patch) | |
tree | 8813a832613a00aecf958499c6047a5b58954936 /com32/chain | |
parent | dfc78281b079868a640bab1915502b61626b35d5 (diff) | |
download | syslinux-eadb9947a49e7ddc2ce29e567ae70c2c02e7571a.tar.gz |
com32/chain: allow service-only runs
This patch introduces small feature, allowing so called "service-only"
runs - where the chain modules does everything as instructed, but
otherwise doesn't perform actual chainloading.
This is useful for 'mbrchs', '[un]hide[all]' and 'setbpb'+'save'
options, making possible adjustments to partition/boot sector values on
any disk/partition.
See 'chain' option in doc/chain.txt for more details.
Signed-off-by: Michal Soltys <soltys@ziu.info>
Diffstat (limited to 'com32/chain')
-rw-r--r-- | com32/chain/chain.c | 14 | ||||
-rw-r--r-- | com32/chain/options.c | 29 | ||||
-rw-r--r-- | com32/chain/options.h | 1 |
3 files changed, 31 insertions, 13 deletions
diff --git a/com32/chain/chain.c b/com32/chain/chain.c index 25d8fa75..73d107d8 100644 --- a/com32/chain/chain.c +++ b/com32/chain/chain.c @@ -662,9 +662,10 @@ int main(int argc, char *argv[]) memset(&hdat, 0, sizeof(hdat)); memset(&sdat, 0, sizeof(sdat)); memset(&opt, 0, sizeof(opt)); - opt.sect = true; /* by def load sector */ - opt.maps = true; /* by def map sector */ - opt.hand = true; /* by def prepare handover */ + opt.sect = true; /* by def. load sector */ + opt.maps = true; /* by def. map sector */ + opt.hand = true; /* by def. prepare handover */ + opt.chain = true; /* by def. do chainload */ opt.foff = opt.soff = opt.fip = opt.sip = 0x7C00; opt.drivename = "boot"; #ifdef DEBUG @@ -777,7 +778,7 @@ int main(int argc, char *argv[]) goto bail; /* - * Prepare boot-time mmap data We should to it here, as manglers could + * Prepare boot-time mmap data. We should to it here, as manglers could * potentially alter some of the data. */ @@ -806,7 +807,10 @@ int main(int argc, char *argv[]) wait_key(); } - do_boot(data, ndata); + if (ndata && opt.chain) /* boot only if we actually chainload */ + do_boot(data, ndata); + else + error("Service-only run completed, exiting.\n"); bail: pi_del(&iter); /* Free allocated areas */ diff --git a/com32/chain/options.c b/com32/chain/options.c index 2c3d0ff8..53810da7 100644 --- a/com32/chain/options.c +++ b/com32/chain/options.c @@ -65,10 +65,6 @@ Usage:\n\ chain.c32 fs [options]\n\ ", "\ \nOptions ('no' prefix specifies default value):\n\ - file=<file> Load and execute <file>\n\ - seg=<s[:o[:i]]> Load file at <s:o>, jump to <s:i>\n\ - - defaults to 0:0x7C00:0x7C00\n\ - - ommited o/i values default to 0\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 to 0x7C00\n\ @@ -78,17 +74,23 @@ Usage:\n\ nosave Write adjusted sector back to disk\n\ hand Prepare handover area\n\ nohptr Force ds:si and ds:bp to point to handover area\n\ - bss=<filename> Emulate syslinux's BSS\n\ - bs=<filename> Emulate syslinux's BS\n\ noswap Swap drive numbers, if bootdisk is not fd0/hd0\n\ - nohide Hide primary partitions, unhide selected partition\n\ - nohideall Hide *all* partitions, unhide selected partition\n\ + nohide Disable all hide variations (also the default)\n\ + hide Hide primary partitions, unhide selected partition\n\ + hideall Hide *all* partitions, unhide selected partition\n\ + unhide Unhide primary partitions\n\ + unhideall Unhide *all* partitions\n\ nombrchs Walk *all* partitions and fix E/MBRs' chs values\n\ nokeeppxe Keep the PXE and UNDI stacks in memory (PXELINUX)\n\ nowarn Wait for a keypress to continue chainloading\n\ - useful to see emited warnings\n\ + chain Actually perform the chainloading\n\ ", "\ \nOptions continued ...\n\ + file=<file> Load and execute <file>\n\ + seg=<s[:o[:i]]> Load file at <s:o>, jump to <s:i>\n\ + - defaults to 0:0x7C00:0x7C00\n\ + - ommited o/i values default to 0\n\ isolinux=<loader> Load another version of ISOLINUX\n\ ntldr=<loader> Load Windows NTLDR, SETUPLDR.BIN or BOOTMGR\n\ cmldr=<loader> Load Recovery Console of Windows NT/2K/XP/2003\n\ @@ -100,6 +102,8 @@ Usage:\n\ grub=<loader> Load GRUB Legacy stage2\n\ grubcfg=<filename> Set alternative config filename for GRUB Legacy\n\ grldr=<loader> Load GRUB4DOS grldr\n\ + bss=<filename> Emulate syslinux's BSS\n\ + bs=<filename> Emulate syslinux's BS\n\ \nPlease see doc/chain.txt for the detailed documentation.\n\ " }; @@ -268,6 +272,13 @@ int parse_args(int argc, char *argv[]) opt.warn = true; } else if (!strcmp(argv[i], "nowarn")) { opt.warn = false; + } else if (!strcmp(argv[i], "chain")) { + opt.chain = true; + } else if (!strcmp(argv[i], "nochain")) { + opt.chain = false; + opt.file = NULL; + opt.maps = false; + opt.hand = false; } else if (((argv[i][0] == 'h' || argv[i][0] == 'f') && argv[i][1] == 'd') || !strncmp(argv[i], "mbr:", 4) @@ -302,10 +313,12 @@ int parse_args(int argc, char *argv[]) goto bail; } +#if 0 if ((!opt.maps || !opt.sect) && !opt.file) { error("You have to load something.\n"); goto bail; } +#endif if (opt.filebpb && !opt.file) { error("Option 'filebpb' requires a file.\n"); diff --git a/com32/chain/options.h b/com32/chain/options.h index ee15768c..bc244f60 100644 --- a/com32/chain/options.h +++ b/com32/chain/options.h @@ -29,6 +29,7 @@ struct options { bool filebpb; bool mbrchs; bool warn; + bool chain; uint16_t keeppxe; struct syslinux_rm_regs regs; }; |