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)
Sat, Mar 30, 2:18 AM
Unknown Object (File)
Feb 23 2024, 10:50 AM
Unknown Object (File)
Dec 19 2023, 11:46 PM
Unknown Object (File)
Dec 14 2023, 9:09 AM
Unknown Object (File)
Dec 1 2023, 7:07 PM
Unknown Object (File)
Nov 30 2023, 3:48 PM
Unknown Object (File)
Oct 26 2023, 11:46 AM
Unknown Object (File)
Oct 13 2023, 6:10 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