From mboxrd@z Thu Jan 1 00:00:00 1970 Delivery-date: Fri, 24 Nov 2023 12:24:14 +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 1r6UI9-007Oux-2w for lore@lore.pengutronix.de; Fri, 24 Nov 2023 12:24:14 +0100 Received: from localhost ([127.0.0.1] helo=metis.whiteo.stw.pengutronix.de) by metis.whiteo.stw.pengutronix.de with esmtp (Exim 4.92) (envelope-from ) id 1r6UI9-0003Qp-TH; Fri, 24 Nov 2023 12:24:13 +0100 Received: from drehscheibe.grey.stw.pengutronix.de ([2a0a:edc0:0:c01:1d::a2]) by metis.whiteo.stw.pengutronix.de with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1r6UI8-0003QP-Dr; Fri, 24 Nov 2023 12:24:12 +0100 Received: from [2a0a:edc0:2:b01:1d::c5] (helo=pty.whiteo.stw.pengutronix.de) by drehscheibe.grey.stw.pengutronix.de with esmtps (TLS1.3) tls TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384 (Exim 4.94.2) (envelope-from ) id 1r6UI8-00BFlK-1P; Fri, 24 Nov 2023 12:24:12 +0100 Received: from rhi by pty.whiteo.stw.pengutronix.de with local (Exim 4.94.2) (envelope-from ) id 1r6UI7-002fPk-Oa; Fri, 24 Nov 2023 12:24:11 +0100 Date: Fri, 24 Nov 2023 12:24:11 +0100 From: Roland Hieber To: Ahmad Fatoum Message-ID: <20231124112411.triclqhc4nkzczj5@pengutronix.de> References: <20231106110405.3209233-1-a.fatoum@pengutronix.de> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: <20231106110405.3209233-1-a.fatoum@pengutronix.de> Subject: Re: [OSS-Tools] [PATCH] libdt: prefer first found disk when looking for block devices X-BeenThere: oss-tools@pengutronix.de X-Mailman-Version: 2.1.29 Precedence: list List-Id: Pengutronix Public Open-Source-Development List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Leonard =?utf-8?B?R8O2aHJz?= , oss-tools@pengutronix.de Sender: "OSS-Tools" X-SA-Exim-Connect-IP: 127.0.0.1 X-SA-Exim-Mail-From: oss-tools-bounces@pengutronix.de X-SA-Exim-Scanned: No (on metis.whiteo.stw.pengutronix.de); SAEximRunCond expanded to false On Mon, Nov 06, 2023 at 12:04:05PM +0100, Ahmad Fatoum wrote: > Recent rework introduced a regression for state located in the eMMC > user area described by DT fixed partitions. Whereas before, the first > device with type "disk" was taken, dt-utils will now iterate over all > devices to try to find a matching GPT partition. If it doesn't find any, > it will instead take the last device with type "disk", which will be the > second boot partition for eMMC devices leading barebox-state to access > /dev/mmcblkXboot1 instead of /dev/mmcblkX. > > Let's fix this regression by restoring the old behavior of preferring the > first disk. This may not be totally future proof, but it worked ok for > years and a better solution can always be added later with a regular > release. > > Reported-by: Leonard Göhrs > Signed-off-by: Ahmad Fatoum > --- > src/libdt.c | 2 +- > 1 file changed, 1 insertion(+), 1 deletion(-) Thanks, this patch is now released in v2023.11.0. - Roland > diff --git a/src/libdt.c b/src/libdt.c > index 650b40467587..72e8ab41e09b 100644 > --- a/src/libdt.c > +++ b/src/libdt.c > @@ -2301,7 +2301,7 @@ static int cdev_from_block_device(struct udev_device *dev, > devtype = udev_device_get_devtype(part); > if (!devtype) > continue; > - if (!strcmp(devtype, "disk")) { > + if (!strcmp(devtype, "disk") && !best_match) { > best_match = part; > > /* Should we try to find a matching partition first? */ > -- > 2.39.2 > > > -- Roland Hieber, Pengutronix e.K. | r.hieber@pengutronix.de | Steuerwalder Str. 21 | https://www.pengutronix.de/ | 31137 Hildesheim, Germany | Phone: +49-5121-206917-0 | Amtsgericht Hildesheim, HRA 2686 | Fax: +49-5121-206917-5555 |