Browse Source

fs: add O_DSYNC

PR-URL: https://github.com/nodejs/node/pull/15451
Fixes: https://github.com/nodejs/node/issues/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>
canary-base
Jussi Räsänen 8 years ago
committed by Tobias Nießen
parent
commit
60460bf80d
No known key found for this signature in database GPG Key ID: 718207F8FD156B70
  1. 5
      doc/api/fs.md
  2. 5
      src/node_constants.cc
  3. 10
      test/parallel/test-fs-open-flags.js

5
doc/api/fs.md

@ -2808,6 +2808,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

5
src/node_constants.cc

@ -1089,6 +1089,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

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

@ -22,6 +22,7 @@
// Flags: --expose_internals
'use strict';
const common = require('../common');
const fixtures = require('../common/fixtures');
const assert = require('assert');
const fs = require('fs');
@ -32,6 +33,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;
@ -78,3 +80,11 @@ common.expectsError(
() => stringToFlags(null),
{ code: 'ERR_INVALID_OPT_VALUE', type: TypeError }
);
if (common.isLinux === true) {
const file = fixtures.path('a.js');
fs.open(file, O_DSYNC, common.mustCall(function(err, fd) {
assert.ifError(err);
}));
}

Loading…
Cancel
Save