Skip site navigation (1)Skip section navigation (2)
Date:      Fri, 24 Dec 2010 15:30:36 +0100
From:      "C. P. Ghost" <cpghost@cordula.ws>
To:        Mohammad Hedayati <hedayati.mo@gmail.com>
Cc:        freebsd-questions@freebsd.org
Subject:   Re: Inappropriate ioctl for device
Message-ID:  <AANLkTinC4VROgD40GM1v7Mfdzk7_rtwQOFfKaa--0gC_@mail.gmail.com>
In-Reply-To: <AANLkTi=oUgvCMGtaayXnE%2BBW0nTbZSuuyXXkkOSg7Ccf@mail.gmail.com>
References:  <AANLkTi=oUgvCMGtaayXnE%2BBW0nTbZSuuyXXkkOSg7Ccf@mail.gmail.com>

next in thread | previous in thread | raw e-mail | index | archive | help
On Fri, Dec 24, 2010 at 11:21 AM, Mohammad Hedayati
<hedayati.mo@gmail.com> 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 threa=
d *td)
> {
> =A0 =A0 =A0int error =3D 0;
> =A0 =A0 =A0uprintf("Here...\n");
> =A0 =A0 =A0return(error);
> }
> and I'm calling it here:
>
> len =3D ioctl(cd, 0);
> perror("ioctl");
>
> but when runnig it says:
>
> ioctl: Inappropriate ioctl for device

Just a wild guess: are you sure you've hooked up your
ioctl() function to the struct cdevsw, i.e. something
like this?

static struct cdevsw yourdevice_cdevsw =3D {
        .d_version =3D    D_VERSION,
        .d_read =3D       yourdevice_read,
        .d_write =3D      yourdevice_write,
        .d_ioctl =3D      yourdevice_ioctl,     /* <--- or just ioctl? */
        .d_name =3D       "yourdevice",
};

Perhaps you could ask on freebsd-hackers@ list instead?

> where's the problem?

-cpghost.

--=20
Cordula's Web. http://www.cordula.ws/



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?AANLkTinC4VROgD40GM1v7Mfdzk7_rtwQOFfKaa--0gC_>