Skip site navigation (1)Skip section navigation (2)
Date:      Sun, 12 Jan 2003 20:14:57 -0800 (PST)
From:      Nate Lawson <nate@root.org>
To:        Sean Kelly <smkelly@zombie.org>
Cc:        current@freebsd.org
Subject:   Re: fdisk issues?
Message-ID:  <Pine.BSF.4.21.0301122009290.33006-100000@root.org>
In-Reply-To: <20030113040247.GA816@edgemaster.zombie.org>

next in thread | previous in thread | raw e-mail | index | archive | help
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




Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?Pine.BSF.4.21.0301122009290.33006-100000>