2 # SPDX-License-Identifier: GPL-2.0
3 # Copyright (c) 2019 Red Hat, Inc. All Rights Reserved.
7 # Test to ensure xfs_growfs command accepts device nodes if & only
9 # This functionality, though undocumented, worked until xfsprogs v4.12
10 # It was added back and documented after xfsprogs v5.2 via
11 # 7e8275f8 xfs_growfs: allow mounted device node as argument
16 seqres=$RESULT_DIR/$seq
17 echo "QA output created by $seq"
21 status=1 # failure is the default!
22 trap "_cleanup; exit \$status" 0 1 2 3 15
24 loopfile=$TEST_DIR/fsfile
25 mntdir=$TEST_DIR/mntdir
26 loop_symlink=$TEST_DIR/loop_symlink.$$
31 [ -n "$loop_dev" ] && _destroy_loop_device $loop_dev
37 # get standard environment, filters and checks
41 # remove previous $seqres.full before test
44 # real QA test starts here
46 # Modify as appropriate.
52 mkdir -p $mntdir || _fail "!!! failed to create temp mount dir"
54 echo "=== mkfs.xfs ==="
55 $MKFS_XFS_PROG -d file,name=$loopfile,size=16m -f >/dev/null 2>&1
57 echo "=== truncate ==="
58 $XFS_IO_PROG -fc "truncate 256m" $loopfile
60 echo "=== create loop device ==="
61 loop_dev=$(_create_loop_device $loopfile)
63 echo "=== create loop device symlink ==="
64 ln -s $loop_dev $loop_symlink
66 echo "loop device is $loop_dev" >> $seqres.full
68 # These unmounted operations should fail
70 echo "=== xfs_growfs - unmounted device, command should be rejected ==="
71 $XFS_GROWFS_PROG $loop_dev 2>&1 | sed -e s:$loop_dev:LOOPDEV:
73 echo "=== xfs_growfs - check symlinked dev, unmounted ==="
74 $XFS_GROWFS_PROG $loop_symlink 2>&1 | sed -e s:$loop_symlink:LOOPSYMLINK:
76 # These mounted operations should pass
79 $MOUNT_PROG $loop_dev $mntdir || _fail "!!! failed to loopback mount"
81 echo "=== xfs_growfs - check device node ==="
82 $XFS_GROWFS_PROG -D 8192 $loop_dev > /dev/null
84 echo "=== xfs_growfs - check device symlink ==="
85 $XFS_GROWFS_PROG -D 12288 $loop_symlink > /dev/null
87 echo "=== unmount ==="
88 $UMOUNT_PROG $mntdir || _fail "!!! failed to unmount"
90 echo "=== mount device symlink ==="
91 $MOUNT_PROG $loop_symlink $mntdir || _fail "!!! failed to loopback mount"
93 echo "=== xfs_growfs - check device symlink ==="
94 $XFS_GROWFS_PROG -D 16384 $loop_symlink > /dev/null
96 echo "=== xfs_growfs - check device node ==="
97 $XFS_GROWFS_PROG -D 20480 $loop_dev > /dev/null