sfdisk: add --list-free
Signed-off-by: Karel Zak <kzak@redhat.com>
This commit is contained in:
parent
0efd951c80
commit
8abdb91211
|
@ -33,6 +33,7 @@ _sfdisk_module()
|
|||
--change-id
|
||||
--print-id
|
||||
--list
|
||||
--list-free
|
||||
--dump
|
||||
--increment
|
||||
--unit
|
||||
|
|
|
@ -85,6 +85,9 @@ not able to use JSON as input format.
|
|||
List the partitions of all or the specified devices. This command can be used
|
||||
together with \fB\-\-verify\fR.
|
||||
.TP
|
||||
.BR \-F , " \-\-list-free " [ \fIdevice ...]
|
||||
List the free unpartitioned areas on all or the specified devices.
|
||||
.TP
|
||||
.BR \-\-part\-attrs " \fIdevice partno [" \fIattrs ]
|
||||
Change the GPT partition attribute bits. If \fIattrs\fR is not specified,
|
||||
then print the current partition settings. The \fIattrs\fR argument is a
|
||||
|
|
|
@ -71,6 +71,7 @@ enum {
|
|||
ACT_CHANGE_ID,
|
||||
ACT_DUMP,
|
||||
ACT_LIST,
|
||||
ACT_LIST_FREE,
|
||||
ACT_LIST_TYPES,
|
||||
ACT_SHOW_SIZE,
|
||||
ACT_SHOW_GEOM,
|
||||
|
@ -360,6 +361,28 @@ static int command_list_partitions(struct sfdisk *sf, int argc, char **argv)
|
|||
return 0;
|
||||
}
|
||||
|
||||
/*
|
||||
* sfdisk --list-free [<device ..]
|
||||
*/
|
||||
static int command_list_freespace(struct sfdisk *sf, int argc, char **argv)
|
||||
{
|
||||
fdisk_enable_listonly(sf->cxt, 1);
|
||||
|
||||
if (argc) {
|
||||
int i, ct = 0;
|
||||
|
||||
for (i = 0; i < argc; i++) {
|
||||
if (ct)
|
||||
fputs("\n\n", stdout);
|
||||
if (print_device_freespace(sf->cxt, argv[i], 0) == 0)
|
||||
ct++;
|
||||
}
|
||||
} else
|
||||
print_all_devices_freespace(sf->cxt);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
/*
|
||||
* sfdisk --list-types
|
||||
*/
|
||||
|
@ -1413,6 +1436,7 @@ static void __attribute__ ((__noreturn__)) usage(FILE *out)
|
|||
fputs(_(" -J, --json <dev> dump partition table in JSON format\n"), out);
|
||||
fputs(_(" -g, --show-geometry [<dev> ...] list geometry of all or specified devices\n"), out);
|
||||
fputs(_(" -l, --list [<dev> ...] list partitions of each device\n"), out);
|
||||
fputs(_(" -F, --list-free [<dev> ...] list unpartitions free areas of each device\n"), out);
|
||||
fputs(_(" -s, --show-size [<dev> ...] list sizes of all or specified devices\n"), out);
|
||||
fputs(_(" -T, --list-types print the recognized types (see -X)\n"), out);
|
||||
fputs(_(" -V, --verify [<dev> ...] test whether partitions seem correct\n"), out);
|
||||
|
@ -1496,6 +1520,7 @@ int main(int argc, char *argv[])
|
|||
{ "label", required_argument, NULL, 'X' },
|
||||
{ "label-nested", required_argument, NULL, 'Y' },
|
||||
{ "list", no_argument, NULL, 'l' },
|
||||
{ "list-free", no_argument, NULL, 'F' },
|
||||
{ "list-types", no_argument, NULL, 'T' },
|
||||
{ "no-act", no_argument, NULL, 'n' },
|
||||
{ "no-reread", no_argument, NULL, OPT_NOREREAD },
|
||||
|
@ -1527,7 +1552,7 @@ int main(int argc, char *argv[])
|
|||
textdomain(PACKAGE);
|
||||
atexit(close_stdout);
|
||||
|
||||
while ((c = getopt_long(argc, argv, "aAbcdfghJlLo:O:nN:qsTu:vVX:Y:",
|
||||
while ((c = getopt_long(argc, argv, "aAbcdfFghJlLo:O:nN:qsTu:vVX:Y:",
|
||||
longopts, &longidx)) != -1) {
|
||||
switch(c) {
|
||||
case 'A':
|
||||
|
@ -1556,6 +1581,9 @@ int main(int argc, char *argv[])
|
|||
case 'd':
|
||||
sf->act = ACT_DUMP;
|
||||
break;
|
||||
case 'F':
|
||||
sf->act = ACT_LIST_FREE;
|
||||
break;
|
||||
case 'f':
|
||||
sf->force = 1;
|
||||
break;
|
||||
|
@ -1667,6 +1695,10 @@ int main(int argc, char *argv[])
|
|||
rc = command_list_types(sf);
|
||||
break;
|
||||
|
||||
case ACT_LIST_FREE:
|
||||
rc = command_list_freespace(sf, argc - optind, argv + optind);
|
||||
break;
|
||||
|
||||
case ACT_FDISK:
|
||||
rc = command_fdisk(sf, argc - optind, argv + optind);
|
||||
break;
|
||||
|
|
Loading…
Reference in New Issue