From owner-svn-src-all@freebsd.org Fri Feb 10 14:49:06 2017 Return-Path: Delivered-To: svn-src-all@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 3F0A6CD8210; Fri, 10 Feb 2017 14:49:06 +0000 (UTC) (envelope-from kib@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::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 0ECB6354; Fri, 10 Feb 2017 14:49:05 +0000 (UTC) (envelope-from kib@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id v1AEn5An004756; Fri, 10 Feb 2017 14:49:05 GMT (envelope-from kib@FreeBSD.org) Received: (from kib@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id v1AEn5XX004753; Fri, 10 Feb 2017 14:49:05 GMT (envelope-from kib@FreeBSD.org) Message-Id: <201702101449.v1AEn5XX004753@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: kib set sender to kib@FreeBSD.org using -f From: Konstantin Belousov Date: Fri, 10 Feb 2017 14:49:05 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r313549 - in head/sys: kern sys X-SVN-Group: head MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.23 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: Fri, 10 Feb 2017 14:49:06 -0000 Author: kib Date: Fri Feb 10 14:49:04 2017 New Revision: 313549 URL: https://svnweb.freebsd.org/changeset/base/313549 Log: Fix r313495. The file type DTYPE_VNODE can be assigned as a fallback if VOP_OPEN() did not initialized file type. This is a typical code path used by normal file systems. Also, change error returned for inappropriate file type used for O_EXLOCK to EOPNOTSUPP, as declared in the open(2) man page. Reported by: cy, dhw, Iblis Lin Tested by: dhw Sponsored by: The FreeBSD Foundation MFC after: 13 days Modified: head/sys/kern/vfs_vnops.c head/sys/sys/file.h Modified: head/sys/kern/vfs_vnops.c ============================================================================== --- head/sys/kern/vfs_vnops.c Fri Feb 10 14:38:28 2017 (r313548) +++ head/sys/kern/vfs_vnops.c Fri Feb 10 14:49:04 2017 (r313549) @@ -351,8 +351,8 @@ vn_open_vnode(struct vnode *vp, int fmod while ((fmode & (O_EXLOCK | O_SHLOCK)) != 0) { KASSERT(fp != NULL, ("open with flock requires fp")); - if (fp->f_type != DTYPE_VNODE) { - error = EBADF; + if (fp->f_type != DTYPE_NONE && fp->f_type != DTYPE_VNODE) { + error = EOPNOTSUPP; break; } lock_flags = VOP_ISLOCKED(vp); Modified: head/sys/sys/file.h ============================================================================== --- head/sys/sys/file.h Fri Feb 10 14:38:28 2017 (r313548) +++ head/sys/sys/file.h Fri Feb 10 14:49:04 2017 (r313549) @@ -53,6 +53,7 @@ struct vnode; #endif /* _KERNEL */ +#define DTYPE_NONE 0 /* not yet initialized */ #define DTYPE_VNODE 1 /* file */ #define DTYPE_SOCKET 2 /* communications endpoint */ #define DTYPE_PIPE 3 /* pipe */