Page MenuHomeFreeBSD

Fix seekdir() followed by an immediate telldir().

Authored by jhb on Jul 26 2014, 7:14 PM.



If telldir() is called immediately after a call to seekdir(), POSIX
requires the return value of telldir() to equal the value passed to
seekdir(). The current seekdir code with SINGLEUSE enabled breaks
this case as each call to telldir() allocates a new cookie. Instead,
remove the SINGLEUSE code and change telldir() to look for an existing
cookie for the directory's current location rather than always creating
a new cookie.

PR: 121656

Test Plan

Added a simple unit test that does:

l1 = telldir(d);
seekdir(d, l1);
l2 = telldir(d);

and verifies that l1 is equivalent to l2.

Note that we could dispense with the cookies entirely in the unionfs
case and just use dd_loc as the seek value instead.

Diff Detail

rS FreeBSD src repository - subversion
No Linters Available
No Unit Test Coverage

Event Timeline

jhb retitled this revision from to Fix seekdir() followed by an immediate telldir()..
jhb updated this object.
jhb edited the test plan for this revision. (Show Details)
jhb added reviewers: jilles, pfg.
jilles edited edge metadata.
This revision is now accepted and ready to land.Jul 27 2014, 9:01 AM