| 1 | /* Linux implementation of preadv2 (LFS version). |
| 2 | Copyright (C) 2017-2019 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 | #include <sys/uio.h> |
| 20 | #include <sysdep-cancel.h> |
| 21 | |
| 22 | #if !defined(__NR_preadv64v2) && defined(__NR_preadv2) |
| 23 | # define __NR_preadv64v2 __NR_preadv2 |
| 24 | #endif |
| 25 | |
| 26 | ssize_t |
| 27 | preadv64v2 (int fd, const struct iovec *vector, int count, off64_t offset, |
| 28 | int flags) |
| 29 | { |
| 30 | #ifdef __NR_preadv64v2 |
| 31 | ssize_t result = SYSCALL_CANCEL (preadv64v2, fd, vector, count, |
| 32 | LO_HI_LONG (offset), flags); |
| 33 | if (result >= 0 || errno != ENOSYS) |
| 34 | return result; |
| 35 | #endif |
| 36 | /* Trying to emulate the preadv2 syscall flags is troublesome: |
| 37 | |
| 38 | * We can not temporary change the file state of the O_DSYNC and O_SYNC |
| 39 | flags to emulate RWF_{D}SYNC (attempts to change the state of using |
| 40 | fcntl are silently ignored). |
| 41 | |
| 42 | * IOCB_HIPRI requires the file opened in O_DIRECT and uses an internal |
| 43 | semantic not provided by any other flag (O_NONBLOCK for instance). */ |
| 44 | |
| 45 | if (flags != 0) |
| 46 | { |
| 47 | __set_errno (ENOTSUP); |
| 48 | return -1; |
| 49 | } |
| 50 | |
| 51 | if (offset == -1) |
| 52 | return __readv (fd, vector, count); |
| 53 | else |
| 54 | return preadv64 (fd, vector, count, offset); |
| 55 | } |
| 56 | |
| 57 | #ifdef __OFF_T_MATCHES_OFF64_T |
| 58 | strong_alias (preadv64v2, preadv2) |
| 59 | #endif |
| 60 | |