I just know how to add system calls to kernel of Linux. My system call (like lots of other system calls) takes a pointer to a struct created by me. If I want to add the struct to kernel source how and where should I add it?
0
votes
1 Answers
0
votes
Place a header containing the new struct
in include/uapi/linux
.
Avoid namespace pollution by using the appropriate types e.g. __u16
instead of unsigned short
/uint16_t
, __kernel_time_t
instead of time_t
...etc. Check out struct mii_ioctl_data
for an example.
By adding a header-y += new_header.h
entry to include/uapi/linux/Kbuild
, you can then export the header with make headers_install
.
By default, it installs the headers in ./usr
. If you want it to install them as system headers, use make headers_install INSTALL_HDR_PATH=/usr
instead. This results in the contents of the uapi
directory being merged into /usr/include
. You may then #include <linux/new_header.h>
in your userspace program.