[glib/glib-2-38] glocalfile: Only use O_DIRECTORY if available



commit 32c42dacc1bff28ed4018ff5585ba7fbf74782f3
Author: William Orr <will worrbase com>
Date:   Thu Sep 26 11:02:06 2013 -0700

    glocalfile: Only use O_DIRECTORY if available
    
    Solaris 10 for example doesn't have it.
    
    https://bugzilla.gnome.org/show_bug.cgi?id=708860

 configure.ac     |   12 ++++++++++++
 gio/glocalfile.c |    6 +++++-
 2 files changed, 17 insertions(+), 1 deletions(-)
---
diff --git a/configure.ac b/configure.ac
index 797cb92..dc7d0bb 100644
--- a/configure.ac
+++ b/configure.ac
@@ -1225,6 +1225,18 @@ AS_IF([test "$ac_cv_func_statfs" = yes], [
       AC_MSG_ERROR([unable to determine number of arguments to statfs()])])])
 ])
 
+dnl
+dnl open takes O_DIRECTORY as an option
+dnl
+AC_MSG_CHECKING([open() option O_DIRECTORY])
+AC_TRY_COMPILE([#include <fcntl.h>
+#include <sys/types.h>
+#include <sys/stat.h>],
+[open(0, O_DIRECTORY, 0);],[
+       AC_MSG_RESULT([yes])
+       AC_DEFINE(HAVE_OPEN_O_DIRECTORY, 1, [open option O_DIRECTORY])],[
+       AC_MSG_RESULT([no])])
+
 #
 # Check whether to use an included printf
 #
diff --git a/gio/glocalfile.c b/gio/glocalfile.c
index 345214d..3763a46 100644
--- a/gio/glocalfile.c
+++ b/gio/glocalfile.c
@@ -2699,7 +2699,11 @@ g_local_file_measure_size_of_file (gint           parent_fd,
         return FALSE;
 
 #ifdef AT_FDCWD
-      dir_fd = openat (parent_fd, name->data, O_RDONLY | O_DIRECTORY);
+#ifdef HAVE_OPEN_O_DIRECTORY
+      dir_fd = openat (parent_fd, name->data, O_RDONLY|O_DIRECTORY);
+#else
+      dir_fd = openat (parent_fd, name->data, O_RDONLY);
+#endif
       if (dir_fd < 0)
         return g_local_file_measure_size_error (state->flags, errno, name, error);
 #endif


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]