https://bugs.freebsd.org/bugzilla/show_bug.cgi?id=258010
--- Comment #5 from [email protected] --- A commit in branch main references this bug: URL: https://cgit.FreeBSD.org/src/commit/?id=f1f230439fa48581f40a57f095627f667a9713c3 commit f1f230439fa48581f40a57f095627f667a9713c3 Author: Mark Johnston <[email protected]> AuthorDate: 2025-07-03 20:07:45 +0000 Commit: Mark Johnston <[email protected]> CommitDate: 2025-07-04 14:42:33 +0000 vfs: Initial revision of inotify Add an implementation of inotify_init(), inotify_add_watch(), inotify_rm_watch(), source-compatible with Linux. This provides functionality similar to kevent(2)'s EVFILT_VNODE, i.e., it lets applications monitor filesystem files for accesses. Compared to inotify, however, EVFILT_VNODE has the limitation of requiring the application to open the file to be monitored. This means that activity on a newly created file cannot be monitored reliably, and that a file descriptor per file in the hierarchy is required. inotify on the other hand allows a directory and its entries to be monitored at once. It introduces a new file descriptor type to which "watches" can be attached; a watch is a pseudo-file descriptor associated with a file or directory and a set of events to watch for. When a watched vnode is accessed, a description of the event is queued to the inotify descriptor, readable with read(2). Events for files in a watched directory include the file name. A watched vnode has its usecount bumped, so name cache entries originating from a watched directory are not evicted. Name cache entries are used to populate inotify events for files with a link in a watched directory. In particular, if a file is accessed with, say, read(2), an IN_ACCESS event will be generated for any watched hard link of the file. The inotify_add_watch_at() variant is included so that this functionality is available in capability mode; plain inotify_add_watch() is disallowed in capability mode. When a file in a nullfs mount is watched, the watch is attached to the lower vnode, such that accesses via either layer generate inotify events. Many thanks to Gleb Popov for testing this patch and finding lots of bugs. PR: 258010, 215011 Reviewed by: kib Tested by: arrowd MFC after: 3 months Sponsored by: Klara, Inc. Differential Revision: https://reviews.freebsd.org/D50315 share/man/man4/rights.4 | 10 +- sys/bsm/audit_kevents.h | 1 + sys/conf/files | 1 + sys/fs/nullfs/null_subr.c | 4 + sys/fs/nullfs/null_vnops.c | 29 +- sys/kern/kern_resource.c | 21 + sys/kern/subr_capability.c | 4 + sys/kern/sys_generic.c | 35 +- sys/kern/syscalls.master | 15 + sys/kern/vfs_cache.c | 59 +++ sys/kern/vfs_default.c | 17 + sys/kern/vfs_inotify.c (new) | 1008 ++++++++++++++++++++++++++++++++++++++++++ sys/kern/vfs_subr.c | 7 +- sys/kern/vfs_vnops.c | 3 +- sys/kern/vnode_if.src | 21 + sys/sys/caprights.h | 2 + sys/sys/capsicum.h | 8 +- sys/sys/exterr_cat.h | 1 + sys/sys/file.h | 1 + sys/sys/inotify.h (new) | 146 ++++++ sys/sys/resourcevar.h | 4 + sys/sys/specialfd.h | 5 + sys/sys/user.h | 5 + sys/sys/vnode.h | 12 +- sys/tools/vnode_if.awk | 1 + 25 files changed, 1405 insertions(+), 15 deletions(-) -- You are receiving this mail because: You are on the CC list for the bug.
