blob: 583cfc62af947c424c30682eb105c7123b1eaae8 [file] [log] [blame]
The Android Open Source Project1dc9e472009-03-03 19:28:35 -08001/*
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 Hughesff26a162017-08-17 22:34:21 +000028
Elliott Hughescf59e192021-10-13 18:25:21 -070029#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 Project1dc9e472009-03-03 19:28:35 -080035
36#include <sys/cdefs.h>
37#include <sys/types.h>
38#include <linux/uio.h>
39
40__BEGIN_DECLS
41
Elliott Hughescf59e192021-10-13 18:25:21 -070042/**
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 */
Elliott Hughesff26a162017-08-17 22:34:21 +000049ssize_t readv(int __fd, const struct iovec* __iov, int __count);
Elliott Hughescf59e192021-10-13 18:25:21 -070050
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 */
Elliott Hughesff26a162017-08-17 22:34:21 +000058ssize_t writev(int __fd, const struct iovec* __iov, int __count);
Elliott Hughesbe57a402015-06-10 17:24:20 -070059
60#if defined(__USE_GNU)
Elliott Hughes6f4594d2015-08-26 13:27:43 -070061
Elliott Hughescf59e192021-10-13 18:25:21 -070062/**
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 */
72ssize_t preadv(int __fd, const struct iovec* __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 */
84ssize_t pwritev(int __fd, const struct iovec* __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 */
91ssize_t preadv64(int __fd, const struct iovec* __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 */
98ssize_t pwritev64(int __fd, const struct iovec* __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 */
110ssize_t preadv2(int __fd, const struct iovec* __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 */
122ssize_t pwritev2(int __fd, const struct iovec* __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 */
129ssize_t preadv64v2(int __fd, const struct iovec* __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 */
136ssize_t pwritev64v2(int __fd, const struct iovec* __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 */
Elliott Hughesff26a162017-08-17 22:34:21 +0000147ssize_t process_vm_readv(pid_t __pid, const struct iovec* __local_iov, unsigned long __local_iov_count, const struct iovec* __remote_iov, unsigned long __remote_iov_count, unsigned long __flags) __INTRODUCED_IN(23);
Elliott Hughescf59e192021-10-13 18:25:21 -0700148
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 */
Elliott Hughesff26a162017-08-17 22:34:21 +0000158ssize_t process_vm_writev(pid_t __pid, const struct iovec* __local_iov, unsigned long __local_iov_count, const struct iovec* __remote_iov, unsigned long __remote_iov_count, unsigned long __flags) __INTRODUCED_IN(23);
Elliott Hughescf59e192021-10-13 18:25:21 -0700159
Elliott Hughesbe57a402015-06-10 17:24:20 -0700160#endif
The Android Open Source Project1dc9e472009-03-03 19:28:35 -0800161
162__END_DECLS