]> git.ozlabs.org Git - yaboot.git/commitdiff
read boot-once, zero out, set bootoncelabel as default
authorPaul Nasrat <pnasrat@redhat.com>
Thu, 19 Apr 2007 09:12:22 +0000 (10:12 +0100)
committerPaul Nasrat <pauln@enki.eridu>
Thu, 19 Apr 2007 09:12:22 +0000 (10:12 +0100)
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@us.ibm.com>
second/yaboot.c

index 20296dfb5bfd6216bfca32b4e552bc9ef31f5078..9b8fcc8e301b9741d37b33585edbe085885b0a44 100644 (file)
@@ -112,6 +112,7 @@ static void     setup_display(void);
 
 int useconf = 0;
 char bootdevice[BOOTDEVSZ];
 
 int useconf = 0;
 char bootdevice[BOOTDEVSZ];
+char bootoncelabel[1024];
 char bootargs[1024];
 char *password = NULL;
 struct boot_fspec_t boot;
 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 (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)
          if (imagename)
               prom_printf("%s", imagename);
          if (params->args)
@@ -1625,6 +1630,14 @@ yaboot_main(void)
          return -1;
      }
 
          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;
      if (!parse_device_path(bootdevice, NULL, -1, "", &boot)) {
          prom_printf("%s: Unable to parse\n", bootdevice);
          return -1;