Find the answer to your Linux question:
Results 1 to 2 of 2
Enjoy an ad free experience by logging in. Not a member yet? Register.
  1. #1

    Unhappy 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.....

  2. #2
    Just Joined! alex1983-0112's Avatar
    Join Date
    Apr 2008
    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) {

    Hope this help.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts