check we support quotas
[xfstests-dev.git] / 103
1 #! /bin/sh
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 #  This program is free software; you can redistribute it and/or modify
9 #  it under the terms of the GNU General Public License as published by
10 #  the Free Software Foundation; either version 2 of the License, or
11 #  (at your option) any later version.
12 #
13 #  This program is distributed in the hope that it will 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 to the Free Software
20 #  Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307
21 #  USA
22 #
23 #  Contact information: Silicon Graphics, Inc., 1500 Crittenden Lane,
24 #  Mountain View, CA 94043, USA, or: http://www.sgi.com
25 #-----------------------------------------------------------------------
26 #
27 # creator
28 owner=nathans@sgi.com
29
30 seq=`basename $0`
31 echo "QA output created by $seq"
32
33 here=`pwd`
34 tmp=/tmp/$$
35 status=1        # failure is the default!
36 trap "rm -f $tmp.*; exit \$status" 0 1 2 3 15
37
38 # get standard environment, filters and checks
39 . ./common.rc
40 . ./common.filter
41
42 _create_scratch()
43 {
44         echo "*** mkfs"
45         if ! _scratch_mkfs_xfs >$tmp.out 2>&1
46         then
47                 cat $tmp.out
48                 echo "failed to mkfs $SCRATCH_DEV"
49                 exit 1
50         fi
51
52         echo "*** mount"
53         if ! _scratch_mount 2>/dev/null
54         then
55                 echo "failed to mount $SCRATCH_DEV"
56                 exit 1
57         fi
58 }
59
60 _filter_scratch()
61 {
62         sed -e "s,$SCRATCH_MNT,SCRATCH_MNT,g"
63 }
64
65 _filter_ln()
66 {
67     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"
68 }
69
70 _filter_noymlinks_flag()
71 {
72         _test_inode_flag nosymlinks $SCRATCH_MNT/nosymlink
73         if [ $? -eq 0 ]; then
74                 echo "--n-- SCRATCH_MNT/nosymlink"
75         else
76                 echo "----- SCRATCH_MNT/nosymlink"
77         fi
78 }
79
80 # real QA test starts here
81 _supported_os Linux IRIX
82 _supported_fs xfs
83 _require_command /usr/sbin/xfs_io
84 _require_scratch
85
86 _create_scratch
87
88
89 echo "*** testing nosymlinks directories"
90 mkdir $SCRATCH_MNT/nosymlink
91 echo "*** setting nosymlinks bit"
92 $XFS_IO_PROG -r -c 'chattr +n' $SCRATCH_MNT/nosymlink
93 _filter_noymlinks_flag
94
95 touch $SCRATCH_MNT/nosymlink/source
96 ln -s $SCRATCH_MNT/nosymlink/source $SCRATCH_MNT/nosymlink/target 2>&1 \
97         | _filter_scratch | _filter_ln
98 ln $SCRATCH_MNT/nosymlink/source $SCRATCH_MNT/nosymlink/hardlinksareok
99
100 echo "*** 1st listing..."
101 find $SCRATCH_MNT | _filter_scratch
102
103 echo "*** clearing nosymlinks bit"
104 $XFS_IO_PROG -r -c 'chattr -n' $SCRATCH_MNT/nosymlink
105 _filter_noymlinks_flag
106
107 ln -s $SCRATCH_MNT/nosymlink/source $SCRATCH_MNT/nosymlink/target
108 ln $SCRATCH_MNT/nosymlink/source $SCRATCH_MNT/nosymlink/hardlinksareok2
109
110 echo "*** 2nd listing..."
111 find $SCRATCH_MNT | _filter_scratch
112
113 echo "*** finished testing nosymlinks directories"
114
115 status=0
116 exit