From owner-freebsd-hackers Wed Jun 21 17:30:22 2000 Delivered-To: freebsd-hackers@freebsd.org Received: from smtp10.atl.mindspring.net (smtp10.atl.mindspring.net [207.69.200.246]) by hub.freebsd.org (Postfix) with ESMTP id 2FD3337BC76 for ; Wed, 21 Jun 2000 17:30:17 -0700 (PDT) (envelope-from vsilyaev@mindspring.com) Received: from jupiter.delta.ny.us (nyf-ny8-04.ix.netcom.com [198.211.17.196]) by smtp10.atl.mindspring.net (8.9.3/8.8.5) with ESMTP id UAA25614; Wed, 21 Jun 2000 20:30:14 -0400 (EDT) Received: (from vsilyaev@localhost) by jupiter.delta.ny.us (8.9.3/8.9.3) id UAA00526; Wed, 21 Jun 2000 20:30:12 -0400 (EDT) (envelope-from vsilyaev) Date: Wed, 21 Jun 2000 20:30:11 -0400 From: "Vladimir N. Silyaev" To: Coleman Kane Cc: freebsd-hackers@freebsd.org Subject: Re: Linux ioctls Message-ID: <20000621203011.A499@jupiter.delta.ny.us> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Mailer: Mutt 1.0i Sender: owner-freebsd-hackers@FreeBSD.ORG Precedence: bulk X-Loop: FreeBSD.ORG In the FreeBSD after 4.0 Release, have ability to registrate new Linux -> FreeBSD ioctl's translators in the any part of the kernel code. It's looks like this: #define LINUX_IOCTL_SET(n,low,high) \ static linux_ioctl_function_t linux_ioctl_##n; \ static struct linux_ioctl_handler n##_handler = {linux_ioctl_##n, low, high }; \ SYSINIT(n##register, SI_SUB_KLD, SI_ORDER_MIDDLE, linux_ioctl_register_handler, &n##_handler); \ SYSUNINIT(n##unregister, SI_SUB_KLD, SI_ORDER_MIDDLE, linux_ioctl_unregister_han dler, &n##_handler); I'm thinking that this stuff better to include in a some of the linux emulator headers. and after that: low high LINUX_IOCTL_SET(net, 0x8900, 0x89ff); /* handler declaration */ Linux ioctl's constants, #define LINUX_SIOCSIFADDR 0x8916 /* set PA address */ #define LINUX_SIOCSIFFLAGS 0x8914 /* set flags */ #define LINUX_SIOCSIFBR 0x8941 /* Set bridging options */ Translator implementation, static int linux_ioctl_net(struct proc *p, struct linux_ioctl_args *args) { int error=ENOIOCTL; DEB(printf(__FUNCTION__ ": cmd 0x%04lx arg %p\n", args->cmd, (void*)args->ar g)); switch (args->cmd & 0xffff) { case LINUX_SIOCSIFFLAGS: args->cmd = SIOCSIFFLAGS; error = ioctl(p, (struct ioctl_args *)args); break; case LINUX_SIOCSIFADDR: args->cmd = SIOCSIFADDR; error = ioctl(p, (struct ioctl_args *)args); break; case LINUX_SIOCSIFBR: args->cmd = VMIO_SIOCSIFBR; error = ioctl(p, (struct ioctl_args *)args); break; ... } DEB(printf(__FUNCTION__ ": return %d\n", error)); return (error); } As far as I know such thing now are used only in linux emulator code and in the FreeBSD drivers for vmware. -- Vladimir To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-hackers" in the body of the message