xfs: force file creation to the data device for certain layout tests
[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_fs xfs
52 _require_scratch
53
54 _create_scratch
55
56 echo "*** testing nosymlinks directories"
57 mkdir $SCRATCH_MNT/nosymlink
58 echo "*** setting nosymlinks bit"
59 $XFS_IO_PROG -r -c 'chattr +n' $SCRATCH_MNT/nosymlink
60 _filter_noymlinks_flag
61
62 touch $SCRATCH_MNT/nosymlink/source
63 ln -s $SCRATCH_MNT/nosymlink/source $SCRATCH_MNT/nosymlink/target 2>&1 \
64         | _filter_scratch | _filter_ln
65 ln $SCRATCH_MNT/nosymlink/source $SCRATCH_MNT/nosymlink/hardlinksareok
66
67 echo "*** 1st listing..."
68 find $SCRATCH_MNT | _filter_scratch
69
70 echo "*** clearing nosymlinks bit"
71 $XFS_IO_PROG -r -c 'chattr -n' $SCRATCH_MNT/nosymlink
72 _filter_noymlinks_flag
73
74 ln -s $SCRATCH_MNT/nosymlink/source $SCRATCH_MNT/nosymlink/target
75 ln $SCRATCH_MNT/nosymlink/source $SCRATCH_MNT/nosymlink/hardlinksareok2
76
77 echo "*** 2nd listing..."
78 find $SCRATCH_MNT | _filter_scratch
79
80 echo "*** finished testing nosymlinks directories"
81
82 status=0
83 exit