master - lvconvert: handle old arg quirk when combining snapshot
by David Teigland
Gitweb: http://git.fedorahosted.org/git/?p=lvm2.git;a=commitdiff;h=286d39ee3c4334...
Commit: 286d39ee3c4334e9ce0609d9136dfd6b5d6bf34a
Parent: d3af0e7528dbba30824379fc98cb4db437559ad5
Author: David Teigland <teigland(a)redhat.com>
AuthorDate: Wed Feb 15 12:40:35 2017 -0600
Committer: David Teigland <teigland(a)redhat.com>
CommitterDate: Wed Feb 15 12:40:35 2017 -0600
lvconvert: handle old arg quirk when combining snapshot
The old ad hoc arg parsing when combining a split snapshot
allowed the first lv to have a vgname, but not the second.
Since lvconvert now uses the standard arg parsing in
process_each_lv(), the old one-off behavior requires a
work around.
---
tools/lvconvert.c | 37 +++++++++++++++++++++++++++++++++++++
1 files changed, 37 insertions(+), 0 deletions(-)
diff --git a/tools/lvconvert.c b/tools/lvconvert.c
index 502d614..a2ad115 100644
--- a/tools/lvconvert.c
+++ b/tools/lvconvert.c
@@ -3649,6 +3649,43 @@ static int _lvconvert_combine_split_snapshot_single(struct cmd_context *cmd,
int lvconvert_combine_split_snapshot_cmd(struct cmd_context *cmd, int argc, char **argv)
{
+ const char *vgname = NULL;
+ const char *lvname1;
+ const char *lvname2;
+ char *vglv;
+ int vglv_sz;
+
+ /*
+ * Hack to accomodate an old parsing quirk that allowed the
+ * the VG name to be attached to only the LV in arg pos 1,
+ * i.e. lvconvert -s vgname/lvname lvname
+ *
+ * The LV name in arg pos 2 is the one that is processed
+ * by process_each_lv(). If that LV has no VG name, but
+ * the first LV does, then copy the VG name from arg pos 1
+ * and add it to the LV name in arg pos 2 so that the
+ * standard arg parsing in process_each_lv will find it.
+ *
+ * This is the only instance in all commands.
+ */
+
+ lvname1 = cmd->position_argv[0];
+ lvname2 = cmd->position_argv[1];
+
+ if (strstr("/", lvname1) && !strstr("/", lvname2) && !getenv("LVM_VG_NAME")) {
+ if (!validate_lvname_param(cmd, &vgname, &lvname1))
+ return_ECMD_FAILED;
+
+ vglv_sz = strlen(vgname) + strlen(lvname2) + 2;
+ if (!(vglv = dm_pool_alloc(cmd->mem, vglv_sz)) ||
+ dm_snprintf(vglv, vglv_sz, "%s/%s", vgname, lvname2) < 0) {
+ log_error("vg/lv string alloc failed.");
+ return_ECMD_FAILED;
+ }
+
+ cmd->position_argv[1] = vglv;
+ }
+
return process_each_lv(cmd, 1, cmd->position_argv + 1, NULL, NULL, READ_FOR_UPDATE,
NULL, NULL, &_lvconvert_combine_split_snapshot_single);
}
7 years, 3 months
master - lvcreate: LVM_VG_NAME applies even without name arg
by David Teigland
Gitweb: http://git.fedorahosted.org/git/?p=lvm2.git;a=commitdiff;h=d3af0e7528dbba...
Commit: d3af0e7528dbba30824379fc98cb4db437559ad5
Parent: 7417c8acfa0e9274fbfcf3220630ac3b66e88fb4
Author: David Teigland <teigland(a)redhat.com>
AuthorDate: Wed Feb 15 12:07:51 2017 -0600
Committer: David Teigland <teigland(a)redhat.com>
CommitterDate: Wed Feb 15 12:07:51 2017 -0600
lvcreate: LVM_VG_NAME applies even without name arg
There was a small flaw in the logic regarding when LVM_VG_NAME
can replace a VG position arg.
---
tools/lvmcmdline.c | 14 ++++++++++----
1 files changed, 10 insertions(+), 4 deletions(-)
diff --git a/tools/lvmcmdline.c b/tools/lvmcmdline.c
index 02aaff2..41ae8c4 100644
--- a/tools/lvmcmdline.c
+++ b/tools/lvmcmdline.c
@@ -1280,6 +1280,7 @@ check_val:
static int _command_required_pos_matches(struct cmd_context *cmd, int ci, int rp, char **argv)
{
const char *name;
+ char *gotenv = NULL;
/*
* rp is the index in required_pos_args[] of the required positional arg.
@@ -1311,14 +1312,19 @@ static int _command_required_pos_matches(struct cmd_context *cmd, int ci, int rp
if (!strcmp(cmd->name, "lvcreate") &&
(rp == 0) &&
val_bit_is_set(commands[ci].required_pos_args[rp].def.val_bits, vg_VAL) &&
- (arg_is_set(cmd, name_ARG) || arg_is_set(cmd, thinpool_ARG) || arg_is_set(cmd, cachepool_ARG))) {
+ (arg_is_set(cmd, name_ARG) ||
+ arg_is_set(cmd, thinpool_ARG) ||
+ arg_is_set(cmd, cachepool_ARG) ||
+ (gotenv = getenv("LVM_VG_NAME")))) {
+
+ if (gotenv)
+ return 1;
+
if ((name = arg_str_value(cmd, name_ARG, NULL))) {
- if (strstr(name, "/") || getenv("LVM_VG_NAME"))
+ if (strstr(name, "/"))
return 1;
}
- /* FIXME: does LVM_VG_NAME also work with --thinpool/--cachepool ? */
-
if ((name = arg_str_value(cmd, thinpool_ARG, NULL))) {
if (strstr(name, "/"))
return 1;
7 years, 3 months
master - Revert "lvconvert: enable previous syntax to swap metadata"
by David Teigland
Gitweb: http://git.fedorahosted.org/git/?p=lvm2.git;a=commitdiff;h=7417c8acfa0e92...
Commit: 7417c8acfa0e9274fbfcf3220630ac3b66e88fb4
Parent: d2c5bb5c7066142930c88275d2fb6c8552559c9a
Author: David Teigland <teigland(a)redhat.com>
AuthorDate: Tue Feb 14 16:02:54 2017 -0600
Committer: David Teigland <teigland(a)redhat.com>
CommitterDate: Tue Feb 14 16:02:54 2017 -0600
Revert "lvconvert: enable previous syntax to swap metadata"
This reverts commit 717363bb9427c02addeb22ef77396132cb30c782.
These alternate forms for swapping metadata cannot be
distinguished from the command for creating a pool.
If we were to add these alternate forms for swapping
metadata, we would need to overload the pool creation
command defs, making those definitions ambiguous.
---
tools/command-lines.in | 14 --------------
tools/lvconvert.c | 2 ++
tools/lvmcmdline.c | 2 --
tools/tools.h | 1 -
4 files changed, 2 insertions(+), 17 deletions(-)
diff --git a/tools/command-lines.in b/tools/command-lines.in
index b6aa1d1..377e536 100644
--- a/tools/command-lines.in
+++ b/tools/command-lines.in
@@ -508,20 +508,6 @@ OO: --chunksize SizeKB, OO_LVCONVERT
ID: lvconvert_swap_pool_metadata
DESC: Swap metadata LV in a thin pool or cache pool (for repair only).
-lvconvert --poolmetadata LV --thinpool LV_thinpool
-OO: --chunksize SizeKB, OO_LVCONVERT
-ID: lvconvert_swap_thinpool_metadata
-DESC: Swap metadata LV in a thin pool (for repair only).
-DESC: (variant, use --swapmetadata).
-FLAGS: SECONDARY_SYNTAX
-
-lvconvert --poolmetadata LV --cachepool LV_cachepool
-OO: --chunksize SizeKB, OO_LVCONVERT
-ID: lvconvert_swap_cachepool_metadata
-DESC: Swap metadata LV in a cache pool (for repair only).
-DESC: (variant, use --swapmetadata).
-FLAGS: SECONDARY_SYNTAX
-
---
# lvconvert --merge is an extremely ambiguous command.
diff --git a/tools/lvconvert.c b/tools/lvconvert.c
index 3897602..502d614 100644
--- a/tools/lvconvert.c
+++ b/tools/lvconvert.c
@@ -4040,6 +4040,7 @@ int lvconvert_swap_pool_metadata_cmd(struct cmd_context *cmd, int argc, char **a
NULL, NULL, &_lvconvert_swap_pool_metadata_single);
}
+#if 0
int lvconvert_swap_pool_metadata_noarg_cmd(struct cmd_context *cmd, int argc, char **argv)
{
struct command *new_command;
@@ -4071,6 +4072,7 @@ int lvconvert_swap_pool_metadata_noarg_cmd(struct cmd_context *cmd, int argc, ch
return lvconvert_swap_pool_metadata_cmd(cmd, argc, argv);
}
+#endif
static int _lvconvert_merge_thin_single(struct cmd_context *cmd,
struct logical_volume *lv,
diff --git a/tools/lvmcmdline.c b/tools/lvmcmdline.c
index 65f80c8..02aaff2 100644
--- a/tools/lvmcmdline.c
+++ b/tools/lvmcmdline.c
@@ -141,8 +141,6 @@ struct command_function command_functions[CMD_COUNT] = {
{ lvconvert_to_thin_with_external_CMD, lvconvert_to_thin_with_external_cmd },
{ lvconvert_to_cache_vol_CMD, lvconvert_to_cache_vol_cmd },
{ lvconvert_swap_pool_metadata_CMD, lvconvert_swap_pool_metadata_cmd },
- { lvconvert_swap_thinpool_metadata_CMD, lvconvert_swap_pool_metadata_noarg_cmd },
- { lvconvert_swap_cachepool_metadata_CMD, lvconvert_swap_pool_metadata_noarg_cmd },
{ lvconvert_merge_thin_CMD, lvconvert_merge_thin_cmd },
{ lvconvert_split_and_keep_cachepool_CMD, lvconvert_split_cachepool_cmd },
{ lvconvert_split_and_remove_cachepool_CMD, lvconvert_split_cachepool_cmd },
diff --git a/tools/tools.h b/tools/tools.h
index 2f2a0fd..b3858a0 100644
--- a/tools/tools.h
+++ b/tools/tools.h
@@ -278,7 +278,6 @@ int lvconvert_to_pool_noarg_cmd(struct cmd_context *cmd, int argc, char **argv);
int lvconvert_to_cache_vol_cmd(struct cmd_context *cmd, int argc, char **argv);
int lvconvert_to_thin_with_external_cmd(struct cmd_context *cmd, int argc, char **argv);
int lvconvert_swap_pool_metadata_cmd(struct cmd_context *cmd, int argc, char **argv);
-int lvconvert_swap_pool_metadata_noarg_cmd(struct cmd_context *cmd, int argc, char **argv);
int lvconvert_merge_thin_cmd(struct cmd_context *cmd, int argc, char **argv);
int lvconvert_split_cachepool_cmd(struct cmd_context *cmd, int argc, char **argv);
7 years, 3 months
master - coverity cleanups
by David Teigland
Gitweb: http://git.fedorahosted.org/git/?p=lvm2.git;a=commitdiff;h=d2c5bb5c706614...
Commit: d2c5bb5c7066142930c88275d2fb6c8552559c9a
Parent: 1236e0ed293d13bff1205dbd2ac31877278b7a90
Author: David Teigland <teigland(a)redhat.com>
AuthorDate: Tue Feb 14 15:53:29 2017 -0600
Committer: David Teigland <teigland(a)redhat.com>
CommitterDate: Tue Feb 14 15:53:29 2017 -0600
coverity cleanups
---
tools/command.h | 6 +++---
1 files changed, 3 insertions(+), 3 deletions(-)
diff --git a/tools/command.h b/tools/command.h
index 3d708f0..0c3f9f3 100644
--- a/tools/command.h
+++ b/tools/command.h
@@ -69,7 +69,7 @@ struct command_name {
static inline int val_bit_is_set(uint64_t val_bits, int val_enum)
{
- return (val_bits & (1 << val_enum)) ? 1 : 0;
+ return (val_bits & (1ULL << val_enum)) ? 1 : 0;
}
static inline uint64_t val_enum_to_bit(int val_enum)
@@ -79,7 +79,7 @@ static inline uint64_t val_enum_to_bit(int val_enum)
static inline int lvp_bit_is_set(uint64_t lvp_bits, int lvp_enum)
{
- return (lvp_bits & (1 << lvp_enum)) ? 1 : 0;
+ return (lvp_bits & (1ULL << lvp_enum)) ? 1 : 0;
}
static inline uint64_t lvp_enum_to_bit(int lvp_enum)
@@ -89,7 +89,7 @@ static inline uint64_t lvp_enum_to_bit(int lvp_enum)
static inline int lvt_bit_is_set(uint64_t lvt_bits, int lvt_enum)
{
- return (lvt_bits & (1 << lvt_enum)) ? 1 : 0;
+ return (lvt_bits & (1ULL << lvt_enum)) ? 1 : 0;
}
static inline uint64_t lvt_enum_to_bit(int lvt_enum)
7 years, 3 months
master - man-generator: fix compiler warnings
by David Teigland
Gitweb: http://git.fedorahosted.org/git/?p=lvm2.git;a=commitdiff;h=1236e0ed293d13...
Commit: 1236e0ed293d13bff1205dbd2ac31877278b7a90
Parent: 1dddb068c90d553957dd8668b76c3eb9734b2e95
Author: David Teigland <teigland(a)redhat.com>
AuthorDate: Tue Feb 14 10:28:52 2017 -0600
Committer: David Teigland <teigland(a)redhat.com>
CommitterDate: Tue Feb 14 10:28:52 2017 -0600
man-generator: fix compiler warnings
---
tools/command.c | 7 +++----
1 files changed, 3 insertions(+), 4 deletions(-)
diff --git a/tools/command.c b/tools/command.c
index b655abe..aa33d5c 100644
--- a/tools/command.c
+++ b/tools/command.c
@@ -2181,7 +2181,7 @@ void print_man_usage(char *lvmname, struct command *cmd)
void print_man_usage_common(struct command *cmd)
{
struct command_name *cname;
- int i, sep, ro, rp, oo, op, opt_enum;
+ int i, sep, rp, oo, op, opt_enum;
if (!(cname = find_command_name(cmd->name)))
return;
@@ -2569,7 +2569,7 @@ static void include_description_file(char *name, char *des_file)
if (fd < 0)
return;
- read(fd, buf, sizeof(buf));
+ (void)read(fd, buf, sizeof(buf));
buf[MAX_MAN_DESC-1] = '\0';
@@ -2584,8 +2584,7 @@ void print_man(char *name, char *des_file, int include_primary, int include_seco
struct command_name *cname;
struct command *cmd, *prev_cmd = NULL;
char *lvmname = name;
- const char *desc;
- int i, j, ro, rp, oo, op;
+ int i;
if (!strncmp(name, "lvm-", 4))
name += 4;
7 years, 3 months
master - man/help: use separator in units list
by David Teigland
Gitweb: http://git.fedorahosted.org/git/?p=lvm2.git;a=commitdiff;h=1dddb068c90d55...
Commit: 1dddb068c90d553957dd8668b76c3eb9734b2e95
Parent: c0f2a59993e373781c6dd5568cd559547cfe49a1
Author: David Teigland <teigland(a)redhat.com>
AuthorDate: Tue Feb 14 10:20:38 2017 -0600
Committer: David Teigland <teigland(a)redhat.com>
CommitterDate: Tue Feb 14 10:21:39 2017 -0600
man/help: use separator in units list
h|H|b|B|... instead of hHbB...
---
tools/vals.h | 2 +-
1 files changed, 1 insertions(+), 1 deletions(-)
diff --git a/tools/vals.h b/tools/vals.h
index 38029aa..d9b0064 100644
--- a/tools/vals.h
+++ b/tools/vals.h
@@ -122,7 +122,7 @@ val(numsigned_VAL, int_arg_with_sign, "SNumber", "[+|-]Number")
val(numsignedper_VAL, int_arg_with_sign_and_percent, "SNumberP", "[+|-]Number[%VG|%PVS|%FREE]")
val(permission_VAL, permission_arg, "Permission", "rw|r")
val(metadatatype_VAL, metadatatype_arg, "MetadataType", "lvm2|lvm1")
-val(units_VAL, string_arg, "Units", "hHbBsSkKmMgGtTpPeE")
+val(units_VAL, string_arg, "Units", "h|H|b|B|s|S|k|K|m|M|g|G|t|T|p|P|e|E")
val(segtype_VAL, segtype_arg, "SegType", "linear|striped|snapshot|mirror|raid*|thin|cache|thin-pool|cache-pool")
val(alloc_VAL, alloc_arg, "Alloc", "contiguous|cling|cling_by_tags|normal|anywhere|inherit")
val(locktype_VAL, locktype_arg, "LockType", "sanlock|dlm|none")
7 years, 3 months
master - commands: skip parsing command defs for other command names
by David Teigland
Gitweb: http://git.fedorahosted.org/git/?p=lvm2.git;a=commitdiff;h=c0f2a59993e373...
Commit: c0f2a59993e373781c6dd5568cd559547cfe49a1
Parent: f46b28bdb6f8c0f7bae7a8b4fb4b886332831318
Author: David Teigland <teigland(a)redhat.com>
AuthorDate: Tue Feb 14 10:16:13 2017 -0600
Committer: David Teigland <teigland(a)redhat.com>
CommitterDate: Tue Feb 14 10:16:13 2017 -0600
commands: skip parsing command defs for other command names
The base command name can be used to skip parsing
command defs that will not be needed.
---
tools/command.c | 30 ++++++++++++++++++++++--------
tools/command.h | 2 +-
tools/lvm2cmdline.h | 2 +-
tools/lvmcmdlib.c | 2 +-
tools/lvmcmdline.c | 14 +++++++++++---
5 files changed, 36 insertions(+), 14 deletions(-)
diff --git a/tools/command.c b/tools/command.c
index a968bed..b655abe 100644
--- a/tools/command.c
+++ b/tools/command.c
@@ -1292,7 +1292,7 @@ static int copy_line(char *line, int max_line, int *position)
return 1;
}
-int define_commands(void)
+int define_commands(char *run_name)
{
struct command *cmd;
char line[MAX_LINE];
@@ -1306,6 +1306,10 @@ int define_commands(void)
int prev_was_oo = 0;
int prev_was_op = 0;
int copy_pos = 0;
+ int skip = 0;
+
+ if (run_name && !strcmp(run_name, "help"))
+ run_name = NULL;
create_opt_names_alpha();
@@ -1340,6 +1344,16 @@ int define_commands(void)
cmd->command_index = cmd_count;
cmd_count++;
cmd->name = strdup(name);
+
+ if (run_name && strcmp(run_name, name)) {
+ skip = 1;
+ prev_was_oo_def = 0;
+ prev_was_oo = 0;
+ prev_was_op = 0;
+ continue;
+ }
+ skip = 0;
+
cmd->pos_count = 1;
add_required_line(cmd, line_argc, line_argv);
@@ -1353,7 +1367,7 @@ int define_commands(void)
* context of the existing command[].
*/
- if (is_desc_line(line_argv[0])) {
+ if (is_desc_line(line_argv[0]) && !skip) {
char *desc = strdup(line_orig);
if (cmd->desc) {
int newlen = strlen(cmd->desc) + strlen(desc) + 2;
@@ -1369,12 +1383,12 @@ int define_commands(void)
continue;
}
- if (is_flags_line(line_argv[0])) {
+ if (is_flags_line(line_argv[0]) && !skip) {
add_flags(cmd, line_orig);
continue;
}
- if (is_rule_line(line_argv[0])) {
+ if (is_rule_line(line_argv[0]) && !skip) {
add_rule(cmd, line_orig);
continue;
}
@@ -1394,7 +1408,7 @@ int define_commands(void)
}
/* OO: ... */
- if (is_oo_line(line_argv[0])) {
+ if (is_oo_line(line_argv[0]) && !skip) {
add_optional_opt_line(cmd, line_argc, line_argv);
prev_was_oo_def = 0;
prev_was_oo = 1;
@@ -1403,7 +1417,7 @@ int define_commands(void)
}
/* OP: ... */
- if (is_op_line(line_argv[0])) {
+ if (is_op_line(line_argv[0]) && !skip) {
add_optional_pos_line(cmd, line_argc, line_argv);
prev_was_oo_def = 0;
prev_was_oo = 0;
@@ -1412,7 +1426,7 @@ int define_commands(void)
}
/* IO: ... */
- if (is_io_line(line_argv[0])) {
+ if (is_io_line(line_argv[0]) && !skip) {
add_ignore_opt_line(cmd, line_argc, line_argv);
prev_was_oo = 0;
prev_was_op = 0;
@@ -2703,7 +2717,7 @@ int main(int argc, char *argv[])
exit(EXIT_FAILURE);
}
- define_commands();
+ define_commands(NULL);
print_man(argv[1], (argc > 2) ? argv[2] : NULL, 1, 1);
diff --git a/tools/command.h b/tools/command.h
index b3fae03..3d708f0 100644
--- a/tools/command.h
+++ b/tools/command.h
@@ -209,7 +209,7 @@ struct command {
int pos_count; /* temp counter used by create-command */
};
-int define_commands(void);
+int define_commands(char *run_name);
int command_id_to_enum(const char *str);
void print_usage(struct command *cmd);
void print_usage_common(struct command_name *cname, struct command *cmd);
diff --git a/tools/lvm2cmdline.h b/tools/lvm2cmdline.h
index 9b75c36..00162a4 100644
--- a/tools/lvm2cmdline.h
+++ b/tools/lvm2cmdline.h
@@ -32,7 +32,7 @@ void *cmdlib_lvm2_init(unsigned static_compile);
void lvm_fin(struct cmd_context *cmd);
struct cmd_context *init_lvm(unsigned set_connections, unsigned set_filters);
-void lvm_register_commands(void);
+void lvm_register_commands(char *name);
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_return_code(int ret);
diff --git a/tools/lvmcmdlib.c b/tools/lvmcmdlib.c
index a1e938b..9e50343 100644
--- a/tools/lvmcmdlib.c
+++ b/tools/lvmcmdlib.c
@@ -34,7 +34,7 @@ void *cmdlib_lvm2_init(unsigned static_compile)
if (!(cmd = init_lvm(1, 1)))
return NULL;
- lvm_register_commands();
+ lvm_register_commands(NULL);
return (void *) cmd;
}
diff --git a/tools/lvmcmdline.c b/tools/lvmcmdline.c
index 494f01f..65f80c8 100644
--- a/tools/lvmcmdline.c
+++ b/tools/lvmcmdline.c
@@ -1128,7 +1128,7 @@ static struct command_function *_find_command_id_function(int command_enum)
return NULL;
}
-void lvm_register_commands(void)
+void lvm_register_commands(char *name)
{
int i;
@@ -1138,7 +1138,7 @@ void lvm_register_commands(void)
* populate commands[] array with command definitions
* by parsing command-lines.in/command-lines-input.h
*/
- if (!define_commands()) {
+ if (!define_commands(name)) {
log_error("Failed to parse command definitions.");
return;
}
@@ -3158,6 +3158,7 @@ int lvm2_main(int argc, char **argv)
int ret, alias = 0;
struct custom_fds custom_fds;
struct cmd_context *cmd;
+ char *name;
if (!argv)
return -1;
@@ -3199,7 +3200,14 @@ int lvm2_main(int argc, char **argv)
cmd->argv = argv;
- lvm_register_commands();
+ if (!alias && argc == 1)
+ name = NULL;
+ else if (alias)
+ name = argv[0];
+ else
+ name = argv[1];
+
+ lvm_register_commands(name);
if (_lvm1_fallback(cmd)) {
/* Attempt to run equivalent LVM1 tool instead */
7 years, 3 months
master - commands: improve help/usage output
by David Teigland
Gitweb: http://git.fedorahosted.org/git/?p=lvm2.git;a=commitdiff;h=f46b28bdb6f8c0...
Commit: f46b28bdb6f8c0f7bae7a8b4fb4b886332831318
Parent: c868562a7968db9b0d00df9b1d0a8967a9aacaa3
Author: David Teigland <teigland(a)redhat.com>
AuthorDate: Tue Feb 14 09:49:26 2017 -0600
Committer: David Teigland <teigland(a)redhat.com>
CommitterDate: Tue Feb 14 09:52:09 2017 -0600
commands: improve help/usage output
Replace --help --help with --long-help.
Some blank lines were needed.
Add 'lvm help all' to print help for all commands.
---
tools/args.h | 7 +++-
tools/command-lines.in | 2 +-
tools/command.c | 5 ++-
tools/lvmcmdline.c | 95 ++++++++++++++++++++++++++++--------------------
4 files changed, 64 insertions(+), 45 deletions(-)
diff --git a/tools/args.h b/tools/args.h
index b33df9a..f64b126 100644
--- a/tools/args.h
+++ b/tools/args.h
@@ -244,6 +244,9 @@ arg(locktype_ARG, '\0', "locktype", locktype_VAL, 0, 0,
arg(logonly_ARG, '\0', "logonly", 0, 0, 0,
"Suppress command report and display only log report.\n")
+arg(longhelp_ARG, '\0', "longhelp", 0, 0, 0,
+ "Display long help text.\n")
+
arg(maxrecoveryrate_ARG, '\0', "maxrecoveryrate", sizekb_VAL, 0, 0,
"Sets the maximum recovery rate for a RAID LV. The rate value\n"
"is an amount of data per second for each device in the array.\n"
@@ -920,8 +923,8 @@ arg(force_ARG, 'f', "force", 0, ARG_COUNTABLE, 0,
/* Not used. */
arg(full_ARG, 'f', "full", 0, 0, 0, NULL)
-arg(help_ARG, 'h', "help", 0, ARG_COUNTABLE, 0,
- "Display help text. Repeat this option for more information.\n")
+arg(help_ARG, 'h', "help", 0, 0, 0,
+ "Display help text.\n")
arg(cache_ARG, 'H', "cache", 0, 0, 0,
"Specifies the command is handling a cache LV or cache pool.\n"
diff --git a/tools/command-lines.in b/tools/command-lines.in
index 2eddd41..b6aa1d1 100644
--- a/tools/command-lines.in
+++ b/tools/command-lines.in
@@ -187,7 +187,7 @@
# OO_ALL is included in every command automatically.
#
OO_ALL: --commandprofile String, --config String, --debug,
---driverloaded Bool, --help, --profile String, --quiet,
+--driverloaded Bool, --help, --longhelp, --profile String, --quiet,
--verbose, --version, --yes, --test
#
diff --git a/tools/command.c b/tools/command.c
index 0ff5cd7..a968bed 100644
--- a/tools/command.c
+++ b/tools/command.c
@@ -1640,7 +1640,7 @@ void print_usage(struct command *cmd)
printf(" ]");
done:
- printf("\n");
+ printf("\n\n");
return;
}
@@ -1704,7 +1704,8 @@ void print_usage_common(struct command_name *cname, struct command *cmd)
}
}
- printf(" ]\n");
+ printf(" ]");
+ printf("\n\n");
}
#ifdef MAN_PAGE_GENERATOR
diff --git a/tools/lvmcmdline.c b/tools/lvmcmdline.c
index 43278ff..494f01f 100644
--- a/tools/lvmcmdline.c
+++ b/tools/lvmcmdline.c
@@ -1384,7 +1384,7 @@ static struct command *_find_command(struct cmd_context *cmd, const char *path,
continue;
/* For help and version just return the first entry with matching name. */
- if (arg_is_set(cmd, help_ARG) || arg_is_set(cmd, help2_ARG) || arg_is_set(cmd, version_ARG))
+ if (arg_is_set(cmd, help_ARG) || arg_is_set(cmd, help2_ARG) || arg_is_set(cmd, longhelp_ARG) || arg_is_set(cmd, version_ARG))
return &commands[i];
match_required = 0; /* required parameters that match */
@@ -1661,7 +1661,40 @@ static void _short_usage(const char *name)
log_error("Run `%s --help' for more information.", name);
}
-static int _usage(const char *name, int help_count)
+static void _usage_notes(void)
+{
+ /*
+ * Excluding commonly understood syntax style like the meanings of:
+ * [ ] for optional, ... for repeatable, | for one of the following,
+ * -- for an option name, lower case strings and digits for literals.
+ */
+ log_print("Usage notes:");
+ log_print(". Variable parameters are: Number, String, PV, VG, LV, Tag.");
+ log_print(". Select indicates that a required positional parameter can");
+ log_print(" be omitted if the --select option is used.");
+ log_print(". --size Number can be replaced with --extents NumberExtents.");
+ log_print(". When --name is omitted from lvcreate, a new LV name is");
+ log_print(" generated with the \"lvol\" prefix and a unique numeric suffix.");
+ log_print(". The required VG parameter in lvcreate may be omitted when");
+ log_print(" the VG name is included in another option, e.g. --name VG/LV.");
+ log_print(". For required options listed in parentheses, e.g. (--A, --B),");
+ log_print(" any one is required, after which the others are optional.");
+ log_print(". The _new suffix indicates the VG or LV must not yet exist.");
+ log_print(". LV followed by _<type> indicates that an LV of the given type");
+ log_print(" is required. (raid represents any raid<N> type.)");
+ log_print(". Input units are always treated as base two values, regardless of");
+ log_print(" unit capitalization, e.g. 'k' and 'K' both refer to 1024.");
+ log_print(". The default input unit is specified by letter, followed by |unit");
+ log_print(" which represents other possible input units: bBsSkKmMgGtTpPeE.");
+ log_print(". Output units can be specified with the --units option, for which");
+ log_print(" lower/upper case letters refer to base 2/10 values.");
+ log_print(" formats that are recognized, e.g. for compatibility.");
+ log_print(". See man pages for short option equivalents of long option names,");
+ log_print(" and for more detailed descriptions of variable parameters.");
+ log_print(" ");
+}
+
+static int _usage(const char *name, int longhelp)
{
struct command_name *cname = find_command_name(name);
struct command *cmd;
@@ -1678,52 +1711,33 @@ static int _usage(const char *name, int help_count)
if (strcmp(_cmdline.commands[i].name, name))
continue;
- if ((_cmdline.commands[i].cmd_flags & CMD_FLAG_SECONDARY_SYNTAX) && (help_count < 3))
+ if ((_cmdline.commands[i].cmd_flags & CMD_FLAG_SECONDARY_SYNTAX) && !longhelp)
continue;
print_usage(&_cmdline.commands[i]);
cmd = &_cmdline.commands[i];
- printf("\n");
}
/* Common options are printed once for all variants of a command name. */
print_usage_common(cname, cmd);
- if (help_count > 1) {
- /*
- * Excluding commonly understood syntax style like the meanings of:
- * [ ] for optional, ... for repeatable, | for one of the following,
- * -- for an option name, lower case strings and digits for literals.
- */
- log_print("Usage notes:");
- log_print(". Variable parameters are: Number, String, PV, VG, LV, Tag.");
- log_print(". Select indicates that a required positional parameter can");
- log_print(" be omitted if the --select option is used.");
- log_print(". --size Number can be replaced with --extents NumberExtents.");
- log_print(". When --name is omitted from lvcreate, a new LV name is");
- log_print(" generated with the \"lvol\" prefix and a unique numeric suffix.");
- log_print(". The required VG parameter in lvcreate may be omitted when");
- log_print(" the VG name is included in another option, e.g. --name VG/LV.");
- log_print(". For required options listed in parentheses, e.g. (--A, --B),");
- log_print(" any one is required, after which the others are optional.");
- log_print(". The _new suffix indicates the VG or LV must not yet exist.");
- log_print(". LV followed by _<type> indicates that an LV of the given type");
- log_print(" is required. (raid represents any raid<N> type.)");
- log_print(". Input units are always treated as base two values, regardless of");
- log_print(" unit capitalization, e.g. 'k' and 'K' both refer to 1024.");
- log_print(". The default input unit is specified by letter, followed by |unit");
- log_print(" which represents other possible input units: bBsSkKmMgGtTpPeE.");
- log_print(". Output units can be specified with the --units option, for which");
- log_print(" lower/upper case letters refer to base 2/10 values.");
- log_print(". Use --help --help --help to print secondary command syntax");
- log_print(" formats that are recognized, e.g. for compatibility.");
- log_print(". See man pages for short option equivalents of long option names,");
- log_print(" and for more detailed descriptions of variable parameters.");
- }
+ if (longhelp)
+ _usage_notes();
return 1;
}
+static void _usage_all(void)
+{
+ int i;
+
+ for (i = 0; i < MAX_COMMAND_NAMES; i++) {
+ if (!command_names[i].name)
+ break;
+ _usage(command_names[i].name, 0);
+ }
+}
+
/*
* Sets up the arguments to pass to getopt_long().
*
@@ -2158,11 +2172,10 @@ static int _get_settings(struct cmd_context *cmd)
static int _process_common_commands(struct cmd_context *cmd)
{
- if (arg_is_set(cmd, help_ARG) || arg_is_set(cmd, help2_ARG)) {
- _usage(cmd->name, arg_count(cmd, help_ARG));
-
- if (arg_count(cmd, help_ARG) < 2)
- log_print("(Use --help --help for usage notes.)");
+ if (arg_is_set(cmd, help_ARG) ||
+ arg_is_set(cmd, longhelp_ARG) ||
+ arg_is_set(cmd, help2_ARG)) {
+ _usage(cmd->name, arg_is_set(cmd, longhelp_ARG));
return ECMD_PROCESSED;
}
@@ -2195,6 +2208,8 @@ int help(struct cmd_context *cmd __attribute__((unused)), int argc, char **argv)
if (!argc)
_display_help();
+ else if (argc == 1 && !strcmp(argv[0], "all"))
+ _usage_all();
else {
int i;
for (i = 0; i < argc; i++)
7 years, 3 months
master - Makefile: all_man also requires man-generator now
by Alasdair Kergon
Gitweb: http://git.fedorahosted.org/git/?p=lvm2.git;a=commitdiff;h=c868562a7968db...
Commit: c868562a7968db9b0d00df9b1d0a8967a9aacaa3
Parent: 22457ed4d97e0fdb13b15b44facf21521e8a1549
Author: Alasdair G Kergon <agk(a)redhat.com>
AuthorDate: Tue Feb 14 13:24:31 2017 +0000
Committer: Alasdair G Kergon <agk(a)redhat.com>
CommitterDate: Tue Feb 14 13:24:31 2017 +0000
Makefile: all_man also requires man-generator now
---
Makefile.in | 1 +
1 files changed, 1 insertions(+), 0 deletions(-)
diff --git a/Makefile.in b/Makefile.in
index e0a30f3..b525278 100644
--- a/Makefile.in
+++ b/Makefile.in
@@ -60,6 +60,7 @@ daemons: lib libdaemon tools
tools: lib libdaemon device-mapper
po: tools daemons
man: tools
+all_man: tools
scripts: liblvm libdm
lib.device-mapper: include.device-mapper
7 years, 3 months
master - makefiles: missing deps
by Zdenek Kabelac
Gitweb: http://git.fedorahosted.org/git/?p=lvm2.git;a=commitdiff;h=22457ed4d97e0f...
Commit: 22457ed4d97e0fdb13b15b44facf21521e8a1549
Parent: fc0e49297d6a6818b82169d1059084770c29b9d6
Author: Zdenek Kabelac <zkabelac(a)redhat.com>
AuthorDate: Tue Feb 14 10:24:25 2017 +0100
Committer: Zdenek Kabelac <zkabelac(a)redhat.com>
CommitterDate: Tue Feb 14 10:24:56 2017 +0100
makefiles: missing deps
---
Makefile.in | 1 +
tools/Makefile.in | 3 +--
2 files changed, 2 insertions(+), 2 deletions(-)
diff --git a/Makefile.in b/Makefile.in
index 52441f1..e0a30f3 100644
--- a/Makefile.in
+++ b/Makefile.in
@@ -59,6 +59,7 @@ liblvm: lib
daemons: lib libdaemon tools
tools: lib libdaemon device-mapper
po: tools daemons
+man: tools
scripts: liblvm libdm
lib.device-mapper: include.device-mapper
diff --git a/tools/Makefile.in b/tools/Makefile.in
index ed359ea..9e1ccba 100644
--- a/tools/Makefile.in
+++ b/tools/Makefile.in
@@ -175,8 +175,6 @@ liblvm2cmd.$(LIB_SUFFIX).$(LIB_VERSION): liblvm2cmd.$(LIB_SUFFIX)
$(CC) -E -P $(srcdir)/cmdnames.h 2> /dev/null | \
$(EGREP) -v '^ *(|#.*|config|devtypes|dumpconfig|formats|fullreport|help|lastlog|lvpoll|pvdata|segtypes|systemid|tags|version) *$$' > .commands
-.DELETE_ON_ERROR:
-
command-count.h: $(srcdir)/command-lines.in Makefile
set -o pipefail && \
( cat $(top_srcdir)/doc/license.txt && \
@@ -204,6 +202,7 @@ command-lines-input.h: $(srcdir)/command-lines.in Makefile
) > $@
$(SOURCES:%.c=%.d) $(SOURCES2:%.c=%.d): command-lines-input.h command-count.h cmds.h
+$(SOURCES:%.c=%.o) $(SOURCES2:%.c=%.o): command-lines-input.h command-count.h cmds.h
ifneq ("$(CFLOW_CMD)", "")
CFLOW_SOURCES = $(addprefix $(srcdir)/, $(SOURCES))
7 years, 3 months