2 # SPDX-License-Identifier: GPL-2.0
3 # Copyright (c) 2000-2002 Silicon Graphics, Inc. All Rights Reserved.
7 # xfs_db type attr test (pv 797508 linux-xfs & IRIX)
10 seqres=$RESULT_DIR/$seq
11 echo "QA output created by $seq"
15 status=0 # success is the default!
16 # get standard environment, filters and checks
24 _scratch_unmount 2>/dev/null
27 trap "_cleanup; exit \$status" 0 1 2 3 15
31 ${ATTR_PROG} $* 2>$tmp.err >$tmp.out
34 -e "s#$SCRATCH_MNT[^ .:]*#<TESTFILE>#g" \
35 -e "s#$tmp[^ :]*#<TMPFILE>#g;" \
38 -e "s#$SCRATCH_MNT[^ .:]*#<TESTFILE>#g" \
39 -e "s#$tmp[^ :]*#<TMPFILE>#g;" \
46 ${GETFATTR_PROG} $* 2>$tmp.err >$tmp.out
49 -e "s#$SCRATCH_MNT[^ .:]*#<TESTFILE>#g" \
50 -e "s#$tmp[^ :]*#<TMPFILE>#g;" \
53 -e "s#$SCRATCH_MNT[^ .:]*#<TESTFILE>#g" \
54 -e "s#$tmp[^ :]*#<TMPFILE>#g;" \
59 # real QA test starts here
67 _scratch_unmount >/dev/null 2>&1
70 _scratch_mkfs_xfs >/dev/null \
71 || _fail "mkfs failed"
76 testfile=$SCRATCH_MNT/testfile
77 echo "*** make test file 1"
80 echo "v1" | _attr -s "a1" $testfile.1 >/dev/null
81 echo "v2--" | _attr -s "a2--" $testfile.1 >/dev/null
82 _getfattr --absolute-names $testfile.1
83 inum_1=`ls -li $testfile.1 | $AWK_PROG '{ print $1 }'`
85 echo "*** make test file 2"
88 echo "value_1" | _attr -s "a1" $testfile.2 >/dev/null
89 echo "value_2" | _attr -s "a2-----" $testfile.2 >/dev/null
90 ( echo start; POSIXLY_CORRECT=yes dd if=/dev/zero bs=65525 count=1; echo end )\
91 | _attr -s "a3" $testfile.2 >/dev/null
92 _getfattr --absolute-names $testfile.2
94 # print name and size from 1st line of output
95 _attr -g "a3" $testfile.2 > $tmp.hahahahaplonk
96 head -1 $tmp.hahahahaplonk
98 # Above goo works around some truly bizzaro sh/sed/head interaction
99 # for some versions of these tools (fails on Redhat 7+, 6.2 worked)
101 # print out the rest of the data apart from the header
102 # the size is +1 for an extra \n at the end
103 echo -n "size of attr value = "
104 # wc inserts different amounts of whitespace in front...
105 _attr -g "a3" $testfile.2 | tail -3 | wc -c | sed -e "s/^ *//"
108 inum_2=`ls -li $testfile.2 | $AWK_PROG '{ print $1 }'`
110 echo "*** unmount FS"
111 _scratch_unmount >>$seqres.full 2>&1 \
112 || _fail "umount failed"
114 echo "*** dump attributes (1)"
116 _scratch_xfs_db -r -c "inode $inum_1" -c "print a.sfattr" | \
117 sed -e '/secure = /d' | sed -e '/parent = /d'
119 echo "*** dump attributes (2)"
121 # There is a fair bit of filtering here to convert v5 filesystem output
122 # into the v4 format that holds the meaningful information for the test.
123 _scratch_xfs_db -r -c "inode $inum_2" -c "a a.bmx[0].startblock" -c print \
128 /hdr.info.crc/ && next;
129 /hdr.info.bno/ && next;
130 /hdr.info.uuid/ && next;
131 /hdr.info.lsn/ && next;
132 /hdr.info.owner/ && next;
133 s/^(hdr.info.magic =) 0x3bee/\1 0xfbee/;
134 s/^(hdr.firstused =) (\d+)/\1 FIRSTUSED/;
135 s/^(hdr.freemap\[0-2] = \[base,size]).*/\1 [FREEMAP..]/;
136 s/^(entries\[0-2] = \[hashval,nameidx,incomplete,root,local]).*/\1 [ENTRIES..]/;
137 print unless /^\d+:\[.*/;'