use fcntl manipulate file descriptor api to lock and unlock file
use truncate and ftruncate in linux