Page MenuHomeFreeBSD

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

Authored by jhb on Jul 26 2014, 7:14 PM.
Tags
None
Referenced Files
Unknown Object (File)
Sep 29 2024, 1:16 PM
Unknown Object (File)
Sep 23 2024, 10:23 PM
Unknown Object (File)
Aug 16 2024, 12:21 AM
Unknown Object (File)
Aug 2 2024, 2:52 AM
Unknown Object (File)
Jul 28 2024, 5:22 PM
Unknown Object (File)
Jul 4 2024, 8:15 PM
Unknown Object (File)
Jul 2 2024, 5:45 AM
Unknown Object (File)
Jun 12 2024, 10:50 PM
Subscribers
None
Tokens
"Like" token, awarded by pfg.

Details

Reviewers
jilles
pfg
Summary

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

Repository
rS FreeBSD src repository - subversion
Lint
No Lint Coverage
Unit
No 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