LinuxQuestions.org
Share your knowledge at the LQ Wiki.
Go Back   LinuxQuestions.org > Forums > Linux Forums > Linux - Software > Linux - Kernel
User Name
Password
Linux - Kernel This forum is for all discussion relating to the Linux kernel.

Notices


Reply
  Search this Thread
Old 09-02-2006, 01:29 AM   #1
Sreeram B S
LQ Newbie
 
Registered: Apr 2006
Posts: 26

Rep: Reputation: 0
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
 
Old 09-02-2006, 09:09 PM   #2
theoffset
Member
 
Registered: Aug 2005
Location: Guadalajara, Jal, Mexico
Distribution: Slackware Linux
Posts: 211

Rep: Reputation: 31
I might be wrong, but I don't think you can do that without some level of hacking in the kernel source.
 
  


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
Where to get the kernel functions? okeyla Linux - Newbie 1 05-17-2005 05:05 AM
kernel functions sunfzam Linux - Software 14 04-10-2005 12:27 AM
kernel functions sunfzam Linux - Distributions 3 04-05-2005 02:52 PM
Calling User-space program functions from Kernel modules shivanu Programming 1 03-05-2005 02:11 PM
FYI: Creating User Defined Functions for MySQL mchirico LinuxQuestions.org Member Success Stories 1 06-11-2004 08:51 PM

LinuxQuestions.org > Forums > Linux Forums > Linux - Software > Linux - Kernel

All times are GMT -5. The time now is 03:36 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