From c82ecd6656840e26afa60c8565bb9acaa67c5e6e Mon Sep 17 00:00:00 2001 From: Dave Wysochanski Date: Tue, 28 Jul 2009 11:03:28 +0000 Subject: [PATCH] Add lvm_library_get_version() and update unit tests to display version. --- liblvm/.exported_symbols | 1 + liblvm/lvm.h | 14 ++++++++++++++ liblvm/lvm_base.c | 5 +++++ test/api/test.c | 1 + test/api/vgtest.c | 1 + 5 files changed, 22 insertions(+) diff --git a/liblvm/.exported_symbols b/liblvm/.exported_symbols index f6307754f..452b676a3 100644 --- a/liblvm/.exported_symbols +++ b/liblvm/.exported_symbols @@ -1,3 +1,4 @@ +lvm_library_get_version lvm_init lvm_quit lvm_config_reload diff --git a/liblvm/lvm.h b/liblvm/lvm.h index 7476b5424..7da8cc5a2 100644 --- a/liblvm/lvm.h +++ b/liblvm/lvm.h @@ -28,6 +28,20 @@ */ /******************************** WARNING ********************************/ +/** + * Retrieve the library version. + * + * The library version is the same format as the full LVM version. + * The format is as follows: + * LVM_MAJOR.LVM_MINOR.LVM_PATCHLEVEL(LVM_LIBAPI)[-LVM_RELEASE] + * An application wishing to determine compatibility with a particular version + * of the library should check at least the LVM_MAJOR, LVM_MINOR, and + * LVM_LIBAPI numbers. For example, assume the full LVM version is + * 2.02.50(1)-1. The application should verify the "2.02" and the "(1)". + * + * \return A string describing the library version. + */ +const char *lvm_library_get_version(void); /******************************** structures ********************************/ diff --git a/liblvm/lvm_base.c b/liblvm/lvm_base.c index b8cd385e9..a6afe1003 100644 --- a/liblvm/lvm_base.c +++ b/liblvm/lvm_base.c @@ -17,6 +17,11 @@ #include "toolcontext.h" #include "locking.h" +const char *lvm_library_get_version(void) +{ + return LVM_VERSION; +} + lvm_t lvm_init(const char *system_dir) { struct cmd_context *cmd; diff --git a/test/api/test.c b/test/api/test.c index 144c59507..95e1b0b19 100644 --- a/test/api/test.c +++ b/test/api/test.c @@ -607,6 +607,7 @@ int main (int argc, char *argv[]) return 1; } + printf("Library version: %s\n", lvm_library_get_version()); lvmapi_test_shell(libh); lvm_quit(libh); diff --git a/test/api/vgtest.c b/test/api/vgtest.c index 4df185ed6..96495a5d4 100644 --- a/test/api/vgtest.c +++ b/test/api/vgtest.c @@ -96,6 +96,7 @@ int main(int argc, char *argv[]) goto bad; } + printf("Library version: %s\n", lvm_library_get_version()); vg_create(vg_name); vg_extend(vg, device); -- 2.43.5