Subject: Re: struct netbsd32_statvfs and packed attribute
To: Markus Mayer <>
From: David Laight <>
List: tech-kern
Date: 09/08/2007 14:22:30
On Fri, Sep 07, 2007 at 04:36:21PM -0700, Markus Mayer wrote:
> Hi,
> I just noticed an issue with netbsd32_statvfs and the getvfsstat() 
> syscall. This is for a MIPS platform with 64 bit kernel and (some) 32 
> bit userland applications. However, I am assuming it'll affect other 
> platforms, as well.
> I traced the problem to the attribute "packed" that is specified for 
> struct netbsd32_statvfs. netbsd32_statvfs is 2228 bytes in the kernel. 
> However, struct statvfs, which is not packed, is 2232 bytes in 32 bit 
> userland.

IIRC the 'problem' is that struct statvfs has a 64bit integer that
isn't (by default) aligned on an 8 byte boundary.
On i386 (I'm not sure about sparc) 64bit types only have 4 byte alignment,
so an amd64 kernel (where they have 8 byte alignment) incorrectly
maps the statvfs structure.
Adding 'base' types netbsd32_int64 and netbsd32_uint64 (which have 4byte
alignemnt when needed) may be necessary.  Packing the whole structure
gives a massive performance penalty on cpus that can't do misaligned


David Laight: