diff mbox series

[v2] udev-extraconf: mount.sh: check if filesystem is supported before mounting

Message ID 20231108094059.79116-1-lukas.funke-oss@weidmueller.com
State Accepted, archived
Commit 695e0a41e3c1cb47484605934a57e7df591bd19f
Headers show
Series [v2] udev-extraconf: mount.sh: check if filesystem is supported before mounting | expand

Commit Message

Lukas Funke Nov. 8, 2023, 9:40 a.m. UTC
From: Lukas Funke <lukas.funke@weidmueller.com>

Check if the filesystem is supported by the kernel before trying to
mount it. Systemd-mount will mount the directories asynchronously
resulting in stale directories if the devices filesystem is not
supported.

Signed-off-by: Lukas Funke <lukas.funke@weidmueller.com>
---
 meta/recipes-core/udev/udev-extraconf/mount.sh | 15 +++++++++++++++
 1 file changed, 15 insertions(+)
diff mbox series

Patch

diff --git a/meta/recipes-core/udev/udev-extraconf/mount.sh b/meta/recipes-core/udev/udev-extraconf/mount.sh
index 989fabc194..adf0c7aafa 100644
--- a/meta/recipes-core/udev/udev-extraconf/mount.sh
+++ b/meta/recipes-core/udev/udev-extraconf/mount.sh
@@ -36,6 +36,16 @@  do
 	fi
 done
 
+is_filesystem_supported() {
+    while read -r fs; do
+       if [ "${fs#nodev}" = "$1" ];
+       then
+           return 0
+       fi
+    done < "/proc/filesystems"
+    return 1
+}
+
 automount_systemd() {
     name="`basename "$DEVNAME"`"
 
@@ -64,6 +74,11 @@  automount_systemd() {
         grep "^[[:space:]]*$tmp" /etc/fstab && return
     done
 
+    if ! is_filesystem_supported $ID_FS_TYPE; then
+        logger "mount.sh/automount" "Filesystem '$ID_FS_TYPE' on '${DEVNAME}' is unsupported"
+        return
+    fi
+
     [ -d "$MOUNT_BASE/$name" ] || mkdir -p "$MOUNT_BASE/$name"
 
     MOUNT="$MOUNT -o silent"