[PATCH] partitions: dos: support root=PARTUUID= generation with zero NT signature

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



For MBR-partitioned disks, the NT signature is used to derive the PARTUUID used
to identify the root partition. For this to work reliably, the NT signature is
expected to be unique across all attached MBR-partitioned storage.

Some partition tools may populate the NT signature with an all-zero
value by default, which will likely run afoul of the uniqueness
expectations. When this happens, barebox' bootm.appendroot feature will
report a non-descriptive error message:

  ERROR: Failed to append kernel cmdline parameter 'root='

and continue to boot the kernel without a root= option.

As the kernel doesn't mind an all-zero NT signature, let's just support
computing the correct partuuid in this case. The user is still presented
with an info message:

  Adding "root=PARTUUID=00000000-02" to Kernel commandline

and it's up to them to do something about it.

Signed-off-by: Ahmad Fatoum <a.fatoum@xxxxxxxxxxxxxx>
---
 common/partitions/dos.c | 11 +++--------
 1 file changed, 3 insertions(+), 8 deletions(-)

diff --git a/common/partitions/dos.c b/common/partitions/dos.c
index 7472824b00b9..c3d1c4a542c3 100644
--- a/common/partitions/dos.c
+++ b/common/partitions/dos.c
@@ -144,9 +144,7 @@ static void dos_extended_partition(struct block_device *blk, struct partition_de
 			get_unaligned_le32(&table[0].partition_start);
 		pd->parts[n].size = get_unaligned_le32(&table[0].partition_size);
 		pd->parts[n].dos_partition_type = table[0].type;
-		if (signature)
-			sprintf(pd->parts[n].partuuid, "%08x-%02u",
-				signature, partno);
+		sprintf(pd->parts[n].partuuid, "%08x-%02u", signature, partno);
 		pd->used_entries++;
 		partno++;
 
@@ -182,8 +180,7 @@ static void dos_partition(void *buf, struct block_device *blk,
 	struct disk_signature_priv *dsp;
 	uint32_t signature = get_unaligned_le32(buf + 0x1b8);
 
-	if (signature)
-		sprintf(blk->cdev.diskuuid, "%08x", signature);
+	sprintf(blk->cdev.diskuuid, "%08x", signature);
 
 	blk->cdev.flags |= DEVFS_IS_MBR_PARTITIONED;
 
@@ -199,9 +196,7 @@ static void dos_partition(void *buf, struct block_device *blk,
 			pd->parts[n].first_sec = pentry.first_sec;
 			pd->parts[n].size = pentry.size;
 			pd->parts[n].dos_partition_type = pentry.dos_partition_type;
-			if (signature)
-				sprintf(pd->parts[n].partuuid, "%08x-%02d",
-						signature, i + 1);
+			sprintf(pd->parts[n].partuuid, "%08x-%02d", signature, i + 1);
 			pd->used_entries++;
 
 			if (is_extended_partition(&pentry)) {
-- 
2.39.2





[Index of Archives]     [Linux Embedded]     [Linux USB Devel]     [Linux Audio Users]     [Yosemite News]     [Linux Kernel]     [Linux SCSI]     [XFree86]

  Powered by Linux