xfs: convert tests to SPDX license tags
[xfstests-dev.git] / tests / xfs / 298
1 #! /bin/bash
2 # SPDX-License-Identifier: GPL-2.0
3 # Copyright (c) 2013 SGI.  All Rights Reserved.
4 #
5 # FS QA Test No. 298
6 #
7 # Test that inline symlinks are removed from the inode when an extended
8 # attributes forces it into being remote symlink.
9 # Warning: this test will ASSERT on unpatched DEBUG XFS.
10 #
11 seq=`basename $0`
12 seqres=$RESULT_DIR/$seq
13 echo "QA output created by $seq"
14
15 here=`pwd`
16 tmp=/tmp/$$
17 status=1        # failure is the default!
18 trap "_cleanup; exit \$status" 0 1 2 3 15
19
20 _cleanup()
21 {
22     cd /
23     rm -f $tmp.*
24 }
25
26 # get standard environment, filters and checks
27 . ./common/rc
28 . ./common/filter
29
30 # real QA test starts here
31
32 # Modify as appropriate. This is a XFS specific bug. xfs_db also limits
33 # this test to xfs
34 _supported_fs xfs
35 _supported_os Linux
36
37 _require_scratch
38
39 rm -f $seqres.full
40 _scratch_mkfs_xfs >/dev/null 2>&1
41
42 SYMLINK_FILE="$SCRATCH_MNT/symlink"
43 SYMLINK=""
44 SYMLINK_ADD="0123456789ABCDEF01234567890ABCDEF"
45
46 # test from 32 to MAXPATHLEN sized symlink. This should make sure that
47 # 256-1024 byte version 2 and 3 inodes are covered.
48 SIZE=32
49 while [ $SIZE -lt 1024 ];do
50         _scratch_mount >/dev/null 2>&1
51         cd $SCRATCH_MNT
52         echo "Testing symlink size $SIZE"
53         SYMLINK="${SYMLINK}${SYMLINK_ADD}"
54         ln -s $SYMLINK $SYMLINK_FILE > /dev/null 2>&1
55
56         inode=`ls -li $SYMLINK_FILE | awk '{print $1}'`
57 # add the extended attributes
58         attr  -Rs 1234567890ab $SYMLINK_FILE < /dev/null > /dev/null 2>&1
59         attr  -Rs 1234567890ac $SYMLINK_FILE < /dev/null > /dev/null 2>&1
60         attr  -Rs 1234567890ad $SYMLINK_FILE < /dev/null > /dev/null 2>&1
61 # remove the extended attributes
62         attr  -Rr 1234567890ab $SYMLINK_FILE > /dev/null 2>&1
63         attr  -Rr 1234567890ac $SYMLINK_FILE > /dev/null 2>&1
64         attr  -Rr 1234567890ad $SYMLINK_FILE > /dev/null 2>&1
65 # remove the symlink - make sure ifree removes the remote symlink.
66         rm $SYMLINK_FILE
67 # umount and check the number of extents on the inode. Should be 0.
68         cd /
69         _scratch_unmount >/dev/null 2>&1
70         _scratch_xfs_db  -c "inode $inode" -c "p core.nextents"
71
72         let SIZE=$SIZE+32
73 done
74
75 status=0
76 exit