Skip to content
Advertisement

sys_ functions in syscalls.h are undefined

I’m just making a kernel module. And I meet this warnings:

JavaScript

How can I fix this problem?

This is my codes:

JavaScript

And my workspace is Ubuntu 3.13.0-66-generic.

I need to use file descriptor. So, I can’t use filp_ functions(like filp_open).

Edit1:

My Makefile: obj-m += NAME.o

JavaScript

Advertisement

Answer

Calling system calls(sys_* functions) from the kernel code is not a good idea. Actually, many of system calls can be expressed in functions, available for kernel modules.

I need to use file descriptor. So, I can’t use filp_ functions(like filp_open).

File descriptor can be easy transformed into file pointer using fdget. See, e.g., implementation of fallocate system call (SYSCALL_DEFINE4(fallocate...) in fs/open.h).

As for errno, this variable is user space only. System calls return error using -E convention, it is libc who stores this value into errno.

User contributions licensed under: CC BY-SA
5 People found this is helpful
Advertisement