fs/pstore/inode.c
Source file repositories/reference/linux-study-clean/fs/pstore/inode.c
File Facts
- System
- Linux kernel
- Corpus path
fs/pstore/inode.c- Extension
.c- Size
- 11965 bytes
- Lines
- 529
- 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.
- 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/fsnotify.hlinux/pagemap.hlinux/highmem.hlinux/time.hlinux/init.hlinux/list.hlinux/string.hlinux/seq_file.hlinux/ramfs.hlinux/fs_parser.hlinux/fs_context.hlinux/sched.hlinux/magic.hlinux/pstore.hlinux/slab.hlinux/uaccess.hlinux/cleanup.hinternal.h
Detected Declarations
struct pstore_privatestruct pstore_ftrace_seq_datastruct pstore_contextfunction free_pstore_privatefunction pstore_ftrace_seq_stopfunction pstore_ftrace_seq_showfunction pstore_file_readfunction pstore_file_openfunction pstore_file_llseekfunction pstore_unlinkfunction pstore_evict_inodefunction pstore_parse_paramfunction pstore_show_optionsfunction pstore_reconfigurefunction pstore_put_backend_recordsfunction scoped_guardfunction pstore_mkfilefunction pstore_get_recordsfunction pstore_fill_superfunction pstore_get_treefunction pstore_free_fcfunction pstore_kill_sbfunction pstore_init_fs_contextfunction pstore_init_fsfunction pstore_exit_fs
Annotated Snippet
static const struct file_operations pstore_file_operations = {
.open = pstore_file_open,
.read = pstore_file_read,
.llseek = pstore_file_llseek,
.release = seq_release,
};
/*
* When a file is unlinked from our file system we call the
* platform driver to erase the record from persistent store.
*/
static int pstore_unlink(struct inode *dir, struct dentry *dentry)
{
struct pstore_private *p = d_inode(dentry)->i_private;
struct pstore_record *record = p->record;
if (!record->psi->erase)
return -EPERM;
/* Make sure we can't race while removing this file. */
scoped_guard(mutex, &records_list_lock) {
if (!list_empty(&p->list))
list_del_init(&p->list);
else
return -ENOENT;
p->dentry = NULL;
}
scoped_guard(mutex, &record->psi->read_mutex)
record->psi->erase(record);
return simple_unlink(dir, dentry);
}
static void pstore_evict_inode(struct inode *inode)
{
struct pstore_private *p = inode->i_private;
clear_inode(inode);
free_pstore_private(p);
}
static const struct inode_operations pstore_dir_inode_operations = {
.lookup = simple_lookup,
.unlink = pstore_unlink,
};
static struct inode *pstore_get_inode(struct super_block *sb)
{
struct inode *inode = new_inode(sb);
if (inode) {
inode->i_ino = get_next_ino();
simple_inode_init_ts(inode);
}
return inode;
}
enum {
Opt_kmsg_bytes
};
static const struct fs_parameter_spec pstore_param_spec[] = {
fsparam_u32 ("kmsg_bytes", Opt_kmsg_bytes),
{}
};
struct pstore_context {
unsigned int kmsg_bytes;
};
static int pstore_parse_param(struct fs_context *fc, struct fs_parameter *param)
{
struct pstore_context *ctx = fc->fs_private;
struct fs_parse_result result;
int opt;
opt = fs_parse(fc, pstore_param_spec, param, &result);
/* pstore has historically ignored invalid kmsg_bytes param */
if (opt < 0)
return 0;
switch (opt) {
case Opt_kmsg_bytes:
ctx->kmsg_bytes = result.uint_32;
break;
default:
return -EINVAL;
}
return 0;
Annotation
- Immediate include surface: `linux/module.h`, `linux/fs.h`, `linux/fsnotify.h`, `linux/pagemap.h`, `linux/highmem.h`, `linux/time.h`, `linux/init.h`, `linux/list.h`.
- Detected declarations: `struct pstore_private`, `struct pstore_ftrace_seq_data`, `struct pstore_context`, `function free_pstore_private`, `function pstore_ftrace_seq_stop`, `function pstore_ftrace_seq_show`, `function pstore_file_read`, `function pstore_file_open`, `function pstore_file_llseek`, `function pstore_unlink`.
- Atlas domain: Core OS / VFS And Filesystem Core.
- Implementation status: pattern implementation candidate.
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.