This is the mail archive of the
lvm2-cvs@sourceware.org
mailing list for the LVM2 project.
LVM2 ./WHATS_NEW ./configure ./configure.in li ...
- From: agk at sourceware dot org
- To: lvm2-cvs at sourceware dot org
- Date: 18 Aug 2006 21:17:19 -0000
- Subject: LVM2 ./WHATS_NEW ./configure ./configure.in li ...
CVSROOT: /cvs/lvm2
Module name: LVM2
Changes by: agk@sourceware.org 2006-08-18 21:17:18
Modified files:
. : WHATS_NEW configure configure.in
lib/commands : toolcontext.c toolcontext.h
tools : Makefile.in lvm2cmdline.h lvmcmdline.c
Added files:
tools : lvm2cmd-static.c lvm2cmd.c lvmcmdlib.c
Log message:
Move CMDLIB code into separate file and record whether static build.
Patches:
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/WHATS_NEW.diff?cvsroot=lvm2&r1=1.425&r2=1.426
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/configure.diff?cvsroot=lvm2&r1=1.51&r2=1.52
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/configure.in.diff?cvsroot=lvm2&r1=1.50&r2=1.51
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/lib/commands/toolcontext.c.diff?cvsroot=lvm2&r1=1.39&r2=1.40
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/lib/commands/toolcontext.h.diff?cvsroot=lvm2&r1=1.17&r2=1.18
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/tools/lvm2cmd-static.c.diff?cvsroot=lvm2&r1=NONE&r2=1.1
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/tools/lvm2cmd.c.diff?cvsroot=lvm2&r1=NONE&r2=1.1
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/tools/lvmcmdlib.c.diff?cvsroot=lvm2&r1=NONE&r2=1.1
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/tools/Makefile.in.diff?cvsroot=lvm2&r1=1.75&r2=1.76
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/tools/lvm2cmdline.h.diff?cvsroot=lvm2&r1=1.3&r2=1.4
http://sourceware.org/cgi-bin/cvsweb.cgi/LVM2/tools/lvmcmdline.c.diff?cvsroot=lvm2&r1=1.32&r2=1.33
--- LVM2/WHATS_NEW 2006/08/17 20:04:38 1.425
+++ LVM2/WHATS_NEW 2006/08/18 21:17:17 1.426
@@ -1,5 +1,6 @@
Version 2.02.10 -
==================================
+ Move CMDLIB code into separate file and record whether static build.
Version 2.02.09 - 17th August 2006
==================================
--- LVM2/configure 2006/05/16 16:48:30 1.51
+++ LVM2/configure 2006/08/18 21:17:17 1.52
@@ -7534,14 +7534,6 @@
echo "$as_me:$LINENO: result: $CMDLIB" >&5
echo "${ECHO_T}$CMDLIB" >&6
-if test x$CMDLIB = xyes; then
-
-cat >>confdefs.h <<\_ACEOF
-#define CMDLIB 1
-_ACEOF
-
-fi
-
################################################################################
echo "$as_me:$LINENO: checking whether to build fsadm" >&5
echo $ECHO_N "checking whether to build fsadm... $ECHO_C" >&6
--- LVM2/configure.in 2006/05/16 16:48:30 1.50
+++ LVM2/configure.in 2006/08/18 21:17:17 1.51
@@ -351,10 +351,6 @@
CMDLIB=$enableval, CMDLIB=no)
AC_MSG_RESULT($CMDLIB)
-if test x$CMDLIB = xyes; then
- AC_DEFINE([CMDLIB], 1, [Define to 1 to build the shared command library.])
-fi
-
################################################################################
dnl -- Enable fsadm
AC_MSG_CHECKING(whether to build fsadm)
--- LVM2/lib/commands/toolcontext.c 2006/05/16 20:42:01 1.39
+++ LVM2/lib/commands/toolcontext.c 2006/08/18 21:17:18 1.40
@@ -879,7 +879,7 @@
}
/* Entry point */
-struct cmd_context *create_toolcontext(struct arg *the_args)
+struct cmd_context *create_toolcontext(struct arg *the_args, unsigned is_static)
{
struct cmd_context *cmd;
@@ -902,6 +902,7 @@
}
memset(cmd, 0, sizeof(*cmd));
cmd->args = the_args;
+ cmd->is_static = is_static;
cmd->hosttags = 0;
list_init(&cmd->formats);
list_init(&cmd->segtypes);
--- LVM2/lib/commands/toolcontext.h 2006/05/16 16:48:30 1.17
+++ LVM2/lib/commands/toolcontext.h 2006/08/18 21:17:18 1.18
@@ -64,6 +64,7 @@
struct command *command;
struct arg *args;
char **argv;
+ unsigned is_static; /* Static binary? */
struct dev_filter *filter;
int dump_filter; /* Dump filter when exiting? */
@@ -87,7 +88,7 @@
char proc_dir[PATH_MAX];
};
-struct cmd_context *create_toolcontext(struct arg *the_args);
+struct cmd_context *create_toolcontext(struct arg *the_args, unsigned is_static);
void destroy_toolcontext(struct cmd_context *cmd);
int refresh_toolcontext(struct cmd_context *cmd);
int config_files_changed(struct cmd_context *cmd);
/cvs/lvm2/LVM2/tools/lvm2cmd-static.c,v --> standard output
revision 1.1
--- LVM2/tools/lvm2cmd-static.c
+++ - 2006-08-18 21:17:18.958299000 +0000
@@ -0,0 +1,21 @@
+/*
+ * Copyright (C) 2006 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 "lvm2cmdline.h"
+#include "lvm2cmd.h"
+
+void *lvm2_init(void)
+{
+ return cmdlib_lvm2_init(1);
+}
/cvs/lvm2/LVM2/tools/lvm2cmd.c,v --> standard output
revision 1.1
--- LVM2/tools/lvm2cmd.c
+++ - 2006-08-18 21:17:19.043941000 +0000
@@ -0,0 +1,21 @@
+/*
+ * Copyright (C) 2006 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 "lvm2cmdline.h"
+#include "lvm2cmd.h"
+
+void *lvm2_init(void)
+{
+ return cmdlib_lvm2_init(0);
+}
/cvs/lvm2/LVM2/tools/lvmcmdlib.c,v --> standard output
revision 1.1
--- LVM2/tools/lvmcmdlib.c
+++ - 2006-08-18 21:17:19.125212000 +0000
@@ -0,0 +1,111 @@
+/*
+ * 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
+ */
+
+#include "tools.h"
+#include "lvm2cmdline.h"
+#include "label.h"
+#include "version.h"
+
+#include "stub.h"
+#include "lvm2cmd.h"
+
+#include <signal.h>
+#include <syslog.h>
+#include <libgen.h>
+#include <sys/stat.h>
+#include <time.h>
+#include <sys/resource.h>
+
+void *cmdlib_lvm2_init(unsigned is_static)
+{
+ struct cmd_context *cmd;
+
+ lvm_register_commands();
+
+ if (!(cmd = init_lvm(is_static)))
+ return NULL;
+
+ return (void *) cmd;
+}
+
+int lvm2_run(void *handle, const char *cmdline)
+{
+ int argc, ret, oneoff = 0;
+ char *args[MAX_ARGS], **argv, *cmdcopy = NULL;
+ struct cmd_context *cmd;
+
+ argv = args;
+
+ if (!handle) {
+ oneoff = 1;
+ if (!(handle = lvm2_init())) {
+ log_error("Handle initialisation failed.");
+ return ECMD_FAILED;
+ }
+ }
+
+ cmd = (struct cmd_context *) handle;
+
+ cmd->argv = argv;
+
+ if (!(cmdcopy = dm_strdup(cmdline))) {
+ log_error("Cmdline copy failed.");
+ ret = ECMD_FAILED;
+ goto out;
+ }
+
+ if (lvm_split(cmdcopy, &argc, argv, MAX_ARGS) == MAX_ARGS) {
+ log_error("Too many arguments. Limit is %d.", MAX_ARGS);
+ ret = EINVALID_CMD_LINE;
+ goto out;
+ }
+
+ if (!argc) {
+ log_error("No command supplied");
+ ret = EINVALID_CMD_LINE;
+ goto out;
+ }
+
+ ret = lvm_run_command(cmd, argc, argv);
+
+ out:
+ dm_free(cmdcopy);
+
+ if (oneoff)
+ lvm2_exit(handle);
+
+ return ret;
+}
+
+void lvm2_log_level(void *handle, int level)
+{
+ struct cmd_context *cmd = (struct cmd_context *) handle;
+
+ cmd->default_settings.verbose = level - VERBOSE_BASE_LEVEL;
+
+ return;
+}
+
+void lvm2_log_fn(lvm2_log_fn_t log_fn)
+{
+ init_log_fn(log_fn);
+}
+
+void lvm2_exit(void *handle)
+{
+ struct cmd_context *cmd = (struct cmd_context *) handle;
+
+ lvm_fin(cmd);
+}
--- LVM2/tools/Makefile.in 2006/05/16 16:48:31 1.75
+++ LVM2/tools/Makefile.in 2006/08/18 21:17:18 1.76
@@ -80,7 +80,9 @@
LVMLIBS = -llvm
-CLEAN_TARGETS = liblvm2cmd.so liblvm2cmd.a lvm lvm.o lvm.static lvm.cflow lvm.xref lvm.tree lvm.rxref lvm.rtree
+CLEAN_TARGETS = liblvm2cmd.so liblvm2cmd.a liblvm2cmd-static.a lvm lvm.o \
+ lvm2cmd.o lvm2cmd-static.o lvm2cmdlib.o lvm.static \
+ lvm.cflow lvm.xref lvm.tree lvm.rxref lvm.rtree
ifeq ("@CMDLIB@", "yes")
TARGETS += liblvm2cmd.so
@@ -104,9 +106,13 @@
$(CC) -o $@ $(OBJECTS) lvm-static.o -static $(LDFLAGS) $(LVMLIBS) \
$(LIBS) -rdynamic
-liblvm2cmd.a: $(top_srcdir)/lib/liblvm.a $(OBJECTS)
+liblvm2cmd.a: $(top_srcdir)/lib/liblvm.a $(OBJECTS) lvmcmdlib.o lvm2cmd.o
cat $(top_srcdir)/lib/liblvm.a > $@
- $(AR) rs $@ $(OBJECTS)
+ $(AR) rs $@ $(OBJECTS) lvmcmdlib.o lvm2cmd.o
+
+liblvm2cmd-static.a: $(top_srcdir)/lib/liblvm.a $(OBJECTS) lvmcmdlib.o lvm2cmd-static.o
+ cat $(top_srcdir)/lib/liblvm.a > $@
+ $(AR) rs $@ $(OBJECTS) lvmcmdlib.o lvm2cmd-static.o
liblvm2cmd.so: liblvm2cmd.a $(LDDEPS)
@@ -141,8 +147,8 @@
$(INSTALL) -D $(OWNER) $(GROUP) -m 444 lvm2cmd.h \
$(includedir)/lvm2cmd.h
-install_cmdlib_static: liblvm2cmd.a
- $(INSTALL) -D $(OWNER) $(GROUP) -m 555 $(STRIP) liblvm2cmd.a \
+install_cmdlib_static: liblvm2cmd-static.a
+ $(INSTALL) -D $(OWNER) $(GROUP) -m 555 $(STRIP) liblvm2cmd-static.a \
$(libdir)/liblvm2cmd.a.$(LIB_VERSION)
$(LN_S) -f liblvm2cmd.a.$(LIB_VERSION) $(libdir)/liblvm2cmd.a
$(INSTALL) -D $(OWNER) $(GROUP) -m 444 lvm2cmd.h \
--- LVM2/tools/lvm2cmdline.h 2005/02/18 18:57:48 1.3
+++ LVM2/tools/lvm2cmdline.h 2006/08/18 21:17:18 1.4
@@ -1,6 +1,6 @@
/*
* Copyright (C) 2003-2004 Sistina Software, Inc. All rights reserved.
- * Copyright (C) 2004 Red Hat, Inc. All rights reserved.
+ * Copyright (C) 2004-2006 Red Hat, Inc. All rights reserved.
*
* This file is part of LVM2.
*
@@ -16,6 +16,16 @@
#ifndef _LVM_CMDLINE_H
#define _LVM_CMDLINE_H
-int lvm2_main(int argc, char **argv, int is_static);
+struct cmd_context;
+
+int lvm2_main(int argc, char **argv, unsigned is_static);
+
+void *cmdlib_lvm2_init(unsigned is_static);
+void lvm_fin(struct cmd_context *cmd);
+
+struct cmd_context *init_lvm(unsigned is_static);
+void lvm_register_commands(void);
+int lvm_split(char *str, int *argc, char **argv, int max);
+int lvm_run_command(struct cmd_context *cmd, int argc, char **argv);
#endif
--- LVM2/tools/lvmcmdline.c 2006/08/01 14:56:33 1.32
+++ LVM2/tools/lvmcmdline.c 2006/08/18 21:17:18 1.33
@@ -443,7 +443,7 @@
_create_new_command(name, fn, desc, usagestr, nargs, args);
}
-static void _register_commands()
+void lvm_register_commands(void)
{
#define xx(a, b, c...) _register_command(# a, a, b, ## c, \
driverloaded_ARG, \
@@ -843,7 +843,7 @@
return NULL;
}
-static int _run_command(struct cmd_context *cmd, int argc, char **argv)
+int lvm_run_command(struct cmd_context *cmd, int argc, char **argv)
{
int ret = 0;
int locking_type;
@@ -936,7 +936,7 @@
return ret;
}
-static int _split(char *str, int *argc, char **argv, int max)
+int lvm_split(char *str, int *argc, char **argv, int max)
{
char *b = str, *e;
*argc = 0;
@@ -995,11 +995,11 @@
}
}
-static struct cmd_context *_init_lvm(void)
+struct cmd_context *init_lvm(unsigned is_static)
{
struct cmd_context *cmd;
- if (!(cmd = create_toolcontext(&the_args[0]))) {
+ if (!(cmd = create_toolcontext(&the_args[0], is_static))) {
stack;
return NULL;
}
@@ -1021,7 +1021,7 @@
dm_free(_commands);
}
-static void _fin(struct cmd_context *cmd)
+void lvm_fin(struct cmd_context *cmd)
{
_fin_commands();
destroy_toolcontext(cmd);
@@ -1055,7 +1055,7 @@
ret = EINVALID_CMD_LINE;
break;
}
- if (_split(buffer, &argc, argv, MAX_ARGS) == MAX_ARGS) {
+ if (lvm_split(buffer, &argc, argv, MAX_ARGS) == MAX_ARGS) {
buffer[50] = '\0';
log_error("Too many arguments: %s", buffer);
ret = EINVALID_CMD_LINE;
@@ -1065,7 +1065,7 @@
continue;
if (!strcmp(argv[0], "quit") || !strcmp(argv[0], "exit"))
break;
- _run_command(cmd, argc, argv);
+ lvm_run_command(cmd, argc, argv);
}
fclose(script);
@@ -1251,7 +1251,7 @@
argv = args;
- if (_split(input, &argc, argv, MAX_ARGS) == MAX_ARGS) {
+ if (lvm_split(input, &argc, argv, MAX_ARGS) == MAX_ARGS) {
log_error("Too many arguments, sorry.");
continue;
}
@@ -1270,7 +1270,7 @@
break;
}
- ret = _run_command(cmd, argc, argv);
+ ret = lvm_run_command(cmd, argc, argv);
if (ret == ENO_SUCH_CMD)
log_error("No such command '%s'. Try 'help'.",
argv[0]);
@@ -1284,92 +1284,6 @@
#endif
-#ifdef CMDLIB
-
-void *lvm2_init(void)
-{
- struct cmd_context *cmd;
-
- _register_commands();
-
- if (!(cmd = _init_lvm()))
- return NULL;
-
- return (void *) cmd;
-}
-
-int lvm2_run(void *handle, const char *cmdline)
-{
- int argc, ret, oneoff = 0;
- char *args[MAX_ARGS], **argv, *cmdcopy = NULL;
- struct cmd_context *cmd;
-
- argv = args;
-
- if (!handle) {
- oneoff = 1;
- if (!(handle = lvm2_init())) {
- log_error("Handle initialisation failed.");
- return ECMD_FAILED;
- }
- }
-
- cmd = (struct cmd_context *) handle;
-
- cmd->argv = argv;
-
- if (!(cmdcopy = dm_strdup(cmdline))) {
- log_error("Cmdline copy failed.");
- ret = ECMD_FAILED;
- goto out;
- }
-
- if (_split(cmdcopy, &argc, argv, MAX_ARGS) == MAX_ARGS) {
- log_error("Too many arguments. Limit is %d.", MAX_ARGS);
- ret = EINVALID_CMD_LINE;
- goto out;
- }
-
- if (!argc) {
- log_error("No command supplied");
- ret = EINVALID_CMD_LINE;
- goto out;
- }
-
- ret = _run_command(cmd, argc, argv);
-
- out:
- dm_free(cmdcopy);
-
- if (oneoff)
- lvm2_exit(handle);
-
- return ret;
-}
-
-void lvm2_log_level(void *handle, int level)
-{
- struct cmd_context *cmd = (struct cmd_context *) handle;
-
- cmd->default_settings.verbose = level - VERBOSE_BASE_LEVEL;
-
- return;
-}
-
-void lvm2_log_fn(lvm2_log_fn_t log_fn)
-{
- init_log_fn(log_fn);
-}
-
-void lvm2_exit(void *handle)
-{
- struct cmd_context *cmd = (struct cmd_context *) handle;
-
- _fin(cmd);
-}
-
-#endif
-
/*
* Determine whether we should fall back and exec the equivalent LVM1 tool
*/
@@ -1406,7 +1320,7 @@
log_sys_error("execvp", path);
}
-int lvm2_main(int argc, char **argv, int is_static)
+int lvm2_main(int argc, char **argv, unsigned is_static)
{
char *namebase, *base;
int ret, alias = 0;
@@ -1432,11 +1346,11 @@
free(namebase);
- if (!(cmd = _init_lvm()))
+ if (!(cmd = init_lvm(is_static)))
return -1;
cmd->argv = argv;
- _register_commands();
+ lvm_register_commands();
if (_lvm1_fallback(cmd)) {
/* Attempt to run equivalent LVM1 tool instead */
@@ -1472,14 +1386,14 @@
argv++;
}
- ret = _run_command(cmd, argc, argv);
+ ret = lvm_run_command(cmd, argc, argv);
if ((ret == ENO_SUCH_CMD) && (!alias))
ret = _run_script(cmd, argc, argv);
if (ret == ENO_SUCH_CMD)
log_error("No such command. Try 'help'.");
out:
- _fin(cmd);
+ lvm_fin(cmd);
if (ret == ECMD_PROCESSED)
ret = 0;
return ret;