我正在使用 libfuse 的低级 API 在 C++ 中实现用户空间文件系统,已实现以下功能:lookup、forget、getattr、setattr、mknod、read、write、opendir、readdir 和releasedir。
出于测试目的,我在初始化期间用一些文件填充根目录,并且我正在尝试写入/读取其中之一。写入成功,但读取时FUSE挂起。
这是输出:
unique: 302, opcode: LOOKUP (1), nodeid: 1, insize: 46, pid: 444120 <---- echo foo >cat mnt/foo
unique: 302, success, outsize: 144
unique: 304, opcode: OPEN (14), nodeid: 2, insize: 48, pid: 444120
unique: 304, success, outsize: 32
unique: 306, opcode: GETXATTR (22), nodeid: 2, insize: 68, pid: 444120
unique: 306, error: -38 (Function not implemented), outsize: 16
unique: 308, opcode: FLUSH (25), nodeid: 2, insize: 64, pid: 444120
unique: 308, error: -38 (Function not implemented), outsize: 16
unique: 310, opcode: WRITE (16), nodeid: 2, insize: 84, pid: 444120
unique: 310, success, outsize: 24
unique: 312, opcode: LOOKUP (1), nodeid: 1, insize: 46, pid: 477019 <---- cat mnt/foo
unique: 312, success, outsize: 144
unique: 314, opcode: OPEN (14), nodeid: 2, insize: 48, pid: 477019
unique: 314, success, outsize: 32
出于某种原因,我可以
cat
仍为空的文件,但是一旦我写入它们,FUSE就会挂起。我启用了单线程模式,但我很难调试它,因为 FUSE 在我的回调执行后挂起。
关于可能出现的问题有什么指示吗?
这是文件的统计信息
foo
:
File: mnt/foo
Size: 4 Blocks: 8 IO Block: 4096 regular file
Device: 59h/89d Inode: 2 Links: 1
Access: (0666/-rw-rw-rw-) Uid: ( 0/ root) Gid: ( 0/ root)
Access: 2023-10-24 21:04:25.000000000 -0100
Modify: 2023-10-24 21:04:25.000000000 -0100
Change: 2023-10-24 21:04:25.000000000 -0100
Birth: -
我忽略了
fuse_reply_err
调用的用法。成功时应该以 0
值调用它。
在
release
回调(或其他仅期望 fuse_reply_err
作为回复的回调)中错过此调用会导致熔断器挂起。