From f341f6692cea00cba17589a677b4a8369b14e7d7 Mon Sep 17 00:00:00 2001 From: proski Date: Tue, 1 Jul 2008 23:18:25 +0000 Subject: [PATCH] 2008-07-01 Pavel Roskin * fs/fat.c: Fix UUID calculation on big-endian systems. We write uuid as a 32-bit value in CPU byte order, so declare and use it as such. --- ChangeLog | 4 ++++ fs/fat.c | 9 +++++---- 2 files changed, 9 insertions(+), 4 deletions(-) diff --git a/ChangeLog b/ChangeLog index 68867d55b..d7a858474 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,5 +1,9 @@ 2008-07-01 Pavel Roskin + * fs/fat.c: Fix UUID calculation on big-endian systems. We + write uuid as a 32-bit value in CPU byte order, so declare and + use it as such. + * disk/raid.c: Cast grub_dprintf() arguments to unsigned long long if the format specifier expects it. * partmap/gpt.c (gpt_partition_map_iterate): Likewise. diff --git a/fs/fat.c b/fs/fat.c index 4d04aeca3..63979b4b4 100644 --- a/fs/fat.c +++ b/fs/fat.c @@ -143,7 +143,7 @@ struct grub_fat_data grub_uint32_t cur_cluster_num; grub_uint32_t cur_cluster; - grub_uint16_t uuid[2]; + grub_uint32_t uuid; }; #ifndef GRUB_UTIL @@ -311,9 +311,9 @@ grub_fat_mount (grub_disk_t disk) /* Serial number. */ if (bpb.sectors_per_fat_16) - *((grub_uint32_t *) &data->uuid) = grub_le_to_cpu32 (bpb.version_specific.fat12_or_fat16.num_serial); + data->uuid = grub_le_to_cpu32 (bpb.version_specific.fat12_or_fat16.num_serial); else - *((grub_uint32_t *) &data->uuid) = grub_le_to_cpu32 (bpb.version_specific.fat32.num_serial); + data->uuid = grub_le_to_cpu32 (bpb.version_specific.fat32.num_serial); /* Ignore the 3rd bit, because some BIOSes assigns 0xF0 to the media descriptor, even if it is a so-called superfloppy (e.g. an USB key). @@ -839,7 +839,8 @@ grub_fat_uuid (grub_device_t device, char **uuid) if (data) { *uuid = grub_malloc (sizeof ("xxxx-xxxx")); - grub_sprintf (*uuid, "%04x-%04x", data->uuid[1], data->uuid[0]); + grub_sprintf (*uuid, "%04x-%04x", (grub_uint16_t) (data->uuid >> 8), + (grub_uint16_t) data->uuid); } else *uuid = NULL;