summaryrefslogtreecommitdiffstats
path: root/shlibs/mount/src/context_mount.c
diff options
context:
space:
mode:
authorKarel Zak2010-11-08 11:14:44 +0100
committerKarel Zak2011-01-03 12:28:46 +0100
commit1d0cd73f3f8929132e731a821ceb07fa6193c00c (patch)
tree6ef4dd8d0d801baa03a8dcf1a6830d265ef7524b /shlibs/mount/src/context_mount.c
parentlibmount: fix Makefile and tests (diff)
downloadkernel-qcow2-util-linux-1d0cd73f3f8929132e731a821ceb07fa6193c00c.tar.gz
kernel-qcow2-util-linux-1d0cd73f3f8929132e731a821ceb07fa6193c00c.tar.xz
kernel-qcow2-util-linux-1d0cd73f3f8929132e731a821ceb07fa6193c00c.zip
libmount: rewrite update
Signed-off-by: Karel Zak <kzak@redhat.com>
Diffstat (limited to 'shlibs/mount/src/context_mount.c')
-rw-r--r--shlibs/mount/src/context_mount.c117
1 files changed, 22 insertions, 95 deletions
diff --git a/shlibs/mount/src/context_mount.c b/shlibs/mount/src/context_mount.c
index e12e0a933..de6557df4 100644
--- a/shlibs/mount/src/context_mount.c
+++ b/shlibs/mount/src/context_mount.c
@@ -363,32 +363,30 @@ static int do_mount(mnt_context *cxt, const char *try_type)
}
/**
- * mnt_context_prepare_mount:
+ * mnt_context_do_mount:
* @cxt: mount context
*
- * This function:
- * - read information from fstab (if necessary)
- * - cleanup mount options
- * - check premissions
- * - prepare device (e.g. loop device)
- * - detect FS type (if necessary)
- * - generate mount flags and mount data (if not set yet)
- * - prepare for mtab update (if necessary)
+ * Mount filesystem by mount(2) or fork()+exec(/sbin/mount.<type>).
*
- * It's strongly recommended to use this function before mnt_context_mount_fs().
+ * See also mnt_context_disable_helpers().
*
* Returns: 0 on success, and negative number in case of error.
*/
-int mnt_context_prepare_mount(mnt_context *cxt)
+int mnt_context_do_mount(mnt_context *cxt)
{
- int rc = 0;
+ int rc = -EINVAL;
+ const char *type;
- if (!cxt)
- return -EINVAL;
+ assert(cxt);
+ assert(cxt->fs);
+ assert((cxt->flags & MNT_FL_MOUNTFLAGS_MERGED));
- if (!cxt->fs || (!mnt_fs_get_source(cxt->fs) &&
- !mnt_fs_get_target(cxt->fs)))
+ if (!cxt || !cxt->fs || (cxt->fs->flags & MNT_FS_SWAP))
return -EINVAL;
+ if (!mnt_fs_get_source(cxt->fs) && !mnt_fs_get_target(cxt->fs))
+ return -EINVAL;
+
+ cxt->action = MNT_ACT_MOUNT;
DBG(CXT, mnt_debug_h(cxt, "mount: preparing"));
@@ -406,39 +404,13 @@ int mnt_context_prepare_mount(mnt_context *cxt)
if (!rc)
rc = mnt_context_prepare_helper(cxt, "mount", NULL);
if (!rc)
- rc = mnt_context_prepare_update(cxt, MNT_ACT_MOUNT);
+ rc = mnt_context_prepare_update(cxt);
- if (!rc) {
- DBG(CXT, mnt_debug_h(cxt, "sucessfully prepared"));
- return 0;
+ if (rc) {
+ DBG(CXT, mnt_debug_h(cxt, "mount: preparing failed"));
+ return rc;
}
- DBG(CXT, mnt_debug_h(cxt, "prepare failed"));
- return rc;
-}
-
-/**
- * mnt_context_do_mount:
- * @cxt: mount context
- *
- * Mount filesystem by mount(2) or fork()+exec(/sbin/mount.<type>).
- *
- * See also mnt_context_disable_helpers().
- *
- * Returns: 0 on success, and negative number in case of error.
- */
-int mnt_context_do_mount(mnt_context *cxt)
-{
- int rc = -EINVAL;
- const char *type;
-
- assert(cxt);
- assert(cxt->fs);
- assert((cxt->flags & MNT_FL_MOUNTFLAGS_MERGED));
-
- if (!cxt || !cxt->fs || (cxt->fs->flags & MNT_FS_SWAP))
- return -EINVAL;
-
DBG(CXT, mnt_debug_h(cxt, "mount: do mount"));
if (!(cxt->flags & MNT_FL_MOUNTDATA))
@@ -456,55 +428,10 @@ int mnt_context_do_mount(mnt_context *cxt)
/* TODO: try all filesystems from /proc/filesystems and /etc/filesystems */
- return rc;
-}
-
-/**
- * mnt_context_post_mount:
- * @cxt: mount context
- *
- * Updates mtab, etc. This function should be always called after
- * mnt_context_do_mount().
- *
- * Returns: 0 on success, and negative number in case of error.
- */
-int mnt_context_post_mount(mnt_context *cxt)
-{
- int rc = 0;
-
- assert(cxt);
- assert(cxt->fs);
- assert((cxt->flags & MNT_FL_MOUNTFLAGS_MERGED));
-
- if (!cxt)
- return -EINVAL;
- /*
- * Update /etc/mtab or /var/run/mount/mountinfo
+ /* TODO: if mtab update is expected then check if the
+ * target is really mounted read-write to avoid 'ro' in
+ * mtab and 'rw' in /proc/mounts.
*/
- if (!cxt->syscall_errno && !cxt->helper &&
- !(cxt->flags & MNT_FL_NOMTAB) &&
- cxt->update && !mnt_update_is_pointless(cxt->update)) {
-
- /* TODO: if mtab update is expected then checkif the target is really
- * mounted read-write to avoid 'ro' in mtab and 'rw' in /proc/mounts.
- */
- rc = mnt_update_file(cxt->update);
- }
-
- return rc;
-}
-
-/**
- * mnt_context_mount_strerror
- * @cxt: mount context
- * @buf: buffer
- * @bufsiz: size of the buffer
- *
- * Returns: 0 or negative number in case of error.
- */
-int mnt_context_mount_strerror(mnt_context *cxt, char *buf, size_t bufsiz)
-{
- /* TODO: based on cxt->syscall_errno or cxt->helper_status */
- return 0;
+ return mnt_context_update_tabs(cxt);
}