From: Karel Zak Date: Mon, 24 Jan 2011 12:59:17 +0000 (+0100) Subject: libmount: add mnt_context_get_{source,target,fstype} X-Git-Url: https://err.no/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=e95b3ca33cd5563424216d5da4119ce2fa2515cf;p=util-linux libmount: add mnt_context_get_{source,target,fstype} Signed-off-by: Karel Zak --- diff --git a/shlibs/mount/docs/libmount-sections.txt b/shlibs/mount/docs/libmount-sections.txt index 956fe8a5..8a3a7d22 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 d82532e3..bfa0292f 100644 --- a/shlibs/mount/src/context.c +++ b/shlibs/mount/src/context.c @@ -503,6 +503,17 @@ int mnt_context_set_source(struct libmnt_context *cxt, const char *source) return mnt_fs_set_source(mnt_context_get_fs(cxt), 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 @@ -515,6 +526,17 @@ int mnt_context_set_target(struct libmnt_context *cxt, const char *target) return mnt_fs_set_target(mnt_context_get_fs(cxt), 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 @@ -532,6 +554,17 @@ int mnt_context_set_fstype(struct libmnt_context *cxt, const char *fstype) return mnt_fs_set_fstype(mnt_context_get_fs(cxt), 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 @@ -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. helper. * + * The function also calls mnt_context_disable_helpers() to avoid recursive + * mount. helpers calling. It you really want to call another + * mount. 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 86a61885..6ac24ca1 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 34174ec5..4709a8a2 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;