fs/tracefs/event_inode.c
Source file repositories/reference/linux-study-clean/fs/tracefs/event_inode.c
File Facts
- System
- Linux kernel
- Corpus path
fs/tracefs/event_inode.c- Extension
.c- Size
- 23700 bytes
- Lines
- 901
- Domain
- Core OS
- Bucket
- VFS And Filesystem Core
- Inferred role
- Core OS: operation-table or driver-model contract
- Status
- pattern 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.
- Defines an operation table; this is where Linux turns generic core objects into subsystem-specific behavior.
- Uses kernel synchronization; read lock ordering, sleepability, and interrupt context assumptions before translating.
- Allocates kernel memory; connect allocation flags and lifetime to context constraints.
- Defines or uses C structs; map object ownership, embedded links, reference counts, and lock ownership.
Dependency Surface
linux/fsnotify.hlinux/fs.hlinux/namei.hlinux/workqueue.hlinux/security.hlinux/tracefs.hlinux/kref.hlinux/delay.hinternal.h
Detected Declarations
struct eventfs_root_inodefunction eventfs_dir_inofunction free_ei_rcufunction inodesfunction put_eifunction free_eifunction cleanup_eifunction update_attrfunction eventfs_set_attrfunction eventfs_set_attrsfunction list_for_each_entryfunction eventfs_remountfunction update_inode_attrfunction eventfs_d_releasefunction lookup_file_dentryfunction list_for_each_entryfunction getdentsfunction scoped_guardfunction scoped_guardfunction list_for_each_entry_srcufunction openfunction scoped_guardfunction eventfs_create_dirfunction eventfs_remove_recfunction eventfs_remove_recfunction eventfs_remove_events_dirfunction eventfs_remount_lockfunction eventfs_remount_unlock
Annotated Snippet
static const struct file_operations eventfs_file_operations = {
.read = generic_read_dir,
.iterate_shared = eventfs_iterate,
.llseek = generic_file_llseek,
};
static void eventfs_set_attrs(struct eventfs_inode *ei, bool update_uid, kuid_t uid,
bool update_gid, kgid_t gid, int level)
{
struct eventfs_inode *ei_child;
lockdep_assert_held(&eventfs_mutex);
/* Update events/<system>/<event> */
if (WARN_ON_ONCE(level > 3))
return;
if (update_uid) {
ei->attr.mode &= ~EVENTFS_SAVE_UID;
ei->attr.uid = uid;
}
if (update_gid) {
ei->attr.mode &= ~EVENTFS_SAVE_GID;
ei->attr.gid = gid;
}
list_for_each_entry(ei_child, &ei->children, list) {
eventfs_set_attrs(ei_child, update_uid, uid, update_gid, gid, level + 1);
}
if (!ei->entry_attrs)
return;
for (int i = 0; i < ei->nr_entries; i++) {
if (update_uid) {
ei->entry_attrs[i].mode &= ~EVENTFS_SAVE_UID;
ei->entry_attrs[i].uid = uid;
}
if (update_gid) {
ei->entry_attrs[i].mode &= ~EVENTFS_SAVE_GID;
ei->entry_attrs[i].gid = gid;
}
}
}
/*
* On a remount of tracefs, if UID or GID options are set, then
* the mount point inode permissions should be used.
* Reset the saved permission flags appropriately.
*/
void eventfs_remount(struct tracefs_inode *ti, bool update_uid, bool update_gid)
{
struct eventfs_inode *ei = ti->private;
/* Only the events directory does the updates */
if (!ei || !ei->is_events || ei->is_freed)
return;
eventfs_set_attrs(ei, update_uid, ti->vfs_inode.i_uid,
update_gid, ti->vfs_inode.i_gid, 0);
}
static void update_inode_attr(struct inode *inode, umode_t mode,
struct eventfs_attr *attr, struct eventfs_root_inode *rei)
{
if (attr && attr->mode & EVENTFS_SAVE_MODE)
inode->i_mode = attr->mode & EVENTFS_MODE_MASK;
else
inode->i_mode = mode;
if (attr && attr->mode & EVENTFS_SAVE_UID)
inode->i_uid = attr->uid;
else
inode->i_uid = rei->ei.attr.uid;
if (attr && attr->mode & EVENTFS_SAVE_GID)
inode->i_gid = attr->gid;
else
inode->i_gid = rei->ei.attr.gid;
}
static struct inode *eventfs_get_inode(struct dentry *dentry, struct eventfs_attr *attr,
umode_t mode, struct eventfs_inode *ei)
{
struct eventfs_root_inode *rei;
struct eventfs_inode *pei;
struct tracefs_inode *ti;
struct inode *inode;
Annotation
- Immediate include surface: `linux/fsnotify.h`, `linux/fs.h`, `linux/namei.h`, `linux/workqueue.h`, `linux/security.h`, `linux/tracefs.h`, `linux/kref.h`, `linux/delay.h`.
- Detected declarations: `struct eventfs_root_inode`, `function eventfs_dir_ino`, `function free_ei_rcu`, `function inodes`, `function put_ei`, `function free_ei`, `function cleanup_ei`, `function update_attr`, `function eventfs_set_attr`, `function eventfs_set_attrs`.
- Atlas domain: Core OS / VFS And Filesystem Core.
- Implementation status: pattern 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.