ftruncatefd
ftruncatefd is a function in POSIX-compliant operating systems that allows a program to truncate or extend a file to a specified size. It takes two arguments: a file descriptor and a length. The file descriptor refers to an open file, and the length specifies the desired new size of the file in bytes.
If the specified length is less than the current size of the file, the file is truncated,
ftruncatefd is useful for various file manipulation tasks, such as resizing log files, pre-allocating space for