aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--extlinux/main.c4
-rw-r--r--libinstaller/syslxopt.c43
-rw-r--r--libinstaller/syslxopt.h10
-rw-r--r--linux/syslinux.c6
4 files changed, 44 insertions, 19 deletions
diff --git a/extlinux/main.c b/extlinux/main.c
index e33e3ae0..c76add41 100644
--- a/extlinux/main.c
+++ b/extlinux/main.c
@@ -883,7 +883,7 @@ int modify_existing_adv(const char *path)
int main(int argc, char *argv[])
{
- parse_options(argc, argv, 0);
+ parse_options(argc, argv, MODE_EXTLINUX);
if (!opt.directory)
usage(EX_USAGE, 0);
@@ -892,7 +892,7 @@ int main(int argc, char *argv[])
if (opt.reset_adv || opt.set_once || opt.menu_save)
return modify_existing_adv(opt.directory);
else
- usage(EX_USAGE, 0);
+ usage(EX_USAGE, MODE_EXTLINUX);
}
return install_loader(opt.directory, opt.update_only);
diff --git a/libinstaller/syslxopt.c b/libinstaller/syslxopt.c
index 728b19e4..6b23a612 100644
--- a/libinstaller/syslxopt.c
+++ b/libinstaller/syslxopt.c
@@ -42,9 +42,10 @@ struct sys_options opt = {
};
const struct option long_options[] = {
+ {"force", 0, NULL, 'f'}, /* dummy option for compatibility */
{"install", 0, NULL, 'i'},
{"directory", 1, NULL, 'd'},
- {"offset", 1, NULL, 'f'},
+ {"offset", 1, NULL, 't'},
{"update", 0, NULL, 'U'},
{"zipdrive", 0, NULL, 'z'},
{"sectors", 1, NULL, 'S'},
@@ -53,27 +54,36 @@ const struct option long_options[] = {
{"raid-mode", 0, NULL, 'r'},
{"version", 0, NULL, 'v'},
{"help", 0, NULL, 'h'},
- {"once", 1, NULL, 'o'},
+ {"once", 1, NULL, OPT_ONCE},
{"clear-once", 0, NULL, 'O'},
{"reset-adv", 0, NULL, OPT_RESET_ADV},
{"menu-save", 1, NULL, 'M'},
{0, 0, 0, 0}
};
-const char short_options[] = "id:f:UuzS:H:rvho:OM:";
+const char short_options[] = "tfid:UuzS:H:rvho:OM:";
-void __attribute__ ((noreturn)) usage(int rv, int mode)
+void __attribute__ ((noreturn)) usage(int rv, enum syslinux_mode mode)
{
- if (mode) /* for unmounted fs installation */
+ switch (mode) {
+ case MODE_SYSLINUX:
+ /* For unmounted fs installation (syslinux) */
fprintf(stderr,
"Usage: %s [options] device\n"
- " --offset -f 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);
- else /* actually extlinux can also use -d to provide directory too */
+ break;
+
+ case MODE_EXTLINUX:
+ /* Mounted fs installation (extlinux) */
+ /* Actually extlinux can also use -d to provide a directory too... */
fprintf(stderr,
"Usage: %s [options] directory\n",
program);
+ break;
+ }
+
fprintf(stderr,
" --install -i Install over the current bootsector\n"
" --update -U Update a previous EXTLINUX installation\n"
@@ -82,7 +92,7 @@ void __attribute__ ((noreturn)) usage(int rv, int mode)
" --heads=# -H Force number of heads\n"
" --stupid -s Slow, safe and stupid mode\n"
" --raid -r Fall back to the next device on boot failure\n"
- " --once=... -o Execute a command once upon boot\n"
+ " --once=... %s Execute a command once upon boot\n"
" --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"
@@ -93,13 +103,13 @@ void __attribute__ ((noreturn)) usage(int rv, int mode)
" which includes zipdisks and LS-120 superfloppies.\n"
"\n"
" The -z option is useful for USB devices which are considered\n"
- " hard disks by some BIOSes and zipdrives by other BIOSes.\n"
- );
+ " hard disks by some BIOSes and zipdrives by other BIOSes.\n",
+ mode == MODE_SYSLINUX ? " " : "-o");
exit(rv);
}
-void parse_options(int argc, char *argv[], int mode)
+void parse_options(int argc, char *argv[], enum syslinux_mode mode)
{
int o;
@@ -107,6 +117,8 @@ void parse_options(int argc, char *argv[], int mode)
while ((o = getopt_long(argc, argv, short_options,
long_options, NULL)) != EOF) {
switch (o) {
+ case 'f':
+ break;
case 'z':
opt.heads = 64;
opt.sectors = 32;
@@ -146,9 +158,16 @@ void parse_options(int argc, char *argv[], int mode)
usage(0, mode);
break;
case 'o':
+ if (mode == MODE_SYSLINUX) {
+ fprintf(stderr, "Warning: -o will change meaning in a future version, use -t or --offset\n");
+ goto opt_offset;
+ }
+ /* else fall through */
+ case OPT_ONCE:
opt.set_once = optarg;
break;
- case 'f':
+ case 't':
+opt_offset:
opt.offset = strtoul(optarg, NULL, 0);
case 'O':
opt.set_once = "";
diff --git a/libinstaller/syslxopt.h b/libinstaller/syslxopt.h
index dfa6dc75..ba60ce2f 100644
--- a/libinstaller/syslxopt.h
+++ b/libinstaller/syslxopt.h
@@ -19,10 +19,16 @@ struct sys_options {
enum long_only_opt {
OPT_NONE,
OPT_RESET_ADV,
+ OPT_ONCE,
};
-void __attribute__ ((noreturn)) usage(int rv, int mode);
-void parse_options(int argc, char *argv[], int mode);
+enum syslinux_mode {
+ MODE_SYSLINUX, /* Unmounted filesystem */
+ MODE_EXTLINUX,
+};
+
+void __attribute__ ((noreturn)) usage(int rv, enum syslinux_mode mode);
+void parse_options(int argc, char *argv[], enum syslinux_mode mode);
extern struct sys_options opt;
extern const struct option long_options[];
diff --git a/linux/syslinux.c b/linux/syslinux.c
index 1194fbb3..bd3c555c 100644
--- a/linux/syslinux.c
+++ b/linux/syslinux.c
@@ -286,12 +286,12 @@ int main(int argc, char *argv[])
mypid = getpid();
umask(077);
- parse_options(argc, argv, 1);
+ parse_options(argc, argv, MODE_SYSLINUX);
subdir = opt.directory;
if (!opt.device)
- usage(EX_USAGE, 1);
+ usage(EX_USAGE, MODE_SYSLINUX);
/*
* First make sure we can open the device at all, and that we have
@@ -400,7 +400,7 @@ int main(int argc, char *argv[])
rmdir(mntpath);
exit(0);
} else
- usage(EX_USAGE, 0);
+ usage(EX_USAGE, MODE_SYSLINUX);
}
/* Read a pre-existing ADV, if already installed */