Re: stat64 for over 2TB file returned invalid st_blocks

From: Dave Kleikamp
Date: Fri Dec 02 2005 - 09:11:23 EST


On Fri, 2005-12-02 at 22:18 +0900, Takashi Sato wrote:
> >> 2. Change the type of architecture dependent stat64.st_blocks in
> >> include/asm/asm-*/stat.h from unsigned long to unsigned long long.
> >> I tried modifying only stat64 of 32bit architecture
> >> (include/asm-i386/stat.h).
> >
> >This changes the API, but the structure does suggest that the 4-byte pad
> >should be used for the high-order bytes of st_blocks, so that's not
> >really a problem. A correct fix would replace __pad4 with
> >st_blocks_high (or something like that) and ensure that the high-order
> >word was stored there. Your proposed fix would only be correct on
> >little-endian hardware, as Jörn pointed out.
>
> Thank you for your advice. I'll research for glibc and consider
> how to implement.
> By the way I think, as Avi Kivity said, it's always little-endian on i386,
> is it correct?

That's true. The patch does fix i386 without any bad side-effects. A
generic fix that would fix all architectures would be a little more
complicated, since the size of st_blocks varies. 32-bit big-endian
would have to explicitly copy the high and low words. (The first time I
looked at this, I ignored the fact that the change was in asm-i386.)

Shaggy
--
David Kleikamp
IBM Linux Technology Center

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