You are not logged in.

#1 2015-04-08 16:53:37

emraldinho
Member
Registered: 2015-02-10
Posts: 7

Loadable Kernel Help

Hi,

I hope everyone is having a great day.

I am learning Kernel programming and I have a newbie, question. So I have a Kernel module that I wrote which goes like:

SYSCALL_DEFINE2(testFunction, pid_t, pid, uid_t *, uid)
{
    // I do a bunch of stuff here
}

but now I want to convert it into a Loadable Kernel function, and I know I have to do something like this:

static int __init testFunction(pid_t, pid, uid_t *, uid)
&
static void __exit exit_module(void)
&
module_init(testFunction);
module_exit(exitModule);

My question is, how exactly am I supposed to integrate the SYSCALL_DEFINE2(testFunction, pid_t, pid, uid_t *, uid) now?

Thanks in advance!

Offline

#2 2015-04-08 17:18:16

ewaller
Administrator
From: Pasadena, CA
Registered: 2009-07-13
Posts: 20,611

Re: Loadable Kernel Help

In my opinion, Linux Device Drivers is the canonical reference.  Look at chapter 2


Nothing is too wonderful to be true, if it be consistent with the laws of nature -- Michael Faraday
The shortest way to ruin a country is to give power to demagogues.— Dionysius of Halicarnassus
---
How to Ask Questions the Smart Way

Offline

#3 2015-04-08 19:14:58

emraldinho
Member
Registered: 2015-02-10
Posts: 7

Re: Loadable Kernel Help

ewaller wrote:

In my opinion, Linux Device Drivers is the canonical reference.  Look at chapter 2

Thank you, read the document, it is really good. From my understanding,

SYSCALL_DEFINE2(testFunction, pid_t, pid, uid_t *, uid)
{
    // I do a bunch of stuff here
}
I do the bunch of stuff in module_init() instead of this system call, then I publish a pointer to the testFunction and then modify the Makefile?

am I right?

Offline

#4 2015-04-08 19:56:58

ewaller
Administrator
From: Pasadena, CA
Registered: 2009-07-13
Posts: 20,611

Re: Loadable Kernel Help

I think so.  It has been awhile since I have played with modules and I cannot access my home computer from here sad .  I did try all the examples in that book and they do work.


Nothing is too wonderful to be true, if it be consistent with the laws of nature -- Michael Faraday
The shortest way to ruin a country is to give power to demagogues.— Dionysius of Halicarnassus
---
How to Ask Questions the Smart Way

Offline

Board footer

Powered by FluxBB