]> err.no Git - util-linux/commitdiff
libmount: fix context mount test
authorKarel Zak <kzak@redhat.com>
Mon, 22 Nov 2010 22:15:54 +0000 (23:15 +0100)
committerKarel Zak <kzak@redhat.com>
Mon, 3 Jan 2011 11:28:46 +0000 (12:28 +0100)
Signed-off-by: Karel Zak <kzak@redhat.com>
shlibs/mount/src/context.c
shlibs/mount/src/context_mount.c
shlibs/mount/src/mount.h.in

index 3863629caf9e722307f2be49295e065a8175aaf8..3ab5a73789a2bfa4662b84080ae7ab4e5ecd652d 100644 (file)
@@ -1079,10 +1079,12 @@ int mnt_context_update_tabs(mnt_context *cxt)
 
        assert(cxt);
 
-       if (cxt->flags & MNT_FL_NOMTAB)
+       if ((cxt->flags & MNT_FL_NOMTAB) && cxt->helper)
                return 0;
        if (!cxt->update || !mnt_update_is_ready(cxt->update))
                return 0;
+       if (cxt->syscall_status)
+               return 0;
 
        if (mnt_update_is_userspace_only(cxt->update))
                filename = cxt->utab_path;
@@ -1264,10 +1266,8 @@ mnt_lock *lock;
 
 static void lock_fallback(void)
 {
-       if (lock) {
+       if (lock)
                mnt_unlock_file(lock);
-               mnt_free_lock(lock);
-       }
 }
 
 int test_mount(struct mtest *ts, int argc, char *argv[])
@@ -1302,24 +1302,13 @@ int test_mount(struct mtest *ts, int argc, char *argv[])
                mnt_context_set_target(cxt, argv[idx++]);
        }
 
-       rc = mnt_context_prepare_mount(cxt);
-       if (rc)
-               printf("failed to prepare mount\n");
-       else {
-               lock = mnt_context_get_lock(cxt);
-               if (lock)
-                       atexit(lock_fallback);
+       lock = mnt_context_get_lock(cxt);
+       if (lock)
+               atexit(lock_fallback);
 
-               rc = mnt_context_do_mount(cxt);
-               if (rc)
-                       printf("failed to mount\n");
-               else {
-                       printf("successfully mounted\n");
-                       rc = mnt_context_post_mount(cxt);
-                       if (rc)
-                               printf("mtab update failed\n");
-               }
-       }
+       rc = mnt_context_do_mount(cxt);
+       if (rc)
+               printf("failed to mount %s\n", strerror(errno));
 
        mnt_free_context(cxt);
        return rc;
@@ -1365,24 +1354,13 @@ int test_umount(struct mtest *ts, int argc, char *argv[])
                goto err;
        }
 
-       rc = mnt_context_prepare_umount(cxt);
-       if (rc)
-               printf("failed to prepare umount\n");
-       else {
-               lock = mnt_context_get_lock(cxt);
-               if (lock)
-                       atexit(lock_fallback);
+       lock = mnt_context_get_lock(cxt);
+       if (lock)
+               atexit(lock_fallback);
 
-               rc = mnt_context_do_umount(cxt);
-               if (rc)
-                       printf("failed to umount\n");
-               else {
-                       printf("successfully umounted\n");
-                       rc = mnt_context_post_umount(cxt);
-                       if (rc)
-                               printf("mtab update failed\n");
-               }
-       }
+       rc = mnt_context_do_umount(cxt);
+       if (rc)
+               printf("failed to umount\n");
 err:
        mnt_free_context(cxt);
        return rc;
index 070d72f101eb62c21995d66d021e0aed9f203ac5..7b0a9c12648f56fc5ff395edf68d6d36167eec67 100644 (file)
@@ -377,6 +377,7 @@ static int do_mount_by_pattern(mnt_context *cxt, const char *pattern)
        char **filesystems, **fp;
 
        assert(cxt);
+       assert((cxt->flags & MNT_FL_MOUNTFLAGS_MERGED));
 
        if (!neg && pattern) {
                /*
@@ -436,7 +437,6 @@ int mnt_context_do_mount(mnt_context *cxt)
 
        assert(cxt);
        assert(cxt->fs);
-       assert((cxt->flags & MNT_FL_MOUNTFLAGS_MERGED));
        assert(cxt->helper_exec_status == 1);
        assert(cxt->syscall_status == 1);
 
index 5553921edaf3b2234070977bf6e0c4f1f2b4675c..1123171941127c99228547f2451322bd4b22cd7f 100644 (file)
@@ -350,6 +350,9 @@ extern int mnt_context_set_mountdata(mnt_context *cxt, void *data);
 extern int mnt_context_apply_fstab(mnt_context *cxt);
 extern int mnt_context_get_status(mnt_context *cxt);
 
+extern int mnt_context_do_mount(mnt_context *cxt);
+extern int mnt_context_do_umount(mnt_context *cxt);
+
 /*
  * mount(8) userspace options masks (MNT_MAP_USERSPACE map)
  */