From owner-freebsd-current Sun Jan 12 20:15: 2 2003 Delivered-To: freebsd-current@freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id B5F4D37B401 for ; Sun, 12 Jan 2003 20:15:00 -0800 (PST) Received: from rootlabs.com (root.org [67.118.192.226]) by mx1.FreeBSD.org (Postfix) with SMTP id 8BDE043EB2 for ; Sun, 12 Jan 2003 20:14:56 -0800 (PST) (envelope-from nate@rootlabs.com) Received: (qmail 33058 invoked by uid 1000); 13 Jan 2003 04:14:57 -0000 Date: Sun, 12 Jan 2003 20:14:57 -0800 (PST) From: Nate Lawson To: Sean Kelly Cc: current@freebsd.org Subject: Re: fdisk issues? In-Reply-To: <20030113040247.GA816@edgemaster.zombie.org> Message-ID: MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII Sender: owner-freebsd-current@FreeBSD.ORG Precedence: bulk List-ID: List-Archive: (Web Archive) List-Help: (List Instructions) List-Subscribe: List-Unsubscribe: X-Loop: FreeBSD.ORG On Sun, 12 Jan 2003, Sean Kelly wrote: > edgemaster# fdisk ad1 > Floating exception (core dumped) > > In get_params, we have: > ... > 780 error = ioctl(fd, DIOCGFWSECTORS, &u); > 781 if (error == 0) > 782 sectors = dos_sectors = u; > 783 error = ioctl(fd, DIOCGFWHEADS, &u); > 784 if (error == 0) > 785 heads = dos_heads = u; > 786 > 787 dos_cylsecs = cylsecs = heads * sectors; > 788 disksecs = cyls * heads * sectors; > ... > 794 error = ioctl(fd, DIOCGMEDIASIZE, &o); > 795 if (error == 0) { > 796 disksecs = o / u; > 797 cyls = dos_cyls = o / (u * dos_heads * dos_sectors); > 798 } > ... Any disk which returns 0 for these params is broken. I put in a workaround for the GEOM case: sys/geom/geom_dev.c revision 1.26 date: 2002/10/15 21:28:50; author: njl; state: Exp; lines: +8 -0 Return an error if the drive reports heads/sectors that do not make sense. This fixes a divide by zero in fdisk(8) There should probably be an appropriate error check in fdisk to catch problems like this instead of dumping core. The more important question is "who in the kernel is setting these to 0?" as that part needs work too. -Nate To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-current" in the body of the message