Linux中的“ sys / ioctl.h”标头


8

我在 Linux 2.6.32-26-generic

当我查看“ ioctl.h”听众文件的linux源代码时,我可以看到许多变体。(对于不同的平台,我想)。即

./fs/ocfs2/ioctl.h
./fs/btrfs/ioctl.h
./fs/ceph/ioctl.h
./include/config/i2o/config/old/ioctl.h
./include/asm-generic/ioctl.h
./include/linux/hdlc/ioctl.h
./include/linux/ioctl.h
./drivers/video/via/ioctl.h
./drivers/staging/vt6655/ioctl.h
./drivers/staging/vt6656/ioctl.h
./arch/ia64/include/asm/ioctl.h
./arch/h8300/include/asm/ioctl.h
./arch/microblaze/include/asm/ioctl.h
./arch/score/include/asm/ioctl.h
./arch/avr32/include/asm/ioctl.h
./arch/alpha/include/asm/ioctl.h
./arch/x86/include/asm/ioctl.h
./arch/m32r/include/asm/ioctl.h
./arch/mn10300/include/asm/ioctl.h
./arch/sparc/include/asm/ioctl.h
./arch/powerpc/include/asm/ioctl.h
./arch/m68k/include/asm/ioctl.h
./arch/sh/include/asm/ioctl.h
./arch/xtensa/include/asm/ioctl.h
./arch/mips/include/asm/ioctl.h
./arch/s390/include/asm/ioctl.h
./arch/arm/include/asm/ioctl.h
./arch/blackfin/include/asm/ioctl.h
./arch/frv/include/asm/ioctl.h
./arch/parisc/include/asm/ioctl.h
./arch/cris/include/asm/ioctl.h

但我看到该文件被包含为 #include <sys/ioctl.h>

此映射如何工作?


这更适合stackoverflow吗?
哈里

Answers:


5

我相信包含的文件是/usr/include/sys/ioctl.h(不是来自/ usr / src / linux或某些文件)。在我的系统上,它属于glibc,而不是内核或内核头文件。

实际上,内核源代码没有包含任何内容-/ usr / src / linux(或如此)中的头仅用于内核编译。如果某些软件需要一些内核头文件进行编译,则使用/usr/include/linux(和其他一些)中的文件头,这些文件通常是kernel-headers或包的一部分linux-headers


3

包含文件的默认搜索路径为/usr/include。这是C编译器的一个属性,理论上不同的编译器可以使用不同的路径,但实际上它们都可以查找/usr/include(以及其他一些依赖编译器的位置)。

#include <sys/ioctl.h>表示sys/ioctl.h在include路径中查找相对于条目的名为的文件/usr/include/sys/ioctl.h

除非您正在编译内核模块(或内核本身),否则内核源代码中的标头不相关。C语言库或C编译器随附了Userland程序的标头。

By using our site, you acknowledge that you have read and understand our Cookie Policy and Privacy Policy.
Licensed under cc by-sa 3.0 with attribution required.