]> git.ipfire.org Git - thirdparty/util-linux.git/commitdiff
libmount: export info about library features
authorKarel Zak <kzak@redhat.com>
Mon, 23 Jan 2012 11:27:01 +0000 (12:27 +0100)
committerKarel Zak <kzak@redhat.com>
Mon, 23 Jan 2012 11:27:01 +0000 (12:27 +0100)
Signed-off-by: Karel Zak <kzak@redhat.com>
libmount/src/libmount.h.in
libmount/src/libmount.sym
libmount/src/version.c

index 8ecc7f2385a8b7096ae779771224bd620c541320..3e5a45f838415b1c4625c035426cbb0a5da8715c 100644 (file)
@@ -120,6 +120,7 @@ extern void mnt_init_debug(int mask);
 /* version.c */
 extern int mnt_parse_version_string(const char *ver_string);
 extern int mnt_get_library_version(const char **ver_string);
+extern int mnt_get_library_features(const char ***features);
 
 /* utils.c */
 extern char *mnt_mangle(const char *str);
index d3d94e0cea1d90ffbc066611c5563eb16df3b0d2..42b2e30926edf2af1ee806130a4e79db6f946f92 100644 (file)
@@ -223,4 +223,5 @@ global:
        mnt_fs_is_netfs;
        mnt_fs_is_pseudofs;
        mnt_fs_is_swaparea;
+       mnt_get_library_features;
 } MOUNT_2.20;
index 327188dbebd99aa2bba1378510db56d719b683c7..e3bc5ca8aeb20be0bb24d4e3dd9bebc43e31539f 100644 (file)
 #include "mountP.h"
 
 static const char *lib_version = LIBMOUNT_VERSION;
+static const char *lib_features[] = {
+#ifdef HAVE_LIBSELINUX
+       "selinux",
+#endif
+#ifdef CONFIG_LIBMOUNT_DEBUG
+       "debug",
+#endif
+       NULL
+};
 
 /**
  * mnt_parse_version_string:
@@ -42,7 +51,7 @@ int mnt_parse_version_string(const char *ver_string)
 
 /**
  * mnt_get_library_version:
- * @ver_string: return pointer to the static library version string
+ * @ver_string: return pointer to the static library version string if not NULL
  *
  * Returns: release version number.
  */
@@ -54,15 +63,46 @@ int mnt_get_library_version(const char **ver_string)
        return mnt_parse_version_string(lib_version);
 }
 
+/**
+ * mnt_get_library_features:
+ * @features: returns pointer to the static array of strings, the array is
+ *            terminated by NULL.
+ *
+ * Example:
+ *
+ *     const char *features;
+ *
+ *     mnt_get_library_features(&features);
+ *     while (features && *features)
+ *             printf("%s\n", *features++);
+ *
+ * Returns: number of items in the features array not including the last NULL,
+ *          or less then zero in case of error
+ */
+int mnt_get_library_features(const char ***features)
+{
+       if (!features)
+               return -EINVAL;
+
+       *features = lib_features;
+       return ARRAY_SIZE(lib_features) - 1;
+}
+
 #ifdef TEST_PROGRAM
 int test_version(struct libmnt_test *ts, int argc, char *argv[])
 {
        const char *ver;
+       const char **features;
 
        mnt_get_library_version(&ver);
 
        printf("Library version: %s\n", ver);
        printf("Library API version: " LIBMOUNT_VERSION "\n");
+       printf("Library features:");
+
+       mnt_get_library_features(&features);
+       while (features && *features)
+               printf(" %s", *features++);
 
        if (mnt_get_library_version(NULL) ==
                        mnt_parse_version_string(LIBMOUNT_VERSION))