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@arachsys.com>
#define SECTOR_SIZE 512
-#define MAX_HEADS 255
+#define MAX_HEADS 256
#define MAX_SECTORS 63
#define ACTIVE_FLAG 0x80
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':