]> git-server-git.apps.pok.os.sepia.ceph.com Git - xfstests-dev.git/commitdiff
fstests: Verify dir permissions when creating a stub subvolume
authorLee Trager <lee@trager.us>
Fri, 18 Aug 2023 08:11:56 +0000 (01:11 -0700)
committerZorro Lang <zlang@kernel.org>
Fri, 18 Aug 2023 19:36:22 +0000 (03:36 +0800)
btrfs supports creating nesting subvolumes however snapshots are not
recurive. When a snapshot is taken of a volume which contains a subvolume
the subvolume is replaced with a stub subvolume which has the same name and
uses inode number 2. This test validates that the stub volume copies
permissions of the original volume.

Signed-off-by: Lee Trager <lee@trager.us>
Reviewed-by: Zorro Lang <zlang@redhat.com>
Reviewed-by: Filipe Manana <fdmanana@suse.com>
Signed-off-by: Zorro Lang <zlang@kernel.org>
common/rc
tests/btrfs/300 [new file with mode: 0755]
tests/btrfs/300.out [new file with mode: 0644]
tests/overlay/020

index 66d270acf06938e169d82bff10f37043916e4552..7005f4bf623dd9e7ea993ba70b062af5a562ecb0 100644 (file)
--- a/common/rc
+++ b/common/rc
@@ -5224,6 +5224,11 @@ _soak_loop_running() {
        return 0
 }
 
+_require_unshare() {
+       unshare -f -r -m -p -U $@ true &>/dev/null || \
+               _notrun "unshare: command not found, should be in util-linux"
+}
+
 init_rc
 
 ################################################################################
diff --git a/tests/btrfs/300 b/tests/btrfs/300
new file mode 100755 (executable)
index 0000000..d372250
--- /dev/null
@@ -0,0 +1,52 @@
+#!/bin/bash
+# SPDX-License-Identifier: GPL-2.0
+# Copyright (c) 2023 Meta Platforms, Inc.  All Rights Reserved.
+#
+# FS QA Test 300
+#
+# Validate that snapshots taken while in a remapped namespace preserve
+# the permissions of the user.
+#
+. ./common/preamble
+
+_begin_fstest auto quick subvol snapshot
+_register_cleanup "cleanup"
+
+_supported_fs btrfs
+_fixed_by_kernel_commit xxxxxxxxxxxx \
+       "btrfs: copy dir permission and time when creating a stub subvolume"
+
+_require_test
+_require_user
+_require_group
+_require_unix_perm_checking
+_require_unshare
+
+test_dir="${TEST_DIR}/${seq}"
+cleanup() {
+       rm -rf $test_dir
+       cd /
+       rm -rf $tmp.*
+}
+
+rm -rf $test_dir
+mkdir $test_dir
+chown $qa_user:$qa_group $test_dir
+
+# _user_do executes each command as $qa_user in its own subshell. unshare
+# sets the namespace for the running shell. The test must run in one user
+# subshell to preserve the namespace over multiple commands.
+_user_do "
+cd ${test_dir};
+unshare --user --keep-caps --map-auto --map-root-user;
+$BTRFS_UTIL_PROG subvolume create subvol;
+touch subvol/{1,2,3};
+$BTRFS_UTIL_PROG subvolume create subvol/subsubvol;
+touch subvol/subsubvol/{4,5,6};
+$BTRFS_UTIL_PROG subvolume snapshot subvol snapshot;
+"
+
+find $test_dir/. -printf "%M %u %g ./%P\n"
+
+status=0
+exit
diff --git a/tests/btrfs/300.out b/tests/btrfs/300.out
new file mode 100644 (file)
index 0000000..6e94447
--- /dev/null
@@ -0,0 +1,18 @@
+QA output created by 300
+Create subvolume './subvol'
+Create subvolume 'subvol/subsubvol'
+Create a snapshot of 'subvol' in './snapshot'
+drwxr-xr-x fsgqa fsgqa ./
+drwxr-xr-x fsgqa fsgqa ./subvol
+-rw-r--r-- fsgqa fsgqa ./subvol/1
+-rw-r--r-- fsgqa fsgqa ./subvol/2
+-rw-r--r-- fsgqa fsgqa ./subvol/3
+drwxr-xr-x fsgqa fsgqa ./subvol/subsubvol
+-rw-r--r-- fsgqa fsgqa ./subvol/subsubvol/4
+-rw-r--r-- fsgqa fsgqa ./subvol/subsubvol/5
+-rw-r--r-- fsgqa fsgqa ./subvol/subsubvol/6
+drwxr-xr-x fsgqa fsgqa ./snapshot
+-rw-r--r-- fsgqa fsgqa ./snapshot/1
+-rw-r--r-- fsgqa fsgqa ./snapshot/2
+-rw-r--r-- fsgqa fsgqa ./snapshot/3
+drwxr-xr-x fsgqa fsgqa ./snapshot/subsubvol
index 98a33aec23f7f27b19e16511fb541dc17a77cae4..9f82da344b8a793c0596d82ce757f4e34929623d 100755 (executable)
@@ -16,18 +16,13 @@ _begin_fstest auto quick copyup perms
 
 # real QA test starts here
 
-require_unshare() {
-       unshare -f -r "$@" true &>/dev/null || \
-               _notrun "unshare $@: not supported"
-}
-
 # Modify as appropriate.
 _supported_fs overlay
 _fixed_by_kernel_commit 3fe6e52f0626 \
        "ovl: override creds with the ones from the superblock mounter"
 
 _require_scratch
-require_unshare -m -p -U
+_require_unshare
 
 # Remove all files from previous tests
 _scratch_mkfs