* How to write System calls?
@ 2001-10-29 11:16 Sureshkumar Kamalanathan
2001-10-30 9:11 ` Matthieu Delahaye
2001-10-31 1:35 ` Keith Owens
0 siblings, 2 replies; 4+ messages in thread
From: Sureshkumar Kamalanathan @ 2001-10-29 11:16 UTC (permalink / raw)
To: linux-kernel
Hi All,
Good day!
I have 2.4.4 kernel. I have to write some system calls for
interaction with the kernel from the userland. Can any of you tell me
where I can get the information regarding this?
I have the Linux Kernel Internals by Beck and others. But it gives
the procedure only for 2.2.x.
Moreover I need to implement these system calls as Loadable modules.
Any pointers in this regard will be highly appreciated and I'll very
grateful!!
Thanks in advance,
Regards,
Suresh.
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: How to write System calls?
2001-10-29 11:16 How to write System calls? Sureshkumar Kamalanathan
@ 2001-10-30 9:11 ` Matthieu Delahaye
2001-10-31 1:35 ` Keith Owens
1 sibling, 0 replies; 4+ messages in thread
From: Matthieu Delahaye @ 2001-10-30 9:11 UTC (permalink / raw)
To: Sureshkumar Kamalanathan; +Cc: linux-kernel
Hi,
First, I propose you to have a look on "Linux Kernel 2.4 Internals" from
Tigran Aivazian. You can read it from the LDP at exact URL:
http://www.linuxdoc.org/LDP/lki/index.html
In this, you'll probably see that syscalls are hardcoded (file
arch/xxx/kernel/entry.S on your kernel tree).
This means, AFAIK, you cannot implements a syscall function in a module ;-)
One other way is using your modules to implements char drivers and use
ioctl() as if it was yours syscalls. This method is generally
recommended to users who wants to implement new sayscalls.
Am I wrong?
Regards,
Matthieu
Sureshkumar Kamalanathan wrote:
>Hi All,
> Good day!
> I have 2.4.4 kernel. I have to write some system calls for
>interaction with the kernel from the userland. Can any of you tell me
>where I can get the information regarding this?
> I have the Linux Kernel Internals by Beck and others. But it gives
>the procedure only for 2.2.x.
> Moreover I need to implement these system calls as Loadable modules.
> Any pointers in this regard will be highly appreciated and I'll very
>grateful!!
>
> Thanks in advance,
>
>Regards,
>Suresh.
>-
>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/
>
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: How to write System calls?
@ 2001-10-30 9:25 Rajat Chadda
0 siblings, 0 replies; 4+ messages in thread
From: Rajat Chadda @ 2001-10-30 9:25 UTC (permalink / raw)
To: Matthieu Delahaye; +Cc: Sureshkumar Kamalanathan, linux-kernel
[-- Attachment #1: Type: text/plain, Size: 2087 bytes --]
Yes -- system calls can be implemented
as modules.
prog8.c is a module.
prog9.c is a user-space program.
In <asm/unistd.h> -- add
#define __NR_my_func 250
----- Original Message -----
From: Matthieu Delahaye <delahaym@esiee.fr>
Date: Tuesday, October 30, 2001 2:41 pm
Subject: Re: How to write System calls?
> Hi,
>
> First, I propose you to have a look on "Linux Kernel 2.4 Internals"
> from
> Tigran Aivazian. You can read it from the LDP at exact URL:
> http://www.linuxdoc.org/LDP/lki/index.html
> In this, you'll probably see that syscalls are hardcoded (file
> arch/xxx/kernel/entry.S on your kernel tree).
> This means, AFAIK, you cannot implements a syscall function in a
> module ;-)
> One other way is using your modules to implements char drivers and
> use
> ioctl() as if it was yours syscalls. This method is generally
> recommended to users who wants to implement new sayscalls.
>
>
> Am I wrong?
>
> Regards,
> Matthieu
>
> Sureshkumar Kamalanathan wrote:
>
> >Hi All,
> > Good day!
> > I have 2.4.4 kernel. I have to write some system calls for
> >interaction with the kernel from the userland. Can any of you
> tell me
> >where I can get the information regarding this?
> > I have the Linux Kernel Internals by Beck and others. But it gives
> >the procedure only for 2.2.x.
> > Moreover I need to implement these system calls as Loadable
> modules.> Any pointers in this regard will be highly appreciated
> and I'll very
> >grateful!!
> >
> > Thanks in advance,
> >
> >Regards,
> >Suresh.
> >-
> >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/
> >
>
>
>
> -
> 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/
>
[-- Attachment #2: rog8.c --]
[-- Type: application/octet-stream, Size: 574 bytes --]
#include <linux/kernel.h>
#include <linux/module.h>
#include <linux/sys.h>
#include <stdio.h>
extern void *sys_call_table[];
asmlinkage static void sys_my_func();
void *old_val;
int
init_module()
{
printk("Adding my own system call \n");
old_val = (void *) sys_call_table[250];
sys_call_table[250] = (void *) sys_my_func;
return 0;
}
asmlinkage static void sys_my_func()
{
printk("I am a working system call.\n");
}
void
cleanup_module()
{
sys_call_table[250] = old_val;
printk("<1> Restoring sys_call_table\n");
}
[-- Attachment #3: rog9.c --]
[-- Type: application/octet-stream, Size: 181 bytes --]
#include <stdio.h>
#include <linux/unistd.h>
extern long __res;
_syscall0(void,my_func);
main()
{
my_func();
printf("going to print my call\n");
printf("bye bye \n");
}
[-- Attachment #4: Wipro_Disclaimer.txt --]
[-- Type: text/plain, Size: 855 bytes --]
-----------------------------------------------------------------------------------------------------------------------
Information transmitted by this E-MAIL is proprietary to Wipro and/or its Customers and
is intended for use only by the individual or entity to which it is
addressed, and may contain information that is privileged, confidential or
exempt from disclosure under applicable law. If you are not the intended
recipient or it appears that this mail has been forwarded to you without
proper authority, you are notified that any use or dissemination of this
information in any manner is strictly prohibited. In such cases, please
notify us immediately at mailto:mailadmin@wipro.com and delete this mail
from your records.
------------------------------------------------------------------------------------------------------------------------
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: How to write System calls?
2001-10-29 11:16 How to write System calls? Sureshkumar Kamalanathan
2001-10-30 9:11 ` Matthieu Delahaye
@ 2001-10-31 1:35 ` Keith Owens
1 sibling, 0 replies; 4+ messages in thread
From: Keith Owens @ 2001-10-31 1:35 UTC (permalink / raw)
To: Sureshkumar Kamalanathan; +Cc: linux-kernel
On Mon, 29 Oct 2001 16:46:49 +0530,
Sureshkumar Kamalanathan <skk@sasken.com> wrote:
> I have 2.4.4 kernel. I have to write some system calls for
>interaction with the kernel from the userland. Can any of you tell me
>where I can get the information regarding this?
> I have the Linux Kernel Internals by Beck and others. But it gives
>the procedure only for 2.2.x.
> Moreover I need to implement these system calls as Loadable modules.
Syscall entries are hard coded into the syscall table, usually in
arch/$(ARCH)/entry.S.
There is no generic way to add a syscall that is serviced by a module.
I know that the modutils HOWTO gives examples of syscalls in modules
but that doc is out of date, on some architectures you have to adjust
additional registers to make a remote function call. On those systems
the syscall table works because the kernel is compiled with special
flags, that will not work for modules. Also Linus has said that he
does not want modules to be able to override syscalls.
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2001-10-31 10:34 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2001-10-29 11:16 How to write System calls? Sureshkumar Kamalanathan
2001-10-30 9:11 ` Matthieu Delahaye
2001-10-31 1:35 ` Keith Owens
-- strict thread matches above, loose matches on Subject: below --
2001-10-30 9:25 Rajat Chadda
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox