Performing Ioctls to Devices in Kernel

cd_freebsd cd_freebsd at gatorzone.com
Wed Jun 18 13:38:35 PDT 2003


I want to be able to send IOCTL commands to standard devices (fdd,cdrom,kbd) from my kernel driver. Whereas I can do reads and writes using the vn_rdwr commands, how do I do IOCTLS? VOP_IOCTL keeps giving me EINVAL when I try to send the DIOCGDINFO IOCTL.

My code is basically

NDINIT(&_VdFloppyND, LOOKUP, FOLLOW, UIO_SYSSPACE, "/dev/fd0", p);

vn_open(&_VdFloppyND, FREAD, 0);

osError = VOP_IOCTL(_VdFloppyND.ni_vp,
                    DIOCGDINFO,
                    (caddr_t)&dl,
                    0,              // fflags ???
                    p->p_ucred,
                    p);

Questions:
1) Is there something I am doing wrong?
2) Should I use something else other than vn_open/vn_rdwr/VOP_*?

The error occurs regardless whether the floppy is mounted or not.


More information about the freebsd-hackers mailing list