diff options
author | Karel Zak | 2012-01-23 12:27:01 +0100 |
---|---|---|
committer | Karel Zak | 2012-01-23 12:27:01 +0100 |
commit | df51de6b37a9531cdb36a37f4caa28a03a3242d9 (patch) | |
tree | ec4138ea0c5e22bc0680f7b5bbd79eb19018cb48 | |
parent | umount: (new) use the same exit codes as mount(8) (diff) | |
download | kernel-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>
-rw-r--r-- | libmount/src/libmount.h.in | 1 | ||||
-rw-r--r-- | libmount/src/libmount.sym | 1 | ||||
-rw-r--r-- | libmount/src/version.c | 42 |
3 files changed, 43 insertions, 1 deletions
diff --git a/libmount/src/libmount.h.in b/libmount/src/libmount.h.in index 8ecc7f238..3e5a45f83 100644 --- a/libmount/src/libmount.h.in +++ b/libmount/src/libmount.h.in @@ -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); diff --git a/libmount/src/libmount.sym b/libmount/src/libmount.sym index d3d94e0ce..42b2e3092 100644 --- a/libmount/src/libmount.sym +++ b/libmount/src/libmount.sym @@ -223,4 +223,5 @@ global: mnt_fs_is_netfs; mnt_fs_is_pseudofs; mnt_fs_is_swaparea; + mnt_get_library_features; } MOUNT_2.20; 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)) |