From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mailman by lists.gnu.org with archive (Exim 4.43) id 1KZs5Q-0004h2-HZ for mharc-grub-devel@gnu.org; Sun, 31 Aug 2008 14:55:44 -0400 Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1KZs5O-0004fU-Ru for grub-devel@gnu.org; Sun, 31 Aug 2008 14:55:42 -0400 Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1KZs5N-0004dh-3I for grub-devel@gnu.org; Sun, 31 Aug 2008 14:55:42 -0400 Received: from [199.232.76.173] (port=37581 helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1KZs5M-0004dY-Qc for grub-devel@gnu.org; Sun, 31 Aug 2008 14:55:40 -0400 Received: from moutng.kundenserver.de ([212.227.126.183]:50448) by monty-python.gnu.org with esmtp (Exim 4.60) (envelope-from ) id 1KZs5M-00062n-4I for grub-devel@gnu.org; Sun, 31 Aug 2008 14:55:40 -0400 Received: from [85.180.1.203] (e180001203.adsl.alicedsl.de [85.180.1.203]) by mrelayeu.kundenserver.de (node=mrelayeu0) with ESMTP (Nemesis) id 0MKwh2-1KZs5K3GLu-00074x; Sun, 31 Aug 2008 20:55:39 +0200 From: Felix Zielcke To: The development of GRUB 2 In-Reply-To: <20080831184044.GB8807@thorin> References: <1220127336.21696.30.camel@fz.local> <20080831134746.GD2688@thorin> <1220192824.4354.11.camel@fz.local> <20080831165647.GA32241@thorin> <1220203421.4354.34.camel@fz.local> <20080831184044.GB8807@thorin> Content-Type: multipart/mixed; boundary="=-svdrHa2WPnYOOAKunBId" Date: Sun, 31 Aug 2008 20:55:38 +0200 Message-Id: <1220208938.14424.8.camel@fz.local> Mime-Version: 1.0 X-Mailer: Evolution 2.22.3.1 X-Provags-ID: V01U2FsdGVkX1+dSCqOkFlrbi/PCtThafqUKcsqGwzcRpRqI+M /qxkeZ+w6wCSe4pP/Ak4tPaqEaDxhP7EPxaTB3mCS73TqLpLH2 LlPWCg3G7YYGzbpgdOFEylnIip1nQRt X-detected-kernel: by monty-python.gnu.org: Linux 2.6? (barebone, rare!) Subject: Re: [PATCH] iso9660 UUID support by using the creation date/time 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: Sun, 31 Aug 2008 18:55:43 -0000 --=-svdrHa2WPnYOOAKunBId Content-Type: text/plain Content-Transfer-Encoding: 7bit Am Sonntag, den 31.08.2008, 20:40 +0200 schrieb Robert Millan: > On Sun, Aug 31, 2008 at 07:23:41PM +0200, Felix Zielcke wrote: > > + *uuid = grub_malloc (sizeof ("YYYY-MM-DD-HH-mm-ss-hh") > > Lovely :-) > > > + sizeof ('\0')); > > Is this really needed? sizeof("foo") implicitly includes the trailing \0. Args, I'm blind :( I copied the function from fs/ntfs.c and there it says `grub_malloc 16 + sizeof (\0)' With "" it's useless so .5 attached so it doestn't get lost :) -- Felix Zielcke --=-svdrHa2WPnYOOAKunBId Content-Disposition: attachment; filename=iso9660_uuid.patch.5 Content-Type: text/plain; name=iso9660_uuid.patch.5; charset=UTF-8 Content-Transfer-Encoding: 7bit 2008-08-31 Felix Zielcke * fs/iso9660.c (grub_iso9660_date): New structure. (grub_iso9660_primary_voldesc): Add `grub_iso9660_date' member. (grub_iso9660_uuid): New function. Index: fs/iso9660.c =================================================================== --- fs/iso9660.c (Revision 1840) +++ fs/iso9660.c (Arbeitskopie) @@ -67,6 +67,18 @@ struct grub_iso9660_dir grub_uint8_t namelen; } __attribute__ ((packed)); +struct grub_iso9660_date +{ + grub_uint8_t year[4]; + grub_uint8_t month[2]; + grub_uint8_t day[2]; + grub_uint8_t hour[2]; + grub_uint8_t minute[2]; + grub_uint8_t second[2]; + grub_uint8_t hundredth[2]; + grub_uint8_t offset; +} __attribute__ ((packed)); + /* The primary volume descriptor. Only little endian is used. */ struct grub_iso9660_primary_voldesc { @@ -81,6 +93,8 @@ struct grub_iso9660_primary_voldesc grub_uint32_t path_table; grub_uint8_t unused5[12]; struct grub_iso9660_dir rootdir; + grub_uint8_t unused6[641]; + struct grub_iso9660_date created; } __attribute__ ((packed)); /* A single entry in the path table. */ @@ -812,6 +826,58 @@ grub_iso9660_label (grub_device_t device return grub_errno; } + +static grub_err_t +grub_iso9660_uuid (grub_device_t device, char **uuid) +{ + struct grub_iso9660_data *data; + grub_disk_t disk = device->disk; + +#ifndef GRUB_UTIL + grub_dl_ref (my_mod); +#endif + + data = grub_iso9660_mount (disk); + if (data) + { + if (! data->voldesc.created.year[0] && ! data->voldesc.created.year[1] + && ! data->voldesc.created.year[2] && ! data->voldesc.created.year[3] + && ! data->voldesc.created.month[0] && ! data->voldesc.created.month[1] + && ! data->voldesc.created.day[0] && ! data->voldesc.created.day[1] + && ! data->voldesc.created.hour[0] && ! data->voldesc.created.hour[1] + && ! data->voldesc.created.minute[0] && ! data->voldesc.created.minute[1] + && ! data->voldesc.created.second[0] && ! data->voldesc.created.second[1] + && ! data->voldesc.created.hundredth[0] && ! data->voldesc.created.hundredth[1]) + { + grub_error (GRUB_ERR_BAD_NUMBER, "No creation date in filesystem to generate UUID."); + *uuid = NULL; + } + else + { + *uuid = grub_malloc (sizeof ("YYYY-MM-DD-HH-mm-ss-hh")); + grub_sprintf (*uuid, "%c%c%c%c-%c%c-%c%c-%c%c-%c%c-%c%c-%c%c", + data->voldesc.created.year[0], data->voldesc.created.year[1], + data->voldesc.created.year[2], data->voldesc.created.year[3], + data->voldesc.created.month[0], data->voldesc.created.month[1], + data->voldesc.created.day[0], data->voldesc.created.day[1], + data->voldesc.created.hour[0], data->voldesc.created.hour[1], + data->voldesc.created.minute[0], data->voldesc.created.minute[1], + data->voldesc.created.second[0], data->voldesc.created.second[1], + data->voldesc.created.hundredth[0], data->voldesc.created.hundredth[1]); + } + } + else + *uuid = NULL; + +#ifndef GRUB_UTIL + grub_dl_unref (my_mod); +#endif + + grub_free (data); + + return grub_errno; +} + static struct grub_fs grub_iso9660_fs = @@ -822,6 +888,7 @@ static struct grub_fs grub_iso9660_fs = .read = grub_iso9660_read, .close = grub_iso9660_close, .label = grub_iso9660_label, + .uuid = grub_iso9660_uuid, .next = 0 }; --=-svdrHa2WPnYOOAKunBId--