diff options
author | Awal Garg | 2018-07-28 15:20:35 +0200 |
---|---|---|
committer | Karel Zak | 2018-07-31 14:54:12 +0200 |
commit | 757cefbb61dd22254ae8441f7caed39be7c59483 (patch) | |
tree | 419734d3d5afd00ffc9f8ebc6bdca2d2796783d6 /disk-utils | |
parent | hwclock: remove ntpd from man page (diff) | |
download | kernel-qcow2-util-linux-757cefbb61dd22254ae8441f7caed39be7c59483.tar.gz kernel-qcow2-util-linux-757cefbb61dd22254ae8441f7caed39be7c59483.tar.xz kernel-qcow2-util-linux-757cefbb61dd22254ae8441f7caed39be7c59483.zip |
libfdisk: Accept negative numbers for last sector input
[kzak@redhat.com: - add note to the man page
- add '-' to the dialog query
- cleanup functions names and libfdisk.sym]
Signed-off-by: Karel Zak <kzak@redhat.com>
Diffstat (limited to 'disk-utils')
-rw-r--r-- | disk-utils/fdisk.8 | 17 | ||||
-rw-r--r-- | disk-utils/fdisk.c | 2 |
2 files changed, 12 insertions, 7 deletions
diff --git a/disk-utils/fdisk.8 b/disk-utils/fdisk.8 index 91c6b6f84..430c96c3d 100644 --- a/disk-utils/fdisk.8 +++ b/disk-utils/fdisk.8 @@ -33,7 +33,7 @@ All partitioning is driven by device I/O limits (the topology) by default. is able to optimize the disk layout for a 4K-sector size and use an alignment offset on modern devices for MBR and GPT. It is always a good idea to follow \fBfdisk\fR's defaults as the default values (e.g. first and last partition sectors) and partition -sizes specified by the +<size>{M,G,...} notation are always aligned according +sizes specified by the +/-<size>{M,G,...} notation are always aligned according to the device properties. Note that @@ -161,16 +161,19 @@ documentation (the Documentation/devices.txt file). .SH SIZES The "last sector" dialog accepts partition size specified by number of sectors -or by +<size>{K,B,M,G,...} notation. +or by +/-<size>{K,B,M,G,...} notation. If the size is prefixed by '+' then it is interpreted as relative to the -partition first sector. In this case the size is expected in bytes and the -number may be followed by the multiplicative suffixes KiB=1024, MiB=1024*1024, -and so on for GiB, TiB, PiB, EiB, ZiB and YiB. The "iB" is optional, e.g. "K" -has the same meaning as "KiB". +partition first sector. If the size is prefixed by '-' then it is interpreted +as relative to the high limit (last available sector for the partition). + +In the case the size is specified in bytes than the number may be followed by +the multiplicative suffixes KiB=1024, MiB=1024*1024, and so on for GiB, TiB, +PiB, EiB, ZiB and YiB. The "iB" is optional, e.g. "K" has the same meaning as +"KiB". The relative sizes are always aligned according to device I/O limits. The -+<size>{K,B,M,G,...} notation is recommended. ++/-<size>{K,B,M,G,...} notation is recommended. For backward compatibility fdisk also accepts the suffixes KB=1000, MB=1000*1000, and so on for GB, TB, PB, EB, ZB and YB. These 10^N suffixes diff --git a/disk-utils/fdisk.c b/disk-utils/fdisk.c index 73525fa51..ed4db8bd0 100644 --- a/disk-utils/fdisk.c +++ b/disk-utils/fdisk.c @@ -357,6 +357,8 @@ static int ask_offset(struct fdisk_context *cxt, } if (sig == '+') num += base; + else if (sig == '-' && fdisk_ask_number_is_wrap_negative(ask)) + num = high - num; else if (sig == '-') num = base - num; |