LinuxQuestions.org
Register a domain and help support LQ
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Software > Linux - Kernel
User Name
Password
Linux - Kernel This forum is for all discussion relating to the Linux kernel.

Notices

Reply
 
LinkBack Search this Thread
Old 10-24-2009, 11:54 PM   #1
novice_
LQ Newbie
 
Registered: Jun 2009
Posts: 2

Rep: Reputation: 0
Communicating between Kernel and User Application


Hi,

I am looking for a way to exchange messages/data between kernel module and userspace app. How can i do that ?

What i want to do is that the kernel module is outputting data constantly. I want that data to be displayed to the user. The user can run a process which connects to the kernel module and displays what kernel module is outputting. Secondly, i want the user to be able to send data/command to the kernel module to control its behavior.

Any help on how i can achieve this or any links that explain the same would be appreciated.

Thank You
 
Old 10-25-2009, 05:10 AM   #2
janoszen
Member
 
Registered: Oct 2009
Location: Budapest
Distribution: Mostly Gentoo, sometimes Debian/(K)Ubuntu
Posts: 143

Rep: Reputation: 22
Well

Well, I'm not even close to being an expert, but implementing a syscall in the kernel module would be the key. iptables / netfilter for example uses a predefined structure to pass the whole data to the kernel. This leads to problems on some architectures but might still be worthwhile checking out.
 
Old 10-25-2009, 05:39 AM   #3
unSpawn
Moderator
 
Registered: May 2001
Posts: 20,993
Blog Entries: 44

Rep: Reputation: 1239Reputation: 1239Reputation: 1239Reputation: 1239Reputation: 1239Reputation: 1239Reputation: 1239Reputation: 1239Reputation: 1239
Quote:
Originally Posted by novice_ View Post
What i want to do is that the kernel module is outputting data constantly. I want that data to be displayed to the user. The user can run a process which connects to the kernel module and displays what kernel module is outputting.
There is no necessity for "a user to run a process which connects to the kernel module" as output can be provided through /proc easily (for instance 'netstat' reading /proc/net/snmp).


Quote:
Originally Posted by novice_ View Post
i want the user to be able to send data/command to the kernel module to control its behavior.
Depends on what needs to be written. If it's like flipping a boolean (like /proc/sys/net/ipv4/ip_forward) then a sysctl key could do. Else, building on janoszen reply, see for instance how 'iptables' handles providing instructions to the Netfilter framework ('man 7 netlink', http://people.redhat.com/nhorman/papers/netlink.pdf). BTW I'm no expert either ;-p
 
Old 10-25-2009, 05:44 AM   #4
syg00
Guru
 
Registered: Aug 2003
Location: Australia
Distribution: Lots ...
Posts: 9,976

Rep: Reputation: 548Reputation: 548Reputation: 548Reputation: 548Reputation: 548Reputation: 548
Just use /proc in both directions - the kernel module is responsible for creating any "files" needed, and can respond in need.
 
Old 11-19-2009, 04:10 AM   #5
Anisha Kaul
Senior Member
 
Registered: Dec 2008
Location: Gurgaon, India
Distribution: Slackware 13.1, OpenSuse 11.2
Posts: 4,202
Blog Entries: 14

Rep: Reputation: 625Reputation: 625Reputation: 625Reputation: 625Reputation: 625Reputation: 625
Functions like copy_to_user and copy_from_user are available for copying data to and from user space and kernel space.
Kindly search for usage documentations on the net.
 
  


Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Kernel Module to send Message to User Space Application hnshashi Linux - Newbie 2 08-22-2008 01:48 AM
Access kernel register from user application navvu_mom Linux - Software 0 05-28-2008 10:44 AM
communicating to user space eternity_00 Linux - Networking 2 05-01-2006 07:48 AM
communicating driver tx status to kernel gsrdemon Linux - Wireless Networking 0 08-01-2005 06:17 AM


All times are GMT -5. The time now is 02:03 PM.

Main Menu
 
My LQ
Write for LQ
LinuxQuestions.org is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
Syndicate
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
identi.ca: @linuxquestions
Facebook: @linuxquestions
Open Source Consulting | Domain Registration