1
0
mirror of git://sourceware.org/git/lvm2.git synced 2025-12-28 04:23:49 +03:00

Compare commits

...

15 Commits

Author SHA1 Message Date
Alasdair Kergon
5e7a308528 Ignore error setting selinux file context if fs doesn't support it. 2004-04-16 12:24:46 +00:00
Alasdair Kergon
7952177786 2.00.12 2004-04-14 20:09:25 +00:00
Alasdair Kergon
9afbe49c84 update 2004-04-14 18:31:35 +00:00
Alasdair Kergon
9f06ba2db3 fix selinux error mesg 2004-04-14 18:10:10 +00:00
Alasdair Kergon
fe55bfddcf lvm.static can be installed in different dir from rest of tools 2004-04-14 18:00:23 +00:00
Alasdair Kergon
c0842e6444 Install example config file by default if there isn't one already. 2004-04-14 17:39:55 +00:00
Alasdair Kergon
3fed20d06a Add power2 2004-04-14 17:33:51 +00:00
Alasdair Kergon
5e8f2e2c04 Fix lvs_in_vg_opened counting. 2004-04-14 17:33:04 +00:00
Alasdair Kergon
e4df99ea84 fix patch that misapplied 2004-04-08 17:21:01 +00:00
Alasdair Kergon
b3276f5f11 Update version 2004-04-08 17:14:00 +00:00
Alasdair Kergon
32667ca256 Option for auto-fallback to LVM1 tools if running 2.4 without device-mapper. 2004-04-08 15:23:23 +00:00
Alasdair Kergon
bed122a170 update for 2.00.10 2004-04-07 18:12:51 +00:00
Alasdair Kergon
14adc9b875 Basic selinux support 2004-04-07 14:08:22 +00:00
Alasdair Kergon
a8778bbc5a Fix status overflow check in kernel patches. 2004-04-07 12:39:59 +00:00
Alasdair Kergon
a54e641f44 fix static selinux build 2004-04-06 20:32:02 +00:00
23 changed files with 388 additions and 14 deletions

View File

@@ -16,7 +16,7 @@ srcdir = @srcdir@
top_srcdir = @top_srcdir@
VPATH = @srcdir@
SUBDIRS = include man
SUBDIRS = doc include man
ifeq ("@INTL@", "yes")
SUBDIRS += po

View File

@@ -1 +1 @@
2.00.10-cvs (2004-04-06)
2.00.12-cvs (2004-04-14)

View File

@@ -1,6 +1,25 @@
Version 2.00.10 - 6 Apr 2004
Version 2.00.13 - 64 Apr 2004
=============================
Ignore error setting selinux file context if fs doesn't support it.
Version 2.00.12 - 14 Apr 2004
=============================
Install a default lvm.conf into /etc/lvm if there isn't one already.
Allow different installation dir for lvm.static (configure --staticdir=)
Fix inverted selinux error check.
Recognise power2 in /proc/devices.
Fix counting in lvs_in_vg_opened. [It ignored devices open more than once.]
Version 2.00.11 - 8 Apr 2004
============================
Set fallback_to_lvm1 in lvm.conf (or configure --enable-lvm1_fallback)
to run lvm1 binaries if running a 2.4 kernel without device-mapper.
Version 2.00.10 - 7 Apr 2004
============================
More fixes for static build.
Add basic selinux support.
Fix sysfs detection.
Version 2.00.09 - 31 Mar 2004
=============================

View File

@@ -1,3 +1,15 @@
Version 1.00.16 - 16 Apr 2004
=============================
Ignore error setting selinux file context if fs doesn't support it.
Version 1.00.15 - 7 Apr 2004
============================
Fix status overflow check in kernel patches.
Version 1.00.14 - 6 Apr 2004
============================
Fix static selinux build.
Version 1.00.13 - 6 Apr 2004
============================
Add some basic selinux support.

120
configure vendored
View File

@@ -309,7 +309,7 @@ ac_includes_default="\
#endif"
ac_default_prefix=/usr
ac_subst_vars='SHELL PATH_SEPARATOR PACKAGE_NAME PACKAGE_TARNAME PACKAGE_VERSION PACKAGE_STRING PACKAGE_BUGREPORT exec_prefix prefix program_transform_name bindir sbindir libexecdir datadir sysconfdir sharedstatedir localstatedir libdir includedir oldincludedir infodir mandir build_alias host_alias target_alias DEFS ECHO_C ECHO_N ECHO_T LIBS AWK CC CFLAGS LDFLAGS CPPFLAGS ac_ct_CC EXEEXT OBJEXT INSTALL_PROGRAM INSTALL_SCRIPT INSTALL_DATA LN_S SET_MAKE RANLIB ac_ct_RANLIB CPP EGREP build build_cpu build_vendor build_os host host_cpu host_vendor host_os target target_cpu target_vendor target_os MSGFMT JOBS STATIC_LINK LVM1 OWNER GROUP CLDFLAGS CLDWHOLEARCHIVE CLDNOWHOLEARCHIVE LD_DEPS LD_FLAGS SOFLAG LVM_VERSION DEBUG DEVMAPPER HAVE_LIBDL CMDLIB LOCALEDIR INTL_PACKAGE INTL LIBOBJS LTLIBOBJS'
ac_subst_vars='SHELL PATH_SEPARATOR PACKAGE_NAME PACKAGE_TARNAME PACKAGE_VERSION PACKAGE_STRING PACKAGE_BUGREPORT exec_prefix prefix program_transform_name bindir sbindir libexecdir datadir sysconfdir sharedstatedir localstatedir libdir includedir oldincludedir infodir mandir build_alias host_alias target_alias DEFS ECHO_C ECHO_N ECHO_T LIBS AWK CC CFLAGS LDFLAGS CPPFLAGS ac_ct_CC EXEEXT OBJEXT INSTALL_PROGRAM INSTALL_SCRIPT INSTALL_DATA LN_S SET_MAKE RANLIB ac_ct_RANLIB CPP EGREP build build_cpu build_vendor build_os host host_cpu host_vendor host_os target target_cpu target_vendor target_os MSGFMT JOBS STATIC_LINK LVM1 OWNER GROUP CLDFLAGS CLDWHOLEARCHIVE CLDNOWHOLEARCHIVE LD_DEPS LD_FLAGS SOFLAG LVM_VERSION LVM1_FALLBACK DEBUG DEVMAPPER HAVE_LIBDL HAVE_SELINUX CMDLIB LOCALEDIR CONFDIR STATICDIR INTL_PACKAGE INTL LIBOBJS LTLIBOBJS'
ac_subst_files=''
# Initialize some variables set by options.
@@ -845,6 +845,8 @@ if test -n "$ac_init_help"; then
Optional Features:
--disable-FEATURE do not include FEATURE (same as --enable-FEATURE=no)
--enable-FEATURE[=ARG] include FEATURE [ARG=yes]
--enable-lvm1_fallback Use this to fall back and use LVM1 binaries if
device-mapper is missing from the kernel
--enable-jobs=NUM Number of jobs to run simultaneously
--enable-static_link Use this to link the tools to their libraries
statically. Default is dynamic linking
@@ -863,6 +865,8 @@ Optional Packages:
--with-lvm1=TYPE LVM1 metadata support: internal/shared/none
TYPE=internal
--with-localedir=DIR Translation files in DIR PREFIX/share/locale
--with-confdir=DIR Configuration files in DIR /etc
--with-staticdir=DIR Static binary in DIR EXEC_PREFIX/sbin
Some influential environment variables:
CC C compiler command
@@ -3921,6 +3925,18 @@ else
GROUP="root"
fi;
# Check whether --enable-lvm1_fallback or --disable-lvm1_fallback was given.
if test "${enable_lvm1_fallback+set}" = set; then
enableval="$enable_lvm1_fallback"
LVM1_FALLBACK=$enableval
else
LVM1_FALLBACK=no
fi;
if test x$LVM1_FALLBACK = xyes; then
CFLAGS="$CFLAGS -DLVM1_FALLBACK"
fi
# Check whether --with-lvm1 or --without-lvm1 was given.
if test "${with_lvm1+set}" = set; then
@@ -4592,13 +4608,79 @@ else
fi
if [ "x$LVM1" = xshared -a "x$STATIC_LINK" = xyes ];
then { { echo "$as_me:$LINENO: error: Features cannot be \"shared\" when building statically
then { { echo "$as_me:$LINENO: error: Features cannot be 'shared' when building statically
" >&5
echo "$as_me: error: Features cannot be \"shared\" when building statically
echo "$as_me: error: Features cannot be 'shared' when building statically
" >&2;}
{ (exit 1); exit 1; }; }
exit
fi;
fi
echo "$as_me:$LINENO: checking for is_selinux_enabled in -lselinux" >&5
echo $ECHO_N "checking for is_selinux_enabled in -lselinux... $ECHO_C" >&6
if test "${ac_cv_lib_selinux_is_selinux_enabled+set}" = set; then
echo $ECHO_N "(cached) $ECHO_C" >&6
else
ac_check_lib_save_LIBS=$LIBS
LIBS="-lselinux $LIBS"
cat >conftest.$ac_ext <<_ACEOF
#line $LINENO "configure"
/* confdefs.h. */
_ACEOF
cat confdefs.h >>conftest.$ac_ext
cat >>conftest.$ac_ext <<_ACEOF
/* end confdefs.h. */
/* Override any gcc2 internal prototype to avoid an error. */
#ifdef __cplusplus
extern "C"
#endif
/* We use char because int might match the return type of a gcc2
builtin and then its argument prototype would still apply. */
char is_selinux_enabled ();
int
main ()
{
is_selinux_enabled ();
;
return 0;
}
_ACEOF
rm -f conftest.$ac_objext conftest$ac_exeext
if { (eval echo "$as_me:$LINENO: \"$ac_link\"") >&5
(eval $ac_link) 2>&5
ac_status=$?
echo "$as_me:$LINENO: \$? = $ac_status" >&5
(exit $ac_status); } &&
{ ac_try='test -s conftest$ac_exeext'
{ (eval echo "$as_me:$LINENO: \"$ac_try\"") >&5
(eval $ac_try) 2>&5
ac_status=$?
echo "$as_me:$LINENO: \$? = $ac_status" >&5
(exit $ac_status); }; }; then
ac_cv_lib_selinux_is_selinux_enabled=yes
else
echo "$as_me: failed program was:" >&5
sed 's/^/| /' conftest.$ac_ext >&5
ac_cv_lib_selinux_is_selinux_enabled=no
fi
rm -f conftest.$ac_objext conftest$ac_exeext conftest.$ac_ext
LIBS=$ac_check_lib_save_LIBS
fi
echo "$as_me:$LINENO: result: $ac_cv_lib_selinux_is_selinux_enabled" >&5
echo "${ECHO_T}$ac_cv_lib_selinux_is_selinux_enabled" >&6
if test $ac_cv_lib_selinux_is_selinux_enabled = yes; then
HAVE_SELINUX=yes
else
HAVE_SELINUX=no
fi
if test x$HAVE_SELINUX = xyes; then
CFLAGS="$CFLAGS -DHAVE_SELINUX"
LIBS="-lselinux $LIBS"
fi
for ac_header in getopt.h
@@ -4976,6 +5058,25 @@ else
fi;
fi
# Check whether --with-confdir or --without-confdir was given.
if test "${with_confdir+set}" = set; then
withval="$with_confdir"
CONFDIR="$withval"
else
CONFDIR='/etc'
fi;
# Check whether --with-staticdir or --without-staticdir was given.
if test "${with_staticdir+set}" = set; then
withval="$with_staticdir"
STATICDIR="$withval"
else
STATICDIR='${exec_prefix}/sbin'
fi;
if test "-f VERSION"; then
LVM_VERSION="\"`cat VERSION`\""
else
@@ -5005,7 +5106,11 @@ fi
ac_config_files="$ac_config_files Makefile make.tmpl include/Makefile lib/Makefile lib/format1/Makefile man/Makefile po/Makefile tools/Makefile tools/version.h test/mm/Makefile test/device/Makefile test/format1/Makefile test/regex/Makefile test/filters/Makefile"
ac_config_files="$ac_config_files Makefile make.tmpl doc/Makefile include/Makefile lib/Makefile lib/format1/Makefile man/Makefile po/Makefile tools/Makefile tools/version.h test/mm/Makefile test/device/Makefile test/format1/Makefile test/regex/Makefile test/filters/Makefile"
cat >confcache <<\_ACEOF
# This file is a shell script that caches the results of configure
# tests run on this system so they can be shared between configure
@@ -5558,6 +5663,7 @@ do
# Handling of arguments.
"Makefile" ) CONFIG_FILES="$CONFIG_FILES Makefile" ;;
"make.tmpl" ) CONFIG_FILES="$CONFIG_FILES make.tmpl" ;;
"doc/Makefile" ) CONFIG_FILES="$CONFIG_FILES doc/Makefile" ;;
"include/Makefile" ) CONFIG_FILES="$CONFIG_FILES include/Makefile" ;;
"lib/Makefile" ) CONFIG_FILES="$CONFIG_FILES lib/Makefile" ;;
"lib/format1/Makefile" ) CONFIG_FILES="$CONFIG_FILES lib/format1/Makefile" ;;
@@ -5695,11 +5801,15 @@ s,@LD_DEPS@,$LD_DEPS,;t t
s,@LD_FLAGS@,$LD_FLAGS,;t t
s,@SOFLAG@,$SOFLAG,;t t
s,@LVM_VERSION@,$LVM_VERSION,;t t
s,@LVM1_FALLBACK@,$LVM1_FALLBACK,;t t
s,@DEBUG@,$DEBUG,;t t
s,@DEVMAPPER@,$DEVMAPPER,;t t
s,@HAVE_LIBDL@,$HAVE_LIBDL,;t t
s,@HAVE_SELINUX@,$HAVE_SELINUX,;t t
s,@CMDLIB@,$CMDLIB,;t t
s,@LOCALEDIR@,$LOCALEDIR,;t t
s,@CONFDIR@,$CONFDIR,;t t
s,@STATICDIR@,$STATICDIR,;t t
s,@INTL_PACKAGE@,$INTL_PACKAGE,;t t
s,@INTL@,$INTL,;t t
s,@LIBOBJS@,$LIBOBJS,;t t

View File

@@ -86,6 +86,14 @@ AC_ARG_WITH(group,
[ GROUP="$withval" ],
[ GROUP="root" ])
dnl -- LVM1 tool fallback option
AC_ARG_ENABLE(lvm1_fallback, [ --enable-lvm1_fallback Use this to fall back and use LVM1 binaries if
device-mapper is missing from the kernel], LVM1_FALLBACK=$enableval, LVM1_FALLBACK=no)
if test x$LVM1_FALLBACK = xyes; then
CFLAGS="$CFLAGS -DLVM1_FALLBACK"
fi
dnl -- format1 inclusion type
AC_ARG_WITH(lvm1,
[ --with-lvm1=TYPE LVM1 metadata support: internal/shared/none
@@ -195,10 +203,18 @@ fi
dnl Check for shared/static conflicts
if [[ "x$LVM1" = xshared -a "x$STATIC_LINK" = xyes ]];
then AC_MSG_ERROR(
Features cannot be \"shared\" when building statically
Features cannot be 'shared' when building statically
)
exit
fi;
fi
dnl Check for is_selinux_enabled
AC_CHECK_LIB(selinux, is_selinux_enabled, HAVE_SELINUX=yes, HAVE_SELINUX=no)
if test x$HAVE_SELINUX = xyes; then
CFLAGS="$CFLAGS -DHAVE_SELINUX"
LIBS="-lselinux $LIBS"
fi
dnl Check for getopt
AC_CHECK_HEADERS(getopt.h, CFLAGS="$CFLAGS -DHAVE_GETOPTLONG")
@@ -242,6 +258,17 @@ if test x$INTL = xyes; then
[ LOCALEDIR='${prefix}/share/locale' ])
fi
AC_ARG_WITH(confdir,
[ --with-confdir=DIR Configuration files in DIR [/etc]],
[ CONFDIR="$withval" ],
[ CONFDIR='/etc' ])
AC_ARG_WITH(staticdir,
[ --with-staticdir=DIR Static binary in DIR [EXEC_PREFIX/sbin]],
[ STATICDIR="$withval" ],
[ STATICDIR='${exec_prefix}/sbin' ])
if test "-f VERSION"; then
LVM_VERSION="\"`cat VERSION`\""
else
@@ -262,12 +289,16 @@ AC_SUBST(LD_FLAGS)
AC_SUBST(SOFLAG)
AC_SUBST(LIBS)
AC_SUBST(LVM_VERSION)
AC_SUBST(LVM1_FALLBACK)
AC_SUBST(DEBUG)
AC_SUBST(DEVMAPPER)
AC_SUBST(HAVE_LIBDL)
AC_SUBST(HAVE_SELINUX)
AC_SUBST(CMDLIB)
AC_SUBST(MSGFMT)
AC_SUBST(LOCALEDIR)
AC_SUBST(CONFDIR)
AC_SUBST(STATICDIR)
AC_SUBST(INTL_PACKAGE)
AC_SUBST(INTL)
@@ -276,6 +307,7 @@ dnl keep utility scripts running properly
AC_OUTPUT( \
Makefile \
make.tmpl \
doc/Makefile \
include/Makefile \
lib/Makefile \
lib/format1/Makefile \

29
doc/Makefile.in Normal file
View File

@@ -0,0 +1,29 @@
#
# Copyright (C) 2004 Red Hat, Inc. All rights reserved.
#
# This file is part of the LVM2.
#
# This copyrighted material is made available to anyone wishing to use,
# modify, copy, or redistribute it subject to the terms and conditions
# of the GNU General Public License v.2.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software Foundation,
# Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
srcdir = @srcdir@
top_srcdir = @top_srcdir@
VPATH = @srcdir@
CONFSRC=example.conf
CONFDEST=lvm.conf
include ../make.tmpl
install:
@if [ ! -e $(confdir)/$(CONFDEST) ]; then \
echo "Installing $(CONFSRC) as $(confdir)/$(CONFDEST)"; \
@INSTALL@ -D -o $(OWNER) -g $(GROUP) -m 644 $(CONFSRC) \
$(confdir)/$(CONFDEST); \
fi

View File

@@ -175,6 +175,16 @@ global {
# setting this to 0 should suppress the error messages.
activation = 1
# If we can't communicate with device-mapper, should we try running
# the LVM1 tools?
# This option only applies to 2.4 kernels and is provided to help you
# switch between device-mapper kernels and LVM1 kernels.
# The LVM1 tools need to be installed with .lvm1 suffices
# e.g. vgscan.lvm1 and they will stop working after you start using
# the new lvm2 on-disk metadata format.
# The default value is set when the tools are built.
# fallback_to_lvm1 = 0
# The default metadata format that commands should use - "lvm1" or "lvm2".
# The command line override is -M1 or -M2.
# Defaults to "lvm1" if compiled in, else "lvm2".

View File

@@ -34,6 +34,7 @@
../lib/misc/lib.h
../lib/misc/lvm-file.h
../lib/misc/lvm-string.h
../lib/misc/selinux.h
../lib/misc/sharedlib.h
../lib/regex/matcher.h
../lib/report/report.h

View File

@@ -95,6 +95,10 @@ ifeq ("@HAVE_LIBDL@", "yes")
misc/sharedlib.c
endif
ifeq ("@HAVE_SELINUX@", "yes")
SOURCES += misc/selinux.c
endif
LIB_STATIC = liblvm.a
$(SUBDIRS): $(LIB_STATIC)

View File

@@ -19,6 +19,7 @@
#include "memlock.h"
#include "display.h"
#include "fs.h"
#include "lvm-file.h"
#include "lvm-string.h"
#include "pool.h"
#include "toolcontext.h"
@@ -31,6 +32,22 @@
#define _skip(fmt, args...) log_very_verbose("Skipping: " fmt , ## args)
int lvm1_present(struct cmd_context *cmd)
{
char path[PATH_MAX];
if (lvm_snprintf(path, sizeof(path), "%s/lvm/global", cmd->proc_dir)
< 0) {
log_error("LVM1 proc global snprintf failed");
return 0;
}
if (path_exists(path))
return 1;
else
return 0;
}
#ifndef DEVMAPPER_SUPPORT
void set_activation(int act)
{
@@ -523,7 +540,7 @@ int lvs_in_vg_opened(struct volume_group *vg)
list_iterate(lvh, &vg->lvs) {
lv = list_item(lvh, struct lv_list)->lv;
count += (_lv_open_count(lv) == 1);
count += (_lv_open_count(lv) > 0);
}
return count;

View File

@@ -36,6 +36,7 @@ int activation(void);
int driver_version(char *version, size_t size);
int library_version(char *version, size_t size);
int lvm1_present(struct cmd_context *cmd);
int target_present(const char *target_name);

View File

@@ -20,6 +20,10 @@
#include "lvm-file.h"
#include "memlock.h"
#ifdef HAVE_SELINUX
# include "selinux.h"
#endif
#include <sys/stat.h>
#include <fcntl.h>
#include <unistd.h>
@@ -175,6 +179,13 @@ static int _mk_link(const char *dev_dir, const char *vg_name,
return 0;
}
#ifdef HAVE_SELINUX
if (!set_selinux_context(lv_path)) {
log_sys_error("set_selinux_context", lv_path);
return 0;
}
#endif
return 1;
}

View File

@@ -450,6 +450,11 @@ static int _init_hostname(struct cmd_context *cmd)
return 0;
}
if (!(cmd->kernel_vsn = pool_strdup(cmd->libmem, uts.release))) {
log_error("_init_hostname: pool_strdup kernel_vsn failed");
return 0;
}
return 1;
}

View File

@@ -58,6 +58,7 @@ struct cmd_context {
struct list formats; /* Available formats */
const char *hostname;
const char *kernel_vsn;
char *cmd_line;
struct command *command;

View File

@@ -35,6 +35,12 @@
#define DEFAULT_UMASK 0077
#ifdef LVM1_FALLBACK
# define DEFAULT_FALLBACK_TO_LVM1 1
#else
# define DEFAULT_FALLBACK_TO_LVM1 0
#endif
#ifdef LVM1_SUPPORT
# define DEFAULT_FORMAT "lvm1"
#else

View File

@@ -53,6 +53,7 @@ static const device_info_t device_info[] = {
{"ubd", 16}, /* User-mode virtual block device */
{"ataraid", 16}, /* ATA Raid */
{"drbd", 16}, /* Distributed Replicated Block Device */
{"power2", 16}, /* EMC Powerpath */
{NULL, 0}
};

42
lib/misc/selinux.c Normal file
View File

@@ -0,0 +1,42 @@
/*
* Copyright (C) 2002-2004 Sistina Software, Inc. All rights reserved.
* Copyright (C) 2004 Red Hat, Inc. All rights reserved.
*
* This file is part of LVM2.
*
* This copyrighted material is made available to anyone wishing to use,
* modify, copy, or redistribute it subject to the terms and conditions
* of the GNU General Public License v.2.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software Foundation,
* Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
#include "lib.h"
#include "selinux.h"
#include <selinux/selinux.h>
int set_selinux_context(const char *path)
{
security_context_t scontext;
log_very_verbose("Setting SELinux context for %s", path);
if (is_selinux_enabled() <= 0)
return 0;
if (matchpathcon(path, 0, &scontext) < 0) {
log_sys_error("matchpathcon", path);
return 0;
}
if ((lsetfilecon(path, scontext) < 0) && (errno != ENOTSUP)) {
log_sys_error("lsetfilecon", path);
free(scontext);
return 0;
}
free(scontext);
return 1;
}

20
lib/misc/selinux.h Normal file
View File

@@ -0,0 +1,20 @@
/*
* Copyright (C) 2004 Red Hat, Inc. All rights reserved.
*
* This file is part of LVM2.
*
* This copyrighted material is made available to anyone wishing to use,
* modify, copy, or redistribute it subject to the terms and conditions
* of the GNU General Public License v.2.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software Foundation,
* Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
#ifndef _LVM_SELINUX_H
#define _LVM_SELINUX_H
int set_selinux_context(const char * path);
#endif

View File

@@ -215,7 +215,7 @@ static int _set_selinux_context(const char *path)
return 0;
}
if (lsetfilecon(path, scontext) < 0) {
if ((lsetfilecon(path, scontext) < 0) && (errno != ENOTSUP)) {
log_error("%s: lsetfilecon failed: %s", path, strerror(errno));
free(scontext);
return 0;

View File

@@ -36,12 +36,14 @@ SOFLAG += @SOFLAG@
prefix = @prefix@
exec_prefix = @exec_prefix@
bindir = $(DESTDIR)@bindir@
confdir = $(DESTDIR)@CONFDIR@/lvm
includedir = $(DESTDIR)@includedir@
libdir = $(DESTDIR)@libdir@
sbindir = $(DESTDIR)@sbindir@
infodir = $(DESTDIR)@infodir@
mandir = $(DESTDIR)@mandir@
localedir = $(DESTDIR)@LOCALEDIR@
staticdir = $(DESTDIR)@STATICDIR@
# setup misc variables
# define the ownership variables for the binaries and man pages

View File

@@ -134,7 +134,7 @@ install_tools_dynamic: lvm .commands
install_tools_static: lvm.static
$(INSTALL) -D -o $(OWNER) -g $(GROUP) -m 555 $(STRIP) lvm.static \
$(sbindir)/lvm.static
$(staticdir)/lvm.static
install: $(INSTALL_TARGETS)

View File

@@ -1054,7 +1054,7 @@ static char *_list_args(const char *text, int state)
char c;
if (!(c = (the_args +
com->valid_args[match_no++])->short_arg))
continue;
continue;
sprintf(s, "-%c", c);
if (!strncmp(text, s, len))
@@ -1285,6 +1285,42 @@ void lvm2_exit(void *handle)
#endif
/*
* Determine whether we should fall back and exec the equivalent LVM1 tool
*/
static int _lvm1_fallback(struct cmd_context *cmd)
{
char vsn[80];
int dm_present;
if (!find_config_int(cmd->cft->root, "global/fallback_to_lvm1",
DEFAULT_FALLBACK_TO_LVM1) ||
strncmp(cmd->kernel_vsn, "2.4.", 4))
return 0;
log_suppress(1);
dm_present = driver_version(vsn, sizeof(vsn));
log_suppress(0);
if (dm_present || !lvm1_present(cmd))
return 0;
return 1;
}
static void _exec_lvm1_command(struct cmd_context *cmd, int argc, char **argv)
{
char path[PATH_MAX];
if (lvm_snprintf(path, sizeof(path), "%s.lvm1", argv[0]) < 0) {
log_error("Failed to create LVM1 tool pathname");
return;
}
execvp(path, argv);
log_sys_error("execvp", path);
}
int lvm2_main(int argc, char **argv)
{
char *namebase, *base;
@@ -1305,6 +1341,21 @@ int lvm2_main(int argc, char **argv)
_register_commands();
if (_lvm1_fallback(cmd)) {
/* Attempt to run equivalent LVM1 tool instead */
if (!alias) {
argv++;
argc--;
alias = 0;
}
if (!argc) {
log_error("Falling back to LVM1 tools, but no "
"command specified.");
return ECMD_FAILED;
}
_exec_lvm1_command(cmd, argc, argv);
return ECMD_FAILED;
}
#ifdef READLINE_SUPPORT
if (!alias && argc == 1) {
ret = _shell(cmd);