user@devops:~$ cat README.md
inotify-watch
# Description
inotify-watch (cpp-inotify-watch) is a Linux filesystem event monitor written in C++23 with zero dependencies on top of the kernel's inotify(7) API. 15 event types decoded: CREATE, MODIFY, ATTRIB, DELETE, MOVED_FROM/MOVED_TO, OPEN, ACCESS, CLOSE_WRITE/CLOSE_NOWRITE, DELETE_SELF, MOVE_SELF, UNMOUNT and Q_OVERFLOW, with IN_ISDIR detection (directory events shown bold). Rename pairing by cookie: MOVED_FROM and MOVED_TO share the kernel's cookie field (unique per rename) and are printed as a single RENAME line (a.txt -> b.txt). Recursive watching (-r): inotify is not recursive by nature, so the tool scans the tree with std::filesystem (recursive_directory_iterator with skip_permission_denied and per-iteration error_code clearing) and registers one watch per directory. Configurable mask (-m create,modify,delete,move,attrib,open,close,access,all) with name validation. JSON-lines output (--json) with {ts, type, path, dir, cookie} for jq scripting. RAII over the inotify fd with std::expected for exception-free error handling, a poll() loop with 500ms timeout that answers Ctrl+C and --timeout N, and non-blocking queue draining (EAGAIN = done). Demo mode (--demo) with a realistic synthetic app-build stream for containers/VMs. 30 self-tests (--selftest) against real events in a temporary directory: create/modify/attrib/rename/delete, cookie pairing, mask filtering, remove_watch, direct file watching, recursive watching in nested subdirectories and JSON format. Zero dependencies: direct build with g++ -std=c++23.
# Key features
$ 15 inotify event types decoded: CREATE, MODIFY, ATTRIB, DELETE, MOVED_FROM/MOVED_TO, OPEN, ACCESS, CLOSE_WRITE/NOWRITE, DELETE_SELF, MOVE_SELF, UNMOUNT and Q_OVERFLOW
$ Rename pairing by kernel cookie: MOVED_FROM + MOVED_TO are matched via the cookie field and printed as a single RENAME line (a.txt -> b.txt)
$ Recursive watching (-r): inotify is not recursive by nature — scans the tree with std::filesystem (skip_permission_denied + per-iteration error_code) and registers one watch per directory
$ IN_ISDIR detection: directory events are flagged and shown bold (dir vs file)
$ Configurable mask (-m create,modify,delete,move,attrib,open,close,access,all) with name validation
$ JSON-lines output (--json) with {ts, type, path, dir, cookie} for jq scripting
$ RAII over the inotify fd with std::expected (C++23), 500ms poll() loop, Ctrl+C and --timeout N, non-blocking queue draining (EAGAIN = done)
$ --demo synthetic mode for containers/VMs and 30 self-tests (--selftest) against real events in a temporary directory
# Gallery
# Technologies used