summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDenys Vlasenko2016-08-23 17:18:45 +0200
committerDenys Vlasenko2016-08-23 17:18:45 +0200
commit29483ffb075f1a64d2183ebe188b83f5704ba637 (patch)
tree16651b685d79ed5959c024a299df27b5ee5c8f36
parent607f2b404e992174d7c5956d11e8f35f78d2701f (diff)
downloadbusybox-29483ffb075f1a64d2183ebe188b83f5704ba637.zip
busybox-29483ffb075f1a64d2183ebe188b83f5704ba637.tar.gz
fdisk: tweak some messages
"Total allocated sectors 2021315 greater than the maximum 2020356" maximum what? Turns out, that's the CHS size of the disk. Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
-rw-r--r--util-linux/fdisk.c43
1 files changed, 24 insertions, 19 deletions
diff --git a/util-linux/fdisk.c b/util-linux/fdisk.c
index 6b5e388..a048dd9 100644
--- a/util-linux/fdisk.c
+++ b/util-linux/fdisk.c
@@ -1897,22 +1897,23 @@ static void
list_disk_geometry(void)
{
ullong bytes = ((ullong)total_number_of_sectors << 9);
- long megabytes = bytes / 1000000;
-
- if (megabytes < 10000)
- printf("\nDisk %s: %lu MB, %llu bytes\n",
- disk_device, megabytes, bytes);
- else
- printf("\nDisk %s: %lu.%lu GB, %llu bytes\n",
- disk_device, megabytes/1000, (megabytes/100)%10, bytes);
- printf("%u heads, %u sectors/track, %u cylinders",
- g_heads, g_sectors, g_cylinders);
- if (units_per_sector == 1)
- printf(", total %"SECT_FMT"u sectors",
- total_number_of_sectors / (sector_size/512));
- printf("\nUnits = %s of %u * %u = %u bytes\n\n",
+ ullong xbytes = bytes / (1024*1024);
+ char x = 'M';
+
+ if (xbytes >= 10000) {
+ xbytes += 512; /* fdisk util-linux 2.28 does this */
+ xbytes /= 1024;
+ x = 'G';
+ }
+ printf("Disk %s: %llu %cB, %llu bytes, %"SECT_FMT"u sectors\n"
+ "%u cylinders, %u heads, %u sectors/track\n"
+ "Units: %s of %u * %u = %u bytes\n\n",
+ disk_device, xbytes, x,
+ bytes, total_number_of_sectors,
+ g_cylinders, g_heads, g_sectors,
str_units(PLURAL),
- units_per_sector, sector_size, units_per_sector * sector_size);
+ units_per_sector, sector_size, units_per_sector * sector_size
+ );
}
/*
@@ -2277,6 +2278,7 @@ verify(void)
{
int i, j;
sector_t total = 1;
+ sector_t chs_size;
sector_t first[g_partitions], last[g_partitions];
struct partition *p;
@@ -2338,11 +2340,14 @@ verify(void)
}
}
- if (total > g_heads * g_sectors * g_cylinders)
- printf("Total allocated sectors %u greater than the maximum "
- "%u\n", total, g_heads * g_sectors * g_cylinders);
+ chs_size = (sector_t)g_heads * g_sectors * g_cylinders;
+ if (total > chs_size)
+ printf("Total allocated sectors %u"
+ " greater than CHS size %"SECT_FMT"u\n",
+ total, chs_size
+ );
else {
- total = g_heads * g_sectors * g_cylinders - total;
+ total = chs_size - total;
if (total != 0)
printf("%"SECT_FMT"u unallocated sectors\n", total);
}