.\" 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 .\" Translated by Urko Lusa 19980210 .\" Translation revised May 1 1998 by Juan Piernas with .\" fixes from Nicolás Lichtmaier .\" Modified Mon Dec 21 13:37:05 1998 by Andries Brouwer (aeb@cwi.nl) .\" Translation revised on Tue Apr 6 1999 by Juan Piernas .\" .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 .sp .BI "int truncate(const char *" path ", off_t " length ); .br .BI "int ftruncate(int " fd ", off_t " length ); .SH DESCRIPCIÓN .B truncate hace que el fichero nombrado por .I path o referido por .I fd sea truncado a una longitud máxima de .I length bytes. Si el fichero era mayor que dicha longitud, los datos extra se perderán. Con .BR ftruncate , el fichero debe estar abierto para escritura. .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 ENOTDIR Un componente de la ruta no es un directorio. .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 EACCES No se tiene permiso de búsqueda para algún componente de la ruta. .TP .B EACCES El usuario no tiene permiso de escritura sobre el fichero. .TP .B ELOOP Se encontraron demasiados enlaces simbólicos al traducir la ruta. .TP .B EISDIR El fichero es en realidad un directorio. .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. .TP .B EIO Ocurrió un error de E/S al actualizar el inodo. .TP .B EFAULT .I path apunta fuera del espacio de direcciones asignado al proceso. .PP Para .BR ftruncate : .TP .B EBADF .I fd no es un descriptor válido. .TP .B EINVAL .I fd hace referencia a un socket, no a un fichero. .TP .B EINVAL .I fd no está abierto para escritura. .SH "CONFORME A" 4.4BSD, SVr4 (estas funciones aparecieron por primera vez en BSD 4.2). SVr4 documenta las condiciones de error adicionales EINTR, EMFILE, EMULTIHP, ENAMETOOLONG, ENFILE, ENOLINK y ENOTDIR para .BR truncate . SVr4 documenta las condiciones de error adicionales EAGAIN y EINTR para .BR ftruncate . POSIX posee .I ftruncate pero no .IR truncate . .SH FALLOS Estas llamadas deberían ser ampliadas para permitir descartar rangos de bytes de un fichero. .SH "VÉASE TAMBIÉN" .BR open (2)