du(1)/fts(3) integer overflow

henry henry at jot.to
Mon Dec 13 03:42:27 PST 2004


I have noticed a problem with the fts(3) library or the way du(1) interacts
with it.

A 3.2TiB file gives the following output:
> du -cs /fs/file
3408720016      /fs/file
-886247279      total
> du -hcs /fs/file
3.2T    /fs/file
        total
> 

This is because while stat(2) reports blocks as a 64bit number du(1) uses
the 32bit value FTSENT.fts_number to store the result:
du.c (1.36):
269:                            p->fts_parent->fts_number +=
p->fts_statp->st_blocks;
270:            }
271:            savednumber = p->fts_parent->fts_number;
272:    }

The simplest change appears to be to make fts_number 64bit however this
changes the fts(3) abi, so I am not sure if this is acceptable.

Thoughts?



More information about the freebsd-hackers mailing list