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 | |
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')
-rw-r--r-- | libmount/src/fs.c | 35 | ||||
-rw-r--r-- | libmount/src/libmount.h.in | 2 | ||||
-rw-r--r-- | libmount/src/libmount.sym | 1 |
3 files changed, 38 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 * diff --git a/libmount/src/libmount.h.in b/libmount/src/libmount.h.in index b93011aa8..e716f8f0c 100644 --- a/libmount/src/libmount.h.in +++ b/libmount/src/libmount.h.in @@ -330,6 +330,8 @@ extern const char *mnt_fs_get_options(struct libmnt_fs *fs) extern const char *mnt_fs_get_optional_fields(struct libmnt_fs *fs) __ul_attribute__((nonnull)) __ul_attribute__((warn_unused_result)); +extern int mnt_fs_get_propagation(struct libmnt_fs *fs, unsigned long *flags); + extern int mnt_fs_set_options(struct libmnt_fs *fs, const char *optstr); extern int mnt_fs_append_options(struct libmnt_fs *fs, const char *optstr); extern int mnt_fs_prepend_options(struct libmnt_fs *fs, const char *optstr); diff --git a/libmount/src/libmount.sym b/libmount/src/libmount.sym index ecb3e01f7..68b272a8d 100644 --- a/libmount/src/libmount.sym +++ b/libmount/src/libmount.sym @@ -252,4 +252,5 @@ global: MOUNT_2.23 { global: mnt_fs_get_optional_fields; + mnt_fs_get_propagation; } MOUNT_2.22; |