]> git.ipfire.org Git - thirdparty/util-linux.git/commitdiff
libmount: cleanup high-level mount API
authorKarel Zak <kzak@redhat.com>
Wed, 2 Feb 2011 20:19:14 +0000 (21:19 +0100)
committerKarel Zak <kzak@redhat.com>
Wed, 2 Feb 2011 20:19:14 +0000 (21:19 +0100)
Signed-off-by: Karel Zak <kzak@redhat.com>
shlibs/mount/docs/libmount-sections.txt
shlibs/mount/samples/mount.c
shlibs/mount/src/context.c
shlibs/mount/src/context_mount.c
shlibs/mount/src/libmount.h.in
shlibs/mount/src/libmount.sym

index 8a3a7d22bfac2169db02b6785ce4197c7739d3fb..d351aab53b87db8efc16cddf2f1fe9a87ddd8d89 100644 (file)
@@ -211,8 +211,12 @@ mnt_context_set_source
 mnt_context_set_target
 mnt_context_set_user_mflags
 mnt_context_strerror
+mnt_context_mount
 mnt_free_context
 mnt_new_context
 mnt_reset_context
+mnt_context_prepare_mount
+mnt_context_do_mount
+mnt_context_finalize_mount
 </SECTION>
 
index 5e87d88dbe88c3e68f83e2b0bfcd496e3ea82116..8095ffccbed14fe7df0751ce9829f0937c38591a 100644 (file)
@@ -409,7 +409,7 @@ int main(int argc, char **argv)
        if (lock)
                atexit(lock_atexit_cleanup);
 
-       rc = mnt_mount_context(cxt);
+       rc = mnt_context_mount(cxt);
        if (rc) {
                /* TODO: call mnt_context_strerror() */
                rc = EX_FAIL;
index 676552bf135e8f8123ac67f6aae5e5a43f871ccb..de852a3af31a791978e7c679b40e9bd8031dfff8 100644 (file)
@@ -1486,7 +1486,7 @@ int mnt_context_get_status(struct libmnt_context *cxt)
  * @status: mount(2) return code
  *
  * This function should be used if [u]mount(2) syscall was NOT called by
- * libmount (mnt_mount_context() or mnt_context_do_mount()) only.
+ * libmount (mnt_context_mount() or mnt_context_do_mount()) only.
  *
  * Returns: 0 or negative number in case of error.
  */
@@ -1586,7 +1586,7 @@ int test_mount(struct libmnt_test *ts, int argc, char *argv[])
        if (lock)
                atexit(lock_fallback);
 
-       rc = mnt_mount_context(cxt);
+       rc = mnt_context_mount(cxt);
        if (rc)
                printf("failed to mount %s\n", strerror(errno));
        else
index 8c764078d14f8d94666f6e5d1d87ab1980786366..7f684727785aa9821155950fb6d63b98b643bd40 100644 (file)
@@ -496,7 +496,6 @@ int mnt_context_prepare_mount(struct libmnt_context *cxt)
                return -EINVAL;
        if (!mnt_fs_get_source(cxt->fs) && !mnt_fs_get_target(cxt->fs))
                return -EINVAL;
-
        if (cxt->flags & MNT_FL_PREPARED)
                return 0;
 
@@ -546,6 +545,7 @@ int mnt_context_do_mount(struct libmnt_context *cxt)
        assert(cxt->syscall_status == 1);
        assert((cxt->flags & MNT_FL_MOUNTFLAGS_MERGED));
        assert((cxt->flags & MNT_FL_PREPARED));
+       assert((cxt->action == MNT_ACT_MOUNT));
 
        DBG(CXT, mnt_debug_h(cxt, "mount: do mount"));
 
@@ -560,12 +560,36 @@ int mnt_context_do_mount(struct libmnt_context *cxt)
 }
 
 /**
- * mnt_mount_context:
+ * mnt_context_finalize_mount:
+ * @cxt: context
+ *
+ * Mtab update, etc. Unnecessary for mnt_context_mount(), but should be called
+ * after mnt_context_do_mount(). See also mnt_context_set_syscall_status().
+ *
+ * Returns: negative number on error, 0 on success.
+ */
+int mnt_context_finalize_mount(struct libmnt_context *cxt)
+{
+       int rc;
+
+       assert(cxt);
+       assert(cxt->fs);
+       assert((cxt->flags & MNT_FL_MOUNTFLAGS_MERGED));
+       assert((cxt->flags & MNT_FL_PREPARED));
+
+       rc = mnt_context_prepare_update(cxt);
+       if (!rc)
+               rc = mnt_context_update_tabs(cxt);;
+       return rc;
+}
+
+/**
+ * mnt_context_mount:
  * @cxt: mount context
  *
- * Mount filesystem by mount(2) or fork()+exec(/sbin/mount.type).
+ * High-level, mounts filesystem by mount(2) or fork()+exec(/sbin/mount.type).
  *
- * This is top-level function for FS mounting, similar to:
+ * This is similar to:
  *
  *     mnt_context_prepare_mount(cxt);
  *     mnt_context_do_mount(cxt);
@@ -577,7 +601,7 @@ int mnt_context_do_mount(struct libmnt_context *cxt)
  *          does not mean that mount(2) syscall or mount.type helper wasn't
  *          sucessfully called. Check mnt_context_get_status() after error!
  */
-int mnt_mount_context(struct libmnt_context *cxt)
+int mnt_context_mount(struct libmnt_context *cxt)
 {
        int rc;
 
@@ -601,27 +625,3 @@ int mnt_mount_context(struct libmnt_context *cxt)
        return rc;
 }
 
-/**
- * mnt_context_finalize_mount:
- * @cxt: context
- *
- * Mtab update, etc. Unnecessary for mnt_context_mount(), but should be called
- * after mnt_context_do_mount(). See also mnt_context_set_syscall_status().
- *
- * Returns: negative number on error, 0 on success.
- */
-int mnt_context_finalize_mount(struct libmnt_context *cxt)
-{
-       int rc;
-
-       assert(cxt);
-       assert(cxt->fs);
-       assert((cxt->flags & MNT_FL_MOUNTFLAGS_MERGED));
-       assert((cxt->flags & MNT_FL_PREPARED));
-
-       rc = mnt_context_prepare_update(cxt);
-       if (!rc)
-               rc = mnt_context_update_tabs(cxt);;
-       return rc;
-}
-
index 153b28aec1e1cc67afa8a84c68088eb173f6055b..9870ba79271db410360fff120df06eef5fe423af 100644 (file)
@@ -416,7 +416,7 @@ extern int mnt_context_get_status(struct libmnt_context *cxt);
 extern int mnt_context_strerror(struct libmnt_context *cxt, char *buf,
                                size_t bufsiz);
 
-extern int mnt_mount_context(struct libmnt_context *cxt);
+extern int mnt_context_mount(struct libmnt_context *cxt);
 
 extern int mnt_context_prepare_mount(struct libmnt_context *cxt);
 extern int mnt_context_do_mount(struct libmnt_context *cxt);
index 160174ea07e9640c06475654e2c9e068e632052e..47488b512628950eab06e34d8bc27fdb60522cb7 100644 (file)
@@ -133,7 +133,7 @@ global:
        mnt_mangle;
        mnt_match_fstype;
        mnt_match_options;
-       mnt_mount_context;
+       mnt_context_mount;
        mnt_new_cache;
        mnt_new_context;
        mnt_new_fs;