From 7fed33ae490989642156aae633d2139058e55429 Mon Sep 17 00:00:00 2001 From: Mohamad Chaarawi Date: Tue, 9 Sep 2014 16:35:35 -0500 Subject: [svn-r25582] Dynamic VOL plugin loading: - add support for searching for plugins by name in the H5PL interface - add support for searching for VOL plugins and returning the plugin structure - implement H5VLregister_by_name - add tests similar to the filter plugin tests - still needs some refactoring and better test framework and cmake support. --- MANIFEST | 4 + configure | 3 +- configure.ac | 1 + src/H5PL.c | 218 +++++++++++++++++++-------- src/H5PLextern.h | 3 +- src/H5PLprivate.h | 2 +- src/H5Pocpl.c | 2 +- src/H5VL.c | 129 +++++++++++----- src/H5VLpublic.h | 2 +- src/H5Z.c | 32 ++-- test/Makefile.am | 11 +- test/Makefile.in | 87 ++++++++--- test/dynlibvol1.c | 366 +++++++++++++++++++++++++++++++++++++++++++++ test/dynlibvol2.c | 366 +++++++++++++++++++++++++++++++++++++++++++++ test/test_vol_plugin.sh.in | 80 ++++++++++ test/vol_test.c | 136 +++++++++++++++++ 16 files changed, 1304 insertions(+), 138 deletions(-) create mode 100644 test/dynlibvol1.c create mode 100644 test/dynlibvol2.c create mode 100644 test/test_vol_plugin.sh.in create mode 100644 test/vol_test.c diff --git a/MANIFEST b/MANIFEST index 5864eec..cad597a 100644 --- a/MANIFEST +++ b/MANIFEST @@ -995,6 +995,8 @@ ./test/dynlib1.c ./test/dynlib2.c ./test/dynlib3.c +./test/dynlibvol1.c +./test/dynlibvol2.c ./test/earray.c ./test/efc.c ./test/enc_dec_plist.c @@ -1070,6 +1072,7 @@ ./test/ohdr.c ./test/objcopy.c ./test/plugin.c +./test/vol_test.c ./test/reserved.c ./test/pool.c ./test/set_extent.c @@ -1095,6 +1098,7 @@ ./test/testhdf5.h ./test/testlibinfo.sh.in ./test/test_plugin.sh.in +./test/test_vol_plugin.sh.in ./test/testmeta.c ./test/tfile.c ./test/tgenprop.c diff --git a/configure b/configure index 2dca279..d532263 100755 --- a/configure +++ b/configure @@ -33268,7 +33268,7 @@ else fi -ac_config_files="$ac_config_files src/libhdf5.settings Makefile src/Makefile test/Makefile test/testcheck_version.sh test/testerror.sh test/H5srcdir_str.h test/testlibinfo.sh test/testlinks_env.sh test/test_plugin.sh testpar/Makefile perform/Makefile tools/Makefile tools/h5dump/Makefile tools/h5dump/testh5dump.sh tools/h5dump/testh5dumppbits.sh tools/h5dump/testh5dumpxml.sh tools/h5ls/testh5ls.sh tools/h5import/Makefile tools/h5import/h5importtestutil.sh tools/h5diff/Makefile tools/h5diff/testh5diff.sh tools/h5diff/testph5diff.sh tools/h5jam/Makefile tools/h5jam/testh5jam.sh tools/h5repack/Makefile tools/h5repack/h5repack.sh tools/h5repack/h5repack_plugin.sh tools/h5ls/Makefile tools/h5copy/Makefile tools/h5copy/testh5copy.sh tools/lib/Makefile tools/misc/Makefile tools/misc/h5cc tools/misc/testh5mkgrp.sh tools/misc/testh5repart.sh tools/h5stat/testh5stat.sh tools/h5stat/Makefile examples/Makefile examples/run-c-ex.sh examples/testh5cc.sh c++/Makefile c++/src/Makefile c++/src/h5c++ c++/test/Makefile c++/test/H5srcdir_str.h c++/examples/Makefile c++/examples/run-c++-ex.sh c++/examples/testh5c++.sh fortran/Makefile fortran/src/h5fc fortran/src/Makefile fortran/test/Makefile fortran/testpar/Makefile fortran/examples/Makefile fortran/examples/run-fortran-ex.sh fortran/examples/testh5fc.sh hl/Makefile hl/src/Makefile hl/test/Makefile hl/test/H5srcdir_str.h hl/tools/Makefile hl/tools/gif2h5/Makefile hl/tools/gif2h5/h52giftest.sh hl/examples/Makefile hl/examples/run-hlc-ex.sh hl/c++/Makefile hl/c++/src/Makefile hl/c++/test/Makefile hl/c++/examples/Makefile hl/c++/examples/run-hlc++-ex.sh hl/fortran/Makefile hl/fortran/src/Makefile hl/fortran/test/Makefile hl/fortran/examples/Makefile hl/fortran/examples/run-hlfortran-ex.sh" +ac_config_files="$ac_config_files src/libhdf5.settings Makefile src/Makefile test/Makefile test/testcheck_version.sh test/testerror.sh test/H5srcdir_str.h test/testlibinfo.sh test/testlinks_env.sh test/test_plugin.sh test/test_vol_plugin.sh testpar/Makefile perform/Makefile tools/Makefile tools/h5dump/Makefile tools/h5dump/testh5dump.sh tools/h5dump/testh5dumppbits.sh tools/h5dump/testh5dumpxml.sh tools/h5ls/testh5ls.sh tools/h5import/Makefile tools/h5import/h5importtestutil.sh tools/h5diff/Makefile tools/h5diff/testh5diff.sh tools/h5diff/testph5diff.sh tools/h5jam/Makefile tools/h5jam/testh5jam.sh tools/h5repack/Makefile tools/h5repack/h5repack.sh tools/h5repack/h5repack_plugin.sh tools/h5ls/Makefile tools/h5copy/Makefile tools/h5copy/testh5copy.sh tools/lib/Makefile tools/misc/Makefile tools/misc/h5cc tools/misc/testh5mkgrp.sh tools/misc/testh5repart.sh tools/h5stat/testh5stat.sh tools/h5stat/Makefile examples/Makefile examples/run-c-ex.sh examples/testh5cc.sh c++/Makefile c++/src/Makefile c++/src/h5c++ c++/test/Makefile c++/test/H5srcdir_str.h c++/examples/Makefile c++/examples/run-c++-ex.sh c++/examples/testh5c++.sh fortran/Makefile fortran/src/h5fc fortran/src/Makefile fortran/test/Makefile fortran/testpar/Makefile fortran/examples/Makefile fortran/examples/run-fortran-ex.sh fortran/examples/testh5fc.sh hl/Makefile hl/src/Makefile hl/test/Makefile hl/test/H5srcdir_str.h hl/tools/Makefile hl/tools/gif2h5/Makefile hl/tools/gif2h5/h52giftest.sh hl/examples/Makefile hl/examples/run-hlc-ex.sh hl/c++/Makefile hl/c++/src/Makefile hl/c++/test/Makefile hl/c++/examples/Makefile hl/c++/examples/run-hlc++-ex.sh hl/fortran/Makefile hl/fortran/src/Makefile hl/fortran/test/Makefile hl/fortran/examples/Makefile hl/fortran/examples/run-hlfortran-ex.sh" cat >confcache <<\_ACEOF @@ -34547,6 +34547,7 @@ do "test/testlibinfo.sh") CONFIG_FILES="$CONFIG_FILES test/testlibinfo.sh" ;; "test/testlinks_env.sh") CONFIG_FILES="$CONFIG_FILES test/testlinks_env.sh" ;; "test/test_plugin.sh") CONFIG_FILES="$CONFIG_FILES test/test_plugin.sh" ;; + "test/test_vol_plugin.sh") CONFIG_FILES="$CONFIG_FILES test/test_vol_plugin.sh" ;; "testpar/Makefile") CONFIG_FILES="$CONFIG_FILES testpar/Makefile" ;; "perform/Makefile") CONFIG_FILES="$CONFIG_FILES perform/Makefile" ;; "tools/Makefile") CONFIG_FILES="$CONFIG_FILES tools/Makefile" ;; diff --git a/configure.ac b/configure.ac index 78a4ca9..d238db4 100644 --- a/configure.ac +++ b/configure.ac @@ -4479,6 +4479,7 @@ AC_CONFIG_FILES([src/libhdf5.settings test/testlibinfo.sh test/testlinks_env.sh test/test_plugin.sh + test/test_vol_plugin.sh testpar/Makefile perform/Makefile tools/Makefile diff --git a/src/H5PL.c b/src/H5PL.c index 21bc0f2..3ec66e8 100644 --- a/src/H5PL.c +++ b/src/H5PL.c @@ -27,6 +27,7 @@ #include "H5Eprivate.h" /* Error handling */ #include "H5MMprivate.h" /* Memory management */ #include "H5PLprivate.h" /* Plugin */ +#include "H5VLprivate.h" /* VOL */ #include "H5Zprivate.h" /* Filter pipeline */ @@ -96,9 +97,10 @@ typedef const void *(*H5PL_get_plugin_info_t)(void); /* Type for the list of info for opened plugin libraries */ typedef struct H5PL_table_t { - H5PL_type_t pl_type; /* plugin type */ - int pl_id; /* ID for the plugin */ - H5PL_HANDLE handle; /* plugin handle */ + H5PL_type_t pl_type; /* plugin type */ + int pl_id; /* ID for the plugin */ + const char *pl_name; /* name of the plugin */ + H5PL_HANDLE handle; /* plugin handle */ } H5PL_table_t; @@ -107,9 +109,9 @@ typedef struct H5PL_table_t { /********************/ static herr_t H5PL__init_path_table(void); -static htri_t H5PL__find(H5PL_type_t plugin_type, int type_id, char *dir, const void **info); -static htri_t H5PL__open(H5PL_type_t pl_type, char *libname, int plugin_id, const void **pl_info); -static htri_t H5PL__search_table(H5PL_type_t plugin_type, int type_id, const void **info); +static htri_t H5PL__find(H5PL_type_t plugin_type, int type_id, const char *plugin_name, char *dir, const void **info); +static htri_t H5PL__open(H5PL_type_t pl_type, char *libname, int plugin_id, const char *plugin_name, const void **pl_info); +static htri_t H5PL__search_table(H5PL_type_t plugin_type, int type_id, const char *plugin_name, const void **info); static herr_t H5PL__close(H5PL_HANDLE handle); @@ -132,6 +134,11 @@ static size_t H5PL_table_alloc_g = 0; static size_t H5PL_table_used_g = 0; static H5PL_table_t *H5PL_table_g = NULL; +/* Table for opened vol plugin libraries */ +static size_t H5PL_vol_table_alloc_g = 0; +static size_t H5PL_vol_table_used_g = 0; +static H5PL_table_t *H5PL_vol_table_g = NULL; + /* Table of location paths for plugin libraries */ static char *H5PL_path_table_g[H5PL_MAX_PATH_NUM]; static size_t H5PL_num_paths_g = 0; @@ -231,10 +238,20 @@ H5PL_term_interface(void) for(u = 0; u < H5PL_table_used_g; u++) H5PL__close((H5PL_table_g[u]).handle); + /* Close opened dynamic vol libraries */ + for(u = 0; u < H5PL_vol_table_used_g; u++) { + H5PL__close((H5PL_vol_table_g[u]).handle); + HDfree(H5PL_vol_table_g[u].pl_name); + } + /* Free the table of dynamic libraries */ H5PL_table_g = (H5PL_table_t *)H5MM_xfree(H5PL_table_g); H5PL_table_used_g = H5PL_table_alloc_g = 0; + /* Free the table of dynamic vol libraries */ + H5PL_vol_table_g = (H5PL_table_t *)H5MM_xfree(H5PL_vol_table_g); + H5PL_vol_table_used_g = H5PL_vol_table_alloc_g = 0; + /* Free the table of search paths */ for(u = 0; u < H5PL_num_paths_g; u++) if(H5PL_path_table_g[u]) @@ -253,9 +270,9 @@ H5PL_term_interface(void) /*------------------------------------------------------------------------- * Function: H5PL_load * - * Purpose: Given the plugin type and identifier, this function searches - * and/or loads a dynamic plugin library first among the already - * opened libraries then in the designated location paths. + * Purpose: Given the plugin type and identifier and/or name, this function + * searches and/or loads a dynamic plugin library first among the + * already opened libraries then in the designated location paths. * * Return: Non-NULL on success/NULL on failure * @@ -265,7 +282,7 @@ H5PL_term_interface(void) *------------------------------------------------------------------------- */ const void * -H5PL_load(H5PL_type_t type, int id) +H5PL_load(H5PL_type_t type, int id, const char *name) { htri_t found; /* Whether the plugin was found */ const void *plugin_info = NULL; @@ -285,7 +302,7 @@ H5PL_load(H5PL_type_t type, int id) HGOTO_ERROR(H5E_PLUGIN, H5E_CANTINIT, NULL, "can't initialize search path table") /* Search in the table of already loaded plugin libraries */ - if((found = H5PL__search_table(type, id, &plugin_info)) < 0) + if((found = H5PL__search_table(type, id, name, &plugin_info)) < 0) HGOTO_ERROR(H5E_PLUGIN, H5E_CANTGET, NULL, "search in table failed") /* If not found, iterate through the path table to find the right dynamic library */ @@ -293,7 +310,7 @@ H5PL_load(H5PL_type_t type, int id) size_t i; /* Local index variable */ for(i = 0; i < H5PL_num_paths_g; i++) { - if((found = H5PL__find(type, id, H5PL_path_table_g[i], &plugin_info)) < 0) + if((found = H5PL__find(type, id, name, H5PL_path_table_g[i], &plugin_info)) < 0) HGOTO_ERROR(H5E_PLUGIN, H5E_CANTGET, NULL, "search in paths failed") /* Break out if found */ @@ -387,7 +404,7 @@ done: */ #ifndef H5_HAVE_WIN32_API static htri_t -H5PL__find(H5PL_type_t plugin_type, int type_id, char *dir, const void **info) +H5PL__find(H5PL_type_t plugin_type, int type_id, const char *plugin_name, char *dir, const void **info) { char *pathname = NULL; DIR *dirp = NULL; @@ -425,8 +442,8 @@ H5PL__find(H5PL_type_t plugin_type, int type_id, char *dir, const void **info) if(S_ISDIR(my_stat.st_mode)) continue; - /* Attempt to open the dynamic library as a filter library */ - if((found_in_dir = H5PL__open(plugin_type, pathname, type_id, info)) < 0) + /* Attempt to open the dynamic library */ + if((found_in_dir = H5PL__open(plugin_type, pathname, type_id, plugin_name, info)) < 0) HGOTO_ERROR(H5E_PLUGIN, H5E_CANTGET, FAIL, "search in directory failed") if(found_in_dir) { /* Indicate success */ @@ -449,7 +466,7 @@ done: } /* end H5PL__find() */ #else /* H5_HAVE_WIN32_API */ static htri_t -H5PL__find(H5PL_type_t plugin_type, int type_id, char *dir, const void **info) +H5PL__find(H5PL_type_t plugin_type, int type_id, const char *plugin_name, char *dir, const void **info) { WIN32_FIND_DATA fdFile; HANDLE hFind; @@ -482,7 +499,7 @@ H5PL__find(H5PL_type_t plugin_type, int type_id, char *dir, const void **info) if(fdFile.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY) continue; - if((found_in_dir = H5PL__open(plugin_type, pathname, type_id, info)) < 0) + if((found_in_dir = H5PL__open(plugin_type, pathname, type_id, plugin_name, info)) < 0) HGOTO_ERROR(H5E_PLUGIN, H5E_CANTGET, FAIL, "search in directory failed") if(found_in_dir) { /* Indicate success */ @@ -522,7 +539,7 @@ done: *------------------------------------------------------------------------- */ static htri_t -H5PL__open(H5PL_type_t pl_type, char *libname, int pl_id, const void **pl_info) +H5PL__open(H5PL_type_t pl_type, char *libname, int pl_id, const char *pl_name, const void **pl_info) { H5PL_HANDLE handle = NULL; htri_t ret_value = FALSE; @@ -546,45 +563,108 @@ H5PL__open(H5PL_type_t pl_type, char *libname, int pl_id, const void **pl_info) HGOTO_ERROR(H5E_PLUGIN, H5E_CLOSEERROR, FAIL, "can't close dynamic library") } /* end if */ else { - const H5Z_class2_t *plugin_info; - - /* Invoke H5PLget_plugin_info to verify this is the right library we are looking for. - * Move on if it isn't. - */ - if(NULL == (plugin_info = (const H5Z_class2_t *)(*get_plugin_info)())) { - if(H5PL__close(handle) < 0) - HGOTO_ERROR(H5E_PLUGIN, H5E_CLOSEERROR, FAIL, "can't close dynamic library") - HGOTO_ERROR(H5E_PLUGIN, H5E_CANTGET, FAIL, "can't get plugin info") - } /* end if */ - - /* Successfully found plugin library, check if it's the right one */ - if(plugin_info->id == pl_id) { - /* Expand the table if it is too small */ - if(H5PL_table_used_g >= H5PL_table_alloc_g) { - size_t n = MAX(H5Z_MAX_NFILTERS, 2 * H5PL_table_alloc_g); - H5PL_table_t *table = (H5PL_table_t *)H5MM_realloc(H5PL_table_g, n * sizeof(H5PL_table_t)); - - if(!table) - HGOTO_ERROR(H5E_RESOURCE, H5E_CANTALLOC, FAIL, "unable to extend dynamic library table") - - H5PL_table_g = table; - H5PL_table_alloc_g = n; - } /* end if */ - - (H5PL_table_g[H5PL_table_used_g]).handle = handle; - (H5PL_table_g[H5PL_table_used_g]).pl_type = pl_type; - (H5PL_table_g[H5PL_table_used_g]).pl_id = plugin_info->id; - H5PL_table_used_g++; - - /* Set the plugin info to return */ - *pl_info = (const void *)plugin_info; - - /* Indicate success */ - ret_value = TRUE; - } /* end if */ - else - if(H5PL__close(handle) < 0) - HGOTO_ERROR(H5E_PLUGIN, H5E_CLOSEERROR, FAIL, "can't close dynamic library") + switch(pl_type) { + case H5PL_TYPE_FILTER: + { + const H5Z_class2_t *plugin_info; + + /* Invoke H5PLget_plugin_info to verify this is the right library we are looking for. + * Move on if it isn't. + */ + if(NULL == (plugin_info = (const H5Z_class2_t *)(*get_plugin_info)())) { + if(H5PL__close(handle) < 0) + HGOTO_ERROR(H5E_PLUGIN, H5E_CLOSEERROR, FAIL, "can't close dynamic library") + HGOTO_ERROR(H5E_PLUGIN, H5E_CANTGET, FAIL, "can't get plugin info") + } /* end if */ + + /* Successfully found plugin library, check if it's the right one */ + if(plugin_info->id == pl_id) { + /* Expand the table if it is too small */ + if(H5PL_table_used_g >= H5PL_table_alloc_g) { + size_t n = MAX(H5Z_MAX_NFILTERS, 2 * H5PL_table_alloc_g); + H5PL_table_t *table = (H5PL_table_t *)H5MM_realloc(H5PL_table_g, n * sizeof(H5PL_table_t)); + + if(!table) + HGOTO_ERROR(H5E_RESOURCE, H5E_CANTALLOC, FAIL, "unable to extend dynamic library table") + + H5PL_table_g = table; + H5PL_table_alloc_g = n; + } /* end if */ + + (H5PL_table_g[H5PL_table_used_g]).handle = handle; + (H5PL_table_g[H5PL_table_used_g]).pl_type = pl_type; + (H5PL_table_g[H5PL_table_used_g]).pl_id = plugin_info->id; + H5PL_table_used_g++; + + /* Set the plugin info to return */ + *pl_info = (const void *)plugin_info; + + /* Indicate success */ + ret_value = TRUE; + } /* end if */ + else + if(H5PL__close(handle) < 0) + HGOTO_ERROR(H5E_PLUGIN, H5E_CLOSEERROR, FAIL, "can't close dynamic library") + + break; + } + case H5PL_TYPE_VOL: + { + const H5VL_class_t *plugin_info; + + /* Invoke H5PLget_plugin_info to verify this is the right library we are looking for. + * Move on if it isn't. + */ + if(NULL == (plugin_info = (const H5VL_class_t *)(*get_plugin_info)())) { + if(H5PL__close(handle) < 0) + HGOTO_ERROR(H5E_PLUGIN, H5E_CLOSEERROR, FAIL, "can't close dynamic library") + HGOTO_ERROR(H5E_PLUGIN, H5E_CANTGET, FAIL, "can't get plugin info") + } /* end if */ + + /* Successfully found plugin library, check if it's the right one */ + if((pl_id > MAX_VOL_LIB_VALUE && plugin_info->value == pl_id) || + (pl_name && !strcmp(pl_name, plugin_info->name))) { + /* Expand the table if it is too small */ + if(H5PL_vol_table_used_g >= H5PL_vol_table_alloc_g) { + size_t n; + H5PL_table_t *table = NULL; + + if(0 == H5PL_vol_table_alloc_g) + n = 16; + else + n = 2 * H5PL_vol_table_alloc_g; + + table = (H5PL_table_t *)H5MM_realloc(H5PL_vol_table_g, n * sizeof(H5PL_table_t)); + if(!table) + HGOTO_ERROR(H5E_RESOURCE, H5E_CANTALLOC, FAIL, "unable to extend dynamic library table for vol plugins") + + H5PL_vol_table_g = table; + H5PL_vol_table_alloc_g = n; + } /* end if */ + + (H5PL_vol_table_g[H5PL_vol_table_used_g]).handle = handle; + (H5PL_vol_table_g[H5PL_vol_table_used_g]).pl_type = pl_type; + (H5PL_vol_table_g[H5PL_vol_table_used_g]).pl_id = plugin_info->value; + (H5PL_vol_table_g[H5PL_vol_table_used_g]).pl_name = HDstrdup(pl_name); + H5PL_vol_table_used_g++; + + /* Set the plugin info to return */ + *pl_info = (const void *)plugin_info; + + /* Indicate success */ + ret_value = TRUE; + } /* end if */ + else + if(H5PL__close(handle) < 0) + HGOTO_ERROR(H5E_PLUGIN, H5E_CLOSEERROR, FAIL, "can't close dynamic library") + + break; + } + case H5PL_TYPE_ERROR: + case H5PL_TYPE_NONE: + default: + HGOTO_ERROR(H5E_PLUGIN, H5E_BADVALUE, FAIL, "invalid plugin type") + } /* end switch */ } /* end if */ } /* end else */ @@ -609,14 +689,14 @@ done: *------------------------------------------------------------------------- */ static htri_t -H5PL__search_table(H5PL_type_t plugin_type, int type_id, const void **info) +H5PL__search_table(H5PL_type_t plugin_type, int type_id, const char *plugin_name, const void **info) { htri_t ret_value = FALSE; FUNC_ENTER_STATIC /* Search in the table of already opened dynamic libraries */ - if(H5PL_table_used_g > 0) { + if(H5PL_TYPE_FILTER == plugin_type && H5PL_table_used_g > 0) { size_t i; for(i = 0; i < H5PL_table_used_g; i++) { @@ -635,6 +715,26 @@ H5PL__search_table(H5PL_type_t plugin_type, int type_id, const void **info) } /* end if */ } /* end for */ } /* end if */ + else if(H5PL_TYPE_VOL == plugin_type && H5PL_vol_table_used_g > 0) { + size_t i; + + for(i = 0; i < H5PL_vol_table_used_g; i++) { + if((plugin_type == (H5PL_vol_table_g[i]).pl_type) && + (type_id == (H5PL_vol_table_g[i]).pl_id || !strcmp(plugin_name, (H5PL_vol_table_g[i]).pl_name))) { + H5PL_get_plugin_info_t get_plugin_info; + const H5VL_class_t *plugin_info; + + if(NULL == (get_plugin_info = (H5PL_get_plugin_info_t)H5PL_GET_LIB_FUNC((H5PL_vol_table_g[i]).handle, "H5PLget_plugin_info"))) + HGOTO_ERROR(H5E_DATATYPE, H5E_CANTGET, FAIL, "can't get function for H5PLget_plugin_info") + + if(NULL == (plugin_info = (const H5VL_class_t *)(*get_plugin_info)())) + HGOTO_ERROR(H5E_DATATYPE, H5E_CANTGET, FAIL, "can't get plugin info") + + *info = plugin_info; + HGOTO_DONE(TRUE) + } /* end if */ + } /* end for */ + } /* end if */ done: FUNC_LEAVE_NOAPI(ret_value) diff --git a/src/H5PLextern.h b/src/H5PLextern.h index 943e3aa..b5563e4 100644 --- a/src/H5PLextern.h +++ b/src/H5PLextern.h @@ -30,7 +30,8 @@ typedef enum H5PL_type_t { H5PL_TYPE_ERROR = -1, /*error */ H5PL_TYPE_FILTER = 0, /*filter */ - H5PL_TYPE_NONE = 1 /*this must be last! */ + H5PL_TYPE_VOL = 1, /*vol plugin */ + H5PL_TYPE_NONE = 2 /*this must be last! */ } H5PL_type_t; diff --git a/src/H5PLprivate.h b/src/H5PLprivate.h index b117613..237408d 100644 --- a/src/H5PLprivate.h +++ b/src/H5PLprivate.h @@ -46,7 +46,7 @@ /***************************************/ /* Internal API routines */ -H5_DLL const void *H5PL_load(H5PL_type_t plugin_type, int type_id); +H5_DLL const void *H5PL_load(H5PL_type_t plugin_type, int type_id, const char *plugin_name); H5_DLL htri_t H5PL_no_plugin(void); #endif /* _H5PLprivate_H */ diff --git a/src/H5Pocpl.c b/src/H5Pocpl.c index 37beb90..94fb5b2 100644 --- a/src/H5Pocpl.c +++ b/src/H5Pocpl.c @@ -834,7 +834,7 @@ H5P__set_filter(H5P_genplist_t *plist, H5Z_filter_t filter, unsigned int flags, if(!filter_avail) { const H5Z_class2_t *filter_info; - if(NULL == (filter_info = (const H5Z_class2_t *)H5PL_load(H5PL_TYPE_FILTER, (int)filter))) + if(NULL == (filter_info = (const H5Z_class2_t *)H5PL_load(H5PL_TYPE_FILTER, (int)filter, NULL))) HGOTO_ERROR(H5E_PLINE, H5E_CANTLOAD, FAIL, "failed to load dynamically loaded plugin") if(H5Z_register(filter_info) < 0) HGOTO_ERROR(H5E_PLINE, H5E_CANTINIT, FAIL, "unable to register filter") diff --git a/src/H5VL.c b/src/H5VL.c index 65a8a8f..f1a39ee 100644 --- a/src/H5VL.c +++ b/src/H5VL.c @@ -40,6 +40,7 @@ #include "H5Eprivate.h" /* Error handling */ #include "H5Iprivate.h" /* IDs */ #include "H5MMprivate.h" /* Memory management */ +#include "H5PLprivate.h" /* Plugins */ #include "H5VLpkg.h" /* VOL package header */ #include "H5VLprivate.h" /* VOL */ @@ -205,6 +206,39 @@ H5VL_free_cls(H5VL_class_t *cls) /*------------------------------------------------------------------------- + * Function: H5VL__get_plugin_cb + * + * Purpose: Callback routine to search through registered VLs + * + * Return: Success: The first object in the type for which FUNC + * returns non-zero. NULL if FUNC returned zero + * for every object in the type. + * Failure: NULL + * + * Programmer: Quincey Koziol + * Friday, March 30, 2012 + * + *------------------------------------------------------------------------- + */ +static int +H5VL__get_plugin_cb(void *obj, hid_t id, void *_op_data) +{ + H5VL_get_plugin_ud_t *op_data = (H5VL_get_plugin_ud_t *)_op_data; /* User data for callback */ + H5VL_class_t *cls = (H5VL_class_t *)obj; + int ret_value = H5_ITER_CONT; /* Callback return value */ + + FUNC_ENTER_STATIC_NOERR + + if(0 == strcmp(cls->name, op_data->name)) { + op_data->ret_id = id; + ret_value = H5_ITER_STOP; + } + + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5VL__get_plugin_cb() */ + + +/*------------------------------------------------------------------------- * Function: H5VLregister * * Purpose: Registers a new vol plugin as a member of the virtual object @@ -240,7 +274,7 @@ H5VLregister(const H5VL_class_t *cls) /* MSC - check if required callback are defined?? */ /* Create the new class ID */ - if((ret_value=H5VL_register(cls, sizeof(H5VL_class_t), TRUE)) < 0) + if((ret_value = H5VL_register(cls, sizeof(H5VL_class_t), TRUE)) < 0) HGOTO_ERROR(H5E_ATOM, H5E_CANTREGISTER, FAIL, "unable to register vol plugin ID") done: @@ -249,6 +283,66 @@ done: /*------------------------------------------------------------------------- + * Function: H5VLregister_by_name + * + * Purpose: Registers a new vol plugin as a member of the virtual object + * layer class. + * + * Return: Success: A vol plugin ID which is good until the + * library is closed or the plugin is + * unregistered. + * + * Failure: A negative value. + * + * Programmer: Mohamad Chaarawi + * September, 2014 + * + *------------------------------------------------------------------------- + */ +hid_t +H5VLregister_by_name(const char *name) +{ + H5VL_get_plugin_ud_t op_data; + hid_t ret_value; + + FUNC_ENTER_API(FAIL) + H5TRACE1("i", "*s", name); + + /* Check arguments */ + if(!name) + HGOTO_ERROR(H5E_ARGS, H5E_UNINITIALIZED, FAIL, "null plugin name is disallowed") + + op_data.ret_id = FAIL; + op_data.name = name; + + /* check if plugin is already registered */ + if(H5I_iterate(H5I_VOL, H5VL__get_plugin_cb, &op_data, TRUE) < 0) + HGOTO_ERROR(H5E_VOL, H5E_BADITER,FAIL, "can't iterate over VOL ids") + + if(op_data.ret_id != FAIL) { + /* If plugin alread registered, increment ref count on ID and return ID */ + if(H5I_inc_ref(op_data.ret_id, TRUE) < 0) + HGOTO_ERROR(H5E_VOL, H5E_CANTINC, FAIL, "unable to increment ref count on VOL plugin") + ret_value = op_data.ret_id; + } + else { + const H5VL_class_t *cls; + + /* Try loading the plugin */ + if(NULL == (cls = (const H5VL_class_t *)H5PL_load(H5PL_TYPE_VOL, -1, name))) + HGOTO_ERROR(H5E_VOL, H5E_CANTINIT, FAIL, "unable to load VOL plugin") + + /* Register the plugin we loaded */ + if((ret_value = H5VL_register(cls, sizeof(H5VL_class_t), TRUE)) < 0) + HGOTO_ERROR(H5E_ATOM, H5E_CANTREGISTER, FAIL, "unable to register vol plugin ID") + } + +done: + FUNC_LEAVE_API(ret_value) +} /* end H5VLregister() */ + + +/*------------------------------------------------------------------------- * Function: H5VLunregister * * Purpose: Removes a vol plugin ID from the library. This in no way affects @@ -353,39 +447,6 @@ done: /*------------------------------------------------------------------------- - * Function: H5VL__is_registered_cb - * - * Purpose: Callback routine to search through registered VLs - * - * Return: Success: The first object in the type for which FUNC - * returns non-zero. NULL if FUNC returned zero - * for every object in the type. - * Failure: NULL - * - * Programmer: Quincey Koziol - * Friday, March 30, 2012 - * - *------------------------------------------------------------------------- - */ -static int -H5VL__get_plugin_cb(void *obj, hid_t id, void *_op_data) -{ - H5VL_get_plugin_ud_t *op_data = (H5VL_get_plugin_ud_t *)_op_data; /* User data for callback */ - H5VL_class_t *cls = (H5VL_class_t *)obj; - int ret_value = H5_ITER_CONT; /* Callback return value */ - - FUNC_ENTER_STATIC_NOERR - - if(0 == strcmp(cls->name, op_data->name)) { - op_data->ret_id = id; - ret_value = H5_ITER_STOP; - } - - FUNC_LEAVE_NOAPI(ret_value) -} /* end H5VL__get_plugin_cb() */ - - -/*------------------------------------------------------------------------- * Function: H5VLis_registered * * Purpose: Tests whether a VOL class has been registered or not diff --git a/src/H5VLpublic.h b/src/H5VLpublic.h index 35c4c46..bf3517c 100644 --- a/src/H5VLpublic.h +++ b/src/H5VLpublic.h @@ -420,13 +420,13 @@ H5_DLL herr_t H5VLterminate(hid_t plugin_id, hid_t vtpl_id); H5_DLL hid_t H5VLget_plugin_id(const char *name); H5_DLL herr_t H5VLclose(hid_t plugin_id); H5_DLL hid_t H5VLregister(const H5VL_class_t *cls); +H5_DLL hid_t H5VLregister_by_name(const char *plugin_name); H5_DLL herr_t H5VLunregister(hid_t plugin_id); H5_DLL htri_t H5VLis_registered(const char *name); H5_DLL ssize_t H5VLget_plugin_name(hid_t id, char *name/*out*/, size_t size); H5_DLL hid_t H5VLobject_register(void *obj, H5I_type_t obj_type, hid_t plugin_id); H5_DLL herr_t H5VLget_object(hid_t obj_id, void **obj); #if 0 -H5_DLL hid_t H5VLregister_by_name(const char *plugin_name); H5_DLL herr_t H5VLioctl(hid_t loc_id or vol_id, , ...); #endif diff --git a/src/H5Z.c b/src/H5Z.c index f1a385a..bc5f290 100644 --- a/src/H5Z.c +++ b/src/H5Z.c @@ -668,8 +668,8 @@ H5Zfilter_avail(H5Z_filter_t id) else if(ret_value == FALSE) { const H5Z_class2_t *filter_info; - if(NULL != (filter_info = (const H5Z_class2_t *)H5PL_load(H5PL_TYPE_FILTER, (int)id))) - ret_value = TRUE; + if(NULL != (filter_info = (const H5Z_class2_t *)H5PL_load(H5PL_TYPE_FILTER, (int)id, NULL))) + ret_value = TRUE; } /* end if */ done: @@ -1330,20 +1330,20 @@ H5Z_pipeline(const H5O_pline_t *pline, unsigned flags, */ if((fclass_idx = H5Z_find_idx(pline->filter[idx].id)) < 0) { hbool_t issue_error = FALSE; - const H5Z_class2_t *filter_info; - - /* Try loading the filter */ - if(NULL != (filter_info = (const H5Z_class2_t *)H5PL_load(H5PL_TYPE_FILTER, (int)(pline->filter[idx].id)))) { - /* Register the filter we loaded */ - if(H5Z_register(filter_info) < 0) - HGOTO_ERROR(H5E_PLINE, H5E_CANTINIT, FAIL, "unable to register filter") - - /* Search in the table of registered filters again to find the dynamic filter just loaded and registered */ - if((fclass_idx = H5Z_find_idx(pline->filter[idx].id)) < 0) - issue_error = TRUE; - } /* end if */ - else - issue_error = TRUE; + const H5Z_class2_t *filter_info; + + /* Try loading the filter */ + if(NULL != (filter_info = (const H5Z_class2_t *)H5PL_load(H5PL_TYPE_FILTER, (int)(pline->filter[idx].id), NULL))) { + /* Register the filter we loaded */ + if(H5Z_register(filter_info) < 0) + HGOTO_ERROR(H5E_PLINE, H5E_CANTINIT, FAIL, "unable to register filter") + + /* Search in the table of registered filters again to find the dynamic filter just loaded and registered */ + if((fclass_idx = H5Z_find_idx(pline->filter[idx].id)) < 0) + issue_error = TRUE; + } /* end if */ + else + issue_error = TRUE; /* Check for error */ if(issue_error) { diff --git a/test/Makefile.am b/test/Makefile.am index b5ebcf3..6d5e5ce 100644 --- a/test/Makefile.am +++ b/test/Makefile.am @@ -28,7 +28,9 @@ TEST_SCRIPT = testerror.sh testlibinfo.sh testcheck_version.sh testlinks_env.sh SCRIPT_DEPEND = error_test$(EXEEXT) err_compat$(EXEEXT) links_env$(EXEEXT) if HAVE_SHARED_CONDITIONAL TEST_SCRIPT += test_plugin.sh + TEST_SCRIPT += test_vol_plugin.sh SCRIPT_DEPEND += plugin$(EXEEXT) + SCRIPT_DEPEND += vol_test$(EXEEXT) endif check_SCRIPTS = $(TEST_SCRIPT) @@ -57,6 +59,7 @@ TEST_PROG= testhdf5 lheap ohdr stab gheap cache cache_api cache_tagging \ check_PROGRAMS=$(TEST_PROG) error_test err_compat tcheck_version testmeta links_env if HAVE_SHARED_CONDITIONAL check_PROGRAMS+= plugin + check_PROGRAMS+= vol_test endif # These programs generate test files for the tests. They don't need to be @@ -81,10 +84,13 @@ if HAVE_SHARED_CONDITIONAL # The libdynlib1 and libdynlib2 library for testing plugin module plugin.c. # Build it as shared library if configure is enabled for shared library. - lib_LTLIBRARIES=libdynlib1.la libdynlib2.la libdynlib3.la + lib_LTLIBRARIES=libdynlib1.la libdynlib2.la libdynlib3.la libdynlibvol1.la libdynlibvol2.la libdynlib1_la_SOURCES=dynlib1.c libdynlib2_la_SOURCES=dynlib2.c libdynlib3_la_SOURCES=dynlib3.c + libdynlibvol1_la_SOURCES=dynlibvol1.c + libdynlibvol2_la_SOURCES=dynlibvol2.c + install-exec-hook: $(RM) $(DESTDIR)$(libdir)/*dynlib* @@ -142,6 +148,7 @@ CHECK_CLEANFILES+=accum.h5 cmpd_dset.h5 compact_dataset.h5 dataset.h5 dset_offse tmisc[0-9]*.h5 set_extent[1-5].h5 ext[12].bin \ getname.h5 getname[1-3].h5 sec2_file.h5 direct_file.h5 \ family_file000[0-3][0-9].h5 new_family_v16_000[0-3][0-9].h5 \ + log_file1.h5 log_file2.h5 \ multi_file-[rs].h5 core_file plugin.h5 \ new_move_[ab].h5 ntypes.h5 dangle.h5 error_test.h5 err_compat.h5 \ dtransform.h5 test_filters.h5 get_file_name.h5 tstint[1-2].h5 \ @@ -159,6 +166,6 @@ testhdf5_SOURCES=testhdf5.c tarray.c tattr.c tchecksum.c tconfig.c tfile.c \ tvlstr.c tvltypes.c # Temporary files. -DISTCLEANFILES=testerror.sh testlibinfo.sh testcheck_version.sh testlinks_env.sh test_plugin.sh +DISTCLEANFILES=testerror.sh testlibinfo.sh testcheck_version.sh testlinks_env.sh test_plugin.sh test_vol_plugin.sh include $(top_srcdir)/config/conclude.am diff --git a/test/Makefile.in b/test/Makefile.in index 2a43aaf..8723a03 100644 --- a/test/Makefile.in +++ b/test/Makefile.in @@ -102,14 +102,16 @@ DIST_COMMON = $(top_srcdir)/config/commence.am \ $(srcdir)/testcheck_version.sh.in $(srcdir)/testerror.sh.in \ $(srcdir)/H5srcdir_str.h.in $(srcdir)/testlibinfo.sh.in \ $(srcdir)/testlinks_env.sh.in $(srcdir)/test_plugin.sh.in \ - $(top_srcdir)/bin/depcomp $(top_srcdir)/bin/test-driver \ - COPYING -@HAVE_SHARED_CONDITIONAL_TRUE@am__append_1 = test_plugin.sh -@HAVE_SHARED_CONDITIONAL_TRUE@am__append_2 = plugin$(EXEEXT) + $(srcdir)/test_vol_plugin.sh.in $(top_srcdir)/bin/depcomp \ + $(top_srcdir)/bin/test-driver COPYING +@HAVE_SHARED_CONDITIONAL_TRUE@am__append_1 = test_plugin.sh \ +@HAVE_SHARED_CONDITIONAL_TRUE@ test_vol_plugin.sh +@HAVE_SHARED_CONDITIONAL_TRUE@am__append_2 = plugin$(EXEEXT) \ +@HAVE_SHARED_CONDITIONAL_TRUE@ vol_test$(EXEEXT) check_PROGRAMS = $(am__EXEEXT_1) error_test$(EXEEXT) \ err_compat$(EXEEXT) tcheck_version$(EXEEXT) testmeta$(EXEEXT) \ links_env$(EXEEXT) $(am__EXEEXT_2) -@HAVE_SHARED_CONDITIONAL_TRUE@am__append_3 = plugin +@HAVE_SHARED_CONDITIONAL_TRUE@am__append_3 = plugin vol_test @BUILD_ALL_CONDITIONAL_TRUE@noinst_PROGRAMS = $(am__EXEEXT_3) @DIRECT_VFD_CONDITIONAL_TRUE@am__append_4 = direct TESTS = $(am__EXEEXT_1) $(TEST_SCRIPT) @@ -121,7 +123,8 @@ am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \ mkinstalldirs = $(SHELL) $(top_srcdir)/bin/mkinstalldirs CONFIG_HEADER = $(top_builddir)/src/H5config.h CONFIG_CLEAN_FILES = testcheck_version.sh testerror.sh H5srcdir_str.h \ - testlibinfo.sh testlinks_env.sh test_plugin.sh + testlibinfo.sh testlinks_env.sh test_plugin.sh \ + test_vol_plugin.sh CONFIG_CLEAN_VPATH_FILES = am__vpath_adj_setup = srcdirstrip=`echo "$(srcdir)" | sed 's|.|.|g'`; am__vpath_adj = case $$p in \ @@ -174,6 +177,20 @@ am__libdynlib3_la_SOURCES_DIST = dynlib3.c libdynlib3_la_OBJECTS = $(am_libdynlib3_la_OBJECTS) @HAVE_SHARED_CONDITIONAL_TRUE@am_libdynlib3_la_rpath = -rpath \ @HAVE_SHARED_CONDITIONAL_TRUE@ $(libdir) +libdynlibvol1_la_LIBADD = +am__libdynlibvol1_la_SOURCES_DIST = dynlibvol1.c +@HAVE_SHARED_CONDITIONAL_TRUE@am_libdynlibvol1_la_OBJECTS = \ +@HAVE_SHARED_CONDITIONAL_TRUE@ dynlibvol1.lo +libdynlibvol1_la_OBJECTS = $(am_libdynlibvol1_la_OBJECTS) +@HAVE_SHARED_CONDITIONAL_TRUE@am_libdynlibvol1_la_rpath = -rpath \ +@HAVE_SHARED_CONDITIONAL_TRUE@ $(libdir) +libdynlibvol2_la_LIBADD = +am__libdynlibvol2_la_SOURCES_DIST = dynlibvol2.c +@HAVE_SHARED_CONDITIONAL_TRUE@am_libdynlibvol2_la_OBJECTS = \ +@HAVE_SHARED_CONDITIONAL_TRUE@ dynlibvol2.lo +libdynlibvol2_la_OBJECTS = $(am_libdynlibvol2_la_OBJECTS) +@HAVE_SHARED_CONDITIONAL_TRUE@am_libdynlibvol2_la_rpath = -rpath \ +@HAVE_SHARED_CONDITIONAL_TRUE@ $(libdir) libh5test_la_LIBADD = am_libh5test_la_OBJECTS = h5test.lo testframe.lo cache_common.lo libh5test_la_OBJECTS = $(am_libh5test_la_OBJECTS) @@ -196,7 +213,8 @@ am__EXEEXT_1 = testhdf5$(EXEEXT) lheap$(EXEEXT) ohdr$(EXEEXT) \ freespace$(EXEEXT) mf$(EXEEXT) farray$(EXEEXT) earray$(EXEEXT) \ btree2$(EXEEXT) fheap$(EXEEXT) file_image$(EXEEXT) \ unregister$(EXEEXT) -@HAVE_SHARED_CONDITIONAL_TRUE@am__EXEEXT_2 = plugin$(EXEEXT) +@HAVE_SHARED_CONDITIONAL_TRUE@am__EXEEXT_2 = plugin$(EXEEXT) \ +@HAVE_SHARED_CONDITIONAL_TRUE@ vol_test$(EXEEXT) am__EXEEXT_3 = gen_bad_ohdr$(EXEEXT) gen_bogus$(EXEEXT) \ gen_cross$(EXEEXT) gen_deflate$(EXEEXT) gen_filters$(EXEEXT) \ gen_new_array$(EXEEXT) gen_new_fill$(EXEEXT) \ @@ -522,6 +540,10 @@ vfd_SOURCES = vfd.c vfd_OBJECTS = vfd.$(OBJEXT) vfd_LDADD = $(LDADD) vfd_DEPENDENCIES = libh5test.la $(LIBHDF5) +vol_test_SOURCES = vol_test.c +vol_test_OBJECTS = vol_test.$(OBJEXT) +vol_test_LDADD = $(LDADD) +vol_test_DEPENDENCIES = libh5test.la $(LIBHDF5) AM_V_P = $(am__v_P_@AM_V@) am__v_P_ = $(am__v_P_@AM_DEFAULT_V@) am__v_P_0 = false @@ -557,7 +579,8 @@ am__v_CCLD_ = $(am__v_CCLD_@AM_DEFAULT_V@) am__v_CCLD_0 = @echo " CCLD " $@; am__v_CCLD_1 = SOURCES = $(libdynlib1_la_SOURCES) $(libdynlib2_la_SOURCES) \ - $(libdynlib3_la_SOURCES) $(libh5test_la_SOURCES) accum.c \ + $(libdynlib3_la_SOURCES) $(libdynlibvol1_la_SOURCES) \ + $(libdynlibvol2_la_SOURCES) $(libh5test_la_SOURCES) accum.c \ app_ref.c big.c bittests.c btree2.c cache.c cache_api.c \ cache_tagging.c cmpd_dset.c cross_read.c dangle.c dsets.c \ dt_arith.c dtransform.c dtypes.c earray.c efc.c \ @@ -573,10 +596,12 @@ SOURCES = $(libdynlib1_la_SOURCES) $(libdynlib2_la_SOURCES) \ mount.c mtime.c ntypes.c objcopy.c ohdr.c plugin.c pool.c \ reserved.c set_extent.c space_overflow.c stab.c \ tcheck_version.c $(testhdf5_SOURCES) testmeta.c \ - $(ttsafe_SOURCES) unlink.c unregister.c vfd.c + $(ttsafe_SOURCES) unlink.c unregister.c vfd.c vol_test.c DIST_SOURCES = $(am__libdynlib1_la_SOURCES_DIST) \ $(am__libdynlib2_la_SOURCES_DIST) \ - $(am__libdynlib3_la_SOURCES_DIST) $(libh5test_la_SOURCES) \ + $(am__libdynlib3_la_SOURCES_DIST) \ + $(am__libdynlibvol1_la_SOURCES_DIST) \ + $(am__libdynlibvol2_la_SOURCES_DIST) $(libh5test_la_SOURCES) \ accum.c app_ref.c big.c bittests.c btree2.c cache.c \ cache_api.c cache_tagging.c cmpd_dset.c cross_read.c dangle.c \ dsets.c dt_arith.c dtransform.c dtypes.c earray.c efc.c \ @@ -592,7 +617,7 @@ DIST_SOURCES = $(am__libdynlib1_la_SOURCES_DIST) \ mount.c mtime.c ntypes.c objcopy.c ohdr.c plugin.c pool.c \ reserved.c set_extent.c space_overflow.c stab.c \ tcheck_version.c $(testhdf5_SOURCES) testmeta.c \ - $(ttsafe_SOURCES) unlink.c unregister.c vfd.c + $(ttsafe_SOURCES) unlink.c unregister.c vfd.c vol_test.c am__can_run_installinfo = \ case $$AM_UPDATE_INFO_DIR in \ n|no|NO) false;; \ @@ -1093,15 +1118,16 @@ CHECK_CLEANFILES = *.chkexe *.chklog *.clog accum.h5 cmpd_dset.h5 \ tmisc[0-9]*.h5 set_extent[1-5].h5 ext[12].bin getname.h5 \ getname[1-3].h5 sec2_file.h5 direct_file.h5 \ family_file000[0-3][0-9].h5 new_family_v16_000[0-3][0-9].h5 \ - multi_file-[rs].h5 core_file plugin.h5 new_move_[ab].h5 \ - ntypes.h5 dangle.h5 error_test.h5 err_compat.h5 dtransform.h5 \ - test_filters.h5 get_file_name.h5 tstint[1-2].h5 \ - unlink_chunked.h5 btree2.h5 objcopy_src.h5 objcopy_dst.h5 \ - objcopy_ext.dat trefer1.h5 trefer2.h5 app_ref.h5 farray.h5 \ - earray.h5 efc[0-5].h5 log_vfd_out.log new_multi_file_v16-r.h5 \ - new_multi_file_v16-s.h5 split_get_file_image_test-m.h5 \ - split_get_file_image_test-r.h5 file_image_core_test.h5.copy \ - unregister_filter_1.h5 unregister_filter_2.h5 + log_file1.h5 log_file2.h5 multi_file-[rs].h5 core_file \ + plugin.h5 new_move_[ab].h5 ntypes.h5 dangle.h5 error_test.h5 \ + err_compat.h5 dtransform.h5 test_filters.h5 get_file_name.h5 \ + tstint[1-2].h5 unlink_chunked.h5 btree2.h5 objcopy_src.h5 \ + objcopy_dst.h5 objcopy_ext.dat trefer1.h5 trefer2.h5 \ + app_ref.h5 farray.h5 earray.h5 efc[0-5].h5 log_vfd_out.log \ + new_multi_file_v16-r.h5 new_multi_file_v16-s.h5 \ + split_get_file_image_test-m.h5 split_get_file_image_test-r.h5 \ + file_image_core_test.h5.copy unregister_filter_1.h5 \ + unregister_filter_2.h5 # Test script for error_test and err_compat TEST_SCRIPT = testerror.sh testlibinfo.sh testcheck_version.sh \ @@ -1140,10 +1166,12 @@ BUILD_ALL_PROGS = gen_bad_ohdr gen_bogus gen_cross gen_deflate gen_filters gen_n @HAVE_SHARED_CONDITIONAL_FALSE@noinst_LTLIBRARIES = libh5test.la @HAVE_SHARED_CONDITIONAL_TRUE@noinst_LTLIBRARIES = libh5test.la -@HAVE_SHARED_CONDITIONAL_TRUE@lib_LTLIBRARIES = libdynlib1.la libdynlib2.la libdynlib3.la +@HAVE_SHARED_CONDITIONAL_TRUE@lib_LTLIBRARIES = libdynlib1.la libdynlib2.la libdynlib3.la libdynlibvol1.la libdynlibvol2.la @HAVE_SHARED_CONDITIONAL_TRUE@libdynlib1_la_SOURCES = dynlib1.c @HAVE_SHARED_CONDITIONAL_TRUE@libdynlib2_la_SOURCES = dynlib2.c @HAVE_SHARED_CONDITIONAL_TRUE@libdynlib3_la_SOURCES = dynlib3.c +@HAVE_SHARED_CONDITIONAL_TRUE@libdynlibvol1_la_SOURCES = dynlibvol1.c +@HAVE_SHARED_CONDITIONAL_TRUE@libdynlibvol2_la_SOURCES = dynlibvol2.c libh5test_la_SOURCES = h5test.c testframe.c cache_common.c # Use libhd5test.la to compile all of the tests @@ -1164,7 +1192,7 @@ testhdf5_SOURCES = testhdf5.c tarray.c tattr.c tchecksum.c tconfig.c tfile.c \ # Temporary files. -DISTCLEANFILES = testerror.sh testlibinfo.sh testcheck_version.sh testlinks_env.sh test_plugin.sh +DISTCLEANFILES = testerror.sh testlibinfo.sh testcheck_version.sh testlinks_env.sh test_plugin.sh test_vol_plugin.sh # Automake needs to be taught how to build lib, progs, and tests targets. # These will be filled in automatically for the most part (e.g., @@ -1232,6 +1260,8 @@ testlinks_env.sh: $(top_builddir)/config.status $(srcdir)/testlinks_env.sh.in cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ test_plugin.sh: $(top_builddir)/config.status $(srcdir)/test_plugin.sh.in cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ +test_vol_plugin.sh: $(top_builddir)/config.status $(srcdir)/test_vol_plugin.sh.in + cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ install-libLTLIBRARIES: $(lib_LTLIBRARIES) @$(NORMAL_INSTALL) @@ -1288,6 +1318,12 @@ libdynlib2.la: $(libdynlib2_la_OBJECTS) $(libdynlib2_la_DEPENDENCIES) $(EXTRA_li libdynlib3.la: $(libdynlib3_la_OBJECTS) $(libdynlib3_la_DEPENDENCIES) $(EXTRA_libdynlib3_la_DEPENDENCIES) $(AM_V_CCLD)$(LINK) $(am_libdynlib3_la_rpath) $(libdynlib3_la_OBJECTS) $(libdynlib3_la_LIBADD) $(LIBS) +libdynlibvol1.la: $(libdynlibvol1_la_OBJECTS) $(libdynlibvol1_la_DEPENDENCIES) $(EXTRA_libdynlibvol1_la_DEPENDENCIES) + $(AM_V_CCLD)$(LINK) $(am_libdynlibvol1_la_rpath) $(libdynlibvol1_la_OBJECTS) $(libdynlibvol1_la_LIBADD) $(LIBS) + +libdynlibvol2.la: $(libdynlibvol2_la_OBJECTS) $(libdynlibvol2_la_DEPENDENCIES) $(EXTRA_libdynlibvol2_la_DEPENDENCIES) + $(AM_V_CCLD)$(LINK) $(am_libdynlibvol2_la_rpath) $(libdynlibvol2_la_OBJECTS) $(libdynlibvol2_la_LIBADD) $(LIBS) + libh5test.la: $(libh5test_la_OBJECTS) $(libh5test_la_DEPENDENCIES) $(EXTRA_libh5test_la_DEPENDENCIES) $(AM_V_CCLD)$(LINK) $(am_libh5test_la_rpath) $(libh5test_la_OBJECTS) $(libh5test_la_LIBADD) $(LIBS) @@ -1613,6 +1649,10 @@ vfd$(EXEEXT): $(vfd_OBJECTS) $(vfd_DEPENDENCIES) $(EXTRA_vfd_DEPENDENCIES) @rm -f vfd$(EXEEXT) $(AM_V_CCLD)$(LINK) $(vfd_OBJECTS) $(vfd_LDADD) $(LIBS) +vol_test$(EXEEXT): $(vol_test_OBJECTS) $(vol_test_DEPENDENCIES) $(EXTRA_vol_test_DEPENDENCIES) + @rm -f vol_test$(EXEEXT) + $(AM_V_CCLD)$(LINK) $(vol_test_OBJECTS) $(vol_test_LDADD) $(LIBS) + mostlyclean-compile: -rm -f *.$(OBJEXT) @@ -1638,6 +1678,8 @@ distclean-compile: @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/dynlib1.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/dynlib2.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/dynlib3.Plo@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/dynlibvol1.Plo@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/dynlibvol2.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/earray.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/efc.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/enc_dec_plist.Po@am__quote@ @@ -1729,6 +1771,7 @@ distclean-compile: @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/unlink.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/unregister.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/vfd.Po@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/vol_test.Po@am__quote@ .c.o: @am__fastdepCC_TRUE@ $(AM_V_CC)$(COMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ $< diff --git a/test/dynlibvol1.c b/test/dynlibvol1.c new file mode 100644 index 0000000..1f8ae0e --- /dev/null +++ b/test/dynlibvol1.c @@ -0,0 +1,366 @@ + +#include +#include +#include +#include "H5PLextern.h" +#include "hdf5.h" + +#define LOG 501 + +static herr_t H5VL_log_init(hid_t vipl_id); +static herr_t H5VL_log_term(hid_t vtpl_id); + +/* Datatype callbacks */ +static void *H5VL_log_datatype_commit(void *obj, H5VL_loc_params_t loc_params, const char *name, hid_t type_id, hid_t lcpl_id, hid_t tcpl_id, hid_t tapl_id, hid_t dxpl_id, void **req); +static void *H5VL_log_datatype_open(void *obj, H5VL_loc_params_t loc_params, const char *name, hid_t tapl_id, hid_t dxpl_id, void **req); +static herr_t H5VL_log_datatype_get(void *dt, H5VL_datatype_get_t get_type, hid_t dxpl_id, void **req, va_list arguments); +static herr_t H5VL_log_datatype_close(void *dt, hid_t dxpl_id, void **req); + +/* Dataset callbacks */ +static void *H5VL_log_dataset_create(void *obj, H5VL_loc_params_t loc_params, const char *name, hid_t dcpl_id, hid_t dapl_id, hid_t dxpl_id, void **req); +static void *H5VL_log_dataset_open(void *obj, H5VL_loc_params_t loc_params, const char *name, hid_t dapl_id, hid_t dxpl_id, void **req); +static herr_t H5VL_log_dataset_read(void *dset, hid_t mem_type_id, hid_t mem_space_id, + hid_t file_space_id, hid_t plist_id, void *buf, void **req); +static herr_t H5VL_log_dataset_write(void *dset, hid_t mem_type_id, hid_t mem_space_id, + hid_t file_space_id, hid_t plist_id, const void *buf, void **req); +static herr_t H5VL_log_dataset_close(void *dset, hid_t dxpl_id, void **req); + +/* File callbacks */ +static void *H5VL_log_file_create(const char *name, unsigned flags, hid_t fcpl_id, hid_t fapl_id, hid_t dxpl_id, void **req); +static void *H5VL_log_file_open(const char *name, unsigned flags, hid_t fapl_id, hid_t dxpl_id, void **req); +static herr_t H5VL_log_file_get(void *file, H5VL_file_get_t get_type, hid_t dxpl_id, void **req, va_list arguments); +static herr_t H5VL_log_file_close(void *file, hid_t dxpl_id, void **req); + +/* Group callbacks */ +static void *H5VL_log_group_create(void *obj, H5VL_loc_params_t loc_params, const char *name, hid_t gcpl_id, hid_t gapl_id, hid_t dxpl_id, void **req); +static herr_t H5VL_log_group_close(void *grp, hid_t dxpl_id, void **req); + +/* Link callbacks */ + +/* Object callbacks */ +static void *H5VL_log_object_open(void *obj, H5VL_loc_params_t loc_params, H5I_type_t *opened_type, hid_t dxpl_id, void **req); +static herr_t H5VL_log_object_specific(void *obj, H5VL_loc_params_t loc_params, H5VL_object_specific_t specific_type, hid_t dxpl_id, void **req, va_list arguments); + +hid_t native_plugin_id = -1; + +static const H5VL_class_t H5VL_log1_g = { + 0, + LOG, + "log1", /* name */ + H5VL_log_init, /* initialize */ + H5VL_log_term, /* terminate */ + sizeof(hid_t), + NULL, + NULL, + { /* attribute_cls */ + NULL, //H5VL_log_attr_create, /* create */ + NULL, //H5VL_log_attr_open, /* open */ + NULL, //H5VL_log_attr_read, /* read */ + NULL, //H5VL_log_attr_write, /* write */ + NULL, //H5VL_log_attr_get, /* get */ + NULL, //H5VL_log_attr_specific, /* specific */ + NULL, //H5VL_log_attr_optional, /* optional */ + NULL //H5VL_log_attr_close /* close */ + }, + { /* dataset_cls */ + H5VL_log_dataset_create, /* create */ + H5VL_log_dataset_open, /* open */ + H5VL_log_dataset_read, /* read */ + H5VL_log_dataset_write, /* write */ + NULL, //H5VL_log_dataset_get, /* get */ + NULL, //H5VL_log_dataset_specific, /* specific */ + NULL, //H5VL_log_dataset_optional, /* optional */ + H5VL_log_dataset_close /* close */ + }, + { /* datatype_cls */ + H5VL_log_datatype_commit, /* commit */ + H5VL_log_datatype_open, /* open */ + H5VL_log_datatype_get, /* get_size */ + NULL, //H5VL_log_datatype_specific, /* specific */ + NULL, //H5VL_log_datatype_optional, /* optional */ + H5VL_log_datatype_close /* close */ + }, + { /* file_cls */ + H5VL_log_file_create, /* create */ + H5VL_log_file_open, /* open */ + H5VL_log_file_get, /* get */ + NULL, //H5VL_log_file_specific, /* specific */ + NULL, //H5VL_log_file_optional, /* optional */ + H5VL_log_file_close /* close */ + }, + { /* group_cls */ + H5VL_log_group_create, /* create */ + NULL, //H5VL_log_group_open, /* open */ + NULL, //H5VL_log_group_get, /* get */ + NULL, //H5VL_log_group_specific, /* specific */ + NULL, //H5VL_log_group_optional, /* optional */ + H5VL_log_group_close /* close */ + }, + { /* link_cls */ + NULL, //H5VL_log_link_create, /* create */ + NULL, //H5VL_log_link_copy, /* copy */ + NULL, //H5VL_log_link_move, /* move */ + NULL, //H5VL_log_link_get, /* get */ + NULL, //H5VL_log_link_specific, /* specific */ + NULL, //H5VL_log_link_optional, /* optional */ + }, + { /* object_cls */ + H5VL_log_object_open, /* open */ + NULL, //H5VL_log_object_copy, /* copy */ + NULL, //H5VL_log_object_get, /* get */ + H5VL_log_object_specific, /* specific */ + NULL, //H5VL_log_object_optional, /* optional */ + }, + { + NULL, + NULL, + NULL + }, + NULL +}; + +typedef struct H5VL_log_t { + void *under_object; +} H5VL_log_t; + +H5PL_type_t H5PLget_plugin_type(void) {return H5PL_TYPE_VOL;} +const void *H5PLget_plugin_info(void) {return &H5VL_log1_g;} + +static herr_t H5VL_log_init(hid_t vipl_id) +{ + printf("------- LOG INIT\n"); + return 0; +} + +static herr_t H5VL_log_term(hid_t vtpl_id) +{ + printf("------- LOG TERM\n"); + return 0; +} + +static void * +H5VL_log_file_create(const char *name, unsigned flags, hid_t fcpl_id, hid_t fapl_id, hid_t dxpl_id, void **req) +{ + hid_t under_fapl; + H5VL_log_t *file; + + native_plugin_id = H5VLget_plugin_id("native"); + assert(native_plugin_id > 0); + + file = (H5VL_log_t *)calloc(1, sizeof(H5VL_log_t)); + + under_fapl = *((hid_t *)H5Pget_vol_info(fapl_id)); + file->under_object = H5VLfile_create(name, flags, fcpl_id, under_fapl, dxpl_id, req); + + printf("------- LOG H5Fcreate\n"); + return (void *)file; +} + +static void * +H5VL_log_file_open(const char *name, unsigned flags, hid_t fapl_id, hid_t dxpl_id, void **req) +{ + hid_t under_fapl; + H5VL_log_t *file; + + file = (H5VL_log_t *)calloc(1, sizeof(H5VL_log_t)); + + under_fapl = *((hid_t *)H5Pget_vol_info(fapl_id)); + file->under_object = H5VLfile_open(name, flags, under_fapl, dxpl_id, req); + + printf("------- LOG H5Fopen\n"); + return (void *)file; +} + +static herr_t +H5VL_log_file_get(void *file, H5VL_file_get_t get_type, hid_t dxpl_id, void **req, va_list arguments) +{ + H5VL_log_t *f = (H5VL_log_t *)file; + + H5VLfile_get(f->under_object, native_plugin_id, get_type, dxpl_id, req, arguments); + + printf("------- LOG H5Fget %d\n", get_type); + return 1; +} +static herr_t +H5VL_log_file_close(void *file, hid_t dxpl_id, void **req) +{ + H5VL_log_t *f = (H5VL_log_t *)file; + + H5VLfile_close(f->under_object, native_plugin_id, dxpl_id, req); + free(f); + + printf("------- LOG H5Fclose\n"); + return 1; +} + +static void * +H5VL_log_group_create(void *obj, H5VL_loc_params_t loc_params, const char *name, + hid_t gcpl_id, hid_t gapl_id, hid_t dxpl_id, void **req) +{ + H5VL_log_t *group; + H5VL_log_t *o = (H5VL_log_t *)obj; + + group = (H5VL_log_t *)calloc(1, sizeof(H5VL_log_t)); + + group->under_object = H5VLgroup_create(o->under_object, loc_params, native_plugin_id, name, gcpl_id, gapl_id, dxpl_id, req); + + printf("------- LOG H5Gcreate\n"); + return (void *)group; +} + +static herr_t +H5VL_log_group_close(void *grp, hid_t dxpl_id, void **req) +{ + H5VL_log_t *g = (H5VL_log_t *)grp; + + H5VLgroup_close(g->under_object, native_plugin_id, dxpl_id, req); + free(g); + + printf("------- LOG H5Gclose\n"); + return 1; +} + +static void * +H5VL_log_datatype_commit(void *obj, H5VL_loc_params_t loc_params, const char *name, + hid_t type_id, hid_t lcpl_id, hid_t tcpl_id, hid_t tapl_id, hid_t dxpl_id, void **req) +{ + H5VL_log_t *dt; + H5VL_log_t *o = (H5VL_log_t *)obj; + + dt = (H5VL_log_t *)calloc(1, sizeof(H5VL_log_t)); + + dt->under_object = H5VLdatatype_commit(o->under_object, loc_params, native_plugin_id, name, + type_id, lcpl_id, tcpl_id, tapl_id, dxpl_id, req); + + printf("------- LOG H5Tcommit\n"); + return dt; +} +static void * +H5VL_log_datatype_open(void *obj, H5VL_loc_params_t loc_params, const char *name, hid_t tapl_id, hid_t dxpl_id, void **req) +{ + H5VL_log_t *dt; + H5VL_log_t *o = (H5VL_log_t *)obj; + + dt = (H5VL_log_t *)calloc(1, sizeof(H5VL_log_t)); + + dt->under_object = H5VLdatatype_open(o->under_object, loc_params, native_plugin_id, name, tapl_id, dxpl_id, req); + + printf("------- LOG H5Topen\n"); + return (void *)dt; +} + +static herr_t +H5VL_log_datatype_get(void *dt, H5VL_datatype_get_t get_type, hid_t dxpl_id, void **req, va_list arguments) +{ + H5VL_log_t *o = (H5VL_log_t *)dt; + herr_t ret_value; + + ret_value = H5VLdatatype_get(o->under_object, native_plugin_id, get_type, dxpl_id, req, arguments); + + printf("------- LOG datatype get\n"); + return ret_value; +} + +static herr_t +H5VL_log_datatype_close(void *dt, hid_t dxpl_id, void **req) +{ + H5VL_log_t *type = (H5VL_log_t *)dt; + + assert(type->under_object); + + H5VLdatatype_close(type->under_object, native_plugin_id, dxpl_id, req); + free(type); + + printf("------- LOG H5Tclose\n"); + return 1; +} + +static void * +H5VL_log_object_open(void *obj, H5VL_loc_params_t loc_params, H5I_type_t *opened_type, hid_t dxpl_id, void **req) +{ + H5VL_log_t *new_obj; + H5VL_log_t *o = (H5VL_log_t *)obj; + + new_obj = (H5VL_log_t *)calloc(1, sizeof(H5VL_log_t)); + + new_obj->under_object = H5VLobject_open(o->under_object, loc_params, native_plugin_id, opened_type, dxpl_id, req); + + printf("------- LOG H5Oopen\n"); + return (void *)new_obj; +} + +static herr_t +H5VL_log_object_specific(void *obj, H5VL_loc_params_t loc_params, H5VL_object_specific_t specific_type, + hid_t dxpl_id, void **req, va_list arguments) +{ + H5VL_log_t *o = (H5VL_log_t *)obj; + + H5VLobject_specific(o->under_object, loc_params, native_plugin_id, specific_type, dxpl_id, req, arguments); + + printf("------- LOG Object specific\n"); + return 1; +} + +static void * +H5VL_log_dataset_create(void *obj, H5VL_loc_params_t loc_params, const char *name, hid_t dcpl_id, hid_t dapl_id, hid_t dxpl_id, void **req) +{ + H5VL_log_t *dset; + H5VL_log_t *o = (H5VL_log_t *)obj; + + dset = (H5VL_log_t *)calloc(1, sizeof(H5VL_log_t)); + + dset->under_object = H5VLdataset_create(o->under_object, loc_params, native_plugin_id, name, dcpl_id, dapl_id, dxpl_id, req); + + printf("------- LOG H5Dcreate\n"); + return (void *)dset; +} + +static void * +H5VL_log_dataset_open(void *obj, H5VL_loc_params_t loc_params, const char *name, hid_t dapl_id, hid_t dxpl_id, void **req) +{ + H5VL_log_t *dset; + H5VL_log_t *o = (H5VL_log_t *)obj; + + dset = (H5VL_log_t *)calloc(1, sizeof(H5VL_log_t)); + + dset->under_object = H5VLdataset_open(o->under_object, loc_params, native_plugin_id, name, dapl_id, dxpl_id, req); + + printf("------- LOG H5Dopen\n"); + return (void *)dset; +} + +static herr_t +H5VL_log_dataset_read(void *dset, hid_t mem_type_id, hid_t mem_space_id, + hid_t file_space_id, hid_t plist_id, void *buf, void **req) +{ + H5VL_log_t *d = (H5VL_log_t *)dset; + + H5VLdataset_read(d->under_object, native_plugin_id, mem_type_id, mem_space_id, file_space_id, + plist_id, buf, req); + + printf("------- LOG H5Dread\n"); + return 1; +} +static herr_t +H5VL_log_dataset_write(void *dset, hid_t mem_type_id, hid_t mem_space_id, + hid_t file_space_id, hid_t plist_id, const void *buf, void **req) +{ + H5VL_log_t *d = (H5VL_log_t *)dset; + + H5VLdataset_write(d->under_object, native_plugin_id, mem_type_id, mem_space_id, file_space_id, + plist_id, buf, req); + + printf("------- LOG H5Dwrite\n"); + return 1; +} +static herr_t +H5VL_log_dataset_close(void *dset, hid_t dxpl_id, void **req) +{ + H5VL_log_t *d = (H5VL_log_t *)dset; + + H5VLdataset_close(d->under_object, native_plugin_id, dxpl_id, req); + free(d); + + printf("------- LOG H5Dclose\n"); + return 1; +} diff --git a/test/dynlibvol2.c b/test/dynlibvol2.c new file mode 100644 index 0000000..1877c21 --- /dev/null +++ b/test/dynlibvol2.c @@ -0,0 +1,366 @@ + +#include +#include +#include +#include "H5PLextern.h" +#include "hdf5.h" + +#define LOG 502 + +static herr_t H5VL_log_init(hid_t vipl_id); +static herr_t H5VL_log_term(hid_t vtpl_id); + +/* Datatype callbacks */ +static void *H5VL_log_datatype_commit(void *obj, H5VL_loc_params_t loc_params, const char *name, hid_t type_id, hid_t lcpl_id, hid_t tcpl_id, hid_t tapl_id, hid_t dxpl_id, void **req); +static void *H5VL_log_datatype_open(void *obj, H5VL_loc_params_t loc_params, const char *name, hid_t tapl_id, hid_t dxpl_id, void **req); +static herr_t H5VL_log_datatype_get(void *dt, H5VL_datatype_get_t get_type, hid_t dxpl_id, void **req, va_list arguments); +static herr_t H5VL_log_datatype_close(void *dt, hid_t dxpl_id, void **req); + +/* Dataset callbacks */ +static void *H5VL_log_dataset_create(void *obj, H5VL_loc_params_t loc_params, const char *name, hid_t dcpl_id, hid_t dapl_id, hid_t dxpl_id, void **req); +static void *H5VL_log_dataset_open(void *obj, H5VL_loc_params_t loc_params, const char *name, hid_t dapl_id, hid_t dxpl_id, void **req); +static herr_t H5VL_log_dataset_read(void *dset, hid_t mem_type_id, hid_t mem_space_id, + hid_t file_space_id, hid_t plist_id, void *buf, void **req); +static herr_t H5VL_log_dataset_write(void *dset, hid_t mem_type_id, hid_t mem_space_id, + hid_t file_space_id, hid_t plist_id, const void *buf, void **req); +static herr_t H5VL_log_dataset_close(void *dset, hid_t dxpl_id, void **req); + +/* File callbacks */ +static void *H5VL_log_file_create(const char *name, unsigned flags, hid_t fcpl_id, hid_t fapl_id, hid_t dxpl_id, void **req); +static void *H5VL_log_file_open(const char *name, unsigned flags, hid_t fapl_id, hid_t dxpl_id, void **req); +static herr_t H5VL_log_file_get(void *file, H5VL_file_get_t get_type, hid_t dxpl_id, void **req, va_list arguments); +static herr_t H5VL_log_file_close(void *file, hid_t dxpl_id, void **req); + +/* Group callbacks */ +static void *H5VL_log_group_create(void *obj, H5VL_loc_params_t loc_params, const char *name, hid_t gcpl_id, hid_t gapl_id, hid_t dxpl_id, void **req); +static herr_t H5VL_log_group_close(void *grp, hid_t dxpl_id, void **req); + +/* Link callbacks */ + +/* Object callbacks */ +static void *H5VL_log_object_open(void *obj, H5VL_loc_params_t loc_params, H5I_type_t *opened_type, hid_t dxpl_id, void **req); +static herr_t H5VL_log_object_specific(void *obj, H5VL_loc_params_t loc_params, H5VL_object_specific_t specific_type, hid_t dxpl_id, void **req, va_list arguments); + +hid_t native_plugin_id = -1; + +static const H5VL_class_t H5VL_log2_g = { + 0, + LOG, + "log2", /* name */ + H5VL_log_init, /* initialize */ + H5VL_log_term, /* terminate */ + sizeof(hid_t), + NULL, + NULL, + { /* attribute_cls */ + NULL, //H5VL_log_attr_create, /* create */ + NULL, //H5VL_log_attr_open, /* open */ + NULL, //H5VL_log_attr_read, /* read */ + NULL, //H5VL_log_attr_write, /* write */ + NULL, //H5VL_log_attr_get, /* get */ + NULL, //H5VL_log_attr_specific, /* specific */ + NULL, //H5VL_log_attr_optional, /* optional */ + NULL //H5VL_log_attr_close /* close */ + }, + { /* dataset_cls */ + H5VL_log_dataset_create, /* create */ + H5VL_log_dataset_open, /* open */ + H5VL_log_dataset_read, /* read */ + H5VL_log_dataset_write, /* write */ + NULL, //H5VL_log_dataset_get, /* get */ + NULL, //H5VL_log_dataset_specific, /* specific */ + NULL, //H5VL_log_dataset_optional, /* optional */ + H5VL_log_dataset_close /* close */ + }, + { /* datatype_cls */ + H5VL_log_datatype_commit, /* commit */ + H5VL_log_datatype_open, /* open */ + H5VL_log_datatype_get, /* get_size */ + NULL, //H5VL_log_datatype_specific, /* specific */ + NULL, //H5VL_log_datatype_optional, /* optional */ + H5VL_log_datatype_close /* close */ + }, + { /* file_cls */ + H5VL_log_file_create, /* create */ + H5VL_log_file_open, /* open */ + H5VL_log_file_get, /* get */ + NULL, //H5VL_log_file_specific, /* specific */ + NULL, //H5VL_log_file_optional, /* optional */ + H5VL_log_file_close /* close */ + }, + { /* group_cls */ + H5VL_log_group_create, /* create */ + NULL, //H5VL_log_group_open, /* open */ + NULL, //H5VL_log_group_get, /* get */ + NULL, //H5VL_log_group_specific, /* specific */ + NULL, //H5VL_log_group_optional, /* optional */ + H5VL_log_group_close /* close */ + }, + { /* link_cls */ + NULL, //H5VL_log_link_create, /* create */ + NULL, //H5VL_log_link_copy, /* copy */ + NULL, //H5VL_log_link_move, /* move */ + NULL, //H5VL_log_link_get, /* get */ + NULL, //H5VL_log_link_specific, /* specific */ + NULL, //H5VL_log_link_optional, /* optional */ + }, + { /* object_cls */ + H5VL_log_object_open, /* open */ + NULL, //H5VL_log_object_copy, /* copy */ + NULL, //H5VL_log_object_get, /* get */ + H5VL_log_object_specific, /* specific */ + NULL, //H5VL_log_object_optional, /* optional */ + }, + { + NULL, + NULL, + NULL + }, + NULL +}; + +typedef struct H5VL_log_t { + void *under_object; +} H5VL_log_t; + +H5PL_type_t H5PLget_plugin_type(void) {return H5PL_TYPE_VOL;} +const void *H5PLget_plugin_info(void) {return &H5VL_log2_g;} + +static herr_t H5VL_log_init(hid_t vipl_id) +{ + printf("------- LOG INIT\n"); + return 0; +} + +static herr_t H5VL_log_term(hid_t vtpl_id) +{ + printf("------- LOG TERM\n"); + return 0; +} + +static void * +H5VL_log_file_create(const char *name, unsigned flags, hid_t fcpl_id, hid_t fapl_id, hid_t dxpl_id, void **req) +{ + hid_t under_fapl; + H5VL_log_t *file; + + native_plugin_id = H5VLget_plugin_id("native"); + assert(native_plugin_id > 0); + + file = (H5VL_log_t *)calloc(1, sizeof(H5VL_log_t)); + + under_fapl = *((hid_t *)H5Pget_vol_info(fapl_id)); + file->under_object = H5VLfile_create(name, flags, fcpl_id, under_fapl, dxpl_id, req); + + printf("------- LOG H5Fcreate\n"); + return (void *)file; +} + +static void * +H5VL_log_file_open(const char *name, unsigned flags, hid_t fapl_id, hid_t dxpl_id, void **req) +{ + hid_t under_fapl; + H5VL_log_t *file; + + file = (H5VL_log_t *)calloc(1, sizeof(H5VL_log_t)); + + under_fapl = *((hid_t *)H5Pget_vol_info(fapl_id)); + file->under_object = H5VLfile_open(name, flags, under_fapl, dxpl_id, req); + + printf("------- LOG H5Fopen\n"); + return (void *)file; +} + +static herr_t +H5VL_log_file_get(void *file, H5VL_file_get_t get_type, hid_t dxpl_id, void **req, va_list arguments) +{ + H5VL_log_t *f = (H5VL_log_t *)file; + + H5VLfile_get(f->under_object, native_plugin_id, get_type, dxpl_id, req, arguments); + + printf("------- LOG H5Fget %d\n", get_type); + return 1; +} +static herr_t +H5VL_log_file_close(void *file, hid_t dxpl_id, void **req) +{ + H5VL_log_t *f = (H5VL_log_t *)file; + + H5VLfile_close(f->under_object, native_plugin_id, dxpl_id, req); + free(f); + + printf("------- LOG H5Fclose\n"); + return 1; +} + +static void * +H5VL_log_group_create(void *obj, H5VL_loc_params_t loc_params, const char *name, + hid_t gcpl_id, hid_t gapl_id, hid_t dxpl_id, void **req) +{ + H5VL_log_t *group; + H5VL_log_t *o = (H5VL_log_t *)obj; + + group = (H5VL_log_t *)calloc(1, sizeof(H5VL_log_t)); + + group->under_object = H5VLgroup_create(o->under_object, loc_params, native_plugin_id, name, gcpl_id, gapl_id, dxpl_id, req); + + printf("------- LOG H5Gcreate\n"); + return (void *)group; +} + +static herr_t +H5VL_log_group_close(void *grp, hid_t dxpl_id, void **req) +{ + H5VL_log_t *g = (H5VL_log_t *)grp; + + H5VLgroup_close(g->under_object, native_plugin_id, dxpl_id, req); + free(g); + + printf("------- LOG H5Gclose\n"); + return 1; +} + +static void * +H5VL_log_datatype_commit(void *obj, H5VL_loc_params_t loc_params, const char *name, + hid_t type_id, hid_t lcpl_id, hid_t tcpl_id, hid_t tapl_id, hid_t dxpl_id, void **req) +{ + H5VL_log_t *dt; + H5VL_log_t *o = (H5VL_log_t *)obj; + + dt = (H5VL_log_t *)calloc(1, sizeof(H5VL_log_t)); + + dt->under_object = H5VLdatatype_commit(o->under_object, loc_params, native_plugin_id, name, + type_id, lcpl_id, tcpl_id, tapl_id, dxpl_id, req); + + printf("------- LOG H5Tcommit\n"); + return dt; +} +static void * +H5VL_log_datatype_open(void *obj, H5VL_loc_params_t loc_params, const char *name, hid_t tapl_id, hid_t dxpl_id, void **req) +{ + H5VL_log_t *dt; + H5VL_log_t *o = (H5VL_log_t *)obj; + + dt = (H5VL_log_t *)calloc(1, sizeof(H5VL_log_t)); + + dt->under_object = H5VLdatatype_open(o->under_object, loc_params, native_plugin_id, name, tapl_id, dxpl_id, req); + + printf("------- LOG H5Topen\n"); + return (void *)dt; +} + +static herr_t +H5VL_log_datatype_get(void *dt, H5VL_datatype_get_t get_type, hid_t dxpl_id, void **req, va_list arguments) +{ + H5VL_log_t *o = (H5VL_log_t *)dt; + herr_t ret_value; + + ret_value = H5VLdatatype_get(o->under_object, native_plugin_id, get_type, dxpl_id, req, arguments); + + printf("------- LOG datatype get\n"); + return ret_value; +} + +static herr_t +H5VL_log_datatype_close(void *dt, hid_t dxpl_id, void **req) +{ + H5VL_log_t *type = (H5VL_log_t *)dt; + + assert(type->under_object); + + H5VLdatatype_close(type->under_object, native_plugin_id, dxpl_id, req); + free(type); + + printf("------- LOG H5Tclose\n"); + return 1; +} + +static void * +H5VL_log_object_open(void *obj, H5VL_loc_params_t loc_params, H5I_type_t *opened_type, hid_t dxpl_id, void **req) +{ + H5VL_log_t *new_obj; + H5VL_log_t *o = (H5VL_log_t *)obj; + + new_obj = (H5VL_log_t *)calloc(1, sizeof(H5VL_log_t)); + + new_obj->under_object = H5VLobject_open(o->under_object, loc_params, native_plugin_id, opened_type, dxpl_id, req); + + printf("------- LOG H5Oopen\n"); + return (void *)new_obj; +} + +static herr_t +H5VL_log_object_specific(void *obj, H5VL_loc_params_t loc_params, H5VL_object_specific_t specific_type, + hid_t dxpl_id, void **req, va_list arguments) +{ + H5VL_log_t *o = (H5VL_log_t *)obj; + + H5VLobject_specific(o->under_object, loc_params, native_plugin_id, specific_type, dxpl_id, req, arguments); + + printf("------- LOG Object specific\n"); + return 1; +} + +static void * +H5VL_log_dataset_create(void *obj, H5VL_loc_params_t loc_params, const char *name, hid_t dcpl_id, hid_t dapl_id, hid_t dxpl_id, void **req) +{ + H5VL_log_t *dset; + H5VL_log_t *o = (H5VL_log_t *)obj; + + dset = (H5VL_log_t *)calloc(1, sizeof(H5VL_log_t)); + + dset->under_object = H5VLdataset_create(o->under_object, loc_params, native_plugin_id, name, dcpl_id, dapl_id, dxpl_id, req); + + printf("------- LOG H5Dcreate\n"); + return (void *)dset; +} + +static void * +H5VL_log_dataset_open(void *obj, H5VL_loc_params_t loc_params, const char *name, hid_t dapl_id, hid_t dxpl_id, void **req) +{ + H5VL_log_t *dset; + H5VL_log_t *o = (H5VL_log_t *)obj; + + dset = (H5VL_log_t *)calloc(1, sizeof(H5VL_log_t)); + + dset->under_object = H5VLdataset_open(o->under_object, loc_params, native_plugin_id, name, dapl_id, dxpl_id, req); + + printf("------- LOG H5Dopen\n"); + return (void *)dset; +} + +static herr_t +H5VL_log_dataset_read(void *dset, hid_t mem_type_id, hid_t mem_space_id, + hid_t file_space_id, hid_t plist_id, void *buf, void **req) +{ + H5VL_log_t *d = (H5VL_log_t *)dset; + + H5VLdataset_read(d->under_object, native_plugin_id, mem_type_id, mem_space_id, file_space_id, + plist_id, buf, req); + + printf("------- LOG H5Dread\n"); + return 1; +} +static herr_t +H5VL_log_dataset_write(void *dset, hid_t mem_type_id, hid_t mem_space_id, + hid_t file_space_id, hid_t plist_id, const void *buf, void **req) +{ + H5VL_log_t *d = (H5VL_log_t *)dset; + + H5VLdataset_write(d->under_object, native_plugin_id, mem_type_id, mem_space_id, file_space_id, + plist_id, buf, req); + + printf("------- LOG H5Dwrite\n"); + return 1; +} +static herr_t +H5VL_log_dataset_close(void *dset, hid_t dxpl_id, void **req) +{ + H5VL_log_t *d = (H5VL_log_t *)dset; + + H5VLdataset_close(d->under_object, native_plugin_id, dxpl_id, req); + free(d); + + printf("------- LOG H5Dclose\n"); + return 1; +} diff --git a/test/test_vol_plugin.sh.in b/test/test_vol_plugin.sh.in new file mode 100644 index 0000000..ae6c768 --- /dev/null +++ b/test/test_vol_plugin.sh.in @@ -0,0 +1,80 @@ +#! /bin/sh +# +# Copyright by The HDF Group. +# All rights reserved. +# +# This file is part of HDF5. The full HDF5 copyright notice, including +# terms governing use, modification, and redistribution, is contained in +# the files COPYING and Copyright.html. COPYING can be found at the root +# of the source code distribution tree; Copyright.html can be found at the +# root level of an installed copy of the electronic document set and is +# linked from the top-level documents page. It can also be found at +# http://hdfgroup.org/HDF5/doc/Copyright.html. If you do not have access +# to either file, you may request a copy from help@hdfgroup.org. +# +srcdir=@srcdir@ +TOP_BUILDDIR=@top_builddir@ + +# Determine backward compatibility options enabled +DEPRECATED_SYMBOLS="@DEPRECATED_SYMBOLS@" + +EXIT_SUCCESS=0 +EXIT_FAILURE=1 + +nerrors=0 +verbose=yes +exit_code=$EXIT_SUCCESS + +TEST_NAME=vol_test +TEST_BIN=`pwd`/$TEST_NAME +FROM_DIR=`pwd`/.libs +PLUGIN_LIB="$FROM_DIR/libdynlibvol1.* $FROM_DIR/libdynlibvol2.*" +PLUGIN_LIBDIR=voltestdir +CP="cp -p" # Use -p to preserve mode,ownership,timestamps +RM="rm -rf" + +# Print a line-line message left justified in a field of 70 characters +# beginning with the word "Testing". +# +TESTING() { + SPACES=" " + echo "Testing $* $SPACES" | cut -c1-70 | tr -d '\012' +} + +# Main Body +# Create test directories if not exists yet. +test -d $PLUGIN_LIBDIR || mkdir -p $PLUGIN_LIBDIR +if [ $? != 0 ]; then + echo "Failed to create test directory($PLUGIN_LIBDIR)" + exit $EXIT_FAILURE +fi + +# copy plugin library for test +$CP $PLUGIN_LIB $PLUGIN_LIBDIR +if [ $? != 0 ]; then + echo "Failed to copy plugin library ($PLUGIN_LIB) for test." + exit $EXIT_FAILURE +fi + +# setup plugin path +ENVCMD="env HDF5_PLUGIN_PATH=${PLUGIN_LIBDIR}" + +# Run the test +$ENVCMD $TEST_BIN +if [ $? != 0 ]; then + nerrors=`expr $nerrors + 1` +fi + +# print results +if test $nerrors -ne 0 ; then + echo "$nerrors errors encountered" + exit_code=$EXIT_FAILURE +else + echo "All VOL Plugin API tests passed." + exit_code=$EXIT_SUCCESS +fi + +# Clean up temporary files/directories and leave +$RM $PLUGIN_LIBDIR + +exit $exit_code diff --git a/test/vol_test.c b/test/vol_test.c new file mode 100644 index 0000000..70169ca --- /dev/null +++ b/test/vol_test.c @@ -0,0 +1,136 @@ + +#include +#include +#include +#include "hdf5.h" + +hid_t native_plugin_id = -1; + +static herr_t +visit_cb(hid_t oid, const char *name, + const H5O_info_t *oinfo, void *udata) +{ + ssize_t len; + char n[25]; + + if(H5Iget_type(oid) == H5I_GROUP) { + len = H5VLget_plugin_name(oid, n, 50); + printf ("Visiting GROUP VOL name = %s %d\n", n, len); + } + if(H5Iget_type(oid) == H5I_DATASET) + printf("visiting dataset\n"); + if(H5Iget_type(oid) == H5I_DATATYPE) + printf("visiting datatype\n"); + + return 1; +} + +int main(int argc, char **argv) { + const char group_name[]="/Group"; + const char dataset_name[]="Data"; + char fullpath[500]; + hid_t file_id; + hid_t group_id; + hid_t dataspaceId; + hid_t datasetId; + hid_t acc_tpl; + hid_t under_fapl; + hid_t vol_id, vol_id2; + hid_t int_id; + hid_t space; + const unsigned int nelem=60; + int *data; + int n; + unsigned int i; + hsize_t dims[1]; + ssize_t len; + char name[25]; + static hsize_t ds_size[2] = {10, 20}; + + for(n=1 ; n<3 ; n++) { + char pl_name[4]; + const char file_name[50]; + + sprintf(pl_name, "log%d", n); + sprintf(file_name, "log_file%d.h5", n); + + vol_id = H5VLregister_by_name (pl_name); + assert(vol_id > 0); + assert(H5VLis_registered(pl_name) == 1); + + under_fapl = H5Pcreate (H5P_FILE_ACCESS); + H5Pset_fapl_native(under_fapl); + assert(H5VLis_registered("native") == 1); + + vol_id2 = H5VLget_plugin_id(pl_name); + H5VLinitialize(vol_id2, H5P_DEFAULT); + H5VLclose(vol_id2); + + native_plugin_id = H5VLget_plugin_id("native"); + assert(native_plugin_id > 0); + + acc_tpl = H5Pcreate (H5P_FILE_ACCESS); + H5Pset_vol(acc_tpl, vol_id, &under_fapl); + + file_id = H5Fcreate(file_name, H5F_ACC_TRUNC, H5P_DEFAULT, acc_tpl); + len = H5VLget_plugin_name(file_id, name, 25); + printf ("FILE VOL name = %s %d\n", name, len); + + group_id = H5Gcreate2(file_id, group_name, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT); + len = H5VLget_plugin_name(group_id, name, 50); + printf ("GROUP VOL name = %s %d\n", name, len); + + int_id = H5Tcopy(H5T_NATIVE_INT); + H5Tcommit2(file_id, "int", int_id, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT); + len = H5VLget_plugin_name(int_id, name, 50); + printf ("DT COMMIT name = %s %d\n", name, len); + H5Tclose(int_id); + + int_id = H5Topen2(file_id, "int", H5P_DEFAULT); + len = H5VLget_plugin_name(int_id, name, 50); + printf ("DT OPEN name = %s %d\n", name, len); + H5Tclose(int_id); + + int_id = H5Oopen(file_id,"int",H5P_DEFAULT); + len = H5VLget_plugin_name(int_id, name, 50); + printf ("DT OOPEN name = %s %d\n", name, len); + + len = H5Fget_name(file_id, name, 50); + printf("name = %d %s\n", len, name); + + data = (int *)malloc (sizeof(int)*nelem); + for(i=0;i