mirror of
https://git.rtems.org/rtems-libbsd/
synced 2025-10-14 18:41:59 +08:00
Update to FreeBSD head 2016-08-23
Git mirror commit 9fe7c416e6abb28b1398fd3e5687099846800cfd.
This commit is contained in:
@@ -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);
|
||||
}
|
||||
|
||||
|
@@ -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:
|
||||
/*
|
||||
|
@@ -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);
|
||||
|
@@ -46,6 +46,10 @@ __FBSDID("$FreeBSD$");
|
||||
|
||||
static int __dberr(void);
|
||||
|
||||
#ifndef O_CLOEXEC
|
||||
#define O_CLOEXEC 0
|
||||
#endif
|
||||
|
||||
DB *
|
||||
dbopen(const char *fname, int flags, int mode, DBTYPE type, const void *openinfo)
|
||||
{
|
||||
@@ -53,7 +57,7 @@ dbopen(const char *fname, int flags, int mode, DBTYPE type, const void *openinfo
|
||||
#define DB_FLAGS (DB_LOCK | DB_SHMEM | DB_TXN)
|
||||
#define USE_OPEN_FLAGS \
|
||||
(O_CREAT | O_EXCL | O_EXLOCK | O_NOFOLLOW | O_NONBLOCK | \
|
||||
O_RDONLY | O_RDWR | O_SHLOCK | O_SYNC | O_TRUNC)
|
||||
O_RDONLY | O_RDWR | O_SHLOCK | O_SYNC | O_TRUNC | O_CLOEXEC)
|
||||
|
||||
if ((flags & ~(USE_OPEN_FLAGS | DB_FLAGS)) == 0)
|
||||
switch (type) {
|
||||
|
@@ -66,7 +66,7 @@ __rec_open(const char *fname, int flags, int mode, const RECNOINFO *openinfo,
|
||||
int rfd, sverrno;
|
||||
|
||||
/* Open the user's file -- if this fails, we're done. */
|
||||
if (fname != NULL && (rfd = _open(fname, flags, mode)) < 0)
|
||||
if (fname != NULL && (rfd = _open(fname, flags | O_CLOEXEC, mode)) < 0)
|
||||
return (NULL);
|
||||
|
||||
/* Create a btree in memory (backed by disk). */
|
||||
|
@@ -142,8 +142,7 @@ einval: errno = EINVAL;
|
||||
return (RET_ERROR);
|
||||
if (nrec > t->bt_nrecs + 1) {
|
||||
if (F_ISSET(t, R_FIXLEN)) {
|
||||
if ((tdata.data =
|
||||
(void *)malloc(t->bt_reclen)) == NULL)
|
||||
if ((tdata.data = malloc(t->bt_reclen)) == NULL)
|
||||
return (RET_ERROR);
|
||||
tdata.size = t->bt_reclen;
|
||||
memset(tdata.data, t->bt_bval, tdata.size);
|
||||
@@ -210,7 +209,7 @@ __rec_iput(BTREE *t, recno_t nrec, const DBT *data, u_int flags)
|
||||
return (RET_ERROR);
|
||||
tdata.data = db;
|
||||
tdata.size = NOVFLSIZE;
|
||||
*(pgno_t *)db = pg;
|
||||
memcpy(db, &pg, sizeof(pg));
|
||||
*(u_int32_t *)(db + sizeof(pgno_t)) = data->size;
|
||||
dflags = P_BIGDATA;
|
||||
data = &tdata;
|
||||
|
Reference in New Issue
Block a user