Add a New Module in Linux Kernel

A new in-memory logging module is added in the Linux kernel

1. Add the source code of the new module into the kernel:
# cd /root/linux-
# mkdir netlog
Copy the source files into this directory
Copy the header file into /root/linux-

2. Create Makefile in /root/linux-
# vi Makefile
Add the following lines:
obj-$(CONFIG_NETLOG) += netlog.o
netlog-y := net_log.o
obj-m += ram_log.o

3. Create Kconfig in /root/linux-
# vi Kconfig
Add the following lines:
config NETLOG
tristate "net_log example module"
Enable example net_log module.

4. Modify Kconfig in /root/linux-
# vi Kconfig
Add one line 'source "net/netlog/Kconfig"' before 'endif' in the end

5. Modify Makefile in /root/linux-
# vi Makefile
Add one line "obj-$(CONFIG_NETLOG) += netlog/" in the end

6. Compile the module:
# make
Type 'y' if it is a built-in module or 'm' if it is a loadable module
The new config flag should be added in /root/linux-

7. Install the module:
# make modules_install
# make install

Free Web Hosting