]> git.ipfire.org Git - thirdparty/util-linux.git/commitdiff
mount: apply "nofail" to MNT_ERR_NOSOURCE libmount error
authorKarel Zak <kzak@redhat.com>
Mon, 7 Apr 2014 10:09:11 +0000 (12:09 +0200)
committerKarel Zak <kzak@redhat.com>
Mon, 7 Apr 2014 10:09:11 +0000 (12:09 +0200)
 fstab:
     UUID=nonexist /mnt/nonexist1 ext4 nofail 0 1

 # mount -av
 mount: can't find UUID=nonexist

.. this is bug of course.

Reported-by: Patrick McLean <chutzpah@gentoo.org>
Signed-off-by: Karel Zak <kzak@redhat.com>
libmount/src/context.c
sys-utils/mount.c

index 2d9795e239a7a6d21b3e6ec9800009aaa3b97177..b7278a42dde2828498b07a5e131d21578e541973 100644 (file)
@@ -716,6 +716,11 @@ void *mnt_context_get_mtab_userdata(struct libmnt_context *cxt)
  * @cxt: mount context
  * @source: mount source (device, directory, UUID, LABEL, ...)
  *
+ * Note that libmount does not interpret "nofail" (MNT_MS_NOFAIL)
+ * mount option. The real return code is always returned, when
+ * the device does not exist then it's usually MNT_ERR_NOSOURCE
+ * from libmount or ENOENT, ENOTDIR, ENOTBLK, ENXIO from moun(2).
+ *
  * Returns: 0 on success, negative number in case of error.
  */
 int mnt_context_set_source(struct libmnt_context *cxt, const char *source)
index 4c5f0e528f3a04d3b0ccf52e4d7719dfa53139d1..74a1a84f2bced45e39152ee2ba001682275b7d32 100644 (file)
@@ -431,6 +431,8 @@ try_readonly:
                                warnx(_("you must specify the filesystem type"));
                        return MOUNT_EX_USAGE;
                case -MNT_ERR_NOSOURCE:
+                       if (uflags & MNT_MS_NOFAIL)
+                               return MOUNT_EX_SUCCESS;
                        if (src)
                                warnx(_("can't find %s"), src);
                        else