diff options
author | Karel Zak | 2010-08-24 16:03:50 +0200 |
---|---|---|
committer | Karel Zak | 2011-01-03 12:28:41 +0100 |
commit | 569f95b7e8d457e11ce1ca114128bdf7f732208f (patch) | |
tree | 2238076ad3f5acfa73ba0f9d7b38c1ccb8cefe82 /shlibs/mount/src/fs.c | |
parent | libmount: improve an rename API for mtab management (diff) | |
download | kernel-qcow2-util-linux-569f95b7e8d457e11ce1ca114128bdf7f732208f.tar.gz kernel-qcow2-util-linux-569f95b7e8d457e11ce1ca114128bdf7f732208f.tar.xz kernel-qcow2-util-linux-569f95b7e8d457e11ce1ca114128bdf7f732208f.zip |
libmount: clean up mnt_fs_set_optstr()
Signed-off-by: Karel Zak <kzak@redhat.com>
Diffstat (limited to 'shlibs/mount/src/fs.c')
-rw-r--r-- | shlibs/mount/src/fs.c | 72 |
1 files changed, 55 insertions, 17 deletions
diff --git a/shlibs/mount/src/fs.c b/shlibs/mount/src/fs.c index 4931d0785..2151d5449 100644 --- a/shlibs/mount/src/fs.c +++ b/shlibs/mount/src/fs.c @@ -390,16 +390,7 @@ const char *mnt_fs_get_optstr(mnt_fs *fs) return fs ? fs->optstr : NULL; } -/** - * mnt_fs_set_optstr: - * @fs: fstab/mtab/mountinfo entry - * @optstr: options string - * - * 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) +int __mnt_fs_set_optstr(mnt_fs *fs, const char *optstr, int split) { char *p = NULL, *v = NULL, *f = NULL; @@ -409,7 +400,8 @@ int mnt_fs_set_optstr(mnt_fs *fs, const char *optstr) return -1; if (optstr) { - if (mnt_split_optstr((char *) optstr, NULL, &v, &f, 0, 0)) + if (split && + mnt_split_optstr((char *) optstr, NULL, &v, &f, 0, 0)) return -1; p = strdup(optstr); @@ -431,17 +423,31 @@ int mnt_fs_set_optstr(mnt_fs *fs, const char *optstr) } /** - * mnt_fs_append_optstr: + * mnt_fs_set_optstr: * @fs: fstab/mtab/mountinfo entry - * @optstr: options string (usually userspace specific options) + * @optstr: options string * - * 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. + * This function creates a private copy of @optstr. The function also updates + * VFS and FS mount options. * * Returns: 0 on success or -1 in case of error. */ -int mnt_fs_append_optstr(mnt_fs *fs, const char *optstr) +int mnt_fs_set_optstr(mnt_fs *fs, const char *optstr) +{ + return __mnt_fs_set_optstr(fs, optstr, TRUE); +} + +/** + * mnt_fs_append_userspace_optstr: + * @fs: fstab/mtab/mountinfo entry + * @optstr: options string + * + * This function appends @optstr to the current list of the mount options. The VFS and + * FS mount options are not modified. + * + * Returns: 0 on success or -1 in case of error. + */ +int mnt_fs_append_userspace_optstr(mnt_fs *fs, const char *optstr) { assert(fs); @@ -452,6 +458,38 @@ int mnt_fs_append_optstr(mnt_fs *fs, const char *optstr) } /** + * mnt_fs_append_optstr: + * @fs: fstab/mtab/mountinfo entry + * @optstr: mount options + * + * Returns: 0 on success or -1 in case of error. + */ +int mnt_fs_append_optstr(mnt_fs *fs, const char *optstr) +{ + char *v = NULL, *f = NULL; + + assert(fs); + + if (!fs) + return -1; + if (!optstr) + return 0; + + if (mnt_split_optstr((char *) optstr, NULL, &v, &f, 0, 0)) + return -1; + + if (mnt_optstr_append_option(&fs->optstr, optstr, NULL)) + return -1; + if (v && mnt_optstr_append_option(&fs->vfs_optstr, v, NULL)) + return -1; + if (f && mnt_optstr_append_option(&fs->fs_optstr, f, NULL)) + return -1; + + return 0; + +} + +/** * mnt_fs_get_fs_optstr: * @fs: fstab/mtab/mountinfo entry pointer * |