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 _begin_fstest growfs auto quick
13 # Override the default cleanup function.
24 # Import common functions.
27 # real QA test starts here
29 # Modify as appropriate.
34 tmpfile=$TEST_DIR/fsfile
35 tmpdir=$TEST_DIR/tmpdir
36 tmpsymlink=$TEST_DIR/tmpsymlink.$$
37 tmpbind=$TEST_DIR/tmpbind.$$
39 mkdir -p $tmpdir || _fail "!!! failed to create temp mount dir"
41 echo "=== mkfs.xfs ==="
42 $MKFS_XFS_PROG -d file,name=$tmpfile,size=16m -f >/dev/null 2>&1
44 echo "=== truncate ==="
45 $XFS_IO_PROG -fc "truncate 256m" $tmpfile
47 echo "=== xfs_growfs - unmounted, command should be rejected ==="
48 $XFS_GROWFS_PROG $tmpdir 2>&1 | _filter_test_dir
50 echo "=== xfs_growfs - check relative path, unmounted ==="
52 $XFS_GROWFS_PROG ./tmpdir 2>&1 | _filter_test_dir
54 echo "=== xfs_growfs - no path, unmounted ==="
55 $XFS_GROWFS_PROG tmpdir 2>&1 | _filter_test_dir
57 echo "=== xfs_growfs - plain file - should be rejected ==="
58 $XFS_GROWFS_PROG $tmpfile 2>&1 | _filter_test_dir
61 $MOUNT_PROG -o loop $tmpfile $tmpdir || _fail "!!! failed to loopback mount"
63 echo "=== xfs_growfs - mounted - check absolute path ==="
64 $XFS_GROWFS_PROG -D 8192 $tmpdir | _filter_test_dir > /dev/null
66 echo "=== xfs_growfs - check relative path ==="
67 $XFS_GROWFS_PROG -D 12288 ./tmpdir > /dev/null
69 echo "=== xfs_growfs - no path ==="
70 $XFS_GROWFS_PROG -D 16384 tmpdir > /dev/null
72 echo "=== xfs_growfs - symbolic link ==="
73 ln -s $tmpdir $tmpsymlink
74 $XFS_GROWFS_PROG -D 20480 $tmpsymlink | _filter_test_dir > /dev/null
76 echo "=== xfs_growfs - symbolic link using relative path ==="
77 $XFS_GROWFS_PROG -D 24576 ./tmpsymlink.$$ > /dev/null
79 echo "=== xfs_growfs - symbolic link using no path ==="
80 $XFS_GROWFS_PROG -D 28672 tmpsymlink.$$ > /dev/null
82 echo "=== xfs_growfs - bind mount ==="
84 $MOUNT_PROG -o bind $tmpdir $tmpbind
85 $XFS_GROWFS_PROG -D 32768 $tmpbind | _filter_test_dir > /dev/null
87 echo "=== xfs_growfs - bind mount - relative path ==="
88 $XFS_GROWFS_PROG -D 36864 ./tmpbind.$$ > /dev/null
90 echo "=== xfs_growfs - bind mount - no path ==="
91 $XFS_GROWFS_PROG -D 40960 tmpbind.$$ > /dev/null
93 echo "=== xfs_growfs - plain file - should be rejected ==="
94 $XFS_GROWFS_PROG $tmpfile 2>&1 | _filter_test_dir