static int env_recover(char *progname) { DbEnv *dbenv; home_entry *hp; u_int32_t flags; int exitval, ret; for (hp = LIST_FIRST(&__dbsrv_home); hp != NULL; hp = LIST_NEXT(hp, entries)) { exitval = 0; dbenv = new DbEnv(DB_CXX_NO_EXCEPTIONS); if (__dbsrv_verbose == 1) { (void)dbenv->set_verbose(DB_VERB_RECOVERY, 1); (void)dbenv->set_verbose(DB_VERB_CHKPOINT, 1); } dbenv->set_errfile(stderr); dbenv->set_errpfx(progname); if (hp->passwd != NULL) (void)dbenv->set_encrypt(hp->passwd, DB_ENCRYPT_AES); /* * Initialize the env with DB_RECOVER. That is all we * have to do to run recovery. */ if (__dbsrv_verbose) printf("Running recovery on %s\n", hp->home); flags = DB_CREATE | DB_INIT_LOCK | DB_INIT_LOG | DB_INIT_MPOOL | DB_INIT_TXN | DB_USE_ENVIRON | DB_RECOVER; if ((ret = dbenv->open(hp->home, flags, 0)) != 0) { dbenv->err(ret, "DbEnv->open"); goto error; } if (0) { error: exitval = 1; } if ((ret = dbenv->close(0)) != 0) { exitval = 1; fprintf(stderr, "%s: dbenv->close: %s\n", progname, db_strerror(ret)); } if (exitval) return (exitval); } return (0); }