Penguin

Differences between current version and revision by previous author of ftruncate(2).

Other diffs: Previous Major Revision, Previous Revision, or view the Annotated Edit History

Newer page: version 2 Last edited on Thursday, November 7, 2002 12:24:02 am by PerryLorier
Older page: version 1 Last edited on Tuesday, June 4, 2002 12:23:41 am by perry Revert
@@ -1,162 +1,34 @@
-TRUNCATE  
-!!!TRUNCATE  
-NAME  
-SYNOPSIS  
-DESCRIPTION  
-RETURN VALUE  
-ERRORS  
-CONFORMING TO  
-BUGS  
-SEE ALSO  
-----  
 !!NAME 
+truncate, ftruncate - truncate a file to a specified length  
  
-  
-truncate, ftruncate - truncate a file to a specified length  
 !!SYNOPSIS 
+ __#include <unistd>__  
+ __int ftruncate(int__ ''fd''__, off_t__ ''length''__);__  
  
-  
-__#include __  
-  
-  
-__int truncate(const char *__''path''__, off_t__  
-''length''__);  
-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.  
  
-  
-__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.  
  
-  
-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.  
  
-  
-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 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''.  
  
-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.  
  
-  
-These calls should be generalized to allow ranges of bytes  
-in a file to be discarded.  
 !!SEE ALSO 
-  
-  
- open(2)  
-----  
+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.