summaryrefslogtreecommitdiff
path: root/disk
diff options
context:
space:
mode:
authorStephen Warren <swarren@nvidia.com>2012-09-21 09:51:00 +0000
committerTom Rini <trini@ti.com>2012-09-25 15:05:45 -0700
commitd27b5f9398aba377ff2185fb4b8170eeca7c3b65 (patch)
treee16e261eb090e9893b26001998973e5ee2d2bc11 /disk
parent894bfbbfb772de2f8640f91aee322f3cb2577cb7 (diff)
disk: part_msdos: parse and store partition UUID
The MSDOS/MBR partition table includes a 32-bit unique ID, often referred to as the NT disk signature. When combined with a partition number within the table, this can form a unique ID similar in concept to EFI/GPT's partition UUID. This patch generates UUIDs in the format 0002dd75-01, which matches the format expected by the Linux kernel. Signed-off-by: Stephen Warren <swarren@nvidia.com>
Diffstat (limited to 'disk')
-rw-r--r--disk/part_dos.c15
-rw-r--r--disk/part_dos.h2
2 files changed, 13 insertions, 4 deletions
diff --git a/disk/part_dos.c b/disk/part_dos.c
index 24ac00ccc32..c9a3e2bf02e 100644
--- a/disk/part_dos.c
+++ b/disk/part_dos.c
@@ -169,7 +169,8 @@ static void print_partition_extended (block_dev_desc_t *dev_desc, int ext_part_s
*/
static int get_partition_info_extended (block_dev_desc_t *dev_desc, int ext_part_sector,
int relative, int part_num,
- int which_part, disk_partition_t *info)
+ int which_part, disk_partition_t *info,
+ unsigned int disksig)
{
ALLOC_CACHE_ALIGN_BUFFER(unsigned char, buffer, dev_desc->blksz);
dos_partition_t *pt;
@@ -188,6 +189,11 @@ static int get_partition_info_extended (block_dev_desc_t *dev_desc, int ext_part
return -1;
}
+#ifdef CONFIG_PARTITION_UUIDS
+ if (!ext_part_sector)
+ disksig = le32_to_int(&buffer[DOS_PART_DISKSIG_OFFSET]);
+#endif
+
/* Print all primary/logical partitions */
pt = (dos_partition_t *) (buffer + DOS_PART_TBL_OFFSET);
for (i = 0; i < 4; i++, pt++) {
@@ -229,6 +235,9 @@ static int get_partition_info_extended (block_dev_desc_t *dev_desc, int ext_part
/* sprintf(info->type, "%d, pt->sys_ind); */
sprintf ((char *)info->type, "U-Boot");
info->bootable = is_bootable(pt);
+#ifdef CONFIG_PARTITION_UUIDS
+ sprintf(info->uuid, "%08x-%02x", disksig, part_num);
+#endif
return 0;
}
@@ -247,7 +256,7 @@ static int get_partition_info_extended (block_dev_desc_t *dev_desc, int ext_part
return get_partition_info_extended (dev_desc, lba_start,
ext_part_sector == 0 ? lba_start : relative,
- part_num, which_part, info);
+ part_num, which_part, info, disksig);
}
}
return -1;
@@ -261,7 +270,7 @@ void print_part_dos (block_dev_desc_t *dev_desc)
int get_partition_info_dos (block_dev_desc_t *dev_desc, int part, disk_partition_t * info)
{
- return get_partition_info_extended (dev_desc, 0, 0, 1, part, info);
+ return get_partition_info_extended(dev_desc, 0, 0, 1, part, info, 0);
}
diff --git a/disk/part_dos.h b/disk/part_dos.h
index de755425e0e..7b77c1d4477 100644
--- a/disk/part_dos.h
+++ b/disk/part_dos.h
@@ -24,7 +24,7 @@
#ifndef _DISK_PART_DOS_H
#define _DISK_PART_DOS_H
-
+#define DOS_PART_DISKSIG_OFFSET 0x1b8
#define DOS_PART_TBL_OFFSET 0x1be
#define DOS_PART_MAGIC_OFFSET 0x1fe
#define DOS_PBR_FSTYPE_OFFSET 0x36