TRUNCATE(2) COMMAND REFERENCE TRUNCATE(2) NAME truncate, ftruncate - truncate a file to a specified length SYNOPSIS truncate(path, length) char *path; long length; ftruncate(fd, length) int fd; long length; DESCRIPTION Truncate causes the file named by path or referenced by fd to be truncated to at most length bytes in size. If the file previously was larger than this size, the extra data is lost. With ftruncate, the file must be open for writing. DIAGNOSTICS Truncate succeeds unless: [ENOASCII] The pathname contains a character with the high-order bit set. [ENAMETOOLONG] The pathname path is too long. [ENOTDIR] A component of the path prefix of path is not a directory. [EIO] An I/O error occurred while reading from or writing to the file system. [ENOENT] The named file path does not exist. [EACCES] A component of the path prefix of path denies search permission. [EACCES] Write permission is denied for path. [EISDIR] The named file is a directory. [EROFS] The named file resides on a read-only file system. [ETXTBSY] The file is a pure procedure (shared text) file that is being executed. [EFAULT] Path points outside the process's allocated address space. [ELOOP] Too many symbolic links were encourntered in translating the pathname. Printed 4/6/89 1
TRUNCATE(2) COMMAND REFERENCE TRUNCATE(2) [EINVAL] Length value given was negative. Ftruncate succeeds unless: [EBADF] Fd is not a valid descriptor. [EACCES] Write permission is denied for the file referenced by fd. [EINVAL] Fd references a socket, not a file. [EROFS] Fd resides on a read-only file system. [EINVAL] Length value given was negative. RETURN VALUE Upon successful completion, a value of 0 is returned. Otherwise, a value of -1 is returned and errno is set to indicate the error. CAVEATS Partial blocks discarded as the result of truncation are not zero filled; this can result in holes in files which do not read as zero. These calls should be generalized to allow ranges of bytes in a file to be discarded. SEE ALSO open(2). Printed 4/6/89 2
%%index%% na:336,111; sy:447,1002; de:1449,572; di:2021,1340;3769,514; rv:4283,280; ca:4563,326; se:4889,125; %%index%%000000000133