aboutsummaryrefslogtreecommitdiffstats
path: root/disk-utils/fdisk-menu.c
diff options
context:
space:
mode:
authorKarel Zak <kzak@redhat.com>2024-04-16 13:36:32 +0200
committerKarel Zak <kzak@redhat.com>2024-04-17 09:38:52 +0200
commita4c0dce86bcdb3a785667ea1f96ed4127fa0d545 (patch)
tree0f34afc1695fbbb5bcd54cf60893643c495ebc9f /disk-utils/fdisk-menu.c
parent7817415a5538354dfa24532f3420bfd3e74df795 (diff)
downloadutil-linux-a4c0dce86bcdb3a785667ea1f96ed4127fa0d545.tar.gz
fdisk: add 'T' command to discard sectors
We currently have blkdiscard(8), but it can be difficult to use for unpartitioned areas or for partitions when working with a whole-disk device. This commit adds BLKDISCARD support to fdisk, so that the user does not have to specify any range, but instead follows the partition table. Addresses: https://github.com/util-linux/util-linux/issues/2804 Signed-off-by: Karel Zak <kzak@redhat.com>
Diffstat (limited to 'disk-utils/fdisk-menu.c')
-rw-r--r--disk-utils/fdisk-menu.c5
1 files changed, 5 insertions, 0 deletions
diff --git a/disk-utils/fdisk-menu.c b/disk-utils/fdisk-menu.c
index 4c6a918934..717554b0e3 100644
--- a/disk-utils/fdisk-menu.c
+++ b/disk-utils/fdisk-menu.c
@@ -112,6 +112,7 @@ static const struct menu menu_generic = {
MENU_BENT_E('v', N_("verify the partition table"), FDISK_DISKLABEL_BSD),
MENU_ENT ('i', N_("print information about a partition")),
MENU_ENT ('e', N_("resize a partition")),
+ MENU_ENT ('T', N_("discard (trim) sectors")),
MENU_XENT('d', N_("print the raw data of the first sector from the device")),
MENU_XENT('D', N_("print the raw data of the disklabel from the device")),
@@ -714,6 +715,10 @@ static int generic_menu_cb(struct fdisk_context **cxt0,
fdisk_unref_context(cxt);
}
break;
+ case 'T':
+ /* discard (trim) */
+ discard_sectors(cxt);
+ break;
}
return rc;