diff options
author | Thomas Bächler <thomas@archlinux.org> | 2010-06-07 21:23:46 +0200 |
---|---|---|
committer | H. Peter Anvin <hpa@linux.intel.com> | 2010-06-07 14:54:25 -0700 |
commit | 7f0b9b9404ba90009b656c80fb5caa444b47be9d (patch) | |
tree | a14504dda1a6fc1105cd7b68260c44b6670cea6d | |
parent | 068684738163202cbfe02eede0e9f7239492b35d (diff) | |
download | syslinux-7f0b9b9404ba90009b656c80fb5caa444b47be9d.tar.gz |
extlinux: add a --menu-save option
Add the --menu-save option to set the MENU SAVE value from the running
system using extlinux.
From: Thomas Bächler <thomas@archlinux.org>
Signed-off-by: H. Peter Anvin <hpa@linux.intel.com>
-rw-r--r-- | extlinux/main.c | 9 | ||||
-rw-r--r-- | libinstaller/syslxopt.c | 8 | ||||
-rw-r--r-- | libinstaller/syslxopt.h | 1 | ||||
-rw-r--r-- | man/extlinux.1 | 3 |
4 files changed, 19 insertions, 2 deletions
diff --git a/extlinux/main.c b/extlinux/main.c index 0669bb9c..8a0ac63b 100644 --- a/extlinux/main.c +++ b/extlinux/main.c @@ -381,6 +381,13 @@ int modify_adv(void) rv = -1; } } + if (opt.menu_save) { + if (syslinux_setadv(ADV_MENUSAVE, strlen(opt.menu_save), opt.menu_save)) { + fprintf(stderr, "%s: not enough space for menu-save label\n", + program); + rv = -1; + } + } return rv; } @@ -877,7 +884,7 @@ int main(int argc, char *argv[]) usage(EX_USAGE, 0); if (opt.update_only == -1) { - if (opt.reset_adv || opt.set_once) + if (opt.reset_adv || opt.set_once || opt.menu_save) return modify_existing_adv(opt.directory); else usage(EX_USAGE, 0); diff --git a/libinstaller/syslxopt.c b/libinstaller/syslxopt.c index 7718de3a..728b19e4 100644 --- a/libinstaller/syslxopt.c +++ b/libinstaller/syslxopt.c @@ -38,6 +38,7 @@ struct sys_options opt = { .directory = NULL, .device = NULL, .offset = 0, + .menu_save = NULL, }; const struct option long_options[] = { @@ -55,10 +56,11 @@ const struct option long_options[] = { {"once", 1, NULL, 'o'}, {"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:O"; +const char short_options[] = "id:f:UuzS:H:rvho:OM:"; void __attribute__ ((noreturn)) usage(int rv, int mode) { @@ -83,6 +85,7 @@ void __attribute__ ((noreturn)) usage(int rv, int mode) " --once=... -o 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" "\n" " Note: geometry is determined at boot time for devices which\n" " are considered hard disks by the BIOS. Unfortunately, this is\n" @@ -155,6 +158,9 @@ void parse_options(int argc, char *argv[], int mode) case OPT_RESET_ADV: opt.reset_adv = 1; break; + case 'M': + opt.menu_save = optarg; + break; case 'v': fputs(program, stderr); fputs(" " VERSION_STR diff --git a/libinstaller/syslxopt.h b/libinstaller/syslxopt.h index d925fa34..dfa6dc75 100644 --- a/libinstaller/syslxopt.h +++ b/libinstaller/syslxopt.h @@ -13,6 +13,7 @@ struct sys_options { const char *directory; const char *device; unsigned int offset; + const char *menu_save; }; enum long_only_opt { diff --git a/man/extlinux.1 b/man/extlinux.1 index 426eeb37..c29f5246 100644 --- a/man/extlinux.1 +++ b/man/extlinux.1 @@ -28,6 +28,9 @@ Clear the boot-once command. \fB\-o\fR, \fB\-\-once\fR=\fIcommand\fR Execute a command once upon boot. .TP +\fB\-M\fR, \fB\-\-menu\-save\fR=\fIlabel\fR +Set the label to select as default on the next boot +.TP \fB\-r\fR, \fB\-\-raid\fR Fall back to the next device on boot failure. .TP |