" -P Set the parameter permanently, filesystem-wide.\n"
" -d Remove the permanent setting (only with -P option).\n"},
{"list_param", jt_lcfg_listparam, 0,
- "list the Lustre or LNET parameter name\n"
- "usage: list_param [-F|-R] <param_path1 param_path2 ...>\n"
- "List the name of Lustre or LNET parameter from the specified path.\n"
- " -F Add '/', '@' or '=' for dirs, symlinks and writeable files,\n"
- "respectively.\n"
- " -R Recursively list all parameters under the specified path.\n"},
+ "list the Lustre or LNET parameter name\n"
+ "usage: list_param [-F|-R|-D] <param_path1 param_path2 ...>\n"
+ "List the name of Lustre or LNET parameter from the specified path.\n"
+ " -F Add '/', '@' or '=' for dirs, symlinks and writeable files,\n"
+ "respectively.\n"
+ " -D Only list directories.\n"
+ " -R Recursively list all parameters under the specified path.\n"},
/* Debug commands */
{"==== debugging control ====", jt_noop, 0, "debug"},
"usage: nodemap_test_nid <nid>"},
{"nodemap_test_id", jt_nodemap_test_id, 0,
"Usage: nodemap_test_id --nid <nid> --idtype [uid|gid] --id <id>"},
+ {"nodemap_info", jt_nodemap_info, 0,
+ "Usage: nodemap_info [list|nodemap_name|all]"},
/* Changelog commands */
{"=== Changelogs ==", jt_noop, 0, "changelog user management"},
unsigned int po_recursive:1;
unsigned int po_params2:1;
unsigned int po_delete:1;
+ unsigned int po_only_dir:1;
};
/* Param set to single log file, used by all clients and servers.
/* Display the path in the same format as sysctl
* For eg. obdfilter.lustre-OST0000.stats */
static char *
-display_name(char *filename, size_t filename_size, bool po_show_type)
+display_name(char *filename, size_t filename_size, struct param_opts *popt)
{
struct stat st;
char *tmp;
char *suffix = NULL;
- if (po_show_type) {
+ if (popt->po_show_type || popt->po_only_dir) {
if (lstat(filename, &st) == -1)
return NULL;
- if (S_ISDIR(st.st_mode))
- suffix = "/";
- else if (S_ISLNK(st.st_mode))
- suffix = "@";
- else if (st.st_mode & S_IWUSR)
- suffix = "=";
+ if (popt->po_show_type) {
+ if (S_ISDIR(st.st_mode))
+ suffix = "/";
+ else if (S_ISLNK(st.st_mode))
+ suffix = "@";
+ else if (st.st_mode & S_IWUSR)
+ suffix = "=";
+ } else if (popt->po_only_dir) {
+ if (!S_ISDIR(st.st_mode))
+ return NULL;
+ }
}
filename += strlen("/proc/");
/* Append the indicator to entries. We know there is enough space
* for the suffix, since the path prefix was deleted. */
- if (po_show_type && suffix != NULL)
+ if (popt->po_show_type && suffix != NULL)
strncat(filename, suffix, filename_size);
return filename;
static int listparam_cmdline(int argc, char **argv, struct param_opts *popt)
{
- int ch;
+ int ch;
- popt->po_show_path = 1;
- popt->po_only_path = 1;
- popt->po_show_type = 0;
- popt->po_recursive = 0;
+ popt->po_show_path = 1;
+ popt->po_only_path = 1;
+ popt->po_show_type = 0;
+ popt->po_recursive = 0;
+ popt->po_only_dir = 0;
- while ((ch = getopt(argc, argv, "FR")) != -1) {
- switch (ch) {
- case 'F':
- popt->po_show_type = 1;
- break;
- case 'R':
- popt->po_recursive = 1;
- break;
- default:
- return -1;
- }
- }
+ while ((ch = getopt(argc, argv, "FRD")) != -1) {
+ switch (ch) {
+ case 'F':
+ popt->po_show_type = 1;
+ break;
+ case 'R':
+ popt->po_recursive = 1;
+ break;
+ case 'D':
+ popt->po_only_dir = 1;
+ break;
+ default:
+ return -1;
+ }
+ }
- return optind;
+ return optind;
}
static int listparam_display(struct param_opts *popt, char *pattern)
if (rc < 0)
return rc;
- rc = glob(filename, GLOB_BRACE | (popt->po_recursive ? GLOB_MARK : 0),
+ rc = glob(filename,
+ GLOB_BRACE |
+ (popt->po_recursive ? GLOB_MARK : 0) |
+ /* GLOB_ONLYDIR doesn't guarantee, only a hint */
+ (popt->po_only_dir ? GLOB_ONLYDIR : 0),
NULL, &glob_info);
if (rc) {
fprintf(stderr, "error: list_param: %s: %s\n",
else
last = 0;
strlcpy(filename, glob_info.gl_pathv[i], len);
- valuename = display_name(filename, len, popt->po_show_type);
+ valuename = display_name(filename, len, popt);
if (valuename)
printf("%s\n", valuename);
if (last) {
strncpy(filename, glob_info.gl_pathv[i],
sizeof(filename));
valuename = display_name(filename, sizeof(filename),
- false);
+ popt);
}
/* Write the contents of file to stdout */
return rc;
}
+/**
+ * Output information about nodemaps.
+ * \param argc number of args
+ * \param argv[] variable string arguments
+ *
+ * [list|nodemap_name|all] \a list will list all nodemaps (default).
+ * Specifying a \a nodemap_name will
+ * display info about that specific nodemap.
+ * \a all will display info for all nodemaps.
+ * \retval 0 on success
+ */
+int jt_nodemap_info(int argc, char **argv)
+{
+ const char usage_str[] = "usage: nodemap_info "
+ "[list|nodemap_name|all]\n";
+ struct param_opts popt = {
+ .po_only_path = 0,
+ .po_show_path = 1,
+ .po_show_type = 0,
+ .po_recursive = 0,
+ .po_only_dir = 0
+ };
+ int rc = 0;
+
+ if (argc > 2) {
+ fprintf(stderr, usage_str);
+ return -1;
+ }
+
+ if (argc == 1 || strcmp("list", argv[1]) == 0) {
+ popt.po_only_path = 1;
+ popt.po_only_dir = 1;
+ rc = listparam_display(&popt, "nodemap/*");
+ } else if (strcmp("all", argv[1]) == 0) {
+ rc = getparam_display(&popt, "nodemap/*/*");
+ } else {
+ char pattern[PATH_MAX];
+
+ snprintf(pattern, sizeof(pattern), "nodemap/%s/*", argv[1]);
+ rc = getparam_display(&popt, pattern);
+ if (rc == -ESRCH)
+ fprintf(stderr, "error: nodemap_info: cannot find"
+ "nodemap %s\n", argv[1]);
+ }
+ return rc;
+}
+
+
static int setparam_cmdline(int argc, char **argv, struct param_opts *popt)
{
int ch;
strncpy(filename, glob_info.gl_pathv[i],
sizeof(filename));
valuename = display_name(filename, sizeof(filename),
- false);
+ popt);
if (valuename)
printf("%s=%s\n", valuename, value);
}