MCPcopy Create free account
hub / github.com/F-Stack/f-stack / vn_ioctl

Function vn_ioctl

freebsd/kern/vfs_vnops.c:1619–1666  ·  view source on GitHub ↗

* File table vnode ioctl routine. */

Source from the content-addressed store, hash-verified

1617 * File table vnode ioctl routine.
1618 */
1619static int
1620vn_ioctl(struct file *fp, u_long com, void *data, struct ucred *active_cred,
1621 struct thread *td)
1622{
1623 struct vattr vattr;
1624 struct vnode *vp;
1625 struct fiobmap2_arg *bmarg;
1626 int error;
1627
1628 vp = fp->f_vnode;
1629 switch (vp->v_type) {
1630 case VDIR:
1631 case VREG:
1632 switch (com) {
1633 case FIONREAD:
1634 vn_lock(vp, LK_SHARED | LK_RETRY);
1635 error = VOP_GETATTR(vp, &vattr, active_cred);
1636 VOP_UNLOCK(vp);
1637 if (error == 0)
1638 *(int *)data = vattr.va_size - fp->f_offset;
1639 return (error);
1640 case FIOBMAP2:
1641 bmarg = (struct fiobmap2_arg *)data;
1642 vn_lock(vp, LK_SHARED | LK_RETRY);
1643#ifdef MAC
1644 error = mac_vnode_check_read(active_cred, fp->f_cred,
1645 vp);
1646 if (error == 0)
1647#endif
1648 error = VOP_BMAP(vp, bmarg->bn, NULL,
1649 &bmarg->bn, &bmarg->runp, &bmarg->runb);
1650 VOP_UNLOCK(vp);
1651 return (error);
1652 case FIONBIO:
1653 case FIOASYNC:
1654 return (0);
1655 default:
1656 return (VOP_IOCTL(vp, com, data, fp->f_flag,
1657 active_cred, td));
1658 }
1659 break;
1660 case VCHR:
1661 return (VOP_IOCTL(vp, com, data, fp->f_flag,
1662 active_cred, td));
1663 default:
1664 return (ENOTTY);
1665 }
1666}
1667
1668/*
1669 * File table vnode poll routine.

Callers

nothing calls this directly

Calls 3

vn_lockFunction · 0.85
VOP_GETATTRFunction · 0.85
mac_vnode_check_readFunction · 0.85

Tested by

no test coverage detected