3 #-----------------------------------------------------------------------
4 # Copyright (c) 2005 Silicon Graphics, Inc. All Rights Reserved.
6 # This program is free software; you can redistribute it and/or
7 # modify it under the terms of the GNU General Public License as
8 # published by the Free Software Foundation.
10 # This program is distributed in the hope that it would be useful,
11 # but WITHOUT ANY WARRANTY; without even the implied warranty of
12 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 # GNU General Public License for more details.
15 # You should have received a copy of the GNU General Public License
16 # along with this program; if not, write the Free Software Foundation,
17 # Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
19 #-----------------------------------------------------------------------
23 # Test out xfs_repair_ipaths
26 owner=tes@crackle.melbourne.sgi.com
29 echo "QA output created by $seq"
33 status=1 # failure is the default!
34 trap "_cleanup; exit \$status" 0 1 2 3 15
44 # ~/attr -Fl a/b/c/d/foo
45 # Attribute "0000000000180080 0000000000000001" has a 3 byte value for a/b/c/d/foo
47 # ~/attr -Fg "0000000000180080 0000000000000001" a/b/c/d/foo
48 # Attribute "0000000000180080 0000000000000001" had a 3 byte value for a/b/c/d/foo:
51 # ~/attr -Pg "0000000000180080 0000000000000001" a/b/c/d/foo
52 # Attribute "0000000000180080 0000000000000001" had a 12 byte value for a/b/c/d/foo:
57 # filter out inode numbers to ordinal numbers
58 # (assumes they come in order)
62 find $SCRATCH_MNT -exec stat -iq {} \; >$tmp.inodes
65 -e 's/Attribute "[0-9][0-9]*/Attribute "INODE/' \
66 | nawk -v inodefile=$tmp.inodes '
69 while (getline < inodefile > 0) {
75 for (i = 1; i <= NF; i++) {
78 $nextone = inodemap[$nextone]
91 sed -e 's/inode: \([0-9][0-9]*\)/inode: N/g' \
92 -e 's/Attribute "[0-9][0-9]*/Attribute "INODE/'
96 # get standard environment, filters and checks
105 rm -f $here/$seq.full
108 _scratch_mkfs_xfs >>$here/$seq.full 2>&1 \
109 || _fail "mkfs scratch failed"
110 _scratch_mkfs_xfs -i paths=1 >>$here/$seq.full 2>&1 \
111 || _notrun "i_paths not supported"
114 _scratch_mount >>$here/$seq.full 2>&1 \
115 || _fail "mount failed: $MOUNT_OPTIONS"
117 # real QA test starts here
122 echo "--- create some files and directories to work on ---"
129 touch dir2/dir3/file3
141 echo "--- check all is ok before we start ---"
143 xfs_check_ipaths $SCRATCH_MNT
144 xfs_repair_ipaths -n $SCRATCH_MNT
147 echo "--- now break some stuff ---"
152 echo "1. remove the EA"
155 stat_ino=`stat -iq dir2`
156 attrname=`printf "%.16x %.16x" $stat_ino $cnt`
157 #echo "attrname = $attrname"
158 attr -Fr "$attrname" dir2/file2
162 echo "2. change the EA name"
164 attr -Fl dir2/dir3/file3
166 attrname=`printf "%.16x %.16x" $stat_ino $cnt`
168 attr -Fs "$attrname" -V $attrvalue dir2/dir3/file3
169 attr -Fl dir2/dir3/file3
172 echo "3. change the EA value"
175 stat_ino=`stat -iq $d`
176 attrname=`printf "%.16x %.16x" $stat_ino $cnt`
178 attr -Fs "$attrname" -V "$attrvalue" $d/file4
180 attr -Fg "$attrname" $d/file4
183 echo "4. add an extra EA - diff name, same value"
187 attrname=`printf "%.16x %.16x" $stat_ino $cnt`
189 attr -Fs "$attrname" -V $attrvalue $d/file5
191 attr -Fg "$attrname" $d/file5
194 echo "5. add an extra EA - diff name, diff value"
198 attrname=`printf "%.16x %.16x" $stat_ino $cnt`
200 attr -Fs "$attrname" -V $attrvalue $d/file6
202 attr -Fg "$attrname" $d/file6
205 echo "6. give bad fmt'ed EA name and get rid of existing name"
209 attr -Fs "$attrname" -V $attrvalue $d/file7
210 # remove old attrname
212 stat_ino=`stat -iq $d`
213 attrname=`printf "%.16x %.16x" $stat_ino $cnt`
214 attr -Fr "$attrname" $d/file7
217 echo "--- now check it ---"
221 echo "xfs_check_ipaths"
223 xfs_check_ipaths $SCRATCH_MNT
226 echo "xfs_repair_ipaths"
228 xfs_repair_ipaths -n $SCRATCH_MNT
231 echo "--- now repair it ---"
235 echo "xfs_repair_ipaths"
237 xfs_repair_ipaths $SCRATCH_MNT
240 echo "--- now check it again ---"
245 echo "xfs_check_ipaths"
247 xfs_check_ipaths $SCRATCH_MNT
250 echo "xfs_repair_ipaths"
252 xfs_repair_ipaths -n $SCRATCH_MNT
255 _do_test 2>&1 | tee $seq.full | _filter_inodes