Skip to content

Commit 8ec81a8

Browse files
Jussi RäsänenMylesBorins
Jussi Räsänen
authored andcommitted
fs: add O_DSYNC
Backport-PR-URL: #15653 PR-URL: #15451 Fixes: #15425 Reviewed-By: Ben Noordhuis <[email protected]> Reviewed-By: James M Snell <[email protected]> Reviewed-By: Luigi Pinca <[email protected]> Reviewed-By: Colin Ihrig <[email protected]> Reviewed-By: Tobias Nießen <[email protected]>
1 parent 27c4efd commit 8ec81a8

File tree

3 files changed

+20
-2
lines changed

3 files changed

+20
-2
lines changed

doc/api/fs.md

+5
Original file line numberDiff line numberDiff line change
@@ -2869,6 +2869,11 @@ The following constants are meant for use with `fs.open()`.
28692869
<td><code>O_SYNC</code></td>
28702870
<td>Flag indicating that the file is opened for synchronous I/O.</td>
28712871
</tr>
2872+
<tr>
2873+
<td><code>O_DSYNC</code></td>
2874+
<td>Flag indicating that the file is opened for synchronous I/O
2875+
with write operations waiting for data integrity.</td>
2876+
</tr>
28722877
<tr>
28732878
<td><code>O_SYMLINK</code></td>
28742879
<td>Flag indicating to open the symbolic link itself rather than the

src/node_constants.cc

+5
Original file line numberDiff line numberDiff line change
@@ -1085,6 +1085,11 @@ void DefineSystemConstants(Local<Object> target) {
10851085
NODE_DEFINE_CONSTANT(target, O_SYNC);
10861086
#endif
10871087

1088+
#ifdef O_DSYNC
1089+
NODE_DEFINE_CONSTANT(target, O_DSYNC);
1090+
#endif
1091+
1092+
10881093
#ifdef O_SYMLINK
10891094
NODE_DEFINE_CONSTANT(target, O_SYMLINK);
10901095
#endif

test/parallel/test-fs-open-flags.js

+10-2
Original file line numberDiff line numberDiff line change
@@ -21,9 +21,8 @@
2121

2222
// Flags: --expose_internals
2323
'use strict';
24-
require('../common');
24+
const common = require('../common');
2525
const assert = require('assert');
26-
2726
const fs = require('fs');
2827

2928
const O_APPEND = fs.constants.O_APPEND || 0;
@@ -32,6 +31,7 @@ const O_EXCL = fs.constants.O_EXCL || 0;
3231
const O_RDONLY = fs.constants.O_RDONLY || 0;
3332
const O_RDWR = fs.constants.O_RDWR || 0;
3433
const O_SYNC = fs.constants.O_SYNC || 0;
34+
const O_DSYNC = fs.constants.O_DSYNC || 0;
3535
const O_TRUNC = fs.constants.O_TRUNC || 0;
3636
const O_WRONLY = fs.constants.O_WRONLY || 0;
3737

@@ -79,6 +79,14 @@ assert.throws(
7979
/^Error: Unknown file open flag: null$/
8080
);
8181

82+
if (common.isLinux === true) {
83+
const file = `${__dirname}/../fixtures/a.js`;
84+
85+
fs.open(file, O_DSYNC, common.mustCall(function(err, fd) {
86+
assert.ifError(err);
87+
}));
88+
}
89+
8290
function escapeRegExp(string) {
8391
return string.replace(/[\\^$*+?.()|[\]{}]/g, '\\$&');
8492
}

0 commit comments

Comments
 (0)