summaryrefslogtreecommitdiffstats
path: root/shlibs/mount
diff options
context:
space:
mode:
authorKarel Zak2010-07-28 15:14:41 +0200
committerKarel Zak2011-01-03 12:28:40 +0100
commitf309b8a7c90693a73ab45dc548029d1007c7afe4 (patch)
tree7997c95a54c45afb334e0c129264eb48232028d1 /shlibs/mount
parentlibmount: add unit test for mnt_copy_fs() (diff)
downloadkernel-qcow2-util-linux-f309b8a7c90693a73ab45dc548029d1007c7afe4.tar.gz
kernel-qcow2-util-linux-f309b8a7c90693a73ab45dc548029d1007c7afe4.tar.xz
kernel-qcow2-util-linux-f309b8a7c90693a73ab45dc548029d1007c7afe4.zip
libmount: add uhelper=, improve mnt_split_optstr()
Signed-off-by: Karel Zak <kzak@redhat.com>
Diffstat (limited to 'shlibs/mount')
-rw-r--r--shlibs/mount/src/fs.c2
-rw-r--r--shlibs/mount/src/mount.h.in5
-rw-r--r--shlibs/mount/src/optmap.c2
-rw-r--r--shlibs/mount/src/optstr.c29
4 files changed, 29 insertions, 9 deletions
diff --git a/shlibs/mount/src/fs.c b/shlibs/mount/src/fs.c
index f0eae7448..7fc5e8825 100644
--- a/shlibs/mount/src/fs.c
+++ b/shlibs/mount/src/fs.c
@@ -407,7 +407,7 @@ int mnt_fs_set_optstr(mnt_fs *fs, const char *optstr)
if (!fs || !optstr)
return -1;
- if (mnt_split_optstr((char *) optstr, NULL, &v, &f))
+ if (mnt_split_optstr((char *) optstr, NULL, &v, &f, 0, 0))
return -1;
p = strdup(optstr);
diff --git a/shlibs/mount/src/mount.h.in b/shlibs/mount/src/mount.h.in
index 33f8d1722..6a1cd19be 100644
--- a/shlibs/mount/src/mount.h.in
+++ b/shlibs/mount/src/mount.h.in
@@ -146,7 +146,9 @@ extern int mnt_optstr_set_option(char **optstr, const char *name,
const char *value);
extern int mnt_optstr_remove_option(char **optstr, const char *name);
-extern int mnt_split_optstr(const char *optstr, char **user, char **vfs, char **fs);
+extern int mnt_split_optstr(const char *optstr,
+ char **user, char **vfs, char **fs,
+ int ifnore_user, int ignore_vfs);
/* iter.c */
enum {
@@ -305,6 +307,7 @@ extern int mnt_tab_find_next_fs(mnt_tab *tb, mnt_iter *itr,
#define MNT_MS_COMMENT (1 << 8)
#define MNT_MS_LOOP (1 << 9)
#define MNT_MS_NOFAIL (1 << 10)
+#define MNT_MS_UHELPER (1 << 11)
/*
* mount(2) MS_* masks (MNT_MAP_LINUX map)
diff --git a/shlibs/mount/src/optmap.c b/shlibs/mount/src/optmap.c
index 0163776a7..12ead4023 100644
--- a/shlibs/mount/src/optmap.c
+++ b/shlibs/mount/src/optmap.c
@@ -167,6 +167,8 @@ static const struct mnt_optmap userspace_opts_map[] =
{ "nofail", MNT_MS_NOFAIL, MNT_NOMTAB }, /* Do not fail if ENOENT on dev */
+ { "uhelper=%s", MNT_MS_UHELPER }, /* /sbin/umount.<helper> */
+
{ NULL, 0, 0 }
};
diff --git a/shlibs/mount/src/optstr.c b/shlibs/mount/src/optstr.c
index fe9ee9bed..f17bd7d3a 100644
--- a/shlibs/mount/src/optstr.c
+++ b/shlibs/mount/src/optstr.c
@@ -336,15 +336,25 @@ int mnt_optstr_remove_option(char **optstr, const char *name)
* @user: returns newly allocated string with userspace options
* @vfs: returns newly allocated string with VFS options
* @fs: returns newly allocated string with FS options
+ * @ignore_user: option mask for options that should be ignored
+ * @ignore_vfs: option mask for options that should be ignored
+ *
+ * For example:
+ *
+ * mnt_split_optstr(optstr, &u, NULL, NULL, MNT_NOMTAB, 0);
+ *
+ * returns all userspace options, the options that does not belong to
+ * mtab are ignored.
*
* Note that FS options are all options that are undefined in MNT_USERSPACE_MAP
* or MNT_LINUX_MAP.
*
* Returns: 0 on success, or -1 in case of error.
*/
-int mnt_split_optstr(char *optstr, char **user, char **vfs, char **fs)
+int mnt_split_optstr(const char *optstr, char **user, char **vfs, char **fs,
+ int ignore_user, int ignore_vfs)
{
- char *name, *val;
+ char *name, *val, *str = (char *) optstr;
size_t namesz, valsz;
struct mnt_optmap const *maps[2];
@@ -363,18 +373,23 @@ int mnt_split_optstr(char *optstr, char **user, char **vfs, char **fs)
if (user)
*user = NULL;
- while(!mnt_optstr_next_option(&optstr, &name, &namesz, &val, &valsz)) {
+ while(!mnt_optstr_next_option(&str, &name, &namesz, &val, &valsz)) {
int rc = 0;
+ const struct mnt_optmap *ent;
const struct mnt_optmap *m =
- mnt_optmap_get_entry(maps, 2, name, namesz, NULL);
+ mnt_optmap_get_entry(maps, 2, name, namesz, &ent);
- if (m && m == maps[0] && vfs)
+ if (m && m == maps[0] && vfs) {
+ if (ignore_vfs && (ent->mask & ignore_vfs))
+ continue;
rc = __mnt_optstr_append_option(vfs, name, namesz,
val, valsz);
- else if (m && m == maps[1] && user)
+ } else if (m && m == maps[1] && user) {
+ if (ignore_user && (ent->mask & ignore_user))
+ continue;
rc = __mnt_optstr_append_option(user, name, namesz,
val, valsz);
- else if (!m && fs)
+ } else if (!m && fs)
rc = __mnt_optstr_append_option(fs, name, namesz,
val, valsz);
if (rc) {