summaryrefslogtreecommitdiffstats
path: root/tools/lvm.c
diff options
context:
space:
mode:
authorAlasdair Kergon <agk@redhat.com>2002-01-10 14:46:50 +0000
committerAlasdair Kergon <agk@redhat.com>2002-01-10 14:46:50 +0000
commitdad43063f8c65b299369514eec413fb273f7ed93 (patch)
treed0d2fb980e5f29f99b01fa93d28c6487b87bdaea /tools/lvm.c
parent88cc3edf2e3d1f0efe3495fecd95f00d98c47d32 (diff)
downloadlvm2-dad43063f8c65b299369514eec413fb273f7ed93.tar.gz
lvm2-dad43063f8c65b299369514eec413fb273f7ed93.tar.xz
lvm2-dad43063f8c65b299369514eec413fb273f7ed93.zip
Allow for multiple spellings / backwards compatibility of renamed
command line options. vgchange --resizeable y pvchange --allocatable y But --allocation is still allowed for both (as LVM1) and --resizable is OK.
Diffstat (limited to 'tools/lvm.c')
-rw-r--r--tools/lvm.c43
1 files changed, 35 insertions, 8 deletions
diff --git a/tools/lvm.c b/tools/lvm.c
index cd9655b4..2559ad8d 100644
--- a/tools/lvm.c
+++ b/tools/lvm.c
@@ -502,10 +502,33 @@ static struct arg *find_arg(struct command *com, int opt)
return 0;
}
-static int process_common_commands(struct command *com)
+static int merge_synonym(int oldarg, int newarg)
{
- int l;
+ struct arg *old, *new;
+
+ if (arg_count(oldarg) && arg_count(newarg)) {
+ log_error("%s and %s are synonyms. Please only supply one.",
+ the_args[oldarg].long_arg,
+ the_args[newarg].long_arg);
+ return 0;
+ }
+
+ if (!arg_count(oldarg))
+ return 1;
+
+ old = the_args + oldarg;
+ new = the_args + newarg;
+
+ new->count = old->count;
+ new->value = old->value;
+ new->i_value = old->i_value;
+ new->sign = old->sign;
+ return 1;
+}
+
+static int process_common_commands(struct command *com)
+{
_current_settings = _default_settings;
if (arg_count(suspend_ARG))
@@ -537,12 +560,16 @@ static int process_common_commands(struct command *com)
return ECMD_PROCESSED;
}
- /* Set autobackup if command takes this option */
- for (l = 0; l < com->num_args; l++)
- if (arg_count(autobackup_ARG)) {
- _current_settings.archive = 1;
- _current_settings.backup = 1;
- }
+ if (arg_count(autobackup_ARG)) {
+ _current_settings.archive = 1;
+ _current_settings.backup = 1;
+ }
+
+ /* Handle synonyms */
+ if (!merge_synonym(resizable_ARG, resizeable_ARG) ||
+ !merge_synonym(allocation_ARG, allocatable_ARG) ||
+ !merge_synonym(allocation_ARG, resizeable_ARG))
+ return ECMD_FAILED;
/* Zero indicates it's OK to continue processing this command */
return 0;