mirror of
git://sourceware.org/git/lvm2.git
synced 2024-12-21 13:34:40 +03:00
liblvm: remove lvmapi
This has been deprecated for a while.
This commit is contained in:
parent
e6bb780d24
commit
0d22b58172
21
Makefile.in
21
Makefile.in
@ -28,10 +28,6 @@ ifeq ("@INTL@", "yes")
|
||||
SUBDIRS += po
|
||||
endif
|
||||
|
||||
ifeq ("@APPLIB@", "yes")
|
||||
SUBDIRS += liblvm
|
||||
endif
|
||||
|
||||
ifeq ("@PYTHON_BINDINGS@", "yes")
|
||||
SUBDIRS += python
|
||||
endif
|
||||
@ -43,7 +39,7 @@ endif
|
||||
ifeq ($(MAKECMDGOALS),distclean)
|
||||
SUBDIRS = conf include man test scripts \
|
||||
libdaemon lib tools daemons libdm \
|
||||
udev po liblvm python
|
||||
udev po python
|
||||
tools.distclean: test.distclean
|
||||
endif
|
||||
DISTCLEAN_DIRS += lcov_reports*
|
||||
@ -54,18 +50,16 @@ include make.tmpl
|
||||
libdm: include
|
||||
libdaemon: include
|
||||
lib: libdm libdaemon
|
||||
liblvm: lib
|
||||
daemons: lib libdaemon tools
|
||||
tools: lib libdaemon device-mapper
|
||||
po: tools daemons
|
||||
man: tools
|
||||
all_man: tools
|
||||
scripts: liblvm libdm
|
||||
scripts: libdm
|
||||
test: tools daemons
|
||||
|
||||
lib.device-mapper: include.device-mapper
|
||||
libdm.device-mapper: include.device-mapper
|
||||
liblvm.device-mapper: include.device-mapper
|
||||
daemons.device-mapper: libdm.device-mapper
|
||||
tools.device-mapper: libdm.device-mapper
|
||||
scripts.device-mapper: include.device-mapper
|
||||
@ -79,10 +73,6 @@ po.pofile: tools.pofile daemons.pofile
|
||||
pofile: po.pofile
|
||||
endif
|
||||
|
||||
ifeq ("@PYTHON_BINDINGS@", "yes")
|
||||
python: liblvm
|
||||
endif
|
||||
|
||||
ifneq ("$(CFLOW_CMD)", "")
|
||||
tools.cflow: libdm.cflow lib.cflow
|
||||
daemons.cflow: tools.cflow
|
||||
@ -159,15 +149,10 @@ install_systemd_units:
|
||||
install_all_man:
|
||||
$(MAKE) -C man install_all_man
|
||||
|
||||
ifeq ("@PYTHON_BINDINGS@", "yes")
|
||||
install_python_bindings:
|
||||
$(MAKE) -C liblvm/python install_python_bindings
|
||||
endif
|
||||
|
||||
install_tmpfiles_configuration:
|
||||
$(MAKE) -C scripts install_tmpfiles_configuration
|
||||
|
||||
LCOV_TRACES = libdm.info lib.info liblvm.info tools.info \
|
||||
LCOV_TRACES = libdm.info lib.info tools.info \
|
||||
libdaemon/client.info libdaemon/server.info \
|
||||
test/unit.info \
|
||||
daemons/clvmd.info \
|
||||
|
91
aclocal.m4
vendored
91
aclocal.m4
vendored
@ -1,6 +1,6 @@
|
||||
# generated automatically by aclocal 1.15 -*- Autoconf -*-
|
||||
# generated automatically by aclocal 1.15.1 -*- Autoconf -*-
|
||||
|
||||
# Copyright (C) 1996-2014 Free Software Foundation, Inc.
|
||||
# Copyright (C) 1996-2017 Free Software Foundation, Inc.
|
||||
|
||||
# This file is free software; the Free Software Foundation
|
||||
# gives unlimited permission to copy and/or distribute it,
|
||||
@ -13,7 +13,7 @@
|
||||
|
||||
m4_ifndef([AC_CONFIG_MACRO_DIRS], [m4_defun([_AM_CONFIG_MACRO_DIRS], [])m4_defun([AC_CONFIG_MACRO_DIRS], [_AM_CONFIG_MACRO_DIRS($@)])])
|
||||
# ===========================================================================
|
||||
# http://www.gnu.org/software/autoconf-archive/ax_python_module.html
|
||||
# https://www.gnu.org/software/autoconf-archive/ax_python_module.html
|
||||
# ===========================================================================
|
||||
#
|
||||
# SYNOPSIS
|
||||
@ -37,7 +37,7 @@ m4_ifndef([AC_CONFIG_MACRO_DIRS], [m4_defun([_AM_CONFIG_MACRO_DIRS], [])m4_defun
|
||||
# and this notice are preserved. This file is offered as-is, without any
|
||||
# warranty.
|
||||
|
||||
#serial 8
|
||||
#serial 9
|
||||
|
||||
AU_ALIAS([AC_PYTHON_MODULE], [AX_PYTHON_MODULE])
|
||||
AC_DEFUN([AX_PYTHON_MODULE],[
|
||||
@ -69,9 +69,9 @@ AC_DEFUN([AX_PYTHON_MODULE],[
|
||||
fi
|
||||
])
|
||||
|
||||
dnl pkg.m4 - Macros to locate and utilise pkg-config. -*- Autoconf -*-
|
||||
dnl serial 11 (pkg-config-0.29)
|
||||
dnl
|
||||
# pkg.m4 - Macros to locate and utilise pkg-config. -*- Autoconf -*-
|
||||
# serial 11 (pkg-config-0.29.1)
|
||||
|
||||
dnl Copyright © 2004 Scott James Remnant <scott@netsplit.com>.
|
||||
dnl Copyright © 2012-2015 Dan Nicholson <dbn.lists@gmail.com>
|
||||
dnl
|
||||
@ -112,7 +112,7 @@ dnl
|
||||
dnl See the "Since" comment for each macro you use to see what version
|
||||
dnl of the macros you require.
|
||||
m4_defun([PKG_PREREQ],
|
||||
[m4_define([PKG_MACROS_VERSION], [0.29])
|
||||
[m4_define([PKG_MACROS_VERSION], [0.29.1])
|
||||
m4_if(m4_version_compare(PKG_MACROS_VERSION, [$1]), -1,
|
||||
[m4_fatal([pkg.m4 version $1 or higher is required but ]PKG_MACROS_VERSION[ found])])
|
||||
])dnl PKG_PREREQ
|
||||
@ -345,7 +345,75 @@ AS_VAR_COPY([$1], [pkg_cv_][$1])
|
||||
AS_VAR_IF([$1], [""], [$5], [$4])dnl
|
||||
])dnl PKG_CHECK_VAR
|
||||
|
||||
# Copyright (C) 1999-2014 Free Software Foundation, Inc.
|
||||
dnl PKG_WITH_MODULES(VARIABLE-PREFIX, MODULES,
|
||||
dnl [ACTION-IF-FOUND],[ACTION-IF-NOT-FOUND],
|
||||
dnl [DESCRIPTION], [DEFAULT])
|
||||
dnl ------------------------------------------
|
||||
dnl
|
||||
dnl Prepare a "--with-" configure option using the lowercase
|
||||
dnl [VARIABLE-PREFIX] name, merging the behaviour of AC_ARG_WITH and
|
||||
dnl PKG_CHECK_MODULES in a single macro.
|
||||
AC_DEFUN([PKG_WITH_MODULES],
|
||||
[
|
||||
m4_pushdef([with_arg], m4_tolower([$1]))
|
||||
|
||||
m4_pushdef([description],
|
||||
[m4_default([$5], [build with ]with_arg[ support])])
|
||||
|
||||
m4_pushdef([def_arg], [m4_default([$6], [auto])])
|
||||
m4_pushdef([def_action_if_found], [AS_TR_SH([with_]with_arg)=yes])
|
||||
m4_pushdef([def_action_if_not_found], [AS_TR_SH([with_]with_arg)=no])
|
||||
|
||||
m4_case(def_arg,
|
||||
[yes],[m4_pushdef([with_without], [--without-]with_arg)],
|
||||
[m4_pushdef([with_without],[--with-]with_arg)])
|
||||
|
||||
AC_ARG_WITH(with_arg,
|
||||
AS_HELP_STRING(with_without, description[ @<:@default=]def_arg[@:>@]),,
|
||||
[AS_TR_SH([with_]with_arg)=def_arg])
|
||||
|
||||
AS_CASE([$AS_TR_SH([with_]with_arg)],
|
||||
[yes],[PKG_CHECK_MODULES([$1],[$2],$3,$4)],
|
||||
[auto],[PKG_CHECK_MODULES([$1],[$2],
|
||||
[m4_n([def_action_if_found]) $3],
|
||||
[m4_n([def_action_if_not_found]) $4])])
|
||||
|
||||
m4_popdef([with_arg])
|
||||
m4_popdef([description])
|
||||
m4_popdef([def_arg])
|
||||
|
||||
])dnl PKG_WITH_MODULES
|
||||
|
||||
dnl PKG_HAVE_WITH_MODULES(VARIABLE-PREFIX, MODULES,
|
||||
dnl [DESCRIPTION], [DEFAULT])
|
||||
dnl -----------------------------------------------
|
||||
dnl
|
||||
dnl Convenience macro to trigger AM_CONDITIONAL after PKG_WITH_MODULES
|
||||
dnl check._[VARIABLE-PREFIX] is exported as make variable.
|
||||
AC_DEFUN([PKG_HAVE_WITH_MODULES],
|
||||
[
|
||||
PKG_WITH_MODULES([$1],[$2],,,[$3],[$4])
|
||||
|
||||
AM_CONDITIONAL([HAVE_][$1],
|
||||
[test "$AS_TR_SH([with_]m4_tolower([$1]))" = "yes"])
|
||||
])dnl PKG_HAVE_WITH_MODULES
|
||||
|
||||
dnl PKG_HAVE_DEFINE_WITH_MODULES(VARIABLE-PREFIX, MODULES,
|
||||
dnl [DESCRIPTION], [DEFAULT])
|
||||
dnl ------------------------------------------------------
|
||||
dnl
|
||||
dnl Convenience macro to run AM_CONDITIONAL and AC_DEFINE after
|
||||
dnl PKG_WITH_MODULES check. HAVE_[VARIABLE-PREFIX] is exported as make
|
||||
dnl and preprocessor variable.
|
||||
AC_DEFUN([PKG_HAVE_DEFINE_WITH_MODULES],
|
||||
[
|
||||
PKG_HAVE_WITH_MODULES([$1],[$2],[$3],[$4])
|
||||
|
||||
AS_IF([test "$AS_TR_SH([with_]m4_tolower([$1]))" = "yes"],
|
||||
[AC_DEFINE([HAVE_][$1], 1, [Enable ]m4_tolower([$1])[ support])])
|
||||
])dnl PKG_HAVE_DEFINE_WITH_MODULES
|
||||
|
||||
# Copyright (C) 1999-2017 Free Software Foundation, Inc.
|
||||
#
|
||||
# This file is free software; the Free Software Foundation
|
||||
# gives unlimited permission to copy and/or distribute it,
|
||||
@ -378,8 +446,9 @@ AC_DEFUN([AM_PATH_PYTHON],
|
||||
[
|
||||
dnl Find a Python interpreter. Python versions prior to 2.0 are not
|
||||
dnl supported. (2.0 was released on October 16, 2000).
|
||||
dnl FIXME: Remove the need to hard-code Python versions here.
|
||||
m4_define_default([_AM_PYTHON_INTERPRETER_LIST],
|
||||
[python python2 python3 python3.3 python3.2 python3.1 python3.0 python2.7 dnl
|
||||
[python python2 python3 python3.5 python3.4 python3.3 python3.2 python3.1 python3.0 python2.7 dnl
|
||||
python2.6 python2.5 python2.4 python2.3 python2.2 python2.1 python2.0])
|
||||
|
||||
AC_ARG_VAR([PYTHON], [the Python interpreter])
|
||||
@ -580,7 +649,7 @@ for i in list(range(0, 4)): minverhex = (minverhex << 8) + minver[[i]]
|
||||
sys.exit(sys.hexversion < minverhex)"
|
||||
AS_IF([AM_RUN_LOG([$1 -c "$prog"])], [$3], [$4])])
|
||||
|
||||
# Copyright (C) 2001-2014 Free Software Foundation, Inc.
|
||||
# Copyright (C) 2001-2017 Free Software Foundation, Inc.
|
||||
#
|
||||
# This file is free software; the Free Software Foundation
|
||||
# gives unlimited permission to copy and/or distribute it,
|
||||
|
63
configure.ac
63
configure.ac
@ -1108,20 +1108,6 @@ if test "$ODIRECT" = yes; then
|
||||
AC_DEFINE([O_DIRECT_SUPPORT], 1, [Define to 1 to enable O_DIRECT support.])
|
||||
fi
|
||||
|
||||
################################################################################
|
||||
dnl -- Enable liblvm2app.so
|
||||
AC_MSG_CHECKING(whether to build liblvm2app.so application library)
|
||||
AC_ARG_ENABLE(applib,
|
||||
AC_HELP_STRING([--enable-applib], [build application library]),
|
||||
APPLIB=$enableval, APPLIB=no)
|
||||
AC_MSG_RESULT($APPLIB)
|
||||
AC_SUBST([LVM2APP_LIB])
|
||||
test "$APPLIB" = yes \
|
||||
&& LVM2APP_LIB=-llvm2app \
|
||||
|| LVM2APP_LIB=
|
||||
AS_IF([test "$APPLIB"],
|
||||
[AC_MSG_WARN([liblvm2app is deprecated. Use D-Bus API])])
|
||||
|
||||
################################################################################
|
||||
dnl -- Enable cmdlib
|
||||
AC_MSG_CHECKING(whether to compile liblvm2cmd.so)
|
||||
@ -1145,44 +1131,9 @@ AS_IF([test "$NOTIFYDBUS_SUPPORT" = yes && test "BUILD_LVMDBUSD" = yes],
|
||||
[AC_MSG_WARN([Building D-Bus support without D-Bus notifications.])])
|
||||
|
||||
################################################################################
|
||||
dnl -- Enable Python liblvm2app bindings
|
||||
AC_MSG_CHECKING(whether to build Python wrapper for liblvm2app.so)
|
||||
AC_ARG_ENABLE(python_bindings,
|
||||
AC_HELP_STRING([--enable-python_bindings], [build default Python applib bindings]),
|
||||
PYTHON_BINDINGS=$enableval, PYTHON_BINDINGS=no)
|
||||
AC_MSG_RESULT($PYTHON_BINDINGS)
|
||||
dnl -- Enable Python dbus library
|
||||
|
||||
AC_MSG_CHECKING(whether to build Python2 wrapper for liblvm2app.so)
|
||||
AC_ARG_ENABLE(python2_bindings,
|
||||
AC_HELP_STRING([--enable-python2_bindings], [build Python2 applib bindings]),
|
||||
PYTHON2_BINDINGS=$enableval, PYTHON2_BINDINGS=no)
|
||||
AC_MSG_RESULT($PYTHON2_BINDINGS)
|
||||
|
||||
|
||||
AC_MSG_CHECKING(whether to build Python3 wrapper for liblvm2app.so)
|
||||
AC_ARG_ENABLE(python3_bindings,
|
||||
AC_HELP_STRING([--enable-python3_bindings], [build Python3 applib bindings]),
|
||||
PYTHON3_BINDINGS=$enableval, PYTHON3_BINDINGS=no)
|
||||
AC_MSG_RESULT($PYTHON3_BINDINGS)
|
||||
|
||||
if test "$PYTHON_BINDINGS" = yes; then
|
||||
AC_MSG_ERROR([--enable-python-bindings is replaced by --enable-python2-bindings and --enable-python3-bindings])
|
||||
fi
|
||||
|
||||
if test "$PYTHON2_BINDINGS" = yes; then
|
||||
AM_PATH_PYTHON([2])
|
||||
AC_PATH_TOOL(PYTHON2, python2)
|
||||
test -z "$PYTHON2" && AC_MSG_ERROR([python2 is required for --enable-python2_bindings but cannot be found])
|
||||
AC_PATH_TOOL(PYTHON2_CONFIG, python2-config)
|
||||
test -z "$PYTHON2_CONFIG" && AC_PATH_TOOL(PYTHON2_CONFIG, python-config)
|
||||
test -z "$PYTHON2_CONFIG" && AC_MSG_ERROR([python headers are required for --enable-python2_bindings but cannot be found])
|
||||
PYTHON2_INCDIRS=`"$PYTHON2_CONFIG" --includes`
|
||||
PYTHON2_LIBDIRS=`"$PYTHON2_CONFIG" --libs`
|
||||
PYTHON2DIR=$pythondir
|
||||
PYTHON_BINDINGS=yes
|
||||
fi
|
||||
|
||||
if test "$PYTHON3_BINDINGS" = yes -o "$BUILD_LVMDBUSD" = yes; then
|
||||
if test "$BUILD_LVMDBUSD" = yes; then
|
||||
unset PYTHON PYTHON_CONFIG
|
||||
unset am_cv_pathless_PYTHON ac_cv_path_PYTHON am_cv_python_platform
|
||||
unset am_cv_python_pythondir am_cv_python_version am_cv_python_pyexecdir
|
||||
@ -1196,19 +1147,12 @@ if test "$PYTHON3_BINDINGS" = yes -o "$BUILD_LVMDBUSD" = yes; then
|
||||
PYTHON3_LIBDIRS=`"$PYTHON3_CONFIG" --libs`
|
||||
PYTHON3DIR=$pythondir
|
||||
test "$PYTHON3_BINDINGS" = yes && PYTHON_BINDINGS=yes
|
||||
fi
|
||||
|
||||
if test "$BUILD_LVMDBUSD" = yes; then
|
||||
# To get this macro, install autoconf-archive package then run autoreconf
|
||||
AC_PYTHON_MODULE([pyudev], [Required], python3)
|
||||
AC_PYTHON_MODULE([dbus], [Required], python3)
|
||||
fi
|
||||
|
||||
if test "$PYTHON_BINDINGS" = yes -o "$PYTHON2_BINDINGS" = yes -o "$PYTHON3_BINDINGS" = yes; then
|
||||
AC_MSG_WARN([Python bindings are deprecated. Use D-Bus API])
|
||||
test "$APPLIB" != yes && AC_MSG_ERROR([Python_bindings require --enable-applib])
|
||||
fi
|
||||
|
||||
################################################################################
|
||||
dnl -- Enable pkg-config
|
||||
AC_ARG_ENABLE(pkgconfig,
|
||||
@ -1656,7 +1600,6 @@ LVM_LIBAPI=`echo "$VER" | $AWK -F '[[()]]' '{print $2}'`
|
||||
AC_DEFINE_UNQUOTED(LVM_CONFIGURE_LINE, "$CONFIGURE_LINE", [configure command line used])
|
||||
|
||||
################################################################################
|
||||
AC_SUBST(APPLIB)
|
||||
AC_SUBST(AWK)
|
||||
AC_SUBST(BLKID_PC)
|
||||
AC_SUBST(BUILD_CMIRRORD)
|
||||
@ -1843,8 +1786,6 @@ libdaemon/client/Makefile
|
||||
libdaemon/server/Makefile
|
||||
libdm/Makefile
|
||||
libdm/libdevmapper.pc
|
||||
liblvm/Makefile
|
||||
liblvm/liblvm2app.pc
|
||||
man/Makefile
|
||||
po/Makefile
|
||||
python/Makefile
|
||||
|
@ -28,9 +28,6 @@
|
||||
/* Path to cmirrord pidfile. */
|
||||
#undef CMIRRORD_PIDFILE
|
||||
|
||||
/* Define to 0 to exclude libSaCkpt. */
|
||||
#undef CMIRROR_HAS_CHECKPOINT
|
||||
|
||||
/* Define to one of `_getb67', `GETB67', `getb67' for Cray-2 and Cray-YMP
|
||||
systems. This function is required for `alloca.c' support on those systems.
|
||||
*/
|
||||
@ -185,9 +182,6 @@
|
||||
/* Define to 1 if you don't have `vprintf' but do have `_doprnt.' */
|
||||
#undef HAVE_DOPRNT
|
||||
|
||||
/* Define to 1 if you have the `dup2' function. */
|
||||
#undef HAVE_DUP2
|
||||
|
||||
/* Define to 1 if you have the <errno.h> header file. */
|
||||
#undef HAVE_ERRNO_H
|
||||
|
||||
@ -209,9 +203,6 @@
|
||||
/* Define to 1 if getline is available. */
|
||||
#undef HAVE_GETLINE
|
||||
|
||||
/* Define to 1 if you have the `getmntent' function. */
|
||||
#undef HAVE_GETMNTENT
|
||||
|
||||
/* Define to 1 if getopt_long is available. */
|
||||
#undef HAVE_GETOPTLONG
|
||||
|
||||
@ -236,9 +227,6 @@
|
||||
/* Define to 1 if dynamic libraries are available. */
|
||||
#undef HAVE_LIBDL
|
||||
|
||||
/* Define to 1 if you have the <libdlm.h> header file. */
|
||||
#undef HAVE_LIBDLM_H
|
||||
|
||||
/* Define to 1 if you have the <libgen.h> header file. */
|
||||
#undef HAVE_LIBGEN_H
|
||||
|
||||
@ -283,9 +271,6 @@
|
||||
/* Define to 1 if you have the `memchr' function. */
|
||||
#undef HAVE_MEMCHR
|
||||
|
||||
/* Define to 1 if you have the `memmove' function. */
|
||||
#undef HAVE_MEMMOVE
|
||||
|
||||
/* Define to 1 if you have the <memory.h> header file. */
|
||||
#undef HAVE_MEMORY_H
|
||||
|
||||
@ -301,30 +286,18 @@
|
||||
/* Define to 1 if you have a working `mmap' system call. */
|
||||
#undef HAVE_MMAP
|
||||
|
||||
/* Define to 1 if you have the <mntent.h> header file. */
|
||||
#undef HAVE_MNTENT_H
|
||||
|
||||
/* Define to 1 if you have the `munmap' function. */
|
||||
#undef HAVE_MUNMAP
|
||||
|
||||
/* Define to 1 if you have the <ndir.h> header file, and it defines `DIR'. */
|
||||
#undef HAVE_NDIR_H
|
||||
|
||||
/* Define to 1 if you have the <netdb.h> header file. */
|
||||
#undef HAVE_NETDB_H
|
||||
|
||||
/* Define to 1 if you have the <netinet/in.h> header file. */
|
||||
#undef HAVE_NETINET_IN_H
|
||||
|
||||
/* Define to 1 if you have the `nl_langinfo' function. */
|
||||
#undef HAVE_NL_LANGINFO
|
||||
|
||||
/* Define to 1 if you have the <paths.h> header file. */
|
||||
#undef HAVE_PATHS_H
|
||||
|
||||
/* Define to 1 if you have the <pthread.h> header file. */
|
||||
#undef HAVE_PTHREAD_H
|
||||
|
||||
/* Define to 1 if the system has the type `ptrdiff_t'. */
|
||||
#undef HAVE_PTRDIFF_T
|
||||
|
||||
@ -350,12 +323,6 @@
|
||||
/* Define to 1 if you have the `rmdir' function. */
|
||||
#undef HAVE_RMDIR
|
||||
|
||||
/* Define to 1 if you have the <search.h> header file. */
|
||||
#undef HAVE_SEARCH_H
|
||||
|
||||
/* Define to 1 if you have the `select' function. */
|
||||
#undef HAVE_SELECT
|
||||
|
||||
/* Define to 1 to include support for selinux. */
|
||||
#undef HAVE_SELINUX
|
||||
|
||||
@ -377,9 +344,6 @@
|
||||
/* Define to 1 if you have the <signal.h> header file. */
|
||||
#undef HAVE_SIGNAL_H
|
||||
|
||||
/* Define to 1 if you have the `socket' function. */
|
||||
#undef HAVE_SOCKET
|
||||
|
||||
/* Define to 1 if `stat' has the bug that it succeeds when given the
|
||||
zero-length file name argument. */
|
||||
#undef HAVE_STAT_EMPTY_STRING_BUG
|
||||
@ -491,9 +455,6 @@
|
||||
/* Define to 1 if you have the <sys/mman.h> header file. */
|
||||
#undef HAVE_SYS_MMAN_H
|
||||
|
||||
/* Define to 1 if you have the <sys/mount.h> header file. */
|
||||
#undef HAVE_SYS_MOUNT_H
|
||||
|
||||
/* Define to 1 if you have the <sys/ndir.h> header file, and it defines `DIR'.
|
||||
*/
|
||||
#undef HAVE_SYS_NDIR_H
|
||||
@ -504,15 +465,9 @@
|
||||
/* Define to 1 if you have the <sys/resource.h> header file. */
|
||||
#undef HAVE_SYS_RESOURCE_H
|
||||
|
||||
/* Define to 1 if you have the <sys/select.h> header file. */
|
||||
#undef HAVE_SYS_SELECT_H
|
||||
|
||||
/* Define to 1 if you have the <sys/sem.h> header file. */
|
||||
#undef HAVE_SYS_SEM_H
|
||||
|
||||
/* Define to 1 if you have the <sys/socket.h> header file. */
|
||||
#undef HAVE_SYS_SOCKET_H
|
||||
|
||||
/* Define to 1 if you have the <sys/statvfs.h> header file. */
|
||||
#undef HAVE_SYS_STATVFS_H
|
||||
|
||||
@ -528,12 +483,6 @@
|
||||
/* Define to 1 if you have the <sys/types.h> header file. */
|
||||
#undef HAVE_SYS_TYPES_H
|
||||
|
||||
/* Define to 1 if you have the <sys/uio.h> header file. */
|
||||
#undef HAVE_SYS_UIO_H
|
||||
|
||||
/* Define to 1 if you have the <sys/un.h> header file. */
|
||||
#undef HAVE_SYS_UN_H
|
||||
|
||||
/* Define to 1 if you have the <sys/utsname.h> header file. */
|
||||
#undef HAVE_SYS_UTSNAME_H
|
||||
|
||||
@ -555,9 +504,6 @@
|
||||
/* Define to 1 if you have the <unistd.h> header file. */
|
||||
#undef HAVE_UNISTD_H
|
||||
|
||||
/* Define to 1 if you have the <utmpx.h> header file. */
|
||||
#undef HAVE_UTMPX_H
|
||||
|
||||
/* valgrind.h found */
|
||||
#undef HAVE_VALGRIND
|
||||
|
||||
@ -598,6 +544,9 @@
|
||||
slash. */
|
||||
#undef LSTAT_FOLLOWS_SLASHED_SYMLINK
|
||||
|
||||
/* Path to lvmconfig binary. */
|
||||
#undef LVMCONFIG_PATH
|
||||
|
||||
/* Path to lvmetad pidfile. */
|
||||
#undef LVMETAD_PIDFILE
|
||||
|
||||
@ -669,15 +618,6 @@
|
||||
/* Define as the return type of signal handlers (`int' or `void'). */
|
||||
#undef RETSIGTYPE
|
||||
|
||||
/* Define to the type of arg 1 for `select'. */
|
||||
#undef SELECT_TYPE_ARG1
|
||||
|
||||
/* Define to the type of args 2, 3 and 4 for `select'. */
|
||||
#undef SELECT_TYPE_ARG234
|
||||
|
||||
/* Define to the type of arg 5 for `select'. */
|
||||
#undef SELECT_TYPE_ARG5
|
||||
|
||||
/* Define to 1 to include built-in support for snapshots. */
|
||||
#undef SNAPSHOT_INTERNAL
|
||||
|
||||
|
254
liblvm/Doxyfile
254
liblvm/Doxyfile
@ -1,254 +0,0 @@
|
||||
# Doxyfile 1.5.7.1
|
||||
|
||||
#---------------------------------------------------------------------------
|
||||
# Project related configuration options
|
||||
#---------------------------------------------------------------------------
|
||||
DOXYFILE_ENCODING = UTF-8
|
||||
PROJECT_NAME =
|
||||
PROJECT_NUMBER =
|
||||
OUTPUT_DIRECTORY = doxygen-output
|
||||
CREATE_SUBDIRS = NO
|
||||
OUTPUT_LANGUAGE = English
|
||||
BRIEF_MEMBER_DESC = YES
|
||||
REPEAT_BRIEF = YES
|
||||
ABBREVIATE_BRIEF =
|
||||
ALWAYS_DETAILED_SEC = NO
|
||||
INLINE_INHERITED_MEMB = NO
|
||||
FULL_PATH_NAMES = YES
|
||||
STRIP_FROM_PATH =
|
||||
STRIP_FROM_INC_PATH =
|
||||
SHORT_NAMES = NO
|
||||
JAVADOC_AUTOBRIEF = NO
|
||||
QT_AUTOBRIEF = NO
|
||||
MULTILINE_CPP_IS_BRIEF = NO
|
||||
INHERIT_DOCS = YES
|
||||
SEPARATE_MEMBER_PAGES = NO
|
||||
TAB_SIZE = 8
|
||||
ALIASES =
|
||||
OPTIMIZE_OUTPUT_FOR_C = NO
|
||||
OPTIMIZE_OUTPUT_JAVA = NO
|
||||
OPTIMIZE_FOR_FORTRAN = NO
|
||||
OPTIMIZE_OUTPUT_VHDL = NO
|
||||
BUILTIN_STL_SUPPORT = NO
|
||||
CPP_CLI_SUPPORT = NO
|
||||
SIP_SUPPORT = NO
|
||||
IDL_PROPERTY_SUPPORT = YES
|
||||
DISTRIBUTE_GROUP_DOC = NO
|
||||
SUBGROUPING = YES
|
||||
TYPEDEF_HIDES_STRUCT = NO
|
||||
SYMBOL_CACHE_SIZE = 0
|
||||
#---------------------------------------------------------------------------
|
||||
# Build related configuration options
|
||||
#---------------------------------------------------------------------------
|
||||
EXTRACT_ALL = YES
|
||||
EXTRACT_PRIVATE = YES
|
||||
EXTRACT_STATIC = NO
|
||||
EXTRACT_LOCAL_CLASSES = YES
|
||||
EXTRACT_LOCAL_METHODS = NO
|
||||
EXTRACT_ANON_NSPACES = NO
|
||||
HIDE_UNDOC_MEMBERS = NO
|
||||
HIDE_UNDOC_CLASSES = NO
|
||||
HIDE_FRIEND_COMPOUNDS = NO
|
||||
HIDE_IN_BODY_DOCS = NO
|
||||
INTERNAL_DOCS = NO
|
||||
CASE_SENSE_NAMES = YES
|
||||
HIDE_SCOPE_NAMES = NO
|
||||
SHOW_INCLUDE_FILES = YES
|
||||
INLINE_INFO = YES
|
||||
SORT_MEMBER_DOCS = YES
|
||||
SORT_BRIEF_DOCS = NO
|
||||
SORT_GROUP_NAMES = NO
|
||||
SORT_BY_SCOPE_NAME = NO
|
||||
GENERATE_TODOLIST = YES
|
||||
GENERATE_TESTLIST = YES
|
||||
GENERATE_BUGLIST = YES
|
||||
GENERATE_DEPRECATEDLIST= YES
|
||||
ENABLED_SECTIONS =
|
||||
MAX_INITIALIZER_LINES = 30
|
||||
SHOW_USED_FILES = YES
|
||||
SHOW_DIRECTORIES = NO
|
||||
SHOW_FILES = YES
|
||||
SHOW_NAMESPACES = YES
|
||||
FILE_VERSION_FILTER =
|
||||
LAYOUT_FILE =
|
||||
#---------------------------------------------------------------------------
|
||||
# configuration options related to warning and progress messages
|
||||
#---------------------------------------------------------------------------
|
||||
QUIET = NO
|
||||
WARNINGS = YES
|
||||
WARN_IF_UNDOCUMENTED = YES
|
||||
WARN_IF_DOC_ERROR = YES
|
||||
WARN_NO_PARAMDOC = NO
|
||||
WARN_FORMAT = "$file:$line: $text"
|
||||
WARN_LOGFILE =
|
||||
#---------------------------------------------------------------------------
|
||||
# configuration options related to the input files
|
||||
#---------------------------------------------------------------------------
|
||||
INPUT = ./
|
||||
INPUT_ENCODING = UTF-8
|
||||
FILE_PATTERNS = *.c \
|
||||
*.h
|
||||
RECURSIVE = NO
|
||||
EXCLUDE =
|
||||
EXCLUDE_SYMLINKS = NO
|
||||
EXCLUDE_PATTERNS =
|
||||
EXCLUDE_SYMBOLS =
|
||||
EXAMPLE_PATH = ../test/api
|
||||
EXAMPLE_PATTERNS =
|
||||
EXAMPLE_RECURSIVE = NO
|
||||
IMAGE_PATH =
|
||||
INPUT_FILTER =
|
||||
FILTER_PATTERNS =
|
||||
FILTER_SOURCE_FILES = NO
|
||||
#---------------------------------------------------------------------------
|
||||
# configuration options related to source browsing
|
||||
#---------------------------------------------------------------------------
|
||||
SOURCE_BROWSER = NO
|
||||
INLINE_SOURCES = NO
|
||||
STRIP_CODE_COMMENTS = YES
|
||||
REFERENCED_BY_RELATION = NO
|
||||
REFERENCES_RELATION = NO
|
||||
REFERENCES_LINK_SOURCE = YES
|
||||
USE_HTAGS = NO
|
||||
VERBATIM_HEADERS = YES
|
||||
#---------------------------------------------------------------------------
|
||||
# configuration options related to the alphabetical class index
|
||||
#---------------------------------------------------------------------------
|
||||
ALPHABETICAL_INDEX = NO
|
||||
COLS_IN_ALPHA_INDEX = 5
|
||||
IGNORE_PREFIX =
|
||||
#---------------------------------------------------------------------------
|
||||
# configuration options related to the HTML output
|
||||
#---------------------------------------------------------------------------
|
||||
GENERATE_HTML = YES
|
||||
HTML_OUTPUT = html
|
||||
HTML_FILE_EXTENSION = .html
|
||||
HTML_HEADER =
|
||||
HTML_FOOTER =
|
||||
HTML_STYLESHEET =
|
||||
HTML_ALIGN_MEMBERS = YES
|
||||
HTML_DYNAMIC_SECTIONS = NO
|
||||
GENERATE_DOCSET = NO
|
||||
DOCSET_FEEDNAME = "Doxygen generated docs"
|
||||
DOCSET_BUNDLE_ID = org.doxygen.Project
|
||||
GENERATE_HTMLHELP = NO
|
||||
CHM_FILE =
|
||||
HHC_LOCATION =
|
||||
GENERATE_CHI = NO
|
||||
CHM_INDEX_ENCODING =
|
||||
BINARY_TOC = NO
|
||||
TOC_EXPAND = NO
|
||||
GENERATE_QHP = NO
|
||||
QCH_FILE =
|
||||
QHP_NAMESPACE = org.doxygen.Project
|
||||
QHP_VIRTUAL_FOLDER = doc
|
||||
QHG_LOCATION =
|
||||
DISABLE_INDEX = NO
|
||||
ENUM_VALUES_PER_LINE = 4
|
||||
GENERATE_TREEVIEW = NONE
|
||||
TREEVIEW_WIDTH = 250
|
||||
FORMULA_FONTSIZE = 10
|
||||
#---------------------------------------------------------------------------
|
||||
# configuration options related to the LaTeX output
|
||||
#---------------------------------------------------------------------------
|
||||
GENERATE_LATEX = YES
|
||||
LATEX_OUTPUT = latex
|
||||
LATEX_CMD_NAME = latex
|
||||
MAKEINDEX_CMD_NAME = makeindex
|
||||
COMPACT_LATEX = NO
|
||||
PAPER_TYPE = a4wide
|
||||
EXTRA_PACKAGES =
|
||||
LATEX_HEADER =
|
||||
PDF_HYPERLINKS = YES
|
||||
USE_PDFLATEX = YES
|
||||
LATEX_BATCHMODE = NO
|
||||
LATEX_HIDE_INDICES = NO
|
||||
#---------------------------------------------------------------------------
|
||||
# configuration options related to the RTF output
|
||||
#---------------------------------------------------------------------------
|
||||
GENERATE_RTF = NO
|
||||
RTF_OUTPUT = rtf
|
||||
COMPACT_RTF = NO
|
||||
RTF_HYPERLINKS = NO
|
||||
RTF_STYLESHEET_FILE =
|
||||
RTF_EXTENSIONS_FILE =
|
||||
#---------------------------------------------------------------------------
|
||||
# configuration options related to the man page output
|
||||
#---------------------------------------------------------------------------
|
||||
GENERATE_MAN = YES
|
||||
MAN_OUTPUT = man
|
||||
MAN_EXTENSION = .3
|
||||
MAN_LINKS = NO
|
||||
#---------------------------------------------------------------------------
|
||||
# configuration options related to the XML output
|
||||
#---------------------------------------------------------------------------
|
||||
GENERATE_XML = NO
|
||||
XML_OUTPUT = xml
|
||||
XML_SCHEMA =
|
||||
XML_DTD =
|
||||
XML_PROGRAMLISTING = YES
|
||||
#---------------------------------------------------------------------------
|
||||
# configuration options for the AutoGen Definitions output
|
||||
#---------------------------------------------------------------------------
|
||||
GENERATE_AUTOGEN_DEF = NO
|
||||
#---------------------------------------------------------------------------
|
||||
# configuration options related to the Perl module output
|
||||
#---------------------------------------------------------------------------
|
||||
GENERATE_PERLMOD = NO
|
||||
PERLMOD_LATEX = NO
|
||||
PERLMOD_PRETTY = YES
|
||||
PERLMOD_MAKEVAR_PREFIX =
|
||||
#---------------------------------------------------------------------------
|
||||
# Configuration options related to the preprocessor
|
||||
#---------------------------------------------------------------------------
|
||||
ENABLE_PREPROCESSING = YES
|
||||
MACRO_EXPANSION = NO
|
||||
EXPAND_ONLY_PREDEF = NO
|
||||
SEARCH_INCLUDES = YES
|
||||
INCLUDE_PATH = ../libdm
|
||||
INCLUDE_FILE_PATTERNS =
|
||||
PREDEFINED =
|
||||
EXPAND_AS_DEFINED =
|
||||
SKIP_FUNCTION_MACROS = YES
|
||||
#---------------------------------------------------------------------------
|
||||
# Configuration::additions related to external references
|
||||
#---------------------------------------------------------------------------
|
||||
TAGFILES =
|
||||
GENERATE_TAGFILE =
|
||||
ALLEXTERNALS = NO
|
||||
EXTERNAL_GROUPS = YES
|
||||
PERL_PATH = /usr/bin/perl
|
||||
#---------------------------------------------------------------------------
|
||||
# Configuration options related to the dot tool
|
||||
#---------------------------------------------------------------------------
|
||||
CLASS_DIAGRAMS = YES
|
||||
MSCGEN_PATH =
|
||||
HIDE_UNDOC_RELATIONS = YES
|
||||
HAVE_DOT = NO
|
||||
DOT_FONTNAME = FreeSans
|
||||
DOT_FONTSIZE = 10
|
||||
DOT_FONTPATH =
|
||||
CLASS_GRAPH = YES
|
||||
COLLABORATION_GRAPH = YES
|
||||
GROUP_GRAPHS = YES
|
||||
UML_LOOK = NO
|
||||
TEMPLATE_RELATIONS = NO
|
||||
INCLUDE_GRAPH = YES
|
||||
INCLUDED_BY_GRAPH = YES
|
||||
CALL_GRAPH = YES
|
||||
CALLER_GRAPH = NO
|
||||
GRAPHICAL_HIERARCHY = YES
|
||||
DIRECTORY_GRAPH = YES
|
||||
DOT_IMAGE_FORMAT = png
|
||||
DOT_PATH =
|
||||
DOTFILE_DIRS =
|
||||
DOT_GRAPH_MAX_NODES = 50
|
||||
MAX_DOT_GRAPH_DEPTH = 0
|
||||
DOT_TRANSPARENT = NO
|
||||
DOT_MULTI_TARGETS = NO
|
||||
GENERATE_LEGEND = YES
|
||||
DOT_CLEANUP = YES
|
||||
#---------------------------------------------------------------------------
|
||||
# Configuration::additions related to the search engine
|
||||
#---------------------------------------------------------------------------
|
||||
SEARCHENGINE = NO
|
@ -1,81 +0,0 @@
|
||||
#
|
||||
# Copyright (C) 2001-2004 Sistina Software, Inc. All rights reserved.
|
||||
# Copyright (C) 2004-2013 Red Hat, Inc. All rights reserved.
|
||||
#
|
||||
# This file is part of LVM2.
|
||||
#
|
||||
# This copyrighted material is made available to anyone wishing to use,
|
||||
# modify, copy, or redistribute it subject to the terms and conditions
|
||||
# of the GNU General Public License v.2.
|
||||
#
|
||||
# You should have received a copy of the GNU General Public License
|
||||
# along with this program; if not, write to the Free Software Foundation,
|
||||
# Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
|
||||
srcdir = @srcdir@
|
||||
top_srcdir = @top_srcdir@
|
||||
top_builddir = @top_builddir@
|
||||
|
||||
SOURCES =\
|
||||
lvm_misc.c \
|
||||
lvm_prop.c \
|
||||
lvm_base.c \
|
||||
lvm_lv.c \
|
||||
lvm_pv.c \
|
||||
lvm_vg.c
|
||||
|
||||
LIB_NAME = liblvm2app
|
||||
LIB_VERSION = $(LIB_VERSION_APP)
|
||||
|
||||
ifeq ("@STATIC_LINK@", "yes")
|
||||
LIB_STATIC = $(LIB_NAME).a
|
||||
endif
|
||||
|
||||
LIB_SHARED = $(LIB_NAME).$(LIB_SUFFIX)
|
||||
|
||||
CLEAN_TARGETS += liblvm.cflow $(LIB_NAME).a
|
||||
|
||||
EXPORTED_HEADER = $(srcdir)/lvm2app.h
|
||||
EXPORTED_FN_PREFIX = lvm
|
||||
|
||||
LDDEPS += $(top_builddir)/lib/liblvm-internal.a
|
||||
|
||||
include $(top_builddir)/make.tmpl
|
||||
|
||||
LDFLAGS += -L$(top_builddir)/lib -L$(top_builddir)/daemons/dmeventd
|
||||
LIBS += $(LVMINTERNAL_LIBS) -laio
|
||||
|
||||
.PHONY: install_dynamic install_static install_include install_pkgconfig
|
||||
|
||||
INSTALL_TYPE = install_dynamic
|
||||
|
||||
ifeq ("@STATIC_LINK@", "yes")
|
||||
INSTALL_TYPE += install_static
|
||||
endif
|
||||
|
||||
ifeq ("@PKGCONFIG@", "yes")
|
||||
INSTALL_TYPE += install_pkgconfig
|
||||
endif
|
||||
|
||||
install: $(INSTALL_TYPE) install_include
|
||||
|
||||
install_include: $(srcdir)/lvm2app.h
|
||||
$(INSTALL_DATA) -D $< $(includedir)/$(<F)
|
||||
|
||||
install_dynamic: install_lib_shared
|
||||
|
||||
install_static: $(LIB_STATIC)
|
||||
$(INSTALL_DATA) -D $< $(usrlibdir)/$(<F)
|
||||
|
||||
install_pkgconfig: $(LIB_NAME).pc
|
||||
$(INSTALL_DATA) -D $< $(pkgconfigdir)/lvm2app.pc
|
||||
|
||||
liblvm.cflow: $(SOURCES)
|
||||
set -e; (echo -n "SOURCES += "; \
|
||||
echo $(SOURCES) | \
|
||||
sed "s/^/ /;s/ / $(top_srcdir)\/liblvm\//g;s/$$//"; \
|
||||
) > $@
|
||||
|
||||
cflow: liblvm.cflow
|
||||
|
||||
DISTCLEAN_TARGETS += $(LIB_NAME).pc
|
@ -1,11 +0,0 @@
|
||||
prefix=@prefix@
|
||||
exec_prefix=@exec_prefix@
|
||||
libdir=@libdir@
|
||||
includedir=@includedir@
|
||||
|
||||
Name: lvm2app
|
||||
Description: lvm2 application library
|
||||
Version: @LVM_MAJOR@.@LVM_LIBAPI@
|
||||
Cflags: -I${includedir}
|
||||
Libs: -L${libdir} -llvm2app
|
||||
Requires.private: devmapper @BLKID_PC@
|
1983
liblvm/lvm2app.h
1983
liblvm/lvm2app.h
File diff suppressed because it is too large
Load Diff
@ -1,216 +0,0 @@
|
||||
/*
|
||||
* Copyright (C) 2008,2009 Red Hat, Inc. All rights reserved.
|
||||
*
|
||||
* This file is part of LVM2.
|
||||
*
|
||||
* This copyrighted material is made available to anyone wishing to use,
|
||||
* modify, copy, or redistribute it subject to the terms and conditions
|
||||
* of the GNU Lesser General Public License v.2.1.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public License
|
||||
* along with this program; if not, write to the Free Software Foundation,
|
||||
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
*/
|
||||
|
||||
#include "lib/misc/lib.h"
|
||||
#include "lib/commands/toolcontext.h"
|
||||
#include "lib/locking/locking.h"
|
||||
#include "lvm-version.h"
|
||||
#include "lib/metadata/metadata-exported.h"
|
||||
#include "liblvm/lvm2app.h"
|
||||
#include "lvm_misc.h"
|
||||
|
||||
const char *lvm_library_get_version(void)
|
||||
{
|
||||
return LVM_VERSION;
|
||||
}
|
||||
|
||||
static lvm_t _lvm_init(const char *system_dir)
|
||||
{
|
||||
struct cmd_context *cmd;
|
||||
|
||||
/* FIXME: logging bound to handle
|
||||
*/
|
||||
|
||||
if (!udev_init_library_context())
|
||||
stack;
|
||||
|
||||
/*
|
||||
* It's not necessary to use name mangling for LVM:
|
||||
* - the character set used for VG-LV names is subset of udev character set
|
||||
* - when we check other devices (e.g. device_is_usable fn), we use major:minor, not dm names
|
||||
*/
|
||||
dm_set_name_mangling_mode(DM_STRING_MANGLING_NONE);
|
||||
|
||||
/* create context */
|
||||
/* FIXME: split create_toolcontext */
|
||||
/* FIXME: make all globals configurable */
|
||||
cmd = create_toolcontext(0, system_dir, 0, 0, 1, 1);
|
||||
if (!cmd)
|
||||
return NULL;
|
||||
|
||||
/*
|
||||
* FIXME: if an non memory error occured, return the cmd (maybe some
|
||||
* cleanup needed).
|
||||
*/
|
||||
|
||||
/* initialization from lvm_run_command */
|
||||
init_error_message_produced(0);
|
||||
|
||||
/* FIXME: locking_type config option needed? */
|
||||
/* initialize locking */
|
||||
if (!init_locking(-1, cmd, 0)) {
|
||||
/* FIXME: use EAGAIN as error code here */
|
||||
lvm_quit((lvm_t) cmd);
|
||||
return NULL;
|
||||
}
|
||||
/*
|
||||
* FIXME: Use cmd->cmd_line as audit trail for liblvm calls. Used in
|
||||
* archive() call. Possible example:
|
||||
* cmd_line = "lvm_vg_create: vg1\nlvm_vg_extend vg1 /dev/sda1\n"
|
||||
*/
|
||||
cmd->cmd_line = "liblvm";
|
||||
|
||||
/*
|
||||
* Turn off writing to stdout/stderr.
|
||||
* FIXME Fix lib/ to support a non-interactive mode instead.
|
||||
*/
|
||||
log_suppress(1);
|
||||
|
||||
return (lvm_t) cmd;
|
||||
}
|
||||
|
||||
|
||||
lvm_t lvm_init(const char *system_dir)
|
||||
{
|
||||
lvm_t h = NULL;
|
||||
struct saved_env e = store_user_env(NULL);
|
||||
h = _lvm_init(system_dir);
|
||||
restore_user_env(&e);
|
||||
return h;
|
||||
}
|
||||
|
||||
void lvm_quit(lvm_t libh)
|
||||
{
|
||||
struct saved_env e = store_user_env((struct cmd_context *)libh);
|
||||
fin_locking();
|
||||
destroy_toolcontext((struct cmd_context *)libh);
|
||||
udev_fin_library_context();
|
||||
restore_user_env(&e);
|
||||
}
|
||||
|
||||
int lvm_config_reload(lvm_t libh)
|
||||
{
|
||||
int rc = 0;
|
||||
|
||||
/* FIXME: re-init locking needed here? */
|
||||
struct saved_env e = store_user_env((struct cmd_context *)libh);
|
||||
if (!refresh_toolcontext((struct cmd_context *)libh))
|
||||
rc = -1;
|
||||
restore_user_env(&e);
|
||||
return rc;
|
||||
}
|
||||
|
||||
/*
|
||||
* FIXME: submit a patch to document the --config option
|
||||
*/
|
||||
int lvm_config_override(lvm_t libh, const char *config_settings)
|
||||
{
|
||||
int rc = 0;
|
||||
struct cmd_context *cmd = (struct cmd_context *)libh;
|
||||
struct saved_env e = store_user_env((struct cmd_context *)libh);
|
||||
|
||||
if (!override_config_tree_from_string(cmd, config_settings))
|
||||
rc = -1;
|
||||
restore_user_env(&e);
|
||||
return rc;
|
||||
}
|
||||
|
||||
/*
|
||||
* When full lvm connection is not being used, libh can be NULL
|
||||
* and this command will internally create a single-use, light-weight
|
||||
* cmd struct that only has cmd->cft populated from lvm.conf.
|
||||
*/
|
||||
int lvm_config_find_bool(lvm_t libh, const char *config_path, int fail)
|
||||
{
|
||||
int rc = 0;
|
||||
struct cmd_context *cmd;
|
||||
struct saved_env e;
|
||||
|
||||
if (libh) {
|
||||
cmd = (struct cmd_context *)libh;
|
||||
e = store_user_env((struct cmd_context *)libh);
|
||||
} else {
|
||||
if (!(cmd = create_config_context()))
|
||||
return 0;
|
||||
}
|
||||
|
||||
rc = dm_config_tree_find_bool(cmd->cft, config_path, fail);
|
||||
|
||||
if (libh)
|
||||
restore_user_env(&e);
|
||||
else
|
||||
destroy_config_context(cmd);
|
||||
return rc;
|
||||
}
|
||||
|
||||
int lvm_errno(lvm_t libh)
|
||||
{
|
||||
int rc;
|
||||
struct saved_env e = store_user_env((struct cmd_context *)libh);
|
||||
rc = stored_errno();
|
||||
restore_user_env(&e);
|
||||
return rc;
|
||||
}
|
||||
|
||||
const char *lvm_errmsg(lvm_t libh)
|
||||
{
|
||||
const char *rc = NULL;
|
||||
struct cmd_context *cmd = (struct cmd_context *)libh;
|
||||
struct saved_env e = store_user_env((struct cmd_context *)libh);
|
||||
|
||||
const char *msg = stored_errmsg_with_clear();
|
||||
if (msg) {
|
||||
rc = dm_pool_strdup(cmd->mem, msg);
|
||||
free((void *)msg);
|
||||
}
|
||||
|
||||
restore_user_env(&e);
|
||||
return rc;
|
||||
}
|
||||
|
||||
const char *lvm_vgname_from_pvid(lvm_t libh, const char *pvid)
|
||||
{
|
||||
const char *rc = NULL;
|
||||
struct cmd_context *cmd = (struct cmd_context *)libh;
|
||||
struct id id;
|
||||
struct saved_env e = store_user_env((struct cmd_context *)libh);
|
||||
|
||||
if (id_read_format(&id, pvid)) {
|
||||
rc = find_vgname_from_pvid(cmd, (char *)id.uuid);
|
||||
} else {
|
||||
log_error(INTERNAL_ERROR "Unable to convert uuid");
|
||||
}
|
||||
|
||||
restore_user_env(&e);
|
||||
return rc;
|
||||
}
|
||||
|
||||
const char *lvm_vgname_from_device(lvm_t libh, const char *device)
|
||||
{
|
||||
const char *rc = NULL;
|
||||
struct cmd_context *cmd = (struct cmd_context *)libh;
|
||||
struct saved_env e = store_user_env(cmd);
|
||||
rc = find_vgname_from_pvname(cmd, device);
|
||||
restore_user_env(&e);
|
||||
return rc;
|
||||
}
|
||||
|
||||
/*
|
||||
* No context to work with, so no ability to save off and restore env is not
|
||||
* available and is not needed.
|
||||
*/
|
||||
float lvm_percent_to_float(percent_t v)
|
||||
{
|
||||
return dm_percent_to_float(v);
|
||||
}
|
820
liblvm/lvm_lv.c
820
liblvm/lvm_lv.c
@ -1,820 +0,0 @@
|
||||
/*
|
||||
* Copyright (C) 2008-2013 Red Hat, Inc. All rights reserved.
|
||||
*
|
||||
* This file is part of LVM2.
|
||||
*
|
||||
* This copyrighted material is made available to anyone wishing to use,
|
||||
* modify, copy, or redistribute it subject to the terms and conditions
|
||||
* of the GNU Lesser General Public License v.2.1.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public License
|
||||
* along with this program; if not, write to the Free Software Foundation,
|
||||
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
*/
|
||||
|
||||
#include "lib/misc/lib.h"
|
||||
#include "lib/metadata/metadata-exported.h"
|
||||
#include "lib/misc/lvm-string.h"
|
||||
#include "lib/config/defaults.h"
|
||||
#include "lib/metadata/segtype.h"
|
||||
#include "lib/locking/locking.h"
|
||||
#include "lib/activate/activate.h"
|
||||
#include "lvm_misc.h"
|
||||
#include "liblvm/lvm2app.h"
|
||||
|
||||
/* FIXME Improve all the log messages to include context. Which VG/LV as a minimum? */
|
||||
|
||||
struct lvm_lv_create_params
|
||||
{
|
||||
uint32_t magic;
|
||||
vg_t vg;
|
||||
struct lvcreate_params lvp;
|
||||
};
|
||||
|
||||
#define LV_CREATE_PARAMS_MAGIC 0xFEED0001
|
||||
|
||||
static int _lv_check_handle(const lv_t lv, const int vg_writeable)
|
||||
{
|
||||
if (!lv || !lv->vg || vg_read_error(lv->vg))
|
||||
return -1;
|
||||
if (vg_writeable && !vg_check_write_mode(lv->vg))
|
||||
return -1;
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* FIXME: have lib/report/report.c _disp function call lv_size()? */
|
||||
uint64_t lvm_lv_get_size(const lv_t lv)
|
||||
{
|
||||
uint64_t rc;
|
||||
struct saved_env e = store_user_env(lv->vg->cmd);
|
||||
rc = SECTOR_SIZE * lv_size(lv);
|
||||
restore_user_env(&e);
|
||||
return rc;
|
||||
}
|
||||
|
||||
const char *lvm_lv_get_uuid(const lv_t lv)
|
||||
{
|
||||
const char *rc;
|
||||
struct saved_env e = store_user_env(lv->vg->cmd);
|
||||
rc = lv_uuid_dup(lv->vg->vgmem, lv);
|
||||
restore_user_env(&e);
|
||||
return rc;
|
||||
}
|
||||
|
||||
const char *lvm_lv_get_name(const lv_t lv)
|
||||
{
|
||||
const char *rc;
|
||||
struct saved_env e = store_user_env(lv->vg->cmd);
|
||||
rc = dm_pool_strndup(lv->vg->vgmem, lv->name, NAME_LEN+1);
|
||||
restore_user_env(&e);
|
||||
return rc;
|
||||
}
|
||||
|
||||
const char *lvm_lv_get_attr(const lv_t lv)
|
||||
{
|
||||
const char *rc;
|
||||
struct saved_env e = store_user_env(lv->vg->cmd);
|
||||
rc = lv_attr_dup(lv->vg->vgmem, lv);
|
||||
restore_user_env(&e);
|
||||
return rc;
|
||||
}
|
||||
|
||||
const char *lvm_lv_get_origin(const lv_t lv)
|
||||
{
|
||||
const char *rc;
|
||||
struct saved_env e = store_user_env(lv->vg->cmd);
|
||||
rc = lv_origin_dup(lv->vg->vgmem, lv);
|
||||
restore_user_env(&e);
|
||||
return rc;
|
||||
}
|
||||
|
||||
struct lvm_property_value lvm_lv_get_property(const lv_t lv, const char *name)
|
||||
{
|
||||
struct lvm_property_value rc;
|
||||
struct saved_env e = store_user_env(lv->vg->cmd);
|
||||
rc = get_property(NULL, NULL, lv, NULL, NULL, NULL, NULL, name);
|
||||
restore_user_env(&e);
|
||||
return rc;
|
||||
}
|
||||
|
||||
struct lvm_property_value lvm_lvseg_get_property(const lvseg_t lvseg,
|
||||
const char *name)
|
||||
{
|
||||
struct lvm_property_value rc;
|
||||
struct saved_env e = store_user_env(lvseg->lv->vg->cmd);
|
||||
rc = get_property(NULL, NULL, NULL, lvseg, NULL, NULL, NULL, name);
|
||||
restore_user_env(&e);
|
||||
return rc;
|
||||
}
|
||||
|
||||
uint64_t lvm_lv_is_active(const lv_t lv)
|
||||
{
|
||||
uint64_t rc = 0;
|
||||
struct lvinfo info;
|
||||
|
||||
struct saved_env e = store_user_env(lv->vg->cmd);
|
||||
|
||||
if (lv_info(lv->vg->cmd, lv, 0, &info, 0, 0) &&
|
||||
info.exists && info.live_table)
|
||||
rc = 1;
|
||||
|
||||
restore_user_env(&e);
|
||||
return rc;
|
||||
}
|
||||
|
||||
uint64_t lvm_lv_is_suspended(const lv_t lv)
|
||||
{
|
||||
uint64_t rc = 0;
|
||||
struct lvinfo info;
|
||||
struct saved_env e = store_user_env(lv->vg->cmd);
|
||||
|
||||
if (lv_info(lv->vg->cmd, lv, 0, &info, 0, 0) &&
|
||||
info.exists && info.suspended)
|
||||
rc = 1;
|
||||
|
||||
restore_user_env(&e);
|
||||
return rc;
|
||||
}
|
||||
|
||||
static int _lvm_lv_add_tag(lv_t lv, const char *tag)
|
||||
{
|
||||
if (_lv_check_handle(lv, 1))
|
||||
return -1;
|
||||
if (!lv_change_tag(lv, tag, 1))
|
||||
return -1;
|
||||
return 0;
|
||||
}
|
||||
|
||||
int lvm_lv_add_tag(lv_t lv, const char *tag)
|
||||
{
|
||||
int rc;
|
||||
struct saved_env e = store_user_env(lv->vg->cmd);
|
||||
rc = _lvm_lv_add_tag(lv, tag);
|
||||
restore_user_env(&e);
|
||||
return rc;
|
||||
}
|
||||
|
||||
|
||||
static int _lvm_lv_remove_tag(lv_t lv, const char *tag)
|
||||
{
|
||||
if (_lv_check_handle(lv, 1))
|
||||
return -1;
|
||||
if (!lv_change_tag(lv, tag, 0))
|
||||
return -1;
|
||||
return 0;
|
||||
}
|
||||
|
||||
int lvm_lv_remove_tag(lv_t lv, const char *tag)
|
||||
{
|
||||
int rc;
|
||||
struct saved_env e = store_user_env(lv->vg->cmd);
|
||||
rc = _lvm_lv_remove_tag(lv, tag);
|
||||
restore_user_env(&e);
|
||||
return rc;
|
||||
}
|
||||
|
||||
|
||||
struct dm_list *lvm_lv_get_tags(const lv_t lv)
|
||||
{
|
||||
struct dm_list *rc;
|
||||
struct saved_env e = store_user_env(lv->vg->cmd);
|
||||
rc = tag_list_copy(lv->vg->vgmem, &lv->tags);
|
||||
restore_user_env(&e);
|
||||
return rc;
|
||||
}
|
||||
|
||||
/* Set defaults for non-segment specific LV parameters */
|
||||
static void _lv_set_default_params(struct lvcreate_params *lp,
|
||||
vg_t vg, const char *lvname,
|
||||
uint64_t extents)
|
||||
{
|
||||
lp->zero = 1;
|
||||
lp->wipe_signatures = 0;
|
||||
lp->major = -1;
|
||||
lp->minor = -1;
|
||||
lp->activate = CHANGE_AY;
|
||||
lp->lv_name = lvname; /* FIXME: check this for safety */
|
||||
lp->pvh = &vg->pvs;
|
||||
|
||||
lp->extents = extents;
|
||||
lp->permission = LVM_READ | LVM_WRITE;
|
||||
lp->read_ahead = DM_READ_AHEAD_NONE;
|
||||
lp->alloc = ALLOC_INHERIT;
|
||||
dm_list_init(&lp->tags);
|
||||
}
|
||||
|
||||
static struct segment_type * _get_segtype(struct cmd_context *cmd) {
|
||||
struct segment_type *rc = get_segtype_from_string(cmd, SEG_TYPE_NAME_STRIPED);
|
||||
if (!rc) {
|
||||
log_error(INTERNAL_ERROR "Segtype striped not found.");
|
||||
}
|
||||
return rc;
|
||||
}
|
||||
|
||||
/* Set default for linear segment specific LV parameters */
|
||||
static int _lv_set_default_linear_params(struct cmd_context *cmd,
|
||||
struct lvcreate_params *lp)
|
||||
{
|
||||
if (!(lp->segtype = _get_segtype(cmd))) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
lp->stripes = 1;
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
/*
|
||||
* FIXME: This function should probably not commit to disk but require calling
|
||||
* lvm_vg_write. However, this appears to be non-trivial change until
|
||||
* lv_create_single is refactored by segtype.
|
||||
*/
|
||||
static lv_t _lvm_vg_create_lv_linear(vg_t vg, const char *name, uint64_t size)
|
||||
{
|
||||
struct lvcreate_params lp = { 0 };
|
||||
uint64_t extents;
|
||||
struct logical_volume *lv;
|
||||
|
||||
if (vg_read_error(vg))
|
||||
return NULL;
|
||||
if (!vg_check_write_mode(vg))
|
||||
return NULL;
|
||||
|
||||
if (!(extents = extents_from_size(vg->cmd, size / SECTOR_SIZE,
|
||||
vg->extent_size))) {
|
||||
log_error("Unable to create LV without size.");
|
||||
return NULL;
|
||||
}
|
||||
|
||||
_lv_set_default_params(&lp, vg, name, extents);
|
||||
if (!_lv_set_default_linear_params(vg->cmd, &lp))
|
||||
return_NULL;
|
||||
if (!(lv = lv_create_single(vg, &lp)))
|
||||
return_NULL;
|
||||
return (lv_t) lv;
|
||||
}
|
||||
|
||||
lv_t lvm_vg_create_lv_linear(vg_t vg, const char *name, uint64_t size)
|
||||
{
|
||||
lv_t rc;
|
||||
struct saved_env e = store_user_env(vg->cmd);
|
||||
rc = _lvm_vg_create_lv_linear(vg, name, size);
|
||||
restore_user_env(&e);
|
||||
return rc;
|
||||
}
|
||||
|
||||
/*
|
||||
* FIXME: This function should probably not commit to disk but require calling
|
||||
* lvm_vg_write.
|
||||
*/
|
||||
static int _lvm_vg_remove_lv(lv_t lv)
|
||||
{
|
||||
if (!lv || !lv->vg || vg_read_error(lv->vg))
|
||||
return -1;
|
||||
if (!vg_check_write_mode(lv->vg))
|
||||
return -1;
|
||||
if (!lv_remove_single(lv->vg->cmd, lv, DONT_PROMPT, 0))
|
||||
return -1;
|
||||
return 0;
|
||||
}
|
||||
|
||||
int lvm_vg_remove_lv(lv_t lv)
|
||||
{
|
||||
int rc;
|
||||
struct saved_env e = store_user_env(lv->vg->cmd);
|
||||
rc = _lvm_vg_remove_lv(lv);
|
||||
restore_user_env(&e);
|
||||
return rc;
|
||||
}
|
||||
|
||||
static int _lvm_lv_activate(lv_t lv)
|
||||
{
|
||||
if (!lv || !lv->vg || vg_read_error(lv->vg) || !lv->vg->cmd)
|
||||
return -1;
|
||||
|
||||
/* FIXME: handle pvmove stuff later */
|
||||
if (lv_is_locked(lv)) {
|
||||
log_error("Unable to activate locked LV");
|
||||
return -1;
|
||||
}
|
||||
|
||||
/* FIXME: handle lvconvert stuff later */
|
||||
if (lv_is_converting(lv)) {
|
||||
log_error("Unable to activate LV with in-progress lvconvert");
|
||||
return -1;
|
||||
}
|
||||
|
||||
if (lv_is_origin(lv) ||
|
||||
lv_is_pvmove(lv) ||
|
||||
seg_only_exclusive(first_seg(lv))) {
|
||||
log_verbose("Activating logical volume \"%s\" "
|
||||
"exclusively", lv->name);
|
||||
if (!activate_lv_excl(lv->vg->cmd, lv)) {
|
||||
/* FIXME Improve msg */
|
||||
log_error("Activate exclusive failed.");
|
||||
return -1;
|
||||
}
|
||||
} else {
|
||||
log_verbose("Activating logical volume \"%s\"",
|
||||
lv->name);
|
||||
if (!activate_lv(lv->vg->cmd, lv)) {
|
||||
/* FIXME Improve msg */
|
||||
log_error("Activate failed.");
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
int lvm_lv_activate(lv_t lv)
|
||||
{
|
||||
int rc;
|
||||
struct saved_env e = store_user_env(lv->vg->cmd);
|
||||
rc = _lvm_lv_activate(lv);
|
||||
restore_user_env(&e);
|
||||
return rc;
|
||||
}
|
||||
|
||||
static int _lvm_lv_deactivate(lv_t lv)
|
||||
{
|
||||
if (!lv || !lv->vg || vg_read_error(lv->vg) || !lv->vg->cmd)
|
||||
return -1;
|
||||
|
||||
log_verbose("Deactivating logical volume \"%s\"", lv->name);
|
||||
if (!deactivate_lv(lv->vg->cmd, lv)) {
|
||||
log_error("Deactivate failed.");
|
||||
return -1;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
int lvm_lv_deactivate(lv_t lv)
|
||||
{
|
||||
int rc;
|
||||
struct saved_env e = store_user_env(lv->vg->cmd);
|
||||
rc = _lvm_lv_deactivate(lv);
|
||||
restore_user_env(&e);
|
||||
return rc;
|
||||
}
|
||||
|
||||
static struct dm_list *_lvm_lv_list_lvsegs(lv_t lv)
|
||||
{
|
||||
struct dm_list *list;
|
||||
lvseg_list_t *lvseg;
|
||||
struct lv_segment *lvl;
|
||||
|
||||
if (dm_list_empty(&lv->segments))
|
||||
return NULL;
|
||||
|
||||
if (!(list = dm_pool_zalloc(lv->vg->vgmem, sizeof(*list)))) {
|
||||
log_errno(ENOMEM, "Memory allocation fail for dm_list.");
|
||||
return NULL;
|
||||
}
|
||||
dm_list_init(list);
|
||||
|
||||
dm_list_iterate_items(lvl, &lv->segments) {
|
||||
if (!(lvseg = dm_pool_zalloc(lv->vg->vgmem, sizeof(*lvseg)))) {
|
||||
log_errno(ENOMEM,
|
||||
"Memory allocation fail for lvm_lvseg_list.");
|
||||
return NULL;
|
||||
}
|
||||
lvseg->lvseg = lvl;
|
||||
dm_list_add(list, &lvseg->list);
|
||||
}
|
||||
return list;
|
||||
}
|
||||
|
||||
struct dm_list *lvm_lv_list_lvsegs(lv_t lv)
|
||||
{
|
||||
struct dm_list *rc;
|
||||
struct saved_env e = store_user_env(lv->vg->cmd);
|
||||
rc = _lvm_lv_list_lvsegs(lv);
|
||||
restore_user_env(&e);
|
||||
return rc;
|
||||
}
|
||||
|
||||
lv_t lvm_lv_from_name(vg_t vg, const char *name)
|
||||
{
|
||||
lv_t rc = NULL;
|
||||
struct lv_list *lvl;
|
||||
|
||||
struct saved_env e = store_user_env(vg->cmd);
|
||||
dm_list_iterate_items(lvl, &vg->lvs) {
|
||||
if (!strcmp(name, lvl->lv->name)) {
|
||||
rc = lvl->lv;
|
||||
break;
|
||||
}
|
||||
}
|
||||
restore_user_env(&e);
|
||||
return rc;
|
||||
}
|
||||
|
||||
static lv_t _lvm_lv_from_uuid(vg_t vg, const char *uuid)
|
||||
{
|
||||
struct lv_list *lvl;
|
||||
struct id id;
|
||||
|
||||
if (strlen(uuid) < ID_LEN) {
|
||||
log_errno (EINVAL, "Invalid UUID string length");
|
||||
return NULL;
|
||||
}
|
||||
|
||||
if (!id_read_format(&id, uuid)) {
|
||||
log_errno(EINVAL, "Invalid UUID format.");
|
||||
return NULL;
|
||||
}
|
||||
|
||||
dm_list_iterate_items(lvl, &vg->lvs) {
|
||||
if (id_equal(&vg->id, &lvl->lv->lvid.id[0]) &&
|
||||
id_equal(&id, &lvl->lv->lvid.id[1]))
|
||||
return lvl->lv;
|
||||
}
|
||||
return NULL;
|
||||
}
|
||||
|
||||
lv_t lvm_lv_from_uuid(vg_t vg, const char *uuid)
|
||||
{
|
||||
lv_t rc;
|
||||
struct saved_env e = store_user_env(vg->cmd);
|
||||
rc = _lvm_lv_from_uuid(vg, uuid);
|
||||
restore_user_env(&e);
|
||||
return rc;
|
||||
}
|
||||
|
||||
int lvm_lv_rename(lv_t lv, const char *new_name)
|
||||
{
|
||||
int rc = 0;
|
||||
struct saved_env e = store_user_env(lv->vg->cmd);
|
||||
if (!lv_rename(lv->vg->cmd, lv, new_name)) {
|
||||
/* FIXME Improve msg */
|
||||
log_error("LV rename failed.");
|
||||
rc = -1;
|
||||
}
|
||||
restore_user_env(&e);
|
||||
return rc;
|
||||
}
|
||||
|
||||
int lvm_lv_resize(const lv_t lv, uint64_t new_size)
|
||||
{
|
||||
int rc = 0;
|
||||
struct lvresize_params lp = {
|
||||
.sign = SIGN_NONE,
|
||||
.percent = PERCENT_NONE,
|
||||
.resize = LV_ANY,
|
||||
.size = new_size >> SECTOR_SHIFT,
|
||||
.force = 1, /* Assume the user has a good backup? */
|
||||
};
|
||||
struct saved_env e = store_user_env(lv->vg->cmd);
|
||||
|
||||
if (!lv_resize(lv, &lp, &lv->vg->pvs)) {
|
||||
/* FIXME Improve msg */
|
||||
log_error("LV resize failed.");
|
||||
/* FIXME Define consistent symbolic return codes */
|
||||
rc = -1;
|
||||
}
|
||||
restore_user_env(&e);
|
||||
return rc;
|
||||
}
|
||||
|
||||
lv_t lvm_lv_snapshot(const lv_t lv, const char *snap_name,
|
||||
uint64_t max_snap_size)
|
||||
{
|
||||
lv_t rc = NULL;
|
||||
struct lvm_lv_create_params *lvcp = NULL;
|
||||
struct saved_env e = store_user_env(lv->vg->cmd);
|
||||
|
||||
lvcp = lvm_lv_params_create_snapshot(lv, snap_name, max_snap_size);
|
||||
if (lvcp) {
|
||||
rc = lvm_lv_create(lvcp);
|
||||
}
|
||||
restore_user_env(&e);
|
||||
return rc;
|
||||
}
|
||||
|
||||
/* Set defaults for thin pool specific LV parameters */
|
||||
static int _lv_set_pool_params(struct lvcreate_params *lp,
|
||||
vg_t vg, const char *pool_name,
|
||||
uint64_t extents, uint64_t meta_size)
|
||||
{
|
||||
uint64_t pool_metadata_size;
|
||||
|
||||
_lv_set_default_params(lp, vg, pool_name, extents);
|
||||
|
||||
lp->create_pool = 1;
|
||||
lp->segtype = get_segtype_from_string(vg->cmd, SEG_TYPE_NAME_THIN_POOL);
|
||||
lp->stripes = 1;
|
||||
|
||||
if (!meta_size) {
|
||||
pool_metadata_size = extents * vg->extent_size /
|
||||
(lp->chunk_size * (SECTOR_SIZE / 64));
|
||||
while ((pool_metadata_size >
|
||||
(DEFAULT_THIN_POOL_OPTIMAL_METADATA_SIZE * 2)) &&
|
||||
lp->chunk_size < DM_THIN_MAX_DATA_BLOCK_SIZE) {
|
||||
lp->chunk_size <<= 1;
|
||||
pool_metadata_size >>= 1;
|
||||
}
|
||||
} else
|
||||
pool_metadata_size = meta_size;
|
||||
|
||||
if (pool_metadata_size % vg->extent_size)
|
||||
pool_metadata_size +=
|
||||
vg->extent_size - pool_metadata_size % vg->extent_size;
|
||||
|
||||
if (!(lp->pool_metadata_extents =
|
||||
extents_from_size(vg->cmd, pool_metadata_size / SECTOR_SIZE,
|
||||
vg->extent_size)))
|
||||
return_0;
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
static lv_create_params_t _lvm_lv_params_create_thin_pool(vg_t vg,
|
||||
const char *pool_name, uint64_t size, uint32_t chunk_size,
|
||||
uint64_t meta_size, lvm_thin_discards_t discard)
|
||||
{
|
||||
uint64_t extents = 0;
|
||||
struct lvm_lv_create_params *lvcp = NULL;
|
||||
|
||||
if (meta_size > (2 * DEFAULT_THIN_POOL_MAX_METADATA_SIZE)) {
|
||||
log_error("Invalid metadata size");
|
||||
return NULL;
|
||||
}
|
||||
|
||||
if (meta_size &&
|
||||
meta_size < (2 * DEFAULT_THIN_POOL_MIN_METADATA_SIZE)) {
|
||||
log_error("Invalid metadata size");
|
||||
return NULL;
|
||||
}
|
||||
|
||||
if (vg_read_error(vg))
|
||||
return NULL;
|
||||
|
||||
if (!vg_check_write_mode(vg))
|
||||
return NULL;
|
||||
|
||||
if (pool_name == NULL || !strlen(pool_name)) {
|
||||
log_error("pool_name invalid");
|
||||
return NULL;
|
||||
}
|
||||
|
||||
if (!(extents = extents_from_size(vg->cmd, size / SECTOR_SIZE,
|
||||
vg->extent_size))) {
|
||||
log_error("Unable to create LV thin pool without size.");
|
||||
return NULL;
|
||||
}
|
||||
|
||||
lvcp = dm_pool_zalloc(vg->vgmem, sizeof (struct lvm_lv_create_params));
|
||||
|
||||
if (lvcp) {
|
||||
lvcp->vg = vg;
|
||||
switch (discard) {
|
||||
case LVM_THIN_DISCARDS_IGNORE:
|
||||
lvcp->lvp.discards = THIN_DISCARDS_IGNORE;
|
||||
break;
|
||||
case LVM_THIN_DISCARDS_NO_PASSDOWN:
|
||||
lvcp->lvp.discards = THIN_DISCARDS_NO_PASSDOWN;
|
||||
break;
|
||||
case LVM_THIN_DISCARDS_PASSDOWN:
|
||||
lvcp->lvp.discards = THIN_DISCARDS_PASSDOWN;
|
||||
break;
|
||||
default:
|
||||
log_error("Invalid discard argument %d for thin pool creation.", discard);
|
||||
return NULL;
|
||||
}
|
||||
lvcp->lvp.zero_new_blocks = THIN_ZERO_YES;
|
||||
|
||||
if (chunk_size)
|
||||
lvcp->lvp.chunk_size = chunk_size;
|
||||
else
|
||||
lvcp->lvp.chunk_size = DEFAULT_THIN_POOL_CHUNK_SIZE * 2;
|
||||
|
||||
if (lvcp->lvp.chunk_size < DM_THIN_MIN_DATA_BLOCK_SIZE ||
|
||||
lvcp->lvp.chunk_size > DM_THIN_MAX_DATA_BLOCK_SIZE) {
|
||||
log_error("Invalid chunk_size");
|
||||
return NULL;
|
||||
}
|
||||
|
||||
if (!_lv_set_pool_params(&lvcp->lvp, vg, pool_name, extents, meta_size))
|
||||
return_NULL;
|
||||
|
||||
lvcp->magic = LV_CREATE_PARAMS_MAGIC;
|
||||
}
|
||||
return lvcp;
|
||||
}
|
||||
|
||||
lv_create_params_t lvm_lv_params_create_thin_pool(vg_t vg,
|
||||
const char *pool_name, uint64_t size, uint32_t chunk_size,
|
||||
uint64_t meta_size, lvm_thin_discards_t discard)
|
||||
{
|
||||
lv_create_params_t rc;
|
||||
struct saved_env e = store_user_env(vg->cmd);
|
||||
rc = _lvm_lv_params_create_thin_pool(vg, pool_name, size, chunk_size,
|
||||
meta_size, discard);
|
||||
restore_user_env(&e);
|
||||
return rc;
|
||||
}
|
||||
|
||||
/* Set defaults for thin LV specific parameters */
|
||||
static int _lv_set_thin_params(struct lvcreate_params *lp,
|
||||
vg_t vg, const char *pool_name,
|
||||
const char *lvname,
|
||||
uint32_t extents)
|
||||
{
|
||||
_lv_set_default_params(lp, vg, lvname, 0);
|
||||
|
||||
lp->pool_name = pool_name;
|
||||
lp->segtype = get_segtype_from_string(vg->cmd, SEG_TYPE_NAME_THIN);
|
||||
lp->virtual_extents = extents;
|
||||
lp->stripes = 1;
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
static lv_create_params_t _lvm_lv_params_create_snapshot(const lv_t lv,
|
||||
const char *snap_name,
|
||||
uint64_t max_snap_size)
|
||||
{
|
||||
uint64_t size = 0;
|
||||
uint64_t extents = 0;
|
||||
struct lvm_lv_create_params *lvcp = NULL;
|
||||
|
||||
if (vg_read_error(lv->vg)) {
|
||||
return NULL;
|
||||
}
|
||||
|
||||
if (!vg_check_write_mode(lv->vg))
|
||||
return NULL;
|
||||
|
||||
if (snap_name == NULL || !strlen(snap_name)) {
|
||||
log_error("snap_name invalid");
|
||||
return NULL;
|
||||
}
|
||||
|
||||
if (max_snap_size) {
|
||||
size = max_snap_size >> SECTOR_SHIFT;
|
||||
if (!(extents = extents_from_size(lv->vg->cmd, size, lv->vg->extent_size)))
|
||||
return_NULL;
|
||||
}
|
||||
|
||||
if (!size && !lv_is_thin_volume(lv) ) {
|
||||
log_error("Origin is not thin, specify size of snapshot");
|
||||
return NULL;
|
||||
}
|
||||
|
||||
lvcp = dm_pool_zalloc(lv->vg->vgmem, sizeof (struct lvm_lv_create_params));
|
||||
if (lvcp) {
|
||||
lvcp->vg = lv->vg;
|
||||
_lv_set_default_params(&lvcp->lvp, lv->vg, snap_name, extents);
|
||||
|
||||
if (size) {
|
||||
if (!(lvcp->lvp.segtype = get_segtype_from_string(lv->vg->cmd, SEG_TYPE_NAME_SNAPSHOT))) {
|
||||
log_error("Segtype snapshot not found.");
|
||||
return NULL;
|
||||
}
|
||||
lvcp->lvp.chunk_size = 8;
|
||||
lvcp->lvp.snapshot = 1;
|
||||
} else {
|
||||
if (!(lvcp->lvp.segtype = get_segtype_from_string(lv->vg->cmd, SEG_TYPE_NAME_THIN))) {
|
||||
log_error("Segtype thin not found.");
|
||||
return NULL;
|
||||
}
|
||||
|
||||
lvcp->lvp.pool_name = first_seg(lv)->pool_lv->name;
|
||||
}
|
||||
|
||||
lvcp->lvp.stripes = 1;
|
||||
lvcp->lvp.origin_name = lv->name;
|
||||
|
||||
lvcp->magic = LV_CREATE_PARAMS_MAGIC;
|
||||
}
|
||||
|
||||
return lvcp;
|
||||
}
|
||||
|
||||
lv_create_params_t lvm_lv_params_create_snapshot(const lv_t lv,
|
||||
const char *snap_name,
|
||||
uint64_t max_snap_size)
|
||||
{
|
||||
lv_create_params_t rc;
|
||||
struct saved_env e = store_user_env(lv->vg->cmd);
|
||||
rc = _lvm_lv_params_create_snapshot(lv, snap_name, max_snap_size);
|
||||
restore_user_env(&e);
|
||||
return rc;
|
||||
}
|
||||
|
||||
static lv_create_params_t _lvm_lv_params_create_thin(const vg_t vg,
|
||||
const char *pool_name,
|
||||
const char *lvname, uint64_t size)
|
||||
{
|
||||
struct lvm_lv_create_params *lvcp = NULL;
|
||||
uint32_t extents = 0;
|
||||
|
||||
/* precondition checks */
|
||||
if (vg_read_error(vg))
|
||||
return NULL;
|
||||
|
||||
if (!vg_check_write_mode(vg))
|
||||
return NULL;
|
||||
|
||||
if (pool_name == NULL || !strlen(pool_name)) {
|
||||
log_error("pool_name invalid");
|
||||
return NULL;
|
||||
}
|
||||
|
||||
if (lvname == NULL || !strlen(lvname)) {
|
||||
log_error("lvname invalid");
|
||||
return NULL;
|
||||
}
|
||||
|
||||
if (!(extents = extents_from_size(vg->cmd, size / SECTOR_SIZE,
|
||||
vg->extent_size))) {
|
||||
log_error("Unable to create thin LV without size.");
|
||||
return NULL;
|
||||
}
|
||||
|
||||
lvcp = dm_pool_zalloc(vg->vgmem, sizeof (struct lvm_lv_create_params));
|
||||
if (lvcp) {
|
||||
lvcp->vg = vg;
|
||||
if (!_lv_set_thin_params(&lvcp->lvp, vg, pool_name, lvname, extents))
|
||||
return_NULL;
|
||||
|
||||
lvcp->magic = LV_CREATE_PARAMS_MAGIC;
|
||||
}
|
||||
|
||||
return lvcp;
|
||||
}
|
||||
|
||||
lv_create_params_t lvm_lv_params_create_thin(const vg_t vg, const char *pool_name,
|
||||
const char *lvname, uint64_t size)
|
||||
{
|
||||
lv_create_params_t rc;
|
||||
struct saved_env e = store_user_env(vg->cmd);
|
||||
rc = _lvm_lv_params_create_thin(vg, pool_name, lvname, size);
|
||||
restore_user_env(&e);
|
||||
return rc;
|
||||
}
|
||||
|
||||
struct lvm_property_value lvm_lv_params_get_property(
|
||||
const lv_create_params_t params,
|
||||
const char *name)
|
||||
{
|
||||
struct lvm_property_value rc = { .is_valid = 0 };
|
||||
|
||||
if (params && params->magic == LV_CREATE_PARAMS_MAGIC) {
|
||||
struct saved_env e = store_user_env(params->vg->cmd);
|
||||
rc = get_property(NULL, NULL, NULL, NULL, NULL, ¶ms->lvp, NULL, name);
|
||||
restore_user_env(&e);
|
||||
} else
|
||||
log_error("Invalid lv_create_params parameter");
|
||||
|
||||
return rc;
|
||||
}
|
||||
|
||||
int lvm_lv_params_set_property(lv_create_params_t params, const char *name,
|
||||
struct lvm_property_value *prop)
|
||||
{
|
||||
int rc = -1;
|
||||
|
||||
if (params && params->magic == LV_CREATE_PARAMS_MAGIC) {
|
||||
struct saved_env e = store_user_env(params->vg->cmd);
|
||||
rc = set_property(NULL, NULL, NULL, ¶ms->lvp, NULL, name, prop);
|
||||
restore_user_env(&e);
|
||||
} else
|
||||
log_error("Invalid lv_create_params parameter");
|
||||
|
||||
return rc;
|
||||
}
|
||||
|
||||
static lv_t _lvm_lv_create(lv_create_params_t params)
|
||||
{
|
||||
struct lv_list *lvl = NULL;
|
||||
|
||||
if (params && params->magic == LV_CREATE_PARAMS_MAGIC) {
|
||||
if (!params->lvp.segtype) {
|
||||
log_error("segtype parameter is NULL");
|
||||
return_NULL;
|
||||
}
|
||||
if (!lv_create_single(params->vg, ¶ms->lvp))
|
||||
return_NULL;
|
||||
|
||||
/*
|
||||
* In some case we are making a thin pool so lv_name is not valid, but
|
||||
* pool is.
|
||||
*/
|
||||
if (!(lvl = find_lv_in_vg(params->vg,
|
||||
(params->lvp.lv_name) ? params->lvp.lv_name : params->lvp.pool_name)))
|
||||
return_NULL;
|
||||
return (lv_t) lvl->lv;
|
||||
}
|
||||
log_error("Invalid lv_create_params parameter");
|
||||
return NULL;
|
||||
}
|
||||
|
||||
lv_t lvm_lv_create(lv_create_params_t params)
|
||||
{
|
||||
lv_t rc;
|
||||
struct saved_env e = store_user_env(params->vg->cmd);
|
||||
rc = _lvm_lv_create(params);
|
||||
restore_user_env(&e);
|
||||
return rc;
|
||||
}
|
@ -1,168 +0,0 @@
|
||||
/*
|
||||
* Copyright (C) 2008-2013 Red Hat, Inc. All rights reserved.
|
||||
*
|
||||
* This file is part of LVM2.
|
||||
*
|
||||
* This copyrighted material is made available to anyone wishing to use,
|
||||
* modify, copy, or redistribute it subject to the terms and conditions
|
||||
* of the GNU Lesser General Public License v.2.1.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public License
|
||||
* along with this program; if not, write to the Free Software Foundation,
|
||||
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
*/
|
||||
|
||||
#include "lib/misc/lib.h"
|
||||
#include "lib/report/properties.h"
|
||||
#include "lvm_misc.h"
|
||||
#include "liblvm/lvm2app.h"
|
||||
#include "lvm_prop.h"
|
||||
|
||||
struct dm_list *tag_list_copy(struct dm_pool *p, struct dm_list *tag_list)
|
||||
{
|
||||
struct dm_list *list;
|
||||
lvm_str_list_t *lsl;
|
||||
struct dm_str_list *sl;
|
||||
|
||||
if (!(list = dm_pool_zalloc(p, sizeof(*list)))) {
|
||||
log_errno(ENOMEM, "Memory allocation fail for dm_list.");
|
||||
return NULL;
|
||||
}
|
||||
dm_list_init(list);
|
||||
|
||||
dm_list_iterate_items(sl, tag_list) {
|
||||
if (!(lsl = dm_pool_zalloc(p, sizeof(*lsl)))) {
|
||||
log_errno(ENOMEM,
|
||||
"Memory allocation fail for lvm_lv_list.");
|
||||
return NULL;
|
||||
}
|
||||
if (!(lsl->str = dm_pool_strdup(p, sl->str))) {
|
||||
log_errno(ENOMEM,
|
||||
"Memory allocation fail for lvm_lv_list->str.");
|
||||
return NULL;
|
||||
}
|
||||
dm_list_add(list, &lsl->list);
|
||||
}
|
||||
return list;
|
||||
}
|
||||
|
||||
struct lvm_property_value get_property(const pv_t pv, const vg_t vg,
|
||||
const lv_t lv,
|
||||
const lvseg_t lvseg,
|
||||
const pvseg_t pvseg,
|
||||
const struct lvcreate_params *lvcp,
|
||||
const struct pvcreate_params *pvcp,
|
||||
const char *name)
|
||||
{
|
||||
struct lvm_property_type prop;
|
||||
struct lvm_property_value v = { 0 };
|
||||
|
||||
prop.id = name;
|
||||
|
||||
if (pv) {
|
||||
if (!pv_get_property(pv, &prop))
|
||||
return v;
|
||||
} else if (vg) {
|
||||
if (!vg_get_property(vg, &prop))
|
||||
return v;
|
||||
} else if (lv) {
|
||||
if (!lv_get_property(lv, &prop))
|
||||
return v;
|
||||
} else if (lvseg) {
|
||||
if (!lvseg_get_property(lvseg, &prop))
|
||||
return v;
|
||||
} else if (pvseg) {
|
||||
if (!pvseg_get_property(pvseg, &prop))
|
||||
return v;
|
||||
} else if (lvcp) {
|
||||
if (!lv_create_param_get_property(lvcp, &prop))
|
||||
return v;
|
||||
} else if (pvcp) {
|
||||
if (!pv_create_param_get_property(pvcp, &prop))
|
||||
return v;
|
||||
} else {
|
||||
log_errno(EINVAL, "Invalid NULL handle passed to library function.");
|
||||
return v;
|
||||
}
|
||||
|
||||
v.is_settable = prop.is_settable;
|
||||
v.is_string = prop.is_string;
|
||||
v.is_integer = prop.is_integer;
|
||||
v.is_signed = prop.is_signed;
|
||||
if (v.is_string)
|
||||
v.value.string = prop.value.string;
|
||||
if (v.is_integer)
|
||||
v.value.integer = prop.value.integer;
|
||||
v.is_valid = 1;
|
||||
return v;
|
||||
}
|
||||
|
||||
|
||||
int set_property(const pv_t pv, const vg_t vg, const lv_t lv,
|
||||
struct lvcreate_params *lvcp,
|
||||
struct pvcreate_params *pvcp,
|
||||
const char *name,
|
||||
struct lvm_property_value *v)
|
||||
{
|
||||
struct lvm_property_type prop;
|
||||
|
||||
prop.id = name;
|
||||
if (v->is_string)
|
||||
prop.value.string = v->value.string;
|
||||
else
|
||||
prop.value.integer = v->value.integer;
|
||||
if (pv) {
|
||||
if (!pv_set_property(pv, &prop)) {
|
||||
v->is_valid = 0;
|
||||
return -1;
|
||||
}
|
||||
} else if (vg) {
|
||||
if (!vg_set_property(vg, &prop)) {
|
||||
v->is_valid = 0;
|
||||
return -1;
|
||||
}
|
||||
} else if (lv) {
|
||||
if (!lv_set_property(lv, &prop)) {
|
||||
v->is_valid = 0;
|
||||
return -1;
|
||||
}
|
||||
} else if (lvcp) {
|
||||
if (!lv_create_param_set_property(lvcp, &prop)) {
|
||||
v->is_valid = 0;
|
||||
return -1;
|
||||
}
|
||||
} else if (pvcp) {
|
||||
if (!pv_create_param_set_property(pvcp, &prop)) {
|
||||
v->is_valid = 0;
|
||||
return -1;
|
||||
}
|
||||
} else {
|
||||
return -1;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
/*
|
||||
* Store anything that may need to be restored back to the user on library
|
||||
* call exit. Currently the only thing we are preserving is the users umask.
|
||||
*/
|
||||
struct saved_env store_user_env(struct cmd_context *cmd)
|
||||
{
|
||||
struct saved_env env = {0};
|
||||
|
||||
if (cmd) {
|
||||
env.user_umask = umask(cmd->default_settings.umask);
|
||||
} else {
|
||||
env.user_umask = umask(0);
|
||||
umask(env.user_umask);
|
||||
}
|
||||
|
||||
return env;
|
||||
}
|
||||
|
||||
void restore_user_env(const struct saved_env *env)
|
||||
{
|
||||
if (env) {
|
||||
umask(env->user_umask);
|
||||
}
|
||||
}
|
@ -1,46 +0,0 @@
|
||||
/*
|
||||
* Copyright (C) 2008-2013 Red Hat, Inc. All rights reserved.
|
||||
*
|
||||
* This file is part of LVM2.
|
||||
*
|
||||
* This copyrighted material is made available to anyone wishing to use,
|
||||
* modify, copy, or redistribute it subject to the terms and conditions
|
||||
* of the GNU Lesser General Public License v.2.1.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public License
|
||||
* along with this program; if not, write to the Free Software Foundation,
|
||||
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
*/
|
||||
#ifndef _LVM2APP_MISC_H
|
||||
#define _LVM2APP_MISC_H
|
||||
|
||||
#include "device_mapper/libdevmapper.h"
|
||||
#include "liblvm/lvm2app.h"
|
||||
#include "lib/metadata/metadata-exported.h"
|
||||
#include "lib/commands/toolcontext.h"
|
||||
|
||||
#include <sys/types.h>
|
||||
#include <sys/stat.h>
|
||||
|
||||
struct saved_env
|
||||
{
|
||||
mode_t user_umask;
|
||||
};
|
||||
|
||||
struct saved_env store_user_env(struct cmd_context *cmd);
|
||||
void restore_user_env(const struct saved_env *env);
|
||||
|
||||
struct dm_list *tag_list_copy(struct dm_pool *p, struct dm_list *tag_list);
|
||||
struct lvm_property_value get_property(const pv_t pv, const vg_t vg,
|
||||
const lv_t lv, const lvseg_t lvseg,
|
||||
const pvseg_t pvseg,
|
||||
const struct lvcreate_params *lvcp,
|
||||
const struct pvcreate_params *pvcp,
|
||||
const char *name);
|
||||
int set_property(const pv_t pv, const vg_t vg, const lv_t lv,
|
||||
struct lvcreate_params *lvcp,
|
||||
struct pvcreate_params *pvcp,
|
||||
const char *name,
|
||||
struct lvm_property_value *value);
|
||||
|
||||
#endif
|
@ -1,74 +0,0 @@
|
||||
/*
|
||||
* Copyright (C) 2013 Red Hat, Inc. All rights reserved.
|
||||
*
|
||||
* This file is part of LVM2.
|
||||
*
|
||||
* This copyrighted material is made available to anyone wishing to use,
|
||||
* modify, copy, or redistribute it subject to the terms and conditions
|
||||
* of the GNU Lesser General Public License v.2.1.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public License
|
||||
* along with this program; if not, write to the Free Software Foundation,
|
||||
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
*/
|
||||
|
||||
#include "lvm_prop.h"
|
||||
#include "device_mapper/libdevmapper.h"
|
||||
#include "lib/metadata/metadata.h"
|
||||
|
||||
/* lv create parameters */
|
||||
GET_LVCREATEPARAMS_NUM_PROPERTY_FN(skip_zero, lvcp->zero)
|
||||
SET_LVCREATEPARAMS_NUM_PROPERTY_FN(skip_zero, lvcp->zero)
|
||||
|
||||
/* PV create parameters */
|
||||
GET_PVCREATEPARAMS_NUM_PROPERTY_FN(size, pvcp->pva.size)
|
||||
SET_PVCREATEPARAMS_NUM_PROPERTY_FN(size, pvcp->pva.size)
|
||||
|
||||
GET_PVCREATEPARAMS_NUM_PROPERTY_FN(pvmetadatacopies, pvcp->pva.pvmetadatacopies)
|
||||
SET_PVCREATEPARAMS_NUM_PROPERTY_FN(pvmetadatacopies, pvcp->pva.pvmetadatacopies)
|
||||
|
||||
GET_PVCREATEPARAMS_NUM_PROPERTY_FN(pvmetadatasize, pvcp->pva.pvmetadatasize)
|
||||
SET_PVCREATEPARAMS_NUM_PROPERTY_FN(pvmetadatasize, pvcp->pva.pvmetadatasize)
|
||||
|
||||
GET_PVCREATEPARAMS_NUM_PROPERTY_FN(data_alignment, pvcp->pva.data_alignment)
|
||||
SET_PVCREATEPARAMS_NUM_PROPERTY_FN(data_alignment, pvcp->pva.data_alignment)
|
||||
|
||||
GET_PVCREATEPARAMS_NUM_PROPERTY_FN(data_alignment_offset, pvcp->pva.data_alignment_offset)
|
||||
SET_PVCREATEPARAMS_NUM_PROPERTY_FN(data_alignment_offset, pvcp->pva.data_alignment_offset)
|
||||
|
||||
GET_PVCREATEPARAMS_NUM_PROPERTY_FN(zero, pvcp->zero)
|
||||
SET_PVCREATEPARAMS_NUM_PROPERTY_FN(zero, pvcp->zero)
|
||||
|
||||
struct lvm_property_type _lib_properties[] = {
|
||||
#include "lvm_prop_fields.h"
|
||||
{ 0, "", 0, 0, 0, 0, { .integer = 0 }, prop_not_implemented_get,
|
||||
prop_not_implemented_set },
|
||||
};
|
||||
|
||||
#undef STR
|
||||
#undef NUM
|
||||
#undef FIELD
|
||||
|
||||
int lv_create_param_get_property(const struct lvcreate_params *lvcp,
|
||||
struct lvm_property_type *prop)
|
||||
{
|
||||
return prop_get_property(_lib_properties, lvcp, prop, LV_CREATE_PARAMS);
|
||||
}
|
||||
|
||||
int lv_create_param_set_property(struct lvcreate_params *lvcp,
|
||||
struct lvm_property_type *prop)
|
||||
{
|
||||
return prop_set_property(_lib_properties, lvcp, prop, LV_CREATE_PARAMS);
|
||||
}
|
||||
|
||||
int pv_create_param_get_property(const struct pvcreate_params *pvcp,
|
||||
struct lvm_property_type *prop)
|
||||
{
|
||||
return prop_get_property(_lib_properties, pvcp, prop, PV_CREATE_PARAMS);
|
||||
}
|
||||
|
||||
int pv_create_param_set_property(struct pvcreate_params *pvcp,
|
||||
struct lvm_property_type *prop)
|
||||
{
|
||||
return prop_set_property(_lib_properties, pvcp, prop, PV_CREATE_PARAMS);
|
||||
}
|
@ -1,49 +0,0 @@
|
||||
/*
|
||||
* Copyright (C) 2013 Red Hat, Inc. All rights reserved.
|
||||
*
|
||||
* This file is part of LVM2.
|
||||
*
|
||||
* This copyrighted material is made available to anyone wishing to use,
|
||||
* modify, copy, or redistribute it subject to the terms and conditions
|
||||
* of the GNU Lesser General Public License v.2.1.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public License
|
||||
* along with this program; if not, write to the Free Software Foundation,
|
||||
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
*/
|
||||
#include "lib/properties/prop_common.h"
|
||||
|
||||
#ifndef _LIB_LVM_PROP_H
|
||||
#define _LIB_LVM_PROP_H
|
||||
|
||||
typedef struct lvcreate_params type_lvcreate_params;
|
||||
typedef struct pvcreate_params type_pvcreate_params;
|
||||
|
||||
#define LV_CREATE_PARAMS 1
|
||||
#define PV_CREATE_PARAMS 2
|
||||
|
||||
#define GET_LVCREATEPARAMS_NUM_PROPERTY_FN(NAME, VALUE)\
|
||||
GET_NUM_PROPERTY_FN(NAME, VALUE, lvcreate_params, lvcp)
|
||||
|
||||
#define SET_LVCREATEPARAMS_NUM_PROPERTY_FN(NAME, VALUE) \
|
||||
SET_NUM_PROPERTY(NAME, VALUE, lvcreate_params, lvcp)
|
||||
|
||||
#define GET_PVCREATEPARAMS_NUM_PROPERTY_FN(NAME, VALUE)\
|
||||
GET_NUM_PROPERTY_FN(NAME, VALUE, pvcreate_params, pvcp)
|
||||
|
||||
#define SET_PVCREATEPARAMS_NUM_PROPERTY_FN(NAME, VALUE) \
|
||||
SET_NUM_PROPERTY(NAME, VALUE, pvcreate_params, pvcp)
|
||||
|
||||
int lv_create_param_get_property(const struct lvcreate_params *lvcp,
|
||||
struct lvm_property_type *prop);
|
||||
|
||||
int lv_create_param_set_property(struct lvcreate_params *lvcp,
|
||||
struct lvm_property_type *prop);
|
||||
|
||||
int pv_create_param_get_property(const struct pvcreate_params *pvcp,
|
||||
struct lvm_property_type *prop);
|
||||
|
||||
int pv_create_param_set_property(struct pvcreate_params *pvcp,
|
||||
struct lvm_property_type *prop);
|
||||
|
||||
#endif
|
@ -1,22 +0,0 @@
|
||||
/*
|
||||
* Copyright (C) 2013 Red Hat, Inc. All rights reserved.
|
||||
*
|
||||
* This file is part of LVM2.
|
||||
*
|
||||
* This copyrighted material is made available to anyone wishing to use,
|
||||
* modify, copy, or redistribute it subject to the terms and conditions
|
||||
* of the GNU Lesser General Public License v.2.1.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public License
|
||||
* along with this program; if not, write to the Free Software Foundation,
|
||||
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
*/
|
||||
|
||||
FIELD(LV_CREATE_PARAMS, lvcreate_params, NUM, "skip_zero", zero, 2, uint32, skip_zero, "Skip zeroing on lv creation", 1)
|
||||
|
||||
FIELD(PV_CREATE_PARAMS, pvcreate_params, NUM, "size", size, 2, uint64_t, size, "PV size", 1)
|
||||
FIELD(PV_CREATE_PARAMS, pvcreate_params, NUM, "pvmetadatacopies", pvmetadatacopies, 2, uint64_t, pvmetadatacopies, "PV Metadata copies", 1)
|
||||
FIELD(PV_CREATE_PARAMS, pvcreate_params, NUM, "pvmetadatasize", pvmetadatasize, 2, uint64_t, pvmetadatasize, "PV Metadata size", 1)
|
||||
FIELD(PV_CREATE_PARAMS, pvcreate_params, NUM, "data_alignment", data_alignment, 2, uint64_t, data_alignment, "Start data to a multiple of value", 1)
|
||||
FIELD(PV_CREATE_PARAMS, pvcreate_params, NUM, "data_alignment_offset", data_alignment_offset, 2, uint64_t, data_alignment_offset, "Shift the start of the data area", 1)
|
||||
FIELD(PV_CREATE_PARAMS, pvcreate_params, NUM, "zero", zero, 2, uint64_t, zero, "Zero first 2048 bytes of device", 1)
|
474
liblvm/lvm_pv.c
474
liblvm/lvm_pv.c
@ -1,474 +0,0 @@
|
||||
/*
|
||||
* Copyright (C) 2008-2013 Red Hat, Inc. All rights reserved.
|
||||
*
|
||||
* This file is part of LVM2.
|
||||
*
|
||||
* This copyrighted material is made available to anyone wishing to use,
|
||||
* modify, copy, or redistribute it subject to the terms and conditions
|
||||
* of the GNU Lesser General Public License v.2.1.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public License
|
||||
* along with this program; if not, write to the Free Software Foundation,
|
||||
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
*/
|
||||
|
||||
#include <stddef.h>
|
||||
#include "lib/misc/lib.h"
|
||||
#include "lib/metadata/metadata-exported.h"
|
||||
#include "lib/misc/lvm-string.h"
|
||||
#include "lib/datastruct/str_list.h"
|
||||
#include "lvm_misc.h"
|
||||
#include "liblvm/lvm2app.h"
|
||||
#include "lib/locking/locking.h"
|
||||
#include "lib/commands/toolcontext.h"
|
||||
#include "lvm_misc.h"
|
||||
#include "lib/cache/lvmetad.h"
|
||||
|
||||
struct lvm_pv_create_params
|
||||
{
|
||||
uint32_t magic;
|
||||
lvm_t libh;
|
||||
const char *pv_name;
|
||||
struct pvcreate_params pv_p;
|
||||
};
|
||||
|
||||
#define PV_CREATE_PARAMS_MAGIC 0xFEED0002
|
||||
|
||||
const char *lvm_pv_get_uuid(const pv_t pv)
|
||||
{
|
||||
const char *rc;
|
||||
struct saved_env e = store_user_env(pv->vg->cmd);
|
||||
rc = pv_uuid_dup(pv->vg->vgmem, pv);
|
||||
restore_user_env(&e);
|
||||
return rc;
|
||||
}
|
||||
|
||||
const char *lvm_pv_get_name(const pv_t pv)
|
||||
{
|
||||
const char *rc;
|
||||
struct saved_env e = store_user_env(pv->vg->cmd);
|
||||
rc = dm_pool_strndup(pv->vg->vgmem, pv_dev_name(pv), NAME_LEN);
|
||||
restore_user_env(&e);
|
||||
return rc;
|
||||
}
|
||||
|
||||
uint64_t lvm_pv_get_mda_count(const pv_t pv)
|
||||
{
|
||||
uint64_t rc;
|
||||
struct saved_env e = store_user_env(pv->vg->cmd);
|
||||
rc = (uint64_t) pv_mda_count(pv);
|
||||
restore_user_env(&e);
|
||||
return rc;
|
||||
}
|
||||
|
||||
uint64_t lvm_pv_get_dev_size(const pv_t pv)
|
||||
{
|
||||
uint64_t rc;
|
||||
struct saved_env e = store_user_env(pv->vg->cmd);
|
||||
rc = SECTOR_SIZE * pv_dev_size(pv);
|
||||
restore_user_env(&e);
|
||||
return rc;
|
||||
}
|
||||
|
||||
uint64_t lvm_pv_get_size(const pv_t pv)
|
||||
{
|
||||
uint64_t rc;
|
||||
struct saved_env e = store_user_env(pv->vg->cmd);
|
||||
rc = SECTOR_SIZE * pv_size_field(pv);
|
||||
restore_user_env(&e);
|
||||
return rc;
|
||||
}
|
||||
|
||||
uint64_t lvm_pv_get_free(const pv_t pv)
|
||||
{
|
||||
uint64_t rc;
|
||||
struct saved_env e = store_user_env(pv->vg->cmd);
|
||||
rc = SECTOR_SIZE * pv_free(pv);
|
||||
restore_user_env(&e);
|
||||
return rc;
|
||||
}
|
||||
|
||||
struct lvm_property_value lvm_pv_get_property(const pv_t pv, const char *name)
|
||||
{
|
||||
struct lvm_property_value rc;
|
||||
struct saved_env e = store_user_env(pv->vg->cmd);
|
||||
rc = get_property(pv, NULL, NULL, NULL, NULL, NULL, NULL, name);
|
||||
restore_user_env(&e);
|
||||
return rc;
|
||||
}
|
||||
|
||||
struct lvm_property_value lvm_pvseg_get_property(const pvseg_t pvseg,
|
||||
const char *name)
|
||||
{
|
||||
struct lvm_property_value rc;
|
||||
struct saved_env e = store_user_env(pvseg->pv->vg->cmd);
|
||||
rc = get_property(NULL, NULL, NULL, NULL, pvseg, NULL, NULL, name);
|
||||
restore_user_env(&e);
|
||||
return rc;
|
||||
}
|
||||
|
||||
struct lvm_list_wrapper
|
||||
{
|
||||
unsigned long magic;
|
||||
struct cmd_context *cmd;
|
||||
struct dm_list pvslist;
|
||||
struct dm_list vgslist;
|
||||
};
|
||||
|
||||
int lvm_pv_remove(lvm_t libh, const char *pv_name)
|
||||
{
|
||||
int rc = 0;
|
||||
struct cmd_context *cmd = (struct cmd_context *)libh;
|
||||
struct saved_env e = store_user_env(cmd);
|
||||
struct dm_list pv_names;
|
||||
|
||||
dm_list_init(&pv_names);
|
||||
|
||||
if (!str_list_add(cmd->mem, &pv_names, pv_name))
|
||||
rc = -1;
|
||||
|
||||
if (rc >= 0 && !pvremove_many(cmd, &pv_names, 0, 0))
|
||||
rc = -1;
|
||||
|
||||
restore_user_env(&e);
|
||||
return rc;
|
||||
}
|
||||
|
||||
#define PV_LIST_MAGIC 4026907153U
|
||||
|
||||
static struct dm_list *_lvm_list_pvs(lvm_t libh)
|
||||
{
|
||||
struct lvm_list_wrapper *rc = NULL;
|
||||
struct cmd_context *cmd = (struct cmd_context *)libh;
|
||||
|
||||
/*
|
||||
* This memory will get cleared when the library handle
|
||||
* gets closed, don't try to free is as it doesn't work
|
||||
* like malloc/free do.
|
||||
*/
|
||||
if (!(rc = dm_pool_zalloc(cmd->mem, sizeof(*rc)))) {
|
||||
log_errno(ENOMEM, "Memory allocation fail for pv list.");
|
||||
return NULL;
|
||||
}
|
||||
|
||||
if (!lock_vol(cmd, VG_GLOBAL, LCK_VG_WRITE, NULL)) {
|
||||
log_errno(ENOLCK, "Unable to obtain global lock.");
|
||||
} else {
|
||||
dm_list_init(&rc->pvslist);
|
||||
dm_list_init(&rc->vgslist);
|
||||
if (!get_pvs_perserve_vg(cmd, &rc->pvslist, &rc->vgslist))
|
||||
return_NULL;
|
||||
|
||||
/*
|
||||
* If we have no PVs we still need to have access to cmd
|
||||
* pointer in the free call.
|
||||
*/
|
||||
rc->cmd = cmd;
|
||||
rc->magic = PV_LIST_MAGIC;
|
||||
}
|
||||
|
||||
return &rc->pvslist;
|
||||
}
|
||||
|
||||
struct dm_list *lvm_list_pvs(lvm_t libh)
|
||||
{
|
||||
struct dm_list *rc;
|
||||
struct saved_env e = store_user_env((struct cmd_context *)libh);
|
||||
rc = _lvm_list_pvs(libh);
|
||||
restore_user_env(&e);
|
||||
return rc;
|
||||
}
|
||||
|
||||
int lvm_list_pvs_free(struct dm_list *pvlist)
|
||||
{
|
||||
struct lvm_list_wrapper *to_delete;
|
||||
struct vg_list *vgl;
|
||||
struct pv_list *pvl;
|
||||
struct saved_env e;
|
||||
|
||||
if (pvlist) {
|
||||
to_delete = dm_list_struct_base(pvlist, struct lvm_list_wrapper, pvslist);
|
||||
if (to_delete->magic != PV_LIST_MAGIC) {
|
||||
log_errno(EINVAL, "Not a correct pvlist structure");
|
||||
return -1;
|
||||
}
|
||||
|
||||
/*
|
||||
* Need to ensure that pointer is valid before we can use reference to
|
||||
* cmd.
|
||||
*/
|
||||
e = store_user_env(to_delete->cmd);
|
||||
|
||||
dm_list_iterate_items(vgl, &to_delete->vgslist) {
|
||||
release_vg(vgl->vg);
|
||||
}
|
||||
|
||||
dm_list_iterate_items(pvl, &to_delete->pvslist)
|
||||
free_pv_fid(pvl->pv);
|
||||
|
||||
unlock_vg(to_delete->cmd, NULL, VG_GLOBAL);
|
||||
to_delete->magic = 0xA5A5A5A5;
|
||||
|
||||
restore_user_env(&e);
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static struct dm_list *_lvm_pv_list_pvsegs(pv_t pv)
|
||||
{
|
||||
struct dm_list *list;
|
||||
pvseg_list_t *pvseg;
|
||||
struct pv_segment *pvl;
|
||||
|
||||
if (dm_list_empty(&pv->segments))
|
||||
return NULL;
|
||||
|
||||
if (!(list = dm_pool_zalloc(pv->vg->vgmem, sizeof(*list)))) {
|
||||
log_errno(ENOMEM, "Memory allocation fail for dm_list.");
|
||||
return NULL;
|
||||
}
|
||||
|
||||
dm_list_init(list);
|
||||
|
||||
dm_list_iterate_items(pvl, &pv->segments) {
|
||||
if (!(pvseg = dm_pool_zalloc(pv->vg->vgmem, sizeof(*pvseg)))) {
|
||||
log_errno(ENOMEM,
|
||||
"Memory allocation fail for lvm_pvseg_list.");
|
||||
return NULL;
|
||||
}
|
||||
pvseg->pvseg = pvl;
|
||||
dm_list_add(list, &pvseg->list);
|
||||
}
|
||||
|
||||
return list;
|
||||
}
|
||||
|
||||
struct dm_list *lvm_pv_list_pvsegs(pv_t pv)
|
||||
{
|
||||
struct dm_list *rc;
|
||||
struct saved_env e = store_user_env(pv->vg->cmd);
|
||||
rc = _lvm_pv_list_pvsegs(pv);
|
||||
restore_user_env(&e);
|
||||
return rc;
|
||||
}
|
||||
|
||||
pv_t lvm_pv_from_name(vg_t vg, const char *name)
|
||||
{
|
||||
pv_t rc = NULL;
|
||||
struct pv_list *pvl;
|
||||
struct saved_env e = store_user_env(vg->cmd);
|
||||
|
||||
dm_list_iterate_items(pvl, &vg->pvs)
|
||||
if (!strcmp(name, pv_dev_name(pvl->pv))) {
|
||||
rc = pvl->pv;
|
||||
break;
|
||||
}
|
||||
|
||||
restore_user_env(&e);
|
||||
return rc;
|
||||
}
|
||||
|
||||
static pv_t _lvm_pv_from_uuid(vg_t vg, const char *uuid)
|
||||
{
|
||||
struct pv_list *pvl;
|
||||
struct id id;
|
||||
|
||||
if (strlen(uuid) < ID_LEN) {
|
||||
log_errno (EINVAL, "Invalid UUID string length");
|
||||
return NULL;
|
||||
}
|
||||
|
||||
if (!id_read_format(&id, uuid)) {
|
||||
log_errno(EINVAL, "Invalid UUID format.");
|
||||
return NULL;
|
||||
}
|
||||
|
||||
dm_list_iterate_items(pvl, &vg->pvs)
|
||||
if (id_equal(&id, &pvl->pv->id))
|
||||
return pvl->pv;
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
||||
pv_t lvm_pv_from_uuid(vg_t vg, const char *uuid)
|
||||
{
|
||||
pv_t rc;
|
||||
struct saved_env e = store_user_env(vg->cmd);
|
||||
rc = _lvm_pv_from_uuid(vg, uuid);
|
||||
restore_user_env(&e);
|
||||
return rc;
|
||||
}
|
||||
|
||||
static int _lvm_pv_resize(const pv_t pv, uint64_t new_size)
|
||||
{
|
||||
uint64_t size = new_size >> SECTOR_SHIFT;
|
||||
|
||||
if (new_size % SECTOR_SIZE) {
|
||||
log_errno(EINVAL, "Size not a multiple of 512");
|
||||
return -1;
|
||||
}
|
||||
|
||||
if (!vg_check_write_mode(pv->vg))
|
||||
return -1;
|
||||
|
||||
if (!pv_resize_single(pv->vg->cmd, pv->vg, pv, size, 1)) {
|
||||
log_error("PV re-size failed!");
|
||||
return -1;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
int lvm_pv_resize(const pv_t pv, uint64_t new_size)
|
||||
{
|
||||
int rc;
|
||||
struct saved_env e = store_user_env(pv->vg->cmd);
|
||||
rc = _lvm_pv_resize(pv, new_size);
|
||||
restore_user_env(&e);
|
||||
return rc;
|
||||
}
|
||||
|
||||
/*
|
||||
* Common internal code to create a parameter passing object
|
||||
*/
|
||||
static struct lvm_pv_create_params *_lvm_pv_params_create(
|
||||
lvm_t libh,
|
||||
const char *pv_name,
|
||||
struct lvm_pv_create_params *pvcp_in)
|
||||
{
|
||||
struct lvm_pv_create_params *pvcp = NULL;
|
||||
const char *dev = NULL;
|
||||
struct cmd_context *cmd = (struct cmd_context *)libh;
|
||||
|
||||
if (!pv_name || strlen(pv_name) == 0) {
|
||||
log_error("Invalid pv_name");
|
||||
return NULL;
|
||||
}
|
||||
|
||||
if (!pvcp_in) {
|
||||
pvcp = dm_pool_zalloc(cmd->libmem, sizeof(struct lvm_pv_create_params));
|
||||
} else {
|
||||
pvcp = pvcp_in;
|
||||
}
|
||||
|
||||
if (!pvcp) {
|
||||
return NULL;
|
||||
}
|
||||
|
||||
dev = dm_pool_strdup(cmd->libmem, pv_name);
|
||||
if (!dev) {
|
||||
return NULL;
|
||||
}
|
||||
|
||||
pvcreate_params_set_defaults(&pvcp->pv_p);
|
||||
pvcp->pv_p.yes = 1;
|
||||
pvcp->pv_p.force = DONT_PROMPT;
|
||||
pvcp->pv_name = dev;
|
||||
pvcp->libh = libh;
|
||||
pvcp->magic = PV_CREATE_PARAMS_MAGIC;
|
||||
|
||||
return pvcp;
|
||||
}
|
||||
|
||||
pv_create_params_t lvm_pv_params_create(lvm_t libh, const char *pv_name)
|
||||
{
|
||||
pv_create_params_t rc;
|
||||
struct saved_env e = store_user_env((struct cmd_context *)libh);
|
||||
rc = _lvm_pv_params_create(libh, pv_name, NULL);
|
||||
restore_user_env(&e);
|
||||
return rc;
|
||||
}
|
||||
|
||||
struct lvm_property_value lvm_pv_params_get_property(
|
||||
const pv_create_params_t params,
|
||||
const char *name)
|
||||
{
|
||||
struct lvm_property_value rc = {
|
||||
.is_valid = 0
|
||||
};
|
||||
struct saved_env e;
|
||||
|
||||
if (params && params->magic == PV_CREATE_PARAMS_MAGIC) {
|
||||
e = store_user_env((struct cmd_context *)(params->libh));
|
||||
rc = get_property(NULL, NULL, NULL, NULL, NULL, NULL, ¶ms->pv_p,
|
||||
name);
|
||||
restore_user_env(&e);
|
||||
} else {
|
||||
log_error("Invalid pv_create_params parameter");
|
||||
}
|
||||
|
||||
return rc;
|
||||
}
|
||||
|
||||
int lvm_pv_params_set_property(pv_create_params_t params, const char *name,
|
||||
struct lvm_property_value *prop)
|
||||
{
|
||||
int rc = -1;
|
||||
struct saved_env e;
|
||||
|
||||
if (params && params->magic == PV_CREATE_PARAMS_MAGIC) {
|
||||
e = store_user_env((struct cmd_context *)(params->libh));
|
||||
rc = set_property(NULL, NULL, NULL, NULL, ¶ms->pv_p, name, prop);
|
||||
restore_user_env(&e);
|
||||
} else {
|
||||
log_error("Invalid pv_create_params parameter");
|
||||
}
|
||||
return rc;
|
||||
}
|
||||
|
||||
static int _pv_create(pv_create_params_t params)
|
||||
{
|
||||
struct cmd_context *cmd = (struct cmd_context *)params->libh;
|
||||
int rc = 0;
|
||||
|
||||
if (params->pv_p.pva.size) {
|
||||
if (params->pv_p.pva.size % SECTOR_SIZE) {
|
||||
log_errno(EINVAL, "Size not a multiple of 512");
|
||||
return -1;
|
||||
}
|
||||
params->pv_p.pva.size = params->pv_p.pva.size >> SECTOR_SHIFT;
|
||||
}
|
||||
|
||||
if (!lock_vol(cmd, VG_ORPHANS, LCK_VG_WRITE, NULL)) {
|
||||
log_errno(EINVAL, "Can't get lock for orphan PVs");
|
||||
return -1;
|
||||
}
|
||||
|
||||
if (!(pvcreate_vol(cmd, params->pv_name, ¶ms->pv_p, 1)))
|
||||
rc = -1;
|
||||
|
||||
unlock_vg(cmd, NULL, VG_ORPHANS);
|
||||
return rc;
|
||||
}
|
||||
|
||||
int lvm_pv_create(lvm_t libh, const char *pv_name, uint64_t size)
|
||||
{
|
||||
struct lvm_pv_create_params pp;
|
||||
int rc = -1;
|
||||
struct saved_env e = store_user_env((struct cmd_context *)libh);
|
||||
|
||||
if (_lvm_pv_params_create(libh, pv_name, &pp)) {
|
||||
pp.pv_p.pva.size = size;
|
||||
rc = _pv_create(&pp);
|
||||
}
|
||||
|
||||
restore_user_env(&e);
|
||||
return rc;
|
||||
}
|
||||
|
||||
int lvm_pv_create_adv(pv_create_params_t params)
|
||||
{
|
||||
int rc = -1;
|
||||
struct saved_env e;
|
||||
|
||||
if (params && params->magic == PV_CREATE_PARAMS_MAGIC) {
|
||||
e = store_user_env((struct cmd_context *)(params->libh));
|
||||
rc = _pv_create(params);
|
||||
restore_user_env(&e);
|
||||
} else {
|
||||
log_error("Invalid pv_create_params parameter");
|
||||
}
|
||||
|
||||
return rc;
|
||||
}
|
564
liblvm/lvm_vg.c
564
liblvm/lvm_vg.c
@ -1,564 +0,0 @@
|
||||
/*
|
||||
* Copyright (C) 2008-2013 Red Hat, Inc. All rights reserved.
|
||||
*
|
||||
* This file is part of LVM2.
|
||||
*
|
||||
* This copyrighted material is made available to anyone wishing to use,
|
||||
* modify, copy, or redistribute it subject to the terms and conditions
|
||||
* of the GNU Lesser General Public License v.2.1.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public License
|
||||
* along with this program; if not, write to the Free Software Foundation,
|
||||
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
*/
|
||||
|
||||
#include "lib/misc/lib.h"
|
||||
#include "lib/commands/toolcontext.h"
|
||||
#include "lib/metadata/metadata.h"
|
||||
#include "lib/format_text/archiver.h"
|
||||
#include "lib/locking/locking.h"
|
||||
#include "lib/cache/lvmcache.h"
|
||||
#include "lib/cache/lvmetad.h"
|
||||
#include "lvm_misc.h"
|
||||
#include "liblvm/lvm2app.h"
|
||||
#include "lib/display/display.h"
|
||||
#include "lib/cache/lvmetad.h"
|
||||
|
||||
int lvm_vg_add_tag(vg_t vg, const char *tag)
|
||||
{
|
||||
int rc = -1;
|
||||
struct saved_env e = store_user_env(vg->cmd);
|
||||
|
||||
if (!vg_read_error(vg) && vg_check_write_mode(vg) &&
|
||||
vg_change_tag(vg, tag, 1))
|
||||
rc = 0;
|
||||
restore_user_env(&e);
|
||||
return rc;
|
||||
}
|
||||
|
||||
|
||||
int lvm_vg_remove_tag(vg_t vg, const char *tag)
|
||||
{
|
||||
int rc = -1;
|
||||
struct saved_env e = store_user_env(vg->cmd);
|
||||
|
||||
if (!vg_read_error(vg) && vg_check_write_mode(vg) &&
|
||||
vg_change_tag(vg, tag, 0))
|
||||
rc = 0;
|
||||
restore_user_env(&e);
|
||||
return rc;
|
||||
}
|
||||
|
||||
|
||||
vg_t lvm_vg_create(lvm_t libh, const char *vg_name)
|
||||
{
|
||||
struct volume_group *vg = NULL;
|
||||
struct saved_env e = store_user_env((struct cmd_context *)libh);
|
||||
|
||||
vg = vg_lock_and_create((struct cmd_context *)libh, vg_name);
|
||||
/* FIXME: error handling is still TBD */
|
||||
if (vg_read_error(vg)) {
|
||||
release_vg(vg);
|
||||
vg = NULL;
|
||||
} else {
|
||||
vg->open_mode = 'w';
|
||||
}
|
||||
|
||||
restore_user_env(&e);
|
||||
return (vg_t) vg;
|
||||
}
|
||||
|
||||
static int _lvm_vg_extend(vg_t vg, const char *device)
|
||||
{
|
||||
struct pvcreate_params pp;
|
||||
|
||||
if (vg_read_error(vg))
|
||||
return -1;
|
||||
|
||||
if (!vg_check_write_mode(vg))
|
||||
return -1;
|
||||
|
||||
if (!lock_vol(vg->cmd, VG_ORPHANS, LCK_VG_WRITE, NULL)) {
|
||||
log_error("Can't get lock for orphan PVs");
|
||||
return -1;
|
||||
}
|
||||
|
||||
pvcreate_params_set_defaults(&pp);
|
||||
if (!vg_extend(vg, 1, &device, &pp)) {
|
||||
unlock_vg(vg->cmd, NULL, VG_ORPHANS);
|
||||
return -1;
|
||||
}
|
||||
/*
|
||||
* FIXME: Either commit to disk, or keep holding VG_ORPHANS and
|
||||
* release in lvm_vg_close().
|
||||
*/
|
||||
unlock_vg(vg->cmd, NULL, VG_ORPHANS);
|
||||
return 0;
|
||||
}
|
||||
|
||||
int lvm_vg_extend(vg_t vg, const char *device)
|
||||
{
|
||||
int rc = 0;
|
||||
struct saved_env e = store_user_env(vg->cmd);
|
||||
rc = _lvm_vg_extend(vg, device);
|
||||
restore_user_env(&e);
|
||||
return rc;
|
||||
}
|
||||
|
||||
int lvm_vg_reduce(vg_t vg, const char *device)
|
||||
{
|
||||
int rc = -1;
|
||||
struct saved_env e = store_user_env(vg->cmd);
|
||||
|
||||
if (!vg_read_error(vg) && vg_check_write_mode(vg) && vg_reduce(vg, device))
|
||||
rc = 0;
|
||||
|
||||
restore_user_env(&e);
|
||||
return rc;
|
||||
}
|
||||
|
||||
int lvm_vg_set_extent_size(vg_t vg, uint32_t new_size)
|
||||
{
|
||||
int rc = -1;
|
||||
struct saved_env e = store_user_env(vg->cmd);
|
||||
|
||||
if (!vg_read_error(vg) && vg_check_write_mode(vg) &&
|
||||
vg_set_extent_size(vg, new_size / SECTOR_SIZE))
|
||||
rc = 0;
|
||||
|
||||
restore_user_env(&e);
|
||||
return rc;
|
||||
}
|
||||
|
||||
static int _lvm_vg_write(vg_t vg)
|
||||
{
|
||||
struct pv_list *pvl;
|
||||
|
||||
if (vg_read_error(vg))
|
||||
return -1;
|
||||
if (!vg_check_write_mode(vg))
|
||||
return -1;
|
||||
|
||||
if (dm_list_empty(&vg->pvs)) {
|
||||
if (!vg_remove(vg))
|
||||
return -1;
|
||||
return 0;
|
||||
}
|
||||
|
||||
if (! dm_list_empty(&vg->removed_pvs)) {
|
||||
if (!lock_vol(vg->cmd, VG_ORPHANS, LCK_VG_WRITE, NULL)) {
|
||||
log_error("Can't get lock for orphan PVs");
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
if (!archive(vg))
|
||||
return -1;
|
||||
|
||||
/* Store VG on disk(s) */
|
||||
if (!vg_write(vg) || !vg_commit(vg))
|
||||
return -1;
|
||||
|
||||
if (! dm_list_empty(&vg->removed_pvs)) {
|
||||
dm_list_iterate_items(pvl, &vg->removed_pvs) {
|
||||
pv_write_orphan(vg->cmd, pvl->pv);
|
||||
pv_set_fid(pvl->pv, NULL);
|
||||
/* FIXME: do pvremove / label_remove()? */
|
||||
}
|
||||
dm_list_init(&vg->removed_pvs);
|
||||
unlock_vg(vg->cmd, NULL, VG_ORPHANS);
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
int lvm_vg_write(vg_t vg)
|
||||
{
|
||||
int rc;
|
||||
struct saved_env e = store_user_env(vg->cmd);
|
||||
rc = _lvm_vg_write(vg);
|
||||
restore_user_env(&e);
|
||||
return rc;
|
||||
}
|
||||
|
||||
int lvm_vg_close(vg_t vg)
|
||||
{
|
||||
struct saved_env e = store_user_env(vg->cmd);
|
||||
if (vg_read_error(vg) == FAILED_LOCKING)
|
||||
release_vg(vg);
|
||||
else if (!lvmcache_vgname_is_locked(vg->name))
|
||||
release_vg(vg);
|
||||
else
|
||||
unlock_and_release_vg(vg->cmd, vg, vg->name);
|
||||
restore_user_env(&e);
|
||||
return 0;
|
||||
}
|
||||
|
||||
int lvm_vg_remove(vg_t vg)
|
||||
{
|
||||
int rc = -1;
|
||||
struct saved_env e = store_user_env(vg->cmd);
|
||||
|
||||
if (!vg_read_error(vg) && vg_check_write_mode(vg) && vg_remove_check(vg)) {
|
||||
vg_remove_pvs(vg);
|
||||
rc = 0;
|
||||
}
|
||||
|
||||
restore_user_env(&e);
|
||||
return rc;
|
||||
}
|
||||
|
||||
static vg_t _lvm_vg_open(lvm_t libh, const char *vgname, const char *mode,
|
||||
uint32_t flags)
|
||||
{
|
||||
uint32_t internal_flags = 0;
|
||||
struct volume_group *vg;
|
||||
|
||||
if (!strncmp(mode, "w", 1))
|
||||
internal_flags |= READ_FOR_UPDATE;
|
||||
else if (strncmp(mode, "r", 1)) {
|
||||
log_errno(EINVAL, "Invalid VG open mode");
|
||||
return NULL;
|
||||
}
|
||||
|
||||
lvmcache_label_scan((struct cmd_context *)libh);
|
||||
|
||||
vg = vg_read((struct cmd_context *)libh, vgname, NULL, internal_flags, 0);
|
||||
if (vg_read_error(vg)) {
|
||||
/* FIXME: use log_errno either here in inside vg_read */
|
||||
release_vg(vg);
|
||||
return NULL;
|
||||
}
|
||||
/* FIXME: combine this with locking ? */
|
||||
vg->open_mode = mode[0];
|
||||
|
||||
return (vg_t) vg;
|
||||
}
|
||||
|
||||
vg_t lvm_vg_open(lvm_t libh, const char *vgname, const char *mode,
|
||||
uint32_t flags)
|
||||
{
|
||||
vg_t rc;
|
||||
struct saved_env e = store_user_env((struct cmd_context*)libh);
|
||||
rc = _lvm_vg_open(libh, vgname, mode, flags);
|
||||
restore_user_env(&e);
|
||||
return rc;
|
||||
}
|
||||
|
||||
static struct dm_list *_lvm_vg_list_pvs(vg_t vg)
|
||||
{
|
||||
struct dm_list *list;
|
||||
pv_list_t *pvs;
|
||||
struct pv_list *pvl;
|
||||
|
||||
if (dm_list_empty(&vg->pvs))
|
||||
return NULL;
|
||||
|
||||
if (!(list = dm_pool_zalloc(vg->vgmem, sizeof(*list)))) {
|
||||
log_errno(ENOMEM, "Memory allocation fail for dm_list.");
|
||||
return NULL;
|
||||
}
|
||||
dm_list_init(list);
|
||||
|
||||
dm_list_iterate_items(pvl, &vg->pvs) {
|
||||
if (!(pvs = dm_pool_zalloc(vg->vgmem, sizeof(*pvs)))) {
|
||||
log_errno(ENOMEM,
|
||||
"Memory allocation fail for lvm_pv_list.");
|
||||
return NULL;
|
||||
}
|
||||
pvs->pv = pvl->pv;
|
||||
dm_list_add(list, &pvs->list);
|
||||
}
|
||||
return list;
|
||||
}
|
||||
|
||||
struct dm_list *lvm_vg_list_pvs(vg_t vg)
|
||||
{
|
||||
struct dm_list *rc;
|
||||
struct saved_env e = store_user_env(vg->cmd);
|
||||
rc = _lvm_vg_list_pvs(vg);
|
||||
restore_user_env(&e);
|
||||
return rc;
|
||||
}
|
||||
|
||||
static struct dm_list *_lvm_vg_list_lvs(vg_t vg)
|
||||
{
|
||||
struct dm_list *list;
|
||||
lv_list_t *lvs;
|
||||
struct lv_list *lvl;
|
||||
|
||||
if (dm_list_empty(&vg->lvs))
|
||||
return NULL;
|
||||
|
||||
if (!(list = dm_pool_zalloc(vg->vgmem, sizeof(*list)))) {
|
||||
log_errno(ENOMEM, "Memory allocation fail for dm_list.");
|
||||
return NULL;
|
||||
}
|
||||
dm_list_init(list);
|
||||
|
||||
dm_list_iterate_items(lvl, &vg->lvs) {
|
||||
if (!(lvs = dm_pool_zalloc(vg->vgmem, sizeof(*lvs)))) {
|
||||
log_errno(ENOMEM,
|
||||
"Memory allocation fail for lvm_lv_list.");
|
||||
return NULL;
|
||||
}
|
||||
lvs->lv = lvl->lv;
|
||||
dm_list_add(list, &lvs->list);
|
||||
}
|
||||
return list;
|
||||
}
|
||||
|
||||
struct dm_list *lvm_vg_list_lvs(vg_t vg)
|
||||
{
|
||||
struct dm_list *rc;
|
||||
struct saved_env e = store_user_env(vg->cmd);
|
||||
rc = _lvm_vg_list_lvs(vg);
|
||||
restore_user_env(&e);
|
||||
return rc;
|
||||
}
|
||||
|
||||
struct dm_list *lvm_vg_get_tags(const vg_t vg)
|
||||
{
|
||||
struct dm_list *rc;
|
||||
struct saved_env e = store_user_env(vg->cmd);
|
||||
rc = tag_list_copy(vg->vgmem, &vg->tags);
|
||||
restore_user_env(&e);
|
||||
return rc;
|
||||
}
|
||||
|
||||
uint64_t lvm_vg_get_seqno(const vg_t vg)
|
||||
{
|
||||
uint64_t rc;
|
||||
struct saved_env e = store_user_env(vg->cmd);
|
||||
rc = vg_seqno(vg);
|
||||
restore_user_env(&e);
|
||||
return rc;
|
||||
}
|
||||
|
||||
uint64_t lvm_vg_is_clustered(const vg_t vg)
|
||||
{
|
||||
uint64_t rc;
|
||||
struct saved_env e = store_user_env(vg->cmd);
|
||||
rc = vg_is_clustered(vg);
|
||||
restore_user_env(&e);
|
||||
return rc;
|
||||
}
|
||||
|
||||
uint64_t lvm_vg_is_exported(const vg_t vg)
|
||||
{
|
||||
uint64_t rc;
|
||||
struct saved_env e = store_user_env(vg->cmd);
|
||||
rc = vg_is_exported(vg);
|
||||
restore_user_env(&e);
|
||||
return rc;
|
||||
}
|
||||
|
||||
uint64_t lvm_vg_is_partial(const vg_t vg)
|
||||
{
|
||||
uint64_t rc;
|
||||
struct saved_env e = store_user_env(vg->cmd);
|
||||
rc = (vg_missing_pv_count(vg) != 0);
|
||||
restore_user_env(&e);
|
||||
return rc;
|
||||
}
|
||||
|
||||
/* FIXME: invalid handle? return INTMAX? */
|
||||
uint64_t lvm_vg_get_size(const vg_t vg)
|
||||
{
|
||||
uint64_t rc;
|
||||
struct saved_env e = store_user_env(vg->cmd);
|
||||
rc = SECTOR_SIZE * vg_size(vg);
|
||||
restore_user_env(&e);
|
||||
return rc;
|
||||
}
|
||||
|
||||
uint64_t lvm_vg_get_free_size(const vg_t vg)
|
||||
{
|
||||
uint64_t rc;
|
||||
struct saved_env e = store_user_env(vg->cmd);
|
||||
rc = SECTOR_SIZE * vg_free(vg);
|
||||
restore_user_env(&e);
|
||||
return rc;
|
||||
}
|
||||
|
||||
uint64_t lvm_vg_get_extent_size(const vg_t vg)
|
||||
{
|
||||
uint64_t rc;
|
||||
struct saved_env e = store_user_env(vg->cmd);
|
||||
rc = SECTOR_SIZE * vg_extent_size(vg);
|
||||
restore_user_env(&e);
|
||||
return rc;
|
||||
}
|
||||
|
||||
uint64_t lvm_vg_get_extent_count(const vg_t vg)
|
||||
{
|
||||
uint64_t rc;
|
||||
struct saved_env e = store_user_env(vg->cmd);
|
||||
rc = vg_extent_count(vg);
|
||||
restore_user_env(&e);
|
||||
return rc;
|
||||
}
|
||||
|
||||
uint64_t lvm_vg_get_free_extent_count(const vg_t vg)
|
||||
{
|
||||
uint64_t rc;
|
||||
struct saved_env e = store_user_env(vg->cmd);
|
||||
rc = vg_free_count(vg);
|
||||
restore_user_env(&e);
|
||||
return rc;
|
||||
}
|
||||
|
||||
uint64_t lvm_vg_get_pv_count(const vg_t vg)
|
||||
{
|
||||
uint64_t rc;
|
||||
struct saved_env e = store_user_env(vg->cmd);
|
||||
rc = vg_pv_count(vg);
|
||||
restore_user_env(&e);
|
||||
return rc;
|
||||
}
|
||||
|
||||
uint64_t lvm_vg_get_max_pv(const vg_t vg)
|
||||
{
|
||||
uint64_t rc;
|
||||
struct saved_env e = store_user_env(vg->cmd);
|
||||
rc = vg_max_pv(vg);
|
||||
restore_user_env(&e);
|
||||
return rc;
|
||||
}
|
||||
|
||||
uint64_t lvm_vg_get_max_lv(const vg_t vg)
|
||||
{
|
||||
uint64_t rc;
|
||||
struct saved_env e = store_user_env(vg->cmd);
|
||||
rc = vg_max_lv(vg);
|
||||
restore_user_env(&e);
|
||||
return rc;
|
||||
}
|
||||
|
||||
const char *lvm_vg_get_uuid(const vg_t vg)
|
||||
{
|
||||
const char *rc;
|
||||
struct saved_env e = store_user_env(vg->cmd);
|
||||
rc = vg_uuid_dup(vg);
|
||||
restore_user_env(&e);
|
||||
return rc;
|
||||
}
|
||||
|
||||
const char *lvm_vg_get_name(const vg_t vg)
|
||||
{
|
||||
const char *rc;
|
||||
struct saved_env e = store_user_env(vg->cmd);
|
||||
rc = dm_pool_strndup(vg->vgmem, vg->name, NAME_LEN+1);
|
||||
restore_user_env(&e);
|
||||
return rc;
|
||||
}
|
||||
|
||||
|
||||
struct lvm_property_value lvm_vg_get_property(const vg_t vg, const char *name)
|
||||
{
|
||||
struct lvm_property_value rc;
|
||||
struct saved_env e = store_user_env(vg->cmd);
|
||||
rc = get_property(NULL, vg, NULL, NULL, NULL, NULL, NULL, name);
|
||||
restore_user_env(&e);
|
||||
return rc;
|
||||
}
|
||||
|
||||
int lvm_vg_set_property(const vg_t vg, const char *name,
|
||||
struct lvm_property_value *value)
|
||||
{
|
||||
/* At this point it is unknown if all property set paths make the
|
||||
* appropriate copy of the string. We will allocate a copy on the vg so
|
||||
* that worst case we have two copies which will get freed when the vg gets
|
||||
* released.
|
||||
*/
|
||||
int rc;
|
||||
struct saved_env e = store_user_env(vg->cmd);
|
||||
|
||||
if (value->is_valid && value->is_string && value->value.string) {
|
||||
value->value.string = dm_pool_strndup(vg->vgmem, value->value.string,
|
||||
strlen(value->value.string) + 1);
|
||||
}
|
||||
|
||||
rc = set_property(NULL, vg, NULL, NULL, NULL, name, value);
|
||||
restore_user_env(&e);
|
||||
return rc;
|
||||
}
|
||||
|
||||
struct dm_list *lvm_list_vg_names(lvm_t libh)
|
||||
{
|
||||
struct dm_list *rc = NULL;
|
||||
struct saved_env e = store_user_env((struct cmd_context *)libh);
|
||||
|
||||
if (lvmetad_vg_list_to_lvmcache((struct cmd_context *)libh)) {
|
||||
rc = get_vgnames((struct cmd_context *)libh, 0);
|
||||
}
|
||||
restore_user_env(&e);
|
||||
return rc;
|
||||
}
|
||||
|
||||
struct dm_list *lvm_list_vg_uuids(lvm_t libh)
|
||||
{
|
||||
struct dm_list *rc = NULL;
|
||||
struct saved_env e = store_user_env((struct cmd_context *)libh);
|
||||
|
||||
if (lvmetad_vg_list_to_lvmcache((struct cmd_context *)libh)) {
|
||||
rc = get_vgids((struct cmd_context *)libh, 0);
|
||||
}
|
||||
restore_user_env(&e);
|
||||
return rc;
|
||||
}
|
||||
|
||||
/*
|
||||
* FIXME: Elaborate on when to use, side-effects, .cache file, etc
|
||||
*/
|
||||
int lvm_scan(lvm_t libh)
|
||||
{
|
||||
int rc = 0;
|
||||
struct saved_env e = store_user_env((struct cmd_context *)libh);
|
||||
|
||||
if (!lvmcache_label_scan((struct cmd_context *)libh))
|
||||
rc = -1;
|
||||
|
||||
restore_user_env(&e);
|
||||
return rc;
|
||||
}
|
||||
|
||||
int lvm_lv_name_validate(const vg_t vg, const char *name)
|
||||
{
|
||||
int rc = -1;
|
||||
name_error_t name_error;
|
||||
int historical;
|
||||
|
||||
struct saved_env e = store_user_env(vg->cmd);
|
||||
|
||||
name_error = validate_name_detailed(name);
|
||||
|
||||
if (NAME_VALID == name_error) {
|
||||
if (apply_lvname_restrictions(name)) {
|
||||
if (!lv_name_is_used_in_vg(vg, name, &historical)) {
|
||||
rc = 0;
|
||||
} else {
|
||||
log_errno(EINVAL, "%sLV name exists in VG",
|
||||
historical ? "historical " : "");
|
||||
}
|
||||
}
|
||||
} else {
|
||||
display_name_error(name_error);
|
||||
}
|
||||
|
||||
restore_user_env(&e);
|
||||
return rc;
|
||||
}
|
||||
|
||||
int lvm_vg_name_validate(lvm_t libh, const char *name)
|
||||
{
|
||||
int rc = -1;
|
||||
struct cmd_context *cmd = (struct cmd_context *)libh;
|
||||
struct saved_env e = store_user_env(cmd);
|
||||
|
||||
if (validate_new_vg_name(cmd, name))
|
||||
rc = 0;
|
||||
|
||||
restore_user_env(&e);
|
||||
return rc;
|
||||
}
|
@ -1,90 +0,0 @@
|
||||
/*
|
||||
* Copyright (C) 2009 Red Hat, Inc. All rights reserved.
|
||||
*
|
||||
* This file is part of LVM2.
|
||||
*
|
||||
* This copyrighted material is made available to anyone wishing to use,
|
||||
* modify, copy, or redistribute it subject to the terms and conditions
|
||||
* of the GNU Lesser General Public License v.2.1.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public License
|
||||
* along with this program; if not, write to the Free Software Foundation,
|
||||
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
*/
|
||||
|
||||
#include <stdio.h>
|
||||
#include <unistd.h>
|
||||
#include <inttypes.h>
|
||||
#include <assert.h>
|
||||
|
||||
#include "lvm2app.h"
|
||||
|
||||
int main(int argc, char *argv[])
|
||||
{
|
||||
char *vgname = NULL;
|
||||
lvm_t handle;
|
||||
vg_t vg;
|
||||
lv_t lv;
|
||||
lvm_str_list_t *sl;
|
||||
pv_list_t *pvl;
|
||||
lv_list_t *lvl;
|
||||
struct dm_list *vgnames;
|
||||
struct dm_list *vgids;
|
||||
struct dm_list *pvlist;
|
||||
struct dm_list *lvlist;
|
||||
int added = 0;
|
||||
int ret;
|
||||
int i;
|
||||
|
||||
vgname = argv[1];
|
||||
|
||||
handle = lvm_init(NULL);
|
||||
if (!handle) {
|
||||
printf("lvm_init failed\n");
|
||||
return -1;
|
||||
}
|
||||
|
||||
vg = lvm_vg_create(handle, vgname);
|
||||
|
||||
for (i = 2; i < argc; i++) {
|
||||
printf("adding %s to vg\n", argv[i]);
|
||||
ret = lvm_vg_extend(vg, argv[i]);
|
||||
|
||||
if (ret) {
|
||||
printf("Failed to add %s to vg\n", argv[i]);
|
||||
goto out;
|
||||
}
|
||||
|
||||
added++;
|
||||
}
|
||||
|
||||
if (!added) {
|
||||
printf("No PVs added, not writing VG.\n");
|
||||
goto out;
|
||||
}
|
||||
|
||||
printf("writing vg\n");
|
||||
ret = lvm_vg_write(vg);
|
||||
|
||||
lvm_vg_close(vg);
|
||||
|
||||
sleep(1);
|
||||
|
||||
vg = lvm_vg_open(handle, vgname, "w", 0);
|
||||
if (!vg) {
|
||||
printf("vg open %s failed\n", vgname);
|
||||
goto out;
|
||||
}
|
||||
|
||||
lv = lvm_vg_create_lv_linear(vg, "lv0", 1024*1024);
|
||||
if (!lv) {
|
||||
printf("lv create failed\n");
|
||||
goto out;
|
||||
}
|
||||
|
||||
lvm_vg_close(vg);
|
||||
out:
|
||||
lvm_quit(handle);
|
||||
|
||||
return 0;
|
||||
}
|
@ -1,95 +0,0 @@
|
||||
/*
|
||||
* Copyright (C) 2009 Red Hat, Inc. All rights reserved.
|
||||
*
|
||||
* This file is part of LVM2.
|
||||
*
|
||||
* This copyrighted material is made available to anyone wishing to use,
|
||||
* modify, copy, or redistribute it subject to the terms and conditions
|
||||
* of the GNU Lesser General Public License v.2.1.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public License
|
||||
* along with this program; if not, write to the Free Software Foundation,
|
||||
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
*/
|
||||
|
||||
#include <stdio.h>
|
||||
#include <unistd.h>
|
||||
#include <inttypes.h>
|
||||
#include <assert.h>
|
||||
|
||||
#include "lvm2app.h"
|
||||
|
||||
int main(int argc, char *argv[])
|
||||
{
|
||||
char *vgname = NULL;
|
||||
lvm_t handle;
|
||||
vg_t vg;
|
||||
lvm_str_list_t *sl;
|
||||
pv_list_t *pvl;
|
||||
lv_list_t *lvl;
|
||||
struct dm_list *vgnames;
|
||||
struct dm_list *vgids;
|
||||
struct dm_list *pvlist;
|
||||
struct dm_list *lvlist;
|
||||
uint64_t val;
|
||||
|
||||
vgname = argv[1];
|
||||
|
||||
handle = lvm_init(NULL);
|
||||
if (!handle) {
|
||||
printf("lvm_init failed\n");
|
||||
return -1;
|
||||
}
|
||||
|
||||
vgnames = lvm_list_vg_names(handle);
|
||||
|
||||
dm_list_iterate_items(sl, vgnames)
|
||||
printf("vg name %s\n", sl->str);
|
||||
|
||||
vgids = lvm_list_vg_uuids(handle);
|
||||
|
||||
dm_list_iterate_items(sl, vgids)
|
||||
printf("vg uuid %s\n", sl->str);
|
||||
|
||||
if (!vgname) {
|
||||
printf("No vg name arg\n");
|
||||
goto out;
|
||||
}
|
||||
|
||||
vg = lvm_vg_open(handle, vgname, "r", 0);
|
||||
|
||||
if (!vg) {
|
||||
printf("vg open %s failed\n", vgname);
|
||||
goto out;
|
||||
}
|
||||
|
||||
val = lvm_vg_get_seqno(vg);
|
||||
|
||||
printf("vg seqno %llu\n", (unsigned long long)val);
|
||||
|
||||
pvlist = lvm_vg_list_pvs(vg);
|
||||
|
||||
dm_list_iterate_items(pvl, pvlist) {
|
||||
printf("vg pv name %s\n", lvm_pv_get_name(pvl->pv));
|
||||
|
||||
val = lvm_pv_get_dev_size(pvl->pv);
|
||||
|
||||
printf("vg pv size %llu\n", (unsigned long long)val);
|
||||
}
|
||||
|
||||
lvlist = lvm_vg_list_lvs(vg);
|
||||
|
||||
dm_list_iterate_items(lvl, lvlist) {
|
||||
printf("vg lv name %s\n", lvm_lv_get_name(lvl->lv));
|
||||
|
||||
val = lvm_lv_get_size(lvl->lv);
|
||||
|
||||
printf("vg lv size %llu\n", (unsigned long long)val);
|
||||
}
|
||||
|
||||
lvm_vg_close(vg);
|
||||
out:
|
||||
lvm_quit(handle);
|
||||
|
||||
return 0;
|
||||
}
|
@ -16,47 +16,14 @@ top_srcdir = @top_srcdir@
|
||||
top_builddir = @top_builddir@
|
||||
|
||||
TARGETS =
|
||||
ifeq ("@APPLIB@", "yes")
|
||||
TARGETS += test
|
||||
SOURCES = test.c
|
||||
|
||||
TARGETS += \
|
||||
lvtest.t \
|
||||
vglist.t \
|
||||
percent.t \
|
||||
pe_start.t \
|
||||
thin_percent.t \
|
||||
vgtest.t
|
||||
|
||||
SOURCES2 = \
|
||||
lvtest.c \
|
||||
vglist.c \
|
||||
percent.c \
|
||||
pe_start.c \
|
||||
thin_percent.c \
|
||||
vgtest.c
|
||||
|
||||
endif
|
||||
|
||||
PYTEST = python_lvm_unit.py
|
||||
|
||||
include $(top_builddir)/make.tmpl
|
||||
|
||||
DEFS += -D_REENTRANT
|
||||
DEPLIBS += $(top_builddir)/liblvm/liblvm2app.so
|
||||
LDFLAGS+=\
|
||||
-L$(top_builddir)/liblvm \
|
||||
-L$(top_builddir)/daemons/dmeventd
|
||||
LIBS += @LVM2APP_LIB@ $(DMEVENT_LIBS)
|
||||
|
||||
%.t: %.o $(DEPLIBS)
|
||||
$(CC) -o $@ $(<) $(CFLAGS) $(LDFLAGS) $(ELDFLAGS) $(LIBS)
|
||||
|
||||
all:
|
||||
test -x $(PYTEST) || chmod 755 $(PYTEST)
|
||||
|
||||
test: $(OBJECTS) $(DEPLIBS)
|
||||
$(CC) -o $@ $(OBJECTS) $(CFLAGS) $(LDFLAGS) $(ELDFLAGS) $(LIBS) $(READLINE_LIBS)
|
||||
|
||||
Makefile: $(srcdir)/Makefile.in $(top_builddir)/config.status
|
||||
cd $(top_builddir) && $(SHELL) ./config.status test/api/Makefile
|
||||
|
@ -1,64 +0,0 @@
|
||||
/*
|
||||
* Copyright (C) 2010 Red Hat, Inc. All rights reserved.
|
||||
*
|
||||
* This file is part of LVM2.
|
||||
*
|
||||
* This copyrighted material is made available to anyone wishing to use,
|
||||
* modify, copy, or redistribute it subject to the terms and conditions
|
||||
* of the GNU Lesser General Public License v.2.1.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public License
|
||||
* along with this program; if not, write to the Free Software Foundation,
|
||||
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
*/
|
||||
|
||||
#undef NDEBUG
|
||||
|
||||
#include "liblvm/lvm2app.h"
|
||||
#include "assert.h"
|
||||
|
||||
#define err(args...) \
|
||||
do { fprintf(stderr, args); goto bad; } while (0)
|
||||
|
||||
int main(int argc, char *argv[])
|
||||
{
|
||||
lvm_t handle;
|
||||
vg_t vg;
|
||||
lv_t lv;
|
||||
int r = -1;
|
||||
|
||||
if (!(handle = lvm_init(NULL)))
|
||||
return -1;
|
||||
|
||||
if (!(vg = lvm_vg_open(handle, argv[1], "w", 0)))
|
||||
err("VG open %s failed.\n", argv[1]);
|
||||
|
||||
if (!(lv = lvm_lv_from_name(vg, "test")))
|
||||
err("LV test not found.\n");
|
||||
|
||||
if (lvm_lv_deactivate(lv))
|
||||
err("LV test deactivation failed.\n");
|
||||
|
||||
if (lvm_lv_activate(lv))
|
||||
err("LV test activation failed.\n");
|
||||
|
||||
if (lvm_lv_activate(lv))
|
||||
err("LV test repeated activation failed.\n");
|
||||
|
||||
if (lvm_lv_rename(lv, "test1"))
|
||||
err("LV test rename to test1 failed.\n");
|
||||
|
||||
if (lvm_lv_rename(lv, "test2"))
|
||||
err("LV test1 rename to test2 failed.\n");
|
||||
|
||||
if (lvm_lv_rename(lv, "test"))
|
||||
err("LV test2 rename to test failed.\n");
|
||||
|
||||
if (lvm_vg_close(vg))
|
||||
err("VG close failed.\n");
|
||||
|
||||
r = 0;
|
||||
bad:
|
||||
lvm_quit(handle);
|
||||
return r;
|
||||
}
|
@ -1,47 +0,0 @@
|
||||
/*
|
||||
* Copyright (C) 2011 Red Hat, Inc. All rights reserved.
|
||||
*
|
||||
* This file is part of LVM2.
|
||||
*
|
||||
* This copyrighted material is made available to anyone wishing to use,
|
||||
* modify, copy, or redistribute it subject to the terms and conditions
|
||||
* of the GNU Lesser General Public License v.2.1.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public License
|
||||
* along with this program; if not, write to the Free Software Foundation,
|
||||
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
*/
|
||||
|
||||
#undef NDEBUG
|
||||
|
||||
#include "liblvm/lvm2app.h"
|
||||
#include "assert.h"
|
||||
|
||||
int main(int argc, char *argv[])
|
||||
{
|
||||
lvm_t handle;
|
||||
vg_t vg = NULL;
|
||||
pv_t pv;
|
||||
struct lvm_property_value v;
|
||||
|
||||
handle = lvm_init(NULL);
|
||||
assert(handle);
|
||||
|
||||
vg = lvm_vg_create(handle, argv[1]);
|
||||
assert(vg);
|
||||
|
||||
if (lvm_vg_extend(vg, argv[2]))
|
||||
abort();
|
||||
|
||||
pv = lvm_pv_from_name(vg, argv[2]);
|
||||
assert(pv);
|
||||
|
||||
v = lvm_pv_get_property(pv, "pe_start");
|
||||
assert(v.is_valid);
|
||||
fprintf(stderr, "pe_start = %d\n", (int)v.value.integer);
|
||||
assert(v.value.integer == 2048 * 512);
|
||||
|
||||
lvm_vg_close(vg);
|
||||
lvm_quit(handle);
|
||||
return 0;
|
||||
}
|
@ -1,63 +0,0 @@
|
||||
/*
|
||||
* Copyright (C) 2010 Red Hat, Inc. All rights reserved.
|
||||
*
|
||||
* This file is part of LVM2.
|
||||
*
|
||||
* This copyrighted material is made available to anyone wishing to use,
|
||||
* modify, copy, or redistribute it subject to the terms and conditions
|
||||
* of the GNU Lesser General Public License v.2.1.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public License
|
||||
* along with this program; if not, write to the Free Software Foundation,
|
||||
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
*/
|
||||
|
||||
#undef NDEBUG
|
||||
|
||||
#include "liblvm/lvm2app.h"
|
||||
#include "assert.h"
|
||||
|
||||
int main(int argc, char *argv[])
|
||||
{
|
||||
lvm_t handle;
|
||||
vg_t vg = NULL;
|
||||
lv_t lv;
|
||||
struct lvm_property_value v;
|
||||
struct lvm_property_value d;
|
||||
|
||||
handle = lvm_init(NULL);
|
||||
assert(handle);
|
||||
|
||||
vg = lvm_vg_open(handle, argv[1], "r", 0);
|
||||
assert(vg);
|
||||
|
||||
lv = lvm_lv_from_name(vg, "snap");
|
||||
assert(lv);
|
||||
|
||||
v = lvm_lv_get_property(lv, "snap_percent");
|
||||
assert(v.is_valid);
|
||||
assert(v.value.integer == PERCENT_0);
|
||||
|
||||
lv = lvm_lv_from_name(vg, "mirr");
|
||||
assert(lv);
|
||||
|
||||
v = lvm_lv_get_property(lv, "copy_percent");
|
||||
assert(v.is_valid);
|
||||
assert(v.value.integer == PERCENT_100);
|
||||
|
||||
lv = lvm_lv_from_name(vg, "snap2");
|
||||
assert(lv);
|
||||
|
||||
v = lvm_lv_get_property(lv, "snap_percent");
|
||||
assert(v.is_valid);
|
||||
assert(v.value.integer == 50 * PERCENT_1);
|
||||
|
||||
d = lvm_lv_get_property(lv, "data_percent");
|
||||
assert(d.is_valid);
|
||||
assert(d.value.integer == v.value.integer);
|
||||
|
||||
lvm_vg_close(vg);
|
||||
|
||||
lvm_quit(handle);
|
||||
return 0;
|
||||
}
|
1110
test/api/test.c
1110
test/api/test.c
File diff suppressed because it is too large
Load Diff
@ -1,78 +0,0 @@
|
||||
/*
|
||||
* Copyright (C) 2012 Red Hat, Inc. All rights reserved.
|
||||
*
|
||||
* This file is part of LVM2.
|
||||
*
|
||||
* This copyrighted material is made available to anyone wishing to use,
|
||||
* modify, copy, or redistribute it subject to the terms and conditions
|
||||
* of the GNU Lesser General Public License v.2.1.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public License
|
||||
* along with this program; if not, write to the Free Software Foundation,
|
||||
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
*/
|
||||
|
||||
#undef NDEBUG
|
||||
|
||||
#include "liblvm/lvm2app.h"
|
||||
#include "assert.h"
|
||||
|
||||
int main(int argc, char *argv[])
|
||||
{
|
||||
lvm_t handle;
|
||||
vg_t vg;
|
||||
lv_t lv;
|
||||
struct lvm_property_value v;
|
||||
struct dm_list *lvsegs;
|
||||
struct lvm_lvseg_list *lvl;
|
||||
|
||||
handle = lvm_init(NULL);
|
||||
assert(handle);
|
||||
|
||||
vg = lvm_vg_open(handle, argv[1], "r", 0);
|
||||
assert(vg);
|
||||
|
||||
lv = lvm_lv_from_name(vg, "pool");
|
||||
assert(lv);
|
||||
|
||||
lvsegs = lvm_lv_list_lvsegs(lv);
|
||||
assert(lvsegs && (dm_list_size(lvsegs) == 1));
|
||||
dm_list_iterate_items(lvl, lvsegs) {
|
||||
v = lvm_lvseg_get_property(lvl->lvseg, "discards");
|
||||
assert(v.is_valid && v.is_string);
|
||||
assert(strcmp(v.value.string, "passdown") == 0);
|
||||
}
|
||||
|
||||
v = lvm_lv_get_property(lv, "data_percent");
|
||||
assert(v.is_valid);
|
||||
assert(v.value.integer == 25 * PERCENT_1);
|
||||
|
||||
|
||||
lv = lvm_lv_from_name(vg, "thin");
|
||||
assert(lv);
|
||||
|
||||
v = lvm_lv_get_property(lv, "data_percent");
|
||||
assert(v.is_valid);
|
||||
assert(v.value.integer == 50 * PERCENT_1);
|
||||
|
||||
|
||||
lv = lvm_lv_from_name(vg, "snap");
|
||||
assert(lv);
|
||||
|
||||
v = lvm_lv_get_property(lv, "data_percent");
|
||||
assert(v.is_valid);
|
||||
assert(v.value.integer == 75 * PERCENT_1);
|
||||
|
||||
v = lvm_lv_get_property(lv, "snap_percent");
|
||||
assert(v.is_valid);
|
||||
assert(v.value.integer == (uint64_t) DM_PERCENT_INVALID);
|
||||
|
||||
v = lvm_lv_get_property(lv, "origin");
|
||||
assert(v.is_valid);
|
||||
assert(strcmp(v.value.string, "thin") == 0);
|
||||
|
||||
lvm_vg_close(vg);
|
||||
lvm_quit(handle);
|
||||
|
||||
return 0;
|
||||
}
|
@ -1,73 +0,0 @@
|
||||
/*
|
||||
* Copyright (C) 2009 Red Hat, Inc. All rights reserved.
|
||||
*
|
||||
* This file is part of LVM2.
|
||||
*
|
||||
* This copyrighted material is made available to anyone wishing to use,
|
||||
* modify, copy, or redistribute it subject to the terms and conditions
|
||||
* of the GNU Lesser General Public License v.2.1.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public License
|
||||
* along with this program; if not, write to the Free Software Foundation,
|
||||
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
*/
|
||||
|
||||
#include <stdio.h>
|
||||
#include <unistd.h>
|
||||
#include <inttypes.h>
|
||||
#include <assert.h>
|
||||
|
||||
#include "liblvm/lvm2app.h"
|
||||
|
||||
lvm_t handle;
|
||||
vg_t vg;
|
||||
|
||||
static void start(void) {
|
||||
handle = lvm_init(NULL);
|
||||
if (!handle) {
|
||||
fprintf(stderr, "Unable to lvm_init\n");
|
||||
abort();
|
||||
}
|
||||
}
|
||||
|
||||
static void done(int ok) {
|
||||
if (handle && lvm_errno(handle)) {
|
||||
fprintf(stderr, "LVM Error: %s\n", lvm_errmsg(handle));
|
||||
ok = 0;
|
||||
}
|
||||
if (handle)
|
||||
lvm_quit(handle);
|
||||
if (!ok)
|
||||
abort();
|
||||
}
|
||||
|
||||
int main(int argc, char *argv[])
|
||||
{
|
||||
lvm_str_list_t *str;
|
||||
int i = 0;
|
||||
struct dm_list *vgnames;
|
||||
struct dm_list *vgids;
|
||||
|
||||
if (argc != 3)
|
||||
abort();
|
||||
|
||||
start();
|
||||
vgnames = lvm_list_vg_names(handle);
|
||||
dm_list_iterate_items(str, vgnames) {
|
||||
assert(++i <= 1);
|
||||
assert(!strcmp(str->str, argv[1]));
|
||||
}
|
||||
assert(i == 1);
|
||||
done(1);
|
||||
|
||||
i = 0;
|
||||
start();
|
||||
vgids = lvm_list_vg_uuids(handle);
|
||||
dm_list_iterate_items(str, vgids) {
|
||||
assert(++i <= 1);
|
||||
assert(!strcmp(str->str, argv[2]));
|
||||
}
|
||||
assert(i == 1);
|
||||
done(1);
|
||||
return 0;
|
||||
}
|
@ -1,164 +0,0 @@
|
||||
/*
|
||||
* Copyright (C) 2009 Red Hat, Inc. All rights reserved.
|
||||
*
|
||||
* This file is part of LVM2.
|
||||
*
|
||||
* This copyrighted material is made available to anyone wishing to use,
|
||||
* modify, copy, or redistribute it subject to the terms and conditions
|
||||
* of the GNU Lesser General Public License v.2.1.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public License
|
||||
* along with this program; if not, write to the Free Software Foundation,
|
||||
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
|
||||
*/
|
||||
/*
|
||||
* Unit test case for vgcreate and related APIs.
|
||||
* # gcc -g vgcreate.c -I../../liblvm -I../../include -L../../liblvm \
|
||||
* -L../../libdm -ldevmapper -llvm2app
|
||||
* # export LD_LIBRARY_PATH=`pwd`/../../libdm:`pwd`/../../liblvm
|
||||
*/
|
||||
#include <stdio.h>
|
||||
#include <unistd.h>
|
||||
#include <inttypes.h>
|
||||
|
||||
#include "liblvm/lvm2app.h"
|
||||
|
||||
lvm_t handle;
|
||||
vg_t vg;
|
||||
const char *vg_name;
|
||||
#define MAX_DEVICES 16
|
||||
const char *device[MAX_DEVICES];
|
||||
uint64_t size = 4096;
|
||||
|
||||
#define vg_create(vg_name) \
|
||||
printf("Creating VG %s\n", vg_name); \
|
||||
vg = lvm_vg_create(handle, vg_name); \
|
||||
if (!vg) { \
|
||||
fprintf(stderr, "Error creating volume group %s\n", vg_name); \
|
||||
goto bad; \
|
||||
}
|
||||
#define vg_extend(vg, dev) \
|
||||
printf("Extending VG %s by %s\n", vg_name, dev); \
|
||||
status = lvm_vg_extend(vg, dev); \
|
||||
if (status) { \
|
||||
fprintf(stderr, "Error extending volume group %s " \
|
||||
"with device %s\n", vg_name, dev); \
|
||||
goto bad; \
|
||||
}
|
||||
#define vg_commit(vg) \
|
||||
printf("Committing VG %s to disk\n", vg_name); \
|
||||
status = lvm_vg_write(vg); \
|
||||
if (status) { \
|
||||
fprintf(stderr, "Commit of volume group '%s' failed\n", \
|
||||
lvm_vg_get_name(vg)); \
|
||||
goto bad; \
|
||||
}
|
||||
#define vg_open(vg_name, mode) \
|
||||
printf("Opening VG %s %s\n", vg_name, mode); \
|
||||
vg = lvm_vg_open(handle, vg_name, mode, 0); \
|
||||
if (!vg) { \
|
||||
fprintf(stderr, "Error opening volume group %s\n", vg_name); \
|
||||
goto bad; \
|
||||
}
|
||||
#define vg_close(vg) \
|
||||
printf("Closing VG %s\n", vg_name); \
|
||||
if (lvm_vg_close(vg)) { \
|
||||
fprintf(stderr, "Error closing volume group %s\n", vg_name); \
|
||||
goto bad; \
|
||||
}
|
||||
#define vg_reduce(vg, dev) \
|
||||
printf("Reducing VG %s by %s\n", vg_name, dev); \
|
||||
status = lvm_vg_reduce(vg, dev); \
|
||||
if (status) { \
|
||||
fprintf(stderr, "Error reducing volume group %s " \
|
||||
"by device %s\n", vg_name, dev); \
|
||||
goto bad; \
|
||||
}
|
||||
#define vg_remove(vg) \
|
||||
printf("Removing VG %s from system\n", vg_name); \
|
||||
status = lvm_vg_remove(vg); \
|
||||
if (status) { \
|
||||
fprintf(stderr, "Revmoval of volume group '%s' failed\n", \
|
||||
vg_name); \
|
||||
goto bad; \
|
||||
}
|
||||
|
||||
static int init_vgtest(int argc, char *argv[])
|
||||
{
|
||||
int i;
|
||||
|
||||
if (argc < 4) {
|
||||
fprintf(stderr, "Usage: %s <vgname> <pv1> <pv2> [... <pvN> ]",
|
||||
argv[0]);
|
||||
return -1;
|
||||
}
|
||||
vg_name = argv[1];
|
||||
for(i=2; i<MAX_DEVICES && i < argc; i++) {
|
||||
device[i-2] = argv[i];
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
int main(int argc, char *argv[])
|
||||
{
|
||||
int status;
|
||||
|
||||
if (init_vgtest(argc, argv) < 0)
|
||||
goto bad;
|
||||
|
||||
/* FIXME: make the below messages verbose-only and print PASS/FAIL*/
|
||||
printf("Opening LVM\n");
|
||||
handle = lvm_init(NULL);
|
||||
if (!handle) {
|
||||
fprintf(stderr, "Unable to lvm_init\n");
|
||||
goto bad;
|
||||
}
|
||||
|
||||
printf("Library version: %s\n", lvm_library_get_version());
|
||||
vg_create(vg_name);
|
||||
vg_extend(vg, device[0]);
|
||||
|
||||
printf("Setting VG %s extent_size to %"PRIu64"\n", vg_name, size);
|
||||
status = lvm_vg_set_extent_size(vg, size);
|
||||
if (status) {
|
||||
fprintf(stderr, "Can not set physical extent "
|
||||
"size '%"PRIu64"' for '%s'\n",
|
||||
size, vg_name);
|
||||
goto bad;
|
||||
}
|
||||
|
||||
vg_commit(vg);
|
||||
vg_close(vg);
|
||||
|
||||
vg_open(vg_name, "r");
|
||||
vg_close(vg);
|
||||
|
||||
vg_open(vg_name, "w");
|
||||
vg_extend(vg, device[1]);
|
||||
vg_reduce(vg, device[0]);
|
||||
vg_commit(vg);
|
||||
vg_close(vg);
|
||||
|
||||
vg_open(vg_name, "w");
|
||||
vg_extend(vg, device[0]);
|
||||
vg_commit(vg);
|
||||
vg_close(vg);
|
||||
|
||||
vg_open(vg_name, "w");
|
||||
vg_remove(vg);
|
||||
vg_commit(vg);
|
||||
vg_close(vg);
|
||||
|
||||
lvm_quit(handle);
|
||||
printf("liblvm vgcreate unit test PASS\n");
|
||||
_exit(0);
|
||||
bad:
|
||||
printf("liblvm vgcreate unit test FAIL\n");
|
||||
if (handle && lvm_errno(handle))
|
||||
fprintf(stderr, "LVM Error: %s\n", lvm_errmsg(handle));
|
||||
if (vg)
|
||||
lvm_vg_close(vg);
|
||||
if (handle)
|
||||
lvm_quit(handle);
|
||||
_exit(-1);
|
||||
}
|
Loading…
Reference in New Issue
Block a user