Last active
September 9, 2016 04:37
-
-
Save yagihiro/304683 to your computer and use it in GitHub Desktop.
minimum linux kernel module
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 := mykmod.o | |
KDIR := /lib/modules/$(shell uname -r)/build | |
PWD := $(shell pwd) | |
default: | |
$(MAKE) -C $(KDIR) SUBDIRS=$(PWD) modules |
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> | |
static int __devinit mykmod_init(void) | |
{ | |
pr_info("mykmod loaded\n"); | |
return 0; | |
} | |
static void __devexit mykmod_exit(void) | |
{ | |
pr_info("mykmod exit\n"); | |
} | |
module_init(mykmod_init); | |
module_exit(mykmod_exit); | |
MODULE_DESCRIPTION("mykmod"); | |
MODULE_LICENSE("GPL"); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment