]> git.ozlabs.org Git - yaboot.git/blobdiff - second/file.c
Don't use ELF entry point.
[yaboot.git] / second / file.c
index 0278dfaed5302d52050f8da097d0fccbf291c8d5..ed70376be542670865c249a52e1086381418acd3 100644 (file)
@@ -1,7 +1,7 @@
 /*
  *  file.c - Filesystem related interfaces
  *
- *  Copyright (C) 2001 Ethan Benson
+ *  Copyright (C) 2001, 2002 Ethan Benson
  *
  *  parse_device_path()
  *
@@ -78,8 +78,8 @@ parse_device_path(char *imagepath, char *defdevice, int defpart,
 
      if (!imagepath)
          return 0;
-     else
-         ipath = strdup(imagepath);
+     else if (!(ipath = strdup(imagepath))) 
+         return 0;
 
      if (defdevice)
          defdev = strdup(defdevice);
@@ -89,6 +89,8 @@ parse_device_path(char *imagepath, char *defdevice, int defpart,
               if ((ptr = strrchr(defdev, ':')) != NULL)
                    *ptr = 0; /* remove trailing : from defdevice if necessary */
          }
+     } else {
+         return 0;
      }
 
      /* if there is no : then there is no filename or partition.  must
@@ -123,6 +125,7 @@ parse_device_path(char *imagepath, char *defdevice, int defpart,
      } else if (strlen(ipath)) {
           result->file = strdup(ipath);
      } else {
+         free(defdev);
          return 0;
      }
 
@@ -137,7 +140,7 @@ parse_device_path(char *imagepath, char *defdevice, int defpart,
 
      free(ipath);
      if (defdev)
-         free(defdev);
+          free(defdev);
      return 1;
 }
 
@@ -166,8 +169,12 @@ file_block_open(   struct boot_file_t*     file,
                  p->part_number, p->part_start, p->part_size );
          if (partition == -1) {
               file->fs = fs_open( file, dev_name, p, file_name );
-              if (file->fs != NULL)
-                   goto bail;
+              if (file->fs == NULL || fserrorno != FILE_ERR_OK)
+                   continue;
+              else {
+                   partition = p->part_number;
+                   goto done;
+              }
          }
          if ((partition >= 0) && (partition == p->part_number))
               found = p;
@@ -183,7 +190,7 @@ file_block_open(    struct boot_file_t*     file,
      DEBUG_F( "Using OF defaults.. (found = %p)\n", found );
      file->fs = fs_open( file, dev_name, found, file_name );
 
-bail:
+done:
      if (parts)
          partitions_free(parts);