|
Helping ordinary people create extraordinary websites! |
Monitor Linux File System Events with InotifyBy Eli M. Dow2005-05-31
Why inotify? There are many reasons to use inotify instead of dnotify. The first is that dnotify requires opening one file descriptor for each directory that you intend to watch for changes. This can become quite costly when you are monitoring several directories at once, since it is possible to reach a per-process file descriptor limit. Additionally, the file descriptor pins the directory, disallowing the backing device to be unmounted, which causes problems in scenarios involving removable media. When using inotify, if you are watching a file on a file system that is unmounted, the watch is automatically removed and you receive an unmount event. The second reason dnotify is inferior to inotify is a bit more complex. It is important to note that straightforward file system-monitoring granularity using the dnotify infrastructure exists only at the directory level. For more fine-grained monitoring with dnotify, application programmers are forced to keep a cache of An additional advantage of inotify is that it uses a file descriptor as the basic interface to let application developers use Inotify solves these issues by providing a more elegant API that uses minimal file descriptors and ensures finer granularity of monitoring. Communication with inotify is provided through a device node. For these reasons it should be your clear choice when monitoring files on Linux 2.6 platforms. Tutorial Pages: » This next-gen, dnotify replacement meets file system event-monitoring needs in the 2.6 kernel » Why inotify? » Installing inotify » Using inotify in a simple application » Conclusion » Resources First published by IBM DeveloperWorks
|
|