Alien-SVN
view release on metacpan or search on metacpan
src/subversion/subversion/libsvn_fs/fs-loader.c view on Meta::CPAN
return svn_error_createf(SVN_ERR_VERSION_MISMATCH, NULL,
_("Mismatched FS module version for '%s':"
" found %d.%d.%d%s,"
" expected %d.%d.%d%s"),
fst->fs_type,
my_version->major, my_version->minor,
my_version->patch, my_version->tag,
fs_version->major, fs_version->minor,
fs_version->patch, fs_version->tag);
return SVN_NO_ERROR;
}
#if defined(SVN_USE_DSO) && APR_HAS_DSO
/* Return *FST for the third party FS_TYPE */
static svn_error_t *
get_or_allocate_third(struct fs_type_defn **fst,
const char *fs_type)
{
while (*fst)
{
if (strcmp(fs_type, (*fst)->fs_type) == 0)
return SVN_NO_ERROR;
fst = &(*fst)->next;
}
*fst = apr_palloc(common_pool, sizeof(struct fs_type_defn));
(*fst)->fs_type = apr_pstrdup(common_pool, fs_type);
(*fst)->fsap_name = (*fst)->fs_type;
(*fst)->initfunc = NULL;
(*fst)->next = NULL;
return SVN_NO_ERROR;
}
#endif
/* Fetch a library vtable by FS type. */
static svn_error_t *
get_library_vtable(fs_library_vtable_t **vtable, const char *fs_type,
apr_pool_t *pool)
{
struct fs_type_defn **fst = &fs_modules;
svn_boolean_t known = FALSE;
/* There are two FS module definitions known at compile time. We
want to check these without any locking overhead even when
dynamic third party modules are enabled. The third party modules
cannot be checked until the lock is held. */
if (strcmp(fs_type, (*fst)->fs_type) == 0)
known = TRUE;
else
{
fst = &(*fst)->next;
if (strcmp(fs_type, (*fst)->fs_type) == 0)
known = TRUE;
}
#if defined(SVN_USE_DSO) && APR_HAS_DSO
/* Third party FS modules that are unknown at compile time.
A third party FS is identified by the file fs-type containing a
third party name, say "foo". The loader will load the DSO with
the name "libsvn_fs_foo" and use the entry point with the name
"svn_fs_foo__init".
Note: the BDB and FSFS modules don't follow this naming scheme
and this allows them to be used to test the third party loader.
Change the content of fs-type to "base" in a BDB filesystem or to
"fs" in an FSFS filesystem and they will be loaded as third party
modules. */
if (!known)
{
fst = &(*fst)->next;
if (!common_pool) /* Best-effort init, see get_library_vtable_direct. */
SVN_ERR(svn_fs_initialize(NULL));
SVN_MUTEX__WITH_LOCK(common_pool_lock,
get_or_allocate_third(fst, fs_type));
known = TRUE;
}
#endif
if (!known)
return svn_error_createf(SVN_ERR_FS_UNKNOWN_FS_TYPE, NULL,
_("Unknown FS type '%s'"), fs_type);
return get_library_vtable_direct(vtable, *fst, pool);
}
svn_error_t *
svn_fs_type(const char **fs_type, const char *path, apr_pool_t *pool)
{
const char *filename;
char buf[128];
svn_error_t *err;
apr_file_t *file;
apr_size_t len;
/* Read the fsap-name file to get the FSAP name, or assume the (old)
default. For old repositories I suppose we could check some
other file, DB_CONFIG or strings say, but for now just check the
directory exists. */
filename = svn_dirent_join(path, FS_TYPE_FILENAME, pool);
err = svn_io_file_open(&file, filename, APR_READ|APR_BUFFERED, 0, pool);
if (err && APR_STATUS_IS_ENOENT(err->apr_err))
{
svn_node_kind_t kind;
svn_error_t *err2 = svn_io_check_path(path, &kind, pool);
if (err2)
{
svn_error_clear(err2);
return err;
}
if (kind == svn_node_dir)
{
svn_error_clear(err);
*fs_type = SVN_FS_TYPE_BDB;
return SVN_NO_ERROR;
}
return err;
}
else if (err)
return err;
len = sizeof(buf);
( run in 0.669 second using v1.01-cache-2.11-cpan-483215c6ad5 )