summaryrefslogtreecommitdiff
path: root/benchmarks/blogbench/patches/patch-ad
blob: 11cf2a720eeec8727ff66661192aa71e5a13d387 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
$NetBSD: patch-ad,v 1.2 2006/10/22 04:36:12 rillig Exp $

--- src/helpers.c.orig	2005-02-11 15:46:26.000000000 +0100
+++ src/helpers.c	2006-10-22 06:33:08.000000000 +0200
@@ -48,9 +48,20 @@ int create_dummy_file(const char * const
     size_t towrite;
     ssize_t written;    
     int fd;
-    
-    if ((fd = open(file_name, O_CREAT | O_TRUNC | O_WRONLY,
-		   (mode_t) 0600)) == -1) {
+    mode_t m;
+
+#if defined(O_DIRECT)
+    m = O_CREAT|O_TRUNC|O_WRONLY|(do_directio ? O_DIRECT : 0);
+#else
+    if (do_directio) {
+	reentrant_printf("open: O_DIRECT is not supported on this system.\n");
+	return -1;
+    }
+    m = O_CREAT|O_TRUNC|O_WRONLY;
+#endif
+
+    fd = open(file_name, m, (mode_t)0600);
+    if (fd == -1) {
 	if (errno != ENOENT) {	    
 	    reentrant_printf("open(\"%s\"): %s\n",
 			     file_name, strerror(errno));