1
0
mirror of git://sourceware.org/git/lvm2.git synced 2025-09-24 21:44:22 +03:00

Compare commits

...

59 Commits

Author SHA1 Message Date
Alasdair Kergon
482eb1f3fb update for 1.00.10 2004-04-02 16:47:43 +00:00
Alasdair Kergon
6e0f638f5e Build process fixes/tidy-ups. 2004-04-02 15:18:38 +00:00
Alasdair Kergon
bab349047d updates for release 2004-03-31 20:14:02 +00:00
Alasdair Kergon
28ea6b8de8 update text for release 2004-03-31 20:09:56 +00:00
Alasdair Kergon
9d51bbdae8 Update VERSION 2004-03-31 19:12:17 +00:00
Alasdair Kergon
d622f79533 Add 2.4 support for DM_LIST_VERSIONS (dmsetup targets).
Rebaseline patches to 2.4.26-rc1.
2004-03-31 18:54:17 +00:00
Alasdair Kergon
04c8515ad1 Missing dev_close_all()s 2004-03-31 18:41:39 +00:00
Alasdair Kergon
53bc4251d1 Update changelog. 2004-03-30 20:33:26 +00:00
Alasdair Kergon
a5a751f02f Example cmdlib program. 2004-03-30 19:54:59 +00:00
Alasdair Kergon
66ed5f82c4 Update copyright notices. 2004-03-30 19:35:44 +00:00
Alasdair Kergon
c802a9e6aa Update changelog. 2004-03-30 19:12:42 +00:00
Alasdair Kergon
880f210946 Update copyright messages. 2004-03-30 19:08:57 +00:00
Alasdair Kergon
4f9f7eb6a6 Fix vgmknodes to remove dud /dev/mapper entries 2004-03-30 14:40:03 +00:00
Alasdair Kergon
f910c4a8e7 Rename dev_manager_mknodes -> dev_manager_lv_mknodes etc. 2004-03-30 14:38:57 +00:00
Alasdair Kergon
529686d965 spelling corrections 2004-03-30 14:36:50 +00:00
Alasdair Kergon
84dfd1536f vgdisplay_colons 2004-03-30 14:35:40 +00:00
Alasdair Kergon
85dedc324c Move full mknodes functionality from dmsetup into libdevmapper. 2004-03-30 14:31:58 +00:00
Alasdair Kergon
d639237411 and another typo 2004-03-26 21:49:57 +00:00
Alasdair Kergon
449aaf75f1 typo 2004-03-26 21:47:43 +00:00
Alasdair Kergon
b1fda66caa missing definition 2004-03-26 21:46:01 +00:00
Alasdair Kergon
66a8e90fd9 lvchange --refresh 2004-03-26 21:24:03 +00:00
Alasdair Kergon
37b487d191 tweak memlock includes 2004-03-26 21:11:34 +00:00
Alasdair Kergon
6c59fe3577 Add string display to mem leak dump. 2004-03-26 21:09:44 +00:00
Alasdair Kergon
1cbb70c992 indent 2004-03-26 21:07:30 +00:00
Alasdair Kergon
e06b39f882 move lock_lvs; add lock memlock code 2004-03-26 20:49:35 +00:00
Alasdair Kergon
2602b1493e LV allocation variable renaming 2004-03-26 20:35:14 +00:00
Alasdair Kergon
989d14502d Add locking flags + memlock option. 2004-03-26 20:17:11 +00:00
Alasdair Kergon
f78a550282 makefile spacing 2004-03-26 20:03:58 +00:00
Alasdair Kergon
54a1abb284 Add list_versions to library 2004-03-26 19:52:09 +00:00
Alasdair Kergon
97b492a8e2 Ignore open hidden LVs when checking if deactivation is OK. 2004-03-26 19:13:39 +00:00
Alasdair Kergon
0873bd14a9 Suppress move percentage when inactive 2004-03-26 19:10:48 +00:00
Alasdair Kergon
eff6ba429a Tidy sysfs includes 2004-03-26 18:54:55 +00:00
Alasdair Kergon
8c18064be4 indent 2004-03-26 15:46:37 +00:00
Alasdair Kergon
44a1ac0cf3 lv_info_by_lvid 2004-03-26 15:35:01 +00:00
Alasdair Kergon
28dc8d88dd cmdlib prototypes 2004-03-26 14:56:41 +00:00
Alasdair Kergon
2c0c2b64ba .export.sym generation 2004-03-26 14:51:23 +00:00
Alasdair Kergon
bd3e0f5248 cmdlib logging function 2004-03-26 14:47:14 +00:00
Alasdair Kergon
cd52d98938 update configure for cmdlib 2004-03-26 14:17:14 +00:00
Alasdair Kergon
894c70e7f8 Update makefiles (incl. cmdlib). 2004-03-26 13:21:12 +00:00
Alasdair Kergon
51d70c2edd Rename some files to avoid duplicate filenames in tree. 2004-03-26 12:25:15 +00:00
Alasdair Kergon
7d4b355240 Add cmdlib code. 2004-03-26 12:21:24 +00:00
Alasdair Kergon
3b56193b98 Add --nolocking option for read operations if locking is failing/unavailable. 2004-03-26 12:09:33 +00:00
Alasdair Kergon
b16045b57d Move main() into separate file. 2004-03-26 12:00:24 +00:00
Alasdair Kergon
9e8b0fca5b Indent; _init -> _init_lvm 2004-03-26 11:49:07 +00:00
Alasdair Kergon
35cf1b3b5b Rebaseline internal verbose level. 2004-03-26 11:45:01 +00:00
Alasdair Kergon
83f788af57 Document metadata tagging. 2004-03-22 15:08:50 +00:00
Alasdair Kergon
2ffe378d3f Only print warning message once when compiled without libdevmapper. 2004-03-19 16:26:46 +00:00
Alasdair Kergon
38b33a4a5e Fix lvreduce pv extents calculations. 2004-03-19 16:19:41 +00:00
Alasdair Kergon
60bf9ed0a0 Avoid sscanf %as for uClibc 2004-03-19 15:52:22 +00:00
Alasdair Kergon
16adf4de1b Fix DESTDIR with configure path overrides. 2004-03-17 19:37:44 +00:00
Alasdair Kergon
80de983023 additional activation functions 2004-03-08 18:54:13 +00:00
Alasdair Kergon
8703ca623f rename config file vars & always use / as separator 2004-03-08 18:28:45 +00:00
Alasdair Kergon
286253a73f host tags 2004-03-08 18:13:22 +00:00
Alasdair Kergon
bd806a41df move hostname into global 2004-03-08 17:25:59 +00:00
Alasdair Kergon
b89c4e9002 tagging 2004-03-08 17:19:15 +00:00
Alasdair Kergon
6dbf31c0c3 More str_list fns. 2004-03-08 15:23:01 +00:00
Alasdair Kergon
060c45d8a1 Fix (rare) bug in recognition of long argument forms. 2004-03-08 13:54:45 +00:00
Alasdair Kergon
33d3e82e4d Detailed changelog. 2004-02-27 22:36:13 +00:00
Alasdair Kergon
4bb074514d Update man page incl. 'targets', event_nr. 2004-02-27 19:36:49 +00:00
221 changed files with 12896 additions and 6869 deletions

View File

@@ -1,20 +1,16 @@
#
# Copyright (C) 2001 Sistina Software
# Copyright (C) 2001-2004 Sistina Software, Inc. All rights reserved.
# Copyright (C) 2004 Red Hat, Inc. All rights reserved.
#
# This LVM library is free software; you can redistribute it and/or
# modify it under the terms of the GNU Library General Public
# License as published by the Free Software Foundation; either
# version 2 of the License, or (at your option) any later version.
# This file is part of the LVM2.
#
# This LVM library is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
# Library General Public License for more details.
# 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 Library General Public
# License along with this LVM library; if not, write to the Free
# Software Foundation, Inc., 59 Temple Place - Suite 330, Boston,
# MA 02111-1307, USA
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software Foundation,
# Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
srcdir = @srcdir@
top_srcdir = @top_srcdir@

View File

@@ -1 +1 @@
2.00.08-cvs (2003-11-14)
2.00.09-cvs (2004-03-31)

View File

@@ -1,3 +1,31 @@
Version 2.00.09 - 31 Mar 2004
=============================
Update copyright notices for Red Hat.
Fix vgmknodes to remove dud /dev/mapper entries. (libdevmapper update reqd).
Add LVM1-style colon output to vgdisplay.
lvchange --refresh to reload active LVs.
Add string display to memory leak dump.
Add locking flags & memlock option.
Add list_versions to library.
Ignore open hidden LVs when checking if deactivation is OK.
Suppress move percentage when device inactive.
Add lv_info_by_lvid.
Various tidy-ups to the build process.
Rebaseline internal verbose level.
Add --nolocking option for read operations if locking is failing.
Add option to compile into a library.
When compiled without libdevmapper, only print warning message once.
Fix lvreduce PV extent calculations.
Fix DESTDIR to work with configure path overrides.
Always use / as config file separator & rename internal config file variables.
Add support for tagging PV/VG/LVs and hosts.
Fix rare bug in recognition of long cmdline argument forms.
Add basic internationalisation infrastructure.
Don't recurse symlinked dirs such as /dev/fd on 2.6 kernels.
Update autoconf files.
Add sysfs block device filtering for 2.6 kernels.
Update refs for move to sources.redhat.com.
Friday 14th November 2003
=========================
Some bug fixes & minor enhancements, including:

29
WHATS_NEW_DM Normal file
View File

@@ -0,0 +1,29 @@
Version 1.00.10 - 2 Apr 2004
============================
Fix DESTDIR handling.
Static build installs to dmsetup.static.
Basic support for internationalisation.
Minor Makefile tidy-ups/fixes.
Version 1.00.09 - 31 Mar 2004
=============================
Update copyright notices to Red Hat.
Move full mknodes functionality from dmsetup into libdevmapper.
Avoid sscanf %as for uClibc compatibility.
Cope if DM_LIST_VERSIONS is not defined.
Add DM_LIST_VERSIONS functionality to kernel patches.
Generate new kernel patches for 2.4.26-rc1.
Version 1.00.08 - 27 Feb 2004
=============================
Added 'dmsetup targets'.
Added event_nr support to 'dmsetup wait'.
Updated dmsetup man page.
Allow logging function to be reset to use internal one.
Bring log macros in line with LVM2 ones.
Added 'make install_static_lib' which installs libdevmapper.a.
Made configure/makefiles closer to LVM2 versions.
Fixed DESTDIR for make install/install_static_lib.
Updated README/INSTALL to reflect move to sources.redhat.com.
Updated autoconf files to 2003-06-17.

6688
configure vendored

File diff suppressed because it is too large Load Diff

View File

@@ -1,4 +1,3 @@
################################################################################
##
## Copyright 1999-2000 Sistina Software, Inc.
##
@@ -51,7 +50,23 @@ AC_CANONICAL_SYSTEM
case "$host_os" in
linux*)
CFLAGS= ;;
CFLAGS=
CLDFLAGS="-Wl,--version-script,.export.sym"
CLDWHOLEARCHIVE="-Wl,-whole-archive"
CLDNOWHOLEARCHIVE="-Wl,-no-whole-archive"
LD_DEPS=".export.sym"
SOFLAG="-shared"
DEVMAPPER=yes
ODIRECT=yes ;;
darwin*)
CFLAGS="-no-cpp-precomp -fno-common"
CLDFLAGS=
CLDWHOLEARCHIVE="-all_load"
CLDNOWHOLEARCHIVE=
LD_DEPS=
SOFLAG="-dynamiclib"
DEVMAPPER=no
ODIRECT=no ;;
esac
dnl -- prefix is /usr by default, the exec_prefix default is setup later
@@ -89,8 +104,8 @@ fi
AC_ARG_ENABLE(jobs, [ --enable-jobs=NUM Number of jobs to run simultaneously], JOBS=-j$enableval, JOBS=-j2)
dnl Enables staticly linked tools
AC_ARG_ENABLE(static_link, [ --enable-static_link Use this to link the tools to the liblvm library
dnl Enables staticly-linked tools
AC_ARG_ENABLE(static_link, [ --enable-static_link Use this to link the tools to their libraries
statically. Default is dynamic linking], STATIC_LINK=$enableval, STATIC_LINK=no)
dnl Enable readline
@@ -110,7 +125,7 @@ echo "$ac_t""$DEBUG" 1>&6
echo $ac_n "checking whether to enable device-mapper""... $ac_c" 1>&6
dnl Disable devmapper
AC_ARG_ENABLE(devmapper, [ --disable-devmapper Disable device-mapper interaction], \
DEVMAPPER=no, DEVMAPPER=yes)
DEVMAPPER=no)
echo "$ac_t""$DEVMAPPER" 1>&6
if test x$DEVMAPPER = xyes; then
@@ -120,13 +135,23 @@ fi
echo $ac_n "checking whether to enable O_DIRECT""... $ac_c" 1>&6
dnl Disable O_DIRECT
AC_ARG_ENABLE(o_direct, [ --disable-o_direct Disable O_DIRECT], \
ODIRECT=no, ODIRECT=yes)
ODIRECT=no)
echo "$ac_t""$ODIRECT" 1>&6
if test x$ODIRECT = xyes; then
CFLAGS="$CFLAGS -DO_DIRECT_SUPPORT"
fi
echo $ac_n "checking whether to compile liblvm2cmd.so""... $ac_c" 1>&6
dnl Enable cmdlib
AC_ARG_ENABLE(cmdlib, [ --enable-cmdlib Build shared command library], \
CMDLIB=yes, CMDLIB=no)
echo "$ac_t""$CMDLIB" 1>&6
if test x$CMDLIB = xyes; then
CFLAGS="$CFLAGS -DCMDLIB"
fi
dnl Mess with default exec_prefix
if [[ "x$exec_prefix" = xNONE -a "x$prefix" = xNONE ]];
then exec_prefix="";
@@ -217,15 +242,22 @@ AC_SUBST(LVM1)
AC_SUBST(OWNER)
AC_SUBST(GROUP)
AC_SUBST(CFLAGS)
AC_SUBST(CLDFLAGS)
AC_SUBST(CLDWHOLEARCHIVE)
AC_SUBST(CLDNOWHOLEARCHIVE)
AC_SUBST(LD_DEPS)
AC_SUBST(SOFLAG)
AC_SUBST(LIBS)
AC_SUBST(LVM_VERSION)
AC_SUBST(DEBUG)
AC_SUBST(DEVMAPPER)
AC_SUBST(HAVE_LIBDL)
AC_SUBST(CMDLIB)
AC_SUBST(MSGFMT)
AC_SUBST(LOCALEDIR)
AC_SUBST(INTL_PACKAGE)
AC_SUBST(INTL)
dnl First and last lines should not contain files to generate in order to
dnl keep utility scripts running properly
AC_OUTPUT( \

View File

@@ -219,6 +219,14 @@ activation {
# Nice value used while devices suspended
process_priority = -18
# If volume_list is defined, each LV is only activated if there is a
# match against the list.
# "vgname" and "vgname/lvname" are matched exactly.
# "@tag" matches any tag set in the LV or VG.
# "@*" matches if any tag defined on the host is also set in the LV or VG
#
# volume_list = [ "vg1", "vg2/lvol1", "@tag1", "@*" ]
}

47
doc/example_cmdlib.c Normal file
View File

@@ -0,0 +1,47 @@
/*
* Copyright (C) 2004 Red Hat, Inc. All rights reserved.
*
* This file is part of LVM2.
*
* This copyrighted material is made available to anyone wishing to use,
* modify, copy, or redistribute it subject to the terms and conditions
* of the GNU General Public License v.2.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software Foundation,
* Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
#include "lvm2cmd.h"
/* All output gets passed to this function line-by-line */
void test_log_fn(int level, const char *file, int line, const char *format)
{
/* Extract and process output here rather than printing it */
if (level != 4)
return;
printf("%s\n", format);
return;
}
int main(int argc, char **argv)
{
void *handle;
int r;
lvm2_log_fn(test_log_fn);
handle = lvm2_init();
lvm2_log_level(handle, 1);
r = lvm2_run(handle, "vgs --noheadings vg1");
/* More commands here */
lvm2_exit(handle);
return r;
}

View File

@@ -1,20 +1,16 @@
#
# Copyright (C) 2001 Sistina Software
# Copyright (C) 2001-2004 Sistina Software, Inc. All rights reserved.
# Copyright (C) 2004 Red Hat, Inc. All rights reserved.
#
# This LVM library is free software; you can redistribute it and/or
# modify it under the terms of the GNU Library General Public
# License as published by the Free Software Foundation; either
# version 2 of the License, or (at your option) any later version.
# This file is part of the LVM2.
#
# This LVM library is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
# Library General Public License for more details.
# 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 Library General Public
# License along with this LVM library; if not, write to the Free
# Software Foundation, Inc., 59 Temple Place - Suite 330, Boston,
# MA 02111-1307, USA
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software Foundation,
# Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
SHELL = /bin/sh

View File

@@ -1,8 +1,16 @@
#
# Copyright (C) 2001 Sistina Software (UK) Limited
# Copyright (C) 2001-2004 Sistina Software, Inc. All rights reserved.
# Copyright (C) 2004 Red Hat, Inc. All rights reserved.
#
# This file is released under the GPL.
# This file is part of the LVM2.
#
# This copyrighted material is made available to anyone wishing to use,
# modify, copy, or redistribute it subject to the terms and conditions
# of the GNU General Public License v.2.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software Foundation,
# Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
srcdir = @srcdir@
top_srcdir = @top_srcdir@
@@ -12,7 +20,7 @@ ifeq ("@LVM1@", "shared")
SUBDIRS = format1
endif
SOURCES=\
SOURCES =\
activate/activate.c \
cache/lvmcache.c \
commands/toolcontext.c \
@@ -36,6 +44,7 @@ SOURCES=\
format_text/format-text.c \
format_text/import.c \
format_text/import_vsn1.c \
format_text/tags.c \
format_text/text_label.c \
label/label.c \
locking/file_locking.c \
@@ -60,7 +69,7 @@ SOURCES=\
uuid/uuid.c
ifeq ("@LVM1@", "internal")
SOURCES+=\
SOURCES +=\
format1/disk-rep.c \
format1/format1.c \
format1/import-export.c \
@@ -71,28 +80,24 @@ ifeq ("@LVM1@", "internal")
endif
ifeq ("@DEBUG@", "yes")
SOURCES+=\
mm/dbg_malloc.c
SOURCES += mm/dbg_malloc.c
endif
ifeq ("@DEVMAPPER@", "yes")
SOURCES+=\
SOURCES +=\
activate/dev_manager.c \
activate/fs.c
endif
ifeq ("@HAVE_LIBDL@", "yes")
SOURCES+=\
SOURCES +=\
locking/external_locking.c \
misc/sharedlib.c
endif
TARGETS=liblvm.a
LIB_STATIC = liblvm.a
TARGETS = $(LIB_STATIC)
include ../make.tmpl
liblvm.a: $(OBJECTS)
$(RM) $@
$(AR) r $@ $(OBJECTS)
$(RANLIB) $@

View File

@@ -1,7 +1,16 @@
/*
* Copyright (C) 2001 Sistina Software (UK) Limited.
* Copyright (C) 2001-2004 Sistina Software, Inc. All rights reserved.
* Copyright (C) 2004 Red Hat, Inc. All rights reserved.
*
* This file is released under the LGPL.
* This file is part of LVM2.
*
* This copyrighted material is made available to anyone wishing to use,
* modify, copy, or redistribute it subject to the terms and conditions
* of the GNU General Public License v.2.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software Foundation,
* Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
#include "lib.h"
@@ -14,6 +23,7 @@
#include "pool.h"
#include "toolcontext.h"
#include "dev_manager.h"
#include "str_list.h"
#include <limits.h>
#include <fcntl.h>
@@ -24,9 +34,15 @@
#ifndef DEVMAPPER_SUPPORT
void set_activation(int act)
{
if (act)
log_error("Compiled without libdevmapper support. "
"Can't enable activation.");
static int warned = 0;
if (warned || !act)
return;
log_error("Compiled without libdevmapper support. "
"Can't enable activation.");
warned = 1;
}
int activation(void)
{
@@ -40,10 +56,19 @@ int driver_version(char *version, size_t size)
{
return 0;
}
int target_present(const char *target_name)
{
return 0;
}
int lv_info(const struct logical_volume *lv, struct lvinfo *info)
{
return 0;
}
int lv_info_by_lvid(struct cmd_context *cmd, const char *lvid_s,
struct lvinfo *info)
{
return 0;
}
int lv_snapshot_percent(struct logical_volume *lv, float *percent)
{
return 0;
@@ -61,10 +86,18 @@ int lvs_in_vg_opened(struct volume_group *vg)
{
return 0;
}
int lv_suspend(struct cmd_context *cmd, const char *lvid_s)
{
return 1;
}
int lv_suspend_if_active(struct cmd_context *cmd, const char *lvid_s)
{
return 1;
}
int lv_resume(struct cmd_context *cmd, const char *lvid_s)
{
return 1;
}
int lv_resume_if_active(struct cmd_context *cmd, const char *lvid_s)
{
return 1;
@@ -73,10 +106,19 @@ int lv_deactivate(struct cmd_context *cmd, const char *lvid_s)
{
return 1;
}
int lv_activation_filter(struct cmd_context *cmd, const char *lvid_s,
int *activate_lv)
{
return 1;
}
int lv_activate(struct cmd_context *cmd, const char *lvid_s)
{
return 1;
}
int lv_activate_with_filter(struct cmd_context *cmd, const char *lvid_s)
{
return 1;
}
int lv_mknodes(struct cmd_context *cmd, const struct logical_volume *lv)
{
@@ -111,6 +153,86 @@ int activation(void)
return _activation;
}
static int _passes_activation_filter(struct cmd_context *cmd,
struct logical_volume *lv)
{
struct config_node *cn;
struct config_value *cv;
char *str;
char path[PATH_MAX];
if (!(cn = find_config_node(cmd->cft->root, "activation/volume_list"))) {
/* If no hosts tags defined, activate */
if (list_empty(&cmd->tags))
return 1;
/* If any host tag matches any LV or VG tag, activate */
if (str_list_match_list(&cmd->tags, &lv->tags) ||
str_list_match_list(&cmd->tags, &lv->vg->tags))
return 1;
/* Don't activate */
return 0;
}
for (cv = cn->v; cv; cv = cv->next) {
if (cv->type != CFG_STRING) {
log_error("Ignoring invalid string in config file "
"activation/volume_list");
continue;
}
str = cv->v.str;
if (!*str) {
log_error("Ignoring empty string in config file "
"activation/volume_list");
continue;
}
/* Tag? */
if (*str == '@') {
str++;
if (!*str) {
log_error("Ignoring empty tag in config file "
"activation/volume_list");
continue;
}
/* If any host tag matches any LV or VG tag, activate */
if (!strcmp(str, "*")) {
if (str_list_match_list(&cmd->tags, &lv->tags)
|| str_list_match_list(&cmd->tags,
&lv->vg->tags))
return 1;
else
continue;
}
/* If supplied tag matches LV or VG tag, activate */
if (str_list_match_item(&lv->tags, str) ||
str_list_match_item(&lv->vg->tags, str))
return 1;
else
continue;
}
if (!index(str, '/')) {
/* vgname supplied */
if (!strcmp(str, lv->vg->name))
return 1;
else
continue;
}
/* vgname/lvname */
if (lvm_snprintf(path, sizeof(path), "%s/%s", lv->vg->name,
lv->name) < 0) {
log_error("lvm_snprintf error from %s/%s", lv->vg->name,
lv->name);
continue;
}
if (!strcmp(path, str))
return 1;
}
return 0;
}
int library_version(char *version, size_t size)
{
if (!activation())
@@ -149,6 +271,46 @@ int driver_version(char *version, size_t size)
return r;
}
int target_present(const char *target_name)
{
int r = 0;
struct dm_task *dmt;
struct dm_versions *target, *last_target;
if (!activation())
return 0;
log_very_verbose("Getting target version for %s", target_name);
if (!(dmt = dm_task_create(DM_DEVICE_LIST_VERSIONS))) {
stack;
return 0;
}
if (!dm_task_run(dmt)) {
log_debug("Failed to get %s target version", target_name);
/* Assume this was because LIST_VERSIONS isn't supported */
return 1;
}
target = dm_task_get_versions(dmt);
do {
last_target = target;
if (!strcmp(target_name, target->name)) {
r = 1;
goto out;
}
target = (void *) target + target->next;
} while (last_target != target);
out:
dm_task_destroy(dmt);
return r;
}
/*
* Returns 1 if info structure populated, else 0 on failure.
*/
@@ -162,7 +324,7 @@ static int _lv_info(const struct logical_volume *lv, int mknodes,
if (!activation())
return 0;
if (!(dm = dev_manager_create(lv->vg->name, lv->vg->cmd->cf))) {
if (!(dm = dev_manager_create(lv->vg->name, lv->vg->cmd->cft))) {
stack;
return 0;
}
@@ -186,6 +348,17 @@ int lv_info(const struct logical_volume *lv, struct lvinfo *info)
return _lv_info(lv, 0, info);
}
int lv_info_by_lvid(struct cmd_context *cmd, const char *lvid_s,
struct lvinfo *info)
{
struct logical_volume *lv;
if (!(lv = lv_from_lvid(cmd, lvid_s)))
return 0;
return _lv_info(lv, 0, info);
}
/*
* Returns 1 if percent set, else 0 on failure.
*/
@@ -197,7 +370,7 @@ int lv_snapshot_percent(struct logical_volume *lv, float *percent)
if (!activation())
return 0;
if (!(dm = dev_manager_create(lv->vg->name, lv->vg->cmd->cf))) {
if (!(dm = dev_manager_create(lv->vg->name, lv->vg->cmd->cft))) {
stack;
return 0;
}
@@ -216,11 +389,20 @@ int lv_mirror_percent(struct logical_volume *lv, int wait, float *percent,
{
int r;
struct dev_manager *dm;
struct lvinfo info;
if (!activation())
return 0;
if (!(dm = dev_manager_create(lv->vg->name, lv->vg->cmd->cf))) {
if (!lv_info(lv, &info)) {
stack;
return 0;
}
if (!info.exists)
return 0;
if (!(dm = dev_manager_create(lv->vg->name, lv->vg->cmd->cft))) {
stack;
return 0;
}
@@ -258,12 +440,12 @@ static int _lv_open_count(struct logical_volume *lv)
}
/* FIXME Need to detect and handle an lv rename */
static int _lv_activate(struct logical_volume *lv)
static int _lv_activate_lv(struct logical_volume *lv)
{
int r;
struct dev_manager *dm;
if (!(dm = dev_manager_create(lv->vg->name, lv->vg->cmd->cf))) {
if (!(dm = dev_manager_create(lv->vg->name, lv->vg->cmd->cft))) {
stack;
return 0;
}
@@ -280,7 +462,7 @@ static int _lv_deactivate(struct logical_volume *lv)
int r;
struct dev_manager *dm;
if (!(dm = dev_manager_create(lv->vg->name, lv->vg->cmd->cf))) {
if (!(dm = dev_manager_create(lv->vg->name, lv->vg->cmd->cft))) {
stack;
return 0;
}
@@ -292,12 +474,12 @@ static int _lv_deactivate(struct logical_volume *lv)
return r;
}
static int _lv_suspend(struct logical_volume *lv)
static int _lv_suspend_lv(struct logical_volume *lv)
{
int r;
struct dev_manager *dm;
if (!(dm = dev_manager_create(lv->vg->name, lv->vg->cmd->cf))) {
if (!(dm = dev_manager_create(lv->vg->name, lv->vg->cmd->cft))) {
stack;
return 0;
}
@@ -347,8 +529,8 @@ int lvs_in_vg_opened(struct volume_group *vg)
return count;
}
/* These return success if the device is not active */
int lv_suspend_if_active(struct cmd_context *cmd, const char *lvid_s)
static int _lv_suspend(struct cmd_context *cmd, const char *lvid_s,
int error_if_not_suspended)
{
struct logical_volume *lv;
struct lvinfo info;
@@ -370,10 +552,10 @@ int lv_suspend_if_active(struct cmd_context *cmd, const char *lvid_s)
}
if (!info.exists || info.suspended)
return 1;
return error_if_not_suspended ? 0 : 1;
memlock_inc();
if (!_lv_suspend(lv)) {
if (!_lv_suspend_lv(lv)) {
memlock_dec();
fs_unlock();
return 0;
@@ -382,7 +564,19 @@ int lv_suspend_if_active(struct cmd_context *cmd, const char *lvid_s)
return 1;
}
int lv_resume_if_active(struct cmd_context *cmd, const char *lvid_s)
/* Returns success if the device is not active */
int lv_suspend_if_active(struct cmd_context *cmd, const char *lvid_s)
{
return _lv_suspend(cmd, lvid_s, 0);
}
int lv_suspend(struct cmd_context *cmd, const char *lvid_s)
{
return _lv_suspend(cmd, lvid_s, 1);
}
static int _lv_resume(struct cmd_context *cmd, const char *lvid_s,
int error_if_not_active)
{
struct logical_volume *lv;
struct lvinfo info;
@@ -404,9 +598,9 @@ int lv_resume_if_active(struct cmd_context *cmd, const char *lvid_s)
}
if (!info.exists || !info.suspended)
return 1;
return error_if_not_active ? 0 : 1;
if (!_lv_activate(lv))
if (!_lv_activate_lv(lv))
return 0;
memlock_dec();
@@ -415,6 +609,17 @@ int lv_resume_if_active(struct cmd_context *cmd, const char *lvid_s)
return 1;
}
/* Returns success if the device is not active */
int lv_resume_if_active(struct cmd_context *cmd, const char *lvid_s)
{
return _lv_resume(cmd, lvid_s, 0);
}
int lv_resume(struct cmd_context *cmd, const char *lvid_s)
{
return _lv_resume(cmd, lvid_s, 1);
}
int lv_deactivate(struct cmd_context *cmd, const char *lvid_s)
{
struct logical_volume *lv;
@@ -440,7 +645,7 @@ int lv_deactivate(struct cmd_context *cmd, const char *lvid_s)
if (!info.exists)
return 1;
if (info.open_count) {
if (info.open_count && (lv->status & VISIBLE_LV)) {
log_error("LV %s/%s in use: not removing", lv->vg->name,
lv->name);
return 0;
@@ -454,7 +659,31 @@ int lv_deactivate(struct cmd_context *cmd, const char *lvid_s)
return r;
}
int lv_activate(struct cmd_context *cmd, const char *lvid_s)
/* Test if LV passes filter */
int lv_activation_filter(struct cmd_context *cmd, const char *lvid_s,
int *activate_lv)
{
struct logical_volume *lv;
if (!activation())
goto activate;
if (!(lv = lv_from_lvid(cmd, lvid_s)))
return 0;
if (!_passes_activation_filter(cmd, lv)) {
log_verbose("Not activating %s/%s due to config file settings",
lv->vg->name, lv->name);
*activate_lv = 0;
return 1;
}
activate:
*activate_lv = 1;
return 1;
}
static int _lv_activate(struct cmd_context *cmd, const char *lvid_s, int filter)
{
struct logical_volume *lv;
struct lvinfo info;
@@ -466,6 +695,12 @@ int lv_activate(struct cmd_context *cmd, const char *lvid_s)
if (!(lv = lv_from_lvid(cmd, lvid_s)))
return 0;
if (filter && !_passes_activation_filter(cmd, lv)) {
log_verbose("Not activating %s/%s due to config file settings",
lv->vg->name, lv->name);
return 0;
}
if (test_mode()) {
_skip("Activating '%s'.", lv->name);
return 1;
@@ -480,27 +715,45 @@ int lv_activate(struct cmd_context *cmd, const char *lvid_s)
return 1;
memlock_inc();
r = _lv_activate(lv);
r = _lv_activate_lv(lv);
memlock_dec();
fs_unlock();
return r;
}
/* Activate LV */
int lv_activate(struct cmd_context *cmd, const char *lvid_s)
{
return _lv_activate(cmd, lvid_s, 0);
}
/* Activate LV only if it passes filter */
int lv_activate_with_filter(struct cmd_context *cmd, const char *lvid_s)
{
return _lv_activate(cmd, lvid_s, 1);
}
int lv_mknodes(struct cmd_context *cmd, const struct logical_volume *lv)
{
struct lvinfo info;
int r = 1;
if (!lv) {
r = dev_manager_mknodes();
fs_unlock();
return r;
}
if (!_lv_info(lv, 1, &info)) {
stack;
return 0;
}
if (info.exists)
r = dev_manager_mknodes(lv);
r = dev_manager_lv_mknodes(lv);
else
r = dev_manager_rmnodes(lv);
r = dev_manager_lv_rmnodes(lv);
fs_unlock();

View File

@@ -1,7 +1,16 @@
/*
* Copyright (C) 2001 Sistina Software (UK) Limited.
* Copyright (C) 2001-2004 Sistina Software, Inc. All rights reserved.
* Copyright (C) 2004 Red Hat, Inc. All rights reserved.
*
* This file is released under the LGPL.
* This file is part of LVM2.
*
* This copyrighted material is made available to anyone wishing to use,
* modify, copy, or redistribute it subject to the terms and conditions
* of the GNU General Public License v.2.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software Foundation,
* Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
#ifndef LVM_ACTIVATE_H
@@ -28,11 +37,16 @@ int activation(void);
int driver_version(char *version, size_t size);
int library_version(char *version, size_t size);
int target_present(const char *target_name);
void activation_exit(void);
int lv_suspend(struct cmd_context *cmd, const char *lvid_s);
int lv_suspend_if_active(struct cmd_context *cmd, const char *lvid_s);
int lv_resume(struct cmd_context *cmd, const char *lvid_s);
int lv_resume_if_active(struct cmd_context *cmd, const char *lvid_s);
int lv_activate(struct cmd_context *cmd, const char *lvid_s);
int lv_activate_with_filter(struct cmd_context *cmd, const char *lvid_s);
int lv_deactivate(struct cmd_context *cmd, const char *lvid_s);
int lv_mknodes(struct cmd_context *cmd, const struct logical_volume *lv);
@@ -41,6 +55,15 @@ int lv_mknodes(struct cmd_context *cmd, const struct logical_volume *lv);
* Returns 1 if info structure has been populated, else 0.
*/
int lv_info(const struct logical_volume *lv, struct lvinfo *info);
int lv_info_by_lvid(struct cmd_context *cmd, const char *lvid_s,
struct lvinfo *info);
/*
* Returns 1 if activate_lv has been set: 1 = activate; 0 = don't.
*/
int lv_activation_filter(struct cmd_context *cmd, const char *lvid_s,
int *activate_lv);
/*
* Returns 1 if percent has been set, else 0.
*/

View File

@@ -1,7 +1,16 @@
/*
* Copyright (C) 2002 Sistina Software (UK) Limited.
* Copyright (C) 2002-2004 Sistina Software, Inc. All rights reserved.
* Copyright (C) 2004 Red Hat, Inc. All rights reserved.
*
* This file is released under the LGPL.
* This file is part of LVM2.
*
* This copyrighted material is made available to anyone wishing to use,
* modify, copy, or redistribute it subject to the terms and conditions
* of the GNU General Public License v.2.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software Foundation,
* Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
#include "lib.h"
@@ -108,7 +117,7 @@ static uint32_t mirror_region_size = 0;
struct dev_manager {
struct pool *mem;
struct config_tree *cf;
struct config_tree *cft;
const char *stripe_filler;
uint32_t mirror_region_size;
uint32_t pvmove_mirror_count;
@@ -1015,7 +1024,7 @@ static int _populate_snapshot(struct dev_manager *dm,
* dev_manager implementation.
*/
struct dev_manager *dev_manager_create(const char *vg_name,
struct config_tree *cf)
struct config_tree *cft)
{
struct pool *mem;
struct dev_manager *dm;
@@ -1031,18 +1040,17 @@ struct dev_manager *dev_manager_create(const char *vg_name,
}
dm->mem = mem;
dm->cf = cf;
dm->cft = cft;
if (!stripe_filler) {
stripe_filler = find_config_str(cf->root,
stripe_filler = find_config_str(cft->root,
"activation/missing_stripe_filler",
'/', DEFAULT_STRIPE_FILLER);
DEFAULT_STRIPE_FILLER);
}
dm->stripe_filler = stripe_filler;
if (!mirror_region_size) {
mirror_region_size = 2 * find_config_int(cf->root,
mirror_region_size = 2 * find_config_int(cft->root,
"activation/mirror_region_size",
'/',
DEFAULT_MIRROR_REGION_SIZE);
}
dm->mirror_region_size = mirror_region_size;
@@ -1940,7 +1948,6 @@ static int _add_existing_layer(struct dev_manager *dm, const char *name)
static int _scan_existing_devices(struct dev_manager *dm)
{
int r = 0;
struct dm_names *names;
unsigned next = 0;
@@ -2184,7 +2191,7 @@ int dev_manager_suspend(struct dev_manager *dm, struct logical_volume *lv)
return _action(dm, lv, SUSPEND);
}
int dev_manager_mknodes(const struct logical_volume *lv)
int dev_manager_lv_mknodes(const struct logical_volume *lv)
{
char *name;
@@ -2197,11 +2204,25 @@ int dev_manager_mknodes(const struct logical_volume *lv)
return fs_add_lv(lv, name);
}
int dev_manager_rmnodes(const struct logical_volume *lv)
int dev_manager_lv_rmnodes(const struct logical_volume *lv)
{
return fs_del_lv(lv);
}
int dev_manager_mknodes(void)
{
struct dm_task *dmt;
int r;
if (!(dmt = dm_task_create(DM_DEVICE_MKNODES)))
return 0;
r = dm_task_run(dmt);
dm_task_destroy(dmt);
return r;
}
void dev_manager_exit(void)
{
dm_lib_exit();

View File

@@ -1,7 +1,16 @@
/*
* Copyright (C) 2002 Sistina Software (UK) Limited.
* Copyright (C) 2002-2004 Sistina Software, Inc. All rights reserved.
* Copyright (C) 2004 Red Hat, Inc. All rights reserved.
*
* This file is released under the LGPL.
* This file is part of LVM2.
*
* This copyrighted material is made available to anyone wishing to use,
* modify, copy, or redistribute it subject to the terms and conditions
* of the GNU General Public License v.2.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software Foundation,
* Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
#ifndef _LVM_DEV_MANAGER_H
@@ -38,8 +47,9 @@ int dev_manager_suspend(struct dev_manager *dm, struct logical_volume *lv);
int dev_manager_activate(struct dev_manager *dm, struct logical_volume *lv);
int dev_manager_deactivate(struct dev_manager *dm, struct logical_volume *lv);
int dev_manager_mknodes(const struct logical_volume *lv);
int dev_manager_rmnodes(const struct logical_volume *lv);
int dev_manager_lv_mknodes(const struct logical_volume *lv);
int dev_manager_lv_rmnodes(const struct logical_volume *lv);
int dev_manager_mknodes(void);
/*
* Put the desired changes into effect.

View File

@@ -1,7 +1,16 @@
/*
* Copyright (C) 2001 Sistina Software (UK) Limited.
* Copyright (C) 2001-2004 Sistina Software, Inc. All rights reserved.
* Copyright (C) 2004 Red Hat, Inc. All rights reserved.
*
* This file is released under the LGPL.
* This file is part of LVM2.
*
* This copyrighted material is made available to anyone wishing to use,
* modify, copy, or redistribute it subject to the terms and conditions
* of the GNU General Public License v.2.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software Foundation,
* Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
#include "lib.h"

View File

@@ -1,7 +1,16 @@
/*
* Copyright (C) 2001 Sistina Software (UK) Limited.
* Copyright (C) 2001-2004 Sistina Software, Inc. All rights reserved.
* Copyright (C) 2004 Red Hat, Inc. All rights reserved.
*
* This file is released under the LGPL.
* This file is part of LVM2.
*
* This copyrighted material is made available to anyone wishing to use,
* modify, copy, or redistribute it subject to the terms and conditions
* of the GNU General Public License v.2.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software Foundation,
* Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
#ifndef _LVM_FS_H

13
lib/cache/lvmcache.c vendored
View File

@@ -1,7 +1,16 @@
/*
* Copyright (C) 2001 Sistina Software (UK) Limited.
* Copyright (C) 2001-2004 Sistina Software, Inc. All rights reserved.
* Copyright (C) 2004 Red Hat, Inc. All rights reserved.
*
* This file is released under the LGPL.
* This file is part of LVM2.
*
* This copyrighted material is made available to anyone wishing to use,
* modify, copy, or redistribute it subject to the terms and conditions
* of the GNU General Public License v.2.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software Foundation,
* Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*
*/

13
lib/cache/lvmcache.h vendored
View File

@@ -1,7 +1,16 @@
/*
* Copyright (C) 2001 Sistina Software (UK) Limited.
* Copyright (C) 2001-2004 Sistina Software, Inc. All rights reserved.
* Copyright (C) 2004 Red Hat, Inc. All rights reserved.
*
* This file is released under the LGPL.
* This file is part of LVM2.
*
* This copyrighted material is made available to anyone wishing to use,
* modify, copy, or redistribute it subject to the terms and conditions
* of the GNU General Public License v.2.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software Foundation,
* Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*
*/

View File

@@ -1,7 +1,16 @@
/*
* Copyright (C) 2001 Sistina Software (UK) Limited.
* Copyright (C) 2001-2004 Sistina Software, Inc. All rights reserved.
* Copyright (C) 2004 Red Hat, Inc. All rights reserved.
*
* This file is released under the LGPL.
* This file is part of LVM2.
*
* This copyrighted material is made available to anyone wishing to use,
* modify, copy, or redistribute it subject to the terms and conditions
* of the GNU General Public License v.2.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software Foundation,
* Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
#ifndef _LVM_ERRORS_H

View File

@@ -1,7 +1,16 @@
/*
* Copyright (C) 2001 Sistina Software (UK) Limited.
* Copyright (C) 2001-2004 Sistina Software, Inc. All rights reserved.
* Copyright (C) 2004 Red Hat, Inc. All rights reserved.
*
* This file is released under the LGPL.
* This file is part of LVM2.
*
* This copyrighted material is made available to anyone wishing to use,
* modify, copy, or redistribute it subject to the terms and conditions
* of the GNU General Public License v.2.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software Foundation,
* Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*
*/
@@ -22,6 +31,7 @@
#include "format-text.h"
#include "display.h"
#include "memlock.h"
#include "str_list.h"
#ifdef HAVE_LIBDL
#include "sharedlib.h"
@@ -33,6 +43,7 @@
#include <locale.h>
#include <sys/stat.h>
#include <sys/utsname.h>
#include <syslog.h>
#include <time.h>
@@ -68,7 +79,7 @@ static void _init_logging(struct cmd_context *cmd)
/* Syslog */
cmd->default_settings.syslog =
find_config_int(cmd->cf->root, "log/syslog", '/', DEFAULT_SYSLOG);
find_config_int(cmd->cft->root, "log/syslog", DEFAULT_SYSLOG);
if (cmd->default_settings.syslog != 1)
fin_syslog();
@@ -77,47 +88,51 @@ static void _init_logging(struct cmd_context *cmd)
/* Debug level for log file output */
cmd->default_settings.debug =
find_config_int(cmd->cf->root, "log/level", '/', DEFAULT_LOGLEVEL);
find_config_int(cmd->cft->root, "log/level", DEFAULT_LOGLEVEL);
init_debug(cmd->default_settings.debug);
/* Verbose level for tty output */
cmd->default_settings.verbose =
find_config_int(cmd->cf->root, "log/verbose", '/', DEFAULT_VERBOSE);
init_verbose(cmd->default_settings.verbose);
find_config_int(cmd->cft->root, "log/verbose", DEFAULT_VERBOSE);
init_verbose(cmd->default_settings.verbose + VERBOSE_BASE_LEVEL);
/* Log message formatting */
init_indent(find_config_int(cmd->cf->root, "log/indent", '/',
init_indent(find_config_int(cmd->cft->root, "log/indent",
DEFAULT_INDENT));
cmd->default_settings.msg_prefix = find_config_str(cmd->cf->root,
"log/prefix", '/',
cmd->default_settings.msg_prefix = find_config_str(cmd->cft->root,
"log/prefix",
DEFAULT_MSG_PREFIX);
init_msg_prefix(cmd->default_settings.msg_prefix);
cmd->default_settings.cmd_name = find_config_int(cmd->cf->root,
cmd->default_settings.cmd_name = find_config_int(cmd->cft->root,
"log/command_names",
'/', DEFAULT_CMD_NAME);
DEFAULT_CMD_NAME);
init_cmd_name(cmd->default_settings.cmd_name);
/* Test mode */
cmd->default_settings.test =
find_config_int(cmd->cf->root, "global/test", '/', 0);
find_config_int(cmd->cft->root, "global/test", 0);
/* Settings for logging to file */
if (find_config_int(cmd->cf->root, "log/overwrite", '/',
if (find_config_int(cmd->cft->root, "log/overwrite",
DEFAULT_OVERWRITE))
append = 0;
log_file = find_config_str(cmd->cf->root, "log/file", '/', 0);
if (log_file)
init_log_file(log_file, append);
log_file = find_config_str(cmd->cft->root, "log/file", 0);
log_file = find_config_str(cmd->cf->root, "log/activate_file", '/', 0);
if (log_file) {
release_log_memory();
fin_log();
init_log_file(log_file, append);
}
log_file = find_config_str(cmd->cft->root, "log/activate_file", 0);
if (log_file)
init_log_direct(log_file, append);
init_log_while_suspended(find_config_int(cmd->cf->root,
"log/activation", '/', 0));
init_log_while_suspended(find_config_int(cmd->cft->root,
"log/activation", 0));
t = time(NULL);
log_verbose("Logging initialised at %s", ctime(&t));
@@ -133,8 +148,8 @@ static int _process_config(struct cmd_context *cmd)
mode_t old_umask;
/* umask */
cmd->default_settings.umask = find_config_int(cmd->cf->root,
"global/umask", '/',
cmd->default_settings.umask = find_config_int(cmd->cft->root,
"global/umask",
DEFAULT_UMASK);
if ((old_umask = umask((mode_t) cmd->default_settings.umask)) !=
@@ -143,8 +158,8 @@ static int _process_config(struct cmd_context *cmd)
/* dev dir */
if (lvm_snprintf(cmd->dev_dir, sizeof(cmd->dev_dir), "%s/",
find_config_str(cmd->cf->root, "devices/dir",
'/', DEFAULT_DEV_DIR)) < 0) {
find_config_str(cmd->cft->root, "devices/dir",
DEFAULT_DEV_DIR)) < 0) {
log_error("Device directory given in config file too long");
return 0;
}
@@ -154,27 +169,25 @@ static int _process_config(struct cmd_context *cmd)
/* proc dir */
if (lvm_snprintf(cmd->proc_dir, sizeof(cmd->proc_dir), "%s",
find_config_str(cmd->cf->root, "global/proc",
'/', DEFAULT_PROC_DIR)) < 0) {
find_config_str(cmd->cft->root, "global/proc",
DEFAULT_PROC_DIR)) < 0) {
log_error("Device directory given in config file too long");
return 0;
}
/* activation? */
cmd->default_settings.activation = find_config_int(cmd->cf->root,
cmd->default_settings.activation = find_config_int(cmd->cft->root,
"global/activation",
'/',
DEFAULT_ACTIVATION);
set_activation(cmd->default_settings.activation);
cmd->default_settings.suffix = find_config_int(cmd->cf->root,
cmd->default_settings.suffix = find_config_int(cmd->cft->root,
"global/suffix",
'/', DEFAULT_SUFFIX);
DEFAULT_SUFFIX);
if (!(cmd->default_settings.unit_factor =
units_to_bytes(find_config_str(cmd->cf->root,
units_to_bytes(find_config_str(cmd->cft->root,
"global/units",
'/',
DEFAULT_UNITS),
&cmd->default_settings.unit_type))) {
log_error("Invalid units specification");
@@ -190,7 +203,7 @@ static int _init_config(struct cmd_context *cmd)
struct stat info;
char config_file[PATH_MAX] = "";
if (!(cmd->cf = create_config_tree())) {
if (!(cmd->cft = create_config_tree())) {
stack;
return 0;
}
@@ -202,7 +215,7 @@ static int _init_config(struct cmd_context *cmd)
if (lvm_snprintf(config_file, sizeof(config_file),
"%s/lvm.conf", cmd->sys_dir) < 0) {
log_error("LVM_SYSTEM_DIR was too long");
destroy_config_tree(cmd->cf);
destroy_config_tree(cmd->cft);
return 0;
}
@@ -211,13 +224,13 @@ static int _init_config(struct cmd_context *cmd)
if (errno == ENOENT)
return 1;
log_sys_error("stat", config_file);
destroy_config_tree(cmd->cf);
destroy_config_tree(cmd->cft);
return 0;
}
if (!read_config_file(cmd->cf, config_file)) {
if (!read_config_file(cmd->cft, config_file)) {
log_error("Failed to load config file %s", config_file);
destroy_config_tree(cmd->cf);
destroy_config_tree(cmd->cft);
return 0;
}
@@ -234,7 +247,7 @@ static int _init_dev_cache(struct cmd_context *cmd)
return 0;
}
if (!(cn = find_config_node(cmd->cf->root, "devices/scan", '/'))) {
if (!(cn = find_config_node(cmd->cft->root, "devices/scan"))) {
if (!dev_cache_add_dir("/dev")) {
log_error("Failed to add /dev to internal "
"device cache");
@@ -273,14 +286,14 @@ static struct dev_filter *_init_filter_components(struct cmd_context *cmd)
memset(filters, 0, sizeof(filters));
/* sysfs filter */
if (find_config_bool(cmd->cf->root, "devices/sysfs_scan", '/',
if (find_config_bool(cmd->cft->root, "devices/sysfs_scan",
DEFAULT_SYSFS_SCAN)) {
if ((filters[nr_filt] = sysfs_filter_create(cmd->proc_dir)))
nr_filt++;
}
/* regex filter */
if (!(cn = find_config_node(cmd->cf->root, "devices/filter", '/')))
if (!(cn = find_config_node(cmd->cft->root, "devices/filter")))
log_debug("devices/filter not found in config file: no regex "
"filter installed");
@@ -290,7 +303,7 @@ static struct dev_filter *_init_filter_components(struct cmd_context *cmd)
}
/* device type filter */
cn = find_config_node(cmd->cf->root, "devices/types", '/');
cn = find_config_node(cmd->cft->root, "devices/types");
if (!(filters[nr_filt++] = lvm_type_filter_create(cmd->proc_dir, cn))) {
log_error("Failed to create lvm type filter");
return NULL;
@@ -321,21 +334,21 @@ static int _init_filters(struct cmd_context *cmd)
}
dev_cache =
find_config_str(cmd->cf->root, "devices/cache", '/', cache_file);
find_config_str(cmd->cft->root, "devices/cache", cache_file);
if (!(f4 = persistent_filter_create(f3, dev_cache))) {
log_error("Failed to create persistent device filter");
return 0;
}
/* Should we ever dump persistent filter state? */
if (find_config_int(cmd->cf->root, "devices/write_cache_state", '/', 1))
if (find_config_int(cmd->cft->root, "devices/write_cache_state", 1))
cmd->dump_filter = 1;
if (!*cmd->sys_dir)
cmd->dump_filter = 0;
if (!stat(dev_cache, &st) &&
(st.st_mtime > config_file_timestamp(cmd->cf)) &&
(st.st_mtime > config_file_timestamp(cmd->cft)) &&
!persistent_filter_load(f4))
log_verbose("Failed to load existing device cache from %s",
dev_cache);
@@ -367,8 +380,7 @@ static int _init_formats(struct cmd_context *cmd)
#ifdef HAVE_LIBDL
/* Load any formats in shared libs */
if ((cn = find_config_node(cmd->cf->root, "global/format_libraries",
'/'))) {
if ((cn = find_config_node(cmd->cft->root, "global/format_libraries"))) {
struct config_value *cv;
struct format_type *(*init_format_fn) (struct cmd_context *);
@@ -380,7 +392,7 @@ static int _init_formats(struct cmd_context *cmd)
"global/format_libraries");
return 0;
}
if (!(lib = load_shared_library(cmd->cf, cv->v.str,
if (!(lib = load_shared_library(cmd->cft, cv->v.str,
"format"))) {
stack;
return 0;
@@ -408,7 +420,7 @@ static int _init_formats(struct cmd_context *cmd)
cmd->fmt_backup = fmt;
format = find_config_str(cmd->cf->root, "global/format", '/',
format = find_config_str(cmd->cft->root, "global/format",
DEFAULT_FORMAT);
list_iterate(fmth, &cmd->formats) {
@@ -424,6 +436,122 @@ static int _init_formats(struct cmd_context *cmd)
return 0;
}
static int _init_hostname(struct cmd_context *cmd)
{
struct utsname uts;
if (uname(&uts)) {
log_sys_error("uname", "_init_hostname");
return 0;
}
if (!(cmd->hostname = pool_strdup(cmd->libmem, uts.nodename))) {
log_error("_init_hostname: pool_strdup failed");
return 0;
}
return 1;
}
static int _set_tag(struct cmd_context *cmd, const char *tag)
{
log_very_verbose("Setting host tag: %s", pool_strdup(cmd->libmem, tag));
if (!str_list_add(cmd->libmem, &cmd->tags, tag)) {
log_error("_init_tags: str_list_add %s failed", tag);
return 0;
}
return 1;
}
static int _check_host_filters(struct cmd_context *cmd, struct config_node *hn,
int *passes)
{
struct config_node *cn;
struct config_value *cv;
*passes = 1;
for (cn = hn; cn; cn = cn->sib) {
if (!cn->v)
continue;
if (!strcmp(cn->key, "host_list")) {
*passes = 0;
if (cn->v->type == CFG_EMPTY_ARRAY)
continue;
for (cv = cn->v; cv; cv = cv->next) {
if (cv->type != CFG_STRING) {
log_error("Invalid hostname string "
"for tag %s", cn->key);
return 0;
}
if (!strcmp(cv->v.str, cmd->hostname)) {
*passes = 1;
return 1;
}
}
}
if (!strcmp(cn->key, "host_filter")) {
log_error("host_filter not supported yet");
return 0;
}
}
return 1;
}
static int _init_tags(struct cmd_context *cmd)
{
struct config_node *tn, *cn;
const char *tag;
int passes;
list_init(&cmd->tags);
if (!(tn = find_config_node(cmd->cft->root, "tags")) ||
!tn->child) {
log_very_verbose("No tags defined in config file");
return 1;
}
if (find_config_int(cmd->cft->root, "tags/hosttags",
DEFAULT_HOSTTAGS)) {
/* FIXME Strip out invalid chars: only A-Za-z0-9_+.- */
if (!_set_tag(cmd, cmd->hostname)) {
stack;
return 0;
}
}
for (cn = tn->child; cn; cn = cn->sib) {
if (cn->v)
continue;
tag = cn->key;
if (*tag == '@')
tag++;
if (!validate_name(tag)) {
log_error("Invalid tag in config file: %s", cn->key);
return 0;
}
if (cn->child) {
passes = 0;
if (!_check_host_filters(cmd, cn->child, &passes)) {
stack;
return 0;
}
if (!passes)
continue;
}
if (!_set_tag(cmd, tag)) {
stack;
return 0;
}
}
return 1;
}
/* Entry point */
struct cmd_context *create_toolcontext(struct arg *the_args)
{
@@ -464,6 +592,11 @@ struct cmd_context *create_toolcontext(struct arg *the_args)
_init_logging(cmd);
if (!(cmd->libmem = pool_create(4 * 1024))) {
log_error("Library memory pool creation failed");
return 0;
}
if (!_process_config(cmd))
goto error;
@@ -483,6 +616,12 @@ struct cmd_context *create_toolcontext(struct arg *the_args)
if (!_init_formats(cmd))
goto error;
if (!_init_hostname(cmd))
goto error;
if (!_init_tags(cmd))
goto error;
cmd->current_settings = cmd->default_settings;
return cmd;
@@ -492,6 +631,16 @@ struct cmd_context *create_toolcontext(struct arg *the_args)
return NULL;
}
int refresh_toolcontext(struct cmd_context *cmd)
{
_init_logging(cmd);
_init_tags(cmd);
/* FIXME Reset filters and dev_cache */
return 1;
}
static void _destroy_formats(struct list *formats)
{
struct list *fmtl, *tmp;
@@ -522,7 +671,8 @@ void destroy_toolcontext(struct cmd_context *cmd)
cmd->filter->destroy(cmd->filter);
pool_destroy(cmd->mem);
dev_cache_exit();
destroy_config_tree(cmd->cf);
destroy_config_tree(cmd->cft);
pool_destroy(cmd->libmem);
dbg_free(cmd);
release_log_memory();

View File

@@ -1,8 +1,16 @@
/*
* Copyright (C) 2001 Sistina Software (UK) Limited.
* Copyright (C) 2001-2004 Sistina Software, Inc. All rights reserved.
* Copyright (C) 2004 Red Hat, Inc. All rights reserved.
*
* This file is released under the LGPL.
* This file is part of LVM2.
*
* This copyrighted material is made available to anyone wishing to use,
* modify, copy, or redistribute it subject to the terms and conditions
* of the GNU General Public License v.2.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software Foundation,
* Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
#ifndef _LVM_TOOLCONTEXT_H
@@ -42,13 +50,14 @@ struct config_info {
/* FIXME Split into tool & library contexts */
/* command-instance-related variables needed by library */
struct cmd_context {
/* format handler allocates all objects from here */
struct pool *mem;
struct pool *libmem; /* For permanent config data */
struct pool *mem; /* Transient: Cleared between each command */
const struct format_type *fmt; /* Current format to use by default */
struct format_type *fmt_backup; /* Format to use for backups */
struct list formats; /* Available formats */
const char *hostname;
char *cmd_line;
struct command *command;
@@ -58,10 +67,13 @@ struct cmd_context {
struct dev_filter *filter;
int dump_filter; /* Dump filter when exiting? */
struct config_tree *cf;
struct config_tree *cft;
struct config_info default_settings;
struct config_info current_settings;
/* List of defined tags */
struct list tags;
char sys_dir[PATH_MAX];
char dev_dir[PATH_MAX];
char proc_dir[PATH_MAX];
@@ -69,5 +81,6 @@ struct cmd_context {
struct cmd_context *create_toolcontext(struct arg *the_args);
void destroy_toolcontext(struct cmd_context *cmd);
int refresh_toolcontext(struct cmd_context *cmd);
#endif

View File

@@ -1,7 +1,16 @@
/*
* Copyright (C) 2001 Sistina Software (UK) Limited.
* Copyright (C) 2001-2004 Sistina Software, Inc. All rights reserved.
* Copyright (C) 2004 Red Hat, Inc. All rights reserved.
*
* This file is released under the LGPL.
* This file is part of LVM2.
*
* This copyrighted material is made available to anyone wishing to use,
* modify, copy, or redistribute it subject to the terms and conditions
* of the GNU General Public License v.2.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software Foundation,
* Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
#include "lib.h"
@@ -43,7 +52,7 @@ struct parser {
};
struct cs {
struct config_tree cf;
struct config_tree cft;
struct pool *mem;
time_t timestamp;
char *filename;
@@ -60,6 +69,8 @@ static struct config_value *_create_value(struct parser *p);
static struct config_node *_create_node(struct parser *p);
static char *_dup_tok(struct parser *p);
static const int sep = '/';
#define MAX_INDENT 32
#define match(t) do {\
@@ -99,22 +110,22 @@ struct config_tree *create_config_tree(void)
}
c->mem = mem;
c->cf.root = (struct config_node *) NULL;
c->cft.root = (struct config_node *) NULL;
c->timestamp = 0;
c->filename = NULL;
return &c->cf;
return &c->cft;
}
void destroy_config_tree(struct config_tree *cf)
void destroy_config_tree(struct config_tree *cft)
{
pool_destroy(((struct cs *) cf)->mem);
pool_destroy(((struct cs *) cft)->mem);
}
int read_config_fd(struct config_tree *cf, struct device *dev,
int read_config_fd(struct config_tree *cft, struct device *dev,
off_t offset, size_t size, off_t offset2, size_t size2,
checksum_fn_t checksum_fn, uint32_t checksum)
{
struct cs *c = (struct cs *) cf;
struct cs *c = (struct cs *) cft;
struct parser *p;
int r = 0;
int use_mmap = 1;
@@ -172,7 +183,7 @@ int read_config_fd(struct config_tree *cf, struct device *dev,
p->tb = p->te = p->fb;
p->line = 1;
_get_token(p, TOK_SECTION_E);
if (!(cf->root = _file(p))) {
if (!(cft->root = _file(p))) {
stack;
goto out;
}
@@ -193,9 +204,9 @@ int read_config_fd(struct config_tree *cf, struct device *dev,
return r;
}
int read_config_file(struct config_tree *cf, const char *file)
int read_config_file(struct config_tree *cft, const char *file)
{
struct cs *c = (struct cs *) cf;
struct cs *c = (struct cs *) cft;
struct stat info;
struct device *dev;
int r = 1;
@@ -225,7 +236,7 @@ int read_config_file(struct config_tree *cf, const char *file)
return 0;
}
r = read_config_fd(cf, dev, 0, (size_t) info.st_size, 0, 0,
r = read_config_fd(cft, dev, 0, (size_t) info.st_size, 0, 0,
(checksum_fn_t) NULL, 0);
dev_close(dev);
@@ -236,9 +247,9 @@ int read_config_file(struct config_tree *cf, const char *file)
return r;
}
time_t config_file_timestamp(struct config_tree *cf)
time_t config_file_timestamp(struct config_tree *cft)
{
struct cs *c = (struct cs *) cf;
struct cs *c = (struct cs *) cft;
return c->timestamp;
}
@@ -246,10 +257,10 @@ time_t config_file_timestamp(struct config_tree *cf)
/*
* Returns 1 if config file reloaded
*/
int reload_config_file(struct config_tree **cf)
int reload_config_file(struct config_tree **cft)
{
struct config_tree *new_cf;
struct cs *c = (struct cs *) *cf;
struct config_tree *new_cft;
struct cs *c = (struct cs *) *cft;
struct cs *new_cs;
struct stat info;
struct device *dev;
@@ -283,7 +294,7 @@ int reload_config_file(struct config_tree **cf)
return 0;
}
if (!(new_cf = create_config_tree())) {
if (!(new_cft = create_config_tree())) {
log_error("Allocation of new config_tree failed");
return 0;
}
@@ -298,17 +309,17 @@ int reload_config_file(struct config_tree **cf)
return 0;
}
r = read_config_fd(new_cf, dev, 0, (size_t) info.st_size,
r = read_config_fd(new_cft, dev, 0, (size_t) info.st_size,
0, 0, (checksum_fn_t) NULL, 0);
dev_close(dev);
if (r) {
new_cs = (struct cs *) new_cf;
new_cs = (struct cs *) new_cft;
new_cs->filename = pool_strdup(new_cs->mem, c->filename);
new_cs->timestamp = info.st_mtime;
destroy_config_tree(*cf);
*cf = new_cf;
destroy_config_tree(*cft);
*cft = new_cft;
}
return r;
@@ -382,7 +393,7 @@ static int _write_config(struct config_node *n, FILE *fp, int level)
return 1;
}
int write_config_file(struct config_tree *cf, const char *file)
int write_config_file(struct config_tree *cft, const char *file)
{
int r = 1;
FILE *fp;
@@ -396,7 +407,7 @@ int write_config_file(struct config_tree *cf, const char *file)
}
log_verbose("Dumping configuration to %s", file);
if (!_write_config(cf->root, fp, 0)) {
if (!_write_config(cft->root, fp, 0)) {
log_error("Failure while writing configuration");
r = 0;
}
@@ -728,8 +739,7 @@ static char *_dup_tok(struct parser *p)
/*
* utility functions
*/
struct config_node *find_config_node(struct config_node *cn,
const char *path, const int sep)
struct config_node *find_config_node(struct config_node *cn, const char *path)
{
const char *e;
@@ -761,9 +771,9 @@ struct config_node *find_config_node(struct config_node *cn,
}
const char *find_config_str(struct config_node *cn,
const char *path, const int sep, const char *fail)
const char *path, const char *fail)
{
struct config_node *n = find_config_node(cn, path, sep);
struct config_node *n = find_config_node(cn, path);
if (n && n->v->type == CFG_STRING) {
if (*n->v->v.str)
@@ -777,10 +787,9 @@ const char *find_config_str(struct config_node *cn,
return fail;
}
int find_config_int(struct config_node *cn, const char *path,
const int sep, int fail)
int find_config_int(struct config_node *cn, const char *path, int fail)
{
struct config_node *n = find_config_node(cn, path, sep);
struct config_node *n = find_config_node(cn, path);
if (n && n->v->type == CFG_INT) {
log_very_verbose("Setting %s to %d", path, n->v->v.i);
@@ -792,10 +801,9 @@ int find_config_int(struct config_node *cn, const char *path,
return fail;
}
float find_config_float(struct config_node *cn, const char *path,
const int sep, float fail)
float find_config_float(struct config_node *cn, const char *path, float fail)
{
struct config_node *n = find_config_node(cn, path, sep);
struct config_node *n = find_config_node(cn, path);
if (n && n->v->type == CFG_FLOAT) {
log_very_verbose("Setting %s to %f", path, n->v->v.r);
@@ -835,10 +843,9 @@ static int _str_to_bool(const char *str, int fail)
return fail;
}
int find_config_bool(struct config_node *cn, const char *path,
const int sep, int fail)
int find_config_bool(struct config_node *cn, const char *path, int fail)
{
struct config_node *n = find_config_node(cn, path, sep);
struct config_node *n = find_config_node(cn, path);
struct config_value *v;
if (!n)
@@ -858,11 +865,11 @@ int find_config_bool(struct config_node *cn, const char *path,
}
int get_config_uint32(struct config_node *cn, const char *path,
const int sep, uint32_t *result)
uint32_t *result)
{
struct config_node *n;
n = find_config_node(cn, path, sep);
n = find_config_node(cn, path);
if (!n || !n->v || n->v->type != CFG_INT)
return 0;
@@ -872,11 +879,11 @@ int get_config_uint32(struct config_node *cn, const char *path,
}
int get_config_uint64(struct config_node *cn, const char *path,
const int sep, uint64_t *result)
uint64_t *result)
{
struct config_node *n;
n = find_config_node(cn, path, sep);
n = find_config_node(cn, path);
if (!n || !n->v || n->v->type != CFG_INT)
return 0;
@@ -886,12 +893,11 @@ int get_config_uint64(struct config_node *cn, const char *path,
return 1;
}
int get_config_str(struct config_node *cn, const char *path,
const int sep, char **result)
int get_config_str(struct config_node *cn, const char *path, char **result)
{
struct config_node *n;
n = find_config_node(cn, path, sep);
n = find_config_node(cn, path);
if (!n || !n->v || n->v->type != CFG_STRING)
return 0;

View File

@@ -1,7 +1,16 @@
/*
* Copyright (C) 2001 Sistina Software (UK) Limited.
* Copyright (C) 2001-2004 Sistina Software, Inc. All rights reserved.
* Copyright (C) 2004 Red Hat, Inc. All rights reserved.
*
* This file is released under the LGPL.
* This file is part of LVM2.
*
* This copyrighted material is made available to anyone wishing to use,
* modify, copy, or redistribute it subject to the terms and conditions
* of the GNU General Public License v.2.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software Foundation,
* Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
#ifndef _LVM_CONFIG_H
@@ -51,31 +60,27 @@ int reload_config_file(struct config_tree **cf);
time_t config_file_timestamp(struct config_tree *cf);
struct config_node *find_config_node(struct config_node *cn,
const char *path, const int separator);
const char *path);
const char *find_config_str(struct config_node *cn,
const char *path, const int sep, const char *fail);
const char *find_config_str(struct config_node *cn, const char *path,
const char *fail);
int find_config_int(struct config_node *cn, const char *path,
const int sep, int fail);
int find_config_int(struct config_node *cn, const char *path, int fail);
float find_config_float(struct config_node *cn, const char *path,
const int sep, float fail);
float find_config_float(struct config_node *cn, const char *path, float fail);
/*
* Understands (0, ~0), (y, n), (yes, no), (on,
* off), (true, false).
*/
int find_config_bool(struct config_node *cn, const char *path,
const int sep, int fail);
int find_config_bool(struct config_node *cn, const char *path, int fail);
int get_config_uint32(struct config_node *cn, const char *path,
const int sep, uint32_t *result);
uint32_t *result);
int get_config_uint64(struct config_node *cn, const char *path,
const int sep, uint64_t *result);
uint64_t *result);
int get_config_str(struct config_node *cn, const char *path,
const int sep, char **result);
int get_config_str(struct config_node *cn, const char *path, char **result);
#endif

View File

@@ -1,7 +1,16 @@
/*
* Copyright (C) 2001 Sistina Software (UK) Limited.
* Copyright (C) 2001-2004 Sistina Software, Inc. All rights reserved.
* Copyright (C) 2004 Red Hat, Inc. All rights reserved.
*
* This file is released under the GPL.
* This file is part of LVM2.
*
* This copyrighted material is made available to anyone wishing to use,
* modify, copy, or redistribute it subject to the terms and conditions
* of the GNU General Public License v.2.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software Foundation,
* Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
#ifndef _LVM_DEFAULTS_H
@@ -51,6 +60,7 @@
#define DEFAULT_INDENT 1
#define DEFAULT_UNITS "h"
#define DEFAULT_SUFFIX 1
#define DEFAULT_HOSTTAGS 0
#ifdef DEVMAPPER_SUPPORT
# define DEFAULT_ACTIVATION 1

View File

@@ -1,7 +1,16 @@
/*
* Copyright (C) 2001 Sistina Software (UK) Limited.
* Copyright (C) 2001-2004 Sistina Software, Inc. All rights reserved.
* Copyright (C) 2004 Red Hat, Inc. All rights reserved.
*
* This file is released under the LGPL.
* This file is part of LVM2.
*
* This copyrighted material is made available to anyone wishing to use,
* modify, copy, or redistribute it subject to the terms and conditions
* of the GNU General Public License v.2.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software Foundation,
* Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
#include "lib.h"

View File

@@ -1,7 +1,16 @@
/*
* Copyright (C) 2001 Sistina Software (UK) Limited.
* Copyright (C) 2001-2004 Sistina Software, Inc. All rights reserved.
* Copyright (C) 2004 Red Hat, Inc. All rights reserved.
*
* This file is released under the GPL.
* This file is part of LVM2.
*
* This copyrighted material is made available to anyone wishing to use,
* modify, copy, or redistribute it subject to the terms and conditions
* of the GNU General Public License v.2.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software Foundation,
* Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
#ifndef _LVM_BITSET_H

View File

@@ -1,7 +1,16 @@
/*
* Copyright (C) 2001 Sistina Software (UK) Limited.
* Copyright (C) 2001-2004 Sistina Software, Inc. All rights reserved.
* Copyright (C) 2004 Red Hat, Inc. All rights reserved.
*
* This file is released under the LGPL.
* This file is part of LVM2.
*
* This copyrighted material is made available to anyone wishing to use,
* modify, copy, or redistribute it subject to the terms and conditions
* of the GNU General Public License v.2.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software Foundation,
* Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
#include "lib.h"

View File

@@ -1,7 +1,16 @@
/*
* Copyright (C) 2001 Sistina Software (UK) Limited.
* Copyright (C) 2001-2004 Sistina Software, Inc. All rights reserved.
* Copyright (C) 2004 Red Hat, Inc. All rights reserved.
*
* This file is released under the GPL.
* This file is part of LVM2.
*
* This copyrighted material is made available to anyone wishing to use,
* modify, copy, or redistribute it subject to the terms and conditions
* of the GNU General Public License v.2.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software Foundation,
* Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
#ifndef _LVM_BTREE_H

View File

@@ -1,7 +1,16 @@
/*
* Copyright (C) 2001 Sistina Software
* Copyright (C) 2001-2004 Sistina Software, Inc. All rights reserved.
* Copyright (C) 2004 Red Hat, Inc. All rights reserved.
*
* This file is released under the LGPL.
* This file is part of LVM2.
*
* This copyrighted material is made available to anyone wishing to use,
* modify, copy, or redistribute it subject to the terms and conditions
* of the GNU General Public License v.2.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software Foundation,
* Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
#include "lib.h"

View File

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

View File

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

View File

@@ -1,7 +1,16 @@
/*
* Copyright (C) 2001 Sistina Software (UK) Limited.
* Copyright (C) 2001-2004 Sistina Software, Inc. All rights reserved.
* Copyright (C) 2004 Red Hat, Inc. All rights reserved.
*
* This file is released under the GPL.
* This file is part of LVM2.
*
* This copyrighted material is made available to anyone wishing to use,
* modify, copy, or redistribute it subject to the terms and conditions
* of the GNU General Public License v.2.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software Foundation,
* Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
#ifndef _LVM_TYPES_H

View File

@@ -1,7 +1,16 @@
/*
* Copyright (C) 2003 Sistina Software
* Copyright (C) 2003-2004 Sistina Software, Inc. All rights reserved.
* Copyright (C) 2004 Red Hat, Inc. All rights reserved.
*
* This file is released under the LGPL.
* This file is part of LVM2.
*
* This copyrighted material is made available to anyone wishing to use,
* modify, copy, or redistribute it subject to the terms and conditions
* of the GNU General Public License v.2.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software Foundation,
* Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
#include "lib.h"
@@ -57,6 +66,25 @@ int str_list_del(struct list *sll, const char *str)
return 1;
}
int str_list_dup(struct pool *mem, struct list *sllnew, struct list *sllold)
{
struct str_list *sl;
list_init(sllnew);
list_iterate_items(sl, sllold) {
if (!str_list_add(mem, sllnew, strdup(sl->str))) {
stack;
return 0;
}
}
return 1;
}
/*
* Is item on list?
*/
int str_list_match_item(struct list *sll, const char *str)
{
struct str_list *sl;
@@ -68,6 +96,9 @@ int str_list_match_item(struct list *sll, const char *str)
return 0;
}
/*
* Is at least one item on both lists?
*/
int str_list_match_list(struct list *sll, struct list *sll2)
{
struct str_list *sl;
@@ -78,3 +109,20 @@ int str_list_match_list(struct list *sll, struct list *sll2)
return 0;
}
/*
* Do both lists contain the same set of items?
*/
int str_list_lists_equal(struct list *sll, struct list *sll2)
{
struct str_list *sl;
if (list_size(sll) != list_size(sll2))
return 0;
list_iterate_items(sl, sll)
if (!str_list_match_item(sll2, sl->str))
return 0;
return 1;
}

View File

@@ -1,7 +1,16 @@
/*
* Copyright (C) 2003 Sistina Software (UK) Limited.
* Copyright (C) 2003-2004 Sistina Software, Inc. All rights reserved.
* Copyright (C) 2004 Red Hat, Inc. All rights reserved.
*
* This file is released under the GPL.
* This file is part of LVM2.
*
* This copyrighted material is made available to anyone wishing to use,
* modify, copy, or redistribute it subject to the terms and conditions
* of the GNU General Public License v.2.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software Foundation,
* Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
#ifndef _LVM_STR_LIST_H
@@ -14,5 +23,7 @@ int str_list_add(struct pool *mem, struct list *sll, const char *str);
int str_list_del(struct list *sll, const char *str);
int str_list_match_item(struct list *sll, const char *str);
int str_list_match_list(struct list *sll, struct list *sll2);
int str_list_lists_equal(struct list *sll, struct list *sll2);
int str_list_dup(struct pool *mem, struct list *sllnew, struct list *sllold);
#endif

View File

@@ -1,7 +1,16 @@
/*
* Copyright (C) 2001 Sistina Software (UK) Limited.
* Copyright (C) 2001-2004 Sistina Software, Inc. All rights reserved.
* Copyright (C) 2004 Red Hat, Inc. All rights reserved.
*
* This file is released under the LGPL.
* This file is part of LVM2.
*
* This copyrighted material is made available to anyone wishing to use,
* modify, copy, or redistribute it subject to the terms and conditions
* of the GNU General Public License v.2.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software Foundation,
* Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
#include "lib.h"

View File

@@ -1,7 +1,16 @@
/*
* Copyright (C) 2001 Sistina Software (UK) Limited.
* Copyright (C) 2001-2004 Sistina Software, Inc. All rights reserved.
* Copyright (C) 2004 Red Hat, Inc. All rights reserved.
*
* This file is released under the GPL.
* This file is part of LVM2.
*
* This copyrighted material is made available to anyone wishing to use,
* modify, copy, or redistribute it subject to the terms and conditions
* of the GNU General Public License v.2.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software Foundation,
* Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
#ifndef _LVM_DEV_CACHE_H

View File

@@ -1,7 +1,16 @@
/*
* Copyright (C) 2001 Sistina Software
* Copyright (C) 2001-2004 Sistina Software, Inc. All rights reserved.
* Copyright (C) 2004 Red Hat, Inc. All rights reserved.
*
* This file is released under the LGPL.
* This file is part of LVM2.
*
* This copyrighted material is made available to anyone wishing to use,
* modify, copy, or redistribute it subject to the terms and conditions
* of the GNU General Public License v.2.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software Foundation,
* Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
#include "lib.h"

View File

@@ -1,20 +1,16 @@
/*
* Copyright (C) 2001 Sistina Software
* Copyright (C) 2001-2004 Sistina Software, Inc. All rights reserved.
* Copyright (C) 2004 Red Hat, Inc. All rights reserved.
*
* This LVM library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Library General Public
* License as published by the Free Software Foundation; either
* version 2 of the License, or (at your option) any later version.
* This file is part of LVM2.
*
* This LVM library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Library General Public License for more details.
* 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 Library General Public
* License along with this LVM library; if not, write to the Free
* Software Foundation, Inc., 59 Temple Place - Suite 330, Boston,
* MA 02111-1307, USA
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software Foundation,
* Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
#if 0

View File

@@ -1,7 +1,16 @@
/*
* Copyright (C) 2001 Sistina Software (UK) Limited.
* Copyright (C) 2001-2004 Sistina Software, Inc. All rights reserved.
* Copyright (C) 2004 Red Hat, Inc. All rights reserved.
*
* This file is released under the GPL.
* This file is part of LVM2.
*
* This copyrighted material is made available to anyone wishing to use,
* modify, copy, or redistribute it subject to the terms and conditions
* of the GNU General Public License v.2.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software Foundation,
* Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
#ifndef _LVM_DEVICE_H

View File

@@ -1,21 +1,16 @@
/*
* Copyright (C) 2001 Sistina Software
* Copyright (C) 2001-2004 Sistina Software, Inc. All rights reserved.
* Copyright (C) 2004 Red Hat, Inc. All rights reserved.
*
* This LVM library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Library General Public
* License as published by the Free Software Foundation; either
* version 2 of the License, or (at your option) any later version.
* This file is part of LVM2.
*
* This LVM library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Library General Public License for more details.
*
* You should have received a copy of the GNU Library General Public
* License along with this LVM library; if not, write to the Free
* Software Foundation, Inc., 59 Temple Place - Suite 330, Boston,
* MA 02111-1307, USA
* This copyrighted material is made available to anyone wishing to use,
* modify, copy, or redistribute it subject to the terms and conditions
* of the GNU General Public License v.2.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software Foundation,
* Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
#include "lib.h"
@@ -659,6 +654,53 @@ void vgdisplay_full(struct volume_group *vg)
void vgdisplay_colons(struct volume_group *vg)
{
uint32_t active_pvs;
const char *access;
char uuid[64];
if (vg->status & PARTIAL_VG)
active_pvs = list_size(&vg->pvs);
else
active_pvs = vg->pv_count;
switch (vg->status & (LVM_READ | LVM_WRITE)) {
case LVM_READ | LVM_WRITE:
access = "r/w";
break;
case LVM_READ:
access = "r";
break;
case LVM_WRITE:
access = "w";
break;
default:
access = "";
}
if (!id_write_format(&vg->id, uuid, sizeof(uuid))) {
stack;
return;
}
log_print("%s:%s:%d:-1:%u:%u:%u:-1:%u:%u:%u:%" PRIu64 ":%" PRIu32
":%u:%u:%u:%s",
vg->name,
access,
vg->status,
/* internal volume group number; obsolete */
vg->max_lv,
vg->lv_count,
lvs_in_vg_opened(vg),
/* FIXME: maximum logical volume size */
vg->max_pv,
vg->pv_count,
active_pvs,
(uint64_t) vg->extent_count * (vg->extent_size / 2),
vg->extent_size / 2,
vg->extent_count,
vg->extent_count - vg->free_count,
vg->free_count,
uuid[0] ? uuid : "none");
return;
}

View File

@@ -1,21 +1,16 @@
/*
* Copyright (C) 2001 Sistina Software
* Copyright (C) 2001-2004 Sistina Software, Inc. All rights reserved.
* Copyright (C) 2004 Red Hat, Inc. All rights reserved.
*
* This LVM library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Library General Public
* License as published by the Free Software Foundation; either
* version 2 of the License, or (at your option) any later version.
* This file is part of LVM2.
*
* This LVM library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Library General Public License for more details.
*
* You should have received a copy of the GNU Library General Public
* License along with this LVM library; if not, write to the Free
* Software Foundation, Inc., 59 Temple Place - Suite 330, Boston,
* MA 02111-1307, USA
* This copyrighted material is made available to anyone wishing to use,
* modify, copy, or redistribute it subject to the terms and conditions
* of the GNU General Public License v.2.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software Foundation,
* Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
#ifndef _LVM_DISPLAY_H

View File

@@ -1,7 +1,16 @@
/*
* Copyright (C) 2001 Sistina Software (UK) Limited.
* Copyright (C) 2001-2004 Sistina Software, Inc. All rights reserved.
* Copyright (C) 2004 Red Hat, Inc. All rights reserved.
*
* This file is released under the LGPL.
* This file is part of LVM2.
*
* This copyrighted material is made available to anyone wishing to use,
* modify, copy, or redistribute it subject to the terms and conditions
* of the GNU General Public License v.2.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software Foundation,
* Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
#include "lib.h"

View File

@@ -1,7 +1,16 @@
/*
* Copyright (C) 2001 Sistina Software (UK) Limited.
* Copyright (C) 2001-2004 Sistina Software, Inc. All rights reserved.
* Copyright (C) 2004 Red Hat, Inc. All rights reserved.
*
* This file is released under the GPL.
* This file is part of LVM2.
*
* This copyrighted material is made available to anyone wishing to use,
* modify, copy, or redistribute it subject to the terms and conditions
* of the GNU General Public License v.2.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software Foundation,
* Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
#ifndef _LVM_FILTER_COMPOSITE_H

View File

@@ -1,7 +1,16 @@
/*
* Copyright (C) 2001 Sistina Software (UK) Limited.
* Copyright (C) 2001-2004 Sistina Software, Inc. All rights reserved.
* Copyright (C) 2004 Red Hat, Inc. All rights reserved.
*
* This file is released under the LGPL.
* This file is part of LVM2.
*
* This copyrighted material is made available to anyone wishing to use,
* modify, copy, or redistribute it subject to the terms and conditions
* of the GNU General Public License v.2.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software Foundation,
* Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
#include "lib.h"
@@ -51,13 +60,13 @@ int persistent_filter_wipe(struct dev_filter *f)
return 1;
}
static int _read_array(struct pfilter *pf, struct config_tree *cf,
static int _read_array(struct pfilter *pf, struct config_tree *cft,
const char *path, void *data)
{
struct config_node *cn;
struct config_value *cv;
if (!(cn = find_config_node(cf->root, path, '/'))) {
if (!(cn = find_config_node(cft->root, path))) {
log_very_verbose("Couldn't find %s array in '%s'",
path, pf->file);
return 0;
@@ -88,22 +97,22 @@ int persistent_filter_load(struct dev_filter *f)
struct pfilter *pf = (struct pfilter *) f->private;
int r = 0;
struct config_tree *cf;
struct config_tree *cft;
if (!(cf = create_config_tree())) {
if (!(cft = create_config_tree())) {
stack;
return 0;
}
if (!read_config_file(cf, pf->file)) {
if (!read_config_file(cft, pf->file)) {
stack;
goto out;
}
_read_array(pf, cf, "persistent_filter_cache/valid_devices",
_read_array(pf, cft, "persistent_filter_cache/valid_devices",
PF_GOOD_DEVICE);
/* We don't gain anything by holding invalid devices */
/* _read_array(pf, cf, "persistent_filter_cache/invalid_devices",
/* _read_array(pf, cft, "persistent_filter_cache/invalid_devices",
PF_BAD_DEVICE); */
/* Did we find anything? */
@@ -116,7 +125,7 @@ int persistent_filter_load(struct dev_filter *f)
log_very_verbose("Loaded persistent filter cache from %s", pf->file);
out:
destroy_config_tree(cf);
destroy_config_tree(cft);
return r;
}

View File

@@ -1,7 +1,16 @@
/*
* Copyright (C) 2001 Sistina Software (UK) Limited.
* Copyright (C) 2001-2004 Sistina Software, Inc. All rights reserved.
* Copyright (C) 2004 Red Hat, Inc. All rights reserved.
*
* This file is released under the GPL.
* This file is part of LVM2.
*
* This copyrighted material is made available to anyone wishing to use,
* modify, copy, or redistribute it subject to the terms and conditions
* of the GNU General Public License v.2.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software Foundation,
* Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
#ifndef _LVM_FILTER_PERSISTENT_H

View File

@@ -1,7 +1,16 @@
/*
* Copyright (C) 2001 Sistina Software (UK) Limited.
* Copyright (C) 2001-2004 Sistina Software, Inc. All rights reserved.
* Copyright (C) 2004 Red Hat, Inc. All rights reserved.
*
* This file is released under the LGPL.
* This file is part of LVM2.
*
* This copyrighted material is made available to anyone wishing to use,
* modify, copy, or redistribute it subject to the terms and conditions
* of the GNU General Public License v.2.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software Foundation,
* Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
#include "lib.h"
@@ -42,7 +51,7 @@ static int _extract_pattern(struct pool *mem, const char *pat,
pat++;
/*
* get the seperator
* get the separator
*/
switch (*pat) {
case '(':
@@ -75,7 +84,7 @@ static int _extract_pattern(struct pool *mem, const char *pat,
*/
ptr = r + strlen(r) - 1;
if (*ptr != sep) {
log_info("invalid seperator at end of regex");
log_info("invalid separator at end of regex");
return 0;
}
*ptr = '\0';

View File

@@ -1,7 +1,16 @@
/*
* Copyright (C) 2001 Sistina Software (UK) Limited.
* Copyright (C) 2001-2004 Sistina Software, Inc. All rights reserved.
* Copyright (C) 2004 Red Hat, Inc. All rights reserved.
*
* This file is released under the GPL.
* This file is part of LVM2.
*
* This copyrighted material is made available to anyone wishing to use,
* modify, copy, or redistribute it subject to the terms and conditions
* of the GNU General Public License v.2.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software Foundation,
* Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
#ifndef _LVM_FILTER_REGEX_H

View File

@@ -1,7 +1,15 @@
/*
* Copyright (C) 2004 Red Hat Inc
* Copyright (C) 2004 Red Hat, Inc. All rights reserved.
*
* This file is released under the GPL.
* This file is part of LVM2.
*
* This copyrighted material is made available to anyone wishing to use,
* modify, copy, or redistribute it subject to the terms and conditions
* of the GNU General Public License v.2.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software Foundation,
* Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
#include "lib.h"
@@ -9,9 +17,8 @@
#include "lvm-string.h"
#include "pool.h"
#include <sys/sysmacros.h>
#include <sys/param.h>
#include <sys/types.h>
#ifdef linux
#include <dirent.h>
static int _locate_sysfs_blocks(const char *proc, char *path, size_t len)
@@ -271,3 +278,11 @@ struct dev_filter *sysfs_filter_create(const char *proc)
return NULL;
}
#else
struct dev_filter *sysfs_filter_create(const char *proc)
{
return NULL;
}
#endif

View File

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

View File

@@ -1,21 +1,16 @@
/*
* Copyright (C) 2001 Sistina Software
* Copyright (C) 2001-2004 Sistina Software, Inc. All rights reserved.
* Copyright (C) 2004 Red Hat, Inc. All rights reserved.
*
* lvm is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2, or (at your option)
* any later version.
* This file is part of LVM2.
*
* lvm is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
* 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 GNU CC; see the file COPYING. If not, write to
* the Free Software Foundation, 59 Temple Place - Suite 330,
* Boston, MA 02111-1307, USA.
*
* along with this program; if not, write to the Free Software Foundation,
* Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
#include "lib.h"

View File

@@ -1,21 +1,16 @@
/*
* Copyright (C) 2001 Sistina Software
* Copyright (C) 2001-2004 Sistina Software, Inc. All rights reserved.
* Copyright (C) 2004 Red Hat, Inc. All rights reserved.
*
* lvm is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2, or (at your option)
* any later version.
* This file is part of LVM2.
*
* lvm is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
* 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 GNU CC; see the file COPYING. If not, write to
* the Free Software Foundation, 59 Temple Place - Suite 330,
* Boston, MA 02111-1307, USA.
*
* along with this program; if not, write to the Free Software Foundation,
* Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
#ifndef _LVM_FILTER_H

View File

@@ -1,7 +0,0 @@
Base {
global:
init_format;
local:
*;
};

View File

@@ -0,0 +1 @@
init_format

View File

@@ -1,14 +1,22 @@
#
# Copyright (C) 2002 Sistina Software (UK) Limited.
# Copyright (C) 2002-2004 Sistina Software, Inc. All rights reserved.
# Copyright (C) 2004 Red Hat, Inc. All rights reserved.
#
# This file is released under the LGPL.
# This file is part of the LVM2.
#
# This copyrighted material is made available to anyone wishing to use,
# modify, copy, or redistribute it subject to the terms and conditions
# of the GNU General Public License v.2.
#
# You should have received a copy of the GNU General Public License
# along with this program; if not, write to the Free Software Foundation,
# Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
srcdir = @srcdir@
top_srcdir = @top_srcdir@
VPATH = @srcdir@
SOURCES=\
SOURCES =\
disk-rep.c \
format1.c \
import-export.c \
@@ -17,15 +25,14 @@ SOURCES=\
lvm1-label.c \
vg_number.c
TARGETS=liblvm2format1.so
TARGETS = liblvm2format1.so
include ../../make.tmpl
.PHONY: install
install: liblvm2format1.so
$(INSTALL) -D -o $(OWNER) -g $(GROUP) -m 555 $(STRIP) $< \
$(libdir)/liblvm2format1.so.$(LIB_VERSION)
$(LN_S) -f liblvm2format1.so.$(LIB_VERSION) $(libdir)/liblvm2format1.so
.PHONY: install

View File

@@ -1,7 +1,16 @@
/*
* Copyright (C) 2001 Sistina Software (UK) Limited.
* Copyright (C) 2001-2004 Sistina Software, Inc. All rights reserved.
* Copyright (C) 2004 Red Hat, Inc. All rights reserved.
*
* This file is released under the LGPL.
* This file is part of LVM2.
*
* This copyrighted material is made available to anyone wishing to use,
* modify, copy, or redistribute it subject to the terms and conditions
* of the GNU General Public License v.2.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software Foundation,
* Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
#include "lib.h"

View File

@@ -1,7 +1,16 @@
/*
* Copyright (C) 2001 Sistina Software (UK) Limited.
* Copyright (C) 2001-2004 Sistina Software, Inc. All rights reserved.
* Copyright (C) 2004 Red Hat, Inc. All rights reserved.
*
* This file is released under the GPL.
* This file is part of LVM2.
*
* This copyrighted material is made available to anyone wishing to use,
* modify, copy, or redistribute it subject to the terms and conditions
* of the GNU General Public License v.2.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software Foundation,
* Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
#ifndef DISK_REP_FORMAT1_H
@@ -10,6 +19,7 @@
#include "lvm-types.h"
#include "metadata.h"
#include "pool.h"
#include "toolcontext.h"
#define MAX_PV 256
#define MAX_LV 256
@@ -196,7 +206,8 @@ int write_disks(const struct format_type *fmt, struct list *pvds);
int import_pv(struct pool *mem, struct device *dev,
struct volume_group *vg,
struct physical_volume *pv, struct pv_disk *pvd);
int export_pv(struct pool *mem, struct volume_group *vg,
int export_pv(struct cmd_context *cmd, struct pool *mem,
struct volume_group *vg,
struct pv_disk *pvd, struct physical_volume *pv);
int import_vg(struct pool *mem,

View File

@@ -1,7 +1,16 @@
/*
* Copyright (C) 2001 Sistina Software (UK) Limited.
* Copyright (C) 2001-2004 Sistina Software, Inc. All rights reserved.
* Copyright (C) 2004 Red Hat, Inc. All rights reserved.
*
* This file is released under the LGPL.
* This file is part of LVM2.
*
* This copyrighted material is made available to anyone wishing to use,
* modify, copy, or redistribute it subject to the terms and conditions
* of the GNU General Public License v.2.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software Foundation,
* Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
#include "lib.h"
@@ -139,6 +148,7 @@ static struct volume_group *_build_vg(struct format_instance *fid,
list_init(&vg->pvs);
list_init(&vg->lvs);
list_init(&vg->snapshots);
list_init(&vg->tags);
if (!_check_vgs(pvs, &partial))
goto bad;
@@ -201,7 +211,8 @@ static struct volume_group *_vg_read(struct format_instance *fid,
return vg;
}
static struct disk_list *_flatten_pv(struct pool *mem, struct volume_group *vg,
static struct disk_list *_flatten_pv(struct format_instance *fid,
struct pool *mem, struct volume_group *vg,
struct physical_volume *pv,
const char *dev_dir)
{
@@ -218,7 +229,7 @@ static struct disk_list *_flatten_pv(struct pool *mem, struct volume_group *vg,
list_init(&dl->uuids);
list_init(&dl->lvds);
if (!export_pv(mem, vg, &dl->pvd, pv) ||
if (!export_pv(fid->fmt->cmd, mem, vg, &dl->pvd, pv) ||
!export_vg(&dl->vgd, vg) ||
!export_uuids(dl, vg) ||
!export_lvs(dl, vg, pv, dev_dir) || !calculate_layout(dl)) {
@@ -242,7 +253,7 @@ static int _flatten_vg(struct format_instance *fid, struct pool *mem,
list_iterate(pvh, &vg->pvs) {
pvl = list_item(pvh, struct pv_list);
if (!(data = _flatten_pv(mem, vg, pvl->pv, dev_dir))) {
if (!(data = _flatten_pv(fid, mem, vg, pvl->pv, dev_dir))) {
stack;
return 0;
}
@@ -421,7 +432,7 @@ static int _pv_write(const struct format_type *fmt, struct physical_volume *pv,
dl->mem = mem;
dl->dev = pv->dev;
if (!export_pv(mem, NULL, &dl->pvd, pv)) {
if (!export_pv(fmt->cmd, mem, NULL, &dl->pvd, pv)) {
stack;
goto bad;
}

View File

@@ -1,7 +1,16 @@
/*
* Copyright (C) 2001 Sistina Software (UK) Limited.
* Copyright (C) 2001-2004 Sistina Software, Inc. All rights reserved.
* Copyright (C) 2004 Red Hat, Inc. All rights reserved.
*
* This file is released under the GPL.
* This file is part of LVM2.
*
* This copyrighted material is made available to anyone wishing to use,
* modify, copy, or redistribute it subject to the terms and conditions
* of the GNU General Public License v.2.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software Foundation,
* Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
#ifndef _LVM_FORMAT1_H

View File

@@ -1,9 +1,20 @@
/*
* Copyright (C) 2001 Sistina Software (UK) Limited.
* Copyright (C) 2001-2004 Sistina Software, Inc. All rights reserved.
* Copyright (C) 2004 Red Hat, Inc. All rights reserved.
*
* This file is part of LVM2.
*
* This copyrighted material is made available to anyone wishing to use,
* modify, copy, or redistribute it subject to the terms and conditions
* of the GNU General Public License v.2.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software Foundation,
* Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
/*
* Translates between disk and in-core formats.
*
* This file is released under the LGPL.
*/
#include "lib.h"
@@ -13,9 +24,9 @@
#include "list.h"
#include "lvm-string.h"
#include "filter.h"
#include "toolcontext.h"
#include <time.h>
#include <sys/utsname.h>
static int _check_vg_name(const char *name)
{
@@ -56,9 +67,9 @@ int import_pv(struct pool *mem, struct device *dev,
if (vg &&
strncmp(vg->system_id, pvd->system_id, sizeof(pvd->system_id)))
log_very_verbose("System ID %s on %s differs from %s for "
"volume group", pvd->system_id,
dev_name(pv->dev), vg->system_id);
log_very_verbose("System ID %s on %s differs from %s for "
"volume group", pvd->system_id,
dev_name(pv->dev), vg->system_id);
/*
* If exported, we still need to flag in pv->status too because
@@ -76,20 +87,16 @@ int import_pv(struct pool *mem, struct device *dev,
pv->pe_count = pvd->pe_total;
pv->pe_alloc_count = pvd->pe_allocated;
list_init(&pv->tags);
return 1;
}
static int _system_id(char *s, const char *prefix)
static int _system_id(struct cmd_context *cmd, char *s, const char *prefix)
{
struct utsname uts;
if (uname(&uts) != 0) {
log_sys_error("uname", "_system_id");
return 0;
}
if (lvm_snprintf(s, NAME_LEN, "%s%s%lu",
prefix, uts.nodename, time(NULL)) < 0) {
prefix, cmd->hostname, time(NULL)) < 0) {
log_error("Generated system_id too long");
return 0;
}
@@ -97,7 +104,8 @@ static int _system_id(char *s, const char *prefix)
return 1;
}
int export_pv(struct pool *mem, struct volume_group *vg,
int export_pv(struct cmd_context *cmd, struct pool *mem,
struct volume_group *vg,
struct pv_disk *pvd, struct physical_volume *pv)
{
memset(pvd, 0, sizeof(*pvd));
@@ -128,7 +136,7 @@ int export_pv(struct pool *mem, struct volume_group *vg,
if (!*vg->system_id ||
strncmp(vg->system_id, EXPORTED_TAG,
sizeof(EXPORTED_TAG) - 1)) {
if (!_system_id(pvd->system_id, EXPORTED_TAG)) {
if (!_system_id(cmd, pvd->system_id, EXPORTED_TAG)) {
stack;
return 0;
}
@@ -145,7 +153,7 @@ int export_pv(struct pool *mem, struct volume_group *vg,
/* Is VG being imported? */
if (vg && !(vg->status & EXPORTED_VG) && *vg->system_id &&
!strncmp(vg->system_id, EXPORTED_TAG, sizeof(EXPORTED_TAG) - 1)) {
if (!_system_id(pvd->system_id, IMPORTED_TAG)) {
if (!_system_id(cmd, pvd->system_id, IMPORTED_TAG)) {
stack;
return 0;
}
@@ -153,7 +161,7 @@ int export_pv(struct pool *mem, struct volume_group *vg,
/* Generate system_id if PV is in VG */
if (!pvd->system_id || !*pvd->system_id)
if (!_system_id(pvd->system_id, "")) {
if (!_system_id(cmd, pvd->system_id, "")) {
stack;
return 0;
}
@@ -162,7 +170,7 @@ int export_pv(struct pool *mem, struct volume_group *vg,
if (vg &&
(!*vg->system_id ||
strncmp(vg->system_id, pvd->system_id, sizeof(pvd->system_id))))
strncpy(vg->system_id, pvd->system_id, NAME_LEN);
strncpy(vg->system_id, pvd->system_id, NAME_LEN);
//pvd->pv_major = MAJOR(pv->dev);
@@ -314,6 +322,7 @@ int import_lv(struct pool *mem, struct logical_volume *lv, struct lv_disk *lvd)
lv->le_count = lvd->lv_allocated_le;
list_init(&lv->segments);
list_init(&lv->tags);
return 1;
}

View File

@@ -1,7 +1,16 @@
/*
* Copyright (C) 2001 Sistina Software (UK) Limited.
* Copyright (C) 2001-2004 Sistina Software, Inc. All rights reserved.
* Copyright (C) 2004 Red Hat, Inc. All rights reserved.
*
* This file is released under the LGPL.
* This file is part of LVM2.
*
* This copyrighted material is made available to anyone wishing to use,
* modify, copy, or redistribute it subject to the terms and conditions
* of the GNU General Public License v.2.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software Foundation,
* Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
#include "lib.h"

View File

@@ -1,7 +1,16 @@
/*
* Copyright (C) 2001 Sistina Software (UK) Limited.
* Copyright (C) 2001-2004 Sistina Software, Inc. All rights reserved.
* Copyright (C) 2004 Red Hat, Inc. All rights reserved.
*
* This file is released under the LGPL.
* This file is part of LVM2.
*
* This copyrighted material is made available to anyone wishing to use,
* modify, copy, or redistribute it subject to the terms and conditions
* of the GNU General Public License v.2.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software Foundation,
* Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
#include "lib.h"

View File

@@ -1,7 +1,16 @@
/*
* Copyright (C) 2002 Sistina Software (UK) Limited.
* Copyright (C) 2002-2004 Sistina Software, Inc. All rights reserved.
* Copyright (C) 2004 Red Hat, Inc. All rights reserved.
*
* This file is released under the LGPL.
* This file is part of LVM2.
*
* This copyrighted material is made available to anyone wishing to use,
* modify, copy, or redistribute it subject to the terms and conditions
* of the GNU General Public License v.2.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software Foundation,
* Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
#include "lib.h"

View File

@@ -1,7 +1,16 @@
/*
* Copyright (C) 2002 Sistina Software (UK) Limited.
* Copyright (C) 2002-2004 Sistina Software, Inc. All rights reserved.
* Copyright (C) 2004 Red Hat, Inc. All rights reserved.
*
* This file is released under the LGPL.
* This file is part of LVM2.
*
* This copyrighted material is made available to anyone wishing to use,
* modify, copy, or redistribute it subject to the terms and conditions
* of the GNU General Public License v.2.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software Foundation,
* Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
#ifndef _LVM_LVM1_LABEL_H

View File

@@ -1,7 +1,16 @@
/*
* Copyright (C) 2001 Sistina Software (UK) Limited.
* Copyright (C) 2001-2004 Sistina Software, Inc. All rights reserved.
* Copyright (C) 2004 Red Hat, Inc. All rights reserved.
*
* This file is released under the LGPL.
* This file is part of LVM2.
*
* This copyrighted material is made available to anyone wishing to use,
* modify, copy, or redistribute it subject to the terms and conditions
* of the GNU General Public License v.2.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software Foundation,
* Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
#include "lib.h"

View File

@@ -1,7 +1,16 @@
/*
* Copyright (C) 2001 Sistina Software (UK) Limited.
* Copyright (C) 2001-2004 Sistina Software, Inc. All rights reserved.
* Copyright (C) 2004 Red Hat, Inc. All rights reserved.
*
* This file is released under the LGPL.
* This file is part of LVM2.
*
* This copyrighted material is made available to anyone wishing to use,
* modify, copy, or redistribute it subject to the terms and conditions
* of the GNU General Public License v.2.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software Foundation,
* Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
#include "lib.h"

View File

@@ -1,7 +1,16 @@
/*
* Copyright (C) 2001 Sistina Software (UK) Limited.
* Copyright (C) 2001-2004 Sistina Software, Inc. All rights reserved.
* Copyright (C) 2004 Red Hat, Inc. All rights reserved.
*
* This file is released under the LGPL.
* This file is part of LVM2.
*
* This copyrighted material is made available to anyone wishing to use,
* modify, copy, or redistribute it subject to the terms and conditions
* of the GNU General Public License v.2.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software Foundation,
* Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
#include "lib.h"
@@ -270,7 +279,7 @@ static int _print_header(struct formatter *f,
static int _print_vg(struct formatter *f, struct volume_group *vg)
{
char buffer[256];
char buffer[4096];
if (!id_write_format(&vg->id, buffer, sizeof(buffer))) {
stack;
@@ -280,14 +289,24 @@ static int _print_vg(struct formatter *f, struct volume_group *vg)
_outf(f, "id = \"%s\"", buffer);
_outf(f, "seqno = %u", vg->seqno);
if (!print_flags(vg->status, VG_FLAGS, buffer, sizeof(buffer))) {
stack;
return 0;
}
_outf(f, "status = %s", buffer);
if (!list_empty(&vg->tags)) {
if (!print_tags(&vg->tags, buffer, sizeof(buffer))) {
stack;
return 0;
}
_outf(f, "tags = %s", buffer);
}
if (vg->system_id && *vg->system_id)
_outf(f, "system_id = \"%s\"", vg->system_id);
if (!_out_size(f, (uint64_t) vg->extent_size, "extent_size = %u",
vg->extent_size)) {
stack;
@@ -314,7 +333,7 @@ static int _print_pvs(struct formatter *f, struct volume_group *vg)
{
struct list *pvh;
struct physical_volume *pv;
char buffer[256];
char buffer[4096];
const char *name;
_outf(f, "physical_volumes {");
@@ -348,8 +367,16 @@ static int _print_pvs(struct formatter *f, struct volume_group *vg)
stack;
return 0;
}
_outf(f, "status = %s", buffer);
if (!list_empty(&pv->tags)) {
if (!print_tags(&pv->tags, buffer, sizeof(buffer))) {
stack;
return 0;
}
_outf(f, "tags = %s", buffer);
}
_outf(f, "pe_start = %" PRIu64, pv->pe_start);
if (!_out_size(f, vg->extent_size * (uint64_t) pv->pe_count,
"pe_count = %u", pv->pe_count)) {
@@ -372,6 +399,7 @@ static int _print_segment(struct formatter *f, struct volume_group *vg,
unsigned int s;
const char *name;
const char *type;
char buffer[4096];
_outf(f, "segment%u {", count);
_inc_indent(f);
@@ -386,6 +414,14 @@ static int _print_segment(struct formatter *f, struct volume_group *vg,
f->nl(f);
_outf(f, "type = \"%s\"", get_segtype_string(seg->type));
if (!list_empty(&seg->tags)) {
if (!print_tags(&seg->tags, buffer, sizeof(buffer))) {
stack;
return 0;
}
_outf(f, "tags = %s", buffer);
}
switch (seg->type) {
case SEG_SNAPSHOT:
_outf(f, "chunk_size = %u", seg->chunk_size);
@@ -490,6 +526,9 @@ static int _print_snapshot(struct formatter *f, struct snapshot *snap,
seg.cow = snap->cow;
seg.chunk_size = snap->chunk_size;
/* Can't tag a snapshot independently of its origin */
list_init(&seg.tags);
if (!_print_segment(f, snap->origin->vg, 1, &seg)) {
stack;
return 0;
@@ -524,7 +563,7 @@ static int _print_lvs(struct formatter *f, struct volume_group *vg)
struct list *lvh;
struct logical_volume *lv;
struct lv_segment *seg;
char buffer[256];
char buffer[4096];
int seg_count;
/*
@@ -555,8 +594,16 @@ static int _print_lvs(struct formatter *f, struct volume_group *vg)
stack;
return 0;
}
_outf(f, "status = %s", buffer);
if (!list_empty(&lv->tags)) {
if (!print_tags(&lv->tags, buffer, sizeof(buffer))) {
stack;
return 0;
}
_outf(f, "tags = %s", buffer);
}
if (lv->alloc != ALLOC_DEFAULT)
_outf(f, "allocation_policy = \"%s\"",
get_alloc_string(lv->alloc));

View File

@@ -1,7 +1,16 @@
/*
* Copyright (C) 2001 Sistina Software (UK) Limited.
* Copyright (C) 2001-2004 Sistina Software, Inc. All rights reserved.
* Copyright (C) 2004 Red Hat, Inc. All rights reserved.
*
* This file is released under the LGPL.
* This file is part of LVM2.
*
* This copyrighted material is made available to anyone wishing to use,
* modify, copy, or redistribute it subject to the terms and conditions
* of the GNU General Public License v.2.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software Foundation,
* Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
#include "lib.h"

View File

@@ -1,7 +1,16 @@
/*
* Copyright (C) 2001-2002 Sistina Software (UK) Limited.
* Copyright (C) 2001-2004 Sistina Software, Inc. All rights reserved.
* Copyright (C) 2004 Red Hat, Inc. All rights reserved.
*
* This file is released under the LGPL.
* This file is part of LVM2.
*
* This copyrighted material is made available to anyone wishing to use,
* modify, copy, or redistribute it subject to the terms and conditions
* of the GNU General Public License v.2.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software Foundation,
* Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
#include "lib.h"
@@ -1584,21 +1593,21 @@ static int _get_config_disk_area(struct cmd_context *cmd,
return 0;
}
if (!get_config_uint64(cn, "start_sector", '/', &dev_area.start)) {
if (!get_config_uint64(cn, "start_sector", &dev_area.start)) {
log_error("Missing start_sector in metadata disk_area section "
"of config file");
return 0;
}
dev_area.start <<= SECTOR_SHIFT;
if (!get_config_uint64(cn, "size", '/', &dev_area.size)) {
if (!get_config_uint64(cn, "size", &dev_area.size)) {
log_error("Missing size in metadata disk_area section "
"of config file");
return 0;
}
dev_area.size <<= SECTOR_SHIFT;
if (!get_config_str(cn, "id", '/', &id_str)) {
if (!get_config_str(cn, "id", &id_str)) {
log_error("Missing uuid in metadata disk_area section "
"of config file");
return 0;
@@ -1640,7 +1649,7 @@ struct format_type *create_text_format(struct cmd_context *cmd)
fmt->ops = &_text_handler;
fmt->name = FMT_TEXT_NAME;
fmt->alias = FMT_TEXT_ALIAS;
fmt->features = FMT_SEGMENTS | FMT_MDAS;
fmt->features = FMT_SEGMENTS | FMT_MDAS | FMT_TAGS;
if (!(mda_lists = dbg_malloc(sizeof(struct mda_lists)))) {
log_error("Failed to allocate dir_list");
@@ -1663,7 +1672,7 @@ struct format_type *create_text_format(struct cmd_context *cmd)
return NULL;
}
if ((cn = find_config_node(cmd->cf->root, "metadata/dirs", '/'))) {
if ((cn = find_config_node(cmd->cft->root, "metadata/dirs"))) {
for (cv = cn->v; cv; cv = cv->next) {
if (cv->type != CFG_STRING) {
log_error("Invalid string in config file: "
@@ -1679,7 +1688,7 @@ struct format_type *create_text_format(struct cmd_context *cmd)
}
}
if (!(cn = find_config_node(cmd->cf->root, "metadata/disk_areas", '/')))
if (!(cn = find_config_node(cmd->cft->root, "metadata/disk_areas")))
return fmt;
for (cn = cn->child; cn; cn = cn->sib) {

View File

@@ -1,7 +1,16 @@
/*
* Copyright (C) 2001 Sistina Software (UK) Limited.
* Copyright (C) 2001-2004 Sistina Software, Inc. All rights reserved.
* Copyright (C) 2004 Red Hat, Inc. All rights reserved.
*
* This file is released under the LGPL.
* This file is part of LVM2.
*
* This copyrighted material is made available to anyone wishing to use,
* modify, copy, or redistribute it subject to the terms and conditions
* of the GNU General Public License v.2.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software Foundation,
* Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
#ifndef _LVM_FORMAT_TEXT_H

View File

@@ -1,7 +1,16 @@
/*
* Copyright (C) 2001 Sistina Software (UK) Limited.
* Copyright (C) 2001-2004 Sistina Software, Inc. All rights reserved.
* Copyright (C) 2004 Red Hat, Inc. All rights reserved.
*
* This file is released under the LGPL.
* This file is part of LVM2.
*
* This copyrighted material is made available to anyone wishing to use,
* modify, copy, or redistribute it subject to the terms and conditions
* of the GNU General Public License v.2.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software Foundation,
* Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
#ifndef _LVM_TEXT_IMPORT_EXPORT_H
@@ -46,6 +55,9 @@ struct text_vg_version_ops *text_vg_vsn1_init(void);
int print_flags(uint32_t status, int type, char *buffer, size_t size);
int read_flags(uint32_t *status, int type, struct config_value *cv);
int print_tags(struct list *tags, char *buffer, size_t size);
int read_tags(struct pool *mem, struct list *tags, struct config_value *cv);
int text_vg_export_file(struct volume_group *vg, const char *desc, FILE *fp);
int text_vg_export_raw(struct volume_group *vg, const char *desc, char *buf,
uint32_t size);

View File

@@ -1,7 +1,16 @@
/*
* Copyright (C) 2001 Sistina Software (UK) Limited.
* Copyright (C) 2001-2004 Sistina Software, Inc. All rights reserved.
* Copyright (C) 2004 Red Hat, Inc. All rights reserved.
*
* This file is released under the LGPL.
* This file is part of LVM2.
*
* This copyrighted material is made available to anyone wishing to use,
* modify, copy, or redistribute it subject to the terms and conditions
* of the GNU General Public License v.2.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software Foundation,
* Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
#include "lib.h"
@@ -26,7 +35,7 @@ struct volume_group *text_vg_import_fd(struct format_instance *fid,
time_t *when, char **desc)
{
struct volume_group *vg = NULL;
struct config_tree *cf;
struct config_tree *cft;
struct text_vg_version_ops **vsn;
static int _initialised = 0;
@@ -40,13 +49,13 @@ struct volume_group *text_vg_import_fd(struct format_instance *fid,
*desc = NULL;
*when = 0;
if (!(cf = create_config_tree())) {
if (!(cft = create_config_tree())) {
stack;
goto out;
}
if ((!dev && !read_config_file(cf, file)) ||
(dev && !read_config_fd(cf, dev, offset, size,
if ((!dev && !read_config_file(cft, file)) ||
(dev && !read_config_fd(cft, dev, offset, size,
offset2, size2, checksum_fn, checksum))) {
log_error("Couldn't read volume group metadata.");
goto out;
@@ -56,20 +65,20 @@ struct volume_group *text_vg_import_fd(struct format_instance *fid,
* Find a set of version functions that can read this file
*/
for (vsn = &_text_vsn_list[0]; *vsn; vsn++) {
if (!(*vsn)->check_version(cf))
if (!(*vsn)->check_version(cft))
continue;
if (!(vg = (*vsn)->read_vg(fid, cf))) {
if (!(vg = (*vsn)->read_vg(fid, cft))) {
stack;
goto out;
}
(*vsn)->read_desc(fid->fmt->cmd->mem, cf, when, desc);
(*vsn)->read_desc(fid->fmt->cmd->mem, cft, when, desc);
break;
}
out:
destroy_config_tree(cf);
destroy_config_tree(cft);
return vg;
}

View File

@@ -1,7 +1,16 @@
/*
* Copyright (C) 2001 Sistina Software (UK) Limited.
* Copyright (C) 2001-2004 Sistina Software, Inc. All rights reserved.
* Copyright (C) 2004 Red Hat, Inc. All rights reserved.
*
* This file is released under the LGPL.
* This file is part of LVM2.
*
* This copyrighted material is made available to anyone wishing to use,
* modify, copy, or redistribute it subject to the terms and conditions
* of the GNU General Public License v.2.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software Foundation,
* Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
#include "lib.h"
@@ -20,13 +29,13 @@ typedef int (*section_fn) (struct format_instance * fid, struct pool * mem,
struct hash_table * pv_hash);
#define _read_int32(root, path, result) \
get_config_uint32(root, path, '/', result)
get_config_uint32(root, path, result)
#define _read_uint32(root, path, result) \
get_config_uint32(root, path, '/', result)
get_config_uint32(root, path, result)
#define _read_int64(root, path, result) \
get_config_uint64(root, path, '/', result)
get_config_uint64(root, path, result)
/*
* Logs an attempt to read an invalid format file.
@@ -40,7 +49,7 @@ static void _invalid_format(const char *str)
* Checks that the config file contains vg metadata, and that it
* we recognise the version number,
*/
static int _check_version(struct config_tree *cf)
static int _check_version(struct config_tree *cft)
{
struct config_node *cn;
struct config_value *cv;
@@ -48,7 +57,7 @@ static int _check_version(struct config_tree *cf)
/*
* Check the contents field.
*/
if (!(cn = find_config_node(cf->root, CONTENTS_FIELD, '/'))) {
if (!(cn = find_config_node(cft->root, CONTENTS_FIELD))) {
_invalid_format("missing contents field");
return 0;
}
@@ -62,7 +71,7 @@ static int _check_version(struct config_tree *cf)
/*
* Check the version number.
*/
if (!(cn = find_config_node(cf->root, FORMAT_VERSION_FIELD, '/'))) {
if (!(cn = find_config_node(cft->root, FORMAT_VERSION_FIELD))) {
_invalid_format("missing version number");
return 0;
}
@@ -80,7 +89,7 @@ static int _read_id(struct id *id, struct config_node *cn, const char *path)
{
struct config_value *cv;
if (!(cn = find_config_node(cn, path, '/'))) {
if (!(cn = find_config_node(cn, path))) {
log_error("Couldn't find uuid.");
return 0;
}
@@ -157,7 +166,7 @@ static int _read_pv(struct format_instance *fid, struct pool *mem,
return 0;
}
if (!(cn = find_config_node(pvn, "status", '/'))) {
if (!(cn = find_config_node(pvn, "status"))) {
log_error("Couldn't find status flags for physical volume.");
return 0;
}
@@ -178,6 +187,16 @@ static int _read_pv(struct format_instance *fid, struct pool *mem,
return 0;
}
list_init(&pv->tags);
/* Optional tags */
if ((cn = find_config_node(pvn, "tags")) &&
!(read_tags(mem, &pv->tags, cn->v))) {
log_error("Couldn't read tags for physical volume %s in %s.",
dev_name(pv->dev), vg->name);
return 0;
}
/* adjust the volume group. */
vg->extent_count += pv->pe_count;
vg->free_count += pv->pe_count;
@@ -245,7 +264,7 @@ static int _read_segment(struct pool *mem, struct volume_group *vg,
}
segtype = SEG_STRIPED; /* Default */
if ((cn = find_config_node(sn, "type", '/'))) {
if ((cn = find_config_node(sn, "type"))) {
cv = cn->v;
if (!cv || !cv->v.str) {
log_error("Segment type must be a string.");
@@ -269,7 +288,7 @@ static int _read_segment(struct pool *mem, struct volume_group *vg,
return 0;
}
if (find_config_node(sn, "extents_moved", '/')) {
if (find_config_node(sn, "extents_moved")) {
if (_read_uint32(sn, "extents_moved", &extents_moved))
seg_status |= PVMOVE;
else {
@@ -293,6 +312,14 @@ static int _read_segment(struct pool *mem, struct volume_group *vg,
seg->status = seg_status;
seg->extents_moved = extents_moved;
/* Optional tags */
if ((cn = find_config_node(sn, "tags")) &&
!(read_tags(mem, &seg->tags, cn->v))) {
log_error("Couldn't read tags for a segment of %s/%s.",
vg->name, lv->name);
return 0;
}
switch (segtype) {
case SEG_SNAPSHOT:
lv->status |= SNAPSHOT;
@@ -304,13 +331,13 @@ static int _read_segment(struct pool *mem, struct volume_group *vg,
log_suppress(1);
if (!(cow_name = find_config_str(sn, "cow_store", '/', NULL))) {
if (!(cow_name = find_config_str(sn, "cow_store", NULL))) {
log_suppress(0);
log_error("Snapshot cow storage not specified.");
return 0;
}
if (!(org_name = find_config_str(sn, "origin", '/', NULL))) {
if (!(org_name = find_config_str(sn, "origin", NULL))) {
log_suppress(0);
log_error("Snapshot origin not specified.");
return 0;
@@ -344,7 +371,7 @@ static int _read_segment(struct pool *mem, struct volume_group *vg,
return 0;
}
if (!(cn = find_config_node(sn, "stripes", '/'))) {
if (!(cn = find_config_node(sn, "stripes"))) {
log_error("Couldn't find stripes array for segment "
"'%s'.", sn->key);
return 0;
@@ -362,7 +389,7 @@ static int _read_segment(struct pool *mem, struct volume_group *vg,
}
if ((seg->type == SEG_MIRRORED) &&
!(cn = find_config_node(sn, "mirrors", '/'))) {
!(cn = find_config_node(sn, "mirrors"))) {
log_error("Couldn't find mirrors array for segment "
"'%s'.", sn->key);
return 0;
@@ -518,7 +545,7 @@ static int _read_lvnames(struct format_instance *fid, struct pool *mem,
return 0;
}
if (!(cn = find_config_node(lvn, "status", '/'))) {
if (!(cn = find_config_node(lvn, "status"))) {
log_error("Couldn't find status flags for logical volume.");
return 0;
}
@@ -529,7 +556,7 @@ static int _read_lvnames(struct format_instance *fid, struct pool *mem,
}
lv->alloc = ALLOC_DEFAULT;
if ((cn = find_config_node(lvn, "allocation_policy", '/'))) {
if ((cn = find_config_node(lvn, "allocation_policy"))) {
struct config_value *cv = cn->v;
if (!cv || !cv->v.str) {
log_error("allocation_policy must be a string.");
@@ -544,6 +571,15 @@ static int _read_lvnames(struct format_instance *fid, struct pool *mem,
lv->read_ahead = 0;
list_init(&lv->segments);
list_init(&lv->tags);
/* Optional tags */
if ((cn = find_config_node(lvn, "tags")) &&
!(read_tags(mem, &lv->tags, cn->v))) {
log_error("Couldn't read tags for logical volume %s/%s.",
vg->name, lv->name);
return 0;
}
lv->vg = vg;
vg->lv_count++;
@@ -618,7 +654,7 @@ static int _read_sections(struct format_instance *fid,
{
struct config_node *n;
if (!(n = find_config_node(vgn, section, '/'))) {
if (!(n = find_config_node(vgn, section))) {
if (!optional) {
log_error("Couldn't find section '%s'.", section);
return 0;
@@ -638,7 +674,7 @@ static int _read_sections(struct format_instance *fid,
}
static struct volume_group *_read_vg(struct format_instance *fid,
struct config_tree *cf)
struct config_tree *cft)
{
struct config_node *vgn, *cn;
struct volume_group *vg;
@@ -646,7 +682,7 @@ static struct volume_group *_read_vg(struct format_instance *fid,
struct pool *mem = fid->fmt->cmd->mem;
/* skip any top-level values */
for (vgn = cf->root; (vgn && vgn->v); vgn = vgn->sib) ;
for (vgn = cft->root; (vgn && vgn->v); vgn = vgn->sib) ;
if (!vgn) {
log_error("Couldn't find volume group in file.");
@@ -675,7 +711,7 @@ static struct volume_group *_read_vg(struct format_instance *fid,
vgn = vgn->child;
if ((cn = find_config_node(vgn, "system_id", '/')) && cn->v) {
if ((cn = find_config_node(vgn, "system_id")) && cn->v) {
if (!cn->v->v.str) {
log_error("system_id must be a string");
goto bad;
@@ -694,7 +730,7 @@ static struct volume_group *_read_vg(struct format_instance *fid,
goto bad;
}
if (!(cn = find_config_node(vgn, "status", '/'))) {
if (!(cn = find_config_node(vgn, "status"))) {
log_error("Couldn't find status flags for volume group %s.",
vg->name);
goto bad;
@@ -748,6 +784,14 @@ static struct volume_group *_read_vg(struct format_instance *fid,
list_init(&vg->lvs);
list_init(&vg->snapshots);
list_init(&vg->tags);
/* Optional tags */
if ((cn = find_config_node(vgn, "tags")) &&
!(read_tags(mem, &vg->tags, cn->v))) {
log_error("Couldn't read tags for volume group %s.", vg->name);
goto bad;
}
if (!_read_sections(fid, "logical_volumes", _read_lvnames, mem, vg,
vgn, pv_hash, 1)) {
@@ -784,17 +828,17 @@ static struct volume_group *_read_vg(struct format_instance *fid,
}
static void _read_desc(struct pool *mem,
struct config_tree *cf, time_t *when, char **desc)
struct config_tree *cft, time_t *when, char **desc)
{
const char *d;
unsigned int u = 0u;
log_suppress(1);
d = find_config_str(cf->root, "description", '/', "");
d = find_config_str(cft->root, "description", "");
log_suppress(0);
*desc = pool_strdup(mem, d);
get_config_uint32(cf->root, "creation_time", '/', &u);
get_config_uint32(cft->root, "creation_time", &u);
*when = u;
}

View File

@@ -1,7 +1,16 @@
/*
* Copyright (C) 2001 Sistina Software (UK) Limited.
* Copyright (C) 2001-2004 Sistina Software, Inc. All rights reserved.
* Copyright (C) 2004 Red Hat, Inc. All rights reserved.
*
* This file is released under the LGPL.
* This file is part of LVM2.
*
* This copyrighted material is made available to anyone wishing to use,
* modify, copy, or redistribute it subject to the terms and conditions
* of the GNU General Public License v.2.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software Foundation,
* Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
#ifndef _LVM_TEXT_LAYOUT_H

76
lib/format_text/tags.c Normal file
View File

@@ -0,0 +1,76 @@
/*
* Copyright (C) 2003-2004 Sistina Software, Inc. All rights reserved.
* Copyright (C) 2004 Red Hat, Inc. All rights reserved.
*
* This file is part of LVM2.
*
* This copyrighted material is made available to anyone wishing to use,
* modify, copy, or redistribute it subject to the terms and conditions
* of the GNU General Public License v.2.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software Foundation,
* Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
#include "lib.h"
#include "metadata.h"
#include "import-export.h"
#include "pool.h"
#include "str_list.h"
#include "lvm-string.h"
int print_tags(struct list *tags, char *buffer, size_t size)
{
struct str_list *sl;
int first = 1;
if (!emit_to_buffer(&buffer, &size, "[")) {
stack;
return 0;
}
list_iterate_items(sl, tags) {
if (!first) {
if (!emit_to_buffer(&buffer, &size, ", ")) {
stack;
return 0;
}
} else
first = 0;
if (!emit_to_buffer(&buffer, &size, "\"%s\"", sl->str)) {
stack;
return 0;
}
}
if (!emit_to_buffer(&buffer, &size, "]")) {
stack;
return 0;
}
return 1;
}
int read_tags(struct pool *mem, struct list *tags, struct config_value *cv)
{
if (cv->type == CFG_EMPTY_ARRAY)
return 1;
while (cv) {
if (cv->type != CFG_STRING) {
log_error("Found a tag that is not a string");
return 0;
}
if (!str_list_add(mem, tags, pool_strdup(mem, cv->v.str))) {
stack;
return 0;
}
cv = cv->next;
}
return 1;
}

View File

@@ -1,7 +1,16 @@
/*
* Copyright (C) 2002 Sistina Software (UK) Limited.
* Copyright (C) 2002-2004 Sistina Software, Inc. All rights reserved.
* Copyright (C) 2004 Red Hat, Inc. All rights reserved.
*
* This file is released under the LGPL.
* This file is part of LVM2.
*
* This copyrighted material is made available to anyone wishing to use,
* modify, copy, or redistribute it subject to the terms and conditions
* of the GNU General Public License v.2.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software Foundation,
* Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
#include "lib.h"

View File

@@ -1,7 +1,16 @@
/*
* Copyright (C) 2002 Sistina Software
* Copyright (C) 2002-2004 Sistina Software, Inc. All rights reserved.
* Copyright (C) 2004 Red Hat, Inc. All rights reserved.
*
* This file is released under the LGPL.
* This file is part of LVM2.
*
* This copyrighted material is made available to anyone wishing to use,
* modify, copy, or redistribute it subject to the terms and conditions
* of the GNU General Public License v.2.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software Foundation,
* Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
#include "lib.h"

View File

@@ -1,7 +1,16 @@
/*
* Copyright (C) 2002 Sistina Software (UK) Limited.
* Copyright (C) 2002-2004 Sistina Software, Inc. All rights reserved.
* Copyright (C) 2004 Red Hat, Inc. All rights reserved.
*
* This file is released under the LGPL.
* This file is part of LVM2.
*
* This copyrighted material is made available to anyone wishing to use,
* modify, copy, or redistribute it subject to the terms and conditions
* of the GNU General Public License v.2.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software Foundation,
* Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
#ifndef _LVM_LABEL_H

View File

@@ -1,8 +1,16 @@
/*
* Copyright (C) 2002 Sistina Software (UK) Limited.
* Copyright (C) 2002-2004 Sistina Software, Inc. All rights reserved.
* Copyright (C) 2004 Red Hat, Inc. All rights reserved.
*
* This file is released under the LGPL.
* This file is part of LVM2.
*
* This copyrighted material is made available to anyone wishing to use,
* modify, copy, or redistribute it subject to the terms and conditions
* of the GNU General Public License v.2.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software Foundation,
* Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
#include "lib.h"
@@ -14,7 +22,8 @@ static void *_locking_lib = NULL;
static void (*_end_fn) (void) = NULL;
static int (*_lock_fn) (struct cmd_context * cmd, const char *resource,
int flags) = NULL;
static int (*_init_fn) (int type, struct config_tree * cf) = NULL;
static int (*_init_fn) (int type, struct config_tree * cft,
uint32_t *flags) = NULL;
static int _lock_resource(struct cmd_context *cmd, const char *resource,
int flags)
@@ -38,7 +47,7 @@ static void _fin_external_locking(void)
_lock_fn = NULL;
}
int init_external_locking(struct locking_type *locking, struct config_tree *cf)
int init_external_locking(struct locking_type *locking, struct config_tree *cft)
{
const char *libname;
@@ -49,19 +58,20 @@ int init_external_locking(struct locking_type *locking, struct config_tree *cf)
locking->lock_resource = _lock_resource;
locking->fin_locking = _fin_external_locking;
locking->flags = 0;
libname = find_config_str(cf->root, "global/locking_library", '/',
libname = find_config_str(cft->root, "global/locking_library",
DEFAULT_LOCKING_LIB);
if (!(_locking_lib = load_shared_library(cf, libname, "locking"))) {
if (!(_locking_lib = load_shared_library(cft, libname, "locking"))) {
stack;
return 0;
}
/* Get the functions we need */
if (!(_init_fn = dlsym(_locking_lib, "init_locking")) ||
if (!(_init_fn = dlsym(_locking_lib, "locking_init")) ||
!(_lock_fn = dlsym(_locking_lib, "lock_resource")) ||
!(_end_fn = dlsym(_locking_lib, "end_locking"))) {
!(_end_fn = dlsym(_locking_lib, "locking_end"))) {
log_error("Shared library %s does not contain locking "
"functions", libname);
dlclose(_locking_lib);
@@ -70,5 +80,5 @@ int init_external_locking(struct locking_type *locking, struct config_tree *cf)
}
log_verbose("Loaded external locking library %s", libname);
return _init_fn(2, cf);
return _init_fn(2, cft, &locking->flags);
}

View File

@@ -1,8 +1,16 @@
/*
* Copyright (C) 2001 Sistina Software (UK) Limited.
* Copyright (C) 2001-2004 Sistina Software, Inc. All rights reserved.
* Copyright (C) 2004 Red Hat, Inc. All rights reserved.
*
* This file is released under the LGPL.
* This file is part of LVM2.
*
* This copyrighted material is made available to anyone wishing to use,
* modify, copy, or redistribute it subject to the terms and conditions
* of the GNU General Public License v.2.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software Foundation,
* Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
#include "lib.h"
@@ -252,15 +260,16 @@ static int _file_lock_resource(struct cmd_context *cmd, const char *resource,
return 1;
}
int init_file_locking(struct locking_type *locking, struct config_tree *cf)
int init_file_locking(struct locking_type *locking, struct config_tree *cft)
{
locking->lock_resource = _file_lock_resource;
locking->reset_locking = _reset_file_locking;
locking->fin_locking = _fin_file_locking;
locking->flags = 0;
/* Get lockfile directory from config file */
strncpy(_lock_dir, find_config_str(cf->root, "global/locking_dir",
'/', DEFAULT_LOCK_DIR),
strncpy(_lock_dir, find_config_str(cft->root, "global/locking_dir",
DEFAULT_LOCK_DIR),
sizeof(_lock_dir));
if (!create_dir(_lock_dir))

View File

@@ -1,8 +1,16 @@
/*
* Copyright (C) 2001 Sistina Software (UK) Limited.
* Copyright (C) 2001-2004 Sistina Software, Inc. All rights reserved.
* Copyright (C) 2004 Red Hat, Inc. All rights reserved.
*
* This file is released under the LGPL.
* This file is part of LVM2.
*
* This copyrighted material is made available to anyone wishing to use,
* modify, copy, or redistribute it subject to the terms and conditions
* of the GNU General Public License v.2.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software Foundation,
* Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
#include "lib.h"
@@ -11,6 +19,7 @@
#include "lvm-string.h"
#include "activate.h"
#include "toolcontext.h"
#include "memlock.h"
#include <signal.h>
#include <sys/stat.h>
@@ -62,6 +71,24 @@ static void _unblock_signals(void)
return;
}
static void _lock_memory(int flags)
{
if (!(_locking.flags & LCK_PRE_MEMLOCK))
return;
if ((flags & (LCK_SCOPE_MASK | LCK_TYPE_MASK)) == LCK_LV_SUSPEND)
memlock_inc();
}
static void _unlock_memory(int flags)
{
if (!(_locking.flags & LCK_PRE_MEMLOCK))
return;
if ((flags & (LCK_SCOPE_MASK | LCK_TYPE_MASK)) == LCK_LV_RESUME)
memlock_dec();
}
void reset_locking(void)
{
int was_locked = _vg_lock_count;
@@ -95,24 +122,24 @@ static inline void _update_vg_lock_count(int flags)
/*
* Select a locking type
*/
int init_locking(int type, struct config_tree *cf)
int init_locking(int type, struct config_tree *cft)
{
switch (type) {
case 0:
init_no_locking(&_locking, cf);
init_no_locking(&_locking, cft);
log_print("WARNING: Locking disabled. Be careful! "
"This could corrupt your metadata.");
return 1;
case 1:
if (!init_file_locking(&_locking, cf))
if (!init_file_locking(&_locking, cft))
break;
log_very_verbose("File-based locking enabled.");
return 1;
#ifdef HAVE_LIBDL
case 2:
if (!init_external_locking(&_locking, cf))
if (!init_external_locking(&_locking, cft))
break;
log_very_verbose("External locking enabled.");
return 1;
@@ -129,7 +156,7 @@ int init_locking(int type, struct config_tree *cf)
/* FIXME Ensure only read ops are permitted */
log_verbose("Locking disabled - only read operations permitted.");
init_no_locking(&_locking, cf);
init_no_locking(&_locking, cft);
return 1;
}
@@ -176,13 +203,16 @@ int check_lvm1_vg_inactive(struct cmd_context *cmd, const char *vgname)
static int _lock_vol(struct cmd_context *cmd, const char *resource, int flags)
{
_block_signals(flags);
_lock_memory(flags);
if (!(_locking.lock_resource(cmd, resource, flags))) {
_unlock_memory(flags);
_unblock_signals();
return 0;
}
_update_vg_lock_count(flags);
_unlock_memory(flags);
_unblock_signals();
return 1;
@@ -221,6 +251,42 @@ int lock_vol(struct cmd_context *cmd, const char *vol, int flags)
return 1;
}
/* Unlock list of LVs */
int unlock_lvs(struct cmd_context *cmd, struct list *lvs)
{
struct list *lvh;
struct logical_volume *lv;
list_iterate(lvh, lvs) {
lv = list_item(lvh, struct lv_list)->lv;
unlock_lv(cmd, lv->lvid.s);
}
return 1;
}
/* Lock a list of LVs */
int lock_lvs(struct cmd_context *cmd, struct list *lvs, int flags)
{
struct list *lvh;
struct logical_volume *lv;
list_iterate(lvh, lvs) {
lv = list_item(lvh, struct lv_list)->lv;
if (!lock_vol(cmd, lv->lvid.s, flags)) {
log_error("Failed to suspend %s", lv->name);
list_uniterate(lvh, lvs, lvh) {
lv = list_item(lvh, struct lv_list)->lv;
unlock_lv(cmd, lv->lvid.s);
}
return 0;
}
}
return 1;
}
int vg_write_lock_held(void)
{
return _vg_write_lock_held;

View File

@@ -1,8 +1,16 @@
/*
* Copyright (C) 2001 Sistina Software (UK) Limited.
* Copyright (C) 2001-2004 Sistina Software, Inc. All rights reserved.
* Copyright (C) 2004 Red Hat, Inc. All rights reserved.
*
* This file is released under the LGPL.
* This file is part of LVM2.
*
* This copyrighted material is made available to anyone wishing to use,
* modify, copy, or redistribute it subject to the terms and conditions
* of the GNU General Public License v.2.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software Foundation,
* Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
#include "metadata.h"
@@ -64,10 +72,16 @@ int check_lvm1_vg_inactive(struct cmd_context *cmd, const char *vgname);
#define LCK_VG_WRITE (LCK_VG | LCK_WRITE | LCK_HOLD)
#define LCK_VG_UNLOCK (LCK_VG | LCK_UNLOCK)
#define LCK_LV_DEACTIVATE (LCK_LV | LCK_EXCL)
#define LCK_LV_SUSPEND (LCK_LV | LCK_WRITE)
#define LCK_LV_ACTIVATE (LCK_LV | LCK_READ)
#define LCK_LV_RESUME (LCK_LV | LCK_UNLOCK | LCK_NONBLOCK)
#define LCK_LV_UNLOCK (LCK_LV | LCK_UNLOCK)
#define LCK_LV_ACTIVATE (LCK_LV | LCK_READ)
#define LCK_LV_DEACTIVATE (LCK_LV | LCK_EXCL)
#define unlock_lv(cmd, vol) lock_vol(cmd, vol, LCK_LV_UNLOCK)
#define unlock_vg(cmd, vol) lock_vol(cmd, vol, LCK_VG_UNLOCK)
/* Process list of LVs */
int lock_lvs(struct cmd_context *cmd, struct list *lvs, int flags);
int unlock_lvs(struct cmd_context *cmd, struct list *lvs);

View File

@@ -1,8 +1,16 @@
/*
* Copyright (C) 2001 Sistina Software (UK) Limited.
* Copyright (C) 2001-2004 Sistina Software, Inc. All rights reserved.
* Copyright (C) 2004 Red Hat, Inc. All rights reserved.
*
* This file is released under the LGPL.
* This file is part of LVM2.
*
* This copyrighted material is made available to anyone wishing to use,
* modify, copy, or redistribute it subject to the terms and conditions
* of the GNU General Public License v.2.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software Foundation,
* Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
#include "metadata.h"
@@ -14,7 +22,10 @@ typedef int (*lock_resource_fn) (struct cmd_context * cmd, const char *resource,
typedef void (*fin_lock_fn) (void);
typedef void (*reset_lock_fn) (void);
#define LCK_PRE_MEMLOCK 0x00000001 /* Is memlock() needed before calls? */
struct locking_type {
uint32_t flags;
lock_resource_fn lock_resource;
reset_lock_fn reset_locking;

View File

@@ -1,8 +1,16 @@
/*
* Copyright (C) 2001 Sistina Software (UK) Limited.
* Copyright (C) 2001-2004 Sistina Software, Inc. All rights reserved.
* Copyright (C) 2004 Red Hat, Inc. All rights reserved.
*
* This file is released under the LGPL.
* This file is part of LVM2.
*
* This copyrighted material is made available to anyone wishing to use,
* modify, copy, or redistribute it subject to the terms and conditions
* of the GNU General Public License v.2.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software Foundation,
* Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
#include "lib.h"
@@ -66,11 +74,12 @@ static int _no_lock_resource(struct cmd_context *cmd, const char *resource,
return 1;
}
int init_no_locking(struct locking_type *locking, struct config_tree *cf)
int init_no_locking(struct locking_type *locking, struct config_tree *cft)
{
locking->lock_resource = _no_lock_resource;
locking->reset_locking = _no_reset_locking;
locking->fin_locking = _no_fin_locking;
locking->flags = 0;
return 1;
}

View File

@@ -1,7 +1,16 @@
/*
* Copyright (C) 2001 Sistina Software (UK) Limited.
* Copyright (C) 2001-2004 Sistina Software, Inc. All rights reserved.
* Copyright (C) 2004 Red Hat, Inc. All rights reserved.
*
* This file is released under the LGPL.
* This file is part of LVM2.
*
* This copyrighted material is made available to anyone wishing to use,
* modify, copy, or redistribute it subject to the terms and conditions
* of the GNU General Public License v.2.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software Foundation,
* Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
#include "lib.h"
@@ -16,7 +25,7 @@ static FILE *_log_file;
static struct device _log_dev;
static struct str_list _log_dev_alias;
static int _verbose_level = 0;
static int _verbose_level = VERBOSE_BASE_LEVEL;
static int _test = 0;
static int _partial = 0;
static int _pvmove = 0;
@@ -33,6 +42,16 @@ static char _cmd_name[30] = "";
static char _msg_prefix[30] = " ";
static int _already_logging = 0;
static lvm2_log_fn_t _lvm2_log_fn = NULL;
void init_log_fn(lvm2_log_fn_t log_fn)
{
if (log_fn)
_lvm2_log_fn = log_fn;
else
_lvm2_log_fn = NULL;
}
void init_log_file(const char *log_file, int append)
{
const char *open_mode = append ? "a" : "w";
@@ -47,11 +66,9 @@ void init_log_file(const char *log_file, int append)
void init_log_direct(const char *log_file, int append)
{
const char *filename;
int open_flags = append ? 0 : O_TRUNC;
filename = dbg_strdup(log_file);
dev_create_file(filename, &_log_dev, &_log_dev_alias);
dev_create_file(log_file, &_log_dev, &_log_dev_alias);
if (!dev_open_flags(&_log_dev, O_RDWR | O_CREAT | open_flags, 1, 0))
return;
@@ -76,6 +93,9 @@ void log_suppress(int suppress)
void release_log_memory(void)
{
if (!_log_direct)
return;
dbg_free((char *) _log_dev_alias.str);
_log_dev_alias.str = "activate_log file";
}
@@ -184,19 +204,40 @@ int debug_level()
void print_log(int level, const char *file, int line, const char *format, ...)
{
va_list ap;
char buf[1024];
char buf[1024], buf2[4096];
int bufused, n;
char *trformat; /* Translated format string */
const char *message;
const char *trformat; /* Translated format string */
trformat = _(format);
if (_lvm2_log_fn) {
va_start(ap, format);
n = vsnprintf(buf2, sizeof(buf2) - 1, trformat, ap);
va_end(ap);
if (n < 0) {
fprintf(stderr, _("vsnprintf failed: skipping external "
"logging function"));
goto log_it;
}
buf2[sizeof(buf2) - 1] = '\0';
message = &buf2[0];
_lvm2_log_fn(level, file, line, message);
return;
}
log_it:
if (!_log_suppress) {
va_start(ap, format);
switch (level) {
case _LOG_DEBUG:
if (!strcmp("<backtrace>", format))
break;
if (_verbose_level > 2) {
if (_verbose_level >= _LOG_DEBUG) {
printf("%s%s", _cmd_name, _msg_prefix);
if (_indent)
printf(" ");
@@ -206,7 +247,7 @@ void print_log(int level, const char *file, int line, const char *format, ...)
break;
case _LOG_INFO:
if (_verbose_level > 1) {
if (_verbose_level >= _LOG_INFO) {
printf("%s%s", _cmd_name, _msg_prefix);
if (_indent)
printf(" ");
@@ -215,7 +256,7 @@ void print_log(int level, const char *file, int line, const char *format, ...)
}
break;
case _LOG_NOTICE:
if (_verbose_level) {
if (_verbose_level >= _LOG_NOTICE) {
printf("%s%s", _cmd_name, _msg_prefix);
if (_indent)
printf(" ");
@@ -224,22 +265,27 @@ void print_log(int level, const char *file, int line, const char *format, ...)
}
break;
case _LOG_WARN:
printf("%s%s", _cmd_name, _msg_prefix);
vprintf(trformat, ap);
putchar('\n');
if (_verbose_level >= _LOG_WARN) {
printf("%s%s", _cmd_name, _msg_prefix);
vprintf(trformat, ap);
putchar('\n');
}
break;
case _LOG_ERR:
fprintf(stderr, "%s%s", _cmd_name, _msg_prefix);
vfprintf(stderr, trformat, ap);
fputc('\n', stderr);
if (_verbose_level >= _LOG_ERR) {
fprintf(stderr, "%s%s", _cmd_name, _msg_prefix);
vfprintf(stderr, trformat, ap);
fputc('\n', stderr);
}
break;
case _LOG_FATAL:
default:
fprintf(stderr, "%s%s", _cmd_name, _msg_prefix);
vfprintf(stderr, trformat, ap);
fputc('\n', stderr);
if (_verbose_level >= _LOG_FATAL) {
fprintf(stderr, "%s%s", _cmd_name, _msg_prefix);
vfprintf(stderr, trformat, ap);
fputc('\n', stderr);
}
break;
;
}
va_end(ap);
}

View File

@@ -1,7 +1,16 @@
/*
* Copyright (C) 2001 Sistina Software (UK) Limited.
* Copyright (C) 2001-2004 Sistina Software, Inc. All rights reserved.
* Copyright (C) 2004 Red Hat, Inc. All rights reserved.
*
* This file is released under the GPL.
* This file is part of LVM2.
*
* This copyrighted material is made available to anyone wishing to use,
* modify, copy, or redistribute it subject to the terms and conditions
* of the GNU General Public License v.2.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software Foundation,
* Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
#ifndef _LVM_LOG_H
@@ -39,6 +48,8 @@
#define _LOG_ERR 3
#define _LOG_FATAL 2
#define VERBOSE_BASE_LEVEL _LOG_WARN
void init_log_file(const char *log_file, int append);
void init_log_direct(const char *log_file, int append);
void init_log_while_suspended(int log_while_suspended);
@@ -72,6 +83,11 @@ void log_suppress(int suppress);
/* Suppress messages to syslog */
void syslog_suppress(int suppress);
typedef void (*lvm2_log_fn_t) (int level, const char *file, int line,
const char *message);
void init_log_fn(lvm2_log_fn_t log_fn);
void print_log(int level, const char *file, int line, const char *format, ...)
__attribute__ ((format(printf, 4, 5)));

View File

@@ -1,11 +1,20 @@
/*
* Copyright (C) 2003 Sistina Software (UK) Limited.
* Copyright (C) 2003-2004 Sistina Software, Inc. All rights reserved.
* Copyright (C) 2004 Red Hat, Inc. All rights reserved.
*
* This file is released under the LGPL.
* This file is part of LVM2.
*
* This copyrighted material is made available to anyone wishing to use,
* modify, copy, or redistribute it subject to the terms and conditions
* of the GNU General Public License v.2.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software Foundation,
* Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
#ifndef _LVM_LV_ALLOC_H
#include "pool.h"
struct lv_segment *alloc_lv_segment(struct pool *mem, uint32_t stripes);
struct lv_segment *alloc_lv_segment(struct pool *mem, uint32_t num_areas);
#endif

View File

@@ -1,7 +1,16 @@
/*
* Copyright (C) 2001 Sistina Software
* Copyright (C) 2001-2004 Sistina Software, Inc. All rights reserved.
* Copyright (C) 2004 Red Hat, Inc. All rights reserved.
*
* This file is released under the LGPL.
* This file is part of LVM2.
*
* This copyrighted material is made available to anyone wishing to use,
* modify, copy, or redistribute it subject to the terms and conditions
* of the GNU General Public License v.2.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software Foundation,
* Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
#include "lib.h"
@@ -50,46 +59,54 @@ static void _put_extents(struct lv_segment *seg)
}
}
struct lv_segment *alloc_lv_segment(struct pool *mem, uint32_t stripes)
struct lv_segment *alloc_lv_segment(struct pool *mem, uint32_t num_areas)
{
struct lv_segment *seg;
uint32_t len = sizeof(*seg) + (stripes * sizeof(seg->area[0]));
uint32_t len = sizeof(*seg) + (num_areas * sizeof(seg->area[0]));
if (!(seg = pool_zalloc(mem, len))) {
stack;
return NULL;
}
list_init(&seg->tags);
return seg;
}
static int _alloc_stripe_area(struct logical_volume *lv, uint32_t stripes,
uint32_t stripe_size,
struct pv_area **areas, uint32_t *ix)
static int _alloc_parallel_area(struct logical_volume *lv, uint32_t area_count,
uint32_t stripe_size,
struct pv_area **areas, uint32_t *ix)
{
uint32_t count = lv->le_count - *ix;
uint32_t area_len = count / stripes;
uint32_t smallest = areas[stripes - 1]->count;
uint32_t count, area_len, smallest;
uint32_t s;
struct lv_segment *seg;
int striped = 0;
striped = 1;
count = lv->le_count - *ix;
area_len = count / (striped ? area_count : 1);
smallest = areas[area_count - 1]->count;
if (smallest < area_len)
area_len = smallest;
if (!(seg = alloc_lv_segment(lv->vg->cmd->mem, stripes))) {
log_err("Couldn't allocate new stripe segment.");
if (!(seg = alloc_lv_segment(lv->vg->cmd->mem, area_count))) {
log_err("Couldn't allocate new parallel segment.");
return 0;
}
seg->lv = lv;
seg->type = SEG_STRIPED;
seg->le = *ix;
seg->len = area_len * stripes;
seg->len = area_len * (striped ? area_count : 1);
seg->area_len = area_len;
seg->area_count = stripes;
seg->area_count = area_count;
seg->stripe_size = stripe_size;
seg->extents_moved = 0u;
for (s = 0; s < stripes; s++) {
for (s = 0; s < area_count; s++) {
struct pv_area *pva = areas[s];
seg->area[s].type = AREA_PV;
seg->area[s].u.pv.pv = pva->map->pvl->pv;
@@ -116,9 +133,9 @@ static int _comp_area(const void *l, const void *r)
return 0;
}
static int _alloc_striped(struct logical_volume *lv,
struct list *pvms, uint32_t allocated,
uint32_t stripes, uint32_t stripe_size)
static int _alloc_parallel(struct logical_volume *lv,
struct list *pvms, uint32_t allocated,
uint32_t stripes, uint32_t stripe_size)
{
int r = 0;
struct list *pvmh;
@@ -126,6 +143,9 @@ static int _alloc_striped(struct logical_volume *lv,
unsigned int pv_count = 0, ix;
struct pv_map *pvm;
size_t len;
uint32_t area_count;
area_count = stripes;
list_iterate(pvmh, pvms)
pv_count++;
@@ -149,9 +169,9 @@ static int _alloc_striped(struct logical_volume *lv,
areas[ix++] = list_item(pvm->areas.n, struct pv_area);
}
if (ix < stripes) {
if (ix < area_count) {
log_error("Insufficient allocatable extents suitable "
"for striping for logical volume "
"for parallel use for logical volume "
"%s: %u required", lv->name, lv->le_count);
goto out;
}
@@ -159,8 +179,8 @@ static int _alloc_striped(struct logical_volume *lv,
/* sort the areas so we allocate from the biggest */
qsort(areas, ix, sizeof(*areas), _comp_area);
if (!_alloc_stripe_area(lv, stripes, stripe_size, areas,
&allocated)) {
if (!_alloc_parallel_area(lv, area_count, stripe_size, areas,
&allocated)) {
stack;
goto out;
}
@@ -401,7 +421,7 @@ static int _allocate(struct volume_group *vg, struct logical_volume *lv,
goto out;
if (stripes > 1)
r = _alloc_striped(lv, pvms, allocated, stripes, stripe_size);
r = _alloc_parallel(lv, pvms, allocated, stripes, stripe_size);
else if (mirrored_pv)
r = _alloc_mirrored(lv, pvms, allocated, mirrored_pv,
@@ -519,6 +539,7 @@ struct logical_volume *lv_create_empty(struct format_instance *fi,
lv->size = UINT64_C(0);
lv->le_count = 0;
list_init(&lv->segments);
list_init(&lv->tags);
if (fi->fmt->ops->lv_setup && !fi->fmt->ops->lv_setup(fi, lv)) {
stack;
@@ -592,6 +613,7 @@ int lv_reduce(struct format_instance *fi,
struct list *segh;
struct lv_segment *seg;
uint32_t count = extents;
int striped;
for (segh = lv->segments.p;
(segh != &lv->segments) && count; segh = segh->p) {
@@ -606,6 +628,16 @@ int lv_reduce(struct format_instance *fi,
/* reduce this segment */
_put_extents(seg);
seg->len -= count;
striped = (seg->type == SEG_STRIPED);
/* Caller must ensure exact divisibility */
if (striped && (count % seg->area_count)) {
log_error("Segment extent reduction %" PRIu32
"not divisible by #stripes %" PRIu32,
count, seg->area_count);
return 0;
}
seg->area_len -=
count / (striped ? seg->area_count : 1);
_get_extents(seg);
count = 0;
}
@@ -708,42 +740,6 @@ int lv_remove(struct volume_group *vg, struct logical_volume *lv)
return 1;
}
/* Unlock list of LVs */
int unlock_lvs(struct cmd_context *cmd, struct list *lvs)
{
struct list *lvh;
struct logical_volume *lv;
list_iterate(lvh, lvs) {
lv = list_item(lvh, struct lv_list)->lv;
unlock_lv(cmd, lv->lvid.s);
}
return 1;
}
/* Lock a list of LVs */
int lock_lvs(struct cmd_context *cmd, struct list *lvs, int flags)
{
struct list *lvh;
struct logical_volume *lv;
list_iterate(lvh, lvs) {
lv = list_item(lvh, struct lv_list)->lv;
if (!lock_vol(cmd, lv->lvid.s, flags)) {
log_error("Failed to lock %s", lv->name);
list_uniterate(lvh, lvs, lvh) {
lv = list_item(lvh, struct lv_list)->lv;
unlock_lv(cmd, lv->lvid.s);
}
return 0;
}
}
return 1;
}
uint32_t find_free_lvnum(struct logical_volume *lv)
{
int lvnum_used[MAX_RESTRICTED_LVS + 1];

View File

@@ -1,13 +1,23 @@
/*
* Copyright (C) 2001 Sistina Software
* Copyright (C) 2001-2004 Sistina Software, Inc. All rights reserved.
* Copyright (C) 2004 Red Hat, Inc. All rights reserved.
*
* This file is released under the LGPL.
* This file is part of LVM2.
*
* This copyrighted material is made available to anyone wishing to use,
* modify, copy, or redistribute it subject to the terms and conditions
* of the GNU General Public License v.2.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software Foundation,
* Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
#include "lib.h"
#include "metadata.h"
#include "toolcontext.h"
#include "lv_alloc.h"
#include "str_list.h"
/*
* Test whether two segments could be merged by the current merging code
@@ -40,6 +50,9 @@ static int _segments_compatible(struct lv_segment *first,
return 0;
}
if (!str_list_lists_equal(&first->tags, &second->tags))
return 0;
return 1;
}
@@ -129,6 +142,11 @@ static int _lv_split_segment(struct logical_volume *lv, struct lv_segment *seg,
len = sizeof(*seg) + (seg->area_count * sizeof(seg->area[0]));
memcpy(split_seg, seg, len);
if (!str_list_dup(lv->vg->cmd->mem, &split_seg->tags, &seg->tags)) {
log_error("LV segment tags duplication failed");
return 0;
}
/* In case of a striped segment, the offset has to be / stripes */
if (seg->type == SEG_STRIPED)
offset /= seg->area_count;

View File

@@ -1,7 +1,16 @@
/*
* Copyright (C) 2001-2003 Sistina Software (UK) Limited.
* Copyright (C) 2001-2004 Sistina Software, Inc. All rights reserved.
* Copyright (C) 2004 Red Hat, Inc. All rights reserved.
*
* This file is released under the LGPL.
* This file is part of LVM2.
*
* This copyrighted material is made available to anyone wishing to use,
* modify, copy, or redistribute it subject to the terms and conditions
* of the GNU General Public License v.2.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software Foundation,
* Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
#include "lib.h"
@@ -211,6 +220,8 @@ struct volume_group *vg_create(struct cmd_context *cmd, const char *vg_name,
vg->snapshot_count = 0;
list_init(&vg->snapshots);
list_init(&vg->tags);
if (!(vg->fid = cmd->fmt->ops->create_instance(cmd->fmt, vg_name,
NULL))) {
log_error("Failed to create format instance");
@@ -293,6 +304,8 @@ struct physical_volume *pv_create(const struct format_type *fmt,
pv->pe_alloc_count = 0;
pv->fmt = fmt;
list_init(&pv->tags);
if (!fmt->ops->pv_setup(fmt, pe_start, existing_extent_count,
existing_extent_size,
pvmetadatacopies, pvmetadatasize, mdas,
@@ -464,7 +477,7 @@ int vg_write(struct volume_group *vg)
/* Write to each copy of the metadata area */
list_iterate(mdah, &vg->fid->metadata_areas) {
mda = list_item(mdah, struct metadata_area);
if(!mda->ops->vg_write) {
if (!mda->ops->vg_write) {
log_error("Format does not support writing volume"
"group metadata areas");
/* Revert */
@@ -562,6 +575,7 @@ static struct volume_group *_vg_read_orphans(struct cmd_context *cmd)
list_init(&vg->pvs);
list_init(&vg->lvs);
list_init(&vg->snapshots);
list_init(&vg->tags);
vg->cmd = cmd;
if (!(vg->name = pool_strdup(cmd->mem, ORPHAN))) {
log_error("vg name allocation failed");
@@ -805,6 +819,8 @@ struct physical_volume *pv_read(struct cmd_context *cmd, const char *pv_name,
return 0;
}
list_init(&pv->tags);
/* FIXME Move more common code up here */
if (!(info->fmt->ops->pv_read(info->fmt, pv_name, pv, mdas))) {
log_error("Failed to read existing physical volume '%s'",

View File

@@ -1,8 +1,19 @@
/*
* Copyright (C) 2001 Sistina Software (UK) Limited.
* Copyright (C) 2001-2004 Sistina Software, Inc. All rights reserved.
* Copyright (C) 2004 Red Hat, Inc. All rights reserved.
*
* This file is released under the LGPL.
* This file is part of LVM2.
*
* This copyrighted material is made available to anyone wishing to use,
* modify, copy, or redistribute it subject to the terms and conditions
* of the GNU General Public License v.2.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software Foundation,
* Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
/*
* This is the in core representation of a volume group and its
* associated physical and logical volumes.
*/
@@ -103,6 +114,8 @@ struct physical_volume {
uint64_t pe_start;
uint32_t pe_count;
uint32_t pe_alloc_count;
struct list tags;
};
struct metadata_area;
@@ -177,6 +190,8 @@ struct volume_group {
/* snapshots */
uint32_t snapshot_count;
struct list snapshots;
struct list tags;
};
struct lv_segment {
@@ -198,6 +213,8 @@ struct lv_segment {
uint32_t chunk_size;
uint32_t extents_moved;
struct list tags;
/* There will be one area for each stripe */
struct {
area_type_t type;
@@ -230,6 +247,7 @@ struct logical_volume {
uint32_t le_count;
struct list segments;
struct list tags;
};
struct snapshot {
@@ -419,10 +437,6 @@ int lv_extend_mirror(struct format_instance *fid,
uint32_t extents, struct list *allocatable_pvs,
uint32_t status);
/* Lock list of LVs */
int lock_lvs(struct cmd_context *cmd, struct list *lvs, int flags);
int unlock_lvs(struct cmd_context *cmd, struct list *lvs);
/* lv must be part of vg->lvs */
int lv_remove(struct volume_group *vg, struct logical_volume *lv);

View File

@@ -1,7 +1,16 @@
/*
* Copyright (C) 2003 Sistina Software (UK) Limited.
* Copyright (C) 2003-2004 Sistina Software, Inc. All rights reserved.
* Copyright (C) 2004 Red Hat, Inc. All rights reserved.
*
* This file is released under the LGPL.
* This file is part of LVM2.
*
* This copyrighted material is made available to anyone wishing to use,
* modify, copy, or redistribute it subject to the terms and conditions
* of the GNU General Public License v.2.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software Foundation,
* Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
#include "lib.h"

View File

@@ -1,7 +1,16 @@
/*
* Copyright (C) 2001 Sistina Software
* Copyright (C) 2001-2004 Sistina Software, Inc. All rights reserved.
* Copyright (C) 2004 Red Hat, Inc. All rights reserved.
*
* This file is released under the LGPL.
* This file is part of LVM2.
*
* This copyrighted material is made available to anyone wishing to use,
* modify, copy, or redistribute it subject to the terms and conditions
* of the GNU General Public License v.2.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software Foundation,
* Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
#include "lib.h"

View File

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

View File

@@ -1,7 +1,16 @@
/*
* Copyright (C) 2002 Sistina Software (UK) Limited.
* Copyright (C) 2002-2004 Sistina Software, Inc. All rights reserved.
* Copyright (C) 2004 Red Hat, Inc. All rights reserved.
*
* This file is released under the LGPL.
* This file is part of LVM2.
*
* This copyrighted material is made available to anyone wishing to use,
* modify, copy, or redistribute it subject to the terms and conditions
* of the GNU General Public License v.2.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software Foundation,
* Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
#include "lib.h"

View File

@@ -1,7 +1,16 @@
/*
* Copyright (C) 2001 Sistina Software (UK) Limited.
* Copyright (C) 2001-2004 Sistina Software, Inc. All rights reserved.
* Copyright (C) 2004 Red Hat, Inc. All rights reserved.
*
* This file is released under the LGPL.
* This file is part of LVM2.
*
* This copyrighted material is made available to anyone wishing to use,
* modify, copy, or redistribute it subject to the terms and conditions
* of the GNU General Public License v.2.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software Foundation,
* Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
#include "lib.h"

View File

@@ -1,7 +1,16 @@
/*
* Copyright (C) 2001 Sistina Software (UK) Limited.
* Copyright (C) 2001-2004 Sistina Software, Inc. All rights reserved.
* Copyright (C) 2004 Red Hat, Inc. All rights reserved.
*
* This file is released under the LGPL.
* This file is part of LVM2.
*
* This copyrighted material is made available to anyone wishing to use,
* modify, copy, or redistribute it subject to the terms and conditions
* of the GNU General Public License v.2.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software Foundation,
* Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
#ifndef _LVM_CRC_H

View File

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

View File

@@ -1,7 +1,16 @@
/*
* Copyright (C) 2001 Sistina Software (UK) Limited.
* Copyright (C) 2001-2004 Sistina Software, Inc. All rights reserved.
* Copyright (C) 2004 Red Hat, Inc. All rights reserved.
*
* This file is released under the LGPL.
* This file is part of LVM2.
*
* This copyrighted material is made available to anyone wishing to use,
* modify, copy, or redistribute it subject to the terms and conditions
* of the GNU General Public License v.2.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software Foundation,
* Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
/*

View File

@@ -1,7 +1,16 @@
/*
* Copyright (C) 2001 Sistina Software (UK) Limited.
* Copyright (C) 2001-2004 Sistina Software, Inc. All rights reserved.
* Copyright (C) 2004 Red Hat, Inc. All rights reserved.
*
* This file is released under the LGPL.
* This file is part of LVM2.
*
* This copyrighted material is made available to anyone wishing to use,
* modify, copy, or redistribute it subject to the terms and conditions
* of the GNU General Public License v.2.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software Foundation,
* Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
#include "lib.h"

View File

@@ -1,7 +1,16 @@
/*
* Copyright (C) 2001 Sistina Software (UK) Limited.
* Copyright (C) 2001-2004 Sistina Software, Inc. All rights reserved.
* Copyright (C) 2004 Red Hat, Inc. All rights reserved.
*
* This file is released under the LGPL.
* This file is part of LVM2.
*
* This copyrighted material is made available to anyone wishing to use,
* modify, copy, or redistribute it subject to the terms and conditions
* of the GNU General Public License v.2.
*
* You should have received a copy of the GNU General Public License
* along with this program; if not, write to the Free Software Foundation,
* Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
/*

Some files were not shown because too many files have changed in this diff Show More