1 .\" Hey Emacs! This file is -*- nroff -*- source.
3 .\" Copyright (c) 2012, Mark R. Bannister <cambridge@users.sourceforge.net>
4 .\" based on text in mkfifoat.3 Copyright (c) 2006, Michael Kerrisk
6 .\" This is free documentation; you can redistribute it and/or
7 .\" modify it under the terms of the GNU General Public License as
8 .\" published by the Free Software Foundation; either version 2 of
9 .\" the License, or (at your option) any later version.
11 .\" The GNU General Public License's references to "object code"
12 .\" and "executables" are to be interpreted as the output of any
13 .\" document formatting or typesetting system, including
14 .\" intermediate and printed output.
16 .\" This manual is distributed in the hope that it will be useful,
17 .\" but WITHOUT ANY WARRANTY; without even the implied warranty of
18 .\" MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 .\" GNU General Public License for more details.
21 .\" You should have received a copy of the GNU General Public
22 .\" License along with this manual; if not, write to the Free
23 .\" Software Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111,
26 .TH SCANDIRAT 3 2012-03-17 "Linux" "Linux Programmer's Manual"
28 scandirat \- scan a directory relative to a directory file descriptor
31 .BR "#define _GNU_SOURCE" " /* See feature_test_macros(7) */"
33 .BR "#include <fcntl.h>" " /* Definition of AT_* constants */"
34 .B #include <dirent.h>
37 .BI "int scandirat(int " dirfd ", const char *" dirp ","
38 .BI "struct dirent ***" namelist ,
41 .BI "int (*" filter ")(const struct dirent *),"
42 .BI "int (*" compar ")(const struct dirent **, const struct dirent **));"
48 system call operates in exactly the same way as
50 except for the differences described in this manual page.
52 If the pathname given in
54 is relative, then it is interpreted relative to the directory
55 referred to by the file descriptor
57 (rather than relative to the current working directory of
58 the calling process, as is done by
60 for a relative pathname).
70 is interpreted relative to the current working
71 directory of the calling process (like
82 returns the number of directory entries selected.
83 On error, \-1 is returned and
85 is set to indicate the error.
87 The same errors that occur for
91 The following additional errors can occur for
96 is not a valid file descriptor.
100 is a relative path and
102 is a file descriptor referring to a file other than a directory.
105 was added to glibc in version 2.15.
107 This function is a GNU extension.
111 for an explanation of the need for
116 .BR path_resolution (7)