btrfs/012: check free size of scratch device before copying files
[xfstests-dev.git] / tests / overlay / 020
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 020
6 #
7 # Reproducer from kernel commit 3fe6e52
8 #    ovl: override creds with the ones from the superblock mounter
9 # Testing ovl copyup/namespace/cred issue.
10 #
11 seq=`basename $0`
12 seqres=$RESULT_DIR/$seq
13 echo "QA output created by $seq"
14
15 here=`pwd`
16 tmp=/tmp/$$
17 status=1        # failure is the default!
18 trap "_cleanup; exit \$status" 0 1 2 3 15
19
20 _cleanup()
21 {
22         cd /
23         rm -f $tmp.*
24 }
25
26 # get standard environment, filters and checks
27 . ./common/rc
28 . ./common/filter
29
30 # remove previous $seqres.full before test
31 rm -f $seqres.full
32
33 # real QA test starts here
34
35 require_unshare() {
36         unshare -f -r "$@" true &>/dev/null || \
37                 _notrun "unshare $@: not supported"
38 }
39
40 # Modify as appropriate.
41 _supported_fs overlay
42 _require_scratch
43 require_unshare -m -p -U
44
45 # Remove all files from previous tests
46 _scratch_mkfs
47
48 lowerdir=$OVL_BASE_SCRATCH_MNT/$OVL_LOWER
49 mkdir -p $lowerdir/dir
50
51 _scratch_mount
52
53 unshare -m -p -f -U -r bash -c \
54         "touch $SCRATCH_MNT/dir/{1,2,3}; rm -fR $SCRATCH_MNT/*"
55
56 echo "Silence is golden"
57
58 # success, all done
59 status=0
60 exit