Skip to content

Commit

Permalink
fs: add O_DSYNC
Browse files Browse the repository at this point in the history
Backport-PR-URL: #15653
PR-URL: #15451
Fixes: #15425
Reviewed-By: Ben Noordhuis <info@bnoordhuis.nl>
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Luigi Pinca <luigipinca@gmail.com>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
Reviewed-By: Tobias Nießen <tniessen@tnie.de>
  • Loading branch information
Jussi Räsänen authored and MylesBorins committed Oct 7, 2017
1 parent 27c4efd commit 8ec81a8
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 2 deletions.
5 changes: 5 additions & 0 deletions doc/api/fs.md
Original file line number Diff line number Diff line change
Expand Up @@ -2869,6 +2869,11 @@ The following constants are meant for use with `fs.open()`.
<td><code>O_SYNC</code></td>
<td>Flag indicating that the file is opened for synchronous I/O.</td>
</tr>
<tr>
<td><code>O_DSYNC</code></td>
<td>Flag indicating that the file is opened for synchronous I/O
with write operations waiting for data integrity.</td>
</tr>
<tr>
<td><code>O_SYMLINK</code></td>
<td>Flag indicating to open the symbolic link itself rather than the
Expand Down
5 changes: 5 additions & 0 deletions src/node_constants.cc
Original file line number Diff line number Diff line change
Expand Up @@ -1085,6 +1085,11 @@ void DefineSystemConstants(Local<Object> target) {
NODE_DEFINE_CONSTANT(target, O_SYNC);
#endif

#ifdef O_DSYNC
NODE_DEFINE_CONSTANT(target, O_DSYNC);
#endif


#ifdef O_SYMLINK
NODE_DEFINE_CONSTANT(target, O_SYMLINK);
#endif
Expand Down
12 changes: 10 additions & 2 deletions test/parallel/test-fs-open-flags.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,8 @@

// Flags: --expose_internals
'use strict';
require('../common');
const common = require('../common');
const assert = require('assert');

const fs = require('fs');

const O_APPEND = fs.constants.O_APPEND || 0;
Expand All @@ -32,6 +31,7 @@ const O_EXCL = fs.constants.O_EXCL || 0;
const O_RDONLY = fs.constants.O_RDONLY || 0;
const O_RDWR = fs.constants.O_RDWR || 0;
const O_SYNC = fs.constants.O_SYNC || 0;
const O_DSYNC = fs.constants.O_DSYNC || 0;
const O_TRUNC = fs.constants.O_TRUNC || 0;
const O_WRONLY = fs.constants.O_WRONLY || 0;

Expand Down Expand Up @@ -79,6 +79,14 @@ assert.throws(
/^Error: Unknown file open flag: null$/
);

if (common.isLinux === true) {
const file = `${__dirname}/../fixtures/a.js`;

fs.open(file, O_DSYNC, common.mustCall(function(err, fd) {
assert.ifError(err);
}));
}

function escapeRegExp(string) {
return string.replace(/[\\^$*+?.()|[\]{}]/g, '\\$&');
}

0 comments on commit 8ec81a8

Please sign in to comment.