mirror of https://git.musl-libc.org/git/musl
You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
31 lines
523 B
31 lines
523 B
|
15 years ago
|
#include <dirent.h>
|
||
|
|
#include <errno.h>
|
||
|
|
#include <stdlib.h>
|
||
|
|
#include <string.h>
|
||
|
|
#include "__dirent.h"
|
||
|
|
#include "libc.h"
|
||
|
|
|
||
|
|
int readdir_r(DIR *dir, struct dirent *buf, struct dirent **result)
|
||
|
|
{
|
||
|
|
struct dirent *de;
|
||
|
|
int errno_save = errno;
|
||
|
|
int ret;
|
||
|
|
|
||
|
|
LOCK(&dir->lock);
|
||
|
|
errno = 0;
|
||
|
|
de = readdir(dir);
|
||
|
|
if ((ret = errno)) {
|
||
|
|
UNLOCK(&dir->lock);
|
||
|
|
return ret;
|
||
|
|
}
|
||
|
|
errno = errno_save;
|
||
|
|
if (de) memcpy(buf, de, de->d_reclen);
|
||
|
|
else buf = NULL;
|
||
|
|
|
||
|
|
UNLOCK(&dir->lock);
|
||
|
|
*result = buf;
|
||
|
|
return 0;
|
||
|
|
}
|
||
|
|
|
||
|
|
LFS64_2(readdir_r, readdir64_r);
|