|
|
1.1 ! root 1: .TH TRUNCATE 2 "7 July 1983" ! 2: .UC 4 ! 3: .SH NAME ! 4: truncate \- truncate a file to a specified length ! 5: .SH SYNOPSIS ! 6: .nf ! 7: .ft B ! 8: truncate(path, length) ! 9: char *path; ! 10: int length; ! 11: .PP ! 12: .ft B ! 13: ftruncate(fd, length) ! 14: int fd, length; ! 15: .fi ! 16: .SH DESCRIPTION ! 17: .I Truncate ! 18: causes the file named by ! 19: .I path ! 20: or referenced by ! 21: .I fd ! 22: to be truncated to at most ! 23: .I length ! 24: bytes in size. If the file previously ! 25: was larger than this size, the extra data ! 26: is lost. ! 27: With ! 28: .IR ftruncate , ! 29: the file must be open for writing. ! 30: .SH "RETURN VALUES ! 31: A value of 0 is returned if the call succeeds. If the call ! 32: fails a \-1 is returned, and the global variable \fIerrno\fP ! 33: specifies the error. ! 34: .SH "ERRORS ! 35: .I Truncate ! 36: succeeds unless: ! 37: .TP 15 ! 38: [EPERM] ! 39: The pathname contains a character with the high-order bit set. ! 40: .TP 15 ! 41: [ENOENT] ! 42: The pathname was too long. ! 43: .TP 15 ! 44: [ENOTDIR] ! 45: A component of the path prefix of \fIpath\fP is not a directory. ! 46: .TP 15 ! 47: [ENOENT] ! 48: The named file does not exist. ! 49: .TP 15 ! 50: [EACCES] ! 51: A component of the \fIpath\fP prefix denies search permission. ! 52: .TP 15 ! 53: [EISDIR] ! 54: The named file is a directory. ! 55: .TP 15 ! 56: [EROFS] ! 57: The named file resides on a read-only file system. ! 58: .TP 15 ! 59: [ETXTBSY] ! 60: The file is a pure procedure (shared text) file that is being executed. ! 61: .TP 15 ! 62: [EFAULT] ! 63: .I Name ! 64: points outside the process's allocated address space. ! 65: .PP ! 66: .I Ftruncate ! 67: succeeds unless: ! 68: .TP 15 ! 69: [EBADF] ! 70: The ! 71: .I fd ! 72: is not a valid descriptor. ! 73: .TP 15 ! 74: [EINVAL] ! 75: The ! 76: .I fd ! 77: references a socket, not a file. ! 78: .SH "SEE ALSO" ! 79: open(2) ! 80: .SH BUGS ! 81: Partial blocks discarded as the result of truncation ! 82: are not zero filled; this can result in holes in files ! 83: which do not read as zero. ! 84: .PP ! 85: These calls should be generalized to allow ranges ! 86: of bytes in a file to be discarded.
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.