opnsense-src/sys/fs
Mark Johnston f1f230439f 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
2025-07-04 14:42:33 +00:00
..
autofs Reduce reliance on sys/sysproto.h pollution 2024-04-15 21:35:40 +01:00
cd9660 cd9660: Add _WANT_ISO_MNT 2025-06-16 22:32:09 +01:00
cuse cuse: Use NULL for SYSUNINIT's last arg, which is a pointer type 2024-12-10 01:14:07 +08:00
deadfs sys: Remove ancient SCCS tags. 2023-11-26 22:23:30 -07:00
devfs devfs: Set eofflag in devfs_readdir() 2025-05-29 18:25:56 +00:00
ext2fs ext2fs: 'struct ufid': Re-order fields and unpack 2024-12-13 15:04:50 +01:00
fdescfs file: Add a fd flag with O_RESOLVE_BENEATH semantics 2025-06-24 21:04:18 +00:00
fifofs sys: Remove ancient SCCS tags. 2023-11-26 22:23:30 -07:00
fuse fusefs: exterrorize fuse_vnops.c 2025-07-04 10:14:21 +03:00
mntfs sys: Remove $FreeBSD$: two-line .h pattern 2023-08-16 11:54:11 -06:00
msdosfs msdosfs: Add _WANT_MSDOSFS_INTERNALS to replace MAKEFS in headers 2025-06-16 22:33:18 +01:00
nfs nfscl: Use delegation ACE when mounted with nocto 2025-06-30 07:51:01 -07:00
nfsclient files: Fix builds without "options UFS_ACL" 2025-07-02 07:35:34 -07:00
nfsserver nfsd: Use an NFSv4 ACL for the delegation ACE if available 2025-06-29 09:09:23 -07:00
nullfs vfs: Initial revision of inotify 2025-07-04 14:42:33 +00:00
p9fs p9fs: Call VN_LOCK_ASHARE on new vnodes 2025-06-13 19:19:59 +00:00
procfs proc_rwmem check PRIV_PROC_MEM_WRITE when writing 2024-11-08 16:11:33 -08:00
pseudofs pseudofs: make dup name an error instead of panic 2025-06-06 01:41:40 +03:00
smbfs Internal scheduling priorities: Always use symbolic ones 2025-06-17 22:08:02 -04:00
tarfs tarfs: 'struct tarfs_fid': Switch 'gen' to 'u_int', avoid packing 2024-12-13 15:04:42 +01:00
tmpfs tmpfs: turn vfs.tmpfs.memory_percent into CTLFLAG_RWTUN 2025-04-11 13:02:06 -04:00
udf udf: Fix a typo in a source code comment 2025-05-05 10:47:23 +02:00
unionfs namei: Fix cn_flags width in various places 2025-05-27 13:29:14 +00:00