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 v2 09/10] rauc-udev: generate symlinks based on GPT partition labels
Date: Fri,  3 Nov 2023 23:52:52 +0100	[thread overview]
Message-ID: <20231103225253.1349209-10-rhi@pengutronix.de> (raw)
In-Reply-To: <20231103225253.1349209-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
device.

  [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..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




  parent reply	other threads:[~2023-11-03 22:53 UTC|newest]

Thread overview: 16+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-11-03 22:52 [DistroKit] [PATCH v2 00/10] refactor data partition setup Roland Hieber
2023-11-03 22:52 ` [DistroKit] [PATCH v2 01/10] treewide: images: unify partition labels Roland Hieber
2023-11-03 22:52 ` [DistroKit] [PATCH v2 02/10] v7a: image-stm32mp: set GPT Partition Type UUID Roland Hieber
2023-11-03 22:52 ` [DistroKit] [PATCH v2 03/10] treewide: images: remove size specifications for root partitions Roland Hieber
2023-11-03 22:52 ` [DistroKit] [PATCH v2 04/10] treewide: images: increase size of all qemu images to 1 GiB Roland Hieber
2023-11-03 22:52 ` [DistroKit] [PATCH v2 05/10] datapartition: generate partitions via systemd-repart Roland Hieber
2023-11-09  8:13   ` Roland Hieber
2023-12-12 18:07     ` Robert Schwebel
2023-12-13 14:49       ` Roland Hieber
2023-11-03 22:52 ` [DistroKit] [PATCH v2 06/10] datapartition: add missing mount unit Roland Hieber
2023-11-03 22:52 ` [DistroKit] [PATCH v2 07/10] datapartition: set license Roland Hieber
2023-11-04 11:14   ` Michael Olbrich
2023-11-06 11:55     ` Robert Schwebel
2023-11-03 22:52 ` [DistroKit] [PATCH v2 08/10] treewide: images: remove root-B and data partitions Roland Hieber
2023-11-03 22:52 ` Roland Hieber [this message]
2023-11-03 22:52 ` [DistroKit] [PATCH v2 10/10] v7a: barebox: bootchooser: use GPT partition labels Roland Hieber

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:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

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

  git send-email \
    --in-reply-to=20231103225253.1349209-10-rhi@pengutronix.de \
    --to=rhi@pengutronix.de \
    --cc=distrokit@pengutronix.de \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* 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