diff options
author | Matthew Dempsky <matthew@cvs.openbsd.org> | 2011-07-09 01:28:49 +0000 |
---|---|---|
committer | Matthew Dempsky <matthew@cvs.openbsd.org> | 2011-07-09 01:28:49 +0000 |
commit | aa56a8937683997424c97f9a6d5d895875d09902 (patch) | |
tree | ec79564a0336d2c23c5bead8c5fcdea2e6cbfb6d | |
parent | 462e16bede2f5559d4d01a1649b811abb4d51974 (diff) |
Add support for the O_CLOEXEC and O_DIRECTORY flags introduced in
POSIX Issue 7.
Requested by oga@ (and maybe djm@); ok guenther@
-rw-r--r-- | sys/kern/vfs_syscalls.c | 4 | ||||
-rw-r--r-- | sys/kern/vfs_vnops.c | 6 | ||||
-rw-r--r-- | sys/sys/fcntl.h | 6 |
3 files changed, 13 insertions, 3 deletions
diff --git a/sys/kern/vfs_syscalls.c b/sys/kern/vfs_syscalls.c index 4f94147b51a..9b1bcf4f641 100644 --- a/sys/kern/vfs_syscalls.c +++ b/sys/kern/vfs_syscalls.c @@ -1,4 +1,4 @@ -/* $OpenBSD: vfs_syscalls.c,v 1.171 2011/07/08 19:28:38 otto Exp $ */ +/* $OpenBSD: vfs_syscalls.c,v 1.172 2011/07/09 01:28:48 matthew Exp $ */ /* $NetBSD: vfs_syscalls.c,v 1.71 1996/04/23 10:29:02 mycroft Exp $ */ /* @@ -928,6 +928,8 @@ doopenat(struct proc *p, int fd, const char *path, int oflags, mode_t mode, } } VOP_UNLOCK(vp, 0, p); + if (flags & O_CLOEXEC) + fdp->fd_ofileflags[indx] |= UF_EXCLOSE; *retval = indx; FILE_SET_MATURE(fp); out: diff --git a/sys/kern/vfs_vnops.c b/sys/kern/vfs_vnops.c index 001dca5bbe5..03ade69df5f 100644 --- a/sys/kern/vfs_vnops.c +++ b/sys/kern/vfs_vnops.c @@ -1,4 +1,4 @@ -/* $OpenBSD: vfs_vnops.c,v 1.67 2011/07/06 09:14:26 matthew Exp $ */ +/* $OpenBSD: vfs_vnops.c,v 1.68 2011/07/09 01:28:48 matthew Exp $ */ /* $NetBSD: vfs_vnops.c,v 1.20 1996/02/04 02:18:41 christos Exp $ */ /* @@ -135,6 +135,10 @@ vn_open(struct nameidata *ndp, int fmode, int cmode) error = ELOOP; goto bad; } + if ((fmode & O_DIRECTORY) && vp->v_type != VDIR) { + error = ENOTDIR; + goto bad; + } if ((fmode & O_CREAT) == 0) { if (fmode & FREAD) { if ((error = VOP_ACCESS(vp, VREAD, cred, p)) != 0) diff --git a/sys/sys/fcntl.h b/sys/sys/fcntl.h index f14b27cc3c3..03faadd235c 100644 --- a/sys/sys/fcntl.h +++ b/sys/sys/fcntl.h @@ -1,4 +1,4 @@ -/* $OpenBSD: fcntl.h,v 1.15 2011/07/08 21:26:27 matthew Exp $ */ +/* $OpenBSD: fcntl.h,v 1.16 2011/07/09 01:28:48 matthew Exp $ */ /* $NetBSD: fcntl.h,v 1.8 1995/03/26 20:24:12 jtc Exp $ */ /*- @@ -108,6 +108,10 @@ /* defined by POSIX 1003.1; BSD default, this bit is not required */ #define O_NOCTTY 0x8000 /* don't assign controlling terminal */ +/* defined by POSIX Issue 7 */ +#define O_CLOEXEC 0x10000 /* atomically set FD_CLOEXEC */ +#define O_DIRECTORY 0x20000 /* fail if not a directory */ + #ifdef _KERNEL /* * convert from open() flags to/from fflags; convert O_RD/WR to FREAD/FWRITE. |