@@ -50,12 +50,12 @@ extern int ncmds;
extern void help_init(void);
extern void quit_init(void);
-typedef int (*argsfunc_t)(int index);
+typedef int (*iterfunc_t)(int index);
typedef int (*checkfunc_t)(const cmdinfo_t *ci);
extern void add_command(const cmdinfo_t *ci);
extern void add_user_command(char *optarg);
-extern void add_args_command(argsfunc_t af);
+extern void add_command_iterator(iterfunc_t func);
extern void add_check_command(checkfunc_t cf);
extern const cmdinfo_t *find_command(const char *cmd);
@@ -90,8 +90,13 @@ init_commands(void)
cowextsize_init();
}
+/*
+ * This allows xfs_io commands specified on the command line to be run on every
+ * open file in the file table. Commands that should not be iterated across all
+ * open files need to specify CMD_FLAG_ONESHOT in their command flags.
+ */
static int
-init_args_command(
+filetable_iterator(
int index)
{
if (index >= filecount)
@@ -214,7 +219,7 @@ init(
}
init_commands();
- add_args_command(init_args_command);
+ add_command_iterator(filetable_iterator);
add_check_command(init_check_command);
}
@@ -23,7 +23,7 @@
cmdinfo_t *cmdtab;
int ncmds;
-static argsfunc_t args_func;
+static iterfunc_t iter_func;
static checkfunc_t check_func;
static int ncmdline;
static char **cmdline;
@@ -130,7 +130,7 @@ add_user_command(char *optarg)
* so we abort straight away.
*/
static int
-args_command(
+iterate_command(
const cmdinfo_t *ct,
int index)
{
@@ -138,16 +138,16 @@ args_command(
return 0;
if (ct->flags & CMD_FLAG_ONESHOT)
return -1;
- if (args_func)
- return args_func(index);
+ if (iter_func)
+ return iter_func(index);
return 0;
}
void
-add_args_command(
- argsfunc_t af)
+add_command_iterator(
+ iterfunc_t func)
{
- args_func = af;
+ iter_func = func;
}
void
@@ -171,7 +171,7 @@ command_loop(void)
ct = find_command(v[0]);
if (ct) {
j = 0;
- while (!done && (j = args_command(ct, j)))
+ while (!done && (j = iterate_command(ct, j)))
done = command(ct, c, v);
} else
fprintf(stderr, _("command \"%s\" not found\n"),
@@ -75,8 +75,13 @@ init_commands(void)
state_init();
}
+/*
+ * This function allows xfs_quota commands to iterate across all discovered
+ * quota enabled filesystems. Commands that should not iterate all filesystems
+ * should specify CMD_FLAG_ONESHOT in their command flags.
+ */
static int
-init_args_command(
+filesystem_iterator(
int index)
{
if (index >= fs_count)
@@ -189,7 +194,7 @@ init(
free(projopts);
init_commands();
- add_args_command(init_args_command);
+ add_command_iterator(filesystem_iterator);
add_check_command(init_check_command);
/*