1
0
mirror of https://sourceware.org/git/glibc.git synced 2025-07-29 11:41:21 +03:00

linux: Add __readdir_unlocked

And use it on readdir_r implementation.

Checked on i686-linux-gnu.
This commit is contained in:
Adhemerval Zanella
2020-04-14 17:22:29 -03:00
parent 4b962c9e85
commit 30d2e4a963
3 changed files with 30 additions and 67 deletions

View File

@ -23,15 +23,11 @@
/* Read a directory entry from DIRP. */
struct dirent *
__readdir (DIR *dirp)
__readdir_unlocked (DIR *dirp)
{
struct dirent *dp;
int saved_errno = errno;
#if IS_IN (libc)
__libc_lock_lock (dirp->lock);
#endif
do
{
size_t reclen;
@ -75,6 +71,18 @@ __readdir (DIR *dirp)
/* Skip deleted files. */
} while (dp->d_ino == 0);
return dp;
}
struct dirent *
__readdir (DIR *dirp)
{
struct dirent *dp;
#if IS_IN (libc)
__libc_lock_lock (dirp->lock);
#endif
dp = __readdir_unlocked (dirp);
#if IS_IN (libc)
__libc_lock_unlock (dirp->lock);
#endif