generic/077: fall back to /usr if /lib/modules doesn't exist
[xfstests-dev.git] / tests / xfs / 298
1 #! /bin/bash
2 # FS QA Test No. 298
3 #
4 # Test that inline symlinks are removed from the inode when an extended
5 # attributes forces it into being remote symlink.
6 # Warning: this test will ASSERT on unpatched DEBUG XFS.
7 #
8 #-----------------------------------------------------------------------
9 # Copyright (c) 2013 SGI.  All Rights Reserved.
10 #
11 # This program is free software; you can redistribute it and/or
12 # modify it under the terms of the GNU General Public License as
13 # published by the Free Software Foundation.
14 #
15 # This program is distributed in the hope that it would be useful,
16 # but WITHOUT ANY WARRANTY; without even the implied warranty of
17 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
18 # GNU General Public License for more details.
19 #
20 # You should have received a copy of the GNU General Public License
21 # along with this program; if not, write the Free Software Foundation,
22 # Inc.,  51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
23 #-----------------------------------------------------------------------
24 #
25
26 seq=`basename $0`
27 seqres=$RESULT_DIR/$seq
28 echo "QA output created by $seq"
29
30 here=`pwd`
31 tmp=/tmp/$$
32 status=1        # failure is the default!
33 trap "_cleanup; exit \$status" 0 1 2 3 15
34
35 _cleanup()
36 {
37     cd /
38     rm -f $tmp.*
39 }
40
41 # get standard environment, filters and checks
42 . ./common/rc
43 . ./common/filter
44
45 # real QA test starts here
46
47 # Modify as appropriate. This is a XFS specific bug. xfs_db also limits
48 # this test to xfs
49 _supported_fs xfs
50 _supported_os Linux
51
52 _require_scratch
53
54 rm -f $seqres.full
55 _scratch_mkfs_xfs >/dev/null 2>&1
56
57 SYMLINK_FILE="$SCRATCH_MNT/symlink"
58 SYMLINK=""
59 SYMLINK_ADD="0123456789ABCDEF01234567890ABCDEF"
60
61 # test from 32 to MAXPATHLEN sized symlink. This should make sure that
62 # 256-1024 byte version 2 and 3 inodes are covered.
63 SIZE=32
64 while [ $SIZE -lt 1024 ];do
65         _scratch_mount >/dev/null 2>&1
66         cd $SCRATCH_MNT
67         echo "Testing symlink size $SIZE"
68         SYMLINK="${SYMLINK}${SYMLINK_ADD}"
69         ln -s $SYMLINK $SYMLINK_FILE > /dev/null 2>&1
70
71         inode=`ls -li $SYMLINK_FILE | awk '{print $1}'`
72 # add the extended attributes
73         attr  -Rs 1234567890ab $SYMLINK_FILE < /dev/null > /dev/null 2>&1
74         attr  -Rs 1234567890ac $SYMLINK_FILE < /dev/null > /dev/null 2>&1
75         attr  -Rs 1234567890ad $SYMLINK_FILE < /dev/null > /dev/null 2>&1
76 # remove the extended attributes
77         attr  -Rr 1234567890ab $SYMLINK_FILE > /dev/null 2>&1
78         attr  -Rr 1234567890ac $SYMLINK_FILE > /dev/null 2>&1
79         attr  -Rr 1234567890ad $SYMLINK_FILE > /dev/null 2>&1
80 # remove the symlink - make sure ifree removes the remote symlink.
81         rm $SYMLINK_FILE
82 # umount and check the number of extents on the inode. Should be 0.
83         cd
84         _scratch_unmount >/dev/null 2>&1
85         $XFS_DB_PROG  -c "inode $inode" -c "p core.nextents" $SCRATCH_DEV
86
87         let SIZE=$SIZE+32
88 done
89
90 status=0
91 exit