From owner-freebsd-hackers@FreeBSD.ORG Fri Dec 24 17:44:04 2010 Return-Path: Delivered-To: freebsd-hackers@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id B14CA106566B for ; Fri, 24 Dec 2010 17:44:04 +0000 (UTC) (envelope-from gljennjohn@googlemail.com) Received: from mail-bw0-f54.google.com (mail-bw0-f54.google.com [209.85.214.54]) by mx1.freebsd.org (Postfix) with ESMTP id 3597E8FC14 for ; Fri, 24 Dec 2010 17:44:03 +0000 (UTC) Received: by bwz12 with SMTP id 12so1236495bwz.13 for ; Fri, 24 Dec 2010 09:44:02 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=googlemail.com; s=gamma; h=domainkey-signature:received:received:date:from:to:cc:subject :message-id:in-reply-to:references:reply-to:x-mailer:mime-version :content-type:content-transfer-encoding; bh=hGMNWtBqxNhnGbvoguS1uE1BZbzK9noHfm5bDmtyxnc=; b=ay5ivu+S3AXqLTMRJ7ipOI8EMq9O2Gc6R7VDe+VS3kwWFjdizRujghbOyaqby9EdSf WKSYE0odI5J3bFLspPg7Ij472qdj37ey4tzjgkPcOrfIHYeBFwjuY52iFvD1BFTLWDQA 9N/iRvnDug0MwAHhk2YJTKkzcLFTQxHyQyDk8= DomainKey-Signature: a=rsa-sha1; c=nofws; d=googlemail.com; s=gamma; h=date:from:to:cc:subject:message-id:in-reply-to:references:reply-to :x-mailer:mime-version:content-type:content-transfer-encoding; b=gGFwXTNxyLh3h+YHJ1o3wZ5R9kZHFW6TZwAcDiQ9FUOfLt5uf+17cUw/7of8KNNNTy gxkKXvvnAe6eVh/naftY1AQabO5Ur3hn7+whPKAEyXVlpirTyBwFtCPkkcvIWj+nV4Ks dIAAoGT6pCofbrdPPPuVAB81RLQZDggPM5EeA= Received: by 10.204.50.200 with SMTP id a8mr981493bkg.209.1293212642650; Fri, 24 Dec 2010 09:44:02 -0800 (PST) Received: from ernst.jennejohn.org (p578E395D.dip.t-dialin.net [87.142.57.93]) by mx.google.com with ESMTPS id q18sm6323795bka.15.2010.12.24.09.44.00 (version=TLSv1/SSLv3 cipher=RC4-MD5); Fri, 24 Dec 2010 09:44:01 -0800 (PST) Date: Fri, 24 Dec 2010 18:43:57 +0100 From: Gary Jennejohn To: freebsd-hackers@freebsd.org Message-ID: <20101224184357.1e8f03bb@ernst.jennejohn.org> In-Reply-To: References: <20101224170144.1d734e3c@ernst.jennejohn.org> X-Mailer: Claws Mail 3.7.8 (GTK+ 2.18.7; amd64-portbld-freebsd9.0) Mime-Version: 1.0 Content-Type: text/plain; charset=US-ASCII Content-Transfer-Encoding: 7bit Cc: Mohammad Hedayati Subject: Re: Inappropriate ioctl for device X-BeenThere: freebsd-hackers@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list Reply-To: gljennjohn@googlemail.com List-Id: Technical Discussions relating to FreeBSD List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 24 Dec 2010 17:44:04 -0000 On Fri, 24 Dec 2010 19:37:37 +0330 Mohammad Hedayati wrote: > On Fri, Dec 24, 2010 at 7:31 PM, Gary Jennejohn > wrote: > > > On Fri, 24 Dec 2010 18:17:18 +0330 > > 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 > > > > Carefully read ioctl(2) and consider that you're passing in 0 as the cmd. > > If you still don't understand your error, post again. > > > > Hint: look at /sys/kern/sys_generic.c:^ioctl > > > > -- > > Gary Jennejohn > > > > It was a misspelling, I'm doing as bellow, if you mean the u_long. > > unsinged long cmd = 0; > len = ioctl(cd, cmd); > No, that isn't what I meant. Read the kernel code - cmd = 0 is not legal. -- Gary Jennejohn