xfs/007: fix regressions on V4 filesystems
[xfstests-dev.git] / tests / xfs / 019
1 #! /bin/bash
2 # SPDX-License-Identifier: GPL-2.0
3 # Copyright (c) 2000-2004 Silicon Graphics, Inc.  All Rights Reserved.
4 #
5 # FS QA Test No. 019
6 #
7 # mkfs protofile test
8 #
9 . ./common/preamble
10 _begin_fstest mkfs auto quick
11
12 seqfull="$seqres.full"
13 # Import common functions.
14 . ./common/filter
15
16 # Override the default cleanup function.
17 _cleanup()
18 {
19     echo "*** unmount"
20     _scratch_unmount 2>/dev/null
21     rm -f $tmp.*
22 }
23
24 _full()
25 {
26     echo ""            >>$seqfull
27     echo "*** $* ***"  >>$seqfull
28     echo ""            >>$seqfull
29 }
30
31 _filter_stat()
32 {
33     sed '
34         /^Access:/d;
35         /^Modify:/d;
36         /^Change:/d;
37         s/Device: *[0-9][0-9]*,[0-9][0-9]*/Device: <DEVICE>/;
38         s/Inode: *[0-9][0-9]*/Inode: <INODE>/;
39         s/Size: *[0-9][0-9]* *Filetype: Dir/Size: <DSIZE> Filetype: Dir/;
40     ' | tr -s ' '
41 }
42
43 # real QA test starts here
44 _supported_fs xfs
45
46 _require_scratch
47
48 # mkfs cannot create a filesystem with protofiles if realtime is enabled, so
49 # don't run this test if the rtinherit is anywhere in the mkfs options.
50 echo "$MKFS_OPTIONS" | grep -q "rtinherit" && \
51         _notrun "Cannot mkfs with a protofile and -d rtinherit."
52
53 protofile=$tmp.proto
54 tempfile=$tmp.file
55
56 echo fish >$tempfile
57 $here/src/devzero -b 2048 -n 2 -c -v 44 $tempfile.2 
58
59 cat >$protofile <<EOF
60 DUMMY1
61 0 0
62 : root directory
63 d--777 3 1
64 : a directory
65 directory d--755 3 1 
66 file_xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx_0 ---755 3 1 $tempfile
67 file_xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx_1 ---755 3 1 $tempfile
68 file_xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx_2 ---755 3 1 $tempfile
69 file_xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx_3 ---755 3 1 $tempfile
70 file_xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx_4 ---755 3 1 $tempfile
71 $
72 : back in the root
73 setuid -u-666 0 0 $tempfile
74 setgid --g666 0 0 $tempfile
75 setugid -ug666 0 0 $tempfile
76 block_device b--012 3 1 161 162 
77 char_device c--345 3 1 177 178
78 pipe p--670 0 0
79 symlink l--123 0 0 bigfile
80 : a file we actually read
81 bigfile ---666 3 0 $tempfile.2
82 : done
83 $
84 EOF
85
86 if [ $? -ne 0 ]
87 then
88     _fail "failed to create test protofile"
89 fi
90
91 _verify_fs()
92 {
93         echo "*** create FS version $1"
94         VERSION="-n version=$1"
95
96         rm -f $seqfull
97         _scratch_unmount >/dev/null 2>&1
98
99         _full "mkfs"
100         _scratch_mkfs_xfs $VERSION -p $protofile >>$seqfull 2>&1 \
101                 || _fail "mkfs failed"
102
103         echo "*** check FS"
104         _check_scratch_fs
105
106         echo "*** mount FS"
107         _full " mount"
108         _try_scratch_mount >>$seqfull 2>&1 \
109                 || _fail "mount failed"
110
111         echo "*** verify FS"
112         (cd $SCRATCH_MNT ; find . | LC_COLLATE=POSIX sort \
113                 | grep -v ".use_space" \
114                 | xargs $here/src/lstat64 | _filter_stat)
115         diff -q $SCRATCH_MNT/bigfile $tempfile.2 \
116                 || _fail "bigfile corrupted"
117
118         echo "*** unmount FS"
119         _full "umount"
120         _scratch_unmount >>$seqfull 2>&1 \
121                 || _fail "umount failed"
122 }
123
124 #_verify_fs 1
125 _verify_fs 2
126
127 echo "*** done"
128 rm $seqfull
129 status=0
130 exit