Filp_open Linux error counts

I have a question about a function filp_open

:

I can get the error number from the function IS_ERR

, but I don't understand the meaning of the error number.

Where can you find definitions for the number of errors filp_open

?

+3


source to share


1 answer


You shouldn't use filp_open

kernel mode read / write files. For security reasons. Other reasons can be found in this answer and this answer (taken from this comment ). The official documentation also recommends against using flp_open

:

It's a helper to open a file from the kernel if you really need to. But in general you shouldn't be doing this, so please move, there is nothing to see here.

Error code definitions

The kernel uses the same error numbers (errno) in kernel space as in user space. So, as OmnipotentEntity pointed out , you can see man errno

for reference what the errors usually mean.



It is also helpful to look at the actual implementation filp_open

and possible sources of errors such as file_open_name

and build_open_flags

.

Note that it IS_ERR

does not return an error, but simply returns whether the delivery pointer is an error value or not. You should use PTR_ERR

to retrieve the error value from the pointer in case if IS_ERR

true. Example:

fptr = filp_open(...)

if (IS_ERR(fptr)) {
    printk("%d\n", PTR_ERR(fptr));
}

      

+4


source







All Articles