mirror of
git://sourceware.org/git/lvm2.git
synced 2025-11-02 04:23:50 +03:00
Compare commits
38 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
6bb20ee09e | ||
|
|
541356430c | ||
|
|
2f4d91fd69 | ||
|
|
f58c5e6b30 | ||
|
|
0311d0132c | ||
|
|
c946c97402 | ||
|
|
84a6f51318 | ||
|
|
24a1501b0d | ||
|
|
383b6f5fcc | ||
|
|
633dd7ff9b | ||
|
|
580624fad6 | ||
|
|
a8190f7efa | ||
|
|
dd2157534b | ||
|
|
38a90e7669 | ||
|
|
6bfc526dcd | ||
|
|
aadb8a7405 | ||
|
|
27082bf77e | ||
|
|
a2903c80cd | ||
|
|
9a77c5369c | ||
|
|
3c30741a19 | ||
|
|
7028ad4ec0 | ||
|
|
8de750c6aa | ||
|
|
04f98de9ee | ||
|
|
a1a019784b | ||
|
|
4aeeae77bd | ||
|
|
651cfc2b78 | ||
|
|
2ef8af25e2 | ||
|
|
0b13852a5b | ||
|
|
13427578c9 | ||
|
|
d89ca2087e | ||
|
|
8b0ea9fba6 | ||
|
|
9f0b653d5a | ||
|
|
659a339233 | ||
|
|
4c29f177a0 | ||
|
|
d664e63d55 | ||
|
|
2493509dbe | ||
|
|
1c8b27f554 | ||
|
|
68297b7186 |
200
configure
vendored
200
configure
vendored
@@ -26,6 +26,10 @@ ac_help="$ac_help
|
||||
statically. Default is dynamic linking"
|
||||
ac_help="$ac_help
|
||||
--enable-readline Enable readline support"
|
||||
ac_help="$ac_help
|
||||
--enable-debug Enable debugging"
|
||||
ac_help="$ac_help
|
||||
--disable-devmapper Disable device-mapper interaction"
|
||||
|
||||
# Initialize some variables set by options.
|
||||
# The variables have the same names as the options, with
|
||||
@@ -562,7 +566,7 @@ do
|
||||
# Extract the first word of "$ac_prog", so it can be a program name with args.
|
||||
set dummy $ac_prog; ac_word=$2
|
||||
echo $ac_n "checking for $ac_word""... $ac_c" 1>&6
|
||||
echo "configure:566: checking for $ac_word" >&5
|
||||
echo "configure:570: checking for $ac_word" >&5
|
||||
if eval "test \"`echo '$''{'ac_cv_prog_AWK'+set}'`\" = set"; then
|
||||
echo $ac_n "(cached) $ac_c" 1>&6
|
||||
else
|
||||
@@ -594,7 +598,7 @@ done
|
||||
# Extract the first word of "gcc", so it can be a program name with args.
|
||||
set dummy gcc; ac_word=$2
|
||||
echo $ac_n "checking for $ac_word""... $ac_c" 1>&6
|
||||
echo "configure:598: checking for $ac_word" >&5
|
||||
echo "configure:602: checking for $ac_word" >&5
|
||||
if eval "test \"`echo '$''{'ac_cv_prog_CC'+set}'`\" = set"; then
|
||||
echo $ac_n "(cached) $ac_c" 1>&6
|
||||
else
|
||||
@@ -624,7 +628,7 @@ if test -z "$CC"; then
|
||||
# Extract the first word of "cc", so it can be a program name with args.
|
||||
set dummy cc; ac_word=$2
|
||||
echo $ac_n "checking for $ac_word""... $ac_c" 1>&6
|
||||
echo "configure:628: checking for $ac_word" >&5
|
||||
echo "configure:632: checking for $ac_word" >&5
|
||||
if eval "test \"`echo '$''{'ac_cv_prog_CC'+set}'`\" = set"; then
|
||||
echo $ac_n "(cached) $ac_c" 1>&6
|
||||
else
|
||||
@@ -675,7 +679,7 @@ fi
|
||||
# Extract the first word of "cl", so it can be a program name with args.
|
||||
set dummy cl; ac_word=$2
|
||||
echo $ac_n "checking for $ac_word""... $ac_c" 1>&6
|
||||
echo "configure:679: checking for $ac_word" >&5
|
||||
echo "configure:683: checking for $ac_word" >&5
|
||||
if eval "test \"`echo '$''{'ac_cv_prog_CC'+set}'`\" = set"; then
|
||||
echo $ac_n "(cached) $ac_c" 1>&6
|
||||
else
|
||||
@@ -707,7 +711,7 @@ fi
|
||||
fi
|
||||
|
||||
echo $ac_n "checking whether the C compiler ($CC $CFLAGS $LDFLAGS) works""... $ac_c" 1>&6
|
||||
echo "configure:711: checking whether the C compiler ($CC $CFLAGS $LDFLAGS) works" >&5
|
||||
echo "configure:715: checking whether the C compiler ($CC $CFLAGS $LDFLAGS) works" >&5
|
||||
|
||||
ac_ext=c
|
||||
# CFLAGS is not in ac_cpp because -g, -O, etc. are not valid cpp options.
|
||||
@@ -718,12 +722,12 @@ cross_compiling=$ac_cv_prog_cc_cross
|
||||
|
||||
cat > conftest.$ac_ext << EOF
|
||||
|
||||
#line 722 "configure"
|
||||
#line 726 "configure"
|
||||
#include "confdefs.h"
|
||||
|
||||
main(){return(0);}
|
||||
EOF
|
||||
if { (eval echo configure:727: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
|
||||
if { (eval echo configure:731: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
|
||||
ac_cv_prog_cc_works=yes
|
||||
# If we can't run a trivial program, we are probably using a cross compiler.
|
||||
if (./conftest; exit) 2>/dev/null; then
|
||||
@@ -749,12 +753,12 @@ if test $ac_cv_prog_cc_works = no; then
|
||||
{ echo "configure: error: installation or configuration problem: C compiler cannot create executables." 1>&2; exit 1; }
|
||||
fi
|
||||
echo $ac_n "checking whether the C compiler ($CC $CFLAGS $LDFLAGS) is a cross-compiler""... $ac_c" 1>&6
|
||||
echo "configure:753: checking whether the C compiler ($CC $CFLAGS $LDFLAGS) is a cross-compiler" >&5
|
||||
echo "configure:757: checking whether the C compiler ($CC $CFLAGS $LDFLAGS) is a cross-compiler" >&5
|
||||
echo "$ac_t""$ac_cv_prog_cc_cross" 1>&6
|
||||
cross_compiling=$ac_cv_prog_cc_cross
|
||||
|
||||
echo $ac_n "checking whether we are using GNU C""... $ac_c" 1>&6
|
||||
echo "configure:758: checking whether we are using GNU C" >&5
|
||||
echo "configure:762: checking whether we are using GNU C" >&5
|
||||
if eval "test \"`echo '$''{'ac_cv_prog_gcc'+set}'`\" = set"; then
|
||||
echo $ac_n "(cached) $ac_c" 1>&6
|
||||
else
|
||||
@@ -763,7 +767,7 @@ else
|
||||
yes;
|
||||
#endif
|
||||
EOF
|
||||
if { ac_try='${CC-cc} -E conftest.c'; { (eval echo configure:767: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }; } | egrep yes >/dev/null 2>&1; then
|
||||
if { ac_try='${CC-cc} -E conftest.c'; { (eval echo configure:771: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }; } | egrep yes >/dev/null 2>&1; then
|
||||
ac_cv_prog_gcc=yes
|
||||
else
|
||||
ac_cv_prog_gcc=no
|
||||
@@ -782,7 +786,7 @@ ac_test_CFLAGS="${CFLAGS+set}"
|
||||
ac_save_CFLAGS="$CFLAGS"
|
||||
CFLAGS=
|
||||
echo $ac_n "checking whether ${CC-cc} accepts -g""... $ac_c" 1>&6
|
||||
echo "configure:786: checking whether ${CC-cc} accepts -g" >&5
|
||||
echo "configure:790: checking whether ${CC-cc} accepts -g" >&5
|
||||
if eval "test \"`echo '$''{'ac_cv_prog_cc_g'+set}'`\" = set"; then
|
||||
echo $ac_n "(cached) $ac_c" 1>&6
|
||||
else
|
||||
@@ -825,7 +829,7 @@ fi
|
||||
# SVR4 /usr/ucb/install, which tries to use the nonexistent group "staff"
|
||||
# ./install, which can be erroneously created by make from ./install.sh.
|
||||
echo $ac_n "checking for a BSD compatible install""... $ac_c" 1>&6
|
||||
echo "configure:829: checking for a BSD compatible install" >&5
|
||||
echo "configure:833: checking for a BSD compatible install" >&5
|
||||
if test -z "$INSTALL"; then
|
||||
if eval "test \"`echo '$''{'ac_cv_path_install'+set}'`\" = set"; then
|
||||
echo $ac_n "(cached) $ac_c" 1>&6
|
||||
@@ -878,7 +882,7 @@ test -z "$INSTALL_SCRIPT" && INSTALL_SCRIPT='${INSTALL_PROGRAM}'
|
||||
test -z "$INSTALL_DATA" && INSTALL_DATA='${INSTALL} -m 644'
|
||||
|
||||
echo $ac_n "checking whether ln -s works""... $ac_c" 1>&6
|
||||
echo "configure:882: checking whether ln -s works" >&5
|
||||
echo "configure:886: checking whether ln -s works" >&5
|
||||
if eval "test \"`echo '$''{'ac_cv_prog_LN_S'+set}'`\" = set"; then
|
||||
echo $ac_n "(cached) $ac_c" 1>&6
|
||||
else
|
||||
@@ -899,7 +903,7 @@ else
|
||||
fi
|
||||
|
||||
echo $ac_n "checking whether ${MAKE-make} sets \${MAKE}""... $ac_c" 1>&6
|
||||
echo "configure:903: checking whether ${MAKE-make} sets \${MAKE}" >&5
|
||||
echo "configure:907: checking whether ${MAKE-make} sets \${MAKE}" >&5
|
||||
set dummy ${MAKE-make}; ac_make=`echo "$2" | sed 'y%./+-%__p_%'`
|
||||
if eval "test \"`echo '$''{'ac_cv_prog_make_${ac_make}_set'+set}'`\" = set"; then
|
||||
echo $ac_n "(cached) $ac_c" 1>&6
|
||||
@@ -928,7 +932,7 @@ fi
|
||||
# Extract the first word of "ranlib", so it can be a program name with args.
|
||||
set dummy ranlib; ac_word=$2
|
||||
echo $ac_n "checking for $ac_word""... $ac_c" 1>&6
|
||||
echo "configure:932: checking for $ac_word" >&5
|
||||
echo "configure:936: checking for $ac_word" >&5
|
||||
if eval "test \"`echo '$''{'ac_cv_prog_RANLIB'+set}'`\" = set"; then
|
||||
echo $ac_n "(cached) $ac_c" 1>&6
|
||||
else
|
||||
@@ -961,12 +965,12 @@ for ac_hdr in dirent.h sys/ndir.h sys/dir.h ndir.h
|
||||
do
|
||||
ac_safe=`echo "$ac_hdr" | sed 'y%./+-%__p_%'`
|
||||
echo $ac_n "checking for $ac_hdr that defines DIR""... $ac_c" 1>&6
|
||||
echo "configure:965: checking for $ac_hdr that defines DIR" >&5
|
||||
echo "configure:969: checking for $ac_hdr that defines DIR" >&5
|
||||
if eval "test \"`echo '$''{'ac_cv_header_dirent_$ac_safe'+set}'`\" = set"; then
|
||||
echo $ac_n "(cached) $ac_c" 1>&6
|
||||
else
|
||||
cat > conftest.$ac_ext <<EOF
|
||||
#line 970 "configure"
|
||||
#line 974 "configure"
|
||||
#include "confdefs.h"
|
||||
#include <sys/types.h>
|
||||
#include <$ac_hdr>
|
||||
@@ -974,7 +978,7 @@ int main() {
|
||||
DIR *dirp = 0;
|
||||
; return 0; }
|
||||
EOF
|
||||
if { (eval echo configure:978: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
|
||||
if { (eval echo configure:982: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
|
||||
rm -rf conftest*
|
||||
eval "ac_cv_header_dirent_$ac_safe=yes"
|
||||
else
|
||||
@@ -999,7 +1003,7 @@ done
|
||||
# Two versions of opendir et al. are in -ldir and -lx on SCO Xenix.
|
||||
if test $ac_header_dirent = dirent.h; then
|
||||
echo $ac_n "checking for opendir in -ldir""... $ac_c" 1>&6
|
||||
echo "configure:1003: checking for opendir in -ldir" >&5
|
||||
echo "configure:1007: checking for opendir in -ldir" >&5
|
||||
ac_lib_var=`echo dir'_'opendir | sed 'y%./+-%__p_%'`
|
||||
if eval "test \"`echo '$''{'ac_cv_lib_$ac_lib_var'+set}'`\" = set"; then
|
||||
echo $ac_n "(cached) $ac_c" 1>&6
|
||||
@@ -1007,7 +1011,7 @@ else
|
||||
ac_save_LIBS="$LIBS"
|
||||
LIBS="-ldir $LIBS"
|
||||
cat > conftest.$ac_ext <<EOF
|
||||
#line 1011 "configure"
|
||||
#line 1015 "configure"
|
||||
#include "confdefs.h"
|
||||
/* Override any gcc2 internal prototype to avoid an error. */
|
||||
/* We use char because int might match the return type of a gcc2
|
||||
@@ -1018,7 +1022,7 @@ int main() {
|
||||
opendir()
|
||||
; return 0; }
|
||||
EOF
|
||||
if { (eval echo configure:1022: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
|
||||
if { (eval echo configure:1026: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
|
||||
rm -rf conftest*
|
||||
eval "ac_cv_lib_$ac_lib_var=yes"
|
||||
else
|
||||
@@ -1040,7 +1044,7 @@ fi
|
||||
|
||||
else
|
||||
echo $ac_n "checking for opendir in -lx""... $ac_c" 1>&6
|
||||
echo "configure:1044: checking for opendir in -lx" >&5
|
||||
echo "configure:1048: checking for opendir in -lx" >&5
|
||||
ac_lib_var=`echo x'_'opendir | sed 'y%./+-%__p_%'`
|
||||
if eval "test \"`echo '$''{'ac_cv_lib_$ac_lib_var'+set}'`\" = set"; then
|
||||
echo $ac_n "(cached) $ac_c" 1>&6
|
||||
@@ -1048,7 +1052,7 @@ else
|
||||
ac_save_LIBS="$LIBS"
|
||||
LIBS="-lx $LIBS"
|
||||
cat > conftest.$ac_ext <<EOF
|
||||
#line 1052 "configure"
|
||||
#line 1056 "configure"
|
||||
#include "confdefs.h"
|
||||
/* Override any gcc2 internal prototype to avoid an error. */
|
||||
/* We use char because int might match the return type of a gcc2
|
||||
@@ -1059,7 +1063,7 @@ int main() {
|
||||
opendir()
|
||||
; return 0; }
|
||||
EOF
|
||||
if { (eval echo configure:1063: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
|
||||
if { (eval echo configure:1067: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
|
||||
rm -rf conftest*
|
||||
eval "ac_cv_lib_$ac_lib_var=yes"
|
||||
else
|
||||
@@ -1082,7 +1086,7 @@ fi
|
||||
fi
|
||||
|
||||
echo $ac_n "checking how to run the C preprocessor""... $ac_c" 1>&6
|
||||
echo "configure:1086: checking how to run the C preprocessor" >&5
|
||||
echo "configure:1090: checking how to run the C preprocessor" >&5
|
||||
# On Suns, sometimes $CPP names a directory.
|
||||
if test -n "$CPP" && test -d "$CPP"; then
|
||||
CPP=
|
||||
@@ -1097,13 +1101,13 @@ else
|
||||
# On the NeXT, cc -E runs the code through the compiler's parser,
|
||||
# not just through cpp.
|
||||
cat > conftest.$ac_ext <<EOF
|
||||
#line 1101 "configure"
|
||||
#line 1105 "configure"
|
||||
#include "confdefs.h"
|
||||
#include <assert.h>
|
||||
Syntax Error
|
||||
EOF
|
||||
ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out"
|
||||
{ (eval echo configure:1107: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
|
||||
{ (eval echo configure:1111: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
|
||||
ac_err=`grep -v '^ *+' conftest.out | grep -v "^conftest.${ac_ext}\$"`
|
||||
if test -z "$ac_err"; then
|
||||
:
|
||||
@@ -1114,13 +1118,13 @@ else
|
||||
rm -rf conftest*
|
||||
CPP="${CC-cc} -E -traditional-cpp"
|
||||
cat > conftest.$ac_ext <<EOF
|
||||
#line 1118 "configure"
|
||||
#line 1122 "configure"
|
||||
#include "confdefs.h"
|
||||
#include <assert.h>
|
||||
Syntax Error
|
||||
EOF
|
||||
ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out"
|
||||
{ (eval echo configure:1124: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
|
||||
{ (eval echo configure:1128: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
|
||||
ac_err=`grep -v '^ *+' conftest.out | grep -v "^conftest.${ac_ext}\$"`
|
||||
if test -z "$ac_err"; then
|
||||
:
|
||||
@@ -1131,13 +1135,13 @@ else
|
||||
rm -rf conftest*
|
||||
CPP="${CC-cc} -nologo -E"
|
||||
cat > conftest.$ac_ext <<EOF
|
||||
#line 1135 "configure"
|
||||
#line 1139 "configure"
|
||||
#include "confdefs.h"
|
||||
#include <assert.h>
|
||||
Syntax Error
|
||||
EOF
|
||||
ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out"
|
||||
{ (eval echo configure:1141: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
|
||||
{ (eval echo configure:1145: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
|
||||
ac_err=`grep -v '^ *+' conftest.out | grep -v "^conftest.${ac_ext}\$"`
|
||||
if test -z "$ac_err"; then
|
||||
:
|
||||
@@ -1162,12 +1166,12 @@ fi
|
||||
echo "$ac_t""$CPP" 1>&6
|
||||
|
||||
echo $ac_n "checking for ANSI C header files""... $ac_c" 1>&6
|
||||
echo "configure:1166: checking for ANSI C header files" >&5
|
||||
echo "configure:1170: checking for ANSI C header files" >&5
|
||||
if eval "test \"`echo '$''{'ac_cv_header_stdc'+set}'`\" = set"; then
|
||||
echo $ac_n "(cached) $ac_c" 1>&6
|
||||
else
|
||||
cat > conftest.$ac_ext <<EOF
|
||||
#line 1171 "configure"
|
||||
#line 1175 "configure"
|
||||
#include "confdefs.h"
|
||||
#include <stdlib.h>
|
||||
#include <stdarg.h>
|
||||
@@ -1175,7 +1179,7 @@ else
|
||||
#include <float.h>
|
||||
EOF
|
||||
ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out"
|
||||
{ (eval echo configure:1179: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
|
||||
{ (eval echo configure:1183: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
|
||||
ac_err=`grep -v '^ *+' conftest.out | grep -v "^conftest.${ac_ext}\$"`
|
||||
if test -z "$ac_err"; then
|
||||
rm -rf conftest*
|
||||
@@ -1192,7 +1196,7 @@ rm -f conftest*
|
||||
if test $ac_cv_header_stdc = yes; then
|
||||
# SunOS 4.x string.h does not declare mem*, contrary to ANSI.
|
||||
cat > conftest.$ac_ext <<EOF
|
||||
#line 1196 "configure"
|
||||
#line 1200 "configure"
|
||||
#include "confdefs.h"
|
||||
#include <string.h>
|
||||
EOF
|
||||
@@ -1210,7 +1214,7 @@ fi
|
||||
if test $ac_cv_header_stdc = yes; then
|
||||
# ISC 2.0.2 stdlib.h does not declare free, contrary to ANSI.
|
||||
cat > conftest.$ac_ext <<EOF
|
||||
#line 1214 "configure"
|
||||
#line 1218 "configure"
|
||||
#include "confdefs.h"
|
||||
#include <stdlib.h>
|
||||
EOF
|
||||
@@ -1231,7 +1235,7 @@ if test "$cross_compiling" = yes; then
|
||||
:
|
||||
else
|
||||
cat > conftest.$ac_ext <<EOF
|
||||
#line 1235 "configure"
|
||||
#line 1239 "configure"
|
||||
#include "confdefs.h"
|
||||
#include <ctype.h>
|
||||
#define ISLOWER(c) ('a' <= (c) && (c) <= 'z')
|
||||
@@ -1242,7 +1246,7 @@ if (XOR (islower (i), ISLOWER (i)) || toupper (i) != TOUPPER (i)) exit(2);
|
||||
exit (0); }
|
||||
|
||||
EOF
|
||||
if { (eval echo configure:1246: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null
|
||||
if { (eval echo configure:1250: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null
|
||||
then
|
||||
:
|
||||
else
|
||||
@@ -1269,17 +1273,17 @@ for ac_hdr in fcntl.h malloc.h sys/ioctl.h unistd.h
|
||||
do
|
||||
ac_safe=`echo "$ac_hdr" | sed 'y%./+-%__p_%'`
|
||||
echo $ac_n "checking for $ac_hdr""... $ac_c" 1>&6
|
||||
echo "configure:1273: checking for $ac_hdr" >&5
|
||||
echo "configure:1277: checking for $ac_hdr" >&5
|
||||
if eval "test \"`echo '$''{'ac_cv_header_$ac_safe'+set}'`\" = set"; then
|
||||
echo $ac_n "(cached) $ac_c" 1>&6
|
||||
else
|
||||
cat > conftest.$ac_ext <<EOF
|
||||
#line 1278 "configure"
|
||||
#line 1282 "configure"
|
||||
#include "confdefs.h"
|
||||
#include <$ac_hdr>
|
||||
EOF
|
||||
ac_try="$ac_cpp conftest.$ac_ext >/dev/null 2>conftest.out"
|
||||
{ (eval echo configure:1283: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
|
||||
{ (eval echo configure:1287: \"$ac_try\") 1>&5; (eval $ac_try) 2>&5; }
|
||||
ac_err=`grep -v '^ *+' conftest.out | grep -v "^conftest.${ac_ext}\$"`
|
||||
if test -z "$ac_err"; then
|
||||
rm -rf conftest*
|
||||
@@ -1307,12 +1311,12 @@ done
|
||||
|
||||
|
||||
echo $ac_n "checking for working const""... $ac_c" 1>&6
|
||||
echo "configure:1311: checking for working const" >&5
|
||||
echo "configure:1315: checking for working const" >&5
|
||||
if eval "test \"`echo '$''{'ac_cv_c_const'+set}'`\" = set"; then
|
||||
echo $ac_n "(cached) $ac_c" 1>&6
|
||||
else
|
||||
cat > conftest.$ac_ext <<EOF
|
||||
#line 1316 "configure"
|
||||
#line 1320 "configure"
|
||||
#include "confdefs.h"
|
||||
|
||||
int main() {
|
||||
@@ -1361,7 +1365,7 @@ ccp = (char const *const *) p;
|
||||
|
||||
; return 0; }
|
||||
EOF
|
||||
if { (eval echo configure:1365: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
|
||||
if { (eval echo configure:1369: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
|
||||
rm -rf conftest*
|
||||
ac_cv_c_const=yes
|
||||
else
|
||||
@@ -1382,21 +1386,21 @@ EOF
|
||||
fi
|
||||
|
||||
echo $ac_n "checking for inline""... $ac_c" 1>&6
|
||||
echo "configure:1386: checking for inline" >&5
|
||||
echo "configure:1390: checking for inline" >&5
|
||||
if eval "test \"`echo '$''{'ac_cv_c_inline'+set}'`\" = set"; then
|
||||
echo $ac_n "(cached) $ac_c" 1>&6
|
||||
else
|
||||
ac_cv_c_inline=no
|
||||
for ac_kw in inline __inline__ __inline; do
|
||||
cat > conftest.$ac_ext <<EOF
|
||||
#line 1393 "configure"
|
||||
#line 1397 "configure"
|
||||
#include "confdefs.h"
|
||||
|
||||
int main() {
|
||||
} int $ac_kw foo() {
|
||||
; return 0; }
|
||||
EOF
|
||||
if { (eval echo configure:1400: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
|
||||
if { (eval echo configure:1404: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
|
||||
rm -rf conftest*
|
||||
ac_cv_c_inline=$ac_kw; break
|
||||
else
|
||||
@@ -1422,12 +1426,12 @@ EOF
|
||||
esac
|
||||
|
||||
echo $ac_n "checking for off_t""... $ac_c" 1>&6
|
||||
echo "configure:1426: checking for off_t" >&5
|
||||
echo "configure:1430: checking for off_t" >&5
|
||||
if eval "test \"`echo '$''{'ac_cv_type_off_t'+set}'`\" = set"; then
|
||||
echo $ac_n "(cached) $ac_c" 1>&6
|
||||
else
|
||||
cat > conftest.$ac_ext <<EOF
|
||||
#line 1431 "configure"
|
||||
#line 1435 "configure"
|
||||
#include "confdefs.h"
|
||||
#include <sys/types.h>
|
||||
#if STDC_HEADERS
|
||||
@@ -1455,12 +1459,12 @@ EOF
|
||||
fi
|
||||
|
||||
echo $ac_n "checking for pid_t""... $ac_c" 1>&6
|
||||
echo "configure:1459: checking for pid_t" >&5
|
||||
echo "configure:1463: checking for pid_t" >&5
|
||||
if eval "test \"`echo '$''{'ac_cv_type_pid_t'+set}'`\" = set"; then
|
||||
echo $ac_n "(cached) $ac_c" 1>&6
|
||||
else
|
||||
cat > conftest.$ac_ext <<EOF
|
||||
#line 1464 "configure"
|
||||
#line 1468 "configure"
|
||||
#include "confdefs.h"
|
||||
#include <sys/types.h>
|
||||
#if STDC_HEADERS
|
||||
@@ -1488,12 +1492,12 @@ EOF
|
||||
fi
|
||||
|
||||
echo $ac_n "checking for size_t""... $ac_c" 1>&6
|
||||
echo "configure:1492: checking for size_t" >&5
|
||||
echo "configure:1496: checking for size_t" >&5
|
||||
if eval "test \"`echo '$''{'ac_cv_type_size_t'+set}'`\" = set"; then
|
||||
echo $ac_n "(cached) $ac_c" 1>&6
|
||||
else
|
||||
cat > conftest.$ac_ext <<EOF
|
||||
#line 1497 "configure"
|
||||
#line 1501 "configure"
|
||||
#include "confdefs.h"
|
||||
#include <sys/types.h>
|
||||
#if STDC_HEADERS
|
||||
@@ -1521,12 +1525,12 @@ EOF
|
||||
fi
|
||||
|
||||
echo $ac_n "checking for st_rdev in struct stat""... $ac_c" 1>&6
|
||||
echo "configure:1525: checking for st_rdev in struct stat" >&5
|
||||
echo "configure:1529: checking for st_rdev in struct stat" >&5
|
||||
if eval "test \"`echo '$''{'ac_cv_struct_st_rdev'+set}'`\" = set"; then
|
||||
echo $ac_n "(cached) $ac_c" 1>&6
|
||||
else
|
||||
cat > conftest.$ac_ext <<EOF
|
||||
#line 1530 "configure"
|
||||
#line 1534 "configure"
|
||||
#include "confdefs.h"
|
||||
#include <sys/types.h>
|
||||
#include <sys/stat.h>
|
||||
@@ -1534,7 +1538,7 @@ int main() {
|
||||
struct stat s; s.st_rdev;
|
||||
; return 0; }
|
||||
EOF
|
||||
if { (eval echo configure:1538: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
|
||||
if { (eval echo configure:1542: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
|
||||
rm -rf conftest*
|
||||
ac_cv_struct_st_rdev=yes
|
||||
else
|
||||
@@ -1555,12 +1559,12 @@ EOF
|
||||
fi
|
||||
|
||||
echo $ac_n "checking whether time.h and sys/time.h may both be included""... $ac_c" 1>&6
|
||||
echo "configure:1559: checking whether time.h and sys/time.h may both be included" >&5
|
||||
echo "configure:1563: checking whether time.h and sys/time.h may both be included" >&5
|
||||
if eval "test \"`echo '$''{'ac_cv_header_time'+set}'`\" = set"; then
|
||||
echo $ac_n "(cached) $ac_c" 1>&6
|
||||
else
|
||||
cat > conftest.$ac_ext <<EOF
|
||||
#line 1564 "configure"
|
||||
#line 1568 "configure"
|
||||
#include "confdefs.h"
|
||||
#include <sys/types.h>
|
||||
#include <sys/time.h>
|
||||
@@ -1569,7 +1573,7 @@ int main() {
|
||||
struct tm *tp;
|
||||
; return 0; }
|
||||
EOF
|
||||
if { (eval echo configure:1573: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
|
||||
if { (eval echo configure:1577: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
|
||||
rm -rf conftest*
|
||||
ac_cv_header_time=yes
|
||||
else
|
||||
@@ -1630,7 +1634,7 @@ if test "${enable_jobs+set}" = set; then
|
||||
enableval="$enable_jobs"
|
||||
JOBS=-j$enableval
|
||||
else
|
||||
JOBS=
|
||||
JOBS=-j2
|
||||
fi
|
||||
|
||||
|
||||
@@ -1653,19 +1657,39 @@ else
|
||||
fi
|
||||
|
||||
|
||||
# Check whether --enable-debug or --disable-debug was given.
|
||||
if test "${enable_debug+set}" = set; then
|
||||
enableval="$enable_debug"
|
||||
\
|
||||
DEBUG=yes
|
||||
else
|
||||
DEBUG=no
|
||||
fi
|
||||
|
||||
|
||||
# Check whether --enable-devmapper or --disable-devmapper was given.
|
||||
if test "${enable_devmapper+set}" = set; then
|
||||
enableval="$enable_devmapper"
|
||||
\
|
||||
DEVMAPPER=no
|
||||
else
|
||||
DEVMAPPER=yes
|
||||
fi
|
||||
|
||||
|
||||
if [ "x$exec_prefix" = xNONE -a "x$prefix" = xNONE ];
|
||||
then exec_prefix="";
|
||||
fi;
|
||||
|
||||
if test $ac_cv_prog_gcc = yes; then
|
||||
echo $ac_n "checking whether ${CC-cc} needs -traditional""... $ac_c" 1>&6
|
||||
echo "configure:1663: checking whether ${CC-cc} needs -traditional" >&5
|
||||
echo "configure:1687: checking whether ${CC-cc} needs -traditional" >&5
|
||||
if eval "test \"`echo '$''{'ac_cv_prog_gcc_traditional'+set}'`\" = set"; then
|
||||
echo $ac_n "(cached) $ac_c" 1>&6
|
||||
else
|
||||
ac_pattern="Autoconf.*'x'"
|
||||
cat > conftest.$ac_ext <<EOF
|
||||
#line 1669 "configure"
|
||||
#line 1693 "configure"
|
||||
#include "confdefs.h"
|
||||
#include <sgtty.h>
|
||||
Autoconf TIOCGETP
|
||||
@@ -1683,7 +1707,7 @@ rm -f conftest*
|
||||
|
||||
if test $ac_cv_prog_gcc_traditional = no; then
|
||||
cat > conftest.$ac_ext <<EOF
|
||||
#line 1687 "configure"
|
||||
#line 1711 "configure"
|
||||
#include "confdefs.h"
|
||||
#include <termio.h>
|
||||
Autoconf TCGETA
|
||||
@@ -1705,12 +1729,12 @@ echo "$ac_t""$ac_cv_prog_gcc_traditional" 1>&6
|
||||
fi
|
||||
|
||||
echo $ac_n "checking return type of signal handlers""... $ac_c" 1>&6
|
||||
echo "configure:1709: checking return type of signal handlers" >&5
|
||||
echo "configure:1733: checking return type of signal handlers" >&5
|
||||
if eval "test \"`echo '$''{'ac_cv_type_signal'+set}'`\" = set"; then
|
||||
echo $ac_n "(cached) $ac_c" 1>&6
|
||||
else
|
||||
cat > conftest.$ac_ext <<EOF
|
||||
#line 1714 "configure"
|
||||
#line 1738 "configure"
|
||||
#include "confdefs.h"
|
||||
#include <sys/types.h>
|
||||
#include <signal.h>
|
||||
@@ -1727,7 +1751,7 @@ int main() {
|
||||
int i;
|
||||
; return 0; }
|
||||
EOF
|
||||
if { (eval echo configure:1731: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
|
||||
if { (eval echo configure:1755: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
|
||||
rm -rf conftest*
|
||||
ac_cv_type_signal=void
|
||||
else
|
||||
@@ -1746,12 +1770,12 @@ EOF
|
||||
|
||||
|
||||
echo $ac_n "checking for vprintf""... $ac_c" 1>&6
|
||||
echo "configure:1750: checking for vprintf" >&5
|
||||
echo "configure:1774: checking for vprintf" >&5
|
||||
if eval "test \"`echo '$''{'ac_cv_func_vprintf'+set}'`\" = set"; then
|
||||
echo $ac_n "(cached) $ac_c" 1>&6
|
||||
else
|
||||
cat > conftest.$ac_ext <<EOF
|
||||
#line 1755 "configure"
|
||||
#line 1779 "configure"
|
||||
#include "confdefs.h"
|
||||
/* System header to define __stub macros and hopefully few prototypes,
|
||||
which can conflict with char vprintf(); below. */
|
||||
@@ -1774,7 +1798,7 @@ vprintf();
|
||||
|
||||
; return 0; }
|
||||
EOF
|
||||
if { (eval echo configure:1778: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
|
||||
if { (eval echo configure:1802: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
|
||||
rm -rf conftest*
|
||||
eval "ac_cv_func_vprintf=yes"
|
||||
else
|
||||
@@ -1798,12 +1822,12 @@ fi
|
||||
|
||||
if test "$ac_cv_func_vprintf" != yes; then
|
||||
echo $ac_n "checking for _doprnt""... $ac_c" 1>&6
|
||||
echo "configure:1802: checking for _doprnt" >&5
|
||||
echo "configure:1826: checking for _doprnt" >&5
|
||||
if eval "test \"`echo '$''{'ac_cv_func__doprnt'+set}'`\" = set"; then
|
||||
echo $ac_n "(cached) $ac_c" 1>&6
|
||||
else
|
||||
cat > conftest.$ac_ext <<EOF
|
||||
#line 1807 "configure"
|
||||
#line 1831 "configure"
|
||||
#include "confdefs.h"
|
||||
/* System header to define __stub macros and hopefully few prototypes,
|
||||
which can conflict with char _doprnt(); below. */
|
||||
@@ -1826,7 +1850,7 @@ _doprnt();
|
||||
|
||||
; return 0; }
|
||||
EOF
|
||||
if { (eval echo configure:1830: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
|
||||
if { (eval echo configure:1854: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
|
||||
rm -rf conftest*
|
||||
eval "ac_cv_func__doprnt=yes"
|
||||
else
|
||||
@@ -1853,12 +1877,12 @@ fi
|
||||
for ac_func in mkdir rmdir uname
|
||||
do
|
||||
echo $ac_n "checking for $ac_func""... $ac_c" 1>&6
|
||||
echo "configure:1857: checking for $ac_func" >&5
|
||||
echo "configure:1881: checking for $ac_func" >&5
|
||||
if eval "test \"`echo '$''{'ac_cv_func_$ac_func'+set}'`\" = set"; then
|
||||
echo $ac_n "(cached) $ac_c" 1>&6
|
||||
else
|
||||
cat > conftest.$ac_ext <<EOF
|
||||
#line 1862 "configure"
|
||||
#line 1886 "configure"
|
||||
#include "confdefs.h"
|
||||
/* System header to define __stub macros and hopefully few prototypes,
|
||||
which can conflict with char $ac_func(); below. */
|
||||
@@ -1881,7 +1905,7 @@ $ac_func();
|
||||
|
||||
; return 0; }
|
||||
EOF
|
||||
if { (eval echo configure:1885: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
|
||||
if { (eval echo configure:1909: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
|
||||
rm -rf conftest*
|
||||
eval "ac_cv_func_$ac_func=yes"
|
||||
else
|
||||
@@ -1909,14 +1933,14 @@ done
|
||||
if test x$READLINE = xyes; then
|
||||
|
||||
echo $ac_n "checking for library containing tgetent""... $ac_c" 1>&6
|
||||
echo "configure:1913: checking for library containing tgetent" >&5
|
||||
echo "configure:1937: checking for library containing tgetent" >&5
|
||||
if eval "test \"`echo '$''{'ac_cv_search_tgetent'+set}'`\" = set"; then
|
||||
echo $ac_n "(cached) $ac_c" 1>&6
|
||||
else
|
||||
ac_func_search_save_LIBS="$LIBS"
|
||||
ac_cv_search_tgetent="no"
|
||||
cat > conftest.$ac_ext <<EOF
|
||||
#line 1920 "configure"
|
||||
#line 1944 "configure"
|
||||
#include "confdefs.h"
|
||||
/* Override any gcc2 internal prototype to avoid an error. */
|
||||
/* We use char because int might match the return type of a gcc2
|
||||
@@ -1927,7 +1951,7 @@ int main() {
|
||||
tgetent()
|
||||
; return 0; }
|
||||
EOF
|
||||
if { (eval echo configure:1931: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
|
||||
if { (eval echo configure:1955: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
|
||||
rm -rf conftest*
|
||||
ac_cv_search_tgetent="none required"
|
||||
else
|
||||
@@ -1938,7 +1962,7 @@ rm -f conftest*
|
||||
test "$ac_cv_search_tgetent" = "no" && for i in ncurses curses termcap termlib; do
|
||||
LIBS="-l$i $ac_func_search_save_LIBS"
|
||||
cat > conftest.$ac_ext <<EOF
|
||||
#line 1942 "configure"
|
||||
#line 1966 "configure"
|
||||
#include "confdefs.h"
|
||||
/* Override any gcc2 internal prototype to avoid an error. */
|
||||
/* We use char because int might match the return type of a gcc2
|
||||
@@ -1949,7 +1973,7 @@ int main() {
|
||||
tgetent()
|
||||
; return 0; }
|
||||
EOF
|
||||
if { (eval echo configure:1953: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
|
||||
if { (eval echo configure:1977: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
|
||||
rm -rf conftest*
|
||||
ac_cv_search_tgetent="-l$i"
|
||||
break
|
||||
@@ -1983,7 +2007,7 @@ fi
|
||||
|
||||
if test x$READLINE = xyes; then
|
||||
echo $ac_n "checking for readline in -lreadline""... $ac_c" 1>&6
|
||||
echo "configure:1987: checking for readline in -lreadline" >&5
|
||||
echo "configure:2011: checking for readline in -lreadline" >&5
|
||||
ac_lib_var=`echo readline'_'readline | sed 'y%./+-%__p_%'`
|
||||
if eval "test \"`echo '$''{'ac_cv_lib_$ac_lib_var'+set}'`\" = set"; then
|
||||
echo $ac_n "(cached) $ac_c" 1>&6
|
||||
@@ -1991,7 +2015,7 @@ else
|
||||
ac_save_LIBS="$LIBS"
|
||||
LIBS="-lreadline $LIBS"
|
||||
cat > conftest.$ac_ext <<EOF
|
||||
#line 1995 "configure"
|
||||
#line 2019 "configure"
|
||||
#include "confdefs.h"
|
||||
/* Override any gcc2 internal prototype to avoid an error. */
|
||||
/* We use char because int might match the return type of a gcc2
|
||||
@@ -2002,7 +2026,7 @@ int main() {
|
||||
readline()
|
||||
; return 0; }
|
||||
EOF
|
||||
if { (eval echo configure:2006: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
|
||||
if { (eval echo configure:2030: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
|
||||
rm -rf conftest*
|
||||
eval "ac_cv_lib_$ac_lib_var=yes"
|
||||
else
|
||||
@@ -2039,12 +2063,12 @@ package as well (which may be called readline-devel or something similar).
|
||||
fi
|
||||
|
||||
echo $ac_n "checking for rl_completion_matches""... $ac_c" 1>&6
|
||||
echo "configure:2043: checking for rl_completion_matches" >&5
|
||||
echo "configure:2067: checking for rl_completion_matches" >&5
|
||||
if eval "test \"`echo '$''{'ac_cv_func_rl_completion_matches'+set}'`\" = set"; then
|
||||
echo $ac_n "(cached) $ac_c" 1>&6
|
||||
else
|
||||
cat > conftest.$ac_ext <<EOF
|
||||
#line 2048 "configure"
|
||||
#line 2072 "configure"
|
||||
#include "confdefs.h"
|
||||
/* System header to define __stub macros and hopefully few prototypes,
|
||||
which can conflict with char rl_completion_matches(); below. */
|
||||
@@ -2067,7 +2091,7 @@ rl_completion_matches();
|
||||
|
||||
; return 0; }
|
||||
EOF
|
||||
if { (eval echo configure:2071: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
|
||||
if { (eval echo configure:2095: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext}; then
|
||||
rm -rf conftest*
|
||||
eval "ac_cv_func_rl_completion_matches=yes"
|
||||
else
|
||||
@@ -2104,6 +2128,8 @@ fi
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
trap '' 1 2 15
|
||||
cat > confcache <<\EOF
|
||||
# This file is a shell script that caches the results of configure
|
||||
@@ -2280,6 +2306,8 @@ s%@HAVE_RL_COMPLETION_MATCHES@%$HAVE_RL_COMPLETION_MATCHES%g
|
||||
s%@OWNER@%$OWNER%g
|
||||
s%@GROUP@%$GROUP%g
|
||||
s%@LVM_VERSION@%$LVM_VERSION%g
|
||||
s%@DEBUG@%$DEBUG%g
|
||||
s%@DEVMAPPER@%$DEVMAPPER%g
|
||||
|
||||
CEOF
|
||||
EOF
|
||||
|
||||
12
configure.in
12
configure.in
@@ -75,7 +75,7 @@ if [[ "x$LVM1" != xnone -a "x$LVM1" != xinternal -a "x$LVM1" != xshared ]];
|
||||
exit
|
||||
fi;
|
||||
|
||||
AC_ARG_ENABLE(jobs, [ --enable-jobs=NUM Number of jobs to run simultaneously], JOBS=-j$enableval, JOBS=)
|
||||
AC_ARG_ENABLE(jobs, [ --enable-jobs=NUM Number of jobs to run simultaneously], JOBS=-j$enableval, JOBS=-j2)
|
||||
|
||||
dnl Enables staticly linked tools
|
||||
AC_ARG_ENABLE(static_link, [ --enable-static_link Use this to link the tools to the liblvm library
|
||||
@@ -85,6 +85,14 @@ dnl Enable readline
|
||||
AC_ARG_ENABLE(readline, [ --enable-readline Enable readline support], \
|
||||
READLINE=$enableval, READLINE=no)
|
||||
|
||||
dnl Enable Debugging
|
||||
AC_ARG_ENABLE(debug, [ --enable-debug Enable debugging], \
|
||||
DEBUG=yes, DEBUG=no)
|
||||
|
||||
dnl Disable devmapper
|
||||
AC_ARG_ENABLE(devmapper, [ --disable-devmapper Disable device-mapper interaction], \
|
||||
DEVMAPPER=no, DEVMAPPER=yes)
|
||||
|
||||
dnl Mess with default exec_prefix
|
||||
if [[ "x$exec_prefix" = xNONE -a "x$prefix" = xNONE ]];
|
||||
then exec_prefix="";
|
||||
@@ -145,6 +153,8 @@ AC_SUBST(OWNER)
|
||||
AC_SUBST(GROUP)
|
||||
AC_SUBST(LIBS)
|
||||
AC_SUBST(LVM_VERSION)
|
||||
AC_SUBST(DEBUG)
|
||||
AC_SUBST(DEVMAPPER)
|
||||
dnl First and last lines should not contain files to generate in order to
|
||||
dnl keep utility scripts running properly
|
||||
AC_OUTPUT( \
|
||||
|
||||
6
debian/README.Debian
vendored
Normal file
6
debian/README.Debian
vendored
Normal file
@@ -0,0 +1,6 @@
|
||||
LVM2 requires the device-mapper kernel module (dm-mod). This is
|
||||
available as a kernel patch for 2.4 (in kernel-patch-device-mapper), and
|
||||
is distributed with linux 2.5 and above. The LVM1 kernel module (lvm-mod)
|
||||
will not work with lvm2 packages. dm-mod and lvm-mod may both be loaded
|
||||
in the kernel at the same time with no problems. Without dm-mod, this
|
||||
package is pretty useless.
|
||||
13
debian/changelog
vendored
13
debian/changelog
vendored
@@ -1,3 +1,16 @@
|
||||
lvm2 (1.95.11-1) unstable; urgency=low
|
||||
|
||||
* New upstream release. (Closes: #171436)
|
||||
* Removed TODO and INTRO from debian/docs; added WHATS_NEW.
|
||||
* Remove vgcfgrestore.8 undocumented symlink.
|
||||
* Added a README.Debian, mentioning the device-mapper kernel module
|
||||
requirement that lvm2 has. (Closes: #171674, #163020)
|
||||
* Get rid of debian/conffiles (debhelper's smart enough to figure that out).
|
||||
* debian/copyright fix to appease lintian.
|
||||
* Fix typo in tools/commands.h that caused /usr/sbin/; to be created.
|
||||
|
||||
-- Andres Salomon <dilinger@mp3revolution.net> Mon, 9 Dec 2002 02:51:02 -0400
|
||||
|
||||
lvm2 (1.95.10-2) unstable; urgency=low
|
||||
|
||||
* Fix software raid problems by ensuring lvm init script runs after
|
||||
|
||||
2
debian/conffiles
vendored
2
debian/conffiles
vendored
@@ -1,2 +0,0 @@
|
||||
/etc/lvm/lvm.conf
|
||||
/etc/init.d/lvm2
|
||||
2
debian/copyright
vendored
2
debian/copyright
vendored
@@ -3,7 +3,7 @@ Wed, 20 Feb 2002 03:17:25 -0500.
|
||||
|
||||
It was downloaded from http://www.sistina.com/products_lvm.htm
|
||||
|
||||
Upstream Author(s): LVM Development Team
|
||||
Upstream Author: LVM Development Team
|
||||
|
||||
Copyright (c) 2001-2002 LVM Development Team
|
||||
|
||||
|
||||
3
debian/docs
vendored
3
debian/docs
vendored
@@ -1,6 +1,5 @@
|
||||
BUGS
|
||||
INTRO
|
||||
README
|
||||
TODO
|
||||
VERSION
|
||||
WHATS_NEW
|
||||
doc/*
|
||||
|
||||
1
debian/undocumented
vendored
1
debian/undocumented
vendored
@@ -7,7 +7,6 @@ pvdata.8
|
||||
pvmove.8
|
||||
pvresize.8
|
||||
version.8
|
||||
vgcfgrestore.8
|
||||
vgexport.8
|
||||
vgimport.8
|
||||
vgmknodes.8
|
||||
|
||||
@@ -23,8 +23,15 @@ devices {
|
||||
# The filter consists of an array of regular expressions. These
|
||||
# expressions can be delimited by a character of your choice, and
|
||||
# prefixed with either an 'a' (for accept) or 'r' (for reject).
|
||||
# The first expression found to match a device name determines if
|
||||
# the device will be accepted or rejected (ignored). Devices that
|
||||
# don't match any patterns are accepted.
|
||||
|
||||
# Remember to run vgscan after you change this parameter.
|
||||
# If using RAID md devices as physical volumes, you should
|
||||
# set up a filter here to reject the constituent devices.
|
||||
|
||||
# Remember to run vgscan after you change this parameter to ensure
|
||||
# that the cache file gets regenerated (see below).
|
||||
|
||||
# By default we accept every block device:
|
||||
filter = [ "a/.*/" ]
|
||||
@@ -44,11 +51,16 @@ devices {
|
||||
# The results of the filtering are cached on disk to avoid
|
||||
# rescanning dud devices (which can take a very long time). By
|
||||
# default this cache file is hidden in the /etc/lvm directory.
|
||||
# It is safe to delete this file. vgscan regenerates it.
|
||||
# It is safe to delete this file: the tools regenerate it.
|
||||
cache = "/etc/lvm/.cache"
|
||||
|
||||
# You can turn off writing this cache file by setting this to 0.
|
||||
write_cache_state = 1
|
||||
|
||||
# An advanced setting.
|
||||
# List of pairs of additional acceptable block device types found
|
||||
# in /proc/devices with maximum (non-zero) number of partitions.
|
||||
# types = [ "fd", 16 ]
|
||||
}
|
||||
|
||||
# This section that allows you to configure the nature of the
|
||||
|
||||
@@ -12,7 +12,6 @@
|
||||
../lib/device/dev-cache.h
|
||||
../lib/device/device.h
|
||||
../lib/display/display.h
|
||||
../lib/display/display_formats.h
|
||||
../lib/filters/filter-composite.h
|
||||
../lib/filters/filter-persistent.h
|
||||
../lib/filters/filter-regex.h
|
||||
@@ -33,4 +32,5 @@
|
||||
../lib/misc/lvm-string.h
|
||||
../lib/misc/sharedlib.h
|
||||
../lib/regex/matcher.h
|
||||
../lib/report/report.h
|
||||
../lib/uuid/uuid.h
|
||||
|
||||
@@ -14,8 +14,6 @@ endif
|
||||
|
||||
SOURCES=\
|
||||
activate/activate.c \
|
||||
activate/dev_manager.c \
|
||||
activate/fs.c \
|
||||
cache/cache.c \
|
||||
commands/toolcontext.c \
|
||||
config/config.c \
|
||||
@@ -50,12 +48,13 @@ SOURCES=\
|
||||
metadata/snapshot_manip.c \
|
||||
misc/crc.c \
|
||||
misc/lvm-file.c \
|
||||
misc/lvm-string.c \
|
||||
misc/sharedlib.c \
|
||||
mm/dbg_malloc.c \
|
||||
mm/pool.c \
|
||||
regex/matcher.c \
|
||||
regex/parse_rx.c \
|
||||
regex/ttree.c \
|
||||
report/report.c \
|
||||
uuid/uuid.c
|
||||
|
||||
ifeq ("@LVM1@", "internal")
|
||||
@@ -69,6 +68,17 @@ ifeq ("@LVM1@", "internal")
|
||||
format1/vg_number.c
|
||||
endif
|
||||
|
||||
ifeq ("@DEBUG@", "yes")
|
||||
SOURCES+=\
|
||||
mm/dbg_malloc.c
|
||||
endif
|
||||
|
||||
ifeq ("@DEVMAPPER@", "yes")
|
||||
SOURCES+=\
|
||||
activate/dev_manager.c \
|
||||
activate/fs.c
|
||||
endif
|
||||
|
||||
TARGETS=liblvm.a
|
||||
|
||||
include ../make.tmpl
|
||||
|
||||
@@ -20,14 +20,68 @@
|
||||
|
||||
#define _skip(fmt, args...) log_very_verbose("Skipping: " fmt , ## args)
|
||||
|
||||
#ifndef DEVMAPPER_SUPPORT
|
||||
void set_activation(int act)
|
||||
{
|
||||
if (act)
|
||||
log_error("Compiled without libdevmapper support. "
|
||||
"Can't enable activation.");
|
||||
}
|
||||
int activation(void)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
int library_version(char *version, size_t size)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
int driver_version(char *version, size_t size)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
int lv_info(const struct logical_volume *lv, struct lvinfo *info)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
int lv_snapshot_percent(struct logical_volume *lv, float *percent)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
int lvs_in_vg_activated(struct volume_group *vg)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
int lvs_in_vg_opened(struct volume_group *vg)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
int lv_suspend_if_active(struct cmd_context *cmd, const char *lvid_s)
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
int lv_resume_if_active(struct cmd_context *cmd, const char *lvid_s)
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
int lv_deactivate(struct cmd_context *cmd, const char *lvid_s)
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
int lv_activate(struct cmd_context *cmd, const char *lvid_s)
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
|
||||
#else /* DEVMAPPER_SUPPORT */
|
||||
|
||||
static int _activation = 1;
|
||||
|
||||
void set_activation(int activation)
|
||||
void set_activation(int act)
|
||||
{
|
||||
if (activation == _activation)
|
||||
if (act == _activation)
|
||||
return;
|
||||
|
||||
_activation = activation;
|
||||
_activation = act;
|
||||
if (_activation)
|
||||
log_verbose("Activation enabled. Device-mapper kernel "
|
||||
"driver will be used.");
|
||||
@@ -36,7 +90,7 @@ void set_activation(int activation)
|
||||
"interaction will be attempted.");
|
||||
}
|
||||
|
||||
int activation()
|
||||
int activation(void)
|
||||
{
|
||||
return _activation;
|
||||
}
|
||||
@@ -82,10 +136,11 @@ int driver_version(char *version, size_t size)
|
||||
/*
|
||||
* Returns 1 if info structure populated, else 0 on failure.
|
||||
*/
|
||||
int lv_info(struct logical_volume *lv, struct dm_info *info)
|
||||
int lv_info(const struct logical_volume *lv, struct lvinfo *info)
|
||||
{
|
||||
int r;
|
||||
struct dev_manager *dm;
|
||||
struct dm_info dminfo;
|
||||
|
||||
if (!activation())
|
||||
return 0;
|
||||
@@ -95,9 +150,16 @@ int lv_info(struct logical_volume *lv, struct dm_info *info)
|
||||
return 0;
|
||||
}
|
||||
|
||||
if (!(r = dev_manager_info(dm, lv, info)))
|
||||
if (!(r = dev_manager_info(dm, lv, &dminfo)))
|
||||
stack;
|
||||
|
||||
info->exists = dminfo.exists;
|
||||
info->suspended = dminfo.suspended;
|
||||
info->open_count = dminfo.open_count;
|
||||
info->major = dminfo.major;
|
||||
info->minor = dminfo.minor;
|
||||
info->read_only = dminfo.read_only;
|
||||
|
||||
dev_manager_destroy(dm);
|
||||
return r;
|
||||
}
|
||||
@@ -128,7 +190,7 @@ int lv_snapshot_percent(struct logical_volume *lv, float *percent)
|
||||
|
||||
static int _lv_active(struct logical_volume *lv)
|
||||
{
|
||||
struct dm_info info;
|
||||
struct lvinfo info;
|
||||
|
||||
if (!lv_info(lv, &info)) {
|
||||
stack;
|
||||
@@ -140,7 +202,7 @@ static int _lv_active(struct logical_volume *lv)
|
||||
|
||||
static int _lv_open_count(struct logical_volume *lv)
|
||||
{
|
||||
struct dm_info info;
|
||||
struct lvinfo info;
|
||||
|
||||
if (!lv_info(lv, &info)) {
|
||||
stack;
|
||||
@@ -244,7 +306,7 @@ int lvs_in_vg_opened(struct volume_group *vg)
|
||||
int lv_suspend_if_active(struct cmd_context *cmd, const char *lvid_s)
|
||||
{
|
||||
struct logical_volume *lv;
|
||||
struct dm_info info;
|
||||
struct lvinfo info;
|
||||
|
||||
if (!activation())
|
||||
return 1;
|
||||
@@ -274,7 +336,7 @@ int lv_suspend_if_active(struct cmd_context *cmd, const char *lvid_s)
|
||||
int lv_resume_if_active(struct cmd_context *cmd, const char *lvid_s)
|
||||
{
|
||||
struct logical_volume *lv;
|
||||
struct dm_info info;
|
||||
struct lvinfo info;
|
||||
|
||||
if (!activation())
|
||||
return 1;
|
||||
@@ -301,7 +363,7 @@ int lv_resume_if_active(struct cmd_context *cmd, const char *lvid_s)
|
||||
int lv_deactivate(struct cmd_context *cmd, const char *lvid_s)
|
||||
{
|
||||
struct logical_volume *lv;
|
||||
struct dm_info info;
|
||||
struct lvinfo info;
|
||||
|
||||
if (!activation())
|
||||
return 1;
|
||||
@@ -328,7 +390,7 @@ int lv_deactivate(struct cmd_context *cmd, const char *lvid_s)
|
||||
int lv_activate(struct cmd_context *cmd, const char *lvid_s)
|
||||
{
|
||||
struct logical_volume *lv;
|
||||
struct dm_info info;
|
||||
struct lvinfo info;
|
||||
|
||||
if (!activation())
|
||||
return 1;
|
||||
@@ -351,3 +413,5 @@ int lv_activate(struct cmd_context *cmd, const char *lvid_s)
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
@@ -8,10 +8,22 @@
|
||||
#define LVM_ACTIVATE_H
|
||||
|
||||
#include "metadata.h"
|
||||
|
||||
#ifdef DEVMAPPER_SUPPORT
|
||||
#include <libdevmapper.h>
|
||||
#endif
|
||||
|
||||
struct lvinfo {
|
||||
int exists;
|
||||
int suspended;
|
||||
unsigned int open_count;
|
||||
int major;
|
||||
int minor;
|
||||
int read_only;
|
||||
};
|
||||
|
||||
void set_activation(int activation);
|
||||
int activation();
|
||||
int activation(void);
|
||||
|
||||
int driver_version(char *version, size_t size);
|
||||
int library_version(char *version, size_t size);
|
||||
@@ -19,7 +31,7 @@ int library_version(char *version, size_t size);
|
||||
/*
|
||||
* Returns 1 if info structure has been populated, else 0.
|
||||
*/
|
||||
int lv_info(struct logical_volume *lv, struct dm_info *info);
|
||||
int lv_info(const struct logical_volume *lv, struct lvinfo *info);
|
||||
/*
|
||||
* Returns 1 if percent has been set, else 0.
|
||||
*/
|
||||
|
||||
@@ -68,7 +68,7 @@ struct dev_layer {
|
||||
struct dm_info info;
|
||||
|
||||
/* lvid plus layer */
|
||||
char *dlid;
|
||||
const char *dlid;
|
||||
|
||||
struct logical_volume *lv;
|
||||
|
||||
@@ -242,7 +242,7 @@ static char *_find_lv_name(char *vg)
|
||||
static char *_build_dlid(struct pool *mem, const char *lvid, const char *layer)
|
||||
{
|
||||
char *dlid;
|
||||
int len;
|
||||
size_t len;
|
||||
|
||||
if (!layer)
|
||||
layer = "";
|
||||
@@ -392,7 +392,7 @@ static int _status(const char *name, const char *uuid,
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int _rename(struct dev_manager *dm, struct dev_layer *dl, char *newname)
|
||||
static int _rename(struct dev_layer *dl, char *newname)
|
||||
{
|
||||
int r = 1;
|
||||
struct dm_task *dmt;
|
||||
@@ -583,8 +583,8 @@ static int _emit_target(struct dm_task *dmt, struct lv_segment *seg)
|
||||
uint64_t esize = seg->lv->vg->extent_size;
|
||||
uint32_t s, stripes = seg->stripes;
|
||||
int w = 0, tw = 0;
|
||||
char *filler = "/dev/ioerror";
|
||||
char *target;
|
||||
const char *filler = "/dev/ioerror";
|
||||
const char *target = NULL;
|
||||
|
||||
if (stripes == 1) {
|
||||
if (!seg->area[0].pv) {
|
||||
@@ -671,7 +671,7 @@ static int _populate_origin(struct dev_manager *dm,
|
||||
|
||||
log_debug("Adding target: 0 %" PRIu64 " snapshot-origin %s",
|
||||
dl->lv->size, params);
|
||||
if (!dm_task_add_target(dmt, 0, dl->lv->size,
|
||||
if (!dm_task_add_target(dmt, __UINT64_C(0), dl->lv->size,
|
||||
"snapshot-origin", params)) {
|
||||
stack;
|
||||
return 0;
|
||||
@@ -711,7 +711,8 @@ static int _populate_snapshot(struct dev_manager *dm,
|
||||
|
||||
log_debug("Adding target: 0 %" PRIu64 " snapshot %s",
|
||||
s->origin->size, params);
|
||||
if (!dm_task_add_target(dmt, 0, s->origin->size, "snapshot", params)) {
|
||||
if (!dm_task_add_target
|
||||
(dmt, __UINT64_C(0), s->origin->size, "snapshot", params)) {
|
||||
stack;
|
||||
return 0;
|
||||
}
|
||||
@@ -767,7 +768,7 @@ void dev_manager_destroy(struct dev_manager *dm)
|
||||
pool_destroy(dm->mem);
|
||||
}
|
||||
|
||||
int dev_manager_info(struct dev_manager *dm, struct logical_volume *lv,
|
||||
int dev_manager_info(struct dev_manager *dm, const struct logical_volume *lv,
|
||||
struct dm_info *info)
|
||||
{
|
||||
char *name;
|
||||
@@ -843,7 +844,7 @@ int dev_manager_snapshot_percent(struct dev_manager *dm,
|
||||
}
|
||||
|
||||
static struct dev_layer *_create_dev(struct dev_manager *dm, char *name,
|
||||
char *dlid)
|
||||
const char *dlid)
|
||||
{
|
||||
struct dev_layer *dl;
|
||||
char *uuid;
|
||||
@@ -952,7 +953,7 @@ static int _expand_origin_real(struct dev_manager *dm,
|
||||
struct logical_volume *lv)
|
||||
{
|
||||
struct dev_layer *dl;
|
||||
char *real_dlid;
|
||||
const char *real_dlid;
|
||||
|
||||
if (!(dl = _create_layer(dm, "real", lv))) {
|
||||
stack;
|
||||
@@ -1007,7 +1008,7 @@ static int _expand_snapshot(struct dev_manager *dm, struct logical_volume *lv,
|
||||
* cow
|
||||
*/
|
||||
struct dev_layer *dl;
|
||||
char *cow_dlid;
|
||||
const char *cow_dlid;
|
||||
|
||||
if (!(dl = _create_layer(dm, "cow", lv))) {
|
||||
stack;
|
||||
@@ -1164,8 +1165,8 @@ static inline int _suspend_parent(struct dev_layer *parent)
|
||||
* Recurses through the tree, ensuring that devices are created
|
||||
* in correct order.
|
||||
*/
|
||||
int _create_rec(struct dev_manager *dm, struct dev_layer *dl,
|
||||
struct dev_layer *parent)
|
||||
static int _create_rec(struct dev_manager *dm, struct dev_layer *dl,
|
||||
struct dev_layer *parent)
|
||||
{
|
||||
struct list *sh;
|
||||
struct dev_layer *dep;
|
||||
@@ -1210,7 +1211,7 @@ int _create_rec(struct dev_manager *dm, struct dev_layer *dl,
|
||||
suffix);
|
||||
if (strcmp(newname, dl->name)) {
|
||||
if (!_suspend_parent(parent) ||
|
||||
!_suspend(dl) || !_rename(dm, dl, newname)) {
|
||||
!_suspend(dl) || !_rename(dl, newname)) {
|
||||
stack;
|
||||
return 0;
|
||||
}
|
||||
@@ -1290,7 +1291,7 @@ static int _fill_in_remove_list(struct dev_manager *dm)
|
||||
/*
|
||||
* Layers are removed in a top-down manner.
|
||||
*/
|
||||
int _remove_old_layers(struct dev_manager *dm)
|
||||
static int _remove_old_layers(struct dev_manager *dm)
|
||||
{
|
||||
int change;
|
||||
struct list *rh, *n;
|
||||
|
||||
@@ -25,7 +25,7 @@ void dev_manager_destroy(struct dev_manager *dm);
|
||||
* (eg, an origin is created before its snapshot, but is not
|
||||
* unsuspended until the snapshot is also created.)
|
||||
*/
|
||||
int dev_manager_info(struct dev_manager *dm, struct logical_volume *lv,
|
||||
int dev_manager_info(struct dev_manager *dm, const struct logical_volume *lv,
|
||||
struct dm_info *info);
|
||||
int dev_manager_snapshot_percent(struct dev_manager *dm,
|
||||
struct logical_volume *lv, float *percent);
|
||||
|
||||
@@ -14,6 +14,7 @@
|
||||
#include <fcntl.h>
|
||||
#include <unistd.h>
|
||||
#include <limits.h>
|
||||
#include <dirent.h>
|
||||
#include <libdevmapper.h>
|
||||
|
||||
static int _mk_dir(struct volume_group *vg)
|
||||
@@ -58,13 +59,55 @@ static int _rm_dir(struct volume_group *vg)
|
||||
return 1;
|
||||
}
|
||||
|
||||
static void _rm_blks(const char *dir)
|
||||
{
|
||||
const char *name;
|
||||
char path[PATH_MAX];
|
||||
struct dirent *dirent;
|
||||
struct stat buf;
|
||||
DIR *d;
|
||||
|
||||
if (!(d = opendir(dir))) {
|
||||
log_sys_error("opendir", dir);
|
||||
return;
|
||||
}
|
||||
|
||||
while ((dirent = readdir(d))) {
|
||||
name = dirent->d_name;
|
||||
|
||||
if (!strcmp(name, ".") || !strcmp(name, ".."))
|
||||
continue;
|
||||
|
||||
if (lvm_snprintf(path, sizeof(path), "%s/%s", dir, name) == -1) {
|
||||
log_error("Couldn't create path for %s", name);
|
||||
continue;
|
||||
}
|
||||
|
||||
if (!lstat(path, &buf)) {
|
||||
if (!S_ISBLK(buf.st_mode))
|
||||
continue;
|
||||
log_very_verbose("Removing %s", path);
|
||||
if (unlink(path) < 0)
|
||||
log_sys_error("unlink", path);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
static int _mk_link(struct logical_volume *lv, const char *dev)
|
||||
{
|
||||
char lv_path[PATH_MAX], link_path[PATH_MAX];
|
||||
char lv_path[PATH_MAX], link_path[PATH_MAX], lvm1_group_path[PATH_MAX];
|
||||
char vg_path[PATH_MAX];
|
||||
struct stat buf;
|
||||
|
||||
if (lvm_snprintf(lv_path, sizeof(lv_path), "%s%s/%s",
|
||||
lv->vg->cmd->dev_dir, lv->vg->name, lv->name) == -1) {
|
||||
if (lvm_snprintf(vg_path, sizeof(vg_path), "%s%s",
|
||||
lv->vg->cmd->dev_dir, lv->vg->name) == -1) {
|
||||
log_error("Couldn't create path for volume group dir %s",
|
||||
lv->vg->name);
|
||||
return 0;
|
||||
}
|
||||
|
||||
if (lvm_snprintf(lv_path, sizeof(lv_path), "%s/%s", vg_path,
|
||||
lv->name) == -1) {
|
||||
log_error("Couldn't create source pathname for "
|
||||
"logical volume link %s", lv->name);
|
||||
return 0;
|
||||
@@ -77,13 +120,38 @@ static int _mk_link(struct logical_volume *lv, const char *dev)
|
||||
return 0;
|
||||
}
|
||||
|
||||
if (lvm_snprintf(lvm1_group_path, sizeof(lvm1_group_path), "%s/group",
|
||||
vg_path) == -1) {
|
||||
log_error("Couldn't create pathname for LVM1 group file for %s",
|
||||
lv->vg->name);
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* To reach this point, the VG must have been locked.
|
||||
* As locking fails if the VG is active under LVM1, it's
|
||||
* now safe to remove any LVM1 devices we find here
|
||||
* (as well as any existing LVM2 symlink). */
|
||||
if (!lstat(lvm1_group_path, &buf)) {
|
||||
if (!S_ISCHR(buf.st_mode)) {
|
||||
log_error("Non-LVM1 character device found at %s",
|
||||
lvm1_group_path);
|
||||
} else {
|
||||
_rm_blks(vg_path);
|
||||
|
||||
log_very_verbose("Removing %s", lvm1_group_path);
|
||||
if (unlink(lvm1_group_path) < 0)
|
||||
log_sys_error("unlink", lvm1_group_path);
|
||||
}
|
||||
}
|
||||
|
||||
if (!lstat(lv_path, &buf)) {
|
||||
if (!S_ISLNK(buf.st_mode)) {
|
||||
if (!S_ISLNK(buf.st_mode) && !S_ISBLK(buf.st_mode)) {
|
||||
log_error("Symbolic link %s not created: file exists",
|
||||
link_path);
|
||||
return 0;
|
||||
}
|
||||
|
||||
log_very_verbose("Removing %s", lv_path);
|
||||
if (unlink(lv_path) < 0) {
|
||||
log_sys_error("unlink", lv_path);
|
||||
return 0;
|
||||
@@ -110,12 +178,12 @@ static int _rm_link(struct logical_volume *lv, const char *lv_name)
|
||||
return 0;
|
||||
}
|
||||
|
||||
log_very_verbose("Removing link %s", lv_path);
|
||||
if (lstat(lv_path, &buf) || !S_ISLNK(buf.st_mode)) {
|
||||
log_error("%s not symbolic link - not removing", lv_path);
|
||||
return 0;
|
||||
}
|
||||
|
||||
log_very_verbose("Removing link %s", lv_path);
|
||||
if (unlink(lv_path) < 0) {
|
||||
log_sys_error("unlink", lv_path);
|
||||
return 0;
|
||||
|
||||
@@ -19,5 +19,4 @@ int fs_del_lv(struct logical_volume *lv);
|
||||
int fs_rename_lv(struct logical_volume *lv,
|
||||
const char *dev, const char *old_name);
|
||||
|
||||
|
||||
#endif
|
||||
|
||||
50
lib/cache/cache.c
vendored
50
lib/cache/cache.c
vendored
@@ -11,6 +11,9 @@
|
||||
#include "toolcontext.h"
|
||||
#include "dev-cache.h"
|
||||
#include "metadata.h"
|
||||
#include "filter.h"
|
||||
|
||||
#include <linux/kdev_t.h>
|
||||
|
||||
static struct hash_table *_pvid_hash = NULL;
|
||||
static struct hash_table *_vgid_hash = NULL;
|
||||
@@ -18,7 +21,7 @@ static struct hash_table *_vgname_hash = NULL;
|
||||
static struct list _vginfos;
|
||||
int _has_scanned = 0;
|
||||
|
||||
int cache_init()
|
||||
int cache_init(void)
|
||||
{
|
||||
list_init(&_vginfos);
|
||||
|
||||
@@ -47,7 +50,7 @@ struct cache_vginfo *vginfo_from_vgname(const char *vgname)
|
||||
return vginfo;
|
||||
}
|
||||
|
||||
struct format_type *fmt_from_vgname(const char *vgname)
|
||||
const struct format_type *fmt_from_vgname(const char *vgname)
|
||||
{
|
||||
struct cache_vginfo *vginfo;
|
||||
|
||||
@@ -60,11 +63,16 @@ struct format_type *fmt_from_vgname(const char *vgname)
|
||||
struct cache_vginfo *vginfo_from_vgid(const char *vgid)
|
||||
{
|
||||
struct cache_vginfo *vginfo;
|
||||
char id[ID_LEN + 1];
|
||||
|
||||
if (!_vgid_hash || !vgid)
|
||||
return NULL;
|
||||
|
||||
if (!(vginfo = hash_lookup_fixed(_vgid_hash, vgid, ID_LEN)))
|
||||
/* vgid not necessarily NULL-terminated */
|
||||
strncpy(&id[0], vgid, ID_LEN);
|
||||
id[ID_LEN] = '\0';
|
||||
|
||||
if (!(vginfo = hash_lookup(_vgid_hash, id)))
|
||||
return NULL;
|
||||
|
||||
return vginfo;
|
||||
@@ -73,11 +81,15 @@ struct cache_vginfo *vginfo_from_vgid(const char *vgid)
|
||||
struct cache_info *info_from_pvid(const char *pvid)
|
||||
{
|
||||
struct cache_info *info;
|
||||
char id[ID_LEN + 1];
|
||||
|
||||
if (!_pvid_hash || !pvid)
|
||||
return NULL;
|
||||
|
||||
if (!(info = hash_lookup_fixed(_pvid_hash, pvid, ID_LEN)))
|
||||
strncpy(&id[0], pvid, ID_LEN);
|
||||
id[ID_LEN] = '\0';
|
||||
|
||||
if (!(info = hash_lookup(_pvid_hash, id)))
|
||||
return NULL;
|
||||
|
||||
return info;
|
||||
@@ -91,7 +103,7 @@ static void _rescan_entry(struct cache_info *info)
|
||||
label_read(info->dev, &label);
|
||||
}
|
||||
|
||||
static int _scan_invalid(struct cmd_context *cmd)
|
||||
static int _scan_invalid(void)
|
||||
{
|
||||
hash_iter(_pvid_hash, (iterate_fn) _rescan_entry);
|
||||
|
||||
@@ -121,7 +133,7 @@ int cache_label_scan(struct cmd_context *cmd, int full_scan)
|
||||
}
|
||||
|
||||
if (_has_scanned && !full_scan) {
|
||||
r = _scan_invalid(cmd);
|
||||
r = _scan_invalid();
|
||||
goto out;
|
||||
}
|
||||
|
||||
@@ -223,7 +235,7 @@ struct device *device_from_pvid(struct cmd_context *cmd, struct id *pvid)
|
||||
return NULL;
|
||||
}
|
||||
|
||||
void _drop_vginfo(struct cache_info *info)
|
||||
static void _drop_vginfo(struct cache_info *info)
|
||||
{
|
||||
if (!list_empty(&info->list)) {
|
||||
list_del(&info->list);
|
||||
@@ -409,6 +421,26 @@ struct cache_info *cache_add(struct labeller *labeller, const char *pvid,
|
||||
list_init(&info->list);
|
||||
info->dev = dev;
|
||||
} else {
|
||||
if (existing->dev != dev) {
|
||||
/* Is the existing entry a duplicate pvid e.g. md ? */
|
||||
if (MAJOR(existing->dev->dev) == md_major() &&
|
||||
MAJOR(dev->dev) != md_major()) {
|
||||
log_very_verbose("Ignoring duplicate PV %s on "
|
||||
"%s - using md %s",
|
||||
pvid, dev_name(dev),
|
||||
dev_name(existing->dev));
|
||||
return NULL;
|
||||
} else if (MAJOR(existing->dev->dev) != md_major() &&
|
||||
MAJOR(dev->dev) == md_major())
|
||||
log_very_verbose("Duplicate PV %s on %s - "
|
||||
"using md %s", pvid,
|
||||
dev_name(existing->dev),
|
||||
dev_name(dev));
|
||||
else
|
||||
log_error("Found duplicate PV %s: using %s not "
|
||||
"%s", pvid, dev_name(dev),
|
||||
dev_name(existing->dev));
|
||||
}
|
||||
info = existing;
|
||||
/* Has labeller changed? */
|
||||
if (info->label->labeller != labeller) {
|
||||
@@ -423,7 +455,7 @@ struct cache_info *cache_add(struct labeller *labeller, const char *pvid,
|
||||
label = info->label;
|
||||
}
|
||||
|
||||
info->fmt = (struct format_type *) labeller->private;
|
||||
info->fmt = (const struct format_type *) labeller->private;
|
||||
info->status |= CACHE_INVALID;
|
||||
|
||||
if (!_cache_update_pvid(info, pvid_s)) {
|
||||
@@ -467,7 +499,7 @@ static void _cache_destroy_vgnamelist(struct cache_vginfo *vginfo)
|
||||
dbg_free(vginfo);
|
||||
}
|
||||
|
||||
void cache_destroy()
|
||||
void cache_destroy(void)
|
||||
{
|
||||
_has_scanned = 0;
|
||||
|
||||
|
||||
10
lib/cache/cache.h
vendored
10
lib/cache/cache.h
vendored
@@ -28,7 +28,7 @@ struct cache_vginfo {
|
||||
struct list infos; /* List head for cache_infos */
|
||||
char *vgname; /* "" == orphan */
|
||||
char vgid[ID_LEN + 1];
|
||||
struct format_type *fmt;
|
||||
const struct format_type *fmt;
|
||||
};
|
||||
|
||||
struct cache_info {
|
||||
@@ -37,14 +37,14 @@ struct cache_info {
|
||||
struct list das; /* list head for data areas */
|
||||
struct cache_vginfo *vginfo; /* NULL == unknown */
|
||||
struct label *label;
|
||||
struct format_type *fmt;
|
||||
const struct format_type *fmt;
|
||||
struct device *dev;
|
||||
uint64_t device_size; /* Bytes */
|
||||
uint32_t status;
|
||||
};
|
||||
|
||||
int cache_init();
|
||||
void cache_destroy();
|
||||
int cache_init(void);
|
||||
void cache_destroy(void);
|
||||
|
||||
/* Set full_scan to 1 to reread every filtered device label */
|
||||
int cache_label_scan(struct cmd_context *cmd, int full_scan);
|
||||
@@ -60,7 +60,7 @@ int cache_update_vgname(struct cache_info *info, const char *vgname);
|
||||
int cache_update_vg(struct volume_group *vg);
|
||||
|
||||
/* Queries */
|
||||
struct format_type *fmt_from_vgname(const char *vgname);
|
||||
const struct format_type *fmt_from_vgname(const char *vgname);
|
||||
struct cache_vginfo *vginfo_from_vgname(const char *vgname);
|
||||
struct cache_vginfo *vginfo_from_vgid(const char *vgid);
|
||||
struct cache_info *info_from_pvid(const char *pvid);
|
||||
|
||||
@@ -13,4 +13,3 @@
|
||||
#define ECMD_FAILED 5
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
@@ -20,6 +20,7 @@
|
||||
#include "lvm-file.h"
|
||||
#include "format-text.h"
|
||||
#include "sharedlib.h"
|
||||
#include "display.h"
|
||||
|
||||
#ifdef LVM1_INTERNAL
|
||||
#include "format1.h"
|
||||
@@ -52,7 +53,7 @@ static int _get_env_vars(struct cmd_context *cmd)
|
||||
|
||||
static void _init_logging(struct cmd_context *cmd)
|
||||
{
|
||||
char *open_mode = "a";
|
||||
const char *open_mode = "a";
|
||||
time_t t;
|
||||
|
||||
const char *log_file;
|
||||
@@ -112,7 +113,9 @@ static void _init_logging(struct cmd_context *cmd)
|
||||
log_verbose("Logging initialised at %s", ctime(&t));
|
||||
|
||||
/* Tell device-mapper about our logging */
|
||||
#ifdef DEVMAPPER_SUPPORT
|
||||
dm_log_init(print_log);
|
||||
#endif
|
||||
}
|
||||
|
||||
static int _process_config(struct cmd_context *cmd)
|
||||
@@ -136,7 +139,9 @@ static int _process_config(struct cmd_context *cmd)
|
||||
return 0;
|
||||
}
|
||||
|
||||
#ifdef DEVMAPPER_SUPPORT
|
||||
dm_set_dev_dir(cmd->dev_dir);
|
||||
#endif
|
||||
|
||||
/* proc dir */
|
||||
if (lvm_snprintf(cmd->proc_dir, sizeof(cmd->proc_dir), "%s",
|
||||
@@ -153,6 +158,20 @@ static int _process_config(struct cmd_context *cmd)
|
||||
DEFAULT_ACTIVATION);
|
||||
set_activation(cmd->default_settings.activation);
|
||||
|
||||
cmd->default_settings.suffix = find_config_int(cmd->cf->root,
|
||||
"global/suffix",
|
||||
'/', DEFAULT_SUFFIX);
|
||||
|
||||
if (!(cmd->default_settings.unit_factor =
|
||||
units_to_bytes(find_config_str(cmd->cf->root,
|
||||
"global/units",
|
||||
'/',
|
||||
DEFAULT_UNITS),
|
||||
&cmd->default_settings.unit_type))) {
|
||||
log_error("Invalid units specification");
|
||||
return 0;
|
||||
}
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
@@ -239,7 +258,9 @@ static struct dev_filter *_init_filter_components(struct cmd_context *cmd)
|
||||
struct config_node *cn;
|
||||
struct dev_filter *f1, *f2, *f3;
|
||||
|
||||
if (!(f2 = lvm_type_filter_create(cmd->proc_dir)))
|
||||
cn = find_config_node(cmd->cf->root, "devices/types", '/');
|
||||
|
||||
if (!(f2 = lvm_type_filter_create(cmd->proc_dir, cn)))
|
||||
return NULL;
|
||||
|
||||
if (!(cn = find_config_node(cmd->cf->root, "devices/filter", '/'))) {
|
||||
@@ -294,7 +315,9 @@ static int _init_filters(struct cmd_context *cmd)
|
||||
if (!*cmd->sys_dir)
|
||||
cmd->dump_filter = 0;
|
||||
|
||||
if (!stat(lvm_cache, &st) && !persistent_filter_load(f4))
|
||||
if (!stat(lvm_cache, &st) &&
|
||||
(st.st_mtime > config_file_timestamp(cmd->cf)) &&
|
||||
!persistent_filter_load(f4))
|
||||
log_verbose("Failed to load existing device cache from %s",
|
||||
lvm_cache);
|
||||
|
||||
@@ -312,7 +335,7 @@ static int _init_formats(struct cmd_context *cmd)
|
||||
struct config_node *cn;
|
||||
struct config_value *cv;
|
||||
|
||||
struct format_type *(*init_format_fn) (struct cmd_context * cmd);
|
||||
struct format_type *(*init_format_fn) (struct cmd_context *);
|
||||
|
||||
void *lib;
|
||||
|
||||
@@ -435,7 +458,7 @@ struct cmd_context *create_toolcontext(struct arg *the_args)
|
||||
return NULL;
|
||||
}
|
||||
|
||||
void destroy_formats(struct list *formats)
|
||||
static void _destroy_formats(struct list *formats)
|
||||
{
|
||||
struct list *fmtl, *tmp;
|
||||
struct format_type *fmt;
|
||||
@@ -458,7 +481,7 @@ void destroy_toolcontext(struct cmd_context *cmd)
|
||||
|
||||
cache_destroy();
|
||||
label_exit();
|
||||
destroy_formats(&cmd->formats);
|
||||
_destroy_formats(&cmd->formats);
|
||||
cmd->filter->destroy(cmd->filter);
|
||||
pool_destroy(cmd->mem);
|
||||
dev_cache_exit();
|
||||
|
||||
@@ -25,6 +25,9 @@ struct config_info {
|
||||
int test;
|
||||
int syslog;
|
||||
int activation;
|
||||
int suffix;
|
||||
uint64_t unit_factor;
|
||||
char unit_type;
|
||||
const char *msg_prefix;
|
||||
int cmd_name; /* Show command name? */
|
||||
|
||||
@@ -42,7 +45,7 @@ struct cmd_context {
|
||||
/* format handler allocates all objects from here */
|
||||
struct pool *mem;
|
||||
|
||||
struct format_type *fmt; /* Current format to use by default */
|
||||
const struct format_type *fmt; /* Current format to use by default */
|
||||
struct format_type *fmt_backup; /* Format to use for backups */
|
||||
|
||||
struct list formats; /* Available formats */
|
||||
|
||||
@@ -112,12 +112,12 @@ void destroy_config_tree(struct config_tree *cf)
|
||||
}
|
||||
|
||||
int read_config_fd(struct config_tree *cf, int fd, const char *file,
|
||||
off_t offset, uint32_t size, off_t offset2, uint32_t size2,
|
||||
off_t offset, size_t size, off_t offset2, size_t size2,
|
||||
checksum_fn_t checksum_fn, uint32_t checksum)
|
||||
{
|
||||
struct cs *c = (struct cs *) cf;
|
||||
struct parser *p;
|
||||
off_t mmap_offset;
|
||||
off_t mmap_offset = 0;
|
||||
int r = 0;
|
||||
|
||||
if (!(p = pool_alloc(c->mem, sizeof(*p)))) {
|
||||
@@ -223,7 +223,7 @@ int read_config_file(struct config_tree *cf, const char *file)
|
||||
return 0;
|
||||
}
|
||||
|
||||
r = read_config_fd(cf, fd, file, 0, info.st_size, 0, 0,
|
||||
r = read_config_fd(cf, fd, file, 0, (size_t) info.st_size, 0, 0,
|
||||
(checksum_fn_t) NULL, 0);
|
||||
|
||||
close(fd);
|
||||
@@ -234,6 +234,13 @@ int read_config_file(struct config_tree *cf, const char *file)
|
||||
return r;
|
||||
}
|
||||
|
||||
time_t config_file_timestamp(struct config_tree *cf)
|
||||
{
|
||||
struct cs *c = (struct cs *) cf;
|
||||
|
||||
return c->timestamp;
|
||||
}
|
||||
|
||||
/*
|
||||
* Returns 1 if config file reloaded
|
||||
*/
|
||||
@@ -245,6 +252,9 @@ int reload_config_file(struct config_tree **cf)
|
||||
struct stat info;
|
||||
int r, fd;
|
||||
|
||||
if (!c->filename)
|
||||
return 0;
|
||||
|
||||
if (stat(c->filename, &info) == -1) {
|
||||
if (errno == ENOENT)
|
||||
return 1;
|
||||
@@ -280,8 +290,8 @@ int reload_config_file(struct config_tree **cf)
|
||||
return 0;
|
||||
}
|
||||
|
||||
r = read_config_fd(new_cf, fd, c->filename, 0, info.st_size, 0, 0,
|
||||
(checksum_fn_t) NULL, 0);
|
||||
r = read_config_fd(new_cf, fd, c->filename, 0, (size_t) info.st_size,
|
||||
0, 0, (checksum_fn_t) NULL, 0);
|
||||
close(fd);
|
||||
|
||||
if (r) {
|
||||
@@ -665,7 +675,7 @@ static struct config_node *_create_node(struct parser *p)
|
||||
|
||||
static char *_dup_tok(struct parser *p)
|
||||
{
|
||||
int len = p->te - p->tb;
|
||||
size_t len = p->te - p->tb;
|
||||
char *str = pool_alloc(p->mem, len + 1);
|
||||
if (!str) {
|
||||
stack;
|
||||
@@ -680,7 +690,7 @@ static char *_dup_tok(struct parser *p)
|
||||
* utility functions
|
||||
*/
|
||||
struct config_node *find_config_node(struct config_node *cn,
|
||||
const char *path, char sep)
|
||||
const char *path, const int sep)
|
||||
{
|
||||
const char *e;
|
||||
|
||||
@@ -712,7 +722,7 @@ struct config_node *find_config_node(struct config_node *cn,
|
||||
}
|
||||
|
||||
const char *find_config_str(struct config_node *cn,
|
||||
const char *path, char sep, const char *fail)
|
||||
const char *path, const int sep, const char *fail)
|
||||
{
|
||||
struct config_node *n = find_config_node(cn, path, sep);
|
||||
|
||||
@@ -729,7 +739,7 @@ const char *find_config_str(struct config_node *cn,
|
||||
}
|
||||
|
||||
int find_config_int(struct config_node *cn, const char *path,
|
||||
char sep, int fail)
|
||||
const int sep, int fail)
|
||||
{
|
||||
struct config_node *n = find_config_node(cn, path, sep);
|
||||
|
||||
@@ -744,7 +754,7 @@ int find_config_int(struct config_node *cn, const char *path,
|
||||
}
|
||||
|
||||
float find_config_float(struct config_node *cn, const char *path,
|
||||
char sep, float fail)
|
||||
const int sep, float fail)
|
||||
{
|
||||
struct config_node *n = find_config_node(cn, path, sep);
|
||||
|
||||
@@ -787,7 +797,7 @@ static int _str_to_bool(const char *str, int fail)
|
||||
}
|
||||
|
||||
int find_config_bool(struct config_node *cn, const char *path,
|
||||
char sep, int fail)
|
||||
const int sep, int fail)
|
||||
{
|
||||
struct config_node *n = find_config_node(cn, path, sep);
|
||||
struct config_value *v;
|
||||
@@ -809,7 +819,7 @@ int find_config_bool(struct config_node *cn, const char *path,
|
||||
}
|
||||
|
||||
int get_config_uint32(struct config_node *cn, const char *path,
|
||||
char sep, uint32_t *result)
|
||||
const int sep, uint32_t *result)
|
||||
{
|
||||
struct config_node *n;
|
||||
|
||||
@@ -823,7 +833,7 @@ int get_config_uint32(struct config_node *cn, const char *path,
|
||||
}
|
||||
|
||||
int get_config_uint64(struct config_node *cn, const char *path,
|
||||
char sep, uint64_t *result)
|
||||
const int sep, uint64_t *result)
|
||||
{
|
||||
struct config_node *n;
|
||||
|
||||
@@ -838,7 +848,7 @@ int get_config_uint64(struct config_node *cn, const char *path,
|
||||
}
|
||||
|
||||
int get_config_str(struct config_node *cn, const char *path,
|
||||
char sep, char **result)
|
||||
const int sep, char **result)
|
||||
{
|
||||
struct config_node *n;
|
||||
|
||||
|
||||
@@ -43,39 +43,40 @@ void destroy_config_tree(struct config_tree *cf);
|
||||
typedef uint32_t (*checksum_fn_t) (uint32_t initial, void *buf, uint32_t size);
|
||||
|
||||
int read_config_fd(struct config_tree *cf, int fd, const char *file,
|
||||
off_t offset, uint32_t size, off_t offset2, uint32_t size2,
|
||||
off_t offset, size_t size, off_t offset2, size_t size2,
|
||||
checksum_fn_t checksum_fn, uint32_t checksum);
|
||||
|
||||
int read_config_file(struct config_tree *cf, const char *file);
|
||||
int write_config_file(struct config_tree *cf, const char *file);
|
||||
int reload_config_file(struct config_tree **cf);
|
||||
time_t config_file_timestamp(struct config_tree *cf);
|
||||
|
||||
struct config_node *find_config_node(struct config_node *cn,
|
||||
const char *path, char seperator);
|
||||
const char *path, const int separator);
|
||||
|
||||
const char *find_config_str(struct config_node *cn,
|
||||
const char *path, char sep, const char *fail);
|
||||
const char *path, const int sep, const char *fail);
|
||||
|
||||
int find_config_int(struct config_node *cn, const char *path,
|
||||
char sep, int fail);
|
||||
const int sep, int fail);
|
||||
|
||||
float find_config_float(struct config_node *cn, const char *path,
|
||||
char sep, float fail);
|
||||
const int sep, float fail);
|
||||
|
||||
/*
|
||||
* Understands (0, ~0), (y, n), (yes, no), (on,
|
||||
* off), (true, false).
|
||||
*/
|
||||
int find_config_bool(struct config_node *cn, const char *path,
|
||||
char sep, int fail);
|
||||
const int sep, int fail);
|
||||
|
||||
int get_config_uint32(struct config_node *cn, const char *path,
|
||||
char sep, uint32_t *result);
|
||||
const int sep, uint32_t *result);
|
||||
|
||||
int get_config_uint64(struct config_node *cn, const char *path,
|
||||
char sep, uint64_t *result);
|
||||
const int sep, uint64_t *result);
|
||||
|
||||
int get_config_str(struct config_node *cn, const char *path,
|
||||
char sep, char **result);
|
||||
const int sep, char **result);
|
||||
|
||||
#endif
|
||||
|
||||
@@ -31,9 +31,10 @@
|
||||
#define DEFAULT_FORMAT "lvm2"
|
||||
#endif
|
||||
|
||||
#define DEFAULT_STRIPESIZE 64 /* KB */
|
||||
#define DEFAULT_PVMETADATASIZE 255
|
||||
#define DEFAULT_PVMETADATACOPIES 1
|
||||
#define DEFAULT_LABELSECTOR 1
|
||||
#define DEFAULT_LABELSECTOR __UINT64_C(1)
|
||||
|
||||
#define DEFAULT_MSG_PREFIX " "
|
||||
#define DEFAULT_CMD_NAME 0
|
||||
@@ -47,11 +48,37 @@
|
||||
#define DEFAULT_VERBOSE 0
|
||||
#define DEFAULT_LOGLEVEL 0
|
||||
#define DEFAULT_INDENT 1
|
||||
#define DEFAULT_UNITS "h"
|
||||
#define DEFAULT_SUFFIX 1
|
||||
|
||||
#define DEFAULT_ACTIVATION 1
|
||||
#ifdef DEVMAPPER_SUPPORT
|
||||
#define DEFAULT_ACTIVATION 1
|
||||
#else
|
||||
#define DEFAULT_ACTIVATION 0
|
||||
#endif
|
||||
|
||||
#ifdef READLINE_SUPPORT
|
||||
#define DEFAULT_MAX_HISTORY 100
|
||||
#endif
|
||||
|
||||
#define DEFAULT_REP_ALIGNED 1
|
||||
#define DEFAULT_REP_BUFFERED 1
|
||||
#define DEFAULT_REP_HEADINGS 1
|
||||
#define DEFAULT_REP_SEPARATOR " "
|
||||
|
||||
#define DEFAULT_LVS_COLS "lv_name,vg_name,lv_attr,lv_size,origin,snap_percent"
|
||||
#define DEFAULT_VGS_COLS "vg_name,pv_count,lv_count,snap_count,vg_attr,vg_size,vg_free"
|
||||
#define DEFAULT_PVS_COLS "pv_name,vg_name,pv_fmt,pv_attr,pv_size,pv_free"
|
||||
#define DEFAULT_SEGS_COLS "lv_name,vg_name,lv_attr,stripes,segtype,seg_size"
|
||||
|
||||
#define DEFAULT_LVS_COLS_VERB "lv_name,vg_name,seg_count,lv_attr,lv_size,lv_minor,origin,snap_percent,lv_uuid"
|
||||
#define DEFAULT_VGS_COLS_VERB "vg_name,vg_attr,vg_extent_size,pv_count,lv_count,snap_count,vg_size,vg_free,vg_uuid"
|
||||
#define DEFAULT_PVS_COLS_VERB "pv_name,vg_name,pv_fmt,pv_attr,pv_size,pv_free,pv_uuid"
|
||||
#define DEFAULT_SEGS_COLS_VERB "lv_name,vg_name,lv_attr,seg_start,seg_size,stripes,segtype,stripesize,chunksize"
|
||||
|
||||
#define DEFAULT_LVS_SORT "vg_name,lv_name"
|
||||
#define DEFAULT_VGS_SORT "vg_name"
|
||||
#define DEFAULT_PVS_SORT "pv_name"
|
||||
#define DEFAULT_SEGS_SORT "vg_name,lv_name,seg_start"
|
||||
|
||||
#endif /* _LVM_DEFAULTS_H */
|
||||
|
||||
@@ -12,8 +12,8 @@
|
||||
|
||||
bitset_t bitset_create(struct pool *mem, unsigned num_bits)
|
||||
{
|
||||
int n = (num_bits / BITS_PER_INT) + 2;
|
||||
int size = sizeof(int) * n;
|
||||
unsigned n = (num_bits / BITS_PER_INT) + 2;
|
||||
size_t size = sizeof(int) * n;
|
||||
unsigned *bs = pool_zalloc(mem, size);
|
||||
|
||||
if (!bs)
|
||||
|
||||
@@ -15,12 +15,12 @@
|
||||
typedef uint32_t *bitset_t;
|
||||
|
||||
bitset_t bitset_create(struct pool *mem, unsigned num_bits);
|
||||
void bitset_destroy(bitset_t bs);
|
||||
|
||||
void bit_union(bitset_t out, bitset_t in1, bitset_t in2);
|
||||
int bit_get_first(bitset_t bs);
|
||||
int bit_get_next(bitset_t bs, int last_bit);
|
||||
|
||||
|
||||
#define BITS_PER_INT (sizeof(int) * CHAR_BIT)
|
||||
|
||||
#define bit(bs, i) \
|
||||
|
||||
@@ -46,7 +46,7 @@ static uint32_t _shuffle(uint32_t k)
|
||||
#endif
|
||||
}
|
||||
|
||||
struct node **_lookup(struct node **c, uint32_t key, struct node **p)
|
||||
static struct node **_lookup(struct node **c, uint32_t key, struct node **p)
|
||||
{
|
||||
*p = NULL;
|
||||
while (*c) {
|
||||
|
||||
@@ -59,10 +59,10 @@ static struct hash_node *_create_node(const char *str)
|
||||
return n;
|
||||
}
|
||||
|
||||
static unsigned _hash(const char *str, int len)
|
||||
static unsigned _hash(const char *str)
|
||||
{
|
||||
unsigned long int h = 0, g;
|
||||
while (*str && len--) {
|
||||
unsigned long h = 0, g;
|
||||
while (*str) {
|
||||
h <<= 4;
|
||||
h += _nums[(int) *str++];
|
||||
g = h & ((unsigned long) 0xf << 16u);
|
||||
@@ -125,30 +125,18 @@ void hash_destroy(struct hash_table *t)
|
||||
dbg_free(t);
|
||||
}
|
||||
|
||||
static inline struct hash_node **_find_fixed(struct hash_table *t,
|
||||
const char *key, uint32_t len)
|
||||
static inline struct hash_node **_find(struct hash_table *t, const char *key)
|
||||
{
|
||||
unsigned h = _hash(key, len) & (t->num_slots - 1);
|
||||
unsigned h = _hash(key) & (t->num_slots - 1);
|
||||
struct hash_node **c;
|
||||
|
||||
for (c = &t->slots[h]; *c; c = &((*c)->next))
|
||||
if (!strncmp(key, (*c)->key, len))
|
||||
if (!strcmp(key, (*c)->key))
|
||||
break;
|
||||
|
||||
return c;
|
||||
}
|
||||
|
||||
static inline struct hash_node **_find(struct hash_table *t, const char *key)
|
||||
{
|
||||
return _find_fixed(t, key, strlen(key));
|
||||
}
|
||||
|
||||
void *hash_lookup_fixed(struct hash_table *t, const char *key, uint32_t len)
|
||||
{
|
||||
struct hash_node **c = _find_fixed(t, key, len);
|
||||
return *c ? (*c)->data : 0;
|
||||
}
|
||||
|
||||
void *hash_lookup(struct hash_table *t, const char *key)
|
||||
{
|
||||
struct hash_node **c = _find(t, key);
|
||||
@@ -220,7 +208,7 @@ void *hash_get_data(struct hash_table *t, struct hash_node *n)
|
||||
return n->data;
|
||||
}
|
||||
|
||||
static struct hash_node *_next_slot(struct hash_table *t, unsigned int s)
|
||||
static struct hash_node *_next_slot(struct hash_table *t, unsigned s)
|
||||
{
|
||||
struct hash_node *c = NULL;
|
||||
int i;
|
||||
@@ -238,6 +226,6 @@ struct hash_node *hash_get_first(struct hash_table *t)
|
||||
|
||||
struct hash_node *hash_get_next(struct hash_table *t, struct hash_node *n)
|
||||
{
|
||||
unsigned int h = _hash(n->key, strlen(n->key)) & (t->num_slots - 1);
|
||||
unsigned h = _hash(n->key) & (t->num_slots - 1);
|
||||
return n->next ? n->next : _next_slot(t, h + 1);
|
||||
}
|
||||
|
||||
@@ -12,7 +12,7 @@
|
||||
struct hash_table;
|
||||
struct hash_node;
|
||||
|
||||
typedef void (*iterate_fn)(void *data);
|
||||
typedef void (*iterate_fn) (void *data);
|
||||
|
||||
struct hash_table *hash_create(unsigned size_hint);
|
||||
void hash_destroy(struct hash_table *t);
|
||||
@@ -36,4 +36,3 @@ struct hash_node *hash_get_next(struct hash_table *t, struct hash_node *n);
|
||||
v = hash_get_next(h, v))
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
@@ -7,17 +7,17 @@
|
||||
#ifndef _LVM_LIST_H
|
||||
#define _LVM_LIST_H
|
||||
|
||||
#include <assert.h>
|
||||
|
||||
struct list {
|
||||
struct list *n, *p;
|
||||
};
|
||||
|
||||
static inline void list_init(struct list *head) {
|
||||
static inline void list_init(struct list *head)
|
||||
{
|
||||
head->n = head->p = head;
|
||||
}
|
||||
|
||||
static inline void list_add(struct list *head, struct list *elem) {
|
||||
static inline void list_add(struct list *head, struct list *elem)
|
||||
{
|
||||
assert(head->n);
|
||||
|
||||
elem->n = head;
|
||||
@@ -27,7 +27,8 @@ static inline void list_add(struct list *head, struct list *elem) {
|
||||
head->p = elem;
|
||||
}
|
||||
|
||||
static inline void list_add_h(struct list *head, struct list *elem) {
|
||||
static inline void list_add_h(struct list *head, struct list *elem)
|
||||
{
|
||||
assert(head->n);
|
||||
|
||||
elem->n = head->n;
|
||||
@@ -37,27 +38,35 @@ static inline void list_add_h(struct list *head, struct list *elem) {
|
||||
head->n = elem;
|
||||
}
|
||||
|
||||
static inline void list_del(struct list *elem) {
|
||||
static inline void list_del(struct list *elem)
|
||||
{
|
||||
elem->n->p = elem->p;
|
||||
elem->p->n = elem->n;
|
||||
}
|
||||
|
||||
static inline int list_empty(struct list *head) {
|
||||
static inline int list_empty(struct list *head)
|
||||
{
|
||||
return head->n == head;
|
||||
}
|
||||
|
||||
static inline int list_end(struct list *head, struct list *elem)
|
||||
{
|
||||
return elem->n == head;
|
||||
}
|
||||
|
||||
#define list_iterate(v, head) \
|
||||
for (v = (head)->n; v != head; v = v->n)
|
||||
|
||||
#define list_iterate_safe(v, t, head) \
|
||||
for (v = (head)->n, t = v->n; v != head; v = t, t = v->n)
|
||||
|
||||
static inline int list_size(struct list *head) {
|
||||
int s = 0;
|
||||
struct list *v;
|
||||
static inline unsigned int list_size(const struct list *head)
|
||||
{
|
||||
unsigned int s = 0;
|
||||
const struct list *v;
|
||||
|
||||
list_iterate(v, head)
|
||||
s++;
|
||||
s++;
|
||||
|
||||
return s;
|
||||
}
|
||||
|
||||
@@ -12,6 +12,13 @@
|
||||
#include <sys/types.h>
|
||||
#include <inttypes.h>
|
||||
|
||||
/* Define some portable printing types */
|
||||
#if __WORDSIZE == 64
|
||||
#define PRIsize_t "lu"
|
||||
#else
|
||||
#define PRIsize_t "u"
|
||||
#endif
|
||||
|
||||
struct str_list {
|
||||
struct list list;
|
||||
char *str;
|
||||
|
||||
@@ -18,11 +18,6 @@
|
||||
#include <dirent.h>
|
||||
#include <linux/kdev_t.h>
|
||||
|
||||
/*
|
||||
* FIXME: really need to seperate names from the devices since
|
||||
* multiple names can point to the same device.
|
||||
*/
|
||||
|
||||
struct dev_iter {
|
||||
struct btree_iter *current;
|
||||
struct dev_filter *filter;
|
||||
@@ -53,7 +48,7 @@ static struct device *_create_dev(dev_t d)
|
||||
struct device *dev;
|
||||
|
||||
if (!(dev = _alloc(sizeof(*dev)))) {
|
||||
stack;
|
||||
log_error("struct device allocation failed");
|
||||
return NULL;
|
||||
}
|
||||
|
||||
@@ -62,24 +57,110 @@ static struct device *_create_dev(dev_t d)
|
||||
dev->fd = -1;
|
||||
dev->flags = 0;
|
||||
memset(dev->pvid, 0, sizeof(dev->pvid));
|
||||
|
||||
return dev;
|
||||
}
|
||||
|
||||
/* Return 1 if we prefer path1 else return 0 */
|
||||
static int _compare_paths(const char *path0, const char *path1)
|
||||
{
|
||||
int slash0 = 0, slash1 = 0;
|
||||
const char *p;
|
||||
char p0[PATH_MAX], p1[PATH_MAX];
|
||||
char *s0, *s1;
|
||||
struct stat stat0, stat1;
|
||||
|
||||
/* Return the path with fewer slashes */
|
||||
for (p = path0; p++; p = (const char *) strchr(p, '/'))
|
||||
slash0++;
|
||||
|
||||
for (p = path1; p++; p = (const char *) strchr(p, '/'))
|
||||
slash1++;
|
||||
|
||||
if (slash0 < slash1)
|
||||
return 0;
|
||||
if (slash1 < slash0)
|
||||
return 1;
|
||||
|
||||
strncpy(p0, path0, PATH_MAX);
|
||||
strncpy(p1, path1, PATH_MAX);
|
||||
s0 = &p0[0] + 1;
|
||||
s1 = &p1[0] + 1;
|
||||
|
||||
/* We prefer symlinks - they exist for a reason!
|
||||
* So we prefer a shorter path before the first symlink in the name.
|
||||
* FIXME Configuration option to invert this? */
|
||||
while (s0) {
|
||||
s0 = strchr(s0, '/');
|
||||
s1 = strchr(s1, '/');
|
||||
if (s0) {
|
||||
*s0 = '\0';
|
||||
*s1 = '\0';
|
||||
}
|
||||
if (lstat(p0, &stat0)) {
|
||||
log_sys_error("lstat", p0);
|
||||
return 1;
|
||||
}
|
||||
if (lstat(p1, &stat1)) {
|
||||
log_sys_error("lstat", p1);
|
||||
return 0;
|
||||
}
|
||||
if (S_ISLNK(stat0.st_mode) && !S_ISLNK(stat1.st_mode))
|
||||
return 0;
|
||||
if (!S_ISLNK(stat0.st_mode) && S_ISLNK(stat1.st_mode))
|
||||
return 1;
|
||||
if (s0) {
|
||||
*s0++ = '/';
|
||||
*s1++ = '/';
|
||||
}
|
||||
}
|
||||
|
||||
/* ASCII comparison */
|
||||
if (strcmp(path0, path1) < 0)
|
||||
return 0;
|
||||
else
|
||||
return 1;
|
||||
}
|
||||
|
||||
static int _add_alias(struct device *dev, const char *path)
|
||||
{
|
||||
struct str_list *sl = _alloc(sizeof(*sl));
|
||||
struct list *ah;
|
||||
const char *oldpath;
|
||||
int prefer_old = 1;
|
||||
|
||||
if (!sl) {
|
||||
stack;
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* Is name already there? */
|
||||
list_iterate(ah, &dev->aliases) {
|
||||
if (!strcmp(list_item(ah, struct str_list)->str, path)) {
|
||||
stack;
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
|
||||
if (!(sl->str = pool_strdup(_cache.mem, path))) {
|
||||
stack;
|
||||
return 0;
|
||||
}
|
||||
|
||||
list_add(&dev->aliases, &sl->list);
|
||||
if (!list_empty(&dev->aliases)) {
|
||||
oldpath = list_item(dev->aliases.n, struct str_list)->str;
|
||||
prefer_old = _compare_paths(path, oldpath);
|
||||
log_debug("%s: Aliased to %s in device cache%s",
|
||||
path, oldpath, prefer_old ? "" : " (preferred name)");
|
||||
|
||||
} else
|
||||
log_debug("%s: Added to device cache", path);
|
||||
|
||||
if (prefer_old)
|
||||
list_add(&dev->aliases, &sl->list);
|
||||
else
|
||||
list_add_h(&dev->aliases, &sl->list);
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
@@ -92,14 +173,15 @@ static int _insert_dev(const char *path, dev_t d)
|
||||
struct device *dev;
|
||||
|
||||
/* is this device already registered ? */
|
||||
if (!(dev = (struct device *) btree_lookup(_cache.devices, d))) {
|
||||
if (!(dev = (struct device *) btree_lookup(_cache.devices,
|
||||
(uint32_t) d))) {
|
||||
/* create new device */
|
||||
if (!(dev = _create_dev(d))) {
|
||||
stack;
|
||||
return 0;
|
||||
}
|
||||
|
||||
if (!(btree_insert(_cache.devices, d, dev))) {
|
||||
if (!(btree_insert(_cache.devices, (uint32_t) d, dev))) {
|
||||
log_err("Couldn't insert device into binary tree.");
|
||||
_free(dev);
|
||||
return 0;
|
||||
@@ -121,7 +203,7 @@ static int _insert_dev(const char *path, dev_t d)
|
||||
|
||||
static char *_join(const char *dir, const char *name)
|
||||
{
|
||||
int len = strlen(dir) + strlen(name) + 2;
|
||||
size_t len = strlen(dir) + strlen(name) + 2;
|
||||
char *r = dbg_malloc(len);
|
||||
if (r)
|
||||
snprintf(r, len, "%s/%s", dir, name);
|
||||
@@ -273,7 +355,7 @@ int dev_cache_init(void)
|
||||
return 0;
|
||||
}
|
||||
|
||||
void _check_closed(struct device *dev)
|
||||
static void _check_closed(struct device *dev)
|
||||
{
|
||||
if (dev->fd >= 0)
|
||||
log_err("Device '%s' has been left open.", dev_name(dev));
|
||||
@@ -309,8 +391,10 @@ int dev_cache_add_dir(const char *path)
|
||||
return 1;
|
||||
}
|
||||
|
||||
if (!(dl = _alloc(sizeof(*dl) + strlen(path) + 1)))
|
||||
if (!(dl = _alloc(sizeof(*dl) + strlen(path) + 1))) {
|
||||
log_error("dir_list allocation failed");
|
||||
return 0;
|
||||
}
|
||||
|
||||
strcpy(dl->dir, path);
|
||||
list_add(&_cache.dirs, &dl->list);
|
||||
@@ -378,8 +462,10 @@ struct dev_iter *dev_iter_create(struct dev_filter *f)
|
||||
{
|
||||
struct dev_iter *di = dbg_malloc(sizeof(*di));
|
||||
|
||||
if (!di)
|
||||
if (!di) {
|
||||
log_error("dev_iter allocation failed");
|
||||
return NULL;
|
||||
}
|
||||
|
||||
_full_scan();
|
||||
di->current = btree_first(_cache.devices);
|
||||
|
||||
@@ -15,12 +15,11 @@
|
||||
* predicate for devices.
|
||||
*/
|
||||
struct dev_filter {
|
||||
int (*passes_filter)(struct dev_filter *f, struct device *dev);
|
||||
void (*destroy)(struct dev_filter *f);
|
||||
int (*passes_filter) (struct dev_filter * f, struct device * dev);
|
||||
void (*destroy) (struct dev_filter * f);
|
||||
void *private;
|
||||
};
|
||||
|
||||
|
||||
/*
|
||||
* The global device cache.
|
||||
*/
|
||||
@@ -34,7 +33,6 @@ int dev_cache_has_scanned(void);
|
||||
int dev_cache_add_dir(const char *path);
|
||||
struct device *dev_cache_get(const char *name, struct dev_filter *f);
|
||||
|
||||
|
||||
/*
|
||||
* Object for iterating through the cache.
|
||||
*/
|
||||
|
||||
@@ -9,12 +9,18 @@
|
||||
#include "lvm-types.h"
|
||||
#include "metadata.h"
|
||||
|
||||
#include <limits.h>
|
||||
#include <sys/stat.h>
|
||||
#include <fcntl.h>
|
||||
#include <unistd.h>
|
||||
#include <linux/unistd.h>
|
||||
#include <sys/ioctl.h>
|
||||
#include <linux/fs.h> // UGH!!! for BLKSSZGET
|
||||
|
||||
/* FIXME 64 bit offset!!!
|
||||
_syscall5(int, _llseek, uint, fd, ulong, hi, ulong, lo, loff_t *, res, uint, wh);
|
||||
*/
|
||||
|
||||
int dev_get_size(struct device *dev, uint64_t *size)
|
||||
{
|
||||
int fd;
|
||||
@@ -123,15 +129,14 @@ int dev_close(struct device *dev)
|
||||
return 1;
|
||||
}
|
||||
|
||||
/*
|
||||
* FIXME: factor common code out.
|
||||
*/
|
||||
int raw_read(int fd, void *buf, size_t count)
|
||||
ssize_t raw_read(int fd, void *buf, size_t count)
|
||||
{
|
||||
size_t n = 0;
|
||||
int tot = 0;
|
||||
ssize_t n = 0, tot = 0;
|
||||
|
||||
while (tot < count) {
|
||||
if (count > SSIZE_MAX)
|
||||
return -1;
|
||||
|
||||
while (tot < (signed) count) {
|
||||
do
|
||||
n = read(fd, buf, count - tot);
|
||||
while ((n < 0) && ((errno == EINTR) || (errno == EAGAIN)));
|
||||
@@ -146,18 +151,19 @@ int raw_read(int fd, void *buf, size_t count)
|
||||
return tot;
|
||||
}
|
||||
|
||||
int64_t dev_read(struct device * dev, uint64_t offset,
|
||||
int64_t len, void *buffer)
|
||||
ssize_t dev_read(struct device *dev, uint64_t offset, size_t len, void *buffer)
|
||||
{
|
||||
const char *name = dev_name(dev);
|
||||
int fd = dev->fd;
|
||||
/* loff_t pos; */
|
||||
|
||||
if (fd < 0) {
|
||||
log_err("Attempt to read an unopened device (%s).", name);
|
||||
return 0;
|
||||
}
|
||||
|
||||
if (lseek(fd, offset, SEEK_SET) < 0) {
|
||||
/* if (_llseek((unsigned) fd, (ulong) (offset >> 32), (ulong) (offset & 0xFFFFFFFF), &pos, SEEK_SET) < 0) { */
|
||||
if (lseek(fd, (off_t) offset, SEEK_SET) < 0) {
|
||||
log_sys_error("lseek", name);
|
||||
return 0;
|
||||
}
|
||||
@@ -165,7 +171,7 @@ int64_t dev_read(struct device * dev, uint64_t offset,
|
||||
return raw_read(fd, buffer, len);
|
||||
}
|
||||
|
||||
int _write(int fd, const void *buf, size_t count)
|
||||
static int _write(int fd, const void *buf, size_t count)
|
||||
{
|
||||
ssize_t n = 0;
|
||||
int tot = 0;
|
||||
@@ -189,8 +195,8 @@ int _write(int fd, const void *buf, size_t count)
|
||||
return tot;
|
||||
}
|
||||
|
||||
int64_t dev_write(struct device * dev, uint64_t offset,
|
||||
int64_t len, void *buffer)
|
||||
int64_t dev_write(struct device * dev, uint64_t offset, size_t len,
|
||||
void *buffer)
|
||||
{
|
||||
const char *name = dev_name(dev);
|
||||
int fd = dev->fd;
|
||||
@@ -200,7 +206,7 @@ int64_t dev_write(struct device * dev, uint64_t offset,
|
||||
return 0;
|
||||
}
|
||||
|
||||
if (lseek(fd, offset, SEEK_SET) < 0) {
|
||||
if (lseek(fd, (off_t) offset, SEEK_SET) < 0) {
|
||||
log_sys_error("lseek", name);
|
||||
return 0;
|
||||
}
|
||||
@@ -210,9 +216,10 @@ int64_t dev_write(struct device * dev, uint64_t offset,
|
||||
return _write(fd, buffer, len);
|
||||
}
|
||||
|
||||
int dev_zero(struct device *dev, uint64_t offset, int64_t len)
|
||||
int dev_zero(struct device *dev, uint64_t offset, size_t len)
|
||||
{
|
||||
int64_t r, s;
|
||||
int64_t r;
|
||||
size_t s;
|
||||
char buffer[4096];
|
||||
int already_open;
|
||||
|
||||
@@ -223,7 +230,7 @@ int dev_zero(struct device *dev, uint64_t offset, int64_t len)
|
||||
return 0;
|
||||
}
|
||||
|
||||
if (lseek(dev->fd, offset, SEEK_SET) < 0) {
|
||||
if (lseek(dev->fd, (off_t) offset, SEEK_SET) < 0) {
|
||||
log_sys_error("lseek", dev_name(dev));
|
||||
if (!already_open && !dev_close(dev))
|
||||
stack;
|
||||
@@ -231,10 +238,10 @@ int dev_zero(struct device *dev, uint64_t offset, int64_t len)
|
||||
}
|
||||
|
||||
if ((offset % SECTOR_SIZE) || (len % SECTOR_SIZE))
|
||||
log_debug("Wiping %s at %" PRIu64 " length %" PRId64,
|
||||
log_debug("Wiping %s at %" PRIu64 " length %" PRIsize_t,
|
||||
dev_name(dev), offset, len);
|
||||
else
|
||||
log_debug("Wiping %s at sector %" PRIu64 " length %" PRId64
|
||||
log_debug("Wiping %s at sector %" PRIu64 " length %" PRIsize_t
|
||||
" sectors", dev_name(dev), offset >> SECTOR_SHIFT,
|
||||
len >> SECTOR_SHIFT);
|
||||
|
||||
|
||||
@@ -53,15 +53,14 @@ static inline int dev_fd(struct device *dev)
|
||||
return dev->fd;
|
||||
}
|
||||
|
||||
int raw_read(int fd, void *buf, size_t count);
|
||||
ssize_t raw_read(int fd, void *buf, size_t count);
|
||||
|
||||
int64_t dev_read(struct device *dev,
|
||||
uint64_t offset, int64_t len, void *buffer);
|
||||
int64_t dev_write(struct device *dev,
|
||||
uint64_t offset, int64_t len, void *buffer);
|
||||
int dev_zero(struct device *dev, uint64_t offset, int64_t len);
|
||||
ssize_t dev_read(struct device *dev, uint64_t offset, size_t len, void *buffer);
|
||||
int64_t dev_write(struct device *dev, uint64_t offset, size_t len,
|
||||
void *buffer);
|
||||
int dev_zero(struct device *dev, uint64_t offset, size_t len);
|
||||
|
||||
static inline const char *dev_name(struct device *dev)
|
||||
static inline const char *dev_name(const struct device *dev)
|
||||
{
|
||||
return (dev) ? list_item(dev->aliases.n, struct str_list)->str :
|
||||
"unknown device";
|
||||
@@ -70,14 +69,20 @@ static inline const char *dev_name(struct device *dev)
|
||||
/* Return a valid device name from the alias list; NULL otherwise */
|
||||
const char *dev_name_confirmed(struct device *dev);
|
||||
|
||||
static inline int is_lvm_partition(const char *name)
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
|
||||
static inline int dev_is_open(struct device *dev)
|
||||
{
|
||||
return dev->fd >= 0 ? 1 : 0;
|
||||
}
|
||||
|
||||
/* FIXME Check partition type if appropriate */
|
||||
|
||||
#define is_lvm_partition(a) 1
|
||||
|
||||
/*
|
||||
static inline int is_lvm_partition(const char *name)
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
*/
|
||||
|
||||
#endif
|
||||
|
||||
@@ -49,6 +49,73 @@ static struct {
|
||||
static int _num_policies = sizeof(_policies) / sizeof(*_policies);
|
||||
static int _num_segtypes = sizeof(_segtypes) / sizeof(*_segtypes);
|
||||
|
||||
uint64_t units_to_bytes(const char *units, char *unit_type)
|
||||
{
|
||||
char *ptr = NULL;
|
||||
uint64_t v;
|
||||
|
||||
if (isdigit(*units)) {
|
||||
v = (uint64_t) strtod(units, &ptr);
|
||||
if (ptr == units)
|
||||
return 0;
|
||||
units = ptr;
|
||||
} else
|
||||
v = 1;
|
||||
|
||||
if (v == 1)
|
||||
*unit_type = *units;
|
||||
else
|
||||
*unit_type = 'U';
|
||||
|
||||
switch (*units) {
|
||||
case 'h':
|
||||
case 'H':
|
||||
v = __UINT64_C(1);
|
||||
*unit_type = *units;
|
||||
break;
|
||||
case 's':
|
||||
v *= SECTOR_SIZE;
|
||||
case 'b':
|
||||
case 'B':
|
||||
v *= __UINT64_C(1);
|
||||
break;
|
||||
#define KILO __UINT64_C(1024)
|
||||
case 'k':
|
||||
v *= KILO;
|
||||
case 'm':
|
||||
v *= KILO * KILO;
|
||||
break;
|
||||
case 'g':
|
||||
v *= KILO * KILO * KILO;
|
||||
break;
|
||||
case 't':
|
||||
v *= KILO * KILO * KILO * KILO;
|
||||
break;
|
||||
#undef KILO
|
||||
#define KILO __UINT64_C(1000)
|
||||
case 'K':
|
||||
v *= KILO;
|
||||
break;
|
||||
case 'M':
|
||||
v *= KILO * KILO;
|
||||
break;
|
||||
case 'G':
|
||||
v *= KILO * KILO * KILO;
|
||||
break;
|
||||
case 'T':
|
||||
v *= KILO * KILO * KILO * KILO;
|
||||
break;
|
||||
#undef KILO
|
||||
default:
|
||||
return 0;
|
||||
}
|
||||
|
||||
if (*(units + 1))
|
||||
return 0;
|
||||
|
||||
return v;
|
||||
}
|
||||
|
||||
const char *get_alloc_string(alloc_policy_t alloc)
|
||||
{
|
||||
int i;
|
||||
@@ -68,7 +135,7 @@ const char *get_segtype_string(segment_type_t segtype)
|
||||
if (_segtypes[i].segtype == segtype)
|
||||
return _segtypes[i].str;
|
||||
|
||||
return NULL;
|
||||
return "unknown";
|
||||
}
|
||||
|
||||
alloc_policy_t get_alloc_from_string(const char *str)
|
||||
@@ -95,35 +162,60 @@ segment_type_t get_segtype_from_string(const char *str)
|
||||
return SEG_STRIPED;
|
||||
}
|
||||
|
||||
char *display_size(uint64_t size, size_len_t sl)
|
||||
const char *display_size(struct cmd_context *cmd, uint64_t size, size_len_t sl)
|
||||
{
|
||||
int s;
|
||||
ulong byte = 1024 * 1024 * 1024;
|
||||
int suffix = 1;
|
||||
uint64_t byte;
|
||||
uint64_t units = __UINT64_C(1024);
|
||||
char *size_buf = NULL;
|
||||
char *size_str[][2] = {
|
||||
{"Terabyte", "TB"},
|
||||
{"Gigabyte", "GB"},
|
||||
{"Megabyte", "MB"},
|
||||
{"Kilobyte", "KB"},
|
||||
{"", ""}
|
||||
const char *size_str[][3] = {
|
||||
{" Terabyte", " TB", "T"},
|
||||
{" Gigabyte", " GB", "G"},
|
||||
{" Megabyte", " MB", "M"},
|
||||
{" Kilobyte", " KB", "K"},
|
||||
{"", "", ""},
|
||||
{" Byte ", " B ", "B"},
|
||||
{" Units ", " Un", "U"},
|
||||
{" Sectors ", " Se", "S"},
|
||||
{" ", " ", " "},
|
||||
};
|
||||
|
||||
if (!(size_buf = dbg_malloc(SIZE_BUF))) {
|
||||
if (!(size_buf = pool_alloc(cmd->mem, SIZE_BUF))) {
|
||||
log_error("no memory for size display buffer");
|
||||
return NULL;
|
||||
return "";
|
||||
}
|
||||
|
||||
if (size == 0LL)
|
||||
sprintf(size_buf, "0");
|
||||
else {
|
||||
suffix = cmd->current_settings.suffix;
|
||||
|
||||
for (s = 0; s < 8; s++)
|
||||
if (toupper((int) cmd->current_settings.unit_type) ==
|
||||
*size_str[s][2])
|
||||
break;
|
||||
|
||||
if (size == __UINT64_C(0)) {
|
||||
sprintf(size_buf, "0%s", suffix ? size_str[s][sl] : "");
|
||||
return size_buf;
|
||||
}
|
||||
|
||||
if (s < 8) {
|
||||
byte = cmd->current_settings.unit_factor;
|
||||
size *= __UINT64_C(1024);
|
||||
} else {
|
||||
suffix = 1;
|
||||
if (cmd->current_settings.unit_type == 'H')
|
||||
units = __UINT64_C(1000);
|
||||
else
|
||||
units = __UINT64_C(1024);
|
||||
byte = units * units * units;
|
||||
s = 0;
|
||||
while (size_str[s] && size < byte)
|
||||
s++, byte /= 1024;
|
||||
snprintf(size_buf, SIZE_BUF - 1,
|
||||
"%.2f %s", (float) size / byte, size_str[s][sl]);
|
||||
s++, byte /= units;
|
||||
}
|
||||
|
||||
/* Caller to deallocate */
|
||||
snprintf(size_buf, SIZE_BUF - 1, "%.2f%s", (float) size / byte,
|
||||
suffix ? size_str[s][sl] : "");
|
||||
|
||||
return size_buf;
|
||||
}
|
||||
|
||||
@@ -139,7 +231,7 @@ void pvdisplay_colons(struct physical_volume *pv)
|
||||
return;
|
||||
}
|
||||
|
||||
log_print("%s:%s:%" PRIu64 ":-1:%u:%u:-1:%" PRIu64 ":%u:%u:%u:%s",
|
||||
log_print("%s:%s:%" PRIu64 ":-1:%u:%u:-1:%" PRIu32 ":%u:%u:%u:%s",
|
||||
dev_name(pv->dev), pv->vg_name, pv->size,
|
||||
/* FIXME pv->pv_number, Derive or remove? */
|
||||
pv->status, /* FIXME Support old or new format here? */
|
||||
@@ -154,12 +246,13 @@ void pvdisplay_colons(struct physical_volume *pv)
|
||||
}
|
||||
|
||||
/* FIXME Include label fields */
|
||||
void pvdisplay_full(struct physical_volume *pv, void *handle)
|
||||
void pvdisplay_full(struct cmd_context *cmd, struct physical_volume *pv,
|
||||
void *handle)
|
||||
{
|
||||
char uuid[64];
|
||||
char *size, *size1; /*, *size2; */
|
||||
const char *size;
|
||||
|
||||
uint64_t pe_free;
|
||||
uint32_t pe_free;
|
||||
|
||||
if (!pv)
|
||||
return;
|
||||
@@ -174,23 +267,21 @@ void pvdisplay_full(struct physical_volume *pv, void *handle)
|
||||
log_print("VG Name %s%s", pv->vg_name,
|
||||
pv->status & EXPORTED_VG ? " (exported)" : "");
|
||||
|
||||
size = display_size((uint64_t) pv->size / 2, SIZE_SHORT);
|
||||
size = display_size(cmd, (uint64_t) pv->size / 2, SIZE_SHORT);
|
||||
if (pv->pe_size && pv->pe_count) {
|
||||
size1 = display_size((pv->size - pv->pe_count * pv->pe_size)
|
||||
/ 2, SIZE_SHORT);
|
||||
|
||||
/******** FIXME display LVM on-disk data size
|
||||
size2 = display_size(pv->size / 2, SIZE_SHORT);
|
||||
********/
|
||||
|
||||
log_print("PV Size %s" " / not usable %s", /* [LVM: %s]", */
|
||||
size, size1); /* , size2); */
|
||||
size, display_size(cmd,
|
||||
(pv->size -
|
||||
pv->pe_count * pv->pe_size) / 2,
|
||||
SIZE_SHORT));
|
||||
|
||||
dbg_free(size1);
|
||||
/* dbg_free(size2); */
|
||||
} else
|
||||
log_print("PV Size %s", size);
|
||||
dbg_free(size);
|
||||
|
||||
/* PV number not part of LVM2 design
|
||||
log_print("PV# %u", pv->pv_number);
|
||||
@@ -206,9 +297,9 @@ void pvdisplay_full(struct physical_volume *pv, void *handle)
|
||||
/* LV count is no longer available when displaying PV
|
||||
log_print("Cur LV %u", vg->lv_count);
|
||||
*/
|
||||
log_print("PE Size (KByte) %" PRIu64, pv->pe_size / 2);
|
||||
log_print("PE Size (KByte) %" PRIu32, pv->pe_size / 2);
|
||||
log_print("Total PE %u", pv->pe_count);
|
||||
log_print("Free PE %" PRIu64, pe_free);
|
||||
log_print("Free PE %" PRIu32, pe_free);
|
||||
log_print("Allocated PE %u", pv->pe_alloc_count);
|
||||
log_print("PV UUID %s", *uuid ? uuid : "none");
|
||||
log_print(" ");
|
||||
@@ -219,11 +310,19 @@ void pvdisplay_full(struct physical_volume *pv, void *handle)
|
||||
int pvdisplay_short(struct cmd_context *cmd, struct volume_group *vg,
|
||||
struct physical_volume *pv, void *handle)
|
||||
{
|
||||
char uuid[64];
|
||||
|
||||
if (!pv)
|
||||
return 0;
|
||||
|
||||
if (!id_write_format(&pv->id, uuid, sizeof(uuid))) {
|
||||
stack;
|
||||
return 0;
|
||||
}
|
||||
|
||||
log_print("PV Name %s ", dev_name(pv->dev));
|
||||
/* FIXME pv->pv_number); */
|
||||
log_print("PV UUID %s", *uuid ? uuid : "none");
|
||||
log_print("PV Status %sallocatable",
|
||||
(pv->status & ALLOCATABLE_PV) ? "" : "NOT ");
|
||||
log_print("Total PE / Free PE %u / %u",
|
||||
@@ -236,7 +335,7 @@ int pvdisplay_short(struct cmd_context *cmd, struct volume_group *vg,
|
||||
void lvdisplay_colons(struct logical_volume *lv)
|
||||
{
|
||||
int inkernel;
|
||||
struct dm_info info;
|
||||
struct lvinfo info;
|
||||
inkernel = lv_info(lv, &info) && info.exists;
|
||||
|
||||
log_print("%s%s/%s:%s:%d:%d:-1:%d:%" PRIu64 ":%d:-1:%d:%d:%d:%d",
|
||||
@@ -256,13 +355,12 @@ void lvdisplay_colons(struct logical_volume *lv)
|
||||
int lvdisplay_full(struct cmd_context *cmd, struct logical_volume *lv,
|
||||
void *handle)
|
||||
{
|
||||
char *size;
|
||||
struct dm_info info;
|
||||
struct lvinfo info;
|
||||
int inkernel, snap_active;
|
||||
char uuid[64];
|
||||
struct snapshot *snap = NULL;
|
||||
struct list *slh, *snaplist;
|
||||
float snap_percent; /* fused, fsize; */
|
||||
float snap_percent; /* fused, fsize; */
|
||||
|
||||
if (!id_write_format(&lv->lvid.id[1], uuid, sizeof(uuid))) {
|
||||
stack;
|
||||
@@ -295,6 +393,7 @@ int lvdisplay_full(struct cmd_context *cmd, struct logical_volume *lv,
|
||||
snap->cow->name,
|
||||
(snap_active > 0) ? "active" : "INACTIVE");
|
||||
}
|
||||
snap = NULL;
|
||||
} else if ((snap = find_cow(lv))) {
|
||||
snap_active = lv_snapshot_percent(lv, &snap_percent);
|
||||
log_print("LV snapshot status %s destination for %s%s/%s",
|
||||
@@ -316,10 +415,10 @@ int lvdisplay_full(struct cmd_context *cmd, struct logical_volume *lv,
|
||||
if (inkernel)
|
||||
log_print("# open %u", info.open_count);
|
||||
|
||||
size = display_size(snap ? snap->origin->size / 2 : lv->size / 2,
|
||||
SIZE_SHORT);
|
||||
log_print("LV Size %s", size);
|
||||
dbg_free(size);
|
||||
log_print("LV Size %s",
|
||||
display_size(cmd,
|
||||
snap ? snap->origin->size / 2 : lv->size / 2,
|
||||
SIZE_SHORT));
|
||||
|
||||
log_print("Current LE %u",
|
||||
snap ? snap->origin->le_count : lv->le_count);
|
||||
@@ -334,23 +433,23 @@ int lvdisplay_full(struct cmd_context *cmd, struct logical_volume *lv,
|
||||
log_print("Stripe size (KByte) %u", lv->stripesize / 2);
|
||||
***********/
|
||||
|
||||
if (snap) {
|
||||
if (snap_percent == -1)
|
||||
snap_percent = 100;
|
||||
if (snap) {
|
||||
if (snap_percent == -1)
|
||||
snap_percent = 100;
|
||||
|
||||
size = display_size(snap->chunk_size / 2, SIZE_SHORT);
|
||||
log_print("Snapshot chunk size %s", size);
|
||||
dbg_free(size);
|
||||
log_print("Snapshot chunk size %s",
|
||||
display_size(cmd, (uint64_t) snap->chunk_size / 2,
|
||||
SIZE_SHORT));
|
||||
|
||||
/*
|
||||
size = display_size(lv->size / 2, SIZE_SHORT);
|
||||
sscanf(size, "%f", &fsize);
|
||||
fused = fsize * snap_percent / 100;
|
||||
*/
|
||||
log_print("Allocated to snapshot %.2f%% ", /* [%.2f/%s]", */
|
||||
snap_percent); /*, fused, size); */
|
||||
/* dbg_free(size); */
|
||||
}
|
||||
log_print("Allocated to snapshot %.2f%% ", /* [%.2f/%s]", */
|
||||
snap_percent); /*, fused, size); */
|
||||
/* dbg_free(size); */
|
||||
}
|
||||
|
||||
/********** FIXME Snapshot
|
||||
size = ???
|
||||
@@ -374,7 +473,7 @@ int lvdisplay_full(struct cmd_context *cmd, struct logical_volume *lv,
|
||||
return 0;
|
||||
}
|
||||
|
||||
void _display_stripe(struct lv_segment *seg, int s, const char *pre)
|
||||
static void _display_stripe(struct lv_segment *seg, uint32_t s, const char *pre)
|
||||
{
|
||||
uint32_t len = seg->len / seg->stripes;
|
||||
|
||||
@@ -388,7 +487,7 @@ void _display_stripe(struct lv_segment *seg, int s, const char *pre)
|
||||
|
||||
int lvdisplay_segments(struct logical_volume *lv)
|
||||
{
|
||||
int s;
|
||||
uint32_t s;
|
||||
struct list *segh;
|
||||
struct lv_segment *seg;
|
||||
|
||||
@@ -397,19 +496,23 @@ int lvdisplay_segments(struct logical_volume *lv)
|
||||
list_iterate(segh, &lv->segments) {
|
||||
seg = list_item(segh, struct lv_segment);
|
||||
|
||||
log_print("Logical extent %d to %d:",
|
||||
log_print("Logical extent %u to %u:",
|
||||
seg->le, seg->le + seg->len - 1);
|
||||
|
||||
log_print(" Type\t\t%s", get_segtype_string(seg->type));
|
||||
if (seg->type == SEG_STRIPED && seg->stripes == 1)
|
||||
log_print(" Type\t\tlinear");
|
||||
else
|
||||
log_print(" Type\t\t%s",
|
||||
get_segtype_string(seg->type));
|
||||
|
||||
switch (seg->type) {
|
||||
case SEG_STRIPED:
|
||||
if (seg->stripes == 1)
|
||||
_display_stripe(seg, 0, " ");
|
||||
else {
|
||||
log_print(" Stripes\t\t%d", seg->stripes);
|
||||
log_print(" Stripe size\t\t%d",
|
||||
seg->stripe_size);
|
||||
log_print(" Stripes\t\t%u", seg->stripes);
|
||||
log_print(" Stripe size\t\t%u KB",
|
||||
seg->stripe_size / 2);
|
||||
|
||||
for (s = 0; s < seg->stripes; s++) {
|
||||
log_print(" Stripe %d:", s);
|
||||
@@ -437,7 +540,6 @@ void vgdisplay_full(struct volume_group *vg)
|
||||
{
|
||||
uint32_t access;
|
||||
uint32_t active_pvs;
|
||||
char *s1;
|
||||
char uuid[64];
|
||||
|
||||
if (vg->status & PARTIAL_VG)
|
||||
@@ -483,28 +585,34 @@ void vgdisplay_full(struct volume_group *vg)
|
||||
log_print("Cur PV %u", vg->pv_count);
|
||||
log_print("Act PV %u", active_pvs);
|
||||
|
||||
s1 = display_size((uint64_t) vg->extent_count * (vg->extent_size / 2),
|
||||
SIZE_SHORT);
|
||||
log_print("VG Size %s", s1);
|
||||
dbg_free(s1);
|
||||
log_print("VG Size %s",
|
||||
display_size(vg->cmd,
|
||||
(uint64_t) vg->extent_count * (vg->extent_size /
|
||||
2), SIZE_SHORT));
|
||||
|
||||
s1 = display_size(vg->extent_size / 2, SIZE_SHORT);
|
||||
log_print("PE Size %s", s1);
|
||||
dbg_free(s1);
|
||||
log_print("PE Size %s",
|
||||
display_size(vg->cmd, (uint64_t) vg->extent_size / 2,
|
||||
SIZE_SHORT));
|
||||
|
||||
log_print("Total PE %u", vg->extent_count);
|
||||
|
||||
s1 = display_size(((uint64_t)
|
||||
vg->extent_count - vg->free_count) *
|
||||
(vg->extent_size / 2), SIZE_SHORT);
|
||||
log_print("Alloc PE / Size %u / %s",
|
||||
vg->extent_count - vg->free_count, s1);
|
||||
dbg_free(s1);
|
||||
vg->extent_count - vg->free_count, display_size(vg->cmd,
|
||||
((uint64_t)
|
||||
vg->
|
||||
extent_count
|
||||
-
|
||||
vg->
|
||||
free_count) *
|
||||
(vg->
|
||||
extent_size /
|
||||
2),
|
||||
SIZE_SHORT));
|
||||
|
||||
s1 = display_size((uint64_t) vg->free_count * (vg->extent_size / 2),
|
||||
SIZE_SHORT);
|
||||
log_print("Free PE / Size %u / %s", vg->free_count, s1);
|
||||
dbg_free(s1);
|
||||
log_print("Free PE / Size %u / %s", vg->free_count,
|
||||
display_size(vg->cmd,
|
||||
(uint64_t) vg->free_count * (vg->extent_size /
|
||||
2), SIZE_SHORT));
|
||||
|
||||
if (!id_write_format(&vg->id, uuid, sizeof(uuid))) {
|
||||
stack;
|
||||
@@ -524,16 +632,17 @@ void vgdisplay_colons(struct volume_group *vg)
|
||||
|
||||
void vgdisplay_short(struct volume_group *vg)
|
||||
{
|
||||
char *s1, *s2, *s3;
|
||||
s1 = display_size(vg->extent_count * vg->extent_size / 2, SIZE_SHORT);
|
||||
s2 = display_size((vg->extent_count -
|
||||
vg->free_count) * vg->extent_size / 2, SIZE_SHORT);
|
||||
s3 = display_size(vg->free_count * vg->extent_size / 2, SIZE_SHORT);
|
||||
log_print("\"%s\" %-9s [%-9s used / %s free]", vg->name,
|
||||
/********* FIXME if "open" print "/used" else print "/idle"??? ******/
|
||||
s1, s2, s3);
|
||||
dbg_free(s1);
|
||||
dbg_free(s2);
|
||||
dbg_free(s3);
|
||||
display_size(vg->cmd, (uint64_t) vg->extent_count *
|
||||
vg->extent_size / 2, SIZE_SHORT),
|
||||
display_size(vg->cmd,
|
||||
((uint64_t) vg->extent_count -
|
||||
vg->free_count) * vg->extent_size / 2,
|
||||
SIZE_SHORT), display_size(vg->cmd,
|
||||
(uint64_t) vg->
|
||||
free_count *
|
||||
vg->extent_size / 2,
|
||||
SIZE_SHORT));
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -25,14 +25,17 @@
|
||||
|
||||
#include <stdint.h>
|
||||
|
||||
typedef enum { SIZE_LONG = 0, SIZE_SHORT = 1 } size_len_t;
|
||||
typedef enum { SIZE_LONG = 0, SIZE_SHORT = 1, SIZE_UNIT = 2 } size_len_t;
|
||||
|
||||
uint64_t units_to_bytes(const char *units, char *unit_type);
|
||||
|
||||
/* Specify size in KB */
|
||||
char *display_size(uint64_t size, size_len_t sl);
|
||||
const char *display_size(struct cmd_context *cmd, uint64_t size, size_len_t sl);
|
||||
char *display_uuid(char *uuidstr);
|
||||
|
||||
void pvdisplay_colons(struct physical_volume *pv);
|
||||
void pvdisplay_full(struct physical_volume *pv, void *handle);
|
||||
void pvdisplay_full(struct cmd_context *cmd, struct physical_volume *pv,
|
||||
void *handle);
|
||||
int pvdisplay_short(struct cmd_context *cmd, struct volume_group *vg,
|
||||
struct physical_volume *pv, void *handle);
|
||||
|
||||
|
||||
@@ -19,6 +19,8 @@ static int _and_p(struct dev_filter *f, struct device *dev)
|
||||
filters++;
|
||||
}
|
||||
|
||||
log_debug("Using %s", dev_name(dev));
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
||||
@@ -32,8 +32,12 @@ static int _init_hash(struct pfilter *pf)
|
||||
if (pf->devices)
|
||||
hash_destroy(pf->devices);
|
||||
|
||||
pf->devices = hash_create(128);
|
||||
return pf->devices ? 1 : 0;
|
||||
if (!(pf->devices = hash_create(128))) {
|
||||
stack;
|
||||
return 0;
|
||||
}
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
int persistent_filter_wipe(struct dev_filter *f)
|
||||
@@ -109,6 +113,8 @@ int persistent_filter_load(struct dev_filter *f)
|
||||
r = 1;
|
||||
}
|
||||
|
||||
log_very_verbose("Loaded persistent filter cache from %s", pf->file);
|
||||
|
||||
out:
|
||||
destroy_config_tree(cf);
|
||||
return r;
|
||||
@@ -199,7 +205,11 @@ static int _lookup_p(struct dev_filter *f, struct device *dev)
|
||||
}
|
||||
}
|
||||
|
||||
return l == PF_GOOD_DEVICE;
|
||||
if (l == PF_BAD_DEVICE) {
|
||||
log_debug("%s: Skipping (cached)", dev_name(dev));
|
||||
return 0;
|
||||
} else
|
||||
return 1;
|
||||
}
|
||||
|
||||
static void _destroy(struct dev_filter *f)
|
||||
|
||||
@@ -19,7 +19,7 @@ struct rfilter {
|
||||
};
|
||||
|
||||
static int _extract_pattern(struct pool *mem, const char *pat,
|
||||
char **regex, bitset_t accept, int index)
|
||||
char **regex, bitset_t accept, int ix)
|
||||
{
|
||||
char sep, *r, *ptr;
|
||||
|
||||
@@ -28,11 +28,11 @@ static int _extract_pattern(struct pool *mem, const char *pat,
|
||||
*/
|
||||
switch (*pat) {
|
||||
case 'a':
|
||||
bit_set(accept, index);
|
||||
bit_set(accept, ix);
|
||||
break;
|
||||
|
||||
case 'r':
|
||||
bit_clear(accept, index);
|
||||
bit_clear(accept, ix);
|
||||
break;
|
||||
|
||||
default:
|
||||
@@ -80,7 +80,7 @@ static int _extract_pattern(struct pool *mem, const char *pat,
|
||||
}
|
||||
*ptr = '\0';
|
||||
|
||||
regex[index] = r;
|
||||
regex[ix] = r;
|
||||
return 1;
|
||||
}
|
||||
|
||||
@@ -89,7 +89,8 @@ static int _build_matcher(struct rfilter *rf, struct config_value *val)
|
||||
struct pool *scratch;
|
||||
struct config_value *v;
|
||||
char **regex;
|
||||
int count = 0, i, r = 0;
|
||||
unsigned count = 0;
|
||||
int i, r = 0;
|
||||
|
||||
if (!(scratch = pool_create(1024))) {
|
||||
stack;
|
||||
@@ -161,6 +162,8 @@ static int _accept_p(struct dev_filter *f, struct device *dev)
|
||||
if (bit(rf->accept, m)) {
|
||||
|
||||
if (!first) {
|
||||
log_debug("%s: New preferred name",
|
||||
sl->str);
|
||||
list_del(&sl->list);
|
||||
list_add_h(&dev->aliases, &sl->list);
|
||||
}
|
||||
|
||||
@@ -22,6 +22,7 @@
|
||||
#include "dev-cache.h"
|
||||
#include "filter.h"
|
||||
#include "lvm-string.h"
|
||||
#include "config.h"
|
||||
|
||||
#include <dirent.h>
|
||||
#include <sys/stat.h>
|
||||
@@ -33,14 +34,19 @@
|
||||
#define NUMBER_OF_MAJORS 256
|
||||
|
||||
typedef struct {
|
||||
char *name;
|
||||
int max_partitions;
|
||||
const char *name;
|
||||
const int max_partitions;
|
||||
} device_info_t;
|
||||
|
||||
static int _md_major = -1;
|
||||
|
||||
/* FIXME Move list into config file */
|
||||
static device_info_t device_info[] = {
|
||||
int md_major(void)
|
||||
{
|
||||
return _md_major;
|
||||
}
|
||||
|
||||
/* This list can be supplemented with devices/types in the config file */
|
||||
static const device_info_t device_info[] = {
|
||||
{"ide", 16}, /* IDE disk */
|
||||
{"sd", 16}, /* SCSI disk */
|
||||
{"md", 16}, /* Multiple Disk driver (SoftRAID) */
|
||||
@@ -55,21 +61,23 @@ static device_info_t device_info[] = {
|
||||
{NULL, 0}
|
||||
};
|
||||
|
||||
static int *scan_proc_dev(const char *proc);
|
||||
|
||||
static int passes_lvm_type_device_filter(struct dev_filter *f,
|
||||
struct device *dev)
|
||||
static int _passes_lvm_type_device_filter(struct dev_filter *f,
|
||||
struct device *dev)
|
||||
{
|
||||
int fd;
|
||||
const char *name = dev_name(dev);
|
||||
|
||||
/* Is this a recognised device type? */
|
||||
if (!(((int *) f->private)[MAJOR(dev->dev)]))
|
||||
if (!(((int *) f->private)[MAJOR(dev->dev)])) {
|
||||
log_debug("%s: Skipping: Unrecognised LVM device type %"
|
||||
PRIu64, name, (uint64_t) MAJOR(dev->dev));
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* Check it's accessible */
|
||||
if ((fd = open(name, O_RDONLY)) < 0) {
|
||||
log_debug("Unable to open %s: %s", name, strerror(errno));
|
||||
log_debug("%s: Skipping: open failed: %s", name,
|
||||
strerror(errno));
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -78,48 +86,18 @@ static int passes_lvm_type_device_filter(struct dev_filter *f,
|
||||
return 1;
|
||||
}
|
||||
|
||||
struct dev_filter *lvm_type_filter_create(const char *proc)
|
||||
{
|
||||
struct dev_filter *f;
|
||||
|
||||
if (!(f = dbg_malloc(sizeof(struct dev_filter)))) {
|
||||
log_error("LVM type filter allocation failed");
|
||||
return NULL;
|
||||
}
|
||||
|
||||
f->passes_filter = passes_lvm_type_device_filter;
|
||||
f->destroy = lvm_type_filter_destroy;
|
||||
|
||||
if (!(f->private = scan_proc_dev(proc)))
|
||||
return NULL;
|
||||
|
||||
return f;
|
||||
}
|
||||
|
||||
int md_major(void)
|
||||
{
|
||||
return _md_major;
|
||||
}
|
||||
|
||||
void lvm_type_filter_destroy(struct dev_filter *f)
|
||||
{
|
||||
dbg_free(f->private);
|
||||
dbg_free(f);
|
||||
return;
|
||||
}
|
||||
|
||||
static int *scan_proc_dev(const char *proc)
|
||||
static int *_scan_proc_dev(const char *proc, struct config_node *cn)
|
||||
{
|
||||
char line[80];
|
||||
char proc_devices[PATH_MAX];
|
||||
FILE *pd = NULL;
|
||||
int ret = 0;
|
||||
int i, j = 0;
|
||||
int line_maj = 0;
|
||||
int blocksection = 0;
|
||||
int dev_len = 0;
|
||||
|
||||
size_t dev_len = 0;
|
||||
struct config_value *cv;
|
||||
int *max_partitions_by_major;
|
||||
char *name;
|
||||
|
||||
if (!(max_partitions_by_major =
|
||||
dbg_malloc(sizeof(int) * NUMBER_OF_MAJORS))) {
|
||||
@@ -170,12 +148,44 @@ static int *scan_proc_dev(const char *proc)
|
||||
for (j = 0; device_info[j].name != NULL; j++) {
|
||||
|
||||
dev_len = strlen(device_info[j].name);
|
||||
if (dev_len <= strlen(line + i)
|
||||
&& !strncmp(device_info[j].name, line + i, dev_len)
|
||||
&& (line_maj < NUMBER_OF_MAJORS)) {
|
||||
if (dev_len <= strlen(line + i) &&
|
||||
!strncmp(device_info[j].name, line + i, dev_len) &&
|
||||
(line_maj < NUMBER_OF_MAJORS)) {
|
||||
max_partitions_by_major[line_maj] =
|
||||
device_info[j].max_partitions;
|
||||
ret++;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (max_partitions_by_major[line_maj] || !cn)
|
||||
continue;
|
||||
|
||||
/* Check devices/types for local variations */
|
||||
for (cv = cn->v; cv; cv = cv->next) {
|
||||
if (cv->type != CFG_STRING) {
|
||||
log_error("Expecting string in devices/types "
|
||||
"in config file");
|
||||
return NULL;
|
||||
}
|
||||
dev_len = strlen(cv->v.str);
|
||||
name = cv->v.str;
|
||||
cv = cv->next;
|
||||
if (!cv || cv->type != CFG_INT) {
|
||||
log_error("Max partition count missing for %s "
|
||||
"in devices/types in config file",
|
||||
name);
|
||||
return NULL;
|
||||
}
|
||||
if (!cv->v.i) {
|
||||
log_error("Zero partition count invalid for "
|
||||
"%s in devices/types in config file",
|
||||
name);
|
||||
return NULL;
|
||||
}
|
||||
if (dev_len <= strlen(line + i) &&
|
||||
!strncmp(name, line + i, dev_len) &&
|
||||
(line_maj < NUMBER_OF_MAJORS)) {
|
||||
max_partitions_by_major[line_maj] = cv->v.i;
|
||||
break;
|
||||
}
|
||||
}
|
||||
@@ -183,3 +193,31 @@ static int *scan_proc_dev(const char *proc)
|
||||
fclose(pd);
|
||||
return max_partitions_by_major;
|
||||
}
|
||||
|
||||
struct dev_filter *lvm_type_filter_create(const char *proc,
|
||||
struct config_node *cn)
|
||||
{
|
||||
struct dev_filter *f;
|
||||
|
||||
if (!(f = dbg_malloc(sizeof(struct dev_filter)))) {
|
||||
log_error("LVM type filter allocation failed");
|
||||
return NULL;
|
||||
}
|
||||
|
||||
f->passes_filter = _passes_lvm_type_device_filter;
|
||||
f->destroy = lvm_type_filter_destroy;
|
||||
|
||||
if (!(f->private = _scan_proc_dev(proc, cn))) {
|
||||
stack;
|
||||
return NULL;
|
||||
}
|
||||
|
||||
return f;
|
||||
}
|
||||
|
||||
void lvm_type_filter_destroy(struct dev_filter *f)
|
||||
{
|
||||
dbg_free(f->private);
|
||||
dbg_free(f);
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -21,11 +21,13 @@
|
||||
#ifndef _LVM_FILTER_H
|
||||
#define _LVM_FILTER_H
|
||||
|
||||
struct dev_filter *lvm_type_filter_create(const char *proc);
|
||||
#include "config.h"
|
||||
|
||||
struct dev_filter *lvm_type_filter_create(const char *proc,
|
||||
struct config_node *cn);
|
||||
|
||||
void lvm_type_filter_destroy(struct dev_filter *f);
|
||||
|
||||
int md_major(void);
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
{
|
||||
Base {
|
||||
global:
|
||||
init_format;
|
||||
local:
|
||||
|
||||
@@ -94,7 +94,7 @@ static void _xlate_vgd(struct vg_disk *disk)
|
||||
xx32(pvg_total);
|
||||
}
|
||||
|
||||
static void _xlate_extents(struct pe_disk *extents, int count)
|
||||
static void _xlate_extents(struct pe_disk *extents, uint32_t count)
|
||||
{
|
||||
int i;
|
||||
|
||||
@@ -132,7 +132,7 @@ static int _munge_formats(struct pv_disk *pvd)
|
||||
|
||||
static int _read_pvd(struct device *dev, struct pv_disk *pvd)
|
||||
{
|
||||
if (dev_read(dev, 0, sizeof(*pvd), pvd) != sizeof(*pvd)) {
|
||||
if (dev_read(dev, __UINT64_C(0), sizeof(*pvd), pvd) != sizeof(*pvd)) {
|
||||
log_very_verbose("Failed to read PV data from %s",
|
||||
dev_name(dev));
|
||||
return 0;
|
||||
@@ -155,7 +155,7 @@ static int _read_pvd(struct device *dev, struct pv_disk *pvd)
|
||||
return 1;
|
||||
}
|
||||
|
||||
static int _read_lvd(struct device *dev, ulong pos, struct lv_disk *disk)
|
||||
static int _read_lvd(struct device *dev, uint64_t pos, struct lv_disk *disk)
|
||||
{
|
||||
if (dev_read(dev, pos, sizeof(*disk), disk) != sizeof(*disk))
|
||||
fail;
|
||||
@@ -168,7 +168,7 @@ static int _read_lvd(struct device *dev, ulong pos, struct lv_disk *disk)
|
||||
static int _read_vgd(struct disk_list *data)
|
||||
{
|
||||
struct vg_disk *vgd = &data->vgd;
|
||||
ulong pos = data->pvd.vg_on_disk.base;
|
||||
uint64_t pos = data->pvd.vg_on_disk.base;
|
||||
if (dev_read(data->dev, pos, sizeof(*vgd), vgd) != sizeof(*vgd))
|
||||
fail;
|
||||
|
||||
@@ -182,8 +182,8 @@ static int _read_uuids(struct disk_list *data)
|
||||
int num_read = 0;
|
||||
struct uuid_list *ul;
|
||||
char buffer[NAME_LEN];
|
||||
ulong pos = data->pvd.pv_uuidlist_on_disk.base;
|
||||
ulong end = pos + data->pvd.pv_uuidlist_on_disk.size;
|
||||
uint64_t pos = data->pvd.pv_uuidlist_on_disk.base;
|
||||
uint64_t end = pos + data->pvd.pv_uuidlist_on_disk.size;
|
||||
|
||||
while (pos < end && num_read < data->vgd.pv_cur) {
|
||||
if (dev_read(data->dev, pos, sizeof(buffer), buffer) !=
|
||||
@@ -212,8 +212,8 @@ static inline int _check_lvd(struct lv_disk *lvd)
|
||||
|
||||
static int _read_lvs(struct disk_list *data)
|
||||
{
|
||||
int i, read = 0;
|
||||
ulong pos;
|
||||
unsigned int i, read = 0;
|
||||
uint64_t pos;
|
||||
struct lvd_list *ll;
|
||||
struct vg_disk *vgd = &data->vgd;
|
||||
|
||||
@@ -241,7 +241,7 @@ static int _read_extents(struct disk_list *data)
|
||||
{
|
||||
size_t len = sizeof(struct pe_disk) * data->pvd.pe_total;
|
||||
struct pe_disk *extents = pool_alloc(data->mem, len);
|
||||
ulong pos = data->pvd.pe_on_disk.base;
|
||||
uint64_t pos = data->pvd.pe_on_disk.base;
|
||||
|
||||
if (!extents)
|
||||
fail;
|
||||
@@ -260,7 +260,8 @@ static int _read_extents(struct disk_list *data)
|
||||
*/
|
||||
static void _munge_exported_vg(struct disk_list *data)
|
||||
{
|
||||
int l, s;
|
||||
int l;
|
||||
size_t s;
|
||||
|
||||
/* Return if PV not in a VG or VG not exported */
|
||||
if ((!*data->pvd.vg_name) || !(data->vgd.vg_status & VG_EXPORTED))
|
||||
@@ -274,7 +275,7 @@ static void _munge_exported_vg(struct disk_list *data)
|
||||
data->pvd.pv_status |= VG_EXPORTED;
|
||||
}
|
||||
|
||||
static struct disk_list *__read_disk(struct format_type *fmt,
|
||||
static struct disk_list *__read_disk(const struct format_type *fmt,
|
||||
struct device *dev, struct pool *mem,
|
||||
const char *vg_name)
|
||||
{
|
||||
@@ -361,7 +362,7 @@ static struct disk_list *__read_disk(struct format_type *fmt,
|
||||
return NULL;
|
||||
}
|
||||
|
||||
struct disk_list *read_disk(struct format_type *fmt, struct device *dev,
|
||||
struct disk_list *read_disk(const struct format_type *fmt, struct device *dev,
|
||||
struct pool *mem, const char *vg_name)
|
||||
{
|
||||
struct disk_list *r;
|
||||
@@ -408,7 +409,7 @@ static void _add_pv_to_list(struct list *head, struct disk_list *data)
|
||||
* We keep track of the first object allocated form the pool
|
||||
* so we can free off all the memory if something goes wrong.
|
||||
*/
|
||||
int read_pvs_in_vg(struct format_type *fmt, const char *vg_name,
|
||||
int read_pvs_in_vg(const struct format_type *fmt, const char *vg_name,
|
||||
struct dev_filter *filter, struct pool *mem,
|
||||
struct list *head)
|
||||
{
|
||||
@@ -461,7 +462,7 @@ int read_pvs_in_vg(struct format_type *fmt, const char *vg_name,
|
||||
static int _write_vgd(struct disk_list *data)
|
||||
{
|
||||
struct vg_disk *vgd = &data->vgd;
|
||||
ulong pos = data->pvd.vg_on_disk.base;
|
||||
uint64_t pos = data->pvd.vg_on_disk.base;
|
||||
|
||||
_xlate_vgd(vgd);
|
||||
if (dev_write(data->dev, pos, sizeof(*vgd), vgd) != sizeof(*vgd))
|
||||
@@ -476,8 +477,8 @@ static int _write_uuids(struct disk_list *data)
|
||||
{
|
||||
struct uuid_list *ul;
|
||||
struct list *uh;
|
||||
ulong pos = data->pvd.pv_uuidlist_on_disk.base;
|
||||
ulong end = pos + data->pvd.pv_uuidlist_on_disk.size;
|
||||
uint64_t pos = data->pvd.pv_uuidlist_on_disk.base;
|
||||
uint64_t end = pos + data->pvd.pv_uuidlist_on_disk.size;
|
||||
|
||||
list_iterate(uh, &data->uuids) {
|
||||
if (pos >= end) {
|
||||
@@ -496,7 +497,7 @@ static int _write_uuids(struct disk_list *data)
|
||||
return 1;
|
||||
}
|
||||
|
||||
static int _write_lvd(struct device *dev, ulong pos, struct lv_disk *disk)
|
||||
static int _write_lvd(struct device *dev, uint64_t pos, struct lv_disk *disk)
|
||||
{
|
||||
_xlate_lvd(disk);
|
||||
if (dev_write(dev, pos, sizeof(*disk), disk) != sizeof(*disk))
|
||||
@@ -510,7 +511,7 @@ static int _write_lvd(struct device *dev, ulong pos, struct lv_disk *disk)
|
||||
static int _write_lvs(struct disk_list *data)
|
||||
{
|
||||
struct list *lvh;
|
||||
ulong pos, offset;
|
||||
uint64_t pos, offset;
|
||||
|
||||
pos = data->pvd.lv_on_disk.base;
|
||||
|
||||
@@ -540,7 +541,7 @@ static int _write_extents(struct disk_list *data)
|
||||
{
|
||||
size_t len = sizeof(struct pe_disk) * data->pvd.pe_total;
|
||||
struct pe_disk *extents = data->extents;
|
||||
ulong pos = data->pvd.pe_on_disk.base;
|
||||
uint64_t pos = data->pvd.pe_on_disk.base;
|
||||
|
||||
_xlate_extents(extents, data->pvd.pe_total);
|
||||
if (dev_write(data->dev, pos, len, extents) != len)
|
||||
@@ -554,8 +555,8 @@ static int _write_extents(struct disk_list *data)
|
||||
static int _write_pvd(struct disk_list *data)
|
||||
{
|
||||
char *buf;
|
||||
ulong pos = data->pvd.pv_on_disk.base;
|
||||
ulong size = data->pvd.pv_on_disk.size;
|
||||
uint64_t pos = data->pvd.pv_on_disk.base;
|
||||
size_t size = data->pvd.pv_on_disk.size;
|
||||
|
||||
if (size < sizeof(struct pv_disk)) {
|
||||
log_error("Invalid PV structure size.");
|
||||
@@ -587,7 +588,8 @@ static int _write_pvd(struct disk_list *data)
|
||||
/*
|
||||
* assumes the device has been opened.
|
||||
*/
|
||||
static int __write_all_pvd(struct format_type *fmt, struct disk_list *data)
|
||||
static int __write_all_pvd(const struct format_type *fmt,
|
||||
struct disk_list *data)
|
||||
{
|
||||
const char *pv_name = dev_name(data->dev);
|
||||
|
||||
@@ -636,7 +638,7 @@ static int __write_all_pvd(struct format_type *fmt, struct disk_list *data)
|
||||
/*
|
||||
* opens the device and hands to the above fn.
|
||||
*/
|
||||
static int _write_all_pvd(struct format_type *fmt, struct disk_list *data)
|
||||
static int _write_all_pvd(const struct format_type *fmt, struct disk_list *data)
|
||||
{
|
||||
int r;
|
||||
|
||||
@@ -658,7 +660,7 @@ static int _write_all_pvd(struct format_type *fmt, struct disk_list *data)
|
||||
* little sanity checking, so make sure correct
|
||||
* data is passed to here.
|
||||
*/
|
||||
int write_disks(struct format_type *fmt, struct list *pvs)
|
||||
int write_disks(const struct format_type *fmt, struct list *pvs)
|
||||
{
|
||||
struct list *pvh;
|
||||
struct disk_list *dl;
|
||||
|
||||
@@ -178,14 +178,14 @@ int calculate_extent_count(struct physical_volume *pv, uint32_t extent_size,
|
||||
* disk_lists.
|
||||
*/
|
||||
|
||||
struct disk_list *read_disk(struct format_type *fmt, struct device *dev,
|
||||
struct disk_list *read_disk(const struct format_type *fmt, struct device *dev,
|
||||
struct pool *mem, const char *vg_name);
|
||||
|
||||
int read_pvs_in_vg(struct format_type *fmt, const char *vg_name,
|
||||
int read_pvs_in_vg(const struct format_type *fmt, const char *vg_name,
|
||||
struct dev_filter *filter,
|
||||
struct pool *mem, struct list *results);
|
||||
|
||||
int write_disks(struct format_type *fmt, struct list *pvds);
|
||||
int write_disks(const struct format_type *fmt, struct list *pvds);
|
||||
|
||||
/*
|
||||
* Functions to translate to between disk and in
|
||||
@@ -205,10 +205,10 @@ int import_lv(struct pool *mem, struct logical_volume *lv, struct lv_disk *lvd);
|
||||
|
||||
int import_extents(struct pool *mem, struct volume_group *vg,
|
||||
struct list *pvds);
|
||||
int export_extents(struct disk_list *dl, int lv_num,
|
||||
int export_extents(struct disk_list *dl, uint32_t lv_num,
|
||||
struct logical_volume *lv, struct physical_volume *pv);
|
||||
|
||||
int import_pvs(struct format_type *fmt, struct pool *mem,
|
||||
int import_pvs(const struct format_type *fmt, struct pool *mem,
|
||||
struct volume_group *vg,
|
||||
struct list *pvds, struct list *results, int *count);
|
||||
|
||||
|
||||
@@ -23,8 +23,9 @@ static int _check_vgs(struct list *pvs, int *partial)
|
||||
struct disk_list *dl = NULL;
|
||||
struct disk_list *first = NULL;
|
||||
|
||||
int pv_count = 0;
|
||||
int exported = -1;
|
||||
uint32_t pv_count = 0;
|
||||
uint32_t exported = 0;
|
||||
int first_time = 1;
|
||||
|
||||
*partial = 0;
|
||||
|
||||
@@ -36,8 +37,9 @@ static int _check_vgs(struct list *pvs, int *partial)
|
||||
list_iterate(pvh, pvs) {
|
||||
dl = list_item(pvh, struct disk_list);
|
||||
|
||||
if (exported < 0) {
|
||||
if (first_time) {
|
||||
exported = dl->pvd.pv_status & VG_EXPORTED;
|
||||
first_time = 0;
|
||||
continue;
|
||||
}
|
||||
|
||||
@@ -251,8 +253,8 @@ static int _vg_write(struct format_instance *fid, struct volume_group *vg,
|
||||
return r;
|
||||
}
|
||||
|
||||
int _pv_read(struct format_type *fmt, const char *pv_name,
|
||||
struct physical_volume *pv, struct list *mdas)
|
||||
static int _pv_read(const struct format_type *fmt, const char *pv_name,
|
||||
struct physical_volume *pv, struct list *mdas)
|
||||
{
|
||||
struct pool *mem = pool_create(1024);
|
||||
struct disk_list *dl;
|
||||
@@ -290,21 +292,19 @@ int _pv_read(struct format_type *fmt, const char *pv_name,
|
||||
return r;
|
||||
}
|
||||
|
||||
static int _pv_setup(struct format_type *fmt,
|
||||
static int _pv_setup(const struct format_type *fmt,
|
||||
uint64_t pe_start, uint32_t extent_count,
|
||||
uint32_t extent_size,
|
||||
int pvmetadatacopies,
|
||||
uint64_t pvmetadatasize, struct list *mdas,
|
||||
struct physical_volume *pv, struct volume_group *vg)
|
||||
{
|
||||
char *sz;
|
||||
|
||||
if (pv->size > MAX_PV_SIZE)
|
||||
pv->size--;
|
||||
if (pv->size > MAX_PV_SIZE) {
|
||||
log_error("Physical volumes cannot be bigger than %s",
|
||||
sz = display_size(MAX_PV_SIZE / 2, SIZE_SHORT));
|
||||
dbg_free(sz);
|
||||
display_size(fmt->cmd, (uint64_t) MAX_PV_SIZE / 2,
|
||||
SIZE_SHORT));
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -332,10 +332,10 @@ static int _pv_setup(struct format_type *fmt,
|
||||
return 1;
|
||||
}
|
||||
|
||||
static int _find_free_lvnum(struct logical_volume *lv)
|
||||
static uint32_t _find_free_lvnum(struct logical_volume *lv)
|
||||
{
|
||||
int lvnum_used[MAX_LV];
|
||||
int i = 0;
|
||||
uint32_t i = 0;
|
||||
struct list *lvh;
|
||||
struct lv_list *lvl;
|
||||
|
||||
@@ -365,16 +365,16 @@ static int _lv_setup(struct format_instance *fid, struct logical_volume *lv)
|
||||
return 0;
|
||||
}
|
||||
if (lv->size > max_size) {
|
||||
char *dummy = display_size(max_size, SIZE_SHORT);
|
||||
log_error("logical volumes cannot be larger than %s", dummy);
|
||||
dbg_free(dummy);
|
||||
log_error("logical volumes cannot be larger than %s",
|
||||
display_size(fid->fmt->cmd, max_size / 2,
|
||||
SIZE_SHORT));
|
||||
return 0;
|
||||
}
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
static int _pv_write(struct format_type *fmt, struct physical_volume *pv,
|
||||
static int _pv_write(const struct format_type *fmt, struct physical_volume *pv,
|
||||
struct list *mdas, int64_t sector)
|
||||
{
|
||||
struct pool *mem;
|
||||
@@ -437,7 +437,7 @@ static int _pv_write(struct format_type *fmt, struct physical_volume *pv,
|
||||
return 0;
|
||||
}
|
||||
|
||||
int _vg_setup(struct format_instance *fid, struct volume_group *vg)
|
||||
static int _vg_setup(struct format_instance *fid, struct volume_group *vg)
|
||||
{
|
||||
/* just check max_pv and max_lv */
|
||||
if (vg->max_lv >= MAX_LV)
|
||||
@@ -447,22 +447,22 @@ int _vg_setup(struct format_instance *fid, struct volume_group *vg)
|
||||
vg->max_pv = MAX_PV - 1;
|
||||
|
||||
if (vg->extent_size > MAX_PE_SIZE || vg->extent_size < MIN_PE_SIZE) {
|
||||
char *dummy, *dummy2;
|
||||
|
||||
log_error("Extent size must be between %s and %s",
|
||||
(dummy = display_size(MIN_PE_SIZE / 2, SIZE_SHORT)),
|
||||
(dummy2 = display_size(MAX_PE_SIZE / 2, SIZE_SHORT)));
|
||||
display_size(fid->fmt->cmd, (uint64_t) MIN_PE_SIZE
|
||||
/ 2,
|
||||
SIZE_SHORT), display_size(fid->fmt->cmd,
|
||||
(uint64_t)
|
||||
MAX_PE_SIZE
|
||||
/ 2,
|
||||
SIZE_SHORT));
|
||||
|
||||
dbg_free(dummy);
|
||||
dbg_free(dummy2);
|
||||
return 0;
|
||||
}
|
||||
|
||||
if (vg->extent_size % MIN_PE_SIZE) {
|
||||
char *dummy;
|
||||
log_error("Extent size must be multiple of %s",
|
||||
(dummy = display_size(MIN_PE_SIZE / 2, SIZE_SHORT)));
|
||||
dbg_free(dummy);
|
||||
display_size(fid->fmt->cmd,
|
||||
(uint64_t) MIN_PE_SIZE / 2, SIZE_SHORT));
|
||||
return 0;
|
||||
}
|
||||
|
||||
@@ -480,8 +480,9 @@ static struct metadata_area_ops _metadata_format1_ops = {
|
||||
vg_write:_vg_write,
|
||||
};
|
||||
|
||||
struct format_instance *_create_instance(struct format_type *fmt,
|
||||
const char *vgname, void *private)
|
||||
static struct format_instance *_create_instance(const struct format_type *fmt,
|
||||
const char *vgname,
|
||||
void *private)
|
||||
{
|
||||
struct format_instance *fid;
|
||||
struct metadata_area *mda;
|
||||
@@ -508,14 +509,14 @@ struct format_instance *_create_instance(struct format_type *fmt,
|
||||
return fid;
|
||||
}
|
||||
|
||||
void _destroy_instance(struct format_instance *fid)
|
||||
static void _destroy_instance(struct format_instance *fid)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
void _destroy(struct format_type *fmt)
|
||||
static void _destroy(const struct format_type *fmt)
|
||||
{
|
||||
dbg_free(fmt);
|
||||
dbg_free((void *) fmt);
|
||||
}
|
||||
|
||||
static struct format_handler _format1_ops = {
|
||||
|
||||
@@ -79,7 +79,7 @@ int import_pv(struct pool *mem, struct device *dev,
|
||||
return 1;
|
||||
}
|
||||
|
||||
int _system_id(char *s, const char *prefix)
|
||||
static int _system_id(char *s, const char *prefix)
|
||||
{
|
||||
struct utsname uts;
|
||||
|
||||
@@ -353,7 +353,7 @@ static void _export_lv(struct lv_disk *lvd, struct volume_group *vg,
|
||||
lvd->lv_allocation |= LV_CONTIGUOUS;
|
||||
}
|
||||
|
||||
int export_extents(struct disk_list *dl, int lv_num,
|
||||
int export_extents(struct disk_list *dl, uint32_t lv_num,
|
||||
struct logical_volume *lv, struct physical_volume *pv)
|
||||
{
|
||||
struct list *segh;
|
||||
@@ -380,7 +380,7 @@ int export_extents(struct disk_list *dl, int lv_num,
|
||||
return 1;
|
||||
}
|
||||
|
||||
int import_pvs(struct format_type *fmt, struct pool *mem,
|
||||
int import_pvs(const struct format_type *fmt, struct pool *mem,
|
||||
struct volume_group *vg,
|
||||
struct list *pvds, struct list *results, int *count)
|
||||
{
|
||||
@@ -470,7 +470,8 @@ int export_lvs(struct disk_list *dl, struct volume_group *vg,
|
||||
struct list *lvh, *sh;
|
||||
struct lv_list *ll;
|
||||
struct lvd_list *lvdl;
|
||||
int lv_num, len;
|
||||
size_t len;
|
||||
uint32_t lv_num;
|
||||
struct hash_table *lvd_hash;
|
||||
|
||||
if (!_check_vg_name(vg->name)) {
|
||||
|
||||
@@ -62,7 +62,7 @@ static void _calc_simple_layout(struct pv_disk *pvd)
|
||||
pvd->pe_on_disk.size = pvd->pe_total * sizeof(struct pe_disk);
|
||||
}
|
||||
|
||||
int _check_vg_limits(struct disk_list *dl)
|
||||
static int _check_vg_limits(struct disk_list *dl)
|
||||
{
|
||||
if (dl->vgd.lv_max > MAX_LV) {
|
||||
log_error("MaxLogicalVolumes of %d exceeds format limit of %d "
|
||||
|
||||
@@ -100,7 +100,7 @@ struct labeller *lvm1_labeller_create(struct format_type *fmt)
|
||||
}
|
||||
|
||||
l->ops = &_lvm1_ops;
|
||||
l->private = (void *) fmt;
|
||||
l->private = (const void *) fmt;
|
||||
|
||||
return l;
|
||||
}
|
||||
|
||||
@@ -51,23 +51,23 @@ struct archive_file {
|
||||
* Extract vg name and version number from a filename.
|
||||
*/
|
||||
static int _split_vg(const char *filename, char *vg, size_t vg_size,
|
||||
uint32_t *index)
|
||||
uint32_t *ix)
|
||||
{
|
||||
int len, vg_len;
|
||||
char *dot, *underscore;
|
||||
size_t len, vg_len;
|
||||
const char *dot, *underscore;
|
||||
|
||||
len = strlen(filename);
|
||||
if (len < 7)
|
||||
return 0;
|
||||
|
||||
dot = (char *) (filename + len - 3);
|
||||
dot = (filename + len - 3);
|
||||
if (strcmp(".vg", dot))
|
||||
return 0;
|
||||
|
||||
if (!(underscore = rindex(filename, '_')))
|
||||
return 0;
|
||||
|
||||
if (sscanf(underscore + 1, "%u", index) != 1)
|
||||
if (sscanf(underscore + 1, "%u", ix) != 1)
|
||||
return 0;
|
||||
|
||||
vg_len = underscore - filename;
|
||||
@@ -83,7 +83,7 @@ static int _split_vg(const char *filename, char *vg, size_t vg_size,
|
||||
static void _insert_file(struct list *head, struct archive_file *b)
|
||||
{
|
||||
struct list *bh;
|
||||
struct archive_file *bf;
|
||||
struct archive_file *bf = NULL;
|
||||
|
||||
if (list_empty(head)) {
|
||||
list_add(head, &b->list);
|
||||
@@ -123,7 +123,7 @@ static char *_join(struct pool *mem, const char *dir, const char *name)
|
||||
static struct list *_scan_archive(struct pool *mem,
|
||||
const char *vg, const char *dir)
|
||||
{
|
||||
int i, count, index;
|
||||
int i, count, ix;
|
||||
char vg_name[64], *path;
|
||||
struct dirent **dirent;
|
||||
struct archive_file *af;
|
||||
@@ -149,7 +149,7 @@ static struct list *_scan_archive(struct pool *mem,
|
||||
|
||||
/* check the name is the correct format */
|
||||
if (!_split_vg(dirent[i]->d_name, vg_name, sizeof(vg_name),
|
||||
&index))
|
||||
&ix))
|
||||
continue;
|
||||
|
||||
/* is it the vg we're interested in ? */
|
||||
@@ -170,7 +170,7 @@ static struct list *_scan_archive(struct pool *mem,
|
||||
goto out;
|
||||
}
|
||||
|
||||
af->index = index;
|
||||
af->index = ix;
|
||||
af->path = path;
|
||||
|
||||
/*
|
||||
@@ -231,7 +231,7 @@ int archive_vg(struct volume_group *vg,
|
||||
uint32_t retain_days, uint32_t min_archive)
|
||||
{
|
||||
int i, fd, renamed = 0;
|
||||
unsigned int index = 0;
|
||||
unsigned int ix = 0;
|
||||
struct archive_file *last;
|
||||
FILE *fp = NULL;
|
||||
char temp_file[PATH_MAX], archive_name[PATH_MAX];
|
||||
@@ -268,15 +268,15 @@ int archive_vg(struct volume_group *vg,
|
||||
}
|
||||
|
||||
if (list_empty(archives))
|
||||
index = 0;
|
||||
ix = 0;
|
||||
else {
|
||||
last = list_item(archives->p, struct archive_file);
|
||||
index = last->index + 1;
|
||||
ix = last->index + 1;
|
||||
}
|
||||
|
||||
for (i = 0; i < 10; i++) {
|
||||
if (lvm_snprintf(archive_name, sizeof(archive_name),
|
||||
"%s/%s_%05d.vg", dir, vg->name, index) < 0) {
|
||||
"%s/%s_%05d.vg", dir, vg->name, ix) < 0) {
|
||||
log_error("Archive file name too long.");
|
||||
return 0;
|
||||
}
|
||||
@@ -284,7 +284,7 @@ int archive_vg(struct volume_group *vg,
|
||||
if ((renamed = lvm_rename(temp_file, archive_name)))
|
||||
break;
|
||||
|
||||
index++;
|
||||
ix++;
|
||||
}
|
||||
|
||||
if (!renamed)
|
||||
|
||||
@@ -173,7 +173,7 @@ static int _out_with_comment_raw(struct formatter *f, const char *comment,
|
||||
*/
|
||||
static int _sectors_to_units(uint64_t sectors, char *buffer, size_t s)
|
||||
{
|
||||
static char *_units[] = {
|
||||
static const char *_units[] = {
|
||||
"Kilobytes",
|
||||
"Megabytes",
|
||||
"Gigabytes",
|
||||
@@ -288,7 +288,8 @@ static int _print_vg(struct formatter *f, struct volume_group *vg)
|
||||
_outf(f, "status = %s", buffer);
|
||||
if (vg->system_id && *vg->system_id)
|
||||
_outf(f, "system_id = \"%s\"", vg->system_id);
|
||||
if (!_out_size(f, vg->extent_size, "extent_size = %u", vg->extent_size)) {
|
||||
if (!_out_size(f, (uint64_t) vg->extent_size, "extent_size = %u",
|
||||
vg->extent_size)) {
|
||||
stack;
|
||||
return 0;
|
||||
}
|
||||
@@ -369,15 +370,15 @@ static int _print_pvs(struct formatter *f, struct volume_group *vg)
|
||||
static int _print_segment(struct formatter *f, struct volume_group *vg,
|
||||
int count, struct lv_segment *seg)
|
||||
{
|
||||
int s;
|
||||
unsigned int s;
|
||||
const char *name;
|
||||
|
||||
_outf(f, "segment%u {", count);
|
||||
_inc_indent(f);
|
||||
|
||||
_outf(f, "start_extent = %u", seg->le);
|
||||
if (!_out_size(f, seg->len * vg->extent_size, "extent_count = %u",
|
||||
seg->len)) {
|
||||
if (!_out_size(f, (uint64_t) seg->len * vg->extent_size,
|
||||
"extent_count = %u", seg->len)) {
|
||||
stack;
|
||||
return 0;
|
||||
}
|
||||
@@ -391,7 +392,7 @@ static int _print_segment(struct formatter *f, struct volume_group *vg,
|
||||
(seg->stripes == 1) ? "\t# linear" : "");
|
||||
|
||||
if (seg->stripes > 1)
|
||||
_out_size(f, seg->stripe_size,
|
||||
_out_size(f, (uint64_t) seg->stripe_size,
|
||||
"stripe_size = %u", seg->stripe_size);
|
||||
|
||||
f->nl(f);
|
||||
|
||||
@@ -14,8 +14,8 @@
|
||||
* converted into arrays of strings.
|
||||
*/
|
||||
struct flag {
|
||||
int mask;
|
||||
char *description;
|
||||
const int mask;
|
||||
const char *description;
|
||||
};
|
||||
|
||||
static struct flag _vg_flags[] = {
|
||||
@@ -62,7 +62,7 @@ static struct flag *_get_flags(int type)
|
||||
|
||||
static int _emit(char **buffer, size_t *size, const char *fmt, ...)
|
||||
{
|
||||
size_t n;
|
||||
int n;
|
||||
va_list ap;
|
||||
|
||||
va_start(ap, fmt);
|
||||
|
||||
@@ -27,8 +27,8 @@
|
||||
#include <dirent.h>
|
||||
#include <ctype.h>
|
||||
|
||||
static struct format_instance *_create_text_instance(struct format_type *fmt,
|
||||
const char *vgname,
|
||||
static struct format_instance *_create_text_instance(const struct format_type
|
||||
*fmt, const char *vgname,
|
||||
void *context);
|
||||
|
||||
struct dir_list {
|
||||
@@ -48,9 +48,7 @@ struct text_context {
|
||||
};
|
||||
|
||||
/*
|
||||
* NOTE: Currently there can be only one vg per text file, and locking
|
||||
* assumes VG's metadata is only held in metadata areas on PVs
|
||||
* inside the VG.
|
||||
* NOTE: Currently there can be only one vg per text file.
|
||||
*/
|
||||
|
||||
static int _vg_setup(struct format_instance *fid, struct volume_group *vg)
|
||||
@@ -65,17 +63,19 @@ static int _vg_setup(struct format_instance *fid, struct volume_group *vg)
|
||||
|
||||
static int _lv_setup(struct format_instance *fid, struct logical_volume *lv)
|
||||
{
|
||||
/******** FIXME Any LV size restriction?
|
||||
uint64_t max_size = UINT_MAX;
|
||||
|
||||
if (!*lv->lvid.s)
|
||||
lvid_create(&lv->lvid, &lv->vg->id);
|
||||
|
||||
if (lv->size > max_size) {
|
||||
char *dummy = display_size(max_size, SIZE_SHORT);
|
||||
char *dummy = display_size(max_size / 2, SIZE_SHORT);
|
||||
log_error("logical volumes cannot be larger than %s", dummy);
|
||||
dbg_free(dummy);
|
||||
return 0;
|
||||
}
|
||||
*/
|
||||
|
||||
if (!*lv->lvid.s)
|
||||
lvid_create(&lv->lvid, &lv->vg->id);
|
||||
|
||||
return 1;
|
||||
}
|
||||
@@ -97,7 +97,7 @@ static void _xlate_mdah(struct mda_header *mdah)
|
||||
}
|
||||
}
|
||||
|
||||
static struct mda_header *_raw_read_mda_header(struct format_type *fmt,
|
||||
static struct mda_header *_raw_read_mda_header(const struct format_type *fmt,
|
||||
struct device_area *dev_area)
|
||||
{
|
||||
struct mda_header *mdah;
|
||||
@@ -143,7 +143,7 @@ static struct mda_header *_raw_read_mda_header(struct format_type *fmt,
|
||||
return mdah;
|
||||
}
|
||||
|
||||
static int _raw_write_mda_header(struct format_type *fmt,
|
||||
static int _raw_write_mda_header(const struct format_type *fmt,
|
||||
struct device *dev,
|
||||
uint64_t start_byte, struct mda_header *mdah)
|
||||
{
|
||||
@@ -170,7 +170,7 @@ static struct raw_locn *_find_vg_rlocn(struct device_area *dev_area,
|
||||
struct mda_header *mdah,
|
||||
const char *vgname)
|
||||
{
|
||||
int len;
|
||||
size_t len;
|
||||
char vgnamebuf[NAME_LEN + 2];
|
||||
struct raw_locn *rlocn;
|
||||
|
||||
@@ -237,7 +237,7 @@ static struct volume_group *_vg_read_raw_area(struct format_instance *fid,
|
||||
struct mda_header *mdah;
|
||||
time_t when;
|
||||
char *desc;
|
||||
uint64_t wrap = 0;
|
||||
uint32_t wrap = 0;
|
||||
|
||||
if (!dev_open(area->dev, O_RDONLY)) {
|
||||
stack;
|
||||
@@ -255,7 +255,7 @@ static struct volume_group *_vg_read_raw_area(struct format_instance *fid,
|
||||
}
|
||||
|
||||
if (rlocn->offset + rlocn->size > mdah->size)
|
||||
wrap = (rlocn->offset + rlocn->size) - mdah->size;
|
||||
wrap = (uint32_t) ((rlocn->offset + rlocn->size) - mdah->size);
|
||||
|
||||
if (wrap > rlocn->offset) {
|
||||
log_error("VG %s metadata too large for circular buffer",
|
||||
@@ -263,12 +263,13 @@ static struct volume_group *_vg_read_raw_area(struct format_instance *fid,
|
||||
goto out;
|
||||
}
|
||||
|
||||
/* FIXME 64-bit */
|
||||
if (!(vg = text_vg_import_fd(fid, dev_name(area->dev),
|
||||
dev_fd(area->dev),
|
||||
area->start + rlocn->offset,
|
||||
rlocn->size - wrap,
|
||||
area->start + MDA_HEADER_SIZE, wrap,
|
||||
calc_crc, rlocn->checksum, &when,
|
||||
(off_t) (area->start + rlocn->offset),
|
||||
(uint32_t) (rlocn->size - wrap),
|
||||
(off_t) (area->start + MDA_HEADER_SIZE),
|
||||
wrap, calc_crc, rlocn->checksum, &when,
|
||||
&desc))) {
|
||||
stack;
|
||||
goto out;
|
||||
@@ -299,7 +300,7 @@ static int _vg_write_raw(struct format_instance *fid, struct volume_group *vg,
|
||||
struct physical_volume *pv;
|
||||
struct list *pvh;
|
||||
int r = 0;
|
||||
uint64_t new_wrap = 0, old_wrap = 0;
|
||||
uint32_t new_wrap = 0, old_wrap = 0;
|
||||
|
||||
/* FIXME Essential fix! Make dynamic (realloc? pool?) */
|
||||
char buf[65536];
|
||||
@@ -367,20 +368,21 @@ static int _vg_write_raw(struct format_instance *fid, struct volume_group *vg,
|
||||
|
||||
/* Write text out, circularly */
|
||||
if (dev_write(mdac->area.dev, mdac->area.start + mdac->rlocn.offset,
|
||||
mdac->rlocn.size - new_wrap,
|
||||
(size_t) (mdac->rlocn.size - new_wrap),
|
||||
buf) != mdac->rlocn.size - new_wrap) {
|
||||
stack;
|
||||
goto out;
|
||||
}
|
||||
|
||||
if (new_wrap) {
|
||||
log_debug("Writing metadata to %s at %" PRIu64 " len %" PRIu64,
|
||||
log_debug("Writing metadata to %s at %" PRIu64 " len %" PRIu32,
|
||||
dev_name(mdac->area.dev), mdac->area.start +
|
||||
MDA_HEADER_SIZE, new_wrap);
|
||||
|
||||
if (dev_write(mdac->area.dev,
|
||||
mdac->area.start + MDA_HEADER_SIZE,
|
||||
new_wrap, buf + mdac->rlocn.size - new_wrap)
|
||||
(size_t) new_wrap,
|
||||
buf + mdac->rlocn.size - new_wrap)
|
||||
!= new_wrap) {
|
||||
stack;
|
||||
goto out;
|
||||
@@ -388,7 +390,8 @@ static int _vg_write_raw(struct format_instance *fid, struct volume_group *vg,
|
||||
}
|
||||
|
||||
mdac->rlocn.checksum = calc_crc(INITIAL_CRC, buf,
|
||||
mdac->rlocn.size - new_wrap);
|
||||
(uint32_t) (mdac->rlocn.size -
|
||||
new_wrap));
|
||||
if (new_wrap)
|
||||
mdac->rlocn.checksum = calc_crc(mdac->rlocn.checksum,
|
||||
buf + mdac->rlocn.size -
|
||||
@@ -558,7 +561,8 @@ static int _vg_write_file(struct format_instance *fid, struct volume_group *vg,
|
||||
if (slash == 0)
|
||||
strcpy(temp_dir, ".");
|
||||
else if (slash - tc->path_edit < PATH_MAX) {
|
||||
strncpy(temp_dir, tc->path_edit, slash - tc->path_edit);
|
||||
strncpy(temp_dir, tc->path_edit,
|
||||
(size_t) (slash - tc->path_edit));
|
||||
temp_dir[slash - tc->path_edit] = '\0';
|
||||
|
||||
} else {
|
||||
@@ -625,12 +629,12 @@ static int _vg_commit_file_backup(struct format_instance *fid,
|
||||
log_debug("Renaming %s to %s", tc->path_edit, tc->path_live);
|
||||
if (rename(tc->path_edit, tc->path_live)) {
|
||||
log_error("%s: rename to %s failed: %s", tc->path_edit,
|
||||
tc->path_edit, strerror(errno));
|
||||
tc->path_live, strerror(errno));
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
sync();
|
||||
sync_dir(tc->path_edit);
|
||||
|
||||
return 1;
|
||||
}
|
||||
@@ -641,7 +645,7 @@ static int _vg_commit_file(struct format_instance *fid, struct volume_group *vg,
|
||||
struct text_context *tc = (struct text_context *) mda->metadata_locn;
|
||||
char *slash;
|
||||
char newname[PATH_MAX];
|
||||
int len;
|
||||
size_t len;
|
||||
|
||||
if (!_vg_commit_file_backup(fid, vg, mda))
|
||||
return 0;
|
||||
@@ -664,7 +668,7 @@ static int _vg_commit_file(struct format_instance *fid, struct volume_group *vg,
|
||||
log_error("%s: rename to %s failed: %s",
|
||||
tc->path_live, newname,
|
||||
strerror(errno));
|
||||
sync();
|
||||
sync_dir(newname);
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
@@ -688,12 +692,12 @@ static int _vg_remove_file(struct format_instance *fid, struct volume_group *vg,
|
||||
return 0;
|
||||
}
|
||||
|
||||
sync();
|
||||
sync_dir(tc->path_live);
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
static int _scan_file(struct format_type *fmt)
|
||||
static int _scan_file(const struct format_type *fmt)
|
||||
{
|
||||
struct dirent *dirent;
|
||||
struct dir_list *dl;
|
||||
@@ -741,13 +745,13 @@ static int _scan_file(struct format_type *fmt)
|
||||
return 1;
|
||||
}
|
||||
|
||||
int vgname_from_mda(struct format_type *fmt, struct device_area *dev_area,
|
||||
int vgname_from_mda(const struct format_type *fmt, struct device_area *dev_area,
|
||||
char *buf, uint32_t size)
|
||||
{
|
||||
struct raw_locn *rlocn;
|
||||
struct mda_header *mdah;
|
||||
int already_open;
|
||||
int len;
|
||||
unsigned int len;
|
||||
int r = 0;
|
||||
|
||||
already_open = dev_is_open(dev_area->dev);
|
||||
@@ -766,13 +770,13 @@ int vgname_from_mda(struct format_type *fmt, struct device_area *dev_area,
|
||||
|
||||
while (rlocn->offset) {
|
||||
if (dev_read(dev_area->dev, dev_area->start + rlocn->offset,
|
||||
size, buf) != size) {
|
||||
size, buf) != (signed) size) {
|
||||
stack;
|
||||
goto out;
|
||||
}
|
||||
len = 0;
|
||||
while (buf[len] && !isspace(buf[len]) && buf[len] != '{' &&
|
||||
len < size - 1)
|
||||
len < (size - 1))
|
||||
len++;
|
||||
buf[len] = '\0';
|
||||
|
||||
@@ -796,7 +800,7 @@ int vgname_from_mda(struct format_type *fmt, struct device_area *dev_area,
|
||||
return r;
|
||||
}
|
||||
|
||||
static int _scan_raw(struct format_type *fmt)
|
||||
static int _scan_raw(const struct format_type *fmt)
|
||||
{
|
||||
struct raw_list *rl;
|
||||
struct list *rlh, *raw_list;
|
||||
@@ -824,14 +828,14 @@ static int _scan_raw(struct format_type *fmt)
|
||||
return 1;
|
||||
}
|
||||
|
||||
static int _scan(struct format_type *fmt)
|
||||
static int _scan(const struct format_type *fmt)
|
||||
{
|
||||
return (_scan_file(fmt) & _scan_raw(fmt));
|
||||
}
|
||||
|
||||
/* For orphan, creates new mdas according to policy.
|
||||
Always have an mda between end-of-label and PE_ALIGN boundary */
|
||||
static int _mda_setup(struct format_type *fmt,
|
||||
static int _mda_setup(const struct format_type *fmt,
|
||||
uint64_t pe_start, uint64_t pe_end,
|
||||
int pvmetadatacopies,
|
||||
uint64_t pvmetadatasize, struct list *mdas,
|
||||
@@ -887,8 +891,9 @@ static int _mda_setup(struct format_type *fmt,
|
||||
mda_size1))
|
||||
return 0;
|
||||
|
||||
if (!dev_zero(pv->dev, start1,
|
||||
mda_size1 > wipe_size ? wipe_size : mda_size1)) {
|
||||
if (!dev_zero((struct device *) pv->dev, start1,
|
||||
(size_t) (mda_size1 >
|
||||
wipe_size ? wipe_size : mda_size1))) {
|
||||
log_error("Failed to wipe new metadata area");
|
||||
return 0;
|
||||
}
|
||||
@@ -934,7 +939,8 @@ static int _mda_setup(struct format_type *fmt,
|
||||
mda_size2))
|
||||
return 0;
|
||||
if (!dev_zero(pv->dev, start2,
|
||||
mda_size1 > wipe_size ? wipe_size : mda_size1)) {
|
||||
(size_t) (mda_size1 >
|
||||
wipe_size ? wipe_size : mda_size1))) {
|
||||
log_error("Failed to wipe new metadata area");
|
||||
return 0;
|
||||
}
|
||||
@@ -947,7 +953,7 @@ static int _mda_setup(struct format_type *fmt,
|
||||
|
||||
/* Only for orphans */
|
||||
/* Set label_sector to -1 if rewriting existing label into same sector */
|
||||
static int _pv_write(struct format_type *fmt, struct physical_volume *pv,
|
||||
static int _pv_write(const struct format_type *fmt, struct physical_volume *pv,
|
||||
struct list *mdas, int64_t label_sector)
|
||||
{
|
||||
struct label *label;
|
||||
@@ -959,6 +965,8 @@ static int _pv_write(struct format_type *fmt, struct physical_volume *pv,
|
||||
struct mda_header *mdah = (struct mda_header *) buf;
|
||||
uint64_t adjustment;
|
||||
|
||||
/* FIXME Test mode don't update cache? */
|
||||
|
||||
if (!(info = cache_add(fmt->labeller, (char *) &pv->id, pv->dev,
|
||||
ORPHAN, NULL))) {
|
||||
stack;
|
||||
@@ -1017,7 +1025,9 @@ static int _pv_write(struct format_type *fmt, struct physical_volume *pv,
|
||||
pv->pe_start += (PE_ALIGN - adjustment);
|
||||
}
|
||||
}
|
||||
if (!add_da(fmt, NULL, &info->das, pv->pe_start << SECTOR_SHIFT, 0)) {
|
||||
if (!add_da
|
||||
(fmt, NULL, &info->das, pv->pe_start << SECTOR_SHIFT,
|
||||
__UINT64_C(0))) {
|
||||
stack;
|
||||
return 0;
|
||||
}
|
||||
@@ -1051,7 +1061,7 @@ static int _pv_write(struct format_type *fmt, struct physical_volume *pv,
|
||||
return 1;
|
||||
}
|
||||
|
||||
static int _get_pv_from_vg(struct format_type *fmt, const char *vg_name,
|
||||
static int _get_pv_from_vg(const struct format_type *fmt, const char *vg_name,
|
||||
const char *id, struct physical_volume *pv)
|
||||
{
|
||||
struct volume_group *vg;
|
||||
@@ -1071,7 +1081,7 @@ static int _get_pv_from_vg(struct format_type *fmt, const char *vg_name,
|
||||
|
||||
list_iterate(pvh, &vg->pvs) {
|
||||
pvl = list_item(pvh, struct pv_list);
|
||||
if (id_equal(&pvl->pv->id, (struct id *) id)) {
|
||||
if (id_equal(&pvl->pv->id, (const struct id *) id)) {
|
||||
memcpy(pv, pvl->pv, sizeof(*pv));
|
||||
return 1;
|
||||
}
|
||||
@@ -1103,7 +1113,7 @@ static int _add_raw(struct list *raw_list, struct device_area *dev_area)
|
||||
return 1;
|
||||
}
|
||||
|
||||
static int _pv_read(struct format_type *fmt, const char *pv_name,
|
||||
static int _pv_read(const struct format_type *fmt, const char *pv_name,
|
||||
struct physical_volume *pv, struct list *mdas)
|
||||
{
|
||||
struct label *label;
|
||||
@@ -1119,6 +1129,7 @@ static int _pv_read(struct format_type *fmt, const char *pv_name,
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* FIXME Optimise out repeated reading when cache lock held */
|
||||
if (!(label_read(dev, &label))) {
|
||||
stack;
|
||||
return 0;
|
||||
@@ -1208,7 +1219,7 @@ static void _free_raws(struct list *raw_list)
|
||||
}
|
||||
}
|
||||
|
||||
static void _destroy(struct format_type *fmt)
|
||||
static void _destroy(const struct format_type *fmt)
|
||||
{
|
||||
if (fmt->private) {
|
||||
_free_dirs(&((struct mda_lists *) fmt->private)->dirs);
|
||||
@@ -1216,7 +1227,7 @@ static void _destroy(struct format_type *fmt)
|
||||
dbg_free(fmt->private);
|
||||
}
|
||||
|
||||
dbg_free(fmt);
|
||||
dbg_free((void *) fmt);
|
||||
}
|
||||
|
||||
static struct metadata_area_ops _metadata_text_file_ops = {
|
||||
@@ -1241,7 +1252,7 @@ static struct metadata_area_ops _metadata_text_raw_ops = {
|
||||
};
|
||||
|
||||
/* pvmetadatasize in sectors */
|
||||
static int _pv_setup(struct format_type *fmt,
|
||||
static int _pv_setup(const struct format_type *fmt,
|
||||
uint64_t pe_start, uint32_t extent_count,
|
||||
uint32_t extent_size,
|
||||
int pvmetadatacopies,
|
||||
@@ -1332,8 +1343,8 @@ static int _pv_setup(struct format_type *fmt,
|
||||
}
|
||||
|
||||
/* NULL vgname means use only the supplied context e.g. an archive file */
|
||||
static struct format_instance *_create_text_instance(struct format_type *fmt,
|
||||
const char *vgname,
|
||||
static struct format_instance *_create_text_instance(const struct format_type
|
||||
*fmt, const char *vgname,
|
||||
void *context)
|
||||
{
|
||||
struct format_instance *fid;
|
||||
@@ -1406,6 +1417,7 @@ static struct format_instance *_create_text_instance(struct format_type *fmt,
|
||||
/* FIXME Allow multiple dev_areas inside area */
|
||||
memcpy(&mdac->area, &rl->dev_area, sizeof(mdac->area));
|
||||
mda->ops = &_metadata_text_raw_ops;
|
||||
/* FIXME MISTAKE? mda->metadata_locn = context; */
|
||||
list_add(&fid->metadata_areas, &mda->list);
|
||||
}
|
||||
|
||||
|
||||
@@ -36,19 +36,19 @@ struct format_type *create_text_format(struct cmd_context *cmd);
|
||||
void *create_text_context(struct cmd_context *cmd, const char *path,
|
||||
const char *desc);
|
||||
|
||||
struct labeller *text_labeller_create(struct format_type *fmt);
|
||||
struct labeller *text_labeller_create(const struct format_type *fmt);
|
||||
|
||||
int pvhdr_read(struct device *dev, char *buf);
|
||||
|
||||
int add_da(struct format_type *fmt, struct pool *mem, struct list *das,
|
||||
int add_da(const struct format_type *fmt, struct pool *mem, struct list *das,
|
||||
uint64_t start, uint64_t size);
|
||||
void del_das(struct list *das);
|
||||
|
||||
int add_mda(struct format_type *fmt, struct pool *mem, struct list *mdas,
|
||||
int add_mda(const struct format_type *fmt, struct pool *mem, struct list *mdas,
|
||||
struct device *dev, uint64_t start, uint64_t size);
|
||||
void del_mdas(struct list *mdas);
|
||||
|
||||
int vgname_from_mda(struct format_type *fmt, struct device_area *dev_area,
|
||||
int vgname_from_mda(const struct format_type *fmt, struct device_area *dev_area,
|
||||
char *buf, uint32_t size);
|
||||
|
||||
#endif
|
||||
|
||||
@@ -214,7 +214,7 @@ static int _read_segment(struct pool *mem, struct volume_group *vg,
|
||||
struct logical_volume *lv, struct config_node *sn,
|
||||
struct hash_table *pv_hash)
|
||||
{
|
||||
int s;
|
||||
unsigned int s;
|
||||
uint32_t stripes = 0;
|
||||
struct lv_segment *seg;
|
||||
struct config_node *cn;
|
||||
|
||||
@@ -80,7 +80,7 @@ static int _write(struct label *label, char *buf)
|
||||
return 1;
|
||||
}
|
||||
|
||||
int add_da(struct format_type *fmt, struct pool *mem, struct list *das,
|
||||
int add_da(const struct format_type *fmt, struct pool *mem, struct list *das,
|
||||
uint64_t start, uint64_t size)
|
||||
{
|
||||
struct data_area_list *dal;
|
||||
@@ -117,7 +117,7 @@ void del_das(struct list *das)
|
||||
}
|
||||
}
|
||||
|
||||
int add_mda(struct format_type *fmt, struct pool *mem, struct list *mdas,
|
||||
int add_mda(const struct format_type *fmt, struct pool *mem, struct list *mdas,
|
||||
struct device *dev, uint64_t start, uint64_t size)
|
||||
{
|
||||
/* FIXME List size restricted by pv_header SECTOR_SIZE */
|
||||
@@ -264,7 +264,7 @@ struct label_ops _text_ops = {
|
||||
destroy:_destroy
|
||||
};
|
||||
|
||||
struct labeller *text_labeller_create(struct format_type *fmt)
|
||||
struct labeller *text_labeller_create(const struct format_type *fmt)
|
||||
{
|
||||
struct labeller *l;
|
||||
|
||||
@@ -274,7 +274,7 @@ struct labeller *text_labeller_create(struct format_type *fmt)
|
||||
}
|
||||
|
||||
l->ops = &_text_ops;
|
||||
l->private = (void *) fmt;
|
||||
l->private = (const void *) fmt;
|
||||
|
||||
return l;
|
||||
}
|
||||
|
||||
@@ -117,7 +117,8 @@ static struct labeller *_find_labeller(struct device *dev, char *buf,
|
||||
return NULL;
|
||||
}
|
||||
|
||||
if (dev_read(dev, 0, LABEL_SCAN_SIZE, readbuf) != LABEL_SCAN_SIZE) {
|
||||
if (dev_read(dev, __UINT64_C(0), LABEL_SCAN_SIZE, readbuf) !=
|
||||
LABEL_SCAN_SIZE) {
|
||||
log_debug("%s: Failed to read label area", dev_name(dev));
|
||||
goto out;
|
||||
}
|
||||
@@ -204,7 +205,8 @@ int label_remove(struct device *dev)
|
||||
return 0;
|
||||
}
|
||||
|
||||
if (dev_read(dev, 0, LABEL_SCAN_SIZE, readbuf) != LABEL_SCAN_SIZE) {
|
||||
if (dev_read(dev, __UINT64_C(0), LABEL_SCAN_SIZE, readbuf) !=
|
||||
LABEL_SCAN_SIZE) {
|
||||
log_debug("%s: Failed to read label area", dev_name(dev));
|
||||
goto out;
|
||||
}
|
||||
|
||||
@@ -76,7 +76,7 @@ struct label_ops {
|
||||
|
||||
struct labeller {
|
||||
struct label_ops *ops;
|
||||
void *private;
|
||||
const void *private;
|
||||
};
|
||||
|
||||
int label_init(void);
|
||||
|
||||
@@ -72,7 +72,7 @@ static int _release_lock(const char *file)
|
||||
return 0;
|
||||
}
|
||||
|
||||
void fin_file_locking(void)
|
||||
static void _fin_file_locking(void)
|
||||
{
|
||||
_release_lock(NULL);
|
||||
}
|
||||
@@ -90,7 +90,7 @@ static void _remove_ctrl_c_handler()
|
||||
_handler_installed = 0;
|
||||
}
|
||||
|
||||
void _trap_ctrl_c(int signal)
|
||||
static void _trap_ctrl_c(int sig)
|
||||
{
|
||||
_remove_ctrl_c_handler();
|
||||
log_error("CTRL-c detected: giving up waiting for lock");
|
||||
@@ -183,7 +183,8 @@ static int _lock_file(const char *file, int flags)
|
||||
return 0;
|
||||
}
|
||||
|
||||
int file_lock_resource(struct cmd_context *cmd, const char *resource, int flags)
|
||||
static int _file_lock_resource(struct cmd_context *cmd, const char *resource,
|
||||
int flags)
|
||||
{
|
||||
char lockfile[PATH_MAX];
|
||||
|
||||
@@ -231,8 +232,8 @@ int file_lock_resource(struct cmd_context *cmd, const char *resource, int flags)
|
||||
|
||||
int init_file_locking(struct locking_type *locking, struct config_tree *cf)
|
||||
{
|
||||
locking->lock_resource = file_lock_resource;
|
||||
locking->fin_locking = fin_file_locking;
|
||||
locking->lock_resource = _file_lock_resource;
|
||||
locking->fin_locking = _fin_file_locking;
|
||||
|
||||
/* Get lockfile directory from config file */
|
||||
strncpy(_lock_dir, find_config_str(cf->root, "global/locking_dir",
|
||||
|
||||
@@ -14,18 +14,30 @@
|
||||
|
||||
#include <signal.h>
|
||||
#include <sys/stat.h>
|
||||
#include <sys/mman.h>
|
||||
#include <limits.h>
|
||||
|
||||
static struct locking_type _locking;
|
||||
static sigset_t _oldset;
|
||||
|
||||
static int _lock_count = 0; /* Number of locks held */
|
||||
static int _write_lock_held = 0;
|
||||
static int _signals_blocked = 0;
|
||||
|
||||
static void _block_signals(void)
|
||||
static void _block_signals(int flags)
|
||||
{
|
||||
sigset_t set;
|
||||
|
||||
if (!_write_lock_held && (flags & LCK_SCOPE_MASK) == LCK_LV &&
|
||||
(flags & LCK_TYPE_MASK) == LCK_WRITE) {
|
||||
if (mlockall(MCL_CURRENT | MCL_FUTURE))
|
||||
log_sys_error("mlockall", "");
|
||||
else {
|
||||
log_very_verbose("Locking memory");
|
||||
_write_lock_held = 1;
|
||||
}
|
||||
}
|
||||
|
||||
if (_signals_blocked)
|
||||
return;
|
||||
|
||||
@@ -46,6 +58,15 @@ static void _block_signals(void)
|
||||
|
||||
static void _unblock_signals(void)
|
||||
{
|
||||
if (!_lock_count && _write_lock_held) {
|
||||
if (munlockall()) {
|
||||
log_very_verbose("Unlocking memory");
|
||||
log_sys_error("munlockall", "");
|
||||
}
|
||||
|
||||
_write_lock_held = 0;
|
||||
}
|
||||
|
||||
/* Don't unblock signals while any locks are held */
|
||||
if (!_signals_blocked || _lock_count)
|
||||
return;
|
||||
@@ -147,9 +168,9 @@ int check_lvm1_vg_inactive(struct cmd_context *cmd, const char *vgname)
|
||||
* VG locking is by VG name.
|
||||
* FIXME This should become VG uuid.
|
||||
*/
|
||||
int _lock_vol(struct cmd_context *cmd, const char *resource, int flags)
|
||||
static int _lock_vol(struct cmd_context *cmd, const char *resource, int flags)
|
||||
{
|
||||
_block_signals();
|
||||
_block_signals(flags);
|
||||
|
||||
if (!(_locking.lock_resource(cmd, resource, flags))) {
|
||||
_unblock_signals();
|
||||
@@ -174,7 +195,7 @@ int lock_vol(struct cmd_context *cmd, const char *vol, int flags)
|
||||
return 0;
|
||||
case LCK_LV:
|
||||
/* Suspend LV if it's active. */
|
||||
strncpy(resource, (char *) vol, sizeof(resource));
|
||||
strncpy(resource, vol, sizeof(resource));
|
||||
break;
|
||||
default:
|
||||
log_error("Unrecognised lock scope: %d",
|
||||
|
||||
@@ -8,11 +8,10 @@
|
||||
#include "metadata.h"
|
||||
#include "config.h"
|
||||
|
||||
typedef int (*lock_resource_fn)(struct cmd_context *cmd, const char *resource,
|
||||
int flags);
|
||||
|
||||
typedef void (*fin_lock_fn)(void);
|
||||
typedef int (*lock_resource_fn) (struct cmd_context * cmd, const char *resource,
|
||||
int flags);
|
||||
|
||||
typedef void (*fin_lock_fn) (void);
|
||||
|
||||
struct locking_type {
|
||||
lock_resource_fn lock_resource;
|
||||
@@ -20,7 +19,6 @@ struct locking_type {
|
||||
fin_lock_fn fin_locking;
|
||||
};
|
||||
|
||||
|
||||
/*
|
||||
* Locking types
|
||||
*/
|
||||
@@ -29,4 +27,3 @@ int init_no_locking(struct locking_type *locking, struct config_tree *cf);
|
||||
int init_file_locking(struct locking_type *locking, struct config_tree *cf);
|
||||
|
||||
int init_external_locking(struct locking_type *locking, struct config_tree *cf);
|
||||
|
||||
|
||||
@@ -28,8 +28,8 @@
|
||||
*
|
||||
*/
|
||||
|
||||
#include <stdio.h> /* FILE */
|
||||
#include <string.h> /* strerror() */
|
||||
#include <stdio.h> /* FILE */
|
||||
#include <string.h> /* strerror() */
|
||||
#include <errno.h>
|
||||
|
||||
#define _LOG_DEBUG 7
|
||||
@@ -65,7 +65,7 @@ int ignorelockingfailure(void);
|
||||
void log_suppress(int suppress);
|
||||
|
||||
void print_log(int level, const char *file, int line, const char *format, ...)
|
||||
__attribute__ (( format (printf, 4, 5) ));
|
||||
__attribute__ ((format(printf, 4, 5)));
|
||||
|
||||
#define plog(l, x...) print_log(l, __FILE__, __LINE__ , ## x)
|
||||
|
||||
@@ -90,4 +90,3 @@ void print_log(int level, const char *file, int line, const char *format, ...)
|
||||
log_info("%s: %s failed: %s", y, x, strerror(errno))
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
@@ -10,15 +10,13 @@
|
||||
#include "lvm-string.h"
|
||||
#include "toolcontext.h"
|
||||
|
||||
#include <assert.h>
|
||||
|
||||
/*
|
||||
* These functions adjust the pe counts in pv's
|
||||
* after we've added or removed segments.
|
||||
*/
|
||||
static void _get_extents(struct lv_segment *seg)
|
||||
{
|
||||
int s, count;
|
||||
unsigned int s, count;
|
||||
struct physical_volume *pv;
|
||||
|
||||
for (s = 0; s < seg->stripes; s++) {
|
||||
@@ -30,7 +28,7 @@ static void _get_extents(struct lv_segment *seg)
|
||||
|
||||
static void _put_extents(struct lv_segment *seg)
|
||||
{
|
||||
int s, count;
|
||||
unsigned int s, count;
|
||||
struct physical_volume *pv;
|
||||
|
||||
for (s = 0; s < seg->stripes; s++) {
|
||||
@@ -42,7 +40,7 @@ static void _put_extents(struct lv_segment *seg)
|
||||
}
|
||||
}
|
||||
|
||||
static struct lv_segment *_alloc_segment(struct pool *mem, int stripes)
|
||||
static struct lv_segment *_alloc_segment(struct pool *mem, uint32_t stripes)
|
||||
{
|
||||
struct lv_segment *seg;
|
||||
uint32_t len = sizeof(*seg) + (stripes * sizeof(seg->area[0]));
|
||||
@@ -57,9 +55,9 @@ static struct lv_segment *_alloc_segment(struct pool *mem, int stripes)
|
||||
|
||||
static int _alloc_stripe_area(struct logical_volume *lv, uint32_t stripes,
|
||||
uint32_t stripe_size,
|
||||
struct pv_area **areas, uint32_t *index)
|
||||
struct pv_area **areas, uint32_t *ix)
|
||||
{
|
||||
uint32_t count = lv->le_count - *index;
|
||||
uint32_t count = lv->le_count - *ix;
|
||||
uint32_t per_area = count / stripes;
|
||||
uint32_t smallest = areas[stripes - 1]->count;
|
||||
uint32_t s;
|
||||
@@ -75,7 +73,7 @@ static int _alloc_stripe_area(struct logical_volume *lv, uint32_t stripes,
|
||||
|
||||
seg->lv = lv;
|
||||
seg->type = SEG_STRIPED;
|
||||
seg->le = *index;
|
||||
seg->le = *ix;
|
||||
seg->len = per_area * stripes;
|
||||
seg->stripes = stripes;
|
||||
seg->stripe_size = stripe_size;
|
||||
@@ -88,14 +86,14 @@ static int _alloc_stripe_area(struct logical_volume *lv, uint32_t stripes,
|
||||
}
|
||||
|
||||
list_add(&lv->segments, &seg->list);
|
||||
*index += seg->len;
|
||||
*ix += seg->len;
|
||||
return 1;
|
||||
}
|
||||
|
||||
static int _comp_area(const void *l, const void *r)
|
||||
{
|
||||
struct pv_area *lhs = *((struct pv_area **) l);
|
||||
struct pv_area *rhs = *((struct pv_area **) r);
|
||||
const struct pv_area *lhs = *((const struct pv_area **) l);
|
||||
const struct pv_area *rhs = *((const struct pv_area **) r);
|
||||
|
||||
if (lhs->count < rhs->count)
|
||||
return 1;
|
||||
@@ -113,7 +111,7 @@ static int _alloc_striped(struct logical_volume *lv,
|
||||
int r = 0;
|
||||
struct list *pvmh;
|
||||
struct pv_area **areas;
|
||||
int pv_count = 0, index;
|
||||
unsigned int pv_count = 0, ix;
|
||||
struct pv_map *pvm;
|
||||
size_t len;
|
||||
|
||||
@@ -129,18 +127,17 @@ static int _alloc_striped(struct logical_volume *lv,
|
||||
|
||||
while (allocated != lv->le_count) {
|
||||
|
||||
index = 0;
|
||||
ix = 0;
|
||||
list_iterate(pvmh, pvms) {
|
||||
pvm = list_item(pvmh, struct pv_map);
|
||||
|
||||
if (list_empty(&pvm->areas))
|
||||
continue;
|
||||
|
||||
areas[index++] = list_item(pvm->areas.n,
|
||||
struct pv_area);
|
||||
areas[ix++] = list_item(pvm->areas.n, struct pv_area);
|
||||
}
|
||||
|
||||
if (index < stripes) {
|
||||
if (ix < stripes) {
|
||||
log_error("Insufficient allocatable extents suitable "
|
||||
"for striping for logical volume "
|
||||
"%s: %u required", lv->name, lv->le_count);
|
||||
@@ -148,7 +145,7 @@ static int _alloc_striped(struct logical_volume *lv,
|
||||
}
|
||||
|
||||
/* sort the areas so we allocate from the biggest */
|
||||
qsort(areas, index, sizeof(*areas), _comp_area);
|
||||
qsort(areas, ix, sizeof(*areas), _comp_area);
|
||||
|
||||
if (!_alloc_stripe_area(lv, stripes, stripe_size, areas,
|
||||
&allocated)) {
|
||||
@@ -169,14 +166,14 @@ static int _alloc_striped(struct logical_volume *lv,
|
||||
* the complete area then the area is split, otherwise the area
|
||||
* is unlinked from the pv_map.
|
||||
*/
|
||||
static int _alloc_linear_area(struct logical_volume *lv, uint32_t *index,
|
||||
static int _alloc_linear_area(struct logical_volume *lv, uint32_t *ix,
|
||||
struct pv_map *map, struct pv_area *pva)
|
||||
{
|
||||
uint32_t count, remaining;
|
||||
struct lv_segment *seg;
|
||||
|
||||
count = pva->count;
|
||||
remaining = lv->le_count - *index;
|
||||
remaining = lv->le_count - *ix;
|
||||
if (count > remaining)
|
||||
count = remaining;
|
||||
|
||||
@@ -187,7 +184,7 @@ static int _alloc_linear_area(struct logical_volume *lv, uint32_t *index,
|
||||
|
||||
seg->lv = lv;
|
||||
seg->type = SEG_STRIPED;
|
||||
seg->le = *index;
|
||||
seg->le = *ix;
|
||||
seg->len = count;
|
||||
seg->stripe_size = 0;
|
||||
seg->stripes = 1;
|
||||
@@ -197,7 +194,7 @@ static int _alloc_linear_area(struct logical_volume *lv, uint32_t *index,
|
||||
list_add(&lv->segments, &seg->list);
|
||||
|
||||
consume_pv_area(pva, count);
|
||||
*index += count;
|
||||
*ix += count;
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
||||
@@ -14,7 +14,7 @@
|
||||
*/
|
||||
static int _merge(struct lv_segment *first, struct lv_segment *second)
|
||||
{
|
||||
int s;
|
||||
unsigned int s;
|
||||
uint32_t width;
|
||||
|
||||
if (!first ||
|
||||
|
||||
@@ -12,8 +12,8 @@
|
||||
#include "lvm-string.h"
|
||||
#include "cache.h"
|
||||
|
||||
int _add_pv_to_vg(struct format_instance *fid, struct volume_group *vg,
|
||||
const char *pv_name)
|
||||
static int _add_pv_to_vg(struct format_instance *fid, struct volume_group *vg,
|
||||
const char *pv_name)
|
||||
{
|
||||
struct pv_list *pvl;
|
||||
struct physical_volume *pv;
|
||||
@@ -68,7 +68,8 @@ int _add_pv_to_vg(struct format_instance *fid, struct volume_group *vg,
|
||||
|
||||
pv->pe_alloc_count = 0;
|
||||
|
||||
if (!fid->fmt->ops->pv_setup(fid->fmt, 0, 0, vg->extent_size, 0, 0,
|
||||
if (!fid->fmt->ops->pv_setup(fid->fmt, __UINT64_C(0), 0,
|
||||
vg->extent_size, 0, __UINT64_C(0),
|
||||
&fid->metadata_areas, pv, vg)) {
|
||||
log_error("Format-specific setup of physical volume '%s' "
|
||||
"failed.", pv_name);
|
||||
@@ -98,6 +99,30 @@ int _add_pv_to_vg(struct format_instance *fid, struct volume_group *vg,
|
||||
return 1;
|
||||
}
|
||||
|
||||
int vg_rename(struct cmd_context *cmd, struct volume_group *vg,
|
||||
const char *new_name)
|
||||
{
|
||||
struct pool *mem = cmd->mem;
|
||||
struct physical_volume *pv;
|
||||
struct list *pvh;
|
||||
|
||||
if (!(vg->name = pool_strdup(mem, new_name))) {
|
||||
log_error("vg->name allocation failed for '%s'", new_name);
|
||||
return 0;
|
||||
}
|
||||
|
||||
list_iterate(pvh, &vg->pvs) {
|
||||
pv = list_item(pvh, struct pv_list)->pv;
|
||||
if (!(pv->vg_name = pool_strdup(mem, new_name))) {
|
||||
log_error("pv->vg_name allocation failed for '%s'",
|
||||
dev_name(pv->dev));
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
int vg_extend(struct format_instance *fid,
|
||||
struct volume_group *vg, int pv_count, char **pv_names)
|
||||
{
|
||||
@@ -118,7 +143,7 @@ int vg_extend(struct format_instance *fid,
|
||||
|
||||
const char *strip_dir(const char *vg_name, const char *dev_dir)
|
||||
{
|
||||
int len = strlen(dev_dir);
|
||||
size_t len = strlen(dev_dir);
|
||||
if (!strncmp(vg_name, dev_dir, len))
|
||||
vg_name += len;
|
||||
|
||||
@@ -126,8 +151,8 @@ const char *strip_dir(const char *vg_name, const char *dev_dir)
|
||||
}
|
||||
|
||||
struct volume_group *vg_create(struct cmd_context *cmd, const char *vg_name,
|
||||
uint32_t extent_size, int max_pv, int max_lv,
|
||||
int pv_count, char **pv_names)
|
||||
uint32_t extent_size, uint32_t max_pv,
|
||||
uint32_t max_lv, int pv_count, char **pv_names)
|
||||
{
|
||||
struct volume_group *vg;
|
||||
struct pool *mem = cmd->mem;
|
||||
@@ -207,7 +232,7 @@ struct volume_group *vg_create(struct cmd_context *cmd, const char *vg_name,
|
||||
}
|
||||
|
||||
/* Sizes in sectors */
|
||||
struct physical_volume *pv_create(struct format_type *fmt,
|
||||
struct physical_volume *pv_create(const struct format_type *fmt,
|
||||
struct device *dev,
|
||||
struct id *id, uint64_t size,
|
||||
uint64_t pe_start,
|
||||
@@ -231,12 +256,11 @@ struct physical_volume *pv_create(struct format_type *fmt,
|
||||
|
||||
pv->dev = dev;
|
||||
|
||||
if (!(pv->vg_name = pool_alloc(mem, NAME_LEN))) {
|
||||
if (!(pv->vg_name = pool_zalloc(mem, NAME_LEN))) {
|
||||
stack;
|
||||
goto bad;
|
||||
}
|
||||
|
||||
*pv->vg_name = 0;
|
||||
pv->status = ALLOCATABLE_PV;
|
||||
|
||||
if (!dev_get_size(pv->dev, &pv->size)) {
|
||||
@@ -330,7 +354,8 @@ struct lv_list *find_lv_in_vg(struct volume_group *vg, const char *lv_name)
|
||||
return NULL;
|
||||
}
|
||||
|
||||
struct lv_list *find_lv_in_vg_by_lvid(struct volume_group *vg, union lvid *lvid)
|
||||
struct lv_list *find_lv_in_vg_by_lvid(struct volume_group *vg,
|
||||
const union lvid *lvid)
|
||||
{
|
||||
struct list *lvh;
|
||||
struct lv_list *lvl;
|
||||
@@ -429,7 +454,7 @@ int vg_write(struct volume_group *vg)
|
||||
}
|
||||
|
||||
/* Make orphan PVs look like a VG */
|
||||
struct volume_group *_vg_read_orphans(struct cmd_context *cmd)
|
||||
static struct volume_group *_vg_read_orphans(struct cmd_context *cmd)
|
||||
{
|
||||
struct cache_vginfo *vginfo;
|
||||
struct list *ih;
|
||||
@@ -484,11 +509,11 @@ struct volume_group *vg_read(struct cmd_context *cmd, const char *vgname,
|
||||
int *consistent)
|
||||
{
|
||||
struct format_instance *fid;
|
||||
struct format_type *fmt;
|
||||
struct volume_group *vg, *correct_vg;
|
||||
const struct format_type *fmt;
|
||||
struct volume_group *vg, *correct_vg = NULL;
|
||||
struct list *mdah;
|
||||
struct metadata_area *mda;
|
||||
int inconsistent = 0, first_time = 1;
|
||||
int inconsistent = 0;
|
||||
|
||||
if (!*vgname) {
|
||||
*consistent = 1;
|
||||
@@ -521,9 +546,8 @@ struct volume_group *vg_read(struct cmd_context *cmd, const char *vgname,
|
||||
inconsistent = 1;
|
||||
continue;
|
||||
}
|
||||
if (first_time) {
|
||||
if (!correct_vg) {
|
||||
correct_vg = vg;
|
||||
first_time = 0;
|
||||
continue;
|
||||
}
|
||||
/* FIXME Also ensure contents same - checksum compare? */
|
||||
@@ -535,7 +559,7 @@ struct volume_group *vg_read(struct cmd_context *cmd, const char *vgname,
|
||||
}
|
||||
|
||||
/* Failed to find VG */
|
||||
if (first_time) {
|
||||
if (!correct_vg) {
|
||||
stack;
|
||||
return NULL;
|
||||
}
|
||||
@@ -624,9 +648,9 @@ struct logical_volume *lv_from_lvid(struct cmd_context *cmd, const char *lvid_s)
|
||||
{
|
||||
struct lv_list *lvl;
|
||||
struct volume_group *vg;
|
||||
union lvid *lvid;
|
||||
const union lvid *lvid;
|
||||
|
||||
lvid = (union lvid *) lvid_s;
|
||||
lvid = (const union lvid *) lvid_s;
|
||||
|
||||
log_very_verbose("Finding volume group for uuid %s", lvid_s);
|
||||
if (!(vg = vg_read_by_vgid(cmd, lvid->id[0].uuid))) {
|
||||
|
||||
@@ -14,6 +14,7 @@
|
||||
#include "dev-cache.h"
|
||||
#include "list.h"
|
||||
#include "uuid.h"
|
||||
|
||||
#include <sys/types.h>
|
||||
#include <asm/page.h>
|
||||
|
||||
@@ -21,7 +22,6 @@
|
||||
#define MAX_STRIPES 128
|
||||
#define SECTOR_SHIFT 9L
|
||||
#define SECTOR_SIZE ( 1L << SECTOR_SHIFT )
|
||||
#define STRIPE_SIZE_DEFAULT 16 /* 16KB */
|
||||
#define STRIPE_SIZE_MIN ( PAGE_SIZE >> SECTOR_SHIFT) /* PAGESIZE in sectors */
|
||||
#define STRIPE_SIZE_MAX ( 512L * 1024L >> SECTOR_SHIFT) /* 512 KB in sectors */
|
||||
#define PV_MIN_SIZE ( 512L * 1024L >> SECTOR_SHIFT) /* 512 KB in sectors */
|
||||
@@ -84,14 +84,14 @@ struct format_type {
|
||||
struct physical_volume {
|
||||
struct id id;
|
||||
struct device *dev;
|
||||
struct format_type *fmt;
|
||||
char *vg_name;
|
||||
const struct format_type *fmt;
|
||||
const char *vg_name;
|
||||
|
||||
uint32_t status;
|
||||
uint64_t size;
|
||||
|
||||
/* physical extents */
|
||||
uint64_t pe_size;
|
||||
uint32_t pe_size;
|
||||
uint64_t pe_start;
|
||||
uint32_t pe_count;
|
||||
uint32_t pe_alloc_count;
|
||||
@@ -134,7 +134,7 @@ struct metadata_area {
|
||||
};
|
||||
|
||||
struct format_instance {
|
||||
struct format_type *fmt;
|
||||
const struct format_type *fmt;
|
||||
struct list metadata_areas; /* e.g. metadata locations */
|
||||
};
|
||||
|
||||
@@ -252,19 +252,19 @@ struct format_handler {
|
||||
/*
|
||||
* Scan any metadata areas that aren't referenced in PV labels
|
||||
*/
|
||||
int (*scan) (struct format_type * fmt);
|
||||
int (*scan) (const struct format_type * fmt);
|
||||
|
||||
/*
|
||||
* Return PV with given path.
|
||||
*/
|
||||
int (*pv_read) (struct format_type * fmt, const char *pv_name,
|
||||
int (*pv_read) (const struct format_type * fmt, const char *pv_name,
|
||||
struct physical_volume * pv, struct list * mdas);
|
||||
|
||||
/*
|
||||
* Tweak an already filled out a pv ready for importing into a
|
||||
* vg. eg. pe_count is format specific.
|
||||
*/
|
||||
int (*pv_setup) (struct format_type * fmt,
|
||||
int (*pv_setup) (const struct format_type * fmt,
|
||||
uint64_t pe_start, uint32_t extent_count,
|
||||
uint32_t extent_size,
|
||||
int pvmetadatacopies,
|
||||
@@ -275,8 +275,9 @@ struct format_handler {
|
||||
* Write a PV structure to disk. Fails if the PV is in a VG ie
|
||||
* pv->vg_name must be null.
|
||||
*/
|
||||
int (*pv_write) (struct format_type * fmt, struct physical_volume * pv,
|
||||
struct list * mdas, int64_t label_sector);
|
||||
int (*pv_write) (const struct format_type * fmt,
|
||||
struct physical_volume * pv, struct list * mdas,
|
||||
int64_t label_sector);
|
||||
|
||||
/*
|
||||
* Tweak an already filled out a lv eg, check there
|
||||
@@ -294,8 +295,8 @@ struct format_handler {
|
||||
/*
|
||||
* Create format instance with a particular metadata area
|
||||
*/
|
||||
struct format_instance *(*create_instance) (struct format_type * fmt,
|
||||
const char *vgname,
|
||||
struct format_instance *(*create_instance) (const struct format_type *
|
||||
fmt, const char *vgname,
|
||||
void *context);
|
||||
|
||||
/*
|
||||
@@ -306,7 +307,7 @@ struct format_handler {
|
||||
/*
|
||||
* Destructor for format type
|
||||
*/
|
||||
void (*destroy) (struct format_type * fmt);
|
||||
void (*destroy) (const struct format_type * fmt);
|
||||
};
|
||||
|
||||
/*
|
||||
@@ -328,7 +329,7 @@ int pv_write(struct cmd_context *cmd, struct physical_volume *pv,
|
||||
|
||||
/* pe_start and pe_end relate to any existing data so that new metadata
|
||||
* areas can avoid overlap */
|
||||
struct physical_volume *pv_create(struct format_type *fmt,
|
||||
struct physical_volume *pv_create(const struct format_type *fmt,
|
||||
struct device *dev,
|
||||
struct id *id,
|
||||
uint64_t size,
|
||||
@@ -339,10 +340,11 @@ struct physical_volume *pv_create(struct format_type *fmt,
|
||||
uint64_t pvmetadatasize, struct list *mdas);
|
||||
|
||||
struct volume_group *vg_create(struct cmd_context *cmd, const char *name,
|
||||
uint32_t extent_size, int max_pv, int max_lv,
|
||||
int pv_count, char **pv_names);
|
||||
uint32_t extent_size, uint32_t max_pv,
|
||||
uint32_t max_lv, int pv_count, char **pv_names);
|
||||
int vg_remove(struct volume_group *vg);
|
||||
|
||||
int vg_rename(struct cmd_context *cmd, struct volume_group *vg,
|
||||
const char *new_name);
|
||||
int vg_extend(struct format_instance *fi, struct volume_group *vg,
|
||||
int pv_count, char **pv_names);
|
||||
|
||||
@@ -385,7 +387,7 @@ struct physical_volume *find_pv_in_vg_by_uuid(struct volume_group *vg,
|
||||
/* Find an LV within a given VG */
|
||||
struct lv_list *find_lv_in_vg(struct volume_group *vg, const char *lv_name);
|
||||
struct lv_list *find_lv_in_vg_by_lvid(struct volume_group *vg,
|
||||
union lvid *lvid);
|
||||
const union lvid *lvid);
|
||||
|
||||
/* Return the VG that contains a given LV (based on path given in lv_name) */
|
||||
/* or environment var */
|
||||
@@ -419,12 +421,12 @@ int lv_merge_segments(struct logical_volume *lv);
|
||||
/*
|
||||
* Useful functions for managing snapshots.
|
||||
*/
|
||||
int lv_is_origin(struct logical_volume *lv);
|
||||
int lv_is_cow(struct logical_volume *lv);
|
||||
int lv_is_origin(const struct logical_volume *lv);
|
||||
int lv_is_cow(const struct logical_volume *lv);
|
||||
|
||||
struct snapshot *find_cow(struct logical_volume *lv);
|
||||
struct snapshot *find_origin(struct logical_volume *lv);
|
||||
struct list *find_snapshots(struct logical_volume *lv);
|
||||
struct snapshot *find_cow(const struct logical_volume *lv);
|
||||
struct snapshot *find_origin(const struct logical_volume *lv);
|
||||
struct list *find_snapshots(const struct logical_volume *lv);
|
||||
|
||||
int vg_add_snapshot(struct logical_volume *origin,
|
||||
struct logical_volume *cow,
|
||||
|
||||
@@ -8,8 +8,6 @@
|
||||
#include "pv_map.h"
|
||||
#include "hash.h"
|
||||
|
||||
#include <assert.h>
|
||||
|
||||
static int _create_maps(struct pool *mem, struct list *pvs, struct list *maps)
|
||||
{
|
||||
struct list *tmp;
|
||||
@@ -42,7 +40,7 @@ static int _create_maps(struct pool *mem, struct list *pvs, struct list *maps)
|
||||
}
|
||||
|
||||
static int _set_allocated(struct hash_table *hash,
|
||||
struct physical_volume *pv, int pe)
|
||||
struct physical_volume *pv, uint32_t pe)
|
||||
{
|
||||
struct pv_map *pvm;
|
||||
|
||||
@@ -124,7 +122,7 @@ static int _fill_bitsets(struct volume_group *vg, struct list *maps)
|
||||
static void _insert_area(struct list *head, struct pv_area *a)
|
||||
{
|
||||
struct list *pvah;
|
||||
struct pv_area *pva;
|
||||
struct pv_area *pva = NULL;
|
||||
|
||||
if (list_empty(head)) {
|
||||
list_add(head, &a->list);
|
||||
|
||||
@@ -8,7 +8,7 @@
|
||||
#include "metadata.h"
|
||||
#include "toolcontext.h"
|
||||
|
||||
int lv_is_origin(struct logical_volume *lv)
|
||||
int lv_is_origin(const struct logical_volume *lv)
|
||||
{
|
||||
struct list *slh;
|
||||
struct snapshot *s;
|
||||
@@ -22,7 +22,7 @@ int lv_is_origin(struct logical_volume *lv)
|
||||
return 0;
|
||||
}
|
||||
|
||||
int lv_is_cow(struct logical_volume *lv)
|
||||
int lv_is_cow(const struct logical_volume *lv)
|
||||
{
|
||||
struct list *slh;
|
||||
struct snapshot *s;
|
||||
@@ -36,7 +36,7 @@ int lv_is_cow(struct logical_volume *lv)
|
||||
return 0;
|
||||
}
|
||||
|
||||
struct snapshot *find_origin(struct logical_volume *lv)
|
||||
struct snapshot *find_origin(const struct logical_volume *lv)
|
||||
{
|
||||
struct list *slh;
|
||||
struct snapshot *s;
|
||||
@@ -50,7 +50,7 @@ struct snapshot *find_origin(struct logical_volume *lv)
|
||||
return NULL;
|
||||
}
|
||||
|
||||
struct snapshot *find_cow(struct logical_volume *lv)
|
||||
struct snapshot *find_cow(const struct logical_volume *lv)
|
||||
{
|
||||
struct list *slh;
|
||||
struct snapshot *s;
|
||||
@@ -64,7 +64,7 @@ struct snapshot *find_cow(struct logical_volume *lv)
|
||||
return NULL;
|
||||
}
|
||||
|
||||
struct list *find_snapshots(struct logical_volume *lv)
|
||||
struct list *find_snapshots(const struct logical_volume *lv)
|
||||
{
|
||||
struct list *slh;
|
||||
struct list *snaplist;
|
||||
@@ -137,6 +137,7 @@ int vg_add_snapshot(struct logical_volume *origin,
|
||||
cow->status &= ~VISIBLE_LV;
|
||||
sl->snapshot = s;
|
||||
list_add(&origin->vg->snapshots, &sl->list);
|
||||
origin->vg->snapshot_count++;
|
||||
|
||||
return 1;
|
||||
}
|
||||
@@ -151,6 +152,7 @@ int vg_remove_snapshot(struct volume_group *vg, struct logical_volume *cow)
|
||||
|
||||
if (sl->snapshot->cow == cow) {
|
||||
list_del(slh);
|
||||
vg->snapshot_count--;
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -5,7 +5,8 @@
|
||||
*/
|
||||
|
||||
#include "lib.h"
|
||||
#include "lvm-types.h"
|
||||
|
||||
#include "crc.h"
|
||||
|
||||
/* Calculate an endian-independent CRC of supplied buffer */
|
||||
uint32_t calc_crc(uint32_t initial, void *buf, uint32_t size)
|
||||
|
||||
@@ -5,7 +5,7 @@
|
||||
*/
|
||||
|
||||
/*
|
||||
* This file must be included first by every source file.
|
||||
* This file must be included first by every library source file.
|
||||
*/
|
||||
#ifndef _LVM_LIB_H
|
||||
#define _LVM_LIB_H
|
||||
@@ -15,4 +15,6 @@
|
||||
#include "log.h"
|
||||
#include "dbg_malloc.h"
|
||||
|
||||
#include <assert.h>
|
||||
|
||||
#endif
|
||||
|
||||
@@ -194,3 +194,35 @@ int is_empty_dir(const char *dir)
|
||||
|
||||
return dirent ? 0 : 1;
|
||||
}
|
||||
|
||||
void sync_dir(const char *file)
|
||||
{
|
||||
int fd;
|
||||
char *dir, *c;
|
||||
|
||||
if (!(dir = dbg_strdup(file))) {
|
||||
log_error("sync_dir failed in strdup");
|
||||
return;
|
||||
}
|
||||
|
||||
if (!dir_exists(dir)) {
|
||||
c = dir + strlen(dir);
|
||||
while (*c != '/' && c > dir)
|
||||
c--;
|
||||
|
||||
*c = '\0';
|
||||
}
|
||||
|
||||
if ((fd = open(dir, O_RDONLY)) == -1) {
|
||||
log_sys_error("open", dir);
|
||||
goto out;
|
||||
}
|
||||
|
||||
if (fsync(fd) == -1)
|
||||
log_sys_error("fsync", dir);
|
||||
|
||||
close(fd);
|
||||
|
||||
out:
|
||||
dbg_free(dir);
|
||||
}
|
||||
|
||||
@@ -32,3 +32,6 @@ int is_empty_dir(const char *dir);
|
||||
* if directory was successfully created (or already exists), else 0.
|
||||
*/
|
||||
int create_dir(const char *dir);
|
||||
|
||||
/* Sync directory changes */
|
||||
void sync_dir(const char *file);
|
||||
|
||||
31
lib/misc/lvm-string.c
Normal file
31
lib/misc/lvm-string.c
Normal file
@@ -0,0 +1,31 @@
|
||||
/*
|
||||
* Copyright (C) 2001 Sistina Software (UK) Limited.
|
||||
*
|
||||
* This file is released under the LGPL.
|
||||
*/
|
||||
|
||||
#include "lib.h"
|
||||
#include "lvm-types.h"
|
||||
#include "lvm-string.h"
|
||||
|
||||
/*
|
||||
* On error, up to glibc 2.0.6, snprintf returned -1 if buffer was too small;
|
||||
* From glibc 2.1 it returns number of chars (excl. trailing null) that would
|
||||
* have been written had there been room.
|
||||
*
|
||||
* lvm_snprintf reverts to the old behaviour.
|
||||
*/
|
||||
int lvm_snprintf(char *buf, size_t bufsize, const char *format, ...)
|
||||
{
|
||||
int n;
|
||||
va_list ap;
|
||||
|
||||
va_start(ap, format);
|
||||
n = vsnprintf(buf, bufsize, format, ap);
|
||||
va_end(ap);
|
||||
|
||||
if (n < 0 || (n > bufsize - 1))
|
||||
return -1;
|
||||
|
||||
return n;
|
||||
}
|
||||
@@ -17,20 +17,6 @@
|
||||
*
|
||||
* lvm_snprintf reverts to the old behaviour.
|
||||
*/
|
||||
static inline int lvm_snprintf(char *buf, size_t bufsize,
|
||||
const char *format, ...)
|
||||
{
|
||||
int n;
|
||||
va_list ap;
|
||||
|
||||
va_start(ap, format);
|
||||
n = vsnprintf(buf, bufsize, format, ap);
|
||||
va_end(ap);
|
||||
|
||||
if (n < 0 || (n > bufsize - 1))
|
||||
return -1;
|
||||
|
||||
return n;
|
||||
}
|
||||
int lvm_snprintf(char *buf, size_t bufsize, const char *format, ...);
|
||||
|
||||
#endif
|
||||
|
||||
@@ -8,6 +8,7 @@
|
||||
#include "lib.h"
|
||||
#include "config.h"
|
||||
#include "lvm-string.h"
|
||||
#include "sharedlib.h"
|
||||
|
||||
#include <limits.h>
|
||||
#include <sys/stat.h>
|
||||
|
||||
@@ -6,8 +6,8 @@
|
||||
|
||||
#include "lib.h"
|
||||
#include "lvm-types.h"
|
||||
#include "dbg_malloc.h"
|
||||
|
||||
#include <assert.h>
|
||||
#include <stdarg.h>
|
||||
|
||||
struct memblock {
|
||||
@@ -66,7 +66,7 @@ void *malloc_aux(size_t s, const char *file, int line)
|
||||
and fill in the boundary bytes */
|
||||
{
|
||||
char *ptr = (char *) (nb + 1);
|
||||
int i;
|
||||
size_t i;
|
||||
for (i = 0; i < s; i++)
|
||||
*ptr++ = i & 0x1 ? (char) 0xba : (char) 0xbe;
|
||||
|
||||
@@ -87,7 +87,7 @@ void *malloc_aux(size_t s, const char *file, int line)
|
||||
void free_aux(void *p)
|
||||
{
|
||||
char *ptr;
|
||||
int i;
|
||||
size_t i;
|
||||
struct memblock *mb = ((struct memblock *) p) - 1;
|
||||
if (!p)
|
||||
return;
|
||||
@@ -173,7 +173,7 @@ void bounds_check(void)
|
||||
{
|
||||
struct memblock *mb = _head;
|
||||
while (mb) {
|
||||
int i;
|
||||
size_t i;
|
||||
char *ptr = ((char *) (mb + 1)) + mb->length;
|
||||
for (i = 0; i < sizeof(unsigned long); i++)
|
||||
if (*ptr++ != (char) mb->id)
|
||||
|
||||
@@ -7,8 +7,6 @@
|
||||
#include "lib.h"
|
||||
#include "pool.h"
|
||||
|
||||
#include <assert.h>
|
||||
|
||||
struct block {
|
||||
struct block *next;
|
||||
size_t size;
|
||||
|
||||
@@ -10,7 +10,6 @@
|
||||
#include <string.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
|
||||
/*
|
||||
* The pool allocator is useful when you are going to allocate
|
||||
* lots of memory, use the memory for a bit, and then free the
|
||||
@@ -108,7 +107,8 @@ void pool_abandon_object(struct pool *p);
|
||||
/* utilities */
|
||||
char *pool_strdup(struct pool *p, const char *str);
|
||||
|
||||
static inline void *pool_zalloc(struct pool *p, size_t s) {
|
||||
static inline void *pool_zalloc(struct pool *p, size_t s)
|
||||
{
|
||||
void *ptr = pool_alloc(p, s);
|
||||
|
||||
if (ptr)
|
||||
@@ -118,4 +118,3 @@ static inline void *pool_zalloc(struct pool *p, size_t s) {
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
@@ -10,8 +10,6 @@
|
||||
#include "ttree.h"
|
||||
#include "bitset.h"
|
||||
|
||||
#include <assert.h>
|
||||
|
||||
struct dfa_state {
|
||||
int final;
|
||||
struct dfa_state *lookup[256];
|
||||
@@ -25,7 +23,8 @@ struct state_queue {
|
||||
|
||||
struct matcher { /* Instance variables for the lexer */
|
||||
struct dfa_state *start;
|
||||
int num_nodes, nodes_entered;
|
||||
unsigned num_nodes;
|
||||
int nodes_entered;
|
||||
struct rx_node **nodes;
|
||||
struct pool *scratch, *mem;
|
||||
};
|
||||
@@ -184,7 +183,7 @@ static struct state_queue *_create_state_queue(struct pool *mem,
|
||||
|
||||
static int _calc_states(struct matcher *m, struct rx_node *rx)
|
||||
{
|
||||
int iwidth = (m->num_nodes / BITS_PER_INT) + 1;
|
||||
unsigned iwidth = (m->num_nodes / BITS_PER_INT) + 1;
|
||||
struct ttree *tt = ttree_create(m->scratch, iwidth);
|
||||
struct state_queue *h, *t, *tmp;
|
||||
struct dfa_state *dfa, *ldfa;
|
||||
@@ -260,10 +259,12 @@ static int _calc_states(struct matcher *m, struct rx_node *rx)
|
||||
return 1;
|
||||
}
|
||||
|
||||
struct matcher *matcher_create(struct pool *mem, const char **patterns, int num)
|
||||
struct matcher *matcher_create(struct pool *mem, const char **patterns,
|
||||
unsigned num)
|
||||
{
|
||||
char *all, *ptr;
|
||||
int i, len = 0;
|
||||
int i;
|
||||
size_t len = 0;
|
||||
struct rx_node *rx;
|
||||
struct pool *scratch = pool_create(10 * 1024);
|
||||
struct matcher *m;
|
||||
@@ -328,10 +329,10 @@ struct matcher *matcher_create(struct pool *mem, const char **patterns, int num)
|
||||
return NULL;
|
||||
}
|
||||
|
||||
static inline struct dfa_state *_step_matcher(unsigned char c,
|
||||
static inline struct dfa_state *_step_matcher(int c,
|
||||
struct dfa_state *cs, int *r)
|
||||
{
|
||||
if (!(cs = cs->lookup[c]))
|
||||
if (!(cs = cs->lookup[(unsigned char) c]))
|
||||
return NULL;
|
||||
|
||||
if (cs->final && (cs->final > *r))
|
||||
|
||||
@@ -10,8 +10,8 @@
|
||||
#include "pool.h"
|
||||
|
||||
struct matcher;
|
||||
struct matcher *matcher_create(struct pool *mem,
|
||||
const char **patterns, int num);
|
||||
struct matcher *matcher_create(struct pool *mem, const char **patterns,
|
||||
unsigned num);
|
||||
|
||||
int matcher_run(struct matcher *m, const char *begin);
|
||||
|
||||
|
||||
@@ -20,7 +20,7 @@ struct ttree {
|
||||
struct node *root;
|
||||
};
|
||||
|
||||
struct node **_lookup_single(struct node **c, unsigned int k)
|
||||
static struct node **_lookup_single(struct node **c, unsigned int k)
|
||||
{
|
||||
while (*c) {
|
||||
if (k < (*c)->k)
|
||||
|
||||
52
lib/report/columns.h
Normal file
52
lib/report/columns.h
Normal file
@@ -0,0 +1,52 @@
|
||||
/*
|
||||
* Copyright (C) 2002 Sistina Software (UK) Limited.
|
||||
*
|
||||
* This file is released under the LGPL.
|
||||
*/
|
||||
|
||||
/* Report type, Containing struct, Field type, Report heading,
|
||||
* Data field with struct to pass to display function, Minimum display width,
|
||||
* Display Fn, Unique format identifier */
|
||||
FIELD(LVS, lv, STR, "LV UUID", lvid.id[1], 38, uuid, "lv_uuid")
|
||||
FIELD(LVS, lv, STR, "LV", name, 4, string, "lv_name")
|
||||
FIELD(LVS, lv, STR, "Attr", lvid, 4, lvstatus, "lv_attr")
|
||||
FIELD(LVS, lv, NUM, "Min", minor, 3, int32, "lv_minor")
|
||||
FIELD(LVS, lv, NUM, "LSize", size, 5, size64, "lv_size")
|
||||
FIELD(LVS, lv, NUM, "#Seg", lvid, 4, lvsegcount, "seg_count")
|
||||
FIELD(LVS, lv, STR, "Origin", lvid, 6, origin, "origin")
|
||||
FIELD(LVS, lv, NUM, "Snap%", lvid, 6, snpercent, "snap_percent")
|
||||
|
||||
FIELD(PVS, pv, STR, "Fmt", id, 3, pvfmt, "pv_fmt")
|
||||
FIELD(PVS, pv, STR, "PV UUID", id, 38, uuid, "pv_uuid")
|
||||
FIELD(PVS, pv, NUM, "PSize", id, 5, pvsize, "pv_size")
|
||||
FIELD(PVS, pv, NUM, "PFree", id, 5, pvfree, "pv_free")
|
||||
FIELD(PVS, pv, NUM, "Used", id, 4, pvused, "pv_used")
|
||||
FIELD(PVS, pv, STR, "PV", dev, 10, dev_name, "pv_name")
|
||||
FIELD(PVS, pv, STR, "Attr", status, 4, pvstatus, "pv_attr")
|
||||
FIELD(PVS, pv, NUM, "PE", pe_count, 3, uint32, "pv_pe_count")
|
||||
FIELD(PVS, pv, NUM, "Alloc", pe_alloc_count, 5, uint32, "pv_pe_alloc_count")
|
||||
|
||||
FIELD(VGS, vg, STR, "Fmt", cmd, 3, vgfmt, "vg_fmt")
|
||||
FIELD(VGS, vg, STR, "VG UUID", id, 38, uuid, "vg_uuid")
|
||||
FIELD(VGS, vg, STR, "VG", name, 4, string, "vg_name")
|
||||
FIELD(VGS, vg, STR, "Attr", status, 4, vgstatus, "vg_attr")
|
||||
FIELD(VGS, vg, NUM, "VSize", cmd, 5, vgsize, "vg_size")
|
||||
FIELD(VGS, vg, NUM, "VFree", cmd, 5, vgfree, "vg_free")
|
||||
FIELD(VGS, vg, STR, "SYS ID", system_id, 6, string, "vg_sysid")
|
||||
FIELD(VGS, vg, NUM, "Ext", extent_size, 3, size32, "vg_extent_size")
|
||||
FIELD(VGS, vg, NUM, "#Ext", extent_count, 4, uint32, "vg_extent_count")
|
||||
FIELD(VGS, vg, NUM, "Free", free_count, 4, uint32, "vg_free_count")
|
||||
FIELD(VGS, vg, NUM, "MaxLV", max_lv, 5, uint32, "max_lv")
|
||||
FIELD(VGS, vg, NUM, "MaxPV", max_pv, 5, uint32, "max_pv")
|
||||
FIELD(VGS, vg, NUM, "#PV", pv_count, 3, uint32, "pv_count")
|
||||
FIELD(VGS, vg, NUM, "#LV", lv_count, 3, uint32, "lv_count")
|
||||
FIELD(VGS, vg, NUM, "#SN", snapshot_count, 3, uint32, "snap_count")
|
||||
FIELD(VGS, vg, NUM, "Seq", seqno, 3, uint32, "vg_seqno")
|
||||
|
||||
FIELD(SEGS, seg, STR, "Type", list, 4, segtype, "segtype")
|
||||
FIELD(SEGS, seg, NUM, "#Str", stripes, 4, uint32, "stripes")
|
||||
FIELD(SEGS, seg, NUM, "Stripe", stripe_size, 6, size32, "stripesize")
|
||||
FIELD(SEGS, seg, NUM, "Chunk", chunk_size, 5, size32, "chunksize")
|
||||
FIELD(SEGS, seg, NUM, "Start", list, 5, segstart, "seg_start")
|
||||
FIELD(SEGS, seg, NUM, "SSize", list, 5, segsize, "seg_size")
|
||||
|
||||
1101
lib/report/report.c
Normal file
1101
lib/report/report.c
Normal file
File diff suppressed because it is too large
Load Diff
43
lib/report/report.h
Normal file
43
lib/report/report.h
Normal file
@@ -0,0 +1,43 @@
|
||||
/*
|
||||
* Copyright (C) 2002 Sistina Software
|
||||
*
|
||||
* This LVM library is free software; you can redistribute it and/or
|
||||
* modify it under the terms of the GNU Library General Public
|
||||
* License as published by the Free Software Foundation; either
|
||||
* version 2 of the License, or (at your option) any later version.
|
||||
*
|
||||
* This LVM library is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
|
||||
* Library General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Library General Public
|
||||
* License along with this LVM library; if not, write to the Free
|
||||
* Software Foundation, Inc., 59 Temple Place - Suite 330, Boston,
|
||||
* MA 02111-1307, USA
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef _LVM_REPORT_H
|
||||
#define _LVM_REPORT_H
|
||||
|
||||
#include "metadata.h"
|
||||
|
||||
typedef enum { LVS = 1, PVS = 2, VGS = 4, SEGS = 8 } report_type_t;
|
||||
|
||||
struct field;
|
||||
struct report_handle;
|
||||
|
||||
typedef int (*field_report_fn) (struct report_handle * dh, struct field * field,
|
||||
const void *data);
|
||||
|
||||
void *report_init(struct cmd_context *cmd, const char *format, const char *keys,
|
||||
report_type_t *report_type, const char *separator,
|
||||
int aligned, int buffered, int headings);
|
||||
void report_free(void *handle);
|
||||
int report_object(void *handle, struct volume_group *vg,
|
||||
struct logical_volume *lv, struct physical_volume *pv,
|
||||
struct lv_segment *seg);
|
||||
int report_output(void *handle);
|
||||
|
||||
#endif
|
||||
@@ -10,7 +10,6 @@
|
||||
#include <sys/stat.h>
|
||||
#include <fcntl.h>
|
||||
#include <unistd.h>
|
||||
#include <assert.h>
|
||||
|
||||
static unsigned char _c[] =
|
||||
"0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ";
|
||||
@@ -26,7 +25,7 @@ int lvid_create(union lvid *lvid, struct id *vgid)
|
||||
return 1;
|
||||
}
|
||||
|
||||
int lvid_from_lvnum(union lvid *lvid, struct id *vgid, int lv_num)
|
||||
int lvid_from_lvnum(union lvid *lvid, struct id *vgid, uint32_t lv_num)
|
||||
{
|
||||
int i;
|
||||
|
||||
@@ -58,20 +57,21 @@ int lvnum_from_lvid(union lvid *lvid)
|
||||
|
||||
int id_create(struct id *id)
|
||||
{
|
||||
int random, i, len = sizeof(id->uuid);
|
||||
int randomfile, i;
|
||||
size_t len = sizeof(id->uuid);
|
||||
|
||||
memset(id->uuid, 0, len);
|
||||
if ((random = open("/dev/urandom", O_RDONLY)) < 0) {
|
||||
if ((randomfile = open("/dev/urandom", O_RDONLY)) < 0) {
|
||||
log_sys_error("open", "id_create");
|
||||
return 0;
|
||||
}
|
||||
|
||||
if (read(random, id->uuid, len) != len) {
|
||||
if (read(randomfile, id->uuid, len) != len) {
|
||||
log_sys_error("read", "id_create");
|
||||
close(random);
|
||||
close(randomfile);
|
||||
return 0;
|
||||
}
|
||||
close(random);
|
||||
close(randomfile);
|
||||
|
||||
for (i = 0; i < len; i++)
|
||||
id->uuid[i] = _c[id->uuid[i] % (sizeof(_c) - 1)];
|
||||
@@ -84,7 +84,7 @@ int id_create(struct id *id)
|
||||
* the uuid just contains characters from
|
||||
* '_c'. A checksum would have been nice :(
|
||||
*/
|
||||
void _build_inverse(void)
|
||||
static void _build_inverse(void)
|
||||
{
|
||||
char *ptr;
|
||||
|
||||
@@ -112,18 +112,18 @@ int id_valid(struct id *id)
|
||||
return 1;
|
||||
}
|
||||
|
||||
int id_equal(struct id *lhs, struct id *rhs)
|
||||
int id_equal(const struct id *lhs, const struct id *rhs)
|
||||
{
|
||||
return !memcmp(lhs->uuid, rhs->uuid, sizeof(lhs->uuid));
|
||||
}
|
||||
|
||||
#define GROUPS (ID_LEN / 4)
|
||||
|
||||
int id_write_format(struct id *id, char *buffer, size_t size)
|
||||
int id_write_format(const struct id *id, char *buffer, size_t size)
|
||||
{
|
||||
int i, tot;
|
||||
|
||||
static int group_size[] = { 6, 4, 4, 4, 4, 4, 6 };
|
||||
static unsigned group_size[] = { 6, 4, 4, 4, 4, 4, 6 };
|
||||
|
||||
assert(ID_LEN == 32);
|
||||
|
||||
@@ -144,7 +144,7 @@ int id_write_format(struct id *id, char *buffer, size_t size)
|
||||
return 1;
|
||||
}
|
||||
|
||||
int id_read_format(struct id *id, char *buffer)
|
||||
int id_read_format(struct id *id, const char *buffer)
|
||||
{
|
||||
int out = 0;
|
||||
|
||||
|
||||
@@ -25,23 +25,23 @@ union lvid {
|
||||
char s[2 * sizeof(struct id) + 1];
|
||||
};
|
||||
|
||||
int lvid_from_lvnum(union lvid *lvid, struct id *vgid, int lv_num);
|
||||
int lvid_from_lvnum(union lvid *lvid, struct id *vgid, uint32_t lv_num);
|
||||
int lvnum_from_lvid(union lvid *lvid);
|
||||
|
||||
int lvid_create(union lvid *lvid, struct id *vgid);
|
||||
int id_create(struct id *id);
|
||||
int id_valid(struct id *id);
|
||||
int id_equal(struct id *lhs, struct id *rhs);
|
||||
int id_equal(const struct id *lhs, const struct id *rhs);
|
||||
|
||||
/*
|
||||
* Fills 'buffer' with a more human readable form
|
||||
* of the uuid.
|
||||
*/
|
||||
int id_write_format(struct id *id, char *buffer, size_t size);
|
||||
int id_write_format(const struct id *id, char *buffer, size_t size);
|
||||
|
||||
/*
|
||||
* Reads a formatted uuid.
|
||||
*/
|
||||
int id_read_format(struct id *id, char *buffer);
|
||||
int id_read_format(struct id *id, const char *buffer);
|
||||
|
||||
#endif
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
{
|
||||
Base {
|
||||
global:
|
||||
dm_log_init;
|
||||
dm_task_create;
|
||||
|
||||
@@ -7,17 +7,17 @@
|
||||
#ifndef _LVM_LIST_H
|
||||
#define _LVM_LIST_H
|
||||
|
||||
#include <assert.h>
|
||||
|
||||
struct list {
|
||||
struct list *n, *p;
|
||||
};
|
||||
|
||||
static inline void list_init(struct list *head) {
|
||||
static inline void list_init(struct list *head)
|
||||
{
|
||||
head->n = head->p = head;
|
||||
}
|
||||
|
||||
static inline void list_add(struct list *head, struct list *elem) {
|
||||
static inline void list_add(struct list *head, struct list *elem)
|
||||
{
|
||||
assert(head->n);
|
||||
|
||||
elem->n = head;
|
||||
@@ -27,7 +27,8 @@ static inline void list_add(struct list *head, struct list *elem) {
|
||||
head->p = elem;
|
||||
}
|
||||
|
||||
static inline void list_add_h(struct list *head, struct list *elem) {
|
||||
static inline void list_add_h(struct list *head, struct list *elem)
|
||||
{
|
||||
assert(head->n);
|
||||
|
||||
elem->n = head->n;
|
||||
@@ -37,27 +38,35 @@ static inline void list_add_h(struct list *head, struct list *elem) {
|
||||
head->n = elem;
|
||||
}
|
||||
|
||||
static inline void list_del(struct list *elem) {
|
||||
static inline void list_del(struct list *elem)
|
||||
{
|
||||
elem->n->p = elem->p;
|
||||
elem->p->n = elem->n;
|
||||
}
|
||||
|
||||
static inline int list_empty(struct list *head) {
|
||||
static inline int list_empty(struct list *head)
|
||||
{
|
||||
return head->n == head;
|
||||
}
|
||||
|
||||
static inline int list_end(struct list *head, struct list *elem)
|
||||
{
|
||||
return elem->n == head;
|
||||
}
|
||||
|
||||
#define list_iterate(v, head) \
|
||||
for (v = (head)->n; v != head; v = v->n)
|
||||
|
||||
#define list_iterate_safe(v, t, head) \
|
||||
for (v = (head)->n, t = v->n; v != head; v = t, t = v->n)
|
||||
|
||||
static inline int list_size(struct list *head) {
|
||||
int s = 0;
|
||||
struct list *v;
|
||||
static inline unsigned int list_size(const struct list *head)
|
||||
{
|
||||
unsigned int s = 0;
|
||||
const struct list *v;
|
||||
|
||||
list_iterate(v, head)
|
||||
s++;
|
||||
s++;
|
||||
|
||||
return s;
|
||||
}
|
||||
|
||||
23
make.tmpl.in
23
make.tmpl.in
@@ -50,17 +50,22 @@ endif
|
||||
SUFFIXES=
|
||||
SUFFIXES=.c .d .o .so
|
||||
|
||||
CFLAGS+=-Wall
|
||||
#CFLAGS+=-O2
|
||||
CFLAGS+=-g -fno-omit-frame-pointer
|
||||
CFLAGS+=-fPIC -Wall -Wundef -Wshadow -Wcast-align -Wwrite-strings -Wmissing-prototypes -Wmissing-declarations -Wnested-externs -Winline
|
||||
|
||||
#CFLAGS+=-W -Wconversion -Wpointer-arith -Wredundant-decls -Wbad-function-cast -Wcast-qual -Wmissing-noreturn
|
||||
|
||||
ifeq ("@DEBUG@", "yes")
|
||||
CFLAGS+=-g -fno-omit-frame-pointer -DDEBUG_MEM -DDEBUG
|
||||
else
|
||||
CFLAGS+=-O2
|
||||
endif
|
||||
|
||||
#CFLAGS+=-DDEBUG_POOL
|
||||
#CFLAGS+=-DBOUNDS_CHECK
|
||||
|
||||
#CFLAGS+=-pg
|
||||
#LD_FLAGS=-pg
|
||||
|
||||
CFLAGS+=-DDEBUG_MEM -DDEBUG
|
||||
#CFLAGS+=-DDEBUG_POOL
|
||||
#CFLAGS+=-DBOUNDS_CHECK
|
||||
|
||||
LIB_VERSION := $(shell cat $(top_srcdir)/VERSION | \
|
||||
awk -F '.' '{printf "%s.%s",$$1,$$2}')
|
||||
|
||||
@@ -80,6 +85,10 @@ ifeq ("@READLINE@", "yes")
|
||||
CFLAGS += -DREADLINE_SUPPORT
|
||||
endif
|
||||
|
||||
ifeq ("@DEVMAPPER@", "yes")
|
||||
CFLAGS += -DDEVMAPPER_SUPPORT
|
||||
endif
|
||||
|
||||
ifeq ("@HAVE_RL_COMPLETION_MATCHES@", "yes")
|
||||
CFLAGS += -DHAVE_RL_COMPLETION_MATCHES
|
||||
endif
|
||||
|
||||
@@ -22,11 +22,11 @@ VPATH = @srcdir@
|
||||
|
||||
MAN5=lvm.conf.5
|
||||
MAN8=lvchange.8 lvcreate.8 lvdisplay.8 lvextend.8 lvm.8 lvmchange.8 \
|
||||
lvreduce.8 lvremove.8 lvrename.8 lvscan.8 pvchange.8 \
|
||||
pvcreate.8 pvdisplay.8 pvremove.8 pvscan.8 vgcfgbackup.8 \
|
||||
lvreduce.8 lvremove.8 lvrename.8 lvs.8 lvscan.8 pvchange.8 \
|
||||
pvcreate.8 pvdisplay.8 pvremove.8 pvs.8 pvscan.8 vgcfgbackup.8 \
|
||||
vgcfgrestore.8 vgchange.8 vgck.8 vgcreate.8 \
|
||||
vgconvert.8 vgdisplay.8 vgextend.8 vgmerge.8 vgreduce.8 vgremove.8 \
|
||||
vgrename.8 vgscan.8
|
||||
vgrename.8 vgs.8 vgscan.8
|
||||
MAN5DIR=${mandir}/man5
|
||||
MAN8DIR=${mandir}/man8
|
||||
|
||||
|
||||
@@ -91,6 +91,13 @@ Defaults to "/etc/lvm/.cache".
|
||||
\fBwrite_cache_state\fP \(em Set to 0 to disable the writing out of the
|
||||
persistent filter cache file when \fBlvm\fP exits.
|
||||
Defaults to 1.
|
||||
.IP
|
||||
\fBtypes\fP \(em List of pairs of additional acceptable block device types
|
||||
found in /proc/devices together with maximum (non-zero) number of
|
||||
partitions (normally 16). By default, LVM2 supports ide, sd, md, loop,
|
||||
dasd, dac960, nbd, ida, cciss, ubd and ataraid. Block devices with major
|
||||
numbers of different types are ignored by LVM2. Example:
|
||||
\fBtypes = ["fd", 16]\fP
|
||||
.TP
|
||||
\fBlog\fP \(em Default log settings
|
||||
.IP
|
||||
|
||||
64
man/lvs.8
Normal file
64
man/lvs.8
Normal file
@@ -0,0 +1,64 @@
|
||||
.TH LVS 8 "LVM TOOLS" "Sistina Software UK" \" -*- nroff -*-
|
||||
.SH NAME
|
||||
lvs \- report information about logical volumes
|
||||
.SH SYNOPSIS
|
||||
.B lvs
|
||||
[\-\-aligned] [\-d/\-\-debug] [\-h/\-?/\-\-help]
|
||||
[\-\-ignorelockingfailure] [\-\-noheadings] [\-\-nosuffix]
|
||||
[\-o/\-\-options [+]Field[,Field]]
|
||||
[\-O/\-\-sort [+/-]Key1[,[+/-]Key2[,...]]]
|
||||
[\-P/\-\-partial] [\-\-segments]
|
||||
[\-\-separator Separator] [\-\-unbuffered]
|
||||
[\-\-units hsbkmgtHKMGT]
|
||||
[\-v/\-\-verbose]
|
||||
[\-\-version] [VolumeGroupName [VolumeGroupName...]]
|
||||
.SH DESCRIPTION
|
||||
vgs produces formatted output about volume groups
|
||||
.SH OPTIONS
|
||||
See \fBlvm\fP for common options.
|
||||
.TP
|
||||
.I \-\-aligned
|
||||
Use with \-\-separator to align the output columns.
|
||||
.TP
|
||||
.I \-\-noheadings
|
||||
Suppress the headings line that is normally the first line of output.
|
||||
Useful if grepping the output.
|
||||
.TP
|
||||
.I \-\-nosuffix
|
||||
Suppress the suffix on output sizes. Use with \-\-units (except h and H)
|
||||
if processing the output.
|
||||
.TP
|
||||
.I \-o, \-\-options
|
||||
Comma-separated ordered list of columns. Precede the list with '+' to append
|
||||
to the default selection of columns. Column names are:
|
||||
lv_uuid, lv_name, lv_attr, lv_minor, lv_size, seg_count, origin,
|
||||
snap_percent (suppressed if no kernel driver), segtype, stripes,
|
||||
stripesize, chunksize, seg_start, seg_size.
|
||||
With \-\-segments, any "seg_" prefixes are optional; otherwise any "lv_"
|
||||
prefixes are optional. Columns mentioned in \fBvgs (8)\fP
|
||||
can also be chosen
|
||||
The lv_attr bits are: (o)rigin, (s)napshot, (w)riteable, (r)eadonly,
|
||||
(c)ontiguous allocation, (n)ext free allocation, fixed (m)inor, (s)uspended,
|
||||
(a)ctive, device (o)pen.
|
||||
.TP
|
||||
.I \-\-segments
|
||||
Use default columns that emphasize segment information.
|
||||
.TP
|
||||
.I \-O, \-\-sort
|
||||
Comma-separated ordered list of columns to sort by. Replaces the default
|
||||
selection. Precede any column with - for a reverse sort on that column.
|
||||
.TP
|
||||
.I \-\-separator Separator
|
||||
String to use to separate each column. Useful if grepping the output.
|
||||
.TP
|
||||
.I \-\-unbuffered
|
||||
Produce output immediately without sorting or aligning the columns properly.
|
||||
.TP
|
||||
.I \-\-units hsbkmgtHKMGT
|
||||
All sizes are output in these units: (h)uman-readable, (s)ectors, (b)ytes,
|
||||
(k)ilobytes, (m)egabytes, (g)igabytes, (t)erabytes. Capitalise to use multiples
|
||||
of 1000 (S.I.) instead of 1024. Can also specify custom (u)nits e.g.
|
||||
\-\-units 3M
|
||||
.SH SEE ALSO
|
||||
.BR pvs (8),
|
||||
.BR vgs (8)
|
||||
54
man/pvs.8
Normal file
54
man/pvs.8
Normal file
@@ -0,0 +1,54 @@
|
||||
.TH PVS 8 "LVM TOOLS" "Sistina Software UK" \" -*- nroff -*-
|
||||
.SH NAME
|
||||
pvs \- report information about physical volumes
|
||||
.SH SYNOPSIS
|
||||
.B pvs
|
||||
[\-\-aligned] [\-d/\-\-debug] [\-h/\-?/\-\-help]
|
||||
[\-\-ignorelockingfailure] [\-\-noheadings] [\-\-nosuffix]
|
||||
[\-o/\-\-options [+]Field[,Field]]
|
||||
[\-O/\-\-sort [+/-]Key1[,[+/-]Key2[,...]]]
|
||||
[\-\-separator Separator] [\-\-unbuffered]
|
||||
[\-\-units hsbkmgtHKMGT]
|
||||
[\-v/\-\-verbose]
|
||||
[\-\-version] [PhysicalVolume [PhysicalVolume...]]
|
||||
.SH DESCRIPTION
|
||||
pvs produces formatted output about physical volumes
|
||||
.SH OPTIONS
|
||||
See \fBlvm\fP for common options.
|
||||
.TP
|
||||
.I \-\-aligned
|
||||
Use with \-\-separator to align the output columns.
|
||||
.TP
|
||||
.I \-\-noheadings
|
||||
Suppress the headings line that is normally the first line of output.
|
||||
Useful if grepping the output.
|
||||
.TP
|
||||
.I \-\-nosuffix
|
||||
Suppress the suffix on output sizes. Use with \-\-units (except h and H)
|
||||
if processing the output.
|
||||
.TP
|
||||
.I \-o, \-\-options
|
||||
Comma-separated ordered list of columns. Precede the list with '+' to append
|
||||
to the default selection of columns. Column names are: pv_fmt, pv_uuid,
|
||||
pv_size, pv_free, pv_used, pv_name, pv_attr, pv_pe_count, pv_pe_alloc_count.
|
||||
The "pv_" prefix is optional. Columns mentioned in \fBvgs (8)\fP can also
|
||||
be chosen. The pv_attr bits are: (a)llocatable and e(x)ported.
|
||||
.TP
|
||||
.I \-O, \-\-sort
|
||||
Comma-separated ordered list of columns to sort by. Replaces the default
|
||||
selection. Precede any column with - for a reverse sort on that column.
|
||||
.TP
|
||||
.I \-\-separator Separator
|
||||
String to use to separate each column. Useful if grepping the output.
|
||||
.TP
|
||||
.I \-\-unbuffered
|
||||
Produce output immediately without sorting or aligning the columns properly.
|
||||
.TP
|
||||
.I \-\-units hsbkmgtHKMGT
|
||||
All sizes are output in these units: (h)uman-readable, (s)ectors, (b)ytes,
|
||||
(k)ilobytes, (m)egabytes, (g)igabytes, (t)erabytes. Capitalise to use multiples
|
||||
of 1000 (S.I.) instead of 1024. Can also specify custom (u)nits e.g.
|
||||
\-\-units 3M
|
||||
.SH SEE ALSO
|
||||
.BR lvs (8),
|
||||
.BR vgs (8)
|
||||
@@ -18,6 +18,16 @@ allows you to restore the metadata
|
||||
of your volume groups from a text backup file produced by \fBvgcfgbackup\fP.
|
||||
.SH OPTIONS
|
||||
See \fBlvm\fP for common options.
|
||||
.SH REPLACING PHYSICAL VOLUMES
|
||||
\fBvgdisplay --partial --verbose\fP will show you the UUIDs and sizes of
|
||||
any PVs that are no longer present.
|
||||
If a PV in the VG is lost and you wish to substitute
|
||||
another of the same size, use
|
||||
\fBpvcreate --restorefile filename --uuid uuid\fP (plus additional
|
||||
arguments as appropriate) to initialise it with the same UUID as
|
||||
the missing PV. Repeat for all other missing PVs in the VG.
|
||||
Then use \fBvgcfgrestore --file filename\fP to restore the volume
|
||||
group's metadata.
|
||||
.SH SEE ALSO
|
||||
.BR lvm (8),
|
||||
.BR vgcreate (8)
|
||||
|
||||
58
man/vgs.8
Normal file
58
man/vgs.8
Normal file
@@ -0,0 +1,58 @@
|
||||
.TH VGS 8 "LVM TOOLS" "Sistina Software UK" \" -*- nroff -*-
|
||||
.SH NAME
|
||||
vgs \- report information about volume groups
|
||||
.SH SYNOPSIS
|
||||
.B vgs
|
||||
[\-\-aligned] [\-d/\-\-debug] [\-h/\-?/\-\-help]
|
||||
[\-\-ignorelockingfailure] [\-\-noheadings] [\-\-nosuffix]
|
||||
[\-o/\-\-options [+]Field[,Field]]
|
||||
[\-O/\-\-sort [+/-]Key1[,[+/-]Key2[,...]]]
|
||||
[\-P/\-\-partial]
|
||||
[\-\-separator Separator] [\-\-unbuffered]
|
||||
[\-\-units hsbkmgtHKMGT]
|
||||
[\-v/\-\-verbose]
|
||||
[\-\-version] [VolumeGroupName [VolumeGroupName...]]
|
||||
.SH DESCRIPTION
|
||||
vgs produces formatted output about volume groups
|
||||
.SH OPTIONS
|
||||
See \fBlvm\fP for common options.
|
||||
.TP
|
||||
.I \-\-aligned
|
||||
Use with \-\-separator to align the output columns.
|
||||
.TP
|
||||
.I \-\-noheadings
|
||||
Suppress the headings line that is normally the first line of output.
|
||||
Useful if grepping the output.
|
||||
.TP
|
||||
.I \-\-nosuffix
|
||||
Suppress the suffix on output sizes. Use with \-\-units (except h and H)
|
||||
if processing the output.
|
||||
.TP
|
||||
.I \-o, \-\-options
|
||||
Comma-separated ordered list of columns. Precede the list with '+' to append
|
||||
to the default selection of columns. Column names are: vg_fmt, vg_uuid,
|
||||
vg_name, vg_attr, vg_size, vg_free, vg_sysid, vg_extent_size, vg_extent_count,
|
||||
vg_free_count, max_lv, max_pv, pv_count, lv_count, snap_count, vg_seqno.
|
||||
Any "vg_" prefixes are optional. Columns mentioned in either \fBpvs (8)\fP
|
||||
or \fBlvs (8)\fP can also be chosen, but columns cannot be taken from both
|
||||
at the same time. The vg_attr bits are: (w)riteable, (r)eadonly,
|
||||
resi(z)eable, e(x)ported, (p)artial.
|
||||
.TP
|
||||
.I \-O, \-\-sort
|
||||
Comma-separated ordered list of columns to sort by. Replaces the default
|
||||
selection. Precede any column with - for a reverse sort on that column.
|
||||
.TP
|
||||
.I \-\-separator Separator
|
||||
String to use to separate each column. Useful if grepping the output.
|
||||
.TP
|
||||
.I \-\-unbuffered
|
||||
Produce output immediately without sorting or aligning the columns properly.
|
||||
.TP
|
||||
.I \-\-units hsbkmgtHKMGT
|
||||
All sizes are output in these units: (h)uman-readable, (s)ectors, (b)ytes,
|
||||
(k)ilobytes, (m)egabytes, (g)igabytes, (t)erabytes. Capitalise to use multiples
|
||||
of 1000 (S.I.) instead of 1024. Can also specify custom (u)nits e.g.
|
||||
\-\-units 3M
|
||||
.SH SEE ALSO
|
||||
.BR pvs (8),
|
||||
.BR lvs (8)
|
||||
@@ -75,7 +75,7 @@ static void _do_test(int table_size, int num_entries)
|
||||
}
|
||||
}
|
||||
|
||||
for (key = all; key; key = tmp) {
|
||||
for (key = all; key; key = tmp) {
|
||||
tmp = key->next;
|
||||
dbg_free(key);
|
||||
}
|
||||
|
||||
@@ -36,7 +36,7 @@ int main(int argc, char **argv)
|
||||
while ((dev = dev_iter_next(iter)))
|
||||
printf("%s\n", dev->name);
|
||||
|
||||
dev_iter_destroy(iter):
|
||||
dev_iter_destroy(iter):
|
||||
dev_cache_exit();
|
||||
|
||||
dump_memory();
|
||||
|
||||
@@ -39,6 +39,7 @@ SOURCES=\
|
||||
pvdisplay.c \
|
||||
pvremove.c \
|
||||
pvscan.c \
|
||||
report.c \
|
||||
toollib.c \
|
||||
vgcfgbackup.c \
|
||||
vgcfgrestore.c \
|
||||
@@ -61,14 +62,20 @@ TARGETS=\
|
||||
.commands \
|
||||
lvm
|
||||
|
||||
LVMLIBS=-llvm
|
||||
|
||||
ifeq ("@DEVMAPPER@", "yes")
|
||||
LVMLIBS += -ldevmapper
|
||||
endif
|
||||
|
||||
include ../make.tmpl
|
||||
|
||||
lvm: $(OBJECTS) $(top_srcdir)/lib/liblvm.a
|
||||
$(CC) -o lvm $(OBJECTS) $(LD_FLAGS) -L$(top_srcdir)/lib \
|
||||
-L$(DESTDIR)/lib -llvm -ldevmapper $(LIBS) -ldl -rdynamic
|
||||
-L$(DESTDIR)/lib $(LVMLIBS) $(LIBS) -ldl -rdynamic
|
||||
|
||||
.commands: commands.h cmdnames.h
|
||||
$(CC) -E -P cmdnames.h | grep -v help > .commands
|
||||
.commands: commands.h cmdnames.h Makefile
|
||||
$(CC) -E -P cmdnames.h | egrep -v '(help|version)' > .commands
|
||||
|
||||
install: $(TARGETS)
|
||||
$(INSTALL) -D -o $(OWNER) -g $(GROUP) -m 555 $(STRIP) lvm \
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user