| 1126 | } |
| 1127 | |
| 1128 | static SLONG pwrite(int fd, SCHAR* buf, SLONG nbytes, SLONG offset) |
| 1129 | /************************************** |
| 1130 | * |
| 1131 | * p w r i t e |
| 1132 | * |
| 1133 | ************************************** |
| 1134 | * |
| 1135 | * Functional description |
| 1136 | * |
| 1137 | * This function uses Asynchronous I/O calls to implement |
| 1138 | * positioned write from a given offset |
| 1139 | **************************************/ |
| 1140 | { |
| 1141 | struct aiocb io; |
| 1142 | io.aio_fildes = fd; |
| 1143 | io.aio_offset = offset; |
| 1144 | io.aio_buf = buf; |
| 1145 | io.aio_nbytes = nbytes; |
| 1146 | io.aio_reqprio = 0; |
| 1147 | io.aio_sigevent.sigev_notify = SIGEV_NONE; |
| 1148 | int err = aio_write(&io); // atomically reads at offset |
| 1149 | if (err != 0) |
| 1150 | return (err); // errno is set |
| 1151 | |
| 1152 | struct aiocb *list[1]; |
| 1153 | list[0] = &io; |
| 1154 | err = aio_suspend(list, 1, NULL); // wait for I/O to complete |
| 1155 | if (err != 0) |
| 1156 | return (err); // errno is set |
| 1157 | return (aio_return(&io)); // return I/O status |
| 1158 | } |
| 1159 | |
| 1160 | #endif // !(HAVE_PREAD && HAVE_PWRITE) |
| 1161 |
no outgoing calls
no test coverage detected