From ab490047099069aadbb0c30d7765d4dd00318b85 Mon Sep 17 00:00:00 2001 From: Carmelo Amoroso Date: Mon, 6 Oct 2008 15:04:46 +0000 Subject: Fix scandir function to reset the errno when the selector returns zero(no entries) modifying the errno. The attached test case implements a dummy filter that returns alway no entries, but change the errno. scandir is not expected to fail, just returning 0 entries. Signed-off-by: Filippo Arcidiacono Signed-off-by: Giuseppe Cavallaro Signed-off-by: Carmelo Amoroso --- test/misc/tst-scandir.c | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) create mode 100644 test/misc/tst-scandir.c (limited to 'test/misc') diff --git a/test/misc/tst-scandir.c b/test/misc/tst-scandir.c new file mode 100644 index 000000000..6e4646142 --- /dev/null +++ b/test/misc/tst-scandir.c @@ -0,0 +1,21 @@ +#include +#include + +int skip_all(const struct dirent *dirbuf) +{ + __set_errno(EBADF); + return 0; +} + +int main() +{ + struct dirent **namelist; + int n; + + n = scandir(".", &namelist, skip_all, 0); + if (n < 0) { + perror("scandir"); + return 1; + } + return 0; +} -- cgit v1.2.3