Skip site navigation (1)Skip section navigation (2)
Date:      Thu, 11 Aug 2005 01:50:44 +0400
From:      Sergey Uvarov <uvarovsl@mail.pnpi.spb.ru>
To:        John Baldwin <jhb@freebsd.org>
Cc:        freebsd-hackers@freebsd.org
Subject:   Re: preferable way to control kernel module
Message-ID:  <42FA76B4.8010007@mail.pnpi.spb.ru>
In-Reply-To: <200508101737.36542.jhb@FreeBSD.org>
References:  <42FA63A3.4040802@mail.pnpi.spb.ru>	<200508101640.28555.jhb@FreeBSD.org>	<42FA6D78.4020306@mail.pnpi.spb.ru> <200508101737.36542.jhb@FreeBSD.org>

next in thread | previous in thread | raw e-mail | index | archive | help
>>>>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.



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?42FA76B4.8010007>