From f01a2e3e2f02342b3a967ce01d3e824a067d91f8 Mon Sep 17 00:00:00 2001 From: Chris Webb Date: Wed, 13 May 2009 15:54:23 +0100 Subject: [PATCH] fdisk: (and cfdisk) fix to be consistent about maximum heads 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 --- 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 index 96246803..fc0357d2 100644 --- 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 index ef75d4ce..aaa01a84 100644 --- a/fdisk/fdisk.c +++ b/fdisk/fdisk.c @@ -2623,7 +2623,7 @@ main(int argc, char **argv) { 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': -- 2.39.5