copy_from/to_user how to use it simply to get pid into kernel space from userspace?
Hello everyone,
I am looking for providing userspace pid to kernel. And one of may be many ways is copy_from/to_user. can anyone please help me to implement this? or can you give me some examples for this that i can overcome this problem: kernel Code: Code:
struct siginfo sinfo; Code:
void signal_handler (int signum){ please help me out.. :( |
The most common ways to get data from user space to kernel space are:
sysfs procfs chardev There's a good discussion of these (and less popular methods), here: http://people.ee.ethz.ch/~arkeller/l...ace_howto.html Basically, you want to getpid(), and then write it to a file descriptor. That file descriptor will either be in /proc/something, or /sys/something, or /dev/something, depending on which of the above methods you choose. Anyway, that's only a few lines of code. More of the work will be in the kernel module, where you implement one of the above interfaces. |
Quote:
thank you so much jhwilliams. I tried to work with ioctl.. but one thing strange is that, while i am making the device /dev/cdev_example using following command: Quote:
Quote:
i have also tried to check using: Quote:
echo'd to device, but i am getting this message Quote:
|
Thank you so much for response jhwilliams...
I have got succeed in getting PID at kernel space: Here I am posting code for helping the others: Code:
#include <linux/module.h> Code:
obj-m += k_module.o Code:
#include <stdio.h> Thanks for response on my queries.. Raheel.. |
All times are GMT -5. The time now is 06:31 AM. |