]> git.ipfire.org Git - thirdparty/grub.git/commitdiff
Prefer rockridge over Joliet.
authorVladimir 'phcoder' Serbinenko <phcoder@gmail.com>
Fri, 28 Oct 2011 14:26:17 +0000 (16:26 +0200)
committerVladimir 'phcoder' Serbinenko <phcoder@gmail.com>
Fri, 28 Oct 2011 14:26:17 +0000 (16:26 +0200)
* grub-core/fs/iso9660.c (grub_iso9660_mount): Move rockridge detection
to ...
(set_rockridge): ... here.
(grub_iso9660_mount): Check rockridge on the primary label when
discovering. Ignore Joliet if Rockridge is present.

ChangeLog
grub-core/fs/iso9660.c

index 979b5335a87ad17c72e1ce44f196b363c7c34e8c..deaa6ba68bbef426ff3a9da667b04746eecf7f5b 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,13 @@
+2011-10-28  Vladimir Serbinenko  <phcoder@gmail.com>
+
+       Prefer rockridge over Joliet.
+
+       * grub-core/fs/iso9660.c (grub_iso9660_mount): Move rockridge detection
+       to ...
+       (set_rockridge): ... here.
+       (grub_iso9660_mount): Check rockridge on the primary label when
+       discovering. Ignore Joliet if Rockridge is present.
+
 2011-10-28  Vladimir Serbinenko  <phcoder@gmail.com>
 
        Use shifts in nilfs2.
index f3e828b890c33d36726dc8c74d1d3901f19c9c6e..a2e731351863a3f60b97edb77a6193e86a06646b 100644 (file)
@@ -347,17 +347,14 @@ grub_iso9660_convert_string (grub_uint16_t *us, int len)
   return p;
 }
 
-static struct grub_iso9660_data *
-grub_iso9660_mount (grub_disk_t disk)
+static grub_err_t
+set_rockridge (struct grub_iso9660_data *data)
 {
-  struct grub_iso9660_data *data = 0;
-  struct grub_iso9660_dir rootdir;
   int sua_pos;
   int sua_size;
   char *sua;
+  struct grub_iso9660_dir rootdir;
   struct grub_iso9660_susp_entry *entry;
-  struct grub_iso9660_primary_voldesc voldesc;
-  int block;
 
   auto grub_err_t susp_iterate (struct grub_iso9660_susp_entry *);
 
@@ -373,79 +370,32 @@ grub_iso9660_mount (grub_disk_t disk)
       return 0;
     }
 
-  data = grub_zalloc (sizeof (struct grub_iso9660_data));
-  if (! data)
-    return 0;
-
-  data->disk = disk;
-
-  block = 16;
-  do
-    {
-      int copy_voldesc = 0;
-
-      /* Read the superblock.  */
-      if (grub_disk_read (disk, block << GRUB_ISO9660_LOG2_BLKSZ, 0,
-                         sizeof (struct grub_iso9660_primary_voldesc),
-                         (char *) &voldesc))
-        {
-          grub_error (GRUB_ERR_BAD_FS, "not a ISO9660 filesystem");
-          goto fail;
-        }
-
-      if (grub_strncmp ((char *) voldesc.voldesc.magic, "CD001", 5) != 0)
-        {
-          grub_error (GRUB_ERR_BAD_FS, "not a ISO9660 filesystem");
-          goto fail;
-        }
-
-      if (voldesc.voldesc.type == GRUB_ISO9660_VOLDESC_PRIMARY)
-        copy_voldesc = 1;
-      else if ((voldesc.voldesc.type == GRUB_ISO9660_VOLDESC_SUPP) &&
-               (voldesc.escape[0] == 0x25) && (voldesc.escape[1] == 0x2f) &&
-               ((voldesc.escape[2] == 0x40) || /* UCS-2 Level 1.  */
-                (voldesc.escape[2] == 0x43) ||  /* UCS-2 Level 2.  */
-                (voldesc.escape[2] == 0x45)))  /* UCS-2 Level 3.  */
-        {
-          copy_voldesc = 1;
-          data->joliet = 1;
-        }
-
-      if (copy_voldesc)
-        grub_memcpy((char *) &data->voldesc, (char *) &voldesc,
-                    sizeof (struct grub_iso9660_primary_voldesc));
-
-      block++;
-    } while (voldesc.voldesc.type != GRUB_ISO9660_VOLDESC_END);
+  data->rockridge = 0;
 
   /* Read the system use area and test it to see if SUSP is
      supported.  */
-  if (grub_disk_read (disk, (grub_le_to_cpu32 (data->voldesc.rootdir.first_sector)
-                            << GRUB_ISO9660_LOG2_BLKSZ), 0,
+  if (grub_disk_read (data->disk,
+                     (grub_le_to_cpu32 (data->voldesc.rootdir.first_sector)
+                      << GRUB_ISO9660_LOG2_BLKSZ), 0,
                      sizeof (rootdir), (char *) &rootdir))
-    {
-      grub_error (GRUB_ERR_BAD_FS, "not a ISO9660 filesystem");
-      goto fail;
-    }
+    return grub_error (GRUB_ERR_BAD_FS, "not a ISO9660 filesystem");
 
   sua_pos = (sizeof (rootdir) + rootdir.namelen
             + (rootdir.namelen % 2) - 1);
   sua_size = rootdir.len - sua_pos;
 
   if (!sua_size)
-    return data;
+    return GRUB_ERR_NONE;
 
   sua = grub_malloc (sua_size);
   if (! sua)
-    goto fail;
+    return grub_errno;
 
-  if (grub_disk_read (disk, (grub_le_to_cpu32 (data->voldesc.rootdir.first_sector)
-                            << GRUB_ISO9660_LOG2_BLKSZ), sua_pos,
+  if (grub_disk_read (data->disk,
+                     (grub_le_to_cpu32 (data->voldesc.rootdir.first_sector)
+                      << GRUB_ISO9660_LOG2_BLKSZ), sua_pos,
                      sua_size, sua))
-    {
-      grub_error (GRUB_ERR_BAD_FS, "not a ISO9660 filesystem");
-      goto fail;
-    }
+    return grub_error (GRUB_ERR_BAD_FS, "not a ISO9660 filesystem");
 
   entry = (struct grub_iso9660_susp_entry *) sua;
 
@@ -469,8 +419,68 @@ grub_iso9660_mount (grub_disk_t disk)
         extensions.  */
       if (grub_iso9660_susp_iterate (&rootnode,
                                     sua_pos, sua_size, susp_iterate))
-       goto fail;
+       return grub_errno;
     }
+  return GRUB_ERR_NONE;
+}
+
+static struct grub_iso9660_data *
+grub_iso9660_mount (grub_disk_t disk)
+{
+  struct grub_iso9660_data *data = 0;
+  struct grub_iso9660_primary_voldesc voldesc;
+  int block;
+
+  data = grub_zalloc (sizeof (struct grub_iso9660_data));
+  if (! data)
+    return 0;
+
+  data->disk = disk;
+
+  block = 16;
+  do
+    {
+      int copy_voldesc = 0;
+
+      /* Read the superblock.  */
+      if (grub_disk_read (disk, block << GRUB_ISO9660_LOG2_BLKSZ, 0,
+                         sizeof (struct grub_iso9660_primary_voldesc),
+                         (char *) &voldesc))
+        {
+          grub_error (GRUB_ERR_BAD_FS, "not a ISO9660 filesystem");
+          goto fail;
+        }
+
+      if (grub_strncmp ((char *) voldesc.voldesc.magic, "CD001", 5) != 0)
+        {
+          grub_error (GRUB_ERR_BAD_FS, "not a ISO9660 filesystem");
+          goto fail;
+        }
+
+      if (voldesc.voldesc.type == GRUB_ISO9660_VOLDESC_PRIMARY)
+       copy_voldesc = 1;
+      else if (!data->rockridge
+              && (voldesc.voldesc.type == GRUB_ISO9660_VOLDESC_SUPP)
+              && (voldesc.escape[0] == 0x25) && (voldesc.escape[1] == 0x2f)
+              &&
+               ((voldesc.escape[2] == 0x40) || /* UCS-2 Level 1.  */
+                (voldesc.escape[2] == 0x43) ||  /* UCS-2 Level 2.  */
+                (voldesc.escape[2] == 0x45)))  /* UCS-2 Level 3.  */
+        {
+          copy_voldesc = 1;
+          data->joliet = 1;
+        }
+
+      if (copy_voldesc)
+       {
+         grub_memcpy((char *) &data->voldesc, (char *) &voldesc,
+                     sizeof (struct grub_iso9660_primary_voldesc));
+         if (set_rockridge (data))
+           goto fail;
+       }
+
+      block++;
+    } while (voldesc.voldesc.type != GRUB_ISO9660_VOLDESC_END);
 
   return data;