From 395fd5f8ac9b98dac953183fa3d8ccb38c3a86c1 Mon Sep 17 00:00:00 2001 From: hackbard Date: Sun, 14 Apr 2002 16:48:28 +0000 Subject: [PATCH] added hello kernel module --- hello/Makefile | 26 ++++++++++++++++++++++++++ hello/hello.c | 14 ++++++++++++++ 2 files changed, 40 insertions(+) create mode 100644 hello/Makefile create mode 100644 hello/hello.c diff --git a/hello/Makefile b/hello/Makefile new file mode 100644 index 0000000..6339fdd --- /dev/null +++ b/hello/Makefile @@ -0,0 +1,26 @@ +# Makefile of hello.o - my first kernel module. + +INCLUDEDIR = /usr/include + +CFLAGS = -D__KERNEL__ -DMODULE -O -Wall -I$(INCLUDEDIR) + +# findout kernel version. +VER = $(shell awk -F\" '/REL/ {print $$2}' $(INCLUDEDIR)/linux/version.h) + +OBJS = hello.o + +all: $(OBJS) + +#hello.o: hello.o +# $(LD) -r $^ -o $@ + +install: + install -d /lib/modules/$(VER)/misc + install -c hello.o /lib/modules/$(VER)/misc + +clean: + rm -f *.o *~ core + +uninstall: + rm -f /lib/modules/$(VER)/misc/hello.o + diff --git a/hello/hello.c b/hello/hello.c new file mode 100644 index 0000000..48bcb33 --- /dev/null +++ b/hello/hello.c @@ -0,0 +1,14 @@ +/* my first kernel driver :-) */ + +#define MODULE +#include + +int init_module(void) { + printk("<1>hi hackbard, here is your kernel speaking! :)\n"); + return 0; +} + +void cleanup_module(void) { + printk("<1>bye hackbard ...\n"); +} + -- 2.20.1