#! /bin/sh # FS QA Test No. 021 # # xfs_db type attr test (pv 797508 linux-xfs & IRIX) # #----------------------------------------------------------------------- # Copyright (c) 2000-2002 Silicon Graphics, Inc. All Rights Reserved. # # 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() { echo "*** unmount" umount $SCRATCH_MNT 2>/dev/null rm -f $tmp.* } trap "_cleanup; exit \$status" 0 1 2 3 15 _attr() { attr $* 2>$tmp.err >$tmp.out exit=$? sed \ -e "s#$SCRATCH_MNT[^ .:]*##g" \ -e "s#$tmp[^ :]*##g;" \ $tmp.out sed \ -e "s#$SCRATCH_MNT[^ .:]*##g" \ -e "s#$tmp[^ :]*##g;" \ $tmp.err 1>&2 return $exit } _getfattr() { getfattr $* 2>$tmp.err >$tmp.out exit=$? sed \ -e "s#$SCRATCH_MNT[^ .:]*##g" \ -e "s#$tmp[^ :]*##g;" \ $tmp.out sed \ -e "s#$SCRATCH_MNT[^ .:]*##g" \ -e "s#$tmp[^ :]*##g;" \ $tmp.err 1>&2 return $exit } # real QA test starts here _supported_fs xfs _supported_os Linux [ -x /usr/bin/attr ] || _notrun "attr is not installed" [ -x /usr/bin/getfattr ] || _notrun "getfattr is not installed" _require_scratch rm -f $seq.full umount $SCRATCH_DEV >/dev/null 2>&1 echo "*** mkfs" _scratch_mkfs_xfs >/dev/null \ || _fail "mkfs failed" echo "*** mount FS" _scratch_mount >/dev/null \ || _fail "mount failed" 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 _getfattr --absolute-names $testfile.1 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 ( echo start; POSIXLY_CORRECT=yes dd if=/dev/zero bs=65525 count=1; echo end )\ | _attr -s "a3" $testfile.2 >/dev/null _getfattr --absolute-names $testfile.2 # print name and size from 1st line of output _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) # 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 = " # wc inserts different amounts of whitespace in front... _attr -g "a3" $testfile.2 | tail -3 | wc -c | sed -e "s/^ *//" echo "" inum_2=`ls -li $testfile.2 | $AWK_PROG '{ print $1 }'` echo "*** unmount FS" umount $SCRATCH_DEV >>$seq.full 2>&1 \ || _fail "umount failed" echo "*** dump attributes (1)" xfs_db -r -c "inode $inum_1" -c "print a.sfattr" $SCRATCH_DEV | \ sed -e '/secure = /d' echo "*** dump attributes (2)" xfs_db -r -c "inode $inum_2" -c "a a.bmx[0].startblock" -c print $SCRATCH_DEV \ | perl -ne ' s/root,secure,local/root,local/; 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..]/; print;' echo "*** done" exit