From mboxrd@z Thu Jan 1 00:00:00 1970 Delivery-date: Thu, 18 Dec 2025 10:31:31 +0100 Received: from metis.whiteo.stw.pengutronix.de ([2a0a:edc0:2:b01:1d::104]) by lore.white.stw.pengutronix.de with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.96) (envelope-from ) id 1vWAM7-00CmNf-07 for lore@lore.pengutronix.de; Thu, 18 Dec 2025 10:31:31 +0100 Received: from bombadil.infradead.org ([2607:7c80:54:3::133]) by metis.whiteo.stw.pengutronix.de with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1vWAM6-0003QB-CV for lore@pengutronix.de; Thu, 18 Dec 2025 10:31:30 +0100 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=lists.infradead.org; s=bombadil.20210309; h=Sender:List-Subscribe:List-Help :List-Post:List-Archive:List-Unsubscribe:List-Id:Content-Transfer-Encoding: Content-Type:In-Reply-To:From:References:Cc:To:Subject:MIME-Version:Date: Message-ID:Reply-To:Content-ID:Content-Description:Resent-Date:Resent-From: Resent-Sender:Resent-To:Resent-Cc:Resent-Message-ID:List-Owner; bh=6ax8oaEhFtP567d9CXLgpO8kkQ3HtIYPtJBmcXu88WY=; b=Pc09d1wLp+8ou1au4mCsP39dlU Oti0KLcGb9ljLfdhW2+4W7B8P6U8+IV/veBeYirReH8OxrBPNcno8asf+ujZZFZDu+rPx14N40P14 T5VcHBn/gOT1br1AA+9nywLoOHd18dAoJHXG0nIm4fJD2nupkySaj/SAdQ9oyi/Li1N+rQ4JMSlBv cr2mRYLXolUmtWxS1scR/Dzv85gIjTC1zkzBN8avETBWGWkAPzScz+Q4q2QXHLEHdePiSOtSKevUx u7gLB+ONFnON6zVjbg/rd17NVoFhPWEkX9nnKxFZhb7kT/ZbCWi+rn8p0w8TOogAKjKg2fMeUffpq DI9oGeVA==; Received: from localhost ([::1] helo=bombadil.infradead.org) by bombadil.infradead.org with esmtp (Exim 4.98.2 #2 (Red Hat Linux)) id 1vWALf-000000089FN-2NsA; Thu, 18 Dec 2025 09:31:03 +0000 Received: from metis.whiteo.stw.pengutronix.de ([2a0a:edc0:2:b01:1d::104]) by bombadil.infradead.org with esmtps (Exim 4.98.2 #2 (Red Hat Linux)) id 1vWALd-000000089ER-0DJO for barebox@lists.infradead.org; Thu, 18 Dec 2025 09:31:02 +0000 Received: from ptz.office.stw.pengutronix.de ([2a0a:edc0:0:900:1d::77] helo=[127.0.0.1]) by metis.whiteo.stw.pengutronix.de with esmtp (Exim 4.92) (envelope-from ) id 1vWALb-0003LN-Hp; Thu, 18 Dec 2025 10:30:59 +0100 Message-ID: Date: Thu, 18 Dec 2025 10:30:59 +0100 MIME-Version: 1.0 User-Agent: Mozilla Thunderbird To: Sascha Hauer Cc: barebox@lists.infradead.org References: <20251218091945.3461410-1-a.fatoum@pengutronix.de> Content-Language: en-US, de-DE, de-BE From: Ahmad Fatoum In-Reply-To: Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 7bit X-CRM114-Version: 20100106-BlameMichelson ( TRE 0.8.0 (BSD) ) MR-646709E3 X-CRM114-CacheID: sfid-20251218_013101_092313_C4D23811 X-CRM114-Status: GOOD ( 24.46 ) X-BeenThere: barebox@lists.infradead.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Sender: "barebox" X-SA-Exim-Connect-IP: 2607:7c80:54:3::133 X-SA-Exim-Mail-From: barebox-bounces+lore=pengutronix.de@lists.infradead.org X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on metis.whiteo.stw.pengutronix.de X-Spam-Level: X-Spam-Status: No, score=-4.0 required=4.0 tests=AWL,BAYES_00,DKIMWL_WL_HIGH, DKIM_SIGNED,DKIM_VALID,HEADER_FROM_DIFFERENT_DOMAINS, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_NONE autolearn=unavailable autolearn_force=no version=3.4.2 Subject: Re: [PATCH] cdev: maintain partition index in struct cdev X-SA-Exim-Version: 4.2.1 (built Wed, 08 May 2019 21:11:16 +0000) X-SA-Exim-Scanned: Yes (on metis.whiteo.stw.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 >> --- >> 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 |