• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /**
2  * @defgroup uio Uio
3  * @ingroup libc
4  */
5 
6 #ifndef _SYS_UIO_H
7 #define _SYS_UIO_H
8 
9 #ifdef __cplusplus
10 extern "C" {
11 #endif
12 
13 #include <features.h>
14 
15 #define __NEED_size_t
16 #define __NEED_ssize_t
17 #define __NEED_struct_iovec
18 
19 #if defined(_GNU_SOURCE) || defined(_BSD_SOURCE)
20 #define __NEED_off_t
21 #endif
22 
23 #ifdef _GNU_SOURCE
24 #define __NEED_pid_t
25 #endif
26 #ifdef __LITEOS__
27 #define __NEED_int64_t
28 #endif
29 
30 #include <bits/alltypes.h>
31 
32 #define UIO_MAXIOV 1024
33 
34 /**
35  * @ingroup uio
36  *
37  * @par Description:
38  * The readv() function shall be equivalent to read(), except as described below.
39  * The readv() function shall place the input data into the iovcnt buffers specified by the members
40  * of the iov array: iov[0], iov[1], ..., iov[iovcnt-1].
41  * Each iovec entry specifies the base address and length of an area in memory where data should be placed.
42  * The readv() function shall always fill an area completely before proceeding to the next.
43  *
44  * @param fd      [IN]     File descriptor (or socket descriptor) to read from
45  * @param iov     [OUT]    The array that user-provided to save the data
46  * @param iovcnt  [IN]     The number of members in the array
47  *
48  * @attention
49  * <ul>
50  * <li>If the sum of the iov_len values is greater than {SSIZE_MAX},
51  * the operation shall fail and no data shall be transferred.</li>
52  * </ul>
53  *
54  * @retval #ssize_t  A positive non-zero number of bytes read on suceess.
55  * @retval #0        End-of-file or failed in read().
56  * @retval #-1       The iov is a null pointer or out of memory.
57  *
58  * @par Errors
59  * <ul>
60  * <li><b>EBADF</b>: fd is not a valid open file descriptor, or the file system doesn't support read().</li>
61  * <li><b>EACCES</b>: The file is a write-only file.</li>
62  * <li><b>EIO</b>: A hard error occurred in the low level disk I/O layer or the physical drive cannot work.</li>
63  * <li><b>ENOMEM</b>: Out of memory.</li>
64  * <li><b>EINVAL</b>: The sum of the iov_len values is greater than {SSIZE_MAX}</li>
65  * <li><b>ENODEV</b>: The mount is not healthy.</li>
66  * </ul>
67  *
68  * @par Dependency:
69  * <ul><li>uio.h</li></ul>
70  * @see  writev
71  */
72 ssize_t readv (int, const struct iovec *, int);
73 
74 /**
75  * @ingroup uio
76  *
77  * @par Description:
78  * The writev() function shall be equivalent to write(), except as described below.
79  * The writev() function shall gather output data from the iovcnt buffers specified by the members
80  * of the iov array: iov[0], iov[1], ..., iov[iovcnt-1].
81  * Each iovec entry specifies the base address and length of an area in memory from which data should be written.
82  * The writev() function shall always write a complete area before proceeding to the next.
83  *
84  * @param fd      [IN] File descriptor (or socket descriptor) to read from
85  * @param iov     [IN] The array of data that user-provided to write
86  * @param iovcnt  [IN] The number of members in the array
87  *
88  * @attention
89  * <ul>
90  * <li>If all of the iov_len members in the array pointed to by iov are 0, it shall return -1.</li>
91  * <li>If the sum of the iov_len values is greater than {SSIZE_MAX},
92  * the operation shall fail and no data shall be transferred.</li>
93  * </ul>
94  *
95  * @retval #ssize_t  On success, the number of bytes written are returned (zero indicates nothing was written).
96  * @retval #-1       On error, -1 is returned, and errno is set appropriately.
97  *
98  * @par Errors
99  * <ul>
100  * <li><b>EBADF</b>: fd is not a valid open file descriptor, or the file system doesn't support write().</li>
101  * <li><b>EACCES/EROFS</b>: The file is a read-only file or the file system is read-only.</li>
102  * <li><b>EIO</b>: A physical I/O error has occurred.</li>
103  * <li><b>ENOMEM</b>: Out of memory.</li>
104  * <li><b>EINTR</b>: The write operation was terminated due to the receipt of a signal, no data was transferred.</li>
105  * <li><b>ENOSPC</b>: There was no free space remaining on the device containing the file.</li>
106  * <li><b>EAGAIN</b>: Non-blocking I/O has been selected using O_NONBLOCK and the write would block.</li>
107  * <li><b>EFBIG</b>: An attempt was made to write a file that exceeds the implementation defined maximum file
108  * size or the process' file size limit, or to write at a position past the maximum allowed offset.</li>
109  * <li><b>EINVAL</b>: The current position of file is less than zero,
110  * or the sum of the iov_len values is greater than {SSIZE_MAX}.</li>
111  * <li><b>ENODEV</b>: The mount is not healthy.</li>
112  * </ul>
113  *
114  * @par Dependency:
115  * <ul><li>uio.h</li></ul>
116  * @see  readv
117  */
118 ssize_t writev (int, const struct iovec *, int);
119 
120 #if defined(_GNU_SOURCE) || defined(_BSD_SOURCE)
121 ssize_t preadv (int, const struct iovec *, int, off_t);
122 ssize_t pwritev (int, const struct iovec *, int, off_t);
123 #if defined(_LARGEFILE64_SOURCE) || defined(_GNU_SOURCE)
124 #define preadv64 preadv
125 #define pwritev64 pwritev
126 #ifdef __LITEOS__
127 #define off64_t int64_t
128 #else
129 #define off64_t off_t
130 #endif
131 #endif
132 #endif
133 
134 #ifdef _GNU_SOURCE
135 ssize_t process_vm_writev(pid_t, const struct iovec *, unsigned long, const struct iovec *, unsigned long, unsigned long);
136 ssize_t process_vm_readv(pid_t, const struct iovec *, unsigned long, const struct iovec *, unsigned long, unsigned long);
137 #endif
138 
139 #ifdef __cplusplus
140 }
141 #endif
142 
143 #endif
144