Skip site navigation (1)Skip section navigation (2)
Date:      Fri, 14 Jun 2013 21:56:10 +0000 (UTC)
From:      John Baldwin <jhb@FreeBSD.org>
To:        src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-9@freebsd.org
Subject:   svn commit: r251762 - stable/9/sys/kern
Message-ID:  <201306142156.r5ELuAbm090773@svn.freebsd.org>

next in thread | raw e-mail | index | archive | help
Author: jhb
Date: Fri Jun 14 21:56:10 2013
New Revision: 251762
URL: http://svnweb.freebsd.org/changeset/base/251762

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/9/sys/kern/vfs_vnops.c
Directory Properties:
  stable/9/sys/   (props changed)

Modified: stable/9/sys/kern/vfs_vnops.c
==============================================================================
--- stable/9/sys/kern/vfs_vnops.c	Fri Jun 14 21:14:36 2013	(r251761)
+++ stable/9/sys/kern/vfs_vnops.c	Fri Jun 14 21:56:10 2013	(r251762)
@@ -1333,13 +1333,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,



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201306142156.r5ELuAbm090773>