localedata: dz_BT, bo_CN: convert to UTF-8
[glibc.git] / sysdeps / unix / sysv / linux / fcntl_nocancel.c
blob68483d843e57481d342d2e05aaa37d6286f930b8
1 /* Linux fcntl syscall implementation -- non-cancellable.
2 Copyright (C) 2018-2024 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/>. */
19 #include <fcntl.h>
20 #include <stdarg.h>
21 #include <errno.h>
22 #include <sysdep-cancel.h>
23 #include <not-cancel.h>
25 #ifndef __NR_fcntl64
26 # define __NR_fcntl64 __NR_fcntl
27 #endif
29 #ifndef FCNTL_ADJUST_CMD
30 # define FCNTL_ADJUST_CMD(__cmd) __cmd
31 #endif
33 int
34 __fcntl64_nocancel (int fd, int cmd, ...)
36 va_list ap;
37 void *arg;
39 va_start (ap, cmd);
40 arg = va_arg (ap, void *);
41 va_end (ap);
43 cmd = FCNTL_ADJUST_CMD (cmd);
45 return __fcntl64_nocancel_adjusted (fd, cmd, arg);
47 hidden_def (__fcntl64_nocancel)
49 int
50 __fcntl64_nocancel_adjusted (int fd, int cmd, void *arg)
52 if (cmd == F_GETOWN)
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);