info for discussion of syscall getdents() kern/117010

sam samflanker at gmail.com
Mon Feb 25 09:02:01 UTC 2008


hi all

links to similar problems:
http://mail-index.netbsd.org/current-users/2005/11/13/0011.html

 >  bug (+fix) in getdents + readdir
 >  o We're not sure what the Linux kernel intended to place in this field,
 >    but our experience shows that on "real" file systems (that actually
 >    reside on some disk) the offset seems to be a simple (not necessarily
 >    continuous) counter: e.g. first entry may have d_off=1, second: 
d_off=2,
 >    third: d_off=4096, fourth=d_off=4097 etc. We conjecture this is the
 >    serial of the dirent record within the directory (and so, this is 
indeed
 >    the "offset", but counted in records out of which some were already
 >    removed).


 > - In such an "overflow" situation, getdents() tries to lseek (the
 >  directory-fd) to the end of the last-legal-dirent that getdents()
 >  has successfully read.
 >  This offset is supposedly held by the local variable `last_offset'.
 >  But, since `last_offset' is assigned with `d_off' on each iteration,
 >  and since as mentioned above `d_off' usually holds an incorrect value,
 >  the lseek is not performed to the correct place.
 >  getdents() then returns the number of bytes successfully read.


http://sources.redhat.com/ml/libc-alpha/2004-02/msg00013.html

/Vladimir Ermakov



More information about the freebsd-emulation mailing list