summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAhmad Fatoum <a.fatoum@pengutronix.de>2024-02-13 11:08:36 +0100
committerSascha Hauer <s.hauer@pengutronix.de>2024-02-16 12:57:21 +0100
commit82a51038356dc518439a2153ca95482f1f543dc6 (patch)
tree9f50322d60fcfb09686b1be0f182991de876f970
parentb1fc601eda2b5ed24ebeb15a51573a8fe368610c (diff)
downloadbarebox-82a51038356d.tar.gz
barebox-82a51038356d.tar.xz
partitions: dos: support root=PARTUUID= generation with zero NT signature
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> Link: https://lore.barebox.org/20240213100836.2853989-1-a.fatoum@pengutronix.de Signed-off-by: Sascha Hauer <s.hauer@pengutronix.de>
-rw-r--r--common/partitions/dos.c11
1 files changed, 3 insertions, 8 deletions
diff --git a/common/partitions/dos.c b/common/partitions/dos.c
index 7472824b00..c3d1c4a542 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)) {