extlinux: add --device option to override device detect
authorH. Peter Anvin <hpa@zytor.com>
Wed, 20 Jun 2012 23:08:53 +0000 (16:08 -0700)
committerH. Peter Anvin <hpa@zytor.com>
Wed, 20 Jun 2012 23:08:53 +0000 (16:08 -0700)
Add a --device option for scripts and expert users to override the
device detection.

Signed-off-by: H. Peter Anvin <hpa@zytor.com>
extlinux/main.c
libinstaller/syslxopt.c
libinstaller/syslxopt.h
man/extlinux.1

index 6375166..73f3fbe 100644 (file)
@@ -1028,9 +1028,14 @@ static const char *get_devname(const char *path)
        return devname;
     }
 
-    if (fs_type == BTRFS) {
-       /* For btrfs try to get the device name from btrfs itself */
-       devname = find_device_btrfs(path);
+    if (opt.device)
+       devname = opt.device;
+
+    if (!devname){
+       if (fs_type == BTRFS) {
+           /* For btrfs try to get the device name from btrfs itself */
+           devname = find_device_btrfs(path);
+       }
     }
 
     if (!devname) {
index e081a00..dde4969 100644 (file)
@@ -66,6 +66,7 @@ const struct option long_options[] = {
     {"menu-save", 1, NULL, 'M'},
     {"mbr", 0, NULL, 'm'},     /* DOS/Win32 only */
     {"active", 0, NULL, 'a'},  /* DOS/Win32 only */
+    {"device", 1, NULL, OPT_DEVICE},
     {0, 0, 0, 0}
 };
 
@@ -87,7 +88,8 @@ void __attribute__ ((noreturn)) usage(int rv, enum syslinux_mode mode)
        /* Mounted fs installation (extlinux) */
        /* Actually extlinux can also use -d to provide a directory too... */
        fprintf(stderr,
-           "Usage: %s [options] directory\n",
+           "Usage: %s [options] directory\n"
+           "  --device         Force use of a specific block device (experts only)\n"
            program);
        break;
 
@@ -210,6 +212,11 @@ void parse_options(int argc, char *argv[], enum syslinux_mode mode)
        case 'a':
            opt.activate_partition = 1;
            break;
+       case OPT_DEVICE:
+           if (mode != EXTLINUX_MODE)
+               usage(EX_USAGE, mode);
+           opt.device = optarg;
+           break;
        case 'v':
            fprintf(stderr,
                    "%s " VERSION_STR "  Copyright 1994-" YEAR_STR
index bcbe035..042301f 100644 (file)
@@ -24,6 +24,7 @@ enum long_only_opt {
     OPT_NONE,
     OPT_RESET_ADV,
     OPT_ONCE,
+    OPT_DEVICE,
 };
 
 enum syslinux_mode {
index 3192122..5daa4e5 100644 (file)
@@ -45,8 +45,17 @@ Updates a previous \fBEXTLINUX\fP installation.
 .TP
 \fB\-z\fR, \fB\-\-zip\fR
 Force zipdrive geometry (-H 64 -S 32).
+.TP
+\fB\-\-device\fR=\fIdevicename\fR
+Override the automatic detection of device names.  This option is
+intended for special environments only and should not be used by
+normal users.  Misuse of this option can cause disk corruption and
+lost data.
 .SH FILES
-The extlinux configuration file needs to be named extlinux.conf and needs to be stored in the extlinux installation directory. For more information about the contents of extlinux.conf, see syslinux(1) manpage, section files.
+The extlinux configuration file needs to be named syslinux.cfg or
+extlinux.conf and needs to be stored in the extlinux installation
+directory. For more information about the contents of extlinux.conf,
+see syslinux(1) manpage, section files.
 .SH BUGS
 I would appreciate hearing of any problems you have with \s-1SYSLINUX\s+1.  I
 would also like to hear from you if you have successfully used \s-1SYSLINUX\s+1,