Thomas Bächler
2010-Jun-07 19:23 UTC
[syslinux] [PATCH] extlinux: Add the --menu-save option to set the MENU SAVE value from the running system using extlinux
--- extlinux/main.c | 9 ++++++++- libinstaller/syslxopt.c | 8 +++++++- libinstaller/syslxopt.h | 1 + man/extlinux.1 | 3 +++ 4 files changed, 19 insertions(+), 2 deletions(-) diff --git a/extlinux/main.c b/extlinux/main.c index 0669bb9..8a0ac63 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 7718de3..728b19e 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 d925fa3..dfa6dc7 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 426eeb3..c29f524 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 -- 1.7.1
Apparently Analagous Threads
- [PATCH 1/8] extlinux/main.c: support unmounted ext2/3/4 filesystem
- [PATCH 0/9] linux/syslinux: support ext2/3/4 device
- [PATCH 0/9] linux/syslinux: support ext2/3/4 device
- [PATCH 0/8] extlinux: support unmounted ext2/3/4 filesystem
- syslinux-4.02-6-ge841d69 build failure