Last active
November 24, 2023 15:34
-
-
Save matwey/5b8570191724d398105466d17a808952 to your computer and use it in GitHub Desktop.
Linux kernel module example
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/init.h> | |
MODULE_LICENSE("GPL"); | |
static int hello_init(void) { | |
printk(KERN_INFO "Goodbye, cruel world!\n"); | |
return 0; | |
} | |
static void hello_exit(void) { | |
printk(KERN_INFO "Goodbye once more, cruel world!\n"); | |
} | |
module_init(hello_init); | |
module_exit(hello_exit); |
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
obj-m := library.o | |
default: | |
$(MAKE) -C /home/matwey/lab/linux/ M=$(PWD) modules | |
builtin: | |
$(MAKE) -C /lib/modules/$(shell uname -r)/build M=$(PWD) modules | |
clean: | |
$(MAKE) -C /home/matwey/lab/linux/ M=$(PWD) clean |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment