r13263: Check whether open(2) will accept the O_DIRECT flag. This should fix the
authorJames Peach <jpeach@samba.org>
Tue, 31 Jan 2006 21:56:12 +0000 (21:56 +0000)
committerGerald (Jerry) Carter <jerry@samba.org>
Wed, 10 Oct 2007 18:51:39 +0000 (13:51 -0500)
build on NetBSD.
(This used to be commit 7354de62a7fbf3921dfcb0bd865e89bdf1ef5bcd)

source4/build/m4/rewrite.m4
source4/client/cifsddio.c

index f0279c69d067c7f99fcb263b666fadeb02f07693..cd3937135444218b1c7f73866f33861aec429472 100644 (file)
@@ -496,6 +496,18 @@ fi
 ;;
 esac
 
+AC_CACHE_CHECK([for O_DIRECT flag to open(2)],samba_cv_HAVE_OPEN_O_DIRECT,[
+AC_TRY_COMPILE([
+#include <unistd.h>
+#ifdef HAVE_FCNTL_H
+#include <fcntl.h>
+#endif],
+[int fd = open("/dev/null", O_DIRECT);],
+samba_cv_HAVE_OPEN_O_DIRECT=yes,samba_cv_HAVE_OPEN_O_DIRECT=no)])
+if test x"$samba_cv_HAVE_OPEN_O_DIRECT" = x"yes"; then
+    AC_DEFINE(HAVE_OPEN_O_DIRECT,1,[Whether the open(2) accepts O_DIRECT])
+fi 
+
 ###############################################
 # test for where we get crypt() from
 AC_CHECK_LIB_EXT(crypt, CRYPT_LIBS, crypt)
index 51528406bf4ceacc9282e24cfff68cebab40ec29..b13cf3fd08c6f6319f405fe9b3894087bd1c8669 100644 (file)
@@ -99,8 +99,13 @@ open_fd_handle(const char * path, uint64_t iosz, int options)
        fdh->h.io_write = fd_write_func;
        fdh->h.io_seek = fd_seek_func;
 
-       if (options & DD_DIRECT_IO)
+       if (options & DD_DIRECT_IO) {
+#ifdef HAVE_OPEN_O_DIRECT
                oflags |= O_DIRECT;
+#else
+               DEBUG(1, ("no support for direct IO on this platform\n"));
+#endif
+       }
 
        if (options & DD_SYNC_IO)
                oflags |= O_SYNC;