From owner-freebsd-questions@FreeBSD.ORG Fri Dec 24 14:47:26 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 8F5BD1065670 for ; Fri, 24 Dec 2010 14:47:26 +0000 (UTC) (envelope-from hedayati.mo@gmail.com) Received: from mail-ww0-f50.google.com (mail-ww0-f50.google.com [74.125.82.50]) by mx1.freebsd.org (Postfix) with ESMTP id 205AF8FC12 for ; Fri, 24 Dec 2010 14:47:25 +0000 (UTC) Received: by wwf26 with SMTP id 26so6807629wwf.31 for ; Fri, 24 Dec 2010 06:47:25 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:received:mime-version:received:in-reply-to :references:from:date:message-id:subject:to:content-type; bh=hTAPNKLXvbKjuccV52QZAgASpgrQAgPaEA2njMTudqg=; b=pgwYQWmk9E2rJs3Pwk+pcPo0sq83YetWMhnWo1H1hM2BnnHlGrd5Ea6MHR13WLLw04 q5WjVBWsgPG4o1mjSXBNO025fJA9qQ0E6Xcph48e0DZTcFTWy+R5LqdcIaN0bDbaL5CA GFXDoDumkAaukl36fNFy1Yiq2Y8L+rCJiTDRM= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=mime-version:in-reply-to:references:from:date:message-id:subject:to :content-type; b=QCHOgdWm7lru6x96BFv1C/PscEXTwcguiWWirVXehtPpACpFu9JxnFlM+CirEGujXQ qKsC2ayLJdM4tNEXNphmkEOHU5wYHtCaWcTImqvAJwTNIutA5Xwi0+AFAZ0mYyw7u2QX 1JiRF7WPJhqQo68pPi+2XEj91gdd4yJLRkVqE= Received: by 10.227.146.145 with SMTP id h17mr5768703wbv.60.1293202044674; Fri, 24 Dec 2010 06:47:24 -0800 (PST) MIME-Version: 1.0 Received: by 10.227.143.202 with HTTP; Fri, 24 Dec 2010 06:46:44 -0800 (PST) In-Reply-To: References: From: Mohammad Hedayati Date: Fri, 24 Dec 2010 18:16:44 +0330 Message-ID: To: freebsd-questions@freebsd.org Content-Type: text/plain; charset=UTF-8 X-Content-Filtered-By: Mailman/MimeDel 2.1.5 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:47:26 -0000 On Fri, Dec 24, 2010 at 6:00 PM, C. P. Ghost wrote: > 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 > 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/ > Yes, I did. Thanks!