Deleted Added
full compact
fcntl.c (280959) fcntl.c (281714)
1/*-
2 * Copyright (c) 2008 Isilon Inc http://www.isilon.com/
3 * Authors: Doug Rabson <dfr@rabson.org>
4 * Developed with Red Inc: Alfred Perlstein <alfred@freebsd.org>
5 *
1/*-
2 * Copyright (c) 2008 Isilon Inc http://www.isilon.com/
3 * Authors: Doug Rabson <dfr@rabson.org>
4 * Developed with Red Inc: Alfred Perlstein <alfred@freebsd.org>
5 *
6 * Copyright (c) 2014-2015 The FreeBSD Foundation.
7 * All rights reserved.
8 *
9 * Portions of this software were developed by Konstantin Belousov
10 * under sponsorship from the FreeBSD Foundation.
11 *
6 * Redistribution and use in source and binary forms, with or without
7 * modification, are permitted provided that the following conditions
8 * are met:
9 * 1. Redistributions of source code must retain the above copyright
10 * notice, this list of conditions and the following disclaimer.
11 * 2. Redistributions in binary form must reproduce the above copyright
12 * notice, this list of conditions and the following disclaimer in the
13 * documentation and/or other materials provided with the distribution.

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

21 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
22 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
23 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
24 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
25 * SUCH DAMAGE.
26 */
27
28#include <sys/cdefs.h>
12 * Redistribution and use in source and binary forms, with or without
13 * modification, are permitted provided that the following conditions
14 * are met:
15 * 1. Redistributions of source code must retain the above copyright
16 * notice, this list of conditions and the following disclaimer.
17 * 2. Redistributions in binary form must reproduce the above copyright
18 * notice, this list of conditions and the following disclaimer in the
19 * documentation and/or other materials provided with the distribution.

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

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
34#include <sys/cdefs.h>
29__FBSDID("$FreeBSD: head/lib/libc/sys/fcntl.c 280959 2015-04-01 16:55:30Z kib $");
35__FBSDID("$FreeBSD: head/lib/libc/sys/fcntl.c 281714 2015-04-18 21:50:13Z kib $");
30
31#include <fcntl.h>
32#include <stdarg.h>
33#include <sys/types.h>
34#include <sys/syscall.h>
35#include "libc_private.h"
36
37#pragma weak fcntl

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

43
44 va_start(args, cmd);
45 arg = va_arg(args, long);
46 va_end(args);
47
48 return (((int (*)(int, int, ...))
49 __libc_interposing[INTERPOS_fcntl])(fd, cmd, arg));
50}
36
37#include <fcntl.h>
38#include <stdarg.h>
39#include <sys/types.h>
40#include <sys/syscall.h>
41#include "libc_private.h"
42
43#pragma weak fcntl

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

49
50 va_start(args, cmd);
51 arg = va_arg(args, long);
52 va_end(args);
53
54 return (((int (*)(int, int, ...))
55 __libc_interposing[INTERPOS_fcntl])(fd, cmd, arg));
56}
51
52#ifdef SYSCALL_COMPAT
53__weak_reference(__fcntl_compat, __fcntl);
54
55int
56__fcntl_compat(int fd, int cmd, ...)
57{
58 va_list args;
59 long arg;
60 struct __oflock ofl;
61 struct flock *flp;
62 int res;
63
64 va_start(args, cmd);
65 arg = va_arg(args, long);
66 va_end(args);
67
68 if (__getosreldate() >= 800028) {
69 return (__sys_fcntl(fd, cmd, arg));
70 } else {
71 if (cmd == F_GETLK || cmd == F_SETLK || cmd == F_SETLKW) {
72 /*
73 * Convert new-style struct flock (which
74 * includes l_sysid) to old-style.
75 */
76 flp = (struct flock *) (uintptr_t) arg;
77 ofl.l_start = flp->l_start;
78 ofl.l_len = flp->l_len;
79 ofl.l_pid = flp->l_pid;
80 ofl.l_type = flp->l_type;
81 ofl.l_whence = flp->l_whence;
82
83 switch (cmd) {
84 case F_GETLK:
85 res = __sys_fcntl(fd, F_OGETLK, &ofl);
86 if (res >= 0) {
87 flp->l_start = ofl.l_start;
88 flp->l_len = ofl.l_len;
89 flp->l_pid = ofl.l_pid;
90 flp->l_type = ofl.l_type;
91 flp->l_whence = ofl.l_whence;
92 flp->l_sysid = 0;
93 }
94 return (res);
95
96 case F_SETLK:
97 return (__sys_fcntl(fd, F_OSETLK, &ofl));
98
99 case F_SETLKW:
100 return (__sys_fcntl(fd, F_OSETLKW, &ofl));
101 }
102 }
103 return (__sys_fcntl(fd, cmd, arg));
104 }
105}
106#endif