From 68e9d35c5ee534d0834d13e38cbd85fbb59b7828 Mon Sep 17 00:00:00 2001 From: Karel Zak Date: Wed, 19 Jan 2011 17:22:28 +0100 Subject: [PATCH] libmount: add mnt_context_is_* functions Signed-off-by: Karel Zak --- shlibs/mount/src/context.c | 93 +++++++++++++++++++++++++++++++++++++ shlibs/mount/src/mount.h.in | 9 ++++ shlibs/mount/src/mount.sym | 10 +++- 3 files changed, 111 insertions(+), 1 deletion(-) diff --git a/shlibs/mount/src/context.c b/shlibs/mount/src/context.c index 13c5596f..d71cbb63 100644 --- a/shlibs/mount/src/context.c +++ b/shlibs/mount/src/context.c @@ -203,6 +203,18 @@ int mnt_context_set_optsmode(mnt_context *cxt, int mode) return 0; } +/** + * mnt_context_get_optsmode + * @cxt: mount context + * + * Returns: MNT_OMASK_* mask or zero. + */ + +int mnt_context_get_optsmode(mnt_context *cxt) +{ + return cxt ? cxt->optsmode : 0; +} + /** * mnt_context_disable_canonicalize: * @cxt: mount context @@ -237,6 +249,18 @@ int mnt_context_enable_lazy(mnt_context *cxt, int enable) return set_flag(cxt, MNT_FL_LAZY, enable); } +/** + * mnt_context_is_lazy: + * @cxt: mount context + * + * Returns: 1 if lazy umount is enabled or 0 + */ +int mnt_context_is_lazy(mnt_context *cxt) +{ + return cxt && (cxt->flags & MNT_FL_LAZY) ? 1 : 0; +} + + /** * mnt_context_enable_rdonly_umount: * @cxt: mount context @@ -252,6 +276,20 @@ int mnt_context_enable_rdonly_umount(mnt_context *cxt, int enable) return set_flag(cxt, MNT_FL_RDONLY_UMOUNT, enable); } +/** + * mnt_context_is_rdonly_umount + * @cxt: mount context + * + * See also mnt_context_enable_rdonly_umount() and see umount(8) man page, + * option -r. + * + * Returns: 1 if read-only remount failed umount(2) is enables or 0 + */ +int mnt_context_is_rdonly_umount(mnt_context *cxt) +{ + return cxt && (cxt->flags & MNT_FL_RDONLY_UMOUNT) ? 1 : 0; +} + /** * mnt_context_disable_helpers: * @cxt: mount context @@ -280,6 +318,17 @@ int mnt_context_enable_sloppy(mnt_context *cxt, int enable) return set_flag(cxt, MNT_FL_SLOPPY, enable); } +/** + * mnt_context_is_sloppy: + * @cxt: mount context + * + * Returns: 1 if sloppy flag is enabled or 0 + */ +int mnt_context_is_sloppy(mnt_context *cxt) +{ + return cxt && (cxt->flags & MNT_FL_SLOPPY) ? 1 : 0; +} + /** * mnt_context_enable_fake: * @cxt: mount context @@ -294,6 +343,17 @@ int mnt_context_enable_fake(mnt_context *cxt, int enable) return set_flag(cxt, MNT_FL_FAKE, enable); } +/** + * mnt_context_is_fake: + * @cxt: mount context + * + * Returns: 1 if fake flag is enabled or 0 + */ +int mnt_context_is_fake(mnt_context *cxt) +{ + return cxt && (cxt->flags & MNT_FL_FAKE) ? 1 : 0; +} + /** * mnt_context_disable_mtab: * @cxt: mount context @@ -308,6 +368,17 @@ int mnt_context_disable_mtab(mnt_context *cxt, int disable) return set_flag(cxt, MNT_FL_NOMTAB, disable); } +/** + * mnt_context_is_nomtab + * @cxt: mount context + * + * Returns: 1 if no-mtab is enabled or 0 + */ +int mnt_context_is_nomtab(mnt_context *cxt) +{ + return cxt && (cxt->flags & MNT_FL_NOMTAB) ? 1 : 0; +} + /** * mnt_context_enable_force: * @cxt: mount context @@ -322,6 +393,17 @@ int mnt_context_enable_force(mnt_context *cxt, int enable) return set_flag(cxt, MNT_FL_FORCE, enable); } +/** + * mnt_context_is_force + * @cxt: mount context + * + * Returns: 1 if force umounting flag is enabled or 0 + */ +int mnt_context_is_force(mnt_context *cxt) +{ + return cxt && (cxt->flags & MNT_FL_FORCE) ? 1 : 0; +} + /** * mnt_context_enable_verbose: * @cxt: mount context @@ -336,6 +418,17 @@ int mnt_context_enable_verbose(mnt_context *cxt, int enable) return set_flag(cxt, MNT_FL_VERBOSE, enable); } +/** + * mnt_context_is_verbose + * @cxt: mount context + * + * Returns: 1 if verbose flag is enabled or 0 + */ +int mnt_context_is_verbose(mnt_context *cxt) +{ + return cxt && (cxt->flags & MNT_FL_VERBOSE) ? 1 : 0; +} + /** * mnt_context_enable_loopdel: * @cxt: mount context diff --git a/shlibs/mount/src/mount.h.in b/shlibs/mount/src/mount.h.in index 199549eb..828bf708 100644 --- a/shlibs/mount/src/mount.h.in +++ b/shlibs/mount/src/mount.h.in @@ -345,6 +345,15 @@ extern int mnt_context_enable_force(mnt_context *cxt, int enable); extern int mnt_context_enable_verbose(mnt_context *cxt, int enable); extern int mnt_context_enable_loopdel(mnt_context *cxt, int enable); +extern int mnt_context_get_optsmode(mnt_context *cxt); +extern int mnt_context_is_lazy(mnt_context *cxt); +extern int mnt_context_is_rdonly_umount(mnt_context *cxt); +extern int mnt_context_is_sloppy(mnt_context *cxt); +extern int mnt_context_is_fake(mnt_context *cxt); +extern int mnt_context_is_nomtab(mnt_context *cxt); +extern int mnt_context_is_force(mnt_context *cxt); +extern int mnt_context_is_verbose(mnt_context *cxt); + extern int mnt_context_set_fs(mnt_context *cxt, mnt_fs *fs); extern mnt_fs *mnt_context_get_fs(mnt_context *cxt); extern int mnt_context_set_source(mnt_context *cxt, const char *source); diff --git a/shlibs/mount/src/mount.sym b/shlibs/mount/src/mount.sym index 673f8c80..3ad4a021 100644 --- a/shlibs/mount/src/mount.sym +++ b/shlibs/mount/src/mount.sym @@ -28,9 +28,17 @@ global: mnt_context_get_lock; mnt_context_get_mountflags; mnt_context_get_mtab; + mnt_context_get_optsmode; mnt_context_get_status; mnt_context_get_userspace_mountflags; + mnt_context_is_fake; + mnt_context_is_force; + mnt_context_is_lazy; + mnt_context_is_nomtab; + mnt_context_is_rdonly_umount; mnt_context_is_restricted; + mnt_context_is_sloppy; + mnt_context_is_verbose; mnt_context_set_cache; mnt_context_set_fs; mnt_context_set_fstab; @@ -105,6 +113,7 @@ global: mnt_fs_to_mntent; mnt_fstype_is_netfs; mnt_fstype_is_pseudofs; + mnt_get_builtin_optmap; mnt_get_fstab_path; mnt_get_fstype; mnt_get_library_version; @@ -125,7 +134,6 @@ global: mnt_new_tab_from_dir; mnt_new_tab_from_file; mnt_new_update; - mnt_get_builtin_optmap; mnt_optstr_append_option; mnt_optstr_apply_flags; mnt_optstr_get_flags; -- 2.39.5