system calls - returning error code in linux kernel -
i trying understand how linux system calls return error codes. bumped times() system call. simple system call copies data user space , if operation not successful returns -efault
:
syscall_define1(times, struct tms __user *, tbuf) { if (tbuf) { struct tms tmp; do_sys_times(&tmp); if (copy_to_user(tbuf, &tmp, sizeof(struct tms))) return -efault; } force_successful_syscall_return(); return (long) jiffies_64_to_clock_t(get_jiffies_64()); }
my questions are:
- why
-efault
? shouldn'tefault
without minus? - is common return negative error codes?
from man 2 syscalls:
note: system calls indicate failure returning negative error number caller; when happens, wrapper function negates returned error number (to make positive), copies
errno
, , returns-1
caller of wrapper.
see next answers:
Comments
Post a Comment