From: Shao Miller Date: Sat, 3 Jul 2010 07:47:25 +0000 (-0400) Subject: libinstaller: Add --mbr, --active, and --force options X-Git-Tag: syslinux-4.02-pre3^2~2 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=07b70a5266d694c954082b301a205225a892184f;p=profile%2Fivi%2Fsyslinux.git libinstaller: Add --mbr, --active, and --force options In order to consolidate the installer option-parsing system, we add the --mbr (-m), --active (-a), and --force (-f) options from the DOS, Win32, and mtools installers to libinstaller. Since the -m and -a options are not currently valid for the Linux 'syslinux' and 'extlinux' installers, we add error messages to both of these. The -f option is allowed but does nothing for them. Signed-off-by: Shao Miller --- diff --git a/extlinux/main.c b/extlinux/main.c index daebc10..a541e38 100644 --- a/extlinux/main.c +++ b/extlinux/main.c @@ -809,7 +809,7 @@ int main(int argc, char *argv[]) { parse_options(argc, argv, MODE_EXTLINUX); - if (!opt.directory) + if (!opt.directory || opt.install_mbr || opt.activate_partition || opt.force) usage(EX_USAGE, 0); if (opt.update_only == -1) { diff --git a/libinstaller/syslxopt.c b/libinstaller/syslxopt.c index 0ff2efb..8aee160 100644 --- a/libinstaller/syslxopt.c +++ b/libinstaller/syslxopt.c @@ -40,10 +40,13 @@ struct sys_options opt = { .device = NULL, .offset = 0, .menu_save = NULL, + .install_mbr = 0, + .activate_partition = 0, + .force = 0, }; const struct option long_options[] = { - {"force", 0, NULL, 'f'}, /* dummy option for compatibility */ + {"force", 0, NULL, 'f'}, /* DOS/Win32/mtools only */ {"install", 0, NULL, 'i'}, {"directory", 1, NULL, 'd'}, {"offset", 1, NULL, 't'}, @@ -59,10 +62,12 @@ const struct option long_options[] = { {"clear-once", 0, NULL, 'O'}, {"reset-adv", 0, NULL, OPT_RESET_ADV}, {"menu-save", 1, NULL, 'M'}, + {"mbr", 0, NULL, 'm'}, /* DOS/Win32 only */ + {"active", 0, NULL, 'a'}, /* DOS/Win32 only */ {0, 0, 0, 0} }; -const char short_options[] = "t:fid:UuzS:H:rvho:OM:"; +const char short_options[] = "t:fid:UuzS:H:rvho:OM:ma"; void __attribute__ ((noreturn)) usage(int rv, enum syslinux_mode mode) { @@ -97,6 +102,9 @@ void __attribute__ ((noreturn)) usage(int rv, enum syslinux_mode mode) " --clear-once -O Clear the boot-once command\n" " --reset-adv Reset auxilliary data\n" " --menu-save= -M Set the label to select as default on the next boot\n" + " --mbr -m Install an MBR (DOS/Win32 installers only)\n" + " --active -a Mark partition as active (DOS/Win32 installers only)\n" + " --force -f Ignore precautions (DOS/Win32/mtools installers only)\n" "\n" " Note: geometry is determined at boot time for devices which\n" " are considered hard disks by the BIOS. Unfortunately, this is\n" @@ -119,6 +127,7 @@ void parse_options(int argc, char *argv[], enum syslinux_mode mode) long_options, NULL)) != EOF) { switch (o) { case 'f': + opt.force = 1; break; case 'z': opt.heads = 64; @@ -183,6 +192,12 @@ void parse_options(int argc, char *argv[], enum syslinux_mode mode) case 'M': opt.menu_save = optarg; break; + case 'm': + opt.install_mbr = 1; + break; + case 'a': + opt.activate_partition = 1; + break; case 'v': fprintf(stderr, "%s " VERSION_STR " Copyright 1994-" YEAR_STR diff --git a/libinstaller/syslxopt.h b/libinstaller/syslxopt.h index 446ab9a..6fdf1d9 100644 --- a/libinstaller/syslxopt.h +++ b/libinstaller/syslxopt.h @@ -14,6 +14,9 @@ struct sys_options { const char *device; unsigned int offset; const char *menu_save; + int force; + int install_mbr; + int activate_partition; }; enum long_only_opt { diff --git a/linux/syslinux.c b/linux/syslinux.c index 9462138..9807bdf 100644 --- a/linux/syslinux.c +++ b/linux/syslinux.c @@ -273,7 +273,7 @@ int main(int argc, char *argv[]) subdir = "/"; } - if (!opt.device) + if (!opt.device || opt.install_mbr || opt.activate_partition || opt.force) usage(EX_USAGE, MODE_SYSLINUX); /*