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
This commit is contained in:
Yoni Fogel 2007-11-28 14:50:09 +00:00
parent 897e28c38a
commit f40ba83d2f

View file

@ -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
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
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;