LinuxQuestions.org
Latest LQ Deal: Latest LQ Deals
Home Forums Tutorials Articles Register
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.

Notices


Reply
  Search this Thread
Old 02-06-2006, 12:15 AM   #1
vishalbutte
Member
 
Registered: Dec 2005
Posts: 80

Rep: Reputation: 15
Question How to call function in kernel


actually i want to call a function which is stored in my file.I want to call the function in the source code before some kernel function. So how should i do it...

Thanks in advance..
 
Old 02-06-2006, 12:26 AM   #2
jlliagre
Moderator
 
Registered: Feb 2004
Location: Outside Paris
Distribution: Solaris 11.4, Oracle Linux, Mint, Debian/WSL
Posts: 9,789

Rep: Reputation: 492Reputation: 492Reputation: 492Reputation: 492Reputation: 492
Please elaborate.
 
Old 02-06-2006, 12:27 AM   #3
paragn
Member
 
Registered: Jan 2006
Distribution: Red Hat EL5, Fedora 7
Posts: 259

Rep: Reputation: 30
hi,
Ask your kernel related queries on kernelnewbies mailing list. and also try to explain your problem in brief about what you want to do?
 
Old 02-06-2006, 12:41 AM   #4
vishalbutte
Member
 
Registered: Dec 2005
Posts: 80

Original Poster
Rep: Reputation: 15
i wrote some code in one file and in that file there is one function . i want to call that function in the kernel code. i called that function in main.c , in that start_kernel(). and during compilation it is not working .
so i wanted to ask can i directly call my own written function in kernel???
 
Old 02-06-2006, 12:57 AM   #5
vishalbutte
Member
 
Registered: Dec 2005
Posts: 80

Original Poster
Rep: Reputation: 15
i compiled the kernel with the file in which i have written the function which i want to call in main.c file of kernel.
 
Old 02-06-2006, 01:05 AM   #6
paragn
Member
 
Registered: Jan 2006
Distribution: Red Hat EL5, Fedora 7
Posts: 259

Rep: Reputation: 30
try exporting kernel function by using EXPORT_SYMBOL(fun_name)
 
Old 02-06-2006, 01:44 AM   #7
jlliagre
Moderator
 
Registered: Feb 2004
Location: Outside Paris
Distribution: Solaris 11.4, Oracle Linux, Mint, Debian/WSL
Posts: 9,789

Rep: Reputation: 492Reputation: 492Reputation: 492Reputation: 492Reputation: 492
Quote:
Originally Posted by vishalbutte
i wrote some code in one file and in that file there is one function . i want to call that function in the kernel code. i called that function in main.c , in that start_kernel(). and during compilation it is not working .
so i wanted to ask can i directly call my own written function in kernel???
Please explain "it is not working".

Is there a compilation error ?
Is it crashing the kernel ?
Is it just not doing what expected ?

Can you explain what your function is for ?
 
Old 02-06-2006, 11:52 AM   #8
vishalbutte
Member
 
Registered: Dec 2005
Posts: 80

Original Poster
Rep: Reputation: 15
well function accesses one file which contains some information written using structure.
and i want to extract the same into similar but kernel data structure.
so i am calling that function into "start_kernel" fun. of main.c (in fs )as upto there root file sys gets mounted.

when i compiled the kernel it gave errors regardin the

#include<stdio.h> , #include<stdlib.h> .....no such file or directory..
FILE *fp..... fp undeclared like that............

well one question again..
in the same function we hav used "fopen" to open the file which contains
the information.
Is that correct?
If not then what should be used to open the file?

hope so this is sufficient..
thanks for all the replies.
and waiting for the remaining ..
 
Old 02-06-2006, 12:24 PM   #9
jlliagre
Moderator
 
Registered: Feb 2004
Location: Outside Paris
Distribution: Solaris 11.4, Oracle Linux, Mint, Debian/WSL
Posts: 9,789

Rep: Reputation: 492Reputation: 492Reputation: 492Reputation: 492Reputation: 492
For obvious reasons, you cannot use any standard library call nor system calls in the kernel.
 
Old 02-07-2006, 02:09 AM   #10
vishalbutte
Member
 
Registered: Dec 2005
Posts: 80

Original Poster
Rep: Reputation: 15
Question

SO if i cant use the library functuions then which functions i can use to access the files on hard disk ?
Or how can i access the RDBMS databases then ?
Where can i get info about these functions?
can u show me example or if it already used in kernel then
where it is used ?
 
Old 02-07-2006, 02:50 AM   #11
jlliagre
Moderator
 
Registered: Feb 2004
Location: Outside Paris
Distribution: Solaris 11.4, Oracle Linux, Mint, Debian/WSL
Posts: 9,789

Rep: Reputation: 492Reputation: 492Reputation: 492Reputation: 492Reputation: 492
Quote:
Originally Posted by vishalbutte
SO if i cant use the library functuions then which functions i can use to access the files on hard disk ?
This is mostly not the kernel business. The kernel is providing applications a method to access files, but is seldom itself a client of this service.
Quote:
Or how can i access the RDBMS databases then ?
This is definitely not the kernel business.
Quote:
Where can i get info about these functions?
can u show me example or if it already used in kernel then
where it is used ?
If you insist doing that, have a look at acct.c calling filp_open().
 
  


Reply



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
Can a kernel module call the function of another kernel module sceadu Programming 3 05-02-2011 02:22 AM
How to call another function from a function? geminigal Programming 4 04-21-2005 10:41 PM
Call to undefined function: mysql_connect() SocialEngineer Linux - Software 2 11-16-2004 02:24 PM
No Matching Function for Call ! vipinsharma Programming 2 07-05-2004 01:58 PM
how to call function?? harpal Programming 3 04-29-2003 05:59 AM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

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