Home
Main website
Display Sidebar
Hide Ads
Recent Changes
View Source:
ftruncate(2)
Edit
PageHistory
Diff
Info
LikePages
!!NAME truncate, ftruncate - truncate a file to a specified length !!SYNOPSIS __#include <unistd>__ __int ftruncate(int__ ''fd''__, off_t__ ''length''__);__ !!DESCRIPTION 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. !!RETURN VALUE On success, zero is returned. On error, -1 is returned, and ''errno'' is set appropriately. !!ERRORS ;[EBADF]: The ''fd'' is not a valid descriptor. ;[EINVAL]: The ''fd'' references a socket, not a file. ''(what happens if you call it on a pipe?)'' ;[EINVAL]: The ''fd'' is not open for writing. ;[EACCES]: The named file is not writable by the user. ;[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. ;[EIO]: An I/O error occurred updating the inode. ;[EFAULT]: ''Path'' points outside the process's allocated address space. !!CONFORMING TO 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)''. The POSIX standard does not define what happens if the file has fewer bytes than ''length''. !!BUGS These calls should be generalized to allow ranges of bytes in a file to be discarded. !!SEE ALSO open(2), truncate(2)
2 pages link to
ftruncate(2)
:
Man2f
syscalls(2)
This page is a man page (or other imported legacy content). We are unable to automatically determine the license status of this page.