Skip to contentSkip to conversation

don't export fb.h internal structure to userland

PATCH In review GOTO Masanori 1 participant 2 messages Nov 4, 2003 – Nov 5, 2003 Framebuffer layer

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 don't export fb.h internal structure to userland

Hi,

This patch fixes not to compile with linux/fb.h:

	> cat fb.c
	#include <linux/fb.h>
	int main() {}
	> gcc fb.c
	In file included from /usr/include/linux/timer.h:5,
	                 from /usr/include/linux/workqueue.h:8,
	                 from /usr/include/linux/fb.h:5,
	                 from fb.c:1:
	/usr/include/linux/list.h:576:2: warning: #warning "don't include kernel headers in userspace"
	In file included from /usr/include/linux/timer.h:6,
	                 from /usr/include/linux/workqueue.h:8,
	                 from /usr/include/linux/fb.h:5,
	                 from fb.c:1:
	...

This sample program worked in kernel 2.4. Actually this problem is occured by (1) including workqueue.h, and (2) struct fb_pixmap has spinlock_t. This patch fixes with (1) move workqueue.h to internal of __KERNEL__, (2) also move struct fb_pixmap to internal of __KERNEL__. Now fb.h don't export kernel internal structure to userland.

Please apply it.

Regards,
-- gotom

linux/fb.h.new renamed from linux/fb.h +15 -14
@@ -2,7 +2,6 @@
 #define _LINUX_FB_H
 
 #include <linux/tty.h>
-#include <linux/workqueue.h>
 #include <asm/types.h>
 #include <asm/io.h>
 
@@ -331,23 +330,11 @@
 #define FB_PIXMAP_IO      4     /* memory is iomapped       */
 #define FB_PIXMAP_SYNC    256   /* set if GPU can DMA       */
 
-struct fb_pixmap {
-        __u8  *addr;                      /* pointer to memory             */  
-	__u32 size;                       /* size of buffer in bytes       */
-	__u32 offset;                     /* current offset to buffer      */
-	__u32 buf_align;                  /* byte alignment of each bitmap */
-	__u32 scan_align;                 /* alignment per scanline        */
-	__u32 flags;                      /* see FB_PIXMAP_*               */
-					  /* access methods                */
-	void (*outbuf)(u8 *dst, u8 *addr, unsigned int size); 
-	u8   (*inbuf) (u8 *addr);
-	spinlock_t lock;                  /* spinlock                      */
-	atomic_t count;
-};
 #ifdef __KERNEL__
 
 #include <linux/fs.h>
 #include <linux/init.h>
+#include <linux/workqueue.h>
 
 struct fb_info;
 struct vm_area_struct;
@@ -395,6 +382,20 @@
     int (*fb_mmap)(struct fb_info *info, struct file *file, struct vm_area_struct *vma);
 };
 
+struct fb_pixmap {
+        __u8  *addr;                      /* pointer to memory             */  
+	__u32 size;                       /* size of buffer in bytes       */
+	__u32 offset;                     /* current offset to buffer      */
+	__u32 buf_align;                  /* byte alignment of each bitmap */
+	__u32 scan_align;                 /* alignment per scanline        */
+	__u32 flags;                      /* see FB_PIXMAP_*               */
+					  /* access methods                */
+	void (*outbuf)(u8 *dst, u8 *addr, unsigned int size); 
+	u8 (*inbuf) (u8 *addr);
+	spinlock_t lock;                  /* spinlock                      */
+	atomic_t count;
+};
+
 struct fb_info {
    int node;
    int flags;

-------------------------------------------------------
This SF.net email is sponsored by: SF.net Giveback Program. Does SourceForge.net help you be more productive? Does it
help you create better code? SHARE THE LOVE, and help us help
YOU! Click Here: http://sourceforge.net/donate/

#1 lore raw

Hi,

This patch one more fix for linux/fb.h, to move asm/io.h into __KERNEL__. It should also be internal of __KERNEL__. This patch can be applied after my previous linux/fb.h patch is applied.

All my 3 patches are reported by debian package build (because the latest debian unstable distribution /usr/include/linux/* uses the latest linux kernel headers), and many userland applications currently can't build. So please apply these patches for your tree.

This patch from Daniel Jacobowitz <[email protected]>.

Regards,
-- gotom

linux/fb.h +1 -1
@@ -3,7 +3,6 @@
 
 #include <linux/tty.h>
 #include <asm/types.h>
-#include <asm/io.h>
 
 /* Definitions of frame buffers						*/
 
@@ -335,6 +334,7 @@
 #include <linux/fs.h>
 #include <linux/init.h>
 #include <linux/workqueue.h>
+#include <asm/io.h>
 
 struct fb_info;
 struct vm_area_struct;

-------------------------------------------------------
This SF.net email is sponsored by: SF.net Giveback Program. Does SourceForge.net help you be more productive? Does it
help you create better code? SHARE THE LOVE, and help us help
YOU! Click Here: http://sourceforge.net/donate/