Skip to content
This repository has been archived by the owner on Apr 22, 2023. It is now read-only.

Commit

Permalink
fs: fix readFileSync("/proc/cpuinfo") regression
Browse files Browse the repository at this point in the history
Don't use positional reads. Not all proc files support pread(), especially on
older linux kernels.

Fixes #3808.
  • Loading branch information
bnoordhuis committed Aug 1, 2012
1 parent fd56981 commit 23f09d7
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions lib/fs.js
Expand Up @@ -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));
}
Expand Down

0 comments on commit 23f09d7

Please sign in to comment.