xfs/029: filter out "extended-header: cycle: 1" from output
[xfstests-dev.git] / tests / xfs / 103
1 #! /bin/bash
2 # SPDX-License-Identifier: GPL-2.0
3 # Copyright (c) 2000-2005 Silicon Graphics, Inc.  All Rights Reserved.
4 #
5 # FS QA Test No. 103
6 #
7 # Exercise the XFS nosymlinks inode flag
8 #
9 seq=`basename $0`
10 seqres=$RESULT_DIR/$seq
11 echo "QA output created by $seq"
12
13 here=`pwd`
14 tmp=/tmp/$$
15 status=1        # failure is the default!
16 trap "rm -f $tmp.*; exit \$status" 0 1 2 3 15
17
18 # get standard environment, filters and checks
19 . ./common/rc
20 . ./common/filter
21
22 _create_scratch()
23 {
24         echo "*** mkfs"
25         if ! _scratch_mkfs_xfs >$tmp.out 2>&1
26         then
27                 cat $tmp.out
28                 echo "failed to mkfs $SCRATCH_DEV"
29                 exit 1
30         fi
31
32         echo "*** mount"
33         if ! _try_scratch_mount 2>/dev/null
34         then
35                 echo "failed to mount $SCRATCH_DEV"
36                 exit 1
37         fi
38 }
39
40 _filter_noymlinks_flag()
41 {
42         _test_inode_flag nosymlinks $SCRATCH_MNT/nosymlink
43         if [ $? -eq 0 ]; then
44                 echo "--n-- SCRATCH_MNT/nosymlink"
45         else
46                 echo "----- SCRATCH_MNT/nosymlink"
47         fi
48 }
49
50 # real QA test starts here
51 _supported_os Linux
52 _supported_fs xfs
53 _require_scratch
54
55 _create_scratch
56
57 echo "*** testing nosymlinks directories"
58 mkdir $SCRATCH_MNT/nosymlink
59 echo "*** setting nosymlinks bit"
60 $XFS_IO_PROG -r -c 'chattr +n' $SCRATCH_MNT/nosymlink
61 _filter_noymlinks_flag
62
63 touch $SCRATCH_MNT/nosymlink/source
64 ln -s $SCRATCH_MNT/nosymlink/source $SCRATCH_MNT/nosymlink/target 2>&1 \
65         | _filter_scratch | _filter_ln
66 ln $SCRATCH_MNT/nosymlink/source $SCRATCH_MNT/nosymlink/hardlinksareok
67
68 echo "*** 1st listing..."
69 find $SCRATCH_MNT | _filter_scratch
70
71 echo "*** clearing nosymlinks bit"
72 $XFS_IO_PROG -r -c 'chattr -n' $SCRATCH_MNT/nosymlink
73 _filter_noymlinks_flag
74
75 ln -s $SCRATCH_MNT/nosymlink/source $SCRATCH_MNT/nosymlink/target
76 ln $SCRATCH_MNT/nosymlink/source $SCRATCH_MNT/nosymlink/hardlinksareok2
77
78 echo "*** 2nd listing..."
79 find $SCRATCH_MNT | _filter_scratch
80
81 echo "*** finished testing nosymlinks directories"
82
83 status=0
84 exit