mail archive of the barebox mailing list
 help / color / mirror / Atom feed
From: Ahmad Fatoum <a.fatoum@pengutronix.de>
To: Sascha Hauer <s.hauer@pengutronix.de>
Cc: barebox@lists.infradead.org
Subject: Re: [PATCH] cdev: maintain partition index in struct cdev
Date: Thu, 18 Dec 2025 10:30:59 +0100	[thread overview]
Message-ID: <cbbbb3e2-4823-4855-85cf-6a36e104e6b2@pengutronix.de> (raw)
In-Reply-To: <aUPJkljlXW4EOHJ_@pengutronix.de>



On 12/18/25 10:29 AM, Sascha Hauer wrote:
> On Thu, Dec 18, 2025 at 10:19:45AM +0100, Ahmad Fatoum wrote:
>> For use by the EFI loader, we will need to know a partition's number
>> within the partition table on disk, so have the devfs-core keep track
>> of that.
>>
>> Mere iteration over the cdev list doesn't work for thus purpose as there
>> may be invalid PTEs, which cause e.g. the first on-disk partition to
>> have a higher number.
>>
>> See 9dfffaf2ef47 ("partitions: efi: Continue partition enumeration on
>> invalid pte") for more info. A real world example is the current
>> debian-13-nocloud-arm64.raw image, which has two partitions:
>> 0 and 14 (or 1 and 15 in barebox).
> 
> Should have mentioned this in my last mail, but isn't this the other way
> round?

Yes, of course. Should I resend?

> 
> Sascja
> 
>>
>> Signed-off-by: Ahmad Fatoum <a.fatoum@pengutronix.de>
>> ---
>> v2 -> v3:
>>   - fix comment to mention that index is 0-based (Sascha)j
>> v1 -> v2:
>>   - record actual partition number from the table.
>>     I compared against EDK-II and Linux and both take the actual
>>     number, which may not be either the number in our cdev list
>>     or the location on disk.
>> ---
>>  common/partitions.c | 1 +
>>  include/driver.h    | 3 +++
>>  2 files changed, 4 insertions(+)
>>
>> diff --git a/common/partitions.c b/common/partitions.c
>> index 1a4e046c5f55..40f4c629e1ac 100644
>> --- a/common/partitions.c
>> +++ b/common/partitions.c
>> @@ -52,6 +52,7 @@ static int register_one_partition(struct block_device *blk, struct partition *pa
>>  		goto out;
>>  	}
>>  
>> +	cdev->partition_table_index = part->num;
>>  	cdev->flags |= DEVFS_PARTITION_FROM_TABLE | part->flags;
>>  	cdev->typeflags |= part->typeflags;
>>  	cdev->typeuuid = part->typeuuid;
>> diff --git a/include/driver.h b/include/driver.h
>> index 14d1731fd976..77b9b876955a 100644
>> --- a/include/driver.h
>> +++ b/include/driver.h
>> @@ -436,6 +436,9 @@ struct cdev {
>>  	loff_t size;
>>  	unsigned int flags;
>>  	u16 typeflags; /* GPT type-specific attributes */
>> +	s8 partition_table_index;    /* For GPT/MBR-formatted disks only:
>> +				      * 0-based index of partition on disk
>> +				      */
>>  	int open;
>>  	struct mtd_info *mtd;
>>  	struct list_head aliases;
>> -- 
>> 2.47.3
>>
>>
>>
> 

-- 
Pengutronix e.K.                  |                             |
Steuerwalder Str. 21              | http://www.pengutronix.de/  |
31137 Hildesheim, Germany         | Phone: +49-5121-206917-0    |
Amtsgericht Hildesheim, HRA 2686  | Fax:   +49-5121-206917-5555 |




  reply	other threads:[~2025-12-18  9:31 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-12-18  9:19 Ahmad Fatoum
2025-12-18  9:29 ` Sascha Hauer
2025-12-18  9:30   ` Ahmad Fatoum [this message]
2025-12-18  9:38     ` Sascha Hauer
2025-12-18  9:37 ` Sascha Hauer
  -- strict thread matches above, loose matches on Subject: below --
2025-12-11 20:42 Ahmad Fatoum

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=cbbbb3e2-4823-4855-85cf-6a36e104e6b2@pengutronix.de \
    --to=a.fatoum@pengutronix.de \
    --cc=barebox@lists.infradead.org \
    --cc=s.hauer@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