I'm writing a kernel module, and I need to use the errno
variable.
I included <linux/errno.h>
with no problems, and added extern int errno;
,
to my code.
I use the variable in the following way: errno = ENOENT;
.
When I compile the program I get the following warning, and I cannot load the module:
WARNING: "errno" [module path] undefined!
Why is that happening?
I am using a VM of Ubuntu 12.0.4
EDIT: My hooked open syscall looks like this:
asmlinkage int hooked_open(char* path, int flags){
if(strstr(path, file_to_hide) != NULL){
return -ENOENT;
}
return original_open(path, flags);
}
When running strace cat file_to_hide when the module is loaded the return value is 4294967294, no error.
When running strace on a file that does not exist, return value is -1 and ENOENT is raised. I would like to be able to imitate that.