Skip to content

Instantly share code, notes, and snippets.

@matwey
Last active November 24, 2023 15:34
Show Gist options
  • Save matwey/5b8570191724d398105466d17a808952 to your computer and use it in GitHub Desktop.
Save matwey/5b8570191724d398105466d17a808952 to your computer and use it in GitHub Desktop.
Linux kernel module example
#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);
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