summaryrefslogtreecommitdiffstats
path: root/libmount/src/context_mount.c
diff options
context:
space:
mode:
authorKarel Zak2012-04-24 11:52:04 +0200
committerKarel Zak2012-04-24 11:52:04 +0200
commitae5afe071f5bc34a6fc0ddb4c0db98baf485262d (patch)
tree0fba332ce8059c78d338735b5864de2ab52048ce /libmount/src/context_mount.c
parentlscpu: fix possibly undefined operation (diff)
downloadkernel-qcow2-util-linux-ae5afe071f5bc34a6fc0ddb4c0db98baf485262d.tar.gz
kernel-qcow2-util-linux-ae5afe071f5bc34a6fc0ddb4c0db98baf485262d.tar.xz
kernel-qcow2-util-linux-ae5afe071f5bc34a6fc0ddb4c0db98baf485262d.zip
libmount: fix mount by pattern
mount /foo /bar without entry in /etc/fstab the mount command tries all filesystems from /{etc,proc}/filesystems. We should NOT call mount(2) more then once if the syscall returns for example ENOENT, acceptable is only EINVAL. Signed-off-by: Karel Zak <kzak@redhat.com>
Diffstat (limited to 'libmount/src/context_mount.c')
-rw-r--r--libmount/src/context_mount.c5
1 files changed, 4 insertions, 1 deletions
diff --git a/libmount/src/context_mount.c b/libmount/src/context_mount.c
index 1f28753fd..63091b7f8 100644
--- a/libmount/src/context_mount.c
+++ b/libmount/src/context_mount.c
@@ -442,7 +442,7 @@ static int do_mount(struct libmnt_context *cxt, const char *try_type)
if (try_type && !cxt->helper) {
rc = mnt_context_prepare_helper(cxt, "mount", try_type);
- if (!rc)
+ if (rc)
return rc;
}
if (cxt->helper)
@@ -520,6 +520,7 @@ static int do_mount_by_pattern(struct libmnt_context *cxt, const char *pattern)
*end = '\0';
rc = do_mount(cxt, p);
p = end ? end + 1 : NULL;
+
} while (!mnt_context_get_status(cxt) && p);
free(p0);
@@ -541,6 +542,8 @@ static int do_mount_by_pattern(struct libmnt_context *cxt, const char *pattern)
rc = do_mount(cxt, *fp);
if (mnt_context_get_status(cxt))
break;
+ if (mnt_context_get_syscall_errno(cxt) != EINVAL)
+ break;
}
mnt_free_filesystems(filesystems);
return rc;