diff options
author | jhb <jhb@FreeBSD.org> | 2013-05-03 19:08:58 +0000 |
---|---|---|
committer | jhb <jhb@FreeBSD.org> | 2013-05-03 19:08:58 +0000 |
commit | 3ddeecb12be89773eb9b5a58fa1c35fd61bf6693 (patch) | |
tree | 9f71a61a71448b959e4b046b7e95e860c09f40dd /sys/kern | |
parent | 383aea5677ae9f4489314b23087ca08e6ab7b483 (diff) | |
download | FreeBSD-src-3ddeecb12be89773eb9b5a58fa1c35fd61bf6693.zip FreeBSD-src-3ddeecb12be89773eb9b5a58fa1c35fd61bf6693.tar.gz |
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
Diffstat (limited to 'sys/kern')
-rw-r--r-- | sys/kern/vfs_vnops.c | 5 |
1 files changed, 2 insertions, 3 deletions
diff --git a/sys/kern/vfs_vnops.c b/sys/kern/vfs_vnops.c index 6849730..401cfe8 100644 --- a/sys/kern/vfs_vnops.c +++ b/sys/kern/vfs_vnops.c @@ -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, |