master - dmsetup: Use argcp and argvp.
by Alasdair Kergon
Gitweb: http://git.fedorahosted.org/git/?p=lvm2.git;a=commitdiff;h=519c309952245a...
Commit: 519c309952245a0d6221a3297399a310acdb8144
Parent: a161e29c59e01605401c9096f5ad5ace2ae03d9a
Author: Bryn M. Reeves <breeves(a)redhat.com>
AuthorDate: Fri Jul 31 22:53:38 2015 +0100
Committer: Alasdair G Kergon <agk(a)redhat.com>
CommitterDate: Fri Jul 31 22:53:38 2015 +0100
dmsetup: Use argcp and argvp.
---
tools/dmsetup.c | 66 +++++++++++++++++++++++++++---------------------------
1 files changed, 33 insertions(+), 33 deletions(-)
diff --git a/tools/dmsetup.c b/tools/dmsetup.c
index 4b23d72..bc71b35 100644
--- a/tools/dmsetup.c
+++ b/tools/dmsetup.c
@@ -3371,7 +3371,7 @@ error:
return 0;
}
-static int _process_losetup_switches(const char *base, int *argc, char ***argv,
+static int _process_losetup_switches(const char *base, int *argcp, char ***argvp,
const char *dev_dir)
{
int c;
@@ -3388,7 +3388,7 @@ static int _process_losetup_switches(const char *base, int *argc, char ***argv,
optarg = 0;
optind = OPTIND_INIT;
- while ((c = GETOPTLONG_FN(*argc, *argv, "ade:fo:v",
+ while ((c = GETOPTLONG_FN(*argcp, *argvp, "ade:fo:v",
long_options, NULL)) != -1 ) {
if (c == ':' || c == '?')
return 0;
@@ -3406,8 +3406,8 @@ static int _process_losetup_switches(const char *base, int *argc, char ***argv,
_switches[VERBOSE_ARG]++;
}
- *argv += optind ;
- *argc -= optind ;
+ *argvp += optind ;
+ *argcp -= optind ;
if (encrypt_loop){
fprintf(stderr, "%s: Sorry, cryptoloop is not yet implemented "
@@ -3424,33 +3424,33 @@ static int _process_losetup_switches(const char *base, int *argc, char ***argv,
if (find) {
fprintf(stderr, "%s: Sorry, find is not yet implemented "
"in this version.\n", base);
- if (!*argc)
+ if (!*argcp)
return 0;
}
- if (!*argc) {
+ if (!*argcp) {
fprintf(stderr, "%s: Please specify loop_device.\n", base);
_losetup_usage(stderr);
return 0;
}
- if (!(device_name = parse_loop_device_name((*argv)[0], dev_dir))) {
+ if (!(device_name = parse_loop_device_name((*argvp)[0], dev_dir))) {
fprintf(stderr, "%s: Could not parse loop_device %s\n",
- base, (*argv)[0]);
+ base, (*argvp)[0]);
_losetup_usage(stderr);
return 0;
}
if (delete) {
- *argc = 2;
+ *argcp = 2;
- (*argv)[1] = device_name;
- (*argv)[0] = (char *) "remove";
+ (*argvp)[1] = device_name;
+ (*argvp)[0] = (char *) "remove";
return 1;
}
- if (*argc != 2) {
+ if (*argcp != 2) {
fprintf(stderr, "%s: Too few arguments\n", base);
_losetup_usage(stderr);
dm_free(device_name);
@@ -3458,9 +3458,9 @@ static int _process_losetup_switches(const char *base, int *argc, char ***argv,
}
/* FIXME move these to make them available to native dmsetup */
- if (!(loop_file = _get_abspath((*argv)[(find) ? 0 : 1]))) {
+ if (!(loop_file = _get_abspath((*argvp)[(find) ? 0 : 1]))) {
fprintf(stderr, "%s: Could not parse loop file name %s\n",
- base, (*argv)[1]);
+ base, (*argvp)[1]);
_losetup_usage(stderr);
dm_free(device_name);
return 0;
@@ -3469,14 +3469,14 @@ static int _process_losetup_switches(const char *base, int *argc, char ***argv,
_table = dm_malloc(LOOP_TABLE_SIZE);
if (!_table ||
!_loop_table(_table, (size_t) LOOP_TABLE_SIZE, loop_file, device_name, offset)) {
- fprintf(stderr, "Could not build device-mapper table for %s\n", (*argv)[0]);
+ fprintf(stderr, "Could not build device-mapper table for %s\n", (*argvp)[0]);
dm_free(device_name);
return 0;
}
_switches[TABLE_ARG]++;
- (*argv)[0] = (char *) "create";
- (*argv)[1] = device_name ;
+ (*argvp)[0] = (char *) "create";
+ (*argvp)[1] = device_name ;
return 1;
}
@@ -3525,7 +3525,7 @@ static int _process_options(const char *options)
return 1;
}
-static int _process_switches(int *argc, char ***argv, const char *dev_dir)
+static int _process_switches(int *argcp, char ***argvp, const char *dev_dir)
{
const char *base;
char *namebase, *s;
@@ -3593,7 +3593,7 @@ static int _process_switches(int *argc, char ***argv, const char *dev_dir)
memset(&_int_args, 0, sizeof(_int_args));
_read_ahead_flags = 0;
- if (!(namebase = strdup((*argv)[0]))) {
+ if (!(namebase = strdup((*argvp)[0]))) {
fprintf(stderr, "Failed to duplicate name.\n");
return 0;
}
@@ -3608,28 +3608,28 @@ static int _process_switches(int *argc, char ***argv, const char *dev_dir)
_switches[MINOR_ARG]++;
_string_args[OPTIONS_ARG] = (char *) "name";
- if (*argc == 3) {
- _int_args[MAJOR_ARG] = atoi((*argv)[1]);
- _int_args[MINOR_ARG] = atoi((*argv)[2]);
- *argc -= 2;
- *argv += 2;
- } else if ((*argc == 2) &&
- (2 == sscanf((*argv)[1], "%i:%i",
+ if (*argcp == 3) {
+ _int_args[MAJOR_ARG] = atoi((*argvp)[1]);
+ _int_args[MINOR_ARG] = atoi((*argvp)[2]);
+ *argcp -= 2;
+ *argvp += 2;
+ } else if ((*argcp == 2) &&
+ (2 == sscanf((*argvp)[1], "%i:%i",
&_int_args[MAJOR_ARG],
&_int_args[MINOR_ARG]))) {
- *argc -= 1;
- *argv += 1;
+ *argcp -= 1;
+ *argvp += 1;
} else {
fprintf(stderr, "Usage: devmap_name <major> <minor>\n");
return 0;
}
- (*argv)[0] = (char *) "info";
+ (*argvp)[0] = (char *) "info";
return 1;
}
if (!strcmp(base, "losetup") || !strcmp(base, "dmlosetup")){
- r = _process_losetup_switches(base, argc, argv, dev_dir);
+ r = _process_losetup_switches(base, argcp, argvp, dev_dir);
free(namebase);
return r;
}
@@ -3638,7 +3638,7 @@ static int _process_switches(int *argc, char ***argv, const char *dev_dir)
optarg = 0;
optind = OPTIND_INIT;
- while ((ind = -1, c = GETOPTLONG_FN(*argc, *argv, "cCfG:hj:m:M:no:O:rS:u:U:vy",
+ while ((ind = -1, c = GETOPTLONG_FN(*argcp, *argvp, "cCfG:hj:m:M:no:O:rS:u:U:vy",
long_options, NULL)) != -1) {
if (c == ':' || c == '?')
return 0;
@@ -3828,8 +3828,8 @@ static int _process_switches(int *argc, char ***argv, const char *dev_dir)
return 0;
}
- *argv += optind;
- *argc -= optind;
+ *argvp += optind;
+ *argcp -= optind;
return 1;
}
8 years, 1 month
master - dmsetup: Add --count and --interval to reports.
by Alasdair Kergon
Gitweb: http://git.fedorahosted.org/git/?p=lvm2.git;a=commitdiff;h=a161e29c59e016...
Commit: a161e29c59e01605401c9096f5ad5ace2ae03d9a
Parent: 72f754e2bc571ada133057c5a248162dc349cf93
Author: Bryn M. Reeves <breeves(a)redhat.com>
AuthorDate: Fri Jul 31 21:59:34 2015 +0100
Committer: Alasdair G Kergon <agk(a)redhat.com>
CommitterDate: Fri Jul 31 21:59:34 2015 +0100
dmsetup: Add --count and --interval to reports.
For example, to monitor active devices every second you can now run
dmsetup info -c --count 0.
---
WHATS_NEW_DM | 2 +
libdm/.exported_symbols.DM_1_02_104 | 5 +++
libdm/libdevmapper.h | 44 ++++++++++++++++++++++++
libdm/libdm-report.c | 44 ++++++++++++++++++++++++
man/dmsetup.8.in | 18 ++++++++++
tools/dmsetup.c | 64 ++++++++++++++++++++++++++++++-----
6 files changed, 168 insertions(+), 9 deletions(-)
diff --git a/WHATS_NEW_DM b/WHATS_NEW_DM
index 81acfe9..2a006db 100644
--- a/WHATS_NEW_DM
+++ b/WHATS_NEW_DM
@@ -1,5 +1,7 @@
Version 1.02.104 -
=================================
+ Add dmsetup --interval and --count to repeat reports at specified intervals.
+ Add report interval and waiting functions to libdevmapper.
Add dm_timestamp functions to libdevmapper.
Version 1.02.103 - 24th July 2015
diff --git a/libdm/.exported_symbols.DM_1_02_104 b/libdm/.exported_symbols.DM_1_02_104
index 9fafa48..815c689 100644
--- a/libdm/.exported_symbols.DM_1_02_104
+++ b/libdm/.exported_symbols.DM_1_02_104
@@ -1,3 +1,8 @@
+dm_report_set_interval_ms
+dm_report_set_interval_ns
+dm_report_get_interval_ms
+dm_report_get_interval_ns
+dm_report_wait
dm_size_to_string
dm_timestamp_alloc
dm_timestamp_compare
diff --git a/libdm/libdevmapper.h b/libdm/libdevmapper.h
index 001d4c0..11ba0a3 100644
--- a/libdm/libdevmapper.h
+++ b/libdm/libdevmapper.h
@@ -1928,6 +1928,50 @@ int dm_report_field_percent(struct dm_report *rh, struct dm_report_field *field,
void dm_report_field_set_value(struct dm_report_field *field, const void *value,
const void *sortvalue);
+/*
+ * Set an interval (in nanoseconds) for this dm_report object that will
+ * be used by any subsequent call to dm_report_wait_interval. This is
+ * only useful for repeating reports (e.g. statistics).
+ *
+ * The default value is zero: no interval.
+ */
+void dm_report_set_interval_ns(struct dm_report *rh, uint64_t interval_ns);
+
+/*
+ * Set an interval in milliseconds for this dm_report object that will
+ * be used by any subsequent call to dm_report_wait. This is only
+ * useful for repeating reports (e.g. statistics).
+ *
+ * The default value is zero: no interval.
+ */
+void dm_report_set_interval_ms(struct dm_report *rh, uint64_t interval_ms);
+
+/*
+ * Retrieve the configured interval of the dm_report handle rh in
+ * nanoseconds.
+ */
+uint64_t dm_report_get_interval_ns(struct dm_report *rh);
+
+/*
+ * Retrieve the configured interval of the dm_report handle rh in
+ * milliseconds.
+ */
+uint64_t dm_report_get_interval_ms(struct dm_report *rh);
+
+/*
+ * Suspend the calling thread until the current reporting interval
+ * expires. When this function returns the caller should obtain updated
+ * report data and call dm_report_object() and dm_report_output() as
+ * necessary in order to produce the new interval's reporting output.
+ *
+ * Delivery of a non-blocked signal to the thread carrying out the
+ * wait will cause the function to return prematurely with an error.
+ *
+ * Attempting to wait on a report that has no interval set is also
+ * treated as an error.
+ */
+int dm_report_wait(struct dm_report *rh);
+
/*************************
* config file parse/print
*************************/
diff --git a/libdm/libdm-report.c b/libdm/libdm-report.c
index 34374bb..5ae994d 100644
--- a/libdm/libdm-report.c
+++ b/libdm/libdm-report.c
@@ -43,6 +43,8 @@ struct dm_report {
uint32_t flags;
const char *separator;
+ uint64_t interval_ns; /* Reporting interval in nanoseconds */
+
uint32_t keys_count;
/* Ordered list of fields needed for this report */
@@ -4210,3 +4212,45 @@ int dm_report_output(struct dm_report *rh)
else
return _output_as_columns(rh);
}
+
+#define NSEC_PER_USEC UINT64_C(1000)
+#define NSEC_PER_MSEC UINT64_C(1000000)
+#define NSEC_PER_SEC UINT64_C(1000000000)
+
+void dm_report_set_interval_ns(struct dm_report *rh, uint64_t interval_ns)
+{
+ rh->interval_ns = interval_ns;
+}
+
+void dm_report_set_interval_ms(struct dm_report *rh, uint64_t interval_ms)
+{
+ rh->interval_ns = interval_ms * NSEC_PER_MSEC;
+}
+
+uint64_t dm_report_get_interval_ns(struct dm_report *rh)
+{
+ return rh->interval_ns;
+}
+
+uint64_t dm_report_get_interval_ms(struct dm_report *rh)
+{
+ return (rh->interval_ns / NSEC_PER_MSEC);
+}
+
+int dm_report_wait(struct dm_report *rh)
+{
+ int r = 1;
+
+ if (!rh->interval_ns)
+ return_0;
+
+ if (usleep(rh->interval_ns / NSEC_PER_USEC)) {
+ if (errno == EINTR)
+ log_error("Report interval interrupted by signal.");
+ if (errno == EINVAL)
+ log_error("Report interval too short.");
+ r = 0;
+ }
+
+ return r;
+}
diff --git a/man/dmsetup.8.in b/man/dmsetup.8.in
index 57fbdf9..14e393a 100644
--- a/man/dmsetup.8.in
+++ b/man/dmsetup.8.in
@@ -42,6 +42,10 @@ dmsetup \(em low level logical volume management
.IR sort_fields ]
.RB [ \-S | \-\-select
.IR Selection ]
+.RB [ \-\-interval
+.IR seconds ]
+.RB [ \-\-count
+.IR count ]
.RI [ device_name ]
.RE
.br
@@ -187,6 +191,10 @@ In some cases these checks may slow down operations noticeably.
.BR \-c | \-C | \-\-columns
Display output in columns rather than as Field: Value lines.
.TP
+.B \-\-count \fIcount
+Specify the number of times to repeat a report. Set this to zero
+continue until interrupted. The default interval is one second.
+.TP
.BR \-h | \-\-help
Outputs a summary of the commands available, optionally including
the list of report fields (synonym with \fBhelp\fP command).
@@ -196,6 +204,12 @@ When returning any table information from the kernel report on the
inactive table instead of the live table.
Requires kernel driver version 4.16.0 or above.
.TP
+.B \-\-interval \fIseconds
+Specify the interval in seconds between successive iterations for
+repeating reports. If \-\-interval is specified but \-\-count is not,
+reports will continue to repeat until interrupted.
+The default interval is one second.
+.TP
.IR \fB\-\-manglename \ { none | hex | auto }
Mangle any character not on a whitelist using mangling_mode when
processing device-mapper device names and UUIDs. The names and UUIDs
@@ -355,6 +369,10 @@ Outputs some brief information about the device in the form:
.IR fields ]
.RB [ \-O | \-\-sort
.IR sort_fields ]
+.RB [ \-\-interval
+.IR seconds ]
+.RB [ \-\-count
+.IR count ]
.RI [ device_name ]
.br
Output you can customise.
diff --git a/tools/dmsetup.c b/tools/dmsetup.c
index f36119f..4b23d72 100644
--- a/tools/dmsetup.c
+++ b/tools/dmsetup.c
@@ -111,6 +111,7 @@ enum {
ADD_NODE_ON_RESUME_ARG,
CHECKS_ARG,
COLS_ARG,
+ COUNT_ARG,
DEFERRED_ARG,
SELECT_ARG,
EXEC_ARG,
@@ -118,6 +119,7 @@ enum {
GID_ARG,
HELP_ARG,
INACTIVE_ARG,
+ INTERVAL_ARG,
MANGLENAME_ARG,
MAJOR_ARG,
MINOR_ARG,
@@ -182,6 +184,11 @@ static struct dm_tree *_dtree;
static struct dm_report *_report;
static report_type_t _report_type;
static dev_name_t _dev_name_type;
+static uint32_t _count = 1; /* count of repeating reports */
+
+#define NSEC_PER_USEC UINT64_C(1000)
+#define NSEC_PER_MSEC UINT64_C(1000000)
+#define NSEC_PER_SEC UINT64_C(1000000000)
/*
* Commands
@@ -2845,6 +2852,7 @@ static int _report_init(const struct command *cmd)
int aligned = 1, headings = 1, buffered = 1, field_prefixes = 0;
int quoted = 1, columns_as_rows = 0;
uint32_t flags = 0;
+ uint32_t interval;
size_t len = 0;
int r = 0;
@@ -2936,6 +2944,11 @@ static int _report_init(const struct command *cmd)
goto out;
}
+ /* Default interval is 1 second. */
+ interval = _switches[INTERVAL_ARG] ? _int_args[INTERVAL_ARG] : 1;
+
+ dm_report_set_interval_ns(_report, NSEC_PER_SEC * interval);
+
if (field_prefixes)
dm_report_set_output_field_name_prefix(_report, "dm_");
@@ -3110,6 +3123,7 @@ static void _dmsetup_usage(FILE *out)
" [-y|--yes] [--readahead [+]<sectors>|auto|none] [--retry]\n"
" [-c|-C|--columns] [-o <fields>] [-O|--sort <sort_fields>]\n"
" [-S|--select <selection>] [--nameprefixes] [--noheadings]\n"
+ " [--count <count>] [--interval <seconds>]\n"
" [--separator <separator>]\n\n");
for (i = 0; _dmsetup_commands[i].name; i++)
fprintf(out, "\t%s %s\n", _dmsetup_commands[i].name, _dmsetup_commands[i].help);
@@ -3523,6 +3537,7 @@ static int _process_switches(int *argc, char ***argv, const char *dev_dir)
{"readonly", 0, &ind, READ_ONLY},
{"checks", 0, &ind, CHECKS_ARG},
{"columns", 0, &ind, COLS_ARG},
+ {"count", 1, &ind, COUNT_ARG},
{"deferred", 0, &ind, DEFERRED_ARG},
{"select", 1, &ind, SELECT_ARG},
{"exec", 1, &ind, EXEC_ARG},
@@ -3530,6 +3545,7 @@ static int _process_switches(int *argc, char ***argv, const char *dev_dir)
{"gid", 1, &ind, GID_ARG},
{"help", 0, &ind, HELP_ARG},
{"inactive", 0, &ind, INACTIVE_ARG},
+ {"interval", 1, &ind, INTERVAL_ARG},
{"manglename", 1, &ind, MANGLENAME_ARG},
{"major", 1, &ind, MAJOR_ARG},
{"minor", 1, &ind, MINOR_ARG},
@@ -3674,6 +3690,14 @@ static int _process_switches(int *argc, char ***argv, const char *dev_dir)
_switches[ADD_NODE_ON_CREATE_ARG]++;
if (ind == CHECKS_ARG)
_switches[CHECKS_ARG]++;
+ if (ind == COUNT_ARG) {
+ _switches[COUNT_ARG]++;
+ _int_args[COUNT_ARG] = atoi(optarg);
+ if (_int_args[COUNT_ARG] < 0) {
+ log_error("Count must be zero or greater.");
+ return 0;
+ }
+ }
if (ind == UDEVCOOKIE_ARG) {
_switches[UDEVCOOKIE_ARG]++;
_udev_cookie = _get_cookie_value(optarg);
@@ -3709,6 +3733,14 @@ static int _process_switches(int *argc, char ***argv, const char *dev_dir)
}
if (ind == INACTIVE_ARG)
_switches[INACTIVE_ARG]++;
+ if (ind == INTERVAL_ARG) {
+ _switches[INTERVAL_ARG]++;
+ _int_args[INTERVAL_ARG] = atoi(optarg);
+ if (_int_args[INTERVAL_ARG] <= 0) {
+ log_error("Interval must be a positive integer.");
+ return 0;
+ }
+ }
if (ind == MANGLENAME_ARG) {
_switches[MANGLENAME_ARG]++;
if (!strcasecmp(optarg, "none"))
@@ -3880,13 +3912,18 @@ unknown:
goto out;
}
- if (_switches[COLS_ARG] && !_report_init(cmd))
+#ifdef UDEV_SYNC_SUPPORT
+ if (!_set_up_udev_support(dev_dir))
goto out;
+#endif
- #ifdef UDEV_SYNC_SUPPORT
- if (!_set_up_udev_support(dev_dir))
+ if (_switches[COLS_ARG] && !_report_init(cmd))
goto out;
- #endif
+
+ if (_switches[COUNT_ARG])
+ _count = _int_args[COUNT_ARG] ? : UINT32_MAX;
+ else if (_switches[INTERVAL_ARG])
+ _count = UINT32_MAX;
/*
* Extract subcommand?
@@ -3897,17 +3934,26 @@ unknown:
argc--, argv++;
}
- doit:
+doit:
multiple_devices = (cmd->repeatable_cmd && argc != 2 &&
(argc != 1 || (!_switches[UUID_ARG] && !_switches[MAJOR_ARG])));
- r = _perform_command_for_all_repeatable_args(cmd, subcommand, argc, argv, NULL, multiple_devices);
+ do {
+ r = _perform_command_for_all_repeatable_args(cmd, subcommand, argc, argv, NULL, multiple_devices);
+
+ if (_report) {
+ dm_report_output(_report);
+
+ if (_count > 1) {
+ printf("\n");
+ dm_report_wait(_report);
+ }
+ }
+ } while (--_count);
out:
- if (_report) {
- dm_report_output(_report);
+ if (_report)
dm_report_free(_report);
- }
if (_dtree)
dm_tree_free(_dtree);
8 years, 1 month
master - lockd: remove ignorelockingfailure checks
by David Teigland
Gitweb: http://git.fedorahosted.org/git/?p=lvm2.git;a=commitdiff;h=72f754e2bc571a...
Commit: 72f754e2bc571ada133057c5a248162dc349cf93
Parent: 439a579aa2aaf13c2e420b6e7888dbd71d7021c0
Author: David Teigland <teigland(a)redhat.com>
AuthorDate: Fri Jul 31 15:46:51 2015 -0500
Committer: David Teigland <teigland(a)redhat.com>
CommitterDate: Fri Jul 31 15:51:50 2015 -0500
lockd: remove ignorelockingfailure checks
These code paths were effectively unused. The checks
had been added long ago without any real thought behind
what they should do or be used for.
---
lib/locking/lvmlockd.c | 11 +----------
1 files changed, 1 insertions(+), 10 deletions(-)
diff --git a/lib/locking/lvmlockd.c b/lib/locking/lvmlockd.c
index 15abd54..4e85ec1 100644
--- a/lib/locking/lvmlockd.c
+++ b/lib/locking/lvmlockd.c
@@ -1475,11 +1475,7 @@ int lockd_gl(struct cmd_context *cmd, const char *def_mode, uint32_t flags)
log_warn("Duplicate sanlock global locks should be corrected");
if (result < 0) {
- if (ignorelockingfailure()) {
- log_debug("Ignore failed locking for global lock");
- lvmetad_validate_global_cache(cmd, 1);
- return 1;
- } else if (result == -EAGAIN) {
+ if (result == -EAGAIN) {
/*
* Most of the time, retries should avoid this case.
*/
@@ -1770,11 +1766,6 @@ out:
if ((lockd_flags & LD_RF_DUP_GL_LS) && strcmp(mode, "un"))
log_warn("Duplicate sanlock global lock in VG %s", vg_name);
- if (!ret && ignorelockingfailure()) {
- log_debug("Ignore failed locking for VG %s", vg_name);
- return 1;
- }
-
return ret;
}
8 years, 1 month
master - vgchange/lvchange: allow deactivation without locking
by David Teigland
Gitweb: http://git.fedorahosted.org/git/?p=lvm2.git;a=commitdiff;h=439a579aa2aaf1...
Commit: 439a579aa2aaf13c2e420b6e7888dbd71d7021c0
Parent: 649c9d47199feddf7f5b65b5dbe12918ba2b383b
Author: David Teigland <teigland(a)redhat.com>
AuthorDate: Fri Jul 31 14:11:24 2015 -0500
Committer: David Teigland <teigland(a)redhat.com>
CommitterDate: Fri Jul 31 14:11:24 2015 -0500
vgchange/lvchange: allow deactivation without locking
If locking with lvmlockd has failed, allow LVs to be deactivated.
---
tools/lvchange.c | 4 +++-
tools/vgchange.c | 6 ++++--
2 files changed, 7 insertions(+), 3 deletions(-)
diff --git a/tools/lvchange.c b/tools/lvchange.c
index 823c36a..22a407a 100644
--- a/tools/lvchange.c
+++ b/tools/lvchange.c
@@ -1296,7 +1296,9 @@ int lvchange(struct cmd_context *cmd, int argc, char **argv)
*/
if (arg_count(cmd, activate_ARG) || arg_count(cmd, refresh_ARG)) {
cmd->lockd_vg_default_sh = 1;
- cmd->lockd_vg_enforce_sh = 1;
+ /* Allow deactivating if locks fail. */
+ if (is_change_activating((activation_change_t)arg_uint_value(cmd, activate_ARG, CHANGE_AY)))
+ cmd->lockd_vg_enforce_sh = 1;
}
return process_each_lv(cmd, argc, argv,
diff --git a/tools/vgchange.c b/tools/vgchange.c
index a163cf5..7aecd98 100644
--- a/tools/vgchange.c
+++ b/tools/vgchange.c
@@ -204,7 +204,7 @@ int vgchange_activate(struct cmd_context *cmd, struct volume_group *vg,
if (vg->system_id && vg->system_id[0] &&
cmd->system_id && cmd->system_id[0] &&
strcmp(vg->system_id, cmd->system_id) &&
- is_change_activating(activate)) {
+ do_activate) {
log_error("Cannot activate LVs in a foreign VG.");
return ECMD_FAILED;
}
@@ -1026,7 +1026,9 @@ static int _lockd_vgchange(struct cmd_context *cmd, int argc, char **argv)
if (arg_is_set(cmd, activate_ARG) || arg_is_set(cmd, refresh_ARG)) {
cmd->lockd_vg_default_sh = 1;
- cmd->lockd_vg_enforce_sh = 1;
+ /* Allow deactivating if locks fail. */
+ if (is_change_activating((activation_change_t)arg_uint_value(cmd, activate_ARG, CHANGE_AY)))
+ cmd->lockd_vg_enforce_sh = 1;
}
/* Starting a vg lockspace means there are no locks available yet. */
8 years, 1 month
master - dmsetup: Allow commands to have subcommands.
by Alasdair Kergon
Gitweb: http://git.fedorahosted.org/git/?p=lvm2.git;a=commitdiff;h=649c9d47199fed...
Commit: 649c9d47199feddf7f5b65b5dbe12918ba2b383b
Parent: 51f89f2fbdabc3b1800a1fd5ba4c7136ada0f9d3
Author: Alasdair G Kergon <agk(a)redhat.com>
AuthorDate: Fri Jul 31 19:09:31 2015 +0100
Committer: Alasdair G Kergon <agk(a)redhat.com>
CommitterDate: Fri Jul 31 19:09:31 2015 +0100
dmsetup: Allow commands to have subcommands.
No commands set has_subcommands yet.
Move multiple device loop to separate function because we'll
soon want to call it repeatedly.
(Based on patch from bmr.)
---
tools/dmsetup.c | 94 ++++++++++++++++++++++++++++++++----------------------
1 files changed, 56 insertions(+), 38 deletions(-)
diff --git a/tools/dmsetup.c b/tools/dmsetup.c
index 10bf3c6..f36119f 100644
--- a/tools/dmsetup.c
+++ b/tools/dmsetup.c
@@ -197,6 +197,7 @@ struct command {
int min_args;
int max_args;
int repeatable_cmd; /* Repeat to process device list? */
+ int has_subcommands; /* Command implements sub-commands. */
command_fn fn;
};
@@ -3058,42 +3059,42 @@ static int _dmsetup_help(CMD_ARGS);
* Dispatch table
*/
static struct command _dmsetup_commands[] = {
- {"help", "[-c|-C|--columns]", 0, 0, 0, _dmsetup_help},
+ {"help", "[-c|-C|--columns]", 0, 0, 0, 0, _dmsetup_help},
{"create", "<dev_name>\n"
"\t [-j|--major <major> -m|--minor <minor>]\n"
"\t [-U|--uid <uid>] [-G|--gid <gid>] [-M|--mode <octal_mode>]\n"
"\t [-u|uuid <uuid>] [{--addnodeonresume|--addnodeoncreate}]\n"
"\t [--notable | --table <table> | <table_file>]",
- 1, 2,0, _create},
- {"remove", "[-f|--force] [--deferred] <device>", 0, -1, 1, _remove},
- {"remove_all", "[-f|--force]", 0, 0, 0, _remove_all},
- {"suspend", "[--noflush] <device>", 0, -1, 1, _suspend},
- {"resume", "<device> [{--addnodeonresume|--addnodeoncreate}]", 0, -1, 1, _resume},
- {"load", "<device> [<table_file>]", 0, 2, 0, _load},
- {"clear", "<device>", 0, -1, 1, _clear},
- {"reload", "<device> [<table_file>]", 0, 2, 0, _load},
- {"wipe_table", "<device>", 0, -1, 1, _error_device},
- {"rename", "<device> [--setuuid] <new_name_or_uuid>", 1, 2, 0, _rename},
- {"message", "<device> <sector> <message>", 2, -1, 0, _message},
- {"ls", "[--target <target_type>] [--exec <command>] [-o options] [--tree]", 0, 0, 0, _ls},
- {"info", "[<device>]", 0, -1, 1, _info},
- {"deps", "[-o options] [<device>]", 0, -1, 1, _deps},
- {"status", "[<device>] [--noflush] [--target <target_type>]", 0, -1, 1, _status},
- {"table", "[<device>] [--target <target_type>] [--showkeys]", 0, -1, 1, _status},
- {"wait", "<device> [<event_nr>] [--noflush]", 0, 2, 0, _wait},
- {"mknodes", "[<device>]", 0, -1, 1, _mknodes},
- {"mangle", "[<device>]", 0, -1, 1, _mangle},
- {"udevcreatecookie", "", 0, 0, 0, _udevcreatecookie},
- {"udevreleasecookie", "[<cookie>]", 0, 1, 0, _udevreleasecookie},
- {"udevflags", "<cookie>", 1, 1, 0, _udevflags},
- {"udevcomplete", "<cookie>", 1, 1, 0, _udevcomplete},
- {"udevcomplete_all", "<age_in_minutes>", 0, 1, 0, _udevcomplete_all},
- {"udevcookies", "", 0, 0, 0, _udevcookies},
- {"targets", "", 0, 0, 0, _targets},
- {"version", "", 0, 0, 0, _version},
- {"setgeometry", "<device> <cyl> <head> <sect> <start>", 5, 5, 0, _setgeometry},
- {"splitname", "<device> [<subsystem>]", 1, 2, 0, _splitname},
- {NULL, NULL, 0, 0, 0, NULL}
+ 1, 2,0, 0, _create},
+ {"remove", "[-f|--force] [--deferred] <device>", 0, -1, 1, 0, _remove},
+ {"remove_all", "[-f|--force]", 0, 0, 0, 0, _remove_all},
+ {"suspend", "[--noflush] <device>", 0, -1, 1, 0, _suspend},
+ {"resume", "<device> [{--addnodeonresume|--addnodeoncreate}]", 0, -1, 1, 0, _resume},
+ {"load", "<device> [<table_file>]", 0, 2, 0, 0, _load},
+ {"clear", "<device>", 0, -1, 1, 0, _clear},
+ {"reload", "<device> [<table_file>]", 0, 2, 0, 0, _load},
+ {"wipe_table", "<device>", 0, -1, 1, 0, _error_device},
+ {"rename", "<device> [--setuuid] <new_name_or_uuid>", 1, 2, 0, 0, _rename},
+ {"message", "<device> <sector> <message>", 2, -1, 0, 0, _message},
+ {"ls", "[--target <target_type>] [--exec <command>] [-o options] [--tree]", 0, 0, 0, 0, _ls},
+ {"info", "[<device>]", 0, -1, 1, 0, _info},
+ {"deps", "[-o options] [<device>]", 0, -1, 1, 0, _deps},
+ {"status", "[<device>] [--noflush] [--target <target_type>]", 0, -1, 1, 0, _status},
+ {"table", "[<device>] [--target <target_type>] [--showkeys]", 0, -1, 1, 0, _status},
+ {"wait", "<device> [<event_nr>] [--noflush]", 0, 2, 0, 0, _wait},
+ {"mknodes", "[<device>]", 0, -1, 1, 0, _mknodes},
+ {"mangle", "[<device>]", 0, -1, 1, 0, _mangle},
+ {"udevcreatecookie", "", 0, 0, 0, 0, _udevcreatecookie},
+ {"udevreleasecookie", "[<cookie>]", 0, 1, 0, 0, _udevreleasecookie},
+ {"udevflags", "<cookie>", 1, 1, 0, 0, _udevflags},
+ {"udevcomplete", "<cookie>", 1, 1, 0, 0, _udevcomplete},
+ {"udevcomplete_all", "<age_in_minutes>", 0, 1, 0, 0, _udevcomplete_all},
+ {"udevcookies", "", 0, 0, 0, 0, _udevcookies},
+ {"targets", "", 0, 0, 0, 0, _targets},
+ {"version", "", 0, 0, 0, 0, _version},
+ {"setgeometry", "<device> <cyl> <head> <sect> <start>", 5, 5, 0, 0, _setgeometry},
+ {"splitname", "<device> [<subsystem>]", 1, 2, 0, 0, _splitname},
+ {NULL, NULL, 0, 0, 0, 0, NULL}
};
static void _dmsetup_usage(FILE *out)
@@ -3800,11 +3801,25 @@ static int _process_switches(int *argc, char ***argv, const char *dev_dir)
return 1;
}
+static int _perform_command_for_all_repeatable_args(CMD_ARGS)
+{
+ /* FIXME Shift args to remove argv[0] that fn is not allowed to access? */
+ do {
+ if (!cmd->fn(cmd, subcommand, argc--, argv++, NULL, multiple_devices)) {
+ fprintf(stderr, "Command failed\n");
+ return 1;
+ }
+ } while (cmd->repeatable_cmd && argc > 1);
+
+ return 0;
+}
+
int main(int argc, char **argv)
{
int r = 1;
const char *dev_dir;
const struct command *cmd;
+ const char *subcommand = NULL;
int multiple_devices;
(void) setlocale(LC_ALL, "");
@@ -3873,17 +3888,20 @@ unknown:
goto out;
#endif
+ /*
+ * Extract subcommand?
+ * dmsetup <command> <subcommand> [args...]
+ */
+ if (cmd->has_subcommands) {
+ subcommand = argv[1];
+ argc--, argv++;
+ }
+
doit:
multiple_devices = (cmd->repeatable_cmd && argc != 2 &&
(argc != 1 || (!_switches[UUID_ARG] && !_switches[MAJOR_ARG])));
- do {
- if (!cmd->fn(cmd, NULL, argc--, argv++, NULL, multiple_devices)) {
- fprintf(stderr, "Command failed\n");
- goto out;
- }
- } while (cmd->repeatable_cmd && argc > 1);
- r = 0;
+ r = _perform_command_for_all_repeatable_args(cmd, subcommand, argc, argv, NULL, multiple_devices);
out:
if (_report) {
8 years, 1 month
master - dmsetup: Add subcommand parameter.
by Alasdair Kergon
Gitweb: http://git.fedorahosted.org/git/?p=lvm2.git;a=commitdiff;h=51f89f2fbdabc3...
Commit: 51f89f2fbdabc3b1800a1fd5ba4c7136ada0f9d3
Parent: e06d188f0d9763195c9e6040ffb26b7203e39df2
Author: Alasdair G Kergon <agk(a)redhat.com>
AuthorDate: Fri Jul 31 17:47:03 2015 +0100
Committer: Alasdair G Kergon <agk(a)redhat.com>
CommitterDate: Fri Jul 31 17:47:03 2015 +0100
dmsetup: Add subcommand parameter.
Not yet used.
Allows for dmsetup stats <subcommand> dev1 dev2...
---
tools/dmsetup.c | 32 ++++++++++++++++----------------
1 files changed, 16 insertions(+), 16 deletions(-)
diff --git a/tools/dmsetup.c b/tools/dmsetup.c
index 2f62d70..10bf3c6 100644
--- a/tools/dmsetup.c
+++ b/tools/dmsetup.c
@@ -188,7 +188,7 @@ static dev_name_t _dev_name_type;
*/
struct command;
-#define CMD_ARGS const struct command *cmd, int argc, char **argv, struct dm_names *names, int multiple_devices
+#define CMD_ARGS const struct command *cmd, const char *subcommand, int argc, char **argv, struct dm_names *names, int multiple_devices
typedef int (*command_fn) (CMD_ARGS);
struct command {
@@ -1360,7 +1360,7 @@ static int _wait(CMD_ARGS)
(argc > 1) ? (uint32_t) atoi(argv[argc - 1]) : 0, 1);
}
-static int _process_all(const struct command *cmd, int argc, char **argv, int silent,
+static int _process_all(const struct command *cmd, const char *subcommand, int argc, char **argv, int silent,
int (*fn) (CMD_ARGS))
{
int r = 1;
@@ -1393,7 +1393,7 @@ static int _process_all(const struct command *cmd, int argc, char **argv, int si
do {
names = (struct dm_names *)((char *) names + next);
- if (!fn(cmd, argc, argv, names, 1))
+ if (!fn(cmd, subcommand, argc, argv, names, 1))
r = 0;
next = names->next;
} while (next);
@@ -1500,7 +1500,7 @@ static int _remove(CMD_ARGS)
*/
if (_udev_cookie)
log_warn("WARNING: Use of cookie and --force is not compatible.");
- (void) _error_device(cmd, argc, argv, NULL, 0);
+ (void) _error_device(cmd, NULL, argc, argv, NULL, 0);
}
return _simple(DM_DEVICE_REMOVE, argc > 1 ? argv[1] : NULL, 0, 0);
@@ -1524,17 +1524,17 @@ static int _remove_all(CMD_ARGS)
return r;
_num_devices = 0;
- r |= _process_all(cmd, argc, argv, 1, _count_devices);
+ r |= _process_all(cmd, NULL, argc, argv, 1, _count_devices);
/* No devices left? */
if (!_num_devices)
return r;
- r |= _process_all(cmd, argc, argv, 1, _error_device);
+ r |= _process_all(cmd, NULL, argc, argv, 1, _error_device);
r |= _simple(DM_DEVICE_REMOVE_ALL, "", 0, 0) | dm_mknodes(NULL);
_num_devices = 0;
- r |= _process_all(cmd, argc, argv, 1, _count_devices);
+ r |= _process_all(cmd, NULL, argc, argv, 1, _count_devices);
if (!_num_devices)
return r;
@@ -1633,7 +1633,7 @@ static int _status(CMD_ARGS)
name = names->name;
else {
if (argc == 1 && !_switches[UUID_ARG] && !_switches[MAJOR_ARG])
- return _process_all(cmd, argc, argv, 0, _status);
+ return _process_all(cmd, NULL, argc, argv, 0, _status);
name = argv[1];
}
@@ -1772,7 +1772,7 @@ static int _info(CMD_ARGS)
name = names->name;
else {
if (argc == 1 && !_switches[UUID_ARG] && !_switches[MAJOR_ARG])
- return _process_all(cmd, argc, argv, 0, _info);
+ return _process_all(cmd, NULL, argc, argv, 0, _info);
name = argv[1];
}
@@ -1816,7 +1816,7 @@ static int _deps(CMD_ARGS)
name = names->name;
else {
if (argc == 1 && !_switches[UUID_ARG] && !_switches[MAJOR_ARG])
- return _process_all(cmd, argc, argv, 0, _deps);
+ return _process_all(cmd, NULL, argc, argv, 0, _deps);
name = argv[1];
}
@@ -2239,7 +2239,7 @@ static int _build_whole_deptree(const struct command *cmd)
if (!(_dtree = dm_tree_create()))
return 0;
- if (!_process_all(cmd, 0, NULL, 0, _add_dep))
+ if (!_process_all(cmd, NULL, 0, NULL, 0, _add_dep))
return 0;
return 1;
@@ -2954,11 +2954,11 @@ static int _ls(CMD_ARGS)
{
if ((_switches[TARGET_ARG] && _target) ||
(_switches[EXEC_ARG] && _command))
- return _status(cmd, argc, argv, NULL, 0);
+ return _status(cmd, NULL, argc, argv, NULL, 0);
else if ((_switches[TREE_ARG]))
- return _display_tree(cmd, 0, NULL, NULL, 0);
+ return _display_tree(cmd, NULL, 0, NULL, NULL, 0);
else
- return _process_all(cmd, argc, argv, 0, _display_name);
+ return _process_all(cmd, NULL, argc, argv, 0, _display_name);
}
static int _mangle(CMD_ARGS)
@@ -2974,7 +2974,7 @@ static int _mangle(CMD_ARGS)
name = names->name;
else {
if (argc == 1 && !_switches[UUID_ARG] && !_switches[MAJOR_ARG])
- return _process_all(cmd, argc, argv, 0, _mangle);
+ return _process_all(cmd, NULL, argc, argv, 0, _mangle);
name = argv[1];
}
@@ -3877,7 +3877,7 @@ unknown:
multiple_devices = (cmd->repeatable_cmd && argc != 2 &&
(argc != 1 || (!_switches[UUID_ARG] && !_switches[MAJOR_ARG])));
do {
- if (!cmd->fn(cmd, argc--, argv++, NULL, multiple_devices)) {
+ if (!cmd->fn(cmd, NULL, argc--, argv++, NULL, multiple_devices)) {
fprintf(stderr, "Command failed\n");
goto out;
}
8 years, 1 month
master - dmsetup: _find_command returns const
by Alasdair Kergon
Gitweb: http://git.fedorahosted.org/git/?p=lvm2.git;a=commitdiff;h=e06d188f0d9763...
Commit: e06d188f0d9763195c9e6040ffb26b7203e39df2
Parent: fef3cb3f21cba9e88add8ffd1aad8d6691c77109
Author: Alasdair G Kergon <agk(a)redhat.com>
AuthorDate: Fri Jul 31 16:58:14 2015 +0100
Committer: Alasdair G Kergon <agk(a)redhat.com>
CommitterDate: Fri Jul 31 16:58:14 2015 +0100
dmsetup: _find_command returns const
---
tools/dmsetup.c | 6 +++---
1 files changed, 3 insertions(+), 3 deletions(-)
diff --git a/tools/dmsetup.c b/tools/dmsetup.c
index b803e44..2f62d70 100644
--- a/tools/dmsetup.c
+++ b/tools/dmsetup.c
@@ -3149,8 +3149,8 @@ static int _dmsetup_help(CMD_ARGS)
return 1;
}
-static struct command *_find_command(const struct command *commands,
- const char *name)
+static const struct command *_find_command(const struct command *commands,
+ const char *name)
{
int i;
@@ -3161,7 +3161,7 @@ static struct command *_find_command(const struct command *commands,
return NULL;
}
-static struct command *_find_dmsetup_command(const char *name)
+static const struct command *_find_dmsetup_command(const char *name)
{
return _find_command(_dmsetup_commands, name);
}
8 years, 1 month
master - dmsetup: Add _dmsetup to help and usage fns.
by Alasdair Kergon
Gitweb: http://git.fedorahosted.org/git/?p=lvm2.git;a=commitdiff;h=fef3cb3f21cba9...
Commit: fef3cb3f21cba9e88add8ffd1aad8d6691c77109
Parent: 027fe112ecb75e46c671658e233ff353523e9ec3
Author: Alasdair G Kergon <agk(a)redhat.com>
AuthorDate: Fri Jul 31 16:26:38 2015 +0100
Committer: Alasdair G Kergon <agk(a)redhat.com>
CommitterDate: Fri Jul 31 16:26:38 2015 +0100
dmsetup: Add _dmsetup to help and usage fns.
Prepare for dmstats.
Adjust some text to avoid 80-char wrap.
---
tools/dmsetup.c | 28 +++++++++++++++-------------
1 files changed, 15 insertions(+), 13 deletions(-)
diff --git a/tools/dmsetup.c b/tools/dmsetup.c
index 6481288..b803e44 100644
--- a/tools/dmsetup.c
+++ b/tools/dmsetup.c
@@ -3052,17 +3052,18 @@ out:
return r;
}
-static int _help(CMD_ARGS);
+static int _dmsetup_help(CMD_ARGS);
/*
* Dispatch table
*/
static struct command _dmsetup_commands[] = {
- {"help", "[-c|-C|--columns]", 0, 0, 0, _help},
- {"create", "<dev_name> [-j|--major <major> -m|--minor <minor>]\n"
- "\t [-U|--uid <uid>] [-G|--gid <gid>] [-M|--mode <octal_mode>]\n"
- "\t [-u|uuid <uuid>] [{--addnodeonresume|--addnodeoncreate}]\n"
- "\t [--notable | --table <table> | <table_file>]",
+ {"help", "[-c|-C|--columns]", 0, 0, 0, _dmsetup_help},
+ {"create", "<dev_name>\n"
+ "\t [-j|--major <major> -m|--minor <minor>]\n"
+ "\t [-U|--uid <uid>] [-G|--gid <gid>] [-M|--mode <octal_mode>]\n"
+ "\t [-u|uuid <uuid>] [{--addnodeonresume|--addnodeoncreate}]\n"
+ "\t [--notable | --table <table> | <table_file>]",
1, 2,0, _create},
{"remove", "[-f|--force] [--deferred] <device>", 0, -1, 1, _remove},
{"remove_all", "[-f|--force]", 0, 0, 0, _remove_all},
@@ -3095,13 +3096,14 @@ static struct command _dmsetup_commands[] = {
{NULL, NULL, 0, 0, 0, NULL}
};
-static void _usage(FILE *out)
+static void _dmsetup_usage(FILE *out)
{
int i;
fprintf(out, "Usage:\n\n");
fprintf(out, "dmsetup [--version] [-h|--help [-c|-C|--columns]]\n"
- " [--checks] [--manglename <mangling_mode>] [-v|--verbose [-v|--verbose ...]]\n"
+ " [-v|--verbose [-v|--verbose ...]]\n"
+ " [--checks] [--manglename <mangling_mode>]\n"
" [-r|--readonly] [--noopencount] [--nolockfs] [--inactive]\n"
" [--udevcookie [cookie]] [--noudevrules] [--noudevsync] [--verifyudev]\n"
" [-y|--yes] [--readahead [+]<sectors>|auto|none] [--retry]\n"
@@ -3128,9 +3130,9 @@ static void _losetup_usage(FILE *out)
"[-o offset] [-f|loop_device] [file]\n\n");
}
-static int _help(CMD_ARGS)
+static int _dmsetup_help(CMD_ARGS)
{
- _usage(stderr);
+ _dmsetup_usage(stderr);
if (_switches[COLS_ARG]) {
_switches[OPTIONS_ARG] = 1;
@@ -3834,21 +3836,21 @@ int main(int argc, char **argv)
}
if (argc == 0) {
- _usage(stderr);
+ _dmsetup_usage(stderr);
goto out;
}
if (!(cmd = _find_dmsetup_command(argv[0]))) {
unknown:
fprintf(stderr, "Unknown command\n");
- _usage(stderr);
+ _dmsetup_usage(stderr);
goto out;
}
if (argc < cmd->min_args + 1 ||
(cmd->max_args >= 0 && argc > cmd->max_args + 1)) {
fprintf(stderr, "Incorrect number of arguments\n");
- _usage(stderr);
+ _dmsetup_usage(stderr);
goto out;
}
8 years, 1 month
master - dmsetup: Rename _commands to _dmsetup_commands.
by Alasdair Kergon
Gitweb: http://git.fedorahosted.org/git/?p=lvm2.git;a=commitdiff;h=027fe112ecb75e...
Commit: 027fe112ecb75e46c671658e233ff353523e9ec3
Parent: f54198eed62f915df6fdb7c09a186160b5bb3954
Author: Alasdair G Kergon <agk(a)redhat.com>
AuthorDate: Fri Jul 31 16:13:45 2015 +0100
Committer: Alasdair G Kergon <agk(a)redhat.com>
CommitterDate: Fri Jul 31 16:13:45 2015 +0100
dmsetup: Rename _commands to _dmsetup_commands.
We'll need to accommodate sub-commands for dmstats.
---
tools/dmsetup.c | 26 ++++++++++++++++----------
1 files changed, 16 insertions(+), 10 deletions(-)
diff --git a/tools/dmsetup.c b/tools/dmsetup.c
index 7a26db1..6481288 100644
--- a/tools/dmsetup.c
+++ b/tools/dmsetup.c
@@ -3057,7 +3057,7 @@ static int _help(CMD_ARGS);
/*
* Dispatch table
*/
-static struct command _commands[] = {
+static struct command _dmsetup_commands[] = {
{"help", "[-c|-C|--columns]", 0, 0, 0, _help},
{"create", "<dev_name> [-j|--major <major> -m|--minor <minor>]\n"
"\t [-U|--uid <uid>] [-G|--gid <gid>] [-M|--mode <octal_mode>]\n"
@@ -3108,8 +3108,8 @@ static void _usage(FILE *out)
" [-c|-C|--columns] [-o <fields>] [-O|--sort <sort_fields>]\n"
" [-S|--select <selection>] [--nameprefixes] [--noheadings]\n"
" [--separator <separator>]\n\n");
- for (i = 0; _commands[i].name; i++)
- fprintf(out, "\t%s %s\n", _commands[i].name, _commands[i].help);
+ for (i = 0; _dmsetup_commands[i].name; i++)
+ fprintf(out, "\t%s %s\n", _dmsetup_commands[i].name, _dmsetup_commands[i].help);
fprintf(out, "\n<device> may be device name or -u <uuid> or "
"-j <major> -m <minor>\n");
fprintf(out, "<mangling_mode> is one of 'none', 'auto' and 'hex'.\n");
@@ -3147,17 +3147,23 @@ static int _help(CMD_ARGS)
return 1;
}
-static struct command *_find_command(const char *name)
+static struct command *_find_command(const struct command *commands,
+ const char *name)
{
int i;
- for (i = 0; _commands[i].name; i++)
- if (!strcmp(_commands[i].name, name))
- return _commands + i;
+ for (i = 0; commands[i].name; i++)
+ if (!strcmp(commands[i].name, name))
+ return commands + i;
return NULL;
}
+static struct command *_find_dmsetup_command(const char *name)
+{
+ return _find_command(_dmsetup_commands, name);
+}
+
static int _process_tree_options(const char *options)
{
const char *s, *end;
@@ -3816,13 +3822,13 @@ int main(int argc, char **argv)
}
if (_switches[HELP_ARG]) {
- if ((cmd = _find_command("help")))
+ if ((cmd = _find_dmsetup_command("help")))
goto doit;
goto unknown;
}
if (_switches[VERSION_ARG]) {
- if ((cmd = _find_command("version")))
+ if ((cmd = _find_dmsetup_command("version")))
goto doit;
goto unknown;
}
@@ -3832,7 +3838,7 @@ int main(int argc, char **argv)
goto out;
}
- if (!(cmd = _find_command(argv[0]))) {
+ if (!(cmd = _find_dmsetup_command(argv[0]))) {
unknown:
fprintf(stderr, "Unknown command\n");
_usage(stderr);
8 years, 1 month
master - toolcontext: use refresh_filters in refresh_toolcontext
by Peter Rajnoha
Gitweb: http://git.fedorahosted.org/git/?p=lvm2.git;a=commitdiff;h=f54198eed62f91...
Commit: f54198eed62f915df6fdb7c09a186160b5bb3954
Parent: 0dae377fbf1e0b3e1484984602cbaf73487efa47
Author: Peter Rajnoha <prajnoha(a)redhat.com>
AuthorDate: Fri Jul 31 10:20:33 2015 +0200
Committer: Peter Rajnoha <prajnoha(a)redhat.com>
CommitterDate: Fri Jul 31 10:25:36 2015 +0200
toolcontext: use refresh_filters in refresh_toolcontext
Use refresh_filters instead of destroy_filters and init_filters
in refresh_toolcontext fn which deals with cmd->initialized.filters
correctly on refresh.
---
lib/commands/toolcontext.c | 3 +--
1 files changed, 1 insertions(+), 2 deletions(-)
diff --git a/lib/commands/toolcontext.c b/lib/commands/toolcontext.c
index c087820..f4c0c95 100644
--- a/lib/commands/toolcontext.c
+++ b/lib/commands/toolcontext.c
@@ -2011,7 +2011,6 @@ int refresh_toolcontext(struct cmd_context *cmd)
label_exit();
_destroy_segtypes(&cmd->segtypes);
_destroy_formats(cmd, &cmd->formats);
- _destroy_filters(cmd);
if (!dev_cache_exit())
stack;
@@ -2109,7 +2108,7 @@ int refresh_toolcontext(struct cmd_context *cmd)
if (cmd->initialized.connections && !init_connections(cmd))
return_0;
- if (cmd->initialized.filters && !init_filters(cmd, 0))
+ if (!refresh_filters(cmd))
return_0;
reset_lvm_errno(1);
8 years, 2 months