]> code.ossystems Code Review - openembedded-core.git/commitdiff
udev-extraconf: skip mounting partitions already mounted by systemd
authorHector Palacios <hector.palacios@digi.com>
Wed, 18 Sep 2019 08:26:55 +0000 (10:26 +0200)
committerRichard Purdie <richard.purdie@linuxfoundation.org>
Thu, 19 Sep 2019 09:54:26 +0000 (10:54 +0100)
For some devices, udev may sometimes trigger twice the 'add' rule during
boot. Calling the mount.sh script twice will eventually fail for
already mounted partitions, but in that case, the script tries to remove
the created mountpoint, when it shouldn't.
This has been observed on USB sticks connected to a USB hub and may
result in devices not being mounted if plugged-in before booting.

This patch checks for already mounted partitions earlier (before creating
the mount point) and returns with no actions.

Signed-off-by: Hector Palacios <hector.palacios@digi.com>
Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
meta/recipes-core/udev/udev-extraconf/mount.sh

index 79eb0145c2a6b9da6e00bbe53eda21a3fd72c00d..b23731870ea2d94393796ce612d365fc5d771498 100644 (file)
@@ -38,6 +38,12 @@ done
 automount_systemd() {
     name="`basename "$DEVNAME"`"
 
+    # Skip already mounted partitions
+    if [ -f /run/systemd/transient/run-media-$name.mount ]; then
+        logger "mount.sh/automount" "/run/media/$name already mounted"
+        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