* Helper function to readlink from a vnode */
| 2612 | * Helper function to readlink from a vnode |
| 2613 | */ |
| 2614 | static int |
| 2615 | kern_readlink_vp(struct vnode *vp, char *buf, enum uio_seg bufseg, size_t count, |
| 2616 | struct thread *td) |
| 2617 | { |
| 2618 | struct iovec aiov; |
| 2619 | struct uio auio; |
| 2620 | int error; |
| 2621 | |
| 2622 | ASSERT_VOP_LOCKED(vp, "kern_readlink_vp(): vp not locked"); |
| 2623 | #ifdef MAC |
| 2624 | error = mac_vnode_check_readlink(td->td_ucred, vp); |
| 2625 | if (error != 0) |
| 2626 | return (error); |
| 2627 | #endif |
| 2628 | if (vp->v_type != VLNK && (vp->v_vflag & VV_READLINK) == 0) |
| 2629 | return (EINVAL); |
| 2630 | |
| 2631 | aiov.iov_base = buf; |
| 2632 | aiov.iov_len = count; |
| 2633 | auio.uio_iov = &aiov; |
| 2634 | auio.uio_iovcnt = 1; |
| 2635 | auio.uio_offset = 0; |
| 2636 | auio.uio_rw = UIO_READ; |
| 2637 | auio.uio_segflg = bufseg; |
| 2638 | auio.uio_td = td; |
| 2639 | auio.uio_resid = count; |
| 2640 | error = VOP_READLINK(vp, &auio, td->td_ucred); |
| 2641 | td->td_retval[0] = count - auio.uio_resid; |
| 2642 | return (error); |
| 2643 | } |
| 2644 | |
| 2645 | /* |
| 2646 | * Common implementation code for chflags() and fchflags(). |
no test coverage detected