* [OE-core] [kirkstone] [PATCH 1/9] udev-extraconf/initrdscripts/parted: Rename mount.blacklist -> mount.ignorelist
2022-07-17 12:56 [OE-core] [kirkstone] [PATCH 0/9] udev-extraconf fixes liu.ming50
@ 2022-07-17 12:56 ` liu.ming50
2022-07-17 12:56 ` [OE-core] [kirkstone] [PATCH 2/9] udev-extraconf: let automount base directory configurable liu.ming50
` (7 subsequent siblings)
8 siblings, 0 replies; 10+ messages in thread
From: liu.ming50 @ 2022-07-17 12:56 UTC (permalink / raw)
To: openembedded-core; +Cc: steve, Richard Purdie, Luca Ceresoli, Ming Liu
From: Richard Purdie <richard.purdie@linuxfoundation.org>
Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
Signed-off-by: Luca Ceresoli <luca.ceresoli@bootlin.com>
Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
(cherry picked from commit 69e486ddb3059f80ba538e1f59c2ca8a8df0faf9)
Signed-off-by: Ming Liu <liu.ming50@gmail.com>
---
.../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
| 4 ++--
| 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%)
diff --git a/meta/recipes-core/initrdscripts/files/init-install-efi-testfs.sh b/meta/recipes-core/initrdscripts/files/init-install-efi-testfs.sh
index 1fcd29e54c..4bd6ace7b3 100644
--- a/meta/recipes-core/initrdscripts/files/init-install-efi-testfs.sh
+++ b/meta/recipes-core/initrdscripts/files/init-install-efi-testfs.sh
@@ -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
diff --git a/meta/recipes-core/initrdscripts/files/init-install-efi.sh b/meta/recipes-core/initrdscripts/files/init-install-efi.sh
index f667518b89..ffd3870199 100644
--- a/meta/recipes-core/initrdscripts/files/init-install-efi.sh
+++ b/meta/recipes-core/initrdscripts/files/init-install-efi.sh
@@ -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
diff --git a/meta/recipes-core/initrdscripts/files/init-install-testfs.sh b/meta/recipes-core/initrdscripts/files/init-install-testfs.sh
index 7b49001659..8ab74ddc5d 100644
--- a/meta/recipes-core/initrdscripts/files/init-install-testfs.sh
+++ b/meta/recipes-core/initrdscripts/files/init-install-testfs.sh
@@ -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
diff --git a/meta/recipes-core/initrdscripts/files/init-install.sh b/meta/recipes-core/initrdscripts/files/init-install.sh
index e71579631b..df33791ec7 100644
--- a/meta/recipes-core/initrdscripts/files/init-install.sh
+++ b/meta/recipes-core/initrdscripts/files/init-install.sh
@@ -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
--git a/meta/recipes-core/udev/udev-extraconf/mount.blacklist b/meta/recipes-core/udev/udev-extraconf/mount.ignorelist
similarity index 100%
rename from meta/recipes-core/udev/udev-extraconf/mount.blacklist
rename to meta/recipes-core/udev/udev-extraconf/mount.ignorelist
diff --git a/meta/recipes-core/udev/udev-extraconf/mount.sh b/meta/recipes-core/udev/udev-extraconf/mount.sh
index b23731870e..5ba66e98e2 100644
--- a/meta/recipes-core/udev/udev-extraconf/mount.sh
+++ b/meta/recipes-core/udev/udev-extraconf/mount.sh
@@ -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
--git a/meta/recipes-core/udev/udev-extraconf_1.1.bb b/meta/recipes-core/udev/udev-extraconf_1.1.bb
index 2ba35b0df6..7da04379c0 100644
--- a/meta/recipes-core/udev/udev-extraconf_1.1.bb
+++ b/meta/recipes-core/udev/udev-extraconf_1.1.bb
@@ -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"
diff --git a/meta/recipes-extended/parted/files/run-ptest b/meta/recipes-extended/parted/files/run-ptest
index c3d6fca339..096078967f 100644
--- a/meta/recipes-extended/parted/files/run-ptest
+++ b/meta/recipes-extended/parted/files/run-ptest
@@ -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
--
2.25.1
^ permalink raw reply related [flat|nested] 10+ messages in thread* [OE-core] [kirkstone] [PATCH 2/9] udev-extraconf: let automount base directory configurable
2022-07-17 12:56 [OE-core] [kirkstone] [PATCH 0/9] udev-extraconf fixes liu.ming50
2022-07-17 12:56 ` [OE-core] [kirkstone] [PATCH 1/9] udev-extraconf/initrdscripts/parted: Rename mount.blacklist -> mount.ignorelist liu.ming50
@ 2022-07-17 12:56 ` liu.ming50
2022-07-17 12:56 ` [OE-core] [kirkstone] [PATCH 3/9] udev-extraconf/mount.sh: add LABELs to mountpoints liu.ming50
` (6 subsequent siblings)
8 siblings, 0 replies; 10+ messages in thread
From: liu.ming50 @ 2022-07-17 12:56 UTC (permalink / raw)
To: openembedded-core; +Cc: steve, Ming Liu, Luca Ceresoli, Richard Purdie
From: Ming Liu <liu.ming50@gmail.com>
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.
Signed-off-by: Ming Liu <liu.ming50@gmail.com>
Signed-off-by: Luca Ceresoli <luca.ceresoli@bootlin.com>
Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
(cherry picked from commit f077befd5f36ad88623aaf6a38b1a837ecb18650)
Signed-off-by: Ming Liu <liu.ming50@gmail.com>
---
| 25 ++++++++++---------
| 2 ++
2 files changed, 15 insertions(+), 12 deletions(-)
--git a/meta/recipes-core/udev/udev-extraconf/mount.sh b/meta/recipes-core/udev/udev-extraconf/mount.sh
index 5ba66e98e2..c8b773bc07 100644
--- a/meta/recipes-core/udev/udev-extraconf/mount.sh
+++ b/meta/recipes-core/udev/udev-extraconf/mount.sh
@@ -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
--git a/meta/recipes-core/udev/udev-extraconf_1.1.bb b/meta/recipes-core/udev/udev-extraconf_1.1.bb
index 7da04379c0..2b908ac05b 100644
--- a/meta/recipes-core/udev/udev-extraconf_1.1.bb
+++ b/meta/recipes-core/udev/udev-extraconf_1.1.bb
@@ -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
}
--
2.25.1
^ permalink raw reply related [flat|nested] 10+ messages in thread* [OE-core] [kirkstone] [PATCH 3/9] udev-extraconf/mount.sh: add LABELs to mountpoints
2022-07-17 12:56 [OE-core] [kirkstone] [PATCH 0/9] udev-extraconf fixes liu.ming50
2022-07-17 12:56 ` [OE-core] [kirkstone] [PATCH 1/9] udev-extraconf/initrdscripts/parted: Rename mount.blacklist -> mount.ignorelist liu.ming50
2022-07-17 12:56 ` [OE-core] [kirkstone] [PATCH 2/9] udev-extraconf: let automount base directory configurable liu.ming50
@ 2022-07-17 12:56 ` liu.ming50
2022-07-17 12:56 ` [OE-core] [kirkstone] [PATCH 4/9] udev-extraconf/mount.sh: save mount name in our tmp filecache liu.ming50
` (5 subsequent siblings)
8 siblings, 0 replies; 10+ messages in thread
From: liu.ming50 @ 2022-07-17 12:56 UTC (permalink / raw)
To: openembedded-core
Cc: steve, Muhammad Hamza, Arsalan H . Awan, Muhammad Hamza,
Luca Ceresoli, Ming Liu
From: Muhammad Hamza <Muhammad_Hamza@mentor.com>
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.
Signed-off-by: Arsalan H. Awan <Arsalan_Awan@mentor.com>
Signed-off-by: Muhammad Hamza <muhammad_hamza@mentor.com>
Signed-off-by: Luca Ceresoli <luca.ceresoli@bootlin.com>
(cherry picked from commit a9a0a0967832445f1bcc65d58f95343d1b562e1b)
Signed-off-by: Ming Liu <liu.ming50@gmail.com>
---
| 18 ++++++++++++++++++
| 2 +-
2 files changed, 19 insertions(+), 1 deletion(-)
--git a/meta/recipes-core/udev/udev-extraconf/mount.sh b/meta/recipes-core/udev/udev-extraconf/mount.sh
index c8b773bc07..40910be8bd 100644
--- a/meta/recipes-core/udev/udev-extraconf/mount.sh
+++ b/meta/recipes-core/udev/udev-extraconf/mount.sh
@@ -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`
--git a/meta/recipes-core/udev/udev-extraconf_1.1.bb b/meta/recipes-core/udev/udev-extraconf_1.1.bb
index 2b908ac05b..8213c1a930 100644
--- a/meta/recipes-core/udev/udev-extraconf_1.1.bb
+++ b/meta/recipes-core/udev/udev-extraconf_1.1.bb
@@ -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
--
2.25.1
^ permalink raw reply related [flat|nested] 10+ messages in thread* [OE-core] [kirkstone] [PATCH 4/9] udev-extraconf/mount.sh: save mount name in our tmp filecache
2022-07-17 12:56 [OE-core] [kirkstone] [PATCH 0/9] udev-extraconf fixes liu.ming50
` (2 preceding siblings ...)
2022-07-17 12:56 ` [OE-core] [kirkstone] [PATCH 3/9] udev-extraconf/mount.sh: add LABELs to mountpoints liu.ming50
@ 2022-07-17 12:56 ` liu.ming50
2022-07-17 12:56 ` [OE-core] [kirkstone] [PATCH 5/9] udev-extraconf/mount.sh: only mount devices on hotplug liu.ming50
` (4 subsequent siblings)
8 siblings, 0 replies; 10+ messages in thread
From: liu.ming50 @ 2022-07-17 12:56 UTC (permalink / raw)
To: openembedded-core
Cc: steve, Muhammad Hamza, Awais Belal, Muhammad Hamza, Luca Ceresoli,
Ming Liu
From: Muhammad Hamza <Muhammad_Hamza@mentor.com>
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.
Signed-off-by: Awais Belal <awais_belal@mentor.com>
Signed-off-by: Muhammad Hamza <muhammad_hamza@mentor.com>
Signed-off-by: Luca Ceresoli <luca.ceresoli@bootlin.com>
(cherry picked from commit 496b76f8775a620c1d449eb6f62a41656abf2a9b)
Signed-off-by: Ming Liu <liu.ming50@gmail.com>
---
| 5 ++++-
1 file changed, 4 insertions(+), 1 deletion(-)
--git a/meta/recipes-core/udev/udev-extraconf/mount.sh b/meta/recipes-core/udev/udev-extraconf/mount.sh
index 40910be8bd..c4695ee27d 100644
--- a/meta/recipes-core/udev/udev-extraconf/mount.sh
+++ b/meta/recipes-core/udev/udev-extraconf/mount.sh
@@ -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
}
--
2.25.1
^ permalink raw reply related [flat|nested] 10+ messages in thread* [OE-core] [kirkstone] [PATCH 5/9] udev-extraconf/mount.sh: only mount devices on hotplug
2022-07-17 12:56 [OE-core] [kirkstone] [PATCH 0/9] udev-extraconf fixes liu.ming50
` (3 preceding siblings ...)
2022-07-17 12:56 ` [OE-core] [kirkstone] [PATCH 4/9] udev-extraconf/mount.sh: save mount name in our tmp filecache liu.ming50
@ 2022-07-17 12:56 ` liu.ming50
2022-07-17 12:56 ` [OE-core] [kirkstone] [PATCH 6/9] udev-extraconf: force systemd-udevd to use shared MountFlags liu.ming50
` (3 subsequent siblings)
8 siblings, 0 replies; 10+ messages in thread
From: liu.ming50 @ 2022-07-17 12:56 UTC (permalink / raw)
To: openembedded-core
Cc: steve, Muhammad Hamza, Awais Belal, Muhammad Hamza, Luca Ceresoli,
Ming Liu
From: Muhammad Hamza <Muhammad_Hamza@mentor.com>
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.
Signed-off-by: Awais Belal <awais_belal@mentor.com>
Signed-off-by: Muhammad Hamza <muhammad_hamza@mentor.com>
Signed-off-by: Luca Ceresoli <luca.ceresoli@bootlin.com>
(cherry picked from commit 11a5e6c17535438ea1e7a8403ed260c8b3a22bc8)
Signed-off-by: Ming Liu <liu.ming50@gmail.com>
---
| 34 +++++++++++++++----
1 file changed, 27 insertions(+), 7 deletions(-)
--git a/meta/recipes-core/udev/udev-extraconf/mount.sh b/meta/recipes-core/udev/udev-extraconf/mount.sh
index c4695ee27d..537828e3e3 100644
--- a/meta/recipes-core/udev/udev-extraconf/mount.sh
+++ b/meta/recipes-core/udev/udev-extraconf/mount.sh
@@ -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
--
2.25.1
^ permalink raw reply related [flat|nested] 10+ messages in thread* [OE-core] [kirkstone] [PATCH 6/9] udev-extraconf: force systemd-udevd to use shared MountFlags
2022-07-17 12:56 [OE-core] [kirkstone] [PATCH 0/9] udev-extraconf fixes liu.ming50
` (4 preceding siblings ...)
2022-07-17 12:56 ` [OE-core] [kirkstone] [PATCH 5/9] udev-extraconf/mount.sh: only mount devices on hotplug liu.ming50
@ 2022-07-17 12:56 ` liu.ming50
2022-07-17 12:56 ` [OE-core] [kirkstone] [PATCH 7/9] udev-extraconf/mount.sh: ignore lvm in automount liu.ming50
` (2 subsequent siblings)
8 siblings, 0 replies; 10+ messages in thread
From: liu.ming50 @ 2022-07-17 12:56 UTC (permalink / raw)
To: openembedded-core
Cc: steve, Muhammad Hamza, Awais Belal, Muhammad Hamza, Luca Ceresoli,
Ming Liu
From: Muhammad Hamza <Muhammad_Hamza@mentor.com>
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.
Signed-off-by: Awais Belal <awais_belal@mentor.com>
Signed-off-by: Muhammad Hamza <muhammad_hamza@mentor.com>
Signed-off-by: Luca Ceresoli <luca.ceresoli@bootlin.com>
(cherry picked from commit 1e770416b4c9a0468404fb64d55114d93e84763b)
Signed-off-by: Ming Liu <liu.ming50@gmail.com>
---
| 3 +++
| 9 ++++++++-
2 files changed, 11 insertions(+), 1 deletion(-)
create mode 100644 meta/recipes-core/udev/udev-extraconf/systemd-udevd.service
--git a/meta/recipes-core/udev/udev-extraconf/systemd-udevd.service b/meta/recipes-core/udev/udev-extraconf/systemd-udevd.service
new file mode 100644
index 0000000000..a9b86eb6e4
--- /dev/null
+++ b/meta/recipes-core/udev/udev-extraconf/systemd-udevd.service
@@ -0,0 +1,3 @@
+.include @systemd_unitdir@/system/systemd-udevd.service
+[Service]
+MountFlags=shared
--git a/meta/recipes-core/udev/udev-extraconf_1.1.bb b/meta/recipes-core/udev/udev-extraconf_1.1.bb
index 8213c1a930..ef6019259e 100644
--- a/meta/recipes-core/udev/udev-extraconf_1.1.bb
+++ b/meta/recipes-core/udev/udev-extraconf_1.1.bb
@@ -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"
--
2.25.1
^ permalink raw reply related [flat|nested] 10+ messages in thread* [OE-core] [kirkstone] [PATCH 7/9] udev-extraconf/mount.sh: ignore lvm in automount
2022-07-17 12:56 [OE-core] [kirkstone] [PATCH 0/9] udev-extraconf fixes liu.ming50
` (5 preceding siblings ...)
2022-07-17 12:56 ` [OE-core] [kirkstone] [PATCH 6/9] udev-extraconf: force systemd-udevd to use shared MountFlags liu.ming50
@ 2022-07-17 12:56 ` liu.ming50
2022-07-17 12:56 ` [OE-core] [kirkstone] [PATCH 8/9] udev-extraconf: fix some systemd automount issues liu.ming50
2022-07-17 12:56 ` [OE-core] [kirkstone] [PATCH 9/9] udev-extraconf:mount.sh: fix path mismatching issues liu.ming50
8 siblings, 0 replies; 10+ messages in thread
From: liu.ming50 @ 2022-07-17 12:56 UTC (permalink / raw)
To: openembedded-core
Cc: steve, Muhammad Hamza, Ansar Rasool, Muhammad Hamza,
Luca Ceresoli, Ming Liu
From: Muhammad Hamza <Muhammad_Hamza@mentor.com>
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.
Signed-off-by: Ansar Rasool <ansar_rasool@mentor.com>
Signed-off-by: Muhammad Hamza <muhammad_hamza@mentor.com>
Signed-off-by: Luca Ceresoli <luca.ceresoli@bootlin.com>
(cherry picked from commit b1d18072ed9a8b0bca0f20f8e5deefa73ab6acbe)
Signed-off-by: Ming Liu <liu.ming50@gmail.com>
---
| 4 ++++
1 file changed, 4 insertions(+)
--git a/meta/recipes-core/udev/udev-extraconf/mount.sh b/meta/recipes-core/udev/udev-extraconf/mount.sh
index 537828e3e3..8b6ce77741 100644
--- a/meta/recipes-core/udev/udev-extraconf/mount.sh
+++ b/meta/recipes-core/udev/udev-extraconf/mount.sh
@@ -76,6 +76,8 @@ automount_systemd() {
;;
swap)
return ;;
+ lvm*|LVM*)
+ return ;;
# TODO
*)
;;
@@ -129,6 +131,8 @@ automount() {
;;
swap)
return ;;
+ lvm*|LVM*)
+ return ;;
# TODO
*)
;;
--
2.25.1
^ permalink raw reply related [flat|nested] 10+ messages in thread* [OE-core] [kirkstone] [PATCH 8/9] udev-extraconf: fix some systemd automount issues
2022-07-17 12:56 [OE-core] [kirkstone] [PATCH 0/9] udev-extraconf fixes liu.ming50
` (6 preceding siblings ...)
2022-07-17 12:56 ` [OE-core] [kirkstone] [PATCH 7/9] udev-extraconf/mount.sh: ignore lvm in automount liu.ming50
@ 2022-07-17 12:56 ` liu.ming50
2022-07-17 12:56 ` [OE-core] [kirkstone] [PATCH 9/9] udev-extraconf:mount.sh: fix path mismatching issues liu.ming50
8 siblings, 0 replies; 10+ messages in thread
From: liu.ming50 @ 2022-07-17 12:56 UTC (permalink / raw)
To: openembedded-core; +Cc: steve, Ming Liu, Richard Purdie
From: Ming Liu <liu.ming50@gmail.com>
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.
Signed-off-by: Ming Liu <liu.ming50@gmail.com>
Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
(cherry picked from commit 356520d60b9429c6f62124821e42468ff2b7b1d6)
Signed-off-by: Ming Liu <liu.ming50@gmail.com>
---
| 3 ---
| 20 +++++++++++--------
2 files changed, 12 insertions(+), 11 deletions(-)
delete mode 100644 meta/recipes-core/udev/udev-extraconf/systemd-udevd.service
diff --git a/meta/recipes-core/udev/udev-extraconf/systemd-udevd.service b/meta/recipes-core/udev/udev-extraconf/systemd-udevd.service
deleted file mode 100644
index a9b86eb6e4..0000000000
--- a/meta/recipes-core/udev/udev-extraconf/systemd-udevd.service
+++ /dev/null
@@ -1,3 +0,0 @@
-.include @systemd_unitdir@/system/systemd-udevd.service
-[Service]
-MountFlags=shared
--git a/meta/recipes-core/udev/udev-extraconf_1.1.bb b/meta/recipes-core/udev/udev-extraconf_1.1.bb
index ef6019259e..30f1fe76d0 100644
--- a/meta/recipes-core/udev/udev-extraconf_1.1.bb
+++ b/meta/recipes-core/udev/udev-extraconf_1.1.bb
@@ -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
--
2.25.1
^ permalink raw reply related [flat|nested] 10+ messages in thread* [OE-core] [kirkstone] [PATCH 9/9] udev-extraconf:mount.sh: fix path mismatching issues
2022-07-17 12:56 [OE-core] [kirkstone] [PATCH 0/9] udev-extraconf fixes liu.ming50
` (7 preceding siblings ...)
2022-07-17 12:56 ` [OE-core] [kirkstone] [PATCH 8/9] udev-extraconf: fix some systemd automount issues liu.ming50
@ 2022-07-17 12:56 ` liu.ming50
8 siblings, 0 replies; 10+ messages in thread
From: liu.ming50 @ 2022-07-17 12:56 UTC (permalink / raw)
To: openembedded-core; +Cc: steve, Ming Liu, Alexandre Belloni, Richard Purdie
From: Ming Liu <liu.ming50@gmail.com>
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)
Signed-off-by: Ming Liu <liu.ming50@gmail.com>
Signed-off-by: Alexandre Belloni <alexandre.belloni@bootlin.com>
Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
(cherry picked from commit 7ed210054b3e253d5a67075bb9d4768d1661bef1)
Signed-off-by: Ming Liu <liu.ming50@gmail.com>
---
| 8 ++++----
1 file changed, 4 insertions(+), 4 deletions(-)
--git a/meta/recipes-core/udev/udev-extraconf/mount.sh b/meta/recipes-core/udev/udev-extraconf/mount.sh
index 8b6ce77741..43acb3a7a0 100644
--- a/meta/recipes-core/udev/udev-extraconf/mount.sh
+++ b/meta/recipes-core/udev/udev-extraconf/mount.sh
@@ -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"
--
2.25.1
^ permalink raw reply related [flat|nested] 10+ messages in thread