info for discussion of syscall getdents() kern/117010
samflanker at gmail.com
Mon Feb 25 09:02:01 UTC 2008
links to similar problems:
> 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:
> 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
> the "offset", but counted in records out of which some were already
> - 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.
More information about the freebsd-emulation