Date: Fri, 10 Feb 2017 14:49:05 +0000 (UTC) From: Konstantin Belousov <kib@FreeBSD.org> To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-head@freebsd.org Subject: svn commit: r313549 - in head/sys: kern sys Message-ID: <201702101449.v1AEn5XX004753@repo.freebsd.org>
next in thread | raw e-mail | index | archive | help
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 <iblis@hs.ntnu.edu.tw> 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 */
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?201702101449.v1AEn5XX004753>