From 9e9c19185059163e6196fb885ffae006def8f324 Mon Sep 17 00:00:00 2001 From: Thadeu Lima de Souza Cascardo Date: Sat, 5 Dec 2009 12:34:34 -0200 Subject: [PATCH] Linux kernel module hello world! --- Makefile | 11 +++++++++++ hello.c | 17 +++++++++++++++++ 2 files changed, 28 insertions(+) create mode 100644 Makefile create mode 100644 hello.c diff --git a/Makefile b/Makefile new file mode 100644 index 0000000..d26e7c6 --- /dev/null +++ b/Makefile @@ -0,0 +1,11 @@ +ifneq ($(KERNELRELEASE),) + obj-m := hello.o +else + KERNELDIR ?= /lib/modules/$(shell uname -r)/build + PWD := $(shell pwd) +default: + $(MAKE) -C $(KERNELDIR) M=$(PWD) modules + +clean: + $(MAKE) -C $(KERNELDIR) M=$(PWD) clean +endif diff --git a/hello.c b/hello.c new file mode 100644 index 0000000..01e8c26 --- /dev/null +++ b/hello.c @@ -0,0 +1,17 @@ +#include + +MODULE_LICENSE("GPL"); + +static int hello_init(void) +{ + printk(KERN_ALERT "Hello, world!\n"); + return 0; +} + +static void hello_exit(void) +{ + printk(KERN_ALERT "Goodbye, cruel world!\n"); +} + +module_init(hello_init); +module_exit(hello_exit); -- 2.20.1