use mutex to protect ftruncate