fstests: move test group info to test files
[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 . ./common/preamble
10 _begin_fstest metadata dir ioctl auto quick
11
12 # Import common functions.
13 . ./common/filter
14
15 _create_scratch()
16 {
17         echo "*** mkfs"
18         if ! _scratch_mkfs_xfs >$tmp.out 2>&1
19         then
20                 cat $tmp.out
21                 echo "failed to mkfs $SCRATCH_DEV"
22                 exit 1
23         fi
24
25         echo "*** mount"
26         if ! _try_scratch_mount 2>/dev/null
27         then
28                 echo "failed to mount $SCRATCH_DEV"
29                 exit 1
30         fi
31 }
32
33 _filter_noymlinks_flag()
34 {
35         _test_inode_flag nosymlinks $SCRATCH_MNT/nosymlink
36         if [ $? -eq 0 ]; then
37                 echo "--n-- SCRATCH_MNT/nosymlink"
38         else
39                 echo "----- SCRATCH_MNT/nosymlink"
40         fi
41 }
42
43 # real QA test starts here
44 _supported_fs xfs
45 _require_scratch
46
47 _create_scratch
48
49 echo "*** testing nosymlinks directories"
50 mkdir $SCRATCH_MNT/nosymlink
51 echo "*** setting nosymlinks bit"
52 $XFS_IO_PROG -r -c 'chattr +n' $SCRATCH_MNT/nosymlink
53 _filter_noymlinks_flag
54
55 touch $SCRATCH_MNT/nosymlink/source
56 ln -s $SCRATCH_MNT/nosymlink/source $SCRATCH_MNT/nosymlink/target 2>&1 \
57         | _filter_scratch | _filter_ln
58 ln $SCRATCH_MNT/nosymlink/source $SCRATCH_MNT/nosymlink/hardlinksareok
59
60 echo "*** 1st listing..."
61 find $SCRATCH_MNT | _filter_scratch
62
63 echo "*** clearing nosymlinks bit"
64 $XFS_IO_PROG -r -c 'chattr -n' $SCRATCH_MNT/nosymlink
65 _filter_noymlinks_flag
66
67 ln -s $SCRATCH_MNT/nosymlink/source $SCRATCH_MNT/nosymlink/target
68 ln $SCRATCH_MNT/nosymlink/source $SCRATCH_MNT/nosymlink/hardlinksareok2
69
70 echo "*** 2nd listing..."
71 find $SCRATCH_MNT | _filter_scratch
72
73 echo "*** finished testing nosymlinks directories"
74
75 status=0
76 exit