Home
Main website
Display Sidebar
Hide Ads
Recent Changes
View Source:
truncate(2)
Edit
PageHistory
Diff
Info
LikePages
TRUNCATE !!!TRUNCATE NAME SYNOPSIS DESCRIPTION RETURN VALUE ERRORS CONFORMING TO BUGS SEE ALSO ---- !!NAME truncate, ftruncate - truncate a file to a specified length !!SYNOPSIS __#include __ __int truncate(const char *__''path''__, off_t__ ''length''__); int ftruncate(int__ ''fd''__, off_t__ ''length''__);__ !!DESCRIPTION __Truncate__ causes the file named by ''path'' or 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__, 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 For __truncate__: __ENOTDIR__ A component of the path prefix is not a directory. __ENAMETOOLONG__ A component of a pathname exceeded 255 characters, or an entire path name exceeded 1023 characters. __ENOENT__ The named file does not exist. __EACCES__ Search permission is denied for a component of the path prefix. __EACCES__ The named file is not writable by the user. __ELOOP__ Too many symbolic links were encountered in translating the pathname. __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. For __ftruncate__: __EBADF__ The ''fd'' is not a valid descriptor. __EINVAL__ The ''fd'' references a socket, not a file. __EINVAL__ The ''fd'' is not open for writing. !!CONFORMING TO 4.4BSD, SVr4 (these function calls first appeared in BSD 4.2). SVr4 documents additional __truncate__ error conditions EINTR, EMFILE, EMULTIHP, ENAMETOOLONG, ENFILE, ENOLINK, ENOTDIR. SVr4 documents for __ftruncate__ additional EAGAIN and EINTR error conditions. POSIX has ''ftruncate'' but not ''truncate''. 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) ----
6 pages link to
truncate(2)
:
ftruncate(2)
Man2t
stat(2)
syscalls(2)
lstat(2)
fstat(2)
This page is a man page (or other imported legacy content). We are unable to automatically determine the license status of this page.