Docker loading kernel modules

In Linux host: Run the container in privileged mode (–privileged) Add all capabilities (–cap-add=ALL) mount host /lib/modules into the container (-v /lib/modules:/lib/modules) docker run –name container_name \ –privileged \ –cap-add=ALL -d \ -v /dev:/dev \ -v /lib/modules:/lib/modules \ image_id Caution: Here all Linux capabilities are added so capabilities can be refined. Few words about Linux … Read more

Read/write files within a Linux kernel module

You should be aware that you should avoid file I/O from within Linux kernel when possible. The main idea is to go “one level deeper” and call VFS level functions instead of the syscall handler directly: Includes: #include <linux/fs.h> #include <asm/segment.h> #include <asm/uaccess.h> #include <linux/buffer_head.h> Opening a file (similar to open): struct file *file_open(const char … Read more