diff --git a/VERSION b/VERSION new file mode 100644 index 000000000..b9a24a164 --- /dev/null +++ b/VERSION @@ -0,0 +1 @@ +0.95.00-cvs (2002-01-17) diff --git a/configure b/configure index 203ede444..8b891deeb 100755 --- a/configure +++ b/configure @@ -2071,6 +2071,13 @@ fi fi +if test "-f VERSION"; then + LVM_VERSION="\"`cat VERSION`\"" +else + LVM_VERSION="Unknown" +fi + + @@ -2198,6 +2205,7 @@ include/Makefile \ lib/Makefile \ man/Makefile \ tools/Makefile \ +tools/version.h \ test/mm/Makefile \ test/device/Makefile \ test/format1/Makefile \ @@ -2250,6 +2258,7 @@ s%@READLINE@%$READLINE%g s%@HAVE_RL_COMPLETION_MATCHES@%$HAVE_RL_COMPLETION_MATCHES%g s%@OWNER@%$OWNER%g s%@GROUP@%$GROUP%g +s%@LVM_VERSION@%$LVM_VERSION%g CEOF EOF @@ -2298,6 +2307,7 @@ include/Makefile \ lib/Makefile \ man/Makefile \ tools/Makefile \ +tools/version.h \ test/mm/Makefile \ test/device/Makefile \ test/format1/Makefile \ diff --git a/configure.in b/configure.in index 9687f2e52..c95e8c6f8 100644 --- a/configure.in +++ b/configure.in @@ -116,6 +116,12 @@ package as well (which may be called readline-devel or something similar). HAVE_RL_COMPLETION_MATCHES=no) fi +if test "-f VERSION"; then + LVM_VERSION="\"`cat VERSION`\"" +else + LVM_VERSION="Unknown" +fi + AC_SUBST(JOBS) AC_SUBST(STATIC_LINK) AC_SUBST(READLINE) @@ -123,6 +129,7 @@ AC_SUBST(HAVE_RL_COMPLETION_MATCHES) AC_SUBST(OWNER) AC_SUBST(GROUP) AC_SUBST(LIBS) +AC_SUBST(LVM_VERSION) dnl First and last lines should not contain files to generate in order to dnl keep utility scripts running properly AC_OUTPUT( \ @@ -132,6 +139,7 @@ include/Makefile \ lib/Makefile \ man/Makefile \ tools/Makefile \ +tools/version.h \ test/mm/Makefile \ test/device/Makefile \ test/format1/Makefile \ diff --git a/lib/activate/activate.c b/lib/activate/activate.c index b188004f7..6e8ce5133 100644 --- a/lib/activate/activate.c +++ b/lib/activate/activate.c @@ -11,6 +11,13 @@ #include "fs.h" #include "lvm-string.h" +int library_version(char *version, size_t size) +{ + if (!dm_get_library_version(version, size)) + return 0; + return 1; +} + static void _build_lv_name(char *buffer, size_t s, const char *vg_name, const char *lv_name) { @@ -39,6 +46,31 @@ static struct dm_task *_setup_task(struct logical_volume *lv, int task) return _setup_task_with_name(lv, lv->name, task); } +int driver_version(char *version, size_t size) +{ + int r = 0; + struct dm_task *dmt; + + log_very_verbose("Getting driver version"); + if (!(dmt = dm_task_create(DM_DEVICE_VERSION))) { + stack; + return 0; + } + + if (!dm_task_run(dmt)) + log_error("Failed to get driver version"); + + if (!dm_task_get_driver_version(dmt, version, size)) + goto out; + + r = 1; + + out: + dm_task_destroy(dmt); + + return r; +} + int lv_info(struct logical_volume *lv, struct dm_info *info) { int r = 0; diff --git a/lib/activate/activate.h b/lib/activate/activate.h index 50278411f..859333839 100644 --- a/lib/activate/activate.h +++ b/lib/activate/activate.h @@ -11,6 +11,9 @@ /* FIXME Snapshot handling? */ +int driver_version(char *version, size_t size); +int library_version(char *version, size_t size); + int lv_active(struct logical_volume *lv); int lv_suspended(struct logical_volume *lv); int lv_open_count(struct logical_volume *lv); diff --git a/lib/device/dev-cache.c b/lib/device/dev-cache.c index e403a3a84..a87042738 100644 --- a/lib/device/dev-cache.c +++ b/lib/device/dev-cache.c @@ -238,7 +238,7 @@ static int _insert(const char *path, int rec) } else { /* add a device */ if (!S_ISBLK(info.st_mode)) { - //log_debug("%s: Not a block device", path); + log_debug("%s: Not a block device", path); return 0; } diff --git a/tools/commands.h b/tools/commands.h index 5f291564e..c77774a8b 100644 --- a/tools/commands.h +++ b/tools/commands.h @@ -526,3 +526,8 @@ xx(vgsplit, "\tPhysicalVolumePath [PhysicalVolumePath...]\n", autobackup_ARG, list_ARG, test_ARG) + +xx(version, + "Display software and driver version information", + "version\n" ) + diff --git a/tools/lvm.c b/tools/lvm.c index 1feca1501..c98c66cb9 100644 --- a/tools/lvm.c +++ b/tools/lvm.c @@ -9,6 +9,7 @@ #include "defaults.h" #include "lvm1_label.h" #include "label.h" +#include "version.h" #include "stub.h" @@ -537,6 +538,19 @@ static int merge_synonym(int oldarg, int newarg) return 1; } +int version(int argc, char **argv) +{ + char version[80]; + + log_error("LVM version: %s", LVM_VERSION); + if (library_version(version, sizeof(version))) + log_error("Library version: %s", version); + if (driver_version(version, sizeof(version))) + log_error("Driver version: %s", version); + + return ECMD_PROCESSED; +} + static int process_common_commands(struct command *com) { _current_settings = _default_settings; @@ -565,9 +579,7 @@ static int process_common_commands(struct command *com) } if (arg_count(version_ARG)) { - /* FIXME: Add driver and software version */ - log_error("%s: ", com->name); - return ECMD_PROCESSED; + return version(0, (char **)NULL); } if (arg_count(autobackup_ARG)) { diff --git a/tools/version.h.in b/tools/version.h.in new file mode 100644 index 000000000..7ce441f65 --- /dev/null +++ b/tools/version.h.in @@ -0,0 +1 @@ +#define LVM_VERSION @LVM_VERSION@