Commit 9565b06b authored by Yoni Fogel's avatar Yoni Fogel

Default env directory is '.'

Add support for DB_USE_ENVIRON and DB_USE_ENVIRON_ROOT

git-svn-id: file:///svn/tokudb@783 c7de825b-a66e-492c-adef-691d508d4ae1
parent 8b03a47f
...@@ -14,6 +14,7 @@ ...@@ -14,6 +14,7 @@
#include <sys/types.h> #include <sys/types.h>
#include <ctype.h> #include <ctype.h>
#include <unistd.h> #include <unistd.h>
#include <libgen.h>
#include "brt.h" #include "brt.h"
#include "brt-internal.h" #include "brt-internal.h"
...@@ -223,9 +224,21 @@ int __toku_db_env_open(DB_ENV * env, const char *home, u_int32_t flags, int mode ...@@ -223,9 +224,21 @@ int __toku_db_env_open(DB_ENV * env, const char *home, u_int32_t flags, int mode
if (db_env_opened(env)) if (db_env_opened(env))
return EINVAL; return EINVAL;
if ((flags & DB_USE_ENVIRON) && (flags & DB_USE_ENVIRON_ROOT)) return EINVAL;
if (home) {
if ((flags & DB_USE_ENVIRON) || (flags & DB_USE_ENVIRON_ROOT)) return EINVAL;
}
else if ((flags & DB_USE_ENVIRON) ||
((flags & DB_USE_ENVIRON_ROOT) && geteuid() == 0)) {
home = getenv("DB_HOME");
if (!home) return EINVAL; if (!home) return EINVAL;
else { }
else home = ".";
// Verify that the home exists. // Verify that the home exists.
{
struct stat buf; struct stat buf;
r = stat(home, &buf); r = stat(home, &buf);
if (r!=0) return errno; if (r!=0) return errno;
...@@ -250,10 +263,7 @@ int __toku_db_env_open(DB_ENV * env, const char *home, u_int32_t flags, int mode ...@@ -250,10 +263,7 @@ int __toku_db_env_open(DB_ENV * env, const char *home, u_int32_t flags, int mode
env->i->dir = NULL; env->i->dir = NULL;
return r; return r;
} }
if ((r = db_env_read_config(env, flags)) != 0) { if ((r = db_env_read_config(env, flags)) != 0) goto died1;
fprintf(stderr, "FOO FOO FOO \n");
goto died1;
}
env->i->open_flags = flags; env->i->open_flags = flags;
env->i->open_mode = mode; env->i->open_mode = mode;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment