02c3f9d156598eacc9299947a34ea841f4dd799b
[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 echo "QA output created by $seq"
27
28 here=`pwd`
29 tmp=/tmp/$$
30 status=1        # failure is the default!
31 trap "rm -f $tmp.*; exit \$status" 0 1 2 3 15
32
33 # get standard environment, filters and checks
34 . ./common.rc
35 . ./common.filter
36
37 _create_scratch()
38 {
39         echo "*** mkfs"
40         if ! _scratch_mkfs_xfs >$tmp.out 2>&1
41         then
42                 cat $tmp.out
43                 echo "failed to mkfs $SCRATCH_DEV"
44                 exit 1
45         fi
46
47         echo "*** mount"
48         if ! _scratch_mount 2>/dev/null
49         then
50                 echo "failed to mount $SCRATCH_DEV"
51                 exit 1
52         fi
53 }
54
55 _filter_noymlinks_flag()
56 {
57         _test_inode_flag nosymlinks $SCRATCH_MNT/nosymlink
58         if [ $? -eq 0 ]; then
59                 echo "--n-- SCRATCH_MNT/nosymlink"
60         else
61                 echo "----- SCRATCH_MNT/nosymlink"
62         fi
63 }
64
65 # real QA test starts here
66 _supported_os Linux IRIX
67 _supported_fs xfs
68 _require_command $XFS_IO_PROG xfs_io
69 _require_scratch
70
71 _create_scratch
72
73
74 echo "*** testing nosymlinks directories"
75 mkdir $SCRATCH_MNT/nosymlink
76 echo "*** setting nosymlinks bit"
77 $XFS_IO_PROG -r -c 'chattr +n' $SCRATCH_MNT/nosymlink
78 _filter_noymlinks_flag
79
80 touch $SCRATCH_MNT/nosymlink/source
81 ln -s $SCRATCH_MNT/nosymlink/source $SCRATCH_MNT/nosymlink/target 2>&1 \
82         | _filter_scratch | _filter_ln
83 ln $SCRATCH_MNT/nosymlink/source $SCRATCH_MNT/nosymlink/hardlinksareok
84
85 echo "*** 1st listing..."
86 find $SCRATCH_MNT | _filter_scratch
87
88 echo "*** clearing nosymlinks bit"
89 $XFS_IO_PROG -r -c 'chattr -n' $SCRATCH_MNT/nosymlink
90 _filter_noymlinks_flag
91
92 ln -s $SCRATCH_MNT/nosymlink/source $SCRATCH_MNT/nosymlink/target
93 ln $SCRATCH_MNT/nosymlink/source $SCRATCH_MNT/nosymlink/hardlinksareok2
94
95 echo "*** 2nd listing..."
96 find $SCRATCH_MNT | _filter_scratch
97
98 echo "*** finished testing nosymlinks directories"
99
100 status=0
101 exit