xfs: test what happens when we reset the root dir and it has xattrs
[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
36 _require_scratch
37
38 rm -f $seqres.full
39 _scratch_mkfs_xfs >/dev/null 2>&1
40
41 SYMLINK_FILE="$SCRATCH_MNT/symlink"
42 SYMLINK=""
43 SYMLINK_ADD="0123456789ABCDEF01234567890ABCDEF"
44
45 # test from 32 to MAXPATHLEN sized symlink. This should make sure that
46 # 256-1024 byte version 2 and 3 inodes are covered.
47 SIZE=32
48 while [ $SIZE -lt 1024 ];do
49         _scratch_mount >/dev/null 2>&1
50         cd $SCRATCH_MNT
51         echo "Testing symlink size $SIZE"
52         SYMLINK="${SYMLINK}${SYMLINK_ADD}"
53         ln -s $SYMLINK $SYMLINK_FILE > /dev/null 2>&1
54
55         inode=`ls -li $SYMLINK_FILE | awk '{print $1}'`
56 # add the extended attributes
57         attr  -Rs 1234567890ab $SYMLINK_FILE < /dev/null > /dev/null 2>&1
58         attr  -Rs 1234567890ac $SYMLINK_FILE < /dev/null > /dev/null 2>&1
59         attr  -Rs 1234567890ad $SYMLINK_FILE < /dev/null > /dev/null 2>&1
60 # remove the extended attributes
61         attr  -Rr 1234567890ab $SYMLINK_FILE > /dev/null 2>&1
62         attr  -Rr 1234567890ac $SYMLINK_FILE > /dev/null 2>&1
63         attr  -Rr 1234567890ad $SYMLINK_FILE > /dev/null 2>&1
64 # remove the symlink - make sure ifree removes the remote symlink.
65         rm $SYMLINK_FILE
66 # umount and check the number of extents on the inode. Should be 0.
67         cd /
68         _scratch_unmount >/dev/null 2>&1
69         _scratch_xfs_db  -c "inode $inode" -c "p core.nextents"
70
71         let SIZE=$SIZE+32
72 done
73
74 status=0
75 exit