summaryrefslogtreecommitdiffstats
path: root/fdisk/fdisk.c
diff options
context:
space:
mode:
authorKarel Zak2006-12-07 00:26:08 +0100
committerKarel Zak2006-12-07 00:26:08 +0100
commita5a16c68537f8c3e5e61c5fb1680ee9f82b70a4d (patch)
tree830565491cb6af2b456960d28c093054fa287e0b /fdisk/fdisk.c
parentImported from util-linux-2.11x tarball. (diff)
downloadkernel-qcow2-util-linux-a5a16c68537f8c3e5e61c5fb1680ee9f82b70a4d.tar.gz
kernel-qcow2-util-linux-a5a16c68537f8c3e5e61c5fb1680ee9f82b70a4d.tar.xz
kernel-qcow2-util-linux-a5a16c68537f8c3e5e61c5fb1680ee9f82b70a4d.zip
Imported from util-linux-2.11y tarball.
Diffstat (limited to 'fdisk/fdisk.c')
-rw-r--r--fdisk/fdisk.c33
1 files changed, 21 insertions, 12 deletions
diff --git a/fdisk/fdisk.c b/fdisk/fdisk.c
index 5ad15d9f3..32b6bc394 100644
--- a/fdisk/fdisk.c
+++ b/fdisk/fdisk.c
@@ -1081,11 +1081,14 @@ read_int(uint low, uint dflt, uint high, uint base, char *mesg)
continue;
if (*line_ptr == '+' || *line_ptr == '-') {
+ int minus = (*line_ptr == '-');
+ int absolute = 0;
+
i = atoi(line_ptr+1);
- if (*line_ptr == '-')
- i = -i;
+
while (isdigit(*++line_ptr))
use_default = 0;
+
switch (*line_ptr) {
case 'c':
case 'C':
@@ -1094,25 +1097,31 @@ read_int(uint low, uint dflt, uint high, uint base, char *mesg)
break;
case 'k':
case 'K':
- i *= 2;
- i /= (sector_size / 512);
- i /= units_per_sector;
+ absolute = 1000;
break;
case 'm':
case 'M':
- i *= 2048;
- i /= (sector_size / 512);
- i /= units_per_sector;
+ absolute = 1000000;
break;
case 'g':
case 'G':
- i *= 2048000;
- i /= (sector_size / 512);
- i /= units_per_sector;
+ absolute = 1000000000;
break;
default:
break;
}
+ if (absolute) {
+ unsigned long long bytes;
+ unsigned long unit;
+
+ bytes = (unsigned long long) i * absolute;
+ unit = sector_size * units_per_sector;
+ bytes += unit/2; /* round */
+ bytes /= unit;
+ i = bytes;
+ }
+ if (minus)
+ i = -i;
i += base;
} else {
i = atoi(line_ptr);
@@ -1457,7 +1466,7 @@ static void check_consistency(struct partition *p, int partition) {
/* Ending on cylinder boundary? */
if (peh != (heads - 1) || pes != sectors) {
- printf(_("Partition %i does not end on cylinder boundary:\n"),
+ printf(_("Partition %i does not end on cylinder boundary.\n"),
partition + 1);
#if 0
printf(_(" phys=(%d, %d, %d) "), pec, peh, pes);