All of lore.kernel.org
 help / color / mirror / Atom feed
* [U-Boot] [PATCH 1/9] disk: part_efi: remove indent level from loop
@ 2012-10-05 19:29 Stephen Warren
  2012-10-05 19:29 ` [U-Boot] [PATCH 2/9] disk: part_efi: re-order partition list printf, change case Stephen Warren
                   ` (7 more replies)
  0 siblings, 8 replies; 9+ messages in thread
From: Stephen Warren @ 2012-10-05 19:29 UTC (permalink / raw)
  To: u-boot

From: Stephen Warren <swarren@nvidia.com>

Simplify the partition printing loop in print_part_efi() to bail out
early when the first invalid partition is found, rather than indenting
the whole body of the loop. This simplifies later patches.

Signed-off-by: Stephen Warren <swarren@nvidia.com>
---
 disk/part_efi.c |   17 ++++++++---------
 1 files changed, 8 insertions(+), 9 deletions(-)

diff --git a/disk/part_efi.c b/disk/part_efi.c
index 264ea9c..008177e 100644
--- a/disk/part_efi.c
+++ b/disk/part_efi.c
@@ -138,15 +138,14 @@ void print_part_efi(block_dev_desc_t * dev_desc)
 
 	printf("Part\tName\t\t\tStart LBA\tEnd LBA\n");
 	for (i = 0; i < le32_to_int(gpt_head->num_partition_entries); i++) {
+		/* Stop at the first non valid PTE */
+		if (!is_pte_valid(&gpt_pte[i]))
+			break;
 
-		if (is_pte_valid(&gpt_pte[i])) {
-			printf("%3d\t%-18s\t0x%08llX\t0x%08llX\n", (i + 1),
-				print_efiname(&gpt_pte[i]),
-				le64_to_int(gpt_pte[i].starting_lba),
-				le64_to_int(gpt_pte[i].ending_lba));
-		} else {
-			break;	/* Stop at the first non valid PTE */
-		}
+		printf("%3d\t%-18s\t0x%08llX\t0x%08llX\n", (i + 1),
+			print_efiname(&gpt_pte[i]),
+			le64_to_int(gpt_pte[i].starting_lba),
+			le64_to_int(gpt_pte[i].ending_lba));
 	}
 
 	/* Remember to free pte */
-- 
1.7.0.4

^ permalink raw reply related	[flat|nested] 9+ messages in thread

* [U-Boot] [PATCH 2/9] disk: part_efi: re-order partition list printf, change case
  2012-10-05 19:29 [U-Boot] [PATCH 1/9] disk: part_efi: remove indent level from loop Stephen Warren
@ 2012-10-05 19:29 ` Stephen Warren
  2012-10-05 19:29 ` [U-Boot] [PATCH 3/9] disk: part_efi: print partition UUIDs Stephen Warren
                   ` (6 subsequent siblings)
  7 siblings, 0 replies; 9+ messages in thread
From: Stephen Warren @ 2012-10-05 19:29 UTC (permalink / raw)
  To: u-boot

From: Stephen Warren <swarren@nvidia.com>

The partition name is a long variable-length string. Move it last on
the line to ensure consistent layout and that the entries align with
the "header" line. Also, surround it in quotes, so if it's empty, it's
obvious that something is still being printed.

Also, change the case of the LBA numbers; lower-case looks nicer in my
opinion, and will be more consistent with the UUID printing that is
added later in this series.

Signed-off-by: Stephen Warren <swarren@nvidia.com>
---
 disk/part_efi.c |    8 ++++----
 1 files changed, 4 insertions(+), 4 deletions(-)

diff --git a/disk/part_efi.c b/disk/part_efi.c
index 008177e..b6b2bf5 100644
--- a/disk/part_efi.c
+++ b/disk/part_efi.c
@@ -136,16 +136,16 @@ void print_part_efi(block_dev_desc_t * dev_desc)
 
 	debug("%s: gpt-entry at %p\n", __func__, gpt_pte);
 
-	printf("Part\tName\t\t\tStart LBA\tEnd LBA\n");
+	printf("Part\tStart LBA\tEnd LBA\t\tName\n");
 	for (i = 0; i < le32_to_int(gpt_head->num_partition_entries); i++) {
 		/* Stop at the first non valid PTE */
 		if (!is_pte_valid(&gpt_pte[i]))
 			break;
 
-		printf("%3d\t%-18s\t0x%08llX\t0x%08llX\n", (i + 1),
-			print_efiname(&gpt_pte[i]),
+		printf("%3d\t0x%08llx\t0x%08llx\t\"%s\"\n", (i + 1),
 			le64_to_int(gpt_pte[i].starting_lba),
-			le64_to_int(gpt_pte[i].ending_lba));
+			le64_to_int(gpt_pte[i].ending_lba),
+			print_efiname(&gpt_pte[i]));
 	}
 
 	/* Remember to free pte */
-- 
1.7.0.4

^ permalink raw reply related	[flat|nested] 9+ messages in thread

* [U-Boot] [PATCH 3/9] disk: part_efi: print partition UUIDs
  2012-10-05 19:29 [U-Boot] [PATCH 1/9] disk: part_efi: remove indent level from loop Stephen Warren
  2012-10-05 19:29 ` [U-Boot] [PATCH 2/9] disk: part_efi: re-order partition list printf, change case Stephen Warren
@ 2012-10-05 19:29 ` Stephen Warren
  2012-10-05 19:29 ` [U-Boot] [PATCH 4/9] disk: part_efi: add new partition attribute definitions Stephen Warren
                   ` (5 subsequent siblings)
  7 siblings, 0 replies; 9+ messages in thread
From: Stephen Warren @ 2012-10-05 19:29 UTC (permalink / raw)
  To: u-boot

From: Stephen Warren <swarren@nvidia.com>

When printing the partition table, print the partition type UUID and the
individual partition UUID. Do this unconditionally, since partition UUIDs
are useful.

Signed-off-by: Stephen Warren <swarren@nvidia.com>
---
 disk/part_efi.c |   50 ++++++++++++++++++++++++++++----------------------
 1 files changed, 28 insertions(+), 22 deletions(-)

diff --git a/disk/part_efi.c b/disk/part_efi.c
index b6b2bf5..6b80cd9 100644
--- a/disk/part_efi.c
+++ b/disk/part_efi.c
@@ -113,6 +113,26 @@ static char *print_efiname(gpt_entry *pte)
 	return name;
 }
 
+static void uuid_string(unsigned char *uuid, char *str)
+{
+	static const u8 le[16] = {3, 2, 1, 0, 5, 4, 7, 6, 8, 9, 10, 11,
+				  12, 13, 14, 15};
+	int i;
+
+	for (i = 0; i < 16; i++) {
+		sprintf(str, "%02x", uuid[le[i]]);
+		str += 2;
+		switch (i) {
+		case 3:
+		case 5:
+		case 7:
+		case 9:
+			*str++ = '-';
+			break;
+		}
+	}
+}
+
 /*
  * Public Functions (include/part.h)
  */
@@ -122,6 +142,7 @@ void print_part_efi(block_dev_desc_t * dev_desc)
 	ALLOC_CACHE_ALIGN_BUFFER(gpt_header, gpt_head, 1);
 	gpt_entry *gpt_pte = NULL;
 	int i = 0;
+	char uuid[37];
 
 	if (!dev_desc) {
 		printf("%s: Invalid Argument(s)\n", __func__);
@@ -137,6 +158,9 @@ void print_part_efi(block_dev_desc_t * dev_desc)
 	debug("%s: gpt-entry@%p\n", __func__, gpt_pte);
 
 	printf("Part\tStart LBA\tEnd LBA\t\tName\n");
+	printf("\tType UUID\n");
+	printf("\tPartition UUID\n");
+
 	for (i = 0; i < le32_to_int(gpt_head->num_partition_entries); i++) {
 		/* Stop at the first non valid PTE */
 		if (!is_pte_valid(&gpt_pte[i]))
@@ -146,6 +170,10 @@ void print_part_efi(block_dev_desc_t * dev_desc)
 			le64_to_int(gpt_pte[i].starting_lba),
 			le64_to_int(gpt_pte[i].ending_lba),
 			print_efiname(&gpt_pte[i]));
+		uuid_string(gpt_pte[i].partition_type_guid.b, uuid);
+		printf("\ttype:\t%s\n", uuid);
+		uuid_string(gpt_pte[i].unique_partition_guid.b, uuid);
+		printf("\tuuid:\t%s\n", uuid);
 	}
 
 	/* Remember to free pte */
@@ -153,28 +181,6 @@ void print_part_efi(block_dev_desc_t * dev_desc)
 	return;
 }
 
-#ifdef CONFIG_PARTITION_UUIDS
-static void uuid_string(unsigned char *uuid, char *str)
-{
-	static const u8 le[16] = {3, 2, 1, 0, 5, 4, 7, 6, 8, 9, 10, 11,
-				  12, 13, 14, 15};
-	int i;
-
-	for (i = 0; i < 16; i++) {
-		sprintf(str, "%02x", uuid[le[i]]);
-		str += 2;
-		switch (i) {
-		case 3:
-		case 5:
-		case 7:
-		case 9:
-			*str++ = '-';
-			break;
-		}
-	}
-}
-#endif
-
 int get_partition_info_efi(block_dev_desc_t * dev_desc, int part,
 				disk_partition_t * info)
 {
-- 
1.7.0.4

^ permalink raw reply related	[flat|nested] 9+ messages in thread

* [U-Boot] [PATCH 4/9] disk: part_efi: add new partition attribute definitions
  2012-10-05 19:29 [U-Boot] [PATCH 1/9] disk: part_efi: remove indent level from loop Stephen Warren
  2012-10-05 19:29 ` [U-Boot] [PATCH 2/9] disk: part_efi: re-order partition list printf, change case Stephen Warren
  2012-10-05 19:29 ` [U-Boot] [PATCH 3/9] disk: part_efi: print partition UUIDs Stephen Warren
@ 2012-10-05 19:29 ` Stephen Warren
  2012-10-05 19:29 ` [U-Boot] [PATCH 5/9] disk: part_efi: print raw partition attributes Stephen Warren
                   ` (4 subsequent siblings)
  7 siblings, 0 replies; 9+ messages in thread
From: Stephen Warren @ 2012-10-05 19:29 UTC (permalink / raw)
  To: u-boot

From: Stephen Warren <swarren@nvidia.com>

Add no_block_io_protocol and legacy_bios_bootable attribute definitions.
These are sourced from UEFI Spec 2.3, page 105, table 19. Credits to the
libparted source for the specification pointer.

Signed-off-by: Stephen Warren <swarren@nvidia.com>
---
 disk/part_efi.h |    4 +++-
 1 files changed, 3 insertions(+), 1 deletions(-)

diff --git a/disk/part_efi.h b/disk/part_efi.h
index 5903e7c..1d0c67c 100644
--- a/disk/part_efi.h
+++ b/disk/part_efi.h
@@ -113,7 +113,9 @@ typedef struct _gpt_header {
 
 typedef struct _gpt_entry_attributes {
 	unsigned long long required_to_function:1;
-	unsigned long long reserved:47;
+	unsigned long long no_block_io_protocol:1;
+	unsigned long long legacy_bios_bootable:1;
+	unsigned long long reserved:45;
 	unsigned long long type_guid_specific:16;
 } __attribute__ ((packed)) gpt_entry_attributes;
 
-- 
1.7.0.4

^ permalink raw reply related	[flat|nested] 9+ messages in thread

* [U-Boot] [PATCH 5/9] disk: part_efi: print raw partition attributes
  2012-10-05 19:29 [U-Boot] [PATCH 1/9] disk: part_efi: remove indent level from loop Stephen Warren
                   ` (2 preceding siblings ...)
  2012-10-05 19:29 ` [U-Boot] [PATCH 4/9] disk: part_efi: add new partition attribute definitions Stephen Warren
@ 2012-10-05 19:29 ` Stephen Warren
  2012-10-05 19:29 ` [U-Boot] [PATCH 6/9] disk: part_efi: set bootable flag in partition objects Stephen Warren
                   ` (3 subsequent siblings)
  7 siblings, 0 replies; 9+ messages in thread
From: Stephen Warren @ 2012-10-05 19:29 UTC (permalink / raw)
  To: u-boot

From: Stephen Warren <swarren@nvidia.com>

When printing the EFI partition table, print the raw attributes. Convert
struct gpt_entry_attributes to a union to allow raw access.

Signed-off-by: Stephen Warren <swarren@nvidia.com>
---
 disk/part_efi.c |    2 ++
 disk/part_efi.h |   15 +++++++++------
 2 files changed, 11 insertions(+), 6 deletions(-)

diff --git a/disk/part_efi.c b/disk/part_efi.c
index 6b80cd9..d563509 100644
--- a/disk/part_efi.c
+++ b/disk/part_efi.c
@@ -158,6 +158,7 @@ void print_part_efi(block_dev_desc_t * dev_desc)
 	debug("%s: gpt-entry at %p\n", __func__, gpt_pte);
 
 	printf("Part\tStart LBA\tEnd LBA\t\tName\n");
+	printf("\tAttributes\n");
 	printf("\tType UUID\n");
 	printf("\tPartition UUID\n");
 
@@ -170,6 +171,7 @@ void print_part_efi(block_dev_desc_t * dev_desc)
 			le64_to_int(gpt_pte[i].starting_lba),
 			le64_to_int(gpt_pte[i].ending_lba),
 			print_efiname(&gpt_pte[i]));
+		printf("\tattrs:\t0x%016llx\n", gpt_pte[i].attributes.raw);
 		uuid_string(gpt_pte[i].partition_type_guid.b, uuid);
 		printf("\ttype:\t%s\n", uuid);
 		uuid_string(gpt_pte[i].unique_partition_guid.b, uuid);
diff --git a/disk/part_efi.h b/disk/part_efi.h
index 1d0c67c..4e28d1d 100644
--- a/disk/part_efi.h
+++ b/disk/part_efi.h
@@ -111,12 +111,15 @@ typedef struct _gpt_header {
 	unsigned char reserved2[GPT_BLOCK_SIZE - 92];
 } __attribute__ ((packed)) gpt_header;
 
-typedef struct _gpt_entry_attributes {
-	unsigned long long required_to_function:1;
-	unsigned long long no_block_io_protocol:1;
-	unsigned long long legacy_bios_bootable:1;
-	unsigned long long reserved:45;
-	unsigned long long type_guid_specific:16;
+typedef union _gpt_entry_attributes {
+	struct {
+		unsigned long long required_to_function:1;
+		unsigned long long no_block_io_protocol:1;
+		unsigned long long legacy_bios_bootable:1;
+		unsigned long long reserved:45;
+		unsigned long long type_guid_specific:16;
+	} fields;
+	unsigned long long raw;
 } __attribute__ ((packed)) gpt_entry_attributes;
 
 #define PARTNAME_SZ	(72 / sizeof(efi_char16_t))
-- 
1.7.0.4

^ permalink raw reply related	[flat|nested] 9+ messages in thread

* [U-Boot] [PATCH 6/9] disk: part_efi: set bootable flag in partition objects
  2012-10-05 19:29 [U-Boot] [PATCH 1/9] disk: part_efi: remove indent level from loop Stephen Warren
                   ` (3 preceding siblings ...)
  2012-10-05 19:29 ` [U-Boot] [PATCH 5/9] disk: part_efi: print raw partition attributes Stephen Warren
@ 2012-10-05 19:29 ` Stephen Warren
  2012-10-05 19:29 ` [U-Boot] [PATCH 7/9] disk: part_dos: checkpatch cleanups Stephen Warren
                   ` (2 subsequent siblings)
  7 siblings, 0 replies; 9+ messages in thread
From: Stephen Warren @ 2012-10-05 19:29 UTC (permalink / raw)
  To: u-boot

From: Stephen Warren <swarren@nvidia.com>

A partition is considered bootable if it either has the "legacy BIOS
bootable" flag set, or if the partition type UUID matches the standard
"system" type.

Signed-off-by: Stephen Warren <swarren@nvidia.com>
---
 disk/part_efi.c |   10 ++++++++++
 1 files changed, 10 insertions(+), 0 deletions(-)

diff --git a/disk/part_efi.c b/disk/part_efi.c
index d563509..7a39d52 100644
--- a/disk/part_efi.c
+++ b/disk/part_efi.c
@@ -133,6 +133,15 @@ static void uuid_string(unsigned char *uuid, char *str)
 	}
 }
 
+static efi_guid_t system_guid = PARTITION_SYSTEM_GUID;
+
+static inline int is_bootable(gpt_entry *p)
+{
+	return p->attributes.fields.legacy_bios_bootable ||
+		!memcmp(&(p->partition_type_guid), &system_guid,
+			sizeof(efi_guid_t));
+}
+
 /*
  * Public Functions (include/part.h)
  */
@@ -219,6 +228,7 @@ int get_partition_info_efi(block_dev_desc_t * dev_desc, int part,
 	sprintf((char *)info->name, "%s",
 			print_efiname(&gpt_pte[part - 1]));
 	sprintf((char *)info->type, "U-Boot");
+	info->bootable = is_bootable(&gpt_pte[part - 1]);
 #ifdef CONFIG_PARTITION_UUIDS
 	uuid_string(gpt_pte[part - 1].unique_partition_guid.b, info->uuid);
 #endif
-- 
1.7.0.4

^ permalink raw reply related	[flat|nested] 9+ messages in thread

* [U-Boot] [PATCH 7/9] disk: part_dos: checkpatch cleanups
  2012-10-05 19:29 [U-Boot] [PATCH 1/9] disk: part_efi: remove indent level from loop Stephen Warren
                   ` (4 preceding siblings ...)
  2012-10-05 19:29 ` [U-Boot] [PATCH 6/9] disk: part_efi: set bootable flag in partition objects Stephen Warren
@ 2012-10-05 19:29 ` Stephen Warren
  2012-10-05 19:29 ` [U-Boot] [PATCH 8/9] disk: part_dos: align partition table prints Stephen Warren
  2012-10-05 19:29 ` [U-Boot] [PATCH 9/9] disk: part_dos: print partition UUID in partition list Stephen Warren
  7 siblings, 0 replies; 9+ messages in thread
From: Stephen Warren @ 2012-10-05 19:29 UTC (permalink / raw)
  To: u-boot

From: Stephen Warren <swarren@nvidia.com>

Minor cleanups required so later patches don't trigger checkpatch.

Signed-off-by: Stephen Warren <swarren@nvidia.com>
---
 disk/part_dos.c |   21 +++++++++++----------
 1 files changed, 11 insertions(+), 10 deletions(-)

diff --git a/disk/part_dos.c b/disk/part_dos.c
index c9a3e2b..0fadc17 100644
--- a/disk/part_dos.c
+++ b/disk/part_dos.c
@@ -65,7 +65,8 @@ static inline int is_bootable(dos_partition_t *p)
 	return p->boot_ind == 0x80;
 }
 
-static void print_one_part (dos_partition_t *p, int ext_part_sector, int part_num)
+static void print_one_part(dos_partition_t *p, int ext_part_sector,
+			   int part_num)
 {
 	int lba_start = ext_part_sector + le32_to_int (p->start4);
 	int lba_size  = le32_to_int (p->size4);
@@ -104,8 +105,9 @@ int test_part_dos (block_dev_desc_t *dev_desc)
 
 /*  Print a partition that is relative to its Extended partition table
  */
-static void print_partition_extended (block_dev_desc_t *dev_desc, int ext_part_sector, int relative,
-							   int part_num)
+static void print_partition_extended(block_dev_desc_t *dev_desc,
+				     int ext_part_sector, int relative,
+				     int part_num)
 {
 	ALLOC_CACHE_ALIGN_BUFFER(unsigned char, buffer, dev_desc->blksz);
 	dos_partition_t *pt;
@@ -138,7 +140,7 @@ static void print_partition_extended (block_dev_desc_t *dev_desc, int ext_part_s
 
 		if ((pt->sys_ind != 0) &&
 		    (ext_part_sector == 0 || !is_extended (pt->sys_ind)) ) {
-			print_one_part (pt, ext_part_sector, part_num);
+			print_one_part(pt, ext_part_sector, part_num);
 		}
 
 		/* Reverse engr the fdisk part# assignment rule! */
@@ -154,10 +156,9 @@ static void print_partition_extended (block_dev_desc_t *dev_desc, int ext_part_s
 		if (is_extended (pt->sys_ind)) {
 			int lba_start = le32_to_int (pt->start4) + relative;
 
-			print_partition_extended (dev_desc, lba_start,
-						  ext_part_sector == 0  ? lba_start
-									: relative,
-						  part_num);
+			print_partition_extended(dev_desc, lba_start,
+				ext_part_sector == 0  ? lba_start : relative,
+				part_num);
 		}
 	}
 
@@ -264,8 +265,8 @@ static int get_partition_info_extended (block_dev_desc_t *dev_desc, int ext_part
 
 void print_part_dos (block_dev_desc_t *dev_desc)
 {
-	printf ("Partition     Start Sector     Num Sectors     Type\n");
-	print_partition_extended (dev_desc, 0, 0, 1);
+	printf("Partition     Start Sector     Num Sectors     Type\n");
+	print_partition_extended(dev_desc, 0, 0, 1);
 }
 
 int get_partition_info_dos (block_dev_desc_t *dev_desc, int part, disk_partition_t * info)
-- 
1.7.0.4

^ permalink raw reply related	[flat|nested] 9+ messages in thread

* [U-Boot] [PATCH 8/9] disk: part_dos: align partition table prints
  2012-10-05 19:29 [U-Boot] [PATCH 1/9] disk: part_efi: remove indent level from loop Stephen Warren
                   ` (5 preceding siblings ...)
  2012-10-05 19:29 ` [U-Boot] [PATCH 7/9] disk: part_dos: checkpatch cleanups Stephen Warren
@ 2012-10-05 19:29 ` Stephen Warren
  2012-10-05 19:29 ` [U-Boot] [PATCH 9/9] disk: part_dos: print partition UUID in partition list Stephen Warren
  7 siblings, 0 replies; 9+ messages in thread
From: Stephen Warren @ 2012-10-05 19:29 UTC (permalink / raw)
  To: u-boot

From: Stephen Warren <swarren@nvidia.com>

When printing the partition table, make sure data aligns with the column
headers. Change format of partition number field to %3d to match
part_efi.c.

Signed-off-by: Stephen Warren <swarren@nvidia.com>
---
 disk/part_dos.c |    4 ++--
 1 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/disk/part_dos.c b/disk/part_dos.c
index 0fadc17..aed0c77 100644
--- a/disk/part_dos.c
+++ b/disk/part_dos.c
@@ -71,7 +71,7 @@ static void print_one_part(dos_partition_t *p, int ext_part_sector,
 	int lba_start = ext_part_sector + le32_to_int (p->start4);
 	int lba_size  = le32_to_int (p->size4);
 
-	printf("%5d\t\t%10d\t%10d\t%2x%s%s\n",
+	printf("%3d\t%-10d\t%-10d\t%02x%s%s\n",
 		part_num, lba_start, lba_size, p->sys_ind,
 		(is_extended(p->sys_ind) ? " Extd" : ""),
 		(is_bootable(p) ? " Boot" : ""));
@@ -265,7 +265,7 @@ static int get_partition_info_extended (block_dev_desc_t *dev_desc, int ext_part
 
 void print_part_dos (block_dev_desc_t *dev_desc)
 {
-	printf("Partition     Start Sector     Num Sectors     Type\n");
+	printf("Part\tStart Sector\tNum Sectors\tType\n");
 	print_partition_extended(dev_desc, 0, 0, 1);
 }
 
-- 
1.7.0.4

^ permalink raw reply related	[flat|nested] 9+ messages in thread

* [U-Boot] [PATCH 9/9] disk: part_dos: print partition UUID in partition list
  2012-10-05 19:29 [U-Boot] [PATCH 1/9] disk: part_efi: remove indent level from loop Stephen Warren
                   ` (6 preceding siblings ...)
  2012-10-05 19:29 ` [U-Boot] [PATCH 8/9] disk: part_dos: align partition table prints Stephen Warren
@ 2012-10-05 19:29 ` Stephen Warren
  7 siblings, 0 replies; 9+ messages in thread
From: Stephen Warren @ 2012-10-05 19:29 UTC (permalink / raw)
  To: u-boot

From: Stephen Warren <swarren@nvidia.com>

This information may be useful to compare against command "part uuid",
or if you want to manually paste the information into the kernel
command-line.

Signed-off-by: Stephen Warren <swarren@nvidia.com>
---
 disk/part_dos.c |   20 ++++++++++++--------
 1 files changed, 12 insertions(+), 8 deletions(-)

diff --git a/disk/part_dos.c b/disk/part_dos.c
index aed0c77..3069f91 100644
--- a/disk/part_dos.c
+++ b/disk/part_dos.c
@@ -66,13 +66,13 @@ static inline int is_bootable(dos_partition_t *p)
 }
 
 static void print_one_part(dos_partition_t *p, int ext_part_sector,
-			   int part_num)
+			   int part_num, unsigned int disksig)
 {
 	int lba_start = ext_part_sector + le32_to_int (p->start4);
 	int lba_size  = le32_to_int (p->size4);
 
-	printf("%3d\t%-10d\t%-10d\t%02x%s%s\n",
-		part_num, lba_start, lba_size, p->sys_ind,
+	printf("%3d\t%-10d\t%-10d\t%08x-%02x\t%02x%s%s\n",
+		part_num, lba_start, lba_size, disksig, part_num, p->sys_ind,
 		(is_extended(p->sys_ind) ? " Extd" : ""),
 		(is_bootable(p) ? " Boot" : ""));
 }
@@ -107,7 +107,7 @@ int test_part_dos (block_dev_desc_t *dev_desc)
  */
 static void print_partition_extended(block_dev_desc_t *dev_desc,
 				     int ext_part_sector, int relative,
-				     int part_num)
+				     int part_num, unsigned int disksig)
 {
 	ALLOC_CACHE_ALIGN_BUFFER(unsigned char, buffer, dev_desc->blksz);
 	dos_partition_t *pt;
@@ -125,6 +125,10 @@ static void print_partition_extended(block_dev_desc_t *dev_desc,
 			buffer[DOS_PART_MAGIC_OFFSET + 1]);
 		return;
 	}
+
+	if (!ext_part_sector)
+		disksig = le32_to_int(&buffer[DOS_PART_DISKSIG_OFFSET]);
+
 	if(i==DOS_PBR) {
 		printf ("    1\t\t         0\t%10ld\t%2x\n",
 			dev_desc->lba, buffer[DOS_PBR_MEDIA_TYPE_OFFSET]);
@@ -140,7 +144,7 @@ static void print_partition_extended(block_dev_desc_t *dev_desc,
 
 		if ((pt->sys_ind != 0) &&
 		    (ext_part_sector == 0 || !is_extended (pt->sys_ind)) ) {
-			print_one_part(pt, ext_part_sector, part_num);
+			print_one_part(pt, ext_part_sector, part_num, disksig);
 		}
 
 		/* Reverse engr the fdisk part# assignment rule! */
@@ -158,7 +162,7 @@ static void print_partition_extended(block_dev_desc_t *dev_desc,
 
 			print_partition_extended(dev_desc, lba_start,
 				ext_part_sector == 0  ? lba_start : relative,
-				part_num);
+				part_num, disksig);
 		}
 	}
 
@@ -265,8 +269,8 @@ static int get_partition_info_extended (block_dev_desc_t *dev_desc, int ext_part
 
 void print_part_dos (block_dev_desc_t *dev_desc)
 {
-	printf("Part\tStart Sector\tNum Sectors\tType\n");
-	print_partition_extended(dev_desc, 0, 0, 1);
+	printf("Part\tStart Sector\tNum Sectors\tUUID\t\tType\n");
+	print_partition_extended(dev_desc, 0, 0, 1, 0);
 }
 
 int get_partition_info_dos (block_dev_desc_t *dev_desc, int part, disk_partition_t * info)
-- 
1.7.0.4

^ permalink raw reply related	[flat|nested] 9+ messages in thread

end of thread, other threads:[~2012-10-05 19:29 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2012-10-05 19:29 [U-Boot] [PATCH 1/9] disk: part_efi: remove indent level from loop Stephen Warren
2012-10-05 19:29 ` [U-Boot] [PATCH 2/9] disk: part_efi: re-order partition list printf, change case Stephen Warren
2012-10-05 19:29 ` [U-Boot] [PATCH 3/9] disk: part_efi: print partition UUIDs Stephen Warren
2012-10-05 19:29 ` [U-Boot] [PATCH 4/9] disk: part_efi: add new partition attribute definitions Stephen Warren
2012-10-05 19:29 ` [U-Boot] [PATCH 5/9] disk: part_efi: print raw partition attributes Stephen Warren
2012-10-05 19:29 ` [U-Boot] [PATCH 6/9] disk: part_efi: set bootable flag in partition objects Stephen Warren
2012-10-05 19:29 ` [U-Boot] [PATCH 7/9] disk: part_dos: checkpatch cleanups Stephen Warren
2012-10-05 19:29 ` [U-Boot] [PATCH 8/9] disk: part_dos: align partition table prints Stephen Warren
2012-10-05 19:29 ` [U-Boot] [PATCH 9/9] disk: part_dos: print partition UUID in partition list Stephen Warren

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.