mirror of
https://github.com/kdave/btrfs-progs
synced 2025-04-11 03:31:17 +00:00
btrfs-progs: pass cmd_struct to command callback function
This patch passes the cmd_struct to the command callback function. This has several purposes: It allows the command callback to identify which command was used to call it. It also gives us direct access to the usage associated with that command. Signed-off-by: Jeff Mahoney <jeffm@suse.com> Signed-off-by: David Sterba <dsterba@suse.com>
This commit is contained in:
parent
82d48463ea
commit
b44445131f
8
btrfs.c
8
btrfs.c
@ -148,7 +148,7 @@ static const char * const cmd_help_usage[] = {
|
||||
NULL
|
||||
};
|
||||
|
||||
static int cmd_help(int argc, char **argv)
|
||||
static int cmd_help(const struct cmd_struct *unused, int argc, char **argv)
|
||||
{
|
||||
help_command_group(&btrfs_cmd_group, argc, argv);
|
||||
return 0;
|
||||
@ -162,7 +162,7 @@ static const char * const cmd_version_usage[] = {
|
||||
NULL
|
||||
};
|
||||
|
||||
static int cmd_version(int argc, char **argv)
|
||||
static int cmd_version(const struct cmd_struct *unused, int argc, char **argv)
|
||||
{
|
||||
printf("%s\n", PACKAGE_STRING);
|
||||
return 0;
|
||||
@ -231,13 +231,13 @@ static void handle_special_globals(int shift, int argc, char **argv)
|
||||
if (has_full)
|
||||
usage_command_group(&btrfs_cmd_group, true, false);
|
||||
else
|
||||
cmd_help(argc, argv);
|
||||
cmd_execute(&cmd_struct_help, argc, argv);
|
||||
exit(0);
|
||||
}
|
||||
|
||||
for (i = 0; i < shift; i++)
|
||||
if (strcmp(argv[i], "--version") == 0) {
|
||||
cmd_version(argc, argv);
|
||||
cmd_execute(&cmd_struct_version, argc, argv);
|
||||
exit(0);
|
||||
}
|
||||
}
|
||||
|
@ -9869,7 +9869,7 @@ static const char * const cmd_check_usage[] = {
|
||||
NULL
|
||||
};
|
||||
|
||||
static int cmd_check(int argc, char **argv)
|
||||
static int cmd_check(const struct cmd_struct *cmd, int argc, char **argv)
|
||||
{
|
||||
struct cache_tree root_cache;
|
||||
struct btrfs_root *root;
|
||||
|
@ -516,7 +516,8 @@ static const char * const cmd_balance_start_usage[] = {
|
||||
NULL
|
||||
};
|
||||
|
||||
static int cmd_balance_start(int argc, char **argv)
|
||||
static int cmd_balance_start(const struct cmd_struct *cmd,
|
||||
int argc, char **argv)
|
||||
{
|
||||
struct btrfs_ioctl_balance_args args;
|
||||
struct btrfs_balance_args *ptrs[] = { &args.data, &args.sys,
|
||||
@ -682,7 +683,8 @@ static const char * const cmd_balance_pause_usage[] = {
|
||||
NULL
|
||||
};
|
||||
|
||||
static int cmd_balance_pause(int argc, char **argv)
|
||||
static int cmd_balance_pause(const struct cmd_struct *cmd,
|
||||
int argc, char **argv)
|
||||
{
|
||||
const char *path;
|
||||
int fd;
|
||||
@ -721,7 +723,8 @@ static const char * const cmd_balance_cancel_usage[] = {
|
||||
NULL
|
||||
};
|
||||
|
||||
static int cmd_balance_cancel(int argc, char **argv)
|
||||
static int cmd_balance_cancel(const struct cmd_struct *cmd,
|
||||
int argc, char **argv)
|
||||
{
|
||||
const char *path;
|
||||
int fd;
|
||||
@ -760,7 +763,8 @@ static const char * const cmd_balance_resume_usage[] = {
|
||||
NULL
|
||||
};
|
||||
|
||||
static int cmd_balance_resume(int argc, char **argv)
|
||||
static int cmd_balance_resume(const struct cmd_struct *cmd,
|
||||
int argc, char **argv)
|
||||
{
|
||||
struct btrfs_ioctl_balance_args args;
|
||||
const char *path;
|
||||
@ -828,7 +832,8 @@ static const char * const cmd_balance_status_usage[] = {
|
||||
* 1 : Successful to know status of a pending balance
|
||||
* 0 : When there is no pending balance or completed
|
||||
*/
|
||||
static int cmd_balance_status(int argc, char **argv)
|
||||
static int cmd_balance_status(const struct cmd_struct *cmd,
|
||||
int argc, char **argv)
|
||||
{
|
||||
struct btrfs_ioctl_balance_args args;
|
||||
const char *path;
|
||||
@ -907,7 +912,7 @@ out:
|
||||
}
|
||||
static DEFINE_SIMPLE_COMMAND(balance_status, "status");
|
||||
|
||||
static int cmd_balance_full(int argc, char **argv)
|
||||
static int cmd_balance_full(const struct cmd_struct *cmd, int argc, char **argv)
|
||||
{
|
||||
struct btrfs_ioctl_balance_args args;
|
||||
|
||||
@ -934,7 +939,7 @@ static const struct cmd_group balance_cmd_group = {
|
||||
}
|
||||
};
|
||||
|
||||
static int cmd_balance(int argc, char **argv)
|
||||
static int cmd_balance(const struct cmd_struct *unused, int argc, char **argv)
|
||||
{
|
||||
if (argc == 2 && strcmp("start", argv[1]) != 0) {
|
||||
/* old 'btrfs filesystem balance <path>' syntax */
|
||||
|
@ -49,7 +49,8 @@ static const char * const cmd_device_add_usage[] = {
|
||||
NULL
|
||||
};
|
||||
|
||||
static int cmd_device_add(int argc, char **argv)
|
||||
static int cmd_device_add(const struct cmd_struct *cmd,
|
||||
int argc, char **argv)
|
||||
{
|
||||
char *mntpnt;
|
||||
int i, fdmnt, ret = 0;
|
||||
@ -144,14 +145,14 @@ error_out:
|
||||
}
|
||||
static DEFINE_SIMPLE_COMMAND(device_add, "add");
|
||||
|
||||
static int _cmd_device_remove(int argc, char **argv,
|
||||
const char * const *usagestr)
|
||||
static int _cmd_device_remove(const struct cmd_struct *cmd,
|
||||
int argc, char **argv)
|
||||
{
|
||||
char *mntpnt;
|
||||
int i, fdmnt, ret = 0;
|
||||
DIR *dirstream = NULL;
|
||||
|
||||
clean_args_no_options(argc, argv, usagestr);
|
||||
clean_args_no_options(argc, argv, cmd->usagestr);
|
||||
|
||||
if (check_argc_min(argc - optind, 2))
|
||||
return 1;
|
||||
@ -241,9 +242,10 @@ static const char * const cmd_device_remove_usage[] = {
|
||||
NULL
|
||||
};
|
||||
|
||||
static int cmd_device_remove(int argc, char **argv)
|
||||
static int cmd_device_remove(const struct cmd_struct *cmd,
|
||||
int argc, char **argv)
|
||||
{
|
||||
return _cmd_device_remove(argc, argv, cmd_device_remove_usage);
|
||||
return _cmd_device_remove(cmd, argc, argv);
|
||||
}
|
||||
static DEFINE_SIMPLE_COMMAND(device_remove, "remove");
|
||||
|
||||
@ -255,9 +257,10 @@ static const char * const cmd_device_delete_usage[] = {
|
||||
NULL
|
||||
};
|
||||
|
||||
static int cmd_device_delete(int argc, char **argv)
|
||||
static int cmd_device_delete(const struct cmd_struct *cmd,
|
||||
int argc, char **argv)
|
||||
{
|
||||
return _cmd_device_remove(argc, argv, cmd_device_delete_usage);
|
||||
return _cmd_device_remove(cmd, argc, argv);
|
||||
}
|
||||
static DEFINE_COMMAND(device_delete, "delete", cmd_device_delete,
|
||||
cmd_device_delete_usage, NULL, CMD_ALIAS);
|
||||
@ -300,7 +303,7 @@ static const char * const cmd_device_scan_usage[] = {
|
||||
NULL
|
||||
};
|
||||
|
||||
static int cmd_device_scan(int argc, char **argv)
|
||||
static int cmd_device_scan(const struct cmd_struct *cmd, int argc, char **argv)
|
||||
{
|
||||
int i;
|
||||
int devstart;
|
||||
@ -400,14 +403,14 @@ static const char * const cmd_device_ready_usage[] = {
|
||||
NULL
|
||||
};
|
||||
|
||||
static int cmd_device_ready(int argc, char **argv)
|
||||
static int cmd_device_ready(const struct cmd_struct *cmd, int argc, char **argv)
|
||||
{
|
||||
struct btrfs_ioctl_vol_args args;
|
||||
int fd;
|
||||
int ret;
|
||||
char *path;
|
||||
|
||||
clean_args_no_options(argc, argv, cmd_device_ready_usage);
|
||||
clean_args_no_options(argc, argv, cmd->usagestr);
|
||||
|
||||
if (check_argc_exact(argc - optind, 1))
|
||||
return 1;
|
||||
@ -459,7 +462,7 @@ static const char * const cmd_device_stats_usage[] = {
|
||||
NULL
|
||||
};
|
||||
|
||||
static int cmd_device_stats(int argc, char **argv)
|
||||
static int cmd_device_stats(const struct cmd_struct *cmd, int argc, char **argv)
|
||||
{
|
||||
char *dev_path;
|
||||
struct btrfs_ioctl_fs_info_args fi_args;
|
||||
@ -625,7 +628,7 @@ out:
|
||||
return ret;
|
||||
}
|
||||
|
||||
static int cmd_device_usage(int argc, char **argv)
|
||||
static int cmd_device_usage(const struct cmd_struct *cmd, int argc, char **argv)
|
||||
{
|
||||
unsigned unit_mode;
|
||||
int ret = 0;
|
||||
@ -633,7 +636,7 @@ static int cmd_device_usage(int argc, char **argv)
|
||||
|
||||
unit_mode = get_unit_mode_from_arg(&argc, argv, 1);
|
||||
|
||||
clean_args_no_options(argc, argv, cmd_device_usage_usage);
|
||||
clean_args_no_options(argc, argv, cmd->usagestr);
|
||||
|
||||
if (check_argc_min(argc - optind, 1))
|
||||
return 1;
|
||||
@ -678,7 +681,7 @@ static const struct cmd_group device_cmd_group = {
|
||||
}
|
||||
};
|
||||
|
||||
static int cmd_device(int argc, char **argv)
|
||||
static int cmd_device(const struct cmd_struct *unused, int argc, char **argv)
|
||||
{
|
||||
return handle_command_group(&device_cmd_group, argc, argv);
|
||||
}
|
||||
|
@ -558,7 +558,8 @@ static const char * const cmd_filesystem_du_usage[] = {
|
||||
NULL
|
||||
};
|
||||
|
||||
static int cmd_filesystem_du(int argc, char **argv)
|
||||
static int cmd_filesystem_du(const struct cmd_struct *cmd,
|
||||
int argc, char **argv)
|
||||
{
|
||||
int ret = 0, err = 0;
|
||||
int i;
|
||||
|
@ -964,7 +964,8 @@ static const char * const cmd_filesystem_usage_usage[] = {
|
||||
NULL
|
||||
};
|
||||
|
||||
static int cmd_filesystem_usage(int argc, char **argv)
|
||||
static int cmd_filesystem_usage(const struct cmd_struct *cmd,
|
||||
int argc, char **argv)
|
||||
{
|
||||
int ret = 0;
|
||||
unsigned unit_mode;
|
||||
|
@ -120,7 +120,8 @@ static void print_df(struct btrfs_ioctl_space_args *sargs, unsigned unit_mode)
|
||||
}
|
||||
}
|
||||
|
||||
static int cmd_filesystem_df(int argc, char **argv)
|
||||
static int cmd_filesystem_df(const struct cmd_struct *cmd,
|
||||
int argc, char **argv)
|
||||
{
|
||||
struct btrfs_ioctl_space_args *sargs = NULL;
|
||||
int ret;
|
||||
@ -674,7 +675,8 @@ static const char * const cmd_filesystem_show_usage[] = {
|
||||
NULL
|
||||
};
|
||||
|
||||
static int cmd_filesystem_show(int argc, char **argv)
|
||||
static int cmd_filesystem_show(const struct cmd_struct *cmd,
|
||||
int argc, char **argv)
|
||||
{
|
||||
LIST_HEAD(all_uuids);
|
||||
struct btrfs_fs_devices *fs_devices;
|
||||
@ -833,7 +835,8 @@ static const char * const cmd_filesystem_sync_usage[] = {
|
||||
NULL
|
||||
};
|
||||
|
||||
static int cmd_filesystem_sync(int argc, char **argv)
|
||||
static int cmd_filesystem_sync(const struct cmd_struct *cmd,
|
||||
int argc, char **argv)
|
||||
{
|
||||
enum btrfs_util_error err;
|
||||
|
||||
@ -921,7 +924,8 @@ error:
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int cmd_filesystem_defrag(int argc, char **argv)
|
||||
static int cmd_filesystem_defrag(const struct cmd_struct *cmd,
|
||||
int argc, char **argv)
|
||||
{
|
||||
int fd;
|
||||
int flush = 0;
|
||||
@ -1108,7 +1112,8 @@ static const char * const cmd_filesystem_resize_usage[] = {
|
||||
NULL
|
||||
};
|
||||
|
||||
static int cmd_filesystem_resize(int argc, char **argv)
|
||||
static int cmd_filesystem_resize(const struct cmd_struct *cmd,
|
||||
int argc, char **argv)
|
||||
{
|
||||
struct btrfs_ioctl_vol_args args;
|
||||
int fd, res, len, e;
|
||||
@ -1186,7 +1191,8 @@ static const char * const cmd_filesystem_label_usage[] = {
|
||||
NULL
|
||||
};
|
||||
|
||||
static int cmd_filesystem_label(int argc, char **argv)
|
||||
static int cmd_filesystem_label(const struct cmd_struct *cmd,
|
||||
int argc, char **argv)
|
||||
{
|
||||
clean_args_no_options(argc, argv, cmd_filesystem_label_usage);
|
||||
|
||||
@ -1215,7 +1221,8 @@ static const char * const cmd_filesystem_balance_usage[] = {
|
||||
NULL
|
||||
};
|
||||
|
||||
static int cmd_filesystem_balance(int argc, char **argv)
|
||||
static int cmd_filesystem_balance(const struct cmd_struct *unused,
|
||||
int argc, char **argv)
|
||||
{
|
||||
return cmd_execute(&cmd_struct_balance, argc, argv);
|
||||
}
|
||||
@ -1247,7 +1254,8 @@ static const struct cmd_group filesystem_cmd_group = {
|
||||
}
|
||||
};
|
||||
|
||||
static int cmd_filesystem(int argc, char **argv)
|
||||
static int cmd_filesystem(const struct cmd_struct *unused,
|
||||
int argc, char **argv)
|
||||
{
|
||||
return handle_command_group(&filesystem_cmd_group, argc, argv);
|
||||
}
|
||||
|
@ -523,7 +523,8 @@ static const char * const cmd_inspect_dump_super_usage[] = {
|
||||
NULL
|
||||
};
|
||||
|
||||
static int cmd_inspect_dump_super(int argc, char **argv)
|
||||
static int cmd_inspect_dump_super(const struct cmd_struct *cmd,
|
||||
int argc, char **argv)
|
||||
{
|
||||
int all = 0;
|
||||
int full = 0;
|
||||
|
@ -284,7 +284,8 @@ next:
|
||||
return ret;
|
||||
}
|
||||
|
||||
static int cmd_inspect_dump_tree(int argc, char **argv)
|
||||
static int cmd_inspect_dump_tree(const struct cmd_struct *cmd,
|
||||
int argc, char **argv)
|
||||
{
|
||||
struct btrfs_root *root;
|
||||
struct btrfs_fs_info *info;
|
||||
|
@ -427,7 +427,8 @@ static const char * const cmd_inspect_tree_stats_usage[] = {
|
||||
NULL
|
||||
};
|
||||
|
||||
static int cmd_inspect_tree_stats(int argc, char **argv)
|
||||
static int cmd_inspect_tree_stats(const struct cmd_struct *cmd,
|
||||
int argc, char **argv)
|
||||
{
|
||||
struct btrfs_key key;
|
||||
struct btrfs_root *root;
|
||||
|
@ -87,7 +87,8 @@ static const char * const cmd_inspect_inode_resolve_usage[] = {
|
||||
NULL
|
||||
};
|
||||
|
||||
static int cmd_inspect_inode_resolve(int argc, char **argv)
|
||||
static int cmd_inspect_inode_resolve(const struct cmd_struct *cmd,
|
||||
int argc, char **argv)
|
||||
{
|
||||
int fd;
|
||||
int verbose = 0;
|
||||
@ -136,7 +137,8 @@ static const char * const cmd_inspect_logical_resolve_usage[] = {
|
||||
NULL
|
||||
};
|
||||
|
||||
static int cmd_inspect_logical_resolve(int argc, char **argv)
|
||||
static int cmd_inspect_logical_resolve(const struct cmd_struct *cmd,
|
||||
int argc, char **argv)
|
||||
{
|
||||
int ret;
|
||||
int fd;
|
||||
@ -272,7 +274,8 @@ static const char * const cmd_inspect_subvolid_resolve_usage[] = {
|
||||
NULL
|
||||
};
|
||||
|
||||
static int cmd_inspect_subvolid_resolve(int argc, char **argv)
|
||||
static int cmd_inspect_subvolid_resolve(const struct cmd_struct *cmd,
|
||||
int argc, char **argv)
|
||||
{
|
||||
int ret;
|
||||
int fd = -1;
|
||||
@ -315,7 +318,8 @@ static const char* const cmd_inspect_rootid_usage[] = {
|
||||
NULL
|
||||
};
|
||||
|
||||
static int cmd_inspect_rootid(int argc, char **argv)
|
||||
static int cmd_inspect_rootid(const struct cmd_struct *cmd,
|
||||
int argc, char **argv)
|
||||
{
|
||||
int ret;
|
||||
int fd = -1;
|
||||
@ -596,7 +600,8 @@ out:
|
||||
return ret;
|
||||
}
|
||||
|
||||
static int cmd_inspect_min_dev_size(int argc, char **argv)
|
||||
static int cmd_inspect_min_dev_size(const struct cmd_struct *cmd,
|
||||
int argc, char **argv)
|
||||
{
|
||||
int ret;
|
||||
int fd = -1;
|
||||
@ -658,7 +663,7 @@ static const struct cmd_group inspect_cmd_group = {
|
||||
}
|
||||
};
|
||||
|
||||
static int cmd_inspect(int argc, char **argv)
|
||||
static int cmd_inspect(const struct cmd_struct *unused, int argc, char **argv)
|
||||
{
|
||||
return handle_command_group(&inspect_cmd_group, argc, argv);
|
||||
}
|
||||
|
@ -340,7 +340,8 @@ static const char * const cmd_property_get_usage[] = {
|
||||
NULL
|
||||
};
|
||||
|
||||
static int cmd_property_get(int argc, char **argv)
|
||||
static int cmd_property_get(const struct cmd_struct *cmd,
|
||||
int argc, char **argv)
|
||||
{
|
||||
int ret;
|
||||
char *object = NULL;
|
||||
@ -368,7 +369,8 @@ static const char * const cmd_property_set_usage[] = {
|
||||
NULL
|
||||
};
|
||||
|
||||
static int cmd_property_set(int argc, char **argv)
|
||||
static int cmd_property_set(const struct cmd_struct *cmd,
|
||||
int argc, char **argv)
|
||||
{
|
||||
int ret;
|
||||
char *object = NULL;
|
||||
@ -394,7 +396,8 @@ static const char * const cmd_property_list_usage[] = {
|
||||
NULL
|
||||
};
|
||||
|
||||
static int cmd_property_list(int argc, char **argv)
|
||||
static int cmd_property_list(const struct cmd_struct *cmd,
|
||||
int argc, char **argv)
|
||||
{
|
||||
int ret;
|
||||
char *object = NULL;
|
||||
@ -422,7 +425,8 @@ static const struct cmd_group property_cmd_group = {
|
||||
}
|
||||
};
|
||||
|
||||
static int cmd_property(int argc, char **argv)
|
||||
static int cmd_property(const struct cmd_struct *unused,
|
||||
int argc, char **argv)
|
||||
{
|
||||
return handle_command_group(&property_cmd_group, argc, argv);
|
||||
}
|
||||
|
@ -218,7 +218,8 @@ static const char * const cmd_qgroup_assign_usage[] = {
|
||||
NULL
|
||||
};
|
||||
|
||||
static int cmd_qgroup_assign(int argc, char **argv)
|
||||
static int cmd_qgroup_assign(const struct cmd_struct *cmd,
|
||||
int argc, char **argv)
|
||||
{
|
||||
return _cmd_qgroup_assign(1, argc, argv, cmd_qgroup_assign_usage);
|
||||
}
|
||||
@ -230,7 +231,8 @@ static const char * const cmd_qgroup_remove_usage[] = {
|
||||
NULL
|
||||
};
|
||||
|
||||
static int cmd_qgroup_remove(int argc, char **argv)
|
||||
static int cmd_qgroup_remove(const struct cmd_struct *cmd,
|
||||
int argc, char **argv)
|
||||
{
|
||||
return _cmd_qgroup_assign(0, argc, argv, cmd_qgroup_remove_usage);
|
||||
}
|
||||
@ -242,7 +244,8 @@ static const char * const cmd_qgroup_create_usage[] = {
|
||||
NULL
|
||||
};
|
||||
|
||||
static int cmd_qgroup_create(int argc, char **argv)
|
||||
static int cmd_qgroup_create(const struct cmd_struct *cmd,
|
||||
int argc, char **argv)
|
||||
{
|
||||
clean_args_no_options(argc, argv, cmd_qgroup_create_usage);
|
||||
|
||||
@ -256,7 +259,8 @@ static const char * const cmd_qgroup_destroy_usage[] = {
|
||||
NULL
|
||||
};
|
||||
|
||||
static int cmd_qgroup_destroy(int argc, char **argv)
|
||||
static int cmd_qgroup_destroy(const struct cmd_struct *cmd,
|
||||
int argc, char **argv)
|
||||
{
|
||||
clean_args_no_options(argc, argv, cmd_qgroup_destroy_usage);
|
||||
|
||||
@ -284,7 +288,7 @@ static const char * const cmd_qgroup_show_usage[] = {
|
||||
NULL
|
||||
};
|
||||
|
||||
static int cmd_qgroup_show(int argc, char **argv)
|
||||
static int cmd_qgroup_show(const struct cmd_struct *cmd, int argc, char **argv)
|
||||
{
|
||||
char *path;
|
||||
int ret = 0;
|
||||
@ -418,7 +422,7 @@ static const char * const cmd_qgroup_limit_usage[] = {
|
||||
NULL
|
||||
};
|
||||
|
||||
static int cmd_qgroup_limit(int argc, char **argv)
|
||||
static int cmd_qgroup_limit(const struct cmd_struct *cmd, int argc, char **argv)
|
||||
{
|
||||
int ret = 0;
|
||||
int fd;
|
||||
@ -514,7 +518,7 @@ static const struct cmd_group qgroup_cmd_group = {
|
||||
}
|
||||
};
|
||||
|
||||
static int cmd_qgroup(int argc, char **argv)
|
||||
static int cmd_qgroup(const struct cmd_struct *unused, int argc, char **argv)
|
||||
{
|
||||
return handle_command_group(&qgroup_cmd_group, argc, argv);
|
||||
}
|
||||
|
@ -67,7 +67,7 @@ static const char * const cmd_quota_enable_usage[] = {
|
||||
NULL
|
||||
};
|
||||
|
||||
static int cmd_quota_enable(int argc, char **argv)
|
||||
static int cmd_quota_enable(const struct cmd_struct *cmd, int argc, char **argv)
|
||||
{
|
||||
int ret;
|
||||
|
||||
@ -87,7 +87,8 @@ static const char * const cmd_quota_disable_usage[] = {
|
||||
NULL
|
||||
};
|
||||
|
||||
static int cmd_quota_disable(int argc, char **argv)
|
||||
static int cmd_quota_disable(const struct cmd_struct *cmd,
|
||||
int argc, char **argv)
|
||||
{
|
||||
int ret;
|
||||
|
||||
@ -110,7 +111,7 @@ static const char * const cmd_quota_rescan_usage[] = {
|
||||
NULL
|
||||
};
|
||||
|
||||
static int cmd_quota_rescan(int argc, char **argv)
|
||||
static int cmd_quota_rescan(const struct cmd_struct *cmd, int argc, char **argv)
|
||||
{
|
||||
int ret = 0;
|
||||
int fd;
|
||||
@ -206,7 +207,7 @@ static const struct cmd_group quota_cmd_group = {
|
||||
}
|
||||
};
|
||||
|
||||
static int cmd_quota(int argc, char **argv)
|
||||
static int cmd_quota(const struct cmd_struct *unused, int argc, char **argv)
|
||||
{
|
||||
return handle_command_group("a_cmd_group, argc, argv);
|
||||
}
|
||||
|
@ -1281,7 +1281,7 @@ static const char * const cmd_receive_usage[] = {
|
||||
NULL
|
||||
};
|
||||
|
||||
static int cmd_receive(int argc, char **argv)
|
||||
static int cmd_receive(const struct cmd_struct *cmd, int argc, char **argv)
|
||||
{
|
||||
char *tomnt = NULL;
|
||||
char fromfile[PATH_MAX];
|
||||
|
@ -114,7 +114,8 @@ static const char *const cmd_replace_start_usage[] = {
|
||||
NULL
|
||||
};
|
||||
|
||||
static int cmd_replace_start(int argc, char **argv)
|
||||
static int cmd_replace_start(const struct cmd_struct *cmd,
|
||||
int argc, char **argv)
|
||||
{
|
||||
struct btrfs_ioctl_dev_replace_args start_args = {0};
|
||||
struct btrfs_ioctl_dev_replace_args status_args = {0};
|
||||
@ -330,7 +331,8 @@ static const char *const cmd_replace_status_usage[] = {
|
||||
NULL
|
||||
};
|
||||
|
||||
static int cmd_replace_status(int argc, char **argv)
|
||||
static int cmd_replace_status(const struct cmd_struct *cmd,
|
||||
int argc, char **argv)
|
||||
{
|
||||
int fd;
|
||||
int c;
|
||||
@ -499,7 +501,8 @@ static const char *const cmd_replace_cancel_usage[] = {
|
||||
NULL
|
||||
};
|
||||
|
||||
static int cmd_replace_cancel(int argc, char **argv)
|
||||
static int cmd_replace_cancel(const struct cmd_struct *cmd,
|
||||
int argc, char **argv)
|
||||
{
|
||||
struct btrfs_ioctl_dev_replace_args args = {0};
|
||||
int ret;
|
||||
@ -560,7 +563,7 @@ static const struct cmd_group replace_cmd_group = {
|
||||
}
|
||||
};
|
||||
|
||||
static int cmd_replace(int argc, char **argv)
|
||||
static int cmd_replace(const struct cmd_struct *unused, int argc, char **argv)
|
||||
{
|
||||
return handle_command_group(&replace_cmd_group, argc, argv);
|
||||
}
|
||||
|
@ -43,7 +43,8 @@ static const char * const cmd_rescue_chunk_recover_usage[] = {
|
||||
NULL
|
||||
};
|
||||
|
||||
static int cmd_rescue_chunk_recover(int argc, char *argv[])
|
||||
static int cmd_rescue_chunk_recover(const struct cmd_struct *cmd,
|
||||
int argc, char *argv[])
|
||||
{
|
||||
int ret = 0;
|
||||
char *file;
|
||||
@ -113,7 +114,8 @@ static const char * const cmd_rescue_super_recover_usage[] = {
|
||||
* 3 : Fail to Recover bad superblocks
|
||||
* 4 : Abort to recover bad superblocks
|
||||
*/
|
||||
static int cmd_rescue_super_recover(int argc, char **argv)
|
||||
static int cmd_rescue_super_recover(const struct cmd_struct *cmd,
|
||||
int argc, char **argv)
|
||||
{
|
||||
int ret;
|
||||
int verbose = 0;
|
||||
@ -162,7 +164,8 @@ static const char * const cmd_rescue_zero_log_usage[] = {
|
||||
NULL
|
||||
};
|
||||
|
||||
static int cmd_rescue_zero_log(int argc, char **argv)
|
||||
static int cmd_rescue_zero_log(const struct cmd_struct *cmd,
|
||||
int argc, char **argv)
|
||||
{
|
||||
struct btrfs_root *root;
|
||||
struct btrfs_trans_handle *trans;
|
||||
@ -217,7 +220,8 @@ static const char * const cmd_rescue_fix_device_size_usage[] = {
|
||||
NULL
|
||||
};
|
||||
|
||||
static int cmd_rescue_fix_device_size(int argc, char **argv)
|
||||
static int cmd_rescue_fix_device_size(const struct cmd_struct *cmd,
|
||||
int argc, char **argv)
|
||||
{
|
||||
struct btrfs_fs_info *fs_info;
|
||||
char *devname;
|
||||
@ -270,7 +274,7 @@ static const struct cmd_group rescue_cmd_group = {
|
||||
}
|
||||
};
|
||||
|
||||
static int cmd_rescue(int argc, char **argv)
|
||||
static int cmd_rescue(const struct cmd_struct *unused, int argc, char **argv)
|
||||
{
|
||||
return handle_command_group(&rescue_cmd_group, argc, argv);
|
||||
}
|
||||
|
@ -1423,7 +1423,7 @@ static const char * const cmd_restore_usage[] = {
|
||||
NULL
|
||||
};
|
||||
|
||||
static int cmd_restore(int argc, char **argv)
|
||||
static int cmd_restore(const struct cmd_struct *unused, int argc, char **argv)
|
||||
{
|
||||
struct btrfs_root *root;
|
||||
struct btrfs_key key;
|
||||
|
17
cmds-scrub.c
17
cmds-scrub.c
@ -1095,7 +1095,8 @@ static int is_scrub_running_in_kernel(int fd,
|
||||
static const char * const cmd_scrub_start_usage[];
|
||||
static const char * const cmd_scrub_resume_usage[];
|
||||
|
||||
static int scrub_start(int argc, char **argv, int resume)
|
||||
static int scrub_start(const struct cmd_struct *cmd, int argc, char **argv,
|
||||
bool resume)
|
||||
{
|
||||
int fdmnt;
|
||||
int prg_fd = -1;
|
||||
@ -1583,9 +1584,9 @@ static const char * const cmd_scrub_start_usage[] = {
|
||||
NULL
|
||||
};
|
||||
|
||||
static int cmd_scrub_start(int argc, char **argv)
|
||||
static int cmd_scrub_start(const struct cmd_struct *cmd, int argc, char **argv)
|
||||
{
|
||||
return scrub_start(argc, argv, 0);
|
||||
return scrub_start(cmd, argc, argv, false);
|
||||
}
|
||||
static DEFINE_SIMPLE_COMMAND(scrub_start, "start");
|
||||
|
||||
@ -1595,7 +1596,7 @@ static const char * const cmd_scrub_cancel_usage[] = {
|
||||
NULL
|
||||
};
|
||||
|
||||
static int cmd_scrub_cancel(int argc, char **argv)
|
||||
static int cmd_scrub_cancel(const struct cmd_struct *cmd, int argc, char **argv)
|
||||
{
|
||||
char *path;
|
||||
int ret;
|
||||
@ -1650,9 +1651,9 @@ static const char * const cmd_scrub_resume_usage[] = {
|
||||
NULL
|
||||
};
|
||||
|
||||
static int cmd_scrub_resume(int argc, char **argv)
|
||||
static int cmd_scrub_resume(const struct cmd_struct *cmd, int argc, char **argv)
|
||||
{
|
||||
return scrub_start(argc, argv, 1);
|
||||
return scrub_start(cmd, argc, argv, true);
|
||||
}
|
||||
static DEFINE_SIMPLE_COMMAND(scrub_resume, "resume");
|
||||
|
||||
@ -1665,7 +1666,7 @@ static const char * const cmd_scrub_status_usage[] = {
|
||||
NULL
|
||||
};
|
||||
|
||||
static int cmd_scrub_status(int argc, char **argv)
|
||||
static int cmd_scrub_status(const struct cmd_struct *cmd, int argc, char **argv)
|
||||
{
|
||||
char *path;
|
||||
struct btrfs_ioctl_fs_info_args fi_args;
|
||||
@ -1811,7 +1812,7 @@ static const struct cmd_group scrub_cmd_group = {
|
||||
}
|
||||
};
|
||||
|
||||
static int cmd_scrub(int argc, char **argv)
|
||||
static int cmd_scrub(const struct cmd_struct *unused, int argc, char **argv)
|
||||
{
|
||||
return handle_command_group(&scrub_cmd_group, argc, argv);
|
||||
}
|
||||
|
@ -523,7 +523,7 @@ static const char * const cmd_send_usage[] = {
|
||||
NULL
|
||||
};
|
||||
|
||||
static int cmd_send(int argc, char **argv)
|
||||
static int cmd_send(const struct cmd_struct *cmd, int argc, char **argv)
|
||||
{
|
||||
char *subvol = NULL;
|
||||
int ret;
|
||||
|
@ -90,7 +90,8 @@ static const char * const cmd_subvol_create_usage[] = {
|
||||
NULL
|
||||
};
|
||||
|
||||
static int cmd_subvol_create(int argc, char **argv)
|
||||
static int cmd_subvol_create(const struct cmd_struct *cmd,
|
||||
int argc, char **argv)
|
||||
{
|
||||
int retval, res, len;
|
||||
int fddst = -1;
|
||||
@ -235,7 +236,8 @@ static const char * const cmd_subvol_delete_usage[] = {
|
||||
NULL
|
||||
};
|
||||
|
||||
static int cmd_subvol_delete(int argc, char **argv)
|
||||
static int cmd_subvol_delete(const struct cmd_struct *cmd,
|
||||
int argc, char **argv)
|
||||
{
|
||||
int res, ret = 0;
|
||||
int cnt;
|
||||
@ -456,7 +458,7 @@ static const char * const cmd_subvol_list_usage[] = {
|
||||
NULL,
|
||||
};
|
||||
|
||||
static int cmd_subvol_list(int argc, char **argv)
|
||||
static int cmd_subvol_list(const struct cmd_struct *cmd, int argc, char **argv)
|
||||
{
|
||||
struct btrfs_list_filter_set *filter_set;
|
||||
struct btrfs_list_comparer_set *comparer_set;
|
||||
@ -627,7 +629,8 @@ static const char * const cmd_subvol_snapshot_usage[] = {
|
||||
NULL
|
||||
};
|
||||
|
||||
static int cmd_subvol_snapshot(int argc, char **argv)
|
||||
static int cmd_subvol_snapshot(const struct cmd_struct *cmd,
|
||||
int argc, char **argv)
|
||||
{
|
||||
char *subvol, *dst;
|
||||
int res, retval;
|
||||
@ -778,7 +781,8 @@ static const char * const cmd_subvol_get_default_usage[] = {
|
||||
NULL
|
||||
};
|
||||
|
||||
static int cmd_subvol_get_default(int argc, char **argv)
|
||||
static int cmd_subvol_get_default(const struct cmd_struct *cmd,
|
||||
int argc, char **argv)
|
||||
{
|
||||
int fd = -1;
|
||||
int ret = 1;
|
||||
@ -843,7 +847,8 @@ static const char * const cmd_subvol_set_default_usage[] = {
|
||||
NULL
|
||||
};
|
||||
|
||||
static int cmd_subvol_set_default(int argc, char **argv)
|
||||
static int cmd_subvol_set_default(const struct cmd_struct *cmd,
|
||||
int argc, char **argv)
|
||||
{
|
||||
u64 objectid;
|
||||
char *path;
|
||||
@ -880,7 +885,8 @@ static const char * const cmd_subvol_find_new_usage[] = {
|
||||
NULL
|
||||
};
|
||||
|
||||
static int cmd_subvol_find_new(int argc, char **argv)
|
||||
static int cmd_subvol_find_new(const struct cmd_struct *cmd,
|
||||
int argc, char **argv)
|
||||
{
|
||||
int fd;
|
||||
int ret;
|
||||
@ -932,7 +938,7 @@ static const char * const cmd_subvol_show_usage[] = {
|
||||
NULL
|
||||
};
|
||||
|
||||
static int cmd_subvol_show(int argc, char **argv)
|
||||
static int cmd_subvol_show(const struct cmd_struct *cmd, int argc, char **argv)
|
||||
{
|
||||
char tstr[256];
|
||||
char uuidparse[BTRFS_UUID_UNPARSED_SIZE];
|
||||
@ -1188,7 +1194,7 @@ static const char * const cmd_subvol_sync_usage[] = {
|
||||
NULL
|
||||
};
|
||||
|
||||
static int cmd_subvol_sync(int argc, char **argv)
|
||||
static int cmd_subvol_sync(const struct cmd_struct *cmd, int argc, char **argv)
|
||||
{
|
||||
int fd = -1;
|
||||
int ret = 1;
|
||||
@ -1299,7 +1305,8 @@ static const struct cmd_group subvolume_cmd_group = {
|
||||
}
|
||||
};
|
||||
|
||||
static int cmd_subvolume(int argc, char **argv)
|
||||
static int cmd_subvolume(const struct cmd_struct *unused,
|
||||
int argc, char **argv)
|
||||
{
|
||||
return handle_command_group(&subvolume_cmd_group, argc, argv);
|
||||
}
|
||||
|
@ -24,7 +24,7 @@ enum {
|
||||
|
||||
struct cmd_struct {
|
||||
const char *token;
|
||||
int (*fn)(int, char **);
|
||||
int (*fn)(const struct cmd_struct *cmd, int argc, char **argv);
|
||||
|
||||
/*
|
||||
* Usage strings
|
||||
@ -110,7 +110,7 @@ struct cmd_group {
|
||||
static inline int cmd_execute(const struct cmd_struct *cmd,
|
||||
int argc, char **argv)
|
||||
{
|
||||
return cmd->fn(argc, argv);
|
||||
return cmd->fn(cmd, argc, argv);
|
||||
}
|
||||
|
||||
int handle_command_group(const struct cmd_group *grp, int argc,
|
||||
|
Loading…
Reference in New Issue
Block a user