4 # Functions useful for xfs_repair tests
6 # Copyright (c) 2000-2002 Silicon Graphics, Inc. All Rights Reserved.
8 # This program is free software; you can redistribute it and/or modify it
9 # under the terms of version 2 of the GNU General Public License as
10 # published by the Free Software Foundation.
12 # This program is distributed in the hope that it would be useful, but
13 # WITHOUT ANY WARRANTY; without even the implied warranty of
14 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
16 # Further, this software is distributed without any warranty that it is
17 # free of the rightful claim of any third person regarding infringement
18 # or the like. Any license provided herein, whether implied or
19 # otherwise, applies only to this software file. Patent licenses, if
20 # any, provided herein do not apply to combinations of this program with
21 # other software, or any other product whatsoever.
23 # You should have received a copy of the GNU General Public License along
24 # with this program; if not, write the Free Software Foundation, Inc., 59
25 # Temple Place - Suite 330, Boston MA 02111-1307, USA.
27 # Contact information: Silicon Graphics, Inc., 1600 Amphitheatre Pkwy,
28 # Mountain View, CA 94043, or:
32 # For further information regarding this notice, see:
34 # http://oss.sgi.com/projects/GenInfo/SGIGPLNoticeExplan/
42 # set values for off/len variables provided by db
43 eval `xfs_db -r -c "$struct" -c stack $SCRATCH_DEV | perl -ne '
44 if (/byte offset (\d+), length (\d+)/) {
45 print "offset=$1\nlength=$2\n"; exit
47 if [ -z "$offset" -o -z "$length" ]; then
48 echo "cannot calculate offset ($offset) or length ($length)"
51 length=`expr $length / 512`
52 src/devzero -v $value -b 1 -n $length -o $offset $SCRATCH_DEV \
53 | perl -npe 's/\d\.\d\dKb/X.XXKb/g'
60 /- agno = / && next; # remove each AG line (variable number)
61 s/(pointer to) (\d+)/\1 INO/;
62 s/(sb root inode value) (\d+)( \(NULLFSINO\))?/\1 INO/;
63 s/(realtime bitmap inode) (\d+)( \(NULLFSINO\))?/\1 INO/;
64 s/(realtime summary inode) (\d+)( \(NULLFSINO\))?/\1 INO/;
65 s/(inconsistent with calculated value) (\d+)/\1 INO/;
66 s/\.+(found)/\1/g; # remove "searching" output
68 s/(bad length -{0,1}\d+ for ag. 0, should be) (\d+)/\1 LENGTH/;
69 s/(bad length # -{0,1}\d+ for ag. 0, should be) (\d+)/\1 LENGTH/;
70 s/(bad agbno) (\d+)/\1 AGBNO/g;
71 s/(max =) (\d+)/\1 MAX/g;
73 s/(on inode) (\d+)/\1 INO/g;
74 s/(imap claims a free inode) (\d+)/\1 INO/;
75 s/(imap claims in-use inode) (\d+)/\1 INO/;
76 s/(cleared root inode) (\d+)/\1 INO/;
77 s/(resetting inode) (\d+)/\1 INO/;
78 s/(disconnected dir inode) (\d+)/\1 INO/;
80 s/internal log/<TYPEOF> log/g;
81 s/external log on \S+/<TYPEOF> log/g;
82 # realtime subvol - remove this whole line if it appears
83 s/ - generate realtime summary info and bitmap...\n//g;
89 fgrep -v records # lose records in/out lines
92 # do some controlled corrupting & ensure repair recovers us
98 _zero_position $value "$structure"
99 _scratch_xfs_repair 2>&1 | _filter_repair
100 # some basic sanity checks...
102 _scratch_mount #mount
103 POSIXLY_CORRECT=yes \
104 dd if=/bin/sh of=$SCRATCH_MNT/sh 2>&1 |_filter_dd #open,write
105 POSIXLY_CORRECT=yes \
106 dd if=$SCRATCH_MNT/sh of=/dev/null 2>&1 |_filter_dd #read
107 rm -f $SCRATCH_MNT/sh #unlink
108 umount $SCRATCH_MNT #umount
111 # make sure this script returns success