xref: /netbsd-src/lib/libc/sys/ftruncate.c (revision 68e3ffa3778a98182d102ab73fe6b49c7d2b6bd1)
1*68e3ffa3Smatt /*	$NetBSD: ftruncate.c,v 1.14 2012/03/20 16:26:12 matt Exp $	*/
2c67e54a2Scgd 
3218c24c1Scgd /*
4218c24c1Scgd  * Copyright (c) 1992, 1993
5218c24c1Scgd  *	The Regents of the University of California.  All rights reserved.
6218c24c1Scgd  *
7218c24c1Scgd  * Redistribution and use in source and binary forms, with or without
8218c24c1Scgd  * modification, are permitted provided that the following conditions
9218c24c1Scgd  * are met:
10218c24c1Scgd  * 1. Redistributions of source code must retain the above copyright
11218c24c1Scgd  *    notice, this list of conditions and the following disclaimer.
12218c24c1Scgd  * 2. Redistributions in binary form must reproduce the above copyright
13218c24c1Scgd  *    notice, this list of conditions and the following disclaimer in the
14218c24c1Scgd  *    documentation and/or other materials provided with the distribution.
15eb7c1594Sagc  * 3. Neither the name of the University nor the names of its contributors
16218c24c1Scgd  *    may be used to endorse or promote products derived from this software
17218c24c1Scgd  *    without specific prior written permission.
18218c24c1Scgd  *
19218c24c1Scgd  * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
20218c24c1Scgd  * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
21218c24c1Scgd  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
22218c24c1Scgd  * ARE DISCLAIMED.  IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
23218c24c1Scgd  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
24218c24c1Scgd  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
25218c24c1Scgd  * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
26218c24c1Scgd  * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
27218c24c1Scgd  * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
28218c24c1Scgd  * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
29218c24c1Scgd  * SUCH DAMAGE.
30218c24c1Scgd  */
31218c24c1Scgd 
323ad08ca2Schristos #include <sys/cdefs.h>
33218c24c1Scgd #if defined(LIBC_SCCS) && !defined(lint)
34c67e54a2Scgd #if 0
35c67e54a2Scgd static char sccsid[] = "@(#)ftruncate.c	8.1 (Berkeley) 6/17/93";
36c67e54a2Scgd #else
37*68e3ffa3Smatt __RCSID("$NetBSD: ftruncate.c,v 1.14 2012/03/20 16:26:12 matt Exp $");
38c67e54a2Scgd #endif
39218c24c1Scgd #endif /* LIBC_SCCS and not lint */
40ae0bb689Scgd 
41dc86984bSkleink #include "namespace.h"
42ae0bb689Scgd #include <sys/types.h>
43ae0bb689Scgd #include <sys/syscall.h>
44d3b76936Scgd #include <unistd.h>
45ae0bb689Scgd 
46dc86984bSkleink #ifdef __weak_alias
4760549036Smycroft __weak_alias(ftruncate,_ftruncate)
48dc86984bSkleink #endif
49dc86984bSkleink 
502b37ebddSuebayasi int __ftruncate(int, int, off_t);
51b0b7248dSdsl 
52218c24c1Scgd /*
53218c24c1Scgd  * This function provides 64-bit offset padding that
54218c24c1Scgd  * is not supplied by GCC 1.X but is supplied by GCC 2.X.
55218c24c1Scgd  */
56ae0bb689Scgd int
ftruncate(int fd,off_t length)57*68e3ffa3Smatt ftruncate(int fd, off_t length)
58ae0bb689Scgd {
59ae0bb689Scgd 
60b0b7248dSdsl 	return __ftruncate(fd, 0, length);
61ae0bb689Scgd }
62