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.
51 mkdir -p $mntdir || _fail "!!! failed to create temp mount dir"
53 echo "=== mkfs.xfs ==="
54 $MKFS_XFS_PROG -d file,name=$loopfile,size=16m -f >/dev/null 2>&1
56 echo "=== truncate ==="
57 $XFS_IO_PROG -fc "truncate 256m" $loopfile
59 echo "=== create loop device ==="
60 loop_dev=$(_create_loop_device $loopfile)
62 echo "=== create loop device symlink ==="
63 ln -s $loop_dev $loop_symlink
65 echo "loop device is $loop_dev" >> $seqres.full
67 # These unmounted operations should fail
69 echo "=== xfs_growfs - unmounted device, command should be rejected ==="
70 $XFS_GROWFS_PROG $loop_dev 2>&1 | sed -e s:$loop_dev:LOOPDEV:
72 echo "=== xfs_growfs - check symlinked dev, unmounted ==="
73 $XFS_GROWFS_PROG $loop_symlink 2>&1 | sed -e s:$loop_symlink:LOOPSYMLINK:
75 # These mounted operations should pass
78 $MOUNT_PROG $loop_dev $mntdir || _fail "!!! failed to loopback mount"
80 echo "=== xfs_growfs - check device node ==="
81 $XFS_GROWFS_PROG -D 8192 $loop_dev > /dev/null
83 echo "=== xfs_growfs - check device symlink ==="
84 $XFS_GROWFS_PROG -D 12288 $loop_symlink > /dev/null
86 echo "=== unmount ==="
87 $UMOUNT_PROG $mntdir || _fail "!!! failed to unmount"
89 echo "=== mount device symlink ==="
90 $MOUNT_PROG $loop_symlink $mntdir || _fail "!!! failed to loopback mount"
92 echo "=== xfs_growfs - check device symlink ==="
93 $XFS_GROWFS_PROG -D 16384 $loop_symlink > /dev/null
95 echo "=== xfs_growfs - check device node ==="
96 $XFS_GROWFS_PROG -D 20480 $loop_dev > /dev/null