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
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
|
$NetBSD: patch-fsx.c,v 1.1 2016/11/06 16:12:08 wiz Exp $
Portability fixes for NetBSD.
--- fsx.c.orig 2016-11-06 16:10:25.886667703 +0000
+++ fsx.c
@@ -53,7 +53,9 @@
#include <sys/types.h>
#include <sys/stat.h>
#include <time.h>
+#ifdef __APPLE__
#include <sys/paths.h>
+#endif
#include <sys/param.h>
#ifdef _UWIN
# include <limits.h>
@@ -76,6 +78,9 @@
#ifdef XILOG
# include <XILog/XILog.h>
#endif
+#ifndef _PATH_FORKSPECIFIER
+#define _PATH_FORKSPECIFIER "/..namedfork/"
+#endif
/*
* A log entry is an operation and a bunch of arguments.
@@ -754,19 +759,27 @@ doread(unsigned offset, unsigned size)
failure(140);
}
+#ifdef F_NOCACHE
if (cache_off && (fcntl(fd, F_NOCACHE, 1) != 0)) { // turn data caching off
logdump();
prterr("doread: fcntl(F_NOCACHE, 1)");
failure(201);
}
+#endif
iret = read(fd, temp_buf, size);
+#ifdef F_NOCACHE
if (cache_off && (fcntl(fd, F_NOCACHE, 0) != 0)) {
logdump();
prterr("doread: fcntl(F_NOCACHE, 0)");
failure(201);
}
+#endif
} else {
+#ifdef __APPLE__
iret = fgetxattr(fd, eaname, temp_buf, size, 0, 0);
+#else
+ iret = fgetxattr(fd, eaname, temp_buf, size);
+#endif
}
if (iret != size) {
@@ -947,11 +960,13 @@ dowrite(unsigned offset, unsigned size)
prterr("dowrite: lseek");
failure(150);
}
+#ifdef F_NOCACHE
if (cache_off && (fcntl(fd, F_NOCACHE, 1) != 0)) { // turn data caching off
logdump();
prterr("dowrite: fcntl(F_NOCACHE, 1)");
failure(201);
}
+#endif
iret = write(fd, good_buf + file_size, offset - file_size);
if (iret != offset - file_size) {
logdump();
@@ -964,11 +979,13 @@ dowrite(unsigned offset, unsigned size)
}
failure(151);
}
+#ifdef F_NOCACHE
if (cache_off && (fcntl(fd, F_NOCACHE, 0) != 0)) {
logdump();
prterr("dowrite: fcntl(F_NOCACHE, 0)");
failure(201);
}
+#endif
}
}
file_size = offset + size;
@@ -994,11 +1011,13 @@ dowrite(unsigned offset, unsigned size)
prterr("dowrite: lseek");
failure(150);
}
+#ifdef F_NOCACHE
if (cache_off && (fcntl(fd, F_NOCACHE, 1) != 0)) { // turn data caching off
logdump();
prterr("dowrite: fcntl(F_NOCACHE, 1)");
failure(201);
}
+#endif
iret = write(fd, good_buf + offset, size);
if (iret != size) {
logdump();
@@ -1011,21 +1030,31 @@ dowrite(unsigned offset, unsigned size)
}
failure(151);
}
+#ifdef F_NOCACHE
if (cache_off && (fcntl(fd, F_NOCACHE, 0) != 0)) {
logdump();
prterr("dowrite: fcntl(F_NOCACHE, 0)");
failure(201);
}
+#endif
} else {
if (random() % 2000 == 0) {
+#ifdef __APPLE__
iret = fremovexattr(fd, eaname, 0);
+#else
+ iret = fremovexattr(fd, eaname);
+#endif
if (iret != 0) {
logdump();
prterr("ea_dowrite: removexattr");
failure(151);
}
}
+#ifdef __APPLE__
iret = fsetxattr(fd, eaname, good_buf, size, 0, 0);
+#else
+ iret = fsetxattr(fd, eaname, good_buf, size, 0);
+#endif
ea_lastwrite = size;
if (iret != 0) {
logdump();
@@ -1101,7 +1130,7 @@ domapwrite(unsigned offset, unsigned siz
failure(202);
}
memcpy(p + pg_offset, good_buf + offset, size);
- if (msync(p, map_size, 0) != 0) {
+ if (msync(p, map_size, MS_SYNC) != 0) {
logdump();
prterr("domapwrite: msync");
failure(203);
|