2001-01-15 05:01:19 +00:00
|
|
|
#! /bin/sh
|
2004-06-15 07:36:09 +00:00
|
|
|
# FS QA Test No. 021
|
2001-01-15 05:01:19 +00:00
|
|
|
#
|
|
|
|
|
# xfs_db type attr test (pv 797508 linux-xfs & IRIX)
|
|
|
|
|
#
|
|
|
|
|
#-----------------------------------------------------------------------
|
2002-06-04 23:07:56 +00:00
|
|
|
# Copyright (c) 2000-2002 Silicon Graphics, Inc. All Rights Reserved.
|
2001-01-15 05:01:19 +00:00
|
|
|
#
|
|
|
|
|
# This program is free software; you can redistribute it and/or modify it
|
|
|
|
|
# under the terms of version 2 of the GNU General Public License as
|
|
|
|
|
# published by the Free Software Foundation.
|
|
|
|
|
#
|
|
|
|
|
# This program is distributed in the hope that it would be useful, but
|
|
|
|
|
# WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
|
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
|
|
|
|
|
#
|
|
|
|
|
# Further, this software is distributed without any warranty that it is
|
|
|
|
|
# free of the rightful claim of any third person regarding infringement
|
|
|
|
|
# or the like. Any license provided herein, whether implied or
|
|
|
|
|
# otherwise, applies only to this software file. Patent licenses, if
|
|
|
|
|
# any, provided herein do not apply to combinations of this program with
|
|
|
|
|
# other software, or any other product whatsoever.
|
|
|
|
|
#
|
|
|
|
|
# You should have received a copy of the GNU General Public License along
|
|
|
|
|
# with this program; if not, write the Free Software Foundation, Inc., 59
|
|
|
|
|
# Temple Place - Suite 330, Boston MA 02111-1307, USA.
|
|
|
|
|
#
|
|
|
|
|
# Contact information: Silicon Graphics, Inc., 1600 Amphitheatre Pkwy,
|
|
|
|
|
# Mountain View, CA 94043, or:
|
|
|
|
|
#
|
|
|
|
|
# http://www.sgi.com
|
|
|
|
|
#
|
|
|
|
|
# For further information regarding this notice, see:
|
|
|
|
|
#
|
|
|
|
|
# http://oss.sgi.com/projects/GenInfo/SGIGPLNoticeExplan/
|
|
|
|
|
#-----------------------------------------------------------------------
|
|
|
|
|
#
|
|
|
|
|
# creator
|
|
|
|
|
owner=dxm@sgi.com
|
|
|
|
|
|
|
|
|
|
seq=`basename $0`
|
|
|
|
|
echo "QA output created by $seq"
|
|
|
|
|
|
|
|
|
|
here=`pwd`
|
|
|
|
|
tmp=/tmp/$$
|
|
|
|
|
status=0 # success is the default!
|
|
|
|
|
# get standard environment, filters and checks
|
|
|
|
|
. ./common.rc
|
|
|
|
|
. ./common.filter
|
|
|
|
|
|
|
|
|
|
_cleanup()
|
|
|
|
|
{
|
2002-06-21 00:14:20 +00:00
|
|
|
echo "*** unmount"
|
|
|
|
|
umount $SCRATCH_MNT 2>/dev/null
|
|
|
|
|
rm -f $tmp.*
|
2001-01-15 05:01:19 +00:00
|
|
|
}
|
|
|
|
|
trap "_cleanup; exit \$status" 0 1 2 3 15
|
|
|
|
|
|
|
|
|
|
_attr()
|
|
|
|
|
{
|
2002-06-21 00:14:20 +00:00
|
|
|
attr $* 2>$tmp.err >$tmp.out
|
|
|
|
|
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
|
|
|
}
|
|
|
|
|
|
2002-02-25 22:12:17 +00:00
|
|
|
_getfattr()
|
|
|
|
|
{
|
2002-06-21 00:14:20 +00:00
|
|
|
getfattr $* 2>$tmp.err >$tmp.out
|
|
|
|
|
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
|
|
|
|
|
_supported_os Linux
|
|
|
|
|
|
|
|
|
|
[ -x /usr/bin/attr ] || _notrun "attr is not installed"
|
|
|
|
|
[ -x /usr/bin/getfattr ] || _notrun "getfattr is not installed"
|
|
|
|
|
|
2001-01-15 05:01:19 +00:00
|
|
|
_require_scratch
|
|
|
|
|
|
|
|
|
|
rm -f $seq.full
|
|
|
|
|
umount $SCRATCH_DEV >/dev/null 2>&1
|
|
|
|
|
|
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"
|
2003-05-22 04:16:45 +00:00
|
|
|
_scratch_mount >/dev/null \
|
2002-06-21 00:14:20 +00:00
|
|
|
|| _fail "mount failed"
|
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
|
2002-02-25 23:10:01 +00:00
|
|
|
_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
|
2002-02-25 23:10:01 +00:00
|
|
|
_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 }'`
|
2002-06-21 00:14:20 +00:00
|
|
|
|
2001-01-15 05:01:19 +00:00
|
|
|
echo "*** unmount FS"
|
|
|
|
|
umount $SCRATCH_DEV >>$seq.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)"
|
|
|
|
|
|
2004-01-19 04:51:52 +00:00
|
|
|
xfs_db -r -c "inode $inum_1" -c "print a.sfattr" $SCRATCH_DEV | \
|
|
|
|
|
sed -e '/secure = /d'
|
2001-01-15 05:01:19 +00:00
|
|
|
|
|
|
|
|
echo "*** dump attributes (2)"
|
|
|
|
|
|
2002-05-10 02:33:23 +00:00
|
|
|
xfs_db -r -c "inode $inum_2" -c "a a.bmx[0].startblock" -c print $SCRATCH_DEV \
|
2002-06-21 00:14:20 +00:00
|
|
|
| perl -ne '
|
2004-01-29 23:20:35 +00:00
|
|
|
s/root,secure,local/root,local/;
|
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..]/;
|
2002-06-21 00:14:20 +00:00
|
|
|
print;'
|
2002-05-10 02:33:23 +00:00
|
|
|
|
2001-01-15 05:01:19 +00:00
|
|
|
echo "*** done"
|
|
|
|
|
exit
|