fs/pstore/ram.c
Source file repositories/reference/linux-study-clean/fs/pstore/ram.c
File Facts
- System
- Linux kernel
- Corpus path
fs/pstore/ram.c- Extension
.c- Size
- 26489 bytes
- Lines
- 1000
- Domain
- Core OS
- Bucket
- VFS And Filesystem Core
- Inferred role
- Core OS: exported/initcall integration point
- Status
- integration 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.
- Exports symbols or registers init work; inspect boot/module ordering and who consumes the exported contract.
- 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/kernel.hlinux/err.hlinux/module.hlinux/version.hlinux/pstore.hlinux/io.hlinux/ioport.hlinux/platform_device.hlinux/slab.hlinux/compiler.hlinux/of.hlinux/of_address.hlinux/mm.hinternal.hram_internal.h
Detected Declarations
struct ramoops_contextfunction ramoops_pstore_openfunction ramoops_get_next_przfunction ramoops_read_kmsg_hdrfunction prz_okfunction ramoops_pstore_readfunction ramoops_write_kmsg_hdrfunction ramoops_pstore_writefunction ramoops_pstore_write_userfunction ramoops_pstore_erasefunction ramoops_free_przsfunction ramoops_init_przsfunction ramoops_init_przfunction ramoops_parse_dt_u32function ramoops_parse_dtfunction ramoops_probefunction recordfunction ramoops_removefunction ramoops_unregister_dummyfunction ramoops_register_dummyfunction ramoops_initfunction ramoops_exit
Annotated Snippet
struct ramoops_context {
struct persistent_ram_zone **dprzs; /* Oops dump zones */
struct persistent_ram_zone *cprz; /* Console zone */
struct persistent_ram_zone **fprzs; /* Ftrace zones */
struct persistent_ram_zone *mprz; /* PMSG zone */
phys_addr_t phys_addr;
unsigned long size;
unsigned int memtype;
size_t record_size;
size_t console_size;
size_t ftrace_size;
size_t pmsg_size;
u32 flags;
struct persistent_ram_ecc_info ecc_info;
unsigned int max_dump_cnt;
unsigned int dump_write_cnt;
/* _read_cnt need clear on ramoops_pstore_open */
unsigned int dump_read_cnt;
unsigned int console_read_cnt;
unsigned int max_ftrace_cnt;
unsigned int ftrace_read_cnt;
unsigned int pmsg_read_cnt;
struct pstore_info pstore;
};
static struct platform_device *dummy;
static int ramoops_pstore_open(struct pstore_info *psi)
{
struct ramoops_context *cxt = psi->data;
cxt->dump_read_cnt = 0;
cxt->console_read_cnt = 0;
cxt->ftrace_read_cnt = 0;
cxt->pmsg_read_cnt = 0;
return 0;
}
static struct persistent_ram_zone *
ramoops_get_next_prz(struct persistent_ram_zone *przs[], int id,
struct pstore_record *record)
{
struct persistent_ram_zone *prz;
/* Give up if we never existed or have hit the end. */
if (!przs)
return NULL;
prz = przs[id];
if (!prz)
return NULL;
/* Update old/shadowed buffer. */
if (prz->type == PSTORE_TYPE_DMESG)
persistent_ram_save_old(prz);
if (!persistent_ram_old_size(prz))
return NULL;
record->type = prz->type;
record->id = id;
return prz;
}
static int ramoops_read_kmsg_hdr(char *buffer, struct timespec64 *time,
bool *compressed)
{
char data_type;
int header_length = 0;
if (sscanf(buffer, RAMOOPS_KERNMSG_HDR "%lld.%lu-%c\n%n",
(time64_t *)&time->tv_sec, &time->tv_nsec, &data_type,
&header_length) == 3) {
time->tv_nsec *= 1000;
if (data_type == 'C')
*compressed = true;
else
*compressed = false;
} else if (sscanf(buffer, RAMOOPS_KERNMSG_HDR "%lld.%lu\n%n",
(time64_t *)&time->tv_sec, &time->tv_nsec,
&header_length) == 2) {
time->tv_nsec *= 1000;
*compressed = false;
} else {
time->tv_sec = 0;
time->tv_nsec = 0;
*compressed = false;
}
return header_length;
Annotation
- Immediate include surface: `linux/kernel.h`, `linux/err.h`, `linux/module.h`, `linux/version.h`, `linux/pstore.h`, `linux/io.h`, `linux/ioport.h`, `linux/platform_device.h`.
- Detected declarations: `struct ramoops_context`, `function ramoops_pstore_open`, `function ramoops_get_next_prz`, `function ramoops_read_kmsg_hdr`, `function prz_ok`, `function ramoops_pstore_read`, `function ramoops_write_kmsg_hdr`, `function ramoops_pstore_write`, `function ramoops_pstore_write_user`, `function ramoops_pstore_erase`.
- Atlas domain: Core OS / VFS And Filesystem Core.
- Implementation status: integration 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.