Lock the vnode before calling ufs_bmap_seekdata().
r346932 replaced a call to vn_bmap_seekhole() with a call to ufs_bmap_seekdata(). Although vn_bmap_seekhole() locks the vnode, ufs_bmap_seekdata() assumes it is already locked. This patch adds locking of the vnode before the ufs_bmap_seekdata() call. If the vn_lock() call fails, it returns EBADF since that is the normal error returned when a file system is forced dismounted and is already listed as an error return in the lseek(2) man page. Discussed with: markj Reviewed by: kib
This commit is contained in:
parent
776d3d5924
commit
b4c9955e41
@ -2702,11 +2702,18 @@ static int
|
|||||||
ufs_ioctl(struct vop_ioctl_args *ap)
|
ufs_ioctl(struct vop_ioctl_args *ap)
|
||||||
{
|
{
|
||||||
struct vnode *vp;
|
struct vnode *vp;
|
||||||
|
int error;
|
||||||
|
|
||||||
vp = ap->a_vp;
|
vp = ap->a_vp;
|
||||||
switch (ap->a_command) {
|
switch (ap->a_command) {
|
||||||
case FIOSEEKDATA:
|
case FIOSEEKDATA:
|
||||||
return (ufs_bmap_seekdata(vp, (off_t *)ap->a_data));
|
error = vn_lock(vp, LK_SHARED);
|
||||||
|
if (error == 0) {
|
||||||
|
error = ufs_bmap_seekdata(vp, (off_t *)ap->a_data);
|
||||||
|
VOP_UNLOCK(vp, 0);
|
||||||
|
} else
|
||||||
|
error = EBADF;
|
||||||
|
return (error);
|
||||||
case FIOSEEKHOLE:
|
case FIOSEEKHOLE:
|
||||||
return (vn_bmap_seekhole(vp, ap->a_command, (off_t *)ap->a_data,
|
return (vn_bmap_seekhole(vp, ap->a_command, (off_t *)ap->a_data,
|
||||||
ap->a_cred));
|
ap->a_cred));
|
||||||
|
Loading…
x
Reference in New Issue
Block a user