Changeset View
Changeset View
Standalone View
Standalone View
lib/libc/db/db/db.c
Show First 20 Lines • Show All 49 Lines • ▼ Show 20 Lines | |||||
#define O_CLOEXEC 0 | #define O_CLOEXEC 0 | ||||
#endif | #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 \ | const int use_open_flags = O_CREAT | O_EXCL | O_NOFOLLOW | O_NONBLOCK | | ||||
arichardson: This change is needed to make `cross-build/include/linux/fcntl.h` compatible with LLVM since… | |||||
dimUnsubmitted Not Done Inline ActionsIsn't it easier to work around this problem by defining O_EXLOCK and friends to 0 in the compat fcntl.h instead? Then you could leave this file alone. dim: Isn't it easier to work around this problem by defining `O_EXLOCK` and friends to 0 in the… | |||||
arichardsonAuthorUnsubmitted Done Inline ActionsYes it would be, but then we get silent success without a lock if one of the bootstrap tools uses these flags. I think not defining it in that case is safer. arichardson: Yes it would be, but then we get silent success without a lock if one of the bootstrap tools… | |||||
jrtc27Unsubmitted Done Inline ActionsThis diff can be much more minimal if you just do #ifndef/#define 0 like for O_CLOEXEC above (i.e., that's all you need to do, then the existing code here just works). Not in the header, just this file, so it's still an error to try to use one of the missing flags. And yes, this should probably be a separate commit. jrtc27: This diff can be much more minimal if you just do #ifndef/#define 0 like for O_CLOEXEC above (i. | |||||
(O_CREAT | O_EXCL | O_EXLOCK | O_NOFOLLOW | O_NONBLOCK | \ | O_RDONLY | O_RDWR | O_SYNC | O_TRUNC | | ||||
O_RDONLY | O_RDWR | O_SHLOCK | O_SYNC | O_TRUNC | O_CLOEXEC) | #ifdef O_EXLOCK | ||||
O_EXLOCK | | |||||
#endif | |||||
#ifdef O_SHLOCK | |||||
O_SHLOCK | | |||||
#endif | |||||
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, | ||||
mode, openinfo, flags & DB_FLAGS)); | mode, openinfo, flags & DB_FLAGS)); | ||||
case DB_RECNO: | case DB_RECNO: | ||||
return (__rec_open(fname, flags & USE_OPEN_FLAGS, | return (__rec_open(fname, flags & use_open_flags, | ||||
mode, openinfo, flags & DB_FLAGS)); | mode, openinfo, flags & DB_FLAGS)); | ||||
} | } | ||||
errno = EINVAL; | errno = EINVAL; | ||||
return (NULL); | return (NULL); | ||||
} | } | ||||
static int | static int | ||||
__dberr(void) | __dberr(void) | ||||
Show All 21 Lines |
This change is needed to make cross-build/include/linux/fcntl.h compatible with LLVM since that uses ::open(...) which doesn't work with the statement macro.
Can also split this into a separate commit?