Whamcloud - gitweb
LU-5170 utils: Add support for --list-commands option 02/24902/4
authorSteve Guminski <stephenx.guminski@intel.com>
Fri, 13 Jan 2017 15:43:35 +0000 (10:43 -0500)
committerOleg Drokin <oleg.drokin@intel.com>
Wed, 15 Feb 2017 01:03:22 +0000 (01:03 +0000)
A --list-commands option has been added to lfs, lctl, lnetctl and
lst to output a list of the commands supported by each utility. The
commands are printed in a multi-column format to produce more compact
output that is easier to read.  The appropriate man pages have been
updated to include the new options.

The obsolete ACL and join commands have been removed from lfs.

Signed-off-by: Steve Guminski <stephenx.guminski@intel.com>
Change-Id: I3715049539c76e0cd03accfccfbf7eda6f4bf2ff
Reviewed-on: https://review.whamcloud.com/24902
Tested-by: Jenkins
Tested-by: Maloo <hpdd-maloo@intel.com>
Reviewed-by: Andreas Dilger <andreas.dilger@intel.com>
Reviewed-by: Lai Siyao <lai.siyao@intel.com>
12 files changed:
libcfs/include/libcfs/util/parser.h
libcfs/libcfs/util/parser.c
lnet/utils/lnetctl.c
lnet/utils/lst.c
lustre/doc/lctl.8
lustre/doc/lfs.1
lustre/doc/lnetctl.8
lustre/doc/lst.8
lustre/include/lustre/lustre_idl.h
lustre/include/lustre/lustreapi.h
lustre/utils/lctl.c
lustre/utils/lfs.c

index 77dae1d..2fb2db7 100644 (file)
@@ -77,6 +77,9 @@ void Parser_printhelp(char *);                /* Detailed help routine */
 void Parser_exit(int, char **);                /* Shuts down command parser */
 int Parser_execarg(int argc, char **argv, command_t cmds[]);
 int execute_line(char * line);
 void Parser_exit(int, char **);                /* Shuts down command parser */
 int Parser_execarg(int argc, char **argv, command_t cmds[]);
 int execute_line(char * line);
+int Parser_list_commands(const command_t *cmdlist, char *buffer,
+                        size_t buf_size, const char *parent_cmd,
+                        int col_start, int col_num);
 
 /* Converts a string to an integer */
 int Parser_int(char *, int *);
 
 /* Converts a string to an integer */
 int Parser_int(char *, int *);
index ae5e082..3aa97a1 100644 (file)
@@ -53,8 +53,7 @@ static char *skipwhitespace(char *s);
 static char *skiptowhitespace(char *s);
 static command_t *find_cmd(char *name, command_t cmds[], char **next);
 static int process(char *s, char **next, command_t *lookup, command_t **result,
 static char *skiptowhitespace(char *s);
 static command_t *find_cmd(char *name, command_t cmds[], char **next);
 static int process(char *s, char **next, command_t *lookup, command_t **result,
-                   char **prev);
-static void print_commands(char *str, command_t *table);
+                  char **prev);
 
 static char * skipwhitespace(char * s)
 {
 
 static char * skipwhitespace(char * s)
 {
@@ -109,21 +108,21 @@ void Parser_ignore_errors(int ignore)
 
 int Parser_execarg(int argc, char **argv, command_t cmds[])
 {
 
 int Parser_execarg(int argc, char **argv, command_t cmds[])
 {
-        command_t *cmd;
+       command_t *cmd;
 
 
-        cmd = Parser_findargcmd(argv[0], cmds);
-        if ( cmd ) {
-                int rc = (cmd->pc_func)(argc, argv);
-                if (rc == CMD_HELP)
-                        fprintf(stderr, "%s\n", cmd->pc_help);
-                return rc;
-        } else {
+       cmd = Parser_findargcmd(argv[0], cmds);
+       if (cmd != NULL && cmd->pc_func != NULL) {
+               int rc = (cmd->pc_func)(argc, argv);
+               if (rc == CMD_HELP)
+                       fprintf(stderr, "%s\n", cmd->pc_help);
+               return rc;
+       } else {
                printf("Try interactive use without arguments or use one of:\n");
                printf("Try interactive use without arguments or use one of:\n");
-                for (cmd = cmds; cmd->pc_name; cmd++)
-                        printf("\"%s\"\n", cmd->pc_name);
-                printf("as argument.\n");
-        }
-        return -1;
+               for (cmd = cmds; cmd->pc_name; cmd++)
+                       printf("\"%s\"\n", cmd->pc_name);
+               printf("as argument.\n");
+       }
+       return -1;
 }
 
 /* returns the command_t * (NULL if not found) corresponding to a
 }
 
 /* returns the command_t * (NULL if not found) corresponding to a
@@ -192,17 +191,17 @@ static int process(char *s, char ** next, command_t *lookup,
         }
 
 got_it:
         }
 
 got_it:
-        /* found a unique command: component or full? */
-        if ( (*result)->pc_func ) {
-                return CMD_COMPLETE;
-        } else {
-                if ( *next == '\0' ) {
-                        return CMD_INCOMPLETE;
-                } else {
-                        return process(*next, next, (*result)->pc_sub_cmd,
-                                       result, prev);
-                }
-        }
+       /* found a unique command: component or full? */
+       if ((*result)->pc_func != NULL) {
+               return CMD_COMPLETE;
+       } else {
+               if (*next == '\0') {
+                       return CMD_INCOMPLETE;
+               } else {
+                       return process(*next, next, (*result)->pc_sub_cmd,
+                                      result, prev);
+               }
+       }
 }
 
 #ifdef HAVE_LIBREADLINE
 }
 
 #ifdef HAVE_LIBREADLINE
@@ -451,10 +450,12 @@ int Parser_int(char *s, int *val)
 
 void Parser_qhelp(int argc, char *argv[]) {
 
 
 void Parser_qhelp(int argc, char *argv[]) {
 
-        printf("Available commands are:\n");
+       printf("usage: %s [COMMAND] [OPTIONS]... [ARGS]\n",
+               program_invocation_short_name);
+       printf("Without any parameters, interactive mode is invoked\n");
 
 
-        print_commands(NULL, top_level);
-        printf("For more help type: help command-name\n");
+       printf("Try '%s help <COMMAND>' or '%s --list-commands' for more information\n",
+               program_invocation_short_name, program_invocation_short_name);
 }
 
 int Parser_help(int argc, char **argv)
 }
 
 int Parser_help(int argc, char **argv)
@@ -524,24 +525,78 @@ void Parser_printhelp(char *cmd)
 /*************************************************************************
  * COMMANDS                                                              *
  *************************************************************************/
 /*************************************************************************
  * COMMANDS                                                              *
  *************************************************************************/
-static void print_commands(char * str, command_t * table) {
-        command_t * cmds;
-        char         buf[80];
-
-        for (cmds = table; cmds->pc_name; cmds++) {
-                if (cmds->pc_func) {
-                        if (str) printf("\t%s %s\n", str, cmds->pc_name);
-                        else printf("\t%s\n", cmds->pc_name);
-                }
-                if (cmds->pc_sub_cmd) {
-                        if (str) {
-                                sprintf(buf, "%s %s", str, cmds->pc_name);
-                                print_commands(buf, cmds->pc_sub_cmd);
-                        } else {
-                                print_commands(cmds->pc_name, cmds->pc_sub_cmd);
-                        }
-                }
-        }
+
+/**
+ * Parser_list_commands() - Output a list of the supported commands.
+ * @cmdlist:     Array of structures describing the commands.
+ * @buffer:      String buffer used to temporarily store the output text.
+ * @buf_size:    Length of the string buffer.
+ * @parent_cmd:          When called recursively, contains the name of the parent cmd.
+ * @col_start:   Column where printing should begin.
+ * @col_num:     The number of commands printed in a single row.
+ *
+ * The commands and subcommands supported by the utility are printed, arranged
+ * into several columns for readability.  If a command supports subcommands, the
+ * function is called recursively, and the name of the parent command is
+ * supplied so that it can be prepended to the names of the subcommands.
+ *
+ * Return: The number of items that were printed.
+ */
+int Parser_list_commands(const command_t *cmdlist, char *buffer,
+                        size_t buf_size, const char *parent_cmd,
+                        int col_start, int col_num)
+{
+       int col = col_start;
+       int char_max;
+       int len;
+       char fmt[6];
+       int count = 0;
+       int rc;
+
+       if (col_start >= col_num)
+               return 0;
+
+       char_max = (buf_size - 1) / col_num; /* Reserve 1 char for NUL */
+
+       for (; cmdlist->pc_name != NULL; cmdlist++) {
+               if (cmdlist->pc_func == NULL && cmdlist->pc_sub_cmd == NULL)
+                       break;
+               count++;
+               if (parent_cmd != NULL)
+                       len = snprintf(&buffer[col * char_max],
+                                      char_max + 1, "%s %s", parent_cmd,
+                                      cmdlist->pc_name);
+               else
+                       len = snprintf(&buffer[col * char_max],
+                                      char_max + 1, "%s", cmdlist->pc_name);
+
+               /* Add trailing spaces to pad the entry to the column size */
+               if (len < char_max) {
+                       snprintf(fmt, 6, "%%-%2ds", char_max - len);
+                       snprintf(&buffer[col * char_max] + len,
+                                char_max - len + 1, fmt, " ");
+               } else {
+                       buffer[(col + 1) * char_max - 1] = ' ';
+               }
+
+               col++;
+               if (col >= col_num) {
+                       fprintf(stdout, "%s\n", buffer);
+                       col = 0;
+                       buffer[0] = '\0';
+               }
+
+               if (cmdlist->pc_sub_cmd != NULL) {
+                       rc = Parser_list_commands(cmdlist->pc_sub_cmd, buffer,
+                                                buf_size, cmdlist->pc_name,
+                                                col, col_num);
+                       col = (col + rc) % col_num;
+                       count += rc;
+               }
+       }
+       if (parent_cmd == NULL && col != 0)
+               fprintf(stdout, "%s\n", buffer);
+       return count;
 }
 
 char *Parser_getstr(const char *prompt, const char *deft, char *res,
 }
 
 char *Parser_getstr(const char *prompt, const char *deft, char *res,
index 5444327..56e1033 100644 (file)
@@ -58,6 +58,7 @@ static int jt_set_numa(int argc, char **argv);
 static int jt_add_peer_nid(int argc, char **argv);
 static int jt_del_peer_nid(int argc, char **argv);
 /*static int jt_show_peer(int argc, char **argv);*/
 static int jt_add_peer_nid(int argc, char **argv);
 static int jt_del_peer_nid(int argc, char **argv);
 /*static int jt_show_peer(int argc, char **argv);*/
+static int lnetctl_list_commands(int argc, char **argv);
 
 command_t lnet_cmds[] = {
        {"configure", jt_config_lnet, 0, "configure lnet\n"
 
 command_t lnet_cmds[] = {
        {"configure", jt_config_lnet, 0, "configure lnet\n"
@@ -1250,9 +1251,19 @@ command_t list[] = {
        {"help", Parser_help, 0, "help"},
        {"exit", Parser_quit, 0, "quit"},
        {"quit", Parser_quit, 0, "quit"},
        {"help", Parser_help, 0, "help"},
        {"exit", Parser_quit, 0, "quit"},
        {"quit", Parser_quit, 0, "quit"},
+       {"--list-commands", lnetctl_list_commands, 0, "list commands"},
        { 0, 0, 0, NULL }
 };
 
        { 0, 0, 0, NULL }
 };
 
+static int lnetctl_list_commands(int argc, char **argv)
+{
+       char buffer[81] = ""; /* 80 printable chars + terminating NUL */
+
+       Parser_list_commands(list, buffer, sizeof(buffer), NULL, 0, 4);
+
+       return 0;
+}
+
 int main(int argc, char **argv)
 {
        int rc = 0;
 int main(int argc, char **argv)
 {
        int rc = 0;
index 4a71575..78359fe 100644 (file)
@@ -56,6 +56,7 @@
 struct lst_sid LST_INVALID_SID = { .ses_nid = LNET_NID_ANY, .ses_stamp = -1 };
 static struct lst_sid session_id;
 static int                 session_key;
 struct lst_sid LST_INVALID_SID = { .ses_nid = LNET_NID_ANY, .ses_stamp = -1 };
 static struct lst_sid session_id;
 static int                 session_key;
+static int lst_list_commands(int argc, char **argv);
 
 /* All nodes running 2.6.50 or later understand feature LST_FEAT_BULK_LEN */
 static unsigned                session_features = LST_FEATS_MASK;
 
 /* All nodes running 2.6.50 or later understand feature LST_FEAT_BULK_LEN */
 static unsigned                session_features = LST_FEATS_MASK;
@@ -3277,6 +3278,7 @@ static command_t lst_cmdlist[] = {
          "Usage: lst add_test [--batch BATCH] [--loop #] [--concurrency #] "
          " [--distribute #:#] [--from GROUP] [--to GROUP] TEST..."                      },
         {"help",                Parser_help,            0,     "help"                   },
          "Usage: lst add_test [--batch BATCH] [--loop #] [--concurrency #] "
          " [--distribute #:#] [--from GROUP] [--to GROUP] TEST..."                      },
         {"help",                Parser_help,            0,     "help"                   },
+       {"--list-commands",     lst_list_commands,      0,     "list commands"          },
         {0,                     0,                      0,      NULL                    }
 };
 
         {0,                     0,                      0,      NULL                    }
 };
 
@@ -3310,6 +3312,15 @@ lst_initialize(void)
         return 0;
 }
 
         return 0;
 }
 
+static int lst_list_commands(int argc, char **argv)
+{
+       char buffer[81] = ""; /* 80 printable chars + terminating NUL */
+
+       Parser_list_commands(lst_cmdlist, buffer, sizeof(buffer), NULL, 0, 4);
+
+       return 0;
+}
+
 int
 main(int argc, char **argv)
 {
 int
 main(int argc, char **argv)
 {
index 0ade6ff..f29cce9 100644 (file)
@@ -1,4 +1,4 @@
-.TH lctl 1 "2016 Sep 8" Lustre "configuration utilities"
+.TH lctl 8 "2017 Jan 12" Lustre "configuration utilities"
 .SH NAME
 lctl \- Low level Lustre filesystem configuration utility
 .SH SYNOPSIS
 .SH NAME
 lctl \- Low level Lustre filesystem configuration utility
 .SH SYNOPSIS
@@ -7,6 +7,10 @@ lctl \- Low level Lustre filesystem configuration utility
 .br
 .B lctl --device <devno> <command [args]>
 .br
 .br
 .B lctl --device <devno> <command [args]>
 .br
+.B lctl --version
+.br
+.B lctl --list-commands
+.br
 .SH DESCRIPTION
 .B lctl
 is used to directly control Lustre via an ioctl interface, allowing
 .SH DESCRIPTION
 .B lctl
 is used to directly control Lustre via an ioctl interface, allowing
@@ -26,7 +30,7 @@ can be invoked in interactive mode by issuing lctl command. After that, commands
 .BR quit .
 
 To get a complete listing of available commands, type
 .BR quit .
 
 To get a complete listing of available commands, type
-.B help
+.B --list-commands
 at the lctl prompt.  To get basic help on the meaning and syntax of a
 command, type
 .B help
 at the lctl prompt.  To get basic help on the meaning and syntax of a
 command, type
 .B help
@@ -419,6 +423,9 @@ Output the build version of the Lustre kernel modules
 .B --version
 Output the build version of the lctl utility
 .TP
 .B --version
 Output the build version of the lctl utility
 .TP
+.B --list-commands
+Output a list of the commands supported by the lctl utility
+.TP
 .B help
 Provides brief help on the various arguments
 .TP
 .B help
 Provides brief help on the various arguments
 .TP
index ba5d462..ba93482 100644 (file)
@@ -1,4 +1,4 @@
-.TH lfs 1 "2009 Jan 29" Lustre "user utilities"
+.TH lfs 1 "2017 Jan 12" Lustre "user utilities"
 .SH NAME
 lfs \- Lustre utility to create a file with specific striping pattern, find the striping pattern of existing files, do certain quota operations, and manage distributed namespace options for directories
 .SH SYNOPSIS
 .SH NAME
 lfs \- Lustre utility to create a file with specific striping pattern, find the striping pattern of existing files, do certain quota operations, and manage distributed namespace options for directories
 .SH SYNOPSIS
@@ -104,6 +104,8 @@ lfs \- Lustre utility to create a file with specific striping pattern, find the
 .br
 .B lfs --version
 .br
 .br
 .B lfs --version
 .br
+.B lfs --list-commands
+.br
 .B lfs help
 .SH DESCRIPTION
 .B lfs
 .B lfs help
 .SH DESCRIPTION
 .B lfs
@@ -342,6 +344,9 @@ See lfs-migrate(1).
 .B --version
 Output the build version of the lfs utility. Use "lctl lustre_build_version" to get the version of the Lustre kernel modules
 .TP
 .B --version
 Output the build version of the lfs utility. Use "lctl lustre_build_version" to get the version of the Lustre kernel modules
 .TP
+.B --list-commands
+Output a list of the commands supported by the lfs utility
+.TP
 .B help
 Provides brief help on the various arguments
 .TP
 .B help
 Provides brief help on the various arguments
 .TP
index 00e8849..a1165da 100644 (file)
@@ -1,12 +1,15 @@
 .
 .
-.TH lnetctl 1 "2014 Sep 12" Lustre "configuration utilities"
+.TH lnetctl 8 "2017 Jan 12" Lustre "configuration utilities"
 .
 .SH "SYNOPSIS"
 \fBlnetctl\fR
 .
 .br
 .
 .SH "SYNOPSIS"
 \fBlnetctl\fR
 .
 .br
+.B lnetctl --list-commands
+.br
 \fBlnetctl\fR \fB<cmd> <subcmd> [optional parameters]\fR
 .
 \fBlnetctl\fR \fB<cmd> <subcmd> [optional parameters]\fR
 .
+.br
 .SH "DESCRIPTION"
 \fBlnetctl\fR is used to configure LNet parameters allowing various configuration
 and debugging features to be accessed\.
 .SH "DESCRIPTION"
 \fBlnetctl\fR is used to configure LNet parameters allowing various configuration
 and debugging features to be accessed\.
@@ -16,8 +19,9 @@ and debugging features to be accessed\.
 After that, commands are issued as below\.
 .
 .P
 After that, commands are issued as below\.
 .
 .P
-To get a complete listing of available commands, type \fBhelp\fR at the
-lnetctl prompt\. To get basic help on the meaning and syntax of a command
+To get a complete listing of available commands, type
+.B --list-commands
+at the lnetctl prompt\. To get basic help on the meaning and syntax of a command
 type \fB<command>\fR \-\-help\.
 .
 .P
 type \fB<command>\fR \-\-help\.
 .
 .P
@@ -326,6 +330,37 @@ Show LNET statistics
 .br
 
 .
 .br
 
 .
+.SS "Showing Peer Credits"
+.
+.TP
+\fBlnetctl peer_credits\fR
+Show details on configured peer credits
+.
+.br
+\-> Peer nid
+.
+.br
+\-> State
+.
+.br
+\-> Reference count on the peer
+.
+.br
+\-> Maximum transmit credits
+.
+.br
+\-> Available transmit credits
+.
+.br
+\-> Available router credits
+.
+.br
+\-> Minimum router credits\.
+.
+.SH "OPTIONS"
+.TP
+.B --list-commands
+Output a list of the commands supported by the lnetctl utility
 .SH "EXAMPLES"
 .
 .SS "Initializing LNet after load"
 .SH "EXAMPLES"
 .
 .SS "Initializing LNet after load"
index 2d58444..eda9eed 100644 (file)
@@ -1,8 +1,10 @@
-.TH lst 1 "Jul 7, 2008" Lustre "utilities"
+.TH lst 8 "2017 Jan 12" Lustre "configuration utilities"
 .SH NAME
 lst \- Start the Lustre LNET Self-test
 .SH SYNOPSIS
 .B "lst"
 .SH NAME
 lst \- Start the Lustre LNET Self-test
 .SH SYNOPSIS
 .B "lst"
+.br
+.B "lst --list-commands"
 .SH DESCRIPTION
 LNET self-test helps site administrators confirm that Lustre
 Networking (LNET) has been properly installed and configured.
 .SH DESCRIPTION
 LNET self-test helps site administrators confirm that Lustre
 Networking (LNET) has been properly installed and configured.
@@ -26,6 +28,10 @@ These individual point-to-point tests are instantiated according to the
 test type, source group, target group and distribution specified when the
 test is added to the test batch.
 .LP
 test type, source group, target group and distribution specified when the
 test is added to the test batch.
 .LP
+.SH OPTIONS
+.TP
+.B --list-commands
+Output a list of the commands supported by the lst utility
 .SH MODULES
 To run LNET self-test, load these modules: libcfs, lnet, lnet_selftest
 and any one of the klnds (i.e, ksocklnd, ko2iblnd...).
 .SH MODULES
 To run LNET self-test, load these modules: libcfs, lnet, lnet_selftest
 and any one of the klnds (i.e, ksocklnd, ko2iblnd...).
index 65edd58..101d6b9 100644 (file)
@@ -1121,11 +1121,6 @@ lov_mds_md_max_stripe_count(size_t buf_size, __u32 lmm_magic)
                                                       * client holds the lock */
 #define OBD_MD_FLOBJCOUNT    (0x0000400000000000ULL) /* for multiple destroy */
 
                                                       * client holds the lock */
 #define OBD_MD_FLOBJCOUNT    (0x0000400000000000ULL) /* for multiple destroy */
 
-/*     OBD_MD_FLRMTLSETFACL (0x0001000000000000ULL) lfs lsetfacl, obsolete */
-/*     OBD_MD_FLRMTLGETFACL (0x0002000000000000ULL) lfs lgetfacl, obsolete */
-/*     OBD_MD_FLRMTRSETFACL (0x0004000000000000ULL) lfs rsetfacl, obsolete */
-/*     OBD_MD_FLRMTRGETFACL (0x0008000000000000ULL) lfs rgetfacl, obsolete */
-
 #define OBD_MD_FLDATAVERSION (0x0010000000000000ULL) /* iversion sum */
 #define OBD_MD_CLOSE_INTENT_EXECED (0x0020000000000000ULL) /* close intent
                                                              executed */
 #define OBD_MD_FLDATAVERSION (0x0010000000000000ULL) /* iversion sum */
 #define OBD_MD_CLOSE_INTENT_EXECED (0x0020000000000000ULL) /* close intent
                                                              executed */
index 73a76a1..6c0a17f 100644 (file)
@@ -284,10 +284,6 @@ extern int llapi_quotactl(char *mnt, struct if_quotactl *qctl);
 extern int llapi_target_iterate(int type_num, char **obd_type, void *args,
                                llapi_cb_t cb);
 extern int llapi_get_connect_flags(const char *mnt, __u64 *flags);
 extern int llapi_target_iterate(int type_num, char **obd_type, void *args,
                                llapi_cb_t cb);
 extern int llapi_get_connect_flags(const char *mnt, __u64 *flags);
-extern int llapi_lsetfacl(int argc, char *argv[]);
-extern int llapi_lgetfacl(int argc, char *argv[]);
-extern int llapi_rsetfacl(int argc, char *argv[]);
-extern int llapi_rgetfacl(int argc, char *argv[]);
 extern int llapi_cp(int argc, char *argv[]);
 extern int llapi_ls(int argc, char *argv[]);
 extern int llapi_fid2path(const char *device, const char *fidstr, char *path,
 extern int llapi_cp(int argc, char *argv[]);
 extern int llapi_ls(int argc, char *argv[]);
 extern int llapi_fid2path(const char *device, const char *fidstr, char *path,
index 409638f..7af645d 100644 (file)
@@ -46,9 +46,7 @@
 #include "obdctl.h"
 #include <lustre_ver.h>
 
 #include "obdctl.h"
 #include <lustre_ver.h>
 
-static int jt_noop(int argc, char **argv) {
-        return 0;
-}
+static int lctl_list_commands(int argc, char **argv);
 
 static int jt_opt_ignore_errors(int argc, char **argv) {
         Parser_ignore_errors(1);
 
 static int jt_opt_ignore_errors(int argc, char **argv) {
         Parser_ignore_errors(1);
@@ -57,7 +55,7 @@ static int jt_opt_ignore_errors(int argc, char **argv) {
 
 command_t cmdlist[] = {
        /* Metacommands */
 
 command_t cmdlist[] = {
        /* Metacommands */
-       {"===== metacommands =======", jt_noop, 0, "metacommands"},
+       {"===== metacommands =======", NULL, 0, "metacommands"},
        {"--device", jt_opt_device, 0,
         "run <command> after connecting to device <devno>\n"
         "--device <devno> <command [args ...]>"},
        {"--device", jt_opt_device, 0,
         "run <command> after connecting to device <devno>\n"
         "--device <devno> <command [args ...]>"},
@@ -69,7 +67,7 @@ command_t cmdlist[] = {
         "ignore_errors"},
 
        /* User interface commands */
         "ignore_errors"},
 
        /* User interface commands */
-       {"======== control =========", jt_noop, 0, "control commands"},
+       {"======== control =========", NULL, 0, "control commands"},
        {"help", Parser_help, 0, "help"},
        {"lustre_build_version", jt_get_version, 0,
         "print version of Lustre modules\n"
        {"help", Parser_help, 0, "help"},
        {"lustre_build_version", jt_get_version, 0,
         "print version of Lustre modules\n"
@@ -78,9 +76,11 @@ command_t cmdlist[] = {
        {"quit", Parser_quit, 0, "quit"},
        {"--version", Parser_version, 0,
         "print build version of this utility and exit"},
        {"quit", Parser_quit, 0, "quit"},
        {"--version", Parser_version, 0,
         "print build version of this utility and exit"},
+       {"--list-commands", lctl_list_commands, 0,
+        "list commands supported by this utility and exit"},
 
        /* Network configuration commands */
 
        /* Network configuration commands */
-       {"===== network config =====", jt_noop, 0, "network config"},
+       {"===== network config =====", NULL, 0, "network config"},
        {"--net", jt_opt_net, 0, "run <command> after selecting network <net>\n"
         "usage: --net <tcp/o2ib/...> <command>"},
        {"network", jt_ptl_network, 0, "configure LNET"
        {"--net", jt_opt_net, 0, "run <command> after selecting network <net>\n"
         "usage: --net <tcp/o2ib/...> <command>"},
        {"network", jt_ptl_network, 0, "configure LNET"
@@ -143,7 +143,7 @@ command_t cmdlist[] = {
         "usage: net_delay_list"},
 
        /* Device selection commands */
         "usage: net_delay_list"},
 
        /* Device selection commands */
-       {"==== obd device selection ====", jt_noop, 0, "device selection"},
+       {"==== obd device selection ====", NULL, 0, "device selection"},
        {"device", jt_obd_device, 0,
         "set current device to <name|devno>\n"
         "usage: device <%name|$name|devno>"},
        {"device", jt_obd_device, 0,
         "set current device to <name|devno>\n"
         "usage: device <%name|$name|devno>"},
@@ -153,7 +153,7 @@ command_t cmdlist[] = {
         "usage: dl [-t]"},
 
        /* Device operations */
         "usage: dl [-t]"},
 
        /* Device operations */
-       {"==== obd device operations ====", jt_noop, 0, "device operations"},
+       {"==== obd device operations ====", NULL, 0, "device operations"},
        {"activate", jt_obd_activate, 0, "activate an import\n"},
        {"deactivate", jt_obd_deactivate, 0, "deactivate an import. "
         "This command should be used on failed OSC devices in an MDT LOV.\n"},
        {"activate", jt_obd_activate, 0, "activate an import\n"},
        {"deactivate", jt_obd_deactivate, 0, "deactivate an import. "
         "This command should be used on failed OSC devices in an MDT LOV.\n"},
@@ -196,7 +196,7 @@ command_t cmdlist[] = {
         "  -R  Recursively list all parameters under the specified path.\n"},
 
        /* Debug commands */
         "  -R  Recursively list all parameters under the specified path.\n"},
 
        /* Debug commands */
-       {"==== debugging control ====", jt_noop, 0, "debug"},
+       {"==== debugging control ====", NULL, 0, "debug"},
        {"debug_daemon", jt_dbg_debug_daemon, 0,
         "debug daemon control and dump to a file\n"
         "usage: debug_daemon {start file [#MB]|stop}"},
        {"debug_daemon", jt_dbg_debug_daemon, 0,
         "debug daemon control and dump to a file\n"
         "usage: debug_daemon {start file [#MB]|stop}"},
@@ -228,7 +228,7 @@ command_t cmdlist[] = {
         "usage: modules <path>"},
 
        /* Pool commands */
         "usage: modules <path>"},
 
        /* Pool commands */
-       {"===  Pools ==", jt_noop, 0, "pool management"},
+       {"===  Pools ==", NULL, 0, "pool management"},
        {"pool_new", jt_pool_cmd, 0,
         "add a new pool\n"
         "usage: pool_new <fsname>.<poolname>"},
        {"pool_new", jt_pool_cmd, 0,
         "add a new pool\n"
         "usage: pool_new <fsname>.<poolname>"},
@@ -246,7 +246,7 @@ command_t cmdlist[] = {
         "usage: pool_list  <fsname>[.<poolname>] | <pathname>"},
 
        /* Nodemap commands */
         "usage: pool_list  <fsname>[.<poolname>] | <pathname>"},
 
        /* Nodemap commands */
-       {"=== Nodemap ===", jt_noop, 0, "nodemap management"},
+       {"=== Nodemap ===", NULL, 0, "nodemap management"},
        {"nodemap_activate", jt_nodemap_activate, 0,
         "activate nodemap idmapping functions\n"
         "usage: nodemap_activate {0|1}"},
        {"nodemap_activate", jt_nodemap_activate, 0,
         "activate nodemap idmapping functions\n"
         "usage: nodemap_activate {0|1}"},
@@ -280,7 +280,7 @@ command_t cmdlist[] = {
         "Usage: nodemap_info [list|nodemap_name|all]"},
 
        /* Changelog commands */
         "Usage: nodemap_info [list|nodemap_name|all]"},
 
        /* Changelog commands */
-       {"===  Changelogs ==", jt_noop, 0, "changelog user management"},
+       {"===  Changelogs ==", NULL, 0, "changelog user management"},
        {"changelog_register", jt_changelog_register, 0,
         "register a new persistent changelog user, returns id\n"
         "usage: --device <mdtname> changelog_register [-n]"},
        {"changelog_register", jt_changelog_register, 0,
         "register a new persistent changelog user, returns id\n"
         "usage: --device <mdtname> changelog_register [-n]"},
@@ -290,7 +290,7 @@ command_t cmdlist[] = {
 
        /* Device configuration commands */
        {"== device setup (these are not normally used post 1.4) ==",
 
        /* Device configuration commands */
        {"== device setup (these are not normally used post 1.4) ==",
-               jt_noop, 0, "device config"},
+               NULL, 0, "device config"},
        {"attach", jt_lcfg_attach, 0,
         "set the type, name, and uuid of the current device\n"
         "usage: attach type name uuid"},
        {"attach", jt_lcfg_attach, 0,
         "set the type, name, and uuid of the current device\n"
         "usage: attach type name uuid"},
@@ -304,7 +304,7 @@ command_t cmdlist[] = {
         "usage: cleanup [force | failover]"},
 
        /* Test only commands */
         "usage: cleanup [force | failover]"},
 
        /* Test only commands */
-       {"==== testing (DANGEROUS) ====", jt_noop, 0, "testing (DANGEROUS)"},
+       {"==== testing (DANGEROUS) ====", NULL, 0, "testing (DANGEROUS)"},
        {"--threads", jt_opt_threads, 0,
         "run <threads> separate instances of <command> on device <devno>\n"
         "--threads <threads> <verbose> <devno> <command [args ...]>"},
        {"--threads", jt_opt_threads, 0,
         "run <threads> separate instances of <command> on device <devno>\n"
         "--threads <threads> <verbose> <devno> <command [args ...]>"},
@@ -394,7 +394,7 @@ command_t cmdlist[] = {
         "       getobjversion -i <id> -g <group>"},
 
        /* LFSCK commands */
         "       getobjversion -i <id> -g <group>"},
 
        /* LFSCK commands */
-       {"==== LFSCK ====", jt_noop, 0, "LFSCK"},
+       {"==== LFSCK ====", NULL, 0, "LFSCK"},
        {"lfsck_start", jt_lfsck_start, 0, "start LFSCK\n"
         "usage: lfsck_start [-M | --device [MDT,OST]_device]\n"
         "                   [-A | --all] [-c | --create-ostobj [on | off]]\n"
        {"lfsck_start", jt_lfsck_start, 0, "start LFSCK\n"
         "usage: lfsck_start [-M | --device [MDT,OST]_device]\n"
         "                   [-A | --all] [-c | --create-ostobj [on | off]]\n"
@@ -413,7 +413,7 @@ command_t cmdlist[] = {
         "                   [-t | --type lfsck_type[,lfsck_type...]]\n"
         "                   [-w | --wait]"},
 
         "                   [-t | --type lfsck_type[,lfsck_type...]]\n"
         "                   [-w | --wait]"},
 
-       {"==== obsolete (DANGEROUS) ====", jt_noop, 0, "obsolete (DANGEROUS)"},
+       {"==== obsolete (DANGEROUS) ====", NULL, 0, "obsolete (DANGEROUS)"},
        /* some test scripts still use these */
        {"cfg_device", jt_obd_device, 0,
         "set current device to <name>\n"
        /* some test scripts still use these */
        {"cfg_device", jt_obd_device, 0,
         "set current device to <name>\n"
@@ -497,6 +497,24 @@ int lctl_main(int argc, char **argv)
         return rc < 0 ? -rc : rc;
 }
 
         return rc < 0 ? -rc : rc;
 }
 
+static int lctl_list_commands(int argc, char **argv)
+{
+       char buffer[81] = ""; /* 80 printable chars + terminating NUL */
+       command_t *cmd;
+       int rc;
+
+       cmd = cmdlist;
+       while (cmd->pc_name != NULL) {
+               printf("\n%s\n", cmd->pc_name); /* Command category */
+               cmd++;
+               rc = Parser_list_commands(cmd, buffer, sizeof(buffer), NULL,
+                                        0, 4);
+               cmd += rc;
+       }
+
+       return 0;
+}
+
 int main(int argc, char **argv)
 {
        return lctl_main(argc, argv);
 int main(int argc, char **argv)
 {
        return lctl_main(argc, argv);
index da0ccf7..eb78d2b 100644 (file)
@@ -92,11 +92,6 @@ static int lfs_setquota(int argc, char **argv);
 static int lfs_quota(int argc, char **argv);
 #endif
 static int lfs_flushctx(int argc, char **argv);
 static int lfs_quota(int argc, char **argv);
 #endif
 static int lfs_flushctx(int argc, char **argv);
-static int lfs_join(int argc, char **argv);
-static int lfs_lsetfacl(int argc, char **argv);
-static int lfs_lgetfacl(int argc, char **argv);
-static int lfs_rsetfacl(int argc, char **argv);
-static int lfs_rgetfacl(int argc, char **argv);
 static int lfs_cp(int argc, char **argv);
 static int lfs_ls(int argc, char **argv);
 static int lfs_poollist(int argc, char **argv);
 static int lfs_cp(int argc, char **argv);
 static int lfs_ls(int argc, char **argv);
 static int lfs_poollist(int argc, char **argv);
@@ -117,6 +112,7 @@ static int lfs_hsm_cancel(int argc, char **argv);
 static int lfs_swap_layouts(int argc, char **argv);
 static int lfs_mv(int argc, char **argv);
 static int lfs_ladvise(int argc, char **argv);
 static int lfs_swap_layouts(int argc, char **argv);
 static int lfs_mv(int argc, char **argv);
 static int lfs_ladvise(int argc, char **argv);
+static int lfs_list_commands(int argc, char **argv);
 
 /* Setstripe and migrate share mostly the same parameters */
 #define SSM_CMD_COMMON(cmd) \
 
 /* Setstripe and migrate share mostly the same parameters */
 #define SSM_CMD_COMMON(cmd) \
@@ -236,9 +232,6 @@ command_t cmdlist[] = {
          "Display the status of MDS or OSTs (as specified in the command)\n"
          "or all the servers (MDS and OSTs).\n"
          "usage: check <osts|mds|servers>"},
          "Display the status of MDS or OSTs (as specified in the command)\n"
          "or all the servers (MDS and OSTs).\n"
          "usage: check <osts|mds|servers>"},
-        {"join", lfs_join, 0,
-         "join two lustre files into one.\n"
-         "obsolete, HEAD does not support it anymore.\n"},
         {"osts", lfs_osts, 0, "list OSTs connected to client "
          "[for specified path only]\n" "usage: osts [path]"},
         {"mdts", lfs_mdts, 0, "list MDTs connected to client "
         {"osts", lfs_osts, 0, "list OSTs connected to client "
          "[for specified path only]\n" "usage: osts [path]"},
         {"mdts", lfs_mdts, 0, "list MDTs connected to client "
@@ -282,18 +275,6 @@ command_t cmdlist[] = {
 #endif
         {"flushctx", lfs_flushctx, 0, "Flush security context for current user.\n"
          "usage: flushctx [-k] [mountpoint...]"},
 #endif
         {"flushctx", lfs_flushctx, 0, "Flush security context for current user.\n"
          "usage: flushctx [-k] [mountpoint...]"},
-        {"lsetfacl", lfs_lsetfacl, 0,
-         "Remote user setfacl for user/group on the same remote client.\n"
-         "usage: lsetfacl [-bkndRLPvh] [{-m|-x} acl_spec] [{-M|-X} acl_file] file ..."},
-        {"lgetfacl", lfs_lgetfacl, 0,
-         "Remote user getfacl for user/group on the same remote client.\n"
-         "usage: lgetfacl [-dRLPvh] file ..."},
-        {"rsetfacl", lfs_rsetfacl, 0,
-         "Remote user setfacl for user/group on other clients.\n"
-         "usage: rsetfacl [-bkndRLPvh] [{-m|-x} acl_spec] [{-M|-X} acl_file] file ..."},
-        {"rgetfacl", lfs_rgetfacl, 0,
-         "Remote user getfacl for user/group on other clients.\n"
-         "usage: rgetfacl [-dRLPvh] file ..."},
         {"cp", lfs_cp, 0,
          "Remote user copy files and directories.\n"
          "usage: cp [OPTION]... [-T] SOURCE DEST\n\tcp [OPTION]... SOURCE... DIRECTORY\n\tcp [OPTION]... -t DIRECTORY SOURCE..."},
         {"cp", lfs_cp, 0,
          "Remote user copy files and directories.\n"
          "usage: cp [OPTION]... [-T] SOURCE DEST\n\tcp [OPTION]... SOURCE... DIRECTORY\n\tcp [OPTION]... -t DIRECTORY SOURCE..."},
@@ -393,6 +374,8 @@ command_t cmdlist[] = {
        {"quit", Parser_quit, 0, "quit"},
        {"--version", Parser_version, 0,
         "output build version of the utility and exit"},
        {"quit", Parser_quit, 0, "quit"},
        {"--version", Parser_version, 0,
         "output build version of the utility and exit"},
+       {"--list-commands", lfs_list_commands, 0,
+        "list commands supported by the utility and exit"},
        { 0, 0, 0, NULL }
 };
 
        { 0, 0, 0, NULL }
 };
 
@@ -2682,13 +2665,6 @@ static int lfs_check(int argc, char **argv)
 
 }
 
 
 }
 
-static int lfs_join(int argc, char **argv)
-{
-        fprintf(stderr, "join two lustre files into one.\n"
-                        "obsolete, HEAD does not support it anymore.\n");
-        return 0;
-}
-
 #ifdef HAVE_SYS_QUOTA_H
 #define ARG2INT(nr, str, msg)                                           \
 do {                                                                    \
 #ifdef HAVE_SYS_QUOTA_H
 #define ARG2INT(nr, str, msg)                                           \
 do {                                                                    \
@@ -3509,34 +3485,6 @@ static int lfs_flushctx(int argc, char **argv)
         return rc;
 }
 
         return rc;
 }
 
-static int lfs_lsetfacl(int argc, char **argv)
-{
-       fprintf(stderr, "local client sets facl for remote client.\n"
-               "obsolete, does not support it anymore.\n");
-       return 0;
-}
-
-static int lfs_lgetfacl(int argc, char **argv)
-{
-       fprintf(stderr, "local client gets facl for remote client.\n"
-               "obsolete, does not support it anymore.\n");
-       return 0;
-}
-
-static int lfs_rsetfacl(int argc, char **argv)
-{
-       fprintf(stderr, "remote client sets facl for remote client.\n"
-               "obsolete, does not support it anymore.\n");
-       return 0;
-}
-
-static int lfs_rgetfacl(int argc, char **argv)
-{
-       fprintf(stderr, "remote client gets facl for remote client.\n"
-               "obsolete, does not support it anymore.\n");
-       return 0;
-}
-
 static int lfs_cp(int argc, char **argv)
 {
        fprintf(stderr, "remote client copy file(s).\n"
 static int lfs_cp(int argc, char **argv)
 {
        fprintf(stderr, "remote client copy file(s).\n"
@@ -4566,6 +4514,15 @@ next:
        return rc;
 }
 
        return rc;
 }
 
+static int lfs_list_commands(int argc, char **argv)
+{
+       char buffer[81] = ""; /* 80 printable chars + terminating NUL */
+
+       Parser_list_commands(cmdlist, buffer, sizeof(buffer), NULL, 0, 4);
+
+       return 0;
+}
+
 int main(int argc, char **argv)
 {
         int rc;
 int main(int argc, char **argv)
 {
         int rc;