src/kernel/include/kernel/procfs.h + src/kernel/arch/i386/fs/procfs.c.
Linux-style read-only view of kernel state. Each entry is generated on read by a small renderer that walks live kernel state and writes ASCII into the caller’s buffer. No on-disk storage; nothing is cached between reads.
| Path | Renderer | Content |
|---|---|---|
/proc/cpuinfo |
CPUID leaves 0 + 1 | vendor_id, cpu family, model, stepping, flags (fpu/tsc/msr/pae/apic/cmov/mmx/sse/sse2/sse3/sse4_1/sse4_2), arch i386 (protected mode) |
/proc/meminfo |
pmm_managed_count() + pmm_free_count() + heap_used/free() |
Linux-style key/value: MemTotal, MemFree, MemAvailable, MemUsed, Buffers (0), Cached (0), HeapTotal, HeapUsed, HeapFree, PageSize, FreeFrames, TotalFrames. MemTotal reflects the bootloader-available frame pool minus the null page + kernel image (cached at pmm_init). MemUsed folds in HeapUsed (and MemFree subtracts it): the 16 MiB kernel heap is identity-mapped on top of PMM frames the allocator never reserved, so without this it read near-zero on a fresh boot. |
/proc/tasks |
Walk task_pool[], skip TASK_DEAD |
PID NAME STATE TTY TICKS MEMKB CWD. MEMKB is the per-task memory: the 8 KiB kernel stack plus resident user pages (vmm_count_user_pages(page_dir) * 4), so kernel-only tasks (idle, shells) report their stack baseline and ring-3 apps report stack + RSS. Dead-but-not-yet-reclaimed slots are filtered so userspace tools (maktop / cat /proc/tasks) only see live work; TASK_ZOMBIE slots (slice 16b: children awaiting parent wait4) DO appear so the parent can see them. |
/proc/uname |
MAKAR_VERSION + build macros + timer_get_ticks() |
Makar <MAKAR_VERSION> (i386) built <date> <time> + uptime ticks |
Wired in vfs.c as a new backend (VFS_FS_PROC = 3):
vfs_route() recognises any path under /proc.vfs_ls("/proc") calls procfs_ls() to print the entry list.vfs_cat() / vfs_read_file() route to procfs_read_file().vfs_complete() lets tab-completion enumerate /proc/<entry>.vfs_file_exists() returns 1 for known entries.procfs is flat (no subdirectories) and read-only (no vfs_write_file
path). cd /proc is allowed; cd /proc/cpuinfo is rejected as not-a-dir.
PROC_XXX enum value and an entry to the s_entries[] table.render_xxx(pf_writer_t *w) function using pf_puts, pf_putu,
pf_putc.procfs_read_file.No changes to vfs.c are needed.