I am on Linux 2.6.32-26-generic

When I look in to the linux source code for "ioctl.h" hearer file, I could see many variants. (for different platforms, I guess). i.e.


But I see that file being included as #include <sys/ioctl.h>

How does this mapping work?

  • Is this more appropriate for stackoverflow? – hari Sep 21 '11 at 18:10

I believe file is being included is /usr/include/sys/ioctl.h (not from /usr/src/linux or some). And on my system it belongs to glibc, not kernel or kernel-headers.

Actually, nothing gets included from kernel source - headers inside /usr/src/linux (or so) are being used only for kernel compilation. If some software needs some kernel headers to compile it uses ones in /usr/include/linux (and some others), which are usually part of package like kernel-headers or linux-headers.


The default search path for include files is /usr/include. This is a property of the C compiler, and in theory different compilers could use different paths, but in practice they all look in /usr/include (and a few other compiler-dependent places).

#include <sys/ioctl.h> means to look for a file called sys/ioctl.h relatively to an entry in the include path, thus /usr/include/sys/ioctl.h.

The headers in the kernel source are not relevant unless you are compiling a kernel module (or the kernel itself). Headers for userland programs come with the C library or with the C compiler.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.