From: Felix Zielcke <fzielcke@z-51.de>
To: The development of GRUB 2 <grub-devel@gnu.org>
Subject: Re: [PATCH] iso9660 UUID support by using the creation date/time
Date: Sun, 31 Aug 2008 16:27:04 +0200 [thread overview]
Message-ID: <1220192824.4354.11.camel@fz.local> (raw)
In-Reply-To: <20080831134746.GD2688@thorin>
[-- Attachment #1: Type: text/plain, Size: 1022 bytes --]
Hello list,
Am Sonntag, den 31.08.2008, 15:47 +0200 schrieb Robert Millan:
> Nice work :-)
By the way the TAB key on emacs is really nice you even don't need to
care about moving the cursor to the beginning of the line :)
> > The specs say that it's allowed to contain only zeros but I think this
> > shouldn't be a big problem.
>
> I think this could indeed be a problem if it leads to collisions. If "all
> zeroes" is detected, one could rise an error in uuid() function to prevent the
> caller from taking the value into consideration.
I have now used grub_error (GRUB_ERR_BAD_NUMBER)
But maybe it would be better to make a new type for this, though I don't
have yet an idea how to call it.
Suggestions please :)
> Since the string contains human-readable information, may I suggest separating
> it with dashes to make it easier to comprehend?
Good idea, I should have done that first that would make it even for me a bit easier.
I did it now even more human-readable for the `sizeof ()'
--
Felix Zielcke
[-- Attachment #2: iso9660_uuid.patch.3 --]
[-- Type: text/plain, Size: 3345 bytes --]
2008-08-31 Felix Zielcke <fzielcke@z-51.de>
* 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 1839)
+++ 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,8 +826,59 @@ grub_iso9660_label (grub_device_t device
return grub_errno;
}
-\f
+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") + sizeof ('\0'));
+ 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;
+}
+
+\f
static struct grub_fs grub_iso9660_fs =
{
.name = "iso9660",
@@ -822,6 +887,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
};
next prev parent reply other threads:[~2008-08-31 14:27 UTC|newest]
Thread overview: 13+ messages / expand[flat|nested] mbox.gz Atom feed top
2008-08-30 20:15 [PATCH] iso9660 UUID support by using the creation date/time Felix Zielcke
2008-08-30 21:08 ` Felix Zielcke
2008-08-31 13:47 ` Robert Millan
2008-08-31 14:27 ` Felix Zielcke [this message]
2008-08-31 15:06 ` Javier Martín
2008-08-31 16:03 ` Felix Zielcke
2008-08-31 16:56 ` Robert Millan
2008-08-31 17:23 ` Felix Zielcke
2008-08-31 18:40 ` Robert Millan
2008-08-31 18:55 ` Felix Zielcke
2008-09-05 17:02 ` Felix Zielcke
2008-09-06 11:11 ` Robert Millan
2008-09-06 11:17 ` Felix Zielcke
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1220192824.4354.11.camel@fz.local \
--to=fzielcke@z-51.de \
--cc=grub-devel@gnu.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.