How to get data from kernel module ?

Ivan Voras ivoras at freebsd.org
Thu May 6 18:12:10 UTC 2010


On 05/06/10 15:38, Lukáš Czerner wrote:
> Hi,
>
> I am creating a kernel module and I need to get some information from
> that module. I can do this with ioctl and pass the data to the
> user space but it seems a bit unpractical to me, because I do not know
> the amount of the data - it can differ. I do not know of any way to
> pass a list of structures to the userspace through ioctl - is there
> any?
>
> So my question is, is there any standard way in FreeBSD to do this ?
> In linux I would probably use the sysfs, but in FreeBSD I can not find
> anything similar, except just creating some virtual filesystem on my
> own and obviously this is not what I want to do.

As others said, sysctl is one way to go, but might not be very 
convenient if the amount of data is large. I'd rather setup a device and 
a simple protocol to read/write to/from it.

http://www.freebsd.org/doc/en/books/arch-handbook/driverbasics-char.html

(you want the 5+ version)



More information about the freebsd-hackers mailing list