* liblvm base patches I @ 2009-02-19 19:01 Thomas Woerner 2009-02-19 19:01 ` [PATCH 1/3] New parameter system_dir for create_toolcontext Thomas Woerner 0 siblings, 1 reply; 8+ messages in thread From: Thomas Woerner @ 2009-02-19 19:01 UTC (permalink / raw) To: lvm-devel Here are the base patches for liblvm after cleanup. Splitting of create_toolcontext will follow in another patch and also error code and log message handling. ^ permalink raw reply [flat|nested] 8+ messages in thread
* [PATCH 1/3] New parameter system_dir for create_toolcontext. 2009-02-19 19:01 liblvm base patches I Thomas Woerner @ 2009-02-19 19:01 ` Thomas Woerner 2009-02-19 18:14 ` Dave Wysochanski 2009-02-19 19:01 ` [PATCH 2/3] Added more version defines to tools/version.h.in Thomas Woerner 0 siblings, 2 replies; 8+ messages in thread From: Thomas Woerner @ 2009-02-19 19:01 UTC (permalink / raw) To: lvm-devel cmd->sys_dir, which defaults to DEFAULT_SYS_DIR, will be set to system_dir i the parameter is not NULL. If the environment variable LVM_SYSTEM_DIR is set it will overwrite any value of cmd->sys_dir. Signed-off-by: Thomas Woerner <twoerner@redhat.com> --- daemons/clvmd/lvm-functions.c | 4 ++-- lib/commands/toolcontext.c | 16 ++++++++++++++-- lib/commands/toolcontext.h | 9 +++++++-- tools/lvmcmdline.c | 4 ++-- 4 files changed, 25 insertions(+), 8 deletions(-) diff --git a/daemons/clvmd/lvm-functions.c b/daemons/clvmd/lvm-functions.c index 5cf7eff..d720802 100644 --- a/daemons/clvmd/lvm-functions.c +++ b/daemons/clvmd/lvm-functions.c @@ -1,6 +1,6 @@ /* * Copyright (C) 2002-2004 Sistina Software, Inc. All rights reserved. - * Copyright (C) 2004-2008 Red Hat, Inc. All rights reserved. + * Copyright (C) 2004-2009 Red Hat, Inc. All rights reserved. * * This file is part of LVM2. * @@ -724,7 +724,7 @@ void lvm_do_backup(const char *vgname) /* Called to initialise the LVM context of the daemon */ int init_lvm(int using_gulm) { - if (!(cmd = create_toolcontext(1))) { + if (!(cmd = create_toolcontext(1, NULL))) { log_error("Failed to allocate command context"); return 0; } diff --git a/lib/commands/toolcontext.c b/lib/commands/toolcontext.c index 0a98325..39c644c 100644 --- a/lib/commands/toolcontext.c +++ b/lib/commands/toolcontext.c @@ -1,6 +1,6 @@ /* * Copyright (C) 2001-2004 Sistina Software, Inc. All rights reserved. - * Copyright (C) 2004-2007 Red Hat, Inc. All rights reserved. + * Copyright (C) 2004-2009 Red Hat, Inc. All rights reserved. * * This file is part of LVM2. * @@ -998,7 +998,8 @@ static void _init_globals(struct cmd_context *cmd) } /* Entry point */ -struct cmd_context *create_toolcontext(unsigned is_long_lived) +struct cmd_context *create_toolcontext(unsigned is_long_lived, + const char *system_dir) { struct cmd_context *cmd; @@ -1030,6 +1031,17 @@ struct cmd_context *create_toolcontext(unsigned is_long_lived) strcpy(cmd->sys_dir, DEFAULT_SYS_DIR); + /* + * cmd->sys_dir, which defaults to DEFAULT_SYS_DIR, will be set to + * system_dir if the parameter is not NULL. If the environment + * variable LVM_SYSTEM_DIR is set, it will overwrite any value of + * cmd->sys_dir. + */ + if (system_dir) { + strncpy(cmd->sys_dir, system_dir, sizeof(cmd->sys_dir)); + cmd->sys_dir[sizeof(cmd->sys_dir) - 1] = '\0'; + } + if (!_get_env_vars(cmd)) goto error; diff --git a/lib/commands/toolcontext.h b/lib/commands/toolcontext.h index 7d2aef9..eb2b6ef 100644 --- a/lib/commands/toolcontext.h +++ b/lib/commands/toolcontext.h @@ -1,6 +1,6 @@ /* * Copyright (C) 2001-2004 Sistina Software, Inc. All rights reserved. - * Copyright (C) 2004-2007 Red Hat, Inc. All rights reserved. + * Copyright (C) 2004-2009 Red Hat, Inc. All rights reserved. * * This file is part of LVM2. * @@ -94,7 +94,12 @@ struct cmd_context { char sysfs_dir[PATH_MAX]; }; -struct cmd_context *create_toolcontext(unsigned is_long_lived); +/* + * cmd->sys_dir, which defaults to DEFAULT_SYS_DIR, will be set to system_dir + * if the parameter is not NULL. If the environment variable LVM_SYSTEM_DIR is + * set, it will overwrite any value of cmd->sys_dir. + */ +struct cmd_context *create_toolcontext(unsigned is_long_lived, const char *system_dir); void destroy_toolcontext(struct cmd_context *cmd); int refresh_toolcontext(struct cmd_context *cmd); int config_files_changed(struct cmd_context *cmd); diff --git a/tools/lvmcmdline.c b/tools/lvmcmdline.c index 880f31e..cb1bfc6 100644 --- a/tools/lvmcmdline.c +++ b/tools/lvmcmdline.c @@ -1,6 +1,6 @@ /* * Copyright (C) 2001-2004 Sistina Software, Inc. All rights reserved. - * Copyright (C) 2004-2007 Red Hat, Inc. All rights reserved. + * Copyright (C) 2004-2009 Red Hat, Inc. All rights reserved. * * This file is part of LVM2. * @@ -1158,7 +1158,7 @@ struct cmd_context *init_lvm(void) _cmdline.the_args = &_the_args[0]; - if (!(cmd = create_toolcontext(0))) + if (!(cmd = create_toolcontext(0, NULL))) return_NULL; return cmd; -- 1.6.1.3 ^ permalink raw reply related [flat|nested] 8+ messages in thread
* [PATCH 1/3] New parameter system_dir for create_toolcontext. 2009-02-19 19:01 ` [PATCH 1/3] New parameter system_dir for create_toolcontext Thomas Woerner @ 2009-02-19 18:14 ` Dave Wysochanski 2009-02-19 19:01 ` [PATCH 2/3] Added more version defines to tools/version.h.in Thomas Woerner 1 sibling, 0 replies; 8+ messages in thread From: Dave Wysochanski @ 2009-02-19 18:14 UTC (permalink / raw) To: lvm-devel On Thu, 2009-02-19 at 20:01 +0100, Thomas Woerner wrote: > cmd->sys_dir, which defaults to DEFAULT_SYS_DIR, will be set to system_dir i > the parameter is not NULL. If the environment variable LVM_SYSTEM_DIR is set > it will overwrite any value of cmd->sys_dir. > > Signed-off-by: Thomas Woerner <twoerner@redhat.com> > --- > daemons/clvmd/lvm-functions.c | 4 ++-- > lib/commands/toolcontext.c | 16 ++++++++++++++-- > lib/commands/toolcontext.h | 9 +++++++-- > tools/lvmcmdline.c | 4 ++-- > 4 files changed, 25 insertions(+), 8 deletions(-) > > diff --git a/daemons/clvmd/lvm-functions.c b/daemons/clvmd/lvm-functions.c > index 5cf7eff..d720802 100644 > --- a/daemons/clvmd/lvm-functions.c > +++ b/daemons/clvmd/lvm-functions.c > @@ -1,6 +1,6 @@ > /* > * Copyright (C) 2002-2004 Sistina Software, Inc. All rights reserved. > - * Copyright (C) 2004-2008 Red Hat, Inc. All rights reserved. > + * Copyright (C) 2004-2009 Red Hat, Inc. All rights reserved. > * > * This file is part of LVM2. > * > @@ -724,7 +724,7 @@ void lvm_do_backup(const char *vgname) > /* Called to initialise the LVM context of the daemon */ > int init_lvm(int using_gulm) > { > - if (!(cmd = create_toolcontext(1))) { > + if (!(cmd = create_toolcontext(1, NULL))) { > log_error("Failed to allocate command context"); > return 0; > } > diff --git a/lib/commands/toolcontext.c b/lib/commands/toolcontext.c > index 0a98325..39c644c 100644 > --- a/lib/commands/toolcontext.c > +++ b/lib/commands/toolcontext.c > @@ -1,6 +1,6 @@ > /* > * Copyright (C) 2001-2004 Sistina Software, Inc. All rights reserved. > - * Copyright (C) 2004-2007 Red Hat, Inc. All rights reserved. > + * Copyright (C) 2004-2009 Red Hat, Inc. All rights reserved. > * > * This file is part of LVM2. > * > @@ -998,7 +998,8 @@ static void _init_globals(struct cmd_context *cmd) > } > > /* Entry point */ > -struct cmd_context *create_toolcontext(unsigned is_long_lived) > +struct cmd_context *create_toolcontext(unsigned is_long_lived, > + const char *system_dir) > { > struct cmd_context *cmd; > > @@ -1030,6 +1031,17 @@ struct cmd_context *create_toolcontext(unsigned is_long_lived) > > strcpy(cmd->sys_dir, DEFAULT_SYS_DIR); > > + /* > + * cmd->sys_dir, which defaults to DEFAULT_SYS_DIR, will be set to > + * system_dir if the parameter is not NULL. If the environment > + * variable LVM_SYSTEM_DIR is set, it will overwrite any value of > + * cmd->sys_dir. > + */ > + if (system_dir) { > + strncpy(cmd->sys_dir, system_dir, sizeof(cmd->sys_dir)); > + cmd->sys_dir[sizeof(cmd->sys_dir) - 1] = '\0'; > + } > + > if (!_get_env_vars(cmd)) > goto error; > > diff --git a/lib/commands/toolcontext.h b/lib/commands/toolcontext.h > index 7d2aef9..eb2b6ef 100644 > --- a/lib/commands/toolcontext.h > +++ b/lib/commands/toolcontext.h > @@ -1,6 +1,6 @@ > /* > * Copyright (C) 2001-2004 Sistina Software, Inc. All rights reserved. > - * Copyright (C) 2004-2007 Red Hat, Inc. All rights reserved. > + * Copyright (C) 2004-2009 Red Hat, Inc. All rights reserved. > * > * This file is part of LVM2. > * > @@ -94,7 +94,12 @@ struct cmd_context { > char sysfs_dir[PATH_MAX]; > }; > > -struct cmd_context *create_toolcontext(unsigned is_long_lived); > +/* > + * cmd->sys_dir, which defaults to DEFAULT_SYS_DIR, will be set to system_dir > + * if the parameter is not NULL. If the environment variable LVM_SYSTEM_DIR is > + * set, it will overwrite any value of cmd->sys_dir. > + */ > +struct cmd_context *create_toolcontext(unsigned is_long_lived, const char *system_dir); > void destroy_toolcontext(struct cmd_context *cmd); > int refresh_toolcontext(struct cmd_context *cmd); > int config_files_changed(struct cmd_context *cmd); > diff --git a/tools/lvmcmdline.c b/tools/lvmcmdline.c > index 880f31e..cb1bfc6 100644 > --- a/tools/lvmcmdline.c > +++ b/tools/lvmcmdline.c > @@ -1,6 +1,6 @@ > /* > * Copyright (C) 2001-2004 Sistina Software, Inc. All rights reserved. > - * Copyright (C) 2004-2007 Red Hat, Inc. All rights reserved. > + * Copyright (C) 2004-2009 Red Hat, Inc. All rights reserved. > * > * This file is part of LVM2. > * > @@ -1158,7 +1158,7 @@ struct cmd_context *init_lvm(void) > > _cmdline.the_args = &_the_args[0]; > > - if (!(cmd = create_toolcontext(0))) > + if (!(cmd = create_toolcontext(0, NULL))) > return_NULL; > > return cmd; Ack. ^ permalink raw reply [flat|nested] 8+ messages in thread
* [PATCH 2/3] Added more version defines to tools/version.h.in. 2009-02-19 19:01 ` [PATCH 1/3] New parameter system_dir for create_toolcontext Thomas Woerner 2009-02-19 18:14 ` Dave Wysochanski @ 2009-02-19 19:01 ` Thomas Woerner 2009-02-19 18:15 ` Dave Wysochanski 2009-02-19 19:01 ` [PATCH 3/3] New base files needed for liblvm with doxygen style descriptions Thomas Woerner 1 sibling, 2 replies; 8+ messages in thread From: Thomas Woerner @ 2009-02-19 19:01 UTC (permalink / raw) To: lvm-devel Modified tools/version.h.in and configure.in: New defines LVM_MAJOR, LVM_MINOR, LVM_PATCHLEVEL and LVM_RELEASE generated in configure. Maybe a rename of version.h.in to lvm_version.h.in would be good to prevent name conflicts with other projects. Added GPL header to version.h.in. TODO: recreate configure Signed-off-by: Thomas Woerner <twoerner@redhat.com> --- configure.in | 13 ++++++++++++- tools/version.h.in | 27 +++++++++++++++++++++++++++ 2 files changed, 39 insertions(+), 1 deletions(-) diff --git a/configure.in b/configure.in index ea77eff..02a9bbb 100644 --- a/configure.in +++ b/configure.in @@ -1,6 +1,6 @@ ############################################################################### ## Copyright (C) 2000-2004 Sistina Software, Inc. All rights reserved. -## Copyright (C) 2004-2008 Red Hat, Inc. All rights reserved. +## Copyright (C) 2004-2009 Red Hat, Inc. All rights reserved. ## ## This copyrighted material is made available to anyone wishing to use, ## modify, copy, or redistribute it subject to the terms and conditions @@ -723,6 +723,13 @@ DM_LIB_PATCHLEVEL=`cat VERSION_DM | awk -F '[[-. ]]' '{printf "%s.%s.%s",$1,$2,$ LVM_VERSION="\"`cat VERSION 2>/dev/null || echo Unknown`\"" +VER=`cat VERSION | awk '{print $1}'` +echo "$VER" | grep -qi "cvs" && LVM_RELEASE=\"cvs\" || LVM_RELEASE=\"\" +VER=`echo "$VER" | awk -F '-' '{print $1}'` +LVM_MAJOR=`echo "$VER" | awk -F '.' '{printf "%s",$1}'` +LVM_MINOR=`echo "$VER" | awk -F '.' '{printf "%s",$2}'` +LVM_PATCHLEVEL=`echo "$VER" | awk -F '.' '{printf "%s",$3}'` + ################################################################################ AC_SUBST(BUILD_DMEVENTD) AC_SUBST(CFLAGS) @@ -761,6 +768,10 @@ AC_SUBST(LVM1) AC_SUBST(LVM1_FALLBACK) AC_SUBST(CONFDIR) AC_SUBST(LVM_VERSION) +AC_SUBST(LVM_MAJOR) +AC_SUBST(LVM_MINOR) +AC_SUBST(LVM_PATCHLEVEL) +AC_SUBST(LVM_RELEASE) AC_SUBST(MIRRORS) AC_SUBST(MSGFMT) AC_SUBST(OWNER) diff --git a/tools/version.h.in b/tools/version.h.in index a122792..f41fcae 100644 --- a/tools/version.h.in +++ b/tools/version.h.in @@ -1,3 +1,30 @@ +/* + * Copyright (C) 2001-2004 Sistina Software, Inc. All rights reserved. + * Copyright (C) 2004-2009 Red Hat, Inc. All rights reserved. + * + * This file is part of LVM2. + * + * This copyrighted material is made available to anyone wishing to use, + * modify, copy, or redistribute it subject to the terms and conditions + * of the GNU Lesser General Public License v.2.1. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + */ + #ifndef _LVM_VERSION_H +/** + * The LVM version number + * + * LVM_MAJOR.LVM_MINOR.LVM_PATCHLEVEL[-LVM_RELEASE] + * + * If the LVM release tag contains "cvs" then it is a development snapshot. + */ + #define LVM_VERSION @LVM_VERSION@ +#define LVM_MAJOR @LVM_MAJOR@ +#define LVM_MINOR @LVM_MINOR@ +#define LVM_PATCHLEVEL @LVM_PATCHLEVEL@ +#define LVM_RELEASE @LVM_RELEASE@ #endif -- 1.6.1.3 ^ permalink raw reply related [flat|nested] 8+ messages in thread
* [PATCH 2/3] Added more version defines to tools/version.h.in. 2009-02-19 19:01 ` [PATCH 2/3] Added more version defines to tools/version.h.in Thomas Woerner @ 2009-02-19 18:15 ` Dave Wysochanski 2009-02-19 19:01 ` [PATCH 3/3] New base files needed for liblvm with doxygen style descriptions Thomas Woerner 1 sibling, 0 replies; 8+ messages in thread From: Dave Wysochanski @ 2009-02-19 18:15 UTC (permalink / raw) To: lvm-devel On Thu, 2009-02-19 at 20:01 +0100, Thomas Woerner wrote: > Modified tools/version.h.in and configure.in: > New defines LVM_MAJOR, LVM_MINOR, LVM_PATCHLEVEL and LVM_RELEASE generated in > configure. Maybe a rename of version.h.in to lvm_version.h.in would be good to > prevent name conflicts with other projects. Added GPL header to version.h.in. > > TODO: recreate configure > > Signed-off-by: Thomas Woerner <twoerner@redhat.com> > --- > configure.in | 13 ++++++++++++- > tools/version.h.in | 27 +++++++++++++++++++++++++++ > 2 files changed, 39 insertions(+), 1 deletions(-) > > diff --git a/configure.in b/configure.in > index ea77eff..02a9bbb 100644 > --- a/configure.in > +++ b/configure.in > @@ -1,6 +1,6 @@ > ############################################################################### > ## Copyright (C) 2000-2004 Sistina Software, Inc. All rights reserved. > -## Copyright (C) 2004-2008 Red Hat, Inc. All rights reserved. > +## Copyright (C) 2004-2009 Red Hat, Inc. All rights reserved. > ## > ## This copyrighted material is made available to anyone wishing to use, > ## modify, copy, or redistribute it subject to the terms and conditions > @@ -723,6 +723,13 @@ DM_LIB_PATCHLEVEL=`cat VERSION_DM | awk -F '[[-. ]]' '{printf "%s.%s.%s",$1,$2,$ > > LVM_VERSION="\"`cat VERSION 2>/dev/null || echo Unknown`\"" > > +VER=`cat VERSION | awk '{print $1}'` > +echo "$VER" | grep -qi "cvs" && LVM_RELEASE=\"cvs\" || LVM_RELEASE=\"\" > +VER=`echo "$VER" | awk -F '-' '{print $1}'` > +LVM_MAJOR=`echo "$VER" | awk -F '.' '{printf "%s",$1}'` > +LVM_MINOR=`echo "$VER" | awk -F '.' '{printf "%s",$2}'` > +LVM_PATCHLEVEL=`echo "$VER" | awk -F '.' '{printf "%s",$3}'` > + > ################################################################################ > AC_SUBST(BUILD_DMEVENTD) > AC_SUBST(CFLAGS) > @@ -761,6 +768,10 @@ AC_SUBST(LVM1) > AC_SUBST(LVM1_FALLBACK) > AC_SUBST(CONFDIR) > AC_SUBST(LVM_VERSION) > +AC_SUBST(LVM_MAJOR) > +AC_SUBST(LVM_MINOR) > +AC_SUBST(LVM_PATCHLEVEL) > +AC_SUBST(LVM_RELEASE) > AC_SUBST(MIRRORS) > AC_SUBST(MSGFMT) > AC_SUBST(OWNER) > diff --git a/tools/version.h.in b/tools/version.h.in > index a122792..f41fcae 100644 > --- a/tools/version.h.in > +++ b/tools/version.h.in > @@ -1,3 +1,30 @@ > +/* > + * Copyright (C) 2001-2004 Sistina Software, Inc. All rights reserved. > + * Copyright (C) 2004-2009 Red Hat, Inc. All rights reserved. > + * > + * This file is part of LVM2. > + * > + * This copyrighted material is made available to anyone wishing to use, > + * modify, copy, or redistribute it subject to the terms and conditions > + * of the GNU Lesser General Public License v.2.1. > + * > + * You should have received a copy of the GNU Lesser General Public License > + * along with this program; if not, write to the Free Software Foundation, > + * Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA > + */ > + > #ifndef _LVM_VERSION_H > +/** > + * The LVM version number > + * > + * LVM_MAJOR.LVM_MINOR.LVM_PATCHLEVEL[-LVM_RELEASE] > + * > + * If the LVM release tag contains "cvs" then it is a development snapshot. > + */ > + > #define LVM_VERSION @LVM_VERSION@ > +#define LVM_MAJOR @LVM_MAJOR@ > +#define LVM_MINOR @LVM_MINOR@ > +#define LVM_PATCHLEVEL @LVM_PATCHLEVEL@ > +#define LVM_RELEASE @LVM_RELEASE@ > #endif Ack. Will you generate configure or someone else? ^ permalink raw reply [flat|nested] 8+ messages in thread
* [PATCH 3/3] New base files needed for liblvm with doxygen style descriptions. 2009-02-19 19:01 ` [PATCH 2/3] Added more version defines to tools/version.h.in Thomas Woerner 2009-02-19 18:15 ` Dave Wysochanski @ 2009-02-19 19:01 ` Thomas Woerner 2009-02-19 18:18 ` Dave Wysochanski 1 sibling, 1 reply; 8+ messages in thread From: Thomas Woerner @ 2009-02-19 19:01 UTC (permalink / raw) To: lvm-devel Added files lib/lvm.h and lib/lvm_base.c: New structure lvm (used as an alias to cmd_context), new type definition lvm_t for the lvm handle. Added functions lvm_create, lvm_destroy and lvm_reload_config using the new handle. Modified test/api/test.c: Use new lvm.h header file and lvm_t handle. Removed lib/lvm2.h Signed-off-by: Thomas Woerner <twoerner@redhat.com> --- lib/Makefile.in | 5 ++- lib/lvm.h | 57 +++++++++++++++++++++++++++++++++++++++++++++++++++++++ lib/lvm2.h | 53 --------------------------------------------------- test/api/test.c | 17 +++++++-------- 4 files changed, 68 insertions(+), 64 deletions(-) create mode 100644 lib/lvm.h delete mode 100644 lib/lvm2.h diff --git a/lib/Makefile.in b/lib/Makefile.in index 54092cd..47786a7 100644 --- a/lib/Makefile.in +++ b/lib/Makefile.in @@ -1,6 +1,6 @@ # # Copyright (C) 2001-2004 Sistina Software, Inc. All rights reserved. -# Copyright (C) 2004-2007 Red Hat, Inc. All rights reserved. +# Copyright (C) 2004-2009 Red Hat, Inc. All rights reserved. # # This file is part of LVM2. # @@ -86,7 +86,8 @@ SOURCES =\ report/report.c \ striped/striped.c \ uuid/uuid.c \ - zero/zero.c + zero/zero.c \ + lvm_base.c ifeq ("@LVM1@", "internal") SOURCES +=\ diff --git a/lib/lvm.h b/lib/lvm.h new file mode 100644 index 0000000..09ff680 --- /dev/null +++ b/lib/lvm.h @@ -0,0 +1,57 @@ +/* + * Copyright (C) 2008,2009 Red Hat, Inc. All rights reserved. + * + * This file is part of LVM2. + * + * This copyrighted material is made available to anyone wishing to use, + * modify, copy, or redistribute it subject to the terms and conditions + * of the GNU Lesser General Public License v.2.1. + * + * You should have received a copy of the GNU Lesser General Public License + * along with this program; if not, write to the Free Software Foundation, + * Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + */ +#ifndef _LIB_LVM_H +#define _LIB_LVM_H + +#include "version.h" + +#include <stdint.h> + +struct lvm; /* internal data */ + +/** + * The lvm handle. + */ +typedef struct lvm *lvm_t; + +/** + * Create a LVM handle. + * + * \param system_dir + * Set an alternative system path or NULL for the default value. If + * the environment variable LVM_SYSTEM_DIR is set, it will overwrite + * this value. + * \return A valid LVM handle is returned or NULL if there has been a + * memory allocation problem. You have to check if an error occured + * with the lvm_error function. + */ +lvm_t lvm_create(const char *system_dir); + +/** + * Destroy a LVM handle allocated with lvm_create. + * + * \param libh + * Handle obtained from lvm_create. + */ +void lvm_destroy(lvm_t libh); + +/** + * Reload the original configuration from the system directory. + * + * \param libh + * Handle obtained from lvm_create. + */ +int lvm_reload_config(lvm_t libh); + +#endif /* _LIB_LVM_H */ diff --git a/lib/lvm2.h b/lib/lvm2.h deleted file mode 100644 index b18cead..0000000 --- a/lib/lvm2.h +++ /dev/null @@ -1,53 +0,0 @@ -/* - * Copyright (C) 2001-2004 Sistina Software, Inc. All rights reserved. - * Copyright (C) 2004-2008 Red Hat, Inc. All rights reserved. - * - * This file is part of LVM2. - * - * This copyrighted material is made available to anyone wishing to use, - * modify, copy, or redistribute it subject to the terms and conditions - * of the GNU Lesser General Public License v.2.1. - * - * You should have received a copy of the GNU Lesser General Public License - * along with this program; if not, write to the Free Software Foundation, - * Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA - */ -#ifndef _LIB_LVM2_H -#define _LIB_LVM2_H - -#include <stdint.h> - -/* - * Library Initialisation - * FIXME: For now just #define lvm2_create() and lvm2_destroy() to - * create_toolcontext() and destroy_toolcontext() - */ -struct arg; -struct cmd_context; -struct cmd_context *create_toolcontext(unsigned is_long_lived); -void destroy_toolcontext(struct cmd_context *cmd); - -/* - * lvm2_create -lvm_handle_t lvm2_create(void); - * - * Description: Create an LVM2 handle used in many other APIs. - * - * Returns: - * NULL: Fail - unable to initialise handle. - * non-NULL: Success - valid LVM2 handle returned - */ -#define lvm2_create(X) create_toolcontext(1) - -/* - * lvm2_destroy -void lvm2_destroy(lvm_handle_t h); - * - * Description: Destroy an LVM2 handle allocated with lvm2_create - * - * Parameters: - * - h (IN): handle obtained from lvm2_create - */ -#define lvm2_destroy(X) destroy_toolcontext(X) - -#endif diff --git a/test/api/test.c b/test/api/test.c index de53c46..b742976 100644 --- a/test/api/test.c +++ b/test/api/test.c @@ -1,6 +1,6 @@ /* * Copyright (C) 2001-2004 Sistina Software, Inc. All rights reserved. - * Copyright (C) 2004-2008 Red Hat, Inc. All rights reserved. + * Copyright (C) 2004-2009 Red Hat, Inc. All rights reserved. * * This file is part of LVM2. * @@ -16,7 +16,7 @@ #include <string.h> #include <stdlib.h> #include <readline/readline.h> -#include "lvm2.h" +#include "lvm.h" #define MAX_ARGS 64 @@ -48,7 +48,7 @@ static int lvm_split(char *str, int *argc, char **argv, int max) return *argc; } -static int lvmapi_test_shell(void *h) +static int lvmapi_test_shell(lvm_t libh) { int argc, i; char *input = NULL, *args[MAX_ARGS], **argv; @@ -99,18 +99,17 @@ static int lvmapi_test_shell(void *h) int main (int argc, char *argv[]) { - void *h; + lvm_t libh; - h = lvm2_create(); - if (!h) { + libh = lvm_create(NULL); + if (!libh) { printf("Unable to open lvm library instance\n"); return 1; } - lvmapi_test_shell(h); + lvmapi_test_shell(libh); - if (h) - lvm2_destroy(h); + lvm_destroy(libh); return 0; } -- 1.6.1.3 ^ permalink raw reply related [flat|nested] 8+ messages in thread
* [PATCH 3/3] New base files needed for liblvm with doxygen style descriptions. 2009-02-19 19:01 ` [PATCH 3/3] New base files needed for liblvm with doxygen style descriptions Thomas Woerner @ 2009-02-19 18:18 ` Dave Wysochanski 0 siblings, 0 replies; 8+ messages in thread From: Dave Wysochanski @ 2009-02-19 18:18 UTC (permalink / raw) To: lvm-devel On Thu, 2009-02-19 at 20:01 +0100, Thomas Woerner wrote: > Added files lib/lvm.h and lib/lvm_base.c: > New structure lvm (used as an alias to cmd_context), new type definition lvm_t > for the lvm handle. Added functions lvm_create, lvm_destroy and > lvm_reload_config using the new handle. > > Modified test/api/test.c: > Use new lvm.h header file and lvm_t handle. > > Removed lib/lvm2.h > > Signed-off-by: Thomas Woerner <twoerner@redhat.com> > --- > lib/Makefile.in | 5 ++- > lib/lvm.h | 57 +++++++++++++++++++++++++++++++++++++++++++++++++++++++ > lib/lvm2.h | 53 --------------------------------------------------- > test/api/test.c | 17 +++++++-------- > 4 files changed, 68 insertions(+), 64 deletions(-) > create mode 100644 lib/lvm.h > delete mode 100644 lib/lvm2.h > > diff --git a/lib/Makefile.in b/lib/Makefile.in > index 54092cd..47786a7 100644 > --- a/lib/Makefile.in > +++ b/lib/Makefile.in > @@ -1,6 +1,6 @@ > # > # Copyright (C) 2001-2004 Sistina Software, Inc. All rights reserved. > -# Copyright (C) 2004-2007 Red Hat, Inc. All rights reserved. > +# Copyright (C) 2004-2009 Red Hat, Inc. All rights reserved. > # > # This file is part of LVM2. > # > @@ -86,7 +86,8 @@ SOURCES =\ > report/report.c \ > striped/striped.c \ > uuid/uuid.c \ > - zero/zero.c > + zero/zero.c \ > + lvm_base.c > > ifeq ("@LVM1@", "internal") > SOURCES +=\ > diff --git a/lib/lvm.h b/lib/lvm.h > new file mode 100644 > index 0000000..09ff680 > --- /dev/null > +++ b/lib/lvm.h > @@ -0,0 +1,57 @@ > +/* > + * Copyright (C) 2008,2009 Red Hat, Inc. All rights reserved. > + * > + * This file is part of LVM2. > + * > + * This copyrighted material is made available to anyone wishing to use, > + * modify, copy, or redistribute it subject to the terms and conditions > + * of the GNU Lesser General Public License v.2.1. > + * > + * You should have received a copy of the GNU Lesser General Public License > + * along with this program; if not, write to the Free Software Foundation, > + * Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA > + */ > +#ifndef _LIB_LVM_H > +#define _LIB_LVM_H > + > +#include "version.h" > + > +#include <stdint.h> > + > +struct lvm; /* internal data */ > + > +/** > + * The lvm handle. > + */ > +typedef struct lvm *lvm_t; > + > +/** > + * Create a LVM handle. > + * > + * \param system_dir > + * Set an alternative system path or NULL for the default value. If > + * the environment variable LVM_SYSTEM_DIR is set, it will overwrite > + * this value. > + * \return A valid LVM handle is returned or NULL if there has been a > + * memory allocation problem. You have to check if an error occured > + * with the lvm_error function. > + */ > +lvm_t lvm_create(const char *system_dir); > + > +/** > + * Destroy a LVM handle allocated with lvm_create. > + * > + * \param libh > + * Handle obtained from lvm_create. > + */ > +void lvm_destroy(lvm_t libh); > + > +/** > + * Reload the original configuration from the system directory. > + * > + * \param libh > + * Handle obtained from lvm_create. > + */ > +int lvm_reload_config(lvm_t libh); > + > +#endif /* _LIB_LVM_H */ > diff --git a/lib/lvm2.h b/lib/lvm2.h > deleted file mode 100644 > index b18cead..0000000 > --- a/lib/lvm2.h > +++ /dev/null > @@ -1,53 +0,0 @@ > -/* > - * Copyright (C) 2001-2004 Sistina Software, Inc. All rights reserved. > - * Copyright (C) 2004-2008 Red Hat, Inc. All rights reserved. > - * > - * This file is part of LVM2. > - * > - * This copyrighted material is made available to anyone wishing to use, > - * modify, copy, or redistribute it subject to the terms and conditions > - * of the GNU Lesser General Public License v.2.1. > - * > - * You should have received a copy of the GNU Lesser General Public License > - * along with this program; if not, write to the Free Software Foundation, > - * Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA > - */ > -#ifndef _LIB_LVM2_H > -#define _LIB_LVM2_H > - > -#include <stdint.h> > - > -/* > - * Library Initialisation > - * FIXME: For now just #define lvm2_create() and lvm2_destroy() to > - * create_toolcontext() and destroy_toolcontext() > - */ > -struct arg; > -struct cmd_context; > -struct cmd_context *create_toolcontext(unsigned is_long_lived); > -void destroy_toolcontext(struct cmd_context *cmd); > - > -/* > - * lvm2_create > -lvm_handle_t lvm2_create(void); > - * > - * Description: Create an LVM2 handle used in many other APIs. > - * > - * Returns: > - * NULL: Fail - unable to initialise handle. > - * non-NULL: Success - valid LVM2 handle returned > - */ > -#define lvm2_create(X) create_toolcontext(1) > - > -/* > - * lvm2_destroy > -void lvm2_destroy(lvm_handle_t h); > - * > - * Description: Destroy an LVM2 handle allocated with lvm2_create > - * > - * Parameters: > - * - h (IN): handle obtained from lvm2_create > - */ > -#define lvm2_destroy(X) destroy_toolcontext(X) > - > -#endif > diff --git a/test/api/test.c b/test/api/test.c > index de53c46..b742976 100644 > --- a/test/api/test.c > +++ b/test/api/test.c > @@ -1,6 +1,6 @@ > /* > * Copyright (C) 2001-2004 Sistina Software, Inc. All rights reserved. > - * Copyright (C) 2004-2008 Red Hat, Inc. All rights reserved. > + * Copyright (C) 2004-2009 Red Hat, Inc. All rights reserved. > * > * This file is part of LVM2. > * > @@ -16,7 +16,7 @@ > #include <string.h> > #include <stdlib.h> > #include <readline/readline.h> > -#include "lvm2.h" > +#include "lvm.h" > > #define MAX_ARGS 64 > > @@ -48,7 +48,7 @@ static int lvm_split(char *str, int *argc, char **argv, int max) > return *argc; > } > > -static int lvmapi_test_shell(void *h) > +static int lvmapi_test_shell(lvm_t libh) > { > int argc, i; > char *input = NULL, *args[MAX_ARGS], **argv; > @@ -99,18 +99,17 @@ static int lvmapi_test_shell(void *h) > > int main (int argc, char *argv[]) > { > - void *h; > + lvm_t libh; > > - h = lvm2_create(); > - if (!h) { > + libh = lvm_create(NULL); > + if (!libh) { > printf("Unable to open lvm library instance\n"); > return 1; > } > > - lvmapi_test_shell(h); > + lvmapi_test_shell(libh); > > - if (h) > - lvm2_destroy(h); > + lvm_destroy(libh); > return 0; > } > lvm_base.c missing - did you forget to 'git add'? Ack the rest of the patch. ^ permalink raw reply [flat|nested] 8+ messages in thread
* Latest liblvm base patches @ 2009-02-20 16:41 Thomas Woerner 2009-02-20 16:41 ` [PATCH 1/3] New parameter system_dir for create_toolcontext Thomas Woerner 0 siblings, 1 reply; 8+ messages in thread From: Thomas Woerner @ 2009-02-20 16:41 UTC (permalink / raw) To: lvm-devel Here are the latest liblvm base patches. ^ permalink raw reply [flat|nested] 8+ messages in thread
* [PATCH 1/3] New parameter system_dir for create_toolcontext. 2009-02-20 16:41 Latest liblvm base patches Thomas Woerner @ 2009-02-20 16:41 ` Thomas Woerner 0 siblings, 0 replies; 8+ messages in thread From: Thomas Woerner @ 2009-02-20 16:41 UTC (permalink / raw) To: lvm-devel cmd->sys_dir, which defaults to DEFAULT_SYS_DIR, will be set to system_dir i the parameter is not NULL. If the environment variable LVM_SYSTEM_DIR is set it will overwrite any value of cmd->sys_dir. Signed-off-by: Thomas Woerner <twoerner@redhat.com> --- daemons/clvmd/lvm-functions.c | 4 ++-- lib/commands/toolcontext.c | 16 ++++++++++++++-- lib/commands/toolcontext.h | 9 +++++++-- tools/lvmcmdline.c | 4 ++-- 4 files changed, 25 insertions(+), 8 deletions(-) diff --git a/daemons/clvmd/lvm-functions.c b/daemons/clvmd/lvm-functions.c index 5cf7eff..d720802 100644 --- a/daemons/clvmd/lvm-functions.c +++ b/daemons/clvmd/lvm-functions.c @@ -1,6 +1,6 @@ /* * Copyright (C) 2002-2004 Sistina Software, Inc. All rights reserved. - * Copyright (C) 2004-2008 Red Hat, Inc. All rights reserved. + * Copyright (C) 2004-2009 Red Hat, Inc. All rights reserved. * * This file is part of LVM2. * @@ -724,7 +724,7 @@ void lvm_do_backup(const char *vgname) /* Called to initialise the LVM context of the daemon */ int init_lvm(int using_gulm) { - if (!(cmd = create_toolcontext(1))) { + if (!(cmd = create_toolcontext(1, NULL))) { log_error("Failed to allocate command context"); return 0; } diff --git a/lib/commands/toolcontext.c b/lib/commands/toolcontext.c index 0a98325..39c644c 100644 --- a/lib/commands/toolcontext.c +++ b/lib/commands/toolcontext.c @@ -1,6 +1,6 @@ /* * Copyright (C) 2001-2004 Sistina Software, Inc. All rights reserved. - * Copyright (C) 2004-2007 Red Hat, Inc. All rights reserved. + * Copyright (C) 2004-2009 Red Hat, Inc. All rights reserved. * * This file is part of LVM2. * @@ -998,7 +998,8 @@ static void _init_globals(struct cmd_context *cmd) } /* Entry point */ -struct cmd_context *create_toolcontext(unsigned is_long_lived) +struct cmd_context *create_toolcontext(unsigned is_long_lived, + const char *system_dir) { struct cmd_context *cmd; @@ -1030,6 +1031,17 @@ struct cmd_context *create_toolcontext(unsigned is_long_lived) strcpy(cmd->sys_dir, DEFAULT_SYS_DIR); + /* + * cmd->sys_dir, which defaults to DEFAULT_SYS_DIR, will be set to + * system_dir if the parameter is not NULL. If the environment + * variable LVM_SYSTEM_DIR is set, it will overwrite any value of + * cmd->sys_dir. + */ + if (system_dir) { + strncpy(cmd->sys_dir, system_dir, sizeof(cmd->sys_dir)); + cmd->sys_dir[sizeof(cmd->sys_dir) - 1] = '\0'; + } + if (!_get_env_vars(cmd)) goto error; diff --git a/lib/commands/toolcontext.h b/lib/commands/toolcontext.h index 7d2aef9..eb2b6ef 100644 --- a/lib/commands/toolcontext.h +++ b/lib/commands/toolcontext.h @@ -1,6 +1,6 @@ /* * Copyright (C) 2001-2004 Sistina Software, Inc. All rights reserved. - * Copyright (C) 2004-2007 Red Hat, Inc. All rights reserved. + * Copyright (C) 2004-2009 Red Hat, Inc. All rights reserved. * * This file is part of LVM2. * @@ -94,7 +94,12 @@ struct cmd_context { char sysfs_dir[PATH_MAX]; }; -struct cmd_context *create_toolcontext(unsigned is_long_lived); +/* + * cmd->sys_dir, which defaults to DEFAULT_SYS_DIR, will be set to system_dir + * if the parameter is not NULL. If the environment variable LVM_SYSTEM_DIR is + * set, it will overwrite any value of cmd->sys_dir. + */ +struct cmd_context *create_toolcontext(unsigned is_long_lived, const char *system_dir); void destroy_toolcontext(struct cmd_context *cmd); int refresh_toolcontext(struct cmd_context *cmd); int config_files_changed(struct cmd_context *cmd); diff --git a/tools/lvmcmdline.c b/tools/lvmcmdline.c index 880f31e..cb1bfc6 100644 --- a/tools/lvmcmdline.c +++ b/tools/lvmcmdline.c @@ -1,6 +1,6 @@ /* * Copyright (C) 2001-2004 Sistina Software, Inc. All rights reserved. - * Copyright (C) 2004-2007 Red Hat, Inc. All rights reserved. + * Copyright (C) 2004-2009 Red Hat, Inc. All rights reserved. * * This file is part of LVM2. * @@ -1158,7 +1158,7 @@ struct cmd_context *init_lvm(void) _cmdline.the_args = &_the_args[0]; - if (!(cmd = create_toolcontext(0))) + if (!(cmd = create_toolcontext(0, NULL))) return_NULL; return cmd; -- 1.6.1.3 ^ permalink raw reply related [flat|nested] 8+ messages in thread
end of thread, other threads:[~2009-02-20 16:41 UTC | newest] Thread overview: 8+ messages (download: mbox.gz follow: Atom feed -- links below jump to the message on this page -- 2009-02-19 19:01 liblvm base patches I Thomas Woerner 2009-02-19 19:01 ` [PATCH 1/3] New parameter system_dir for create_toolcontext Thomas Woerner 2009-02-19 18:14 ` Dave Wysochanski 2009-02-19 19:01 ` [PATCH 2/3] Added more version defines to tools/version.h.in Thomas Woerner 2009-02-19 18:15 ` Dave Wysochanski 2009-02-19 19:01 ` [PATCH 3/3] New base files needed for liblvm with doxygen style descriptions Thomas Woerner 2009-02-19 18:18 ` Dave Wysochanski -- strict thread matches above, loose matches on Subject: below -- 2009-02-20 16:41 Latest liblvm base patches Thomas Woerner 2009-02-20 16:41 ` [PATCH 1/3] New parameter system_dir for create_toolcontext Thomas Woerner
This is an external index of several public inboxes, see mirroring instructions on how to clone and mirror all data and code used by this external index.