Sysinfo struct in linux / kernel.h

I followed a look at various kernel header files and came across <linux/kernel.h>. Inside is a structure called sysinfo.

I tried to use it out of the box, so to speak, and all the values ​​in the structure returned. I assume that I need to use the poplating function mentioned above do_sysinfo(struct sysinfo *info).

The fact is that I can not find any information that refers to its use. I tried the function out of the box and it failed because it could not be connected. Does anyone have any info on how to use this or why it doesn't work? I am new to this area. If you had any links to good guides / information, that would be great.

+5
source share
2 answers

I assume that you tried to call this function from user space. This is not possible because this header is for kernel use only, except that struct sysinfo is "generic".

You probably want to use a system call int sysinfo(struct sysinfo *info)by enabling sys/sysinfo.hto populate struct sysinfo.

+5
source

do_sysinfo- implementation on the core side; it is not available from userland. System call sysinfoavailable; this is what fills the structure:

#include <sys/sysinfo.h>

...

struct sysinfo info;
sysinfo(&info);

Please note that in the section /proc(eg, /proc/uptime, /proc/cpuinfo, /proc/meminfo), there is much more information available in the analysis files.

+4
source

All Articles