mail archive of the barebox mailing list
 help / color / mirror / Atom feed
* [PATCH] partitions: dos: support root=PARTUUID= generation with zero NT signature
@ 2024-02-13 10:08 Ahmad Fatoum
  2024-02-16 11:57 ` Sascha Hauer
  0 siblings, 1 reply; 2+ messages in thread
From: Ahmad Fatoum @ 2024-02-13 10:08 UTC (permalink / raw)
  To: barebox; +Cc: rhi, Ahmad Fatoum

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@pengutronix.de>
---
 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




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

end of thread, other threads:[~2024-02-16 11:58 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2024-02-13 10:08 [PATCH] partitions: dos: support root=PARTUUID= generation with zero NT signature Ahmad Fatoum
2024-02-16 11:57 ` Sascha Hauer

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox