summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--libmount/docs/libmount-sections.txt1
-rw-r--r--libmount/src/fs.c35
-rw-r--r--libmount/src/libmount.h.in2
-rw-r--r--libmount/src/libmount.sym1
4 files changed, 39 insertions, 0 deletions
diff --git a/libmount/docs/libmount-sections.txt b/libmount/docs/libmount-sections.txt
index f69a63b8a..6a00ea413 100644
--- a/libmount/docs/libmount-sections.txt
+++ b/libmount/docs/libmount-sections.txt
@@ -174,6 +174,7 @@ mnt_fs_get_options
mnt_fs_get_parent_id
mnt_fs_get_passno
mnt_fs_get_priority
+mnt_fs_get_propagation
mnt_fs_get_root
mnt_fs_get_size
mnt_fs_get_source
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;