Changeset View
Changeset View
Standalone View
Standalone View
sys/kern/vfs_vnops.c
| Show First 20 Lines • Show All 2,441 Lines • ▼ Show 20 Lines | vn_bmap_seekhole_locked(struct vnode *vp, u_long cmd, off_t *off, | ||||
| struct ucred *cred) | struct ucred *cred) | ||||
| { | { | ||||
| struct vattr va; | struct vattr va; | ||||
| daddr_t bn, bnp; | daddr_t bn, bnp; | ||||
| uint64_t bsize; | uint64_t bsize; | ||||
| off_t noff; | off_t noff; | ||||
| int error; | int error; | ||||
| KASSERT(cmd == FIOSEEKHOLE || cmd == FIOSEEKDATA, | |||||
| ("%s: Wrong command %lu", __func__, cmd)); | |||||
| ASSERT_VOP_LOCKED(vp, "vn_bmap_seekhole_locked"); | ASSERT_VOP_LOCKED(vp, "vn_bmap_seekhole_locked"); | ||||
| if (vp->v_type != VREG) { | if (vp->v_type != VREG) { | ||||
| error = ENOTTY; | error = ENOTTY; | ||||
| goto out; | goto out; | ||||
| } | } | ||||
| error = VOP_GETATTR(vp, &va, cred); | error = VOP_GETATTR(vp, &va, cred); | ||||
| if (error != 0) | if (error != 0) | ||||
| Show All 11 Lines | if (error == EOPNOTSUPP) { | ||||
| error = ENOTTY; | error = ENOTTY; | ||||
| goto out; | goto out; | ||||
| } | } | ||||
| if ((bnp == -1 && cmd == FIOSEEKHOLE) || | if ((bnp == -1 && cmd == FIOSEEKHOLE) || | ||||
| (bnp != -1 && cmd == FIOSEEKDATA)) { | (bnp != -1 && cmd == FIOSEEKDATA)) { | ||||
| noff = bn * bsize; | noff = bn * bsize; | ||||
| if (noff < *off) | if (noff < *off) | ||||
| noff = *off; | noff = *off; | ||||
| goto out; | goto out; | ||||
markj: This is the only place that really needs a goto, the rest can `return (mumble)`. I don't insist… | |||||
| } | } | ||||
| } | } | ||||
| if (noff > va.va_size) | if (noff > va.va_size) | ||||
| noff = va.va_size; | noff = va.va_size; | ||||
| /* noff == va.va_size. There is an implicit hole at the end of file. */ | /* noff == va.va_size. There is an implicit hole at the end of file. */ | ||||
| if (cmd == FIOSEEKDATA) | if (cmd == FIOSEEKDATA) | ||||
| error = ENXIO; | error = ENXIO; | ||||
| out: | out: | ||||
| if (error == 0) | if (error == 0) | ||||
| *off = noff; | *off = noff; | ||||
| return (error); | return (error); | ||||
| } | } | ||||
| int | int | ||||
| vn_bmap_seekhole(struct vnode *vp, u_long cmd, off_t *off, struct ucred *cred) | vn_bmap_seekhole(struct vnode *vp, u_long cmd, off_t *off, struct ucred *cred) | ||||
| { | { | ||||
| int error; | int error; | ||||
| KASSERT(cmd == FIOSEEKHOLE || cmd == FIOSEEKDATA, | KASSERT(cmd == FIOSEEKHOLE || cmd == FIOSEEKDATA, | ||||
| ("Wrong command %lu", cmd)); | ("%s: Wrong command %lu", __func__, cmd)); | ||||
| if (vn_lock(vp, LK_SHARED) != 0) | if (vn_lock(vp, LK_SHARED) != 0) | ||||
| return (EBADF); | return (EBADF); | ||||
| error = vn_bmap_seekhole_locked(vp, cmd, off, cred); | error = vn_bmap_seekhole_locked(vp, cmd, off, cred); | ||||
| VOP_UNLOCK(vp); | VOP_UNLOCK(vp); | ||||
| return (error); | return (error); | ||||
| } | } | ||||
| ▲ Show 20 Lines • Show All 1,157 Lines • Show Last 20 Lines | |||||
This is the only place that really needs a goto, the rest can return (mumble). I don't insist on changing the diff, though.