Node: Add `#ifdef O_DSYNC`

Created on 15 Sep 2017  路  6Comments  路  Source: nodejs/node

node_constants.cc exports O_SYNC on Linux, but O_DSYNC should probably be added.

feature request fs good first issue

Most helpful comment

@jrasanen awesome! let us know if you need any pointers :)

All 6 comments

I could try to do this

@jrasanen awesome! let us know if you need any pointers :)

How would one write a test case for testing if O_DSYNC is being used?

I made the changes and verified the code using strace,

$ sudo strace -e trace=open -f ./node write_cats_to_tmp.js
[pid  9226] open("/vagrant/node/write_cats_to_tmp.js", O_RDONLY|O_CLOEXEC) = 12
Wrote to /tmp/cats.tmp
[pid  9232] open("/tmp/cats.tmp", O_WRONLY|O_CREAT|O_TRUNC|O_DSYNC|O_CLOEXEC, 0666) = 12
Writing to file
Wrote 9 bytes

Since the flag has no directly observable effect, I think the best you can do is check that it's there when common.isLinux === true and that it's accepted by fs.open() without error.

@bnoordhuis ok thanks! Which place you would recommend I add the test to? test-fs-open-flags.js?

Yes, that's a good place for it.

Was this page helpful?
0 / 5 - 0 ratings