From owner-freebsd-hackers@FreeBSD.ORG Fri Dec 24 16:01:49 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 D818A1065744 for ; Fri, 24 Dec 2010 16:01:49 +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 5E95C8FC0A for ; Fri, 24 Dec 2010 16:01:49 +0000 (UTC) Received: by bwz12 with SMTP id 12so1187017bwz.13 for ; Fri, 24 Dec 2010 08:01:48 -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=Ua3aeTnIZn6REExsjCxI5h1at13ksWvzuievOzh2bh8=; b=VZW2O+OP35XFe460MZCrQEXzVxSZbjh0VUhii8h3rBV//h3vwUD1cffR8YiBi38F6y vueN8H8ennH/GgjogVQSjvKU/8QEmt5tm15z71vwep3bOk9DWvC3zN2x5bRrqM0gNHUQ 1AiVr/iW592oFfyQ6hLQztosVGEj0rhV/bgoo= 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=SMnw0rmgdLhY0rOOnoRC5fdtZTh9M9mMTnRp0JfrcgKbjwErCzhvL6Riv6ovEGPhEu Y1ZwtiIBRhzLjcM9OM7OWG9CSYu4MX41J0WXGXv9t0vQ57gG6U/nf0LM55NDoLnIyRbe 0H6IYjff3edEQvscsNsZrK0NB9GeBaFsH7FRA= Received: by 10.204.80.70 with SMTP id s6mr3434802bkk.142.1293206508193; Fri, 24 Dec 2010 08:01:48 -0800 (PST) Received: from ernst.jennejohn.org (p578E395D.dip.t-dialin.net [87.142.57.93]) by mx.google.com with ESMTPS id f20sm3749114bkf.4.2010.12.24.08.01.46 (version=TLSv1/SSLv3 cipher=RC4-MD5); Fri, 24 Dec 2010 08:01:47 -0800 (PST) Date: Fri, 24 Dec 2010 17:01:44 +0100 From: Gary Jennejohn To: Mohammad Hedayati Message-ID: <20101224170144.1d734e3c@ernst.jennejohn.org> In-Reply-To: References: 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: freebsd-hackers@freebsd.org 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 16:01:49 -0000 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