rpms/lvm2/devel lvm2-nostaticreadline.patch, NONE, 1.1 lvm2.spec, 1.106, 1.107
fedora-cvs-commits at redhat.com
fedora-cvs-commits at redhat.com
Wed Feb 14 17:02:37 UTC 2007
Author: agk
Update of /cvs/dist/rpms/lvm2/devel
In directory cvs.devel.redhat.com:/tmp/cvs-serv4584
Modified Files:
lvm2.spec
Added Files:
lvm2-nostaticreadline.patch
Log Message:
Remove readline support from lvm.static
lvm2-nostaticreadline.patch:
VERSION | 2
WHATS_NEW | 5
scripts/last_cvs_update.sh | 2
tools/lvm-static.c | 5
tools/lvm.c | 224 +++++++++++++++++++++++++++++++++++
tools/lvm2cmdline.h | 9 +
tools/lvmcmdline.c | 284 ++++-----------------------------------------
tools/reporter.c | 3
8 files changed, 277 insertions(+), 257 deletions(-)
--- NEW FILE lvm2-nostaticreadline.patch ---
--- LVM2.2.02.22/scripts/last_cvs_update.sh 2001-08-15 17:20:45.000000000 +0100
+++ LVM2/scripts/last_cvs_update.sh 2001-08-15 17:20:45.000000000 +0100
@@ -1,5 +1,5 @@
#!/bin/sh
-#$Header: /sourceware/projects/lvm2-home/cvsfiles/LVM2/scripts/last_cvs_update.sh,v 1.1 2001/08/15 16:20:45 lewis Exp $
+#$Header: /cvs/lvm2/LVM2/scripts/last_cvs_update.sh,v 1.1 2001/08/15 16:20:45 lewis Exp $
################################################################################
##
## Copyright 2001 Sistina Software, Inc.
--- LVM2.2.02.22/tools/lvm2cmdline.h 2006-08-18 22:17:18.000000000 +0100
+++ LVM2/tools/lvm2cmdline.h 2007-02-14 16:08:49.000000000 +0000
@@ -18,6 +18,14 @@
struct cmd_context;
+struct cmdline_context {
+ struct arg *the_args;
+ struct command *commands;
+ int num_commands;
+ int commands_size;
+ int interactive;
+};
+
int lvm2_main(int argc, char **argv, unsigned is_static);
void *cmdlib_lvm2_init(unsigned is_static);
@@ -27,5 +35,6 @@
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);
+int lvm_shell(struct cmd_context *cmd, struct cmdline_context *cmdline);
#endif
--- LVM2.2.02.22/tools/lvm.c 2005-02-18 18:57:48.000000000 +0000
+++ LVM2/tools/lvm.c 2007-02-14 16:21:31.000000000 +0000
@@ -13,9 +13,233 @@
* Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
*/
+#include "tools.h"
#include "lvm2cmdline.h"
int main(int argc, char **argv)
{
return lvm2_main(argc, argv, 0);
}
+
+#ifdef READLINE_SUPPORT
+
+# include <readline/readline.h>
+# include <readline/history.h>
+# ifndef HAVE_RL_COMPLETION_MATCHES
+# define rl_completion_matches(a, b) completion_matches((char *)a, b)
+# endif
+
+static struct cmdline_context *_cmdline;
+
+/* List matching commands */
+static char *_list_cmds(const char *text, int state)
+{
+ static int i = 0;
+ static size_t len = 0;
+
+ /* Initialise if this is a new completion attempt */
+ if (!state) {
+ i = 0;
+ len = strlen(text);
+ }
+
+ while (i < _cmdline->num_commands)
+ if (!strncmp(text, _cmdline->commands[i++].name, len))
+ return strdup(_cmdline->commands[i - 1].name);
+
+ return NULL;
+}
+
+/* List matching arguments */
+static char *_list_args(const char *text, int state)
+{
+ static int match_no = 0;
+ static size_t len = 0;
+ static struct command *com;
+
+ /* Initialise if this is a new completion attempt */
+ if (!state) {
+ char *s = rl_line_buffer;
+ int j = 0;
+
+ match_no = 0;
+ com = NULL;
+ len = strlen(text);
+
+ /* Find start of first word in line buffer */
+ while (isspace(*s))
+ s++;
+
+ /* Look for word in list of commands */
+ for (j = 0; j < _cmdline->num_commands; j++) {
+ const char *p;
+ char *q = s;
+
+ p = _cmdline->commands[j].name;
+ while (*p == *q) {
+ p++;
+ q++;
+ }
+ if ((!*p) && *q == ' ') {
+ com = _cmdline->commands + j;
+ break;
+ }
+ }
+
+ if (!com)
+ return NULL;
+ }
+
+ /* Short form arguments */
+ if (len < 3) {
+ while (match_no < com->num_args) {
+ char s[3];
+ char c;
+ if (!(c = (_cmdline->the_args +
+ com->valid_args[match_no++])->short_arg))
+ continue;
+
+ sprintf(s, "-%c", c);
+ if (!strncmp(text, s, len))
+ return strdup(s);
+ }
+ }
+
+ /* Long form arguments */
+ if (match_no < com->num_args)
+ match_no = com->num_args;
+
+ while (match_no - com->num_args < com->num_args) {
+ const char *l;
+ l = (_cmdline->the_args +
+ com->valid_args[match_no++ - com->num_args])->long_arg;
+ if (*(l + 2) && !strncmp(text, l, len))
+ return strdup(l);
+ }
+
+ return NULL;
+}
+
+/* Custom completion function */
+static char **_completion(const char *text, int start_pos, int end_pos)
+{
+ char **match_list = NULL;
+ int p = 0;
+
+ while (isspace((int) *(rl_line_buffer + p)))
+ p++;
+
+ /* First word should be one of our commands */
+ if (start_pos == p)
+ match_list = rl_completion_matches(text, _list_cmds);
+
+ else if (*text == '-')
+ match_list = rl_completion_matches(text, _list_args);
+ /* else other args */
+
+ /* No further completion */
+ rl_attempted_completion_over = 1;
+ return match_list;
+}
+
+static int _hist_file(char *buffer, size_t size)
+{
+ char *e = getenv("HOME");
+
+ if (dm_snprintf(buffer, size, "%s/.lvm_history", e) < 0) {
+ log_error("$HOME/.lvm_history: path too long");
+ return 0;
+ }
+
+ return 1;
+}
+
+static void _read_history(struct cmd_context *cmd)
+{
+ char hist_file[PATH_MAX];
+
+ if (!_hist_file(hist_file, sizeof(hist_file)))
+ return;
+
+ if (read_history(hist_file))
+ log_very_verbose("Couldn't read history from %s.", hist_file);
+
+ stifle_history(find_config_tree_int(cmd, "shell/history_size",
+ DEFAULT_MAX_HISTORY));
+
+}
+
+static void _write_history(void)
+{
+ char hist_file[PATH_MAX];
+
+ if (!_hist_file(hist_file, sizeof(hist_file)))
+ return;
+
+ if (write_history(hist_file))
+ log_very_verbose("Couldn't write history to %s.", hist_file);
+}
+
+int lvm_shell(struct cmd_context *cmd, struct cmdline_context *cmdline)
+{
+ int argc, ret;
+ char *input = NULL, *args[MAX_ARGS], **argv;
+
+ rl_readline_name = "lvm";
+ rl_attempted_completion_function = (CPPFunction *) _completion;
+
+ _read_history(cmd);
+
+ _cmdline = cmdline;
+
+ _cmdline->interactive = 1;
+ while (1) {
+ free(input);
+ input = readline("lvm> ");
+
+ /* EOF */
+ if (!input) {
+ printf("\n");
+ break;
+ }
+
+ /* empty line */
+ if (!*input)
+ continue;
+
+ add_history(input);
+
+ argv = args;
+
+ if (lvm_split(input, &argc, argv, MAX_ARGS) == MAX_ARGS) {
+ log_error("Too many arguments, sorry.");
+ continue;
+ }
+
+ if (!strcmp(argv[0], "lvm")) {
+ argv++;
+ argc--;
+ }
+
+ if (!argc)
+ continue;
+
+ if (!strcmp(argv[0], "quit") || !strcmp(argv[0], "exit")) {
+ remove_history(history_length - 1);
+ log_error("Exiting.");
+ break;
+ }
+
+ ret = lvm_run_command(cmd, argc, argv);
+ if (ret == ENO_SUCH_CMD)
+ log_error("No such command '%s'. Try 'help'.",
+ argv[0]);
+
+ _write_history();
+ }
+
+ free(input);
+ return 0;
+}
+
+#endif /* READLINE_SUPPORT */
--- LVM2.2.02.22/tools/lvmcmdline.c 2007-01-25 14:37:48.000000000 +0000
+++ LVM2/tools/lvmcmdline.c 2007-02-14 16:17:39.000000000 +0000
@@ -41,30 +41,16 @@
# define OPTIND_INIT 1
#endif
-#ifdef READLINE_SUPPORT
-# include <readline/readline.h>
-# include <readline/history.h>
-# ifndef HAVE_RL_COMPLETION_MATCHES
-# define rl_completion_matches(a, b) completion_matches((char *)a, b)
-# endif
-#endif
-
/*
- * Exported table of valid switches
+ * Table of valid switches
*/
-struct arg the_args[ARG_COUNT + 1] = {
-
+static struct arg _the_args[ARG_COUNT + 1] = {
#define arg(a, b, c, d) {b, "", "--" c, d, 0, NULL, 0, 0, INT64_C(0), UINT64_C(0), SIGN_NONE, PERCENT_NONE, NULL},
#include "args.h"
#undef arg
-
};
-static int _array_size;
-static int _num_commands;
-static struct command *_commands;
-
-static int _interactive;
+static struct cmdline_context _cmdline;
int yes_no_arg(struct cmd_context *cmd __attribute((unused)), struct arg *a)
{
@@ -412,21 +398,21 @@
static void __alloc(int size)
{
- if (!(_commands = dm_realloc(_commands, sizeof(*_commands) * size))) {
+ if (!(_cmdline.commands = dm_realloc(_cmdline.commands, sizeof(*_cmdline.commands) * size))) {
log_fatal("Couldn't allocate memory.");
exit(ECMD_FAILED);
}
- _array_size = size;
+ _cmdline.commands_size = size;
}
static void _alloc_command(void)
{
- if (!_array_size)
+ if (!_cmdline.commands_size)
__alloc(32);
- if (_array_size <= _num_commands)
- __alloc(2 * _array_size);
+ if (_cmdline.commands_size <= _cmdline.num_commands)
+ __alloc(2 * _cmdline.commands_size);
}
static void _create_new_command(const char *name, command_fn command,
@@ -437,7 +423,7 @@
_alloc_command();
- nc = _commands + _num_commands++;
+ nc = _cmdline.commands + _cmdline.num_commands++;
nc->name = name;
nc->desc = desc;
@@ -495,17 +481,17 @@
namebase = strdup(name);
base = basename(namebase);
- for (i = 0; i < _num_commands; i++) {
- if (!strcmp(base, _commands[i].name))
+ for (i = 0; i < _cmdline.num_commands; i++) {
+ if (!strcmp(base, _cmdline.commands[i].name))
break;
}
free(namebase);
- if (i >= _num_commands)
+ if (i >= _cmdline.num_commands)
return 0;
- return _commands + i;
+ return _cmdline.commands + i;
}
static void _usage(const char *name)
@@ -527,7 +513,7 @@
*/
static void _add_getopt_arg(int arg, char **ptr, struct option **o)
{
- struct arg *a = the_args + arg;
+ struct arg *a = _cmdline.the_args + arg;
if (a->short_arg) {
*(*ptr)++ = a->short_arg;
@@ -556,12 +542,12 @@
for (i = 0; i < com->num_args; i++) {
arg = com->valid_args[i];
- a = the_args + arg;
+ a = _cmdline.the_args + arg;
/*
* opt should equal either the
* short arg, or the index into
- * 'the_args'.
+ * the_args.
*/
if ((a->short_arg && (opt == a->short_arg)) ||
(!a->short_arg && (opt == arg)))
@@ -580,7 +566,7 @@
struct arg *a;
for (i = 0; i < ARG_COUNT; i++) {
- a = the_args + i;
+ a = _cmdline.the_args + i;
/* zero the count and arg */
a->count = 0;
@@ -651,15 +637,15 @@
if (arg_count(cmd, oldarg) && arg_count(cmd, newarg)) {
log_error("%s and %s are synonyms. Please only supply one.",
- the_args[oldarg].long_arg, the_args[newarg].long_arg);
+ _cmdline.the_args[oldarg].long_arg, _cmdline.the_args[newarg].long_arg);
return 0;
}
if (!arg_count(cmd, oldarg))
return 1;
- old = the_args + oldarg;
- new = the_args + newarg;
+ old = _cmdline.the_args + oldarg;
+ new = _cmdline.the_args + newarg;
new->count = old->count;
new->value = old->value;
@@ -782,8 +768,8 @@
log_error("Use 'lvm help <command>' for more information");
log_error(" ");
- for (i = 0; i < _num_commands; i++) {
- struct command *com = _commands + i;
+ for (i = 0; i < _cmdline.num_commands; i++) {
+ struct command *com = _cmdline.commands + i;
log_error("%-16.16s%s", com->name, com->desc);
}
@@ -959,7 +945,7 @@
*/
dm_pool_empty(cmd->mem);
- if (ret == EINVALID_CMD_LINE && !_interactive)
+ if (ret == EINVALID_CMD_LINE && !_cmdline.interactive)
_usage(cmd->command->name);
log_debug("Completed: %s", cmd->cmd_line);
@@ -1030,7 +1016,9 @@
{
struct cmd_context *cmd;
- if (!(cmd = create_toolcontext(&the_args[0], is_static, 0))) {
+ _cmdline.the_args = &_the_args[0];
+
+ if (!(cmd = create_toolcontext(_cmdline.the_args, is_static, 0))) {
stack;
return NULL;
}
@@ -1046,10 +1034,10 @@
{
int i;
- for (i = 0; i < _num_commands; i++)
- dm_free(_commands[i].valid_args);
+ for (i = 0; i < _cmdline.num_commands; i++)
+ dm_free(_cmdline.commands[i].valid_args);
- dm_free(_commands);
+ dm_free(_cmdline.commands);
}
void lvm_fin(struct cmd_context *cmd)
@@ -1106,218 +1094,6 @@
return ret;
}
-#ifdef READLINE_SUPPORT
-/* List matching commands */
-static char *_list_cmds(const char *text, int state)
-{
- static int i = 0;
- static size_t len = 0;
-
- /* Initialise if this is a new completion attempt */
- if (!state) {
- i = 0;
- len = strlen(text);
- }
-
- while (i < _num_commands)
- if (!strncmp(text, _commands[i++].name, len))
- return strdup(_commands[i - 1].name);
-
- return NULL;
-}
-
-/* List matching arguments */
-static char *_list_args(const char *text, int state)
-{
- static int match_no = 0;
- static size_t len = 0;
- static struct command *com;
-
- /* Initialise if this is a new completion attempt */
- if (!state) {
- char *s = rl_line_buffer;
- int j = 0;
-
- match_no = 0;
- com = NULL;
- len = strlen(text);
-
- /* Find start of first word in line buffer */
- while (isspace(*s))
- s++;
-
- /* Look for word in list of commands */
- for (j = 0; j < _num_commands; j++) {
- const char *p;
- char *q = s;
-
- p = _commands[j].name;
- while (*p == *q) {
- p++;
- q++;
- }
- if ((!*p) && *q == ' ') {
- com = _commands + j;
- break;
- }
- }
-
- if (!com)
- return NULL;
- }
-
- /* Short form arguments */
- if (len < 3) {
- while (match_no < com->num_args) {
- char s[3];
- char c;
- if (!(c = (the_args +
- com->valid_args[match_no++])->short_arg))
- continue;
-
- sprintf(s, "-%c", c);
- if (!strncmp(text, s, len))
- return strdup(s);
- }
- }
-
- /* Long form arguments */
- if (match_no < com->num_args)
- match_no = com->num_args;
-
- while (match_no - com->num_args < com->num_args) {
- const char *l;
- l = (the_args +
- com->valid_args[match_no++ - com->num_args])->long_arg;
- if (*(l + 2) && !strncmp(text, l, len))
- return strdup(l);
- }
-
- return NULL;
-}
-
-/* Custom completion function */
-static char **_completion(const char *text, int start_pos, int end_pos)
-{
- char **match_list = NULL;
- int p = 0;
-
- while (isspace((int) *(rl_line_buffer + p)))
- p++;
-
- /* First word should be one of our commands */
- if (start_pos == p)
- match_list = rl_completion_matches(text, _list_cmds);
-
- else if (*text == '-')
- match_list = rl_completion_matches(text, _list_args);
- /* else other args */
-
- /* No further completion */
- rl_attempted_completion_over = 1;
- return match_list;
-}
-
-static int _hist_file(char *buffer, size_t size)
-{
- char *e = getenv("HOME");
-
- if (dm_snprintf(buffer, size, "%s/.lvm_history", e) < 0) {
- log_error("$HOME/.lvm_history: path too long");
- return 0;
- }
-
- return 1;
-}
-
-static void _read_history(struct cmd_context *cmd)
-{
- char hist_file[PATH_MAX];
-
- if (!_hist_file(hist_file, sizeof(hist_file)))
- return;
-
- if (read_history(hist_file))
- log_very_verbose("Couldn't read history from %s.", hist_file);
-
- stifle_history(find_config_tree_int(cmd, "shell/history_size",
- DEFAULT_MAX_HISTORY));
-
-}
-
-static void _write_history(void)
-{
- char hist_file[PATH_MAX];
-
- if (!_hist_file(hist_file, sizeof(hist_file)))
- return;
-
- if (write_history(hist_file))
- log_very_verbose("Couldn't write history to %s.", hist_file);
-}
-
-static int _shell(struct cmd_context *cmd)
-{
- int argc, ret;
- char *input = NULL, *args[MAX_ARGS], **argv;
-
- rl_readline_name = "lvm";
- rl_attempted_completion_function = (CPPFunction *) _completion;
-
- _read_history(cmd);
-
- _interactive = 1;
- while (1) {
- free(input);
- input = readline("lvm> ");
-
- /* EOF */
- if (!input) {
- printf("\n");
- break;
- }
-
- /* empty line */
- if (!*input)
- continue;
-
- add_history(input);
-
- argv = args;
-
- if (lvm_split(input, &argc, argv, MAX_ARGS) == MAX_ARGS) {
- log_error("Too many arguments, sorry.");
- continue;
- }
-
- if (!strcmp(argv[0], "lvm")) {
- argv++;
- argc--;
- }
-
- if (!argc)
- continue;
-
- if (!strcmp(argv[0], "quit") || !strcmp(argv[0], "exit")) {
- remove_history(history_length - 1);
- log_error("Exiting.");
- break;
- }
-
- ret = lvm_run_command(cmd, argc, argv);
- if (ret == ENO_SUCH_CMD)
- log_error("No such command '%s'. Try 'help'.",
- argv[0]);
-
- _write_history();
- }
-
- free(input);
- return 0;
-}
-
-#endif
-
/*
* Determine whether we should fall back and exec the equivalent LVM1 tool
*/
@@ -1403,7 +1179,7 @@
}
#ifdef READLINE_SUPPORT
if (!alias && argc == 1) {
- ret = _shell(cmd);
+ ret = lvm_shell(cmd, &_cmdline);
goto out;
}
#endif
--- LVM2.2.02.22/tools/lvm-static.c 2005-02-18 18:58:31.000000000 +0000
+++ LVM2/tools/lvm-static.c 2007-02-14 16:08:57.000000000 +0000
@@ -19,3 +19,8 @@
{
return lvm2_main(argc, argv, 1);
}
+
+int lvm_shell(struct cmd_context *cmd, struct cmdline_context *cmdline)
+{
+ return 0;
+}
--- LVM2.2.02.22/tools/reporter.c 2007-01-27 02:32:31.000000000 +0000
+++ LVM2/tools/reporter.c 2007-02-14 15:05:41.000000000 +0000
@@ -286,7 +286,7 @@
if (!(report_handle = report_init(cmd, options, keys, &report_type,
separator, aligned, buffered,
headings)))
- return 0;
+ return_0;
/* Ensure options selected are compatible */
if (report_type & SEGS)
@@ -295,6 +295,7 @@
report_type |= PVS;
if ((report_type & LVS) && (report_type & PVS)) {
log_error("Can't report LV and PV fields at the same time");
+ dm_report_free(report_handle);
return 0;
}
--- LVM2.2.02.22/VERSION 2007-02-13 16:06:04.000000000 +0000
+++ LVM2/VERSION 2007-02-14 14:18:57.000000000 +0000
@@ -1 +1 @@
-2.02.22 (2007-02-13)
+2.02.23-cvs (2007-02-13)
--- LVM2.2.02.22/WHATS_NEW 2007-02-13 16:04:38.000000000 +0000
+++ LVM2/WHATS_NEW 2007-02-14 16:43:38.000000000 +0000
@@ -1,3 +1,8 @@
+Version 2.02.23 -
+====================================
+ Exclude readline support from lvm.static.
+ Fix a leak in a reporting error path (2.02.19).
+
Version 2.02.22 - 13th February 2007
====================================
Correct -b and -P on a couple of man pages.
Index: lvm2.spec
===================================================================
RCS file: /cvs/dist/rpms/lvm2/devel/lvm2.spec,v
retrieving revision 1.106
retrieving revision 1.107
diff -u -r1.106 -r1.107
--- lvm2.spec 13 Feb 2007 23:49:12 -0000 1.106
+++ lvm2.spec 14 Feb 2007 17:02:35 -0000 1.107
@@ -9,6 +9,7 @@
URL: http://sources.redhat.com/lvm2
Source0: LVM2.%{version}.tgz
Patch0: cluster-locking-built-in.patch
+Patch1: lvm2-nostaticreadline.patch
BuildRoot: %{_tmppath}/%{name}-%{version}-%{release}-root-%(%{__id_u} -n)
BuildRequires: device-mapper-devel >= %{device_mapper_version}
BuildRequires: libselinux-devel >= 1.30.19-4, libsepol-devel
@@ -33,6 +34,7 @@
%prep
%setup -q -n LVM2.%{version}
%patch -p1 -b .locking
+%patch1 -p1 -b .nostaticreadline
%build
%configure --enable-static_link --enable-readline --enable-lvm1_fallback --with-clvmd=cman --with-cluster=internal --with-pool=internal --with-staticdir=/sbin --with-user= --with-group=
@@ -192,7 +194,7 @@
%changelog
-* Tue Feb 13 2007 Alasdair Kergon <agk at redhat.com> - 2.02.22-1
+* Wed Feb 14 2007 Alasdair Kergon <agk at redhat.com> - 2.02.22-1
- Add ncurses-static BuildRequires after package split.
- Fix loading of segment_libraries.
- If a PV reappears after it was removed from its VG, make it an orphan.
@@ -200,6 +202,7 @@
- Fix some vgreduce --removemissing command line validation.
- Trivial man page corrections (-b and -P).
- Add global/units to example.conf.
+- Remove readline support from lvm.static.
* Mon Feb 05 2007 Alasdair Kergon <agk at redhat.com> - 2.02.21-4
- Remove file wildcards and unintentional lvmconf installation.
More information about the fedora-cvs-commits
mailing list