summaryrefslogtreecommitdiffstats
path: root/partx/partx.c
diff options
context:
space:
mode:
authorKarel Zak2011-05-10 11:39:51 +0200
committerKarel Zak2011-05-10 11:39:51 +0200
commit8ed48785e1d5266211884540350afa22cd1513a3 (patch)
treed8da89dd10f24e077bfaa9be83f0b5b34e2e7dfa /partx/partx.c
parentfindmnt: add --pairs to output in key="value" format (diff)
downloadkernel-qcow2-util-linux-8ed48785e1d5266211884540350afa22cd1513a3.tar.gz
kernel-qcow2-util-linux-8ed48785e1d5266211884540350afa22cd1513a3.tar.xz
kernel-qcow2-util-linux-8ed48785e1d5266211884540350afa22cd1513a3.zip
partx: add --pairs to output in key="value" format
Signed-off-by: Karel Zak <kzak@redhat.com>
Diffstat (limited to 'partx/partx.c')
-rw-r--r--partx/partx.c36
1 files changed, 22 insertions, 14 deletions
diff --git a/partx/partx.c b/partx/partx.c
index 7c89cf57b..5979701c5 100644
--- a/partx/partx.c
+++ b/partx/partx.c
@@ -608,13 +608,14 @@ static void __attribute__((__noreturn__)) usage(FILE *out)
" -b, --bytes print SIZE in bytes rather than in human readable format\n"
" -g, --noheadings don't print headings for --show\n"
- " -r, --raw use raw format output\n"
+ " -P, --pairs use key=\"value\" output format\n"
+ " -r, --raw use raw output format\n"
" -t, --type <TYPE> specify the partition type (dos, bsd, solaris, etc.)\n"
" -n, --nr <M:N> specify the range of partitions (e.g. --nr 2:4)\n"
" -o, --output <LIST> define which output columns to use\n"
" -h, --help print this help\n\n"));
- fprintf(out, _("\nAvailable columns (for --show):\n"));
+ fprintf(out, _("\nAvailable columns (for --show, --raw or --pairs):\n"));
for (i = 0; i < __NCOLUMNS; i++)
fprintf(out, " %10s %s\n", infos[i].name, _(infos[i].help));
@@ -650,53 +651,60 @@ int main(int argc, char **argv)
{ "type", required_argument, NULL, 't' },
{ "nr", required_argument, NULL, 'n' },
{ "output", required_argument, NULL, 'o' },
+ { "pairs", no_argument, NULL, 'P' },
{ "help", no_argument, NULL, 'h' },
{ NULL, 0, NULL, 0 }
};
- while ((c = getopt_long(argc, argv, "abdglrsvn:t:o:h", long_opts, NULL)) != -1) {
+ while ((c = getopt_long(argc, argv,
+ "abdglrsvn:t:o:Ph", long_opts, NULL)) != -1) {
+
switch(c) {
case 'a':
+ case 'd':
+ case 'l':
+ case 'r':
+ case 'P':
+ case 's':
if (what)
- errx_mutually_exclusive("--{add,delete,show,list,raw}");
+ errx_mutually_exclusive("--{add,delete,show,list,raw,pairs}");
+ break;
+ }
+
+ switch(c) {
+ case 'a':
what = ACT_ADD;
break;
case 'b':
partx_flags |= FL_BYTES;
break;
case 'd':
- if (what)
- errx_mutually_exclusive("--{add,delete,show,list,raw}");
what = ACT_DELETE;
break;
case 'g':
tt_flags |= TT_FL_NOHEADINGS;
break;
case 'l':
- if (what)
- errx_mutually_exclusive("--{add,delete,show,list,raw}");
what = ACT_LIST;
break;
case 'n':
if (parse_range(optarg, &lower, &upper))
errx(EXIT_FAILURE, _("failed to parse --nr <M-N> range"));
break;
-
case 'o':
if (tt_parse_columns_list(optarg, columns, &ncolumns,
column_name_to_id))
return EXIT_FAILURE;
break;
+ case 'P':
+ tt_flags |= TT_FL_EXPORT;
+ what = ACT_SHOW;
+ break;
case 'r':
tt_flags |= TT_FL_RAW;
- if (what)
- errx_mutually_exclusive("--{add,delete,show,list,raw}");
what = ACT_SHOW;
break;
-
case 's':
- if (what)
- errx_mutually_exclusive("--{add,delete,show,list,raw}");
what = ACT_SHOW;
break;
case 't':