From 9b173b99874556041c3302b338e27e48978ec967 Mon Sep 17 00:00:00 2001 From: lonkaars Date: Wed, 17 Apr 2024 13:45:51 +0200 Subject: hello world working --- .gitignore | 7 +++++++ 1/Makefile | 8 ++++++++ 1/main.c | 17 +++++++++++++++++ 3 files changed, 32 insertions(+) create mode 100644 .gitignore create mode 100644 1/Makefile create mode 100644 1/main.c diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..995c2a4 --- /dev/null +++ b/.gitignore @@ -0,0 +1,7 @@ +*.ko +*.mod +*.mod.c +*.o +*.cmd +modules.order +Module.symvers diff --git a/1/Makefile b/1/Makefile new file mode 100644 index 0000000..990d695 --- /dev/null +++ b/1/Makefile @@ -0,0 +1,8 @@ +RELEASE := $(shell uname -r) +KERNEL := /lib/modules/$(RELEASE)/build + +obj-m += main.o + +all: + $(MAKE) -C $(KERNEL) M=$(PWD) modules + diff --git a/1/main.c b/1/main.c new file mode 100644 index 0000000..819ba32 --- /dev/null +++ b/1/main.c @@ -0,0 +1,17 @@ +#include +#include + +MODULE_LICENSE("MIT"); + +static int hello_init(void) { + printk(KERN_ALERT "Hello, world\n"); + return 0; +} + +static void hello_exit(void) { + printk(KERN_ALERT "Goodbye, world\n"); +} + +module_init(hello_init); +module_exit(hello_exit); + -- cgit v1.2.3