pull in the libc versions of these headers so that the proper userspace defines/typedefs are utilized. the trouble here is that some of the linux/ headers define structs that the libc net/ headers define (like the if.h header). we cannot simply say "your program should not include linux/if.h when using net/if.h" because some of the other linux/ headers may correctly be utilized with net/if.h but they correctly include linux/if.h. we also cannot say "just use the linux/ headers and not the libc net/ headers" because the libc headers include more definitions than its kernel equivalent. since there is no obvious (at least to me) answer here, we hack the linux/ headers to simply pull in userspace headers and ignore the linux/ ones completely. this seems to give a proper clean userspace experience. --- a/include/linux/socket.h +++ b/include/linux/socket.h @@ -303,4 +303,9 @@ extern int put_cmsg(struct msghdr*, int #endif #endif /* not kernel and not glibc */ + +#ifndef __KERNEL__ +# include +#endif + #endif /* _LINUX_SOCKET_H */ --- a/include/linux/stat.h +++ b/include/linux/stat.h @@ -74,4 +74,8 @@ struct kstat { #endif +#ifndef __KERNEL__ +# include +#endif + #endif --- a/include/linux/types.h +++ b/include/linux/types.h @@ -9,8 +9,11 @@ unsigned long name[BITS_TO_LONGS(bits)] #define BITS_PER_BYTE 8 -#endif +#else +#include +#include +#endif #include #include --- a/include/linux/time.h +++ b/include/linux/time.h @@ -1,3 +1,9 @@ +#ifndef _LINUX_TIME_H +# include +# include +# define _LINUX_TIME_H +#endif + #ifndef _LINUX_TIME_H #define _LINUX_TIME_H --- a/include/linux/if.h +++ b/include/linux/if.h @@ -17,6 +17,11 @@ * 2 of the License, or (at your option) any later version. */ #ifndef _LINUX_IF_H +# include +# define _LINUX_IF_H +#endif + +#ifndef _LINUX_IF_H #define _LINUX_IF_H #include /* for "__kernel_caddr_t" et al */ --- a/include/linux/ip.h +++ b/include/linux/ip.h @@ -15,6 +15,11 @@ * 2 of the License, or (at your option) any later version. */ #ifndef _LINUX_IP_H +# include +# define _LINUX_IP_H +#endif + +#ifndef _LINUX_IP_H #define _LINUX_IP_H #include #include --- a/include/linux/cdrom.h +++ b/include/linux/cdrom.h @@ -11,6 +11,10 @@ #ifndef _LINUX_CDROM_H #define _LINUX_CDROM_H +#ifndef __KERNEL__ +# include +#endif + #include /*******************************************************