0cb51f2819002bd803e5273846190a11ca46fa13
[xfstests-dev.git] / tests / xfs / 103
1 #! /bin/bash
2 # FS QA Test No. 103
3 #
4 # Exercise the XFS nosymlinks inode flag
5 #
6 #-----------------------------------------------------------------------
7 # Copyright (c) 2000-2005 Silicon Graphics, Inc.  All Rights Reserved.
8 #
9 # This program is free software; you can redistribute it and/or
10 # modify it under the terms of the GNU General Public License as
11 # published by the Free Software Foundation.
12 #
13 # This program is distributed in the hope that it would be useful,
14 # but WITHOUT ANY WARRANTY; without even the implied warranty of
15 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
16 # GNU General Public License for more details.
17 #
18 # You should have received a copy of the GNU General Public License
19 # along with this program; if not, write the Free Software Foundation,
20 # Inc.,  51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
21 #
22 #-----------------------------------------------------------------------
23 #
24
25 seq=`basename $0`
26 seqres=$RESULT_DIR/$seq
27 seqres=$RESULT_DIR/$seq
28 seqres=$RESULT_DIR/$seq
29 echo "QA output created by $seq"
30
31 here=`pwd`
32 tmp=/tmp/$$
33 status=1        # failure is the default!
34 trap "rm -f $tmp.*; exit \$status" 0 1 2 3 15
35
36 # get standard environment, filters and checks
37 . ./common/rc
38 . ./common/filter
39
40 _create_scratch()
41 {
42         echo "*** mkfs"
43         if ! _scratch_mkfs_xfs >$tmp.out 2>&1
44         then
45                 cat $tmp.out
46                 echo "failed to mkfs $SCRATCH_DEV"
47                 exit 1
48         fi
49
50         echo "*** mount"
51         if ! _scratch_mount 2>/dev/null
52         then
53                 echo "failed to mount $SCRATCH_DEV"
54                 exit 1
55         fi
56 }
57
58 _filter_noymlinks_flag()
59 {
60         _test_inode_flag nosymlinks $SCRATCH_MNT/nosymlink
61         if [ $? -eq 0 ]; then
62                 echo "--n-- SCRATCH_MNT/nosymlink"
63         else
64                 echo "----- SCRATCH_MNT/nosymlink"
65         fi
66 }
67
68 # real QA test starts here
69 _supported_os Linux IRIX
70 _supported_fs xfs
71 _require_command $XFS_IO_PROG xfs_io
72 _require_scratch
73
74 _create_scratch
75
76
77 echo "*** testing nosymlinks directories"
78 mkdir $SCRATCH_MNT/nosymlink
79 echo "*** setting nosymlinks bit"
80 $XFS_IO_PROG -r -c 'chattr +n' $SCRATCH_MNT/nosymlink
81 _filter_noymlinks_flag
82
83 touch $SCRATCH_MNT/nosymlink/source
84 ln -s $SCRATCH_MNT/nosymlink/source $SCRATCH_MNT/nosymlink/target 2>&1 \
85         | _filter_scratch | _filter_ln
86 ln $SCRATCH_MNT/nosymlink/source $SCRATCH_MNT/nosymlink/hardlinksareok
87
88 echo "*** 1st listing..."
89 find $SCRATCH_MNT | _filter_scratch
90
91 echo "*** clearing nosymlinks bit"
92 $XFS_IO_PROG -r -c 'chattr -n' $SCRATCH_MNT/nosymlink
93 _filter_noymlinks_flag
94
95 ln -s $SCRATCH_MNT/nosymlink/source $SCRATCH_MNT/nosymlink/target
96 ln $SCRATCH_MNT/nosymlink/source $SCRATCH_MNT/nosymlink/hardlinksareok2
97
98 echo "*** 2nd listing..."
99 find $SCRATCH_MNT | _filter_scratch
100
101 echo "*** finished testing nosymlinks directories"
102
103 status=0
104 exit