Changeset View
Changeset View
Standalone View
Standalone View
head/lib/libc/db/db/db.c
Show All 38 Lines | |||||
#include <fcntl.h> | #include <fcntl.h> | ||||
#include <stddef.h> | #include <stddef.h> | ||||
#include <stdio.h> | #include <stdio.h> | ||||
#include <db.h> | #include <db.h> | ||||
static int __dberr(void); | static int __dberr(void); | ||||
#ifndef O_CLOEXEC | |||||
#define O_CLOEXEC 0 | |||||
#endif | |||||
DB * | DB * | ||||
dbopen(const char *fname, int flags, int mode, DBTYPE type, const void *openinfo) | dbopen(const char *fname, int flags, int mode, DBTYPE type, const void *openinfo) | ||||
{ | { | ||||
#define DB_FLAGS (DB_LOCK | DB_SHMEM | DB_TXN) | #define DB_FLAGS (DB_LOCK | DB_SHMEM | DB_TXN) | ||||
#define USE_OPEN_FLAGS \ | #define USE_OPEN_FLAGS \ | ||||
(O_CREAT | O_EXCL | O_EXLOCK | O_NOFOLLOW | O_NONBLOCK | \ | (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) | if ((flags & ~(USE_OPEN_FLAGS | DB_FLAGS)) == 0) | ||||
switch (type) { | switch (type) { | ||||
case DB_BTREE: | case DB_BTREE: | ||||
return (__bt_open(fname, flags & USE_OPEN_FLAGS, | return (__bt_open(fname, flags & USE_OPEN_FLAGS, | ||||
mode, openinfo, flags & DB_FLAGS)); | mode, openinfo, flags & DB_FLAGS)); | ||||
case DB_HASH: | case DB_HASH: | ||||
return (__hash_open(fname, flags & USE_OPEN_FLAGS, | return (__hash_open(fname, flags & USE_OPEN_FLAGS, | ||||
Show All 32 Lines |