This module makes a character device.
This module shows how to use syscalls with a character device kernel module. This example implements following file operations.
Their implementations are registered with the file_operations struct.
static struct file_operations kmod_fops = {
.owner = THIS_MODULE,
.open = kmod_open,
.mmap = kmod_mmap,
.unlocked_ioctl = kmod_ioctl,
.poll = kmod_poll,
.release = kmod_release,
};
The kernel module installation.
$ make
$ insmod ./kmod.ko
Test application.
$ cd app
$ make
$ ./kmod-test
This program is tested on Ubuntu 17.04 with Linux-4.10.
Do you have the header files of your Linux kernel or the kernel source itself?
The following command installing the kernel header files may be able to solve the problem.
sudo apt-get install linux-headers-$(uname -r)