]>
Commit | Line | Data |
---|---|---|
329ea513 | 1 | /* Linux fcntl syscall implementation -- non-cancellable. |
2b778ceb | 2 | Copyright (C) 2018-2021 Free Software Foundation, Inc. |
329ea513 ZW |
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 | |
5a82c748 | 17 | <https://www.gnu.org/licenses/>. */ |
329ea513 ZW |
18 | |
19 | #include <fcntl.h> | |
20 | #include <stdarg.h> | |
21 | #include <errno.h> | |
22 | #include <sysdep-cancel.h> | |
23 | #include <not-cancel.h> | |
24 | ||
25 | #ifndef __NR_fcntl64 | |
26 | # define __NR_fcntl64 __NR_fcntl | |
27 | #endif | |
28 | ||
29 | #ifndef FCNTL_ADJUST_CMD | |
30 | # define FCNTL_ADJUST_CMD(__cmd) __cmd | |
31 | #endif | |
32 | ||
33 | int | |
06ab719d | 34 | __fcntl64_nocancel (int fd, int cmd, ...) |
329ea513 ZW |
35 | { |
36 | va_list ap; | |
37 | void *arg; | |
38 | ||
39 | va_start (ap, cmd); | |
40 | arg = va_arg (ap, void *); | |
41 | va_end (ap); | |
42 | ||
43 | cmd = FCNTL_ADJUST_CMD (cmd); | |
44 | ||
06ab719d | 45 | return __fcntl64_nocancel_adjusted (fd, cmd, arg); |
329ea513 | 46 | } |
06ab719d | 47 | hidden_def (__fcntl64_nocancel) |
329ea513 ZW |
48 | |
49 | int | |
06ab719d | 50 | __fcntl64_nocancel_adjusted (int fd, int cmd, void *arg) |
329ea513 ZW |
51 | { |
52 | if (cmd == F_GETOWN) | |
53 | { | |
329ea513 | 54 | struct f_owner_ex fex; |
bc2eb932 AZ |
55 | int res = INTERNAL_SYSCALL_CALL (fcntl64, fd, F_GETOWN_EX, &fex); |
56 | if (!INTERNAL_SYSCALL_ERROR_P (res)) | |
329ea513 ZW |
57 | return fex.type == F_OWNER_GID ? -fex.pid : fex.pid; |
58 | ||
59 | return INLINE_SYSCALL_ERROR_RETURN_VALUE | |
bc2eb932 | 60 | (INTERNAL_SYSCALL_ERRNO (res)); |
329ea513 ZW |
61 | } |
62 | ||
63 | return INLINE_SYSCALL_CALL (fcntl64, fd, cmd, (void *) arg); | |
64 | } |