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 [EMAIL PROTECTED]
with "unsubscribe freebsd-current" in the body of the message

Reply via email to