-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathContainerfile.libfuse-remap
More file actions
103 lines (92 loc) · 3.53 KB
/
Containerfile.libfuse-remap
File metadata and controls
103 lines (92 loc) · 3.53 KB
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
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
# Test container for libfuse remap_file_range (FICLONE) support
#
# Build:
# podman build -t localhost/libfuse-remap-test -f Containerfile.libfuse-remap .
#
# Run with patched kernel:
# sudo fcvm podman run --name libfuse-test --network bridged --privileged \
# --kernel /mnt/fcvm-btrfs/kernels/vmlinux-6.12.10-*.bin \
# --map /mnt/fcvm-btrfs/test-libfuse:/data \
# localhost/libfuse-remap-test
FROM alpine:latest AS builder
RUN apk add --no-cache git meson ninja gcc g++ musl-dev linux-headers python3 eudev-dev
WORKDIR /build
RUN git clone --depth 1 -b remap-file-range https://github.com/ejc3/libfuse.git
WORKDIR /build/libfuse
# Build libfuse static library
RUN meson setup build --default-library=static -Dexamples=false -Dtests=false -Duseroot=false && \
ninja -C build
# Build passthrough_ll statically linked
RUN gcc -static -O2 -I/build/libfuse/include -I/build/libfuse/build \
-o /build/passthrough_ll /build/libfuse/example/passthrough_ll.c \
/build/libfuse/build/lib/libfuse3.a -lpthread
# Build ficlone_test
COPY fuse-pipe/tests/libfuse_remap/ficlone_test.c /build/
RUN gcc -static -O2 -o /build/ficlone_test /build/ficlone_test.c
# Final image
FROM alpine:latest
RUN apk add --no-cache fuse3 btrfs-progs e2fsprogs-extra
COPY --from=builder /build/passthrough_ll /usr/local/bin/
COPY --from=builder /build/ficlone_test /usr/local/bin/
# Create test script - tests both FICLONE and FICLONERANGE
RUN printf '#!/bin/sh\n\
set -e\n\
echo "=== libfuse remap_file_range test ==="\n\
echo ""\n\
echo "Creating btrfs loopback filesystem..."\n\
dd if=/dev/zero of=/tmp/btrfs.img bs=1M count=150 2>/dev/null\n\
mkfs.btrfs -q /tmp/btrfs.img\n\
mkdir -p /btrfs /fuse-mnt\n\
mount -o loop /tmp/btrfs.img /btrfs\n\
echo "Created btrfs filesystem"\n\
\n\
# Create test file (must be block-aligned for FICLONERANGE)\n\
dd if=/dev/urandom of=/btrfs/source.bin bs=4096 count=256 2>/dev/null\n\
echo "Created 1MB test file on btrfs (256 x 4KB blocks)"\n\
\n\
echo "Starting passthrough_ll on btrfs..."\n\
/usr/local/bin/passthrough_ll -d -o source=/btrfs /fuse-mnt 2>&1 &\n\
FUSE_PID=$!\n\
sleep 2\n\
if ! mountpoint -q /fuse-mnt; then echo "ERROR: FUSE mount failed"; kill $FUSE_PID 2>/dev/null; exit 1; fi\n\
\n\
echo ""\n\
echo "=== Test 1: FICLONE (whole file clone) ==="\n\
/usr/local/bin/ficlone_test /fuse-mnt/source.bin /fuse-mnt/dest1.bin\n\
RESULT1=$?\n\
\n\
echo ""\n\
echo "=== Test 2: FICLONERANGE (partial clone, offset=0, len=512KB) ==="\n\
/usr/local/bin/ficlone_test --range /fuse-mnt/source.bin /fuse-mnt/dest2.bin 0 524288\n\
RESULT2=$?\n\
\n\
echo ""\n\
echo "=== Test 3: FICLONERANGE (partial clone, offset=512KB, len=512KB) ==="\n\
/usr/local/bin/ficlone_test --range /fuse-mnt/source.bin /fuse-mnt/dest3.bin 524288 524288\n\
RESULT3=$?\n\
\n\
fusermount3 -u /fuse-mnt 2>/dev/null || true\n\
wait $FUSE_PID 2>/dev/null || true\n\
\n\
echo ""\n\
echo "=== Results ==="\n\
ls -la /btrfs/\n\
echo ""\n\
echo "Verifying shared extents with filefrag:"\n\
for f in source.bin dest1.bin dest2.bin dest3.bin; do\n\
echo "--- $f ---"\n\
filefrag -v /btrfs/$f 2>/dev/null | grep -E "^\\s+[0-9]+:|flags:" || true\n\
done\n\
\n\
umount /btrfs\n\
\n\
# All tests must pass\n\
if [ $RESULT1 -ne 0 ] || [ $RESULT2 -ne 0 ] || [ $RESULT3 -ne 0 ]; then\n\
echo "FAILED: FICLONE=$RESULT1 FICLONERANGE1=$RESULT2 FICLONERANGE2=$RESULT3"\n\
exit 1\n\
fi\n\
echo ""\n\
echo "SUCCESS: All FICLONE/FICLONERANGE tests passed!"\n\
exit 0\n' > /usr/local/bin/test-libfuse-remap.sh && \
chmod +x /usr/local/bin/test-libfuse-remap.sh
CMD ["/usr/local/bin/test-libfuse-remap.sh"]