VFS: add ability to open files O_CLOEXEC

.adjust libc to make use of it (undo __minix diff)

Change-Id: I90a1aa219fcd1b12b6bc60e72176f326eac8184a
This commit is contained in:
Thomas Veerman 2013-01-10 15:31:30 +00:00
parent 2ea6149f7c
commit fd610ba1b0
13 changed files with 3 additions and 52 deletions

View file

@ -46,10 +46,6 @@ __RCSID("$NetBSD: citrus_mmap.c,v 1.4 2011/10/15 23:00:01 christos Exp $");
#include "citrus_region.h"
#include "citrus_mmap.h"
#if defined(__minix) && !defined(O_CLOEXEC)
#define O_CLOEXEC 0
#endif
int
_citrus_map_file(struct _citrus_region * __restrict r,
const char * __restrict path)

View file

@ -70,15 +70,8 @@ __rec_open(const char *fname, int flags, mode_t mode, const RECNOINFO *openinfo,
dbp = NULL;
/* Open the user's file -- if this fails, we're done. */
if (fname != NULL) {
#ifndef O_CLOEXEC
#define O_CLOEXEC 0
#endif
if ((rfd = open(fname, flags | O_CLOEXEC, mode)) == -1)
return NULL;
#if O_CLOEXEC == 0
if (fcntl(rfd, F_SETFD, FD_CLOEXEC) == -1)
goto err;
#endif
}
/* Create a btree in memory (backed by disk). */

View file

@ -213,9 +213,6 @@ fts_open(char * const *argv, int options,
* and ".." are all fairly nasty problems. Note, if we can't get the
* descriptor we run anyway, just more slowly.
*/
#ifndef O_CLOEXEC
#define O_CLOEXEC 0
#endif
if (!ISSET(FTS_NOCHDIR)) {
if ((sp->fts_rfd = open(".", O_RDONLY | O_CLOEXEC, 0)) == -1)
SET(FTS_NOCHDIR);

View file

@ -42,10 +42,6 @@ __RCSID("$NetBSD: initdir.c,v 1.3 2012/03/13 21:13:36 christos Exp $");
#include <sys/featuretest.h>
#include <sys/types.h>
#if !defined(O_CLOEXEC)
#define O_CLOEXEC 0
#endif
#endif
#include "reentrant.h"

View file

@ -45,10 +45,6 @@ __RCSID("$NetBSD: opendir.c,v 1.38 2011/10/15 23:00:01 christos Exp $");
#include <sys/cdefs.h>
#include <sys/types.h>
#if !defined(O_CLOEXEC)
#define O_CLOEXEC 0
#endif
#endif
#include "extern.h"
@ -94,12 +90,6 @@ __opendir2(const char *name, int flags)
if ((fd = open(name, O_RDONLY | O_NONBLOCK | O_CLOEXEC)) == -1)
return NULL;
#if defined(__minix)
if (fcntl(fd, F_SETFD, FD_CLOEXEC) == -1) {
close(fd);
return NULL;
}
#endif /* defined(__minix) */
return __opendir_common(fd, name, flags);
}

View file

@ -59,10 +59,6 @@ __RCSID("$NetBSD: popen.c,v 1.32 2012/06/25 22:32:43 abs Exp $");
#include "env.h"
#include "reentrant.h"
#if defined(__minix) && !defined(O_CLOEXEC)
#define O_CLOEXEC 0
#endif
#ifdef __weak_alias
__weak_alias(popen,_popen)
__weak_alias(pclose,_pclose)

View file

@ -49,10 +49,6 @@ __RCSID("$NetBSD: flags.c,v 1.16 2012/03/15 18:22:30 christos Exp $");
#include "reentrant.h"
#include "local.h"
#if defined(__minix) && !defined(O_CLOEXEC)
#define O_CLOEXEC 0
#endif
/*
* Return the (stdio) flags for a given mode. Store the flags
* to be passed to an open() syscall through *optr.

View file

@ -49,10 +49,6 @@ __RCSID("$NetBSD: adjtime.c,v 1.12 2011/10/15 23:00:02 christos Exp $");
#include <sys/clockctl.h>
#if defined(__minix) && !defined(O_CLOEXEC)
#define O_CLOEXEC 0
#endif
extern int __clockctl_fd;
int ____adjtime50(const struct timeval *, struct timeval *);

View file

@ -51,10 +51,6 @@ __RCSID("$NetBSD: clock_settime.c,v 1.12 2011/10/15 23:00:02 christos Exp $");
#include <sys/clockctl.h>
#if defined(__minix) && !defined(O_CLOEXEC)
#define O_CLOEXEC 0
#endif
extern int __clockctl_fd;
int ____clock_settime50(clockid_t, const struct timespec *);

View file

@ -55,10 +55,6 @@ __RCSID("$NetBSD: ntp_adjtime.c,v 1.13 2012/03/20 16:26:12 matt Exp $");
__weak_alias(ntp_adjtime,_ntp_adjtime)
#endif
#if defined(__minix) && !defined(O_CLOEXEC)
#define O_CLOEXEC 0
#endif
extern int __clockctl_fd;
int __ntp_adjtime(struct timex *);

View file

@ -51,10 +51,6 @@ __RCSID("$NetBSD: settimeofday.c,v 1.14 2011/10/15 23:00:02 christos Exp $");
#include <time.h>
#include <unistd.h>
#if defined(__minix) && !defined(O_CLOEXEC)
#define O_CLOEXEC 0
#endif
int __clockctl_fd = -1;
int ____settimeofday50(const struct timeval *, const void *);

View file

@ -160,6 +160,8 @@ int common_open(char path[PATH_MAX], int oflags, mode_t omode)
filp->filp_count = 1;
filp->filp_vno = vp;
filp->filp_flags = oflags;
if (oflags & O_CLOEXEC)
FD_SET(scratch(fp).file.fd_nr, &fp->fp_cloexec_set);
/* Only do the normal open code if we didn't just create the file. */
if (exist) {

View file

@ -72,6 +72,7 @@
#define O_REOPEN 010000 /* automatically re-open device after driver
* restart
*/
#define O_CLOEXEC 020000 /* close on exec */
#ifndef __minix /* NOT SUPPORTED! */