aboutsummaryrefslogtreecommitdiff
path: root/util-linux/fdisk.c
diff options
context:
space:
mode:
Diffstat (limited to 'util-linux/fdisk.c')
-rw-r--r--util-linux/fdisk.c33
1 files changed, 15 insertions, 18 deletions
diff --git a/util-linux/fdisk.c b/util-linux/fdisk.c
index f28d4fdd2..e58cb0fd1 100644
--- a/util-linux/fdisk.c
+++ b/util-linux/fdisk.c
@@ -299,9 +299,6 @@ static int get_boot(enum action what);
299static int get_boot(void); 299static int get_boot(void);
300#endif 300#endif
301 301
302#define PLURAL 0
303#define SINGULAR 1
304
305static sector_t get_start_sect(const struct partition *p); 302static sector_t get_start_sect(const struct partition *p);
306static sector_t get_nr_sects(const struct partition *p); 303static sector_t get_nr_sects(const struct partition *p);
307 304
@@ -591,18 +588,18 @@ partname(const char *dev, int pno, int lth)
591 return bufp; 588 return bufp;
592} 589}
593 590
591#if ENABLE_FEATURE_SGI_LABEL || ENABLE_FEATURE_OSF_LABEL
594static ALWAYS_INLINE struct partition * 592static ALWAYS_INLINE struct partition *
595get_part_table(int i) 593get_part_table(int i)
596{ 594{
597 return ptes[i].part_table; 595 return ptes[i].part_table;
598} 596}
597#endif
599 598
600static const char * 599static ALWAYS_INLINE const char *
601str_units(int n) 600str_units(void)
602{ /* n==1: use singular */ 601{
603 if (n == 1) 602 return display_in_cyl_units ? "cylinder" : "sector";
604 return display_in_cyl_units ? "cylinder" : "sector";
605 return display_in_cyl_units ? "cylinders" : "sectors";
606} 603}
607 604
608static int 605static int
@@ -1778,8 +1775,8 @@ change_units(void)
1778{ 1775{
1779 display_in_cyl_units = !display_in_cyl_units; 1776 display_in_cyl_units = !display_in_cyl_units;
1780 update_units(); 1777 update_units();
1781 printf("Changing display/entry units to %s\n", 1778 printf("Changing display/entry units to %ss\n",
1782 str_units(PLURAL)); 1779 str_units());
1783} 1780}
1784 1781
1785static void 1782static void
@@ -2030,8 +2027,7 @@ check_consistency(const struct partition *p, int partition)
2030static void 2027static void
2031list_disk_geometry(void) 2028list_disk_geometry(void)
2032{ 2029{
2033 ullong bytes = ((ullong)total_number_of_sectors << 9); 2030 ullong xbytes = total_number_of_sectors / (1024*1024 / 512);
2034 ullong xbytes = bytes / (1024*1024);
2035 char x = 'M'; 2031 char x = 'M';
2036 2032
2037 if (xbytes >= 10000) { 2033 if (xbytes >= 10000) {
@@ -2041,11 +2037,12 @@ list_disk_geometry(void)
2041 } 2037 }
2042 printf("Disk %s: %llu %cB, %llu bytes, %"SECT_FMT"u sectors\n" 2038 printf("Disk %s: %llu %cB, %llu bytes, %"SECT_FMT"u sectors\n"
2043 "%u cylinders, %u heads, %u sectors/track\n" 2039 "%u cylinders, %u heads, %u sectors/track\n"
2044 "Units: %s of %u * %u = %u bytes\n\n", 2040 "Units: %ss of %u * %u = %u bytes\n"
2041 "\n",
2045 disk_device, xbytes, x, 2042 disk_device, xbytes, x,
2046 bytes, total_number_of_sectors, 2043 ((ullong)total_number_of_sectors * 512), total_number_of_sectors,
2047 g_cylinders, g_heads, g_sectors, 2044 g_cylinders, g_heads, g_sectors,
2048 str_units(PLURAL), 2045 str_units(),
2049 units_per_sector, sector_size, units_per_sector * sector_size 2046 units_per_sector, sector_size, units_per_sector * sector_size
2050 ); 2047 );
2051} 2048}
@@ -2486,7 +2483,7 @@ add_partition(int n, int sys)
2486 for (i = 0; i < g_partitions; i++) 2483 for (i = 0; i < g_partitions; i++)
2487 first[i] = (cround(first[i]) - 1) * units_per_sector; 2484 first[i] = (cround(first[i]) - 1) * units_per_sector;
2488 2485
2489 snprintf(mesg, sizeof(mesg), "First %s", str_units(SINGULAR)); 2486 snprintf(mesg, sizeof(mesg), "First %s", str_units());
2490 do { 2487 do {
2491 temp = start; 2488 temp = start;
2492 for (i = 0; i < g_partitions; i++) { 2489 for (i = 0; i < g_partitions; i++) {
@@ -2548,7 +2545,7 @@ add_partition(int n, int sys)
2548 } else { 2545 } else {
2549 snprintf(mesg, sizeof(mesg), 2546 snprintf(mesg, sizeof(mesg),
2550 "Last %s or +size{,K,M,G,T}", 2547 "Last %s or +size{,K,M,G,T}",
2551 str_units(SINGULAR) 2548 str_units()
2552 ); 2549 );
2553 stop = read_int(cround(start), cround(limit), cround(limit), cround(start), mesg); 2550 stop = read_int(cround(start), cround(limit), cround(limit), cround(start), mesg);
2554 if (display_in_cyl_units) { 2551 if (display_in_cyl_units) {