[PATCH 2/4] read boot-once, zero out, set bootoncelabel as default

Dustin Kirkland dustin.kirkland at us.ibm.com
Fri Mar 2 01:37:43 EST 2007


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 <dustin.kirkland at us.ibm.com>


diff --git a/second/yaboot.c b/second/yaboot.c
index d7a3a20..5bbf351 100644
--- a/second/yaboot.c
+++ b/second/yaboot.c
@@ -112,6 +112,7 @@ static void     setup_display(void);
 
 int useconf = 0;
 char bootdevice[1024];
+char bootoncelabel[1024];
 char *password = NULL;
 struct boot_fspec_t boot;
 int _machine = _MACH_Pmac;
@@ -654,8 +655,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)
@@ -1485,6 +1490,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;





More information about the Yaboot-devel mailing list