PDA

View Full Version : [Solved] Export data from kernel module


schmurfy
June 20th, 2010, 15:47
Hello,
I am currently writing a kernel module which needs to export some data to userland space, what is the preferred way of doing this ?
I was thinking of maybe using /proc but I am rather lost on how to do this (It is my first try at developing a kernel module).

A basic example of what i wish to do is (maybe procfs is not what i need but it illustrates well my need):

#!/bin/sh

ACTIVE_LINK=`cat /proc/active_link`

if [ $ACTIVE_LINK == 1 ];then
[...]

What I need to export is a single integer.
Thanks for any pointers :)

PS: I tried to do a search but frankly I don't even know what to search for :\

expl
June 20th, 2010, 16:22
Use sysctl interface to export this integer. You can find some examples if you look for them.

schmurfy
June 20th, 2010, 16:40
thanks.

eyebone
June 21st, 2010, 16:44
besides sysctl, u can use of course copyin copyout if there is some userland daemon or tool waiting for information.

cheers,