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

Dustin Kirkland dustin.kirkland at us.ibm.com
Thu Apr 19 11:08:52 EST 2007


On Thu, 2007-03-01 at 08:37 -0600, Dustin Kirkland wrote:
> 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> 

Patch updated against current git.  No functional changes.

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;





More information about the Yaboot-devel mailing list