change to handle the return value of ftruncate