[syslinux:master] extlinux: add --device option to override device detect

syslinux-bot for H. Peter Anvin hpa at zytor.com
Wed Jun 20 16:12:07 PDT 2012


Commit-ID:  3f51f9e151e1a0829ae6321320baa3b6e7c61877
Gitweb:     http://www.syslinux.org/commit/3f51f9e151e1a0829ae6321320baa3b6e7c61877
Author:     H. Peter Anvin <hpa at zytor.com>
AuthorDate: Wed, 20 Jun 2012 16:08:53 -0700
Committer:  H. Peter Anvin <hpa at zytor.com>
CommitDate: Wed, 20 Jun 2012 16:08:53 -0700

extlinux: add --device option to override device detect

Add a --device option for scripts and expert users to override the
device detection.

Signed-off-by: H. Peter Anvin <hpa at zytor.com>

---
 extlinux/main.c         |   11 ++++++++---
 libinstaller/syslxopt.c |    9 ++++++++-
 libinstaller/syslxopt.h |    1 +
 man/extlinux.1          |   11 ++++++++++-
 4 files changed, 27 insertions(+), 5 deletions(-)

diff --git a/extlinux/main.c b/extlinux/main.c
index 6375166..73f3fbe 100644
--- a/extlinux/main.c
+++ b/extlinux/main.c
@@ -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) {
diff --git a/libinstaller/syslxopt.c b/libinstaller/syslxopt.c
index e081a00..dde4969 100644
--- a/libinstaller/syslxopt.c
+++ b/libinstaller/syslxopt.c
@@ -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
diff --git a/libinstaller/syslxopt.h b/libinstaller/syslxopt.h
index bcbe035..042301f 100644
--- a/libinstaller/syslxopt.h
+++ b/libinstaller/syslxopt.h
@@ -24,6 +24,7 @@ enum long_only_opt {
     OPT_NONE,
     OPT_RESET_ADV,
     OPT_ONCE,
+    OPT_DEVICE,
 };
 
 enum syslinux_mode {
diff --git a/man/extlinux.1 b/man/extlinux.1
index 3192122..5daa4e5 100644
--- a/man/extlinux.1
+++ b/man/extlinux.1
@@ -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,


More information about the Syslinux-commits mailing list