From mboxrd@z Thu Jan 1 00:00:00 1970 Delivery-date: Mon, 06 Nov 2023 12:14:46 +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 1qzxZ8-0004GB-0P for lore@lore.pengutronix.de; Mon, 06 Nov 2023 12:14:46 +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 1qzxOq-0002kO-FB; Mon, 06 Nov 2023 12:04:08 +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 1qzxOo-0002jh-NH; Mon, 06 Nov 2023 12:04:06 +0100 Received: from [2a0a:edc0:0:1101:1d::54] (helo=dude05.red.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 1qzxOo-0070Sc-Ai; Mon, 06 Nov 2023 12:04:06 +0100 Received: from localhost ([::1] helo=dude05.red.stw.pengutronix.de) by dude05.red.stw.pengutronix.de with esmtp (Exim 4.96) (envelope-from ) id 1qzxOo-00DSs5-0m; Mon, 06 Nov 2023 12:04:06 +0100 From: Ahmad Fatoum To: oss-tools@pengutronix.de Date: Mon, 6 Nov 2023 12:04:05 +0100 Message-Id: <20231106110405.3209233-1-a.fatoum@pengutronix.de> X-Mailer: git-send-email 2.39.2 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Subject: [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: =?UTF-8?q?Leonard=20G=C3=B6hrs?= 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 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(-) 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