Make handle_myst_reloc get a module_pack.
[ksplice.git] / ksplice-undo.in
blobcf6efac2d9d1df16cda3c99d8625bd00863dd30b
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 unless(-e "/proc/ksplice_$kid") {
54 print "Ksplice id $kid is not present in the kernel\n";
55 exit(0);
57 unless(runval("echo 1 > /proc/ksplice_$kid") == 0 and
58 (runstr("lsmod") =~ m/- $/m or runval_raw("rmmod ksplice_$kid") == 0)) {
59 my $dmesg = runstr("dmesg | grep ksplice");
60 while($dmesg =~ /ksplice: Preparing to reverse/) {
61 $dmesg = $';
64 if($dmesg =~ /to-be-reversed code is busy/) {
65 print <<END
67 Ksplice has aborted the undo operation because it appears that the code that
68 you are trying to change is continuously in use by the system. More
69 specifically, Ksplice has been unable to find a moment when one or more of the
70 to-be-changed functions is not on a thread's kernel stack.
72 END
75 die;
78 exit(0);
80 =head1 NAME
82 ksplice-undo - Undo a Ksplice update that has been applied to the running kernel
84 =head1 SYNOPSIS
86 B<ksplice-undo> I<KSPLICE_ID>
88 =head1 DESCRIPTION
90 B<ksplice-undo> takes as input a Ksplice identification tag, as reported by
91 L<ksplice-view(8)>, and it reverses that update within the running binary kernel.
93 =head1 OPTIONS
95 =over 8
97 =item B<--debug>
99 Reverses the update with debugging output enabled. Recommended only for
100 debugging. I<DEBUG_LEVEL> should be an integer between 0 and 2. B<--debug=2>
101 provides the most debugging information.
103 =over
105 =item Z<> B<0>
107 No debugging output.
109 =item Z<> B<1>
111 Provides basic kernel stack check debugging output.
113 =item Z<> B<2>
115 Provides full kernel stack check debugging output.
117 =back
119 =back
121 =head1 SEE ALSO
123 L<ksplice-create(8)>, L<ksplice-apply(8)>, L<ksplice-view(8)>
125 =head1 COPYRIGHT
127 Copyright (C) 2008 Jeffrey Brian Arnold <jbarnold@mit.edu>.
129 This is free software and documentation. You can redistribute and/or modify it
130 under the terms of the GNU General Public License, version 2.
132 =cut