I have a question about the filp_open
function:
I can get the error number from the IS_ERR
function but I do not understand the meaning of the error number.
Where can find the filp_open
error number definitions?
I have a question about the filp_open
function:
I can get the error number from the IS_ERR
function but I do not understand the meaning of the error number.
Where can find the filp_open
error number definitions?
You should not use filp_open
to read/write files in kernel mode. For (obvious) security reasons. Other reasons can be found in this answer and this answer (taken from this comment). The official documentation also recomends not to use flp_open
:
This is the helper to open a file from kernelspace if you really have to. But in generally you should not do this, so please move along, nothing to see here..
The kernel uses the same error numbers (errno) in kernel space as in the user space. So, as OmnipotentEntity pointed out, you can see man errno
for a reference on what the errors generally mean.
It is also helpful to have a look at the actual implementation of filp_open
and its possible error sources, such as file_open_name
and build_open_flags
.
Note that IS_ERR
does not return the error but merely returns whether the supplied pointer is an error value or not. You have to use PTR_ERR
to retrieve the error value from the pointer in case IS_ERR
is true. Example:
fptr = filp_open(...)
if (IS_ERR(fptr)) {
printk("%d\n", PTR_ERR(fptr));
}