Author: jmallett Date: Wed Nov 27 17:59:13 2013 New Revision: 258686 URL: http://svnweb.freebsd.org/changeset/base/258686
Log: 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") Modified: head/sbin/fdisk/fdisk.c Modified: head/sbin/fdisk/fdisk.c ============================================================================== --- head/sbin/fdisk/fdisk.c Wed Nov 27 16:08:33 2013 (r258685) +++ head/sbin/fdisk/fdisk.c Wed Nov 27 17:59:13 2013 (r258686) @@ -75,7 +75,8 @@ static int secsize = 0; /* the sensed s 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 _______________________________________________ svn-src-all@freebsd.org mailing list http://lists.freebsd.org/mailman/listinfo/svn-src-all To unsubscribe, send any mail to "svn-src-all-unsubscr...@freebsd.org"