- error = VOP_READ(vp, uio, (fp->f_flag & FNONBLOCK) ? IO_NDELAY : 0, cred);
-
- fp->f_offset += count - uio->uio_resid;
+ if(UBCINFOEXISTS(vp)) {
+ memory_object_t pager;
+ struct iovec *iov;
+ off_t file_off;
+ kern_return_t kr = KERN_SUCCESS;
+ kern_return_t ret = KERN_SUCCESS;
+ int count;
+
+ pager = (memory_object_t)ubc_getpager(vp);
+ file_off = uio->uio_offset;
+ iov = uio->uio_iov;
+ count = uio->uio_iovcnt;
+ while(count) {
+ kr = vm_conflict_check(current_map(),
+ (vm_offset_t)iov->iov_base, iov->iov_len,
+ pager, file_off);
+ if(kr == KERN_ALREADY_WAITING) {
+ if((count != uio->uio_iovcnt) &&
+ (ret != KERN_ALREADY_WAITING)) {
+ error = EINVAL;
+ goto done;
+ }
+ ret = KERN_ALREADY_WAITING;
+ } else if (kr != KERN_SUCCESS) {
+ error = EINVAL;
+ goto done;
+ }
+ if(kr != ret) {
+ error = EINVAL;
+ goto done;
+ }
+ file_off += iov->iov_len;
+ iov++;
+ count--;
+ }
+ if(ret == KERN_ALREADY_WAITING) {
+ uio->uio_resid = 0;
+ if ((flags & FOF_OFFSET) == 0)
+ fp->f_offset +=
+ count - uio->uio_resid;
+ error = 0;
+ goto done;
+ }
+ }
+ error = VOP_READ(vp, uio, ioflag, cred);
+ if ((flags & FOF_OFFSET) == 0)
+ fp->f_offset += count - uio->uio_resid;
+done: