1/* Manipulate file descriptor. Linux LFS version.
2 Copyright (C) 2018 Free Software Foundation, Inc.
3 This file is part of the GNU C Library.
4
5 The GNU C Library is free software; you can redistribute it and/or
6 modify it under the terms of the GNU Lesser General Public
7 License as published by the Free Software Foundation; either
8 version 2.1 of the License, or (at your option) any later version.
9
10 The GNU C Library is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 Lesser General Public License for more details.
14
15 You should have received a copy of the GNU Lesser General Public
16 License along with the GNU C Library; if not, see
17 <http://www.gnu.org/licenses/>. */
18
19#define fcntl __no_decl_fcntl
20#define __fcntl __no_decl___fcntl
21#include <fcntl.h>
22#undef fcntl
23#undef __fcntl
24#include <stdarg.h>
25#include <errno.h>
26#include <sysdep-cancel.h>
27
28#ifndef __NR_fcntl64
29# define __NR_fcntl64 __NR_fcntl
30#endif
31
32#ifndef FCNTL_ADJUST_CMD
33# define FCNTL_ADJUST_CMD(__cmd) __cmd
34#endif
35
36int
37__libc_fcntl64 (int fd, int cmd, ...)
38{
39 va_list ap;
40 void *arg;
41
42 va_start (ap, cmd);
43 arg = va_arg (ap, void *);
44 va_end (ap);
45
46 cmd = FCNTL_ADJUST_CMD (cmd);
47
48 if (cmd == F_SETLKW || cmd == F_SETLKW64 || cmd == F_OFD_SETLKW)
49 return SYSCALL_CANCEL (fcntl64, fd, cmd, arg);
50
51 return __fcntl64_nocancel_adjusted (fd, cmd, arg);
52}
53libc_hidden_def (__libc_fcntl64)
54weak_alias (__libc_fcntl64, __fcntl64)
55libc_hidden_weak (__fcntl64)
56weak_alias (__libc_fcntl64, fcntl64)
57
58#ifdef __OFF_T_MATCHES_OFF64_T
59weak_alias (__libc_fcntl64, __libc_fcntl)
60weak_alias (__libc_fcntl64, __fcntl)
61weak_alias (__libc_fcntl64, __GI___fcntl)
62weak_alias (__libc_fcntl64, fcntl)
63#endif
64