# Export data from kernel module



## schmurfy (Jun 20, 2010)

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 (Jun 20, 2010)

Use sysctl interface to export this integer. You can find some examples if you look for them.


----------



## schmurfy (Jun 20, 2010)

thanks.


----------



## eyebone (Jun 21, 2010)

besides sysctl, u can use of course copyin copyout if there is some userland daemon or tool waiting for information.

cheers,


----------

