Always seek back to the beginning of a regular directory, even if the

previous seek location was 0.  Without this, readdir() would see
dd_loc of zero and call getdirentries() which would start reading
entries at the current seek location of the directory ignoring the
first batch of entries.  Also, rewinddir() should always seek so that
it reads the directory from the beginning to get updated entries.

PR:		192935
Reported by:	iron@mail.ua
MFC after:	3 days
This commit is contained in:
John Baldwin 2014-09-03 19:01:34 +00:00
parent e527e84592
commit c3d1e48a6b

View File

@ -53,7 +53,7 @@ rewinddir(dirp)
_pthread_mutex_lock(&dirp->dd_lock);
if (dirp->dd_flags & __DTF_READALL)
_filldir(dirp, false);
else if (dirp->dd_seek != 0) {
else {
(void) lseek(dirp->dd_fd, 0, SEEK_SET);
dirp->dd_seek = 0;
}