kernel/gcov/fs.c
Source file repositories/reference/linux-study-clean/kernel/gcov/fs.c
File Facts
- System
- Linux kernel
- Corpus path
kernel/gcov/fs.c- Extension
.c- Size
- 21222 bytes
- Lines
- 882
- Domain
- Core OS
- Bucket
- Scheduler, Processes, Timers, Sync, And Syscalls
- 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/init.hlinux/module.hlinux/debugfs.hlinux/fs.hlinux/list.hlinux/string.hlinux/slab.hlinux/mutex.hlinux/seq_file.hlinux/mm.hgcov.h
Detected Declarations
struct gcov_nodestruct gcov_iteratorfunction gcov_persist_setupfunction gcov_iter_freefunction gcov_iter_startfunction gcov_iter_nextfunction gcov_iter_writefunction gcov_seq_showfunction gcov_seq_stopfunction openfunction releasefunction list_for_each_entryfunction reset_nodefunction writefunction filesfunction init_nodefunction remove_linksfunction release_nodefunction remove_nodefunction list_for_each_entryfunction writefunction reset_readfunction add_nodefunction add_infofunction get_info_indexfunction save_infofunction remove_infofunction gcov_eventfunction gcov_fs_initmodule init gcov_fs_init
Annotated Snippet
static const struct file_operations gcov_data_fops = {
.open = gcov_seq_open,
.release = gcov_seq_release,
.read = seq_read,
.llseek = seq_lseek,
.write = gcov_seq_write,
};
/* Basic initialization of a new node. */
static void init_node(struct gcov_node *node, struct gcov_info *info,
const char *name, struct gcov_node *parent)
{
INIT_LIST_HEAD(&node->list);
INIT_LIST_HEAD(&node->children);
INIT_LIST_HEAD(&node->all);
if (node->loaded_info) {
node->loaded_info[0] = info;
node->num_loaded = 1;
}
node->parent = parent;
if (name)
strcpy(node->name, name);
}
/*
* Create a new node and associated debugfs entry. Needs to be called with
* node_lock held.
*/
static struct gcov_node *new_node(struct gcov_node *parent,
struct gcov_info *info, const char *name)
{
struct gcov_node *node;
node = kzalloc(sizeof(struct gcov_node) + strlen(name) + 1, GFP_KERNEL);
if (!node)
goto err_nomem;
if (info) {
node->loaded_info = kzalloc_objs(struct gcov_info *, 1);
if (!node->loaded_info)
goto err_nomem;
}
init_node(node, info, name, parent);
/* Differentiate between gcov data file nodes and directory nodes. */
if (info) {
node->dentry = debugfs_create_file(deskew(node->name), 0600,
parent->dentry, node, &gcov_data_fops);
} else
node->dentry = debugfs_create_dir(node->name, parent->dentry);
if (info)
add_links(node, parent->dentry);
list_add(&node->list, &parent->children);
list_add(&node->all, &all_head);
return node;
err_nomem:
kfree(node);
pr_warn("out of memory\n");
return NULL;
}
/* Remove symbolic links associated with node. */
static void remove_links(struct gcov_node *node)
{
int i;
if (!node->links)
return;
for (i = 0; gcov_link[i].ext; i++)
debugfs_remove(node->links[i]);
kfree(node->links);
node->links = NULL;
}
/*
* Remove node from all lists and debugfs and release associated resources.
* Needs to be called with node_lock held.
*/
static void release_node(struct gcov_node *node)
{
list_del(&node->list);
list_del(&node->all);
debugfs_remove(node->dentry);
remove_links(node);
kfree(node->loaded_info);
if (node->unloaded_info)
gcov_info_free(node->unloaded_info);
kfree(node);
}
Annotation
- Immediate include surface: `linux/init.h`, `linux/module.h`, `linux/debugfs.h`, `linux/fs.h`, `linux/list.h`, `linux/string.h`, `linux/slab.h`, `linux/mutex.h`.
- Detected declarations: `struct gcov_node`, `struct gcov_iterator`, `function gcov_persist_setup`, `function gcov_iter_free`, `function gcov_iter_start`, `function gcov_iter_next`, `function gcov_iter_write`, `function gcov_seq_show`, `function gcov_seq_stop`, `function open`.
- Atlas domain: Core OS / Scheduler, Processes, Timers, Sync, And Syscalls.
- 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.