* Common code for readv and preadv that reads data in * from a file using the passed in uio, offset, and flags. */
| 342 | * from a file using the passed in uio, offset, and flags. |
| 343 | */ |
| 344 | static int |
| 345 | dofileread(struct thread *td, int fd, struct file *fp, struct uio *auio, |
| 346 | off_t offset, int flags) |
| 347 | { |
| 348 | ssize_t cnt; |
| 349 | int error; |
| 350 | #ifdef KTRACE |
| 351 | struct uio *ktruio = NULL; |
| 352 | #endif |
| 353 | |
| 354 | AUDIT_ARG_FD(fd); |
| 355 | |
| 356 | /* Finish zero length reads right here */ |
| 357 | if (auio->uio_resid == 0) { |
| 358 | td->td_retval[0] = 0; |
| 359 | return (0); |
| 360 | } |
| 361 | auio->uio_rw = UIO_READ; |
| 362 | auio->uio_offset = offset; |
| 363 | auio->uio_td = td; |
| 364 | #ifdef KTRACE |
| 365 | if (KTRPOINT(td, KTR_GENIO)) |
| 366 | ktruio = cloneuio(auio); |
| 367 | #endif |
| 368 | cnt = auio->uio_resid; |
| 369 | if ((error = fo_read(fp, auio, td->td_ucred, flags, td))) { |
| 370 | if (auio->uio_resid != cnt && (error == ERESTART || |
| 371 | error == EINTR || error == EWOULDBLOCK)) |
| 372 | error = 0; |
| 373 | } |
| 374 | cnt -= auio->uio_resid; |
| 375 | #ifdef KTRACE |
| 376 | if (ktruio != NULL) { |
| 377 | ktruio->uio_resid = cnt; |
| 378 | ktrgenio(fd, UIO_READ, ktruio, error); |
| 379 | } |
| 380 | #endif |
| 381 | td->td_retval[0] = cnt; |
| 382 | return (error); |
| 383 | } |
| 384 | |
| 385 | #ifndef _SYS_SYSPROTO_H_ |
| 386 | struct write_args { |
no test coverage detected