summaryrefslogtreecommitdiffstats
path: root/libmount/src/version.c
diff options
context:
space:
mode:
authorKarel Zak2012-01-23 12:27:01 +0100
committerKarel Zak2012-01-23 12:27:01 +0100
commitdf51de6b37a9531cdb36a37f4caa28a03a3242d9 (patch)
treeec4138ea0c5e22bc0680f7b5bbd79eb19018cb48 /libmount/src/version.c
parentumount: (new) use the same exit codes as mount(8) (diff)
downloadkernel-qcow2-util-linux-df51de6b37a9531cdb36a37f4caa28a03a3242d9.tar.gz
kernel-qcow2-util-linux-df51de6b37a9531cdb36a37f4caa28a03a3242d9.tar.xz
kernel-qcow2-util-linux-df51de6b37a9531cdb36a37f4caa28a03a3242d9.zip
libmount: export info about library features
Signed-off-by: Karel Zak <kzak@redhat.com>
Diffstat (limited to 'libmount/src/version.c')
-rw-r--r--libmount/src/version.c42
1 files changed, 41 insertions, 1 deletions
diff --git a/libmount/src/version.c b/libmount/src/version.c
index 327188dbe..e3bc5ca8a 100644
--- a/libmount/src/version.c
+++ b/libmount/src/version.c
@@ -18,6 +18,15 @@
#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))