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 */ 28 29 #pragma once 30 31 /** 32 * @file sys/uio.h 33 * @brief Multi-buffer ("vector") I/O operations using `struct iovec`. 34 */ 35 36 #include <sys/cdefs.h> 37 #include <sys/types.h> 38 #include <linux/uio.h> 39 40 __BEGIN_DECLS 41 42 /** 43 * [readv(2)](http://man7.org/linux/man-pages/man2/readv.2.html) reads 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 */ 49 ssize_t readv(int __fd, const struct iovec* _Nonnull __iov, int __count); 50 51 /** 52 * [writev(2)](http://man7.org/linux/man-pages/man2/writev.2.html) writes 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 */ 58 ssize_t writev(int __fd, const struct iovec* _Nonnull __iov, int __count); 59 60 #if defined(__USE_GNU) 61 62 /** 63 * [preadv(2)](http://man7.org/linux/man-pages/man2/preadv.2.html) reads 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 */ 72 ssize_t preadv(int __fd, const struct iovec* _Nonnull __iov, int __count, off_t __offset) __RENAME_IF_FILE_OFFSET64(preadv64) __INTRODUCED_IN(24); 73 74 /** 75 * [pwritev(2)](http://man7.org/linux/man-pages/man2/pwritev.2.html) writes 76 * to an fd from the `__count` buffers described by `__iov`, starting at offset 77 * `__offset` into the file. 78 * 79 * Returns the number of bytes written on success, 80 * and returns -1 and sets `errno` on failure. 81 * 82 * Available since API level 24. 83 */ 84 ssize_t pwritev(int __fd, const struct iovec* _Nonnull __iov, int __count, off_t __offset) __RENAME_IF_FILE_OFFSET64(pwritev64) __INTRODUCED_IN(24); 85 86 /** 87 * Like preadv() but with a 64-bit offset even in a 32-bit process. 88 * 89 * Available since API level 24. 90 */ 91 ssize_t preadv64(int __fd, const struct iovec* _Nonnull __iov, int __count, off64_t __offset) __INTRODUCED_IN(24); 92 93 /** 94 * Like pwritev() but with a 64-bit offset even in a 32-bit process. 95 * 96 * Available since API level 24. 97 */ 98 ssize_t pwritev64(int __fd, const struct iovec* _Nonnull __iov, int __count, off64_t __offset) __INTRODUCED_IN(24); 99 100 /** 101 * [preadv2(2)](http://man7.org/linux/man-pages/man2/preadv2.2.html) reads 102 * from an fd into the `__count` buffers described by `__iov`, starting at 103 * offset `__offset` into the file, with the given flags. 104 * 105 * Returns the number of bytes read on success, 106 * and returns -1 and sets `errno` on failure. 107 * 108 * Available since API level 33. 109 */ 110 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); 111 112 /** 113 * [pwritev2(2)](http://man7.org/linux/man-pages/man2/pwritev2.2.html) writes 114 * to an fd from the `__count` buffers described by `__iov`, starting at offset 115 * `__offset` into the file, with the given flags. 116 * 117 * Returns the number of bytes written on success, 118 * and returns -1 and sets `errno` on failure. 119 * 120 * Available since API level 33. 121 */ 122 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); 123 124 /** 125 * Like preadv2() but with a 64-bit offset even in a 32-bit process. 126 * 127 * Available since API level 33. 128 */ 129 ssize_t preadv64v2(int __fd, const struct iovec* _Nonnull __iov, int __count, off64_t __offset, int __flags) __INTRODUCED_IN(33); 130 131 /** 132 * Like pwritev2() but with a 64-bit offset even in a 32-bit process. 133 * 134 * Available since API level 33. 135 */ 136 ssize_t pwritev64v2(int __fd, const struct iovec* _Nonnull __iov, int __count, off64_t __offset, int __flags) __INTRODUCED_IN(33); 137 138 /** 139 * [process_vm_readv(2)](http://man7.org/linux/man-pages/man2/process_vm_readv.2.html) 140 * reads from the address space of another process. 141 * 142 * Returns the number of bytes read on success, 143 * and returns -1 and sets `errno` on failure. 144 * 145 * Available since API level 23. 146 */ 147 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); 148 149 /** 150 * [process_vm_writev(2)](http://man7.org/linux/man-pages/man2/process_vm_writev.2.html) 151 * writes to the address space of another process. 152 * 153 * Returns the number of bytes read on success, 154 * and returns -1 and sets `errno` on failure. 155 * 156 * Available since API level 23. 157 */ 158 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); 159 160 #endif 161 162 __END_DECLS 163