summaryrefslogtreecommitdiff
path: root/tests/btrfs/330
blob: 095f6b36a65ecc4200d9b3f89e0d8ed5627ccda1 (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
#! /bin/bash
# SPDX-License-Identifier: GPL-2.0
# Copyright (c) 2023 Meta Platforms, Inc.  All Rights Reserved.
#
# FS QA Test No. btrfs/330
#
# Test mounting one subvolume as ro and another as rw
#
. ./common/preamble
_begin_fstest auto quick subvol

_cleanup()
{
	rm -rf $TEST_DIR/$seq
}

# Import common functions.
. ./common/filter.btrfs

# real QA test starts here
_supported_fs btrfs
_require_scratch

$MOUNT_PROG -V | grep -q 'fd-based-mount'
[ "$?" -eq 0 ] && _notrun "mount uses the new mount api"

_scratch_mkfs >> $seqres.full 2>&1 || _fail "mkfs failed"
_scratch_mount

# Create our subvolumes to mount
$BTRFS_UTIL_PROG subvolume create $SCRATCH_MNT/foo | _filter_scratch
$BTRFS_UTIL_PROG subvolume create $SCRATCH_MNT/bar | _filter_scratch

_scratch_unmount

mkdir -p $TEST_DIR/$seq/foo
mkdir -p $TEST_DIR/$seq/bar

_mount -t btrfs -o subvol=foo,ro $SCRATCH_DEV $TEST_DIR/$seq/foo
_mount -t btrfs -o subvol=bar,rw $SCRATCH_DEV $TEST_DIR/$seq/bar

echo "making sure foo is read only"
touch $TEST_DIR/$seq/foo/baz > /dev/null 2&>1
ls $TEST_DIR/$seq/foo

echo "making sure bar allows writes"
touch $TEST_DIR/$seq/bar/qux
ls $TEST_DIR/$seq/bar

$UMOUNT_PROG $TEST_DIR/$seq/foo
$UMOUNT_PROG $TEST_DIR/$seq/bar

status=0 ; exit