From owner-svn-src-stable-10@FreeBSD.ORG Wed Nov 19 10:25:09 2014 Return-Path: Delivered-To: svn-src-stable-10@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) (using TLSv1.2 with cipher AECDH-AES256-SHA (256/256 bits)) (No client certificate requested) by hub.freebsd.org (Postfix) with ESMTPS id EA0A6E3A; Wed, 19 Nov 2014 10:25:09 +0000 (UTC) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:1900:2254:2068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id BC87EF9B; Wed, 19 Nov 2014 10:25:09 +0000 (UTC) Received: from svn.freebsd.org ([127.0.1.70]) by svn.freebsd.org (8.14.9/8.14.9) with ESMTP id sAJAP9YK041408; Wed, 19 Nov 2014 10:25:09 GMT (envelope-from kib@FreeBSD.org) Received: (from kib@localhost) by svn.freebsd.org (8.14.9/8.14.9/Submit) id sAJAP9UA041407; Wed, 19 Nov 2014 10:25:09 GMT (envelope-from kib@FreeBSD.org) Message-Id: <201411191025.sAJAP9UA041407@svn.freebsd.org> X-Authentication-Warning: svn.freebsd.org: kib set sender to kib@FreeBSD.org using -f From: Konstantin Belousov Date: Wed, 19 Nov 2014 10:25:09 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-10@freebsd.org Subject: svn commit: r274706 - stable/10/sys/kern X-SVN-Group: stable-10 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-stable-10@freebsd.org X-Mailman-Version: 2.1.18-1 Precedence: list List-Id: SVN commit messages for only the 10-stable src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 19 Nov 2014 10:25:10 -0000 Author: kib Date: Wed Nov 19 10:25:08 2014 New Revision: 274706 URL: https://svnweb.freebsd.org/changeset/base/274706 Log: MFC r274438: For posix_fallocate(2) and posix_fadvise(2), return ESPIPE when underlying file does not have DFLAG_SEEKABLE set. For posix_fallocate(2), simplify error handling logic. Modified: stable/10/sys/kern/vfs_syscalls.c Directory Properties: stable/10/ (props changed) Modified: stable/10/sys/kern/vfs_syscalls.c ============================================================================== --- stable/10/sys/kern/vfs_syscalls.c Wed Nov 19 09:07:49 2014 (r274705) +++ stable/10/sys/kern/vfs_syscalls.c Wed Nov 19 10:25:08 2014 (r274706) @@ -4549,38 +4549,29 @@ kern_posix_fallocate(struct thread *td, off_t olen, ooffset; int error; - fp = NULL; + if (offset < 0 || len <= 0) + return (EINVAL); + /* Check for wrap. */ + if (offset > OFF_MAX - len) + return (EFBIG); error = fget(td, fd, cap_rights_init(&rights, CAP_WRITE), &fp); if (error != 0) - goto out; - - switch (fp->f_type) { - case DTYPE_VNODE: - break; - case DTYPE_PIPE: - case DTYPE_FIFO: + return (error); + if ((fp->f_ops->fo_flags & DFLAG_SEEKABLE) == 0) { error = ESPIPE; goto out; - default: - error = ENODEV; - goto out; } if ((fp->f_flag & FWRITE) == 0) { error = EBADF; goto out; } - vp = fp->f_vnode; - if (vp->v_type != VREG) { + if (fp->f_type != DTYPE_VNODE) { error = ENODEV; goto out; } - if (offset < 0 || len <= 0) { - error = EINVAL; - goto out; - } - /* Check for wrap. */ - if (offset > OFF_MAX - len) { - error = EFBIG; + vp = fp->f_vnode; + if (vp->v_type != VREG) { + error = ENODEV; goto out; } @@ -4617,8 +4608,7 @@ kern_posix_fallocate(struct thread *td, maybe_yield(); } out: - if (fp != NULL) - fdrop(fp, td); + fdrop(fp, td); return (error); } @@ -4668,15 +4658,11 @@ kern_posix_fadvise(struct thread *td, in error = fget(td, fd, cap_rights_init(&rights), &fp); if (error != 0) goto out; - - switch (fp->f_type) { - case DTYPE_VNODE: - break; - case DTYPE_PIPE: - case DTYPE_FIFO: + if ((fp->f_ops->fo_flags & DFLAG_SEEKABLE) == 0) { error = ESPIPE; goto out; - default: + } + if (fp->f_type != DTYPE_VNODE) { error = ENODEV; goto out; }