Procfs is an in-memory file system. This is an interface for user space for collecting information and entering (configuring) information into kernel data structures. In other words, procfs allows user space to interact and analyze kernel data structures as they exist at run time.
Therefore, any file inside / proc is not intended to be read from within the kernel or kernel module. And why should this be done? In a monolithic kernel, such as Linux, you can access the data structures of one subsystem in the kernel through another directly or through a predefined function.
The following function call may help:
struct timespec uptime; do_posix_clock_monotonic_gettime(&uptime);
You can refer to the / proc / uptime implementation from the link below, it is essentially a seq_file .
http://lxr.free-electrons.com/source/fs/proc/uptime.c
source share