From f227573925902e9f3ed1e3c641089576308e382e Mon Sep 17 00:00:00 2001 From: jhb Date: Mon, 8 Sep 2014 14:45:58 +0000 Subject: MFC 271048: 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 Approved by: re (gjb) --- lib/libc/gen/rewinddir.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'lib') diff --git a/lib/libc/gen/rewinddir.c b/lib/libc/gen/rewinddir.c index 89e717c..193f4b0 100644 --- a/lib/libc/gen/rewinddir.c +++ b/lib/libc/gen/rewinddir.c @@ -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; } -- cgit v1.1