System call error

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • creativeinspiration
    New Member
    • Jun 2007
    • 25

    System call error

    Hey guys. I am trying to implement a system call in linux kernel. I usually use ubutntu, but this I am doing on Fedora. I am using kernel 2.6. Here is what I did:

    1. Added a line to arch/i386/kernel/syscall_table.S :

    .long sys_foo

    2. Added a line to linux/include/asm-i386/unistd.h:

    #define __NR_foo 324

    also incremented the call count by 1.

    3. Added this code to sys.c

    [code]
    asmlinkage long sys_foo(void)
    {
    printk("Hello Kernel World");
    return THREAD_SIZE;
    }
    [\code]

    4. Wrote this user level client program to test my call:

    Code:

    #include <unistd.h>
    #include <linux/unistd.h>


    #define __NR_foo 324
    __syscall0(long , foo)

    int main()
    {

    foo();
    return 0;
    }

    However, when I compile the user level program, I get the following error:

    success.c:6: error: expected declaration specifiers or ‘...’ before ‘foo’
    success.c: In function ‘__syscall0’:
    success.c:9: error: expected ‘=’, ‘,’, ‘;’, ‘asm’ or ‘__attribute__’ before ‘{’ token
    success.c:6: error: parameter name omitted
    success.c:13: error: expected ‘{’ at end of input

    Anybody has any idea?
  • juliushemanth
    New Member
    • Dec 2007
    • 1

    #2
    I am stuck with same problem while implementing system call....

    somebody please help me out...

    Comment

    • MarshMallow
      New Member
      • Nov 2007
      • 52

      #3
      Originally posted by juliushemanth
      I am stuck with same problem while implementing system call....

      somebody please help me out...
      It looks like you didn't pay too much attention to makefiles.

      Comment

      • niko
        New Member
        • Dec 2007
        • 1

        #4
        -I /usr/include/linux/

        Comment

        Working...