4 # Functions useful for xfs_repair tests
6 # Copyright (c) 2000 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
59 /- agno = / && next; # remove each AG line (variable number)
60 s/(pointer to) (\d+)/\1 INO/;
61 s/(sb root inode value) (\d+)/\1 INO/;
62 s/(realtime bitmap inode) (\d+)/\1 INO/;
63 s/(realtime summary inode) (\d+)/\1 INO/;
64 s/(inconsistent with calculated value) (\d+)/\1 INO/;
65 s/\.+(found)/\1/g; # remove "searching" output
67 s/(bad length -{0,1}\d+ for ag. 0, should be) (\d+)/\1 LENGTH/;
68 s/(bad length # -{0,1}\d+ for ag. 0, should be) (\d+)/\1 LENGTH/;
69 s/(bad agbno) (\d+)/\1 AGBNO/g;
70 s/(max =) (\d+)/\1 MAX/g;
72 s/(on inode) (\d+)/\1 INO/g;
73 s/(imap claims a free inode) (\d+)/\1 INO/;
74 s/(imap claims in-use inode) (\d+)/\1 INO/;
75 s/(cleared root inode) (\d+)/\1 INO/;
76 s/(resetting inode) (\d+)/\1 INO/;
77 s/(disconnected dir inode) (\d+)/\1 INO/;
83 fgrep -v records # lose records in/out lines
86 # do some controlled corrupting & ensure repair recovers us
92 _zero_position $value "$structure"
93 xfs_repair $SCRATCH_DEV 2>&1 | _filter_repair
94 # some basic sanity checks...
95 _check_fs $SCRATCH_DEV
96 mount -t xfs $SCRATCH_DEV $SCRATCH_MNT #mount
97 dd if=/bin/sh of=$SCRATCH_MNT/sh 2>&1 |_filter_dd #open,write
98 dd if=$SCRATCH_MNT/sh of=/dev/null 2>&1 |_filter_dd #read
99 rm -f $SCRATCH_MNT/sh #unlink
100 umount $SCRATCH_MNT #umount
103 # make sure this script returns success