C – Linux system call return value

Linux system call return value… here is a solution to the problem.

Linux system call return value

During homework, we were asked to add system calls to the Linux kernel (Red Hat 2.4.18). Depending on the assignment, the return value of the new system call should be void. The system call itself is very simple (only one assignment is required) and error-free.
From what I’ve read and learned, system calls usually return a negative value for failure or 0 for success. My question is whether this is just a common practice or is it necessary? Can a system call return void?


In Linux, all system calls return long values, if they are at all. Suppose you declare your system call using:

    /* ... */

This results in:

asmlinkage long sys_mycall(void)

If you don’t have any useful return values and the call doesn’t fail, simply return 0 each time to indicate success.

Related Problems and Solutions