include/linux/fsnotify_backend.h
Source file repositories/reference/linux-study-clean/include/linux/fsnotify_backend.h
File Facts
- System
- Linux kernel
- Corpus path
include/linux/fsnotify_backend.h- Extension
.h- Size
- 33578 bytes
- Lines
- 1005
- 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/idr.hlinux/fs.hlinux/list.hlinux/path.hlinux/spinlock.hlinux/types.hlinux/atomic.hlinux/user_namespace.hlinux/refcount.hlinux/mempool.hlinux/sched/mm.h
Detected Declarations
struct fsnotify_groupstruct fsnotify_eventstruct fsnotify_markstruct fsnotify_event_private_datastruct fsnotify_fnamestruct fsnotify_iter_infostruct mem_cgroupstruct fsnotify_opsstruct fsnotify_eventstruct fsnotify_groupstruct inotify_group_private_datastruct fanotify_group_private_datastruct fs_error_reportstruct file_rangestruct fsnotify_mntstruct fsnotify_rename_datastruct fsnotify_iter_infostruct fsnotify_mark_connectorstruct fsnotify_sb_infostruct fsnotify_markenum fsnotify_group_prioenum fsnotify_data_typeenum fsnotify_iter_typeenum fsnotify_obj_typefunction fsnotify_group_lockfunction fsnotify_group_unlockfunction fsnotify_group_assert_lockedfunction fsnotify_data_mnt_idfunction fsnotify_valid_obj_typefunction fsnotify_iter_should_report_typefunction fsnotify_iter_set_report_typefunction fsnotify_iter_stepfunction fsnotify_parent_needed_maskfunction fsnotify_inode_watches_childrenfunction fsnotify_update_flagsfunction fsnotify_add_eventfunction fsnotify_queue_overflowfunction fsnotify_is_overflow_eventfunction fsnotify_notify_queue_is_emptyfunction fsnotify_ignore_maskfunction fsnotify_ignored_eventsfunction maskfunction fsnotify_effective_ignore_maskfunction fsnotify_calc_maskfunction fsnotify_add_inode_markfunction fsnotify_add_inode_mark_lockedfunction fsnotify_init_eventfunction fsnotify_pre_content
Annotated Snippet
struct fsnotify_ops {
int (*handle_event)(struct fsnotify_group *group, u32 mask,
const void *data, int data_type, struct inode *dir,
const struct qstr *file_name, u32 cookie,
struct fsnotify_iter_info *iter_info);
int (*handle_inode_event)(struct fsnotify_mark *mark, u32 mask,
struct inode *inode, struct inode *dir,
const struct qstr *file_name, u32 cookie);
void (*free_group_priv)(struct fsnotify_group *group);
void (*freeing_mark)(struct fsnotify_mark *mark, struct fsnotify_group *group);
void (*free_event)(struct fsnotify_group *group, struct fsnotify_event *event);
/* called on final put+free to free memory */
void (*free_mark)(struct fsnotify_mark *mark);
};
/*
* all of the information about the original object we want to now send to
* a group. If you want to carry more info from the accessing task to the
* listener this structure is where you need to be adding fields.
*/
struct fsnotify_event {
struct list_head list;
};
/*
* fsnotify group priorities.
* Events are sent in order from highest priority to lowest priority.
*/
enum fsnotify_group_prio {
FSNOTIFY_PRIO_NORMAL = 0, /* normal notifiers, no permissions */
FSNOTIFY_PRIO_CONTENT, /* fanotify permission events */
FSNOTIFY_PRIO_PRE_CONTENT, /* fanotify pre-content events */
__FSNOTIFY_PRIO_NUM
};
/*
* A group is a "thing" that wants to receive notification about filesystem
* events. The mask holds the subset of event types this group cares about.
* refcnt on a group is up to the implementor and at any moment if it goes 0
* everything will be cleaned up.
*/
struct fsnotify_group {
const struct fsnotify_ops *ops; /* how this group handles things */
/*
* How the refcnt is used is up to each group. When the refcnt hits 0
* fsnotify will clean up all of the resources associated with this group.
* As an example, the dnotify group will always have a refcnt=1 and that
* will never change. Inotify, on the other hand, has a group per
* inotify_init() and the refcnt will hit 0 only when that fd has been
* closed.
*/
refcount_t refcnt; /* things with interest in this group */
/* needed to send notification to userspace */
spinlock_t notification_lock; /* protect the notification_list */
struct list_head notification_list; /* list of event_holder this group needs to send to userspace */
wait_queue_head_t notification_waitq; /* read() on the notification file blocks on this waitq */
unsigned int q_len; /* events on the queue */
unsigned int max_events; /* maximum events allowed on the list */
enum fsnotify_group_prio priority; /* priority for sending events */
bool shutdown; /* group is being shut down, don't queue more events */
#define FSNOTIFY_GROUP_USER 0x01 /* user allocated group */
#define FSNOTIFY_GROUP_DUPS 0x02 /* allow multiple marks per object */
int flags;
unsigned int owner_flags; /* stored flags of mark_mutex owner */
/* stores all fastpath marks assoc with this group so they can be cleaned on unregister */
struct mutex mark_mutex; /* protect marks_list */
atomic_t user_waits; /* Number of tasks waiting for user
* response */
struct list_head marks_list; /* all inode marks for this group */
struct fasync_struct *fsn_fa; /* async notification */
struct fsnotify_event *overflow_event; /* Event we queue when the
* notification list is too
* full */
struct mem_cgroup *memcg; /* memcg to charge allocations */
struct user_namespace *user_ns; /* user ns where group was created */
/* groups can define private fields here or use the void *private */
union {
void *private;
#ifdef CONFIG_INOTIFY_USER
struct inotify_group_private_data {
spinlock_t idr_lock;
struct idr idr;
Annotation
- Immediate include surface: `linux/idr.h`, `linux/fs.h`, `linux/list.h`, `linux/path.h`, `linux/spinlock.h`, `linux/types.h`, `linux/atomic.h`, `linux/user_namespace.h`.
- Detected declarations: `struct fsnotify_group`, `struct fsnotify_event`, `struct fsnotify_mark`, `struct fsnotify_event_private_data`, `struct fsnotify_fname`, `struct fsnotify_iter_info`, `struct mem_cgroup`, `struct fsnotify_ops`, `struct fsnotify_event`, `struct fsnotify_group`.
- 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.