1 /* Linux fcntl syscall implementation -- non-cancellable.
2 Copyright (C) 2018-2023 Free Software Foundation, Inc.
3 This file is part of the GNU C Library.
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.
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.
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 <https://www.gnu.org/licenses/>. */
22 #include <sysdep-cancel.h>
23 #include <not-cancel.h>
26 # define __NR_fcntl64 __NR_fcntl
29 #ifndef FCNTL_ADJUST_CMD
30 # define FCNTL_ADJUST_CMD(__cmd) __cmd
34 __fcntl64_nocancel (int fd
, int cmd
, ...)
40 arg
= va_arg (ap
, void *);
43 cmd
= FCNTL_ADJUST_CMD (cmd
);
45 return __fcntl64_nocancel_adjusted (fd
, cmd
, arg
);
47 hidden_def (__fcntl64_nocancel
)
50 __fcntl64_nocancel_adjusted (int fd
, int cmd
, void *arg
)
54 struct f_owner_ex fex
;
55 int res
= INTERNAL_SYSCALL_CALL (fcntl64
, fd
, F_GETOWN_EX
, &fex
);
56 if (!INTERNAL_SYSCALL_ERROR_P (res
))
57 return fex
.type
== F_OWNER_GID
? -fex
.pid
: fex
.pid
;
59 return INLINE_SYSCALL_ERROR_RETURN_VALUE
60 (INTERNAL_SYSCALL_ERRNO (res
));
63 return INLINE_SYSCALL_CALL (fcntl64
, fd
, cmd
, (void *) arg
);