2004-09-23 14:35:43 +00:00
#! /bin/sh
# FS QA Test No. 103
#
2005-07-11 14:57:36 +00:00
# Exercise the XFS nosymlinks inode flag
2004-09-23 14:35:43 +00:00
#
#-----------------------------------------------------------------------
2005-08-18 03:49:54 +00:00
# Copyright (c) 2000-2005 Silicon Graphics, Inc. All Rights Reserved.
2004-09-23 14:35:43 +00:00
#-----------------------------------------------------------------------
#
# creator
owner = nathans@sgi.com
seq = ` basename $0 `
echo " QA output created by $seq "
here = ` pwd `
tmp = /tmp/$$
status = 1 # failure is the default!
trap " rm -f $tmp .*; exit \$status " 0 1 2 3 15
# get standard environment, filters and checks
. ./common.rc
. ./common.filter
_create_scratch( )
{
echo "*** mkfs"
if ! _scratch_mkfs_xfs >$tmp .out 2>& 1
then
cat $tmp .out
echo " failed to mkfs $SCRATCH_DEV "
exit 1
fi
echo "*** mount"
if ! _scratch_mount 2>/dev/null
then
echo " failed to mount $SCRATCH_DEV "
exit 1
fi
}
_filter_scratch( )
{
sed -e " s, $SCRATCH_MNT ,SCRATCH_MNT,g "
}
2005-08-18 03:49:54 +00:00
_filter_ln( )
{
2008-03-26 03:27:32 +00:00
sed -e "s,SCRATCH_MNT/nosymlink/target - Operation not permitted,ln: creating symbolic link \`SCRATCH_MNT/nosymlink/target\' to \`SCRATCH_MNT/nosymlink/source\': Operation not permitted,g" \
-e "s,: Operation not permitted, to \`SCRATCH_MNT/nosymlink/source\': Operation not permitted,g"
2005-08-18 03:49:54 +00:00
}
2005-07-11 14:57:36 +00:00
_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
}
2004-09-23 14:35:43 +00:00
# real QA test starts here
2005-08-18 03:49:54 +00:00
_supported_os Linux IRIX
2004-09-23 14:35:43 +00:00
_supported_fs xfs
_require_command /usr/sbin/xfs_io
_require_scratch
_create_scratch
echo "*** testing nosymlinks directories"
2005-07-11 14:57:36 +00:00
mkdir $SCRATCH_MNT /nosymlink
2004-09-23 14:35:43 +00:00
echo "*** setting nosymlinks bit"
2005-07-11 14:57:36 +00:00
$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 \
2005-08-18 03:49:54 +00:00
| _filter_scratch | _filter_ln
2005-07-11 14:57:36 +00:00
ln $SCRATCH_MNT /nosymlink/source $SCRATCH_MNT /nosymlink/hardlinksareok
2004-09-23 14:35:43 +00:00
echo "*** 1st listing..."
find $SCRATCH_MNT | _filter_scratch
echo "*** clearing nosymlinks bit"
2005-07-11 14:57:36 +00:00
$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
2004-09-23 14:35:43 +00:00
echo "*** 2nd listing..."
find $SCRATCH_MNT | _filter_scratch
echo "*** finished testing nosymlinks directories"
status = 0
exit