common/xfs: refactor commands to select a particular xfs backing device
[xfstests-dev.git] / tests / overlay / 003
1 #! /bin/bash
2 # SPDX-License-Identifier: GPL-2.0
3 # Copyright (c) 2016 Red Hat Inc. All Rights Reserved.
4 #
5 # FS QA Test 003
6 #
7 # Test overlayfs basic whiteout.
8 #
9 # Overlayfs whiteout can be visible if underlying upper fs does not
10 # support d_type. Kernel commit
11 #       45aebea (ovl: Ensure upper filesystem supports d_type)
12 # prevents mounting overlayfs like this since v4.6-rc1.
13 # No harm to keep this test as a sanity check.
14 #
15 seq=`basename $0`
16 seqres=$RESULT_DIR/$seq
17 echo "QA output created by $seq"
18
19 here=`pwd`
20 tmp=/tmp/$$
21 status=1        # failure is the default!
22 trap "_cleanup; exit \$status" 0 1 2 3 15
23
24 _cleanup()
25 {
26         cd /
27         rm -f $tmp.*
28 }
29
30 # get standard environment, filters and checks
31 . ./common/rc
32 . ./common/filter
33
34 # remove previous $seqres.full before test
35 rm -f $seqres.full
36
37 # real QA test starts here
38
39 # Modify as appropriate.
40 _supported_fs overlay
41 _require_scratch
42
43 # Remove all files from previous tests
44 _scratch_mkfs
45
46 # Create test files dirs in lower dir
47 lowerdir=${OVL_BASE_SCRATCH_MNT}/${OVL_LOWER}
48 mkdir -p $lowerdir
49
50 touch ${lowerdir}/test_file
51 ln -s ${lowerdir}/test_file ${lowerdir}/test_softlink_file
52 ln ${lowerdir}/test_file ${lowerdir}/test_hardlink_file
53
54 mkdir -p ${lowerdir}/test_dir
55 ln -s ${lowerdir}/test_dir ${lowerdir}/test_softlink_dir
56
57 mknod ${lowerdir}/test_cdev c 2 3
58 ln -s ${lowerdir}/test_cdev ${lowerdir}/test_softlink_cdev
59 ln ${lowerdir}/test_cdev ${lowerdir}/test_hardlink_cdev
60
61 mknod ${lowerdir}/test_bdev b 2 4
62 ln -s ${lowerdir}/test_bdev ${lowerdir}/test_softlink_bdev
63 ln ${lowerdir}/test_bdev ${lowerdir}/test_hardlink_bdev
64
65 mknod ${lowerdir}/test_pipe p
66 ln -s ${lowerdir}/test_pipe ${lowerdir}/test_softlink_pipe
67 ln ${lowerdir}/test_pipe ${lowerdir}/test_hardlink_pipe
68
69 _scratch_mount
70
71 # whiteout all files in overlay mountpoint
72 rm -rf ${SCRATCH_MNT}/*
73 # nothing should be listed
74 ls ${SCRATCH_MNT}/
75
76 # unmount overlayfs but not base fs
77 $UMOUNT_PROG $SCRATCH_MNT
78
79 echo "Silence is golden"
80 # success, all done
81 status=0
82 exit