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 _begin_fstest auto quick mount
15 # Override the default cleanup function.
19 $CHATTR_PROG -i $workdir
23 # Import common functions.
26 # real QA test starts here
28 # Use non-default scratch underlying overlay dirs, we need to check
29 # them explicity after test.
30 _require_scratch_nocheck
33 # Remove all files from previous tests
36 # Create multiple lowerdirs and upperdir, workdir
37 lowerdir1=$OVL_BASE_SCRATCH_MNT/lower1
38 lowerdir2=$OVL_BASE_SCRATCH_MNT/lower2
39 upperdir=$OVL_BASE_SCRATCH_MNT/upper
40 workdir=$OVL_BASE_SCRATCH_MNT/workdir
41 mkdir -p $lowerdir1 $lowerdir2 $upperdir $workdir
43 # Mount overlay with lower layers only.
44 # Verify that overlay is mounted read-only and that it cannot be remounted rw.
45 $MOUNT_PROG -t overlay -o"lowerdir=$lowerdir2:$lowerdir1" \
46 $OVL_BASE_SCRATCH_MNT $SCRATCH_MNT
47 touch $SCRATCH_MNT/foo 2>&1 | _filter_scratch
48 $MOUNT_PROG -o remount,rw $SCRATCH_MNT 2>&1 | _filter_ro_mount
49 $UMOUNT_PROG $SCRATCH_MNT
51 # Make workdir immutable to prevent workdir re-create on mount
52 $CHATTR_PROG +i $workdir
54 # Mount overlay with upper and workdir and expect failure to re-create workdir.
55 # Verify that overlay is mounted read-only and that it cannot be remounted rw.
56 _overlay_scratch_mount_dirs $lowerdir2 $upperdir $workdir
57 touch $SCRATCH_MNT/bar 2>&1 | _filter_scratch
58 _scratch_remount rw 2>&1 | _filter_ro_mount
61 _overlay_check_scratch_dirs $lowerdir2 $upperdir $workdir