version 1, including all changes.
.
Rev |
Author |
# |
Line |
1 |
perry |
1 |
TRUNCATE |
|
|
2 |
!!!TRUNCATE |
|
|
3 |
NAME |
|
|
4 |
SYNOPSIS |
|
|
5 |
DESCRIPTION |
|
|
6 |
RETURN VALUE |
|
|
7 |
ERRORS |
|
|
8 |
CONFORMING TO |
|
|
9 |
BUGS |
|
|
10 |
SEE ALSO |
|
|
11 |
---- |
|
|
12 |
!!NAME |
|
|
13 |
|
|
|
14 |
|
|
|
15 |
truncate, ftruncate - truncate a file to a specified length |
|
|
16 |
!!SYNOPSIS |
|
|
17 |
|
|
|
18 |
|
|
|
19 |
__#include __ |
|
|
20 |
|
|
|
21 |
|
|
|
22 |
__int truncate(const char *__''path''__, off_t__ |
|
|
23 |
''length''__); |
|
|
24 |
int ftruncate(int__ ''fd''__, off_t__ |
|
|
25 |
''length''__);__ |
|
|
26 |
!!DESCRIPTION |
|
|
27 |
|
|
|
28 |
|
|
|
29 |
__Truncate__ causes the file named by ''path'' or |
|
|
30 |
referenced by ''fd'' to be truncated to at most |
|
|
31 |
''length'' bytes in size. If the file previously was |
|
|
32 |
larger than this size, the extra data is lost. If the file |
|
|
33 |
previously was shorter, it is unspecified whether the file |
|
|
34 |
is left unchanged or is extended. In the latter case the |
|
|
35 |
extended part reads as zero bytes. With __ftruncate__, |
|
|
36 |
the file must be open for writing. |
|
|
37 |
!!RETURN VALUE |
|
|
38 |
|
|
|
39 |
|
|
|
40 |
On success, zero is returned. On error, -1 is returned, and |
|
|
41 |
''errno'' is set appropriately. |
|
|
42 |
!!ERRORS |
|
|
43 |
|
|
|
44 |
|
|
|
45 |
For __truncate__: |
|
|
46 |
|
|
|
47 |
|
|
|
48 |
__ENOTDIR__ |
|
|
49 |
|
|
|
50 |
|
|
|
51 |
A component of the path prefix is not a |
|
|
52 |
directory. |
|
|
53 |
|
|
|
54 |
|
|
|
55 |
__ENAMETOOLONG__ |
|
|
56 |
|
|
|
57 |
|
|
|
58 |
A component of a pathname exceeded 255 characters, or an |
|
|
59 |
entire path name exceeded 1023 characters. |
|
|
60 |
|
|
|
61 |
|
|
|
62 |
__ENOENT__ |
|
|
63 |
|
|
|
64 |
|
|
|
65 |
The named file does not exist. |
|
|
66 |
|
|
|
67 |
|
|
|
68 |
__EACCES__ |
|
|
69 |
|
|
|
70 |
|
|
|
71 |
Search permission is denied for a component of the path |
|
|
72 |
prefix. |
|
|
73 |
|
|
|
74 |
|
|
|
75 |
__EACCES__ |
|
|
76 |
|
|
|
77 |
|
|
|
78 |
The named file is not writable by the user. |
|
|
79 |
|
|
|
80 |
|
|
|
81 |
__ELOOP__ |
|
|
82 |
|
|
|
83 |
|
|
|
84 |
Too many symbolic links were encountered in translating the |
|
|
85 |
pathname. |
|
|
86 |
|
|
|
87 |
|
|
|
88 |
__EISDIR__ |
|
|
89 |
|
|
|
90 |
|
|
|
91 |
The named file is a directory. |
|
|
92 |
|
|
|
93 |
|
|
|
94 |
__EROFS__ |
|
|
95 |
|
|
|
96 |
|
|
|
97 |
The named file resides on a read-only file |
|
|
98 |
system. |
|
|
99 |
|
|
|
100 |
|
|
|
101 |
__ETXTBSY__ |
|
|
102 |
|
|
|
103 |
|
|
|
104 |
The file is a pure procedure (shared text) file that is |
|
|
105 |
being executed. |
|
|
106 |
|
|
|
107 |
|
|
|
108 |
__EIO__ |
|
|
109 |
|
|
|
110 |
|
|
|
111 |
An I/O error occurred updating the inode. |
|
|
112 |
|
|
|
113 |
|
|
|
114 |
__EFAULT__ |
|
|
115 |
|
|
|
116 |
|
|
|
117 |
''Path'' points outside the process's allocated address |
|
|
118 |
space. |
|
|
119 |
|
|
|
120 |
|
|
|
121 |
For __ftruncate__: |
|
|
122 |
|
|
|
123 |
|
|
|
124 |
__EBADF__ |
|
|
125 |
|
|
|
126 |
|
|
|
127 |
The ''fd'' is not a valid descriptor. |
|
|
128 |
|
|
|
129 |
|
|
|
130 |
__EINVAL__ |
|
|
131 |
|
|
|
132 |
|
|
|
133 |
The ''fd'' references a socket, not a file. |
|
|
134 |
|
|
|
135 |
|
|
|
136 |
__EINVAL__ |
|
|
137 |
|
|
|
138 |
|
|
|
139 |
The ''fd'' is not open for writing. |
|
|
140 |
!!CONFORMING TO |
|
|
141 |
|
|
|
142 |
|
|
|
143 |
4.4BSD, SVr4 (these function calls first appeared in BSD |
|
|
144 |
4.2). SVr4 documents additional __truncate__ error |
|
|
145 |
conditions EINTR, EMFILE, EMULTIHP, ENAMETOOLONG, ENFILE, |
|
|
146 |
ENOLINK, ENOTDIR. SVr4 documents for __ftruncate__ |
|
|
147 |
additional EAGAIN and EINTR error conditions. POSIX has |
|
|
148 |
''ftruncate'' but not ''truncate''. |
|
|
149 |
|
|
|
150 |
|
|
|
151 |
The POSIX standard does not define what happens if the file |
|
|
152 |
has fewer bytes than ''length''. |
|
|
153 |
!!BUGS |
|
|
154 |
|
|
|
155 |
|
|
|
156 |
These calls should be generalized to allow ranges of bytes |
|
|
157 |
in a file to be discarded. |
|
|
158 |
!!SEE ALSO |
|
|
159 |
|
|
|
160 |
|
|
|
161 |
open(2) |
|
|
162 |
---- |