2010-01-20 10:27:08 +11:00
|
|
|
#! /bin/bash
|
2018-06-09 11:35:45 +10:00
|
|
|
# SPDX-License-Identifier: GPL-2.0
|
|
|
|
|
# Copyright (c) 2000-2002 Silicon Graphics, Inc. All Rights Reserved.
|
|
|
|
|
#
|
2009-05-28 17:04:15 +02:00
|
|
|
# FS QA Test No. 021
|
|
|
|
|
#
|
|
|
|
|
# xfs_db type attr test (pv 797508 linux-xfs & IRIX)
|
2009-05-12 13:24:15 -05:00
|
|
|
#
|
2001-01-15 05:01:19 +00:00
|
|
|
seq=`basename $0`
|
2013-03-15 12:28:02 +00:00
|
|
|
seqres=$RESULT_DIR/$seq
|
2001-01-15 05:01:19 +00:00
|
|
|
echo "QA output created by $seq"
|
|
|
|
|
|
|
|
|
|
here=`pwd`
|
|
|
|
|
tmp=/tmp/$$
|
|
|
|
|
status=0 # success is the default!
|
|
|
|
|
# get standard environment, filters and checks
|
2013-03-15 12:28:04 +00:00
|
|
|
. ./common/rc
|
|
|
|
|
. ./common/filter
|
|
|
|
|
. ./common/attr
|
2001-01-15 05:01:19 +00:00
|
|
|
|
|
|
|
|
_cleanup()
|
|
|
|
|
{
|
2002-06-21 00:14:20 +00:00
|
|
|
echo "*** unmount"
|
2015-12-21 18:07:43 +11:00
|
|
|
_scratch_unmount 2>/dev/null
|
2002-06-21 00:14:20 +00:00
|
|
|
rm -f $tmp.*
|
2001-01-15 05:01:19 +00:00
|
|
|
}
|
|
|
|
|
trap "_cleanup; exit \$status" 0 1 2 3 15
|
|
|
|
|
|
|
|
|
|
_attr()
|
|
|
|
|
{
|
2010-10-21 20:07:31 +00:00
|
|
|
${ATTR_PROG} $* 2>$tmp.err >$tmp.out
|
2002-06-21 00:14:20 +00:00
|
|
|
exit=$?
|
2003-05-14 05:25:31 +00:00
|
|
|
sed \
|
|
|
|
|
-e "s#$SCRATCH_MNT[^ .:]*#<TESTFILE>#g" \
|
|
|
|
|
-e "s#$tmp[^ :]*#<TMPFILE>#g;" \
|
2002-06-21 00:14:20 +00:00
|
|
|
$tmp.out
|
2003-05-14 05:25:31 +00:00
|
|
|
sed \
|
|
|
|
|
-e "s#$SCRATCH_MNT[^ .:]*#<TESTFILE>#g" \
|
|
|
|
|
-e "s#$tmp[^ :]*#<TMPFILE>#g;" \
|
2002-06-21 00:14:20 +00:00
|
|
|
$tmp.err 1>&2
|
|
|
|
|
return $exit
|
2001-01-15 05:01:19 +00:00
|
|
|
}
|
|
|
|
|
|
2018-08-23 10:41:24 +08:00
|
|
|
do_getfattr()
|
2002-02-25 22:12:17 +00:00
|
|
|
{
|
2018-08-23 10:41:24 +08:00
|
|
|
_getfattr $* 2>$tmp.err >$tmp.out
|
2002-06-21 00:14:20 +00:00
|
|
|
exit=$?
|
2003-05-14 05:25:31 +00:00
|
|
|
sed \
|
|
|
|
|
-e "s#$SCRATCH_MNT[^ .:]*#<TESTFILE>#g" \
|
|
|
|
|
-e "s#$tmp[^ :]*#<TMPFILE>#g;" \
|
2002-06-21 00:14:20 +00:00
|
|
|
$tmp.out
|
2003-05-14 05:25:31 +00:00
|
|
|
sed \
|
|
|
|
|
-e "s#$SCRATCH_MNT[^ .:]*#<TESTFILE>#g" \
|
|
|
|
|
-e "s#$tmp[^ :]*#<TMPFILE>#g;" \
|
2002-06-21 00:14:20 +00:00
|
|
|
$tmp.err 1>&2
|
|
|
|
|
return $exit
|
2002-05-10 02:33:23 +00:00
|
|
|
}
|
|
|
|
|
|
2001-01-15 05:01:19 +00:00
|
|
|
# real QA test starts here
|
2004-06-15 07:36:09 +00:00
|
|
|
_supported_fs xfs
|
|
|
|
|
|
2001-01-15 05:01:19 +00:00
|
|
|
_require_scratch
|
2010-10-21 21:11:48 +02:00
|
|
|
_require_attrs
|
2001-01-15 05:01:19 +00:00
|
|
|
|
2013-03-15 12:28:02 +00:00
|
|
|
rm -f $seqres.full
|
2015-12-21 18:07:43 +11:00
|
|
|
_scratch_unmount >/dev/null 2>&1
|
2001-01-15 05:01:19 +00:00
|
|
|
|
2002-05-06 07:44:22 +00:00
|
|
|
echo "*** mkfs"
|
2003-05-22 04:16:45 +00:00
|
|
|
_scratch_mkfs_xfs >/dev/null \
|
2002-06-21 00:14:20 +00:00
|
|
|
|| _fail "mkfs failed"
|
2003-05-14 05:25:31 +00:00
|
|
|
|
2001-01-15 05:01:19 +00:00
|
|
|
echo "*** mount FS"
|
2018-02-07 17:31:36 +08:00
|
|
|
_scratch_mount
|
2003-05-14 05:25:31 +00:00
|
|
|
|
2001-01-15 05:01:19 +00:00
|
|
|
testfile=$SCRATCH_MNT/testfile
|
|
|
|
|
echo "*** make test file 1"
|
|
|
|
|
|
|
|
|
|
touch $testfile.1
|
|
|
|
|
echo "v1" | _attr -s "a1" $testfile.1 >/dev/null
|
|
|
|
|
echo "v2--" | _attr -s "a2--" $testfile.1 >/dev/null
|
2018-08-23 10:41:24 +08:00
|
|
|
do_getfattr --absolute-names $testfile.1
|
2001-01-15 05:01:19 +00:00
|
|
|
inum_1=`ls -li $testfile.1 | $AWK_PROG '{ print $1 }'`
|
|
|
|
|
|
|
|
|
|
echo "*** make test file 2"
|
|
|
|
|
|
|
|
|
|
touch $testfile.2
|
|
|
|
|
echo "value_1" | _attr -s "a1" $testfile.2 >/dev/null
|
|
|
|
|
echo "value_2" | _attr -s "a2-----" $testfile.2 >/dev/null
|
2003-06-12 04:17:41 +00:00
|
|
|
( echo start; POSIXLY_CORRECT=yes dd if=/dev/zero bs=65525 count=1; echo end )\
|
2002-06-21 00:14:20 +00:00
|
|
|
| _attr -s "a3" $testfile.2 >/dev/null
|
2018-08-23 10:41:24 +08:00
|
|
|
do_getfattr --absolute-names $testfile.2
|
2002-02-25 22:33:42 +00:00
|
|
|
|
|
|
|
|
# print name and size from 1st line of output
|
2003-05-14 05:25:31 +00:00
|
|
|
_attr -g "a3" $testfile.2 > $tmp.hahahahaplonk
|
|
|
|
|
head -1 $tmp.hahahahaplonk
|
|
|
|
|
# NOTE:
|
|
|
|
|
# Above goo works around some truly bizzaro sh/sed/head interaction
|
|
|
|
|
# for some versions of these tools (fails on Redhat 7+, 6.2 worked)
|
2002-02-25 22:33:42 +00:00
|
|
|
|
|
|
|
|
# print out the rest of the data apart from the header
|
|
|
|
|
# the size is +1 for an extra \n at the end
|
|
|
|
|
echo -n "size of attr value = "
|
2004-05-04 00:09:53 +00:00
|
|
|
# wc inserts different amounts of whitespace in front...
|
|
|
|
|
_attr -g "a3" $testfile.2 | tail -3 | wc -c | sed -e "s/^ *//"
|
2002-02-25 22:33:42 +00:00
|
|
|
echo ""
|
|
|
|
|
|
2001-01-15 05:01:19 +00:00
|
|
|
inum_2=`ls -li $testfile.2 | $AWK_PROG '{ print $1 }'`
|
2006-03-28 06:04:20 +00:00
|
|
|
|
2001-01-15 05:01:19 +00:00
|
|
|
echo "*** unmount FS"
|
2015-12-21 18:07:43 +11:00
|
|
|
_scratch_unmount >>$seqres.full 2>&1 \
|
2002-06-21 00:14:20 +00:00
|
|
|
|| _fail "umount failed"
|
|
|
|
|
|
2001-01-15 05:01:19 +00:00
|
|
|
echo "*** dump attributes (1)"
|
|
|
|
|
|
2016-10-17 15:09:34 -07:00
|
|
|
_scratch_xfs_db -r -c "inode $inum_1" -c "print a.sfattr" | \
|
2006-03-28 06:04:20 +00:00
|
|
|
sed -e '/secure = /d' | sed -e '/parent = /d'
|
2001-01-15 05:01:19 +00:00
|
|
|
|
|
|
|
|
echo "*** dump attributes (2)"
|
|
|
|
|
|
2014-02-18 17:16:34 +11:00
|
|
|
# There is a fair bit of filtering here to convert v5 filesystem output
|
|
|
|
|
# into the v4 format that holds the meaningful information for the test.
|
2016-10-17 15:09:34 -07:00
|
|
|
_scratch_xfs_db -r -c "inode $inum_2" -c "a a.bmx[0].startblock" -c print \
|
2002-06-21 00:14:20 +00:00
|
|
|
| perl -ne '
|
2006-03-28 06:04:20 +00:00
|
|
|
s/,secure//;
|
|
|
|
|
s/,parent//;
|
2014-02-18 17:16:34 +11:00
|
|
|
s/info.hdr/info/;
|
|
|
|
|
/hdr.info.crc/ && next;
|
|
|
|
|
/hdr.info.bno/ && next;
|
|
|
|
|
/hdr.info.uuid/ && next;
|
|
|
|
|
/hdr.info.lsn/ && next;
|
|
|
|
|
/hdr.info.owner/ && next;
|
|
|
|
|
s/^(hdr.info.magic =) 0x3bee/\1 0xfbee/;
|
2002-05-10 02:33:23 +00:00
|
|
|
s/^(hdr.firstused =) (\d+)/\1 FIRSTUSED/;
|
|
|
|
|
s/^(hdr.freemap\[0-2] = \[base,size]).*/\1 [FREEMAP..]/;
|
|
|
|
|
s/^(entries\[0-2] = \[hashval,nameidx,incomplete,root,local]).*/\1 [ENTRIES..]/;
|
2016-11-05 00:16:10 +08:00
|
|
|
print unless /^\d+:\[.*/;'
|
2002-05-10 02:33:23 +00:00
|
|
|
|
2001-01-15 05:01:19 +00:00
|
|
|
echo "*** done"
|
|
|
|
|
exit
|