summaryrefslogtreecommitdiffstats
path: root/disk-utils/sfdisk.c
diff options
context:
space:
mode:
authorKarel Zak2014-10-03 12:40:19 +0200
committerKarel Zak2014-10-07 14:55:32 +0200
commit01f9286cb1e9c891b678af122d50bb2e9e99142e (patch)
tree1d49874724235771bd9803a318f19f91a84b93e4 /disk-utils/sfdisk.c
parentfdisk: add --output <list> for print command(s) (diff)
downloadkernel-qcow2-util-linux-01f9286cb1e9c891b678af122d50bb2e9e99142e.tar.gz
kernel-qcow2-util-linux-01f9286cb1e9c891b678af122d50bb2e9e99142e.tar.xz
kernel-qcow2-util-linux-01f9286cb1e9c891b678af122d50bb2e9e99142e.zip
sfdisk: add --output <list> for print command(s)
Signed-off-by: Karel Zak <kzak@redhat.com>
Diffstat (limited to 'disk-utils/sfdisk.c')
-rw-r--r--disk-utils/sfdisk.c12
1 files changed, 11 insertions, 1 deletions
diff --git a/disk-utils/sfdisk.c b/disk-utils/sfdisk.c
index 754bd6f2e..af83d2c22 100644
--- a/disk-utils/sfdisk.c
+++ b/disk-utils/sfdisk.c
@@ -1306,6 +1306,7 @@ static void __attribute__ ((__noreturn__)) usage(FILE *out)
fputs(_(" -A, --append append partitions to existing partition table\n"), out);
fputs(_(" -b, --backup backup partition table sectors (see -O)\n"), out);
fputs(_(" -f, --force disable all consistency checking\n"), out);
+ fputs(_(" -o, --output <list> output columns\n"), out);
fputs(_(" -O, --backup-file <path> override default backout file name\n"), out);
fputs(_(" -N, --partno <num> specify partition number\n"), out);
fputs(_(" -X, --label <name> specify label type (dos, gpt, ...)\n"), out);
@@ -1320,6 +1321,8 @@ static void __attribute__ ((__noreturn__)) usage(FILE *out)
fputs(USAGE_HELP, out);
fputs(USAGE_VERSION, out);
+ list_available_columns(out);
+
fprintf(out, USAGE_MAN_TAIL("sfdisk(8)"));
exit(out == stderr ? EXIT_FAILURE : EXIT_SUCCESS);
}
@@ -1327,6 +1330,7 @@ static void __attribute__ ((__noreturn__)) usage(FILE *out)
int main(int argc, char *argv[])
{
+ const char *outarg = NULL;
int rc = -EINVAL, c, longidx = -1;
struct sfdisk _sf = {
.partno = -1
@@ -1356,6 +1360,7 @@ int main(int argc, char *argv[])
{ "list-types", no_argument, NULL, 'T' },
{ "no-act", no_argument, NULL, 'n' },
{ "no-reread", no_argument, NULL, OPT_NOREREAD },
+ { "output", required_argument, NULL, 'o' },
{ "partno", required_argument, NULL, 'N' },
{ "show-size", no_argument, NULL, 's' },
{ "show-geometry", no_argument, NULL, 'g' },
@@ -1383,7 +1388,7 @@ int main(int argc, char *argv[])
textdomain(PACKAGE);
atexit(close_stdout);
- while ((c = getopt_long(argc, argv, "aAbcdfghlLO:nN:qsTu:vVX:",
+ while ((c = getopt_long(argc, argv, "aAbcdfghlLo:O:nN:qsTu:vVX:",
longopts, &longidx)) != -1) {
switch(c) {
case 'a':
@@ -1423,6 +1428,9 @@ int main(int argc, char *argv[])
case 'L':
warnx(_("--Linux option is unnecessary and deprecated"));
break;
+ case 'o':
+ outarg = optarg;
+ break;
case 'O':
sf->backup = 1;
sf->backup_file = optarg;
@@ -1481,6 +1489,8 @@ int main(int argc, char *argv[])
}
sfdisk_init(sf);
+ if (outarg)
+ init_fields(NULL, outarg, NULL);
if (sf->verify && !sf->act)
sf->act = ACT_VERIFY; /* --verify make be used with --list too */