zramctl: add --output-all option

Signed-off-by: Sami Kerola <kerolasa@iki.fi>
This commit is contained in:
Sami Kerola 2018-04-24 22:18:54 +01:00
parent b5b43f276e
commit 2e7ccec7bb
No known key found for this signature in database
GPG Key ID: A9553245FDE9B739
3 changed files with 14 additions and 1 deletions

View File

@ -41,6 +41,7 @@ _zramctl_module()
--find
--noheadings
--output
--output-all
--raw
--reset
--size

View File

@ -59,6 +59,9 @@ Define the status output columns to be used. If no output arrangement is
specified, then a default set is used.
Use \fB\-\-help\fP to get a list of all supported columns.
.TP
.B \-\-output\-all
Output all available columns.
.TP
.B \-\-raw
Use the raw format for status output.
.TP

View File

@ -543,6 +543,7 @@ static void __attribute__((__noreturn__)) usage(void)
fputs(_(" -f, --find find a free device\n"), out);
fputs(_(" -n, --noheadings don't print headings\n"), out);
fputs(_(" -o, --output <list> columns to use for status output\n"), out);
fputs(_(" --output-all output all columns\n"), out);
fputs(_(" --raw use raw status output format\n"), out);
fputs(_(" -r, --reset reset all specified devices\n"), out);
fputs(_(" -s, --size <size> device size\n"), out);
@ -575,7 +576,10 @@ int main(int argc, char **argv)
int rc = 0, c, find = 0, act = A_NONE;
struct zram *zram = NULL;
enum { OPT_RAW = CHAR_MAX + 1 };
enum {
OPT_RAW = CHAR_MAX + 1,
OPT_LIST_TYPES
};
static const struct option longopts[] = {
{ "algorithm", required_argument, NULL, 'a' },
@ -583,6 +587,7 @@ int main(int argc, char **argv)
{ "find", no_argument, NULL, 'f' },
{ "help", no_argument, NULL, 'h' },
{ "output", required_argument, NULL, 'o' },
{ "output-all",no_argument, NULL, OPT_LIST_TYPES },
{ "noheadings",no_argument, NULL, 'n' },
{ "reset", no_argument, NULL, 'r' },
{ "raw", no_argument, NULL, OPT_RAW },
@ -625,6 +630,10 @@ int main(int argc, char **argv)
if (ncolumns < 0)
return EXIT_FAILURE;
break;
case OPT_LIST_TYPES:
for (ncolumns = 0; (size_t)ncolumns < ARRAY_SIZE(infos); ncolumns++)
columns[ncolumns] = ncolumns;
break;
case 's':
size = strtosize_or_err(optarg, _("failed to parse size"));
act = A_CREATE;