summaryrefslogtreecommitdiffstats
path: root/shlibs/mount/src/fs.c
diff options
context:
space:
mode:
authorKarel Zak2010-07-09 16:39:50 +0200
committerKarel Zak2011-01-03 12:28:40 +0100
commit3661b841289fb36c5690272441737d5d0b34bf88 (patch)
tree6946577ab1a4f82264a56c852b089d4763068a11 /shlibs/mount/src/fs.c
parentlibmount: don't return old data from optls iterator (diff)
downloadkernel-qcow2-util-linux-3661b841289fb36c5690272441737d5d0b34bf88.tar.gz
kernel-qcow2-util-linux-3661b841289fb36c5690272441737d5d0b34bf88.tar.xz
kernel-qcow2-util-linux-3661b841289fb36c5690272441737d5d0b34bf88.zip
libmount: add mnt_split_optstr()
Signed-off-by: Karel Zak <kzak@redhat.com>
Diffstat (limited to 'shlibs/mount/src/fs.c')
-rw-r--r--shlibs/mount/src/fs.c40
1 files changed, 31 insertions, 9 deletions
diff --git a/shlibs/mount/src/fs.c b/shlibs/mount/src/fs.c
index c8677c702..8e51fd73d 100644
--- a/shlibs/mount/src/fs.c
+++ b/shlibs/mount/src/fs.c
@@ -332,37 +332,59 @@ const char *mnt_fs_get_optstr(mnt_fs *fs)
* @fs: fstab/mtab/mountinfo entry
* @optstr: options string
*
- * This function creates a private copy (strdup()) of @optstr.
+ * This function creates a private copy of @optstr.
*
* Returns: 0 on success or -1 in case of error.
*/
int mnt_fs_set_optstr(mnt_fs *fs, const char *optstr)
{
- char *p;
+ char *p, *v, *f;
assert(fs);
if (!fs || !optstr)
return -1;
+ if (mnt_split_optstr((char *) optstr, NULL, &v, &f))
+ return -1;
+
p = strdup(optstr);
- if (!p)
+ if (!p) {
+ free(v);
+ free(f);
return -1;
+ }
free(fs->optstr);
free(fs->fs_optstr);
free(fs->vfs_optstr);
- fs->fs_optstr = fs->vfs_optstr = NULL;
-
- /* TODO: it would be possible to use built-in maps of options
- * and differentiate between VFS and FS options, then we can
- * set fs_optstr and vfs_optstr */
fs->optstr = p;
-
+ fs->fs_optstr = f;
+ fs->vfs_optstr = v;
return 0;
}
/**
+ * mnt_fs_append_optstr:
+ * @fs: fstab/mtab/mountinfo entry
+ * @optstr: options string (usually userspace specific options)
+ *
+ * This function appends @optstr to the current list of the mount options. The
+ * VFS and FS specific lists are not modified -- so then the
+ * mnt_fs_get_optstr() function returns VFS + FS + userspace mount options.
+ *
+ * Returns: 0 on success or -1 in case of error.
+ */
+int mnt_fs_append_optstr(mnt_fs *fs, const char *optstr)
+{
+ assert(fs);
+
+ if (!fs || !optstr)
+ return -1;
+ return mnt_optstr_append_option(&fs->optstr, optstr, NULL);
+}
+
+/**
* mnt_fs_get_fs_optstr:
* @fs: fstab/mtab/mountinfo entry pointer
*