truncate(3)truncate(3)NAMEtruncate - sets a file to a specified length
SYNOPSIS
#include <sys/types.h>
int truncate (const char *path, off_t length );
LIBRARY
SVR4 Library (libsvr4)
DESCRIPTION
The file whose name is given by path or referenced by the descriptor
files has its size set to length bytes.
If the file was previously longer than length, bytes past length will
no longer be accessible. If it was shorter, bytes from the EOF before
the call to the EOF after the call will be read in as zeros. The effec‐
tive user ID of the process must have write permission for the file.
RETURN VALUES
Success. Failure.
ERRORS
Errno is set to indicate the errors. Failure may result from: Search
permission is denied on a component of the path prefix. Write permis‐
sion is denied for the file referred to by path. Path points outside
the process's allocated address space. A signal was caught during exe‐
cution of the truncate routine. Path is not an ordinary file. An I/O
error occured while reading from or writing to the file system. The
file referred to by path is a directory. Too many symbolic links were
encountered in translating the path. The length of a path component
exceeds {NAME_MAX} characters, or the length of path exceeds {PATH_MAX}
characters. Either a component of the path prefix or the file referred
to by path does not exist. A component of the path prefix of path is
not a directory. The file referred to by path resides on a read-only
file.
RELATED INFORMATION
Functions: chmod(2), fcntl(2), open(2)truncate(3)