[PATCH v2 2/2] partitions: dos: change first partition number from 1 to 0

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

 



Traditionally barebox starts partition numbers at 0. This was changed
in 8f48e6366c to start at 1. This was done to make the parted numbering
consistent to the Linux tool. This breaks boot scripts though which
assume 0 to be the first partition, so change it back.

Fixes: 8f48e6366c ("partitions: dos: implement partition manipulation support")
Signed-off-by: Sascha Hauer <s.hauer@xxxxxxxxxxxxxx>
---

Notes:
    Changes since v1:
    
    - fix partuuid number passed to Linux

 common/partitions/dos.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/common/partitions/dos.c b/common/partitions/dos.c
index 47b5764124..1b0051f978 100644
--- a/common/partitions/dos.c
+++ b/common/partitions/dos.c
@@ -127,7 +127,7 @@ static void dos_extended_partition(struct block_device *blk, struct dos_partitio
 	uint8_t *buf = malloc(SECTOR_SIZE);
 	uint32_t ebr_sector = partition->first_sec;
 	struct partition_entry *table = (struct partition_entry *)&buf[0x1be];
-	unsigned partno = 5;
+	unsigned partno = 4;
 	struct dos_partition *dpart;
 	struct partition *pentry;
 
@@ -170,7 +170,7 @@ static void dos_extended_partition(struct block_device *blk, struct dos_partitio
 		pentry->size = get_unaligned_le32(&table[0].partition_size);
 		pentry->dos_partition_type = table[0].type;
 		pentry->num = partno;
-		sprintf(pentry->partuuid, "%08x-%02u", signature, partno);
+		sprintf(pentry->partuuid, "%08x-%02u", signature, partno + 1);
 
 		list_add_tail(&pentry->list, &dpd->pd.partitions);
 
@@ -237,7 +237,7 @@ static struct partition_desc *dos_partition(void *buf, struct block_device *blk)
 		pentry->first_sec = first_sec;
 		pentry->size = get_unaligned_le32(&table[i].partition_size);
 		pentry->dos_partition_type = table[i].type;
-		pentry->num = i + 1;
+		pentry->num = i;
 
 		sprintf(pentry->partuuid, "%08x-%02d", signature, i + 1);
 		dpd->signature = signature;
-- 
2.39.2





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

  Powered by Linux