(1<<32 blocks * 512 bytes, done with unsigned 64 bit math).
(cherry picked from commit
8d0f0b6ba864155914f88e39076213b4486efee4)
Bug: http://b/
32331571
Test: du -sh /data/local/tmp after filling that directory
Change-Id: I8c8ad146f4c1c1daa6c2cf276ec01aa6e390cc91
struct du_data {
long maxdepth;
struct du_data {
long maxdepth;
+ unsigned long depth, total;
dev_t st_dev;
void *inodes;
};
dev_t st_dev;
void *inodes;
};
+ unsigned long depth, total;
dev_t st_dev;
void *inodes;
)
dev_t st_dev;
void *inodes;
)
-// dirtree callback, comput/display size of node
+// dirtree callback, compute/display size of node
static int do_du(struct dirtree *node)
{
static int do_du(struct dirtree *node)
{
+ unsigned long blocks;
+
if (!node->parent) TT.st_dev = node->st.st_dev;
else if (!dirtree_notdotdot(node)) return 0;
if (!node->parent) TT.st_dev = node->st.st_dev;
else if (!dirtree_notdotdot(node)) return 0;
- node->extra += node->st.st_blocks;
- if (node->parent) node->parent->extra += node->extra;
+ // Modern compilers' optimizers are insane and think signed overflow
+ // behaves differently than unsigned overflow. Sigh. Big hammer.
+ blocks = node->st.st_blocks + (unsigned long)node->extra;
+ node->extra = blocks;
+ if (node->parent)
+ node->parent->extra = (unsigned long)node->parent->extra+blocks;
else TT.total += node->extra;
if ((toys.optflags & FLAG_a) || !node->parent
|| (S_ISDIR(node->st.st_mode) && !(toys.optflags & FLAG_s)))
{
else TT.total += node->extra;
if ((toys.optflags & FLAG_a) || !node->parent
|| (S_ISDIR(node->st.st_mode) && !(toys.optflags & FLAG_s)))
{
- print(node->extra*512, node);
+ blocks = node->extra;
+ print(blocks*512LL, node);