]> CyberLeo.Net >> Repos - FreeBSD/stable/10.git/commit
MFC 268531,269079,269204:
authorjhb <jhb@ccf9f872-aa2e-dd11-9fc8-001c23d0bc1f>
Thu, 14 Aug 2014 20:20:21 +0000 (20:20 +0000)
committerjhb <jhb@ccf9f872-aa2e-dd11-9fc8-001c23d0bc1f>
Thu, 14 Aug 2014 20:20:21 +0000 (20:20 +0000)
commit306bc621460e5ef39ae86babd31befdf40eaf9c1
treec73c3e046f6b2412b005899914d466e00f3774a2
parent831e76d2a9c6f21d78aa6b7597b63d04c29c76fc
MFC 268531,269079,269204:
Fix various edge cases with rewinddir(), seekdir(), and telldir():
- In the unionfs case, opendir() and fdopendir() read the directory's full
  contents and cache it.  This cache is not refreshed when rewinddir() is
  called, so rewinddir() will not notice updates to a directory.  Fix this
  by splitting the code to fetch a directory's contents out of
  __opendir_common() into a new _filldir() function and call this from
  rewinddir() when operating on a unionfs directory.
- If rewinddir() is called on a directory opened with fdopendir() before
  any directory entries are fetched, rewinddir() will not adjust the seek
  location of the backing file descriptor.  If the file descriptor passed
  to fdopendir() had a non-zero offset, the rewinddir() will not rewind to
  the beginning.  Fix this by always seeking back to 0 in rewinddir().
  This means the dd_rewind hack can also be removed.
- Add missing locking to rewinddir()
- POSIX says that passing a location returned by telldir() to seekdir()
  after an intervening call to rewinddir() is undefined, so reclaim any
  pending telldir() cookies in the directory when rewinddir() is called.
- 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

git-svn-id: svn://svn.freebsd.org/base/stable/10@270002 ccf9f872-aa2e-dd11-9fc8-001c23d0bc1f
include/dirent.h
lib/libc/gen/directory.3
lib/libc/gen/gen-private.h
lib/libc/gen/opendir.c
lib/libc/gen/readdir.c
lib/libc/gen/rewinddir.c
lib/libc/gen/telldir.c
lib/libc/gen/telldir.h