From 40820ec8d53e89af9efa0b5caef52b7f42ad5186 Mon Sep 17 00:00:00 2001 From: Brian Hammond Date: Fri, 23 Apr 2010 11:31:50 -0400 Subject: [PATCH] Leave pos as undefined to allow reads from unseekable files like /proc/x/smaps on Linux --- lib/fs.js | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/lib/fs.js b/lib/fs.js index c3ab698e633..48030de4797 100644 --- a/lib/fs.js +++ b/lib/fs.js @@ -63,7 +63,8 @@ fs.readFile = function (path, encoding_, callback) { if (err) { if (callback) callback(err); } else { - readAll(fd, 0, "", encoding, callback); + // leave pos undefined to allow reads on unseekable devices + readAll(fd, undefined, "", encoding, callback); } }); }; @@ -73,7 +74,7 @@ fs.readFileSync = function (path, encoding) { var fd = binding.open(path, process.O_RDONLY, 0666); var content = ''; - var pos = 0; + var pos; // leave undefined to allow reads on unseekable devices var r; while ((r = binding.read(fd, 4*1024, pos, encoding)) && r[0]) {