Skip to content

Commit 60460bf

Browse files
Jussi Räsänentniessen
Jussi Räsänen
authored andcommitted
fs: add O_DSYNC
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 66e45b8 commit 60460bf

File tree

3 files changed

+20
-0
lines changed

3 files changed

+20
-0
lines changed

doc/api/fs.md

+5
Original file line numberDiff line numberDiff line change
@@ -2808,6 +2808,11 @@ The following constants are meant for use with `fs.open()`.
28082808
<td><code>O_SYNC</code></td>
28092809
<td>Flag indicating that the file is opened for synchronous I/O.</td>
28102810
</tr>
2811+
<tr>
2812+
<td><code>O_DSYNC</code></td>
2813+
<td>Flag indicating that the file is opened for synchronous I/O
2814+
with write operations waiting for data integrity.</td>
2815+
</tr>
28112816
<tr>
28122817
<td><code>O_SYMLINK</code></td>
28132818
<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
@@ -1089,6 +1089,11 @@ void DefineSystemConstants(Local<Object> target) {
10891089
NODE_DEFINE_CONSTANT(target, O_SYNC);
10901090
#endif
10911091

1092+
#ifdef O_DSYNC
1093+
NODE_DEFINE_CONSTANT(target, O_DSYNC);
1094+
#endif
1095+
1096+
10921097
#ifdef O_SYMLINK
10931098
NODE_DEFINE_CONSTANT(target, O_SYMLINK);
10941099
#endif

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

+10
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@
2222
// Flags: --expose_internals
2323
'use strict';
2424
const common = require('../common');
25+
const fixtures = require('../common/fixtures');
2526
const assert = require('assert');
2627

2728
const fs = require('fs');
@@ -32,6 +33,7 @@ const O_EXCL = fs.constants.O_EXCL || 0;
3233
const O_RDONLY = fs.constants.O_RDONLY || 0;
3334
const O_RDWR = fs.constants.O_RDWR || 0;
3435
const O_SYNC = fs.constants.O_SYNC || 0;
36+
const O_DSYNC = fs.constants.O_DSYNC || 0;
3537
const O_TRUNC = fs.constants.O_TRUNC || 0;
3638
const O_WRONLY = fs.constants.O_WRONLY || 0;
3739

@@ -78,3 +80,11 @@ common.expectsError(
7880
() => stringToFlags(null),
7981
{ code: 'ERR_INVALID_OPT_VALUE', type: TypeError }
8082
);
83+
84+
if (common.isLinux === true) {
85+
const file = fixtures.path('a.js');
86+
87+
fs.open(file, O_DSYNC, common.mustCall(function(err, fd) {
88+
assert.ifError(err);
89+
}));
90+
}

0 commit comments

Comments
 (0)