From 4abdd7d2f8cea4f749015419d3966ee70325b5ca Mon Sep 17 00:00:00 2001 From: Kjell Wooding Date: Fri, 18 Jan 2002 08:33:11 +0000 Subject: Add disklabel-style editing for size/offset values in the partition tables. These values may now contain units, such as "300k" "500M" or "2G". (sectors, bytes, and cylinders are also supported.) This should largely eliminate the need for a calculator when using fdisk on large disks. --- sbin/fdisk/cmd.c | 15 ++++++++++----- 1 file changed, 10 insertions(+), 5 deletions(-) (limited to 'sbin/fdisk/cmd.c') diff --git a/sbin/fdisk/cmd.c b/sbin/fdisk/cmd.c index 470b0128a98..2781adbaae9 100644 --- a/sbin/fdisk/cmd.c +++ b/sbin/fdisk/cmd.c @@ -1,4 +1,4 @@ -/* $OpenBSD: cmd.c,v 1.28 2001/01/28 00:56:07 weingart Exp $ */ +/* $OpenBSD: cmd.c,v 1.29 2002/01/18 08:33:10 kjell Exp $ */ /* * Copyright (c) 1997 Tobias Weingartner @@ -175,15 +175,20 @@ Xedit(cmd, disk, mbr, tt, offset) u_int m; /* Get data */ - EDIT("Partition offset", ASK_DEC, pp->bs, 0, - disk->real->size, NULL); + pp->bs = getuint(disk, "offset", + "Starting sector for this partition.", pp->bs, + disk->real->size, 0, DO_CONVERSIONS | + (pp->id == FS_BSDFFS ? DO_ROUNDING : 0)); + m = MAX(pp->ns, disk->real->size - pp->bs); if ( m > disk->real->size - pp->bs) { /* dont have default value extend beyond end of disk */ m = disk->real->size - pp->bs; } - EDIT("Partition size", ASK_DEC, pp->ns, 1, - m, NULL); + pp->ns = getuint(disk, "size", "Size of the partition.", + pp->ns, m, pp->bs , DO_CONVERSIONS | + ((pp->id == FS_BSDFFS || pp->id == FS_SWAP) ? + DO_ROUNDING : 0)); /* Fix up CHS values */ PRT_fix_CHS(disk, pp, pn); -- cgit v1.2.3