DistroKit Mailinglist
 help / color / mirror / Atom feed
From: Roland Hieber <rhi@pengutronix.de>
To: distrokit@pengutronix.de
Cc: Roland Hieber <rhi@pengutronix.de>
Subject: [DistroKit] [PATCH 09/10] rauc-udev: generate symlinks based on GPT partition labels
Date: Fri,  3 Nov 2023 19:24:37 +0100	[thread overview]
Message-ID: <20231103182438.1051601-9-rhi@pengutronix.de> (raw)
In-Reply-To: <20231103182438.1051601-1-rhi@pengutronix.de>

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

  [1]: https://github.com/systemd/systemd/pull/29219

Signed-off-by: Roland Hieber <rhi@pengutronix.de>
 .../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..6bb361554a1f 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"
-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"
-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"
-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"
-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"
-# 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{PARTNAME}=="root-A", SYMLINK+="disk/by-usage/rootfs0"
+TAGS=="boot_disk", ENV{PARTNAME}=="root-B", SYMLINK+="disk/by-usage/rootfs1"
+TAGS=="boot_disk", ENV{PARTNAME}=="data",   SYMLINK+="disk/by-usage/data"

  parent reply	other threads:[~2023-11-03 18:24 UTC|newest]

Thread overview: 16+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-11-03 18:24 [DistroKit] [PATCH 01/10] treewide: images: unify " Roland Hieber
2023-11-03 18:24 ` [DistroKit] [PATCH 02/10] v7a: image-stm32mp: set GPT Partition Type UUID Roland Hieber
2023-11-06  8:21   ` Ahmad Fatoum
2023-11-03 18:24 ` [DistroKit] [PATCH 03/10] treewide: images: remove size specifications for root partitions Roland Hieber
2023-11-06  8:21   ` Ahmad Fatoum
2023-11-06  9:40     ` Roland Hieber
2023-11-06  9:41       ` Ahmad Fatoum
2023-11-03 18:24 ` [DistroKit] [PATCH 04/10] treewide: images: increase size of all qemu images to 1 GiB Roland Hieber
2023-11-03 18:24 ` [DistroKit] [PATCH 05/10] datapartition: generate partitions via systemd-repart Roland Hieber
2023-11-03 18:24 ` [DistroKit] [PATCH 06/10] datapartition: add missing mount unit Roland Hieber
2023-11-03 18:24 ` [DistroKit] [PATCH 07/10] datapartition: set license Roland Hieber
2023-11-03 18:24 ` [DistroKit] [PATCH 08/10] treewide: images: remove root-B and data partitions Roland Hieber
2023-11-03 18:24 ` Roland Hieber [this message]
2023-11-03 18:24 ` [DistroKit] [PATCH 10/10] v7a: barebox: bootchooser: use GPT partition labels Roland Hieber
2023-11-06 11:43 ` [DistroKit] [PATCH 01/10] treewide: images: unify " Robert Schwebel
2023-11-06 11:50   ` Robert Schwebel

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:

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20231103182438.1051601-9-rhi@pengutronix.de \
    --to=rhi@pengutronix.de \
    --cc=distrokit@pengutronix.de \


* 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