Kernel Modul erstellen: Unterschied zwischen den Versionen
Zur Navigation springen
Zur Suche springen
(Die Seite wurde neu angelegt: „=Module Quellcode hello.c= <pre> #include <linux/init.h> #include <linux/module.h> #include <linux/kernel.h> static int __init hello_init(void) { printk(K…“) |
|||
| Zeile 17: | Zeile 17: | ||
module_exit(hello_exit); | module_exit(hello_exit); | ||
| − | + | MODULE_LICENSE("GPL"); | |
MODULE_DESCRIPTION("A simple Hello World module"); | MODULE_DESCRIPTION("A simple Hello World module"); | ||
MODULE_AUTHOR("Your Name"); | MODULE_AUTHOR("Your Name"); | ||
</pre> | </pre> | ||
| + | |||
=Makefile= | =Makefile= | ||
<pre> | <pre> | ||
Version vom 26. Juni 2023, 12:20 Uhr
Module Quellcode hello.c
#include <linux/init.h>
#include <linux/module.h>
#include <linux/kernel.h>
static int __init hello_init(void) {
printk(KERN_INFO "Hello, World!\n");
return 0;
}
static void __exit hello_exit(void) {
printk(KERN_INFO "Goodbye, World!\n");
}
module_init(hello_init);
module_exit(hello_exit);
MODULE_LICENSE("GPL");
MODULE_DESCRIPTION("A simple Hello World module");
MODULE_AUTHOR("Your Name");
Makefile
obj-m += hello.o all: make -C /lib/modules/$(shell uname -r)/build M=$(PWD) modules clean: make -C /lib/modules/$(shell uname -r)/build M=$(PWD) clean
Kompilierung
- make
Laden
- insmod hello
Entladen
- rmmod hello