mirror of
https://github.com/cirosantilli/linux-kernel-module-cheat.git
synced 2026-01-27 04:01:36 +01:00
panic
This commit is contained in:
@@ -39,3 +39,4 @@ See also: <https://superuser.com/questions/351387/how-to-stop-kernel-messages-fr
|
|||||||
1. [debugfs](kernel_module/debugfs.c)
|
1. [debugfs](kernel_module/debugfs.c)
|
||||||
1. [fops](kernel_module/fops.c)
|
1. [fops](kernel_module/fops.c)
|
||||||
1. [workqueue](kernel_module/workqueue.c)
|
1. [workqueue](kernel_module/workqueue.c)
|
||||||
|
1. [panic](kernel_module/panic.c)
|
||||||
|
|||||||
@@ -11,6 +11,8 @@ Hello world module.
|
|||||||
#include <linux/module.h>
|
#include <linux/module.h>
|
||||||
#include <linux/kernel.h>
|
#include <linux/kernel.h>
|
||||||
|
|
||||||
|
MODULE_LICENSE("GPL");
|
||||||
|
|
||||||
int init_module(void)
|
int init_module(void)
|
||||||
{
|
{
|
||||||
printk(KERN_INFO "hello init\n");
|
printk(KERN_INFO "hello init\n");
|
||||||
|
|||||||
@@ -7,6 +7,8 @@ Mostly to check that our build infrastructure can handle more than one module!
|
|||||||
#include <linux/module.h>
|
#include <linux/module.h>
|
||||||
#include <linux/kernel.h>
|
#include <linux/kernel.h>
|
||||||
|
|
||||||
|
MODULE_LICENSE("GPL");
|
||||||
|
|
||||||
int init_module(void)
|
int init_module(void)
|
||||||
{
|
{
|
||||||
printk(KERN_INFO "hello2 init\n");
|
printk(KERN_INFO "hello2 init\n");
|
||||||
|
|||||||
26
kernel_module/panic.c
Normal file
26
kernel_module/panic.c
Normal file
@@ -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 <linux/module.h>
|
||||||
|
#include <linux/kernel.h>
|
||||||
|
|
||||||
|
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");
|
||||||
|
}
|
||||||
@@ -1,4 +1,3 @@
|
|||||||
|
|
||||||
/*
|
/*
|
||||||
Usage:
|
Usage:
|
||||||
|
|
||||||
@@ -7,6 +6,9 @@ Usage:
|
|||||||
rmmod workqueue
|
rmmod workqueue
|
||||||
|
|
||||||
Creates a separate thread. So init_module can return, but some work will still get done.
|
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 <linux/kernel.h>
|
#include <linux/kernel.h>
|
||||||
|
|||||||
Reference in New Issue
Block a user