[PATCH] Hide struct ustat in include/linux/types.h from userspace?;

Dan Kegel (dank@kegel.com)
Sat, 21 Jun 2003 20:10:23 -0700


I have to apply the following patch, kindly sent to me by
Kaz Kojima, to the 2.4.19/2.4.20 kernel in
order to build glibc-2.3.2 for the sh4 processor.
All it does is hide the kernel's definition of struct ustat
from userspace. This prevents a clash with the userspace
definition of struct ustat.
I verified this has not yet been applied as of 2.4.22-pre1.

I'm not familiar enough with the kernel/c-library interface to
know whether this patch is the proper fix, but it's the one
being used by the sh-linux folks.

The symptom without this patch is:

In file included from sys/ustat.h:30,
from ../sysdeps/unix/sysv/linux/ustat.c:21:
../sysdeps/generic/bits/ustat.h:26: error: redefinition of `struct ustat'
make[2]: *** [/build/sh4-unknown-linux-gnu/gcc-3.3-glibc-2.3.2/build-glibc/misc/ustat.o] Error 1
make[2]: Leaving directory `/build/sh4-unknown-linux-gnu/gcc-3.3-glibc-2.3.2/glibc-2.3.2/misc'

Yeah, I know the sh folks have their own kernel tree, but IMHO
one ought at least be able to build working toolchains with the
vanilla vger kernel headers. I now have a script that builds
cross-toolchains for many architectures from scratch at
http://kegel.com/crosstool
and I'm trying to nudge patches into the main trees of gcc, glibc, and linux
so their next vanilla releases can be used to build working
cross-compilers targeting every architecture glibc supports
without patches.
- Dan

diff -u linux-2.5.69-sf-orig/include/linux/types.h /usr/local/sh4-unknown-linux-gnu/include/linux/types.h
--- linux-2.5.69-sf-orig/include/linux/types.h Wed Mar 5 12:29:34 2003
+++ sh4-unknown-linux-gnu/include/linux/types.h Sat Apr 19 10:05:52 2003
@@ -141,6 +141,7 @@

#endif /* __KERNEL_STRICT_NAMES */

+#ifdef __KERNEL__
/*
* Below are truly Linux-specific types that should never collide with
* any application/library that wants linux/types.h.
@@ -152,5 +153,6 @@
char f_fname[6];
char f_fpack[6];
};
+#endif

#endif /* _LINUX_TYPES_H */

-- 
Dan Kegel
http://www.kegel.com
http://counter.li.org/cgi-bin/runscript/display-person.cgi?user=78045

- To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to majordomo@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html Please read the FAQ at http://www.tux.org/lkml/