summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKarel Zak <kzak@redhat.com>2014-04-07 12:09:11 +0200
committerKarel Zak <kzak@redhat.com>2014-04-23 11:55:08 +0200
commit0aa6c429897e75d55ca6e7f3f104f397e158914b (patch)
treed8bc57a31fdd7ad1b3e6600cef25fc8309661324
parentf435d4be5fe7c1e34caaead0bb34af0db7a05867 (diff)
downloadutil-linux-0aa6c429897e75d55ca6e7f3f104f397e158914b.tar.gz
mount: apply "nofail" to MNT_ERR_NOSOURCE libmount error
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>
-rw-r--r--libmount/src/context.c5
-rw-r--r--sys-utils/mount.c2
2 files changed, 7 insertions, 0 deletions
diff --git a/libmount/src/context.c b/libmount/src/context.c
index 5a88bcdcc..8dca3c12a 100644
--- a/libmount/src/context.c
+++ b/libmount/src/context.c
@@ -712,6 +712,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)
diff --git a/sys-utils/mount.c b/sys-utils/mount.c
index 29fb2f2c9..97365b168 100644
--- a/sys-utils/mount.c
+++ b/sys-utils/mount.c
@@ -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