* Give next character to user as result of read. */
| 305 | * Give next character to user as result of read. |
| 306 | */ |
| 307 | int |
| 308 | ureadc(int c, struct uio *uio) |
| 309 | { |
| 310 | struct iovec *iov; |
| 311 | char *iov_base; |
| 312 | |
| 313 | WITNESS_WARN(WARN_GIANTOK | WARN_SLEEPOK, NULL, |
| 314 | "Calling ureadc()"); |
| 315 | |
| 316 | again: |
| 317 | if (uio->uio_iovcnt == 0 || uio->uio_resid == 0) |
| 318 | panic("ureadc"); |
| 319 | iov = uio->uio_iov; |
| 320 | if (iov->iov_len == 0) { |
| 321 | uio->uio_iovcnt--; |
| 322 | uio->uio_iov++; |
| 323 | goto again; |
| 324 | } |
| 325 | switch (uio->uio_segflg) { |
| 326 | case UIO_USERSPACE: |
| 327 | if (subyte(iov->iov_base, c) < 0) |
| 328 | return (EFAULT); |
| 329 | break; |
| 330 | |
| 331 | case UIO_SYSSPACE: |
| 332 | iov_base = iov->iov_base; |
| 333 | *iov_base = c; |
| 334 | break; |
| 335 | |
| 336 | case UIO_NOCOPY: |
| 337 | break; |
| 338 | } |
| 339 | iov->iov_base = (char *)iov->iov_base + 1; |
| 340 | iov->iov_len--; |
| 341 | uio->uio_resid--; |
| 342 | uio->uio_offset++; |
| 343 | return (0); |
| 344 | } |
| 345 | |
| 346 | int |
| 347 | copyiniov(const struct iovec *iovp, u_int iovcnt, struct iovec **iov, int error) |
no test coverage detected