mail archive of the barebox mailing list
 help / color / mirror / Atom feed
From: Ahmad Fatoum <a.fatoum@pengutronix.de>
To: barebox@lists.infradead.org
Cc: rhi@pengutronix.de, Ahmad Fatoum <a.fatoum@pengutronix.de>
Subject: [PATCH] partitions: dos: support root=PARTUUID= generation with zero NT signature
Date: Tue, 13 Feb 2024 11:08:36 +0100	[thread overview]
Message-ID: <20240213100836.2853989-1-a.fatoum@pengutronix.de> (raw)

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




             reply	other threads:[~2024-02-13 10:09 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-02-13 10:08 Ahmad Fatoum [this message]
2024-02-16 11:57 ` Sascha Hauer

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20240213100836.2853989-1-a.fatoum@pengutronix.de \
    --to=a.fatoum@pengutronix.de \
    --cc=barebox@lists.infradead.org \
    --cc=rhi@pengutronix.de \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox