summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorKarel Zak2011-01-24 13:59:17 +0100
committerKarel Zak2011-01-24 13:59:17 +0100
commite95b3ca33cd5563424216d5da4119ce2fa2515cf (patch)
tree26512d51242dccaf673cc5a61c568c70bb1efb7f
parenttests: ignore device name used in some fdisk and blkid tests (diff)
downloadkernel-qcow2-util-linux-e95b3ca33cd5563424216d5da4119ce2fa2515cf.tar.gz
kernel-qcow2-util-linux-e95b3ca33cd5563424216d5da4119ce2fa2515cf.tar.xz
kernel-qcow2-util-linux-e95b3ca33cd5563424216d5da4119ce2fa2515cf.zip
libmount: add mnt_context_get_{source,target,fstype}
Signed-off-by: Karel Zak <kzak@redhat.com>
-rw-r--r--shlibs/mount/docs/libmount-sections.txt5
-rw-r--r--shlibs/mount/src/context.c46
-rw-r--r--shlibs/mount/src/libmount.h.in4
-rw-r--r--shlibs/mount/src/mount.sym5
4 files changed, 57 insertions, 3 deletions
diff --git a/shlibs/mount/docs/libmount-sections.txt b/shlibs/mount/docs/libmount-sections.txt
index 956fe8a5d..8a3a7d22b 100644
--- a/shlibs/mount/docs/libmount-sections.txt
+++ b/shlibs/mount/docs/libmount-sections.txt
@@ -188,10 +188,13 @@ mnt_context_enable_verbose
mnt_context_get_cache
mnt_context_get_fs
mnt_context_get_fstab
+mnt_context_get_fstype
mnt_context_get_lock
mnt_context_get_mflags
mnt_context_get_mtab
+mnt_context_get_source
mnt_context_get_status
+mnt_context_get_target
mnt_context_get_user_mflags
mnt_context_is_restricted
mnt_context_set_cache
@@ -199,8 +202,8 @@ mnt_context_set_fs
mnt_context_set_fstab
mnt_context_set_fstype
mnt_context_set_fstype_pattern
-mnt_context_set_mountdata
mnt_context_set_mflags
+mnt_context_set_mountdata
mnt_context_set_options
mnt_context_set_options_pattern
mnt_context_set_optsmode
diff --git a/shlibs/mount/src/context.c b/shlibs/mount/src/context.c
index d82532e33..bfa0292fa 100644
--- a/shlibs/mount/src/context.c
+++ b/shlibs/mount/src/context.c
@@ -504,6 +504,17 @@ int mnt_context_set_source(struct libmnt_context *cxt, const char *source)
}
/**
+ * mnt_context_get_source:
+ * @cxt: mount context
+ *
+ * Returns: returns pointer or NULL in case of error pr if not set.
+ */
+const char *mnt_context_get_source(struct libmnt_context *cxt)
+{
+ return mnt_fs_get_source(mnt_context_get_fs(cxt));
+}
+
+/**
* mnt_context_set_target:
* @cxt: mount context
* @target: mountpoint
@@ -516,6 +527,17 @@ int mnt_context_set_target(struct libmnt_context *cxt, const char *target)
}
/**
+ * mnt_context_get_target:
+ * @cxt: mount context
+ *
+ * Returns: returns pointer or NULL in case of error pr if not set.
+ */
+const char *mnt_context_get_target(struct libmnt_context *cxt)
+{
+ return mnt_fs_get_target(mnt_context_get_fs(cxt));
+}
+
+/**
* mnt_context_set_fstype:
* @cxt: mount context
* @fstype: filesystem type
@@ -533,6 +555,17 @@ int mnt_context_set_fstype(struct libmnt_context *cxt, const char *fstype)
}
/**
+ * mnt_context_get_fstype:
+ * @cxt: mount context
+ *
+ * Returns: returns pointer or NULL in case of error pr if not set.
+ */
+const char *mnt_context_get_fstype(struct libmnt_context *cxt)
+{
+ return mnt_fs_get_fstype(mnt_context_get_fs(cxt));
+}
+
+/**
* mnt_context_set_options:
* @cxt: mount context
* @optstr: comma delimited mount options
@@ -1466,11 +1499,22 @@ int mnt_context_strerror(struct libmnt_context *cxt, char *buf, size_t bufsiz)
*
* This function infors libmount that used from [u]mount.<type> helper.
*
+ * The function also calls mnt_context_disable_helpers() to avoid recursive
+ * mount.<type> helpers calling. It you really want to call another
+ * mount.<type> helper from your helper than you have to explicitly enable this
+ * feature by:
+ *
+ * mnt_context_disable_helpers(cxt, FALSE);
+ *
* Returns: 0 on success, negative number in case of error.
*/
int mnt_context_init_helper(struct libmnt_context *cxt, int flags)
{
- return set_flag(cxt, MNT_FL_HELPER, 1);
+ int rc = mnt_context_disable_helpers(cxt, TRUE);
+
+ if (!rc)
+ return set_flag(cxt, MNT_FL_HELPER, 1);
+ return rc;
}
#ifdef TEST_PROGRAM
diff --git a/shlibs/mount/src/libmount.h.in b/shlibs/mount/src/libmount.h.in
index 86a618850..6ac24ca18 100644
--- a/shlibs/mount/src/libmount.h.in
+++ b/shlibs/mount/src/libmount.h.in
@@ -378,6 +378,10 @@ extern struct libmnt_fs *mnt_context_get_fs(struct libmnt_context *cxt);
extern int mnt_context_set_source(struct libmnt_context *cxt, const char *source);
extern int mnt_context_set_target(struct libmnt_context *cxt, const char *target);
extern int mnt_context_set_fstype(struct libmnt_context *cxt, const char *fstype);
+extern const char *mnt_context_get_source(struct libmnt_context *cxt);
+extern const char *mnt_context_get_target(struct libmnt_context *cxt);
+extern const char *mnt_context_get_fstype(struct libmnt_context *cxt);
+
extern int mnt_context_set_options(struct libmnt_context *cxt, const char *optstr);
extern int mnt_context_append_options(struct libmnt_context *cxt,
const char *optstr);
diff --git a/shlibs/mount/src/mount.sym b/shlibs/mount/src/mount.sym
index 34174ec5f..4709a8a21 100644
--- a/shlibs/mount/src/mount.sym
+++ b/shlibs/mount/src/mount.sym
@@ -26,11 +26,14 @@ global:
mnt_context_get_cache;
mnt_context_get_fs;
mnt_context_get_fstab;
+ mnt_context_get_fstype;
mnt_context_get_lock;
mnt_context_get_mflags;
mnt_context_get_mtab;
mnt_context_get_optsmode;
+ mnt_context_get_source;
mnt_context_get_status;
+ mnt_context_get_target;
mnt_context_get_user_mflags;
mnt_context_init_helper;
mnt_context_is_fake;
@@ -48,8 +51,8 @@ global:
mnt_context_set_fstab;
mnt_context_set_fstype;
mnt_context_set_fstype_pattern;
- mnt_context_set_mountdata;
mnt_context_set_mflags;
+ mnt_context_set_mountdata;
mnt_context_set_options;
mnt_context_set_options_pattern;
mnt_context_set_optsmode;