LinuxQuestions.org
Help answer threads with 0 replies.
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices


Reply
  Search this Thread
Old 09-09-2009, 01:53 AM   #1
dongbo
LQ Newbie
 
Registered: Aug 2009
Location: Singapore
Distribution: RedHat 8; kernel 2.4.18
Posts: 15

Rep: Reputation: 0
How is the data passed between user space and kernel


I am trying to pass some parameters from user space to kernel when reading a proc file. Firstly, I clear the buffer in user space and put some special tokens inside, but it seems that all the tokens are gone when I print the buffer in kernel. Does this mean when the proc read function in kernel is called, kernel will allocate memory without initializing it and when the read function exits, the memory will be copied into the user space buffer?

Is there any good method to pass parameter when calling proc read function?
 
Old 09-09-2009, 09:02 PM   #2
karlatLQ
Member
 
Registered: Sep 2009
Posts: 67

Rep: Reputation: 19
Sounds like the vars get out of scope.
 
Old 09-09-2009, 11:55 PM   #3
jiml8
Senior Member
 
Registered: Sep 2003
Posts: 3,171

Rep: Reputation: 116Reputation: 116
In linux, everything is a file - including the entries in /proc. If you want to pass data to the kernel, you have to open your /proc entry like it was a file, then write() to it.

The driver, or portion of the kernel, that puts up the pseudo-file in /proc has to have a routine available to read that data when your userspace program writes it.
 
Old 09-11-2009, 04:08 AM   #4
dongbo
LQ Newbie
 
Registered: Aug 2009
Location: Singapore
Distribution: RedHat 8; kernel 2.4.18
Posts: 15

Original Poster
Rep: Reputation: 0
Thanks to both of you, I think it is my mistake to use the read file to pass information to the file. The device is actually not as simple as a file with only read and write functionality. Therefore, I add it as a char device. When read the device, all the available data will be passed (several bytes). When user would like to write it. A structure will be given indicating which register and what the value is.
 
  


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



Similar Threads
Thread Thread Starter Forum Replies Last Post
Transfer data from kernel to user space pmil Programming 11 08-01-2009 05:23 AM
how to call socket prog code written in user space from kernel space???HELP kurt2 Programming 2 07-15-2009 09:56 PM
What I should do to transmit mass of data from user to kernel space? duyuyang Linux - Kernel 3 01-07-2009 03:20 AM
how to input data from user space to kernel unikgila Linux - Kernel 3 08-26-2008 10:04 PM
How to share data b/w user space and kernel space nandac Linux - Kernel 1 11-28-2006 10:15 PM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 04:43 AM.

Main Menu
Advertisement
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
Open Source Consulting | Domain Registration