File: truncate.2

package info (click to toggle)
manpages-es 1.55-4
  • links: PTS
  • area: main
  • in suites: etch, etch-m68k
  • size: 7,472 kB
  • ctags: 6
  • sloc: sh: 1,349; makefile: 63
file content (184 lines) | stat: -rw-r--r-- 6,080 bytes parent folder | download | duplicates (4)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
.\" Copyright (c) 1983, 1991 The Regents of the University of California.
.\" All rights reserved.
.\"
.\" Redistribution and use in source and binary forms, with or without
.\" modification, are permitted provided that the following conditions
.\" are met:
.\" 1. Redistributions of source code must retain the above copyright
.\"    notice, this list of conditions and the following disclaimer.
.\" 2. Redistributions in binary form must reproduce the above copyright
.\"    notice, this list of conditions and the following disclaimer in the
.\"    documentation and/or other materials provided with the distribution.
.\" 3. All advertising materials mentioning features or use of this software
.\"    must display the following acknowledgement:
.\"	This product includes software developed by the University of
.\"	California, Berkeley and its contributors.
.\" 4. Neither the name of the University nor the names of its contributors
.\"    may be used to endorse or promote products derived from this software
.\"    without specific prior written permission.
.\"
.\" THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
.\" ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
.\" IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
.\" ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
.\" FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
.\" DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
.\" OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
.\" HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
.\" LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
.\" OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
.\" SUCH DAMAGE.
.\"
.\"     @(#)truncate.2	6.9 (Berkeley) 3/10/91
.\"
.\" Modified Sat Jul 24 12:46:33 1993 by Rik Faith <faith@cs.unc.edu>
.\" Modified Tue Oct 22 22:36:33 1996 by Eric S. Raymond <esr@thyrsus.com>
.\" Modified Mon Dec 21 13:37:05 1998 by Andries Brouwer <aeb@cwi.nl>
.\" Modified 7 Jan 2002, Michael Kerrisk <mtk16@ext.canterbury.ac.nz>
.\" Modified 2002-04-06, aeb
.\"
.\" Translated by Urko Lusa <ulusa@lacueva.ddns.org> 19980210
.\" Translation revised May 1 1998 by Juan Piernas <piernas@dif.um.es> with
.\" fixes from Nicolás Lichtmaier <nick@debian.org>
.\" Modified Mon Dec 21 13:37:05 1998 by Andries Brouwer (aeb@cwi.nl)
.\" Translation revised on Tue Apr 6 1999 by Juan Piernas <piernas@ditec.um.es>
.\" Revisado por Miguel Pérez Ibars <mpi79470@alu.um.es> el 1-diciembre-2004
.\"
.TH TRUNCATE 2 "21 diciembre 1998" "Linux" "Manual del programador de Linux"
.SH NOMBRE
truncate, ftruncate \- trunca un fichero a una longitud especificada
.SH SINOPSIS
.B #include <unistd.h>
.br
.B #include <sys/types.h>
.sp
.BI "int truncate(const char *" path ", off_t " length );
.br
.BI "int ftruncate(int " fd ", off_t " length );
.SH DESCRIPCIÓN
Las funciones
.B truncate
y
.B ftruncate
hacen que el fichero regular cuyo nombre es
.I path
o que es referenciado por
.I fd
sea truncado a un tamaño de 
.I length
bytes.
.LP
Si el fichero era previamente más grande que este tamaño, los datos extra se pierden.
Si el fichero era previamente más pequeño, es extendido, y
la zona ampliada es rellenada con bytes cero.
.LP
El puntero del fichero no se modifica.
.LP
Si el tamaño cambia, los campos ctime y mtime del fichero son actualizados,
y los bits de modo suid y sgid pueden ser limpiados.
.LP
Con
.BR ftruncate ,
el fichero debe estar abierto para escritura; con
.BR truncate ,
el fichero debe ser escribible.
.SH "VALOR DEVUELTO"
En caso de éxito, se devuelve cero. En caso de  error,  se
devuelve -1 y se establece el
.I errno
apropiado.
.SH ERRORES
Para
.BR truncate :
.TP
.B EACCES
Se deniega el permiso de búsqueda para un componente del prefijo de la ruta,
o el fichero nombrado no puede ser escrito por el usuario.
.TP
.B EFAULT
.I Path
apunta fuera del espacio de direcciones asignado al proceso.
.TP
.B EFBIG
El argumento
.I length
es mayor que el tamaño máximo de fichero. (XSI)
.TP
.B EINTR
Se capturó una señal durante la ejecución.
.TP
.B EINVAL
El argumento
.I length
es negativo o mayor que el tamaño máximo de fichero.
.TP
.B EIO
Ocurrió un error de E/S mientras se actualizaba el nodo-i.
.TP
.B EISDIR
El fichero nombrado es un directorio.
.TP
.B ELOOP
Demasiados enlaces simbólicos en la traducción del nombre de ruta.
.TP
.B ENAMETOOLONG
Un componente de la ruta excede los 255 caracteres, o la ruta completa
excede los 1023 caracteres.
.TP
.B ENOENT
El fichero no existe.
.TP
.B EROFS
El fichero reside en un sistema de ficheros de sólo lectura.
.TP
.B ETXTBSY
El fichero es un fichero de procedimientos puros (código
compartido) que se está ejecutando.
.PP
Para
.B ftruncate
se aplican los mismos errores, pero en lugar de tratar con 
.IR path ,
los errores pueden ocurrir ahora con
.IR fd :
.TP
.B EBADF
.I fd
no es un descriptor válido.
.TP
.BR EBADF " o " EINVAL
.I fd
no está abierto para escritura.
.TP
.B EINVAL
.I fd
no hace referencia a un fichero regular.
.SH "CONFORME A"
4.4BSD, SVr4 (estas funciones aparecieron por primera vez en BSD 4.2).
POSIX 1003.1-1996 posee
.BR ftruncate .
POSIX 1003.1-2001 posee también
.IR truncate ,
como una extensión de XSI.
.LP
SVr4 documenta para
.B truncate
las condiciones de error adicionales EMFILE, EMULTIHP, ENFILE, ENOLINK.  SVr4 documenta para
.B ftruncate
una condición de error adicional EAGAIN.
.SH OBSERVACIONES
La descripción de arriba es para sistemas conformes con XSI.
Para sistemas no conformes con XSI, el estándar POSIX permite
dos comportamientos para
.B ftruncate
cuando
.I length
excede la longitud del fichero
(observe que
.B truncate
no está especificada en absoluto en tales condiciones):
bien devolver un error o extender el fichero.
(La mayoría de sistemas UNIX siguen el requisito de XSI.)
.\" At the very least: OSF/1, Solaris 7, and FreeBSD conform, mtk, Jan 2002
.SH "VÉASE TAMBIÉN"
.BR open (2)