Reputation: 73
I have implemented a system call which returns values like 0, 1 and 2, according to some conditions in the process priority. I am performing a syscall()
in a file. When the system call returns 0, I am getting the return value of syscall()
as 0. But, when it return 1 or 2, I am getting -1 for 1 and the system call number for any other values. Please let me know, is it possible to return values apart from 0 and -1.
Upvotes: 1
Views: 693
Reputation: 46
The kernel implementation of a system call does not return a value, it returns an error code. The first argument to your function is a "struct thread", and you pass the return value back to userspace by setting td->td_retval[0] to the desired return value. See, for example, the implementation of getpid() in sys/kern/kern_prot.c.
Upvotes: 3