tracefs: Add read-only eventfs filesystem at /sys/kernel/events
Introduce a new read-only pseudo-filesystem "eventfs" mounted at
/sys/kernel/events that exposes trace event format and id files
(mode 0444) to unprivileged users. This allows tools like perf to
discover event formats without requiring access to the full
tracefs/debugfs mount.
The eventfs file system reuses the existing eventfs_inode lazy-lookup
infrastructure. A new set of super_operations
(eventfs_ro_super_operations) shares the tracefs inode allocator so
that eventfs_get_inode() and get_tracefs() work on the RO superblock.
The superblock is manually initialized to ensure the root inode is
allocated with tracefs_alloc_inode, allowing the root to serve
directly as the events directory without another events subdirectory.
Each qualifying event gets a subsystem directory containing format
and id files. The top-level events directory also exposes header_page
and header_event. Similar to tracefs, a change will need to be made in
systemd to mount this filesystem automatically.
[
Steven Rostedt rewrote to use the lookup functions to determine read
only files to show. The struct eventfs_entry now has a "readonly" field
and if it is set, it will be displayed in the read only file system.
The original code [1] duplicated the eventfs_inodes for every event and
subsystem. The new approach uses the existing eventfs_inodes (without
requiring more memory to store them) and uses the eventfs_entry arrays to
show which files are allowed to be read readonly or not.
[1] https://patch.msgid.link/20260715135231.338535-4-ashelat@redhat.com
]
Link: https://patch.msgid.link/20261103175534.6bd94b13@gandalf.local.home
Assisted-by: CLAUDE:claude-opus-4 Apogee
Signed-off-by: Anubhav Shelat <ashelat@redhat.com>
Signed-off-by: Steven Rostedt <rostedt@goodmis.org>
6 files changed