From owner-freebsd-hackers@FreeBSD.ORG Wed Aug 10 21:47:32 2005 Return-Path: X-Original-To: freebsd-hackers@freebsd.org Delivered-To: freebsd-hackers@freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id CD60216A41F; Wed, 10 Aug 2005 21:47:32 +0000 (GMT) (envelope-from uvarovsl@mail.pnpi.spb.ru) Received: from mail.lsi.ru (mail.lsi.ru [212.58.192.30]) by mx1.FreeBSD.org (Postfix) with ESMTP id 6280F43D46; Wed, 10 Aug 2005 21:47:30 +0000 (GMT) (envelope-from uvarovsl@mail.pnpi.spb.ru) Received: by mail.lsi.ru (Postfix, from userid 426) id 883DA386C8B; Thu, 11 Aug 2005 01:47:29 +0400 (MSD) Received: from [10.0.0.3] (unknown [212.58.210.222]) by mail.lsi.ru (Postfix) with ESMTP id 20EAF386C6F; Thu, 11 Aug 2005 01:47:26 +0400 (MSD) Message-ID: <42FA76B4.8010007@mail.pnpi.spb.ru> Date: Thu, 11 Aug 2005 01:50:44 +0400 From: Sergey Uvarov User-Agent: Mozilla/5.0 (X11; U; Linux i686; en-US; rv:1.7.8) Gecko/20050511 X-Accept-Language: ru, en-us, en MIME-Version: 1.0 To: John Baldwin References: <42FA63A3.4040802@mail.pnpi.spb.ru> <200508101640.28555.jhb@FreeBSD.org> <42FA6D78.4020306@mail.pnpi.spb.ru> <200508101737.36542.jhb@FreeBSD.org> In-Reply-To: <200508101737.36542.jhb@FreeBSD.org> Content-Type: text/plain; charset=us-ascii; format=flowed Content-Transfer-Encoding: 7bit Cc: freebsd-hackers@freebsd.org Subject: Re: preferable way to control kernel module 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: Wed, 10 Aug 2005 21:47:32 -0000 >>>>I'm writing a kernel module for my own needs. AFAIK the following >>>>methods could be used: >>>> >>>>1) allocate not used system call with help of SYSCALL_MODULE macro >>>> >>>>2) allocate proprieatry oid via SYSCTL_OID(OID_AUTO) and write an >>>>appropriate sysctl handler(s) >>>> >>>>3) add a file in /dev and use ioctl(2) call >>>> >>>>What is a preferable way to control my module? >>> >>>It depends on what you want to do really. I've used sysctl's for simple >>>debug modules where I write to the sysctl to have it perform a desired >>>action. >> >>I need to pass some configuration parameters to my module and retrieve a >>status back. Interface is quite similar to ptrace(2) syscall. I don't >>need to pass large amount of data. > > > If it's a single integer or some such, I'd say use sysctl. If it's a > structure, I'd go the ioctl(2) route. Creating /dev entries isn't all that > hard. In your case you'd just need open/close/ioctl in a cdevsw, then use > make_dev() during MOD_LOAD and destroy_dev() during MOD_UNLOAD. > Thank you for advise. But I wonder: what is wrong with syscall approach (via SYSCALL_MODULE macro)? Thanks again, Sergey.