开发者

Python Fuse calling 'readlink' 6 times in a row

I am implementing a file开发者_如何学JAVAsystem 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?


Well, it's definitely not ls calling readlink more than once. Unless you're calling it with unusual flags?

$ls
entropy  share
$ls -l
total 0
lrwxrwxrwx 1 entropy users 14 Aug  8 14:26 entropy -> /home/entropy/
lrwxrwxrwx 1 entropy users 11 Aug  8 14:18 share -> /usr/share/
$ltrace ls 2>&1 | grep readlink
$ltrace ls -l 2>&1 | grep readlink
readlink(0xbfdbb6c0, 0x9549b90, 15, 0, 0xb75ceec8) = 14
readlink(0xbfdbb6c0, 0x954a148, 12, 0xbfdbb992, 0) = 11
$

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.


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.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜