libinstaller: Add --mbr, --active, and --force options
authorShao Miller <shao.miller@yrdsb.edu.on.ca>
Sat, 3 Jul 2010 07:47:25 +0000 (03:47 -0400)
committerShao Miller <shao.miller@yrdsb.edu.on.ca>
Sat, 10 Jul 2010 04:26:23 +0000 (21:26 -0700)
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 <shao.miller@yrdsb.edu.on.ca>
extlinux/main.c
libinstaller/syslxopt.c
libinstaller/syslxopt.h
linux/syslinux.c

index daebc10..a541e38 100644 (file)
@@ -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) {
index 0ff2efb..8aee160 100644 (file)
@@ -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
index 446ab9a..6fdf1d9 100644 (file)
@@ -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 {
index 9462138..9807bdf 100644 (file)
@@ -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);
 
     /*