From owner-svn-src-all@FreeBSD.ORG Wed Mar 10 19:49:33 2010 Return-Path: Delivered-To: svn-src-all@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id 8601F1065670; Wed, 10 Mar 2010 19:49:33 +0000 (UTC) (envelope-from jhb@FreeBSD.org) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:4f8:fff6::2c]) by mx1.freebsd.org (Postfix) with ESMTP id 752898FC26; Wed, 10 Mar 2010 19:49:33 +0000 (UTC) Received: from svn.freebsd.org (localhost [127.0.0.1]) by svn.freebsd.org (8.14.3/8.14.3) with ESMTP id o2AJnXiv044638; Wed, 10 Mar 2010 19:49:33 GMT (envelope-from jhb@svn.freebsd.org) Received: (from jhb@localhost) by svn.freebsd.org (8.14.3/8.14.3/Submit) id o2AJnXHR044636; Wed, 10 Mar 2010 19:49:33 GMT (envelope-from jhb@svn.freebsd.org) Message-Id: <201003101949.o2AJnXHR044636@svn.freebsd.org> From: John Baldwin Date: Wed, 10 Mar 2010 19:49:33 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-7@freebsd.org X-SVN-Group: stable-7 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Cc: Subject: svn commit: r204971 - stable/7/sys/kern X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.5 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: Wed, 10 Mar 2010 19:49:33 -0000 Author: jhb Date: Wed Mar 10 19:49:33 2010 New Revision: 204971 URL: http://svn.freebsd.org/changeset/base/204971 Log: MFC 204638: Allow lseek(SEEK_END) to work on disk devices by using the DIOCGMEDIASIZE to determine the media size. Modified: stable/7/sys/kern/vfs_syscalls.c Directory Properties: stable/7/sys/ (props changed) stable/7/sys/cddl/contrib/opensolaris/ (props changed) stable/7/sys/contrib/dev/acpica/ (props changed) stable/7/sys/contrib/pf/ (props changed) Modified: stable/7/sys/kern/vfs_syscalls.c ============================================================================== --- stable/7/sys/kern/vfs_syscalls.c Wed Mar 10 19:47:05 2010 (r204970) +++ stable/7/sys/kern/vfs_syscalls.c Wed Mar 10 19:49:33 2010 (r204971) @@ -46,6 +46,7 @@ __FBSDID("$FreeBSD$"); #include #include #include +#include #include #include #include @@ -1762,7 +1763,7 @@ lseek(td, uap) struct file *fp; struct vnode *vp; struct vattr vattr; - off_t offset; + off_t offset, size; int error, noneg; int vfslocked; @@ -1792,6 +1793,15 @@ lseek(td, uap) VOP_UNLOCK(vp, 0, td); if (error) break; + + /* + * If the file references a disk device, then fetch + * the media size and use that to determine the ending + * offset. + */ + if (vattr.va_size == 0 && vp->v_type == VCHR && + fo_ioctl(fp, DIOCGMEDIASIZE, &size, cred, td) == 0) + vattr.va_size = size; if (noneg && (vattr.va_size > OFF_MAX || (offset > 0 && vattr.va_size > OFF_MAX - offset))) {