From 320a30ef3761980800710b9d8352229c53c36a43 Mon Sep 17 00:00:00 2001 From: Paul Nasrat Date: Thu, 19 Apr 2007 10:12:22 +0100 Subject: [PATCH] read boot-once, zero out, set bootoncelabel as default This patch reads the boot-once environment variable from Open Firmware and stores in a global variable, "bootoncelabel". It then unconditionally zeros out the boot-once environment variable. *** Note that according to 1275, setprop will create a specified environment variable if it doesn't already exist. A bug in nvsetenv causes it to fail silently if you try to set an OF environment variable that does not already exist. However, simply booting a system running a yaboot with this patch set compiled in will in fact create the boot-once environment variable, which nvsetenv can later set and reset. Signed-off-by: Dustin Kirkland --- second/yaboot.c | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) diff --git a/second/yaboot.c b/second/yaboot.c index 20296df..9b8fcc8 100644 --- a/second/yaboot.c +++ b/second/yaboot.c @@ -112,6 +112,7 @@ static void setup_display(void); int useconf = 0; char bootdevice[BOOTDEVSZ]; +char bootoncelabel[1024]; char bootargs[1024]; char *password = NULL; struct boot_fspec_t boot; @@ -764,8 +765,12 @@ int get_params(struct boot_param_t* params) } if (c == '\n' || c == '\r') { - if (!imagename) - imagename = cfg_get_default(); + if (!imagename) { + if (bootoncelabel[0] != 0) + imagename = bootoncelabel; + else + imagename = cfg_get_default(); + } if (imagename) prom_printf("%s", imagename); if (params->args) @@ -1625,6 +1630,14 @@ yaboot_main(void) return -1; } + if (bootoncelabel[0] == 0) { + prom_get_options("boot-once", bootoncelabel, + sizeof(bootoncelabel)); + if (bootoncelabel[0] != 0) + DEBUG_F("boot-once: [%s]\n", bootoncelabel); + } + prom_set_options("boot-once", NULL, 0); + if (!parse_device_path(bootdevice, NULL, -1, "", &boot)) { prom_printf("%s: Unable to parse\n", bootdevice); return -1; -- 2.39.2