/* Open the BDB environment at PATH and compare its configuration flags with FLAGS. If every flag in FLAGS is set in the environment, then set *MATCH to true. Else set *MATCH to false. */ static svn_error_t * check_env_flags(svn_boolean_t *match, u_int32_t flags, const char *path, apr_pool_t *pool) { bdb_env_baton_t *bdb; #if SVN_BDB_VERSION_AT_LEAST(4, 7) int flag_state; #else u_int32_t envflags; #endif SVN_ERR(svn_fs_bdb__open(&bdb, path, SVN_BDB_STANDARD_ENV_FLAGS, 0666, pool)); #if SVN_BDB_VERSION_AT_LEAST(4, 7) SVN_BDB_ERR(bdb, bdb->env->log_get_config(bdb->env, flags, &flag_state)); #else SVN_BDB_ERR(bdb, bdb->env->get_flags(bdb->env, &envflags)); #endif SVN_ERR(svn_fs_bdb__close(bdb)); #if SVN_BDB_VERSION_AT_LEAST(4, 7) if (flag_state == 0) #else if (flags & envflags) #endif *match = TRUE; else *match = FALSE; return SVN_NO_ERROR; }
static svn_error_t * base_bdb_logfiles(apr_array_header_t **logfiles, const char *path, svn_boolean_t only_unused, apr_pool_t *pool) { bdb_env_baton_t *bdb; char **filelist; char **filename; u_int32_t flags = only_unused ? 0 : DB_ARCH_LOG; *logfiles = apr_array_make(pool, 4, sizeof(const char *)); SVN_ERR(svn_fs_bdb__open(&bdb, path, SVN_BDB_STANDARD_ENV_FLAGS, 0666, pool)); SVN_BDB_ERR(bdb, bdb->env->log_archive(bdb->env, &filelist, flags)); if (filelist == NULL) return svn_fs_bdb__close(bdb); for (filename = filelist; *filename != NULL; ++filename) { APR_ARRAY_PUSH(*logfiles, const char *) = apr_pstrdup(pool, *filename); } free(filelist); return svn_fs_bdb__close(bdb); }
/* Convert a BDB error to a Subversion error. */ static svn_error_t * convert_bdb_error(bdb_env_t *bdb, int db_err) { if (db_err) { bdb_env_baton_t bdb_baton; bdb_baton.env = bdb->env; bdb_baton.bdb = bdb; bdb_baton.error_info = get_error_info(bdb); SVN_BDB_ERR(&bdb_baton, db_err); } return SVN_NO_ERROR; }
/* Set *PAGESIZE to the size of pages used to hold items in the database environment located at PATH. */ static svn_error_t * get_db_pagesize(u_int32_t *pagesize, const char *path, apr_pool_t *pool) { bdb_env_baton_t *bdb; DB *nodes_table; SVN_ERR(svn_fs_bdb__open(&bdb, path, SVN_BDB_STANDARD_ENV_FLAGS, 0666, pool)); /* ### We're only asking for the pagesize on the 'nodes' table. Is this enough? We never call DB->set_pagesize() on any of our tables, so presumably BDB is using the same default pagesize for all our databases, right? */ SVN_BDB_ERR(bdb, svn_fs_bdb__open_nodes_table(&nodes_table, bdb->env, FALSE)); SVN_BDB_ERR(bdb, nodes_table->get_pagesize(nodes_table, pagesize)); SVN_BDB_ERR(bdb, nodes_table->close(nodes_table, 0)); return svn_fs_bdb__close(bdb); }