truncate.2

来自「<B>Digital的Unix操作系统VAX 4.2源码</B>」· 2 代码 · 共 103 行

2
103
字号
.\" SCCSID: @(#)truncate.2	8.1	9/11/90.TH truncate 2.SH Nametruncate, ftruncate \- truncate a file to a specified length.SH Syntax.nf.ft Btruncate(path, length)char *path;int length;.PP.ft Bftruncate(fd, length)int fd, length;.fi.SH Description.NXR "truncate system call".NXR "ftruncate system call".NXR "file" "truncating to specified length"The.PN truncatesystem call causes the file named by.I pathor referenced by.I fdto be truncated to, at most,.I lengthbytes in size.  If the file previouslywas larger than this size, the extra datais lost.With.PN ftruncate ,the file must be open for writing..SH Return ValuesA value of zero (0) is returned if the call succeeds.  If the callfails, a \-1 is returned, and the global variable \fIerrno\fPspecifies the error..SH RestrictionsPartial blocks discarded as the result of truncationare not zero-filled. This can result in holes in filesthat do not read as zero..SH DiagnosticsThe.PN truncatesystem callsucceeds unless:.TP 15[ENOTDIR]A component of the path prefix is not a directory..TP 15[ENOENT]The named file does not exist..TP 15[EACCES]Search permission is denied for a component of the path prefix..TP 15[EISDIR]The named file is a directory..TP 15[EROFS]The named file resides on a read-only file system..TP 15[ETXTBSY]The file is a pure procedure (shared text) file that is being executed..TP 15[EFAULT]The.I path points outside the process's allocated address space..TP 15[ENAMETOOLONG]A component of a pathname exceeded 255 characters, or an entirepath name exceeded 1023 characters..TP 15[ELOOP]Too many symbolic links were encountered in translating thepathname..TP 15[EIO]An I/O error occurred updating the inode..PPThe.PN ftruncatesystem call succeeds unless:.TP 15[EBADF]The.I fdis not a valid descriptor..TP 15[EINVAL]The.I fdreferences a socket, not a file..TP[ETIMEDOUT]A connect request or remote file operation failed,because the connected partydid not properly respond after a periodof time that is dependent on the communications protocol..SH See Alsoopen(2)

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?