summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAlasdair G Kergon <agk@redhat.com>2015-07-31 17:47:03 +0100
committerAlasdair G Kergon <agk@redhat.com>2015-07-31 17:47:03 +0100
commit51f89f2fbdabc3b1800a1fd5ba4c7136ada0f9d3 (patch)
tree66a1a68d759b2ebc7fc0269162ab3df69c2a807c
parente06d188f0d9763195c9e6040ffb26b7203e39df2 (diff)
downloadlvm2-51f89f2fbdabc3b1800a1fd5ba4c7136ada0f9d3.tar.gz
dmsetup: Add subcommand parameter.
Not yet used. Allows for dmsetup stats <subcommand> dev1 dev2...
-rw-r--r--tools/dmsetup.c32
1 files changed, 16 insertions, 16 deletions
diff --git a/tools/dmsetup.c b/tools/dmsetup.c
index 2f62d70cc..10bf3c6e1 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;
}