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>

index | next in thread | previous in thread | raw e-mail

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 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

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 = {
        .d_version =    D_VERSION,
        .d_read =       yourdevice_read,
        .d_write =      yourdevice_write,
        .d_ioctl =      yourdevice_ioctl,     /* <--- or just ioctl? */
        .d_name =       "yourdevice",
};

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

> where's the problem?

-cpghost.

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


help

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