diff options
Diffstat (limited to 'freebsd/lib/libc/db/btree/bt_open.c')
-rw-r--r-- | freebsd/lib/libc/db/btree/bt_open.c | 14 |
1 files changed, 6 insertions, 8 deletions
diff --git a/freebsd/lib/libc/db/btree/bt_open.c b/freebsd/lib/libc/db/btree/bt_open.c index b249f5cd..ce393bbb 100644 --- a/freebsd/lib/libc/db/btree/bt_open.c +++ b/freebsd/lib/libc/db/btree/bt_open.c @@ -59,6 +59,7 @@ __FBSDID("$FreeBSD$"); #include <string.h> #include <unistd.h> #include "un-namespace.h" +#include "libc_private.h" #include <db.h> #include "btree.h" @@ -198,7 +199,7 @@ __bt_open(const char *fname, int flags, int mode, const BTREEINFO *openinfo, int goto einval; } - if ((t->bt_fd = _open(fname, flags, mode)) < 0) + if ((t->bt_fd = _open(fname, flags | O_CLOEXEC, mode)) < 0) goto err; } else { @@ -209,9 +210,6 @@ __bt_open(const char *fname, int flags, int mode, const BTREEINFO *openinfo, int F_SET(t, B_INMEM); } - if (_fcntl(t->bt_fd, F_SETFD, 1) == -1) - goto err; - if (_fstat(t->bt_fd, &sb)) goto err; if (sb.st_size) { @@ -281,7 +279,7 @@ __bt_open(const char *fname, int flags, int mode, const BTREEINFO *openinfo, int b.cachesize = b.psize * MINCACHE; /* Calculate number of pages to cache. */ - ncache = (b.cachesize + t->bt_psize - 1) / t->bt_psize; + ncache = howmany(b.cachesize, t->bt_psize); /* * The btree data structure requires that at least two keys can fit on @@ -406,10 +404,10 @@ tmp(void) } (void)sigfillset(&set); - (void)_sigprocmask(SIG_BLOCK, &set, &oset); - if ((fd = mkstemp(path)) != -1) + (void)__libc_sigprocmask(SIG_BLOCK, &set, &oset); + if ((fd = mkostemp(path, O_CLOEXEC)) != -1) (void)unlink(path); - (void)_sigprocmask(SIG_SETMASK, &oset, NULL); + (void)__libc_sigprocmask(SIG_SETMASK, &oset, NULL); return(fd); } |