]> git.ipfire.org Git - thirdparty/util-linux.git/commitdiff
libmount: add mnt_fs_get_propagation()
authorKarel Zak <kzak@redhat.com>
Thu, 10 Jan 2013 14:58:52 +0000 (15:58 +0100)
committerKarel Zak <kzak@redhat.com>
Thu, 10 Jan 2013 14:58:52 +0000 (15:58 +0100)
Signed-off-by: Karel Zak <kzak@redhat.com>
libmount/docs/libmount-sections.txt
libmount/src/fs.c
libmount/src/libmount.h.in
libmount/src/libmount.sym

index f69a63b8ac81e4c62f65ddf91638d2e238257c8d..6a00ea413b97a71b191026f911dc21d6aaf31be0 100644 (file)
@@ -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
index 5c1a1074a09601d7700f5e250b32b4e8128b63bf..232a2f61887556d5aaa4e48e6de683369f13e02f 100644 (file)
@@ -489,6 +489,41 @@ static int mnt_fs_get_flags(struct libmnt_fs *fs)
        return fs ? fs->flags : 0;
 }
 
+/**
+ * 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
index b93011aa88bbda8d003cd9fc03d6847efa306998..e716f8f0cfd72d33f06a6296b8ee03a45e48843a 100644 (file)
@@ -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);
index ecb3e01f78d7608a3d68fe4bd0695f8ad34bd283..68b272a8d01e3207517ee2b750222a44904b2a2b 100644 (file)
@@ -252,4 +252,5 @@ global:
 MOUNT_2.23 {
 global:
        mnt_fs_get_optional_fields;
+       mnt_fs_get_propagation;
 } MOUNT_2.22;