fix up tree walking with symlinks for attr
[xfstests-dev.git] / 137
1 #! /bin/sh
2 # FSQA Test No. 137
3 #
4 # Test for NULL files problem
5 #
6 #-----------------------------------------------------------------------
7 #  Copyright (c) 2006 Silicon Graphics, Inc.  All Rights Reserved.
8 #-----------------------------------------------------------------------
9 #
10 # creator
11 owner=lachlan@sgi.com
12
13 seq=`basename $0`
14 echo "QA output created by $seq"
15
16 here=`pwd`
17 tmp=/tmp/$$
18 status=1    # failure is the default!
19 trap "_cleanup; exit \$status" 0 1 2 3 15
20
21 _cleanup()
22 {
23     _cleanup_testdir
24 }
25
26 # get standard environment, filters and checks
27 . ./common.rc
28 . ./common.filter
29
30 # real QA test starts here
31 _supported_fs xfs
32 _supported_os Linux IRIX
33
34 _setup_testdir
35 _require_scratch
36 _scratch_mkfs_xfs >/dev/null 2>&1
37 _scratch_mount
38
39 # create files
40 i=1;
41 while [ $i -lt 1000 ]
42 do
43         file=$SCRATCH_MNT/$i
44         xfs_io -f -c "pwrite -b 64k -S 0xff 0 64k" $file > /dev/null
45         if [ $? -ne 0 ]
46         then
47                 echo error creating/writing file $file
48                 exit
49         fi
50         i=`expr $i + 1`
51 done
52
53 # give the system a chance to write something out
54 sleep 10
55
56 src/godown $SCRATCH_MNT
57
58 umount $SCRATCH_MNT
59 _scratch_mount
60 umount $SCRATCH_MNT
61 if [ ! _check_scratch_fs ]
62 then
63         echo error detected in filesystem
64         exit
65 fi
66 _scratch_mount
67
68 # check file size and contents
69 i=1;
70 while [ $i -lt 1000 ]
71 do
72         file=$SCRATCH_MNT/$i
73         # if file does not exist, the create was not logged, skip it
74         if [ -e $file ]
75         then
76                 # if file size is zero it cannot be corrupt, skip it
77                 if [ -s $file ]
78                 then
79                         # if file has non-zero size but no extents then it's contents will be NULLs, bad.
80                         if xfs_bmap $file | grep 'no extents' > /dev/null
81                         then
82                                 echo corrupt file $file - non-zero size but no extents
83                         elif xfs_bmap $file | grep 'hole' > /dev/null
84                         then
85                                 echo corrupt file $file - contains holes
86                         else
87                                 rm -f $file
88                         fi
89                 else
90                         rm -f $file
91                 fi
92         fi
93         i=`expr $i + 1`
94 done
95
96 status=0
97 exit