From 88c35e70a06d1d048cc32153d8214bcd28107528 Mon Sep 17 00:00:00 2001 From: Joran Dirk Greef Date: Thu, 7 Apr 2016 14:36:39 +0200 Subject: [PATCH] doc: clarify fs.watch() and inodes on linux, os x On Linux and OS X systems, `fs.watch()` resolves the watched path to an inode. This clarifies that `fs.watch()` watches the inode and not the path. If the inode of the path subsequently changes, `fs.watch()` will continue watching the original inode and events for the path will no longer be emitted. This is expected behavior. Fixes: https://github.com/nodejs/node/issues/5039 PR-URL: https://github.com/nodejs/node/pull/6099 Reviewed-By: James M Snell --- doc/api/fs.markdown | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/doc/api/fs.markdown b/doc/api/fs.markdown index fc2dd5934ec498..8a05ffa3c23ea9 100644 --- a/doc/api/fs.markdown +++ b/doc/api/fs.markdown @@ -1155,6 +1155,16 @@ reliably or at all. You can still use `fs.watchFile`, which uses stat polling, but it is slower and less reliable. +#### Inodes + + + +On Linux and OS X systems, `fs.watch()` resolves the path to an [inode][] and +watches the inode. If the watched path is deleted and recreated, it is assigned +a new inode. The watch will emit an event for the delete but will continue +watching the *original* inode. Events for the new inode will not be emitted. +This is expected behavior. + #### Filename Argument @@ -1376,3 +1386,4 @@ Synchronous versions of [`fs.write()`][]. Returns the number of bytes written. [MDN-Date]: https://developer.mozilla.org/en/JavaScript/Reference/Global_Objects/Date [Readable Stream]: stream.html#stream_class_stream_readable [Writable Stream]: stream.html#stream_class_stream_writable +[inode]: http://www.linux.org/threads/intro-to-inodes.4130