[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: coreutils-5.92:du not AIX largefile safe --
From: |
Jim Meyering |
Subject: |
Re: coreutils-5.92:du not AIX largefile safe -- |
Date: |
Fri, 04 Nov 2005 00:26:34 +0100 |
Paul Townsend <address@hidden> wrote:
> When the `du' included with coreutils-5.92 is compiled on an AIX 5.1 box
> that has a 32 bit kernel and is compiled with large file support, it
> incorrectly computes the size of a file that exceeds 2**31-1 bytes. If
> I've interpretted the code correctly, it's because the stat->st_blocks
> entry is a signed int that's multiplied by 512 before being promoted to
> an unsigned long long (uintmax_t). The patch below forces the promotion
> before the multiplication.
>
> -- Paul Townsend (alpha a beta present at purdue dot edu)
>
> diff -u coreutils-5.92/src/du.c.orig coreutils-5.92/src/du.c
> --- coreutils-5.92/src/du.c.orig 2005-10-15 04:13:21.000000000 -0500
> +++ coreutils-5.92/src/du.c 2005-11-02 02:44:21.767391000 -0500
> @@ -537,7 +537,7 @@
> duinfo_set (&dui,
> (apparent_size
> ? sb->st_size
> - : ST_NBLOCKS (*sb) * ST_NBLOCKSIZE),
> + : (uintmax_t) ST_NBLOCKS (*sb) * ST_NBLOCKSIZE),
> (time_type == time_mtime ? get_stat_mtime (sb)
> : time_type == time_atime ? get_stat_atime (sb)
> : get_stat_ctime (sb)));
Thanks for the report and patch.
That looks right to me, too.
Would you please test it with something like this:
printf %$(echo '2^31-1'|bc)s x > k
du -s k
printf x >> k
du -s k
printf x >> k
du -s k
I get this output:
2097152 k
2097152 k
2097156 k
Of course, your numbers may vary a little.
The important thing is that there be no errors.
- coreutils-5.92:du not AIX largefile safe --, Paul Townsend, 2005/11/03
- Re: coreutils-5.92:du not AIX largefile safe --,
Jim Meyering <=
- Re: coreutils-5.92:du not AIX largefile safe --, Paul Townsend, 2005/11/03
- Re: coreutils-5.92:du not AIX largefile safe --, Jim Meyering, 2005/11/04
- Re: coreutils-5.92:du not AIX largefile safe --, Paul Townsend, 2005/11/08
- Re: coreutils-5.92:du not AIX largefile safe --, Jim Meyering, 2005/11/08
- Re: coreutils-5.92:du not AIX largefile safe --, Paul Townsend, 2005/11/09
- Re: coreutils-5.92:du not AIX largefile safe --, Jim Meyering, 2005/11/09
- Re: coreutils-5.92:du not AIX largefile safe --, Jim Meyering, 2005/11/09
- Re: coreutils-5.92:du not AIX largefile safe --, Alfred M\. Szmidt, 2005/11/09