Go back OS Review Device Driver NS Tools Home Papers Daily Link To Main |
Hello, World Module
=============== hello.c ================================ #include <linux/module.h> int init_module(void) { printk("<1>Hello world \n"); return 0; } void cleanup_module(void) { printk("<1>Goodbye world \n"); } ==================================================== ================= Makefile ======================== #DEBUG = y INCLUDEDIR = /usr/src/linux/include ifeq ($(DEBUG),y) DEBFLAGS = -O -g -DJIT_DEBUG -DJIQ_DEBUG -DALL_DEBUG else DEBFLAGS = -O2 endif CFLAGS = -D__KERNEL__ -DMODULE -Wall $(DEBFLAGS) CFLAGS += -I$(INCLUDEDIR) OBJS = hello.o all: $(OBJS) $(CC) $(CFLAGS) -c $^ -o $@ clean: rm -f *.o hello.o: hello.c $(CC) $(CFLAGS) -c $^ -o $@ ======================================================= make /sbin/insmod hello.o lsmod rmmod hello.o /var/log/·Î À̵¿Çؼ "tail messages" |