diff options
author | Alasdair G Kergon <agk@redhat.com> | 2015-07-31 16:13:45 +0100 |
---|---|---|
committer | Alasdair G Kergon <agk@redhat.com> | 2015-07-31 16:13:45 +0100 |
commit | 027fe112ecb75e46c671658e233ff353523e9ec3 (patch) | |
tree | a3c8236965a8432b51eb0d8a6b5568dad9aede1c | |
parent | f54198eed62f915df6fdb7c09a186160b5bb3954 (diff) | |
download | lvm2-027fe112ecb75e46c671658e233ff353523e9ec3.tar.gz |
dmsetup: Rename _commands to _dmsetup_commands.
We'll need to accommodate sub-commands for dmstats.
-rw-r--r-- | tools/dmsetup.c | 26 |
1 files changed, 16 insertions, 10 deletions
diff --git a/tools/dmsetup.c b/tools/dmsetup.c index 7a26db158..64812886a 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); |