[PATCH] Fix fdisk and cfdisk to be consistent about maximum heads

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

 



Fix fdisk and cfdisk to be consistent about maximum heads

Without this patch, fdisk allows up to 256 heads to be set via the menu, but
only up to 255 heads by command line -H. Similarly, cfdisk's -H option also
enforces heads <= 255 instead of heads <= 256.

The strange limit of 256 comes about because (heads - 1) should fit in a
single byte for legacy CHS. Geometries of 256 heads and 32 sectors are seen
in disks from other operating systems where cylinder-aligned partitions
which are also aligned to a 4MB boundary are wanted.

Signed-off-by: Chris Webb <chris@xxxxxxxxxxxx>
---
 fdisk/cfdisk.c |  2 +-
 fdisk/fdisk.c  |  2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/fdisk/cfdisk.c b/fdisk/cfdisk.c
--- a/fdisk/cfdisk.c
+++ b/fdisk/cfdisk.c
@@ -107,7 +107,7 @@
 
 #define SECTOR_SIZE 512
 
-#define MAX_HEADS 255
+#define MAX_HEADS 256
 #define MAX_SECTORS 63
 
 #define ACTIVE_FLAG 0x80
diff --git a/fdisk/fdisk.c b/fdisk/fdisk.c
--- a/fdisk/fdisk.c
+++ b/fdisk/fdisk.c
@@ -2601,7 +2601,7 @@
 			break;
 		case 'H':
 			user_heads = atoi(optarg);
-			if (user_heads <= 0 || user_heads >= 256)
+			if (user_heads <= 0 || user_heads > 256)
 				user_heads = 0;
 			break;
 		case 'S':


--
To unsubscribe from this list: send the line "unsubscribe util-linux-ng" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html

[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