fs/proc/uptime.c
Source file repositories/reference/linux-study-clean/fs/proc/uptime.c
File Facts
- System
- Linux kernel
- Corpus path
fs/proc/uptime.c- Extension
.c- Size
- 1072 bytes
- Lines
- 46
- Domain
- Core OS
- Bucket
- VFS And Filesystem Core
- Inferred role
- Core OS: implementation source
- Status
- source 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 or uses C structs; map object ownership, embedded links, reference counts, and lock ownership.
Dependency Surface
linux/fs.hlinux/init.hlinux/proc_fs.hlinux/sched.hlinux/seq_file.hlinux/time.hlinux/time_namespace.hlinux/kernel_stat.hinternal.h
Detected Declarations
function uptime_proc_showfunction proc_uptime_initmodule init proc_uptime_init
Annotated Snippet
// SPDX-License-Identifier: GPL-2.0
#include <linux/fs.h>
#include <linux/init.h>
#include <linux/proc_fs.h>
#include <linux/sched.h>
#include <linux/seq_file.h>
#include <linux/time.h>
#include <linux/time_namespace.h>
#include <linux/kernel_stat.h>
#include "internal.h"
static int uptime_proc_show(struct seq_file *m, void *v)
{
struct timespec64 uptime;
struct timespec64 idle;
u64 idle_nsec;
u32 rem;
int i;
idle_nsec = 0;
for_each_possible_cpu(i)
idle_nsec += kcpustat_field(CPUTIME_IDLE, i);
ktime_get_boottime_ts64(&uptime);
timens_add_boottime(&uptime);
idle.tv_sec = div_u64_rem(idle_nsec, NSEC_PER_SEC, &rem);
idle.tv_nsec = rem;
seq_printf(m, "%lu.%02lu %lu.%02lu\n",
(unsigned long) uptime.tv_sec,
(uptime.tv_nsec / (NSEC_PER_SEC / 100)),
(unsigned long) idle.tv_sec,
(idle.tv_nsec / (NSEC_PER_SEC / 100)));
return 0;
}
static int __init proc_uptime_init(void)
{
struct proc_dir_entry *pde;
pde = proc_create_single("uptime", 0, NULL, uptime_proc_show);
pde_make_permanent(pde);
return 0;
}
fs_initcall(proc_uptime_init);
Annotation
- Immediate include surface: `linux/fs.h`, `linux/init.h`, `linux/proc_fs.h`, `linux/sched.h`, `linux/seq_file.h`, `linux/time.h`, `linux/time_namespace.h`, `linux/kernel_stat.h`.
- Detected declarations: `function uptime_proc_show`, `function proc_uptime_init`, `module init proc_uptime_init`.
- Atlas domain: Core OS / VFS And Filesystem Core.
- Implementation status: source 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.