Add explanation of map_printk check.
[ksplice.git] / ksplice-undo.in
blobccbec96150e9505a1b5b9a0d4ee09f20a851cf05
1 #!/usr/bin/perl
3 # Copyright (C) 2008 Jeffrey Brian Arnold <jbarnold@mit.edu>
5 # This program is free software; you can redistribute it and/or modify
6 # it under the terms of the GNU General Public License, version 2.
8 # This program is distributed in the hope that it will be useful,
9 # but WITHOUT ANY WARRANTY; without even the implied warranty of
10 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
11 # GNU General Public License for more details.
13 # You should have received a copy of the GNU General Public License
14 # along with this program; if not, write to the Free Software
15 # Foundation, Inc., 51 Franklin Street - Fifth Floor, Boston, MA
16 # 02110-1301, USA.
18 use Getopt::Long;
19 use Cwd 'abs_path', 'getcwd';
20 use Pod::Usage;
21 use strict;
22 use warnings;
23 use lib 'KSPLICE_DATA_DIR';
24 use ksplice;
26 my ($help, $wantversion, $debug) = (0, 0, 0);
27 GetOptions("help|?" => \$help,
28 "version" => \$wantversion,
29 "verbose|v!" => \$verbose,
30 "debug=i" => \$debug) or pod2usage(1);
32 if($wantversion) {
33 print $version_str;
34 exit(0);
36 pod2usage(1) if($help || scalar(@ARGV != 1));
38 my $kid = $ARGV[0];
39 $kid =~ s/^ksplice[_-]//;
41 if($debug) {
42 if(! -d "/sys/module/ksplice_$kid") {
43 die "/sys/module/ksplice_$kid does not exist";
45 elsif(! -d "/sys/module/ksplice_$kid/parameters") {
46 runval("echo $debug > /sys/module/ksplice_$kid/debug");
48 else {
49 runval("echo $debug > /sys/module/ksplice_$kid/parameters/debug");
53 check_in_proc($kid);
54 runval("echo 1 > /proc/ksplice_$kid");
55 if(runval_raw("rmmod ksplice_$kid") != 0) {
56 my $dmesg = runstr("dmesg | grep ksplice");
57 while($dmesg =~ /ksplice: Preparing to reverse/) {
58 $dmesg = $';
61 if($dmesg =~ /to-be-reversed code is busy/) {
62 print <<END
64 Ksplice has aborted the undo operation because it appears that the code that
65 you are trying to change is continuously in use by the system. More
66 specifically, Ksplice has been unable to find a moment when one or more of the
67 to-be-changed functions is not on a thread's kernel stack.
69 END
72 die;
75 exit(0);
77 =head1 NAME
79 ksplice-undo - Undo a Ksplice update that has been applied to the running kernel
81 =head1 SYNOPSIS
83 B<ksplice-undo> I<KSPLICE_ID>
85 =head1 DESCRIPTION
87 B<ksplice-undo> takes as input a Ksplice identification tag, as reported by
88 L<ksplice-view(8)>, and it reverses that update within the running binary kernel.
90 =head1 OPTIONS
92 =over 8
94 =item B<--debug>
96 Reverses the update with debugging output enabled. Recommended only for
97 debugging. I<DEBUG_LEVEL> should be an integer between 0 and 2. B<--debug=2>
98 provides the most debugging information.
100 =over
102 =item Z<> B<0>
104 No debugging output.
106 =item Z<> B<1>
108 Provides basic kernel stack check debugging output.
110 =item Z<> B<2>
112 Provides full kernel stack check debugging output.
114 =back
116 =back
118 =head1 SEE ALSO
120 L<ksplice-create(8)>, L<ksplice-apply(8)>, L<ksplice-view(8)>
122 =head1 COPYRIGHT
124 Copyright (C) 2008 Jeffrey Brian Arnold <jbarnold@mit.edu>.
126 This is free software and documentation. You can redistribute and/or modify it
127 under the terms of the GNU General Public License, version 2.
129 =cut