Changeset View
Changeset View
Standalone View
Standalone View
sys/kern/vfs_vnops.c
Show First 20 Lines • Show All 2,430 Lines • ▼ Show 20 Lines | vn_pages_remove(struct vnode *vp, vm_pindex_t start, vm_pindex_t end) | ||||
if ((object = vp->v_object) == NULL) | if ((object = vp->v_object) == NULL) | ||||
return; | return; | ||||
VM_OBJECT_WLOCK(object); | VM_OBJECT_WLOCK(object); | ||||
vm_object_page_remove(object, start, end, 0); | vm_object_page_remove(object, start, end, 0); | ||||
VM_OBJECT_WUNLOCK(object); | VM_OBJECT_WUNLOCK(object); | ||||
} | } | ||||
int | int | ||||
vn_bmap_seekhole(struct vnode *vp, u_long cmd, off_t *off, struct ucred *cred) | vn_bmap_seekhole_locked(struct vnode *vp, u_long cmd, off_t *off, | ||||
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, | KASSERT(cmd == FIOSEEKHOLE || cmd == FIOSEEKDATA, | ||||
("Wrong command %lu", cmd)); | ("%s: Wrong command %lu", __func__, cmd)); | ||||
ASSERT_VOP_LOCKED(vp, "vn_bmap_seekhole_locked"); | |||||
if (vn_lock(vp, LK_SHARED) != 0) | if (vn_lock(vp, LK_SHARED) != 0) | ||||
return (EBADF); | return (EBADF); | ||||
if (vp->v_type != VREG) { | if (vp->v_type != VREG) { | ||||
error = ENOTTY; | error = ENOTTY; | ||||
goto unlock; | goto unlock; | ||||
} | } | ||||
error = VOP_GETATTR(vp, &va, cred); | error = VOP_GETATTR(vp, &va, cred); | ||||
Show All 12 Lines | if (error == EOPNOTSUPP) { | ||||
error = ENOTTY; | error = ENOTTY; | ||||
goto unlock; | goto unlock; | ||||
} | } | ||||
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 unlock; | goto unlock; | ||||
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; | ||||
unlock: | unlock: | ||||
VOP_UNLOCK(vp); | VOP_UNLOCK(vp); | ||||
if (error == 0) | if (error == 0) | ||||
*off = noff; | *off = noff; | ||||
return (error); | |||||
} | |||||
int | |||||
vn_bmap_seekhole(struct vnode *vp, u_long cmd, off_t *off, struct ucred *cred) | |||||
{ | |||||
int error; | |||||
KASSERT(cmd == FIOSEEKHOLE || cmd == FIOSEEKDATA, | |||||
("%s: Wrong command %lu", __func__, cmd)); | |||||
if (vn_lock(vp, LK_SHARED) != 0) | |||||
return (EBADF); | |||||
error = vn_bmap_seekhole_locked(vp, cmd, off, cred); | |||||
VOP_UNLOCK(vp); | |||||
return (error); | return (error); | ||||
} | } | ||||
int | int | ||||
vn_seek(struct file *fp, off_t offset, int whence, struct thread *td) | vn_seek(struct file *fp, off_t offset, int whence, struct thread *td) | ||||
{ | { | ||||
struct ucred *cred; | struct ucred *cred; | ||||
struct vnode *vp; | struct vnode *vp; | ||||
▲ Show 20 Lines • Show All 1,038 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.