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