Commit 46e337f6 authored by Rich Prohaska's avatar Rich Prohaska

turn assert into an error return. close #407

git-svn-id: file:///svn/tokudb@2307 c7de825b-a66e-492c-adef-691d508d4ae1
parent 0438e575
......@@ -23,7 +23,7 @@ clean:
rm -rf $(TARGETS) *.gcno *.gcda *.gcov *.db
check: $(TARGETS) \
check_db_create_1 check_db_create_2 check_db_create_3 check_db_create_4
check_db_create_1 check_db_create_2 check_db_create_3 check_db_create_4 check_permissions
$(VGRIND) ./test1
$(VGRIND) ./test1e
rm -f foo.db
......@@ -56,3 +56,9 @@ check_db_create_3:
$(VGRIND) ./db_create --help; let exitcode=$$?; if [ $$exitcode -ne 0 ] ; then exit 0; else exit 1; fi
check_db_create_4:
$(VGRIND) ./db_create -s; let exitcode=$$?; if [ $$exitcode -ne 0 ] ; then exit 0; else exit 1; fi
check_permissions:
rm -f test.db
./db_create test.db 1 1
chmod -w test.db
./db_create test.db 2 2; let exitcode=$$?; if [ $$exitcode -ne 0 ] ; then exit 0; else exit 1; fi
\ No newline at end of file
......@@ -23,7 +23,7 @@ int dbdump(char *dbfile, char *dbname) {
#endif
r = db.open(0, dbfile, dbname, DB_UNKNOWN, 0, 0777);
if (r != 0) {
printf("cant open %s:%s\n", dbfile, dbname);
printf("cant open %s:%s %d:%s\n", dbfile, dbname, r, db_strerror(r));
#if USE_ENV
r = env.close(0); assert(r == 0);
#endif
......
......@@ -1365,21 +1365,25 @@ int toku_brt_open(BRT t, const char *fname, const char *fname_in_env, const char
{
int fd = open(fname, O_RDWR, 0777);
r = errno;
if (fd==-1 && errno==ENOENT) {
if (!is_create) {
t->database_name=0;
goto died0a;
}
fd = open(fname, O_RDWR | O_CREAT, 0777);
r = errno;
if (fd==-1) {
t->database_name=0;
goto died0a;
}
r = toku_logger_log_fcreate(txn, fname_in_env, 0777);
if (r!=0) goto died0a;
if (fd==-1) {
if (errno==ENOENT) {
if (!is_create) {
t->database_name=0;
goto died0a;
}
fd = open(fname, O_RDWR | O_CREAT, 0777);
r = errno;
if (fd==-1) {
t->database_name=0;
goto died0a;
}
r = toku_logger_log_fcreate(txn, fname_in_env, 0777);
if (r!=0) goto died0a;
} else
goto died0a;
}
r=toku_cachetable_openfd(&t->cf, cachetable, fd);
if (r != 0) goto died0a;
toku_logger_log_fopen(txn, fname_in_env, toku_cachefile_filenum(t->cf));
}
if (r!=0) {
......
......@@ -107,7 +107,7 @@ int toku_cachetable_openfd (CACHEFILE *cf, CACHETABLE t, int fd) {
struct fileid fileid;
memset(&fileid, 0, sizeof(fileid));
r=fstat(fd, &statbuf);
assert(r==0);
if (r != 0) return errno;
fileid.st_dev = statbuf.st_dev;
fileid.st_ino = statbuf.st_ino;
for (extant = t->cachefiles; extant; extant=extant->next) {
......
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