From owner-freebsd-questions@FreeBSD.ORG Fri Dec 24 14:30:38 2010 Return-Path: Delivered-To: freebsd-questions@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 482F81065673 for ; Fri, 24 Dec 2010 14:30:38 +0000 (UTC) (envelope-from cpghost@cordula.ws) Received: from mail-qy0-f175.google.com (mail-qy0-f175.google.com [209.85.216.175]) by mx1.freebsd.org (Postfix) with ESMTP id 0EB188FC27 for ; Fri, 24 Dec 2010 14:30:37 +0000 (UTC) Received: by qyk8 with SMTP id 8so7571773qyk.13 for ; Fri, 24 Dec 2010 06:30:37 -0800 (PST) MIME-Version: 1.0 Received: by 10.229.213.13 with SMTP id gu13mr4639982qcb.196.1293201036594; Fri, 24 Dec 2010 06:30:36 -0800 (PST) Received: by 10.229.238.70 with HTTP; Fri, 24 Dec 2010 06:30:36 -0800 (PST) X-Originating-IP: [93.221.165.156] In-Reply-To: References: Date: Fri, 24 Dec 2010 15:30:36 +0100 Message-ID: From: "C. P. Ghost" To: Mohammad Hedayati Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable Cc: freebsd-questions@freebsd.org Subject: Re: Inappropriate ioctl for device X-BeenThere: freebsd-questions@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: User questions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 24 Dec 2010 14:30:38 -0000 On Fri, Dec 24, 2010 at 11:21 AM, 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 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/