Update to FreeBSD head 2016-08-23

Git mirror commit 9fe7c416e6abb28b1398fd3e5687099846800cfd.
This commit is contained in:
Sebastian Huber
2016-10-07 15:10:20 +02:00
parent 8c0eebac7d
commit c40e45b75e
1040 changed files with 156866 additions and 67039 deletions

View File

@@ -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);
}

View File

@@ -57,7 +57,7 @@ static EPG *bt_fast(BTREE *, const DBT *, const DBT *, int *);
* dbp: pointer to access method
* key: key
* data: data
* flag: R_NOOVERWRITE
* flag: R_NOOVERWRITE, R_SETCURSOR, R_CURSOR
*
* Returns:
* RET_ERROR, RET_SUCCESS and RET_SPECIAL if the key is already in the
@@ -93,6 +93,7 @@ __bt_put(const DB *dbp, DBT *key, const DBT *data, u_int flags)
switch (flags) {
case 0:
case R_NOOVERWRITE:
case R_SETCURSOR:
break;
case R_CURSOR:
/*

View File

@@ -38,7 +38,6 @@ static char sccsid[] = "@(#)bt_split.c 8.10 (Berkeley) 1/9/95";
#include <sys/cdefs.h>
__FBSDID("$FreeBSD$");
#include <sys/types.h>
#include <rtems/bsd/sys/param.h>
#include <limits.h>
@@ -238,9 +237,12 @@ __bt_split(BTREE *t, PAGE *sp, const DBT *key, const DBT *data, int flags,
WR_BINTERNAL(dest, nksize ? nksize : bl->ksize,
rchild->pgno, bl->flags & P_BIGKEY);
memmove(dest, bl->bytes, nksize ? nksize : bl->ksize);
if (bl->flags & P_BIGKEY &&
bt_preserve(t, *(pgno_t *)bl->bytes) == RET_ERROR)
goto err1;
if (bl->flags & P_BIGKEY) {
pgno_t pgno;
memcpy(&pgno, bl->bytes, sizeof(pgno));
if (bt_preserve(t, pgno) == RET_ERROR)
goto err1;
}
break;
case P_RINTERNAL:
/*
@@ -546,9 +548,12 @@ bt_broot(BTREE *t, PAGE *h, PAGE *l, PAGE *r)
* If the key is on an overflow page, mark the overflow chain
* so it isn't deleted when the leaf copy of the key is deleted.
*/
if (bl->flags & P_BIGKEY &&
bt_preserve(t, *(pgno_t *)bl->bytes) == RET_ERROR)
return (RET_ERROR);
if (bl->flags & P_BIGKEY) {
pgno_t pgno;
memcpy(&pgno, bl->bytes, sizeof(pgno));
if (bt_preserve(t, pgno) == RET_ERROR)
return (RET_ERROR);
}
break;
case P_BINTERNAL:
bi = GETBINTERNAL(r, 0);