]> git.ipfire.org Git - thirdparty/xfsprogs-dev.git/commitdiff
libxcmd: rename args_command to command_iterator
authorDave Chinner <dchinner@redhat.com>
Thu, 12 Jan 2017 20:12:41 +0000 (14:12 -0600)
committerEric Sandeen <sandeen@redhat.com>
Thu, 12 Jan 2017 20:12:41 +0000 (14:12 -0600)
It is not particularly easy to understand the function of the
args_command abstraction. it's actually a command iterator interface
that allows callers to specify the target of the command and iterate
the command multiple times over different targets. Rename and
document the abstraction to make this functionality clear.

Signed-Off-By: Dave Chinner <dchinner@redhat.com>
Reviewed-by: Christoph Hellwig <hch@lst.de>
Reviewed-by: Eric Sandeen <sandeen@redhat.com>
Signed-off-by: Eric Sandeen <sandeen@sandeen.net>
include/command.h
io/init.c
libxcmd/command.c
quota/init.c

index 58bfcaac44a01945675a3262fc56934c7b199616..637ee06e6e9aff40f092bf1fb3eebb3ce4d863c1 100644 (file)
@@ -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);
index 10ae223aff727d4e37be1b5f3c8dec7fb35358a7..a382d9baeaca1d4560a2ab23f6379cccf5509d37 100644 (file)
--- a/io/init.c
+++ b/io/init.c
@@ -91,8 +91,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)
@@ -215,7 +220,7 @@ init(
        }
 
        init_commands();
-       add_args_command(init_args_command);
+       add_command_iterator(filetable_iterator);
        add_check_command(init_check_command);
 }
 
index dce8361ce3eafd9563d20a8b1094fbd13223b000..789aeb5c5e5ab9444219f3d0f7072d093f7a18bf 100644 (file)
@@ -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"),
index 3bebbb8735f31c014a06d91266307f5c9f560ce6..193f6421fd597c2f004a14fca4480bc539234541 100644 (file)
@@ -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);
 
        /*