Skip to content

Commit bb1a79f

Browse files
committed
btrfs-progs: mkfs-tests: a new test case for --inode-flags
The simple test will create a layout like the following: rootdir |- file1 |- file2 |- subv/ << Regular subvolume | |- file3 |- nocow_subv/ << NODATACOW subvolume | |- file4 |- nocow_dir/ << NODATACOW directory | |- dir2 | | |- file5 | |- file6 |- nocow_file1 << NODATACOW file Any files under NODATACOW subvolume/directory should also be NODATACOW. The explicitly specified single file should also be NODATACOW. Signed-off-by: Qu Wenruo <[email protected]>
1 parent 4c45c11 commit bb1a79f

File tree

1 file changed

+55
-0
lines changed
  • tests/mkfs-tests/038-inode-flags

1 file changed

+55
-0
lines changed
Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
#!/bin/bash
2+
# Basic test for mkfs.btrfs --inode-flags --rootdir. Create a dataset and use it as
3+
# rootdir, then various inode-flags and verify the flag is properly set.
4+
5+
source "$TEST_TOP/common" || exit
6+
7+
check_prereq mkfs.btrfs
8+
check_prereq btrfs
9+
check_global_prereq lsattr
10+
11+
setup_root_helper
12+
prepare_test_dev
13+
14+
tmp=$(_mktemp_dir mkfs-rootdir)
15+
16+
write_file()
17+
{
18+
local path="$1"
19+
local size="$2"
20+
21+
run_check dd if=/dev/zero of="$path" bs="$size" count=1 status=noxfer > /dev/null 2>&1
22+
}
23+
24+
check_nodatacow()
25+
{
26+
local path="$1"
27+
28+
lsattr "$TEST_MNT"/"$path" | grep -q C || _fail "missing NODATACOW flag for $path"
29+
}
30+
31+
write_file "$tmp/file1" 64K
32+
write_file "$tmp/file2" 64K
33+
run_check mkdir -p "$tmp/subv" "$tmp/nocow_subv" "$tmp/nocow_dir/dir2"
34+
write_file "$tmp/subv/file3" 64K
35+
write_file "$tmp/nocow_subv/file4" 64K
36+
write_file "$tmp/nocow_dir/dir2/file5" 64K
37+
write_file "$tmp/nocow_dir/file6" 64K
38+
write_file "$tmp/nocow_file1" 64K
39+
40+
run_check_mkfs_test_dev --rootdir "$tmp" --inode-flags nodatacow:nocow_subv \
41+
--subvol nocow_subv --inode-flags nodatacow:nocow_dir \
42+
--inode-flags nodatacow:nocow_file1
43+
44+
run_check $SUDO_HELPER "$TOP/btrfs" check "$TEST_DEV"
45+
46+
run_check_mount_test_dev
47+
check_nodatacow "nocow_subv"
48+
check_nodatacow "nocow_subv/file4"
49+
check_nodatacow "nocow_dir"
50+
check_nodatacow "nocow_dir/file6"
51+
check_nodatacow "nocow_dir/dir2/file5"
52+
check_nodatacow "nocow_file1"
53+
run_check lsattr -R "$TEST_MNT"
54+
run_check_umount_test_dev
55+
run_check rm -rf -- "$tmp"

0 commit comments

Comments
 (0)