#include "db_config.h"
#include "db_int.h"
int
__os_qnx_region_open(env, name, oflags, mode, fhpp)
ENV *env;
const char *name;
int oflags, mode;
DB_FH **fhpp;
{
DB_FH *fhp;
int fcntl_flags;
int ret;
if ((ret = __os_calloc(env, 1, sizeof(DB_FH), &fhp)) != 0)
return (ret);
if ((ret = __os_strdup(env, name, &fhp->name)) != 0)
goto err;
if (env != NULL) {
MUTEX_LOCK(env, env->mtx_env);
TAILQ_INSERT_TAIL(&env->fdlist, fhp, q);
MUTEX_UNLOCK(env, env->mtx_env);
F_SET(fhp, DB_FH_ENVLINK);
}
if ((fhp->fd = shm_open(name, oflags, mode)) == -1) {
ret = __os_posix_err(__os_get_syserr());
err: (void)__os_closehandle(env, fhp);
return (ret);
}
F_SET(fhp, DB_FH_OPENED);
#ifdef HAVE_FCNTL_F_SETFD
if ((fcntl_flags = fcntl(fhp->fd, F_GETFD)) == -1 ||
fcntl(fhp->fd, F_SETFD, fcntl_flags | FD_CLOEXEC) == -1) {
ret = __os_get_syserr();
__db_syserr(env, ret, "fcntl(F_SETFD)");
(void)__os_closehandle(env, fhp);
return (__os_posix_err(ret));
}
#else
COMPQUIET(fcntl_flags, 0);
#endif
F_SET(fhp, DB_FH_OPENED);
*fhpp = fhp;
return (0);
}