Browse Source

fs: fix readFileSync("/proc/cpuinfo") regression

Don't use positional reads. Not all proc files support pread(), especially on
older linux kernels.

Fixes #3808.
v0.8.7-release
Ben Noordhuis 13 years ago
parent
commit
23f09d7e02
  1. 4
      lib/fs.js

4
lib/fs.js

@ -205,12 +205,12 @@ fs.readFileSync = function(path, encoding) {
var threw = true;
try {
if (size !== 0) {
var bytesRead = fs.readSync(fd, buffer, pos, size - pos, pos);
var bytesRead = fs.readSync(fd, buffer, pos, size - pos);
} else {
// the kernel lies about many files.
// Go ahead and try to read some bytes.
buffer = new Buffer(8192);
var bytesRead = fs.readSync(fd, buffer, 0, 8192, pos);
var bytesRead = fs.readSync(fd, buffer, 0, 8192);
if (bytesRead) {
buffers.push(buffer.slice(0, bytesRead));
}

Loading…
Cancel
Save