diff --git a/ChangeLog b/ChangeLog index 02d5af1..f7275bd 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,5 +1,13 @@ 2009-07-21 Vladimir Serbinenko + UUID support for UFS + + * fs/ufs.c (grub_ufs_sblock): Add uuidhi and uuidlow. + (grub_ufs_uuid): New function. + (grub_ufs_fs): add .uuid + +2009-07-21 Vladimir Serbinenko + * fs/ufs.c (grub_ufs_sblock): Fix offset of mtime2 which was off by 128 bytes diff --git a/fs/ufs.c b/fs/ufs.c index c9531b5..a41145e 100644 --- a/fs/ufs.c +++ b/fs/ufs.c @@ -87,7 +87,10 @@ struct grub_ufs_sblock /* The size of filesystem blocks to disk blocks. */ grub_uint32_t log2_blksz; - grub_uint8_t unused6[80]; + grub_uint8_t unused6[40]; + grub_uint32_t uuidhi; + grub_uint32_t uuidlow; + grub_uint8_t unused7[32]; /* Inodes stored per cylinder group. */ grub_uint32_t ino_per_group; @@ -95,14 +98,14 @@ struct grub_ufs_sblock /* The frags per cylinder group. */ grub_uint32_t frags_per_group; - grub_uint8_t unused7[488]; + grub_uint8_t unused8[488]; /* Volume name for UFS2. */ grub_uint8_t volume_name[GRUB_UFS_VOLNAME_LEN]; - grub_uint8_t unused8[360]; + grub_uint8_t unused9[360]; grub_uint64_t mtime2; - grub_uint8_t unused9[292]; + grub_uint8_t unused10[292]; /* Magic value to check if this is really a UFS filesystem. */ grub_uint32_t magic; @@ -736,6 +739,33 @@ grub_ufs_label (grub_device_t device, char **label) return grub_errno; } +static grub_err_t +grub_ufs_uuid (grub_device_t device, char **uuid) +{ + struct grub_ufs_data *data; + grub_disk_t disk = device->disk; + + grub_dl_ref (my_mod); + + data = grub_ufs_mount (disk); + if (data) + { + *uuid = grub_malloc (16 + sizeof ('\0')); + grub_sprintf (*uuid, "%08lx%08lx", + (unsigned long) grub_le_to_cpu32 (data->sblock.uuidhi), + (unsigned long) grub_le_to_cpu32 (data->sblock.uuidlow)); + } + else + *uuid = NULL; + + grub_dl_unref (my_mod); + + grub_free (data); + + return grub_errno; +} + + /* Get mtime. */ static grub_err_t grub_ufs_mtime (grub_device_t device, grub_int32_t *tm) @@ -769,6 +799,7 @@ static struct grub_fs grub_ufs_fs = .read = grub_ufs_read, .close = grub_ufs_close, .label = grub_ufs_label, + .uuid = grub_ufs_uuid, .mtime = grub_ufs_mtime, .next = 0 };