2 # SPDX-License-Identifier: GPL-2.0
3 # Copyright (C) 2017 CTERA Networks. All Rights Reserved.
7 # Test cases that force read-only mount
10 # - Failure to create work dir
13 seqres=$RESULT_DIR/$seq
14 echo "QA output created by $seq"
18 status=1 # failure is the default!
19 trap "_cleanup; exit \$status" 0 1 2 3 15
24 $CHATTR_PROG -i $workdir
28 # get standard environment, filters and checks
32 # remove previous $seqres.full before test
35 # real QA test starts here
37 # Use non-default scratch underlying overlay dirs, we need to check
38 # them explicity after test.
39 _require_scratch_nocheck
42 # Remove all files from previous tests
45 # Create multiple lowerdirs and upperdir, workdir
46 lowerdir1=$OVL_BASE_SCRATCH_MNT/lower1
47 lowerdir2=$OVL_BASE_SCRATCH_MNT/lower2
48 upperdir=$OVL_BASE_SCRATCH_MNT/upper
49 workdir=$OVL_BASE_SCRATCH_MNT/workdir
50 mkdir -p $lowerdir1 $lowerdir2 $upperdir $workdir
52 # Mount overlay with lower layers only.
53 # Verify that overlay is mounted read-only and that it cannot be remounted rw.
54 $MOUNT_PROG -t overlay -o"lowerdir=$lowerdir2:$lowerdir1" \
55 $OVL_BASE_SCRATCH_MNT $SCRATCH_MNT
56 touch $SCRATCH_MNT/foo 2>&1 | _filter_scratch
57 $MOUNT_PROG -o remount,rw $SCRATCH_MNT 2>&1 | _filter_ro_mount
58 $UMOUNT_PROG $SCRATCH_MNT
60 # Make workdir immutable to prevent workdir re-create on mount
61 $CHATTR_PROG +i $workdir
63 # Mount overlay with upper and workdir and expect failure to re-create workdir.
64 # Verify that overlay is mounted read-only and that it cannot be remounted rw.
65 _overlay_scratch_mount_dirs $lowerdir2 $upperdir $workdir
66 touch $SCRATCH_MNT/bar 2>&1 | _filter_scratch
67 _scratch_remount rw 2>&1 | _filter_ro_mount
70 _overlay_check_scratch_dirs $lowerdir2 $upperdir $workdir