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 *);
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;
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;