1SCANDIRAT(3)               Linux Programmer's Manual              SCANDIRAT(3)
2
3
4

NAME

6       scandirat - scan a directory relative to a directory file descriptor
7

SYNOPSIS

9       #define _GNU_SOURCE         /* See feature_test_macros(7) */
10
11       #include <fcntl.h>          /* Definition of AT_* constants */
12       #include <dirent.h>
13
14       int scandirat(int dirfd, const char *dirp, struct dirent ***namelist,
15              int (*filter)(const struct dirent *),
16              int (*compar)(const struct dirent **, const struct dirent **));
17

DESCRIPTION

19       The  scandirat()  system call operates in exactly the same way as scan‐
20       dir(3), except for the differences described in this manual page.
21
22       If the pathname given in dirp is relative, then it is interpreted rela‐
23       tive  to the directory referred to by the file descriptor dirfd (rather
24       than relative to the current working directory of the calling  process,
25       as is done by scandir(3) for a relative pathname).
26
27       If  dirp is relative and dirfd is the special value AT_FDCWD, then dirp
28       is interpreted relative to the current working directory of the calling
29       process (like scandir(3)).
30
31       If dirp is absolute, then dirfd is ignored.
32

RETURN VALUE

34       On  success,  scandirat()  returns  the  number  of  directory  entries
35       selected.  On error, -1 is returned and errno is set  to  indicate  the
36       error.
37

ERRORS

39       The  same  errors  that occur for scandir(3) can also occur for scandi‐
40       rat().  The following additional errors can occur for scandirat():
41
42       EBADF  dirfd is not a valid file descriptor.
43
44       ENOTDIR
45              dirp is a relative path and dirfd is a file descriptor referring
46              to a file other than a directory.
47

VERSIONS

49       scandirat() was added to glibc in version 2.15.
50

CONFORMING TO

52       This function is a GNU extension.
53

NOTES

55       See openat(2) for an explanation of the need for scandirat().
56

SEE ALSO

58       openat(2), scandir(3), path_resolution(7)
59

COLOPHON

61       This  page  is  part of release 3.53 of the Linux man-pages project.  A
62       description of the project, and information about reporting  bugs,  can
63       be found at http://www.kernel.org/doc/man-pages/.
64
65
66
67Linux                             2012-03-17                      SCANDIRAT(3)
Impressum