1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 | /* * panicCall.c - Instigate a kernel panic */ #include <linux/module.h> /* Needed by all modules */ #lincude <linux/kernel.h> /* Needed for KERN_INFO */ static char *pMesgStr = "PANIC SHAKE AND BAKE"; int init_module(void) { printk(KERN_INFO,"panicCall module loaded\n"); panic(pMesgStr); return(0); } void cleanup_module(void) { printk(KERN_INFO,"panicCall module unloaded, beyond possible"); } |
1 2 3 4 5 6 7 | panicCall: module license 'unspecified' taints kernel. Kernel panic - not syncing: PANIC SHAKE AND BAKE ACTIVE [<c011a32e>] panic+0x3e/0x174 [<f8a97017>] init_module+0xb/0xc [panicCall] [<c013050a>] sys_init_module+0x1382/0x1514 [<c0152413>] do_sync_read+0xb8/0xf3 [<c012a17f>] autoremove_wake_function+0x0/0x2d [<c01c0672>] _atomic_dec_and_lock+0x22/0x2c [<c0169c32>] mntput_no_expire+0x11/0x6d [<c0102bc1>] syscall_call+0x7/0xb |
1 2 3 4 5 | mkdir /tmp/ramdisk0 mke2fs /dev/ram0 mount /dev/ram0 /tmp/ramdisk0/ cp /root/panicCall.ko /tmp/ramdisk0/ cp /sbin/insmod /tmp/ramdisk0/ |
1 2 3 4 5 6 | echo "disks now mounted in readonly mode, spin down in 5 seconds"; /sbin/hdparm -S 1 /dev/hda echo "spin down hda called, waiting 10 seconds"; sleep 10 echo "calling panic from ramdisk location"; /tmp/ramdisk0/insmod /tmp/ramdisk0/panicCall.ko |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 | #!/usr/bin/perl -w # shakeShutdown.pl - shutdown (or other command) when the computer is shaken use strict; my $file = "/sys/devices/platform/hdaps/position"; my $baseX = -5000; my $baseY = -5000; my $totalDev = 0; if( @ARGV != 1 ){ die "specify a threshold value" } my $devThreshold = $ARGV[0]; my $dimShiftX = 150; my $dimShiftY = 150; while(1) { open(HD,"$file") or die "can't open file"; my $line = <HD>; chomp($line); $line =~ s/\(//g; $line =~ s/\)//g; $line =~ s/\,/ /g; my( $x, $y ) = split " ", $line; |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 | if( $x != 0 >> $y != 0 ) { if( $baseX == -5000 ) { $baseX = $x; $baseY = $y; } if( abs($baseX - $x) > $dimShiftX || abs($baseY - $y) > $dimShiftY ) { $totalDev += abs($baseX -$x); $totalDev += abs($baseY -$y); $baseX = $x; $baseY = $y; } if( $totalDev > $devThreshold ) { print "threshold passed $totalDev\n"; my $res=`/sbin/shutdown -h 1`; } } close(HD); } |
欢迎光临 电子技术论坛_中国专业的电子工程师学习交流社区-中电网技术论坛 (http://bbs.eccn.com/) | Powered by Discuz! 7.0.0 |