Generated by GPT-5-mini| inotify | |
|---|---|
| Name | inotify |
| Os | Linux |
| Introduced | 2005 |
| Author | Linus Torvalds / Linux kernel |
| License | GNU General Public License |
inotify
inotify is a Linux kernel subsystem that provides file system event monitoring. It enables applications to receive notifications about changes to files and directories, allowing integration with software such as desktop environments, indexing services, backup solutions, and file synchronization tools. Originating in the mid-2000s within the Linux kernel community, inotify complements user-space utilities and other kernel features by offering efficient, event-driven change detection.
inotify is designed to emit events for file system operations including creation, deletion, modification, and attribute changes. It interacts with subsystems and projects like GTK+, KDE, systemd, GNOME, and desktop search services such as Beagle (software) and Tracker (software). Developers build on inotify for applications similar to rsync, Unison (software), Dropbox (service), and Nextcloud. The facility is part of the Linux kernel mainline and related to other kernel abstractions like epoll and fanotify.
The architecture centers on kernel-managed watch descriptors associated with specified inode paths and monitored masks. Core components include the in-kernel notifier, per-process event queues, and file descriptor interfaces exposed to user space via the POSIX-compatible file descriptor model adopted by Unix derivatives. inotify integrates with kernel VFS structures and interacts indirectly with filesystems such as EXT4, XFS, Btrfs, NFS, and FAT. It also coexists with kernel features like cgroups, namespaces (Linux) and I/O schedulers developed by contributors from organizations such as Red Hat and Intel.
Applications create an inotify instance using a syscall that returns a file descriptor, then add watches for paths with bitmask flags denoting events of interest. Common API functions and syscalls are typically used by toolkits and runtime libraries maintained by projects like GNU C Library, Musl, and language ecosystems such as Python (programming language), Go (programming language), Rust (programming language), and Java (programming language). Bindings exist in frameworks like Qt (software), GTK#, and scripting environments exemplified by Perl, Ruby (programming language), and Node.js. Event loops such as those in libevent and libuv often multiplex inotify file descriptors with network descriptors using mechanisms like epoll.
inotify is efficient for many workloads because it avoids polling and scales better than naive directory scanning strategies; it has been used in large-scale projects led by companies such as Google, Facebook, and Dropbox (service). However, limitations include a finite number of watches per user (tunable via kernel parameters), event coalescing in high-throughput scenarios, and varying semantics across networked filesystems like NFS and CIFS. For high-frequency change streams, alternatives and complements include fanotify, change journals in NTFS, and filesystem-specific mechanisms like inotify-integrated features in Btrfs snapshots or ZFS event frameworks developed by teams at Sun Microsystems and later Oracle. Performance tuning often involves kernel parameters, systemd timers, and integration with services such as cron or systemd timers.
Access to inotify is mediated by standard filesystem permissions and the Linux DAC/ACL models implemented by POSIX and extended by projects like SELinux and AppArmor. The kernel enforces namespace isolation when using Linux namespaces and container technologies like Docker (software) and LXC (Linux Containers), with orchestration systems such as Kubernetes influencing deployment patterns. Misuse or excessive watches can lead to resource exhaustion; distributions by vendors including Debian, Ubuntu, Red Hat Enterprise Linux, and SUSE document sysctl knobs and ulimits to mitigate such risks. Security-conscious applications integrate with access control frameworks maintained by organizations like OpenSSL and The Open Group standards.
Development started as a response to limitations in earlier mechanisms and was implemented in the Linux kernel around 2005, with contributions from kernel developers associated with Red Hat, Novell, and individual contributors coordinated via LKML discussions. It was designed to supersede older approaches used by user-space polling and interfaces influenced by file event APIs from other systems such as BSD and macOS's FSEvents. Over successive kernel releases, maintainers in the Linux kernel project refined semantics, scaling parameters, and interactions with filesystems like EXT3 and EXT4, guided by feedback from upstream projects such as GNOME and KDE.
User-space utilities and libraries wrap the kernel API: tools include daemons and utilities used by systemd, file-sync clients like rsync frontends, desktop components in GNOME and KDE, and language bindings maintained in ecosystems such as CPAN, PyPI, npm (software) and Crates.io. Notable projects leveraging inotify-style notifications include Dropbox (service), Nextcloud, ownCloud, and indexing engines developed by companies such as Apple for analogous services. Monitoring suites and file integrity systems from vendors like Tripwire and AIDE integrate kernel notifications alongside hashing and audit subsystems such as auditd.