The truncate() function causes the regular file named by path to have a size of length bytes.
The ftruncate() function causes the regular file referenced by fildes to have a size of length bytes.
The effect of ftruncate() and truncate() on other types of files is unspecified. If the file previously was larger than length, the
extra data is lost. If it was previously shorter than length, bytes between the old and new lengths are read as zeroes. With ftruncate(), the file must be
open for writing; for truncate(), the process must have write permission for the file.
If the request would cause the file size to exceed the soft file size limit for the process, the request will fail and the implementation will generate the SIGXFSZ
signal for the process.
These functions do not modify the file offset for any open file descriptions associated with the file. On successful completion, if the file size is changed, these functions will mark for update
the st_ctime and st_mtime fields of the file, and if the file is a regular file, the S_ISUID and S_ISGID bits of the file mode may be cleared.
|