c - linux/kernel.h 中的 sysinfo 结构

标签 c linux header kernel

我在查看各种内核头文件时无意中发现了 <linux/kernel.h> .里面有一个叫做sysinfo的结构。 .

我已经尝试开箱即用,可以这么说,并且结构中的所有值都返回了 0。我猜我需要使用上面称为 do_sysinfo(struct sysinfo *info) 的 poplating 函数.

问题是我找不到任何关于如何使用它的信息。我开箱即用地尝试了该功能,但由于无法链接而失败。任何人都有关于如何使用它或为什么它失败的任何信息?我是这个领域的新手。想要任何指向好的指南/信息的链接,如果有的话,那就太好了。

最佳答案

我猜你试图从用户空间调用那个函数。这是不可能的,因为该 header 仅供内核使用,除了“共享”的 struct sysinfo。

您可能希望通过包含 sys/sysinfo.h 来使用系统调用 int sysinfo(struct sysinfo *info) 以填充 struct sysinfo

关于c - linux/kernel.h 中的 sysinfo 结构,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/9572680/

相关文章:

linux - 限制 Squid 只能访问一个站点

c++ - VS代码: How to add include path of project subDirectory?

c - 如何在编译时定义由来自不同模块的静态(私有(private))结构组成的结构数组?

c - 尝试更改 char* 指针位置时出现 "Error: expression must be a modifiable lvalue"

linux - Qt,Linux,检查给定用户是否有sudo权限

php - UTF-8贯穿始终

JQuery 问题 - 直到滚动时 Logo 才会显示

jquery mobile 添加 listview 到 "navbar in footer "

c - ansi c 中的结构语法,带有逗号,多个字段只有一个类型声明

c - Windows GDI : Difference Between a Pattern Brush & BitBlt of a Bitmap