Skip site navigation (1)Skip section navigation (2)
Date:      Fri, 3 May 2013 19:08:59 +0000 (UTC)
From:      John Baldwin <jhb@FreeBSD.org>
To:        src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org
Subject:   svn commit: r250220 - head/sys/kern
Message-ID:  <201305031908.r43J8xnI094418@svn.freebsd.org>

next in thread | raw e-mail | index | archive | help
Author: jhb
Date: Fri May  3 19:08:58 2013
New Revision: 250220
URL: http://svnweb.freebsd.org/changeset/base/250220

Log:
  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

Modified:
  head/sys/kern/vfs_vnops.c

Modified: head/sys/kern/vfs_vnops.c
==============================================================================
--- head/sys/kern/vfs_vnops.c	Fri May  3 18:58:37 2013	(r250219)
+++ head/sys/kern/vfs_vnops.c	Fri May  3 19:08:58 2013	(r250220)
@@ -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,



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