How to use kernel functions like get_current() in user programs
Hi friends,
I have started looking at data structures in Kernel very very recently. However, whenever I come across a data structure, I feel like calling them from my user program just to know its working or current value.
Say, for example, the kernel function get_current(). This is a function, which many system calls like "getpid", "getppid" use. If I want to call this function directly from my program ie, without using system call interface, what libraries should I include?
I tried the following program, but failed !!
#include <stdio.h>
#include <linux/kernel.h>
#include <unistd.h>
int main()
{
struct task_struct *p;
p = get_current();
printf ("UID = %d\n", p->uid);
return 0;
}
This program does not work, it says "Invalid dereferencing". What is the correct procedure to use such kernel functions?
Please guide.
Thanks,
Sreeram
|