From: Srinivas Chinta <chintasrinivas_tech@yahoo.com>
To: Sudharsan Vijayaraghavan <svijayar@cisco.com>
Subject: Re: Help !! calling function in module from a user program
Date: Tue, 18 Feb 2003 05:43:15 -0800 (PST) [thread overview]
Message-ID: <20030218134315.91052.qmail@web21206.mail.yahoo.com> (raw)
In-Reply-To: <4.3.2.7.2.20030218181634.01fb5428@desh>
[-- Attachment #1: Type: text/plain, Size: 1264 bytes --]
Hi,
One way of doing this is , by hooking up your function
inside the module as a system call.
Here i'm sending two files, module.c and user_space.c.
first do "insmod module.o" and then run
"./user_space".
As i'm also a newbee, i'm not aware of the
disadvantages of this approach.
thanks,
Srinivasu Chinta.
--- Sudharsan Vijayaraghavan <svijayar@cisco.com>
wrote:
> Hi,
>
> Am a new bee to linux internals.
> I am trying to make a simple program witch will call
> a function from a
> module. I made a module compiled it and INSMOD-it
> into kernel, that works
> fine. I would like to call from my user program a
> function defined in my
> kernel module.
>
> Please suggest any method thro' which this could be
> accomplished.
> The only way i did it was by running my new module
> as insmod mymodule.o and
> get my job done.
>
> Thanks,
> Sudharsan.
>
> -
> To unsubscribe from this list: send the line
> "unsubscribe linux-kernel" in
> the body of a message to majordomo@vger.kernel.org
> More majordomo info at
> http://vger.kernel.org/majordomo-info.html
> Please read the FAQ at http://www.tux.org/lkml/
__________________________________________________
Do you Yahoo!?
Yahoo! Shopping - Send Flowers for Valentine's Day
http://shopping.yahoo.com
[-- Attachment #2: module.c --]
[-- Type: text/plain, Size: 463 bytes --]
#define MODULE
#define __KERNEL__
#include <linux/module.h>
#include <linux/kernel.h>
extern void *sys_call_table[];
void * org_func;
static void my_func()
{
printk("Executing my_func...!");
}
int init_module(void)
{
printk("init_module ...!");
org_func = sys_call_table[250];
sys_call_table[250] = my_func;
return 0;
}
void cleanup_module()
{
sys_call_table[250] = org_func;
printk("cleaning up...!");
}
[-- Attachment #3: user_space.c --]
[-- Type: text/plain, Size: 145 bytes --]
#include <stdio.h>
#include <errno.h>
#include <asm/unistd.h>
#define __NR_my_func 250
_syscall0(void, my_func);
main()
{
my_func();
}
next prev parent reply other threads:[~2003-02-18 13:33 UTC|newest]
Thread overview: 5+ messages / expand[flat|nested] mbox.gz Atom feed top
2003-02-18 12:50 Sudharsan Vijayaraghavan
2003-02-18 13:00 ` Alex Bennee
2003-02-18 13:43 ` Srinivas Chinta [this message]
2003-02-18 14:04 ` Alex Bennee
2003-02-18 13:44 ` Richard B. Johnson
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20030218134315.91052.qmail@web21206.mail.yahoo.com \
--to=chintasrinivas_tech@yahoo.com \
--cc=svijayar@cisco.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®