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:

  1. why -efault? shouldn't efault without minus?
  2. 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

Popular posts from this blog

commonjs - How to write a typescript definition file for a node module that exports a function? -

openid - Okta: Failed to get authorization code through API call -

ios - Change Storyboard View using Seague -