/usr/include/linux和linux内核源代码中的include文件夹有什么区别? [英] What's the difference between /usr/include/linux and the include folder in linux kernel source?

查看:309
本文介绍了/usr/include/linux和linux内核源代码中的include文件夹有什么区别?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在刚安装的Ubuntu上,我在/usr/include/linux/usr/src/kernel-version-headers/include/linux

On a freshly installed Ubuntu , i found kernel headers in both /usr/include/linux , and /usr/src/kernel-version-headers/include/linux

它们彼此相同吗?

推荐答案

它们非常不同; /usr/include/linux标头是在编译系统的标准C库时使用的标头.它们归C库包装所有,并与标准C库同步更新.它们的存在是为了向内核提供 userland 接口,正如C库所理解和经纪"的 1 一样.

They are very different; the /usr/include/linux headers are the headers that were used when compiling the system's standard C library. They are owned by the C library packaging, and updated in lockstep with the standard C library. They exist to provide the userland interface to the kernel, as understood and "brokered"1 by the C library.

/usr/src/linux-headers-$(uname -r)/include/linux标头通过/lib/modules/$(uname -r)/build符号链接使用.它们由内核头文件包拥有,并与内核同步更新.这些是内核头文件的子集,并且是构建树外内核模块所需的足够的Kbuild系统.这些文件表示内核内部结构 -如果模块要正确理解内存中的对象,则必须针对这些模块进行构建.有关一些详细信息,请参见内核的Documentation/kbuild/modules.txt文件.

The /usr/src/linux-headers-$(uname -r)/include/linux headers are used via the /lib/modules/$(uname -r)/build symbolic links. They are owned by the kernel headers packages and updated in lockstep with the kernel. These are a subset of the kernel headers and enough of the Kbuild system required to build out-of-tree kernel modules. These files represent the kernel internals -- modules must build against these if they are to properly understand in-memory objects. See the kernel's Documentation/kbuild/modules.txt file for some details.

1:中介"是我的第一个字选择,但这意味着某种访问控制,事实并非如此. "Brokered"表示第三方过程,但事实并非如此.考虑:当C程序调用_exit()时,它实际上是在调用标准C库的_exit() wrapper ,后者又调用了exit(2)系统调用. select(2)接口对可以跟踪的文件描述符的数量有上限,并且该限制已编译到标准C库中.即使扩展了内核的接口,也需要重新编译C库.

1: "Mediated" was my first word choice, but it implies some sort of access controls, which isn't the case. "Brokered" implies a third-party process, but that is also not the case. Consider: when a C program calls _exit(), it is actually calling the Standard C library's _exit() wrapper, which calls the exit(2) system call. The select(2) interface has an upper limit on the number of file descriptors that can be tracked, and that limit is compiled into the standard C library. Even if the kernel's interface were extended, the C library would also need to be recompiled.

这篇关于/usr/include/linux和linux内核源代码中的include文件夹有什么区别?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆