Python Fuse calling readlink 6 times in a row

I am using a file system using Python Fuse. The catalog contains only symlinksand as such I return S_IFLNK | 0777by the method getattr.

Now, when I do lsin the directory, I notice that Linux calls the method readlink6 times in a row for each entry in the directory.

Is this a mistake on my side or a normal behavior?

+3
source share
2 answers

Well, it definitely does not rewrite readlink more than once. If you do not call 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
$

ls readlink , . , . , , , , .

+2

st_size getattr? ls st_size , readlink.

+1

Source: https://habr.com/ru/post/1757820/


All Articles