summaryrefslogtreecommitdiff
path: root/tests/xfs/149
blob: 503eff65d48d58bc4a50835a220a1df6a732ffc1 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
#! /bin/bash
# SPDX-License-Identifier: GPL-2.0
# Copyright (c) 2019 Red Hat, Inc.  All Rights Reserved.
#
# FS QA Test No. 149
#
# Test to ensure xfs_growfs command accepts device nodes if & only
# if they are mounted.
# This functionality, though undocumented, worked until xfsprogs v4.12
# It was added back and documented after xfsprogs v5.2 via
#   7e8275f8 xfs_growfs: allow mounted device node as argument
#
# Based on xfs/289
#
. ./common/preamble
_begin_fstest auto quick growfs

loopfile=$TEST_DIR/fsfile
mntdir=$TEST_DIR/mntdir
loop_symlink=$TEST_DIR/loop_symlink.$$

# Override the default cleanup function.
_cleanup()
{
    $UMOUNT_PROG $mntdir
    [ -n "$loop_dev" ] && _destroy_loop_device $loop_dev
    rmdir $mntdir
    rm -f $loop_symlink
    rm -f $loopfile
}

# Import common functions.
. ./common/filter

# real QA test starts here

# Modify as appropriate.
_supported_fs xfs
_require_test
_require_loop

mkdir -p $mntdir || _fail "!!! failed to create temp mount dir"

echo "=== mkfs.xfs ==="
$MKFS_XFS_PROG -d file,name=$loopfile,size=16m -f >/dev/null 2>&1

echo "=== truncate ==="
$XFS_IO_PROG -fc "truncate 256m" $loopfile

echo "=== create loop device ==="
loop_dev=$(_create_loop_device $loopfile)

echo "=== create loop device symlink ==="
ln -s $loop_dev $loop_symlink

echo "loop device is $loop_dev" >> $seqres.full

# These unmounted operations should fail

echo "=== xfs_growfs - unmounted device, command should be rejected ==="
$XFS_GROWFS_PROG $loop_dev 2>&1 | sed -e s:$loop_dev:LOOPDEV:

echo "=== xfs_growfs - check symlinked dev, unmounted ==="
$XFS_GROWFS_PROG $loop_symlink 2>&1 | sed -e s:$loop_symlink:LOOPSYMLINK:

# These mounted operations should pass

echo "=== mount ==="
$MOUNT_PROG $loop_dev $mntdir || _fail "!!! failed to loopback mount"

echo "=== xfs_growfs - check device node ==="
$XFS_GROWFS_PROG -D 8192 $loop_dev > /dev/null

echo "=== xfs_growfs - check device symlink ==="
$XFS_GROWFS_PROG -D 12288 $loop_symlink > /dev/null

echo "=== unmount ==="
$UMOUNT_PROG $mntdir || _fail "!!! failed to unmount"

echo "=== mount device symlink ==="
$MOUNT_PROG $loop_symlink $mntdir || _fail "!!! failed to loopback mount"

echo "=== xfs_growfs - check device symlink ==="
$XFS_GROWFS_PROG -D 16384 $loop_symlink > /dev/null

echo "=== xfs_growfs - check device node ==="
$XFS_GROWFS_PROG -D 20480 $loop_dev > /dev/null

# success, all done
status=0
exit