[linux-cifs-client] readdir and filldir callback

tvrtko.ursulin at sophos.com tvrtko.ursulin at sophos.com
Thu Mar 1 11:24:23 GMT 2007


I've sent the email below on linux fs-devel yesterday hoping for some 
clarification on the subject. Since CIFS seems to have "the most 
complicated" implementation of it, maybe someone here could shred some 
light on how is this API designed to work?

--------------------------

Hi guys,

I am looking at different implementations of readir functions across 
various filesystems and I think it isn't obvious how should the filldir_t 
callback return code be handled.

Here is what I found how different filesystems will handle it:

- some will abort reading on any non-zero return code and return zero from 
readdir (ext2, ext3, minix, jfs) - this is what I thought should happen

- others seem to abort only on negative return codes but still return zero 
to vfs_readdir (nfs, reiserfs)
        - what will reiserfs do if filldir returns a positive value? 
continue filling?

- smbfs:
        - will check for negative values for . and .. and return zero then
        - for other dentries check for any non-zero and return zero

- and then there are even stranger ones like cifs who will do one thing 
for . and .. :
        - check for negative return value, return -ENOMEM
- and a different thing for other dentries:
        - abort on non-zero, return exactly the same value (including 
positive), except if it is -EOVERFLOW when it will return zero

So either I am totally confused and completely misinterpreting what the 
code says or there is something really strange going on? Are filesystems 
making different assumptions about the filldir_t callback? 

What is the right thing to do?


Thanks,

Tvrtko


Sophos Plc, The Pentagon, Abingdon Science Park, Abingdon,
OX14 3YP, United Kingdom.

Company Reg No 2096520. VAT Reg No GB 348 3873 20.



More information about the linux-cifs-client mailing list