helper: use fstat() to get the size of file