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 *);
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)
{
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");
- 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
}
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
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)
/*************************************************************************
* 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,
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"
{"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 }
};
+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;
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;
"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 }
};
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)
{
-.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
.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
.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
.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
-.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
.br
.B lfs --version
.br
+.B lfs --list-commands
+.br
.B lfs help
.SH DESCRIPTION
.B lfs
.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
.
-.TH lnetctl 1 "2014 Sep 12" Lustre "configuration utilities"
+.TH lnetctl 8 "2017 Jan 12" Lustre "configuration utilities"
.
.SH "SYNOPSIS"
\fBlnetctl\fR
.
.br
+.B lnetctl --list-commands
+.br
\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\.
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
.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"
-.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"
+.br
+.B "lst --list-commands"
.SH DESCRIPTION
LNET self-test helps site administrators confirm that Lustre
Networking (LNET) has been properly installed and configured.
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...).
* 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 */
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,
#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);
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 ...]>"},
"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"
{"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 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"
"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>"},
"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"},
" -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}"},
"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>"},
"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}"},
"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]"},
/* 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"},
"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 ...]>"},
" 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"
" [-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"
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);
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_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) \
"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 "
#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..."},
{"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 }
};
}
-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 { \
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"
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;