.\" Copyright (c) 2012, Mark R. Bannister .\" based on text in mkfifoat.3 Copyright (c) 2006, Michael Kerrisk .\" .\" %%%LICENSE_START(GPLv2+_DOC_FULL) .\" This is free documentation; you can redistribute it and/or .\" modify it under the terms of the GNU General Public License as .\" published by the Free Software Foundation; either version 2 of .\" the License, or (at your option) any later version. .\" .\" The GNU General Public License's references to "object code" .\" and "executables" are to be interpreted as the output of any .\" document formatting or typesetting system, including .\" intermediate and printed output. .\" .\" This manual is distributed in the hope that it will be useful, .\" but WITHOUT ANY WARRANTY; without even the implied warranty of .\" MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the .\" GNU General Public License for more details. .\" .\" You should have received a copy of the GNU General Public .\" License along with this manual; if not, see .\" . .\" %%%LICENSE_END .\" .TH SCANDIRAT 3 2012-03-17 "Linux" "Linux Programmer's Manual" .SH NAME scandirat \- scan a directory relative to a directory file descriptor .SH SYNOPSIS .nf .BR "#define _GNU_SOURCE" " /* See feature_test_macros(7) */" .BR "#include " " /* Definition of AT_* constants */" .B #include .sp .fi .BI "int scandirat(int " dirfd ", const char *" dirp "," .BI "struct dirent ***" namelist , .nf .RS .BI "int (*" filter ")(const struct dirent *)," .BI "int (*" compar ")(const struct dirent **, const struct dirent **));" .RE .fi .SH DESCRIPTION The .BR scandirat () system call operates in exactly the same way as .BR scandir (3), except for the differences described in this manual page. If the pathname given in .I dirp is relative, then it is interpreted relative to the directory referred to by the file descriptor .I dirfd (rather than relative to the current working directory of the calling process, as is done by .BR scandir (3) for a relative pathname). If .I dirp is relative and .I dirfd is the special value .BR AT_FDCWD , then .I dirp is interpreted relative to the current working directory of the calling process (like .BR scandir (3)). If .I dirp is absolute, then .I dirfd is ignored. .SH RETURN VALUE On success, .BR scandirat () returns the number of directory entries selected. On error, \-1 is returned and .I errno is set to indicate the error. .SH ERRORS The same errors that occur for .BR scandir (3) can also occur for .BR scandirat (). The following additional errors can occur for .BR scandirat (): .TP .B EBADF .I dirfd is not a valid file descriptor. .TP .B ENOTDIR .I dirp is a relative path and .I dirfd is a file descriptor referring to a file other than a directory. .SH VERSIONS .BR scandirat () was added to glibc in version 2.15. .SH CONFORMING TO This function is a GNU extension. .SH NOTES See .BR openat (2) for an explanation of the need for .BR scandirat (). .SH SEE ALSO .BR openat (2), .BR scandir (3), .BR path_resolution (7)