fs/ubifs/debug.c
Source file repositories/reference/linux-study-clean/fs/ubifs/debug.c
File Facts
- System
- Linux kernel
- Corpus path
fs/ubifs/debug.c- Extension
.c- Size
- 84434 bytes
- Lines
- 3053
- 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.
- Touches user memory; correctness depends on fault-safe copying and privilege boundary handling.
- 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/debugfs.hlinux/math64.hlinux/uaccess.hlinux/random.hlinux/ctype.hubifs.h
Detected Declarations
struct fsck_inodestruct fsck_datafunction dump_chfunction ubifs_dump_inodefunction ubifs_dump_nodefunction ubifs_dump_budget_reqfunction ubifs_dump_lstatsfunction ubifs_dump_budgfunction ubifs_dump_lpropfunction ubifs_dump_lpropsfunction ubifs_dump_lpt_infofunction ubifs_dump_lebfunction list_for_each_entryfunction ubifs_dump_znodefunction ubifs_dump_heapfunction ubifs_dump_pnodefunction ubifs_dump_tncfunction dump_znodefunction ubifs_dump_indexfunction dbg_save_space_infofunction dbg_check_space_infofunction dbg_check_synced_i_sizefunction dbg_check_dirfunction dbg_check_key_orderfunction dbg_check_znodefunction dbg_check_tncfunction dbg_walk_indexfunction add_sizefunction dbg_check_idx_sizefunction check_leaffunction free_inodesfunction check_inodesfunction dbg_check_filesystemfunction dbg_check_data_nodes_orderfunction dbg_check_nondata_nodes_orderfunction chancefunction power_cut_emulatedfunction corrupt_datafunction dbg_leb_writefunction dbg_leb_changefunction dbg_leb_unmapfunction dbg_leb_mapfunction dfs_file_openfunction provide_user_outputfunction dfs_file_readfunction interpret_user_inputfunction dfs_file_writefunction dbg_debugfs_init_fs
Annotated Snippet
static const struct file_operations dfs_fops = {
.open = dfs_file_open,
.read = dfs_file_read,
.write = dfs_file_write,
.owner = THIS_MODULE,
};
/**
* dbg_debugfs_init_fs - initialize debugfs for UBIFS instance.
* @c: UBIFS file-system description object
*
* This function creates all debugfs files for this instance of UBIFS.
*
* Note, the only reason we have not merged this function with the
* 'ubifs_debugging_init()' function is because it is better to initialize
* debugfs interfaces at the very end of the mount process, and remove them at
* the very beginning of the mount process.
*/
void dbg_debugfs_init_fs(struct ubifs_info *c)
{
int n;
const char *fname;
struct ubifs_debug_info *d = c->dbg;
n = snprintf(d->dfs_dir_name, UBIFS_DFS_DIR_LEN, UBIFS_DFS_DIR_NAME,
c->vi.ubi_num, c->vi.vol_id);
if (n >= UBIFS_DFS_DIR_LEN) {
/* The array size is too small */
return;
}
fname = d->dfs_dir_name;
d->dfs_dir = debugfs_create_dir(fname, dfs_rootdir);
fname = "dump_lprops";
d->dfs_dump_lprops = debugfs_create_file(fname, S_IWUSR, d->dfs_dir, c,
&dfs_fops);
fname = "dump_budg";
d->dfs_dump_budg = debugfs_create_file(fname, S_IWUSR, d->dfs_dir, c,
&dfs_fops);
fname = "dump_tnc";
d->dfs_dump_tnc = debugfs_create_file(fname, S_IWUSR, d->dfs_dir, c,
&dfs_fops);
fname = "chk_general";
d->dfs_chk_gen = debugfs_create_file(fname, S_IRUSR | S_IWUSR,
d->dfs_dir, c, &dfs_fops);
fname = "chk_index";
d->dfs_chk_index = debugfs_create_file(fname, S_IRUSR | S_IWUSR,
d->dfs_dir, c, &dfs_fops);
fname = "chk_orphans";
d->dfs_chk_orph = debugfs_create_file(fname, S_IRUSR | S_IWUSR,
d->dfs_dir, c, &dfs_fops);
fname = "chk_lprops";
d->dfs_chk_lprops = debugfs_create_file(fname, S_IRUSR | S_IWUSR,
d->dfs_dir, c, &dfs_fops);
fname = "chk_fs";
d->dfs_chk_fs = debugfs_create_file(fname, S_IRUSR | S_IWUSR,
d->dfs_dir, c, &dfs_fops);
fname = "tst_recovery";
d->dfs_tst_rcvry = debugfs_create_file(fname, S_IRUSR | S_IWUSR,
d->dfs_dir, c, &dfs_fops);
fname = "ro_error";
d->dfs_ro_error = debugfs_create_file(fname, S_IRUSR | S_IWUSR,
d->dfs_dir, c, &dfs_fops);
}
/**
* dbg_debugfs_exit_fs - remove all debugfs files.
* @c: UBIFS file-system description object
*/
void dbg_debugfs_exit_fs(struct ubifs_info *c)
{
debugfs_remove_recursive(c->dbg->dfs_dir);
}
struct ubifs_global_debug_info ubifs_dbg;
static struct dentry *dfs_chk_gen;
static struct dentry *dfs_chk_index;
static struct dentry *dfs_chk_orph;
static struct dentry *dfs_chk_lprops;
Annotation
- Immediate include surface: `linux/module.h`, `linux/debugfs.h`, `linux/math64.h`, `linux/uaccess.h`, `linux/random.h`, `linux/ctype.h`, `ubifs.h`.
- Detected declarations: `struct fsck_inode`, `struct fsck_data`, `function dump_ch`, `function ubifs_dump_inode`, `function ubifs_dump_node`, `function ubifs_dump_budget_req`, `function ubifs_dump_lstats`, `function ubifs_dump_budg`, `function ubifs_dump_lprop`, `function ubifs_dump_lprops`.
- Atlas domain: Core OS / VFS And Filesystem Core.
- Implementation status: pattern implementation candidate.
- This snippet crosses the user/kernel memory boundary; validate fault handling and access checks before translating the pattern.
- 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.