4 # xfs_db type attr test (pv 797508 linux-xfs & IRIX)
6 #-----------------------------------------------------------------------
7 # Copyright (c) 2000-2002 Silicon Graphics, Inc. All Rights Reserved.
9 # This program is free software; you can redistribute it and/or
10 # modify it under the terms of the GNU General Public License as
11 # published by the Free Software Foundation.
13 # This program is distributed in the hope that it would be useful,
14 # but WITHOUT ANY WARRANTY; without even the implied warranty of
15 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 # GNU General Public License for more details.
18 # You should have received a copy of the GNU General Public License
19 # along with this program; if not, write the Free Software Foundation,
20 # Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
22 #-----------------------------------------------------------------------
26 seqres=$RESULT_DIR/$seq
27 echo "QA output created by $seq"
31 status=0 # success is the default!
32 # get standard environment, filters and checks
40 _scratch_unmount 2>/dev/null
43 trap "_cleanup; exit \$status" 0 1 2 3 15
47 ${ATTR_PROG} $* 2>$tmp.err >$tmp.out
50 -e "s#$SCRATCH_MNT[^ .:]*#<TESTFILE>#g" \
51 -e "s#$tmp[^ :]*#<TMPFILE>#g;" \
54 -e "s#$SCRATCH_MNT[^ .:]*#<TESTFILE>#g" \
55 -e "s#$tmp[^ :]*#<TMPFILE>#g;" \
62 ${GETFATTR_PROG} $* 2>$tmp.err >$tmp.out
65 -e "s#$SCRATCH_MNT[^ .:]*#<TESTFILE>#g" \
66 -e "s#$tmp[^ :]*#<TMPFILE>#g;" \
69 -e "s#$SCRATCH_MNT[^ .:]*#<TESTFILE>#g" \
70 -e "s#$tmp[^ :]*#<TMPFILE>#g;" \
75 # real QA test starts here
83 _scratch_unmount >/dev/null 2>&1
86 _scratch_mkfs_xfs >/dev/null \
87 || _fail "mkfs failed"
90 _scratch_mount >/dev/null \
91 || _fail "mount failed"
93 testfile=$SCRATCH_MNT/testfile
94 echo "*** make test file 1"
97 echo "v1" | _attr -s "a1" $testfile.1 >/dev/null
98 echo "v2--" | _attr -s "a2--" $testfile.1 >/dev/null
99 _getfattr --absolute-names $testfile.1
100 inum_1=`ls -li $testfile.1 | $AWK_PROG '{ print $1 }'`
102 echo "*** make test file 2"
105 echo "value_1" | _attr -s "a1" $testfile.2 >/dev/null
106 echo "value_2" | _attr -s "a2-----" $testfile.2 >/dev/null
107 ( echo start; POSIXLY_CORRECT=yes dd if=/dev/zero bs=65525 count=1; echo end )\
108 | _attr -s "a3" $testfile.2 >/dev/null
109 _getfattr --absolute-names $testfile.2
111 # print name and size from 1st line of output
112 _attr -g "a3" $testfile.2 > $tmp.hahahahaplonk
113 head -1 $tmp.hahahahaplonk
115 # Above goo works around some truly bizzaro sh/sed/head interaction
116 # for some versions of these tools (fails on Redhat 7+, 6.2 worked)
118 # print out the rest of the data apart from the header
119 # the size is +1 for an extra \n at the end
120 echo -n "size of attr value = "
121 # wc inserts different amounts of whitespace in front...
122 _attr -g "a3" $testfile.2 | tail -3 | wc -c | sed -e "s/^ *//"
125 inum_2=`ls -li $testfile.2 | $AWK_PROG '{ print $1 }'`
127 echo "*** unmount FS"
128 _scratch_unmount >>$seqres.full 2>&1 \
129 || _fail "umount failed"
131 echo "*** dump attributes (1)"
133 _scratch_xfs_db -r -c "inode $inum_1" -c "print a.sfattr" | \
134 sed -e '/secure = /d' | sed -e '/parent = /d'
136 echo "*** dump attributes (2)"
138 # There is a fair bit of filtering here to convert v5 filesystem output
139 # into the v4 format that holds the meaningful information for the test.
140 _scratch_xfs_db -r -c "inode $inum_2" -c "a a.bmx[0].startblock" -c print \
145 /hdr.info.crc/ && next;
146 /hdr.info.bno/ && next;
147 /hdr.info.uuid/ && next;
148 /hdr.info.lsn/ && next;
149 /hdr.info.owner/ && next;
150 s/^(hdr.info.magic =) 0x3bee/\1 0xfbee/;
151 s/^(hdr.firstused =) (\d+)/\1 FIRSTUSED/;
152 s/^(hdr.freemap\[0-2] = \[base,size]).*/\1 [FREEMAP..]/;
153 s/^(entries\[0-2] = \[hashval,nameidx,incomplete,root,local]).*/\1 [ENTRIES..]/;
154 print unless /^\d+:\[.*/;'