mirror of
git://sourceware.org/git/lvm2.git
synced 2024-12-30 17:18:21 +03:00
Default stripesize 64k & config file setting for it;
Clear many compiler warnings (i386) & associated bugs - hopefully without introducing too many new bugs:-) (Same exercise required for other archs.) Default compilation has optimisation - or else use ./configure --enable-debug
This commit is contained in:
parent
4c64ed4ced
commit
8ef2b021ed
186
configure
vendored
186
configure
vendored
@ -26,6 +26,8 @@ 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"
|
||||
|
||||
# Initialize some variables set by options.
|
||||
# The variables have the same names as the options, with
|
||||
@ -562,7 +564,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:568: 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 +596,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:600: 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 +626,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:630: 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 +677,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:681: 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 +709,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:713: 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 +720,12 @@ cross_compiling=$ac_cv_prog_cc_cross
|
||||
|
||||
cat > conftest.$ac_ext << EOF
|
||||
|
||||
#line 722 "configure"
|
||||
#line 724 "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:729: \"$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 +751,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:755: 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:760: 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 +765,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:769: \"$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 +784,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:788: 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 +827,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:831: 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 +880,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:884: 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 +901,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:905: 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 +930,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:934: 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 +963,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:967: 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 972 "configure"
|
||||
#include "confdefs.h"
|
||||
#include <sys/types.h>
|
||||
#include <$ac_hdr>
|
||||
@ -974,7 +976,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:980: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
|
||||
rm -rf conftest*
|
||||
eval "ac_cv_header_dirent_$ac_safe=yes"
|
||||
else
|
||||
@ -999,7 +1001,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:1005: 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 +1009,7 @@ else
|
||||
ac_save_LIBS="$LIBS"
|
||||
LIBS="-ldir $LIBS"
|
||||
cat > conftest.$ac_ext <<EOF
|
||||
#line 1011 "configure"
|
||||
#line 1013 "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 +1020,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:1024: \"$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 +1042,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:1046: 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 +1050,7 @@ else
|
||||
ac_save_LIBS="$LIBS"
|
||||
LIBS="-lx $LIBS"
|
||||
cat > conftest.$ac_ext <<EOF
|
||||
#line 1052 "configure"
|
||||
#line 1054 "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 +1061,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:1065: \"$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 +1084,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:1088: 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 +1099,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 1103 "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:1109: \"$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 +1116,13 @@ else
|
||||
rm -rf conftest*
|
||||
CPP="${CC-cc} -E -traditional-cpp"
|
||||
cat > conftest.$ac_ext <<EOF
|
||||
#line 1118 "configure"
|
||||
#line 1120 "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:1126: \"$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 +1133,13 @@ else
|
||||
rm -rf conftest*
|
||||
CPP="${CC-cc} -nologo -E"
|
||||
cat > conftest.$ac_ext <<EOF
|
||||
#line 1135 "configure"
|
||||
#line 1137 "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:1143: \"$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 +1164,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:1168: 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 1173 "configure"
|
||||
#include "confdefs.h"
|
||||
#include <stdlib.h>
|
||||
#include <stdarg.h>
|
||||
@ -1175,7 +1177,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:1181: \"$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 +1194,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 1198 "configure"
|
||||
#include "confdefs.h"
|
||||
#include <string.h>
|
||||
EOF
|
||||
@ -1210,7 +1212,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 1216 "configure"
|
||||
#include "confdefs.h"
|
||||
#include <stdlib.h>
|
||||
EOF
|
||||
@ -1231,7 +1233,7 @@ if test "$cross_compiling" = yes; then
|
||||
:
|
||||
else
|
||||
cat > conftest.$ac_ext <<EOF
|
||||
#line 1235 "configure"
|
||||
#line 1237 "configure"
|
||||
#include "confdefs.h"
|
||||
#include <ctype.h>
|
||||
#define ISLOWER(c) ('a' <= (c) && (c) <= 'z')
|
||||
@ -1242,7 +1244,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:1248: \"$ac_link\") 1>&5; (eval $ac_link) 2>&5; } && test -s conftest${ac_exeext} && (./conftest; exit) 2>/dev/null
|
||||
then
|
||||
:
|
||||
else
|
||||
@ -1269,17 +1271,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:1275: 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 1280 "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:1285: \"$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 +1309,12 @@ done
|
||||
|
||||
|
||||
echo $ac_n "checking for working const""... $ac_c" 1>&6
|
||||
echo "configure:1311: checking for working const" >&5
|
||||
echo "configure:1313: 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 1318 "configure"
|
||||
#include "confdefs.h"
|
||||
|
||||
int main() {
|
||||
@ -1361,7 +1363,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:1367: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
|
||||
rm -rf conftest*
|
||||
ac_cv_c_const=yes
|
||||
else
|
||||
@ -1382,21 +1384,21 @@ EOF
|
||||
fi
|
||||
|
||||
echo $ac_n "checking for inline""... $ac_c" 1>&6
|
||||
echo "configure:1386: checking for inline" >&5
|
||||
echo "configure:1388: 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 1395 "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:1402: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
|
||||
rm -rf conftest*
|
||||
ac_cv_c_inline=$ac_kw; break
|
||||
else
|
||||
@ -1422,12 +1424,12 @@ EOF
|
||||
esac
|
||||
|
||||
echo $ac_n "checking for off_t""... $ac_c" 1>&6
|
||||
echo "configure:1426: checking for off_t" >&5
|
||||
echo "configure:1428: 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 1433 "configure"
|
||||
#include "confdefs.h"
|
||||
#include <sys/types.h>
|
||||
#if STDC_HEADERS
|
||||
@ -1455,12 +1457,12 @@ EOF
|
||||
fi
|
||||
|
||||
echo $ac_n "checking for pid_t""... $ac_c" 1>&6
|
||||
echo "configure:1459: checking for pid_t" >&5
|
||||
echo "configure:1461: 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 1466 "configure"
|
||||
#include "confdefs.h"
|
||||
#include <sys/types.h>
|
||||
#if STDC_HEADERS
|
||||
@ -1488,12 +1490,12 @@ EOF
|
||||
fi
|
||||
|
||||
echo $ac_n "checking for size_t""... $ac_c" 1>&6
|
||||
echo "configure:1492: checking for size_t" >&5
|
||||
echo "configure:1494: 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 1499 "configure"
|
||||
#include "confdefs.h"
|
||||
#include <sys/types.h>
|
||||
#if STDC_HEADERS
|
||||
@ -1521,12 +1523,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:1527: 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 1532 "configure"
|
||||
#include "confdefs.h"
|
||||
#include <sys/types.h>
|
||||
#include <sys/stat.h>
|
||||
@ -1534,7 +1536,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:1540: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
|
||||
rm -rf conftest*
|
||||
ac_cv_struct_st_rdev=yes
|
||||
else
|
||||
@ -1555,12 +1557,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:1561: 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 1566 "configure"
|
||||
#include "confdefs.h"
|
||||
#include <sys/types.h>
|
||||
#include <sys/time.h>
|
||||
@ -1569,7 +1571,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:1575: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
|
||||
rm -rf conftest*
|
||||
ac_cv_header_time=yes
|
||||
else
|
||||
@ -1630,7 +1632,7 @@ if test "${enable_jobs+set}" = set; then
|
||||
enableval="$enable_jobs"
|
||||
JOBS=-j$enableval
|
||||
else
|
||||
JOBS=
|
||||
JOBS=-j2
|
||||
fi
|
||||
|
||||
|
||||
@ -1653,19 +1655,29 @@ 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
|
||||
|
||||
|
||||
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:1675: 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 1681 "configure"
|
||||
#include "confdefs.h"
|
||||
#include <sgtty.h>
|
||||
Autoconf TIOCGETP
|
||||
@ -1683,7 +1695,7 @@ rm -f conftest*
|
||||
|
||||
if test $ac_cv_prog_gcc_traditional = no; then
|
||||
cat > conftest.$ac_ext <<EOF
|
||||
#line 1687 "configure"
|
||||
#line 1699 "configure"
|
||||
#include "confdefs.h"
|
||||
#include <termio.h>
|
||||
Autoconf TCGETA
|
||||
@ -1705,12 +1717,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:1721: 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 1726 "configure"
|
||||
#include "confdefs.h"
|
||||
#include <sys/types.h>
|
||||
#include <signal.h>
|
||||
@ -1727,7 +1739,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:1743: \"$ac_compile\") 1>&5; (eval $ac_compile) 2>&5; }; then
|
||||
rm -rf conftest*
|
||||
ac_cv_type_signal=void
|
||||
else
|
||||
@ -1746,12 +1758,12 @@ EOF
|
||||
|
||||
|
||||
echo $ac_n "checking for vprintf""... $ac_c" 1>&6
|
||||
echo "configure:1750: checking for vprintf" >&5
|
||||
echo "configure:1762: 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 1767 "configure"
|
||||
#include "confdefs.h"
|
||||
/* System header to define __stub macros and hopefully few prototypes,
|
||||
which can conflict with char vprintf(); below. */
|
||||
@ -1774,7 +1786,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:1790: \"$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 +1810,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:1814: 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 1819 "configure"
|
||||
#include "confdefs.h"
|
||||
/* System header to define __stub macros and hopefully few prototypes,
|
||||
which can conflict with char _doprnt(); below. */
|
||||
@ -1826,7 +1838,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:1842: \"$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 +1865,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:1869: 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 1874 "configure"
|
||||
#include "confdefs.h"
|
||||
/* System header to define __stub macros and hopefully few prototypes,
|
||||
which can conflict with char $ac_func(); below. */
|
||||
@ -1881,7 +1893,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:1897: \"$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 +1921,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:1925: 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 1932 "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 +1939,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:1943: \"$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 +1950,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 1954 "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 +1961,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:1965: \"$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 +1995,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:1999: 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 +2003,7 @@ else
|
||||
ac_save_LIBS="$LIBS"
|
||||
LIBS="-lreadline $LIBS"
|
||||
cat > conftest.$ac_ext <<EOF
|
||||
#line 1995 "configure"
|
||||
#line 2007 "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 +2014,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:2018: \"$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 +2051,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:2055: 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 2060 "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 +2079,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:2083: \"$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 +2116,7 @@ fi
|
||||
|
||||
|
||||
|
||||
|
||||
trap '' 1 2 15
|
||||
cat > confcache <<\EOF
|
||||
# This file is a shell script that caches the results of configure
|
||||
@ -2280,6 +2293,7 @@ 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
|
||||
|
||||
CEOF
|
||||
EOF
|
||||
|
@ -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,10 @@ 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 Mess with default exec_prefix
|
||||
if [[ "x$exec_prefix" = xNONE -a "x$prefix" = xNONE ]];
|
||||
then exec_prefix="";
|
||||
@ -145,6 +149,7 @@ AC_SUBST(OWNER)
|
||||
AC_SUBST(GROUP)
|
||||
AC_SUBST(LIBS)
|
||||
AC_SUBST(LVM_VERSION)
|
||||
AC_SUBST(DEBUG)
|
||||
dnl First and last lines should not contain files to generate in order to
|
||||
dnl keep utility scripts running properly
|
||||
AC_OUTPUT( \
|
||||
|
@ -50,8 +50,8 @@ 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 \
|
||||
@ -70,6 +70,11 @@ ifeq ("@LVM1@", "internal")
|
||||
format1/vg_number.c
|
||||
endif
|
||||
|
||||
ifeq ("@DEBUG@", "yes")
|
||||
SOURCES+=\
|
||||
mm/dbg_malloc.c
|
||||
endif
|
||||
|
||||
TARGETS=liblvm.a
|
||||
|
||||
include ../make.tmpl
|
||||
|
@ -22,12 +22,12 @@
|
||||
|
||||
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 +36,7 @@ void set_activation(int activation)
|
||||
"interaction will be attempted.");
|
||||
}
|
||||
|
||||
int activation()
|
||||
int activation(void)
|
||||
{
|
||||
return _activation;
|
||||
}
|
||||
@ -82,7 +82,7 @@ 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 dm_info *info)
|
||||
{
|
||||
int r;
|
||||
struct dev_manager *dm;
|
||||
|
@ -11,7 +11,7 @@
|
||||
#include <libdevmapper.h>
|
||||
|
||||
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 +19,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 dm_info *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);
|
||||
|
@ -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
|
||||
|
14
lib/cache/cache.c
vendored
14
lib/cache/cache.c
vendored
@ -18,7 +18,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 +47,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;
|
||||
|
||||
@ -91,7 +91,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 +121,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 +223,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);
|
||||
@ -423,7 +423,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 +467,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
|
||||
|
||||
|
@ -53,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;
|
||||
@ -329,7 +329,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;
|
||||
|
||||
@ -452,7 +452,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;
|
||||
@ -475,7 +475,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();
|
||||
|
@ -45,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);
|
||||
@ -283,8 +283,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) {
|
||||
@ -668,7 +668,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;
|
||||
@ -683,7 +683,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;
|
||||
|
||||
@ -715,7 +715,7 @@ struct config_node *find_config_node(struct config_node *cn,
|
||||
}
|
||||
|
||||
const char *find_config_str(struct config_node *cn,
|
||||
const char *path, const char sep, const char *fail)
|
||||
const char *path, const int sep, const char *fail)
|
||||
{
|
||||
struct config_node *n = find_config_node(cn, path, sep);
|
||||
|
||||
@ -732,7 +732,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);
|
||||
|
||||
@ -747,7 +747,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);
|
||||
|
||||
@ -790,7 +790,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;
|
||||
@ -812,7 +812,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;
|
||||
|
||||
@ -826,7 +826,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;
|
||||
|
||||
@ -841,7 +841,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,7 +43,7 @@ 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);
|
||||
@ -51,31 +51,31 @@ int write_config_file(struct config_tree *cf, const char *file);
|
||||
int reload_config_file(struct config_tree **cf);
|
||||
|
||||
struct config_node *find_config_node(struct config_node *cn,
|
||||
const char *path, char separator);
|
||||
const char *path, const int separator);
|
||||
|
||||
const char *find_config_str(struct config_node *cn,
|
||||
const char *path, const 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
|
||||
|
@ -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,9 +59,9 @@ 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 len)
|
||||
{
|
||||
unsigned long int h = 0, g;
|
||||
unsigned long h = 0, g;
|
||||
while (*str && len--) {
|
||||
h <<= 4;
|
||||
h += _nums[(int) *str++];
|
||||
@ -126,7 +126,7 @@ void hash_destroy(struct hash_table *t)
|
||||
}
|
||||
|
||||
static inline struct hash_node **_find_fixed(struct hash_table *t,
|
||||
const char *key, uint32_t len)
|
||||
const char *key, unsigned len)
|
||||
{
|
||||
unsigned h = _hash(key, len) & (t->num_slots - 1);
|
||||
struct hash_node **c;
|
||||
@ -143,7 +143,7 @@ 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)
|
||||
void *hash_lookup_fixed(struct hash_table *t, const char *key, unsigned len)
|
||||
{
|
||||
struct hash_node **c = _find_fixed(t, key, len);
|
||||
return *c ? (*c)->data : 0;
|
||||
@ -220,7 +220,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 +238,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, strlen(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,8 +7,6 @@
|
||||
#ifndef _LVM_LIST_H
|
||||
#define _LVM_LIST_H
|
||||
|
||||
#include <assert.h>
|
||||
|
||||
struct list {
|
||||
struct list *n, *p;
|
||||
};
|
||||
@ -62,10 +60,10 @@ static inline int list_end(struct list *head, struct list *elem)
|
||||
#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)
|
||||
static inline unsigned int list_size(const struct list *head)
|
||||
{
|
||||
int s = 0;
|
||||
struct list *v;
|
||||
unsigned int s = 0;
|
||||
const struct list *v;
|
||||
|
||||
list_iterate(v, head)
|
||||
s++;
|
||||
|
@ -92,14 +92,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 +122,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 +274,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));
|
||||
|
@ -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 %u",
|
||||
dev_name(dev), offset, len);
|
||||
else
|
||||
log_debug("Wiping %s at sector %" PRIu64 " length %" PRId64
|
||||
log_debug("Wiping %s at sector %" PRIu64 " length %u"
|
||||
" 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
|
||||
|
@ -51,65 +51,66 @@ static int _num_segtypes = sizeof(_segtypes) / sizeof(*_segtypes);
|
||||
|
||||
uint64_t units_to_bytes(const char *units, char *unit_type)
|
||||
{
|
||||
|
||||
char *ptr;
|
||||
char *ptr = NULL;
|
||||
uint64_t v;
|
||||
|
||||
ptr = (char *) units;
|
||||
|
||||
if (isdigit(*units)) {
|
||||
v = (uint64_t) strtod(units, &ptr);
|
||||
if (ptr == units)
|
||||
return 0;
|
||||
units = ptr;
|
||||
} else
|
||||
v = 1;
|
||||
|
||||
if (v == 1)
|
||||
*unit_type = *ptr;
|
||||
*unit_type = *units;
|
||||
else
|
||||
*unit_type = 'U';
|
||||
|
||||
switch (*ptr) {
|
||||
switch (*units) {
|
||||
case 'h':
|
||||
case 'H':
|
||||
v = 1ULL;
|
||||
*unit_type = *ptr;
|
||||
v = __UINT64_C(1);
|
||||
*unit_type = *units;
|
||||
break;
|
||||
case 's':
|
||||
v *= SECTOR_SIZE;
|
||||
case 'b':
|
||||
case 'B':
|
||||
v *= 1ULL;
|
||||
v *= __UINT64_C(1);
|
||||
break;
|
||||
#define KILO __UINT64_C(1024)
|
||||
case 'k':
|
||||
v *= 1024ULL;
|
||||
break;
|
||||
v *= KILO;
|
||||
case 'm':
|
||||
v *= 1024ULL * 1024ULL;
|
||||
v *= KILO * KILO;
|
||||
break;
|
||||
case 'g':
|
||||
v *= 1024ULL * 1024ULL * 1024ULL;
|
||||
v *= KILO * KILO * KILO;
|
||||
break;
|
||||
case 't':
|
||||
v *= 1024ULL * 1024ULL * 1024ULL * 1024ULL;
|
||||
v *= KILO * KILO * KILO * KILO;
|
||||
break;
|
||||
#undef KILO
|
||||
#define KILO __UINT64_C(1000)
|
||||
case 'K':
|
||||
v *= 1000ULL;
|
||||
v *= KILO;
|
||||
break;
|
||||
case 'M':
|
||||
v *= 1000ULL * 1000ULL;
|
||||
v *= KILO * KILO;
|
||||
break;
|
||||
case 'G':
|
||||
v *= 1000ULL * 1000ULL * 1000ULL;
|
||||
v *= KILO * KILO * KILO;
|
||||
break;
|
||||
case 'T':
|
||||
v *= 1000ULL * 1000ULL * 1000ULL * 1000ULL;
|
||||
v *= KILO * KILO * KILO * KILO;
|
||||
break;
|
||||
#undef KILO
|
||||
default:
|
||||
return 0;
|
||||
}
|
||||
|
||||
if (*(ptr + 1))
|
||||
if (*(units + 1))
|
||||
return 0;
|
||||
|
||||
return v;
|
||||
@ -166,9 +167,9 @@ const char *display_size(struct cmd_context *cmd, uint64_t size, size_len_t sl)
|
||||
int s;
|
||||
int suffix = 1;
|
||||
uint64_t byte;
|
||||
uint64_t units = 1024ULL;
|
||||
uint64_t units = __UINT64_C(1024);
|
||||
char *size_buf = NULL;
|
||||
char *size_str[][3] = {
|
||||
const char *size_str[][3] = {
|
||||
{" Terabyte", " TB", "T"},
|
||||
{" Gigabyte", " GB", "G"},
|
||||
{" Megabyte", " MB", "M"},
|
||||
@ -192,20 +193,20 @@ const char *display_size(struct cmd_context *cmd, uint64_t size, size_len_t sl)
|
||||
*size_str[s][2])
|
||||
break;
|
||||
|
||||
if (size == 0ULL) {
|
||||
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 *= 1024ULL;
|
||||
size *= __UINT64_C(1024);
|
||||
} else {
|
||||
suffix = 1;
|
||||
if (cmd->current_settings.unit_type == 'H')
|
||||
units = 1000ULL;
|
||||
units = __UINT64_C(1000);
|
||||
else
|
||||
units = 1024ULL;
|
||||
units = __UINT64_C(1024);
|
||||
byte = units * units * units;
|
||||
s = 0;
|
||||
while (size_str[s] && size < byte)
|
||||
@ -230,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? */
|
||||
@ -251,7 +252,7 @@ void pvdisplay_full(struct cmd_context *cmd, struct physical_volume *pv,
|
||||
char uuid[64];
|
||||
const char *size;
|
||||
|
||||
uint64_t pe_free;
|
||||
uint32_t pe_free;
|
||||
|
||||
if (!pv)
|
||||
return;
|
||||
@ -296,9 +297,9 @@ void pvdisplay_full(struct cmd_context *cmd, struct physical_volume *pv,
|
||||
/* 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(" ");
|
||||
@ -437,7 +438,8 @@ int lvdisplay_full(struct cmd_context *cmd, struct logical_volume *lv,
|
||||
snap_percent = 100;
|
||||
|
||||
log_print("Snapshot chunk size %s",
|
||||
display_size(cmd, snap->chunk_size / 2, SIZE_SHORT));
|
||||
display_size(cmd, (uint64_t) snap->chunk_size / 2,
|
||||
SIZE_SHORT));
|
||||
|
||||
/*
|
||||
size = display_size(lv->size / 2, SIZE_SHORT);
|
||||
@ -471,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;
|
||||
|
||||
@ -485,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;
|
||||
|
||||
@ -589,7 +591,8 @@ void vgdisplay_full(struct volume_group *vg)
|
||||
2), SIZE_SHORT));
|
||||
|
||||
log_print("PE Size %s",
|
||||
display_size(vg->cmd, vg->extent_size / 2, SIZE_SHORT));
|
||||
display_size(vg->cmd, (uint64_t) vg->extent_size / 2,
|
||||
SIZE_SHORT));
|
||||
|
||||
log_print("Total PE %u", vg->extent_count);
|
||||
|
||||
@ -631,13 +634,15 @@ void vgdisplay_short(struct volume_group *vg)
|
||||
{
|
||||
log_print("\"%s\" %-9s [%-9s used / %s free]", vg->name,
|
||||
/********* FIXME if "open" print "/used" else print "/idle"??? ******/
|
||||
display_size(vg->cmd, vg->extent_count * vg->extent_size / 2,
|
||||
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,
|
||||
(vg->extent_count -
|
||||
vg->free_count) *
|
||||
(uint64_t) vg->
|
||||
free_count *
|
||||
vg->extent_size / 2,
|
||||
SIZE_SHORT),
|
||||
display_size(vg->cmd, vg->free_count * vg->extent_size / 2,
|
||||
SIZE_SHORT));
|
||||
SIZE_SHORT));
|
||||
return;
|
||||
}
|
||||
|
@ -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;
|
||||
|
@ -34,8 +34,8 @@
|
||||
#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;
|
||||
@ -46,7 +46,7 @@ int md_major(void)
|
||||
}
|
||||
|
||||
/* This list can be supplemented with devices/types in the config file */
|
||||
static device_info_t device_info[] = {
|
||||
static const device_info_t device_info[] = {
|
||||
{"ide", 16}, /* IDE disk */
|
||||
{"sd", 16}, /* SCSI disk */
|
||||
{"md", 16}, /* Multiple Disk driver (SoftRAID) */
|
||||
@ -90,7 +90,7 @@ static int *_scan_proc_dev(const char *proc, struct config_node *cn)
|
||||
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;
|
||||
|
@ -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,7 +292,7 @@ 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,
|
||||
@ -301,7 +303,8 @@ static int _pv_setup(struct format_type *fmt,
|
||||
pv->size--;
|
||||
if (pv->size > MAX_PV_SIZE) {
|
||||
log_error("Physical volumes cannot be bigger than %s",
|
||||
display_size(fmt->cmd, MAX_PV_SIZE / 2, SIZE_SHORT));
|
||||
display_size(fmt->cmd, (uint64_t) MAX_PV_SIZE / 2,
|
||||
SIZE_SHORT));
|
||||
return 0;
|
||||
}
|
||||
|
||||
@ -329,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;
|
||||
|
||||
@ -371,7 +374,7 @@ static int _lv_setup(struct format_instance *fid, struct logical_volume *lv)
|
||||
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;
|
||||
@ -434,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)
|
||||
@ -445,10 +448,12 @@ int _vg_setup(struct format_instance *fid, struct volume_group *vg)
|
||||
|
||||
if (vg->extent_size > MAX_PE_SIZE || vg->extent_size < MIN_PE_SIZE) {
|
||||
log_error("Extent size must be between %s and %s",
|
||||
display_size(fid->fmt->cmd, MIN_PE_SIZE / 2,
|
||||
display_size(fid->fmt->cmd, (uint64_t) MIN_PE_SIZE
|
||||
/ 2,
|
||||
SIZE_SHORT), display_size(fid->fmt->cmd,
|
||||
MAX_PE_SIZE /
|
||||
2,
|
||||
(uint64_t)
|
||||
MAX_PE_SIZE
|
||||
/ 2,
|
||||
SIZE_SHORT));
|
||||
|
||||
return 0;
|
||||
@ -456,8 +461,8 @@ int _vg_setup(struct format_instance *fid, struct volume_group *vg)
|
||||
|
||||
if (vg->extent_size % MIN_PE_SIZE) {
|
||||
log_error("Extent size must be multiple of %s",
|
||||
display_size(fid->fmt->cmd, MIN_PE_SIZE / 2,
|
||||
SIZE_SHORT));
|
||||
display_size(fid->fmt->cmd,
|
||||
(uint64_t) MIN_PE_SIZE / 2, SIZE_SHORT));
|
||||
return 0;
|
||||
}
|
||||
|
||||
@ -475,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;
|
||||
@ -503,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)
|
||||
@ -99,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;
|
||||
@ -145,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)
|
||||
{
|
||||
@ -172,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;
|
||||
|
||||
@ -239,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;
|
||||
@ -257,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",
|
||||
@ -265,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;
|
||||
@ -301,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];
|
||||
@ -369,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;
|
||||
@ -390,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 -
|
||||
@ -560,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 {
|
||||
@ -643,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;
|
||||
@ -695,7 +697,7 @@ static int _vg_remove_file(struct format_instance *fid, struct volume_group *vg,
|
||||
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;
|
||||
@ -743,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);
|
||||
@ -768,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';
|
||||
|
||||
@ -798,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;
|
||||
@ -826,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,
|
||||
@ -889,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;
|
||||
}
|
||||
@ -936,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;
|
||||
}
|
||||
@ -949,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;
|
||||
@ -961,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;
|
||||
@ -1019,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;
|
||||
}
|
||||
@ -1053,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;
|
||||
@ -1073,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;
|
||||
}
|
||||
@ -1105,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;
|
||||
@ -1121,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;
|
||||
@ -1210,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);
|
||||
@ -1218,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 = {
|
||||
@ -1243,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,
|
||||
@ -1334,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;
|
||||
@ -1408,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",
|
||||
|
@ -147,7 +147,7 @@ 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();
|
||||
|
||||
@ -174,7 +174,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);
|
||||
|
||||
|
@ -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;
|
||||
|
@ -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
|
||||
|
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)
|
||||
|
@ -53,7 +53,7 @@ struct report_handle {
|
||||
struct pool *mem;
|
||||
|
||||
report_type_t type;
|
||||
char *field_prefix;
|
||||
const char *field_prefix;
|
||||
uint32_t flags;
|
||||
const char *separator;
|
||||
|
||||
@ -93,8 +93,8 @@ struct field {
|
||||
struct list list;
|
||||
struct field_properties *props;
|
||||
|
||||
char *report_string; /* Formatted ready for display */
|
||||
void *sort_value; /* Raw value for sorting */
|
||||
const char *report_string; /* Formatted ready for display */
|
||||
const void *sort_value; /* Raw value for sorting */
|
||||
};
|
||||
|
||||
struct row {
|
||||
@ -110,12 +110,14 @@ struct row {
|
||||
static int _string_disp(struct report_handle *rh, struct field *field,
|
||||
const void *data)
|
||||
{
|
||||
if (!(field->report_string = pool_strdup(rh->mem, *(char **) data))) {
|
||||
if (!
|
||||
(field->report_string =
|
||||
pool_strdup(rh->mem, *(const char **) data))) {
|
||||
log_error("pool_strdup failed");
|
||||
return 0;
|
||||
}
|
||||
|
||||
field->sort_value = (void *) field->report_string;
|
||||
field->sort_value = (const void *) field->report_string;
|
||||
|
||||
return 1;
|
||||
}
|
||||
@ -123,7 +125,7 @@ static int _string_disp(struct report_handle *rh, struct field *field,
|
||||
static int _dev_name_disp(struct report_handle *rh, struct field *field,
|
||||
const void *data)
|
||||
{
|
||||
const char *name = dev_name(*(struct device **) data);
|
||||
const char *name = dev_name(*(const struct device **) data);
|
||||
|
||||
return _string_disp(rh, field, &name);
|
||||
}
|
||||
@ -131,11 +133,11 @@ static int _dev_name_disp(struct report_handle *rh, struct field *field,
|
||||
static int _vgfmt_disp(struct report_handle *rh, struct field *field,
|
||||
const void *data)
|
||||
{
|
||||
struct volume_group *vg = (struct volume_group *) data;
|
||||
const struct volume_group *vg = (const struct volume_group *) data;
|
||||
|
||||
if (!vg->fid) {
|
||||
field->report_string = "";
|
||||
field->sort_value = (void *) field->report_string;
|
||||
field->sort_value = (const void *) field->report_string;
|
||||
return 1;
|
||||
}
|
||||
|
||||
@ -145,11 +147,12 @@ static int _vgfmt_disp(struct report_handle *rh, struct field *field,
|
||||
static int _pvfmt_disp(struct report_handle *rh, struct field *field,
|
||||
const void *data)
|
||||
{
|
||||
struct physical_volume *pv = (struct physical_volume *) data;
|
||||
const struct physical_volume *pv =
|
||||
(const struct physical_volume *) data;
|
||||
|
||||
if (!pv->fmt) {
|
||||
field->report_string = "";
|
||||
field->sort_value = (void *) field->report_string;
|
||||
field->sort_value = (const void *) field->report_string;
|
||||
return 1;
|
||||
}
|
||||
|
||||
@ -159,51 +162,53 @@ static int _pvfmt_disp(struct report_handle *rh, struct field *field,
|
||||
static int _lvstatus_disp(struct report_handle *rh, struct field *field,
|
||||
const void *data)
|
||||
{
|
||||
struct logical_volume *lv = (struct logical_volume *) data;
|
||||
const struct logical_volume *lv = (const struct logical_volume *) data;
|
||||
struct dm_info info;
|
||||
char *repstr;
|
||||
|
||||
if (!(field->report_string = pool_zalloc(rh->mem, 7))) {
|
||||
if (!(repstr = pool_zalloc(rh->mem, 7))) {
|
||||
log_error("pool_alloc failed");
|
||||
return 0;
|
||||
}
|
||||
|
||||
if (lv_is_origin(lv))
|
||||
field->report_string[0] = 'o';
|
||||
repstr[0] = 'o';
|
||||
else if (find_cow(lv))
|
||||
field->report_string[0] = 's';
|
||||
repstr[0] = 's';
|
||||
else
|
||||
field->report_string[0] = '-';
|
||||
repstr[0] = '-';
|
||||
|
||||
if (lv->status & LVM_WRITE)
|
||||
field->report_string[1] = 'w';
|
||||
repstr[1] = 'w';
|
||||
else
|
||||
field->report_string[1] = 'r';
|
||||
repstr[1] = 'r';
|
||||
|
||||
if (lv->alloc == ALLOC_CONTIGUOUS)
|
||||
field->report_string[2] = 'c';
|
||||
repstr[2] = 'c';
|
||||
else
|
||||
field->report_string[2] = 'n';
|
||||
repstr[2] = 'n';
|
||||
|
||||
if (lv->status & FIXED_MINOR)
|
||||
field->report_string[3] = 'm'; /* Fixed Minor */
|
||||
repstr[3] = 'm'; /* Fixed Minor */
|
||||
else
|
||||
field->report_string[3] = '-';
|
||||
repstr[3] = '-';
|
||||
|
||||
if (lv_info(lv, &info) && info.exists) {
|
||||
if (info.suspended)
|
||||
field->report_string[4] = 's'; /* Suspended */
|
||||
repstr[4] = 's'; /* Suspended */
|
||||
else
|
||||
field->report_string[4] = 'a'; /* Active */
|
||||
repstr[4] = 'a'; /* Active */
|
||||
if (info.open_count)
|
||||
field->report_string[5] = 'o'; /* Open */
|
||||
repstr[5] = 'o'; /* Open */
|
||||
else
|
||||
field->report_string[5] = '-';
|
||||
repstr[5] = '-';
|
||||
} else {
|
||||
field->report_string[4] = '-';
|
||||
field->report_string[5] = '-';
|
||||
repstr[4] = '-';
|
||||
repstr[5] = '-';
|
||||
}
|
||||
|
||||
field->sort_value = (void *) field->report_string;
|
||||
field->report_string = repstr;
|
||||
field->sort_value = (const void *) field->report_string;
|
||||
|
||||
return 1;
|
||||
}
|
||||
@ -211,24 +216,26 @@ static int _lvstatus_disp(struct report_handle *rh, struct field *field,
|
||||
static int _pvstatus_disp(struct report_handle *rh, struct field *field,
|
||||
const void *data)
|
||||
{
|
||||
uint32_t status = *(uint32_t *) data;
|
||||
const uint32_t status = *(const uint32_t *) data;
|
||||
char *repstr;
|
||||
|
||||
if (!(field->report_string = pool_zalloc(rh->mem, 4))) {
|
||||
if (!(repstr = pool_zalloc(rh->mem, 4))) {
|
||||
log_error("pool_alloc failed");
|
||||
return 0;
|
||||
}
|
||||
|
||||
if (status & ALLOCATABLE_PV)
|
||||
field->report_string[0] = 'a';
|
||||
repstr[0] = 'a';
|
||||
else
|
||||
field->report_string[0] = '-';
|
||||
repstr[0] = '-';
|
||||
|
||||
if (status & EXPORTED_VG)
|
||||
field->report_string[1] = 'x';
|
||||
repstr[1] = 'x';
|
||||
else
|
||||
field->report_string[1] = '-';
|
||||
repstr[1] = '-';
|
||||
|
||||
field->sort_value = (void *) field->report_string;
|
||||
field->report_string = repstr;
|
||||
field->sort_value = (const void *) field->report_string;
|
||||
|
||||
return 1;
|
||||
}
|
||||
@ -236,34 +243,36 @@ static int _pvstatus_disp(struct report_handle *rh, struct field *field,
|
||||
static int _vgstatus_disp(struct report_handle *rh, struct field *field,
|
||||
const void *data)
|
||||
{
|
||||
uint32_t status = *(uint32_t *) data;
|
||||
const uint32_t status = *(const uint32_t *) data;
|
||||
char *repstr;
|
||||
|
||||
if (!(field->report_string = pool_zalloc(rh->mem, 5))) {
|
||||
if (!(repstr = pool_zalloc(rh->mem, 5))) {
|
||||
log_error("pool_alloc failed");
|
||||
return 0;
|
||||
}
|
||||
|
||||
if (status & LVM_WRITE)
|
||||
field->report_string[0] = 'w';
|
||||
repstr[0] = 'w';
|
||||
else
|
||||
field->report_string[0] = 'r';
|
||||
repstr[0] = 'r';
|
||||
|
||||
if (status & RESIZEABLE_VG)
|
||||
field->report_string[1] = 'z';
|
||||
repstr[1] = 'z';
|
||||
else
|
||||
field->report_string[1] = '-';
|
||||
repstr[1] = '-';
|
||||
|
||||
if (status & EXPORTED_VG)
|
||||
field->report_string[2] = 'x';
|
||||
repstr[2] = 'x';
|
||||
else
|
||||
field->report_string[2] = '-';
|
||||
repstr[2] = '-';
|
||||
|
||||
if (status & PARTIAL_VG)
|
||||
field->report_string[3] = 'p';
|
||||
repstr[3] = 'p';
|
||||
else
|
||||
field->report_string[3] = '-';
|
||||
repstr[3] = '-';
|
||||
|
||||
field->sort_value = (void *) field->report_string;
|
||||
field->report_string = repstr;
|
||||
field->sort_value = (const void *) field->report_string;
|
||||
|
||||
return 1;
|
||||
}
|
||||
@ -271,13 +280,13 @@ static int _vgstatus_disp(struct report_handle *rh, struct field *field,
|
||||
static int _segtype_disp(struct report_handle *rh, struct field *field,
|
||||
const void *data)
|
||||
{
|
||||
struct lv_segment *seg = (struct lv_segment *) data;
|
||||
const struct lv_segment *seg = (const struct lv_segment *) data;
|
||||
|
||||
if (seg->stripes == 1)
|
||||
field->report_string = "linear";
|
||||
else
|
||||
field->report_string = (char *) get_segtype_string(seg->type);
|
||||
field->sort_value = (void *) field->report_string;
|
||||
field->report_string = get_segtype_string(seg->type);
|
||||
field->sort_value = (const void *) field->report_string;
|
||||
|
||||
return 1;
|
||||
}
|
||||
@ -285,14 +294,14 @@ static int _segtype_disp(struct report_handle *rh, struct field *field,
|
||||
static int _origin_disp(struct report_handle *rh, struct field *field,
|
||||
const void *data)
|
||||
{
|
||||
struct logical_volume *lv = (struct logical_volume *) data;
|
||||
const struct logical_volume *lv = (const struct logical_volume *) data;
|
||||
struct snapshot *snap;
|
||||
|
||||
if ((snap = find_cow(lv)))
|
||||
return _string_disp(rh, field, &snap->origin->name);
|
||||
|
||||
field->report_string = "";
|
||||
field->sort_value = (void *) field->report_string;
|
||||
field->sort_value = (const void *) field->report_string;
|
||||
|
||||
return 1;
|
||||
}
|
||||
@ -300,8 +309,9 @@ static int _origin_disp(struct report_handle *rh, struct field *field,
|
||||
static int _size32_disp(struct report_handle *rh, struct field *field,
|
||||
const void *data)
|
||||
{
|
||||
uint32_t size = *(uint32_t *) data;
|
||||
const uint32_t size = *(const uint32_t *) data;
|
||||
const char *disp;
|
||||
uint64_t *sortval;
|
||||
|
||||
if (!*(disp = display_size(rh->cmd, (uint64_t) size / 2, SIZE_UNIT))) {
|
||||
stack;
|
||||
@ -313,12 +323,13 @@ static int _size32_disp(struct report_handle *rh, struct field *field,
|
||||
return 0;
|
||||
}
|
||||
|
||||
if (!(field->sort_value = pool_alloc(rh->mem, sizeof(uint64_t)))) {
|
||||
if (!(sortval = pool_alloc(rh->mem, sizeof(uint64_t)))) {
|
||||
log_error("pool_alloc failed");
|
||||
return 0;
|
||||
}
|
||||
|
||||
*(uint64_t *) field->sort_value = (uint64_t) size;
|
||||
*sortval = (const uint64_t) size;
|
||||
field->sort_value = (const void *) sortval;
|
||||
|
||||
return 1;
|
||||
}
|
||||
@ -326,8 +337,9 @@ static int _size32_disp(struct report_handle *rh, struct field *field,
|
||||
static int _size64_disp(struct report_handle *rh, struct field *field,
|
||||
const void *data)
|
||||
{
|
||||
uint64_t size = *(uint64_t *) data;
|
||||
const uint64_t size = *(const uint64_t *) data;
|
||||
const char *disp;
|
||||
uint64_t *sortval;
|
||||
|
||||
if (!*(disp = display_size(rh->cmd, size / 2, SIZE_UNIT))) {
|
||||
stack;
|
||||
@ -339,12 +351,13 @@ static int _size64_disp(struct report_handle *rh, struct field *field,
|
||||
return 0;
|
||||
}
|
||||
|
||||
if (!(field->sort_value = pool_alloc(rh->mem, sizeof(uint64_t)))) {
|
||||
if (!(sortval = pool_alloc(rh->mem, sizeof(uint64_t)))) {
|
||||
log_error("pool_alloc failed");
|
||||
return 0;
|
||||
}
|
||||
|
||||
*(uint64_t *) field->sort_value = size;
|
||||
*sortval = size;
|
||||
field->sort_value = sortval;
|
||||
|
||||
return 1;
|
||||
}
|
||||
@ -352,7 +365,7 @@ static int _size64_disp(struct report_handle *rh, struct field *field,
|
||||
static int _vgsize_disp(struct report_handle *rh, struct field *field,
|
||||
const void *data)
|
||||
{
|
||||
struct volume_group *vg = (struct volume_group *) data;
|
||||
const struct volume_group *vg = (const struct volume_group *) data;
|
||||
uint64_t size;
|
||||
|
||||
size = vg->extent_count * vg->extent_size;
|
||||
@ -363,7 +376,7 @@ static int _vgsize_disp(struct report_handle *rh, struct field *field,
|
||||
static int _segstart_disp(struct report_handle *rh, struct field *field,
|
||||
const void *data)
|
||||
{
|
||||
struct lv_segment *seg = (struct lv_segment *) data;
|
||||
const struct lv_segment *seg = (const struct lv_segment *) data;
|
||||
uint64_t start;
|
||||
|
||||
start = seg->le * seg->lv->vg->extent_size;
|
||||
@ -374,7 +387,7 @@ static int _segstart_disp(struct report_handle *rh, struct field *field,
|
||||
static int _segsize_disp(struct report_handle *rh, struct field *field,
|
||||
const void *data)
|
||||
{
|
||||
struct lv_segment *seg = (struct lv_segment *) data;
|
||||
const struct lv_segment *seg = (const struct lv_segment *) data;
|
||||
uint64_t size;
|
||||
|
||||
size = seg->len * seg->lv->vg->extent_size;
|
||||
@ -385,7 +398,8 @@ static int _segsize_disp(struct report_handle *rh, struct field *field,
|
||||
static int _pvused_disp(struct report_handle *rh, struct field *field,
|
||||
const void *data)
|
||||
{
|
||||
struct physical_volume *pv = (struct physical_volume *) data;
|
||||
const struct physical_volume *pv =
|
||||
(const struct physical_volume *) data;
|
||||
uint64_t used;
|
||||
|
||||
if (!pv->pe_count)
|
||||
@ -399,21 +413,23 @@ static int _pvused_disp(struct report_handle *rh, struct field *field,
|
||||
static int _pvfree_disp(struct report_handle *rh, struct field *field,
|
||||
const void *data)
|
||||
{
|
||||
struct physical_volume *pv = (struct physical_volume *) data;
|
||||
uint64_t free;
|
||||
const struct physical_volume *pv =
|
||||
(const struct physical_volume *) data;
|
||||
uint64_t freespace;
|
||||
|
||||
if (!pv->pe_count)
|
||||
free = pv->size;
|
||||
freespace = pv->size;
|
||||
else
|
||||
free = (pv->pe_count - pv->pe_alloc_count) * pv->pe_size;
|
||||
freespace = (pv->pe_count - pv->pe_alloc_count) * pv->pe_size;
|
||||
|
||||
return _size64_disp(rh, field, &free);
|
||||
return _size64_disp(rh, field, &freespace);
|
||||
}
|
||||
|
||||
static int _pvsize_disp(struct report_handle *rh, struct field *field,
|
||||
const void *data)
|
||||
{
|
||||
struct physical_volume *pv = (struct physical_volume *) data;
|
||||
const struct physical_volume *pv =
|
||||
(const struct physical_volume *) data;
|
||||
uint64_t size;
|
||||
|
||||
if (!pv->pe_count)
|
||||
@ -427,28 +443,31 @@ static int _pvsize_disp(struct report_handle *rh, struct field *field,
|
||||
static int _vgfree_disp(struct report_handle *rh, struct field *field,
|
||||
const void *data)
|
||||
{
|
||||
struct volume_group *vg = (struct volume_group *) data;
|
||||
uint64_t free;
|
||||
const struct volume_group *vg = (const struct volume_group *) data;
|
||||
uint64_t freespace;
|
||||
|
||||
free = vg->free_count * vg->extent_size;
|
||||
freespace = vg->free_count * vg->extent_size;
|
||||
|
||||
return _size64_disp(rh, field, &free);
|
||||
return _size64_disp(rh, field, &freespace);
|
||||
}
|
||||
|
||||
static int _uuid_disp(struct report_handle *rh, struct field *field,
|
||||
const void *data)
|
||||
{
|
||||
char *repstr = NULL;
|
||||
|
||||
if (!(field->report_string = pool_alloc(rh->mem, 40))) {
|
||||
log_error("pool_alloc failed");
|
||||
return 0;
|
||||
}
|
||||
|
||||
if (!id_write_format((struct id *) data, field->report_string, 40)) {
|
||||
if (!id_write_format((const struct id *) data, repstr, 40)) {
|
||||
stack;
|
||||
return 0;
|
||||
}
|
||||
|
||||
field->sort_value = (void *) field->report_string;
|
||||
field->report_string = repstr;
|
||||
field->sort_value = (const void *) field->report_string;
|
||||
|
||||
return 1;
|
||||
}
|
||||
@ -456,57 +475,65 @@ static int _uuid_disp(struct report_handle *rh, struct field *field,
|
||||
static int _uint32_disp(struct report_handle *rh, struct field *field,
|
||||
const void *data)
|
||||
{
|
||||
uint32_t value = *(uint32_t *) data;
|
||||
const uint32_t value = *(const uint32_t *) data;
|
||||
uint64_t *sortval;
|
||||
char *repstr;
|
||||
|
||||
if (!(field->report_string = pool_zalloc(rh->mem, 12))) {
|
||||
if (!(repstr = pool_zalloc(rh->mem, 12))) {
|
||||
log_error("pool_alloc failed");
|
||||
return 0;
|
||||
}
|
||||
|
||||
if (!(field->sort_value = pool_alloc(rh->mem, sizeof(uint64_t)))) {
|
||||
if (!(sortval = pool_alloc(rh->mem, sizeof(uint64_t)))) {
|
||||
log_error("pool_alloc failed");
|
||||
return 0;
|
||||
}
|
||||
|
||||
*(uint64_t *) field->sort_value = value;
|
||||
|
||||
if (lvm_snprintf(field->report_string, 11, "%u", value) < 0) {
|
||||
if (lvm_snprintf(repstr, 11, "%u", value) < 0) {
|
||||
log_error("uint32 too big: %u", value);
|
||||
return 0;
|
||||
}
|
||||
|
||||
*sortval = (const uint64_t) value;
|
||||
field->sort_value = sortval;
|
||||
field->report_string = repstr;
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
static int _int32_disp(struct report_handle *rh, struct field *field,
|
||||
const void *data)
|
||||
{
|
||||
int32_t value = *(int32_t *) data;
|
||||
const int32_t value = *(const int32_t *) data;
|
||||
uint64_t *sortval;
|
||||
char *repstr;
|
||||
|
||||
if (!(field->report_string = pool_zalloc(rh->mem, 13))) {
|
||||
if (!(repstr = pool_zalloc(rh->mem, 13))) {
|
||||
log_error("pool_alloc failed");
|
||||
return 0;
|
||||
}
|
||||
|
||||
if (!(field->sort_value = pool_alloc(rh->mem, sizeof(int64_t)))) {
|
||||
if (!(sortval = pool_alloc(rh->mem, sizeof(int64_t)))) {
|
||||
log_error("pool_alloc failed");
|
||||
return 0;
|
||||
}
|
||||
|
||||
*(int64_t *) field->sort_value = value;
|
||||
|
||||
if (lvm_snprintf(field->report_string, 12, "%d", value) < 0) {
|
||||
if (lvm_snprintf(repstr, 12, "%d", value) < 0) {
|
||||
log_error("int32 too big: %d", value);
|
||||
return 0;
|
||||
}
|
||||
|
||||
*sortval = (const uint64_t) value;
|
||||
field->sort_value = sortval;
|
||||
field->report_string = repstr;
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
static int _lvsegcount_disp(struct report_handle *rh, struct field *field,
|
||||
const void *data)
|
||||
{
|
||||
struct logical_volume *lv = (struct logical_volume *) data;
|
||||
const struct logical_volume *lv = (const struct logical_volume *) data;
|
||||
uint32_t count;
|
||||
|
||||
count = list_size(&lv->segments);
|
||||
@ -517,11 +544,13 @@ static int _lvsegcount_disp(struct report_handle *rh, struct field *field,
|
||||
static int _snpercent_disp(struct report_handle *rh, struct field *field,
|
||||
const void *data)
|
||||
{
|
||||
struct logical_volume *lv = (struct logical_volume *) data;
|
||||
const struct logical_volume *lv = (const struct logical_volume *) data;
|
||||
struct snapshot *snap;
|
||||
float snap_percent;
|
||||
uint64_t *sortval;
|
||||
char *repstr;
|
||||
|
||||
if (!(field->sort_value = pool_alloc(rh->mem, sizeof(uint64_t)))) {
|
||||
if (!(sortval = pool_alloc(rh->mem, sizeof(uint64_t)))) {
|
||||
log_error("pool_alloc failed");
|
||||
return 0;
|
||||
}
|
||||
@ -529,11 +558,12 @@ static int _snpercent_disp(struct report_handle *rh, struct field *field,
|
||||
if (!(snap = find_cow(lv))
|
||||
|| !lv_snapshot_percent(snap->cow, &snap_percent)) {
|
||||
field->report_string = "";
|
||||
*(uint64_t *) field->sort_value = 0LL;
|
||||
*sortval = __UINT64_C(0);
|
||||
field->sort_value = sortval;
|
||||
return 1;
|
||||
}
|
||||
|
||||
if (!(field->report_string = pool_zalloc(rh->mem, 8))) {
|
||||
if (!(repstr = pool_zalloc(rh->mem, 8))) {
|
||||
log_error("pool_alloc failed");
|
||||
return 0;
|
||||
}
|
||||
@ -541,13 +571,15 @@ static int _snpercent_disp(struct report_handle *rh, struct field *field,
|
||||
if (snap_percent == -1)
|
||||
snap_percent = 100;
|
||||
|
||||
*(uint64_t *) field->sort_value = snap_percent * 1000;
|
||||
|
||||
if (lvm_snprintf(field->report_string, 7, "%.2f", snap_percent) < 0) {
|
||||
if (lvm_snprintf(repstr, 7, "%.2f", snap_percent) < 0) {
|
||||
log_error("snapshot percentage too large");
|
||||
return 0;
|
||||
}
|
||||
|
||||
*sortval = snap_percent * __UINT64_C(1000);
|
||||
field->sort_value = sortval;
|
||||
field->report_string = repstr;
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
@ -575,12 +607,12 @@ static struct {
|
||||
#undef NUM
|
||||
#undef FIELD
|
||||
|
||||
const int _num_fields = sizeof(_fields) / sizeof(_fields[0]);
|
||||
const unsigned int _num_fields = sizeof(_fields) / sizeof(_fields[0]);
|
||||
|
||||
/*
|
||||
* Initialise report handle
|
||||
*/
|
||||
static int _field_match(struct report_handle *rh, const char *field, int len)
|
||||
static int _field_match(struct report_handle *rh, const char *field, size_t len)
|
||||
{
|
||||
uint32_t f, l;
|
||||
struct field_properties *fp;
|
||||
@ -635,33 +667,33 @@ static int _add_sort_key(struct report_handle *rh, uint32_t field_num,
|
||||
|
||||
if (!found) {
|
||||
/* Add as a non-display field */
|
||||
if (!(fp = pool_zalloc(rh->mem, sizeof(*fp)))) {
|
||||
if (!(found = pool_zalloc(rh->mem, sizeof(*found)))) {
|
||||
log_error("struct field_properties allocation failed");
|
||||
return 0;
|
||||
}
|
||||
|
||||
rh->type |= _fields[field_num].type;
|
||||
fp->field_num = field_num;
|
||||
fp->width = _fields[field_num].width;
|
||||
fp->flags = _fields[field_num].flags | FLD_HIDDEN;
|
||||
found->field_num = field_num;
|
||||
found->width = _fields[field_num].width;
|
||||
found->flags = _fields[field_num].flags | FLD_HIDDEN;
|
||||
|
||||
list_add(&rh->field_props, &fp->list);
|
||||
list_add(&rh->field_props, &found->list);
|
||||
}
|
||||
|
||||
if (fp->flags & FLD_SORT_KEY) {
|
||||
if (found->flags & FLD_SORT_KEY) {
|
||||
log_error("Ignoring duplicate sort field: %s",
|
||||
_fields[field_num].id);
|
||||
return 1;
|
||||
}
|
||||
|
||||
fp->flags |= FLD_SORT_KEY;
|
||||
fp->sort_posn = rh->keys_count++;
|
||||
fp->flags |= flags;
|
||||
found->flags |= FLD_SORT_KEY;
|
||||
found->sort_posn = rh->keys_count++;
|
||||
found->flags |= flags;
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
static int _key_match(struct report_handle *rh, const char *key, int len)
|
||||
static int _key_match(struct report_handle *rh, const char *key, size_t len)
|
||||
{
|
||||
uint32_t f, l;
|
||||
uint32_t flags = 0;
|
||||
@ -711,7 +743,7 @@ static int _parse_options(struct report_handle *rh, const char *format)
|
||||
ws = we;
|
||||
while (*we && *we != ',')
|
||||
we++;
|
||||
if (!_field_match(rh, ws, we - ws)) {
|
||||
if (!_field_match(rh, ws, (size_t) (we - ws))) {
|
||||
log_error("Unrecognised field: %.*s", we - ws, ws);
|
||||
return 0;
|
||||
}
|
||||
@ -732,7 +764,7 @@ static int _parse_keys(struct report_handle *rh, const char *keys)
|
||||
ws = we;
|
||||
while (*we && *we != ',')
|
||||
we++;
|
||||
if (!_key_match(rh, ws, we - ws)) {
|
||||
if (!_key_match(rh, ws, (size_t) (we - ws))) {
|
||||
log_error("Unrecognised field: %.*s", we - ws, ws);
|
||||
return 0;
|
||||
}
|
||||
@ -837,7 +869,7 @@ int report_object(void *handle, struct volume_group *vg,
|
||||
struct field_properties *fp;
|
||||
struct row *row;
|
||||
struct field *field;
|
||||
void *data;
|
||||
void *data = NULL;
|
||||
|
||||
if (lv && pv) {
|
||||
log_error("report_object: One of *lv and *pv must be NULL!");
|
||||
@ -910,7 +942,7 @@ int report_object(void *handle, struct volume_group *vg,
|
||||
/*
|
||||
* Print row of headings
|
||||
*/
|
||||
int report_headings(void *handle)
|
||||
static int _report_headings(void *handle)
|
||||
{
|
||||
struct report_handle *rh = handle;
|
||||
struct list *fh;
|
||||
@ -948,17 +980,19 @@ int report_headings(void *handle)
|
||||
*/
|
||||
static int _row_compare(const void *a, const void *b)
|
||||
{
|
||||
struct row *rowa = *(struct row **) a;
|
||||
struct row *rowb = *(struct row **) b;
|
||||
struct field *sfa, *sfb;
|
||||
const struct row *rowa = *(const struct row **) a;
|
||||
const struct row *rowb = *(const struct row **) b;
|
||||
const struct field *sfa, *sfb;
|
||||
int32_t cnt = -1;
|
||||
|
||||
for (cnt = 0; cnt < rowa->rh->keys_count; cnt++) {
|
||||
sfa = (*rowa->sort_fields)[cnt];
|
||||
sfb = (*rowb->sort_fields)[cnt];
|
||||
if (sfa->props->flags & FLD_NUMBER) {
|
||||
uint64_t numa = *(uint64_t *) sfa->sort_value;
|
||||
uint64_t numb = *(uint64_t *) sfb->sort_value;
|
||||
const uint64_t numa =
|
||||
*(const uint64_t *) sfa->sort_value;
|
||||
const uint64_t numb =
|
||||
*(const uint64_t *) sfb->sort_value;
|
||||
|
||||
if (numa == numb)
|
||||
continue;
|
||||
@ -969,8 +1003,8 @@ static int _row_compare(const void *a, const void *b)
|
||||
return (numa < numb) ? 1 : -1;
|
||||
}
|
||||
} else { /* FLD_STRING */
|
||||
char *stra = (char *) sfa->sort_value;
|
||||
char *strb = (char *) sfb->sort_value;
|
||||
const char *stra = (const char *) sfa->sort_value;
|
||||
const char *strb = (const char *) sfb->sort_value;
|
||||
int cmp = strcmp(stra, strb);
|
||||
|
||||
if (!cmp)
|
||||
@ -1033,7 +1067,7 @@ int report_output(void *handle)
|
||||
|
||||
/* If headings not printed yet, calculate field widths and print them */
|
||||
if (!(rh->flags & RH_HEADINGS_PRINTED))
|
||||
report_headings(rh);
|
||||
_report_headings(rh);
|
||||
|
||||
/* Print and clear buffer */
|
||||
list_iterate_safe(rowh, rtmp, &rh->rows) {
|
||||
|
@ -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
|
||||
|
@ -7,8 +7,6 @@
|
||||
#ifndef _LVM_LIST_H
|
||||
#define _LVM_LIST_H
|
||||
|
||||
#include <assert.h>
|
||||
|
||||
struct list {
|
||||
struct list *n, *p;
|
||||
};
|
||||
@ -62,10 +60,10 @@ static inline int list_end(struct list *head, struct list *elem)
|
||||
#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)
|
||||
static inline unsigned int list_size(const struct list *head)
|
||||
{
|
||||
int s = 0;
|
||||
struct list *v;
|
||||
unsigned int s = 0;
|
||||
const struct list *v;
|
||||
|
||||
list_iterate(v, head)
|
||||
s++;
|
||||
|
19
make.tmpl.in
19
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}')
|
||||
|
||||
|
@ -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();
|
||||
|
@ -204,7 +204,7 @@ int backup_remove(const char *vg_name)
|
||||
struct volume_group *backup_read_vg(struct cmd_context *cmd,
|
||||
const char *vg_name, const char *file)
|
||||
{
|
||||
struct volume_group *vg;
|
||||
struct volume_group *vg = NULL;
|
||||
struct format_instance *tf;
|
||||
struct list *mdah;
|
||||
struct metadata_area *mda;
|
||||
@ -262,8 +262,8 @@ int backup_restore_vg(struct cmd_context *cmd, struct volume_group *vg)
|
||||
return 0;
|
||||
}
|
||||
if (!vg->fid->fmt->ops->
|
||||
pv_setup(vg->fid->fmt, 0, 0, 0, 0, 0,
|
||||
&vg->fid->metadata_areas, pv, vg)) {
|
||||
pv_setup(vg->fid->fmt, __UINT64_C(0), 0, 0, 0,
|
||||
__UINT64_C(0), &vg->fid->metadata_areas, pv, vg)) {
|
||||
log_error("Format-specific setup for %s failed",
|
||||
dev_name(pv->dev));
|
||||
return 0;
|
||||
@ -310,7 +310,7 @@ int backup_restore(struct cmd_context *cmd, const char *vg_name)
|
||||
|
||||
int backup_to_file(const char *file, const char *desc, struct volume_group *vg)
|
||||
{
|
||||
int r;
|
||||
int r = 0;
|
||||
struct format_instance *tf;
|
||||
struct list *mdah;
|
||||
struct metadata_area *mda;
|
||||
|
@ -23,9 +23,9 @@
|
||||
static int lvchange_permission(struct cmd_context *cmd,
|
||||
struct logical_volume *lv)
|
||||
{
|
||||
int lv_access;
|
||||
uint32_t lv_access;
|
||||
|
||||
lv_access = arg_int_value(cmd, permission_ARG, 0);
|
||||
lv_access = arg_uint_value(cmd, permission_ARG, 0);
|
||||
|
||||
if ((lv_access & LVM_WRITE) && (lv->status & LVM_WRITE)) {
|
||||
log_error("Logical volume \"%s\" is already writable",
|
||||
@ -162,9 +162,9 @@ static int lvchange_contiguous(struct cmd_context *cmd,
|
||||
static int lvchange_readahead(struct cmd_context *cmd,
|
||||
struct logical_volume *lv)
|
||||
{
|
||||
int read_ahead = 0;
|
||||
unsigned int read_ahead = 0;
|
||||
|
||||
read_ahead = arg_int_value(cmd, readahead_ARG, 0);
|
||||
read_ahead = arg_uint_value(cmd, readahead_ARG, 0);
|
||||
|
||||
/******* FIXME Ranges?
|
||||
if (read_ahead < LVM_MIN_READ_AHEAD || read_ahead > LVM_MAX_READ_AHEAD) {
|
||||
|
@ -17,8 +17,8 @@ struct lvcreate_params {
|
||||
int minor;
|
||||
|
||||
char *origin;
|
||||
char *vg_name;
|
||||
char *lv_name;
|
||||
const char *vg_name;
|
||||
const char *lv_name;
|
||||
|
||||
uint32_t stripes;
|
||||
uint32_t stripe_size;
|
||||
@ -140,11 +140,11 @@ static int _read_size_params(struct lvcreate_params *lp,
|
||||
}
|
||||
|
||||
if (arg_count(cmd, extents_ARG))
|
||||
lp->extents = arg_int_value(cmd, extents_ARG, 0);
|
||||
lp->extents = arg_uint_value(cmd, extents_ARG, 0);
|
||||
|
||||
/* Size returned in kilobyte units; held in sectors */
|
||||
if (arg_count(cmd, size_ARG))
|
||||
lp->size = arg_uint64_value(cmd, size_ARG, 0) * 2ull;
|
||||
lp->size = arg_uint64_value(cmd, size_ARG, __UINT64_C(0)) * 2;
|
||||
|
||||
return 1;
|
||||
}
|
||||
@ -158,13 +158,13 @@ static int _read_stripe_params(struct lvcreate_params *lp,
|
||||
lp->stripes = 1;
|
||||
|
||||
if (arg_count(cmd, stripes_ARG)) {
|
||||
lp->stripes = arg_int_value(cmd, stripes_ARG, 1);
|
||||
lp->stripes = arg_uint_value(cmd, stripes_ARG, 1);
|
||||
if (lp->stripes == 1)
|
||||
log_print("Redundant stripes argument: default is 1");
|
||||
}
|
||||
|
||||
if (arg_count(cmd, stripesize_ARG))
|
||||
lp->stripe_size = 2 * arg_int_value(cmd, stripesize_ARG, 0);
|
||||
lp->stripe_size = 2 * arg_uint_value(cmd, stripesize_ARG, 0);
|
||||
|
||||
if (lp->stripes == 1 && lp->stripe_size) {
|
||||
log_print("Ignoring stripesize argument with single stripe");
|
||||
@ -172,7 +172,9 @@ static int _read_stripe_params(struct lvcreate_params *lp,
|
||||
}
|
||||
|
||||
if (lp->stripes > 1 && !lp->stripe_size) {
|
||||
lp->stripe_size = 2 * STRIPE_SIZE_DEFAULT;
|
||||
lp->stripe_size = find_config_int(cmd->cf->root,
|
||||
"metadata/stripesize", '/',
|
||||
DEFAULT_STRIPESIZE) * 2;
|
||||
log_print("Using default stripesize %dKB", lp->stripe_size / 2);
|
||||
}
|
||||
|
||||
@ -211,7 +213,7 @@ static int _read_params(struct lvcreate_params *lp, struct cmd_context *cmd,
|
||||
log_error("-s and -Z are incompatible");
|
||||
return 0;
|
||||
}
|
||||
lp->chunk_size = 2 * arg_int_value(cmd, chunksize_ARG, 8);
|
||||
lp->chunk_size = 2 * arg_uint_value(cmd, chunksize_ARG, 8);
|
||||
log_verbose("Setting chunksize to %d sectors.", lp->chunk_size);
|
||||
} else {
|
||||
if (arg_count(cmd, chunksize_ARG)) {
|
||||
@ -239,13 +241,13 @@ static int _read_params(struct lvcreate_params *lp, struct cmd_context *cmd,
|
||||
* Read ahead.
|
||||
*/
|
||||
if (arg_count(cmd, readahead_ARG))
|
||||
lp->read_ahead = arg_int_value(cmd, readahead_ARG, 0);
|
||||
lp->read_ahead = arg_uint_value(cmd, readahead_ARG, 0);
|
||||
|
||||
/*
|
||||
* Permissions.
|
||||
*/
|
||||
if (arg_count(cmd, permission_ARG))
|
||||
lp->permission = arg_int_value(cmd, permission_ARG, 0);
|
||||
lp->permission = arg_uint_value(cmd, permission_ARG, 0);
|
||||
else
|
||||
lp->permission = LVM_READ | LVM_WRITE;
|
||||
|
||||
@ -309,7 +311,7 @@ static int _zero_lv(struct cmd_context *cmd, struct logical_volume *lv)
|
||||
if (!(dev_open(dev, O_WRONLY)))
|
||||
return 0;
|
||||
|
||||
dev_zero(dev, 0, 4096);
|
||||
dev_zero(dev, __UINT64_C(0), (size_t) 4096);
|
||||
dev_close(dev);
|
||||
|
||||
return 1;
|
||||
@ -321,7 +323,7 @@ static int _lvcreate(struct cmd_context *cmd, struct lvcreate_params *lp)
|
||||
uint32_t status = 0;
|
||||
alloc_policy_t alloc = ALLOC_DEFAULT;
|
||||
struct volume_group *vg;
|
||||
struct logical_volume *lv, *org;
|
||||
struct logical_volume *lv, *org = NULL;
|
||||
struct list *pvh;
|
||||
int consistent = 1;
|
||||
|
||||
@ -381,7 +383,7 @@ static int _lvcreate(struct cmd_context *cmd, struct lvcreate_params *lp)
|
||||
lp->extents += vg->extent_size - lp->extents %
|
||||
vg->extent_size;
|
||||
log_print("Rounding up size to full physical extent %s",
|
||||
display_size(cmd, lp->extents / 2,
|
||||
display_size(cmd, (uint64_t) lp->extents / 2,
|
||||
SIZE_SHORT));
|
||||
}
|
||||
|
||||
|
@ -20,8 +20,8 @@
|
||||
|
||||
#include "tools.h"
|
||||
|
||||
int lvdisplay_single(struct cmd_context *cmd, struct logical_volume *lv,
|
||||
void *handle)
|
||||
static int _lvdisplay_single(struct cmd_context *cmd, struct logical_volume *lv,
|
||||
void *handle)
|
||||
{
|
||||
if (arg_count(cmd, colon_ARG))
|
||||
lvdisplay_colons(lv);
|
||||
@ -57,5 +57,5 @@ int lvdisplay(struct cmd_context *cmd, int argc, char **argv)
|
||||
}
|
||||
|
||||
return process_each_lv(cmd, argc, argv, LCK_VG_READ, NULL,
|
||||
&lvdisplay_single);
|
||||
&_lvdisplay_single);
|
||||
}
|
||||
|
91
tools/lvm.c
91
tools/lvm.c
@ -5,13 +5,11 @@
|
||||
*/
|
||||
|
||||
#include "tools.h"
|
||||
#include "defaults.h"
|
||||
#include "label.h"
|
||||
#include "version.h"
|
||||
|
||||
#include "stub.h"
|
||||
|
||||
#include <assert.h>
|
||||
#include <getopt.h>
|
||||
#include <signal.h>
|
||||
#include <syslog.h>
|
||||
@ -32,7 +30,7 @@
|
||||
*/
|
||||
struct arg the_args[ARG_COUNT + 1] = {
|
||||
|
||||
#define arg(a, b, c, d) {b, "--" c, d, 0, NULL},
|
||||
#define arg(a, b, c, d) {b, "--" c, d, 0, NULL, 0, 0, __INT64_C(0), __UINT64_C(0), 0, NULL},
|
||||
#include "args.h"
|
||||
#undef arg
|
||||
|
||||
@ -48,11 +46,15 @@ int yes_no_arg(struct cmd_context *cmd, struct arg *a)
|
||||
{
|
||||
a->sign = SIGN_NONE;
|
||||
|
||||
if (!strcmp(a->value, "y"))
|
||||
if (!strcmp(a->value, "y")) {
|
||||
a->i_value = 1;
|
||||
a->ui_value = 1;
|
||||
}
|
||||
|
||||
else if (!strcmp(a->value, "n"))
|
||||
else if (!strcmp(a->value, "n")) {
|
||||
a->i_value = 0;
|
||||
a->ui_value = 0;
|
||||
}
|
||||
|
||||
else
|
||||
return 0;
|
||||
@ -82,7 +84,7 @@ int metadatatype_arg(struct cmd_context *cmd, struct arg *a)
|
||||
return 0;
|
||||
}
|
||||
|
||||
int _get_int_arg(struct arg *a, char **ptr)
|
||||
static int _get_int_arg(struct arg *a, char **ptr)
|
||||
{
|
||||
char *val;
|
||||
long v;
|
||||
@ -109,7 +111,9 @@ int _get_int_arg(struct arg *a, char **ptr)
|
||||
if (*ptr == val)
|
||||
return 0;
|
||||
|
||||
a->i_value = (uint32_t) v;
|
||||
a->i_value = (int32_t) v;
|
||||
a->ui_value = (uint32_t) v;
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
@ -117,7 +121,7 @@ static int _size_arg(struct cmd_context *cmd, struct arg *a, int factor)
|
||||
{
|
||||
char *ptr;
|
||||
int i;
|
||||
static char *suffixes = "kmgt";
|
||||
static const char *suffixes = "kmgt";
|
||||
char *val;
|
||||
double v;
|
||||
|
||||
@ -156,7 +160,8 @@ static int _size_arg(struct cmd_context *cmd, struct arg *a, int factor)
|
||||
} else
|
||||
v *= factor;
|
||||
|
||||
a->i_value = (uint32_t) v;
|
||||
a->i_value = (int32_t) v;
|
||||
a->ui_value = (uint32_t) v;
|
||||
a->i64_value = (int64_t) v;
|
||||
a->ui64_value = (uint64_t) v;
|
||||
|
||||
@ -218,10 +223,10 @@ int permission_arg(struct cmd_context *cmd, struct arg *a)
|
||||
a->sign = SIGN_NONE;
|
||||
|
||||
if ((!strcmp(a->value, "rw")) || (!strcmp(a->value, "wr")))
|
||||
a->i_value = LVM_READ | LVM_WRITE;
|
||||
a->ui_value = LVM_READ | LVM_WRITE;
|
||||
|
||||
else if (!strcmp(a->value, "r"))
|
||||
a->i_value = LVM_READ;
|
||||
a->ui_value = LVM_READ;
|
||||
|
||||
else
|
||||
return 0;
|
||||
@ -268,7 +273,7 @@ static void _alloc_command(void)
|
||||
}
|
||||
|
||||
static void _create_new_command(const char *name, command_fn command,
|
||||
const char *desc, const char *usage,
|
||||
const char *desc, const char *usagestr,
|
||||
int nargs, int *args)
|
||||
{
|
||||
struct command *nc;
|
||||
@ -279,21 +284,21 @@ static void _create_new_command(const char *name, command_fn command,
|
||||
|
||||
nc->name = name;
|
||||
nc->desc = desc;
|
||||
nc->usage = usage;
|
||||
nc->usage = usagestr;
|
||||
nc->fn = command;
|
||||
nc->num_args = nargs;
|
||||
nc->valid_args = args;
|
||||
}
|
||||
|
||||
static void _register_command(const char *name, command_fn fn,
|
||||
const char *desc, const char *usage, ...)
|
||||
const char *desc, const char *usagestr, ...)
|
||||
{
|
||||
int nargs = 0, i;
|
||||
int *args;
|
||||
va_list ap;
|
||||
|
||||
/* count how many arguments we have */
|
||||
va_start(ap, usage);
|
||||
va_start(ap, usagestr);
|
||||
while (va_arg(ap, int) >= 0)
|
||||
nargs++;
|
||||
va_end(ap);
|
||||
@ -305,13 +310,13 @@ static void _register_command(const char *name, command_fn fn,
|
||||
}
|
||||
|
||||
/* fill them in */
|
||||
va_start(ap, usage);
|
||||
va_start(ap, usagestr);
|
||||
for (i = 0; i < nargs; i++)
|
||||
args[i] = va_arg(ap, int);
|
||||
va_end(ap);
|
||||
|
||||
/* enter the command in the register */
|
||||
_create_new_command(name, fn, desc, usage, nargs, args);
|
||||
_create_new_command(name, fn, desc, usagestr, nargs, args);
|
||||
}
|
||||
|
||||
static void _register_commands()
|
||||
@ -346,7 +351,7 @@ static struct command *_find_command(const char *name)
|
||||
return _commands + i;
|
||||
}
|
||||
|
||||
void usage(const char *name)
|
||||
static void _usage(const char *name)
|
||||
{
|
||||
struct command *com = _find_command(name);
|
||||
|
||||
@ -416,12 +421,15 @@ static int _process_command_line(struct cmd_context *cmd, int *argc,
|
||||
struct arg *a;
|
||||
|
||||
for (i = 0; i < ARG_COUNT; i++) {
|
||||
struct arg *a = the_args + i;
|
||||
a = the_args + i;
|
||||
|
||||
/* zero the count and arg */
|
||||
a->count = 0;
|
||||
a->value = 0;
|
||||
a->i_value = 0;
|
||||
a->ui_value = 0;
|
||||
a->i64_value = 0;
|
||||
a->ui64_value = 0;
|
||||
}
|
||||
|
||||
/* fill in the short and long opts */
|
||||
@ -471,7 +479,8 @@ static int _process_command_line(struct cmd_context *cmd, int *argc,
|
||||
|
||||
static int _merge_synonym(struct cmd_context *cmd, int oldarg, int newarg)
|
||||
{
|
||||
struct arg *old, *new;
|
||||
const struct arg *old;
|
||||
struct arg *new;
|
||||
|
||||
if (arg_count(cmd, oldarg) && arg_count(cmd, newarg)) {
|
||||
log_error("%s and %s are synonyms. Please only supply one.",
|
||||
@ -488,6 +497,9 @@ static int _merge_synonym(struct cmd_context *cmd, int oldarg, int newarg)
|
||||
new->count = old->count;
|
||||
new->value = old->value;
|
||||
new->i_value = old->i_value;
|
||||
new->ui_value = old->ui_value;
|
||||
new->i64_value = old->i64_value;
|
||||
new->ui64_value = old->ui64_value;
|
||||
new->sign = old->sign;
|
||||
|
||||
return 1;
|
||||
@ -495,13 +507,13 @@ static int _merge_synonym(struct cmd_context *cmd, int oldarg, int newarg)
|
||||
|
||||
int version(struct cmd_context *cmd, int argc, char **argv)
|
||||
{
|
||||
char version[80];
|
||||
char vsn[80];
|
||||
|
||||
log_print("LVM version: %s", LVM_VERSION);
|
||||
if (library_version(version, sizeof(version)))
|
||||
log_print("Library version: %s", version);
|
||||
if (driver_version(version, sizeof(version)))
|
||||
log_print("Driver version: %s", version);
|
||||
if (library_version(vsn, sizeof(vsn)))
|
||||
log_print("Library version: %s", vsn);
|
||||
if (driver_version(vsn, sizeof(vsn)))
|
||||
log_print("Driver version: %s", vsn);
|
||||
|
||||
return ECMD_PROCESSED;
|
||||
}
|
||||
@ -572,7 +584,7 @@ static int _get_settings(struct cmd_context *cmd)
|
||||
static int _process_common_commands(struct cmd_context *cmd)
|
||||
{
|
||||
if (arg_count(cmd, help_ARG) || arg_count(cmd, help2_ARG)) {
|
||||
usage(cmd->command->name);
|
||||
_usage(cmd->command->name);
|
||||
return ECMD_PROCESSED;
|
||||
}
|
||||
|
||||
@ -606,7 +618,7 @@ int help(struct cmd_context *cmd, int argc, char **argv)
|
||||
else {
|
||||
int i;
|
||||
for (i = 0; i < argc; i++)
|
||||
usage(argv[i]);
|
||||
_usage(argv[i]);
|
||||
}
|
||||
|
||||
return 0;
|
||||
@ -646,7 +658,8 @@ static char *_copy_command_line(struct cmd_context *cmd, int argc, char **argv)
|
||||
goto bad;
|
||||
|
||||
if (i < (argc - 1))
|
||||
if (!pool_grow_object(cmd->mem, " ", 1)) ;
|
||||
if (!pool_grow_object(cmd->mem, " ", 1))
|
||||
goto bad;
|
||||
}
|
||||
|
||||
/*
|
||||
@ -721,7 +734,7 @@ static int _run_command(struct cmd_context *cmd, int argc, char **argv)
|
||||
pool_empty(cmd->mem);
|
||||
|
||||
if (ret == EINVALID_CMD_LINE && !_interactive)
|
||||
usage(cmd->command->name);
|
||||
_usage(cmd->command->name);
|
||||
|
||||
return ret;
|
||||
}
|
||||
@ -761,7 +774,7 @@ static void _init_rand(void)
|
||||
|
||||
static int _init_backup(struct cmd_context *cmd, struct config_tree *cf)
|
||||
{
|
||||
int days, min;
|
||||
uint32_t days, min;
|
||||
char default_dir[PATH_MAX];
|
||||
const char *dir;
|
||||
|
||||
@ -777,11 +790,11 @@ static int _init_backup(struct cmd_context *cmd, struct config_tree *cf)
|
||||
find_config_bool(cmd->cf->root, "backup/archive", '/',
|
||||
DEFAULT_ARCHIVE_ENABLED);
|
||||
|
||||
days = find_config_int(cmd->cf->root, "backup/retain_days", '/',
|
||||
DEFAULT_ARCHIVE_DAYS);
|
||||
days = (uint32_t) find_config_int(cmd->cf->root, "backup/retain_days",
|
||||
'/', DEFAULT_ARCHIVE_DAYS);
|
||||
|
||||
min = find_config_int(cmd->cf->root, "backup/retain_min", '/',
|
||||
DEFAULT_ARCHIVE_NUMBER);
|
||||
min = (uint32_t) find_config_int(cmd->cf->root, "backup/retain_min",
|
||||
'/', DEFAULT_ARCHIVE_NUMBER);
|
||||
|
||||
if (lvm_snprintf
|
||||
(default_dir, sizeof(default_dir), "%s/%s", cmd->sys_dir,
|
||||
@ -909,7 +922,7 @@ static int _run_script(struct cmd_context *cmd, int argc, char **argv)
|
||||
static char *_list_cmds(const char *text, int state)
|
||||
{
|
||||
static int i = 0;
|
||||
static int len = 0;
|
||||
static size_t len = 0;
|
||||
|
||||
/* Initialise if this is a new completion attempt */
|
||||
if (!state) {
|
||||
@ -928,7 +941,7 @@ static char *_list_cmds(const char *text, int state)
|
||||
static char *_list_args(const char *text, int state)
|
||||
{
|
||||
static int match_no = 0;
|
||||
static int len = 0;
|
||||
static size_t len = 0;
|
||||
static struct command *com;
|
||||
|
||||
/* Initialise if this is a new completion attempt */
|
||||
@ -946,10 +959,10 @@ static char *_list_args(const char *text, int state)
|
||||
|
||||
/* Look for word in list of commands */
|
||||
for (j = 0; j < _num_commands; j++) {
|
||||
char *p;
|
||||
const char *p;
|
||||
char *q = s;
|
||||
|
||||
p = (char *) _commands[j].name;
|
||||
p = _commands[j].name;
|
||||
while (*p == *q) {
|
||||
p++;
|
||||
q++;
|
||||
@ -984,7 +997,7 @@ static char *_list_args(const char *text, int state)
|
||||
match_no = com->num_args;
|
||||
|
||||
while (match_no - com->num_args < com->num_args) {
|
||||
char *l;
|
||||
const char *l;
|
||||
l = (the_args +
|
||||
com->valid_args[match_no++ - com->num_args])->long_arg;
|
||||
if (*(l + 2) && !strncmp(text, l, len))
|
||||
|
@ -22,7 +22,7 @@ int max_len;
|
||||
static int _get_max_dev_name_len(struct dev_filter *filter)
|
||||
{
|
||||
int len = 0;
|
||||
int max_len = 0;
|
||||
int maxlen = 0;
|
||||
struct dev_iter *iter;
|
||||
struct device *dev;
|
||||
|
||||
@ -34,12 +34,12 @@ static int _get_max_dev_name_len(struct dev_filter *filter)
|
||||
/* Do scan */
|
||||
for (dev = dev_iter_get(iter); dev; dev = dev_iter_get(iter)) {
|
||||
len = strlen(dev_name(dev));
|
||||
if (len > max_len)
|
||||
max_len = len;
|
||||
if (len > maxlen)
|
||||
maxlen = len;
|
||||
}
|
||||
dev_iter_destroy(iter);
|
||||
|
||||
return max_len;
|
||||
return maxlen;
|
||||
}
|
||||
|
||||
static void _count(struct device *dev, int *disks, int *parts)
|
||||
@ -52,8 +52,8 @@ static void _count(struct device *dev, int *disks, int *parts)
|
||||
(*parts)++;
|
||||
}
|
||||
|
||||
static void _print(struct cmd_context *cmd, struct device *dev, uint64_t size,
|
||||
char *what)
|
||||
static void _print(struct cmd_context *cmd, const struct device *dev,
|
||||
uint64_t size, const char *what)
|
||||
{
|
||||
log_print("%-*s [%15s] %s", max_len, dev_name(dev),
|
||||
display_size(cmd, size / 2, SIZE_SHORT), what ? : "");
|
||||
@ -67,7 +67,7 @@ static int _check_device(struct cmd_context *cmd, struct device *dev)
|
||||
if (!dev_open(dev, 0)) {
|
||||
return 0;
|
||||
}
|
||||
if (dev_read(dev, 0, 1, &buffer) != 1) {
|
||||
if (dev_read(dev, __UINT64_C(0), (size_t) 1, &buffer) != 1) {
|
||||
dev_close(dev);
|
||||
return 0;
|
||||
}
|
||||
|
@ -22,9 +22,9 @@
|
||||
|
||||
int lvrename(struct cmd_context *cmd, int argc, char **argv)
|
||||
{
|
||||
int maxlen;
|
||||
size_t maxlen;
|
||||
char *lv_name_old, *lv_name_new;
|
||||
char *vg_name, *vg_name_new, *vg_name_old;
|
||||
const char *vg_name, *vg_name_new, *vg_name_old;
|
||||
char *st;
|
||||
int consistent = 1;
|
||||
|
||||
@ -78,7 +78,7 @@ int lvrename(struct cmd_context *cmd, int argc, char **argv)
|
||||
maxlen = NAME_LEN - strlen(vg_name) - strlen(cmd->dev_dir) - 3;
|
||||
if (strlen(lv_name_new) > maxlen) {
|
||||
log_error("New logical volume path exceeds maximum length "
|
||||
"of %d!", maxlen);
|
||||
"of %u!", maxlen);
|
||||
return ECMD_FAILED;
|
||||
}
|
||||
|
||||
|
@ -27,12 +27,13 @@ int lvresize(struct cmd_context *cmd, int argc, char **argv)
|
||||
struct dm_info info;
|
||||
uint32_t extents = 0;
|
||||
uint32_t size = 0;
|
||||
uint32_t stripes = 0, stripesize = 0, stripesize_extents = 0;
|
||||
uint32_t stripes = 0, ssize = 0, stripesize_extents = 0;
|
||||
uint32_t seg_stripes = 0, seg_stripesize = 0, seg_size = 0;
|
||||
uint32_t extents_used = 0;
|
||||
uint32_t size_rest;
|
||||
sign_t sign = SIGN_NONE;
|
||||
char *lv_name, *vg_name;
|
||||
char *lv_name;
|
||||
const char *vg_name;
|
||||
char *st;
|
||||
const char *cmd_name;
|
||||
struct list *pvh, *segh;
|
||||
@ -58,12 +59,12 @@ int lvresize(struct cmd_context *cmd, int argc, char **argv)
|
||||
}
|
||||
|
||||
if (arg_count(cmd, extents_ARG)) {
|
||||
extents = arg_int_value(cmd, extents_ARG, 0);
|
||||
extents = arg_uint_value(cmd, extents_ARG, 0);
|
||||
sign = arg_sign_value(cmd, extents_ARG, SIGN_NONE);
|
||||
}
|
||||
|
||||
if (arg_count(cmd, size_ARG)) {
|
||||
size = arg_int_value(cmd, size_ARG, 0);
|
||||
size = arg_uint_value(cmd, size_ARG, 0);
|
||||
sign = arg_sign_value(cmd, size_ARG, SIGN_NONE);
|
||||
}
|
||||
|
||||
@ -125,14 +126,14 @@ int lvresize(struct cmd_context *cmd, int argc, char **argv)
|
||||
|
||||
if (arg_count(cmd, stripes_ARG)) {
|
||||
if (vg->fid->fmt->features & FMT_SEGMENTS)
|
||||
stripes = arg_int_value(cmd, stripes_ARG, 1);
|
||||
stripes = arg_uint_value(cmd, stripes_ARG, 1);
|
||||
else
|
||||
log_print("Varied striping not supported. Ignoring.");
|
||||
}
|
||||
|
||||
if (arg_count(cmd, stripesize_ARG)) {
|
||||
if (vg->fid->fmt->features & FMT_SEGMENTS)
|
||||
stripesize = 2 * arg_int_value(cmd, stripesize_ARG, 0);
|
||||
ssize = 2 * arg_uint_value(cmd, stripesize_ARG, 0);
|
||||
else
|
||||
log_print("Varied stripesize not supported. Ignoring.");
|
||||
}
|
||||
@ -151,7 +152,8 @@ int lvresize(struct cmd_context *cmd, int argc, char **argv)
|
||||
(extents % vg->extent_size);
|
||||
|
||||
log_print("Rounding up size to full physical extent %s",
|
||||
display_size(cmd, extents / 2, SIZE_SHORT));
|
||||
display_size(cmd, (uint64_t) extents / 2,
|
||||
SIZE_SHORT));
|
||||
}
|
||||
|
||||
extents /= vg->extent_size;
|
||||
@ -184,8 +186,7 @@ int lvresize(struct cmd_context *cmd, int argc, char **argv)
|
||||
seg_size = extents - lv->le_count;
|
||||
|
||||
/* If extending, find stripes, stripesize & size of last segment */
|
||||
if (extents > lv->le_count &&
|
||||
!(stripes == 1 || (stripes > 1 && stripesize))) {
|
||||
if (extents > lv->le_count && !(stripes == 1 || (stripes > 1 && ssize))) {
|
||||
list_iterate(segh, &lv->segments) {
|
||||
struct lv_segment *seg;
|
||||
uint32_t sz, str;
|
||||
@ -195,7 +196,7 @@ int lvresize(struct cmd_context *cmd, int argc, char **argv)
|
||||
str = seg->stripes;
|
||||
|
||||
if ((seg_stripesize && seg_stripesize != sz
|
||||
&& !stripesize) ||
|
||||
&& !ssize) ||
|
||||
(seg_stripes && seg_stripes != str && !stripes)) {
|
||||
log_error("Please specify number of "
|
||||
"stripes (-i) and stripesize (-I)");
|
||||
@ -209,15 +210,18 @@ int lvresize(struct cmd_context *cmd, int argc, char **argv)
|
||||
if (!stripes)
|
||||
stripes = seg_stripes;
|
||||
|
||||
if (!stripesize && stripes > 1) {
|
||||
if (!ssize && stripes > 1) {
|
||||
if (seg_stripesize) {
|
||||
log_print("Using stripesize of last segment "
|
||||
"%dKB", seg_stripesize / 2);
|
||||
stripesize = seg_stripesize;
|
||||
ssize = seg_stripesize;
|
||||
} else {
|
||||
ssize = find_config_int(cmd->cf->root,
|
||||
"metadata/stripesize",
|
||||
'/',
|
||||
DEFAULT_STRIPESIZE) * 2;
|
||||
log_print("Using default stripesize %dKB",
|
||||
STRIPE_SIZE_DEFAULT);
|
||||
stripesize = 2 * STRIPE_SIZE_DEFAULT;
|
||||
ssize / 2);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -226,7 +230,7 @@ int lvresize(struct cmd_context *cmd, int argc, char **argv)
|
||||
if (extents < lv->le_count) {
|
||||
extents_used = 0;
|
||||
|
||||
if (stripes || stripesize)
|
||||
if (stripes || ssize)
|
||||
log_error("Ignoring stripes and stripesize arguments "
|
||||
"when reducing");
|
||||
|
||||
@ -247,17 +251,17 @@ int lvresize(struct cmd_context *cmd, int argc, char **argv)
|
||||
}
|
||||
|
||||
seg_size = extents - extents_used;
|
||||
stripesize = seg_stripesize;
|
||||
ssize = seg_stripesize;
|
||||
stripes = seg_stripes;
|
||||
}
|
||||
|
||||
if (stripes > 1 && !stripesize) {
|
||||
if (stripes > 1 && !ssize) {
|
||||
log_error("Stripesize for striped segment should not be 0!");
|
||||
goto error_cmdline;
|
||||
}
|
||||
|
||||
if ((stripes > 1)) {
|
||||
if (!(stripesize_extents = stripesize / vg->extent_size))
|
||||
if (!(stripesize_extents = ssize / vg->extent_size))
|
||||
stripesize_extents = 1;
|
||||
|
||||
if ((size_rest = seg_size % (stripes * stripesize_extents))) {
|
||||
@ -332,26 +336,22 @@ int lvresize(struct cmd_context *cmd, int argc, char **argv)
|
||||
goto error;
|
||||
}
|
||||
|
||||
if ((resize == LV_EXTEND && argc) &&
|
||||
!(pvh = create_pv_list(cmd->mem, vg, argc - opt, argv + opt))) {
|
||||
stack;
|
||||
goto error;
|
||||
}
|
||||
|
||||
if (resize == LV_EXTEND) {
|
||||
if (!(pvh = argc ? create_pv_list(cmd->mem, vg, argc - opt,
|
||||
argv + opt) : &vg->pvs)) {
|
||||
stack;
|
||||
goto error;
|
||||
}
|
||||
|
||||
if (!archive(vg))
|
||||
goto error;
|
||||
|
||||
if (!argc) {
|
||||
/* Use full list from VG */
|
||||
pvh = &vg->pvs;
|
||||
}
|
||||
log_print("Extending logical volume %s to %s", lv_name,
|
||||
display_size(cmd, (uint64_t)
|
||||
extents * (vg->extent_size / 2),
|
||||
SIZE_SHORT));
|
||||
|
||||
if (!lv_extend(vg->fid, lv, stripes, stripesize,
|
||||
if (!lv_extend(vg->fid, lv, stripes, ssize,
|
||||
extents - lv->le_count, pvh))
|
||||
goto error;
|
||||
}
|
||||
|
@ -29,6 +29,7 @@ static int lvscan_single(struct cmd_context *cmd, struct logical_volume *lv,
|
||||
|
||||
const char *active_str, *snapshot_str;
|
||||
|
||||
/* FIXME Add -D arg to skip this! */
|
||||
if (lv_info(lv, &info) && info.exists)
|
||||
active_str = "ACTIVE ";
|
||||
else
|
||||
@ -46,6 +47,8 @@ static int lvscan_single(struct cmd_context *cmd, struct logical_volume *lv,
|
||||
display_size(cmd, lv->size / 2, SIZE_SHORT),
|
||||
get_alloc_string(lv->alloc));
|
||||
|
||||
/* FIXME sprintf? */
|
||||
|
||||
lv_total++;
|
||||
|
||||
lv_capacity_total += lv->size;
|
||||
|
@ -22,8 +22,8 @@
|
||||
|
||||
/* FIXME Locking. PVs in VG. */
|
||||
|
||||
int pvchange_single(struct cmd_context *cmd, struct physical_volume *pv,
|
||||
void *handle)
|
||||
static int _pvchange_single(struct cmd_context *cmd, struct physical_volume *pv,
|
||||
void *handle)
|
||||
{
|
||||
struct volume_group *vg = NULL;
|
||||
struct pv_list *pvl;
|
||||
@ -131,7 +131,7 @@ int pvchange_single(struct cmd_context *cmd, struct physical_volume *pv,
|
||||
backup(vg);
|
||||
unlock_vg(cmd, pv->vg_name);
|
||||
} else {
|
||||
if (!(pv_write(cmd, pv, &mdas, sector))) {
|
||||
if (!(pv_write(cmd, pv, &mdas, (int64_t) sector))) {
|
||||
unlock_vg(cmd, ORPHAN);
|
||||
log_error("Failed to store physical volume \"%s\"",
|
||||
pv_name);
|
||||
@ -154,7 +154,7 @@ int pvchange(struct cmd_context *cmd, int argc, char **argv)
|
||||
struct physical_volume *pv;
|
||||
char *pv_name;
|
||||
|
||||
struct list *pvh, *pvs;
|
||||
struct list *pvh, *pvslist;
|
||||
struct list mdas;
|
||||
|
||||
list_init(&mdas);
|
||||
@ -186,20 +186,20 @@ int pvchange(struct cmd_context *cmd, int argc, char **argv)
|
||||
continue;
|
||||
}
|
||||
total++;
|
||||
done += pvchange_single(cmd, pv, NULL);
|
||||
done += _pvchange_single(cmd, pv, NULL);
|
||||
}
|
||||
} else {
|
||||
log_verbose("Scanning for physical volume names");
|
||||
if (!(pvs = get_pvs(cmd))) {
|
||||
if (!(pvslist = get_pvs(cmd))) {
|
||||
return ECMD_FAILED;
|
||||
}
|
||||
|
||||
list_iterate(pvh, pvs) {
|
||||
list_iterate(pvh, pvslist) {
|
||||
total++;
|
||||
done += pvchange_single(cmd,
|
||||
list_item(pvh,
|
||||
struct pv_list)->pv,
|
||||
NULL);
|
||||
done += _pvchange_single(cmd,
|
||||
list_item(pvh,
|
||||
struct pv_list)->pv,
|
||||
NULL);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -19,7 +19,6 @@
|
||||
*/
|
||||
|
||||
#include "tools.h"
|
||||
#include "defaults.h"
|
||||
|
||||
const char _really_init[] =
|
||||
"Really INITIALIZE physical volume \"%s\" of volume group \"%s\" [y/n]? ";
|
||||
@ -78,14 +77,14 @@ static void pvcreate_single(struct cmd_context *cmd, const char *pv_name,
|
||||
{
|
||||
struct physical_volume *pv, *existing_pv;
|
||||
struct id id, *idp = NULL;
|
||||
char *uuid;
|
||||
const char *uuid = NULL;
|
||||
uint64_t size = 0;
|
||||
struct device *dev;
|
||||
struct list mdas;
|
||||
int pvmetadatacopies;
|
||||
uint64_t pvmetadatasize;
|
||||
struct volume_group *vg;
|
||||
char *restorefile;
|
||||
const char *restorefile;
|
||||
uint64_t pe_start = 0;
|
||||
uint32_t extent_count = 0, extent_size = 0;
|
||||
|
||||
@ -130,9 +129,10 @@ static void pvcreate_single(struct cmd_context *cmd, const char *pv_name,
|
||||
if (!pvcreate_check(cmd, pv_name))
|
||||
goto error;
|
||||
|
||||
size = arg_uint64_value(cmd, physicalvolumesize_ARG, 0) * 2;
|
||||
size = arg_uint64_value(cmd, physicalvolumesize_ARG, __UINT64_C(0)) * 2;
|
||||
|
||||
pvmetadatasize = arg_uint64_value(cmd, metadatasize_ARG, 0) * 2;
|
||||
pvmetadatasize = arg_uint64_value(cmd, metadatasize_ARG, __UINT64_C(0))
|
||||
* 2;
|
||||
if (!pvmetadatasize)
|
||||
pvmetadatasize = find_config_int(cmd->cf->root,
|
||||
"metadata/pvmetadatasize",
|
||||
@ -169,8 +169,8 @@ static void pvcreate_single(struct cmd_context *cmd, const char *pv_name,
|
||||
|
||||
log_very_verbose("Writing physical volume data to disk \"%s\"",
|
||||
pv_name);
|
||||
if (!(pv_write(cmd, pv, &mdas, arg_int_value(cmd, labelsector_ARG,
|
||||
DEFAULT_LABELSECTOR)))) {
|
||||
if (!(pv_write(cmd, pv, &mdas, arg_int64_value(cmd, labelsector_ARG,
|
||||
DEFAULT_LABELSECTOR)))) {
|
||||
log_error("Failed to write physical volume \"%s\"", pv_name);
|
||||
goto error;
|
||||
}
|
||||
|
@ -20,8 +20,8 @@
|
||||
|
||||
#include "tools.h"
|
||||
|
||||
int pvdisplay_single(struct cmd_context *cmd, struct volume_group *vg,
|
||||
struct physical_volume *pv, void *handle)
|
||||
static int _pvdisplay_single(struct cmd_context *cmd, struct volume_group *vg,
|
||||
struct physical_volume *pv, void *handle)
|
||||
{
|
||||
uint64_t size;
|
||||
|
||||
@ -82,7 +82,7 @@ int pvdisplay(struct cmd_context *cmd, int argc, char **argv)
|
||||
return EINVALID_CMD_LINE;
|
||||
}
|
||||
|
||||
process_each_pv(cmd, argc, argv, NULL, NULL, pvdisplay_single);
|
||||
process_each_pv(cmd, argc, argv, NULL, NULL, _pvdisplay_single);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
@ -19,7 +19,6 @@
|
||||
*/
|
||||
|
||||
#include "tools.h"
|
||||
#include "defaults.h"
|
||||
|
||||
const char _really_wipe[] =
|
||||
"Really WIPE LABELS from physical volume \"%s\" of volume group \"%s\" [y/n]? ";
|
||||
|
@ -23,11 +23,11 @@
|
||||
int pv_max_name_len = 0;
|
||||
int vg_max_name_len = 0;
|
||||
|
||||
void pvscan_display_single(struct cmd_context *cmd, struct physical_volume *pv,
|
||||
void *handle)
|
||||
static void _pvscan_display_single(struct cmd_context *cmd,
|
||||
struct physical_volume *pv, void *handle)
|
||||
{
|
||||
char uuid[64];
|
||||
int vg_name_len = 0;
|
||||
unsigned int vg_name_len = 0;
|
||||
|
||||
char pv_tmp_name[NAME_LEN] = { 0, };
|
||||
char vg_tmp_name[NAME_LEN] = { 0, };
|
||||
@ -81,10 +81,10 @@ void pvscan_display_single(struct cmd_context *cmd, struct physical_volume *pv,
|
||||
"[%s / %s free]",
|
||||
pv_max_name_len, pv_tmp_name,
|
||||
vg_name_this,
|
||||
display_size(cmd, pv->pe_count *
|
||||
pv->pe_size / 2,
|
||||
SIZE_SHORT),
|
||||
display_size(cmd, (pv->pe_count - pv->pe_alloc_count)
|
||||
display_size(cmd, (uint64_t) pv->pe_count *
|
||||
pv->pe_size / 2, SIZE_SHORT),
|
||||
display_size(cmd, (uint64_t) (pv->pe_count -
|
||||
pv->pe_alloc_count)
|
||||
* pv->pe_size / 2, SIZE_SHORT));
|
||||
return;
|
||||
}
|
||||
@ -94,10 +94,12 @@ void pvscan_display_single(struct cmd_context *cmd, struct physical_volume *pv,
|
||||
("PV %-*s VG %-*s %s [%s / %s free]", pv_max_name_len,
|
||||
pv_tmp_name, vg_max_name_len, vg_tmp_name,
|
||||
pv->fmt ? pv->fmt->name : " ",
|
||||
display_size(cmd, pv->pe_count * pv->pe_size / 2, SIZE_SHORT),
|
||||
display_size(cmd,
|
||||
(pv->pe_count - pv->pe_alloc_count) * pv->pe_size / 2,
|
||||
SIZE_SHORT));
|
||||
display_size(cmd, (uint64_t) pv->pe_count * pv->pe_size / 2,
|
||||
SIZE_SHORT), display_size(cmd, (uint64_t)
|
||||
(pv->pe_count -
|
||||
pv->pe_alloc_count) *
|
||||
pv->pe_size / 2,
|
||||
SIZE_SHORT));
|
||||
return;
|
||||
}
|
||||
|
||||
@ -106,7 +108,7 @@ int pvscan(struct cmd_context *cmd, int argc, char **argv)
|
||||
int new_pvs_found = 0;
|
||||
int pvs_found = 0;
|
||||
|
||||
struct list *pvs;
|
||||
struct list *pvslist;
|
||||
struct list *pvh;
|
||||
struct pv_list *pvl;
|
||||
struct physical_volume *pv;
|
||||
@ -135,11 +137,11 @@ int pvscan(struct cmd_context *cmd, int argc, char **argv)
|
||||
cache_destroy();
|
||||
|
||||
log_verbose("Walking through all physical volumes");
|
||||
if (!(pvs = get_pvs(cmd)))
|
||||
if (!(pvslist = get_pvs(cmd)))
|
||||
return ECMD_FAILED;
|
||||
|
||||
/* eliminate exported/new if required */
|
||||
list_iterate(pvh, pvs) {
|
||||
list_iterate(pvh, pvslist) {
|
||||
pvl = list_item(pvh, struct pv_list);
|
||||
pv = pvl->pv;
|
||||
|
||||
@ -173,7 +175,7 @@ int pvscan(struct cmd_context *cmd, int argc, char **argv)
|
||||
|
||||
/* find maximum pv name length */
|
||||
pv_max_name_len = vg_max_name_len = 0;
|
||||
list_iterate(pvh, pvs) {
|
||||
list_iterate(pvh, pvslist) {
|
||||
pv = list_item(pvh, struct pv_list)->pv;
|
||||
len = strlen(dev_name(pv->dev));
|
||||
if (pv_max_name_len < len)
|
||||
@ -185,9 +187,9 @@ int pvscan(struct cmd_context *cmd, int argc, char **argv)
|
||||
pv_max_name_len += 2;
|
||||
vg_max_name_len += 2;
|
||||
|
||||
list_iterate(pvh, pvs)
|
||||
pvscan_display_single(cmd, list_item(pvh, struct pv_list)->pv,
|
||||
NULL);
|
||||
list_iterate(pvh, pvslist)
|
||||
_pvscan_display_single(cmd, list_item(pvh, struct pv_list)->pv,
|
||||
NULL);
|
||||
|
||||
if (!pvs_found) {
|
||||
log_print("No matching physical volumes found");
|
||||
|
@ -20,7 +20,6 @@
|
||||
|
||||
#include "tools.h"
|
||||
#include "report.h"
|
||||
#include "defaults.h"
|
||||
|
||||
static int _vgs_single(struct cmd_context *cmd, const char *vg_name,
|
||||
struct volume_group *vg, int consistent, void *handle)
|
||||
@ -83,8 +82,9 @@ static int _report(struct cmd_context *cmd, int argc, char **argv,
|
||||
report_type_t report_type)
|
||||
{
|
||||
void *report_handle;
|
||||
char *opts, *str;
|
||||
const char *keys, *options, *separator;
|
||||
const char *opts;
|
||||
char *str;
|
||||
const char *keys = NULL, *options = NULL, *separator;
|
||||
|
||||
int aligned, buffered, headings;
|
||||
|
||||
@ -156,12 +156,11 @@ static int _report(struct cmd_context *cmd, int argc, char **argv,
|
||||
return 0;
|
||||
}
|
||||
if (*opts == '+') {
|
||||
*opts = ',';
|
||||
str =
|
||||
pool_alloc(cmd->mem,
|
||||
strlen(options) + strlen(opts) + 1);
|
||||
str = pool_alloc(cmd->mem,
|
||||
strlen(options) + strlen(opts) + 1);
|
||||
strcpy(str, options);
|
||||
strcat(str, opts);
|
||||
strcat(str, ",");
|
||||
strcat(str, opts + 1);
|
||||
options = str;
|
||||
} else
|
||||
options = opts;
|
||||
|
@ -70,7 +70,7 @@ int process_each_lv(struct cmd_context *cmd, int argc, char **argv,
|
||||
struct logical_volume *lv;
|
||||
struct lv_list *lvl;
|
||||
|
||||
char *vgname;
|
||||
const char *vgname;
|
||||
|
||||
if (argc) {
|
||||
log_verbose("Using logical volume(s) on command line");
|
||||
@ -326,7 +326,7 @@ int process_each_pv(struct cmd_context *cmd, int argc, char **argv,
|
||||
|
||||
struct pv_list *pvl;
|
||||
struct physical_volume *pv;
|
||||
struct list *pvs, *pvh;
|
||||
struct list *pvslist, *pvh;
|
||||
|
||||
if (argc) {
|
||||
log_verbose("Using physical volume(s) on command line");
|
||||
@ -359,10 +359,10 @@ int process_each_pv(struct cmd_context *cmd, int argc, char **argv,
|
||||
process_each_pv_in_vg(cmd, vg, handle, process_single);
|
||||
} else {
|
||||
log_verbose("Scanning for physical volume names");
|
||||
if (!(pvs = get_pvs(cmd)))
|
||||
if (!(pvslist = get_pvs(cmd)))
|
||||
return ECMD_FAILED;
|
||||
|
||||
list_iterate(pvh, pvs) {
|
||||
list_iterate(pvh, pvslist) {
|
||||
pv = list_item(pvh, struct pv_list)->pv;
|
||||
ret = process_single(cmd, NULL, pv, handle);
|
||||
if (ret > ret_max)
|
||||
@ -374,9 +374,9 @@ int process_each_pv(struct cmd_context *cmd, int argc, char **argv,
|
||||
return ret_max;
|
||||
}
|
||||
|
||||
char *extract_vgname(struct cmd_context *cmd, char *lv_name)
|
||||
const char *extract_vgname(struct cmd_context *cmd, const char *lv_name)
|
||||
{
|
||||
char *vg_name = lv_name;
|
||||
const char *vg_name = lv_name;
|
||||
char *st;
|
||||
char *dev_dir = cmd->dev_dir;
|
||||
|
||||
|
@ -72,7 +72,7 @@ int process_each_lv_in_vg(struct cmd_context *cmd, struct volume_group *vg,
|
||||
void *handle));
|
||||
|
||||
char *default_vgname(struct cmd_context *cmd);
|
||||
char *extract_vgname(struct cmd_context *cmd, char *lv_name);
|
||||
const char *extract_vgname(struct cmd_context *cmd, const char *lv_name);
|
||||
|
||||
/*
|
||||
* Builds a list of pv's from the names in argv. Used in
|
||||
|
@ -9,10 +9,14 @@
|
||||
|
||||
#define _GNU_SOURCE
|
||||
|
||||
#include <assert.h>
|
||||
|
||||
#include "log.h"
|
||||
#include "activate.h"
|
||||
#include "archive.h"
|
||||
#include "cache.h"
|
||||
#include "config.h"
|
||||
#include "defaults.h"
|
||||
#include "dbg_malloc.h"
|
||||
#include "dev-cache.h"
|
||||
#include "device.h"
|
||||
@ -26,20 +30,17 @@
|
||||
#include "metadata.h"
|
||||
#include "list.h"
|
||||
#include "locking.h"
|
||||
#include "log.h"
|
||||
#include "lvm-file.h"
|
||||
#include "lvm-string.h"
|
||||
#include "pool.h"
|
||||
#include "toolcontext.h"
|
||||
#include "toollib.h"
|
||||
|
||||
#include <stdlib.h>
|
||||
#include <unistd.h>
|
||||
#include <ctype.h>
|
||||
#include <limits.h>
|
||||
#include <stdarg.h>
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <unistd.h>
|
||||
#include <sys/types.h>
|
||||
|
||||
#define CMD_LEN 256
|
||||
@ -67,13 +68,14 @@ typedef enum {
|
||||
|
||||
/* a global table of possible arguments */
|
||||
struct arg {
|
||||
char short_arg;
|
||||
char *long_arg;
|
||||
const char short_arg;
|
||||
const char *long_arg;
|
||||
int (*fn) (struct cmd_context * cmd, struct arg * a);
|
||||
|
||||
int count;
|
||||
char *value;
|
||||
uint32_t i_value;
|
||||
int32_t i_value;
|
||||
uint32_t ui_value;
|
||||
int64_t i64_value;
|
||||
uint64_t ui64_value;
|
||||
sign_t sign;
|
||||
@ -108,50 +110,59 @@ int units_arg(struct cmd_context *cmd, struct arg *a);
|
||||
char yes_no_prompt(const char *prompt, ...);
|
||||
|
||||
/* we use the enums to access the switches */
|
||||
static inline int arg_count(struct cmd_context *cmd, int a)
|
||||
static inline const int arg_count(struct cmd_context *cmd, int a)
|
||||
{
|
||||
return cmd->args[a].count;
|
||||
}
|
||||
|
||||
static inline char *arg_value(struct cmd_context *cmd, int a)
|
||||
static inline const char *arg_value(struct cmd_context *cmd, int a)
|
||||
{
|
||||
return cmd->args[a].value;
|
||||
}
|
||||
|
||||
static inline char *arg_str_value(struct cmd_context *cmd, int a, char *def)
|
||||
static inline const char *arg_str_value(struct cmd_context *cmd, int a,
|
||||
const char *def)
|
||||
{
|
||||
return arg_count(cmd, a) ? cmd->args[a].value : def;
|
||||
}
|
||||
|
||||
static inline uint32_t arg_int_value(struct cmd_context *cmd, int a,
|
||||
uint32_t def)
|
||||
static inline const int32_t arg_int_value(struct cmd_context *cmd, int a,
|
||||
const int32_t def)
|
||||
{
|
||||
return arg_count(cmd, a) ? cmd->args[a].i_value : def;
|
||||
}
|
||||
|
||||
static inline int64_t arg_int64_value(struct cmd_context *cmd, int a,
|
||||
uint64_t def)
|
||||
static inline const uint32_t arg_uint_value(struct cmd_context *cmd, int a,
|
||||
const uint32_t def)
|
||||
{
|
||||
return arg_count(cmd, a) ? cmd->args[a].ui_value : def;
|
||||
}
|
||||
|
||||
static inline const int64_t arg_int64_value(struct cmd_context *cmd, int a,
|
||||
const uint64_t def)
|
||||
{
|
||||
return arg_count(cmd, a) ? cmd->args[a].i64_value : def;
|
||||
}
|
||||
|
||||
static inline uint64_t arg_uint64_value(struct cmd_context *cmd, int a,
|
||||
uint64_t def)
|
||||
static inline const uint64_t arg_uint64_value(struct cmd_context *cmd, int a,
|
||||
const uint64_t def)
|
||||
{
|
||||
return arg_count(cmd, a) ? cmd->args[a].ui64_value : def;
|
||||
}
|
||||
|
||||
static inline void *arg_ptr_value(struct cmd_context *cmd, int a, void *def)
|
||||
static inline const void *arg_ptr_value(struct cmd_context *cmd, int a,
|
||||
const void *def)
|
||||
{
|
||||
return arg_count(cmd, a) ? cmd->args[a].ptr : def;
|
||||
}
|
||||
|
||||
static inline sign_t arg_sign_value(struct cmd_context *cmd, int a, sign_t def)
|
||||
static inline const sign_t arg_sign_value(struct cmd_context *cmd, int a,
|
||||
const sign_t def)
|
||||
{
|
||||
return arg_count(cmd, a) ? cmd->args[a].sign : def;
|
||||
}
|
||||
|
||||
static inline int arg_count_increment(struct cmd_context *cmd, int a)
|
||||
static inline const int arg_count_increment(struct cmd_context *cmd, int a)
|
||||
{
|
||||
return cmd->args[a].count++;
|
||||
}
|
||||
|
@ -43,7 +43,8 @@ static int _activate_lvs_in_vg(struct cmd_context *cmd,
|
||||
return count;
|
||||
}
|
||||
|
||||
void vgchange_available(struct cmd_context *cmd, struct volume_group *vg)
|
||||
static void _vgchange_available(struct cmd_context *cmd,
|
||||
struct volume_group *vg)
|
||||
{
|
||||
int lv_open, active;
|
||||
int available = !strcmp(arg_str_value(cmd, available_ARG, "n"), "y");
|
||||
@ -72,7 +73,8 @@ void vgchange_available(struct cmd_context *cmd, struct volume_group *vg)
|
||||
return;
|
||||
}
|
||||
|
||||
void vgchange_resizeable(struct cmd_context *cmd, struct volume_group *vg)
|
||||
static void _vgchange_resizeable(struct cmd_context *cmd,
|
||||
struct volume_group *vg)
|
||||
{
|
||||
int resizeable = !strcmp(arg_str_value(cmd, resizeable_ARG, "n"), "y");
|
||||
|
||||
@ -106,9 +108,10 @@ void vgchange_resizeable(struct cmd_context *cmd, struct volume_group *vg)
|
||||
return;
|
||||
}
|
||||
|
||||
void vgchange_logicalvolume(struct cmd_context *cmd, struct volume_group *vg)
|
||||
static void _vgchange_logicalvolume(struct cmd_context *cmd,
|
||||
struct volume_group *vg)
|
||||
{
|
||||
int max_lv = arg_int_value(cmd, logicalvolume_ARG, 0);
|
||||
uint32_t max_lv = arg_uint_value(cmd, logicalvolume_ARG, 0);
|
||||
|
||||
if (!(vg->status & RESIZEABLE_VG)) {
|
||||
log_error("Volume group \"%s\" must be resizeable "
|
||||
@ -165,13 +168,13 @@ static int vgchange_single(struct cmd_context *cmd, const char *vg_name,
|
||||
}
|
||||
|
||||
if (arg_count(cmd, available_ARG))
|
||||
vgchange_available(cmd, vg);
|
||||
_vgchange_available(cmd, vg);
|
||||
|
||||
if (arg_count(cmd, resizeable_ARG))
|
||||
vgchange_resizeable(cmd, vg);
|
||||
_vgchange_resizeable(cmd, vg);
|
||||
|
||||
if (arg_count(cmd, logicalvolume_ARG))
|
||||
vgchange_logicalvolume(cmd, vg);
|
||||
_vgchange_logicalvolume(cmd, vg);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
@ -19,7 +19,6 @@
|
||||
*/
|
||||
|
||||
#include "tools.h"
|
||||
#include "defaults.h"
|
||||
|
||||
static int vgconvert_single(struct cmd_context *cmd, const char *vg_name,
|
||||
struct volume_group *vg, int consistent,
|
||||
@ -63,7 +62,8 @@ static int vgconvert_single(struct cmd_context *cmd, const char *vg_name,
|
||||
}
|
||||
|
||||
if (cmd->fmt->features & FMT_MDAS) {
|
||||
pvmetadatasize = arg_uint64_value(cmd, metadatasize_ARG, 0) * 2;
|
||||
pvmetadatasize = arg_uint64_value(cmd, metadatasize_ARG,
|
||||
__UINT64_C(0)) * 2;
|
||||
if (!pvmetadatasize)
|
||||
pvmetadatasize =
|
||||
find_config_int(cmd->cf->root,
|
||||
@ -122,8 +122,8 @@ static int vgconvert_single(struct cmd_context *cmd, const char *vg_name,
|
||||
log_very_verbose("Writing physical volume data to disk \"%s\"",
|
||||
dev_name(pv->dev));
|
||||
if (!(pv_write(cmd, pv, &mdas,
|
||||
arg_int_value(cmd, labelsector_ARG,
|
||||
DEFAULT_LABELSECTOR)))) {
|
||||
arg_int64_value(cmd, labelsector_ARG,
|
||||
DEFAULT_LABELSECTOR)))) {
|
||||
log_error("Failed to write physical volume \"%s\"",
|
||||
dev_name(pv->dev));
|
||||
log_error("Use pvcreate and vgcfgrestore to repair "
|
||||
|
@ -28,7 +28,7 @@
|
||||
|
||||
int vgcreate(struct cmd_context *cmd, int argc, char **argv)
|
||||
{
|
||||
int max_lv, max_pv;
|
||||
size_t max_lv, max_pv;
|
||||
uint32_t extent_size;
|
||||
char *vg_name;
|
||||
char vg_path[PATH_MAX];
|
||||
@ -46,12 +46,12 @@ int vgcreate(struct cmd_context *cmd, int argc, char **argv)
|
||||
}
|
||||
|
||||
vg_name = argv[0];
|
||||
max_lv = arg_int_value(cmd, maxlogicalvolumes_ARG, DEFAULT_LV);
|
||||
max_pv = arg_int_value(cmd, maxphysicalvolumes_ARG, DEFAULT_PV);
|
||||
max_lv = arg_uint_value(cmd, maxlogicalvolumes_ARG, DEFAULT_LV);
|
||||
max_pv = arg_uint_value(cmd, maxphysicalvolumes_ARG, DEFAULT_PV);
|
||||
|
||||
/* Units of 512-byte sectors */
|
||||
extent_size =
|
||||
arg_int_value(cmd, physicalextentsize_ARG, DEFAULT_EXTENT) * 2;
|
||||
arg_uint_value(cmd, physicalextentsize_ARG, DEFAULT_EXTENT) * 2;
|
||||
|
||||
if (max_lv < 1) {
|
||||
log_error("maxlogicalvolumes too low");
|
||||
|
@ -20,8 +20,8 @@
|
||||
|
||||
#include "tools.h"
|
||||
|
||||
int vgmerge_single(struct cmd_context *cmd, const char *vg_name_to,
|
||||
const char *vg_name_from)
|
||||
static int _vgmerge_single(struct cmd_context *cmd, const char *vg_name_to,
|
||||
const char *vg_name_from)
|
||||
{
|
||||
struct volume_group *vg_to, *vg_from;
|
||||
struct list *lvh1, *lvh2;
|
||||
@ -202,7 +202,7 @@ int vgmerge(struct cmd_context *cmd, int argc, char **argv)
|
||||
argv++;
|
||||
|
||||
for (; opt < argc; opt++) {
|
||||
ret = vgmerge_single(cmd, vg_name_to, argv[opt]);
|
||||
ret = _vgmerge_single(cmd, vg_name_to, argv[opt]);
|
||||
if (ret > ret_max)
|
||||
ret_max = ret;
|
||||
}
|
||||
|
@ -48,7 +48,7 @@ static int vgreduce_single(struct cmd_context *cmd, struct volume_group *vg,
|
||||
if (pvl)
|
||||
list_del(&pvl->list);
|
||||
|
||||
*pv->vg_name = '\0';
|
||||
pv->vg_name = ORPHAN;
|
||||
vg->pv_count--;
|
||||
vg->free_count -= pv->pe_count - pv->pe_alloc_count;
|
||||
vg->extent_count -= pv->pe_count;
|
||||
@ -59,7 +59,7 @@ static int vgreduce_single(struct cmd_context *cmd, struct volume_group *vg,
|
||||
return ECMD_FAILED;
|
||||
}
|
||||
|
||||
if (!pv_write(cmd, pv, NULL, -1)) {
|
||||
if (!pv_write(cmd, pv, NULL, __INT64_C(-1))) {
|
||||
log_error("Failed to clear metadata from physical "
|
||||
"volume \"%s\" "
|
||||
"after removal from \"%s\"", name, vg->name);
|
||||
|
@ -63,9 +63,9 @@ static int vgremove_single(struct cmd_context *cmd, const char *vg_name,
|
||||
pv = list_item(pvh, struct pv_list)->pv;
|
||||
log_verbose("Removing physical volume \"%s\" from "
|
||||
"volume group \"%s\"", dev_name(pv->dev), vg_name);
|
||||
*pv->vg_name = '\0';
|
||||
pv->vg_name = ORPHAN;
|
||||
/* FIXME Write to same sector label was read from */
|
||||
if (!pv_write(cmd, pv, NULL, -1)) {
|
||||
if (!pv_write(cmd, pv, NULL, __INT64_C(-1))) {
|
||||
log_error("Failed to remove physical volume \"%s\""
|
||||
" from volume group \"%s\"",
|
||||
dev_name(pv->dev), vg_name);
|
||||
|
@ -23,7 +23,7 @@
|
||||
int vgrename(struct cmd_context *cmd, int argc, char **argv)
|
||||
{
|
||||
char *dev_dir;
|
||||
int length;
|
||||
unsigned int length;
|
||||
int consistent = 1;
|
||||
|
||||
char *vg_name_old, *vg_name_new;
|
||||
@ -31,7 +31,6 @@ int vgrename(struct cmd_context *cmd, int argc, char **argv)
|
||||
char old_path[NAME_LEN], new_path[NAME_LEN];
|
||||
|
||||
struct volume_group *vg_old, *vg_new;
|
||||
struct list *pvh;
|
||||
|
||||
if (argc != 2) {
|
||||
log_error("Old and new volume group names need specifying");
|
||||
@ -124,13 +123,7 @@ int vgrename(struct cmd_context *cmd, int argc, char **argv)
|
||||
goto error;
|
||||
|
||||
/* Change the volume group name */
|
||||
strcpy(vg_old->name, vg_name_new);
|
||||
|
||||
/* FIXME Should vg_write fix these implicitly? It has to check them. */
|
||||
list_iterate(pvh, &vg_old->pvs) {
|
||||
strcpy(list_item(pvh, struct pv_list)->pv->vg_name,
|
||||
vg_name_new);
|
||||
}
|
||||
vg_rename(cmd, vg_old, vg_name_new);
|
||||
|
||||
sprintf(old_path, "%s%s", dev_dir, vg_name_old);
|
||||
sprintf(new_path, "%s%s", dev_dir, vg_name_new);
|
||||
|
@ -68,7 +68,7 @@ static int _move_lvs(struct volume_group *vg_from, struct volume_group *vg_to)
|
||||
struct lv_segment *seg;
|
||||
struct physical_volume *pv;
|
||||
struct volume_group *vg_with;
|
||||
int s;
|
||||
unsigned int s;
|
||||
|
||||
list_iterate_safe(lvh, lvht, &vg_from->lvs) {
|
||||
lv = list_item(lvh, struct lv_list)->lv;
|
||||
|
Loading…
Reference in New Issue
Block a user