diff options
author | Karel Zak | 2013-01-10 15:58:52 +0100 |
---|---|---|
committer | Karel Zak | 2013-01-10 15:58:52 +0100 |
commit | 4b9d67a23d8db22ad6772cdb7af94b02f9a59b22 (patch) | |
tree | 816eecd44c0703297b55063a558558c7c33f0241 /libmount/src/fs.c | |
parent | findmnt: add ID column (diff) | |
download | kernel-qcow2-util-linux-4b9d67a23d8db22ad6772cdb7af94b02f9a59b22.tar.gz kernel-qcow2-util-linux-4b9d67a23d8db22ad6772cdb7af94b02f9a59b22.tar.xz kernel-qcow2-util-linux-4b9d67a23d8db22ad6772cdb7af94b02f9a59b22.zip |
libmount: add mnt_fs_get_propagation()
Signed-off-by: Karel Zak <kzak@redhat.com>
Diffstat (limited to 'libmount/src/fs.c')
-rw-r--r-- | libmount/src/fs.c | 35 |
1 files changed, 35 insertions, 0 deletions
diff --git a/libmount/src/fs.c b/libmount/src/fs.c index 5c1a1074a..232a2f618 100644 --- a/libmount/src/fs.c +++ b/libmount/src/fs.c @@ -490,6 +490,41 @@ static int mnt_fs_get_flags(struct libmnt_fs *fs) } /** + * mnt_fs_get_propagation: + * @fs: mountinfo entry + * @flags: returns propagation MS_* flags as present in mountinfo file + * + * Note that this function set @flags to zero if not found any propagation flag + * in mountinfo file. The kernel default is MS_PRIVATE, this flag is not stored + * in the mountinfo file. + * + * Returns: 0 on success or negative number in case of error. + */ +int mnt_fs_get_propagation(struct libmnt_fs *fs, unsigned long *flags) +{ + if (!fs || !flags) + return -EINVAL; + + *flags = 0; + + if (!fs->opt_fields) + return 0; + + /* + * The optional fields format is incompatible with mount options + * ... we have to parse the field here. + */ + *flags |= strstr(fs->opt_fields, "shared:") ? MS_SHARED : MS_PRIVATE; + + if (strstr(fs->opt_fields, "master:")) + *flags |= MS_SLAVE; + if (strstr(fs->opt_fields, "unbindable")) + *flags |= MS_UNBINDABLE; + + return 0; +} + +/** * mnt_fs_is_kernel: * @fs: filesystem * |