为什么 FUSE readdir 返回输入/输出错误?

发布于 2024-11-24 14:58:16 字数 728 浏览 0 评论 0原文

我在熔断器中实现 readdir() 功能时遇到一个奇怪的问题。基本上,当我在 fusion 中的任何目录上执行 ls 时,我会收到如下错误:

#ls
ls: 读取目录 .: 输入/输出错误
文件1.c 文件2.c

但奇怪的是,readdir() 正在做它应该做的事情。从某种意义上说,在该特定目录中,我有两个名为 file1.cfile2.c 的文件,并且它能够正确读取它。

在调试问题时,我注意到fuse filler 函数(fuse_fill_dir_t 作为参数传递给readdir() )可能是导致此错误的原因。

这是因为如果我只是使用调试 printf 打印目录的内容而不使用填充函数返回内容,我就不会看到错误。

但是,一旦我开始使用填充函数返回内容,我就开始看到此错误。

我有两个与此相关的问题:

1)有人知道为什么 filler 函数可能会导致此问题吗?

2) 如何查找fuse_fill_dir_t函数的代码定义?我已经使用此类参数查看了大多数熔断函数,但到目前为止还没有运气。

任何帮助表示赞赏!

干杯, 维奈

I am seeing a strange issue while implementing the readdir() functionality in fuse. Basically when I do ls on any directory in fuse, I get an error such as:

# ls
ls: reading directory .: Input/output error
file1.c file2.c

But the strange thing is, readdir() is doing exactly what it is supposed to do. In the sense that in that particular directory, I have two files named file1.c and file2.c and it is able to read it correctly.

While debugging the issue I noticed that fuse filler function (fuse_fill_dir_t passed as an argument to readdir() ) is what may be causing this error.

This is because if I simply print the contents of the directory using a debug printf without returning the contents using the filler function, I do not see the error.

But as soon as I start using the filler function to return the contents, I start seeing this error.

I have two questions related to this:

1) Anybody have any idea as to why the filler function might be causing this problem?

2) How do I look for the definition of the code for the fuse_fill_dir_t function? I have looked through most of the fuse functions with that kind of arguments but have had no luck until now.

Any help is appreciated!

Cheers,
Vinay

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

夏の忆 2024-12-01 14:58:16

此类消息可能是由于调用其他(可能未实现的)FUSE 回调(例如 getxattr())失败而引起的。然后调用readdir()并获得正确的结果。

您可以使用键 -d (调试模式)调试运行其可执行文件的 FUSE 文件系统,该文件系统不会守护进程并打印有关 FUSE 调用的详细调试输出。

另外,最好知道您的平台是什么(Linux/OS X/等)。

Such messages may be caused by failed calls to other (possibly unimplemented) FUSE callbacks like getxattr(). Then readdir() is called and results are obtained right.

You can debug a FUSE filesystem running its executable with key -d (debug mode), - that does not daemonize process and prints detailed debug output about FUSE calls.

Also, it would be nice to know what is your platform (Linux/OS X/etc).

口干舌燥 2024-12-01 14:58:16

我最近遇到了这个。请务必阅读 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);

I ran across this recently. Be sure to read the comments in fuse.h to ensure you are using the filler function correctly:

/** 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);
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文