Add a New Module in Linux Kernel


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

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

2. Create Makefile in /root/linux-2.6.35.14/net/netlog:
# 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-2.6.35.14/net/netlog:
# vi Kconfig
Add the following lines:
config NETLOG
tristate "net_log example module"
help
Enable example net_log module.

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

5. Modify Makefile in /root/linux-2.6.35.14/net:
# 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-2.6.35.14/.config

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