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>
This commit is contained in:
Denys Vlasenko 2016-08-23 17:18:45 +02:00
parent 607f2b404e
commit 29483ffb07

View File

@ -1897,22 +1897,23 @@ static void
list_disk_geometry(void) list_disk_geometry(void)
{ {
ullong bytes = ((ullong)total_number_of_sectors << 9); ullong bytes = ((ullong)total_number_of_sectors << 9);
long megabytes = bytes / 1000000; ullong xbytes = bytes / (1024*1024);
char x = 'M';
if (megabytes < 10000) if (xbytes >= 10000) {
printf("\nDisk %s: %lu MB, %llu bytes\n", xbytes += 512; /* fdisk util-linux 2.28 does this */
disk_device, megabytes, bytes); xbytes /= 1024;
else x = 'G';
printf("\nDisk %s: %lu.%lu GB, %llu bytes\n", }
disk_device, megabytes/1000, (megabytes/100)%10, bytes); printf("Disk %s: %llu %cB, %llu bytes, %"SECT_FMT"u sectors\n"
printf("%u heads, %u sectors/track, %u cylinders", "%u cylinders, %u heads, %u sectors/track\n"
g_heads, g_sectors, g_cylinders); "Units: %s of %u * %u = %u bytes\n\n",
if (units_per_sector == 1) disk_device, xbytes, x,
printf(", total %"SECT_FMT"u sectors", bytes, total_number_of_sectors,
total_number_of_sectors / (sector_size/512)); g_cylinders, g_heads, g_sectors,
printf("\nUnits = %s of %u * %u = %u bytes\n\n",
str_units(PLURAL), 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; int i, j;
sector_t total = 1; sector_t total = 1;
sector_t chs_size;
sector_t first[g_partitions], last[g_partitions]; sector_t first[g_partitions], last[g_partitions];
struct partition *p; struct partition *p;
@ -2338,11 +2340,14 @@ verify(void)
} }
} }
if (total > g_heads * g_sectors * g_cylinders) chs_size = (sector_t)g_heads * g_sectors * g_cylinders;
printf("Total allocated sectors %u greater than the maximum " if (total > chs_size)
"%u\n", total, g_heads * g_sectors * g_cylinders); printf("Total allocated sectors %u"
" greater than CHS size %"SECT_FMT"u\n",
total, chs_size
);
else { else {
total = g_heads * g_sectors * g_cylinders - total; total = chs_size - total;
if (total != 0) if (total != 0)
printf("%"SECT_FMT"u unallocated sectors\n", total); printf("%"SECT_FMT"u unallocated sectors\n", total);
} }