Results 1 to 2 of 2
Hi Everyone,
I have written a kernel module in which i need to call system calls.
Actually my requirement is to shutdown the system whenever i get a signal.
But ...
- 03-04-2009 #1Just Joined!
- Join Date
- Aug 2007
- Posts
- 8
System call from Kernel
Hi Everyone,
I have written a kernel module in which i need to call system calls.
Actually my requirement is to shutdown the system whenever i get a signal.
But the system ("shutdown") doesn't work in kernel module.
I 've heard that if we use system_call_table and system_call then we can. But not getting any link.
Please help.....
- 03-07-2009 #2
Hi Hitendra,
So we have 7 macroses in linux kernel named as _syscal0 - _syscall6. The number in macros name assume parameters count in system call. Firsts two parameters in
_syscall0-6 are returning value and system call name. So if we want to use system call without parameters(such as fork) we use _syscall0, with 1 param - _syscall1 and etc. Next pair of parameters assume getting type and variable.
For example for fork() system call:
_syscall0(int , fork)
For exit:
_syscall1(int, exit, int, exit_code)
In u case (shutdown):
_syscall1(void, system, const char*, cmd)
void my_shutdown(const char *cmd) {
system(cmd);
}
Hope this help.


Reply With Quote
