Penguin
Blame: ftruncate(2)
EditPageHistoryDiffInfoLikePages
Annotated edit history of ftruncate(2) version 2, including all changes. View license author blame.
Rev Author # Line
1 perry 1 !!NAME
2 PerryLorier 2 truncate, ftruncate - truncate a file to a specified length
1 perry 3
4 !!SYNOPSIS
2 PerryLorier 5 __#include <unistd>__
6 __int ftruncate(int__ ''fd''__, off_t__ ''length''__);__
1 perry 7
8 !!DESCRIPTION
2 PerryLorier 9 ftruncate(2) causes the file 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. If the file previously was shorter, it is unspecified whether the file is left unchanged or is extended. In the latter case the extended part reads as zero bytes. With ftruncate(2), the file must be open for writing.
1 perry 10
11 !!RETURN VALUE
2 PerryLorier 12 On success, zero is returned. On error, -1 is returned, and ''errno'' is set appropriately.
1 perry 13
14 !!ERRORS
2 PerryLorier 15 ;[EBADF]: The ''fd'' is not a valid descriptor.
16 ;[EINVAL]: The ''fd'' references a socket, not a file. ''(what happens if you call it on a pipe?)''
17 ;[EINVAL]: The ''fd'' is not open for writing.
18 ;[EACCES]: The named file is not writable by the user.
19 ;[EISDIR]: The named file is a directory.
20 ;[EROFS]: The named file resides on a read-only file system.
21 ;[ETXTBSY]: The file is a pure procedure (shared text) file that is being executed.
22 ;[EIO]: An I/O error occurred updating the inode.
23 ;[EFAULT]: ''Path'' points outside the process's allocated address space.
1 perry 24
25 !!CONFORMING TO
2 PerryLorier 26 4.4BSD, SVr4 (these function calls first appeared in BSD 4.2). SVr4 documents for ftruncate(2) additional [EAGAIN] and [EINTR] error conditions. POSIX has ''ftruncate(2)'' but not ''truncate(2)''.
1 perry 27
2 PerryLorier 28 The POSIX standard does not define what happens if the file has fewer bytes than ''length''.
1 perry 29
30 !!BUGS
2 PerryLorier 31 These calls should be generalized to allow ranges of bytes in a file to be discarded.
1 perry 32
33 !!SEE ALSO
2 PerryLorier 34 open(2), truncate(2)
This page is a man page (or other imported legacy content). We are unable to automatically determine the license status of this page.

PHP Warning

lib/blame.php:177: Warning: Invalid argument supplied for foreach() (...repeated 8 times)