Fix FIONREAD on regular files. The computed result was being ignored and

it was being passed down to VOP_IOCTL() where it promptly resulted in
ENOTTY due to a missing else for the past 8 years.  While here, use a
shared vnode lock while fetching the current file's size.

MFC after:	1 week
This commit is contained in:
John Baldwin 2013-05-03 19:08:58 +00:00
parent f5c4b077be
commit dfa66c01ae

View File

@ -1364,13 +1364,12 @@ vn_ioctl(fp, com, data, active_cred, td)
case VREG:
case VDIR:
if (com == FIONREAD) {
vn_lock(vp, LK_EXCLUSIVE | LK_RETRY);
vn_lock(vp, LK_SHARED | LK_RETRY);
error = VOP_GETATTR(vp, &vattr, active_cred);
VOP_UNLOCK(vp, 0);
if (!error)
*(int *)data = vattr.va_size - fp->f_offset;
}
if (com == FIONBIO || com == FIOASYNC) /* XXX */
} else if (com == FIONBIO || com == FIOASYNC) /* XXX */
error = 0;
else
error = VOP_IOCTL(vp, com, data, fp->f_flag,