fs/tracefs/inode.c
Source file repositories/reference/linux-study-clean/fs/tracefs/inode.c
File Facts
- System
- Linux kernel
- Corpus path
fs/tracefs/inode.c- Extension
.c- Size
- 21609 bytes
- Lines
- 810
- 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/module.hlinux/fs.hlinux/fs_context.hlinux/fs_parser.hlinux/kobject.hlinux/namei.hlinux/tracefs.hlinux/fsnotify.hlinux/security.hlinux/seq_file.hlinux/magic.hlinux/slab.hinternal.h
Detected Declarations
struct tracefs_fs_infofunction tracefs_free_inodefunction tracefs_destroy_inodefunction default_read_filefunction default_write_filefunction tracefs_syscall_rmdirfunction set_tracefs_inode_ownerfunction tracefs_permissionfunction tracefs_getattrfunction tracefs_setattrfunction tracefs_parse_paramfunction tracefs_apply_optionsfunction list_for_each_entry_rcufunction tracefs_reconfigurefunction tracefs_show_optionsfunction tracefs_drop_inodefunction tracefs_d_releasefunction tracefs_d_revalidatefunction tracefs_d_deletefunction tracefs_fill_superfunction tracefs_get_treefunction tracefs_free_fcfunction tracefs_init_fs_contextfunction openfunction tracefs_removefunction infunction remove_onefunction tracefs_removefunction tracefs_initializedfunction init_oncefunction tracefs_initmodule init tracefs_initexport tracefs_create_file
Annotated Snippet
static const struct file_operations tracefs_file_operations = {
.read = default_read_file,
.write = default_write_file,
.open = simple_open,
.llseek = noop_llseek,
};
static struct tracefs_dir_ops {
int (*mkdir)(const char *name);
int (*rmdir)(const char *name);
} tracefs_ops __ro_after_init;
static struct dentry *tracefs_syscall_mkdir(struct mnt_idmap *idmap,
struct inode *inode, struct dentry *dentry,
umode_t mode)
{
struct tracefs_inode *ti;
struct name_snapshot name;
int ret;
/*
* This is a new directory that does not take the default of
* the rootfs. It becomes the default permissions for all the
* files and directories underneath it.
*/
ti = get_tracefs(inode);
ti->flags |= TRACEFS_INSTANCE_INODE;
ti->private = inode;
/*
* The mkdir call can call the generic functions that create
* the files within the tracefs system. It is up to the individual
* mkdir routine to handle races.
*/
take_dentry_name_snapshot(&name, dentry);
inode_unlock(inode);
ret = tracefs_ops.mkdir(name.name.name);
inode_lock(inode);
release_dentry_name_snapshot(&name);
return ERR_PTR(ret);
}
static int tracefs_syscall_rmdir(struct inode *inode, struct dentry *dentry)
{
struct name_snapshot name;
int ret;
/*
* The rmdir call can call the generic functions that create
* the files within the tracefs system. It is up to the individual
* rmdir routine to handle races.
* This time we need to unlock not only the parent (inode) but
* also the directory that is being deleted.
*/
take_dentry_name_snapshot(&name, dentry);
inode_unlock(inode);
inode_unlock(d_inode(dentry));
ret = tracefs_ops.rmdir(name.name.name);
inode_lock_nested(inode, I_MUTEX_PARENT);
inode_lock(d_inode(dentry));
release_dentry_name_snapshot(&name);
return ret;
}
static void set_tracefs_inode_owner(struct inode *inode)
{
struct tracefs_inode *ti = get_tracefs(inode);
struct inode *root_inode = ti->private;
kuid_t uid;
kgid_t gid;
uid = root_inode->i_uid;
gid = root_inode->i_gid;
/*
* If the root is not the mount point, then check the root's
* permissions. If it was never set, then default to the
* mount point.
*/
if (root_inode != d_inode(root_inode->i_sb->s_root)) {
struct tracefs_inode *rti;
rti = get_tracefs(root_inode);
root_inode = d_inode(root_inode->i_sb->s_root);
if (!(rti->flags & TRACEFS_UID_PERM_SET))
Annotation
- Immediate include surface: `linux/module.h`, `linux/fs.h`, `linux/fs_context.h`, `linux/fs_parser.h`, `linux/kobject.h`, `linux/namei.h`, `linux/tracefs.h`, `linux/fsnotify.h`.
- Detected declarations: `struct tracefs_fs_info`, `function tracefs_free_inode`, `function tracefs_destroy_inode`, `function default_read_file`, `function default_write_file`, `function tracefs_syscall_rmdir`, `function set_tracefs_inode_owner`, `function tracefs_permission`, `function tracefs_getattr`, `function tracefs_setattr`.
- 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.