.\" Copyright (c) 1983, 1991 The Regents of the University of California.
.\" %sccs.include.redist.man%
.\" @(#)truncate.2 6.9 (Berkeley) %G%
.Nd truncate a file to a specified length
.Fn truncate "const char *path" "off_t length"
.Fn ftruncate "int fd" "off_t length"
to be truncated to at most
bytes in size. If the file previously
was larger than this size, the extra data
the file must be open for writing.
A value of 0 is returned if the call succeeds. If the call
fails a -1 is returned, and the global variable
.Bl -tag -width [ENOTDIR]
A component of the path prefix is not a directory.
The pathname contains a character with the high-order bit set.
A component of a pathname exceeded 255 characters,
or an entire path name exceeded 1023 characters.
The named file does not exist.
Search permission is denied for a component of the path prefix.
The named file is not writable by the user.
Too many symbolic links were encountered in translating the pathname.
The named file is a directory.
The named file resides on a read-only file system.
The file is a pure procedure (shared text) file that is being executed.
An I/O error occurred updating the inode.
points outside the process's allocated address space.
.Bl -tag -width [ENOTDIR]
is not a valid descriptor.
references a socket, not a file.
These calls should be generalized to allow ranges
of bytes in a file to be discarded.
function call appeared in