我在熔断器中实现
readdir()
功能时看到一个奇怪的问题。基本上,当我在 fusion 中的任何目录上执行 ls
时,我会收到如下错误:
#ls
ls: 读取目录.: 输入/输出错误
文件1.c 文件2.c
但奇怪的是,
readdir()
正在做它应该做的事情。从某种意义上说,在该特定目录中,我有两个名为 file1.c
和 file2.c
的文件,并且它能够正确读取它。
在调试问题时,我注意到 fusion
filler
函数(fuse_fill_dir_t
作为参数传递给 readdir()
)可能是导致此错误的原因。
这是因为如果我只是使用调试打印目录的内容
printf
而不使用填充函数返回内容,我不会看到错误。
但是一旦我开始使用填充函数返回内容,我就开始看到这个错误。
我有两个与此相关的问题:
1)有人知道为什么
filler
函数可能会导致这个问题吗?
2) 如何查找
fuse_fill_dir_t
函数的代码定义?我已经使用此类参数查看了大多数熔断函数,但到目前为止还没有运气。
如有任何帮助,我们将不胜感激!
干杯, 维奈
此类消息可能是由于调用其他(可能未实现的)FUSE 回调(如
getxattr()
)失败而引起的。然后调用 readdir()
并获得正确的结果。
您可以使用键
-d
(调试模式)调试运行其可执行文件的 FUSE 文件系统, - 它不会守护进程并打印有关 FUSE 调用的详细调试输出。
此外,最好知道您的平台是什么(Linux/OS X/等)。
我最近遇到了这个。请务必阅读
fuse.h
中的注释,以确保您正确使用填充函数:
/** Read directory
*
* The filesystem may choose between two modes of operation:
*
* 1) The readdir implementation ignores the offset parameter, and
* passes zero to the filler function's offset. The filler
* function will not return '1' (unless an error happens), so the
* whole directory is read in a single readdir operation.
*
* 2) The readdir implementation keeps track of the offsets of the
* directory entries. It uses the offset parameter and always
* passes non-zero offset to the filler function. When the buffer
* is full (or an error happens) the filler function will return
* '1'.
*
* When FUSE_READDIR_PLUS is not set, only some parameters of the
* fill function (the fuse_fill_dir_t parameter) are actually used:
* The file type (which is part of stat::st_mode) is used. And if
* fuse_config::use_ino is set, the inode (stat::st_ino) is also
* used. The other fields are ignored when FUSE_READDIR_PLUS is not
* set.
*/
int (*readdir) (const char *, void *, fuse_fill_dir_t, off_t,
struct fuse_file_info *, enum fuse_readdir_flags);