fs/debugfs/inode.c
Source file repositories/reference/linux-study-clean/fs/debugfs/inode.c
File Facts
- System
- Linux kernel
- Corpus path
fs/debugfs/inode.c- Extension
.c- Size
- 26782 bytes
- Lines
- 930
- 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/pagemap.hlinux/init.hlinux/kobject.hlinux/namei.hlinux/debugfs.hlinux/fsnotify.hlinux/string.hlinux/seq_file.hlinux/magic.hlinux/slab.hlinux/security.hinternal.h
Detected Declarations
struct debugfs_fs_infofunction debugfs_setattrfunction debugfs_parse_paramfunction _debugfs_apply_optionsfunction debugfs_apply_optionsfunction debugfs_apply_options_remountfunction debugfs_reconfigurefunction debugfs_show_optionsfunction init_oncefunction debugfs_free_inodefunction debugfs_release_dentryfunction debugfs_fill_superfunction debugfs_get_treefunction debugfs_free_fcfunction debugfs_init_fs_contextfunction debugfs_lookupfunction openfunction openfunction debugfs_removefunction debugfs_removefunction __debugfs_file_removedfunction debugfs_file_getfunction remove_onefunction debugfs_removefunction debugfs_removefunction __printffunction debugfs_initializedfunction debugfs_kernelfunction debugfs_initmodule init debugfs_initexport debugfs_lookupexport debugfs_create_file_fullexport debugfs_create_file_shortexport debugfs_create_file_unsafeexport debugfs_create_file_sizeexport debugfs_create_direxport debugfs_create_automountexport debugfs_create_symlinkexport debugfs_removeexport debugfs_lookup_and_removeexport debugfs_change_nameexport debugfs_initialized
Annotated Snippet
const struct file_operations *proxy_fops,
const void *real_fops)
{
struct dentry *dentry;
struct inode *inode;
if (!(mode & S_IFMT))
mode |= S_IFREG;
BUG_ON(!S_ISREG(mode));
dentry = debugfs_start_creating(name, parent);
if (IS_ERR(dentry))
return dentry;
inode = debugfs_get_inode(dentry->d_sb);
if (unlikely(!inode)) {
pr_err("out of free dentries, can not create file '%s'\n",
name);
return debugfs_failed_creating(dentry);
}
inode->i_mode = mode;
inode->i_private = data;
inode->i_op = &debugfs_file_inode_operations;
if (!real_fops)
proxy_fops = &debugfs_noop_file_operations;
inode->i_fop = proxy_fops;
DEBUGFS_I(inode)->raw = real_fops;
DEBUGFS_I(inode)->aux = (void *)aux;
d_make_persistent(dentry, inode);
fsnotify_create(d_inode(dentry->d_parent), dentry);
return debugfs_end_creating(dentry);
}
struct dentry *debugfs_create_file_full(const char *name, umode_t mode,
struct dentry *parent, void *data,
const void *aux,
const struct file_operations *fops)
{
return __debugfs_create_file(name, mode, parent, data, aux,
&debugfs_full_proxy_file_operations,
fops);
}
EXPORT_SYMBOL_GPL(debugfs_create_file_full);
struct dentry *debugfs_create_file_short(const char *name, umode_t mode,
struct dentry *parent, void *data,
const void *aux,
const struct debugfs_short_fops *fops)
{
return __debugfs_create_file(name, mode, parent, data, aux,
&debugfs_full_short_proxy_file_operations,
fops);
}
EXPORT_SYMBOL_GPL(debugfs_create_file_short);
/**
* debugfs_create_file_unsafe - create a file in the debugfs filesystem
* @name: a pointer to a string containing the name of the file to create.
* @mode: the permission that the file should have.
* @parent: a pointer to the parent dentry for this file. This should be a
* directory dentry if set. If this parameter is NULL, then the
* file will be created in the root of the debugfs filesystem.
* @data: a pointer to something that the caller will want to get to later
* on. The inode.i_private pointer will point to this value on
* the open() call.
* @fops: a pointer to a struct file_operations that should be used for
* this file.
*
* debugfs_create_file_unsafe() is completely analogous to
* debugfs_create_file(), the only difference being that the fops
* handed it will not get protected against file removals by the
* debugfs core.
*
* It is your responsibility to protect your struct file_operation
* methods against file removals by means of debugfs_file_get()
* and debugfs_file_put(). ->open() is still protected by
* debugfs though.
*
* Any struct file_operations defined by means of
* DEFINE_DEBUGFS_ATTRIBUTE() is protected against file removals and
* thus, may be used here.
*/
struct dentry *debugfs_create_file_unsafe(const char *name, umode_t mode,
struct dentry *parent, void *data,
const struct file_operations *fops)
{
Annotation
- Immediate include surface: `linux/module.h`, `linux/fs.h`, `linux/fs_context.h`, `linux/fs_parser.h`, `linux/pagemap.h`, `linux/init.h`, `linux/kobject.h`, `linux/namei.h`.
- Detected declarations: `struct debugfs_fs_info`, `function debugfs_setattr`, `function debugfs_parse_param`, `function _debugfs_apply_options`, `function debugfs_apply_options`, `function debugfs_apply_options_remount`, `function debugfs_reconfigure`, `function debugfs_show_options`, `function init_once`, `function debugfs_free_inode`.
- 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.