Skip to content

Commit c75b2f2

Browse files
committed
btrfs-progs: convert-tests: add a test case to verify large symbolic link handling
The new test case will: - Create a symbolic which contains a 4095 bytes sized target on ext4 - Convert the ext4 to btrfs - Make sure we can still read the symbolic link For unpatched btrfs-convert, the resulted symbolic link will be rejected by kernel and fail. Signed-off-by: Qu Wenruo <[email protected]>
1 parent b1ccd69 commit c75b2f2

File tree

1 file changed

+27
-0
lines changed

1 file changed

+27
-0
lines changed
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
#!/bin/bash
2+
# Make sure btrfs-convert can handle a symbol link which is 4095 bytes large
3+
4+
source "$TEST_TOP/common" || exit
5+
source "$TEST_TOP/common.convert" || exit
6+
7+
setup_root_helper
8+
prepare_test_dev 1G
9+
check_global_prereq mkfs.ext4
10+
11+
# This is at the symbolic link size limit (PATH_MAX includes the terminating NUL).
12+
link_target=$(printf "%0.sb" {1..4095})
13+
14+
convert_test_prep_fs ext4 mke2fs -t ext4 -b 4096
15+
run_check $SUDO_HELPER ln -s "$link_target" "$TEST_MNT/symbol_link"
16+
run_check_umount_test_dev
17+
18+
# For unpatched btrfs-convert, it will always append one byte to the
19+
# link target, causing above 4095 target to be 4096, exactly one sector,
20+
# resulting a regular file extent.
21+
convert_test_do_convert
22+
23+
run_check_mount_test_dev
24+
# If the unpatched btrfs-convert created a regular extent, and the kernel is
25+
# newer enough, such readlink will be rejected by kernel.
26+
run_check $SUDO_HELPER readlink "$TEST_MNT/symbol_link"
27+
run_check_umount_test_dev

0 commit comments

Comments
 (0)