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 $* 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
66 _scratch_unmount >/dev/null 2>&1
69 _scratch_mkfs_xfs >/dev/null \
70 || _fail "mkfs failed"
75 testfile=$SCRATCH_MNT/testfile
76 echo "*** make test file 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 }'`
84 echo "*** make test file 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
93 # print name and size from 1st line of output
94 _attr -g "a3" $testfile.2 > $tmp.hahahahaplonk
95 head -1 $tmp.hahahahaplonk
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)
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/^ *//"
107 inum_2=`ls -li $testfile.2 | $AWK_PROG '{ print $1 }'`
109 echo "*** unmount FS"
110 _scratch_unmount >>$seqres.full 2>&1 \
111 || _fail "umount failed"
113 echo "*** dump attributes (1)"
115 _scratch_xfs_db -r -c "inode $inum_1" -c "print a.sfattr" | \
116 sed -e '/secure = /d' | sed -e '/parent = /d'
118 echo "*** dump attributes (2)"
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 \
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+:\[.*/;'