include/linux/fsnotify.h
Source file repositories/reference/linux-study-clean/include/linux/fsnotify.h
File Facts
- System
- Linux kernel
- Corpus path
include/linux/fsnotify.h- Extension
.h- Size
- 13328 bytes
- Lines
- 518
- Domain
- Core OS
- Bucket
- Core Kernel Interface
- Inferred role
- Core OS: implementation source
- Status
- source implementation candidate
Why This File Exists
Core operating-system implementation surface: boot, tasks, memory, VFS, syscall-facing interfaces, synchronization, credentials, and isolation.
- Core operating-system implementation surface: boot, tasks, memory, VFS, syscall-facing interfaces, synchronization, credentials, and isolation.
- Uses kernel synchronization; read lock ordering, sleepability, and interrupt context assumptions before translating.
- Defines or uses C structs; map object ownership, embedded links, reference counts, and lock ownership.
Dependency Surface
linux/fsnotify_backend.hlinux/audit.hlinux/slab.hlinux/bug.h
Detected Declarations
function fsnotify_sb_has_priority_watchersfunction fsnotify_sb_has_watchersfunction changedfunction fsnotify_direntfunction fsnotify_inodefunction fsnotify_parentfunction fsnotify_parentfunction fsnotify_pathfunction fsnotify_filefunction fsnotify_file_area_permfunction readfunction fsnotify_mmap_permfunction fsnotify_truncate_permfunction fsnotify_file_permfunction fsnotify_open_perm_and_set_modefunction fsnotify_file_area_permfunction fsnotify_mmap_permfunction fsnotify_truncate_permfunction fsnotify_file_permfunction fsnotify_link_countfunction fsnotify_movefunction fsnotify_inode_deletefunction fsnotify_vfsmount_deletefunction fsnotify_mntns_deletefunction fsnotify_inoderemovefunction fsnotify_createfunction fsnotify_linkfunction d_deletefunction fsnotify_deletefunction fsnotify_unlinkfunction fsnotify_mkdirfunction fsnotify_rmdirfunction fsnotify_accessfunction fsnotify_modifyfunction fsnotify_openfunction fsnotify_closefunction fsnotify_xattrfunction fsnotify_changefunction fsnotify_mnt_attachfunction fsnotify_mnt_detachfunction fsnotify_mnt_move
Annotated Snippet
#ifndef _LINUX_FS_NOTIFY_H
#define _LINUX_FS_NOTIFY_H
/*
* include/linux/fsnotify.h - generic hooks for filesystem notification, to
* reduce in-source duplication from both dnotify and inotify.
*
* We don't compile any of this away in some complicated menagerie of ifdefs.
* Instead, we rely on the code inside to optimize away as needed.
*
* (C) Copyright 2005 Robert Love
*/
#include <linux/fsnotify_backend.h>
#include <linux/audit.h>
#include <linux/slab.h>
#include <linux/bug.h>
/* Are there any inode/mount/sb objects watched with priority prio or above? */
static inline bool fsnotify_sb_has_priority_watchers(struct super_block *sb,
int prio)
{
struct fsnotify_sb_info *sbinfo = fsnotify_sb_info(sb);
/* Were any marks ever added to any object on this sb? */
if (!sbinfo)
return false;
return atomic_long_read(&sbinfo->watched_objects[prio]);
}
/* Are there any inode/mount/sb objects that are being watched at all? */
static inline bool fsnotify_sb_has_watchers(struct super_block *sb)
{
return fsnotify_sb_has_priority_watchers(sb, 0);
}
/*
* Notify this @dir inode about a change in a child directory entry.
* The directory entry may have turned positive or negative or its inode may
* have changed (i.e. renamed over).
*
* Unlike fsnotify_parent(), the event will be reported regardless of the
* FS_EVENT_ON_CHILD mask on the parent inode and will not be reported if only
* the child is interested and not the parent.
*/
static inline int fsnotify_name(__u32 mask, const void *data, int data_type,
struct inode *dir, const struct qstr *name,
u32 cookie)
{
if (!fsnotify_sb_has_watchers(dir->i_sb))
return 0;
return fsnotify(mask, data, data_type, dir, name, NULL, cookie);
}
static inline void fsnotify_dirent(struct inode *dir, struct dentry *dentry,
__u32 mask)
{
fsnotify_name(mask, dentry, FSNOTIFY_EVENT_DENTRY, dir, &dentry->d_name, 0);
}
static inline void fsnotify_inode(struct inode *inode, __u32 mask)
{
if (!fsnotify_sb_has_watchers(inode->i_sb))
return;
if (S_ISDIR(inode->i_mode))
mask |= FS_ISDIR;
fsnotify(mask, inode, FSNOTIFY_EVENT_INODE, NULL, NULL, inode, 0);
}
/* Notify this dentry's parent about a child's events. */
static inline int fsnotify_parent(struct dentry *dentry, __u32 mask,
const void *data, int data_type)
{
struct inode *inode = d_inode(dentry);
if (!fsnotify_sb_has_watchers(inode->i_sb))
return 0;
if (S_ISDIR(inode->i_mode)) {
mask |= FS_ISDIR;
/* sb/mount marks are not interested in name of directory */
if (!(dentry->d_flags & DCACHE_FSNOTIFY_PARENT_WATCHED))
goto notify_child;
}
Annotation
- Immediate include surface: `linux/fsnotify_backend.h`, `linux/audit.h`, `linux/slab.h`, `linux/bug.h`.
- Detected declarations: `function fsnotify_sb_has_priority_watchers`, `function fsnotify_sb_has_watchers`, `function changed`, `function fsnotify_dirent`, `function fsnotify_inode`, `function fsnotify_parent`, `function fsnotify_parent`, `function fsnotify_path`, `function fsnotify_file`, `function fsnotify_file_area_perm`.
- Atlas domain: Core OS / Core Kernel Interface.
- Implementation status: source implementation candidate.
- Synchronization appears in or near this file; preserve lock ordering, sleepability, and interrupt-context constraints.
Implementation Notes
- This generated page is the file-by-file coverage layer; curated subsystem chapters should link here when they synthesize a multi-file control flow.
- Core OS pages should be promoted from atlas-only to deep-reviewed when they explain data structures, invariants, locking, lifecycle, and C implementation snippets.
- Driver-family pages are intentionally pattern-oriented unless they are part of the selected PCIe/NVMe representative device path.