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?
Place a header containing the new struct
in include/uapi/linux
. Avoid namespace pollution by using the appropriate types eg __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.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.