a newbie question

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

 



Hi all,

I tried to write my own system call
and call it from the user land using _syscall0 macro
The following code works but
I m not sure whether the following code that i have written is the legal and 
safer way of doing it.
I saw somewhere in the kernel source code
that the size of the sys_call_table is 256.
In unistd.h for i386 there are only 221 calls
so i decided to insert my own call at 222.
some one please tell me whether it is safe or not to do that.
If not is there a decent way of writing my own system call.

I m using RedHat 7.1 and the kernel version is 2.4.2-2 on an i686

/*The code goes here*/

#include <linux/kernel.h>
#include <linux/module.h>

extern int printk(const char *fmt, ...);
extern void *sys_call_table[];
extern int nr_running;
/*extern int nr_threads;*/
/*extern int last_pid;*/

asmlinkage int our_syscall()
{
        printk("---------------------\n");
        printk("nr_running : %d\n",nr_running);
        printk("---------------------\n");
        return 0;
}

int init_module()
{
        sys_call_table[222] = our_syscall;
        return 0;
}

void cleanup_module()
{
        sys_call_table[222] = 0;
}


thanks and regards,
mohan.
-
Kernelnewbies: Help each other learn about the Linux kernel.
Archive:       http://mail.nl.linux.org/kernelnewbies/
IRC Channel:   irc.openprojects.net / #kernelnewbies
Web Page:      http://www.kernelnewbies.org/


[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