Commit c01226c3145d173a0d38f9d5b4f229cc23d99ae2

Authored by Arnd Bergmann
Committed by Sam Ravnborg
1 parent 17c5ca9883

warn about use of uninstalled kernel headers

User applications frequently hit problems when they try to use
the kernel headers directly, rather than the exported headers.

This adds an explicit warning for this case, and points to
a URL holding an explanation of why this is wrong and what
to do about it.

Signed-off-by: Arnd Bergmann <arnd@arndb.de>
Signed-off-by: Sam Ravnborg <sam@ravnborg.org>

Showing 2 changed files with 7 additions and 1 deletions Side-by-side Diff

include/linux/kernel.h
... ... @@ -659,6 +659,12 @@
659 659  
660 660 #endif /* __KERNEL__ */
661 661  
  662 +#ifndef __EXPORTED_HEADERS__
  663 +#ifndef __KERNEL__
  664 +#warning Attempt to use kernel headers from user space, see http://kernelnewbies.org/KernelHeaders
  665 +#endif /* __KERNEL__ */
  666 +#endif /* __EXPORTED_HEADERS__ */
  667 +
662 668 #define SI_LOAD_SHIFT 16
663 669 struct sysinfo {
664 670 long uptime; /* Seconds since boot */
scripts/headers_install.pl
... ... @@ -20,7 +20,7 @@
20 20  
21 21 my ($readdir, $installdir, $arch, @files) = @ARGV;
22 22  
23   -my $unifdef = "scripts/unifdef -U__KERNEL__";
  23 +my $unifdef = "scripts/unifdef -U__KERNEL__ -D__EXPORTED_HEADERS__";
24 24  
25 25 foreach my $file (@files) {
26 26 local *INFILE;