mirror of
git://sourceware.org/git/lvm2.git
synced 2024-12-21 13:34:40 +03:00
Support --version argument and 'version' shell command.
This commit is contained in:
parent
444b7d2360
commit
fae0c5764f
10
configure
vendored
10
configure
vendored
@ -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 \
|
||||
|
@ -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 \
|
||||
|
@ -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;
|
||||
|
@ -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);
|
||||
|
@ -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;
|
||||
}
|
||||
|
||||
|
@ -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" )
|
||||
|
||||
|
18
tools/lvm.c
18
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)) {
|
||||
|
1
tools/version.h.in
Normal file
1
tools/version.h.in
Normal file
@ -0,0 +1 @@
|
||||
#define LVM_VERSION @LVM_VERSION@
|
Loading…
Reference in New Issue
Block a user