partx: add --list-types option
Use libblkid as the source of truth what partition type names exist, and are supported. Signed-off-by: Sami Kerola <kerolasa@iki.fi>
This commit is contained in:
parent
635d9aa5db
commit
2cdaf94b55
|
@ -27,8 +27,7 @@ _partx_module()
|
||||||
return 0
|
return 0
|
||||||
;;
|
;;
|
||||||
'-t'|'--type')
|
'-t'|'--type')
|
||||||
# FIXME: some command should list type libblkid knows.
|
COMPREPLY=( $(compgen -W "$(partx --list-types)" -- $cur) )
|
||||||
COMPREPLY=( $(compgen -W "aix bsd dos gpt mac minix PMBR sgi solaris sun ultrix unixware" -- $cur) )
|
|
||||||
return 0
|
return 0
|
||||||
;;
|
;;
|
||||||
'-h'|'--help'|'-V'|'--version')
|
'-h'|'--help'|'-V'|'--version')
|
||||||
|
@ -50,6 +49,7 @@ _partx_module()
|
||||||
--raw
|
--raw
|
||||||
--sector-size
|
--sector-size
|
||||||
--type
|
--type
|
||||||
|
--list-types
|
||||||
--verbose
|
--verbose
|
||||||
--help
|
--help
|
||||||
--version
|
--version
|
||||||
|
|
|
@ -119,20 +119,10 @@ The output columns can be selected and rearranged with the
|
||||||
All numbers (except SIZE) are in 512-byte sectors.
|
All numbers (except SIZE) are in 512-byte sectors.
|
||||||
.TP
|
.TP
|
||||||
.BR \-t , " \-\-type " \fItype
|
.BR \-t , " \-\-type " \fItype
|
||||||
Specify the partition table type, which can be one of
|
Specify the partition table type.
|
||||||
.BR aix ,
|
.TP
|
||||||
.BR bsd ,
|
.BR \-\-list\-types
|
||||||
.BR dos ,
|
List supported partition types and exit.
|
||||||
.BR gpt ,
|
|
||||||
.BR mac ,
|
|
||||||
.BR minix ,
|
|
||||||
.BR PMBR ,
|
|
||||||
.BR sgi ,
|
|
||||||
.BR solaris ,
|
|
||||||
.BR sun ,
|
|
||||||
.BR ultrix ,
|
|
||||||
or
|
|
||||||
.BR unixware .
|
|
||||||
.TP
|
.TP
|
||||||
.BR \-u , " \-\-update"
|
.BR \-u , " \-\-update"
|
||||||
Update the specified partitions.
|
Update the specified partitions.
|
||||||
|
|
|
@ -767,7 +767,8 @@ static void __attribute__((__noreturn__)) usage(FILE *out)
|
||||||
fputs(_(" -P, --pairs use key=\"value\" output format\n"), out);
|
fputs(_(" -P, --pairs use key=\"value\" output format\n"), out);
|
||||||
fputs(_(" -r, --raw use raw output format\n"), out);
|
fputs(_(" -r, --raw use raw output format\n"), out);
|
||||||
fputs(_(" -S, --sector-size <num> overwrite sector size\n"), out);
|
fputs(_(" -S, --sector-size <num> overwrite sector size\n"), out);
|
||||||
fputs(_(" -t, --type <type> specify the partition type (dos, bsd, solaris, etc.)\n"), out);
|
fputs(_(" -t, --type <type> specify the partition type\n"), out);
|
||||||
|
fputs(_(" --list-types list supported partition types and exit\n"), out);
|
||||||
fputs(_(" -v, --verbose verbose mode\n"), out);
|
fputs(_(" -v, --verbose verbose mode\n"), out);
|
||||||
|
|
||||||
fputs(USAGE_SEPARATOR, out);
|
fputs(USAGE_SEPARATOR, out);
|
||||||
|
@ -795,6 +796,9 @@ int main(int argc, char **argv)
|
||||||
dev_t disk_devno = 0, part_devno = 0;
|
dev_t disk_devno = 0, part_devno = 0;
|
||||||
unsigned int sector_size = 0;
|
unsigned int sector_size = 0;
|
||||||
|
|
||||||
|
enum {
|
||||||
|
OPT_LIST_TYPES = CHAR_MAX + 1
|
||||||
|
};
|
||||||
static const struct option long_opts[] = {
|
static const struct option long_opts[] = {
|
||||||
{ "bytes", no_argument, NULL, 'b' },
|
{ "bytes", no_argument, NULL, 'b' },
|
||||||
{ "noheadings", no_argument, NULL, 'g' },
|
{ "noheadings", no_argument, NULL, 'g' },
|
||||||
|
@ -805,6 +809,7 @@ int main(int argc, char **argv)
|
||||||
{ "delete", no_argument, NULL, 'd' },
|
{ "delete", no_argument, NULL, 'd' },
|
||||||
{ "update", no_argument, NULL, 'u' },
|
{ "update", no_argument, NULL, 'u' },
|
||||||
{ "type", required_argument, NULL, 't' },
|
{ "type", required_argument, NULL, 't' },
|
||||||
|
{ "list-types", no_argument, NULL, OPT_LIST_TYPES },
|
||||||
{ "nr", required_argument, NULL, 'n' },
|
{ "nr", required_argument, NULL, 'n' },
|
||||||
{ "output", required_argument, NULL, 'o' },
|
{ "output", required_argument, NULL, 'o' },
|
||||||
{ "pairs", no_argument, NULL, 'P' },
|
{ "pairs", no_argument, NULL, 'P' },
|
||||||
|
@ -877,6 +882,15 @@ int main(int argc, char **argv)
|
||||||
case 'v':
|
case 'v':
|
||||||
verbose = 1;
|
verbose = 1;
|
||||||
break;
|
break;
|
||||||
|
case OPT_LIST_TYPES:
|
||||||
|
{
|
||||||
|
size_t idx = 0;
|
||||||
|
const char *name = NULL;
|
||||||
|
|
||||||
|
while (blkid_partitions_get_name(idx++, &name) == 0)
|
||||||
|
puts(name);
|
||||||
|
return EXIT_SUCCESS;
|
||||||
|
}
|
||||||
case 'h':
|
case 'h':
|
||||||
usage(stdout);
|
usage(stdout);
|
||||||
case 'V':
|
case 'V':
|
||||||
|
|
Loading…
Reference in New Issue