| 1606 | } |
| 1607 | |
| 1608 | int |
| 1609 | kern_fpathconf(struct thread *td, int fd, int name, long *valuep) |
| 1610 | { |
| 1611 | struct file *fp; |
| 1612 | struct vnode *vp; |
| 1613 | int error; |
| 1614 | |
| 1615 | error = fget(td, fd, &cap_fpathconf_rights, &fp); |
| 1616 | if (error != 0) |
| 1617 | return (error); |
| 1618 | |
| 1619 | if (name == _PC_ASYNC_IO) { |
| 1620 | *valuep = _POSIX_ASYNCHRONOUS_IO; |
| 1621 | goto out; |
| 1622 | } |
| 1623 | vp = fp->f_vnode; |
| 1624 | if (vp != NULL) { |
| 1625 | vn_lock(vp, LK_SHARED | LK_RETRY); |
| 1626 | error = VOP_PATHCONF(vp, name, valuep); |
| 1627 | VOP_UNLOCK(vp); |
| 1628 | } else if (fp->f_type == DTYPE_PIPE || fp->f_type == DTYPE_SOCKET) { |
| 1629 | if (name != _PC_PIPE_BUF) { |
| 1630 | error = EINVAL; |
| 1631 | } else { |
| 1632 | *valuep = PIPE_BUF; |
| 1633 | error = 0; |
| 1634 | } |
| 1635 | } else { |
| 1636 | error = EOPNOTSUPP; |
| 1637 | } |
| 1638 | out: |
| 1639 | fdrop(fp, td); |
| 1640 | return (error); |
| 1641 | } |
| 1642 | |
| 1643 | /* |
| 1644 | * Copy filecaps structure allocating memory for ioctls array if needed. |
no test coverage detected