2 # SPDX-License-Identifier: GPL-2.0
3 # Copyright (c) 2017 Red Hat, Inc. All Rights Reserved.
7 # Test to ensure xfs_growfs command rejects non-existent mount points
8 # and accepts mounted targets.
11 seqres=$RESULT_DIR/$seq
12 echo "QA output created by $seq"
16 status=1 # failure is the default!
17 trap "_cleanup; exit \$status" 0 1 2 3 15
29 # get standard environment, filters and checks
33 # remove previous $seqres.full before test
36 # real QA test starts here
38 # Modify as appropriate.
43 tmpfile=$TEST_DIR/fsfile
44 tmpdir=$TEST_DIR/tmpdir
45 tmpsymlink=$TEST_DIR/tmpsymlink.$$
46 tmpbind=$TEST_DIR/tmpbind.$$
48 mkdir -p $tmpdir || _fail "!!! failed to create temp mount dir"
50 echo "=== mkfs.xfs ==="
51 $MKFS_XFS_PROG -d file,name=$tmpfile,size=16m -f >/dev/null 2>&1
53 echo "=== truncate ==="
54 $XFS_IO_PROG -fc "truncate 256m" $tmpfile
56 echo "=== xfs_growfs - unmounted, command should be rejected ==="
57 $XFS_GROWFS_PROG $tmpdir 2>&1 | _filter_test_dir
59 echo "=== xfs_growfs - check relative path, unmounted ==="
61 $XFS_GROWFS_PROG ./tmpdir 2>&1 | _filter_test_dir
63 echo "=== xfs_growfs - no path, unmounted ==="
64 $XFS_GROWFS_PROG tmpdir 2>&1 | _filter_test_dir
66 echo "=== xfs_growfs - plain file - should be rejected ==="
67 $XFS_GROWFS_PROG $tmpfile 2>&1 | _filter_test_dir
70 $MOUNT_PROG -o loop $tmpfile $tmpdir || _fail "!!! failed to loopback mount"
72 echo "=== xfs_growfs - mounted - check absolute path ==="
73 $XFS_GROWFS_PROG -D 8192 $tmpdir | _filter_test_dir > /dev/null
75 echo "=== xfs_growfs - check relative path ==="
76 $XFS_GROWFS_PROG -D 12288 ./tmpdir > /dev/null
78 echo "=== xfs_growfs - no path ==="
79 $XFS_GROWFS_PROG -D 16384 tmpdir > /dev/null
81 echo "=== xfs_growfs - symbolic link ==="
82 ln -s $tmpdir $tmpsymlink
83 $XFS_GROWFS_PROG -D 20480 $tmpsymlink | _filter_test_dir > /dev/null
85 echo "=== xfs_growfs - symbolic link using relative path ==="
86 $XFS_GROWFS_PROG -D 24576 ./tmpsymlink.$$ > /dev/null
88 echo "=== xfs_growfs - symbolic link using no path ==="
89 $XFS_GROWFS_PROG -D 28672 tmpsymlink.$$ > /dev/null
91 echo "=== xfs_growfs - bind mount ==="
93 $MOUNT_PROG -o bind $tmpdir $tmpbind
94 $XFS_GROWFS_PROG -D 32768 $tmpbind | _filter_test_dir > /dev/null
96 echo "=== xfs_growfs - bind mount - relative path ==="
97 $XFS_GROWFS_PROG -D 36864 ./tmpbind.$$ > /dev/null
99 echo "=== xfs_growfs - bind mount - no path ==="
100 $XFS_GROWFS_PROG -D 40960 tmpbind.$$ > /dev/null
102 echo "=== xfs_growfs - plain file - should be rejected ==="
103 $XFS_GROWFS_PROG $tmpfile 2>&1 | _filter_test_dir