Date: Mon, 27 Dec 2010 14:29:09 -0500 From: John Baldwin <jhb@FreeBSD.org> To: Mohammad Hedayati <hedayati.mo@gmail.com> Cc: freebsd-drivers@freebsd.org Subject: Re: Inappropriate ioctl for device Message-ID: <4D18E905.1060000@FreeBSD.org> In-Reply-To: <AANLkTikYuYEJ%2B48xz1qOe2p6Ev-C-WWCqbjO31PPZueQ@mail.gmail.com>
index | next in thread | previous in thread | raw e-mail
Mohammad Hedayati wrote:
> I'm writing a simple char device. So far everything went so good
> (read/write), but here I'm going to add support for ioctl.
>
> int
> ioctl(struct cdev *dev, u_long cmd, caddr_t data, int flags, struct thread *td)
> {
> int error = 0;
> uprintf("Here...\n");
> return(error);
> }
> and I'm calling it here:
>
> len = ioctl(cd, 0);
> perror("ioctl");
>
> but when runnig it says:
>
> ioctl: Inappropriate ioctl for device
>
> where's the problem?
0 is not a valid ioctl code. A valid ioctl code has to have at least
one of IOC_VOID, IOC_IN, or IOC_OUT set. Also, if it has either IOC_IN
or IOC_OUT set, it must have a non-zero size field. You should use one
of the _IO* macros from <sys/iocomm.h> to define a valid ioctl code and
pass that to your driver.
--
John Baldwin
home |
help
Want to link to this message? Use this
URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?4D18E905.1060000>
