From owner-freebsd-hackers@FreeBSD.ORG Fri Dec 24 16:08:19 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 137FB1065673 for ; Fri, 24 Dec 2010 16:08:19 +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 9C8F18FC14 for ; Fri, 24 Dec 2010 16:08:18 +0000 (UTC) Received: by wwf26 with SMTP id 26so6862349wwf.31 for ; Fri, 24 Dec 2010 08:08:17 -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=5ru7VlJ6nfIkEHwZ3KASl6m168CD1inKc9U6XhnVCao=; b=FAngF63P8PqjWWdHCQ2s0/73n4tNgMMnuamyoagyj3SqQvBslgbR3aIkHou/Hf9311 AaZWPHQWlmUtERATLvoQH0wn00RwIfbOPOC3lCumrOeb3EVD7pFQpr9Y0guWZkGwClmx 0PhynL+0UCXhcQWEAqeB3g1F94qzSkFtE3KHU= 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=mL8iQfkgNtsmXIWCoWWWDzg2IuPbK76MC1VIHF2pSDn2tEvEW4WuwAMkgSaYb5HCcC UhmqsKRedPb5SoCstSbqW3JpbcmHHHcThpLGyAxKTwzUG4/gTcgNhP3WAU37Cw4vSahu pV+0XXKwAkaQB0ll9w6gE61Jb8XbcCR8y9yZQ= Received: by 10.227.146.145 with SMTP id h17mr5811747wbv.60.1293206897507; Fri, 24 Dec 2010 08:08:17 -0800 (PST) MIME-Version: 1.0 Received: by 10.227.143.202 with HTTP; Fri, 24 Dec 2010 08:07:37 -0800 (PST) In-Reply-To: <20101224170144.1d734e3c@ernst.jennejohn.org> References: <20101224170144.1d734e3c@ernst.jennejohn.org> From: Mohammad Hedayati Date: Fri, 24 Dec 2010 19:37:37 +0330 Message-ID: To: freebsd-hackers@freebsd.org X-Mailman-Approved-At: Fri, 24 Dec 2010 17:08:17 +0000 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-hackers@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list 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 16:08:19 -0000 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);