[syslinux:pathbased] syslinux: provide for backwards compatibility

syslinux-bot for H. Peter Anvin hpa at linux.intel.com
Wed Jun 9 17:48:06 PDT 2010


Commit-ID:  a556d59a601697857e8a034d97cb4347f766cddd
Gitweb:     http://syslinux.zytor.com/commit/a556d59a601697857e8a034d97cb4347f766cddd
Author:     H. Peter Anvin <hpa at linux.intel.com>
AuthorDate: Wed, 9 Jun 2010 17:45:47 -0700
Committer:  H. Peter Anvin <hpa at linux.intel.com>
CommitDate: Wed, 9 Jun 2010 17:45:47 -0700

syslinux: provide for backwards compatibility

Provide for backwards command-line compatibility, together with
warning messages where appropriate.

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


---
 libinstaller/syslxopt.c |   33 ++++++++++++++++++++++-----------
 linux/syslinux.c        |    6 ++++--
 2 files changed, 26 insertions(+), 13 deletions(-)

diff --git a/libinstaller/syslxopt.c b/libinstaller/syslxopt.c
index 6b23a61..5c172d4 100644
--- a/libinstaller/syslxopt.c
+++ b/libinstaller/syslxopt.c
@@ -61,7 +61,7 @@ const struct option long_options[] = {
     {0, 0, 0, 0}
 };
 
-const char short_options[] = "tfid:UuzS:H:rvho:OM:";
+const char short_options[] = "t:fid:UuzS:H:rvho:OM:";
 
 void __attribute__ ((noreturn)) usage(int rv, enum syslinux_mode mode)
 {
@@ -70,7 +70,7 @@ void __attribute__ ((noreturn)) usage(int rv, enum syslinux_mode mode)
 	/* For unmounted fs installation (syslinux) */
 	fprintf(stderr,
 	    "Usage: %s [options] device\n"
-	    "  --offset     -t Offset of the file system on the device \n"
+	    "  --offset     -t  Offset of the file system on the device \n"
 	    "  --directory  -d  Directory for installation target\n",
 	    program);
 	break;
@@ -159,7 +159,7 @@ void parse_options(int argc, char *argv[], enum syslinux_mode mode)
 	    break;
 	case 'o':
 	    if (mode == MODE_SYSLINUX) {
-		fprintf(stderr,	"Warning: -o will change meaning in a future version, use -t or --offset\n");
+		fprintf(stderr,	"%s: -o will change meaning in a future version, use -t or --offset\n", program);
 		goto opt_offset;
 	    }
 	    /* else fall through */
@@ -167,8 +167,9 @@ void parse_options(int argc, char *argv[], enum syslinux_mode mode)
 	    opt.set_once = optarg;
 	    break;
 	case 't':
-opt_offset:
+	opt_offset:
 	    opt.offset = strtoul(optarg, NULL, 0);
+	    break;
 	case 'O':
 	    opt.set_once = "";
 	    break;
@@ -181,16 +182,26 @@ opt_offset:
 	    opt.menu_save = optarg;
 	    break;
 	case 'v':
-	    fputs(program, stderr);
-	    fputs(" " VERSION_STR
-		  "  Copyright 1994-" YEAR_STR " H. Peter Anvin \n", stderr);
+	    fprintf(stderr,
+		    "%s " VERSION_STR "  Copyright 1994-" YEAR_STR
+		    " H. Peter Anvin et al\n", program);
 	    exit(0);
 	default:
+	    fprintf(stderr, "%s: Unknown option: -%c\n", program, optopt);
 	    usage(EX_USAGE, mode);
 	}
     }
-    if (mode)
-	opt.device = argv[optind];
-    else if (!opt.directory)
-	opt.directory = argv[optind];
+
+    switch (mode) {
+    case MODE_SYSLINUX:
+	opt.device = argv[optind++];
+	break;
+    case MODE_EXTLINUX:
+	if (!opt.directory)
+	    opt.directory = argv[optind++];
+	break;
+    }
+
+    if (argv[optind])
+	usage(EX_USAGE, mode);	/* Excess arguments */
 }
diff --git a/linux/syslinux.c b/linux/syslinux.c
index bd3c555..d8b3149 100644
--- a/linux/syslinux.c
+++ b/linux/syslinux.c
@@ -399,8 +399,10 @@ int main(int argc, char *argv[])
 	    sync();
 	    rmdir(mntpath);
 	    exit(0);
-	} else
-	    usage(EX_USAGE, MODE_SYSLINUX);
+	} else {
+	    fprintf(stderr, "%s: please specify --install or --update for the future\n", argv[0]);
+	    opt.update_only = 0;
+	}
     }
 
     /* Read a pre-existing ADV, if already installed */



More information about the Syslinux-commits mailing list