Unify asm/statfs.h
Subsystems (6)
RFC 1/1 Unify asm/statfs.h
At the moment, all 64-bit platforms except Alpha are redefining everything in <asm/statfs.h>, because their definitions are different.
At the cost of an #ifdef defining a local type, we can make it useful for just about all architectures, as is done at {git://,http://} git.infradead.org/users/dwmw2/statfs-2.6.git
The exceptions are MIPS, which has its fields in a different order, and S390, which mixes types of different sizes in its struct statfs -- although we could probably cope with the latter, if we really want to.
arch/sparc/include/asm/statfs_32.h | 6 --- arch/sparc/include/asm/statfs_64.h | 54 ----------------------------- b/arch/alpha/include/asm/statfs.h | 4 ++ b/arch/arm/include/asm/statfs.h | 34 +----------------- b/arch/ia64/include/asm/statfs.h | 52 ++-------------------------- b/arch/powerpc/include/asm/statfs.h | 54 ----------------------------- b/arch/s390/include/asm/statfs.h | 11 ++---- b/arch/sparc/include/asm/statfs.h | 8 +--- b/include/asm-generic/statfs.h | 65 ++++++++++++++++++++++++++---------- b/include/asm-parisc/statfs.h | 55 +----------------------------- b/include/asm-x86/statfs.h | 61 ++------------------------------- 11 files changed, 73 insertions(+), 331 deletions(-)
include/asm-generic/statfs.h +48 -17
@@ -6,33 +6,64 @@typedef __kernel_fsid_t fsid_t ;#endif +/* +* Most 64-bit platforms use 'long', while most 32-bit platforms use '__u32'. +* Yes, they differ in signedness as well as size. +* Special cases can override it for themselves -- except for S390x, which +* is just a little too special for us. And MIPS, which I'm not touching +* with a 10' pole. +*/ +#ifndef __statfs_word +#if BITS_PER_LONG ==64 +#define __statfs_word long +#else +typedef __statfs_word __u32 +#endif +#endif +struct statfs { -__u32 f_type; -__u32 f_bsize; -__u32 f_blocks; -__u32 f_bfree; -__u32 f_bavail; -__u32 f_files; -__u32 f_ffree; +__statfs_word f_type; +__statfs_word f_bsize; +__statfs_word f_blocks; +__statfs_word f_bfree; +__statfs_word f_bavail; +__statfs_word f_files; +__statfs_word f_ffree;__kernel_fsid_t f_fsid; -__u32 f_namelen; -__u32 f_frsize; -__u32 f_spare[5 ]; +__statfs_word f_namelen; +__statfs_word f_frsize; +__statfs_word f_spare[5 ]; }; +/* +* ARM needs to avoid the 32-bit padding at the end, for consistency +* between EABI and OABI +*/ +#ifndef ARCH_PACK_STATFS64 +#define ARCH_PACK_STATFS64 +#endif +struct statfs64 { -__u32 f_type; -__u32 f_bsize; +__statfs_word f_type; +__statfs_word f_bsize;__u64 f_blocks;__u64 f_bfree;__u64 f_bavail;__u64 f_files;__u64 f_ffree;__kernel_fsid_t f_fsid; -__u32 f_namelen; -__u32 f_frsize; -__u32 f_spare[5 ]; -}; +__statfs_word f_namelen; +__statfs_word f_frsize; +__statfs_word f_spare[5 ]; +}ARCH_PACK_STATFS64 ; + +/* +* IA64 and x86_64 need to avoid the 32-bit padding at the end, +* to be compatible with the i386 ABI +*/ +#ifndef ARCH_PACK_COMPAT_STATFS64 +#define ARCH_PACK_COMPAT_STATFS64 +#endif struct compat_statfs64 {__u32 f_type;
@@ -46,6 +77,6 @@ struct compat_statfs64 {__u32 f_namelen;__u32 f_frsize; __u32 f_spare[5]; -}; +}ARCH_PACK_COMPAT_STATFS64 ;#endif
arch/alpha/include/asm/statfs.h +4 -0
@@ -1,6 +1,10 @@#ifndef _ALPHA_STATFS_H#define _ALPHA_STATFS_H +/* Alpha is the only 64-bit platform with 32-bit statfs. And doesn't +even seem to implement statfs64 */ +#define __statfs_word __u32 +#include <asm-generic/statfs.h> #endif
arch/arm/include/asm/statfs.h +2 -32
@@ -1,42 +1,12 @@#ifndef _ASMARM_STATFS_H#define _ASMARM_STATFS_H -#ifndef __KERNEL_STRICT_NAMES -# include <linux/types.h> -typedef __kernel_fsid_t fsid_t ; -#endif - -struct statfs { -__u32 f_type; -__u32 f_bsize; -__u32 f_blocks; -__u32 f_bfree; -__u32 f_bavail; -__u32 f_files; -__u32 f_ffree; -__kernel_fsid_t f_fsid; -__u32 f_namelen; -__u32 f_frsize; -__u32 f_spare[5 ]; -}; -/* * With EABI there is 4 bytes of padding added to this structure. * Let's pack it so the padding goes away to simplify dual ABI support. * Note that user space does NOT have to pack this structure. */ -struct statfs64 { -__u32 f_type; -__u32 f_bsize; -__u64 f_blocks; -__u64 f_bfree; -__u64 f_bavail; -__u64 f_files; -__u64 f_ffree; -__kernel_fsid_t f_fsid; -__u32 f_namelen; -__u32 f_frsize; -__u32 f_spare[5 ]; -} __attribute__ ((packed,aligned (4 ))); +#define ARCH_PACK_STATFS64 __attribute__((packed,aligned(4))) +#include <asm-generic/statfs.h> #endif
arch/ia64/include/asm/statfs.h +5 -47
60 lines not on this page · raw message
arch/powerpc/include/asm/statfs.h +0 -54
60 lines not on this page · raw message
arch/s390/include/asm/statfs.h +4 -7
@@ -12,19 +12,16 @@ #ifndef __s390x__ #include <asm-generic/statfs.h> #else +/* + * We can't use <asm-generic/statfs.h> because in 64-bit mode + * we mix ints of different sizes in our struct statfs. + */ #ifndef __KERNEL_STRICT_NAMES - #include <linux/types.h> - typedef __kernel_fsid_t fsid_t; - #endif -/* - * This is ugly -- we're already 64-bit clean, so just duplicate the - * definitions. - */ struct statfs { int f_type; int f_bsize;
arch/sparc/include/asm/statfs.h +3 -5
@@ -1,8 +1,6 @@#ifndef ___ASM_SPARC_STATFS_H#define ___ASM_SPARC_STATFS_H -#if defined(__sparc__) && defined(__arch64__) -#include <asm/statfs_64.h> -#else -#include <asm/statfs_32.h> -#endif + +#include <asm-generic/statfs.h> +#endif
arch/sparc/include/asm/statfs_32.h deleted +0 -6
@@ -1,6 +0,0 @@ -#ifndef _SPARC_STATFS_H -#define _SPARC_STATFS_H - -#include <asm-generic/statfs.h> - -#endif
arch/sparc/include/asm/statfs_64.h deleted +0 -54
54 lines not on this page · raw message
include/asm-parisc/statfs.h +2 -53
60 lines not on this page · raw message
include/asm-x86/statfs.h +5 -56
68 lines not on this page · raw message
Signature · 2 lines
David Woodhouse Open Source Technology Centre [email protected] Intel Corporation
PATCH 1/8 Make <asm-generic/statfs.h> suitable for 64-bit platforms.
At the moment, 64-bit platforms (other than Alpha) are all redefining things for themselves instead of using <asm-generic/statfs.h>.
As is ARM, since it has special requirements w.r.t. padding.
Make <asm-generic/statfs.h> more generic, and they can use it directly.
--- arch/alpha/include/asm/statfs.h | 4 ++ include/asm-generic/statfs.h | 65 ++++++++++++++++++++++++++++---------- 2 files changed, 52 insertions(+), 17 deletions(-)
arch/alpha/include/asm/statfs.h +4 -0
@@ -1,6 +1,10 @@#ifndef _ALPHA_STATFS_H#define _ALPHA_STATFS_H +/* Alpha is the only 64-bit platform with 32-bit statfs. And doesn't +even seem to implement statfs64 */ +#define __statfs_word __u32 +#include <asm-generic/statfs.h> #endif
include/asm-generic/statfs.h +48 -17
87 lines not on this page · raw message
Signature · 4 lines
1.5.5.1 -- David Woodhouse Open Source Technology Centre [email protected] Intel Corporation
PATCH 2/8 ARM: Use <asm-generic/statfs.h>
In reply to David Woodhouse--- arch/arm/include/asm/statfs.h | 34 ++-------------------------------- 1 files changed, 2 insertions(+), 32 deletions(-)
arch/arm/include/asm/statfs.h +2 -32
@@ -1,42 +1,12 @@#ifndef _ASMARM_STATFS_H#define _ASMARM_STATFS_H -#ifndef __KERNEL_STRICT_NAMES -# include <linux/types.h> -typedef __kernel_fsid_t fsid_t ; -#endif - -struct statfs { -__u32 f_type; -__u32 f_bsize; -__u32 f_blocks; -__u32 f_bfree; -__u32 f_bavail; -__u32 f_files; -__u32 f_ffree; -__kernel_fsid_t f_fsid; -__u32 f_namelen; -__u32 f_frsize; -__u32 f_spare[5 ]; -}; -/* * With EABI there is 4 bytes of padding added to this structure. * Let's pack it so the padding goes away to simplify dual ABI support. * Note that user space does NOT have to pack this structure. */ -struct statfs64 { -__u32 f_type; -__u32 f_bsize; -__u64 f_blocks; -__u64 f_bfree; -__u64 f_bavail; -__u64 f_files; -__u64 f_ffree; -__kernel_fsid_t f_fsid; -__u32 f_namelen; -__u32 f_frsize; -__u32 f_spare[5 ]; -} __attribute__ ((packed,aligned (4 ))); +#define ARCH_PACK_STATFS64 __attribute__((packed,aligned(4))) +#include <asm-generic/statfs.h> #endif
Signature · 4 lines
1.5.5.1 -- David Woodhouse Open Source Technology Centre [email protected] Intel Corporation
PATCH 3/8 IA64: Use <asm-generic/statfs.h>
In reply to David Woodhouse--- arch/ia64/include/asm/statfs.h | 52 ++++------------------------------------ 1 files changed, 5 insertions(+), 47 deletions(-)
arch/ia64/include/asm/statfs.h +5 -47
@@ -8,55 +8,13 @@* David Mosberger-Tang <[email protected]>, Hewlett-Packard Co */ -#ifndef __KERNEL_STRICT_NAMES -# include <linux/types.h> -typedef __kernel_fsid_t fsid_t ; -#endif -/* -* This is ugly --- we're already 64-bit, so just duplicate the definitions +* We need compat_statfs64 to be packed, because the i386 ABI won't +* add padding at the end to bring it to a multiple of 8 bytes, but +* the IA64 ABI will. */ -struct statfs { -long f_type; -long f_bsize; -long f_blocks; -long f_bfree; -long f_bavail; -long f_files; -long f_ffree; -__kernel_fsid_t f_fsid; -long f_namelen; -long f_frsize; -long f_spare[5 ]; -}; - - -struct statfs64 { -long f_type; -long f_bsize; -long f_blocks; -long f_bfree; -long f_bavail; -long f_files; -long f_ffree; -__kernel_fsid_t f_fsid; -long f_namelen; -long f_frsize; -long f_spare[5 ]; -}; +#define ARCH_PACK_COMPAT_STATFS64 __attribute__((packed,aligned(4))) -struct compat_statfs64 { -__u32 f_type; -__u32 f_bsize; -__u64 f_blocks; -__u64 f_bfree; -__u64 f_bavail; -__u64 f_files; -__u64 f_ffree; -__kernel_fsid_t f_fsid; -__u32 f_namelen; -__u32 f_frsize; -__u32 f_spare[5 ]; -} __attribute__((packed)); +#include <asm-generic/statfs.h> #endif /* _ASM_IA64_STATFS_H */
Signature · 4 lines
1.5.5.1 -- David Woodhouse Open Source Technology Centre [email protected] Intel Corporation
PATCH 4/8 x86_64: Use <asm-generic/statfs.h>
In reply to David Woodhouse--- include/asm-x86/statfs.h | 61 ++++------------------------------------------ 1 files changed, 5 insertions(+), 56 deletions(-)
include/asm-x86/statfs.h +5 -56
@@ -1,63 +1,12 @@#ifndef _ASM_X86_STATFS_H#define _ASM_X86_STATFS_H -#ifdef __i386__ -#include <asm-generic/statfs.h> -#else - -#ifndef __KERNEL_STRICT_NAMES - -#include <linux/types.h> - -typedef __kernel_fsid_t fsid_t ; - -#endif -/* -* This is ugly -- we're already 64-bit clean, so just duplicate the -* definitions. +* We need compat_statfs64 to be packed, because the i386 ABI won't +* add padding at the end to bring it to a multiple of 8 bytes, but +* the x86_64 ABI will. */ -struct statfs { -long f_type; -long f_bsize; -long f_blocks; -long f_bfree; -long f_bavail; -long f_files; -long f_ffree; -__kernel_fsid_t f_fsid; -long f_namelen; -long f_frsize; -long f_spare[5 ]; -}; - -struct statfs64 { -long f_type; -long f_bsize; -long f_blocks; -long f_bfree; -long f_bavail; -long f_files; -long f_ffree; -__kernel_fsid_t f_fsid; -long f_namelen; -long f_frsize; -long f_spare[5 ]; -}; +#define ARCH_PACK_COMPAT_STATFS64 __attribute__((packed,aligned(4))) -struct compat_statfs64 { -__u32 f_type; -__u32 f_bsize; -__u64 f_blocks; -__u64 f_bfree; -__u64 f_bavail; -__u64 f_files; -__u64 f_ffree; -__kernel_fsid_t f_fsid; -__u32 f_namelen; -__u32 f_frsize; -__u32 f_spare[5 ]; -} __attribute__((packed)); - -#endif /* !__i386__ */ +#include <asm-generic/statfs.h> #endif
Signature · 4 lines
1.5.5.1 -- David Woodhouse Open Source Technology Centre [email protected] Intel Corporation
Re: [PATCH 4/8] x86_64: Use <asm-generic/statfs.h>
Quoted 1 line · David Woodhouse
Signed-off-by David Woodhouse <[email protected]>
Ingo
PATCH 5/8 PARISC: Use <asm-generic/statfs.h>
In reply to David Woodhouse--- include/asm-parisc/statfs.h | 55 +----------------------------------------- 1 files changed, 2 insertions(+), 53 deletions(-)
include/asm-parisc/statfs.h +2 -53
@@ -1,58 +1,7 @@#ifndef _PARISC_STATFS_H#define _PARISC_STATFS_H -#ifndef __KERNEL_STRICT_NAMES - -#include <linux/types.h> - -typedef __kernel_fsid_t fsid_t ; - -#endif - -/* -* It appears that PARISC could be 64 _or_ 32 bit. -* 64-bit fields must be explicitly 64-bit in statfs64. -*/ -struct statfs { -long f_type; -long f_bsize; -long f_blocks; -long f_bfree; -long f_bavail; -long f_files; -long f_ffree; -__kernel_fsid_t f_fsid; -long f_namelen; -long f_frsize; -long f_spare[5 ]; -}; - -struct statfs64 { -long f_type; -long f_bsize; -__u64 f_blocks; -__u64 f_bfree; -__u64 f_bavail; -__u64 f_files; -__u64 f_ffree; -__kernel_fsid_t f_fsid; -long f_namelen; -long f_frsize; -long f_spare[5 ]; -}; - -struct compat_statfs64 { -__u32 f_type; -__u32 f_bsize; -__u64 f_blocks; -__u64 f_bfree; -__u64 f_bavail; -__u64 f_files; -__u64 f_ffree; -__kernel_fsid_t f_fsid; -__u32 f_namelen; -__u32 f_frsize; -__u32 f_spare[5 ]; -}; +#define __statfs_word long +#include <asm-generic/statfs.h> #endif
Signature · 4 lines
1.5.5.1 -- David Woodhouse Open Source Technology Centre [email protected] Intel Corporation
PATCH 6/8 PowerPC: Use <asm-generic/statfs.h>
In reply to David Woodhouse--- arch/powerpc/include/asm/statfs.h | 54 ------------------------------------- 1 files changed, 0 insertions(+), 54 deletions(-)
arch/powerpc/include/asm/statfs.h +0 -54
@@ -1,60 +1,6 @@#ifndef _ASM_POWERPC_STATFS_H#define _ASM_POWERPC_STATFS_H -/* For ppc32 we just use the generic definitions, not so simple on ppc64 */ - -#ifndef __powerpc64__#include <asm-generic/statfs.h> -#else - -#ifndef __KERNEL_STRICT_NAMES -#include <linux/types.h> -typedef __kernel_fsid_t fsid_t ; -#endif - -/* -* We're already 64-bit, so duplicate the definition -*/ -struct statfs { -long f_type; -long f_bsize; -long f_blocks; -long f_bfree; -long f_bavail; -long f_files; -long f_ffree; -__kernel_fsid_t f_fsid; -long f_namelen; -long f_frsize; -long f_spare[5 ]; -}; - -struct statfs64 { -long f_type; -long f_bsize; -long f_blocks; -long f_bfree; -long f_bavail; -long f_files; -long f_ffree; -__kernel_fsid_t f_fsid; -long f_namelen; -long f_frsize; -long f_spare[5 ]; -}; -struct compat_statfs64 { -__u32 f_type; -__u32 f_bsize; -__u64 f_blocks; -__u64 f_bfree; -__u64 f_bavail; -__u64 f_files; -__u64 f_ffree; -__kernel_fsid_t f_fsid; -__u32 f_namelen; -__u32 f_frsize; -__u32 f_spare[5 ]; -}; -#endif /* ! __powerpc64__ */ #endif
Signature · 4 lines
1.5.5.1 -- David Woodhouse Open Source Technology Centre [email protected] Intel Corporation
PATCH 7/8 SPARC: Use <asm-generic/statfs.h>
In reply to David Woodhouse--- arch/sparc/include/asm/statfs.h | 8 ++--- arch/sparc/include/asm/statfs_32.h | 6 ---- arch/sparc/include/asm/statfs_64.h | 54 ------------------------------------ 3 files changed, 3 insertions(+), 65 deletions(-) delete mode 100644 arch/sparc/include/asm/statfs_32.h delete mode 100644 arch/sparc/include/asm/statfs_64.h
arch/sparc/include/asm/statfs.h +3 -5
@@ -1,8 +1,6 @@#ifndef ___ASM_SPARC_STATFS_H#define ___ASM_SPARC_STATFS_H -#if defined(__sparc__) && defined(__arch64__) -#include <asm/statfs_64.h> -#else -#include <asm/statfs_32.h> -#endif + +#include <asm-generic/statfs.h> +#endif
arch/sparc/include/asm/statfs_32.h deleted +0 -6
@@ -1,6 +0,0 @@ -#ifndef _SPARC_STATFS_H -#define _SPARC_STATFS_H - -#include <asm-generic/statfs.h> - -#endif
arch/sparc/include/asm/statfs_64.h deleted +0 -54
54 lines not on this page · raw message
Signature · 4 lines
1.5.5.1 -- David Woodhouse Open Source Technology Centre [email protected] Intel Corporation
PATCH 8/8 S390: Update comments about why we don't use <asm-generic/statfs.h>
In reply to David Woodhouse--- arch/s390/include/asm/statfs.h | 11 ++++------- 1 files changed, 4 insertions(+), 7 deletions(-)
arch/s390/include/asm/statfs.h +4 -7
@@ -12,19 +12,16 @@ #ifndef __s390x__ #include <asm-generic/statfs.h> #else +/* + * We can't use <asm-generic/statfs.h> because in 64-bit mode + * we mix ints of different sizes in our struct statfs. + */ #ifndef __KERNEL_STRICT_NAMES - #include <linux/types.h> - typedef __kernel_fsid_t fsid_t; - #endif -/* - * This is ugly -- we're already 64-bit clean, so just duplicate the - * definitions. - */ struct statfs { int f_type; int f_bsize;
Signature · 4 lines
1.5.5.1 -- David Woodhouse Open Source Technology Centre [email protected] Intel Corporation