logo

oasis-root

Compiled tree of Oasis Linux based on own branch at <https://hacktivis.me/git/oasis/> git clone https://anongit.hacktivis.me/git/oasis-root.git

truncate.3p (4372B)


  1. '\" et
  2. .TH TRUNCATE "3P" 2017 "IEEE/The Open Group" "POSIX Programmer's Manual"
  3. .\"
  4. .SH PROLOG
  5. This manual page is part of the POSIX Programmer's Manual.
  6. The Linux implementation of this interface may differ (consult
  7. the corresponding Linux manual page for details of Linux behavior),
  8. or the interface may not be implemented on Linux.
  9. .\"
  10. .SH NAME
  11. truncate
  12. \(em truncate a file to a specified length
  13. .SH SYNOPSIS
  14. .LP
  15. .nf
  16. #include <unistd.h>
  17. .P
  18. int truncate(const char *\fIpath\fP, off_t \fIlength\fP);
  19. .fi
  20. .SH DESCRIPTION
  21. The
  22. \fItruncate\fR()
  23. function shall cause the regular file named by
  24. .IR path
  25. to have a size which shall be equal to
  26. .IR length
  27. bytes.
  28. .P
  29. If the file previously was larger than
  30. .IR length ,
  31. the extra data is discarded. If the file was previously shorter than
  32. .IR length ,
  33. its size is increased, and the extended area appears as if it were
  34. zero-filled.
  35. .P
  36. The application shall ensure that the process has write permission for
  37. the file.
  38. .P
  39. If the request would cause the file size to exceed the soft file size
  40. limit for the process, the request shall fail and the implementation
  41. shall generate the SIGXFSZ signal for the process.
  42. .P
  43. The
  44. \fItruncate\fR()
  45. function shall not modify the file offset for any open file descriptions
  46. associated with the file. Upon successful completion,
  47. \fItruncate\fR()
  48. shall mark for update the last data modification and last file status
  49. change timestamps of the file, and the S_ISUID and S_ISGID bits of the
  50. file mode may be cleared.
  51. .SH "RETURN VALUE"
  52. Upon successful completion,
  53. \fItruncate\fR()
  54. shall return 0. Otherwise, \-1 shall be returned, and
  55. .IR errno
  56. set to indicate the error.
  57. .SH ERRORS
  58. The
  59. \fItruncate\fR()
  60. function shall fail if:
  61. .TP
  62. .BR EINTR
  63. A signal was caught during execution.
  64. .TP
  65. .BR EINVAL
  66. The
  67. .IR length
  68. argument was less than 0.
  69. .TP
  70. .BR EFBIG " or " EINVAL
  71. .br
  72. The
  73. .IR length
  74. argument was greater than the maximum file size.
  75. .TP
  76. .BR EIO
  77. An I/O error occurred while reading from or writing to a file system.
  78. .TP
  79. .BR EACCES
  80. A component of the path prefix denies search permission, or write
  81. permission is denied on the file.
  82. .TP
  83. .BR EISDIR
  84. The named file is a directory.
  85. .TP
  86. .BR ELOOP
  87. A loop exists in symbolic links encountered during resolution of the
  88. .IR path
  89. argument.
  90. .TP
  91. .BR ENAMETOOLONG
  92. .br
  93. The length of a component of a pathname is longer than
  94. {NAME_MAX}.
  95. .TP
  96. .BR ENOENT
  97. A component of
  98. .IR path
  99. does not name an existing file or
  100. .IR path
  101. is an empty string.
  102. .TP
  103. .BR ENOTDIR
  104. A component of the path prefix names an existing file that is neither
  105. a directory nor a symbolic link to a directory, or the
  106. .IR path
  107. argument contains at least one non-\c
  108. <slash>
  109. character and ends with one or more trailing
  110. <slash>
  111. characters and the last pathname component names an existing file
  112. that is neither a directory nor a symbolic link to a directory.
  113. .TP
  114. .BR EROFS
  115. The named file resides on a read-only file system.
  116. .br
  117. .P
  118. The
  119. \fItruncate\fR()
  120. function may fail if:
  121. .TP
  122. .BR ELOOP
  123. More than
  124. {SYMLOOP_MAX}
  125. symbolic links were encountered during resolution of the
  126. .IR path
  127. argument.
  128. .TP
  129. .BR ENAMETOOLONG
  130. .br
  131. The length of a pathname exceeds
  132. {PATH_MAX},
  133. or pathname resolution of a symbolic link produced an intermediate
  134. result with a length that exceeds
  135. {PATH_MAX}.
  136. .LP
  137. .IR "The following sections are informative."
  138. .SH EXAMPLES
  139. None.
  140. .SH "APPLICATION USAGE"
  141. None.
  142. .SH RATIONALE
  143. None.
  144. .SH "FUTURE DIRECTIONS"
  145. None.
  146. .SH "SEE ALSO"
  147. .IR "\fIopen\fR\^(\|)"
  148. .P
  149. The Base Definitions volume of POSIX.1\(hy2017,
  150. .IR "\fB<unistd.h>\fP"
  151. .\"
  152. .SH COPYRIGHT
  153. Portions of this text are reprinted and reproduced in electronic form
  154. from IEEE Std 1003.1-2017, Standard for Information Technology
  155. -- Portable Operating System Interface (POSIX), The Open Group Base
  156. Specifications Issue 7, 2018 Edition,
  157. Copyright (C) 2018 by the Institute of
  158. Electrical and Electronics Engineers, Inc and The Open Group.
  159. In the event of any discrepancy between this version and the original IEEE and
  160. The Open Group Standard, the original IEEE and The Open Group Standard
  161. is the referee document. The original Standard can be obtained online at
  162. http://www.opengroup.org/unix/online.html .
  163. .PP
  164. Any typographical or formatting errors that appear
  165. in this page are most likely
  166. to have been introduced during the conversion of the source files to
  167. man page format. To report such errors, see
  168. https://www.kernel.org/doc/man-pages/reporting_bugs.html .