]> git.ipfire.org Git - thirdparty/util-linux.git/commitdiff
libmount: don't report fsconfig errors with "nofail"
authorKarel Zak <kzak@redhat.com>
Thu, 11 Sep 2025 07:35:58 +0000 (09:35 +0200)
committerKarel Zak <kzak@redhat.com>
Thu, 11 Sep 2025 07:35:58 +0000 (09:35 +0200)
The new kernel API returns EINVAL on FSCONFIG_CMD_CREATE if the mount
source is inaccessible. We do not want to report this as an error when
the "nofail" mount option is specified.

Note that EINVAL may also be returned by other fsconfig() settings, so
we need to check whether a source is specified and whether it is really
inaccessible. This is just a heuristic (as with the old mount(2)).

Fixes: https://github.com/util-linux/util-linux/issues/3741
Signed-off-by: Karel Zak <kzak@redhat.com>
libmount/src/context_mount.c

index 9a1832550cf44efa3bc928f4c2c83b5ca07ed89c..04734b73cd7e3700aaa3257b8955c82bf0e48a3d 100644 (file)
@@ -1662,6 +1662,12 @@ int mnt_context_get_mount_excode(
 
        /* Error with already generated messages (by kernel or libmount) */
        if (buf && mnt_context_get_nmesgs(cxt, 'e')) {
+               if (syserr == ENOENT
+                   && uflags & MNT_MS_NOFAIL
+                   && cxt->syscall_name && strcmp(cxt->syscall_name, "fsconfig") == 0
+                   && src && !mnt_is_path(src))
+                       return MNT_EX_SUCCESS;
+
                if (cxt->syscall_name) {
                        size_t len = snprintf(buf, bufsz,
                                        _("%s() failed: "),