From owner-freebsd-drivers@FreeBSD.ORG Tue Sep 5 23:44:55 2006 Return-Path: X-Original-To: freebsd-drivers@freebsd.org Delivered-To: freebsd-drivers@freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id 5FFE816A4E0 for ; Tue, 5 Sep 2006 23:44:55 +0000 (UTC) (envelope-from kristis.makris@asu.edu) Received: from mail.mkgnu.net (net.mkgnu.net [67.40.69.52]) by mx1.FreeBSD.org (Postfix) with ESMTP id BD9E743D5D for ; Tue, 5 Sep 2006 23:44:54 +0000 (GMT) (envelope-from kristis.makris@asu.edu) Received: from syd.mkgnu.net ([::ffff:192.168.0.101]) by morpheus with esmtp; Tue, 05 Sep 2006 17:03:02 -0700 id 00015398.44FE1036.0000501B From: Kristis Makris To: freebsd-drivers@freebsd.org Date: Tue, 05 Sep 2006 16:46:45 -0700 Message-Id: <1157500005.3414.92.camel@syd.mkgnu.net> Mime-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Content-Transfer-Encoding: 7bit X-Mailer: Evolution 2.0.4 Subject: ioctl: uiomove, copyin, copyout X-BeenThere: freebsd-drivers@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Writing device drivers for FreeBSD List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 05 Sep 2006 23:44:55 -0000 Hello, I'm trying to port a driver from Linux 2.2-2.6 to FreeBSD. I have two problems: 1) Finding the equivalent of the Linux copy_to_user and copy_from_user routines. Are those copyin, and copyout ? 2) Getting the ioctl operation to work. When issuing an ioctl from userspace I get: # dynamos_control -o 9 ioctl error for command 9: Inappropriate ioctl for device errno is 25 it's an ENOTTY ... while in the driver I have: static d_read_t dynreplace_file_operations_read; static d_ioctl_t dynreplace_file_operations_ioctl; static struct cdevsw dynreplace_cdevsw = { .d_version = D_VERSION, .d_open = dynreplace_file_operations_open, .d_close = dynreplace_file_operations_release, .d_read = dynreplace_file_operations_read, .d_ioctl = dynreplace_file_operations_ioctl, .d_name = MODULE_NAME_STR, }; int dynreplace_file_operations_ioctl(struct cdev *dev, u_long cmd, caddr_t data, int flags, struct thread *td) { print( "ioctl - MAIN\n"); return 0; } ... the _read operation works as expected, but I don't even see the print statement from _ioctl. The ioctl(2) manpage reads: [ENOTTY] The d argument is not associated with a character special device. This can't be true since the read operation works, and: # ls -lrta /dev/dynamos crwx------ 1 root wheel 0, 95 Sep 2 16:31 /dev/dynamos and... [ENOTTY] The specified request does not apply to the kind of object that the descriptor d references. Is this last part somehow enforced by the kernel ? I know I have an uncommon build process, since the driver is built for multiple OSs, but if I can get the read operation to work why would ioctl be so difficult ? Am I missing something ?