Find the answer to your Linux question:
Results 1 to 3 of 3
Hi everyone I need to write a system call for the first time and it's proven to be pretty frustrating - I'm having trouble wrapping my head around it. But ...
Enjoy an ad free experience by logging in. Not a member yet? Register.
  1. #1
    Just Joined!
    Join Date
    Sep 2011
    Posts
    4

    Writing a System Call


    Hi everyone

    I need to write a system call for the first time and it's proven to be pretty frustrating - I'm having trouble wrapping my head around it. But I figure I'll start off slow. Here is my declaration in sys.c:
    Code:
    SYSCALL_DEFINE1 (getprinfo, struct prinfo *info)
    The compiler returns:
    Code:
    /home/dtroberts/kernelSrc/kernel/sys.c:1816:1: error: macro "__SC_DECL1" requires 2 arguments, but only 1 given
    There are two arguments there. I can also see that info isn't being included in the compiler's output; it's saying that info is undeclared. Am I using SYSCALL_DEFINE1 incorrectly? Am I treating it too much like a user-space program?

    Thank you.

  2. #2
    Linux Guru Cabhan's Avatar
    Join Date
    Jan 2005
    Location
    Seattle, WA, USA
    Posts
    3,252
    Doing a quick trace through the /include/linux/syscalls.h file in the kernel source code implies to me that your arguments and their types should be separate:
    Code:
    SYSCALL_DEFINE1(getprinfo, struct prinfo *, info)
    Having never written a system call, I'm not entirely sure that this is accurate, but given that __SC_DECL1 is defined as:
    Code:
    #define __SC_DECL1(t1, a1)	t1 a1
    I suspect that this is true.

  3. #3
    Just Joined!
    Join Date
    Sep 2011
    Posts
    4
    Quote Originally Posted by Cabhan View Post
    Doing a quick trace through the /include/linux/syscalls.h file in the kernel source code implies to me that your arguments and their types should be separate:
    Code:
    SYSCALL_DEFINE1(getprinfo, struct prinfo *, info)
    Having never written a system call, I'm not entirely sure that this is accurate, but given that __SC_DECL1 is defined as:
    Code:
    #define __SC_DECL1(t1, a1)	t1 a1
    I suspect that this is true.
    Yep, you were right. Defining it as you said fixed my error. Thank you!

Posting Permissions

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