Skip to contentSkip to conversation

udev-extraconf fixes

PATCH New [email protected] 1 participant 10 messages Jul 17, 2022

lore
Share & tools
lore
#0 lore raw

cover udev-extraconf fixes

From: Ming Liu <[email protected]>

udev-extraconf of kirkstone does not work, back-ported several fixes from upstream.

Ming Liu (3):
udev-extraconf: let automount base directory configurable
udev-extraconf: fix some systemd automount issues udev-extraconf:mount.sh: fix path mismatching issues

Muhammad Hamza (5):
udev-extraconf/mount.sh: add LABELs to mountpoints udev-extraconf/mount.sh: save mount name in our tmp filecache udev-extraconf/mount.sh: only mount devices on hotplug
udev-extraconf: force systemd-udevd to use shared MountFlags udev-extraconf/mount.sh: ignore lvm in automount

Richard Purdie (1):
udev-extraconf/initrdscripts/parted: Rename mount.blacklist ->
mount.ignorelist

 .../files/init-install-efi-testfs.sh          |  2 +-
 .../initrdscripts/files/init-install-efi.sh   |  2 +-
 .../files/init-install-testfs.sh              |  2 +-
 .../initrdscripts/files/init-install.sh       |  2 +-
 .../{mount.blacklist => mount.ignorelist}     |  0
 .../recipes-core/udev/udev-extraconf/mount.sh | 90 ++++++++++++++-----
 meta/recipes-core/udev/udev-extraconf_1.1.bb  | 27 ++++--
 meta/recipes-extended/parted/files/run-ptest  |  6 +-
 8 files changed, 95 insertions(+), 36 deletions(-)
 rename meta/recipes-core/udev/udev-extraconf/{mount.blacklist => mount.ignorelist} (100%)
Signature · 1 line
2.25.1
#1 lore raw

PATCH 1/9 udev-extraconf/initrdscripts/parted: Rename mount.blacklist -> mount.ignorelist

From: Richard Purdie <[email protected]>

(cherry picked from commit 69e486ddb3059f80ba538e1f59c2ca8a8df0faf9)
---
 .../initrdscripts/files/init-install-efi-testfs.sh     |  2 +-
 .../initrdscripts/files/init-install-efi.sh            |  2 +-
 .../initrdscripts/files/init-install-testfs.sh         |  2 +-
 meta/recipes-core/initrdscripts/files/init-install.sh  |  2 +-
 .../{mount.blacklist => mount.ignorelist}              |  0
 meta/recipes-core/udev/udev-extraconf/mount.sh         |  4 ++--
 meta/recipes-core/udev/udev-extraconf_1.1.bb           | 10 +++++-----
 meta/recipes-extended/parted/files/run-ptest           |  6 +++---
 8 files changed, 14 insertions(+), 14 deletions(-)
 rename meta/recipes-core/udev/udev-extraconf/{mount.blacklist => mount.ignorelist} (100%)
meta/recipes-core/initrdscripts/files/init-install-efi-testfs.sh +1 -1
index 1fcd29e54c..4bd6ace7b3 100644
@@ -138,7 +138,7 @@ touch /ssd/etc/controllerimage
 if [ -d /ssd/etc/ ] ; then
     # We dont want udev to mount our root device while we're booting...
     if [ -d /ssd/etc/udev/ ] ; then
-        echo "/dev/${device}" >> /ssd/etc/udev/mount.blacklist
+        echo "/dev/${device}" >> /ssd/etc/udev/mount.ignorelist
     fi
 fi
 
meta/recipes-core/initrdscripts/files/init-install-efi.sh +1 -1
index f667518b89..ffd3870199 100644
@@ -229,7 +229,7 @@ if [ -d /tgt_root/etc/ ] ; then
     echo "UUID=$boot_uuid              /boot            vfat       defaults              1  2" >> /tgt_root/etc/fstab
     # We dont want udev to mount our root device while we're booting...
     if [ -d /tgt_root/etc/udev/ ] ; then
-        echo "${device}" >> /tgt_root/etc/udev/mount.blacklist
+        echo "${device}" >> /tgt_root/etc/udev/mount.ignorelist
     fi
 fi
 
meta/recipes-core/initrdscripts/files/init-install-testfs.sh +1 -1
index 7b49001659..8ab74ddc5d 100644
@@ -164,7 +164,7 @@ if [ -d /tgt_root/etc/ ] ; then
     echo "$bootfs              /boot            ext3       defaults              1  2" >> /tgt_root/etc/fstab
     # We dont want udev to mount our root device while we're booting...
     if [ -d /tgt_root/etc/udev/ ] ; then
-	echo "/dev/${device}" >> /tgt_root/etc/udev/mount.blacklist
+	echo "/dev/${device}" >> /tgt_root/etc/udev/mount.ignorelist
     fi
 fi
 umount /tgt_root
meta/recipes-core/initrdscripts/files/init-install.sh +1 -1
index e71579631b..df33791ec7 100644
@@ -261,7 +261,7 @@ if [ -d /tgt_root/etc/ ] ; then
     echo "$bootdev              /boot            ext3       defaults              1  2" >> /tgt_root/etc/fstab
     # We dont want udev to mount our root device while we're booting...
     if [ -d /tgt_root/etc/udev/ ] ; then
-        echo "${device}" >> /tgt_root/etc/udev/mount.blacklist
+        echo "${device}" >> /tgt_root/etc/udev/mount.ignorelist
     fi
 fi
 umount /tgt_root
meta/recipes-core/udev/udev-extraconf/mount.ignorelist renamed from meta/recipes-core/udev/udev-extraconf/mount.blacklist +0 -0
similarity index 100%
rename from meta/recipes-core/udev/udev-extraconf/mount.blacklist
rename to meta/recipes-core/udev/udev-extraconf/mount.ignorelist
meta/recipes-core/udev/udev-extraconf/mount.sh +2 -2
index b23731870e..5ba66e98e2 100644
@@ -26,11 +26,11 @@ fi
 
 PMOUNT="/usr/bin/pmount"
 
-for line in `grep -h -v ^# /etc/udev/mount.blacklist /etc/udev/mount.blacklist.d/*`
+for line in `grep -h -v ^# /etc/udev/mount.ignorelist /etc/udev/mount.ignorelist.d/*`
 do
 	if [ ` expr match "$DEVNAME" "$line" ` -gt 0 ];
 	then
-		logger "udev/mount.sh" "[$DEVNAME] is blacklisted, ignoring"
+		logger "udev/mount.sh" "[$DEVNAME] is marked to ignore"
 		exit 0
 	fi
 done
meta/recipes-core/udev/udev-extraconf_1.1.bb +5 -5
index 2ba35b0df6..7da04379c0 100644
@@ -1,13 +1,13 @@
 SUMMARY = "Extra machine specific configuration files"
 HOMEPAGE = "https://wiki.gentoo.org/wiki/Eudev"
-DESCRIPTION = "Extra machine specific configuration files for udev, specifically blacklist information."
+DESCRIPTION = "Extra machine specific configuration files for udev, specifically information on devices to ignore."
 LICENSE = "MIT"
 LIC_FILES_CHKSUM = "file://${COREBASE}/meta/COPYING.MIT;md5=3da9cfbcb788c80a0384361b4de20420"
 
 SRC_URI = " \
        file://automount.rules \
        file://mount.sh \
-       file://mount.blacklist \
+       file://mount.ignorelist \
        file://autonet.rules \
        file://network.sh \
        file://localextra.rules \
@@ -23,8 +23,8 @@ do_install() {
     install -m 0644 ${WORKDIR}/autonet.rules       ${D}${sysconfdir}/udev/rules.d/autonet.rules
     install -m 0644 ${WORKDIR}/localextra.rules    ${D}${sysconfdir}/udev/rules.d/localextra.rules
 
-    install -d ${D}${sysconfdir}/udev/mount.blacklist.d
-    install -m 0644 ${WORKDIR}/mount.blacklist     ${D}${sysconfdir}/udev/
+    install -d ${D}${sysconfdir}/udev/mount.ignorelist.d
+    install -m 0644 ${WORKDIR}/mount.ignorelist     ${D}${sysconfdir}/udev/
 
     install -d ${D}${sysconfdir}/udev/scripts/
 
@@ -37,7 +37,7 @@ do_install() {
 
 FILES:${PN} = "${sysconfdir}/udev"
 RDEPENDS:${PN} = "udev"
-CONFFILES:${PN} = "${sysconfdir}/udev/mount.blacklist"
+CONFFILES:${PN} = "${sysconfdir}/udev/mount.ignorelist"
 
 # to replace udev-extra-rules from meta-oe
 RPROVIDES:${PN} = "udev-extra-rules"
meta/recipes-extended/parted/files/run-ptest +3 -3
index c3d6fca339..096078967f 100644
@@ -1,7 +1,7 @@
 #!/bin/sh
 
-mkdir -p /etc/udev/mount.blacklist.d
-echo /dev/sda1 >> /etc/udev/mount.blacklist.d/parted-tmp
+mkdir -p /etc/udev/mount.ignorelist.d
+echo /dev/sda1 >> /etc/udev/mount.ignorelist.d/parted-tmp
 rm -f tests/*.log
 make -C tests test-suite.log
-rm /etc/udev/mount.blacklist.d/parted-tmp
+rm /etc/udev/mount.ignorelist.d/parted-tmp
Signature · 1 line
2.25.1
#2 lore raw

PATCH 2/9 udev-extraconf: let automount base directory configurable

In reply to [email protected]

From: Ming Liu <[email protected]>

Dont hard-code automount base directory to '/run/media', introduce a variable MOUNT_BASE to let it configurable, like in udisks2 the mount base is also configurable by setting option: --enable-fhs-media.

(cherry picked from commit f077befd5f36ad88623aaf6a38b1a837ecb18650)
---
 .../recipes-core/udev/udev-extraconf/mount.sh | 25 ++++++++++---------
 meta/recipes-core/udev/udev-extraconf_1.1.bb  |  2 ++
 2 files changed, 15 insertions(+), 12 deletions(-)
meta/recipes-core/udev/udev-extraconf/mount.sh +13 -12
index 5ba66e98e2..c8b773bc07 100644
@@ -6,6 +6,7 @@
 
 BASE_INIT="`readlink -f "@base_sbindir@/init"`"
 INIT_SYSTEMD="@systemd_unitdir@/systemd"
+MOUNT_BASE="@MOUNT_BASE@"
 
 if [ "x$BASE_INIT" = "x$INIT_SYSTEMD" ];then
     # systemd as init uses systemd-mount to mount block devices
@@ -40,7 +41,7 @@ automount_systemd() {
 
     # Skip already mounted partitions
     if [ -f /run/systemd/transient/run-media-$name.mount ]; then
-        logger "mount.sh/automount" "/run/media/$name already mounted"
+        logger "mount.sh/automount" "$MOUNT_BASE/$name already mounted"
         return
     fi
 
@@ -53,7 +54,7 @@ automount_systemd() {
         grep "^[[:space:]]*$tmp" /etc/fstab && return
     done
 
-    [ -d "/run/media/$name" ] || mkdir -p "/run/media/$name"
+    [ -d "$MOUNT_BASE/$name" ] || mkdir -p "$MOUNT_BASE/$name"
 
     MOUNT="$MOUNT -o silent"
 
@@ -70,12 +71,12 @@ automount_systemd() {
         ;;
     esac
 
-    if ! $MOUNT --no-block -t auto $DEVNAME "/run/media/$name"
+    if ! $MOUNT --no-block -t auto $DEVNAME "$MOUNT_BASE/$name"
     then
-        #logger "mount.sh/automount" "$MOUNT -t auto $DEVNAME \"/run/media/$name\" failed!"
-        rm_dir "/run/media/$name"
+        #logger "mount.sh/automount" "$MOUNT -t auto $DEVNAME \"$MOUNT_BASE/$name\" failed!"
+        rm_dir "$MOUNT_BASE/$name"
     else
-        logger "mount.sh/automount" "Auto-mount of [/run/media/$name] successful"
+        logger "mount.sh/automount" "Auto-mount of [$MOUNT_BASE/$name] successful"
         touch "/tmp/.automount-$name"
     fi
 }
@@ -93,7 +94,7 @@ automount() {
 	# configured in fstab
 	grep -q "^$DEVNAME " /proc/mounts && return
 
-	! test -d "/run/media/$name" && mkdir -p "/run/media/$name"
+	! test -d "$MOUNT_BASE/$name" && mkdir -p "$MOUNT_BASE/$name"
 	# Silent util-linux's version of mounting auto
 	if [ "x`readlink $MOUNT`" = "x/bin/mount.util-linux" ] ;
 	then
@@ -113,12 +114,12 @@ automount() {
 		;;
 	esac
 
-	if ! $MOUNT -t auto $DEVNAME "/run/media/$name"
+	if ! $MOUNT -t auto $DEVNAME "$MOUNT_BASE/$name"
 	then
-		#logger "mount.sh/automount" "$MOUNT -t auto $DEVNAME \"/run/media/$name\" failed!"
-		rm_dir "/run/media/$name"
+		#logger "mount.sh/automount" "$MOUNT -t auto $DEVNAME \"$MOUNT_BASE/$name\" failed!"
+		rm_dir "$MOUNT_BASE/$name"
 	else
-		logger "mount.sh/automount" "Auto-mount of [/run/media/$name] successful"
+		logger "mount.sh/automount" "Auto-mount of [$MOUNT_BASE/$name] successful"
 		touch "/tmp/.automount-$name"
 	fi
 }
@@ -157,5 +158,5 @@ if [ "$ACTION" = "remove" ] || [ "$ACTION" = "change" ] && [ -x "$UMOUNT" ] && [
 
     # Remove empty directories from auto-mounter
     name="`basename "$DEVNAME"`"
-    test -e "/tmp/.automount-$name" && rm_dir "/run/media/$name"
+    test -e "/tmp/.automount-$name" && rm_dir "$MOUNT_BASE/$name"
 fi
meta/recipes-core/udev/udev-extraconf_1.1.bb +2 -0
index 7da04379c0..2b908ac05b 100644
@@ -15,6 +15,7 @@ SRC_URI = " \
 
 S = "${WORKDIR}"
 
+MOUNT_BASE = "/run/media"
 
 do_install() {
     install -d ${D}${sysconfdir}/udev/rules.d
@@ -31,6 +32,7 @@ do_install() {
     install -m 0755 ${WORKDIR}/mount.sh ${D}${sysconfdir}/udev/scripts/mount.sh
     sed -i 's|@systemd_unitdir@|${systemd_unitdir}|g' ${D}${sysconfdir}/udev/scripts/mount.sh
     sed -i 's|@base_sbindir@|${base_sbindir}|g' ${D}${sysconfdir}/udev/scripts/mount.sh
+    sed -i 's|@MOUNT_BASE@|${MOUNT_BASE}|g' ${D}${sysconfdir}/udev/scripts/mount.sh
 
     install -m 0755 ${WORKDIR}/network.sh ${D}${sysconfdir}/udev/scripts
 }
Signature · 1 line
2.25.1
#3 lore raw

PATCH 3/9 udev-extraconf/mount.sh: add LABELs to mountpoints

In reply to [email protected]

From: Muhammad Hamza <[email protected]>

This alters the mountpoints such that if a device has a LABEL or a PARTLABEL, it will be mounted at e.g.:

/run/media/$LABEL-<device-node>
/run/media/$PARTLABEL-<device-node>
/run/media/rootfs-sda2

otherwise the device will be mounted at e.g.:

/run/media/<device-node>
/run/media/sda1

The <device-node> appended with LABEL or PARTLABEL makes sure that the mountpoint is unique, therefore, avoids overlapping mounts.

(cherry picked from commit a9a0a0967832445f1bcc65d58f95343d1b562e1b)
---
 meta/recipes-core/udev/udev-extraconf/mount.sh | 18 ++++++++++++++++++
 meta/recipes-core/udev/udev-extraconf_1.1.bb   |  2 +-
 2 files changed, 19 insertions(+), 1 deletion(-)
meta/recipes-core/udev/udev-extraconf/mount.sh +18 -0
index c8b773bc07..40910be8bd 100644
@@ -54,6 +54,9 @@ automount_systemd() {
         grep "^[[:space:]]*$tmp" /etc/fstab && return
     done
 
+    # Get the unique name for mount point
+    get_label_name "${DEVNAME}"
+
     [ -d "$MOUNT_BASE/$name" ] || mkdir -p "$MOUNT_BASE/$name"
 
     MOUNT="$MOUNT -o silent"
@@ -94,6 +97,9 @@ automount() {
 	# configured in fstab
 	grep -q "^$DEVNAME " /proc/mounts && return
 
+	# Get the unique name for mount point
+	get_label_name "${DEVNAME}"
+
 	! test -d "$MOUNT_BASE/$name" && mkdir -p "$MOUNT_BASE/$name"
 	# Silent util-linux's version of mounting auto
 	if [ "x`readlink $MOUNT`" = "x/bin/mount.util-linux" ] ;
@@ -134,6 +140,18 @@ rm_dir() {
 	fi
 }
 
+get_label_name() {
+	# Get the LABEL or PARTLABEL
+	LABEL=`/sbin/blkid | grep "$1:" | grep -o 'LABEL=".*"' | cut -d '"' -f2`
+	# If the $DEVNAME has a LABEL or a PARTLABEL
+	if [ -n "$LABEL" ]; then
+	        # Set the mount location dir name to LABEL appended
+        	# with $name e.g. label-sda. That would avoid overlapping
+	        # mounts in case two devices have same LABEL
+        	name="${LABEL}-${name}"
+	fi
+}
+
 # No ID_FS_TYPE for cdrom device, yet it should be mounted
 name="`basename "$DEVNAME"`"
 [ -e /sys/block/$name/device/media ] && media_type=`cat /sys/block/$name/device/media`
meta/recipes-core/udev/udev-extraconf_1.1.bb +1 -1
index 2b908ac05b..8213c1a930 100644
@@ -38,7 +38,7 @@ do_install() {
 }
 
 FILES:${PN} = "${sysconfdir}/udev"
-RDEPENDS:${PN} = "udev"
+RDEPENDS:${PN} = "udev util-linux-blkid"
 CONFFILES:${PN} = "${sysconfdir}/udev/mount.ignorelist"
 
 # to replace udev-extra-rules from meta-oe
Signature · 1 line
2.25.1
#4 lore raw

PATCH 4/9 udev-extraconf/mount.sh: save mount name in our tmp filecache

In reply to [email protected]

From: Muhammad Hamza <[email protected]>

Doing this will allow to fetch the exact name created by the auto-mounter during the remove action where depending on the scenario utilities such as the blkid might not be usable due to actual device not being present on the system.

(cherry picked from commit 496b76f8775a620c1d449eb6f62a41656abf2a9b)
---
 meta/recipes-core/udev/udev-extraconf/mount.sh | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)
meta/recipes-core/udev/udev-extraconf/mount.sh +4 -1
index 40910be8bd..c4695ee27d 100644
@@ -126,7 +126,10 @@ automount() {
 		rm_dir "$MOUNT_BASE/$name"
 	else
 		logger "mount.sh/automount" "Auto-mount of [$MOUNT_BASE/$name] successful"
-		touch "/tmp/.automount-$name"
+		# The actual device might not be present in the remove event so blkid cannot
+		# be used to calculate what name was generated here. Simply save the mount
+		# name in our tmp file.
+		echo "$name" > "/tmp/.automount-$name"
 	fi
 }
 	
Signature · 1 line
2.25.1
#5 lore raw

PATCH 5/9 udev-extraconf/mount.sh: only mount devices on hotplug

In reply to [email protected]

From: Muhammad Hamza <[email protected]>

fdisk from util-linux (2.31.1) and above allows the user to manipulate an already mounted device. In order to achieve this functionality it issues a BLKRRPART (block device re-read part) ioctl and in response the kernel generates remove/change/add events if the device is not mounted (manually unmounted etc) which are caught and processed by udev. This causes our auto-mounter to remount everything because it does not keep track and things go out of control.
Differentiating between types of remove events such as the one described above (generated by BLKRRPART) and one where the device is physically plugged out is only possible using the DEVPATH variable which is cleaned up only when the device is actually plugged-out. This fixes the above anomaly by only mounting a device in add event which is cleaned up properly (tmp cache deleted) in the remove event or is not present in the tmp cache while making use of the DEVPATH variable during the remove action.

(cherry picked from commit 11a5e6c17535438ea1e7a8403ed260c8b3a22bc8)
---
 .../recipes-core/udev/udev-extraconf/mount.sh | 34 +++++++++++++++----
 1 file changed, 27 insertions(+), 7 deletions(-)
meta/recipes-core/udev/udev-extraconf/mount.sh +27 -7
index c4695ee27d..537828e3e3 100644
@@ -45,6 +45,13 @@ automount_systemd() {
         return
     fi
 
+    # Only go for auto-mounting when the device has been cleaned up in remove
+    # or has not been identified yet
+    if [ -e "/tmp/.automount-$name" ]; then
+            logger "mount.sh/automount" "[$MOUNT_BASE/$name] is already cached"
+            return
+    fi
+
     # Skip the partition which are already in /etc/fstab
     grep "^[[:space:]]*$DEVNAME" /etc/fstab && return
     for n in LABEL PARTLABEL UUID PARTUUID; do
@@ -100,6 +107,13 @@ automount() {
 	# Get the unique name for mount point
 	get_label_name "${DEVNAME}"
 
+        # Only go for auto-mounting when the device has been cleaned up in remove
+        # or has not been identified yet
+        if [ -e "/tmp/.automount-$name" ]; then
+                logger "mount.sh/automount" "[$MOUNT_BASE/$name] is already cached"
+                return
+        fi
+
 	! test -d "$MOUNT_BASE/$name" && mkdir -p "$MOUNT_BASE/$name"
 	# Silent util-linux's version of mounting auto
 	if [ "x`readlink $MOUNT`" = "x/bin/mount.util-linux" ] ;
@@ -172,12 +186,18 @@ if [ "$ACTION" = "add" ] && [ -n "$DEVNAME" ] && [ -n "$ID_FS_TYPE" -o "$media_t
 fi
 
 if [ "$ACTION" = "remove" ] || [ "$ACTION" = "change" ] && [ -x "$UMOUNT" ] && [ -n "$DEVNAME" ]; then
-    for mnt in `cat /proc/mounts | grep "$DEVNAME" | cut -f 2 -d " " `
-    do
-        $UMOUNT $mnt
-    done
-
-    # Remove empty directories from auto-mounter
     name="`basename "$DEVNAME"`"
-    test -e "/tmp/.automount-$name" && rm_dir "$MOUNT_BASE/$name"
+    tmpfile=`find /tmp | grep "\.automount-.*${name}$"`
+    if [ ! -e "/sys/$DEVPATH" -a -e "$tmpfile" ]; then
+        logger "mount.sh/remove" "cleaning up $DEVNAME, was mounted by the auto-mounter"
+        for mnt in `cat /proc/mounts | grep "$DEVNAME" | cut -f 2 -d " " `
+        do
+                $UMOUNT $mnt
+        done
+        # Remove mount directory created by the auto-mounter
+        # and clean up our tmp cache file
+        mntdir=`cat "$tmpfile"`
+        rm_dir "$MOUNT_BASE/$mntdir"
+        rm "$tmpfile"
+    fi
 fi
Signature · 1 line
2.25.1
#6 lore raw

PATCH 6/9 udev-extraconf: force systemd-udevd to use shared MountFlags

In reply to [email protected]

From: Muhammad Hamza <[email protected]>

Automounting does not work cleanly in case systemd as well as udev rules are being used simultaneously and in most cases race conditions and unknown behavior can come up. In case we're running on top of systemd we need to make sure that systemd-udevd knows that udev is in play as well and mounting should be done using shared flags. Also as we're using mount from sources other than systemd-mount in current scripts this is the most manageable fix to automounting problems.

(cherry picked from commit 1e770416b4c9a0468404fb64d55114d93e84763b)
---
 .../udev/udev-extraconf/systemd-udevd.service            | 3 +++
 meta/recipes-core/udev/udev-extraconf_1.1.bb             | 9 ++++++++-
 2 files changed, 11 insertions(+), 1 deletion(-)
 create mode 100644 meta/recipes-core/udev/udev-extraconf/systemd-udevd.service
meta/recipes-core/udev/udev-extraconf/systemd-udevd.service new file +3 -0
new file mode 100644
index 0000000000..a9b86eb6e4
@@ -0,0 +1,3 @@
+.include @systemd_unitdir@/system/systemd-udevd.service
+[Service]
+MountFlags=shared
meta/recipes-core/udev/udev-extraconf_1.1.bb +8 -1
index 8213c1a930..ef6019259e 100644
@@ -11,6 +11,7 @@ SRC_URI = " \
        file://autonet.rules \
        file://network.sh \
        file://localextra.rules \
+       ${@bb.utils.contains('DISTRO_FEATURES', 'systemd', 'file://systemd-udevd.service', '', d)} \
 "
 
 S = "${WORKDIR}"
@@ -35,9 +36,15 @@ do_install() {
     sed -i 's|@MOUNT_BASE@|${MOUNT_BASE}|g' ${D}${sysconfdir}/udev/scripts/mount.sh
 
     install -m 0755 ${WORKDIR}/network.sh ${D}${sysconfdir}/udev/scripts
+
+    if ${@bb.utils.contains('DISTRO_FEATURES', 'systemd', 'true', 'false', d)}; then
+        install -d ${D}${sysconfdir}/systemd/system
+        install ${WORKDIR}/systemd-udevd.service ${D}${sysconfdir}/systemd/system/systemd-udevd.service
+        sed -i 's|@systemd_unitdir@|${systemd_unitdir}|g' ${D}${sysconfdir}/systemd/system/systemd-udevd.service
+    fi
 }
 
-FILES:${PN} = "${sysconfdir}/udev"
+FILES:${PN} = "${sysconfdir}/udev ${@bb.utils.contains('DISTRO_FEATURES', 'systemd', '${sysconfdir}/systemd/system/systemd-udevd.service', '', d)}"
 RDEPENDS:${PN} = "udev util-linux-blkid"
 CONFFILES:${PN} = "${sysconfdir}/udev/mount.ignorelist"
 
Signature · 1 line
2.25.1
#7 lore raw

PATCH 7/9 udev-extraconf/mount.sh: ignore lvm in automount

In reply to [email protected]

From: Muhammad Hamza <[email protected]>

Failure message is shown in boot logs when trying to mount lvm as automounter does not handle cases where lvm is mounted. This simply skips lvm while automounting to avoid failure message in boot logs.

(cherry picked from commit b1d18072ed9a8b0bca0f20f8e5deefa73ab6acbe)
---
 meta/recipes-core/udev/udev-extraconf/mount.sh | 4 ++++
 1 file changed, 4 insertions(+)
meta/recipes-core/udev/udev-extraconf/mount.sh +4 -0
index 537828e3e3..8b6ce77741 100644
@@ -76,6 +76,8 @@ automount_systemd() {
         ;;
     swap)
         return ;;
+    lvm*|LVM*)
+        return ;;
     # TODO
     *)
         ;;
@@ -129,6 +131,8 @@ automount() {
 		;;
 	swap)
 		return ;;
+	lvm*|LVM*)
+                return ;;
 	# TODO
 	*)
 		;;
Signature · 1 line
2.25.1
#8 lore raw

PATCH 8/9 udev-extraconf: fix some systemd automount issues

In reply to [email protected]

From: Ming Liu <[email protected]>

The '.include' syntax has been dropped from latest systemd releases, we need drop the systemd-udevd.service here, introduce a postinst function to add "MountFlags=shared" to systemd-udevd.service.

Also lsblk binary is being called in mount.sh automount_systemd function, add it to RDEPENDS.

(cherry picked from commit 356520d60b9429c6f62124821e42468ff2b7b1d6)
---
 .../udev/udev-extraconf/systemd-udevd.service |  3 ---
 meta/recipes-core/udev/udev-extraconf_1.1.bb  | 20 +++++++++++--------
 2 files changed, 12 insertions(+), 11 deletions(-)
 delete mode 100644 meta/recipes-core/udev/udev-extraconf/systemd-udevd.service
meta/recipes-core/udev/udev-extraconf/systemd-udevd.service deleted +0 -3
deleted file mode 100644
index a9b86eb6e4..0000000000
@@ -1,3 +0,0 @@
-.include @systemd_unitdir@/system/systemd-udevd.service
-[Service]
-MountFlags=shared
meta/recipes-core/udev/udev-extraconf_1.1.bb +12 -8
index ef6019259e..30f1fe76d0 100644
@@ -11,7 +11,6 @@ SRC_URI = " \
        file://autonet.rules \
        file://network.sh \
        file://localextra.rules \
-       ${@bb.utils.contains('DISTRO_FEATURES', 'systemd', 'file://systemd-udevd.service', '', d)} \
 "
 
 S = "${WORKDIR}"
@@ -36,16 +35,21 @@ do_install() {
     sed -i 's|@MOUNT_BASE@|${MOUNT_BASE}|g' ${D}${sysconfdir}/udev/scripts/mount.sh
 
     install -m 0755 ${WORKDIR}/network.sh ${D}${sysconfdir}/udev/scripts
+}
+
+pkg_postinst:${PN} () {
+	if [ -e $D${systemd_unitdir}/system/systemd-udevd.service ]; then
+		sed -i "/\[Service\]/aMountFlags=shared" $D${systemd_unitdir}/system/systemd-udevd.service
+	fi
+}
 
-    if ${@bb.utils.contains('DISTRO_FEATURES', 'systemd', 'true', 'false', d)}; then
-        install -d ${D}${sysconfdir}/systemd/system
-        install ${WORKDIR}/systemd-udevd.service ${D}${sysconfdir}/systemd/system/systemd-udevd.service
-        sed -i 's|@systemd_unitdir@|${systemd_unitdir}|g' ${D}${sysconfdir}/systemd/system/systemd-udevd.service
-    fi
+pkg_postrm:${PN} () {
+	if [ -e $D${systemd_unitdir}/system/systemd-udevd.service ]; then
+		sed -i "/MountFlags=shared/d" $D${systemd_unitdir}/system/systemd-udevd.service
+	fi
 }
 
-FILES:${PN} = "${sysconfdir}/udev ${@bb.utils.contains('DISTRO_FEATURES', 'systemd', '${sysconfdir}/systemd/system/systemd-udevd.service', '', d)}"
-RDEPENDS:${PN} = "udev util-linux-blkid"
+RDEPENDS:${PN} = "udev util-linux-blkid ${@bb.utils.contains('DISTRO_FEATURES', 'systemd', 'util-linux-lsblk', '', d)}"
 CONFFILES:${PN} = "${sysconfdir}/udev/mount.ignorelist"
 
 # to replace udev-extra-rules from meta-oe
Signature · 1 line
2.25.1
#9 lore raw

PATCH 9/9 udev-extraconf:mount.sh: fix path mismatching issues

In reply to [email protected]

From: Ming Liu <[email protected]>

Since commit f077befd5f36ad88623aaf6a38b1a837ecb18650:
[ udev-extraconf: let automount base directory configurable ]

the mount base directory was configurable, we need drop 'run-media' usage as well, change to figure it out from MOUNT_BASE.

Also 'get_label_name' function needs to be called ealier in automount_systemd before checking '/tmp/.automount-$name', otherwise they would never match.

(From OE-Core rev: c013b33162546fb5bd4bcc1daac75aa65d0be1a3)

(cherry picked from commit 7ed210054b3e253d5a67075bb9d4768d1661bef1)
---
 meta/recipes-core/udev/udev-extraconf/mount.sh | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)
meta/recipes-core/udev/udev-extraconf/mount.sh +4 -4
index 8b6ce77741..43acb3a7a0 100644
@@ -40,11 +40,14 @@ automount_systemd() {
     name="`basename "$DEVNAME"`"
 
     # Skip already mounted partitions
-    if [ -f /run/systemd/transient/run-media-$name.mount ]; then
+    if [ -f /run/systemd/transient/$(echo $MOUNT_BASE | cut -d '/' -f 2- | sed 's#/#-#g')-*$name.mount ]; then
         logger "mount.sh/automount" "$MOUNT_BASE/$name already mounted"
         return
     fi
 
+    # Get the unique name for mount point
+    get_label_name "${DEVNAME}"
+
     # Only go for auto-mounting when the device has been cleaned up in remove
     # or has not been identified yet
     if [ -e "/tmp/.automount-$name" ]; then
@@ -61,9 +64,6 @@ automount_systemd() {
         grep "^[[:space:]]*$tmp" /etc/fstab && return
     done
 
-    # Get the unique name for mount point
-    get_label_name "${DEVNAME}"
-
     [ -d "$MOUNT_BASE/$name" ] || mkdir -p "$MOUNT_BASE/$name"
 
     MOUNT="$MOUNT -o silent"
Signature · 1 line
2.25.1