Python Fuse 调用“readlink”连续6次
我正在使用 Python Fuse 实现一个文件系统。目录仅包含符号链接
,因此我返回S_IFLNK | 0777
getattr
方法。
现在,当我对目录执行 ls
操作时,我注意到 Linux 对目录中的每个 条目连续调用 readlink
方法 6 次。
这是我这边的错误还是正常行为?
I am implementing a filesystem using Python Fuse. A directory contains only symlinks
and as such I return S_IFLNK | 0777
on the getattr
method.
Now, when I do an ls
on the directory, I notice that Linux calls readlink
method 6 times in a row for each entry in the directory.
Is it a bug on my side or a normal behavior?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
嗯,这绝对不是 ls 多次调用 readlink 。除非你用不寻常的标志来调用它?
从这里的情况来看,没有标志的 ls 永远不会调用 readlink,并且如果给出了 long 标志,每个链接只会调用一次。我对fuse不太了解,更不用说pythonfuse了。不幸的是,我无法回答你最初的问题,只能说这看起来很像你这边的错误行为,但我可能是错的。
Well, it's definitely not ls calling readlink more than once. Unless you're calling it with unusual flags?
From the looks of things here ls with no flag never calls readlink, and will call it only once per link if the long flag is given. I don't know much about fuse, much less python fuse. So unfortunately, I can't answer your original question beyond saying that this looks very much like buggy behavior on your side but I could be wrong.
您在 getattr 中正确设置了 st_size 吗? ls 将首先尝试使用返回的 st_size 的缓冲区大小,并将其加倍,直到 readlink 缓冲区适合。
Did you set st_size properly in getattr? ls will first try with a buffer size of the returned st_size and double it until the the readlink buffer fits.