Dont attempt db freespace command on big sparse loopback filesystems, takes ages
[xfstests-dev.git] / 019
1 #! /bin/sh
2 # XFS QA Test No. 019
3 #
4 # mkfs protofile test
5 #
6 #-----------------------------------------------------------------------
7 # Copyright (c) 2000-2002 Silicon Graphics, Inc.  All Rights Reserved.
8
9 # This program is free software; you can redistribute it and/or modify it
10 # under the terms of version 2 of the GNU General Public License as
11 # published by the Free Software Foundation.
12
13 # This program is distributed in the hope that it would be useful, but
14 # WITHOUT ANY WARRANTY; without even the implied warranty of
15 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
16
17 # Further, this software is distributed without any warranty that it is
18 # free of the rightful claim of any third person regarding infringement
19 # or the like.  Any license provided herein, whether implied or
20 # otherwise, applies only to this software file.  Patent licenses, if
21 # any, provided herein do not apply to combinations of this program with
22 # other software, or any other product whatsoever.
23
24 # You should have received a copy of the GNU General Public License along
25 # with this program; if not, write the Free Software Foundation, Inc., 59
26 # Temple Place - Suite 330, Boston MA 02111-1307, USA.
27
28 # Contact information: Silicon Graphics, Inc., 1600 Amphitheatre Pkwy,
29 # Mountain View, CA  94043, or:
30
31 # http://www.sgi.com 
32
33 # For further information regarding this notice, see: 
34
35 # http://oss.sgi.com/projects/GenInfo/SGIGPLNoticeExplan/
36 #-----------------------------------------------------------------------
37 #
38 # creator
39 owner=dxm@sgi.com
40
41 seq=`basename $0`
42 echo "QA output created by $seq"
43
44 here=`pwd`
45 tmp=/tmp/$$
46 seqfull="$seq.full"
47 status=1        # failure is the default!
48 # get standard environment, filters and checks
49 . ./common.rc
50 . ./common.filter
51
52 _cleanup()
53 {
54     echo "*** unmount"
55     umount $SCRATCH_MNT 2>/dev/null
56     rm -f $tmp.*
57 }
58 trap "_cleanup; exit \$status" 0 1 2 3 15
59
60 _full()
61 {
62     echo ""            >>$seqfull      
63     echo "*** $* ***"  >>$seqfull
64     echo ""            >>$seqfull
65 }
66
67 _filter_stat()
68 {
69     sed '
70         /^Access:/d;
71         /^Modify:/d;
72         /^Change:/d;
73         s/Device: *[0-9][0-9]*,[0-9][0-9]*/Device: <DEVICE>/;
74         s/Inode: *[0-9][0-9]*/Inode: <INODE>/;
75         s/Size: *[0-9][0-9]* *Filetype: Dir/Size: <DSIZE> Filetype: Dir/;
76     ' | tr -s ' '
77 }
78
79 # real QA test starts here
80
81 _require_scratch
82
83 protofile=$tmp.proto
84 tempfile=$tmp.file
85
86 echo fish >$tempfile
87 $here/src/devzero -b 2048 -n 2 $tempfile.2 -c -v 44
88
89 cat >$protofile <<EOF
90 DUMMY1
91 0 0
92 : root directory
93 d--777 3 1
94 : a directory
95 directory d--755 3 1 
96 file_xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx_0 ---755 3 1 $tempfile
97 file_xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx_1 ---755 3 1 $tempfile
98 file_xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx_2 ---755 3 1 $tempfile
99 file_xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx_3 ---755 3 1 $tempfile
100 file_xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx_4 ---755 3 1 $tempfile
101 $
102 : back in the root
103 setuid -u-666 0 0 $tempfile
104 setgid --g666 0 0 $tempfile
105 setugid -ug666 0 0 $tempfile
106 block_device b--012 3 1 161 162 
107 char_device c--345 3 1 177 178
108 pipe p--670 0 0
109 symlink l--123 0 0 bigfile
110 : a file we actually read
111 bigfile ---666 3 0 $tempfile.2
112 : done
113 $
114 EOF
115
116 if [ $? -ne 0 ]
117 then
118     _fail "failed to create test protofile"
119 fi
120
121 _verify_fs()
122 {
123         echo "*** create FS version $1"
124         VERSION="-n version=$1"
125
126         rm -f $seqfull
127         umount $SCRATCH_DEV >/dev/null 2>&1
128
129         _full "mkfs"
130         _scratch_mkfs_xfs $VERSION -p $protofile >>$seqfull 2>&1 \
131                 || _fail "mount failed"
132
133         echo "*** check FS"
134         _check_scratch_fs
135
136         echo "*** mount FS"
137         _full " mount"
138         _scratch_mount >>$seqfull 2>&1 \
139                 || _fail "mount failed"
140     
141         echo "*** verify FS"
142         (cd $SCRATCH_MNT ; find . | sort \
143                 | xargs $here/src/lstat64 | _filter_stat)
144         diff -q $SCRATCH_MNT/bigfile $tempfile.2 \
145                 || _fail "bigfile corrupted"
146     
147         echo "*** unmount FS"
148         _full "umount"
149         umount $SCRATCH_DEV >>$seqfull 2>&1 \
150                 || _fail "umount failed"
151             
152         echo "*** check FS"
153         _check_scratch_fs
154 }
155
156 _verify_fs 1
157 _verify_fs 2
158
159 echo "*** done"
160 rm $seqfull
161 status=0
162 exit