diff --git a/README.md b/README.md index 8032493..8341064 100644 --- a/README.md +++ b/README.md @@ -39,3 +39,4 @@ See also: #include +MODULE_LICENSE("GPL"); + int init_module(void) { printk(KERN_INFO "hello init\n"); diff --git a/kernel_module/hello2.c b/kernel_module/hello2.c index cbdd63b..7beebbd 100644 --- a/kernel_module/hello2.c +++ b/kernel_module/hello2.c @@ -7,6 +7,8 @@ Mostly to check that our build infrastructure can handle more than one module! #include #include +MODULE_LICENSE("GPL"); + int init_module(void) { printk(KERN_INFO "hello2 init\n"); diff --git a/kernel_module/panic.c b/kernel_module/panic.c new file mode 100644 index 0000000..8a0729c --- /dev/null +++ b/kernel_module/panic.c @@ -0,0 +1,26 @@ +/* +It will happen eventually, so you might as well learn do deal with it. + +TODO: how to scroll up to see full trace? Shift + Page Up does not work as it normally does: +https://superuser.com/questions/848412/scrolling-up-the-failed-screen-with-kernel-panic + +The alternative is to get the serial data out streamed to console or to a file: + +- https://superuser.com/questions/269228/write-qemu-booting-virtual-machine-output-to-a-file +- http://www.reactos.org/wiki/QEMU#Redirect_to_a_file +*/ + +#include +#include + +int init_module(void) +{ + printk(KERN_INFO "panic init\n"); + panic("hello panic"); + return 0; +} + +void cleanup_module(void) +{ + printk(KERN_INFO "panic cleanup\n"); +} diff --git a/kernel_module/workqueue_cheat.c b/kernel_module/workqueue_cheat.c index a8f1110..ed33397 100644 --- a/kernel_module/workqueue_cheat.c +++ b/kernel_module/workqueue_cheat.c @@ -1,4 +1,3 @@ - /* Usage: @@ -7,6 +6,9 @@ Usage: rmmod workqueue Creates a separate thread. So init_module can return, but some work will still get done. + +TODO why can't call this workqueue.ko? +https://unix.stackexchange.com/questions/364956/how-can-insmod-fail-with-kernel-module-is-already-loaded-even-is-lsmod-does-not */ #include