]> git.ipfire.org Git - thirdparty/util-linux.git/commitdiff
libmount: fix mount by pattern
authorKarel Zak <kzak@redhat.com>
Tue, 24 Apr 2012 09:52:04 +0000 (11:52 +0200)
committerKarel Zak <kzak@redhat.com>
Thu, 24 May 2012 10:17:51 +0000 (12:17 +0200)
  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>
libmount/src/context_mount.c

index 99f7dd3428753dc8999b46e8eda869bdf0e4991d..bb27117c15aac3c94d7894f29d939fd1d19f41b7 100644 (file)
@@ -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;