Skip to contentSkip to conversation

'make headers_check' fixes for 2.6.18

PATCH New David Woodhouse 1 participant 7 messages Sep 9, 2006

Subsystems (3)
lore
Share & tools
lore
#0 lore raw

cover 'make headers_check' fixes for 2.6.18

Our implementation of 'make headers_check' is currently _extremely_ simple -- all it does is check that none of the exported header files are trying to include other header files which aren't also exported.

Mostly, this happens when the unexported headers aren't actually needed from the user-visible part of the file which includes them. The fix is usually to move the #include so that it sits inside the #ifdef __KERNEL__ where it's actually used. A few minor fixes follow, to fix 'make headers_check' in 2.6.18 at least for selected architectures...

Signature · 1 line
dwmw2
#1 lore raw

PATCH 1/6 Reduce user-visible noise in <linux/nfs_fs.h>

We don't need any of this crap included from the user-visible part of nfs_fs.h -- remove it all.

In fact, we probably don't need anything but NFS_SUPER_MAGIC to be defined; is there any need for anything else? And magic numbers should probably move to <linux/magic.h> rather than being strewn across various fs-specific include files which exist in userspace for solely that purpose.

With this patch, 'make header_check' works again at least on PowerPC.

include/linux/nfs_fs.h +26 -26
index 530b1e6..6c2066c 100644
@@ -9,27 +9,6 @@
 #ifndef _LINUX_NFS_FS_H
 #define _LINUX_NFS_FS_H
 
-#include <linux/in.h>
-#include <linux/mm.h>
-#include <linux/pagemap.h>
-#include <linux/rwsem.h>
-#include <linux/wait.h>
-
-#include <linux/sunrpc/debug.h>
-#include <linux/sunrpc/auth.h>
-#include <linux/sunrpc/clnt.h>
-
-#include <linux/nfs.h>
-#include <linux/nfs2.h>
-#include <linux/nfs3.h>
-#include <linux/nfs4.h>
-#include <linux/nfs_xdr.h>
-
-#include <linux/nfs_fs_sb.h>
-
-#include <linux/rwsem.h>
-#include <linux/mempool.h>
-
 /*
  * Enable debugging support for nfs client.
  * Requires RPC_DEBUG.
@@ -48,11 +27,6 @@ #define NFS_MAX_TCP_TIMEOUT	(600*HZ)
 #define NFS_SUPER_MAGIC			0x6969
 
 /*
- * These are the default flags for swap requests
- */
-#define NFS_RPC_SWAPFLAGS		(RPC_TASK_SWAPPER|RPC_TASK_ROOTCREDS)
-
-/*
  * When flushing a cluster of dirty pages, there can be different
  * strategies:
  */
@@ -65,6 +39,32 @@ #define FLUSH_INVALIDATE	64	/* Invalidat
 
 #ifdef __KERNEL__
 
+#include <linux/in.h>
+#include <linux/mm.h>
+#include <linux/pagemap.h>
+#include <linux/rwsem.h>
+#include <linux/wait.h>
+
+#include <linux/sunrpc/debug.h>
+#include <linux/sunrpc/auth.h>
+#include <linux/sunrpc/clnt.h>
+
+#include <linux/nfs.h>
+#include <linux/nfs2.h>
+#include <linux/nfs3.h>
+#include <linux/nfs4.h>
+#include <linux/nfs_xdr.h>
+
+#include <linux/nfs_fs_sb.h>
+
+#include <linux/rwsem.h>
+#include <linux/mempool.h>
+
+/*
+ * These are the default flags for swap requests
+ */
+#define NFS_RPC_SWAPFLAGS		(RPC_TASK_SWAPPER|RPC_TASK_ROOTCREDS)
+
 /*
  * NFSv3/v4 Access mode cache entry
  */
Signature · 1 line
dwmw2
#2 lore raw

PATCH 2/6 Remove <asm/timex.h> from user export

In reply to David Woodhouse

There's useful stuff in <linux/timex.h> but <asm/timex.h> has nothing for userspace. Stop exporting it, and include it only from within the existing #ifdef __KERNEL__ part of <linux/timex.h>

This fixes a 'make headers_check' failure on i386 because asm-i386/timex.h includes both asm-i386/tsc.h and asm-i386/processor.h, neither of which are exported to userspace. It's not entirely clear _why_ it includes either of these, but it does.

include/asm-generic/Kbuild.asm +1 -1
index 6b16dda..c00de60 100644
@@ -2,7 +2,7 @@ unifdef-y += a.out.h auxvec.h byteorder.
 	ioctls.h ipcbuf.h mman.h msgbuf.h param.h poll.h		\
 	posix_types.h ptrace.h resource.h sembuf.h shmbuf.h shmparam.h	\
 	sigcontext.h siginfo.h signal.h socket.h sockios.h stat.h	\
-	statfs.h termbits.h termios.h timex.h types.h unistd.h user.h
+	statfs.h termbits.h termios.h types.h unistd.h user.h
 
 # These probably shouldn't be exported
 unifdef-y += elf.h page.h
include/linux/timex.h +2 -1
index 19bb653..d543d38 100644
@@ -57,7 +57,6 @@ #include <linux/compiler.h>
 #include <linux/time.h>
 
 #include <asm/param.h>
-#include <asm/timex.h>
 
 /*
  * SHIFT_KG and SHIFT_KF establish the damping of the PLL and are chosen
@@ -191,6 +190,8 @@ #define TIME_ERROR	5	/* clock not synchr
 #define TIME_BAD	TIME_ERROR /* bw compat */
 
 #ifdef __KERNEL__
+#include <asm/timex.h>
+
 /*
  * kernel variables
  * Note: maximum error = NTP synch distance = dispersion + delay / 2;
Signature · 1 line
dwmw2
#3 lore raw

PATCH 3/6 Move inclusion of <linux/linkage.h> in <asm-i386/signal.h>

In reply to David Woodhouse

Because <linux/linkage.h> doesn't exist in userspace, it should be only included from within #ifdef __KERNEL__. Move the corresponding #include

include/asm-i386/signal.h +3 -1
index 3824a50..c3e8ade 100644
@@ -2,7 +2,6 @@ #ifndef _ASMi386_SIGNAL_H
 #define _ASMi386_SIGNAL_H
 
 #include <linux/types.h>
-#include <linux/linkage.h>
 #include <linux/time.h>
 #include <linux/compiler.h>
 
@@ -10,6 +9,9 @@ #include <linux/compiler.h>
 struct siginfo;
 
 #ifdef __KERNEL__
+
+#include <linux/linkage.h>
+
 /* Most things should be clean enough to redefine this at will, if care
    is taken to make libc match.  */
 
Signature · 1 line
dwmw2
#4 lore raw

PATCH 4/6 Move kernel-only #includes within <asm-i386/elf.h>

In reply to David Woodhouse

Some files which don't exist in userspace were being included unconditionally in asm-i386/elf.h. Move the offending #includes down a few lines so that they're protected by #ifdef __KERNEL__

In fact, we probably want to kill off all userspace use of asm/elf.h -- but we aren't there yet, so we should at least make it possible to include it for now.

include/asm-i386/elf.h +6 -4
index 1eac92c..db4344d 100644
@@ -7,10 +7,7 @@ #define __ASMi386_ELF_H
 
 #include <asm/ptrace.h>
 #include <asm/user.h>
-#include <asm/processor.h>
-#include <asm/system.h>		/* for savesegment */
 #include <asm/auxvec.h>
-#include <asm/desc.h>
 
 #include <linux/utsname.h>
 
@@ -48,6 +45,12 @@ #define ELF_CLASS	ELFCLASS32
 #define ELF_DATA	ELFDATA2LSB
 #define ELF_ARCH	EM_386
 
+#ifdef __KERNEL__
+
+#include <asm/processor.h>
+#include <asm/system.h>		/* for savesegment */
+#include <asm/desc.h>
+
 /* SVR4/i386 ABI (pages 3-31, 3-32) says that when the program starts %edx
    contains a pointer to a function which might be registered using `atexit'.
    This provides a mean for the dynamic linker to call DT_FINI functions for
@@ -111,7 +114,6 @@ #define ELF_HWCAP	(boot_cpu_data.x86_cap
 
 #define ELF_PLATFORM  (system_utsname.machine)
 
-#ifdef __KERNEL__
 #define SET_PERSONALITY(ex, ibcs2) do { } while (0)
 
 /*
Signature · 1 line
dwmw2
#5 lore raw

PATCH 5/6 Don't expose PFN stuff to userspace in <asm-i386/setup.h>

In reply to David Woodhouse

The header file <linux/pfn.h> doesn't exist in userspace and probably shouldn't -- but it's used unconditionally in <asm-i386/setup.h>. Protect it with #ifdef __KERNEL__ and move setup.h from $(header-y) to $(unifdef-y) in Kbuild accordingly.

include/asm-i386/Kbuild +2 -2
index 335b2fa..2308190 100644
@@ -1,5 +1,5 @@
 include include/asm-generic/Kbuild.asm
 
-header-y += boot.h debugreg.h ldt.h setup.h ucontext.h
+header-y += boot.h debugreg.h ldt.h ucontext.h
 
-unifdef-y += mtrr.h vm86.h
+unifdef-y += mtrr.h setup.h vm86.h
include/asm-i386/setup.h +2 -0
index f737e42..2734909 100644
@@ -6,6 +6,7 @@
 #ifndef _i386_SETUP_H
 #define _i386_SETUP_H
 
+#ifdef __KERNEL__
 #include <linux/pfn.h>
 
 /*
@@ -13,6 +14,7 @@ #include <linux/pfn.h>
  */
 #define MAXMEM_PFN	PFN_DOWN(MAXMEM)
 #define MAX_NONPAE_PFN	(1 << 20)
+#endif
 
 #define PARAM_SIZE 4096
 #define COMMAND_LINE_SIZE 256
Signature · 1 line
dwmw2
#6 lore raw

PATCH 6/6 Fix userspace build of asm-mips/page.h

In reply to David Woodhouse

MIPS asm/page.h unconditionally includes <asm-generic/memory_model.h>, which doesn't exist in userspace. Move an #endif /* __KERNEL__ */ down a few lines to prevent that.

Also, remove the broken definition of PAGE_SIZE which is never going to be correct -- in the absence of PAGE_SIZE, non-broken userspace will fall back to using sysconf() or getpagesize() instead.

include/asm-mips/page.h +2 -6
index 6ed1151..219d359 100644
@@ -14,8 +14,6 @@ #ifdef __KERNEL__
 
 #include <spaces.h>
 
-#endif
-
 /*
  * PAGE_SHIFT determines the page size
  */
@@ -34,8 +32,6 @@ #endif
 #define PAGE_SIZE	(1UL << PAGE_SHIFT)
 #define PAGE_MASK       (~((1 << PAGE_SHIFT) - 1))
 
-
-#ifdef __KERNEL__
 #ifndef __ASSEMBLY__
 
 extern void clear_page(void * page);
@@ -168,8 +164,6 @@ #define VM_DATA_DEFAULT_FLAGS	(VM_READ |
 #define UNCAC_ADDR(addr)	((addr) - PAGE_OFFSET + UNCAC_BASE)
 #define CAC_ADDR(addr)		((addr) - UNCAC_BASE + PAGE_OFFSET)
 
-#endif /* defined (__KERNEL__) */
-
 #ifdef CONFIG_LIMITED_DMA
 #define WANT_PAGE_VIRTUAL
 #endif
@@ -177,4 +171,6 @@ #endif
 #include <asm-generic/memory_model.h>
 #include <asm-generic/page.h>
 
+#endif /* defined (__KERNEL__) */
+
 #endif /* _ASM_PAGE_H */
Signature · 1 line
dwmw2