Add a generic inode flag tester, fix filter in test 103.

Merge of master-melb:xfs-cmds:23132a by kenmcd.
This commit is contained in:
Nathan Scott
2005-07-11 14:57:36 +00:00
parent 9e4bae9c4b
commit 8b5b80690a
3 changed files with 164 additions and 157 deletions
+23 -25
View File
@@ -1,8 +1,7 @@
#! /bin/sh
# FS QA Test No. 103
#
# Exercise the XFS nosymlinks and project inheritance inode flags
# (for now only nosymlinks is tested; other is not yet implemented).
# Exercise the XFS nosymlinks inode flag
#
#-----------------------------------------------------------------------
# Copyright (c) 2000-2004 Silicon Graphics, Inc. All Rights Reserved.
@@ -74,6 +73,16 @@ _filter_scratch()
sed -e "s,$SCRATCH_MNT,SCRATCH_MNT,g"
}
_filter_noymlinks_flag()
{
_test_inode_flag nosymlinks $SCRATCH_MNT/nosymlink
if [ $? -eq 0 ]; then
echo "--n-- SCRATCH_MNT/nosymlink"
else
echo "----- SCRATCH_MNT/nosymlink"
fi
}
# real QA test starts here
_supported_fs xfs
_require_command /usr/sbin/xfs_io
@@ -83,41 +92,30 @@ _create_scratch
echo "*** testing nosymlinks directories"
mkdir $SCRATCH_MNT/nosymlinks
mkdir $SCRATCH_MNT/nosymlink
echo "*** setting nosymlinks bit"
$XFS_IO_PROG -r -c 'chattr +n' -c lsattr $SCRATCH_MNT/nosymlinks \
$XFS_IO_PROG -r -c 'chattr +n' $SCRATCH_MNT/nosymlink
_filter_noymlinks_flag
touch $SCRATCH_MNT/nosymlink/source
ln -s $SCRATCH_MNT/nosymlink/source $SCRATCH_MNT/nosymlink/target 2>&1 \
| _filter_scratch
touch $SCRATCH_MNT/nosymlinks/source
ln -s $SCRATCH_MNT/nosymlinks/source $SCRATCH_MNT/nosymlinks/target 2>&1 \
| _filter_scratch
ln $SCRATCH_MNT/nosymlinks/source $SCRATCH_MNT/nosymlinks/hardlinksareok
ln $SCRATCH_MNT/nosymlink/source $SCRATCH_MNT/nosymlink/hardlinksareok
echo "*** 1st listing..."
find $SCRATCH_MNT | _filter_scratch
echo "*** clearing nosymlinks bit"
$XFS_IO_PROG -r -c 'chattr -n' -c lsattr $SCRATCH_MNT/nosymlinks | _filter_scratch
ln -s $SCRATCH_MNT/nosymlinks/source $SCRATCH_MNT/nosymlinks/target
ln $SCRATCH_MNT/nosymlinks/source $SCRATCH_MNT/nosymlinks/hardlinksareok2
$XFS_IO_PROG -r -c 'chattr -n' $SCRATCH_MNT/nosymlink
_filter_noymlinks_flag
ln -s $SCRATCH_MNT/nosymlink/source $SCRATCH_MNT/nosymlink/target
ln $SCRATCH_MNT/nosymlink/source $SCRATCH_MNT/nosymlink/hardlinksareok2
echo "*** 2nd listing..."
find $SCRATCH_MNT | _filter_scratch
echo "*** finished testing nosymlinks directories"
# echo "*** testing inherited project IDs"
# mkdir $SCRATCH_MNT/projectids
# $XFS_IO_PROG -r -c 'chattr +P' -c lsattr -c 'chproj 42' $SCRATCH_MNT/projectids\
# | _filter_scratch
# mkdir -p $SCRATCH_MNT/projectids/a/b
# touch $SCRATCH_MNT/projectids/a/b/c
# $XFS_IO_PROG -r -c 'lsattr -R' $SCRATCH_MNT/projectids
# $XFS_IO_PROG -r -c 'lsproj' $SCRATCH_MNT/projectids/a $SCRATCH_MNT/projectids/a/b/c\
# | _filter_scratch
# echo "*** 3rd listing..."
# find $SCRATCH_MNT | _filter_scratch
# echo "*** finished testing inherited project IDs"
status=0
exit
+11 -11
View File
@@ -3,20 +3,20 @@ QA output created by 103
*** mount
*** testing nosymlinks directories
*** setting nosymlinks bit
---------n SCRATCH_MNT/nosymlinks
ln: creating symbolic link `SCRATCH_MNT/nosymlinks/target' to `SCRATCH_MNT/nosymlinks/source': Operation not permitted
--n-- SCRATCH_MNT/nosymlink
ln: creating symbolic link `SCRATCH_MNT/nosymlink/target' to `SCRATCH_MNT/nosymlink/source': Operation not permitted
*** 1st listing...
SCRATCH_MNT
SCRATCH_MNT/nosymlinks
SCRATCH_MNT/nosymlinks/source
SCRATCH_MNT/nosymlinks/hardlinksareok
SCRATCH_MNT/nosymlink
SCRATCH_MNT/nosymlink/source
SCRATCH_MNT/nosymlink/hardlinksareok
*** clearing nosymlinks bit
---------- SCRATCH_MNT/nosymlinks
----- SCRATCH_MNT/nosymlink
*** 2nd listing...
SCRATCH_MNT
SCRATCH_MNT/nosymlinks
SCRATCH_MNT/nosymlinks/source
SCRATCH_MNT/nosymlinks/hardlinksareok
SCRATCH_MNT/nosymlinks/target
SCRATCH_MNT/nosymlinks/hardlinksareok2
SCRATCH_MNT/nosymlink
SCRATCH_MNT/nosymlink/source
SCRATCH_MNT/nosymlink/hardlinksareok
SCRATCH_MNT/nosymlink/target
SCRATCH_MNT/nosymlink/hardlinksareok2
*** finished testing nosymlinks directories
+56 -47
View File
@@ -383,7 +383,6 @@ _fs_options()
$AWK_PROG -v dev=$1 '
match($1,dev) { print $4 }
' </proc/mounts
}
# returns device number if a file is a block device
@@ -504,7 +503,6 @@ _require_scratch()
then
_notrun "this test requires a valid \$SCRATCH_DEV"
fi
if [ "`_is_block_dev $SCRATCH_DEV`" = "`_is_block_dev $TEST_DEV`" ]
then
_notrun "this test requires a valid \$SCRATCH_DEV"
@@ -522,7 +520,6 @@ _require_scratch()
;;
esac
# mounted?
if _mount | grep -q $SCRATCH_DEV
then
@@ -1004,43 +1001,6 @@ _cleanup_testdir()
esac
}
################################################################################
if [ "$iam" != new -a "$iam" != bench ]
then
# make some further configuration checks here
if [ "$TEST_DEV" = "" ]
then
echo "common.rc: Error: \$TEST_DEV is not set"
exit 1
fi
# if $TEST_DEV is not mounted, mount it now as XFS
if [ -z "`_fs_type $TEST_DEV`" ]
then
# $TEST_DEV is not mounted
if ! _test_mount
then
echo "common.rc: retrying test device mount with external set"
[ "$USE_EXTERNAL" != "yes" ] && export USE_EXTERNAL=yes
if ! _test_mount
then
echo "common.rc: could not mount $TEST_DEV on $TEST_DIR"
exit 1
fi
fi
fi
if [ "`_fs_type $TEST_DEV`" != "xfs" ]
then
echo "common.rc: Error: \$TEST_DEV ($TEST_DEV) is not a MOUNTED XFS filesystem"
$DF_PROG $TEST_DEV
exit 1
fi
fi
_link_out_file()
{
if [ -z "$1" ]; then
@@ -1058,11 +1018,6 @@ _link_out_file()
fi
}
# Populate a filesystem with inodes for performance experiments
#
# usage: populate [-v] [-n ndirs] [-f nfiles] [-d depth] [-r root] [-s size]
#
_die()
{
echo $@
@@ -1106,7 +1061,10 @@ _descend()
done
}
# Populate a filesystem with inodes for performance experiments
#
# usage: populate [-v] [-n ndirs] [-f nfiles] [-d depth] [-r root] [-s size]
#
_populate_fs()
{
@@ -1137,8 +1095,59 @@ _populate_fs()
cd $here
[ $verbose = true ] && echo done
}
# query whether the given file has the given inode flag set
#
_test_inode_flag()
{
flag=$1
file=$2
if which $XFS_IO_PROG >/dev/null; then
if $XFS_IO_PROG -r -c 'lsattr -v' "$file" | fgrep -q "$flag" ; then
return 0
fi
fi
return 1
}
################################################################################
if [ "$iam" != new -a "$iam" != bench ]
then
# make some further configuration checks here
if [ "$TEST_DEV" = "" ]
then
echo "common.rc: Error: \$TEST_DEV is not set"
exit 1
fi
# if $TEST_DEV is not mounted, mount it now as XFS
if [ -z "`_fs_type $TEST_DEV`" ]
then
# $TEST_DEV is not mounted
if ! _test_mount
then
echo "common.rc: retrying test device mount with external set"
[ "$USE_EXTERNAL" != "yes" ] && export USE_EXTERNAL=yes
if ! _test_mount
then
echo "common.rc: could not mount $TEST_DEV on $TEST_DIR"
exit 1
fi
fi
fi
if [ "`_fs_type $TEST_DEV`" != "xfs" ]
then
echo "common.rc: Error: \$TEST_DEV ($TEST_DEV) is not a MOUNTED XFS filesystem"
$DF_PROG $TEST_DEV
exit 1
fi
fi
# make sure this script returns success
/bin/true