about summary refs log tree commit diff
path: root/sysdeps/unix/opendir.c
diff options
context:
space:
mode:
Diffstat (limited to 'sysdeps/unix/opendir.c')
-rw-r--r--sysdeps/unix/opendir.c12
1 files changed, 8 insertions, 4 deletions
diff --git a/sysdeps/unix/opendir.c b/sysdeps/unix/opendir.c
index 461f82bc97..927caab70f 100644
--- a/sysdeps/unix/opendir.c
+++ b/sysdeps/unix/opendir.c
@@ -120,11 +120,15 @@ __opendir (const char *name)
      O_DIRECTORY flag is honored by the kernel.  */
   if (__builtin_expect (__fxstat64 (_STAT_VER, fd, &statbuf), 0) < 0)
     goto lose;
-  if (o_directory_works <= 0
-      && __builtin_expect (! S_ISDIR (statbuf.st_mode), 0))
+#ifdef O_DIRECTORY
+  if (o_directory_works <= 0)
+#endif
     {
-      save_errno = ENOTDIR;
-      goto lose;
+      if (__builtin_expect (! S_ISDIR (statbuf.st_mode), 0))
+	{
+	  save_errno = ENOTDIR;
+	  goto lose;
+	}
     }
 
   if (__builtin_expect (__fcntl (fd, F_SETFD, FD_CLOEXEC), 0) < 0)