Use execveat syscall in fexecve (bug 22134)
[glibc.git] / sysdeps / unix / sysv / linux / preadv2.c
blob137e2dd7913f3264e7203ae6a7cbc2308f4fc886
1 /* Linux implementation of preadv2.
2 Copyright (C) 2017 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 <http://www.gnu.org/licenses/>. */
19 #include <sys/uio.h>
20 #include <sysdep-cancel.h>
22 #ifndef __OFF_T_MATCHES_OFF64_T
24 # if !defined (__NR_preadv2) && defined (__NR_pread64v2)
25 # define __NR_preadv2 __NR_pread64v2
26 # endif
28 ssize_t
29 preadv2 (int fd, const struct iovec *vector, int count, off_t offset,
30 int flags)
32 # ifdef __NR_preadv2
33 ssize_t result = SYSCALL_CANCEL (preadv2, fd, vector, count,
34 LO_HI_LONG (offset), flags);
35 if (result >= 0)
36 return result;
37 # endif
38 /* Trying to emulate the preadv2 syscall flags is troublesome:
40 * We can not temporary change the file state of the O_DSYNC and O_SYNC
41 flags to emulate RWF_{D}SYNC (attempts to change the state of using
42 fcntl are silently ignored).
44 * IOCB_HIPRI requires the file opened in O_DIRECT and uses an internal
45 semantic not provided by any other flag (O_NONBLOCK for instance). */
47 if (flags != 0)
49 __set_errno (ENOTSUP);
50 return -1;
52 return preadv (fd, vector, count, offset);
55 #endif