diff options
author | jmallett <jmallett@FreeBSD.org> | 2013-11-27 17:59:13 +0000 |
---|---|---|
committer | jmallett <jmallett@FreeBSD.org> | 2013-11-27 17:59:13 +0000 |
commit | 3cb4d3eea83ac358d0b81378bcd3f9daeff9d8dc (patch) | |
tree | b105d9a7d148511a3ea675096dacdc97350d5217 | |
parent | 72d47a0e82d67027747995da5d97d696bfe5e637 (diff) | |
download | FreeBSD-src-3cb4d3eea83ac358d0b81378bcd3f9daeff9d8dc.zip FreeBSD-src-3cb4d3eea83ac358d0b81378bcd3f9daeff9d8dc.tar.gz |
Fix fdisk(8) to create 2TB partitions on disks larger than 2TB, rather than
only being able to create 1TB partitions:
o) Use an unsigned 32-bit quantity to store the number of disk sectors.
o) Detect overflow of said 32-bit quantity and clamp to 2^32.
o) Rather than returning the disk sector count from get_params, return 0 on
success, since its return value is only ever compared to -1 to detect
failure. This would cause returning 2^32 sectors to be interpreted as an
error.
Reviewed by: bde ("good for a quick fix")
-rw-r--r-- | sbin/fdisk/fdisk.c | 10 |
1 files changed, 7 insertions, 3 deletions
diff --git a/sbin/fdisk/fdisk.c b/sbin/fdisk/fdisk.c index da5af0c..34b96ef 100644 --- a/sbin/fdisk/fdisk.c +++ b/sbin/fdisk/fdisk.c @@ -75,7 +75,8 @@ static int secsize = 0; /* the sensed sector size */ static char *disk; -static int cyls, sectors, heads, cylsecs, disksecs; +static int cyls, sectors, heads, cylsecs; +static u_int32_t disksecs; struct mboot { unsigned char *bootinst; /* boot code */ @@ -873,10 +874,13 @@ get_params() o = g_mediasize(fd); if (o < 0) return (-1); - disksecs = o / u; + if (o / u <= NO_DISK_SECTORS) + disksecs = o / u; + else + disksecs = NO_DISK_SECTORS; cyls = dos_cyls = o / (u * dos_heads * dos_sectors); - return (disksecs); + return (0); } static int |