truncate (7) ( Linux man: Макропакеты и соглашения )
BSD mandoc
NAME
truncateftruncate
- truncate or extend a file to a specified length
LIBRARY
Lb libc
SYNOPSIS
#include <unistd.h> int
truncate (const char *path off_t length); int
ftruncate (int fd off_t length);
DESCRIPTION
The
truncate ();
system call
causes the file named by
Fa path
or referenced by
Fa fd
to be truncated or extended to
Fa length
bytes in size.
If the file
was larger than this size, the extra data
is lost.
If the file was smaller than this size,
it will be extended as if by writing bytes
with the value zero.
With
ftruncate (,);
the file must be open for writing.
RETURN VALUES
Rv -std
If the file to be modified is not a directory or
a regular file, the
truncate ();
call has no effect and returns the value 0.
ERRORS
The
truncate ();
system call
succeeds unless:
Bq Er ENOTDIR
A component of the path prefix is not a directory.
Bq Er ENAMETOOLONG
A component of a pathname exceeded 255 characters,
or an entire path name exceeded 1023 characters.
Bq Er ENOENT
The named file does not exist.
Bq Er EACCES
Search permission is denied for a component of the path prefix.
Bq Er EACCES
The named file is not writable by the user.
Bq Er ELOOP
Too many symbolic links were encountered in translating the pathname.
Bq Er EPERM
The named file has its immutable or append-only flag set, see the
chflags(2)
manual page for more information.
Bq Er EISDIR
The named file is a directory.
Bq Er EROFS
The named file resides on a read-only file system.
Bq Er ETXTBSY
The file is a pure procedure (shared text) file that is being executed.
Bq Er EFBIG
The
Fa length
argument was greater than the maximum file size.
Bq Er EINVAL
The
Fa length
argument was less than 0.
Bq Er EIO
An I/O error occurred updating the inode.
Bq Er EFAULT
The
Fa path
argument
points outside the process's allocated address space.
The
ftruncate ();
system call
succeeds unless:
Bq Er EBADF
The
Fa fd
argument
is not a valid descriptor.
Bq Er EINVAL
The
Fa fd
argument
references a socket, not a file.