Deleted Added
full compact
ftruncate.c (36808) ftruncate.c (71579)
1/*
2 * Copyright (c) 1992, 1993
3 * The Regents of the University of California. All rights reserved.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions
7 * are met:
8 * 1. Redistributions of source code must retain the above copyright

--- 15 unchanged lines hidden (view full) ---

24 * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
25 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
26 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
27 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
28 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
29 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
30 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
31 * SUCH DAMAGE.
1/*
2 * Copyright (c) 1992, 1993
3 * The Regents of the University of California. All rights reserved.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions
7 * are met:
8 * 1. Redistributions of source code must retain the above copyright

--- 15 unchanged lines hidden (view full) ---

24 * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
25 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
26 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
27 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
28 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
29 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
30 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
31 * SUCH DAMAGE.
32 *
33 * $FreeBSD: head/lib/libc/sys/ftruncate.c 71579 2001-01-24 13:01:12Z deischen $
32 */
33
34#if defined(LIBC_SCCS) && !defined(lint)
35static char sccsid[] = "@(#)ftruncate.c 8.1 (Berkeley) 6/17/93";
36#endif /* LIBC_SCCS and not lint */
37
38#include <sys/types.h>
39#include <sys/syscall.h>
40#include <unistd.h>
34 */
35
36#if defined(LIBC_SCCS) && !defined(lint)
37static char sccsid[] = "@(#)ftruncate.c 8.1 (Berkeley) 6/17/93";
38#endif /* LIBC_SCCS and not lint */
39
40#include <sys/types.h>
41#include <sys/syscall.h>
42#include <unistd.h>
41#ifdef _THREAD_SAFE
42#include <pthread.h>
43#include "pthread_private.h"
44#endif
45
46/*
47 * This function provides 64-bit offset padding that
48 * is not supplied by GCC 1.X but is supplied by GCC 2.X.
49 */
50int
51ftruncate(fd, length)
52 int fd;
53 off_t length;
54{
55
43
44/*
45 * This function provides 64-bit offset padding that
46 * is not supplied by GCC 1.X but is supplied by GCC 2.X.
47 */
48int
49ftruncate(fd, length)
50 int fd;
51 off_t length;
52{
53
56#ifdef _THREAD_SAFE
57 int retval;
58 if (_FD_LOCK(fd, FD_RDWR, NULL) != 0) {
59 retval = -1;
60 } else {
61 retval = __syscall((quad_t)SYS_ftruncate, fd, 0, length);
62 _FD_UNLOCK(fd, FD_RDWR);
63 }
64 return(retval);
65#else
66 return(__syscall((quad_t)SYS_ftruncate, fd, 0, length));
54 return(__syscall((quad_t)SYS_ftruncate, fd, 0, length));
67#endif
68}
55}