summaryrefslogtreecommitdiffstats
path: root/shlibs/mount/src/fs.c
diff options
context:
space:
mode:
authorKarel Zak2010-12-22 13:15:04 +0100
committerKarel Zak2011-01-03 12:28:48 +0100
commitf84fa6f7b98dd00ef6f196815b18590ca50c3528 (patch)
tree6b7c7f0a084ea242240c2fb0d9980e954ae24fcc /shlibs/mount/src/fs.c
parenttests: check for mtab (diff)
downloadkernel-qcow2-util-linux-f84fa6f7b98dd00ef6f196815b18590ca50c3528.tar.gz
kernel-qcow2-util-linux-f84fa6f7b98dd00ef6f196815b18590ca50c3528.tar.xz
kernel-qcow2-util-linux-f84fa6f7b98dd00ef6f196815b18590ca50c3528.zip
libmount: better work with mtab options
Signed-off-by: Karel Zak <kzak@redhat.com>
Diffstat (limited to 'shlibs/mount/src/fs.c')
-rw-r--r--shlibs/mount/src/fs.c54
1 files changed, 54 insertions, 0 deletions
diff --git a/shlibs/mount/src/fs.c b/shlibs/mount/src/fs.c
index 94c353558..21e02f3df 100644
--- a/shlibs/mount/src/fs.c
+++ b/shlibs/mount/src/fs.c
@@ -146,6 +146,60 @@ err:
}
/**
+ * mnt_copy_mtab_fs:
+ * @fs: filesystem
+ *
+ * This function copies all @fs description except information that does not
+ * belong to /etc/mtab (e.g. VFS and userspace mount options with MNT_NOMTAB
+ * mask).
+ *
+ * Returns: copy of @fs.
+ */
+mnt_fs *mnt_copy_mtab_fs(const mnt_fs *fs)
+{
+ mnt_fs *n = mnt_new_fs();
+
+ if (!n)
+ return NULL;
+
+ if (cpy_str_at_offset(n, fs, offsetof(struct _mnt_fs, source)))
+ goto err;
+ if (cpy_str_at_offset(n, fs, offsetof(struct _mnt_fs, target)))
+ goto err;
+ if (cpy_str_at_offset(n, fs, offsetof(struct _mnt_fs, fstype)))
+ goto err;
+
+ if (fs->vfs_optstr) {
+ char *p = NULL;
+ mnt_optstr_get_options(fs->vfs_optstr, &p,
+ mnt_get_builtin_optmap(MNT_LINUX_MAP),
+ MNT_NOMTAB);
+ n->vfs_optstr = p;
+ }
+
+ if (fs->user_optstr) {
+ char *p = NULL;
+ mnt_optstr_get_options(fs->user_optstr, &p,
+ mnt_get_builtin_optmap(MNT_USERSPACE_MAP),
+ MNT_NOMTAB);
+ n->user_optstr = p;
+ }
+
+ if (cpy_str_at_offset(n, fs, offsetof(struct _mnt_fs, fs_optstr)))
+ goto err;
+
+ n->freq = fs->freq;
+ n->passno = fs->passno;
+ n->flags = fs->flags;
+
+ return n;
+err:
+ mnt_free_fs(n);
+ return NULL;
+
+}
+
+/**
* mnt_fs_get_userdata:
* @fs: mnt_file instance
*