Re: Adding a system call thru a module

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Adding a system call from within a module isn't a very good idea. For reasons 
on this search the archives on kernel-newbies and linux-kernel. This topic 
has been discussed many times.


On Friday 12 July 2002 4:00 pm, Karthik M wrote:
> hi,
>
> I was trying to add a system call from a module. I was
> trying out a sample program to do the same.
>
> It gave me an error when i tried to insert the module
> into the kernel. The error stmt was:
>
> ---snip-----
>
> [root]# insmod testcall.o
> testcall.o: init_module: Device or resource busy
> Hint: insmod errors can be caused by incorrect module
> parameters, including invalid IO or IRQ parameters
> [root]#
>
> ---snip----
>
> The program was :
>
> -----snip-----
>
> #include<linux/kernel.h>
> #include<linux/module.h>
> #include<linux/sys.h>
> #include<sys/syscall.h>
>
> static const char *version = "testcall.c: 7/11/2002
> Karthik";
>
> static int syscall_num = 225;
>
> extern int sys_call_table[];
>
> asmlinkage int sys_hello(void)
> {
>   printk("The kernel says 'Hi'\n");
>   return 1;
> }
>
> int init_module(void)
> {
>   printk(version);
>
>   if(sys_call_table[syscall_num])
>     {
>       printk("Error : %d",syscall_num);
>       return 1;
>     }
>
>   sys_call_table[syscall_num] = (int)sys_hello;
>
>   return 0;
>
> }
>
> void cleanup_module(void)
> {
>   sys_call_table[syscall_num] = 0;
> }
>
> -----snip-----
>
> The command used to compile was:
>
> ----snip----
>
> [root]# gcc -D__KERNEL__ -DMODULE -Wall
> -I/usr/src/linux/include -O2 -c te
> stcall.c
>
> ----snip----
>
> I am stuck and could'nt find a possible solution for
> this problem.
>
> TIA
>
> karthik
>
> __________________________________________________
> Do You Yahoo!?
> Sign up for SBC Yahoo! Dial - First Month Free
> http://sbc.yahoo.com
--
Kernelnewbies: Help each other learn about the Linux kernel.
Archive:       http://mail.nl.linux.org/kernelnewbies/
FAQ:           http://kernelnewbies.org/faq/


[Index of Archives]     [Newbies FAQ]     [Linux Kernel Mentors]     [Linux Kernel Development]     [IETF Annouce]     [Git]     [Networking]     [Security]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux RAID]     [Linux SCSI]     [Linux ACPI]
  Powered by Linux