LinuxQuestions.org
Download your favorite Linux distribution at LQ ISO.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Newbie
User Name
Password
Linux - Newbie This Linux forum is for members that are new to Linux.
Just starting out and have a question? If it is not in the man pages or the how-to's this is the place!

Notices


Reply
  Search this Thread
Old 07-01-2014, 01:08 PM   #1
ch2301
LQ Newbie
 
Registered: Jul 2014
Posts: 3

Rep: Reputation: Disabled
To pass a list of values from userspace to kernelspace


Hi all,
I'm working on a linux project. I need to pass a list of integer values from a userspace program to the kernel space. Could anyone tell me how to do this ?
Thank you!
 
Old 07-01-2014, 01:15 PM   #2
suicidaleggroll
LQ Guru
 
Registered: Nov 2010
Location: Colorado
Distribution: OpenSUSE, CentOS
Posts: 5,258

Rep: Reputation: 1947Reputation: 1947Reputation: 1947Reputation: 1947Reputation: 1947Reputation: 1947Reputation: 1947Reputation: 1947Reputation: 1947Reputation: 1947Reputation: 1947
I'm assuming you have a kernel module you're trying to interface with? Is it your kernel module? What type is it? For a character device there are basically two ways to pass it data from userspace, either "write" or "ioctl". "write" is what's called when you write data into the device (eg: /dev/mydevice). You can't really differentiate between different variable types, it's mainly just used for block writing from userspace to kernel space. "ioctl" is what you would use to pass specific variables/configuration settings to the character device. You can use ioctl to send commands, send values, read values, etc.
 
Old 07-01-2014, 01:24 PM   #3
ch2301
LQ Newbie
 
Registered: Jul 2014
Posts: 3

Original Poster
Rep: Reputation: Disabled
Hi, Its not a kernel module. Its a slightly modified linux kernel which I'm working on. I need to pass the values to one of the source files in the kernel directory. http://www.litmus-rt.org/.
 
Old 07-02-2014, 12:50 AM   #4
ch2301
LQ Newbie
 
Registered: Jul 2014
Posts: 3

Original Poster
Rep: Reputation: Disabled
Hi, No, this is not a kernel module. It's a modified linux kernel with support for real-time research experiments. Please refer to www[dot]litmus-rt[dot]org. What I wish to do is to transfer the list of integer values to one of the source files in the modified kernel. Also, is mmap() possible in my case ?

Last edited by ch2301; 07-02-2014 at 01:04 PM.
 
Old 07-03-2014, 05:39 AM   #5
jpollard
Senior Member
 
Registered: Dec 2012
Location: Washington DC area
Distribution: Fedora, CentOS, Slackware
Posts: 4,599

Rep: Reputation: 1241Reputation: 1241Reputation: 1241Reputation: 1241Reputation: 1241Reputation: 1241Reputation: 1241Reputation: 1241Reputation: 1241
You can't transfer to a "source file in the kernel" as there are no source files...

There are only two ways to transfer data - write or ioctl.

Now, there are several ways to implement write - have the "modification" create a sysfs/proc interface, or create a device driver that supports write (also works for ioctl).
 
Old 07-03-2014, 10:46 AM   #6
suicidaleggroll
LQ Guru
 
Registered: Nov 2010
Location: Colorado
Distribution: OpenSUSE, CentOS
Posts: 5,258

Rep: Reputation: 1947Reputation: 1947Reputation: 1947Reputation: 1947Reputation: 1947Reputation: 1947Reputation: 1947Reputation: 1947Reputation: 1947Reputation: 1947Reputation: 1947
As jpollard said, you can't just inject values into variables in the kernel source. From the sound of it, you would want to modify the source file you're interested in to make some public set/get routines for those variables, and then write a kernel module to allow you to call the set/get routines through ioctl commands from userspace.
 
  


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
[SOLVED] what is the printf equivalent to pass values by ref? (C programming) zagzagel Programming 21 06-17-2013 12:57 PM
[SOLVED] How to call a userspace function from kernelspace vilhelmgray Linux - Kernel 3 04-24-2013 08:54 AM
[SOLVED] splitting of comma separated values file (horizontal) into a list (vertical ) list Donoughue Linux - Newbie 3 10-20-2011 02:18 PM
shared timers between kernelspace and userspace bizoo Programming 4 07-10-2009 06:34 AM
making Common .h file for userspace and kernelspace devkpict Linux - Kernel 0 02-04-2008 02:54 AM


All times are GMT -5. The time now is 08:29 PM.

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
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration