lctl-get_param \- retrieve configuration parameters
.SH SYNOPSIS
.br
-.IR "\fBlctl get_param " [ -F "] [" -n | -N "] [" -R "] <" parameter ...>
+.IR "\fBlctl get_param " [ -F "] [" -H "] [" -n | -N "] [" -R "] <" parameter ...>
.br
.SH DESCRIPTION
Get the value of the named Lustre or LNet
is equivalent to
.BR "lctl list_param -F" .
.TP
+.B -H
+Prefix each parameter value line with the parameter name, as a header. It
+also print a line for empty values. It could be useful when wildcards are
+used and filtering the output.
+.TP
.B -n
Print only the parameter value and not parameter name. This may be confusing
if multiple parameter names are specified, as the parameters are not
"The path can contain shell-style filename patterns.\n"
" -F When -N specified, add '/', '@' or '=' for directories,\n"
" symlinks and writeable files, respectively.\n"
+ " -H Prefix each output line with the parameter name.\n"
" -n Print only the value and not parameter name.\n"
" -N Print only matched parameter names and not the values.\n"
" (Especially useful when using patterns.)\n"
unsigned int po_file:1;
unsigned int po_yaml:1;
unsigned int po_detail:1;
+ unsigned int po_header:1;
unsigned int po_parallel_threads;
};
#define popt_is_parallel(popt) ((popt).po_parallel_threads > 0)
goto free_buf;
}
/* don't print anything for empty files */
- if (buf[0] == '\0')
+ if (buf[0] == '\0') {
+ if (popt->po_header)
+ printf("%s=\n", param_name);
goto free_buf;
+ }
+
+ if (popt->po_header) {
+ char *oldbuf = buf;
+ char *next;
+
+ do {
+ /* Split at first \n, if any */
+ next = strchrnul(oldbuf, '\n');
+
+ printf("%s=%.*s\n", param_name, (int)(next - oldbuf),
+ oldbuf);
+
+ buflen -= next - oldbuf + 1;
+ oldbuf = next + 1;
- if (popt->po_show_path) {
- bool longbuf;
+ } while (buflen > 0);
- longbuf = memchr(buf, '\n', buflen - 1) ||
- buflen + strlen(param_name) >= 80;
- printf("%s=%s", param_name, longbuf ? "\n" : "");
+ } else if (popt->po_show_path) {
+ bool multilines = memchr(buf, '\n', buflen - 1);
+
+ printf("%s=%s%s", param_name, multilines ? "\n" : "", buf);
+ } else {
+ printf("%s", buf);
}
- printf("%s", buf);
free_buf:
free(buf);
popt->po_show_path = 1;
- while ((ch = getopt(argc, argv, "FnNRy")) != -1) {
+ while ((ch = getopt(argc, argv, "FHnNRy")) != -1) {
switch (ch) {
case 'F':
popt->po_show_type = 1;
break;
+ case 'H':
+ popt->po_header = 1;
+ break;
case 'n':
popt->po_show_path = 0;
break;