Skip to content

Commit 4dd7815

Browse files
committed
[rfuse3]: update offset comparison in minimal filesystem example and improve test cleanup
- Changed the offset comparison in the minimal filesystem example to use u64 for consistency. - Enhanced the test script to use a more reliable method for checking if the mount point is active and added a cleanup trap for better resource management. Signed-off-by: LangQi99 <[email protected]>
1 parent 54fdc83 commit 4dd7815

File tree

2 files changed

+5
-9
lines changed

2 files changed

+5
-9
lines changed

project/rfuse3/examples/minimal_filesystem_example.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -225,7 +225,7 @@ impl Filesystem for MinimalFileSystem {
225225

226226
let filtered: Vec<_> = entries
227227
.into_iter()
228-
.filter(|entry| entry.offset > offset as i64)
228+
.filter(|entry| (entry.offset as u64) > offset)
229229
.map(Ok)
230230
.collect();
231231

project/rfuse3/tests/minimal_filesystem_test.sh

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ CRATE_DIR=$(cd "$SCRIPT_DIR/.." && pwd)
1111
echo "Testing minimal filesystem example..."
1212

1313
# Clean up any existing mount point
14-
if mountpoint -q "$MOUNTPOINT" 2>/dev/null; then
14+
if mount | grep -q " on $MOUNTPOINT "; then
1515
echo "Unmounting existing mount point..."
1616
umount "$MOUNTPOINT" || true
1717
fi
@@ -28,6 +28,9 @@ echo "Starting filesystem at $MOUNTPOINT..."
2828
cargo run --example minimal_filesystem_example -- --mountpoint "$MOUNTPOINT" &
2929
FS_PID=$!
3030

31+
# Set up cleanup trap
32+
trap "kill $FS_PID 2>/dev/null || true; umount $MOUNTPOINT 2>/dev/null || true; rmdir $MOUNTPOINT 2>/dev/null || true" EXIT
33+
3134
# Wait for filesystem to be ready
3235
sleep 2
3336

@@ -43,11 +46,4 @@ cat "$MOUNTPOINT/hello.txt"
4346
echo "Testing file statistics..."
4447
stat "$MOUNTPOINT"
4548

46-
# Clean up
47-
echo "Cleaning up..."
48-
kill $FS_PID 2>/dev/null || true
49-
sleep 1
50-
umount "$MOUNTPOINT" 2>/dev/null || true
51-
rmdir "$MOUNTPOINT" 2>/dev/null || true
52-
5349
echo "Test completed successfully!"

0 commit comments

Comments
 (0)