I'm trying to compile and I keep getting the following error: enter image description here
I've included the asm-i386/errno.h
once and it didn't work. Also I've tried including linux/errno.h
and it didn't work ether.
What file should I include?
I'm trying to compile and I keep getting the following error: enter image description here
I've included the asm-i386/errno.h
once and it didn't work. Also I've tried including linux/errno.h
and it didn't work ether.
What file should I include?
There is no errno
variable in Linux kernel: this variable lives in user space only.
If kernel function wants to report about the error and specify the error code, it encapsulates the error code into the returning value. There are 3 possibilities of such encapsulation, dependent from value type returned on success:
This mostly used convention is sometimes referenced as 0/-err
.
ERR_PTR(err)
on fail.This expression is evaluated to the pointer, which can never points to real kernel object. This convention may be used even if NULL is valid result.
+val/-err
.In case when 0 is valid result, this convention may be used too: +val/0/-err
.
When user space library needs to set errno according to kernel's request, it checks result of the system call (which is the only way for perform request to the kernel). Dependent on syscall, either 1 or 3 convention is used (return type of any system call is long
).
Example of "setting" errno
in kernel space for user space see here.