Subject: DIOCGDINFO handling by fdc(4)
To: None <>
From: Klaus Heinz <>
List: tech-kern
Date: 09/12/2006 20:24:55

today I was trying to use sysutils/grub from pkgsrc and ended up with grub
aborting with SIGFPE when I did "setup (fd0)".

After a little research I discovered that grub uses DIOCGDINFO on /dev/rfd0a
(a 3.5" floppy disk) and because the returned disklabel is very thinly
populated (everything 0 but d_type (=3DDTYPE_FLOPPY), d_secsize (=3D512),
d_secpercyl (=3D36) and d_secperunit (=3D0x1FFFFFFF)) there is an arithmetic
exception when grub tries to divide by 0.

Can anyone tell my why the disklabel returned in
src/sys/dev/isa/fd.c:fdioctl() does not contain some more data than just
d_secpercyl, d_type and d_secsize?

=46rom the code I suppose that we could also retrieve the sectors per
track, number of heads and number of cylinders from struct fd_softc and
return them as d_nsectors, d_ntracks and d_ncylinders, respectively,
in the disklabel for DIOCGDINFO.

d_secperunit looks completely wrong to me, the floppy drive does not
have 0x1FFFFFFF sectors but I could not see where that value comes from.

Everything done with NetBSD/i386 3.1 RC2 but fd.c:fdioctl() has not really
changed in -current, as far as I can see.