bug-coreutils
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: coreutils-5.92:du not AIX largefile safe --


From: Paul Townsend
Subject: Re: coreutils-5.92:du not AIX largefile safe --
Date: Thu, 03 Nov 2005 21:57:39 -0500

On Fri, 04 Nov 2005 00:26:34 +0100, Jim Meyering wrote:
>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.

I put the above plus a couple of other commands in a script.  Below is
the output of `ksh -xv tst'.

printf %$(echo '2^31-1'|bc)s x > k
+ bc
+ echo 2^31-1
+ printf %2147483647s x
+ 1> k
gdu -s k
+ gdu -s k
2097152 k
printf x >> k
+ printf x
+ 1>> k
gdu -s k
+ gdu -s k
2097152 k
printf x >> k
+ printf x
+ 1>> k
gdu -s k
+ gdu -s k
2097280 k
ls -l k
+ ls -l k
-rw-r--r--  1 aab      pucc     2147483649 Nov  3 21:23 k
stat k
+ stat k
  File: "k"
  Size: 2147483649   Allocated Blocks: 4194560      Filetype: Regular File
  Mode: (0644/-rw-r--r--)         Uid: (  513/     aab)  Gid: ( 1233/    pucc)
Device: 42,2   Inode: 302084    Links: 1    
Access: Thu Nov  3 21:50:26 2005(00000.00:00:00)
Modify: Thu Nov  3 21:23:14 2005(00000.00:27:12)
Change: Thu Nov  3 21:23:14 2005(00000.00:27:12)




reply via email to

[Prev in Thread] Current Thread [Next in Thread]