CLUSTER_SIZE(*ef->sb) / 512;
stbuf->st_mtime = node->mtime;
stbuf->st_atime = node->atime;
- stbuf->st_ctime = 0; /* unapplicable */
+ /* set ctime to mtime to ensure we don't break programs that rely on ctime
+ (e.g. rsync) */
+ stbuf->st_ctime = node->mtime;
}
#define SEC_IN_MIN 60ll
size_t i;
const char* units[] = {"bytes", "KB", "MB", "GB", "TB", "PB"};
uint64_t divisor = 1;
+ uint64_t temp = 0;
- for (i = 0; i < sizeof(units) / sizeof(units[0]) - 1; i++)
+ for (i = 0; i < sizeof(units) / sizeof(units[0]) - 1; i++, divisor *= 1024)
{
- if ((value + divisor / 2) / divisor < 1024)
+ temp = (value + divisor / 2) / divisor;
+
+ if (temp == 0)
+ break;
+ if (temp / 1024 * 1024 == temp)
+ continue;
+ if (temp < 10240)
break;
- divisor *= 1024;
}
- hb->value = (value + divisor / 2) / divisor;
+ hb->value = temp;
hb->unit = units[i];
}