[PATCH] fdisk: let cfdisk display cylinders beyond 1024

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



There is absolutely no reason why cfdisk should not display
cylinders beyond 1024. The number of cylinders needs to be
truncated only for the CHS field.

The attached patch fixes this. A separate patch for the translations
will follow.

Signed-off-by: Peter Breitenlohner <peb@xxxxxxxxxxxx>
	Don't truncate displayed cylinders, only when packed as CHS

	FIXME: Needs translations!

diff -ur util-linux-ng-2.13.orig/fdisk/cfdisk.c util-linux-ng-2.13/fdisk/cfdisk.c
--- util-linux-ng-2.13.orig/fdisk/cfdisk.c	2007-08-13 12:39:46.000000000 +0200
+++ util-linux-ng-2.13/fdisk/cfdisk.c	2007-10-19 20:24:59.000000000 +0200
@@ -180,8 +180,6 @@
 
 static void
 set_hsc0(unsigned char *h, unsigned char *s, int *c, long long sector) {
-	if (sector >= 1024*cylinder_size)
-		sector = 1024*cylinder_size - 1;
 	*s = sector % sectors + 1;
 	sector /= sectors;
 	*h = sector % heads;
@@ -194,6 +192,8 @@
 	long long sector) {
 	int cc;
 
+	if (sector >= 1024*cylinder_size)
+		sector = 1024*cylinder_size - 1;
 	set_hsc0(h, s, &cc, sector);
 	*c = cc & 0xFF;
 	*s |= (cc >> 2) & 0xC0;
@@ -2163,7 +2163,7 @@
 	set_hsc0(&eh, &es, &ec, end);
     }
 
-    fp_printf(fp, "%2d  0x%02X %4d %4d %4d 0x%02X %4d %4d %4d %11lld %11lld\n",
+    fp_printf(fp, "%2d  0x%02X %4d %4d %5d 0x%02X %4d %4d %5d %11lld %11lld\n",
 	      num+1, flags, sh, ss, sc, id, eh, es, ec, first, size);
 }
 
@@ -2201,9 +2201,9 @@
     fp_printf(fp, _("Partition Table for %s\n"), disk_device);
     fp_printf(fp, "\n");
     /* Three-line heading. Read "Start Sector" etc vertically. */
-    fp_printf(fp, _("         ---Starting---      ----Ending----    Start     Number of\n"));
-    fp_printf(fp, _(" # Flags Head Sect Cyl   ID  Head Sect Cyl     Sector    Sectors\n"));
-    fp_printf(fp, _("-- ----- ---- ---- ---- ---- ---- ---- ---- ----------- -----------\n"));
+    fp_printf(fp, _("         ---Starting----      ----Ending-----    Start     Number of\n"));
+    fp_printf(fp, _(" # Flags Head Sect  Cyl   ID  Head Sect  Cyl     Sector    Sectors\n"));
+    fp_printf(fp, _("-- ----- ---- ---- ----- ---- ---- ---- ----- ----------- -----------\n"));
 
     for (i = 0; i < 4; i++) {
 	for (j = 0;

[Index of Archives]     [Netdev]     [Ethernet Bridging]     [Linux Wireless]     [Kernel Newbies]     [Security]     [Linux for Hams]     [Netfilter]     [Bugtraq]     [Yosemite News]     [MIPS Linux]     [ARM Linux]     [Linux RAID]     [Linux Admin]     [Samba]

  Powered by Linux