projects
/
oweals
/
musl.git
/ blob
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
history
|
raw
|
HEAD
implement hcreate_r, hdestroy_r and hsearch_r
[oweals/musl.git]
/
src
/
dirent
/
readdir_r.c
1
#include <dirent.h>
2
#include <errno.h>
3
#include <string.h>
4
#include "__dirent.h"
5
#include "libc.h"
6
7
int readdir_r(DIR *restrict dir, struct dirent *restrict buf, struct dirent **restrict result)
8
{
9
struct dirent *de;
10
int errno_save = errno;
11
int ret;
12
13
LOCK(dir->lock);
14
errno = 0;
15
de = readdir(dir);
16
if ((ret = errno)) {
17
UNLOCK(dir->lock);
18
return ret;
19
}
20
errno = errno_save;
21
if (de) memcpy(buf, de, de->d_reclen);
22
else buf = NULL;
23
24
UNLOCK(dir->lock);
25
*result = buf;
26
return 0;
27
}
28
29
LFS64_2(readdir_r, readdir64_r);