Index: gen/gen-private.h =================================================================== --- gen/gen-private.h (revision 267610) +++ gen/gen-private.h (working copy) @@ -48,7 +48,6 @@ char *dd_buf; /* data buffer */ int dd_len; /* size of data buffer */ long dd_seek; /* magic cookie returned by getdirentries */ - long dd_rewind; /* magic cookie for rewinding */ int dd_flags; /* flags for readdir */ struct pthread_mutex *dd_lock; /* lock */ struct _telldir *dd_td; /* telldir position recording */ Index: gen/opendir.c =================================================================== --- gen/opendir.c (revision 267610) +++ gen/opendir.c (working copy) @@ -292,7 +292,7 @@ dirp->dd_buf = malloc(dirp->dd_len); if (dirp->dd_buf == NULL) goto fail; - dirp->dd_seek = 0; + dirp->dd_seek = lseek(fd, 0, SEEK_CUR); } dirp->dd_loc = 0; @@ -300,11 +300,6 @@ dirp->dd_flags = flags; dirp->dd_lock = NULL; - /* - * Set up seek point for rewinddir. - */ - dirp->dd_rewind = telldir(dirp); - return (dirp); fail: Index: gen/rewinddir.c =================================================================== --- gen/rewinddir.c (revision 267610) +++ gen/rewinddir.c (working copy) @@ -33,9 +33,14 @@ #include __FBSDID("$FreeBSD$"); +#include "namespace.h" #include #include +#include +#include +#include "un-namespace.h" +#include "libc_private.h" #include "gen-private.h" #include "telldir.h" @@ -44,6 +49,13 @@ DIR *dirp; { - _seekdir(dirp, dirp->dd_rewind); - dirp->dd_rewind = telldir(dirp); + if (__isthreaded) + _pthread_mutex_lock(&dirp->dd_lock); + if (dirp->dd_seek != 0) { + (void) lseek(dirp->dd_fd, 0, SEEK_SET); + dirp->dd_seek = 0; + } + dirp->dd_loc = 0; + if (__isthreaded) + _pthread_mutex_unlock(&dirp->dd_lock); }