xfs: no excessive warnings about dprecated mount options on remount
[xfstests-dev.git] / tests / xfs / 021
1 #! /bin/bash
2 # SPDX-License-Identifier: GPL-2.0
3 # Copyright (c) 2000-2002 Silicon Graphics, Inc.  All Rights Reserved.
4 #
5 # FS QA Test No. 021
6 #
7 # xfs_db type attr test (pv 797508 linux-xfs & IRIX)
8 #
9 seq=`basename $0`
10 seqres=$RESULT_DIR/$seq
11 echo "QA output created by $seq"
12
13 here=`pwd`
14 tmp=/tmp/$$
15 status=0        # success is the default!
16 # get standard environment, filters and checks
17 . ./common/rc
18 . ./common/filter
19 . ./common/attr
20
21 _cleanup()
22 {
23         echo "*** unmount"
24         _scratch_unmount 2>/dev/null
25         rm -f $tmp.*
26 }
27 trap "_cleanup; exit \$status" 0 1 2 3 15
28
29 _attr()
30 {
31         ${ATTR_PROG} $* 2>$tmp.err >$tmp.out
32         exit=$?
33         sed \
34             -e "s#$SCRATCH_MNT[^ .:]*#<TESTFILE>#g" \
35             -e "s#$tmp[^ :]*#<TMPFILE>#g;" \
36                 $tmp.out
37         sed \
38             -e "s#$SCRATCH_MNT[^ .:]*#<TESTFILE>#g" \
39             -e "s#$tmp[^ :]*#<TMPFILE>#g;" \
40                 $tmp.err 1>&2
41         return $exit
42 }
43
44 do_getfattr()
45 {
46         _getfattr $* 2>$tmp.err >$tmp.out
47         exit=$?
48         sed \
49             -e "s#$SCRATCH_MNT[^ .:]*#<TESTFILE>#g" \
50             -e "s#$tmp[^ :]*#<TMPFILE>#g;" \
51                 $tmp.out
52         sed \
53             -e "s#$SCRATCH_MNT[^ .:]*#<TESTFILE>#g" \
54             -e "s#$tmp[^ :]*#<TMPFILE>#g;" \
55                 $tmp.err 1>&2
56         return $exit
57 }
58
59 # real QA test starts here
60 _supported_fs xfs
61
62 _require_scratch
63 _require_attrs
64
65 rm -f $seqres.full
66 _scratch_unmount >/dev/null 2>&1
67
68 echo "*** mkfs"
69 _scratch_mkfs_xfs >/dev/null \
70         || _fail "mkfs failed"
71
72 echo "*** mount FS"
73 _scratch_mount
74
75 testfile=$SCRATCH_MNT/testfile
76 echo "*** make test file 1"
77
78 touch $testfile.1
79 echo "v1" | _attr -s "a1" $testfile.1 >/dev/null
80 echo "v2--" | _attr -s "a2--" $testfile.1 >/dev/null
81 do_getfattr --absolute-names $testfile.1
82 inum_1=`ls -li $testfile.1 | $AWK_PROG '{ print $1 }'`
83
84 echo "*** make test file 2"
85
86 touch $testfile.2
87 echo "value_1" | _attr -s "a1" $testfile.2 >/dev/null
88 echo "value_2" | _attr -s "a2-----" $testfile.2 >/dev/null
89 ( echo start; POSIXLY_CORRECT=yes dd if=/dev/zero bs=65525 count=1; echo end )\
90         | _attr -s "a3" $testfile.2 >/dev/null
91 do_getfattr --absolute-names $testfile.2
92
93 # print name and size from 1st line of output
94 _attr -g "a3" $testfile.2 > $tmp.hahahahaplonk
95 head -1 $tmp.hahahahaplonk
96 # NOTE:
97 # Above goo works around some truly bizzaro sh/sed/head interaction
98 # for some versions of these tools (fails on Redhat 7+, 6.2 worked)
99
100 # print out the rest of the data apart from the header
101 # the size is +1 for an extra \n at the end
102 echo -n "size of attr value = "
103 # wc inserts different amounts of whitespace in front...
104 _attr -g "a3" $testfile.2 | tail -3 | wc -c | sed -e "s/^ *//"
105 echo ""
106
107 inum_2=`ls -li $testfile.2 | $AWK_PROG '{ print $1 }'`
108
109 echo "*** unmount FS"
110 _scratch_unmount >>$seqres.full 2>&1 \
111         || _fail "umount failed"
112
113 echo "*** dump attributes (1)"
114
115 _scratch_xfs_db -r -c "inode $inum_1" -c "print a.sfattr"  | \
116         sed -e '/secure = /d' | sed -e '/parent = /d'
117
118 echo "*** dump attributes (2)"
119
120 # There is a fair bit of filtering here to convert v5 filesystem output
121 # into the v4 format that holds the meaningful information for the test.
122 _scratch_xfs_db -r -c "inode $inum_2" -c "a a.bmx[0].startblock" -c print  \
123         | perl -ne '
124 s/,secure//;
125 s/,parent//;
126 s/info.hdr/info/;
127 /hdr.info.crc/ && next;
128 /hdr.info.bno/ && next;
129 /hdr.info.uuid/ && next;
130 /hdr.info.lsn/ && next;
131 /hdr.info.owner/ && next;
132 s/^(hdr.info.magic =) 0x3bee/\1 0xfbee/;
133 s/^(hdr.firstused =) (\d+)/\1 FIRSTUSED/;
134 s/^(hdr.freemap\[0-2] = \[base,size]).*/\1 [FREEMAP..]/;
135 s/^(entries\[0-2] = \[hashval,nameidx,incomplete,root,local]).*/\1 [ENTRIES..]/;
136         print unless /^\d+:\[.*/;'
137
138 echo "*** done"
139 exit