X-Git-Url: https://git.gag.com/?a=blobdiff_plain;f=lib%2Fopendir.c;h=b77f54040efe78c3192cd592d1397976409a46a1;hb=92249085071a973e2c0621b0415b93d2e48bb00d;hp=de0ea5a24f60dffc793bd5683cac43ece299dbdb;hpb=d57728a6ca2413a7c564d8b7bb13d9e5a5a180f3;p=debian%2Fgzip
diff --git a/lib/opendir.c b/lib/opendir.c
index de0ea5a..b77f540 100644
--- a/lib/opendir.c
+++ b/lib/opendir.c
@@ -1,5 +1,5 @@
/* Start reading the entries of a directory.
- Copyright (C) 2006-2013 Free Software Foundation, Inc.
+ Copyright (C) 2006-2018 Free Software Foundation, Inc.
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
@@ -12,7 +12,7 @@
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
- along with this program. If not, see . */
+ along with this program. If not, see . */
#include
@@ -40,6 +40,11 @@
# include
#endif
+#ifdef __KLIBC__
+# include
+# include
+#endif
+
DIR *
opendir (const char *dir_name)
{
@@ -51,6 +56,22 @@ opendir (const char *dir_name)
if (dirp == NULL)
return NULL;
+# ifdef __KLIBC__
+ {
+ int fd = open (dir_name, O_RDONLY);
+ if (fd == -1 || _gl_register_dirp_fd (fd, dirp))
+ {
+ int saved_errno = errno;
+
+ close (fd);
+ closedir (dirp);
+
+ errno = saved_errno;
+
+ return NULL;
+ }
+ }
+# endif
#else
char dir_name_mask[MAX_PATH + 1 + 1 + 1];