Take the 2-minute tour ×
Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems.. It's 100% free, no registration required.

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.

./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

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

How does this mapping work?

share|improve this question
    
Is this more appropriate for stackoverflow? –  hari Sep 21 '11 at 18:10

2 Answers 2

up vote 2 down vote accepted

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.

share|improve this answer

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.

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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