[PATCH 2/3] PReP FAT support

Leonardo Rangel lrangel at linux.vnet.ibm.com
Fri Nov 9 04:55:24 EST 2007


Here we add the config file list, with the file names yaboot will look for,
and the function that will iterate through this list, trying to load  
the config files with that names.

In special cases were the user has explicitly informed the config file name
(ie: by using conf= argument), we ignore the config file list and simply try
to load the filename he informed.


Index: yaboot/second/yaboot.c
===================================================================
--- yaboot.orig/second/yaboot.c 2007-11-08 12:00:22.000000000 -0200
+++ yaboot/second/yaboot.c  2007-11-08 12:11:11.000000000 -0200
@@ -173,6 +173,14 @@

  static struct first_info *quik_fip = NULL;

+static const char *config_file_list[] = {
+    "/etc/yaboot.conf",
+    "yaboot.conf",
+    "yaboot.cnf",
+    NULL
+};
+
+
  int
  yaboot_start (unsigned long r3, unsigned long r4, unsigned long r5)
  {
@@ -341,6 +349,7 @@

       /* Open it */
       result = open_file(fspec, &file);
+     DEBUG_F("Trying to load config file: %s\n", fspec->file);
       if (result != FILE_ERR_OK) {
       prom_printf("%s:%d,", fspec->dev, fspec->part);
       prom_perror(result, fspec->file);
@@ -445,6 +454,26 @@
       return result;
  }

+
+static int
+iterate_and_load_config_file(struct boot_fspec_t *origfs){
+    int i, rc = 0;
+    struct boot_fspec_t fs;
+
+    for (i = 0; config_file_list[i]; i++) {
+        fs.dev = origfs->dev;
+        fs.part = origfs->part;
+        strcpy(fs.file,config_file_list[i]);
+
+        rc = load_config_file(&fs);
+
+        if (rc == 1)
+            return 1;
+        }
+    return 0;
+}
+
+
  /*
   * Search for config file by MAC address, then by IP address.
   * Basically copying pxelinux's algorithm.
@@ -922,6 +951,9 @@
                  }
              }

+            /* Attempt to load only the config file supplied by the user,
+             * not those on the list
+             */
              prom_printf("Loading config file...\n");
              useconf = load_config_file(&boot);
              if (useconf > 0){
@@ -1756,15 +1788,22 @@

       /*
        * If we're doing a netboot, first look for one which matches our
-      * MAC address.
+      * MAC or IP addresses.
        */
       if (prom_get_devtype(boot.dev) == FILE_DEVICE_NET) {
            prom_printf("Try to netboot\n");
       useconf = load_my_config_file(&boot);
       }

-     if (!useconf)
-         useconf = load_config_file(&boot);
+     /* No config file was informed. Iterating through the config_file_list
+      * to find a valid config file
+     */
+     if (!useconf){
+         if (conf_given)
+             useconf = load_config_file(&boot);
+         else
+             useconf = iterate_and_load_config_file(&boot);
+     }

       prom_printf("Welcome to yaboot version " VERSION "\n");
       prom_printf("Enter \"help\" to get some basic usage information\n");





More information about the Yaboot-devel mailing list