diff options
author | Karel Zak | 2012-01-25 17:14:24 +0100 |
---|---|---|
committer | Karel Zak | 2012-01-25 17:14:24 +0100 |
commit | 5810d870970709684cee1219f3459b5cc3fc9915 (patch) | |
tree | 4dcebb6acbde599b8447c65a0ceefb87d9f92ee9 /libmount/src/context_mount.c | |
parent | blkid: move cache to /run on new systems (diff) | |
download | kernel-qcow2-util-linux-5810d870970709684cee1219f3459b5cc3fc9915.tar.gz kernel-qcow2-util-linux-5810d870970709684cee1219f3459b5cc3fc9915.tar.xz kernel-qcow2-util-linux-5810d870970709684cee1219f3459b5cc3fc9915.zip |
libmount: don't pass comments=/x-* to mount.<type> helpers
This patch add a new flag MNT_NOHLPS for mount options map, options
with this flag will not be passed to /sbin/mount.<type> helpers.
Signed-off-by: Karel Zak <kzak@redhat.com>
Diffstat (limited to 'libmount/src/context_mount.c')
-rw-r--r-- | libmount/src/context_mount.c | 32 |
1 files changed, 28 insertions, 4 deletions
diff --git a/libmount/src/context_mount.c b/libmount/src/context_mount.c index 17bbd4287..b3a26fcc8 100644 --- a/libmount/src/context_mount.c +++ b/libmount/src/context_mount.c @@ -147,26 +147,50 @@ done: */ static int generate_helper_optstr(struct libmnt_context *cxt, char **optstr) { + struct libmnt_optmap const *maps[1]; + char *next, *name, *val; + size_t namesz, valsz; int rc = 0; assert(cxt); assert(cxt->fs); assert(optstr); + DBG(CXT, mnt_debug_h(cxt, "mount: generate heper mount options")); + *optstr = mnt_fs_strdup_options(cxt->fs); if (!*optstr) return -ENOMEM; if (cxt->flags & MNT_FL_SAVED_USER) rc = mnt_optstr_set_option(optstr, "user", cxt->orig_user); - if (rc) { - free(*optstr); - *optstr = NULL; + if (rc) + goto err; + + /* remove userspace options with MNT_NOHLPS flag */ + maps[0] = mnt_get_builtin_optmap(MNT_USERSPACE_MAP); + next = *optstr; + + while (!mnt_optstr_next_option(&next, &name, &namesz, &val, &valsz)) { + const struct libmnt_optmap *ent; + + mnt_optmap_get_entry(maps, 1, name, namesz, &ent); + if (ent && ent->id && (ent->mask & MNT_NOHLPS)) { + next = name; + rc = mnt_optstr_remove_option_at(optstr, name, + val ? val + valsz : name + namesz); + if (rc) + goto err; + } } + + return rc; +err: + free(*optstr); + *optstr = NULL; return rc; } - /* * this has to be called before fix_optstr() */ |