From owner-svn-src-all@FreeBSD.ORG Mon May 6 17:55:24 2013 Return-Path: Delivered-To: svn-src-all@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by hub.freebsd.org (Postfix) with ESMTP id 5CD2728E; Mon, 6 May 2013 17:55:24 +0000 (UTC) (envelope-from jhb@freebsd.org) Received: from bigwig.baldwin.cx (bigwig.baldwin.cx [IPv6:2001:470:1f11:75::1]) by mx1.freebsd.org (Postfix) with ESMTP id 395916A8; Mon, 6 May 2013 17:55:24 +0000 (UTC) Received: from jhbbsd.localnet (unknown [209.249.190.124]) by bigwig.baldwin.cx (Postfix) with ESMTPSA id A0681B94A; Mon, 6 May 2013 13:55:23 -0400 (EDT) From: John Baldwin To: Bruce Evans Subject: Re: svn commit: r250220 - head/sys/kern Date: Mon, 6 May 2013 13:55:20 -0400 User-Agent: KMail/1.13.5 (FreeBSD/8.2-CBSD-20110714-p25; KDE/4.5.5; amd64; ; ) References: <201305031908.r43J8xnI094418@svn.freebsd.org> <20130504184721.E619@etaplex.bde.org> In-Reply-To: <20130504184721.E619@etaplex.bde.org> MIME-Version: 1.0 Content-Type: Text/Plain; charset="iso-8859-1" Content-Transfer-Encoding: 7bit Message-Id: <201305061355.20826.jhb@freebsd.org> X-Greylist: Sender succeeded SMTP AUTH, not delayed by milter-greylist-4.2.7 (bigwig.baldwin.cx); Mon, 06 May 2013 13:55:23 -0400 (EDT) Cc: svn-src-head@freebsd.org, svn-src-all@freebsd.org X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 06 May 2013 17:55:24 -0000 On Saturday, May 04, 2013 4:47:43 am Bruce Evans wrote: > > 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. > > In another thread I complained to kib about using the bad style of not > returning as soon as possible, but instead sometimes returning and sometimes > falling through a complicated if-else ladder to get to the return at the > end. What about this: static int vn_ioctl(fp, com, data, active_cred, td) struct file *fp; u_long com; void *data; struct ucred *active_cred; struct thread *td; { struct vnode *vp = fp->f_vnode; struct vattr vattr; switch (vp->v_type) { case VREG: case VDIR: switch (com) { case FIONREAD: 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; return (error); case FIONBIO: case FIOASYNC: return (0); /* XXX */ default: return (VOP_IOCTL(vp, com, data, fp->f_flag, active_cred, td)); } default: return (ENOTTY); } } (The 'XXX' comment could perhaps be expanded to something along the lines of 'Allow fcntl() to toggle FNONBLOCK and FASYNC.') -- John Baldwin