FreeBSD errors on new dir code

Jeremy Allison jra at samba.org
Tue Feb 1 01:08:39 GMT 2005


On Tue, Feb 01, 2005 at 11:52:28AM +1100, James Peach wrote:
> On Mon, Jan 31, 2005 at 10:57:17AM -0500, Green, Paul wrote:
> > Stratus VOS has the same restriction as FreeBSD on the value of seekdir()
> > and telldir(). They are valid for the lifetime of the directory stream
> > (dirp); once that directory stream is closed, you may (or may not) get a new
> > set of values from telldir().  That's all POSIX requires us to do....
> 
> IRIX has the same restriction. This will just happen to work if no-one
> changes the directory between the closedir and the opendir. But if some
> directory entries are removed and you end up trying to seek past the
> end of the directory, unusual things will happen ..
> 
>     ~/snippets [31] ./a.out testdir
>     telldir gave: 0
>     seeking to 4096
>     readdir failed: Error 0
>     telldir gave: 761360498
> 
> XFS also has a few different ways of storing directory entries, so
> if you racily re-open a changing directory, the order in which entries
> are returned could be different.

Try the code I just committed. I removed the dependance upon telldir
returns being the same between directory opens. There is still a
dependence if more than 256 directories are open simultaneously (the
underlying logic will close the oldest, and if it's reused it will
try and seek to the same offset) but this logic has been in Samba
for many many years and no one noticed :-).

Jeremy.


More information about the samba-technical mailing list