The Android Open Source Project | 1dc9e47 | 2009-03-03 19:28:35 -0800 | [diff] [blame] | 1 | /* |
| 2 | * Copyright (C) 2008 The Android Open Source Project |
| 3 | * All rights reserved. |
| 4 | * |
| 5 | * Redistribution and use in source and binary forms, with or without |
| 6 | * modification, are permitted provided that the following conditions |
| 7 | * are met: |
| 8 | * * Redistributions of source code must retain the above copyright |
| 9 | * notice, this list of conditions and the following disclaimer. |
| 10 | * * Redistributions in binary form must reproduce the above copyright |
| 11 | * notice, this list of conditions and the following disclaimer in |
| 12 | * the documentation and/or other materials provided with the |
| 13 | * distribution. |
| 14 | * |
| 15 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS |
| 16 | * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT |
| 17 | * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS |
| 18 | * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE |
| 19 | * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, |
| 20 | * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, |
| 21 | * BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS |
| 22 | * OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED |
| 23 | * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, |
| 24 | * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT |
| 25 | * OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF |
| 26 | * SUCH DAMAGE. |
| 27 | */ |
Elliott Hughes | ff26a16 | 2017-08-17 22:34:21 +0000 | [diff] [blame] | 28 | |
Elliott Hughes | cf59e19 | 2021-10-13 18:25:21 -0700 | [diff] [blame] | 29 | #pragma once |
| 30 | |
| 31 | /** |
| 32 | * @file sys/uio.h |
| 33 | * @brief Multi-buffer ("vector") I/O operations using `struct iovec`. |
| 34 | */ |
The Android Open Source Project | 1dc9e47 | 2009-03-03 19:28:35 -0800 | [diff] [blame] | 35 | |
| 36 | #include <sys/cdefs.h> |
| 37 | #include <sys/types.h> |
| 38 | #include <linux/uio.h> |
| 39 | |
| 40 | __BEGIN_DECLS |
| 41 | |
Elliott Hughes | cf59e19 | 2021-10-13 18:25:21 -0700 | [diff] [blame] | 42 | /** |
Elliott Hughes | bbd39aa | 2024-08-13 20:59:16 +0000 | [diff] [blame] | 43 | * [readv(2)](https://man7.org/linux/man-pages/man2/readv.2.html) reads |
Elliott Hughes | cf59e19 | 2021-10-13 18:25:21 -0700 | [diff] [blame] | 44 | * from an fd into the `__count` buffers described by `__iov`. |
| 45 | * |
| 46 | * Returns the number of bytes read on success, |
| 47 | * and returns -1 and sets `errno` on failure. |
| 48 | */ |
zijunzhao | d633600 | 2023-05-03 22:48:15 +0000 | [diff] [blame] | 49 | ssize_t readv(int __fd, const struct iovec* _Nonnull __iov, int __count); |
Elliott Hughes | cf59e19 | 2021-10-13 18:25:21 -0700 | [diff] [blame] | 50 | |
| 51 | /** |
Elliott Hughes | bbd39aa | 2024-08-13 20:59:16 +0000 | [diff] [blame] | 52 | * [writev(2)](https://man7.org/linux/man-pages/man2/writev.2.html) writes |
Elliott Hughes | cf59e19 | 2021-10-13 18:25:21 -0700 | [diff] [blame] | 53 | * to an fd from the `__count` buffers described by `__iov`. |
| 54 | * |
| 55 | * Returns the number of bytes written on success, |
| 56 | * and returns -1 and sets `errno` on failure. |
| 57 | */ |
zijunzhao | d633600 | 2023-05-03 22:48:15 +0000 | [diff] [blame] | 58 | ssize_t writev(int __fd, const struct iovec* _Nonnull __iov, int __count); |
Elliott Hughes | be57a40 | 2015-06-10 17:24:20 -0700 | [diff] [blame] | 59 | |
| 60 | #if defined(__USE_GNU) |
Elliott Hughes | 6f4594d | 2015-08-26 13:27:43 -0700 | [diff] [blame] | 61 | |
Elliott Hughes | cf59e19 | 2021-10-13 18:25:21 -0700 | [diff] [blame] | 62 | /** |
Elliott Hughes | bbd39aa | 2024-08-13 20:59:16 +0000 | [diff] [blame] | 63 | * [preadv(2)](https://man7.org/linux/man-pages/man2/preadv.2.html) reads |
Elliott Hughes | cf59e19 | 2021-10-13 18:25:21 -0700 | [diff] [blame] | 64 | * from an fd into the `__count` buffers described by `__iov`, starting at |
| 65 | * offset `__offset` into the file. |
| 66 | * |
| 67 | * Returns the number of bytes read on success, |
| 68 | * and returns -1 and sets `errno` on failure. |
| 69 | * |
| 70 | * Available since API level 24. |
| 71 | */ |
Dan Albert | 02ce401 | 2024-10-25 19:13:49 +0000 | [diff] [blame] | 72 | |
| 73 | #if __BIONIC_AVAILABILITY_GUARD(24) |
zijunzhao | d633600 | 2023-05-03 22:48:15 +0000 | [diff] [blame] | 74 | ssize_t preadv(int __fd, const struct iovec* _Nonnull __iov, int __count, off_t __offset) __RENAME_IF_FILE_OFFSET64(preadv64) __INTRODUCED_IN(24); |
Elliott Hughes | cf59e19 | 2021-10-13 18:25:21 -0700 | [diff] [blame] | 75 | |
| 76 | /** |
Elliott Hughes | bbd39aa | 2024-08-13 20:59:16 +0000 | [diff] [blame] | 77 | * [pwritev(2)](https://man7.org/linux/man-pages/man2/pwritev.2.html) writes |
Elliott Hughes | cf59e19 | 2021-10-13 18:25:21 -0700 | [diff] [blame] | 78 | * to an fd from the `__count` buffers described by `__iov`, starting at offset |
| 79 | * `__offset` into the file. |
| 80 | * |
| 81 | * Returns the number of bytes written on success, |
| 82 | * and returns -1 and sets `errno` on failure. |
| 83 | * |
| 84 | * Available since API level 24. |
| 85 | */ |
zijunzhao | d633600 | 2023-05-03 22:48:15 +0000 | [diff] [blame] | 86 | ssize_t pwritev(int __fd, const struct iovec* _Nonnull __iov, int __count, off_t __offset) __RENAME_IF_FILE_OFFSET64(pwritev64) __INTRODUCED_IN(24); |
Elliott Hughes | cf59e19 | 2021-10-13 18:25:21 -0700 | [diff] [blame] | 87 | |
| 88 | /** |
| 89 | * Like preadv() but with a 64-bit offset even in a 32-bit process. |
| 90 | * |
| 91 | * Available since API level 24. |
| 92 | */ |
zijunzhao | d633600 | 2023-05-03 22:48:15 +0000 | [diff] [blame] | 93 | ssize_t preadv64(int __fd, const struct iovec* _Nonnull __iov, int __count, off64_t __offset) __INTRODUCED_IN(24); |
Elliott Hughes | cf59e19 | 2021-10-13 18:25:21 -0700 | [diff] [blame] | 94 | |
| 95 | /** |
| 96 | * Like pwritev() but with a 64-bit offset even in a 32-bit process. |
| 97 | * |
| 98 | * Available since API level 24. |
| 99 | */ |
zijunzhao | d633600 | 2023-05-03 22:48:15 +0000 | [diff] [blame] | 100 | ssize_t pwritev64(int __fd, const struct iovec* _Nonnull __iov, int __count, off64_t __offset) __INTRODUCED_IN(24); |
Dan Albert | 02ce401 | 2024-10-25 19:13:49 +0000 | [diff] [blame] | 101 | #endif /* __BIONIC_AVAILABILITY_GUARD(24) */ |
| 102 | |
Elliott Hughes | cf59e19 | 2021-10-13 18:25:21 -0700 | [diff] [blame] | 103 | |
| 104 | /** |
Elliott Hughes | bbd39aa | 2024-08-13 20:59:16 +0000 | [diff] [blame] | 105 | * [preadv2(2)](https://man7.org/linux/man-pages/man2/preadv2.2.html) reads |
Elliott Hughes | cf59e19 | 2021-10-13 18:25:21 -0700 | [diff] [blame] | 106 | * from an fd into the `__count` buffers described by `__iov`, starting at |
| 107 | * offset `__offset` into the file, with the given flags. |
| 108 | * |
| 109 | * Returns the number of bytes read on success, |
| 110 | * and returns -1 and sets `errno` on failure. |
| 111 | * |
| 112 | * Available since API level 33. |
| 113 | */ |
Dan Albert | 02ce401 | 2024-10-25 19:13:49 +0000 | [diff] [blame] | 114 | |
| 115 | #if __BIONIC_AVAILABILITY_GUARD(33) |
zijunzhao | d633600 | 2023-05-03 22:48:15 +0000 | [diff] [blame] | 116 | ssize_t preadv2(int __fd, const struct iovec* _Nonnull __iov, int __count, off_t __offset, int __flags) __RENAME_IF_FILE_OFFSET64(preadv64v2) __INTRODUCED_IN(33); |
Elliott Hughes | cf59e19 | 2021-10-13 18:25:21 -0700 | [diff] [blame] | 117 | |
| 118 | /** |
Elliott Hughes | bbd39aa | 2024-08-13 20:59:16 +0000 | [diff] [blame] | 119 | * [pwritev2(2)](https://man7.org/linux/man-pages/man2/pwritev2.2.html) writes |
Elliott Hughes | cf59e19 | 2021-10-13 18:25:21 -0700 | [diff] [blame] | 120 | * to an fd from the `__count` buffers described by `__iov`, starting at offset |
| 121 | * `__offset` into the file, with the given flags. |
| 122 | * |
| 123 | * Returns the number of bytes written on success, |
| 124 | * and returns -1 and sets `errno` on failure. |
| 125 | * |
| 126 | * Available since API level 33. |
| 127 | */ |
zijunzhao | d633600 | 2023-05-03 22:48:15 +0000 | [diff] [blame] | 128 | ssize_t pwritev2(int __fd, const struct iovec* _Nonnull __iov, int __count, off_t __offset, int __flags) __RENAME_IF_FILE_OFFSET64(pwritev64v2) __INTRODUCED_IN(33); |
Elliott Hughes | cf59e19 | 2021-10-13 18:25:21 -0700 | [diff] [blame] | 129 | |
| 130 | /** |
| 131 | * Like preadv2() but with a 64-bit offset even in a 32-bit process. |
| 132 | * |
| 133 | * Available since API level 33. |
| 134 | */ |
zijunzhao | d633600 | 2023-05-03 22:48:15 +0000 | [diff] [blame] | 135 | ssize_t preadv64v2(int __fd, const struct iovec* _Nonnull __iov, int __count, off64_t __offset, int __flags) __INTRODUCED_IN(33); |
Elliott Hughes | cf59e19 | 2021-10-13 18:25:21 -0700 | [diff] [blame] | 136 | |
| 137 | /** |
| 138 | * Like pwritev2() but with a 64-bit offset even in a 32-bit process. |
| 139 | * |
| 140 | * Available since API level 33. |
| 141 | */ |
zijunzhao | d633600 | 2023-05-03 22:48:15 +0000 | [diff] [blame] | 142 | ssize_t pwritev64v2(int __fd, const struct iovec* _Nonnull __iov, int __count, off64_t __offset, int __flags) __INTRODUCED_IN(33); |
Dan Albert | 02ce401 | 2024-10-25 19:13:49 +0000 | [diff] [blame] | 143 | #endif /* __BIONIC_AVAILABILITY_GUARD(33) */ |
| 144 | |
Elliott Hughes | cf59e19 | 2021-10-13 18:25:21 -0700 | [diff] [blame] | 145 | |
| 146 | /** |
Elliott Hughes | bbd39aa | 2024-08-13 20:59:16 +0000 | [diff] [blame] | 147 | * [process_vm_readv(2)](https://man7.org/linux/man-pages/man2/process_vm_readv.2.html) |
Elliott Hughes | cf59e19 | 2021-10-13 18:25:21 -0700 | [diff] [blame] | 148 | * reads from the address space of another process. |
| 149 | * |
| 150 | * Returns the number of bytes read on success, |
| 151 | * and returns -1 and sets `errno` on failure. |
| 152 | * |
| 153 | * Available since API level 23. |
| 154 | */ |
Dan Albert | 02ce401 | 2024-10-25 19:13:49 +0000 | [diff] [blame] | 155 | |
| 156 | #if __BIONIC_AVAILABILITY_GUARD(23) |
zijunzhao | d633600 | 2023-05-03 22:48:15 +0000 | [diff] [blame] | 157 | ssize_t process_vm_readv(pid_t __pid, const struct iovec* __BIONIC_COMPLICATED_NULLNESS __local_iov, unsigned long __local_iov_count, const struct iovec* __BIONIC_COMPLICATED_NULLNESS __remote_iov, unsigned long __remote_iov_count, unsigned long __flags) __INTRODUCED_IN(23); |
Elliott Hughes | cf59e19 | 2021-10-13 18:25:21 -0700 | [diff] [blame] | 158 | |
| 159 | /** |
Elliott Hughes | bbd39aa | 2024-08-13 20:59:16 +0000 | [diff] [blame] | 160 | * [process_vm_writev(2)](https://man7.org/linux/man-pages/man2/process_vm_writev.2.html) |
Elliott Hughes | cf59e19 | 2021-10-13 18:25:21 -0700 | [diff] [blame] | 161 | * writes to the address space of another process. |
| 162 | * |
| 163 | * Returns the number of bytes read on success, |
| 164 | * and returns -1 and sets `errno` on failure. |
| 165 | * |
| 166 | * Available since API level 23. |
| 167 | */ |
zijunzhao | d633600 | 2023-05-03 22:48:15 +0000 | [diff] [blame] | 168 | ssize_t process_vm_writev(pid_t __pid, const struct iovec* __BIONIC_COMPLICATED_NULLNESS __local_iov, unsigned long __local_iov_count, const struct iovec* __BIONIC_COMPLICATED_NULLNESS __remote_iov, unsigned long __remote_iov_count, unsigned long __flags) __INTRODUCED_IN(23); |
Dan Albert | 02ce401 | 2024-10-25 19:13:49 +0000 | [diff] [blame] | 169 | #endif /* __BIONIC_AVAILABILITY_GUARD(23) */ |
| 170 | |
Elliott Hughes | cf59e19 | 2021-10-13 18:25:21 -0700 | [diff] [blame] | 171 | |
Elliott Hughes | be57a40 | 2015-06-10 17:24:20 -0700 | [diff] [blame] | 172 | #endif |
The Android Open Source Project | 1dc9e47 | 2009-03-03 19:28:35 -0800 | [diff] [blame] | 173 | |
| 174 | __END_DECLS |