Received: from mailman by lists.gnu.org with archive (Exim 4.43) id 1K2Z0P-0006Op-2U for mharc-grub-devel@gnu.org; Sat, 31 May 2008 17:52:53 -0400 Received: from mailman by lists.gnu.org with tmda-scanned (Exim 4.43) id 1K2Z0N-0006OI-0l for grub-devel@gnu.org; Sat, 31 May 2008 17:52:51 -0400 Received: from exim by lists.gnu.org with spam-scanned (Exim 4.43) id 1K2Z0L-0006NY-5w for grub-devel@gnu.org; Sat, 31 May 2008 17:52:50 -0400 Received: from [199.232.76.173] (port=59408 helo=monty-python.gnu.org) by lists.gnu.org with esmtp (Exim 4.43) id 1K2Z0L-0006NK-0F for grub-devel@gnu.org; Sat, 31 May 2008 17:52:49 -0400 Received: from aybabtu.com ([69.60.117.155]:40093) by monty-python.gnu.org with esmtps (TLS-1.0:RSA_AES_256_CBC_SHA1:32) (Exim 4.60) (envelope-from ) id 1K2Z0K-0001ds-Hb for grub-devel@gnu.org; Sat, 31 May 2008 17:52:48 -0400 Received: from [192.168.10.10] (helo=thorin) by aybabtu.com with esmtps (TLS-1.0:RSA_AES_256_CBC_SHA1:32) (Exim 4.63) (envelope-from ) id 1K2Yzk-0005r9-9S for grub-devel@gnu.org; Sat, 31 May 2008 23:52:13 +0200 Received: from rmh by thorin with local (Exim 4.63) (envelope-from ) id 1K2Z02-0005B6-5c for grub-devel@gnu.org; Sat, 31 May 2008 23:52:30 +0200 Date: Sat, 31 May 2008 23:52:30 +0200 From: Robert Millan To: grub-devel@gnu.org Message-ID: <20080531215230.GA19893@thorin> MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="YZ5djTAD1cGYuMQK" Content-Disposition: inline Content-Transfer-Encoding: 8bit Organization: free as in freedom X-Message-Flag: Worried about Outlook viruses? Switch to Thunderbird! www.mozilla.com/thunderbird X-Debbugs-No-Ack: true User-Agent: Mutt/1.5.13 (2006-08-11) X-detected-kernel: by monty-python.gnu.org: Genre and OS details not recognized. Subject: [PATCH] reiserfs & xfs UUIDs 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: Sat, 31 May 2008 21:52:51 -0000 --YZ5djTAD1cGYuMQK Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: 8bit This patch adds support for UUIDs on reiserfs and xfs. -- Robert Millan I know my rights; I want my phone call! What good is a phone call… if you are unable to speak? (as seen on /.) --YZ5djTAD1cGYuMQK Content-Type: text/x-diff; charset=us-ascii Content-Disposition: attachment; filename="reiserfs_and_xfs.diff" 2008-05-31 Robert Millan * fs/reiserfs.c (grub_reiserfs_superblock): Add `uuid' field. (grub_reiserfs_uuid): New function. (grub_reiserfs_fs): Reference grub_reiserfs_uuid() in `uuid' struct member. * fs/xfs.c (grub_xfs_sblock): Add `uuid' field. (grub_xfs_uuid): New function. (grub_xfs_fs): Reference grub_reiserfs_uuid() in `uuid' struct member. diff -x configure -x config.h.in -x CVS -x '*~' -x '*.mk' -urp ../grub2/fs/reiserfs.c ./fs/reiserfs.c --- ../grub2/fs/reiserfs.c 2008-05-28 15:41:57.000000000 +0200 +++ ./fs/reiserfs.c 2008-05-31 23:47:45.000000000 +0200 @@ -108,6 +108,8 @@ struct grub_reiserfs_superblock grub_uint16_t version; grub_uint16_t reserved; grub_uint32_t inode_generation; + grub_uint8_t unused[4]; + grub_uint16_t uuid[8]; } __attribute__ ((packed)); struct grub_reiserfs_journal_header @@ -1468,6 +1470,38 @@ grub_reiserfs_label (grub_device_t devic return grub_errno; } +static grub_err_t +grub_reiserfs_uuid (grub_device_t device, char **uuid) +{ + struct grub_reiserfs_data *data; + grub_disk_t disk = device->disk; + +#ifndef GRUB_UTIL + grub_dl_ref (my_mod); +#endif + + data = grub_reiserfs_mount (disk); + if (data) + { + *uuid = grub_malloc (40 + sizeof ('\0')); + grub_sprintf (*uuid, "%04x%04x-%04x-%04x-%04x-%04x%04x%04x", + grub_be_to_cpu16 (data->superblock.uuid[0]), grub_be_to_cpu16 (data->superblock.uuid[1]), + grub_be_to_cpu16 (data->superblock.uuid[2]), grub_be_to_cpu16 (data->superblock.uuid[3]), + grub_be_to_cpu16 (data->superblock.uuid[4]), grub_be_to_cpu16 (data->superblock.uuid[5]), + grub_be_to_cpu16 (data->superblock.uuid[6]), grub_be_to_cpu16 (data->superblock.uuid[7])); + } + else + *uuid = NULL; + +#ifndef GRUB_UTIL + grub_dl_unref (my_mod); +#endif + + grub_free (data); + + return grub_errno; +} + static struct grub_fs grub_reiserfs_fs = { .name = "reiserfs", @@ -1476,6 +1510,7 @@ static struct grub_fs grub_reiserfs_fs = .read = grub_reiserfs_read, .close = grub_reiserfs_close, .label = grub_reiserfs_label, + .uuid = grub_reiserfs_uuid, .next = 0 }; diff -x configure -x config.h.in -x CVS -x '*~' -x '*.mk' -urp ../grub2/fs/xfs.c ./fs/xfs.c --- ../grub2/fs/xfs.c 2008-05-29 15:02:13.000000000 +0200 +++ ./fs/xfs.c 2008-05-31 23:49:10.000000000 +0200 @@ -37,17 +37,19 @@ struct grub_xfs_sblock { grub_uint8_t magic[4]; grub_uint32_t bsize; - grub_uint8_t unused1[48]; + grub_uint8_t unused1[24]; + grub_uint16_t uuid[8]; + grub_uint8_t unused2[8]; grub_uint64_t rootino; - grub_uint8_t unused2[20]; - grub_uint32_t agsize; grub_uint8_t unused3[20]; + grub_uint32_t agsize; + grub_uint8_t unused4[20]; grub_uint8_t label[12]; grub_uint8_t log2_bsize; - grub_uint8_t unused4[2]; + grub_uint8_t unused5[2]; grub_uint8_t log2_inop; grub_uint8_t log2_agblk; - grub_uint8_t unused5[67]; + grub_uint8_t unused6[67]; grub_uint8_t log2_dirblk; } __attribute__ ((packed)); @@ -763,6 +765,38 @@ grub_xfs_label (grub_device_t device, ch return grub_errno; } +static grub_err_t +grub_xfs_uuid (grub_device_t device, char **uuid) +{ + struct grub_xfs_data *data; + grub_disk_t disk = device->disk; + +#ifndef GRUB_UTIL + grub_dl_ref (my_mod); +#endif + + data = grub_xfs_mount (disk); + if (data) + { + *uuid = grub_malloc (40 + sizeof ('\0')); + grub_sprintf (*uuid, "%04x%04x-%04x-%04x-%04x-%04x%04x%04x", + grub_be_to_cpu16 (data->sblock.uuid[0]), grub_be_to_cpu16 (data->sblock.uuid[1]), + grub_be_to_cpu16 (data->sblock.uuid[2]), grub_be_to_cpu16 (data->sblock.uuid[3]), + grub_be_to_cpu16 (data->sblock.uuid[4]), grub_be_to_cpu16 (data->sblock.uuid[5]), + grub_be_to_cpu16 (data->sblock.uuid[6]), grub_be_to_cpu16 (data->sblock.uuid[7])); + } + else + *uuid = NULL; + +#ifndef GRUB_UTIL + grub_dl_unref (my_mod); +#endif + + grub_free (data); + + return grub_errno; +} + static struct grub_fs grub_xfs_fs = @@ -773,6 +807,7 @@ static struct grub_fs grub_xfs_fs = .read = grub_xfs_read, .close = grub_xfs_close, .label = grub_xfs_label, + .uuid = grub_xfs_uuid, .next = 0 }; --YZ5djTAD1cGYuMQK--