diff mbox series

udev-extraconf: Allow optionally skipping systemd-fsck

Message ID 20250509094421.20786-1-mark.jonas@de.bosch.com
State New
Headers show
Series udev-extraconf: Allow optionally skipping systemd-fsck | expand

Commit Message

Jonas Mark (BT-FS/ENG1-GRB) May 9, 2025, 9:44 a.m. UTC
From: Ricardo Simoes <ricardo.simoes@pt.bosch.com>

When the fsck backend does not respect the exit codes predefined by
fsck, systemd-fsck might not work as expected.

This is the case for fsck.fat from dosfstools [1]. When a FAT formatted
and write protected partition is checked with fsck.fat it will terminate
with exit code '6' [2]. What fsck.fat wants to signal is that a write
protected device cannot be checked. However, that code is interpreted by
systemd-fsck as a bit mask:

- 2: System should be rebooted
- 4: Filesystem errors left uncorrected

As a practical example, a write-protected, FAT formatted SD-card will
not be mounted in this case.

This patch introduces the environment variable SKIP_SYSTEMD_MOUNT_FSCK.
When SKIP_SYSTEMD_MOUNT_FSCK exists systemd-mount will be called with
the --fsck=no option. Thus, the partition will be mounted without
running systemd-fsck.

In general, this new feature is useful when the filesystem is known to
be clean and the fsck backend does not respect the exit codes.

Finally, one way to use this new feature would be to add
ENV{SKIP_SYSTEMD_MOUNT_FSCK}="1" to the udev rule calling the mount
script.

[1] https://github.com/dosfstools/dosfstools/issues/89
[2] https://github.com/dosfstools/dosfstools/blob/v4.2/src/io.c#L63

Signed-off-by: Ricardo Simoes <ricardo.simoes@pt.bosch.com>
Signed-off-by: Mark Jonas <mark.jonas@de.bosch.com>
---
 meta/recipes-core/udev/udev-extraconf/mount.sh | 4 ++++
 1 file changed, 4 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 0cbae48729..d6de05f0b6 100644
--- a/meta/recipes-core/udev/udev-extraconf/mount.sh
+++ b/meta/recipes-core/udev/udev-extraconf/mount.sh
@@ -83,6 +83,10 @@  automount_systemd() {
 
     MOUNT="$MOUNT -o silent"
 
+    if [ -n "${SKIP_SYSTEMD_MOUNT_FSCK+isset}" ]; then
+        MOUNT="$MOUNT --fsck=no"
+    fi
+
     # If filesystemtype is vfat, change the ownership group to mount group, and
     # grant it with  w/r/x permissions.
     case $ID_FS_TYPE in