From: Vladimir 'phcoder' Serbinenko Date: Fri, 28 Oct 2011 14:26:17 +0000 (+0200) Subject: Prefer rockridge over Joliet. X-Git-Tag: 2.00~1041 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=c39224b052b2322cc75bca9432fdb29617415c82;p=thirdparty%2Fgrub.git 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. --- diff --git a/ChangeLog b/ChangeLog index 979b5335a..deaa6ba68 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,13 @@ +2011-10-28 Vladimir Serbinenko + + 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 Use shifts in nilfs2. diff --git a/grub-core/fs/iso9660.c b/grub-core/fs/iso9660.c index f3e828b89..a2e731351 100644 --- a/grub-core/fs/iso9660.c +++ b/grub-core/fs/iso9660.c @@ -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;