svn commit: r251764 - stable/8/sys/kern

John Baldwin jhb at FreeBSD.org
Fri Jun 14 22:06:45 UTC 2013


Author: jhb
Date: Fri Jun 14 22:06:45 2013
New Revision: 251764
URL: http://svnweb.freebsd.org/changeset/base/251764

Log:
  MFC 250220:
  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.

Modified:
  stable/8/sys/kern/vfs_vnops.c
Directory Properties:
  stable/8/sys/   (props changed)
  stable/8/sys/kern/   (props changed)

Modified: stable/8/sys/kern/vfs_vnops.c
==============================================================================
--- stable/8/sys/kern/vfs_vnops.c	Fri Jun 14 22:06:18 2013	(r251763)
+++ stable/8/sys/kern/vfs_vnops.c	Fri Jun 14 22:06:45 2013	(r251764)
@@ -952,13 +952,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,


More information about the svn-src-stable-8 mailing list