From e587f14b6f60bbf702a1a13c4399446d9654b708 Mon Sep 17 00:00:00 2001 From: Yaakov Selkowitz Date: Wed, 22 Feb 2012 01:58:24 +0000 Subject: [PATCH] * cygwin.din (scandirat): Export. * posix.sgml (std-gnu): Add scandirat. * syscalls.cc (scandirat): New function. * include/cygwin/version.h (CYGWIN_VERSION_API_MINOR): Bump. * include/sys/dirent.h (scandirat): Declare. --- winsup/cygwin/ChangeLog | 10 +++++++++- winsup/cygwin/cygwin.din | 1 + winsup/cygwin/include/cygwin/version.h | 3 ++- winsup/cygwin/include/sys/dirent.h | 6 +++++- winsup/cygwin/posix.sgml | 1 + winsup/cygwin/syscalls.cc | 16 ++++++++++++++++ 6 files changed, 34 insertions(+), 3 deletions(-) diff --git a/winsup/cygwin/ChangeLog b/winsup/cygwin/ChangeLog index b677e67d4..fc456da26 100644 --- a/winsup/cygwin/ChangeLog +++ b/winsup/cygwin/ChangeLog @@ -1,3 +1,11 @@ +2012-02-21 Yaakov Selkowitz + + * cygwin.din (scandirat): Export. + * posix.sgml (std-gnu): Add scandirat. + * syscalls.cc (scandirat): New function. + * include/cygwin/version.h (CYGWIN_VERSION_API_MINOR): Bump. + * include/sys/dirent.h (scandirat): Declare. + 2012-02-21 Corinna Vinschen Based on an idea from Nick Lowe : @@ -165,7 +173,7 @@ Explain how and why. * thread.h (PTHREAD_DEFAULT_STACKSIZE): Change definition. Explain why. -2012-02-12 Yaakov Selkowitz +2012-02-12 Yaakov Selkowitz * include/pthread.h: Include time.h as required by POSIX. diff --git a/winsup/cygwin/cygwin.din b/winsup/cygwin/cygwin.din index 3b99ed853..22b4ea94a 100644 --- a/winsup/cygwin/cygwin.din +++ b/winsup/cygwin/cygwin.din @@ -1406,6 +1406,7 @@ scalbnf NOSIGFE _scalbnf = scalbnf NOSIGFE scandir SIGFE _scandir = scandir SIGFE +scandirat SIGFE scanf SIGFE _scanf = scanf SIGFE scanf_r = _scanf_r SIGFE diff --git a/winsup/cygwin/include/cygwin/version.h b/winsup/cygwin/include/cygwin/version.h index 1d73f79d5..be5855843 100644 --- a/winsup/cygwin/include/cygwin/version.h +++ b/winsup/cygwin/include/cygwin/version.h @@ -428,12 +428,13 @@ details. */ 257: Export getpt. 258: Export get_current_dir_name. 259: Export pthread_sigqueue. + 260: Export scandirat. */ /* Note that we forgot to bump the api for ualarm, strtoll, strtoull */ #define CYGWIN_VERSION_API_MAJOR 0 -#define CYGWIN_VERSION_API_MINOR 259 +#define CYGWIN_VERSION_API_MINOR 260 /* There is also a compatibity version number associated with the shared memory regions. It is incremented when incompatible diff --git a/winsup/cygwin/include/sys/dirent.h b/winsup/cygwin/include/sys/dirent.h index 70a9e63b1..aabcd37e4 100644 --- a/winsup/cygwin/include/sys/dirent.h +++ b/winsup/cygwin/include/sys/dirent.h @@ -1,6 +1,6 @@ /* Posix dirent.h for WIN32. - Copyright 2001, 2002, 2003, 2005, 2006, 2007, 2010 Red Hat, Inc. + Copyright 2001, 2002, 2003, 2005, 2006, 2007, 2010, 2012 Red Hat, Inc. This software is a copyrighted work licensed under the terms of the Cygwin license. Please consult the file "CYGWIN_LICENSE" for @@ -69,6 +69,10 @@ int scandir (const char *__dir, int (*select) (const struct dirent *), int (*compar) (const struct dirent **, const struct dirent **)); +int scandirat (int __dirfd, const char *__dir, struct dirent ***__namelist, + int (*select) (const struct dirent *), + int (*compar) (const struct dirent **, const struct dirent **)); + int alphasort (const struct dirent **__a, const struct dirent **__b); #ifdef _DIRENT_HAVE_D_TYPE /* File types for `d_type'. */ diff --git a/winsup/cygwin/posix.sgml b/winsup/cygwin/posix.sgml index bba9f0704..5bb27d7c7 100644 --- a/winsup/cygwin/posix.sgml +++ b/winsup/cygwin/posix.sgml @@ -1136,6 +1136,7 @@ also IEEE Std 1003.1-2008 (POSIX.1-2008). pthread_sigqueue ptsname_r removexattr + scandirat setxattr strchrnul sysinfo diff --git a/winsup/cygwin/syscalls.cc b/winsup/cygwin/syscalls.cc index 8cdadb2d7..21037fa10 100644 --- a/winsup/cygwin/syscalls.cc +++ b/winsup/cygwin/syscalls.cc @@ -39,6 +39,7 @@ details. */ #include #include #include +#include #include "ntdll.h" #undef fstat @@ -4436,6 +4437,21 @@ renameat (int olddirfd, const char *oldpathname, return rename (oldpath, newpath); } +extern "C" int +scandirat (int dirfd, const char *pathname, struct dirent ***namelist, + int (*select) (const struct dirent *), + int (*compar) (const struct dirent **, const struct dirent **)) +{ + tmp_pathbuf tp; + myfault efault; + if (efault.faulted (EFAULT)) + return -1; + char *path = tp.c_get (); + if (gen_full_path_at (path, dirfd, pathname)) + return -1; + return scandir (pathname, namelist, select, compar); +} + extern "C" int symlinkat (const char *oldpath, int newdirfd, const char *newpathname) {