]> xenbits.xensource.com Git - freebsd.git/commitdiff
Return EISDIR when directory is opened with O_CREAT without O_DIRECTORY.
authorkib <kib@FreeBSD.org>
Tue, 17 Sep 2019 18:32:18 +0000 (18:32 +0000)
committerkib <kib@FreeBSD.org>
Tue, 17 Sep 2019 18:32:18 +0000 (18:32 +0000)
Reviewed by: bcr (man page), emaste (previous version)
PR: 240452
Sponsored by: The FreeBSD Foundation
MFC after: 1 week
DIfferential revision: https://reviews.freebsd.org/D21634

lib/libc/sys/open.2
sys/kern/vfs_vnops.c

index a876cccb84b52666c3282599db7b05ec002a9fd9..fe50b292d1bda847e2d47c16e4bf84aaeded05e2 100644 (file)
@@ -28,7 +28,7 @@
 .\"     @(#)open.2     8.2 (Berkeley) 11/16/93
 .\" $FreeBSD$
 .\"
-.Dd June 14, 2019
+.Dd September 17, 2019
 .Dt OPEN 2
 .Os
 .Sh NAME
@@ -419,6 +419,11 @@ Too many symbolic links were encountered in translating the pathname.
 .It Bq Er EISDIR
 The named file is a directory, and the arguments specify
 it is to be modified.
+.It Bq Er EISDIR
+The named file is a directory, and the flags specified
+.Dv O_CREAT
+without
+.Dv O_DIRECTORY .
 .It Bq Er EROFS
 The named file resides on a read-only file system,
 and the file is to be modified.
index 4116ee51120d996cfcecc474d10378c111c761af..3f8bd4504808ba10f21442f383a5fcbd22248985 100644 (file)
@@ -264,6 +264,10 @@ restart:
                                error = EEXIST;
                                goto bad;
                        }
+                       if (vp->v_type == VDIR) {
+                               error = EISDIR;
+                               goto bad;
+                       }
                        fmode &= ~O_CREAT;
                }
        } else {