LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Newbie (https://www.linuxquestions.org/questions/linux-newbie-8/)
-   -   To pass a list of values from userspace to kernelspace (https://www.linuxquestions.org/questions/linux-newbie-8/to-pass-a-list-of-values-from-userspace-to-kernelspace-4175509767/)

ch2301 07-01-2014 12:08 PM

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!

suicidaleggroll 07-01-2014 12:15 PM

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.

ch2301 07-01-2014 12:24 PM

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/.

ch2301 07-01-2014 11:50 PM

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 ?

jpollard 07-03-2014 04:39 AM

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).

suicidaleggroll 07-03-2014 09:46 AM

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.


All times are GMT -5. The time now is 02:33 AM.