All of lore.kernel.org
 help / color / mirror / Atom feed
From: Robert Millan <rmh@aybabtu.com>
To: The development of GRUB 2 <grub-devel@gnu.org>
Subject: [PATCH] ntfs UUIDs (Re: UUID-based boot (Re: [PATCH] Environment block support for grub2))
Date: Sat, 7 Jun 2008 01:31:31 +0200	[thread overview]
Message-ID: <20080606233131.GA7956@thorin> (raw)
In-Reply-To: <ca0f59980806061022s336d0b90ie4a4643c3cb66dc0@mail.gmail.com>

[-- Attachment #1: Type: text/plain, Size: 787 bytes --]

On Sat, Jun 07, 2008 at 01:22:23AM +0800, Bean wrote:
> > Then for the Vista use case, I suppose the remaining questions are if NTFS
> > supports UUIDs (or otherwise we have to ressort to labels?), and if we can
> > extract filesystem metadata from Windows (if possible without requiring that
> > a Cygwin installation is present).
> 
> ntfs has a 64-bit serial number, it's not quite the same as uuid, but
> it can be used to identify the partition.

This patch adds the 64-bit serial number as UUID.  But I'm not sure what is the
"standard" method to stringify this number.  Apparently, Windows only prints
half of it in the dir command.

-- 
Robert Millan

<GPLv2> I know my rights; I want my phone call!
<DRM> What good is a phone call… if you are unable to speak?
(as seen on /.)

[-- Attachment #2: ntfs_uuid.diff --]
[-- Type: text/x-diff, Size: 2181 bytes --]

diff -x ChangeLog -x configure -x config.h.in -x CVS -x '*~' -x '*.mk' -urp ../grub2/fs/ntfs.c ./fs/ntfs.c
--- ../grub2/fs/ntfs.c	2008-05-29 15:02:13.000000000 +0200
+++ ./fs/ntfs.c	2008-06-07 01:28:13.000000000 +0200
@@ -830,6 +830,8 @@ grub_ntfs_mount (grub_disk_t disk)
       (disk, data->mft_start, 0, data->mft_size << BLK_SHR, data->mmft.buf))
     goto fail;
 
+  *((grub_uint64_t *) &data->uuid) = bpb.num_serial;
+
   if (fixup (data, data->mmft.buf, data->mft_size, "FILE"))
     goto fail;
 
@@ -1078,6 +1080,36 @@ fail:
   return grub_errno;
 }
 
+static grub_err_t
+grub_ntfs_uuid (grub_device_t device, char **uuid)
+{
+  struct grub_ntfs_data *data;
+  grub_disk_t disk = device->disk;
+
+#ifndef GRUB_UTIL
+  grub_dl_ref (my_mod);
+#endif
+
+  data = grub_ntfs_mount (disk);
+  if (data)
+    {
+      *uuid = grub_malloc (sizeof ("xxxx-xxxx-xxxx-xxxx"));
+      grub_sprintf (*uuid, "%04x-%04x-%04x-%04x",
+		    grub_le_to_cpu16 (data->uuid[0]), grub_le_to_cpu16 (data->uuid[1]),
+		    grub_le_to_cpu16 (data->uuid[2]), grub_le_to_cpu16 (data->uuid[3]));
+    }
+  else
+    *uuid = NULL;
+
+#ifndef GRUB_UTIL
+  grub_dl_unref (my_mod);
+#endif
+
+  grub_free (data);
+
+  return grub_errno;
+}
+
 static struct grub_fs grub_ntfs_fs = {
   .name = "ntfs",
   .dir = grub_ntfs_dir,
@@ -1085,6 +1117,7 @@ static struct grub_fs grub_ntfs_fs = {
   .read = grub_ntfs_read,
   .close = grub_ntfs_close,
   .label = grub_ntfs_label,
+  .uuid = grub_ntfs_uuid,
   .next = 0
 };
 
diff -x ChangeLog -x configure -x config.h.in -x CVS -x '*~' -x '*.mk' -urp ../grub2/include/grub/ntfs.h ./include/grub/ntfs.h
--- ../grub2/include/grub/ntfs.h	2008-04-07 16:34:45.000000000 +0200
+++ ./include/grub/ntfs.h	2008-06-07 01:17:44.000000000 +0200
@@ -115,7 +115,7 @@ struct grub_ntfs_bpb
   grub_int8_t reserved_4[3];
   grub_int8_t clusters_per_index;
   grub_int8_t reserved_5[3];
-  grub_uint64_t serial_number;
+  grub_uint64_t num_serial;
   grub_uint32_t checksum;
 } __attribute__ ((packed));
 
@@ -151,6 +151,7 @@ struct grub_ntfs_data
   grub_uint32_t spc;
   grub_uint32_t blocksize;
   grub_uint32_t mft_start;
+  grub_uint16_t uuid[4];
 };
 
 struct grub_ntfs_comp

  parent reply	other threads:[~2008-06-07  0:19 UTC|newest]

Thread overview: 23+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2008-05-30 20:27 [PATCH] Environment block support for grub2 Bean
2008-05-31 10:10 ` Robert Millan
2008-05-31 10:54   ` Bean
2008-05-31 11:39     ` Robert Millan
2008-05-31 12:09       ` Bean
2008-05-31 15:09         ` Bean
2008-06-03 21:09           ` Robert Millan
2008-06-04  3:49             ` Bean
2008-06-06 16:43               ` UUID-based boot (Re: [PATCH] Environment block support for grub2) Robert Millan
2008-06-06 17:22                 ` Bean
2008-06-06 22:03                   ` Robert Millan
2008-06-07  4:33                     ` Bean
2008-06-08 19:26                       ` Robert Millan
2008-06-07  7:24                     ` Vesa Jääskeläinen
2008-06-06 23:31                   ` Robert Millan [this message]
2008-06-07  5:44                     ` [PATCH] ntfs UUIDs (Re: UUID-based boot (Re: [PATCH] Environment block support for grub2)) Tomáš Ebenlendr
2008-06-08  3:34                       ` Pavel Roskin
2008-06-08 19:19                         ` Robert Millan
2008-05-31 15:21         ` [PATCH] Environment block support for grub2 Robert Millan
2008-06-13 22:48           ` Yoshinori K. Okuji
2008-06-14  3:41             ` Bean
2008-06-14 18:32               ` Robert Millan
2008-06-14 19:22                 ` Bean

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=20080606233131.GA7956@thorin \
    --to=rmh@aybabtu.com \
    --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.