Received: from mailman by lists.gnu.org with archive (Exim 4.43) id 1JM8gJ-0000s8-7p for mharc-grub-devel@gnu.org; Mon, 04 Feb 2008 16:16:47 -0500 Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1JM8gH-0000oe-9Z for grub-devel@gnu.org; Mon, 04 Feb 2008 16:16:45 -0500 Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1JM8gG-0000nM-KP for grub-devel@gnu.org; Mon, 04 Feb 2008 16:16:44 -0500 Received: from [199.232.76.173] (helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1JM8gG-0000mw-CT for grub-devel@gnu.org; Mon, 04 Feb 2008 16:16:44 -0500 Received: from ti-out-0910.google.com ([209.85.142.189]) by monty-python.gnu.org with esmtp (Exim 4.60) (envelope-from ) id 1JM8gF-0007Km-Og for grub-devel@gnu.org; Mon, 04 Feb 2008 16:16:44 -0500 Received: by ti-out-0910.google.com with SMTP id a20so168942tia.10 for ; Mon, 04 Feb 2008 13:16:40 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:received:received:message-id:date:from:to:subject:in-reply-to:mime-version:content-type:content-transfer-encoding:content-disposition:references; bh=3ZCf6SysZnh9iHrAFgAkV3v9N5tT4XmuXlv+Gy3H9Eo=; b=xnvCdm1J/i5u0B8bjo2Mgsu5ij6BCQXYdd3Xn5WRycJkc/cejsxbuNVcFvXexgJ4I3WFtAdxRWSN7UHkjLc76F1Hk10j0PPKXY4sWzRmjJ2Jz5KJskS2F9KCSRVsgk13d5EOItw4mZpvV2gxHgqU/G7IT4sTyzqE4rYTQFPlA9Q= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=message-id:date:from:to:subject:in-reply-to:mime-version:content-type:content-transfer-encoding:content-disposition:references; b=Vn7kYNByh0y8imKugPBCJmHb+jZPlZ3YZtwDV5D2dMhnO3LGmfyP0yEpKcNZCBQj7o65JfbRL2YtTSeQfXtMy43o/Pl7UVEJtM+iji7KCunv6bJpwiIRFojZY7C5RNoYODj72w02qbEf68ae3FW3zhh11LR8NL1b95Jf61rCzLs= Received: by 10.110.73.3 with SMTP id v3mr3533619tia.21.1202159800638; Mon, 04 Feb 2008 13:16:40 -0800 (PST) Received: by 10.110.62.19 with HTTP; Mon, 4 Feb 2008 13:16:40 -0800 (PST) Message-ID: Date: Tue, 5 Feb 2008 05:16:40 +0800 From: Bean To: "The development of GRUB 2" In-Reply-To: <878x2090ru.fsf@xs4all.nl> MIME-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit Content-Disposition: inline References: <878x2090ru.fsf@xs4all.nl> X-detected-kernel: by monty-python.gnu.org: Linux 2.6 (newer, 2) Subject: Re: [PATCH] support joliet extension in iso9660 filesystem X-BeenThere: grub-devel@gnu.org X-Mailman-Version: 2.1.5 Precedence: list Reply-To: The development of GRUB 2 List-Id: The development of GRUB 2 List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 04 Feb 2008 21:16:45 -0000 On Feb 4, 2008 11:52 PM, Marco Gerards wrote: > > This patch add joliet extension support for iso9660. > > Great! Hopefully Rockridge still works? i have tested -R, -J and -R -J to build iso, it all works well. > > + int sec; > > sec? changed to block > Why did the indentation change for the lines above? I use -b option to create the patch, maybe i can some problem with indentation, it should be ok now. > > - grub_error (GRUB_ERR_BAD_FS, "not a iso9660 filesystem"); > > - goto fail; > > + is_copy = 1; > > is_copy? changed to copy_voldesc 2008-02-04 Bean * fs/iso9660.c (GRUB_ISO9660_VOLDESC_BOOT): New macro. (GRUB_ISO9660_VOLDESC_PRIMARY): Likewise. (GRUB_ISO9660_VOLDESC_SUPP): Likewise. (GRUB_ISO9660_VOLDESC_PART): Likewise. (GRUB_ISO9660_VOLDESC_END): Likewise. (grub_iso9660_primary_voldesc): New member escape. (grub_iso9660_data): New member joliet. (grub_iso9660_convert_string): New function. (grub_iso9660_mount): Detect joliet extension. (grub_iso9660_iterate_dir): Convert filename when joliet is detected. (grub_iso9660_iso9660_label): Likewise. diff --git a/fs/iso9660.c b/fs/iso9660.c index 15ce51d..374ec24 100644 --- a/fs/iso9660.c +++ b/fs/iso9660.c @@ -38,6 +38,12 @@ #define GRUB_ISO9660_RR_DOT 2 #define GRUB_ISO9660_RR_DOTDOT 4 +#define GRUB_ISO9660_VOLDESC_BOOT 0 +#define GRUB_ISO9660_VOLDESC_PRIMARY 1 +#define GRUB_ISO9660_VOLDESC_SUPP 2 +#define GRUB_ISO9660_VOLDESC_PART 3 +#define GRUB_ISO9660_VOLDESC_END 255 + /* The head of a volume descriptor. */ struct grub_iso9660_voldesc { @@ -67,11 +73,13 @@ struct grub_iso9660_primary_voldesc struct grub_iso9660_voldesc voldesc; grub_uint8_t unused1[33]; grub_uint8_t volname[32]; - grub_uint8_t unused2[60]; + grub_uint8_t unused2[16]; + grub_uint8_t escape[32]; + grub_uint8_t unused3[12]; grub_uint32_t path_table_size; - grub_uint8_t unused3[4]; + grub_uint8_t unused4[4]; grub_uint32_t path_table; - grub_uint8_t unused4[12]; + grub_uint8_t unused5[12]; struct grub_iso9660_dir rootdir; } __attribute__ ((packed)); @@ -115,6 +123,7 @@ struct grub_iso9660_data unsigned int length; int rockridge; int susp_skip; + int joliet; }; struct grub_fshelp_node @@ -197,6 +206,23 @@ grub_iso9660_susp_iterate (struct grub_iso9660_data *data, return 0; } +static char * +grub_iso9660_convert_string (grub_uint16_t *us, int len) +{ + char *p; + int i; + + p = grub_malloc (len * 4 + 1); + if (! p) + return p; + + for (i=0; ivoldesc)) - { - grub_error (GRUB_ERR_BAD_FS, "not a iso9660 filesystem"); - goto fail; - } - - if (grub_strncmp ((char *) data->voldesc.voldesc.magic, "CD001", 5) != 0) - { - grub_error (GRUB_ERR_BAD_FS, "not a iso9660 filesystem"); - goto fail; - } - data->disk = disk; data->rockridge = 0; - + data->joliet = 0; + + 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); + /* 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) @@ -254,14 +307,6 @@ grub_iso9660_mount (grub_disk_t disk) goto fail; } - if (grub_disk_read (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; - } - sua_pos = (sizeof (rootdir) + rootdir.namelen + (rootdir.namelen % 2) - 1); sua_size = rootdir.len - sua_pos; @@ -572,6 +617,20 @@ grub_iso9660_iterate_dir (grub_fshelp_node_t dir, filename = name; } + if (dir->data->joliet) + { + char *oldname; + + oldname = filename; + filename = grub_iso9660_convert_string + ((grub_uint16_t *) oldname, dirent.namelen >> 1); + + if (filename_alloc) + grub_free (oldname); + + filename_alloc = 1; + } + if (hook (filename, type, node)) { if (filename_alloc) @@ -740,7 +799,11 @@ grub_iso9660_label (grub_device_t device, char **label) if (data) { - *label = grub_strndup ((char *) data->voldesc.volname, 32); + if (data->joliet) + *label = grub_iso9660_convert_string + ((grub_uint16_t *) &data->voldesc.volname, 16); + else + *label = grub_strndup ((char *) data->voldesc.volname, 32); grub_free (data); } else -- Bean