Last active
August 11, 2021 03:28
-
-
Save BenSYZ/71026ad184b206c5f9e42be33b542250 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 最后生成的目标,即module_example.ko | |
obj-m:=module_example.o | |
CURRENT_PATH := $(shell pwd) | |
LINUX_KERNEL := $(shell uname -r) | |
LINUX_KERNEL_PATH := /usr/lib/modules/$(LINUX_KERNEL)/build | |
all: | |
make -C $(LINUX_KERNEL_PATH) M=$(CURRENT_PATH) modules | |
clean: | |
make -C $(LINUX_KERNEL_PATH) M=$(CURRENT_PATH) clean | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <linux/module.h> | |
#include <linux/kernel.h> | |
#include <linux/init.h> | |
static int __init lkp_init(void){ | |
printk("<1>Hello, world! from the kernel space...\n"); | |
return 0; | |
} | |
static void __exit lkp_exit(void){ | |
printk("<1>Goodbye, world! leaving the kernel space...\n"); | |
} | |
module_init(lkp_init); | |
module_exit(lkp_exit); | |
MODULE_LICENSE("GPL"); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment