From mboxrd@z Thu Jan 1 00:00:00 1970 Delivery-date: Fri, 03 Nov 2023 23:53:08 +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.94.2) (envelope-from ) id 1qz32K-000EPB-Vr for lore@lore.pengutronix.de; Fri, 03 Nov 2023 23:53:08 +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 1qz32G-00007T-OU; Fri, 03 Nov 2023 23:53:04 +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 1qz329-0008K9-Pi; Fri, 03 Nov 2023 23:52:57 +0100 Received: from [2a0a:edc0:0:1101:1d::ac] (helo=dude04.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 1qz329-006QH5-7G; Fri, 03 Nov 2023 23:52:57 +0100 Received: from rhi by dude04.red.stw.pengutronix.de with local (Exim 4.96) (envelope-from ) id 1qz329-005f16-0M; Fri, 03 Nov 2023 23:52:57 +0100 From: Roland Hieber To: distrokit@pengutronix.de Date: Fri, 3 Nov 2023 23:52:52 +0100 Message-Id: <20231103225253.1349209-10-rhi@pengutronix.de> X-Mailer: git-send-email 2.39.2 In-Reply-To: <20231103225253.1349209-1-rhi@pengutronix.de> References: <20231103225253.1349209-1-rhi@pengutronix.de> MIME-Version: 1.0 Content-Transfer-Encoding: 8bit Subject: [DistroKit] [PATCH v2 09/10] rauc-udev: generate symlinks based on GPT partition labels X-BeenThere: distrokit@pengutronix.de X-Mailman-Version: 2.1.29 Precedence: list List-Id: DistroKit Mailinglist List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Roland Hieber Sender: "DistroKit" X-SA-Exim-Connect-IP: 127.0.0.1 X-SA-Exim-Mail-From: distrokit-bounces@pengutronix.de X-SA-Exim-Scanned: No (on metis.whiteo.stw.pengutronix.de); SAEximRunCond expanded to false Now that all our images have a GPT header which contains partitions with the labels "root-A", "root-B", and "data", we can use those to generate the symlinks in /dev/disk/by-usage/ instead of using the hardcoded, number-based kernel device names. This gives us the flexibility to change the order of the partitions on disk as long as their GPT partition labels stay the same. Since the symlinks in /dev/disk/by-partlabel/ are not necessarily unique (see [1]), we cannot use these here. Instead, rework the current match clauses to determine the devpath of the boot device based on the board compatible, and only create by-usage symlinks for partitions on the boot device. [1]: https://github.com/systemd/systemd/pull/29219 Signed-off-by: Roland Hieber --- .../lib/udev/rules.d/90-rauc-partitions.rules | 54 +++++++------------ 1 file changed, 18 insertions(+), 36 deletions(-) diff --git a/projectroot/usr/lib/udev/rules.d/90-rauc-partitions.rules b/projectroot/usr/lib/udev/rules.d/90-rauc-partitions.rules index e909df01958f..64f1aab46ac0 100644 --- a/projectroot/usr/lib/udev/rules.d/90-rauc-partitions.rules +++ b/projectroot/usr/lib/udev/rules.d/90-rauc-partitions.rules @@ -8,42 +8,24 @@ IMPORT{program}="of_base_compatible" # Add symlinks named /dev/disk/by-usage/{data,rootfs0,rootfs1} pointing # to the correct partitions based on the device tree compatible -ENV{OF_BASE_COMPATIBLE}!="*arm,vexpress,v2p-ca9*", GOTO="qemu_vexpress_end" -KERNEL=="mmcblk0p1", SYMLINK+="disk/by-usage/rootfs0" -KERNEL=="mmcblk0p2", SYMLINK+="disk/by-usage/rootfs1" -KERNEL=="mmcblk0p3", SYMLINK+="disk/by-usage/data" -GOTO="rauc_partitions_end" -LABEL="qemu_vexpress_end" - -ENV{OF_BASE_COMPATIBLE}!="*lxa,stm32mp157c-mc1*", GOTO="lxa_mc1_end" -KERNEL=="mmcblk0p6", SYMLINK+="disk/by-usage/rootfs0" -KERNEL=="mmcblk0p7", SYMLINK+="disk/by-usage/rootfs1" -KERNEL=="mmcblk0p8", SYMLINK+="disk/by-usage/data" -GOTO="rauc_partitions_end" -LABEL="lxa_mc1_end" - -ENV{OF_BASE_COMPATIBLE}!="*ti,am335x-bone-black*", GOTO="beaglebone_black_end" -KERNEL=="mmcblk0p2", SYMLINK+="disk/by-usage/rootfs0" -KERNEL=="mmcblk0p3", SYMLINK+="disk/by-usage/rootfs1" -KERNEL=="mmcblk0p4", SYMLINK+="disk/by-usage/data" -GOTO="rauc_partitions_end" -LABEL="beaglebone_black_end" - -ENV{OF_BASE_COMPATIBLE}!="*raspberrypi,3-model-b*", GOTO="rpi3_end" -KERNEL=="mmcblk0p2", SYMLINK+="disk/by-usage/rootfs0" -KERNEL=="mmcblk0p3", SYMLINK+="disk/by-usage/rootfs1" -KERNEL=="mmcblk0p4", SYMLINK+="disk/by-usage/data" -GOTO="rauc_partitions_end" -LABEL="rpi3_end" - -ENV{OF_BASE_COMPATIBLE}!="*riot,imx6s-riotboard*", GOTO="riotboard_end" -KERNEL=="mmcblk2p1", SYMLINK+="disk/by-usage/rootfs0" -KERNEL=="mmcblk2p2", SYMLINK+="disk/by-usage/rootfs1" -KERNEL=="mmcblk2p3", SYMLINK+="disk/by-usage/data" -GOTO="rauc_partitions_end" -LABEL="riotboard_end" - -# fallback for boards not yet supported by RAUC + +# first part: find out the boot disk on known platforms +ENV{OF_BASE_COMPATIBLE}=="*arm,vexpress,v2p-ca9*", ENV{ID_PATH}=="platform-bus@40000000:motherboard-bus@40000000:iofpga@7,00000000-amba-10005000.mmci", TAG+="boot_disk" +ENV{OF_BASE_COMPATIBLE}=="*lxa,stm32mp157c-mc1*", ENV{ID_PATH}=="platform-soc-amba-58005000.mmc", TAG+="boot_disk" +ENV{OF_BASE_COMPATIBLE}=="*ti,am335x-bone-black*", ENV{ID_PATH}=="platform-48060000.mmc", TAG+="boot_disk" +ENV{OF_BASE_COMPATIBLE}=="*raspberrypi,3-model-b*", ENV{ID_PATH}=="platform-3f202000.mmc", TAG+="boot_disk" +ENV{OF_BASE_COMPATIBLE}=="*riot,imx6s-riotboard*", ENV{ID_PATH}=="platform-2198000.mmc", TAG+="boot_disk" + +# second part: create /dev/disk/by-usage/ symlinks +ENV{DEVTYPE}!="partition", GOTO="rauc_partitions_end" + +# fallback for boards not yet supported by RAUC; +# this will get overwritten below if we detected the boot disk KERNEL=="mmcblk0p3", SYMLINK+="disk/by-usage/data" +# symlinks based on GPT partition labels +TAGS=="boot_disk", ENV{ID_PART_ENTRY_NAME}=="root-A", SYMLINK+="disk/by-usage/rootfs0" +TAGS=="boot_disk", ENV{ID_PART_ENTRY_NAME}=="root-B", SYMLINK+="disk/by-usage/rootfs1" +TAGS=="boot_disk", ENV{ID_PART_ENTRY_NAME}=="data", SYMLINK+="disk/by-usage/data" + LABEL="rauc_partitions_end" -- 2.39.2