From: Karel Zak Date: Tue, 24 Apr 2012 09:52:04 +0000 (+0200) Subject: libmount: fix mount by pattern X-Git-Tag: v2.22-rc1~488 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=ae5afe071f5bc34a6fc0ddb4c0db98baf485262d;p=thirdparty%2Futil-linux.git 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 --- diff --git a/libmount/src/context_mount.c b/libmount/src/context_mount.c index 1f28753fdf..63091b7f88 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;