diff --git a/lib/fs.js b/lib/fs.js index 18cf7f16c1..8cd15eb04e 100644 --- a/lib/fs.js +++ b/lib/fs.js @@ -185,10 +185,11 @@ function modeNum(m, def) { } fs.open = function(path, flags, mode, callback) { - mode = modeNum(mode, '0666'); var callback_ = arguments[arguments.length - 1]; var callback = (typeof(callback_) == 'function' ? callback_ : null); + mode = modeNum(mode, '0666'); + binding.open(path, stringToFlags(flags), mode, callback || noop); }; diff --git a/test/simple/test-fs-open.js b/test/simple/test-fs-open.js new file mode 100644 index 0000000000..2971d4608e --- /dev/null +++ b/test/simple/test-fs-open.js @@ -0,0 +1,17 @@ +var common = require('../common'); +var assert = require('assert'); +var fs = require('fs'); + +var openFd; +fs.open(__filename, 'r', function(err, fd) { + if (err) { + throw err; + } + + openFd = fd; +}); + +process.addListener('exit', function() { + assert.ok(openFd); +}); +