From b0ff9a76b79b1de6409c8d12a78eace770fbc51f Mon Sep 17 00:00:00 2001 From: Chris Morin Date: Thu, 18 May 2017 20:07:19 -0400 Subject: [PATCH] sfdisk: disambiguate units of --show-size [kzak@redhat.com: - use optutils.h] Signed-off-by: Chris Morin Signed-off-by: Karel Zak --- disk-utils/sfdisk.8 | 7 +++++-- disk-utils/sfdisk.c | 14 ++++++++++++-- 2 files changed, 17 insertions(+), 4 deletions(-) diff --git a/disk-utils/sfdisk.8 b/disk-utils/sfdisk.8 index b67befc44..5266ca744 100644 --- a/disk-utils/sfdisk.8 +++ b/disk-utils/sfdisk.8 @@ -132,7 +132,9 @@ then print the current partition UUID. Renumber the partitions, ordering them by their start offset. .TP .BR \-s , " \-\-show\-size " [ \fIdevice ...] -List the sizes of all or the specified devices. +List the sizes of all or the specified devices in units of 1024 byte size. +This command is DEPRECATED in favour of +.BR blockdev (1). .TP .BR \-T , " \-\-list\-types" Print all supported types for the current disk label or the label specified by @@ -219,7 +221,8 @@ specified in the format \fI+list\fP (e.g. \fB-o +UUID\fP). Suppress extra info messages. .TP .BR \-u , " \-\-unit S" -Deprecated option. Only the sector unit is supported. +Deprecated option. Only the sector unit is supported. This option is not +supported when using the --show-size command. .TP .BR \-X , " \-\-label " \fItype Specify the disk label type (e.g. \fBdos\fR, \fBgpt\fR, ...). If this option diff --git a/disk-utils/sfdisk.c b/disk-utils/sfdisk.c index fe85c26ab..2ac8cef02 100644 --- a/disk-utils/sfdisk.c +++ b/disk-utils/sfdisk.c @@ -49,6 +49,7 @@ #include "all-io.h" #include "rpmatch.h" #include "loopdev.h" +#include "optutils.h" #include "libfdisk.h" #include "fdisk-list.h" @@ -1961,7 +1962,6 @@ int main(int argc, char *argv[]) { "output", required_argument, NULL, 'o' }, { "partno", required_argument, NULL, 'N' }, { "reorder", no_argument, NULL, 'r' }, - { "show-size", no_argument, NULL, 's' }, { "show-geometry", no_argument, NULL, 'g' }, { "quiet", no_argument, NULL, 'q' }, { "verify", no_argument, NULL, 'V' }, @@ -1975,8 +1975,9 @@ int main(int argc, char *argv[]) { "part-attrs", no_argument, NULL, OPT_PARTATTRS }, { "show-pt-geometry", no_argument, NULL, 'G' }, /* deprecated */ - { "unit", required_argument, NULL, 'u' }, + { "unit", required_argument, NULL, 'u' }, /* deprecated */ { "Linux", no_argument, NULL, 'L' }, /* deprecated */ + { "show-size", no_argument, NULL, 's' }, /* deprecated */ { "change-id",no_argument, NULL, OPT_CHANGE_ID }, /* deprecated */ { "id", no_argument, NULL, 'c' }, /* deprecated */ @@ -1984,6 +1985,12 @@ int main(int argc, char *argv[]) { NULL, 0, NULL, 0 }, }; + static const ul_excl_t excl[] = { /* rows and cols in ASCII order */ + { 's','u'}, /* --show-size --unit */ + { 0 } + }; + int excl_st[ARRAY_SIZE(excl)] = UL_EXCL_STATUS_INIT; + setlocale(LC_ALL, ""); bindtextdomain(PACKAGE, LOCALEDIR); @@ -1992,6 +1999,9 @@ int main(int argc, char *argv[]) while ((c = getopt_long(argc, argv, "aAbcdfFgGhJlLo:O:nN:qrsTu:vVX:Y:w:W:", longopts, &longidx)) != -1) { + + err_exclusive_options(c, longopts, excl, excl_st); + switch(c) { case 'A': sf->act = ACT_ACTIVATE;