summaryrefslogtreecommitdiffstats
path: root/cpukit/libcsupport/src/readdir_r.c
blob: 0347f25d8b2d36f8e9d8ca49ca3b68c38161db8c (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
/**
 *  @file
 *
 *  @brief Read a Directory
 *  @ingroup libcsupport
 */

#if HAVE_CONFIG_H
#include "config.h"
#endif

#ifndef HAVE_READDIR_R

#include <sys/types.h>
#include <dirent.h>
#include <errno.h>
#include <stdio.h>

/**
 *  The RTEMS version of readdir is already thread-safe.
 *  This routine is reentrant version of readdir().
 */
int readdir_r(
  DIR *__restrict dirp,
  struct dirent *__restrict entry,
  struct dirent **__restrict result
)
{
     *result = readdir(dirp);
     if (*result)
         *entry = **result;
     return *result ? 0 : errno;
}

#endif