diff options
author | Binh-Minh Ribler <bmribler@hdfgroup.org> | 2018-12-23 06:18:42 (GMT) |
---|---|---|
committer | Binh-Minh Ribler <bmribler@hdfgroup.org> | 2018-12-23 06:18:42 (GMT) |
commit | c3f51c52d098d6cd2e6c2955a50140bdb45571c6 (patch) | |
tree | 3fbc8a16ba3140b0f7ed1febfbff9afb511073bd | |
parent | 251ba120b5e3277a0e53e9ea2417f6b370cf7d05 (diff) | |
parent | 7d28a4295ebac24dd0a84da9f4b880488d8bd32f (diff) | |
download | hdf5-c3f51c52d098d6cd2e6c2955a50140bdb45571c6.zip hdf5-c3f51c52d098d6cd2e6c2955a50140bdb45571c6.tar.gz hdf5-c3f51c52d098d6cd2e6c2955a50140bdb45571c6.tar.bz2 |
Merge branch 'develop' of https://bitbucket.hdfgroup.org/scm/~bmribler/hdf5_bmr_fixbug into develop
319 files changed, 21245 insertions, 12035 deletions
diff --git a/CMakeLists.txt b/CMakeLists.txt index e2fb000..a16cb08 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -756,6 +756,13 @@ if (BUILD_TESTING) mark_as_advanced (HDF5_TEST_FHEAP_VFD) endif () + option (HDF5_TEST_VOL "Execute tests with different VOL connectors" OFF) + mark_as_advanced (HDF5_TEST_VOL) + if (HDF5_TEST_VOL) + option (HDF5_TEST_FHEAP_VOL "Execute fheap test with different VOL connectors" ON) + mark_as_advanced (HDF5_TEST_FHEAP_VOL) + endif () + option (HDF_TEST_EXPRESS "Control testing framework (0-3)" "0") mark_as_advanced (HDF_TEST_EXPRESS) @@ -171,7 +171,6 @@ ./examples/h5_vds-percival.c ./examples/h5_vds-percival-unlim.c ./examples/h5_vds-percival-unlim-maxmin.c -./examples/h5_vol_external_log_native.c ./examples/testh5cc.sh.in ./examples/README @@ -890,11 +889,21 @@ ./src/H5TS.c ./src/H5TSprivate.h ./src/H5VL.c +./src/H5VLcallback.c ./src/H5VLint.c ./src/H5VLmodule.h ./src/H5VLnative.c ./src/H5VLnative.h +./src/H5VLnative_attr.c +./src/H5VLnative_dataset.c +./src/H5VLnative_datatype.c +./src/H5VLnative_file.c +./src/H5VLnative_group.c +./src/H5VLnative_link.c +./src/H5VLnative_object.c ./src/H5VLnative_private.h +./src/H5VLpassthru.c +./src/H5VLpassthru.h ./src/H5VLpkg.h ./src/H5VLprivate.h ./src/H5VLpublic.h @@ -1146,7 +1155,6 @@ ./test/test_filters_le.h5 ./test/test_filters_be.h5 ./test/gen_filters.c -./test/chunk_info.c ./test/vds.c ./test/vds_swmr.h ./test/vds_swmr_gen.c @@ -1388,14 +1396,17 @@ ./tools/test/h5format_convert/testfiles/h5fc_v_err.ddl.err ./tools/test/h5format_convert/testfiles/h5fc_v_non_chunked.ddl ./tools/test/h5format_convert/testfiles/h5fc_d_file.ddl +./tools/test/h5format_convert/testfiles/h5fc_d_file.ddl.err +./tools/test/h5format_convert/testfiles/h5fc_d_file-d.ddl ./tools/test/h5format_convert/testfiles/h5fc_v_ndata_bt1.ddl ./tools/test/h5format_convert/testfiles/h5fc_dname.ddl -./tools/test/h5format_convert/testfiles/h5fc_nonexistdset_file.ddl +./tools/test/h5format_convert/testfiles/h5fc_dname.err +./tools/test/h5format_convert/testfiles/h5fc_nonexistfile.ddl.err +./tools/test/h5format_convert/testfiles/h5fc_nonexistdset_file.ddl.err ./tools/test/h5format_convert/testfiles/h5fc_help.ddl ./tools/test/h5format_convert/testfiles/h5fc_v_all.ddl ./tools/test/h5format_convert/testfiles/h5fc_nooption.ddl ./tools/test/h5format_convert/testfiles/h5fc_v_n_1d.ddl -./tools/test/h5format_convert/testfiles/h5fc_nonexistfile.ddl ./tools/test/h5format_convert/testfiles/h5fc_non_v3.h5 ./tools/test/h5format_convert/testfiles/h5fc_edge_v3.h5 ./tools/test/h5format_convert/testfiles/h5fc_err_level.h5 @@ -1465,6 +1476,11 @@ ./tools/test/h5ls/vds_prefix/tvds-4.ls ./tools/test/h5ls/vds_prefix/tvds-5.ls +# h5ls test error files +./tools/test/h5ls/errfiles/nosuchfile.err +./tools/test/h5ls/errfiles/textlinksrc-nodangle-1.err +./tools/test/h5ls/errfiles/tgroup-1.err + # h5copy sources ./tools/src/h5copy/Makefile.am ./tools/src/h5copy/h5copy.c @@ -1520,10 +1536,11 @@ ./tools/test/misc/testfiles/h5clear_less_after_size.ddl ./tools/test/misc/testfiles/h5clear_less_before_size.ddl ./tools/test/misc/testfiles/h5clear_missing_file.ddl +./tools/test/misc/testfiles/h5clear_missing_file.err ./tools/test/misc/testfiles/h5clear_noclose_after_size.ddl ./tools/test/misc/testfiles/h5clear_noclose_before_size.ddl -./tools/test/misc/testfiles/h5clear_no_mdc_image.ddl -./tools/test/misc/testfiles/h5clear_open_fail.ddl +./tools/test/misc/testfiles/h5clear_no_mdc_image.err +./tools/test/misc/testfiles/h5clear_open_fail.err ./tools/test/misc/testfiles/h5clear_status_noclose_after_size.ddl ./tools/test/misc/testfiles/h5clear_usage.ddl ./tools/test/misc/testfiles/h5clear_user_equal_after_size.ddl @@ -1577,10 +1594,6 @@ ./tools/test/h5stat/testh5stat.sh.in ./tools/test/h5stat/testfiles/h5stat_dims1.ddl ./tools/test/h5stat/testfiles/h5stat_dims2.ddl -./tools/test/h5stat/testfiles/h5stat_err1_dims.ddl -./tools/test/h5stat/testfiles/h5stat_err1_links.ddl -./tools/test/h5stat/testfiles/h5stat_err1_numattrs.ddl -./tools/test/h5stat/testfiles/h5stat_err2_numattrs.ddl ./tools/test/h5stat/testfiles/h5stat_err_old_fill.h5 ./tools/test/h5stat/testfiles/h5stat_err_old_fill.ddl ./tools/test/h5stat/testfiles/h5stat_err_old_layout.h5 @@ -1618,6 +1631,15 @@ ./tools/test/h5stat/testfiles/h5stat_threshold.h5 ./tools/test/h5stat/testfiles/h5stat_tsohm.ddl ./tools/test/h5stat/testfiles/h5stat_tsohm.h5 +./tools/test/h5stat/testfiles/h5stat_err_refcount.err +./tools/test/h5stat/testfiles/h5stat_err_old_layout.err +./tools/test/h5stat/testfiles/h5stat_err_old_fill.err +./tools/test/h5stat/testfiles/h5stat_err1_dims.err +./tools/test/h5stat/testfiles/h5stat_err1_links.err +./tools/test/h5stat/testfiles/h5stat_err1_numattrs.err +./tools/test/h5stat/testfiles/h5stat_err2_numattrs.err +./tools/test/h5stat/testfiles/h5stat_notexist.err +./tools/test/h5stat/testfiles/h5stat_nofile.err # h5dump test files ./tools/testfiles/charsets.h5 @@ -2279,7 +2301,6 @@ ./tools/test/h5diff/testfiles/h5diff_600.txt ./tools/test/h5diff/testfiles/h5diff_601.txt ./tools/test/h5diff/testfiles/h5diff_601_ERR.err -./tools/test/h5diff/testfiles/h5diff_601_ERR.txt ./tools/test/h5diff/testfiles/h5diff_603.txt ./tools/test/h5diff/testfiles/h5diff_604.txt ./tools/test/h5diff/testfiles/h5diff_605.txt @@ -2386,21 +2407,12 @@ ./tools/test/h5diff/testfiles/h5diff_452.txt ./tools/test/h5diff/testfiles/h5diff_453.txt ./tools/test/h5diff/testfiles/h5diff_454.txt -./tools/test/h5diff/testfiles/h5diff_454_ERR.err -./tools/test/h5diff/testfiles/h5diff_454_ERR.txt +./tools/test/h5diff/testfiles/dangling_link.err ./tools/test/h5diff/testfiles/h5diff_455.txt -./tools/test/h5diff/testfiles/h5diff_455_ERR.err -./tools/test/h5diff/testfiles/h5diff_455_ERR.txt ./tools/test/h5diff/testfiles/h5diff_456.txt ./tools/test/h5diff/testfiles/h5diff_457.txt -./tools/test/h5diff/testfiles/h5diff_457_ERR.err -./tools/test/h5diff/testfiles/h5diff_457_ERR.txt ./tools/test/h5diff/testfiles/h5diff_458.txt -./tools/test/h5diff/testfiles/h5diff_458_ERR.err -./tools/test/h5diff/testfiles/h5diff_458_ERR.txt ./tools/test/h5diff/testfiles/h5diff_459.txt -./tools/test/h5diff/testfiles/h5diff_459_ERR.err -./tools/test/h5diff/testfiles/h5diff_459_ERR.txt ./tools/test/h5diff/testfiles/h5diff_465.txt ./tools/test/h5diff/testfiles/h5diff_466.txt ./tools/test/h5diff/testfiles/h5diff_467.txt @@ -2490,6 +2502,7 @@ ./tools/test/h5diff/testfiles/tudfilter.h5 ./tools/test/h5diff/testfiles/tudfilter2.h5 ./tools/test/h5diff/testfiles/h5diff_ud.txt +./tools/test/h5diff/testfiles/h5diff_udfail.err ./tools/test/h5diff/testfiles/h5diff_udfail.txt ./tools/test/h5diff/testfiles/diff_strings1.h5 ./tools/test/h5diff/testfiles/diff_strings2.h5 @@ -2590,6 +2603,7 @@ ./tools/test/h5copy/testfiles/h5copy_extlinks_src.h5 ./tools/test/h5copy/testfiles/h5copy_extlinks_trg.h5 ./tools/test/h5copy/testfiles/h5copy_extlinks_src.out.ls +./tools/test/h5copy/testfiles/h5copy_misc1.err ./tools/test/h5copy/testfiles/h5copy_misc1.out ./tools/test/h5copy/testfiles/h5copytst_new.h5 ./tools/test/h5copy/testfiles/h5copytst_new.out.ls @@ -2758,16 +2772,17 @@ # expected test output from testing h5watch # -./hl/tools/testfiles/w-err-cmpd1.ddl -./hl/tools/testfiles/w-err-cmpd2.ddl -./hl/tools/testfiles/w-err-cmpd3.ddl -./hl/tools/testfiles/w-err-cmpd4.ddl -./hl/tools/testfiles/w-err-cmpd5.ddl -./hl/tools/testfiles/w-err-dset1.ddl -./hl/tools/testfiles/w-err-dset2.ddl -./hl/tools/testfiles/w-err-dset-nomax.ddl -./hl/tools/testfiles/w-err-dset-none.ddl -./hl/tools/testfiles/w-err-file.ddl +./hl/tools/testfiles/w-err-std.ddl +./hl/tools/testfiles/w-err-cmpd1.err +./hl/tools/testfiles/w-err-cmpd2.err +./hl/tools/testfiles/w-err-cmpd3.err +./hl/tools/testfiles/w-err-cmpd4.err +./hl/tools/testfiles/w-err-cmpd5.err +./hl/tools/testfiles/w-err-dset1.err +./hl/tools/testfiles/w-err-dset2.err +./hl/tools/testfiles/w-err-dset-nomax.err +./hl/tools/testfiles/w-err-dset-none.err +./hl/tools/testfiles/w-err-file.err ./hl/tools/testfiles/w-err-poll0.ddl ./hl/tools/testfiles/w-err-poll.ddl ./hl/tools/testfiles/w-err-width.ddl @@ -2877,6 +2892,8 @@ ./java/src/jni/h5sImp.h ./java/src/jni/h5tImp.c ./java/src/jni/h5tImp.h +./java/src/jni/h5vlImp.c +./java/src/jni/h5vlImp.h ./java/src/jni/h5zImp.c ./java/src/jni/h5zImp.h @@ -3115,6 +3132,7 @@ ./java/test/testfiles/JUnit-TestH5Tparams.txt ./java/test/testfiles/JUnit-TestH5Tbasic.txt ./java/test/testfiles/JUnit-TestH5T.txt +./java/test/testfiles/JUnit-TestH5VL.txt ./java/test/testfiles/JUnit-TestH5Z.txt ./java/test/h5ex_g_iterate.orig ./java/test/TestH5.java @@ -3152,6 +3170,7 @@ ./java/test/TestH5Tparams.java ./java/test/TestH5Tbasic.java ./java/test/TestH5T.java +./java/test/TestH5VL.java ./java/test/TestH5Z.java ./java/test/TestAll.java @@ -3196,6 +3215,7 @@ ./config/cmake/UseJavaSymlinks.cmake ./config/cmake/userblockTest.cmake ./config/cmake/vfdTest.cmake +./config/cmake/volTest.cmake ./config/cmake/wait_H5Tinit.cmake ./config/cmake_ext_mod/ConfigureChecks.cmake @@ -3236,6 +3256,7 @@ ./c++/src/CMakeLists.txt ./c++/test/CMakeLists.txt ./c++/test/CMakeTests.cmake +./c++/test/CMakeVFDTests.cmake ./examples/CMakeLists.txt ./examples/CMakeTests.cmake ./examples/run-all-ex.sh @@ -3275,10 +3296,12 @@ ./test/CMakeLists.txt ./test/CMakeTests.cmake ./test/CMakeVFDTests.cmake +./test/CMakeVOLTests.cmake ./test/flushrefreshTest.cmake ./test/ShellTests.cmake ./testpar/CMakeLists.txt ./testpar/CMakeTests.cmake +./testpar/CMakeVFDTests.cmake ./tools/CMakeLists.txt ./tools/lib/CMakeLists.txt ./tools/src/CMakeLists.txt @@ -3311,6 +3334,7 @@ ./tools/src/h5repack/CMakeLists.txt ./tools/test/h5repack/CMakeLists.txt ./tools/test/h5repack/CMakeTests.cmake +./tools/test/h5repack/CMakeVFDTests.cmake ./tools/src/h5stat/CMakeLists.txt ./tools/test/h5stat/CMakeLists.txt ./tools/test/h5stat/CMakeTests.cmake diff --git a/Makefile.am b/Makefile.am index e3e5e3d..d58b1b4 100644 --- a/Makefile.am +++ b/Makefile.am @@ -186,6 +186,15 @@ check-vfd: fi; \ done +# Run tests with different Virtual Object Layer Connectors. +# Currently, only invoke check-vol in the test directory. +check-vol: + for d in src test; do \ + if test $$d != .; then \ + (cd $$d && $(MAKE) $(AM_MAKEFLAGS) $@) || exit 1; \ + fi; \ + done + # Automake wants to make config.status depend on configure. This # makes sense, but config.status can't always be regenerated # properly, which can cause builds to fail. diff --git a/bin/makehelp b/bin/makehelp index d6fbda2..4707397 100755 --- a/bin/makehelp +++ b/bin/makehelp @@ -40,6 +40,7 @@ make distclean: remove all files generated by make, make check, or make check-p: Only run parallel tests make check-s: Only run serial tests make check-vfd: Run tests with each virtual file driver +make check-vol: Run tests with each virtual object layer connector HDF5 uses Automake, so any standard Automake targets not listed here should also work. diff --git a/bin/snapshot b/bin/snapshot index 5c78fc8..5900728 100755 --- a/bin/snapshot +++ b/bin/snapshot @@ -132,6 +132,7 @@ DISPLAYUSAGE() Usage: $PROGNAME [all] [checkout] [ftp <URL> [diff] [test] [srcdir] [release] [help] [clean] [distclean] [echo] [deploy <dir>] [deploydir <dir>] [zlib <zlib_path>] [releasedir <dir>] [srcdirname <dir>] [check-vfd] + [check-vol] [exec <command>] [module-load <module-list>] [op-configure <option>] [--<option>] all: Run all commands (checkout, test & release) @@ -169,6 +170,8 @@ Usage: $PROGNAME [all] [checkout] [ftp <URL> [diff] [test] [srcdir] [release] [h [Default is $ReleaseDir_default] check-vfd: Run make check-vfd instead of just make check. + check-vol: + Run make check-vol instead of just make check. exttest <testscript>; Run testscript; exec <command>: @@ -422,6 +425,9 @@ while [ $# -gt 0 ] ; do check-vfd) CHECKVAL=check-vfd ;; + check-vol) + CHECKVAL=check-vol + ;; module-load) shift if [ $# -lt 1 ]; then @@ -68,6 +68,7 @@ $Source = ""; "unsigned" => "Iu", "unsigned int" => "Iu", "uint32_t" => "Iu", + "uint64_t" => "UL", "H5I_type_t" => "It", "H5G_link_t" => "Ll", #Same as H5L_type_t now "H5L_type_t" => "Ll", @@ -98,6 +99,7 @@ $Source = ""; "unsigned long long" => "UL", "H5VL_attr_get_t" => "Va", "H5VL_attr_specific_t" => "Vb", + "H5VL_class_value_t" => "VC", "H5VL_dataset_get_t" => "Vc", "H5VL_dataset_specific_t" => "Vd", "H5VL_datatype_get_t" => "Ve", @@ -111,6 +113,7 @@ $Source = ""; "H5VL_link_specific_t" => "Vm", "H5VL_object_get_t" => "Vn", "H5VL_object_specific_t" => "Vo", + "H5VL_request_specific_t" => "Vr", "void" => "x", "FILE" => "x", "H5A_operator_t" => "x", @@ -167,6 +170,7 @@ $Source = ""; "H5VL_t" => "x", "H5VL_class_t" => "x", "H5VL_loc_params_t" => "x", + "H5VL_request_notify_t" => "x", "H5Z_func_t" => "x", "H5Z_filter_func_t" => "x", "va_list" => "x", @@ -315,7 +319,7 @@ sub rewrite_func ($$$$$) { # Ignored due to NO TRACE comment. } elsif ($body =~ s/((\n[ \t]*)H5TRACE\d+\s*\(.*?\);)\n/"$2$trace"/es) { # Replaced an H5TRACE macro. - } elsif ($body=~s/((\n[ \t]*)FUNC_ENTER\w*\s*(\(.*?\))?;??)\n/"$1$2$trace"/es) { + } elsif ($body=~s/((\n[ \t]*)FUNC_ENTER\w*[ \t]*(\(.*?\))?;??)\n/"$1$2$trace"/es) { # Added an H5TRACE macro after a FUNC_ENTER macro. } else { errmesg $file, $name, "unable to insert tracing information"; diff --git a/c++/src/H5IdComponent.cpp b/c++/src/H5IdComponent.cpp index 20a0a99..40520aa 100644 --- a/c++/src/H5IdComponent.cpp +++ b/c++/src/H5IdComponent.cpp @@ -174,7 +174,6 @@ H5I_type_t IdComponent::getHDFObjType() const /// \li \c H5I_DATASPACE /// \li \c H5I_DATASET /// \li \c H5I_ATTR -/// \li \c H5I_REFERENCE (DEPRECATED) /// \li \c H5I_VFL /// \li \c H5I_VOL /// \li \c H5I_GENPROP_CLS @@ -228,7 +227,6 @@ bool IdComponent::isValid(hid_t an_id) /// \li \c H5I_DATASPACE /// \li \c H5I_DATASET /// \li \c H5I_ATTR -/// \li \c H5I_REFERENCE (DEPRECATED) /// \li \c H5I_VFL /// \li \c H5I_VOL /// \li \c H5I_GENPROP_CLS diff --git a/c++/src/H5PropList.cpp b/c++/src/H5PropList.cpp index 99f722c..a01878c 100644 --- a/c++/src/H5PropList.cpp +++ b/c++/src/H5PropList.cpp @@ -149,7 +149,6 @@ PropList::PropList(const hid_t plist_id) : IdComponent() case H5I_DATASPACE: case H5I_DATASET: case H5I_ATTR: - case H5I_REFERENCE: case H5I_VFL: case H5I_VOL: case H5I_ERROR_CLASS: diff --git a/c++/test/CMakeTests.cmake b/c++/test/CMakeTests.cmake index 6de801e..02bff3e 100644 --- a/c++/test/CMakeTests.cmake +++ b/c++/test/CMakeTests.cmake @@ -47,55 +47,12 @@ else () endif () set_tests_properties (CPP_testhdf5 PROPERTIES DEPENDS CPP_testhdf5-clear-objects) -if (HDF5_TEST_VFD) - - set (VFD_LIST - sec2 - stdio - core - split - multi - family - ) - - if (DIRECT_VFD) - set (VFD_LIST ${VFD_LIST} direct) - endif () - - macro (ADD_VFD_TEST vfdname resultcode) - if (NOT HDF5_ENABLE_USING_MEMCHECKER) - file (MAKE_DIRECTORY "${PROJECT_BINARY_DIR}/${vfdname}") - add_test ( - NAME CPP_VFD-${vfdname}-cpp_testhdf5-clear-objects - COMMAND ${CMAKE_COMMAND} - -E remove - tattr_basic.h5 - tattr_compound.h5 - tattr_dtype.h5 - tattr_multi.h5 - tattr_scalar.h5 - tfattrs.h5 - titerate.h5 - ) - add_test ( - NAME CPP_VFD-${vfdname}-cpp_testhdf5 - COMMAND "${CMAKE_COMMAND}" - -D "TEST_PROGRAM=$<TARGET_FILE:cpp_testhdf5>" - -D "TEST_ARGS:STRING=" - -D "TEST_VFD:STRING=${vfdname}" - -D "TEST_EXPECT=${resultcode}" - -D "TEST_OUTPUT=cpp_testhdf5" - -D "TEST_FOLDER=${PROJECT_BINARY_DIR}/${vfdname}" - -P "${HDF_RESOURCES_DIR}/vfdTest.cmake" - ) - set_tests_properties (CPP_VFD-${vfdname}-cpp_testhdf5 PROPERTIES DEPENDS CPP_VFD-${vfdname}-cpp_testhdf5-clear-objects) - set_tests_properties (CPP_VFD-${vfdname}-cpp_testhdf5 PROPERTIES TIMEOUT 30) - endif () - endmacro () - - # Run test with different Virtual File Driver - foreach (vfd ${VFD_LIST}) - ADD_VFD_TEST (${vfd} 0) - endforeach () +############################################################################## +############################################################################## +### V F D T E S T S ### +############################################################################## +############################################################################## +if (HDF5_TEST_VFD) + include (CMakeVFDTests.cmake) endif () diff --git a/c++/test/CMakeVFDTests.cmake b/c++/test/CMakeVFDTests.cmake new file mode 100644 index 0000000..996a20f --- /dev/null +++ b/c++/test/CMakeVFDTests.cmake @@ -0,0 +1,65 @@ +# +# 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 COPYING file, which can be found at the root of the source code +# distribution tree, or in https://support.hdfgroup.org/ftp/HDF5/releases. +# If you do not have access to either file, you may request a copy from +# help@hdfgroup.org. +# + +############################################################################## +############################################################################## +### T E S T I N G ### +############################################################################## +############################################################################## + set (VFD_LIST + sec2 + stdio + core + split + multi + family + ) + + if (DIRECT_VFD) + set (VFD_LIST ${VFD_LIST} direct) + endif () + + macro (ADD_VFD_TEST vfdname resultcode) + if (NOT HDF5_ENABLE_USING_MEMCHECKER) + file (MAKE_DIRECTORY "${PROJECT_BINARY_DIR}/${vfdname}") + add_test ( + NAME CPP_VFD-${vfdname}-cpp_testhdf5-clear-objects + COMMAND ${CMAKE_COMMAND} + -E remove + tattr_basic.h5 + tattr_compound.h5 + tattr_dtype.h5 + tattr_multi.h5 + tattr_scalar.h5 + tfattrs.h5 + titerate.h5 + ) + add_test ( + NAME CPP_VFD-${vfdname}-cpp_testhdf5 + COMMAND "${CMAKE_COMMAND}" + -D "TEST_PROGRAM=$<TARGET_FILE:cpp_testhdf5>" + -D "TEST_ARGS:STRING=" + -D "TEST_VFD:STRING=${vfdname}" + -D "TEST_EXPECT=${resultcode}" + -D "TEST_OUTPUT=cpp_testhdf5" + -D "TEST_FOLDER=${PROJECT_BINARY_DIR}/${vfdname}" + -P "${HDF_RESOURCES_DIR}/vfdTest.cmake" + ) + set_tests_properties (CPP_VFD-${vfdname}-cpp_testhdf5 PROPERTIES DEPENDS CPP_VFD-${vfdname}-cpp_testhdf5-clear-objects) + set_tests_properties (CPP_VFD-${vfdname}-cpp_testhdf5 PROPERTIES TIMEOUT 30) + endif () + endmacro () + + # Run test with different Virtual File Driver + foreach (vfd ${VFD_LIST}) + ADD_VFD_TEST (${vfd} 0) + endforeach () diff --git a/c++/test/tlinks.cpp b/c++/test/tlinks.cpp index f8d7089..6e990c9 100644 --- a/c++/test/tlinks.cpp +++ b/c++/test/tlinks.cpp @@ -857,11 +857,6 @@ void test_links() { hid_t fapl_id, fapl2_id; /* File access property lists */ unsigned new_format; /* Whether to use the new format or not */ - const char *envval; - - envval = HDgetenv("HDF5_DRIVER"); - if(envval == NULL) - envval = "nomatch"; fapl_id = h5_fileaccess(); diff --git a/config/cmake/jrunTest.cmake b/config/cmake/jrunTest.cmake index b66f3a8..43aef22 100644 --- a/config/cmake/jrunTest.cmake +++ b/config/cmake/jrunTest.cmake @@ -32,9 +32,6 @@ endif () if (NOT TEST_CLASSPATH) message (STATUS "Require TEST_CLASSPATH to be defined") endif () -if (NOT TEST_REFERENCE) - message (FATAL_ERROR "Require TEST_REFERENCE to be defined") -endif () if (EXISTS ${TEST_FOLDER}/${TEST_OUTPUT}) file (REMOVE ${TEST_FOLDER}/${TEST_OUTPUT}) @@ -44,14 +41,6 @@ if (EXISTS ${TEST_FOLDER}/${TEST_OUTPUT}.err) file (REMOVE ${TEST_FOLDER}/${TEST_OUTPUT}.err) endif () -# if there is not an error reference file add the error output to the stdout file -if (NOT TEST_ERRREF) - if (NOT SKIP_APPEND) - # append error file since skip was not defined - set (ERROR_APPEND 1) - endif () -endif () - if (NOT TEST_LOG_LEVEL) set (LOG_LEVEL "info") else () @@ -131,52 +120,54 @@ message (STATUS "COMMAND Error: ${TEST_ERROR}") # compare output files to references unless this must be skipped if (NOT TEST_SKIP_COMPARE) - if (WIN32 AND NOT MINGW) - file (READ ${TEST_FOLDER}/${TEST_REFERENCE} TEST_STREAM) - file (WRITE ${TEST_FOLDER}/${TEST_REFERENCE} "${TEST_STREAM}") - endif () + if (EXISTS ${TEST_FOLDER}/${TEST_REFERENCE}) + if (WIN32 AND NOT MINGW) + file (READ ${TEST_FOLDER}/${TEST_REFERENCE} TEST_STREAM) + file (WRITE ${TEST_FOLDER}/${TEST_REFERENCE} "${TEST_STREAM}") + endif () - # now compare the output with the reference - execute_process ( - COMMAND ${CMAKE_COMMAND} -E compare_files ${TEST_FOLDER}/${TEST_OUTPUT} ${TEST_FOLDER}/${TEST_REFERENCE} - RESULT_VARIABLE TEST_RESULT - ) - if (NOT "${TEST_RESULT}" STREQUAL "0") - set (TEST_RESULT 0) - file (STRINGS ${TEST_FOLDER}/${TEST_OUTPUT} test_act) - list (LENGTH test_act len_act) - file (STRINGS ${TEST_FOLDER}/${TEST_REFERENCE} test_ref) - list (LENGTH test_ref len_ref) - if (NOT "${len_act}" STREQUAL "0" AND NOT "${len_ref}" STREQUAL "0") - math (EXPR _FP_LEN "${len_ref} - 1") - foreach (line RANGE 0 ${_FP_LEN}) - list (GET test_act ${line} str_act) - list (GET test_ref ${line} str_ref) - if (NOT "${str_act}" STREQUAL "${str_ref}") - if (NOT "${str_act}" STREQUAL "") - set (TEST_RESULT 1) - message ("line = ${line}\n***ACTUAL: ${str_act}\n****REFER: ${str_ref}\n") + # now compare the output with the reference + execute_process ( + COMMAND ${CMAKE_COMMAND} -E compare_files ${TEST_FOLDER}/${TEST_OUTPUT} ${TEST_FOLDER}/${TEST_REFERENCE} + RESULT_VARIABLE TEST_RESULT + ) + if (NOT "${TEST_RESULT}" STREQUAL "0") + set (TEST_RESULT 0) + file (STRINGS ${TEST_FOLDER}/${TEST_OUTPUT} test_act) + list (LENGTH test_act len_act) + file (STRINGS ${TEST_FOLDER}/${TEST_REFERENCE} test_ref) + list (LENGTH test_ref len_ref) + if (NOT "${len_act}" STREQUAL "0" AND NOT "${len_ref}" STREQUAL "0") + math (EXPR _FP_LEN "${len_ref} - 1") + foreach (line RANGE 0 ${_FP_LEN}) + list (GET test_act ${line} str_act) + list (GET test_ref ${line} str_ref) + if (NOT "${str_act}" STREQUAL "${str_ref}") + if (NOT "${str_act}" STREQUAL "") + set (TEST_RESULT 1) + message ("line = ${line}\n***ACTUAL: ${str_act}\n****REFER: ${str_ref}\n") + endif () endif () + endforeach () + else () + if ("${len_act}" STREQUAL "0") + message (STATUS "COMPARE Failed: ${TEST_FOLDER}/${TEST_OUTPUT} is empty") + endif () + if ("${len_ref}" STREQUAL "0") + message (STATUS "COMPARE Failed: ${TEST_FOLDER}/${TEST_REFERENCE} is empty") endif () - endforeach () - else () - if ("${len_act}" STREQUAL "0") - message (STATUS "COMPARE Failed: ${TEST_FOLDER}/${TEST_OUTPUT} is empty") endif () - if ("${len_ref}" STREQUAL "0") - message (STATUS "COMPARE Failed: ${TEST_FOLDER}/${TEST_REFERENCE} is empty") + if (NOT "${len_act}" STREQUAL "${len_ref}") + set (TEST_RESULT 1) endif () endif () - if (NOT "${len_act}" STREQUAL "${len_ref}") - set (TEST_RESULT 1) - endif () - endif () - message (STATUS "COMPARE Result: ${TEST_RESULT}") + message (STATUS "COMPARE Result: ${TEST_RESULT}") - # again, if return value is !=0 scream and shout - if (NOT "${TEST_RESULT}" STREQUAL "0") - message (FATAL_ERROR "Failed: The output of ${TEST_OUTPUT} did not match ${TEST_REFERENCE}") + # again, if return value is !=0 scream and shout + if (NOT "${TEST_RESULT}" STREQUAL "0") + message (FATAL_ERROR "Failed: The output of ${TEST_OUTPUT} did not match ${TEST_REFERENCE}") + endif () endif () # now compare the .err file with the error reference, if supplied @@ -217,7 +208,7 @@ if (NOT TEST_SKIP_COMPARE) if ("${len_ref}" STREQUAL "0") message (STATUS "COMPARE Failed: ${TEST_FOLDER}/${TEST_ERRREF} is empty") endif () - endif() + endif () if (NOT "${len_act}" STREQUAL "${len_ref}") set (TEST_RESULT 1) endif () @@ -226,7 +217,7 @@ if (NOT TEST_SKIP_COMPARE) message (STATUS "COMPARE Result: ${TEST_RESULT}") # again, if return value is !=0 scream and shout - if (NOT ${TEST_RESULT} STREQUAL 0) + if (NOT "${TEST_RESULT}" STREQUAL "0") message (FATAL_ERROR "Failed: The error output of ${TEST_OUTPUT}.err did not match ${TEST_ERRREF}") endif () endif () diff --git a/config/cmake/scripts/HDF5options.cmake b/config/cmake/scripts/HDF5options.cmake index 6d1a57a..d4cc996 100755 --- a/config/cmake/scripts/HDF5options.cmake +++ b/config/cmake/scripts/HDF5options.cmake @@ -58,12 +58,13 @@ set (ADD_BUILD_OPTIONS "${ADD_BUILD_OPTIONS} -DHDF5_ALLOW_EXTERNAL_SUPPORT:STRIN ### ext libs from git #set (ADD_BUILD_OPTIONS "${ADD_BUILD_OPTIONS} -DHDF5_ALLOW_EXTERNAL_SUPPORT:STRING=GIT") ### ext libs on system +#set (ADD_BUILD_OPTIONS "${ADD_BUILD_OPTIONS} -DHDF5_ALLOW_EXTERNAL_SUPPORT:STRING=NO") #set (ADD_BUILD_OPTIONS "${ADD_BUILD_OPTIONS} -DZLIB_LIBRARY:FILEPATH=some_location/lib/zlib.lib -DZLIB_INCLUDE_DIR:PATH=some_location/include") #set (ADD_BUILD_OPTIONS "${ADD_BUILD_OPTIONS} -DSZIP_LIBRARY:FILEPATH=some_location/lib/szlib.lib -DSZIP_INCLUDE_DIR:PATH=some_location/include") -### disable ext zlib building +### disable using ext zlib #set (ADD_BUILD_OPTIONS "${ADD_BUILD_OPTIONS} -DHDF5_ENABLE_Z_LIB_SUPPORT:BOOL=OFF") -### disable ext szip building +### disable using ext szip #set (ADD_BUILD_OPTIONS "${ADD_BUILD_OPTIONS} -DHDF5_ENABLE_SZIP_SUPPORT:BOOL=OFF") #set (ADD_BUILD_OPTIONS "${ADD_BUILD_OPTIONS} -DHDF5_ENABLE_SZIP_ENCODING:BOOL=OFF") diff --git a/config/cmake/vfdTest.cmake b/config/cmake/vfdTest.cmake index 66a97c0..95a4c40 100644 --- a/config/cmake/vfdTest.cmake +++ b/config/cmake/vfdTest.cmake @@ -32,9 +32,9 @@ if (EXISTS ${TEST_FOLDER}/${TEST_OUTPUT}.err) endif () # if there is not an error reference file add the error output to the stdout file -if (NOT TEST_ERRREF) - set (ERROR_APPEND 1) -endif () +#if (NOT TEST_ERRREF) +# set (ERROR_APPEND 1) +#endif () message (STATUS "USING ${TEST_VFD} ON COMMAND: ${TEST_PROGRAM} ${TEST_ARGS}") diff --git a/config/cmake/volTest.cmake b/config/cmake/volTest.cmake new file mode 100644 index 0000000..27da8a5 --- /dev/null +++ b/config/cmake/volTest.cmake @@ -0,0 +1,76 @@ +# +# 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 COPYING file, which can be found at the root of the source code +# distribution tree, or in https://support.hdfgroup.org/ftp/HDF5/releases. +# If you do not have access to either file, you may request a copy from +# help@hdfgroup.org. +# +# volTest.cmake executes a command and captures the output in a file. Command uses specified VOL. +# Exit status of command can also be compared. + +# arguments checking +if (NOT TEST_PROGRAM) + message (FATAL_ERROR "Require TEST_PROGRAM to be defined") +endif () +if (NOT TEST_FOLDER) + message ( FATAL_ERROR "Require TEST_FOLDER to be defined") +endif () +if (NOT TEST_VOL) + message (FATAL_ERROR "Require TEST_VOL to be defined") +endif () + +if (EXISTS ${TEST_FOLDER}/${TEST_OUTPUT}) + file (REMOVE ${TEST_FOLDER}/${TEST_OUTPUT}) +endif () + +if (EXISTS ${TEST_FOLDER}/${TEST_OUTPUT}.err) + file (REMOVE ${TEST_FOLDER}/${TEST_OUTPUT}.err) +endif () + +# if there is not an error reference file add the error output to the stdout file +#if (NOT TEST_ERRREF) +# set (ERROR_APPEND 1) +#endif () + +message (STATUS "USING ${TEST_VOL} ON COMMAND: ${TEST_PROGRAM} ${TEST_ARGS}") + +set (ENV{HDF5_VOL_CONNECTOR} "${TEST_VOL}") + +# run the test program, capture the stdout/stderr and the result var +execute_process ( + COMMAND ${TEST_PROGRAM} ${TEST_ARGS} + WORKING_DIRECTORY ${TEST_FOLDER} + RESULT_VARIABLE TEST_RESULT + OUTPUT_FILE ${TEST_OUTPUT}.out + ERROR_FILE ${TEST_OUTPUT}.err + OUTPUT_VARIABLE TEST_OUT + ERROR_VARIABLE TEST_ERROR +) + +message (STATUS "COMMAND Result: ${TEST_RESULT}") + +# if the .err file exists and ERRROR_APPEND is enabled +if (ERROR_APPEND AND EXISTS ${TEST_FOLDER}/${TEST_OUTPUT}.err) + file (READ ${TEST_FOLDER}/${TEST_OUTPUT}.err TEST_STREAM) + file (APPEND ${TEST_FOLDER}/${TEST_OUTPUT}.out "${TEST_STREAM}") +endif () + +# if the return value is !=${TEST_EXPECT} bail out +if (NOT "${TEST_RESULT}" STREQUAL "${TEST_EXPECT}") + if (NOT TEST_NOERRDISPLAY) + if (EXISTS ${TEST_FOLDER}/${TEST_OUTPUT}.out) + file (READ ${TEST_FOLDER}/${TEST_OUTPUT}.out TEST_STREAM) + message (STATUS "Output USING ${TEST_VOL}:\n${TEST_STREAM}") + endif () + endif () + message (FATAL_ERROR "Failed: Test program ${TEST_PROGRAM} exited != ${TEST_EXPECT}.\n${TEST_ERROR}") +endif () + +message (STATUS "COMMAND Error: ${TEST_ERROR}") + +# everything went fine... +message ("Passed: The ${TEST_PROGRAM} program used vol ${TEST_VOL}") diff --git a/config/cmake_ext_mod/runTest.cmake b/config/cmake_ext_mod/runTest.cmake index 5569a73..8181ff0 100644 --- a/config/cmake_ext_mod/runTest.cmake +++ b/config/cmake_ext_mod/runTest.cmake @@ -26,9 +26,6 @@ endif () if (NOT TEST_EXPECT) message (STATUS "Require TEST_EXPECT to be defined") endif () -if (NOT TEST_SKIP_COMPARE AND NOT TEST_REFERENCE) - message (FATAL_ERROR "Require TEST_REFERENCE to be defined") -endif () if (EXISTS ${TEST_FOLDER}/${TEST_OUTPUT}) file (REMOVE ${TEST_FOLDER}/${TEST_OUTPUT}) @@ -38,11 +35,6 @@ if (EXISTS ${TEST_FOLDER}/${TEST_OUTPUT}.err) file (REMOVE ${TEST_FOLDER}/${TEST_OUTPUT}.err) endif () -# if there is not an error reference file add the error output to the stdout file -if (NOT TEST_ERRREF) - set (ERROR_APPEND 1) -endif () - message (STATUS "COMMAND: ${TEST_PROGRAM} ${TEST_ARGS}") if (TEST_LIBRARY_DIRECTORY) @@ -96,9 +88,21 @@ endif () message (STATUS "COMMAND Result: ${TEST_RESULT}") # if the .err file exists and ERRROR_APPEND is enabled -if (ERROR_APPEND AND EXISTS ${TEST_FOLDER}/${TEST_OUTPUT}.err) +if (EXISTS ${TEST_FOLDER}/${TEST_OUTPUT}.err) file (READ ${TEST_FOLDER}/${TEST_OUTPUT}.err TEST_STREAM) - file (APPEND ${TEST_FOLDER}/${TEST_OUTPUT} "${TEST_STREAM}") + if (TEST_MASK_FILE) + STRING(REGEX REPLACE "CurrentDir is [^\n]+\n" "CurrentDir is (dir name)\n" TEST_STREAM "${TEST_STREAM}") + endif () + # remove special output + string (REGEX REPLACE "^.*_pmi_alps[^\n]+\n" "" TEST_STREAM "${TEST_STREAM}") + + if (NOT ERROR_APPEND) + # append error output to the stdout output file + file (WRITE ${TEST_FOLDER}/${TEST_OUTPUT}.err "${TEST_STREAM}") + else () + # write back to original .err file + file (APPEND ${TEST_FOLDER}/${TEST_OUTPUT} "${TEST_STREAM}") + endif () endif () # append the test result status with a predefined text @@ -119,6 +123,11 @@ endif () message (STATUS "COMMAND Error: ${TEST_ERROR}") +# remove special output +file (READ ${TEST_FOLDER}/${TEST_OUTPUT} TEST_STREAM) +string (REGEX REPLACE "^.*_pmi_alps[^\n]+\n" "" TEST_STREAM "${TEST_STREAM}") +file (WRITE ${TEST_FOLDER}/${TEST_OUTPUT} "${TEST_STREAM}") + # if the output file needs Storage text removed if (TEST_MASK) file (READ ${TEST_FOLDER}/${TEST_OUTPUT} TEST_STREAM) @@ -173,63 +182,65 @@ endif () # compare output files to references unless this must be skipped if (NOT TEST_SKIP_COMPARE) - if (WIN32 AND NOT MINGW) - file (READ ${TEST_FOLDER}/${TEST_REFERENCE} TEST_STREAM) - file (WRITE ${TEST_FOLDER}/${TEST_REFERENCE} "${TEST_STREAM}") - endif () + if (EXISTS ${TEST_FOLDER}/${TEST_REFERENCE}) + if (WIN32 AND NOT MINGW) + file (READ ${TEST_FOLDER}/${TEST_REFERENCE} TEST_STREAM) + file (WRITE ${TEST_FOLDER}/${TEST_REFERENCE} "${TEST_STREAM}") + endif () - if (NOT TEST_SORT_COMPARE) - # now compare the output with the reference - execute_process ( - COMMAND ${CMAKE_COMMAND} -E compare_files ${TEST_FOLDER}/${TEST_OUTPUT} ${TEST_FOLDER}/${TEST_REFERENCE} - RESULT_VARIABLE TEST_RESULT - ) - else () - file (STRINGS ${TEST_FOLDER}/${TEST_OUTPUT} v1) - file (STRINGS ${TEST_FOLDER}/${TEST_REFERENCE} v2) - list (SORT v1) - list (SORT v2) - if (NOT v1 STREQUAL v2) - set(TEST_RESULT 1) + if (NOT TEST_SORT_COMPARE) + # now compare the output with the reference + execute_process ( + COMMAND ${CMAKE_COMMAND} -E compare_files ${TEST_FOLDER}/${TEST_OUTPUT} ${TEST_FOLDER}/${TEST_REFERENCE} + RESULT_VARIABLE TEST_RESULT + ) + else () + file (STRINGS ${TEST_FOLDER}/${TEST_OUTPUT} v1) + file (STRINGS ${TEST_FOLDER}/${TEST_REFERENCE} v2) + list (SORT v1) + list (SORT v2) + if (NOT v1 STREQUAL v2) + set(TEST_RESULT 1) + endif () endif () - endif () - if (NOT "${TEST_RESULT}" STREQUAL "0") - set (TEST_RESULT 0) - file (STRINGS ${TEST_FOLDER}/${TEST_OUTPUT} test_act) - list (LENGTH test_act len_act) - file (STRINGS ${TEST_FOLDER}/${TEST_REFERENCE} test_ref) - list (LENGTH test_ref len_ref) - if (NOT "${len_act}" STREQUAL "0" AND NOT "${len_ref}" STREQUAL "0") - math (EXPR _FP_LEN "${len_ref} - 1") - foreach (line RANGE 0 ${_FP_LEN}) - list (GET test_act ${line} str_act) - list (GET test_ref ${line} str_ref) - if (NOT "${str_act}" STREQUAL "${str_ref}") - if (NOT "${str_act}" STREQUAL "") - set (TEST_RESULT 1) - message ("line = ${line}\n***ACTUAL: ${str_act}\n****REFER: ${str_ref}\n") + if (NOT "${TEST_RESULT}" STREQUAL "0") + set (TEST_RESULT 0) + file (STRINGS ${TEST_FOLDER}/${TEST_OUTPUT} test_act) + list (LENGTH test_act len_act) + file (STRINGS ${TEST_FOLDER}/${TEST_REFERENCE} test_ref) + list (LENGTH test_ref len_ref) + if (NOT "${len_act}" STREQUAL "0" AND NOT "${len_ref}" STREQUAL "0") + math (EXPR _FP_LEN "${len_ref} - 1") + foreach (line RANGE 0 ${_FP_LEN}) + list (GET test_act ${line} str_act) + list (GET test_ref ${line} str_ref) + if (NOT "${str_act}" STREQUAL "${str_ref}") + if (NOT "${str_act}" STREQUAL "") + set (TEST_RESULT 1) + message ("line = ${line}\n***ACTUAL: ${str_act}\n****REFER: ${str_ref}\n") + endif () endif () + endforeach () + else () + if ("${len_act}" STREQUAL "0") + message (STATUS "COMPARE Failed: ${TEST_FOLDER}/${TEST_OUTPUT} is empty") + endif () + if ("${len_ref}" STREQUAL "0") + message (STATUS "COMPARE Failed: ${TEST_FOLDER}/${TEST_REFERENCE} is empty") endif () - endforeach () - else () - if ("${len_act}" STREQUAL "0") - message (STATUS "COMPARE Failed: ${TEST_FOLDER}/${TEST_OUTPUT} is empty") endif () - if ("${len_ref}" STREQUAL "0") - message (STATUS "COMPARE Failed: ${TEST_FOLDER}/${TEST_REFERENCE} is empty") + if (NOT "${len_act}" STREQUAL "${len_ref}") + set (TEST_RESULT 1) endif () endif () - if (NOT "${len_act}" STREQUAL "${len_ref}") - set (TEST_RESULT 1) - endif () - endif () - message (STATUS "COMPARE Result: ${TEST_RESULT}") + message (STATUS "COMPARE Result: ${TEST_RESULT}") - # again, if return value is !=0 scream and shout - if (NOT "${TEST_RESULT}" STREQUAL "0") - message (FATAL_ERROR "Failed: The output of ${TEST_OUTPUT} did not match ${TEST_REFERENCE}") + # again, if return value is !=0 scream and shout + if (NOT "${TEST_RESULT}" STREQUAL "0") + message (FATAL_ERROR "Failed: The output of ${TEST_OUTPUT} did not match ${TEST_REFERENCE}") + endif () endif () # now compare the .err file with the error reference, if supplied @@ -260,7 +271,7 @@ if (NOT TEST_SKIP_COMPARE) if (NOT "${str_act}" STREQUAL "") set (TEST_RESULT 1) message ("line = ${line}\n***ACTUAL: ${str_act}\n****REFER: ${str_ref}\n") - endif () + endif () endif () endforeach () else () @@ -285,5 +296,27 @@ if (NOT TEST_SKIP_COMPARE) endif () endif () +if (TEST_GREP_COMPARE) + # now grep the output with the reference + file (READ ${TEST_FOLDER}/${TEST_OUTPUT} TEST_STREAM) + + # TEST_REFERENCE should always be matched + string (REGEX MATCH "${TEST_REFERENCE}" TEST_MATCH ${TEST_STREAM}) + string (COMPARE EQUAL "${TEST_REFERENCE}" "${TEST_MATCH}" TEST_RESULT) + if ("${TEST_RESULT}" STREQUAL "0") + message (FATAL_ERROR "Failed: The output of ${TEST_PROGRAM} did not contain ${TEST_REFERENCE}") + endif () + + string (REGEX MATCH "${TEST_FILTER}" TEST_MATCH ${TEST_STREAM}) + if ("${TEST_EXPECT}" STREQUAL "1") + # TEST_EXPECT (1) interperts TEST_FILTER as NOT to match + string (LENGTH "${TEST_MATCH}" TEST_RESULT) + if (NOT "${TEST_RESULT}" STREQUAL "0") + message (FATAL_ERROR "Failed: The output of ${TEST_PROGRAM} did contain ${TEST_FILTER}") + endif () + endif () +endif () + # everything went fine... -message ("Passed: The output of ${TEST_PROGRAM} matches ${TEST_REFERENCE}") +message ("${TEST_PROGRAM} Passed") + diff --git a/config/commence.am b/config/commence.am index 5fe21a6..5d88a88 100644 --- a/config/commence.am +++ b/config/commence.am @@ -97,7 +97,8 @@ CHECK_CLEANFILES=*.chkexe *.chklog *.clog *.clog2 # exists. .PHONY: build-check-clean build-check-p build-check-s build-lib build-progs \ build-tests check-clean check-install check-p check-s check-vfd \ - install-doc lib progs tests uninstall-doc _exec_check-s _test help + check-vol install-doc lib progs tests uninstall-doc _exec_check-s \ + _test help help: @$(top_srcdir)/bin/makehelp diff --git a/config/conclude.am b/config/conclude.am index 4bdbb0b..d0dbf3a 100644 --- a/config/conclude.am +++ b/config/conclude.am @@ -131,28 +131,43 @@ $(TEST_PROG_CHKEXE) $(TEST_PROG_PARA_CHKEXE) dummy.chkexe_: echo "============================" > $${log}; \ fi; \ if test "X$(FORTRAN_API)" = "Xyes"; then \ - echo "Fortran API: Testing $(HDF5_DRIVER) $${tname} $(TEST_FLAGS)"; \ + echo "Fortran API: Testing $${tname} $(TEST_FLAGS)"; \ if test -n "$(REALTIMEOUTPUT)"; then \ - echo "Fortran API: $(HDF5_DRIVER) $${tname} $(TEST_FLAGS) Test Log" | tee -a $${log}; \ + echo "Fortran API: Test log for $${tname} $(TEST_FLAGS)" | tee -a $${log}; \ else \ - echo "Fortran API: $(HDF5_DRIVER) $${tname} $(TEST_FLAGS) Test Log" >> $${log}; \ + echo "Fortran API: Test log for $${tname} $(TEST_FLAGS)" >> $${log}; \ fi; \ elif test "X$(CXX_API)" = "Xyes"; then \ - echo "C++ API: Testing $(HDF5_DRIVER) $${tname} $(TEST_FLAGS)"; \ + echo "C++ API: Testing $${tname} $(TEST_FLAGS)"; \ if test -n "$(REALTIMEOUTPUT)"; then \ - echo "C++ API: $(HDF5_DRIVER) $${tname} $(TEST_FLAGS) Test Log" | tee -a $${log};\ + echo "C++ API: Test log for $${tname} $(TEST_FLAGS)" | tee -a $${log};\ else \ - echo "C++ API: $(HDF5_DRIVER) $${tname} $(TEST_FLAGS) Test Log" >> $${log};\ + echo "C++ API: Test log for $${tname} $(TEST_FLAGS)" >> $${log};\ fi; \ else \ - echo "Testing $(HDF5_DRIVER) $${tname} $(TEST_FLAGS)"; \ + echo "Testing: $${tname} $(TEST_FLAGS)"; \ if test -n "$(REALTIMEOUTPUT)"; then \ - echo "$(HDF5_DRIVER) $${tname} $(TEST_FLAGS) Test Log" | tee -a $${log}; \ + echo "Test log for $${tname} $(TEST_FLAGS)" | tee -a $${log}; \ else \ - echo "$(HDF5_DRIVER) $${tname} $(TEST_FLAGS) Test Log" >> $${log}; \ + echo "Test log for $${tname} $(TEST_FLAGS)" >> $${log}; \ fi; \ fi; \ if test -n "$(REALTIMEOUTPUT)"; then \ + if test -n "$(HDF5_VOL_CONNECTOR)"; then \ + echo "VOL connector: $(HDF5_VOL_CONNECTOR)" | tee -a $${log}; \ + fi; \ + if test -n "$(HDF5_DRIVER)"; then \ + echo "Virtual file driver (VFD): $(HDF5_DRIVER)" | tee -a $${log}; \ + fi; \ + else \ + if test -n "$(HDF5_VOL_CONNECTOR)"; then \ + echo "VOL connector: $(HDF5_VOL_CONNECTOR)" >> $${log}; \ + fi; \ + if test -n "$(HDF5_DRIVER)"; then \ + echo "Virtual file driver (VFD): $(HDF5_DRIVER)" >> $${log}; \ + fi; \ + fi; \ + if test -n "$(REALTIMEOUTPUT)"; then \ echo "============================" | tee -a $${log}; \ else \ echo "============================" >> $${log}; \ @@ -266,3 +281,15 @@ check-vfd: $(LIB) $(PROGS) $(chk_TESTS) HDF5_DRIVER=$$vfd $(MAKE) $(AM_MAKEFLAGS) check || exit 1; \ fi; \ done + +# Run test with different Virtual Object Layer Connector +check-vol: $(LIB) $(PROGS) $(chk_TESTS) + @for vol in $(VOL_LIST) dummy; do \ + if test "$$vol" != dummy; then \ + echo "============================"; \ + echo "Testing VOL Connector: \"$$vol\""; \ + echo "============================"; \ + $(MAKE) $(AM_MAKEFLAGS) check-clean || exit 1; \ + HDF5_VOL_CONNECTOR="$$vol" $(MAKE) $(AM_MAKEFLAGS) check || exit 1; \ + fi; \ + done diff --git a/examples/CMakeLists.txt b/examples/CMakeLists.txt index 9956b06..2239d64 100644 --- a/examples/CMakeLists.txt +++ b/examples/CMakeLists.txt @@ -37,7 +37,6 @@ set (examples h5_vds-percival h5_vds-percival-unlim h5_vds-percival-unlim-maxmin - h5_vol_external_log_native ) foreach (example ${examples}) diff --git a/examples/CMakeTests.cmake b/examples/CMakeTests.cmake index dd4766a..6b4504b 100644 --- a/examples/CMakeTests.cmake +++ b/examples/CMakeTests.cmake @@ -181,9 +181,9 @@ ### Windows pops up a modal permission dialog on this test if (H5_HAVE_PARALLEL AND NOT WIN32) if (HDF5_ENABLE_USING_MEMCHECKER) - add_test (NAME EXAMPLES-ph5example COMMAND $<TARGET_FILE:ph5example>) + add_test (NAME EXAMPLES_PAR-ph5example COMMAND $<TARGET_FILE:ph5example>) else () - add_test (NAME EXAMPLES-ph5example COMMAND "${CMAKE_COMMAND}" + add_test (NAME EXAMPLES_PAR-ph5example COMMAND "${CMAKE_COMMAND}" -D "TEST_PROGRAM=$<TARGET_FILE:ph5example>" -D "TEST_ARGS:STRING=" -D "TEST_EXPECT=0" @@ -195,14 +195,14 @@ ) endif () if (NOT "${last_test}" STREQUAL "") - set_tests_properties (EXAMPLES-ph5example PROPERTIES DEPENDS ${last_test}) + set_tests_properties (EXAMPLES_PAR-ph5example PROPERTIES DEPENDS ${last_test}) endif () - set (last_test "EXAMPLES-ph5example") + set (last_test "EXAMPLES_PAR-ph5example") if (BUILD_SHARED_LIBS) if (HDF5_ENABLE_USING_MEMCHECKER) - add_test (NAME EXAMPLES-shared-ph5example COMMAND $<TARGET_FILE:ph5example-shared>) + add_test (NAME EXAMPLES_PAR-shared-ph5example COMMAND $<TARGET_FILE:ph5example-shared>) else () - add_test (NAME EXAMPLES-shared-ph5example COMMAND "${CMAKE_COMMAND}" + add_test (NAME EXAMPLES_PAR-shared-ph5example COMMAND "${CMAKE_COMMAND}" -D "TEST_PROGRAM=$<TARGET_FILE:ph5example-shared>" -D "TEST_ARGS:STRING=" -D "TEST_EXPECT=0" @@ -213,10 +213,10 @@ -P "${HDF_RESOURCES_EXT_DIR}/runTest.cmake" ) endif () - set_tests_properties (EXAMPLES-shared-ph5example PROPERTIES WORKING_DIRECTORY ${PROJECT_BINARY_DIR}/H5EX-shared) + set_tests_properties (EXAMPLES_PAR-shared-ph5example PROPERTIES WORKING_DIRECTORY ${PROJECT_BINARY_DIR}/H5EX-shared) if (NOT "${last_test}" STREQUAL "") - set_tests_properties (EXAMPLES-shared-ph5example PROPERTIES DEPENDS ${last_test}) + set_tests_properties (EXAMPLES_PAR-shared-ph5example PROPERTIES DEPENDS ${last_test}) endif () - set (last_test "EXAMPLES-shared-ph5example") + set (last_test "EXAMPLES_PAR-shared-ph5example") endif () endif () diff --git a/examples/Makefile.am b/examples/Makefile.am index ae6c092..554ee44 100644 --- a/examples/Makefile.am +++ b/examples/Makefile.am @@ -37,8 +37,7 @@ EXAMPLE_PROG = h5_write h5_read h5_extend_write h5_chunk_read h5_compound \ h5_group h5_select h5_attribute h5_mount h5_reference h5_drivers \ h5_ref2reg h5_extlink h5_elink_unix2win h5_shared_mesg h5_vds h5_vds-exc \ h5_vds-exclim h5_vds-eiger h5_vds-simpleIO h5_vds-percival \ - h5_vds-percival-unlim h5_vds-percival-unlim-maxmin \ - h5_vol_external_log_native + h5_vds-percival-unlim h5_vds-percival-unlim-maxmin TEST_SCRIPT=testh5cc.sh TEST_EXAMPLES_SCRIPT=$(INSTALL_SCRIPT_FILES) @@ -51,8 +50,7 @@ INSTALL_FILES = h5_write.c h5_read.c h5_extend_write.c h5_chunk_read.c \ h5_reference.c h5_drivers.c h5_extlink.c h5_elink_unix2win.c \ h5_ref2reg.c h5_shared_mesg.c ph5example.c h5_vds.c h5_vds-exc.c \ h5_vds-exclim.c h5_vds-eiger.c h5_vds-simpleIO.c h5_vds-percival.c \ - h5_vds-percival-unlim.c h5_vds-percival-unlim-maxmin.c \ - h5_vol_external_log_native.c + h5_vds-percival-unlim.c h5_vds-percival-unlim-maxmin.c @@ -129,7 +127,6 @@ h5_vds-simpleIO: $(srcdir)/h5_vds-simpleIO.c h5_vds-percival: $(srcdir)/h5_vds-percival.c h5_vds-percival-unlim: $(srcdir)/h5_vds-percival-unlim.c h5_vds-percival-unlim-maxmin: $(srcdir)/h5_vds-percival-unlim-maxmin.c -h5_vol_external_log_native: $(srcdir)/h5_vol_external_log_native.c if BUILD_SHARED_SZIP_CONDITIONAL LD_LIBRARY_PATH=$(LL_PATH) diff --git a/examples/h5_extlink.c b/examples/h5_extlink.c index 1a07656..229e465 100644 --- a/examples/h5_extlink.c +++ b/examples/h5_extlink.c @@ -208,7 +208,7 @@ static void extlink_prefix_example(void) * that a path was supplied in the udata. */ static hid_t UD_soft_traverse(const char *link_name, hid_t cur_group, - const void *udata, size_t udata_size, hid_t lapl_id); + const void *udata, size_t udata_size, hid_t lapl_id, hid_t dxpl_id); static void soft_link_example(void) { @@ -277,7 +277,7 @@ static void soft_link_example(void) */ static hid_t UD_soft_traverse(const char *link_name, hid_t cur_group, - const void *udata, size_t udata_size, hid_t lapl_id) + const void *udata, size_t udata_size, hid_t lapl_id, hid_t dxpl_id) { const char *target = (const char *) udata; hid_t ret_value; diff --git a/examples/h5_vol_external_log_native.c b/examples/h5_vol_external_log_native.c deleted file mode 100644 index 616214d..0000000 --- a/examples/h5_vol_external_log_native.c +++ /dev/null @@ -1,489 +0,0 @@ - -#include <stdio.h> -#include <stdlib.h> -#include <assert.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_driver_id = -1; - -static const H5VL_class_t H5VL_log_g = { - 0, - LOG, - "log", /* 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; - -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_driver_name(oid, n, 50); - printf ("Visiting GROUP VOL name = %s %lu\n", n, (unsigned long)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 file_name[]="large_dataset.h5"; - 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 attr; - hid_t space; - const unsigned int nelem=60; - int *data; - unsigned int i; - hsize_t dims[1]; - ssize_t len; - char name[25]; - static hsize_t ds_size[2] = {10, 20}; - - under_fapl = H5Pcreate(H5P_FILE_ACCESS); - H5Pset_fapl_native(under_fapl); - assert(H5VLis_driver_registered("native") == 1); - - vol_id = H5VLregister_driver(&H5VL_log_g); - assert(vol_id > 0); - assert(H5VLis_driver_registered("log") == 1); - - vol_id2 = H5VLget_driver_id("log"); - H5VLinitialize(vol_id2, H5P_DEFAULT); - H5VLclose(vol_id2); - - native_driver_id = H5VLget_driver_id("native"); - assert(native_driver_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_driver_name(file_id, name, 25); - printf("FILE VOL name = %s %lu\n", name, (unsigned long)len); - - group_id = H5Gcreate2(file_id, group_name, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT); - len = H5VLget_driver_name(group_id, name, 50); - printf("GROUP VOL name = %s %lu\n", name, (unsigned long)len); - - int_id = H5Tcopy(H5T_NATIVE_INT); - H5Tcommit2(file_id, "int", int_id, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT); - len = H5VLget_driver_name(int_id, name, 50); - printf("DT COMMIT name = %s %lu\n", name, (unsigned long)len); - H5Tclose(int_id); - - int_id = H5Topen2(file_id, "int", H5P_DEFAULT); - len = H5VLget_driver_name(int_id, name, 50); - printf("DT OPEN name = %s %lu\n", name, (unsigned long)len); - H5Tclose(int_id); - - int_id = H5Oopen(file_id,"int",H5P_DEFAULT); - len = H5VLget_driver_name(int_id, name, 50); - printf("DT OPEN name = %s %lu\n", name, (unsigned long)len); - - len = H5Fget_name(file_id, name, 50); - printf("name = %lu %s\n", (unsigned long)len, name); - - data = malloc(sizeof(int)*nelem); - for(i = 0; i < nelem; ++i) - data[i] = i; - - dims [0] = 60; - dataspaceId = H5Screate_simple(1, dims, NULL); - space = H5Screate_simple (2, ds_size, ds_size); - - sprintf(fullpath,"%s/%s",group_name,dataset_name); - datasetId = H5Dcreate2(file_id,fullpath,H5T_NATIVE_INT,dataspaceId,H5P_DEFAULT,H5P_DEFAULT,H5P_DEFAULT); - H5Sclose(dataspaceId); - - len = H5VLget_driver_name(datasetId, name, 50); - printf ("DSET name = %s %lu\n", name, (unsigned long)len); - - H5Dwrite(datasetId, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, H5P_DEFAULT, data); - H5Dclose(datasetId); - - H5Ovisit2(file_id, H5_INDEX_NAME, H5_ITER_NATIVE, visit_cb, NULL, H5O_INFO_ALL); - - free(data); - H5Oclose(int_id); - H5Sclose (space); - H5Gclose(group_id); - H5Fclose(file_id); - H5Pclose(acc_tpl); - H5Pclose(under_fapl); - - H5VLclose(native_driver_id); - H5VLterminate(vol_id, H5P_DEFAULT); - H5VLunregister_driver(vol_id); - assert(H5VLis_driver_registered("log") == 0); - - return EXIT_SUCCESS; -} - -static herr_t -H5VL_log_init(hid_t vipl_id) -{ - printf("------- LOG INIT\n"); - return 1; -} - -static herr_t -H5VL_log_term(hid_t vtpl_id) -{ - printf("------- LOG TERM\n"); - return 1; -} - -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; - - 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_driver_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_driver_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_driver_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_driver_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_driver_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_driver_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_driver_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_driver_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_driver_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_driver_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_driver_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_driver_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_driver_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_driver_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_driver_id, dxpl_id, req); - free(d); - - printf("------- LOG H5Dclose\n"); - return 1; -} - diff --git a/examples/run-c-ex.sh.in b/examples/run-c-ex.sh.in index 6ff2e9a..209cdd7 100644 --- a/examples/run-c-ex.sh.in +++ b/examples/run-c-ex.sh.in @@ -139,9 +139,7 @@ then RunTest h5_vds-percival-unlim-maxmin&&\ rm h5_vds-percival-unlim-maxmin &&\ RunTest h5_vds &&\ - rm h5_vds &&\ - RunTest h5_vol_external_log_native &&\ - rm h5_vol_external_log_native); then + rm h5_vds); then EXIT_VALUE=${EXIT_SUCCESS} else EXIT_VALUE=${EXIT_FAILURE} diff --git a/hl/tools/h5watch/CMakeTests.cmake b/hl/tools/h5watch/CMakeTests.cmake index 0b7b4d4..13d5e47 100644 --- a/hl/tools/h5watch/CMakeTests.cmake +++ b/hl/tools/h5watch/CMakeTests.cmake @@ -18,16 +18,16 @@ set (H5WATCH_TEST_FILES w-help1.ddl - w-err-cmpd1.ddl - w-err-cmpd2.ddl - w-err-cmpd3.ddl - w-err-cmpd4.ddl - w-err-cmpd5.ddl - w-err-dset1.ddl - w-err-dset2.ddl - w-err-dset-nomax.ddl - w-err-dset-none.ddl - w-err-file.ddl + w-err-cmpd1.err + w-err-cmpd2.err + w-err-cmpd3.err + w-err-cmpd4.err + w-err-cmpd5.err + w-err-dset1.err + w-err-dset2.err + w-err-dset-nomax.err + w-err-dset-none.err + w-err-file.err w-err-poll.ddl w-err-poll0.ddl w-err-width.ddl @@ -86,6 +86,25 @@ add_custom_target(H5WATCH_files ALL COMMENT "Copying files needed by H5WATCH tes endif () endmacro () + macro (ADD_H5_ERR_TEST resultfile resultcode) + if (NOT HDF5_ENABLE_USING_MEMCHECKER) + add_test ( + NAME H5WATCH_ARGS-h5watch-${resultfile} + COMMAND "${CMAKE_COMMAND}" + -D "TEST_PROGRAM=$<TARGET_FILE:h5watch>" + -D "TEST_ARGS:STRING=${ARGN}" + -D "TEST_FOLDER=${PROJECT_BINARY_DIR}/testfiles" + -D "TEST_OUTPUT=${resultfile}.out" + -D "TEST_EXPECT=${resultcode}" + -D "TEST_REFERENCE=${resultfile}.mty" + -D "TEST_ERRREF=${resultfile}.err" + -P "${HDF_RESOURCES_EXT_DIR}/runTest.cmake" + ) + set_tests_properties (H5WATCH_ARGS-h5watch-${resultfile} PROPERTIES DEPENDS ${last_test}) + set (last_test "H5WATCH_ARGS-h5watch-${resultfile}") + endif () + endmacro () + macro (ADD_H5_WATCH resultfile resultcode) if (NOT HDF5_ENABLE_USING_MEMCHECKER) add_test ( @@ -162,20 +181,20 @@ if (NOT SWMR_INCOMPAT) ADD_H5_TEST (w-help1 0 --help) # # Tests on expected failures - ADD_H5_TEST (w-err-dset1 1 WATCH.h5) - ADD_H5_TEST (w-err-dset2 1 WATCH.h5/group/DSET_CMPD) - ADD_H5_TEST (w-err-dset-none 1 WATCH.h5/DSET_NONE) - ADD_H5_TEST (w-err-dset-nomax 1 WATCH.h5/DSET_NOMAX) - ADD_H5_TEST (w-err-file 1 ../WATCH.h5/DSET_CMPD) + ADD_H5_ERR_TEST (w-err-dset1 1 WATCH.h5) + ADD_H5_ERR_TEST (w-err-dset2 1 WATCH.h5/group/DSET_CMPD) + ADD_H5_ERR_TEST (w-err-dset-none 1 WATCH.h5/DSET_NONE) + ADD_H5_ERR_TEST (w-err-dset-nomax 1 WATCH.h5/DSET_NOMAX) + ADD_H5_ERR_TEST (w-err-file 1 ../WATCH.h5/DSET_CMPD) ADD_H5_TEST (w-err-width 1 --width=-8 WATCH.h5/DSET_ONE) ADD_H5_TEST (w-err-poll 1 --polling=-8 WATCH.h5/DSET_ONE) ADD_H5_TEST (w-err-poll0 1 --polling=0 WATCH.h5/DSET_ONE) # # Tests on invalid field names via --fields option for a compound typed dataset: DSET_CMPD - ADD_H5_TEST (w-err-cmpd1 1 --fields=fieldx WATCH.h5/DSET_CMPD) - ADD_H5_TEST (w-err-cmpd2 1 --fields=field1,field2. WATCH.h5/DSET_CMPD) - ADD_H5_TEST (w-err-cmpd3 1 --fields=field1,field2, WATCH.h5/DSET_CMPD) - ADD_H5_TEST (w-err-cmpd4 1 --fields=field1,field2.b.k WATCH.h5/DSET_CMPD) - ADD_H5_TEST (w-err-cmpd5 1 --fields=field1 --fields=field2.b.k WATCH.h5/DSET_CMPD) + ADD_H5_ERR_TEST (w-err-cmpd1 1 --fields=fieldx WATCH.h5/DSET_CMPD) + ADD_H5_ERR_TEST (w-err-cmpd2 1 --fields=field1,field2. WATCH.h5/DSET_CMPD) + ADD_H5_ERR_TEST (w-err-cmpd3 1 --fields=field1,field2, WATCH.h5/DSET_CMPD) + ADD_H5_ERR_TEST (w-err-cmpd4 1 --fields=field1,field2.b.k WATCH.h5/DSET_CMPD) + ADD_H5_ERR_TEST (w-err-cmpd5 1 --fields=field1 --fields=field2.b.k WATCH.h5/DSET_CMPD) # endif () diff --git a/hl/tools/h5watch/testh5watch.sh.in b/hl/tools/h5watch/testh5watch.sh.in index 3f8f5ae..d31bcc3 100644 --- a/hl/tools/h5watch/testh5watch.sh.in +++ b/hl/tools/h5watch/testh5watch.sh.in @@ -32,19 +32,19 @@ fi #echo #exit 0 -H5WATCH=h5watch # The tool name -H5WATCH_BIN=`pwd`/$H5WATCH # The path of H5WATCH -EXTEND_DSET=extend_dset # Routine to extend the dataset when watching -EXTEND_BIN=`pwd`/$EXTEND_DSET # The path of EXTEND_DSET +H5WATCH=h5watch # The tool name +H5WATCH_BIN=`pwd`/$H5WATCH # The path of H5WATCH +EXTEND_DSET=extend_dset # Routine to extend the dataset when watching +EXTEND_BIN=`pwd`/$EXTEND_DSET # The path of EXTEND_DSET # EXIT_SUCCESS=0 EXIT_FAILURE=1 # -GEN_TEST=h5watchgentest # Generate HDF5 file with various datasets -GEN_TEST_BIN=`pwd`/$GEN_TEST # Path of the binary GEN_TEST +GEN_TEST=h5watchgentest # Generate HDF5 file with various datasets +GEN_TEST_BIN=`pwd`/$GEN_TEST # Path of the binary GEN_TEST WATCHFILE=`pwd`/WATCH.h5 # The HDF5 file generated to test h5watch TESTFILE=TEST.h5 # The temporary file (a copy of WATCH.h5) used by tests -TRY_MAX=30 # Try running the test again +TRY_MAX=30 # Try running the test again # # These 3 defines should be the same as the defines in ./extend_dset.c WRITER_MESSAGE=writer_message # The message file created by the "extend" process @@ -53,7 +53,7 @@ MESSAGE_TIMEOUT=300 # Message timeout length in secs # CMP='cmp -s' DIFF='diff -c' -NLINES=20 # Max. lines of output to display if test fails +NLINES=20 # Max. lines of output to display if test fails # # Mac OS: just to make sure echo "backslash backslash" behaves properly if test `uname -s` = 'Darwin'; then @@ -83,9 +83,9 @@ TESTING() { # Overall algorithm: # # Run a test and print PASSED or FAILED -# If a test did not return with the expected return code, +# If a test did not return with the expected return code, # increment the `nerrors' global variable and (if $verbose is set) display up to $NLINES -# lines of the actual output from the test. +# lines of the actual output from the test. # If the test did return the expected code, # compare the actual output with the expected output; # If the outputs are the same, print PASSED, @@ -137,7 +137,54 @@ TOOLTEST() { # Clean up output file if test -z "$HDF5_NOCLEANUP"; then - rm -f $actual $actual_err + rm -f $actual $actual_err + fi +} +# +# TOOLTEST_ERR(): +# same as toolset only compare error file +# +# Arguments: +# +# $1 -- expected output +# $2 -- expected return code +# $3 and on -- arguments for h5watch +TOOLTEST_ERR() { + expect="$srcdir/../testfiles/$1" + expect_err="$srcdir/../testfiles/`basename $1 .ddl`.err" + actual="../testfiles/`basename $1 .ddl`.out" + actual_err="../testfiles/`basename $1 .ddl`.out.err" + shift + retvalexpect=$1 + shift + # Run test. + TESTING $H5WATCH $@ + ( + $RUNSERIAL $H5WATCH_BIN "$@" + ) > $actual 2>$actual_err + exitcode=$? + if [ $exitcode -ne $retvalexpect ]; then + $ECHO "*FAILED*" + nerrors="`expr $nerrors + 1`" + if [ yes = "$verbose" ]; then + $ECHO "test returned with exit code $exitcode" + $ECHO "test output: (up to $NLINES lines)" + head -$NLINES $actual + $ECHO "***end of test output***" + $ECHO "" + fi + elif $CMP $expect_err $actual_err; then + $ECHO " PASSED" + else + $ECHO "*FAILED*" + $ECHO " Expected result differs from actual result" + nerrors="`expr $nerrors + 1`" + test yes = "$verbose" && $DIFF $expect_err $actual_err |sed 's/^/ /' + fi + + # Clean up output file + if test -z "$HDF5_NOCLEANUP"; then + rm -f $actual $actual_err fi } @@ -176,15 +223,15 @@ do # Wait for message from "extend_dset" process to start h5watch-- # To wait for the writer message file or till the maximum # of seconds is reached # This performs similar function as the routine h5_wait_message() in test/h5test.c - mexist=0 # Indicate whether the message file is found - t0=`date +%s` # Get current time in seconds - difft=0 # Initialize the time difference - while [ $difft -lt $MESSAGE_TIMEOUT ] ; # Loop till message times out + mexist=0 # Indicate whether the message file is found + t0=`date +%s` # Get current time in seconds + difft=0 # Initialize the time difference + while [ $difft -lt $MESSAGE_TIMEOUT ] ; # Loop till message times out do - t1=`date +%s` # Get current time in seconds - difft=`expr $t1 - $t0` # Calculate the time difference + t1=`date +%s` # Get current time in seconds + difft=`expr $t1 - $t0` # Calculate the time difference if [ -e $WRITER_MESSAGE ]; then # If message file is found: - mexist=1 # indicate the message file is found + mexist=1 # indicate the message file is found rm $WRITER_MESSAGE # remove the message file break # get out of the while loop fi @@ -211,8 +258,8 @@ do wait $extend_pid # Wait for "extend" process to complete extend_exit=$? # Collect "extend" process' exit code sleep 1 # Sleep to make sure output is flushed - kill $watch_pid # Kill h5watch - wait $watch_pid # Wait for "h5watch" process to complete + kill $watch_pid # Kill h5watch + wait $watch_pid # Wait for "h5watch" process to complete # if [ $extend_exit -ne 0 ]; then # Error returned from "extend" process $ECHO "*FAILED*" @@ -265,7 +312,7 @@ done; # DSET_ONE: one-dimensional dataset # # DSET_TWO: two-dimensional dataset # # DSET_CMPD: one-dimensional dataset with compound type # -# DSET_CMPD_ESC: one-dimensional dataset with compound type & escape/separator characters # +# DSET_CMPD_ESC: one-dimensional dataset with compound type & escape/separator characters # # DSET_CMPD_TWO: two-dimensional dataset with compound type # # # # The following datasets are one-dimensional, chunked, max. dimension setting: # @@ -282,11 +329,11 @@ done; ################################################################################################# # # # Tests on expected failures: # -# Invalid file name # -# Unable to find dataset, invalid dataset # -# DSET_NONE and DSET_NOMAX # -# Invalid input to options --width and --polling # -# Invalid field names for -f option # +# Invalid file name # +# Unable to find dataset, invalid dataset # +# DSET_NONE and DSET_NOMAX # +# Invalid input to options --width and --polling # +# Invalid field names for -f option # # # ################################################################################################# # @@ -296,21 +343,21 @@ $GEN_TEST_BIN TOOLTEST w-help1.ddl 0 --help # # Tests on expected failures -TOOLTEST w-err-dset1.ddl 1 WATCH.h5 -TOOLTEST w-err-dset2.ddl 1 WATCH.h5/group/DSET_CMPD -TOOLTEST w-err-dset-none.ddl 1 WATCH.h5/DSET_NONE -TOOLTEST w-err-dset-nomax.ddl 1 WATCH.h5/DSET_NOMAX -TOOLTEST w-err-file.ddl 1 ../WATCH.h5/DSET_CMPD +TOOLTEST_ERR w-err-dset1.ddl 1 WATCH.h5 +TOOLTEST_ERR w-err-dset2.ddl 1 WATCH.h5/group/DSET_CMPD +TOOLTEST_ERR w-err-dset-none.ddl 1 WATCH.h5/DSET_NONE +TOOLTEST_ERR w-err-dset-nomax.ddl 1 WATCH.h5/DSET_NOMAX +TOOLTEST_ERR w-err-file.ddl 1 ../WATCH.h5/DSET_CMPD TOOLTEST w-err-width.ddl 1 --width=-8 WATCH.h5/DSET_ONE TOOLTEST w-err-poll.ddl 1 --polling=-8 WATCH.h5/DSET_ONE TOOLTEST w-err-poll0.ddl 1 --polling=0 WATCH.h5/DSET_ONE # # Tests on invalid field names via --fields option for a compound typed dataset: DSET_CMPD -TOOLTEST w-err-cmpd1.ddl 1 --fields=fieldx WATCH.h5/DSET_CMPD -TOOLTEST w-err-cmpd2.ddl 1 --fields=field1,field2. WATCH.h5/DSET_CMPD -TOOLTEST w-err-cmpd3.ddl 1 --fields=field1,field2, WATCH.h5/DSET_CMPD -TOOLTEST w-err-cmpd4.ddl 1 --fields=field1,field2.b.k WATCH.h5/DSET_CMPD -TOOLTEST w-err-cmpd5.ddl 1 --fields=field1 --fields=field2.b.k WATCH.h5/DSET_CMPD +TOOLTEST_ERR w-err-cmpd1.ddl 1 --fields=fieldx WATCH.h5/DSET_CMPD +TOOLTEST_ERR w-err-cmpd2.ddl 1 --fields=field1,field2. WATCH.h5/DSET_CMPD +TOOLTEST_ERR w-err-cmpd3.ddl 1 --fields=field1,field2, WATCH.h5/DSET_CMPD +TOOLTEST_ERR w-err-cmpd4.ddl 1 --fields=field1,field2.b.k WATCH.h5/DSET_CMPD +TOOLTEST_ERR w-err-cmpd5.ddl 1 --fields=field1 --fields=field2.b.k WATCH.h5/DSET_CMPD # echo "DONE WITH 1st SET OF TESTS" # diff --git a/hl/tools/testfiles/w-err-cmpd4.ddl b/hl/tools/testfiles/w-err-cmpd1.err index 775d6a0..9c165fb 100644 --- a/hl/tools/testfiles/w-err-cmpd4.ddl +++ b/hl/tools/testfiles/w-err-cmpd1.err @@ -1,2 +1 @@ -Opened "WATCH.h5" with sec2 driver. h5watch error: error in processing <list_of_fields> diff --git a/hl/tools/testfiles/w-err-cmpd1.ddl b/hl/tools/testfiles/w-err-cmpd2.err index 775d6a0..9c165fb 100644 --- a/hl/tools/testfiles/w-err-cmpd1.ddl +++ b/hl/tools/testfiles/w-err-cmpd2.err @@ -1,2 +1 @@ -Opened "WATCH.h5" with sec2 driver. h5watch error: error in processing <list_of_fields> diff --git a/hl/tools/testfiles/w-err-cmpd2.ddl b/hl/tools/testfiles/w-err-cmpd3.err index 775d6a0..9c165fb 100644 --- a/hl/tools/testfiles/w-err-cmpd2.ddl +++ b/hl/tools/testfiles/w-err-cmpd3.err @@ -1,2 +1 @@ -Opened "WATCH.h5" with sec2 driver. h5watch error: error in processing <list_of_fields> diff --git a/hl/tools/testfiles/w-err-cmpd3.ddl b/hl/tools/testfiles/w-err-cmpd4.err index 775d6a0..9c165fb 100644 --- a/hl/tools/testfiles/w-err-cmpd3.ddl +++ b/hl/tools/testfiles/w-err-cmpd4.err @@ -1,2 +1 @@ -Opened "WATCH.h5" with sec2 driver. h5watch error: error in processing <list_of_fields> diff --git a/hl/tools/testfiles/w-err-cmpd5.err b/hl/tools/testfiles/w-err-cmpd5.err new file mode 100644 index 0000000..9c165fb --- /dev/null +++ b/hl/tools/testfiles/w-err-cmpd5.err @@ -0,0 +1 @@ +h5watch error: error in processing <list_of_fields> diff --git a/hl/tools/testfiles/w-err-dset-nomax.ddl b/hl/tools/testfiles/w-err-dset-nomax.err index b99cf84..fd5ca7e 100644 --- a/hl/tools/testfiles/w-err-dset-nomax.ddl +++ b/hl/tools/testfiles/w-err-dset-nomax.err @@ -1,2 +1 @@ -Opened "WATCH.h5" with sec2 driver. h5watch error: "/DSET_NOMAX" should have unlimited or max. dimension setting diff --git a/hl/tools/testfiles/w-err-dset-none.ddl b/hl/tools/testfiles/w-err-dset-none.err index cbf6770..db781c3 100644 --- a/hl/tools/testfiles/w-err-dset-none.ddl +++ b/hl/tools/testfiles/w-err-dset-none.err @@ -1,2 +1 @@ -Opened "WATCH.h5" with sec2 driver. h5watch error: "/DSET_NONE" should be a chunked or virtual dataset diff --git a/hl/tools/testfiles/w-err-dset1.ddl b/hl/tools/testfiles/w-err-dset1.err index 433c4d6..d6b2a6e 100644 --- a/hl/tools/testfiles/w-err-dset1.ddl +++ b/hl/tools/testfiles/w-err-dset1.err @@ -1,2 +1 @@ -Opened "WATCH.h5" with sec2 driver. h5watch error: no dataset specified diff --git a/hl/tools/testfiles/w-err-dset2.ddl b/hl/tools/testfiles/w-err-dset2.err index 81b52de..3f77ec8 100644 --- a/hl/tools/testfiles/w-err-dset2.ddl +++ b/hl/tools/testfiles/w-err-dset2.err @@ -1,2 +1 @@ -Opened "WATCH.h5" with sec2 driver. h5watch error: unable to open dataset "/group/DSET_CMPD" diff --git a/hl/tools/testfiles/w-err-file.ddl b/hl/tools/testfiles/w-err-file.err index 015661f..015661f 100644 --- a/hl/tools/testfiles/w-err-file.ddl +++ b/hl/tools/testfiles/w-err-file.err diff --git a/hl/tools/testfiles/w-err-cmpd5.ddl b/hl/tools/testfiles/w-err-std.ddl index 775d6a0..775d6a0 100644 --- a/hl/tools/testfiles/w-err-cmpd5.ddl +++ b/hl/tools/testfiles/w-err-std.ddl diff --git a/java/src/hdf/hdf5lib/H5.java b/java/src/hdf/hdf5lib/H5.java index f9f9b65..e354207 100644 --- a/java/src/hdf/hdf5lib/H5.java +++ b/java/src/hdf/hdf5lib/H5.java @@ -499,9 +499,9 @@ public class H5 implements java.io.Serializable { private synchronized static native boolean H5is_library_threadsafe(); // /////// unimplemented //////// - // H5_DLL herr_t H5free_memory(void *mem); - // H5_DLL void *H5allocate_memory(size_t size, hbool_t clear); - // H5_DLL void *H5resize_memory(void *mem, size_t size); + // herr_t H5free_memory(void *mem); + // void *H5allocate_memory(size_t size, hbool_t clear); + // void *H5resize_memory(void *mem, size_t size); // //////////////////////////////////////////////////////////// // // @@ -852,7 +852,8 @@ public class H5 implements java.io.Serializable { * @exception HDF5LibraryException * - Error from the HDF-5 Library. **/ - public static long H5Aget_space(long attr_id) throws HDF5LibraryException { + public static long H5Aget_space(long attr_id) throws HDF5LibraryException + { long id = _H5Aget_space(attr_id); if (id > 0) { log.trace("OPEN_IDS: H5Aget_space add {}", id); @@ -888,7 +889,8 @@ public class H5 implements java.io.Serializable { * @exception HDF5LibraryException * - Error from the HDF-5 Library. **/ - public static long H5Aget_type(long attr_id) throws HDF5LibraryException { + public static long H5Aget_type(long attr_id) throws HDF5LibraryException + { long id = _H5Aget_type(attr_id); if (id > 0) { log.trace("OPEN_IDS: H5Aget_type add {}", id); @@ -918,8 +920,9 @@ public class H5 implements java.io.Serializable { * @exception NullPointerException * - Name is null. **/ - public static long H5Aopen(long obj_id, String attr_name, long aapl_id) throws HDF5LibraryException, - NullPointerException { + public static long H5Aopen(long obj_id, String attr_name, long aapl_id) + throws HDF5LibraryException, NullPointerException + { long id = _H5Aopen(obj_id, attr_name, aapl_id); if (id > 0) { log.trace("OPEN_IDS: H5Aopen add {}", id); @@ -959,7 +962,8 @@ public class H5 implements java.io.Serializable { * - Name is null. **/ public static long H5Aopen_by_idx(long loc_id, String obj_name, int idx_type, int order, long n, long aapl_id, - long lapl_id) throws HDF5LibraryException, NullPointerException { + long lapl_id) throws HDF5LibraryException, NullPointerException + { long id = _H5Aopen_by_idx(loc_id, obj_name, idx_type, order, n, aapl_id, lapl_id); if (id > 0) { log.trace("OPEN_IDS: H5Aopen_by_idx add {}", id); @@ -994,7 +998,8 @@ public class H5 implements java.io.Serializable { * - obj_name is null. **/ public static long H5Aopen_by_name(long loc_id, String obj_name, String attr_name, long aapl_id, long lapl_id) - throws HDF5LibraryException, NullPointerException { + throws HDF5LibraryException, NullPointerException + { long id = _H5Aopen_by_name(loc_id, obj_name, attr_name, aapl_id, lapl_id); if (id > 0) { log.trace("OPEN_IDS: H5Aopen_by_name add {}", id); @@ -1015,8 +1020,10 @@ public class H5 implements java.io.Serializable { * IN: Identifier of an attribute to read. * @param mem_type_id * IN: Identifier of the attribute datatype (in memory). - * @param buf - * IN: Buffer for data to be read. + * @param obj + * Buffer to store data read from the file. + * @param isCriticalPinning + * request lock on data reference. * * @return a non-negative value if successful * @@ -1025,9 +1032,19 @@ public class H5 implements java.io.Serializable { * @exception NullPointerException * - data buffer is null. **/ - public synchronized static native int H5Aread(long attr_id, long mem_type_id, byte[] buf) + public synchronized static native int H5Aread(long attr_id, long mem_type_id, byte[] obj, boolean isCriticalPinning) throws HDF5LibraryException, NullPointerException; + public synchronized static int H5Aread(long attr_id, long mem_type_id, byte[] buf) throws HDF5LibraryException, NullPointerException + { + return H5Aread(attr_id, mem_type_id, buf, true); + } + + public synchronized static int H5Aread(long attr_id, long mem_type_id, Object obj) throws HDF5Exception, HDF5LibraryException, NullPointerException + { + return H5Aread(attr_id, mem_type_id, obj, true); + } + /** * H5Aread reads an attribute, specified with attr_id. The attribute's memory datatype is specified with * mem_type_id. The entire attribute is read into data object from the file. @@ -1038,31 +1055,143 @@ public class H5 implements java.io.Serializable { * IN: Identifier of the attribute datatype (in memory). * @param obj * IN: Object for data to be read. + * @param isCriticalPinning + * request lock on data reference. * * @return a non-negative value if successful * + * @exception HDF5Exception + * - Failure in the data conversion. * @exception HDF5LibraryException * - Error from the HDF-5 Library. * @exception NullPointerException * - data buffer is null. See public synchronized static native int H5Aread( ) **/ - public synchronized static int H5Aread(long attr_id, long mem_type_id, Object obj) throws HDF5Exception, - NullPointerException { - HDFArray theArray = new HDFArray(obj); - byte[] buf = theArray.emptyBytes(); + public synchronized static int H5Aread(long attr_id, long mem_type_id, Object obj, boolean isCriticalPinning) + throws HDF5Exception, HDF5LibraryException, NullPointerException + { + int status = -1; + boolean is1D = false; - // This will raise an exception if there is an error - int status = H5Aread(attr_id, mem_type_id, buf); + Class dataClass = obj.getClass(); + if (!dataClass.isArray()) { + throw (new HDF5JavaException("H5Aread: data is not an array")); + } - // No exception: status really ought to be OK - if (status >= 0) { - obj = theArray.arrayify(buf); + String cname = dataClass.getName(); + is1D = (cname.lastIndexOf('[') == cname.indexOf('[')); + char dname = cname.charAt(cname.lastIndexOf("[") + 1); + log.trace("H5Aread: cname={} is1D={} dname={}", cname, is1D, dname); + + if (is1D && (dname == 'B')) { + log.trace("H5Aread_dname_B"); + status = H5Aread(attr_id, mem_type_id, (byte[]) obj, isCriticalPinning); + } + else if (is1D && (dname == 'S')) { + log.trace("H5Aread_dname_S"); + status = H5Aread_short(attr_id, mem_type_id, (short[]) obj, isCriticalPinning); + } + else if (is1D && (dname == 'I')) { + log.trace("H5Aread_dname_I"); + status = H5Aread_int(attr_id, mem_type_id, (int[]) obj, isCriticalPinning); + } + else if (is1D && (dname == 'J')) { + log.trace("H5Aread_dname_J"); + status = H5Aread_long(attr_id, mem_type_id, (long[]) obj, isCriticalPinning); + } + else if (is1D && (dname == 'F')) { + log.trace("H5Aread_dname_F"); + status = H5Aread_float(attr_id, mem_type_id, (float[]) obj, isCriticalPinning); + } + else if (is1D && (dname == 'D')) { + log.trace("H5Aread_dname_D"); + status = H5Aread_double(attr_id, mem_type_id, (double[]) obj, isCriticalPinning); + } + else if ((H5.H5Tdetect_class(mem_type_id, HDF5Constants.H5T_REFERENCE) && (is1D && (dataClass.getComponentType() == String.class))) || H5.H5Tequal(mem_type_id, HDF5Constants.H5T_STD_REF_DSETREG)) { + log.trace("H5Aread_reg_ref"); + status = H5Aread_reg_ref(attr_id, mem_type_id, (String[]) obj); + } + else if (is1D && (dataClass.getComponentType() == String.class)) { + log.trace("H5Aread_string type"); + status = H5Aread_string(attr_id, mem_type_id, (String[]) obj); + } + else { + // Create a data buffer to hold the data into a Java Array + HDFArray theArray = new HDFArray(obj); + byte[] buf = theArray.emptyBytes(); + log.trace("H5Aread_else"); + + // This will raise an exception if there is an error + status = H5Aread(attr_id, mem_type_id, buf, isCriticalPinning); + + // No exception: status really ought to be OK + if (status >= 0) { + obj = theArray.arrayify(buf); + } + + // clean up these: assign 'null' as hint to gc() + buf = null; + theArray = null; } return status; } - public synchronized static native int H5AreadVL(long attr_id, long mem_type_id, String[] buf) + public synchronized static native int H5Aread_double(long attr_id, long mem_type_id, double[] buf, boolean isCriticalPinning) + throws HDF5LibraryException, NullPointerException; + + public synchronized static int H5Aread_double(long attr_id, long mem_type_id, double[] buf) + throws HDF5LibraryException, NullPointerException + { + return H5Aread_double(attr_id, mem_type_id, buf, true); + } + + public synchronized static native int H5Aread_float(long attr_id, long mem_type_id, float[] buf, boolean isCriticalPinning) + throws HDF5LibraryException, NullPointerException; + + public synchronized static int H5Aread_float(long attr_id, long mem_type_id, float[] buf) + throws HDF5LibraryException, NullPointerException + { + return H5Aread_float(attr_id, mem_type_id, buf, true); + } + + public synchronized static native int H5Aread_int(long attr_id, long mem_type_id, int[] buf, boolean isCriticalPinning) + throws HDF5LibraryException, NullPointerException; + + public synchronized static int H5Aread_int(long attr_id, long mem_type_id, int[] buf) + throws HDF5LibraryException, NullPointerException + { + return H5Aread_int(attr_id, mem_type_id, buf, true); + } + + public synchronized static native int H5Aread_long(long attr_id, long mem_type_id, long[] buf, boolean isCriticalPinning) + throws HDF5LibraryException, NullPointerException; + + public synchronized static int H5Aread_long(long attr_id, long mem_type_id, long[] buf) + throws HDF5LibraryException, NullPointerException + { + return H5Aread_long(attr_id, mem_type_id, buf, true); + } + + public synchronized static native int H5Aread_reg_ref(long attr_id, long mem_type_id, String[] buf) + throws HDF5LibraryException, NullPointerException; + + public synchronized static native int H5Aread_short(long attr_id, long mem_type_id, short[] buf, boolean isCriticalPinning) + throws HDF5LibraryException, NullPointerException; + + public synchronized static int H5Aread_short(long attr_id, long mem_type_id, short[] buf) + throws HDF5LibraryException, NullPointerException + { + return H5Aread_short(attr_id, mem_type_id, buf, true); + } + + public synchronized static native int H5AreadVL(long attr_id, long mem_type_id, Object[] buf) + throws HDF5LibraryException, NullPointerException; + + public synchronized static native int H5Aread_string(long attr_id, long mem_type_id, String[] buf) + throws HDF5LibraryException, NullPointerException; + + public synchronized static native int H5Aread_VLStrings(long attr_id, long mem_type_id, Object[] buf) throws HDF5LibraryException, NullPointerException; public synchronized static native int H5AreadComplex(long attr_id, long mem_type_id, String[] buf) @@ -1123,7 +1252,9 @@ public class H5 implements java.io.Serializable { * @param mem_type_id * IN: Identifier of the attribute datatype (in memory). * @param buf - * IN: Data to be written. + * IN: Buffer with data to be written to the file. + * @param isCriticalPinning + * IN: request lock on data reference. * * @return a non-negative value if successful * @@ -1132,9 +1263,21 @@ public class H5 implements java.io.Serializable { * @exception NullPointerException * - data is null. **/ - public synchronized static native int H5Awrite(long attr_id, long mem_type_id, byte[] buf) + public synchronized static native int H5Awrite(long attr_id, long mem_type_id, byte[] buf, boolean isCriticalPinning) throws HDF5LibraryException, NullPointerException; + public synchronized static int H5Awrite(long attr_id, long mem_type_id, byte[] buf) + throws HDF5LibraryException, NullPointerException + { + return H5Awrite(attr_id, mem_type_id, buf, true); + } + + public synchronized static int H5Awrite(long attr_id, long mem_type_id, Object obj) + throws HDF5Exception, HDF5LibraryException, NullPointerException + { + return H5Awrite(attr_id, mem_type_id, obj, true); + } + /** * H5Awrite writes an attribute, specified with attr_id. The attribute's memory datatype is specified with * mem_type_id. The entire attribute is written from data object to the file. @@ -1145,28 +1288,140 @@ public class H5 implements java.io.Serializable { * IN: Identifier of the attribute datatype (in memory). * @param obj * IN: Data object to be written. + * @param isCriticalPinning + * request lock on data reference. * * @return a non-negative value if successful * + * @exception HDF5Exception + * - Failure in the data conversion. * @exception HDF5LibraryException * - Error from the HDF-5 Library. * @exception NullPointerException - * - data object is null. See public synchronized static native int H5Awrite(int attr_id, int - * mem_type_id, byte[] buf); + * - data object is null **/ - public synchronized static int H5Awrite(long attr_id, long mem_type_id, Object obj) - throws HDF5Exception, NullPointerException + public synchronized static int H5Awrite(long attr_id, long mem_type_id, Object obj, boolean isCriticalPinning) + throws HDF5Exception, HDF5LibraryException, NullPointerException { - HDFArray theArray = new HDFArray(obj); - byte[] buf = theArray.byteify(); + int status = -1; + boolean is1D = false; - int retVal = H5Awrite(attr_id, mem_type_id, buf); - buf = null; - theArray = null; - return retVal; + Class dataClass = obj.getClass(); + if (!dataClass.isArray()) { + throw (new HDF5JavaException("H5Dwrite: data is not an array")); + } + + String cname = dataClass.getName(); + is1D = (cname.lastIndexOf('[') == cname.indexOf('[')); + char dname = cname.charAt(cname.lastIndexOf("[") + 1); + + if (is1D && (dname == 'B')) { + status = H5Awrite(attr_id, mem_type_id, (byte[]) obj, isCriticalPinning); + } + else if (is1D && (dname == 'S')) { + status = H5Awrite_short(attr_id, mem_type_id, (short[]) obj, isCriticalPinning); + } + else if (is1D && (dname == 'I')) { + status = H5Awrite_int(attr_id, mem_type_id, (int[]) obj, isCriticalPinning); + } + else if (is1D && (dname == 'J')) { + status = H5Awrite_long(attr_id, mem_type_id, (long[]) obj, isCriticalPinning); + } + else if (is1D && (dname == 'F')) { + status = H5Awrite_float(attr_id, mem_type_id, (float[]) obj, isCriticalPinning); + } + else if (is1D && (dname == 'D')) { + status = H5Awrite_double(attr_id, mem_type_id, (double[]) obj, isCriticalPinning); + } + else if (is1D && (dataClass.getComponentType() == String.class)) { + log.trace("H5Dwrite_string type"); + status = H5Awrite_string(attr_id, mem_type_id, (String[]) obj); + } + else { + HDFArray theArray = new HDFArray(obj); + byte[] buf = theArray.byteify(); + + status = H5Awrite(attr_id, mem_type_id, buf); + buf = null; + theArray = null; + } + + return status; } - public synchronized static native int H5AwriteVL(long attr_id, long mem_type_id, String[] buf) + public synchronized static native int H5Awrite_double(long attr_id, long mem_type_id, double[] buf, boolean isCriticalPinning) + throws HDF5LibraryException, NullPointerException; + + public synchronized static int H5Awrite_double(long attr_id, long mem_type_id, double[] buf) + throws HDF5LibraryException, NullPointerException + { + return H5Awrite_double(attr_id, mem_type_id, buf, true); + } + + public synchronized static native int H5Awrite_float(long attr_id, long mem_type_id, float[] buf, boolean isCriticalPinning) + throws HDF5LibraryException, NullPointerException; + + public synchronized static int H5Awrite_float(long attr_id, long mem_type_id, float[] buf) + throws HDF5LibraryException, NullPointerException + { + return H5Awrite_float(attr_id, mem_type_id, buf, true); + } + + public synchronized static native int H5Awrite_int(long attr_id, long mem_type_id, int[] buf, boolean isCriticalPinning) + throws HDF5LibraryException, NullPointerException; + + public synchronized static int H5Awrite_int(long attr_id, long mem_type_id, int[] buf) + throws HDF5LibraryException, NullPointerException + { + return H5Awrite_int(attr_id, mem_type_id, buf, true); + } + + public synchronized static native int H5Awrite_long(long attr_id, long mem_type_id, long[] buf, boolean isCriticalPinning) + throws HDF5LibraryException, NullPointerException; + + public synchronized static int H5Awrite_long(long attr_id, long mem_type_id, long[] buf) + throws HDF5LibraryException, NullPointerException + { + return H5Awrite_long(attr_id, mem_type_id, buf, true); + } + + public synchronized static native int H5Awrite_short(long attr_id, long mem_type_id, short[] buf, boolean isCriticalPinning) + throws HDF5LibraryException, NullPointerException; + + public synchronized static int H5Awrite_short(long attr_id, long mem_type_id, short[] buf) + throws HDF5LibraryException, NullPointerException + { + return H5Awrite_short(attr_id, mem_type_id, buf, true); + } + + public synchronized static native int H5Awrite_string(long attr_id, long mem_type_id, String[] buf) + throws HDF5LibraryException, NullPointerException; + + public synchronized static native int H5AwriteVL(long attr_id, long mem_type_id, Object[] buf) + throws HDF5LibraryException, NullPointerException; + + /** + * H5Awrite_VLStrings writes a variable length String dataset, specified by its identifier attr_id, from + * the application memory buffer buf into the file. + * + * ---- contributed by Rosetta Biosoftware + * + * @param attr_id + * Identifier of the attribute read from. + * @param mem_type_id + * Identifier of the memory datatype. + * @param buf + * Buffer with data to be written to the file. + * + * @return a non-negative value if successful + * + * @exception HDF5LibraryException + * - Error from the HDF-5 Library. + * @exception NullPointerException + * - name is null. + **/ + + public synchronized static native int H5Awrite_VLStrings(long attr_id, long mem_type_id, Object[] buf) throws HDF5LibraryException, NullPointerException; /** @@ -1614,8 +1869,8 @@ public class H5 implements java.io.Serializable { * @exception NullPointerException * - name is null. **/ - public static long H5Dopen(long loc_id, String name, long dapl_id) throws HDF5LibraryException, - NullPointerException { + public static long H5Dopen(long loc_id, String name, long dapl_id) throws HDF5LibraryException, NullPointerException + { long id = _H5Dopen2(loc_id, name, dapl_id); if (id > 0) { log.trace("OPEN_IDS: H5Dopen add {}", id); @@ -1664,12 +1919,14 @@ public class H5 implements java.io.Serializable { NullPointerException; public synchronized static int H5Dread(long dataset_id, long mem_type_id, long mem_space_id, long file_space_id, - long xfer_plist_id, byte[] buf) throws HDF5LibraryException, NullPointerException { + long xfer_plist_id, byte[] buf) throws HDF5LibraryException, NullPointerException + { return H5Dread(dataset_id, mem_type_id, mem_space_id, file_space_id, xfer_plist_id, buf, true); } public synchronized static int H5Dread(long dataset_id, long mem_type_id, long mem_space_id, long file_space_id, - long xfer_plist_id, Object obj) throws HDF5Exception, HDF5LibraryException, NullPointerException { + long xfer_plist_id, Object obj) throws HDF5Exception, HDF5LibraryException, NullPointerException + { return H5Dread(dataset_id, mem_type_id, mem_space_id, file_space_id, xfer_plist_id, obj, true); } @@ -1703,7 +1960,8 @@ public class H5 implements java.io.Serializable { **/ public synchronized static int H5Dread(long dataset_id, long mem_type_id, long mem_space_id, long file_space_id, long xfer_plist_id, Object obj, boolean isCriticalPinning) throws HDF5Exception, HDF5LibraryException, - NullPointerException { + NullPointerException + { int status = -1; boolean is1D = false; @@ -1734,7 +1992,8 @@ public class H5 implements java.io.Serializable { } else if (is1D && (dname == 'J')) { log.trace("H5Dread_dname_J"); - status = H5Dread_long(dataset_id, mem_type_id, mem_space_id, file_space_id, xfer_plist_id, (long[]) obj); + status = H5Dread_long(dataset_id, mem_type_id, mem_space_id, file_space_id, xfer_plist_id, (long[]) obj, + isCriticalPinning); } else if (is1D && (dname == 'F')) { log.trace("H5Dread_dname_F"); @@ -1783,7 +2042,8 @@ public class H5 implements java.io.Serializable { throws HDF5LibraryException, NullPointerException; public synchronized static int H5Dread_double(long dataset_id, long mem_type_id, long mem_space_id, - long file_space_id, long xfer_plist_id, double[] buf) throws HDF5LibraryException, NullPointerException { + long file_space_id, long xfer_plist_id, double[] buf) throws HDF5LibraryException, NullPointerException + { return H5Dread_double(dataset_id, mem_type_id, mem_space_id, file_space_id, xfer_plist_id, buf, true); } @@ -1792,7 +2052,8 @@ public class H5 implements java.io.Serializable { throws HDF5LibraryException, NullPointerException; public synchronized static int H5Dread_float(long dataset_id, long mem_type_id, long mem_space_id, - long file_space_id, long xfer_plist_id, float[] buf) throws HDF5LibraryException, NullPointerException { + long file_space_id, long xfer_plist_id, float[] buf) throws HDF5LibraryException, NullPointerException + { return H5Dread_float(dataset_id, mem_type_id, mem_space_id, file_space_id, xfer_plist_id, buf, true); } @@ -1801,7 +2062,8 @@ public class H5 implements java.io.Serializable { NullPointerException; public synchronized static int H5Dread_int(long dataset_id, long mem_type_id, long mem_space_id, - long file_space_id, long xfer_plist_id, int[] buf) throws HDF5LibraryException, NullPointerException { + long file_space_id, long xfer_plist_id, int[] buf) throws HDF5LibraryException, NullPointerException + { return H5Dread_int(dataset_id, mem_type_id, mem_space_id, file_space_id, xfer_plist_id, buf, true); } @@ -1810,22 +2072,21 @@ public class H5 implements java.io.Serializable { NullPointerException; public synchronized static int H5Dread_long(long dataset_id, long mem_type_id, long mem_space_id, - long file_space_id, long xfer_plist_id, long[] buf) throws HDF5LibraryException, NullPointerException { + long file_space_id, long xfer_plist_id, long[] buf) throws HDF5LibraryException, NullPointerException + { return H5Dread_long(dataset_id, mem_type_id, mem_space_id, file_space_id, xfer_plist_id, buf, true); } public synchronized static native int H5Dread_reg_ref(long dataset_id, long mem_type_id, long mem_space_id, long file_space_id, long xfer_plist_id, String[] buf) throws HDF5LibraryException, NullPointerException; - public synchronized static native int H5Dread_reg_ref_data(long dataset_id, long mem_type_id, long mem_space_id, - long file_space_id, long xfer_plist_id, String[] buf) throws HDF5LibraryException, NullPointerException; - public synchronized static native int H5Dread_short(long dataset_id, long mem_type_id, long mem_space_id, long file_space_id, long xfer_plist_id, short[] buf, boolean isCriticalPinning) throws HDF5LibraryException, NullPointerException; public synchronized static int H5Dread_short(long dataset_id, long mem_type_id, long mem_space_id, - long file_space_id, long xfer_plist_id, short[] buf) throws HDF5LibraryException, NullPointerException { + long file_space_id, long xfer_plist_id, short[] buf) throws HDF5LibraryException, NullPointerException + { return H5Dread_short(dataset_id, mem_type_id, mem_space_id, file_space_id, xfer_plist_id, buf, true); } @@ -1929,12 +2190,14 @@ public class H5 implements java.io.Serializable { NullPointerException; public synchronized static int H5Dwrite(long dataset_id, long mem_type_id, long mem_space_id, long file_space_id, - long xfer_plist_id, byte[] buf) throws HDF5LibraryException, NullPointerException { + long xfer_plist_id, byte[] buf) throws HDF5LibraryException, NullPointerException + { return H5Dwrite(dataset_id, mem_type_id, mem_space_id, file_space_id, xfer_plist_id, buf, true); } public synchronized static int H5Dwrite(long dataset_id, long mem_type_id, long mem_space_id, long file_space_id, - long xfer_plist_id, Object obj) throws HDF5Exception, HDF5LibraryException, NullPointerException { + long xfer_plist_id, Object obj) throws HDF5Exception, HDF5LibraryException, NullPointerException + { return H5Dwrite(dataset_id, mem_type_id, mem_space_id, file_space_id, xfer_plist_id, obj, true); } @@ -1968,7 +2231,8 @@ public class H5 implements java.io.Serializable { **/ public synchronized static int H5Dwrite(long dataset_id, long mem_type_id, long mem_space_id, long file_space_id, long xfer_plist_id, Object obj, boolean isCriticalPinning) throws HDF5Exception, HDF5LibraryException, - NullPointerException { + NullPointerException + { int status = -1; boolean is1D = false; @@ -2031,7 +2295,8 @@ public class H5 implements java.io.Serializable { throws HDF5LibraryException, NullPointerException; public synchronized static int H5Dwrite_double(long dataset_id, long mem_type_id, long mem_space_id, - long file_space_id, long xfer_plist_id, double[] buf) throws HDF5LibraryException, NullPointerException { + long file_space_id, long xfer_plist_id, double[] buf) throws HDF5LibraryException, NullPointerException + { return H5Dwrite_double(dataset_id, mem_type_id, mem_space_id, file_space_id, xfer_plist_id, buf, true); } @@ -2040,7 +2305,8 @@ public class H5 implements java.io.Serializable { throws HDF5LibraryException, NullPointerException; public synchronized static int H5Dwrite_float(long dataset_id, long mem_type_id, long mem_space_id, - long file_space_id, long xfer_plist_id, float[] buf) throws HDF5LibraryException, NullPointerException { + long file_space_id, long xfer_plist_id, float[] buf) throws HDF5LibraryException, NullPointerException + { return H5Dwrite_float(dataset_id, mem_type_id, mem_space_id, file_space_id, xfer_plist_id, buf, true); } @@ -2049,7 +2315,8 @@ public class H5 implements java.io.Serializable { NullPointerException; public synchronized static int H5Dwrite_int(long dataset_id, long mem_type_id, long mem_space_id, - long file_space_id, long xfer_plist_id, int[] buf) throws HDF5LibraryException, NullPointerException { + long file_space_id, long xfer_plist_id, int[] buf) throws HDF5LibraryException, NullPointerException + { return H5Dwrite_int(dataset_id, mem_type_id, mem_space_id, file_space_id, xfer_plist_id, buf, true); } @@ -2058,7 +2325,8 @@ public class H5 implements java.io.Serializable { NullPointerException; public synchronized static int H5Dwrite_long(long dataset_id, long mem_type_id, long mem_space_id, - long file_space_id, long xfer_plist_id, long[] buf) throws HDF5LibraryException, NullPointerException { + long file_space_id, long xfer_plist_id, long[] buf) throws HDF5LibraryException, NullPointerException + { return H5Dwrite_long(dataset_id, mem_type_id, mem_space_id, file_space_id, xfer_plist_id, buf, true); } @@ -2067,7 +2335,8 @@ public class H5 implements java.io.Serializable { throws HDF5LibraryException, NullPointerException; public synchronized static int H5Dwrite_short(long dataset_id, long mem_type_id, long mem_space_id, - long file_space_id, long xfer_plist_id, short[] buf) throws HDF5LibraryException, NullPointerException { + long file_space_id, long xfer_plist_id, short[] buf) throws HDF5LibraryException, NullPointerException + { return H5Dwrite_short(dataset_id, mem_type_id, mem_space_id, file_space_id, xfer_plist_id, buf, true); } @@ -2133,10 +2402,10 @@ public class H5 implements java.io.Serializable { public synchronized static native void H5Drefresh(long dset_id) throws HDF5LibraryException; // /////// unimplemented //////// - // H5_DLL herr_t H5Ddebug(hid_t dset_id); - // H5_DLL herr_t H5Dget_chunk_storage_size(hid_t dset_id, const hsize_t *offset, hsize_t *chunk_bytes); - // H5_DLL herr_t H5Dformat_convert(hid_t dset_id); - // H5_DLL herr_t H5Dget_chunk_index_type(hid_t did, H5D_chunk_index_t *idx_type); + // herr_t H5Ddebug(hid_t dset_id); + // herr_t H5Dget_chunk_storage_size(hid_t dset_id, const hsize_t *offset, hsize_t *chunk_bytes); + // herr_t H5Dformat_convert(hid_t dset_id); + // herr_t H5Dget_chunk_index_type(hid_t did, H5D_chunk_index_t *idx_type); // herr_t H5Dgather(hid_t src_space_id, const void *src_buf, hid_t type_id, // size_t dst_buf_size, void *dst_buf, H5D_gather_func_t op, void *op_data); @@ -2808,10 +3077,29 @@ public class H5 implements java.io.Serializable { * - Error from the HDF-5 Library. * @exception NullPointerException * - name is null. + * + * @deprecated As of HDF5 1.10.5 in favor of H5Fis_accessible. **/ public synchronized static native boolean H5Fis_hdf5(String name) throws HDF5LibraryException, NullPointerException; /** + * H5Fis_accessible determines if the file can be opened with the given fapl. + * + * @param name + * IN: File name to check. + * @param file_id + * IN: File identifier for a currently-open HDF5 file + * + * @return true if file is accessible, false if not. + * + * @exception HDF5LibraryException + * - Error from the HDF-5 Library. + * @exception NullPointerException + * - name is null. + **/ + public synchronized static native boolean H5Fis_accessible(String name, long file_id) throws HDF5LibraryException, NullPointerException; + + /** * H5Fmount mounts the file specified by child_id onto the group specified by loc_id and name using the mount * properties plist_id. * @@ -2942,20 +3230,20 @@ public class H5 implements java.io.Serializable { throws HDF5LibraryException, NullPointerException; // /////// unimplemented //////// - // H5_DLL herr_t H5Fget_eoa(hid_t file_id, haddr_t *eoa); - // H5_DLL herr_t H5Fincrement_filesize(hid_t file_id, hsize_t increment); + // herr_t H5Fget_eoa(hid_t file_id, haddr_t *eoa); + // herr_t H5Fincrement_filesize(hid_t file_id, hsize_t increment); // ssize_t H5Fget_file_image(hid_t file_id, void * buf_ptr, size_t buf_len); // herr_t H5Fget_metadata_read_retry_info(hid_t file_id, H5F_retry_info_t *info); // ssize_t H5Fget_free_sections(hid_t file_id, H5F_mem_t type, size_t nsects, H5F_sect_info_t *sect_info/*out*/); - // H5_DLL herr_t H5Fset_libver_bounds(hid_t file_id, H5F_libver_t low, H5F_libver_t high); - // H5_DLL herr_t H5Fformat_convert(hid_t fid); - // H5_DLL herr_t H5Freset_page_buffering_stats(hid_t file_id); - // H5_DLL herr_t H5Fget_page_buffering_stats(hid_t file_id, unsigned accesses[2], + // herr_t H5Fset_libver_bounds(hid_t file_id, H5F_libver_t low, H5F_libver_t high); + // herr_t H5Fformat_convert(hid_t fid); + // herr_t H5Freset_page_buffering_stats(hid_t file_id); + // herr_t H5Fget_page_buffering_stats(hid_t file_id, unsigned accesses[2], // unsigned hits[2], unsigned misses[2], unsigned evictions[2], unsigned bypasses[2]); - // H5_DLL herr_t H5Fget_mdc_image_info(hid_t file_id, haddr_t *image_addr, hsize_t *image_size); + // herr_t H5Fget_mdc_image_info(hid_t file_id, haddr_t *image_addr, hsize_t *image_size); // #ifdef H5_HAVE_PARALLEL - // H5_DLL herr_t H5Fset_mpi_atomicity(hid_t file_id, hbool_t flag); - // H5_DLL herr_t H5Fget_mpi_atomicity(hid_t file_id, hbool_t *flag); + // herr_t H5Fset_mpi_atomicity(hid_t file_id, hbool_t flag); + // herr_t H5Fget_mpi_atomicity(hid_t file_id, hbool_t *flag); // #endif /* H5_HAVE_PARALLEL */ // /** @@ -3015,25 +3303,25 @@ public class H5 implements java.io.Serializable { // //////////////////////////////////////////////////////////// // /////// unimplemented //////// - // H5_DLL hid_t H5FDregister(const H5FD_class_t *cls); - // H5_DLL herr_t H5FDunregister(hid_t driver_id); - // H5_DLL H5FD_t *H5FDopen(const char *name, unsigned flags, hid_t fapl_id, haddr_t maxaddr); - // H5_DLL herr_t H5FDclose(H5FD_t *file); - // H5_DLL int H5FDcmp(const H5FD_t *f1, const H5FD_t *f2); - // H5_DLL int H5FDquery(const H5FD_t *f, unsigned long *flags); - // H5_DLL haddr_t H5FDalloc(H5FD_t *file, H5FD_mem_t type, hid_t dxpl_id, hsize_t size); - // H5_DLL herr_t H5FDfree(H5FD_t *file, H5FD_mem_t type, hid_t dxpl_id, haddr_t addr, hsize_t size); - // H5_DLL haddr_t H5FDget_eoa(H5FD_t *file, H5FD_mem_t type); - // H5_DLL herr_t H5FDset_eoa(H5FD_t *file, H5FD_mem_t type, haddr_t eoa); - // H5_DLL haddr_t H5FDget_eof(H5FD_t *file, H5FD_mem_t type); - // H5_DLL herr_t H5FDget_vfd_handle(H5FD_t *file, hid_t fapl, void**file_handle); - // H5_DLL herr_t H5FDread(H5FD_t *file, H5FD_mem_t type, hid_t dxpl_id, haddr_t addr, size_t size, void *buf/*out*/); - // H5_DLL herr_t H5FDwrite(H5FD_t *file, H5FD_mem_t type, hid_t dxpl_id, haddr_t addr, size_t size, const void *buf); - // H5_DLL herr_t H5FDflush(H5FD_t *file, hid_t dxpl_id, hbool_t closing); - // H5_DLL herr_t H5FDtruncate(H5FD_t *file, hid_t dxpl_id, hbool_t closing); - // H5_DLL herr_t H5FDlock(H5FD_t *file, hbool_t rw); - // H5_DLL herr_t H5FDunlock(H5FD_t *file); - // H5_DLL herr_t H5FDdriver_query(hid_t driver_id, unsigned long *flags/*out*/); + // hid_t H5FDregister(const H5FD_class_t *cls); + // herr_t H5FDunregister(hid_t driver_id); + // H5FD_t *H5FDopen(const char *name, unsigned flags, hid_t fapl_id, haddr_t maxaddr); + // herr_t H5FDclose(H5FD_t *file); + // int H5FDcmp(const H5FD_t *f1, const H5FD_t *f2); + // int H5FDquery(const H5FD_t *f, unsigned long *flags); + // haddr_t H5FDalloc(H5FD_t *file, H5FD_mem_t type, hid_t dxpl_id, hsize_t size); + // herr_t H5FDfree(H5FD_t *file, H5FD_mem_t type, hid_t dxpl_id, haddr_t addr, hsize_t size); + // haddr_t H5FDget_eoa(H5FD_t *file, H5FD_mem_t type); + // herr_t H5FDset_eoa(H5FD_t *file, H5FD_mem_t type, haddr_t eoa); + // haddr_t H5FDget_eof(H5FD_t *file, H5FD_mem_t type); + // herr_t H5FDget_vfd_handle(H5FD_t *file, hid_t fapl, void**file_handle); + // herr_t H5FDread(H5FD_t *file, H5FD_mem_t type, hid_t dxpl_id, haddr_t addr, size_t size, void *buf/*out*/); + // herr_t H5FDwrite(H5FD_t *file, H5FD_mem_t type, hid_t dxpl_id, haddr_t addr, size_t size, const void *buf); + // herr_t H5FDflush(H5FD_t *file, hid_t dxpl_id, hbool_t closing); + // herr_t H5FDtruncate(H5FD_t *file, hid_t dxpl_id, hbool_t closing); + // herr_t H5FDlock(H5FD_t *file, hbool_t rw); + // herr_t H5FDunlock(H5FD_t *file); + // herr_t H5FDdriver_query(hid_t driver_id, unsigned long *flags/*out*/); // //////////////////////////////////////////////////////////// // // @@ -3506,7 +3794,7 @@ public class H5 implements java.io.Serializable { // //////////////////////////////////////////////////////////// // // - // H5I: HDF5 1.8 Identifier Interface API Functions // + // H5I: HDF5 Identifier Interface API Functions // // // // //////////////////////////////////////////////////////////// @@ -3662,12 +3950,20 @@ public class H5 implements java.io.Serializable { // hid_t H5Iregister(H5I_type_t type, const void *object); + // typedef herr_t (*H5I_free_t)(void *); // H5I_type_t H5Iregister_type(size_t hash_size, unsigned reserved, H5I_free_t free_func); // void *H5Iremove_verify(hid_t id, H5I_type_t id_type); + // Type of the function to compare objects & keys + // typedef int (*H5I_search_func_t)(void *obj, hid_t id, void *key); // void *H5Isearch(H5I_type_t type, H5I_search_func_t func, void *key); + // Type of the H5Iiterate callback function + // typedef herr_t (*H5I_iterate_func_t)(hid_t id, void *udata); + // herr_t H5Iiterate(H5I_type_t type, H5I_iterate_func_t op, void *op_data); + + // ////////////////////////////////////////////////////////////////// // H5L: Link Interface Functions // // ////////////////////////////////////////////////////////////////// @@ -4695,9 +4991,9 @@ public class H5 implements java.io.Serializable { public synchronized static native void H5Orefresh(long object_id) throws HDF5LibraryException; // /////// unimplemented //////// - // H5_DLL herr_t H5Odisable_mdc_flushes(hid_t object_id); - // H5_DLL herr_t H5Oenable_mdc_flushes(hid_t object_id); - // H5_DLL herr_t H5Oare_mdc_flushes_disabled(hid_t object_id, hbool_t *are_disabled); + // herr_t H5Odisable_mdc_flushes(hid_t object_id); + // herr_t H5Oenable_mdc_flushes(hid_t object_id); + // herr_t H5Oare_mdc_flushes_disabled(hid_t object_id, hbool_t *are_disabled); // //////////////////////////////////////////////////////////// // // @@ -4982,6 +5278,27 @@ public class H5 implements java.io.Serializable { private synchronized static native long _H5Pcopy(long plist) throws HDF5LibraryException; + // Define property list class callback function pointer types + // typedef herr_t (*H5P_cls_create_func_t)(hid_t prop_id, void *create_data); + // typedef herr_t (*H5P_cls_copy_func_t)(hid_t new_prop_id, hid_t old_prop_id, void *copy_data); + // typedef herr_t (*H5P_cls_close_func_t)(hid_t prop_id, void *close_data); + + // Define property list callback function pointer types + // typedef herr_t (*H5P_prp_cb1_t)(const char *name, size_t size, void *value); + // typedef herr_t (*H5P_prp_cb2_t)(hid_t prop_id, const char *name, size_t size, void *value); + // typedef H5P_prp_cb1_t H5P_prp_create_func_t; + // typedef H5P_prp_cb2_t H5P_prp_set_func_t; + // typedef H5P_prp_cb2_t H5P_prp_get_func_t; + // typedef herr_t (*H5P_prp_encode_func_t)(const void *value, void **buf, size_t *size); + // typedef herr_t (*H5P_prp_decode_func_t)(const void **buf, void *value); + // typedef H5P_prp_cb2_t H5P_prp_delete_func_t; + // typedef H5P_prp_cb1_t H5P_prp_copy_func_t; + // typedef int (*H5P_prp_compare_func_t)(const void *value1, const void *value2, size_t size); + // typedef H5P_prp_cb1_t H5P_prp_close_func_t; + + // Define property list iteration function type + // typedef herr_t (*H5P_iterate_t)(hid_t id, const char *name, void *iter_data); + public static long H5Pcreate_class_nocb(long parent_class, String name) throws HDF5LibraryException { long id = _H5Pcreate_class_nocb(parent_class, name); if (id > 0) { @@ -6145,6 +6462,11 @@ public class H5 implements java.io.Serializable { public synchronized static native void H5Pset_evict_on_close(long fapl_id, boolean evict_on_close) throws HDF5LibraryException; + // ///// unimplemented ///// + // herr_t H5Pset_vol(hid_t plist_id, hid_t new_vol_id, const void *new_vol_info); + // herr_t H5Pget_vol_id(hid_t plist_id, hid_t *vol_id); + // herr_t H5Pget_vol_info(hid_t plist_id, void **vol_info); + // Dataset creation property list (DCPL) routines // /** @@ -7523,13 +7845,13 @@ public class H5 implements java.io.Serializable { // herr_t H5Pget_core_write_tracking(hid_t fapl_id, hbool_t *is_enabled, size_t *page_size); // #ifdef H5_HAVE_PARALLEL // herr_t H5Pset_all_coll_metadata_ops(hid_t accpl_id, hbool_t is_collective); - // H5_DLL herr_t H5Pget_all_coll_metadata_ops(hid_t plist_id, hbool_t *is_collective); + // herr_t H5Pget_all_coll_metadata_ops(hid_t plist_id, hbool_t *is_collective); // herr_t H5Pset_coll_metadata_write(hid_t fapl_id, hbool_t is_collective); // herr_t H5Pget_coll_metadata_write(hid_t fapl_id, hbool_t *is_collective); // #endif /* H5_HAVE_PARALLEL */ - // H5_DLL herr_t H5Pset_mdc_image_config(hid_t plist_id, H5AC_cache_image_config_t *config_ptr); - // H5_DLL herr_t H5Pget_mdc_image_config(hid_t plist_id, H5AC_cache_image_config_t *config_ptr /*out*/); - // H5_DLL herr_t H5Pset_page_buffer_size(hid_t plist_id, size_t buf_size, unsigned min_meta_per, unsigned min_raw_per); + // herr_t H5Pset_mdc_image_config(hid_t plist_id, H5AC_cache_image_config_t *config_ptr); + // herr_t H5Pget_mdc_image_config(hid_t plist_id, H5AC_cache_image_config_t *config_ptr /*out*/); + // herr_t H5Pset_page_buffer_size(hid_t plist_id, size_t buf_size, unsigned min_meta_per, unsigned min_raw_per); // herr_t H5Pget_page_buffer_size(hid_t fapl_id, size_t *buf_size, unsigned *min_meta_perc, unsigned *min_raw_perc); // herr_t H5Pset_object_flush_cb (hid_t fapl_id, H5F_flush_cb_t func, void *user_data); // herr_t H5Pget_object_flush_cb (hid_t fapl_id, H5F_flush_cb_t *func, void **user_data); @@ -7552,9 +7874,9 @@ public class H5 implements java.io.Serializable { // herr_t H5Pget_type_conv_cb(hid_t plist, H5T_conv_except_func_t *func, void **op_data) // herr_t H5Pset_type_conv_cb( hid_t plist, H5T_conv_except_func_t func, void *op_data) // #ifdef H5_HAVE_PARALLEL - // H5_DLL herr_t H5Pget_mpio_actual_chunk_opt_mode(hid_t plist_id, H5D_mpio_actual_chunk_opt_mode_t *actual_chunk_opt_mode); - // H5_DLL herr_t H5Pget_mpio_actual_io_mode(hid_t plist_id, H5D_mpio_actual_io_mode_t *actual_io_mode); - // H5_DLL herr_t H5Pget_mpio_no_collective_cause(hid_t plist_id, uint32_t *local_no_collective_cause, uint32_t *global_no_collective_cause); + // herr_t H5Pget_mpio_actual_chunk_opt_mode(hid_t plist_id, H5D_mpio_actual_chunk_opt_mode_t *actual_chunk_opt_mode); + // herr_t H5Pget_mpio_actual_io_mode(hid_t plist_id, H5D_mpio_actual_io_mode_t *actual_io_mode); + // herr_t H5Pget_mpio_no_collective_cause(hid_t plist_id, uint32_t *local_no_collective_cause, uint32_t *global_no_collective_cause); // #endif /* H5_HAVE_PARALLEL */ // Link creation property list (LCPL) routines // @@ -8497,16 +8819,17 @@ public class H5 implements java.io.Serializable { // /////// unimplemented //////// // #ifdef NEW_HYPERSLAB_API - // H5_DLL hid_t H5Scombine_hyperslab(hid_t space_id, H5S_seloper_t op, + // hid_t H5Scombine_hyperslab(hid_t space_id, H5S_seloper_t op, // const hsize_t start[], // const hsize_t _stride[], // const hsize_t count[], // const hsize_t _block[]); - // H5_DLL herr_t H5Sselect_select(hid_t space1_id, H5S_seloper_t op, + // herr_t H5Sselect_select(hid_t space1_id, H5S_seloper_t op, // hid_t space2_id); - // H5_DLL hid_t H5Scombine_select(hid_t space1_id, H5S_seloper_t op, + // hid_t H5Scombine_select(hid_t space1_id, H5S_seloper_t op, // hid_t space2_id); // #endif /* NEW_HYPERSLAB_API */ + // herr_t H5Sselect_copy(hid_t dst_id, hid_t src_id); @@ -9985,6 +10308,25 @@ public class H5 implements java.io.Serializable { // //////////////////////////////////////////////////////////// // // + // H5VL: VOL Interface Functions // + // // + // //////////////////////////////////////////////////////////// + + /// VOL Connector Functionality + public synchronized static native long H5VLregister_connector_by_name(String connector_name, long vipl_id); + public synchronized static native long H5VLregister_connector_by_value(int connector_value, long vipl_id); + public synchronized static native boolean H5VLis_connector_registered(String name); + public synchronized static native long H5VLget_connector_id(String name); + public synchronized static native String H5VLget_connector_name(long object_id); + public synchronized static native void H5VLclose(long connector_id); + public synchronized static native void H5VLunregister_connector(long connector_id); + + // /////// unimplemented //////// + // hid_t H5VLregister_connector(const H5VL_class_t *cls, hid_t vipl_id); + + + // //////////////////////////////////////////////////////////// + // // // H5Z: Filter Interface Functions // // // // //////////////////////////////////////////////////////////// @@ -9995,9 +10337,9 @@ public class H5 implements java.io.Serializable { public synchronized static native int H5Zunregister(int filter) throws HDF5LibraryException, NullPointerException; -} + // /////// unimplemented //////// -// /////// unimplemented //////// + // herr_t H5Zregister(const void *cls); -// herr_t H5Zregister(const void *cls); +} diff --git a/java/src/hdf/hdf5lib/HDF5Constants.java b/java/src/hdf/hdf5lib/HDF5Constants.java index b530f4b..a0c2ed6 100644 --- a/java/src/hdf/hdf5lib/HDF5Constants.java +++ b/java/src/hdf/hdf5lib/HDF5Constants.java @@ -195,6 +195,11 @@ public class HDF5Constants { public static final long H5E_WALK_UPWARD = H5E_WALK_UPWARD(); public static final long H5E_WRITEERROR = H5E_WRITEERROR(); + private static final int H5ES_STATUS_IN_PROGRESS = H5ES_STATUS_IN_PROGRESS(); + private static final int H5ES_STATUS_SUCCEED = H5ES_STATUS_SUCCEED(); + private static final int H5ES_STATUS_FAIL = H5ES_STATUS_FAIL(); + private static final int H5ES_STATUS_CANCELED = H5ES_STATUS_CANCELED(); + public static final int H5F_ACC_CREAT = H5F_ACC_CREAT(); public static final int H5F_ACC_EXCL = H5F_ACC_EXCL(); public static final int H5F_ACC_RDONLY = H5F_ACC_RDONLY(); @@ -315,7 +320,6 @@ public class HDF5Constants { public static final int H5I_GROUP = H5I_GROUP(); public static final int H5I_INVALID_HID = H5I_INVALID_HID(); public static final int H5I_NTYPES = H5I_NTYPES(); - public static final int H5I_REFERENCE = H5I_REFERENCE(); public static final int H5I_UNINIT = H5I_UNINIT(); public static final int H5I_VFL = H5I_VFL(); public static final int H5I_VOL = H5I_VOL(); @@ -390,7 +394,10 @@ public class HDF5Constants { public static final int H5PL_TYPE_ERROR = H5PL_TYPE_ERROR(); public static final int H5PL_TYPE_FILTER = H5PL_TYPE_FILTER(); + public static final int H5PL_TYPE_VOL = H5PL_TYPE_VOL(); + public static final int H5PL_TYPE_NONE = H5PL_TYPE_NONE(); public static final int H5PL_FILTER_PLUGIN = H5PL_FILTER_PLUGIN(); + public static final int H5PL_VOL_PLUGIN = H5PL_VOL_PLUGIN(); public static final int H5PL_ALL_PLUGIN = H5PL_ALL_PLUGIN(); public static final int H5R_BADTYPE = H5R_BADTYPE(); @@ -626,6 +633,18 @@ public class HDF5Constants { public static final long H5T_VARIABLE = H5T_VARIABLE(); public static final int H5T_VLEN = H5T_VLEN(); public static final int H5T_VL_T = H5T_VL_T(); + + public static final int H5VL_CAP_FLAG_NONE = H5VL_CAP_FLAG_NONE(); + public static final int H5VL_CAP_FLAG_THREADSAFE = H5VL_CAP_FLAG_THREADSAFE(); + public static final long H5VL_NATIVE = H5VL_NATIVE(); + public static final String H5VL_NATIVE_NAME = H5VL_NATIVE_NAME(); + public static final int H5VL_NATIVE_VALUE = H5VL_NATIVE_VALUE(); + public static final int H5VL_NATIVE_VERSION = H5VL_NATIVE_VERSION(); + public static final int H5_VOL_INVALID = H5_VOL_INVALID(); + public static final int H5_VOL_NATIVE = H5_VOL_NATIVE(); + public static final int H5_VOL_RESERVED = H5_VOL_RESERVED(); + public static final int H5_VOL_MAX = H5_VOL_MAX(); + public static final int H5Z_CB_CONT = H5Z_CB_CONT(); public static final int H5Z_CB_ERROR = H5Z_CB_ERROR(); public static final int H5Z_CB_FAIL = H5Z_CB_FAIL(); @@ -990,6 +1009,14 @@ public class HDF5Constants { private static native final long H5E_WRITEERROR(); + private static native final int H5ES_STATUS_IN_PROGRESS(); + + private static native final int H5ES_STATUS_SUCCEED(); + + private static native final int H5ES_STATUS_FAIL(); + + private static native final int H5ES_STATUS_CANCELED(); + private static native final int H5F_ACC_CREAT(); private static native final int H5F_ACC_EXCL(); @@ -1222,8 +1249,6 @@ public class HDF5Constants { private static native final int H5I_NTYPES(); - private static native final int H5I_REFERENCE(); - private static native final int H5I_UNINIT(); private static native final int H5I_VFL(); @@ -1364,10 +1389,16 @@ public class HDF5Constants { private static native final int H5PL_TYPE_FILTER(); + private static native final int H5PL_TYPE_VOL(); + + private static native final int H5PL_TYPE_NONE(); + private static native final int H5PL_FILTER_PLUGIN(); private static native final int H5PL_ALL_PLUGIN(); + private static native final int H5PL_VOL_PLUGIN(); + private static native final int H5R_BADTYPE(); private static native final int H5R_DATASET_REGION(); @@ -1834,6 +1865,26 @@ public class HDF5Constants { private static native final int H5T_VL_T(); + private static native final int H5VL_CAP_FLAG_NONE(); + + private static native final int H5VL_CAP_FLAG_THREADSAFE(); + + private static native final long H5VL_NATIVE(); + + private static native final String H5VL_NATIVE_NAME(); + + private static native final int H5VL_NATIVE_VALUE(); + + private static native final int H5VL_NATIVE_VERSION(); + + private static native final int H5_VOL_INVALID(); + + private static native final int H5_VOL_NATIVE(); + + private static native final int H5_VOL_RESERVED(); + + private static native final int H5_VOL_MAX(); + private static native final int H5Z_CB_CONT(); private static native final int H5Z_CB_ERROR(); diff --git a/java/src/jni/CMakeLists.txt b/java/src/jni/CMakeLists.txt index 7b95e0b..00c2b34 100644 --- a/java/src/jni/CMakeLists.txt +++ b/java/src/jni/CMakeLists.txt @@ -19,6 +19,7 @@ set (HDF5_JAVA_JNI_CSRCS ${HDF5_JAVA_JNI_SOURCE_DIR}/h5sImp.c ${HDF5_JAVA_JNI_SOURCE_DIR}/h5tImp.c ${HDF5_JAVA_JNI_SOURCE_DIR}/h5util.c + ${HDF5_JAVA_JNI_SOURCE_DIR}/h5vlImp.c ${HDF5_JAVA_JNI_SOURCE_DIR}/h5zImp.c ${HDF5_JAVA_JNI_SOURCE_DIR}/nativeData.c ) @@ -40,6 +41,7 @@ set (HDF5_JAVA_JNI_CHDRS ${HDF5_JAVA_JNI_SOURCE_DIR}/h5sImp.h ${HDF5_JAVA_JNI_SOURCE_DIR}/h5tImp.h ${HDF5_JAVA_JNI_SOURCE_DIR}/h5util.h + ${HDF5_JAVA_JNI_SOURCE_DIR}/h5vlImp.h ${HDF5_JAVA_JNI_SOURCE_DIR}/h5zImp.h ${HDF5_JAVA_JNI_SOURCE_DIR}/nativeData.h ) @@ -48,7 +50,9 @@ set (CMAKE_INCLUDE_CURRENT_DIR_IN_INTERFACE ON) ########### JNI libraries always must be built shared ############### add_library (${HDF5_JAVA_JNI_LIB_TARGET} SHARED ${HDF5_JAVA_JNI_CSRCS} ${HDF5_JAVA_JNI_CHDRS}) -target_include_directories(${HDF5_JAVA_JNI_LIB_TARGET} PRIVATE ${HDF5_BINARY_DIR} ${HDF5_JAVA_JNI_SOURCE_DIR}) +target_include_directories(${HDF5_JAVA_JNI_LIB_TARGET} + PRIVATE "${HDF5_BINARY_DIR};${HDF5_JAVA_JNI_SOURCE_DIR};$<$<BOOL:${HDF5_ENABLE_PARALLEL}>:${MPI_C_INCLUDE_DIRS}>" +) TARGET_C_PROPERTIES (${HDF5_JAVA_JNI_LIB_TARGET} SHARED) target_link_libraries (${HDF5_JAVA_JNI_LIB_TARGET} PUBLIC ${HDF5_LIBSH_TARGET}) set_target_properties (${HDF5_JAVA_JNI_LIB_TARGET} PROPERTIES FOLDER libraries/jni) diff --git a/java/src/jni/Makefile.am b/java/src/jni/Makefile.am index 6ded371..370b08b 100644 --- a/java/src/jni/Makefile.am +++ b/java/src/jni/Makefile.am @@ -34,7 +34,7 @@ libhdf5_java_la_LDFLAGS = -avoid-version -shared -export-dynamic -version-info $ # Source files for the library libhdf5_java_la_SOURCES=exceptionImp.c h5Constants.c nativeData.c h5util.c h5Imp.c \ h5aImp.c h5dImp.c h5eImp.c h5fImp.c h5gImp.c h5iImp.c h5lImp.c h5oImp.c \ - h5pImp.c h5plImp.c h5rImp.c h5sImp.c h5tImp.c h5zImp.c + h5pImp.c h5plImp.c h5rImp.c h5sImp.c h5tImp.c h5vlImp.c h5zImp.c # HDF5 Java (JNI) library depends on HDF5 Library. libhdf5_java_la_LIBADD=$(LIBHDF5) diff --git a/java/src/jni/h5Constants.c b/java/src/jni/h5Constants.c index fdec61a..e88fa55 100644 --- a/java/src/jni/h5Constants.c +++ b/java/src/jni/h5Constants.c @@ -21,8 +21,10 @@ extern "C" { #endif /* __cplusplus */ -#include <jni.h> #include "hdf5.h" +#include <jni.h> +#include <stdlib.h> +#include "h5jni.h" #pragma GCC diagnostic push #pragma GCC diagnostic ignored "-Wmissing-prototypes" @@ -352,6 +354,15 @@ Java_hdf_hdf5lib_HDF5Constants_H5E_1WALK_1UPWARD(JNIEnv *env, jclass cls) { retu JNIEXPORT jlong JNICALL Java_hdf_hdf5lib_HDF5Constants_H5E_1WRITEERROR(JNIEnv *env, jclass cls) { return H5E_WRITEERROR; } +JNIEXPORT jlong JNICALL +Java_hdf_hdf5lib_HDF5Constants_H5ES_1STATUS_1IN_1PROGRESS(JNIEnv *env, jclass cls) { return H5ES_STATUS_IN_PROGRESS; } +JNIEXPORT jlong JNICALL +Java_hdf_hdf5lib_HDF5Constants_H5ES_1STATUS_1SUCCEED(JNIEnv *env, jclass cls) { return H5ES_STATUS_SUCCEED; } +JNIEXPORT jlong JNICALL +Java_hdf_hdf5lib_HDF5Constants_H5ES_1STATUS_1FAIL(JNIEnv *env, jclass cls) { return H5ES_STATUS_FAIL; } +JNIEXPORT jlong JNICALL +Java_hdf_hdf5lib_HDF5Constants_H5ES_1STATUS_1CANCELED(JNIEnv *env, jclass cls) { return H5ES_STATUS_CANCELED; } + /* Java does not have unsigned native types */ #pragma GCC diagnostic push #pragma GCC diagnostic ignored "-Wsign-conversion" @@ -603,8 +614,6 @@ Java_hdf_hdf5lib_HDF5Constants_H5I_1DATASET(JNIEnv *env, jclass cls) { return H5 JNIEXPORT jint JNICALL Java_hdf_hdf5lib_HDF5Constants_H5I_1ATTR(JNIEnv *env, jclass cls) { return H5I_ATTR; } JNIEXPORT jint JNICALL -Java_hdf_hdf5lib_HDF5Constants_H5I_1REFERENCE(JNIEnv *env, jclass cls) { return H5I_REFERENCE; } -JNIEXPORT jint JNICALL Java_hdf_hdf5lib_HDF5Constants_H5I_1VFL(JNIEnv *env, jclass cls) { return H5I_VFL; } JNIEXPORT jint JNICALL Java_hdf_hdf5lib_HDF5Constants_H5I_1VOL(JNIEnv *env, jclass cls) { return H5I_VOL; } @@ -763,8 +772,14 @@ Java_hdf_hdf5lib_HDF5Constants_H5PL_1TYPE_1ERROR(JNIEnv *env, jclass cls) { retu JNIEXPORT jint JNICALL Java_hdf_hdf5lib_HDF5Constants_H5PL_1TYPE_1FILTER(JNIEnv *env, jclass cls) { return H5PL_TYPE_FILTER; } JNIEXPORT jint JNICALL +Java_hdf_hdf5lib_HDF5Constants_H5PL_1TYPE_1VOL(JNIEnv *env, jclass cls) { return H5PL_TYPE_VOL; } +JNIEXPORT jint JNICALL +Java_hdf_hdf5lib_HDF5Constants_H5PL_1TYPE_1NONE(JNIEnv *env, jclass cls) { return H5PL_TYPE_NONE; } +JNIEXPORT jint JNICALL Java_hdf_hdf5lib_HDF5Constants_H5PL_1FILTER_1PLUGIN(JNIEnv *env, jclass cls) { return H5PL_FILTER_PLUGIN; } JNIEXPORT jint JNICALL +Java_hdf_hdf5lib_HDF5Constants_H5PL_1VOL_1PLUGIN(JNIEnv *env, jclass cls) { return H5PL_VOL_PLUGIN; } +JNIEXPORT jint JNICALL Java_hdf_hdf5lib_HDF5Constants_H5PL_1ALL_1PLUGIN(JNIEnv *env, jclass cls) { return H5PL_ALL_PLUGIN; } JNIEXPORT jint JNICALL @@ -1239,6 +1254,28 @@ JNIEXPORT jint JNICALL Java_hdf_hdf5lib_HDF5Constants_H5T_1VL_1T(JNIEnv *env, jclass cls) { return sizeof(hvl_t); } JNIEXPORT jint JNICALL +Java_hdf_hdf5lib_HDF5Constants_H5VL_1CAP_1FLAG_1NONE(JNIEnv *env, jclass cls) { return H5VL_CAP_FLAG_NONE; } +JNIEXPORT jint JNICALL +Java_hdf_hdf5lib_HDF5Constants_H5VL_1CAP_1FLAG_1THREADSAFE(JNIEnv *env, jclass cls) { return H5VL_CAP_FLAG_THREADSAFE; } +JNIEXPORT jlong JNICALL +Java_hdf_hdf5lib_HDF5Constants_H5VL_1NATIVE(JNIEnv *env, jclass cls) { return H5VL_NATIVE; } +JNIEXPORT jobject JNICALL +Java_hdf_hdf5lib_HDF5Constants_H5VL_1NATIVE_1NAME(JNIEnv *env, jclass cls) { return (jstring)ENVPTR->NewStringUTF(ENVPAR H5VL_NATIVE_NAME); } +JNIEXPORT jint JNICALL +Java_hdf_hdf5lib_HDF5Constants_H5VL_1NATIVE_1VALUE(JNIEnv *env, jclass cls) { return H5VL_NATIVE_VALUE; } +JNIEXPORT jint JNICALL +Java_hdf_hdf5lib_HDF5Constants_H5VL_1NATIVE_1VERSION(JNIEnv *env, jclass cls) { return H5VL_NATIVE_VERSION; } + +JNIEXPORT jint JNICALL +Java_hdf_hdf5lib_HDF5Constants_H5_1VOL_1INVALID(JNIEnv *env, jclass cls) { return H5_VOL_INVALID; } +JNIEXPORT jint JNICALL +Java_hdf_hdf5lib_HDF5Constants_H5_1VOL_1NATIVE(JNIEnv *env, jclass cls) { return H5_VOL_NATIVE; } +JNIEXPORT jint JNICALL +Java_hdf_hdf5lib_HDF5Constants_H5_1VOL_1RESERVED(JNIEnv *env, jclass cls) { return H5_VOL_RESERVED; } +JNIEXPORT jint JNICALL +Java_hdf_hdf5lib_HDF5Constants_H5_1VOL_1MAX(JNIEnv *env, jclass cls) { return H5_VOL_MAX; } + +JNIEXPORT jint JNICALL Java_hdf_hdf5lib_HDF5Constants_H5Z_1CB_1CONT(JNIEnv *env, jclass cls) { return H5Z_CB_CONT; } JNIEXPORT jint JNICALL Java_hdf_hdf5lib_HDF5Constants_H5Z_1CB_1ERROR(JNIEnv *env, jclass cls) { return H5Z_CB_ERROR; } diff --git a/java/src/jni/h5aImp.c b/java/src/jni/h5aImp.c index aba2240..e0ec4ca 100644 --- a/java/src/jni/h5aImp.c +++ b/java/src/jni/h5aImp.c @@ -60,6 +60,94 @@ static herr_t H5AreadVL_str (JNIEnv *env, hid_t attr_id, hid_t mem_id, jobjectAr static herr_t H5A_iterate_cb(hid_t g_id, const char *name, const H5A_info_t *info, void *cb_data); +/********************/ +/* Local Macros */ +/********************/ + +#define PIN_BYTE_ARRAY() { \ + if (isCriticalPinning) \ + buffP = (jbyte*)ENVPTR->GetPrimitiveArrayCritical(ENVPAR buf, &isCopy); \ + else \ + buffP = ENVPTR->GetByteArrayElements(ENVPAR buf, &isCopy); \ +} + +#define UNPIN_BYTE_ARRAY(mode) { \ + if (isCriticalPinning) \ + ENVPTR->ReleasePrimitiveArrayCritical(ENVPAR buf, buffP, mode); \ + else \ + ENVPTR->ReleaseByteArrayElements(ENVPAR buf, buffP, mode); \ +} + +#define PIN_SHORT_ARRAY() { \ + if (isCriticalPinning) \ + buffP = (jshort*)ENVPTR->GetPrimitiveArrayCritical(ENVPAR buf, &isCopy); \ + else \ + buffP = ENVPTR->GetShortArrayElements(ENVPAR buf, &isCopy); \ +} + +#define UNPIN_SHORT_ARRAY(mode) { \ + if (isCriticalPinning) \ + ENVPTR->ReleasePrimitiveArrayCritical(ENVPAR buf, buffP, mode); \ + else \ + ENVPTR->ReleaseShortArrayElements(ENVPAR buf, buffP, mode); \ +} + +#define PIN_INT_ARRAY() { \ + if (isCriticalPinning) \ + buffP = (jint*)ENVPTR->GetPrimitiveArrayCritical(ENVPAR buf, &isCopy); \ + else \ + buffP = ENVPTR->GetIntArrayElements(ENVPAR buf, &isCopy); \ +} + +#define UNPIN_INT_ARRAY(mode) { \ + if (isCriticalPinning) \ + ENVPTR->ReleasePrimitiveArrayCritical(ENVPAR buf, buffP, mode); \ + else \ + ENVPTR->ReleaseIntArrayElements(ENVPAR buf, buffP, mode); \ +} + +#define PIN_LONG_ARRAY() { \ + if (isCriticalPinning) \ + buffP = (jlong*)ENVPTR->GetPrimitiveArrayCritical(ENVPAR buf, &isCopy); \ + else \ + buffP = ENVPTR->GetLongArrayElements(ENVPAR buf,&isCopy); \ +} + +#define UNPIN_LONG_ARRAY(mode) { \ + if (isCriticalPinning) \ + ENVPTR->ReleasePrimitiveArrayCritical(ENVPAR buf, buffP, mode); \ + else \ + ENVPTR->ReleaseLongArrayElements(ENVPAR buf, buffP, mode); \ +} + +#define PIN_FLOAT_ARRAY() { \ + if (isCriticalPinning) \ + buffP = (jfloat*)ENVPTR->GetPrimitiveArrayCritical(ENVPAR buf, &isCopy); \ + else \ + buffP = ENVPTR->GetFloatArrayElements(ENVPAR buf, &isCopy); \ +} + +#define UNPIN_FLOAT_ARRAY(mode) { \ + if (isCriticalPinning) \ + ENVPTR->ReleasePrimitiveArrayCritical(ENVPAR buf, buffP, mode); \ + else \ + ENVPTR->ReleaseFloatArrayElements(ENVPAR buf, buffP, mode); \ +} + +#define PIN_DOUBLE_ARRAY() { \ + if (isCriticalPinning) \ + buffP = (jdouble*)ENVPTR->GetPrimitiveArrayCritical(ENVPAR buf, &isCopy); \ + else \ + buffP = ENVPTR->GetDoubleArrayElements(ENVPAR buf, &isCopy); \ +} + +#define UNPIN_DOUBLE_ARRAY(mode) { \ + if (isCriticalPinning) \ + ENVPTR->ReleasePrimitiveArrayCritical(ENVPAR buf, buffP, mode); \ + else \ + ENVPTR->ReleaseDoubleArrayElements(ENVPAR buf, buffP, mode); \ +} + /* * Class: hdf_hdf5lib_H5 @@ -129,36 +217,129 @@ Java_hdf_hdf5lib_H5__1H5Aopen_1idx return (jlong)attr_id; } /* end Java_hdf_hdf5lib_H5__1H5Aopen_1idx */ +static htri_t +H5Tdetect_variable_str + (hid_t tid) { + htri_t ret_val = 0; + + if (H5Tget_class(tid) == H5T_COMPOUND) { + unsigned i; + unsigned nm = (unsigned)H5Tget_nmembers(tid); + for(i = 0; i < nm; i++) { + htri_t status = 0; + hid_t mtid = 0; + if((mtid = H5Tget_member_type(tid, i)) < 0) + return -1; /* exit immediately on error */ + if((status = H5Tdetect_variable_str(mtid)) < 0) + return status; /* exit immediately on error */ + ret_val |= status; + H5Tclose (mtid); + } /* end for */ + } /* end if */ + else + ret_val = H5Tis_variable_str(tid); + + return ret_val; +} /* end H5Tdetect_variable_str */ + +/* + * Class: hdf_hdf5lib_H5 + * Method: H5Aread + * Signature: (JJ[BZ)I + */ +JNIEXPORT jint JNICALL +Java_hdf_hdf5lib_H5_H5Aread + (JNIEnv *env, jclass clss, jlong attr_id, jlong mem_type_id, jbyteArray buf, jboolean isCriticalPinning) +{ + herr_t status = -1; + jbyte *buffP; + jboolean isCopy; + htri_t data_class; + + if (buf == NULL) { + h5nullArgument( env,"H5Aread: buf is NULL"); + } /* end if */ + else if((data_class = H5Tdetect_class(mem_type_id, H5T_VLEN)) < 0) { + h5JNIFatalError(env, "H5Aread: H5Tdetect_class() failed"); + } /* end else if */ + else if(data_class == 1) { + h5badArgument(env, "H5Aread: buf does not support variable length type"); + } /* end else if */ + else { + /* recursive detect any vlen string in type (compound, array ...) */ + if((data_class = H5Tdetect_variable_str(mem_type_id)) < 0) { + h5JNIFatalError(env, "H5Aread: H5Tdetect_variable_str() failed"); + } /* end if */ + else if(data_class == 1) { + h5badArgument(env, "H5Aread: buf does not support variable length type"); + } /* end else if */ + else { + PIN_BYTE_ARRAY(); + + if (buffP == NULL) { + h5JNIFatalError(env, "H5Aread: buf not pinned"); + } /* end if */ + else { + status = H5Aread((hid_t)attr_id, (hid_t)mem_type_id, buffP); + if (status < 0) { + UNPIN_BYTE_ARRAY(JNI_ABORT); + h5libraryError(env); + } /* end if */ + else { + UNPIN_BYTE_ARRAY(0); /* update java buffer for return */ + } /* end else */ + } /* end else */ + } /* end else */ + } /* end else */ + + return (jint)status; +} /* end Java_hdf_hdf5lib_H5_H5Aread */ + /* * Class: hdf_hdf5lib_H5 * Method: H5Awrite - * Signature: (JJ[B)I + * Signature: (JJ[BZ)I */ JNIEXPORT jint JNICALL Java_hdf_hdf5lib_H5_H5Awrite - (JNIEnv *env, jclass clss, jlong attr_id, jlong mem_type_id, jbyteArray buf) + (JNIEnv *env, jclass clss, jlong attr_id, jlong mem_type_id, jbyteArray buf, jboolean isCriticalPinning) { herr_t status = -1; - jbyte *byteP; + jbyte *buffP; jboolean isCopy; + htri_t data_class; if (buf == NULL) { h5nullArgument( env,"H5Awrite: buf is NULL"); } /* end if */ + else if((data_class = H5Tdetect_class(mem_type_id, H5T_VLEN)) < 0) { + h5JNIFatalError(env, "H5Awrite: H5Tdetect_class() failed"); + } /* end else if */ + else if(data_class == 1) { + h5badArgument(env, "H5Awrite: buf does not support variable length type"); + } /* end else if */ else { - byteP = ENVPTR->GetByteArrayElements(ENVPAR buf, &isCopy); - if (byteP == NULL) { - h5JNIFatalError(env,"H5Awrite: buf is not pinned"); + /* recursive detect any vlen string in type (compound, array ...) */ + if((data_class = H5Tdetect_variable_str(mem_type_id)) < 0) { + h5JNIFatalError(env, "H5Awrite: H5Tdetect_variable_str() failed"); } /* end if */ + else if(data_class == 1) { + h5badArgument(env, "H5Awrite: buf does not support variable length type"); + } /* end else if */ else { - status = H5Awrite((hid_t)attr_id, (hid_t)mem_type_id, byteP); + PIN_BYTE_ARRAY(); + if (buffP == NULL) { + h5JNIFatalError(env, "H5Awrite: buf not pinned"); + } /* end if */ + else { + status = H5Awrite((hid_t)attr_id, (hid_t)mem_type_id, buffP); - /* free the buffer without copying back */ - ENVPTR->ReleaseByteArrayElements(ENVPAR buf, byteP, JNI_ABORT); + UNPIN_BYTE_ARRAY(JNI_ABORT); /* no need to update buffer */ - if (status < 0) - h5libraryError(env); - } + if (status < 0) + h5libraryError(env); + } /* end else */ + } /* end else */ } /* end else */ return (jint)status; @@ -166,190 +347,653 @@ Java_hdf_hdf5lib_H5_H5Awrite /* * Class: hdf_hdf5lib_H5 - * Method: H5Aread - * Signature: (JJ[B)I + * Method: H5Aread_short + * Signature: (JJ[SZ)I */ JNIEXPORT jint JNICALL -Java_hdf_hdf5lib_H5_H5Aread - (JNIEnv *env, jclass clss, jlong attr_id, jlong mem_type_id, jbyteArray buf) +Java_hdf_hdf5lib_H5_H5Aread_1short + (JNIEnv *env, jclass clss, jlong attr_id, jlong mem_type_id, jshortArray buf, jboolean isCriticalPinning) { herr_t status = -1; - jbyte *byteP; + jshort *buffP; jboolean isCopy; + htri_t data_class; if (buf == NULL) { - h5nullArgument( env,"H5Aread: buf is NULL"); + h5nullArgument(env, "H5Aread_short: buf is NULL"); } /* end if */ + else if((data_class = H5Tdetect_class(mem_type_id, H5T_VLEN)) < 0) { + h5JNIFatalError(env, "H5Aread: H5Tdetect_class() failed"); + } /* end else if */ + else if(data_class == 1) { + h5badArgument(env, "H5Aread_short: buf does not support variable length type"); + } /* end else if */ else { - byteP = ENVPTR->GetByteArrayElements(ENVPAR buf, &isCopy); - if (byteP == NULL) { - h5JNIFatalError( env,"H5Aread: buf is not pinned"); + /* recursive detect any vlen string in type (compound, array ...) */ + if((data_class = H5Tdetect_variable_str(mem_type_id)) < 0) { + h5JNIFatalError(env, "H5Aread_short: H5Tdetect_variable_str() failed"); } /* end if */ + else if(data_class == 1) { + h5badArgument(env, "H5Aread_short: buf does not support variable length type"); + } /* end else if */ else { - status = H5Aread((hid_t)attr_id, (hid_t)mem_type_id, byteP); - if (status < 0) { - ENVPTR->ReleaseByteArrayElements(ENVPAR buf, byteP, JNI_ABORT); - h5libraryError(env); + PIN_SHORT_ARRAY(); + if (buffP == NULL) { + h5JNIFatalError(env, "H5Aread_short: buf not pinned"); } /* end if */ - else { - ENVPTR->ReleaseByteArrayElements(ENVPAR buf, byteP, 0); + else { + status = H5Aread((hid_t)attr_id, (hid_t)mem_type_id, buffP); + + if (status < 0) { + UNPIN_SHORT_ARRAY(JNI_ABORT); + h5libraryError(env); + } /* end if */ + else { + UNPIN_SHORT_ARRAY(0); + } /* end else */ } /* end else */ } /* end else */ } /* end else */ return (jint)status; -} /* end Java_hdf_hdf5lib_H5_H5Aread */ +} /* end Java_hdf_hdf5lib_H5_H5Aread_1short */ /* * Class: hdf_hdf5lib_H5 - * Method: H5AwriteVL - * Signature: (JJ[Ljava/lang/String;)I + * Method: H5Awrite_short + * Signature: (JJ[SZ)I */ JNIEXPORT jint JNICALL -Java_hdf_hdf5lib_H5_H5AwriteVL - (JNIEnv *env, jclass clss, jlong attr_id, jlong mem_type_id, jobjectArray buf) +Java_hdf_hdf5lib_H5_H5Awrite_1short + (JNIEnv *env, jclass clss, jlong attr_id, jlong mem_type_id, jshortArray buf, jboolean isCriticalPinning) { - herr_t status = -1; - htri_t isStr = 0; - htri_t isVlenStr = 0; - htri_t isComplex = 0; + herr_t status = -1; + jshort *buffP; + jboolean isCopy; + htri_t data_class; + + if (buf == NULL ) { + h5nullArgument(env, "H5Awrite_short: buf is NULL"); + } /* end if */ + else if((data_class = H5Tdetect_class(mem_type_id, H5T_VLEN)) < 0) { + h5JNIFatalError(env, "H5Awrite_short: H5Tdetect_class() failed"); + } /* end else if */ + else if(data_class == 1) { + h5badArgument(env, "H5Awrite_short: buf does not support variable length type"); + } /* end else if */ + else { + /* recursive detect any vlen string in type (compound, array ...) */ + if((data_class = H5Tdetect_variable_str(mem_type_id)) < 0) { + h5JNIFatalError(env, "H5Awrite_short: H5Tdetect_variable_str() failed"); + } /* end if */ + else if(data_class == 1) { + h5badArgument(env, "H5Awrite_short: buf does not support variable length type"); + } /* end else if */ + else { + PIN_SHORT_ARRAY(); + if (buffP == NULL) { + h5JNIFatalError(env, "H5Awrite_short: buf not pinned"); + } /* end if */ + else { + status = H5Awrite((hid_t)attr_id, (hid_t)mem_type_id, buffP); + + UNPIN_SHORT_ARRAY(JNI_ABORT); + + if (status < 0) + h5libraryError(env); + } /* end else */ + } /* end else */ + } /* end else */ + + return (jint)status; +} /* end Java_hdf_hdf5lib_H5_H5Awrite_1short */ + +/* + * Class: hdf_hdf5lib_H5 + * Method: H5Aread_int + * Signature: (JJ[IZ)I + */ +JNIEXPORT jint JNICALL +Java_hdf_hdf5lib_H5_H5Aread_1int + (JNIEnv *env, jclass clss, jlong attr_id, jlong mem_type_id, jintArray buf, jboolean isCriticalPinning) +{ + herr_t status = -1; + jint *buffP; + jboolean isCopy; + htri_t data_class; if (buf == NULL) { - h5nullArgument(env, "H5AwriteVL: buf is NULL"); + h5nullArgument(env, "H5Aread_int: buf is NULL"); } /* end if */ + else if((data_class = H5Tdetect_class(mem_type_id, H5T_VLEN)) < 0) { + h5JNIFatalError(env, "H5Aread_int: H5Tdetect_class() failed"); + } /* end else if */ + else if(data_class == 1) { + h5badArgument(env, "H5Aread_int: buf does not support variable length type"); + } /* end else if */ else { - isStr = H5Tdetect_class((hid_t)mem_type_id, H5T_STRING); - if (H5Tget_class((hid_t)mem_type_id) == H5T_COMPOUND) { - unsigned i; - int nm = H5Tget_nmembers(mem_type_id); - for(i = 0; i <nm; i++) { - hid_t nested_tid = H5Tget_member_type((hid_t)mem_type_id, i); - isComplex = H5Tdetect_class((hid_t)nested_tid, H5T_COMPOUND) || - H5Tdetect_class((hid_t)nested_tid, H5T_VLEN); - H5Tclose(nested_tid); - } - } - else if (H5Tget_class((hid_t)mem_type_id) == H5T_VLEN) { - isVlenStr = 1; /* strings created by H5Tvlen_create(H5T_C_S1) */ - } - if (isStr == 0 || isComplex>0 || isVlenStr) { - status = H5AwriteVL_asstr(env, (hid_t)attr_id, (hid_t)mem_type_id, buf); - } - else if (isStr > 0) { - status = H5AwriteVL_str(env, (hid_t)attr_id, (hid_t)mem_type_id, buf); - } + /* recursive detect any vlen string in type (compound, array ...) */ + if((data_class = H5Tdetect_variable_str(mem_type_id)) < 0) { + h5JNIFatalError(env, "H5Aread_int: H5Tdetect_variable_str() failed"); + } /* end if */ + else if(data_class == 1) { + h5badArgument(env, "H5Aread_int: buf does not support variable length type"); + } /* end else if */ + else { + PIN_INT_ARRAY(); + if (buffP == NULL) { + h5JNIFatalError(env, "H5Aread_int: buf not pinned"); + } /* end if */ + else { + status = H5Aread((hid_t)attr_id, (hid_t)mem_type_id, buffP); + + if (status < 0) { + UNPIN_INT_ARRAY(JNI_ABORT); + h5libraryError(env); + } /* end if */ + else { + UNPIN_INT_ARRAY(0); + } /* end else */ + } /* end else */ + } /* end else */ } /* end else */ return (jint)status; -} /* end Java_hdf_hdf5lib_H5_H5Awrite_1VL */ +} /* end Java_hdf_hdf5lib_H5_H5Aread_1int */ -herr_t -H5AwriteVL_str - (JNIEnv *env, hid_t aid, hid_t tid, jobjectArray buf) +/* + * Class: hdf_hdf5lib_H5 + * Method: H5Awrite_int + * Signature: (JJ[IZ)I + */ +JNIEXPORT jint JNICALL +Java_hdf_hdf5lib_H5_H5Awrite_1int + (JNIEnv *env, jclass clss, jlong attr_id, jlong mem_type_id, jintArray buf, jboolean isCriticalPinning) { - herr_t status = -1; - char **wdata; - jsize size; - jint i; + herr_t status = -1; + jint *buffP; + jboolean isCopy; + htri_t data_class; - size = ENVPTR->GetArrayLength(ENVPAR (jarray) buf); + if (buf == NULL) { + h5nullArgument(env, "H5Awrite_int: buf is NULL"); + } /* end if */ + else if((data_class = H5Tdetect_class(mem_type_id, H5T_VLEN)) < 0) { + h5JNIFatalError(env, "H5Awrite_int: H5Tdetect_class() failed"); + } /* end else if */ + else if(data_class == 1) { + h5badArgument(env, "H5Awrite_int: buf does not support variable length type"); + } /* end else if */ + else { + /* recursive detect any vlen string in type (compound, array ...) */ + if((data_class = H5Tdetect_variable_str(mem_type_id)) < 0) { + h5JNIFatalError(env, "H5Awrite_int: H5Tdetect_variable_str() failed"); + } /* end if */ + else if(data_class == 1) { + h5badArgument(env, "H5Awrite_int: buf does not support variable length type"); + } /* end else if */ + else { + PIN_INT_ARRAY(); + if (buffP == NULL) { + h5JNIFatalError(env, "H5Awrite_int: buf not pinned"); + } /* end if */ + else { + status = H5Awrite((hid_t)attr_id, (hid_t)mem_type_id, buffP); - wdata = (char**)HDcalloc((size_t)size + 1, sizeof(char*)); - if (!wdata) { - h5JNIFatalError(env, "H5AwriteVL_str: cannot allocate buffer"); + UNPIN_INT_ARRAY(JNI_ABORT); + + if (status < 0) + h5libraryError(env); + } /* end else */ + } /* end else */ + } /* end else */ + + return (jint)status; +} /* end Java_hdf_hdf5lib_H5_H5Awrite_1int */ + +/* + * Class: hdf_hdf5lib_H5 + * Method: H5Aread_long + * Signature: (JJ[JZ)I + */ +JNIEXPORT jint JNICALL +Java_hdf_hdf5lib_H5_H5Aread_1long + (JNIEnv *env, jclass clss, jlong attr_id, jlong mem_type_id, jlongArray buf, jboolean isCriticalPinning) +{ + herr_t status = -1; + jlong *buffP; + jboolean isCopy; + htri_t data_class; + + if (buf == NULL) { + h5nullArgument(env, "H5Aread_long: buf is NULL"); } /* end if */ + else if((data_class = H5Tdetect_class(mem_type_id, H5T_VLEN)) < 0) { + h5JNIFatalError(env, "H5Aread_long: H5Tdetect_class() failed"); + } /* end else if */ + else if(data_class == 1) { + h5badArgument(env, "H5Aread_long: buf does not support variable length type"); + } /* end else if */ else { - HDmemset(wdata, 0, (size_t)size * sizeof(char*)); - for (i = 0; i < size; ++i) { - jstring obj = (jstring) ENVPTR->GetObjectArrayElement(ENVPAR (jobjectArray) buf, i); - if (obj != 0) { - jsize length = ENVPTR->GetStringUTFLength(ENVPAR obj); - const char *utf8 = ENVPTR->GetStringUTFChars(ENVPAR obj, 0); + /* recursive detect any vlen string in type (compound, array ...) */ + if((data_class = H5Tdetect_variable_str(mem_type_id)) < 0) { + h5JNIFatalError(env, "H5Aread_long: H5Tdetect_variable_str() failed"); + } /* end if */ + else if(data_class == 1) { + h5badArgument(env, "H5Aread_long: buf does not support variable length type"); + } /* end else if */ + else { + PIN_LONG_ARRAY(); + if (buffP == NULL) { + h5JNIFatalError(env, "H5Aread_long: buf not pinned"); + } /* end if */ + else { + status = H5Aread((hid_t)attr_id, (hid_t)mem_type_id, buffP); - if (utf8) { - wdata[i] = (char*)HDmalloc((size_t)length + 1); - if (wdata[i]) { - HDmemset(wdata[i], 0, ((size_t)length + 1)); - HDstrncpy(wdata[i], utf8, (size_t)length); - } /* end if */ + if (status < 0) { + UNPIN_LONG_ARRAY(JNI_ABORT); + h5libraryError(env); } /* end if */ + else { + UNPIN_LONG_ARRAY(0); + } /* end else */ + } /* end else */ + } /* end else */ + } /* end else */ - ENVPTR->ReleaseStringUTFChars(ENVPAR obj, utf8); - ENVPTR->DeleteLocalRef(ENVPAR obj); + return (jint)status; +} /* end Java_hdf_hdf5lib_H5_H5Aread_1long */ + +/* + * Class: hdf_hdf5lib_H5 + * Method: H5Awrite_long + * Signature: (JJ[JZ)I + */ +JNIEXPORT jint JNICALL +Java_hdf_hdf5lib_H5_H5Awrite_1long + (JNIEnv *env, jclass clss, jlong attr_id, jlong mem_type_id, jlongArray buf, jboolean isCriticalPinning) +{ + herr_t status = -1; + jlong *buffP; + jboolean isCopy; + htri_t data_class; + + if (buf == NULL) { + h5nullArgument(env, "H5Awrite_long: buf is NULL"); + } /* end if */ + else if((data_class = H5Tdetect_class(mem_type_id, H5T_VLEN)) < 0) { + h5JNIFatalError(env, "H5Dwrite_long: H5Tdetect_class() failed"); + } /* end else if */ + else if(data_class == 1) { + h5badArgument(env, "H5Awrite_long: buf does not support variable length type"); + } /* end else if */ + else { + /* recursive detect any vlen string in type (compound, array ...) */ + if((data_class = H5Tdetect_variable_str(mem_type_id)) < 0) { + h5JNIFatalError(env, "H5Awrite_long: H5Tdetect_variable_str() failed"); + } /* end if */ + else if(data_class == 1) { + h5badArgument(env, "H5Awrite_long: buf does not support variable length type"); + } /* end else if */ + else { + PIN_LONG_ARRAY(); + if (buffP == NULL) { + h5JNIFatalError(env, "H5Awrite_long: buf not pinned"); } /* end if */ - } /* end for (i = 0; i < size; ++i) */ + else { + status = H5Awrite((hid_t)attr_id, (hid_t)mem_type_id, buffP); - status = H5Awrite((hid_t)aid, (hid_t)tid, wdata); + UNPIN_LONG_ARRAY(JNI_ABORT); + if (status < 0) + h5libraryError(env); + } /* end else */ + } /* end else */ + } /* end else */ - for (i = 0; i < size; i++) { - if(wdata[i]) { - HDfree(wdata[i]); + return (jint)status; +} /* end Java_hdf_hdf5lib_H5_H5Awrite_1long */ + +/* + * Class: hdf_hdf5lib_H5 + * Method: H5Aread_float + * Signature: (JJ[FZ)I + */ +JNIEXPORT jint JNICALL +Java_hdf_hdf5lib_H5_H5Aread_1float + (JNIEnv *env, jclass clss, jlong attr_id, jlong mem_type_id, jfloatArray buf, jboolean isCriticalPinning) +{ + herr_t status = -1; + jfloat *buffP; + jboolean isCopy; + htri_t data_class; + + if (buf == NULL) { + h5nullArgument(env, "H5Aread_float: buf is NULL"); + } /* end if */ + else if((data_class = H5Tdetect_class(mem_type_id, H5T_VLEN)) < 0) { + h5JNIFatalError(env, "H5Dread_float: H5Tdetect_class() failed"); + } /* end else if */ + else if(data_class == 1) { + h5badArgument(env, "H5Aread_float: buf does not support variable length type"); + } /* end else if */ + else { + /* recursive detect any vlen string in type (compound, array ...) */ + if((data_class = H5Tdetect_variable_str(mem_type_id)) < 0) { + h5JNIFatalError(env, "H5Aread_float: H5Tdetect_variable_str() failed"); + } /* end if */ + else if(data_class == 1) { + h5badArgument(env, "H5Aread_float: buf does not support variable length type"); + } /* end else if */ + else { + PIN_FLOAT_ARRAY(); + if (buffP == NULL) { + h5JNIFatalError(env, "H5Aread_float: buf not pinned"); } /* end if */ - } /* end for */ - HDfree(wdata); + else { + status = H5Aread((hid_t)attr_id, (hid_t)mem_type_id, buffP); - if (status < 0) - h5libraryError(env); + if (status < 0) { + UNPIN_FLOAT_ARRAY(JNI_ABORT); + h5libraryError(env); + } /* end if */ + else { + UNPIN_FLOAT_ARRAY(0); + } /* end else */ + } /* end else */ + } /* end else */ } /* end else */ return (jint)status; -} +} /* end Java_hdf_hdf5lib_H5_H5Aread_1float */ -herr_t -H5AwriteVL_asstr - (JNIEnv *env, hid_t aid, hid_t tid, jobjectArray buf) +/* + * Class: hdf_hdf5lib_H5 + * Method: H5Awrite_float + * Signature: (JJ[FZ)I + */ +JNIEXPORT jint JNICALL +Java_hdf_hdf5lib_H5_H5Awrite_1float + (JNIEnv *env, jclass clss, jlong attr_id, jlong mem_type_id, jfloatArray buf, jboolean isCriticalPinning) { - char **strs; - jstring jstr; - jint i; - jint n; - hid_t sid; - hsize_t dims[H5S_MAX_RANK]; - herr_t status = -1; + herr_t status = -1; + jfloat *buffP; + jboolean isCopy; + htri_t data_class; - n = ENVPTR->GetArrayLength(ENVPAR buf); - strs =(hvl_t*)HDcalloc((size_t)n, sizeof(hvl_t)); + if (buf == NULL) { + h5nullArgument(env, "H5Awrite_float: buf is NULL"); + } /* end if */ + else if((data_class = H5Tdetect_class(mem_type_id, H5T_VLEN)) < 0) { + h5JNIFatalError(env, "H5Awrite_float: H5Tdetect_class() failed"); + } /* end else if */ + else if(data_class == 1) { + h5badArgument(env, "H5Awrite_float: buf does not support variable length type"); + } /* end else if */ + else { + /* recursive detect any vlen string in type (compound, array ...) */ + if((data_class = H5Tdetect_variable_str(mem_type_id)) < 0) { + h5JNIFatalError(env, "H5Awrite_float: H5Tdetect_variable_str() failed"); + } /* end if */ + else if(data_class == 1) { + h5badArgument(env, "H5Awrite_float: buf does not support variable length type"); + } /* end else if */ + else { + PIN_FLOAT_ARRAY(); + if (buffP == NULL) { + h5JNIFatalError(env, "H5Awrite_float: buf not pinned"); + } /* end if */ + else { + status = H5Awrite((hid_t)attr_id, (hid_t)mem_type_id, buffP); - if (strs == NULL) { - h5JNIFatalError(env, "H5AwriteVL_asstr: failed to allocate buff for read variable length strings"); + UNPIN_FLOAT_ARRAY(JNI_ABORT); + if (status < 0) + h5libraryError(env); + } /* end else */ + } /* end else */ + } /* end else */ + + return (jint)status; +} /* end Java_hdf_hdf5lib_H5_H5Awrite_1float */ + +/* + * Class: hdf_hdf5lib_H5 + * Method: H5Aread_double + * Signature: (JJ[DZ)I + */ +JNIEXPORT jint JNICALL +Java_hdf_hdf5lib_H5_H5Aread_1double + (JNIEnv *env, jclass clss, jlong attr_id, jlong mem_type_id, jdoubleArray buf, jboolean isCriticalPinning) +{ + herr_t status = -1; + jdouble *buffP; + jboolean isCopy; + htri_t data_class; + + if (buf == NULL) { + h5nullArgument(env, "H5Aread_double: buf is NULL"); } /* end if */ + else if((data_class = H5Tdetect_class(mem_type_id, H5T_VLEN)) < 0) { + h5JNIFatalError(env, "H5Aread_double: H5Tdetect_class() failed"); + } /* end else if */ + else if(data_class == 1) { + h5badArgument(env, "H5Aread_double: buf does not support variable length type"); + } /* end else if */ else { - status = H5Awrite(aid, tid, strs); + /* recursive detect any vlen string in type (compound, array ...) */ + if((data_class = H5Tdetect_variable_str(mem_type_id)) < 0) { + h5JNIFatalError(env, "H5Aread_double: H5Tdetect_variable_str() failed"); + } /* end if */ + else if(data_class == 1) { + h5badArgument(env, "H5Aread_double: buf does not support variable length type"); + } /* end else if */ + else { + PIN_DOUBLE_ARRAY(); + if (buffP == NULL) { + h5JNIFatalError(env, "H5Aread_double: buf not pinned"); + } /* end if */ + else { + status = H5Aread((hid_t)attr_id, (hid_t)mem_type_id, buffP); - if (status < 0) { - dims[0] = (hsize_t)n; - sid = H5Screate_simple(1, dims, NULL); - H5Dvlen_reclaim(tid, sid, H5P_DEFAULT, strs); - H5Sclose(sid); - HDfree(strs); - h5JNIFatalError(env, "H5AwriteVL_str: failed to read variable length strings"); + if (status < 0) { + UNPIN_DOUBLE_ARRAY(JNI_ABORT); + h5libraryError(env); + } /* end if */ + else { + UNPIN_DOUBLE_ARRAY(0); + } /* end else */ + } /* end else */ + } /* end else */ + } /* end else */ + + return (jint)status; +} /* end Java_hdf_hdf5lib_H5_H5Aread_1double */ + +/* + * Class: hdf_hdf5lib_H5 + * Method: H5Awrite_double + * Signature: (JJ[DZ)I + */ +JNIEXPORT jint JNICALL +Java_hdf_hdf5lib_H5_H5Awrite_1double + (JNIEnv *env, jclass clss, jlong attr_id, jlong mem_type_id, jdoubleArray buf, jboolean isCriticalPinning) +{ + herr_t status = -1; + jdouble *buffP; + jboolean isCopy; + htri_t data_class; + + if (buf == NULL) { + h5nullArgument(env, "H5Awrite_double: buf is NULL"); + } /* end if */ + else if((data_class = H5Tdetect_class(mem_type_id, H5T_VLEN)) < 0) { + h5JNIFatalError(env, "H5Awrite_double: H5Tdetect_class() failed"); + } /* end else if */ + else if(data_class == 1) { + h5badArgument(env, "H5Awrite_double: buf does not support variable length type"); + } /* end else if */ + else { + /* recursive detect any vlen string in type (compound, array ...) */ + if((data_class = H5Tdetect_variable_str(mem_type_id)) < 0) { + h5JNIFatalError(env, "H5Awrite_double: H5Tdetect_variable_str() failed"); } /* end if */ + else if(data_class == 1) { + h5badArgument(env, "H5Awrite_double: buf does not support variable length type"); + } /* end else if */ else { - for (i=0; i < n; i++) { - jstr = ENVPTR->NewStringUTF(ENVPAR strs[i]); - ENVPTR->SetObjectArrayElement(ENVPAR buf, i, jstr); - H5free_memory (strs[i]); + PIN_DOUBLE_ARRAY(); + if (buffP == NULL) { + h5JNIFatalError(env, "H5Awrite_double: buf not pinned"); + } /* end if */ + else { + status = H5Awrite((hid_t)attr_id, (hid_t)mem_type_id, buffP); + + UNPIN_DOUBLE_ARRAY(JNI_ABORT); + if (status < 0) + h5libraryError(env); + } /* end else */ + } /* end else */ + } /* end else */ + + return (jint)status; +} /* end Java_hdf_hdf5lib_H5_H5Awrite_1double */ + +/* + * Class: hdf_hdf5lib_H5 + * Method: H5Aread_string + * Signature: (JJ[Ljava/lang/String;)I + */ +JNIEXPORT jint JNICALL +Java_hdf_hdf5lib_H5_H5Aread_1string + (JNIEnv *env, jclass clss, jlong attr_id, jlong mem_type_id, jobjectArray j_buf) +{ + herr_t status = -1; + char *c_buf; + char *cstr; + size_t str_len; + jsize i; + jsize n; + size_t pos; + jstring jstr; + + c_buf = cstr = NULL; + if (j_buf == NULL) { + h5nullArgument(env, "H5Aread_string: buf is NULL"); + } /* end if */ + else if ((n = ENVPTR->GetArrayLength(ENVPAR j_buf)) <= 0) { + h5nullArgument(env, "H5Aread_string: buf length <= 0"); + } /* end else if */ + else if ((str_len = H5Tget_size((hid_t)mem_type_id)) <=0) { + h5libraryError(env); + } /* end else if */ + else { + if ((cstr = (char*)HDmalloc(str_len + 1)) == NULL) { + h5JNIFatalError(env, "H5Aread_string: memory allocation failed."); + } /* end if */ + else { + if ((c_buf = (char*)HDmalloc((size_t)n * str_len)) == NULL) { + if (cstr) + HDfree(cstr); + cstr = NULL; + h5JNIFatalError(env, "H5Aread_string: memory allocation failed."); + } /* end if */ + else { + status = H5Aread((hid_t)attr_id, (hid_t)mem_type_id, c_buf); + + if (status < 0) { + if (cstr) + HDfree(cstr); + cstr = NULL; + if (c_buf) + HDfree(c_buf); + c_buf = NULL; + h5libraryError(env); + } /* end if */ + else { + pos = 0; + for (i = 0; i < n; i++) { + HDmemcpy(cstr, c_buf+pos, str_len); + cstr[str_len] = '\0'; + jstr = ENVPTR->NewStringUTF(ENVPAR cstr); + ENVPTR->SetObjectArrayElement(ENVPAR j_buf, i, jstr); + pos += str_len; + } /* end for */ + } /* end else */ + + if (c_buf) + HDfree(c_buf); + } /* end else cbuf allocation*/ + + if (cstr) + HDfree(cstr); + } /* end else cstr allocation*/ + } /* end else */ + + return (jint)status; +} /* end Java_hdf_hdf5lib_H5_H5Aread_1string */ + +/* + * Class: hdf_hdf5lib_H5 + * Method: H5Awrite_string + * Signature: (JJ[Ljava/lang/String;)I + */ +JNIEXPORT jint JNICALL +Java_hdf_hdf5lib_H5_H5Awrite_1string + (JNIEnv *env, jclass clss, jlong attr_id, jlong mem_type_id, jobjectArray j_buf) +{ + herr_t status = -1; + char *c_buf; + jsize str_len; + jsize i; + jsize n; + + if (j_buf == NULL) { + h5nullArgument(env, "H5Awrite_string: buf is NULL"); + } /* end if */ + else if ((n = ENVPTR->GetArrayLength(ENVPAR j_buf)) <= 0) { + h5nullArgument(env, "H5Awrite_string: buf length <= 0"); + } /* end else if */ + else if ((str_len = (jsize)H5Tget_size((hid_t)mem_type_id)) <=0) { + h5libraryError(env); + } /* end else if */ + else { + if ((c_buf = (char*)HDmalloc((size_t)n * (size_t)str_len)) == NULL) { + h5JNIFatalError(env, "H5Awrite_string: memory allocation failed."); + } /* end if */ + else { + for (i = 0; i < n; i++) { + jstring obj = (jstring)ENVPTR->GetObjectArrayElement(ENVPAR (jobjectArray)j_buf, i); + if (obj != 0) { + jsize length = ENVPTR->GetStringUTFLength(ENVPAR obj); + const char *utf8 = ENVPTR->GetStringUTFChars(ENVPAR obj, 0); + + if (utf8) { + HDstrncpy(&c_buf[i * str_len], utf8, str_len); + } /* end if */ + + ENVPTR->ReleaseStringUTFChars(ENVPAR obj, utf8); + ENVPTR->DeleteLocalRef(ENVPAR obj); + } /* end if */ } /* end for */ - /* - for repeatedly reading a dataset with a large number of strs (e.g., 1,000,000 strings, - H5Dvlen_reclaim() may crash on Windows because the Java GC will not be able to collect - free space in time. Instead, use "H5free_memory(strs[i])" above to free individual strings - after it is done. - H5Dvlen_reclaim(tid, mem_sid, xfer_plist_id, strs); - */ + status = H5Awrite((hid_t)attr_id, (hid_t)mem_type_id, c_buf); - HDfree(strs); + if (c_buf) + HDfree(c_buf); + c_buf = NULL; + + if (status < 0) { + h5libraryError(env); + } /* end if */ } /* end else */ } /* end else */ - return status; -} /* end H5AwriteVL_str */ + return (jint)status; +} /* end Java_hdf_hdf5lib_H5_H5Awrite_1string */ /* * Class: hdf_hdf5lib_H5 * Method: H5AreadVL - * Signature: (JJJJJ[Ljava/lang/String;)I + * Signature: (JJ[Ljava/lang/String;)I */ JNIEXPORT jint JNICALL Java_hdf_hdf5lib_H5_H5AreadVL @@ -519,6 +1163,206 @@ H5AreadVL_str /* * Class: hdf_hdf5lib_H5 + * Method: H5AwriteVL + * Signature: (JJ[Ljava/lang/String;)I + */ +JNIEXPORT jint JNICALL +Java_hdf_hdf5lib_H5_H5AwriteVL + (JNIEnv *env, jclass clss, jlong attr_id, jlong mem_type_id, jobjectArray buf) +{ + herr_t status = -1; + htri_t isStr = 0; + htri_t isVlenStr = 0; + htri_t isComplex = 0; + + if (buf == NULL) { + h5nullArgument(env, "H5AwriteVL: buf is NULL"); + } /* end if */ + else { + isStr = H5Tdetect_class((hid_t)mem_type_id, H5T_STRING); + if (H5Tget_class((hid_t)mem_type_id) == H5T_COMPOUND) { + unsigned i; + int nm = H5Tget_nmembers(mem_type_id); + for(i = 0; i <nm; i++) { + hid_t nested_tid = H5Tget_member_type((hid_t)mem_type_id, i); + isComplex = H5Tdetect_class((hid_t)nested_tid, H5T_COMPOUND) || + H5Tdetect_class((hid_t)nested_tid, H5T_VLEN); + H5Tclose(nested_tid); + } + } + else if (H5Tget_class((hid_t)mem_type_id) == H5T_VLEN) { + isVlenStr = 1; /* strings created by H5Tvlen_create(H5T_C_S1) */ + } + if (isStr == 0 || isComplex>0 || isVlenStr) { + status = H5AwriteVL_asstr(env, (hid_t)attr_id, (hid_t)mem_type_id, buf); + } + else if (isStr > 0) { + status = H5AwriteVL_str(env, (hid_t)attr_id, (hid_t)mem_type_id, buf); + } + } /* end else */ + + return (jint)status; +} /* end Java_hdf_hdf5lib_H5_H5Awrite_1VL */ + +herr_t +H5AwriteVL_str + (JNIEnv *env, hid_t aid, hid_t tid, jobjectArray buf) +{ + herr_t status = -1; + char **wdata; + jsize size; + jint i; + + size = ENVPTR->GetArrayLength(ENVPAR (jarray) buf); + + wdata = (char**)HDcalloc((size_t)size + 1, sizeof(char*)); + if (!wdata) { + h5JNIFatalError(env, "H5AwriteVL_str: cannot allocate buffer"); + } /* end if */ + else { + HDmemset(wdata, 0, (size_t)size * sizeof(char*)); + for (i = 0; i < size; ++i) { + jstring obj = (jstring) ENVPTR->GetObjectArrayElement(ENVPAR (jobjectArray) buf, i); + if (obj != 0) { + jsize length = ENVPTR->GetStringUTFLength(ENVPAR obj); + const char *utf8 = ENVPTR->GetStringUTFChars(ENVPAR obj, 0); + + if (utf8) { + wdata[i] = (char*)HDmalloc((size_t)length + 1); + if (wdata[i]) { + HDmemset(wdata[i], 0, ((size_t)length + 1)); + HDstrncpy(wdata[i], utf8, (size_t)length); + } /* end if */ + } /* end if */ + + ENVPTR->ReleaseStringUTFChars(ENVPAR obj, utf8); + ENVPTR->DeleteLocalRef(ENVPAR obj); + } /* end if */ + } /* end for (i = 0; i < size; ++i) */ + + status = H5Awrite((hid_t)aid, (hid_t)tid, wdata); + + for (i = 0; i < size; i++) { + if(wdata[i]) { + HDfree(wdata[i]); + } /* end if */ + } /* end for */ + HDfree(wdata); + + if (status < 0) + h5libraryError(env); + } /* end else */ + + return (jint)status; +} + +herr_t +H5AwriteVL_asstr + (JNIEnv *env, hid_t aid, hid_t tid, jobjectArray buf) +{ + char **strs; + jstring jstr; + jint i; + jint n; + hid_t sid; + hsize_t dims[H5S_MAX_RANK]; + herr_t status = -1; + + n = ENVPTR->GetArrayLength(ENVPAR buf); + strs =(hvl_t*)HDcalloc((size_t)n, sizeof(hvl_t)); + + if (strs == NULL) { + h5JNIFatalError(env, "H5AwriteVL_asstr: failed to allocate buff for read variable length strings"); + } /* end if */ + else { + status = H5Awrite(aid, tid, strs); + + if (status < 0) { + dims[0] = (hsize_t)n; + sid = H5Screate_simple(1, dims, NULL); + H5Dvlen_reclaim(tid, sid, H5P_DEFAULT, strs); + H5Sclose(sid); + HDfree(strs); + h5JNIFatalError(env, "H5AwriteVL_str: failed to read variable length strings"); + } /* end if */ + else { + for (i=0; i < n; i++) { + jstr = ENVPTR->NewStringUTF(ENVPAR strs[i]); + ENVPTR->SetObjectArrayElement(ENVPAR buf, i, jstr); + H5free_memory (strs[i]); + } /* end for */ + + /* + for repeatedly reading a dataset with a large number of strs (e.g., 1,000,000 strings, + H5Dvlen_reclaim() may crash on Windows because the Java GC will not be able to collect + free space in time. Instead, use "H5free_memory(strs[i])" above to free individual strings + after it is done. + H5Dvlen_reclaim(tid, mem_sid, xfer_plist_id, strs); + */ + + HDfree(strs); + } /* end else */ + } /* end else */ + + return status; +} /* end H5AwriteVL_str */ + +/* + * Class: hdf_hdf5lib_H5 + * Method: H5Aread_reg_ref + * Signature: (JJ[Ljava/lang/String;)I + */ +JNIEXPORT jint JNICALL +Java_hdf_hdf5lib_H5_H5Aread_1reg_1ref + (JNIEnv *env, jclass clss, jlong attr_id, jlong mem_type_id, jobjectArray buf) +{ + herr_t status = -1; + h5str_t h5str; + size_t size; + hdset_reg_ref_t *ref_data; + jint i; + jint n; + jstring jstr; + + hid_t region = -1; + hid_t aid = (hid_t) attr_id; + hid_t tid = (hid_t) mem_type_id; + + n = ENVPTR->GetArrayLength(ENVPAR buf); + size = sizeof(hdset_reg_ref_t); /*H5Tget_size(tid);*/ + ref_data = (hdset_reg_ref_t*)HDmalloc(size * (size_t)n); + + if (ref_data == NULL) { + h5JNIFatalError(env, "H5Aread_reg_ref: failed to allocate buff for read"); + return -1; + } /* end if */ + + status = H5Aread(aid, tid, ref_data); + + if (status < 0) { + HDfree(ref_data); + h5JNIFatalError(env, "H5Aread_reg_ref: failed to read data"); + return -1; + } /* end if */ + + HDmemset(&h5str, 0, sizeof(h5str_t)); + h5str_new(&h5str, 1024); + for (i=0; i<n; i++) { + h5str.s[0] = '\0'; + h5str_sprintf(&h5str, aid, tid, ref_data[i], 0, 0); + jstr = ENVPTR->NewStringUTF(ENVPAR h5str.s); + + ENVPTR->SetObjectArrayElement(ENVPAR buf, i, jstr); + } /* end for */ + + h5str_free(&h5str); + HDfree(ref_data); + + return (jint)status; +} /* end Java_hdf_hdf5lib_H5_H5Aread_1reg_1ref */ + +/* + * Class: hdf_hdf5lib_H5 * Method: H5Aget_space * Signature: (J)J */ diff --git a/java/src/jni/h5aImp.h b/java/src/jni/h5aImp.h index f3758eb..15cc83e 100644 --- a/java/src/jni/h5aImp.h +++ b/java/src/jni/h5aImp.h @@ -51,21 +51,120 @@ Java_hdf_hdf5lib_H5__1H5Aopen_1idx /* * Class: hdf_hdf5lib_H5 + * Method: H5Aread + * Signature: (JJ[B)I + */ +JNIEXPORT jint JNICALL +Java_hdf_hdf5lib_H5_H5Aread + (JNIEnv *, jclass, jlong, jlong, jbyteArray, jboolean); + +/* + * Class: hdf_hdf5lib_H5 * Method: H5Awrite * Signature: (JJ[B)I */ JNIEXPORT jint JNICALL Java_hdf_hdf5lib_H5_H5Awrite - (JNIEnv *, jclass, jlong, jlong, jbyteArray); + (JNIEnv *, jclass, jlong, jlong, jbyteArray, jboolean); /* * Class: hdf_hdf5lib_H5 - * Method: H5Aread - * Signature: (JJ[B)I + * Method: H5Aread_short + * Signature: (JJ[SZ)I */ JNIEXPORT jint JNICALL -Java_hdf_hdf5lib_H5_H5Aread - (JNIEnv *, jclass, jlong, jlong, jbyteArray); +Java_hdf_hdf5lib_H5_H5Aread_1short + (JNIEnv*, jclass, jlong, jlong, jshortArray, jboolean); + +/* + * Class: hdf_hdf5lib_H5 + * Method: H5Awrite_short + * Signature: (JJ[SZ)I + */ +JNIEXPORT jint JNICALL +Java_hdf_hdf5lib_H5_H5Awrite_1short + (JNIEnv*, jclass, jlong, jlong, jshortArray, jboolean); + +/* + * Class: hdf_hdf5lib_H5 + * Method: H5Aread_int + * Signature: (JJ[IZ)I + */ +JNIEXPORT jint JNICALL +Java_hdf_hdf5lib_H5_H5Aread_1int + (JNIEnv*, jclass, jlong, jlong, jintArray, jboolean); + +/* + * Class: hdf_hdf5lib_H5 + * Method: H5Awrite_int + * Signature: (JJ[IZ)I + */ +JNIEXPORT jint JNICALL +Java_hdf_hdf5lib_H5_H5Awrite_1int + (JNIEnv*, jclass, jlong, jlong, jintArray, jboolean); + +/* + * Class: hdf_hdf5lib_H5 + * Method: H5Aread_long + * Signature: (JJ[JZ)I + */ +JNIEXPORT jint JNICALL +Java_hdf_hdf5lib_H5_H5Aread_1long + (JNIEnv*, jclass, jlong, jlong, jlongArray, jboolean); + +/* + * Class: hdf_hdf5lib_H5 + * Method: H5Awrite_long + * Signature: (JJ[JZ)I + */ +JNIEXPORT jint JNICALL +Java_hdf_hdf5lib_H5_H5Awrite_1long + (JNIEnv*, jclass, jlong, jlong, jlongArray, jboolean); + +/* + * Class: hdf_hdf5lib_H5 + * Method: H5Aread_float + * Signature: (JJ[FZ)I + */ +JNIEXPORT jint JNICALL +Java_hdf_hdf5lib_H5_H5Aread_1float + (JNIEnv*, jclass, jlong, jlong, jfloatArray, jboolean); + +/* + * Class: hdf_hdf5lib_H5 + * Method: H5Awrite_float + * Signature: (JJ[FZ)I + */ +JNIEXPORT jint JNICALL +Java_hdf_hdf5lib_H5_H5Awrite_1float + (JNIEnv*, jclass, jlong, jlong, jfloatArray, jboolean); + +/* + * Class: hdf_hdf5lib_H5 + * Method: H5Aread_double + * Signature: (JJ[DZ)I + */ +JNIEXPORT jint JNICALL +Java_hdf_hdf5lib_H5_H5Aread_1double + (JNIEnv*, jclass, jlong, jlong, jdoubleArray, jboolean); + +/* + * Class: hdf_hdf5lib_H5 + * Method: H5Awrite_double + * Signature: (JJ[DZ)I + */ +JNIEXPORT jint JNICALL +Java_hdf_hdf5lib_H5_H5Awrite_1double + (JNIEnv*, jclass, jlong, jlong, jdoubleArray, jboolean); + +/* + * Class: hdf_hdf5lib_H5 + * Method: H5AreadVL + * Signature: (JJ[Ljava/lang/String;)I + */ +JNIEXPORT jint JNICALL +Java_hdf_hdf5lib_H5_H5AreadVL + (JNIEnv *, jclass, jlong, jlong, jobjectArray); /* * Class: hdf_hdf5lib_H5 @@ -78,12 +177,48 @@ Java_hdf_hdf5lib_H5_H5AwriteVL /* * Class: hdf_hdf5lib_H5 - * Method: H5AreadVL + * Method: H5Aread_string * Signature: (JJ[Ljava/lang/String;)I */ JNIEXPORT jint JNICALL -Java_hdf_hdf5lib_H5_H5AreadVL - (JNIEnv *, jclass, jlong, jlong, jobjectArray); +Java_hdf_hdf5lib_H5_H5Aread_1string + (JNIEnv*, jclass, jlong, jlong, jobjectArray); + +/* + * Class: hdf_hdf5lib_H5 + * Method: H5Awrite_string + * Signature: (JJ[Ljava/lang/String;)I + */ +JNIEXPORT jint JNICALL +Java_hdf_hdf5lib_H5_H5Awrite_1string +(JNIEnv*, jclass, jlong, jlong, jobjectArray); + +/* + * Class: hdf_hdf5lib_H5 + * Method: H5Aread_VLStrings + * Signature: (JJ[Ljava/lang/String;)I + */ +JNIEXPORT jint JNICALL +Java_hdf_hdf5lib_H5_H5Aread_1VLStrings +(JNIEnv*, jclass, jlong, jlong, jobjectArray); + +/* + * Class: hdf_hdf5lib_H5 + * Method: H5Awrite_VLStrings + * Signature: (JJ[B)I + */ +JNIEXPORT jint JNICALL +Java_hdf_hdf5lib_H5_H5Awrite_1VLStrings + (JNIEnv*, jclass, jlong, jlong, jobjectArray); + +/* + * Class: hdf_hdf5lib_H5 + * Method: H5Aread_reg_ref + * Signature: (JJ[Ljava/lang/String;)I + */ +JNIEXPORT jint JNICALL +Java_hdf_hdf5lib_H5_H5Aread_1reg_1ref +(JNIEnv*, jclass, jlong, jlong, jobjectArray); /* * Class: hdf_hdf5lib_H5 diff --git a/java/src/jni/h5dImp.c b/java/src/jni/h5dImp.c index 652c873..79a5d0a 100644 --- a/java/src/jni/h5dImp.c +++ b/java/src/jni/h5dImp.c @@ -1574,84 +1574,6 @@ Java_hdf_hdf5lib_H5_H5Dread_1reg_1ref /* * Class: hdf_hdf5lib_H5 - * Method: H5Dread_reg_ref_data - * Signature: (JJJJJ[Ljava/lang/String;)I - */ -JNIEXPORT jint JNICALL -Java_hdf_hdf5lib_H5_H5Dread_1reg_1ref_1data - (JNIEnv *env, jclass clss, - jlong dataset_id, jlong mem_type_id, jlong mem_space_id, - jlong file_space_id, jlong xfer_plist_id, jobjectArray buf) -{ - herr_t status = -1; - h5str_t h5str; - size_t size; - hdset_reg_ref_t *ref_data; - jint i; - jint n; - jstring jstr; - - hid_t region_obj; - H5S_sel_type region_type; - - hid_t region = -1; - hid_t did = (hid_t) dataset_id; - hid_t tid = (hid_t) mem_type_id; - hid_t mem_sid = (hid_t) mem_space_id; - hid_t file_sid = (hid_t) file_space_id; - - n = ENVPTR->GetArrayLength(ENVPAR buf); - size = sizeof(hdset_reg_ref_t); /*H5Tget_size(tid);*/ - ref_data = (hdset_reg_ref_t*)HDmalloc(size * (size_t)n); - - if (ref_data == NULL) { - h5JNIFatalError(env, "H5Dread_reg_ref_data: failed to allocate buff for read"); - return -1; - } /* end if */ - - status = H5Dread(did, tid, mem_sid, file_sid, xfer_plist_id, ref_data); - - if (status < 0) { - HDfree(ref_data); - h5JNIFatalError(env, "H5Dread_reg_ref_data: failed to read data"); - return -1; - } /* end if */ - - HDmemset(&h5str, 0, sizeof(h5str_t)); - h5str_new(&h5str, 1024); - for (i=0; i<n; i++) { - h5str.s[0] = '\0'; - - /* get name of the dataset the region reference points to using H5Rget_name */ - region_obj = H5Rdereference2(did, H5P_DEFAULT, H5R_DATASET_REGION, ref_data[i]); - if (region_obj >= 0) { - region = H5Rget_region(did, H5R_DATASET_REGION, ref_data[i]); - if (region >= 0) { - region_type = H5Sget_select_type(region); - if(region_type==H5S_SEL_POINTS) { - h5str_dump_region_points_data(&h5str, region, region_obj); - } /* end if */ - else { - h5str_dump_region_blocks_data(&h5str, region, region_obj); - } /* end else */ - - H5Sclose(region); - } /* end if */ - H5Dclose(region_obj); - } /* end if */ - jstr = ENVPTR->NewStringUTF(ENVPAR h5str.s); - - ENVPTR->SetObjectArrayElement(ENVPAR buf, i, jstr); - } /* end for */ - - h5str_free(&h5str); - HDfree(ref_data); - - return (jint)status; -} /* end Java_hdf_hdf5lib_H5_H5Dread_1reg_1ref_1data */ - -/* - * Class: hdf_hdf5lib_H5 * Method: _H5Dcreate2 * Signature: (JLjava/lang/String;JJJJJ)J */ diff --git a/java/src/jni/h5dImp.h b/java/src/jni/h5dImp.h index 1fe71a8..f824452 100644 --- a/java/src/jni/h5dImp.h +++ b/java/src/jni/h5dImp.h @@ -250,7 +250,7 @@ Java_hdf_hdf5lib_H5_H5Dread_1VLStrings /* * Class: hdf_hdf5lib_H5 * Method: H5Dwrite_VLStrings - * Signature: (JJJJJ[BZ)I + * Signature: (JJJJJ[B)I */ JNIEXPORT jint JNICALL Java_hdf_hdf5lib_H5_H5Dwrite_1VLStrings @@ -267,15 +267,6 @@ Java_hdf_hdf5lib_H5_H5Dread_1reg_1ref /* * Class: hdf_hdf5lib_H5 - * Method: H5Dread_reg_ref_data - * Signature: (JJJJJ[Ljava/lang/String;)I - */ -JNIEXPORT jint JNICALL -Java_hdf_hdf5lib_H5_H5Dread_1reg_1ref_1data - (JNIEnv*, jclass, jlong, jlong, jlong, jlong, jlong, jobjectArray); - -/* - * Class: hdf_hdf5lib_H5 * Method: _H5Dcreate2 * Signature: (JLjava/lang/String;JJJJJ)J */ diff --git a/java/src/jni/h5fImp.c b/java/src/jni/h5fImp.c index 9d68290..248e654 100644 --- a/java/src/jni/h5fImp.c +++ b/java/src/jni/h5fImp.c @@ -168,6 +168,33 @@ Java_hdf_hdf5lib_H5_H5Fis_1hdf5 /* * Class: hdf_hdf5lib_H5 + * Method: H5Fis_accessible + * Signature: (Ljava/lang/String;J)Z + */ +JNIEXPORT jboolean JNICALL +Java_hdf_hdf5lib_H5_H5Fis_1accessible + (JNIEnv *env, jclass clss, jstring name, jlong file_id) +{ + htri_t bval = JNI_FALSE; + const char *fileName; + + PIN_JAVA_STRING(name, fileName); + if (fileName != NULL) { + bval = H5Fis_accessible(fileName, (hid_t)file_id); + + UNPIN_JAVA_STRING(name, fileName); + + if (bval > 0) + bval = JNI_TRUE; + else if (bval < 0) + h5libraryError(env); + } + + return (jboolean)bval; +} /* end Java_hdf_hdf5lib_H5_H5Fis_1accessible */ + +/* + * Class: hdf_hdf5lib_H5 * Method: H5Fget_create_plist * Signature: (J)J */ @@ -177,7 +204,7 @@ Java_hdf_hdf5lib_H5__1H5Fget_1create_1plist { hid_t retVal = -1; - retVal = H5Fget_create_plist((hid_t)file_id ); + retVal = H5Fget_create_plist((hid_t)file_id); if (retVal < 0) h5libraryError(env); diff --git a/java/src/jni/h5fImp.h b/java/src/jni/h5fImp.h index fcfdedf..af0fa1d 100644 --- a/java/src/jni/h5fImp.h +++ b/java/src/jni/h5fImp.h @@ -68,6 +68,15 @@ Java_hdf_hdf5lib_H5_H5Fis_1hdf5 /* * Class: hdf_hdf5lib_H5 + * Method: H5Fis_accessible + * Signature: (Ljava/lang/String;J)Z + */ +JNIEXPORT jboolean JNICALL +Java_hdf_hdf5lib_H5_H5Fis_1ccessible + (JNIEnv*, jclass, jstring, jlong); + +/* + * Class: hdf_hdf5lib_H5 * Method: H5Fget_create_plist * Signature: (J)J */ diff --git a/java/src/jni/h5vlImp.c b/java/src/jni/h5vlImp.c new file mode 100644 index 0000000..89ea703 --- /dev/null +++ b/java/src/jni/h5vlImp.c @@ -0,0 +1,206 @@ +/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * + * Copyright by The HDF Group. * + * Copyright by the Board of Trustees of the University of Illinois. * + * 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 COPYING file, which can be found at the root of the source code * + * distribution tree, or in https://support.hdfgroup.org/ftp/HDF5/releases. * + * If you do not have access to either file, you may request a copy from * + * help@hdfgroup.org. * + * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ + +/* + * For details of the HDF libraries, see the HDF Documentation at: + * http://hdfgroup.org/HDF5/doc/ + * + */ + +#ifdef __cplusplus +extern "C" { +#endif /* __cplusplus */ + +#include "hdf5.h" +#include <jni.h> +#include <stdlib.h> +#include "h5jni.h" +#include "h5vlImp.h" + +/* + * Class: hdf_hdf5lib_H5 + * Method: H5VLregister_connector_by_name + * Signature: (Ljava/lang/String;J)J + */ +JNIEXPORT jlong JNICALL +Java_hdf_hdf5lib_H5_H5VLregister_1connector_1by_1name + (JNIEnv *env, jclass clss, jobject connector_name, jlong vipl_id) +{ + hid_t status = -1; + const char *vlName; + + PIN_JAVA_STRING(connector_name, vlName); + if (vlName != NULL) { + status = H5VLregister_connector_by_name(vlName, (hid_t)vipl_id); + + UNPIN_JAVA_STRING(connector_name, vlName); + + if (status < 0) + h5libraryError(env); + } + + return (jlong)status; +} /* end Java_hdf_hdf5lib_H5_H5VLregister_1connector_1by_1name */ + +/* + * Class: hdf_hdf5lib_H5 + * Method: H5VLregister_connector_by_value + * Signature: (IJ)J + */ +JNIEXPORT jlong JNICALL +Java_hdf_hdf5lib_H5_H5VLregister_1connector_1by_1value + (JNIEnv *env, jclass clss, jint connector_value, jlong vipl_id) +{ + hid_t status = H5VLregister_connector_by_value((H5VL_class_value_t)connector_value, (hid_t)vipl_id); + + if (status < 0) + h5libraryError(env); + + return (jlong)status; +} /* end Java_hdf_hdf5lib_H5_H5VLregister_1connector_1by_1value */ + +/* + * Class: hdf_hdf5lib_H5 + * Method: H5VLis_connector_registered + * Signature: (Ljava/lang/String;)Z + */ +JNIEXPORT jboolean JNICALL +Java_hdf_hdf5lib_H5_H5VLis_1connector_1registered + (JNIEnv *env, jclass clss, jobject connector_name) +{ + htri_t bval = JNI_FALSE; + const char *vlName; + + PIN_JAVA_STRING(connector_name, vlName); + if (vlName != NULL) { + bval = H5VLis_connector_registered(vlName); + + UNPIN_JAVA_STRING(connector_name, vlName); + + if (bval > 0) + bval = JNI_TRUE; + else if (bval < 0) + h5libraryError(env); + } + + return (jboolean)bval; +} /* end Java_hdf_hdf5lib_H5_H5VLis_1connector_1registered */ + +/* + * Class: hdf_hdf5lib_H5 + * Method: H5VLget_connector_id + * Signature: (Ljava/lang/String;)J + */ +JNIEXPORT jlong JNICALL +Java_hdf_hdf5lib_H5_H5VLget_1connector_1id + (JNIEnv *env, jclass clss, jobject connector_name) +{ + hid_t status = -1; + const char *vlName; + + PIN_JAVA_STRING(connector_name, vlName); + if (vlName != NULL) { + status = H5VLget_connector_id(vlName); + + UNPIN_JAVA_STRING(connector_name, vlName); + + if (status < 0) + h5libraryError(env); + } + + return (jlong)status; +} /* end Java_hdf_hdf5lib_H5_H5VLget_1connector_1id */ + +/* + * Class: hdf_hdf5lib_H5 + * Method: H5VLget_connector_name + * Signature: (J)Ljava/lang/String; + */ + +JNIEXPORT jobject JNICALL +Java_hdf_hdf5lib_H5_H5VLget_1connector_1name + (JNIEnv *env, jclass clss, jlong object_id) +{ + char *vlName; + ssize_t buf_size; + ssize_t status; + jstring str = NULL; + + /* get the length of the comment */ + buf_size = H5VLget_connector_name((hid_t)object_id, NULL, 0); + if (buf_size < 0) { + H5Eprint2(H5E_DEFAULT, NULL); + + h5badArgument(env, "H5VLget_connector_name: buf_size < 0"); + } /* end if */ + else if (buf_size > 0) { + buf_size++; /* add extra space for the null terminator */ + vlName = (char *)HDmalloc(sizeof(char) * (size_t)buf_size); + if (vlName == NULL) { + /* exception -- out of memory */ + h5outOfMemory(env, "H5VLget_connector_name: malloc failed"); + } /* end if */ + else { + status = H5VLget_connector_name((hid_t)object_id, vlName, (size_t)buf_size); + + if (status < 0) { + h5libraryError(env); + } /* end if */ + else { + /* may throw OutOfMemoryError */ + str = ENVPTR->NewStringUTF(ENVPAR vlName); + if (str == NULL) { + h5JNIFatalError(env, "H5VLget_connector_name: return string not allocated"); + } /* end if */ + } /* end else */ + HDfree(vlName); + } + } /* end else if */ + + return (jstring)str; +} /* end Java_hdf_hdf5lib_H5_H5VLget_1connector_1name */ + +/* + * Class: hdf_hdf5lib_H5 + * Method: H5VLclose + * Signature: (J)V + */ +JNIEXPORT void JNICALL +Java_hdf_hdf5lib_H5_H5VLclose + (JNIEnv *env, jclass clss, jlong connector_id) +{ + herr_t retValue = H5VLclose((hid_t)connector_id); + + if (retValue < 0) + h5libraryError(env); +} /* end Java_hdf_hdf5lib_H5_H5VLclose */ + +/* + * Class: hdf_hdf5lib_H5 + * Method: H5VLunregister_connector + * Signature: (J)V + */ +JNIEXPORT void JNICALL +Java_hdf_hdf5lib_H5_H5VLunregister_1connector + (JNIEnv *env, jclass clss, jlong connector_id) +{ + herr_t retValue = H5VLunregister_connector((hid_t)connector_id); + + if (retValue < 0) + h5libraryError(env); +} /* end Java_hdf_hdf5lib_H5_H5VLunregister_1connector */ + + +#ifdef __cplusplus +} /* end extern "C" */ +#endif /* __cplusplus */ diff --git a/java/src/jni/h5vlImp.h b/java/src/jni/h5vlImp.h new file mode 100644 index 0000000..af824a9 --- /dev/null +++ b/java/src/jni/h5vlImp.h @@ -0,0 +1,91 @@ +/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * + * Copyright by The HDF Group. * + * Copyright by the Board of Trustees of the University of Illinois. * + * 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 COPYING file, which can be found at the root of the source code * + * distribution tree, or in https://support.hdfgroup.org/ftp/HDF5/releases. * + * If you do not have access to either file, you may request a copy from * + * help@hdfgroup.org. * + * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ + +#include <jni.h> +/* Header for class hdf_hdf5lib_H5_H5VL */ + +#ifndef _Included_hdf_hdf5lib_H5_H5VL +#define _Included_hdf_hdf5lib_H5_H5VL + +#ifdef __cplusplus +extern "C" { +#endif /* __cplusplus */ +/* + * Class: hdf_hdf5lib_H5 + * Method: H5VLregister_connector_by_name + * Signature: (Ljava/lang/String;J)J + */ +JNIEXPORT jlong JNICALL +Java_hdf_hdf5lib_H5_H5VLregister_1connector_1by_1name + (JNIEnv *, jclass, jobject, jlong); + +/* + * Class: hdf_hdf5lib_H5 + * Method: H5VLregister_connector_by_value + * Signature: (IJ)J + */ +JNIEXPORT jlong JNICALL +Java_hdf_hdf5lib_H5_H5VLregister_1connector_1by_1value + (JNIEnv *, jclass, jint, jlong); + +/* + * Class: hdf_hdf5lib_H5 + * Method: H5VLis_connector_registered + * Signature: (Ljava/lang/String;)Z + */ +JNIEXPORT jboolean JNICALL +Java_hdf_hdf5lib_H5_H5VLis_connector_registered + (JNIEnv *, jclass, jobject); + +/* + * Class: hdf_hdf5lib_H5 + * Method: H5VLget_connector_id + * Signature: (Ljava/lang/String;)J + */ +JNIEXPORT jlong JNICALL +Java_hdf_hdf5lib_H5_H5VLget_1connector_1id + (JNIEnv *, jclass, jobject); + +/* + * Class: hdf_hdf5lib_H5 + * Method: H5VLget_connector_name + * Signature: (J)Ljava/lang/String; + */ + +JNIEXPORT jobject JNICALL +Java_hdf_hdf5lib_H5_H5VLget_1connector_1name + (JNIEnv *, jclass, jlong); + +/* + * Class: hdf_hdf5lib_H5 + * Method: H5VLclose + * Signature: (J)V + */ +JNIEXPORT void JNICALL +Java_hdf_hdf5lib_H5_H5VLclose + (JNIEnv *, jclass, jlong); + +/* + * Class: hdf_hdf5lib_H5 + * Method: H5VLunregister_connector + * Signature: (J)V + */ +JNIEXPORT void JNICALL +Java_hdf_hdf5lib_H5_H5VLunregister_1connector + (JNIEnv *, jclass, jlong); + +#ifdef __cplusplus +} /* end extern "C" */ +#endif /* __cplusplus */ + +#endif /* _Included_hdf_hdf5lib_H5_H5VL */ diff --git a/java/test/CMakeLists.txt b/java/test/CMakeLists.txt index b76f572..937b129 100644 --- a/java/test/CMakeLists.txt +++ b/java/test/CMakeLists.txt @@ -38,6 +38,7 @@ set (HDF5_JAVA_TEST_SOURCES TestH5Ocreate TestH5Ocopy TestH5PL + TestH5VL TestH5Z ) diff --git a/java/test/Makefile.am b/java/test/Makefile.am index 6635ef7..af99d92 100644 --- a/java/test/Makefile.am +++ b/java/test/Makefile.am @@ -69,6 +69,7 @@ noinst_JAVA = \ TestH5Ocreate.java \ TestH5Ocopy.java \ TestH5PL.java \ + TestH5VL.java \ TestH5Z.java \ TestH5E.java \ TestH5Edefault.java \ diff --git a/java/test/TestH5Fbasic.java b/java/test/TestH5Fbasic.java index 11d6644..a5afb6e 100644 --- a/java/test/TestH5Fbasic.java +++ b/java/test/TestH5Fbasic.java @@ -81,6 +81,19 @@ public class TestH5Fbasic { assertTrue(isH5 == true); } + @Test + public void testH5Fis_accessible() { + boolean isH5 = false; + + try { + isH5 = H5.H5Fis_accessible(H5_FILE, HDF5Constants.H5P_DEFAULT); + } + catch (Throwable err) { + fail("H5.H5Fis_accessible failed on " + H5_FILE + ": " + err); + } + assertTrue(isH5 == true); + } + @Test(expected = HDF5LibraryException.class) public void testH5Fcreate_EXCL() throws Throwable { H5.H5Fcreate(H5_FILE, HDF5Constants.H5F_ACC_EXCL, diff --git a/java/test/TestH5Fparams.java b/java/test/TestH5Fparams.java index fffded1..3d64aa9 100644 --- a/java/test/TestH5Fparams.java +++ b/java/test/TestH5Fparams.java @@ -60,6 +60,11 @@ public class TestH5Fparams { } @Test(expected = NullPointerException.class) + public void testH5Fis_accessible_null() throws Throwable { + H5.H5Fis_accessible(null, -1); + } + + @Test(expected = NullPointerException.class) public void testH5Fmount_null() throws Throwable { H5.H5Fmount(-1, null, -1, HDF5Constants.H5P_DEFAULT); } diff --git a/java/test/TestH5VL.java b/java/test/TestH5VL.java new file mode 100644 index 0000000..0397be1 --- /dev/null +++ b/java/test/TestH5VL.java @@ -0,0 +1,117 @@ +/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * + * Copyright by The HDF Group. * + * Copyright by the Board of Trustees of the University of Illinois. * + * 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 COPYING file, which can be found at the root of the source code * + * distribution tree, or in https://support.hdfgroup.org/ftp/HDF5/releases. * + * If you do not have access to either file, you may request a copy from * + * help@hdfgroup.org. * + * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ + +package test; + +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertFalse; +import static org.junit.Assert.assertTrue; +import static org.junit.Assert.fail; +import hdf.hdf5lib.H5; +import hdf.hdf5lib.HDF5Constants; +import hdf.hdf5lib.exceptions.HDF5LibraryException; + +import java.io.File; + +import org.junit.After; +import org.junit.Before; +import org.junit.Rule; +import org.junit.Test; +import org.junit.rules.TestName; + +public class TestH5VL { + @Rule public TestName testname = new TestName(); + + private final void _deleteFile(String filename) { + File file = new File(filename); + + if (file.exists()) { + try {file.delete();} catch (SecurityException e) {} + } + } + + @Before + public void checkOpenIDs() { + assertTrue("H5 open ids is 0",H5.getOpenIDCount()==0); + System.out.print(testname.getMethodName()); + } + @After + public void nextTestName() { + System.out.println(); + } + + @Test + public void testH5VLnative_init() { + try { + boolean is_registered; + + is_registered = H5.H5VLis_connector_registered(HDF5Constants.H5VL_NATIVE_NAME); + assertTrue("H5.H5VLis_connector_registered H5VL_NATIVE_NAME", is_registered); + + is_registered = H5.H5VLis_connector_registered("FAKE_VOL_NAME"); + assertFalse("H5.H5VLis_connector_registered FAKE_VOL_NAME", is_registered); + } + catch (Throwable err) { + err.printStackTrace(); + fail("H5.H5VLis_connector_registered " + err); + } + } + + @Test + public void testH5VLget_connector_id() { + try { + long native_id = H5.H5VLget_connector_id(HDF5Constants.H5VL_NATIVE_NAME); + assertTrue("H5.H5VLget_connector_id H5VL_NATIVE_NAME", native_id >= 0); + assertEquals(HDF5Constants.H5VL_NATIVE, native_id); + } + catch (Throwable err) { + err.printStackTrace(); + fail("H5.H5VLget_connector_id " + err); + } + } + + @Test + public void testH5VLget_connector_name() { + String H5_FILE = "testFvl.h5"; + + long H5fid = H5.H5Fcreate(H5_FILE, HDF5Constants.H5F_ACC_TRUNC, + HDF5Constants.H5P_DEFAULT, HDF5Constants.H5P_DEFAULT); + H5.H5Fflush(H5fid, HDF5Constants.H5F_SCOPE_LOCAL); + + try { + String native_name = H5.H5VLget_connector_name(H5fid); + assertTrue("H5.H5VLget_connector_name H5VL_NATIVE", native_name.compareToIgnoreCase(HDF5Constants.H5VL_NATIVE_NAME)==0); + } + catch (Throwable err) { + err.printStackTrace(); + fail("H5.H5VLget_connector_name " + err); + } + finally { + if (H5fid > 0) { + try {H5.H5Fclose(H5fid);} catch (Exception ex) {} + } + _deleteFile(H5_FILE); + } + } + + @Test(expected = HDF5LibraryException.class) + public void testH5VLclose_NegativeID() throws Throwable { + H5.H5VLclose(-1); + } + + @Test(expected = HDF5LibraryException.class) + public void testH5VLunregister_connector_NegativeID() throws Throwable { + H5.H5VLunregister_connector(-1); + } +} + diff --git a/java/test/junit.sh.in b/java/test/junit.sh.in index 350fb7b..add1af4 100644 --- a/java/test/junit.sh.in +++ b/java/test/junit.sh.in @@ -101,6 +101,7 @@ $HDFTEST_HOME/testfiles/JUnit-TestH5Obasic.txt $HDFTEST_HOME/testfiles/JUnit-TestH5Ocreate.txt $HDFTEST_HOME/testfiles/JUnit-TestH5Ocopy.txt $HDFTEST_HOME/testfiles/JUnit-TestH5PL.txt +$HDFTEST_HOME/testfiles/JUnit-TestH5VL.txt $HDFTEST_HOME/testfiles/JUnit-TestH5Z.txt $HDFTEST_HOME/testfiles/JUnit-TestH5E.txt $HDFTEST_HOME/testfiles/JUnit-TestH5Edefault.txt @@ -989,6 +990,27 @@ else test yes = "$verbose" && $DIFF JUnit-TestH5PL.txt JUnit-TestH5PL.out |sed 's/^/ /' fi +echo "$JAVAEXE $JAVAEXEFLAGS -Xmx1024M -Dorg.slf4j.simpleLogger.defaultLog=trace -Djava.library.path=$BLDLIBDIR -cp $CLASSPATH -ea org.junit.runner.JUnitCore test.TestH5VL" +TESTING JUnit-TestH5VL +($RUNSERIAL $JAVAEXE $JAVAEXEFLAGS -Xmx1024M -Dorg.slf4j.simpleLogger.defaultLog=trace -Djava.library.path=$BLDLIBDIR -cp $CLASSPATH -ea org.junit.runner.JUnitCore test.TestH5VL > JUnit-TestH5VL.ext) + +# Extract file name, line number, version and thread IDs because they may be different +sed -e 's/thread [0-9]*/thread (IDs)/' -e 's/: .*\.c /: (file name) /' \ + -e 's/line [0-9]*/line (number)/' \ + -e 's/Time: [0-9]*\.[0-9]*/Time: XXXX/' \ + -e 's/v[1-9]*\.[0-9]*\./version (number)\./' \ + -e 's/[1-9]*\.[0-9]*\.[0-9]*[^)]*/version (number)/' \ + JUnit-TestH5VL.ext > JUnit-TestH5VL.out + +if diff JUnit-TestH5VL.out JUnit-TestH5VL.txt > /dev/null; then + echo " PASSED JUnit-TestH5VL" +else + echo "**FAILED** JUnit-TestH5VL" + echo " Expected result differs from actual result" + nerrors="`expr $nerrors + 1`" + test yes = "$verbose" && $DIFF JUnit-TestH5VL.txt JUnit-TestH5VL.out |sed 's/^/ /' +fi + echo "$JAVAEXE $JAVAEXEFLAGS -Xmx1024M -Dorg.slf4j.simpleLogger.defaultLog=trace -Djava.library.path=$BLDLIBDIR -cp $CLASSPATH -ea org.junit.runner.JUnitCore test.TestH5Z" TESTING JUnit-TestH5Z ($RUNSERIAL $JAVAEXE $JAVAEXEFLAGS -Xmx1024M -Dorg.slf4j.simpleLogger.defaultLog=trace -Djava.library.path=$BLDLIBDIR -cp $CLASSPATH -ea org.junit.runner.JUnitCore test.TestH5Z > JUnit-TestH5Z.ext) diff --git a/java/test/testfiles/JUnit-TestH5Edefault.txt b/java/test/testfiles/JUnit-TestH5Edefault.txt index 71d1431..48c6254 100644 --- a/java/test/testfiles/JUnit-TestH5Edefault.txt +++ b/java/test/testfiles/JUnit-TestH5Edefault.txt @@ -38,17 +38,20 @@ HDF5-DIAG: Error detected in HDF5 (version (number)) thread (IDs): minor: Unable to open file #001: (file name) line (number) in H5VL_file_open(): open failed major: Virtual Object Layer - minor: Unable to initialize object - #002: (file name) line (number) in H5VL_native_file_open(): unable to open file + minor: Can't open object + #002: (file name) line (number) in H5VL__file_open(): open failed + major: Virtual Object Layer + minor: Can't open object + #003: (file name) line (number) in H5VL__native_file_open(): unable to open file major: File accessibility minor: Unable to open file - #003: (file name) line (number) in H5F_open(): unable to open file: name = 'test', tent_flags = 1 + #004: (file name) line (number) in H5F_open(): unable to open file: name = 'test', tent_flags = 1 major: File accessibility minor: Unable to open file - #004: (file name) line (number) in H5FD_open(): open failed + #005: (file name) line (number) in H5FD_open(): open failed major: Virtual File Layer minor: Unable to initialize object - #005: (file name) line (number) in H5FD_sec2_open(): unable to open file: name = 'test', errno = 2, error message = 'No such file or directory', flags = 1, o_flags = 2 + #006: (file name) line (number) in H5FD_sec2_open(): unable to open file: name = 'test', errno = 2, error message = 'No such file or directory', flags = 1, o_flags = 2 major: File accessibility minor: Unable to open file HDF5-DIAG: Error detected in HDF5 (version (number)) thread (IDs): @@ -57,16 +60,19 @@ HDF5-DIAG: Error detected in HDF5 (version (number)) thread (IDs): minor: Unable to open file #001: (file name) line (number) in H5VL_file_open(): open failed major: Virtual Object Layer - minor: Unable to initialize object - #002: (file name) line (number) in H5VL_native_file_open(): unable to open file + minor: Can't open object + #002: (file name) line (number) in H5VL__file_open(): open failed + major: Virtual Object Layer + minor: Can't open object + #003: (file name) line (number) in H5VL__native_file_open(): unable to open file major: File accessibility minor: Unable to open file - #003: (file name) line (number) in H5F_open(): unable to open file: name = 'test', tent_flags = 1 + #004: (file name) line (number) in H5F_open(): unable to open file: name = 'test', tent_flags = 1 major: File accessibility minor: Unable to open file - #004: (file name) line (number) in H5FD_open(): open failed + #005: (file name) line (number) in H5FD_open(): open failed major: Virtual File Layer minor: Unable to initialize object - #005: (file name) line (number) in H5FD_sec2_open(): unable to open file: name = 'test', errno = 2, error message = 'No such file or directory', flags = 1, o_flags = 2 + #006: (file name) line (number) in H5FD_sec2_open(): unable to open file: name = 'test', errno = 2, error message = 'No such file or directory', flags = 1, o_flags = 2 major: File accessibility minor: Unable to open file diff --git a/java/test/testfiles/JUnit-TestH5Fbasic.txt b/java/test/testfiles/JUnit-TestH5Fbasic.txt index 467e2fb..2654624 100644 --- a/java/test/testfiles/JUnit-TestH5Fbasic.txt +++ b/java/test/testfiles/JUnit-TestH5Fbasic.txt @@ -9,6 +9,7 @@ JUnit version 4.11 .testH5Freopen_closed .testH5Freset_mdc_hit_rate_stats .testH5Fget_name +.testH5Fis_accessible .testH5Fcreate .testH5Fclear_elink_file_cache .testH5Fclose_twice @@ -17,5 +18,5 @@ JUnit version 4.11 Time: XXXX -OK (15 tests) +OK (16 tests) diff --git a/java/test/testfiles/JUnit-TestH5Fparams.txt b/java/test/testfiles/JUnit-TestH5Fparams.txt index 9d35220..e91cbdc 100644 --- a/java/test/testfiles/JUnit-TestH5Fparams.txt +++ b/java/test/testfiles/JUnit-TestH5Fparams.txt @@ -1,4 +1,5 @@ JUnit version 4.11 +.testH5Fis_accessible_null .testH5Fcreate_null .testH5Fflush_local .testH5Fget_info @@ -13,5 +14,5 @@ JUnit version 4.11 Time: XXXX -OK (11 tests) +OK (12 tests) diff --git a/java/test/testfiles/JUnit-TestH5VL.txt b/java/test/testfiles/JUnit-TestH5VL.txt new file mode 100644 index 0000000..caadf26 --- /dev/null +++ b/java/test/testfiles/JUnit-TestH5VL.txt @@ -0,0 +1,11 @@ +JUnit version 4.11 +.testH5VLget_connector_id +.testH5VLnative_init +.testH5VLget_connector_name +.testH5VLclose_NegativeID +.testH5VLunregister_connector_NegativeID + +Time: XXXX + +OK (5 tests) + diff --git a/release_docs/INSTALL_CMake.txt b/release_docs/INSTALL_CMake.txt index edd876a..8acd35f 100644 --- a/release_docs/INSTALL_CMake.txt +++ b/release_docs/INSTALL_CMake.txt @@ -651,6 +651,7 @@ HDF5_PACKAGE_EXTLIBS "CPACK - include external libraries" HDF5_STRICT_FORMAT_CHECKS "Whether to perform strict file format checks" OFF HDF_TEST_EXPRESS "Control testing framework (0-3)" "0" HDF5_TEST_VFD "Execute tests with different VFDs" OFF +HDF5_TEST_VOL "Execute tests with different VOL connectors" OFF HDF5_USE_16_API_DEFAULT "Use the HDF5 1.6.x API by default" OFF HDF5_USE_18_API_DEFAULT "Use the HDF5 1.8.x API by default" OFF HDF5_USE_110_API_DEFAULT "Use the HDF5 1.10.x API by default" OFF diff --git a/release_docs/RELEASE.txt b/release_docs/RELEASE.txt index c17cdcd..024db9a 100644 --- a/release_docs/RELEASE.txt +++ b/release_docs/RELEASE.txt @@ -48,6 +48,15 @@ New Features Configuration: ------------- + - Keep stderr and stdout separate in tests + + Changed test handling of output capture. Tests now keep the stderr + output separate from the stdout output. It is up to the test to decide + which output to check against a reference. Also added the option + to grep for a string in either output. + + (ADB - 2018/12/12, HDFFV-10632) + - Add toolchain and cross-compile support Added info on using a toolchain file to INSTALL_CMAKE.txt. A @@ -111,37 +120,6 @@ New Features (ADB - 2018/07/16) - - Incorrectly installed private header files were removed from - CMake installs. - - The CMake build files incorrectly flagged the following header files - as public and installed them. They are private and will no longer be - installed. - - HDF5 library private package files (H5Xpkg.h) - H5Edefin.h - H5Einit.h - H5Eterm.h - H5LTparse.h - h5diff.h - h5tools_dump.h - h5tools.h - h5tools_ref.h - h5tools_str.h - h5tools_utils.h - h5trav.h - - (DER - 2018/10/26, HDFFV-10614, 10609) - - - Autotools installs now install H5FDwindows.h - - This is simply to align the installed header files between the - autotools and CMake. H5FDwindows.h has no functionality on - non-Windows systems. - - (DER - 2018/10/26, HDFFV-10614) - - Library: -------- - Allow pre-generated H5Tinit.c and H5make_libsettings.c to be used. @@ -151,23 +129,11 @@ New Features (ADB - 2018/09/18, HDFFV-10332) + - Remove H5I_REFERENCE from the library - - Several empty public header files where removed from the distribution - - The following files were empty placeholders. They are for internal - packages that are unlikely to ever have public functionality and have - thus been removed. + This ID class was never used by the library and has been removed. - H5Bpublic.h - H5B2public.h - H5FSpublic.h - H5HFpublic.h - H5HGpublic.h - H5HLpublic.h - - They were only installed in CMake builds. - - (DER - 2018/10/26, HDFFV-10614) + (DER - 2018/12/08, HDFFV-10252) Parallel Library: @@ -230,6 +196,23 @@ New Features Java Library: ---------------- + - Duplicate the data read/write functions of Datasets for Attributes. + + Region references could not be displayed for attributes as they could + for datasets. Datasets had overloaded read and write functions for different + datatypes that were not available for attributes. After adding similar + functions, attribute region references work normally. + + (ADB - 2018/12/12, HDFVIEW-4) + + + - Removed H5I_REFERENCE from the Java wrappers + + This ID class was never used by the library and has been removed + from the Java wrappers. + + (DER - 2018/12/08, HDFFV-10252) + Tools: ------ @@ -331,7 +314,11 @@ Bug Fixes since HDF5-1.10.3 release Fortran -------- - - + - Made Fortran specific subroutines PRIVATE in generic procedures. + + Effected generic procedures were functions in H5A, H5D, H5P, H5R and H5T. + + (MSB, 2018/12/04, HDFFV-10511) Tools ----- @@ -517,19 +504,6 @@ Bug Fixes since HDF5-1.10.2 release (LRK - 2018/07/18, HDFFV-10475) - - The --enable-debug/production configure flags are listed as 'deprecated' - when they should really be listed as 'removed'. - - In the autotools overhaul several years ago, we removed these flags and - implemented a new --enable-build-mode= flag. This was done because we - changed the semantics of the modes and didn't want users to silently - be exposed to them. The newer system is also more flexible and us to - add other modes (like 'clean'). - - The --enable-debug/production flags are now listed as removed. - - (DER - 2018/05/31, HDFFV-10505) - - Moved the location of gcc attribute. The gcc attribute(no_sanitize), named as the macro HDF_NO_UBSAN, diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index bca5a92..c9a2fda 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -625,11 +625,21 @@ IDE_GENERATED_PROPERTIES ("H5UC" "${H5UC_HDRS}" "${H5UC_SOURCES}" ) set (H5VL_SOURCES ${HDF5_SRC_DIR}/H5VL.c + ${HDF5_SRC_DIR}/H5VLcallback.c ${HDF5_SRC_DIR}/H5VLint.c ${HDF5_SRC_DIR}/H5VLnative.c + ${HDF5_SRC_DIR}/H5VLnative_attr.c + ${HDF5_SRC_DIR}/H5VLnative_dataset.c + ${HDF5_SRC_DIR}/H5VLnative_datatype.c + ${HDF5_SRC_DIR}/H5VLnative_file.c + ${HDF5_SRC_DIR}/H5VLnative_group.c + ${HDF5_SRC_DIR}/H5VLnative_link.c + ${HDF5_SRC_DIR}/H5VLnative_object.c + ${HDF5_SRC_DIR}/H5VLpassthru.c ) set (H5VL_HDRS ${HDF5_SRC_DIR}/H5VLnative.h + ${HDF5_SRC_DIR}/H5VLpassthru.h ${HDF5_SRC_DIR}/H5VLpublic.h ) IDE_GENERATED_PROPERTIES ("H5VL" "${H5VL_HDRS}" "${H5VL_SOURCES}" ) @@ -866,8 +876,8 @@ set (H5_PRIVATE_HEADERS ${HDF5_SRC_DIR}/H5UCprivate.h - ${HDF5_SRC_DIR}/H5VLpkg.h ${HDF5_SRC_DIR}/H5VLnative_private.h + ${HDF5_SRC_DIR}/H5VLpkg.h ${HDF5_SRC_DIR}/H5VLprivate.h ${HDF5_SRC_DIR}/H5VMprivate.h @@ -948,10 +958,13 @@ if (NOT EXISTS ${HDF5_GENERATED_SOURCE_DIR}/H5Tinit.c) ) add_custom_command ( OUTPUT ${HDF5_GENERATED_SOURCE_DIR}/H5Tinit.c + ${HDF5_GENERATED_SOURCE_DIR}/gen_SRCS.stamp1 COMMAND ${HDF5_BATCH_CMD} ARGS ${HDF5_BINARY_DIR}/${HDF5_BATCH_H5DETECT_SCRIPT} COMMAND ${CMAKE_COMMAND} ARGS -E echo "Executed batch command to create H5Tinit.c" + COMMAND ${CMAKE_COMMAND} + ARGS -E touch ${HDF5_GENERATED_SOURCE_DIR}/gen_SRCS.stamp1 DEPENDS H5detect WORKING_DIRECTORY ${HDF5_GENERATED_SOURCE_DIR} ) @@ -961,31 +974,62 @@ if (NOT EXISTS ${HDF5_GENERATED_SOURCE_DIR}/H5Tinit.c) if (BUILD_SHARED_LIBS) add_custom_command ( OUTPUT ${HDF5_GENERATED_SOURCE_DIR}/shared/H5Tinit.c + ${HDF5_GENERATED_SOURCE_DIR}/shared/shared_gen_SRCS.stamp1 COMMAND ${CMAKE_COMMAND} ARGS -E copy_if_different "${HDF5_GENERATED_SOURCE_DIR}/H5Tinit.c" "${HDF5_GENERATED_SOURCE_DIR}/shared/H5Tinit.c" + COMMAND ${CMAKE_COMMAND} + ARGS -E touch ${HDF5_GENERATED_SOURCE_DIR}/shared/shared_gen_SRCS.stamp1 DEPENDS gen_H5Tinit ${HDF5_GENERATED_SOURCE_DIR}/H5Tinit_created + WORKING_DIRECTORY ${HDF5_GENERATED_SOURCE_DIR} ) set_source_files_properties (${HDF5_GENERATED_SOURCE_DIR}/shared/H5Tinit.c PROPERTIES GENERATED TRUE) endif () else () add_custom_command ( OUTPUT ${HDF5_GENERATED_SOURCE_DIR}/H5Tinit.c + ${HDF5_GENERATED_SOURCE_DIR}/gen_SRCS.stamp1 COMMAND ${CMAKE_CROSSCOMPILING_EMULATOR}$<TARGET_FILE:H5detect> ARGS ${HDF5_GENERATED_SOURCE_DIR}/H5Tinit.c + COMMAND ${CMAKE_COMMAND} + ARGS -E touch ${HDF5_GENERATED_SOURCE_DIR}/gen_SRCS.stamp1 DEPENDS H5detect WORKING_DIRECTORY ${HDF5_GENERATED_SOURCE_DIR} ) if (BUILD_SHARED_LIBS) add_custom_command ( OUTPUT ${HDF5_GENERATED_SOURCE_DIR}/shared/H5Tinit.c + ${HDF5_GENERATED_SOURCE_DIR}/shared/shared_gen_SRCS.stamp1 COMMAND ${CMAKE_COMMAND} ARGS -E copy_if_different "${HDF5_GENERATED_SOURCE_DIR}/H5Tinit.c" "${HDF5_GENERATED_SOURCE_DIR}/shared/H5Tinit.c" + COMMAND ${CMAKE_COMMAND} + ARGS -E touch ${HDF5_GENERATED_SOURCE_DIR}/shared/shared_gen_SRCS.stamp1 DEPENDS ${HDF5_GENERATED_SOURCE_DIR}/H5Tinit.c + WORKING_DIRECTORY ${HDF5_GENERATED_SOURCE_DIR} ) set_source_files_properties (${HDF5_GENERATED_SOURCE_DIR}/shared/H5Tinit.c PROPERTIES GENERATED TRUE) endif () endif () set_source_files_properties (${HDF5_GENERATED_SOURCE_DIR}/H5Tinit.c PROPERTIES GENERATED TRUE) +else () + add_custom_command ( + OUTPUT ${HDF5_GENERATED_SOURCE_DIR}/gen_SRCS.stamp1 + COMMAND ${CMAKE_COMMAND} + ARGS -E touch ${HDF5_GENERATED_SOURCE_DIR}/gen_SRCS.stamp1 + DEPENDS ${HDF5_GENERATED_SOURCE_DIR}/H5Tinit.c + WORKING_DIRECTORY ${HDF5_GENERATED_SOURCE_DIR} + ) + if (BUILD_SHARED_LIBS) + add_custom_command ( + OUTPUT ${HDF5_GENERATED_SOURCE_DIR}/shared/shared_gen_SRCS.stamp1 + COMMAND ${CMAKE_COMMAND} + ARGS -E copy_if_different "${HDF5_GENERATED_SOURCE_DIR}/H5Tinit.c" "${HDF5_GENERATED_SOURCE_DIR}/shared/H5Tinit.c" + COMMAND ${CMAKE_COMMAND} + ARGS -E touch ${HDF5_GENERATED_SOURCE_DIR}/shared/shared_gen_SRCS.stamp1 + DEPENDS ${HDF5_GENERATED_SOURCE_DIR}/H5Tinit.c + WORKING_DIRECTORY ${HDF5_GENERATED_SOURCE_DIR} + ) + set_source_files_properties (${HDF5_GENERATED_SOURCE_DIR}/shared/H5Tinit.c PROPERTIES GENERATED TRUE) + endif () endif () add_executable (H5make_libsettings ${HDF5_SRC_DIR}/H5make_libsettings.c) @@ -999,8 +1043,11 @@ target_link_libraries (H5make_libsettings add_custom_command ( OUTPUT ${HDF5_BINARY_DIR}/H5lib_settings.c + ${HDF5_BINARY_DIR}/gen_SRCS.stamp2 COMMAND ${CMAKE_CROSSCOMPILING_EMULATOR}$<TARGET_FILE:H5make_libsettings> ARGS ${HDF5_BINARY_DIR}/H5lib_settings.c + COMMAND ${CMAKE_COMMAND} + ARGS -E touch ${HDF5_GENERATED_SOURCE_DIR}/gen_SRCS.stamp2 DEPENDS H5make_libsettings WORKING_DIRECTORY ${HDF5_BINARY_DIR} ) @@ -1008,9 +1055,13 @@ set_source_files_properties (${HDF5_BINARY_DIR}/H5lib_settings.c PROPERTIES GENE if (BUILD_SHARED_LIBS) add_custom_command ( OUTPUT ${HDF5_BINARY_DIR}/shared/H5lib_settings.c + ${HDF5_BINARY_DIR}/shared/shared_gen_SRCS.stamp2 COMMAND ${CMAKE_COMMAND} ARGS -E copy_if_different "${HDF5_BINARY_DIR}/H5lib_settings.c" "${HDF5_BINARY_DIR}/shared/H5lib_settings.c" + COMMAND ${CMAKE_COMMAND} + ARGS -E touch ${HDF5_GENERATED_SOURCE_DIR}/shared/shared_gen_SRCS.stamp2 DEPENDS ${HDF5_BINARY_DIR}/H5lib_settings.c + WORKING_DIRECTORY ${HDF5_BINARY_DIR} ) set_source_files_properties (${HDF5_BINARY_DIR}/shared/H5lib_settings.c PROPERTIES GENERATED TRUE) endif () @@ -1023,8 +1074,8 @@ option (HDF5_ENABLE_DEBUG_APIS "Turn on extra debug output in all packages" OFF) # Add H5Tinit source to build - generated by H5detect/CMake at configure time #----------------------------------------------------------------------------- set (gen_SRCS ${HDF5_GENERATED_SOURCE_DIR}/H5Tinit.c ${HDF5_BINARY_DIR}/H5lib_settings.c) +add_custom_target (gen_${HDF5_LIB_TARGET} ALL DEPENDS ${HDF5_GENERATED_SOURCE_DIR}/gen_SRCS.stamp1 ${HDF5_GENERATED_SOURCE_DIR}/gen_SRCS.stamp2) -add_custom_target (gen_${HDF5_LIB_TARGET} ALL DEPENDS ${gen_SRCS}) add_library (${HDF5_LIB_TARGET} STATIC ${common_SRCS} ${gen_SRCS} ${H5_PUBLIC_HEADERS} ${H5_PRIVATE_HEADERS} ${H5_GENERATED_HEADERS}) target_include_directories(${HDF5_LIB_TARGET} PRIVATE "${HDF5_SRC_DIR};${HDF5_BINARY_DIR};$<$<BOOL:${HDF5_ENABLE_PARALLEL}>:${MPI_C_INCLUDE_DIRS}>" @@ -1053,8 +1104,8 @@ set (install_targets ${HDF5_LIB_TARGET}) if (BUILD_SHARED_LIBS) set (shared_gen_SRCS ${HDF5_GENERATED_SOURCE_DIR}/shared/H5Tinit.c ${HDF5_BINARY_DIR}/shared/H5lib_settings.c) + add_custom_target (gen_${HDF5_LIBSH_TARGET} ALL DEPENDS ${HDF5_GENERATED_SOURCE_DIR}/shared/shared_gen_SRCS.stamp1 ${HDF5_GENERATED_SOURCE_DIR}/shared/shared_gen_SRCS.stamp2) - add_custom_target (gen_${HDF5_LIBSH_TARGET} ALL DEPENDS ${shared_gen_SRCS}) add_library (${HDF5_LIBSH_TARGET} SHARED ${common_SRCS} ${shared_gen_SRCS} ${H5_PUBLIC_HEADERS} ${H5_PRIVATE_HEADERS} ${H5_GENERATED_HEADERS}) target_include_directories(${HDF5_LIBSH_TARGET} PRIVATE "${HDF5_SRC_DIR};${HDF5_BINARY_DIR};$<$<BOOL:${HDF5_ENABLE_PARALLEL}>:${MPI_C_INCLUDE_DIRS}>" @@ -296,18 +296,17 @@ H5Acreate2(hid_t loc_id, const char *attr_name, hid_t type_id, hid_t space_id, loc_params.obj_type = H5I_get_type(loc_id); /* Create the attribute */ - if(NULL == (attr = H5VL_attr_create(vol_obj->data, loc_params, vol_obj->driver->cls, attr_name, - acpl_id, aapl_id, H5P_DATASET_XFER_DEFAULT, H5_REQUEST_NULL))) + if(NULL == (attr = H5VL_attr_create(vol_obj, &loc_params, attr_name, acpl_id, aapl_id, H5P_DATASET_XFER_DEFAULT, H5_REQUEST_NULL))) HGOTO_ERROR(H5E_ATTR, H5E_CANTINIT, H5I_INVALID_HID, "unable to create attribute") /* Register the new attribute and get an ID for it */ - if((ret_value = H5VL_register(H5I_ATTR, attr, vol_obj->driver, TRUE)) < 0) - HGOTO_ERROR(H5E_ATOM, H5E_CANTREGISTER, H5I_INVALID_HID, "unable to atomize attribute handle") + if((ret_value = H5VL_register(H5I_ATTR, attr, vol_obj->connector, TRUE)) < 0) + HGOTO_ERROR(H5E_ATTR, H5E_CANTREGISTER, H5I_INVALID_HID, "unable to atomize attribute handle") done: /* Cleanup on failure */ if(H5I_INVALID_HID == ret_value) - if(attr && H5VL_attr_close(attr, vol_obj->driver->cls, H5P_DATASET_XFER_DEFAULT, H5_REQUEST_NULL) < 0) + if(attr && H5VL_attr_close(vol_obj, H5P_DATASET_XFER_DEFAULT, H5_REQUEST_NULL) < 0) HDONE_ERROR(H5E_ATTR, H5E_CLOSEERROR, H5I_INVALID_HID, "can't close attribute") FUNC_LEAVE_API(ret_value) @@ -349,7 +348,7 @@ H5Acreate_by_name(hid_t loc_id, const char *obj_name, const char *attr_name, hid_t type_id, hid_t space_id, hid_t acpl_id, hid_t aapl_id, hid_t lapl_id) { - void *attr = NULL; /* attr token from VOL plugin */ + void *attr = NULL; /* attr token from VOL connector */ H5VL_object_t *vol_obj = NULL; /* object token of loc_id */ H5P_genplist_t *plist; /* Property list pointer */ H5VL_loc_params_t loc_params; @@ -402,18 +401,17 @@ H5Acreate_by_name(hid_t loc_id, const char *obj_name, const char *attr_name, HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, H5I_INVALID_HID, "invalid location identifier") /* Create the attribute */ - if(NULL == (attr = H5VL_attr_create(vol_obj->data, loc_params, vol_obj->driver->cls, attr_name, - acpl_id, aapl_id, H5P_DATASET_XFER_DEFAULT, H5_REQUEST_NULL))) + if(NULL == (attr = H5VL_attr_create(vol_obj, &loc_params, attr_name, acpl_id, aapl_id, H5P_DATASET_XFER_DEFAULT, H5_REQUEST_NULL))) HGOTO_ERROR(H5E_ATTR, H5E_CANTINIT, H5I_INVALID_HID, "unable to create attribute") /* Register the new attribute and get an ID for it */ - if((ret_value = H5VL_register(H5I_ATTR, attr, vol_obj->driver, TRUE)) < 0) - HGOTO_ERROR(H5E_ATOM, H5E_CANTREGISTER, H5I_INVALID_HID, "unable to atomize attribute handle") + if((ret_value = H5VL_register(H5I_ATTR, attr, vol_obj->connector, TRUE)) < 0) + HGOTO_ERROR(H5E_ATTR, H5E_CANTREGISTER, H5I_INVALID_HID, "unable to atomize attribute handle") done: /* Cleanup on failure */ if(H5I_INVALID_HID == ret_value) - if(attr && H5VL_attr_close (attr, vol_obj->driver->cls, H5P_DATASET_XFER_DEFAULT, H5_REQUEST_NULL) < 0) + if(attr && H5VL_attr_close(vol_obj, H5P_DATASET_XFER_DEFAULT, H5_REQUEST_NULL) < 0) HDONE_ERROR(H5E_ATTR, H5E_CLOSEERROR, H5I_INVALID_HID, "can't close attribute") FUNC_LEAVE_API(ret_value) @@ -442,7 +440,7 @@ done: hid_t H5Aopen(hid_t loc_id, const char *attr_name, hid_t aapl_id) { - void *attr = NULL; /* attr token from VOL driver */ + void *attr = NULL; /* attr token from VOL connector */ H5VL_object_t *vol_obj = NULL; /* object token of loc_id */ H5VL_loc_params_t loc_params; hid_t ret_value = H5I_INVALID_HID; @@ -471,18 +469,17 @@ H5Aopen(hid_t loc_id, const char *attr_name, hid_t aapl_id) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, H5I_INVALID_HID, "invalid location identifier") /* Open the attribute */ - if(NULL == (attr = H5VL_attr_open(vol_obj->data, loc_params, vol_obj->driver->cls, - attr_name, aapl_id, H5P_DATASET_XFER_DEFAULT, H5_REQUEST_NULL))) + if(NULL == (attr = H5VL_attr_open(vol_obj, &loc_params, attr_name, aapl_id, H5P_DATASET_XFER_DEFAULT, H5_REQUEST_NULL))) HGOTO_ERROR(H5E_ATTR, H5E_CANTOPENOBJ, H5I_INVALID_HID, "unable to open attribute: '%s'", attr_name) /* Register the attribute and get an ID for it */ - if((ret_value = H5VL_register(H5I_ATTR, attr, vol_obj->driver, TRUE)) < 0) - HGOTO_ERROR(H5E_ATOM, H5E_CANTREGISTER, H5I_INVALID_HID, "unable to atomize attribute handle") + if((ret_value = H5VL_register(H5I_ATTR, attr, vol_obj->connector, TRUE)) < 0) + HGOTO_ERROR(H5E_ATTR, H5E_CANTREGISTER, H5I_INVALID_HID, "unable to atomize attribute handle") done: /* Cleanup on failure */ if(H5I_INVALID_HID == ret_value) - if(attr && H5VL_attr_close(attr, vol_obj->driver->cls, H5P_DATASET_XFER_DEFAULT, H5_REQUEST_NULL) < 0) + if(attr && H5VL_attr_close(vol_obj, H5P_DATASET_XFER_DEFAULT, H5_REQUEST_NULL) < 0) HDONE_ERROR(H5E_ATTR, H5E_CLOSEERROR, H5I_INVALID_HID, "can't close attribute") FUNC_LEAVE_API(ret_value) @@ -514,7 +511,7 @@ hid_t H5Aopen_by_name(hid_t loc_id, const char *obj_name, const char *attr_name, hid_t aapl_id, hid_t lapl_id) { - void *attr = NULL; /* attr token from VOL driver */ + void *attr = NULL; /* attr token from VOL connector */ H5VL_object_t *vol_obj = NULL; /* object token of loc_id */ H5VL_loc_params_t loc_params; hid_t ret_value = H5I_INVALID_HID; @@ -554,18 +551,17 @@ H5Aopen_by_name(hid_t loc_id, const char *obj_name, const char *attr_name, HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, H5I_INVALID_HID, "invalid location identifier") /* Open the attribute */ - if(NULL == (attr = H5VL_attr_open(vol_obj->data, loc_params, vol_obj->driver->cls, - attr_name, aapl_id, H5P_DATASET_XFER_DEFAULT, H5_REQUEST_NULL))) + if(NULL == (attr = H5VL_attr_open(vol_obj, &loc_params, attr_name, aapl_id, H5P_DATASET_XFER_DEFAULT, H5_REQUEST_NULL))) HGOTO_ERROR(H5E_ATTR, H5E_CANTOPENOBJ, H5I_INVALID_HID, "can't open attribute") /* Register the attribute and get an ID for it */ - if((ret_value = H5VL_register(H5I_ATTR, attr, vol_obj->driver, TRUE)) < 0) - HGOTO_ERROR(H5E_ATOM, H5E_CANTREGISTER, H5I_INVALID_HID, "unable to atomize attribute handle") + if((ret_value = H5VL_register(H5I_ATTR, attr, vol_obj->connector, TRUE)) < 0) + HGOTO_ERROR(H5E_ATTR, H5E_CANTREGISTER, H5I_INVALID_HID, "unable to atomize attribute handle") done: /* Cleanup on failure */ if(H5I_INVALID_HID == ret_value) - if(attr && H5VL_attr_close (attr, vol_obj->driver->cls, H5P_DATASET_XFER_DEFAULT, H5_REQUEST_NULL) < 0) + if(attr && H5VL_attr_close(vol_obj, H5P_DATASET_XFER_DEFAULT, H5_REQUEST_NULL) < 0) HDONE_ERROR(H5E_ATTR, H5E_CLOSEERROR, H5I_INVALID_HID, "can't close attribute") FUNC_LEAVE_API(ret_value) @@ -646,18 +642,17 @@ H5Aopen_by_idx(hid_t loc_id, const char *obj_name, H5_index_t idx_type, HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, H5I_INVALID_HID, "invalid location identifier") /* Open the attribute */ - if(NULL == (attr = H5VL_attr_open(vol_obj->data, loc_params, vol_obj->driver->cls, - NULL, aapl_id, H5P_DATASET_XFER_DEFAULT, H5_REQUEST_NULL))) + if(NULL == (attr = H5VL_attr_open(vol_obj, &loc_params, NULL, aapl_id, H5P_DATASET_XFER_DEFAULT, H5_REQUEST_NULL))) HGOTO_ERROR(H5E_ATTR, H5E_CANTOPENOBJ, H5I_INVALID_HID, "unable to open attribute") /* Register the attribute and get an ID for it */ - if((ret_value = H5VL_register(H5I_ATTR, attr, vol_obj->driver, TRUE)) < 0) - HGOTO_ERROR(H5E_ATOM, H5E_CANTREGISTER, H5I_INVALID_HID, "unable to atomize attribute handle") + if((ret_value = H5VL_register(H5I_ATTR, attr, vol_obj->connector, TRUE)) < 0) + HGOTO_ERROR(H5E_ATTR, H5E_CANTREGISTER, H5I_INVALID_HID, "unable to atomize attribute handle") done: /* Cleanup on failure */ if(H5I_INVALID_HID == ret_value) - if(attr && H5VL_attr_close(attr, vol_obj->driver->cls, H5P_DATASET_XFER_DEFAULT, H5_REQUEST_NULL) < 0) + if(attr && H5VL_attr_close(vol_obj, H5P_DATASET_XFER_DEFAULT, H5_REQUEST_NULL) < 0) HDONE_ERROR(H5E_ATTR, H5E_CLOSEERROR, H5I_INVALID_HID, "can't close attribute") FUNC_LEAVE_API(ret_value) @@ -702,8 +697,7 @@ H5Awrite(hid_t attr_id, hid_t dtype_id, const void *buf) HGOTO_ERROR(H5E_ATTR, H5E_CANTSET, FAIL, "can't set collective metadata read") /* Write the attribute data */ - if((ret_value = H5VL_attr_write(vol_obj->data, vol_obj->driver->cls, - dtype_id, buf, H5P_DATASET_XFER_DEFAULT, H5_REQUEST_NULL)) < 0) + if((ret_value = H5VL_attr_write(vol_obj, dtype_id, buf, H5P_DATASET_XFER_DEFAULT, H5_REQUEST_NULL)) < 0) HGOTO_ERROR(H5E_ATTR, H5E_WRITEERROR, FAIL, "unable to write attribute") done: @@ -745,8 +739,7 @@ H5Aread(hid_t attr_id, hid_t dtype_id, void *buf) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "buf parameter can't be NULL") /* Read the attribute data */ - if((ret_value = H5VL_attr_read(vol_obj->data, vol_obj->driver->cls, - dtype_id, buf, H5P_DATASET_XFER_DEFAULT, H5_REQUEST_NULL)) < 0) + if((ret_value = H5VL_attr_read(vol_obj, dtype_id, buf, H5P_DATASET_XFER_DEFAULT, H5_REQUEST_NULL)) < 0) HGOTO_ERROR(H5E_ATTR, H5E_READERROR, FAIL, "unable to read attribute") done: @@ -784,8 +777,7 @@ H5Aget_space(hid_t attr_id) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, H5I_INVALID_HID, "not an attribute") /* Get the dataspace */ - if(H5VL_attr_get(vol_obj->data, vol_obj->driver->cls, H5VL_ATTR_GET_SPACE, - H5P_DATASET_XFER_DEFAULT, H5_REQUEST_NULL, &ret_value) < 0) + if(H5VL_attr_get(vol_obj, H5VL_ATTR_GET_SPACE, H5P_DATASET_XFER_DEFAULT, H5_REQUEST_NULL, &ret_value) < 0) HGOTO_ERROR(H5E_ATTR, H5E_CANTGET, H5I_INVALID_HID, "unable to get dataspace of attribute") done: @@ -812,7 +804,7 @@ done: hid_t H5Aget_type(hid_t attr_id) { - H5VL_object_t *vol_obj = NULL; /* Attribute object for ID */ + H5VL_object_t *vol_obj = NULL; /* Attribute object for ID */ hid_t ret_value = H5I_INVALID_HID; /* Return value */ FUNC_ENTER_API(H5I_INVALID_HID) @@ -823,8 +815,7 @@ H5Aget_type(hid_t attr_id) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, H5I_INVALID_HID, "not an attribute") /* Get the datatype */ - if(H5VL_attr_get(vol_obj->data, vol_obj->driver->cls, H5VL_ATTR_GET_TYPE, - H5P_DATASET_XFER_DEFAULT, H5_REQUEST_NULL, &ret_value) < 0) + if(H5VL_attr_get(vol_obj, H5VL_ATTR_GET_TYPE, H5P_DATASET_XFER_DEFAULT, H5_REQUEST_NULL, &ret_value) < 0) HGOTO_ERROR(H5E_ATTR, H5E_CANTGET, H5I_INVALID_HID, "unable to get datatype of attribute") done: @@ -867,8 +858,7 @@ H5Aget_create_plist(hid_t attr_id) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, H5I_INVALID_HID, "not an attribute") /* Get the acpl */ - if(H5VL_attr_get(vol_obj->data, vol_obj->driver->cls, H5VL_ATTR_GET_ACPL, - H5P_DATASET_XFER_DEFAULT, H5_REQUEST_NULL, &ret_value) < 0) + if(H5VL_attr_get(vol_obj, H5VL_ATTR_GET_ACPL, H5P_DATASET_XFER_DEFAULT, H5_REQUEST_NULL, &ret_value) < 0) HGOTO_ERROR(H5E_ATTR, H5E_CANTGET, H5I_INVALID_HID, "unable to get creation property list for attribute") done: @@ -918,9 +908,7 @@ H5Aget_name(hid_t attr_id, size_t buf_size, char *buf) loc_params.obj_type = H5I_get_type(attr_id); /* Get the attribute name */ - if(H5VL_attr_get(vol_obj->data, vol_obj->driver->cls, H5VL_ATTR_GET_NAME, - H5P_DATASET_XFER_DEFAULT, H5_REQUEST_NULL, - loc_params, buf_size, buf, &ret_value) < 0) + if(H5VL_attr_get(vol_obj, H5VL_ATTR_GET_NAME, H5P_DATASET_XFER_DEFAULT, H5_REQUEST_NULL, &loc_params, buf_size, buf, &ret_value) < 0) HGOTO_ERROR(H5E_ATTR, H5E_CANTGET, (-1), "unable to get attribute name") done: @@ -985,8 +973,7 @@ H5Aget_name_by_idx(hid_t loc_id, const char *obj_name, H5_index_t idx_type, loc_params.obj_type = H5I_get_type(loc_id); /* Get the name */ - if(H5VL_attr_get(vol_obj->data, vol_obj->driver->cls, H5VL_ATTR_GET_NAME, - H5P_DATASET_XFER_DEFAULT, H5_REQUEST_NULL, loc_params, size, name, &ret_value) < 0) + if(H5VL_attr_get(vol_obj, H5VL_ATTR_GET_NAME, H5P_DATASET_XFER_DEFAULT, H5_REQUEST_NULL, &loc_params, size, name, &ret_value) < 0) HGOTO_ERROR(H5E_ATTR, H5E_CANTGET, FAIL, "unable to get name") done: @@ -1025,8 +1012,7 @@ H5Aget_storage_size(hid_t attr_id) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, 0, "not an attribute") /* Get the storage size */ - if(H5VL_attr_get(vol_obj->data, vol_obj->driver->cls, H5VL_ATTR_GET_STORAGE_SIZE, - H5P_DATASET_XFER_DEFAULT, H5_REQUEST_NULL, &ret_value) < 0) + if(H5VL_attr_get(vol_obj, H5VL_ATTR_GET_STORAGE_SIZE, H5P_DATASET_XFER_DEFAULT, H5_REQUEST_NULL, &ret_value) < 0) HGOTO_ERROR(H5E_ATTR, H5E_CANTGET, 0, "unable to get acpl") done: @@ -1060,13 +1046,14 @@ H5Aget_info(hid_t attr_id, H5A_info_t *ainfo) /* Check arguments */ if(NULL == (vol_obj = (H5VL_object_t *)H5I_object_verify(attr_id, H5I_ATTR))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not an attribute") + if(!ainfo) + HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "attribute_info parameter cannot be NULL") loc_params.type = H5VL_OBJECT_BY_SELF; loc_params.obj_type = H5I_get_type(attr_id); /* Get the attribute information */ - if(H5VL_attr_get(vol_obj->data, vol_obj->driver->cls, H5VL_ATTR_GET_INFO, - H5P_DATASET_XFER_DEFAULT, H5_REQUEST_NULL, loc_params, ainfo) < 0) + if(H5VL_attr_get(vol_obj, H5VL_ATTR_GET_INFO, H5P_DATASET_XFER_DEFAULT, H5_REQUEST_NULL, &loc_params, ainfo) < 0) HGOTO_ERROR(H5E_ATTR, H5E_CANTGET, FAIL, "unable to get attribute info") done: @@ -1122,8 +1109,7 @@ H5Aget_info_by_name(hid_t loc_id, const char *obj_name, const char *attr_name, HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "invalid object identifier") /* Get the attribute information */ - if(H5VL_attr_get(vol_obj->data, vol_obj->driver->cls, H5VL_ATTR_GET_INFO, - H5P_DATASET_XFER_DEFAULT, H5_REQUEST_NULL, loc_params, ainfo, attr_name) < 0) + if(H5VL_attr_get(vol_obj, H5VL_ATTR_GET_INFO, H5P_DATASET_XFER_DEFAULT, H5_REQUEST_NULL, &loc_params, ainfo, attr_name) < 0) HGOTO_ERROR(H5E_ATTR, H5E_CANTGET, FAIL, "unable to get attribute info") done: @@ -1186,8 +1172,7 @@ H5Aget_info_by_idx(hid_t loc_id, const char *obj_name, H5_index_t idx_type, HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "invalid object identifier") /* Get the attribute information */ - if(H5VL_attr_get(vol_obj->data, vol_obj->driver->cls, H5VL_ATTR_GET_INFO, - H5P_DATASET_XFER_DEFAULT, H5_REQUEST_NULL, loc_params, ainfo) < 0) + if(H5VL_attr_get(vol_obj, H5VL_ATTR_GET_INFO, H5P_DATASET_XFER_DEFAULT, H5_REQUEST_NULL, &loc_params, ainfo) < 0) HGOTO_ERROR(H5E_ATTR, H5E_CANTGET, FAIL, "unable to get attribute info") done: @@ -1238,10 +1223,9 @@ H5Arename(hid_t loc_id, const char *old_name, const char *new_name) HGOTO_ERROR(H5E_ATTR, H5E_CANTSET, FAIL, "can't set collective metadata read") /* Rename the attribute */ - if((ret_value = H5VL_attr_specific(vol_obj->data, loc_params, vol_obj->driver->cls, H5VL_ATTR_RENAME, - H5P_DATASET_XFER_DEFAULT, H5_REQUEST_NULL, old_name, new_name)) < 0) + if(H5VL_attr_specific(vol_obj, &loc_params, H5VL_ATTR_RENAME, H5P_DATASET_XFER_DEFAULT, H5_REQUEST_NULL, old_name, new_name) < 0) HGOTO_ERROR(H5E_ATTR, H5E_CANTRENAME, FAIL, "can't rename attribute") - } + } /* end if */ done: FUNC_LEAVE_API(ret_value) @@ -1299,10 +1283,9 @@ H5Arename_by_name(hid_t loc_id, const char *obj_name, const char *old_attr_name, HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "invalid location identifier") /* Rename the attribute */ - if((ret_value = H5VL_attr_specific(vol_obj->data, loc_params, vol_obj->driver->cls, H5VL_ATTR_RENAME, - H5P_DATASET_XFER_DEFAULT, H5_REQUEST_NULL, old_attr_name, new_attr_name)) < 0) + if(H5VL_attr_specific(vol_obj, &loc_params, H5VL_ATTR_RENAME, H5P_DATASET_XFER_DEFAULT, H5_REQUEST_NULL, old_attr_name, new_attr_name) < 0) HGOTO_ERROR(H5E_ATTR, H5E_CANTRENAME, FAIL, "can't rename attribute") - } + } /* end if */ done: FUNC_LEAVE_API(ret_value) @@ -1377,9 +1360,7 @@ H5Aiterate2(hid_t loc_id, H5_index_t idx_type, H5_iter_order_t order, HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "invalid location identifier") /* Iterate over attributes */ - if((ret_value = H5VL_attr_specific(vol_obj->data, loc_params, vol_obj->driver->cls, H5VL_ATTR_ITER, - H5P_DATASET_XFER_DEFAULT, H5_REQUEST_NULL, - idx_type, order, idx, op, op_data)) < 0) + if((ret_value = H5VL_attr_specific(vol_obj, &loc_params, H5VL_ATTR_ITER, H5P_DATASET_XFER_DEFAULT, H5_REQUEST_NULL, (int)idx_type, (int)order, idx, op, op_data)) < 0) HERROR(H5E_ATTR, H5E_BADITER, "error iterating over attributes"); done: @@ -1467,9 +1448,7 @@ H5Aiterate_by_name(hid_t loc_id, const char *obj_name, H5_index_t idx_type, HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "invalid location identifier") /* Iterate over attributes */ - if((ret_value = H5VL_attr_specific(vol_obj->data, loc_params, vol_obj->driver->cls, H5VL_ATTR_ITER, - H5P_DATASET_XFER_DEFAULT, H5_REQUEST_NULL, - idx_type, order, idx, op, op_data)) < 0) + if((ret_value = H5VL_attr_specific(vol_obj, &loc_params, H5VL_ATTR_ITER, H5P_DATASET_XFER_DEFAULT, H5_REQUEST_NULL, (int)idx_type, (int)order, idx, op, op_data)) < 0) HERROR(H5E_ATTR, H5E_BADITER, "attribute iteration failed"); done: @@ -1522,8 +1501,7 @@ H5Adelete(hid_t loc_id, const char *name) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "invalid object identifier") /* Delete the attribute */ - if((ret_value = H5VL_attr_specific(vol_obj->data, loc_params, vol_obj->driver->cls, H5VL_ATTR_DELETE, - H5P_DATASET_XFER_DEFAULT, H5_REQUEST_NULL, name)) < 0) + if(H5VL_attr_specific(vol_obj, &loc_params, H5VL_ATTR_DELETE, H5P_DATASET_XFER_DEFAULT, H5_REQUEST_NULL, name) < 0) HGOTO_ERROR(H5E_ATTR, H5E_CANTDELETE, FAIL, "unable to delete attribute") done: @@ -1581,8 +1559,7 @@ H5Adelete_by_name(hid_t loc_id, const char *obj_name, const char *attr_name, HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "invalid object identifier") /* Delete the attribute */ - if((ret_value = H5VL_attr_specific(vol_obj->data, loc_params, vol_obj->driver->cls, H5VL_ATTR_DELETE, - H5P_DATASET_XFER_DEFAULT, H5_REQUEST_NULL, attr_name)) < 0) + if(H5VL_attr_specific(vol_obj, &loc_params, H5VL_ATTR_DELETE, H5P_DATASET_XFER_DEFAULT, H5_REQUEST_NULL, attr_name) < 0) HGOTO_ERROR(H5E_ATTR, H5E_CANTDELETE, FAIL, "unable to delete attribute") done: @@ -1652,8 +1629,7 @@ H5Adelete_by_idx(hid_t loc_id, const char *obj_name, H5_index_t idx_type, HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "invalid object identifier") /* Delete the attribute through the VOL */ - if((ret_value = H5VL_attr_specific(vol_obj->data, loc_params, vol_obj->driver->cls, H5VL_ATTR_DELETE, - H5P_DATASET_XFER_DEFAULT, H5_REQUEST_NULL, NULL)) < 0) + if(H5VL_attr_specific(vol_obj, &loc_params, H5VL_ATTR_DELETE, H5P_DATASET_XFER_DEFAULT, H5_REQUEST_NULL, NULL) < 0) HGOTO_ERROR(H5E_ATTR, H5E_CANTDELETE, FAIL, "unable to delete attribute") done: @@ -1731,8 +1707,7 @@ H5Aexists(hid_t obj_id, const char *attr_name) loc_params.obj_type = H5I_get_type(obj_id); /* Check if the attribute exists */ - if(H5VL_attr_specific(vol_obj->data, loc_params, vol_obj->driver->cls, H5VL_ATTR_EXISTS, - H5P_DATASET_XFER_DEFAULT, H5_REQUEST_NULL, attr_name, &ret_value) < 0) + if(H5VL_attr_specific(vol_obj, &loc_params, H5VL_ATTR_EXISTS, H5P_DATASET_XFER_DEFAULT, H5_REQUEST_NULL, attr_name, &ret_value) < 0) HGOTO_ERROR(H5E_ATTR, H5E_CANTGET, FAIL, "unable to determine if attribute exists") done: @@ -1786,8 +1761,7 @@ H5Aexists_by_name(hid_t loc_id, const char *obj_name, const char *attr_name, loc_params.obj_type = H5I_get_type(loc_id); /* Check existence of attribute */ - if(H5VL_attr_specific(vol_obj->data, loc_params, vol_obj->driver->cls, H5VL_ATTR_EXISTS, - H5P_DATASET_XFER_DEFAULT, H5_REQUEST_NULL, attr_name, &ret_value) < 0) + if(H5VL_attr_specific(vol_obj, &loc_params, H5VL_ATTR_EXISTS, H5P_DATASET_XFER_DEFAULT, H5_REQUEST_NULL, attr_name, &ret_value) < 0) HGOTO_ERROR(H5E_ATTR, H5E_CANTGET, FAIL, "unable to determine if attribute exists") done: diff --git a/src/H5Adeprec.c b/src/H5Adeprec.c index cce9316..b438cd2 100644 --- a/src/H5Adeprec.c +++ b/src/H5Adeprec.c @@ -45,6 +45,8 @@ #include "H5Opkg.h" /* Object headers */ #include "H5VLprivate.h" /* Virtual object layer */ +#include "H5VLnative_private.h" /* Native VOL connector */ + /****************/ /* Local Macros */ @@ -114,8 +116,8 @@ hid_t H5Acreate1(hid_t loc_id, const char *name, hid_t type_id, hid_t space_id, hid_t acpl_id) { - void *attr = NULL; /* attr token from VOL plugin */ - H5VL_object_t *vol_obj = NULL; /* object token of loc_id */ + void *attr = NULL; /* attr token from VOL connector */ + H5VL_object_t *vol_obj = NULL; /* Object token of loc_id */ H5VL_loc_params_t loc_params; H5P_genplist_t *plist; /* Property list pointer */ hid_t ret_value = H5I_INVALID_HID; /* Return value */ @@ -156,18 +158,17 @@ H5Acreate1(hid_t loc_id, const char *name, hid_t type_id, hid_t space_id, HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, H5I_INVALID_HID, "invalid location identifier") /* Create the attribute */ - if(NULL == (attr = H5VL_attr_create(vol_obj->data, loc_params, vol_obj->driver->cls, name, - acpl_id, H5P_DEFAULT, H5P_DATASET_XFER_DEFAULT, H5_REQUEST_NULL))) + if(NULL == (attr = H5VL_attr_create(vol_obj, &loc_params, name, acpl_id, H5P_DEFAULT, H5P_DATASET_XFER_DEFAULT, H5_REQUEST_NULL))) HGOTO_ERROR(H5E_ATTR, H5E_CANTINIT, H5I_INVALID_HID, "unable to create attribute") /* Register the new attribute and get an ID for it */ - if((ret_value = H5VL_register(H5I_ATTR, attr, vol_obj->driver, TRUE)) < 0) - HGOTO_ERROR(H5E_ATOM, H5E_CANTREGISTER, H5I_INVALID_HID, "unable to register attribute for ID") + if((ret_value = H5VL_register(H5I_ATTR, attr, vol_obj->connector, TRUE)) < 0) + HGOTO_ERROR(H5E_ATTR, H5E_CANTREGISTER, H5I_INVALID_HID, "unable to register attribute for ID") done: /* Clean up on failure */ if(H5I_INVALID_HID == ret_value) - if(attr && H5VL_attr_close(attr, vol_obj->driver->cls, H5P_DATASET_XFER_DEFAULT, H5_REQUEST_NULL) < 0) + if(attr && H5VL_attr_close(vol_obj, H5P_DATASET_XFER_DEFAULT, H5_REQUEST_NULL) < 0) HDONE_ERROR(H5E_ATTR, H5E_CLOSEERROR, H5I_INVALID_HID, "can't close attribute") FUNC_LEAVE_API(ret_value) @@ -199,8 +200,8 @@ done: hid_t H5Aopen_name(hid_t loc_id, const char *name) { - void *attr = NULL; /* attr token from VOL plugin */ - H5VL_object_t *vol_obj = NULL; /* object token of loc_id */ + void *attr = NULL; /* attr token from VOL connector */ + H5VL_object_t *vol_obj = NULL; /* Object token of loc_id */ H5VL_loc_params_t loc_params; hid_t ret_value = H5I_INVALID_HID; /* Return value */ @@ -218,22 +219,21 @@ H5Aopen_name(hid_t loc_id, const char *name) loc_params.obj_type = H5I_get_type(loc_id); /* Get the location object */ - if (NULL == (vol_obj = H5VL_vol_object(loc_id))) + if(NULL == (vol_obj = H5VL_vol_object(loc_id))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, H5I_INVALID_HID, "invalid location identifier") /* Open the attribute */ - if (NULL == (attr = H5VL_attr_open(vol_obj->data, loc_params, vol_obj->driver->cls, - name, H5P_DEFAULT, H5P_DATASET_XFER_DEFAULT, H5_REQUEST_NULL))) + if(NULL == (attr = H5VL_attr_open(vol_obj, &loc_params, name, H5P_DEFAULT, H5P_DATASET_XFER_DEFAULT, H5_REQUEST_NULL))) HGOTO_ERROR(H5E_ATTR, H5E_CANTOPENOBJ, H5I_INVALID_HID, "unable to open attribute") /* Register the attribute and get an ID for it */ - if ((ret_value = H5VL_register(H5I_ATTR, attr, vol_obj->driver, TRUE)) < 0) - HGOTO_ERROR(H5E_ATOM, H5E_CANTREGISTER, H5I_INVALID_HID, "unable to atomize attribute handle") + if((ret_value = H5VL_register(H5I_ATTR, attr, vol_obj->connector, TRUE)) < 0) + HGOTO_ERROR(H5E_ATTR, H5E_CANTREGISTER, H5I_INVALID_HID, "unable to atomize attribute handle") done: /* Clean up on failure */ if(H5I_INVALID_HID == ret_value) - if(attr && H5VL_attr_close(attr, vol_obj->driver->cls, H5P_DATASET_XFER_DEFAULT, H5_REQUEST_NULL) < 0) + if(attr && H5VL_attr_close(vol_obj, H5P_DATASET_XFER_DEFAULT, H5_REQUEST_NULL) < 0) HDONE_ERROR(H5E_ATTR, H5E_CLOSEERROR, H5I_INVALID_HID, "can't close attribute") FUNC_LEAVE_API(ret_value) @@ -265,8 +265,8 @@ done: hid_t H5Aopen_idx(hid_t loc_id, unsigned idx) { - void *attr = NULL; /* attr token from VOL plugin */ - H5VL_object_t *vol_obj = NULL; /* object token of loc_id */ + void *attr = NULL; /* attr token from VOL connector */ + H5VL_object_t *vol_obj = NULL; /* Object token of loc_id */ H5VL_loc_params_t loc_params; hid_t ret_value = H5I_INVALID_HID; /* Return value */ @@ -291,18 +291,17 @@ H5Aopen_idx(hid_t loc_id, unsigned idx) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, H5I_INVALID_HID, "invalid location identifier") /* Open the attribute */ - if(NULL == (attr = H5VL_attr_open(vol_obj->data, loc_params, vol_obj->driver->cls, - NULL, H5P_DEFAULT, H5P_DATASET_XFER_DEFAULT, H5_REQUEST_NULL))) + if(NULL == (attr = H5VL_attr_open(vol_obj, &loc_params, NULL, H5P_DEFAULT, H5P_DATASET_XFER_DEFAULT, H5_REQUEST_NULL))) HGOTO_ERROR(H5E_ATTR, H5E_CANTOPENOBJ, H5I_INVALID_HID, "unable to open attribute") /* Register the attribute and get an ID for it */ - if((ret_value = H5VL_register(H5I_ATTR, attr, vol_obj->driver, TRUE)) < 0) - HGOTO_ERROR(H5E_ATOM, H5E_CANTREGISTER, H5I_INVALID_HID, "unable to atomize attribute handle") + if((ret_value = H5VL_register(H5I_ATTR, attr, vol_obj->connector, TRUE)) < 0) + HGOTO_ERROR(H5E_ATTR, H5E_CANTREGISTER, H5I_INVALID_HID, "unable to atomize attribute handle") done: /* Clean up on failure */ if(H5I_INVALID_HID == ret_value) - if(attr && H5VL_attr_close(attr, vol_obj->driver->cls, H5P_DATASET_XFER_DEFAULT, H5_REQUEST_NULL) < 0) + if(attr && H5VL_attr_close(vol_obj, H5P_DATASET_XFER_DEFAULT, H5_REQUEST_NULL) < 0) HDONE_ERROR(H5E_ATTR, H5E_CLOSEERROR, H5I_INVALID_HID, "can't close attribute") FUNC_LEAVE_API(ret_value) @@ -330,7 +329,7 @@ done: int H5Aget_num_attrs(hid_t loc_id) { - H5VL_object_t *vol_obj; + H5VL_object_t *vol_obj = NULL; /* Object token of loc_id */ H5VL_loc_params_t loc_params; H5O_info_t oinfo; int ret_value = -1; @@ -341,13 +340,12 @@ H5Aget_num_attrs(hid_t loc_id) loc_params.type = H5VL_OBJECT_BY_SELF; loc_params.obj_type = H5I_get_type(loc_id); - /* get the location object */ + /* Get the location object */ if(NULL == (vol_obj = H5VL_vol_object(loc_id))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, (-1), "invalid location identifier") /* Get the number of attributes for the object */ - if(H5VL_object_optional(vol_obj->data, vol_obj->driver->cls, H5P_DATASET_XFER_DEFAULT, - H5_REQUEST_NULL, H5VL_OBJECT_GET_INFO, loc_params, &oinfo, H5O_INFO_ALL) < 0) + if(H5VL_object_optional(vol_obj, H5P_DATASET_XFER_DEFAULT, H5_REQUEST_NULL, H5VL_NATIVE_OBJECT_GET_INFO, &loc_params, &oinfo, H5O_INFO_ALL) < 0) HGOTO_ERROR(H5E_ATTR, H5E_CANTGET, (-1), "unable to get attribute count for object") H5_CHECKED_ASSIGN(ret_value, int, oinfo.num_attrs, hsize_t); @@ -397,18 +395,23 @@ done: herr_t H5Aiterate1(hid_t loc_id, unsigned *attr_num, H5A_operator1_t op, void *op_data) { - herr_t ret_value; /* Return value */ + H5VL_object_t *vol_obj = NULL; /* Object token of loc_id */ + herr_t ret_value; /* Return value */ - FUNC_ENTER_API(FAIL) + FUNC_ENTER_API(H5_ITER_ERROR) H5TRACE4("e", "i*Iux*x", loc_id, attr_num, op, op_data); /* check arguments */ if(H5I_ATTR == H5I_get_type(loc_id)) - HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "location is not valid for an attribute") + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, H5_ITER_ERROR, "location is not valid for an attribute") + + /* Get the location object */ + if(NULL == (vol_obj = H5VL_vol_object(loc_id))) + HGOTO_ERROR(H5E_VOL, H5E_BADTYPE, H5_ITER_ERROR, "invalid location identifier") /* Call attribute iteration routine */ - if((ret_value = H5A__iterate_old(loc_id, attr_num, op, op_data)) < 0) - HERROR(H5E_ATTR, H5E_BADITER, "error iterating over attributes"); + if((ret_value = H5VL_attr_optional(vol_obj, H5P_DATASET_XFER_DEFAULT, H5_REQUEST_NULL, H5VL_NATIVE_ATTR_ITERATE_OLD, loc_id, attr_num, op, op_data)) < 0) + HERROR(H5E_VOL, H5E_BADITER, "error iterating over attributes"); done: FUNC_LEAVE_API(ret_value) diff --git a/src/H5Aint.c b/src/H5Aint.c index ca5cb80..6502fa4 100644 --- a/src/H5Aint.c +++ b/src/H5Aint.c @@ -43,7 +43,6 @@ #include "H5Opkg.h" /* Object headers */ #include "H5SMprivate.h" /* Shared Object Header Messages */ #include "H5VLprivate.h" /* Virtual Object Layer */ -#include "H5VLnative_private.h" /* Native VOL driver */ /****************/ @@ -924,7 +923,7 @@ H5A__get_type(H5A_t *attr) * two level IDs, where the VOL object is a copy of the * returned datatype */ - if ((ret_value = H5VL_native_register(H5I_DATATYPE, dt, TRUE)) < 0) + if ((ret_value = H5VL_wrap_register(H5I_DATATYPE, dt, TRUE)) < 0) HGOTO_ERROR(H5E_ATOM, H5E_CANTREGISTER, H5I_INVALID_HID, "unable to atomize file handle") } else { @@ -1156,7 +1155,7 @@ H5A__close_cb(H5VL_object_t *attr_vol_obj) HDassert(attr_vol_obj); /* Close the attribute */ - if((ret_value = H5VL_attr_close(attr_vol_obj->data, attr_vol_obj->driver->cls, H5P_DATASET_XFER_DEFAULT, H5_REQUEST_NULL)) < 0) + if((ret_value = H5VL_attr_close(attr_vol_obj, H5P_DATASET_XFER_DEFAULT, H5_REQUEST_NULL)) < 0) HGOTO_ERROR(H5E_ATTR, H5E_CLOSEERROR, FAIL, "problem closing attribute") /* Free the VOL object */ @@ -2621,7 +2620,7 @@ H5A__iterate(const H5G_loc_t *loc, const char *obj_name, H5_index_t idx_type, H5 H5G_name_t obj_path; /* Opened object group hier. path */ H5O_loc_t obj_oloc; /* Opened object object location */ hbool_t loc_found = FALSE; /* Entry at 'obj_name' found */ - hid_t obj_loc_id = (-1); /* ID for object located */ + hid_t obj_loc_id = H5I_INVALID_HID; /* ID for object located */ H5A_attr_iter_op_t attr_op; /* Attribute operator */ void *temp_obj = NULL; H5I_type_t obj_type; @@ -2648,7 +2647,7 @@ H5A__iterate(const H5G_loc_t *loc, const char *obj_name, H5_index_t idx_type, H5 HGOTO_ERROR(H5E_ATTR, H5E_CANTOPENOBJ, FAIL, "unable to open object"); /* Get an ID for the object */ - if((obj_loc_id = H5VL_native_register(obj_type, temp_obj, TRUE)) < 0) + if((obj_loc_id = H5VL_wrap_register(obj_type, temp_obj, TRUE)) < 0) HGOTO_ERROR(H5E_ATOM, H5E_CANTREGISTER, FAIL, "unable to register datatype"); /* Call internal attribute iteration routine */ @@ -2660,7 +2659,7 @@ done: if(obj_loc_id != H5I_INVALID_HID) { if(H5I_dec_app_ref(obj_loc_id) < 0) HDONE_ERROR(H5E_ATTR, H5E_CANTDEC, FAIL, "unable to close temporary object"); - } + } /* end if */ else if(loc_found && H5G_loc_free(&obj_loc) < 0) HDONE_ERROR(H5E_ATTR, H5E_CANTRELEASE, FAIL, "can't free location"); @@ -2689,7 +2688,7 @@ H5A__iterate_old(hid_t loc_id, unsigned *attr_num, H5A_operator1_t op, hsize_t idx; /* Index of attribute to start iterating at */ herr_t ret_value = SUCCEED; /* Return value */ - FUNC_ENTER_PACKAGE + FUNC_ENTER_PACKAGE_NOERR /* Build attribute operator info */ attr_op.op_type = H5A_ATTR_OP_APP; @@ -2700,13 +2699,12 @@ H5A__iterate_old(hid_t loc_id, unsigned *attr_num, H5A_operator1_t op, /* Call internal attribute iteration routine */ if((ret_value = H5A__iterate_common(loc_id, H5_INDEX_CRT_ORDER, H5_ITER_INC, &idx, &attr_op, op_data)) < 0) - HGOTO_ERROR(H5E_ATTR, H5E_BADITER, FAIL, "error iterating over attributes") + HERROR(H5E_ATTR, H5E_BADITER, "error iterating over attributes"); /* Translate hsize_t index value to legacy unsigned index value*/ if(attr_num) *attr_num = (unsigned)idx; -done: FUNC_LEAVE_NOAPI(ret_value) } /* H5A__iterate_old() */ #endif /* H5_NO_DEPRECATED_SYMBOLS */ diff --git a/src/H5Apublic.h b/src/H5Apublic.h index 586940b..7162f6e 100644 --- a/src/H5Apublic.h +++ b/src/H5Apublic.h @@ -22,10 +22,6 @@ #include "H5Opublic.h" /* Object Headers */ #include "H5Tpublic.h" /* Datatypes */ -#ifdef __cplusplus -extern "C" { -#endif - /* Information struct for attribute (for H5Aget_info/H5Aget_info_by_idx) */ typedef struct { hbool_t corder_valid; /* Indicate if creation order is valid */ @@ -38,7 +34,19 @@ typedef struct { typedef herr_t (*H5A_operator2_t)(hid_t location_id/*in*/, const char *attr_name/*in*/, const H5A_info_t *ainfo/*in*/, void *op_data/*in,out*/); -/* Public function prototypes */ + +/********************/ +/* Public Variables */ +/********************/ + + +/*********************/ +/* Public Prototypes */ +/*********************/ +#ifdef __cplusplus +extern "C" { +#endif + H5_DLL hid_t H5Acreate2(hid_t loc_id, const char *attr_name, hid_t type_id, hid_t space_id, hid_t acpl_id, hid_t aapl_id); H5_DLL hid_t H5Acreate_by_name(hid_t loc_id, const char *obj_name, const char *attr_name, @@ -125,7 +125,6 @@ (*head)->ctx.H5_GLUE(PROP_FIELD,_set) = TRUE; \ } /* end if */ \ } -#endif /* H5_HAVE_PARALLEL */ /* Macro for the duplicated code to test and set properties for a property list */ #define H5CX_SET_PROP(PROP_NAME, PROP_FIELD) \ @@ -140,6 +139,7 @@ if(H5P_set((*head)->ctx.dxpl, PROP_NAME, &(*head)->ctx.PROP_FIELD) < 0) \ HGOTO_ERROR(H5E_CONTEXT, H5E_CANTSET, NULL, "error setting filter mask xfer property") \ } /* end if */ +#endif /* H5_HAVE_PARALLEL */ /******************/ @@ -267,6 +267,10 @@ typedef struct H5CX_t { /* Cached LAPL properties */ size_t nlinks; /* Number of soft / UD links to traverse (H5L_ACS_NLINKS_NAME) */ hbool_t nlinks_valid; /* Whether number of soft / UD links to traverse is valid */ + + /* Cached VOL properties */ + void *vol_wrap_ctx; /* VOL plugin's "wrap context" for creating IDs */ + hbool_t vol_wrap_ctx_valid; /* Whether VOL plugin's "wrap context" for creating IDs is valid */ } H5CX_t; /* Typedef for nodes on the API context stack */ @@ -918,6 +922,40 @@ done: /*------------------------------------------------------------------------- + * Function: H5CX_set_vol_wrap_ctx + * + * Purpose: Sets the VOL object wrapping context for an operation. + * + * Return: Non-negative on success / Negative on failure + * + * Programmer: Quincey Koziol + * October 14, 2018 + * + *------------------------------------------------------------------------- + */ +herr_t +H5CX_set_vol_wrap_ctx(void *vol_wrap_ctx) +{ + H5CX_node_t **head = H5CX_get_my_context(); /* Get the pointer to the head of the API context, for this thread */ + herr_t ret_value = SUCCEED; /* Return value */ + + FUNC_ENTER_NOAPI(FAIL) + + /* Sanity check */ + HDassert(head && *head); + + /* Set the API context value */ + (*head)->ctx.vol_wrap_ctx = vol_wrap_ctx; + + /* Mark the value as valid */ + (*head)->ctx.vol_wrap_ctx_valid = TRUE; + +done: + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5CX_set_vol_wrap_ctx() */ + + +/*------------------------------------------------------------------------- * Function: H5CX_get_dxpl * * Purpose: Retrieves the DXPL ID for the current API call context. @@ -970,6 +1008,42 @@ H5CX_get_lapl(void) /*------------------------------------------------------------------------- + * Function: H5CX_get_vol_wrap_ctx + * + * Purpose: Retrieves the VOL object wrapping context for an operation. + * + * Return: Non-negative on success / Negative on failure + * + * Programmer: Quincey Koziol + * October 14, 2018 + * + *------------------------------------------------------------------------- + */ +herr_t +H5CX_get_vol_wrap_ctx(void **vol_wrap_ctx) +{ + H5CX_node_t **head = H5CX_get_my_context(); /* Get the pointer to the head of the API context, for this thread */ + herr_t ret_value = SUCCEED; /* Return value */ + + FUNC_ENTER_NOAPI(FAIL) + + /* Sanity check */ + HDassert(vol_wrap_ctx); + HDassert(head && *head); + + /* Check for value that was set */ + if((*head)->ctx.vol_wrap_ctx_valid) + /* Get the value */ + *vol_wrap_ctx = (*head)->ctx.vol_wrap_ctx; + else + *vol_wrap_ctx = NULL; + +done: + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5CX_get_vol_wrap_ctx() */ + + +/*------------------------------------------------------------------------- * Function: H5CX_get_tag * * Purpose: Retrieves the object tag for the current API call context. @@ -2501,7 +2575,9 @@ H5CX__pop_common(void) ret_value = (*head); (*head) = (*head)->next; +#ifdef H5_HAVE_PARALLEL done: +#endif /* H5_HAVE_PARALLEL */ FUNC_LEAVE_NOAPI(ret_value) } /* end H5CX__pop_common() */ diff --git a/src/H5CXprivate.h b/src/H5CXprivate.h index 44a4067..57ca5cd 100644 --- a/src/H5CXprivate.h +++ b/src/H5CXprivate.h @@ -63,10 +63,12 @@ H5_DLL void H5CX_set_lapl(hid_t lapl_id); H5_DLL herr_t H5CX_set_apl(hid_t *acspl_id, const H5P_libclass_t *libclass, hid_t loc_id, hbool_t is_collective); H5_DLL herr_t H5CX_set_loc(hid_t loc_id); +H5_DLL herr_t H5CX_set_vol_wrap_ctx(void *wrap_ctx); /* "Getter" routines for API context info */ H5_DLL hid_t H5CX_get_dxpl(void); H5_DLL hid_t H5CX_get_lapl(void); +H5_DLL herr_t H5CX_get_vol_wrap_ctx(void **wrap_ctx); H5_DLL haddr_t H5CX_get_tag(void); H5_DLL H5AC_ring_t H5CX_get_ring(void); #ifdef H5_HAVE_PARALLEL diff --git a/src/H5Cquery.c b/src/H5Cquery.c index 6c927b0..e4f3133 100644 --- a/src/H5Cquery.c +++ b/src/H5Cquery.c @@ -472,11 +472,11 @@ H5C_get_mdc_image_info(H5C_t * cache_ptr, haddr_t *image_addr, hsize_t *image_le if((cache_ptr == NULL) || (cache_ptr->magic != H5C__H5C_T_MAGIC)) HGOTO_ERROR(H5E_CACHE, H5E_BADVALUE, FAIL, "bad cache_ptr on entry") - if(image_addr == NULL || image_len == NULL) - HGOTO_ERROR(H5E_CACHE, H5E_BADVALUE, FAIL, "bad image_addr or image_len on entry") - *image_addr = cache_ptr->image_addr; - *image_len = cache_ptr->image_len; + if(image_addr) + *image_addr = cache_ptr->image_addr; + if(image_len) + *image_len = cache_ptr->image_len; done: FUNC_LEAVE_NOAPI(ret_value) @@ -29,6 +29,8 @@ #include "H5Iprivate.h" /* IDs */ #include "H5VLprivate.h" /* Virtual Object Layer */ +#include "H5VLnative_private.h" /* Native VOL connector */ + /****************/ /* Local Macros */ @@ -158,17 +160,16 @@ H5Dcreate2(hid_t loc_id, const char *name, hid_t type_id, hid_t space_id, loc_params.obj_type = H5I_get_type(loc_id); /* Create the dataset */ - if(NULL == (dset = H5VL_dataset_create(vol_obj->data, loc_params, vol_obj->driver->cls, - name, dcpl_id, dapl_id, H5P_DATASET_XFER_DEFAULT, H5_REQUEST_NULL))) + if(NULL == (dset = H5VL_dataset_create(vol_obj, &loc_params, name, dcpl_id, dapl_id, H5P_DATASET_XFER_DEFAULT, H5_REQUEST_NULL))) HGOTO_ERROR(H5E_DATASET, H5E_CANTINIT, H5I_INVALID_HID, "unable to create dataset") /* Get an atom for the dataset */ - if((ret_value = H5VL_register(H5I_DATASET, dset, vol_obj->driver, TRUE)) < 0) - HGOTO_ERROR(H5E_ATOM, H5E_CANTREGISTER, H5I_INVALID_HID, "unable to atomize dataset handle") + if((ret_value = H5VL_register(H5I_DATASET, dset, vol_obj->connector, TRUE)) < 0) + HGOTO_ERROR(H5E_DATASET, H5E_CANTREGISTER, H5I_INVALID_HID, "unable to atomize dataset handle") done: if(H5I_INVALID_HID == ret_value) - if(dset && H5VL_dataset_close(dset, vol_obj->driver->cls, H5P_DATASET_XFER_DEFAULT, H5_REQUEST_NULL) < 0) + if(dset && H5VL_dataset_close(vol_obj, H5P_DATASET_XFER_DEFAULT, H5_REQUEST_NULL) < 0) HDONE_ERROR(H5E_DATASET, H5E_CLOSEERROR, H5I_INVALID_HID, "unable to release dataset") FUNC_LEAVE_API(ret_value) @@ -211,7 +212,7 @@ hid_t H5Dcreate_anon(hid_t loc_id, hid_t type_id, hid_t space_id, hid_t dcpl_id, hid_t dapl_id) { - void *dset = NULL; /* dset token from VOL plugin */ + void *dset = NULL; /* dset token from VOL connector */ H5VL_object_t *vol_obj = NULL; /* object token of loc_id */ H5VL_loc_params_t loc_params; H5P_genplist_t *plist; /* Property list pointer */ @@ -250,19 +251,17 @@ H5Dcreate_anon(hid_t loc_id, hid_t type_id, hid_t space_id, hid_t dcpl_id, loc_params.obj_type = H5I_get_type(loc_id); /* Create the dataset */ - if(NULL == (dset = H5VL_dataset_create(vol_obj->data, loc_params, vol_obj->driver->cls, - NULL, dcpl_id, dapl_id, - H5P_DATASET_XFER_DEFAULT, H5_REQUEST_NULL))) + if(NULL == (dset = H5VL_dataset_create(vol_obj, &loc_params, NULL, dcpl_id, dapl_id, H5P_DATASET_XFER_DEFAULT, H5_REQUEST_NULL))) HGOTO_ERROR(H5E_DATASET, H5E_CANTINIT, H5I_INVALID_HID, "unable to create dataset") /* Get an atom for the dataset */ - if((ret_value = H5VL_register(H5I_DATASET, dset, vol_obj->driver, TRUE)) < 0) - HGOTO_ERROR(H5E_ATOM, H5E_CANTREGISTER, H5I_INVALID_HID, "unable to register dataset") + if((ret_value = H5VL_register(H5I_DATASET, dset, vol_obj->connector, TRUE)) < 0) + HGOTO_ERROR(H5E_DATASET, H5E_CANTREGISTER, H5I_INVALID_HID, "unable to register dataset") done: /* Cleanup on failure */ if(H5I_INVALID_HID == ret_value) - if(dset && H5VL_dataset_close (dset, vol_obj->driver->cls, H5P_DATASET_XFER_DEFAULT, H5_REQUEST_NULL) < 0) + if(dset && H5VL_dataset_close(vol_obj, H5P_DATASET_XFER_DEFAULT, H5_REQUEST_NULL) < 0) HDONE_ERROR(H5E_DATASET, H5E_CLOSEERROR, H5I_INVALID_HID, "unable to release dataset") FUNC_LEAVE_API(ret_value) @@ -287,7 +286,7 @@ done: hid_t H5Dopen2(hid_t loc_id, const char *name, hid_t dapl_id) { - void *dset = NULL; /* dset token from VOL plugin */ + void *dset = NULL; /* dset token from VOL connector */ H5VL_object_t *vol_obj = NULL; /* object token of loc_id */ H5VL_loc_params_t loc_params; hid_t ret_value = H5I_INVALID_HID; /* Return value */ @@ -314,18 +313,18 @@ H5Dopen2(hid_t loc_id, const char *name, hid_t dapl_id) loc_params.obj_type = H5I_get_type(loc_id); /* Open the dataset */ - if(NULL == (dset = H5VL_dataset_open(vol_obj->data, loc_params, vol_obj->driver->cls, name, - dapl_id, H5P_DATASET_XFER_DEFAULT, H5_REQUEST_NULL))) + if(NULL == (dset = H5VL_dataset_open(vol_obj, &loc_params, name, dapl_id, H5P_DATASET_XFER_DEFAULT, H5_REQUEST_NULL))) HGOTO_ERROR(H5E_DATASET, H5E_CANTOPENOBJ, H5I_INVALID_HID, "unable to open dataset") /* Register an atom for the dataset */ - if((ret_value = H5VL_register(H5I_DATASET, dset, vol_obj->driver, TRUE)) < 0) - HGOTO_ERROR(H5E_ATOM, H5E_CANTREGISTER, H5I_INVALID_HID, "can't register dataset atom") + if((ret_value = H5VL_register(H5I_DATASET, dset, vol_obj->connector, TRUE)) < 0) + HGOTO_ERROR(H5E_DATASET, H5E_CANTREGISTER, H5I_INVALID_HID, "can't register dataset atom") done: if(H5I_INVALID_HID == ret_value) - if(dset && H5VL_dataset_close(dset, vol_obj->driver->cls, H5P_DATASET_XFER_DEFAULT, H5_REQUEST_NULL) < 0) + if(dset && H5VL_dataset_close(vol_obj, H5P_DATASET_XFER_DEFAULT, H5_REQUEST_NULL) < 0) HDONE_ERROR(H5E_DATASET, H5E_CLOSEERROR, H5I_INVALID_HID, "unable to release dataset") + FUNC_LEAVE_API(ret_value) } /* end H5Dopen2() */ @@ -391,8 +390,7 @@ H5Dget_space(hid_t dset_id) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, H5I_INVALID_HID, "invalid dataset identifier") /* Get the dataspace */ - if(H5VL_dataset_get(vol_obj->data, vol_obj->driver->cls, H5VL_DATASET_GET_SPACE, - H5P_DATASET_XFER_DEFAULT, H5_REQUEST_NULL, &ret_value) < 0) + if(H5VL_dataset_get(vol_obj, H5VL_DATASET_GET_SPACE, H5P_DATASET_XFER_DEFAULT, H5_REQUEST_NULL, &ret_value) < 0) HGOTO_ERROR(H5E_DATASET, H5E_CANTGET, H5I_INVALID_HID, "unable to get dataspace") done: @@ -423,8 +421,7 @@ H5Dget_space_status(hid_t dset_id, H5D_space_status_t *allocation) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "invalid dataset identifier") /* Get dataspace status */ - if((ret_value = H5VL_dataset_get(vol_obj->data, vol_obj->driver->cls, H5VL_DATASET_GET_SPACE_STATUS, - H5P_DATASET_XFER_DEFAULT, H5_REQUEST_NULL, allocation)) < 0) + if((ret_value = H5VL_dataset_get(vol_obj, H5VL_DATASET_GET_SPACE_STATUS, H5P_DATASET_XFER_DEFAULT, H5_REQUEST_NULL, allocation)) < 0) HGOTO_ERROR(H5E_DATASET, H5E_CANTGET, FAIL, "unable to get space status") done: @@ -459,8 +456,7 @@ H5Dget_type(hid_t dset_id) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, H5I_INVALID_HID, "invalid dataset identifier") /* get the datatype */ - if(H5VL_dataset_get(vol_obj->data, vol_obj->driver->cls, H5VL_DATASET_GET_TYPE, - H5P_DATASET_XFER_DEFAULT, H5_REQUEST_NULL, &ret_value) < 0) + if(H5VL_dataset_get(vol_obj, H5VL_DATASET_GET_TYPE, H5P_DATASET_XFER_DEFAULT, H5_REQUEST_NULL, &ret_value) < 0) HGOTO_ERROR(H5E_DATASET, H5E_CANTGET, H5I_INVALID_HID, "unable to get datatype") done: @@ -498,8 +494,7 @@ H5Dget_create_plist(hid_t dset_id) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, H5I_INVALID_HID, "invalid dataset identifier") /* Get the dataset creation property list */ - if(H5VL_dataset_get(vol_obj->data, vol_obj->driver->cls, H5VL_DATASET_GET_DCPL, - H5P_DATASET_XFER_DEFAULT, H5_REQUEST_NULL, &ret_value) < 0) + if(H5VL_dataset_get(vol_obj, H5VL_DATASET_GET_DCPL, H5P_DATASET_XFER_DEFAULT, H5_REQUEST_NULL, &ret_value) < 0) HGOTO_ERROR(H5E_DATASET, H5E_CANTGET, H5I_INVALID_HID, "unable to get dataset creation properties") done: @@ -554,8 +549,7 @@ H5Dget_access_plist(hid_t dset_id) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, H5I_INVALID_HID, "invalid dataset identifier") /* Get the dataset access property list */ - if(H5VL_dataset_get(vol_obj->data, vol_obj->driver->cls, H5VL_DATASET_GET_DAPL, - H5P_DATASET_XFER_DEFAULT, H5_REQUEST_NULL, &ret_value) < 0) + if(H5VL_dataset_get(vol_obj, H5VL_DATASET_GET_DAPL, H5P_DATASET_XFER_DEFAULT, H5_REQUEST_NULL, &ret_value) < 0) HGOTO_ERROR(H5E_DATASET, H5E_CANTGET, H5I_INVALID_HID, "unable to get dataset access properties") done: @@ -592,8 +586,7 @@ H5Dget_storage_size(hid_t dset_id) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, 0, "invalid dataset identifier") /* Get the storage size */ - if(H5VL_dataset_get(vol_obj->data, vol_obj->driver->cls, H5VL_DATASET_GET_STORAGE_SIZE, - H5P_DATASET_XFER_DEFAULT, H5_REQUEST_NULL, &ret_value) < 0) + if(H5VL_dataset_get(vol_obj, H5VL_DATASET_GET_STORAGE_SIZE, H5P_DATASET_XFER_DEFAULT, H5_REQUEST_NULL, &ret_value) < 0) HGOTO_ERROR(H5E_DATASET, H5E_CANTGET, 0, "unable to get storage size") done: @@ -626,8 +619,7 @@ H5Dget_offset(hid_t dset_id) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, HADDR_UNDEF, "invalid dataset identifier") /* Get the offset */ - if(H5VL_dataset_get(vol_obj->data, vol_obj->driver->cls, H5VL_DATASET_GET_OFFSET, - H5P_DATASET_XFER_DEFAULT, H5_REQUEST_NULL, &ret_value) < 0) + if(H5VL_dataset_get(vol_obj, H5VL_DATASET_GET_OFFSET, H5P_DATASET_XFER_DEFAULT, H5_REQUEST_NULL, &ret_value) < 0) HGOTO_ERROR(H5E_DATASET, H5E_CANTGET, HADDR_UNDEF, "unable to get offset") done: @@ -840,8 +832,7 @@ H5Dvlen_get_buf_size(hid_t dataset_id, hid_t type_id, hid_t space_id, vlen_bufsize.mspace_id = H5I_INVALID_HID; /* Get a copy of the dataset's dataspace */ - if(H5VL_dataset_get(vol_obj->data, vol_obj->driver->cls, H5VL_DATASET_GET_SPACE, - H5P_DATASET_XFER_DEFAULT, H5_REQUEST_NULL, &vlen_bufsize.fspace_id) < 0) + if(H5VL_dataset_get(vol_obj, H5VL_DATASET_GET_SPACE, H5P_DATASET_XFER_DEFAULT, H5_REQUEST_NULL, &vlen_bufsize.fspace_id) < 0) HGOTO_ERROR(H5E_DATASET, H5E_CANTCOPY, FAIL, "can't copy dataspace") /* Create a scalar for the memory dataspace */ @@ -922,8 +913,7 @@ H5Dset_extent(hid_t dset_id, const hsize_t size[]) HGOTO_ERROR(H5E_DATASET, H5E_CANTSET, FAIL, "can't set collective metadata read info") /* Set the extent */ - if ((ret_value = H5VL_dataset_specific(vol_obj->data, vol_obj->driver->cls, H5VL_DATASET_SET_EXTENT, - H5P_DATASET_XFER_DEFAULT, H5_REQUEST_NULL, size)) < 0) + if ((ret_value = H5VL_dataset_specific(vol_obj, H5VL_DATASET_SET_EXTENT, H5P_DATASET_XFER_DEFAULT, H5_REQUEST_NULL, size)) < 0) HGOTO_ERROR(H5E_DATASET, H5E_CANTSET, FAIL, "unable to set dataset extent") done: @@ -961,8 +951,7 @@ H5Dflush(hid_t dset_id) * XXX: Note that we need to pass the ID to the VOL since the H5F_flush_cb_t * callback needs it and that's in the public API. */ - if((ret_value = H5VL_dataset_specific(vol_obj->data, vol_obj->driver->cls, H5VL_DATASET_FLUSH, - H5P_DATASET_XFER_DEFAULT, H5_REQUEST_NULL, dset_id)) < 0) + if((ret_value = H5VL_dataset_specific(vol_obj, H5VL_DATASET_FLUSH, H5P_DATASET_XFER_DEFAULT, H5_REQUEST_NULL, dset_id)) < 0) HGOTO_ERROR(H5E_DATASET, H5E_CANTFLUSH, FAIL, "unable to flush dataset") done: @@ -997,8 +986,7 @@ H5Drefresh(hid_t dset_id) HGOTO_ERROR(H5E_DATASET, H5E_CANTSET, FAIL, "can't set collective metadata read info") /* Refresh the dataset object */ - if((ret_value = H5VL_dataset_specific(vol_obj->data, vol_obj->driver->cls, H5VL_DATASET_REFRESH, - H5P_DATASET_XFER_DEFAULT, H5_REQUEST_NULL, dset_id)) < 0) + if((ret_value = H5VL_dataset_specific(vol_obj, H5VL_DATASET_REFRESH, H5P_DATASET_XFER_DEFAULT, H5_REQUEST_NULL, dset_id)) < 0) HGOTO_ERROR(H5E_DATASET, H5E_CANTLOAD, FAIL, "unable to refresh dataset") done: @@ -1041,8 +1029,7 @@ H5Dformat_convert(hid_t dset_id) HGOTO_ERROR(H5E_DATASET, H5E_CANTSET, FAIL, "can't set collective metadata read info") /* Convert the dataset */ - if(H5VL_dataset_optional(vol_obj->data, vol_obj->driver->cls, H5P_DATASET_XFER_DEFAULT, - H5_REQUEST_NULL, H5VL_DATASET_FORMAT_CONVERT) < 0) + if(H5VL_dataset_optional(vol_obj, H5P_DATASET_XFER_DEFAULT, H5_REQUEST_NULL, H5VL_NATIVE_DATASET_FORMAT_CONVERT) < 0) HGOTO_ERROR(H5E_DATASET, H5E_INTERNAL, FAIL, "can't convert dataset format") done: @@ -1078,8 +1065,7 @@ H5Dget_chunk_index_type(hid_t dset_id, H5D_chunk_index_t *idx_type) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "idx_type parameter cannot be NULL") /* Get the chunk indexing type */ - if(H5VL_dataset_optional(vol_obj->data, vol_obj->driver->cls, H5P_DATASET_XFER_DEFAULT, - H5_REQUEST_NULL, H5VL_DATASET_GET_CHUNK_INDEX_TYPE, idx_type) < 0) + if(H5VL_dataset_optional(vol_obj, H5P_DATASET_XFER_DEFAULT, H5_REQUEST_NULL, H5VL_NATIVE_DATASET_GET_CHUNK_INDEX_TYPE, idx_type) < 0) HGOTO_ERROR(H5E_DATASET, H5E_CANTGET, FAIL, "can't get chunk index type") done: @@ -1120,8 +1106,7 @@ H5Dget_chunk_storage_size(hid_t dset_id, const hsize_t *offset, hsize_t *chunk_n HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "chunk_nbytes parameter cannot be NULL") /* Get the dataset creation property list */ - if(H5VL_dataset_optional(vol_obj->data, vol_obj->driver->cls, H5P_DATASET_XFER_DEFAULT, - H5_REQUEST_NULL, H5VL_DATASET_GET_CHUNK_STORAGE_SIZE, offset, chunk_nbytes) < 0) + if(H5VL_dataset_optional(vol_obj, H5P_DATASET_XFER_DEFAULT, H5_REQUEST_NULL, H5VL_NATIVE_DATASET_GET_CHUNK_STORAGE_SIZE, offset, chunk_nbytes) < 0) HGOTO_ERROR(H5E_DATASET, H5E_CANTGET, FAIL, "can't get storage size of chunk") done: diff --git a/src/H5Ddeprec.c b/src/H5Ddeprec.c index 58238bc..76827b4 100644 --- a/src/H5Ddeprec.c +++ b/src/H5Ddeprec.c @@ -40,7 +40,7 @@ #include "H5Dpkg.h" /* Datasets */ #include "H5Eprivate.h" /* Error handling */ #include "H5Iprivate.h" /* IDs */ -#include "H5VLprivate.h" /* VOL plugins */ +#include "H5VLprivate.h" /* Virtual Object Layer */ /****************/ @@ -113,7 +113,7 @@ hid_t H5Dcreate1(hid_t loc_id, const char *name, hid_t type_id, hid_t space_id, hid_t dcpl_id) { - void *dset = NULL; /* dset token from VOL plugin */ + void *dset = NULL; /* dset token from VOL connector */ H5VL_object_t *vol_obj = NULL; /* object token of loc_id */ H5VL_loc_params_t loc_params; H5P_genplist_t *plist; /* Property list pointer */ @@ -161,17 +161,16 @@ H5Dcreate1(hid_t loc_id, const char *name, hid_t type_id, hid_t space_id, HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, H5I_INVALID_HID, "invalid location identifier") /* Create the dataset through the VOL */ - if(NULL == (dset = H5VL_dataset_create(vol_obj->data, loc_params, vol_obj->driver->cls, name, dcpl_id, - H5P_DATASET_ACCESS_DEFAULT, H5P_DATASET_XFER_DEFAULT, H5_REQUEST_NULL))) + if(NULL == (dset = H5VL_dataset_create(vol_obj, &loc_params, name, dcpl_id, H5P_DATASET_ACCESS_DEFAULT, H5P_DATASET_XFER_DEFAULT, H5_REQUEST_NULL))) HGOTO_ERROR(H5E_DATASET, H5E_CANTINIT, H5I_INVALID_HID, "unable to create dataset") /* Get an atom for the dataset */ - if((ret_value = H5VL_register(H5I_DATASET, dset, vol_obj->driver, TRUE)) < 0) - HGOTO_ERROR(H5E_ATOM, H5E_CANTREGISTER, H5I_INVALID_HID, "unable to register dataset") + if((ret_value = H5VL_register(H5I_DATASET, dset, vol_obj->connector, TRUE)) < 0) + HGOTO_ERROR(H5E_DATASET, H5E_CANTREGISTER, H5I_INVALID_HID, "unable to register dataset") done: if (H5I_INVALID_HID == ret_value) - if(dset && H5VL_dataset_close(dset, vol_obj->driver->cls, H5P_DATASET_XFER_DEFAULT, H5_REQUEST_NULL) < 0) + if(dset && H5VL_dataset_close(vol_obj, H5P_DATASET_XFER_DEFAULT, H5_REQUEST_NULL) < 0) HDONE_ERROR(H5E_DATASET, H5E_CLOSEERROR, H5I_INVALID_HID, "unable to release dataset") FUNC_LEAVE_API(ret_value) @@ -198,7 +197,7 @@ done: hid_t H5Dopen1(hid_t loc_id, const char *name) { - void *dset = NULL; /* dset token from VOL plugin */ + void *dset = NULL; /* dset token from VOL connector */ H5VL_object_t *vol_obj = NULL; /* object token of loc_id */ H5VL_loc_params_t loc_params; hid_t ret_value = H5I_INVALID_HID; /* Return value */ @@ -221,17 +220,16 @@ H5Dopen1(hid_t loc_id, const char *name) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, H5I_INVALID_HID, "invalid location identifier") /* Open the dataset */ - if(NULL == (dset = H5VL_dataset_open(vol_obj->data, loc_params, vol_obj->driver->cls, name, - H5P_DATASET_ACCESS_DEFAULT, H5P_DATASET_XFER_DEFAULT, H5_REQUEST_NULL))) + if(NULL == (dset = H5VL_dataset_open(vol_obj, &loc_params, name, H5P_DATASET_ACCESS_DEFAULT, H5P_DATASET_XFER_DEFAULT, H5_REQUEST_NULL))) HGOTO_ERROR(H5E_DATASET, H5E_CANTOPENOBJ, H5I_INVALID_HID, "unable to open dataset") /* Get an atom for the dataset */ - if((ret_value = H5VL_register(H5I_DATASET, dset, vol_obj->driver, TRUE)) < 0) - HGOTO_ERROR(H5E_ATOM, H5E_CANTREGISTER, H5I_INVALID_HID, "can't register dataset atom") + if((ret_value = H5VL_register(H5I_DATASET, dset, vol_obj->connector, TRUE)) < 0) + HGOTO_ERROR(H5E_DATASET, H5E_CANTREGISTER, H5I_INVALID_HID, "can't register dataset atom") done: if(H5I_INVALID_HID == ret_value) - if(dset && H5VL_dataset_close(dset, vol_obj->driver->cls, H5P_DATASET_XFER_DEFAULT, H5_REQUEST_NULL) < 0) + if(dset && H5VL_dataset_close(vol_obj, H5P_DATASET_XFER_DEFAULT, H5_REQUEST_NULL) < 0) HDONE_ERROR(H5E_DATASET, H5E_CLOSEERROR, H5I_INVALID_HID, "unable to release dataset") FUNC_LEAVE_API(ret_value) @@ -275,8 +273,7 @@ H5Dextend(hid_t dset_id, const hsize_t size[]) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "no size specified") /* Get the dataspace pointer for the dataset */ - if(H5VL_dataset_get(vol_obj->data, vol_obj->driver->cls, H5VL_DATASET_GET_SPACE, - H5P_DATASET_XFER_DEFAULT, H5_REQUEST_NULL, &sid) < 0) + if(H5VL_dataset_get(vol_obj, H5VL_DATASET_GET_SPACE, H5P_DATASET_XFER_DEFAULT, H5_REQUEST_NULL, &sid) < 0) HGOTO_ERROR(H5E_DATASET, H5E_CANTGET, FAIL, "unable to get dataspace") if(H5I_INVALID_HID == sid) HGOTO_ERROR(H5E_DATASET, H5E_CANTGET, FAIL, "received an invalid dataspace from the dataset") @@ -306,8 +303,7 @@ H5Dextend(hid_t dset_id, const hsize_t size[]) HGOTO_ERROR(H5E_DATASET, H5E_CANTSET, FAIL, "can't set collective metadata read info") /* Increase size */ - if ((ret_value = H5VL_dataset_specific(vol_obj->data, vol_obj->driver->cls, H5VL_DATASET_SET_EXTENT, - H5P_DATASET_XFER_DEFAULT, H5_REQUEST_NULL, dset_dims)) < 0) + if ((ret_value = H5VL_dataset_specific(vol_obj, H5VL_DATASET_SET_EXTENT, H5P_DATASET_XFER_DEFAULT, H5_REQUEST_NULL, dset_dims)) < 0) HGOTO_ERROR(H5E_DATASET, H5E_CANTSET, FAIL, "unable to extend dataset") done: diff --git a/src/H5Dint.c b/src/H5Dint.c index 253d005..6bb3343 100644 --- a/src/H5Dint.c +++ b/src/H5Dint.c @@ -21,17 +21,16 @@ /***********/ /* Headers */ /***********/ -#include "H5private.h" /* Generic Functions */ -#include "H5CXprivate.h" /* API Contexts */ -#include "H5Dpkg.h" /* Datasets */ -#include "H5Eprivate.h" /* Error handling */ -#include "H5FLprivate.h" /* Free Lists */ -#include "H5FOprivate.h" /* File objects */ -#include "H5Iprivate.h" /* IDs */ -#include "H5Lprivate.h" /* Links */ -#include "H5MMprivate.h" /* Memory management */ -#include "H5VLprivate.h" /* Virtual Object Layer */ -#include "H5VLnative_private.h" /* Native VOL driver */ +#include "H5private.h" /* Generic Functions */ +#include "H5CXprivate.h" /* API Contexts */ +#include "H5Dpkg.h" /* Datasets */ +#include "H5Eprivate.h" /* Error handling */ +#include "H5FLprivate.h" /* Free Lists */ +#include "H5FOprivate.h" /* File objects */ +#include "H5Iprivate.h" /* IDs */ +#include "H5Lprivate.h" /* Links */ +#include "H5MMprivate.h" /* Memory management */ +#include "H5VLprivate.h" /* Virtual Object Layer */ /****************/ @@ -301,7 +300,7 @@ H5D__close_cb(H5VL_object_t *dset_vol_obj) HDassert(dset_vol_obj); /* Close the dataset */ - if(H5VL_dataset_close(dset_vol_obj->data, dset_vol_obj->driver->cls, H5P_DATASET_XFER_DEFAULT, H5_REQUEST_NULL) < 0) + if(H5VL_dataset_close(dset_vol_obj, H5P_DATASET_XFER_DEFAULT, H5_REQUEST_NULL) < 0) HGOTO_ERROR(H5E_DATASET, H5E_CLOSEERROR, FAIL, "unable to close dataset"); done: @@ -975,7 +974,7 @@ H5D__create(H5F_t *file, hid_t type_id, const H5S_t *space, hid_t dcpl_id, /* Get the dataset's datatype */ if(NULL == (dt = (const H5T_t *)H5I_object(type_id))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, NULL, "not a datatype") - /* If this is a named datatype, get the pointer via the VOL driver */ + /* If this is a named datatype, get the pointer via the VOL plugin */ type = (const H5T_t *)H5T_get_actual_type(dt); /* Check if the datatype is "sensible" for use in a dataset */ @@ -1962,12 +1961,12 @@ H5D_oloc(H5D_t *dataset) *------------------------------------------------------------------------- */ H5G_name_t * -H5D_nameof(H5D_t *dataset) +H5D_nameof(const H5D_t *dataset) { /* Use FUNC_ENTER_NOAPI_NOINIT_NOERR here to avoid performance issues */ FUNC_ENTER_NOAPI_NOINIT_NOERR - FUNC_LEAVE_NOAPI(dataset ? &(dataset->path) : (H5G_name_t *)NULL) + FUNC_LEAVE_NOAPI(dataset ? (H5G_name_t *)&(dataset->path) : (H5G_name_t *)NULL) } /* end H5D_nameof() */ @@ -2460,10 +2459,7 @@ H5D__vlen_get_buf_size(void H5_ATTR_UNUSED *elem, hid_t type_id, HGOTO_ERROR(H5E_DATASET, H5E_CANTCREATE, FAIL, "can't select point") /* Read in the point (with the custom VL memory allocator) */ - if(H5VL_dataset_read(vol_obj->data, vol_obj->driver->cls, - type_id, vlen_bufsize->mspace_id, - vlen_bufsize->fspace_id, H5P_DATASET_XFER_DEFAULT, - vlen_bufsize->fl_tbuf, H5_REQUEST_NULL) < 0) + if(H5VL_dataset_read(vol_obj, type_id, vlen_bufsize->mspace_id, vlen_bufsize->fspace_id, H5P_DATASET_XFER_DEFAULT, vlen_bufsize->fl_tbuf, H5_REQUEST_NULL) < 0) HGOTO_ERROR(H5E_DATASET, H5E_READERROR, FAIL, "can't read point") done: @@ -3402,13 +3398,12 @@ H5D__get_type(const H5D_t *dset) * two-level IDs, where the VOL object is a copy of the * returned datatype. */ - if((ret_value = H5VL_native_register(H5I_DATATYPE, dt, TRUE)) < 0) + if((ret_value = H5VL_wrap_register(H5I_DATATYPE, dt, TRUE)) < 0) HGOTO_ERROR(H5E_ATOM, H5E_CANTREGISTER, FAIL, "unable to register datatype") - } - else { + } /* end if */ + else if((ret_value = H5I_register(H5I_DATATYPE, dt, TRUE)) < 0) HGOTO_ERROR(H5E_ATOM, H5E_CANTREGISTER, FAIL, "unable to register datatype") - } done: if(ret_value < 0) diff --git a/src/H5Dio.c b/src/H5Dio.c index b6d4f1b..fe85d23 100644 --- a/src/H5Dio.c +++ b/src/H5Dio.c @@ -30,6 +30,8 @@ #include "H5MMprivate.h" /* Memory management */ #include "H5Sprivate.h" /* Dataspace */ +#include "H5VLnative_private.h" /* Native VOL connector */ + #ifdef H5_HAVE_PARALLEL /* Remove this if H5R_DATASET_REGION is no longer used in this file */ #include "H5Rpublic.h" @@ -191,8 +193,7 @@ H5Dread(hid_t dset_id, hid_t mem_type_id, hid_t mem_space_id, H5CX_set_dxpl(dxpl_id); /* Read the data */ - if ((ret_value = H5VL_dataset_read(vol_obj->data, vol_obj->driver->cls, mem_type_id, mem_space_id, - file_space_id, dxpl_id, buf, H5_REQUEST_NULL)) < 0) + if ((ret_value = H5VL_dataset_read(vol_obj, mem_type_id, mem_space_id, file_space_id, dxpl_id, buf, H5_REQUEST_NULL)) < 0) HGOTO_ERROR(H5E_DATASET, H5E_READERROR, FAIL, "can't read data") done: @@ -243,8 +244,7 @@ H5Dread_chunk(hid_t dset_id, hid_t dxpl_id, const hsize_t *offset, uint32_t *fil H5CX_set_dxpl(dxpl_id); /* Read the raw chunk */ - if (H5VL_dataset_optional(vol_obj->data, vol_obj->driver->cls, dxpl_id, - H5_REQUEST_NULL, H5VL_DATASET_CHUNK_READ, offset, filters, buf) < 0) + if(H5VL_dataset_optional(vol_obj, dxpl_id, H5_REQUEST_NULL, H5VL_NATIVE_DATASET_CHUNK_READ, offset, filters, buf) < 0) HGOTO_ERROR(H5E_DATASET, H5E_READERROR, FAIL, "can't read unprocessed chunk data") done: @@ -315,8 +315,7 @@ H5Dwrite(hid_t dset_id, hid_t mem_type_id, hid_t mem_space_id, H5CX_set_dxpl(dxpl_id); /* Write the data */ - if ((ret_value = H5VL_dataset_write(vol_obj->data, vol_obj->driver->cls, mem_type_id, mem_space_id, - file_space_id, dxpl_id, buf, H5_REQUEST_NULL)) < 0) + if ((ret_value = H5VL_dataset_write(vol_obj, mem_type_id, mem_space_id, file_space_id, dxpl_id, buf, H5_REQUEST_NULL)) < 0) HGOTO_ERROR(H5E_DATASET, H5E_WRITEERROR, FAIL, "can't write data") done: @@ -373,8 +372,7 @@ H5Dwrite_chunk(hid_t dset_id, hid_t dxpl_id, uint32_t filters, const hsize_t *of H5CX_set_dxpl(dxpl_id); /* Write chunk */ - if (H5VL_dataset_optional(vol_obj->data, vol_obj->driver->cls, dxpl_id, - H5_REQUEST_NULL, H5VL_DATASET_CHUNK_WRITE, filters, offset, data_size_32, buf) < 0) + if(H5VL_dataset_optional(vol_obj, dxpl_id, H5_REQUEST_NULL, H5VL_NATIVE_DATASET_CHUNK_WRITE, filters, offset, data_size_32, buf) < 0) HGOTO_ERROR(H5E_DATASET, H5E_WRITEERROR, FAIL, "can't write unprocessed chunk data") done: diff --git a/src/H5Dpkg.h b/src/H5Dpkg.h index c84c245..2767aa1 100644 --- a/src/H5Dpkg.h +++ b/src/H5Dpkg.h @@ -110,15 +110,6 @@ typedef struct H5D_type_info_t { hbool_t bkg_buf_allocated; /* Whether the background buffer was allocated */ } H5D_type_info_t; -/* types for dataset optional VOL operations */ -typedef enum H5VL_dataset_optional_t { - H5VL_DATASET_FORMAT_CONVERT, /* H5Dformat_convert (internal) */ - H5VL_DATASET_GET_CHUNK_INDEX_TYPE, /* H5Dget_chunk_index_type */ - H5VL_DATASET_GET_CHUNK_STORAGE_SIZE, /* H5Dget_chunk_storage_size */ - H5VL_DATASET_CHUNK_READ, /* H5Dchunk_read */ - H5VL_DATASET_CHUNK_WRITE, /* H5Dchunk_write */ -} H5VL_dataset_optional_t; - /* Forward declaration of structs used below */ struct H5D_io_info_t; struct H5D_chunk_map_t; diff --git a/src/H5Dprivate.h b/src/H5Dprivate.h index cbee0de..4e9cda8 100644 --- a/src/H5Dprivate.h +++ b/src/H5Dprivate.h @@ -158,7 +158,7 @@ H5_DLL herr_t H5D_close(H5D_t *dataset); H5_DLL herr_t H5D_mult_refresh_close(hid_t dset_id); H5_DLL herr_t H5D_mult_refresh_reopen(H5D_t *dataset); H5_DLL H5O_loc_t *H5D_oloc(H5D_t *dataset); -H5_DLL H5G_name_t *H5D_nameof(H5D_t *dataset); +H5_DLL H5G_name_t *H5D_nameof(const H5D_t *dataset); H5_DLL H5T_t *H5D_typeof(const H5D_t *dset); H5_DLL herr_t H5D_flush_all(const H5F_t *f); H5_DLL hid_t H5D_get_create_plist(const H5D_t *dset); diff --git a/src/H5Dpublic.h b/src/H5Dpublic.h index a1ccda0..63f1a24 100644 --- a/src/H5Dpublic.h +++ b/src/H5Dpublic.h @@ -104,17 +104,6 @@ typedef enum H5D_vds_view_t { /* Callback for H5Pset_append_flush() in a dataset access property list */ typedef herr_t (*H5D_append_cb_t)(hid_t dataset_id, hsize_t *cur_dims, void *op_data); -/********************/ -/* Public Variables */ -/********************/ - -/*********************/ -/* Public Prototypes */ -/*********************/ -#ifdef __cplusplus -extern "C" { -#endif - /* Define the operator function pointer for H5Diterate() */ typedef herr_t (*H5D_operator_t)(void *elem, hid_t type_id, unsigned ndim, const hsize_t *point, void *operator_data); @@ -128,6 +117,18 @@ typedef herr_t (*H5D_scatter_func_t)(const void **src_buf/*out*/, typedef herr_t (*H5D_gather_func_t)(const void *dst_buf, size_t dst_buf_bytes_used, void *op_data); + +/********************/ +/* Public Variables */ +/********************/ + +/*********************/ +/* Public Prototypes */ +/*********************/ +#ifdef __cplusplus +extern "C" { +#endif + H5_DLL hid_t H5Dcreate2(hid_t loc_id, const char *name, hid_t type_id, hid_t space_id, hid_t lcpl_id, hid_t dcpl_id, hid_t dapl_id); H5_DLL hid_t H5Dcreate_anon(hid_t file_id, hid_t type_id, hid_t space_id, diff --git a/src/H5Dvirtual.c b/src/H5Dvirtual.c index c7c1eec..c0d49d8 100644 --- a/src/H5Dvirtual.c +++ b/src/H5Dvirtual.c @@ -58,7 +58,6 @@ #include "H5Oprivate.h" /* Object headers */ #include "H5Pprivate.h" /* Property Lists */ #include "H5Sprivate.h" /* Dataspaces */ -#include "H5VLnative_private.h" /* Native VOL driver */ #include "H5VLprivate.h" /* Virtual Object Layer */ /****************/ @@ -2963,7 +2962,6 @@ static herr_t H5D__virtual_refresh_source_dset(H5D_t **dset) { hid_t temp_id = H5I_INVALID_HID; /* Temporary dataset identifier */ - hid_t native_vol_id = H5I_INVALID_HID; /* ID for the native VOL driver */ H5VL_object_t *vol_obj = NULL; /* VOL object stored with the ID */ herr_t ret_value = SUCCEED; /* Return value */ @@ -2972,12 +2970,8 @@ H5D__virtual_refresh_source_dset(H5D_t **dset) /* Sanity check */ HDassert(dset && *dset); - /* Get the native VOL driver's ID */ - if((native_vol_id = H5VL_native_get_driver_id()) < 0) - HGOTO_ERROR(H5E_DATASET, H5E_CANTGET, FAIL, "can't get native VOL driver ID") - /* Get a temporary identifier for this source dataset */ - if((temp_id = H5VL_register_using_vol_id(H5I_DATASET, *dset, native_vol_id, FALSE)) < 0) + if((temp_id = H5VL_wrap_register(H5I_DATASET, *dset, FALSE)) < 0) HGOTO_ERROR(H5E_DATASET, H5E_CANTREGISTER, FAIL, "can't register (temporary) source dataset ID") /* Refresh source dataset */ @@ -2987,7 +2981,8 @@ H5D__virtual_refresh_source_dset(H5D_t **dset) /* Discard the identifier & replace the dataset */ if(NULL == (vol_obj = (H5VL_object_t *)H5I_remove(temp_id))) HGOTO_ERROR(H5E_DATASET, H5E_CANTREMOVE, FAIL, "can't unregister source dataset ID") - *dset = (H5D_t *)(vol_obj->data); + if(NULL == (*dset = (H5D_t *)H5VL_object_data(vol_obj))) + HGOTO_ERROR(H5E_DATASET, H5E_CANTGET, FAIL, "can't retrieve library object from VOL object") vol_obj->data = NULL; done: @@ -2995,7 +2990,7 @@ done: HDONE_ERROR(H5E_DATASET, H5E_CANTDEC, FAIL, "unable to free VOL object") FUNC_LEAVE_NOAPI(ret_value) -} /* end H5D__virtual_refresh_source_dsets() */ +} /* end H5D__virtual_refresh_source_dset() */ /*------------------------------------------------------------------------- diff --git a/src/H5ESpublic.h b/src/H5ESpublic.h index cb8eebf..e3b1b56 100644 --- a/src/H5ESpublic.h +++ b/src/H5ESpublic.h @@ -29,7 +29,7 @@ typedef enum H5ES_status_t { H5ES_STATUS_IN_PROGRESS, /* Operation has not yet completed */ H5ES_STATUS_SUCCEED, /* Operation has completed, successfully */ H5ES_STATUS_FAIL, /* Operation has completed, but failed */ - H5ES_STATUS_CANCEL /* Operation has not completed and has been cancelled */ + H5ES_STATUS_CANCELED /* Operation has not completed and was canceled */ } H5ES_status_t; @@ -38,15 +38,31 @@ #include "H5Tprivate.h" /* Datatypes */ #include "H5VLprivate.h" /* Virtual Object Layer */ +#include "H5VLnative_private.h" /* Native VOL connector */ + /****************/ /* Local Macros */ /****************/ + /******************/ /* Local Typedefs */ /******************/ +/* User data for traversal routine to get ID counts */ +typedef struct { + size_t obj_count; /* Number of objects counted so far */ + unsigned types; /* Types of objects to be counted */ +} H5F_trav_obj_cnt_t; + +/* User data for traversal routine to get ID lists */ +typedef struct { + size_t max_objs; /* Maximum # of IDs to record */ + hid_t *oid_list; /* Array of recorded IDs*/ + size_t obj_count; /* Number of objects counted so far */ +} H5F_trav_obj_ids_t; + /********************/ /* Package Typedefs */ @@ -199,12 +215,12 @@ H5F__close_cb(H5VL_object_t *file_vol_obj) HDassert(file_vol_obj); /* Close the file */ - if(H5VL_file_close(file_vol_obj->data, file_vol_obj->driver->cls, H5P_DATASET_XFER_DEFAULT, H5_REQUEST_NULL) < 0) - HGOTO_ERROR(H5E_FILE, H5E_CANTCLOSEFILE, FAIL, "unable to close file"); + if(H5VL_file_close(file_vol_obj, H5P_DATASET_XFER_DEFAULT, H5_REQUEST_NULL) < 0) + HGOTO_ERROR(H5E_FILE, H5E_CANTCLOSEFILE, FAIL, "unable to close file") /* Free the VOL object */ if(H5VL_free_object(file_vol_obj) < 0) - HGOTO_ERROR(H5E_FILE, H5E_CANTDEC, FAIL, "unable to free VOL object"); + HGOTO_ERROR(H5E_FILE, H5E_CANTDEC, FAIL, "unable to free VOL object") done: FUNC_LEAVE_NOAPI(ret_value) @@ -239,8 +255,7 @@ H5Fget_create_plist(hid_t file_id) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, H5I_INVALID_HID, "invalid file identifier") /* Retrieve the file creation property list */ - if(H5VL_file_get(vol_obj->data, vol_obj->driver->cls, H5VL_FILE_GET_FCPL, - H5P_DATASET_XFER_DEFAULT, H5_REQUEST_NULL, &ret_value) < 0) + if(H5VL_file_get(vol_obj, H5VL_FILE_GET_FCPL, H5P_DATASET_XFER_DEFAULT, H5_REQUEST_NULL, &ret_value) < 0) HGOTO_ERROR(H5E_PLIST, H5E_CANTCOPY, H5I_INVALID_HID, "unable to retrieve file creation properties") done: @@ -280,8 +295,7 @@ H5Fget_access_plist(hid_t file_id) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, H5I_INVALID_HID, "invalid file identifier") /* Retrieve the file's access property list */ - if(H5VL_file_get(vol_obj->data, vol_obj->driver->cls, H5VL_FILE_GET_FAPL, - H5P_DATASET_XFER_DEFAULT, H5_REQUEST_NULL, &ret_value) < 0) + if(H5VL_file_get(vol_obj, H5VL_FILE_GET_FAPL, H5P_DATASET_XFER_DEFAULT, H5_REQUEST_NULL, &ret_value) < 0) HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, H5I_INVALID_HID, "can't get file access property list") done: @@ -308,7 +322,7 @@ H5F__get_all_count_cb(void H5_ATTR_UNUSED *obj_ptr, hid_t H5_ATTR_UNUSED obj_id, FUNC_ENTER_STATIC_NOERR - *(udata->obj_count) = *(udata->obj_count) + 1; + udata->obj_count++; FUNC_LEAVE_NOAPI(ret_value) } /* H5F_get_all_count_cb */ @@ -350,42 +364,38 @@ H5Fget_obj_count(hid_t file_id, unsigned types) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, (-1), "not a file id") /* Get the count */ - if(H5VL_file_get(vol_obj->data, vol_obj->driver->cls, H5VL_FILE_GET_OBJ_COUNT, - H5P_DATASET_XFER_DEFAULT, H5_REQUEST_NULL, types, &ret_value) < 0) + if(H5VL_file_get(vol_obj, H5VL_FILE_GET_OBJ_COUNT, H5P_DATASET_XFER_DEFAULT, H5_REQUEST_NULL, types, &ret_value) < 0) HGOTO_ERROR(H5E_FILE, H5E_CANTGET, (-1), "unable to get object count in file(s)") } /* If we passed in the 'special' ID, get the count for everything open in the * library, iterating over all open files and getting the object count for each. - * - * XXX: Consider making this a helper function in H5I. */ else { H5F_trav_obj_cnt_t udata; - udata.obj_count = &ret_value; + /* Set up callback context */ udata.types = types | H5F_OBJ_LOCAL; + udata.obj_count = 0; - if(types & H5F_OBJ_FILE) { + if(types & H5F_OBJ_FILE) if(H5I_iterate(H5I_FILE, H5F__get_all_count_cb, &udata, TRUE) < 0) - HGOTO_ERROR(H5E_FILE, H5E_BADITER, (-1), "iteration over file IDs failed"); - } - if(types & H5F_OBJ_DATASET) { + HGOTO_ERROR(H5E_FILE, H5E_BADITER, (-1), "iteration over file IDs failed") + if(types & H5F_OBJ_DATASET) if(H5I_iterate(H5I_DATASET, H5F__get_all_count_cb, &udata, TRUE) < 0) - HGOTO_ERROR(H5E_FILE, H5E_BADITER, (-1), "iteration over dataset IDs failed"); - } - if(types & H5F_OBJ_GROUP) { + HGOTO_ERROR(H5E_FILE, H5E_BADITER, (-1), "iteration over dataset IDs failed") + if(types & H5F_OBJ_GROUP) if(H5I_iterate(H5I_GROUP, H5F__get_all_count_cb, &udata, TRUE) < 0) - HGOTO_ERROR(H5E_FILE, H5E_BADITER, (-1), "iteration over group IDs failed"); - } - if(types & H5F_OBJ_DATATYPE) { + HGOTO_ERROR(H5E_FILE, H5E_BADITER, (-1), "iteration over group IDs failed") + if(types & H5F_OBJ_DATATYPE) if(H5I_iterate(H5I_DATATYPE, H5F__get_all_count_cb, &udata, TRUE) < 0) - HGOTO_ERROR(H5E_FILE, H5E_BADITER, (-1), "iteration over datatype IDs failed"); - } - if(types & H5F_OBJ_ATTR) { + HGOTO_ERROR(H5E_FILE, H5E_BADITER, (-1), "iteration over datatype IDs failed") + if(types & H5F_OBJ_ATTR) if(H5I_iterate(H5I_ATTR, H5F__get_all_count_cb, &udata, TRUE) < 0) - HGOTO_ERROR(H5E_FILE, H5E_BADITER, (-1), "iteration over attribute IDs failed"); - } - } + HGOTO_ERROR(H5E_FILE, H5E_BADITER, (-1), "iteration over attribute IDs failed") + + /* Set return value */ + ret_value = (ssize_t)udata.obj_count; + } /* end else */ done: FUNC_LEAVE_API(ret_value) @@ -411,11 +421,12 @@ H5F__get_all_ids_cb(void H5_ATTR_UNUSED *obj_ptr, hid_t obj_id, void *key) FUNC_ENTER_STATIC_NOERR - if(*udata->obj_count >= udata->max_objs) + if(udata->obj_count >= udata->max_objs) HGOTO_DONE(H5_ITER_STOP); - udata->oid_list[*udata->obj_count] = obj_id; - *(udata->obj_count) = *(udata->obj_count) + 1; + /* Add the ID to the array */ + udata->oid_list[udata->obj_count] = obj_id; + udata->obj_count++; done: FUNC_LEAVE_NOAPI(ret_value) @@ -430,6 +441,9 @@ done: * NOTE: Type mismatch - You can ask for more objects than can be * returned. * + * NOTE: Currently, the IDs' ref counts are not incremented. Is this + * intentional and documented? + * * Return: Success: The number of IDs in oid_list * * Failure: -1 @@ -462,14 +476,12 @@ H5Fget_obj_ids(hid_t file_id, unsigned types, size_t max_objs, hid_t *oid_list) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, (-1), "invalid file identifier") /* Get the IDs */ - if(H5VL_file_get(vol_obj->data, vol_obj->driver->cls, H5VL_FILE_GET_OBJ_IDS, - H5P_DATASET_XFER_DEFAULT, H5_REQUEST_NULL, types, max_objs, oid_list, &ret_value) < 0) + if(H5VL_file_get(vol_obj, H5VL_FILE_GET_OBJ_IDS, H5P_DATASET_XFER_DEFAULT, H5_REQUEST_NULL, types, max_objs, oid_list, &ret_value) < 0) HGOTO_ERROR(H5E_FILE, H5E_CANTGET, (-1), "unable to get object ids in file(s)") - } + } /* end if */ /* If we passed in the 'special' ID, get the count for everything open in the * library, iterating over all open files and getting the object count for each. * - * XXX: Consider making this a helper function in H5I. * XXX: Note that the RM states that passing in a negative value for max_objs * gets you all the objects. This technically works, but is clearly wrong * behavior since max_objs is an unsigned type. @@ -477,31 +489,30 @@ H5Fget_obj_ids(hid_t file_id, unsigned types, size_t max_objs, hid_t *oid_list) else { H5F_trav_obj_ids_t udata; + /* Set up callback context */ udata.max_objs = max_objs; udata.oid_list = oid_list; - udata.obj_count = &ret_value; + udata.obj_count = 0; - if(types & H5F_OBJ_FILE) { + if(types & H5F_OBJ_FILE) if(H5I_iterate(H5I_FILE, H5F__get_all_ids_cb, &udata, TRUE) < 0) - HGOTO_ERROR(H5E_FILE, H5E_BADITER, (-1), "iteration over file IDs failed"); - } - if(types & H5F_OBJ_DATASET) { + HGOTO_ERROR(H5E_FILE, H5E_BADITER, (-1), "iteration over file IDs failed") + if(types & H5F_OBJ_DATASET) if(H5I_iterate(H5I_DATASET, H5F__get_all_ids_cb, &udata, TRUE) < 0) - HGOTO_ERROR(H5E_FILE, H5E_BADITER, (-1), "iteration over dataset IDs failed"); - } - if(types & H5F_OBJ_GROUP) { + HGOTO_ERROR(H5E_FILE, H5E_BADITER, (-1), "iteration over dataset IDs failed") + if(types & H5F_OBJ_GROUP) if(H5I_iterate(H5I_GROUP, H5F__get_all_ids_cb, &udata, TRUE) < 0) - HGOTO_ERROR(H5E_FILE, H5E_BADITER, (-1), "iteration over group IDs failed"); - } - if(types & H5F_OBJ_DATATYPE) { + HGOTO_ERROR(H5E_FILE, H5E_BADITER, (-1), "iteration over group IDs failed") + if(types & H5F_OBJ_DATATYPE) if(H5I_iterate(H5I_DATATYPE, H5F__get_all_ids_cb, &udata, TRUE) < 0) - HGOTO_ERROR(H5E_FILE, H5E_BADITER, (-1), "iteration over datatype IDs failed"); - } - if(types & H5F_OBJ_ATTR) { + HGOTO_ERROR(H5E_FILE, H5E_BADITER, (-1), "iteration over datatype IDs failed") + if(types & H5F_OBJ_ATTR) if(H5I_iterate(H5I_ATTR, H5F__get_all_ids_cb, &udata, TRUE) < 0) - HGOTO_ERROR(H5E_FILE, H5E_BADITER, (-1), "iteration over attribute IDs failed"); - } - } + HGOTO_ERROR(H5E_FILE, H5E_BADITER, (-1), "iteration over attribute IDs failed") + + /* Set return value */ + ret_value = (ssize_t)udata.obj_count; + } /* end else */ done: FUNC_LEAVE_API(ret_value) @@ -536,8 +547,7 @@ H5Fget_vfd_handle(hid_t file_id, hid_t fapl_id, void **file_handle) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "invalid file identifier") /* Retrieve the VFD handle for the file */ - if(H5VL_file_optional(vol_obj->data, vol_obj->driver->cls, H5P_DATASET_XFER_DEFAULT, - H5_REQUEST_NULL, H5VL_FILE_GET_VFD_HANDLE, file_handle, fapl_id) < 0) + if(H5VL_file_optional(vol_obj, H5P_DATASET_XFER_DEFAULT, H5_REQUEST_NULL, H5VL_NATIVE_FILE_GET_VFD_HANDLE, file_handle, fapl_id) < 0) HGOTO_ERROR(H5E_FILE, H5E_CANTGET, FAIL, "unable to get VFD handle") done: @@ -574,8 +584,7 @@ H5Fis_accessible(const char *name, hid_t fapl_id) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not file access property list") /* Check if file is accessible */ - if(H5VL_file_specific(NULL, NULL, H5VL_FILE_IS_ACCESSIBLE, H5P_DATASET_XFER_DEFAULT, - H5_REQUEST_NULL, fapl_id, name, &ret_value) < 0) + if(H5VL_file_specific(NULL, H5VL_FILE_IS_ACCESSIBLE, H5P_DATASET_XFER_DEFAULT, H5_REQUEST_NULL, fapl_id, name, &ret_value) < 0) HGOTO_ERROR(H5E_FILE, H5E_NOTHDF5, FAIL, "unable to determine if file is accessible as HDF5") done: @@ -611,12 +620,9 @@ done: hid_t H5Fcreate(const char *filename, unsigned flags, hid_t fcpl_id, hid_t fapl_id) { - void *new_file = NULL; /* file struct for new file */ - + H5F_t *new_file = NULL; /* File struct for new file */ H5P_genplist_t *plist; /* Property list pointer */ - H5VL_class_t *cls = NULL; /* VOL Class structure for callback info */ - H5VL_t *driver = NULL; /* VOL driver struct */ - H5VL_driver_prop_t driver_prop; /* Property for vol driver ID & info */ + H5VL_connector_prop_t connector_prop; /* Property for VOL connector ID & info */ hid_t ret_value; /* return value */ FUNC_ENTER_API(H5I_INVALID_HID) @@ -650,10 +656,8 @@ H5Fcreate(const char *filename, unsigned flags, hid_t fcpl_id, hid_t fapl_id) /* get the VOL info from the fapl */ if(NULL == (plist = (H5P_genplist_t *)H5I_object(fapl_id))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, H5I_INVALID_HID, "not a file access property list") - if(H5P_peek(plist, H5F_ACS_VOL_DRV_NAME, &driver_prop) < 0) - HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, H5I_INVALID_HID, "can't get vol driver info") - if(NULL == (cls = (H5VL_class_t *)H5I_object_verify(driver_prop.driver_id, H5I_VOL))) - HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, H5I_INVALID_HID, "not a VOL driver ID") + if(H5P_peek(plist, H5F_ACS_VOL_CONN_NAME, &connector_prop) < 0) + HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, H5I_INVALID_HID, "can't get VOL connector info") /* Adjust bit flags by turning on the creation bit and making sure that * the EXCL or TRUNC bit is set. All newly-created files are opened for @@ -664,21 +668,12 @@ H5Fcreate(const char *filename, unsigned flags, hid_t fcpl_id, hid_t fapl_id) flags |= H5F_ACC_RDWR | H5F_ACC_CREAT; /* Create a new file or truncate an existing file through the VOL */ - if(NULL == (new_file = H5VL_file_create(cls, filename, flags, fcpl_id, fapl_id, - H5P_DATASET_XFER_DEFAULT, H5_REQUEST_NULL))) + if(NULL == (new_file = (H5F_t *)H5VL_file_create(&connector_prop, filename, flags, fcpl_id, fapl_id, H5P_DATASET_XFER_DEFAULT, H5_REQUEST_NULL))) HGOTO_ERROR(H5E_FILE, H5E_CANTOPENFILE, H5I_INVALID_HID, "unable to create file") - /* Setup VOL driver struct */ - if(NULL == (driver = H5FL_CALLOC(H5VL_t))) - HGOTO_ERROR(H5E_FILE, H5E_NOSPACE, H5I_INVALID_HID, "can't allocate VL info struct") - driver->cls = cls; - driver->id = driver_prop.driver_id; - if(H5I_inc_ref(driver->id, FALSE) < 0) - HGOTO_ERROR(H5E_ATOM, H5E_CANTINC, H5I_INVALID_HID, "unable to increment ref count on VOL driver") - /* Get an atom for the file */ - if((ret_value = H5VL_register(H5I_FILE, new_file, driver, TRUE)) < 0) - HGOTO_ERROR(H5E_ATOM, H5E_CANTREGISTER, H5I_INVALID_HID, "unable to atomize file handle") + if((ret_value = H5VL_register_using_vol_id(H5I_FILE, new_file, connector_prop.connector_id, TRUE)) < 0) + HGOTO_ERROR(H5E_FILE, H5E_CANTREGISTER, H5I_INVALID_HID, "unable to atomize file handle") done: FUNC_LEAVE_API(ret_value) @@ -707,12 +702,10 @@ done: hid_t H5Fopen(const char *filename, unsigned flags, hid_t fapl_id) { - void *new_file = NULL; /* file struct for new file */ - H5P_genplist_t *plist; /* Property list pointer */ - H5VL_driver_prop_t driver_prop; /* Property for vol driver ID & info */ - H5VL_class_t *cls = NULL; /* VOL class structure for callback info */ - H5VL_t *driver = NULL; /* VOL driver struct */ - hid_t ret_value; /* return value */ + H5F_t *new_file = NULL; /* File struct for new file */ + H5P_genplist_t *plist; /* Property list pointer */ + H5VL_connector_prop_t connector_prop; /* Property for VOL connector ID & info */ + hid_t ret_value; /* return value */ FUNC_ENTER_API(H5I_INVALID_HID) H5TRACE3("i", "*sIui", filename, flags, fapl_id); @@ -739,26 +732,16 @@ H5Fopen(const char *filename, unsigned flags, hid_t fapl_id) /* Get the VOL info from the fapl */ if(NULL == (plist = (H5P_genplist_t *)H5I_object(fapl_id))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, H5I_INVALID_HID, "not a file access property list") - if(H5P_peek(plist, H5F_ACS_VOL_DRV_NAME, &driver_prop) < 0) - HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, H5I_INVALID_HID, "can't get VOL driver info") - if(NULL == (cls = (H5VL_class_t *)H5I_object_verify(driver_prop.driver_id, H5I_VOL))) - HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, H5I_INVALID_HID, "invalid VOL driver ID") + if(H5P_peek(plist, H5F_ACS_VOL_CONN_NAME, &connector_prop) < 0) + HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, H5I_INVALID_HID, "can't get VOL connector info") /* Open the file through the VOL layer */ - if(NULL == (new_file = H5VL_file_open(cls, filename, flags, fapl_id, H5P_DATASET_XFER_DEFAULT, H5_REQUEST_NULL))) + if(NULL == (new_file = (H5F_t *)H5VL_file_open(&connector_prop, filename, flags, fapl_id, H5P_DATASET_XFER_DEFAULT, H5_REQUEST_NULL))) HGOTO_ERROR(H5E_FILE, H5E_CANTOPENFILE, H5I_INVALID_HID, "unable to open file") - /* Setup VOL driver struct */ - if(NULL == (driver = H5FL_CALLOC(H5VL_t))) - HGOTO_ERROR(H5E_FILE, H5E_NOSPACE, H5I_INVALID_HID, "can't allocate VL info struct") - driver->cls = cls; - driver->id = driver_prop.driver_id; - if(H5I_inc_ref(driver->id, FALSE) < 0) - HGOTO_ERROR(H5E_ATOM, H5E_CANTINC, H5I_INVALID_HID, "unable to increment ref count on VOL driver") - /* Get an ID for the file */ - if((ret_value = H5VL_register(H5I_FILE, new_file, driver, TRUE)) < 0) - HGOTO_ERROR(H5E_ATOM, H5E_CANTREGISTER, H5I_INVALID_HID, "unable to atomize file handle") + if((ret_value = H5VL_register_using_vol_id(H5I_FILE, new_file, connector_prop.connector_id, TRUE)) < 0) + HGOTO_ERROR(H5E_FILE, H5E_CANTREGISTER, H5I_INVALID_HID, "unable to atomize file handle") done: FUNC_LEAVE_API(ret_value) @@ -789,17 +772,15 @@ H5Fflush(hid_t object_id, H5F_scope_t scope) /* Get the type of object we're flushing + sanity check */ obj_type = H5I_get_type(object_id); if(H5I_FILE != obj_type && H5I_GROUP != obj_type && H5I_DATATYPE != obj_type && - H5I_DATASET != obj_type && H5I_ATTR != obj_type) { + H5I_DATASET != obj_type && H5I_ATTR != obj_type) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a file or file object") - } /* get the file object */ if(NULL == (vol_obj = H5VL_vol_object(object_id))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "invalid object identifier") /* Flush the object */ - if(H5VL_file_specific(vol_obj->data, vol_obj->driver->cls, H5VL_FILE_FLUSH, - H5P_DATASET_XFER_DEFAULT, H5_REQUEST_NULL, obj_type, scope) < 0) + if(H5VL_file_specific(vol_obj, H5VL_FILE_FLUSH, H5P_DATASET_XFER_DEFAULT, H5_REQUEST_NULL, (int)obj_type, (int)scope) < 0) HGOTO_ERROR(H5E_FILE, H5E_CANTFLUSH, FAIL, "unable to flush file") done: @@ -863,7 +844,7 @@ hid_t H5Freopen(hid_t file_id) { H5VL_object_t *vol_obj = NULL; - void *file; /* File token from VOL driver */ + H5F_t *file = NULL; /* File struct for new file */ hid_t ret_value = H5I_INVALID_HID; /* Return value */ FUNC_ENTER_API(H5I_INVALID_HID) @@ -874,17 +855,16 @@ H5Freopen(hid_t file_id) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, H5I_INVALID_HID, "invalid file identifier") /* Reopen the file */ - if(H5VL_file_optional(vol_obj->data, vol_obj->driver->cls, H5P_DATASET_XFER_DEFAULT, - H5_REQUEST_NULL, H5VL_FILE_REOPEN, &file) < 0) - HGOTO_ERROR(H5E_FILE, H5E_CANTINIT, H5I_INVALID_HID, "unable to reopen file via the VOL driver") + if(H5VL_file_specific(vol_obj, H5VL_FILE_REOPEN, H5P_DATASET_XFER_DEFAULT, H5_REQUEST_NULL, &file) < 0) + HGOTO_ERROR(H5E_FILE, H5E_CANTINIT, H5I_INVALID_HID, "unable to reopen file via the VOL connector") /* Make sure that worked */ if(NULL == file) HGOTO_ERROR(H5E_FILE, H5E_CANTINIT, H5I_INVALID_HID, "unable to reopen file") /* Get an atom for the file */ - if((ret_value = H5VL_register(H5I_FILE, file, vol_obj->driver, TRUE)) < 0) - HGOTO_ERROR(H5E_ATOM, H5E_CANTREGISTER, H5I_INVALID_HID, "unable to atomize file handle") + if((ret_value = H5VL_register(H5I_FILE, file, vol_obj->connector, TRUE)) < 0) + HGOTO_ERROR(H5E_FILE, H5E_CANTREGISTER, H5I_INVALID_HID, "unable to atomize file handle") done: /* XXX (VOL MERGE): If registration fails, file will not be closed */ @@ -919,10 +899,9 @@ H5Fget_intent(hid_t file_id, unsigned *intent_flags) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "invalid file identifier") /* Get the flags */ - if((ret_value = H5VL_file_get(vol_obj->data, vol_obj->driver->cls, H5VL_FILE_GET_INTENT, - H5P_DATASET_XFER_DEFAULT, H5_REQUEST_NULL, intent_flags)) < 0) + if((ret_value = H5VL_file_get(vol_obj, H5VL_FILE_GET_INTENT, H5P_DATASET_XFER_DEFAULT, H5_REQUEST_NULL, intent_flags)) < 0) HGOTO_ERROR(H5E_FILE, H5E_CANTGET, FAIL, "unable to get file's intent flags") - } + } /* end if */ done: FUNC_LEAVE_API(ret_value) @@ -954,8 +933,7 @@ H5Fget_freespace(hid_t file_id) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, (-1), "invalid file identifier") /* Get the amount of free space in the file */ - if(H5VL_file_optional(vol_obj->data, vol_obj->driver->cls, H5P_DATASET_XFER_DEFAULT, - H5_REQUEST_NULL, H5VL_FILE_GET_FREE_SPACE, &ret_value) < 0) + if(H5VL_file_optional(vol_obj, H5P_DATASET_XFER_DEFAULT, H5_REQUEST_NULL, H5VL_NATIVE_FILE_GET_FREE_SPACE, &ret_value) < 0) HGOTO_ERROR(H5E_FILE, H5E_CANTGET, (-1), "unable to get file free space") done: @@ -990,8 +968,7 @@ H5Fget_filesize(hid_t file_id, hsize_t *size) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "not a file ID") /* Get the file size */ - if(H5VL_file_optional(vol_obj->data, vol_obj->driver->cls, H5P_DATASET_XFER_DEFAULT, - H5_REQUEST_NULL, H5VL_FILE_GET_SIZE, size) < 0) + if(H5VL_file_optional(vol_obj, H5P_DATASET_XFER_DEFAULT, H5_REQUEST_NULL, H5VL_NATIVE_FILE_GET_SIZE, size) < 0) HGOTO_ERROR(H5E_FILE, H5E_CANTGET, FAIL, "unable to get file size") done: @@ -1041,8 +1018,8 @@ done: ssize_t H5Fget_file_image(hid_t file_id, void *buf_ptr, size_t buf_len) { - H5VL_object_t *vol_obj; /* File object for file ID */ - ssize_t ret_value; /* Return value */ + H5VL_object_t *vol_obj; /* File object for file ID */ + ssize_t ret_value; /* Return value */ FUNC_ENTER_API((-1)) H5TRACE3("Zs", "i*xz", file_id, buf_ptr, buf_len); @@ -1052,8 +1029,7 @@ H5Fget_file_image(hid_t file_id, void *buf_ptr, size_t buf_len) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, (-1), "not a file ID") /* Get the file image */ - if(H5VL_file_optional(vol_obj->data, vol_obj->driver->cls, H5P_DATASET_XFER_DEFAULT, H5_REQUEST_NULL, - H5VL_FILE_GET_FILE_IMAGE, buf_ptr, &ret_value, buf_len) < 0) + if(H5VL_file_optional(vol_obj, H5P_DATASET_XFER_DEFAULT, H5_REQUEST_NULL, H5VL_NATIVE_FILE_GET_FILE_IMAGE, buf_ptr, &ret_value, buf_len) < 0) HGOTO_ERROR(H5E_FILE, H5E_CANTGET, (-1), "unable to get file image") done: @@ -1093,8 +1069,7 @@ H5Fget_mdc_config(hid_t file_id, H5AC_cache_config_t *config_ptr) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "invalid file identifier") /* Get the metadata cache configuration */ - if(H5VL_file_optional(vol_obj->data, vol_obj->driver->cls, H5P_DATASET_XFER_DEFAULT, - H5_REQUEST_NULL, H5VL_FILE_GET_MDC_CONF, config_ptr) < 0) + if(H5VL_file_optional(vol_obj, H5P_DATASET_XFER_DEFAULT, H5_REQUEST_NULL, H5VL_NATIVE_FILE_GET_MDC_CONF, config_ptr) < 0) HGOTO_ERROR(H5E_FILE, H5E_CANTGET, FAIL, "unable to get metadata cache configuration") done: @@ -1127,8 +1102,7 @@ H5Fset_mdc_config(hid_t file_id, H5AC_cache_config_t *config_ptr) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "invalid file identifier") /* Set the metadata cache configuration */ - if(H5VL_file_optional(vol_obj->data, vol_obj->driver->cls, H5P_DATASET_XFER_DEFAULT, - H5_REQUEST_NULL, H5VL_FILE_SET_MDC_CONFIG, config_ptr) < 0) + if(H5VL_file_optional(vol_obj, H5P_DATASET_XFER_DEFAULT, H5_REQUEST_NULL, H5VL_NATIVE_FILE_SET_MDC_CONFIG, config_ptr) < 0) HGOTO_ERROR(H5E_FILE, H5E_CANTSET, FAIL, "unable to set metadata cache configuration") done: @@ -1164,8 +1138,7 @@ H5Fget_mdc_hit_rate(hid_t file_id, double *hit_rate_ptr) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "not a file ID") /* Get the current hit rate */ - if(H5VL_file_optional(vol_obj->data, vol_obj->driver->cls, H5P_DATASET_XFER_DEFAULT, - H5_REQUEST_NULL, H5VL_FILE_GET_MDC_HR, hit_rate_ptr) < 0) + if(H5VL_file_optional(vol_obj, H5P_DATASET_XFER_DEFAULT, H5_REQUEST_NULL, H5VL_NATIVE_FILE_GET_MDC_HR, hit_rate_ptr) < 0) HGOTO_ERROR(H5E_FILE, H5E_CANTGET, FAIL, "unable to get MDC hit rate") done: @@ -1202,9 +1175,7 @@ H5Fget_mdc_size(hid_t file_id, size_t *max_size_ptr, size_t *min_clean_size_ptr, HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "not a file ID") /* Get the size data */ - if(H5VL_file_optional(vol_obj->data, vol_obj->driver->cls, H5P_DATASET_XFER_DEFAULT, - H5_REQUEST_NULL, H5VL_FILE_GET_MDC_SIZE, - max_size_ptr, min_clean_size_ptr, cur_size_ptr, cur_num_entries_ptr) < 0) + if(H5VL_file_optional(vol_obj, H5P_DATASET_XFER_DEFAULT, H5_REQUEST_NULL, H5VL_NATIVE_FILE_GET_MDC_SIZE, max_size_ptr, min_clean_size_ptr, cur_size_ptr, cur_num_entries_ptr) < 0) HGOTO_ERROR(H5E_FILE, H5E_CANTGET, FAIL, "unable to get MDC size") done: @@ -1242,8 +1213,7 @@ H5Freset_mdc_hit_rate_stats(hid_t file_id) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "invalid file identifier") /* Reset the hit rate statistic */ - if(H5VL_file_optional(vol_obj->data, vol_obj->driver->cls, H5P_DATASET_XFER_DEFAULT, - H5_REQUEST_NULL, H5VL_FILE_RESET_MDC_HIT_RATE) < 0) + if(H5VL_file_optional(vol_obj, H5P_DATASET_XFER_DEFAULT, H5_REQUEST_NULL, H5VL_NATIVE_FILE_RESET_MDC_HIT_RATE) < 0) HGOTO_ERROR(H5E_FILE, H5E_CANTSET, FAIL, "can't reset cache hit rate") done: @@ -1277,7 +1247,7 @@ H5Fget_name(hid_t obj_id, char *name/*out*/, size_t size) { H5VL_object_t *vol_obj = NULL; H5I_type_t type; - ssize_t ret_value = -1; + ssize_t ret_value = -1; /* Return value */ FUNC_ENTER_API((-1)) H5TRACE3("Zs", "ixz", obj_id, name, size); @@ -1292,8 +1262,7 @@ H5Fget_name(hid_t obj_id, char *name/*out*/, size_t size) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, (-1), "invalid file identifier") /* Get the filename via the VOL */ - if(H5VL_file_get(vol_obj->data, vol_obj->driver->cls, H5VL_FILE_GET_NAME, - H5P_DATASET_XFER_DEFAULT, H5_REQUEST_NULL, type, size, name, &ret_value) < 0) + if(H5VL_file_get(vol_obj, H5VL_FILE_GET_NAME, H5P_DATASET_XFER_DEFAULT, H5_REQUEST_NULL, (int)type, size, name, &ret_value) < 0) HGOTO_ERROR(H5E_FILE, H5E_CANTGET, (-1), "unable to get file name") done: @@ -1338,8 +1307,7 @@ H5Fget_info2(hid_t obj_id, H5F_info2_t *finfo) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "invalid object identifier") /* Get the file information */ - if(H5VL_file_optional(vol_obj->data, vol_obj->driver->cls, H5P_DATASET_XFER_DEFAULT, H5_REQUEST_NULL, - H5VL_FILE_GET_INFO, type, finfo) < 0) + if(H5VL_file_optional(vol_obj, H5P_DATASET_XFER_DEFAULT, H5_REQUEST_NULL, H5VL_NATIVE_FILE_GET_INFO, (int)type, finfo) < 0) HGOTO_ERROR(H5E_FILE, H5E_CANTGET, FAIL, "unable to retrieve file info") done: @@ -1375,8 +1343,7 @@ H5Fget_metadata_read_retry_info(hid_t file_id, H5F_retry_info_t *info) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "not a file ID") /* Get the retry info */ - if(H5VL_file_optional(vol_obj->data, vol_obj->driver->cls, H5P_DATASET_XFER_DEFAULT, - H5_REQUEST_NULL, H5VL_FILE_GET_METADATA_READ_RETRY_INFO, info) < 0) + if(H5VL_file_optional(vol_obj, H5P_DATASET_XFER_DEFAULT, H5_REQUEST_NULL, H5VL_NATIVE_FILE_GET_METADATA_READ_RETRY_INFO, info) < 0) HGOTO_ERROR(H5E_FILE, H5E_CANTRELEASE, FAIL, "can't get metadata read retry info") done: @@ -1415,8 +1382,7 @@ H5Fget_free_sections(hid_t file_id, H5F_mem_t type, size_t nsects, HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, (-1), "nsects must be > 0") /* Get the free-space section information in the file */ - if(H5VL_file_optional(vol_obj->data, vol_obj->driver->cls, H5P_DATASET_XFER_DEFAULT, H5_REQUEST_NULL, - H5VL_FILE_GET_FREE_SECTIONS, sect_info, &ret_value, type, nsects) < 0) + if(H5VL_file_optional(vol_obj, H5P_DATASET_XFER_DEFAULT, H5_REQUEST_NULL, H5VL_NATIVE_FILE_GET_FREE_SECTIONS, sect_info, &ret_value, (int)type, nsects) < 0) HGOTO_ERROR(H5E_FILE, H5E_CANTGET, (-1), "unable to get file free sections") done: @@ -1449,8 +1415,7 @@ H5Fclear_elink_file_cache(hid_t file_id) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "not a file ID") /* Release the EFC */ - if(H5VL_file_optional(vol_obj->data, vol_obj->driver->cls, H5P_DATASET_XFER_DEFAULT, - H5_REQUEST_NULL, H5VL_FILE_CLEAR_ELINK_CACHE) < 0) + if(H5VL_file_optional(vol_obj, H5P_DATASET_XFER_DEFAULT, H5_REQUEST_NULL, H5VL_NATIVE_FILE_CLEAR_ELINK_CACHE) < 0) HGOTO_ERROR(H5E_FILE, H5E_CANTRELEASE, FAIL, "can't release external file cache") done: @@ -1509,9 +1474,8 @@ H5Fstart_swmr_write(hid_t file_id) if(H5CX_set_loc(file_id) < 0) HGOTO_ERROR(H5E_FILE, H5E_CANTSET, FAIL, "can't set collective metadata read info") - /* start SWMR writing */ - if(H5VL_file_optional(vol_obj->data, vol_obj->driver->cls, H5P_DATASET_XFER_DEFAULT, - H5_REQUEST_NULL, H5VL_FILE_START_SWMR_WRITE) < 0) + /* Start SWMR writing */ + if(H5VL_file_optional(vol_obj, H5P_DATASET_XFER_DEFAULT, H5_REQUEST_NULL, H5VL_NATIVE_FILE_START_SWMR_WRITE) < 0) HGOTO_ERROR(H5E_FILE, H5E_SYSTEM, FAIL, "unable to start SWMR writing") done: @@ -1543,8 +1507,7 @@ H5Fstart_mdc_logging(hid_t file_id) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "hid_t identifier is not a file ID") /* Call mdc logging function */ - if(H5VL_file_optional(vol_obj->data, vol_obj->driver->cls, H5P_DATASET_XFER_DEFAULT, - H5_REQUEST_NULL, H5VL_FILE_START_MDC_LOGGING) < 0) + if(H5VL_file_optional(vol_obj, H5P_DATASET_XFER_DEFAULT, H5_REQUEST_NULL, H5VL_NATIVE_FILE_START_MDC_LOGGING) < 0) HGOTO_ERROR(H5E_FILE, H5E_LOGFAIL, FAIL, "unable to start mdc logging") done: @@ -1577,8 +1540,7 @@ H5Fstop_mdc_logging(hid_t file_id) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "hid_t identifier is not a file ID") /* Call mdc logging function */ - if(H5VL_file_optional(vol_obj->data, vol_obj->driver->cls, H5P_DATASET_XFER_DEFAULT, - H5_REQUEST_NULL, H5VL_FILE_STOP_MDC_LOGGING) < 0) + if(H5VL_file_optional(vol_obj, H5P_DATASET_XFER_DEFAULT, H5_REQUEST_NULL, H5VL_NATIVE_FILE_STOP_MDC_LOGGING) < 0) HGOTO_ERROR(H5E_FILE, H5E_LOGFAIL, FAIL, "unable to stop mdc logging") done: @@ -1612,8 +1574,7 @@ H5Fget_mdc_logging_status(hid_t file_id, hbool_t *is_enabled, HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "hid_t identifier is not a file ID") /* Call mdc logging function */ - if(H5VL_file_optional(vol_obj->data, vol_obj->driver->cls, H5P_DATASET_XFER_DEFAULT, - H5_REQUEST_NULL, H5VL_FILE_GET_MDC_LOGGING_STATUS, is_enabled, is_currently_logging) < 0) + if(H5VL_file_optional(vol_obj, H5P_DATASET_XFER_DEFAULT, H5_REQUEST_NULL, H5VL_NATIVE_FILE_GET_MDC_LOGGING_STATUS, is_enabled, is_currently_logging) < 0) HGOTO_ERROR(H5E_FILE, H5E_LOGFAIL, FAIL, "unable to get logging status") done: @@ -1633,13 +1594,10 @@ done: * *------------------------------------------------------------------------- */ -/* XXX (VOL MERGE): This could go in the native VOL driver under 'optional' - */ herr_t H5Fset_libver_bounds(hid_t file_id, H5F_libver_t low, H5F_libver_t high) { H5VL_object_t *vol_obj; /* File as VOL object */ - H5F_t *f; /* File */ herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_API(FAIL) @@ -1648,15 +1606,14 @@ H5Fset_libver_bounds(hid_t file_id, H5F_libver_t low, H5F_libver_t high) /* Check args */ if(NULL == (vol_obj = (H5VL_object_t *)H5I_object_verify(file_id, H5I_FILE))) HGOTO_ERROR(H5E_FILE, H5E_BADVALUE, FAIL, "not a file ID") - f = (H5F_t *)(vol_obj->data); /* Set up collective metadata if appropriate */ if(H5CX_set_loc(file_id) < 0) HGOTO_ERROR(H5E_FILE, H5E_CANTSET, FAIL, "can't set collective metadata read info") - /* Call internal set_libver_bounds function */ - if(H5F__set_libver_bounds(f, low, high) < 0) - HGOTO_ERROR(H5E_FILE, H5E_CANTSET, FAIL, "cannot set low/high bounds") + /* Set the library's version bounds */ + if(H5VL_file_optional(vol_obj, H5P_DATASET_XFER_DEFAULT, H5_REQUEST_NULL, H5VL_NATIVE_FILE_SET_LIBVER_BOUNDS, low, high) < 0) + HGOTO_ERROR(H5E_FILE, H5E_CANTSET, FAIL, "can't set library version bounds") done: FUNC_LEAVE_API(ret_value) @@ -1692,8 +1649,7 @@ H5Fformat_convert(hid_t file_id) HGOTO_ERROR(H5E_FILE, H5E_CANTSET, FAIL, "can't set collective metadata read info") /* Convert the format */ - if(H5VL_file_optional(vol_obj->data, vol_obj->driver->cls, H5P_DATASET_XFER_DEFAULT, - H5_REQUEST_NULL, H5VL_FILE_FORMAT_CONVERT) < 0) + if(H5VL_file_optional(vol_obj, H5P_DATASET_XFER_DEFAULT, H5_REQUEST_NULL, H5VL_NATIVE_FILE_FORMAT_CONVERT) < 0) HGOTO_ERROR(H5E_FILE, H5E_CANTCONVERT, FAIL, "can't convert file format") done: @@ -1724,8 +1680,7 @@ H5Freset_page_buffering_stats(hid_t file_id) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "invalid file identifier") /* Reset the statistics */ - if(H5VL_file_optional(vol_obj->data, vol_obj->driver->cls, H5P_DATASET_XFER_DEFAULT, - H5_REQUEST_NULL, H5VL_FILE_RESET_PAGE_BUFFERING_STATS) < 0) + if(H5VL_file_optional(vol_obj, H5P_DATASET_XFER_DEFAULT, H5_REQUEST_NULL, H5VL_NATIVE_FILE_RESET_PAGE_BUFFERING_STATS) < 0) HGOTO_ERROR(H5E_FILE, H5E_CANTSET, FAIL, "can't reset stats for page buffering") done: @@ -1760,9 +1715,7 @@ H5Fget_page_buffering_stats(hid_t file_id, unsigned accesses[2], unsigned hits[2 HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "NULL input parameters for stats") /* Get the statistics */ - if(H5VL_file_optional(vol_obj->data, vol_obj->driver->cls, H5P_DATASET_XFER_DEFAULT, - H5_REQUEST_NULL, H5VL_FILE_GET_PAGE_BUFFERING_STATS, - accesses, hits, misses, evictions, bypasses) < 0) + if(H5VL_file_optional(vol_obj, H5P_DATASET_XFER_DEFAULT, H5_REQUEST_NULL, H5VL_NATIVE_FILE_GET_PAGE_BUFFERING_STATS, accesses, hits, misses, evictions, bypasses) < 0) HGOTO_ERROR(H5E_FILE, H5E_CANTGET, FAIL, "can't retrieve stats for page buffering") done: @@ -1786,21 +1739,19 @@ done: herr_t H5Fget_mdc_image_info(hid_t file_id, haddr_t *image_addr, hsize_t *image_len) { - H5F_t *file; /* File object for file ID */ + H5VL_object_t *vol_obj; /* File info */ herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_API(FAIL) H5TRACE3("e", "i*a*h", file_id, image_addr, image_len); /* Check args */ - if(NULL == (file = (H5F_t *)H5VL_object_verify(file_id, H5I_FILE))) - HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "not a file ID") - if(NULL == image_addr || NULL == image_len) - HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "NULL image addr or image len") + if(NULL == (vol_obj = (H5VL_object_t *)H5I_object_verify(file_id, H5I_FILE))) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "hid_t identifier is not a file ID") /* Go get the address and size of the cache image */ - if(H5AC_get_mdc_image_info(file->shared->cache, image_addr, image_len) < 0) - HGOTO_ERROR(H5E_CACHE, H5E_CANTGET, FAIL, "can't retrieve cache image info") + if(H5VL_file_optional(vol_obj, H5P_DATASET_XFER_DEFAULT, H5_REQUEST_NULL, H5VL_NATIVE_FILE_GET_MDC_IMAGE_INFO, image_addr, image_len) < 0) + HGOTO_ERROR(H5E_FILE, H5E_CANTGET, FAIL, "can't retrieve cache image info") done: FUNC_LEAVE_API(ret_value) @@ -1820,29 +1771,23 @@ done: herr_t H5Fget_eoa(hid_t file_id, haddr_t *eoa) { - H5F_t *file; /* File object for file ID */ - haddr_t rel_eoa; /* Relative address of EOA */ + H5VL_object_t *vol_obj; /* File info */ herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_API(FAIL) H5TRACE2("e", "i*a", file_id, eoa); /* Check args */ - if(NULL == (file = (H5F_t *)H5VL_object_verify(file_id, H5I_FILE))) + if(NULL == (vol_obj = (H5VL_object_t *)H5I_object_verify(file_id, H5I_FILE))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "hid_t identifier is not a file ID") - /* This public routine will work only for drivers with this feature enabled.*/ - /* We might introduce a new feature flag in the future */ - if(!H5F_HAS_FEATURE(file, H5FD_FEAT_SUPPORTS_SWMR_IO)) - HGOTO_ERROR(H5E_FILE, H5E_BADVALUE, FAIL, "must use a SWMR-compatible VFD for this public routine") - - /* The real work */ - if(HADDR_UNDEF == (rel_eoa = H5FD_get_eoa(file->shared->lf, H5FD_MEM_DEFAULT))) - HGOTO_ERROR(H5E_FILE, H5E_CANTGET, FAIL, "get_eoa request failed") + /* Only do work if valid pointer to fill in */ + if(eoa) { + /* Retrieve the EOA for the file */ + if(H5VL_file_optional(vol_obj, H5P_DATASET_XFER_DEFAULT, H5_REQUEST_NULL, H5VL_NATIVE_FILE_GET_EOA, eoa) < 0) + HGOTO_ERROR(H5E_FILE, H5E_CANTGET, FAIL, "unable to get EOA") + } /* end if */ - /* (Note compensating for base address subtraction in internal routine) */ - if(eoa) - *eoa = rel_eoa + H5FD_get_base_addr(file->shared->lf); done: FUNC_LEAVE_API(ret_value) } /* H5Fget_eoa() */ @@ -1859,30 +1804,19 @@ done: herr_t H5Fincrement_filesize(hid_t file_id, hsize_t increment) { - H5F_t *file; /* File object for file ID */ - haddr_t max_eof_eoa; /* Maximum of the relative EOA & EOF */ - herr_t ret_value = SUCCEED; /* Return value */ + H5VL_object_t *vol_obj; /* File info */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_API(FAIL) H5TRACE2("e", "ih", file_id, increment); /* Check args */ - if(NULL == (file = (H5F_t *)H5VL_object_verify(file_id, H5I_FILE))) + if(NULL == (vol_obj = (H5VL_object_t *)H5I_object_verify(file_id, H5I_FILE))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "hid_t identifier is not a file ID") - /* This public routine will work only for drivers with this feature enabled.*/ - /* We might introduce a new feature flag in the future */ - if(!H5F_HAS_FEATURE(file, H5FD_FEAT_SUPPORTS_SWMR_IO)) - HGOTO_ERROR(H5E_FILE, H5E_BADVALUE, FAIL, "must use a SWMR-compatible VFD for this public routine") - - /* Get the maximum of EOA and EOF */ - if(H5F__get_max_eof_eoa(file, &max_eof_eoa) < 0) - HGOTO_ERROR(H5E_FILE, H5E_CANTGET, FAIL, "file can't get max eof/eoa ") - - /* Set EOA to the maximum value + increment */ - /* H5FD_set_eoa() will add base_addr to max_eof_eoa */ - if(H5FD_set_eoa(file->shared->lf, H5FD_MEM_DEFAULT, max_eof_eoa + increment) < 0) - HGOTO_ERROR(H5E_FILE, H5E_CANTSET, FAIL, "driver set_eoa request failed") + /* Increment the file size */ + if(H5VL_file_optional(vol_obj, H5P_DATASET_XFER_DEFAULT, H5_REQUEST_NULL, H5VL_NATIVE_FILE_INCR_FILESIZE, increment) < 0) + HGOTO_ERROR(H5E_FILE, H5E_CANTSET, FAIL, "unable to increment file size") done: FUNC_LEAVE_API(ret_value) diff --git a/src/H5FDcore.c b/src/H5FDcore.c index 2ab04dc..ec6b2a7 100644 --- a/src/H5FDcore.c +++ b/src/H5FDcore.c @@ -54,6 +54,7 @@ typedef struct H5FD_core_t { haddr_t eof; /* current allocated size */ size_t increment; /* multiples for mem allocation */ hbool_t backing_store; /* write to file name on flush */ + hbool_t write_tracking; /* Whether to track writes */ size_t bstore_page_size; /* backing store page size */ int fd; /* backing store file descriptor */ /* Information for determining uniqueness of a file with a backing store */ @@ -93,10 +94,14 @@ typedef struct H5FD_core_t { typedef struct H5FD_core_fapl_t { size_t increment; /* how much to grow memory */ hbool_t backing_store; /* write to file name on flush */ + hbool_t write_tracking; /* Whether to track writes */ + size_t page_size; /* Page size for tracked writes */ } H5FD_core_fapl_t; /* Allocate memory in multiples of this size by default */ -#define H5FD_CORE_INCREMENT 8192 +#define H5FD_CORE_INCREMENT 8192 +#define H5FD_CORE_WRITE_TRACKING_FLAG FALSE +#define H5FD_CORE_WRITE_TRACKING_PAGE_SIZE 524288 /* These macros check for overflow of various quantities. These macros * assume that file_offset_t is signed and haddr_t and size_t are unsigned. @@ -466,6 +471,100 @@ H5FD__core_term(void) /*------------------------------------------------------------------------- + * Function: H5Pset_core_write_tracking + * + * Purpose: Enables/disables core VFD write tracking and page + * aggregation size. + * + * Return: Non-negative on success/Negative on failure + * + * Programmer: Dana Robinson + * Tuesday, April 8, 2014 + * + *------------------------------------------------------------------------- + */ +herr_t +H5Pset_core_write_tracking(hid_t plist_id, hbool_t is_enabled, size_t page_size) +{ + H5P_genplist_t *plist; /* Property list pointer */ + H5FD_core_fapl_t fa; /* Core VFD info */ + const H5FD_core_fapl_t *old_fa; /* Old core VFD info */ + herr_t ret_value = SUCCEED; /* Return value */ + + FUNC_ENTER_API(FAIL) + H5TRACE3("e", "ibz", plist_id, is_enabled, page_size); + + /* The page size cannot be zero */ + if(page_size == 0) + HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "page_size cannot be zero") + + /* Get the plist structure */ + if(NULL == (plist = H5P_object_verify(plist_id, H5P_FILE_ACCESS))) + HGOTO_ERROR(H5E_PLIST, H5E_BADATOM, FAIL, "can't find object for ID") + if(H5FD_CORE != H5P_peek_driver(plist)) + HGOTO_ERROR(H5E_PLIST, H5E_BADVALUE, FAIL, "incorrect VFL driver") + if(NULL == (old_fa = (const H5FD_core_fapl_t *)H5P_peek_driver_info(plist))) + HGOTO_ERROR(H5E_PLIST, H5E_BADVALUE, FAIL, "bad VFL driver info") + + /* Set VFD info values */ + HDmemset(&fa, 0, sizeof(H5FD_core_fapl_t)); + fa.increment = old_fa->increment; + fa.backing_store = old_fa->backing_store; + fa.write_tracking = is_enabled; + fa.page_size = page_size; + + /* Set the property values & the driver for the FAPL */ + if(H5P_set_driver(plist, H5FD_CORE, &fa) < 0) + HGOTO_ERROR(H5E_PLIST, H5E_CANTSET, FAIL, "can't set core VFD as driver") + +done: + FUNC_LEAVE_API(ret_value) +} /* end H5Pset_core_write_tracking() */ + + +/*------------------------------------------------------------------------- + * Function: H5Pget_core_write_tracking + * + * Purpose: Gets information about core VFD write tracking and page + * aggregation size. + * + * Return: Non-negative on success/Negative on failure + * + * Programmer: Dana Robinson + * Tuesday, April 8, 2014 + * + *------------------------------------------------------------------------- + */ +herr_t +H5Pget_core_write_tracking(hid_t plist_id, hbool_t *is_enabled, size_t *page_size) +{ + H5P_genplist_t *plist; /* Property list pointer */ + const H5FD_core_fapl_t *fa; /* Core VFD info */ + herr_t ret_value = SUCCEED; /* Return value */ + + FUNC_ENTER_API(FAIL) + H5TRACE3("e", "i*b*z", plist_id, is_enabled, page_size); + + /* Get the plist structure */ + if(NULL == (plist = H5P_object_verify(plist_id, H5P_FILE_ACCESS))) + HGOTO_ERROR(H5E_PLIST, H5E_BADATOM, FAIL, "can't find object for ID") + if(H5FD_CORE != H5P_peek_driver(plist)) + HGOTO_ERROR(H5E_PLIST, H5E_BADVALUE, FAIL, "incorrect VFL driver") + if(NULL == (fa = (const H5FD_core_fapl_t *)H5P_peek_driver_info(plist))) + HGOTO_ERROR(H5E_PLIST, H5E_BADVALUE, FAIL, "bad VFL driver info") + + /* Get values */ + if(is_enabled) + *is_enabled = fa->write_tracking; + if(page_size) + *page_size = fa->page_size; + +done: + FUNC_LEAVE_API(ret_value) +} /* end H5Pget_core_write_tracking() */ + + +/*------------------------------------------------------------------------- * Function: H5Pset_fapl_core * * Purpose: Modify the file access property list to use the H5FD_CORE @@ -482,9 +581,9 @@ H5FD__core_term(void) herr_t H5Pset_fapl_core(hid_t fapl_id, size_t increment, hbool_t backing_store) { - H5FD_core_fapl_t fa; - H5P_genplist_t *plist; /* Property list pointer */ - herr_t ret_value; + H5P_genplist_t *plist; /* Property list pointer */ + H5FD_core_fapl_t fa; /* Core VFD info */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_API(FAIL) H5TRACE3("e", "izb", fapl_id, increment, backing_store); @@ -493,10 +592,16 @@ H5Pset_fapl_core(hid_t fapl_id, size_t increment, hbool_t backing_store) if(NULL == (plist = H5P_object_verify(fapl_id,H5P_FILE_ACCESS))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a file access property list") + /* Set VFD info values */ + HDmemset(&fa, 0, sizeof(H5FD_core_fapl_t)); fa.increment = increment; fa.backing_store = backing_store; + fa.write_tracking = H5FD_CORE_WRITE_TRACKING_FLAG; + fa.page_size = H5FD_CORE_WRITE_TRACKING_PAGE_SIZE; - ret_value = H5P_set_driver(plist, H5FD_CORE, &fa); + /* Set the property values & the driver for the FAPL */ + if(H5P_set_driver(plist, H5FD_CORE, &fa) < 0) + HGOTO_ERROR(H5E_PLIST, H5E_CANTSET, FAIL, "can't set core VFD as driver") done: FUNC_LEAVE_API(ret_value) @@ -518,9 +623,9 @@ done: herr_t H5Pget_fapl_core(hid_t fapl_id, size_t *increment /*out*/, hbool_t *backing_store /*out*/) { - H5P_genplist_t *plist; /* Property list pointer */ - const H5FD_core_fapl_t *fa; - herr_t ret_value = SUCCEED; /* Return value */ + H5P_genplist_t *plist; /* Property list pointer */ + const H5FD_core_fapl_t *fa; /* Core VFD info */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_API(FAIL) H5TRACE3("e", "ixx", fapl_id, increment, backing_store); @@ -559,7 +664,7 @@ static void * H5FD__core_fapl_get(H5FD_t *_file) { H5FD_core_t *file = (H5FD_core_t*)_file; - H5FD_core_fapl_t *fa; + H5FD_core_fapl_t *fa; /* Core VFD info */ void *ret_value = NULL; /* Return value */ FUNC_ENTER_STATIC @@ -569,6 +674,8 @@ H5FD__core_fapl_get(H5FD_t *_file) fa->increment = file->increment; fa->backing_store = (hbool_t)(file->fd >= 0); + fa->write_tracking = file->write_tracking; + fa->page_size = file->bstore_page_size; /* Set return value */ ret_value = fa; @@ -776,35 +883,28 @@ H5FD__core_open(const char *name, unsigned flags, hid_t fapl_id, haddr_t maxaddr } /* end if */ } /* end if */ + /* Get the write tracking & page size */ + file->write_tracking = fa->write_tracking; + file->bstore_page_size = fa->page_size; + /* Set up write tracking if the backing store is on */ file->dirty_list = NULL; if(fa->backing_store) { - hbool_t write_tracking_flag = FALSE; /* what the user asked for */ hbool_t use_write_tracking = FALSE; /* what we're actually doing */ - /* Get the write tracking flag */ - if(H5P_get(plist, H5F_ACS_CORE_WRITE_TRACKING_FLAG_NAME, &write_tracking_flag) < 0) - HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, NULL, "can't get core VFD write tracking flag"); - - /* Get the page size */ - if(H5P_get(plist, H5F_ACS_CORE_WRITE_TRACKING_PAGE_SIZE_NAME, &(file->bstore_page_size)) < 0) - HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, NULL, "can't get core VFD write tracking page size"); - /* default is to have write tracking OFF for create (hence the check to see * if the user explicitly set a page size) and ON with the default page size * on open (when not read-only). */ /* Only use write tracking if the file is open for writing */ - use_write_tracking = - TRUE == write_tracking_flag /* user asked for write tracking */ - && !(o_flags & O_RDONLY) /* file is open for writing (i.e. not read-only) */ - && file->bstore_page_size != 0; /* page size is not zero */ + use_write_tracking = (TRUE == fa->write_tracking) /* user asked for write tracking */ + && !(o_flags & O_RDONLY) /* file is open for writing (i.e. not read-only) */ + && (file->bstore_page_size != 0); /* page size is not zero */ /* initialize the dirty list */ - if(use_write_tracking) { + if(use_write_tracking) if(NULL == (file->dirty_list = H5SL_create(H5SL_TYPE_HADDR, NULL))) HGOTO_ERROR(H5E_SLIST, H5E_CANTCREATE, NULL, "can't create core vfd dirty region list"); - } /* end if */ } /* end if */ /* Set return value */ diff --git a/src/H5FDdirect.c b/src/H5FDdirect.c index 906ec28..d1a8fc8 100644 --- a/src/H5FDdirect.c +++ b/src/H5FDdirect.c @@ -291,6 +291,7 @@ H5Pset_fapl_direct(hid_t fapl_id, size_t boundary, size_t block_size, size_t cbu if(NULL == (plist = H5P_object_verify(fapl_id,H5P_FILE_ACCESS))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a file access property list") + HDmemset(&fa, 0, sizeof(H5FD_direct_fapl_t)); if(boundary != 0) fa.mboundary = boundary; else @@ -417,7 +418,7 @@ static void * H5FD_direct_fapl_copy(const void *_old_fa) { const H5FD_direct_fapl_t *old_fa = (const H5FD_direct_fapl_t*)_old_fa; - H5FD_direct_fapl_t *new_fa = H5MM_malloc(sizeof(H5FD_direct_fapl_t)); + H5FD_direct_fapl_t *new_fa = H5MM_calloc(sizeof(H5FD_direct_fapl_t)); FUNC_ENTER_NOAPI_NOINIT_NOERR diff --git a/src/H5FDlog.c b/src/H5FDlog.c index 3dcd7f5..cd9ab0e 100644 --- a/src/H5FDlog.c +++ b/src/H5FDlog.c @@ -329,6 +329,8 @@ H5Pset_fapl_log(hid_t fapl_id, const char *logfile, unsigned long long flags, si if(NULL == (plist = H5P_object_verify(fapl_id, H5P_FILE_ACCESS))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a file access property list") + HDmemset(&fa, 0, sizeof(H5FD_log_fapl_t)); + /* This shallow copy is correct! The string will be properly * copied deep down in the H5P code. */ diff --git a/src/H5FDmpio.c b/src/H5FDmpio.c index 87f8b6a..c04906e 100644 --- a/src/H5FDmpio.c +++ b/src/H5FDmpio.c @@ -319,6 +319,7 @@ H5Pset_fapl_mpio(hid_t fapl_id, MPI_Comm comm, MPI_Info info) HGOTO_ERROR(H5E_PLIST, H5E_BADTYPE, FAIL, "not a valid communicator") /* Initialize driver specific properties */ + HDmemset(&fa, 0, sizeof(H5FD_mpio_fapl_t)); fa.comm = comm; fa.info = info; diff --git a/src/H5FDmulti.c b/src/H5FDmulti.c index aa1b118..e8dde50 100644 --- a/src/H5FDmulti.c +++ b/src/H5FDmulti.c @@ -497,6 +497,7 @@ H5Pset_fapl_multi(hid_t fapl_id, const H5FD_mem_t *memb_map, * Initialize driver specific information. No need to copy it into the FA * struct since all members will be copied by H5Pset_driver(). */ + memset(&fa, 0, sizeof(H5FD_multi_fapl_t)); memcpy(fa.memb_map, memb_map, H5FD_MEM_NTYPES*sizeof(H5FD_mem_t)); memcpy(fa.memb_fapl, memb_fapl, H5FD_MEM_NTYPES*sizeof(hid_t)); memcpy(fa.memb_name, memb_name, H5FD_MEM_NTYPES*sizeof(char*)); @@ -892,7 +893,7 @@ static void * H5FD_multi_fapl_copy(const void *_old_fa) { const H5FD_multi_fapl_t *old_fa = (const H5FD_multi_fapl_t*)_old_fa; - H5FD_multi_fapl_t *new_fa = (H5FD_multi_fapl_t *)malloc(sizeof(H5FD_multi_fapl_t)); + H5FD_multi_fapl_t *new_fa = (H5FD_multi_fapl_t *)calloc(1, sizeof(H5FD_multi_fapl_t)); int nerrors = 0; static const char *func="H5FD_multi_fapl_copy"; /* Function Name for error reporting */ diff --git a/src/H5FDtest.c b/src/H5FDtest.c index 080223c..dec0818 100644 --- a/src/H5FDtest.c +++ b/src/H5FDtest.c @@ -104,11 +104,10 @@ H5FD__supports_swmr_test(const char *vfd_name) FUNC_ENTER_NOAPI_NOINIT_NOERR - if(!vfd_name || !HDstrcmp(vfd_name, "")) + if(!vfd_name || !HDstrcmp(vfd_name, "") || !HDstrcmp(vfd_name, "nomatch")) ret_value = TRUE; else - ret_value = !HDstrcmp(vfd_name, "log") - || !HDstrcmp(vfd_name, "sec2"); + ret_value = !HDstrcmp(vfd_name, "log") || !HDstrcmp(vfd_name, "sec2"); FUNC_LEAVE_NOAPI(ret_value) diff --git a/src/H5Fdeprec.c b/src/H5Fdeprec.c index 6fee596..18e915f 100644 --- a/src/H5Fdeprec.c +++ b/src/H5Fdeprec.c @@ -42,6 +42,8 @@ #include "H5Iprivate.h" /* IDs */ #include "H5SMprivate.h" /* Shared object header messages */ +#include "H5VLnative_private.h" /* Native VOL connector */ + /****************/ /* Local Macros */ @@ -96,7 +98,8 @@ herr_t H5Fget_info1(hid_t obj_id, H5F_info1_t *finfo) { - H5F_t *f; /* Top file in mount hierarchy */ + H5VL_object_t *vol_obj = NULL; + H5I_type_t type; H5F_info2_t finfo2; /* Current file info struct */ herr_t ret_value = SUCCEED; /* Return value */ @@ -107,27 +110,17 @@ H5Fget_info1(hid_t obj_id, H5F_info1_t *finfo) if(!finfo) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "no info struct") - /* For file IDs, get the file object directly - * - * (This prevents the H5G_loc() call from returning the file pointer for - * the top file in a mount hierarchy) - */ - if(H5I_get_type(obj_id) == H5I_FILE ) { - if(NULL == (f = (H5F_t *)H5VL_object(obj_id))) - HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a file") - } - else { - H5G_loc_t loc; /* Object location */ - - /* Get symbol table entry */ - if(H5G_loc(obj_id, &loc) < 0) - HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "not a valid object ID") - f = loc.oloc->file; - } - HDassert(f->shared); - - /* Get the current file info */ - if(H5F__get_info(f, &finfo2) < 0) + /* Check the type */ + type = H5I_get_type(obj_id); + if(H5I_FILE != type && H5I_GROUP != type && H5I_DATATYPE != type && H5I_DATASET != type && H5I_ATTR != type) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a file or file object") + + /* Get the file object */ + if(NULL == (vol_obj = H5VL_vol_object(obj_id))) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "invalid object identifier") + + /* Get the file information */ + if(H5VL_file_optional(vol_obj, H5P_DATASET_XFER_DEFAULT, H5_REQUEST_NULL, H5VL_NATIVE_FILE_GET_INFO, type, &finfo2) < 0) HGOTO_ERROR(H5E_FILE, H5E_CANTGET, FAIL, "unable to retrieve file info") /* Copy the compatible fields into the older struct */ @@ -165,12 +158,11 @@ H5Fis_hdf5(const char *name) if(!name || !*name) HGOTO_ERROR(H5E_ARGS, H5E_BADRANGE, (-1), "no file name specified") - /* call the private is_HDF5 function */ - if((ret_value = H5F__is_hdf5(name, H5P_FILE_ACCESS_DEFAULT)) < 0) - HGOTO_ERROR(H5E_FILE, H5E_NOTHDF5, (-1), "unable open file") + /* Check if file is accessible */ + if(H5VL_file_specific(NULL, H5VL_FILE_IS_ACCESSIBLE, H5P_DATASET_XFER_DEFAULT, H5_REQUEST_NULL, H5P_FILE_ACCESS_DEFAULT, name, &ret_value) < 0) + HGOTO_ERROR(H5E_FILE, H5E_NOTHDF5, (-1), "unable to determine if file is accessible as HDF5") done: - FUNC_LEAVE_API(ret_value) } /* end H5Fis_hdf5() */ @@ -209,16 +201,13 @@ done: * *------------------------------------------------------------------------- */ -/* XXX (VOL MERGE): This could go in the native VOL driver under 'optional'. - */ herr_t H5Fset_latest_format(hid_t file_id, hbool_t latest_format) { H5VL_object_t *vol_obj; /* File as VOL object */ - H5F_t *f; /* File */ - H5F_libver_t low = H5F_LIBVER_LATEST; /* Low bound */ - H5F_libver_t high = H5F_LIBVER_LATEST; /* High bound */ - herr_t ret_value = SUCCEED; /* Return value */ + H5F_libver_t low = H5F_LIBVER_LATEST; /* Low bound */ + H5F_libver_t high = H5F_LIBVER_LATEST; /* High bound */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_API(FAIL) H5TRACE2("e", "ib", file_id, latest_format); @@ -226,17 +215,20 @@ H5Fset_latest_format(hid_t file_id, hbool_t latest_format) /* Check args */ if(NULL == (vol_obj = (H5VL_object_t *)H5I_object_verify(file_id, H5I_FILE))) HGOTO_ERROR(H5E_FILE, H5E_BADVALUE, FAIL, "not a file ID") - f = (H5F_t *)(vol_obj->data); + + /* Set up collective metadata if appropriate */ + if(H5CX_set_loc(file_id) < 0) + HGOTO_ERROR(H5E_FILE, H5E_CANTSET, FAIL, "can't set collective metadata read info") /* 'low' and 'high' are both initialized to LATEST. * If latest format is not expected, set 'low' to EARLIEST - */ + */ if(!latest_format) low = H5F_LIBVER_EARLIEST; - /* Call private set_libver_bounds function to set the bounds */ - if(H5F__set_libver_bounds(f, low, high) < 0) - HGOTO_ERROR(H5E_FILE, H5E_CANTSET, FAIL, "cannot set low/high bounds") + /* Set the library's version bounds */ + if(H5VL_file_optional(vol_obj, H5P_DATASET_XFER_DEFAULT, H5_REQUEST_NULL, H5VL_NATIVE_FILE_SET_LIBVER_BOUNDS, (int)low, (int)high) < 0) + HGOTO_ERROR(H5E_FILE, H5E_CANTSET, FAIL, "can't set library version bounds") done: FUNC_LEAVE_API(ret_value) diff --git a/src/H5Fint.c b/src/H5Fint.c index 1a0c8b9..8de1769 100644 --- a/src/H5Fint.c +++ b/src/H5Fint.c @@ -37,8 +37,9 @@ #include "H5Pprivate.h" /* Property lists */ #include "H5SMprivate.h" /* Shared Object Header Messages */ #include "H5Tprivate.h" /* Datatypes */ -#include "H5VLprivate.h" /* VOL drivers */ -#include "H5VLnative_private.h" /* Native VOL driver */ +#include "H5VLprivate.h" /* Virtual Object Layer */ + +#include "H5VLnative_private.h" /* Native VOL connector */ /****************/ @@ -75,10 +76,12 @@ typedef struct H5F_olist_t { /* Local Prototypes */ /********************/ +static herr_t H5F__set_vol_conn(H5F_t *file, hid_t vol_id, const void *vol_info); static herr_t H5F__get_objects(const H5F_t *f, unsigned types, size_t max_index, hid_t *obj_id_list, hbool_t app_ref, size_t *obj_id_count_ptr); static int H5F__get_objects_cb(void *obj_ptr, hid_t obj_id, void *key); static herr_t H5F__build_name(const char *prefix, const char *file_name, char **full_name/*out*/); static char *H5F__getenv_prefix_name(char **env_prefix/*in,out*/); +static H5F_t *H5F__new(H5F_file_t *shared, unsigned flags, hid_t fcpl_id, hid_t fapl_id, H5FD_t *lf); static herr_t H5F__build_actual_name(const H5F_t *f, const H5P_genplist_t *fapl, const char *name, char ** /*out*/ actual_name); static herr_t H5F__flush_phase1(H5F_t *f); static herr_t H5F__flush_phase2(H5F_t *f, hbool_t closing); @@ -107,6 +110,50 @@ H5FL_DEFINE(H5F_file_t); /*------------------------------------------------------------------------- + * Function: H5F__set_vol_conn + * + * Purpose: Set the VOL connector ID and info for a file. + * + * Return: SUCCEED/FAIL + * + *------------------------------------------------------------------------- + */ +static herr_t +H5F__set_vol_conn(H5F_t *file, hid_t vol_id, const void *vol_info) +{ + void *new_connector_info = NULL; /* Copy of connector info */ + herr_t ret_value = SUCCEED; /* Return value */ + + FUNC_ENTER_STATIC + + /* Sanity check */ + HDassert(file); + + /* Copy connector info, if it exists */ + if(vol_info) { + H5VL_class_t *connector; /* Pointer to connector */ + + /* Retrieve the connector for the ID */ + if(NULL == (connector = (H5VL_class_t *)H5I_object(vol_id))) + HGOTO_ERROR(H5E_FILE, H5E_BADTYPE, FAIL, "not a VOL connector ID") + + /* Allocate and copy connector info */ + if(H5VL_copy_connector_info(connector, &new_connector_info, vol_info) < 0) + HGOTO_ERROR(H5E_FILE, H5E_CANTCOPY, FAIL, "connector info copy failed") + } /* end if */ + + /* Cache the connector ID & info for the container */ + file->shared->vol_id = vol_id; + file->shared->vol_info = new_connector_info; + if(H5I_inc_ref(file->shared->vol_id, FALSE) < 0) + HGOTO_ERROR(H5E_FILE, H5E_CANTINC, FAIL, "incrementing VOL connector ID failed") + +done: + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5F__set_vol_conn() */ + + +/*------------------------------------------------------------------------- * Function: H5F_get_access_plist * * Purpose: Returns a copy of the file access property list of the @@ -129,6 +176,7 @@ H5F_get_access_plist(H5F_t *f, hbool_t app_ref) H5P_genplist_t *old_plist; /* Old property list */ H5FD_driver_prop_t driver_prop; /* Property for driver ID & info */ hbool_t driver_prop_copied = FALSE; /* Whether the driver property has been set up */ + H5VL_connector_prop_t connector_prop; /* Property for VOL connector ID & info */ unsigned efc_size = 0; hid_t ret_value = H5I_INVALID_HID; /* Return value */ @@ -141,60 +189,60 @@ H5F_get_access_plist(H5F_t *f, hbool_t app_ref) if(NULL == (old_plist = (H5P_genplist_t *)H5I_object(H5P_LST_FILE_ACCESS_ID_g))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, H5I_INVALID_HID, "not a property list") if((ret_value = H5P_copy_plist(old_plist, app_ref)) < 0) - HGOTO_ERROR(H5E_PLIST, H5E_CANTINIT, H5I_INVALID_HID, "can't copy file access property list") + HGOTO_ERROR(H5E_FILE, H5E_CANTINIT, H5I_INVALID_HID, "can't copy file access property list") if(NULL == (new_plist = (H5P_genplist_t *)H5I_object(ret_value))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, H5I_INVALID_HID, "not a property list") /* Copy properties of the file access property list */ if(H5P_set(new_plist, H5F_ACS_META_CACHE_INIT_CONFIG_NAME, &(f->shared->mdc_initCacheCfg)) < 0) - HGOTO_ERROR(H5E_PLIST, H5E_CANTSET, H5I_INVALID_HID, "can't set initial metadata cache resize config.") + HGOTO_ERROR(H5E_FILE, H5E_CANTSET, H5I_INVALID_HID, "can't set initial metadata cache resize config.") if(H5P_set(new_plist, H5F_ACS_DATA_CACHE_NUM_SLOTS_NAME, &(f->shared->rdcc_nslots)) < 0) - HGOTO_ERROR(H5E_PLIST, H5E_CANTSET, H5I_INVALID_HID, "can't set data cache number of slots") + HGOTO_ERROR(H5E_FILE, H5E_CANTSET, H5I_INVALID_HID, "can't set data cache number of slots") if(H5P_set(new_plist, H5F_ACS_DATA_CACHE_BYTE_SIZE_NAME, &(f->shared->rdcc_nbytes)) < 0) - HGOTO_ERROR(H5E_PLIST, H5E_CANTSET, H5I_INVALID_HID, "can't set data cache byte size") + HGOTO_ERROR(H5E_FILE, H5E_CANTSET, H5I_INVALID_HID, "can't set data cache byte size") if(H5P_set(new_plist, H5F_ACS_PREEMPT_READ_CHUNKS_NAME, &(f->shared->rdcc_w0)) < 0) - HGOTO_ERROR(H5E_PLIST, H5E_CANTSET, H5I_INVALID_HID, "can't set preempt read chunks") + HGOTO_ERROR(H5E_FILE, H5E_CANTSET, H5I_INVALID_HID, "can't set preempt read chunks") if(H5P_set(new_plist, H5F_ACS_ALIGN_THRHD_NAME, &(f->shared->threshold)) < 0) - HGOTO_ERROR(H5E_PLIST, H5E_CANTSET, H5I_INVALID_HID, "can't set alignment threshold") + HGOTO_ERROR(H5E_FILE, H5E_CANTSET, H5I_INVALID_HID, "can't set alignment threshold") if(H5P_set(new_plist, H5F_ACS_ALIGN_NAME, &(f->shared->alignment)) < 0) - HGOTO_ERROR(H5E_PLIST, H5E_CANTSET, H5I_INVALID_HID, "can't set alignment") + HGOTO_ERROR(H5E_FILE, H5E_CANTSET, H5I_INVALID_HID, "can't set alignment") if(H5P_set(new_plist, H5F_ACS_GARBG_COLCT_REF_NAME, &(f->shared->gc_ref)) < 0) - HGOTO_ERROR(H5E_PLIST, H5E_CANTSET, H5I_INVALID_HID, "can't set garbage collect reference") + HGOTO_ERROR(H5E_FILE, H5E_CANTSET, H5I_INVALID_HID, "can't set garbage collect reference") if(H5P_set(new_plist, H5F_ACS_META_BLOCK_SIZE_NAME, &(f->shared->meta_aggr.alloc_size)) < 0) - HGOTO_ERROR(H5E_PLIST, H5E_CANTSET, H5I_INVALID_HID, "can't set metadata cache size") + HGOTO_ERROR(H5E_FILE, H5E_CANTSET, H5I_INVALID_HID, "can't set metadata cache size") if(H5P_set(new_plist, H5F_ACS_SIEVE_BUF_SIZE_NAME, &(f->shared->sieve_buf_size)) < 0) - HGOTO_ERROR(H5E_PLIST, H5E_CANTSET, H5I_INVALID_HID, "can't sieve buffer size") + HGOTO_ERROR(H5E_FILE, H5E_CANTSET, H5I_INVALID_HID, "can't sieve buffer size") if(H5P_set(new_plist, H5F_ACS_SDATA_BLOCK_SIZE_NAME, &(f->shared->sdata_aggr.alloc_size)) < 0) - HGOTO_ERROR(H5E_PLIST, H5E_CANTSET, H5I_INVALID_HID, "can't set 'small data' cache size") + HGOTO_ERROR(H5E_FILE, H5E_CANTSET, H5I_INVALID_HID, "can't set 'small data' cache size") if(H5P_set(new_plist, H5F_ACS_LIBVER_LOW_BOUND_NAME, &f->shared->low_bound) < 0) - HGOTO_ERROR(H5E_PLIST, H5E_CANTSET, H5I_INVALID_HID, "can't set 'low' bound for library format versions") + HGOTO_ERROR(H5E_FILE, H5E_CANTSET, H5I_INVALID_HID, "can't set 'low' bound for library format versions") if(H5P_set(new_plist, H5F_ACS_LIBVER_HIGH_BOUND_NAME, &f->shared->high_bound) < 0) - HGOTO_ERROR(H5E_PLIST, H5E_CANTSET, H5I_INVALID_HID, "can't set 'high' bound for library format versions") + HGOTO_ERROR(H5E_FILE, H5E_CANTSET, H5I_INVALID_HID, "can't set 'high' bound for library format versions") if(H5P_set(new_plist, H5F_ACS_METADATA_READ_ATTEMPTS_NAME, &(f->shared->read_attempts)) < 0) - HGOTO_ERROR(H5E_PLIST, H5E_CANTSET, H5I_INVALID_HID, "can't set 'read attempts ' flag") + HGOTO_ERROR(H5E_FILE, H5E_CANTSET, H5I_INVALID_HID, "can't set 'read attempts ' flag") if(H5P_set(new_plist, H5F_ACS_OBJECT_FLUSH_CB_NAME, &(f->shared->object_flush)) < 0) - HGOTO_ERROR(H5E_PLIST, H5E_CANTSET, H5I_INVALID_HID, "can't set object flush callback") + HGOTO_ERROR(H5E_FILE, H5E_CANTSET, H5I_INVALID_HID, "can't set object flush callback") if(f->shared->efc) efc_size = H5F__efc_max_nfiles(f->shared->efc); if(H5P_set(new_plist, H5F_ACS_EFC_SIZE_NAME, &efc_size) < 0) - HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, H5I_INVALID_HID, "can't set elink file cache size") + HGOTO_ERROR(H5E_FILE, H5E_CANTGET, H5I_INVALID_HID, "can't set elink file cache size") if(f->shared->page_buf != NULL) { if(H5P_set(new_plist, H5F_ACS_PAGE_BUFFER_SIZE_NAME, &(f->shared->page_buf->max_size)) < 0) - HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, H5I_INVALID_HID, "can't set page buffer size") + HGOTO_ERROR(H5E_FILE, H5E_CANTGET, H5I_INVALID_HID, "can't set page buffer size") if(H5P_set(new_plist, H5F_ACS_PAGE_BUFFER_MIN_META_PERC_NAME, &(f->shared->page_buf->min_meta_perc)) < 0) - HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, H5I_INVALID_HID, "can't set minimum metadata fraction of page buffer") + HGOTO_ERROR(H5E_FILE, H5E_CANTGET, H5I_INVALID_HID, "can't set minimum metadata fraction of page buffer") if(H5P_set(new_plist, H5F_ACS_PAGE_BUFFER_MIN_RAW_PERC_NAME, &(f->shared->page_buf->min_raw_perc)) < 0) - HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, H5I_INVALID_HID, "can't set minimum raw data fraction of page buffer") + HGOTO_ERROR(H5E_FILE, H5E_CANTGET, H5I_INVALID_HID, "can't set minimum raw data fraction of page buffer") } /* end if */ #ifdef H5_HAVE_PARALLEL if(H5P_set(new_plist, H5_COLL_MD_READ_FLAG_NAME, &(f->coll_md_read)) < 0) - HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, H5I_INVALID_HID, "can't set collective metadata read flag") + HGOTO_ERROR(H5E_FILE, H5E_CANTGET, H5I_INVALID_HID, "can't set collective metadata read flag") if(H5P_set(new_plist, H5F_ACS_COLL_MD_WRITE_FLAG_NAME, &(f->coll_md_write)) < 0) - HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, H5I_INVALID_HID, "can't set collective metadata read flag") + HGOTO_ERROR(H5E_FILE, H5E_CANTGET, H5I_INVALID_HID, "can't set collective metadata read flag") #endif /* H5_HAVE_PARALLEL */ if(H5P_set(new_plist, H5F_ACS_META_CACHE_INIT_IMAGE_CONFIG_NAME, &(f->shared->mdc_initCacheImageCfg)) < 0) - HGOTO_ERROR(H5E_PLIST, H5E_CANTSET, H5I_INVALID_HID, "can't set initial metadata cache resize config.") + HGOTO_ERROR(H5E_FILE, H5E_CANTSET, H5I_INVALID_HID, "can't set initial metadata cache resize config.") /* Prepare the driver property */ driver_prop.driver_id = f->shared->lf->driver_id; @@ -203,13 +251,19 @@ H5F_get_access_plist(H5F_t *f, hbool_t app_ref) /* Set the driver property */ if(H5P_set(new_plist, H5F_ACS_FILE_DRV_NAME, &driver_prop) < 0) - HGOTO_ERROR(H5E_PLIST, H5E_CANTSET, H5I_INVALID_HID, "can't set file driver ID & info") + HGOTO_ERROR(H5E_FILE, H5E_CANTSET, H5I_INVALID_HID, "can't set file driver ID & info") + + /* Set the VOL connector property */ + connector_prop.connector_id = f->shared->vol_id; + connector_prop.connector_info = f->shared->vol_info; + if(H5P_set(new_plist, H5F_ACS_VOL_CONN_NAME, &connector_prop) < 0) + HGOTO_ERROR(H5E_FILE, H5E_CANTSET, H5I_INVALID_HID, "can't set VOL connector ID & info") /* Set the file close degree appropriately */ if(f->shared->fc_degree == H5F_CLOSE_DEFAULT && H5P_set(new_plist, H5F_ACS_CLOSE_DEGREE_NAME, &(f->shared->lf->cls->fc_degree)) < 0) - HGOTO_ERROR(H5E_PLIST, H5E_CANTSET, H5I_INVALID_HID, "can't set file close degree") + HGOTO_ERROR(H5E_FILE, H5E_CANTSET, H5I_INVALID_HID, "can't set file close degree") else if(f->shared->fc_degree != H5F_CLOSE_DEFAULT && H5P_set(new_plist, H5F_ACS_CLOSE_DEGREE_NAME, &(f->shared->fc_degree)) < 0) - HGOTO_ERROR(H5E_PLIST, H5E_CANTSET, H5I_INVALID_HID, "can't set file close degree") + HGOTO_ERROR(H5E_FILE, H5E_CANTSET, H5I_INVALID_HID, "can't set file close degree") done: /* Release the copy of the driver info, if it was set up */ @@ -307,11 +361,11 @@ H5F__get_objects(const H5F_t *f, unsigned types, size_t max_nobjs, hid_t *obj_id if(types & H5F_OBJ_LOCAL) { olist.file_info.local = TRUE; olist.file_info.ptr.file = f; - } + } /* end if */ else { olist.file_info.local = FALSE; olist.file_info.ptr.shared = f ? f->shared : NULL; - } + } /* end else */ /* Iterate through file IDs to count the number, and put their * IDs on the object list. */ @@ -319,7 +373,7 @@ H5F__get_objects(const H5F_t *f, unsigned types, size_t max_nobjs, hid_t *obj_id olist.obj_type = H5I_FILE; if(H5I_iterate(H5I_FILE, H5F__get_objects_cb, &olist, app_ref) < 0) HGOTO_ERROR(H5E_FILE, H5E_BADITER, FAIL, "iteration failed(1)") - } + } /* end if */ /* If the caller just wants to count the number of objects (OLIST.MAX_NOBJS is zero), * or the caller wants to get the list of IDs and the list isn't full, @@ -330,8 +384,8 @@ H5F__get_objects(const H5F_t *f, unsigned types, size_t max_nobjs, hid_t *obj_id olist.obj_type = H5I_DATASET; if(H5I_iterate(H5I_DATASET, H5F__get_objects_cb, &olist, app_ref) < 0) HGOTO_ERROR(H5E_FILE, H5E_BADITER, FAIL, "iteration failed(2)") - } - } + } /* end if */ + } /* end if */ /* If the caller just wants to count the number of objects (OLIST.MAX_NOBJS is zero), * or the caller wants to get the list of IDs and the list isn't full, @@ -342,8 +396,8 @@ H5F__get_objects(const H5F_t *f, unsigned types, size_t max_nobjs, hid_t *obj_id olist.obj_type = H5I_GROUP; if(H5I_iterate(H5I_GROUP, H5F__get_objects_cb, &olist, app_ref) < 0) HGOTO_ERROR(H5E_FILE, H5E_BADITER, FAIL, "iteration failed(3)") - } - } + } /* end if */ + } /* end if */ /* If the caller just wants to count the number of objects (OLIST.MAX_NOBJS is zero), * or the caller wants to get the list of IDs and the list isn't full, @@ -354,8 +408,8 @@ H5F__get_objects(const H5F_t *f, unsigned types, size_t max_nobjs, hid_t *obj_id olist.obj_type = H5I_DATATYPE; if(H5I_iterate(H5I_DATATYPE, H5F__get_objects_cb, &olist, app_ref) < 0) HGOTO_ERROR(H5E_FILE, H5E_BADITER, FAIL, "iteration failed(4)") - } - } + } /* end if */ + } /* end if */ /* If the caller just wants to count the number of objects (OLIST.MAX_NOBJS is zero), * or the caller wants to get the list of IDs and the list isn't full, @@ -366,8 +420,8 @@ H5F__get_objects(const H5F_t *f, unsigned types, size_t max_nobjs, hid_t *obj_id olist.obj_type = H5I_ATTR; if(H5I_iterate(H5I_ATTR, H5F__get_objects_cb, &olist, app_ref) < 0) HGOTO_ERROR(H5E_FILE, H5E_BADITER, FAIL, "iteration failed(5)") - } - } + } /* end if */ + } /* end if */ /* Set the number of objects currently open */ *obj_id_count_ptr = obj_id_count; @@ -409,8 +463,8 @@ H5F__get_objects_cb(void *obj_ptr, hid_t obj_id, void *key) (!olist->file_info.ptr.shared || (olist->file_info.ptr.shared && ((H5F_t*)obj_ptr)->shared == olist->file_info.ptr.shared)))) { add_obj = TRUE; - } - } + } /* end if */ + } /* end if */ else { /* Either count opened object IDs or put the IDs on the list */ H5O_loc_t *oloc; /* Group entry info for object */ @@ -438,7 +492,6 @@ H5F__get_objects_cb(void *obj_ptr, hid_t obj_id, void *key) case H5I_BADID: case H5I_FILE: case H5I_DATASPACE: - case H5I_REFERENCE: case H5I_VFL: case H5I_VOL: case H5I_GENPROP_CLS: @@ -460,7 +513,7 @@ H5F__get_objects_cb(void *obj_ptr, hid_t obj_id, void *key) (!olist->file_info.ptr.shared && olist->obj_type != H5I_DATATYPE) || (oloc && oloc->file && oloc->file->shared == olist->file_info.ptr.shared)))) { add_obj = TRUE; - } + } /* end if */ } /* end else */ if(add_obj) { @@ -468,7 +521,7 @@ H5F__get_objects_cb(void *obj_ptr, hid_t obj_id, void *key) if(olist->obj_id_list) { olist->obj_id_list[olist->list_index] = obj_id; olist->list_index++; - } + } /* end if */ /* Increment the number of open objects */ if(olist->obj_id_count) @@ -481,7 +534,7 @@ H5F__get_objects_cb(void *obj_ptr, hid_t obj_id, void *key) */ if(olist->max_nobjs > 0 && olist->list_index >= olist->max_nobjs) HGOTO_DONE(H5_ITER_STOP) /* Indicate that the iterator should stop */ - } + } /* end if */ done: FUNC_LEAVE_NOAPI(ret_value) @@ -835,13 +888,13 @@ done: * *------------------------------------------------------------------------- */ -H5F_t * +static H5F_t * H5F__new(H5F_file_t *shared, unsigned flags, hid_t fcpl_id, hid_t fapl_id, H5FD_t *lf) { H5F_t *f = NULL; H5F_t *ret_value = NULL; - FUNC_ENTER_PACKAGE + FUNC_ENTER_STATIC if(NULL == (f = H5FL_CALLOC(H5F_t))) HGOTO_ERROR(H5E_FILE, H5E_NOSPACE, NULL, "can't allocate top file structure") @@ -1005,12 +1058,12 @@ H5F__new(H5F_file_t *shared, unsigned flags, hid_t fcpl_id, hid_t fapl_id, H5FD_ f->shared->feature_flags &= ~(unsigned)H5FD_FEAT_ACCUMULATE_METADATA; if(H5FD_set_feature_flags(f->shared->lf, f->shared->feature_flags) < 0) HGOTO_ERROR(H5E_FILE, H5E_CANTSET, NULL, "can't set feature_flags in VFD") - } + } /* end if */ else { /* If no value for read attempts has been set, use the default */ if(!f->shared->read_attempts) f->shared->read_attempts = H5F_METADATA_READ_ATTEMPTS; - } + } /* end else */ /* Determine the # of bins for metdata read retries */ if(H5F_set_retries(f) < 0) @@ -1036,6 +1089,16 @@ H5F__new(H5F_file_t *shared, unsigned flags, hid_t fcpl_id, hid_t fapl_id, H5FD_ if(H5P_get(plist, H5F_ACS_OBJECT_FLUSH_CB_NAME, &(f->shared->object_flush)) < 0) HGOTO_ERROR(H5E_FILE, H5E_CANTGET, NULL, "can't get object flush cb info") + /* Get the VOL connector info */ + { + H5VL_connector_prop_t connector_prop; /* Property for VOL connector ID & info */ + + if(H5P_peek(plist, H5F_ACS_VOL_CONN_NAME, &connector_prop) < 0) + HGOTO_ERROR(H5E_FILE, H5E_CANTGET, NULL, "can't get VOL connector info") + if(H5F__set_vol_conn(f, connector_prop.connector_id, connector_prop.connector_info) < 0) + HGOTO_ERROR(H5E_FILE, H5E_CANTINIT, NULL, "can't cache VOL connector info") + } /* end block */ + /* Create a metadata cache with the specified number of elements. * The cache might be created with a different number of elements and * the access property list should be updated to reflect that. @@ -1296,6 +1359,25 @@ H5F__dest(H5F_t *f, hbool_t flush) /* Push error, but keep going*/ HDONE_ERROR(H5E_FILE, H5E_CANTDEC, FAIL, "can't close property list") + /* Clean up the cached VOL connector ID & info */ + if(f->shared->vol_info) { + H5VL_class_t *connector; /* Pointer to connector */ + + /* Retrieve the connector for the ID */ + if(NULL == (connector = (H5VL_class_t *)H5I_object(f->shared->vol_id))) + /* Push error, but keep going*/ + HDONE_ERROR(H5E_FILE, H5E_BADTYPE, FAIL, "not a VOL connector ID") + + /* Free the connector info */ + if(H5VL_free_connector_info(connector, f->shared->vol_info) < 0) + /* Push error, but keep going*/ + HDONE_ERROR(H5E_FILE, H5E_CANTRELEASE, FAIL, "unable to release VOL connector info object") + } /* end if */ + if(f->shared->vol_id > 0) + if(H5I_dec_ref(f->shared->vol_id) < 0) + /* Push error, but keep going*/ + HDONE_ERROR(H5E_FILE, H5E_CANTDEC, FAIL, "can't close VOL connector ID") + /* Close the file */ if(H5FD_close(f->shared->lf) < 0) /* Push error, but keep going*/ @@ -1535,7 +1617,7 @@ H5F_open(const char *name, unsigned flags, hid_t fcpl_id, hid_t fapl_id) /* Create the 'top' file structure */ if(NULL == (file = H5F__new(NULL, flags, fcpl_id, fapl_id, lf))) { /* If this is the only time the file has been opened and the struct - * returned is NULL, H5FD_close() will never be called via H5F_dest() + * returned is NULL, H5FD_close() will never be called via H5F__dest() * so we have to close lf here before heading to the error handling. */ if(H5FD_close(lf) < 0) @@ -1634,16 +1716,6 @@ H5F_open(const char *name, unsigned flags, hid_t fcpl_id, hid_t fapl_id) */ if(H5P_get(a_plist, H5F_ACS_CLOSE_DEGREE_NAME, &fc_degree) < 0) HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, NULL, "can't get file close degree") - - /* This is a private property to clear the status_flags in the super block */ - /* Use by h5clear and a routine in test/flush2.c to clear the test file's status_flags */ - if(H5P_exist_plist(a_plist, H5F_ACS_CLEAR_STATUS_FLAGS_NAME) > 0) { - if(H5P_get(a_plist, H5F_ACS_CLEAR_STATUS_FLAGS_NAME, &clear) < 0) - HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, NULL, "can't get clearance for status_flags") - else if(clear) - file->shared->sblock->status_flags = 0; - } /* end if */ - if(shared->nrefs == 1) { if(fc_degree == H5F_CLOSE_DEFAULT) shared->fc_degree = lf->cls->fc_degree; @@ -1657,6 +1729,15 @@ H5F_open(const char *name, unsigned flags, hid_t fcpl_id, hid_t fapl_id) HGOTO_ERROR(H5E_FILE, H5E_CANTINIT, NULL, "file close degree doesn't match") } /* end if */ + /* This is a private property to clear the status_flags in the super block */ + /* Use by h5clear and a routine in test/flush2.c to clear the test file's status_flags */ + if(H5P_exist_plist(a_plist, H5F_ACS_CLEAR_STATUS_FLAGS_NAME) > 0) { + if(H5P_get(a_plist, H5F_ACS_CLEAR_STATUS_FLAGS_NAME, &clear) < 0) + HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, NULL, "can't get clearance for status_flags") + else if(clear) + file->shared->sblock->status_flags = 0; + } /* end if */ + /* Record the evict-on-close MDC behavior. If it's the first time opening * the file, set it to access property list value; if it's the second time * or later, verify that the access property list value matches the value @@ -2099,7 +2180,7 @@ H5F_try_close(H5F_t *f, hbool_t *was_closed /*out*/) /* Delay flush until the shared file struct is closed, in H5F__dest. If the * application called H5Fclose, it would have been flushed in that function - * (unless it will have been flushed in H5F_dest anyways). + * (unless it will have been flushed in H5F__dest anyways). */ /* Destroy the H5F_t struct and decrement the reference count for the @@ -2135,7 +2216,7 @@ done: H5F_t * H5F__reopen(H5F_t *f) { - H5F_t *ret_value = NULL; + H5F_t *ret_value = NULL; /* Return value */ FUNC_ENTER_PACKAGE @@ -2166,7 +2247,7 @@ done: *------------------------------------------------------------------------- */ hid_t -H5F_get_id(H5F_t *file, hbool_t app_ref) +H5F_get_id(H5F_t *file) { hid_t ret_value = H5I_INVALID_HID; /* Return value */ @@ -2175,16 +2256,16 @@ H5F_get_id(H5F_t *file, hbool_t app_ref) HDassert(file); if(H5I_find_id(file, H5I_FILE, &ret_value) < 0 || H5I_INVALID_HID == ret_value) { - /* resurrect the ID - Register an ID with the native driver */ - if((ret_value = H5VL_native_register(H5I_FILE, file, app_ref)) < 0) + /* resurrect the ID - Register an ID with the native connector */ + if((ret_value = H5VL_wrap_register(H5I_FILE, file, FALSE)) < 0) HGOTO_ERROR(H5E_ATOM, H5E_CANTREGISTER, H5I_INVALID_HID, "unable to register group") file->id_exists = TRUE; - } + } /* end if */ else { /* Increment reference count on existing ID */ - if(H5I_inc_ref(ret_value, app_ref) < 0) - HGOTO_ERROR(H5E_ATOM, H5E_CANTSET, H5I_INVALID_HID, "incrementing file ID failed") - } + if(H5I_inc_ref(ret_value, FALSE) < 0) + HGOTO_ERROR(H5E_ATOM, H5E_CANTINC, H5I_INVALID_HID, "incrementing file ID failed") + } /* end else */ done: FUNC_LEAVE_NOAPI(ret_value) @@ -2999,6 +3080,7 @@ H5F__set_eoa(const H5F_t *f, H5F_mem_t type, haddr_t addr) HDassert(f->shared); /* Dispatch to driver */ + /* (H5FD_set_eoa() will add base_addr to addr) */ if(H5FD_set_eoa(f->shared->lf, type, addr) < 0) HGOTO_ERROR(H5E_FILE, H5E_CANTSET, FAIL, "driver set_eoa request failed") @@ -3234,7 +3316,7 @@ H5F__start_swmr_write(H5F_t *f) H5G_name_t *obj_paths = NULL; /* Group hierarchy path */ size_t u; /* Local index variable */ hbool_t setup = FALSE; /* Boolean flag to indicate whether SWMR setting is enabled */ - H5VL_t *vol_driver = NULL; /* VOL driver for the file */ + H5VL_t *vol_connector = NULL; /* VOL connector for the file */ herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_PACKAGE @@ -3274,16 +3356,16 @@ H5F__start_swmr_write(H5F_t *f) HGOTO_ERROR(H5E_FILE, H5E_CANTFLUSH, FAIL, "unable to flush file's cached information") /* Get the # of opened named datatypes and attributes */ - if(H5F_get_obj_count(f, H5F_OBJ_DATATYPE|H5F_OBJ_ATTR, FALSE, &nt_attr_count) < 0) + if(H5F_get_obj_count(f, H5F_OBJ_DATATYPE | H5F_OBJ_ATTR, FALSE, &nt_attr_count) < 0) HGOTO_ERROR(H5E_FILE, H5E_BADITER, FAIL, "H5F_get_obj_count failed") - if(nt_attr_count) + if(nt_attr_count > 0) HGOTO_ERROR(H5E_FILE, H5E_BADVALUE, FAIL, "named datatypes and/or attributes opened in the file") /* Get the # of opened datasets and groups */ - if(H5F_get_obj_count(f, H5F_OBJ_GROUP|H5F_OBJ_DATASET, FALSE, &grp_dset_count) < 0) + if(H5F_get_obj_count(f, H5F_OBJ_GROUP | H5F_OBJ_DATASET, FALSE, &grp_dset_count) < 0) HGOTO_ERROR(H5E_FILE, H5E_BADITER, FAIL, "H5F_get_obj_count failed") - if(grp_dset_count) { + if(grp_dset_count > 0) { /* Allocate space for group and object locations */ if((obj_ids = (hid_t *) H5MM_malloc(grp_dset_count * sizeof(hid_t))) == NULL) HGOTO_ERROR(H5E_FILE, H5E_NOSPACE, FAIL, "can't allocate buffer for hid_t") @@ -3298,17 +3380,20 @@ H5F__start_swmr_write(H5F_t *f) if(H5F_get_obj_ids(f, H5F_OBJ_GROUP|H5F_OBJ_DATASET, grp_dset_count, obj_ids, FALSE, &grp_dset_count) < 0) HGOTO_ERROR(H5E_FILE, H5E_CANTGET, FAIL, "H5F_get_obj_ids failed") - /* Save the VOL driver for the refresh step */ + /* Save the VOL connector and the object wrapping context for the refresh step */ if(grp_dset_count > 0) { - H5VL_object_t *vol_obj = NULL; + H5VL_object_t *vol_obj; + /* Get the VOL object for one of the IDs */ if(NULL == (vol_obj = H5VL_vol_object(obj_ids[0]))) - HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "invalid object identifier") + HGOTO_ERROR(H5E_FILE, H5E_BADTYPE, FAIL, "invalid object identifier") - vol_driver = vol_obj->driver; - } + /* Get the (top) connector for the ID */ + vol_connector = vol_obj->connector; + } /* end if */ - /* Refresh opened objects (groups, datasets) in the file */ + /* Gather information about opened objects (groups, datasets) in the file */ + /* (For refresh later on) */ for(u = 0; u < grp_dset_count; u++) { H5O_loc_t *oloc; /* object location */ H5G_loc_t tmp_loc; @@ -3369,10 +3454,9 @@ H5F__start_swmr_write(H5F_t *f) HGOTO_ERROR(H5E_FILE, H5E_CANTFLUSH, FAIL, "unable to evict file's cached information") /* Refresh (reopen) the objects (groups & datasets) in the file */ - for(u = 0; u < grp_dset_count; u++) { - if(H5O_refresh_metadata_reopen(obj_ids[u], &obj_glocs[u], vol_driver, TRUE) < 0) + for(u = 0; u < grp_dset_count; u++) + if(H5O_refresh_metadata_reopen(obj_ids[u], &obj_glocs[u], vol_connector, TRUE) < 0) HGOTO_ERROR(H5E_ATOM, H5E_CLOSEERROR, FAIL, "can't refresh-close object") - } /* Unlock the file */ if(H5FD_unlock(f->shared->lf) < 0) @@ -3482,3 +3566,152 @@ done: FUNC_LEAVE_NOAPI(ret_value) } /* H5F__format_convert() */ + +/*--------------------------------------------------------------------------- + * Function: H5F__get_file + * + * Purpose: Utility routine to get file struct for an object + * + * Returns: SUCCESS: A pointer to the H5F_t struct for the file + * associated with the object. + * FAILURE: NULL + * + *--------------------------------------------------------------------------- + */ +H5F_t * +H5F__get_file(void *obj, H5I_type_t type) +{ + H5F_t *ret_value = NULL; /* File pointer */ + H5O_loc_t *oloc = NULL; /* Object location for ID */ + + FUNC_ENTER_PACKAGE + + switch(type) { + case H5I_FILE: + ret_value = (H5F_t *)obj; + break; + + case H5I_GROUP: + oloc = H5G_oloc((H5G_t *)obj); + break; + + case H5I_DATATYPE: + oloc = H5T_oloc((H5T_t *)obj); + break; + + case H5I_DATASET: + oloc = H5D_oloc((H5D_t *)obj); + break; + + case H5I_ATTR: + oloc = H5A_oloc((H5A_t *)obj); + break; + + case H5I_UNINIT: + case H5I_BADID: + case H5I_DATASPACE: + case H5I_VFL: + case H5I_VOL: + case H5I_GENPROP_CLS: + case H5I_GENPROP_LST: + case H5I_ERROR_CLASS: + case H5I_ERROR_MSG: + case H5I_ERROR_STACK: + case H5I_NTYPES: + default: + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, NULL, "not a file or file object") + } /* end switch */ + + /* Set return value for objects (not files) */ + if(oloc) + ret_value = oloc->file; + + /* Couldn't find a file struct */ + if(!ret_value) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, NULL, "object is not associated with a file") + +done: + FUNC_LEAVE_NOAPI(ret_value) +} /* H5F__get_file */ + + +/*------------------------------------------------------------------------- + * Function: H5F__get_file_id + * + * Purpose: The package version of H5Iget_file_id(), obtains the file + * ID given an object ID. + * + * Return: Success: The file ID associated with the object + * Failure: H5I_INVALID_HID + * + *------------------------------------------------------------------------- + */ +hid_t +H5F__get_file_id(H5F_t *file) +{ + hid_t file_id = H5I_INVALID_HID; /* File ID */ + hid_t ret_value = H5I_INVALID_HID; /* Return value */ + + FUNC_ENTER_PACKAGE + + /* Check if the file's ID already exists */ + if(H5I_find_id(file, H5I_FILE, &file_id) < 0) + HGOTO_ERROR(H5E_FILE, H5E_CANTGET, H5I_INVALID_HID, "getting file ID failed") + + /* If the ID does not exist, register it with the VOL connector */ + if(H5I_INVALID_HID == file_id) { + if((file_id = H5VL_wrap_register(H5I_FILE, file, TRUE)) < 0) + HGOTO_ERROR(H5E_FILE, H5E_CANTREGISTER, H5I_INVALID_HID, "unable to atomize file handle") + file->id_exists = TRUE; + } /* end if */ + else { + /* Increment ref count on existing ID */ + if(H5I_inc_ref(file_id, TRUE) < 0) + HGOTO_ERROR(H5E_FILE, H5E_CANTSET, H5I_INVALID_HID, "incrementing file ID failed") + } /* end else */ + + /* Set return value */ + ret_value = file_id; + +done: + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5F__get_file_id() */ + + +/*------------------------------------------------------------------------- + * Function: H5F_get_file_id + * + * Purpose: The private version of H5Iget_file_id(), obtains the file + * ID given an object ID. + * + * Return: Success: The file ID associated with the object + * Failure: H5I_INVALID_HID + * + *------------------------------------------------------------------------- + */ +hid_t +H5F_get_file_id(hid_t obj_id, H5I_type_t type) +{ + H5VL_object_t *vol_obj; /* File info */ + hid_t file_id = H5I_INVALID_HID; /* File ID for object */ + hid_t ret_value = H5I_INVALID_HID; /* Return value */ + + FUNC_ENTER_NOAPI(H5I_INVALID_HID) + + /* Get the object pointer */ + if(NULL == (vol_obj = H5VL_vol_object(obj_id))) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, H5I_INVALID_HID, "invalid identifier") + + /* Get the file through the VOL */ + if(H5VL_file_optional(vol_obj, H5P_DATASET_XFER_DEFAULT, H5_REQUEST_NULL, H5VL_NATIVE_FILE_GET_FILE_ID, (int)type, &file_id) < 0) + HGOTO_ERROR(H5E_FILE, H5E_CANTINIT, H5I_INVALID_HID, "unable to get file ID") + if(H5I_INVALID_HID == file_id) + HGOTO_ERROR(H5E_FILE, H5E_CANTINIT, H5I_INVALID_HID, "unable to get the file ID through the VOL") + + /* Set return value */ + ret_value = file_id; + +done: + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5F_get_file_id() */ + diff --git a/src/H5Fmount.c b/src/H5Fmount.c index 310edd4..13d95aa 100644 --- a/src/H5Fmount.c +++ b/src/H5Fmount.c @@ -477,13 +477,12 @@ H5Fmount(hid_t loc_id, const char *name, hid_t child_id, hid_t plist_id) if(NULL == (child_vol_obj = (H5VL_object_t *)H5I_object(child_id))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "could not get child object") - /* Check if both objects are associated with the same VOL plugin */ - if(loc_vol_obj->driver->cls->value != child_vol_obj->driver->cls->value) - HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "Can't mount file onto object from different VOL driver") + /* Check if both objects are associated with the same VOL connector */ + if(loc_vol_obj->connector->cls->value != child_vol_obj->connector->cls->value) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "Can't mount file onto object from different VOL connector") /* Perform the mount operation */ - if(H5VL_file_specific(loc_vol_obj->data, loc_vol_obj->driver->cls, H5VL_FILE_MOUNT, H5P_DATASET_XFER_DEFAULT, - H5_REQUEST_NULL, loc_type, name, child_vol_obj->data, plist_id) < 0) + if(H5VL_file_specific(loc_vol_obj, H5VL_FILE_MOUNT, H5P_DATASET_XFER_DEFAULT, H5_REQUEST_NULL, (int)loc_type, name, child_vol_obj->data, plist_id) < 0) HGOTO_ERROR(H5E_FILE, H5E_MOUNT, FAIL, "unable to mount file") done: @@ -535,8 +534,7 @@ H5Funmount(hid_t loc_id, const char *name) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "could not get location object") /* Perform the unmount operation */ - if(H5VL_file_specific(vol_obj->data, vol_obj->driver->cls, H5VL_FILE_UNMOUNT, - H5P_DATASET_XFER_DEFAULT, H5_REQUEST_NULL, loc_type, name) < 0) + if(H5VL_file_specific(vol_obj, H5VL_FILE_UNMOUNT, H5P_DATASET_XFER_DEFAULT, H5_REQUEST_NULL, (int)loc_type, name) < 0) HGOTO_ERROR(H5E_FILE, H5E_MOUNT, FAIL, "unable to unmount file") done: diff --git a/src/H5Fpkg.h b/src/H5Fpkg.h index 2098a77..4ad2c55 100644 --- a/src/H5Fpkg.h +++ b/src/H5Fpkg.h @@ -292,7 +292,7 @@ struct H5F_file_t { /* begin on file access/create */ char *mdc_log_location; /* location of mdc log */ hid_t fcpl_id; /* File creation property list ID */ - H5F_close_degree_t fc_degree; /* File close behavior degree */ + H5F_close_degree_t fc_degree; /* File close behavior degree */ hbool_t evict_on_close; /* If the file's objects should be evicted from the metadata cache on close */ size_t rdcc_nslots; /* Size of raw data chunk cache (slots) */ size_t rdcc_nbytes; /* Size of raw data chunk cache (bytes) */ @@ -310,6 +310,10 @@ struct H5F_file_t { H5FO_t *open_objs; /* Open objects in file */ H5UC_t *grp_btree_shared; /* Ref-counted group B-tree node info */ + /* Cached VOL connector ID & info */ + hid_t vol_id; /* ID of VOL connector for the container */ + void *vol_info; /* Copy of VOL connector info for container */ + /* File space allocation information */ H5F_fspace_strategy_t fs_strategy; /* File space handling strategy */ hsize_t fs_threshold; /* Free space section threshold */ @@ -378,47 +382,6 @@ struct H5F_t { #endif /* H5_HAVE_PARALLEL */ }; -/* types for file optional VOL operations */ -typedef enum H5VL_file_optional_t { - H5VL_FILE_CLEAR_ELINK_CACHE, /* Clear external link cache */ - H5VL_FILE_GET_FILE_IMAGE, /* file image */ - H5VL_FILE_GET_FREE_SECTIONS, /* file free selections */ - H5VL_FILE_GET_FREE_SPACE, /* file freespace */ - H5VL_FILE_GET_INFO, /* file info */ - H5VL_FILE_GET_MDC_CONF, /* file metadata cache configuration */ - H5VL_FILE_GET_MDC_HR, /* file metadata cache hit rate */ - H5VL_FILE_GET_MDC_SIZE, /* file metadata cache size */ - H5VL_FILE_GET_SIZE, /* file size */ - H5VL_FILE_GET_VFD_HANDLE, /* file VFD handle */ - H5VL_FILE_REOPEN, /* reopen the file */ - H5VL_FILE_RESET_MDC_HIT_RATE, /* get metadata cache hit rate */ - H5VL_FILE_SET_MDC_CONFIG, /* set metadata cache configuration */ - H5VL_FILE_GET_METADATA_READ_RETRY_INFO, - H5VL_FILE_START_SWMR_WRITE, - H5VL_FILE_START_MDC_LOGGING, - H5VL_FILE_STOP_MDC_LOGGING, - H5VL_FILE_GET_MDC_LOGGING_STATUS, - H5VL_FILE_SET_LATEST_FORMAT, - H5VL_FILE_FORMAT_CONVERT, - H5VL_FILE_RESET_PAGE_BUFFERING_STATS, - H5VL_FILE_GET_PAGE_BUFFERING_STATS, - H5VL_FILE_GET_MDC_IMAGE_INFO - -} H5VL_file_optional_t; - -/* User data for traversal routine to get ID counts */ -typedef struct { - ssize_t *obj_count; /* number of objects counted so far */ - unsigned types; /* types of objects to be counted */ -} H5F_trav_obj_cnt_t; - -/* User data for traversal routine to get ID lists */ -/* XXX (VOL MERGE): Should the type of obj_count and max_objs be identical? */ -typedef struct { - size_t max_objs; - hid_t *oid_list; - ssize_t *obj_count; /* number of objects counted so far */ -} H5F_trav_obj_ids_t; /*****************************/ /* Package Private Variables */ @@ -437,7 +400,6 @@ H5FL_EXTERN(H5F_file_t); /* General routines */ H5_DLL H5F_t *H5F__reopen(H5F_t *f); -H5_DLL H5F_t *H5F__new(H5F_file_t *shared, unsigned flags, hid_t fcpl_id, hid_t fapl_id, H5FD_t *lf); H5_DLL herr_t H5F__dest(H5F_t *f, hbool_t flush); H5_DLL herr_t H5F__flush(H5F_t *f); H5_DLL htri_t H5F__is_hdf5(const char *name, hid_t fapl_id); @@ -447,6 +409,8 @@ H5_DLL herr_t H5F__format_convert(H5F_t *f); H5_DLL herr_t H5F__start_swmr_write(H5F_t *f); H5_DLL herr_t H5F__close(H5F_t *f); H5_DLL herr_t H5F__set_libver_bounds(H5F_t *f, H5F_libver_t low, H5F_libver_t high); +H5_DLL H5F_t *H5F__get_file(void *obj, H5I_type_t type); +H5_DLL hid_t H5F__get_file_id(H5F_t *file); /* File mount related routines */ H5_DLL herr_t H5F__mount(H5G_loc_t *loc, const char *name, H5F_t *child, hid_t plist_id); @@ -506,6 +470,7 @@ H5_DLL herr_t H5F__get_sohm_mesg_count_test(hid_t fid, unsigned type_id, size_t H5_DLL herr_t H5F__check_cached_stab_test(hid_t file_id); H5_DLL herr_t H5F__get_maxaddr_test(hid_t file_id, haddr_t *maxaddr); H5_DLL herr_t H5F__get_sbe_addr_test(hid_t file_id, haddr_t *sbe_addr); +H5_DLL htri_t H5F__same_file_test(hid_t file_id1, hid_t file_id2); #endif /* H5F_TESTING */ #endif /* _H5Fpkg_H */ diff --git a/src/H5Fprivate.h b/src/H5Fprivate.h index a4b7880..85f0d15 100644 --- a/src/H5Fprivate.h +++ b/src/H5Fprivate.h @@ -479,7 +479,7 @@ typedef struct H5F_t H5F_t; #define H5F_ACS_SDATA_BLOCK_SIZE_NAME "sdata_block_size" /* Minimum "small data" allocation block size (when aggregating "small" raw data allocations) */ #define H5F_ACS_GARBG_COLCT_REF_NAME "gc_ref" /* Garbage-collect references */ #define H5F_ACS_FILE_DRV_NAME "vfd_info" /* File driver ID & info */ -#define H5F_ACS_VOL_DRV_NAME "vol_driver_info" /* VOL driver ID & info */ +#define H5F_ACS_VOL_CONN_NAME "vol_connector_info" /* VOL connector ID & info */ #define H5F_ACS_CLOSE_DEGREE_NAME "close_degree" /* File close degree */ #define H5F_ACS_FAMILY_OFFSET_NAME "family_offset" /* Offset position in file for family file driver */ #define H5F_ACS_FAMILY_NEWSIZE_NAME "family_newsize" /* New member size of family driver. (private property only used by h5repart) */ @@ -500,9 +500,7 @@ typedef struct H5F_t H5F_t; #define H5F_ACS_USE_MDC_LOGGING_NAME "use_mdc_logging" /* Whether to use metadata cache logging */ #define H5F_ACS_MDC_LOG_LOCATION_NAME "mdc_log_location" /* Name of metadata cache log location */ #define H5F_ACS_START_MDC_LOG_ON_ACCESS_NAME "start_mdc_log_on_access" /* Whether logging starts on file create/open */ -#define H5F_ACS_CORE_WRITE_TRACKING_FLAG_NAME "core_write_tracking_flag" /* Whether or not core VFD backing store write tracking is enabled */ #define H5F_ACS_EVICT_ON_CLOSE_FLAG_NAME "evict_on_close_flag" /* Whether or not the metadata cache will evict objects on close */ -#define H5F_ACS_CORE_WRITE_TRACKING_PAGE_SIZE_NAME "core_write_tracking_page_size" /* The page size in kiB when core VFD write tracking is enabled */ #define H5F_ACS_COLL_MD_WRITE_FLAG_NAME "collective_metadata_write" /* property indicating whether metadata writes are done collectively or not */ #define H5F_ACS_META_CACHE_INIT_IMAGE_CONFIG_NAME "mdc_initCacheImageCfg" /* Initial metadata cache image creation configuration */ #define H5F_ACS_PAGE_BUFFER_SIZE_NAME "page_buffer_size" /* the maximum size for the page buffer cache */ @@ -716,6 +714,7 @@ typedef enum H5F_prefix_open_t { /* Private functions */ H5_DLL H5F_t *H5F_open(const char *name, unsigned flags, hid_t fcpl_id, hid_t fapl_id); H5_DLL herr_t H5F_try_close(H5F_t *f, hbool_t *was_closed/*out*/); +H5_DLL hid_t H5F_get_file_id(hid_t obj_id, H5I_type_t id_type); /* Functions that retrieve values from the file struct */ H5_DLL H5F_libver_t H5F_get_low_bound(const H5F_t *f); @@ -734,7 +733,7 @@ H5_DLL H5F_t *H5F_get_parent(const H5F_t *f); H5_DLL unsigned H5F_get_nmounts(const H5F_t *f); H5_DLL unsigned H5F_get_read_attempts(const H5F_t *f); H5_DLL hid_t H5F_get_access_plist(H5F_t *f, hbool_t app_ref); -H5_DLL hid_t H5F_get_id(H5F_t *file, hbool_t app_ref); +H5_DLL hid_t H5F_get_id(H5F_t *file); H5_DLL herr_t H5F_get_obj_count(const H5F_t *f, unsigned types, hbool_t app_ref, size_t *obj_id_count_ptr); H5_DLL herr_t H5F_get_obj_ids(const H5F_t *f, unsigned types, size_t max_objs, hid_t *oid_list, hbool_t app_ref, size_t *obj_id_count_ptr); H5_DLL hsize_t H5F_get_pgend_meta_thres(const H5F_t *f); diff --git a/src/H5Fpublic.h b/src/H5Fpublic.h index 8e54e7f..e1b6dc3 100644 --- a/src/H5Fpublic.h +++ b/src/H5Fpublic.h @@ -218,11 +218,13 @@ typedef struct H5F_retry_info_t { typedef herr_t (*H5F_flush_cb_t)(hid_t object_id, void *udata); +/*********************/ +/* Public Prototypes */ +/*********************/ #ifdef __cplusplus extern "C" { #endif -/* Functions in H5F.c */ H5_DLL htri_t H5Fis_accessible(const char *container_name, hid_t fapl_id); H5_DLL hid_t H5Fcreate(const char *filename, unsigned flags, hid_t create_plist, hid_t access_plist); diff --git a/src/H5Fquery.c b/src/H5Fquery.c index b036974..3147e95 100644 --- a/src/H5Fquery.c +++ b/src/H5Fquery.c @@ -904,7 +904,7 @@ H5F_get_eoa(const H5F_t *f, H5FD_mem_t type) /* Dispatch to driver */ if(HADDR_UNDEF == (ret_value = H5FD_get_eoa(f->shared->lf, type))) - HGOTO_ERROR(H5E_VFL, H5E_CANTINIT, HADDR_UNDEF, "driver get_eoa request failed") + HGOTO_ERROR(H5E_VFL, H5E_CANTINIT, HADDR_UNDEF, "driver get_eoa request failed") done: FUNC_LEAVE_NOAPI(ret_value) diff --git a/src/H5Ftest.c b/src/H5Ftest.c index 1183284..49a2a22 100644 --- a/src/H5Ftest.c +++ b/src/H5Ftest.c @@ -233,3 +233,37 @@ done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5F__get_sbe_addr_test() */ + +/*------------------------------------------------------------------------- + * Function: H5F__same_file_test + * + * Purpose: Check if two file IDs refer to the same underlying file. + * + * Return: SUCCEED/FAIL + * + * Programmer: Quincey Koziol + * Oct 13, 2018 + * + *------------------------------------------------------------------------- + */ +htri_t +H5F__same_file_test(hid_t file_id1, hid_t file_id2) +{ + H5F_t *file1, *file2; /* File info */ + htri_t ret_value = FAIL; /* Return value */ + + FUNC_ENTER_PACKAGE + + /* Check arguments */ + if(NULL == (file1 = (H5F_t *)H5VL_object_verify(file_id1, H5I_FILE))) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a file") + if(NULL == (file2 = (H5F_t *)H5VL_object_verify(file_id2, H5I_FILE))) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a file") + + /* If they are using the same underlying "shared" file struct, they are the same file */ + ret_value = (file1->shared == file2->shared); + +done: + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5F__same_file_test() */ + @@ -278,7 +278,7 @@ H5G__close_cb(H5VL_object_t *grp_vol_obj) HDassert(grp_vol_obj); /* Close the group */ - if(H5VL_group_close(grp_vol_obj->data, grp_vol_obj->driver->cls, H5P_DATASET_XFER_DEFAULT, H5_REQUEST_NULL) < 0) + if(H5VL_group_close(grp_vol_obj, H5P_DATASET_XFER_DEFAULT, H5_REQUEST_NULL) < 0) HGOTO_ERROR(H5E_SYM, H5E_CLOSEERROR, FAIL, "unable to close group") /* Free the VOL object */ @@ -351,13 +351,13 @@ H5Gcreate2(hid_t loc_id, const char *name, hid_t lcpl_id, hid_t gcpl_id, HGOTO_ERROR(H5E_SYM, H5E_CANTSET, H5I_INVALID_HID, "can't set access property list info") /* Get the gcpl structure and set the link properties on it */ - if (NULL == (plist = (H5P_genplist_t *)H5I_object(gcpl_id))) + if(NULL == (plist = (H5P_genplist_t *)H5I_object(gcpl_id))) HGOTO_ERROR(H5E_ATOM, H5E_BADATOM, H5I_INVALID_HID, "can't find object for ID") - if (H5P_set(plist, H5VL_PROP_GRP_LCPL_ID, &lcpl_id) < 0) + if(H5P_set(plist, H5VL_PROP_GRP_LCPL_ID, &lcpl_id) < 0) HGOTO_ERROR(H5E_PLIST, H5E_CANTSET, H5I_INVALID_HID, "can't set property value for lcpl id") - /* get the location object */ - if (NULL == (vol_obj = (H5VL_object_t *)H5I_object(loc_id))) + /* Get the location object */ + if(NULL == (vol_obj = (H5VL_object_t *)H5I_object(loc_id))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, H5I_INVALID_HID, "invalid location identifier") /* Set the location parameters */ @@ -365,17 +365,16 @@ H5Gcreate2(hid_t loc_id, const char *name, hid_t lcpl_id, hid_t gcpl_id, loc_params.obj_type = H5I_get_type(loc_id); /* Create the group */ - if(NULL == (grp = H5VL_group_create(vol_obj->data, loc_params, vol_obj->driver->cls, name, - gcpl_id, gapl_id, H5P_DATASET_XFER_DEFAULT, H5_REQUEST_NULL))) + if(NULL == (grp = H5VL_group_create(vol_obj, &loc_params, name, gcpl_id, gapl_id, H5P_DATASET_XFER_DEFAULT, H5_REQUEST_NULL))) HGOTO_ERROR(H5E_SYM, H5E_CANTINIT, H5I_INVALID_HID, "unable to create group") /* Get an atom for the group */ - if((ret_value = H5VL_register(H5I_GROUP, grp, vol_obj->driver, TRUE)) < 0) - HGOTO_ERROR(H5E_ATOM, H5E_CANTREGISTER, H5I_INVALID_HID, "unable to atomize group handle") + if((ret_value = H5VL_register(H5I_GROUP, grp, vol_obj->connector, TRUE)) < 0) + HGOTO_ERROR(H5E_SYM, H5E_CANTREGISTER, H5I_INVALID_HID, "unable to atomize group handle") done: if(H5I_INVALID_HID == ret_value) - if(grp && H5VL_group_close(grp, vol_obj->driver->cls, H5P_DATASET_XFER_DEFAULT, H5_REQUEST_NULL) < 0) + if(grp && H5VL_group_close(vol_obj, H5P_DATASET_XFER_DEFAULT, H5_REQUEST_NULL) < 0) HDONE_ERROR(H5E_SYM, H5E_CLOSEERROR, H5I_INVALID_HID, "unable to release group") FUNC_LEAVE_API(ret_value) @@ -440,23 +439,22 @@ H5Gcreate_anon(hid_t loc_id, hid_t gcpl_id, hid_t gapl_id) loc_params.type = H5VL_OBJECT_BY_SELF; loc_params.obj_type = H5I_get_type(loc_id); - /* get the location object */ + /* Get the location object */ if(NULL == (vol_obj = (H5VL_object_t *)H5I_object(loc_id))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, H5I_INVALID_HID, "invalid location identifier") /* Create the group */ - if(NULL == (grp = H5VL_group_create(vol_obj->data, loc_params, vol_obj->driver->cls, NULL, - gcpl_id, gapl_id, H5P_DATASET_XFER_DEFAULT, H5_REQUEST_NULL))) + if(NULL == (grp = H5VL_group_create(vol_obj, &loc_params, NULL, gcpl_id, gapl_id, H5P_DATASET_XFER_DEFAULT, H5_REQUEST_NULL))) HGOTO_ERROR(H5E_SYM, H5E_CANTINIT, H5I_INVALID_HID, "unable to create group") /* Get an atom for the group */ - if((ret_value = H5VL_register(H5I_GROUP, grp, vol_obj->driver, TRUE)) < 0) - HGOTO_ERROR(H5E_ATOM, H5E_CANTREGISTER, H5I_INVALID_HID, "unable to atomize group handle") + if((ret_value = H5VL_register(H5I_GROUP, grp, vol_obj->connector, TRUE)) < 0) + HGOTO_ERROR(H5E_SYM, H5E_CANTREGISTER, H5I_INVALID_HID, "unable to atomize group handle") done: /* Cleanup on failure */ if(H5I_INVALID_HID == ret_value) - if(grp && H5VL_group_close(grp, vol_obj->driver->cls, H5P_DATASET_XFER_DEFAULT, H5_REQUEST_NULL) < 0) + if(grp && H5VL_group_close(vol_obj, H5P_DATASET_XFER_DEFAULT, H5_REQUEST_NULL) < 0) HDONE_ERROR(H5E_SYM, H5E_CLOSEERROR, H5I_INVALID_HID, "unable to release group") FUNC_LEAVE_API(ret_value) @@ -482,9 +480,9 @@ hid_t H5Gopen2(hid_t loc_id, const char *name, hid_t gapl_id) { void *grp = NULL; /* Group opened */ - H5VL_object_t *vol_obj = NULL; /* object token of loc_id */ + H5VL_object_t *vol_obj = NULL; /* object token of loc_id */ H5VL_loc_params_t loc_params; - hid_t ret_value = H5I_INVALID_HID; /* Return value */ + hid_t ret_value = H5I_INVALID_HID; /* Return value */ FUNC_ENTER_API(H5I_INVALID_HID) H5TRACE3("i", "i*si", loc_id, name, gapl_id); @@ -506,17 +504,17 @@ H5Gopen2(hid_t loc_id, const char *name, hid_t gapl_id) /* Open the group */ loc_params.type = H5VL_OBJECT_BY_SELF; loc_params.obj_type = H5I_get_type(loc_id); - if(NULL == (grp = H5VL_group_open(vol_obj->data, loc_params, vol_obj->driver->cls, - name, gapl_id, H5P_DATASET_XFER_DEFAULT, H5_REQUEST_NULL))) + + if(NULL == (grp = H5VL_group_open(vol_obj, &loc_params, name, gapl_id, H5P_DATASET_XFER_DEFAULT, H5_REQUEST_NULL))) HGOTO_ERROR(H5E_SYM, H5E_CANTOPENOBJ, H5I_INVALID_HID, "unable to open group") /* Register an ID for the group */ - if((ret_value = H5VL_register(H5I_GROUP, grp, vol_obj->driver, TRUE)) < 0) - HGOTO_ERROR(H5E_ATOM, H5E_CANTREGISTER, H5I_INVALID_HID, "unable to register group") + if((ret_value = H5VL_register(H5I_GROUP, grp, vol_obj->connector, TRUE)) < 0) + HGOTO_ERROR(H5E_SYM, H5E_CANTREGISTER, H5I_INVALID_HID, "unable to register group") done: if(H5I_INVALID_HID == ret_value) - if(grp && H5VL_group_close(grp, vol_obj->driver->cls, H5P_DATASET_XFER_DEFAULT, H5_REQUEST_NULL) < 0) + if(grp && H5VL_group_close(vol_obj, H5P_DATASET_XFER_DEFAULT, H5_REQUEST_NULL) < 0) HDONE_ERROR(H5E_SYM, H5E_CLOSEERROR, H5I_INVALID_HID, "unable to release group") FUNC_LEAVE_API(ret_value) @@ -550,8 +548,7 @@ H5Gget_create_plist(hid_t group_id) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, H5I_INVALID_HID, "not a group ID") /* Get the group creation property list for the group */ - if(H5VL_group_get(vol_obj->data, vol_obj->driver->cls, H5VL_GROUP_GET_GCPL, - H5P_DATASET_XFER_DEFAULT, H5_REQUEST_NULL, &ret_value) < 0) + if(H5VL_group_get(vol_obj, H5VL_GROUP_GET_GCPL, H5P_DATASET_XFER_DEFAULT, H5_REQUEST_NULL, &ret_value) < 0) HGOTO_ERROR(H5E_SYM, H5E_CANTGET, H5I_INVALID_HID, "can't get group's creation property list") done: @@ -593,8 +590,7 @@ H5Gget_info(hid_t loc_id, H5G_info_t *group_info) /* Retrieve the group's information */ loc_params.type = H5VL_OBJECT_BY_SELF; loc_params.obj_type = id_type; - if((ret_value = H5VL_group_get(vol_obj->data, vol_obj->driver->cls, H5VL_GROUP_GET_INFO, - H5P_DATASET_XFER_DEFAULT, H5_REQUEST_NULL, loc_params, group_info)) < 0) + if(H5VL_group_get(vol_obj, H5VL_GROUP_GET_INFO, H5P_DATASET_XFER_DEFAULT, H5_REQUEST_NULL, &loc_params, group_info) < 0) HGOTO_ERROR(H5E_SYM, H5E_CANTGET, FAIL, "unable to get group info") done: @@ -636,7 +632,7 @@ H5Gget_info_by_name(hid_t loc_id, const char *name, H5G_info_t *group_info, HGOTO_ERROR(H5E_SYM, H5E_CANTSET, FAIL, "can't set access property list info") /* Get the location object */ - if (NULL == (vol_obj = (H5VL_object_t *)H5I_object(loc_id))) + if(NULL == (vol_obj = (H5VL_object_t *)H5I_object(loc_id))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "invalid location identifier") /* Set up location parameters */ @@ -646,8 +642,7 @@ H5Gget_info_by_name(hid_t loc_id, const char *name, H5G_info_t *group_info, loc_params.obj_type = H5I_get_type(loc_id); /* Retrieve the group's information */ - if((ret_value = H5VL_group_get(vol_obj->data, vol_obj->driver->cls, H5VL_GROUP_GET_INFO, - H5P_DATASET_XFER_DEFAULT, H5_REQUEST_NULL, loc_params, group_info)) < 0) + if(H5VL_group_get(vol_obj, H5VL_GROUP_GET_INFO, H5P_DATASET_XFER_DEFAULT, H5_REQUEST_NULL, &loc_params, group_info) < 0) HGOTO_ERROR(H5E_SYM, H5E_CANTGET, FAIL, "can't retrieve group info") done: @@ -693,7 +688,7 @@ H5Gget_info_by_idx(hid_t loc_id, const char *group_name, H5_index_t idx_type, if(H5CX_set_apl(&lapl_id, H5P_CLS_LACC, loc_id, FALSE) < 0) HGOTO_ERROR(H5E_SYM, H5E_CANTSET, FAIL, "can't set access property list info") - /* get the location object */ + /* Get the location object */ if(NULL == (vol_obj = (H5VL_object_t *)H5I_object(loc_id))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "invalid location identifier") @@ -707,8 +702,7 @@ H5Gget_info_by_idx(hid_t loc_id, const char *group_name, H5_index_t idx_type, loc_params.obj_type = H5I_get_type(loc_id); /* Retrieve the group's information */ - if((ret_value = H5VL_group_get(vol_obj->data, vol_obj->driver->cls, H5VL_GROUP_GET_INFO, - H5P_DATASET_XFER_DEFAULT, H5_REQUEST_NULL, loc_params, group_info)) < 0) + if(H5VL_group_get(vol_obj, H5VL_GROUP_GET_INFO, H5P_DATASET_XFER_DEFAULT, H5_REQUEST_NULL, &loc_params, group_info) < 0) HGOTO_ERROR(H5E_SYM, H5E_CANTGET, FAIL, "can't retrieve group info") done: @@ -779,8 +773,7 @@ H5Gflush(hid_t group_id) HGOTO_ERROR(H5E_SYM, H5E_CANTSET, FAIL, "can't set collective metadata read info") /* Flush group's metadata to file */ - if((ret_value = H5VL_group_specific(vol_obj->data, vol_obj->driver->cls, H5VL_GROUP_FLUSH, - H5P_DATASET_XFER_DEFAULT, H5_REQUEST_NULL, group_id)) < 0) + if(H5VL_group_specific(vol_obj, H5VL_GROUP_FLUSH, H5P_DATASET_XFER_DEFAULT, H5_REQUEST_NULL, group_id) < 0) HGOTO_ERROR(H5E_SYM, H5E_CANTFLUSH, FAIL, "unable to flush group") done: @@ -818,8 +811,7 @@ H5Grefresh(hid_t group_id) HGOTO_ERROR(H5E_SYM, H5E_CANTSET, FAIL, "can't set collective metadata read info") /* Refresh group's metadata */ - if((ret_value = H5VL_group_specific(vol_obj->data, vol_obj->driver->cls, H5VL_GROUP_REFRESH, - H5P_DATASET_XFER_DEFAULT, H5_REQUEST_NULL, group_id)) < 0) + if(H5VL_group_specific(vol_obj, H5VL_GROUP_REFRESH, H5P_DATASET_XFER_DEFAULT, H5_REQUEST_NULL, group_id) < 0) HGOTO_ERROR(H5E_SYM, H5E_CANTLOAD, FAIL, "unable to refresh group") done: diff --git a/src/H5Gcompact.c b/src/H5Gcompact.c index b32ce39..7e2b324 100644 --- a/src/H5Gcompact.c +++ b/src/H5Gcompact.c @@ -572,71 +572,3 @@ done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5G__compact_lookup_by_idx() */ -#ifndef H5_NO_DEPRECATED_SYMBOLS - -/*------------------------------------------------------------------------- - * Function: H5G__compact_get_type_by_idx - * - * Purpose: Returns the type of objects in the group by giving index. - * - * Return: Success: Non-negative - * Failure: Negative - * - * Programmer: Quincey Koziol - * Sep 12, 2005 - * - *------------------------------------------------------------------------- - */ -H5G_obj_t -H5G__compact_get_type_by_idx(H5O_loc_t *oloc, const H5O_linfo_t *linfo, - hsize_t idx) -{ - H5G_link_table_t ltable = {0, NULL}; /* Link table */ - H5G_obj_t ret_value = H5G_UNKNOWN; /* Return value */ - - FUNC_ENTER_PACKAGE - - /* Sanity check */ - HDassert(oloc); - - /* Build table of all link messages */ - if(H5G__compact_build_table(oloc, linfo, H5_INDEX_NAME, H5_ITER_INC, <able) < 0) - HGOTO_ERROR(H5E_SYM, H5E_CANTINIT, H5G_UNKNOWN, "can't create link message table") - - /* Check for going out of bounds */ - if(idx >= ltable.nlinks) - HGOTO_ERROR(H5E_ARGS, H5E_BADRANGE, H5G_UNKNOWN, "index out of bound") - - /* Determine type of object */ - if(ltable.lnks[idx].type == H5L_TYPE_SOFT) - ret_value = H5G_LINK; - else if(ltable.lnks[idx].type >= H5L_TYPE_UD_MIN) - ret_value = H5G_UDLINK; - else if(ltable.lnks[idx].type == H5L_TYPE_HARD){ - H5O_loc_t tmp_oloc; /* Temporary object location */ - H5O_type_t obj_type; /* Type of object at location */ - - /* Build temporary object location */ - tmp_oloc.file = oloc->file; - tmp_oloc.addr = ltable.lnks[idx].u.hard.addr; - - /* Get the type of the object */ - if(H5O_obj_type(&tmp_oloc, &obj_type) < 0) - HGOTO_ERROR(H5E_SYM, H5E_CANTGET, H5G_UNKNOWN, "can't get object type") - - /* Map to group object type */ - if(H5G_UNKNOWN == (ret_value = H5G_map_obj_type(obj_type))) - HGOTO_ERROR(H5E_SYM, H5E_BADTYPE, H5G_UNKNOWN, "can't determine object type") - } else { - HGOTO_ERROR(H5E_SYM, H5E_BADTYPE, H5G_UNKNOWN, "unknown link type") - } /* end else */ - -done: - /* Release link table */ - if(ltable.lnks && H5G__link_release_table(<able) < 0) - HDONE_ERROR(H5E_SYM, H5E_CANTFREE, H5G_UNKNOWN, "unable to release link table") - - FUNC_LEAVE_NOAPI(ret_value) -} /* end H5G__compact_get_type_by_idx() */ -#endif /* H5_NO_DEPRECATED_SYMBOLS */ - diff --git a/src/H5Gdense.c b/src/H5Gdense.c index d2bcad1..a2ef55c 100644 --- a/src/H5Gdense.c +++ b/src/H5Gdense.c @@ -1777,80 +1777,3 @@ done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5G__dense_delete() */ -#ifndef H5_NO_DEPRECATED_SYMBOLS - -/*------------------------------------------------------------------------- - * Function: H5G__dense_get_type_by_idx - * - * Purpose: Returns the type of objects in the group by giving index. - * - * Note: This routine assumes a lookup on the link name index in - * increasing order and isn't currently set up to be as - * flexible as other routines in this code module, because - * the H5Gget_objtype_by_idx that it's supporting is - * deprecated. - * - * Return: Success: Non-negative, object type - * Failure: Negative - * - * Programmer: Quincey Koziol - * koziol@hdfgroup.org - * Sep 19 2006 - * - *------------------------------------------------------------------------- - */ -H5G_obj_t -H5G__dense_get_type_by_idx(H5F_t *f, H5O_linfo_t *linfo, hsize_t idx) -{ - H5G_link_table_t ltable = {0, NULL}; /* Table of links */ - H5G_obj_t ret_value = H5G_UNKNOWN; /* Return value */ - - FUNC_ENTER_PACKAGE - - /* - * Check arguments. - */ - HDassert(f); - HDassert(linfo); - - /* Build the table of links for this group */ - if(H5G__dense_build_table(f, linfo, H5_INDEX_NAME, H5_ITER_INC, <able) < 0) - HGOTO_ERROR(H5E_SYM, H5E_CANTGET, H5G_UNKNOWN, "error building table of links") - - /* Check for going out of bounds */ - if(idx >= ltable.nlinks) - HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, H5G_UNKNOWN, "index out of bound") - - /* Determine type of object */ - if(ltable.lnks[idx].type == H5L_TYPE_SOFT) - ret_value = H5G_LINK; - else if(ltable.lnks[idx].type >= H5L_TYPE_UD_MIN) - ret_value = H5G_UDLINK; - else if(ltable.lnks[idx].type == H5L_TYPE_HARD) { - H5O_loc_t tmp_oloc; /* Temporary object location */ - H5O_type_t obj_type; /* Type of object at location */ - - /* Build temporary object location */ - tmp_oloc.file = f; - tmp_oloc.addr = ltable.lnks[idx].u.hard.addr; - - /* Get the type of the object */ - if(H5O_obj_type(&tmp_oloc, &obj_type) < 0) - HGOTO_ERROR(H5E_SYM, H5E_CANTGET, H5G_UNKNOWN, "can't get object type") - - /* Map to group object type */ - if(H5G_UNKNOWN == (ret_value = H5G_map_obj_type(obj_type))) - HGOTO_ERROR(H5E_SYM, H5E_BADTYPE, H5G_UNKNOWN, "can't determine object type") - } else { - HGOTO_ERROR(H5E_SYM, H5E_BADTYPE, H5G_UNKNOWN, "unknown link type") - } /* end else */ - -done: - /* Release link table */ - if(ltable.lnks && H5G__link_release_table(<able) < 0) - HDONE_ERROR(H5E_SYM, H5E_CANTFREE, H5G_UNKNOWN, "unable to release link table") - - FUNC_LEAVE_NOAPI(ret_value) -} /* end H5G__dense_get_type_by_idx() */ -#endif /* H5_NO_DEPRECATED_SYMBOLS */ - diff --git a/src/H5Gdeprec.c b/src/H5Gdeprec.c index d2e991b..cb03b5e 100644 --- a/src/H5Gdeprec.c +++ b/src/H5Gdeprec.c @@ -43,7 +43,9 @@ #include "H5Iprivate.h" /* IDs */ #include "H5Lprivate.h" /* Links */ #include "H5Pprivate.h" /* Property lists */ -#include "H5VLprivate.h" /* VOL plugins */ +#include "H5VLprivate.h" /* Virtual Object Layer */ + +#include "H5VLnative_private.h" /* Native VOL connector */ /****************/ @@ -72,13 +74,9 @@ typedef struct { /********************/ /* Local Prototypes */ /********************/ - static herr_t H5G__get_objinfo_cb(H5G_loc_t *grp_loc/*in*/, const char *name, const H5O_link_t *lnk, H5G_loc_t *obj_loc, void *_udata/*in,out*/, H5G_own_loc_t *own_loc/*out*/); -static herr_t H5G__get_objinfo(const H5G_loc_t *loc, const char *name, - hbool_t follow_link, H5G_stat_t *statbuf/*out*/); -static H5G_obj_t H5G__obj_get_type_by_idx(H5O_loc_t *oloc, hsize_t idx); #endif /* H5_NO_DEPRECATED_SYMBOLS */ @@ -172,7 +170,7 @@ hid_t H5Gcreate1(hid_t loc_id, const char *name, size_t size_hint) { void *grp = NULL; /* New group created */ - H5VL_object_t *vol_obj = NULL; /* object token of loc_id */ + H5VL_object_t *vol_obj; /* Object token of loc_id */ H5VL_loc_params_t loc_params; H5P_genplist_t *plist; /* Property list pointer */ hid_t tmp_gcpl = H5I_INVALID_HID; /* Temporary group creation property list */ @@ -227,6 +225,7 @@ H5Gcreate1(hid_t loc_id, const char *name, size_t size_hint) if(H5P_set(plist, H5VL_PROP_GRP_LCPL_ID, &lcpl_id) < 0) HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, H5I_INVALID_HID, "can't get property value for lcpl id") + /* Set location parameters */ loc_params.type = H5VL_OBJECT_BY_SELF; loc_params.obj_type = H5I_get_type(loc_id); @@ -235,13 +234,12 @@ H5Gcreate1(hid_t loc_id, const char *name, size_t size_hint) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, H5I_INVALID_HID, "invalid location identifier") /* Create the group */ - if(NULL == (grp = H5VL_group_create(vol_obj->data, loc_params, vol_obj->driver->cls, name, tmp_gcpl, - H5P_GROUP_ACCESS_DEFAULT, H5P_DATASET_XFER_DEFAULT, H5_REQUEST_NULL))) + if(NULL == (grp = H5VL_group_create(vol_obj, &loc_params, name, tmp_gcpl, H5P_GROUP_ACCESS_DEFAULT, H5P_DATASET_XFER_DEFAULT, H5_REQUEST_NULL))) HGOTO_ERROR(H5E_SYM, H5E_CANTINIT, H5I_INVALID_HID, "unable to create group") /* Get an atom for the group */ - if((ret_value = H5VL_register(H5I_GROUP, grp, vol_obj->driver, TRUE)) < 0) - HGOTO_ERROR(H5E_ATOM, H5E_CANTREGISTER, H5I_INVALID_HID, "unable to register group") + if((ret_value = H5VL_register(H5I_GROUP, grp, vol_obj->connector, TRUE)) < 0) + HGOTO_ERROR(H5E_SYM, H5E_CANTREGISTER, H5I_INVALID_HID, "unable to register group") done: if(H5I_INVALID_HID != tmp_gcpl && tmp_gcpl != H5P_GROUP_CREATE_DEFAULT) @@ -249,7 +247,7 @@ done: HDONE_ERROR(H5E_SYM, H5E_CLOSEERROR, H5I_INVALID_HID, "unable to release property list") if(H5I_INVALID_HID == ret_value) - if(grp && H5VL_group_close(grp, vol_obj->driver->cls, H5P_DATASET_XFER_DEFAULT, H5_REQUEST_NULL) < 0) + if(grp && H5VL_group_close(vol_obj, H5P_DATASET_XFER_DEFAULT, H5_REQUEST_NULL) < 0) HDONE_ERROR(H5E_SYM, H5E_CLOSEERROR, H5I_INVALID_HID, "unable to release group") FUNC_LEAVE_API(ret_value) @@ -276,10 +274,10 @@ done: hid_t H5Gopen1(hid_t loc_id, const char *name) { - void *grp = NULL; /* Group opened */ - H5VL_object_t *vol_obj = NULL; /* object token of loc_id */ + void *grp = NULL; /* Group opened */ + H5VL_object_t *vol_obj = NULL; /* Object token of loc_id */ H5VL_loc_params_t loc_params; - hid_t ret_value = H5I_INVALID_HID; /* Return value */ + hid_t ret_value = H5I_INVALID_HID; /* Return value */ FUNC_ENTER_API(H5I_INVALID_HID) H5TRACE2("i", "i*s", loc_id, name); @@ -297,17 +295,16 @@ H5Gopen1(hid_t loc_id, const char *name) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, H5I_INVALID_HID, "invalid location identifier") /* Open the group */ - if(NULL == (grp = H5VL_group_open(vol_obj->data, loc_params, vol_obj->driver->cls, name, H5P_DEFAULT, - H5P_DATASET_XFER_DEFAULT, H5_REQUEST_NULL))) + if(NULL == (grp = H5VL_group_open(vol_obj, &loc_params, name, H5P_DEFAULT, H5P_DATASET_XFER_DEFAULT, H5_REQUEST_NULL))) HGOTO_ERROR(H5E_SYM, H5E_CANTOPENOBJ, H5I_INVALID_HID, "unable to open group") /* Get an atom for the group */ - if((ret_value = H5VL_register(H5I_GROUP, grp, vol_obj->driver, TRUE)) < 0) - HGOTO_ERROR(H5E_ATOM, H5E_CANTREGISTER, H5I_INVALID_HID, "unable to register group") + if((ret_value = H5VL_register(H5I_GROUP, grp, vol_obj->connector, TRUE)) < 0) + HGOTO_ERROR(H5E_SYM, H5E_CANTREGISTER, H5I_INVALID_HID, "unable to register group") done: if(H5I_INVALID_HID == ret_value) - if(grp && H5VL_group_close(grp, vol_obj->driver->cls, H5P_DATASET_XFER_DEFAULT, H5_REQUEST_NULL) < 0) + if(grp && H5VL_group_close(vol_obj, H5P_DATASET_XFER_DEFAULT, H5_REQUEST_NULL) < 0) HDONE_ERROR(H5E_SYM, H5E_CLOSEERROR, H5I_INVALID_HID, "unable to release group") FUNC_LEAVE_API(ret_value) @@ -348,9 +345,10 @@ H5Glink(hid_t cur_loc_id, H5G_link_t type, const char *cur_name, const char *new /* Create link */ if(type == H5L_TYPE_HARD) { - H5VL_object_t *vol_obj = NULL; /* object token of loc_id */ + H5VL_object_t *vol_obj; /* Object token of loc_id */ H5VL_loc_params_t loc_params1; H5VL_loc_params_t loc_params2; + H5VL_object_t tmp_vol_obj; /* Temporary object token of */ loc_params1.type = H5VL_OBJECT_BY_NAME; loc_params1.obj_type = H5I_get_type(cur_loc_id); @@ -371,13 +369,16 @@ H5Glink(hid_t cur_loc_id, H5G_link_t type, const char *cur_name, const char *new if(H5P_set(plist, H5VL_PROP_LINK_TARGET_LOC_PARAMS, &loc_params1) < 0) HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, FAIL, "can't set property value for target loc params") + /* Construct a temporary VOL object */ + tmp_vol_obj.data = NULL; + tmp_vol_obj.connector = vol_obj->connector; + /* Create the link through the VOL */ - if((ret_value = H5VL_link_create(H5VL_LINK_CREATE_HARD, NULL, loc_params2, vol_obj->driver->cls, - lcpl_id, H5P_DEFAULT, H5P_DATASET_XFER_DEFAULT, H5_REQUEST_NULL)) < 0) + if(H5VL_link_create(H5VL_LINK_CREATE_HARD, &tmp_vol_obj, &loc_params2, lcpl_id, H5P_DEFAULT, H5P_DATASET_XFER_DEFAULT, H5_REQUEST_NULL) < 0) HGOTO_ERROR(H5E_SYM, H5E_CANTINIT, FAIL, "unable to create link") - } + } /* end if */ else if(type == H5L_TYPE_SOFT) { - H5VL_object_t *vol_obj = NULL; /* object token of loc_id */ + H5VL_object_t *vol_obj; /* Object token of loc_id */ H5VL_loc_params_t loc_params; loc_params.type = H5VL_OBJECT_BY_NAME; @@ -394,10 +395,9 @@ H5Glink(hid_t cur_loc_id, H5G_link_t type, const char *cur_name, const char *new HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, FAIL, "can't get property value for target name") /* Create the link through the VOL */ - if((ret_value = H5VL_link_create(H5VL_LINK_CREATE_SOFT, vol_obj->data, loc_params, vol_obj->driver->cls, - lcpl_id, H5P_DEFAULT, H5P_DATASET_XFER_DEFAULT, H5_REQUEST_NULL)) < 0) + if(H5VL_link_create(H5VL_LINK_CREATE_SOFT, vol_obj, &loc_params, lcpl_id, H5P_DEFAULT, H5P_DATASET_XFER_DEFAULT, H5_REQUEST_NULL) < 0) HGOTO_ERROR(H5E_SYM, H5E_CANTINIT, FAIL, "unable to create link") - } + } /* end else-if */ else HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "Not a valid link type") @@ -441,8 +441,8 @@ H5Glink2(hid_t cur_loc_id, const char *cur_name, H5G_link_t type, /* Create the appropriate kind of link */ if(type == H5L_TYPE_HARD) { - H5VL_object_t *vol_obj1 = NULL; /* object token of loc_id */ - H5VL_object_t *vol_obj2 = NULL; /* object token of loc_id */ + H5VL_object_t *vol_obj1; /* Object token of loc_id */ + H5VL_object_t *vol_obj2; /* Object token of loc_id */ H5VL_loc_params_t loc_params1; H5VL_loc_params_t loc_params2; @@ -469,12 +469,11 @@ H5Glink2(hid_t cur_loc_id, const char *cur_name, H5G_link_t type, HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, FAIL, "can't set property value for target name") /* Create the link through the VOL */ - if((ret_value = H5VL_link_create(H5VL_LINK_CREATE_HARD, vol_obj2->data, loc_params2, vol_obj2->driver->cls, - lcpl_id, H5P_DEFAULT, H5P_DATASET_XFER_DEFAULT, H5_REQUEST_NULL)) < 0) + if(H5VL_link_create(H5VL_LINK_CREATE_HARD, vol_obj2, &loc_params2, lcpl_id, H5P_DEFAULT, H5P_DATASET_XFER_DEFAULT, H5_REQUEST_NULL) < 0) HGOTO_ERROR(H5E_SYM, H5E_CANTINIT, FAIL, "unable to create link") - } + } /* end if */ else if(type == H5L_TYPE_SOFT) { - H5VL_object_t *vol_obj = NULL; /* object token of loc_id */ + H5VL_object_t *vol_obj; /* Object token of loc_id */ H5VL_loc_params_t loc_params; /* Soft links only need one location, the new_loc_id, but it's possible that @@ -496,10 +495,9 @@ H5Glink2(hid_t cur_loc_id, const char *cur_name, H5G_link_t type, HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, FAIL, "can't get property value for target name") /* Create the link through the VOL */ - if((ret_value = H5VL_link_create(H5VL_LINK_CREATE_SOFT, vol_obj->data, loc_params, vol_obj->driver->cls, - lcpl_id, H5P_DEFAULT, H5P_DATASET_XFER_DEFAULT, H5_REQUEST_NULL)) < 0) + if(H5VL_link_create(H5VL_LINK_CREATE_SOFT, vol_obj, &loc_params, lcpl_id, H5P_DEFAULT, H5P_DATASET_XFER_DEFAULT, H5_REQUEST_NULL) < 0) HGOTO_ERROR(H5E_SYM, H5E_CANTINIT, FAIL, "unable to create link") - } + } /* end else-if */ else HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "not a valid link type") @@ -518,10 +516,10 @@ done: herr_t H5Gmove(hid_t src_loc_id, const char *src_name, const char *dst_name) { - H5VL_object_t *vol_obj = NULL; /* object token of loc_id */ + H5VL_object_t *vol_obj; /* Object token of loc_id */ H5VL_loc_params_t loc_params1; H5VL_loc_params_t loc_params2; - herr_t ret_value = SUCCEED; /* Return value */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_API(FAIL) H5TRACE3("e", "i*s*s", src_loc_id, src_name, dst_name); @@ -544,8 +542,7 @@ H5Gmove(hid_t src_loc_id, const char *src_name, const char *dst_name) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "invalid location identifier") /* Move the link */ - if((ret_value = H5VL_link_move(vol_obj->data, loc_params1, NULL, loc_params2, vol_obj->driver->cls, - H5P_DEFAULT, H5P_DEFAULT, H5P_DATASET_XFER_DEFAULT, H5_REQUEST_NULL)) < 0) + if(H5VL_link_move(vol_obj, &loc_params1, NULL, &loc_params2, H5P_DEFAULT, H5P_DEFAULT, H5P_DATASET_XFER_DEFAULT, H5_REQUEST_NULL) < 0) HGOTO_ERROR(H5E_SYM, H5E_CANTMOVE, FAIL, "couldn't move link") done: @@ -564,9 +561,9 @@ herr_t H5Gmove2(hid_t src_loc_id, const char *src_name, hid_t dst_loc_id, const char *dst_name) { - H5VL_object_t *vol_obj1 = NULL; /* object token of src_id */ + H5VL_object_t *vol_obj1 = NULL; /* Object token of src_id */ H5VL_loc_params_t loc_params1; - H5VL_object_t *vol_obj2 = NULL; /* object token of dst_id */ + H5VL_object_t *vol_obj2 = NULL; /* Object token of dst_id */ H5VL_loc_params_t loc_params2; herr_t ret_value = SUCCEED; /* Return value */ @@ -582,27 +579,24 @@ H5Gmove2(hid_t src_loc_id, const char *src_name, hid_t dst_loc_id, loc_params1.loc_data.loc_by_name.name = src_name; loc_params1.loc_data.loc_by_name.lapl_id = H5P_DEFAULT; loc_params1.obj_type = H5I_get_type(src_loc_id); + /* Set location parameter for destination object */ loc_params2.type = H5VL_OBJECT_BY_NAME; loc_params2.loc_data.loc_by_name.name = dst_name; loc_params2.loc_data.loc_by_name.lapl_id = H5P_DEFAULT; loc_params2.obj_type = H5I_get_type(dst_loc_id); - if(H5L_SAME_LOC != src_loc_id) { + if(H5L_SAME_LOC != src_loc_id) /* get the location object */ if(NULL == (vol_obj1 = (H5VL_object_t *)H5I_object(src_loc_id))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "invalid location identifier") - } - if(H5L_SAME_LOC != dst_loc_id) { + if(H5L_SAME_LOC != dst_loc_id) /* get the location object */ if(NULL == (vol_obj2 = (H5VL_object_t *)H5I_object(dst_loc_id))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "invalid location identifier") - } /* Move the link */ - if((ret_value = H5VL_link_move(vol_obj1->data, loc_params1, vol_obj2->data, loc_params2, - vol_obj1->driver->cls, H5P_DEFAULT, H5P_DEFAULT, - H5P_DATASET_XFER_DEFAULT, H5_REQUEST_NULL)) < 0) + if(H5VL_link_move(vol_obj1, &loc_params1, vol_obj2, &loc_params2, H5P_DEFAULT, H5P_DEFAULT, H5P_DATASET_XFER_DEFAULT, H5_REQUEST_NULL) < 0) HGOTO_ERROR(H5E_SYM, H5E_CANTMOVE, FAIL, "unable to move link") done: @@ -620,7 +614,7 @@ done: herr_t H5Gunlink(hid_t loc_id, const char *name) { - H5VL_object_t *vol_obj = NULL; /* object token of loc_id */ + H5VL_object_t *vol_obj; /* Object token of loc_id */ H5VL_loc_params_t loc_params; herr_t ret_value = SUCCEED; /* Return value */ @@ -645,8 +639,7 @@ H5Gunlink(hid_t loc_id, const char *name) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "invalid location identifier") /* Delete the link */ - if(H5VL_link_specific(vol_obj->data, loc_params, vol_obj->driver->cls, H5VL_LINK_DELETE, - H5P_DATASET_XFER_DEFAULT, H5_REQUEST_NULL) < 0) + if(H5VL_link_specific(vol_obj, &loc_params, H5VL_LINK_DELETE, H5P_DATASET_XFER_DEFAULT, H5_REQUEST_NULL) < 0) HGOTO_ERROR(H5E_SYM, H5E_CANTDELETE, FAIL, "couldn't delete link") done: @@ -665,7 +658,7 @@ done: herr_t H5Gget_linkval(hid_t loc_id, const char *name, size_t size, char *buf/*out*/) { - H5VL_object_t *vol_obj = NULL; /* object token of loc_id */ + H5VL_object_t *vol_obj; /* Object token of loc_id */ H5VL_loc_params_t loc_params; herr_t ret_value = SUCCEED; /* Return value */ @@ -690,8 +683,7 @@ H5Gget_linkval(hid_t loc_id, const char *name, size_t size, char *buf/*out*/) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "invalid location identifier") /* Get the link value */ - if((ret_value = H5VL_link_get(vol_obj->data, loc_params, vol_obj->driver->cls, H5VL_LINK_GET_VAL, - H5P_DATASET_XFER_DEFAULT, H5_REQUEST_NULL, buf, size)) < 0) + if(H5VL_link_get(vol_obj, &loc_params, H5VL_LINK_GET_VAL, H5P_DATASET_XFER_DEFAULT, H5_REQUEST_NULL, buf, size) < 0) HGOTO_ERROR(H5E_SYM, H5E_CANTGET, FAIL, "unable to get link value") done: @@ -719,14 +711,13 @@ done: herr_t H5Gset_comment(hid_t loc_id, const char *name, const char *comment) { - H5G_loc_t loc; /* Group's location */ - herr_t ret_value = SUCCEED; /* Return value */ + H5VL_object_t *vol_obj; /* Object token of loc_id */ + H5VL_loc_params_t loc_params; + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_API(FAIL) H5TRACE3("e", "i*s*s", loc_id, name, comment); - if(H5G_loc(loc_id, &loc) < 0) - HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a location") if(!name || !*name) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "no name specified") @@ -734,8 +725,18 @@ H5Gset_comment(hid_t loc_id, const char *name, const char *comment) if(H5CX_set_loc(loc_id) < 0) HGOTO_ERROR(H5E_SYM, H5E_CANTSET, FAIL, "can't set collective metadata read info") + /* Fill in location struct fields */ + loc_params.type = H5VL_OBJECT_BY_NAME; + loc_params.loc_data.loc_by_name.name = name; + loc_params.loc_data.loc_by_name.lapl_id = H5P_LINK_ACCESS_DEFAULT; + loc_params.obj_type = H5I_get_type(loc_id); + + /* Get the location object */ + if(NULL == (vol_obj = H5VL_vol_object(loc_id))) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "invalid location identifier") + /* Set the comment */ - if(H5G_loc_set_comment(&loc, name, comment) < 0) + if(H5VL_object_optional(vol_obj, H5P_DATASET_XFER_DEFAULT, H5_REQUEST_NULL, H5VL_NATIVE_OBJECT_SET_COMMENT, &loc_params, comment) < 0) HGOTO_ERROR(H5E_SYM, H5E_CANTSET, FAIL, "unable to set comment value") done: @@ -769,26 +770,39 @@ done: int H5Gget_comment(hid_t loc_id, const char *name, size_t bufsize, char *buf) { - H5G_loc_t loc; /* Group's location */ + H5VL_object_t *vol_obj; /* Object token of loc_id */ + H5VL_loc_params_t loc_params; + ssize_t op_ret; /* Return value from operation */ int ret_value; /* Return value */ - FUNC_ENTER_API(FAIL) + FUNC_ENTER_API(-1) H5TRACE4("Is", "i*sz*s", loc_id, name, bufsize, buf); - if(H5G_loc(loc_id, &loc) < 0) - HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a location") if(!name || !*name) - HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "no name specified") + HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, -1, "no name specified") if(bufsize > 0 && !buf) - HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "no buffer specified") + HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, -1, "no buffer specified") /* Set up collective metadata if appropriate */ if(H5CX_set_loc(loc_id) < 0) - HGOTO_ERROR(H5E_SYM, H5E_CANTSET, FAIL, "can't set collective metadata read info") + HGOTO_ERROR(H5E_SYM, H5E_CANTSET, -1, "can't set collective metadata read info") + + /* Fill in location struct fields */ + loc_params.type = H5VL_OBJECT_BY_NAME; + loc_params.loc_data.loc_by_name.name = name; + loc_params.loc_data.loc_by_name.lapl_id = H5P_LINK_ACCESS_DEFAULT; + loc_params.obj_type = H5I_get_type(loc_id); + + /* Get the location object */ + if(NULL == (vol_obj = H5VL_vol_object(loc_id))) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, -1, "invalid location identifier") /* Get the comment */ - if((ret_value = (int)H5G_loc_get_comment(&loc, name, buf, bufsize)) < 0) - HGOTO_ERROR(H5E_SYM, H5E_CANTGET, FAIL, "unable to get comment value") + if(H5VL_object_optional(vol_obj, H5P_DATASET_XFER_DEFAULT, H5_REQUEST_NULL, H5VL_NATIVE_OBJECT_GET_COMMENT, &loc_params, buf, bufsize, &op_ret) < 0) + HGOTO_ERROR(H5E_SYM, H5E_CANTGET, -1, "unable to get comment value") + + /* Set return value */ + ret_value = (int)op_ret; done: FUNC_LEAVE_API(ret_value) @@ -823,18 +837,17 @@ herr_t H5Giterate(hid_t loc_id, const char *name, int *idx_p, H5G_iterate_t op, void *op_data) { - H5G_loc_t loc; /* Location of object */ + H5VL_object_t *vol_obj; /* Object token of loc_id */ + H5VL_loc_params_t loc_params; H5G_link_iterate_t lnk_op; /* Link operator */ hsize_t last_obj; /* Index of last object looked at */ - hsize_t idx; /* Internal location to hold index */ + hsize_t idx; /* Internal location to hold index */ herr_t ret_value; /* Return value */ FUNC_ENTER_API(FAIL) H5TRACE5("e", "i*s*Isx*x", loc_id, name, idx_p, op, op_data); /* Check args */ - if(H5G_loc(loc_id, &loc) < 0) - HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a location ID") if(!name || !*name) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "no name specified") if(idx_p && *idx_p < 0) @@ -850,9 +863,19 @@ H5Giterate(hid_t loc_id, const char *name, int *idx_p, H5G_iterate_t op, lnk_op.op_type = H5G_LINK_OP_OLD; lnk_op.op_func.op_old = op; - /* Call private function */ - if((ret_value = H5G_iterate(&loc, name, H5_INDEX_NAME, H5_ITER_INC, idx, &last_obj, &lnk_op, op_data)) < 0) - HGOTO_ERROR(H5E_SYM, H5E_BADITER, FAIL, "group iteration failed") + /* Fill out location struct */ + loc_params.type = H5VL_OBJECT_BY_NAME; + loc_params.loc_data.loc_by_name.name = name; + loc_params.loc_data.loc_by_name.lapl_id = H5P_LINK_ACCESS_DEFAULT; + loc_params.obj_type = H5I_get_type(loc_id); + + /* Get the object pointer */ + if(NULL == (vol_obj = H5VL_vol_object(loc_id))) + HGOTO_ERROR(H5E_ATOM, H5E_BADTYPE, (-1), "invalid identifier") + + /* Call private iteration function, through VOL callback */ + if((ret_value = H5VL_group_optional(vol_obj, H5P_DATASET_XFER_DEFAULT, H5_REQUEST_NULL, H5VL_NATIVE_GROUP_ITERATE_OLD, &loc_params, idx, &last_obj, &lnk_op, op_data)) < 0) + HERROR(H5E_SYM, H5E_BADITER, "error iterating over group's links"); /* Set the index we stopped at */ if(idx_p) @@ -882,29 +905,35 @@ done: herr_t H5Gget_num_objs(hid_t loc_id, hsize_t *num_objs) { - H5G_loc_t loc; /* Location of object */ + H5VL_object_t *vol_obj; /* Object token of loc_id */ + H5I_type_t id_type; /* Type of ID */ + H5VL_loc_params_t loc_params; H5G_info_t grp_info; /* Group information */ - H5O_type_t obj_type; /* Type of object at location */ - herr_t ret_value = SUCCEED; + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_API(FAIL) H5TRACE2("e", "i*h", loc_id, num_objs); /* Check args */ - if(H5G_loc(loc_id, &loc) < 0) - HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a location ID") - if(H5O_obj_type(loc.oloc, &obj_type) < 0) - HGOTO_ERROR(H5E_ARGS, H5E_CANTGET, FAIL, "can't get object type") - if(obj_type != H5O_TYPE_GROUP) - HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a group") + id_type = H5I_get_type(loc_id); + if(!(H5I_GROUP == id_type || H5I_FILE == id_type)) + HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "invalid group (or file) ID") if(!num_objs) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "bad pointer to # of objects") - /* Retrieve information about the group */ - if(H5G__obj_info(loc.oloc, &grp_info) < 0) - HGOTO_ERROR(H5E_SYM, H5E_CANTCOUNT, FAIL, "can't determine # of objects") + /* Fill in location struct fields */ + loc_params.type = H5VL_OBJECT_BY_SELF; + loc_params.obj_type = id_type; - /* Set the number of objects [sic: links] in the group */ + /* Get group location */ + if(NULL == (vol_obj = (H5VL_object_t *)H5I_object(loc_id))) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "invalid location identifier") + + /* Retrieve the group's information */ + if(H5VL_group_get(vol_obj, H5VL_GROUP_GET_INFO, H5P_DATASET_XFER_DEFAULT, H5_REQUEST_NULL, &loc_params, &grp_info) < 0) + HGOTO_ERROR(H5E_SYM, H5E_CANTGET, FAIL, "unable to get group info") + + /* Set the number of objects [i.e. links] in the group */ *num_objs = grp_info.nlinks; done: @@ -931,23 +960,40 @@ done: */ herr_t H5Gget_objinfo(hid_t loc_id, const char *name, hbool_t follow_link, - H5G_stat_t *statbuf/*out*/) + H5G_stat_t *statbuf/*out*/) { - H5G_loc_t loc; /* Group's location */ - herr_t ret_value = SUCCEED; /* Return value */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_API(FAIL) H5TRACE4("e", "i*sbx", loc_id, name, follow_link, statbuf); /* Check arguments */ - if(H5G_loc(loc_id, &loc) < 0) - HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a location") if(!name || !*name) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "no name specified") - /* Get info */ - if(H5G__get_objinfo(&loc, name, follow_link, statbuf) < 0) - HGOTO_ERROR(H5E_SYM, H5E_CANTGET, FAIL, "cannot stat object") + /* Set up collective metadata if appropriate */ + if(H5CX_set_loc(loc_id) < 0) + HGOTO_ERROR(H5E_SYM, H5E_CANTSET, FAIL, "can't set collective metadata read info") + + /* Retrieve object info, if pointer to struct is given */ + if(statbuf) { + H5VL_object_t *vol_obj; /* Object token of loc_id */ + H5VL_loc_params_t loc_params; + + /* Fill out location struct */ + loc_params.type = H5VL_OBJECT_BY_NAME; + loc_params.loc_data.loc_by_name.name = name; + loc_params.loc_data.loc_by_name.lapl_id = H5P_LINK_ACCESS_DEFAULT; + loc_params.obj_type = H5I_get_type(loc_id); + + /* Get the location object */ + if(NULL == (vol_obj = H5VL_vol_object(loc_id))) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "invalid location identifier") + + /* Retrieve the object's information */ + if(H5VL_group_optional(vol_obj, H5P_DATASET_XFER_DEFAULT, H5_REQUEST_NULL, H5VL_NATIVE_GROUP_GET_OBJINFO, &loc_params, (unsigned)follow_link, statbuf) < 0) + HGOTO_ERROR(H5E_SYM, H5E_CANTGET, FAIL, "can't get info for object: '%s'", name) + } /* end if */ done: FUNC_LEAVE_API(ret_value) @@ -972,6 +1018,7 @@ H5G__get_objinfo_cb(H5G_loc_t H5_ATTR_UNUSED *grp_loc/*in*/, const char *name, c H5G_loc_t *obj_loc, void *_udata/*in,out*/, H5G_own_loc_t *own_loc/*out*/) { H5G_trav_goi_t *udata = (H5G_trav_goi_t *)_udata; /* User data passed in */ + H5G_stat_t *statbuf = udata->statbuf; /* Convenience pointer for statbuf */ herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_STATIC @@ -980,48 +1027,43 @@ H5G__get_objinfo_cb(H5G_loc_t H5_ATTR_UNUSED *grp_loc/*in*/, const char *name, c if(lnk == NULL && obj_loc == NULL) HGOTO_ERROR(H5E_SYM, H5E_NOTFOUND, FAIL, "'%s' doesn't exist", name) - /* Only modify user's buffer if it's available */ - if(udata->statbuf) { - H5G_stat_t *statbuf = udata->statbuf; /* Convenience pointer for statbuf */ - - /* Common code to retrieve the file's fileno */ - if(H5F_get_fileno((obj_loc ? obj_loc : grp_loc)->oloc->file, &statbuf->fileno[0]) < 0) - HGOTO_ERROR(H5E_FILE, H5E_BADVALUE, FAIL, "unable to read fileno") + /* Common code to retrieve the file's fileno */ + if(H5F_get_fileno((obj_loc ? obj_loc : grp_loc)->oloc->file, &statbuf->fileno[0]) < 0) + HGOTO_ERROR(H5E_FILE, H5E_BADVALUE, FAIL, "unable to read fileno") - /* Info for soft and UD links is gotten by H5L_get_info. If we have - * a hard link, follow it and get info on the object - */ - if(udata->follow_link || !lnk || (lnk->type == H5L_TYPE_HARD)) { - H5O_info_t oinfo; /* Object information */ + /* Info for soft and UD links is gotten by H5L_get_info. If we have + * a hard link, follow it and get info on the object + */ + if(udata->follow_link || !lnk || (lnk->type == H5L_TYPE_HARD)) { + H5O_info_t oinfo; /* Object information */ - /* Go retrieve the object information */ - /* (don't need index & heap info) */ - HDassert(obj_loc); - if(H5O_get_info(obj_loc->oloc, &oinfo, H5O_INFO_BASIC|H5O_INFO_TIME|H5O_INFO_HDR) < 0) - HGOTO_ERROR(H5E_OHDR, H5E_CANTGET, FAIL, "unable to get object info") + /* Go retrieve the object information */ + /* (don't need index & heap info) */ + HDassert(obj_loc); + if(H5O_get_info(obj_loc->oloc, &oinfo, H5O_INFO_BASIC|H5O_INFO_TIME|H5O_INFO_HDR) < 0) + HGOTO_ERROR(H5E_OHDR, H5E_CANTGET, FAIL, "unable to get object info") - /* Get mapped object type */ - statbuf->type = H5G_map_obj_type(oinfo.type); + /* Get mapped object type */ + statbuf->type = H5G_map_obj_type(oinfo.type); - /* Get object number (i.e. address) for object */ - statbuf->objno[0] = (unsigned long)(oinfo.addr); + /* Get object number (i.e. address) for object */ + statbuf->objno[0] = (unsigned long)(oinfo.addr); #if H5_SIZEOF_UINT64_T > H5_SIZEOF_LONG - statbuf->objno[1] = (unsigned long)(oinfo.addr >> 8 * sizeof(long)); + statbuf->objno[1] = (unsigned long)(oinfo.addr >> 8 * sizeof(long)); #else - statbuf->objno[1] = 0; + statbuf->objno[1] = 0; #endif - /* Get # of hard links pointing to object */ - statbuf->nlink = oinfo.rc; + /* Get # of hard links pointing to object */ + statbuf->nlink = oinfo.rc; - /* Get modification time for object */ - statbuf->mtime = oinfo.ctime; + /* Get modification time for object */ + statbuf->mtime = oinfo.ctime; - /* Retrieve the object header information */ - statbuf->ohdr.size = oinfo.hdr.space.total; - statbuf->ohdr.free = oinfo.hdr.space.free; - statbuf->ohdr.nmesgs = oinfo.hdr.nmesgs; - statbuf->ohdr.nchunks = oinfo.hdr.nchunks; - } /* end if */ + /* Retrieve the object header information */ + statbuf->ohdr.size = oinfo.hdr.space.total; + statbuf->ohdr.free = oinfo.hdr.space.free; + statbuf->ohdr.nmesgs = oinfo.hdr.nmesgs; + statbuf->ohdr.nchunks = oinfo.hdr.nchunks; } /* end if */ done: @@ -1049,22 +1091,22 @@ done: * *------------------------------------------------------------------------- */ -static herr_t +herr_t H5G__get_objinfo(const H5G_loc_t *loc, const char *name, hbool_t follow_link, H5G_stat_t *statbuf/*out*/) { H5G_trav_goi_t udata; /* User data for callback */ herr_t ret_value = SUCCEED; /* Return value */ - FUNC_ENTER_STATIC + FUNC_ENTER_PACKAGE /* Sanity checks */ HDassert(loc); HDassert(name && *name); + HDassert(statbuf); - /* Reset stat buffer, if one was given */ - if(statbuf) - HDmemset(statbuf, 0, sizeof(H5G_stat_t)); + /* Reset stat buffer */ + HDmemset(statbuf, 0, sizeof(H5G_stat_t)); /* Set up user data for retrieving information */ udata.statbuf = statbuf; @@ -1072,12 +1114,11 @@ H5G__get_objinfo(const H5G_loc_t *loc, const char *name, hbool_t follow_link, udata.loc_file = loc->oloc->file; /* Traverse the group hierarchy to locate the object to get info about */ - if(H5G_traverse(loc, name, (unsigned)(follow_link ? H5G_TARGET_NORMAL : H5G_TARGET_SLINK|H5G_TARGET_UDLINK), - H5G__get_objinfo_cb, &udata) < 0) + if(H5G_traverse(loc, name, (unsigned)(follow_link ? H5G_TARGET_NORMAL : (H5G_TARGET_SLINK | H5G_TARGET_UDLINK)), H5G__get_objinfo_cb, &udata) < 0) HGOTO_ERROR(H5E_SYM, H5E_EXISTS, FAIL, "name doesn't exist") /* If we're pointing at a soft or UD link, get the real link length and type */ - if(statbuf && follow_link == 0) { + if(follow_link == 0) { H5L_info_t linfo; /* Link information buffer */ herr_t ret; @@ -1129,24 +1170,33 @@ done: ssize_t H5Gget_objname_by_idx(hid_t loc_id, hsize_t idx, char *name, size_t size) { - H5G_loc_t loc; /* Object location */ - H5O_type_t obj_type; /* Type of object at location */ - ssize_t ret_value; + H5VL_object_t *vol_obj; /* Object token of loc_id */ + H5VL_loc_params_t loc_params; + ssize_t ret_value; /* Return value */ FUNC_ENTER_API(FAIL) H5TRACE4("Zs", "ih*sz", loc_id, idx, name, size); - /* Check args */ - if(H5G_loc(loc_id, &loc) < 0) - HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a location ID") - if(H5O_obj_type(loc.oloc, &obj_type) < 0) - HGOTO_ERROR(H5E_ARGS, H5E_CANTGET, FAIL, "can't get object type") - if(obj_type != H5O_TYPE_GROUP) - HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a group") + /* Set up collective metadata if appropriate */ + if(H5CX_set_loc(loc_id) < 0) + HGOTO_ERROR(H5E_SYM, H5E_CANTSET, (-1), "can't set collective metadata read info") + + /* Fill in location struct fields */ + loc_params.type = H5VL_OBJECT_BY_IDX; + loc_params.loc_data.loc_by_idx.name = "."; + loc_params.loc_data.loc_by_idx.idx_type = H5_INDEX_NAME; + loc_params.loc_data.loc_by_idx.order = H5_ITER_INC; + loc_params.loc_data.loc_by_idx.n = idx; + loc_params.loc_data.loc_by_idx.lapl_id = H5P_LINK_ACCESS_DEFAULT; + loc_params.obj_type = H5I_get_type(loc_id); + + /* Get the location object */ + if(NULL == (vol_obj = (H5VL_object_t *)H5I_object(loc_id))) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, (-1), "invalid location identifier") /* Call internal function */ - if((ret_value = H5G_obj_get_name_by_idx(loc.oloc, H5_INDEX_NAME, H5_ITER_INC, idx, name, size)) < 0) - HGOTO_ERROR(H5E_SYM, H5E_CANTGET, FAIL, "can't get object name") + if(H5VL_link_get(vol_obj, &loc_params, H5VL_LINK_GET_NAME, H5P_DATASET_XFER_DEFAULT, H5_REQUEST_NULL, name, size, &ret_value) < 0) + HGOTO_ERROR(H5E_SYM, H5E_CANTGET, (-1), "can't get object name") done: FUNC_LEAVE_API(ret_value) @@ -1171,82 +1221,39 @@ done: H5G_obj_t H5Gget_objtype_by_idx(hid_t loc_id, hsize_t idx) { - H5G_loc_t loc; /* Object location */ - H5G_obj_t ret_value; + H5VL_object_t *vol_obj; /* Object token of loc_id */ + H5VL_loc_params_t loc_params; + H5O_info_t oinfo; /* Object info (contains object type) */ + unsigned fields; /* Which fields in object info to populate */ + H5G_obj_t ret_value; /* Return value */ FUNC_ENTER_API(H5G_UNKNOWN) H5TRACE2("Go", "ih", loc_id, idx); - /* Check args */ - if(H5G_loc(loc_id, &loc) < 0) - HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, H5G_UNKNOWN, "not a location ID") - - /* Call internal function*/ - if(H5G_UNKNOWN == (ret_value = H5G__obj_get_type_by_idx(loc.oloc, idx))) - HGOTO_ERROR(H5E_SYM, H5E_BADTYPE, H5G_UNKNOWN, "can't get object type") - -done: - FUNC_LEAVE_API(ret_value) -} /* end H5Gget_objtype_by_idx() */ - - -/*------------------------------------------------------------------------- - * Function: H5G__obj_get_type_by_idx - * - * Purpose: Private function for H5Gget_objtype_by_idx. - * Returns the type of objects in the group by giving index. - * - * Return: Success: H5G_GROUP(1), H5G_DATASET(2), H5G_TYPE(3) - * - * Failure: Negative - * - * Programmer: Raymond Lu - * Nov 20, 2002 - * - *------------------------------------------------------------------------- - */ -static H5G_obj_t -H5G__obj_get_type_by_idx(H5O_loc_t *oloc, hsize_t idx) -{ - H5O_linfo_t linfo; /* Link info message */ - htri_t linfo_exists; /* Whether the link info message exists */ - H5O_type_t obj_type; /* Type of object at location */ - H5G_obj_t ret_value = H5G_UNKNOWN; /* Return value */ + /* Set location parameters */ + loc_params.type = H5VL_OBJECT_BY_IDX; + loc_params.loc_data.loc_by_idx.name = "."; + loc_params.loc_data.loc_by_idx.idx_type = H5_INDEX_NAME; + loc_params.loc_data.loc_by_idx.order = H5_ITER_INC; + loc_params.loc_data.loc_by_idx.n = idx; + loc_params.loc_data.loc_by_idx.lapl_id = H5P_LINK_ACCESS_DEFAULT; + loc_params.obj_type = H5I_get_type(loc_id); - FUNC_ENTER_STATIC_TAG(oloc->addr) + /* Get the location object */ + if(NULL == (vol_obj = H5VL_vol_object(loc_id))) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, H5G_UNKNOWN, "invalid location identifier") - /* Sanity check */ - HDassert(oloc); + /* Retrieve the object's basic information (which includes its type) */ + fields = H5O_INFO_BASIC; + if(H5VL_object_optional(vol_obj, H5P_DATASET_XFER_DEFAULT, H5_REQUEST_NULL, H5VL_NATIVE_OBJECT_GET_INFO, &loc_params, &oinfo, fields) < 0) + HGOTO_ERROR(H5E_SYM, H5E_BADTYPE, H5G_UNKNOWN, "can't get object info") - /* Check args */ - if(H5O_obj_type(oloc, &obj_type) < 0) - HGOTO_ERROR(H5E_SYM, H5E_CANTGET, H5G_UNKNOWN, "can't get object type") - if(obj_type != H5O_TYPE_GROUP) - HGOTO_ERROR(H5E_SYM, H5E_BADTYPE, H5G_UNKNOWN, "not a group") - - /* Attempt to get the link info for this group */ - if((linfo_exists = H5G__obj_get_linfo(oloc, &linfo)) < 0) - HGOTO_ERROR(H5E_SYM, H5E_CANTGET, H5G_UNKNOWN, "can't check for link info message") - if(linfo_exists) { - if(H5F_addr_defined(linfo.fheap_addr)) { - /* Get the object's name from the dense link storage */ - if((ret_value = H5G__dense_get_type_by_idx(oloc->file, &linfo, idx)) < 0) - HGOTO_ERROR(H5E_SYM, H5E_NOTFOUND, H5G_UNKNOWN, "can't locate type") - } /* end if */ - else { - /* Get the object's type from the link messages */ - if((ret_value = H5G__compact_get_type_by_idx(oloc, &linfo, idx)) < 0) - HGOTO_ERROR(H5E_SYM, H5E_NOTFOUND, H5G_UNKNOWN, "can't locate type") - } /* end else */ - } /* end if */ - else { - /* Get the object's type from the symbol table */ - if((ret_value = H5G__stab_get_type_by_idx(oloc, idx)) < 0) - HGOTO_ERROR(H5E_SYM, H5E_NOTFOUND, H5G_UNKNOWN, "can't locate type") - } /* end else */ + /* Map to group object type */ + if(H5G_UNKNOWN == (ret_value = H5G_map_obj_type(oinfo.type))) + HGOTO_ERROR(H5E_SYM, H5E_BADTYPE, H5G_UNKNOWN, "can't determine object type") done: - FUNC_LEAVE_NOAPI_TAG(ret_value) -} /* end H5G__obj_get_type_by_idx() */ + FUNC_LEAVE_API(ret_value) +} /* end H5Gget_objtype_by_idx() */ #endif /* H5_NO_DEPRECATED_SYMBOLS */ diff --git a/src/H5Gint.c b/src/H5Gint.c index 26c582e..049c696 100644 --- a/src/H5Gint.c +++ b/src/H5Gint.c @@ -39,7 +39,6 @@ #include "H5Iprivate.h" /* IDs */ #include "H5Lprivate.h" /* Links */ #include "H5MMprivate.h" /* Memory management */ -#include "H5VLnative_private.h" /* Native VOL driver */ /****************/ @@ -579,7 +578,7 @@ H5G_oloc(H5G_t *grp) *------------------------------------------------------------------------- */ H5G_name_t * -H5G_nameof(H5G_t *grp) +H5G_nameof(const H5G_t *grp) { /* Use FUNC_ENTER_NOAPI_NOINIT_NOERR here to avoid performance issues */ FUNC_ENTER_NOAPI_NOINIT_NOERR @@ -808,7 +807,7 @@ H5G_iterate(H5G_loc_t *loc, const char *group_name, */ if(NULL == (grp = H5G__open_name(loc, group_name))) HGOTO_ERROR(H5E_SYM, H5E_CANTOPENOBJ, FAIL, "unable to open group") - if((gid = H5VL_native_register(H5I_GROUP, grp, TRUE)) < 0) + if((gid = H5VL_wrap_register(H5I_GROUP, grp, TRUE)) < 0) HGOTO_ERROR(H5E_ATOM, H5E_CANTREGISTER, FAIL, "unable to register group") /* Set up user data for callback */ @@ -1070,7 +1069,7 @@ H5G_visit(H5G_loc_t *loc, const char *group_name, H5_index_t idx_type, HGOTO_ERROR(H5E_SYM, H5E_CANTOPENOBJ, FAIL, "unable to open group") /* Register an ID for the starting group */ - if((gid = H5VL_native_register(H5I_GROUP, grp, TRUE)) < 0) + if((gid = H5VL_wrap_register(H5I_GROUP, grp, TRUE)) < 0) HGOTO_ERROR(H5E_ATOM, H5E_CANTREGISTER, FAIL, "unable to register group") /* Get the location of the starting group */ diff --git a/src/H5Gloc.c b/src/H5Gloc.c index 2dacd94..5724031 100644 --- a/src/H5Gloc.c +++ b/src/H5Gloc.c @@ -210,9 +210,6 @@ H5G_loc_real(void *obj, H5I_type_t type, H5G_loc_t *loc) break; } - case H5I_REFERENCE: - HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "unable to get group location of reference") - case H5I_DATASPACE: HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "unable to get group location of dataspace") diff --git a/src/H5Gname.c b/src/H5Gname.c index b6b0c20..2aece2b 100644 --- a/src/H5Gname.c +++ b/src/H5Gname.c @@ -584,21 +584,9 @@ H5G_get_name(const H5G_loc_t *loc, char *name/*out*/, size_t size, *cached = TRUE; } /* end if */ else if(!loc->path->obj_hidden) { - hid_t file; - - /* Retrieve file ID for name search */ - if((file = H5F_get_id(loc->oloc->file, FALSE)) < 0) - HGOTO_ERROR(H5E_SYM, H5E_CANTGET, FAIL, "can't get file ID") - /* Search for name of object */ - if((len = H5G_get_name_by_addr(file, loc->oloc, name, size)) < 0) { - H5I_dec_ref(file); + if((len = H5G_get_name_by_addr(loc->oloc->file, loc->oloc, name, size)) < 0) HGOTO_ERROR(H5E_SYM, H5E_CANTGET, FAIL, "can't determine name") - } /* end if */ - - /* Close file ID used for search */ - if(H5I_dec_ref(file) < 0) - HGOTO_ERROR(H5E_SYM, H5E_CANTCLOSEFILE, FAIL, "can't determine name") /* Indicate that the name is _not_ cached, if requested */ /* (Currently only used for testing - QAK, 2010/07/26) */ @@ -833,7 +821,6 @@ H5G_name_replace_cb(void *obj_ptr, hid_t obj_id, void *key) case H5I_FILE: case H5I_DATASPACE: case H5I_ATTR: - case H5I_REFERENCE: case H5I_VFL: case H5I_VOL: case H5I_GENPROP_CLS: @@ -1282,8 +1269,7 @@ done: *------------------------------------------------------------------------- */ ssize_t -H5G_get_name_by_addr(hid_t file, const H5O_loc_t *loc, - char *name, size_t size) +H5G_get_name_by_addr(H5F_t *f, const H5O_loc_t *loc, char *name, size_t size) { H5G_gnba_iter_t udata; /* User data for iteration */ H5G_loc_t root_loc; /* Root group's location */ @@ -1296,8 +1282,8 @@ H5G_get_name_by_addr(hid_t file, const H5O_loc_t *loc, FUNC_ENTER_NOAPI((-1)) - /* Construct the link info for the file's root group */ - if(H5G_loc(file, &root_loc) < 0) + /* Construct a group location for root group of the file */ + if(H5G_root_loc(f, &root_loc) < 0) HGOTO_ERROR(H5E_SYM, H5E_CANTGET, (-1), "can't get root group's location") /* Check for root group being the object looked for */ diff --git a/src/H5Gpkg.h b/src/H5Gpkg.h index 836213d..f475bde 100644 --- a/src/H5Gpkg.h +++ b/src/H5Gpkg.h @@ -381,9 +381,6 @@ H5_DLL herr_t H5G__stab_lookup_by_idx(const H5O_loc_t *grp_oloc, H5_iter_order_t #ifndef H5_STRICT_FORMAT_CHECKS H5_DLL herr_t H5G__stab_valid(H5O_loc_t *grp_oloc, H5O_stab_t *alt_stab); #endif /* H5_STRICT_FORMAT_CHECKS */ -#ifndef H5_NO_DEPRECATED_SYMBOLS -H5_DLL H5G_obj_t H5G__stab_get_type_by_idx(H5O_loc_t *oloc, hsize_t idx); -#endif /* H5_NO_DEPRECATED_SYMBOLS */ /* @@ -448,10 +445,6 @@ H5_DLL htri_t H5G__compact_lookup(const H5O_loc_t *grp_oloc, const char *name, H5_DLL herr_t H5G__compact_lookup_by_idx(const H5O_loc_t *oloc, const H5O_linfo_t *linfo, H5_index_t idx_type, H5_iter_order_t order, hsize_t n, H5O_link_t *lnk); -#ifndef H5_NO_DEPRECATED_SYMBOLS -H5_DLL H5G_obj_t H5G__compact_get_type_by_idx(H5O_loc_t *oloc, - const H5O_linfo_t *linfo, hsize_t idx); -#endif /* H5_NO_DEPRECATED_SYMBOLS */ /* Functions that understand "dense" link storage */ H5_DLL herr_t H5G__dense_build_table(H5F_t *f, const H5O_linfo_t *linfo, @@ -476,10 +469,6 @@ H5_DLL herr_t H5G__dense_remove_by_idx(H5F_t *f, const H5O_linfo_t *linfo, H5RS_str_t *grp_full_path_r, H5_index_t idx_type, H5_iter_order_t order, hsize_t n); H5_DLL herr_t H5G__dense_delete(H5F_t *f, H5O_linfo_t *linfo, hbool_t adj_link); -#ifndef H5_NO_DEPRECATED_SYMBOLS -H5_DLL H5G_obj_t H5G__dense_get_type_by_idx(H5F_t *f, H5O_linfo_t *linfo, - hsize_t idx); -#endif /* H5_NO_DEPRECATED_SYMBOLS */ /* Functions that understand group objects */ H5_DLL herr_t H5G__obj_create(H5F_t *f, H5G_obj_create_t *gcrt_info, @@ -494,6 +483,10 @@ H5_DLL herr_t H5G__obj_iterate(const H5O_loc_t *grp_oloc, H5_DLL herr_t H5G__obj_info(const H5O_loc_t *oloc, H5G_info_t *grp_info); H5_DLL htri_t H5G__obj_lookup(const H5O_loc_t *grp_oloc, const char *name, H5O_link_t *lnk); +#ifndef H5_NO_DEPRECATED_SYMBOLS +H5_DLL herr_t H5G__get_objinfo(const H5G_loc_t *loc, const char *name, + hbool_t follow_link, H5G_stat_t *statbuf/*out*/); +#endif /* H5_NO_DEPRECATED_SYMBOLS */ /* * These functions operate on group hierarchy names. diff --git a/src/H5Gprivate.h b/src/H5Gprivate.h index f4f04bc..f149f29 100644 --- a/src/H5Gprivate.h +++ b/src/H5Gprivate.h @@ -187,7 +187,7 @@ typedef struct H5G_entry_t H5G_entry_t; * call. */ H5_DLL struct H5O_loc_t *H5G_oloc(H5G_t *grp); -H5_DLL H5G_name_t * H5G_nameof(H5G_t *grp); +H5_DLL H5G_name_t * H5G_nameof(const H5G_t *grp); H5_DLL H5F_t *H5G_fileof(H5G_t *grp); H5_DLL H5G_t *H5G_open(const H5G_loc_t *loc); H5_DLL herr_t H5G_close(H5G_t *grp); @@ -261,7 +261,7 @@ H5_DLL herr_t H5G_name_copy(H5G_name_t *dst, const H5G_name_t *src, H5_copy_dept H5_DLL herr_t H5G_name_free(H5G_name_t *name); H5_DLL ssize_t H5G_get_name(const H5G_loc_t *loc, char *name/*out*/, size_t size, hbool_t *cached); -H5_DLL ssize_t H5G_get_name_by_addr(hid_t fid, const struct H5O_loc_t *loc, +H5_DLL ssize_t H5G_get_name_by_addr(H5F_t *f, const struct H5O_loc_t *loc, char* name, size_t size); H5_DLL H5RS_str_t *H5G_build_fullpath_refstr_str(H5RS_str_t *path_r, const char *name); diff --git a/src/H5Gpublic.h b/src/H5Gpublic.h index ab6f200..170b74d 100644 --- a/src/H5Gpublic.h +++ b/src/H5Gpublic.h @@ -37,10 +37,6 @@ /* Public Macros */ /*****************/ -#ifdef __cplusplus -extern "C" { -#endif - /*******************/ /* Public Typedefs */ /*******************/ @@ -62,6 +58,7 @@ typedef struct H5G_info_t { hbool_t mounted; /* Whether group has a file mounted on it */ } H5G_info_t; + /********************/ /* Public Variables */ /********************/ @@ -70,6 +67,10 @@ typedef struct H5G_info_t { /*********************/ /* Public Prototypes */ /*********************/ +#ifdef __cplusplus +extern "C" { +#endif + H5_DLL hid_t H5Gcreate2(hid_t loc_id, const char *name, hid_t lcpl_id, hid_t gcpl_id, hid_t gapl_id); H5_DLL hid_t H5Gcreate_anon(hid_t loc_id, hid_t gcpl_id, hid_t gapl_id); diff --git a/src/H5Gstab.c b/src/H5Gstab.c index 9072b97..e8d38b9 100644 --- a/src/H5Gstab.c +++ b/src/H5Gstab.c @@ -1103,118 +1103,3 @@ done: } /* end H5G__stab_valid */ #endif /* H5_STRICT_FORMAT_CHECKS */ -#ifndef H5_NO_DEPRECATED_SYMBOLS - -/*------------------------------------------------------------------------- - * Function: H5G_stab_get_type_by_idx_cb - * - * Purpose: Callback for B-tree iteration 'by index' info query to - * retrieve the type of an object - * - * Return: Success: Non-negative - * Failure: Negative - * - * Programmer: Quincey Koziol - * Nov 7, 2006 - * - *------------------------------------------------------------------------- - */ -static herr_t -H5G_stab_get_type_by_idx_cb(const H5G_entry_t *ent, void *_udata) -{ - H5G_bt_it_gtbi_t *udata = (H5G_bt_it_gtbi_t *)_udata; - herr_t ret_value = SUCCEED; /* Return value */ - - FUNC_ENTER_NOAPI_NOINIT - - /* Sanity check */ - HDassert(ent); - HDassert(udata); - - /* Check for a soft link */ - switch(ent->type) { - case H5G_CACHED_SLINK: - udata->type = H5G_LINK; - break; - - case H5G_CACHED_ERROR: - case H5G_NOTHING_CACHED: - case H5G_CACHED_STAB: - case H5G_NCACHED: - default: - { - H5O_loc_t tmp_oloc; /* Temporary object location */ - H5O_type_t obj_type; /* Type of object at location */ - - /* Build temporary object location */ - tmp_oloc.file = udata->f; - HDassert(H5F_addr_defined(ent->header)); - tmp_oloc.addr = ent->header; - - /* Get the type of the object */ - if(H5O_obj_type(&tmp_oloc, &obj_type) < 0) - HGOTO_ERROR(H5E_SYM, H5E_CANTGET, FAIL, "can't get object type") - udata->type = H5G_map_obj_type(obj_type); - } - break; - } /* end switch */ - -done: - FUNC_LEAVE_NOAPI(ret_value) -} /* end H5G_stab_get_type_by_idx_cb */ - - -/*------------------------------------------------------------------------- - * Function: H5G__stab_get_type_by_idx - * - * Purpose: Private function for H5Gget_objtype_by_idx. - * Returns the type of objects in the group by giving index. - * - * Return: Success: H5G_GROUP(1), H5G_DATASET(2), H5G_TYPE(3) - * - * Failure: UNKNOWN - * - * Programmer: Raymond Lu - * Nov 20, 2002 - * - *------------------------------------------------------------------------- - */ -H5G_obj_t -H5G__stab_get_type_by_idx(H5O_loc_t *oloc, hsize_t idx) -{ - H5O_stab_t stab; /* Info about local heap & B-tree */ - H5G_bt_it_gtbi_t udata; /* User data for B-tree callback */ - H5G_obj_t ret_value = H5G_UNKNOWN; /* Return value */ - - FUNC_ENTER_PACKAGE_TAG(oloc->addr) - - /* Sanity check */ - HDassert(oloc); - - /* Get the B-tree & local heap info */ - if(NULL == H5O_msg_read(oloc, H5O_STAB_ID, &stab)) - HGOTO_ERROR(H5E_SYM, H5E_NOTFOUND, H5G_UNKNOWN, "unable to determine local heap address") - - /* Set iteration information */ - udata.common.idx = idx; - udata.common.num_objs = 0; - udata.common.op = H5G_stab_get_type_by_idx_cb; - udata.f = oloc->file; - udata.type = H5G_UNKNOWN; - - /* Iterate over the group members */ - if(H5B_iterate(oloc->file, H5B_SNODE, stab.btree_addr, H5G__node_by_idx, &udata) < 0) - HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, H5G_UNKNOWN, "iteration operator failed") - - /* If we don't know the type now, we almost certainly went out of bounds */ - if(udata.type == H5G_UNKNOWN) - HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, H5G_UNKNOWN, "index out of bound") - - /* Set the return value */ - ret_value = udata.type; - -done: - FUNC_LEAVE_NOAPI_TAG(ret_value) -} /* end H5G__stab_get_type_by_idx() */ -#endif /* H5_NO_DEPRECATED_SYMBOLS */ - diff --git a/src/H5Gtest.c b/src/H5Gtest.c index 1995015..af6acb3 100644 --- a/src/H5Gtest.c +++ b/src/H5Gtest.c @@ -609,7 +609,6 @@ H5G__user_path_test(hid_t obj_id, char *user_path, size_t *user_path_len, unsign case H5I_FILE: case H5I_DATASPACE: case H5I_ATTR: - case H5I_REFERENCE: case H5I_VFL: case H5I_VOL: case H5I_GENPROP_CLS: diff --git a/src/H5Gtraverse.c b/src/H5Gtraverse.c index 8fefcd8..d029bea 100644 --- a/src/H5Gtraverse.c +++ b/src/H5Gtraverse.c @@ -43,7 +43,6 @@ #include "H5MMprivate.h" /* Memory management */ #include "H5Ppublic.h" /* Property Lists */ #include "H5WBprivate.h" /* Wrapped Buffers */ -#include "H5VLnative_private.h" /* Native VOL driver */ /****************/ @@ -198,7 +197,7 @@ H5G__traverse_ud(const H5G_loc_t *grp_loc/*in,out*/, const H5O_link_t *lnk, /* Create a group ID to pass to the user-defined callback */ if(NULL == (grp = H5G_open(&grp_loc_copy))) HGOTO_ERROR(H5E_SYM, H5E_CANTOPENOBJ, FAIL, "unable to open group") - if((cur_grp = H5VL_native_register(H5I_GROUP, grp, FALSE)) < 0) + if((cur_grp = H5VL_wrap_register(H5I_GROUP, grp, FALSE)) < 0) HGOTO_ERROR(H5E_SYM, H5E_CANTREGISTER, FAIL, "unable to register group") /* User-defined callback function */ @@ -785,7 +785,14 @@ H5HG_remove (H5F_t *f, H5HG_t *hobj) HGOTO_ERROR(H5E_HEAP, H5E_CANTPROTECT, FAIL, "unable to protect global heap") HDassert(hobj->idx < heap->nused); - HDassert(heap->obj[hobj->idx].begin); + + /* When the application selects the same location to rewrite the VL element by using H5Sselect_elements, + * it can happen that the entry has been removed by first rewrite. Here we simply skip the removal of + * the entry and let the second rewrite happen (see HDFFV-10635). In the future, it'd be nice to handle + * this situation in H5T_conv_vlen in H5Tconv.c instead of this level (HDFFV-10648). */ + if(heap->obj[hobj->idx].nrefs == 0 && heap->obj[hobj->idx].size == 0 && !heap->obj[hobj->idx].begin) + HGOTO_DONE(ret_value) + obj_start = heap->obj[hobj->idx].begin; /* Include object header size */ need = H5HG_ALIGN(heap->obj[hobj->idx].size) + H5HG_SIZEOF_OBJHDR(f); @@ -33,8 +33,9 @@ #include "H5ACprivate.h" /* Metadata cache */ #include "H5CXprivate.h" /* API Contexts */ #include "H5Dprivate.h" /* Datasets */ -#include "H5Eprivate.h" /* Error handling */ -#include "H5FLprivate.h" /* Free Lists */ +#include "H5Eprivate.h" /* Error handling */ +#include "H5Fprivate.h" /* File access */ +#include "H5FLprivate.h" /* Free Lists */ #include "H5Gprivate.h" /* Groups */ #include "H5Ipkg.h" /* IDs */ #include "H5MMprivate.h" /* Memory management */ @@ -130,6 +131,7 @@ H5FL_DEFINE_STATIC(H5I_class_t); H5FL_EXTERN(H5VL_object_t); /*--------------------- Local function prototypes ---------------------------*/ +static void *H5I__unwrap(void *obj_ptr, H5I_type_t type); static htri_t H5I__clear_type_cb(void *_id, void *key, void *udata); static int H5I__destroy_type(H5I_type_t type); static void *H5I__remove_verify(hid_t id, H5I_type_t id_type); @@ -139,7 +141,6 @@ static int H5I__get_type_ref(H5I_type_t type); static int H5I__search_cb(void *obj, hid_t id, void *_udata); static H5I_id_info_t *H5I__find_id(hid_t id); static int H5I__iterate_pub_cb(void *obj, hid_t id, void *udata); -static hid_t H5I__get_file_id(hid_t obj_id, H5I_type_t id_type); static int H5I__find_id_cb(void *_item, void *_key, void *_udata); static int H5I__id_dump_cb(void *_item, void *_key, void *_udata); @@ -452,6 +453,50 @@ done: /*------------------------------------------------------------------------- + * Function: H5I__unwrap + * + * Purpose: Unwraps the object pointer for the 'item' that corresponds + * to an ID. + * + * Return: Pointer to the unwrapped pointer (can't fail) + * + * Programmer: Quincey Koziol + * Friday, October 19, 2018 + * + *------------------------------------------------------------------------- + */ +static void * +H5I__unwrap(void *obj_ptr, H5I_type_t type) +{ + void *ret_value = NULL; /* Return value */ + + FUNC_ENTER_STATIC_NOERR + + /* Sanity checks */ + HDassert(obj_ptr); + + /* The stored object pointer might be an H5VL_object_t, in which + * case we'll need to get the wrapped object struct (H5F_t *, etc.). + */ + if(H5I_FILE == type || H5I_GROUP == type || H5I_DATASET == type || H5I_ATTR == type) { + const H5VL_object_t *vol_obj; + + vol_obj = (const H5VL_object_t *)obj_ptr; + ret_value = H5VL_object_data(vol_obj); + } /* end if */ + else if(H5I_DATATYPE == type) { + H5T_t *dt = (H5T_t *)obj_ptr; + + ret_value = (void *)H5T_get_actual_type(dt); + } /* end if */ + else + ret_value = obj_ptr; + + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5I__unwrap() */ + + +/*------------------------------------------------------------------------- * Function: H5Iclear_type * * Purpose: Removes all objects from the type, calling the free @@ -547,6 +592,7 @@ H5I__clear_type_cb(void *_id, void H5_ATTR_UNUSED *key, void *_udata) FUNC_ENTER_STATIC_NOERR + /* Sanity checks */ HDassert(id); HDassert(udata); HDassert(udata->type_ptr); @@ -556,8 +602,7 @@ H5I__clear_type_cb(void *_id, void H5_ATTR_UNUSED *key, void *_udata) */ if(udata->force || (id->count - (!udata->app_ref * id->app_count)) <= 1) { /* Check for a 'free' function and call it, if it exists */ - /* (Casting away const OK -QAK) */ - if(udata->type_ptr->cls->free_func && (udata->type_ptr->cls->free_func)((void *)id->obj_ptr) < 0) { + if(udata->type_ptr->cls->free_func && (udata->type_ptr->cls->free_func)((void *)id->obj_ptr) < 0) { /* (Casting away const OK -QAK) */ if(udata->force) { #ifdef H5I_DEBUG if(H5DEBUG(I)) { @@ -858,8 +903,7 @@ H5I_subst(hid_t id, const void *new_object) HGOTO_ERROR(H5E_ATOM, H5E_NOTFOUND, NULL, "can't get ID ref count") /* Get the old object pointer to return */ - /* (Casting away const OK -QAK) */ - ret_value = (void *)id_ptr->obj_ptr; + ret_value = (void *)id_ptr->obj_ptr; /* (Casting away const OK -QAK) */ /* Set the new object pointer for the ID */ id_ptr->obj_ptr = new_object; @@ -1980,16 +2024,7 @@ H5I__iterate_cb(void *_item, void H5_ATTR_UNUSED *_key, void *_udata) /* The stored object pointer might be an H5VL_object_t, in which * case we'll need to get the wrapped object struct (H5F_t *, etc.). */ - if(H5I_FILE == type || H5I_GROUP == type || H5I_DATASET == type || H5I_ATTR == type) { - const H5VL_object_t *vol_obj = (const H5VL_object_t *)item->obj_ptr; - obj_ptr = vol_obj->data; - } - else if(H5I_DATATYPE == type) { - const H5T_t *dt = (const H5T_t *)item->obj_ptr; - obj_ptr = (void *)H5T_get_actual_type(dt); - } - else - obj_ptr = item->obj_ptr; + obj_ptr = H5I__unwrap((void *)item->obj_ptr, type); /* Invoke callback function */ cb_ret_val = (*udata->user_func)((void *)obj_ptr, item->id, udata->user_udata); /* (Casting away const OK) */ @@ -1999,7 +2034,7 @@ H5I__iterate_cb(void *_item, void H5_ATTR_UNUSED *_key, void *_udata) ret_value = H5_ITER_STOP; /* terminate iteration early */ else if(cb_ret_val < 0) ret_value = H5_ITER_ERROR; /* indicate failure (which terminates iteration) */ - } + } /* end if */ FUNC_LEAVE_NOAPI(ret_value) } /* end H5I__iterate_cb() */ @@ -2057,7 +2092,7 @@ H5I_iterate(H5I_type_t type, H5I_search_func_t func, void *udata, hbool_t app_re /* Iterate over IDs */ if ((iter_status = H5SL_iterate(type_ptr->ids, H5I__iterate_cb, &iter_udata)) < 0) HGOTO_ERROR(H5E_ATOM, H5E_BADITER, FAIL, "iteration failed") - } + } /* end if */ done: FUNC_LEAVE_NOAPI(ret_value) @@ -2111,7 +2146,7 @@ done: * * Failure: -1 * - * NOTE: Not safe for arbitrary VOL drivers as it relies on + * NOTE: Not safe for arbitrary VOL connectors as it relies on * private H5G calls. * * Comments: Public function @@ -2129,18 +2164,24 @@ done: ssize_t H5Iget_name(hid_t id, char *name/*out*/, size_t size) { + H5VL_object_t *vol_obj; /* Object token of loc_id */ + H5VL_loc_params_t loc_params; H5G_loc_t loc; /* Object location */ ssize_t ret_value; /* Return value */ FUNC_ENTER_API((-1)) H5TRACE3("Zs", "ixz", id, name, size); - /* Get object location */ - if(H5G_loc(id, &loc) < 0) - HGOTO_ERROR(H5E_ATOM, H5E_CANTGET, (-1), "can't retrieve object location") + /* Get the object pointer */ + if(NULL == (vol_obj = H5VL_vol_object(id))) + HGOTO_ERROR(H5E_ATOM, H5E_BADTYPE, (-1), "invalid identifier") + + /* Set location parameters */ + loc_params.type = H5VL_OBJECT_BY_SELF; + loc_params.obj_type = H5I_get_type(id); /* Retrieve object's name */ - if((ret_value = H5G_get_name(&loc, name, size, NULL)) < 0) + if(H5VL_object_get(vol_obj, &loc_params, H5VL_ID_GET_NAME, H5P_DATASET_XFER_DEFAULT, H5_REQUEST_NULL, &ret_value, name, size) < 0) HGOTO_ERROR(H5E_ATOM, H5E_CANTGET, (-1), "can't retrieve object name") done: @@ -2174,9 +2215,9 @@ H5Iget_file_id(hid_t obj_id) /* Call internal function */ if (H5I_FILE == type || H5I_DATATYPE == type || H5I_GROUP == type || H5I_DATASET == type || H5I_ATTR == type) { - if ((ret_value = H5I__get_file_id(obj_id, type)) < 0) + if ((ret_value = H5F_get_file_id(obj_id, type)) < 0) HGOTO_ERROR(H5E_ATOM, H5E_CANTGET, H5I_INVALID_HID, "can't retrieve file ID") - } + } /* end if */ else HGOTO_ERROR(H5E_ARGS, H5E_BADRANGE, H5I_INVALID_HID, "not an ID of a file object") @@ -2186,56 +2227,6 @@ done: /*------------------------------------------------------------------------- - * Function: H5I__get_file_id - * - * Purpose: The private version of H5Iget_file_id(), obtains the file - * ID given an object ID. - * - * Return: Success: The file ID associated with the object - * Failure: H5I_INVALID_HID - * - *------------------------------------------------------------------------- - */ -static hid_t -H5I__get_file_id(hid_t obj_id, H5I_type_t type) -{ - H5VL_object_t *vol_obj = NULL; - void *file = NULL; - hid_t ret_value = H5I_INVALID_HID; /* Return value */ - - FUNC_ENTER_STATIC - - /* Get the object pointer */ - if (NULL == (vol_obj = H5VL_vol_object(obj_id))) - HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, H5I_INVALID_HID, "invalid identifier") - - /* Get the file through the VOL */ - if (H5VL_file_get(vol_obj->data, vol_obj->driver->cls, H5VL_OBJECT_GET_FILE, H5P_DATASET_XFER_DEFAULT, H5_REQUEST_NULL, type, &file) < 0) - HGOTO_ERROR(H5E_FILE, H5E_CANTINIT, H5I_INVALID_HID, "unable to get file") - if (NULL == file) - HGOTO_ERROR(H5E_FILE, H5E_CANTINIT, H5I_INVALID_HID, "unable to get the file through the VOL") - - /* Check if the file's ID already exists */ - if (H5I_find_id(file, H5I_FILE, &ret_value) < 0) - HGOTO_ERROR(H5E_ATOM, H5E_CANTGET, H5I_INVALID_HID, "getting file ID failed") - - /* If the ID does not exist, register it with the VOL driver */ - if (H5I_INVALID_HID == ret_value) { - if ((ret_value = H5VL_register(H5I_FILE, file, vol_obj->driver, TRUE)) < 0) - HGOTO_ERROR(H5E_ATOM, H5E_CANTREGISTER, H5I_INVALID_HID, "unable to atomize file handle") - } - else { - /* Increment ref count on existing ID */ - if (H5I_inc_ref(ret_value, TRUE) < 0) - HGOTO_ERROR(H5E_ATOM, H5E_CANTSET, H5I_INVALID_HID, "incrementing file ID failed") - } - -done: - FUNC_LEAVE_NOAPI(ret_value) -} /* end H5I__get_file_id() */ - - -/*------------------------------------------------------------------------- * Function: H5I__find_id_cb * * Purpose: Callback for searching for an ID with a specific pointer @@ -2260,23 +2251,14 @@ H5I__find_id_cb(void *_item, void H5_ATTR_UNUSED *_key, void *_udata) HDassert(item); HDassert(udata); - /* Get a pointer to the VOL driver's data */ - if (H5I_FILE == type || H5I_GROUP == type || H5I_DATASET == type || H5I_ATTR == type) { - const H5VL_object_t *vol_obj = (const H5VL_object_t *)item->obj_ptr; - obj_ptr = vol_obj->data; - } - else if (H5I_DATATYPE == type) { - const H5T_t *dt = (const H5T_t *)item->obj_ptr; - obj_ptr = (void *)H5T_get_actual_type(dt); - } - else - obj_ptr = item->obj_ptr; + /* Get a pointer to the VOL connector's data */ + obj_ptr = H5I__unwrap(item->obj_ptr, type); /* Check for a match */ if (obj_ptr == udata->object) { udata->ret_id = item->id; ret_value = H5_ITER_STOP; - } + } /* end if */ FUNC_LEAVE_NOAPI(ret_value) } /* end H5I__find_id_cb() */ @@ -2324,7 +2306,7 @@ H5I_find_id(const void *object, H5I_type_t type, hid_t *id) HGOTO_ERROR(H5E_ATOM, H5E_BADITER, FAIL, "iteration failed") *id = udata.ret_id; - } + } /* end if */ done: FUNC_LEAVE_NOAPI(ret_value) @@ -2346,7 +2328,7 @@ H5I__id_dump_cb(void *_item, void H5_ATTR_UNUSED *_key, void *_udata) H5I_id_info_t *item = (H5I_id_info_t *)_item; /* Pointer to the ID node */ H5I_type_t type = *(H5I_type_t *)_udata; /* User data */ H5G_name_t *path = NULL; /* Path to file object */ - const void *obj_ptr = NULL; /* Pointer to VOL driver object */ + const void *obj_ptr = NULL; /* Pointer to VOL connector object */ FUNC_ENTER_STATIC_NOERR @@ -2360,37 +2342,36 @@ H5I__id_dump_cb(void *_item, void H5_ATTR_UNUSED *_key, void *_udata) { const H5VL_object_t *vol_obj = (const H5VL_object_t *)item->obj_ptr; - obj_ptr = vol_obj->data; - - if(H5_VOL_NATIVE == vol_obj->driver->cls->value) - path = H5G_nameof((H5G_t *)obj_ptr); + obj_ptr = H5VL_object_data(vol_obj); + if(H5_VOL_NATIVE == vol_obj->connector->cls->value) + path = H5G_nameof((const H5G_t *)obj_ptr); break; } + case H5I_DATASET: { const H5VL_object_t *vol_obj = (const H5VL_object_t *)item->obj_ptr; - obj_ptr = vol_obj->data; - - if(H5_VOL_NATIVE == vol_obj->driver->cls->value) - path = H5D_nameof((H5D_t *)obj_ptr); + obj_ptr = H5VL_object_data(vol_obj); + if(H5_VOL_NATIVE == vol_obj->connector->cls->value) + path = H5D_nameof((const H5D_t *)obj_ptr); break; } + case H5I_DATATYPE: { const H5T_t *dt = (const H5T_t *)item->obj_ptr; - obj_ptr = (void *)H5T_get_actual_type(dt); - - path = H5T_nameof((H5T_t *)obj_ptr); + obj_ptr = (void *)H5T_get_actual_type((H5T_t *)dt); /* Casting away const OK - QAK */ + path = H5T_nameof((const H5T_t *)obj_ptr); break; } + case H5I_UNINIT: case H5I_BADID: case H5I_FILE: case H5I_DATASPACE: case H5I_ATTR: - case H5I_REFERENCE: case H5I_VFL: case H5I_VOL: case H5I_GENPROP_CLS: diff --git a/src/H5Ipublic.h b/src/H5Ipublic.h index f4b5cc9..56873ec 100644 --- a/src/H5Ipublic.h +++ b/src/H5Ipublic.h @@ -29,9 +29,6 @@ * * When adding types here, add a section to the 'misc19' test in test/tmisc.c * to verify that the H5I{inc|dec|get}_ref() routines work correctly with it. - * - * NOTE: H5I_REFERENCE is not used by the library and has been deprecated - * with a tentative removal version of 1.12.0. (DER, July 2017) */ typedef enum H5I_type_t { H5I_UNINIT = (-2), /* uninitialized type */ @@ -42,7 +39,6 @@ typedef enum H5I_type_t { H5I_DATASPACE, /* type ID for Dataspace objects */ H5I_DATASET, /* type ID for Dataset objects */ H5I_ATTR, /* type ID for Attribute objects */ - H5I_REFERENCE, /* *DEPRECATED* type ID for Reference objects */ H5I_VFL, /* type ID for virtual file layer */ H5I_VOL, /* type ID for virtual object layer */ H5I_GENPROP_CLS, /* type ID for generic property list classes */ diff --git a/src/H5Itest.c b/src/H5Itest.c index 4b54835..79bc482 100644 --- a/src/H5Itest.c +++ b/src/H5Itest.c @@ -78,26 +78,41 @@ ssize_t H5I__get_name_test(hid_t id, char *name/*out*/, size_t size, hbool_t *cached) { + H5VL_object_t *vol_obj; /* Object token of id */ H5G_loc_t loc; /* Object location */ hbool_t api_ctx_pushed = FALSE; /* Whether API context pushed */ + hbool_t vol_wrapper_set = FALSE;/* Whether the VOL object wrapping context was set up */ ssize_t ret_value = -1; /* Return value */ FUNC_ENTER_PACKAGE - /* Get object location */ - if(H5G_loc(id, &loc) < 0) - HGOTO_ERROR(H5E_ATOM, H5E_CANTGET, (-1), "can't retrieve object location") - /* Set API context */ if(H5CX_push() < 0) HGOTO_ERROR(H5E_SYM, H5E_CANTSET, (-1), "can't set API context") api_ctx_pushed = TRUE; + /* Get the object pointer */ + if(NULL == (vol_obj = H5VL_vol_object(id))) + HGOTO_ERROR(H5E_ATOM, H5E_BADTYPE, (-1), "invalid identifier") + + /* Set wrapper info in API context */ + if(H5VL_set_vol_wrapper(vol_obj->data, vol_obj->connector) < 0) + HGOTO_ERROR(H5E_ATOM, H5E_CANTSET, FAIL, "can't set VOL wrapper info") + vol_wrapper_set = TRUE; + + /* Get object location */ + if(H5G_loc(id, &loc) < 0) + HGOTO_ERROR(H5E_ATOM, H5E_CANTGET, (-1), "can't retrieve object location") + /* Call internal group routine to retrieve object's name */ if((ret_value = H5G_get_name(&loc, name, size, cached)) < 0) HGOTO_ERROR(H5E_ATOM, H5E_CANTGET, (-1), "can't retrieve object name") done: + /* Reset object wrapping info in API context */ + if(vol_wrapper_set && H5VL_reset_vol_wrapper() < 0) + HDONE_ERROR(H5E_ATOM, H5E_CANTRESET, FAIL, "can't reset VOL wrapper info") + if(api_ctx_pushed && H5CX_pop() < 0) HDONE_ERROR(H5E_SYM, H5E_CANTRESET, (-1), "can't reset API context") @@ -34,7 +34,6 @@ #include "H5Oprivate.h" /* File objects */ #include "H5Pprivate.h" /* Property lists */ #include "H5VLprivate.h" /* Virtual Object Layer */ -#include "H5VLnative_private.h" /* Native VOL driver */ /****************/ @@ -316,28 +315,22 @@ H5Lmove(hid_t src_loc_id, const char *src_name, hid_t dst_loc_id, loc_params2.loc_data.loc_by_name.lapl_id = lapl_id; loc_params2.obj_type = H5I_get_type(dst_loc_id); - if (H5L_SAME_LOC != src_loc_id) { + if (H5L_SAME_LOC != src_loc_id) /* Get the location object */ if (NULL == (vol_obj1 = (H5VL_object_t *)H5I_object(src_loc_id))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "invalid location identifier") - } - if (H5L_SAME_LOC != dst_loc_id) { + if (H5L_SAME_LOC != dst_loc_id) /* Get the location object */ if (NULL == (vol_obj2 = (H5VL_object_t *)H5I_object(dst_loc_id))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "invalid location identifier") - } - /* Make sure that the VOL drivers are the same */ - if (vol_obj1 && vol_obj2) { - if (vol_obj1->driver->cls->value != vol_obj2->driver->cls->value) - HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "Objects are accessed through different VOL plugins and can't be linked") - } + /* Make sure that the VOL connectors are the same */ + if (vol_obj1 && vol_obj2) + if (vol_obj1->connector->cls->value != vol_obj2->connector->cls->value) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "Objects are accessed through different VOL connectors and can't be linked") /* Move the link */ - if (H5VL_link_move((vol_obj1 ? vol_obj1->data : NULL), loc_params1, - (vol_obj2 ? vol_obj2->data : NULL), loc_params2, - (vol_obj1 ? vol_obj1->driver->cls : vol_obj2->driver->cls), - lcpl_id, lapl_id, H5P_DATASET_XFER_DEFAULT, H5_REQUEST_NULL) < 0) + if(H5VL_link_move(vol_obj1, &loc_params1, vol_obj2, &loc_params2, lcpl_id, lapl_id, H5P_DATASET_XFER_DEFAULT, H5_REQUEST_NULL) < 0) HGOTO_ERROR(H5E_LINK, H5E_CANTMOVE, FAIL, "unable to move link") done: @@ -367,6 +360,7 @@ H5Lcopy(hid_t src_loc_id, const char *src_name, hid_t dst_loc_id, H5VL_loc_params_t loc_params1; H5VL_object_t *vol_obj2 = NULL; /* Object token of dst_id */ H5VL_loc_params_t loc_params2; + H5VL_object_t tmp_vol_obj; /* Temporary object token of */ herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_API(FAIL) @@ -392,7 +386,6 @@ H5Lcopy(hid_t src_loc_id, const char *src_name, hid_t dst_loc_id, if(H5P_DEFAULT == lcpl_id) lcpl_id = H5P_LINK_CREATE_DEFAULT; - /* Set location paramter for source object */ loc_params1.type = H5VL_OBJECT_BY_NAME; loc_params1.loc_data.loc_by_name.name = src_name; @@ -405,28 +398,26 @@ H5Lcopy(hid_t src_loc_id, const char *src_name, hid_t dst_loc_id, loc_params2.loc_data.loc_by_name.lapl_id = lapl_id; loc_params2.obj_type = H5I_get_type(dst_loc_id); - if(H5L_SAME_LOC != src_loc_id) { + if(H5L_SAME_LOC != src_loc_id) /* Get the location object */ if(NULL == (vol_obj1 = (H5VL_object_t *)H5I_object(src_loc_id))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "invalid location identifier") - } - if(H5L_SAME_LOC != dst_loc_id) { + if(H5L_SAME_LOC != dst_loc_id) /* Get the location object */ if(NULL == (vol_obj2 = (H5VL_object_t *)H5I_object(dst_loc_id))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "invalid location identifier") - } - /* Make sure that the VOL plugins are the same */ - if(vol_obj1 && vol_obj2) { - if(vol_obj1->driver->cls->value != vol_obj2->driver->cls->value) - HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "Objects are accessed through different VOL plugins and can't be linked") - } + /* Make sure that the VOL connectors are the same */ + if(vol_obj1 && vol_obj2) + if(vol_obj1->connector->cls->value != vol_obj2->connector->cls->value) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "Objects are accessed through different VOL connectors and can't be linked") + + /* Construct a temporary source VOL object */ + tmp_vol_obj.data = (vol_obj1 ? vol_obj1->data : NULL); + tmp_vol_obj.connector = (vol_obj1 ? vol_obj1->connector : vol_obj2->connector); /* Copy the link */ - if(H5VL_link_copy((vol_obj1 ? vol_obj1->data : NULL), loc_params1, - (vol_obj2 ? vol_obj2->data : NULL), loc_params2, - (vol_obj1 ? vol_obj1->driver->cls : vol_obj2->driver->cls), - lcpl_id, lapl_id, H5P_DATASET_XFER_DEFAULT, H5_REQUEST_NULL) < 0) + if(H5VL_link_copy(&tmp_vol_obj, &loc_params1, vol_obj2, &loc_params2, lcpl_id, lapl_id, H5P_DATASET_XFER_DEFAULT, H5_REQUEST_NULL) < 0) HGOTO_ERROR(H5E_LINK, H5E_CANTMOVE, FAIL, "unable to copy link") done: @@ -505,8 +496,7 @@ H5Lcreate_soft(const char *link_target, hid_t link_loc_id, const char *link_name HGOTO_ERROR(H5E_LINK, H5E_CANTSET, FAIL, "can't set access property list info") /* Create the link */ - if(H5VL_link_create(H5VL_LINK_CREATE_SOFT, vol_obj->data, loc_params, vol_obj->driver->cls, - lcpl_id, lapl_id, H5P_DATASET_XFER_DEFAULT, H5_REQUEST_NULL) < 0) + if(H5VL_link_create(H5VL_LINK_CREATE_SOFT, vol_obj, &loc_params, lcpl_id, lapl_id, H5P_DATASET_XFER_DEFAULT, H5_REQUEST_NULL) < 0) HGOTO_ERROR(H5E_LINK, H5E_CANTCREATE, FAIL, "unable to create soft link") done: @@ -534,8 +524,9 @@ herr_t H5Lcreate_hard(hid_t cur_loc_id, const char *cur_name, hid_t new_loc_id, const char *new_name, hid_t lcpl_id, hid_t lapl_id) { - H5VL_object_t *vol_obj1 = NULL; /* object token of cur_loc_id */ - H5VL_object_t *vol_obj2 = NULL; /* object token of new_loc_id */ + H5VL_object_t *vol_obj1 = NULL; /* Object token of cur_loc_id */ + H5VL_object_t *vol_obj2 = NULL; /* Object token of new_loc_id */ + H5VL_object_t tmp_vol_obj; /* Temporary object token of */ H5VL_loc_params_t loc_params1; H5VL_loc_params_t loc_params2; H5P_genplist_t *plist; /* Property list pointer */ @@ -578,22 +569,19 @@ H5Lcreate_hard(hid_t cur_loc_id, const char *cur_name, loc_params2.loc_data.loc_by_name.name = new_name; loc_params2.loc_data.loc_by_name.lapl_id = lapl_id; - if(H5L_SAME_LOC != cur_loc_id) { + if(H5L_SAME_LOC != cur_loc_id) /* Get the current location object */ if (NULL == (vol_obj1 = (H5VL_object_t *)H5VL_vol_object(cur_loc_id))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "invalid location identifier") - } - if(H5L_SAME_LOC != new_loc_id) { + if(H5L_SAME_LOC != new_loc_id) /* Get the new location object */ if(NULL == (vol_obj2 = (H5VL_object_t *)H5VL_vol_object(new_loc_id))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "invalid location identifier") - } - /* Make sure that the VOL drivers are the same */ - if(vol_obj1 && vol_obj2) { - if(vol_obj1->driver->cls->value != vol_obj2->driver->cls->value) - HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "Objects are accessed through different VOL drivers and can't be linked") - } + /* Make sure that the VOL connectors are the same */ + if(vol_obj1 && vol_obj2) + if(vol_obj1->connector->cls->value != vol_obj2->connector->cls->value) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "Objects are accessed through different VOL connectors and can't be linked") /* Get the link creation plist structure */ if(NULL == (plist = (H5P_genplist_t *)H5I_object(lcpl_id))) @@ -605,10 +593,12 @@ H5Lcreate_hard(hid_t cur_loc_id, const char *cur_name, if(H5P_set(plist, H5VL_PROP_LINK_TARGET_LOC_PARAMS, &loc_params1) < 0) HGOTO_ERROR(H5E_LINK, H5E_CANTGET, FAIL, "can't set property value for target name") + /* Construct a temporary VOL object */ + tmp_vol_obj.data = (vol_obj2 ? (vol_obj2->data) : NULL); + tmp_vol_obj.connector = (vol_obj1 != NULL ? vol_obj1->connector : vol_obj2->connector); + /* Create the link */ - if(H5VL_link_create(H5VL_LINK_CREATE_HARD, (vol_obj2 ? (vol_obj2->data) : NULL), loc_params2, - (vol_obj1 != NULL ? vol_obj1->driver->cls : vol_obj2->driver->cls), - lcpl_id, lapl_id, H5P_DATASET_XFER_DEFAULT, H5_REQUEST_NULL) < 0) + if(H5VL_link_create(H5VL_LINK_CREATE_HARD, &tmp_vol_obj, &loc_params2, lcpl_id, lapl_id, H5P_DATASET_XFER_DEFAULT, H5_REQUEST_NULL) < 0) HGOTO_ERROR(H5E_LINK, H5E_CANTCREATE, FAIL, "unable to create hard link") done: @@ -644,10 +634,10 @@ herr_t H5Lcreate_ud(hid_t link_loc_id, const char *link_name, H5L_type_t link_type, const void *udata, size_t udata_size, hid_t lcpl_id, hid_t lapl_id) { - H5VL_object_t *vol_obj = NULL; /* object token of loc_id */ + H5VL_object_t *vol_obj = NULL; /* Object token of loc_id */ H5VL_loc_params_t loc_params; - H5P_genplist_t *plist; /* Property list pointer */ - herr_t ret_value = SUCCEED; /* Return value */ + H5P_genplist_t *plist; /* Property list pointer */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_API(FAIL) H5TRACE7("e", "i*sLl*xzii", link_loc_id, link_name, link_type, udata, @@ -689,8 +679,7 @@ H5Lcreate_ud(hid_t link_loc_id, const char *link_name, H5L_type_t link_type, HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, FAIL, "can't get property value from plist") /* Create external link */ - if(H5VL_link_create(H5VL_LINK_CREATE_UD, vol_obj->data, loc_params, vol_obj->driver->cls, - lcpl_id, lapl_id, H5P_DATASET_XFER_DEFAULT, H5_REQUEST_NULL) < 0) + if(H5VL_link_create(H5VL_LINK_CREATE_UD, vol_obj, &loc_params, lcpl_id, lapl_id, H5P_DATASET_XFER_DEFAULT, H5_REQUEST_NULL) < 0) HGOTO_ERROR(H5E_LINK, H5E_CANTINIT, FAIL, "unable to create link") done: @@ -744,8 +733,7 @@ H5Ldelete(hid_t loc_id, const char *name, hid_t lapl_id) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "invalid location identifier") /* Unlink */ - if(H5VL_link_specific(vol_obj->data, loc_params, vol_obj->driver->cls, H5VL_LINK_DELETE, - H5P_DATASET_XFER_DEFAULT, H5_REQUEST_NULL) < 0) + if(H5VL_link_specific(vol_obj, &loc_params, H5VL_LINK_DELETE, H5P_DATASET_XFER_DEFAULT, H5_REQUEST_NULL) < 0) HGOTO_ERROR(H5E_LINK, H5E_CANTDELETE, FAIL, "unable to delete link") done: @@ -808,8 +796,7 @@ H5Ldelete_by_idx(hid_t loc_id, const char *group_name, H5_index_t idx_type, HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "invalid location identifier") /* Delete the link */ - if(H5VL_link_specific(vol_obj->data, loc_params, vol_obj->driver->cls, H5VL_LINK_DELETE, - H5P_DATASET_XFER_DEFAULT, H5_REQUEST_NULL) < 0) + if(H5VL_link_specific(vol_obj, &loc_params, H5VL_LINK_DELETE, H5P_DATASET_XFER_DEFAULT, H5_REQUEST_NULL) < 0) HGOTO_ERROR(H5E_LINK, H5E_CANTDELETE, FAIL, "unable to delete link") done: @@ -865,8 +852,7 @@ H5Lget_val(hid_t loc_id, const char *name, void *buf/*out*/, size_t size, HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "invalid location identifier") /* Get the link value */ - if(H5VL_link_get(vol_obj->data, loc_params, vol_obj->driver->cls, H5VL_LINK_GET_VAL, - H5P_DATASET_XFER_DEFAULT, H5_REQUEST_NULL, buf, size) < 0) + if(H5VL_link_get(vol_obj, &loc_params, H5VL_LINK_GET_VAL, H5P_DATASET_XFER_DEFAULT, H5_REQUEST_NULL, buf, size) < 0) HGOTO_ERROR(H5E_LINK, H5E_CANTGET, FAIL, "unable to get link value for '%s'", name) done: @@ -930,8 +916,7 @@ H5Lget_val_by_idx(hid_t loc_id, const char *group_name, H5_index_t idx_type, HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "invalid location identifier") /* Get the link value */ - if(H5VL_link_get(vol_obj->data, loc_params, vol_obj->driver->cls, H5VL_LINK_GET_VAL, - H5P_DATASET_XFER_DEFAULT, H5_REQUEST_NULL, buf, size) < 0) + if(H5VL_link_get(vol_obj, &loc_params, H5VL_LINK_GET_VAL, H5P_DATASET_XFER_DEFAULT, H5_REQUEST_NULL, buf, size) < 0) HGOTO_ERROR(H5E_LINK, H5E_CANTGET, FAIL, "unable to get link value") done: @@ -982,8 +967,7 @@ H5Lexists(hid_t loc_id, const char *name, hid_t lapl_id) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "invalid location identifier") /* Check for the existence of the link */ - if(H5VL_link_specific(vol_obj->data, loc_params, vol_obj->driver->cls, H5VL_LINK_EXISTS, - H5P_DATASET_XFER_DEFAULT, H5_REQUEST_NULL, &ret_value) < 0) + if(H5VL_link_specific(vol_obj, &loc_params, H5VL_LINK_EXISTS, H5P_DATASET_XFER_DEFAULT, H5_REQUEST_NULL, &ret_value) < 0) HGOTO_ERROR(H5E_LINK, H5E_CANTGET, FAIL, "unable to get link info") done: @@ -1034,8 +1018,7 @@ H5Lget_info(hid_t loc_id, const char *name, H5L_info_t *linfo /*out*/, HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "invalid location identifier") /* Get the link information */ - if(H5VL_link_get(vol_obj->data, loc_params, vol_obj->driver->cls, H5VL_LINK_GET_INFO, - H5P_DATASET_XFER_DEFAULT, H5_REQUEST_NULL, linfo) < 0) + if(H5VL_link_get(vol_obj, &loc_params, H5VL_LINK_GET_INFO, H5P_DATASET_XFER_DEFAULT, H5_REQUEST_NULL, linfo) < 0) HGOTO_ERROR(H5E_LINK, H5E_CANTGET, FAIL, "unable to get link info") done: @@ -1095,8 +1078,7 @@ H5Lget_info_by_idx(hid_t loc_id, const char *group_name, HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "invalid location identifier") /* Get the link information */ - if(H5VL_link_get(vol_obj->data, loc_params, vol_obj->driver->cls, H5VL_LINK_GET_INFO, - H5P_DATASET_XFER_DEFAULT, H5_REQUEST_NULL, linfo) < 0) + if(H5VL_link_get(vol_obj, &loc_params, H5VL_LINK_GET_INFO, H5P_DATASET_XFER_DEFAULT, H5_REQUEST_NULL, linfo) < 0) HGOTO_ERROR(H5E_LINK, H5E_CANTGET, FAIL, "unable to get link info") done: @@ -1292,8 +1274,7 @@ H5Lget_name_by_idx(hid_t loc_id, const char *group_name, HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, (-1), "invalid location identifier") /* Get the link information */ - if(H5VL_link_get(vol_obj->data, loc_params, vol_obj->driver->cls, H5VL_LINK_GET_NAME, - H5P_DATASET_XFER_DEFAULT, H5_REQUEST_NULL, name, size, &ret_value) < 0) + if(H5VL_link_get(vol_obj, &loc_params, H5VL_LINK_GET_NAME, H5P_DATASET_XFER_DEFAULT, H5_REQUEST_NULL, name, size, &ret_value) < 0) HGOTO_ERROR(H5E_LINK, H5E_CANTGET, (-1), "unable to get link name") done: @@ -1351,9 +1332,7 @@ H5Literate(hid_t group_id, H5_index_t idx_type, H5_iter_order_t order, loc_params.obj_type = H5I_get_type(group_id); /* Iterate over the links */ - if((ret_value = H5VL_link_specific(vol_obj->data, loc_params, vol_obj->driver->cls, H5VL_LINK_ITER, - H5P_DATASET_XFER_DEFAULT, H5_REQUEST_NULL, - FALSE, idx_type, order, idx_p, op, op_data)) < 0) + if((ret_value = H5VL_link_specific(vol_obj, &loc_params, H5VL_LINK_ITER, H5P_DATASET_XFER_DEFAULT, H5_REQUEST_NULL, (unsigned)FALSE, (int)idx_type, (int)order, idx_p, op, op_data)) < 0) HGOTO_ERROR(H5E_LINK, H5E_BADITER, FAIL, "link iteration failed") done: @@ -1423,8 +1402,7 @@ H5Literate_by_name(hid_t loc_id, const char *group_name, loc_params.loc_data.loc_by_name.lapl_id = lapl_id; /* Iterate over the links */ - if((ret_value = H5VL_link_specific(vol_obj->data, loc_params, vol_obj->driver->cls, H5VL_LINK_ITER, - H5P_DATASET_XFER_DEFAULT, H5_REQUEST_NULL, FALSE, idx_type, order, idx_p, op, op_data)) < 0) + if((ret_value = H5VL_link_specific(vol_obj, &loc_params, H5VL_LINK_ITER, H5P_DATASET_XFER_DEFAULT, H5_REQUEST_NULL, FALSE, idx_type, order, idx_p, op, op_data)) < 0) HGOTO_ERROR(H5E_LINK, H5E_BADITER, FAIL, "link iteration failed") done: @@ -1492,9 +1470,7 @@ H5Lvisit(hid_t group_id, H5_index_t idx_type, H5_iter_order_t order, HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "invalid location identifier") /* Iterate over the links */ - if((ret_value = H5VL_link_specific(vol_obj->data, loc_params, vol_obj->driver->cls, H5VL_LINK_ITER, - H5P_DATASET_XFER_DEFAULT, H5_REQUEST_NULL, - TRUE, idx_type, order, NULL, op, op_data)) < 0) + if((ret_value = H5VL_link_specific(vol_obj, &loc_params, H5VL_LINK_ITER, H5P_DATASET_XFER_DEFAULT, H5_REQUEST_NULL, TRUE, idx_type, order, NULL, op, op_data)) < 0) HGOTO_ERROR(H5E_LINK, H5E_BADITER, FAIL, "link visitation failed") done: @@ -1569,9 +1545,7 @@ H5Lvisit_by_name(hid_t loc_id, const char *group_name, H5_index_t idx_type, loc_params.loc_data.loc_by_name.lapl_id = lapl_id; /* Visit the links */ - if((ret_value = H5VL_link_specific(vol_obj->data, loc_params, vol_obj->driver->cls, H5VL_LINK_ITER, - H5P_DATASET_XFER_DEFAULT, H5_REQUEST_NULL, - TRUE, idx_type, order, NULL, op, op_data)) < 0) + if((ret_value = H5VL_link_specific(vol_obj, &loc_params, H5VL_LINK_ITER, H5P_DATASET_XFER_DEFAULT, H5_REQUEST_NULL, TRUE, idx_type, order, NULL, op, op_data)) < 0) HGOTO_ERROR(H5E_LINK, H5E_BADITER, FAIL, "link visitation failed") done: @@ -1949,7 +1923,7 @@ H5L__link_cb(H5G_loc_t *grp_loc/*in*/, const char *name, const H5O_link_t H5_ATT /* Set up location for user-defined callback */ if(NULL == (grp = H5G_open(&temp_loc))) HGOTO_ERROR(H5E_LINK, H5E_CANTOPENOBJ, FAIL, "unable to open group") - if((grp_id = H5VL_native_register(H5I_GROUP, grp, TRUE)) < 0) + if((grp_id = H5VL_wrap_register(H5I_GROUP, grp, TRUE)) < 0) HGOTO_ERROR(H5E_LINK, H5E_CANTREGISTER, FAIL, "unable to register ID for group") /* Make callback */ @@ -2734,7 +2708,7 @@ H5L__move_dest_cb(H5G_loc_t *grp_loc/*in*/, const char *name, /* Set up location for user-defined callback */ if(NULL == (grp = H5G_open(&temp_loc))) HGOTO_ERROR(H5E_LINK, H5E_CANTOPENOBJ, FAIL, "unable to open group") - if((grp_id = H5VL_native_register(H5I_GROUP, grp, TRUE)) < 0) + if((grp_id = H5VL_wrap_register(H5I_GROUP, grp, TRUE)) < 0) HGOTO_ERROR(H5E_LINK, H5E_CANTREGISTER, FAIL, "unable to register group ID") if(udata->copy) { diff --git a/src/H5Lexternal.c b/src/H5Lexternal.c index 34c96a8..0f3296f 100644 --- a/src/H5Lexternal.c +++ b/src/H5Lexternal.c @@ -34,7 +34,6 @@ #include "H5Opublic.h" /* File objects */ #include "H5Pprivate.h" /* Property lists */ #include "H5VLprivate.h" /* Virtual Object Layer */ -#include "H5VLnative_private.h" /* Native VOL driver */ /****************/ @@ -243,7 +242,7 @@ H5L__extern_traverse(const char H5_ATTR_UNUSED *link_name, hid_t cur_group, HGOTO_ERROR(H5E_LINK, H5E_CANTOPENOBJ, H5I_INVALID_HID, "unable to open object") /* Get an ID for the external link's object */ - if((ext_obj_id = H5VL_native_register(opened_type, ext_obj, TRUE)) < 0) + if((ext_obj_id = H5VL_wrap_register(opened_type, ext_obj, TRUE)) < 0) HGOTO_ERROR(H5E_ATOM, H5E_CANTREGISTER, H5I_INVALID_HID, "unable to register external link object") /* Set return value */ @@ -414,8 +413,7 @@ H5Lcreate_external(const char *file_name, const char *obj_name, HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, FAIL, "can't get property value from plist") /* Create an external link */ - if((ret_value = H5VL_link_create(H5VL_LINK_CREATE_UD, vol_obj->data, loc_params, vol_obj->driver->cls, - lcpl_id, lapl_id, H5P_DATASET_XFER_DEFAULT, H5_REQUEST_NULL)) < 0) + if(H5VL_link_create(H5VL_LINK_CREATE_UD, vol_obj, &loc_params, lcpl_id, lapl_id, H5P_DATASET_XFER_DEFAULT, H5_REQUEST_NULL) < 0) HGOTO_ERROR(H5E_LINK, H5E_CANTINIT, FAIL, "unable to create external link") done: @@ -38,6 +38,8 @@ #include "H5Lprivate.h" /* Links */ #include "H5Opkg.h" /* Object headers */ +#include "H5VLnative_private.h" /* Native VOL connector */ + /****************/ /* Local Macros */ @@ -100,7 +102,7 @@ hid_t H5Oopen(hid_t loc_id, const char *name, hid_t lapl_id) { - H5VL_object_t *vol_obj = NULL; /* Object token of loc_id */ + H5VL_object_t *vol_obj; /* Object token of loc_id */ H5I_type_t opened_type; void *opened_obj = NULL; H5VL_loc_params_t loc_params; @@ -130,13 +132,13 @@ H5Oopen(hid_t loc_id, const char *name, hid_t lapl_id) loc_params.obj_type = H5I_get_type(loc_id); /* Open the object */ - if(NULL == (opened_obj = H5VL_object_open(vol_obj->data, loc_params, vol_obj->driver->cls, - &opened_type, H5P_DATASET_XFER_DEFAULT, H5_REQUEST_NULL))) + if(NULL == (opened_obj = H5VL_object_open(vol_obj, &loc_params, &opened_type, H5P_DATASET_XFER_DEFAULT, H5_REQUEST_NULL))) HGOTO_ERROR(H5E_OHDR, H5E_CANTOPENOBJ, H5I_INVALID_HID, "unable to open object") /* Get an atom for the object */ - if((ret_value = H5VL_register(opened_type, opened_obj, vol_obj->driver, TRUE)) < 0) - HGOTO_ERROR(H5E_ATOM, H5E_CANTREGISTER, H5I_INVALID_HID, "unable to atomize object handle") + if((ret_value = H5VL_register(opened_type, opened_obj, vol_obj->connector, TRUE)) < 0) + HGOTO_ERROR(H5E_OHDR, H5E_CANTREGISTER, H5I_INVALID_HID, "unable to atomize object handle") + done: FUNC_LEAVE_API(ret_value) } /* end H5Oopen() */ @@ -169,7 +171,7 @@ hid_t H5Oopen_by_idx(hid_t loc_id, const char *group_name, H5_index_t idx_type, H5_iter_order_t order, hsize_t n, hid_t lapl_id) { - H5VL_object_t *vol_obj = NULL; /* object token of loc_id */ + H5VL_object_t *vol_obj; /* Object token of loc_id */ H5I_type_t opened_type; void *opened_obj = NULL; H5VL_loc_params_t loc_params; @@ -203,12 +205,11 @@ H5Oopen_by_idx(hid_t loc_id, const char *group_name, H5_index_t idx_type, HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, H5I_INVALID_HID, "invalid location identifier") /* Open the object */ - if(NULL == (opened_obj = H5VL_object_open(vol_obj->data, loc_params, vol_obj->driver->cls, - &opened_type, H5P_DATASET_XFER_DEFAULT, H5_REQUEST_NULL))) + if(NULL == (opened_obj = H5VL_object_open(vol_obj, &loc_params, &opened_type, H5P_DATASET_XFER_DEFAULT, H5_REQUEST_NULL))) HGOTO_ERROR(H5E_OHDR, H5E_CANTOPENOBJ, H5I_INVALID_HID, "unable to open object") - if((ret_value = H5VL_register(opened_type, opened_obj, vol_obj->driver, TRUE)) < 0) - HGOTO_ERROR(H5E_ATOM, H5E_CANTREGISTER, H5I_INVALID_HID, "unable to atomize object handle") + if((ret_value = H5VL_register(opened_type, opened_obj, vol_obj->connector, TRUE)) < 0) + HGOTO_ERROR(H5E_OHDR, H5E_CANTREGISTER, H5I_INVALID_HID, "unable to atomize object handle") done: FUNC_LEAVE_API(ret_value) @@ -253,7 +254,7 @@ done: hid_t H5Oopen_by_addr(hid_t loc_id, haddr_t addr) { - H5VL_object_t *vol_obj = NULL; /* object token of loc_id */ + H5VL_object_t *vol_obj; /* Object token of loc_id */ H5I_type_t opened_type; void *opened_obj = NULL; H5VL_loc_params_t loc_params; @@ -271,13 +272,12 @@ H5Oopen_by_addr(hid_t loc_id, haddr_t addr) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, H5I_INVALID_HID, "invalid location identifier") /* Open the object */ - if(NULL == (opened_obj = H5VL_object_open(vol_obj->data, loc_params, vol_obj->driver->cls, &opened_type, - H5P_DATASET_XFER_DEFAULT, H5_REQUEST_NULL))) + if(NULL == (opened_obj = H5VL_object_open(vol_obj, &loc_params, &opened_type, H5P_DATASET_XFER_DEFAULT, H5_REQUEST_NULL))) HGOTO_ERROR(H5E_OHDR, H5E_CANTOPENOBJ, H5I_INVALID_HID, "unable to open object") /* Register the dataset ID */ - if((ret_value = H5VL_register(opened_type, opened_obj, vol_obj->driver, TRUE)) < 0) - HGOTO_ERROR(H5E_ATOM, H5E_CANTREGISTER, H5I_INVALID_HID, "unable to atomize object handle") + if((ret_value = H5VL_register(opened_type, opened_obj, vol_obj->connector, TRUE)) < 0) + HGOTO_ERROR(H5E_OHDR, H5E_CANTREGISTER, H5I_INVALID_HID, "unable to atomize object handle") done: FUNC_LEAVE_API(ret_value) @@ -311,6 +311,7 @@ H5Olink(hid_t obj_id, hid_t new_loc_id, const char *new_name, hid_t lcpl_id, { H5VL_object_t *vol_obj1 = NULL; /* object token of obj_id */ H5VL_object_t *vol_obj2 = NULL; /* object token of new_loc_id */ + H5VL_object_t tmp_vol_obj; /* Temporary object token of */ H5VL_loc_params_t loc_params1; H5VL_loc_params_t loc_params2; H5P_genplist_t *plist; /* Property list pointer */ @@ -348,21 +349,19 @@ H5Olink(hid_t obj_id, hid_t new_loc_id, const char *new_name, hid_t lcpl_id, loc_params2.loc_data.loc_by_name.name = new_name; loc_params2.loc_data.loc_by_name.lapl_id = lapl_id; - if(H5L_SAME_LOC != obj_id) { + if(H5L_SAME_LOC != obj_id) /* get the location object */ if(NULL == (vol_obj1 = H5VL_vol_object(obj_id))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "invalid location identifier") - } - if(H5L_SAME_LOC != new_loc_id) { + if(H5L_SAME_LOC != new_loc_id) /* get the location object */ if(NULL == (vol_obj2 = H5VL_vol_object(new_loc_id))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "invalid location identifier") - } - /* Make sure that the VOL plugins are the same */ - if(vol_obj1 && vol_obj2) { - if (vol_obj1->driver->cls->value != vol_obj2->driver->cls->value) - HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "Objects are accessed through different VOL plugins and can't be linked") - } + + /* Make sure that the VOL connectors are the same */ + if(vol_obj1 && vol_obj2) + if (vol_obj1->connector->cls->value != vol_obj2->connector->cls->value) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "Objects are accessed through different VOL connectors and can't be linked") /* Get the plist structure */ if(NULL == (plist = (H5P_genplist_t *)H5I_object(lcpl_id))) @@ -374,10 +373,12 @@ H5Olink(hid_t obj_id, hid_t new_loc_id, const char *new_name, hid_t lcpl_id, if(H5P_set(plist, H5VL_PROP_LINK_TARGET_LOC_PARAMS, &loc_params1) < 0) HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, FAIL, "can't set property value for target id") + /* Construct a temporary VOL object */ + tmp_vol_obj.data = vol_obj2->data; + tmp_vol_obj.connector = (vol_obj1 != NULL ? vol_obj1->connector : vol_obj2->connector); + /* Create a link to the object */ - if(H5VL_link_create(H5VL_LINK_CREATE_HARD, vol_obj2->data, loc_params2, - (vol_obj1 != NULL ? vol_obj1->driver->cls : vol_obj2->driver->cls), - lcpl_id, lapl_id, H5P_DATASET_XFER_DEFAULT, H5_REQUEST_NULL) < 0) + if(H5VL_link_create(H5VL_LINK_CREATE_HARD, &tmp_vol_obj, &loc_params2, lcpl_id, lapl_id, H5P_DATASET_XFER_DEFAULT, H5_REQUEST_NULL) < 0) HGOTO_ERROR(H5E_OHDR, H5E_CANTCREATE, FAIL, "unable to create link") done: @@ -408,7 +409,7 @@ done: herr_t H5Oincr_refcount(hid_t object_id) { - H5VL_object_t *vol_obj = NULL; /* object token of loc_id */ + H5VL_object_t *vol_obj; /* Object token of loc_id */ H5VL_loc_params_t loc_params; herr_t ret_value = SUCCEED; @@ -427,8 +428,7 @@ H5Oincr_refcount(hid_t object_id) HGOTO_ERROR(H5E_OHDR, H5E_CANTSET, FAIL, "can't set access property list info") /* Change the object's reference count */ - if(H5VL_object_specific(vol_obj->data, loc_params, vol_obj->driver->cls, H5VL_OBJECT_CHANGE_REF_COUNT, - H5P_DATASET_XFER_DEFAULT, H5_REQUEST_NULL, 1) < 0) + if(H5VL_object_specific(vol_obj, &loc_params, H5VL_OBJECT_CHANGE_REF_COUNT, H5P_DATASET_XFER_DEFAULT, H5_REQUEST_NULL, 1) < 0) HGOTO_ERROR(H5E_OHDR, H5E_LINKCOUNT, FAIL, "modifying object link count failed") done: @@ -459,7 +459,7 @@ done: herr_t H5Odecr_refcount(hid_t object_id) { - H5VL_object_t *vol_obj = NULL; /* object token of loc_id */ + H5VL_object_t *vol_obj; /* Object token of loc_id */ H5VL_loc_params_t loc_params; herr_t ret_value = SUCCEED; /* Return value */ @@ -478,8 +478,7 @@ H5Odecr_refcount(hid_t object_id) HGOTO_ERROR(H5E_OHDR, H5E_CANTSET, FAIL, "can't set access property list info") /* Change the object's reference count */ - if(H5VL_object_specific(vol_obj->data, loc_params, vol_obj->driver->cls, H5VL_OBJECT_CHANGE_REF_COUNT, - H5P_DATASET_XFER_DEFAULT, H5_REQUEST_NULL, -1) < 0) + if(H5VL_object_specific(vol_obj, &loc_params, H5VL_OBJECT_CHANGE_REF_COUNT, H5P_DATASET_XFER_DEFAULT, H5_REQUEST_NULL, -1) < 0) HGOTO_ERROR(H5E_OHDR, H5E_LINKCOUNT, FAIL, "modifying object link count failed") done: @@ -503,7 +502,7 @@ done: htri_t H5Oexists_by_name(hid_t loc_id, const char *name, hid_t lapl_id) { - H5VL_object_t *vol_obj = NULL; /* Object token of loc_id */ + H5VL_object_t *vol_obj; /* Object token of loc_id */ H5VL_loc_params_t loc_params; htri_t ret_value = FAIL; /* Return value */ @@ -531,8 +530,7 @@ H5Oexists_by_name(hid_t loc_id, const char *name, hid_t lapl_id) loc_params.obj_type = H5I_get_type(loc_id); /* Check if the object exists */ - if(H5VL_object_specific(vol_obj->data, loc_params, vol_obj->driver->cls, H5VL_OBJECT_EXISTS, - H5P_DATASET_XFER_DEFAULT, H5_REQUEST_NULL, &ret_value) < 0) + if(H5VL_object_specific(vol_obj, &loc_params, H5VL_OBJECT_EXISTS, H5P_DATASET_XFER_DEFAULT, H5_REQUEST_NULL, &ret_value) < 0) HGOTO_ERROR(H5E_OHDR, H5E_CANTGET, FAIL, "unable to determine if '%s' exists", name) done: @@ -557,7 +555,7 @@ done: herr_t H5Oget_info2(hid_t loc_id, H5O_info_t *oinfo, unsigned fields) { - H5VL_object_t *vol_obj = NULL; /* Object token of loc_id */ + H5VL_object_t *vol_obj; /* Object token of loc_id */ H5VL_loc_params_t loc_params; herr_t ret_value = SUCCEED; /* Return value */ @@ -579,8 +577,7 @@ H5Oget_info2(hid_t loc_id, H5O_info_t *oinfo, unsigned fields) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "invalid location identifier") /* Retrieve the object's information */ - if(H5VL_object_optional(vol_obj->data, vol_obj->driver->cls, H5P_DATASET_XFER_DEFAULT, - H5_REQUEST_NULL, H5VL_OBJECT_GET_INFO, loc_params, oinfo, fields) < 0) + if(H5VL_object_optional(vol_obj, H5P_DATASET_XFER_DEFAULT, H5_REQUEST_NULL, H5VL_NATIVE_OBJECT_GET_INFO, &loc_params, oinfo, fields) < 0) HGOTO_ERROR(H5E_OHDR, H5E_CANTGET, FAIL, "can't get info for object") done: @@ -606,7 +603,7 @@ herr_t H5Oget_info_by_name2(hid_t loc_id, const char *name, H5O_info_t *oinfo, unsigned fields, hid_t lapl_id) { - H5VL_object_t *vol_obj = NULL; /* object token of loc_id */ + H5VL_object_t *vol_obj; /* Object token of loc_id */ H5VL_loc_params_t loc_params; herr_t ret_value = SUCCEED; /* Return value */ @@ -638,8 +635,7 @@ H5Oget_info_by_name2(hid_t loc_id, const char *name, H5O_info_t *oinfo, HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "invalid location identifier") /* Retrieve the object's information */ - if(H5VL_object_optional(vol_obj->data, vol_obj->driver->cls, H5P_DATASET_XFER_DEFAULT, H5_REQUEST_NULL, - H5VL_OBJECT_GET_INFO, loc_params, oinfo, fields) < 0) + if(H5VL_object_optional(vol_obj, H5P_DATASET_XFER_DEFAULT, H5_REQUEST_NULL, H5VL_NATIVE_OBJECT_GET_INFO, &loc_params, oinfo, fields) < 0) HGOTO_ERROR(H5E_OHDR, H5E_CANTGET, FAIL, "can't get info for object: '%s'", name) done: @@ -667,7 +663,7 @@ herr_t H5Oget_info_by_idx2(hid_t loc_id, const char *group_name, H5_index_t idx_type, H5_iter_order_t order, hsize_t n, H5O_info_t *oinfo, unsigned fields, hid_t lapl_id) { - H5VL_object_t *vol_obj = NULL; /* object token of loc_id */ + H5VL_object_t *vol_obj; /* Object token of loc_id */ H5VL_loc_params_t loc_params; herr_t ret_value = SUCCEED; /* Return value */ @@ -704,8 +700,7 @@ H5Oget_info_by_idx2(hid_t loc_id, const char *group_name, H5_index_t idx_type, HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "invalid location identifier") /* Retrieve the object's information */ - if(H5VL_object_optional(vol_obj->data, vol_obj->driver->cls, H5P_DATASET_XFER_DEFAULT, H5_REQUEST_NULL, - H5VL_OBJECT_GET_INFO, loc_params, oinfo, fields) < 0) + if(H5VL_object_optional(vol_obj, H5P_DATASET_XFER_DEFAULT, H5_REQUEST_NULL, H5VL_NATIVE_OBJECT_GET_INFO, &loc_params, oinfo, fields) < 0) HGOTO_ERROR(H5E_OHDR, H5E_CANTGET, FAIL, "can't get info for object") done: @@ -733,7 +728,7 @@ done: herr_t H5Oset_comment(hid_t obj_id, const char *comment) { - H5VL_object_t *vol_obj = NULL; /* object token of loc_id */ + H5VL_object_t *vol_obj; /* Object token of loc_id */ H5VL_loc_params_t loc_params; herr_t ret_value = SUCCEED; /* Return value */ @@ -753,8 +748,7 @@ H5Oset_comment(hid_t obj_id, const char *comment) loc_params.obj_type = H5I_get_type(obj_id); /* (Re)set the object's comment */ - if(H5VL_object_optional(vol_obj->data, vol_obj->driver->cls, H5P_DATASET_XFER_DEFAULT, - H5_REQUEST_NULL, H5VL_OBJECT_SET_COMMENT, loc_params, comment) < 0) + if(H5VL_object_optional(vol_obj, H5P_DATASET_XFER_DEFAULT, H5_REQUEST_NULL, H5VL_NATIVE_OBJECT_SET_COMMENT, &loc_params, comment) < 0) HGOTO_ERROR(H5E_OHDR, H5E_CANTSET, FAIL, "can't set comment for object") done: @@ -783,7 +777,7 @@ herr_t H5Oset_comment_by_name(hid_t loc_id, const char *name, const char *comment, hid_t lapl_id) { - H5VL_object_t *vol_obj = NULL; /* object token of loc_id */ + H5VL_object_t *vol_obj; /* Object token of loc_id */ H5VL_loc_params_t loc_params; herr_t ret_value = SUCCEED; /* Return value */ @@ -809,8 +803,7 @@ H5Oset_comment_by_name(hid_t loc_id, const char *name, const char *comment, HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "invalid location identifier") /* (Re)set the object's comment */ - if(H5VL_object_optional(vol_obj->data, vol_obj->driver->cls, H5P_DATASET_XFER_DEFAULT, H5_REQUEST_NULL, - H5VL_OBJECT_SET_COMMENT, loc_params, comment) < 0) + if(H5VL_object_optional(vol_obj, H5P_DATASET_XFER_DEFAULT, H5_REQUEST_NULL, H5VL_NATIVE_OBJECT_SET_COMMENT, &loc_params, comment) < 0) HGOTO_ERROR(H5E_OHDR, H5E_CANTSET, FAIL, "can't set comment for object: '%s'", name) done: @@ -837,7 +830,7 @@ done: ssize_t H5Oget_comment(hid_t obj_id, char *comment, size_t bufsize) { - H5VL_object_t *vol_obj = NULL; /* object token of loc_id */ + H5VL_object_t *vol_obj; /* Object token of loc_id */ H5VL_loc_params_t loc_params; ssize_t ret_value = -1; /* Return value */ @@ -845,7 +838,7 @@ H5Oget_comment(hid_t obj_id, char *comment, size_t bufsize) H5TRACE3("Zs", "i*sz", obj_id, comment, bufsize); /* Get the object */ - if (NULL == (vol_obj = H5VL_vol_object(obj_id))) + if(NULL == (vol_obj = H5VL_vol_object(obj_id))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, (-1), "invalid location identifier") /* Set fields in the location struct */ @@ -853,8 +846,7 @@ H5Oget_comment(hid_t obj_id, char *comment, size_t bufsize) loc_params.obj_type = H5I_get_type(obj_id); /* Retrieve the object's comment */ - if (H5VL_object_optional(vol_obj->data, vol_obj->driver->cls, H5P_DATASET_XFER_DEFAULT, H5_REQUEST_NULL, - H5VL_OBJECT_GET_COMMENT, loc_params, comment, bufsize, &ret_value) < 0) + if(H5VL_object_optional(vol_obj, H5P_DATASET_XFER_DEFAULT, H5_REQUEST_NULL, H5VL_NATIVE_OBJECT_GET_COMMENT, &loc_params, comment, bufsize, &ret_value) < 0) HGOTO_ERROR(H5E_OHDR, H5E_CANTGET, (-1), "can't get comment for object") done: @@ -882,7 +874,7 @@ ssize_t H5Oget_comment_by_name(hid_t loc_id, const char *name, char *comment, size_t bufsize, hid_t lapl_id) { - H5VL_object_t *vol_obj = NULL; /* object token of loc_id */ + H5VL_object_t *vol_obj; /* Object token of loc_id */ H5VL_loc_params_t loc_params; ssize_t ret_value = -1; /* Return value */ @@ -908,8 +900,7 @@ H5Oget_comment_by_name(hid_t loc_id, const char *name, char *comment, size_t buf HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, (-1), "invalid location identifier") /* Retrieve the object's comment */ - if(H5VL_object_optional(vol_obj->data, vol_obj->driver->cls, H5P_DATASET_XFER_DEFAULT, H5_REQUEST_NULL, - H5VL_OBJECT_GET_COMMENT, loc_params, comment, bufsize, &ret_value) < 0) + if(H5VL_object_optional(vol_obj, H5P_DATASET_XFER_DEFAULT, H5_REQUEST_NULL, H5VL_NATIVE_OBJECT_GET_COMMENT, &loc_params, comment, bufsize, &ret_value) < 0) HGOTO_ERROR(H5E_OHDR, H5E_CANTGET, (-1), "can't get comment for object: '%s'", name) done: @@ -956,7 +947,7 @@ herr_t H5Ovisit2(hid_t obj_id, H5_index_t idx_type, H5_iter_order_t order, H5O_iterate_t op, void *op_data, unsigned fields) { - H5VL_object_t *vol_obj = NULL; /* Object token of loc_id */ + H5VL_object_t *vol_obj; /* Object token of loc_id */ H5VL_loc_params_t loc_params; herr_t ret_value; /* Return value */ @@ -982,9 +973,7 @@ H5Ovisit2(hid_t obj_id, H5_index_t idx_type, H5_iter_order_t order, loc_params.obj_type = H5I_get_type(obj_id); /* Visit the objects */ - if((ret_value = H5VL_object_specific(vol_obj->data, loc_params, vol_obj->driver->cls, - H5VL_OBJECT_VISIT, H5P_DATASET_XFER_DEFAULT, H5_REQUEST_NULL, - idx_type, order, op, op_data, fields)) < 0) + if((ret_value = H5VL_object_specific(vol_obj, &loc_params, H5VL_OBJECT_VISIT, H5P_DATASET_XFER_DEFAULT, H5_REQUEST_NULL, (int)idx_type, (int)order, op, op_data, fields)) < 0) HGOTO_ERROR(H5E_OHDR, H5E_BADITER, FAIL, "object iteration failed") done: @@ -1031,7 +1020,7 @@ herr_t H5Ovisit_by_name2(hid_t loc_id, const char *obj_name, H5_index_t idx_type, H5_iter_order_t order, H5O_iterate_t op, void *op_data, unsigned fields, hid_t lapl_id) { - H5VL_object_t *vol_obj = NULL; /* Object token of loc_id */ + H5VL_object_t *vol_obj; /* Object token of loc_id */ H5VL_loc_params_t loc_params; herr_t ret_value; /* Return value */ @@ -1068,9 +1057,7 @@ H5Ovisit_by_name2(hid_t loc_id, const char *obj_name, H5_index_t idx_type, loc_params.obj_type = H5I_get_type(loc_id); /* Visit the objects */ - if((ret_value = H5VL_object_specific(vol_obj->data, loc_params, vol_obj->driver->cls, - H5VL_OBJECT_VISIT, H5P_DATASET_XFER_DEFAULT, H5_REQUEST_NULL, - idx_type, order, op, op_data, fields)) < 0) + if((ret_value = H5VL_object_specific(vol_obj, &loc_params, H5VL_OBJECT_VISIT, H5P_DATASET_XFER_DEFAULT, H5_REQUEST_NULL, (int)idx_type, (int)order, op, op_data, fields)) < 0) HGOTO_ERROR(H5E_OHDR, H5E_BADITER, FAIL, "object iteration failed") done: @@ -1119,7 +1106,6 @@ H5Oclose(hid_t object_id) case H5I_FILE: case H5I_DATASPACE: case H5I_ATTR: - case H5I_REFERENCE: case H5I_VFL: case H5I_VOL: case H5I_GENPROP_CLS: diff --git a/src/H5Oattribute.c b/src/H5Oattribute.c index 1d509e5..6e135c5 100644 --- a/src/H5Oattribute.c +++ b/src/H5Oattribute.c @@ -1304,7 +1304,7 @@ H5O_attr_iterate_real(hid_t loc_id, const H5O_loc_t *loc, H5_index_t idx_type, /* Iterate over attributes in table */ if((ret_value = H5A__attr_iterate_table(&atable, skip, last_attr, loc_id, attr_op, op_data)) < 0) - HERROR(H5E_ATTR, H5E_CANTNEXT, "iteration operator failed"); + HERROR(H5E_ATTR, H5E_BADITER, "iteration operator failed"); } /* end else */ done: diff --git a/src/H5Ocopy.c b/src/H5Ocopy.c index c03c352..a3d4884 100644 --- a/src/H5Ocopy.c +++ b/src/H5Ocopy.c @@ -247,9 +247,7 @@ H5Ocopy(hid_t src_loc_id, const char *src_name, hid_t dst_loc_id, loc_params2.obj_type = H5I_get_type(dst_loc_id); /* Copy the object */ - if((ret_value = H5VL_object_copy(vol_obj1->data, loc_params1, vol_obj1->driver->cls, src_name, - vol_obj2->data, loc_params2, vol_obj2->driver->cls, dst_name, - ocpypl_id, lcpl_id, H5P_DATASET_XFER_DEFAULT, H5_REQUEST_NULL)) < 0) + if(H5VL_object_copy(vol_obj1, &loc_params1, src_name, vol_obj2, &loc_params2, dst_name, ocpypl_id, lcpl_id, H5P_DATASET_XFER_DEFAULT, H5_REQUEST_NULL) < 0) HGOTO_ERROR(H5E_OHDR, H5E_CANTCOPY, FAIL, "unable to copy object") done: diff --git a/src/H5Odeprec.c b/src/H5Odeprec.c index 68eb170..7aefc67 100644 --- a/src/H5Odeprec.c +++ b/src/H5Odeprec.c @@ -37,6 +37,8 @@ #include "H5Iprivate.h" /* IDs */ #include "H5Opkg.h" /* Object headers */ +#include "H5VLnative_private.h" /* Native VOL connector */ + /****************/ /* Local Macros */ @@ -109,8 +111,7 @@ H5Oget_info1(hid_t loc_id, H5O_info_t *oinfo) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "invalid location identifier") /* Retrieve the object's information */ - if(H5VL_object_optional(vol_obj->data, vol_obj->driver->cls, H5P_DATASET_XFER_DEFAULT, - H5_REQUEST_NULL, H5VL_OBJECT_GET_INFO, loc_params, oinfo, H5O_INFO_ALL) < 0) + if(H5VL_object_optional(vol_obj, H5P_DATASET_XFER_DEFAULT, H5_REQUEST_NULL, H5VL_NATIVE_OBJECT_GET_INFO, &loc_params, oinfo, H5O_INFO_ALL) < 0) HGOTO_ERROR(H5E_OHDR, H5E_CANTGET, FAIL, "can't get info for object") done: @@ -161,8 +162,7 @@ H5Oget_info_by_name1(hid_t loc_id, const char *name, H5O_info_t *oinfo, hid_t la HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "invalid location identifier") /* Retrieve the object's information */ - if(H5VL_object_optional(vol_obj->data, vol_obj->driver->cls, H5P_DATASET_XFER_DEFAULT, H5_REQUEST_NULL, - H5VL_OBJECT_GET_INFO, loc_params, oinfo, H5O_INFO_ALL) < 0) + if(H5VL_object_optional(vol_obj, H5P_DATASET_XFER_DEFAULT, H5_REQUEST_NULL, H5VL_NATIVE_OBJECT_GET_INFO, &loc_params, oinfo, H5O_INFO_ALL) < 0) HGOTO_ERROR(H5E_OHDR, H5E_CANTGET, FAIL, "can't get info for object: '%s'", name) done: @@ -223,8 +223,7 @@ H5Oget_info_by_idx1(hid_t loc_id, const char *group_name, H5_index_t idx_type, HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "invalid location identifier") /* Retrieve the object's information */ - if(H5VL_object_optional(vol_obj->data, vol_obj->driver->cls, H5P_DATASET_XFER_DEFAULT, H5_REQUEST_NULL, - H5VL_OBJECT_GET_INFO, loc_params, oinfo, H5O_INFO_ALL) < 0) + if(H5VL_object_optional(vol_obj, H5P_DATASET_XFER_DEFAULT, H5_REQUEST_NULL, H5VL_NATIVE_OBJECT_GET_INFO, &loc_params, oinfo, H5O_INFO_ALL) < 0) HGOTO_ERROR(H5E_OHDR, H5E_CANTGET, FAIL, "can't get info for object") done: @@ -292,9 +291,7 @@ H5Ovisit1(hid_t obj_id, H5_index_t idx_type, H5_iter_order_t order, loc_params.obj_type = H5I_get_type(obj_id); /* Visit the objects */ - if((ret_value = H5VL_object_specific(vol_obj->data, loc_params, vol_obj->driver->cls, - H5VL_OBJECT_VISIT, H5P_DATASET_XFER_DEFAULT, H5_REQUEST_NULL, - idx_type, order, op, op_data, H5O_INFO_ALL)) < 0) + if((ret_value = H5VL_object_specific(vol_obj, &loc_params, H5VL_OBJECT_VISIT, H5P_DATASET_XFER_DEFAULT, H5_REQUEST_NULL, (int)idx_type, (int)order, op, op_data, H5O_INFO_ALL)) < 0) HGOTO_ERROR(H5E_OHDR, H5E_BADITER, FAIL, "object visitation failed") done: @@ -373,9 +370,7 @@ H5Ovisit_by_name1(hid_t loc_id, const char *obj_name, H5_index_t idx_type, loc_params.obj_type = H5I_get_type(loc_id); /* Visit the objects */ - if((ret_value = H5VL_object_specific(vol_obj->data, loc_params, vol_obj->driver->cls, - H5VL_OBJECT_VISIT, H5P_DATASET_XFER_DEFAULT, H5_REQUEST_NULL, - idx_type, order, op, op_data, H5O_INFO_ALL)) < 0) + if((ret_value = H5VL_object_specific(vol_obj, &loc_params, H5VL_OBJECT_VISIT, H5P_DATASET_XFER_DEFAULT, H5_REQUEST_NULL, (int)idx_type, (int)order, op, op_data, H5O_INFO_ALL)) < 0) HGOTO_ERROR(H5E_OHDR, H5E_BADITER, FAIL, "object visitation failed") done: diff --git a/src/H5Ofill.c b/src/H5Ofill.c index adf36b9..125da36 100644 --- a/src/H5Ofill.c +++ b/src/H5Ofill.c @@ -347,9 +347,9 @@ H5O_fill_old_decode(H5F_t *f, H5O_t *open_oh, if(NULL == (dt = (H5T_t *)H5O_msg_read_oh(f, open_oh, H5O_DTYPE_ID, NULL))) HGOTO_ERROR(H5E_SYM, H5E_CANTGET, NULL, "can't read DTYPE message") /* Verify size */ - if(fill->size != H5T_GET_SIZE(dt)) + if(fill->size != (ssize_t)H5T_GET_SIZE(dt)) HGOTO_ERROR(H5E_SYM, H5E_CANTGET, NULL, "inconsistent fill value size") - } + } /* end if */ if(NULL == (fill->buf = H5MM_malloc((size_t)fill->size))) HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, NULL, "memory allocation failed for fill value") diff --git a/src/H5Oflush.c b/src/H5Oflush.c index 40b6c6e..da9d1d0 100644 --- a/src/H5Oflush.c +++ b/src/H5Oflush.c @@ -92,8 +92,7 @@ H5Oflush(hid_t obj_id) loc_params.obj_type = H5I_get_type(obj_id); /* Flush the object */ - if((ret_value = H5VL_object_specific(vol_obj->data, loc_params, vol_obj->driver->cls, - H5VL_OBJECT_FLUSH, H5P_DATASET_XFER_DEFAULT, H5_REQUEST_NULL, obj_id)) < 0) + if(H5VL_object_specific(vol_obj, &loc_params, H5VL_OBJECT_FLUSH, H5P_DATASET_XFER_DEFAULT, H5_REQUEST_NULL, obj_id) < 0) HGOTO_ERROR(H5E_OHDR, H5E_CANTFLUSH, FAIL, "unable to flush object") done: @@ -257,8 +256,7 @@ H5Orefresh(hid_t oid) loc_params.obj_type = H5I_get_type(oid); /* Refresh the object */ - if((ret_value = H5VL_object_specific(vol_obj->data, loc_params, vol_obj->driver->cls, - H5VL_OBJECT_REFRESH, H5P_DATASET_XFER_DEFAULT, H5_REQUEST_NULL, oid)) < 0) + if(H5VL_object_specific(vol_obj, &loc_params, H5VL_OBJECT_REFRESH, H5P_DATASET_XFER_DEFAULT, H5_REQUEST_NULL, oid) < 0) HGOTO_ERROR(H5E_OHDR, H5E_CANTLOAD, FAIL, "unable to refresh object") done: @@ -301,7 +299,7 @@ H5O_refresh_metadata(hid_t oid, H5O_loc_t oloc) H5O_loc_t obj_oloc; H5G_name_t obj_path; H5O_shared_t cached_H5O_shared; - H5VL_t *driver = NULL; + H5VL_t *connector = NULL; /* Create empty object location */ obj_loc.oloc = &obj_oloc; @@ -319,29 +317,29 @@ H5O_refresh_metadata(hid_t oid, H5O_loc_t oloc) if(H5T_save_refresh_state(oid, &cached_H5O_shared) < 0) HGOTO_ERROR(H5E_DATATYPE, H5E_CANTOPENOBJ, FAIL, "unable to save datatype state") - /* Get the VOL object from the ID and cache a pointer to the driver. + /* Get the VOL object from the ID and cache a pointer to the connector. * The vol_obj will disappear when the underlying object is closed, so * we can't use that directly. */ if(NULL == (vol_obj = H5VL_vol_object(oid))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "invalid object identifier") - driver = vol_obj->driver; + connector = vol_obj->connector; - /* Bump the number of references on the VOL driver. - * If you don't do this, VDS refreshes can accidentally close the driver. + /* Bump the number of references on the VOL connector. + * If you don't do this, VDS refreshes can accidentally close the connector. */ - driver->nrefs++; + connector->nrefs++; /* Close object & evict its metadata */ if((H5O__refresh_metadata_close(oid, oloc, &obj_loc)) < 0) HGOTO_ERROR(H5E_OHDR, H5E_CANTLOAD, FAIL, "unable to refresh object") /* Re-open the object, re-fetching its metadata */ - if((H5O_refresh_metadata_reopen(oid, &obj_loc, driver, FALSE)) < 0) + if((H5O_refresh_metadata_reopen(oid, &obj_loc, connector, FALSE)) < 0) HGOTO_ERROR(H5E_OHDR, H5E_CANTLOAD, FAIL, "unable to refresh object") - /* Restore the number of references on the VOL driver */ - driver->nrefs--; + /* Restore the number of references on the VOL connector */ + connector->nrefs--; /* Restore important datatype state */ if(H5I_get_type(oid) == H5I_DATATYPE) @@ -444,7 +442,7 @@ done: *------------------------------------------------------------------------- */ herr_t -H5O_refresh_metadata_reopen(hid_t oid, H5G_loc_t *obj_loc, H5VL_t *vol_driver, hbool_t start_swmr) +H5O_refresh_metadata_reopen(hid_t oid, H5G_loc_t *obj_loc, H5VL_t *vol_connector, hbool_t start_swmr) { void *object = NULL; /* Object for this operation */ H5I_type_t type; /* Type of object for the ID */ @@ -454,7 +452,7 @@ H5O_refresh_metadata_reopen(hid_t oid, H5G_loc_t *obj_loc, H5VL_t *vol_driver, h /* Sanity check */ HDassert(obj_loc); - HDassert(vol_driver); + HDassert(vol_connector); /* Get object's type */ type = H5I_get_type(oid); @@ -463,13 +461,13 @@ H5O_refresh_metadata_reopen(hid_t oid, H5G_loc_t *obj_loc, H5VL_t *vol_driver, h case H5I_GROUP: /* Re-open the group */ if(NULL == (object = H5G_open(obj_loc))) - HGOTO_ERROR(H5E_SYM, H5E_CANTOPENOBJ, FAIL, "unable to open group") + HGOTO_ERROR(H5E_OHDR, H5E_CANTOPENOBJ, FAIL, "unable to open group") break; case H5I_DATATYPE: /* Re-open the named datatype */ if(NULL == (object = H5T_open(obj_loc))) - HGOTO_ERROR(H5E_DATATYPE, H5E_CANTOPENOBJ, FAIL, "unable to open named datatype") + HGOTO_ERROR(H5E_OHDR, H5E_CANTOPENOBJ, FAIL, "unable to open named datatype") break; case H5I_DATASET: @@ -478,7 +476,7 @@ H5O_refresh_metadata_reopen(hid_t oid, H5G_loc_t *obj_loc, H5VL_t *vol_driver, h HGOTO_ERROR(H5E_DATASET, H5E_CANTOPENOBJ, FAIL, "unable to open dataset") if(!start_swmr) /* No need to handle multiple opens when H5Fstart_swmr_write() */ if(H5D_mult_refresh_reopen((H5D_t *)object) < 0) - HGOTO_ERROR(H5E_DATASET, H5E_CANTOPENOBJ, FAIL, "unable to finish refresh for dataset") + HGOTO_ERROR(H5E_OHDR, H5E_CANTOPENOBJ, FAIL, "unable to finish refresh for dataset") break; case H5I_UNINIT: @@ -486,7 +484,6 @@ H5O_refresh_metadata_reopen(hid_t oid, H5G_loc_t *obj_loc, H5VL_t *vol_driver, h case H5I_FILE: case H5I_DATASPACE: case H5I_ATTR: - case H5I_REFERENCE: case H5I_VFL: case H5I_VOL: case H5I_GENPROP_CLS: @@ -496,13 +493,13 @@ H5O_refresh_metadata_reopen(hid_t oid, H5G_loc_t *obj_loc, H5VL_t *vol_driver, h case H5I_ERROR_STACK: case H5I_NTYPES: default: - HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a valid file object ID (dataset, group, or datatype)") + HGOTO_ERROR(H5E_OHDR, H5E_BADTYPE, FAIL, "not a valid file object ID (dataset, group, or datatype)") break; } /* end switch */ /* Re-register ID for the object */ - if((H5VL_register_using_existing_id(type, object, vol_driver, TRUE, oid)) < 0) - HGOTO_ERROR(H5E_ATOM, H5E_CANTREGISTER, FAIL, "unable to re-register object ID after refresh") + if((H5VL_register_using_existing_id(type, object, vol_connector, TRUE, oid)) < 0) + HGOTO_ERROR(H5E_OHDR, H5E_CANTREGISTER, FAIL, "unable to re-register object ID after refresh") done: FUNC_LEAVE_NOAPI(ret_value); diff --git a/src/H5Oint.c b/src/H5Oint.c index 30fe127..a97a2fd 100644 --- a/src/H5Oint.c +++ b/src/H5Oint.c @@ -43,7 +43,6 @@ #endif /* H5O_ENABLE_BOGUS */ #include "H5Opkg.h" /* Object headers */ #include "H5VLprivate.h" /* Virtual Object Layer */ -#include "H5VLnative_private.h" /* Native VOL driver */ /****************/ @@ -1766,7 +1765,6 @@ H5O_get_loc(hid_t object_id) case H5I_FILE: case H5I_DATASPACE: case H5I_ATTR: - case H5I_REFERENCE: case H5I_VFL: case H5I_VOL: case H5I_GENPROP_CLS: @@ -2114,7 +2112,7 @@ H5O_get_info(const H5O_loc_t *loc, H5O_info_t *oinfo, unsigned fields) /* Set the object's reference count */ oinfo->rc = oh->nlink; - } + } /* end if */ /* Get time information, if requested */ if(fields & H5O_INFO_TIME) { @@ -2658,7 +2656,7 @@ H5O__visit(H5G_loc_t *loc, const char *obj_name, H5_index_t idx_type, HGOTO_ERROR(H5E_OHDR, H5E_CANTOPENOBJ, FAIL, "unable to open object") /* Get an ID for the visited object */ - if((obj_id = H5VL_native_register(opened_type, obj, TRUE)) < 0) + if((obj_id = H5VL_wrap_register(opened_type, obj, TRUE)) < 0) HGOTO_ERROR(H5E_ATOM, H5E_CANTREGISTER, FAIL, "unable to register visited object") /* Make callback for starting object */ diff --git a/src/H5Olink.c b/src/H5Olink.c index 6447936..55e1aee 100644 --- a/src/H5Olink.c +++ b/src/H5Olink.c @@ -612,6 +612,7 @@ herr_t H5O_link_delete(H5F_t *f, H5O_t H5_ATTR_UNUSED *open_oh, void *_mesg) { H5O_link_t *lnk = (H5O_link_t *)_mesg; + hid_t file_id = -1; /* ID for the file the link is located in (passed to user callback) */ herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_NOAPI(FAIL) @@ -645,25 +646,21 @@ H5O_link_delete(H5F_t *f, H5O_t H5_ATTR_UNUSED *open_oh, void *_mesg) /* Check for delete callback */ if(link_class->del_func) { - hid_t file_id; /* ID for the file the link is located in (passed to user callback) */ - /* Get a file ID for the file the link is in */ - if((file_id = H5F_get_id(f, FALSE)) < 0) + if((file_id = H5F_get_id(f)) < 0) HGOTO_ERROR(H5E_OHDR, H5E_CANTGET, FAIL, "unable to get file ID") /* Call user-defined link's 'delete' callback */ - if((link_class->del_func)(lnk->name, file_id, lnk->u.ud.udata, lnk->u.ud.size) < 0) { - H5I_dec_ref(file_id); + if((link_class->del_func)(lnk->name, file_id, lnk->u.ud.udata, lnk->u.ud.size) < 0) HGOTO_ERROR(H5E_OHDR, H5E_CALLBACK, FAIL, "link deletion callback returned failure") - } /* end if */ - - /* Release the file ID */ - if(H5I_dec_ref(file_id) < 0) - HGOTO_ERROR(H5E_OHDR, H5E_CANTCLOSEFILE, FAIL, "can't close file") } /* end if */ } /* end if */ done: + /* Release the file ID */ + if(file_id > 0 && H5I_dec_ref(file_id) < 0) + HDONE_ERROR(H5E_OHDR, H5E_CANTCLOSEFILE, FAIL, "can't close file") + FUNC_LEAVE_NOAPI(ret_value) } /* end H5O_link_delete() */ diff --git a/src/H5Opkg.h b/src/H5Opkg.h index 7254edb..dbc8089 100644 --- a/src/H5Opkg.h +++ b/src/H5Opkg.h @@ -414,13 +414,6 @@ typedef struct H5O_chk_cache_ud_t { H5O_common_cache_ud_t common; /* Common object header cache callback info */ } H5O_chk_cache_ud_t; -/* types for object optional VOL operations */ -typedef enum H5VL_object_optional_t { - H5VL_OBJECT_GET_COMMENT, /* get object comment */ - H5VL_OBJECT_GET_INFO, /* get object info */ - H5VL_OBJECT_SET_COMMENT /* set object comment */ -} H5VL_object_optional_t; - /* Header message ID to class mapping */ H5_DLLVAR const H5O_msg_class_t *const H5O_msg_class_g[H5O_MSG_TYPES]; diff --git a/src/H5Oprivate.h b/src/H5Oprivate.h index 048e13e..7ed9e26 100644 --- a/src/H5Oprivate.h +++ b/src/H5Oprivate.h @@ -851,7 +851,6 @@ typedef struct { } u; } H5O_mesg_operator_t; - /* Typedef for abstract object creation */ typedef struct { H5O_type_t obj_type; /* Type of object to create */ diff --git a/src/H5Opublic.h b/src/H5Opublic.h index da2910d..c868e72 100644 --- a/src/H5Opublic.h +++ b/src/H5Opublic.h @@ -150,18 +150,19 @@ typedef enum H5O_mcdt_search_ret_t { /* Callback to invoke when completing the search for a matching committed datatype from the committed dtype list */ typedef H5O_mcdt_search_ret_t (*H5O_mcdt_search_cb_t)(void *op_data); + /********************/ /* Public Variables */ /********************/ +/*********************/ +/* Public Prototypes */ +/*********************/ #ifdef __cplusplus extern "C" { #endif -/*********************/ -/* Public Prototypes */ -/*********************/ H5_DLL hid_t H5Oopen(hid_t loc_id, const char *name, hid_t lapl_id); H5_DLL hid_t H5Oopen_by_addr(hid_t loc_id, haddr_t addr); H5_DLL hid_t H5Oopen_by_idx(hid_t loc_id, const char *group_name, diff --git a/src/H5PLint.c b/src/H5PLint.c index 166b300..ded315a 100644 --- a/src/H5PLint.c +++ b/src/H5PLint.c @@ -30,7 +30,6 @@ #include "H5Eprivate.h" /* Error handling */ #include "H5MMprivate.h" /* Memory management */ #include "H5PLpkg.h" /* Plugin */ -#include "H5VLprivate.h" /* Virtual Object Layer */ #include "H5Zprivate.h" /* Filter pipeline */ @@ -236,7 +235,7 @@ done: *------------------------------------------------------------------------- */ const void * -H5PL_load(H5PL_type_t type, H5PL_key_t key) +H5PL_load(H5PL_type_t type, const H5PL_key_t *key) { H5PL_search_params_t search_params; /* Plugin search parameters */ hbool_t found = FALSE; /* Whether the plugin was found */ @@ -263,7 +262,7 @@ H5PL_load(H5PL_type_t type, H5PL_key_t key) /* Set up the search parameters */ search_params.type = type; - search_params.key.id = key.id; + search_params.key = key; /* Search in the table of already loaded plugin libraries */ if(H5PL__find_plugin_in_cache(&search_params, &found, &plugin_info) < 0) @@ -308,7 +307,8 @@ done: #pragma GCC diagnostic push #pragma GCC diagnostic ignored "-Wpedantic" herr_t -H5PL__open(const char *path, H5PL_type_t type, H5PL_key_t key, hbool_t *success, const void **plugin_info) +H5PL__open(const char *path, H5PL_type_t type, const H5PL_key_t *key, + hbool_t *success, const void **plugin_info) { H5PL_HANDLE handle = NULL; H5PL_get_plugin_info_t get_plugin_info = NULL; @@ -350,29 +350,44 @@ H5PL__open(const char *path, H5PL_type_t type, H5PL_key_t key, hbool_t *success, HGOTO_ERROR(H5E_PLUGIN, H5E_CANTGET, FAIL, "can't get filter info from plugin") /* If the filter IDs match, we're done. Set the output parameters. */ - if (filter_info->id == key.id) { + if (filter_info->id == key->id) { *plugin_info = (const void *)filter_info; *success = TRUE; } break; } + case H5PL_TYPE_VOL: { - const H5VL_class_t *cls = NULL; + const H5VL_class_t *cls; /* Get the plugin info */ - if (NULL == (cls = (const H5VL_class_t *)(*get_plugin_info)())) + if(NULL == (cls = (const H5VL_class_t *)(*get_plugin_info)())) HGOTO_ERROR(H5E_PLUGIN, H5E_CANTGET, FAIL, "can't get VOL driver info from plugin") - /* If the plugin names match, we're done. Set the output parameters. */ - if (cls->name && !HDstrcmp(cls->name, key.name)) { - *plugin_info = (const void *)cls; - *success = TRUE; - } + /* Which kind of key are we looking for? */ + if(key->vol.kind == H5VL_GET_CONNECTOR_BY_NAME) { + /* If the plugin names match, we're done. Set the output parameters. */ + if(cls->name && !HDstrcmp(cls->name, key->vol.u.name)) { + *plugin_info = (const void *)cls; + *success = TRUE; + } /* end if */ + } /* end if */ + else { + /* Sanity check */ + HDassert(key->vol.kind == H5VL_GET_CONNECTOR_BY_VALUE); + + /* If the plugin values match, we're done. Set the output parameters. */ + if(cls->value == key->vol.u.value) { + *plugin_info = (const void *)cls; + *success = TRUE; + } /* end if */ + } /* end else */ break; } + case H5PL_TYPE_ERROR: case H5PL_TYPE_NONE: default: diff --git a/src/H5PLpath.c b/src/H5PLpath.c index 972f1d0..04248b5 100644 --- a/src/H5PLpath.c +++ b/src/H5PLpath.c @@ -242,6 +242,7 @@ H5PL__create_path_table(void) * environment variable or the default. */ char *next_path = NULL; /* A path tokenized from the paths string */ + char *lasts = NULL; /* Context pointer for strtok_r() call */ herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_PACKAGE @@ -265,8 +266,7 @@ H5PL__create_path_table(void) HGOTO_ERROR(H5E_PLUGIN, H5E_CANTALLOC, FAIL, "can't allocate memory for path copy") /* Separate the paths and store them */ - /* XXX: strtok() is not thread-safe */ - next_path = HDstrtok(paths, H5PL_PATH_SEPARATOR); + next_path = HDstrtok_r(paths, H5PL_PATH_SEPARATOR, &lasts); while (next_path) { /* Insert the path into the table */ @@ -274,7 +274,7 @@ H5PL__create_path_table(void) HGOTO_ERROR(H5E_PLUGIN, H5E_CANTALLOC, FAIL, "can't insert path: %s", next_path) /* Get the next path from the environment string */ - next_path = HDstrtok(NULL, H5PL_PATH_SEPARATOR); + next_path = HDstrtok_r(NULL, H5PL_PATH_SEPARATOR, &lasts); } /* end while */ done: diff --git a/src/H5PLpkg.h b/src/H5PLpkg.h index dfaa4af..c3ad8f5 100644 --- a/src/H5PLpkg.h +++ b/src/H5PLpkg.h @@ -116,7 +116,7 @@ /* Data used to search for plugins */ typedef struct H5PL_search_params_t { H5PL_type_t type; - H5PL_key_t key; + const H5PL_key_t *key; } H5PL_search_params_t; @@ -134,13 +134,15 @@ H5_DLL herr_t H5PL__get_plugin_control_mask(unsigned int *mask /*out*/); H5_DLL herr_t H5PL__set_plugin_control_mask(unsigned int mask); /* Plugin search and manipulation */ -H5_DLL herr_t H5PL__open(const char *libname, H5PL_type_t type, H5PL_key_t key, hbool_t *success /*out*/, const void **plugin_info /*out*/); +H5_DLL herr_t H5PL__open(const char *libname, H5PL_type_t type, const H5PL_key_t *key, + hbool_t *success /*out*/, const void **plugin_info /*out*/); H5_DLL herr_t H5PL__close(H5PL_HANDLE handle); /* Plugin cache calls */ H5_DLL herr_t H5PL__create_plugin_cache(void); H5_DLL herr_t H5PL__close_plugin_cache(hbool_t *already_closed /*out*/); -H5_DLL herr_t H5PL__add_plugin(H5PL_type_t type, H5PL_key_t key, H5PL_HANDLE handle); +H5_DLL herr_t H5PL__add_plugin(H5PL_type_t type, const H5PL_key_t *key, + H5PL_HANDLE handle); H5_DLL herr_t H5PL__find_plugin_in_cache(const H5PL_search_params_t *search_params, hbool_t *found /*out*/, const void **plugin_info /*out*/); /* Plugin search path calls */ diff --git a/src/H5PLplugin_cache.c b/src/H5PLplugin_cache.c index e905ac2..cd0b4d6 100644 --- a/src/H5PLplugin_cache.c +++ b/src/H5PLplugin_cache.c @@ -216,7 +216,7 @@ done: *------------------------------------------------------------------------- */ herr_t -H5PL__add_plugin(H5PL_type_t type, H5PL_key_t key, H5PL_HANDLE handle) +H5PL__add_plugin(H5PL_type_t type, const H5PL_key_t *key, H5PL_HANDLE handle) { herr_t ret_value = SUCCEED; @@ -229,7 +229,7 @@ H5PL__add_plugin(H5PL_type_t type, H5PL_key_t key, H5PL_HANDLE handle) /* Store the plugin info and bump the # of plugins */ H5PL_cache_g[H5PL_num_plugins_g].type = type; - H5PL_cache_g[H5PL_num_plugins_g].key = key; + H5PL_cache_g[H5PL_num_plugins_g].key = *key; H5PL_cache_g[H5PL_num_plugins_g].handle = handle; H5PL_num_plugins_g++; @@ -276,7 +276,7 @@ H5PL__find_plugin_in_cache(const H5PL_search_params_t *search_params, hbool_t *f for (u = 0; u < H5PL_num_plugins_g; u++) { /* If the plugin type (filter, etc.) and ID match, query the plugin for its info */ - if ((search_params->type == (H5PL_cache_g[u]).type) && (search_params->key.id == (H5PL_cache_g[u]).key.id)) { + if ((search_params->type == (H5PL_cache_g[u]).type) && (search_params->key->id == (H5PL_cache_g[u]).key.id)) { H5PL_get_plugin_info_t get_plugin_info_function; const H5Z_class2_t *filter_info; diff --git a/src/H5PLprivate.h b/src/H5PLprivate.h index 2af1b70..5ce9b87 100644 --- a/src/H5PLprivate.h +++ b/src/H5PLprivate.h @@ -21,7 +21,8 @@ #include "H5PLpublic.h" /* Private headers needed by this file */ -#include "H5private.h" /* Generic Functions */ +#include "H5private.h" /* Generic Functions */ +#include "H5VLprivate.h" /* Virtual Object Layer */ /**************************/ @@ -35,8 +36,14 @@ /* The key that will be used to find the plugin */ typedef union H5PL_key_t { - int id; /* filters */ - const char *name; /* VOL drivers */ + int id; /* I/O filters */ + struct { + H5VL_get_connector_kind_t kind; /* Kind of VOL lookup to do */ + union { + H5VL_class_value_t value; /* VOL connector value */ + const char *name; /* VOL connector name */ + } u; + } vol; } H5PL_key_t; @@ -50,7 +57,7 @@ typedef union H5PL_key_t { /***************************************/ /* Internal API routines */ -H5_DLL const void *H5PL_load(H5PL_type_t plugin_type, H5PL_key_t key); +H5_DLL const void *H5PL_load(H5PL_type_t plugin_type, const H5PL_key_t *key); #endif /* _H5PLprivate_H */ diff --git a/src/H5Pfapl.c b/src/H5Pfapl.c index 23eb924..452ea3f 100644 --- a/src/H5Pfapl.c +++ b/src/H5Pfapl.c @@ -39,17 +39,17 @@ #include "H5Iprivate.h" /* IDs */ #include "H5MMprivate.h" /* Memory Management */ #include "H5Ppkg.h" /* Property lists */ -#include "H5VLprivate.h" /* VOL drivers */ +#include "H5VLprivate.h" /* Virtual Object Layer */ -/* Includes needed to set as default file driver */ -#include "H5FDsec2.h" /* Posix unbuffered I/O file driver */ +/* Includes needed to set default file driver */ +#include "H5FDsec2.h" /* POSIX unbuffered I/O */ #include "H5FDstdio.h" /* Standard C buffered I/O */ #ifdef H5_HAVE_WINDOWS #include "H5FDwindows.h" /* Win32 I/O */ #endif -/* Includes needed to set the default VOL driver */ -#include "H5VLnative_private.h" /* Native VOL driver */ +/* Includes needed to set default VOL connector */ +#include "H5VLnative_private.h" /* Native VOL connector */ /****************/ @@ -177,16 +177,6 @@ #define H5F_ACS_FILE_IMAGE_INFO_COPY H5P__facc_file_image_info_copy #define H5F_ACS_FILE_IMAGE_INFO_CMP H5P__facc_file_image_info_cmp #define H5F_ACS_FILE_IMAGE_INFO_CLOSE H5P__facc_file_image_info_close -/* Definition of core VFD write tracking flag */ -#define H5F_ACS_CORE_WRITE_TRACKING_FLAG_SIZE sizeof(hbool_t) -#define H5F_ACS_CORE_WRITE_TRACKING_FLAG_DEF FALSE -#define H5F_ACS_CORE_WRITE_TRACKING_FLAG_ENC H5P__encode_hbool_t -#define H5F_ACS_CORE_WRITE_TRACKING_FLAG_DEC H5P__decode_hbool_t -/* Definition of core VFD write tracking page size */ -#define H5F_ACS_CORE_WRITE_TRACKING_PAGE_SIZE_SIZE sizeof(size_t) -#define H5F_ACS_CORE_WRITE_TRACKING_PAGE_SIZE_DEF 524288 -#define H5F_ACS_CORE_WRITE_TRACKING_PAGE_SIZE_ENC H5P__encode_size_t -#define H5F_ACS_CORE_WRITE_TRACKING_PAGE_SIZE_DEC H5P__decode_size_t /* Definition for # of metadata read attempts */ #define H5F_ACS_METADATA_READ_ATTEMPTS_SIZE sizeof(unsigned) #define H5F_ACS_METADATA_READ_ATTEMPTS_DEF 0 @@ -263,16 +253,16 @@ #define H5F_ACS_PAGE_BUFFER_MIN_RAW_PERC_DEF 0 #define H5F_ACS_PAGE_BUFFER_MIN_RAW_PERC_ENC H5P__encode_unsigned #define H5F_ACS_PAGE_BUFFER_MIN_RAW_PERC_DEC H5P__decode_unsigned -/* Definition for file VOL driver properties (ID, etc.) */ -#define H5F_ACS_VOL_SIZE sizeof(H5VL_driver_prop_t) -#define H5F_ACS_VOL_DEF {H5_DEFAULT_VOL, NULL} -#define H5F_ACS_VOL_CRT H5P__facc_vol_create -#define H5F_ACS_VOL_SET H5P__facc_vol_set -#define H5F_ACS_VOL_GET H5P__facc_vol_get -#define H5F_ACS_VOL_DEL H5P__facc_vol_del -#define H5F_ACS_VOL_COPY H5P__facc_vol_copy -#define H5F_ACS_VOL_CMP H5P__facc_vol_cmp -#define H5F_ACS_VOL_CLOSE H5P__facc_vol_close +/* Definition for file VOL connector properties (ID, etc.) */ +#define H5F_ACS_VOL_CONN_SIZE sizeof(H5VL_connector_prop_t) +#define H5F_ACS_VOL_CONN_DEF {H5_DEFAULT_VOL, NULL} +#define H5F_ACS_VOL_CONN_CRT H5P__facc_vol_create +#define H5F_ACS_VOL_CONN_SET H5P__facc_vol_set +#define H5F_ACS_VOL_CONN_GET H5P__facc_vol_get +#define H5F_ACS_VOL_CONN_DEL H5P__facc_vol_del +#define H5F_ACS_VOL_CONN_COPY H5P__facc_vol_copy +#define H5F_ACS_VOL_CONN_CMP H5P__facc_vol_cmp +#define H5F_ACS_VOL_CONN_CLOSE H5P__facc_vol_close /******************/ @@ -335,7 +325,7 @@ static int H5P__facc_cache_image_config_cmp(const void *_config1, const void *_c static herr_t H5P__facc_cache_image_config_enc(const void *value, void **_pp, size_t *size); static herr_t H5P__facc_cache_image_config_dec(const void **_pp, void *_value); -/* VOL driver callbacks */ +/* VOL connector callbacks */ static herr_t H5P__facc_vol_create(const char *name, size_t size, void *value); static herr_t H5P__facc_vol_set(hid_t prop_id, const char *name, size_t size, void *value); static herr_t H5P__facc_vol_get(hid_t prop_id, const char *name, size_t size, void *value); @@ -401,8 +391,6 @@ static const H5F_libver_t H5F_def_libver_high_bound_g = H5F_ACS_LIBVER_HIGH_BOUN static const hbool_t H5F_def_want_posix_fd_g = H5F_ACS_WANT_POSIX_FD_DEF; /* Default setting for retrieving 'handle' from core VFD */ static const unsigned H5F_def_efc_size_g = H5F_ACS_EFC_SIZE_DEF; /* Default external file cache size */ static const H5FD_file_image_info_t H5F_def_file_image_info_g = H5F_ACS_FILE_IMAGE_INFO_DEF; /* Default file image info and callbacks */ -static const hbool_t H5F_def_core_write_tracking_flag_g = H5F_ACS_CORE_WRITE_TRACKING_FLAG_DEF; /* Default setting for core VFD write tracking */ -static const size_t H5F_def_core_write_tracking_page_size_g = H5F_ACS_CORE_WRITE_TRACKING_PAGE_SIZE_DEF; /* Default core VFD write tracking page size */ static const unsigned H5F_def_metadata_read_attempts_g = H5F_ACS_METADATA_READ_ATTEMPTS_DEF; /* Default setting for the # of metadata read attempts */ static const H5F_object_flush_t H5F_def_object_flush_cb_g = H5F_ACS_OBJECT_FLUSH_CB_DEF; /* Default setting for object flush callback */ static const hbool_t H5F_def_clear_status_flags_g = H5F_ACS_CLEAR_STATUS_FLAGS_DEF; /* Default to clear the superblock status_flags */ @@ -438,7 +426,7 @@ static herr_t H5P__facc_reg_prop(H5P_genclass_t *pclass) { const H5FD_driver_prop_t def_driver_prop = H5F_ACS_FILE_DRV_DEF; /* Default VFL driver ID & info (initialized from a variable) */ - const H5VL_driver_prop_t def_vol_prop = H5F_ACS_VOL_DEF; /* Default VOL driver ID & info (initialized from a variable) */ + const H5VL_connector_prop_t def_vol_prop = H5F_ACS_VOL_CONN_DEF; /* Default VOL connector ID & info (initialized from a variable) */ herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_STATIC @@ -572,18 +560,6 @@ H5P__facc_reg_prop(H5P_genclass_t *pclass) H5F_ACS_FILE_IMAGE_INFO_DEL, H5F_ACS_FILE_IMAGE_INFO_COPY, H5F_ACS_FILE_IMAGE_INFO_CMP, H5F_ACS_FILE_IMAGE_INFO_CLOSE) < 0) HGOTO_ERROR(H5E_PLIST, H5E_CANTINSERT, FAIL, "can't insert property into class") - /* Register the core VFD backing store write tracking flag */ - if(H5P__register_real(pclass, H5F_ACS_CORE_WRITE_TRACKING_FLAG_NAME, H5F_ACS_CORE_WRITE_TRACKING_FLAG_SIZE, &H5F_def_core_write_tracking_flag_g, - NULL, NULL, NULL, H5F_ACS_CORE_WRITE_TRACKING_FLAG_ENC, H5F_ACS_CORE_WRITE_TRACKING_FLAG_DEC, - NULL, NULL, NULL, NULL) < 0) - HGOTO_ERROR(H5E_PLIST, H5E_CANTINSERT, FAIL, "can't insert property into class") - - /* Register the size of the core VFD backing store page size */ - if(H5P__register_real(pclass, H5F_ACS_CORE_WRITE_TRACKING_PAGE_SIZE_NAME, H5F_ACS_CORE_WRITE_TRACKING_PAGE_SIZE_SIZE, &H5F_def_core_write_tracking_page_size_g, - NULL, NULL, NULL, H5F_ACS_CORE_WRITE_TRACKING_PAGE_SIZE_ENC, H5F_ACS_CORE_WRITE_TRACKING_PAGE_SIZE_DEC, - NULL, NULL, NULL, NULL) < 0) - HGOTO_ERROR(H5E_PLIST, H5E_CANTINSERT, FAIL, "can't insert property into class") - /* Register the # of read attempts */ if(H5P__register_real(pclass, H5F_ACS_METADATA_READ_ATTEMPTS_NAME, H5F_ACS_METADATA_READ_ATTEMPTS_SIZE, &H5F_def_metadata_read_attempts_g, NULL, NULL, NULL, H5F_ACS_METADATA_READ_ATTEMPTS_ENC, H5F_ACS_METADATA_READ_ATTEMPTS_DEC, @@ -669,11 +645,11 @@ H5P__facc_reg_prop(H5P_genclass_t *pclass) NULL, NULL, NULL, NULL) < 0) HGOTO_ERROR(H5E_PLIST, H5E_CANTINSERT, FAIL, "can't insert property into class") - /* Register the file VOL driver ID & info */ + /* Register the file VOL connector ID & info */ /* (Note: this property should not have an encode/decode callback -QAK) */ - if(H5P__register_real(pclass, H5F_ACS_VOL_DRV_NAME, H5F_ACS_VOL_SIZE, &def_vol_prop, - H5F_ACS_VOL_CRT, H5F_ACS_VOL_SET, H5F_ACS_VOL_GET, NULL, NULL, - H5F_ACS_VOL_DEL, H5F_ACS_VOL_COPY, H5F_ACS_VOL_CMP, H5F_ACS_VOL_CLOSE) < 0) + if(H5P__register_real(pclass, H5F_ACS_VOL_CONN_NAME, H5F_ACS_VOL_CONN_SIZE, &def_vol_prop, + H5F_ACS_VOL_CONN_CRT, H5F_ACS_VOL_CONN_SET, H5F_ACS_VOL_CONN_GET, NULL, NULL, + H5F_ACS_VOL_CONN_DEL, H5F_ACS_VOL_CONN_COPY, H5F_ACS_VOL_CONN_CMP, H5F_ACS_VOL_CONN_CLOSE) < 0) HGOTO_ERROR(H5E_PLIST, H5E_CANTINSERT, FAIL, "can't insert property into class") done: @@ -3957,89 +3933,6 @@ H5P__facc_libver_type_dec(const void **_pp, void *_value) FUNC_LEAVE_NOAPI(SUCCEED) } /* end H5P__facc_libver_type_dec() */ - -/*------------------------------------------------------------------------- - * Function: H5Pset_core_write_tracking - * - * Purpose: Enables/disables core VFD write tracking and page - * aggregation size. - * - * Return: Non-negative on success/Negative on failure - * - * Programmer: Dana Robinson - * Tuesday, April 8, 2014 - * - *------------------------------------------------------------------------- - */ -herr_t -H5Pset_core_write_tracking(hid_t plist_id, hbool_t is_enabled, size_t page_size) -{ - H5P_genplist_t *plist; /* Property list pointer */ - herr_t ret_value = SUCCEED; /* return value */ - - FUNC_ENTER_API(FAIL) - H5TRACE3("e", "ibz", plist_id, is_enabled, page_size); - - /* The page size cannot be zero */ - if(page_size == 0) - HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "page_size cannot be zero") - - /* Get the plist structure */ - if(NULL == (plist = H5P_object_verify(plist_id, H5P_FILE_ACCESS))) - HGOTO_ERROR(H5E_ATOM, H5E_BADATOM, FAIL, "can't find object for ID") - - /* Set values */ - if(H5P_set(plist, H5F_ACS_CORE_WRITE_TRACKING_FLAG_NAME, &is_enabled) < 0) - HGOTO_ERROR(H5E_PLIST, H5E_CANTSET, FAIL, "can't set core VFD write tracking flag") - if(H5P_set(plist, H5F_ACS_CORE_WRITE_TRACKING_PAGE_SIZE_NAME, &page_size) < 0) - HGOTO_ERROR(H5E_PLIST, H5E_CANTSET, FAIL, "can't set core VFD write tracking page size") - -done: - FUNC_LEAVE_API(ret_value) -} /* end H5Pset_core_write_tracking() */ - - -/*------------------------------------------------------------------------- - * Function: H5Pget_core_write_tracking - * - * Purpose: Gets information about core VFD write tracking and page - * aggregation size. - * - * Return: Non-negative on success/Negative on failure - * - * Programmer: Dana Robinson - * Tuesday, April 8, 2014 - * - *------------------------------------------------------------------------- - */ -herr_t -H5Pget_core_write_tracking(hid_t plist_id, hbool_t *is_enabled, size_t *page_size) -{ - H5P_genplist_t *plist; /* Property list pointer */ - herr_t ret_value = SUCCEED; /* return value */ - - FUNC_ENTER_API(FAIL) - H5TRACE3("e", "i*b*z", plist_id, is_enabled, page_size); - - /* Get the plist structure */ - if(NULL == (plist = H5P_object_verify(plist_id, H5P_FILE_ACCESS))) - HGOTO_ERROR(H5E_ATOM, H5E_BADATOM, FAIL, "can't find object for ID") - - /* Get values */ - if(is_enabled) { - if(H5P_get(plist, H5F_ACS_CORE_WRITE_TRACKING_FLAG_NAME, is_enabled) < 0) - HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, FAIL, "can't get core VFD write tracking flag") - } /* end if */ - - if(page_size) { - if(H5P_get(plist, H5F_ACS_CORE_WRITE_TRACKING_PAGE_SIZE_NAME, page_size) < 0) - HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, FAIL, "can't get core VFD write tracking page size") - } /* end if */ - -done: - FUNC_LEAVE_API(ret_value) -} /* end H5Pget_core_write_tracking() */ - /*------------------------------------------------------------------------- * Function: H5Pset_metadata_read_attempts @@ -4975,10 +4868,10 @@ done: /*------------------------------------------------------------------------- * Function: H5P_set_vol * - * Purpose: Set the VOL driver for a file access property list - * (PLIST_ID). The vol properties will + * Purpose: Set the VOL connector for a file access property list + * (PLIST_ID). The VOL properties will * be copied into the property list and the reference count on - * the vol will be incremented. + * the VOL will be incremented. * * Return: SUCCEED/FAIL * @@ -4992,19 +4885,19 @@ H5P_set_vol(H5P_genplist_t *plist, hid_t vol_id, const void *vol_info) FUNC_ENTER_NOAPI(FAIL) if(NULL == H5I_object_verify(vol_id, H5I_VOL)) - HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a VOL driver ID") + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a VOL connector ID") if(TRUE == H5P_isa_class(plist->plist_id, H5P_FILE_ACCESS)) { - H5VL_driver_prop_t vol_prop; /* Property for VOL ID & info */ + H5VL_connector_prop_t vol_prop; /* Property for VOL ID & info */ - /* Prepare the VOL driver property */ - vol_prop.driver_id = vol_id; - vol_prop.driver_info = vol_info; + /* Prepare the VOL connector property */ + vol_prop.connector_id = vol_id; + vol_prop.connector_info = vol_info; - /* Set the driver ID & info property */ - if(H5P_set(plist, H5F_ACS_VOL_DRV_NAME, &vol_prop) < 0) - HGOTO_ERROR(H5E_PLIST, H5E_CANTSET, FAIL, "can't set VOL driver ID & info") - } + /* Set the connector ID & info property */ + if(H5P_set(plist, H5F_ACS_VOL_CONN_NAME, &vol_prop) < 0) + HGOTO_ERROR(H5E_PLIST, H5E_CANTSET, FAIL, "can't set VOL connector ID & info") + } /* end if */ else HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a file access property list"); @@ -5016,7 +4909,7 @@ done: /*------------------------------------------------------------------------- * Function: H5Pset_vol * - * Purpose: Set the file VOL driver (VOL_ID) for a file access + * Purpose: Set the file VOL connector (VOL_ID) for a file access * property list (PLIST_ID) * * Return: Success: Non-negative @@ -5037,11 +4930,11 @@ H5Pset_vol(hid_t plist_id, hid_t new_vol_id, const void *new_vol_info) if(NULL == (plist = (H5P_genplist_t *)H5I_object_verify(plist_id, H5I_GENPROP_LST))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a property list") if(NULL == H5I_object_verify(new_vol_id, H5I_VOL)) - HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a file vol ID") + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a file VOL ID") - /* Set the vol */ + /* Set the VOL */ if(H5P_set_vol(plist, new_vol_id, new_vol_info) < 0) - HGOTO_ERROR(H5E_PLIST, H5E_CANTSET, FAIL, "can't set vol") + HGOTO_ERROR(H5E_PLIST, H5E_CANTSET, FAIL, "can't set VOL") done: FUNC_LEAVE_API(ret_value) @@ -5049,197 +4942,113 @@ done: /*------------------------------------------------------------------------- - * Function: H5P_get_vol_info - * - * Purpose: Returns a pointer directly to the file vol-specific - * information of a file access property list. - * - * Return: Success: Ptr to *uncopied* vol specific data - * structure if any. - * - * Failure: NULL. Null is also returned if the vol has - * not registered any vol-specific properties - * although no error is pushed on the stack in - * this case. - * - *------------------------------------------------------------------------- - */ -void * -H5P_get_vol_info(H5P_genplist_t *plist) -{ - void *ret_value = NULL; - - FUNC_ENTER_NOAPI(NULL) - - /* Get the current vol info */ - if(TRUE == H5P_isa_class(plist->plist_id, H5P_FILE_ACCESS)) { - H5VL_driver_prop_t driver_prop; /* Property for vol driver ID & info */ - - if(H5P_peek(plist, H5F_ACS_VOL_DRV_NAME, &driver_prop) < 0) - HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, NULL, "can't get vol driver info") - ret_value = (void *)driver_prop.driver_info; - } else - HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, NULL, "not a file access property list") - -done: - FUNC_LEAVE_NOAPI(ret_value) -} /* end H5P_get_vol_info() */ - - -/*------------------------------------------------------------------------- - * Function: H5Pget_vol_info - * - * Purpose: Returns a pointer directly to the file vol-specific - * information of a file access property list. - * - * XXX (VOL MERGE): This API call seems like a REALLY bad idea - DER - * - * Return: Success: Ptr to *uncopied* vol specific data - * structure if any. + * Function: H5Pget_vol_id * - * Failure: NULL. Null is also returned if the vol has - * not registered any vol-specific properties - * although no error is pushed on the stack in - * this case. - * - *------------------------------------------------------------------------- - */ -void * -H5Pget_vol_info(hid_t plist_id) -{ - H5P_genplist_t *plist; /* Property list pointer */ - void *ret_value; /* Return value */ - - FUNC_ENTER_API(NULL) - H5TRACE1("*x", "i", plist_id); - - if(NULL == (plist = (H5P_genplist_t *)H5I_object_verify(plist_id, H5I_GENPROP_LST))) - HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, NULL, "not a property list") - - if(NULL == (ret_value = H5P_get_vol_info(plist))) - HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, NULL, "can't get vol info") - -done: - FUNC_LEAVE_API(ret_value) -} /* end H5Pget_vol_info() */ - - -/*------------------------------------------------------------------------- - * Function: H5P__vol_copy - * - * Purpose: Copy VOL driver ID & info. - * - * Note: This is an "in-place" copy, since this routine gets called - * after the top-level copy has been performed and this routine - * finishes the "deep" part of the copy. + * Purpose: Returns the ID of the current VOL connector. + * This ID should be closed with H5VLclose(). * * Return: Success: Non-negative * Failure: Negative * *------------------------------------------------------------------------- */ -static herr_t -H5P__vol_copy(void *value) +herr_t +H5Pget_vol_id(hid_t plist_id, hid_t *vol_id) { + H5P_genplist_t *plist; /* Property list pointer */ herr_t ret_value = SUCCEED; /* Return value */ - FUNC_ENTER_STATIC - - if(value) { - H5VL_driver_prop_t *info = (H5VL_driver_prop_t *)value; /* Driver ID & info struct */ + FUNC_ENTER_API(FAIL) + H5TRACE2("e", "i*i", plist_id, vol_id); - /* Copy the driver ID & info, if there is one */ - if(info->driver_id > 0) { - /* Increment the reference count on driver ID and copy driver info */ - if(H5I_inc_ref(info->driver_id, FALSE) < 0) - HGOTO_ERROR(H5E_PLIST, H5E_CANTINC, FAIL, "unable to increment ref count on VOL driver ID") + /* Get property list for ID */ + if(NULL == (plist = (H5P_genplist_t *)H5I_object_verify(plist_id, H5I_GENPROP_LST))) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a property list") - /* Copy driver info, if it exists */ - if(info->driver_info) { - H5VL_class_t *driver; /* Pointer to driver */ - void *new_driver; /* Copy of driver info */ + /* Get the current VOL ID */ + if(TRUE == H5P_isa_class(plist->plist_id, H5P_FILE_ACCESS)) { + H5VL_connector_prop_t connector_prop; /* Property for VOL connector ID & info */ - /* Retrieve the driver for the ID */ - if(NULL == (driver = (H5VL_class_t *)H5I_object(info->driver_id))) - HGOTO_ERROR(H5E_PLIST, H5E_BADTYPE, FAIL, "not a VOL driver ID") + /* Get the connector property */ + if(H5P_peek(plist, H5F_ACS_VOL_CONN_NAME, &connector_prop) < 0) + HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, FAIL, "can't get VOL connector info") - /* Allow the driver to copy or do it ourselves */ - if(driver->fapl_copy) { - if(NULL == (new_driver = (driver->fapl_copy)(info->driver_info))) - HGOTO_ERROR(H5E_PLIST, H5E_CANTCOPY, FAIL, "driver info copy failed") - } - else if(driver->fapl_size > 0) { - if(NULL == (new_driver = H5MM_malloc(driver->fapl_size))) - HGOTO_ERROR(H5E_PLIST, H5E_CANTALLOC, FAIL, "driver info allocation failed") - HDmemcpy(new_driver, info->driver_info, driver->fapl_size); - } - else - HGOTO_ERROR(H5E_PLIST, H5E_UNSUPPORTED, FAIL, "no way to copy driver info") + /* Increment the VOL ID's ref count */ + if(H5I_inc_ref(connector_prop.connector_id, TRUE) < 0) + HGOTO_ERROR(H5E_PLIST, H5E_CANTINC, FAIL, "unable to increment ref count on VOL connector ID") - /* Set the driver info for the copy */ - info->driver_info = new_driver; - } - } - } + /* Set the connector ID to return */ + *vol_id = connector_prop.connector_id; + } /* end if */ + else + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a file access property list") done: - FUNC_LEAVE_NOAPI(ret_value) -} /* end H5P__vol_copy() */ + FUNC_LEAVE_API(ret_value) +} /* end H5Pget_vol_id() */ /*------------------------------------------------------------------------- - * Function: H5P__vol_free + * Function: H5Pget_vol_info * - * Purpose: Free VOL driver ID & info. + * Purpose: Returns a copy of the VOL info for a connector. + * This information should be freed with H5VLfree_connector_info. * * Return: Success: Non-negative * Failure: Negative * *------------------------------------------------------------------------- */ -static herr_t -H5P__vol_free(void *value) +herr_t +H5Pget_vol_info(hid_t plist_id, void **vol_info) { + H5P_genplist_t *plist; /* Property list pointer */ herr_t ret_value = SUCCEED; /* Return value */ - FUNC_ENTER_STATIC + FUNC_ENTER_API(FAIL) + H5TRACE2("e", "i**x", plist_id, vol_info); - if(value) { - H5VL_driver_prop_t *info = (H5VL_driver_prop_t *)value; /* Driver ID & info struct */ + /* Get property list for ID */ + if(NULL == (plist = (H5P_genplist_t *)H5I_object_verify(plist_id, H5I_GENPROP_LST))) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a property list") - /* Free the driver info (if it exists) and decrement the ID */ - if(info->driver_id > 0) { - if(info->driver_info) { - H5VL_class_t *driver; /* Pointer to driver */ + /* Get the current VOL info */ + if(TRUE == H5P_isa_class(plist->plist_id, H5P_FILE_ACCESS)) { + void *new_connector_info = NULL; /* Copy of connector info */ + H5VL_connector_prop_t connector_prop; /* Property for VOL connector ID & info */ - /* Retrieve the driver for the ID */ - if(NULL == (driver = (H5VL_class_t *)H5I_object(info->driver_id))) - HGOTO_ERROR(H5E_PLIST, H5E_BADTYPE, FAIL, "not a VOL driver ID") + /* Get the connector property */ + if(H5P_peek(plist, H5F_ACS_VOL_CONN_NAME, &connector_prop) < 0) + HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, FAIL, "can't get VOL connector property") - /* Allow the driver to free info or do it ourselves */ - if(driver->fapl_free) { - if((driver->fapl_free)((void *)info->driver_info) < 0) /* Casting away const OK -QAK */ - HGOTO_ERROR(H5E_PLIST, H5E_CANTFREE, FAIL, "driver info free request failed") - } - else - H5MM_xfree((void *)info->driver_info); /* Casting away const OK -QAK */ - } + /* Copy connector info, if it exists */ + if(connector_prop.connector_info) { + H5VL_class_t *connector; /* Pointer to connector */ - /* Decrement reference count for driver ID */ - if(H5I_dec_ref(info->driver_id) < 0) - HGOTO_ERROR(H5E_PLIST, H5E_CANTDEC, FAIL, "can't decrement reference count for driver ID") - } - } + /* Retrieve the connector for the ID */ + if(NULL == (connector = (H5VL_class_t *)H5I_object(connector_prop.connector_id))) + HGOTO_ERROR(H5E_PLIST, H5E_BADTYPE, FAIL, "not a VOL connector ID") + + /* Allocate and copy connector info */ + if(H5VL_copy_connector_info(connector, &new_connector_info, connector_prop.connector_info) < 0) + HGOTO_ERROR(H5E_PLIST, H5E_CANTCOPY, FAIL, "connector info copy failed") + } /* end if */ + + /* Set the connector info */ + *vol_info = new_connector_info; + } /* end if */ + else + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a file access property list") done: - FUNC_LEAVE_NOAPI(ret_value) -} /* end H5P__vol_free() */ + FUNC_LEAVE_API(ret_value) +} /* end H5Pget_vol_info() */ /*------------------------------------------------------------------------- * Function: H5P__facc_vol_create * - * Purpose: Create callback for the VOL driver ID & info property. + connectorose: Create callback for the VOL connector ID & info property. * * Return: Success: Non-negative * Failure: Negative @@ -5253,9 +5062,9 @@ H5P__facc_vol_create(const char H5_ATTR_UNUSED *name, size_t H5_ATTR_UNUSED size FUNC_ENTER_STATIC - /* Make copy of the VOL driver */ - if(H5P__vol_copy(value) < 0) - HGOTO_ERROR(H5E_PLIST, H5E_CANTCOPY, FAIL, "can't copy VOL driver") + /* Make copy of the VOL connector */ + if(H5VL_conn_copy((H5VL_connector_prop_t *)value) < 0) + HGOTO_ERROR(H5E_PLIST, H5E_CANTCOPY, FAIL, "can't copy VOL connector") done: FUNC_LEAVE_NOAPI(ret_value) @@ -5265,7 +5074,7 @@ done: /*------------------------------------------------------------------------- * Function: H5P__facc_vol_set * - * Purpose: Copies a VOL driver property when it's set for a property list + * Purpose: Copies a VOL connector property when it's set for a property list * * Return: Success: Non-negative * Failure: Negative @@ -5283,9 +5092,9 @@ H5P__facc_vol_set(hid_t H5_ATTR_UNUSED prop_id, const char H5_ATTR_UNUSED *name, /* Sanity check */ HDassert(value); - /* Make copy of VOL driver ID & info */ - if(H5P__vol_copy(value) < 0) - HGOTO_ERROR(H5E_PLIST, H5E_CANTCOPY, FAIL, "can't copy VOL driver") + /* Make copy of VOL connector ID & info */ + if(H5VL_conn_copy((H5VL_connector_prop_t *)value) < 0) + HGOTO_ERROR(H5E_PLIST, H5E_CANTCOPY, FAIL, "can't copy VOL connector") done: FUNC_LEAVE_NOAPI(ret_value) @@ -5295,7 +5104,7 @@ done: /*------------------------------------------------------------------------- * Function: H5P__facc_vol_get * - * Purpose: Copies a VOL driver property when it's retrieved from a property list + * Purpose: Copies a VOL connector property when it's retrieved from a property list * * Return: Success: Non-negative * Failure: Negative @@ -5313,9 +5122,9 @@ H5P__facc_vol_get(hid_t H5_ATTR_UNUSED prop_id, const char H5_ATTR_UNUSED *name, /* Sanity check */ HDassert(value); - /* Make copy of VOL driver */ - if(H5P__vol_copy(value) < 0) - HGOTO_ERROR(H5E_PLIST, H5E_CANTCOPY, FAIL, "can't copy VOL driver") + /* Make copy of VOL connector */ + if(H5VL_conn_copy((H5VL_connector_prop_t *)value) < 0) + HGOTO_ERROR(H5E_PLIST, H5E_CANTCOPY, FAIL, "can't copy VOL connector") done: FUNC_LEAVE_NOAPI(ret_value) @@ -5325,7 +5134,7 @@ done: /*------------------------------------------------------------------------- * Function: H5P__facc_vol_del * - * Purpose: Frees memory used to store the VOL driver ID & info property + * Purpose: Frees memory used to store the VOL connector ID & info property * * Return: Success: Non-negative * Failure: Negative @@ -5339,9 +5148,9 @@ H5P__facc_vol_del(hid_t H5_ATTR_UNUSED prop_id, const char H5_ATTR_UNUSED *name, FUNC_ENTER_STATIC - /* Free the VOL driver ID & info */ - if(H5P__vol_free(value) < 0) - HGOTO_ERROR(H5E_PLIST, H5E_CANTRELEASE, FAIL, "can't release VOL driver") + /* Free the VOL connector ID & info */ + if(H5VL_conn_free((H5VL_connector_prop_t *)value) < 0) + HGOTO_ERROR(H5E_PLIST, H5E_CANTRELEASE, FAIL, "can't release VOL connector") done: FUNC_LEAVE_NOAPI(ret_value) @@ -5351,7 +5160,7 @@ done: /*------------------------------------------------------------------------- * Function: H5P__facc_vol_copy * - * Purpose: Copy callback for the VOL driver ID & info property. + * Purpose: Copy callback for the VOL connector ID & info property. * * Return: Success: Non-negative * Failure: Negative @@ -5365,9 +5174,9 @@ H5P__facc_vol_copy(const char H5_ATTR_UNUSED *name, size_t H5_ATTR_UNUSED size, FUNC_ENTER_STATIC - /* Make copy of VOL driver */ - if(H5P__vol_copy(value) < 0) - HGOTO_ERROR(H5E_PLIST, H5E_CANTCOPY, FAIL, "can't copy VOL driver") + /* Make copy of VOL connector */ + if(H5VL_conn_copy((H5VL_connector_prop_t *)value) < 0) + HGOTO_ERROR(H5E_PLIST, H5E_CANTCOPY, FAIL, "can't copy VOL connector") done: FUNC_LEAVE_NOAPI(ret_value) @@ -5377,7 +5186,7 @@ done: /*------------------------------------------------------------------------- * Function: H5P__facc_vol_cmp * - * Purpose: Callback routine which is called whenever the VOL driver + * Purpose: Callback routine which is called whenever the VOL connector * ID & info property in the file access property list * is compared. * @@ -5390,48 +5199,45 @@ done: static int H5P__facc_vol_cmp(const void *_info1, const void *_info2, size_t H5_ATTR_UNUSED size) { - const H5VL_driver_prop_t *info1 = (const H5VL_driver_prop_t *)_info1; /* Create local aliases for values */ - const H5VL_driver_prop_t *info2 = (const H5VL_driver_prop_t *)_info2; - H5VL_class_t *cls1, *cls2; /* Driver class for each property */ - int cmp_value; /* Value from comparison */ - herr_t ret_value = 0; /* Return value */ + const H5VL_connector_prop_t *info1 = (const H5VL_connector_prop_t *)_info1; /* Create local aliases for values */ + const H5VL_connector_prop_t *info2 = (const H5VL_connector_prop_t *)_info2; + H5VL_class_t *cls1, *cls2; /* connector class for each property */ + int cmp_value = 0; /* Value from comparison */ + herr_t status; /* Status from info comparison */ + int ret_value = 0; /* Return value */ FUNC_ENTER_STATIC_NOERR /* Sanity check */ HDassert(info1); HDassert(info2); - HDassert(size == sizeof(H5VL_driver_prop_t)); + HDassert(size == sizeof(H5VL_connector_prop_t)); - /* Compare drivers */ - if(NULL == (cls1 = (H5VL_class_t *)H5I_object(info1->driver_id))) + /* Compare connectors */ + if(NULL == (cls1 = (H5VL_class_t *)H5I_object(info1->connector_id))) HGOTO_DONE(-1) - if(NULL == (cls2 = (H5VL_class_t *)H5I_object(info2->driver_id))) + if(NULL == (cls2 = (H5VL_class_t *)H5I_object(info2->connector_id))) HGOTO_DONE(1) - if(cls1->name == NULL && cls2->name != NULL) - HGOTO_DONE(-1); - if(cls1->name != NULL && cls2->name == NULL) - HGOTO_DONE(1); - if(0 != (cmp_value = HDstrcmp(cls1->name, cls2->name))) + status = H5VL_cmp_connector_cls(&cmp_value, cls1, cls2); + HDassert(status >= 0); + if(cmp_value != 0) HGOTO_DONE(cmp_value); - /* Compare driver info */ - if(cls1->fapl_size < cls2->fapl_size) - HGOTO_DONE(-1) - if(cls1->fapl_size > cls2->fapl_size) - HGOTO_DONE(1) - HDassert(cls1->fapl_size == cls2->fapl_size); + /* At this point, we should be able to assume that we are dealing with + * the same connector class struct (or a copies of the same class struct) + */ - if(info1->driver_info == NULL && info2->driver_info != NULL) - HGOTO_DONE(-1); - if(info1->driver_info != NULL && info2->driver_info == NULL) - HGOTO_DONE(1); - if(info1->driver_info) { - HDassert(cls1->fapl_size > 0); - if(0 != (cmp_value = HDmemcmp(info1->driver_info, info2->driver_info, cls1->fapl_size))) - HGOTO_DONE(cmp_value); - } + /* Use one of the classes (cls1) info comparison routines to compare the + * info objects + */ + HDassert(cls1->info_cmp == cls2->info_cmp); + status = H5VL_cmp_connector_info(cls1, &cmp_value, info1->connector_info, info2->connector_info); + HDassert(status >= 0); + + /* Set return value */ + ret_value = cmp_value; + done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5P__facc_vol_cmp() */ @@ -5440,7 +5246,7 @@ done: /*------------------------------------------------------------------------- * Function: H5P__facc_vol_close * - * Purpose: Close callback for the VOL driver ID & info property. + * Purpose: Close callback for the VOL connector ID & info property. * * Return: Success: Non-negative * Failure: Negative @@ -5454,9 +5260,9 @@ H5P__facc_vol_close(const char H5_ATTR_UNUSED *name, size_t H5_ATTR_UNUSED size, FUNC_ENTER_STATIC - /* Free the VOL driver */ - if(H5P__vol_free(value) < 0) - HGOTO_ERROR(H5E_PLIST, H5E_CANTRELEASE, FAIL, "can't release VOL driver") + /* Free the VOL connector */ + if(H5VL_conn_free((H5VL_connector_prop_t *)value) < 0) + HGOTO_ERROR(H5E_PLIST, H5E_CANTRELEASE, FAIL, "can't release VOL connector") done: FUNC_LEAVE_NOAPI(ret_value) diff --git a/src/H5Plcpl.c b/src/H5Plcpl.c index 6568ecd..16be52a 100644 --- a/src/H5Plcpl.c +++ b/src/H5Plcpl.c @@ -55,7 +55,7 @@ /* Definitions for Location params */ #define H5L_CRT_LOCATION_SIZE sizeof(H5VL_loc_params_t) -#define H5L_CRT_LOCATION_DEF {H5I_BADID, H5VL_OBJECT_BY_SELF, {HADDR_UNDEF}} +#define H5L_CRT_LOCATION_DEF {H5I_BADID, H5VL_OBJECT_BY_SELF, {{HADDR_UNDEF}}} /* Definitions for target object NAME */ #define H5L_CRT_TARGET_NAME_SIZE sizeof(char *) diff --git a/src/H5Pprivate.h b/src/H5Pprivate.h index cd749cb..866f088 100644 --- a/src/H5Pprivate.h +++ b/src/H5Pprivate.h @@ -178,7 +178,6 @@ H5_DLL const void *H5P_peek_driver_info(H5P_genplist_t *plist); H5_DLL herr_t H5P_set_driver(H5P_genplist_t *plist, hid_t new_driver_id, const void *new_driver_info); H5_DLL herr_t H5P_set_vol(H5P_genplist_t *plist, hid_t vol_id, const void *vol_info); -H5_DLL void * H5P_get_vol_info(H5P_genplist_t *plist); H5_DLL herr_t H5P_set_vlen_mem_manager(H5P_genplist_t *plist, H5MM_allocate_t alloc_func, void *alloc_info, H5MM_free_t free_func, void *free_info); diff --git a/src/H5Ppublic.h b/src/H5Ppublic.h index 77d8ebb..86c6687 100644 --- a/src/H5Ppublic.h +++ b/src/H5Ppublic.h @@ -314,7 +314,8 @@ H5_DLL herr_t H5Pset_driver(hid_t plist_id, hid_t driver_id, H5_DLL hid_t H5Pget_driver(hid_t plist_id); H5_DLL const void *H5Pget_driver_info(hid_t plist_id); H5_DLL herr_t H5Pset_vol(hid_t plist_id, hid_t new_vol_id, const void *new_vol_info); -H5_DLL void *H5Pget_vol_info(hid_t plist_id); +H5_DLL herr_t H5Pget_vol_id(hid_t plist_id, hid_t *vol_id); +H5_DLL herr_t H5Pget_vol_info(hid_t plist_id, void **vol_info); H5_DLL herr_t H5Pset_family_offset(hid_t fapl_id, hsize_t offset); H5_DLL herr_t H5Pget_family_offset(hid_t fapl_id, hsize_t *offset); H5_DLL herr_t H5Pset_multi_type(hid_t fapl_id, H5FD_mem_t type); @@ -127,9 +127,7 @@ H5Rcreate(void *ref, hid_t loc_id, const char *name, H5R_type_t ref_type, hid_t HGOTO_ERROR(H5E_REFERENCE, H5E_CANTSET, FAIL, "can't set access property list info") /* Create reference */ - if((ret_value = H5VL_object_specific(vol_obj->data, loc_params, vol_obj->driver->cls, H5VL_REF_CREATE, - H5P_DATASET_XFER_DEFAULT, H5_REQUEST_NULL, - ref, name, ref_type, space_id)) < 0) + if((ret_value = H5VL_object_specific(vol_obj, &loc_params, H5VL_REF_CREATE, H5P_DATASET_XFER_DEFAULT, H5_REQUEST_NULL, ref, name, (int)ref_type, space_id)) < 0) HGOTO_ERROR(H5E_REFERENCE, H5E_CANTCREATE, FAIL, "unable to create reference") done: @@ -200,12 +198,11 @@ H5Rdereference2(hid_t obj_id, hid_t oapl_id, H5R_type_t ref_type, const void *_r loc_params.obj_type = H5I_get_type(obj_id); /* Dereference */ - if(NULL == (opened_obj = H5VL_object_open(vol_obj->data, loc_params, vol_obj->driver->cls, - &opened_type, H5P_DATASET_XFER_DEFAULT, H5_REQUEST_NULL))) + if(NULL == (opened_obj = H5VL_object_open(vol_obj, &loc_params, &opened_type, H5P_DATASET_XFER_DEFAULT, H5_REQUEST_NULL))) HGOTO_ERROR(H5E_REFERENCE, H5E_CANTOPENOBJ, H5I_INVALID_HID, "unable to dereference object") - if((ret_value = H5VL_register(opened_type, opened_obj, vol_obj->driver, TRUE)) < 0) - HGOTO_ERROR(H5E_ATOM, H5E_CANTREGISTER, H5I_INVALID_HID, "unable to register object handle") + if((ret_value = H5VL_register(opened_type, opened_obj, vol_obj->connector, TRUE)) < 0) + HGOTO_ERROR(H5E_REFERENCE, H5E_CANTREGISTER, H5I_INVALID_HID, "unable to register object handle") done: FUNC_LEAVE_API(ret_value) @@ -260,8 +257,7 @@ H5Rget_region(hid_t id, H5R_type_t ref_type, const void *ref) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, H5I_INVALID_HID, "invalid file identifier") /* Get the dataspace with the correct region selected */ - if(H5VL_object_get(vol_obj->data, loc_params, vol_obj->driver->cls, H5VL_REF_GET_REGION, - H5P_DATASET_XFER_DEFAULT, H5_REQUEST_NULL, &ret_value, ref_type, ref) < 0) + if(H5VL_object_get(vol_obj, &loc_params, H5VL_REF_GET_REGION, H5P_DATASET_XFER_DEFAULT, H5_REQUEST_NULL, &ret_value, (int)ref_type, ref) < 0) HGOTO_ERROR(H5E_REFERENCE, H5E_CANTGET, H5I_INVALID_HID, "unable to retrieve dataspace") done: @@ -318,9 +314,7 @@ H5Rget_obj_type2(hid_t id, H5R_type_t ref_type, const void *ref, HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "invalid file identifier") /* Get the object type */ - if(H5VL_object_get(vol_obj->data, loc_params, vol_obj->driver->cls, - H5VL_REF_GET_TYPE, H5P_DATASET_XFER_DEFAULT, - H5_REQUEST_NULL, obj_type, ref_type, ref) < 0) + if(H5VL_object_get(vol_obj, &loc_params, H5VL_REF_GET_TYPE, H5P_DATASET_XFER_DEFAULT, H5_REQUEST_NULL, obj_type, (int)ref_type, ref) < 0) HGOTO_ERROR(H5E_REFERENCE, H5E_CANTGET, FAIL, "unable to determine object type") done: @@ -387,9 +381,7 @@ H5Rget_name(hid_t id, H5R_type_t ref_type, const void *_ref, char *name, HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, (-1), "invalid file identifier") /* Get name */ - if(H5VL_object_get(vol_obj->data, loc_params, vol_obj->driver->cls, H5VL_REF_GET_NAME, - H5P_DATASET_XFER_DEFAULT, H5_REQUEST_NULL, - &ret_value, name, size, ref_type, _ref) < 0) + if(H5VL_object_get(vol_obj, &loc_params, H5VL_REF_GET_NAME, H5P_DATASET_XFER_DEFAULT, H5_REQUEST_NULL, &ret_value, name, size, (int)ref_type, _ref) < 0) HGOTO_ERROR(H5E_REFERENCE, H5E_CANTGET, (-1), "unable to determine object path") done: diff --git a/src/H5Rdeprec.c b/src/H5Rdeprec.c index f224cda..ab8d3b4 100644 --- a/src/H5Rdeprec.c +++ b/src/H5Rdeprec.c @@ -37,13 +37,13 @@ #include "H5Ppublic.h" /* Property lists */ /* Private headers needed by this file */ -#include "H5private.h" /* Generic Functions */ -#include "H5ACprivate.h" /* Metadata cache */ +#include "H5private.h" /* Generic Functions */ +#include "H5ACprivate.h" /* Metadata cache */ #include "H5CXprivate.h" /* API Contexts */ -#include "H5Eprivate.h" /* Error handling */ -#include "H5Gprivate.h" /* Groups */ +#include "H5Eprivate.h" /* Error handling */ +#include "H5Gprivate.h" /* Groups */ #include "H5Iprivate.h" /* IDs */ -#include "H5Oprivate.h" /* Object headers */ +#include "H5Oprivate.h" /* Object headers */ #include "H5Rpkg.h" /* References */ @@ -126,8 +126,7 @@ H5Rget_obj_type1(hid_t id, H5R_type_t ref_type, const void *ref) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, H5G_UNKNOWN, "invalid file identifier") /* Get the object information */ - if (H5VL_object_get(vol_obj->data, loc_params, vol_obj->driver->cls, H5VL_REF_GET_TYPE, - H5P_DATASET_XFER_DEFAULT, H5_REQUEST_NULL, &obj_type, ref_type, ref) < 0) + if(H5VL_object_get(vol_obj, &loc_params, H5VL_REF_GET_TYPE, H5P_DATASET_XFER_DEFAULT, H5_REQUEST_NULL, &obj_type, (int)ref_type, ref) < 0) HGOTO_ERROR(H5E_REFERENCE, H5E_CANTGET, H5G_UNKNOWN, "unable to determine object type") /* Set return value */ @@ -183,13 +182,12 @@ H5Rdereference1(hid_t obj_id, H5R_type_t ref_type, const void *_ref) loc_params.obj_type = H5I_get_type(obj_id); /* Dereference */ - if (NULL == (opened_obj = H5VL_object_open(vol_obj->data, loc_params, vol_obj->driver->cls, &opened_type, - H5P_DATASET_XFER_DEFAULT, H5_REQUEST_NULL))) + if(NULL == (opened_obj = H5VL_object_open(vol_obj, &loc_params, &opened_type, H5P_DATASET_XFER_DEFAULT, H5_REQUEST_NULL))) HGOTO_ERROR(H5E_REFERENCE, H5E_CANTOPENOBJ, H5I_INVALID_HID, "unable to dereference object") /* Get an atom for the object */ - if ((ret_value = H5VL_register(opened_type, opened_obj, vol_obj->driver, TRUE)) < 0) - HGOTO_ERROR(H5E_ATOM, H5E_CANTREGISTER, H5I_INVALID_HID, "unable to atomize object handle") + if((ret_value = H5VL_register(opened_type, opened_obj, vol_obj->connector, TRUE)) < 0) + HGOTO_ERROR(H5E_REFERENCE, H5E_CANTREGISTER, H5I_INVALID_HID, "unable to atomize object handle") done: FUNC_LEAVE_API(ret_value) diff --git a/src/H5Rint.c b/src/H5Rint.c index 52a4ee1..a4f76ce 100644 --- a/src/H5Rint.c +++ b/src/H5Rint.c @@ -62,18 +62,6 @@ hbool_t H5_PKG_INIT_VAR = FALSE; /* Local Variables */ /*******************/ -/* Reference ID class - * - * NOTE: H5I_REFERENCE is not used by the library and has been deprecated - * with a tentative removal version of 1.12.0. (DER, July 2017) - */ -static const H5I_class_t H5I_REFERENCE_CLS[1] = {{ - H5I_REFERENCE, /* ID class value */ - 0, /* Class flags */ - 0, /* # of reserved IDs for class */ - NULL /* Callback routine for closing objects of this class */ -}}; - /* Flag indicating "top" of interface has been initialized */ static hbool_t H5R_top_package_initialize_s = FALSE; @@ -97,11 +85,7 @@ H5R__init_package(void) FUNC_ENTER_NOAPI_NOINIT - /* Initialize the atom group for the file IDs */ - if (H5I_register_type(H5I_REFERENCE_CLS) < 0) - HGOTO_ERROR(H5E_REFERENCE, H5E_CANTINIT, FAIL, "unable to initialize interface") - - /* Mark "top" of interface as initialized, too */ + /* Mark "top" of interface as initialized */ H5R_top_package_initialize_s = TRUE; done: @@ -134,16 +118,10 @@ H5R_top_term_package(void) FUNC_ENTER_NOAPI_NOINIT_NOERR - if (H5R_top_package_initialize_s) { - if (H5I_nmembers(H5I_REFERENCE) > 0) { - (void)H5I_clear_type(H5I_REFERENCE, FALSE, FALSE); - n++; - } - - /* Mark closed */ - if (0 == n) + /* Mark closed if initialized */ + if(H5R_top_package_initialize_s) + if(0 == n) H5R_top_package_initialize_s = FALSE; - } FUNC_LEAVE_NOAPI(n) } /* end H5R_top_term_package() */ @@ -176,16 +154,12 @@ H5R_term_package(void) FUNC_ENTER_NOAPI_NOINIT_NOERR - if (H5_PKG_INIT_VAR) { + if(H5_PKG_INIT_VAR) { /* Sanity checks */ - HDassert(0 == H5I_nmembers(H5I_REFERENCE)); HDassert(FALSE == H5R_top_package_initialize_s); - /* Destroy the reference id group */ - n += (H5I_dec_type_ref(H5I_REFERENCE) > 0); - /* Mark closed */ - if (0 == n) + if(0 == n) H5_PKG_INIT_VAR = FALSE; } @@ -692,9 +666,9 @@ done: REVISION LOG --------------------------------------------------------------------------*/ ssize_t -H5R__get_name(H5F_t *f, H5R_type_t ref_type, const void *_ref, char *name, size_t size) +H5R__get_name(H5F_t *f, H5R_type_t ref_type, const void *_ref, + char *name, size_t size) { - hid_t file_id = H5I_INVALID_HID; /* ID for file that the reference is in */ H5O_loc_t oloc; /* Object location describing object for reference */ ssize_t ret_value = -1; /* Return value */ @@ -728,7 +702,7 @@ H5R__get_name(H5F_t *f, H5R_type_t ref_type, const void *_ref, char *name, size_ UINT32DECODE(p, hobjid.idx); /* Get the dataset region from the heap (allocate inside routine) */ - if ((buf = (uint8_t *)H5HG_read(oloc.file, &hobjid, NULL, NULL)) == NULL) + if((buf = (uint8_t *)H5HG_read(oloc.file, &hobjid, NULL, NULL)) == NULL) HGOTO_ERROR(H5E_REFERENCE, H5E_READERROR, (-1), "Unable to read dataset region information") /* Get the object oid for the dataset */ @@ -747,19 +721,11 @@ H5R__get_name(H5F_t *f, H5R_type_t ref_type, const void *_ref, char *name, size_ HGOTO_ERROR(H5E_REFERENCE, H5E_UNSUPPORTED, (-1), "internal error (unknown reference type)") } /* end switch */ - /* Retrieve file ID for name search */ - if ((file_id = H5F_get_id(f, FALSE)) < 0) - HGOTO_ERROR(H5E_ATOM, H5E_CANTGET, (-1), "can't get file ID") - /* Get name, length, etc. */ - if ((ret_value = H5G_get_name_by_addr(file_id, &oloc, name, size)) < 0) + if((ret_value = H5G_get_name_by_addr(f, &oloc, name, size)) < 0) HGOTO_ERROR(H5E_REFERENCE, H5E_CANTGET, (-1), "can't determine name") done: - /* Close file ID used for search */ - if (file_id > 0 && H5I_dec_ref(file_id) < 0) - HDONE_ERROR(H5E_REFERENCE, H5E_CANTDEC, (-1), "can't decrement ref count of temp ID") - FUNC_LEAVE_NOAPI(ret_value) } /* end H5R__get_name() */ @@ -1609,23 +1609,22 @@ H5T__close_cb(H5T_t *dt) HDassert(dt->shared); /* If this datatype is VOL-managed (i.e.: has a VOL object), - * close it through the VOL driver. + * close it through the VOL connector. */ if(NULL != dt->vol_obj) { - - /* Close the driver-managed datatype data */ - if(H5VL_datatype_close(dt->vol_obj->data, dt->vol_obj->driver->cls, H5P_DATASET_XFER_DEFAULT, H5_REQUEST_NULL) < 0) - HGOTO_ERROR(H5E_DATATYPE, H5E_CLOSEERROR, FAIL, "unable to close datatype"); + /* Close the connector-managed datatype data */ + if(H5VL_datatype_close(dt->vol_obj, H5P_DATASET_XFER_DEFAULT, H5_REQUEST_NULL) < 0) + HGOTO_ERROR(H5E_DATATYPE, H5E_CLOSEERROR, FAIL, "unable to close datatype") /* Free the VOL object */ if(H5VL_free_object(dt->vol_obj) < 0) - HGOTO_ERROR(H5E_ATTR, H5E_CANTDEC, FAIL, "unable to free VOL object"); + HGOTO_ERROR(H5E_ATTR, H5E_CANTDEC, FAIL, "unable to free VOL object") dt->vol_obj = NULL; - } + } /* end if */ /* Close the datatype */ if(H5T_close(dt) < 0) - HGOTO_ERROR(H5E_DATATYPE, H5E_CLOSEERROR, FAIL, "unable to close datatype"); + HGOTO_ERROR(H5E_DATATYPE, H5E_CLOSEERROR, FAIL, "unable to close datatype") done: FUNC_LEAVE_NOAPI(ret_value) @@ -1730,7 +1729,6 @@ H5Tcopy(hid_t type_id) case H5I_GROUP: case H5I_DATASPACE: case H5I_ATTR: - case H5I_REFERENCE: case H5I_VFL: case H5I_VOL: case H5I_GENPROP_CLS: @@ -1745,7 +1743,7 @@ H5Tcopy(hid_t type_id) /* Copy datatype */ if(NULL == (new_dt = H5T_copy(dt, H5T_COPY_TRANSIENT))) - HGOTO_ERROR(H5E_DATATYPE, H5E_CANTINIT, H5I_INVALID_HID, "unable to copy"); + HGOTO_ERROR(H5E_DATATYPE, H5E_CANTINIT, H5I_INVALID_HID, "unable to copy") /* Atomize result */ if((ret_value = H5I_register(H5I_DATATYPE, new_dt, TRUE)) < 0) @@ -2264,30 +2262,30 @@ done: * the return value is an integer type. * * Return: Success: Data type for base data type. - * * Failure: NULL * * Programmer: Raymond Lu - * October 9, 2002 + * October 9, 2002 + * *------------------------------------------------------------------------- */ H5T_t * H5T_get_super(const H5T_t *dt) { - H5T_t *ret_value=NULL; + H5T_t *ret_value = NULL; FUNC_ENTER_NOAPI(NULL) HDassert(dt); - if (!dt->shared->parent) - HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, NULL, "not a derived data type"); - if (NULL==(ret_value=H5T_copy(dt->shared->parent, H5T_COPY_ALL))) - HGOTO_ERROR(H5E_DATATYPE, H5E_CANTINIT, NULL, "unable to copy parent data type"); + if(!dt->shared->parent) + HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, NULL, "not a derived data type") + if(NULL == (ret_value = H5T_copy(dt->shared->parent, H5T_COPY_ALL))) + HGOTO_ERROR(H5E_DATATYPE, H5E_CANTINIT, NULL, "unable to copy parent data type") done: FUNC_LEAVE_NOAPI(ret_value) -} +} /* end H5T_get_super() */ /*------------------------------------------------------------------------- @@ -3108,7 +3106,7 @@ H5T__create(H5T_class_t type, size_t size) /* Copy the default string datatype */ if(NULL == (dt = H5T_copy(origin_dt, H5T_COPY_TRANSIENT))) - HGOTO_ERROR(H5E_DATATYPE, H5E_CANTINIT, NULL, "unable to copy"); + HGOTO_ERROR(H5E_DATATYPE, H5E_CANTINIT, NULL, "unable to copy") /* Modify the datatype */ if(H5T__set_size(dt, size) < 0) @@ -3230,9 +3228,9 @@ H5T_copy(H5T_t *old_dt, H5T_copy_t method) /* Allocate space */ if(NULL == (new_dt = H5FL_MALLOC(H5T_t))) - HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, NULL, "memory allocation failed"); + HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, NULL, "memory allocation failed") if(NULL == (new_dt->shared = H5FL_MALLOC(H5T_shared_t))) - HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, NULL, "memory allocation failed"); + HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, NULL, "memory allocation failed") /* Copy shared information (entry information is copied last) */ *(new_dt->shared) = *(old_dt->shared); @@ -3273,7 +3271,7 @@ H5T_copy(H5T_t *old_dt, H5T_copy_t method) /* Open named datatype again */ if(H5O_open(&old_dt->oloc) < 0) - HGOTO_ERROR(H5E_DATATYPE, H5E_CANTOPENOBJ, NULL, "unable to reopen named data type"); + HGOTO_ERROR(H5E_DATATYPE, H5E_CANTOPENOBJ, NULL, "unable to reopen named data type") /* Insert opened named datatype into opened object list for the file */ if(H5FO_insert(old_dt->sh_loc.file, old_dt->sh_loc.u.loc.oh_addr, new_dt->shared, FALSE)<0) @@ -3337,7 +3335,7 @@ H5T_copy(H5T_t *old_dt, H5T_copy_t method) new_dt->shared->u.compnd.memb = (H5T_cmemb_t *)H5MM_malloc(new_dt->shared->u.compnd.nalloc * sizeof(H5T_cmemb_t)); if (NULL == new_dt->shared->u.compnd.memb) - HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, NULL, "memory allocation failed"); + HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, NULL, "memory allocation failed") HDmemcpy(new_dt->shared->u.compnd.memb, old_dt->shared->u.compnd.memb, new_dt->shared->u.compnd.nmembs * sizeof(H5T_cmemb_t)); @@ -3355,7 +3353,7 @@ H5T_copy(H5T_t *old_dt, H5T_copy_t method) /* Range check against compound member's offset */ if ((accum_change < 0) && ((ssize_t) new_dt->shared->u.compnd.memb[i].offset < accum_change)) - HGOTO_ERROR(H5E_DATATYPE, H5E_BADVALUE, NULL, "invalid field size in datatype"); + HGOTO_ERROR(H5E_DATATYPE, H5E_BADVALUE, NULL, "invalid field size in datatype") /* Apply the accumulated size change to the offset of the field */ new_dt->shared->u.compnd.memb[i].offset += (size_t) accum_change; @@ -3370,7 +3368,7 @@ H5T_copy(H5T_t *old_dt, H5T_copy_t method) /* check if we couldn't find a match */ if(old_match < 0) - HGOTO_ERROR(H5E_DATATYPE, H5E_CANTCOPY, NULL, "fields in datatype corrupted"); + HGOTO_ERROR(H5E_DATATYPE, H5E_CANTCOPY, NULL, "fields in datatype corrupted") } /* end if */ else old_match = (int) i; @@ -3386,7 +3384,7 @@ H5T_copy(H5T_t *old_dt, H5T_copy_t method) /* Range check against datatype size */ if ((accum_change < 0) && ((ssize_t) new_dt->shared->size < accum_change)) - HGOTO_ERROR(H5E_DATATYPE, H5E_BADVALUE, NULL, "invalid field size in datatype"); + HGOTO_ERROR(H5E_DATATYPE, H5E_BADVALUE, NULL, "invalid field size in datatype") /* Apply the accumulated size change to the size of the compound struct */ new_dt->shared->size += (size_t) accum_change; @@ -3404,7 +3402,7 @@ H5T_copy(H5T_t *old_dt, H5T_copy_t method) new_dt->shared->u.enumer.value = (uint8_t *)H5MM_malloc(new_dt->shared->u.enumer.nalloc * new_dt->shared->size); if(NULL == new_dt->shared->u.enumer.value) - HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, NULL, "memory allocation failed"); + HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, NULL, "memory allocation failed") HDmemcpy(new_dt->shared->u.enumer.value, old_dt->shared->u.enumer.value, new_dt->shared->u.enumer.nmembs * new_dt->shared->size); for(i = 0; i < new_dt->shared->u.enumer.nmembs; i++) { @@ -3418,7 +3416,7 @@ H5T_copy(H5T_t *old_dt, H5T_copy_t method) if(method == H5T_COPY_TRANSIENT || method == H5T_COPY_REOPEN) { /* H5T_copy converts any type into a memory type */ if(H5T_set_loc(new_dt, NULL, H5T_LOC_MEMORY) < 0) - HGOTO_ERROR(H5E_DATATYPE, H5E_CANTINIT, NULL, "invalid datatype location"); + HGOTO_ERROR(H5E_DATATYPE, H5E_CANTINIT, NULL, "invalid datatype location") } /* end if */ break; @@ -3672,7 +3670,7 @@ done: * Purpose: Frees a datatype and all associated memory. * * Note: Does _not_ deal with open named datatypes, etc. so this - * should never see a type managed by a VOL driver. + * should never see a type managed by a VOL connector. * * Return: Non-negative on success/Negative on failure * @@ -3694,7 +3692,7 @@ H5T_close_real(H5T_t *dt) /* Clean up resources, depending on shared state */ if(dt->shared->state != H5T_STATE_OPEN) { if(H5T__free(dt) < 0) - HGOTO_ERROR(H5E_DATATYPE, H5E_CANTFREE, FAIL, "unable to free datatype"); + HGOTO_ERROR(H5E_DATATYPE, H5E_CANTFREE, FAIL, "unable to free datatype") dt->shared = H5FL_FREE(H5T_shared_t, dt->shared); } /* end if */ @@ -3788,7 +3786,7 @@ H5T_close(H5T_t *dt) /* Clean up resources */ if(H5T_close_real(dt) < 0) - HGOTO_ERROR(H5E_DATATYPE, H5E_CANTRELEASE, FAIL, "unable to free datatype"); + HGOTO_ERROR(H5E_DATATYPE, H5E_CANTRELEASE, FAIL, "unable to free datatype") done: FUNC_LEAVE_NOAPI(ret_value) @@ -3837,7 +3835,7 @@ H5T__set_size(H5T_t *dt, size_t size) if(dt->shared->parent) { if(H5T__set_size(dt->shared->parent, size) < 0) - HGOTO_ERROR(H5E_DATATYPE, H5E_CANTINIT, FAIL, "unable to set size for parent data type"); + HGOTO_ERROR(H5E_DATATYPE, H5E_CANTINIT, FAIL, "unable to set size for parent data type") /* Adjust size of datatype appropriately */ if(dt->shared->type==H5T_ARRAY) @@ -3879,7 +3877,7 @@ H5T__set_size(H5T_t *dt, size_t size) size_t max_size; if((num_membs = H5T_get_nmembers(dt)) < 0) - HGOTO_ERROR(H5E_DATATYPE, H5E_CANTINIT, FAIL, "unable to get number of members"); + HGOTO_ERROR(H5E_DATATYPE, H5E_CANTINIT, FAIL, "unable to get number of members") if(num_membs) { for(i = 0; i < (unsigned)num_membs; i++) { @@ -3893,7 +3891,7 @@ H5T__set_size(H5T_t *dt, size_t size) max_size = H5T__get_member_size(dt, max_index); if(size < (max_offset + max_size)) - HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "size shrinking will cut off last member "); + HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "size shrinking will cut off last member ") } /* end if */ /* Compound must not have been packed previously */ @@ -3913,7 +3911,7 @@ H5T__set_size(H5T_t *dt, size_t size) /* Get a copy of unsigned char type as the base/parent type */ if(NULL == (base = (H5T_t *)H5I_object(H5T_NATIVE_UCHAR))) - HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "invalid base datatype"); + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "invalid base datatype") dt->shared->parent=H5T_copy(base,H5T_COPY_ALL); /* change this datatype into a VL string */ @@ -3939,7 +3937,7 @@ H5T__set_size(H5T_t *dt, size_t size) /* Set up VL information */ if (H5T_set_loc(dt, NULL, H5T_LOC_MEMORY)<0) - HGOTO_ERROR(H5E_DATATYPE, H5E_CANTINIT, FAIL, "invalid datatype location"); + HGOTO_ERROR(H5E_DATATYPE, H5E_CANTINIT, FAIL, "invalid datatype location") } /* end if */ else { prec = 8 * size; @@ -3955,7 +3953,7 @@ H5T__set_size(H5T_t *dt, size_t size) if(dt->shared->u.atomic.u.f.sign >= prec+offset || dt->shared->u.atomic.u.f.epos + dt->shared->u.atomic.u.f.esize > prec+offset || dt->shared->u.atomic.u.f.mpos + dt->shared->u.atomic.u.f.msize > prec+offset) { - HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "adjust sign, mantissa, and exponent fields first"); + HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "adjust sign, mantissa, and exponent fields first") } break; @@ -4095,7 +4093,7 @@ H5T_cmp(const H5T_t *dt1, const H5T_t *dt2, hbool_t superset) /* Build an index for each type so the names are sorted */ if(NULL == (idx1 = (unsigned *)H5MM_malloc(dt1->shared->u.compnd.nmembs * sizeof(unsigned))) || NULL == (idx2 = (unsigned *)H5MM_malloc(dt2->shared->u.compnd.nmembs * sizeof(unsigned)))) - HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, 0, "memory allocation failed"); + HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, 0, "memory allocation failed") for(u = 0; u < dt1->shared->u.compnd.nmembs; u++) idx1[u] = idx2[u] = u; if(dt1->shared->u.enumer.nmembs > 1) { @@ -4181,7 +4179,7 @@ H5T_cmp(const H5T_t *dt1, const H5T_t *dt2, hbool_t superset) /* Build an index for each type so the names are sorted */ if(NULL == (idx1 = (unsigned *)H5MM_malloc(dt1->shared->u.enumer.nmembs * sizeof(unsigned))) || NULL == (idx2 = (unsigned *)H5MM_malloc(dt2->shared->u.enumer.nmembs * sizeof(unsigned)))) - HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, 0, "memory allocation failed"); + HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, 0, "memory allocation failed") for(u=0; u<dt1->shared->u.enumer.nmembs; u++) idx1[u] = u; if(dt1->shared->u.enumer.nmembs > 1) { @@ -5070,7 +5068,7 @@ done: *------------------------------------------------------------------------- */ H5G_name_t * -H5T_nameof(H5T_t *dt) +H5T_nameof(const H5T_t *dt) { H5G_name_t *ret_value = NULL; @@ -5190,21 +5188,21 @@ H5T_convert_committed_datatype(H5T_t *dt, H5F_t *f) HGOTO_ERROR(H5E_DATATYPE, H5E_CANTOPENOBJ, FAIL, "unable to reset path") /* If the datatype is committed through the VOL, close it */ - if (NULL != dt->vol_obj) { + if(NULL != dt->vol_obj) { H5VL_object_t *vol_obj = dt->vol_obj; /* Close the datatype through the VOL*/ - if ((ret_value = H5VL_datatype_close(vol_obj->data, vol_obj->driver->cls, H5P_DATASET_XFER_DEFAULT, H5_REQUEST_NULL)) < 0) - HGOTO_ERROR(H5E_DATATYPE, H5E_CLOSEERROR, FAIL, "unable to close datatype"); + if(H5VL_datatype_close(vol_obj, H5P_DATASET_XFER_DEFAULT, H5_REQUEST_NULL) < 0) + HGOTO_ERROR(H5E_DATATYPE, H5E_CLOSEERROR, FAIL, "unable to close datatype") /* Free the datatype and set the VOL object pointer to NULL */ - if (H5VL_free_object(vol_obj) < 0) - HGOTO_ERROR(H5E_ATTR, H5E_CANTDEC, FAIL, "unable to free VOL object"); + if(H5VL_free_object(vol_obj) < 0) + HGOTO_ERROR(H5E_ATTR, H5E_CANTDEC, FAIL, "unable to free VOL object") dt->vol_obj = NULL; - } + } /* end if */ dt->shared->state = H5T_STATE_TRANSIENT; - } + } /* end if */ done: FUNC_LEAVE_NOAPI(ret_value) @@ -5349,7 +5347,7 @@ H5T_set_loc(H5T_t *dt, H5F_t *f, H5T_loc_t loc) /* Mark the VL, compound or array type */ if((changed=H5T_set_loc(dt->shared->parent,f,loc))<0) - HGOTO_ERROR(H5E_DATATYPE, H5E_CANTINIT, FAIL, "Unable to set VL location"); + HGOTO_ERROR(H5E_DATATYPE, H5E_CANTINIT, FAIL, "Unable to set VL location") if(changed>0) ret_value=changed; @@ -5373,7 +5371,7 @@ H5T_set_loc(H5T_t *dt, H5F_t *f, H5T_loc_t loc) /* Range check against compound member's offset */ if ((accum_change < 0) && ((ssize_t) dt->shared->u.compnd.memb[i].offset < accum_change)) - HGOTO_ERROR(H5E_DATATYPE, H5E_BADVALUE, FAIL, "invalid field size in datatype"); + HGOTO_ERROR(H5E_DATATYPE, H5E_BADVALUE, FAIL, "invalid field size in datatype") /* Apply the accumulated size change to the offset of the field */ dt->shared->u.compnd.memb[i].offset += (size_t) accum_change; @@ -5389,7 +5387,7 @@ H5T_set_loc(H5T_t *dt, H5F_t *f, H5T_loc_t loc) /* Mark the VL, compound, enum or array type */ if((changed = H5T_set_loc(memb_type,f,loc)) < 0) - HGOTO_ERROR(H5E_DATATYPE, H5E_CANTINIT, FAIL, "Unable to set VL location"); + HGOTO_ERROR(H5E_DATATYPE, H5E_CANTINIT, FAIL, "Unable to set VL location") if(changed > 0) ret_value = changed; @@ -5398,7 +5396,7 @@ H5T_set_loc(H5T_t *dt, H5F_t *f, H5T_loc_t loc) /* Fail if the old_size is zero */ if (0 == old_size) - HGOTO_ERROR(H5E_DATATYPE, H5E_BADVALUE, FAIL, "old_size of zero would cause division by zero"); + HGOTO_ERROR(H5E_DATATYPE, H5E_BADVALUE, FAIL, "old_size of zero would cause division by zero") /* Adjust the size of the member */ dt->shared->u.compnd.memb[i].size = (dt->shared->u.compnd.memb[i].size*memb_type->shared->size)/old_size; @@ -5411,7 +5409,7 @@ H5T_set_loc(H5T_t *dt, H5F_t *f, H5T_loc_t loc) /* Range check against datatype size */ if ((accum_change < 0) && ((ssize_t) dt->shared->size < accum_change)) - HGOTO_ERROR(H5E_DATATYPE, H5E_BADVALUE, FAIL, "invalid field size in datatype"); + HGOTO_ERROR(H5E_DATATYPE, H5E_BADVALUE, FAIL, "invalid field size in datatype") /* Apply the accumulated size change to the datatype */ dt->shared->size += (size_t) accum_change; @@ -5423,14 +5421,14 @@ H5T_set_loc(H5T_t *dt, H5F_t *f, H5T_loc_t loc) /* (If the force_conv flag is _not_ set, the type cannot change in size, so don't recurse) */ if(dt->shared->parent->shared->force_conv && H5T_IS_COMPLEX(dt->shared->parent->shared->type)) { if((changed = H5T_set_loc(dt->shared->parent,f,loc)) < 0) - HGOTO_ERROR(H5E_DATATYPE, H5E_CANTINIT, FAIL, "Unable to set VL location"); + HGOTO_ERROR(H5E_DATATYPE, H5E_CANTINIT, FAIL, "Unable to set VL location") if(changed > 0) ret_value = changed; } /* end if */ /* Mark this VL sequence */ if((changed = H5T__vlen_set_loc(dt, f, loc)) < 0) - HGOTO_ERROR(H5E_DATATYPE, H5E_CANTINIT, FAIL, "Unable to set VL location"); + HGOTO_ERROR(H5E_DATATYPE, H5E_CANTINIT, FAIL, "Unable to set VL location") if(changed > 0) ret_value = changed; break; diff --git a/src/H5Tcommit.c b/src/H5Tcommit.c index 09a0f3f..712b264 100644 --- a/src/H5Tcommit.c +++ b/src/H5Tcommit.c @@ -150,19 +150,17 @@ H5Tcommit2(hid_t loc_id, const char *name, hid_t type_id, hid_t lcpl_id, HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "invalid object identifier") /* Commit the type */ - if(NULL == (data = H5VL_datatype_commit(vol_obj->data, loc_params, vol_obj->driver->cls, - name, type_id, lcpl_id, tcpl_id, tapl_id, - H5P_DATASET_XFER_DEFAULT, H5_REQUEST_NULL))) + if(NULL == (data = H5VL_datatype_commit(vol_obj, &loc_params, name, type_id, lcpl_id, tcpl_id, tapl_id, H5P_DATASET_XFER_DEFAULT, H5_REQUEST_NULL))) HGOTO_ERROR(H5E_DATATYPE, H5E_CANTINIT, FAIL, "unable to commit datatype") /* Set up VOL object */ if(NULL == (new_obj = H5FL_CALLOC(H5VL_object_t))) - HGOTO_ERROR(H5E_VOL, H5E_NOSPACE, FAIL, "can't allocate top object structure") - new_obj->driver = vol_obj->driver; - new_obj->driver->nrefs ++; + HGOTO_ERROR(H5E_DATATYPE, H5E_CANTALLOC, FAIL, "can't allocate top object structure") + new_obj->connector = vol_obj->connector; + new_obj->connector->nrefs ++; new_obj->data = data; - /* Set the committed type object to the VOL driver pointer in the H5T_t struct */ + /* Set the committed type object to the VOL connector pointer in the H5T_t struct */ dt->vol_obj = new_obj; done: @@ -269,7 +267,7 @@ done: herr_t H5Tcommit_anon(hid_t loc_id, hid_t type_id, hid_t tcpl_id, hid_t tapl_id) { - void *dt = NULL; /* datatype object created by VOL plugin */ + void *dt = NULL; /* datatype object created by VOL connector */ H5VL_object_t *new_obj = NULL; /* VOL object that holds the datatype object and the VOL info */ H5T_t *type = NULL; /* Datatype created */ H5VL_object_t *vol_obj = NULL; /* object token of loc_id */ @@ -305,19 +303,17 @@ H5Tcommit_anon(hid_t loc_id, hid_t type_id, hid_t tcpl_id, hid_t tapl_id) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "invalid file identifier") /* Commit the datatype */ - if(NULL == (dt = H5VL_datatype_commit(vol_obj->data, loc_params, vol_obj->driver->cls, - NULL, type_id, H5P_DEFAULT, tcpl_id, tapl_id, - H5P_DATASET_XFER_DEFAULT, H5_REQUEST_NULL))) + if(NULL == (dt = H5VL_datatype_commit(vol_obj, &loc_params, NULL, type_id, H5P_DEFAULT, tcpl_id, tapl_id, H5P_DATASET_XFER_DEFAULT, H5_REQUEST_NULL))) HGOTO_ERROR(H5E_DATATYPE, H5E_CANTINIT, FAIL, "unable to commit datatype") /* Setup VOL object */ if(NULL == (new_obj = H5FL_CALLOC(H5VL_object_t))) - HGOTO_ERROR(H5E_VOL, H5E_NOSPACE, FAIL, "can't allocate top object structure") - new_obj->driver = vol_obj->driver; - new_obj->driver->nrefs ++; + HGOTO_ERROR(H5E_DATATYPE, H5E_CANTALLOC, FAIL, "can't allocate top object structure") + new_obj->connector = vol_obj->connector; + new_obj->connector->nrefs ++; new_obj->data = dt; - /* Set the committed type object to the VOL pluging pointer in the H5T_t struct */ + /* Set the committed type object to the VOL connector pointer in the H5T_t struct */ type->vol_obj = new_obj; done: @@ -568,7 +564,7 @@ done: hid_t H5Topen2(hid_t loc_id, const char *name, hid_t tapl_id) { - void *dt = NULL; /* datatype token created by VOL driver */ + void *dt = NULL; /* datatype token created by VOL connector */ H5VL_object_t *vol_obj = NULL; /* object token of loc_id */ H5VL_loc_params_t loc_params; hid_t ret_value = H5I_INVALID_HID; /* Return value */ @@ -595,18 +591,17 @@ H5Topen2(hid_t loc_id, const char *name, hid_t tapl_id) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, H5I_INVALID_HID, "invalid file identifier") /* Open the datatype */ - if(NULL == (dt = H5VL_datatype_open(vol_obj->data, loc_params, vol_obj->driver->cls, - name, tapl_id, H5P_DATASET_XFER_DEFAULT, H5_REQUEST_NULL))) + if(NULL == (dt = H5VL_datatype_open(vol_obj, &loc_params, name, tapl_id, H5P_DATASET_XFER_DEFAULT, H5_REQUEST_NULL))) HGOTO_ERROR(H5E_DATATYPE, H5E_CANTOPENOBJ, H5I_INVALID_HID, "unable to open named datatype") /* Register the type and return the ID */ - if((ret_value = H5VL_register(H5I_DATATYPE, dt, vol_obj->driver, TRUE)) < 0) - HGOTO_ERROR(H5E_ATOM, H5E_CANTREGISTER, H5I_INVALID_HID, "unable to register named datatype") + if((ret_value = H5VL_register(H5I_DATATYPE, dt, vol_obj->connector, TRUE)) < 0) + HGOTO_ERROR(H5E_DATATYPE, H5E_CANTREGISTER, H5I_INVALID_HID, "unable to register named datatype") done: /* Cleanup on error */ if(H5I_INVALID_HID == ret_value) - if(dt && H5VL_datatype_close(dt, vol_obj->driver->cls, H5P_DATASET_XFER_DEFAULT, H5_REQUEST_NULL) < 0) + if(dt && H5VL_datatype_close(vol_obj, H5P_DATASET_XFER_DEFAULT, H5_REQUEST_NULL) < 0) HDONE_ERROR(H5E_DATATYPE, H5E_CLOSEERROR, H5I_INVALID_HID, "unable to release datatype") FUNC_LEAVE_API(ret_value) @@ -658,16 +653,15 @@ H5Tget_create_plist(hid_t dtype_id) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, H5I_INVALID_HID, "can't get default creation property list") if((ret_value = H5P_copy_plist(tcpl_plist, TRUE)) < 0) HGOTO_ERROR(H5E_DATATYPE, H5E_CANTGET, H5I_INVALID_HID, "unable to copy the creation property list") - } + } /* end if */ /* If the datatype is committed, retrieve further information */ else { H5VL_object_t *vol_obj = type->vol_obj; /* Get the property list through the VOL */ - if(H5VL_datatype_get(vol_obj->data, vol_obj->driver->cls, H5VL_DATATYPE_GET_TCPL, - H5P_DATASET_XFER_DEFAULT, H5_REQUEST_NULL, &ret_value) < 0) + if(H5VL_datatype_get(vol_obj, H5VL_DATATYPE_GET_TCPL, H5P_DATASET_XFER_DEFAULT, H5_REQUEST_NULL, &ret_value) < 0) HGOTO_ERROR(H5E_DATATYPE, H5E_CANTGET, H5I_INVALID_HID, "can't get object creation info") - } + } /* end else */ done: FUNC_LEAVE_API(ret_value) @@ -707,8 +701,7 @@ H5Tflush(hid_t type_id) /* Flush metadata for named datatype */ if(dt->vol_obj) - if((ret_value = H5VL_datatype_specific(dt->vol_obj->data, dt->vol_obj->driver->cls, H5VL_DATATYPE_FLUSH, - H5P_DATASET_XFER_DEFAULT, H5_REQUEST_NULL, type_id)) < 0) + if(H5VL_datatype_specific(dt->vol_obj, H5VL_DATATYPE_FLUSH, H5P_DATASET_XFER_DEFAULT, H5_REQUEST_NULL, type_id) < 0) HGOTO_ERROR(H5E_DATATYPE, H5E_CANTFLUSH, FAIL, "unable to flush datatype") done: @@ -749,8 +742,7 @@ H5Trefresh(hid_t type_id) /* Refresh the datatype's metadata */ if(dt->vol_obj) - if((ret_value = H5VL_datatype_specific(dt->vol_obj->data, dt->vol_obj->driver->cls, H5VL_DATATYPE_REFRESH, - H5P_DATASET_XFER_DEFAULT, H5_REQUEST_NULL, type_id)) < 0) + if(H5VL_datatype_specific(dt->vol_obj, H5VL_DATATYPE_REFRESH, H5P_DATASET_XFER_DEFAULT, H5_REQUEST_NULL, type_id) < 0) HGOTO_ERROR(H5E_DATATYPE, H5E_CANTLOAD, FAIL, "unable to refresh datatype") done: @@ -1088,7 +1080,7 @@ H5T_update_shared(H5T_t *dt) /*------------------------------------------------------------------------- * Function: H5T_construct_datatype * - * Purpose: Create a Library datatype with a plugin specific datatype object + * Purpose: Create a Library datatype with a connector specific datatype object * * Return: Success: A type structure * Failure: NULL @@ -1100,14 +1092,13 @@ H5T_construct_datatype(H5VL_object_t *vol_obj) { ssize_t nalloc; void *buf = NULL; - H5T_t *dt = NULL; /* datatype token from VOL plugin */ + H5T_t *dt = NULL; /* datatype token from VOL connector */ H5T_t *ret_value = NULL; FUNC_ENTER_NOAPI(NULL) /* get required buf size for encoding the datatype */ - if(H5VL_datatype_get(vol_obj->data, vol_obj->driver->cls, H5VL_DATATYPE_GET_BINARY, - H5P_DATASET_XFER_DEFAULT, H5_REQUEST_NULL, &nalloc, NULL, 0) < 0) + if(H5VL_datatype_get(vol_obj, H5VL_DATATYPE_GET_BINARY, H5P_DATASET_XFER_DEFAULT, H5_REQUEST_NULL, &nalloc, NULL, 0) < 0) HGOTO_ERROR(H5E_DATATYPE, H5E_CANTINIT, NULL, "unable to get datatype serialized size") /* allocate buffer to store binary description of the datatype */ @@ -1115,8 +1106,7 @@ H5T_construct_datatype(H5VL_object_t *vol_obj) HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, NULL, "can't allocate space for datatype") /* get binary description of the datatype */ - if(H5VL_datatype_get(vol_obj->data, vol_obj->driver->cls, H5VL_DATATYPE_GET_BINARY, - H5P_DATASET_XFER_DEFAULT, H5_REQUEST_NULL, &nalloc, buf, (size_t)nalloc) < 0) + if(H5VL_datatype_get(vol_obj, H5VL_DATATYPE_GET_BINARY, H5P_DATASET_XFER_DEFAULT, H5_REQUEST_NULL, &nalloc, buf, (size_t)nalloc) < 0) HGOTO_ERROR(H5E_DATATYPE, H5E_CANTINIT, NULL, "unable to get serialized datatype") if(NULL == (dt = H5T_decode((size_t)nalloc, (const unsigned char *)buf))) @@ -1161,7 +1151,7 @@ H5T_get_named_type(const H5T_t *dt) /*------------------------------------------------------------------------- * Function: H5T_get_actual_type * - * Purpose: Returns underlying native datatype created by native driver + * Purpose: Returns underlying native datatype created by native connector * if datatype is committed, otherwise return the datatype * object associate with the ID. * @@ -1181,7 +1171,7 @@ H5T_get_actual_type(H5T_t *dt) if(NULL == dt->vol_obj) ret_value = dt; else - ret_value = (H5T_t *)dt->vol_obj->data; + ret_value = (H5T_t *)H5VL_object_data(dt->vol_obj); FUNC_LEAVE_NOAPI(ret_value) } /* end H5T_get_actual_type() */ @@ -1268,3 +1258,24 @@ done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5T_restore_refresh_state() */ + +/*------------------------------------------------------------------------- + * Function: H5T_already_vol_managed + * + * Purpose: Check if the committed datatype is already VOL managed + * + * Return: TRUE / FALSE + * + *------------------------------------------------------------------------- + */ +hbool_t +H5T_already_vol_managed(const H5T_t *dt) +{ + FUNC_ENTER_NOAPI_NOINIT_NOERR + + /* Sanity check */ + HDassert(dt); + + FUNC_LEAVE_NOAPI( dt->vol_obj != NULL ) +} /* end H5T_already_vol_managed() */ + diff --git a/src/H5Tdeprec.c b/src/H5Tdeprec.c index 0e45587..6ee0cd7 100644 --- a/src/H5Tdeprec.c +++ b/src/H5Tdeprec.c @@ -43,7 +43,7 @@ #include "H5Iprivate.h" /* IDs */ #include "H5Ppublic.h" /* Property Lists */ #include "H5Tpkg.h" /* Datatypes */ -#include "H5VLprivate.h" /* VOL plugins */ +#include "H5VLprivate.h" /* Virtual Object Layer */ /****************/ @@ -137,20 +137,17 @@ H5Tcommit1(hid_t loc_id, const char *name, hid_t type_id) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "invalid object identifier") /* Commit the datatype */ - if(NULL == (data = H5VL_datatype_commit(vol_obj->data, loc_params, vol_obj->driver->cls, - name, type_id, H5P_LINK_CREATE_DEFAULT, - H5P_DATATYPE_CREATE_DEFAULT, H5P_DATATYPE_ACCESS_DEFAULT, - H5P_DATASET_XFER_DEFAULT, H5_REQUEST_NULL))) + if(NULL == (data = H5VL_datatype_commit(vol_obj, &loc_params, name, type_id, H5P_LINK_CREATE_DEFAULT, H5P_DATATYPE_CREATE_DEFAULT, H5P_DATATYPE_ACCESS_DEFAULT, H5P_DATASET_XFER_DEFAULT, H5_REQUEST_NULL))) HGOTO_ERROR(H5E_DATATYPE, H5E_CANTINIT, FAIL, "unable to commit datatype") /* Set up VOL object */ if(NULL == (new_obj = H5FL_CALLOC(H5VL_object_t))) HGOTO_ERROR(H5E_VOL, H5E_NOSPACE, FAIL, "can't allocate top object structure") - new_obj->driver = vol_obj->driver; - new_obj->driver->nrefs ++; + new_obj->connector = vol_obj->connector; + new_obj->connector->nrefs ++; new_obj->data = data; - /* Set the committed type object to the VOL pluging pointer in the H5T_t struct */ + /* Set the committed type object to the VOL connector pointer in the H5T_t struct */ dt->vol_obj = new_obj; done: @@ -177,7 +174,7 @@ done: hid_t H5Topen1(hid_t loc_id, const char *name) { - void *dt = NULL; /* Datatype token created by VOL plugin */ + void *dt = NULL; /* Datatype token created by VOL connector */ H5VL_object_t *vol_obj = NULL; /* Object token of loc_id */ H5VL_loc_params_t loc_params; hid_t ret_value = H5I_INVALID_HID; /* Return value */ @@ -197,19 +194,17 @@ H5Topen1(hid_t loc_id, const char *name) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, H5I_INVALID_HID, "invalid location identifier") /* Open the datatype */ - if(NULL == (dt = H5VL_datatype_open(vol_obj->data, loc_params, vol_obj->driver->cls, - name, H5P_DATATYPE_ACCESS_DEFAULT, - H5P_DATASET_XFER_DEFAULT, H5_REQUEST_NULL))) + if(NULL == (dt = H5VL_datatype_open(vol_obj, &loc_params, name, H5P_DATATYPE_ACCESS_DEFAULT, H5P_DATASET_XFER_DEFAULT, H5_REQUEST_NULL))) HGOTO_ERROR(H5E_DATATYPE, H5E_CANTOPENOBJ, H5I_INVALID_HID, "unable to open named datatype") /* Register the type and return the ID */ - if((ret_value = H5VL_register(H5I_DATATYPE, dt, vol_obj->driver, TRUE)) < 0) - HGOTO_ERROR(H5E_ATOM, H5E_CANTREGISTER, H5I_INVALID_HID, "unable to register named datatype") + if((ret_value = H5VL_register(H5I_DATATYPE, dt, vol_obj->connector, TRUE)) < 0) + HGOTO_ERROR(H5E_DATATYPE, H5E_CANTREGISTER, H5I_INVALID_HID, "unable to register named datatype") done: /* Cleanup on error */ if(H5I_INVALID_HID == ret_value) - if(dt && H5VL_datatype_close(dt, vol_obj->driver->cls, H5P_DATASET_XFER_DEFAULT, H5_REQUEST_NULL) < 0) + if(dt && H5VL_datatype_close(vol_obj, H5P_DATASET_XFER_DEFAULT, H5_REQUEST_NULL) < 0) HDONE_ERROR(H5E_DATATYPE, H5E_CLOSEERROR, H5I_INVALID_HID, "unable to close datatype") FUNC_LEAVE_API(ret_value) diff --git a/src/H5Tprivate.h b/src/H5Tprivate.h index c0a6d8d..6b6446f 100644 --- a/src/H5Tprivate.h +++ b/src/H5Tprivate.h @@ -119,7 +119,7 @@ H5_DLL herr_t H5T_encode(H5T_t *obj, unsigned char *buf, size_t *nalloc); H5_DLL H5T_t *H5T_decode(size_t buf_size, const unsigned char *buf); H5_DLL herr_t H5T_debug(const H5T_t *dt, FILE * stream); H5_DLL struct H5O_loc_t *H5T_oloc(H5T_t *dt); -H5_DLL H5G_name_t *H5T_nameof(H5T_t *dt); +H5_DLL H5G_name_t *H5T_nameof(const H5T_t *dt); H5_DLL htri_t H5T_is_immutable(const H5T_t *dt); H5_DLL htri_t H5T_is_named(const H5T_t *dt); H5_DLL herr_t H5T_convert_committed_datatype(H5T_t *dt, H5F_t *f); @@ -144,6 +144,7 @@ H5_DLL H5VL_object_t *H5T_get_named_type(const H5T_t *dt); H5_DLL H5T_t *H5T_get_actual_type(H5T_t *dt); H5_DLL herr_t H5T_save_refresh_state(hid_t tid, struct H5O_shared_t *cached_H5O_shared); H5_DLL herr_t H5T_restore_refresh_state(hid_t tid, struct H5O_shared_t *cached_H5O_shared); +H5_DLL hbool_t H5T_already_vol_managed(const H5T_t *dt); /* Reference specific functions */ H5_DLL H5R_type_t H5T_get_ref_type(const H5T_t *dt); diff --git a/src/H5Tvlen.c b/src/H5Tvlen.c index 467847f..841637d 100644 --- a/src/H5Tvlen.c +++ b/src/H5Tvlen.c @@ -531,7 +531,7 @@ H5T_vlen_str_mem_getlen(const void *_vl) #ifdef H5_NO_ALIGNMENT_RESTRICTIONS const char *s=*(const char * const *)_vl; /* Pointer to the user's string information */ #else - const char *s; /* Pointer to the user's string information */ + const char *s = NULL; /* Pointer to the user's string information */ #endif FUNC_ENTER_NOAPI_NOINIT_NOERR @@ -566,7 +566,7 @@ H5T_vlen_str_mem_getptr(void *_vl) #ifdef H5_NO_ALIGNMENT_RESTRICTIONS char *s=*(char **)_vl; /* Pointer to the user's string information */ #else - char *s; /* Pointer to the user's string information */ + char *s = NULL; /* Pointer to the user's string information */ #endif FUNC_ENTER_NOAPI_NOINIT_NOERR @@ -601,7 +601,7 @@ H5T_vlen_str_mem_isnull(const H5F_t H5_ATTR_UNUSED *f, void *_vl) #ifdef H5_NO_ALIGNMENT_RESTRICTIONS char *s=*(char **)_vl; /* Pointer to the user's string information */ #else - char *s; /* Pointer to the user's string information */ + char *s = NULL; /* Pointer to the user's string information */ #endif FUNC_ENTER_NOAPI_NOINIT_NOERR @@ -41,41 +41,54 @@ /* Local Macros */ /****************/ + /******************/ /* Local Typedefs */ /******************/ -/* Information needed for iterating over the registered VOL driver hid_t IDs. - * The name of the new VOL driver that is being registered is stored in the - * name field and the found_id field is initialized to H5I_INVALID_HID (-1). - * If we find a VOL driver with the same name, we set the found_id field to - * the existing ID for return to the function. +/* Information needed for iterating over the registered VOL connector hid_t IDs. + * The name or value of the new VOL connector that is being registered is + * stored in the name (or value) field and the found_id field is initialized to + * H5I_INVALID_HID (-1). If we find a VOL connector with the same name / value, + * we set the found_id field to the existing ID for return to the function. */ typedef struct { - const char *name; /* The name of the VOL driver to check */ - hid_t found_id; /* The library ID if we found a match */ -} H5VL_get_driver_ud_t; + /* IN */ + H5VL_get_connector_kind_t kind; /* Which kind of connector search to make */ + union { + const char *name; /* The name of the VOL connector to check */ + H5VL_class_value_t value; /* The value of the VOL connector to check */ + } u; + + /* OUT */ + hid_t found_id; /* The connector ID, if we found a match */ +} H5VL_get_connector_ud_t; + /********************/ /* Local Prototypes */ /********************/ -static int H5VL__get_driver_cb(void *obj, hid_t id, void *_op_data); +static int H5VL__get_connector_cb(void *obj, hid_t id, void *_op_data); + /*********************/ /* Package Variables */ /*********************/ + /*****************************/ /* Library Private Variables */ /*****************************/ + /*******************/ /* Local Variables */ /*******************/ + /*------------------------------------------------------------------------- - * Function: H5VL__get_driver_cb + * Function: H5VL__get_connector_cb * * Purpose: Callback routine to search through registered VOLs * @@ -87,127 +100,40 @@ static int H5VL__get_driver_cb(void *obj, hid_t id, void *_op_data); *------------------------------------------------------------------------- */ static int -H5VL__get_driver_cb(void *obj, hid_t id, void *_op_data) +H5VL__get_connector_cb(void *obj, hid_t id, void *_op_data) { - H5VL_get_driver_ud_t *op_data = (H5VL_get_driver_ud_t *)_op_data; /* User data for callback */ + H5VL_get_connector_ud_t *op_data = (H5VL_get_connector_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 == HDstrcmp(cls->name, op_data->name)) { - op_data->found_id = id; - ret_value = H5_ITER_STOP; - } + if(H5VL_GET_CONNECTOR_BY_NAME == op_data->kind) { + if(0 == HDstrcmp(cls->name, op_data->u.name)) { + op_data->found_id = id; + ret_value = H5_ITER_STOP; + } /* end if */ + } /* end if */ + else { + HDassert(H5VL_GET_CONNECTOR_BY_VALUE == op_data->kind); + if(cls->value == op_data->u.value) { + op_data->found_id = id; + ret_value = H5_ITER_STOP; + } /* end if */ + } /* end else */ FUNC_LEAVE_NOAPI(ret_value) -} /* end H5VL__get_driver_cb() */ - - -/*------------------------------------------------------------------------- - * Function: H5VLinitialize - * - * Purpose: Calls the driver-specific callback to initialize the driver. - * - * Return: Success: Non-negative - * - * Failure: Negative - * - *------------------------------------------------------------------------- - */ -herr_t -H5VLinitialize(hid_t driver_id, hid_t vipl_id) -{ - H5VL_class_t *cls = NULL; - herr_t ret_value = SUCCEED; /* Return value */ - - FUNC_ENTER_API(FAIL) - H5TRACE2("e", "ii", driver_id, vipl_id); - - /* Check args */ - if (NULL == (cls = (H5VL_class_t *)H5I_object_verify(driver_id, H5I_VOL))) - HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a VOL driver ID") - - if (cls->initialize && cls->initialize(vipl_id) < 0) - HGOTO_ERROR(H5E_VOL, H5E_CANTCLOSEOBJ, FAIL, "VOL driver did not initialize") - -done: - FUNC_LEAVE_API(ret_value) -} /* end H5VLinitialize() */ - - -/*------------------------------------------------------------------------- - * Function: H5VLterminate - * - * Purpose: Calls the driver-specific callback to terminate the driver. - * - * Return: Success: Non-negative - * - * Failure: Negative - * - *------------------------------------------------------------------------- - */ -herr_t -H5VLterminate(hid_t driver_id, hid_t vtpl_id) -{ - H5VL_class_t *cls = NULL; - herr_t ret_value = SUCCEED; /* Return value */ - - FUNC_ENTER_API(FAIL) - H5TRACE2("e", "ii", driver_id, vtpl_id); - - /* Check args */ - if (NULL == (cls = (H5VL_class_t *)H5I_object_verify(driver_id, H5I_VOL))) - HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a VOL driver ID") - - if (cls->terminate && cls->terminate(vtpl_id) < 0) - HGOTO_ERROR(H5E_VOL, H5E_CANTCLOSEOBJ, FAIL, "VOL driver did not terminate cleanly") - -done: - FUNC_LEAVE_API(ret_value) -} /* end H5VLterminate() */ - - -/*------------------------------------------------------------------------- - * Function: H5VLclose - * - * Purpose: Closes the specified VOL driver. The VOL ID will no longer - * be valid for accessing the VOL. - * - * Return: Success: Non-negative - * - * Failure: Negative - * - *------------------------------------------------------------------------- - */ -herr_t -H5VLclose(hid_t vol_id) -{ - herr_t ret_value = SUCCEED; /* Return value */ - - FUNC_ENTER_API(FAIL) - H5TRACE1("e", "i", vol_id); - - /* Check args */ - if(NULL == H5I_object_verify(vol_id, H5I_VOL)) - HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a VOL driver ID") - - if(H5I_dec_app_ref(vol_id) < 0) - HGOTO_ERROR(H5E_VOL, H5E_CANTRELEASE, FAIL, "unable to close VOL driver ID") - -done: - FUNC_LEAVE_API(ret_value) -} /* end H5VLclose() */ +} /* end H5VL__get_connector_cb() */ /*------------------------------------------------------------------------- - * Function: H5VLregister_driver + * Function: H5VLregister_connector * - * Purpose: Registers a new VOL driver as a member of the virtual object + * Purpose: Registers a new VOL connector as a member of the virtual object * layer class. * - * Return: Success: A VOL driver ID which is good until the - * library is closed or the driver is + * Return: Success: A VOL connector ID which is good until the + * library is closed or the connector is * unregistered. * * Failure: H5I_INVALID_HID @@ -215,53 +141,59 @@ done: *------------------------------------------------------------------------- */ hid_t -H5VLregister_driver(const H5VL_class_t *cls) +H5VLregister_connector(const H5VL_class_t *cls, hid_t vipl_id) { - H5VL_get_driver_ud_t op_data; + H5VL_get_connector_ud_t op_data; /* Callback info for connector search */ hid_t ret_value = H5I_INVALID_HID; FUNC_ENTER_API(H5I_INVALID_HID) - H5TRACE1("i", "*x", cls); + H5TRACE2("i", "*xi", cls, vipl_id); /* Check arguments */ if (!cls) - HGOTO_ERROR(H5E_ARGS, H5E_UNINITIALIZED, H5I_INVALID_HID, "VOL driver class pointer cannot be NULL") + HGOTO_ERROR(H5E_ARGS, H5E_UNINITIALIZED, H5I_INVALID_HID, "VOL connector class pointer cannot be NULL") if (!cls->name) - HGOTO_ERROR(H5E_VOL, H5E_CANTREGISTER, H5I_INVALID_HID, "VOL driver class name cannot be the NULL pointer"); - /* XXX: Should probably come up with a max length so we can use strnlen()? */ + HGOTO_ERROR(H5E_VOL, H5E_CANTREGISTER, H5I_INVALID_HID, "VOL connector class name cannot be the NULL pointer") if (0 == HDstrlen(cls->name)) - HGOTO_ERROR(H5E_VOL, H5E_CANTREGISTER, H5I_INVALID_HID, "VOL driver class name cannot be the empty string"); - + HGOTO_ERROR(H5E_VOL, H5E_CANTREGISTER, H5I_INVALID_HID, "VOL connector class name cannot be the empty string") + if (cls->info_copy && !cls->info_free) + HGOTO_ERROR(H5E_VOL, H5E_CANTREGISTER, H5I_INVALID_HID, "VOL connector must provide free callback for VOL info objects when a copy callback is provided") + if (cls->get_wrap_ctx && !cls->free_wrap_ctx) + HGOTO_ERROR(H5E_VOL, H5E_CANTREGISTER, H5I_INVALID_HID, "VOL connector must provide free callback for object wrapping contexts when a get callback is provided") + + op_data.kind = H5VL_GET_CONNECTOR_BY_NAME; + op_data.u.name = cls->name; op_data.found_id = H5I_INVALID_HID; - op_data.name = cls->name; - /* check if driver is already registered */ - if (H5I_iterate(H5I_VOL, H5VL__get_driver_cb, &op_data, TRUE) < 0) + /* check if connector is already registered */ + if (H5I_iterate(H5I_VOL, H5VL__get_connector_cb, &op_data, TRUE) < 0) HGOTO_ERROR(H5E_VOL, H5E_BADITER, H5I_INVALID_HID, "can't iterate over VOL IDs") - /* XXX: Does this need to be an error? Users probably don't care as long - * as their VOL driver is available. - */ - if (op_data.found_id != H5I_INVALID_HID) - HGOTO_ERROR(H5E_VOL, H5E_CANTREGISTER, H5I_INVALID_HID, "VOL driver with the same name is already registered.") - - /* Create the new class ID */ - if ((ret_value = H5VL_register_driver(cls, sizeof(H5VL_class_t), TRUE)) < 0) - HGOTO_ERROR(H5E_ATOM, H5E_CANTREGISTER, H5I_INVALID_HID, "unable to register VOL driver") + /* Increment the ref count on the existing VOL connector ID, if it's already registered */ + if(op_data.found_id != H5I_INVALID_HID) { + if (H5I_inc_ref(op_data.found_id, TRUE) < 0) + HGOTO_ERROR(H5E_VOL, H5E_CANTINC, H5I_INVALID_HID, "unable to increment ref count on VOL connector") + ret_value = op_data.found_id; + } /* end if */ + else { + /* Create a new class ID */ + if ((ret_value = H5VL_register_connector(cls, TRUE, vipl_id)) < 0) + HGOTO_ERROR(H5E_VOL, H5E_CANTREGISTER, H5I_INVALID_HID, "unable to register VOL connector") + } /* end else */ done: FUNC_LEAVE_API(ret_value) -} /* end H5VLregister_driver() */ +} /* end H5VLregister_connector() */ /*------------------------------------------------------------------------- - * Function: H5VLregister_driver_by_name + * Function: H5VLregister_connector_by_name * - * Purpose: Registers a new VOL driver as a member of the virtual object + * Purpose: Registers a new VOL connector as a member of the virtual object * layer class. * - * Return: Success: A VOL driver ID which is good until the - * library is closed or the driver is + * Return: Success: A VOL connector ID which is good until the + * library is closed or the connector is * unregistered. * * Failure: H5I_INVALID_HID @@ -269,90 +201,117 @@ done: *------------------------------------------------------------------------- */ hid_t -H5VLregister_driver_by_name(const char *name) +H5VLregister_connector_by_name(const char *name, hid_t vipl_id) { - H5VL_get_driver_ud_t op_data; - hid_t ret_value = H5I_INVALID_HID; + H5VL_get_connector_ud_t op_data; /* Callback info for connector search */ + hid_t ret_value = H5I_INVALID_HID; FUNC_ENTER_API(H5I_INVALID_HID) - H5TRACE1("i", "*s", name); + H5TRACE2("i", "*si", name, vipl_id); /* Check arguments */ if (!name) - HGOTO_ERROR(H5E_ARGS, H5E_UNINITIALIZED, H5I_INVALID_HID, "null VOL driver name is disallowed") + HGOTO_ERROR(H5E_ARGS, H5E_UNINITIALIZED, H5I_INVALID_HID, "null VOL connector name is disallowed") if (0 == HDstrlen(name)) - HGOTO_ERROR(H5E_ARGS, H5E_UNINITIALIZED, H5I_INVALID_HID, "zero-length VOL driver name is disallowed") + HGOTO_ERROR(H5E_ARGS, H5E_UNINITIALIZED, H5I_INVALID_HID, "zero-length VOL connector name is disallowed") + op_data.kind = H5VL_GET_CONNECTOR_BY_NAME; + op_data.u.name = name; op_data.found_id = H5I_INVALID_HID; - op_data.name = name; - /* Check if driver is already registered */ - if (H5I_iterate(H5I_VOL, H5VL__get_driver_cb, &op_data, TRUE) < 0) + /* Check if connector is already registered */ + if(H5I_iterate(H5I_VOL, H5VL__get_connector_cb, &op_data, TRUE) < 0) HGOTO_ERROR(H5E_VOL, H5E_BADITER, H5I_INVALID_HID, "can't iterate over VOL ids") - if (op_data.found_id != H5I_INVALID_HID) { - /* If driver alread registered, increment ref count on ID and return ID */ - if (H5I_inc_ref(op_data.found_id, TRUE) < 0) - HGOTO_ERROR(H5E_VOL, H5E_CANTINC, H5I_INVALID_HID, "unable to increment ref count on VOL driver") + /* If connector alread registered, increment ref count on ID and return ID */ + if(op_data.found_id != H5I_INVALID_HID) { + if(H5I_inc_ref(op_data.found_id, TRUE) < 0) + HGOTO_ERROR(H5E_VOL, H5E_CANTINC, H5I_INVALID_HID, "unable to increment ref count on VOL connector") ret_value = op_data.found_id; - } + } /* end if */ else { H5PL_key_t key; const H5VL_class_t *cls; - /* Try loading the driver */ - key.name = name; - if (NULL == (cls = (const H5VL_class_t *)H5PL_load(H5PL_TYPE_VOL, key))) - HGOTO_ERROR(H5E_VOL, H5E_CANTINIT, H5I_INVALID_HID, "unable to load VOL driver") + /* Try loading the connector */ + key.vol.kind = H5VL_GET_CONNECTOR_BY_NAME; + key.vol.u.name = name; + if(NULL == (cls = (const H5VL_class_t *)H5PL_load(H5PL_TYPE_VOL, &key))) + HGOTO_ERROR(H5E_VOL, H5E_CANTINIT, H5I_INVALID_HID, "unable to load VOL connector") - /* Register the driver we loaded */ - if ((ret_value = H5VL_register_driver(cls, sizeof(H5VL_class_t), TRUE)) < 0) - HGOTO_ERROR(H5E_ATOM, H5E_CANTREGISTER, H5I_INVALID_HID, "unable to register VOL driver ID") - } + /* Register the connector we loaded */ + if((ret_value = H5VL_register_connector(cls, TRUE, vipl_id)) < 0) + HGOTO_ERROR(H5E_VOL, H5E_CANTREGISTER, H5I_INVALID_HID, "unable to register VOL connector ID") + } /* end else */ done: FUNC_LEAVE_API(ret_value) -} /* end H5VLregister_driver_by_name() */ +} /* end H5VLregister_connector_by_name() */ /*------------------------------------------------------------------------- - * Function: H5VLunregister_driver + * Function: H5VLregister_connector_by_value * - * Purpose: Removes a VOL driver ID from the library. This in no way affects - * file access property lists which have been defined to use - * this VOL driver or files which are already opened under with - * this driver. + * Purpose: Registers a new VOL connector as a member of the virtual object + * layer class. * - * Return: Success: Non-negative + * Return: Success: A VOL connector ID which is good until the + * library is closed or the connector is + * unregistered. * - * Failure: Negative + * Failure: H5I_INVALID_HID * *------------------------------------------------------------------------- */ -herr_t -H5VLunregister_driver(hid_t vol_id) +hid_t +H5VLregister_connector_by_value(H5VL_class_value_t value, hid_t vipl_id) { - H5VL_class_t *cls = NULL; - herr_t ret_value = SUCCEED; /* Return value */ + H5VL_get_connector_ud_t op_data; /* Callback info for connector search */ + hid_t ret_value = H5I_INVALID_HID; - FUNC_ENTER_API(FAIL) - H5TRACE1("e", "i", vol_id); + FUNC_ENTER_API(H5I_INVALID_HID) + H5TRACE2("i", "VCi", value, vipl_id); /* Check arguments */ - if (NULL == (cls = (H5VL_class_t *)H5I_object_verify(vol_id, H5I_VOL))) - HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a vol driver") + if(value < 0) + HGOTO_ERROR(H5E_ARGS, H5E_UNINITIALIZED, H5I_INVALID_HID, "negative VOL connector value is disallowed") - /* The H5VL_class_t struct will be freed by this function */ - if (H5I_dec_app_ref(vol_id) < 0) - HGOTO_ERROR(H5E_VOL, H5E_CANTDEC, FAIL, "unable to unregister vol driver") + op_data.kind = H5VL_GET_CONNECTOR_BY_VALUE; + op_data.u.value = value; + op_data.found_id = H5I_INVALID_HID; + + /* Check if connector is already registered */ + if(H5I_iterate(H5I_VOL, H5VL__get_connector_cb, &op_data, TRUE) < 0) + HGOTO_ERROR(H5E_VOL, H5E_BADITER, H5I_INVALID_HID, "can't iterate over VOL ids") + + /* If connector alread registered, increment ref count on ID and return ID */ + if(op_data.found_id != H5I_INVALID_HID) { + if(H5I_inc_ref(op_data.found_id, TRUE) < 0) + HGOTO_ERROR(H5E_VOL, H5E_CANTINC, H5I_INVALID_HID, "unable to increment ref count on VOL connector") + ret_value = op_data.found_id; + } /* end if */ + else { + H5PL_key_t key; + const H5VL_class_t *cls; + + /* Try loading the connector */ + key.vol.kind = H5VL_GET_CONNECTOR_BY_NAME; + key.vol.u.value = value; + if(NULL == (cls = (const H5VL_class_t *)H5PL_load(H5PL_TYPE_VOL, &key))) + HGOTO_ERROR(H5E_VOL, H5E_CANTINIT, H5I_INVALID_HID, "unable to load VOL connector") + + /* Register the connector we loaded */ + if((ret_value = H5VL_register_connector(cls, TRUE, vipl_id)) < 0) + HGOTO_ERROR(H5E_VOL, H5E_CANTREGISTER, H5I_INVALID_HID, "unable to register VOL connector ID") + } /* end else */ done: FUNC_LEAVE_API(ret_value) -} /* end H5VLunregister_driver() */ +} /* end H5VLregister_connector_by_value() */ /*------------------------------------------------------------------------- - * Function: H5VLis_driver_registered + * Function: H5VLis_connector_registered * * Purpose: Tests whether a VOL class has been registered or not * @@ -365,19 +324,20 @@ done: *------------------------------------------------------------------------- */ htri_t -H5VLis_driver_registered(const char *name) +H5VLis_connector_registered(const char *name) { - H5VL_get_driver_ud_t op_data; - htri_t ret_value = FALSE; /* Return value */ + H5VL_get_connector_ud_t op_data; /* Callback info for connector search */ + htri_t ret_value = FALSE; /* Return value */ FUNC_ENTER_API(FAIL) H5TRACE1("t", "*s", name); + op_data.kind = H5VL_GET_CONNECTOR_BY_NAME; + op_data.u.name = name; op_data.found_id = H5I_INVALID_HID; - op_data.name = name; /* Check arguments */ - if (H5I_iterate(H5I_VOL, H5VL__get_driver_cb, &op_data, TRUE) < 0) + if (H5I_iterate(H5I_VOL, H5VL__get_connector_cb, &op_data, TRUE) < 0) HGOTO_ERROR(H5E_VOL, H5E_BADITER, FAIL, "can't iterate over VOL ids") if (op_data.found_id != H5I_INVALID_HID) @@ -385,13 +345,13 @@ H5VLis_driver_registered(const char *name) done: FUNC_LEAVE_API(ret_value) -} /* end H5VLis_driver_registered() */ +} /* end H5VLis_connector_registered() */ /*------------------------------------------------------------------------- - * Function: H5VLget_driver_id + * Function: H5VLget_connector_id * - * Purpose: Retrieves the ID for a registered VOL driver. + * Purpose: Retrieves the ID for a registered VOL connector. * * Return: Positive if the VOL class has been registered * Negative on error (if the class is not a valid class or not registered) @@ -399,1847 +359,102 @@ done: *------------------------------------------------------------------------- */ hid_t -H5VLget_driver_id(const char *name) +H5VLget_connector_id(const char *name) { - H5VL_get_driver_ud_t op_data; - hid_t ret_value = H5I_INVALID_HID; /* Return value */ + H5VL_get_connector_ud_t op_data; /* Callback info for connector search */ + hid_t ret_value = H5I_INVALID_HID; /* Return value */ FUNC_ENTER_API(H5I_INVALID_HID) H5TRACE1("i", "*s", name); - op_data.found_id = H5I_INVALID_HID; - op_data.name = name; + op_data.kind = H5VL_GET_CONNECTOR_BY_NAME; + op_data.u.name = name; + op_data.found_id = H5I_INVALID_HID; /* Check arguments */ - if (H5I_iterate(H5I_VOL, H5VL__get_driver_cb, &op_data, TRUE) < 0) - HGOTO_ERROR(H5E_VOL, H5E_BADITER, H5I_INVALID_HID, "can't iterate over VOL driver IDs") + if (H5I_iterate(H5I_VOL, H5VL__get_connector_cb, &op_data, TRUE) < 0) + HGOTO_ERROR(H5E_VOL, H5E_BADITER, H5I_INVALID_HID, "can't iterate over VOL connector IDs") if (op_data.found_id != H5I_INVALID_HID) { if (H5I_inc_ref(op_data.found_id, TRUE) < 0) - HGOTO_ERROR(H5E_FILE, H5E_CANTINC, H5I_INVALID_HID, "unable to increment ref count on VOL driver") - + HGOTO_ERROR(H5E_FILE, H5E_CANTINC, H5I_INVALID_HID, "unable to increment ref count on VOL connector") ret_value = op_data.found_id; - } + } /* end if */ done: FUNC_LEAVE_API(ret_value) -} /* end H5VLget_driver_id() */ +} /* end H5VLget_connector_id() */ /*------------------------------------------------------------------------- - * Function: H5VLget_driver_name + * Function: H5VLget_connector_name * - * Purpose: Returns the driver name for the VOL associated with the + * Purpose: Returns the connector name for the VOL associated with the * object or file ID * - * Return: Success: The length of the driver name + * Return: Success: The length of the connector name * * Failure: Negative * *------------------------------------------------------------------------- */ ssize_t -H5VLget_driver_name(hid_t obj_id, char *name/*out*/, size_t size) +H5VLget_connector_name(hid_t obj_id, char *name/*out*/, size_t size) { ssize_t ret_value = -1; FUNC_ENTER_API(FAIL) H5TRACE3("Zs", "ixz", obj_id, name, size); - if ((ret_value = H5VL_get_driver_name(obj_id, name, size)) < 0) - HGOTO_ERROR(H5E_VOL, H5E_CANTGET, FAIL, "Can't get driver name") - -done: - FUNC_LEAVE_API(ret_value) -} /* end H5VLget_driver_name() */ - - -/*--------------------------------------------------------------------------- - * Function: H5VLregister - * - * Purpose: Public routine to register an object and get an ID given a - * VOL driver ID. - * - * Unlike H5Iregister(), this API call can register library - * types (e.g.; H5I_DATASET). - * - * NOTE: This API call is mainly intended for VOL driver authors. - * - * Return: Success: A valid HDF5 ID - * - * Failure: H5I_INVALID_HID - * - *--------------------------------------------------------------------------- - */ -hid_t -H5VLregister(H5I_type_t type, const void *obj, hid_t driver_id) -{ - hid_t ret_value = H5I_INVALID_HID; - - FUNC_ENTER_API(H5I_INVALID_HID) - H5TRACE3("i", "It*xi", type, obj, driver_id); - - if (NULL == obj) - HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, H5I_INVALID_HID, "obj pointer can't be NULL") - - if ((ret_value = H5VL_register_using_vol_id(type, obj, driver_id, TRUE)) < 0) - HGOTO_ERROR(H5E_ATOM, H5E_CANTREGISTER, H5I_INVALID_HID, "unable to register object") - -done: - FUNC_LEAVE_API(ret_value) -} /* H5VLregister */ - - -/*------------------------------------------------------------------------- - * Function: H5VLobject - * - * Purpose: Public utility function to return the VOL object pointer - * associated with an hid_t. - * - * Return: Success: object pointer - * Failure: NULL - * - * Programmer: Jordan Henderson - * January, 2018 - * - *------------------------------------------------------------------------- - */ -void * -H5VLobject(hid_t id) -{ - void *ret_value = NULL; - - FUNC_ENTER_API(NULL) - H5TRACE1("*x", "i", id); - - if (NULL == (ret_value = H5VL_object(id))) - HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, NULL, "invalid identifier") - -done: - FUNC_LEAVE_API(ret_value) -} /* end H5VLobject() */ - - -/*--------------------------------------------------------------------------- - * Function: H5VLget_object - * - * Purpose: Retrieves the object pointer associated with the ID. This - * also optionally returns the H5VL_t struct that this ID - * belongs to, if the user passes a valid pointer value. - * - * Return: Success: Non-negative - * - * Failure: Negative - * - *--------------------------------------------------------------------------- - */ -herr_t -H5VLget_object(hid_t obj_id, void **obj) -{ - herr_t ret_value = SUCCEED; - - FUNC_ENTER_API(FAIL) - H5TRACE2("e", "i**x", obj_id, obj); - - /* Check args */ - if (!obj) - HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "invalid object pointer") - - if (NULL == (*obj = H5VL_vol_object(obj_id))) - HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "ID does not contain a valid object") - -done: - FUNC_LEAVE_API(ret_value) -} /* H5VLget_object */ - - -/*------------------------------------------------------------------------- - * Function: H5VLattr_create - * - * Purpose: Creates an attribute - * - * Return: Success: Pointer to the new attribute - * - * Failure: NULL - * - *------------------------------------------------------------------------- - */ -void * -H5VLattr_create(void *obj, H5VL_loc_params_t loc_params, hid_t driver_id, const char *name, - hid_t acpl_id, hid_t aapl_id, hid_t dxpl_id, void **req) -{ - H5VL_class_t *cls = NULL; - void *ret_value = NULL; /* Return value */ - - FUNC_ENTER_API(NULL) - H5TRACE8("*x", "*xxi*siii**x", obj, loc_params, driver_id, name, acpl_id, - aapl_id, dxpl_id, req); - - if (NULL == obj) - HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, NULL, "invalid object") - if(NULL == (cls = (H5VL_class_t *)H5I_object_verify(driver_id, H5I_VOL))) - HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, NULL, "not a VOL driver ID") - - if(NULL == (ret_value = H5VL_attr_create(obj, loc_params, cls, name, - acpl_id, aapl_id, dxpl_id, req))) - HGOTO_ERROR(H5E_VOL, H5E_CANTINIT, NULL, "unable to create attribute") - -done: - FUNC_LEAVE_API(ret_value) -} /* end H5VLattr_create() */ - - -/*------------------------------------------------------------------------- - * Function: H5VLattr_open - * - * Purpose: Opens an attribute - * - * Return: Success: Pointer to the new attribute - * - * Failure: NULL - * - *------------------------------------------------------------------------- - */ -void * -H5VLattr_open(void *obj, H5VL_loc_params_t loc_params, hid_t driver_id, const char *name, - hid_t aapl_id, hid_t dxpl_id, void **req) -{ - H5VL_class_t *cls = NULL; - void *ret_value = NULL; /* Return value */ - - FUNC_ENTER_API(NULL) - H5TRACE7("*x", "*xxi*sii**x", obj, loc_params, driver_id, name, aapl_id, - dxpl_id, req); - - if (NULL == obj) - HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, NULL, "invalid object") - if(NULL == (cls = (H5VL_class_t *)H5I_object_verify(driver_id, H5I_VOL))) - HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, NULL, "not a VOL driver ID") - - if(NULL == (ret_value = H5VL_attr_open(obj, loc_params, cls, name, aapl_id, - dxpl_id, req))) - HGOTO_ERROR(H5E_VOL, H5E_CANTINIT, NULL, "unable to open attribute") - -done: - FUNC_LEAVE_API(ret_value) -} /* end H5VLattr_open() */ - - -/*------------------------------------------------------------------------- - * Function: H5VLattr_read - * - * Purpose: Reads data from an attribute - * - * Return: Success: Non-negative - * - * Failure: Negative - * - *------------------------------------------------------------------------- - */ -herr_t H5VLattr_read(void *attr, hid_t driver_id, hid_t mem_type_id, void *buf, hid_t dxpl_id, void **req) -{ - H5VL_class_t *cls = NULL; - herr_t ret_value = SUCCEED; - - FUNC_ENTER_API(FAIL) - - if (NULL == attr) - HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "invalid object") - if(NULL == (cls = (H5VL_class_t *)H5I_object_verify(driver_id, H5I_VOL))) - HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a VOL driver ID") - - if((ret_value = H5VL_attr_read(attr, cls, mem_type_id, buf, dxpl_id, req)) < 0) - HGOTO_ERROR(H5E_VOL, H5E_CANTINIT, FAIL, "unable to read attribute") - -done: - FUNC_LEAVE_API(ret_value) -} /* end H5VLattr_read() */ - - -/*------------------------------------------------------------------------- - * Function: H5VLattr_write - * - * Purpose: Writes data to an attribute - * - * Return: Success: Non-negative - * - * Failure: Negative - * - *------------------------------------------------------------------------- - */ -herr_t H5VLattr_write(void *attr, hid_t driver_id, hid_t mem_type_id, const void *buf, hid_t dxpl_id, void **req) -{ - H5VL_class_t *cls = NULL; - herr_t ret_value = SUCCEED; - - FUNC_ENTER_API(FAIL) - - if (NULL == attr) - HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "invalid object") - if(NULL == (cls = (H5VL_class_t *)H5I_object_verify(driver_id, H5I_VOL))) - HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a VOL driver ID") - - if((ret_value = H5VL_attr_write(attr, cls, mem_type_id, buf, dxpl_id, req)) < 0) - HGOTO_ERROR(H5E_VOL, H5E_CANTINIT, FAIL, "unable to write attribute") - -done: - FUNC_LEAVE_API(ret_value) -} /* end H5VLattr_write() */ - - -/*------------------------------------------------------------------------- - * Function: H5VLattr_get - * - * Purpose: Gets information about the attribute - * - * Return: Success: Non-negative - * - * Failure: Negative - * - *------------------------------------------------------------------------- - */ -herr_t -H5VLattr_get(void *obj, hid_t driver_id, H5VL_attr_get_t get_type, - hid_t dxpl_id, void **req, va_list arguments) -{ - H5VL_class_t *cls = NULL; - herr_t ret_value = SUCCEED; - - FUNC_ENTER_API(FAIL) - H5TRACE6("e", "*xiVai**xx", obj, driver_id, get_type, dxpl_id, req, arguments); - - if (NULL == obj) - HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "invalid object") - if(NULL == (cls = (H5VL_class_t *)H5I_object_verify(driver_id, H5I_VOL))) - HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a VOL driver ID") - - /* Bypass the H5VLint layer */ - if(NULL == cls->attr_cls.get) - HGOTO_ERROR(H5E_VOL, H5E_UNSUPPORTED, FAIL, "vol driver has no `attr get' method") - if((ret_value = (cls->attr_cls.get)(obj, get_type, dxpl_id, req, arguments)) < 0) - HGOTO_ERROR(H5E_VOL, H5E_CANTGET, FAIL, "Unable to get attribute information") - -done: - FUNC_LEAVE_API(ret_value) -} /* end H5VLattr_get() */ - - -/*------------------------------------------------------------------------- - * Function: H5VLattr_specific - * - * Purpose: Performs a driver-specific operation on an attribute - * - * Return: Success: Non-negative - * - * Failure: Negative - * - *------------------------------------------------------------------------- - */ -herr_t -H5VLattr_specific(void *obj, H5VL_loc_params_t loc_params, hid_t driver_id, - H5VL_attr_specific_t specific_type, hid_t dxpl_id, void **req, va_list arguments) -{ - H5VL_class_t *cls = NULL; - herr_t ret_value = SUCCEED; - - FUNC_ENTER_API(FAIL) - H5TRACE7("e", "*xxiVbi**xx", obj, loc_params, driver_id, specific_type, - dxpl_id, req, arguments); - - if (NULL == obj) - HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "invalid object") - if(NULL == (cls = (H5VL_class_t *)H5I_object_verify(driver_id, H5I_VOL))) - HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a VOL driver ID") - - /* Bypass the H5VLint layer */ - if(NULL == cls->attr_cls.specific) - HGOTO_ERROR(H5E_VOL, H5E_UNSUPPORTED, FAIL, "vol driver has no `attr specific' method") - if((ret_value = (cls->attr_cls.specific) - (obj, loc_params, specific_type, dxpl_id, req, arguments)) < 0) - HGOTO_ERROR(H5E_VOL, H5E_CANTOPERATE, FAIL, "Unable to execute attribute specific callback") - -done: - FUNC_LEAVE_API(ret_value) -} /* end H5VLattr_specific() */ - - -/*------------------------------------------------------------------------- - * Function: H5VLattr_optional - * - * Purpose: Performs an optional driver-specific operation on an attribute - * - * Return: Success: Non-negative - * - * Failure: Negative - * - *------------------------------------------------------------------------- - */ -herr_t -H5VLattr_optional(void *obj, hid_t driver_id, hid_t dxpl_id, void **req, va_list arguments) -{ - H5VL_class_t *cls = NULL; - herr_t ret_value = SUCCEED; - - FUNC_ENTER_API(FAIL) - H5TRACE5("e", "*xii**xx", obj, driver_id, dxpl_id, req, arguments); - - if (NULL == obj) - HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "invalid object") - if(NULL == (cls = (H5VL_class_t *)H5I_object_verify(driver_id, H5I_VOL))) - HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a VOL driver ID") - - /* Have to bypass the H5VLint layer due to unknown val_list arguments */ - if(NULL == cls->attr_cls.optional) - HGOTO_ERROR(H5E_VOL, H5E_UNSUPPORTED, FAIL, "vol driver has no `attr optional' method") - if((ret_value = (cls->attr_cls.optional)(obj, dxpl_id, req, arguments)) < 0) - HGOTO_ERROR(H5E_VOL, H5E_CANTOPERATE, FAIL, "Unable to execute attribute optional callback") - -done: - FUNC_LEAVE_API(ret_value) -} /* end H5VLattr_optional() */ - - -/*------------------------------------------------------------------------- - * Function: H5VLattr_close - * - * Purpose: Closes an attribute - * - * Return: Success: Non-negative - * - * Failure: Negative - * - *------------------------------------------------------------------------- - */ -herr_t -H5VLattr_close(void *attr, hid_t driver_id, hid_t dxpl_id, void **req) -{ - H5VL_class_t *cls = NULL; - herr_t ret_value = SUCCEED; - - FUNC_ENTER_API(FAIL) - H5TRACE4("e", "*xii**x", attr, driver_id, dxpl_id, req); - - if (NULL == attr) - HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "invalid object") - if(NULL == (cls = (H5VL_class_t *)H5I_object_verify(driver_id, H5I_VOL))) - HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a VOL driver ID") - - if((ret_value = H5VL_attr_close(attr, cls, dxpl_id, req)) < 0) - HGOTO_ERROR(H5E_VOL, H5E_CANTRELEASE, FAIL, "unable to close attribute") - -done: - FUNC_LEAVE_API(ret_value) -} /* end H5VLattr_close() */ - - -/*------------------------------------------------------------------------- - * Function: H5VLdataset_create - * - * Purpose: Creates a dataset - * - * Return: Success: Pointer to the new dataset - * - * Failure: NULL - * - *------------------------------------------------------------------------- - */ -void * -H5VLdataset_create(void *obj, H5VL_loc_params_t loc_params, hid_t driver_id, const char *name, - hid_t dcpl_id, hid_t dapl_id, hid_t dxpl_id, void **req) -{ - H5VL_class_t *cls = NULL; - void *ret_value = NULL; /* Return value */ - - FUNC_ENTER_API(NULL) - H5TRACE8("*x", "*xxi*siii**x", obj, loc_params, driver_id, name, dcpl_id, - dapl_id, dxpl_id, req); - - if (NULL == obj) - HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, NULL, "invalid object") - if(NULL == (cls = (H5VL_class_t *)H5I_object_verify(driver_id, H5I_VOL))) - HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, NULL, "not a VOL driver ID") - - if(NULL == (ret_value = H5VL_dataset_create(obj, loc_params, cls, name, - dcpl_id, dapl_id, dxpl_id, req))) - HGOTO_ERROR(H5E_VOL, H5E_CANTINIT, NULL, "unable to create dataset") - -done: - FUNC_LEAVE_API(ret_value) -} /* end H5VLdataset_create() */ - - -/*------------------------------------------------------------------------- - * Function: H5VLdataset_open - * - * Purpose: Opens a dataset - * - * Return: Success: Pointer to the new dataset - * - * Failure: NULL - * - *------------------------------------------------------------------------- - */ -void * -H5VLdataset_open(void *obj, H5VL_loc_params_t loc_params, hid_t driver_id, const char *name, - hid_t dapl_id, hid_t dxpl_id, void **req) -{ - H5VL_class_t *cls = NULL; - void *ret_value = NULL; - - FUNC_ENTER_API(NULL) - H5TRACE7("*x", "*xxi*sii**x", obj, loc_params, driver_id, name, dapl_id, - dxpl_id, req); - - if (NULL == obj) - HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, NULL, "invalid object") - if(NULL == (cls = (H5VL_class_t *)H5I_object_verify(driver_id, H5I_VOL))) - HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, NULL, "not a VOL driver ID") - - if(NULL == (ret_value = H5VL_dataset_open(obj, loc_params, cls, name, dapl_id, dxpl_id, req))) - HGOTO_ERROR(H5E_VOL, H5E_CANTINIT, NULL, "unable to open dataset") - -done: - FUNC_LEAVE_API(ret_value) -} /* end H5VLdataset_open() */ - - -/*------------------------------------------------------------------------- - * Function: H5VLdataset_read - * - * Purpose: Reads data from a dataset - * - * Return: Success: Non-negative - * - * Failure: Negative - * - *------------------------------------------------------------------------- - */ -herr_t -H5VLdataset_read(void *dset, hid_t driver_id, hid_t mem_type_id, hid_t mem_space_id, - hid_t file_space_id, hid_t plist_id, void *buf, void **req) -{ - H5VL_class_t *cls = NULL; - herr_t ret_value = SUCCEED; - - FUNC_ENTER_API(FAIL) - H5TRACE8("e", "*xiiiii*x**x", dset, driver_id, mem_type_id, mem_space_id, - file_space_id, plist_id, buf, req); - - if (NULL == dset) - HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "invalid object") - if(NULL == (cls = (H5VL_class_t *)H5I_object_verify(driver_id, H5I_VOL))) - HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a VOL driver ID") - - if((ret_value = H5VL_dataset_read(dset, cls, mem_type_id, mem_space_id, file_space_id, - plist_id, buf, req)) < 0) - HGOTO_ERROR(H5E_VOL, H5E_CANTINIT, FAIL, "unable to read dataset") - -done: - FUNC_LEAVE_API(ret_value) -} /* end H5VLdataset_read() */ - - -/*------------------------------------------------------------------------- - * Function: H5VLdataset_write - * - * Purpose: Writes data to a dataset - * - * Return: Success: Non-negative - * - * Failure: Negative - * - *------------------------------------------------------------------------- - */ -herr_t -H5VLdataset_write(void *dset, hid_t driver_id, 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_class_t *cls = NULL; - herr_t ret_value = SUCCEED; - - FUNC_ENTER_API(FAIL) - H5TRACE8("e", "*xiiiii*x**x", dset, driver_id, mem_type_id, mem_space_id, - file_space_id, plist_id, buf, req); - - if (NULL == dset) - HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "invalid object") - if(NULL == (cls = (H5VL_class_t *)H5I_object_verify(driver_id, H5I_VOL))) - HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a VOL driver ID") - - if((ret_value = H5VL_dataset_write(dset, cls, mem_type_id, mem_space_id, file_space_id, - plist_id, buf, req)) < 0) - HGOTO_ERROR(H5E_VOL, H5E_CANTINIT, FAIL, "unable to write dataset") - -done: - FUNC_LEAVE_API(ret_value) -} /* end H5VLdataset_write() */ - - -/*------------------------------------------------------------------------- - * Function: H5VLdataset_get - * - * Purpose: Gets information about a dataset - * - * Return: Success: Non-negative - * - * Failure: Negative - * - *------------------------------------------------------------------------- - */ -herr_t -H5VLdataset_get(void *dset, hid_t driver_id, H5VL_dataset_get_t get_type, - hid_t dxpl_id, void **req, va_list arguments) -{ - H5VL_class_t *cls = NULL; - herr_t ret_value = SUCCEED; - - FUNC_ENTER_API(FAIL) - H5TRACE6("e", "*xiVci**xx", dset, driver_id, get_type, dxpl_id, req, arguments); - - if (NULL == dset) - HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "invalid object") - if(NULL == (cls = (H5VL_class_t *)H5I_object_verify(driver_id, H5I_VOL))) - HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a VOL driver ID") - - /* Bypass the H5VLint layer */ - if(NULL == cls->dataset_cls.get) - HGOTO_ERROR(H5E_VOL, H5E_UNSUPPORTED, FAIL, "vol driver has no `dataset get' method") - if((ret_value = (cls->dataset_cls.get)(dset, get_type, dxpl_id, req, arguments)) < 0) - HGOTO_ERROR(H5E_VOL, H5E_CANTGET, FAIL, "Unable to execute dataset get callback") - -done: - FUNC_LEAVE_API(ret_value) -} /* end H5VLdataset_get() */ - - -/*------------------------------------------------------------------------- - * Function: H5VLdataset_specific - * - * Purpose: Performs a driver-specific operation on a dataset - * - * Return: Success: Non-negative - * - * Failure: Negative - * - *------------------------------------------------------------------------- - */ -herr_t -H5VLdataset_specific(void *obj, hid_t driver_id, H5VL_dataset_specific_t specific_type, - hid_t dxpl_id, void **req, va_list arguments) -{ - H5VL_class_t *cls = NULL; - herr_t ret_value = SUCCEED; - - FUNC_ENTER_API(FAIL) - H5TRACE6("e", "*xiVdi**xx", obj, driver_id, specific_type, dxpl_id, req, - arguments); - - if (NULL == obj) - HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "invalid object") - if(NULL == (cls = (H5VL_class_t *)H5I_object_verify(driver_id, H5I_VOL))) - HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a VOL driver ID") - - if(NULL == cls->dataset_cls.specific) - HGOTO_ERROR(H5E_VOL, H5E_UNSUPPORTED, FAIL, "vol driver has no `dataset specific' method") - if((ret_value = (cls->dataset_cls.specific) - (obj, specific_type, dxpl_id, req, arguments)) < 0) - HGOTO_ERROR(H5E_VOL, H5E_CANTOPERATE, FAIL, "Unable to execute dataset specific callback") - -done: - FUNC_LEAVE_API(ret_value) -} /* end H5VLdataset_specific() */ - - -/*------------------------------------------------------------------------- - * Function: H5VLdataset_optional - * - * Purpose: Performs an optional driver-specific operation on a dataset - * - * Return: Success: Non-negative - * - * Failure: Negative - * - *------------------------------------------------------------------------- - */ -herr_t -H5VLdataset_optional(void *obj, hid_t driver_id, hid_t dxpl_id, void **req, va_list arguments) -{ - H5VL_class_t *cls = NULL; - herr_t ret_value = SUCCEED; - - FUNC_ENTER_API(FAIL) - H5TRACE5("e", "*xii**xx", obj, driver_id, dxpl_id, req, arguments); - - if (NULL == obj) - HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "invalid object") - if(NULL == (cls = (H5VL_class_t *)H5I_object_verify(driver_id, H5I_VOL))) - HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a VOL driver ID") - - if(NULL == cls->dataset_cls.optional) - HGOTO_ERROR(H5E_VOL, H5E_UNSUPPORTED, FAIL, "vol driver has no `dataset optional' method") - if((ret_value = (cls->dataset_cls.optional)(obj, dxpl_id, req, arguments)) < 0) - HGOTO_ERROR(H5E_VOL, H5E_CANTOPERATE, FAIL, "Unable to execute dataset optional callback") - -done: - FUNC_LEAVE_API(ret_value) -} /* end H5VLdataset_optional() */ - - -/*------------------------------------------------------------------------- - * Function: H5VLdataset_close - * - * Purpose: Closes a dataset - * - * Return: Success: Non-negative - * - * Failure: Negative - * - *------------------------------------------------------------------------- - */ -herr_t -H5VLdataset_close(void *dset, hid_t driver_id, hid_t dxpl_id, void **req) -{ - H5VL_class_t *cls = NULL; - herr_t ret_value = SUCCEED; - - FUNC_ENTER_API(FAIL) - H5TRACE4("e", "*xii**x", dset, driver_id, dxpl_id, req); - - if (NULL == dset) - HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "invalid object") - if(NULL == (cls = (H5VL_class_t *)H5I_object_verify(driver_id, H5I_VOL))) - HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a VOL driver ID") - - if((ret_value = H5VL_dataset_close(dset, cls, dxpl_id, req)) < 0) - HGOTO_ERROR(H5E_VOL, H5E_CANTRELEASE, FAIL, "unable to close dataset") - -done: - FUNC_LEAVE_API(ret_value) -} /* end H5VLdataset_close() */ - - -/*------------------------------------------------------------------------- - * Function: H5VLfile_create - * - * Purpose: Creates a file - * - * Return: Success: Pointer to the new file - * - * Failure: NULL - * - *------------------------------------------------------------------------- - */ -void * -H5VLfile_create(const char *name, unsigned flags, hid_t fcpl_id, hid_t fapl_id, - hid_t dxpl_id, void **req) -{ - H5P_genplist_t *plist; /* Property list pointer */ - H5VL_driver_prop_t driver_prop; /* Property for vol driver ID & info */ - H5VL_class_t *cls = NULL; - void *ret_value = NULL; - - FUNC_ENTER_API(NULL) - H5TRACE6("*x", "*sIuiii**x", name, flags, fcpl_id, fapl_id, dxpl_id, req); - - /* get the VOL info from the fapl */ - if(NULL == (plist = (H5P_genplist_t *)H5I_object(fapl_id))) - HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, NULL, "not a file access property list") - if(H5P_peek(plist, H5F_ACS_VOL_DRV_NAME, &driver_prop) < 0) - HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, NULL, "can't get vol driver info") - - if(NULL == (cls = (H5VL_class_t *)H5I_object_verify(driver_prop.driver_id, H5I_VOL))) - HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, NULL, "not a VOL driver ID") - - if(NULL == (ret_value = H5VL_file_create(cls, name, flags, fcpl_id, fapl_id, - dxpl_id, req))) - HGOTO_ERROR(H5E_VOL, H5E_CANTINIT, NULL, "unable to create file") - -done: - FUNC_LEAVE_API(ret_value) -} /* end H5VLfile_create() */ - - -/*------------------------------------------------------------------------- - * Function: H5VLfile_open - * - * Purpose: Opens a file - * - * Return: Success: Pointer to the new file - * - * Failure: NULL - * - *------------------------------------------------------------------------- - */ -void * -H5VLfile_open(const char *name, unsigned flags, hid_t fapl_id, hid_t dxpl_id, void **req) -{ - H5P_genplist_t *plist; /* Property list pointer */ - H5VL_driver_prop_t driver_prop; /* Property for vol driver ID & info */ - H5VL_class_t *cls = NULL; - void *ret_value = NULL; - - FUNC_ENTER_API(NULL) - H5TRACE5("*x", "*sIuii**x", name, flags, fapl_id, dxpl_id, req); - - /* get the VOL info from the fapl */ - if(NULL == (plist = (H5P_genplist_t *)H5I_object(fapl_id))) - HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, NULL, "not a file access property list") - if(H5P_peek(plist, H5F_ACS_VOL_DRV_NAME, &driver_prop) < 0) - HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, NULL, "can't get vol driver info") - - if(NULL == (cls = (H5VL_class_t *)H5I_object_verify(driver_prop.driver_id, H5I_VOL))) - HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, NULL, "not a VOL driver ID") - - if(NULL == (ret_value = H5VL_file_open(cls, name, flags, fapl_id, dxpl_id, req))) - HGOTO_ERROR(H5E_VOL, H5E_CANTINIT, NULL, "unable to create file") - -done: - FUNC_LEAVE_API(ret_value) -} /* end H5VLfile_open() */ - - -/*------------------------------------------------------------------------- - * Function: H5VLfile_get - * - * Purpose: Gets information about the file - * - * Return: Success: Non-negative - * - * Failure: Negative - * - *------------------------------------------------------------------------- - */ -herr_t -H5VLfile_get(void *file, hid_t driver_id, H5VL_file_get_t get_type, - hid_t dxpl_id, void **req, va_list arguments) -{ - H5VL_class_t *cls = NULL; - herr_t ret_value = SUCCEED; - - FUNC_ENTER_API(FAIL) - H5TRACE6("e", "*xiVgi**xx", file, driver_id, get_type, dxpl_id, req, arguments); - - if(NULL == file) - HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "invalid object") - if(NULL == (cls = (H5VL_class_t *)H5I_object_verify(driver_id, H5I_VOL))) - HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a VOL driver ID") - - /* Bypass the H5VLint layer */ - if(NULL == cls->file_cls.get) - HGOTO_ERROR(H5E_VOL, H5E_UNSUPPORTED, FAIL, "vol driver has no `file get' method") - if((ret_value = (cls->file_cls.get)(file, get_type, dxpl_id, req, arguments)) < 0) - HGOTO_ERROR(H5E_VOL, H5E_CANTGET, FAIL, "Unable to execute file get callback") + if ((ret_value = H5VL_get_connector_name(obj_id, name, size)) < 0) + HGOTO_ERROR(H5E_VOL, H5E_CANTGET, FAIL, "Can't get connector name") done: FUNC_LEAVE_API(ret_value) -} /* end H5VLfile_get() */ +} /* end H5VLget_connector_name() */ /*------------------------------------------------------------------------- - * Function: H5VLfile_specific - * - * Purpose: Performs a driver-specific operation on a file - * - * Return: Success: Non-negative - * - * Failure: Negative - * - *------------------------------------------------------------------------- - */ -herr_t -H5VLfile_specific(void *file, hid_t driver_id, H5VL_file_specific_t specific_type, - hid_t dxpl_id, void **req, va_list arguments) -{ - H5VL_class_t *cls = NULL; - herr_t ret_value = SUCCEED; - - FUNC_ENTER_API(FAIL) - H5TRACE6("e", "*xiVhi**xx", file, driver_id, specific_type, dxpl_id, req, - arguments); - - if(specific_type == H5VL_FILE_IS_ACCESSIBLE) { - H5P_genplist_t *plist; /* Property list pointer */ - H5VL_driver_prop_t driver_prop; /* Property for vol driver ID & info */ - hid_t fapl_id; - - fapl_id = va_arg (arguments, hid_t); - - /* get the VOL info from the fapl */ - if(NULL == (plist = (H5P_genplist_t *)H5I_object(fapl_id))) - HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a file access property list") - - if(H5P_peek(plist, H5F_ACS_VOL_DRV_NAME, &driver_prop) < 0) - HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, FAIL, "can't get vol driver info") - - if(NULL == (cls = (H5VL_class_t *)H5I_object_verify(driver_prop.driver_id, H5I_VOL))) - HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a VOL driver ID") - - if((ret_value = (cls->file_cls.specific) - (file, specific_type, dxpl_id, req, arguments)) < 0) - HGOTO_ERROR(H5E_VOL, H5E_CANTGET, FAIL, "specific failed") - } - else { - if(NULL == file) - HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "invalid object") - if(NULL == (cls = (H5VL_class_t *)H5I_object_verify(driver_id, H5I_VOL))) - HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a VOL driver ID") - - if(NULL == cls->file_cls.specific) - HGOTO_ERROR(H5E_VOL, H5E_UNSUPPORTED, FAIL, "vol driver has no `file specific' method") - if((ret_value = (cls->file_cls.specific) - (file, specific_type, dxpl_id, req, arguments)) < 0) - HGOTO_ERROR(H5E_VOL, H5E_CANTOPERATE, FAIL, "Unable to execute file specific callback") - } - -done: - FUNC_LEAVE_API(ret_value) -} /* end H5VLfile_specific() */ - - -/*------------------------------------------------------------------------- - * Function: H5VLfile_optional - * - * Purpose: Performs an optional driver-specific operation on a file - * - * Return: Success: Non-negative - * - * Failure: Negative - * - *------------------------------------------------------------------------- - */ -herr_t -H5VLfile_optional(void *file, hid_t driver_id, hid_t dxpl_id, void **req, va_list arguments) -{ - H5VL_class_t *cls = NULL; - herr_t ret_value = SUCCEED; - - FUNC_ENTER_API(FAIL) - H5TRACE5("e", "*xii**xx", file, driver_id, dxpl_id, req, arguments); - - if(NULL == file) - HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "invalid object") - if(NULL == (cls = (H5VL_class_t *)H5I_object_verify(driver_id, H5I_VOL))) - HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a VOL driver ID") - - if(NULL == cls->file_cls.optional) - HGOTO_ERROR(H5E_VOL, H5E_UNSUPPORTED, FAIL, "vol driver has no `file optional' method") - if((ret_value = (cls->file_cls.optional)(file, dxpl_id, req, arguments)) < 0) - HGOTO_ERROR(H5E_VOL, H5E_CANTOPERATE, FAIL, "Unable to execute file optional callback") - -done: - FUNC_LEAVE_API(ret_value) -} /* end H5VLfile_optional() */ - - -/*------------------------------------------------------------------------- - * Function: H5VLfile_close - * - * Purpose: Closes a file - * - * Return: Success: Non-negative - * - * Failure: Negative - * - *------------------------------------------------------------------------- - */ -herr_t -H5VLfile_close(void *file, hid_t driver_id, hid_t dxpl_id, void **req) -{ - H5VL_class_t *cls = NULL; - herr_t ret_value = SUCCEED; - - FUNC_ENTER_API(FAIL) - H5TRACE4("e", "*xii**x", file, driver_id, dxpl_id, req); - - if(NULL == file) - HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "invalid object") - if(NULL == (cls = (H5VL_class_t *)H5I_object_verify(driver_id, H5I_VOL))) - HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a VOL driver ID") - - if((ret_value = H5VL_file_close(file, cls, dxpl_id, req)) < 0) - HGOTO_ERROR(H5E_VOL, H5E_CANTRELEASE, FAIL, "unable to close file") - -done: - FUNC_LEAVE_API(ret_value) -} /* end H5VLfile_close() */ - - -/*------------------------------------------------------------------------- - * Function: H5VLgroup_create - * - * Purpose: Creates a group - * - * Return: Success: Pointer to the new group - * - * Failure: NULL - * - *------------------------------------------------------------------------- - */ -void * -H5VLgroup_create(void *obj, H5VL_loc_params_t loc_params, hid_t driver_id, const char *name, - hid_t gcpl_id, hid_t gapl_id, hid_t dxpl_id, void **req) -{ - H5VL_class_t *cls = NULL; - void *ret_value = NULL; - - FUNC_ENTER_API(NULL) - H5TRACE8("*x", "*xxi*siii**x", obj, loc_params, driver_id, name, gcpl_id, - gapl_id, dxpl_id, req); - - if (NULL == obj) - HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, NULL, "invalid object") - if(NULL == (cls = (H5VL_class_t *)H5I_object_verify(driver_id, H5I_VOL))) - HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, NULL, "not a VOL driver ID") - - if(NULL == (ret_value = H5VL_group_create(obj, loc_params, cls, name, - gcpl_id, gapl_id, dxpl_id, req))) - HGOTO_ERROR(H5E_VOL, H5E_CANTINIT, NULL, "unable to create group") - -done: - FUNC_LEAVE_API(ret_value) -} /* end H5VLgroup_create() */ - - -/*------------------------------------------------------------------------- - * Function: H5VLgroup_open - * - * Purpose: Opens a group - * - * Return: Success: Pointer to the new group - * - * Failure: NULL - * - *------------------------------------------------------------------------- - */ -void * -H5VLgroup_open(void *obj, H5VL_loc_params_t loc_params, hid_t driver_id, const char *name, - hid_t gapl_id, hid_t dxpl_id, void **req) -{ - H5VL_class_t *cls = NULL; - void *ret_value = NULL; - - FUNC_ENTER_API(NULL) - H5TRACE7("*x", "*xxi*sii**x", obj, loc_params, driver_id, name, gapl_id, - dxpl_id, req); - - if (NULL == obj) - HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, NULL, "invalid object") - if(NULL == (cls = (H5VL_class_t *)H5I_object_verify(driver_id, H5I_VOL))) - HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, NULL, "not a VOL driver ID") - - if(NULL == (ret_value = H5VL_group_open(obj, loc_params, cls, name, - gapl_id, dxpl_id, req))) - HGOTO_ERROR(H5E_VOL, H5E_CANTINIT, NULL, "unable to open group") - -done: - FUNC_LEAVE_API(ret_value) -} /* end H5VLgroup_open() */ - - -/*------------------------------------------------------------------------- - * Function: H5VLgroup_get - * - * Purpose: Gets information about the group - * - * Return: Success: Non-negative - * - * Failure: Negative - * - *------------------------------------------------------------------------- - */ -herr_t -H5VLgroup_get(void *obj, hid_t driver_id, H5VL_group_get_t get_type, - hid_t dxpl_id, void **req, va_list arguments) -{ - H5VL_class_t *cls = NULL; - herr_t ret_value = SUCCEED; - - FUNC_ENTER_API(FAIL) - H5TRACE6("e", "*xiVii**xx", obj, driver_id, get_type, dxpl_id, req, arguments); - - if(NULL == obj) - HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "invalid object") - if(NULL == (cls = (H5VL_class_t *)H5I_object_verify(driver_id, H5I_VOL))) - HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a VOL driver ID") - - /* Bypass the H5VLint layer */ - if(NULL == cls->group_cls.get) - HGOTO_ERROR(H5E_VOL, H5E_UNSUPPORTED, FAIL, "vol driver has no `group get' method") - if((ret_value = (cls->group_cls.get)(obj, get_type, dxpl_id, req, arguments)) < 0) - HGOTO_ERROR(H5E_VOL, H5E_CANTGET, FAIL, "Unable to execute group get callback") - -done: - FUNC_LEAVE_API(ret_value) -} /* end H5VLgroup_get() */ - - -/*------------------------------------------------------------------------- - * Function: H5VLgroup_specific - * - * Purpose: Performs a driver-specific operation on a group - * - * Return: Success: Non-negative - * - * Failure: Negative - * - *------------------------------------------------------------------------- - */ -herr_t -H5VLgroup_specific(void *obj, hid_t driver_id, H5VL_group_specific_t specific_type, - hid_t dxpl_id, void **req, va_list arguments) -{ - H5VL_class_t *cls = NULL; - herr_t ret_value = SUCCEED; - - FUNC_ENTER_API(FAIL) - H5TRACE6("e", "*xiVji**xx", obj, driver_id, specific_type, dxpl_id, req, - arguments); - - if (NULL == obj) - HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "invalid object") - if(NULL == (cls = (H5VL_class_t *)H5I_object_verify(driver_id, H5I_VOL))) - HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a VOL driver ID") - - if(NULL == cls->group_cls.specific) - HGOTO_ERROR(H5E_VOL, H5E_UNSUPPORTED, FAIL, "vol driver has no `group specific' method") - if((ret_value = (cls->group_cls.specific) - (obj, specific_type, dxpl_id, req, arguments)) < 0) - HGOTO_ERROR(H5E_VOL, H5E_CANTOPERATE, FAIL, "Unable to execute group specific callback") - -done: - FUNC_LEAVE_API(ret_value) -} /* end H5VLgroup_specific() */ - - -/*------------------------------------------------------------------------- - * Function: H5VLgroup_optional - * - * Purpose: Performs an optional driver-specific operation on a group - * - * Return: Success: Non-negative - * - * Failure: Negative - * - *------------------------------------------------------------------------- - */ -herr_t -H5VLgroup_optional(void *obj, hid_t driver_id, hid_t dxpl_id, void **req, va_list arguments) -{ - H5VL_class_t *cls = NULL; - herr_t ret_value = SUCCEED; - - FUNC_ENTER_API(FAIL) - H5TRACE5("e", "*xii**xx", obj, driver_id, dxpl_id, req, arguments); - - if (NULL == obj) - HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "invalid object") - if(NULL == (cls = (H5VL_class_t *)H5I_object_verify(driver_id, H5I_VOL))) - HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a VOL driver ID") - - if(NULL == cls->group_cls.optional) - HGOTO_ERROR(H5E_VOL, H5E_UNSUPPORTED, FAIL, "vol driver has no `group optional' method") - if((ret_value = (cls->group_cls.optional)(obj, dxpl_id, req, arguments)) < 0) - HGOTO_ERROR(H5E_VOL, H5E_CANTOPERATE, FAIL, "Unable to execute group optional callback") - -done: - FUNC_LEAVE_API(ret_value) -} /* end H5VLgroup_optional() */ - - -/*------------------------------------------------------------------------- - * Function: H5VLgroup_close - * - * Purpose: Closes a group - * - * Return: Success: Non-negative - * - * Failure: Negative - * - *------------------------------------------------------------------------- - */ -herr_t -H5VLgroup_close(void *grp, hid_t driver_id, hid_t dxpl_id, void **req) -{ - H5VL_class_t *cls = NULL; - herr_t ret_value = SUCCEED; - - FUNC_ENTER_API(FAIL) - H5TRACE4("e", "*xii**x", grp, driver_id, dxpl_id, req); - - if(NULL == grp) - HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "invalid object") - if(NULL == (cls = (H5VL_class_t *)H5I_object_verify(driver_id, H5I_VOL))) - HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a VOL driver ID") - - if((ret_value = H5VL_group_close(grp, cls, dxpl_id, req)) < 0) - HGOTO_ERROR(H5E_VOL, H5E_CANTRELEASE, FAIL, "unable to close group") - -done: - FUNC_LEAVE_API(ret_value) -} /* end H5VLgroup_close() */ - - -/*------------------------------------------------------------------------- - * Function: H5VLlink_create - * - * Purpose: Creates a hard link - * - * Return: Success: Non-negative - * - * Failure: Negative - * - *------------------------------------------------------------------------- - */ -herr_t -H5VLlink_create(H5VL_link_create_type_t create_type, void *obj, H5VL_loc_params_t loc_params, - hid_t driver_id, hid_t lcpl_id, hid_t lapl_id, hid_t dxpl_id, void **req) -{ - H5VL_class_t *cls = NULL; - herr_t ret_value = SUCCEED; - - FUNC_ENTER_API(FAIL) - H5TRACE8("e", "Vk*xxiiii**x", create_type, obj, loc_params, driver_id, lcpl_id, - lapl_id, dxpl_id, req); - - if(NULL == obj) - HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "invalid object") - if(NULL == (cls = (H5VL_class_t *)H5I_object_verify(driver_id, H5I_VOL))) - HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a VOL driver ID") - - if((ret_value = H5VL_link_create(create_type, obj, loc_params, cls, lcpl_id, lapl_id, dxpl_id, req)) < 0) - HGOTO_ERROR(H5E_VOL, H5E_CANTINIT, FAIL, "unable to create link") - -done: - FUNC_LEAVE_API(ret_value) -} /* end H5VLlink_create() */ - - -/*------------------------------------------------------------------------- - * Function: H5VLlink_copy - * - * Purpose: Copies a link to a new location - * - * Return: Success: Non-negative - * - * Failure: Negative - * - *------------------------------------------------------------------------- - */ -herr_t -H5VLlink_copy(void *src_obj, H5VL_loc_params_t loc_params1, void *dst_obj, - H5VL_loc_params_t loc_params2, hid_t driver_id, - hid_t lcpl_id, hid_t lapl_id, hid_t dxpl_id, void **req) -{ - H5VL_class_t *cls = NULL; - herr_t ret_value = SUCCEED; - - FUNC_ENTER_API(FAIL) - H5TRACE9("e", "*xx*xxiiii**x", src_obj, loc_params1, dst_obj, loc_params2, - driver_id, lcpl_id, lapl_id, dxpl_id, req); - - if(NULL == src_obj || NULL == dst_obj) - HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "invalid object") - if(NULL == (cls = (H5VL_class_t *)H5I_object_verify(driver_id, H5I_VOL))) - HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a VOL driver ID") - - if((ret_value = H5VL_link_copy(src_obj, loc_params1, dst_obj, loc_params2, cls, - lcpl_id, lapl_id, dxpl_id, req)) < 0) - HGOTO_ERROR(H5E_VOL, H5E_CANTINIT, FAIL, "unable to copy object") - -done: - FUNC_LEAVE_API(ret_value) -} /* end H5VLlink_copy() */ - - -/*------------------------------------------------------------------------- - * Function: H5VLlink_move - * - * Purpose: Moves a link to another location - * - * Return: Success: Non-negative - * - * Failure: Negative - * - *------------------------------------------------------------------------- - */ -herr_t -H5VLlink_move(void *src_obj, H5VL_loc_params_t loc_params1, void *dst_obj, - H5VL_loc_params_t loc_params2, hid_t driver_id, - hid_t lcpl_id, hid_t lapl_id, hid_t dxpl_id, void **req) -{ - H5VL_class_t *cls = NULL; - herr_t ret_value = SUCCEED; - - FUNC_ENTER_API(FAIL) - H5TRACE9("e", "*xx*xxiiii**x", src_obj, loc_params1, dst_obj, loc_params2, - driver_id, lcpl_id, lapl_id, dxpl_id, req); - - if(NULL == src_obj || NULL == dst_obj) - HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "invalid object") - if(NULL == (cls = (H5VL_class_t *)H5I_object_verify(driver_id, H5I_VOL))) - HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a VOL driver ID") - - if((ret_value = H5VL_link_move(src_obj, loc_params1, dst_obj, loc_params2, cls, - lcpl_id, lapl_id, dxpl_id, req)) < 0) - HGOTO_ERROR(H5E_VOL, H5E_CANTINIT, FAIL, "unable to move object") - -done: - FUNC_LEAVE_API(ret_value) -} /* end H5VLlink_move() */ - - -/*------------------------------------------------------------------------- - * Function: H5VLlink_get - * - * Purpose: Gets information about a link - * - * Return: Success: Non-negative - * - * Failure: Negative - * - *------------------------------------------------------------------------- - */ -herr_t -H5VLlink_get(void *obj, H5VL_loc_params_t loc_params, hid_t driver_id, H5VL_link_get_t get_type, - hid_t dxpl_id, void **req, va_list arguments) -{ - H5VL_class_t *cls = NULL; - herr_t ret_value = SUCCEED; - - FUNC_ENTER_API(FAIL) - H5TRACE7("e", "*xxiVli**xx", obj, loc_params, driver_id, get_type, dxpl_id, req, - arguments); - - if(NULL == obj) - HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "invalid object") - if(NULL == (cls = (H5VL_class_t *)H5I_object_verify(driver_id, H5I_VOL))) - HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a VOL driver ID") - - if(NULL == cls->link_cls.get) - HGOTO_ERROR(H5E_VOL, H5E_UNSUPPORTED, FAIL, "vol driver has no `link get' method") - if((ret_value = (cls->link_cls.get) - (obj, loc_params, get_type, dxpl_id, req, arguments)) < 0) - HGOTO_ERROR(H5E_VOL, H5E_CANTOPERATE, FAIL, "Unable to execute link get callback") - -done: - FUNC_LEAVE_API(ret_value) -} /* end H5VLlink_get() */ - - -/*------------------------------------------------------------------------- - * Function: H5VLlink_specific - * - * Purpose: Performs a driver-specific operation on a link - * - * Return: Success: Non-negative - * - * Failure: Negative - * - *------------------------------------------------------------------------- - */ -herr_t -H5VLlink_specific(void *obj, H5VL_loc_params_t loc_params, hid_t driver_id, - H5VL_link_specific_t specific_type, hid_t dxpl_id, void **req, va_list arguments) -{ - H5VL_class_t *cls = NULL; - herr_t ret_value = SUCCEED; - - FUNC_ENTER_API(FAIL) - H5TRACE7("e", "*xxiVmi**xx", obj, loc_params, driver_id, specific_type, - dxpl_id, req, arguments); - - if (NULL == obj) - HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "invalid object") - if(NULL == (cls = (H5VL_class_t *)H5I_object_verify(driver_id, H5I_VOL))) - HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a VOL driver ID") - - /* Bypass the H5VLint layer */ - if(NULL == cls->link_cls.specific) - HGOTO_ERROR(H5E_VOL, H5E_UNSUPPORTED, FAIL, "vol driver has no `link specific' method") - if((ret_value = (cls->link_cls.specific) - (obj, loc_params, specific_type, dxpl_id, req, arguments)) < 0) - HGOTO_ERROR(H5E_VOL, H5E_CANTOPERATE, FAIL, "Unable to execute link specific callback") - -done: - FUNC_LEAVE_API(ret_value) -} /* end H5VLlink_specific() */ - - -/*------------------------------------------------------------------------- - * Function: H5VLlink_optional - * - * Purpose: Performs an optional driver-specific operation on a link - * - * Return: Success: Non-negative - * - * Failure: Negative - * - *------------------------------------------------------------------------- - */ -herr_t -H5VLlink_optional(void *obj, hid_t driver_id, hid_t dxpl_id, void **req, va_list arguments) -{ - H5VL_class_t *cls = NULL; - herr_t ret_value = SUCCEED; - - FUNC_ENTER_API(FAIL) - H5TRACE5("e", "*xii**xx", obj, driver_id, dxpl_id, req, arguments); - - if (NULL == obj) - HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "invalid object") - if(NULL == (cls = (H5VL_class_t *)H5I_object_verify(driver_id, H5I_VOL))) - HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a VOL driver ID") - - /* Have to bypass the H5VLint layer due to unknown val_list arguments */ - if(NULL == cls->link_cls.optional) - HGOTO_ERROR(H5E_VOL, H5E_UNSUPPORTED, FAIL, "vol driver has no `link optional' method") - if((ret_value = (cls->link_cls.optional)(obj, dxpl_id, req, arguments)) < 0) - HGOTO_ERROR(H5E_VOL, H5E_CANTOPERATE, FAIL, "Unable to execute link optional callback") - -done: - FUNC_LEAVE_API(ret_value) -} /* end H5VLlink_optional() */ - - -/*------------------------------------------------------------------------- - * Function: H5VLobject_open - * - * Purpose: Opens an object - * - * Return: Success: Pointer to the new object - * - * Failure: NULL - * - *------------------------------------------------------------------------- - */ -void * -H5VLobject_open(void *obj, H5VL_loc_params_t params, hid_t driver_id, H5I_type_t *opened_type, - hid_t dxpl_id, void **req) -{ - H5VL_class_t *cls = NULL; - void *ret_value = NULL; - - FUNC_ENTER_API(NULL) - H5TRACE6("*x", "*xxi*Iti**x", obj, params, driver_id, opened_type, dxpl_id, req); - - if (NULL == obj) - HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, NULL, "invalid object") - if(NULL == (cls = (H5VL_class_t *)H5I_object_verify(driver_id, H5I_VOL))) - HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, NULL, "not a VOL driver ID") - - if(NULL == (ret_value = H5VL_object_open(obj, params, cls, opened_type, dxpl_id, req))) - HGOTO_ERROR(H5E_VOL, H5E_CANTINIT, NULL, "unable to create group") - -done: - FUNC_LEAVE_API(ret_value) -} /* end H5VLobject_open() */ - - -/*------------------------------------------------------------------------- - * Function: H5VLobject_copy - * - * Purpose: Copies an object to another location - * - * Return: Success: Non-negative - * - * Failure: Negative - * - *------------------------------------------------------------------------- - */ -herr_t -H5VLobject_copy(void *src_obj, H5VL_loc_params_t loc_params1, hid_t driver_id1, const char *src_name, - void *dst_obj, H5VL_loc_params_t loc_params2, hid_t driver_id2, const char *dst_name, - hid_t ocpypl_id, hid_t lcpl_id, hid_t dxpl_id, void **req) -{ - H5VL_class_t *cls1 = NULL; - H5VL_class_t *cls2 = NULL; - herr_t ret_value = SUCCEED; - - FUNC_ENTER_API(FAIL) - H5TRACE12("e", "*xxi*s*xxi*siii**x", src_obj, loc_params1, driver_id1, - src_name, dst_obj, loc_params2, driver_id2, dst_name, ocpypl_id, - lcpl_id, dxpl_id, req); - - if(NULL == src_obj || NULL == dst_obj) - HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "invalid object") - if(NULL == (cls1 = (H5VL_class_t *)H5I_object_verify(driver_id1, H5I_VOL))) - HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a VOL driver ID") - if(NULL == (cls2 = (H5VL_class_t *)H5I_object_verify(driver_id2, H5I_VOL))) - HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a VOL driver ID") - - if((ret_value = H5VL_object_copy(src_obj, loc_params1, cls1, src_name, - dst_obj, loc_params2, cls2, dst_name, - ocpypl_id, lcpl_id, dxpl_id, req)) < 0) - HGOTO_ERROR(H5E_VOL, H5E_CANTINIT, FAIL, "unable to move object") - -done: - FUNC_LEAVE_API(ret_value) -} /* end H5VLobject_copy() */ - - -/*------------------------------------------------------------------------- - * Function: H5VLobject_get - * - * Purpose: Gets information about an object - * - * Return: Success: Non-negative - * - * Failure: Negative - * - *------------------------------------------------------------------------- - */ -herr_t -H5VLobject_get(void *obj, H5VL_loc_params_t loc_params, hid_t driver_id, H5VL_object_get_t get_type, - hid_t dxpl_id, void **req, va_list arguments) -{ - H5VL_class_t *cls = NULL; - herr_t ret_value = SUCCEED; - - FUNC_ENTER_API(FAIL) - H5TRACE7("e", "*xxiVni**xx", obj, loc_params, driver_id, get_type, dxpl_id, req, - arguments); - - if(NULL == obj) - HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "invalid object") - if(NULL == (cls = (H5VL_class_t *)H5I_object_verify(driver_id, H5I_VOL))) - HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a VOL driver ID") - - if(NULL == cls->object_cls.get) - HGOTO_ERROR(H5E_VOL, H5E_UNSUPPORTED, FAIL, "vol driver has no `object get' method") - if((ret_value = (cls->object_cls.get) - (obj, loc_params, get_type, dxpl_id, req, arguments)) < 0) - HGOTO_ERROR(H5E_VOL, H5E_CANTOPERATE, FAIL, "Unable to execute object get callback") - -done: - FUNC_LEAVE_API(ret_value) -} /* end H5VLobject_get() */ - - -/*------------------------------------------------------------------------- - * Function: H5VLobject_specific - * - * Purpose: Performs a driver-specific operation on an object - * - * Return: Success: Non-negative - * - * Failure: Negative - * - *------------------------------------------------------------------------- - */ -herr_t -H5VLobject_specific(void *obj, H5VL_loc_params_t loc_params, hid_t driver_id, - H5VL_object_specific_t specific_type, hid_t dxpl_id, void **req, va_list arguments) -{ - H5VL_class_t *cls = NULL; - herr_t ret_value = SUCCEED; - - FUNC_ENTER_API(FAIL) - H5TRACE7("e", "*xxiVoi**xx", obj, loc_params, driver_id, specific_type, - dxpl_id, req, arguments); - - if(NULL == obj) - HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "invalid object") - if(NULL == (cls = (H5VL_class_t *)H5I_object_verify(driver_id, H5I_VOL))) - HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a VOL driver ID") - - /* Bypass the H5VLint layer */ - if(NULL == cls->object_cls.specific) - HGOTO_ERROR(H5E_VOL, H5E_UNSUPPORTED, FAIL, "vol driver has no `object specific' method") - if((ret_value = (cls->object_cls.specific) - (obj, loc_params, specific_type, dxpl_id, req, arguments)) < 0) - HGOTO_ERROR(H5E_VOL, H5E_CANTOPERATE, FAIL, "Unable to execute object specific callback") - -done: - FUNC_LEAVE_API(ret_value) -} /* end H5VLobject_specific() */ - - -/*------------------------------------------------------------------------- - * Function: H5VLobject_optional - * - * Purpose: Performs an optional driver-specific operation on an object - * - * Return: Success: Non-negative - * - * Failure: Negative - * - *------------------------------------------------------------------------- - */ -herr_t -H5VLobject_optional(void *obj, hid_t driver_id, hid_t dxpl_id, void **req, va_list arguments) -{ - H5VL_class_t *cls = NULL; - herr_t ret_value = SUCCEED; - - FUNC_ENTER_API(FAIL) - H5TRACE5("e", "*xii**xx", obj, driver_id, dxpl_id, req, arguments); - - if (NULL == obj) - HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "invalid object") - if(NULL == (cls = (H5VL_class_t *)H5I_object_verify(driver_id, H5I_VOL))) - HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a VOL driver ID") - - /* Have to bypass the H5VLint layer due to unknown val_list arguments */ - if(NULL == cls->object_cls.optional) - HGOTO_ERROR(H5E_VOL, H5E_UNSUPPORTED, FAIL, "vol driver has no `object optional' method") - if((ret_value = (cls->object_cls.optional)(obj, dxpl_id, req, arguments)) < 0) - HGOTO_ERROR(H5E_VOL, H5E_CANTOPERATE, FAIL, "Unable to execute object optional callback") - -done: - FUNC_LEAVE_API(ret_value) -} /* end H5VLobject_optional() */ - - -/*------------------------------------------------------------------------- - * Function: H5VLdatatype_commit - * - * Purpose: Commits a datatype to the file - * - * Return: Success: Pointer to the new datatype - * - * Failure: NULL - * - *------------------------------------------------------------------------- - */ -void * -H5VLdatatype_commit(void *obj, H5VL_loc_params_t loc_params, hid_t driver_id, 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_class_t *cls = NULL; - void *ret_value = NULL; - - FUNC_ENTER_API(NULL) - H5TRACE10("*x", "*xxi*siiiii**x", obj, loc_params, driver_id, name, type_id, - lcpl_id, tcpl_id, tapl_id, dxpl_id, req); - - if (NULL == obj) - HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, NULL, "invalid object") - if(NULL == (cls = (H5VL_class_t *)H5I_object_verify(driver_id, H5I_VOL))) - HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, NULL, "not a VOL driver ID") - - if(NULL == (ret_value = H5VL_datatype_commit(obj, loc_params, cls, name, type_id, - lcpl_id, tcpl_id, tapl_id, dxpl_id, req))) - HGOTO_ERROR(H5E_VOL, H5E_CANTINIT, NULL, "unable to commit datatype") - -done: - FUNC_LEAVE_API(ret_value) -} /* end H5VLdatatype_commit() */ - - -/*------------------------------------------------------------------------- - * Function: H5VLdatatype_open - * - * Purpose: Opens a named datatype - * - * Return: Success: Pointer to the new datatype - * - * Failure: NULL - * - *------------------------------------------------------------------------- - */ -void * -H5VLdatatype_open(void *obj, H5VL_loc_params_t loc_params, hid_t driver_id, const char *name, - hid_t tapl_id, hid_t dxpl_id, void **req) -{ - H5VL_class_t *cls = NULL; - void *ret_value = NULL; - - FUNC_ENTER_API(NULL) - H5TRACE7("*x", "*xxi*sii**x", obj, loc_params, driver_id, name, tapl_id, - dxpl_id, req); - - if (NULL == obj) - HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, NULL, "invalid object") - if(NULL == (cls = (H5VL_class_t *)H5I_object_verify(driver_id, H5I_VOL))) - HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, NULL, "not a VOL driver ID") - - if(NULL == (ret_value = H5VL_datatype_open(obj, loc_params, cls, name, - tapl_id, dxpl_id, req))) - HGOTO_ERROR(H5E_VOL, H5E_CANTINIT, NULL, "unable to open datatype") - -done: - FUNC_LEAVE_API(ret_value) -} /* end H5VLdatatype_open() */ - - -/*------------------------------------------------------------------------- - * Function: H5VLdatatype_specific - * - * Purpose: Performs a driver-specific operation on a datatype - * - * Return: Success: Non-negative - * - * Failure: Negative - * - *------------------------------------------------------------------------- - */ -herr_t -H5VLdatatype_specific(void *obj, hid_t driver_id, H5VL_datatype_specific_t specific_type, - hid_t dxpl_id, void **req, va_list arguments) -{ - H5VL_class_t *cls = NULL; - herr_t ret_value = SUCCEED; - - FUNC_ENTER_API(FAIL) - H5TRACE6("e", "*xiVfi**xx", obj, driver_id, specific_type, dxpl_id, req, - arguments); - - if (NULL == obj) - HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "invalid object") - if(NULL == (cls = (H5VL_class_t *)H5I_object_verify(driver_id, H5I_VOL))) - HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a VOL driver ID") - - if(NULL == cls->datatype_cls.specific) - HGOTO_ERROR(H5E_VOL, H5E_UNSUPPORTED, FAIL, "vol driver has no `datatype specific' method") - if((ret_value = (cls->datatype_cls.specific) - (obj, specific_type, dxpl_id, req, arguments)) < 0) - HGOTO_ERROR(H5E_VOL, H5E_CANTOPERATE, FAIL, "Unable to execute datatype specific callback") - -done: - FUNC_LEAVE_API(ret_value) -} /* end H5VLdatatype_specific() */ - - -/*------------------------------------------------------------------------- - * Function: H5VLdatatype_optional - * - * Purpose: Performs an optional driver-specific operation on a datatype - * - * Return: Success: Non-negative - * - * Failure: Negative - * - *------------------------------------------------------------------------- - */ -herr_t -H5VLdatatype_optional(void *obj, hid_t driver_id, hid_t dxpl_id, void **req, va_list arguments) -{ - H5VL_class_t *cls = NULL; - herr_t ret_value = SUCCEED; - - FUNC_ENTER_API(FAIL) - H5TRACE5("e", "*xii**xx", obj, driver_id, dxpl_id, req, arguments); - - if (NULL == obj) - HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "invalid object") - if(NULL == (cls = (H5VL_class_t *)H5I_object_verify(driver_id, H5I_VOL))) - HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a VOL driver ID") - - if(NULL == cls->datatype_cls.optional) - HGOTO_ERROR(H5E_VOL, H5E_UNSUPPORTED, FAIL, "vol driver has no `datatype optional' method") - if((ret_value = (cls->datatype_cls.optional)(obj, dxpl_id, req, arguments)) < 0) - HGOTO_ERROR(H5E_VOL, H5E_CANTOPERATE, FAIL, "Unable to execute datatype optional callback") - -done: - FUNC_LEAVE_API(ret_value) -} /* end H5VLdatatype_optional() */ - - -/*------------------------------------------------------------------------- - * Function: H5VLdatatype_get - * - * Purpose: Gets information about the datatype - * - * Return: Success: Non-negative - * - * Failure: Negative - * - *------------------------------------------------------------------------- - */ -herr_t -H5VLdatatype_get(void *obj, hid_t driver_id, H5VL_datatype_get_t get_type, - hid_t dxpl_id, void **req, va_list arguments) -{ - H5VL_class_t *cls = NULL; - herr_t ret_value = SUCCEED; - - FUNC_ENTER_API(FAIL) - H5TRACE6("e", "*xiVei**xx", obj, driver_id, get_type, dxpl_id, req, arguments); - - if(NULL == obj) - HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "invalid object") - if(NULL == (cls = (H5VL_class_t *)H5I_object_verify(driver_id, H5I_VOL))) - HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a VOL driver ID") - - /* Bypass the H5VLint layer */ - if(NULL == cls->datatype_cls.get) - HGOTO_ERROR(H5E_VOL, H5E_UNSUPPORTED, FAIL, "vol driver has no `datatype get' method") - if((ret_value = (cls->datatype_cls.get)(obj, get_type, dxpl_id, req, arguments)) < 0) - HGOTO_ERROR(H5E_VOL, H5E_CANTGET, FAIL, "Unable to execute datatype get callback") - -done: - FUNC_LEAVE_API(ret_value) -} /* end H5VLdatatype_get() */ - - -/*------------------------------------------------------------------------- - * Function: H5VLdatatype_close - * - * Purpose: Closes a datatype - * - * Return: Success: Non-negative - * - * Failure: Negative - * - *------------------------------------------------------------------------- - */ -herr_t -H5VLdatatype_close(void *dt, hid_t driver_id, hid_t dxpl_id, void **req) -{ - H5VL_class_t *cls = NULL; - herr_t ret_value = SUCCEED; - - FUNC_ENTER_API(FAIL) - H5TRACE4("e", "*xii**x", dt, driver_id, dxpl_id, req); - - if (NULL == dt) - HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "invalid object") - if(NULL == (cls = (H5VL_class_t *)H5I_object_verify(driver_id, H5I_VOL))) - HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a VOL driver ID") - - if((ret_value = H5VL_datatype_close(dt, cls, dxpl_id, req)) < 0) - HGOTO_ERROR(H5E_VOL, H5E_CANTRELEASE, FAIL, "unable to close datatype") - -done: - FUNC_LEAVE_API(ret_value) -} /* end H5VLdatatype_close() */ - - -/*------------------------------------------------------------------------- - * Function: H5VLrequest_cancel + * Function: H5VLclose * - * Purpose: Cancels a request + * Purpose: Closes a VOL connector ID. This in no way affects + * file access property lists which have been defined to use + * this VOL connector or files which are already opened under with + * this connector. * * Return: Success: Non-negative - * * Failure: Negative * *------------------------------------------------------------------------- */ herr_t -H5VLrequest_cancel(void **req, hid_t driver_id, H5ES_status_t *status) +H5VLclose(hid_t vol_id) { - H5VL_class_t *cls = NULL; - herr_t ret_value = SUCCEED; + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_API(FAIL) - H5TRACE3("e", "**xi*Es", req, driver_id, status); + H5TRACE1("e", "i", vol_id); - if (NULL == (cls = (H5VL_class_t *)H5I_object_verify(driver_id, H5I_VOL))) - HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a VOL driver ID") + /* Check args */ + if(NULL == H5I_object_verify(vol_id, H5I_VOL)) + HGOTO_ERROR(H5E_VOL, H5E_BADTYPE, FAIL, "not a VOL connector") - if ((ret_value = H5VL_request_cancel(req, cls, status)) < 0) - HGOTO_ERROR(H5E_VOL, H5E_CANTRELEASE, FAIL, "unable to cancel request") + /* Decrement the ref count on the ID, possibly releasing the VOL connector */ + if(H5I_dec_app_ref(vol_id) < 0) + HGOTO_ERROR(H5E_VOL, H5E_CANTDEC, FAIL, "unable to close VOL connector ID") done: FUNC_LEAVE_API(ret_value) -} /* end H5VLrequest_cancel() */ +} /* end H5VLclose() */ /*------------------------------------------------------------------------- - * Function: H5VLrequest_test + * Function: H5VLunregister_connector * - * Purpose: Tests a request + * Purpose: Removes a VOL connector ID from the library. This in no way affects + * file access property lists which have been defined to use + * this VOL connector or files which are already opened under with + * this connector. * * Return: Success: Non-negative * @@ -2248,54 +463,60 @@ done: *------------------------------------------------------------------------- */ herr_t -H5VLrequest_test(void **req, hid_t driver_id, H5ES_status_t *status) +H5VLunregister_connector(hid_t vol_id) { - H5VL_class_t *cls = NULL; - herr_t ret_value = SUCCEED; + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_API(FAIL) - H5TRACE3("e", "**xi*Es", req, driver_id, status); + H5TRACE1("e", "i", vol_id); - if (NULL == (cls = (H5VL_class_t *)H5I_object_verify(driver_id, H5I_VOL))) - HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a VOL driver ID") + /* Check arguments */ + if(NULL == H5I_object_verify(vol_id, H5I_VOL)) + HGOTO_ERROR(H5E_VOL, H5E_BADTYPE, FAIL, "not a VOL connector") - if ((ret_value = H5VL_request_test(req, cls, status)) < 0) - HGOTO_ERROR(H5E_VOL, H5E_CANTRELEASE, FAIL, "unable to test request") + /* The H5VL_class_t struct will be freed by this function */ + if (H5I_dec_app_ref(vol_id) < 0) + HGOTO_ERROR(H5E_VOL, H5E_CANTDEC, FAIL, "unable to unregister VOL connector") done: FUNC_LEAVE_API(ret_value) -} /* end H5VLrequest_test() */ +} /* end H5VLunregister_connector() */ -/*------------------------------------------------------------------------- - * Function: H5VLrequest_wait +/*--------------------------------------------------------------------------- + * Function: H5VLcmp_connector_cls * - * Purpose: Waits on a request + * Purpose: Compares two connector classes * - * Return: Success: Non-negative + * Return: Success: Non-negative, with *cmp set to positive if + * connector_id1 is greater than connector_id2, negative if connector_id2 + * is greater than connector_id1 and zero if connector_id1 and connector_id2 + * are equal. * * Failure: Negative * - *------------------------------------------------------------------------- + *--------------------------------------------------------------------------- */ herr_t -H5VLrequest_wait(void **req, hid_t driver_id, H5ES_status_t *status) +H5VLcmp_connector_cls(int *cmp, hid_t connector_id1, hid_t connector_id2) { - H5VL_class_t *cls = NULL; - herr_t ret_value = SUCCEED; + H5VL_class_t *cls1, *cls2; /* connectors for IDs */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_API(FAIL) - H5TRACE3("e", "**xi*Es", req, driver_id, status); + H5TRACE3("e", "*Isii", cmp, connector_id1, connector_id2); - if (NULL == (cls = (H5VL_class_t *)H5I_object_verify(driver_id, H5I_VOL))) - HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a VOL driver ID") - - if ((ret_value = H5VL_request_wait(req, cls, status)) < 0) - HGOTO_ERROR(H5E_VOL, H5E_CANTRELEASE, FAIL, "unable to wait on request") + /* Check args and get class pointers */ + if(NULL == (cls1 = (H5VL_class_t *)H5I_object_verify(connector_id1, H5I_VOL))) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a VOL connector ID") + if(NULL == (cls2 = (H5VL_class_t *)H5I_object_verify(connector_id2, H5I_VOL))) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a VOL connector ID") + /* Compare the two VOL connector classes */ + if(H5VL_cmp_connector_cls(cmp, cls1, cls2) < 0) + HGOTO_ERROR(H5E_VOL, H5E_CANTCOMPARE, FAIL, "can't compare connector classes") done: FUNC_LEAVE_API(ret_value) -} /* end H5VLrequest_wait() */ - +} /* H5VLcmp_connector_cls() */ diff --git a/src/H5VLcallback.c b/src/H5VLcallback.c new file mode 100644 index 0000000..811162d --- /dev/null +++ b/src/H5VLcallback.c @@ -0,0 +1,6489 @@ +/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * + * 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 COPYING file, which can be found at the root of the source code * + * distribution tree, or in https://support.hdfgroup.org/ftp/HDF5/releases. * + * If you do not have access to either file, you may request a copy from * + * help@hdfgroup.org. * + * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ + +/* + * Purpose: The Virtual Object Layer as described in documentation. + * The pupose is to provide an abstraction on how to access the + * underlying HDF5 container, whether in a local file with + * a specific file format, or remotely on other machines, etc... + */ + + +/****************/ +/* Module Setup */ +/****************/ + +#include "H5VLmodule.h" /* This source code file is part of the H5VL module */ + + +/***********/ +/* Headers */ +/***********/ + +#include "H5private.h" /* Generic Functions */ +#include "H5Eprivate.h" /* Error handling */ +#include "H5Fprivate.h" /* File access */ +#include "H5Iprivate.h" /* IDs */ +#include "H5MMprivate.h" /* Memory management */ +#include "H5Pprivate.h" /* Property lists */ +#include "H5VLpkg.h" /* Virtual Object Layer */ + + +/****************/ +/* Local Macros */ +/****************/ + + +/******************/ +/* Local Typedefs */ +/******************/ + + +/********************/ +/* Package Typedefs */ +/********************/ + + +/********************/ +/* Local Prototypes */ +/********************/ +static void *H5VL__attr_create(void *obj, const H5VL_loc_params_t *loc_params, + const H5VL_class_t *cls, const char *name, hid_t acpl_id, hid_t aapl_id, + hid_t dxpl_id, void **req); +static void *H5VL__attr_open(void *obj, const H5VL_loc_params_t *loc_params, + const H5VL_class_t *cls, const char *name, hid_t aapl_id, hid_t dxpl_id, + void **req); +static herr_t H5VL__attr_read(void *obj, const H5VL_class_t *cls, hid_t mem_type_id, + void *buf, hid_t dxpl_id, void **req); +static herr_t H5VL__attr_write(void *obj, const H5VL_class_t *cls, hid_t mem_type_id, + const void *buf, hid_t dxpl_id, void **req); +static herr_t H5VL__attr_get(void *obj, const H5VL_class_t *cls, H5VL_attr_get_t get_type, + hid_t dxpl_id, void **req, va_list arguments); +static herr_t H5VL__attr_specific(void *obj, const H5VL_loc_params_t *loc_params, + const H5VL_class_t *cls, H5VL_attr_specific_t specific_type, hid_t dxpl_id, + void **req, va_list arguments); +static herr_t H5VL__attr_optional(void *obj, const H5VL_class_t *cls, hid_t dxpl_id, + void **req, va_list arguments); +static herr_t H5VL__attr_close(void *obj, const H5VL_class_t *cls, hid_t dxpl_id, + void **req); +static void *H5VL__dataset_create(void *obj, const H5VL_loc_params_t *loc_params, + const H5VL_class_t *cls, const char *name, hid_t dcpl_id, hid_t dapl_id, + hid_t dxpl_id, void **req); +static void *H5VL__dataset_open(void *obj, const H5VL_loc_params_t *loc_params, + const H5VL_class_t *cls, const char *name, hid_t dapl_id, hid_t dxpl_id, + void **req); +static herr_t H5VL__dataset_read(void *dset, const H5VL_class_t *cls, + 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__dataset_write(void *obj, const H5VL_class_t *cls, + 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__dataset_get(void *obj, const H5VL_class_t *cls, H5VL_dataset_get_t get_type, + hid_t dxpl_id, void **req, va_list arguments); +static herr_t H5VL__dataset_specific(void *obj, const H5VL_class_t *cls, + H5VL_dataset_specific_t specific_type, hid_t dxpl_id, void **req, va_list arguments); +static herr_t H5VL__dataset_optional(void *obj, const H5VL_class_t *cls, + hid_t dxpl_id, void **req, va_list arguments); +static herr_t H5VL__dataset_close(void *obj, const H5VL_class_t *cls, hid_t dxpl_id, + void **req); +static void * H5VL__file_create(const H5VL_class_t *cls, const char *name, + unsigned flags, hid_t fcpl_id, hid_t fapl_id, hid_t dxpl_id, void **req); +static void * H5VL__file_open(const H5VL_class_t *cls, const char *name, + unsigned flags, hid_t fapl_id, hid_t dxpl_id, void **req); +static herr_t H5VL__file_get(void *obj, const H5VL_class_t *cls, H5VL_file_get_t get_type, + hid_t dxpl_id, void **req, va_list arguments); +static herr_t H5VL__file_specific(void *obj, const H5VL_class_t *cls, H5VL_file_specific_t specific_type, + hid_t dxpl_id, void **req, va_list arguments); +static herr_t H5VL__file_optional(void *obj, const H5VL_class_t *cls, hid_t dxpl_id, + void **req, va_list arguments); +static herr_t H5VL__file_close(void *obj, const H5VL_class_t *cls, hid_t dxpl_id, + void **req); +static void *H5VL__group_create(void *obj, const H5VL_loc_params_t *loc_params, + const H5VL_class_t *cls, const char *name, hid_t gcpl_id, hid_t gapl_id, + hid_t dxpl_id, void **req); +static void *H5VL__group_open(void *obj, const H5VL_loc_params_t *loc_params, + const H5VL_class_t *cls, const char *name, hid_t gapl_id, hid_t dxpl_id, + void **req); +static herr_t H5VL__group_get(void *obj, const H5VL_class_t *cls, H5VL_group_get_t get_type, + hid_t dxpl_id, void **req, va_list arguments); +static herr_t H5VL__group_specific(void *obj, const H5VL_class_t *cls, H5VL_group_specific_t specific_type, + hid_t dxpl_id, void **req, va_list arguments); +static herr_t H5VL__group_optional(void *obj, const H5VL_class_t *cls, hid_t dxpl_id, + void **req, va_list arguments); +static herr_t H5VL__group_close(void *obj, const H5VL_class_t *cls, + hid_t dxpl_id, void **req); +static herr_t H5VL__link_create(H5VL_link_create_type_t create_type, void *obj, + const H5VL_loc_params_t *loc_params, const H5VL_class_t *cls, hid_t lcpl_id, + hid_t lapl_id, hid_t dxpl_id, void **req); +static herr_t H5VL__link_copy(void *src_obj, const H5VL_loc_params_t *loc_params1, + void *dst_obj, const H5VL_loc_params_t *loc_params2, const H5VL_class_t *cls, + hid_t lcpl_id, hid_t lapl_id, hid_t dxpl_id, void **req); +static herr_t H5VL__link_move(void *src_obj, const H5VL_loc_params_t *loc_params1, + void *dst_obj, const H5VL_loc_params_t *loc_params2, const H5VL_class_t *cls, + hid_t lcpl_id, hid_t lapl_id, hid_t dxpl_id, void **req); +static herr_t H5VL__link_get(void *obj, const H5VL_loc_params_t *loc_params, + const H5VL_class_t *cls, H5VL_link_get_t get_type, hid_t dxpl_id, + void **req, va_list arguments); +static herr_t H5VL__link_specific(void *obj, const H5VL_loc_params_t *loc_params, + const H5VL_class_t *cls, H5VL_link_specific_t specific_type, hid_t dxpl_id, + void **req, va_list arguments); +static herr_t H5VL__link_optional(void *obj, const H5VL_class_t *cls, hid_t dxpl_id, + void **req, va_list arguments); +static void *H5VL__object_open(void *obj, const H5VL_loc_params_t *params, const H5VL_class_t *cls, + H5I_type_t *opened_type, hid_t dxpl_id, void **req); +static herr_t H5VL__object_copy(void *src_obj, const H5VL_loc_params_t *src_loc_params, + const char *src_name, void *dst_obj, const H5VL_loc_params_t *dst_loc_params, + const char *dst_name, const H5VL_class_t *cls, hid_t ocpypl_id, + hid_t lcpl_id, hid_t dxpl_id, void **req); +static herr_t H5VL__object_get(void *obj, const H5VL_loc_params_t *loc_params, + const H5VL_class_t *cls, H5VL_object_get_t get_type, hid_t dxpl_id, + void **req, va_list arguments); +static herr_t H5VL__object_specific(void *obj, const H5VL_loc_params_t *loc_params, + const H5VL_class_t *cls, H5VL_object_specific_t specific_type, hid_t dxpl_id, + void **req, va_list arguments); +static herr_t H5VL__object_optional(void *obj, const H5VL_class_t *cls, hid_t dxpl_id, + void **req, va_list arguments); +static void * H5VL__datatype_commit(void *obj, const H5VL_loc_params_t *loc_params, + const H5VL_class_t *cls, 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__datatype_open(void *obj, const H5VL_loc_params_t *loc_params, + const H5VL_class_t *cls, const char *name, hid_t tapl_id, hid_t dxpl_id, + void **req); +static herr_t H5VL__datatype_get(void *obj, const H5VL_class_t *cls, + H5VL_datatype_get_t get_type, hid_t dxpl_id, void **req, va_list arguments); +static herr_t H5VL__datatype_specific(void *obj, const H5VL_class_t *cls, + H5VL_datatype_specific_t specific_type, hid_t dxpl_id, void **req, + va_list arguments); +static herr_t H5VL__datatype_optional(void *obj, const H5VL_class_t *cls, + hid_t dxpl_id, void **req, va_list arguments); +static herr_t H5VL__datatype_close(void *obj, const H5VL_class_t *cls, hid_t dxpl_id, + void **req); +static herr_t H5VL__request_wait(void *req, const H5VL_class_t *cls, + uint64_t timeout, H5ES_status_t *status); +static herr_t H5VL__request_notify(void *req, const H5VL_class_t *cls, + H5VL_request_notify_t cb, void *ctx); +static herr_t H5VL__request_cancel(void *req, const H5VL_class_t *cls); +static herr_t H5VL__request_specific(void *req, const H5VL_class_t *cls, + H5VL_request_specific_t specific_type, va_list arguments); +static herr_t H5VL__request_optional(void *req, const H5VL_class_t *cls, + va_list arguments); +static herr_t H5VL__request_free(void *req, const H5VL_class_t *cls); + + +/*********************/ +/* Package Variables */ +/*********************/ + + +/*****************************/ +/* Library Private Variables */ +/*****************************/ + + +/*******************/ +/* Local Variables */ +/*******************/ + + + +/*------------------------------------------------------------------------- + * Function: H5VLinitialize + * + * Purpose: Calls the connector-specific callback to initialize the connector. + * + * Return: Success: Non-negative + * Failure: Negative + * + *------------------------------------------------------------------------- + */ +herr_t +H5VLinitialize(hid_t connector_id, hid_t vipl_id) +{ + H5VL_class_t *cls; /* VOL connector's class struct */ + herr_t ret_value = SUCCEED; /* Return value */ + + FUNC_ENTER_API_NOINIT + H5TRACE2("e", "ii", connector_id, vipl_id); + + /* Check args */ + if(NULL == (cls = (H5VL_class_t *)H5I_object_verify(connector_id, H5I_VOL))) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a VOL connector ID") + + /* Invoke class' callback, if there is one */ + if(cls->initialize && cls->initialize(vipl_id) < 0) + HGOTO_ERROR(H5E_VOL, H5E_CANTCLOSEOBJ, FAIL, "VOL connector did not initialize") + +done: + FUNC_LEAVE_API_NOINIT(ret_value) +} /* end H5VLinitialize() */ + + +/*------------------------------------------------------------------------- + * Function: H5VLterminate + * + * Purpose: Calls the connector-specific callback to terminate the connector. + * + * Return: Success: Non-negative + * Failure: Negative + * + *------------------------------------------------------------------------- + */ +herr_t +H5VLterminate(hid_t connector_id) +{ + H5VL_class_t *cls; /* VOL connector's class struct */ + herr_t ret_value = SUCCEED; /* Return value */ + + FUNC_ENTER_API_NOINIT + H5TRACE1("e", "i", connector_id); + + /* Check args */ + if(NULL == (cls = (H5VL_class_t *)H5I_object_verify(connector_id, H5I_VOL))) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a VOL connector ID") + + /* Invoke class' callback, if there is one */ + if(cls->terminate && cls->terminate() < 0) + HGOTO_ERROR(H5E_VOL, H5E_CANTCLOSEOBJ, FAIL, "VOL connector did not terminate cleanly") + +done: + FUNC_LEAVE_API_NOINIT(ret_value) +} /* end H5VLterminate() */ + + +/*--------------------------------------------------------------------------- + * Function: H5VLget_cap_flags + * + * Purpose: Retrieves the capability flag for a connector + * + * Return: Success: Non-negative + * Failure: Negative + * + *--------------------------------------------------------------------------- + */ +herr_t +H5VLget_cap_flags(hid_t connector_id, unsigned *cap_flags) +{ + H5VL_class_t *cls; /* VOL connector's class struct */ + herr_t ret_value = SUCCEED; /* Return value */ + + FUNC_ENTER_API_NOINIT + H5TRACE2("e", "i*Iu", connector_id, cap_flags); + + /* Check args */ + if(NULL == (cls = (H5VL_class_t *)H5I_object_verify(connector_id, H5I_VOL))) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a VOL connector ID") + + /* Retrieve capability flags */ + if(cap_flags) + *cap_flags = cls->cap_flags; + +done: + FUNC_LEAVE_API_NOINIT(ret_value) +} /* H5VLget_cap_flags */ + + +/*--------------------------------------------------------------------------- + * Function: H5VLget_value + * + * Purpose: Retrieves the 'value' for a connector + * + * Return: Success: Non-negative + * Failure: Negative + * + *--------------------------------------------------------------------------- + */ +herr_t +H5VLget_value(hid_t connector_id, H5VL_class_value_t *value) +{ + H5VL_class_t *cls; /* VOL connector's class struct */ + herr_t ret_value = SUCCEED; /* Return value */ + + FUNC_ENTER_API_NOINIT + H5TRACE2("e", "i*VC", connector_id, value); + + /* Check args */ + if(NULL == (cls = (H5VL_class_t *)H5I_object_verify(connector_id, H5I_VOL))) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a VOL connector ID") + + /* Retrieve connector value */ + if(value) + *value = cls->value; + +done: + FUNC_LEAVE_API_NOINIT(ret_value) +} /* H5VLget_value */ + + +/*------------------------------------------------------------------------- + * Function: H5VL_copy_connector_info + * + * Purpose: Copy the VOL info for a connector + * + * Return: Success: Non-negative + * Failure: Negative + * + *------------------------------------------------------------------------- + */ +herr_t +H5VL_copy_connector_info(const H5VL_class_t *connector, void **dst_info, + const void *src_info) +{ + void *new_connector_info = NULL; /* Copy of connector info */ + herr_t ret_value = SUCCEED; /* Return value */ + + FUNC_ENTER_NOAPI(FAIL) + + /* Sanity checks */ + HDassert(connector); + + /* Check for actual source info */ + if(src_info) { + /* Allow the connector to copy or do it ourselves */ + if(connector->info_copy) { + if(NULL == (new_connector_info = (connector->info_copy)(src_info))) + HGOTO_ERROR(H5E_VOL, H5E_CANTCOPY, FAIL, "connector info copy callback failed") + } /* end if */ + else if(connector->info_size > 0) { + if(NULL == (new_connector_info = H5MM_malloc(connector->info_size))) + HGOTO_ERROR(H5E_VOL, H5E_CANTALLOC, FAIL, "connector info allocation failed") + HDmemcpy(new_connector_info, src_info, connector->info_size); + } /* end else-if */ + else + HGOTO_ERROR(H5E_VOL, H5E_UNSUPPORTED, FAIL, "no way to copy connector info") + } /* end if */ + + /* Set the connector info for the copy */ + *dst_info = new_connector_info; + +done: + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5VL_copy_connector_info() */ + + +/*--------------------------------------------------------------------------- + * Function: H5VLcopy_connector_info + * + * Purpose: Copies a VOL connector's info object + * + * Return: Success: Non-negative + * Failure: Negative + * + *--------------------------------------------------------------------------- + */ +herr_t +H5VLcopy_connector_info(hid_t connector_id, void **dst_vol_info, void *src_vol_info) +{ + H5VL_class_t *cls; /* VOL connector's class struct */ + herr_t ret_value = SUCCEED; /* Return value */ + + FUNC_ENTER_API_NOINIT + H5TRACE3("e", "i**x*x", connector_id, dst_vol_info, src_vol_info); + + /* Check args and get class pointer */ + if(NULL == (cls = (H5VL_class_t *)H5I_object_verify(connector_id, H5I_VOL))) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a VOL connector ID") + + /* Copy the VOL connector's info object */ + if(H5VL_copy_connector_info(cls, dst_vol_info, src_vol_info) < 0) + HGOTO_ERROR(H5E_VOL, H5E_CANTCOPY, FAIL, "unable to copy VOL connector info object") + +done: + FUNC_LEAVE_API_NOINIT(ret_value) +} /* H5VLcopy_connector_info() */ + + +/*------------------------------------------------------------------------- + * Function: H5VL_cmp_connector_info + * + * Purpose: Compare VOL info for a connector. Sets *cmp_value to + * positive if INFO1 is greater than INFO2, negative if + * INFO2 is greater than INFO1 and zero if INFO1 and + * INFO2 are equal. + * + * Return: Success: Non-negative + * Failure: Negative + * + *------------------------------------------------------------------------- + */ +herr_t +H5VL_cmp_connector_info(const H5VL_class_t *connector, int *cmp_value, + const void *info1, const void *info2) +{ + herr_t ret_value = SUCCEED; /* Return value */ + + FUNC_ENTER_NOAPI(FAIL) + + /* Sanity checks */ + HDassert(connector); + HDassert(cmp_value); + + /* Take care of cases where one or both pointers is NULL */ + if(info1 == NULL && info2 != NULL) { + *cmp_value = -1; + HGOTO_DONE(SUCCEED); + } /* end if */ + if(info1 != NULL && info2 == NULL) { + *cmp_value = 1; + HGOTO_DONE(SUCCEED); + } /* end if */ + if(info1 == NULL && info2 == NULL) { + *cmp_value = 0; + HGOTO_DONE(SUCCEED); + } /* end if */ + + /* Use the class's info comparison routine to compare the info objects, + * if there is a a callback, otherwise just compare the info objects as + * memory buffers + */ + if(connector->info_cmp) { + if((connector->info_cmp)(cmp_value, info1, info2) < 0) + HGOTO_ERROR(H5E_VOL, H5E_CANTCOMPARE, FAIL, "can't compare connector info") + } /* end if */ + else { + HDassert(connector->info_size > 0); + *cmp_value = HDmemcmp(info1, info2, connector->info_size); + } /* end else */ + +done: + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5VL_cmp_connector_info() */ + + +/*--------------------------------------------------------------------------- + * Function: H5VLcmp_connector_info + * + * Purpose: Compares two connector info objects + * + * Note: Both info objects must be from the same VOL connector class + * + * Return: Success: Non-negative, with *cmp set to positive if + * info1 is greater than info2, negative if info2 + * is greater than info1 and zero if info1 and info2 + * are equal. + * Failure: Negative + * + *--------------------------------------------------------------------------- + */ +herr_t +H5VLcmp_connector_info(int *cmp, hid_t connector_id, const void *info1, const void *info2) +{ + H5VL_class_t *cls; /* VOL connector's class struct */ + herr_t ret_value = SUCCEED; /* Return value */ + + FUNC_ENTER_API(FAIL) + H5TRACE4("e", "*Isi*x*x", cmp, connector_id, info1, info2); + + /* Check args and get class pointer */ + if(NULL == (cls = (H5VL_class_t *)H5I_object_verify(connector_id, H5I_VOL))) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a VOL connector ID") + + /* Compare the two VOL connector info objects */ + if(cmp) + H5VL_cmp_connector_info(cls, cmp, info1, info2); + +done: + FUNC_LEAVE_API(ret_value) +} /* H5VLcmp_connector_info() */ + + +/*------------------------------------------------------------------------- + * Function: H5VL_free_connector_info + * + * Purpose: Free VOL info for a connector + * + * Return: Success: Non-negative + * Failure: Negative + * + *------------------------------------------------------------------------- + */ +herr_t +H5VL_free_connector_info(const H5VL_class_t *connector, void *info) +{ + herr_t ret_value = SUCCEED; /* Return value */ + + FUNC_ENTER_NOAPI(FAIL) + + /* Sanity checks */ + HDassert(connector); + + /* Only free info object, if it's non-NULL */ + if(info) { + /* Allow the connector to free info or do it ourselves */ + if(connector->info_free) { + if((connector->info_free)(info) < 0) + HGOTO_ERROR(H5E_VOL, H5E_CANTRELEASE, FAIL, "connector info free request failed") + } /* end if */ + else + H5MM_xfree(info); + } /* end if */ + +done: + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5VL_free_connector_info() */ + + +/*--------------------------------------------------------------------------- + * Function: H5VLfree_connector_info + * + * Purpose: Free VOL connector info object + * + * Return: Success: Non-negative + * Failure: Negative + * + *--------------------------------------------------------------------------- + */ +herr_t +H5VLfree_connector_info(hid_t connector_id, void *info) +{ + H5VL_class_t *cls; /* VOL connector's class struct */ + herr_t ret_value = SUCCEED; /* Return value */ + + FUNC_ENTER_API_NOINIT + H5TRACE2("e", "i*x", connector_id, info); + + /* Check args and get class pointer */ + if(NULL == (cls = (H5VL_class_t *)H5I_object_verify(connector_id, H5I_VOL))) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a VOL connector ID") + + /* Free the VOL connector info object */ + if(H5VL_free_connector_info(cls, info) < 0) + HGOTO_ERROR(H5E_VOL, H5E_CANTRELEASE, FAIL, "unable to release VOL connector info object") + +done: + FUNC_LEAVE_API_NOINIT(ret_value) +} /* H5VLfree_connector_info() */ + + +/*--------------------------------------------------------------------------- + * Function: H5VLconnector_info_to_str + * + * Purpose: Serialize a connector's info into a string + * + * Return: Success: Non-negative + * Failure: Negative + * + *--------------------------------------------------------------------------- + */ +herr_t +H5VLconnector_info_to_str(const void *info, hid_t connector_id, char **str) +{ + herr_t ret_value = SUCCEED; /* Return value */ + + FUNC_ENTER_API_NOINIT + H5TRACE3("e", "*xi**s", info, connector_id, str); + + /* Only serialize info object, if it's non-NULL */ + if(info) { + H5VL_class_t *cls; /* VOL connector's class struct */ + + /* Check args and get class pointer */ + if(NULL == (cls = (H5VL_class_t *)H5I_object_verify(connector_id, H5I_VOL))) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a VOL connector ID") + + /* Allow the connector to serialize info */ + if(cls->info_to_str) { + if((cls->info_to_str)(info, str) < 0) + HGOTO_ERROR(H5E_VOL, H5E_CANTSERIALIZE, FAIL, "can't serialize connector info") + } /* end if */ + else + *str = NULL; + } /* end if */ + else + *str = NULL; + +done: + FUNC_LEAVE_API_NOINIT(ret_value) +} /* H5VLconnector_info_to_str() */ + + +/*--------------------------------------------------------------------------- + * Function: H5VLconnector_str_to_info + * + * Purpose: Deserialize a string into a connector's info + * + * Return: Success: Non-negative + * Failure: Negative + * + *--------------------------------------------------------------------------- + */ +herr_t +H5VLconnector_str_to_info(const char *str, hid_t connector_id, void **info) +{ + herr_t ret_value = SUCCEED; /* Return value */ + + FUNC_ENTER_API_NOINIT + H5TRACE3("e", "*si**x", str, connector_id, info); + + /* Only deserialize string, if it's non-NULL */ + if(str) { + H5VL_class_t *cls; /* VOL connector's class struct */ + + /* Check args and get class pointer */ + if(NULL == (cls = (H5VL_class_t *)H5I_object_verify(connector_id, H5I_VOL))) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a VOL connector ID") + + /* Allow the connector to deserialize info */ + if(cls->str_to_info) { + if((cls->str_to_info)(str, info) < 0) + HGOTO_ERROR(H5E_VOL, H5E_CANTUNSERIALIZE, FAIL, "can't deserialize connector info") + } /* end if */ + else + *info = NULL; + } /* end if */ + else + *info = NULL; + +done: + FUNC_LEAVE_API_NOINIT(ret_value) +} /* H5VLconnector_str_to_info() */ + + +/*--------------------------------------------------------------------------- + * Function: H5VLget_object + * + * Purpose: Retrieves an underlying object. + * + * Return: Success: Non-NULL + * Failure: NULL + * + *--------------------------------------------------------------------------- + */ +void * +H5VLget_object(void *obj, hid_t connector_id) +{ + H5VL_class_t *cls; /* VOL connector's class struct */ + void *ret_value = NULL; /* Return value */ + + FUNC_ENTER_API_NOINIT + H5TRACE2("*x", "*xi", obj, connector_id); + + /* Check args */ + if(NULL == obj) + HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, NULL, "invalid object") + if(NULL == (cls = (H5VL_class_t *)H5I_object_verify(connector_id, H5I_VOL))) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, NULL, "not a VOL connector ID") + + /* Check for 'get_object' callback in connector */ + if(cls->get_object) + ret_value = (cls->get_object)(obj); + else + ret_value = obj; + +done: + FUNC_LEAVE_API_NOINIT(ret_value) +} /* H5VLget_object */ + + +/*------------------------------------------------------------------------- + * Function: H5VL_get_wrap_ctx + * + * Purpose: Retrieve the VOL object wrapping context for a connector + * + * Return: Success: Non-negative + * Failure: Negative + * + *------------------------------------------------------------------------- + */ +herr_t +H5VL_get_wrap_ctx(const H5VL_class_t *connector, void *obj, void **wrap_ctx) +{ + herr_t ret_value = SUCCEED; /* Return value */ + + FUNC_ENTER_NOAPI(FAIL) + + /* Sanity checks */ + HDassert(connector); + HDassert(obj); + HDassert(wrap_ctx); + + /* Allow the connector to copy or do it ourselves */ + if(connector->get_wrap_ctx) { + /* Sanity check */ + HDassert(connector->free_wrap_ctx); + + /* Invoke connector's callback */ + if((connector->get_wrap_ctx)(obj, wrap_ctx) < 0) + HGOTO_ERROR(H5E_VOL, H5E_CANTGET, FAIL, "connector wrap context callback failed") + } /* end if */ + else + *wrap_ctx = NULL; + +done: + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5VL_get_wrap_ctx() */ + + +/*--------------------------------------------------------------------------- + * Function: H5VLget_wrap_ctx + * + * Purpose: Get a VOL connector's object wrapping context + * + * Return: Success: Non-negative + * Failure: Negative + * + *--------------------------------------------------------------------------- + */ +herr_t +H5VLget_wrap_ctx(void *obj, hid_t connector_id, void **wrap_ctx) +{ + H5VL_class_t *cls; /* VOL connector's class struct */ + herr_t ret_value = SUCCEED; /* Return value */ + + FUNC_ENTER_API_NOINIT + H5TRACE3("e", "*xi**x", obj, connector_id, wrap_ctx); + + /* Check args and get class pointer */ + if(NULL == (cls = (H5VL_class_t *)H5I_object_verify(connector_id, H5I_VOL))) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a VOL connector ID") + + /* Get the VOL connector's object wrapper */ + if(H5VL_get_wrap_ctx(cls, obj, wrap_ctx) < 0) + HGOTO_ERROR(H5E_VOL, H5E_CANTGET, FAIL, "unable to retrieve VOL connector object wrap context") + +done: + FUNC_LEAVE_API_NOINIT(ret_value) +} /* H5VLget_wrap_ctx() */ + + +/*------------------------------------------------------------------------- + * Function: H5VL_free_wrap_ctx + * + * Purpose: Free object wrapping context for a connector + * + * Return: Success: Non-negative + * Failure: Negative + * + *------------------------------------------------------------------------- + */ +herr_t +H5VL_free_wrap_ctx(const H5VL_class_t *connector, void *wrap_ctx) +{ + herr_t ret_value = SUCCEED; /* Return value */ + + FUNC_ENTER_NOAPI(FAIL) + + /* Sanity checks */ + HDassert(connector); + + /* Only free wrap context, if it's non-NULL */ + if(wrap_ctx) { + /* Free the connector's object wrapping context */ + if((connector->free_wrap_ctx)(wrap_ctx) < 0) + HGOTO_ERROR(H5E_VOL, H5E_CANTRELEASE, FAIL, "connector wrap context free request failed") + } /* end if */ + +done: + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5VL_free_wrap_ctx() */ + + +/*--------------------------------------------------------------------------- + * Function: H5VLfree_wrap_ctx + * + * Purpose: Release a VOL connector's object wrapping context + * + * Return: Success: Non-negative + * Failure: Negative + * + *--------------------------------------------------------------------------- + */ +herr_t +H5VLfree_wrap_ctx(void *wrap_ctx, hid_t connector_id) +{ + H5VL_class_t *cls; /* VOL connector's class struct */ + herr_t ret_value = SUCCEED; /* Return value */ + + FUNC_ENTER_API_NOINIT + H5TRACE2("e", "*xi", wrap_ctx, connector_id); + + /* Check args and get class pointer */ + if(NULL == (cls = (H5VL_class_t *)H5I_object_verify(connector_id, H5I_VOL))) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a VOL connector ID") + + /* Release the VOL connector's object wrapper */ + if(H5VL_free_wrap_ctx(cls, wrap_ctx) < 0) + HGOTO_ERROR(H5E_VOL, H5E_CANTRELEASE, FAIL, "unable to release VOL connector object wrap context") + +done: + FUNC_LEAVE_API_NOINIT(ret_value) +} /* H5VLfree_wrap_ctx() */ + + +/*------------------------------------------------------------------------- + * Function: H5VL_wrap_object + * + * Purpose: Wrap an object with connector + * + * Return: Success: Non-negative + * Failure: Negative + * + *------------------------------------------------------------------------- + */ +void * +H5VL_wrap_object(const H5VL_class_t *connector, void *wrap_ctx, void *obj) +{ + void *ret_value = SUCCEED; /* Return value */ + + FUNC_ENTER_NOAPI(NULL) + + /* Sanity checks */ + HDassert(connector); + HDassert(obj); + + /* Only wrap object if there's a wrap context */ + if(wrap_ctx) { + /* Ask the connector to wrap the object */ + if(NULL == (ret_value = (connector->wrap_object)(obj, wrap_ctx))) + HGOTO_ERROR(H5E_VOL, H5E_CANTGET, NULL, "can't wrap object") + } /* end if */ + else + ret_value = obj; + +done: + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5VL_wrap_object() */ + + +/*--------------------------------------------------------------------------- + * Function: H5VLwrap_object + * + * Purpose: Asks a connector to wrap an underlying object. + * + * Return: Success: Non-NULL + * Failure: NULL + * + *--------------------------------------------------------------------------- + */ +void * +H5VLwrap_object(void *obj, hid_t connector_id, void *wrap_ctx) +{ + H5VL_class_t *cls; /* VOL connector's class struct */ + void *ret_value = NULL; /* Return value */ + + FUNC_ENTER_API_NOINIT + H5TRACE3("*x", "*xi*x", obj, connector_id, wrap_ctx); + + /* Check args and get class pointer */ + if(NULL == obj) + HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, NULL, "invalid object") + if(NULL == (cls = (H5VL_class_t *)H5I_object_verify(connector_id, H5I_VOL))) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, NULL, "not a VOL connector ID") + + /* Wrap the object */ + if(NULL == (ret_value = H5VL_wrap_object(cls, wrap_ctx, obj))) + HGOTO_ERROR(H5E_VOL, H5E_CANTGET, NULL, "unable to wrap object") + +done: + FUNC_LEAVE_API_NOINIT(ret_value) +} /* H5VLwrap_object */ + + +/*------------------------------------------------------------------------- + * Function: H5VL__attr_create + * + * Purpose: Creates an attribute through the VOL + * + * Return: Success: Pointer to the new attribute + * Failure: NULL + * + *------------------------------------------------------------------------- + */ +static void * +H5VL__attr_create(void *obj, const H5VL_loc_params_t *loc_params, const H5VL_class_t *cls, + const char *name, hid_t acpl_id, hid_t aapl_id, hid_t dxpl_id, void **req) +{ + void *ret_value = NULL; /* Return value */ + + FUNC_ENTER_STATIC + + /* Check if the corresponding VOL callback exists */ + if(NULL == cls->attr_cls.create) + HGOTO_ERROR(H5E_VOL, H5E_UNSUPPORTED, NULL, "VOL connector has no 'attr create' method") + + /* Call the corresponding VOL callback */ + if(NULL == (ret_value = (cls->attr_cls.create)(obj, loc_params, name, acpl_id, aapl_id, dxpl_id, req))) + HGOTO_ERROR(H5E_VOL, H5E_CANTCREATE, NULL, "attribute create failed") + +done: + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5VL_attr_create() */ + + +/*------------------------------------------------------------------------- + * Function: H5VL_attr_create + * + * Purpose: Creates an attribute through the VOL + * + * Return: Success: Pointer to the new attribute + * Failure: NULL + * + *------------------------------------------------------------------------- + */ +void * +H5VL_attr_create(const H5VL_object_t *vol_obj, const H5VL_loc_params_t *loc_params, + const char *name, hid_t acpl_id, hid_t aapl_id, hid_t dxpl_id, void **req) +{ + hbool_t vol_wrapper_set = FALSE; /* Whether the VOL object wrapping context was set up */ + void *ret_value = NULL; /* Return value */ + + FUNC_ENTER_NOAPI(NULL) + + /* Set wrapper info in API context */ + if(H5VL_set_vol_wrapper(vol_obj->data, vol_obj->connector) < 0) + HGOTO_ERROR(H5E_VOL, H5E_CANTSET, NULL, "can't set VOL wrapper info") + vol_wrapper_set = TRUE; + + /* Call the corresponding internal VOL routine */ + if(NULL == (ret_value = H5VL__attr_create(vol_obj->data, loc_params, vol_obj->connector->cls, name, acpl_id, aapl_id, dxpl_id, req))) + HGOTO_ERROR(H5E_VOL, H5E_CANTCREATE, NULL, "attribute create failed") + +done: + /* Reset object wrapping info in API context */ + if(vol_wrapper_set && H5VL_reset_vol_wrapper() < 0) + HDONE_ERROR(H5E_VOL, H5E_CANTRESET, NULL, "can't reset VOL wrapper info") + + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5VL_attr_create() */ + + +/*------------------------------------------------------------------------- + * Function: H5VLattr_create + * + * Purpose: Creates an attribute + * + * Return: Success: Pointer to the new attribute + * Failure: NULL + * + *------------------------------------------------------------------------- + */ +void * +H5VLattr_create(void *obj, const H5VL_loc_params_t *loc_params, hid_t connector_id, + const char *name, hid_t acpl_id, hid_t aapl_id, hid_t dxpl_id, void **req) +{ + H5VL_class_t *cls; /* VOL connector's class struct */ + void *ret_value = NULL; /* Return value */ + + FUNC_ENTER_API_NOINIT + H5TRACE8("*x", "*x*xi*siii**x", obj, loc_params, connector_id, name, acpl_id, + aapl_id, dxpl_id, req); + + /* Check args and get class pointer */ + if(NULL == obj) + HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, NULL, "invalid object") + if(NULL == (cls = (H5VL_class_t *)H5I_object_verify(connector_id, H5I_VOL))) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, NULL, "not a VOL connector ID") + + /* Call the corresponding internal VOL routine */ + if(NULL == (ret_value = H5VL__attr_create(obj, loc_params, cls, name, acpl_id, aapl_id, dxpl_id, req))) + HGOTO_ERROR(H5E_VOL, H5E_CANTCREATE, NULL, "unable to create attribute") + +done: + FUNC_LEAVE_API_NOINIT(ret_value) +} /* end H5VLattr_create() */ + + +/*------------------------------------------------------------------------- + * Function: H5VL__attr_open + * + * Purpose: Opens an attribute through the VOL + * + * Return: Success: Pointer to the attribute + * Failure: NULL + * + *------------------------------------------------------------------------- + */ +static void * +H5VL__attr_open(void *obj, const H5VL_loc_params_t *loc_params, const H5VL_class_t *cls, const char *name, + hid_t aapl_id, hid_t dxpl_id, void **req) +{ + void *ret_value = NULL; /* Return value */ + + FUNC_ENTER_STATIC + + /* Check if the corresponding VOL callback exists */ + if(NULL == cls->attr_cls.open) + HGOTO_ERROR(H5E_VOL, H5E_UNSUPPORTED, NULL, "VOL connector has no 'attr open' method") + + /* Call the corresponding VOL open callback */ + if(NULL == (ret_value = (cls->attr_cls.open)(obj, loc_params, name, aapl_id, dxpl_id, req))) + HGOTO_ERROR(H5E_VOL, H5E_CANTOPENOBJ, NULL, "attribute open failed") + +done: + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5VL__attr_open() */ + + +/*------------------------------------------------------------------------- + * Function: H5VL_attr_open + * + * Purpose: Opens an attribute through the VOL + * + * Return: Success: Pointer to the attribute + * Failure: NULL + * + *------------------------------------------------------------------------- + */ +void * +H5VL_attr_open(const H5VL_object_t *vol_obj, const H5VL_loc_params_t *loc_params, + const char *name, hid_t aapl_id, hid_t dxpl_id, void **req) +{ + hbool_t vol_wrapper_set = FALSE; /* Whether the VOL object wrapping context was set up */ + void *ret_value = NULL; /* Return value */ + + FUNC_ENTER_NOAPI(NULL) + + /* Set wrapper info in API context */ + if(H5VL_set_vol_wrapper(vol_obj->data, vol_obj->connector) < 0) + HGOTO_ERROR(H5E_VOL, H5E_CANTSET, NULL, "can't set VOL wrapper info") + vol_wrapper_set = TRUE; + + /* Call the corresponding internal VOL routine */ + if(NULL == (ret_value = H5VL__attr_open(vol_obj->data, loc_params, vol_obj->connector->cls, name, aapl_id, dxpl_id, req))) + HGOTO_ERROR(H5E_VOL, H5E_CANTOPENOBJ, NULL, "attribute open failed") + +done: + /* Reset object wrapping info in API context */ + if(vol_wrapper_set && H5VL_reset_vol_wrapper() < 0) + HDONE_ERROR(H5E_VOL, H5E_CANTRESET, NULL, "can't reset VOL wrapper info") + + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5VL_attr_open() */ + + +/*------------------------------------------------------------------------- + * Function: H5VLattr_open + * + * Purpose: Opens an attribute + * + * Return: Success: Pointer to the attribute + * Failure: NULL + * + *------------------------------------------------------------------------- + */ +void * +H5VLattr_open(void *obj, const H5VL_loc_params_t *loc_params, hid_t connector_id, + const char *name, hid_t aapl_id, hid_t dxpl_id, void **req) +{ + H5VL_class_t *cls; /* VOL connector's class struct */ + void *ret_value = NULL; /* Return value */ + + FUNC_ENTER_API_NOINIT + H5TRACE7("*x", "*x*xi*sii**x", obj, loc_params, connector_id, name, aapl_id, + dxpl_id, req); + + /* Check args and get class pointer */ + if(NULL == obj) + HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, NULL, "invalid object") + if(NULL == (cls = (H5VL_class_t *)H5I_object_verify(connector_id, H5I_VOL))) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, NULL, "not a VOL connector ID") + + /* Call the corresponding internal VOL routine */ + if(NULL == (ret_value = H5VL__attr_open(obj, loc_params, cls, name, aapl_id, dxpl_id, req))) + HGOTO_ERROR(H5E_VOL, H5E_CANTOPENOBJ, NULL, "unable to open attribute") + +done: + FUNC_LEAVE_API_NOINIT(ret_value) +} /* end H5VLattr_open() */ + + +/*------------------------------------------------------------------------- + * Function: H5VL__attr_read + * + * Purpose: Reads data from attr through the VOL + * + * Return: Success: Non-negative + * Failure: Negative + * + *------------------------------------------------------------------------- + */ +static herr_t +H5VL__attr_read(void *obj, const H5VL_class_t *cls, hid_t mem_type_id, void *buf, + hid_t dxpl_id, void **req) +{ + herr_t ret_value = SUCCEED; /* Return value */ + + FUNC_ENTER_STATIC + + /* Check if the corresponding VOL callback exists */ + if(NULL == cls->attr_cls.read) + HGOTO_ERROR(H5E_VOL, H5E_UNSUPPORTED, FAIL, "VOL connector has no 'attr read' method") + + /* Call the corresponding VOL callback */ + if((cls->attr_cls.read)(obj, mem_type_id, buf, dxpl_id, req) < 0) + HGOTO_ERROR(H5E_VOL, H5E_READERROR, FAIL, "attribute read failed") + +done: + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5VL__attr_read() */ + + +/*------------------------------------------------------------------------- + * Function: H5VL_attr_read + * + * Purpose: Reads data from attr through the VOL + * + * Return: Success: Non-negative + * Failure: Negative + * + *------------------------------------------------------------------------- + */ +herr_t +H5VL_attr_read(const H5VL_object_t *vol_obj, hid_t mem_type_id, void *buf, + hid_t dxpl_id, void **req) +{ + hbool_t vol_wrapper_set = FALSE; /* Whether the VOL object wrapping context was set up */ + herr_t ret_value = SUCCEED; /* Return value */ + + FUNC_ENTER_NOAPI(FAIL) + + /* Set wrapper info in API context */ + if(H5VL_set_vol_wrapper(vol_obj->data, vol_obj->connector) < 0) + HGOTO_ERROR(H5E_VOL, H5E_CANTSET, FAIL, "can't set VOL wrapper info") + vol_wrapper_set = TRUE; + + /* Call the corresponding internal VOL routine */ + if(H5VL__attr_read(vol_obj->data, vol_obj->connector->cls, mem_type_id, buf, dxpl_id, req) < 0) + HGOTO_ERROR(H5E_VOL, H5E_READERROR, FAIL, "attribute read failed") + +done: + /* Reset object wrapping info in API context */ + if(vol_wrapper_set && H5VL_reset_vol_wrapper() < 0) + HDONE_ERROR(H5E_VOL, H5E_CANTRESET, FAIL, "can't reset VOL wrapper info") + + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5VL_attr_read() */ + + +/*------------------------------------------------------------------------- + * Function: H5VLattr_read + * + * Purpose: Reads data from an attribute + * + * Return: Success: Non-negative + * Failure: Negative + * + *------------------------------------------------------------------------- + */ +herr_t +H5VLattr_read(void *obj, hid_t connector_id, hid_t mem_type_id, void *buf, hid_t dxpl_id, void **req) +{ + H5VL_class_t *cls; /* VOL connector's class struct */ + herr_t ret_value = SUCCEED; /* Return value */ + + FUNC_ENTER_API_NOINIT + H5TRACE6("e", "*xii*xi**x", obj, connector_id, mem_type_id, buf, dxpl_id, req); + + /* Check args and get class pointer */ + if(NULL == obj) + HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "invalid object") + if(NULL == (cls = (H5VL_class_t *)H5I_object_verify(connector_id, H5I_VOL))) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a VOL connector ID") + + /* Call the corresponding internal VOL routine */ + if(H5VL__attr_read(obj, cls, mem_type_id, buf, dxpl_id, req) < 0) + HGOTO_ERROR(H5E_VOL, H5E_READERROR, FAIL, "unable to read attribute") + +done: + FUNC_LEAVE_API_NOINIT(ret_value) +} /* end H5VLattr_read() */ + + +/*------------------------------------------------------------------------- + * Function: H5VL__attr_write + * + * Purpose: Writes data to attr through the VOL + * + * Return: Success: Non-negative + * Failure: Negative + * + *------------------------------------------------------------------------- + */ +static herr_t +H5VL__attr_write(void *obj, const H5VL_class_t *cls, hid_t mem_type_id, const void *buf, + hid_t dxpl_id, void **req) +{ + herr_t ret_value = SUCCEED; /* Return value */ + + FUNC_ENTER_STATIC + + /* Check if the corresponding VOL callback exists */ + if(NULL == cls->attr_cls.write) + HGOTO_ERROR(H5E_VOL, H5E_UNSUPPORTED, FAIL, "VOL connector has no 'attr write' method") + + /* Call the corresponding VOL callback */ + if((cls->attr_cls.write)(obj, mem_type_id, buf, dxpl_id, req) < 0) + HGOTO_ERROR(H5E_VOL, H5E_WRITEERROR, FAIL, "write failed") + +done: + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5VL__attr_write() */ + + +/*------------------------------------------------------------------------- + * Function: H5VL_attr_write + * + * Purpose: Writes data to attr through the VOL + * + * Return: Success: Non-negative + * Failure: Negative + * + *------------------------------------------------------------------------- + */ +herr_t +H5VL_attr_write(const H5VL_object_t *vol_obj, hid_t mem_type_id, const void *buf, + hid_t dxpl_id, void **req) +{ + hbool_t vol_wrapper_set = FALSE; /* Whether the VOL object wrapping context was set up */ + herr_t ret_value = SUCCEED; /* Return value */ + + FUNC_ENTER_NOAPI(FAIL) + + /* Set wrapper info in API context */ + if(H5VL_set_vol_wrapper(vol_obj->data, vol_obj->connector) < 0) + HGOTO_ERROR(H5E_VOL, H5E_CANTSET, FAIL, "can't set VOL wrapper info") + vol_wrapper_set = TRUE; + + /* Call the corresponding internal VOL routine */ + if(H5VL__attr_write(vol_obj->data, vol_obj->connector->cls, mem_type_id, buf, dxpl_id, req) < 0) + HGOTO_ERROR(H5E_VOL, H5E_WRITEERROR, FAIL, "write failed") + +done: + /* Reset object wrapping info in API context */ + if(vol_wrapper_set && H5VL_reset_vol_wrapper() < 0) + HDONE_ERROR(H5E_VOL, H5E_CANTRESET, FAIL, "can't reset VOL wrapper info") + + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5VL_attr_write() */ + + +/*------------------------------------------------------------------------- + * Function: H5VLattr_write + * + * Purpose: Writes data to an attribute + * + * Return: Success: Non-negative + * Failure: Negative + * + *------------------------------------------------------------------------- + */ +herr_t +H5VLattr_write(void *obj, hid_t connector_id, hid_t mem_type_id, const void *buf, + hid_t dxpl_id, void **req) +{ + H5VL_class_t *cls; /* VOL connector's class struct */ + herr_t ret_value = SUCCEED; /* Return value */ + + FUNC_ENTER_API_NOINIT + H5TRACE6("e", "*xii*xi**x", obj, connector_id, mem_type_id, buf, dxpl_id, req); + + /* Check args and get class pointer */ + if(NULL == obj) + HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "invalid object") + if(NULL == (cls = (H5VL_class_t *)H5I_object_verify(connector_id, H5I_VOL))) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a VOL connector ID") + + /* Call the corresponding internal VOL routine */ + if(H5VL__attr_write(obj, cls, mem_type_id, buf, dxpl_id, req) < 0) + HGOTO_ERROR(H5E_VOL, H5E_WRITEERROR, FAIL, "unable to write attribute") + +done: + FUNC_LEAVE_API_NOINIT(ret_value) +} /* end H5VLattr_write() */ + + +/*------------------------------------------------------------------------- + * Function: H5VL__attr_get + * + * Purpose: Get specific information about the attribute through the VOL + * + * Return: Success: Non-negative + * Failure: Negative + * + *------------------------------------------------------------------------- + */ +static herr_t +H5VL__attr_get(void *obj, const H5VL_class_t *cls, H5VL_attr_get_t get_type, + hid_t dxpl_id, void **req, va_list arguments) +{ + herr_t ret_value = SUCCEED; /* Return value */ + + FUNC_ENTER_STATIC + + /* Check if the corresponding VOL callback exists */ + if(NULL == cls->attr_cls.get) + HGOTO_ERROR(H5E_VOL, H5E_UNSUPPORTED, FAIL, "VOL connector has no 'attr get' method") + + /* Call the corresponding VOL callback */ + if((cls->attr_cls.get)(obj, get_type, dxpl_id, req, arguments) < 0) + HGOTO_ERROR(H5E_VOL, H5E_CANTGET, FAIL, "attribute get failed") + +done: + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5VL__attr_get() */ + + +/*------------------------------------------------------------------------- + * Function: H5VL_attr_get + * + * Purpose: Get specific information about the attribute through the VOL + * + * Return: Success: Non-negative + * Failure: Negative + * + *------------------------------------------------------------------------- + */ +herr_t +H5VL_attr_get(const H5VL_object_t *vol_obj, H5VL_attr_get_t get_type, + hid_t dxpl_id, void **req, ...) +{ + va_list arguments; /* Argument list passed from the API call */ + hbool_t arg_started = FALSE; /* Whether the va_list has been started */ + hbool_t vol_wrapper_set = FALSE; /* Whether the VOL object wrapping context was set up */ + herr_t ret_value = SUCCEED; /* Return value */ + + FUNC_ENTER_NOAPI(FAIL) + + /* Set wrapper info in API context */ + if(H5VL_set_vol_wrapper(vol_obj->data, vol_obj->connector) < 0) + HGOTO_ERROR(H5E_VOL, H5E_CANTSET, FAIL, "can't set VOL wrapper info") + vol_wrapper_set = TRUE; + + /* Call the corresponding internal VOL routine */ + HDva_start(arguments, req); + arg_started = TRUE; + if(H5VL__attr_get(vol_obj->data, vol_obj->connector->cls, get_type, dxpl_id, req, arguments) < 0) + HGOTO_ERROR(H5E_VOL, H5E_CANTGET, FAIL, "attribute get failed") + +done: + /* End access to the va_list, if we started it */ + if(arg_started) + HDva_end(arguments); + + /* Reset object wrapping info in API context */ + if(vol_wrapper_set && H5VL_reset_vol_wrapper() < 0) + HDONE_ERROR(H5E_VOL, H5E_CANTRESET, FAIL, "can't reset VOL wrapper info") + + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5VL_attr_get() */ + + +/*------------------------------------------------------------------------- + * Function: H5VLattr_get + * + * Purpose: Gets information about the attribute + * + * Return: Success: Non-negative + * Failure: Negative + * + *------------------------------------------------------------------------- + */ +herr_t +H5VLattr_get(void *obj, hid_t connector_id, H5VL_attr_get_t get_type, hid_t dxpl_id, + void **req, va_list arguments) +{ + H5VL_class_t *cls; /* VOL connector's class struct */ + herr_t ret_value = SUCCEED; /* Return value */ + + FUNC_ENTER_API_NOINIT + H5TRACE6("e", "*xiVai**xx", obj, connector_id, get_type, dxpl_id, req, + arguments); + + /* Check args and get class pointer */ + if(NULL == obj) + HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "invalid object") + if(NULL == (cls = (H5VL_class_t *)H5I_object_verify(connector_id, H5I_VOL))) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a VOL connector ID") + + /* Call the corresponding internal VOL routine */ + if(H5VL__attr_get(obj, cls, get_type, dxpl_id, req, arguments) < 0) + HGOTO_ERROR(H5E_VOL, H5E_CANTGET, FAIL, "unable to get attribute information") + +done: + FUNC_LEAVE_API_NOINIT(ret_value) +} /* end H5VLattr_get() */ + + +/*------------------------------------------------------------------------- + * Function: H5VL__attr_specific + * + * Purpose: Specific operation on attributes through the VOL + * + * Return: Success: Non-negative + * Failure: Negative + * + *------------------------------------------------------------------------- + */ +static herr_t +H5VL__attr_specific(void *obj, const H5VL_loc_params_t *loc_params, const H5VL_class_t *cls, + H5VL_attr_specific_t specific_type, hid_t dxpl_id, void **req, + va_list arguments) +{ + herr_t ret_value = SUCCEED; /* Return value */ + + FUNC_ENTER_STATIC + + /* Check if the corresponding VOL callback exists */ + if(NULL == cls->attr_cls.specific) + HGOTO_ERROR(H5E_VOL, H5E_UNSUPPORTED, FAIL, "VOL connector has no 'attr specific' method") + + /* Call the corresponding VOL callback */ + if((ret_value = (cls->attr_cls.specific)(obj, loc_params, specific_type, dxpl_id, req, arguments)) < 0) + HGOTO_ERROR(H5E_VOL, H5E_CANTOPERATE, FAIL, "unable to execute attribute specific callback") + +done: + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5VL__attr_specific() */ + + +/*------------------------------------------------------------------------- + * Function: H5VL_attr_specific + * + * Purpose: Specific operation on attributes through the VOL + * + * Return: Success: Non-negative + * Failure: Negative + * + *------------------------------------------------------------------------- + */ +herr_t +H5VL_attr_specific(const H5VL_object_t *vol_obj, const H5VL_loc_params_t *loc_params, + H5VL_attr_specific_t specific_type, hid_t dxpl_id, void **req, ...) +{ + va_list arguments; /* Argument list passed from the API call */ + hbool_t arg_started = FALSE; /* Whether the va_list has been started */ + hbool_t vol_wrapper_set = FALSE; /* Whether the VOL object wrapping context was set up */ + herr_t ret_value = SUCCEED; /* Return value */ + + FUNC_ENTER_NOAPI(FAIL) + + /* Set wrapper info in API context */ + if(H5VL_set_vol_wrapper(vol_obj->data, vol_obj->connector) < 0) + HGOTO_ERROR(H5E_VOL, H5E_CANTSET, FAIL, "can't set VOL wrapper info") + vol_wrapper_set = TRUE; + + /* Call the corresponding internal VOL routine */ + HDva_start(arguments, req); + arg_started = TRUE; + if((ret_value = H5VL__attr_specific(vol_obj->data, loc_params, vol_obj->connector->cls, specific_type, dxpl_id, req, arguments)) < 0) + HGOTO_ERROR(H5E_VOL, H5E_CANTOPERATE, FAIL, "unable to execute attribute specific callback") + +done: + /* End access to the va_list, if we started it */ + if(arg_started) + HDva_end(arguments); + + /* Reset object wrapping info in API context */ + if(vol_wrapper_set && H5VL_reset_vol_wrapper() < 0) + HDONE_ERROR(H5E_VOL, H5E_CANTRESET, FAIL, "can't reset VOL wrapper info") + + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5VL_attr_specific() */ + + +/*------------------------------------------------------------------------- + * Function: H5VLattr_specific + * + * Purpose: Performs a connector-specific operation on an attribute + * + * Return: Success: Non-negative + * Failure: Negative + * + *------------------------------------------------------------------------- + */ +herr_t +H5VLattr_specific(void *obj, const H5VL_loc_params_t *loc_params, hid_t connector_id, + H5VL_attr_specific_t specific_type, hid_t dxpl_id, void **req, va_list arguments) +{ + H5VL_class_t *cls; /* VOL connector's class struct */ + herr_t ret_value = SUCCEED; /* Return value */ + + FUNC_ENTER_API_NOINIT + H5TRACE7("e", "*x*xiVbi**xx", obj, loc_params, connector_id, specific_type, + dxpl_id, req, arguments); + + /* Check args and get class pointer */ + if(NULL == obj) + HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "invalid object") + if(NULL == (cls = (H5VL_class_t *)H5I_object_verify(connector_id, H5I_VOL))) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a VOL connector ID") + + /* Call the corresponding internal VOL routine */ + if((ret_value = H5VL__attr_specific(obj, loc_params, cls, specific_type, dxpl_id, req, arguments)) < 0) + HGOTO_ERROR(H5E_VOL, H5E_CANTOPERATE, FAIL, "unable to execute attribute specific callback") + +done: + FUNC_LEAVE_API_NOINIT(ret_value) +} /* end H5VLattr_specific() */ + + +/*------------------------------------------------------------------------- + * Function: H5VL__attr_optional + * + * Purpose: Optional operation specific to connectors. + * + * Return: Success: Non-negative + * Failure: Negative + * + *------------------------------------------------------------------------- + */ +static herr_t +H5VL__attr_optional(void *obj, const H5VL_class_t *cls, hid_t dxpl_id, + void **req, va_list arguments) +{ + herr_t ret_value = SUCCEED; /* Return value */ + + FUNC_ENTER_STATIC + + /* Check if the corresponding VOL callback exists */ + if(NULL == cls->attr_cls.optional) + HGOTO_ERROR(H5E_VOL, H5E_UNSUPPORTED, FAIL, "VOL connector has no 'attr optional' method") + + /* Call the corresponding VOL callback */ + if((ret_value = (cls->attr_cls.optional)(obj, dxpl_id, req, arguments)) < 0) + HGOTO_ERROR(H5E_VOL, H5E_CANTOPERATE, FAIL, "unable to execute attribute optional callback") + +done: + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5VL__attr_optional() */ + + +/*------------------------------------------------------------------------- + * Function: H5VL_attr_optional + * + * Purpose: Optional operation specific to connectors. + * + * Return: Success: Non-negative + * Failure: Negative + * + *------------------------------------------------------------------------- + */ +herr_t +H5VL_attr_optional(const H5VL_object_t *vol_obj, hid_t dxpl_id, void **req, ...) +{ + va_list arguments; /* Argument list passed from the API call */ + hbool_t arg_started = FALSE; /* Whether the va_list has been started */ + hbool_t vol_wrapper_set = FALSE; /* Whether the VOL object wrapping context was set up */ + herr_t ret_value = SUCCEED; /* Return value */ + + FUNC_ENTER_NOAPI(FAIL) + + /* Set wrapper info in API context */ + if(H5VL_set_vol_wrapper(vol_obj->data, vol_obj->connector) < 0) + HGOTO_ERROR(H5E_VOL, H5E_CANTSET, FAIL, "can't set VOL wrapper info") + vol_wrapper_set = TRUE; + + /* Call the corresponding internal VOL routine */ + HDva_start(arguments, req); + arg_started = TRUE; + if((ret_value = H5VL__attr_optional(vol_obj->data, vol_obj->connector->cls, dxpl_id, req, arguments)) < 0) + HGOTO_ERROR(H5E_VOL, H5E_CANTOPERATE, FAIL, "unable to execute attribute optional callback") + +done: + /* End access to the va_list, if we started it */ + if(arg_started) + HDva_end(arguments); + + /* Reset object wrapping info in API context */ + if(vol_wrapper_set && H5VL_reset_vol_wrapper() < 0) + HDONE_ERROR(H5E_VOL, H5E_CANTRESET, FAIL, "can't reset VOL wrapper info") + + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5VL_attr_optional() */ + + +/*------------------------------------------------------------------------- + * Function: H5VLattr_optional + * + * Purpose: Performs an optional connector-specific operation on an attribute + * + * Return: Success: Non-negative + * Failure: Negative + * + *------------------------------------------------------------------------- + */ +herr_t +H5VLattr_optional(void *obj, hid_t connector_id, hid_t dxpl_id, void **req, va_list arguments) +{ + H5VL_class_t *cls; /* VOL connector's class struct */ + herr_t ret_value = SUCCEED; /* Return value */ + + FUNC_ENTER_API_NOINIT + H5TRACE5("e", "*xii**xx", obj, connector_id, dxpl_id, req, arguments); + + /* Check args and get class pointer */ + if(NULL == obj) + HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "invalid object") + if(NULL == (cls = (H5VL_class_t *)H5I_object_verify(connector_id, H5I_VOL))) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a VOL connector ID") + + /* Call the corresponding internal VOL routine */ + if((ret_value = H5VL__attr_optional(obj, cls, dxpl_id, req, arguments)) < 0) + HGOTO_ERROR(H5E_VOL, H5E_CANTOPERATE, FAIL, "unable to execute attribute optional callback") + +done: + FUNC_LEAVE_API_NOINIT(ret_value) +} /* end H5VLattr_optional() */ + + +/*------------------------------------------------------------------------- + * Function: H5VL__attr_close + * + * Purpose: Closes an attribute through the VOL + * + * Return: Success: Non-negative + * Failure: Negative + * + *------------------------------------------------------------------------- + */ +static herr_t +H5VL__attr_close(void *obj, const H5VL_class_t *cls, hid_t dxpl_id, void **req) +{ + herr_t ret_value = SUCCEED; /* Return value */ + + FUNC_ENTER_STATIC + + /* Check if the corresponding VOL callback exists */ + if(NULL == cls->attr_cls.close) + HGOTO_ERROR(H5E_VOL, H5E_UNSUPPORTED, FAIL, "VOL connector has no 'attr close' method") + + /* Call the corresponding VOL callback */ + if((cls->attr_cls.close)(obj, dxpl_id, req) < 0) + HGOTO_ERROR(H5E_VOL, H5E_CANTCLOSEOBJ, FAIL, "attribute close failed") + +done: + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5VL__attr_close() */ + + +/*------------------------------------------------------------------------- + * Function: H5VL_attr_close + * + * Purpose: Closes an attribute through the VOL + * + * Return: Success: Non-negative + * Failure: Negative + * + *------------------------------------------------------------------------- + */ +herr_t +H5VL_attr_close(const H5VL_object_t *vol_obj, hid_t dxpl_id, void **req) +{ + herr_t ret_value = SUCCEED; /* Return value */ + + FUNC_ENTER_NOAPI(FAIL) + + /* Sanity check */ + HDassert(vol_obj); + + /* Call the corresponding internal VOL routine */ + if(H5VL__attr_close(vol_obj->data, vol_obj->connector->cls, dxpl_id, req) < 0) + HGOTO_ERROR(H5E_VOL, H5E_CANTCLOSEOBJ, FAIL, "attribute close failed") + +done: + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5VL_attr_close() */ + + +/*------------------------------------------------------------------------- + * Function: H5VLattr_close + * + * Purpose: Closes an attribute + * + * Return: Success: Non-negative + * Failure: Negative + * + *------------------------------------------------------------------------- + */ +herr_t +H5VLattr_close(void *obj, hid_t connector_id, hid_t dxpl_id, void **req) +{ + H5VL_class_t *cls; /* VOL connector's class struct */ + herr_t ret_value = SUCCEED; /* Return value */ + + FUNC_ENTER_API_NOINIT + H5TRACE4("e", "*xii**x", obj, connector_id, dxpl_id, req); + + /* Check args and get class pointer */ + if(NULL == obj) + HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "invalid object") + if(NULL == (cls = (H5VL_class_t *)H5I_object_verify(connector_id, H5I_VOL))) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a VOL connector ID") + + /* Call the corresponding internal VOL routine */ + if(H5VL__attr_close(obj, cls, dxpl_id, req) < 0) + HGOTO_ERROR(H5E_VOL, H5E_CANTCLOSEOBJ, FAIL, "unable to close attribute") + +done: + FUNC_LEAVE_API_NOINIT(ret_value) +} /* end H5VLattr_close() */ + + +/*------------------------------------------------------------------------- + * Function: H5VL__dataset_create + * + * Purpose: Creates a dataset through the VOL + * + * Return: Success: Pointer to new dataset + * Failure: NULL + * + *------------------------------------------------------------------------- + */ +static void * +H5VL__dataset_create(void *obj, const H5VL_loc_params_t *loc_params, const H5VL_class_t *cls, + const char *name, hid_t dcpl_id, hid_t dapl_id, hid_t dxpl_id, void **req) +{ + void *ret_value = NULL; /* Return value */ + + FUNC_ENTER_STATIC + + /* Check if the corresponding VOL callback exists */ + if(NULL == cls->dataset_cls.create) + HGOTO_ERROR(H5E_VOL, H5E_UNSUPPORTED, NULL, "VOL connector has no 'dataset create' method") + + /* Call the corresponding VOL callback */ + if(NULL == (ret_value = (cls->dataset_cls.create)(obj, loc_params, name, dcpl_id, dapl_id, dxpl_id, req))) + HGOTO_ERROR(H5E_VOL, H5E_CANTCREATE, NULL, "dataset create failed") + +done: + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5VL__dataset_create() */ + + +/*------------------------------------------------------------------------- + * Function: H5VL_dataset_create + * + * Purpose: Creates a dataset through the VOL + * + * Return: Success: Pointer to new dataset + * Failure: NULL + * + *------------------------------------------------------------------------- + */ +void * +H5VL_dataset_create(const H5VL_object_t *vol_obj, const H5VL_loc_params_t *loc_params, + const char *name, hid_t dcpl_id, hid_t dapl_id, hid_t dxpl_id, void **req) +{ + hbool_t vol_wrapper_set = FALSE; /* Whether the VOL object wrapping context was set up */ + void *ret_value = NULL; /* Return value */ + + FUNC_ENTER_NOAPI(NULL) + + /* Set wrapper info in API context */ + if(H5VL_set_vol_wrapper(vol_obj->data, vol_obj->connector) < 0) + HGOTO_ERROR(H5E_VOL, H5E_CANTSET, NULL, "can't set VOL wrapper info") + vol_wrapper_set = TRUE; + + /* Call the corresponding internal VOL routine */ + if(NULL == (ret_value = H5VL__dataset_create(vol_obj->data, loc_params, vol_obj->connector->cls, name, dcpl_id, dapl_id, dxpl_id, req))) + HGOTO_ERROR(H5E_VOL, H5E_CANTCREATE, NULL, "dataset create failed") + +done: + /* Reset object wrapping info in API context */ + if(vol_wrapper_set && H5VL_reset_vol_wrapper() < 0) + HDONE_ERROR(H5E_VOL, H5E_CANTRESET, NULL, "can't reset VOL wrapper info") + + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5VL_dataset_create() */ + + +/*------------------------------------------------------------------------- + * Function: H5VLdataset_create + * + * Purpose: Creates a dataset + * + * Return: Success: Pointer to the new dataset + * Failure: NULL + * + *------------------------------------------------------------------------- + */ +void * +H5VLdataset_create(void *obj, const H5VL_loc_params_t *loc_params, hid_t connector_id, + const char *name, hid_t dcpl_id, hid_t dapl_id, hid_t dxpl_id, void **req) +{ + H5VL_class_t *cls; /* VOL connector's class struct */ + void *ret_value = NULL; /* Return value */ + + FUNC_ENTER_API_NOINIT + H5TRACE8("*x", "*x*xi*siii**x", obj, loc_params, connector_id, name, dcpl_id, + dapl_id, dxpl_id, req); + + /* Check args and get class pointer */ + if(NULL == obj) + HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, NULL, "invalid object") + if(NULL == (cls = (H5VL_class_t *)H5I_object_verify(connector_id, H5I_VOL))) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, NULL, "not a VOL connector ID") + + /* Call the corresponding internal VOL routine */ + if(NULL == (ret_value = H5VL__dataset_create(obj, loc_params, cls, name, dcpl_id, dapl_id, dxpl_id, req))) + HGOTO_ERROR(H5E_VOL, H5E_CANTCREATE, NULL, "unable to create dataset") + +done: + FUNC_LEAVE_API_NOINIT(ret_value) +} /* end H5VLdataset_create() */ + + +/*------------------------------------------------------------------------- + * Function: H5VL__dataset_open + * + * Purpose: Opens a dataset through the VOL + * + * Return: Success: Pointer to dataset + * Failure: NULL + * + *------------------------------------------------------------------------- + */ +static void * +H5VL__dataset_open(void *obj, const H5VL_loc_params_t *loc_params, const H5VL_class_t *cls, const char *name, + hid_t dapl_id, hid_t dxpl_id, void **req) +{ + void *ret_value = NULL; /* Return value */ + + FUNC_ENTER_STATIC + + /* Check if the corresponding VOL callback exists */ + if(NULL == cls->dataset_cls.open) + HGOTO_ERROR(H5E_VOL, H5E_UNSUPPORTED, NULL, "VOL connector has no 'dataset open' method") + + /* Call the corresponding VOL callback */ + if(NULL == (ret_value = (cls->dataset_cls.open)(obj, loc_params, name, dapl_id, dxpl_id, req))) + HGOTO_ERROR(H5E_VOL, H5E_CANTOPENOBJ, NULL, "dataset open failed") + +done: + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5VL__dataset_open() */ + + +/*------------------------------------------------------------------------- + * Function: H5VL_dataset_open + * + * Purpose: Opens a dataset through the VOL + * + * Return: Success: Pointer to dataset + * Failure: NULL + * + *------------------------------------------------------------------------- + */ +void * +H5VL_dataset_open(const H5VL_object_t *vol_obj, const H5VL_loc_params_t *loc_params, + const char *name, hid_t dapl_id, hid_t dxpl_id, void **req) +{ + hbool_t vol_wrapper_set = FALSE; /* Whether the VOL object wrapping context was set up */ + void *ret_value = NULL; /* Return value */ + + FUNC_ENTER_NOAPI(NULL) + + /* Set wrapper info in API context */ + if(H5VL_set_vol_wrapper(vol_obj->data, vol_obj->connector) < 0) + HGOTO_ERROR(H5E_VOL, H5E_CANTSET, NULL, "can't set VOL wrapper info") + vol_wrapper_set = TRUE; + + /* Call the corresponding internal VOL routine */ + if(NULL == (ret_value = H5VL__dataset_open(vol_obj->data, loc_params, vol_obj->connector->cls, name, dapl_id, dxpl_id, req))) + HGOTO_ERROR(H5E_VOL, H5E_CANTOPENOBJ, NULL, "dataset open failed") + +done: + /* Reset object wrapping info in API context */ + if(vol_wrapper_set && H5VL_reset_vol_wrapper() < 0) + HDONE_ERROR(H5E_VOL, H5E_CANTRESET, NULL, "can't reset VOL wrapper info") + + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5VL_dataset_open() */ + + +/*------------------------------------------------------------------------- + * Function: H5VLdataset_open + * + * Purpose: Opens a dataset + * + * Return: Success: Pointer to the new dataset + * Failure: NULL + * + *------------------------------------------------------------------------- + */ +void * +H5VLdataset_open(void *obj, const H5VL_loc_params_t *loc_params, hid_t connector_id, + const char *name, hid_t dapl_id, hid_t dxpl_id, void **req) +{ + H5VL_class_t *cls; /* VOL connector's class struct */ + void *ret_value = NULL; /* Return value */ + + FUNC_ENTER_API_NOINIT + H5TRACE7("*x", "*x*xi*sii**x", obj, loc_params, connector_id, name, dapl_id, + dxpl_id, req); + + /* Check args and get class pointer */ + if(NULL == obj) + HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, NULL, "invalid object") + if(NULL == (cls = (H5VL_class_t *)H5I_object_verify(connector_id, H5I_VOL))) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, NULL, "not a VOL connector ID") + + /* Call the corresponding internal VOL routine */ + if(NULL == (ret_value = H5VL__dataset_open(obj, loc_params, cls, name, dapl_id, dxpl_id, req))) + HGOTO_ERROR(H5E_VOL, H5E_CANTOPENOBJ, NULL, "unable to open dataset") + +done: + FUNC_LEAVE_API_NOINIT(ret_value) +} /* end H5VLdataset_open() */ + + +/*------------------------------------------------------------------------- + * Function: H5VL__dataset_read + * + * Purpose: Reads data from dataset through the VOL +* + * Return: Success: Non-negative + * Failure: Negative + * + *------------------------------------------------------------------------- + */ +static herr_t +H5VL__dataset_read(void *obj, const H5VL_class_t *cls, hid_t mem_type_id, + hid_t mem_space_id, hid_t file_space_id, hid_t plist_id, void *buf, + void **req) +{ + herr_t ret_value = SUCCEED; /* Return value */ + + FUNC_ENTER_STATIC + + /* Check if the corresponding VOL callback exists */ + if(NULL == cls->dataset_cls.read) + HGOTO_ERROR(H5E_VOL, H5E_UNSUPPORTED, FAIL, "VOL connector has no 'dataset read' method") + + /* Call the corresponding VOL callback */ + if((cls->dataset_cls.read)(obj, mem_type_id, mem_space_id, file_space_id, plist_id, buf, req) < 0) + HGOTO_ERROR(H5E_VOL, H5E_READERROR, FAIL, "dataset read failed") + +done: + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5VL__dataset_read() */ + + +/*------------------------------------------------------------------------- + * Function: H5VL_dataset_read + * + * Purpose: Reads data from dataset through the VOL +* + * Return: Success: Non-negative + * Failure: Negative + * + *------------------------------------------------------------------------- + */ +herr_t +H5VL_dataset_read(const H5VL_object_t *vol_obj, hid_t mem_type_id, + hid_t mem_space_id, hid_t file_space_id, hid_t plist_id, void *buf, + void **req) +{ + hbool_t vol_wrapper_set = FALSE; /* Whether the VOL object wrapping context was set up */ + herr_t ret_value = SUCCEED; /* Return value */ + + FUNC_ENTER_NOAPI(FAIL) + + /* Set wrapper info in API context */ + if(H5VL_set_vol_wrapper(vol_obj->data, vol_obj->connector) < 0) + HGOTO_ERROR(H5E_VOL, H5E_CANTSET, FAIL, "can't set VOL wrapper info") + vol_wrapper_set = TRUE; + + /* Call the corresponding internal VOL routine */ + if(H5VL__dataset_read(vol_obj->data, vol_obj->connector->cls, mem_type_id, mem_space_id, file_space_id, plist_id, buf, req) < 0) + HGOTO_ERROR(H5E_VOL, H5E_READERROR, FAIL, "dataset read failed") + +done: + /* Reset object wrapping info in API context */ + if(vol_wrapper_set && H5VL_reset_vol_wrapper() < 0) + HDONE_ERROR(H5E_VOL, H5E_CANTRESET, FAIL, "can't reset VOL wrapper info") + + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5VL_dataset_read() */ + + +/*------------------------------------------------------------------------- + * Function: H5VLdataset_read + * + * Purpose: Reads data from a dataset + * + * Return: Success: Non-negative + * Failure: Negative + * + *------------------------------------------------------------------------- + */ +herr_t +H5VLdataset_read(void *obj, hid_t connector_id, hid_t mem_type_id, hid_t mem_space_id, + hid_t file_space_id, hid_t plist_id, void *buf, void **req) +{ + H5VL_class_t *cls; /* VOL connector's class struct */ + herr_t ret_value = SUCCEED; /* Return value */ + + FUNC_ENTER_API_NOINIT + H5TRACE8("e", "*xiiiii*x**x", obj, connector_id, mem_type_id, mem_space_id, + file_space_id, plist_id, buf, req); + + /* Check args and get class pointer */ + if(NULL == obj) + HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "invalid object") + if(NULL == (cls = (H5VL_class_t *)H5I_object_verify(connector_id, H5I_VOL))) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a VOL connector ID") + + /* Call the corresponding internal VOL routine */ + if(H5VL__dataset_read(obj, cls, mem_type_id, mem_space_id, file_space_id, plist_id, buf, req) < 0) + HGOTO_ERROR(H5E_VOL, H5E_CANTINIT, FAIL, "unable to read dataset") + +done: + FUNC_LEAVE_API_NOINIT(ret_value) +} /* end H5VLdataset_read() */ + + +/*------------------------------------------------------------------------- + * Function: H5VL__dataset_write + * + * Purpose: Writes data from dataset through the VOL + * + * Return: Success: Non-negative + * Failure: Negative + * + *------------------------------------------------------------------------- + */ +static herr_t +H5VL__dataset_write(void *obj, const H5VL_class_t *cls, hid_t mem_type_id, + hid_t mem_space_id, hid_t file_space_id, hid_t plist_id, const void *buf, + void **req) +{ + herr_t ret_value = SUCCEED; /* Return value */ + + FUNC_ENTER_STATIC + + /* Check if the corresponding VOL callback exists */ + if(NULL == cls->dataset_cls.write) + HGOTO_ERROR(H5E_VOL, H5E_UNSUPPORTED, FAIL, "VOL connector has no 'dataset write' method") + + /* Call the corresponding VOL callback */ + if((cls->dataset_cls.write)(obj, mem_type_id, mem_space_id, file_space_id, plist_id, buf, req) < 0) + HGOTO_ERROR(H5E_VOL, H5E_WRITEERROR, FAIL, "dataset write failed") + +done: + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5VL__dataset_write() */ + + +/*------------------------------------------------------------------------- + * Function: H5VL_dataset_write + * + * Purpose: Writes data from dataset through the VOL + * + * Return: Success: Non-negative + * Failure: Negative + * + *------------------------------------------------------------------------- + */ +herr_t +H5VL_dataset_write(const H5VL_object_t *vol_obj, hid_t mem_type_id, + hid_t mem_space_id, hid_t file_space_id, hid_t plist_id, const void *buf, + void **req) +{ + hbool_t vol_wrapper_set = FALSE; /* Whether the VOL object wrapping context was set up */ + herr_t ret_value = SUCCEED; /* Return value */ + + FUNC_ENTER_NOAPI(FAIL) + + /* Set wrapper info in API context */ + if(H5VL_set_vol_wrapper(vol_obj->data, vol_obj->connector) < 0) + HGOTO_ERROR(H5E_VOL, H5E_CANTSET, FAIL, "can't set VOL wrapper info") + vol_wrapper_set = TRUE; + + /* Call the corresponding internal VOL routine */ + if(H5VL__dataset_write(vol_obj->data, vol_obj->connector->cls, mem_type_id, mem_space_id, file_space_id, plist_id, buf, req) < 0) + HGOTO_ERROR(H5E_VOL, H5E_WRITEERROR, FAIL, "dataset write failed") + +done: + /* Reset object wrapping info in API context */ + if(vol_wrapper_set && H5VL_reset_vol_wrapper() < 0) + HDONE_ERROR(H5E_VOL, H5E_CANTRESET, FAIL, "can't reset VOL wrapper info") + + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5VL_dataset_write() */ + + +/*------------------------------------------------------------------------- + * Function: H5VLdataset_write + * + * Purpose: Writes data to a dataset + * + * Return: Success: Non-negative + * Failure: Negative + * + *------------------------------------------------------------------------- + */ +herr_t +H5VLdataset_write(void *obj, hid_t connector_id, 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_class_t *cls; /* VOL connector's class struct */ + herr_t ret_value = SUCCEED; /* Return value */ + + FUNC_ENTER_API_NOINIT + H5TRACE8("e", "*xiiiii*x**x", obj, connector_id, mem_type_id, mem_space_id, + file_space_id, plist_id, buf, req); + + /* Check args and get class pointer */ + if(NULL == obj) + HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "invalid object") + if(NULL == (cls = (H5VL_class_t *)H5I_object_verify(connector_id, H5I_VOL))) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a VOL connector ID") + + /* Call the corresponding internal VOL routine */ + if(H5VL__dataset_write(obj, cls, mem_type_id, mem_space_id, file_space_id, plist_id, buf, req) < 0) + HGOTO_ERROR(H5E_VOL, H5E_CANTINIT, FAIL, "unable to write dataset") + +done: + FUNC_LEAVE_API_NOINIT(ret_value) +} /* end H5VLdataset_write() */ + + +/*------------------------------------------------------------------------- + * Function: H5VL__dataset_get + * + * Purpose: Get specific information about the dataset through the VOL + * + * Return: Success: Non-negative + * Failure: Negative + * + *------------------------------------------------------------------------- + */ +static herr_t +H5VL__dataset_get(void *obj, const H5VL_class_t *cls, H5VL_dataset_get_t get_type, + hid_t dxpl_id, void **req, va_list arguments) +{ + herr_t ret_value = SUCCEED; /* Return value */ + + FUNC_ENTER_STATIC + + /* Check if the corresponding VOL callback exists */ + if(NULL == cls->dataset_cls.get) + HGOTO_ERROR(H5E_VOL, H5E_UNSUPPORTED, FAIL, "VOL connector has no 'dataset get' method") + + /* Call the corresponding VOL callback */ + if((cls->dataset_cls.get)(obj, get_type, dxpl_id, req, arguments) < 0) + HGOTO_ERROR(H5E_VOL, H5E_CANTGET, FAIL, "dataset get failed") + +done: + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5VL__dataset_get() */ + + +/*------------------------------------------------------------------------- + * Function: H5VL_dataset_get + * + * Purpose: Get specific information about the dataset through the VOL + * + * Return: Success: Non-negative + * Failure: Negative + * + *------------------------------------------------------------------------- + */ +herr_t +H5VL_dataset_get(const H5VL_object_t *vol_obj, H5VL_dataset_get_t get_type, + hid_t dxpl_id, void **req, ...) +{ + va_list arguments; /* Argument list passed from the API call */ + hbool_t arg_started = FALSE; /* Whether the va_list has been started */ + hbool_t vol_wrapper_set = FALSE; /* Whether the VOL object wrapping context was set up */ + herr_t ret_value = SUCCEED; /* Return value */ + + FUNC_ENTER_NOAPI(FAIL) + + /* Set wrapper info in API context */ + if(H5VL_set_vol_wrapper(vol_obj->data, vol_obj->connector) < 0) + HGOTO_ERROR(H5E_VOL, H5E_CANTSET, FAIL, "can't set VOL wrapper info") + vol_wrapper_set = TRUE; + + /* Call the corresponding internal VOL routine */ + HDva_start(arguments, req); + arg_started = TRUE; + if(H5VL__dataset_get(vol_obj->data, vol_obj->connector->cls, get_type, dxpl_id, req, arguments) < 0) + HGOTO_ERROR(H5E_VOL, H5E_CANTGET, FAIL, "dataset get failed") + +done: + /* End access to the va_list, if we started it */ + if(arg_started) + HDva_end(arguments); + + /* Reset object wrapping info in API context */ + if(vol_wrapper_set && H5VL_reset_vol_wrapper() < 0) + HDONE_ERROR(H5E_VOL, H5E_CANTRESET, FAIL, "can't reset VOL wrapper info") + + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5VL_dataset_get() */ + + +/*------------------------------------------------------------------------- + * Function: H5VLdataset_get + * + * Purpose: Gets information about a dataset + * + * Return: Success: Non-negative + * Failure: Negative + * + *------------------------------------------------------------------------- + */ +herr_t +H5VLdataset_get(void *obj, hid_t connector_id, H5VL_dataset_get_t get_type, + hid_t dxpl_id, void **req, va_list arguments) +{ + H5VL_class_t *cls; /* VOL connector's class struct */ + herr_t ret_value = SUCCEED; /* Return value */ + + FUNC_ENTER_API_NOINIT + H5TRACE6("e", "*xiVci**xx", obj, connector_id, get_type, dxpl_id, req, + arguments); + + /* Check args and get class pointer */ + if(NULL == obj) + HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "invalid object") + if(NULL == (cls = (H5VL_class_t *)H5I_object_verify(connector_id, H5I_VOL))) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a VOL connector ID") + + /* Call the corresponding internal VOL routine */ + if(H5VL__dataset_get(obj, cls, get_type, dxpl_id, req, arguments) < 0) + HGOTO_ERROR(H5E_VOL, H5E_CANTGET, FAIL, "unable to execute dataset get callback") + +done: + FUNC_LEAVE_API_NOINIT(ret_value) +} /* end H5VLdataset_get() */ + + +/*------------------------------------------------------------------------- + * Function: H5VL__dataset_specific + * + * Purpose: Specific operation on datasets through the VOL + * + * Return: Success: Non-negative + * Failure: Negative + * + *------------------------------------------------------------------------- + */ +static herr_t +H5VL__dataset_specific(void *obj, const H5VL_class_t *cls, H5VL_dataset_specific_t specific_type, + hid_t dxpl_id, void **req, va_list arguments) +{ + herr_t ret_value = SUCCEED; /* Return value */ + + FUNC_ENTER_STATIC + + /* Check if the corresponding VOL callback exists */ + if(NULL == cls->dataset_cls.specific) + HGOTO_ERROR(H5E_VOL, H5E_UNSUPPORTED, FAIL, "VOL connector has no 'dataset specific' method") + + /* Call the corresponding VOL callback */ + if((cls->dataset_cls.specific)(obj, specific_type, dxpl_id, req, arguments) < 0) + HGOTO_ERROR(H5E_VOL, H5E_CANTOPERATE, FAIL, "unable to execute dataset specific callback") + +done: + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5VL__dataset_specific() */ + + +/*------------------------------------------------------------------------- + * Function: H5VL_dataset_specific + * + * Purpose: Specific operation on datasets through the VOL + * + * Return: Success: Non-negative + * Failure: Negative + * + *------------------------------------------------------------------------- + */ +herr_t +H5VL_dataset_specific(const H5VL_object_t *vol_obj, H5VL_dataset_specific_t specific_type, + hid_t dxpl_id, void **req, ...) +{ + va_list arguments; /* Argument list passed from the API call */ + hbool_t arg_started = FALSE; /* Whether the va_list has been started */ + hbool_t vol_wrapper_set = FALSE; /* Whether the VOL object wrapping context was set up */ + herr_t ret_value = SUCCEED; /* Return value */ + + FUNC_ENTER_NOAPI(FAIL) + + /* Set wrapper info in API context */ + if(H5VL_set_vol_wrapper(vol_obj->data, vol_obj->connector) < 0) + HGOTO_ERROR(H5E_VOL, H5E_CANTSET, FAIL, "can't set VOL wrapper info") + vol_wrapper_set = TRUE; + + /* Call the corresponding internal VOL routine */ + HDva_start(arguments, req); + arg_started = TRUE; + if(H5VL__dataset_specific(vol_obj->data, vol_obj->connector->cls, specific_type, dxpl_id, req, arguments) < 0) + HGOTO_ERROR(H5E_VOL, H5E_CANTOPERATE, FAIL, "unable to execute dataset specific callback") + +done: + /* End access to the va_list, if we started it */ + if(arg_started) + HDva_end(arguments); + + /* Reset object wrapping info in API context */ + if(vol_wrapper_set && H5VL_reset_vol_wrapper() < 0) + HDONE_ERROR(H5E_VOL, H5E_CANTRESET, FAIL, "can't reset VOL wrapper info") + + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5VL_dataset_specific() */ + + +/*------------------------------------------------------------------------- + * Function: H5VLdataset_specific + * + * Purpose: Performs a connector-specific operation on a dataset + * + * Return: Success: Non-negative + * Failure: Negative + * + *------------------------------------------------------------------------- + */ +herr_t +H5VLdataset_specific(void *obj, hid_t connector_id, H5VL_dataset_specific_t specific_type, + hid_t dxpl_id, void **req, va_list arguments) +{ + H5VL_class_t *cls; /* VOL connector's class struct */ + herr_t ret_value = SUCCEED; /* Return value */ + + FUNC_ENTER_API_NOINIT + H5TRACE6("e", "*xiVdi**xx", obj, connector_id, specific_type, dxpl_id, req, + arguments); + + /* Check args and get class pointer */ + if(NULL == obj) + HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "invalid object") + if(NULL == (cls = (H5VL_class_t *)H5I_object_verify(connector_id, H5I_VOL))) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a VOL connector ID") + + /* Call the corresponding internal VOL routine */ + if(H5VL__dataset_specific(obj, cls, specific_type, dxpl_id, req, arguments) < 0) + HGOTO_ERROR(H5E_VOL, H5E_CANTOPERATE, FAIL, "unable to execute dataset specific callback") + +done: + FUNC_LEAVE_API_NOINIT(ret_value) +} /* end H5VLdataset_specific() */ + + +/*------------------------------------------------------------------------- + * Function: H5VL__dataset_optional + * + * Purpose: Optional operation specific to connectors. + * + * Return: Success: Non-negative + * Failure: Negative + * + *------------------------------------------------------------------------- + */ +static herr_t +H5VL__dataset_optional(void *obj, const H5VL_class_t *cls, hid_t dxpl_id, + void **req, va_list arguments) +{ + herr_t ret_value = SUCCEED; /* Return value */ + + FUNC_ENTER_STATIC + + /* Check if the corresponding VOL callback exists */ + if(NULL == cls->dataset_cls.optional) + HGOTO_ERROR(H5E_VOL, H5E_UNSUPPORTED, FAIL, "VOL connector has no 'dataset optional' method") + + /* Call the corresponding VOL callback */ + if((cls->dataset_cls.optional)(obj, dxpl_id, req, arguments) < 0) + HGOTO_ERROR(H5E_VOL, H5E_CANTOPERATE, FAIL, "unable to execute dataset optional callback") + +done: + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5VL__dataset_optional() */ + + +/*------------------------------------------------------------------------- + * Function: H5VL_dataset_optional + * + * Purpose: Optional operation specific to connectors. + * + * Return: Success: Non-negative + * Failure: Negative + * + *------------------------------------------------------------------------- + */ +herr_t +H5VL_dataset_optional(const H5VL_object_t *vol_obj, hid_t dxpl_id, + void **req, ...) +{ + va_list arguments; /* Argument list passed from the API call */ + hbool_t arg_started = FALSE; /* Whether the va_list has been started */ + hbool_t vol_wrapper_set = FALSE; /* Whether the VOL object wrapping context was set up */ + herr_t ret_value = SUCCEED; /* Return value */ + + FUNC_ENTER_NOAPI(FAIL) + + /* Call the corresponding VOL callback */ + /* Set wrapper info in API context */ + if(H5VL_set_vol_wrapper(vol_obj->data, vol_obj->connector) < 0) + HGOTO_ERROR(H5E_VOL, H5E_CANTSET, FAIL, "can't set VOL wrapper info") + vol_wrapper_set = TRUE; + + /* Call the corresponding internal VOL routine */ + HDva_start(arguments, req); + arg_started = TRUE; + if(H5VL__dataset_optional(vol_obj->data, vol_obj->connector->cls, dxpl_id, req, arguments) < 0) + HGOTO_ERROR(H5E_VOL, H5E_CANTOPERATE, FAIL, "unable to execute dataset optional callback") + +done: + /* End access to the va_list, if we started it */ + if(arg_started) + HDva_end(arguments); + + /* Reset object wrapping info in API context */ + if(vol_wrapper_set && H5VL_reset_vol_wrapper() < 0) + HDONE_ERROR(H5E_VOL, H5E_CANTRESET, FAIL, "can't reset VOL wrapper info") + + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5VL_dataset_optional() */ + + +/*------------------------------------------------------------------------- + * Function: H5VLdataset_optional + * + * Purpose: Performs an optional connector-specific operation on a dataset + * + * Return: Success: Non-negative + * Failure: Negative + * + *------------------------------------------------------------------------- + */ +herr_t +H5VLdataset_optional(void *obj, hid_t connector_id, hid_t dxpl_id, void **req, + va_list arguments) +{ + H5VL_class_t *cls; /* VOL connector's class struct */ + herr_t ret_value = SUCCEED; /* Return value */ + + FUNC_ENTER_API_NOINIT + H5TRACE5("e", "*xii**xx", obj, connector_id, dxpl_id, req, arguments); + + /* Check args and get class pointer */ + if(NULL == obj) + HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "invalid object") + if(NULL == (cls = (H5VL_class_t *)H5I_object_verify(connector_id, H5I_VOL))) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a VOL connector ID") + + /* Call the corresponding internal VOL routine */ + if(H5VL__dataset_optional(obj, cls, dxpl_id, req, arguments) < 0) + HGOTO_ERROR(H5E_VOL, H5E_CANTOPERATE, FAIL, "unable to execute dataset optional callback") + +done: + FUNC_LEAVE_API_NOINIT(ret_value) +} /* end H5VLdataset_optional() */ + + +/*------------------------------------------------------------------------- + * Function: H5VL__dataset_close + * + * Purpose: Closes a dataset through the VOL + * + * Return: Success: Non-negative + * Failure: Negative + * + *------------------------------------------------------------------------- + */ +static herr_t +H5VL__dataset_close(void *obj, const H5VL_class_t *cls, hid_t dxpl_id, void **req) +{ + herr_t ret_value = SUCCEED; /* Return value */ + + FUNC_ENTER_STATIC + + /* Sanity check */ + HDassert(obj); + HDassert(cls); + + /* Check if the corresponding VOL callback exists */ + if(NULL == cls->dataset_cls.close) + HGOTO_ERROR(H5E_VOL, H5E_UNSUPPORTED, FAIL, "VOL connector has no 'dataset close' method") + + /* Call the corresponding VOL callback */ + if((cls->dataset_cls.close)(obj, dxpl_id, req) < 0) + HGOTO_ERROR(H5E_VOL, H5E_CANTCLOSEOBJ, FAIL, "dataset close failed") + +done: + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5VL__dataset_close() */ + + +/*------------------------------------------------------------------------- + * Function: H5VL_dataset_close + * + * Purpose: Closes a dataset through the VOL + * + * Return: Success: Non-negative + * Failure: Negative + * + *------------------------------------------------------------------------- + */ +herr_t +H5VL_dataset_close(const H5VL_object_t *vol_obj, hid_t dxpl_id, void **req) +{ + hbool_t vol_wrapper_set = FALSE; /* Whether the VOL object wrapping context was set up */ + herr_t ret_value = SUCCEED; /* Return value */ + + FUNC_ENTER_NOAPI(FAIL) + + /* Sanity check */ + HDassert(vol_obj); + HDassert(vol_obj->data); + HDassert(vol_obj->connector); + HDassert(vol_obj->connector->cls); + + /* Set wrapper info in API context */ + if(H5VL_set_vol_wrapper(vol_obj->data, vol_obj->connector) < 0) + HGOTO_ERROR(H5E_VOL, H5E_CANTSET, FAIL, "can't set VOL wrapper info") + vol_wrapper_set = TRUE; + + /* Call the corresponding internal VOL routine */ + if(H5VL__dataset_close(vol_obj->data, vol_obj->connector->cls, dxpl_id, req) < 0) + HGOTO_ERROR(H5E_VOL, H5E_CANTCLOSEOBJ, FAIL, "dataset close failed") + +done: + /* Reset object wrapping info in API context */ + if(vol_wrapper_set && H5VL_reset_vol_wrapper() < 0) + HDONE_ERROR(H5E_VOL, H5E_CANTRESET, FAIL, "can't reset VOL wrapper info") + + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5VL_dataset_close() */ + + +/*------------------------------------------------------------------------- + * Function: H5VLdataset_close + * + * Purpose: Closes a dataset + * + * Return: Success: Non-negative + * Failure: Negative + * + *------------------------------------------------------------------------- + */ +herr_t +H5VLdataset_close(void *obj, hid_t connector_id, hid_t dxpl_id, void **req) +{ + H5VL_class_t *cls; /* VOL connector's class struct */ + herr_t ret_value = SUCCEED; /* Return value */ + + FUNC_ENTER_API_NOINIT + H5TRACE4("e", "*xii**x", obj, connector_id, dxpl_id, req); + + /* Check args and get class pointer */ + if(NULL == obj) + HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "invalid object") + if(NULL == (cls = (H5VL_class_t *)H5I_object_verify(connector_id, H5I_VOL))) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a VOL connector ID") + + /* Call the corresponding internal VOL routine */ + if(H5VL__dataset_close(obj, cls, dxpl_id, req) < 0) + HGOTO_ERROR(H5E_VOL, H5E_CANTCLOSEOBJ, FAIL, "unable to close dataset") + +done: + FUNC_LEAVE_API_NOINIT(ret_value) +} /* end H5VLdataset_close() */ + + +/*------------------------------------------------------------------------- + * Function: H5VL__file_create + * + * Purpose: Creates a file through the VOL + * + * Note: Does not have a 'static' version of the routine, since there's + * no objects in the container before this operation completes. + * + * Return: Success: Pointer to new file + * Failure: NULL + * + *------------------------------------------------------------------------- + */ +static void * +H5VL__file_create(const H5VL_class_t *cls, const char *name, + unsigned flags, hid_t fcpl_id, hid_t fapl_id, hid_t dxpl_id, void **req) +{ + void *ret_value = NULL; /* Return value */ + + FUNC_ENTER_STATIC + + /* Check if the corresponding VOL callback exists */ + if(NULL == cls->file_cls.create) + HGOTO_ERROR(H5E_VOL, H5E_UNSUPPORTED, NULL, "VOL connector has no 'file create' method") + + /* Call the corresponding VOL callback */ + if(NULL == (ret_value = (cls->file_cls.create)(name, flags, fcpl_id, fapl_id, dxpl_id, req))) + HGOTO_ERROR(H5E_VOL, H5E_CANTCREATE, NULL, "file create failed") + +done: + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5VL__file_create() */ + + +/*------------------------------------------------------------------------- + * Function: H5VL_file_create + * + * Purpose: Creates a file through the VOL + * + * Note: Does not have a 'static' version of the routine, since there's + * no objects in the container before this operation completes. + * + * Return: Success: Pointer to new file + * Failure: NULL + * + *------------------------------------------------------------------------- + */ +void * +H5VL_file_create(const H5VL_connector_prop_t *connector_prop, const char *name, + unsigned flags, hid_t fcpl_id, hid_t fapl_id, hid_t dxpl_id, void **req) +{ + H5VL_class_t *cls; /* VOL Class structure for callback info */ + void *ret_value = NULL; /* Return value */ + + FUNC_ENTER_NOAPI(NULL) + + /* Get the connector's class */ + if(NULL == (cls = (H5VL_class_t *)H5I_object_verify(connector_prop->connector_id, H5I_VOL))) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, NULL, "not a VOL connector ID") + + /* Call the corresponding internal VOL routine */ + if(NULL == (ret_value = H5VL__file_create(cls, name, flags, fcpl_id, fapl_id, dxpl_id, req))) + HGOTO_ERROR(H5E_VOL, H5E_CANTCREATE, NULL, "file create failed") + +done: + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5VL_file_create() */ + + +/*------------------------------------------------------------------------- + * Function: H5VLfile_create + * + * Purpose: Creates a file + * + * Return: Success: Pointer to the new file + * Failure: NULL + * + *------------------------------------------------------------------------- + */ +void * +H5VLfile_create(const char *name, unsigned flags, hid_t fcpl_id, hid_t fapl_id, + hid_t dxpl_id, void **req) +{ + H5P_genplist_t *plist; /* Property list pointer */ + H5VL_connector_prop_t connector_prop; /* Property for VOL connector ID & info */ + H5VL_class_t *cls; /* VOL connector's class struct */ + void *ret_value = NULL; /* Return value */ + + FUNC_ENTER_API_NOINIT + H5TRACE6("*x", "*sIuiii**x", name, flags, fcpl_id, fapl_id, dxpl_id, req); + + /* Get the VOL info from the fapl */ + if(NULL == (plist = (H5P_genplist_t *)H5I_object(fapl_id))) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, NULL, "not a file access property list") + if(H5P_peek(plist, H5F_ACS_VOL_CONN_NAME, &connector_prop) < 0) + HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, NULL, "can't get VOL connector info") + + /* Get class pointer */ + if(NULL == (cls = (H5VL_class_t *)H5I_object_verify(connector_prop.connector_id, H5I_VOL))) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, NULL, "not a VOL connector ID") + + /* Call the corresponding internal VOL routine */ + if(NULL == (ret_value = H5VL__file_create(cls, name, flags, fcpl_id, fapl_id, dxpl_id, req))) + HGOTO_ERROR(H5E_VOL, H5E_CANTCREATE, NULL, "unable to create file") + +done: + FUNC_LEAVE_API_NOINIT(ret_value) +} /* end H5VLfile_create() */ + + +/*------------------------------------------------------------------------- + * Function: H5VL__file_open + * + * Purpose: Opens a file through the VOL. + * + * Return: Success: Pointer to file. + * Failure: NULL + * + *------------------------------------------------------------------------- + */ +static void * +H5VL__file_open(const H5VL_class_t *cls, const char *name, unsigned flags, + hid_t fapl_id, hid_t dxpl_id, void **req) +{ + void *ret_value = NULL; /* Return value */ + + FUNC_ENTER_STATIC + + /* Check if the corresponding VOL callback exists */ + if(NULL == cls->file_cls.open) + HGOTO_ERROR(H5E_VOL, H5E_UNSUPPORTED, NULL, "VOL connector has no 'file open' method") + + /* Call the corresponding VOL callback */ + if(NULL == (ret_value = (cls->file_cls.open)(name, flags, fapl_id, dxpl_id, req))) + HGOTO_ERROR(H5E_VOL, H5E_CANTOPENOBJ, NULL, "open failed") + +done: + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5VL__file_open() */ + + +/*------------------------------------------------------------------------- + * Function: H5VL_file_open + * + * Purpose: Opens a file through the VOL. + * + * Note: Does not have a 'static' version of the routine, since there's + * no objects in the container before this operation completes. + * + * Return: Success: Pointer to file. + * Failure: NULL + * + *------------------------------------------------------------------------- + */ +void * +H5VL_file_open(const H5VL_connector_prop_t *connector_prop, const char *name, + unsigned flags, hid_t fapl_id, hid_t dxpl_id, void **req) +{ + H5VL_class_t *cls; /* VOL Class structure for callback info */ + void *ret_value = NULL; /* Return value */ + + FUNC_ENTER_NOAPI(NULL) + + /* Get the connector's class */ + if(NULL == (cls = (H5VL_class_t *)H5I_object_verify(connector_prop->connector_id, H5I_VOL))) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, NULL, "not a VOL connector ID") + + /* Call the corresponding internal VOL routine */ + if(NULL == (ret_value = H5VL__file_open(cls, name, flags, fapl_id, dxpl_id, req))) + HGOTO_ERROR(H5E_VOL, H5E_CANTOPENOBJ, NULL, "open failed") + +done: + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5VL_file_open() */ + + +/*------------------------------------------------------------------------- + * Function: H5VLfile_open + * + * Purpose: Opens a file + * + * Return: Success: Pointer to the file + * Failure: NULL + * + *------------------------------------------------------------------------- + */ +void * +H5VLfile_open(const char *name, unsigned flags, hid_t fapl_id, hid_t dxpl_id, + void **req) +{ + H5P_genplist_t *plist; /* Property list pointer */ + H5VL_connector_prop_t connector_prop; /* Property for VOL connector ID & info */ + H5VL_class_t *cls; /* VOL connector's class struct */ + void *ret_value = NULL; /* Return value */ + + FUNC_ENTER_API_NOINIT + H5TRACE5("*x", "*sIuii**x", name, flags, fapl_id, dxpl_id, req); + + /* Get the VOL info from the fapl */ + if(NULL == (plist = (H5P_genplist_t *)H5I_object(fapl_id))) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, NULL, "not a file access property list") + if(H5P_peek(plist, H5F_ACS_VOL_CONN_NAME, &connector_prop) < 0) + HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, NULL, "can't get VOL connector info") + + /* Get class pointer */ + if(NULL == (cls = (H5VL_class_t *)H5I_object_verify(connector_prop.connector_id, H5I_VOL))) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, NULL, "not a VOL connector ID") + + /* Call the corresponding internal VOL routine */ + if(NULL == (ret_value = H5VL__file_open(cls, name, flags, fapl_id, dxpl_id, req))) + HGOTO_ERROR(H5E_VOL, H5E_CANTOPENOBJ, NULL, "unable to open file") + +done: + FUNC_LEAVE_API_NOINIT(ret_value) +} /* end H5VLfile_open() */ + + +/*------------------------------------------------------------------------- + * Function: H5VL__file_get + * + * Purpose: Get specific information about the file through the VOL + * + * Return: Success: Non-negative + * Failure: Negative + * + *------------------------------------------------------------------------- + */ +static herr_t +H5VL__file_get(void *obj, const H5VL_class_t *cls, H5VL_file_get_t get_type, + hid_t dxpl_id, void **req, va_list arguments) +{ + herr_t ret_value = SUCCEED; /* Return value */ + + FUNC_ENTER_STATIC + + /* Check if the corresponding VOL callback exists */ + if(NULL == cls->file_cls.get) + HGOTO_ERROR(H5E_VOL, H5E_UNSUPPORTED, FAIL, "VOL connector has no 'file get' method") + + /* Call the corresponding VOL callback */ + if((cls->file_cls.get)(obj, get_type, dxpl_id, req, arguments) < 0) + HGOTO_ERROR(H5E_VOL, H5E_CANTGET, FAIL, "file get failed") + +done: + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5VL__file_get() */ + + +/*------------------------------------------------------------------------- + * Function: H5VL_file_get + * + * Purpose: Get specific information about the file through the VOL + * + * Return: Success: Non-negative + * Failure: Negative + * + *------------------------------------------------------------------------- + */ +herr_t +H5VL_file_get(const H5VL_object_t *vol_obj, H5VL_file_get_t get_type, + hid_t dxpl_id, void **req, ...) +{ + va_list arguments; /* Argument list passed from the API call */ + hbool_t arg_started = FALSE; /* Whether the va_list has been started */ + hbool_t vol_wrapper_set = FALSE; /* Whether the VOL object wrapping context was set up */ + herr_t ret_value = SUCCEED; /* Return value */ + + FUNC_ENTER_NOAPI(FAIL) + + /* Set wrapper info in API context */ + if(H5VL_set_vol_wrapper(vol_obj->data, vol_obj->connector) < 0) + HGOTO_ERROR(H5E_VOL, H5E_CANTSET, FAIL, "can't set VOL wrapper info") + vol_wrapper_set = TRUE; + + /* Call the corresponding internal VOL routine */ + HDva_start(arguments, req); + arg_started = TRUE; + if(H5VL__file_get(vol_obj->data, vol_obj->connector->cls, get_type, dxpl_id, req, arguments) < 0) + HGOTO_ERROR(H5E_VOL, H5E_CANTGET, FAIL, "file get failed") + +done: + /* End access to the va_list, if we started it */ + if(arg_started) + HDva_end(arguments); + + /* Reset object wrapping info in API context */ + if(vol_wrapper_set && H5VL_reset_vol_wrapper() < 0) + HDONE_ERROR(H5E_VOL, H5E_CANTRESET, FAIL, "can't reset VOL wrapper info") + + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5VL_file_get() */ + + +/*------------------------------------------------------------------------- + * Function: H5VLfile_get + * + * Purpose: Gets information about the file + * + * Return: Success: Non-negative + * Failure: Negative + * + *------------------------------------------------------------------------- + */ +herr_t +H5VLfile_get(void *obj, hid_t connector_id, H5VL_file_get_t get_type, + hid_t dxpl_id, void **req, va_list arguments) +{ + H5VL_class_t *cls; /* VOL connector's class struct */ + herr_t ret_value = SUCCEED; /* Return value */ + + FUNC_ENTER_API_NOINIT + H5TRACE6("e", "*xiVgi**xx", obj, connector_id, get_type, dxpl_id, req, + arguments); + + /* Check args and get class pointer */ + if(NULL == obj) + HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "invalid object") + if(NULL == (cls = (H5VL_class_t *)H5I_object_verify(connector_id, H5I_VOL))) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a VOL connector ID") + + /* Call the corresponding internal VOL routine */ + if(H5VL__file_get(obj, cls, get_type, dxpl_id, req, arguments) < 0) + HGOTO_ERROR(H5E_VOL, H5E_CANTGET, FAIL, "unable to execute file get callback") + +done: + FUNC_LEAVE_API_NOINIT(ret_value) +} /* end H5VLfile_get() */ + + +/*------------------------------------------------------------------------- + * Function: H5VL__file_specific + * + * Purpose: Perform File specific operations through the VOL + * + * Return: Success: Non-negative + * Failure: Negative + * + *------------------------------------------------------------------------- + */ +static herr_t +H5VL__file_specific(void *obj, const H5VL_class_t *cls, H5VL_file_specific_t specific_type, + hid_t dxpl_id, void **req, va_list arguments) +{ + herr_t ret_value = SUCCEED; /* Return value */ + + FUNC_ENTER_STATIC + + /* Check if the corresponding VOL callback exists */ + if(NULL == cls->file_cls.specific) + HGOTO_ERROR(H5E_VOL, H5E_UNSUPPORTED, FAIL, "VOL connector has no 'file specific' method") + + /* Call the corresponding VOL callback */ + if((cls->file_cls.specific)(obj, specific_type, dxpl_id, req, arguments) < 0) + HGOTO_ERROR(H5E_VOL, H5E_CANTOPERATE, FAIL, "file specific failed") + +done: + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5VL__file_specific() */ + + +/*------------------------------------------------------------------------- + * Function: H5VL_file_specific + * + * Purpose: Perform File specific operations through the VOL + * + * Return: Success: Non-negative + * Failure: Negative + * + *------------------------------------------------------------------------- + */ +herr_t +H5VL_file_specific(const H5VL_object_t *vol_obj, H5VL_file_specific_t specific_type, + hid_t dxpl_id, void **req, ...) +{ + const H5VL_class_t *cls; /* VOL connector's class struct */ + va_list arguments; /* Argument list passed from the API call */ + hbool_t arg_started = FALSE; /* Whether the va_list has been started */ + hbool_t vol_wrapper_set = FALSE; /* Whether the VOL object wrapping context was set up */ + herr_t ret_value = SUCCEED; /* Return value */ + + FUNC_ENTER_NOAPI(FAIL) + + /* Start access to the varargs, so they are available in all situations below */ + HDva_start(arguments, req); + arg_started = TRUE; + + /* Special treatment of file access check */ + if(specific_type == H5VL_FILE_IS_ACCESSIBLE) { + H5P_genplist_t *plist; /* Property list pointer */ + H5VL_connector_prop_t connector_prop; /* Property for VOL connector ID & info */ + va_list tmp_args; /* argument list passed from the API call */ + hid_t fapl_id; /* File access property list for accessing the file */ + + /* Get the file access property list to access the file */ + HDva_copy(tmp_args, arguments); + fapl_id = va_arg(tmp_args, hid_t); + HDva_end(tmp_args); + + /* Get the VOL info from the FAPL */ + if(NULL == (plist = (H5P_genplist_t *)H5I_object(fapl_id))) + HGOTO_ERROR(H5E_VOL, H5E_BADTYPE, FAIL, "not a file access property list") + if(H5P_peek(plist, H5F_ACS_VOL_CONN_NAME, &connector_prop) < 0) + HGOTO_ERROR(H5E_VOL, H5E_CANTGET, FAIL, "can't get VOL connector info") + + /* Get class pointer */ + if(NULL == (cls = (H5VL_class_t *)H5I_object_verify(connector_prop.connector_id, H5I_VOL))) + HGOTO_ERROR(H5E_VOL, H5E_BADTYPE, FAIL, "not a VOL connector ID") + } /* end if */ + /* Set wrapper info in API context, for all other operations */ + else { + /* Sanity check */ + HDassert(vol_obj); + + if(H5VL_set_vol_wrapper(vol_obj->data, vol_obj->connector) < 0) + HGOTO_ERROR(H5E_VOL, H5E_CANTSET, FAIL, "can't set VOL wrapper info") + vol_wrapper_set = TRUE; + + /* Set the VOL connector class pointer */ + cls = vol_obj->connector->cls; + } /* end else */ + + /* Call the corresponding internal VOL routine */ + if(H5VL__file_specific(vol_obj ? vol_obj->data : NULL, cls, specific_type, dxpl_id, req, arguments) < 0) + HGOTO_ERROR(H5E_VOL, H5E_CANTOPERATE, FAIL, "file specific failed") + +done: + /* End access to the va_list, if we started it */ + if(arg_started) + HDva_end(arguments); + + /* Reset object wrapping info in API context */ + if(vol_wrapper_set && H5VL_reset_vol_wrapper() < 0) + HDONE_ERROR(H5E_VOL, H5E_CANTRESET, FAIL, "can't reset VOL wrapper info") + + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5VL_file_specific() */ + + +/*------------------------------------------------------------------------- + * Function: H5VLfile_specific + * + * Purpose: Performs a connector-specific operation on a file + * + * Note: The 'obj' parameter is allowed to be NULL + * + * Return: Success: Non-negative + * Failure: Negative + * + *------------------------------------------------------------------------- + */ +herr_t +H5VLfile_specific(void *obj, hid_t connector_id, H5VL_file_specific_t specific_type, + hid_t dxpl_id, void **req, va_list arguments) +{ + H5VL_class_t *cls; /* VOL connector's class struct */ + herr_t ret_value = SUCCEED; /* Return value */ + + FUNC_ENTER_API_NOINIT + H5TRACE6("e", "*xiVhi**xx", obj, connector_id, specific_type, dxpl_id, req, + arguments); + + /* Check args and get class pointer */ + if(NULL == (cls = (H5VL_class_t *)H5I_object_verify(connector_id, H5I_VOL))) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a VOL connector ID") + + /* Call the corresponding internal VOL routine */ + if(H5VL__file_specific(obj, cls, specific_type, dxpl_id, req, arguments) < 0) + HGOTO_ERROR(H5E_VOL, H5E_CANTOPERATE, FAIL, "unable to execute file specific callback") + +done: + FUNC_LEAVE_API_NOINIT(ret_value) +} /* end H5VLfile_specific() */ + + +/*------------------------------------------------------------------------- + * Function: H5VL__file_optional + * + * Purpose: Perform a connector specific operation + * + * Return: Success: Non-negative + * Failure: Negative + * + *------------------------------------------------------------------------- + */ +static herr_t +H5VL__file_optional(void *obj, const H5VL_class_t *cls, hid_t dxpl_id, + void **req, va_list arguments) +{ + herr_t ret_value = SUCCEED; /* Return value */ + + FUNC_ENTER_STATIC + + /* Check if the corresponding VOL callback exists */ + if(NULL == cls->file_cls.optional) + HGOTO_ERROR(H5E_VOL, H5E_UNSUPPORTED, FAIL, "VOL connector has no 'file optional' method") + + /* Call the corresponding VOL callback */ + if((cls->file_cls.optional)(obj, dxpl_id, req, arguments) < 0) + HGOTO_ERROR(H5E_VOL, H5E_CANTOPERATE, FAIL, "file optional failed") + +done: + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5VL__file_optional() */ + + +/*------------------------------------------------------------------------- + * Function: H5VL_file_optional + * + * Purpose: Perform a connector specific operation + * + * Return: Success: Non-negative + * Failure: Negative + * + *------------------------------------------------------------------------- + */ +herr_t +H5VL_file_optional(const H5VL_object_t *vol_obj, hid_t dxpl_id, void **req, ...) +{ + va_list arguments; /* Argument list passed from the API call */ + hbool_t arg_started = FALSE; /* Whether the va_list has been started */ + hbool_t vol_wrapper_set = FALSE; /* Whether the VOL object wrapping context was set up */ + herr_t ret_value = SUCCEED; /* Return value */ + + FUNC_ENTER_NOAPI(FAIL) + + /* Set wrapper info in API context */ + if(H5VL_set_vol_wrapper(vol_obj->data, vol_obj->connector) < 0) + HGOTO_ERROR(H5E_VOL, H5E_CANTSET, FAIL, "can't set VOL wrapper info") + vol_wrapper_set = TRUE; + + /* Call the corresponding internal VOL routine */ + HDva_start(arguments, req); + arg_started = TRUE; + if(H5VL__file_optional(vol_obj->data, vol_obj->connector->cls, dxpl_id, req, arguments) < 0) + HGOTO_ERROR(H5E_VOL, H5E_CANTOPERATE, FAIL, "file optional failed") + +done: + /* End access to the va_list, if we started it */ + if(arg_started) + HDva_end(arguments); + + /* Reset object wrapping info in API context */ + if(vol_wrapper_set && H5VL_reset_vol_wrapper() < 0) + HDONE_ERROR(H5E_VOL, H5E_CANTRESET, FAIL, "can't reset VOL wrapper info") + + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5VL_file_optional() */ + + +/*------------------------------------------------------------------------- + * Function: H5VLfile_optional + * + * Purpose: Performs an optional connector-specific operation on a file + * + * Return: Success: Non-negative + * Failure: Negative + * + *------------------------------------------------------------------------- + */ +herr_t +H5VLfile_optional(void *obj, hid_t connector_id, hid_t dxpl_id, void **req, + va_list arguments) +{ + H5VL_class_t *cls; /* VOL connector's class struct */ + herr_t ret_value = SUCCEED; /* Return value */ + + FUNC_ENTER_API_NOINIT + H5TRACE5("e", "*xii**xx", obj, connector_id, dxpl_id, req, arguments); + + /* Check args and get class pointer */ + if(NULL == obj) + HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "invalid object") + if(NULL == (cls = (H5VL_class_t *)H5I_object_verify(connector_id, H5I_VOL))) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a VOL connector ID") + + /* Call the corresponding internal VOL routine */ + if(H5VL__file_optional(obj, cls, dxpl_id, req, arguments) < 0) + HGOTO_ERROR(H5E_VOL, H5E_CANTOPERATE, FAIL, "unable to execute file optional callback") + +done: + FUNC_LEAVE_API_NOINIT(ret_value) +} /* end H5VLfile_optional() */ + + +/*------------------------------------------------------------------------- + * Function: H5VL__file_close + * + * Purpose: Closes a file through the VOL + * + * Return: Success: Non-negative + * Failure: Negative + * + *------------------------------------------------------------------------- + */ +static herr_t +H5VL__file_close(void *obj, const H5VL_class_t *cls, hid_t dxpl_id, void **req) +{ + herr_t ret_value = SUCCEED; /* Return value */ + + FUNC_ENTER_STATIC + + /* Sanity check */ + HDassert(obj); + HDassert(cls); + + /* Check if the corresponding VOL callback exists */ + if(NULL == cls->file_cls.close) + HGOTO_ERROR(H5E_VOL, H5E_UNSUPPORTED, FAIL, "VOL connector has no 'file close' method") + + /* Call the corresponding VOL callback */ + if((cls->file_cls.close)(obj, dxpl_id, req) < 0) + HGOTO_ERROR(H5E_VOL, H5E_CANTCLOSEFILE, FAIL, "file close failed") + +done: + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5VL__file_close() */ + + +/*------------------------------------------------------------------------- + * Function: H5VL_file_close + * + * Purpose: Closes a file through the VOL + * + * Return: Success: Non-negative + * Failure: Negative + * + *------------------------------------------------------------------------- + */ +herr_t +H5VL_file_close(const H5VL_object_t *vol_obj, hid_t dxpl_id, void **req) +{ + hbool_t vol_wrapper_set = FALSE; /* Whether the VOL object wrapping context was set up */ + herr_t ret_value = SUCCEED; /* Return value */ + + FUNC_ENTER_NOAPI(FAIL) + + /* Set wrapper info in API context */ + if(H5VL_set_vol_wrapper(vol_obj->data, vol_obj->connector) < 0) + HGOTO_ERROR(H5E_VOL, H5E_CANTSET, FAIL, "can't set VOL wrapper info") + vol_wrapper_set = TRUE; + + /* Call the corresponding internal VOL routine */ + if(H5VL__file_close(vol_obj->data, vol_obj->connector->cls, dxpl_id, req) < 0) + HGOTO_ERROR(H5E_VOL, H5E_CANTCLOSEFILE, FAIL, "file close failed") + +done: + /* Reset object wrapping info in API context */ + if(vol_wrapper_set && H5VL_reset_vol_wrapper() < 0) + HDONE_ERROR(H5E_VOL, H5E_CANTRESET, FAIL, "can't reset VOL wrapper info") + + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5VL_file_close() */ + + +/*------------------------------------------------------------------------- + * Function: H5VLfile_close + * + * Purpose: Closes a file + * + * Return: Success: Non-negative + * Failure: Negative + * + *------------------------------------------------------------------------- + */ +herr_t +H5VLfile_close(void *obj, hid_t connector_id, hid_t dxpl_id, void **req) +{ + H5VL_class_t *cls; /* VOL connector's class struct */ + herr_t ret_value = SUCCEED; /* Return value */ + + FUNC_ENTER_API_NOINIT + H5TRACE4("e", "*xii**x", obj, connector_id, dxpl_id, req); + + /* Check args and get class pointer */ + if(NULL == obj) + HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "invalid object") + if(NULL == (cls = (H5VL_class_t *)H5I_object_verify(connector_id, H5I_VOL))) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a VOL connector ID") + + /* Call the corresponding internal VOL routine */ + if(H5VL__file_close(obj, cls, dxpl_id, req) < 0) + HGOTO_ERROR(H5E_VOL, H5E_CANTCLOSEFILE, FAIL, "unable to close file") + +done: + FUNC_LEAVE_API_NOINIT(ret_value) +} /* end H5VLfile_close() */ + + +/*------------------------------------------------------------------------- + * Function: H5VL__group_create + * + * Purpose: Creates a group through the VOL + * + * Return: Success: Pointer to new group + * Failure: NULL + * + *------------------------------------------------------------------------- + */ +static void * +H5VL__group_create(void *obj, const H5VL_loc_params_t *loc_params, const H5VL_class_t *cls, + const char *name, hid_t gcpl_id, hid_t gapl_id, hid_t dxpl_id, void **req) +{ + void *ret_value = NULL; /* Return value */ + + FUNC_ENTER_STATIC + + /* Check if the corresponding VOL callback exists */ + if(NULL == cls->group_cls.create) + HGOTO_ERROR(H5E_VOL, H5E_UNSUPPORTED, NULL, "VOL connector has no 'group create' method") + + /* Call the corresponding VOL callback */ + if(NULL == (ret_value = (cls->group_cls.create)(obj, loc_params, name, gcpl_id, gapl_id, dxpl_id, req))) + HGOTO_ERROR(H5E_VOL, H5E_CANTCREATE, NULL, "group create failed") + +done: + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5VL__group_create() */ + + +/*------------------------------------------------------------------------- + * Function: H5VL_group_create + * + * Purpose: Creates a group through the VOL + * + * Return: Success: Pointer to new group + * Failure: NULL + * + *------------------------------------------------------------------------- + */ +void * +H5VL_group_create(const H5VL_object_t *vol_obj, const H5VL_loc_params_t *loc_params, + const char *name, hid_t gcpl_id, hid_t gapl_id, hid_t dxpl_id, void **req) +{ + hbool_t vol_wrapper_set = FALSE; /* Whether the VOL object wrapping context was set up */ + void *ret_value = NULL; /* Return value */ + + FUNC_ENTER_NOAPI(NULL) + + /* Set wrapper info in API context */ + if(H5VL_set_vol_wrapper(vol_obj->data, vol_obj->connector) < 0) + HGOTO_ERROR(H5E_VOL, H5E_CANTSET, NULL, "can't set VOL wrapper info") + vol_wrapper_set = TRUE; + + /* Call the corresponding internal VOL routine */ + if(NULL == (ret_value = H5VL__group_create(vol_obj->data, loc_params, vol_obj->connector->cls, name, gcpl_id, gapl_id, dxpl_id, req))) + HGOTO_ERROR(H5E_VOL, H5E_CANTCREATE, NULL, "group create failed") + +done: + /* Reset object wrapping info in API context */ + if(vol_wrapper_set && H5VL_reset_vol_wrapper() < 0) + HDONE_ERROR(H5E_VOL, H5E_CANTRESET, NULL, "can't reset VOL wrapper info") + + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5VL_group_create() */ + + +/*------------------------------------------------------------------------- + * Function: H5VLgroup_create + * + * Purpose: Creates a group + * + * Return: Success: Pointer to the new group + * Failure: NULL + * + *------------------------------------------------------------------------- + */ +void * +H5VLgroup_create(void *obj, const H5VL_loc_params_t *loc_params, hid_t connector_id, const char *name, + hid_t gcpl_id, hid_t gapl_id, hid_t dxpl_id, void **req) +{ + H5VL_class_t *cls; /* VOL connector's class struct */ + void *ret_value = NULL; /* Return value */ + + FUNC_ENTER_API_NOINIT + H5TRACE8("*x", "*x*xi*siii**x", obj, loc_params, connector_id, name, gcpl_id, + gapl_id, dxpl_id, req); + + /* Check args and get class pointer */ + if(NULL == obj) + HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, NULL, "invalid object") + if(NULL == (cls = (H5VL_class_t *)H5I_object_verify(connector_id, H5I_VOL))) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, NULL, "not a VOL connector ID") + + /* Call the corresponding internal VOL routine */ + if(NULL == (ret_value = H5VL__group_create(obj, loc_params, cls, name, gcpl_id, gapl_id, dxpl_id, req))) + HGOTO_ERROR(H5E_VOL, H5E_CANTCREATE, NULL, "unable to create group") + +done: + FUNC_LEAVE_API_NOINIT(ret_value) +} /* end H5VLgroup_create() */ + + +/*------------------------------------------------------------------------- + * Function: H5VL__group_open + * + * Purpose: Opens a group through the VOL + * + * Return: Success: Pointer to group + * Failure: NULL + * + *------------------------------------------------------------------------- + */ +static void * +H5VL__group_open(void *obj, const H5VL_loc_params_t *loc_params, const H5VL_class_t *cls, + const char *name, hid_t gapl_id, hid_t dxpl_id, void **req) +{ + void *ret_value = NULL; /* Return value */ + + FUNC_ENTER_STATIC + + /* Check if the corresponding VOL callback exists */ + if(NULL == cls->group_cls.open) + HGOTO_ERROR(H5E_VOL, H5E_UNSUPPORTED, NULL, "VOL connector has no 'group open' method") + + /* Call the corresponding VOL callback */ + if(NULL == (ret_value = (cls->group_cls.open)(obj, loc_params, name, gapl_id, dxpl_id, req))) + HGOTO_ERROR(H5E_VOL, H5E_CANTOPENOBJ, NULL, "group open failed") + +done: + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5VL__group_open() */ + + +/*------------------------------------------------------------------------- + * Function: H5VL_group_open + * + * Purpose: Opens a group through the VOL + * + * Return: Success: Pointer to group + * Failure: NULL + * + *------------------------------------------------------------------------- + */ +void * +H5VL_group_open(const H5VL_object_t *vol_obj, const H5VL_loc_params_t *loc_params, + const char *name, hid_t gapl_id, hid_t dxpl_id, void **req) +{ + hbool_t vol_wrapper_set = FALSE; /* Whether the VOL object wrapping context was set up */ + void *ret_value = NULL; /* Return value */ + + FUNC_ENTER_NOAPI(NULL) + + /* Set wrapper info in API context */ + if(H5VL_set_vol_wrapper(vol_obj->data, vol_obj->connector) < 0) + HGOTO_ERROR(H5E_VOL, H5E_CANTSET, NULL, "can't set VOL wrapper info") + vol_wrapper_set = TRUE; + + /* Call the corresponding internal VOL routine */ + if(NULL == (ret_value = H5VL__group_open(vol_obj->data, loc_params, vol_obj->connector->cls, name, gapl_id, dxpl_id, req))) + HGOTO_ERROR(H5E_VOL, H5E_CANTOPENOBJ, NULL, "group open failed") + +done: + /* Reset object wrapping info in API context */ + if(vol_wrapper_set && H5VL_reset_vol_wrapper() < 0) + HDONE_ERROR(H5E_VOL, H5E_CANTRESET, NULL, "can't reset VOL wrapper info") + + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5VL_group_open() */ + + +/*------------------------------------------------------------------------- + * Function: H5VLgroup_open + * + * Purpose: Opens a group + * + * Return: Success: Pointer to the group + * Failure: NULL + * + *------------------------------------------------------------------------- + */ +void * +H5VLgroup_open(void *obj, const H5VL_loc_params_t *loc_params, hid_t connector_id, const char *name, + hid_t gapl_id, hid_t dxpl_id, void **req) +{ + H5VL_class_t *cls; /* VOL connector's class struct */ + void *ret_value = NULL; /* Return value */ + + FUNC_ENTER_API_NOINIT + H5TRACE7("*x", "*x*xi*sii**x", obj, loc_params, connector_id, name, gapl_id, + dxpl_id, req); + + /* Check args and get class pointer */ + if(NULL == obj) + HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, NULL, "invalid object") + if(NULL == (cls = (H5VL_class_t *)H5I_object_verify(connector_id, H5I_VOL))) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, NULL, "not a VOL connector ID") + + /* Call the corresponding internal VOL routine */ + if(NULL == (ret_value = H5VL__group_open(obj, loc_params, cls, name, gapl_id, dxpl_id, req))) + HGOTO_ERROR(H5E_VOL, H5E_CANTINIT, NULL, "unable to open group") + +done: + FUNC_LEAVE_API_NOINIT(ret_value) +} /* end H5VLgroup_open() */ + + +/*------------------------------------------------------------------------- + * Function: H5VL__group_get + * + * Purpose: Get specific information about the group through the VOL + * + * Return: Success: Non-negative + * Failure: Negative + * + *------------------------------------------------------------------------- + */ +static herr_t +H5VL__group_get(void *obj, const H5VL_class_t *cls, H5VL_group_get_t get_type, + hid_t dxpl_id, void **req, va_list arguments) +{ + herr_t ret_value = SUCCEED; /* Return value */ + + FUNC_ENTER_STATIC + + /* Check if the corresponding VOL callback exists */ + if(NULL == cls->group_cls.get) + HGOTO_ERROR(H5E_VOL, H5E_UNSUPPORTED, FAIL, "VOL connector has no 'group get' method") + + /* Call the corresponding VOL callback */ + if((cls->group_cls.get)(obj, get_type, dxpl_id, req, arguments) < 0) + HGOTO_ERROR(H5E_VOL, H5E_CANTGET, FAIL, "group get failed") + +done: + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5VL__group_get() */ + + +/*------------------------------------------------------------------------- + * Function: H5VL_group_get + * + * Purpose: Get specific information about the group through the VOL + * + * Return: Success: Non-negative + * Failure: Negative + * + *------------------------------------------------------------------------- + */ +herr_t +H5VL_group_get(const H5VL_object_t *vol_obj, H5VL_group_get_t get_type, + hid_t dxpl_id, void **req, ...) +{ + va_list arguments; /* Argument list passed from the API call */ + hbool_t arg_started = FALSE; /* Whether the va_list has been started */ + hbool_t vol_wrapper_set = FALSE; /* Whether the VOL object wrapping context was set up */ + herr_t ret_value = SUCCEED; /* Return value */ + + FUNC_ENTER_NOAPI(FAIL) + + /* Set wrapper info in API context */ + if(H5VL_set_vol_wrapper(vol_obj->data, vol_obj->connector) < 0) + HGOTO_ERROR(H5E_VOL, H5E_CANTSET, FAIL, "can't set VOL wrapper info") + vol_wrapper_set = TRUE; + + /* Call the corresponding internal VOL routine */ + HDva_start(arguments, req); + arg_started = TRUE; + if(H5VL__group_get(vol_obj->data, vol_obj->connector->cls, get_type, dxpl_id, req, arguments) < 0) + HGOTO_ERROR(H5E_VOL, H5E_CANTGET, FAIL, "group get failed") + +done: + /* End access to the va_list, if we started it */ + if(arg_started) + HDva_end(arguments); + + /* Reset object wrapping info in API context */ + if(vol_wrapper_set && H5VL_reset_vol_wrapper() < 0) + HDONE_ERROR(H5E_VOL, H5E_CANTRESET, FAIL, "can't reset VOL wrapper info") + + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5VL_group_get() */ + + +/*------------------------------------------------------------------------- + * Function: H5VLgroup_get + * + * Purpose: Gets information about the group + * + * Return: Success: Non-negative + * Failure: Negative + * + *------------------------------------------------------------------------- + */ +herr_t +H5VLgroup_get(void *obj, hid_t connector_id, H5VL_group_get_t get_type, + hid_t dxpl_id, void **req, va_list arguments) +{ + H5VL_class_t *cls; /* VOL connector's class struct */ + herr_t ret_value = SUCCEED; /* Return value */ + + FUNC_ENTER_API_NOINIT + H5TRACE6("e", "*xiVii**xx", obj, connector_id, get_type, dxpl_id, req, + arguments); + + /* Check args and get class pointer */ + if(NULL == obj) + HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "invalid object") + if(NULL == (cls = (H5VL_class_t *)H5I_object_verify(connector_id, H5I_VOL))) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a VOL connector ID") + + /* Call the corresponding internal VOL routine */ + if(H5VL__group_get(obj, cls, get_type, dxpl_id, req, arguments) < 0) + HGOTO_ERROR(H5E_VOL, H5E_CANTGET, FAIL, "unable to execute group get callback") + +done: + FUNC_LEAVE_API_NOINIT(ret_value) +} /* end H5VLgroup_get() */ + + +/*------------------------------------------------------------------------- + * Function: H5VL__group_specific + * + * Purpose: Specific operation on groups through the VOL + * + * Return: Success: Non-negative + * Failure: Negative + * + *------------------------------------------------------------------------- + */ +static herr_t +H5VL__group_specific(void *obj, const H5VL_class_t *cls, H5VL_group_specific_t specific_type, + hid_t dxpl_id, void **req, va_list arguments) +{ + herr_t ret_value = SUCCEED; /* Return value */ + + FUNC_ENTER_STATIC + + /* Check if the corresponding VOL callback exists */ + if(NULL == cls->group_cls.specific) + HGOTO_ERROR(H5E_VOL, H5E_UNSUPPORTED, FAIL, "VOL connector has no 'group specific' method") + + /* Call the corresponding VOL callback */ + if((cls->group_cls.specific)(obj, specific_type, dxpl_id, req, arguments) < 0) + HGOTO_ERROR(H5E_VOL, H5E_CANTOPERATE, FAIL, "unable to execute group specific callback") + +done: + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5VL__group_specific() */ + + +/*------------------------------------------------------------------------- + * Function: H5VL_group_specific + * + * Purpose: Specific operation on groups through the VOL + * + * Return: Success: Non-negative + * Failure: Negative + * + *------------------------------------------------------------------------- + */ +herr_t +H5VL_group_specific(const H5VL_object_t *vol_obj, H5VL_group_specific_t specific_type, + hid_t dxpl_id, void **req, ...) +{ + va_list arguments; /* Argument list passed from the API call */ + hbool_t arg_started = FALSE; /* Whether the va_list has been started */ + hbool_t vol_wrapper_set = FALSE; /* Whether the VOL object wrapping context was set up */ + herr_t ret_value = SUCCEED; /* Return value */ + + FUNC_ENTER_NOAPI(FAIL) + + /* Set wrapper info in API context */ + if(H5VL_set_vol_wrapper(vol_obj->data, vol_obj->connector) < 0) + HGOTO_ERROR(H5E_VOL, H5E_CANTSET, FAIL, "can't set VOL wrapper info") + vol_wrapper_set = TRUE; + + /* Call the corresponding internal VOL routine */ + HDva_start(arguments, req); + arg_started = TRUE; + if(H5VL__group_specific(vol_obj->data, vol_obj->connector->cls, specific_type, dxpl_id, req, arguments) < 0) + HGOTO_ERROR(H5E_VOL, H5E_CANTOPERATE, FAIL, "unable to execute group specific callback") + +done: + /* End access to the va_list, if we started it */ + if(arg_started) + HDva_end(arguments); + + /* Reset object wrapping info in API context */ + if(vol_wrapper_set && H5VL_reset_vol_wrapper() < 0) + HDONE_ERROR(H5E_VOL, H5E_CANTRESET, FAIL, "can't reset VOL wrapper info") + + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5VL_group_specific() */ + + +/*------------------------------------------------------------------------- + * Function: H5VLgroup_specific + * + * Purpose: Performs a connector-specific operation on a group + * + * Return: Success: Non-negative + * Failure: Negative + * + *------------------------------------------------------------------------- + */ +herr_t +H5VLgroup_specific(void *obj, hid_t connector_id, H5VL_group_specific_t specific_type, + hid_t dxpl_id, void **req, va_list arguments) +{ + H5VL_class_t *cls; /* VOL connector's class struct */ + herr_t ret_value = SUCCEED; /* Return value */ + + FUNC_ENTER_API_NOINIT + H5TRACE6("e", "*xiVji**xx", obj, connector_id, specific_type, dxpl_id, req, + arguments); + + /* Check args and get class pointer */ + if(NULL == obj) + HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "invalid object") + if(NULL == (cls = (H5VL_class_t *)H5I_object_verify(connector_id, H5I_VOL))) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a VOL connector ID") + + /* Call the corresponding internal VOL routine */ + if(H5VL__group_specific(obj, cls, specific_type, dxpl_id, req, arguments) < 0) + HGOTO_ERROR(H5E_VOL, H5E_CANTOPERATE, FAIL, "unable to execute group specific callback") + +done: + FUNC_LEAVE_API_NOINIT(ret_value) +} /* end H5VLgroup_specific() */ + + +/*------------------------------------------------------------------------- + * Function: H5VL__group_optional + * + * Purpose: Optional operation specific to connectors. + * + * Return: Success: Non-negative + * Failure: Negative + * + *------------------------------------------------------------------------- + */ +static herr_t +H5VL__group_optional(void *obj, const H5VL_class_t *cls, hid_t dxpl_id, + void **req, va_list arguments) +{ + herr_t ret_value = SUCCEED; /* Return value */ + + FUNC_ENTER_STATIC + + /* Check if the corresponding VOL callback exists */ + if(NULL == cls->group_cls.optional) + HGOTO_ERROR(H5E_VOL, H5E_UNSUPPORTED, FAIL, "VOL connector has no 'group optional' method") + + /* Call the corresponding VOL callback */ + if((ret_value = (cls->group_cls.optional)(obj, dxpl_id, req, arguments)) < 0) + HGOTO_ERROR(H5E_VOL, H5E_CANTOPERATE, FAIL, "unable to execute group optional callback") + +done: + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5VL__group_optional() */ + + +/*------------------------------------------------------------------------- + * Function: H5VL_group_optional + * + * Purpose: Optional operation specific to connectors. + * + * Return: Success: Non-negative + * Failure: Negative + * + *------------------------------------------------------------------------- + */ +herr_t +H5VL_group_optional(const H5VL_object_t *vol_obj, hid_t dxpl_id, void **req, ...) +{ + va_list arguments; /* Argument list passed from the API call */ + hbool_t arg_started = FALSE; /* Whether the va_list has been started */ + hbool_t vol_wrapper_set = FALSE; /* Whether the VOL object wrapping context was set up */ + herr_t ret_value = SUCCEED; /* Return value */ + + FUNC_ENTER_NOAPI(FAIL) + + /* Set wrapper info in API context */ + if(H5VL_set_vol_wrapper(vol_obj->data, vol_obj->connector) < 0) + HGOTO_ERROR(H5E_VOL, H5E_CANTSET, FAIL, "can't set VOL wrapper info") + vol_wrapper_set = TRUE; + + /* Call the corresponding internal VOL routine */ + HDva_start(arguments, req); + arg_started = TRUE; + if((ret_value = H5VL__group_optional(vol_obj->data, vol_obj->connector->cls, dxpl_id, req, arguments)) < 0) + HGOTO_ERROR(H5E_VOL, H5E_CANTOPERATE, FAIL, "unable to execute group optional callback") + +done: + /* End access to the va_list, if we started it */ + if(arg_started) + HDva_end(arguments); + + /* Reset object wrapping info in API context */ + if(vol_wrapper_set && H5VL_reset_vol_wrapper() < 0) + HDONE_ERROR(H5E_VOL, H5E_CANTRESET, FAIL, "can't reset VOL wrapper info") + + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5VL_group_optional() */ + + +/*------------------------------------------------------------------------- + * Function: H5VLgroup_optional + * + * Purpose: Performs an optional connector-specific operation on a group + * + * Return: Success: Non-negative + * Failure: Negative + * + *------------------------------------------------------------------------- + */ +herr_t +H5VLgroup_optional(void *obj, hid_t connector_id, hid_t dxpl_id, void **req, + va_list arguments) +{ + H5VL_class_t *cls; /* VOL connector's class struct */ + herr_t ret_value = SUCCEED; /* Return value */ + + FUNC_ENTER_API_NOINIT + H5TRACE5("e", "*xii**xx", obj, connector_id, dxpl_id, req, arguments); + + /* Check args and get class pointer */ + if(NULL == obj) + HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "invalid object") + if(NULL == (cls = (H5VL_class_t *)H5I_object_verify(connector_id, H5I_VOL))) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a VOL connector ID") + + /* Call the corresponding internal VOL routine */ + if((ret_value = H5VL__group_optional(obj, cls, dxpl_id, req, arguments)) < 0) + HGOTO_ERROR(H5E_VOL, H5E_CANTOPERATE, FAIL, "unable to execute group optional callback") + +done: + FUNC_LEAVE_API_NOINIT(ret_value) +} /* end H5VLgroup_optional() */ + + +/*------------------------------------------------------------------------- + * Function: H5VL__group_close + * + * Purpose: Closes a group through the VOL + * + * Return: Success: Non-negative + * Failure: Negative + * + *------------------------------------------------------------------------- + */ +static herr_t +H5VL__group_close(void *obj, const H5VL_class_t *cls, hid_t dxpl_id, void **req) +{ + herr_t ret_value = SUCCEED; /* Return value */ + + /* Sanity check */ + HDassert(obj); + HDassert(cls); + + FUNC_ENTER_STATIC + + /* Check if the corresponding VOL callback exists */ + if(NULL == cls->group_cls.close) + HGOTO_ERROR(H5E_VOL, H5E_UNSUPPORTED, FAIL, "VOL connector has no 'group close' method") + + /* Call the corresponding VOL callback */ + if((cls->group_cls.close)(obj, dxpl_id, req) < 0) + HGOTO_ERROR(H5E_VOL, H5E_CANTCLOSEOBJ, FAIL, "group close failed") + +done: + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5VL__group_close() */ + + +/*------------------------------------------------------------------------- + * Function: H5VL_group_close + * + * Purpose: Closes a group through the VOL + * + * Return: Success: Non-negative + * Failure: Negative + * + *------------------------------------------------------------------------- + */ +herr_t +H5VL_group_close(const H5VL_object_t *vol_obj, hid_t dxpl_id, void **req) +{ + hbool_t vol_wrapper_set = FALSE; /* Whether the VOL object wrapping context was set up */ + herr_t ret_value = SUCCEED; /* Return value */ + + FUNC_ENTER_NOAPI(FAIL) + + /* Set wrapper info in API context */ + if(H5VL_set_vol_wrapper(vol_obj->data, vol_obj->connector) < 0) + HGOTO_ERROR(H5E_VOL, H5E_CANTSET, FAIL, "can't set VOL wrapper info") + vol_wrapper_set = TRUE; + + /* Call the corresponding internal VOL routine */ + if(H5VL__group_close(vol_obj->data, vol_obj->connector->cls, dxpl_id, req) < 0) + HGOTO_ERROR(H5E_VOL, H5E_CANTCLOSEOBJ, FAIL, "group close failed") + +done: + /* Reset object wrapping info in API context */ + if(vol_wrapper_set && H5VL_reset_vol_wrapper() < 0) + HDONE_ERROR(H5E_VOL, H5E_CANTRESET, FAIL, "can't reset VOL wrapper info") + + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5VL_group_close() */ + + +/*------------------------------------------------------------------------- + * Function: H5VLgroup_close + * + * Purpose: Closes a group + * + * Return: Success: Non-negative + * Failure: Negative + * + *------------------------------------------------------------------------- + */ +herr_t +H5VLgroup_close(void *obj, hid_t connector_id, hid_t dxpl_id, void **req) +{ + H5VL_class_t *cls; /* VOL connector's class struct */ + herr_t ret_value = SUCCEED; /* Return value */ + + FUNC_ENTER_API_NOINIT + H5TRACE4("e", "*xii**x", obj, connector_id, dxpl_id, req); + + /* Check args and get class pointer */ + if(NULL == obj) + HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "invalid object") + if(NULL == (cls = (H5VL_class_t *)H5I_object_verify(connector_id, H5I_VOL))) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a VOL connector ID") + + /* Call the corresponding internal VOL routine */ + if(H5VL__group_close(obj, cls, dxpl_id, req) < 0) + HGOTO_ERROR(H5E_VOL, H5E_CANTCLOSEOBJ, FAIL, "unable to close group") + +done: + FUNC_LEAVE_API_NOINIT(ret_value) +} /* end H5VLgroup_close() */ + + +/*------------------------------------------------------------------------- + * Function: H5VL__link_create + * + * Purpose: Creates a link through the VOL + * + * Note: The 'obj' parameter is allowed to be NULL + * + * Return: Success: Non-negative + * Failure: Negative + * + *------------------------------------------------------------------------- + */ +static herr_t +H5VL__link_create(H5VL_link_create_type_t create_type, void *obj, const H5VL_loc_params_t *loc_params, + const H5VL_class_t *cls, hid_t lcpl_id, hid_t lapl_id, hid_t dxpl_id, void **req) +{ + herr_t ret_value = SUCCEED; /* Return value */ + + FUNC_ENTER_STATIC + + /* Check if the corresponding VOL callback exists */ + if(NULL == cls->link_cls.create) + HGOTO_ERROR(H5E_VOL, H5E_UNSUPPORTED, FAIL, "VOL connector has no 'link create' method") + + /* Call the corresponding VOL callback */ + if((cls->link_cls.create)(create_type, obj, loc_params, lcpl_id, lapl_id, dxpl_id, req) < 0) + HGOTO_ERROR(H5E_VOL, H5E_CANTCREATE, FAIL, "link create failed") + +done: + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5VL__link_create() */ + + +/*------------------------------------------------------------------------- + * Function: H5VL_link_create + * + * Purpose: Creates a link through the VOL + * + * Return: Success: Non-negative + * Failure: Negative + * + *------------------------------------------------------------------------- + */ +herr_t +H5VL_link_create(H5VL_link_create_type_t create_type, const H5VL_object_t *vol_obj, + const H5VL_loc_params_t *loc_params, hid_t lcpl_id, hid_t lapl_id, hid_t dxpl_id, + void **req) +{ + H5VL_object_t tmp_vol_obj; /* Temporary object token of */ + hbool_t vol_wrapper_set = FALSE; /* Whether the VOL object wrapping context was set up */ + herr_t ret_value = SUCCEED; /* Return value */ + + FUNC_ENTER_NOAPI(FAIL) + + /* Special case for hard links */ + if(H5VL_LINK_CREATE_HARD == create_type && NULL == vol_obj->data) { + H5P_genplist_t *plist; /* Property list pointer */ + + /* Get the VOL data pointer from the fapl */ + if(NULL == (plist = (H5P_genplist_t *)H5I_object(lcpl_id))) + HGOTO_ERROR(H5E_VOL, H5E_BADTYPE, FAIL, "not a file access property list") + if(H5P_peek(plist, H5VL_PROP_LINK_TARGET, &tmp_vol_obj.data) < 0) + HGOTO_ERROR(H5E_VOL, H5E_CANTGET, FAIL, "can't get VOL connector info") + } /* end if */ + else + /* Use the VOL object passed in */ + tmp_vol_obj.data = vol_obj->data; + tmp_vol_obj.connector = vol_obj->connector; + + /* Set wrapper info in API context */ + if(H5VL_set_vol_wrapper(tmp_vol_obj.data, tmp_vol_obj.connector) < 0) + HGOTO_ERROR(H5E_VOL, H5E_CANTSET, FAIL, "can't set VOL wrapper info") + vol_wrapper_set = TRUE; + + /* Call the corresponding internal VOL routine */ + if(H5VL__link_create(create_type, vol_obj->data, loc_params, vol_obj->connector->cls, lcpl_id, lapl_id, dxpl_id, req) < 0) + HGOTO_ERROR(H5E_VOL, H5E_CANTCREATE, FAIL, "link create failed") + +done: + /* Reset object wrapping info in API context */ + if(vol_wrapper_set && H5VL_reset_vol_wrapper() < 0) + HDONE_ERROR(H5E_VOL, H5E_CANTRESET, FAIL, "can't reset VOL wrapper info") + + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5VL_link_create() */ + + +/*------------------------------------------------------------------------- + * Function: H5VLlink_create + * + * Purpose: Creates a link + * + * Note: The 'obj' parameter is allowed to be NULL + * + * Return: Success: Non-negative + * Failure: Negative + * + *------------------------------------------------------------------------- + */ +herr_t +H5VLlink_create(H5VL_link_create_type_t create_type, void *obj, const H5VL_loc_params_t *loc_params, + hid_t connector_id, hid_t lcpl_id, hid_t lapl_id, hid_t dxpl_id, void **req) +{ + H5VL_class_t *cls; /* VOL connector's class struct */ + herr_t ret_value = SUCCEED; /* Return value */ + + FUNC_ENTER_API_NOINIT + H5TRACE8("e", "Vk*x*xiiii**x", create_type, obj, loc_params, connector_id, + lcpl_id, lapl_id, dxpl_id, req); + + /* Get class pointer */ + if(NULL == (cls = (H5VL_class_t *)H5I_object_verify(connector_id, H5I_VOL))) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a VOL connector ID") + + /* Call the corresponding internal VOL routine */ + if(H5VL__link_create(create_type, obj, loc_params, cls, lcpl_id, lapl_id, dxpl_id, req) < 0) + HGOTO_ERROR(H5E_VOL, H5E_CANTCREATE, FAIL, "unable to create link") + +done: + FUNC_LEAVE_API_NOINIT(ret_value) +} /* end H5VLlink_create() */ + + +/*------------------------------------------------------------------------- + * Function: H5VL__link_copy + * + * Purpose: Copys a link from src to dst. + * + * Return: Success: Non-negative + * Failure: Negative + * + *------------------------------------------------------------------------- + */ +static herr_t +H5VL__link_copy(void *src_obj, const H5VL_loc_params_t *loc_params1, void *dst_obj, + const H5VL_loc_params_t *loc_params2, const H5VL_class_t *cls, hid_t lcpl_id, + hid_t lapl_id, hid_t dxpl_id, void **req) +{ + herr_t ret_value = SUCCEED; /* Return value */ + + FUNC_ENTER_STATIC + + /* Check if the corresponding VOL callback exists */ + if(NULL == cls->link_cls.copy) + HGOTO_ERROR(H5E_VOL, H5E_UNSUPPORTED, FAIL, "VOL connector has no 'link copy' method") + + /* Call the corresponding VOL callback */ + if((cls->link_cls.copy)(src_obj, loc_params1, dst_obj, loc_params2, lcpl_id, lapl_id, dxpl_id, req) < 0) + HGOTO_ERROR(H5E_VOL, H5E_CANTCOPY, FAIL, "link copy failed") + +done: + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5VL__link_copy() */ + + +/*------------------------------------------------------------------------- + * Function: H5VL_link_copy + * + * Purpose: Copys a link from src to dst. + * + * Return: Success: Non-negative + * Failure: Negative + * + *------------------------------------------------------------------------- + */ +herr_t +H5VL_link_copy(const H5VL_object_t *src_vol_obj, const H5VL_loc_params_t *loc_params1, + const H5VL_object_t *dst_vol_obj, const H5VL_loc_params_t *loc_params2, hid_t lcpl_id, + hid_t lapl_id, hid_t dxpl_id, void **req) +{ + const H5VL_object_t *vol_obj; /* VOL object for object with data */ + hbool_t vol_wrapper_set = FALSE; /* Whether the VOL object wrapping context was set up */ + herr_t ret_value = SUCCEED; /* Return value */ + + FUNC_ENTER_NOAPI(FAIL) + + /* Set wrapper info in API context */ + vol_obj = (src_vol_obj->data ? src_vol_obj : dst_vol_obj); + if(H5VL_set_vol_wrapper(vol_obj->data, vol_obj->connector) < 0) + HGOTO_ERROR(H5E_VOL, H5E_CANTSET, FAIL, "can't set VOL wrapper info") + vol_wrapper_set = TRUE; + + /* Call the corresponding internal VOL routine */ + if(H5VL__link_copy((src_vol_obj->data ? src_vol_obj->data : NULL), loc_params1, (dst_vol_obj ? dst_vol_obj->data : NULL), loc_params2, vol_obj->connector->cls, lcpl_id, lapl_id, dxpl_id, req) < 0) + HGOTO_ERROR(H5E_VOL, H5E_CANTCOPY, FAIL, "link copy failed") + +done: + /* Reset object wrapping info in API context */ + if(vol_wrapper_set && H5VL_reset_vol_wrapper() < 0) + HDONE_ERROR(H5E_VOL, H5E_CANTRESET, FAIL, "can't reset VOL wrapper info") + + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5VL_link_copy() */ + + +/*------------------------------------------------------------------------- + * Function: H5VLlink_copy + * + * Purpose: Copies a link to a new location + * + * Note: The 'src_obj' and 'dst_obj' parameters are allowed to be NULL + * + * Return: Success: Non-negative + * Failure: Negative + * + *------------------------------------------------------------------------- + */ +herr_t +H5VLlink_copy(void *src_obj, const H5VL_loc_params_t *loc_params1, void *dst_obj, + const H5VL_loc_params_t *loc_params2, hid_t connector_id, hid_t lcpl_id, + hid_t lapl_id, hid_t dxpl_id, void **req) +{ + H5VL_class_t *cls; /* VOL connector's class struct */ + herr_t ret_value = SUCCEED; /* Return value */ + + FUNC_ENTER_API_NOINIT + H5TRACE9("e", "*x*x*x*xiiii**x", src_obj, loc_params1, dst_obj, loc_params2, + connector_id, lcpl_id, lapl_id, dxpl_id, req); + + /* Get class pointer */ + if(NULL == (cls = (H5VL_class_t *)H5I_object_verify(connector_id, H5I_VOL))) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a VOL connector ID") + + /* Call the corresponding internal VOL routine */ + if(H5VL__link_copy(src_obj, loc_params1, dst_obj, loc_params2, cls, lcpl_id, lapl_id, dxpl_id, req) < 0) + HGOTO_ERROR(H5E_VOL, H5E_CANTCOPY, FAIL, "unable to copy object") + +done: + FUNC_LEAVE_API_NOINIT(ret_value) +} /* end H5VLlink_copy() */ + + +/*------------------------------------------------------------------------- + * Function: H5VL__link_move + * + * Purpose: Moves a link from src to dst. + * + * Return: Success: Non-negative + * Failure: Negative + * + *------------------------------------------------------------------------- + */ +static herr_t +H5VL__link_move(void *src_obj, const H5VL_loc_params_t *loc_params1, void *dst_obj, + const H5VL_loc_params_t *loc_params2, const H5VL_class_t *cls, hid_t lcpl_id, + hid_t lapl_id, hid_t dxpl_id, void **req) +{ + herr_t ret_value = SUCCEED; /* Return value */ + + FUNC_ENTER_STATIC + + /* Check if the corresponding VOL callback exists */ + if(NULL == cls->link_cls.move) + HGOTO_ERROR(H5E_VOL, H5E_UNSUPPORTED, FAIL, "VOL connector has no 'link move' method") + + /* Call the corresponding VOL callback */ + if((cls->link_cls.move)(src_obj, loc_params1, dst_obj, loc_params2, lcpl_id, lapl_id, dxpl_id, req) < 0) + HGOTO_ERROR(H5E_VOL, H5E_CANTMOVE, FAIL, "link move failed") + +done: + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5VL__link_move() */ + + +/*------------------------------------------------------------------------- + * Function: H5VL_link_move + * + * Purpose: Moves a link from src to dst. + * + * Return: Success: Non-negative + * Failure: Negative + * + *------------------------------------------------------------------------- + */ +herr_t +H5VL_link_move(const H5VL_object_t *src_vol_obj, const H5VL_loc_params_t *loc_params1, + const H5VL_object_t *dst_vol_obj, const H5VL_loc_params_t *loc_params2, hid_t lcpl_id, + hid_t lapl_id, hid_t dxpl_id, void **req) +{ + const H5VL_object_t *vol_obj; /* VOL object for object with data */ + hbool_t vol_wrapper_set = FALSE; /* Whether the VOL object wrapping context was set up */ + herr_t ret_value = SUCCEED; /* Return value */ + + FUNC_ENTER_NOAPI(FAIL) + + /* Set wrapper info in API context */ + vol_obj = (src_vol_obj ? src_vol_obj : dst_vol_obj); + if(H5VL_set_vol_wrapper(vol_obj->data, vol_obj->connector) < 0) + HGOTO_ERROR(H5E_VOL, H5E_CANTSET, FAIL, "can't set VOL wrapper info") + vol_wrapper_set = TRUE; + + /* Call the corresponding internal VOL routine */ + if(H5VL__link_move((src_vol_obj ? src_vol_obj->data : NULL), loc_params1, (dst_vol_obj ? dst_vol_obj->data : NULL), loc_params2, vol_obj->connector->cls, lcpl_id, lapl_id, dxpl_id, req) < 0) + HGOTO_ERROR(H5E_VOL, H5E_CANTMOVE, FAIL, "link move failed") + +done: + /* Reset object wrapping info in API context */ + if(vol_wrapper_set && H5VL_reset_vol_wrapper() < 0) + HDONE_ERROR(H5E_VOL, H5E_CANTRESET, FAIL, "can't reset VOL wrapper info") + + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5VL_link_move() */ + + +/*------------------------------------------------------------------------- + * Function: H5VLlink_move + * + * Purpose: Moves a link to another location + * + * Note: The 'src_obj' and 'dst_obj' parameters are allowed to be NULL + * + * Return: Success: Non-negative + * Failure: Negative + * + *------------------------------------------------------------------------- + */ +herr_t +H5VLlink_move(void *src_obj, const H5VL_loc_params_t *loc_params1, void *dst_obj, + const H5VL_loc_params_t *loc_params2, hid_t connector_id, hid_t lcpl_id, + hid_t lapl_id, hid_t dxpl_id, void **req) +{ + H5VL_class_t *cls; /* VOL connector's class struct */ + herr_t ret_value = SUCCEED; /* Return value */ + + FUNC_ENTER_API_NOINIT + H5TRACE9("e", "*x*x*x*xiiii**x", src_obj, loc_params1, dst_obj, loc_params2, + connector_id, lcpl_id, lapl_id, dxpl_id, req); + + /* Get class pointer */ + if(NULL == (cls = (H5VL_class_t *)H5I_object_verify(connector_id, H5I_VOL))) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a VOL connector ID") + + /* Call the corresponding internal VOL routine */ + if(H5VL__link_move(src_obj, loc_params1, dst_obj, loc_params2, cls, lcpl_id, lapl_id, dxpl_id, req) < 0) + HGOTO_ERROR(H5E_VOL, H5E_CANTMOVE, FAIL, "unable to move object") + +done: + FUNC_LEAVE_API_NOINIT(ret_value) +} /* end H5VLlink_move() */ + + +/*------------------------------------------------------------------------- + * Function: H5VL__link_get + * + * Purpose: Get specific information about the link through the VOL + * + * Return: Success: Non-negative + * Failure: Negative + * + *------------------------------------------------------------------------- + */ +static herr_t +H5VL__link_get(void *obj, const H5VL_loc_params_t *loc_params, const H5VL_class_t *cls, + H5VL_link_get_t get_type, hid_t dxpl_id, void **req, va_list arguments) +{ + herr_t ret_value = SUCCEED; /* Return value */ + + FUNC_ENTER_STATIC + + /* Check if the corresponding VOL callback exists */ + if(NULL == cls->link_cls.get) + HGOTO_ERROR(H5E_VOL, H5E_UNSUPPORTED, FAIL, "VOL connector has no 'link get' method") + + /* Call the corresponding VOL callback */ + if((cls->link_cls.get)(obj, loc_params, get_type, dxpl_id, req, arguments) < 0) + HGOTO_ERROR(H5E_VOL, H5E_CANTGET, FAIL, "link get failed") + +done: + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5VL__link_get() */ + + +/*------------------------------------------------------------------------- + * Function: H5VL_link_get + * + * Purpose: Get specific information about the link through the VOL + * + * Return: Success: Non-negative + * Failure: Negative + * + *------------------------------------------------------------------------- + */ +herr_t +H5VL_link_get(const H5VL_object_t *vol_obj, const H5VL_loc_params_t *loc_params, + H5VL_link_get_t get_type, hid_t dxpl_id, void **req, ...) +{ + va_list arguments; /* Argument list passed from the API call */ + hbool_t arg_started = FALSE; /* Whether the va_list has been started */ + hbool_t vol_wrapper_set = FALSE; /* Whether the VOL object wrapping context was set up */ + herr_t ret_value = SUCCEED; /* Return value */ + + FUNC_ENTER_NOAPI(FAIL) + + /* Set wrapper info in API context */ + if(H5VL_set_vol_wrapper(vol_obj->data, vol_obj->connector) < 0) + HGOTO_ERROR(H5E_VOL, H5E_CANTSET, FAIL, "can't set VOL wrapper info") + vol_wrapper_set = TRUE; + + /* Call the corresponding internal VOL routine */ + HDva_start(arguments, req); + arg_started = TRUE; + if(H5VL__link_get(vol_obj->data, loc_params, vol_obj->connector->cls, get_type, dxpl_id, req, arguments) < 0) + HGOTO_ERROR(H5E_VOL, H5E_CANTGET, FAIL, "link get failed") + +done: + /* End access to the va_list, if we started it */ + if(arg_started) + HDva_end(arguments); + + /* Reset object wrapping info in API context */ + if(vol_wrapper_set && H5VL_reset_vol_wrapper() < 0) + HDONE_ERROR(H5E_VOL, H5E_CANTRESET, FAIL, "can't reset VOL wrapper info") + + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5VL_link_get() */ + + +/*------------------------------------------------------------------------- + * Function: H5VLlink_get + * + * Purpose: Gets information about a link + * + * Return: Success: Non-negative + * Failure: Negative + * + *------------------------------------------------------------------------- + */ +herr_t +H5VLlink_get(void *obj, const H5VL_loc_params_t *loc_params, hid_t connector_id, H5VL_link_get_t get_type, + hid_t dxpl_id, void **req, va_list arguments) +{ + H5VL_class_t *cls; /* VOL connector's class struct */ + herr_t ret_value = SUCCEED; /* Return value */ + + FUNC_ENTER_API_NOINIT + H5TRACE7("e", "*x*xiVli**xx", obj, loc_params, connector_id, get_type, dxpl_id, + req, arguments); + + /* Check args and get class pointer */ + if(NULL == obj) + HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "invalid object") + if(NULL == (cls = (H5VL_class_t *)H5I_object_verify(connector_id, H5I_VOL))) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a VOL connector ID") + + /* Call the corresponding internal VOL routine */ + if(H5VL__link_get(obj, loc_params, cls, get_type, dxpl_id, req, arguments) < 0) + HGOTO_ERROR(H5E_VOL, H5E_CANTGET, FAIL, "unable to execute link get callback") + +done: + FUNC_LEAVE_API_NOINIT(ret_value) +} /* end H5VLlink_get() */ + + +/*------------------------------------------------------------------------- + * Function: H5VL__link_specific + * + * Purpose: Specific operation on links through the VOL + * + * Return: Success: Non-negative + * Failure: Negative + * + *------------------------------------------------------------------------- + */ +static herr_t +H5VL__link_specific(void *obj, const H5VL_loc_params_t *loc_params, const H5VL_class_t *cls, + H5VL_link_specific_t specific_type, hid_t dxpl_id, void **req, va_list arguments) +{ + herr_t ret_value = SUCCEED; /* Return value */ + + FUNC_ENTER_STATIC + + /* Check if the corresponding VOL callback exists */ + if(NULL == cls->link_cls.specific) + HGOTO_ERROR(H5E_VOL, H5E_UNSUPPORTED, FAIL, "VOL connector has no 'link specific' method") + + /* Call the corresponding VOL callback */ + if((ret_value = (cls->link_cls.specific)(obj, loc_params, specific_type, dxpl_id, req, arguments)) < 0) + HGOTO_ERROR(H5E_VOL, H5E_CANTOPERATE, FAIL, "unable to execute link specific callback") + +done: + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5VL__link_specific() */ + + +/*------------------------------------------------------------------------- + * Function: H5VL_link_specific + * + * Purpose: Specific operation on links through the VOL + * + * Return: Success: Non-negative + * Failure: Negative + * + *------------------------------------------------------------------------- + */ +herr_t +H5VL_link_specific(const H5VL_object_t *vol_obj, const H5VL_loc_params_t *loc_params, + H5VL_link_specific_t specific_type, hid_t dxpl_id, void **req, ...) +{ + va_list arguments; /* Argument list passed from the API call */ + hbool_t arg_started = FALSE; /* Whether the va_list has been started */ + hbool_t vol_wrapper_set = FALSE; /* Whether the VOL object wrapping context was set up */ + herr_t ret_value = SUCCEED; /* Return value */ + + FUNC_ENTER_NOAPI(FAIL) + + /* Set wrapper info in API context */ + if(H5VL_set_vol_wrapper(vol_obj->data, vol_obj->connector) < 0) + HGOTO_ERROR(H5E_VOL, H5E_CANTSET, FAIL, "can't set VOL wrapper info") + vol_wrapper_set = TRUE; + + /* Call the corresponding internal VOL routine */ + HDva_start(arguments, req); + arg_started = TRUE; + if((ret_value = H5VL__link_specific(vol_obj->data, loc_params, vol_obj->connector->cls, specific_type, dxpl_id, req, arguments)) < 0) + HGOTO_ERROR(H5E_VOL, H5E_CANTOPERATE, FAIL, "unable to execute link specific callback") + +done: + /* End access to the va_list, if we started it */ + if(arg_started) + HDva_end(arguments); + + /* Reset object wrapping info in API context */ + if(vol_wrapper_set && H5VL_reset_vol_wrapper() < 0) + HDONE_ERROR(H5E_VOL, H5E_CANTRESET, FAIL, "can't reset VOL wrapper info") + + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5VL_link_specific() */ + + +/*------------------------------------------------------------------------- + * Function: H5VLlink_specific + * + * Purpose: Performs a connector-specific operation on a link + * + * Return: Success: Non-negative + * Failure: Negative + * + *------------------------------------------------------------------------- + */ +herr_t +H5VLlink_specific(void *obj, const H5VL_loc_params_t *loc_params, hid_t connector_id, + H5VL_link_specific_t specific_type, hid_t dxpl_id, void **req, va_list arguments) +{ + H5VL_class_t *cls; /* VOL connector's class struct */ + herr_t ret_value = SUCCEED; /* Return value */ + + FUNC_ENTER_API_NOINIT + H5TRACE7("e", "*x*xiVmi**xx", obj, loc_params, connector_id, specific_type, + dxpl_id, req, arguments); + + /* Check args and get class pointer */ + if(NULL == obj) + HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "invalid object") + if(NULL == (cls = (H5VL_class_t *)H5I_object_verify(connector_id, H5I_VOL))) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a VOL connector ID") + + /* Call the corresponding internal VOL routine */ + if((ret_value = H5VL__link_specific(obj, loc_params, cls, specific_type, dxpl_id, req, arguments)) < 0) + HGOTO_ERROR(H5E_VOL, H5E_CANTOPERATE, FAIL, "unable to execute link specific callback") + +done: + FUNC_LEAVE_API_NOINIT(ret_value) +} /* end H5VLlink_specific() */ + + +/*------------------------------------------------------------------------- + * Function: H5VL__link_optional + * + * Purpose: Optional operation specific to connectors. + * + * Return: Success: Non-negative + * Failure: Negative + * + *------------------------------------------------------------------------- + */ +static herr_t +H5VL__link_optional(void *obj, const H5VL_class_t *cls, hid_t dxpl_id, + void **req, va_list arguments) +{ + herr_t ret_value = SUCCEED; /* Return value */ + + FUNC_ENTER_STATIC + + /* Check if the corresponding VOL callback exists */ + if(NULL == cls->link_cls.optional) + HGOTO_ERROR(H5E_VOL, H5E_UNSUPPORTED, FAIL, "VOL connector has no 'link optional' method") + + /* Call the corresponding VOL callback */ + if((cls->link_cls.optional)(obj, dxpl_id, req, arguments) < 0) + HGOTO_ERROR(H5E_VOL, H5E_CANTOPERATE, FAIL, "unable to execute link optional callback") + +done: + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5VL__link_optional() */ + + +/*------------------------------------------------------------------------- + * Function: H5VL_link_optional + * + * Purpose: Optional operation specific to connectors. + * + * Return: Success: Non-negative + * Failure: Negative + * + *------------------------------------------------------------------------- + */ +herr_t +H5VL_link_optional(const H5VL_object_t *vol_obj, hid_t dxpl_id, void **req, ...) +{ + va_list arguments; /* Argument list passed from the API call */ + hbool_t arg_started = FALSE; /* Whether the va_list has been started */ + hbool_t vol_wrapper_set = FALSE; /* Whether the VOL object wrapping context was set up */ + herr_t ret_value = SUCCEED; /* Return value */ + + FUNC_ENTER_NOAPI(FAIL) + + /* Set wrapper info in API context */ + if(H5VL_set_vol_wrapper(vol_obj->data, vol_obj->connector) < 0) + HGOTO_ERROR(H5E_VOL, H5E_CANTSET, FAIL, "can't set VOL wrapper info") + vol_wrapper_set = TRUE; + + /* Call the corresponding internal VOL routine */ + HDva_start(arguments, req); + arg_started = TRUE; + if(H5VL__link_optional(vol_obj->data, vol_obj->connector->cls, dxpl_id, req, arguments) < 0) + HGOTO_ERROR(H5E_VOL, H5E_CANTOPERATE, FAIL, "unable to execute link optional callback") + +done: + /* End access to the va_list, if we started it */ + if(arg_started) + HDva_end(arguments); + + /* Reset object wrapping info in API context */ + if(vol_wrapper_set && H5VL_reset_vol_wrapper() < 0) + HDONE_ERROR(H5E_VOL, H5E_CANTRESET, FAIL, "can't reset VOL wrapper info") + + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5VL_link_optional() */ + + +/*------------------------------------------------------------------------- + * Function: H5VLlink_optional + * + * Purpose: Performs an optional connector-specific operation on a link + * + * Return: Success: Non-negative + * Failure: Negative + * + *------------------------------------------------------------------------- + */ +herr_t +H5VLlink_optional(void *obj, hid_t connector_id, hid_t dxpl_id, void **req, va_list arguments) +{ + H5VL_class_t *cls; /* VOL connector's class struct */ + herr_t ret_value = SUCCEED; /* Return value */ + + FUNC_ENTER_API_NOINIT + H5TRACE5("e", "*xii**xx", obj, connector_id, dxpl_id, req, arguments); + + /* Check args and get class pointer */ + if(NULL == obj) + HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "invalid object") + if(NULL == (cls = (H5VL_class_t *)H5I_object_verify(connector_id, H5I_VOL))) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a VOL connector ID") + + /* Call the corresponding internal VOL routine */ + if(H5VL__link_optional(obj, cls, dxpl_id, req, arguments) < 0) + HGOTO_ERROR(H5E_VOL, H5E_CANTOPERATE, FAIL, "unable to execute link optional callback") + +done: + FUNC_LEAVE_API_NOINIT(ret_value) +} /* end H5VLlink_optional() */ + + +/*------------------------------------------------------------------------- + * Function: H5VL__object_open + * + * Purpose: Opens a object through the VOL + * + * Return: Success: Pointer to the object + * Failure: NULL + * + *------------------------------------------------------------------------- + */ +static void * +H5VL__object_open(void *obj, const H5VL_loc_params_t *params, const H5VL_class_t *cls, H5I_type_t *opened_type, + hid_t dxpl_id, void **req) +{ + void *ret_value = NULL; /* Return value */ + + FUNC_ENTER_STATIC + + /* Check if the corresponding VOL callback exists */ + if(NULL == cls->object_cls.open) + HGOTO_ERROR(H5E_VOL, H5E_UNSUPPORTED, NULL, "VOL connector has no 'object open' method") + + /* Call the corresponding VOL callback */ + if(NULL == (ret_value = (cls->object_cls.open)(obj, params, opened_type, dxpl_id, req))) + HGOTO_ERROR(H5E_VOL, H5E_CANTOPENOBJ, NULL, "object open failed") + +done: + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5VL__object_open() */ + + +/*------------------------------------------------------------------------- + * Function: H5VL_object_open + * + * Purpose: Opens a object through the VOL + * + * Return: Success: Pointer to the object + * Failure: NULL + * + *------------------------------------------------------------------------- + */ +void * +H5VL_object_open(const H5VL_object_t *vol_obj, const H5VL_loc_params_t *params, + H5I_type_t *opened_type, hid_t dxpl_id, void **req) +{ + hbool_t vol_wrapper_set = FALSE; /* Whether the VOL object wrapping context was set up */ + void *ret_value = NULL; /* Return value */ + + FUNC_ENTER_NOAPI(NULL) + + /* Set wrapper info in API context */ + if(H5VL_set_vol_wrapper(vol_obj->data, vol_obj->connector) < 0) + HGOTO_ERROR(H5E_VOL, H5E_CANTSET, NULL, "can't set VOL wrapper info") + vol_wrapper_set = TRUE; + + /* Call the corresponding internal VOL routine */ + if(NULL == (ret_value = H5VL__object_open(vol_obj->data, params, vol_obj->connector->cls, opened_type, dxpl_id, req))) + HGOTO_ERROR(H5E_VOL, H5E_CANTOPENOBJ, NULL, "object open failed") + +done: + /* Reset object wrapping info in API context */ + if(vol_wrapper_set && H5VL_reset_vol_wrapper() < 0) + HDONE_ERROR(H5E_VOL, H5E_CANTRESET, NULL, "can't reset VOL wrapper info") + + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5VL_object_open() */ + + +/*------------------------------------------------------------------------- + * Function: H5VLobject_open + * + * Purpose: Opens an object + * + * Return: Success: Pointer to the object + * Failure: NULL + * + *------------------------------------------------------------------------- + */ +void * +H5VLobject_open(void *obj, const H5VL_loc_params_t *params, hid_t connector_id, H5I_type_t *opened_type, + hid_t dxpl_id, void **req) +{ + H5VL_class_t *cls; /* VOL connector's class struct */ + void *ret_value = NULL; /* Return value */ + + FUNC_ENTER_API_NOINIT + H5TRACE6("*x", "*x*xi*Iti**x", obj, params, connector_id, opened_type, dxpl_id, + req); + + /* Check args and get class pointer */ + if(NULL == obj) + HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, NULL, "invalid object") + if(NULL == (cls = (H5VL_class_t *)H5I_object_verify(connector_id, H5I_VOL))) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, NULL, "not a VOL connector ID") + + /* Call the corresponding internal VOL routine */ + if(NULL == (ret_value = H5VL__object_open(obj, params, cls, opened_type, dxpl_id, req))) + HGOTO_ERROR(H5E_VOL, H5E_CANTOPENOBJ, NULL, "unable to open object") + +done: + FUNC_LEAVE_API_NOINIT(ret_value) +} /* end H5VLobject_open() */ + + +/*------------------------------------------------------------------------- + * Function: H5VL__object_copy + * + * Purpose: Copies an object to another destination through the VOL + * + * Return: Success: Non-negative + * Failure: Negative + * + *------------------------------------------------------------------------- + */ +static herr_t +H5VL__object_copy(void *src_obj, const H5VL_loc_params_t *src_loc_params, const char *src_name, + void *dst_obj, const H5VL_loc_params_t *dst_loc_params, const char *dst_name, + const H5VL_class_t *cls, hid_t ocpypl_id, hid_t lcpl_id, hid_t dxpl_id, + void **req) +{ + herr_t ret_value = SUCCEED; /* Return value */ + + FUNC_ENTER_STATIC + + /* Check if the corresponding VOL callback exists */ + if(NULL == cls->object_cls.copy) + HGOTO_ERROR(H5E_VOL, H5E_UNSUPPORTED, FAIL, "VOL connector has no 'object copy' method") + + /* Call the corresponding VOL callback */ + if((cls->object_cls.copy)(src_obj, src_loc_params, src_name, dst_obj, dst_loc_params, dst_name, ocpypl_id, lcpl_id, dxpl_id, req) < 0) + HGOTO_ERROR(H5E_VOL, H5E_CANTCOPY, FAIL, "object copy failed") + +done: + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5VL__object_copy() */ + + +/*------------------------------------------------------------------------- + * Function: H5VL_object_copy + * + * Purpose: Copies an object to another destination through the VOL + * + * Return: Success: Non-negative + * Failure: Negative + * + *------------------------------------------------------------------------- + */ +herr_t +H5VL_object_copy(const H5VL_object_t *src_obj, const H5VL_loc_params_t *src_loc_params, + const char *src_name, const H5VL_object_t *dst_obj, const H5VL_loc_params_t *dst_loc_params, + const char *dst_name, hid_t ocpypl_id, hid_t lcpl_id, hid_t dxpl_id, + void **req) +{ + hbool_t vol_wrapper_set = FALSE; /* Whether the VOL object wrapping context was set up */ + herr_t ret_value = SUCCEED; /* Return value */ + + FUNC_ENTER_NOAPI(FAIL) + + /* Make sure that the VOL connectors are the same */ + if(src_obj->connector->cls->value != dst_obj->connector->cls->value) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "objects are accessed through different VOL connectors and can't be copied") + + /* Set wrapper info in API context */ + if(H5VL_set_vol_wrapper(src_obj->data, src_obj->connector) < 0) + HGOTO_ERROR(H5E_VOL, H5E_CANTSET, FAIL, "can't set VOL wrapper info") + vol_wrapper_set = TRUE; + + /* Call the corresponding internal VOL routine */ + if(H5VL__object_copy(src_obj->data, src_loc_params, src_name, dst_obj->data, dst_loc_params, dst_name, src_obj->connector->cls, ocpypl_id, lcpl_id, dxpl_id, req) < 0) + HGOTO_ERROR(H5E_VOL, H5E_CANTCOPY, FAIL, "object copy failed") + +done: + /* Reset object wrapping info in API context */ + if(vol_wrapper_set && H5VL_reset_vol_wrapper() < 0) + HDONE_ERROR(H5E_VOL, H5E_CANTRESET, FAIL, "can't reset VOL wrapper info") + + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5VL_object_copy() */ + + +/*------------------------------------------------------------------------- + * Function: H5VLobject_copy + * + * Purpose: Copies an object to another location + * + * Return: Success: Non-negative + * Failure: Negative + * + *------------------------------------------------------------------------- + */ +herr_t +H5VLobject_copy(void *src_obj, const H5VL_loc_params_t *src_loc_params, + const char *src_name, void *dst_obj, const H5VL_loc_params_t *dst_loc_params, + const char *dst_name, hid_t connector_id, hid_t ocpypl_id, hid_t lcpl_id, + hid_t dxpl_id, void **req) +{ + H5VL_class_t *cls; /* VOL connector's class struct */ + herr_t ret_value = SUCCEED; /* Return value */ + + FUNC_ENTER_API_NOINIT + H5TRACE11("e", "*x*x*s*x*x*siiii**x", src_obj, src_loc_params, src_name, + dst_obj, dst_loc_params, dst_name, connector_id, ocpypl_id, lcpl_id, + dxpl_id, req); + + /* Check args and get class pointers */ + if(NULL == src_obj || NULL == dst_obj) + HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "invalid object") + if(NULL == (cls = (H5VL_class_t *)H5I_object_verify(connector_id, H5I_VOL))) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a VOL connector ID") + + /* Call the corresponding internal VOL routine */ + if(H5VL__object_copy(src_obj, src_loc_params, src_name, dst_obj, dst_loc_params, dst_name, cls, ocpypl_id, lcpl_id, dxpl_id, req) < 0) + HGOTO_ERROR(H5E_VOL, H5E_CANTCOPY, FAIL, "unable to copy object") + +done: + FUNC_LEAVE_API_NOINIT(ret_value) +} /* end H5VLobject_copy() */ + + +/*------------------------------------------------------------------------- + * Function: H5VL__object_get + * + * Purpose: Get specific information about the object through the VOL + * + * Return: Success: Non-negative + * Failure: Negative + * + *------------------------------------------------------------------------- + */ +static herr_t +H5VL__object_get(void *obj, const H5VL_loc_params_t *loc_params, const H5VL_class_t *cls, + H5VL_object_get_t get_type, hid_t dxpl_id, void **req, va_list arguments) +{ + herr_t ret_value = SUCCEED; /* Return value */ + + FUNC_ENTER_STATIC + + /* Check if the corresponding VOL callback exists */ + if(NULL == cls->object_cls.get) + HGOTO_ERROR(H5E_VOL, H5E_UNSUPPORTED, FAIL, "VOL connector has no 'object get' method") + + /* Call the corresponding VOL callback */ + if((cls->object_cls.get)(obj, loc_params, get_type, dxpl_id, req, arguments) < 0) + HGOTO_ERROR(H5E_VOL, H5E_CANTGET, FAIL, "get failed") + +done: + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5VL__object_get() */ + + +/*------------------------------------------------------------------------- + * Function: H5VL_object_get + * + * Purpose: Get specific information about the object through the VOL + * + * Return: Success: Non-negative + * Failure: Negative + * + *------------------------------------------------------------------------- + */ +herr_t +H5VL_object_get(const H5VL_object_t *vol_obj, const H5VL_loc_params_t *loc_params, + H5VL_object_get_t get_type, hid_t dxpl_id, void **req, ...) +{ + va_list arguments; /* Argument list passed from the API call */ + hbool_t arg_started = FALSE; /* Whether the va_list has been started */ + hbool_t vol_wrapper_set = FALSE; /* Whether the VOL object wrapping context was set up */ + herr_t ret_value = SUCCEED; /* Return value */ + + FUNC_ENTER_NOAPI(FAIL) + + /* Set wrapper info in API context */ + if(H5VL_set_vol_wrapper(vol_obj->data, vol_obj->connector) < 0) + HGOTO_ERROR(H5E_VOL, H5E_CANTSET, FAIL, "can't set VOL wrapper info") + vol_wrapper_set = TRUE; + + /* Call the corresponding internal VOL routine */ + HDva_start(arguments, req); + arg_started = TRUE; + if(H5VL__object_get(vol_obj->data, loc_params, vol_obj->connector->cls, get_type, dxpl_id, req, arguments) < 0) + HGOTO_ERROR(H5E_VOL, H5E_CANTGET, FAIL, "get failed") + +done: + /* End access to the va_list, if we started it */ + if(arg_started) + HDva_end(arguments); + + /* Reset object wrapping info in API context */ + if(vol_wrapper_set && H5VL_reset_vol_wrapper() < 0) + HDONE_ERROR(H5E_VOL, H5E_CANTRESET, FAIL, "can't reset VOL wrapper info") + + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5VL_object_get() */ + + +/*------------------------------------------------------------------------- + * Function: H5VLobject_get + * + * Purpose: Gets information about an object + * + * Return: Success: Non-negative + * Failure: Negative + * + *------------------------------------------------------------------------- + */ +herr_t +H5VLobject_get(void *obj, const H5VL_loc_params_t *loc_params, hid_t connector_id, H5VL_object_get_t get_type, + hid_t dxpl_id, void **req, va_list arguments) +{ + H5VL_class_t *cls; /* VOL connector's class struct */ + herr_t ret_value = SUCCEED; /* Return value */ + + FUNC_ENTER_API_NOINIT + H5TRACE7("e", "*x*xiVni**xx", obj, loc_params, connector_id, get_type, dxpl_id, + req, arguments); + + /* Check args and get class pointer */ + if(NULL == obj) + HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "invalid object") + if(NULL == (cls = (H5VL_class_t *)H5I_object_verify(connector_id, H5I_VOL))) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a VOL connector ID") + + /* Call the corresponding internal VOL routine */ + if(H5VL__object_get(obj, loc_params, cls, get_type, dxpl_id, req, arguments) < 0) + HGOTO_ERROR(H5E_VOL, H5E_CANTGET, FAIL, "unable to execute object get callback") + +done: + FUNC_LEAVE_API_NOINIT(ret_value) +} /* end H5VLobject_get() */ + + +/*------------------------------------------------------------------------- + * Function: H5VL__object_specific + * + * Purpose: Specific operation on objects through the VOL + * + * Return: Success: Non-negative + * Failure: Negative + * + *------------------------------------------------------------------------- + */ +static herr_t +H5VL__object_specific(void *obj, const H5VL_loc_params_t *loc_params, const H5VL_class_t *cls, + H5VL_object_specific_t specific_type, hid_t dxpl_id, void **req, + va_list arguments) +{ + herr_t ret_value = SUCCEED; /* Return value */ + + FUNC_ENTER_STATIC + + /* Check if the corresponding VOL callback exists */ + if(NULL == cls->object_cls.specific) + HGOTO_ERROR(H5E_VOL, H5E_UNSUPPORTED, FAIL, "VOL connector has no 'object specific' method") + + /* Call the corresponding VOL callback */ + if((ret_value = (cls->object_cls.specific)(obj, loc_params, specific_type, dxpl_id, req, arguments)) < 0) + HGOTO_ERROR(H5E_VOL, H5E_CANTOPERATE, FAIL, "object specific failed") + +done: + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5VL__object_specific() */ + + +/*------------------------------------------------------------------------- + * Function: H5VL_object_specific + * + * Purpose: Specific operation on objects through the VOL + * + * Return: Success: Non-negative + * Failure: Negative + * + *------------------------------------------------------------------------- + */ +herr_t +H5VL_object_specific(const H5VL_object_t *vol_obj, const H5VL_loc_params_t *loc_params, + H5VL_object_specific_t specific_type, hid_t dxpl_id, void **req, ...) +{ + va_list arguments; /* Argument list passed from the API call */ + hbool_t arg_started = FALSE; /* Whether the va_list has been started */ + hbool_t vol_wrapper_set = FALSE; /* Whether the VOL object wrapping context was set up */ + herr_t ret_value = SUCCEED; /* Return value */ + + FUNC_ENTER_NOAPI(FAIL) + + /* Set wrapper info in API context */ + if(H5VL_set_vol_wrapper(vol_obj->data, vol_obj->connector) < 0) + HGOTO_ERROR(H5E_VOL, H5E_CANTSET, FAIL, "can't set VOL wrapper info") + vol_wrapper_set = TRUE; + + /* Call the corresponding internal VOL routine */ + HDva_start(arguments, req); + arg_started = TRUE; + if((ret_value = H5VL__object_specific(vol_obj->data, loc_params, vol_obj->connector->cls, specific_type, dxpl_id, req, arguments)) < 0) + HGOTO_ERROR(H5E_VOL, H5E_CANTOPERATE, FAIL, "object specific failed") + +done: + /* End access to the va_list, if we started it */ + if(arg_started) + HDva_end(arguments); + + /* Reset object wrapping info in API context */ + if(vol_wrapper_set && H5VL_reset_vol_wrapper() < 0) + HDONE_ERROR(H5E_VOL, H5E_CANTRESET, FAIL, "can't reset VOL wrapper info") + + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5VL_object_specific() */ + + +/*------------------------------------------------------------------------- + * Function: H5VLobject_specific + * + * Purpose: Performs a connector-specific operation on an object + * + * Return: Success: Non-negative + * Failure: Negative + * + *------------------------------------------------------------------------- + */ +herr_t +H5VLobject_specific(void *obj, const H5VL_loc_params_t *loc_params, hid_t connector_id, + H5VL_object_specific_t specific_type, hid_t dxpl_id, void **req, va_list arguments) +{ + H5VL_class_t *cls; /* VOL connector's class struct */ + herr_t ret_value = SUCCEED; /* Return value */ + + FUNC_ENTER_API_NOINIT + H5TRACE7("e", "*x*xiVoi**xx", obj, loc_params, connector_id, specific_type, + dxpl_id, req, arguments); + + /* Check args and get class pointer */ + if(NULL == obj) + HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "invalid object") + if(NULL == (cls = (H5VL_class_t *)H5I_object_verify(connector_id, H5I_VOL))) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a VOL connector ID") + + /* Check if the corresponding VOL callback exists */ + if(NULL == cls->object_cls.specific) + HGOTO_ERROR(H5E_VOL, H5E_UNSUPPORTED, FAIL, "VOL connector has no `object specific' method") + + /* Bypass the H5VLint layer, calling the VOL callback directly */ + if((ret_value = (cls->object_cls.specific)(obj, loc_params, specific_type, dxpl_id, req, arguments)) < 0) + HGOTO_ERROR(H5E_VOL, H5E_CANTOPERATE, FAIL, "unable to execute object specific callback") + +done: + FUNC_LEAVE_API_NOINIT(ret_value) +} /* end H5VLobject_specific() */ + + +/*------------------------------------------------------------------------- + * Function: H5VL__object_optional + * + * Purpose: Optional operation specific to connectors. + * + * Return: Success: Non-negative + * Failure: Negative + * + *------------------------------------------------------------------------- + */ +static herr_t +H5VL__object_optional(void *obj, const H5VL_class_t *cls, hid_t dxpl_id, + void **req, va_list arguments) +{ + herr_t ret_value = SUCCEED; /* Return value */ + + FUNC_ENTER_STATIC + + /* Check if the corresponding VOL callback exists */ + if(NULL == cls->object_cls.optional) + HGOTO_ERROR(H5E_VOL, H5E_UNSUPPORTED, FAIL, "VOL connector has no 'object optional' method") + + /* Call the corresponding VOL callback */ + if((cls->object_cls.optional)(obj, dxpl_id, req, arguments) < 0) + HGOTO_ERROR(H5E_VOL, H5E_CANTOPERATE, FAIL, "unable to execute object optional callback") + +done: + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5VL__object_optional() */ + + +/*------------------------------------------------------------------------- + * Function: H5VL_object_optional + * + * Purpose: Optional operation specific to connectors. + * + * Return: Success: Non-negative + * Failure: Negative + * + *------------------------------------------------------------------------- + */ +herr_t +H5VL_object_optional(const H5VL_object_t *vol_obj, hid_t dxpl_id, void **req, ...) +{ + va_list arguments; /* Argument list passed from the API call */ + hbool_t arg_started = FALSE; /* Whether the va_list has been started */ + hbool_t vol_wrapper_set = FALSE; /* Whether the VOL object wrapping context was set up */ + herr_t ret_value = SUCCEED; /* Return value */ + + FUNC_ENTER_NOAPI(FAIL) + + /* Set wrapper info in API context */ + if(H5VL_set_vol_wrapper(vol_obj->data, vol_obj->connector) < 0) + HGOTO_ERROR(H5E_VOL, H5E_CANTSET, FAIL, "can't set VOL wrapper info") + vol_wrapper_set = TRUE; + + /* Call the corresponding internal VOL routine */ + HDva_start(arguments, req); + arg_started = TRUE; + if(H5VL__object_optional(vol_obj->data, vol_obj->connector->cls, dxpl_id, req, arguments) < 0) + HGOTO_ERROR(H5E_VOL, H5E_CANTOPERATE, FAIL, "unable to execute object optional callback") + +done: + /* End access to the va_list, if we started it */ + if(arg_started) + HDva_end(arguments); + + /* Reset object wrapping info in API context */ + if(vol_wrapper_set && H5VL_reset_vol_wrapper() < 0) + HDONE_ERROR(H5E_VOL, H5E_CANTRESET, FAIL, "can't reset VOL wrapper info") + + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5VL_object_optional() */ + + +/*------------------------------------------------------------------------- + * Function: H5VLobject_optional + * + * Purpose: Performs an optional connector-specific operation on an object + * + * Return: Success: Non-negative + * Failure: Negative + * + *------------------------------------------------------------------------- + */ +herr_t +H5VLobject_optional(void *obj, hid_t connector_id, hid_t dxpl_id, void **req, va_list arguments) +{ + H5VL_class_t *cls; /* VOL connector's class struct */ + herr_t ret_value = SUCCEED; /* Return value */ + + FUNC_ENTER_API_NOINIT + H5TRACE5("e", "*xii**xx", obj, connector_id, dxpl_id, req, arguments); + + /* Check args and get class pointer */ + if(NULL == obj) + HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "invalid object") + if(NULL == (cls = (H5VL_class_t *)H5I_object_verify(connector_id, H5I_VOL))) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a VOL connector ID") + + /* Call the corresponding internal VOL routine */ + if(H5VL__object_optional(obj, cls, dxpl_id, req, arguments) < 0) + HGOTO_ERROR(H5E_VOL, H5E_CANTOPERATE, FAIL, "unable to execute object optional callback") + +done: + FUNC_LEAVE_API_NOINIT(ret_value) +} /* end H5VLobject_optional() */ + + +/*------------------------------------------------------------------------- + * Function: H5VL__datatype_commit + * + * Purpose: Commits a datatype to the file through the VOL + * + * Return: Success: Pointer to the new datatype + * Failure: NULL + * + *------------------------------------------------------------------------- + */ +static void * +H5VL__datatype_commit(void *obj, const H5VL_loc_params_t *loc_params, const H5VL_class_t *cls, + 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) +{ + void *ret_value = NULL; /* Return value */ + + FUNC_ENTER_STATIC + + /* Check if the corresponding VOL callback exists */ + if(NULL == cls->datatype_cls.commit) + HGOTO_ERROR(H5E_VOL, H5E_UNSUPPORTED, NULL, "VOL connector has no 'datatype commit' method") + + /* Call the corresponding VOL callback */ + if(NULL == (ret_value = (cls->datatype_cls.commit)(obj, loc_params, name, type_id, lcpl_id, tcpl_id, tapl_id, dxpl_id, req))) + HGOTO_ERROR(H5E_VOL, H5E_CANTCREATE, NULL, "datatype commit failed") + +done: + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5VL__datatype_commit() */ + + +/*------------------------------------------------------------------------- + * Function: H5VL_datatype_commit + * + * Purpose: Commits a datatype to the file through the VOL + * + * Return: Success: Pointer to the new datatype + * Failure: NULL + * + *------------------------------------------------------------------------- + */ +void * +H5VL_datatype_commit(const H5VL_object_t *vol_obj, const 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) +{ + hbool_t vol_wrapper_set = FALSE; /* Whether the VOL object wrapping context was set up */ + void *ret_value = NULL; /* Return value */ + + FUNC_ENTER_NOAPI(NULL) + + /* Set wrapper info in API context */ + if(H5VL_set_vol_wrapper(vol_obj->data, vol_obj->connector) < 0) + HGOTO_ERROR(H5E_VOL, H5E_CANTSET, NULL, "can't set VOL wrapper info") + vol_wrapper_set = TRUE; + + /* Call the corresponding internal VOL routine */ + if(NULL == (ret_value = H5VL__datatype_commit(vol_obj->data, loc_params, vol_obj->connector->cls, name, type_id, lcpl_id, tcpl_id, tapl_id, dxpl_id, req))) + HGOTO_ERROR(H5E_VOL, H5E_CANTCREATE, NULL, "datatype commit failed") + +done: + /* Reset object wrapping info in API context */ + if(vol_wrapper_set && H5VL_reset_vol_wrapper() < 0) + HDONE_ERROR(H5E_VOL, H5E_CANTRESET, NULL, "can't reset VOL wrapper info") + + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5VL_datatype_commit() */ + + +/*------------------------------------------------------------------------- + * Function: H5VLdatatype_commit + * + * Purpose: Commits a datatype to the file + * + * Return: Success: Pointer to the new datatype + * Failure: NULL + * + *------------------------------------------------------------------------- + */ +void * +H5VLdatatype_commit(void *obj, const H5VL_loc_params_t *loc_params, hid_t connector_id, + 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_class_t *cls; /* VOL connector's class struct */ + void *ret_value = NULL; /* Return value */ + + FUNC_ENTER_API_NOINIT + H5TRACE10("*x", "*x*xi*siiiii**x", obj, loc_params, connector_id, name, + type_id, lcpl_id, tcpl_id, tapl_id, dxpl_id, req); + + /* Check args and get class pointer */ + if(NULL == obj) + HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, NULL, "invalid object") + if(NULL == (cls = (H5VL_class_t *)H5I_object_verify(connector_id, H5I_VOL))) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, NULL, "not a VOL connector ID") + + /* Call the corresponding internal VOL routine */ + if(NULL == (ret_value = H5VL__datatype_commit(obj, loc_params, cls, name, type_id, lcpl_id, tcpl_id, tapl_id, dxpl_id, req))) + HGOTO_ERROR(H5E_VOL, H5E_CANTCREATE, NULL, "unable to commit datatype") + +done: + FUNC_LEAVE_API_NOINIT(ret_value) +} /* end H5VLdatatype_commit() */ + + +/*------------------------------------------------------------------------- + * Function: H5VL__datatype_open + * + * Purpose: Opens a named datatype through the VOL + * + * Return: Success: Pointer to the datatype + * Failure: NULL + * + *------------------------------------------------------------------------- + */ +static void * +H5VL__datatype_open(void *obj, const H5VL_loc_params_t *loc_params, const H5VL_class_t *cls, + const char *name, hid_t tapl_id, hid_t dxpl_id, void **req) +{ + void *ret_value = NULL; /* Return value */ + + FUNC_ENTER_STATIC + + /* Check if the corresponding VOL callback exists */ + if(NULL == cls->datatype_cls.open) + HGOTO_ERROR(H5E_VOL, H5E_CANTINIT, NULL, "no datatype open callback") + + /* Call the corresponding VOL callback */ + if(NULL == (ret_value = (cls->datatype_cls.open)(obj, loc_params, name, tapl_id, dxpl_id, req))) + HGOTO_ERROR(H5E_VOL, H5E_CANTOPENOBJ, NULL, "datatype open failed") + +done: + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5VL__datatype_open() */ + + +/*------------------------------------------------------------------------- + * Function: H5VL_datatype_open + * + * Purpose: Opens a named datatype through the VOL + * + * Return: Success: Pointer to the datatype + * Failure: NULL + * + *------------------------------------------------------------------------- + */ +void * +H5VL_datatype_open(const H5VL_object_t *vol_obj, const H5VL_loc_params_t *loc_params, + const char *name, hid_t tapl_id, hid_t dxpl_id, void **req) +{ + hbool_t vol_wrapper_set = FALSE; /* Whether the VOL object wrapping context was set up */ + void *ret_value = NULL; /* Return value */ + + FUNC_ENTER_NOAPI(NULL) + + /* Set wrapper info in API context */ + if(H5VL_set_vol_wrapper(vol_obj->data, vol_obj->connector) < 0) + HGOTO_ERROR(H5E_VOL, H5E_CANTSET, NULL, "can't set VOL wrapper info") + vol_wrapper_set = TRUE; + + /* Call the corresponding internal VOL routine */ + if(NULL == (ret_value = H5VL__datatype_open(vol_obj->data, loc_params, vol_obj->connector->cls, name, tapl_id, dxpl_id, req))) + HGOTO_ERROR(H5E_VOL, H5E_CANTOPENOBJ, NULL, "datatype open failed") + +done: + /* Reset object wrapping info in API context */ + if(vol_wrapper_set && H5VL_reset_vol_wrapper() < 0) + HDONE_ERROR(H5E_VOL, H5E_CANTRESET, NULL, "can't reset VOL wrapper info") + + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5VL_datatype_open() */ + + +/*------------------------------------------------------------------------- + * Function: H5VLdatatype_open + * + * Purpose: Opens a named datatype + * + * Return: Success: Pointer to the datatype + * Failure: NULL + * + *------------------------------------------------------------------------- + */ +void * +H5VLdatatype_open(void *obj, const H5VL_loc_params_t *loc_params, hid_t connector_id, + const char *name, hid_t tapl_id, hid_t dxpl_id, void **req) +{ + H5VL_class_t *cls; /* VOL connector's class struct */ + void *ret_value = NULL; /* Return value */ + + FUNC_ENTER_API_NOINIT + H5TRACE7("*x", "*x*xi*sii**x", obj, loc_params, connector_id, name, tapl_id, + dxpl_id, req); + + /* Check args and get class pointer */ + if(NULL == obj) + HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, NULL, "invalid object") + if(NULL == (cls = (H5VL_class_t *)H5I_object_verify(connector_id, H5I_VOL))) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, NULL, "not a VOL connector ID") + + /* Call the corresponding internal VOL routine */ + if(NULL == (ret_value = H5VL__datatype_open(obj, loc_params, cls, name, tapl_id, dxpl_id, req))) + HGOTO_ERROR(H5E_VOL, H5E_CANTOPENOBJ, NULL, "unable to open datatype") + +done: + FUNC_LEAVE_API_NOINIT(ret_value) +} /* end H5VLdatatype_open() */ + + +/*------------------------------------------------------------------------- + * Function: H5VL__datatype_get + * + * Purpose: Get specific information about the datatype through the VOL + * + * Return: Success: Non-negative + * Failure: Negative + * + *------------------------------------------------------------------------- + */ +static herr_t +H5VL__datatype_get(void *obj, const H5VL_class_t *cls, H5VL_datatype_get_t get_type, + hid_t dxpl_id, void **req, va_list arguments) +{ + herr_t ret_value = SUCCEED; /* Return value */ + + FUNC_ENTER_STATIC + + /* Check if the corresponding VOL callback exists */ + if(NULL == cls->datatype_cls.get) + HGOTO_ERROR(H5E_VOL, H5E_UNSUPPORTED, FAIL, "VOL connector has no 'datatype get' method") + + /* Call the corresponding VOL callback */ + if((cls->datatype_cls.get)(obj, get_type, dxpl_id, req, arguments) < 0) + HGOTO_ERROR(H5E_VOL, H5E_CANTGET, FAIL, "datatype get failed") + +done: + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5VL__datatype_get() */ + + +/*------------------------------------------------------------------------- + * Function: H5VL_datatype_get + * + * Purpose: Get specific information about the datatype through the VOL + * + * Return: Success: Non-negative + * Failure: Negative + * + *------------------------------------------------------------------------- + */ +herr_t +H5VL_datatype_get(const H5VL_object_t *vol_obj, H5VL_datatype_get_t get_type, + hid_t dxpl_id, void **req, ...) +{ + va_list arguments; /* Argument list passed from the API call */ + hbool_t arg_started = FALSE; /* Whether the va_list has been started */ + hbool_t vol_wrapper_set = FALSE; /* Whether the VOL object wrapping context was set up */ + herr_t ret_value = SUCCEED; /* Return value */ + + FUNC_ENTER_NOAPI(FAIL) + + /* Set wrapper info in API context */ + if(H5VL_set_vol_wrapper(vol_obj->data, vol_obj->connector) < 0) + HGOTO_ERROR(H5E_VOL, H5E_CANTSET, FAIL, "can't set VOL wrapper info") + vol_wrapper_set = TRUE; + + /* Call the corresponding internal VOL routine */ + HDva_start(arguments, req); + arg_started = TRUE; + if(H5VL__datatype_get(vol_obj->data, vol_obj->connector->cls, get_type, dxpl_id, req, arguments) < 0) + HGOTO_ERROR(H5E_VOL, H5E_CANTGET, FAIL, "datatype get failed") + +done: + /* End access to the va_list, if we started it */ + if(arg_started) + HDva_end(arguments); + + /* Reset object wrapping info in API context */ + if(vol_wrapper_set && H5VL_reset_vol_wrapper() < 0) + HDONE_ERROR(H5E_VOL, H5E_CANTRESET, FAIL, "can't reset VOL wrapper info") + + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5VL_datatype_get() */ + + +/*------------------------------------------------------------------------- + * Function: H5VLdatatype_get + * + * Purpose: Gets information about the datatype + * + * Return: Success: Non-negative + * Failure: Negative + * + *------------------------------------------------------------------------- + */ +herr_t +H5VLdatatype_get(void *obj, hid_t connector_id, H5VL_datatype_get_t get_type, + hid_t dxpl_id, void **req, va_list arguments) +{ + H5VL_class_t *cls; /* VOL connector's class struct */ + herr_t ret_value = SUCCEED; /* Return value */ + + FUNC_ENTER_API_NOINIT + H5TRACE6("e", "*xiVei**xx", obj, connector_id, get_type, dxpl_id, req, + arguments); + + /* Check args and get class pointer */ + if(NULL == obj) + HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "invalid object") + if(NULL == (cls = (H5VL_class_t *)H5I_object_verify(connector_id, H5I_VOL))) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a VOL connector ID") + + /* Check if the corresponding VOL callback exists */ + if(NULL == cls->datatype_cls.get) + HGOTO_ERROR(H5E_VOL, H5E_UNSUPPORTED, FAIL, "VOL connector has no `datatype get' method") + + /* Call the corresponding internal VOL routine */ + if(H5VL__datatype_get(obj, cls, get_type, dxpl_id, req, arguments) < 0) + HGOTO_ERROR(H5E_VOL, H5E_CANTGET, FAIL, "unable to execute datatype get callback") + +done: + FUNC_LEAVE_API_NOINIT(ret_value) +} /* end H5VLdatatype_get() */ + + +/*------------------------------------------------------------------------- + * Function: H5VL__datatype_specific + * + * Purpose: Specific operation on datatypes through the VOL + * + * Return: Success: Non-negative + * Failure: Negative + * + *------------------------------------------------------------------------- + */ +static herr_t +H5VL__datatype_specific(void *obj, const H5VL_class_t *cls, H5VL_datatype_specific_t specific_type, + hid_t dxpl_id, void **req, va_list arguments) +{ + herr_t ret_value = SUCCEED; /* Return value */ + + FUNC_ENTER_STATIC + + /* Check if the corresponding VOL callback exists */ + if(NULL == cls->datatype_cls.specific) + HGOTO_ERROR(H5E_VOL, H5E_UNSUPPORTED, FAIL, "VOL connector has no 'datatype specific' method") + + /* Call the corresponding VOL callback */ + if((cls->datatype_cls.specific)(obj, specific_type, dxpl_id, req, arguments) < 0) + HGOTO_ERROR(H5E_VOL, H5E_CANTOPERATE, FAIL, "unable to execute datatype specific callback") + +done: + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5VL__datatype_specific() */ + + +/*------------------------------------------------------------------------- + * Function: H5VL_datatype_specific + * + * Purpose: Specific operation on datatypes through the VOL + * + * Return: Success: Non-negative + * Failure: Negative + * + *------------------------------------------------------------------------- + */ +herr_t +H5VL_datatype_specific(const H5VL_object_t *vol_obj, H5VL_datatype_specific_t specific_type, + hid_t dxpl_id, void **req, ...) +{ + va_list arguments; /* Argument list passed from the API call */ + hbool_t arg_started = FALSE; /* Whether the va_list has been started */ + hbool_t vol_wrapper_set = FALSE; /* Whether the VOL object wrapping context was set up */ + herr_t ret_value = SUCCEED; /* Return value */ + + FUNC_ENTER_NOAPI(FAIL) + + /* Set wrapper info in API context */ + if(H5VL_set_vol_wrapper(vol_obj->data, vol_obj->connector) < 0) + HGOTO_ERROR(H5E_VOL, H5E_CANTSET, FAIL, "can't set VOL wrapper info") + vol_wrapper_set = TRUE; + + /* Call the corresponding internal VOL routine */ + HDva_start(arguments, req); + arg_started = TRUE; + if(H5VL__datatype_specific(vol_obj->data, vol_obj->connector->cls, specific_type, dxpl_id, req, arguments) < 0) + HGOTO_ERROR(H5E_VOL, H5E_CANTOPERATE, FAIL, "unable to execute datatype specific callback") + +done: + /* End access to the va_list, if we started it */ + if(arg_started) + HDva_end(arguments); + + /* Reset object wrapping info in API context */ + if(vol_wrapper_set && H5VL_reset_vol_wrapper() < 0) + HDONE_ERROR(H5E_VOL, H5E_CANTRESET, FAIL, "can't reset VOL wrapper info") + + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5VL_datatype_specific() */ + + +/*------------------------------------------------------------------------- + * Function: H5VLdatatype_specific + * + * Purpose: Performs a connector-specific operation on a datatype + * + * Return: Success: Non-negative + * Failure: Negative + * + *------------------------------------------------------------------------- + */ +herr_t +H5VLdatatype_specific(void *obj, hid_t connector_id, H5VL_datatype_specific_t specific_type, + hid_t dxpl_id, void **req, va_list arguments) +{ + H5VL_class_t *cls; /* VOL connector's class struct */ + herr_t ret_value = SUCCEED; /* Return value */ + + FUNC_ENTER_API_NOINIT + H5TRACE6("e", "*xiVfi**xx", obj, connector_id, specific_type, dxpl_id, req, + arguments); + + /* Check args and get class pointer */ + if(NULL == obj) + HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "invalid object") + if(NULL == (cls = (H5VL_class_t *)H5I_object_verify(connector_id, H5I_VOL))) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a VOL connector ID") + + /* Call the corresponding internal VOL routine */ + if(H5VL__datatype_specific(obj, cls, specific_type, dxpl_id, req, arguments) < 0) + HGOTO_ERROR(H5E_VOL, H5E_CANTOPERATE, FAIL, "unable to execute datatype specific callback") + +done: + FUNC_LEAVE_API_NOINIT(ret_value) +} /* end H5VLdatatype_specific() */ + + +/*------------------------------------------------------------------------- + * Function: H5VL__datatype_optional + * + * Purpose: Optional operation specific to connectors. + * + * Return: Success: Non-negative + * Failure: Negative + * + *------------------------------------------------------------------------- + */ +static herr_t +H5VL__datatype_optional(void *obj, const H5VL_class_t *cls, hid_t dxpl_id, + void **req, va_list arguments) +{ + herr_t ret_value = SUCCEED; /* Return value */ + + FUNC_ENTER_STATIC + + /* Check if the corresponding VOL callback exists */ + if(NULL == cls->datatype_cls.optional) + HGOTO_ERROR(H5E_VOL, H5E_UNSUPPORTED, FAIL, "VOL connector has no 'datatype optional' method") + + /* Call the corresponding VOL callback */ + if((cls->datatype_cls.optional)(obj, dxpl_id, req, arguments) < 0) + HGOTO_ERROR(H5E_VOL, H5E_CANTOPERATE, FAIL, "unable to execute datatype optional callback") + +done: + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5VL__datatype_optional() */ + + +/*------------------------------------------------------------------------- + * Function: H5VL_datatype_optional + * + * Purpose: Optional operation specific to connectors. + * + * Return: Success: Non-negative + * Failure: Negative + * + *------------------------------------------------------------------------- + */ +herr_t +H5VL_datatype_optional(const H5VL_object_t *vol_obj, hid_t dxpl_id, + void **req, ...) +{ + va_list arguments; /* Argument list passed from the API call */ + hbool_t arg_started = FALSE; /* Whether the va_list has been started */ + hbool_t vol_wrapper_set = FALSE; /* Whether the VOL object wrapping context was set up */ + herr_t ret_value = SUCCEED; /* Return value */ + + FUNC_ENTER_NOAPI(FAIL) + + /* Set wrapper info in API context */ + if(H5VL_set_vol_wrapper(vol_obj->data, vol_obj->connector) < 0) + HGOTO_ERROR(H5E_VOL, H5E_CANTSET, FAIL, "can't set VOL wrapper info") + vol_wrapper_set = TRUE; + + /* Call the corresponding internal VOL routine */ + HDva_start(arguments, req); + arg_started = TRUE; + if(H5VL__datatype_optional(vol_obj->data, vol_obj->connector->cls, dxpl_id, req, arguments) < 0) + HGOTO_ERROR(H5E_VOL, H5E_CANTOPERATE, FAIL, "unable to execute datatype optional callback") + +done: + /* End access to the va_list, if we started it */ + if(arg_started) + HDva_end(arguments); + + /* Reset object wrapping info in API context */ + if(vol_wrapper_set && H5VL_reset_vol_wrapper() < 0) + HDONE_ERROR(H5E_VOL, H5E_CANTRESET, FAIL, "can't reset VOL wrapper info") + + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5VL_datatype_optional() */ + + +/*------------------------------------------------------------------------- + * Function: H5VLdatatype_optional + * + * Purpose: Performs an optional connector-specific operation on a datatype + * + * Return: Success: Non-negative + * Failure: Negative + * + *------------------------------------------------------------------------- + */ +herr_t +H5VLdatatype_optional(void *obj, hid_t connector_id, hid_t dxpl_id, void **req, + va_list arguments) +{ + H5VL_class_t *cls; /* VOL connector's class struct */ + herr_t ret_value = SUCCEED; /* Return value */ + + FUNC_ENTER_API_NOINIT + H5TRACE5("e", "*xii**xx", obj, connector_id, dxpl_id, req, arguments); + + /* Check args and get class pointer */ + if(NULL == obj) + HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "invalid object") + if(NULL == (cls = (H5VL_class_t *)H5I_object_verify(connector_id, H5I_VOL))) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a VOL connector ID") + + /* Call the corresponding internal VOL routine */ + if(H5VL__datatype_optional(obj, cls, dxpl_id, req, arguments) < 0) + HGOTO_ERROR(H5E_VOL, H5E_CANTOPERATE, FAIL, "unable to execute datatype optional callback") + +done: + FUNC_LEAVE_API_NOINIT(ret_value) +} /* end H5VLdatatype_optional() */ + + +/*------------------------------------------------------------------------- + * Function: H5VL__datatype_close + * + * Purpose: Closes a datatype through the VOL + * + * Return: Success: Non-negative + * Failure: Negative + * + *------------------------------------------------------------------------- + */ +static herr_t +H5VL__datatype_close(void *obj, const H5VL_class_t *cls, hid_t dxpl_id, + void **req) +{ + herr_t ret_value = SUCCEED; /* Return value */ + + FUNC_ENTER_STATIC + + /* Check if the corresponding VOL callback exists */ + if(NULL == cls->datatype_cls.close) + HGOTO_ERROR(H5E_VOL, H5E_UNSUPPORTED, FAIL, "VOL connector has no 'datatype close' method") + + /* Call the corresponding VOL callback */ + if((cls->datatype_cls.close)(obj, dxpl_id, req) < 0) + HGOTO_ERROR(H5E_VOL, H5E_CANTCLOSEOBJ, FAIL, "datatype close failed") + +done: + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5VL__datatype_close() */ + + +/*------------------------------------------------------------------------- + * Function: H5VL_datatype_close + * + * Purpose: Closes a datatype through the VOL + * + * Return: Success: Non-negative + * Failure: Negative + * + *------------------------------------------------------------------------- + */ +herr_t +H5VL_datatype_close(const H5VL_object_t *vol_obj, hid_t dxpl_id, void **req) +{ + hbool_t vol_wrapper_set = FALSE; /* Whether the VOL object wrapping context was set up */ + herr_t ret_value = SUCCEED; /* Return value */ + + FUNC_ENTER_NOAPI(FAIL) + + /* Set wrapper info in API context */ + if(H5VL_set_vol_wrapper(vol_obj->data, vol_obj->connector) < 0) + HGOTO_ERROR(H5E_VOL, H5E_CANTSET, FAIL, "can't set VOL wrapper info") + vol_wrapper_set = TRUE; + + /* Call the corresponding internal VOL routine */ + if(H5VL__datatype_close(vol_obj->data, vol_obj->connector->cls, dxpl_id, req) < 0) + HGOTO_ERROR(H5E_VOL, H5E_CANTCLOSEOBJ, FAIL, "datatype close failed") + +done: + /* Reset object wrapping info in API context */ + if(vol_wrapper_set && H5VL_reset_vol_wrapper() < 0) + HDONE_ERROR(H5E_VOL, H5E_CANTRESET, FAIL, "can't reset VOL wrapper info") + + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5VL_datatype_close() */ + + +/*------------------------------------------------------------------------- + * Function: H5VLdatatype_close + * + * Purpose: Closes a datatype + * + * Return: Success: Non-negative + * Failure: Negative + * + *------------------------------------------------------------------------- + */ +herr_t +H5VLdatatype_close(void *obj, hid_t connector_id, hid_t dxpl_id, void **req) +{ + H5VL_class_t *cls; /* VOL connector's class struct */ + herr_t ret_value = SUCCEED; /* Return value */ + + FUNC_ENTER_API_NOINIT + H5TRACE4("e", "*xii**x", obj, connector_id, dxpl_id, req); + + /* Check args and get class pointer */ + if(NULL == obj) + HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "invalid object") + if(NULL == (cls = (H5VL_class_t *)H5I_object_verify(connector_id, H5I_VOL))) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a VOL connector ID") + + /* Call the corresponding internal VOL routine */ + if(H5VL__datatype_close(obj, cls, dxpl_id, req) < 0) + HGOTO_ERROR(H5E_VOL, H5E_CANTCLOSEOBJ, FAIL, "unable to close datatype") + +done: + FUNC_LEAVE_API_NOINIT(ret_value) +} /* end H5VLdatatype_close() */ + + +/*------------------------------------------------------------------------- + * Function: H5VL__request_wait + * + * Purpose: Waits on an asychronous request through the VOL + * + * Note: Releases the request if the operation has completed and the + * connector callback succeeds + * + * Return: Success: Non-negative + * Failure: Negative + * + *------------------------------------------------------------------------- + */ +static herr_t +H5VL__request_wait(void *req, const H5VL_class_t *cls, uint64_t timeout, + H5ES_status_t *status) +{ + herr_t ret_value = SUCCEED; /* Return value */ + + FUNC_ENTER_STATIC + + /* Sanity checks */ + HDassert(req); + HDassert(cls); + HDassert(status); + + /* Check if the corresponding VOL callback exists */ + if(NULL == cls->request_cls.wait) + HGOTO_ERROR(H5E_VOL, H5E_UNSUPPORTED, FAIL, "VOL connector has no 'async wait' method") + + /* Call the corresponding VOL callback */ + if((cls->request_cls.wait)(req, timeout, status) < 0) + HGOTO_ERROR(H5E_VOL, H5E_CANTRELEASE, FAIL, "request wait failed") + +done: + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5VL__request_wait() */ + + +/*------------------------------------------------------------------------- + * Function: H5VL_request_wait + * + * Purpose: Waits on an asychronous request through the VOL + * + * Note: Releases the request if the operation has completed and the + * connector callback succeeds + * + * Return: Success: Non-negative + * Failure: Negative + * + *------------------------------------------------------------------------- + */ +herr_t +H5VL_request_wait(const H5VL_object_t *vol_obj, uint64_t timeout, + H5ES_status_t *status) +{ + hbool_t vol_wrapper_set = FALSE; /* Whether the VOL object wrapping context was set up */ + herr_t ret_value = SUCCEED; /* Return value */ + + FUNC_ENTER_NOAPI(FAIL) + + /* Sanity checks */ + HDassert(vol_obj); + + /* Set wrapper info in API context */ + if(H5VL_set_vol_wrapper(vol_obj->data, vol_obj->connector) < 0) + HGOTO_ERROR(H5E_VOL, H5E_CANTSET, FAIL, "can't set VOL wrapper info") + vol_wrapper_set = TRUE; + + /* Call the corresponding internal VOL routine */ + if(H5VL__request_wait(vol_obj->data, vol_obj->connector->cls, timeout, status) < 0) + HGOTO_ERROR(H5E_VOL, H5E_CANTRELEASE, FAIL, "request wait failed") + +done: + /* Reset object wrapping info in API context */ + if(vol_wrapper_set && H5VL_reset_vol_wrapper() < 0) + HDONE_ERROR(H5E_VOL, H5E_CANTRESET, FAIL, "can't reset VOL wrapper info") + + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5VL_request_wait() */ + + +/*------------------------------------------------------------------------- + * Function: H5VLrequest_wait + * + * Purpose: Waits on a request + * + * Note: Releases the request if the operation has completed and the + * connector callback succeeds + * + * Return: Success: Non-negative + * Failure: Negative + * + *------------------------------------------------------------------------- + */ +herr_t +H5VLrequest_wait(void *req, hid_t connector_id, uint64_t timeout, H5ES_status_t *status) +{ + H5VL_class_t *cls; /* VOL connector's class struct */ + herr_t ret_value = SUCCEED; /* Return value */ + + FUNC_ENTER_API_NOINIT + H5TRACE4("e", "*xiUL*Es", req, connector_id, timeout, status); + + /* Get class pointer */ + if(NULL == (cls = (H5VL_class_t *)H5I_object_verify(connector_id, H5I_VOL))) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a VOL connector ID") + + /* Call the corresponding internal VOL routine */ + if(H5VL__request_wait(req, cls, timeout, status) < 0) + HGOTO_ERROR(H5E_VOL, H5E_CANTRELEASE, FAIL, "unable to wait on request") + +done: + FUNC_LEAVE_API_NOINIT(ret_value) +} /* end H5VLrequest_wait() */ + + +/*------------------------------------------------------------------------- + * Function: H5VL__request_notify + * + * Purpose: Registers a user callback to be invoked when an asynchronous + * operation completes + * + * Note: Releases the request, if connector callback succeeds + * + * Return: Success: Non-negative + * Failure: Negative + * + *------------------------------------------------------------------------- + */ +static herr_t +H5VL__request_notify(void *req, const H5VL_class_t *cls, H5VL_request_notify_t cb, + void *ctx) +{ + herr_t ret_value = SUCCEED; /* Return value */ + + FUNC_ENTER_STATIC + + /* Sanity check */ + HDassert(req); + HDassert(cls); + + /* Check if the corresponding VOL callback exists */ + if(NULL == cls->request_cls.notify) + HGOTO_ERROR(H5E_VOL, H5E_UNSUPPORTED, FAIL, "VOL connector has no 'async notify' method") + + /* Call the corresponding VOL callback */ + if((cls->request_cls.notify)(req, cb, ctx) < 0) + HGOTO_ERROR(H5E_VOL, H5E_CANTRELEASE, FAIL, "request notify failed") + +done: + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5VL__request_notify() */ + + +/*------------------------------------------------------------------------- + * Function: H5VL_request_notify + * + * Purpose: Registers a user callback to be invoked when an asynchronous + * operation completes + * + * Note: Releases the request, if connector callback succeeds + * + * Return: Success: Non-negative + * Failure: Negative + * + *------------------------------------------------------------------------- + */ +herr_t +H5VL_request_notify(const H5VL_object_t *vol_obj, H5VL_request_notify_t cb, + void *ctx) +{ + hbool_t vol_wrapper_set = FALSE; /* Whether the VOL object wrapping context was set up */ + herr_t ret_value = SUCCEED; /* Return value */ + + FUNC_ENTER_NOAPI(FAIL) + + /* Sanity check */ + HDassert(vol_obj); + + /* Set wrapper info in API context */ + if(H5VL_set_vol_wrapper(vol_obj->data, vol_obj->connector) < 0) + HGOTO_ERROR(H5E_VOL, H5E_CANTSET, FAIL, "can't set VOL wrapper info") + vol_wrapper_set = TRUE; + + /* Call the corresponding internal VOL routine */ + if(H5VL__request_notify(vol_obj->data, vol_obj->connector->cls, cb, ctx) < 0) + HGOTO_ERROR(H5E_VOL, H5E_CANTSET, FAIL, "request notify failed") + +done: + /* Reset object wrapping info in API context */ + if(vol_wrapper_set && H5VL_reset_vol_wrapper() < 0) + HDONE_ERROR(H5E_VOL, H5E_CANTRESET, FAIL, "can't reset VOL wrapper info") + + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5VL_request_notify() */ + + +/*------------------------------------------------------------------------- + * Function: H5VLrequest_notify + * + * Purpose: Registers a user callback to be invoked when an asynchronous + * operation completes + * + * Note: Releases the request, if connector callback succeeds + * + * Return: Success: Non-negative + * Failure: Negative + * + *------------------------------------------------------------------------- + */ +herr_t +H5VLrequest_notify(void *req, hid_t connector_id, H5VL_request_notify_t cb, + void *ctx) +{ + H5VL_class_t *cls; /* VOL connector's class struct */ + herr_t ret_value = SUCCEED; /* Return value */ + + FUNC_ENTER_API_NOINIT + H5TRACE4("e", "*xix*x", req, connector_id, cb, ctx); + + /* Get class pointer */ + if(NULL == (cls = (H5VL_class_t *)H5I_object_verify(connector_id, H5I_VOL))) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a VOL connector ID") + + /* Call the corresponding internal VOL routine */ + if(H5VL__request_notify(req, cls, cb, ctx) < 0) + HGOTO_ERROR(H5E_VOL, H5E_CANTSET, FAIL, "unable to register notify callback for request") + +done: + FUNC_LEAVE_API_NOINIT(ret_value) +} /* end H5VLrequest_notify() */ + + +/*------------------------------------------------------------------------- + * Function: H5VL__request_cancel + * + * Purpose: Cancels an asynchronous request through the VOL + * + * Note: Releases the request, if connector callback succeeds + * + * Return: Success: Non-negative + * Failure: Negative + * + *------------------------------------------------------------------------- + */ +static herr_t +H5VL__request_cancel(void *req, const H5VL_class_t *cls) +{ + herr_t ret_value = SUCCEED; /* Return value */ + + FUNC_ENTER_STATIC + + /* Sanity check */ + HDassert(req); + HDassert(cls); + + /* Check if the corresponding VOL callback exists */ + if(NULL == cls->request_cls.cancel) + HGOTO_ERROR(H5E_VOL, H5E_UNSUPPORTED, FAIL, "VOL connector has no 'async cancel' method") + + /* Call the corresponding VOL callback */ + if((cls->request_cls.cancel)(req) < 0) + HGOTO_ERROR(H5E_VOL, H5E_CANTRELEASE, FAIL, "request cancel failed") + +done: + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5VL__request_cancel() */ + + +/*------------------------------------------------------------------------- + * Function: H5VL_request_cancel + * + * Purpose: Cancels an asynchronous request through the VOL + * + * Note: Releases the request, if connector callback succeeds + * + * Return: Success: Non-negative + * Failure: Negative + * + *------------------------------------------------------------------------- + */ +herr_t +H5VL_request_cancel(const H5VL_object_t *vol_obj) +{ + hbool_t vol_wrapper_set = FALSE; /* Whether the VOL object wrapping context was set up */ + herr_t ret_value = SUCCEED; /* Return value */ + + FUNC_ENTER_NOAPI(FAIL) + + /* Sanity check */ + HDassert(vol_obj); + + /* Set wrapper info in API context */ + if(H5VL_set_vol_wrapper(vol_obj->data, vol_obj->connector) < 0) + HGOTO_ERROR(H5E_VOL, H5E_CANTSET, FAIL, "can't set VOL wrapper info") + vol_wrapper_set = TRUE; + + /* Call the corresponding internal VOL routine */ + if(H5VL__request_cancel(vol_obj->data, vol_obj->connector->cls) < 0) + HGOTO_ERROR(H5E_VOL, H5E_CANTRELEASE, FAIL, "request cancel failed") + +done: + /* Reset object wrapping info in API context */ + if(vol_wrapper_set && H5VL_reset_vol_wrapper() < 0) + HDONE_ERROR(H5E_VOL, H5E_CANTRESET, FAIL, "can't reset VOL wrapper info") + + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5VL_request_cancel() */ + + +/*------------------------------------------------------------------------- + * Function: H5VLrequest_cancel + * + * Purpose: Cancels a request + * + * Note: Releases the request, if connector callback succeeds + * + * Return: Success: Non-negative + * Failure: Negative + * + *------------------------------------------------------------------------- + */ +herr_t +H5VLrequest_cancel(void *req, hid_t connector_id) +{ + H5VL_class_t *cls; /* VOL connector's class struct */ + herr_t ret_value = SUCCEED; /* Return value */ + + FUNC_ENTER_API_NOINIT + H5TRACE2("e", "*xi", req, connector_id); + + /* Get class pointer */ + if(NULL == (cls = (H5VL_class_t *)H5I_object_verify(connector_id, H5I_VOL))) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a VOL connector ID") + + /* Call the corresponding internal VOL routine */ + if(H5VL__request_cancel(req, cls) < 0) + HGOTO_ERROR(H5E_VOL, H5E_CANTRELEASE, FAIL, "unable to cancel request") + +done: + FUNC_LEAVE_API_NOINIT(ret_value) +} /* end H5VLrequest_cancel() */ + + +/*------------------------------------------------------------------------- + * Function: H5VL__request_specific + * + * Purpose: Specific operation on asynchronous request through the VOL + * + * Return: Success: Non-negative + * Failure: Negative + * + *------------------------------------------------------------------------- + */ +static herr_t +H5VL__request_specific(void *req, const H5VL_class_t *cls, + H5VL_request_specific_t specific_type, va_list arguments) +{ + herr_t ret_value = SUCCEED; /* Return value */ + + FUNC_ENTER_STATIC + + /* Sanity check */ + HDassert(req); + HDassert(cls); + + /* Check if the corresponding VOL callback exists */ + if(NULL == cls->request_cls.specific) + HGOTO_ERROR(H5E_VOL, H5E_UNSUPPORTED, FAIL, "VOL connector has no 'async specific' method") + + /* Call the corresponding VOL callback */ + if((ret_value = (cls->request_cls.specific)(req, specific_type, arguments)) < 0) + HGOTO_ERROR(H5E_VOL, H5E_CANTOPERATE, FAIL, "unable to execute asynchronous request specific callback") + +done: + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5VL__request_specific() */ + + +/*------------------------------------------------------------------------- + * Function: H5VL_request_specific + * + * Purpose: Specific operation on asynchronous request through the VOL + * + * Return: Success: Non-negative + * Failure: Negative + * + *------------------------------------------------------------------------- + */ +herr_t +H5VL_request_specific(const H5VL_object_t *vol_obj, + H5VL_request_specific_t specific_type, ...) +{ + va_list arguments; /* Argument list passed from the API call */ + hbool_t arg_started = FALSE; /* Whether the va_list has been started */ + hbool_t vol_wrapper_set = FALSE; /* Whether the VOL object wrapping context was set up */ + herr_t ret_value = SUCCEED; /* Return value */ + + FUNC_ENTER_NOAPI(FAIL) + + /* Sanity check */ + HDassert(vol_obj); + + /* Set wrapper info in API context */ + if(H5VL_set_vol_wrapper(vol_obj->data, vol_obj->connector) < 0) + HGOTO_ERROR(H5E_VOL, H5E_CANTSET, FAIL, "can't set VOL wrapper info") + vol_wrapper_set = TRUE; + + /* Call the corresponding internal VOL routine */ + HDva_start(arguments, specific_type); + arg_started = TRUE; + if((ret_value = H5VL__request_specific(vol_obj->data, vol_obj->connector->cls, specific_type, arguments)) < 0) + HGOTO_ERROR(H5E_VOL, H5E_CANTOPERATE, FAIL, "unable to execute asynchronous request specific callback") + +done: + /* End access to the va_list, if we started it */ + if(arg_started) + HDva_end(arguments); + + /* Reset object wrapping info in API context */ + if(vol_wrapper_set && H5VL_reset_vol_wrapper() < 0) + HDONE_ERROR(H5E_VOL, H5E_CANTRESET, FAIL, "can't reset VOL wrapper info") + + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5VL_request_specific() */ + + +/*------------------------------------------------------------------------- + * Function: H5VLrequest_specific + * + * Purpose: Performs a connector-specific operation on an asynchronous request + * + * Return: Success: Non-negative + * Failure: Negative + * + *------------------------------------------------------------------------- + */ +herr_t +H5VLrequest_specific(void *req, hid_t connector_id, H5VL_request_specific_t specific_type, + va_list arguments) +{ + H5VL_class_t *cls; /* VOL connector's class struct */ + herr_t ret_value = SUCCEED; /* Return value */ + + FUNC_ENTER_API_NOINIT + H5TRACE4("e", "*xiVrx", req, connector_id, specific_type, arguments); + + /* Get class pointer */ + if(NULL == (cls = (H5VL_class_t *)H5I_object_verify(connector_id, H5I_VOL))) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a VOL connector ID") + + /* Call the corresponding internal VOL routine */ + if((ret_value = H5VL__request_specific(req, cls, specific_type, arguments)) < 0) + HGOTO_ERROR(H5E_VOL, H5E_CANTOPERATE, FAIL, "unable to execute asynchronous request specific callback") + +done: + FUNC_LEAVE_API_NOINIT(ret_value) +} /* end H5VLrequest_specific() */ + + +/*------------------------------------------------------------------------- + * Function: H5VL__request_optional + * + * Purpose: Optional operation specific to connectors. + * + * Return: Success: Non-negative + * Failure: Negative + * + *------------------------------------------------------------------------- + */ +static herr_t +H5VL__request_optional(void *req, const H5VL_class_t *cls, va_list arguments) +{ + herr_t ret_value = SUCCEED; /* Return value */ + + FUNC_ENTER_STATIC + + /* Sanity check */ + HDassert(req); + HDassert(cls); + + /* Check if the corresponding VOL callback exists */ + if(NULL == cls->request_cls.optional) + HGOTO_ERROR(H5E_VOL, H5E_UNSUPPORTED, FAIL, "VOL connector has no 'async optional' method") + + /* Call the corresponding VOL callback */ + if((ret_value = (cls->request_cls.optional)(req, arguments)) < 0) + HGOTO_ERROR(H5E_VOL, H5E_CANTOPERATE, FAIL, "unable to execute asynchronous request optional callback") + +done: + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5VL__request_optional() */ + + +/*------------------------------------------------------------------------- + * Function: H5VL_request_optional + * + * Purpose: Optional operation specific to connectors. + * + * Return: Success: Non-negative + * Failure: Negative + * + *------------------------------------------------------------------------- + */ +herr_t +H5VL_request_optional(const H5VL_object_t *vol_obj, ...) +{ + va_list arguments; /* Argument list passed from the API call */ + hbool_t arg_started = FALSE; /* Whether the va_list has been started */ + hbool_t vol_wrapper_set = FALSE; /* Whether the VOL object wrapping context was set up */ + herr_t ret_value = SUCCEED; /* Return value */ + + FUNC_ENTER_NOAPI(FAIL) + + /* Sanity check */ + HDassert(vol_obj); + + /* Set wrapper info in API context */ + if(H5VL_set_vol_wrapper(vol_obj->data, vol_obj->connector) < 0) + HGOTO_ERROR(H5E_VOL, H5E_CANTSET, FAIL, "can't set VOL wrapper info") + vol_wrapper_set = TRUE; + + /* Call the corresponding internal VOL routine */ + HDva_start(arguments, vol_obj); + arg_started = TRUE; + if((ret_value = H5VL__request_optional(vol_obj->data, vol_obj->connector->cls, arguments)) < 0) + HGOTO_ERROR(H5E_VOL, H5E_CANTOPERATE, FAIL, "unable to execute asynchronous request optional callback") + +done: + /* End access to the va_list, if we started it */ + if(arg_started) + HDva_end(arguments); + + /* Reset object wrapping info in API context */ + if(vol_wrapper_set && H5VL_reset_vol_wrapper() < 0) + HDONE_ERROR(H5E_VOL, H5E_CANTRESET, FAIL, "can't reset VOL wrapper info") + + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5VL_request_optional() */ + + +/*------------------------------------------------------------------------- + * Function: H5VLrequest_optional + * + * Purpose: Performs an optional connector-specific operation on an asynchronous request + * + * Return: Success: Non-negative + * Failure: Negative + * + *------------------------------------------------------------------------- + */ +herr_t +H5VLrequest_optional(void *req, hid_t connector_id, va_list arguments) +{ + H5VL_class_t *cls; /* VOL connector's class struct */ + herr_t ret_value = SUCCEED; /* Return value */ + + FUNC_ENTER_API_NOINIT + H5TRACE3("e", "*xix", req, connector_id, arguments); + + /* Get class pointer */ + if(NULL == (cls = (H5VL_class_t *)H5I_object_verify(connector_id, H5I_VOL))) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a VOL connector ID") + + /* Call the corresponding internal VOL routine */ + if((ret_value = H5VL__request_optional(req, cls, arguments)) < 0) + HGOTO_ERROR(H5E_VOL, H5E_CANTOPERATE, FAIL, "unable to execute asynchronous request optional callback") + +done: + FUNC_LEAVE_API_NOINIT(ret_value) +} /* end H5VLrequest_optional() */ + + +/*------------------------------------------------------------------------- + * Function: H5VL__request_free + * + * Purpose: Frees an asynchronous request through the VOL + * + * Return: Success: Non-negative + * Failure: Negative + * + *------------------------------------------------------------------------- + */ +static herr_t +H5VL__request_free(void *req, const H5VL_class_t *cls) +{ + herr_t ret_value = SUCCEED; /* Return value */ + + FUNC_ENTER_STATIC + + /* Sanity check */ + HDassert(req); + HDassert(cls); + + /* Check if the corresponding VOL callback exists */ + if(NULL == cls->request_cls.free) + HGOTO_ERROR(H5E_VOL, H5E_UNSUPPORTED, FAIL, "VOL connector has no 'async free' method") + + /* Call the corresponding VOL callback */ + if((cls->request_cls.free)(req) < 0) + HGOTO_ERROR(H5E_VOL, H5E_CANTRELEASE, FAIL, "request free failed") + +done: + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5VL__request_free() */ + + +/*------------------------------------------------------------------------- + * Function: H5VL_request_free + * + * Purpose: Frees an asynchronous request through the VOL + * + * Return: Success: Non-negative + * Failure: Negative + * + *------------------------------------------------------------------------- + */ +herr_t +H5VL_request_free(const H5VL_object_t *vol_obj) +{ + hbool_t vol_wrapper_set = FALSE; /* Whether the VOL object wrapping context was set up */ + herr_t ret_value = SUCCEED; /* Return value */ + + FUNC_ENTER_NOAPI(FAIL) + + /* Sanity check */ + HDassert(vol_obj); + + /* Set wrapper info in API context */ + if(H5VL_set_vol_wrapper(vol_obj->data, vol_obj->connector) < 0) + HGOTO_ERROR(H5E_VOL, H5E_CANTSET, FAIL, "can't set VOL wrapper info") + vol_wrapper_set = TRUE; + + /* Call the corresponding VOL callback */ + if(H5VL__request_free(vol_obj->data, vol_obj->connector->cls) < 0) + HGOTO_ERROR(H5E_VOL, H5E_CANTRELEASE, FAIL, "request free failed") + +done: + /* Reset object wrapping info in API context */ + if(vol_wrapper_set && H5VL_reset_vol_wrapper() < 0) + HDONE_ERROR(H5E_VOL, H5E_CANTRESET, FAIL, "can't reset VOL wrapper info") + + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5VL_request_free() */ + + +/*------------------------------------------------------------------------- + * Function: H5VLrequest_free + * + * Purpose: Frees a request + * + * Return: Success: Non-negative + * Failure: Negative + * + *------------------------------------------------------------------------- + */ +herr_t +H5VLrequest_free(void *req, hid_t connector_id) +{ + H5VL_class_t *cls; /* VOL connector's class struct */ + herr_t ret_value = SUCCEED; /* Return value */ + + FUNC_ENTER_API_NOINIT + H5TRACE2("e", "*xi", req, connector_id); + + /* Get class pointer */ + if(NULL == (cls = (H5VL_class_t *)H5I_object_verify(connector_id, H5I_VOL))) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a VOL connector ID") + + /* Call the corresponding internal VOL routine */ + if(H5VL__request_free(req, cls) < 0) + HGOTO_ERROR(H5E_VOL, H5E_CANTRELEASE, FAIL, "unable to free request") + +done: + FUNC_LEAVE_API_NOINIT(ret_value) +} /* end H5VLrequest_free() */ + diff --git a/src/H5VLint.c b/src/H5VLint.c index e246989..d51be0c 100644 --- a/src/H5VLint.c +++ b/src/H5VLint.c @@ -30,11 +30,11 @@ /***********/ #include "H5private.h" /* Generic Functions */ +#include "H5CXprivate.h" /* API Contexts */ #include "H5Eprivate.h" /* Error handling */ #include "H5FLprivate.h" /* Free lists */ #include "H5Iprivate.h" /* IDs */ #include "H5MMprivate.h" /* Memory management */ -#include "H5Pprivate.h" /* Property lists */ #include "H5Tprivate.h" /* Datatypes */ #include "H5VLpkg.h" /* Virtual Object Layer */ @@ -43,19 +43,33 @@ /* Local Macros */ /****************/ + /******************/ /* Local Typedefs */ /******************/ +/* Object wrapping context info */ +typedef struct H5VL_wrap_ctx_t { + unsigned rc; /* Ref. count for the # of times the context was set / reset */ + const H5VL_t *connector; /* VOL connector for "outermost" class to start wrap */ + void *obj_wrap_ctx; /* "wrap context" for outermost connector */ +} H5VL_wrap_ctx_t; + + /********************/ /* Package Typedefs */ /********************/ + /********************/ /* Local Prototypes */ /********************/ +static herr_t H5VL__free_cls(H5VL_class_t *cls); +static void *H5VL__wrap_obj(void *obj); +static H5VL_object_t *H5VL__new_vol_obj(H5I_type_t type, void *object, + H5VL_t *vol_connector, hbool_t wrap_obj); +static void *H5VL__object(hid_t id, H5I_type_t obj_type); -static herr_t H5VL_free_cls(H5VL_class_t *cls); /*********************/ /* Package Variables */ @@ -64,6 +78,7 @@ static herr_t H5VL_free_cls(H5VL_class_t *cls); /* Package initialization variable */ hbool_t H5_PKG_INIT_VAR = FALSE; + /*****************************/ /* Library Private Variables */ /*****************************/ @@ -77,15 +92,22 @@ static const H5I_class_t H5I_VOL_CLS[1] = {{ H5I_VOL, /* ID class value */ 0, /* Class flags */ 0, /* # of reserved IDs for class */ - (H5I_free_t)H5VL_free_cls /* Callback routine for closing objects of this class */ + (H5I_free_t)H5VL__free_cls /* Callback routine for closing objects of this class */ }}; +/* Declare a free list to manage the H5VL_class_t struct */ +H5FL_DEFINE_STATIC(H5VL_class_t); + /* Declare a free list to manage the H5VL_t struct */ H5FL_DEFINE(H5VL_t); /* Declare a free list to manage the H5VL_object_t struct */ H5FL_DEFINE(H5VL_object_t); +/* Declare a free list to manage the H5VL_wrap_ctx_t struct */ +H5FL_DEFINE_STATIC(H5VL_wrap_ctx_t); + + /*------------------------------------------------------------------------- * Function: H5VL_init @@ -132,7 +154,7 @@ H5VL__init_package(void) /* Initialize the atom group for the VL IDs */ if (H5I_register_type(H5I_VOL_CLS) < 0) - HGOTO_ERROR(H5E_VOL, H5E_CANTINIT, FAIL, "unable to initialize H5VL interface"); + HGOTO_ERROR(H5E_VOL, H5E_CANTINIT, FAIL, "unable to initialize H5VL interface") done: FUNC_LEAVE_NOAPI(ret_value) @@ -157,27 +179,27 @@ H5VL_term_package(void) FUNC_ENTER_NOAPI_NOINIT_NOERR - if (H5_PKG_INIT_VAR) { + if(H5_PKG_INIT_VAR) { if (H5I_nmembers(H5I_VOL) > 0) { (void)H5I_clear_type(H5I_VOL, FALSE, FALSE); n++; - } + } /* end if */ else { - /* Destroy the VOL driver ID group */ + /* Destroy the VOL connector ID group */ n += (H5I_dec_type_ref(H5I_VOL) > 0); /* Mark interface as closed */ if (0 == n) H5_PKG_INIT_VAR = FALSE; - } - } + } /* end else */ + } /* end if */ FUNC_LEAVE_NOAPI(n) } /* end H5VL_term_package() */ /*------------------------------------------------------------------------- - * Function: H5VL_free_cls + * Function: H5VL__free_cls * * Purpose: Frees a file VOL class struct and returns an indication of * success. This function is used as the free callback for the @@ -189,27 +211,218 @@ H5VL_term_package(void) *------------------------------------------------------------------------- */ static herr_t -H5VL_free_cls(H5VL_class_t *cls) +H5VL__free_cls(H5VL_class_t *cls) { herr_t ret_value = SUCCEED; - FUNC_ENTER_NOAPI_NOINIT + FUNC_ENTER_STATIC /* Sanity check */ HDassert(cls); - /* XXX: Need to retrieve the VOL termination property list for the - * terminate operation - JTH - */ - if (cls->terminate && cls->terminate(H5P_DEFAULT) < 0) - HGOTO_ERROR(H5E_VOL, H5E_CANTCLOSEOBJ, FAIL, "VOL driver did not terminate cleanly"); + /* Shut down the VOL connector */ + if(cls->terminate && cls->terminate() < 0) + HGOTO_ERROR(H5E_VOL, H5E_CANTCLOSEOBJ, FAIL, "VOL connector did not terminate cleanly") + + /* Release the class */ + H5MM_xfree((void *)cls->name); /* Casting away const OK -QAK */ + H5FL_FREE(H5VL_class_t, cls); + +done: + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5VL__free_cls() */ + + +/*------------------------------------------------------------------------- + * Function: H5VL__wrap_obj + * + * Purpose: Wraps a library object with possible VOL connector wrappers, to + * match the VOL connector stack for the file. + * + * Return: Success: Wrapped object pointer + * Failure: NULL + * + * Programmer: Quincey Koziol + * Friday, October 7, 2018 + * + *------------------------------------------------------------------------- + */ +static void * +H5VL__wrap_obj(void *obj) +{ + H5VL_wrap_ctx_t *vol_wrap_ctx = NULL; /* Object wrapping context */ + void *ret_value = NULL; /* Return value */ + + FUNC_ENTER_STATIC + + /* Check arguments */ + HDassert(obj); + + /* Retrieve the VOL object wrapping context */ + if(H5CX_get_vol_wrap_ctx((void **)&vol_wrap_ctx) < 0) + HGOTO_ERROR(H5E_VOL, H5E_CANTGET, NULL, "can't get VOL object wrap context") + + /* If there is a VOL object wrapping context, wrap the object */ + if(vol_wrap_ctx) { + /* Wrap object, using the VOL callback */ + if(NULL == (ret_value = H5VL_wrap_object(vol_wrap_ctx->connector->cls, vol_wrap_ctx->obj_wrap_ctx, obj))) + HGOTO_ERROR(H5E_VOL, H5E_CANTGET, NULL, "can't wrap object") + } /* end if */ + else + ret_value = obj; + +done: + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5VL__wrap_obj() */ + + +/*------------------------------------------------------------------------- + * Function: H5VL__new_vol_obj + * + * Purpose: Creates a new VOL object, to use when registering an ID. + * + * Return: Success: VOL object pointer + * Failure: NULL + * + * Programmer: Quincey Koziol + * Friday, October 7, 2018 + * + *------------------------------------------------------------------------- + */ +static H5VL_object_t * +H5VL__new_vol_obj(H5I_type_t type, void *object, H5VL_t *vol_connector, hbool_t wrap_obj) +{ + H5VL_object_t *new_vol_obj = NULL; /* Pointer to new VOL object */ + H5VL_object_t *ret_value = NULL; /* Return value */ + + FUNC_ENTER_STATIC + + /* Check arguments */ + HDassert(object); + HDassert(vol_connector); + + /* Make sure type number is valid */ + if(type != H5I_ATTR && type != H5I_DATASET && type != H5I_DATATYPE && type != H5I_FILE && type != H5I_GROUP) + HGOTO_ERROR(H5E_VOL, H5E_BADVALUE, NULL, "invalid type number") + + /* Create the new VOL object */ + if(NULL == (new_vol_obj = H5FL_CALLOC(H5VL_object_t))) + HGOTO_ERROR(H5E_VOL, H5E_CANTALLOC, NULL, "can't allocate memory for VOL object") + new_vol_obj->connector = vol_connector; + if(wrap_obj) { + if(NULL == (new_vol_obj->data = H5VL__wrap_obj(object))) + HGOTO_ERROR(H5E_VOL, H5E_CANTCREATE, NULL, "can't wrap library object") + } /* end if */ + else + new_vol_obj->data = object; + + /* Bump the reference count on the VOL connector */ + vol_connector->nrefs++; + + /* If this is a datatype, we have to hide the VOL object under the H5T_t pointer */ + if(H5I_DATATYPE == type) { + if(NULL == (ret_value = (H5VL_object_t *)H5T_construct_datatype(new_vol_obj))) + HGOTO_ERROR(H5E_VOL, H5E_CANTINIT, NULL, "can't construct datatype object") + } /* end if */ + else + ret_value = (H5VL_object_t *)new_vol_obj; + +done: + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5VL__new_vol_obj() */ - /* XXX (VOL MERGE): We'll leak memory if the name string was dynamically allocated. */ - H5MM_xfree(cls); + +/*------------------------------------------------------------------------- + * Function: H5VL_conn_copy + * + * Purpose: Copy VOL connector ID & info. + * + * Note: This is an "in-place" copy. + * + * Return: Success: Non-negative + * Failure: Negative + * + *------------------------------------------------------------------------- + */ +herr_t +H5VL_conn_copy(H5VL_connector_prop_t *connector_prop) +{ + herr_t ret_value = SUCCEED; /* Return value */ + + FUNC_ENTER_NOAPI(FAIL) + + if(connector_prop) { + /* Copy the connector ID & info, if there is one */ + if(connector_prop->connector_id > 0) { + /* Increment the reference count on connector ID and copy connector info */ + if(H5I_inc_ref(connector_prop->connector_id, FALSE) < 0) + HGOTO_ERROR(H5E_PLIST, H5E_CANTINC, FAIL, "unable to increment ref count on VOL connector ID") + + /* Copy connector info, if it exists */ + if(connector_prop->connector_info) { + H5VL_class_t *connector; /* Pointer to connector */ + void *new_connector_info = NULL; /* Copy of connector info */ + + /* Retrieve the connector for the ID */ + if(NULL == (connector = (H5VL_class_t *)H5I_object(connector_prop->connector_id))) + HGOTO_ERROR(H5E_PLIST, H5E_BADTYPE, FAIL, "not a VOL connector ID") + + /* Allocate and copy connector info */ + if(H5VL_copy_connector_info(connector, &new_connector_info, connector_prop->connector_info) < 0) + HGOTO_ERROR(H5E_PLIST, H5E_CANTCOPY, FAIL, "connector info copy failed") + + /* Set the connector info to the copy */ + connector_prop->connector_info = new_connector_info; + } /* end if */ + } /* end if */ + } /* end if */ + +done: + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5VL_conn_copy() */ + + +/*------------------------------------------------------------------------- + * Function: H5VL_conn_free + * + * Purpose: Free VOL connector ID & info. + * + * Return: Success: Non-negative + * Failure: Negative + * + *------------------------------------------------------------------------- + */ +herr_t +H5VL_conn_free(const H5VL_connector_prop_t *info) +{ + herr_t ret_value = SUCCEED; /* Return value */ + + FUNC_ENTER_NOAPI(FAIL) + + if(info) { + /* Free the connector info (if it exists) and decrement the ID */ + if(info->connector_id > 0) { + if(info->connector_info) { + H5VL_class_t *connector; /* Pointer to connector */ + + /* Retrieve the connector for the ID */ + if(NULL == (connector = (H5VL_class_t *)H5I_object(info->connector_id))) + HGOTO_ERROR(H5E_VOL, H5E_BADTYPE, FAIL, "not a VOL connector ID") + + /* Free the connector info */ + if(H5VL_free_connector_info(connector, (void *)info->connector_info) < 0) /* Casting away const OK - QAK */ + HGOTO_ERROR(H5E_VOL, H5E_CANTRELEASE, FAIL, "unable to release VOL connector info object") + } /* end if */ + + /* Decrement reference count for connector ID */ + if(H5I_dec_ref(info->connector_id) < 0) + HGOTO_ERROR(H5E_VOL, H5E_CANTDEC, FAIL, "can't decrement reference count for connector ID") + } /* end if */ + } /* end if */ done: FUNC_LEAVE_NOAPI(ret_value) -} /* end H5VL_free_cls() */ +} /* end H5VL_conn_free() */ /*------------------------------------------------------------------------- @@ -225,40 +438,25 @@ done: *------------------------------------------------------------------------- */ hid_t -H5VL_register(H5I_type_t type, const void *object, H5VL_t *vol_driver, hbool_t app_ref) +H5VL_register(H5I_type_t type, void *object, H5VL_t *vol_connector, hbool_t app_ref) { - H5VL_object_t *vol_obj = NULL; - hid_t ret_value = H5I_INVALID_HID; + H5VL_object_t *vol_obj = NULL; /* VOL object wrapper for library object */ + hid_t ret_value = H5I_INVALID_HID; /* Return value */ FUNC_ENTER_NOAPI(H5I_INVALID_HID) /* Check arguments */ HDassert(object); - HDassert(vol_driver); - - /* Set up VOL object to wrap the passed-in data */ - if (NULL == (vol_obj = H5FL_CALLOC(H5VL_object_t))) - HGOTO_ERROR(H5E_VOL, H5E_CANTALLOC, H5I_INVALID_HID, "can't allocate top object structure"); - vol_obj->driver = vol_driver; - vol_obj->data = object; + HDassert(vol_connector); - vol_driver->nrefs++; - - /* Datatypes need special handling under the VOL, since they have a non-VOL aspect */ - if (H5I_DATATYPE == type) { - - H5T_t *dt = NULL; - - if (NULL == (dt = H5T_construct_datatype(vol_obj))) - HGOTO_ERROR(H5E_DATATYPE, H5E_CANTINIT, H5I_INVALID_HID, "can't construct datatype object"); - - if ((ret_value = H5I_register(type, dt, app_ref)) < 0) - HGOTO_ERROR(H5E_ATOM, H5E_CANTREGISTER, H5I_INVALID_HID, "unable to atomize handle"); - } - else { - if ((ret_value = H5I_register(type, vol_obj, app_ref)) < 0) - HGOTO_ERROR(H5E_ATOM, H5E_CANTREGISTER, H5I_INVALID_HID, "unable to atomize handle"); - } + /* Set up VOL object for the passed-in data */ + /* (Does not wrap object, since it's from a VOL callback) */ + if(NULL == (vol_obj = H5VL__new_vol_obj(type, object, vol_connector, FALSE))) + HGOTO_ERROR(H5E_VOL, H5E_CANTCREATE, FAIL, "can't create VOL object") + + /* Register VOL object as _object_ type, for future object API calls */ + if((ret_value = H5I_register(type, vol_obj, app_ref)) < 0) + HGOTO_ERROR(H5E_VOL, H5E_CANTREGISTER, H5I_INVALID_HID, "unable to atomize handle") done: FUNC_LEAVE_NOAPI(ret_value) @@ -284,41 +482,24 @@ done: *------------------------------------------------------------------------- */ herr_t -H5VL_register_using_existing_id(H5I_type_t type, void *object, H5VL_t *vol_driver, hbool_t app_ref, hid_t existing_id) +H5VL_register_using_existing_id(H5I_type_t type, void *object, H5VL_t *vol_connector, hbool_t app_ref, hid_t existing_id) { H5VL_object_t *new_vol_obj = NULL; /* Pointer to new VOL object */ - void *stored_obj = NULL; /* Pointer to the object that will be stored */ herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_NOAPI(FAIL) /* Check arguments */ HDassert(object); - HDassert(vol_driver); + HDassert(vol_connector); - /* Make sure type number is valid */ - if(type != H5I_ATTR && type != H5I_DATASET && type != H5I_DATATYPE && type != H5I_FILE && type != H5I_GROUP) - HGOTO_ERROR(H5E_ARGS, H5E_BADRANGE, FAIL, "invalid type number") - - /* Set up the new VOL object */ - if(NULL == (new_vol_obj = H5FL_CALLOC(H5VL_object_t))) - HGOTO_ERROR(H5E_VOL, H5E_CANTALLOC, FAIL, "can't allocate memory for VOL object"); - new_vol_obj->driver = vol_driver; - new_vol_obj->data = object; - - /* Bump the reference count on the VOL driver */ - vol_driver->nrefs++; - - /* If this is a datatype, we have to hide the VOL object under the H5T_t pointer */ - if(H5I_DATATYPE == type) { - if(NULL == (stored_obj = (void *)H5T_construct_datatype(new_vol_obj))) - HGOTO_ERROR(H5E_VOL, H5E_CANTINIT, FAIL, "can't construct datatype object"); - } - else - stored_obj = (void *)new_vol_obj; + /* Set up VOL object for the passed-in data */ + /* (Wraps object, since it's a library object) */ + if(NULL == (new_vol_obj = H5VL__new_vol_obj(type, object, vol_connector, TRUE))) + HGOTO_ERROR(H5E_VOL, H5E_CANTCREATE, FAIL, "can't create VOL object") /* Call the underlying H5I function to complete the registration */ - if(H5I_register_using_existing_id(type, stored_obj, app_ref, existing_id) < 0) + if(H5I_register_using_existing_id(type, new_vol_obj, app_ref, existing_id) < 0) HGOTO_ERROR(H5E_VOL, H5E_CANTREGISTER, FAIL, "can't register object under existing ID") done: @@ -330,8 +511,8 @@ done: * Function: H5VL_register_using_vol_id * * Purpose: Utility function to create a user ID for an object created - * or opened through the VOL. Uses the VOL driver's ID to - * get the driver information instead of it being passed in. + * or opened through the VOL. Uses the VOL connector's ID to + * get the connector information instead of it being passed in. * * Return: Success: A valid HDF5 ID * Failure: H5I_INVALID_HID @@ -339,28 +520,29 @@ done: *------------------------------------------------------------------------- */ hid_t -H5VL_register_using_vol_id(H5I_type_t type, const void *obj, hid_t driver_id, hbool_t app_ref) +H5VL_register_using_vol_id(H5I_type_t type, void *obj, hid_t connector_id, hbool_t app_ref) { H5VL_class_t *cls = NULL; - H5VL_t *driver = NULL; /* VOL driver struct */ + H5VL_t *connector = NULL; /* VOL connector struct */ hid_t ret_value = H5I_INVALID_HID; FUNC_ENTER_NOAPI(FAIL) - if (NULL == (cls = (H5VL_class_t *)H5I_object_verify(driver_id, H5I_VOL))) - HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, H5I_INVALID_HID, "not a VOL driver ID"); + /* Get the VOL class object from the connector's ID */ + if(NULL == (cls = (H5VL_class_t *)H5I_object_verify(connector_id, H5I_VOL))) + HGOTO_ERROR(H5E_VOL, H5E_BADTYPE, H5I_INVALID_HID, "not a VOL connector ID") /* Setup VOL info struct */ - if (NULL == (driver = H5FL_CALLOC(H5VL_t))) - HGOTO_ERROR(H5E_FILE, H5E_NOSPACE, H5I_INVALID_HID, "can't allocate VOL info struct"); - driver->cls = cls; - driver->id = driver_id; - if (H5I_inc_ref(driver->id, FALSE) < 0) - HGOTO_ERROR(H5E_ATOM, H5E_CANTINC, H5I_INVALID_HID, "unable to increment ref count on VOL driver"); + if(NULL == (connector = H5FL_CALLOC(H5VL_t))) + HGOTO_ERROR(H5E_VOL, H5E_CANTALLOC, H5I_INVALID_HID, "can't allocate VOL info struct") + connector->cls = cls; + connector->id = connector_id; + if(H5I_inc_ref(connector->id, FALSE) < 0) + HGOTO_ERROR(H5E_VOL, H5E_CANTINC, H5I_INVALID_HID, "unable to increment ref count on VOL connector") /* Get an ID for the VOL object */ - if ((ret_value = H5VL_register(type, obj, driver, app_ref)) < 0) - HGOTO_ERROR(H5E_ATOM, H5E_CANTREGISTER, H5I_INVALID_HID, "unable to register object handle"); + if((ret_value = H5VL_register(type, obj, connector, app_ref)) < 0) + HGOTO_ERROR(H5E_VOL, H5E_CANTREGISTER, H5I_INVALID_HID, "unable to register object handle") done: FUNC_LEAVE_NOAPI(ret_value) @@ -371,7 +553,7 @@ done: * Function: H5VL_free_object * * Purpose: Wrapper to unregister an object ID with a VOL aux struct - * and decrement ref count on VOL driver ID + * and decrement ref count on VOL connector ID * * Return: SUCCEED/FAIL * @@ -387,13 +569,13 @@ H5VL_free_object(H5VL_object_t *vol_obj) /* Check arguments */ HDassert(vol_obj); - vol_obj->driver->nrefs --; + vol_obj->connector->nrefs --; - if (0 == vol_obj->driver->nrefs) { - if (H5I_dec_ref(vol_obj->driver->id) < 0) - HGOTO_ERROR(H5E_VOL, H5E_CANTDEC, FAIL, "unable to decrement ref count on VOL driver"); - vol_obj->driver = H5FL_FREE(H5VL_t, vol_obj->driver); - } + if(0 == vol_obj->connector->nrefs) { + if(H5I_dec_ref(vol_obj->connector->id) < 0) + HGOTO_ERROR(H5E_VOL, H5E_CANTDEC, FAIL, "unable to decrement ref count on VOL connector") + vol_obj->connector = H5FL_FREE(H5VL_t, vol_obj->connector); + } /* end if */ vol_obj = H5FL_FREE(H5VL_object_t, vol_obj); @@ -403,20 +585,20 @@ done: /*------------------------------------------------------------------------- - * Function: H5VL_register_driver + * Function: H5VL_register_connector * - * Purpose: Registers a new VOL driver as a member of the virtual object + * Purpose: Registers a new VOL connector as a member of the virtual object * layer class. * - * Return: Success: A VOL driver ID which is good until the - * library is closed or the driver is unregistered. + * Return: Success: A VOL connector ID which is good until the + * library is closed or the connector is unregistered. * * Failure: H5I_INVALID_HID * *------------------------------------------------------------------------- */ hid_t -H5VL_register_driver(const void *_cls, size_t size, hbool_t app_ref) +H5VL_register_connector(const void *_cls, hbool_t app_ref, hid_t vipl_id) { const H5VL_class_t *cls = (const H5VL_class_t *)_cls; H5VL_class_t *saved = NULL; @@ -428,38 +610,47 @@ H5VL_register_driver(const void *_cls, size_t size, hbool_t app_ref) HDassert(cls); /* Copy the class structure so the caller can reuse or free it */ - if (NULL == (saved = (H5VL_class_t *)H5MM_calloc(size))) - HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, H5I_INVALID_HID, "memory allocation failed for VOL driver class struct"); - HDmemcpy(saved, cls, size); + if (NULL == (saved = H5FL_CALLOC(H5VL_class_t))) + HGOTO_ERROR(H5E_VOL, H5E_CANTALLOC, H5I_INVALID_HID, "memory allocation failed for VOL connector class struct") + HDmemcpy(saved, cls, sizeof(H5VL_class_t)); + if(NULL == (saved->name = H5MM_strdup(cls->name))) + HGOTO_ERROR(H5E_VOL, H5E_CANTALLOC, H5I_INVALID_HID, "memory allocation failed for VOL connector name") + + /* Initialize the VOL connector */ + if(cls->initialize && cls->initialize(vipl_id) < 0) + HGOTO_ERROR(H5E_VOL, H5E_CANTINIT, H5I_INVALID_HID, "unable to init VOL connector") /* Create the new class ID */ if ((ret_value = H5I_register(H5I_VOL, saved, app_ref)) < 0) - HGOTO_ERROR(H5E_ATOM, H5E_CANTREGISTER, H5I_INVALID_HID, "unable to register VOL driver ID"); + HGOTO_ERROR(H5E_VOL, H5E_CANTREGISTER, H5I_INVALID_HID, "unable to register VOL connector ID") done: - if (ret_value < 0) - if (saved) - H5MM_xfree(saved); + if (ret_value < 0 && saved) { + if (saved->name) + H5MM_xfree((void *)(saved->name)); /* Casting away const OK -QAK */ + + H5FL_FREE(H5VL_class_t, saved); + } FUNC_LEAVE_NOAPI(ret_value) -} /* end H5VL_register_driver() */ +} /* end H5VL_register_connector() */ /*------------------------------------------------------------------------- - * Function: H5VL_get_driver_name + * Function: H5VL_get_connector_name * - * Purpose: Private version of H5VLget_driver_name + * Purpose: Private version of H5VLget_connector_name * - * Return: Success: The length of the driver name + * Return: Success: The length of the connector name * Failure: Negative * *------------------------------------------------------------------------- */ ssize_t -H5VL_get_driver_name(hid_t id, char *name /*out*/, size_t size) +H5VL_get_connector_name(hid_t id, char *name /*out*/, size_t size) { - H5VL_object_t *vol_obj = NULL; - const H5VL_class_t *cls = NULL; + H5VL_object_t *vol_obj; + const H5VL_class_t *cls; size_t len; ssize_t ret_value = -1; @@ -467,23 +658,23 @@ H5VL_get_driver_name(hid_t id, char *name /*out*/, size_t size) /* get the object pointer */ if (NULL == (vol_obj = H5VL_vol_object(id))) - HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "invalid file identifier"); + HGOTO_ERROR(H5E_VOL, H5E_BADTYPE, FAIL, "invalid VOL identifier") - cls = vol_obj->driver->cls; + cls = vol_obj->connector->cls; len = HDstrlen(cls->name); - if (name) { - HDstrncpy(name, cls->name, MIN(len + 1,size)); - if (len >= size) - name[size-1]='\0'; - } + if(name) { + HDstrncpy(name, cls->name, MIN(len + 1, size)); + if(len >= size) + name[size - 1] = '\0'; + } /* end if */ /* Set the return value for the API call */ ret_value = (ssize_t)len; done: FUNC_LEAVE_NOAPI(ret_value) -} /* end H5VL_get_driver_name() */ +} /* end H5VL_get_connector_name() */ /*------------------------------------------------------------------------- @@ -503,149 +694,108 @@ H5VL_object_t * H5VL_vol_object(hid_t id) { void *obj = NULL; - H5I_type_t obj_type = H5I_get_type(id); + H5I_type_t obj_type; H5VL_object_t *ret_value = NULL; FUNC_ENTER_NOAPI(NULL) + obj_type = H5I_get_type(id); if (H5I_FILE == obj_type || H5I_GROUP == obj_type || H5I_ATTR == obj_type || - H5I_DATASET == obj_type || H5I_DATATYPE == obj_type) { - /* get the object */ + H5I_DATASET == obj_type || H5I_DATATYPE == obj_type) { + /* Get the object */ if (NULL == (obj = H5I_object(id))) - HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, NULL, "invalid identifier"); + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, NULL, "invalid identifier") /* if this is a datatype, get the VOL object attached to the H5T_t struct */ - if (H5I_DATATYPE == obj_type) { + if (H5I_DATATYPE == obj_type) if (NULL == (obj = H5T_get_named_type((H5T_t *)obj))) - HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, NULL, "not a named datatype"); - } - } + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, NULL, "not a named datatype") + } /* end if */ else - HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, NULL, "invalid identifier type to function"); - + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, NULL, "invalid identifier type to function") ret_value = (H5VL_object_t *)obj; + done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5VL_vol_object() */ /*------------------------------------------------------------------------- - * Function: H5VL_object + * Function: H5VL_object_data * - * Purpose: Utility function to return the VOL object pointer associated with - * a hid_t. + * Purpose: Correctly retrieve the 'data' field for a VOL object (H5VL_object), + * even for nested / stacked VOL connectors. * - * Return: Success: object pointer - * Failure: NULL + * Return: Success: object pointer + * Failure: NULL * *------------------------------------------------------------------------- */ void * -H5VL_object(hid_t id) +H5VL_object_data(const H5VL_object_t *vol_obj) { - H5VL_object_t *vol_obj = NULL; - void *ret_value = NULL; + void *ret_value = NULL; - FUNC_ENTER_NOAPI(NULL) - - /* Get the symbol table entry */ - switch (H5I_get_type(id)) { - case H5I_GROUP: - case H5I_DATASET: - case H5I_FILE: - case H5I_ATTR: - /* get the object */ - if (NULL == (vol_obj = (H5VL_object_t *)H5I_object(id))) - HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, NULL, "invalid identifier"); - - ret_value = vol_obj->data; - break; - case H5I_DATATYPE: - { - H5T_t *dt = NULL; - - /* get the object */ - if (NULL == (dt = (H5T_t *)H5I_object(id))) - HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, NULL, "invalid identifier"); + FUNC_ENTER_NOAPI_NOINIT_NOERR - /* Get the actual datatype object that should be the vol_obj */ - if (NULL == (vol_obj = H5T_get_named_type(dt))) - HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, NULL, "not a named datatype"); + /* Check for 'get_object' callback in connector */ + if(vol_obj->connector->cls->get_object) + ret_value = (vol_obj->connector->cls->get_object)(vol_obj->data); + else + ret_value = vol_obj->data; - ret_value = vol_obj->data; - break; - } - case H5I_UNINIT: - case H5I_BADID: - case H5I_DATASPACE: - case H5I_REFERENCE: - case H5I_VFL: - case H5I_VOL: - case H5I_GENPROP_CLS: - case H5I_GENPROP_LST: - case H5I_ERROR_CLASS: - case H5I_ERROR_MSG: - case H5I_ERROR_STACK: - case H5I_NTYPES: - default: - HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, NULL, "unknown data object type"); - } -done: FUNC_LEAVE_NOAPI(ret_value) -} /* end H5VL_object() */ +} /* end H5VL_object_data() */ /*------------------------------------------------------------------------- - * Function: H5VL_object_verify + * Function: H5VL__object * - * Purpose: Utility function to return the VOL object pointer associated - * with an identifier. + * Purpose: Internal function to return the VOL object pointer associated + * with an hid_t. * * Return: Success: object pointer * Failure: NULL * *------------------------------------------------------------------------- */ -void * -H5VL_object_verify(hid_t id, H5I_type_t obj_type) +static void * +H5VL__object(hid_t id, H5I_type_t obj_type) { H5VL_object_t *vol_obj = NULL; void *ret_value = NULL; - FUNC_ENTER_NOAPI(NULL) + FUNC_ENTER_STATIC - /* Get the symbol table entry */ - switch (obj_type) { + /* Get the underlying object */ + switch(obj_type) { case H5I_GROUP: case H5I_DATASET: case H5I_FILE: case H5I_ATTR: /* get the object */ - if (NULL == (vol_obj = (H5VL_object_t *)H5I_object_verify(id, obj_type))) - HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, NULL, "invalid identifier"); - - ret_value = vol_obj->data; + if (NULL == (vol_obj = (H5VL_object_t *)H5I_object(id))) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, NULL, "invalid identifier") break; + case H5I_DATATYPE: { H5T_t *dt = NULL; /* get the object */ - if (NULL == (dt = (H5T_t *)H5I_object_verify(id, obj_type))) - HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, NULL, "invalid identifier"); + if (NULL == (dt = (H5T_t *)H5I_object(id))) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, NULL, "invalid identifier") /* Get the actual datatype object that should be the vol_obj */ if (NULL == (vol_obj = H5T_get_named_type(dt))) - HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, NULL, "not a named datatype"); - - ret_value = vol_obj->data; + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, NULL, "not a named datatype") break; } + case H5I_UNINIT: case H5I_BADID: case H5I_DATASPACE: - case H5I_REFERENCE: case H5I_VFL: case H5I_VOL: case H5I_GENPROP_CLS: @@ -656,1613 +806,311 @@ H5VL_object_verify(hid_t id, H5I_type_t obj_type) case H5I_NTYPES: default: HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, NULL, "unknown data object type") - } -done: - FUNC_LEAVE_NOAPI(ret_value) -} /* end H5VL_object_verify() */ - - -/*------------------------------------------------------------------------- - * Function: H5VL_driver_data - * - * Purpose: Get the VOL-specific data stored in a VOL object - * - * Return: Success: Pointer to the data - * - * Failure: NULL (technically can't fail) - * - *------------------------------------------------------------------------- - */ -void * -H5VL_driver_data(H5VL_object_t *vol_obj) -{ - FUNC_ENTER_NOAPI_NOINIT_NOERR - - HDassert(vol_obj); - - FUNC_LEAVE_NOAPI(vol_obj->data) -} /* end H5VL_driver_data() */ - - -/*------------------------------------------------------------------------- - * Function: H5VL_attr_create - * - * Purpose: Creates an attribute through the VOL - * - * Return: Success: pointer to the new attribute - * - * Failure: NULL - * - *------------------------------------------------------------------------- - */ -void * -H5VL_attr_create(void *obj, H5VL_loc_params_t loc_params, const H5VL_class_t *cls, const char *name, - hid_t acpl_id, hid_t aapl_id, hid_t dxpl_id, void **req) -{ - void *ret_value; /* Return value */ - - FUNC_ENTER_NOAPI(NULL) - - /* check if the corresponding VOL create callback exists */ - if (NULL == cls->attr_cls.create) - HGOTO_ERROR(H5E_VOL, H5E_UNSUPPORTED, NULL, "VOL driver has no 'attr create' method") - - /* call the corresponding VOL create callback */ - if (NULL == (ret_value = (cls->attr_cls.create) - (obj, loc_params, name, acpl_id, aapl_id, dxpl_id, req))) - HGOTO_ERROR(H5E_VOL, H5E_CANTINIT, NULL, "create failed") - -done: - FUNC_LEAVE_NOAPI(ret_value) -} /* end H5VL_attr_create() */ - - -/*------------------------------------------------------------------------- - * Function: H5VL_attr_open - * - * Purpose: Opens an attribute through the VOL - * - * Return: Success: pointer to the new attr. - * - * Failure: NULL - * - *------------------------------------------------------------------------- - */ -void * -H5VL_attr_open(void *obj, H5VL_loc_params_t loc_params, const H5VL_class_t *cls, const char *name, - hid_t aapl_id, hid_t dxpl_id, void **req) -{ - void *ret_value; /* Return value */ - - FUNC_ENTER_NOAPI(NULL) - - /* check if the type specific corresponding VOL open callback exists */ - if(NULL == cls->attr_cls.open) - HGOTO_ERROR(H5E_VOL, H5E_UNSUPPORTED, NULL, "VOL driver has no 'attr open' method") - - /* call the corresponding VOL open callback */ - if(NULL == (ret_value = (cls->attr_cls.open) - (obj, loc_params, name, aapl_id, dxpl_id, req))) - HGOTO_ERROR(H5E_VOL, H5E_CANTOPENOBJ, NULL, "attribute open failed") - -done: - FUNC_LEAVE_NOAPI(ret_value) -} /* end H5VL_attr_open() */ - - -/*------------------------------------------------------------------------- - * Function: H5VL_attr_read - * - * Purpose: Reads data from attr through the VOL - * - * Return: Success: Non Negative - * - * Failure: Negative - * - *------------------------------------------------------------------------- - */ -herr_t H5VL_attr_read(void *attr, const H5VL_class_t *cls, hid_t mem_type_id, void *buf, - hid_t dxpl_id, void **req) -{ - herr_t ret_value = SUCCEED; - - FUNC_ENTER_NOAPI(FAIL) - - if(NULL == cls->attr_cls.read) - HGOTO_ERROR(H5E_VOL, H5E_UNSUPPORTED, FAIL, "VOL driver has no 'attr read' method") - if((ret_value = (cls->attr_cls.read)(attr, mem_type_id, buf, dxpl_id, req)) < 0) - HGOTO_ERROR(H5E_VOL, H5E_CANTRELEASE, FAIL, "read failed") - -done: - FUNC_LEAVE_NOAPI(ret_value) -} /* end H5VL_attr_read() */ - - -/*------------------------------------------------------------------------- - * Function: H5VL_attr_write - * - * Purpose: Writes data to attr through the VOL - * - * Return: Success: Non Negative - * - * Failure: Negative - * - *------------------------------------------------------------------------- - */ -herr_t H5VL_attr_write(void *attr, const H5VL_class_t *cls, hid_t mem_type_id, const void *buf, - hid_t dxpl_id, void **req) -{ - herr_t ret_value = SUCCEED; - - FUNC_ENTER_NOAPI(FAIL) - - if(NULL == cls->attr_cls.write) - HGOTO_ERROR(H5E_VOL, H5E_UNSUPPORTED, FAIL, "VOL driver has no 'attr write' method") - if((ret_value = (cls->attr_cls.write)(attr, mem_type_id, buf, dxpl_id, req)) < 0) - HGOTO_ERROR(H5E_VOL, H5E_CANTRELEASE, FAIL, "write failed") - -done: - FUNC_LEAVE_NOAPI(ret_value) -} /* end H5VL_attr_write() */ - - -/*------------------------------------------------------------------------- - * Function: H5VL_attr_get - * - * Purpose: Get specific information about the attribute through the VOL - * - * Return: Success: non negative - * - * Failure: negative - * - *------------------------------------------------------------------------- - */ -herr_t -H5VL_attr_get(void *obj, const H5VL_class_t *cls, H5VL_attr_get_t get_type, - hid_t dxpl_id, void **req, ...) -{ - va_list arguments; /* argument list passed from the API call */ - herr_t ret_value = SUCCEED; - - FUNC_ENTER_NOAPI(FAIL) - - if(NULL == cls->attr_cls.get) - HGOTO_ERROR(H5E_VOL, H5E_UNSUPPORTED, FAIL, "VOL driver has no 'attr get' method") - - va_start (arguments, req); - if((ret_value = (cls->attr_cls.get)(obj, get_type, dxpl_id, req, arguments)) < 0) - HGOTO_ERROR(H5E_VOL, H5E_CANTGET, FAIL, "get failed") - va_end (arguments); - -done: - FUNC_LEAVE_NOAPI(ret_value) -} /* end H5VL_attr_get() */ - - -/*------------------------------------------------------------------------- - * Function: H5VL_attr_specific - * - * Purpose: specific operation on attributes through the VOL - * - * Return: Success: non negative - * - * Failure: negative - * - *------------------------------------------------------------------------- - */ -herr_t -H5VL_attr_specific(void *obj, H5VL_loc_params_t loc_params, const H5VL_class_t *cls, - H5VL_attr_specific_t specific_type, hid_t dxpl_id, void **req, ...) -{ - va_list arguments; /* argument list passed from the API call */ - herr_t ret_value = SUCCEED; - - FUNC_ENTER_NOAPI(FAIL) - - if(NULL == cls->attr_cls.specific) - HGOTO_ERROR(H5E_VOL, H5E_UNSUPPORTED, FAIL, "VOL driver has no 'attr specific' method") - - va_start (arguments, req); - if((ret_value = (cls->attr_cls.specific)(obj, loc_params, specific_type, dxpl_id, req, arguments)) < 0) - HGOTO_ERROR(H5E_VOL, H5E_CANTOPERATE, FAIL, "Unable to execute attribute specific callback") - va_end (arguments); - -done: - FUNC_LEAVE_NOAPI(ret_value) -} /* end H5VL_attr_specific() */ - - -/*------------------------------------------------------------------------- - * Function: H5VL_attr_optional - * - * Purpose: optional operation specific to drivers. - * - * Return: Success: non negative - * - * Failure: negative - * - *------------------------------------------------------------------------- - */ -herr_t -H5VL_attr_optional(void *obj, const H5VL_class_t *cls, hid_t dxpl_id, void **req, ...) -{ - va_list arguments; /* argument list passed from the API call */ - herr_t ret_value = SUCCEED; - - FUNC_ENTER_NOAPI(FAIL) - - if(NULL == cls->attr_cls.optional) - HGOTO_ERROR(H5E_VOL, H5E_UNSUPPORTED, FAIL, "VOL driver has no 'attr optional' method") - - va_start (arguments, req); - if((ret_value = (cls->attr_cls.optional)(obj, dxpl_id, req, arguments)) < 0) - HGOTO_ERROR(H5E_VOL, H5E_CANTOPERATE, FAIL, "Unable to execute attribute optional callback") - va_end (arguments); - -done: - FUNC_LEAVE_NOAPI(ret_value) -} /* end H5VL_attr_optional() */ - - -/*------------------------------------------------------------------------- - * Function: H5VL_attr_close - * - * Purpose: Closes an attribute through the VOL - * - * Return: SUCCEED/FAIL - * - *------------------------------------------------------------------------- - */ -herr_t -H5VL_attr_close(void *attr, const H5VL_class_t *cls, hid_t dxpl_id, void **req) -{ - herr_t ret_value = SUCCEED; - - HDassert(attr); - HDassert(cls); - - FUNC_ENTER_NOAPI(FAIL) - - /* Check if the corresponding VOL callback exists */ - if (NULL == cls->attr_cls.close) - HGOTO_ERROR(H5E_VOL, H5E_UNSUPPORTED, FAIL, "VOL driver has no 'attr close' method"); + } /* end switch */ - /* Call the corresponding VOL callback */ - if ((ret_value = (cls->attr_cls.close)(attr, dxpl_id, req)) < 0) - HGOTO_ERROR(H5E_VOL, H5E_CANTRELEASE, FAIL, "close failed"); + /* Set the return value */ + ret_value = H5VL_object_data(vol_obj); done: FUNC_LEAVE_NOAPI(ret_value) -} /* end H5VL_attr_close() */ +} /* end H5VL__object() */ /*------------------------------------------------------------------------- - * Function: H5VL_dataset_create - * - * Purpose: Creates a dataset through the VOL + * Function: H5VL_object * - * Return: Success: pointer to dataset + * Purpose: Utility function to return the VOL object pointer associated with + * a hid_t. * - * Failure: NULL + * Return: Success: object pointer + * Failure: NULL * *------------------------------------------------------------------------- */ void * -H5VL_dataset_create(void *obj, H5VL_loc_params_t loc_params, const H5VL_class_t *cls, const char *name, - hid_t dcpl_id, hid_t dapl_id, hid_t dxpl_id, void **req) +H5VL_object(hid_t id) { - void *ret_value; /* Return value */ + void *ret_value = NULL; FUNC_ENTER_NOAPI(NULL) - /* check if the corresponding VOL create callback exists */ - if(NULL == cls->dataset_cls.create) - HGOTO_ERROR(H5E_VOL, H5E_UNSUPPORTED, NULL, "VOL driver has no 'dataset create' method") - - /* call the corresponding VOL create callback */ - if(NULL == (ret_value = (cls->dataset_cls.create) - (obj, loc_params, name, dcpl_id, dapl_id, dxpl_id, req))) - HGOTO_ERROR(H5E_VOL, H5E_CANTINIT, NULL, "create failed") + /* Get the underlying object */ + if(NULL == (ret_value = H5VL__object(id, H5I_get_type(id)))) + HGOTO_ERROR(H5E_ARGS, H5E_CANTGET, NULL, "can't retrieve object for ID") done: FUNC_LEAVE_NOAPI(ret_value) -} /* end H5VL_dataset_create() */ +} /* end H5VL_object() */ /*------------------------------------------------------------------------- - * Function: H5VL_dataset_open - * - * Purpose: Opens a dataset through the VOL + * Function: H5VL_object_verify * - * Return: Success: pointer to dataset + * Purpose: Utility function to return the VOL object pointer associated + * with an identifier. * - * Failure: NULL + * Return: Success: object pointer + * Failure: NULL * *------------------------------------------------------------------------- */ void * -H5VL_dataset_open(void *obj, H5VL_loc_params_t loc_params, const H5VL_class_t *cls, const char *name, - hid_t dapl_id, hid_t dxpl_id, void **req) +H5VL_object_verify(hid_t id, H5I_type_t obj_type) { - void *ret_value; /* Return value */ + void *ret_value = NULL; FUNC_ENTER_NOAPI(NULL) - /* check if the type specific corresponding VOL open callback exists */ - if(NULL == cls->dataset_cls.open) - HGOTO_ERROR(H5E_VOL, H5E_UNSUPPORTED, NULL, "VOL driver has no 'dset open' method") - - /* call the corresponding VOL open callback */ - if(NULL == (ret_value = (cls->dataset_cls.open) - (obj, loc_params, name, dapl_id, dxpl_id, req))) - HGOTO_ERROR(H5E_VOL, H5E_CANTOPENOBJ, NULL, "dataset open failed") - -done: - FUNC_LEAVE_NOAPI(ret_value) -} /* end H5VL_dataset_open() */ - - -/*------------------------------------------------------------------------- - * Function: H5VL_dataset_read - * - * Purpose: Reads data from dataset through the VOL -* - * Return: Success: Non Negative - * - * Failure: Negative - * - *------------------------------------------------------------------------- - */ -herr_t -H5VL_dataset_read(void *dset, const H5VL_class_t *cls, hid_t mem_type_id, hid_t mem_space_id, - hid_t file_space_id, hid_t plist_id, void *buf, void **req) -{ - herr_t ret_value = SUCCEED; - - FUNC_ENTER_NOAPI(FAIL) - - if(NULL == cls->dataset_cls.read) - HGOTO_ERROR(H5E_VOL, H5E_UNSUPPORTED, FAIL, "VOL driver has no 'dataset read' method") - if((ret_value = (cls->dataset_cls.read) - (dset, mem_type_id, mem_space_id, file_space_id, plist_id, buf, req)) < 0) - HGOTO_ERROR(H5E_VOL, H5E_READERROR, FAIL, "read failed") - -done: - FUNC_LEAVE_NOAPI(ret_value) -} /* end H5VL_dataset_read() */ - - -/*------------------------------------------------------------------------- - * Function: H5VL_dataset_write - * - * Purpose: Writes data from dataset through the VOL - * - * Return: Success: Non Negative - * - * Failure: Negative - * - *------------------------------------------------------------------------- - */ -herr_t -H5VL_dataset_write(void *dset, const H5VL_class_t *cls, hid_t mem_type_id, hid_t mem_space_id, - hid_t file_space_id, hid_t plist_id, const void *buf, void **req) -{ - herr_t ret_value = SUCCEED; - - FUNC_ENTER_NOAPI(FAIL) - - if(NULL == cls->dataset_cls.write) - HGOTO_ERROR(H5E_VOL, H5E_UNSUPPORTED, FAIL, "VOL driver has no 'dataset write' method") - if((ret_value = (cls->dataset_cls.write) - (dset, mem_type_id, mem_space_id, file_space_id, plist_id, buf, req)) < 0) - HGOTO_ERROR(H5E_VOL, H5E_WRITEERROR, FAIL, "write failed") - -done: - FUNC_LEAVE_NOAPI(ret_value) -} /* end H5VL_dataset_write() */ - - -/*------------------------------------------------------------------------- - * Function: H5VL_dataset_get - * - * Purpose: Get specific information about the dataset through the VOL - * - * Return: Success: non negative - * - * Failure: negative - * - *------------------------------------------------------------------------- - */ -herr_t -H5VL_dataset_get(void *dset, const H5VL_class_t *cls, H5VL_dataset_get_t get_type, - hid_t dxpl_id, void **req, ...) -{ - va_list arguments; /* argument list passed from the API call */ - herr_t ret_value = SUCCEED; - - FUNC_ENTER_NOAPI(FAIL) - - if(NULL == cls->dataset_cls.get) - HGOTO_ERROR(H5E_VOL, H5E_UNSUPPORTED, FAIL, "VOL driver has no 'dataset get' method") + /* Check of ID of correct type */ + if(obj_type != H5I_get_type(id)) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, NULL, "invalid identifier") - va_start (arguments, req); - if((ret_value = (cls->dataset_cls.get)(dset, get_type, dxpl_id, req, arguments)) < 0) - HGOTO_ERROR(H5E_VOL, H5E_CANTGET, FAIL, "get failed") - va_end (arguments); + /* Get the underlying object */ + if(NULL == (ret_value = H5VL__object(id, obj_type))) + HGOTO_ERROR(H5E_ARGS, H5E_CANTGET, NULL, "can't retrieve object for ID") done: FUNC_LEAVE_NOAPI(ret_value) -} /* end H5VL_dataset_get() */ - - -/*------------------------------------------------------------------------- - * Function: H5VL_dataset_specific - * - * Purpose: specific operation on datasets through the VOL - * - * Return: Success: non negative - * - * Failure: negative - * - *------------------------------------------------------------------------- - */ -herr_t -H5VL_dataset_specific(void *obj, const H5VL_class_t *cls, H5VL_dataset_specific_t specific_type, - hid_t dxpl_id, void **req, ...) -{ - va_list arguments; /* argument list passed from the API call */ - herr_t ret_value = SUCCEED; - - FUNC_ENTER_NOAPI(FAIL) - - if(NULL == cls->dataset_cls.specific) - HGOTO_ERROR(H5E_VOL, H5E_UNSUPPORTED, FAIL, "VOL driver has no 'dataset specific' method") - - va_start (arguments, req); - if((ret_value = (cls->dataset_cls.specific) - (obj, specific_type, dxpl_id, req, arguments)) < 0) - HGOTO_ERROR(H5E_VOL, H5E_CANTOPERATE, FAIL, "Unable to execute dataset specific callback") - va_end (arguments); - -done: - FUNC_LEAVE_NOAPI(ret_value) -} /* end H5VL_dataset_specific() */ +} /* end H5VL_object_verify() */ /*------------------------------------------------------------------------- - * Function: H5VL_dataset_optional - * - * Purpose: optional operation specific to drivers. + * Function: H5VL_cmp_connector_cls * - * Return: Success: non negative + * Purpose: Compare VOL class for a connector * - * Failure: negative + * Return: Positive if VALUE1 is greater than VALUE2, negative if + * VALUE2 is greater than VALUE1 and zero if VALUE1 and + * VALUE2 are equal. * *------------------------------------------------------------------------- */ herr_t -H5VL_dataset_optional(void *obj, const H5VL_class_t *cls, hid_t dxpl_id, void **req, ...) +H5VL_cmp_connector_cls(int *cmp_value, const H5VL_class_t *cls1, const H5VL_class_t *cls2) { - va_list arguments; /* argument list passed from the API call */ - herr_t ret_value = SUCCEED; + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_NOAPI(FAIL) - if(NULL == cls->dataset_cls.optional) - HGOTO_ERROR(H5E_VOL, H5E_UNSUPPORTED, FAIL, "VOL driver has no 'dataset optional' method") - - va_start (arguments, req); - if((ret_value = (cls->dataset_cls.optional)(obj, dxpl_id, req, arguments)) < 0) - HGOTO_ERROR(H5E_VOL, H5E_CANTOPERATE, FAIL, "Unable to execute dataset optional callback") - va_end (arguments); + /* Sanity checks */ + HDassert(cls1); + HDassert(cls2); + + /* Compare connector "values" */ + if(cls1->value < cls2->value) { + *cmp_value = -1; + HGOTO_DONE(SUCCEED) + } /* end if */ + if(cls1->value > cls2->value) { + *cmp_value = 1; + HGOTO_DONE(SUCCEED) + } /* end if */ + HDassert(cls1->value == cls2->value); + + /* Compare connector names */ + if(cls1->name == NULL && cls2->name != NULL) { + *cmp_value = -1; + HGOTO_DONE(SUCCEED) + } /* end if */ + if(cls1->name != NULL && cls2->name == NULL) { + *cmp_value = 1; + HGOTO_DONE(SUCCEED) + } /* end if */ + if(0 != (*cmp_value = HDstrcmp(cls1->name, cls2->name))) + HGOTO_DONE(SUCCEED) + + /* Compare connector VOL API versions */ + if(cls1->version < cls2->version) { + *cmp_value = -1; + HGOTO_DONE(SUCCEED) + } /* end if */ + if(cls1->version > cls2->version) { + *cmp_value = 1; + HGOTO_DONE(SUCCEED) + } /* end if */ + HDassert(cls1->version == cls2->version); + + /* Compare connector info */ + if(cls1->info_size < cls2->info_size) { + *cmp_value = -1; + HGOTO_DONE(SUCCEED) + } /* end if */ + if(cls1->info_size > cls2->info_size) { + *cmp_value = 1; + HGOTO_DONE(SUCCEED) + } /* end if */ + HDassert(cls1->info_size == cls2->info_size); + + /* Set comparison value to 'equal' */ + *cmp_value = 0; done: FUNC_LEAVE_NOAPI(ret_value) -} /* end H5VL_dataset_optional() */ +} /* end H5VL_cmp_connector_cls() */ /*------------------------------------------------------------------------- - * Function: H5VL_dataset_close + * Function: H5VL_set_vol_wrapper * - * Purpose: Closes a dataset through the VOL + * Purpose: Set up object wrapping context for current VOL connector * - * Return: SUCCEED/FAIL + * Return: SUCCEED / FAIL * *------------------------------------------------------------------------- */ herr_t -H5VL_dataset_close(void *dset, const H5VL_class_t *cls, hid_t dxpl_id, void **req) +H5VL_set_vol_wrapper(void *obj, const H5VL_t *connector) { - herr_t ret_value = SUCCEED; + H5VL_wrap_ctx_t *vol_wrap_ctx = NULL; /* Object wrapping context */ + void *obj_wrap_ctx = NULL; /* VOL connector's wrapping context */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_NOAPI(FAIL) - HDassert(dset); - HDassert(cls); - - /* Check if the corresponding VOL callback exists */ - if (NULL == cls->dataset_cls.close) - HGOTO_ERROR(H5E_VOL, H5E_UNSUPPORTED, FAIL, "VOL driver has no 'dset close' method"); - - /* Call the corresponding VOL callback */ - if ((ret_value = (cls->dataset_cls.close)(dset, dxpl_id, req)) < 0) - HGOTO_ERROR(H5E_VOL, H5E_CANTRELEASE, FAIL, "close failed"); - -done: - - FUNC_LEAVE_NOAPI(ret_value) -} /* end H5VL_dataset_close() */ - - -/*------------------------------------------------------------------------- - * Function: H5VL_file_create - * - * Purpose: Creates a file through the VOL - * - * Return: Success: pointer to file. - * - * Failure: NULL - * - *------------------------------------------------------------------------- - */ -void * -H5VL_file_create(const H5VL_class_t *cls, const char *name, unsigned flags, hid_t fcpl_id, - hid_t fapl_id, hid_t dxpl_id, void **req) -{ - void *ret_value = NULL; /* Return value */ - - FUNC_ENTER_NOAPI(NULL) - - /* check if the corresponding VOL create callback exists */ - if(NULL == cls->file_cls.create) - HGOTO_ERROR(H5E_VOL, H5E_UNSUPPORTED, NULL, "VOL driver has no 'file create' method") - /* call the corresponding VOL create callback */ - if(NULL == (ret_value = (cls->file_cls.create)(name, flags, fcpl_id, fapl_id, dxpl_id, req))) - HGOTO_ERROR(H5E_VOL, H5E_CANTINIT, NULL, "create failed") - -done: - FUNC_LEAVE_NOAPI(ret_value) -} /* end H5VL_file_create() */ - - -/*------------------------------------------------------------------------- - * Function: H5VL_file_open - * - * Purpose: Opens a file through the VOL. - * - * Return: Success: pointer to file. - * - * Failure: NULL - * - *------------------------------------------------------------------------- - */ -void * -H5VL_file_open(const H5VL_class_t *cls, const char *name, unsigned flags, hid_t fapl_id, - hid_t dxpl_id, void **req) -{ - void *ret_value = NULL; /* Return value */ - - FUNC_ENTER_NOAPI(NULL) + /* Sanity checks */ + HDassert(obj); + HDassert(connector); + + /* Retrieve the VOL object wrap context */ + if(H5CX_get_vol_wrap_ctx((void **)&vol_wrap_ctx) < 0) + HGOTO_ERROR(H5E_VOL, H5E_CANTGET, FAIL, "can't get VOL object wrap context") + + /* Check for existing wrapping context */ + if(NULL == vol_wrap_ctx) { + /* Check if the connector can create a wrap context */ + if(connector->cls->get_wrap_ctx) { + /* Sanity check */ + HDassert(connector->cls->free_wrap_ctx); + + /* Get the wrap context from the connector */ + if((connector->cls->get_wrap_ctx)(obj, &obj_wrap_ctx) < 0) + HGOTO_ERROR(H5E_VOL, H5E_CANTGET, FAIL, "can't retrieve VOL connector's object wrap context") + } /* end if */ + + /* Allocate VOL object wrapper context */ + if(NULL == (vol_wrap_ctx = H5FL_MALLOC(H5VL_wrap_ctx_t))) + HGOTO_ERROR(H5E_VOL, H5E_CANTALLOC, FAIL, "can't allocate VOL wrap context") + + /* Set up VOL object wrapper context */ + vol_wrap_ctx->rc = 1;; + vol_wrap_ctx->connector = connector; + vol_wrap_ctx->obj_wrap_ctx = obj_wrap_ctx; + } /* end if */ + else + /* Incremeent ref count on existing wrapper context */ + vol_wrap_ctx->rc++; - /* check if the corresponding VOL create callback exists */ - if(NULL == cls->file_cls.open) - HGOTO_ERROR(H5E_VOL, H5E_UNSUPPORTED, NULL, "VOL driver has no 'file open' method") - /* call the corresponding VOL create callback */ - if(NULL == (ret_value = (cls->file_cls.open)(name, flags, fapl_id, dxpl_id, req))) - HGOTO_ERROR(H5E_VOL, H5E_CANTINIT, NULL, "open failed") + /* Save the wrapper context */ + if(H5CX_set_vol_wrap_ctx(vol_wrap_ctx) < 0) + HGOTO_ERROR(H5E_VOL, H5E_CANTSET, FAIL, "can't set VOL object wrap context") done: - FUNC_LEAVE_NOAPI(ret_value) -} /* end H5VL_file_open() */ + if(ret_value < 0 && vol_wrap_ctx) + /* Release object wrapping context */ + H5FL_FREE(H5VL_wrap_ctx_t, vol_wrap_ctx); - -/*------------------------------------------------------------------------- - * Function: H5VL_file_get - * - * Purpose: Get specific information about the file through the VOL - * - * Return: Success: non negative - * - * Failure: negative - * - *------------------------------------------------------------------------- - */ -herr_t -H5VL_file_get(void *file, const H5VL_class_t *cls, H5VL_file_get_t get_type, - hid_t dxpl_id, void **req, ...) -{ - va_list arguments; /* argument list passed from the API call */ - herr_t ret_value = SUCCEED; - - FUNC_ENTER_NOAPI(FAIL) - - if(NULL == cls->file_cls.get) - HGOTO_ERROR(H5E_VOL, H5E_UNSUPPORTED, FAIL, "VOL driver has no 'file get' method") - - va_start(arguments, req); - if((ret_value = (cls->file_cls.get)(file, get_type, dxpl_id, req, arguments)) < 0) - HGOTO_ERROR(H5E_VOL, H5E_CANTGET, FAIL, "get failed") - va_end(arguments); - -done: FUNC_LEAVE_NOAPI(ret_value) -} /* end H5VL_file_get() */ +} /* end H5VL_set_vol_wrapper() */ /*------------------------------------------------------------------------- - * Function: H5VL_file_specific + * Function: H5VL_reset_vol_wrapper * - * Purpose: perform File specific operations through the VOL + * Purpose: Reset object wrapping context for current VOL connector * - * Return: Success: non negative - * Failure: negative + * Return: SUCCEED / FAIL * *------------------------------------------------------------------------- */ herr_t -H5VL_file_specific(void *file, const H5VL_class_t *cls, H5VL_file_specific_t specific_type, - hid_t dxpl_id, void **req, ...) +H5VL_reset_vol_wrapper(void) { - va_list arguments; /* argument list passed from the API call */ - herr_t ret_value = SUCCEED; + H5VL_wrap_ctx_t *vol_wrap_ctx = NULL; /* Object wrapping context */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_NOAPI(FAIL) - if(specific_type == H5VL_FILE_IS_ACCESSIBLE) { - H5P_genplist_t *plist; /* Property list pointer */ - H5VL_driver_prop_t driver_prop; /* Property for VOL driver ID & info */ - va_list tmp_args; /* argument list passed from the API call */ - hid_t fapl_id; - - va_start (tmp_args, req); - fapl_id = va_arg (tmp_args, hid_t); - va_end (tmp_args); - - /* get the VOL info from the fapl */ - if(NULL == (plist = (H5P_genplist_t *)H5I_object(fapl_id))) - HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a file access property list") - - if(H5P_peek(plist, H5F_ACS_VOL_DRV_NAME, &driver_prop) < 0) - HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, FAIL, "can't get VOL driver info") - - if(NULL == (cls = (H5VL_class_t *)H5I_object_verify(driver_prop.driver_id, H5I_VOL))) - HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a VOL driver ID") - - va_start (arguments, req); - if((ret_value = (cls->file_cls.specific) - (file, specific_type, dxpl_id, req, arguments)) < 0) - HGOTO_ERROR(H5E_VOL, H5E_CANTGET, FAIL, "specific failed") - va_end (arguments); - } + /* Retrieve the VOL object wrap context */ + if(H5CX_get_vol_wrap_ctx((void **)&vol_wrap_ctx) < 0) + HGOTO_ERROR(H5E_VOL, H5E_CANTGET, FAIL, "can't get VOL object wrap context") + + /* Check for VOL object wrap context */ + if(NULL == vol_wrap_ctx) + HGOTO_ERROR(H5E_VOL, H5E_BADVALUE, FAIL, "no VOL object wrap context?") + + /* Decrement ref count on wrapping context */ + vol_wrap_ctx->rc--; + + /* Release context if the ref count drops to zero */ + if(0 == vol_wrap_ctx->rc) { + /* If there is a VOL connector object wrapping context, release it */ + if(vol_wrap_ctx->obj_wrap_ctx) { + /* Release the VOL connector's object wrapping context */ + if((*vol_wrap_ctx->connector->cls->free_wrap_ctx)(vol_wrap_ctx->obj_wrap_ctx) < 0) + HGOTO_ERROR(H5E_VOL, H5E_CANTRELEASE, FAIL, "unable to release connector's object wrapping context") + } /* end if */ + + /* Release object wrapping context */ + H5FL_FREE(H5VL_wrap_ctx_t, vol_wrap_ctx); + + /* Reset the wrapper context */ + if(H5CX_set_vol_wrap_ctx(NULL) < 0) + HGOTO_ERROR(H5E_VOL, H5E_CANTSET, FAIL, "can't set VOL object wrap context") + } /* end if */ else { - if(NULL == cls->file_cls.specific) - HGOTO_ERROR(H5E_VOL, H5E_UNSUPPORTED, FAIL, "VOL driver has no 'file specific' method") - - va_start (arguments, req); - if((ret_value = (cls->file_cls.specific) - (file, specific_type, dxpl_id, req, arguments)) < 0) - HGOTO_ERROR(H5E_VOL, H5E_CANTGET, FAIL, "specific failed") - va_end (arguments); - } + /* Save the updated wrapper context */ + if(H5CX_set_vol_wrap_ctx(vol_wrap_ctx) < 0) + HGOTO_ERROR(H5E_VOL, H5E_CANTSET, FAIL, "can't set VOL object wrap context") + } /* end else */ done: FUNC_LEAVE_NOAPI(ret_value) -} /* end H5VL_file_specific() */ +} /* end H5VL_reset_vol_wrapper() */ /*------------------------------------------------------------------------- - * Function: H5VL_file_optional + * Function: H5VL_wrap_register * - * Purpose: perform a driver specific operation + * Purpose: Wrap an object and register an ID for it * - * Return: Success: non negative - * Failure: negative + * Return: SUCCEED / FAIL * *------------------------------------------------------------------------- */ -herr_t -H5VL_file_optional(void *file, const H5VL_class_t *cls, hid_t dxpl_id, void **req, ...) -{ - va_list arguments; /* argument list passed from the API call */ - herr_t ret_value = SUCCEED; - - FUNC_ENTER_NOAPI(FAIL) - - if(NULL == cls->file_cls.optional) - HGOTO_ERROR(H5E_VOL, H5E_UNSUPPORTED, FAIL, "VOL driver has no 'file optional' method") - - va_start (arguments, req); - if((ret_value = (cls->file_cls.optional)(file, dxpl_id, req, arguments)) < 0) - HGOTO_ERROR(H5E_VOL, H5E_CANTGET, FAIL, "optional failed") - va_end (arguments); - -done: - FUNC_LEAVE_NOAPI(ret_value) -} /* end H5VL_file_optional() */ - - -/*------------------------------------------------------------------------- - * Function: H5VL_file_close - * - * Purpose: Closes a file through the VOL - * - * Return: SUCCEED/FAIL - * - *------------------------------------------------------------------------- - */ -herr_t -H5VL_file_close(void *file, const H5VL_class_t *cls, hid_t dxpl_id, void **req) -{ - herr_t ret_value = SUCCEED; - - FUNC_ENTER_NOAPI(FAIL) - - HDassert(file); - HDassert(cls); - - /* Check if the corresponding VOL callback exists */ - if (NULL == cls->file_cls.close) - HGOTO_ERROR(H5E_VOL, H5E_UNSUPPORTED, FAIL, "VOL driver has no 'file close' method"); - - /* Call the corresponding VOL callback */ - if ((ret_value = (cls->file_cls.close)(file, dxpl_id, req)) < 0) - HGOTO_ERROR(H5E_VOL, H5E_CANTCLOSEFILE, FAIL, "close failed"); - -done: - FUNC_LEAVE_NOAPI(ret_value) -} /* end H5VL_file_close() */ - - -/*------------------------------------------------------------------------- - * Function: H5VL_group_create - * - * Purpose: Creates a group through the VOL - * - * Return: Success: pointer to new group. - * - * Failure: NULL - * - *------------------------------------------------------------------------- - */ -void * -H5VL_group_create(void *obj, H5VL_loc_params_t loc_params, const H5VL_class_t *cls, const char *name, - hid_t gcpl_id, hid_t gapl_id, hid_t dxpl_id, void **req) -{ - void *ret_value = NULL; /* Return value */ - - FUNC_ENTER_NOAPI(NULL) - - /* check if the corresponding VOL create callback exists */ - if(NULL == cls->group_cls.create) - HGOTO_ERROR(H5E_VOL, H5E_UNSUPPORTED, NULL, "VOL driver has no 'group create' method") - - /* call the corresponding VOL create callback */ - if(NULL == (ret_value = (cls->group_cls.create) - (obj, loc_params, name, gcpl_id, gapl_id, dxpl_id, req))) - HGOTO_ERROR(H5E_VOL, H5E_CANTINIT, NULL, "create failed") - -done: - FUNC_LEAVE_NOAPI(ret_value) -} /* end H5VL_group_create() */ - - -/*------------------------------------------------------------------------- - * Function: H5VL_group_open - * - * Purpose: Opens a group through the VOL - * - * Return: Success: pointer to new group. - * - * Failure: NULL - * - *------------------------------------------------------------------------- - */ -void * -H5VL_group_open(void *obj, H5VL_loc_params_t loc_params, const H5VL_class_t *cls, const char *name, - hid_t gapl_id, hid_t dxpl_id, void **req) -{ - void *ret_value; /* Return value */ - - FUNC_ENTER_NOAPI(NULL) - - if(NULL == cls->group_cls.open) - HGOTO_ERROR(H5E_VOL, H5E_UNSUPPORTED, NULL, "VOL driver has no 'group open' method") - - if(NULL == (ret_value = (cls->group_cls.open) - (obj, loc_params, name, gapl_id, dxpl_id, req))) - HGOTO_ERROR(H5E_VOL, H5E_CANTOPENOBJ, NULL, "open failed") - -done: - FUNC_LEAVE_NOAPI(ret_value) -} /* end H5VL_group_open() */ - - -/*------------------------------------------------------------------------- - * Function: H5VL_group_get - * - * Purpose: Get specific information about the group through the VOL - * - * Return: Success: non negative - * - * Failure: negative - * - *------------------------------------------------------------------------- - */ -herr_t -H5VL_group_get(void *obj, const H5VL_class_t *cls, H5VL_group_get_t get_type, - hid_t dxpl_id, void **req, ...) -{ - va_list arguments; /* argument list passed from the API call */ - herr_t ret_value = SUCCEED; - - FUNC_ENTER_NOAPI(FAIL) - - if(NULL == cls->group_cls.get) - HGOTO_ERROR(H5E_VOL, H5E_UNSUPPORTED, FAIL, "VOL driver has no 'group get' method") - - va_start (arguments, req); - if((ret_value = (cls->group_cls.get) - (obj, get_type, dxpl_id, req, arguments)) < 0) - HGOTO_ERROR(H5E_VOL, H5E_CANTGET, FAIL, "get failed") - va_end (arguments); - -done: - FUNC_LEAVE_NOAPI(ret_value) -} /* end H5VL_group_get() */ - - -/*------------------------------------------------------------------------- - * Function: H5VL_group_specific - * - * Purpose: specific operation on groups through the VOL - * - * Return: Success: non negative - * - * Failure: negative - * - *------------------------------------------------------------------------- - */ -herr_t -H5VL_group_specific(void *obj, const H5VL_class_t *cls, H5VL_group_specific_t specific_type, - hid_t dxpl_id, void **req, ...) -{ - va_list arguments; /* argument list passed from the API call */ - herr_t ret_value = SUCCEED; - - FUNC_ENTER_NOAPI(FAIL) - - if(NULL == cls->group_cls.specific) - HGOTO_ERROR(H5E_VOL, H5E_UNSUPPORTED, FAIL, "VOL driver has no 'group specific' method") - - va_start (arguments, req); - if((ret_value = (cls->group_cls.specific) - (obj, specific_type, dxpl_id, req, arguments)) < 0) - HGOTO_ERROR(H5E_VOL, H5E_CANTOPERATE, FAIL, "Unable to execute group specific callback") - va_end (arguments); - -done: - FUNC_LEAVE_NOAPI(ret_value) -} /* end H5VL_group_specific() */ - - -/*------------------------------------------------------------------------- - * Function: H5VL_group_optional - * - * Purpose: optional operation specific to drivers. - * - * Return: Success: non negative - * - * Failure: negative - * - *------------------------------------------------------------------------- - */ -herr_t -H5VL_group_optional(void *obj, const H5VL_class_t *cls, hid_t dxpl_id, void **req, ...) -{ - va_list arguments; /* argument list passed from the API call */ - herr_t ret_value = SUCCEED; - - FUNC_ENTER_NOAPI(FAIL) - - if(NULL == cls->group_cls.optional) - HGOTO_ERROR(H5E_VOL, H5E_UNSUPPORTED, FAIL, "VOL driver has no 'group optional' method") - - va_start (arguments, req); - if((ret_value = (cls->group_cls.optional)(obj, dxpl_id, req, arguments)) < 0) - HGOTO_ERROR(H5E_VOL, H5E_CANTOPERATE, FAIL, "Unable to execute group optional callback") - va_end (arguments); - -done: - FUNC_LEAVE_NOAPI(ret_value) -} /* end H5VL_group_optional() */ - - -/*------------------------------------------------------------------------- - * Function: H5VL_group_close - * - * Purpose: Closes a group through the VOL - * - * Return: SUCCEED/FAIL - * - *------------------------------------------------------------------------- - */ -herr_t -H5VL_group_close(void *grp, const H5VL_class_t *cls, hid_t dxpl_id, void **req) -{ - herr_t ret_value = SUCCEED; - - HDassert(grp); - HDassert(cls); - - FUNC_ENTER_NOAPI(FAIL) - - /* Check if the corresponding VOL callback exists */ - if (NULL == cls->group_cls.close) - HGOTO_ERROR(H5E_VOL, H5E_UNSUPPORTED, FAIL, "VOL driver has no 'group close' method"); - - /* Call the corresponding VOL callback */ - if ((ret_value = (cls->group_cls.close)(grp, dxpl_id, req)) < 0) - HGOTO_ERROR(H5E_VOL, H5E_CANTRELEASE, FAIL, "close failed"); - -done: - FUNC_LEAVE_NOAPI(ret_value) -} /* end H5VL_group_close() */ - - -/*------------------------------------------------------------------------- - * Function: H5VL_link_create - * - * Purpose: Creates a hard link through the VOL - * - * Return: Non-negative on success/Negative on failure - * - *------------------------------------------------------------------------- - */ -herr_t -H5VL_link_create(H5VL_link_create_type_t create_type, void *obj, H5VL_loc_params_t loc_params, - const H5VL_class_t *cls, hid_t lcpl_id, hid_t lapl_id, hid_t dxpl_id, void **req) -{ - herr_t ret_value = SUCCEED; /* Return value */ - - FUNC_ENTER_NOAPI(FAIL) - - /* check if the corresponding VOL create callback exists */ - if(NULL == cls->link_cls.create) - HGOTO_ERROR(H5E_VOL, H5E_UNSUPPORTED, FAIL, "VOL driver has no 'link create' method") - /* call the corresponding VOL create callback */ - if((ret_value = (cls->link_cls.create) - (create_type, obj, loc_params, lcpl_id, lapl_id, dxpl_id, req)) < 0) - HGOTO_ERROR(H5E_VOL, H5E_CANTINIT, FAIL, "link create failed") - -done: - FUNC_LEAVE_NOAPI(ret_value) -} /* end H5VL_link_create() */ - - -/*------------------------------------------------------------------------- - * Function: H5VL_link_copy - * - * Purpose: Copys a link from src to dst. - * - * Return: Non-negative on success/Negative on failure - * - *------------------------------------------------------------------------- - */ -herr_t -H5VL_link_copy(void *src_obj, H5VL_loc_params_t loc_params1, void *dst_obj, - H5VL_loc_params_t loc_params2, const H5VL_class_t *cls, - hid_t lcpl_id, hid_t lapl_id, hid_t dxpl_id, void **req) -{ - herr_t ret_value = SUCCEED; /* Return value */ - - FUNC_ENTER_NOAPI(FAIL) - - /* check if the corresponding VOL copy callback exists */ - if(NULL == cls->link_cls.copy) - HGOTO_ERROR(H5E_VOL, H5E_UNSUPPORTED, FAIL, "VOL driver has no 'link copy' method") - - /* call the corresponding VOL copy callback */ - if((ret_value = (cls->link_cls.copy) - (src_obj, loc_params1, dst_obj, loc_params2, lcpl_id, - lapl_id, dxpl_id, req)) < 0) - HGOTO_ERROR(H5E_VOL, H5E_CANTINIT, FAIL, "link copy failed") - -done: - FUNC_LEAVE_NOAPI(ret_value) -} /* end H5VL_link_copy() */ - - -/*------------------------------------------------------------------------- - * Function: H5VL_link_move - * - * Purpose: Moves a link from src to dst. - * - * Return: Non-negative on success/Negative on failure - * - *------------------------------------------------------------------------- - */ -herr_t -H5VL_link_move(void *src_obj, H5VL_loc_params_t loc_params1, void *dst_obj, - H5VL_loc_params_t loc_params2, const H5VL_class_t *cls, - hid_t lcpl_id, hid_t lapl_id, hid_t dxpl_id, void **req) -{ - herr_t ret_value = SUCCEED; /* Return value */ - - FUNC_ENTER_NOAPI(FAIL) - - /* check if the corresponding VOL move callback exists */ - if(NULL == cls->link_cls.move) - HGOTO_ERROR(H5E_VOL, H5E_UNSUPPORTED, FAIL, "VOL driver has no 'link move' method") - - /* call the corresponding VOL move callback */ - if((ret_value = (cls->link_cls.move) - (src_obj, loc_params1, dst_obj, loc_params2, lcpl_id, - lapl_id, dxpl_id, req)) < 0) - HGOTO_ERROR(H5E_VOL, H5E_CANTINIT, FAIL, "link move failed") - -done: - FUNC_LEAVE_NOAPI(ret_value) -} /* end H5VL_link_move() */ - - -/*------------------------------------------------------------------------- - * Function: H5VL_link_get - * - * Purpose: Get specific information about the link through the VOL - * - * Return: Success: non negative - * - * Failure: negative - * - *------------------------------------------------------------------------- - */ -herr_t -H5VL_link_get(void *obj, H5VL_loc_params_t loc_params, const H5VL_class_t *cls, H5VL_link_get_t get_type, - hid_t dxpl_id, void **req, ...) -{ - va_list arguments; /* argument list passed from the API call */ - herr_t ret_value = SUCCEED; - - FUNC_ENTER_NOAPI(FAIL) - - if(NULL == cls->link_cls.get) - HGOTO_ERROR(H5E_VOL, H5E_UNSUPPORTED, FAIL, "VOL driver has no 'link get' method") - - va_start (arguments, req); - if((ret_value = (cls->link_cls.get) - (obj, loc_params, get_type, dxpl_id, req, arguments)) < 0) - HGOTO_ERROR(H5E_VOL, H5E_CANTGET, FAIL, "get failed") - va_end (arguments); - -done: - FUNC_LEAVE_NOAPI(ret_value) -} /* end H5VL_link_get() */ - - -/*------------------------------------------------------------------------- - * Function: H5VL_link_specific - * - * Purpose: specific operation on links through the VOL - * - * Return: Success: non negative - * - * Failure: negative - * - *------------------------------------------------------------------------- - */ -herr_t -H5VL_link_specific(void *obj, H5VL_loc_params_t loc_params, const H5VL_class_t *cls, - H5VL_link_specific_t specific_type, hid_t dxpl_id, void **req, ...) -{ - va_list arguments; /* argument list passed from the API call */ - herr_t ret_value = SUCCEED; - - FUNC_ENTER_NOAPI(FAIL) - - if(NULL == cls->link_cls.specific) - HGOTO_ERROR(H5E_VOL, H5E_UNSUPPORTED, FAIL, "VOL driver has no 'link specific' method") - - va_start (arguments, req); - if((ret_value = (cls->link_cls.specific) - (obj, loc_params, specific_type, dxpl_id, req, arguments)) < 0) - HGOTO_ERROR(H5E_VOL, H5E_CANTOPERATE, FAIL, "Unable to execute link specific callback") - va_end (arguments); - -done: - FUNC_LEAVE_NOAPI(ret_value) -} /* end H5VL_link_specific() */ - - -/*------------------------------------------------------------------------- - * Function: H5VL_link_optional - * - * Purpose: optional operation specific to drivers. - * - * Return: Success: non negative - * - * Failure: negative - * - *------------------------------------------------------------------------- - */ -herr_t -H5VL_link_optional(void *obj, const H5VL_class_t *cls, hid_t dxpl_id, void **req, ...) -{ - va_list arguments; /* argument list passed from the API call */ - herr_t ret_value = SUCCEED; - - FUNC_ENTER_NOAPI(FAIL) - - if(NULL == cls->link_cls.optional) - HGOTO_ERROR(H5E_VOL, H5E_UNSUPPORTED, FAIL, "VOL driver has no 'link optional' method") - - va_start (arguments, req); - if((ret_value = (cls->link_cls.optional)(obj, dxpl_id, req, arguments)) < 0) - HGOTO_ERROR(H5E_VOL, H5E_CANTOPERATE, FAIL, "Unable to execute link optional callback") - va_end (arguments); - -done: - FUNC_LEAVE_NOAPI(ret_value) -} /* end H5VL_link_optional() */ - - -/*------------------------------------------------------------------------- - * Function: H5VL_object_open - * - * Purpose: Opens a object through the VOL - * - * Return: Success: User ID of the new object. - * - * Failure: NULL - * - *------------------------------------------------------------------------- - */ -void * -H5VL_object_open(void *obj, H5VL_loc_params_t params, const H5VL_class_t *cls, H5I_type_t *opened_type, - hid_t dxpl_id, void **req) -{ - void *ret_value; /* Return value */ - - FUNC_ENTER_NOAPI(NULL) - - /* check if the corresponding VOL open callback exists */ - if(NULL == cls->object_cls.open) - HGOTO_ERROR(H5E_VOL, H5E_UNSUPPORTED, NULL, "VOL driver has no 'object open' method") - - /* call the corresponding VOL open callback */ - if(NULL == (ret_value = (cls->object_cls.open) - (obj, params, opened_type, dxpl_id, req))) - HGOTO_ERROR(H5E_VOL, H5E_CANTOPENOBJ, NULL, "open failed") - -done: - FUNC_LEAVE_NOAPI(ret_value) -} /* end H5VL_object_open() */ - - -/*------------------------------------------------------------------------- - * Function: H5VL_object_copy - * - * Purpose: Copies an object to another destination through the VOL - * - * Return: Success: Non Negative - * Failure: Negative - * - *------------------------------------------------------------------------- - */ -herr_t -H5VL_object_copy(void *src_obj, H5VL_loc_params_t loc_params1, const H5VL_class_t *cls1, const char *src_name, - void *dst_obj, H5VL_loc_params_t loc_params2, const H5VL_class_t *cls2, const char *dst_name, - hid_t ocpypl_id, hid_t lcpl_id, hid_t dxpl_id, void **req) -{ - herr_t ret_value = SUCCEED; - - FUNC_ENTER_NOAPI(FAIL) - - /* Make sure that the VOL drivers are the same */ - if (cls1->value != cls2->value) - HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "Objects are accessed through different VOL drivers and can't be linked") - - if(NULL == cls1->object_cls.copy) - HGOTO_ERROR(H5E_VOL, H5E_UNSUPPORTED, FAIL, "VOL driver has no 'object copy' method") - - if((ret_value = (cls1->object_cls.copy) - (src_obj, loc_params1, src_name, dst_obj, loc_params2, dst_name, ocpypl_id, - lcpl_id, dxpl_id, req)) < 0) - HGOTO_ERROR(H5E_VOL, H5E_CANTRELEASE, FAIL, "copy failed") - -done: - FUNC_LEAVE_NOAPI(ret_value) -} /* end H5VL_object_copy() */ - - -/*------------------------------------------------------------------------- - * Function: H5VL_object_get - * - * Purpose: Get specific information about the object through the VOL - * - * Return: Success: non negative - * - * Failure: negative - * - *------------------------------------------------------------------------- - */ -herr_t -H5VL_object_get(void *obj, H5VL_loc_params_t loc_params, const H5VL_class_t *cls, H5VL_object_get_t get_type, - hid_t dxpl_id, void **req, ...) -{ - va_list arguments; /* argument list passed from the API call */ - herr_t ret_value = SUCCEED; - - FUNC_ENTER_NOAPI(FAIL) - - if(NULL == cls->object_cls.get) - HGOTO_ERROR(H5E_VOL, H5E_UNSUPPORTED, FAIL, "VOL driver has no 'object get' method") - - va_start (arguments, req); - if((ret_value = (cls->object_cls.get) - (obj, loc_params, get_type, dxpl_id, req, arguments)) < 0) - HGOTO_ERROR(H5E_VOL, H5E_CANTGET, FAIL, "get failed") - va_end (arguments); - -done: - FUNC_LEAVE_NOAPI(ret_value) -} /* end H5VL_object_get() */ - - -/*------------------------------------------------------------------------- - * Function: H5VL_object_specific - * - * Purpose: specific operation on objects through the VOL - * - * Return: Success: non negative - * Failure: negative - * - *------------------------------------------------------------------------- - */ -herr_t -H5VL_object_specific(void *obj, H5VL_loc_params_t loc_params, const H5VL_class_t *cls, - H5VL_object_specific_t specific_type, hid_t dxpl_id, void **req, ...) -{ - va_list arguments; /* argument list passed from the API call */ - herr_t ret_value = SUCCEED; - - FUNC_ENTER_NOAPI(FAIL) - - if(NULL == cls->object_cls.specific) - HGOTO_ERROR(H5E_VOL, H5E_UNSUPPORTED, FAIL, "VOL driver has no 'object specific' method") - - va_start (arguments, req); - if((ret_value = (cls->object_cls.specific) - (obj, loc_params, specific_type, dxpl_id, req, arguments)) < 0) - HGOTO_ERROR(H5E_VOL, H5E_CANTGET, FAIL, "specific failed") - va_end (arguments); - -done: - FUNC_LEAVE_NOAPI(ret_value) -} /* end H5VL_object_specific() */ - - -/*------------------------------------------------------------------------- - * Function: H5VL_object_optional - * - * Purpose: optional operation specific to drivers. - * - * Return: Success: non negative - * - * Failure: negative - * - *------------------------------------------------------------------------- - */ -herr_t -H5VL_object_optional(void *obj, const H5VL_class_t *cls, hid_t dxpl_id, void **req, ...) -{ - va_list arguments; /* argument list passed from the API call */ - herr_t ret_value = SUCCEED; - - FUNC_ENTER_NOAPI(FAIL) - - if(NULL == cls->object_cls.optional) - HGOTO_ERROR(H5E_VOL, H5E_UNSUPPORTED, FAIL, "VOL driver has no 'object optional' method") - - va_start (arguments, req); - if((ret_value = (cls->object_cls.optional)(obj, dxpl_id, req, arguments)) < 0) - HGOTO_ERROR(H5E_VOL, H5E_CANTOPERATE, FAIL, "Unable to execute object optional callback") - va_end (arguments); - -done: - FUNC_LEAVE_NOAPI(ret_value) -} /* end H5VL_object_optional() */ - - -/*------------------------------------------------------------------------- - * Function: H5VL_datatype_commit - * - * Purpose: Commits a datatype to the file through the VOL - * - * Return: Success: Positive - * - * Failure: Negative - * - *------------------------------------------------------------------------- - */ -void * -H5VL_datatype_commit(void *obj, H5VL_loc_params_t loc_params, const H5VL_class_t *cls, 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) -{ - void *ret_value = NULL; /* Return value */ - - FUNC_ENTER_NOAPI(NULL) - - /* check if the corresponding VOL commit callback exists */ - if(NULL == cls->datatype_cls.commit) - HGOTO_ERROR(H5E_VOL, H5E_UNSUPPORTED, NULL, "VOL driver has no 'datatype commit' method") - - /* call the corresponding VOL commit callback */ - if(NULL == (ret_value = (cls->datatype_cls.commit) - (obj, loc_params, name, type_id, lcpl_id, tcpl_id, tapl_id, dxpl_id, req))) - HGOTO_ERROR(H5E_VOL, H5E_CANTINIT, NULL, "commit failed") - -done: - FUNC_LEAVE_NOAPI(ret_value) -} /* end H5VL_datatype_commit() */ - - -/*------------------------------------------------------------------------- - * Function: H5VL_datatype_open - * - * Purpose: Opens a named datatype through the VOL - * - * Return: Success: User ID of the datatype. - * - * Failure: NULL - * - *------------------------------------------------------------------------- - */ -void * -H5VL_datatype_open(void *obj, H5VL_loc_params_t loc_params, const H5VL_class_t *cls, const char *name, - hid_t tapl_id, hid_t dxpl_id, void **req) -{ - void *ret_value = NULL; /* Return value */ - - FUNC_ENTER_NOAPI(NULL) - - /* check if the type specific corresponding VOL open callback exists */ - if(NULL == cls->datatype_cls.open) - HGOTO_ERROR(H5E_VOL, H5E_CANTINIT, NULL, "no datatype open callback"); - - /* call the corresponding VOL open callback */ - if(NULL == (ret_value = (cls->datatype_cls.open) - (obj, loc_params, name, tapl_id, dxpl_id, req))) - HGOTO_ERROR(H5E_VOL, H5E_CANTOPENOBJ, NULL, "open failed") - -done: - FUNC_LEAVE_NOAPI(ret_value) -} /* end H5VL_datatype_open() */ - - -/*------------------------------------------------------------------------- - * Function: H5VL_datatype_get - * - * Purpose: Get specific information about the datatype through the VOL - * - * Return: SUCCEED/FAIL - * - *------------------------------------------------------------------------- - */ -herr_t -H5VL_datatype_get(void *obj, const H5VL_class_t *cls, H5VL_datatype_get_t get_type, - hid_t dxpl_id, void **req, ...) -{ - va_list arguments; /* argument list passed from the API call */ - herr_t ret_value = SUCCEED; - - FUNC_ENTER_NOAPI(FAIL) - - /* Check if the corresponding VOL callback exists */ - if (NULL == cls->datatype_cls.get) - HGOTO_ERROR(H5E_VOL, H5E_UNSUPPORTED, FAIL, "VOL driver has no 'datatype get' method"); - va_start (arguments, req); - - /* Call the corresponding VOL callback */ - if ((ret_value = (cls->datatype_cls.get)(obj, get_type, dxpl_id, req, arguments)) < 0) - HGOTO_ERROR(H5E_VOL, H5E_CANTGET, FAIL, "get failed"); - va_end (arguments); - -done: - FUNC_LEAVE_NOAPI(ret_value) -} /* end H5VL_datatype_get() */ - - -/*------------------------------------------------------------------------- - * Function: H5VL_datatype_specific - * - * Purpose: specific operation on datatypes through the VOL - * - * Return: Success: non negative - * - * Failure: negative - * - *------------------------------------------------------------------------- - */ -herr_t -H5VL_datatype_specific(void *obj, const H5VL_class_t *cls, H5VL_datatype_specific_t specific_type, - hid_t dxpl_id, void **req, ...) -{ - va_list arguments; /* argument list passed from the API call */ - herr_t ret_value = SUCCEED; - - FUNC_ENTER_NOAPI(FAIL) - - if(NULL == cls->datatype_cls.specific) - HGOTO_ERROR(H5E_VOL, H5E_UNSUPPORTED, FAIL, "VOL driver has no 'datatype specific' method") - - va_start (arguments, req); - if((ret_value = (cls->datatype_cls.specific) - (obj, specific_type, dxpl_id, req, arguments)) < 0) - HGOTO_ERROR(H5E_VOL, H5E_CANTOPERATE, FAIL, "Unable to execute datatype specific callback") - va_end (arguments); - -done: - FUNC_LEAVE_NOAPI(ret_value) -} /* end H5VL_datatype_specific() */ - - -/*------------------------------------------------------------------------- - * Function: H5VL_datatype_optional - * - * Purpose: optional operation specific to drivers. - * - * Return: Success: non negative - * - * Failure: negative - * - *------------------------------------------------------------------------- - */ -herr_t -H5VL_datatype_optional(void *obj, const H5VL_class_t *cls, hid_t dxpl_id, void **req, ...) -{ - va_list arguments; /* argument list passed from the API call */ - herr_t ret_value = SUCCEED; - - FUNC_ENTER_NOAPI(FAIL) - - if(NULL == cls->datatype_cls.optional) - HGOTO_ERROR(H5E_VOL, H5E_UNSUPPORTED, FAIL, "VOL driver has no 'datatype optional' method") - - va_start (arguments, req); - if((ret_value = (cls->datatype_cls.optional)(obj, dxpl_id, req, arguments)) < 0) - HGOTO_ERROR(H5E_VOL, H5E_CANTOPERATE, FAIL, "Unable to execute datatype optional callback") - va_end (arguments); - -done: - FUNC_LEAVE_NOAPI(ret_value) -} /* end H5VL_datatype_optional() */ - - -/*------------------------------------------------------------------------- - * Function: H5VL_datatype_close - * - * Purpose: Closes a datatype through the VOL - * - * Return: SUCCEED/FAIL - * - *------------------------------------------------------------------------- - */ -herr_t -H5VL_datatype_close(void *dt, const H5VL_class_t *cls, hid_t dxpl_id, void **req) -{ - herr_t ret_value = SUCCEED; /* Return value */ - - FUNC_ENTER_NOAPI(FAIL) - - /* Check if the corresponding VOL callback exists */ - if (NULL == cls->datatype_cls.close) - HGOTO_ERROR(H5E_VOL, H5E_UNSUPPORTED, FAIL, "VOL driver has no 'datatype close' method"); - - /* Call the corresponding VOL callback */ - if ((ret_value = (cls->datatype_cls.close)(dt, dxpl_id, req)) < 0) - HGOTO_ERROR(H5E_VOL, H5E_CANTRELEASE, FAIL, "close failed"); - -done: - FUNC_LEAVE_NOAPI(ret_value) -} /* end H5VL_datatype_close() */ - - -/*------------------------------------------------------------------------- - * Function: H5VL_request_cancel - * - * Purpose: Cancels an asynchronous request through the VOL - * - * Return: SUCCEED/FAIL - * - *------------------------------------------------------------------------- - */ -herr_t -H5VL_request_cancel(void **req, const H5VL_class_t *cls, H5ES_status_t *status) -{ - herr_t ret_value = SUCCEED; - - FUNC_ENTER_NOAPI(FAIL) - - HDassert(req); - HDassert(cls); - HDassert(status); - - /* Check if the corresponding VOL callback exists */ - if (NULL == cls->async_cls.cancel) - HGOTO_ERROR(H5E_VOL, H5E_UNSUPPORTED, FAIL, "VOL driver has no 'async cancel' method"); - - /* Call the corresponding VOL callback */ - if ((ret_value = (cls->async_cls.cancel)(req, status)) < 0) - HGOTO_ERROR(H5E_VOL, H5E_CANTRELEASE, FAIL, "request cancel failed"); - -done: - FUNC_LEAVE_NOAPI(ret_value) -} /* end H5VL_request_cancel() */ - - -/*------------------------------------------------------------------------- - * Function: H5VL_request_test - * - * Purpose: Tests an asynchronous request through the VOL - * - * Return: SUCCEED/FAIL - * - *------------------------------------------------------------------------- - */ -herr_t -H5VL_request_test(void **req, const H5VL_class_t *cls, H5ES_status_t *status) +hid_t +H5VL_wrap_register(H5I_type_t type, void *obj, hbool_t app_ref) { - herr_t ret_value = SUCCEED; - - FUNC_ENTER_NOAPI(FAIL) + H5VL_wrap_ctx_t *vol_wrap_ctx = NULL; /* Object wrapping context */ + void *new_obj; /* Newly wrapped object */ + hid_t ret_value = H5I_INVALID_HID; /* Return value */ - HDassert(req); - HDassert(cls); - HDassert(status); - - /* Check if the corresponding VOL callback exists */ - if (NULL == cls->async_cls.test) - HGOTO_ERROR(H5E_VOL, H5E_UNSUPPORTED, FAIL, "VOL driver has no 'async test' method"); - - /* Call the corresponding VOL callback */ - if ((ret_value = (cls->async_cls.test)(req, status)) < 0) - HGOTO_ERROR(H5E_VOL, H5E_CANTRELEASE, FAIL, "request test failed"); - -done: - FUNC_LEAVE_NOAPI(ret_value) -} /* end H5VL_request_test() */ + FUNC_ENTER_NOAPI(H5I_INVALID_HID) - -/*------------------------------------------------------------------------- - * Function: H5VL_request_wait - * - * Purpose: Waits on an asychronous request through the VOL - * - * Return: SUCCEED/FAIL - * - *------------------------------------------------------------------------- - */ -herr_t -H5VL_request_wait(void **req, const H5VL_class_t *cls, H5ES_status_t *status) -{ - herr_t ret_value = SUCCEED; + /* Sanity check */ + HDassert(obj); - FUNC_ENTER_NOAPI(FAIL) + /* If the datatype is already VOL-managed, the datatype's vol_obj + * field will get clobbered later, so disallow this. + */ + if(type == H5I_DATATYPE) + if(TRUE == H5T_already_vol_managed((const H5T_t *)obj)) + HGOTO_ERROR(H5E_VOL, H5E_BADTYPE, H5I_INVALID_HID, "can't wrap an uncommitted datatype") - HDassert(req); - HDassert(cls); - HDassert(status); + /* Wrap the object with VOL connector info */ + if(NULL == (new_obj = H5VL__wrap_obj(obj))) + HGOTO_ERROR(H5E_VOL, H5E_CANTCREATE, H5I_INVALID_HID, "can't wrap library object") - /* Check if the corresponding VOL callback exists */ - if (NULL == cls->async_cls.wait) - HGOTO_ERROR(H5E_VOL, H5E_UNSUPPORTED, FAIL, "VOL driver has no 'async wait' method"); + /* Retrieve the VOL object wrapping context */ + if(H5CX_get_vol_wrap_ctx((void **)&vol_wrap_ctx) < 0) + HGOTO_ERROR(H5E_VOL, H5E_CANTGET, H5I_INVALID_HID, "can't get VOL object wrap context") + if(NULL == vol_wrap_ctx || NULL == vol_wrap_ctx->connector) + HGOTO_ERROR(H5E_VOL, H5E_BADVALUE, H5I_INVALID_HID, "VOL object wrap context or its connector is NULL???") - /* Call the corresponding VOL callback */ - if ((ret_value = (cls->async_cls.wait)(req, status)) < 0) - HGOTO_ERROR(H5E_VOL, H5E_CANTRELEASE, FAIL, "request wait failed"); + /* Get an ID for the object */ + if((ret_value = H5VL_register_using_vol_id(type, new_obj, vol_wrap_ctx->connector->id, app_ref)) < 0) + HGOTO_ERROR(H5E_VOL, H5E_CANTREGISTER, H5I_INVALID_HID, "unable to get an ID for the object") done: FUNC_LEAVE_NOAPI(ret_value) -} /* end H5VL_request_wait() */ +} /* end H5VL_wrap_register() */ diff --git a/src/H5VLnative.c b/src/H5VLnative.c index e71e08e..fe0fd4e 100644 --- a/src/H5VLnative.c +++ b/src/H5VLnative.c @@ -11,228 +11,142 @@ * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ /* - * Purpose: The native VOL driver where access is to a single HDF5 file + * Purpose: The native VOL connector where access is to a single HDF5 file * using HDF5 VFDs. */ -#define H5A_FRIEND /* Suppress error about including H5Apkg */ -#define H5D_FRIEND /* Suppress error about including H5Dpkg */ -#define H5F_FRIEND /* Suppress error about including H5Fpkg */ -#define H5G_FRIEND /* Suppress error about including H5Gpkg */ -#define H5L_FRIEND /* Suppress error about including H5Lpkg */ -#define H5O_FRIEND /* Suppress error about including H5Opkg */ -#define H5R_FRIEND /* Suppress error about including H5Rpkg */ -#define H5T_FRIEND /* Suppress error about including H5Tpkg */ - - #include "H5private.h" /* Generic Functions */ -#include "H5Apkg.h" /* Attributes */ -#include "H5Dpkg.h" /* Datasets */ #include "H5Eprivate.h" /* Error handling */ -#include "H5Fpkg.h" /* Files */ -#include "H5Gpkg.h" /* Groups */ #include "H5Iprivate.h" /* IDs */ -#include "H5Lpkg.h" /* Links */ -#include "H5MFprivate.h" /* File memory management */ -#include "H5MMprivate.h" /* Memory management */ -#include "H5Opkg.h" /* Object headers */ #include "H5Pprivate.h" /* Property lists */ -#include "H5Rpkg.h" /* References */ -#include "H5SMprivate.h" /* Shared Object Header Messages */ -#include "H5Tpkg.h" /* Datatypes */ -#include "H5VLprivate.h" /* VOL drivers */ -#include "H5VLnative_private.h" /* Native VOL driver */ +#include "H5VLprivate.h" /* Virtual Object Layer */ + +#include "H5VLnative_private.h" /* Native VOL connector */ -/* - * The VOL driver identification number. - */ -static hid_t H5VL_NATIVE_ID_g = H5I_INVALID_HID; +/* The VOL connector identification number */ +static hid_t H5VL_NATIVE_ID_g = H5I_INVALID_HID; /* Prototypes */ -static H5F_t *H5VL_native_get_file(void *obj, H5I_type_t type); static herr_t H5VL__native_term(void); -/* Atrribute callbacks */ -static void *H5VL_native_attr_create(void *obj, H5VL_loc_params_t loc_params, const char *attr_name, hid_t acpl_id, hid_t aapl_id, hid_t dxpl_id, void **req); -static void *H5VL_native_attr_open(void *obj, H5VL_loc_params_t loc_params, const char *attr_name, hid_t aapl_id, hid_t dxpl_id, void **req); -static herr_t H5VL_native_attr_read(void *attr, hid_t dtype_id, void *buf, hid_t dxpl_id, void **req); -static herr_t H5VL_native_attr_write(void *attr, hid_t dtype_id, const void *buf, hid_t dxpl_id, void **req); -static herr_t H5VL_native_attr_get(void *obj, H5VL_attr_get_t get_type, hid_t dxpl_id, void **req, va_list arguments); -static herr_t H5VL_native_attr_specific(void *obj, H5VL_loc_params_t loc_params, H5VL_attr_specific_t specific_type, hid_t dxpl_id, void **req, va_list arguments); -static herr_t H5VL_native_attr_close(void *attr, hid_t dxpl_id, void **req); - -/* Dataset callbacks */ -static void *H5VL_native_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_native_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_native_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_native_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_native_dataset_get(void *dset, H5VL_dataset_get_t get_type, hid_t dxpl_id, void **req, va_list arguments); -static herr_t H5VL_native_dataset_specific(void *dset, H5VL_dataset_specific_t specific_type, hid_t dxpl_id, void **req, va_list arguments); -static herr_t H5VL_native_dataset_optional(void *dset, hid_t dxpl_id, void **req, va_list arguments); -static herr_t H5VL_native_dataset_close(void *dset, hid_t dxpl_id, void **req); - -/* File callbacks */ -static void *H5VL_native_file_create(const char *name, unsigned flags, hid_t fcpl_id, hid_t fapl_id, hid_t dxpl_id, void **req); -static void *H5VL_native_file_open(const char *name, unsigned flags, hid_t fapl_id, hid_t dxpl_id, void **req); -static herr_t H5VL_native_file_get(void *file, H5VL_file_get_t get_type, hid_t dxpl_id, void **req, va_list arguments); -static herr_t H5VL_native_file_specific(void *file, H5VL_file_specific_t specific_type, hid_t dxpl_id, void **req, va_list arguments); -static herr_t H5VL_native_file_optional(void *file, hid_t dxpl_id, void **req, va_list arguments); -static herr_t H5VL_native_file_close(void *file, hid_t dxpl_id, void **req); - -/* Group callbacks */ -static void *H5VL_native_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 void *H5VL_native_group_open(void *obj, H5VL_loc_params_t loc_params, const char *name, hid_t gapl_id, hid_t dxpl_id, void **req); -static herr_t H5VL_native_group_get(void *obj, H5VL_group_get_t get_type, hid_t dxpl_id, void **req, va_list arguments); -static herr_t H5VL_native_group_specific(void *dset, H5VL_group_specific_t specific_type, hid_t dxpl_id, void **req, va_list arguments); -static herr_t H5VL_native_group_close(void *grp, hid_t dxpl_id, void **req); - -/* Link callbacks */ -static herr_t H5VL_native_link_create(H5VL_link_create_type_t create_type, void *obj, - H5VL_loc_params_t loc_params, hid_t lcpl_id, hid_t lapl_id, hid_t dxpl_id, void **req); -static herr_t H5VL_native_link_copy(void *src_obj, H5VL_loc_params_t loc_params1, - void *dst_obj, H5VL_loc_params_t loc_params2, - hid_t lcpl_id, hid_t lapl_id, hid_t dxpl_id, void **req); -static herr_t H5VL_native_link_move(void *src_obj, H5VL_loc_params_t loc_params1, - void *dst_obj, H5VL_loc_params_t loc_params2, - hid_t lcpl_id, hid_t lapl_id, hid_t dxpl_id, void **req); -static herr_t H5VL_native_link_get(void *obj, H5VL_loc_params_t loc_params, H5VL_link_get_t get_type, hid_t dxpl_id, void **req, va_list arguments); -static herr_t H5VL_native_link_specific(void *obj, H5VL_loc_params_t loc_params, H5VL_link_specific_t specific_type, hid_t dxpl_id, void **req, va_list arguments); - -/* Object callbacks */ -static void *H5VL_native_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_native_object_copy(void *src_obj, H5VL_loc_params_t loc_params1, const char *src_name, - void *dst_obj, H5VL_loc_params_t loc_params2, const char *dst_name, - hid_t ocpypl_id, hid_t lcpl_id, hid_t dxpl_id, void **req); -static herr_t H5VL_native_object_get(void *obj, H5VL_loc_params_t loc_params, H5VL_object_get_t get_type, hid_t dxpl_id, void **req, va_list arguments); -static herr_t H5VL_native_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); -static herr_t H5VL_native_object_optional(void *obj, hid_t dxpl_id, void **req, va_list arguments); - -/* Datatype callbacks */ -static void *H5VL_native_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_native_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_native_datatype_get(void *dt, H5VL_datatype_get_t get_type, hid_t dxpl_id, void **req, va_list arguments); -static herr_t H5VL_native_datatype_specific(void *dt, H5VL_datatype_specific_t specific_type, hid_t dxpl_id, void **req, va_list arguments); -static herr_t H5VL_native_datatype_close(void *dt, hid_t dxpl_id, void **req); - -/* Native VOL driver class struct */ +/* Native VOL connector class struct */ static H5VL_class_t H5VL_native_cls_g = { H5VL_NATIVE_VERSION, /* version */ H5VL_NATIVE_VALUE, /* value */ H5VL_NATIVE_NAME, /* name */ + 0, /* capability flags */ NULL, /* initialize */ - NULL, /* terminate */ - (size_t)0, /* fapl size */ - NULL, /* fapl copy */ - NULL, /* fapl free */ + H5VL__native_term, /* terminate */ + (size_t)0, /* info size */ + NULL, /* info copy */ + NULL, /* info compare */ + NULL, /* info free */ + NULL, /* info to str */ + NULL, /* str to info */ + NULL, /* get_object */ + NULL, /* get_wrap_ctx */ + NULL, /* wrap_object */ + NULL, /* free_wrap_ctx */ { /* attribute_cls */ - H5VL_native_attr_create, /* create */ - H5VL_native_attr_open, /* open */ - H5VL_native_attr_read, /* read */ - H5VL_native_attr_write, /* write */ - H5VL_native_attr_get, /* get */ - H5VL_native_attr_specific, /* specific */ - NULL, /* optional */ - H5VL_native_attr_close /* close */ + H5VL__native_attr_create, /* create */ + H5VL__native_attr_open, /* open */ + H5VL__native_attr_read, /* read */ + H5VL__native_attr_write, /* write */ + H5VL__native_attr_get, /* get */ + H5VL__native_attr_specific, /* specific */ + H5VL__native_attr_optional, /* optional */ + H5VL__native_attr_close /* close */ }, { /* dataset_cls */ - H5VL_native_dataset_create, /* create */ - H5VL_native_dataset_open, /* open */ - H5VL_native_dataset_read, /* read */ - H5VL_native_dataset_write, /* write */ - H5VL_native_dataset_get, /* get */ - H5VL_native_dataset_specific, /* specific */ - H5VL_native_dataset_optional, /* optional */ - H5VL_native_dataset_close /* close */ + H5VL__native_dataset_create, /* create */ + H5VL__native_dataset_open, /* open */ + H5VL__native_dataset_read, /* read */ + H5VL__native_dataset_write, /* write */ + H5VL__native_dataset_get, /* get */ + H5VL__native_dataset_specific, /* specific */ + H5VL__native_dataset_optional, /* optional */ + H5VL__native_dataset_close /* close */ }, { /* datatype_cls */ - H5VL_native_datatype_commit, /* commit */ - H5VL_native_datatype_open, /* open */ - H5VL_native_datatype_get, /* get */ - H5VL_native_datatype_specific, /* specific */ + H5VL__native_datatype_commit, /* commit */ + H5VL__native_datatype_open, /* open */ + H5VL__native_datatype_get, /* get */ + H5VL__native_datatype_specific, /* specific */ NULL, /* optional */ - H5VL_native_datatype_close /* close */ + H5VL__native_datatype_close /* close */ }, { /* file_cls */ - H5VL_native_file_create, /* create */ - H5VL_native_file_open, /* open */ - H5VL_native_file_get, /* get */ - H5VL_native_file_specific, /* specific */ - H5VL_native_file_optional, /* optional */ - H5VL_native_file_close /* close */ + H5VL__native_file_create, /* create */ + H5VL__native_file_open, /* open */ + H5VL__native_file_get, /* get */ + H5VL__native_file_specific, /* specific */ + H5VL__native_file_optional, /* optional */ + H5VL__native_file_close /* close */ }, { /* group_cls */ - H5VL_native_group_create, /* create */ - H5VL_native_group_open, /* open */ - H5VL_native_group_get, /* get */ - H5VL_native_group_specific, /* specific */ - NULL, /* optional */ - H5VL_native_group_close /* close */ + H5VL__native_group_create, /* create */ + H5VL__native_group_open, /* open */ + H5VL__native_group_get, /* get */ + H5VL__native_group_specific, /* specific */ + H5VL__native_group_optional, /* optional */ + H5VL__native_group_close /* close */ }, { /* link_cls */ - H5VL_native_link_create, /* create */ - H5VL_native_link_copy, /* copy */ - H5VL_native_link_move, /* move */ - H5VL_native_link_get, /* get */ - H5VL_native_link_specific, /* specific */ + H5VL__native_link_create, /* create */ + H5VL__native_link_copy, /* copy */ + H5VL__native_link_move, /* move */ + H5VL__native_link_get, /* get */ + H5VL__native_link_specific, /* specific */ NULL /* optional */ }, { /* object_cls */ - H5VL_native_object_open, /* open */ - H5VL_native_object_copy, /* copy */ - H5VL_native_object_get, /* get */ - H5VL_native_object_specific, /* specific */ - H5VL_native_object_optional /* optional */ + H5VL__native_object_open, /* open */ + H5VL__native_object_copy, /* copy */ + H5VL__native_object_get, /* get */ + H5VL__native_object_specific, /* specific */ + H5VL__native_object_optional /* optional */ }, - { /* async_cls */ + { /* request_cls */ + NULL, /* wait */ + NULL, /* notify */ NULL, /* cancel */ - NULL, /* test */ - NULL /* wait */ + NULL, /* specific */ + NULL, /* optional */ + NULL /* free */ }, NULL /* optional */ }; /*------------------------------------------------------------------------- - * Function: H5VL_native_init + * Function: H5VL_native_register * - * Purpose: Initialize this VOL driver by registering it with the - * library. + * Purpose: Register the native VOL connector and retrieve an ID for it. * - * Return: Success: The ID for the native driver + * Return: Success: The ID for the native connector * Failure: H5I_INVALID_HID * *------------------------------------------------------------------------- */ hid_t -H5VL_native_init(void) +H5VL_native_register(void) { hid_t ret_value = H5I_INVALID_HID; /* Return value */ FUNC_ENTER_NOAPI(H5I_INVALID_HID) - /* Register the native VOL driver, if it isn't already */ - if(NULL == H5I_object_verify(H5VL_NATIVE_ID_g, H5I_VOL)) { - if((H5VL_NATIVE_ID_g = H5VL_register_driver((const H5VL_class_t *)&H5VL_native_cls_g, - sizeof(H5VL_class_t), TRUE)) < 0) - HGOTO_ERROR(H5E_ATOM, H5E_CANTINSERT, H5I_INVALID_HID, "can't create ID for native VOL driver") - } + /* Register the native VOL connector, if it isn't already */ + if(NULL == H5I_object_verify(H5VL_NATIVE_ID_g, H5I_VOL)) + if((H5VL_NATIVE_ID_g = H5VL_register_connector((const H5VL_class_t *)&H5VL_native_cls_g, TRUE, H5P_DEFAULT)) < 0) + HGOTO_ERROR(H5E_VOL, H5E_CANTINSERT, H5I_INVALID_HID, "can't create ID for native VOL connector") /* Set return value */ ret_value = H5VL_NATIVE_ID_g; done: FUNC_LEAVE_NOAPI(ret_value) -} /* end H5VL_native_init() */ - -/* XXX (VOL_MERGE): TEMPORARY */ -hid_t -H5VL_native_get_driver_id(void) -{ - return H5VL_NATIVE_ID_g; -} +} /* end H5VL_native_register() */ /*--------------------------------------------------------------------------- @@ -249,3285 +163,9 @@ H5VL__native_term(void) { FUNC_ENTER_STATIC_NOERR - /* Reset VFL ID */ + /* Reset VOL ID */ H5VL_NATIVE_ID_g = H5I_INVALID_HID; FUNC_LEAVE_NOAPI(SUCCEED) } /* end H5VL__native_term() */ - -/*------------------------------------------------------------------------- - * Function: H5Pset_fapl_native - * - * Purpose: Modify the file access property list to use the H5VL_NATIVE - * driver defined in this source file. - * - * Return: SUCCEED/FAIL - * - *------------------------------------------------------------------------- - */ -herr_t -H5Pset_fapl_native(hid_t fapl_id) -{ - H5P_genplist_t *plist; /* Property list pointer */ - herr_t ret_value; - - FUNC_ENTER_API(FAIL) - H5TRACE1("e", "i", fapl_id); - - if(NULL == (plist = H5P_object_verify(fapl_id, H5P_FILE_ACCESS))) - HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a file access property list") - - ret_value = H5P_set_vol(plist, H5VL_NATIVE_ID_g, NULL); - -done: - FUNC_LEAVE_API(ret_value) -} /* end H5Pset_fapl_native() */ - - -/*--------------------------------------------------------------------------- - * Function: H5VL_native_get_file - * - * Purpose: Utility routine to get file struct for an object via the - * native VOL driver. - * - * Returns: SUCCESS: A pointer to the H5F_t struct for the file - * associated with the object. - * FAILURE: NULL - * - *--------------------------------------------------------------------------- - */ -static H5F_t * -H5VL_native_get_file(void *obj, H5I_type_t type) -{ - H5F_t *ret_value = NULL; /* File pointer */ - H5O_loc_t *oloc = NULL; /* Object location for ID */ - - FUNC_ENTER_NOAPI_NOINIT - - switch(type) { - case H5I_FILE: - ret_value = (H5F_t *)obj; - break; - case H5I_GROUP: - { - H5G_t *grp; - grp = (H5G_t *)obj; - oloc = H5G_oloc(grp); - break; - } - case H5I_DATATYPE: - { - H5T_t *dt; - dt = (H5T_t *)obj; - oloc = H5T_oloc(dt); - break; - } - case H5I_DATASET: - { - H5D_t *dset; - dset = (H5D_t *)obj; - oloc = H5D_oloc(dset); - break; - } - - case H5I_ATTR: - { - H5A_t *attr; - attr = (H5A_t *)obj; - oloc = H5A_oloc(attr); - break; - } - case H5I_UNINIT: - case H5I_BADID: - case H5I_DATASPACE: - case H5I_REFERENCE: - case H5I_VFL: - case H5I_VOL: - case H5I_GENPROP_CLS: - case H5I_GENPROP_LST: - case H5I_ERROR_CLASS: - case H5I_ERROR_MSG: - case H5I_ERROR_STACK: - case H5I_NTYPES: - default: - HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, NULL, "not a file or file object") - } - - if(!ret_value) { - if (!oloc) - HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, NULL, "object is not assocated with a file") - ret_value = oloc->file; - } - if(!ret_value) - HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, NULL, "object is not associated with a file") - -done: - FUNC_LEAVE_NOAPI(ret_value) -} /* H5VL_native_get_file */ - - -/*--------------------------------------------------------------------------- - * Function: H5VL_native_register - * - * Purpose: Utility routine to register an ID with the native VOL driver - * as an auxilary object. - * - * Returns: Success: An ID for the object - * Failure: H5I_INVALID_HID - * - *--------------------------------------------------------------------------- - */ -hid_t -H5VL_native_register(H5I_type_t type, const void *obj, hbool_t app_ref) -{ - hid_t ret_value = H5I_INVALID_HID; - - FUNC_ENTER_NOAPI_NOINIT - - HDassert(obj); - - /* If the datatype is already VOL-managed, the datatype's vol_obj - * field will get clobbered later, so disallow this. - */ - if(type == H5I_DATATYPE) - if(((H5T_t *)obj)->vol_obj != NULL) - HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, H5I_INVALID_HID, "can only get an ID for an uncommitted datatype") - - /* Get an ID for the object */ - if((ret_value = H5VL_register_using_vol_id(type, obj, H5VL_NATIVE_ID_g, app_ref)) < 0) - HGOTO_ERROR(H5E_ATOM, H5E_CANTREGISTER, H5I_INVALID_HID, "unable to get an ID for the object") - -done: - FUNC_LEAVE_NOAPI(ret_value) -} /* end H5VL_native_register() */ - - -/*--------------------------------------------------------------------------- - * Function: H5VL_native_unregister - * - * Purpose: Utility routine to decrement ref count on Native VOL driver - * objects. - * - * Returns: SUCCEED/FAIL - * - *--------------------------------------------------------------------------- - */ -herr_t -H5VL_native_unregister(hid_t obj_id) -{ - H5VL_object_t *vol_obj = NULL; - herr_t ret_value = SUCCEED; - - FUNC_ENTER_NOAPI_NOINIT - - /* get the driver pointer */ - if(NULL == (vol_obj = (H5VL_object_t *)H5VL_vol_object(obj_id))) - HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "invalid ID") - - /* free object */ - if(H5VL_free_object(vol_obj) < 0) - HGOTO_ERROR(H5E_FILE, H5E_CANTDEC, FAIL, "unable to free VOL object") - -done: - FUNC_LEAVE_NOAPI(ret_value) -} /* end H5VL_native_unregister() */ - - -/*------------------------------------------------------------------------- - * Function: H5VL_native_attr_create - * - * Purpose: Creates an attribute on an object. - * - * Return: Success: attr id. - * Failure: NULL - * - *------------------------------------------------------------------------- - */ -static void * -H5VL_native_attr_create(void *obj, H5VL_loc_params_t loc_params, const char *attr_name, hid_t acpl_id, - hid_t H5_ATTR_UNUSED aapl_id, hid_t H5_ATTR_UNUSED dxpl_id, void H5_ATTR_UNUSED **req) -{ - H5G_loc_t loc; /* Object location */ - H5G_loc_t obj_loc; /* Location used to open group */ - hbool_t loc_found = FALSE; - H5P_genplist_t *plist; /* Property list pointer */ - hid_t type_id, space_id; - H5T_t *type, *dt; /* Datatype to use for attribute */ - H5S_t *space; /* Dataspace to use for attribute */ - H5A_t *attr = NULL; - void *ret_value = NULL; - - FUNC_ENTER_NOAPI_NOINIT - - /* Get the plist structure */ - if(NULL == (plist = (H5P_genplist_t *)H5I_object(acpl_id))) - HGOTO_ERROR(H5E_ATOM, H5E_BADATOM, NULL, "can't find object for ID") - - /* get creation properties */ - if(H5P_get(plist, H5VL_PROP_ATTR_TYPE_ID, &type_id) < 0) - HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, NULL, "can't get property value for datatype id") - if(H5P_get(plist, H5VL_PROP_ATTR_SPACE_ID, &space_id) < 0) - HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, NULL, "can't get property value for space id") - - if(H5G_loc_real(obj, loc_params.obj_type, &loc) < 0) - HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, NULL, "not a file or file object") - if(0 == (H5F_INTENT(loc.oloc->file) & H5F_ACC_RDWR)) - HGOTO_ERROR(H5E_ARGS, H5E_WRITEERROR, NULL, "no write intent on file") - - if(NULL == (dt = (H5T_t *)H5I_object_verify(type_id, H5I_DATATYPE))) - HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, NULL, "not a datatype") - /* If this is a named datatype, get the driver pointer to the datatype */ - type = H5T_get_actual_type(dt); - - if(NULL == (space = (H5S_t *)H5I_object_verify(space_id, H5I_DATASPACE))) - HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, NULL, "not a data space") - - if(loc_params.type == H5VL_OBJECT_BY_SELF) { - /* H5Acreate */ - /* Go do the real work for attaching the attribute to the dataset */ - if(NULL == (attr = H5A__create(&loc, attr_name, type, space, acpl_id))) - HGOTO_ERROR(H5E_ATTR, H5E_CANTINIT, NULL, "unable to create attribute") - } - else if(loc_params.type == H5VL_OBJECT_BY_NAME) { - /* H5Acreate_by_name */ - if(NULL == (attr = H5A__create_by_name(&loc, loc_params.loc_data.loc_by_name.name, attr_name, type, space, acpl_id))) - HGOTO_ERROR(H5E_ATTR, H5E_CANTINIT, NULL, "unable to create attribute") - } - else { - HGOTO_ERROR(H5E_VOL, H5E_UNSUPPORTED, NULL, "unknown attribute create parameters") - } - ret_value = (void *)attr; - -done: - /* Release resources */ - if(loc_found && H5G_loc_free(&obj_loc) < 0) - HDONE_ERROR(H5E_ATTR, H5E_CANTRELEASE, NULL, "can't free location") - FUNC_LEAVE_NOAPI(ret_value) -} /* end H5VL_native_attr_create() */ - - -/*------------------------------------------------------------------------- - * Function: H5VL_native_attr_open - * - * Purpose: Opens a attr inside a native h5 file. - * - * Return: Success: attr id. - * Failure: NULL - * - * Programmer: Mohamad Chaarawi - * March, 2012 - * - *------------------------------------------------------------------------- - */ -static void * -H5VL_native_attr_open(void *obj, H5VL_loc_params_t loc_params, const char *attr_name, - hid_t H5_ATTR_UNUSED aapl_id, hid_t H5_ATTR_UNUSED dxpl_id, void H5_ATTR_UNUSED **req) -{ - H5G_loc_t loc; /* Object location */ - H5A_t *attr = NULL; /* Attribute opened */ - void *ret_value; - - FUNC_ENTER_NOAPI_NOINIT - - /* check arguments */ - if(H5G_loc_real(obj, loc_params.obj_type, &loc) < 0) - HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, NULL, "not a file or file object") - - if(loc_params.type == H5VL_OBJECT_BY_SELF) { - /* H5Aopen */ - /* Open the attribute */ - if(NULL == (attr = H5A__open(&loc, attr_name))) - HGOTO_ERROR(H5E_ATTR, H5E_CANTOPENOBJ, NULL, "unable to open attribute: '%s'", attr_name) - } - else if(loc_params.type == H5VL_OBJECT_BY_NAME) { - /* H5Aopen_by_name */ - /* Open the attribute on the object header */ - if(NULL == (attr = H5A__open_by_name(&loc, loc_params.loc_data.loc_by_name.name, attr_name))) - HGOTO_ERROR(H5E_ATTR, H5E_CANTOPENOBJ, NULL, "can't open attribute") - } - else if(loc_params.type == H5VL_OBJECT_BY_IDX) { - /* H5Aopen_by_idx */ - /* Open the attribute in the object header */ - if(NULL == (attr = H5A__open_by_idx(&loc, loc_params.loc_data.loc_by_idx.name, - loc_params.loc_data.loc_by_idx.idx_type, - loc_params.loc_data.loc_by_idx.order, - loc_params.loc_data.loc_by_idx.n))) - HGOTO_ERROR(H5E_ATTR, H5E_CANTOPENOBJ, NULL, "unable to open attribute") - } - else { - HGOTO_ERROR(H5E_VOL, H5E_UNSUPPORTED, NULL, "unknown attribute open parameters") - } - - ret_value = (void *)attr; - -done: - FUNC_LEAVE_NOAPI(ret_value) -} /* end H5VL_native_attr_open() */ - - -/*------------------------------------------------------------------------- - * Function: H5VL_native_attr_read - * - * Purpose: Reads in data from attribute. - * - * Non-negative on success/Negative on failure - * - * Programmer: Mohamad Chaarawi - * March, 2012 - * - *------------------------------------------------------------------------- - */ -static herr_t -H5VL_native_attr_read(void *attr, hid_t dtype_id, void *buf, hid_t H5_ATTR_UNUSED dxpl_id, void H5_ATTR_UNUSED **req) -{ - H5T_t *mem_type; /* Memory datatype */ - herr_t ret_value; /* Return value */ - - FUNC_ENTER_NOAPI_NOINIT - - if(NULL == (mem_type = (H5T_t *)H5I_object_verify(dtype_id, H5I_DATATYPE))) - HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a datatype") - /* Go write the actual data to the attribute */ - if((ret_value = H5A__read((H5A_t*)attr, mem_type, buf)) < 0) - HGOTO_ERROR(H5E_ATTR, H5E_READERROR, FAIL, "unable to read attribute") - -done: - FUNC_LEAVE_NOAPI(ret_value) -} /* end H5VL_native_attr_read() */ - - -/*------------------------------------------------------------------------- - * Function: H5VL_native_attr_write - * - * Purpose: Writes out data to attribute. - * - * Non-negative on success/Negative on failure - * - * Programmer: Mohamad Chaarawi - * March, 2012 - * - *------------------------------------------------------------------------- - */ -static herr_t -H5VL_native_attr_write(void *attr, hid_t dtype_id, const void *buf, hid_t H5_ATTR_UNUSED dxpl_id, void H5_ATTR_UNUSED **req) -{ - H5T_t *mem_type; /* Memory datatype */ - herr_t ret_value; /* Return value */ - - FUNC_ENTER_NOAPI_NOINIT - - if(NULL == (mem_type = (H5T_t *)H5I_object_verify(dtype_id, H5I_DATATYPE))) - HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a datatype") - /* Go write the actual data to the attribute */ - if((ret_value = H5A__write((H5A_t*)attr, mem_type, buf)) < 0) - HGOTO_ERROR(H5E_ATTR, H5E_WRITEERROR, FAIL, "unable to write attribute") - -done: - FUNC_LEAVE_NOAPI(ret_value) -} /* end H5VL_native_attr_write() */ - - -/*------------------------------------------------------------------------- - * Function: H5VL_native_attr_get - * - * Purpose: Gets certain information about an attribute - * - * Return: Success: 0 - * Failure: -1 - * - * Programmer: Mohamad Chaarawi - * March, 2012 - * - *------------------------------------------------------------------------- - */ -static herr_t -H5VL_native_attr_get(void *obj, H5VL_attr_get_t get_type, hid_t H5_ATTR_UNUSED dxpl_id, void H5_ATTR_UNUSED **req, va_list arguments) -{ - herr_t ret_value = SUCCEED; /* Return value */ - - FUNC_ENTER_NOAPI_NOINIT - - switch(get_type) { - /* H5Aget_space */ - case H5VL_ATTR_GET_SPACE: - { - hid_t *ret_id = va_arg(arguments, hid_t *); - H5A_t *attr = (H5A_t *)obj; - - if((*ret_id = H5A_get_space(attr)) < 0) - HGOTO_ERROR(H5E_ARGS, H5E_CANTGET, FAIL, "can't get space ID of attribute") - break; - } - /* H5Aget_type */ - case H5VL_ATTR_GET_TYPE: - { - hid_t *ret_id = va_arg(arguments, hid_t *); - H5A_t *attr = (H5A_t *)obj; - - if((*ret_id = H5A__get_type(attr)) < 0) - HGOTO_ERROR(H5E_ARGS, H5E_CANTGET, FAIL, "can't get datatype ID of attribute") - break; - } - /* H5Aget_create_plist */ - case H5VL_ATTR_GET_ACPL: - { - hid_t *ret_id = va_arg(arguments, hid_t *); - H5A_t *attr = (H5A_t *)obj; - - if((*ret_id = H5A__get_create_plist(attr)) < 0) - HGOTO_ERROR(H5E_ARGS, H5E_CANTGET, FAIL, "can't get creation property list for attr") - - break; - } - /* H5Aget_name */ - case H5VL_ATTR_GET_NAME: - { - H5VL_loc_params_t loc_params = va_arg(arguments, H5VL_loc_params_t); - size_t buf_size = va_arg(arguments, size_t); - char *buf = va_arg(arguments, char *); - ssize_t *ret_val = va_arg(arguments, ssize_t *); - H5A_t *attr = NULL; - - if(H5VL_OBJECT_BY_SELF == loc_params.type) { - attr = (H5A_t *)obj; - /* Call private function in turn */ - if(0 > (*ret_val = H5A__get_name(attr, buf_size, buf))) - HGOTO_ERROR(H5E_ATTR, H5E_CANTGET, FAIL, "can't get attribute name") - } - else if(H5VL_OBJECT_BY_IDX == loc_params.type) { - H5G_loc_t loc; - - /* check arguments */ - if(H5G_loc_real(obj, loc_params.obj_type, &loc) < 0) - HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a file or file object") - - /* Open the attribute on the object header */ - if(NULL == (attr = H5A__open_by_idx(&loc, loc_params.loc_data.loc_by_idx.name, - loc_params.loc_data.loc_by_idx.idx_type, - loc_params.loc_data.loc_by_idx.order, - loc_params.loc_data.loc_by_idx.n))) - HGOTO_ERROR(H5E_ATTR, H5E_CANTOPENOBJ, FAIL, "can't open attribute") - - /* Get the length of the name */ - *ret_val = (ssize_t)HDstrlen(attr->shared->name); - - /* Copy the name into the user's buffer, if given */ - if(buf) { - HDstrncpy(buf, attr->shared->name, MIN((size_t)(*ret_val + 1), buf_size)); - if((size_t)(*ret_val) >= buf_size) - buf[buf_size - 1]='\0'; - } /* end if */ - - /* Release resources */ - if(attr && H5A__close(attr) < 0) - HDONE_ERROR(H5E_ATTR, H5E_CANTFREE, FAIL, "can't close attribute") - } - else - HGOTO_ERROR(H5E_SYM, H5E_CANTGET, FAIL, "can't get name of attr") - - break; - } - /* H5Aget_info */ - case H5VL_ATTR_GET_INFO: - { - H5VL_loc_params_t loc_params = va_arg(arguments, H5VL_loc_params_t); - H5A_info_t *ainfo = va_arg(arguments, H5A_info_t *); - H5A_t *attr = NULL; - - if(H5VL_OBJECT_BY_SELF == loc_params.type) { - attr = (H5A_t *)obj; - if(H5A__get_info(attr, ainfo) < 0) - HGOTO_ERROR(H5E_ARGS, H5E_CANTGET, FAIL, "can't get attribute info") - } - else if(H5VL_OBJECT_BY_NAME == loc_params.type) { - char *attr_name = va_arg(arguments, char *); - H5G_loc_t loc; - - /* check arguments */ - if(H5G_loc_real(obj, loc_params.obj_type, &loc) < 0) - HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a file or file object") - - /* Open the attribute on the object header */ - if(NULL == (attr = H5A__open_by_name(&loc, loc_params.loc_data.loc_by_name.name, - attr_name))) - HGOTO_ERROR(H5E_ATTR, H5E_CANTOPENOBJ, FAIL, "can't open attribute") - - /* Get the attribute information */ - if(H5A__get_info(attr, ainfo) < 0) - HGOTO_ERROR(H5E_ATTR, H5E_CANTGET, FAIL, "unable to get attribute info") - - /* Release resources */ - if(attr && H5A__close(attr) < 0) - HDONE_ERROR(H5E_ATTR, H5E_CANTFREE, FAIL, "can't close attribute") - } - else if(H5VL_OBJECT_BY_IDX == loc_params.type) { - H5G_loc_t loc; - - /* check arguments */ - if(H5G_loc_real(obj, loc_params.obj_type, &loc) < 0) - HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a file or file object") - - /* Open the attribute on the object header */ - if(NULL == (attr = H5A__open_by_idx(&loc, loc_params.loc_data.loc_by_idx.name, - loc_params.loc_data.loc_by_idx.idx_type, - loc_params.loc_data.loc_by_idx.order, - loc_params.loc_data.loc_by_idx.n))) - HGOTO_ERROR(H5E_ATTR, H5E_CANTOPENOBJ, FAIL, "can't open attribute") - - /* Get the attribute information */ - if(H5A__get_info(attr, ainfo) < 0) - HGOTO_ERROR(H5E_ATTR, H5E_CANTGET, FAIL, "unable to get attribute info") - - /* Release resources */ - if(attr && H5A__close(attr) < 0) - HDONE_ERROR(H5E_ATTR, H5E_CANTFREE, FAIL, "can't close attribute") - } - else - HGOTO_ERROR(H5E_SYM, H5E_CANTGET, FAIL, "can't get name of attr") - - break; - } - case H5VL_ATTR_GET_STORAGE_SIZE: - { - hsize_t *ret = va_arg(arguments, hsize_t *); - H5A_t *attr = (H5A_t *)obj; - - /* Set return value */ - *ret = attr->shared->data_size; - break; - } - default: - HGOTO_ERROR(H5E_VOL, H5E_CANTGET, FAIL, "can't get this type of information from attr") - } - -done: - FUNC_LEAVE_NOAPI(ret_value) -} /* end H5VL_native_attr_get() */ - - -/*------------------------------------------------------------------------- - * Function: H5VL_native_attr_specific - * - * Purpose: Specific operations for attributes - * - * Return: Success: 0 - * Failure: -1 - * - * Programmer: Mohamad Chaarawi - * August, 2014 - * - *------------------------------------------------------------------------- - */ -static herr_t -H5VL_native_attr_specific(void *obj, H5VL_loc_params_t loc_params, H5VL_attr_specific_t specific_type, - hid_t H5_ATTR_UNUSED dxpl_id, void H5_ATTR_UNUSED **req, va_list arguments) -{ - H5G_loc_t loc; - herr_t ret_value = SUCCEED; /* Return value */ - - FUNC_ENTER_NOAPI_NOINIT - - /* Get location for passed-in object */ - if(H5G_loc_real(obj, loc_params.obj_type, &loc) < 0) - HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a file or file object") - /* XXX: Do I need to clean this up? */ - - switch(specific_type) { - case H5VL_ATTR_DELETE: - { - char *attr_name = va_arg(arguments, char *); - - if(H5VL_OBJECT_BY_SELF == loc_params.type) { - /* H5Adelete */ - /* Delete the attribute from the location */ - if(H5O__attr_remove(loc.oloc, attr_name) < 0) - HGOTO_ERROR(H5E_ATTR, H5E_CANTDELETE, FAIL, "unable to delete attribute") - } - else if(H5VL_OBJECT_BY_NAME == loc_params.type) { - /* H5Adelete_by_name */ - /* Delete the attribute */ - if(H5A__delete_by_name(&loc, loc_params.loc_data.loc_by_name.name, attr_name) < 0) - HGOTO_ERROR(H5E_ATTR, H5E_CANTDELETE, FAIL, "unable to delete attribute") - } - else if(H5VL_OBJECT_BY_IDX == loc_params.type) { - /* H5Adelete_by_idx */ - /* Delete the attribute from the location */ - if(H5A__delete_by_idx(&loc, loc_params.loc_data.loc_by_idx.name, loc_params.loc_data.loc_by_idx.idx_type, - loc_params.loc_data.loc_by_idx.order, loc_params.loc_data.loc_by_idx.n) < 0) - HGOTO_ERROR(H5E_ATTR, H5E_CANTDELETE, FAIL, "unable to delete attribute") - } - else - HGOTO_ERROR(H5E_VOL, H5E_UNSUPPORTED, FAIL, "unknown attribute remove parameters") - break; - } - case H5VL_ATTR_EXISTS: - { - const char *attr_name = va_arg(arguments, const char *); - htri_t *ret = va_arg(arguments, htri_t *); - - if(loc_params.type == H5VL_OBJECT_BY_SELF) { /* H5Aexists */ - /* Check if the attribute exists */ - if((*ret = H5O__attr_exists(loc.oloc, attr_name)) < 0) - HGOTO_ERROR(H5E_ATTR, H5E_CANTGET, FAIL, "unable to determine if attribute exists") - } - else if(loc_params.type == H5VL_OBJECT_BY_NAME) { /* H5Aexists_by_name */ - /* Check if the attribute exists */ - if((*ret = H5A__exists_by_name(loc, loc_params.loc_data.loc_by_name.name, attr_name)) < 0) - HGOTO_ERROR(H5E_ATTR, H5E_CANTGET, FAIL, "unable to determine if attribute exists") - } - else - HGOTO_ERROR(H5E_VOL, H5E_UNSUPPORTED, FAIL, "unknown parameters") - break; - } - case H5VL_ATTR_ITER: - { - H5_index_t idx_type = va_arg(arguments, H5_index_t); - H5_iter_order_t order = va_arg(arguments, H5_iter_order_t); - hsize_t *idx = va_arg(arguments, hsize_t *); - H5A_operator2_t op = va_arg(arguments, H5A_operator2_t); - void *op_data = va_arg(arguments, void *); - - if(loc_params.type == H5VL_OBJECT_BY_SELF) { /* H5Aiterate2 */ - - /* Iterate over attributes */ - if((ret_value = H5A__iterate(&loc, ".", idx_type, order, idx, op, op_data)) < 0) - HGOTO_ERROR(H5E_ATTR, H5E_BADITER, FAIL, "error iterating over attributes") - } - else if(loc_params.type == H5VL_OBJECT_BY_NAME) { /* H5Aiterate_by_name */ - - /* Iterate over attributes by name */ - if((ret_value = H5A__iterate(&loc, loc_params.loc_data.loc_by_name.name, idx_type, order, idx, op, op_data)) < 0) - HGOTO_ERROR(H5E_ATTR, H5E_BADITER, FAIL, "attribute iteration failed"); - } - else - HGOTO_ERROR(H5E_VOL, H5E_UNSUPPORTED, FAIL, "unknown parameters") - break; - } - /* H5Arename/rename_by_name */ - case H5VL_ATTR_RENAME: - { - const char *old_name = va_arg(arguments, const char *); - const char *new_name = va_arg(arguments, const char *); - - if(loc_params.type == H5VL_OBJECT_BY_SELF) { /* H5Arename */ - /* Call attribute rename routine */ - if(H5O__attr_rename(loc.oloc, old_name, new_name) < 0) - HGOTO_ERROR(H5E_ATTR, H5E_CANTRENAME, FAIL, "can't rename attribute") - } - else if(loc_params.type == H5VL_OBJECT_BY_NAME) { /* H5Arename_by_name */ - /* Call attribute rename routine */ - if(H5A__rename_by_name(loc, loc_params.loc_data.loc_by_name.name, old_name, new_name) < 0) - HGOTO_ERROR(H5E_ATTR, H5E_CANTRENAME, FAIL, "can't rename attribute") - } - else - HGOTO_ERROR(H5E_VOL, H5E_UNSUPPORTED, FAIL, "unknown attribute rename parameters") - break; - } - default: - HGOTO_ERROR(H5E_VOL, H5E_UNSUPPORTED, FAIL, "invalid specific operation") - } -done: - FUNC_LEAVE_NOAPI(ret_value) -} /* end H5VL_native_attr_specific() */ - - -/*------------------------------------------------------------------------- - * Function: H5VL_native_attr_close - * - * Purpose: Closes an attribute. - * - * Return: Success: 0 - * Failure: -1, attr not closed. - * - * Programmer: Mohamad Chaarawi - * March, 2012 - * - *------------------------------------------------------------------------- - */ -static herr_t -H5VL_native_attr_close(void *attr, hid_t H5_ATTR_UNUSED dxpl_id, void H5_ATTR_UNUSED **req) -{ - herr_t ret_value = SUCCEED; /* Return value */ - - FUNC_ENTER_NOAPI_NOINIT - - if(H5A__close((H5A_t*)attr) < 0) - HGOTO_ERROR(H5E_SYM, H5E_CANTDEC, FAIL, "can't close attribute") - -done: - FUNC_LEAVE_NOAPI(ret_value) -} /* end H5VL_native_attr_close() */ - - -/*------------------------------------------------------------------------- - * Function: H5VL_native_dataset_create - * - * Purpose: Creates a dataset in a native HDF5 file - * - * Return: Success: Pointer to a dataset struct - * Failure: NULL - * - *------------------------------------------------------------------------- - */ -static void * -H5VL_native_dataset_create(void *obj, H5VL_loc_params_t loc_params, const char *name, hid_t dcpl_id, - hid_t dapl_id, hid_t H5_ATTR_UNUSED dxpl_id, void H5_ATTR_UNUSED **req) -{ - H5P_genplist_t *plist; /* Property list pointer */ - H5G_loc_t loc; /* Object location to insert dataset into */ - hid_t type_id = H5I_INVALID_HID; - hid_t space_id = H5I_INVALID_HID; - hid_t lcpl_id = H5I_INVALID_HID; - H5D_t *dset = NULL; /* New dataset's info */ - const H5S_t *space; /* Dataspace for dataset */ - void *ret_value; - - FUNC_ENTER_NOAPI_NOINIT - - /* Get the plist structure */ - if(NULL == (plist = (H5P_genplist_t *)H5I_object(dcpl_id))) - HGOTO_ERROR(H5E_ATOM, H5E_BADATOM, NULL, "can't find object for ID") - - /* Get creation properties */ - if(H5P_get(plist, H5VL_PROP_DSET_TYPE_ID, &type_id) < 0) - HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, NULL, "can't get property value for datatype id") - if(H5P_get(plist, H5VL_PROP_DSET_SPACE_ID, &space_id) < 0) - HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, NULL, "can't get property value for space id") - if(H5P_get(plist, H5VL_PROP_DSET_LCPL_ID, &lcpl_id) < 0) - HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, NULL, "can't get property value for lcpl id") - - /* Check arguments */ - if(H5G_loc_real(obj, loc_params.obj_type, &loc) < 0) - HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, NULL, "not a file or file object") - if(H5I_DATATYPE != H5I_get_type(type_id)) - HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, NULL, "not a datatype ID") - if(NULL == (space = (const H5S_t *)H5I_object_verify(space_id, H5I_DATASPACE))) - HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, NULL, "not a dataspace ID") - - /* H5Dcreate_anon */ - if(NULL == name) { - /* build and open the new dataset */ - if(NULL == (dset = H5D__create(loc.oloc->file, type_id, space, dcpl_id, dapl_id))) - HGOTO_ERROR(H5E_DATASET, H5E_CANTINIT, NULL, "unable to create dataset") - } - /* H5Dcreate2 */ - else { - /* Create the new dataset & get its ID */ - if(NULL == (dset = H5D__create_named(&loc, name, type_id, space, lcpl_id, - dcpl_id, dapl_id))) - HGOTO_ERROR(H5E_DATASET, H5E_CANTINIT, NULL, "unable to create dataset") - } - ret_value = (void *)dset; - -done: - if(NULL == name) { - /* Release the dataset's object header, if it was created */ - if(dset) { - H5O_loc_t *oloc; /* Object location for dataset */ - - /* Get the new dataset's object location */ - if(NULL == (oloc = H5D_oloc(dset))) - HDONE_ERROR(H5E_DATASET, H5E_CANTGET, NULL, "unable to get object location of dataset") - - /* Decrement refcount on dataset's object header in memory */ - if(H5O_dec_rc_by_loc(oloc) < 0) - HDONE_ERROR(H5E_DATASET, H5E_CANTDEC, NULL, "unable to decrement refcount on newly created object") - } - } - FUNC_LEAVE_NOAPI(ret_value) -} /* end H5VL_native_dataset_create() */ - - -/*------------------------------------------------------------------------- - * Function: H5VL_native_dataset_open - * - * Purpose: Opens a dataset in a native HDF5 file. - * - * Return: Success: Pointer to a dataset struct - * Failure: NULL - * - *------------------------------------------------------------------------- - */ -static void * -H5VL_native_dataset_open(void *obj, H5VL_loc_params_t loc_params, const char *name, - hid_t dapl_id, hid_t H5_ATTR_UNUSED dxpl_id, void H5_ATTR_UNUSED **req) -{ - H5D_t *dset = NULL; - H5G_loc_t loc; /* Object location of group */ - void *ret_value = NULL; - - FUNC_ENTER_NOAPI_NOINIT - - if(H5G_loc_real(obj, loc_params.obj_type, &loc) < 0) - HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, NULL, "not a file or file object") - - /* Open the dataset */ - if(NULL == (dset = H5D__open_name(&loc, name, dapl_id))) - HGOTO_ERROR(H5E_DATASET, H5E_CANTOPENOBJ, NULL, "unable to open dataset") - - ret_value = (void *)dset; - -done: - FUNC_LEAVE_NOAPI(ret_value) -} /* end H5VL_native_dataset_open() */ - - -/*------------------------------------------------------------------------- - * Function: H5VL_native_dataset_read - * - * Purpose: Reads raw data from a dataset into a buffer. - * - * Return: SUCCEED/FAIL - * - *------------------------------------------------------------------------- - */ -static herr_t -H5VL_native_dataset_read(void *obj, hid_t mem_type_id, hid_t mem_space_id, - hid_t file_space_id, hid_t H5_ATTR_UNUSED dxpl_id, void *buf, void H5_ATTR_UNUSED **req) -{ - H5D_t *dset = (H5D_t *)obj; - const H5S_t *mem_space = NULL; - const H5S_t *file_space = NULL; - herr_t ret_value = SUCCEED; /* Return value */ - - FUNC_ENTER_NOAPI_NOINIT - - /* Check arguments */ - if(NULL == dset->oloc.file) - HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "dataset is not associated with a file") - - /* Get validated dataspace pointers */ - if(H5S_get_validated_dataspace(mem_space_id, &mem_space) < 0) - HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "could not get a validated dataspace from mem_space_id") - if(H5S_get_validated_dataspace(file_space_id, &file_space) < 0) - HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "could not get a validated dataspace from file_space_id") - - /* Read raw data */ - if(H5D__read(dset, mem_type_id, mem_space, file_space, buf/*out*/) < 0) - HGOTO_ERROR(H5E_DATASET, H5E_READERROR, FAIL, "can't read data") - -done: - FUNC_LEAVE_NOAPI(ret_value) -} /* end H5VL_native_dataset_read() */ - - -/*------------------------------------------------------------------------- - * Function: H5VL_native_dataset_write - * - * Purpose: Writes raw data from a buffer into a dataset. - * - * Return: SUCCEED/FAIL - * - *------------------------------------------------------------------------- - */ -static herr_t -H5VL_native_dataset_write(void *obj, hid_t mem_type_id, hid_t mem_space_id, - hid_t file_space_id, hid_t H5_ATTR_UNUSED dxpl_id, const void *buf, void H5_ATTR_UNUSED **req) -{ - H5D_t *dset = (H5D_t *)obj; - const H5S_t *mem_space = NULL; - const H5S_t *file_space = NULL; - herr_t ret_value = SUCCEED; /* Return value */ - - FUNC_ENTER_NOAPI_NOINIT - - /* check arguments */ - if(NULL == dset->oloc.file) - HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "dataset is not associated with a file") - - /* Get validated dataspace pointers */ - if(H5S_get_validated_dataspace(mem_space_id, &mem_space) < 0) - HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "could not get a validated dataspace from mem_space_id") - if(H5S_get_validated_dataspace(file_space_id, &file_space) < 0) - HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "could not get a validated dataspace from file_space_id") - - /* Write the data */ - if(H5D__write(dset, mem_type_id, mem_space, file_space, buf) < 0) - HGOTO_ERROR(H5E_DATASET, H5E_WRITEERROR, FAIL, "can't write data") - -done: - FUNC_LEAVE_NOAPI(ret_value) -} /* end H5VL_native_dataset_write() */ - - -/*------------------------------------------------------------------------- - * Function: H5VL_native_dataset_get - * - * Purpose: Gets certain information about a dataset - * - * Return: SUCCEED/FAIL - * - *------------------------------------------------------------------------- - */ -static herr_t -H5VL_native_dataset_get(void *obj, H5VL_dataset_get_t get_type, hid_t H5_ATTR_UNUSED dxpl_id, - void H5_ATTR_UNUSED **req, va_list arguments) -{ - H5D_t *dset = (H5D_t *)obj; - herr_t ret_value = SUCCEED; /* Return value */ - - FUNC_ENTER_NOAPI_NOINIT - - switch(get_type) { - /* H5Dget_space */ - case H5VL_DATASET_GET_SPACE: - { - hid_t *ret_id = va_arg(arguments, hid_t *); - - if((*ret_id = H5D__get_space(dset)) < 0) - HGOTO_ERROR(H5E_ARGS, H5E_CANTGET, FAIL, "can't get space ID of dataset") - - break; - } - /* H5Dget_space_statuc */ - case H5VL_DATASET_GET_SPACE_STATUS: - { - H5D_space_status_t *allocation = va_arg(arguments, H5D_space_status_t *); - - /* Read data space address and return */ - if(H5D__get_space_status(dset, allocation) < 0) - HGOTO_ERROR(H5E_DATASET, H5E_CANTINIT, FAIL, "unable to get space status") - - break; - } - /* H5Dget_type */ - case H5VL_DATASET_GET_TYPE: - { - hid_t *ret_id = va_arg(arguments, hid_t *); - - if((*ret_id = H5D__get_type(dset)) < 0) - HGOTO_ERROR(H5E_ARGS, H5E_CANTGET, FAIL, "can't get datatype ID of dataset") - - break; - } - /* H5Dget_create_plist */ - case H5VL_DATASET_GET_DCPL: - { - hid_t *ret_id = va_arg(arguments, hid_t *); - - if((*ret_id = H5D_get_create_plist(dset)) < 0) - HGOTO_ERROR(H5E_ARGS, H5E_CANTGET, FAIL, "can't get creation property list for dataset") - - break; - } - /* H5Dget_access_plist */ - case H5VL_DATASET_GET_DAPL: - { - hid_t *ret_id = va_arg(arguments, hid_t *); - - if((*ret_id = H5D_get_access_plist(dset)) < 0) - HGOTO_ERROR(H5E_ARGS, H5E_CANTGET, FAIL, "can't get access property list for dataset") - - break; - } - /* H5Dget_storage_size */ - case H5VL_DATASET_GET_STORAGE_SIZE: - { - hsize_t *ret = va_arg(arguments, hsize_t *); - - /* Set return value */ - if(H5D__get_storage_size(dset, ret) < 0) - HGOTO_ERROR(H5E_DATASET, H5E_CANTGET, FAIL, "can't get size of dataset's storage") - break; - } - /* H5Dget_offset */ - case H5VL_DATASET_GET_OFFSET: - { - haddr_t *ret = va_arg(arguments, haddr_t *); - - /* Set return value */ - *ret = H5D__get_offset(dset); - if(!H5F_addr_defined(*ret)) - *ret = HADDR_UNDEF; - break; - } - default: - HGOTO_ERROR(H5E_VOL, H5E_CANTGET, FAIL, "can't get this type of information from dataset") - } - -done: - FUNC_LEAVE_NOAPI(ret_value) -} /* end H5VL_native_dataset_get() */ - - -/*------------------------------------------------------------------------- - * Function: H5VL_native_dataset_specific - * - * Purpose: Specific operations for datasets - * - * Return: SUCCEED/FAIL - * - *------------------------------------------------------------------------- - */ -static herr_t -H5VL_native_dataset_specific(void *obj, H5VL_dataset_specific_t specific_type, - hid_t H5_ATTR_UNUSED dxpl_id, void H5_ATTR_UNUSED **req, va_list arguments) -{ - H5D_t *dset = (H5D_t *)obj; - herr_t ret_value = SUCCEED; /* Return value */ - - FUNC_ENTER_NOAPI_NOINIT - - switch(specific_type) { - /* H5Dspecific_space */ - case H5VL_DATASET_SET_EXTENT: - { - const hsize_t *size = va_arg(arguments, const hsize_t *); - - if(H5D__set_extent(dset, size) < 0) - HGOTO_ERROR(H5E_DATASET, H5E_CANTINIT, FAIL, "unable to set extent of dataset") - break; - } - case H5VL_DATASET_FLUSH: - { - hid_t dset_id = va_arg(arguments, hid_t); - - /* Flush the dataset */ - if(H5D__flush(dset, dset_id) < 0) - HGOTO_ERROR(H5E_DATASET, H5E_CANTFLUSH, FAIL, "unable to flush dataset") - - break; - } - case H5VL_DATASET_REFRESH: - { - hid_t dset_id = va_arg(arguments, hid_t); - - /* Refresh the dataset */ - if((H5D__refresh(dset_id, dset)) < 0) - HGOTO_ERROR(H5E_DATASET, H5E_CANTLOAD, FAIL, "unable to refresh dataset") - - break; - } - default: - HGOTO_ERROR(H5E_VOL, H5E_UNSUPPORTED, FAIL, "invalid specific operation") - } - -done: - FUNC_LEAVE_NOAPI(ret_value) -} /* end H5VL_native_dataset_specific() */ - - -/*------------------------------------------------------------------------- - * Function: H5VL_native_dataset_optional - * - * Purpose: Perform a driver specific operation on a native dataset - * - * Return: SUCCEED/FAIL - * - *------------------------------------------------------------------------- - */ -static herr_t -H5VL_native_dataset_optional(void *obj, hid_t H5_ATTR_UNUSED dxpl_id, void H5_ATTR_UNUSED **req, va_list arguments) -{ - H5D_t *dset = NULL; /* Dataset */ - H5VL_dataset_optional_t optional_type = va_arg(arguments, H5VL_dataset_optional_t); - herr_t ret_value = SUCCEED; /* Return value */ - - FUNC_ENTER_NOAPI_NOINIT - - switch(optional_type) { - case H5VL_DATASET_FORMAT_CONVERT: - { - dset = (H5D_t *)obj; - - switch(dset->shared->layout.type) { - case H5D_CHUNKED: - /* Convert the chunk indexing type to version 1 B-tree if not */ - if(dset->shared->layout.u.chunk.idx_type != H5D_CHUNK_IDX_BTREE) - if((H5D__format_convert(dset)) < 0) - HGOTO_ERROR(H5E_DATASET, H5E_CANTLOAD, FAIL, "unable to downgrade chunk indexing type for dataset") - break; - - case H5D_CONTIGUOUS: - case H5D_COMPACT: - /* Downgrade the layout version to 3 if greater than 3 */ - if(dset->shared->layout.version > H5O_LAYOUT_VERSION_DEFAULT) - if((H5D__format_convert(dset)) < 0) - HGOTO_ERROR(H5E_DATASET, H5E_CANTLOAD, FAIL, "unable to downgrade layout version for dataset") - break; - - case H5D_VIRTUAL: - /* Nothing to do even though layout is version 4 */ - break; - - case H5D_LAYOUT_ERROR: - case H5D_NLAYOUTS: - HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "invalid dataset layout type") - - default: - HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "unknown dataset layout type") - } /* end switch */ - - break; - } - case H5VL_DATASET_GET_CHUNK_INDEX_TYPE: - { - H5D_chunk_index_t *idx_type = va_arg(arguments, H5D_chunk_index_t *); - - dset = (H5D_t *)obj; - - /* Make sure the dataset is chunked */ - if(H5D_CHUNKED != dset->shared->layout.type) - HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a chunked dataset") - - /* Get the chunk indexing type */ - *idx_type = dset->shared->layout.u.chunk.idx_type; - - break; - } - case H5VL_DATASET_GET_CHUNK_STORAGE_SIZE: - { - hsize_t *offset = va_arg(arguments, hsize_t *); - hsize_t *chunk_nbytes = va_arg(arguments, hsize_t *); - - dset = (H5D_t *)obj; - - /* Make sure the dataset is chunked */ - if(H5D_CHUNKED != dset->shared->layout.type) - HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a chunked dataset") - - /* Call private function */ - if(H5D__get_chunk_storage_size(dset, offset, chunk_nbytes) < 0) - HGOTO_ERROR(H5E_DATASET, H5E_CANTGET, FAIL, "can't get storage size of chunk") - - break; - } - case H5VL_DATASET_CHUNK_READ: - { - const hsize_t *offset = va_arg(arguments, hsize_t *); - uint32_t *filters = va_arg(arguments, uint32_t *); - void *buf = va_arg(arguments, void *); - hsize_t offset_copy[H5O_LAYOUT_NDIMS]; /* Internal copy of chunk offset */ - - dset = (H5D_t *)obj; - - /* Check arguments */ - if(NULL == dset->oloc.file) - HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "dataset is not associated with a file") - if(H5D_CHUNKED != dset->shared->layout.type) - HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a chunked dataset") - - /* Copy the user's offset array so we can be sure it's terminated properly. - * (we don't want to mess with the user's buffer). - */ - if(H5D__get_offset_copy(dset, offset, offset_copy) < 0) - HGOTO_ERROR(H5E_DATASET, H5E_CANTALLOC, FAIL, "failure to copy offset array") - - /* Read the raw chunk */ - if(H5D__chunk_direct_read(dset, offset_copy, filters, buf) < 0) - HGOTO_ERROR(H5E_DATASET, H5E_READERROR, FAIL, "can't read unprocessed chunk data") - - break; - } - case H5VL_DATASET_CHUNK_WRITE: - { - uint32_t filters = va_arg(arguments, uint32_t); - const hsize_t *offset = va_arg(arguments, const hsize_t *); - uint32_t data_size_32 = va_arg(arguments, uint32_t); - const void *buf = va_arg(arguments, const void *); - hsize_t offset_copy[H5O_LAYOUT_NDIMS]; /* Internal copy of chunk offset */ - - dset = (H5D_t *)obj; - - /* Check arguments */ - if(NULL == dset->oloc.file) - HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "dataset is not associated with a file") - if(H5D_CHUNKED != dset->shared->layout.type) - HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a chunked dataset") - - /* Copy the user's offset array so we can be sure it's terminated properly. - * (we don't want to mess with the user's buffer). - */ - if(H5D__get_offset_copy(dset, offset, offset_copy) < 0) - HGOTO_ERROR(H5E_DATASET, H5E_CANTALLOC, FAIL, "failure to copy offset array") - - /* Write chunk */ - if(H5D__chunk_direct_write(dset, filters, offset_copy, data_size_32, buf) < 0) - HGOTO_ERROR(H5E_DATASET, H5E_WRITEERROR, FAIL, "can't write unprocessed chunk data") - - break; - } - default: - HGOTO_ERROR(H5E_VOL, H5E_UNSUPPORTED, FAIL, "invalid optional operation") - } - -done: - FUNC_LEAVE_NOAPI(ret_value) -} /* end H5VL_native_dataset_optional() */ - - -/*------------------------------------------------------------------------- - * Function: H5VL_native_dataset_close - * - * Purpose: Closes a dataset. - * - * Return: Success: SUCCEED - * Failure: FAIL (dataset will not be closed) - * - *------------------------------------------------------------------------- - */ -static herr_t -H5VL_native_dataset_close(void *dset, hid_t H5_ATTR_UNUSED dxpl_id, void H5_ATTR_UNUSED **req) -{ - herr_t ret_value = SUCCEED; /* Return value */ - - FUNC_ENTER_NOAPI_NOINIT - - if(H5D_close((H5D_t*)dset) < 0) - HGOTO_ERROR(H5E_DATASET, H5E_CANTDEC, FAIL, "can't close dataset") - -done: - FUNC_LEAVE_NOAPI(ret_value) -} /* end H5VL_native_dataset_close() */ - - -/*------------------------------------------------------------------------- - * Function: H5VL_native_file_create - * - * Purpose: Creates a file as a native HDF5 file. - * - * Return: Success: A pointer to an H5F_t file struct - * - * Failure: NULL - * - *------------------------------------------------------------------------- - */ -static void * -H5VL_native_file_create(const char *name, unsigned flags, hid_t fcpl_id, hid_t fapl_id, - hid_t H5_ATTR_UNUSED dxpl_id, void H5_ATTR_UNUSED **req) -{ - H5F_t *new_file = NULL; - void *ret_value = NULL; - - FUNC_ENTER_NOAPI_NOINIT - - /* Adjust bit flags by turning on the creation bit and making sure that - * the EXCL or TRUNC bit is set. All newly-created files are opened for - * reading and writing. - */ - if(0 == (flags & (H5F_ACC_EXCL|H5F_ACC_TRUNC))) - flags |= H5F_ACC_EXCL; /*default*/ - flags |= H5F_ACC_RDWR | H5F_ACC_CREAT; - - /* Create the file */ - if(NULL == (new_file = H5F_open(name, flags, fcpl_id, fapl_id))) - HGOTO_ERROR(H5E_FILE, H5E_CANTOPENFILE, NULL, "unable to create file") - - new_file->id_exists = TRUE; - ret_value = (void *)new_file; - -done: - if(NULL == ret_value && new_file) - if(H5F__close(new_file) < 0) - HDONE_ERROR(H5E_FILE, H5E_CANTCLOSEFILE, NULL, "problems closing file") - FUNC_LEAVE_NOAPI(ret_value) -} /* end H5VL_native_file_create() */ - - -/*------------------------------------------------------------------------- - * Function: H5VL_native_file_open - * - * Purpose: Opens a file as a native HDF5 file. - * - * Return: Success: A pointer to an H5F_t file struct - * - * Failure: NULL - * - *------------------------------------------------------------------------- - */ -static void * -H5VL_native_file_open(const char *name, unsigned flags, hid_t fapl_id, hid_t H5_ATTR_UNUSED dxpl_id, void H5_ATTR_UNUSED **req) -{ - H5F_t *new_file = NULL; - void *ret_value = NULL; - - FUNC_ENTER_NOAPI_NOINIT - - /* Open the file */ - if(NULL == (new_file = H5F_open(name, flags, H5P_FILE_CREATE_DEFAULT, fapl_id))) - HGOTO_ERROR(H5E_FILE, H5E_CANTOPENFILE, NULL, "unable to open file") - - new_file->id_exists = TRUE; - ret_value = (void *)new_file; - -done: - if(NULL == ret_value && new_file && H5F_try_close(new_file, NULL) < 0) - HDONE_ERROR(H5E_FILE, H5E_CANTCLOSEFILE, NULL, "problems closing file") - FUNC_LEAVE_NOAPI(ret_value) -} /* end H5VL_native_file_open() */ - - -/*------------------------------------------------------------------------- - * Function: H5VL_native_file_get - * - * Purpose: Gets certain data about a file - * - * Return: SUCCEED/FAIL - * - *------------------------------------------------------------------------- - */ -static herr_t -H5VL_native_file_get(void *obj, H5VL_file_get_t get_type, hid_t H5_ATTR_UNUSED dxpl_id, void H5_ATTR_UNUSED **req, va_list arguments) -{ - H5F_t *f = NULL; /* File struct */ - herr_t ret_value = SUCCEED; /* Return value */ - - FUNC_ENTER_NOAPI_NOINIT - - switch(get_type) { - /* H5Fget_access_plist */ - case H5VL_FILE_GET_FAPL: - { - H5P_genplist_t *new_plist; /* New property list */ - hid_t *plist_id = va_arg(arguments, hid_t *); - - f = (H5F_t *)obj; - - /* Retrieve the file's access property list */ - if((*plist_id = H5F_get_access_plist(f, TRUE)) < 0) - HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, FAIL, "can't get file access property list") - - if(NULL == (new_plist = (H5P_genplist_t *)H5I_object(*plist_id))) - HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a property list") - break; - } - /* H5Fget_create_plist */ - case H5VL_FILE_GET_FCPL: - { - H5P_genplist_t *plist; /* Property list */ - hid_t *plist_id = va_arg(arguments, hid_t *); - - f = (H5F_t *)obj; - if(NULL == (plist = (H5P_genplist_t *)H5I_object(f->shared->fcpl_id))) - HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a property list") - - /* Create the property list object to return */ - if((*plist_id = H5P_copy_plist(plist, TRUE)) < 0) - HGOTO_ERROR(H5E_PLIST, H5E_CANTINIT, FAIL, "unable to copy file creation properties") - - break; - } - /* H5Fget_obj_count */ - case H5VL_FILE_GET_OBJ_COUNT: - { - unsigned types = va_arg(arguments, unsigned); - ssize_t *ret = va_arg(arguments, ssize_t *); - size_t obj_count = 0; /* Number of opened objects */ - - f = (H5F_t *)obj; - /* Perform the query */ - if(H5F_get_obj_count(f, types, TRUE, &obj_count) < 0) - HGOTO_ERROR(H5E_FILE, H5E_BADITER, FAIL, "H5F_get_obj_count failed") - - /* Set the return value */ - *ret = (ssize_t)obj_count; - break; - } - /* H5Fget_obj_ids */ - case H5VL_FILE_GET_OBJ_IDS: - { - unsigned types = va_arg(arguments, unsigned); - size_t max_objs = va_arg(arguments, size_t); - hid_t *oid_list = va_arg(arguments, hid_t *); - ssize_t *ret = va_arg(arguments, ssize_t *); - size_t obj_count = 0; /* Number of opened objects */ - - f = (H5F_t *)obj; - /* Perform the query */ - if(H5F_get_obj_ids(f, types, max_objs, oid_list, TRUE, &obj_count) < 0) - HGOTO_ERROR(H5E_FILE, H5E_BADITER, FAIL, "H5F_get_obj_ids failed") - - /* Set the return value */ - *ret = (ssize_t)obj_count; - break; - } - /* H5Fget_intent */ - case H5VL_FILE_GET_INTENT: - { - unsigned *intent_flags = va_arg(arguments, unsigned *); - - f = (H5F_t *)obj; - - /* HDF5 uses some flags internally that users don't know about. - * Simplify things for them so that they only get either H5F_ACC_RDWR - * or H5F_ACC_RDONLY and any SWMR flags. - */ - if(H5F_INTENT(f) & H5F_ACC_RDWR) { - *intent_flags = H5F_ACC_RDWR; - - /* Check for SWMR write access on the file */ - if(H5F_INTENT(f) & H5F_ACC_SWMR_WRITE) - *intent_flags |= H5F_ACC_SWMR_WRITE; - } - else { - *intent_flags = H5F_ACC_RDONLY; - - /* Check for SWMR read access on the file */ - if(H5F_INTENT(f) & H5F_ACC_SWMR_READ) - *intent_flags |= H5F_ACC_SWMR_READ; - } - - break; - } - /* H5Fget_name */ - case H5VL_FILE_GET_NAME: - { - H5I_type_t type = va_arg(arguments, H5I_type_t); - size_t size = va_arg(arguments, size_t); - char *name = va_arg(arguments, char *); - ssize_t *ret = va_arg(arguments, ssize_t *); - size_t len; - - if(NULL == (f = H5VL_native_get_file(obj, type))) - HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a file or file object") - - len = HDstrlen(H5F_OPEN_NAME(f)); - - if(name) { - HDstrncpy(name, H5F_OPEN_NAME(f), MIN(len + 1,size)); - if(len >= size) - name[size-1]='\0'; - } - - /* Set the return value for the API call */ - *ret = (ssize_t)len; - break; - } - /* H5Iget_file_id */ - case H5VL_OBJECT_GET_FILE: - { - H5I_type_t type = va_arg(arguments, H5I_type_t); - void **ret = va_arg(arguments, void **); - - if(NULL == (f = H5VL_native_get_file(obj, type))) - HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a file or file object") - f->id_exists = TRUE; - *ret = (void*)f; - break; - } - default: - HGOTO_ERROR(H5E_VOL, H5E_CANTGET, FAIL, "can't get this type of information") - } /* end switch */ -done: - FUNC_LEAVE_NOAPI(ret_value) -} /* end H5VL_native_file_get() */ - - -/*------------------------------------------------------------------------- - * Function: H5VL_native_file_specific - * - * Purpose: Perform an operation - * - * Return: SUCCEED/FAIL - * - *------------------------------------------------------------------------- - */ -static herr_t -H5VL_native_file_specific(void *obj, H5VL_file_specific_t specific_type, hid_t H5_ATTR_UNUSED dxpl_id, - void H5_ATTR_UNUSED **req, va_list arguments) -{ - herr_t ret_value = SUCCEED; /* Return value */ - - FUNC_ENTER_NOAPI_NOINIT - - switch(specific_type) { - /* H5Fflush */ - case H5VL_FILE_FLUSH: - { - H5I_type_t type = va_arg(arguments, H5I_type_t); - H5F_scope_t scope = va_arg(arguments, H5F_scope_t); - H5F_t *f = NULL; /* File to flush */ - - /* Get the file for the object */ - if(NULL == (f = H5VL_native_get_file(obj, type))) - HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a file or file object") - - /* Nothing to do if the file is read only. This determination is - * made at the shared open(2) flags level, implying that opening a - * file twice, once for read-only and once for read-write, and then - * calling H5Fflush() with the read-only handle, still causes data - * to be flushed. - */ - if(H5F_ACC_RDWR & H5F_INTENT(f)) { - /* Flush other files, depending on scope */ - if(H5F_SCOPE_GLOBAL == scope) { - /* Call the flush routine for mounted file hierarchies */ - if(H5F_flush_mounts(f) < 0) - HGOTO_ERROR(H5E_FILE, H5E_CANTFLUSH, FAIL, "unable to flush mounted file hierarchy") - } - else { - /* Call the flush routine, for this file */ - if(H5F__flush(f) < 0) - HGOTO_ERROR(H5E_FILE, H5E_CANTFLUSH, FAIL, "unable to flush file's cached information") - } - } - break; - } - /* H5Fmount */ - case H5VL_FILE_MOUNT: - { - H5I_type_t type = va_arg(arguments, H5I_type_t); - const char *name = va_arg(arguments, const char *); - H5F_t *child = va_arg(arguments, H5F_t *); - hid_t plist_id = va_arg(arguments, hid_t); - H5G_loc_t loc; - - if(H5G_loc_real(obj, type, &loc) < 0) - HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a file or file object") - - /* Do the mount */ - if(H5F__mount(&loc, name, child, plist_id) < 0) - HGOTO_ERROR(H5E_FILE, H5E_MOUNT, FAIL, "unable to mount file") - - break; - } - /* H5Funmount */ - case H5VL_FILE_UNMOUNT: - { - H5I_type_t type = va_arg(arguments, H5I_type_t); - const char *name = va_arg(arguments, const char *); - H5G_loc_t loc; - - if(H5G_loc_real(obj, type, &loc) < 0) - HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a file or file object") - - /* Unmount */ - if(H5F__unmount(&loc, name) < 0) - HGOTO_ERROR(H5E_FILE, H5E_MOUNT, FAIL, "unable to unmount file") - - break; - } - /* H5Fis_accessible */ - case H5VL_FILE_IS_ACCESSIBLE: - { - hid_t fapl_id = va_arg(arguments, hid_t); - const char *name = va_arg(arguments, const char *); - htri_t *ret = va_arg(arguments, htri_t *); - - /* Call private routine */ - if((*ret = H5F__is_hdf5(name, fapl_id)) < 0) - HGOTO_ERROR(H5E_IO, H5E_CANTINIT, FAIL, "error in HDF5 file check") - break; - } - default: - HGOTO_ERROR(H5E_VOL, H5E_UNSUPPORTED, FAIL, "invalid specific operation") - } - -done: - FUNC_LEAVE_NOAPI(ret_value) -} /* end H5VL_native_file_specific() */ - - -/*------------------------------------------------------------------------- - * Function: H5VL_native_file_optional - * - * Purpose: Perform a driver specific operation on a native file - * - * Return: SUCCEED/FAIL - * - *------------------------------------------------------------------------- - */ -static herr_t -H5VL_native_file_optional(void *obj, hid_t H5_ATTR_UNUSED dxpl_id, void H5_ATTR_UNUSED **req, va_list arguments) -{ - H5F_t *f = NULL; /* File */ - H5VL_file_optional_t optional_type = va_arg(arguments, H5VL_file_optional_t); - herr_t ret_value = SUCCEED; /* Return value */ - - FUNC_ENTER_NOAPI_NOINIT - - switch(optional_type) { - /* H5Fget_filesize */ - case H5VL_FILE_GET_SIZE: - { - haddr_t max_eof_eoa; /* Maximum of the EOA & EOF */ - haddr_t base_addr; /* Base address for the file */ - hsize_t *size = va_arg(arguments, hsize_t *); - - f = (H5F_t *)obj; - - /* Go get the actual file size */ - if(H5F__get_max_eof_eoa(f, &max_eof_eoa) < 0) - HGOTO_ERROR(H5E_FILE, H5E_CANTGET, FAIL, "file can't get max eof/eoa ") - - base_addr = H5FD_get_base_addr(f->shared->lf); - - if(size) - *size = (hsize_t)(max_eof_eoa + base_addr); /* Convert relative base address for file to absolute address */ - - break; - } - /* H5Fget_file_image */ - case H5VL_FILE_GET_FILE_IMAGE: - { - void *buf_ptr = va_arg(arguments, void *); - ssize_t *ret = va_arg(arguments, ssize_t *); - size_t buf_len = va_arg(arguments, size_t ); - - f = (H5F_t *)obj; - /* Do the actual work */ - if((*ret = H5F__get_file_image(f, buf_ptr, buf_len)) < 0) - HGOTO_ERROR(H5E_FILE, H5E_CANTGET, FAIL, "get file image failed") - break; - } - /* H5Fget_freespace */ - case H5VL_FILE_GET_FREE_SPACE: - { - hsize_t tot_space; /* Amount of free space in the file */ - hssize_t *ret = va_arg(arguments, hssize_t *); - - f = (H5F_t *)obj; - /* Go get the actual amount of free space in the file */ - if(H5MF_get_freespace(f, &tot_space, NULL) < 0) - HGOTO_ERROR(H5E_FILE, H5E_CANTGET, FAIL, "unable to check free space for file") - *ret = (hssize_t)tot_space; - break; - } - case H5VL_FILE_GET_FREE_SECTIONS: - { - H5F_sect_info_t *sect_info = va_arg(arguments, H5F_sect_info_t *); - ssize_t *ret = va_arg(arguments, ssize_t *); - H5F_mem_t type = va_arg(arguments, H5F_mem_t); - size_t nsects = va_arg(arguments, size_t); - - f = (H5F_t *)obj; - /* Go get the free-space section information in the file */ - if((*ret = H5MF_get_free_sections(f, type, nsects, sect_info)) < 0) - HGOTO_ERROR(H5E_FILE, H5E_CANTGET, FAIL, "unable to check free space for file") - break; - } - /* H5Fget_info2 */ - case H5VL_FILE_GET_INFO: - { - H5I_type_t type = va_arg(arguments, H5I_type_t); - H5F_info2_t *finfo = va_arg(arguments, H5F_info2_t *); - - /* Get the file struct. This call is careful to not return the file pointer - * for the top file in a mount hierarchy. - */ - if(NULL == (f = H5VL_native_get_file(obj, type))) - HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "could not get a file struct") - - /* Get the file info */ - if(H5F__get_info(f, finfo) < 0) - HGOTO_ERROR(H5E_FILE, H5E_CANTGET, FAIL, "unable to retrieve file info") - - break; - } - /* H5Fget_mdc_config */ - case H5VL_FILE_GET_MDC_CONF: - { - H5AC_cache_config_t *config_ptr = va_arg(arguments, H5AC_cache_config_t *); - - f = (H5F_t *)obj; - /* Go get the resize configuration */ - if(H5AC_get_cache_auto_resize_config(f->shared->cache, config_ptr) < 0) - HGOTO_ERROR(H5E_CACHE, H5E_SYSTEM, FAIL, "H5AC_get_cache_auto_resize_config() failed.") - break; - } - /* H5Fget_mdc_hit_rate */ - case H5VL_FILE_GET_MDC_HR: - { - double *hit_rate_ptr = va_arg(arguments, double *); - - f = (H5F_t *)obj; - /* Go get the current hit rate */ - if(H5AC_get_cache_hit_rate(f->shared->cache, hit_rate_ptr) < 0) - HGOTO_ERROR(H5E_CACHE, H5E_SYSTEM, FAIL, "H5AC_get_cache_hit_rate() failed.") - break; - } - /* H5Fget_mdc_size */ - case H5VL_FILE_GET_MDC_SIZE: - { - size_t *max_size_ptr = va_arg(arguments, size_t *); - size_t *min_clean_size_ptr = va_arg(arguments, size_t *); - size_t *cur_size_ptr = va_arg(arguments, size_t *); - int *cur_num_entries_ptr = va_arg(arguments, int *); - uint32_t cur_num_entries; - - f = (H5F_t *)obj; - /* Go get the size data */ - if(H5AC_get_cache_size(f->shared->cache, max_size_ptr, min_clean_size_ptr, - cur_size_ptr, &cur_num_entries) < 0) - HGOTO_ERROR(H5E_CACHE, H5E_SYSTEM, FAIL, "H5AC_get_cache_size() failed.") - - if(cur_num_entries_ptr != NULL) - *cur_num_entries_ptr = (int)cur_num_entries; - break; - } - /* H5Fget_vfd_handle */ - case H5VL_FILE_GET_VFD_HANDLE: - { - void **file_handle = va_arg(arguments, void **); - hid_t fapl_id = va_arg(arguments, hid_t); - - f = (H5F_t *)obj; - - /* Retrieve the VFD handle for the file */ - if(H5F_get_vfd_handle(f, fapl_id, file_handle) < 0) - HGOTO_ERROR(H5E_FILE, H5E_CANTGET, FAIL, "can't retrieve VFD handle") - break; - } - /* H5Fclear_elink_file_cache */ - case H5VL_FILE_CLEAR_ELINK_CACHE: - { - f = (H5F_t *)obj; - - /* Release the EFC */ - if(f->shared->efc) - if(H5F__efc_release(f->shared->efc) < 0) - HGOTO_ERROR(H5E_FILE, H5E_CANTRELEASE, FAIL, "can't release external file cache") - break; - } - /* H5Freopen */ - case H5VL_FILE_REOPEN: - { - void **ret = va_arg(arguments, void **); - H5F_t *new_file = NULL; - - f = (H5F_t *)obj; - - /* Reopen the file through the VOL driver */ - if(NULL == (new_file = H5F__reopen(f))) - HGOTO_ERROR(H5E_FILE, H5E_CANTINIT, FAIL, "unable to reopen file") - - new_file->id_exists = TRUE; - - *ret = (void *)new_file; - break; - } - /* H5Freset_mdc_hit_rate_stats */ - case H5VL_FILE_RESET_MDC_HIT_RATE: - { - f = (H5F_t *)obj; - /* Reset the hit rate statistic */ - if(H5AC_reset_cache_hit_rate_stats(f->shared->cache) < 0) - HGOTO_ERROR(H5E_CACHE, H5E_SYSTEM, FAIL, "can't reset cache hit rate") - break; - } - case H5VL_FILE_SET_MDC_CONFIG: - { - H5AC_cache_config_t *config_ptr = va_arg(arguments, H5AC_cache_config_t *); - - f = (H5F_t *)obj; - /* set the resize configuration */ - if(H5AC_set_cache_auto_resize_config(f->shared->cache, config_ptr) < 0) - HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "H5AC_set_cache_auto_resize_config() failed") - break; - } - case H5VL_FILE_GET_METADATA_READ_RETRY_INFO: - { - H5F_retry_info_t *info = va_arg(arguments, H5F_retry_info_t *); - - f = (H5F_t *)obj; - - if(H5F_get_metadata_read_retry_info(f, info) < 0) - HGOTO_ERROR(H5E_CACHE, H5E_SYSTEM, FAIL, "can't get metadata read retry info") - - break; - } - case H5VL_FILE_START_SWMR_WRITE: - { - f = (H5F_t *)obj; - - if(H5F__start_swmr_write(f) < 0) - HGOTO_ERROR(H5E_CACHE, H5E_SYSTEM, FAIL, "can't start SWMR write") - - break; - } - case H5VL_FILE_START_MDC_LOGGING: - { - f = (H5F_t *)obj; - - /* Call mdc logging function */ - if(H5C_start_logging(f->shared->cache) < 0) - HGOTO_ERROR(H5E_FILE, H5E_LOGFAIL, FAIL, "unable to start mdc logging") - - break; - } - case H5VL_FILE_STOP_MDC_LOGGING: - { - f = (H5F_t *)obj; - - /* Call mdc logging function */ - if(H5C_stop_logging(f->shared->cache) < 0) - HGOTO_ERROR(H5E_FILE, H5E_LOGFAIL, FAIL, "unable to stop mdc logging") - - break; - } - case H5VL_FILE_GET_MDC_LOGGING_STATUS: - { - hbool_t *is_enabled = va_arg(arguments, hbool_t *); - hbool_t *is_currently_logging = va_arg(arguments, hbool_t *); - - f = (H5F_t *)obj; - - /* Call mdc logging function */ - if(H5C_get_logging_status(f->shared->cache, is_enabled, is_currently_logging) < 0) - HGOTO_ERROR(H5E_FILE, H5E_LOGFAIL, FAIL, "unable to get logging status") - - break; - } - case H5VL_FILE_SET_LATEST_FORMAT: - { - HGOTO_ERROR(H5E_VOL, H5E_UNSUPPORTED, FAIL, "invalid optional operation") - break; - } - case H5VL_FILE_FORMAT_CONVERT: - { - f = (H5F_t *)obj; - - /* Convert the format */ - if(H5F__format_convert(f) < 0) - HGOTO_ERROR(H5E_FILE, H5E_CANTCONVERT, FAIL, "can't convert file format") - - break; - } - case H5VL_FILE_RESET_PAGE_BUFFERING_STATS: - { - f = (H5F_t *)obj; - - /* Sanity check */ - if(NULL == f->shared->page_buf) - HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "page buffering not enabled on file") - - /* Reset the statistics */ - if (H5PB_reset_stats(f->shared->page_buf) < 0) - HGOTO_ERROR(H5E_FILE, H5E_CANTGET, FAIL, "can't reset stats for page buffering") - - break; - } - case H5VL_FILE_GET_PAGE_BUFFERING_STATS: - { - unsigned *accesses = va_arg(arguments, unsigned *); - unsigned *hits = va_arg(arguments, unsigned *); - unsigned *misses = va_arg(arguments, unsigned *); - unsigned *evictions = va_arg(arguments, unsigned *); - unsigned *bypasses = va_arg(arguments, unsigned *); - - f = (H5F_t *)obj; - - /* Sanity check */ - if(NULL == f->shared->page_buf) - HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "page buffering not enabled on file") - - /* Get the statistics */ - if(H5PB_get_stats(f->shared->page_buf, accesses, hits, misses, evictions, bypasses) < 0) - HGOTO_ERROR(H5E_FILE, H5E_CANTGET, FAIL, "can't retrieve stats for page buffering") - - break; - } - case H5VL_FILE_GET_MDC_IMAGE_INFO: - { - HGOTO_ERROR(H5E_VOL, H5E_UNSUPPORTED, FAIL, "invalid optional operation") - break; - } - - default: - HGOTO_ERROR(H5E_VOL, H5E_UNSUPPORTED, FAIL, "invalid optional operation") - } - -done: - FUNC_LEAVE_NOAPI(ret_value) -} /* end H5VL_native_file_optional() */ - - -/*------------------------------------------------------------------------- - * Function: H5VL_native_file_close - * - * Purpose: Closes a file. - * - * Return: SUCCEED/FAIL (the file will not be closed on failure) - * - *------------------------------------------------------------------------- - */ -static herr_t -H5VL_native_file_close(void *file, hid_t H5_ATTR_UNUSED dxpl_id, void H5_ATTR_UNUSED **req) -{ - int nref; - H5F_t *f = (H5F_t *)file; - hid_t file_id = H5I_INVALID_HID; - herr_t ret_value = SUCCEED; /* Return value */ - - FUNC_ENTER_NOAPI_NOINIT - - /* This routine should only be called when a file ID's ref count drops to zero */ - HDassert(H5F_ID_EXISTS(f)); - - /* Flush file if this is the last reference to this id and we have write - * intent, unless it will be flushed by the "shared" file being closed. - * This is only necessary to replicate previous behaviour, and could be - * disabled by an option/property to improve performance. - */ - if((H5F_NREFS(f) > 1) && (H5F_INTENT(f) & H5F_ACC_RDWR)) { - /* Get the file ID corresponding to the H5F_t struct */ - if(H5I_find_id(f, H5I_FILE, &file_id) < 0 || H5I_INVALID_HID == file_id) - HGOTO_ERROR(H5E_ATOM, H5E_CANTGET, FAIL, "invalid atom") - /* Get the number of references outstanding for this file ID */ - if((nref = H5I_get_ref(file_id, FALSE)) < 0) - HGOTO_ERROR(H5E_ATOM, H5E_CANTGET, FAIL, "can't get ID ref count") - if(nref == 1) - if(H5F__flush(f) < 0) - HGOTO_ERROR(H5E_CACHE, H5E_CANTFLUSH, FAIL, "unable to flush cache") - } - - /* Close the file */ - if(H5F__close(f) < 0) - HGOTO_ERROR(H5E_FILE, H5E_CANTDEC, FAIL, "can't close file") - -done: - FUNC_LEAVE_NOAPI(ret_value) -} /* end H5VL_native_file_close() */ - - -/*------------------------------------------------------------------------- - * Function: H5VL_native_group_create - * - * Purpose: Creates a group inside a native h5 file. - * - * Return: Success: Pointer to a group struct - * - * Failure: NULL - * - *------------------------------------------------------------------------- - */ -static void * -H5VL_native_group_create(void *obj, H5VL_loc_params_t loc_params, const char *name, hid_t gcpl_id, - hid_t H5_ATTR_UNUSED gapl_id, hid_t H5_ATTR_UNUSED dxpl_id, void H5_ATTR_UNUSED **req) -{ - H5P_genplist_t *plist; /* Property list pointer */ - H5G_loc_t loc; /* Location to create group */ - H5G_t *grp = NULL; /* New group created */ - hid_t lcpl_id; - void *ret_value; - - FUNC_ENTER_NOAPI_NOINIT - - /* Get the property list structure */ - if(NULL == (plist = (H5P_genplist_t *)H5I_object(gcpl_id))) - HGOTO_ERROR(H5E_ATOM, H5E_BADATOM, NULL, "can't find object for ID") - - /* Get creation properties */ - if(H5P_get(plist, H5VL_PROP_GRP_LCPL_ID, &lcpl_id) < 0) - HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, NULL, "can't get property value for lcpl id") - - /* Set up the location */ - if(H5G_loc_real(obj, loc_params.obj_type, &loc) < 0) - HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, NULL, "not a file or file object") - - /* if name is NULL then this is from H5Gcreate_anon */ - if(name == NULL) { - H5G_obj_create_t gcrt_info; /* Information for group creation */ - - /* Set up group creation info */ - gcrt_info.gcpl_id = gcpl_id; - gcrt_info.cache_type = H5G_NOTHING_CACHED; - HDmemset(&gcrt_info.cache, 0, sizeof(gcrt_info.cache)); - - /* Create the new group & get its ID */ - if(NULL == (grp = H5G__create(loc.oloc->file, &gcrt_info))) - HGOTO_ERROR(H5E_SYM, H5E_CANTINIT, NULL, "unable to create group") - } - /* otherwise it's from H5Gcreate */ - else { - /* Create the new group & get its ID */ - if(NULL == (grp = H5G__create_named(&loc, name, lcpl_id, gcpl_id))) - HGOTO_ERROR(H5E_SYM, H5E_CANTINIT, NULL, "unable to create group") - } - ret_value = (void *)grp; - -done: - if(name == NULL) { - /* Release the group's object header, if it was created */ - if(grp) { - H5O_loc_t *oloc; /* Object location for group */ - - /* Get the new group's object location */ - if(NULL == (oloc = H5G_oloc(grp))) - HDONE_ERROR(H5E_SYM, H5E_CANTGET, NULL, "unable to get object location of group") - - /* Decrement refcount on group's object header in memory */ - if(H5O_dec_rc_by_loc(oloc) < 0) - HDONE_ERROR(H5E_SYM, H5E_CANTDEC, NULL, "unable to decrement refcount on newly created object") - } - } - FUNC_LEAVE_NOAPI(ret_value) -} /* end H5VL_native_group_create() */ - - -/*------------------------------------------------------------------------- - * Function: H5VL_native_group_open - * - * Purpose: Opens a group inside a native h5 file. - * - * Return: Success: Pointer to a group struct - * - * Failure: NULL - * - *------------------------------------------------------------------------- - */ -static void * -H5VL_native_group_open(void *obj, H5VL_loc_params_t loc_params, const char *name, - hid_t H5_ATTR_UNUSED gapl_id, hid_t H5_ATTR_UNUSED dxpl_id, void H5_ATTR_UNUSED **req) -{ - H5G_loc_t loc; /* Location to open group */ - H5G_t *grp = NULL; /* New group opend */ - void *ret_value; - - FUNC_ENTER_NOAPI_NOINIT - - /* Set up the location */ - if(H5G_loc_real(obj, loc_params.obj_type, &loc) < 0) - HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, NULL, "not a file or file object") - - /* Open the group */ - if((grp = H5G__open_name(&loc, name)) == NULL) - HGOTO_ERROR(H5E_SYM, H5E_CANTOPENOBJ, NULL, "unable to open group") - - ret_value = (void *)grp; - -done: - FUNC_LEAVE_NOAPI(ret_value) -} /* end H5VL_native_group_open() */ - - -/*------------------------------------------------------------------------- - * Function: H5VL_native_group_get - * - * Purpose: Gets data about a group - * - * Return: SUCCEED/FAIL - * - *------------------------------------------------------------------------- - */ -static herr_t -H5VL_native_group_get(void *obj, H5VL_group_get_t get_type, hid_t H5_ATTR_UNUSED dxpl_id, void H5_ATTR_UNUSED **req, va_list arguments) -{ - herr_t ret_value = SUCCEED; /* Return value */ - - FUNC_ENTER_NOAPI_NOINIT - - switch(get_type) { - /* H5Gget_create_plist */ - case H5VL_GROUP_GET_GCPL: - { - hid_t *new_gcpl_id = va_arg(arguments, hid_t *); - H5G_t *grp = (H5G_t *)obj; - - if((*new_gcpl_id = H5G_get_create_plist(grp)) < 0) - HGOTO_ERROR(H5E_ARGS, H5E_CANTGET, FAIL, "can't get creation property list for group") - break; - } - /* H5Gget_info */ - case H5VL_GROUP_GET_INFO: - { - H5VL_loc_params_t loc_params = va_arg(arguments, H5VL_loc_params_t); - H5G_info_t *group_info = va_arg(arguments, H5G_info_t *); - H5G_loc_t loc; - - if(H5G_loc_real(obj, loc_params.obj_type, &loc) < 0) - HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a file or file object") - - if(loc_params.type == H5VL_OBJECT_BY_SELF) { - /* H5Gget_info */ - - /* Retrieve the group's information */ - if(H5G__obj_info(loc.oloc, group_info) < 0) - HGOTO_ERROR(H5E_SYM, H5E_CANTGET, FAIL, "can't retrieve group info") - } - else if (loc_params.type == H5VL_OBJECT_BY_NAME) { - /* H5Gget_info_by_name */ - - /* Retrieve the group's information */ - if(H5G__get_info_by_name(&loc, loc_params.loc_data.loc_by_name.name, group_info) < 0) - HGOTO_ERROR(H5E_SYM, H5E_CANTGET, FAIL, "can't retrieve group info") - } - else if(loc_params.type == H5VL_OBJECT_BY_IDX) { - /* H5Gget_info_by_idx */ - - /* Retrieve the group's information */ - if(H5G__get_info_by_idx(&loc, loc_params.loc_data.loc_by_idx.name, loc_params.loc_data.loc_by_idx.idx_type, - loc_params.loc_data.loc_by_idx.order, loc_params.loc_data.loc_by_idx.n, group_info) < 0) - HGOTO_ERROR(H5E_SYM, H5E_CANTGET, FAIL, "can't retrieve group info") - } - else { - HGOTO_ERROR(H5E_VOL, H5E_UNSUPPORTED, FAIL, "unknown get info parameters") - } - break; - } - default: - HGOTO_ERROR(H5E_VOL, H5E_CANTGET, FAIL, "can't get this type of information from group") - } - -done: - FUNC_LEAVE_NOAPI(ret_value) -} /* end H5VL_native_group_get() */ - - -/*------------------------------------------------------------------------- - * Function: H5VL_native_group_specific - * - * Purpose: Specific operations for groups - * - * Return: SUCCEED/FAIL - * - *------------------------------------------------------------------------- - */ -static herr_t -H5VL_native_group_specific(void *obj, H5VL_group_specific_t specific_type, - hid_t H5_ATTR_UNUSED dxpl_id, void H5_ATTR_UNUSED **req, va_list arguments) -{ - H5G_t *grp = (H5G_t *)obj; - herr_t ret_value = SUCCEED; /* Return value */ - - FUNC_ENTER_NOAPI_NOINIT - - switch(specific_type) { - case H5VL_GROUP_FLUSH: - { - hid_t group_id = va_arg(arguments, hid_t); - - /* Flush object's metadata to file */ - if(H5O_flush_common(&grp->oloc, group_id) < 0) - HGOTO_ERROR(H5E_SYM, H5E_CANTFLUSH, FAIL, "unable to flush group") - - break; - } - case H5VL_GROUP_REFRESH: - { - hid_t group_id = va_arg(arguments, hid_t); - - /* Call private function to refresh group object */ - if((H5O_refresh_metadata(group_id, grp->oloc)) < 0) - HGOTO_ERROR(H5E_SYM, H5E_CANTLOAD, FAIL, "unable to refresh group") - - break; - } - default: - HGOTO_ERROR(H5E_VOL, H5E_UNSUPPORTED, FAIL, "invalid specific operation") - } - -done: - FUNC_LEAVE_NOAPI(ret_value) -} /* end H5VL_native_group_specific() */ - - -/*------------------------------------------------------------------------- - * Function: H5VL_native_group_close - * - * Purpose: Closes a group. - * - * Return: SUCCEED/FAIL (the group will not be closed on failure) - * - *------------------------------------------------------------------------- - */ -static herr_t -H5VL_native_group_close(void *grp, hid_t H5_ATTR_UNUSED dxpl_id, void H5_ATTR_UNUSED **req) -{ - herr_t ret_value = SUCCEED; /* Return value */ - - FUNC_ENTER_NOAPI_NOINIT - - if(H5G_close((H5G_t *)grp) < 0) - HGOTO_ERROR(H5E_SYM, H5E_CLOSEERROR, FAIL, "can't close group") - -done: - FUNC_LEAVE_NOAPI(ret_value) -} /* end H5VL_native_group_close() */ - - -/*------------------------------------------------------------------------- - * Function: H5VL_native_link_create - * - * Purpose: Creates an hard/soft/UD/external links. - * - * Return: Non-negative on success/Negative on failure - * - * Programmer: Mohamad Chaarawi - * April, 2012 - * - *------------------------------------------------------------------------- - */ -static herr_t -H5VL_native_link_create(H5VL_link_create_type_t create_type, void *obj, H5VL_loc_params_t loc_params, - hid_t lcpl_id, hid_t H5_ATTR_UNUSED lapl_id, hid_t H5_ATTR_UNUSED dxpl_id, void H5_ATTR_UNUSED **req) -{ - H5P_genplist_t *plist; /* Property list pointer */ - herr_t ret_value = SUCCEED; /* Return value */ - - FUNC_ENTER_NOAPI_NOINIT - - /* Get the plist structure */ - if(NULL == (plist = (H5P_genplist_t *)H5I_object(lcpl_id))) - HGOTO_ERROR(H5E_ATOM, H5E_BADATOM, FAIL, "can't find object for ID"); - - switch(create_type) { - case H5VL_LINK_CREATE_HARD: - { - H5G_loc_t cur_loc; - H5G_loc_t link_loc; - void *cur_obj; - H5VL_loc_params_t cur_params; - - if(H5P_get(plist, H5VL_PROP_LINK_TARGET, &cur_obj) < 0) - HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, FAIL, "can't get property value for current location id") - if(H5P_get(plist, H5VL_PROP_LINK_TARGET_LOC_PARAMS, &cur_params) < 0) - HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, FAIL, "can't get property value for current name") - - if(NULL != cur_obj && H5G_loc_real(cur_obj, cur_params.obj_type, &cur_loc) < 0) - HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a file or file object") - if(NULL != obj && H5G_loc_real(obj, loc_params.obj_type, &link_loc) < 0) - HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a file or file object") - - /* H5Lcreate_hard */ - if(H5VL_OBJECT_BY_NAME == cur_params.type) { - H5G_loc_t *cur_loc_p, *link_loc_p; - - /* Set up current & new location pointers */ - cur_loc_p = &cur_loc; - link_loc_p = &link_loc; - if(NULL == cur_obj) - cur_loc_p = link_loc_p; - else if(NULL == obj) - link_loc_p = cur_loc_p; - else if(cur_loc_p->oloc->file != link_loc_p->oloc->file) - HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "source and destination should be in the same file.") - - /* Create the link */ - if((ret_value = H5L_create_hard(cur_loc_p, cur_params.loc_data.loc_by_name.name, - link_loc_p, loc_params.loc_data.loc_by_name.name, lcpl_id)) < 0) - HGOTO_ERROR(H5E_LINK, H5E_CANTINIT, FAIL, "unable to create link") - } - else { /* H5Olink */ - /* Link to the object */ - if(H5L_link(&link_loc, loc_params.loc_data.loc_by_name.name, &cur_loc, lcpl_id) < 0) - HGOTO_ERROR(H5E_OHDR, H5E_CANTINIT, FAIL, "unable to create link") - } - break; - } - case H5VL_LINK_CREATE_SOFT: - { - char *target_name; - H5G_loc_t link_loc; /* Group location for new link */ - - if(H5G_loc_real(obj, loc_params.obj_type, &link_loc) < 0) - HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a file or file object") - - if(H5P_get(plist, H5VL_PROP_LINK_TARGET_NAME, &target_name) < 0) - HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, FAIL, "can't get property value for targe name") - - /* Create the link */ - if((ret_value = H5L_create_soft(target_name, &link_loc, loc_params.loc_data.loc_by_name.name, lcpl_id)) < 0) - HGOTO_ERROR(H5E_LINK, H5E_CANTINIT, FAIL, "unable to create link") - break; - } - case H5VL_LINK_CREATE_UD: - { - H5G_loc_t link_loc; /* Group location for new link */ - H5L_type_t link_type; - void *udata; - size_t udata_size; - - if(H5G_loc_real(obj, loc_params.obj_type, &link_loc) < 0) - HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a file or file object") - - if(H5P_get(plist, H5VL_PROP_LINK_TYPE, &link_type) < 0) - HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, FAIL, "can't get property value for link type") - if(H5P_get(plist, H5VL_PROP_LINK_UDATA, &udata) < 0) - HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, FAIL, "can't get property value for udata") - if(H5P_get(plist, H5VL_PROP_LINK_UDATA_SIZE, &udata_size) < 0) - HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, FAIL, "can't get property value for udata size") - - /* Create link */ - if(H5L__create_ud(&link_loc, loc_params.loc_data.loc_by_name.name, udata, udata_size, - link_type, lcpl_id) < 0) - HGOTO_ERROR(H5E_LINK, H5E_CANTINIT, FAIL, "unable to create link") - break; - } - default: - HGOTO_ERROR(H5E_LINK, H5E_CANTINIT, FAIL, "invalid link creation call") - } -done: - FUNC_LEAVE_NOAPI(ret_value) -} /* end H5VL_native_link_create() */ - - -/*------------------------------------------------------------------------- - * Function: H5VL_native_link_copy - * - * Purpose: Renames an object within an HDF5 file and copies it to a new - * group. The original name SRC is unlinked from the group graph - * and then inserted with the new name DST (which can specify a - * new path for the object) as an atomic operation. The names - * are interpreted relative to SRC_LOC_ID and - * DST_LOC_ID, which are either file IDs or group ID. - * - * Return: Non-negative on success/Negative on failure - * - * Programmer: Mohamad Chaarawi - * April, 2012 - * - *------------------------------------------------------------------------- - */ -static herr_t -H5VL_native_link_copy(void *src_obj, H5VL_loc_params_t loc_params1, - void *dst_obj, H5VL_loc_params_t loc_params2, - hid_t lcpl_id, hid_t H5_ATTR_UNUSED lapl_id, hid_t H5_ATTR_UNUSED dxpl_id, void H5_ATTR_UNUSED **req) -{ - H5G_loc_t src_loc, *src_loc_p; - H5G_loc_t dst_loc, *dst_loc_p; - herr_t ret_value = SUCCEED; /* Return value */ - - FUNC_ENTER_NOAPI_NOINIT - - if(NULL != src_obj && H5G_loc_real(src_obj, loc_params1.obj_type, &src_loc) < 0) - HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a file or file object") - if(NULL != dst_obj && H5G_loc_real(dst_obj, loc_params2.obj_type, &dst_loc) < 0) - HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a file or file object") - - /* Set up src & dst location pointers */ - src_loc_p = &src_loc; - dst_loc_p = &dst_loc; - if(NULL == src_obj) - src_loc_p = dst_loc_p; - else if(NULL == dst_obj) - dst_loc_p = src_loc_p; - - /* Copy the link */ - if(H5L_move(src_loc_p, loc_params1.loc_data.loc_by_name.name, - dst_loc_p, loc_params2.loc_data.loc_by_name.name, - TRUE, lcpl_id) < 0) - HGOTO_ERROR(H5E_LINK, H5E_CANTCOPY, FAIL, "unable to copy link") - -done: - FUNC_LEAVE_NOAPI(ret_value) -} /* end H5VL_native_link_copy() */ - - -/*------------------------------------------------------------------------- - * Function: H5VL_native_link_move - * - * Purpose: Renames an object within an HDF5 file and moves it to a new - * group. The original name SRC is unlinked from the group graph - * and then inserted with the new name DST (which can specify a - * new path for the object) as an atomic operation. The names - * are interpreted relative to SRC_LOC_ID and - * DST_LOC_ID, which are either file IDs or group ID. - * - * Return: Non-negative on success/Negative on failure - * - * Programmer: Mohamad Chaarawi - * April, 2012 - * - *------------------------------------------------------------------------- - */ -static herr_t -H5VL_native_link_move(void *src_obj, H5VL_loc_params_t loc_params1, - void *dst_obj, H5VL_loc_params_t loc_params2, - hid_t lcpl_id, hid_t H5_ATTR_UNUSED lapl_id, hid_t H5_ATTR_UNUSED dxpl_id, void H5_ATTR_UNUSED **req) -{ - H5G_loc_t src_loc, *src_loc_p; - H5G_loc_t dst_loc, *dst_loc_p; - herr_t ret_value = SUCCEED; /* Return value */ - - FUNC_ENTER_NOAPI_NOINIT - - if(NULL != src_obj && H5G_loc_real(src_obj, loc_params1.obj_type, &src_loc) < 0) - HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a file or file object") - if(NULL != dst_obj && H5G_loc_real(dst_obj, loc_params2.obj_type, &dst_loc) < 0) - HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a file or file object") - - /* Set up src & dst location pointers */ - src_loc_p = &src_loc; - dst_loc_p = &dst_loc; - if(NULL == src_obj) - src_loc_p = dst_loc_p; - else if(NULL == dst_obj) - dst_loc_p = src_loc_p; - - /* Move the link */ - if(H5L_move(src_loc_p, loc_params1.loc_data.loc_by_name.name, - dst_loc_p, loc_params2.loc_data.loc_by_name.name, - FALSE, lcpl_id) < 0) - HGOTO_ERROR(H5E_LINK, H5E_CANTMOVE, FAIL, "unable to move link") - -done: - FUNC_LEAVE_NOAPI(ret_value) -} /* end H5VL_native_link_move() */ - - -/*------------------------------------------------------------------------- - * Function: H5VL_native_link_get - * - * Purpose: Gets certain data about a link - * - * Return: Success: 0 - * Failure: -1 - * - * Programmer: Mohamad Chaarawi - * April, 2012 - * - *------------------------------------------------------------------------- - */ -static herr_t -H5VL_native_link_get(void *obj, H5VL_loc_params_t loc_params, H5VL_link_get_t get_type, - hid_t H5_ATTR_UNUSED dxpl_id, void H5_ATTR_UNUSED **req, va_list arguments) -{ - H5G_loc_t loc; - herr_t ret_value = SUCCEED; /* Return value */ - - FUNC_ENTER_NOAPI_NOINIT - - if(H5G_loc_real(obj, loc_params.obj_type, &loc) < 0) - HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a file or file object") - - switch(get_type) { - /* H5Lget_info/H5Lget_info_by_idx */ - case H5VL_LINK_GET_INFO: - { - H5L_info_t *linfo = va_arg(arguments, H5L_info_t *); - - /* Get the link information */ - if(loc_params.type == H5VL_OBJECT_BY_NAME) { /* H5Lget_info */ - if(H5L_get_info(&loc, loc_params.loc_data.loc_by_name.name, linfo) < 0) - HGOTO_ERROR(H5E_LINK, H5E_NOTFOUND, FAIL, "unable to get link info") - } - else if(loc_params.type == H5VL_OBJECT_BY_IDX) { /* H5Lget_info_by_idx */ - - if(H5L_get_info_by_idx(&loc, loc_params.loc_data.loc_by_idx.name, loc_params.loc_data.loc_by_idx.idx_type, - loc_params.loc_data.loc_by_idx.order, loc_params.loc_data.loc_by_idx.n, linfo) < 0) - HGOTO_ERROR(H5E_LINK, H5E_NOTFOUND, FAIL, "unable to get link info") - } - else - HGOTO_ERROR(H5E_LINK, H5E_NOTFOUND, FAIL, "unable to get link info") - break; - } - /* H5Lget_name_by_idx */ - case H5VL_LINK_GET_NAME: - { - char *name = va_arg(arguments, char *); - size_t size = va_arg(arguments, size_t); - ssize_t *ret = va_arg(arguments, ssize_t *); - - /* Get the link name */ - if((*ret = H5L_get_name_by_idx(&loc, loc_params.loc_data.loc_by_idx.name, loc_params.loc_data.loc_by_idx.idx_type, - loc_params.loc_data.loc_by_idx.order, loc_params.loc_data.loc_by_idx.n, name, size)) < 0) - HGOTO_ERROR(H5E_LINK, H5E_NOTFOUND, FAIL, "unable to get link info") - - break; - } - /* H5Lget_val/H5Lget_val_by_idx */ - case H5VL_LINK_GET_VAL: - { - void *buf = va_arg(arguments, void *); - size_t size = va_arg(arguments, size_t); - - /* Get the link information */ - if(loc_params.type == H5VL_OBJECT_BY_NAME) { /* H5Lget_val */ - if(H5L_get_val(&loc, loc_params.loc_data.loc_by_name.name, buf, size) < 0) - HGOTO_ERROR(H5E_LINK, H5E_NOTFOUND, FAIL, "unable to get link value") - } - else if(loc_params.type == H5VL_OBJECT_BY_IDX) { /* H5Lget_val_by_idx */ - - if(H5L_get_val_by_idx(&loc, loc_params.loc_data.loc_by_idx.name, loc_params.loc_data.loc_by_idx.idx_type, - loc_params.loc_data.loc_by_idx.order, loc_params.loc_data.loc_by_idx.n, buf, size) < 0) - HGOTO_ERROR(H5E_LINK, H5E_NOTFOUND, FAIL, "unable to get link val") - } - else - HGOTO_ERROR(H5E_LINK, H5E_NOTFOUND, FAIL, "unable to get link val") - - break; - } - default: - HGOTO_ERROR(H5E_VOL, H5E_CANTGET, FAIL, "can't get this type of information from link") - } - -done: - FUNC_LEAVE_NOAPI(ret_value) -} /* end H5VL_native_link_get() */ - - -/*------------------------------------------------------------------------- - * Function: H5VL_native_link_specific - * - * Purpose: Specific operations with links - * - * Return: Success: 0 - * Failure: -1 - * - * Programmer: Mohamad Chaarawi - * April, 2012 - * - *------------------------------------------------------------------------- - */ -static herr_t -H5VL_native_link_specific(void *obj, H5VL_loc_params_t loc_params, H5VL_link_specific_t specific_type, - hid_t H5_ATTR_UNUSED dxpl_id, void H5_ATTR_UNUSED **req, va_list arguments) -{ - herr_t ret_value = SUCCEED; /* Return value */ - - FUNC_ENTER_NOAPI_NOINIT - - switch(specific_type) { - case H5VL_LINK_EXISTS: - { - htri_t *ret = va_arg(arguments, htri_t *); - H5G_loc_t loc; - - if(H5G_loc_real(obj, loc_params.obj_type, &loc) < 0) - HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a file or file object") - - /* Check for the existence of the link */ - if((*ret = H5L_exists(&loc, loc_params.loc_data.loc_by_name.name)) < 0) - HGOTO_ERROR(H5E_LINK, H5E_NOTFOUND, FAIL, "unable to specific link info") - break; - } - case H5VL_LINK_ITER: - { - H5G_loc_t loc; - hbool_t recursive = va_arg(arguments, int); - H5_index_t idx_type = va_arg(arguments, H5_index_t); - H5_iter_order_t order = va_arg(arguments, H5_iter_order_t); - hsize_t *idx_p = va_arg(arguments, hsize_t *); - H5L_iterate_t op = va_arg(arguments, H5L_iterate_t); - void *op_data = va_arg(arguments, void *); - - /* Get the location */ - if(H5G_loc_real(obj, loc_params.obj_type, &loc) < 0) - HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a location") - - /* Visit or iterate over the links */ - if(loc_params.type == H5VL_OBJECT_BY_SELF) { - if(recursive) { - /* H5Lvisit */ - if((ret_value = H5G_visit(&loc, ".", idx_type, order, op, op_data)) < 0) - HGOTO_ERROR(H5E_LINK, H5E_BADITER, FAIL, "link visitation failed") - } - else { - /* H5Literate */ - if((ret_value = H5L_iterate(&loc, ".", idx_type, order, idx_p, op, op_data)) < 0) - HGOTO_ERROR(H5E_LINK, H5E_BADITER, FAIL, "error iterating over links") - } - } - else if(loc_params.type == H5VL_OBJECT_BY_NAME) { - if(recursive) { - /* H5Lvisit_by_name */ - if((ret_value = H5G_visit(&loc, loc_params.loc_data.loc_by_name.name, idx_type, order, op, op_data)) < 0) - HGOTO_ERROR(H5E_LINK, H5E_BADITER, FAIL, "link visitation failed") - } - else { - /* H5Literate_by_name */ - if((ret_value = H5L_iterate(&loc, loc_params.loc_data.loc_by_name.name, idx_type, order, idx_p, op, op_data)) < 0) - HGOTO_ERROR(H5E_LINK, H5E_BADITER, FAIL, "error iterating over links") - } - } - else{ - HGOTO_ERROR(H5E_LINK, H5E_UNSUPPORTED, FAIL, "unknown link iterate params") - } - - break; - } - case H5VL_LINK_DELETE: - { - H5G_loc_t loc; - - if(H5G_loc_real(obj, loc_params.obj_type, &loc) < 0) - HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a file or file object") - - /* Unlink */ - if(loc_params.type == H5VL_OBJECT_BY_NAME) { /* H5Ldelete */ - if(H5L_delete(&loc, loc_params.loc_data.loc_by_name.name) < 0) - HGOTO_ERROR(H5E_LINK, H5E_CANTDELETE, FAIL, "unable to delete link") - } - else if(loc_params.type == H5VL_OBJECT_BY_IDX) { /* H5Ldelete_by_idx */ - - if(H5L_delete_by_idx(&loc, loc_params.loc_data.loc_by_idx.name, loc_params.loc_data.loc_by_idx.idx_type, - loc_params.loc_data.loc_by_idx.order, loc_params.loc_data.loc_by_idx.n) < 0) - HGOTO_ERROR(H5E_LINK, H5E_CANTDELETE, FAIL, "unable to delete link") - } - else - HGOTO_ERROR(H5E_LINK, H5E_CANTDELETE, FAIL, "unable to delete link") - break; - } - default: - HGOTO_ERROR(H5E_VOL, H5E_UNSUPPORTED, FAIL, "invalid specific operation") - } - -done: - FUNC_LEAVE_NOAPI(ret_value) -} /* end H5VL_native_link_specific() */ - - -/*------------------------------------------------------------------------- - * Function: H5VL_native_object_open - * - * Purpose: Opens a object inside a native h5 file. - * - * Return: Success: object id. - * Failure: NULL - * - * Programmer: Mohamad Chaarawi - * March, 2012 - * - *------------------------------------------------------------------------- - */ -static void * -H5VL_native_object_open(void *obj, H5VL_loc_params_t loc_params, H5I_type_t *opened_type, - hid_t H5_ATTR_UNUSED dxpl_id, void H5_ATTR_UNUSED **req) -{ - H5G_loc_t loc; - void *ret_value = NULL; - - FUNC_ENTER_NOAPI_NOINIT - - if(H5G_loc_real(obj, loc_params.obj_type, &loc) < 0) - HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, NULL, "not a file or file object") - - switch(loc_params.type) { - case H5VL_OBJECT_BY_NAME: - { - /* Open the object */ - if(NULL == (ret_value = H5O_open_name(&loc, loc_params.loc_data.loc_by_name.name, opened_type))) - HGOTO_ERROR(H5E_OHDR, H5E_CANTOPENOBJ, NULL, "unable to open object by name") - break; - } - case H5VL_OBJECT_BY_IDX: - { - /* Open the object */ - if(NULL == (ret_value = H5O_open_by_idx(&loc, loc_params.loc_data.loc_by_idx.name, loc_params.loc_data.loc_by_idx.idx_type, - loc_params.loc_data.loc_by_idx.order, loc_params.loc_data.loc_by_idx.n, opened_type))) - HGOTO_ERROR(H5E_OHDR, H5E_CANTOPENOBJ, NULL, "unable to open object by index") - break; - } - case H5VL_OBJECT_BY_ADDR: - { - /* Open the object */ - if(NULL == (ret_value = H5O_open_by_addr(&loc, loc_params.loc_data.loc_by_addr.addr, opened_type))) - HGOTO_ERROR(H5E_OHDR, H5E_CANTOPENOBJ, NULL, "unable to open object by address") - break; - } - case H5VL_OBJECT_BY_REF: - { - hid_t temp_id = H5I_INVALID_HID; - H5F_t *file = NULL; - - /* Get the file pointer from the entry */ - file = loc.oloc->file; - - /* Create reference */ - if((temp_id = H5R__dereference(file, loc_params.loc_data.loc_by_ref.lapl_id, - loc_params.loc_data.loc_by_ref.ref_type, - loc_params.loc_data.loc_by_ref._ref)) < 0) - HGOTO_ERROR(H5E_REFERENCE, H5E_CANTOPENOBJ, NULL, "unable to dereference object") - - *opened_type = H5I_get_type(temp_id); - if(NULL == (ret_value = H5I_remove(temp_id))) - HDONE_ERROR(H5E_SYM, H5E_CANTOPENOBJ, NULL, "unable to open object") - break; - } - case H5VL_OBJECT_BY_SELF: - default: - HGOTO_ERROR(H5E_VOL, H5E_UNSUPPORTED, NULL, "unknown open parameters") - } - -done: - FUNC_LEAVE_NOAPI(ret_value) -} /* end H5VL_native_object_open() */ - - -/*------------------------------------------------------------------------- - * Function: H5VL_native_object_copy - * - * Purpose: Copys a object inside a native h5 file. - * - * Return: Success: object id. - * Failure: NULL - * - * Programmer: Mohamad Chaarawi - * March, 2012 - * - *------------------------------------------------------------------------- - */ -static herr_t -H5VL_native_object_copy(void *src_obj, H5VL_loc_params_t loc_params1, const char *src_name, - void *dst_obj, H5VL_loc_params_t loc_params2, const char *dst_name, - hid_t ocpypl_id, hid_t lcpl_id, hid_t H5_ATTR_UNUSED dxpl_id, void H5_ATTR_UNUSED **req) -{ - H5G_loc_t src_loc; /* Source object group location */ - H5G_loc_t dst_loc; /* Destination group location */ - herr_t ret_value = FAIL; - - FUNC_ENTER_NOAPI_NOINIT - - /* get location for objects */ - if(H5G_loc_real(src_obj, loc_params1.obj_type, &src_loc) < 0) - HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a file or file object") - if(H5G_loc_real(dst_obj, loc_params2.obj_type, &dst_loc) < 0) - HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a file or file object") - - /* Open the object */ - if((ret_value = H5O_copy(&src_loc, src_name, &dst_loc, dst_name, ocpypl_id, lcpl_id)) < 0) - HGOTO_ERROR(H5E_SYM, H5E_CANTCOPY, FAIL, "unable to copy object") -done: - FUNC_LEAVE_NOAPI(ret_value) -} /* end H5VL_native_object_copy() */ - - -/*------------------------------------------------------------------------- - * Function: H5VL_native_object_get - * - * Purpose: Gets certain data about an object - * - * Return: SUCCEED/FAIL - * - * Programmer: Mohamad Chaarawi - * March, 2012 - * - *------------------------------------------------------------------------- - */ -static herr_t -H5VL_native_object_get(void *obj, H5VL_loc_params_t loc_params, H5VL_object_get_t get_type, - hid_t H5_ATTR_UNUSED dxpl_id, void H5_ATTR_UNUSED **req, va_list arguments) -{ - herr_t ret_value = SUCCEED; /* Return value */ - H5G_loc_t loc; /* Location of group */ - - FUNC_ENTER_NOAPI_NOINIT - - if(H5G_loc_real(obj, loc_params.obj_type, &loc) < 0) - HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a file or file object") - - switch(get_type) { - /* H5Rget_region */ - case H5VL_REF_GET_REGION: - { - hid_t *ret = va_arg(arguments, hid_t *); - H5R_type_t H5_ATTR_UNUSED ref_type = va_arg(arguments, H5R_type_t); - void *ref = va_arg(arguments, void *); - H5S_t *space = NULL; /* Dataspace object */ - - /* Get the dataspace with the correct region selected */ - if((space = H5R__get_region(loc.oloc->file, ref)) == NULL) - HGOTO_ERROR(H5E_REFERENCE, H5E_CANTGET, FAIL, "unable to retrieve region") - - /* Atomize */ - if((*ret = H5I_register(H5I_DATASPACE, space, TRUE)) < 0) - HGOTO_ERROR(H5E_ATOM, H5E_CANTREGISTER, FAIL, "unable to register dataspace atom") - - break; - } - /* H5Rget_obj_type2 */ - case H5VL_REF_GET_TYPE: - { - H5O_type_t *obj_type = va_arg(arguments, H5O_type_t *); - H5R_type_t ref_type = va_arg(arguments, H5R_type_t); - void *ref = va_arg(arguments, void *); - - /* Get the object information */ - if(H5R__get_obj_type(loc.oloc->file, ref_type, ref, obj_type) < 0) - HGOTO_ERROR(H5E_REFERENCE, H5E_CANTGET, FAIL, "unable to determine object type") - break; - } - /* H5Rget_name */ - case H5VL_REF_GET_NAME: - { - ssize_t *ret = va_arg(arguments, ssize_t *); - char *name = va_arg(arguments, char *); - size_t size = va_arg(arguments, size_t); - H5R_type_t ref_type = va_arg(arguments, H5R_type_t); - void *ref = va_arg(arguments, void *); - - /* Get name */ - if((*ret = H5R__get_name(loc.oloc->file, ref_type, ref, name, size)) < 0) - HGOTO_ERROR(H5E_REFERENCE, H5E_CANTGET, FAIL, "unable to determine object path") - break; - } - default: - HGOTO_ERROR(H5E_VOL, H5E_CANTGET, FAIL, "can't get this type of information from object") - } -done: - FUNC_LEAVE_NOAPI(ret_value) -} /* end H5VL_native_object_get() */ - - -/*------------------------------------------------------------------------- - * Function: H5VL_native_object_specific - * - * Purpose: Perform a driver specific operation for an objectibute - * - * Return: SUCCEED/FAIL - * - *------------------------------------------------------------------------- - */ -static herr_t -H5VL_native_object_specific(void *obj, H5VL_loc_params_t loc_params, H5VL_object_specific_t specific_type, - hid_t H5_ATTR_UNUSED dxpl_id, void H5_ATTR_UNUSED **req, va_list arguments) -{ - H5G_loc_t loc; - herr_t ret_value = SUCCEED; /* Return value */ - - FUNC_ENTER_NOAPI_NOINIT - - if(H5G_loc_real(obj, loc_params.obj_type, &loc) < 0) - HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a file or file object") - - switch(specific_type) { - /* H5Oincr_refcount / H5Odecr_refcount */ - case H5VL_OBJECT_CHANGE_REF_COUNT: - { - int update_ref = va_arg(arguments, int); - H5O_loc_t *oloc = loc.oloc; - - if(H5O_link(oloc, update_ref) < 0) - HGOTO_ERROR(H5E_OHDR, H5E_LINKCOUNT, FAIL, "modifying object link count failed") - - break; - } - /* H5Oexists_by_name */ - case H5VL_OBJECT_EXISTS: - { - htri_t *ret = va_arg(arguments, htri_t *); - - if(loc_params.type == H5VL_OBJECT_BY_NAME) { - /* Check if the object exists */ - if((*ret = H5G_loc_exists(&loc, loc_params.loc_data.loc_by_name.name)) < 0) - HGOTO_ERROR(H5E_OHDR, H5E_CANTGET, FAIL, "unable to determine if '%s' exists", - loc_params.loc_data.loc_by_name.name) - } - else { - HGOTO_ERROR(H5E_VOL, H5E_UNSUPPORTED, FAIL, "unknown object exists parameters") - } - break; - } - case H5VL_OBJECT_VISIT: - { - H5_index_t idx_type = va_arg(arguments, H5_index_t); - H5_iter_order_t order = va_arg(arguments, H5_iter_order_t); - H5O_iterate_t op = va_arg(arguments, H5O_iterate_t); - void *op_data = va_arg(arguments, void *); - unsigned fields = va_arg(arguments, unsigned); - - /* Call internal object visitation routine */ - if(loc_params.type == H5VL_OBJECT_BY_SELF) { - /* H5Ovisit */ - if((ret_value = H5O__visit(&loc, ".", idx_type, order, op, op_data, fields)) < 0) - HGOTO_ERROR(H5E_OHDR, H5E_BADITER, FAIL, "object visitation failed") - } - else if(loc_params.type == H5VL_OBJECT_BY_NAME) { - /* H5Ovisit_by_name */ - if((ret_value = H5O__visit(&loc, loc_params.loc_data.loc_by_name.name, idx_type, order, op, op_data, fields)) < 0) - HGOTO_ERROR(H5E_OHDR, H5E_BADITER, FAIL, "object visitation failed") - } - else - HGOTO_ERROR(H5E_VOL, H5E_UNSUPPORTED, FAIL, "unknown object visit params"); - break; - } - case H5VL_OBJECT_FLUSH: - { - hid_t oid = va_arg(arguments, hid_t); - - /* Flush the object's metadata */ - if(H5O_flush(loc.oloc, oid) < 0) - HGOTO_ERROR(H5E_OHDR, H5E_CANTFLUSH, FAIL, "unable to flush object") - - break; - } - case H5VL_OBJECT_REFRESH: - { - hid_t oid = va_arg(arguments, hid_t); - H5O_loc_t *oloc = loc.oloc; - - /* Refresh the metadata */ - if(H5O_refresh_metadata(oid, *oloc) < 0) - HGOTO_ERROR(H5E_OHDR, H5E_CANTLOAD, FAIL, "unable to refresh object") - - break; - } - case H5VL_REF_CREATE: - { - void *ref = va_arg(arguments, void *); - const char *name = va_arg(arguments, char *); - H5R_type_t ref_type = va_arg(arguments, H5R_type_t); - hid_t space_id = va_arg(arguments, hid_t); - H5S_t *space = NULL; /* Pointer to dataspace containing region */ - - if(space_id != (-1) && (NULL == (space = (H5S_t *)H5I_object_verify(space_id, H5I_DATASPACE)))) - HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a dataspace") - - /* Create reference */ - if(H5R__create(ref, &loc, name, ref_type, space) < 0) - HGOTO_ERROR(H5E_REFERENCE, H5E_CANTCREATE, FAIL, "unable to create reference") - - break; - } - default: - HGOTO_ERROR(H5E_VOL, H5E_CANTGET, FAIL, "can't recognize this operation type") - } - -done: - FUNC_LEAVE_NOAPI(ret_value) -} /* end H5VL_native_object_specific() */ - - -/*------------------------------------------------------------------------- - * Function: H5VL_native_object_optional - * - * Purpose: Perform a driver specific operation for an objectibute - * - * Return: Success: 0 - * Failure: -1 - * - * Programmer: Mohamad Chaarawi - * April, 2012 - * - *------------------------------------------------------------------------- - */ -static herr_t -H5VL_native_object_optional(void *obj, hid_t H5_ATTR_UNUSED dxpl_id, void H5_ATTR_UNUSED **req, va_list arguments) -{ - H5VL_object_optional_t optional_type = va_arg(arguments, H5VL_object_optional_t); - H5VL_loc_params_t loc_params = va_arg(arguments, H5VL_loc_params_t); - H5G_loc_t loc; /* Location of group */ - herr_t ret_value = SUCCEED; /* Return value */ - - FUNC_ENTER_NOAPI_NOINIT - - if(H5G_loc_real(obj, loc_params.obj_type, &loc) < 0) - HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a file or file object") - - switch(optional_type) { - /* H5Oget_info / H5Oget_info_by_name / H5Oget_info_by_idx */ - case H5VL_OBJECT_GET_INFO: - { - H5O_info_t *obj_info = va_arg(arguments, H5O_info_t *); - unsigned fields = va_arg(arguments, unsigned); - - if(loc_params.type == H5VL_OBJECT_BY_SELF) { /* H5Oget_info */ - /* Retrieve the object's information */ - if(H5G_loc_info(&loc, ".", obj_info, fields) < 0) - HGOTO_ERROR(H5E_OHDR, H5E_NOTFOUND, FAIL, "object not found") - } - else if(loc_params.type == H5VL_OBJECT_BY_NAME) { /* H5Oget_info_by_name */ - /* Retrieve the object's information */ - if(H5G_loc_info(&loc, loc_params.loc_data.loc_by_name.name, obj_info, fields) < 0) - HGOTO_ERROR(H5E_OHDR, H5E_NOTFOUND, FAIL, "object not found") - } - else if(loc_params.type == H5VL_OBJECT_BY_IDX) { /* H5Oget_info_by_idx */ - H5G_loc_t obj_loc; /* Location used to open group */ - H5G_name_t obj_path; /* Opened object group hier. path */ - H5O_loc_t obj_oloc; /* Opened object object location */ - - /* Set up opened group location to fill in */ - obj_loc.oloc = &obj_oloc; - obj_loc.path = &obj_path; - H5G_loc_reset(&obj_loc); - - /* Find the object's location, according to the order in the index */ - if(H5G_loc_find_by_idx(&loc, loc_params.loc_data.loc_by_idx.name, - loc_params.loc_data.loc_by_idx.idx_type, - loc_params.loc_data.loc_by_idx.order, - loc_params.loc_data.loc_by_idx.n, &obj_loc/*out*/) < 0) - HGOTO_ERROR(H5E_OHDR, H5E_NOTFOUND, FAIL, "group not found") - - /* Retrieve the object's information */ - if(H5O_get_info(obj_loc.oloc, obj_info, fields) < 0) { - H5G_loc_free(&obj_loc); - HGOTO_ERROR(H5E_OHDR, H5E_CANTGET, FAIL, "can't retrieve object info") - } - - /* Release the object location */ - if(H5G_loc_free(&obj_loc) < 0) - HDONE_ERROR(H5E_OHDR, H5E_CANTRELEASE, FAIL, "can't free location") - } - else { - HGOTO_ERROR(H5E_VOL, H5E_UNSUPPORTED, FAIL, "unknown get info parameters") - } - break; - } - /* H5Oget_comment / H5Oget_comment_by_name */ - case H5VL_OBJECT_GET_COMMENT: - { - char *comment = va_arg(arguments, char *); - size_t bufsize = va_arg(arguments, size_t); - ssize_t *ret = va_arg(arguments, ssize_t *); - - /* Retrieve the object's comment */ - if(loc_params.type == H5VL_OBJECT_BY_SELF) { /* H5Oget_comment */ - if((*ret = H5G_loc_get_comment(&loc, ".", comment/*out*/, bufsize)) < 0) - HGOTO_ERROR(H5E_OHDR, H5E_NOTFOUND, FAIL, "object not found") - } - else if(loc_params.type == H5VL_OBJECT_BY_NAME) { /* H5Oget_comment_by_name */ - if((*ret = H5G_loc_get_comment(&loc, loc_params.loc_data.loc_by_name.name, comment/*out*/, bufsize)) < 0) - HGOTO_ERROR(H5E_OHDR, H5E_NOTFOUND, FAIL, "object not found") - } - else { - HGOTO_ERROR(H5E_VOL, H5E_UNSUPPORTED, FAIL, "unknown set_coment parameters") - } - break; - } - /* H5Oset_comment */ - case H5VL_OBJECT_SET_COMMENT: - { - const char *comment = va_arg(arguments, char *); - - if(loc_params.type == H5VL_OBJECT_BY_SELF) { /* H5Oset_comment */ - /* (Re)set the object's comment */ - if(H5G_loc_set_comment(&loc, ".", comment) < 0) - HGOTO_ERROR(H5E_OHDR, H5E_NOTFOUND, FAIL, "object not found") - } - else if(loc_params.type == H5VL_OBJECT_BY_NAME) { /* H5Oset_comment_by_name */ - /* (Re)set the object's comment */ - if(H5G_loc_set_comment(&loc, loc_params.loc_data.loc_by_name.name, comment) < 0) - HGOTO_ERROR(H5E_OHDR, H5E_NOTFOUND, FAIL, "object not found") - } - else { - HGOTO_ERROR(H5E_VOL, H5E_UNSUPPORTED, FAIL, "unknown set_coment parameters") - } - break; - } - default: - HGOTO_ERROR(H5E_VOL, H5E_CANTGET, FAIL, "can't perform this operation on object"); - } - -done: - FUNC_LEAVE_NOAPI(ret_value) -} /* end H5VL_native_object_optional() */ - - -/*------------------------------------------------------------------------- - * Function: H5VL_native_datatype_commit - * - * Purpose: Commits a datatype inside a native h5 file. - * - * Return: Success: datatype id. - * Failure: NULL - * - * Programmer: Mohamad Chaarawi - * March, 2012 - * - *------------------------------------------------------------------------- - */ -static void * -H5VL_native_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 H5_ATTR_UNUSED tapl_id, hid_t H5_ATTR_UNUSED dxpl_id, void H5_ATTR_UNUSED **req) -{ - H5G_loc_t loc; /* Location to commit datatype */ - H5T_t *dt; /* Datatype for ID */ - H5T_t *type = NULL; /* copy of the original type which will be committed */ - void *ret_value = NULL; /* Return value */ - - FUNC_ENTER_NOAPI_NOINIT - - /* check arguments */ - if(H5G_loc_real(obj, loc_params.obj_type, &loc) < 0) - HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, NULL, "not a file or file object") - - if(NULL == (dt = (H5T_t *)H5I_object_verify(type_id, H5I_DATATYPE))) - HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, NULL, "not a datatype") - - /* Check arguments. We cannot commit an immutable type because H5Tclose() - * normally fails on such types (try H5Tclose(H5T_NATIVE_INT)) but closing - * a named type should always succeed. - */ - if(H5T_STATE_NAMED == dt->shared->state || H5T_STATE_OPEN == dt->shared->state) - HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, NULL, "datatype is already committed") - if(H5T_STATE_IMMUTABLE == dt->shared->state) - HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, NULL, "datatype is immutable") - - /* Check for a "sensible" datatype to store on disk */ - if(H5T_is_sensible(dt) <= 0) - HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, NULL, "datatype is not sensible") - - /* Copy the datatype - the copied one will be the type that is - * committed, and attached to original datatype above the VOL - * layer - */ - if(NULL == (type = H5T_copy(dt, H5T_COPY_TRANSIENT))) - HGOTO_ERROR(H5E_DATATYPE, H5E_CANTINIT, NULL, "unable to copy"); - - /* Commit the datatype */ - if(NULL != name) { - /* H5Tcommit */ - if(H5T__commit_named(&loc, name, type, lcpl_id, tcpl_id) < 0) - HGOTO_ERROR(H5E_DATATYPE, H5E_CANTINIT, NULL, "unable to commit datatype") - } - else { - /* H5Tcommit_anon */ - if(H5T__commit_anon(loc.oloc->file, type, tcpl_id) < 0) - HGOTO_ERROR(H5E_DATATYPE, H5E_CANTINIT, NULL, "unable to commit datatype") - } - ret_value = (void *)type; - -done: - if(NULL == ret_value && type) - H5T_close(type); - FUNC_LEAVE_NOAPI(ret_value) -} /* end H5VL_native_datatype_commit() */ - - -/*------------------------------------------------------------------------- - * Function: H5VL_native_datatype_open - * - * Purpose: Opens a named datatype inside a native h5 file. - * - * Return: Success: datatype pointer - * Failure: NULL - * - *------------------------------------------------------------------------- - */ -static void * -H5VL_native_datatype_open(void *obj, H5VL_loc_params_t loc_params, const char *name, - hid_t H5_ATTR_UNUSED tapl_id, hid_t H5_ATTR_UNUSED dxpl_id, void H5_ATTR_UNUSED **req) -{ - H5T_t *type = NULL; /* Datatype opened in file */ - H5G_loc_t loc; /* Group location of object to open */ - void *ret_value = NULL; - - FUNC_ENTER_NOAPI_NOINIT - - if(H5G_loc_real(obj, loc_params.obj_type, &loc) < 0) - HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, NULL, "not a file or file object") - - /* Open the datatype */ - if(NULL == (type = H5T__open_name(&loc, name))) - HGOTO_ERROR(H5E_DATATYPE, H5E_CANTOPENOBJ, NULL, "unable to open named datatype") - - type->vol_obj = NULL; - - ret_value = (void *)type; - -done: - FUNC_LEAVE_NOAPI(ret_value) -} /* end H5VL_native_datatype_open() */ - - -/*------------------------------------------------------------------------- - * Function: H5VL_native_datatype_get - * - * Purpose: Gets certain information about a datatype - * - * Return: Success: 0 - * Failure: -1 - * - * Programmer: Mohamad Chaarawi - * June, 2013 - * - *------------------------------------------------------------------------- - */ -static herr_t -H5VL_native_datatype_get(void *obj, H5VL_datatype_get_t get_type, - hid_t H5_ATTR_UNUSED dxpl_id, void H5_ATTR_UNUSED **req, va_list arguments) -{ - H5T_t *dt = (H5T_t *)obj; - herr_t ret_value = SUCCEED; /* Return value */ - - FUNC_ENTER_NOAPI_NOINIT - - switch (get_type) { - case H5VL_DATATYPE_GET_BINARY: - { - ssize_t *nalloc = va_arg(arguments, ssize_t *); - void *buf = va_arg(arguments, void *); - size_t size = va_arg(arguments, size_t); - - if(H5T_encode(dt, (unsigned char *)buf, &size) < 0) - HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "can't determine serialized length of datatype") - - *nalloc = (ssize_t) size; - break; - } - /* H5Tget_create_plist */ - case H5VL_DATATYPE_GET_TCPL: - { - hid_t *ret_id = va_arg(arguments, hid_t *); - - if(H5I_INVALID_HID == (*ret_id = H5T__get_create_plist(dt))) - HGOTO_ERROR(H5E_DATATYPE, H5E_CANTGET, FAIL, "can't get object creation info"); - - break; - } - default: - HGOTO_ERROR(H5E_VOL, H5E_CANTGET, FAIL, "can't get this type of information from datatype") - } - -done: - FUNC_LEAVE_NOAPI(ret_value) -} /* end H5VL_native_datatype_get() */ - - -/*------------------------------------------------------------------------- - * Function: H5VL_native_datatype_specific - * - * Purpose: Specific operations for datatype - * - * Return: SUCCEED/FAIL - * - *------------------------------------------------------------------------- - */ -static herr_t -H5VL_native_datatype_specific(void *obj, H5VL_datatype_specific_t specific_type, - hid_t H5_ATTR_UNUSED dxpl_id, void H5_ATTR_UNUSED **req, va_list arguments) -{ - H5T_t *dt = (H5T_t *)obj; - herr_t ret_value = SUCCEED; /* Return value */ - - FUNC_ENTER_NOAPI_NOINIT - - switch(specific_type) { - case H5VL_DATATYPE_FLUSH: - { - hid_t type_id = va_arg(arguments, hid_t); - - /* To flush metadata and invoke flush callback if there is */ - if (H5O_flush_common(&dt->oloc, type_id) < 0) - HGOTO_ERROR(H5E_DATATYPE, H5E_CANTFLUSH, FAIL, "unable to flush datatype") - - break; - } - case H5VL_DATATYPE_REFRESH: - { - hid_t type_id = va_arg(arguments, hid_t); - - /* Call private function to refresh datatype object */ - if ((H5O_refresh_metadata(type_id, dt->oloc)) < 0) - HGOTO_ERROR(H5E_DATATYPE, H5E_CANTLOAD, FAIL, "unable to refresh datatype") - - break; - } - default: - HGOTO_ERROR(H5E_VOL, H5E_UNSUPPORTED, FAIL, "invalid specific operation") - } - -done: - FUNC_LEAVE_NOAPI(ret_value) -} /* end H5VL_native_datatype_specific() */ - - -/*------------------------------------------------------------------------- - * Function: H5VL_native_datatype_close - * - * Purpose: Closes an datatype. - * - * Return: Success: 0 - * Failure: -1, datatype not closed. - * - * Programmer: Mohamad Chaarawi - * March, 2012 - * - *------------------------------------------------------------------------- - */ -static herr_t -H5VL_native_datatype_close(void *dt, hid_t H5_ATTR_UNUSED dxpl_id, void H5_ATTR_UNUSED **req) -{ - herr_t ret_value = SUCCEED; /* Return value */ - - FUNC_ENTER_NOAPI_NOINIT - - if(H5T_close((H5T_t*)dt) < 0) - HGOTO_ERROR(H5E_SYM, H5E_CANTDEC, FAIL, "can't close datatype") - -done: - FUNC_LEAVE_NOAPI(ret_value) -} /* end H5VL_native_datatype_close() */ - diff --git a/src/H5VLnative.h b/src/H5VLnative.h index 832c758..916151b 100644 --- a/src/H5VLnative.h +++ b/src/H5VLnative.h @@ -11,26 +11,85 @@ * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ /* - * Purpose: The public header file for the native VOL driver. + * Purpose: The public header file for the native VOL connector. */ #ifndef _H5VLnative_H #define _H5VLnative_H -/* Characteristics of the native VOL driver */ +/* Identifier for the native VOL connector */ +#define H5VL_NATIVE (H5VL_native_register()) + +/* Characteristics of the native VOL connector */ #define H5VL_NATIVE_NAME "native" #define H5VL_NATIVE_VALUE H5_VOL_NATIVE /* enum value */ #define H5VL_NATIVE_VERSION 0 +/* Typedef and values for native VOL connector attribute optional VOL operations */ +typedef int H5VL_native_attr_optional_t; +#ifndef H5_NO_DEPRECATED_SYMBOLS +#define H5VL_NATIVE_ATTR_ITERATE_OLD 0 /* H5Aiterate (deprecated routine) */ +#endif /* H5_NO_DEPRECATED_SYMBOLS */ + +/* Typedef and values for native VOL connector dataset optional VOL operations */ +typedef int H5VL_native_dataset_optional_t; +#define H5VL_NATIVE_DATASET_FORMAT_CONVERT 0 /* H5Dformat_convert (internal) */ +#define H5VL_NATIVE_DATASET_GET_CHUNK_INDEX_TYPE 1 /* H5Dget_chunk_index_type */ +#define H5VL_NATIVE_DATASET_GET_CHUNK_STORAGE_SIZE 2 /* H5Dget_chunk_storage_size */ +#define H5VL_NATIVE_DATASET_CHUNK_READ 3 /* H5Dchunk_read */ +#define H5VL_NATIVE_DATASET_CHUNK_WRITE 4 /* H5Dchunk_write */ + +/* Typedef and values for native VOL connector file optional VOL operations */ +typedef int H5VL_native_file_optional_t; +#define H5VL_NATIVE_FILE_CLEAR_ELINK_CACHE 0 /* H5Fclear_elink_file_cache */ +#define H5VL_NATIVE_FILE_GET_FILE_IMAGE 1 /* H5Fget_file_image */ +#define H5VL_NATIVE_FILE_GET_FREE_SECTIONS 2 /* H5Fget_free_sections */ +#define H5VL_NATIVE_FILE_GET_FREE_SPACE 3 /* H5Fget_freespace */ +#define H5VL_NATIVE_FILE_GET_INFO 4 /* H5Fget_info1/2 */ +#define H5VL_NATIVE_FILE_GET_MDC_CONF 5 /* H5Fget_mdc_config */ +#define H5VL_NATIVE_FILE_GET_MDC_HR 6 /* H5Fget_mdc_hit_rate */ +#define H5VL_NATIVE_FILE_GET_MDC_SIZE 7 /* H5Fget_mdc_size */ +#define H5VL_NATIVE_FILE_GET_SIZE 8 /* H5Fget_filesize */ +#define H5VL_NATIVE_FILE_GET_VFD_HANDLE 9 /* H5Fget_vfd_handle */ +#define H5VL_NATIVE_FILE_GET_FILE_ID 10 /* H5Fget_file_id */ +#define H5VL_NATIVE_FILE_RESET_MDC_HIT_RATE 11 /* H5Freset_mdc_hit_rate_stats */ +#define H5VL_NATIVE_FILE_SET_MDC_CONFIG 12 /* H5Fset_mdc_config */ +#define H5VL_NATIVE_FILE_GET_METADATA_READ_RETRY_INFO 13 /* H5Fget_metadata_read_retry_info */ +#define H5VL_NATIVE_FILE_START_SWMR_WRITE 14 /* H5Fstart_swmr_write */ +#define H5VL_NATIVE_FILE_START_MDC_LOGGING 15 /* H5Fstart_mdc_logging */ +#define H5VL_NATIVE_FILE_STOP_MDC_LOGGING 16 /* H5Fstop_mdc_logging */ +#define H5VL_NATIVE_FILE_GET_MDC_LOGGING_STATUS 17 /* H5Fget_mdc_logging_status */ +#define H5VL_NATIVE_FILE_FORMAT_CONVERT 18 /* H5Fformat_convert */ +#define H5VL_NATIVE_FILE_RESET_PAGE_BUFFERING_STATS 19 /* H5Freset_page_buffering_stats */ +#define H5VL_NATIVE_FILE_GET_PAGE_BUFFERING_STATS 20 /* H5Fget_page_buffering_stats */ +#define H5VL_NATIVE_FILE_GET_MDC_IMAGE_INFO 21 /* H5Fget_mdc_image_info */ +#define H5VL_NATIVE_FILE_GET_EOA 22 /* H5Fget_eoa */ +#define H5VL_NATIVE_FILE_INCR_FILESIZE 23 /* H5Fincrement_filesize */ +#define H5VL_NATIVE_FILE_SET_LIBVER_BOUNDS 24 /* H5Fset_latest_format/libver_bounds */ + +/* Typedef and values for native VOL connector group optional VOL operations */ +typedef int H5VL_native_group_optional_t; +#ifndef H5_NO_DEPRECATED_SYMBOLS +#define H5VL_NATIVE_GROUP_ITERATE_OLD 0 /* HG5Giterate (deprecated routine) */ +#define H5VL_NATIVE_GROUP_GET_OBJINFO 1 /* HG5Gget_objinfo (deprecated routine) */ +#endif /* H5_NO_DEPRECATED_SYMBOLS */ + +/* Typedef and values for native VOL connector object optional VOL operations */ +typedef int H5VL_native_object_optional_t; +#define H5VL_NATIVE_OBJECT_GET_COMMENT 0 /* H5G|H5Oget_comment, H5Oget_comment_by_name */ +#define H5VL_NATIVE_OBJECT_GET_INFO 1 /* H5Oget_info(_by_idx, _by_name)(2) */ +#define H5VL_NATIVE_OBJECT_SET_COMMENT 2 /* H5G|H5Oset_comment, H5Oset_comment_by_name */ #ifdef __cplusplus extern "C" { #endif -H5_DLL herr_t H5Pset_fapl_native(hid_t fapl_id); +/* Private functions */ +H5_DLL hid_t H5VL_native_register(void); #ifdef __cplusplus } #endif #endif /* _H5VLnative_H */ + diff --git a/src/H5VLnative_attr.c b/src/H5VLnative_attr.c new file mode 100644 index 0000000..7d9f0ac --- /dev/null +++ b/src/H5VLnative_attr.c @@ -0,0 +1,597 @@ +/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * + * 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 COPYING file, which can be found at the root of the source code * + * distribution tree, or in https://support.hdfgroup.org/ftp/HDF5/releases. * + * If you do not have access to either file, you may request a copy from * + * help@hdfgroup.org. * + * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ + +/* + * Purpose: Attribute callbacks for the native VOL connector + * + */ + +#define H5A_FRIEND /* Suppress error about including H5Apkg */ + +#include "H5private.h" /* Generic Functions */ +#include "H5Apkg.h" /* Attributes */ +#include "H5Eprivate.h" /* Error handling */ +#include "H5Fprivate.h" /* Files */ +#include "H5Gprivate.h" /* Groups */ +#include "H5Iprivate.h" /* IDs */ +#include "H5Pprivate.h" /* Property lists */ +#include "H5Sprivate.h" /* Dataspaces */ +#include "H5Tprivate.h" /* Datatypes */ +#include "H5VLprivate.h" /* Virtual Object Layer */ + +#include "H5VLnative_private.h" /* Native VOL connector */ + + + +/*------------------------------------------------------------------------- + * Function: H5VL__native_attr_create + * + * Purpose: Handles the attribute create callback + * + * Return: Success: attribute pointer + * Failure: NULL + * + *------------------------------------------------------------------------- + */ +void * +H5VL__native_attr_create(void *obj, const H5VL_loc_params_t *loc_params, const char *attr_name, + hid_t acpl_id, hid_t H5_ATTR_UNUSED aapl_id, hid_t H5_ATTR_UNUSED dxpl_id, + void H5_ATTR_UNUSED **req) +{ + H5G_loc_t loc; /* Object location */ + H5G_loc_t obj_loc; /* Location used to open group */ + hbool_t loc_found = FALSE; + H5P_genplist_t *plist; /* Property list pointer */ + hid_t type_id, space_id; + H5T_t *type, *dt; /* Datatype to use for attribute */ + H5S_t *space; /* Dataspace to use for attribute */ + H5A_t *attr = NULL; + void *ret_value = NULL; + + FUNC_ENTER_PACKAGE + + /* Get the plist structure */ + if(NULL == (plist = (H5P_genplist_t *)H5I_object(acpl_id))) + HGOTO_ERROR(H5E_ATOM, H5E_BADATOM, NULL, "can't find object for ID") + + /* get creation properties */ + if(H5P_get(plist, H5VL_PROP_ATTR_TYPE_ID, &type_id) < 0) + HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, NULL, "can't get property value for datatype id") + if(H5P_get(plist, H5VL_PROP_ATTR_SPACE_ID, &space_id) < 0) + HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, NULL, "can't get property value for space id") + + if(H5G_loc_real(obj, loc_params->obj_type, &loc) < 0) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, NULL, "not a file or file object") + if(0 == (H5F_INTENT(loc.oloc->file) & H5F_ACC_RDWR)) + HGOTO_ERROR(H5E_ARGS, H5E_WRITEERROR, NULL, "no write intent on file") + + if(NULL == (dt = (H5T_t *)H5I_object_verify(type_id, H5I_DATATYPE))) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, NULL, "not a datatype") + /* If this is a named datatype, get the connector's pointer to the datatype */ + type = H5T_get_actual_type(dt); + + if(NULL == (space = (H5S_t *)H5I_object_verify(space_id, H5I_DATASPACE))) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, NULL, "not a data space") + + if(loc_params->type == H5VL_OBJECT_BY_SELF) { + /* H5Acreate */ + /* Go do the real work for attaching the attribute to the dataset */ + if(NULL == (attr = H5A__create(&loc, attr_name, type, space, acpl_id))) + HGOTO_ERROR(H5E_ATTR, H5E_CANTINIT, NULL, "unable to create attribute") + } /* end if */ + else if(loc_params->type == H5VL_OBJECT_BY_NAME) { + /* H5Acreate_by_name */ + if(NULL == (attr = H5A__create_by_name(&loc, loc_params->loc_data.loc_by_name.name, attr_name, type, space, acpl_id))) + HGOTO_ERROR(H5E_ATTR, H5E_CANTINIT, NULL, "unable to create attribute") + } /* end else-if */ + else + HGOTO_ERROR(H5E_VOL, H5E_UNSUPPORTED, NULL, "unknown attribute create parameters") + + ret_value = (void *)attr; + +done: + /* Release resources */ + if(loc_found && H5G_loc_free(&obj_loc) < 0) + HDONE_ERROR(H5E_ATTR, H5E_CANTRELEASE, NULL, "can't free location") + + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5VL__native_attr_create() */ + + +/*------------------------------------------------------------------------- + * Function: H5VL__native_attr_open + * + * Purpose: Handles the attribute open callback + * + * Return: Success: attribute pointer + * Failure: NULL + * + *------------------------------------------------------------------------- + */ +void * +H5VL__native_attr_open(void *obj, const H5VL_loc_params_t *loc_params, const char *attr_name, + hid_t H5_ATTR_UNUSED aapl_id, hid_t H5_ATTR_UNUSED dxpl_id, void H5_ATTR_UNUSED **req) +{ + H5G_loc_t loc; /* Object location */ + H5A_t *attr = NULL; /* Attribute opened */ + void *ret_value; + + FUNC_ENTER_PACKAGE + + /* check arguments */ + if(H5G_loc_real(obj, loc_params->obj_type, &loc) < 0) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, NULL, "not a file or file object") + + if(loc_params->type == H5VL_OBJECT_BY_SELF) { + /* H5Aopen */ + /* Open the attribute */ + if(NULL == (attr = H5A__open(&loc, attr_name))) + HGOTO_ERROR(H5E_ATTR, H5E_CANTOPENOBJ, NULL, "unable to open attribute: '%s'", attr_name) + } /* end if */ + else if(loc_params->type == H5VL_OBJECT_BY_NAME) { + /* H5Aopen_by_name */ + /* Open the attribute on the object header */ + if(NULL == (attr = H5A__open_by_name(&loc, loc_params->loc_data.loc_by_name.name, attr_name))) + HGOTO_ERROR(H5E_ATTR, H5E_CANTOPENOBJ, NULL, "can't open attribute") + } /* end else-if */ + else if(loc_params->type == H5VL_OBJECT_BY_IDX) { + /* H5Aopen_by_idx */ + /* Open the attribute in the object header */ + if(NULL == (attr = H5A__open_by_idx(&loc, loc_params->loc_data.loc_by_idx.name, + loc_params->loc_data.loc_by_idx.idx_type, + loc_params->loc_data.loc_by_idx.order, + loc_params->loc_data.loc_by_idx.n))) + HGOTO_ERROR(H5E_ATTR, H5E_CANTOPENOBJ, NULL, "unable to open attribute") + } /* end else-if */ + else + HGOTO_ERROR(H5E_VOL, H5E_UNSUPPORTED, NULL, "unknown attribute open parameters") + + ret_value = (void *)attr; + +done: + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5VL__native_attr_open() */ + + +/*------------------------------------------------------------------------- + * Function: H5VL__native_attr_read + * + * Purpose: Handles the attribute read callback + * + * Return: SUCCEED/FAIL + * + *------------------------------------------------------------------------- + */ +herr_t +H5VL__native_attr_read(void *attr, hid_t dtype_id, void *buf, + hid_t H5_ATTR_UNUSED dxpl_id, void H5_ATTR_UNUSED **req) +{ + H5T_t *mem_type; /* Memory datatype */ + herr_t ret_value; /* Return value */ + + FUNC_ENTER_PACKAGE + + if(NULL == (mem_type = (H5T_t *)H5I_object_verify(dtype_id, H5I_DATATYPE))) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a datatype") + + /* Go write the actual data to the attribute */ + if((ret_value = H5A__read((H5A_t*)attr, mem_type, buf)) < 0) + HGOTO_ERROR(H5E_ATTR, H5E_READERROR, FAIL, "unable to read attribute") + +done: + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5VL__native_attr_read() */ + + +/*------------------------------------------------------------------------- + * Function: H5VL__native_attr_write + * + * Purpose: Handles the attribute write callback + * + * Return: SUCCEED/FAIL + * + *------------------------------------------------------------------------- + */ +herr_t +H5VL__native_attr_write(void *attr, hid_t dtype_id, const void *buf, + hid_t H5_ATTR_UNUSED dxpl_id, void H5_ATTR_UNUSED **req) +{ + H5T_t *mem_type; /* Memory datatype */ + herr_t ret_value; /* Return value */ + + FUNC_ENTER_PACKAGE + + if(NULL == (mem_type = (H5T_t *)H5I_object_verify(dtype_id, H5I_DATATYPE))) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a datatype") + + /* Go write the actual data to the attribute */ + if((ret_value = H5A__write((H5A_t*)attr, mem_type, buf)) < 0) + HGOTO_ERROR(H5E_ATTR, H5E_WRITEERROR, FAIL, "unable to write attribute") + +done: + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5VL__native_attr_write() */ + + +/*------------------------------------------------------------------------- + * Function: H5VL__native_attr_get + * + * Purpose: Handles the attribute get callback + * + * Return: SUCCEED/FAIL + * + *------------------------------------------------------------------------- + */ +herr_t +H5VL__native_attr_get(void *obj, H5VL_attr_get_t get_type, + hid_t H5_ATTR_UNUSED dxpl_id, void H5_ATTR_UNUSED **req, va_list arguments) +{ + herr_t ret_value = SUCCEED; /* Return value */ + + FUNC_ENTER_PACKAGE + + switch(get_type) { + /* H5Aget_space */ + case H5VL_ATTR_GET_SPACE: + { + hid_t *ret_id = HDva_arg(arguments, hid_t *); + H5A_t *attr = (H5A_t *)obj; + + if((*ret_id = H5A_get_space(attr)) < 0) + HGOTO_ERROR(H5E_ARGS, H5E_CANTGET, FAIL, "can't get space ID of attribute") + break; + } + + /* H5Aget_type */ + case H5VL_ATTR_GET_TYPE: + { + hid_t *ret_id = HDva_arg(arguments, hid_t *); + H5A_t *attr = (H5A_t *)obj; + + if((*ret_id = H5A__get_type(attr)) < 0) + HGOTO_ERROR(H5E_ARGS, H5E_CANTGET, FAIL, "can't get datatype ID of attribute") + break; + } + + /* H5Aget_create_plist */ + case H5VL_ATTR_GET_ACPL: + { + hid_t *ret_id = HDva_arg(arguments, hid_t *); + H5A_t *attr = (H5A_t *)obj; + + if((*ret_id = H5A__get_create_plist(attr)) < 0) + HGOTO_ERROR(H5E_ARGS, H5E_CANTGET, FAIL, "can't get creation property list for attr") + + break; + } + + /* H5Aget_name */ + case H5VL_ATTR_GET_NAME: + { + const H5VL_loc_params_t *loc_params = HDva_arg(arguments, const H5VL_loc_params_t *); + size_t buf_size = HDva_arg(arguments, size_t); + char *buf = HDva_arg(arguments, char *); + ssize_t *ret_val = HDva_arg(arguments, ssize_t *); + H5A_t *attr = NULL; + + if(H5VL_OBJECT_BY_SELF == loc_params->type) { + attr = (H5A_t *)obj; + /* Call private function in turn */ + if(0 > (*ret_val = H5A__get_name(attr, buf_size, buf))) + HGOTO_ERROR(H5E_ATTR, H5E_CANTGET, FAIL, "can't get attribute name") + } + else if(H5VL_OBJECT_BY_IDX == loc_params->type) { + H5G_loc_t loc; + + /* check arguments */ + if(H5G_loc_real(obj, loc_params->obj_type, &loc) < 0) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a file or file object") + + /* Open the attribute on the object header */ + if(NULL == (attr = H5A__open_by_idx(&loc, loc_params->loc_data.loc_by_idx.name, + loc_params->loc_data.loc_by_idx.idx_type, + loc_params->loc_data.loc_by_idx.order, + loc_params->loc_data.loc_by_idx.n))) + HGOTO_ERROR(H5E_ATTR, H5E_CANTOPENOBJ, FAIL, "can't open attribute") + + /* Get the length of the name */ + *ret_val = (ssize_t)HDstrlen(attr->shared->name); + + /* Copy the name into the user's buffer, if given */ + if(buf) { + HDstrncpy(buf, attr->shared->name, MIN((size_t)(*ret_val + 1), buf_size)); + if((size_t)(*ret_val) >= buf_size) + buf[buf_size - 1]='\0'; + } /* end if */ + + /* Release resources */ + if(attr && H5A__close(attr) < 0) + HGOTO_ERROR(H5E_ATTR, H5E_CANTFREE, FAIL, "can't close attribute") + } + else + HGOTO_ERROR(H5E_SYM, H5E_CANTGET, FAIL, "can't get name of attr") + + break; + } + + /* H5Aget_info */ + case H5VL_ATTR_GET_INFO: + { + const H5VL_loc_params_t *loc_params = HDva_arg(arguments, const H5VL_loc_params_t *); + H5A_info_t *ainfo = HDva_arg(arguments, H5A_info_t *); + H5A_t *attr = NULL; + + if(H5VL_OBJECT_BY_SELF == loc_params->type) { + attr = (H5A_t *)obj; + if(H5A__get_info(attr, ainfo) < 0) + HGOTO_ERROR(H5E_ARGS, H5E_CANTGET, FAIL, "can't get attribute info") + } + else if(H5VL_OBJECT_BY_NAME == loc_params->type) { + char *attr_name = HDva_arg(arguments, char *); + H5G_loc_t loc; + + /* check arguments */ + if(H5G_loc_real(obj, loc_params->obj_type, &loc) < 0) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a file or file object") + + /* Open the attribute on the object header */ + if(NULL == (attr = H5A__open_by_name(&loc, loc_params->loc_data.loc_by_name.name, attr_name))) + HGOTO_ERROR(H5E_ATTR, H5E_CANTOPENOBJ, FAIL, "can't open attribute") + + /* Get the attribute information */ + if(H5A__get_info(attr, ainfo) < 0) + HGOTO_ERROR(H5E_ATTR, H5E_CANTGET, FAIL, "unable to get attribute info") + + /* Release resources */ + if(attr && H5A__close(attr) < 0) + HGOTO_ERROR(H5E_ATTR, H5E_CANTFREE, FAIL, "can't close attribute") + } + else if(H5VL_OBJECT_BY_IDX == loc_params->type) { + H5G_loc_t loc; + + /* check arguments */ + if(H5G_loc_real(obj, loc_params->obj_type, &loc) < 0) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a file or file object") + + /* Open the attribute on the object header */ + if(NULL == (attr = H5A__open_by_idx(&loc, loc_params->loc_data.loc_by_idx.name, + loc_params->loc_data.loc_by_idx.idx_type, + loc_params->loc_data.loc_by_idx.order, + loc_params->loc_data.loc_by_idx.n))) + HGOTO_ERROR(H5E_ATTR, H5E_CANTOPENOBJ, FAIL, "can't open attribute") + + /* Get the attribute information */ + if(H5A__get_info(attr, ainfo) < 0) + HGOTO_ERROR(H5E_ATTR, H5E_CANTGET, FAIL, "unable to get attribute info") + + /* Release resources */ + if(attr && H5A__close(attr) < 0) + HGOTO_ERROR(H5E_ATTR, H5E_CANTFREE, FAIL, "can't close attribute") + } + else + HGOTO_ERROR(H5E_SYM, H5E_CANTGET, FAIL, "can't get name of attr") + + break; + } + + case H5VL_ATTR_GET_STORAGE_SIZE: + { + hsize_t *ret = HDva_arg(arguments, hsize_t *); + H5A_t *attr = (H5A_t *)obj; + + /* Set return value */ + *ret = attr->shared->data_size; + break; + } + + default: + HGOTO_ERROR(H5E_VOL, H5E_CANTGET, FAIL, "can't get this type of information from attr") + } /* end switch */ + +done: + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5VL__native_attr_get() */ + + +/*------------------------------------------------------------------------- + * Function: H5VL__native_attr_specific + * + * Purpose: Handles the attribute specific callback + * + * Return: SUCCEED/FAIL + * + *------------------------------------------------------------------------- + */ +herr_t +H5VL__native_attr_specific(void *obj, const H5VL_loc_params_t *loc_params, H5VL_attr_specific_t specific_type, + hid_t H5_ATTR_UNUSED dxpl_id, void H5_ATTR_UNUSED **req, va_list arguments) +{ + H5G_loc_t loc; + herr_t ret_value = SUCCEED; /* Return value */ + + FUNC_ENTER_PACKAGE + + /* Get location for passed-in object */ + if(H5G_loc_real(obj, loc_params->obj_type, &loc) < 0) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a file or file object") + + switch(specific_type) { + case H5VL_ATTR_DELETE: + { + char *attr_name = HDva_arg(arguments, char *); + + if(H5VL_OBJECT_BY_SELF == loc_params->type) { + /* H5Adelete */ + /* Delete the attribute from the location */ + if(H5O__attr_remove(loc.oloc, attr_name) < 0) + HGOTO_ERROR(H5E_ATTR, H5E_CANTDELETE, FAIL, "unable to delete attribute") + } /* end if */ + else if(H5VL_OBJECT_BY_NAME == loc_params->type) { + /* H5Adelete_by_name */ + /* Delete the attribute */ + if(H5A__delete_by_name(&loc, loc_params->loc_data.loc_by_name.name, attr_name) < 0) + HGOTO_ERROR(H5E_ATTR, H5E_CANTDELETE, FAIL, "unable to delete attribute") + } /* end else-if */ + else if(H5VL_OBJECT_BY_IDX == loc_params->type) { + /* H5Adelete_by_idx */ + /* Delete the attribute from the location */ + if(H5A__delete_by_idx(&loc, loc_params->loc_data.loc_by_idx.name, loc_params->loc_data.loc_by_idx.idx_type, + loc_params->loc_data.loc_by_idx.order, loc_params->loc_data.loc_by_idx.n) < 0) + HGOTO_ERROR(H5E_ATTR, H5E_CANTDELETE, FAIL, "unable to delete attribute") + } /* end else-if */ + else + HGOTO_ERROR(H5E_VOL, H5E_UNSUPPORTED, FAIL, "unknown attribute remove parameters") + break; + } + + case H5VL_ATTR_EXISTS: + { + const char *attr_name = HDva_arg(arguments, const char *); + htri_t *ret = HDva_arg(arguments, htri_t *); + + if(loc_params->type == H5VL_OBJECT_BY_SELF) { /* H5Aexists */ + /* Check if the attribute exists */ + if((*ret = H5O__attr_exists(loc.oloc, attr_name)) < 0) + HGOTO_ERROR(H5E_ATTR, H5E_CANTGET, FAIL, "unable to determine if attribute exists") + } /* end if */ + else if(loc_params->type == H5VL_OBJECT_BY_NAME) { /* H5Aexists_by_name */ + /* Check if the attribute exists */ + if((*ret = H5A__exists_by_name(loc, loc_params->loc_data.loc_by_name.name, attr_name)) < 0) + HGOTO_ERROR(H5E_ATTR, H5E_CANTGET, FAIL, "unable to determine if attribute exists") + } /* end else-if */ + else + HGOTO_ERROR(H5E_VOL, H5E_UNSUPPORTED, FAIL, "unknown parameters") + break; + } + + case H5VL_ATTR_ITER: + { + H5_index_t idx_type = (H5_index_t)HDva_arg(arguments, int); /* enum work-around */ + H5_iter_order_t order = (H5_iter_order_t)HDva_arg(arguments, int); /* enum work-around */ + hsize_t *idx = HDva_arg(arguments, hsize_t *); + H5A_operator2_t op = HDva_arg(arguments, H5A_operator2_t); + void *op_data = HDva_arg(arguments, void *); + + if(loc_params->type == H5VL_OBJECT_BY_SELF) { /* H5Aiterate2 */ + /* Iterate over attributes */ + if((ret_value = H5A__iterate(&loc, ".", idx_type, order, idx, op, op_data)) < 0) + HGOTO_ERROR(H5E_ATTR, H5E_BADITER, FAIL, "error iterating over attributes") + } /* end if */ + else if(loc_params->type == H5VL_OBJECT_BY_NAME) { /* H5Aiterate_by_name */ + /* Iterate over attributes by name */ + if((ret_value = H5A__iterate(&loc, loc_params->loc_data.loc_by_name.name, idx_type, order, idx, op, op_data)) < 0) + HGOTO_ERROR(H5E_ATTR, H5E_BADITER, FAIL, "attribute iteration failed"); + } /* end else-if */ + else + HGOTO_ERROR(H5E_VOL, H5E_UNSUPPORTED, FAIL, "unknown parameters") + break; + } + + /* H5Arename/rename_by_name */ + case H5VL_ATTR_RENAME: + { + const char *old_name = HDva_arg(arguments, const char *); + const char *new_name = HDva_arg(arguments, const char *); + + if(loc_params->type == H5VL_OBJECT_BY_SELF) { /* H5Arename */ + /* Call attribute rename routine */ + if(H5O__attr_rename(loc.oloc, old_name, new_name) < 0) + HGOTO_ERROR(H5E_ATTR, H5E_CANTRENAME, FAIL, "can't rename attribute") + } /* end if */ + else if(loc_params->type == H5VL_OBJECT_BY_NAME) { /* H5Arename_by_name */ + /* Call attribute rename routine */ + if(H5A__rename_by_name(loc, loc_params->loc_data.loc_by_name.name, old_name, new_name) < 0) + HGOTO_ERROR(H5E_ATTR, H5E_CANTRENAME, FAIL, "can't rename attribute") + } /* end else-if */ + else + HGOTO_ERROR(H5E_VOL, H5E_UNSUPPORTED, FAIL, "unknown attribute rename parameters") + break; + } + + default: + HGOTO_ERROR(H5E_VOL, H5E_UNSUPPORTED, FAIL, "invalid specific operation") + } /* end switch */ + +done: + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5VL__native_attr_specific() */ + + +/*------------------------------------------------------------------------- + * Function: H5VL__native_attr_optional + * + * Purpose: Handles the attribute optional callback + * + * Return: SUCCEED/FAIL + * + *------------------------------------------------------------------------- + */ +herr_t +H5VL__native_attr_optional(void H5_ATTR_UNUSED *obj, hid_t H5_ATTR_UNUSED dxpl_id, + void H5_ATTR_UNUSED **req, va_list arguments) +{ + H5VL_native_attr_optional_t optional_type; + herr_t ret_value = SUCCEED; /* Return value */ + + FUNC_ENTER_PACKAGE + + optional_type = HDva_arg(arguments, H5VL_native_attr_optional_t); + switch(optional_type) { +#ifndef H5_NO_DEPRECATED_SYMBOLS + case H5VL_NATIVE_ATTR_ITERATE_OLD: + { + hid_t loc_id = HDva_arg(arguments, hid_t); + unsigned *attr_num = HDva_arg(arguments, unsigned *); + H5A_operator1_t op = HDva_arg(arguments, H5A_operator1_t); + void *op_data = HDva_arg(arguments, void *); + + /* Call the actual iteration routine */ + if((ret_value = H5A__iterate_old(loc_id, attr_num, op, op_data)) < 0) + HERROR(H5E_VOL, H5E_BADITER, "error iterating over attributes"); + + break; + } +#endif /* H5_NO_DEPRECATED_SYMBOLS */ + + default: + HGOTO_ERROR(H5E_VOL, H5E_UNSUPPORTED, FAIL, "invalid optional operation") + } /* end switch */ + +done: + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5VL__native_attr_optional() */ + + +/*------------------------------------------------------------------------- + * Function: H5VL__native_attr_close + * + * Purpose: Handles the attribute close callback + * + * Return: Success: SUCCEED + * Failure: FAIL (attribute will not be closed) + * + *------------------------------------------------------------------------- + */ +herr_t +H5VL__native_attr_close(void *attr, hid_t H5_ATTR_UNUSED dxpl_id, void H5_ATTR_UNUSED **req) +{ + herr_t ret_value = SUCCEED; /* Return value */ + + FUNC_ENTER_PACKAGE + + if(H5A__close((H5A_t*)attr) < 0) + HGOTO_ERROR(H5E_SYM, H5E_CANTDEC, FAIL, "can't close attribute") + +done: + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5VL__native_attr_close() */ + diff --git a/src/H5VLnative_dataset.c b/src/H5VLnative_dataset.c new file mode 100644 index 0000000..8f7351c --- /dev/null +++ b/src/H5VLnative_dataset.c @@ -0,0 +1,575 @@ +/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * + * 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 COPYING file, which can be found at the root of the source code * + * distribution tree, or in https://support.hdfgroup.org/ftp/HDF5/releases. * + * If you do not have access to either file, you may request a copy from * + * help@hdfgroup.org. * + * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ + +/* + * Purpose: Dataset callbacks for the native VOL connector + * + */ + +#define H5D_FRIEND /* Suppress error about including H5Dpkg */ + +#include "H5private.h" /* Generic Functions */ +#include "H5Dpkg.h" /* Datasets */ +#include "H5Eprivate.h" /* Error handling */ +#include "H5Fprivate.h" /* Files */ +#include "H5Gprivate.h" /* Groups */ +#include "H5Iprivate.h" /* IDs */ +#include "H5Pprivate.h" /* Property lists */ +#include "H5Sprivate.h" /* Dataspaces */ +#include "H5VLprivate.h" /* Virtual Object Layer */ + +#include "H5VLnative_private.h" /* Native VOL connector */ + + + +/*------------------------------------------------------------------------- + * Function: H5VL__native_dataset_create + * + * Purpose: Handles the dataset create callback + * + * Return: Success: dataset pointer + * Failure: NULL + * + *------------------------------------------------------------------------- + */ +void * +H5VL__native_dataset_create(void *obj, const H5VL_loc_params_t *loc_params, + const char *name, hid_t dcpl_id, hid_t dapl_id, hid_t H5_ATTR_UNUSED dxpl_id, + void H5_ATTR_UNUSED **req) +{ + H5P_genplist_t *plist; /* Property list pointer */ + H5G_loc_t loc; /* Object location to insert dataset into */ + hid_t type_id = H5I_INVALID_HID; + hid_t space_id = H5I_INVALID_HID; + hid_t lcpl_id = H5I_INVALID_HID; + H5D_t *dset = NULL; /* New dataset's info */ + const H5S_t *space; /* Dataspace for dataset */ + void *ret_value; + + FUNC_ENTER_PACKAGE + + /* Get the plist structure */ + if(NULL == (plist = (H5P_genplist_t *)H5I_object(dcpl_id))) + HGOTO_ERROR(H5E_ATOM, H5E_BADATOM, NULL, "can't find object for ID") + + /* Get creation properties */ + if(H5P_get(plist, H5VL_PROP_DSET_TYPE_ID, &type_id) < 0) + HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, NULL, "can't get property value for datatype id") + if(H5P_get(plist, H5VL_PROP_DSET_SPACE_ID, &space_id) < 0) + HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, NULL, "can't get property value for space id") + if(H5P_get(plist, H5VL_PROP_DSET_LCPL_ID, &lcpl_id) < 0) + HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, NULL, "can't get property value for lcpl id") + + /* Check arguments */ + if(H5G_loc_real(obj, loc_params->obj_type, &loc) < 0) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, NULL, "not a file or file object") + if(H5I_DATATYPE != H5I_get_type(type_id)) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, NULL, "not a datatype ID") + if(NULL == (space = (const H5S_t *)H5I_object_verify(space_id, H5I_DATASPACE))) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, NULL, "not a dataspace ID") + + /* H5Dcreate_anon */ + if(NULL == name) { + /* build and open the new dataset */ + if(NULL == (dset = H5D__create(loc.oloc->file, type_id, space, dcpl_id, dapl_id))) + HGOTO_ERROR(H5E_DATASET, H5E_CANTINIT, NULL, "unable to create dataset") + } /* end if */ + /* H5Dcreate2 */ + else { + /* Create the new dataset & get its ID */ + if(NULL == (dset = H5D__create_named(&loc, name, type_id, space, lcpl_id, dcpl_id, dapl_id))) + HGOTO_ERROR(H5E_DATASET, H5E_CANTINIT, NULL, "unable to create dataset") + } /* end else */ + + ret_value = (void *)dset; + +done: + if(NULL == name) { + /* Release the dataset's object header, if it was created */ + if(dset) { + H5O_loc_t *oloc; /* Object location for dataset */ + + /* Get the new dataset's object location */ + if(NULL == (oloc = H5D_oloc(dset))) + HDONE_ERROR(H5E_DATASET, H5E_CANTGET, NULL, "unable to get object location of dataset") + + /* Decrement refcount on dataset's object header in memory */ + if(H5O_dec_rc_by_loc(oloc) < 0) + HDONE_ERROR(H5E_DATASET, H5E_CANTDEC, NULL, "unable to decrement refcount on newly created object") + } /* end if */ + } /* end if */ + + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5VL__native_dataset_create() */ + + +/*------------------------------------------------------------------------- + * Function: H5VL__native_dataset_open + * + * Purpose: Handles the dataset open callback + * + * Return: Success: dataset pointer + * Failure: NULL + * + *------------------------------------------------------------------------- + */ +void * +H5VL__native_dataset_open(void *obj, const H5VL_loc_params_t *loc_params, const char *name, + hid_t dapl_id, hid_t H5_ATTR_UNUSED dxpl_id, void H5_ATTR_UNUSED **req) +{ + H5D_t *dset = NULL; + H5G_loc_t loc; /* Object location of group */ + void *ret_value = NULL; + + FUNC_ENTER_PACKAGE + + if(H5G_loc_real(obj, loc_params->obj_type, &loc) < 0) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, NULL, "not a file or file object") + + /* Open the dataset */ + if(NULL == (dset = H5D__open_name(&loc, name, dapl_id))) + HGOTO_ERROR(H5E_DATASET, H5E_CANTOPENOBJ, NULL, "unable to open dataset") + + ret_value = (void *)dset; + +done: + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5VL__native_dataset_open() */ + + +/*------------------------------------------------------------------------- + * Function: H5VL__native_dataset_read + * + * Purpose: Handles the dataset read callback + * + * Return: SUCCEED/FAIL + * + *------------------------------------------------------------------------- + */ +herr_t +H5VL__native_dataset_read(void *obj, hid_t mem_type_id, hid_t mem_space_id, + hid_t file_space_id, hid_t H5_ATTR_UNUSED dxpl_id, void *buf, + void H5_ATTR_UNUSED **req) +{ + H5D_t *dset = (H5D_t *)obj; + const H5S_t *mem_space = NULL; + const H5S_t *file_space = NULL; + herr_t ret_value = SUCCEED; /* Return value */ + + FUNC_ENTER_PACKAGE + + /* Check arguments */ + if(NULL == dset->oloc.file) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "dataset is not associated with a file") + + /* Get validated dataspace pointers */ + if(H5S_get_validated_dataspace(mem_space_id, &mem_space) < 0) + HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "could not get a validated dataspace from mem_space_id") + if(H5S_get_validated_dataspace(file_space_id, &file_space) < 0) + HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "could not get a validated dataspace from file_space_id") + + /* Read raw data */ + if(H5D__read(dset, mem_type_id, mem_space, file_space, buf/*out*/) < 0) + HGOTO_ERROR(H5E_DATASET, H5E_READERROR, FAIL, "can't read data") + +done: + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5VL__native_dataset_read() */ + + +/*------------------------------------------------------------------------- + * Function: H5VL__native_dataset_write + * + * Purpose: Handles the dataset write callback + * + * Return: SUCCEED/FAIL + * + *------------------------------------------------------------------------- + */ +herr_t +H5VL__native_dataset_write(void *obj, hid_t mem_type_id, hid_t mem_space_id, + hid_t file_space_id, hid_t H5_ATTR_UNUSED dxpl_id, const void *buf, + void H5_ATTR_UNUSED **req) +{ + H5D_t *dset = (H5D_t *)obj; + const H5S_t *mem_space = NULL; + const H5S_t *file_space = NULL; + herr_t ret_value = SUCCEED; /* Return value */ + + FUNC_ENTER_PACKAGE + + /* check arguments */ + if(NULL == dset->oloc.file) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "dataset is not associated with a file") + + /* Get validated dataspace pointers */ + if(H5S_get_validated_dataspace(mem_space_id, &mem_space) < 0) + HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "could not get a validated dataspace from mem_space_id") + if(H5S_get_validated_dataspace(file_space_id, &file_space) < 0) + HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "could not get a validated dataspace from file_space_id") + + /* Write the data */ + if(H5D__write(dset, mem_type_id, mem_space, file_space, buf) < 0) + HGOTO_ERROR(H5E_DATASET, H5E_WRITEERROR, FAIL, "can't write data") + +done: + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5VL__native_dataset_write() */ + + +/*------------------------------------------------------------------------- + * Function: H5VL__native_dataset_get + * + * Purpose: Handles the dataset get callback + * + * Return: SUCCEED/FAIL + * + *------------------------------------------------------------------------- + */ +herr_t +H5VL__native_dataset_get(void *obj, H5VL_dataset_get_t get_type, + hid_t H5_ATTR_UNUSED dxpl_id, void H5_ATTR_UNUSED **req, va_list arguments) +{ + H5D_t *dset = (H5D_t *)obj; + herr_t ret_value = SUCCEED; /* Return value */ + + FUNC_ENTER_PACKAGE + + switch(get_type) { + /* H5Dget_space */ + case H5VL_DATASET_GET_SPACE: + { + hid_t *ret_id = HDva_arg(arguments, hid_t *); + + if((*ret_id = H5D__get_space(dset)) < 0) + HGOTO_ERROR(H5E_ARGS, H5E_CANTGET, FAIL, "can't get space ID of dataset") + + break; + } + + /* H5Dget_space_statuc */ + case H5VL_DATASET_GET_SPACE_STATUS: + { + H5D_space_status_t *allocation = HDva_arg(arguments, H5D_space_status_t *); + + /* Read data space address and return */ + if(H5D__get_space_status(dset, allocation) < 0) + HGOTO_ERROR(H5E_DATASET, H5E_CANTINIT, FAIL, "unable to get space status") + + break; + } + + /* H5Dget_type */ + case H5VL_DATASET_GET_TYPE: + { + hid_t *ret_id = HDva_arg(arguments, hid_t *); + + if((*ret_id = H5D__get_type(dset)) < 0) + HGOTO_ERROR(H5E_ARGS, H5E_CANTGET, FAIL, "can't get datatype ID of dataset") + + break; + } + + /* H5Dget_create_plist */ + case H5VL_DATASET_GET_DCPL: + { + hid_t *ret_id = HDva_arg(arguments, hid_t *); + + if((*ret_id = H5D_get_create_plist(dset)) < 0) + HGOTO_ERROR(H5E_ARGS, H5E_CANTGET, FAIL, "can't get creation property list for dataset") + + break; + } + + /* H5Dget_access_plist */ + case H5VL_DATASET_GET_DAPL: + { + hid_t *ret_id = HDva_arg(arguments, hid_t *); + + if((*ret_id = H5D_get_access_plist(dset)) < 0) + HGOTO_ERROR(H5E_ARGS, H5E_CANTGET, FAIL, "can't get access property list for dataset") + + break; + } + + /* H5Dget_storage_size */ + case H5VL_DATASET_GET_STORAGE_SIZE: + { + hsize_t *ret = HDva_arg(arguments, hsize_t *); + + /* Set return value */ + if(H5D__get_storage_size(dset, ret) < 0) + HGOTO_ERROR(H5E_DATASET, H5E_CANTGET, FAIL, "can't get size of dataset's storage") + break; + } + + /* H5Dget_offset */ + case H5VL_DATASET_GET_OFFSET: + { + haddr_t *ret = HDva_arg(arguments, haddr_t *); + + /* Set return value */ + *ret = H5D__get_offset(dset); + if(!H5F_addr_defined(*ret)) + *ret = HADDR_UNDEF; + break; + } + + default: + HGOTO_ERROR(H5E_VOL, H5E_CANTGET, FAIL, "can't get this type of information from dataset") + } /* end switch */ + +done: + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5VL__native_dataset_get() */ + + +/*------------------------------------------------------------------------- + * Function: H5VL__native_dataset_specific + * + * Purpose: Handles the dataset specific callback + * + * Return: SUCCEED/FAIL + * + *------------------------------------------------------------------------- + */ +herr_t +H5VL__native_dataset_specific(void *obj, H5VL_dataset_specific_t specific_type, + hid_t H5_ATTR_UNUSED dxpl_id, void H5_ATTR_UNUSED **req, va_list arguments) +{ + H5D_t *dset = (H5D_t *)obj; + herr_t ret_value = SUCCEED; /* Return value */ + + FUNC_ENTER_PACKAGE + + switch(specific_type) { + /* H5Dspecific_space */ + case H5VL_DATASET_SET_EXTENT: + { + const hsize_t *size = HDva_arg(arguments, const hsize_t *); + + if(H5D__set_extent(dset, size) < 0) + HGOTO_ERROR(H5E_DATASET, H5E_CANTINIT, FAIL, "unable to set extent of dataset") + break; + } + + case H5VL_DATASET_FLUSH: + { + hid_t dset_id = HDva_arg(arguments, hid_t); + + /* Flush the dataset */ + if(H5D__flush(dset, dset_id) < 0) + HGOTO_ERROR(H5E_DATASET, H5E_CANTFLUSH, FAIL, "unable to flush dataset") + + break; + } + + case H5VL_DATASET_REFRESH: + { + hid_t dset_id = HDva_arg(arguments, hid_t); + + /* Refresh the dataset */ + if((H5D__refresh(dset_id, dset)) < 0) + HGOTO_ERROR(H5E_DATASET, H5E_CANTLOAD, FAIL, "unable to refresh dataset") + + break; + } + + default: + HGOTO_ERROR(H5E_VOL, H5E_UNSUPPORTED, FAIL, "invalid specific operation") + } /* end switch */ + +done: + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5VL__native_dataset_specific() */ + + +/*------------------------------------------------------------------------- + * Function: H5VL__native_dataset_optional + * + * Purpose: Handles the dataset optional callback + * + * Return: SUCCEED/FAIL + * + *------------------------------------------------------------------------- + */ +herr_t +H5VL__native_dataset_optional(void *obj, hid_t H5_ATTR_UNUSED dxpl_id, + void H5_ATTR_UNUSED **req, va_list arguments) +{ + H5D_t *dset = NULL; /* Dataset */ + H5VL_native_dataset_optional_t optional_type = HDva_arg(arguments, H5VL_native_dataset_optional_t); + herr_t ret_value = SUCCEED; /* Return value */ + + FUNC_ENTER_PACKAGE + + switch(optional_type) { + case H5VL_NATIVE_DATASET_FORMAT_CONVERT: + { + dset = (H5D_t *)obj; + + switch(dset->shared->layout.type) { + case H5D_CHUNKED: + /* Convert the chunk indexing type to version 1 B-tree if not */ + if(dset->shared->layout.u.chunk.idx_type != H5D_CHUNK_IDX_BTREE) + if((H5D__format_convert(dset)) < 0) + HGOTO_ERROR(H5E_DATASET, H5E_CANTLOAD, FAIL, "unable to downgrade chunk indexing type for dataset") + break; + + case H5D_CONTIGUOUS: + case H5D_COMPACT: + /* Downgrade the layout version to 3 if greater than 3 */ + if(dset->shared->layout.version > H5O_LAYOUT_VERSION_DEFAULT) + if((H5D__format_convert(dset)) < 0) + HGOTO_ERROR(H5E_DATASET, H5E_CANTLOAD, FAIL, "unable to downgrade layout version for dataset") + break; + + case H5D_VIRTUAL: + /* Nothing to do even though layout is version 4 */ + break; + + case H5D_LAYOUT_ERROR: + case H5D_NLAYOUTS: + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "invalid dataset layout type") + + default: + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "unknown dataset layout type") + } /* end switch */ + + break; + } + + case H5VL_NATIVE_DATASET_GET_CHUNK_INDEX_TYPE: + { + H5D_chunk_index_t *idx_type = HDva_arg(arguments, H5D_chunk_index_t *); + + dset = (H5D_t *)obj; + + /* Make sure the dataset is chunked */ + if(H5D_CHUNKED != dset->shared->layout.type) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a chunked dataset") + + /* Get the chunk indexing type */ + *idx_type = dset->shared->layout.u.chunk.idx_type; + + break; + } + + case H5VL_NATIVE_DATASET_GET_CHUNK_STORAGE_SIZE: + { + hsize_t *offset = HDva_arg(arguments, hsize_t *); + hsize_t *chunk_nbytes = HDva_arg(arguments, hsize_t *); + + dset = (H5D_t *)obj; + + /* Make sure the dataset is chunked */ + if(H5D_CHUNKED != dset->shared->layout.type) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a chunked dataset") + + /* Call private function */ + if(H5D__get_chunk_storage_size(dset, offset, chunk_nbytes) < 0) + HGOTO_ERROR(H5E_DATASET, H5E_CANTGET, FAIL, "can't get storage size of chunk") + + break; + } + + case H5VL_NATIVE_DATASET_CHUNK_READ: + { + const hsize_t *offset = HDva_arg(arguments, hsize_t *); + uint32_t *filters = HDva_arg(arguments, uint32_t *); + void *buf = HDva_arg(arguments, void *); + hsize_t offset_copy[H5O_LAYOUT_NDIMS]; /* Internal copy of chunk offset */ + + dset = (H5D_t *)obj; + + /* Check arguments */ + if(NULL == dset->oloc.file) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "dataset is not associated with a file") + if(H5D_CHUNKED != dset->shared->layout.type) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a chunked dataset") + + /* Copy the user's offset array so we can be sure it's terminated properly. + * (we don't want to mess with the user's buffer). + */ + if(H5D__get_offset_copy(dset, offset, offset_copy) < 0) + HGOTO_ERROR(H5E_DATASET, H5E_CANTALLOC, FAIL, "failure to copy offset array") + + /* Read the raw chunk */ + if(H5D__chunk_direct_read(dset, offset_copy, filters, buf) < 0) + HGOTO_ERROR(H5E_DATASET, H5E_READERROR, FAIL, "can't read unprocessed chunk data") + + break; + } + + case H5VL_NATIVE_DATASET_CHUNK_WRITE: + { + uint32_t filters = HDva_arg(arguments, uint32_t); + const hsize_t *offset = HDva_arg(arguments, const hsize_t *); + uint32_t data_size_32 = HDva_arg(arguments, uint32_t); + const void *buf = HDva_arg(arguments, const void *); + hsize_t offset_copy[H5O_LAYOUT_NDIMS]; /* Internal copy of chunk offset */ + + dset = (H5D_t *)obj; + + /* Check arguments */ + if(NULL == dset->oloc.file) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "dataset is not associated with a file") + if(H5D_CHUNKED != dset->shared->layout.type) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a chunked dataset") + + /* Copy the user's offset array so we can be sure it's terminated properly. + * (we don't want to mess with the user's buffer). + */ + if(H5D__get_offset_copy(dset, offset, offset_copy) < 0) + HGOTO_ERROR(H5E_DATASET, H5E_CANTALLOC, FAIL, "failure to copy offset array") + + /* Write chunk */ + if(H5D__chunk_direct_write(dset, filters, offset_copy, data_size_32, buf) < 0) + HGOTO_ERROR(H5E_DATASET, H5E_WRITEERROR, FAIL, "can't write unprocessed chunk data") + + break; + } + + default: + HGOTO_ERROR(H5E_VOL, H5E_UNSUPPORTED, FAIL, "invalid optional operation") + } /* end switch */ + +done: + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5VL__native_dataset_optional() */ + + +/*------------------------------------------------------------------------- + * Function: H5VL__native_dataset_close + * + * Purpose: Handles the dataset close callback + * + * Return: Success: SUCCEED + * Failure: FAIL (dataset will not be closed) + * + *------------------------------------------------------------------------- + */ +herr_t +H5VL__native_dataset_close(void *dset, hid_t H5_ATTR_UNUSED dxpl_id, + void H5_ATTR_UNUSED **req) +{ + herr_t ret_value = SUCCEED; /* Return value */ + + FUNC_ENTER_PACKAGE + + if(H5D_close((H5D_t*)dset) < 0) + HGOTO_ERROR(H5E_DATASET, H5E_CANTDEC, FAIL, "can't close dataset") + +done: + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5VL__native_dataset_close() */ + diff --git a/src/H5VLnative_datatype.c b/src/H5VLnative_datatype.c new file mode 100644 index 0000000..3c9463d --- /dev/null +++ b/src/H5VLnative_datatype.c @@ -0,0 +1,265 @@ +/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * + * 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 COPYING file, which can be found at the root of the source code * + * distribution tree, or in https://support.hdfgroup.org/ftp/HDF5/releases. * + * If you do not have access to either file, you may request a copy from * + * help@hdfgroup.org. * + * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ + +/* + * Purpose: Datatype callbacks for the native VOL connector + * + */ + +#define H5T_FRIEND /* Suppress error about including H5Tpkg */ + +#include "H5private.h" /* Generic Functions */ +#include "H5Eprivate.h" /* Error handling */ +#include "H5Gprivate.h" /* Groups */ +#include "H5Iprivate.h" /* IDs */ +#include "H5Oprivate.h" /* Object headers */ +#include "H5Pprivate.h" /* Property lists */ +#include "H5Tpkg.h" /* Datatypes */ +#include "H5VLprivate.h" /* Virtual Object Layer */ + +#include "H5VLnative_private.h" /* Native VOL connector */ + + + +/*------------------------------------------------------------------------- + * Function: H5VL__native_datatype_commit + * + * Purpose: Handles the datatype commit callback + * + * Return: Success: datatype pointer + * Failure: NULL + * + *------------------------------------------------------------------------- + */ +void * +H5VL__native_datatype_commit(void *obj, const H5VL_loc_params_t *loc_params, const char *name, + hid_t type_id, hid_t lcpl_id, hid_t tcpl_id, hid_t H5_ATTR_UNUSED tapl_id, + hid_t H5_ATTR_UNUSED dxpl_id, void H5_ATTR_UNUSED **req) +{ + H5G_loc_t loc; /* Location to commit datatype */ + H5T_t *dt; /* Datatype for ID */ + H5T_t *type = NULL; /* copy of the original type which will be committed */ + void *ret_value = NULL; /* Return value */ + + FUNC_ENTER_PACKAGE + + /* check arguments */ + if(H5G_loc_real(obj, loc_params->obj_type, &loc) < 0) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, NULL, "not a file or file object") + + if(NULL == (dt = (H5T_t *)H5I_object_verify(type_id, H5I_DATATYPE))) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, NULL, "not a datatype") + + /* Check arguments. We cannot commit an immutable type because H5Tclose() + * normally fails on such types (try H5Tclose(H5T_NATIVE_INT)) but closing + * a named type should always succeed. + */ + if(H5T_STATE_NAMED == dt->shared->state || H5T_STATE_OPEN == dt->shared->state) + HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, NULL, "datatype is already committed") + if(H5T_STATE_IMMUTABLE == dt->shared->state) + HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, NULL, "datatype is immutable") + + /* Check for a "sensible" datatype to store on disk */ + if(H5T_is_sensible(dt) <= 0) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, NULL, "datatype is not sensible") + + /* Copy the datatype - the copied one will be the type that is + * committed, and attached to original datatype above the VOL + * layer + */ + if(NULL == (type = H5T_copy(dt, H5T_COPY_TRANSIENT))) + HGOTO_ERROR(H5E_DATATYPE, H5E_CANTINIT, NULL, "unable to copy"); + + /* Commit the datatype */ + if(NULL != name) { + /* H5Tcommit */ + if(H5T__commit_named(&loc, name, type, lcpl_id, tcpl_id) < 0) + HGOTO_ERROR(H5E_DATATYPE, H5E_CANTINIT, NULL, "unable to commit datatype") + } /* end if */ + else { + /* H5Tcommit_anon */ + if(H5T__commit_anon(loc.oloc->file, type, tcpl_id) < 0) + HGOTO_ERROR(H5E_DATATYPE, H5E_CANTINIT, NULL, "unable to commit datatype") + } /* end else */ + + ret_value = (void *)type; + +done: + if(NULL == ret_value && type) + H5T_close(type); + + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5VL__native_datatype_commit() */ + + +/*------------------------------------------------------------------------- + * Function: H5VL__native_datatype_open + * + * Purpose: Handles the datatype open callback + * + * Return: Success: datatype pointer + * Failure: NULL + * + *------------------------------------------------------------------------- + */ +void * +H5VL__native_datatype_open(void *obj, const H5VL_loc_params_t *loc_params, const char *name, + hid_t H5_ATTR_UNUSED tapl_id, hid_t H5_ATTR_UNUSED dxpl_id, void H5_ATTR_UNUSED **req) +{ + H5T_t *type = NULL; /* Datatype opened in file */ + H5G_loc_t loc; /* Group location of object to open */ + void *ret_value = NULL; + + FUNC_ENTER_PACKAGE + + if(H5G_loc_real(obj, loc_params->obj_type, &loc) < 0) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, NULL, "not a file or file object") + + /* Open the datatype */ + if(NULL == (type = H5T__open_name(&loc, name))) + HGOTO_ERROR(H5E_DATATYPE, H5E_CANTOPENOBJ, NULL, "unable to open named datatype") + + type->vol_obj = NULL; + + ret_value = (void *)type; + +done: + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5VL__native_datatype_open() */ + + +/*------------------------------------------------------------------------- + * Function: H5VL__native_datatype_get + * + * Purpose: Handles the datatype get callback + * + * Return: SUCCEED/FAIL + * + *------------------------------------------------------------------------- + */ +herr_t +H5VL__native_datatype_get(void *obj, H5VL_datatype_get_t get_type, + hid_t H5_ATTR_UNUSED dxpl_id, void H5_ATTR_UNUSED **req, va_list arguments) +{ + H5T_t *dt = (H5T_t *)obj; + herr_t ret_value = SUCCEED; /* Return value */ + + FUNC_ENTER_PACKAGE + + switch (get_type) { + case H5VL_DATATYPE_GET_BINARY: + { + ssize_t *nalloc = HDva_arg(arguments, ssize_t *); + void *buf = HDva_arg(arguments, void *); + size_t size = HDva_arg(arguments, size_t); + + if(H5T_encode(dt, (unsigned char *)buf, &size) < 0) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "can't determine serialized length of datatype") + + *nalloc = (ssize_t) size; + break; + } + + /* H5Tget_create_plist */ + case H5VL_DATATYPE_GET_TCPL: + { + hid_t *ret_id = HDva_arg(arguments, hid_t *); + + if(H5I_INVALID_HID == (*ret_id = H5T__get_create_plist(dt))) + HGOTO_ERROR(H5E_DATATYPE, H5E_CANTGET, FAIL, "can't get object creation info"); + + break; + } + + default: + HGOTO_ERROR(H5E_VOL, H5E_CANTGET, FAIL, "can't get this type of information from datatype") + } /* end switch */ + +done: + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5VL__native_datatype_get() */ + + +/*------------------------------------------------------------------------- + * Function: H5VL__native_datatype_specific + * + * Purpose: Handles the datatype specific callback + * + * Return: SUCCEED/FAIL + * + *------------------------------------------------------------------------- + */ +herr_t +H5VL__native_datatype_specific(void *obj, H5VL_datatype_specific_t specific_type, + hid_t H5_ATTR_UNUSED dxpl_id, void H5_ATTR_UNUSED **req, va_list arguments) +{ + H5T_t *dt = (H5T_t *)obj; + herr_t ret_value = SUCCEED; /* Return value */ + + FUNC_ENTER_PACKAGE + + switch(specific_type) { + case H5VL_DATATYPE_FLUSH: + { + hid_t type_id = HDva_arg(arguments, hid_t); + + /* To flush metadata and invoke flush callback if there is */ + if(H5O_flush_common(&dt->oloc, type_id) < 0) + HGOTO_ERROR(H5E_DATATYPE, H5E_CANTFLUSH, FAIL, "unable to flush datatype") + + break; + } + + case H5VL_DATATYPE_REFRESH: + { + hid_t type_id = HDva_arg(arguments, hid_t); + + /* Call private function to refresh datatype object */ + if((H5O_refresh_metadata(type_id, dt->oloc)) < 0) + HGOTO_ERROR(H5E_DATATYPE, H5E_CANTLOAD, FAIL, "unable to refresh datatype") + + break; + } + + default: + HGOTO_ERROR(H5E_VOL, H5E_UNSUPPORTED, FAIL, "invalid specific operation") + } /* end switch */ + +done: + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5VL__native_datatype_specific() */ + + +/*------------------------------------------------------------------------- + * Function: H5VL__native_datatype_close + * + * Purpose: Handles the datatype close callback + * + * Return: Success: SUCCEED + * Failure: FAIL (datatype will not be closed) + * + *------------------------------------------------------------------------- + */ +herr_t +H5VL__native_datatype_close(void *dt, hid_t H5_ATTR_UNUSED dxpl_id, void H5_ATTR_UNUSED **req) +{ + herr_t ret_value = SUCCEED; /* Return value */ + + FUNC_ENTER_PACKAGE + + if(H5T_close((H5T_t*)dt) < 0) + HGOTO_ERROR(H5E_SYM, H5E_CANTDEC, FAIL, "can't close datatype") + +done: + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5VL__native_datatype_close() */ + diff --git a/src/H5VLnative_file.c b/src/H5VLnative_file.c new file mode 100644 index 0000000..994af16 --- /dev/null +++ b/src/H5VLnative_file.c @@ -0,0 +1,811 @@ +/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * + * 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 COPYING file, which can be found at the root of the source code * + * distribution tree, or in https://support.hdfgroup.org/ftp/HDF5/releases. * + * If you do not have access to either file, you may request a copy from * + * help@hdfgroup.org. * + * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ + +/* + * Purpose: File callbacks for the native VOL connector + * + */ + +#define H5F_FRIEND /* Suppress error about including H5Fpkg */ + +#include "H5private.h" /* Generic Functions */ +#include "H5ACprivate.h" /* Metadata cache */ +#include "H5Cprivate.h" /* Cache */ +#include "H5Eprivate.h" /* Error handling */ +#include "H5Fpkg.h" /* Files */ +#include "H5Gprivate.h" /* Groups */ +#include "H5Iprivate.h" /* IDs */ +#include "H5MFprivate.h" /* File memory management */ +#include "H5Pprivate.h" /* Property lists */ +#include "H5PBprivate.h" /* Page buffering */ +#include "H5VLprivate.h" /* Virtual Object Layer */ + +#include "H5VLnative_private.h" /* Native VOL connector */ + + + +/*------------------------------------------------------------------------- + * Function: H5VL__native_file_create + * + * Purpose: Handles the file create callback + * + * Return: Success: file pointer + * Failure: NULL + * + *------------------------------------------------------------------------- + */ +void * +H5VL__native_file_create(const char *name, unsigned flags, hid_t fcpl_id, hid_t fapl_id, + hid_t H5_ATTR_UNUSED dxpl_id, void H5_ATTR_UNUSED **req) +{ + H5F_t *new_file = NULL; + void *ret_value = NULL; + + FUNC_ENTER_PACKAGE + + /* Adjust bit flags by turning on the creation bit and making sure that + * the EXCL or TRUNC bit is set. All newly-created files are opened for + * reading and writing. + */ + if(0 == (flags & (H5F_ACC_EXCL|H5F_ACC_TRUNC))) + flags |= H5F_ACC_EXCL; /* default */ + flags |= H5F_ACC_RDWR | H5F_ACC_CREAT; + + /* Create the file */ + if(NULL == (new_file = H5F_open(name, flags, fcpl_id, fapl_id))) + HGOTO_ERROR(H5E_FILE, H5E_CANTOPENFILE, NULL, "unable to create file") + new_file->id_exists = TRUE; + + ret_value = (void *)new_file; + +done: + if(NULL == ret_value && new_file) + if(H5F__close(new_file) < 0) + HDONE_ERROR(H5E_FILE, H5E_CANTCLOSEFILE, NULL, "problems closing file") + + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5VL__native_file_create() */ + + +/*------------------------------------------------------------------------- + * Function: H5VL__native_file_open + * + * Purpose: Handles the file open callback + * + * Return: Success: file pointer + * Failure: NULL + * + *------------------------------------------------------------------------- + */ +void * +H5VL__native_file_open(const char *name, unsigned flags, hid_t fapl_id, + hid_t H5_ATTR_UNUSED dxpl_id, void H5_ATTR_UNUSED **req) +{ + H5F_t *new_file = NULL; + void *ret_value = NULL; + + FUNC_ENTER_PACKAGE + + /* Open the file */ + if(NULL == (new_file = H5F_open(name, flags, H5P_FILE_CREATE_DEFAULT, fapl_id))) + HGOTO_ERROR(H5E_FILE, H5E_CANTOPENFILE, NULL, "unable to open file") + new_file->id_exists = TRUE; + + ret_value = (void *)new_file; + +done: + if(NULL == ret_value && new_file && H5F_try_close(new_file, NULL) < 0) + HDONE_ERROR(H5E_FILE, H5E_CANTCLOSEFILE, NULL, "problems closing file") + + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5VL__native_file_open() */ + + +/*------------------------------------------------------------------------- + * Function: H5VL__native_file_get + * + * Purpose: Handles the file get callback + * + * Return: SUCCEED/FAIL + * + *------------------------------------------------------------------------- + */ +herr_t +H5VL__native_file_get(void *obj, H5VL_file_get_t get_type, + hid_t H5_ATTR_UNUSED dxpl_id, void H5_ATTR_UNUSED **req, va_list arguments) +{ + H5F_t *f = NULL; /* File struct */ + herr_t ret_value = SUCCEED; /* Return value */ + + FUNC_ENTER_PACKAGE + + switch(get_type) { + /* H5Fget_access_plist */ + case H5VL_FILE_GET_FAPL: + { + H5P_genplist_t *new_plist; /* New property list */ + hid_t *plist_id = HDva_arg(arguments, hid_t *); + + f = (H5F_t *)obj; + + /* Retrieve the file's access property list */ + if((*plist_id = H5F_get_access_plist(f, TRUE)) < 0) + HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, FAIL, "can't get file access property list") + + if(NULL == (new_plist = (H5P_genplist_t *)H5I_object(*plist_id))) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a property list") + break; + } + + /* H5Fget_create_plist */ + case H5VL_FILE_GET_FCPL: + { + H5P_genplist_t *plist; /* Property list */ + hid_t *plist_id = HDva_arg(arguments, hid_t *); + + f = (H5F_t *)obj; + if(NULL == (plist = (H5P_genplist_t *)H5I_object(f->shared->fcpl_id))) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a property list") + + /* Create the property list object to return */ + if((*plist_id = H5P_copy_plist(plist, TRUE)) < 0) + HGOTO_ERROR(H5E_PLIST, H5E_CANTINIT, FAIL, "unable to copy file creation properties") + + break; + } + + /* H5Fget_obj_count */ + case H5VL_FILE_GET_OBJ_COUNT: + { + unsigned types = HDva_arg(arguments, unsigned); + ssize_t *ret = HDva_arg(arguments, ssize_t *); + size_t obj_count = 0; /* Number of opened objects */ + + f = (H5F_t *)obj; + /* Perform the query */ + if(H5F_get_obj_count(f, types, TRUE, &obj_count) < 0) + HGOTO_ERROR(H5E_FILE, H5E_BADITER, FAIL, "H5F_get_obj_count failed") + + /* Set the return value */ + *ret = (ssize_t)obj_count; + break; + } + + /* H5Fget_obj_ids */ + case H5VL_FILE_GET_OBJ_IDS: + { + unsigned types = HDva_arg(arguments, unsigned); + size_t max_objs = HDva_arg(arguments, size_t); + hid_t *oid_list = HDva_arg(arguments, hid_t *); + ssize_t *ret = HDva_arg(arguments, ssize_t *); + size_t obj_count = 0; /* Number of opened objects */ + + f = (H5F_t *)obj; + /* Perform the query */ + if(H5F_get_obj_ids(f, types, max_objs, oid_list, TRUE, &obj_count) < 0) + HGOTO_ERROR(H5E_FILE, H5E_BADITER, FAIL, "H5F_get_obj_ids failed") + + /* Set the return value */ + *ret = (ssize_t)obj_count; + break; + } + + /* H5Fget_intent */ + case H5VL_FILE_GET_INTENT: + { + unsigned *intent_flags = HDva_arg(arguments, unsigned *); + + f = (H5F_t *)obj; + + /* HDF5 uses some flags internally that users don't know about. + * Simplify things for them so that they only get either H5F_ACC_RDWR + * or H5F_ACC_RDONLY and any SWMR flags. + */ + if(H5F_INTENT(f) & H5F_ACC_RDWR) { + *intent_flags = H5F_ACC_RDWR; + + /* Check for SWMR write access on the file */ + if(H5F_INTENT(f) & H5F_ACC_SWMR_WRITE) + *intent_flags |= H5F_ACC_SWMR_WRITE; + } /* end if */ + else { + *intent_flags = H5F_ACC_RDONLY; + + /* Check for SWMR read access on the file */ + if(H5F_INTENT(f) & H5F_ACC_SWMR_READ) + *intent_flags |= H5F_ACC_SWMR_READ; + } /* end else */ + + break; + } + + /* H5Fget_name */ + case H5VL_FILE_GET_NAME: + { + H5I_type_t type = (H5I_type_t)HDva_arg(arguments, int); /* enum work-around */ + size_t size = HDva_arg(arguments, size_t); + char *name = HDva_arg(arguments, char *); + ssize_t *ret = HDva_arg(arguments, ssize_t *); + size_t len; + + if(NULL == (f = H5F__get_file(obj, type))) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a file or file object") + + len = HDstrlen(H5F_OPEN_NAME(f)); + + if(name) { + HDstrncpy(name, H5F_OPEN_NAME(f), MIN(len + 1,size)); + if(len >= size) + name[size-1]='\0'; + } /* end if */ + + /* Set the return value for the API call */ + *ret = (ssize_t)len; + break; + } + + default: + HGOTO_ERROR(H5E_VOL, H5E_CANTGET, FAIL, "can't get this type of information") + } /* end switch */ + +done: + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5VL__native_file_get() */ + + +/*------------------------------------------------------------------------- + * Function: H5VL__native_file_specific + * + * Purpose: Handles the file specific callback + * + * Return: SUCCEED/FAIL + * + *------------------------------------------------------------------------- + */ +herr_t +H5VL__native_file_specific(void *obj, H5VL_file_specific_t specific_type, + hid_t H5_ATTR_UNUSED dxpl_id, void H5_ATTR_UNUSED **req, va_list arguments) +{ + herr_t ret_value = SUCCEED; /* Return value */ + + FUNC_ENTER_PACKAGE + + switch(specific_type) { + /* H5Fflush */ + case H5VL_FILE_FLUSH: + { + H5I_type_t type = (H5I_type_t)HDva_arg(arguments, int); /* enum work-around */ + H5F_scope_t scope = (H5F_scope_t)HDva_arg(arguments, int); /* enum work-around */ + H5F_t *f = NULL; /* File to flush */ + + /* Get the file for the object */ + if(NULL == (f = H5F__get_file(obj, type))) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a file or file object") + + /* Nothing to do if the file is read only. This determination is + * made at the shared open(2) flags level, implying that opening a + * file twice, once for read-only and once for read-write, and then + * calling H5Fflush() with the read-only handle, still causes data + * to be flushed. + */ + if(H5F_ACC_RDWR & H5F_INTENT(f)) { + /* Flush other files, depending on scope */ + if(H5F_SCOPE_GLOBAL == scope) { + /* Call the flush routine for mounted file hierarchies */ + if(H5F_flush_mounts(f) < 0) + HGOTO_ERROR(H5E_FILE, H5E_CANTFLUSH, FAIL, "unable to flush mounted file hierarchy") + } /* end if */ + else { + /* Call the flush routine, for this file */ + if(H5F__flush(f) < 0) + HGOTO_ERROR(H5E_FILE, H5E_CANTFLUSH, FAIL, "unable to flush file's cached information") + } /* end else */ + } /* end if */ + break; + } + + /* H5Freopen */ + case H5VL_FILE_REOPEN: + { + void **ret = HDva_arg(arguments, void **); + H5F_t *new_file = NULL; + + /* Reopen the file through the VOL connector */ + if(NULL == (new_file = H5F__reopen((H5F_t *)obj))) + HGOTO_ERROR(H5E_FILE, H5E_CANTINIT, FAIL, "unable to reopen file") + new_file->id_exists = TRUE; + + *ret = (void *)new_file; + break; + } + + /* H5Fmount */ + case H5VL_FILE_MOUNT: + { + H5I_type_t type = (H5I_type_t)HDva_arg(arguments, int); /* enum work-around */ + const char *name = HDva_arg(arguments, const char *); + H5F_t *child = HDva_arg(arguments, H5F_t *); + hid_t plist_id = HDva_arg(arguments, hid_t); + H5G_loc_t loc; + + if(H5G_loc_real(obj, type, &loc) < 0) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a file or file object") + + /* Do the mount */ + if(H5F__mount(&loc, name, child, plist_id) < 0) + HGOTO_ERROR(H5E_FILE, H5E_MOUNT, FAIL, "unable to mount file") + + break; + } + + /* H5Funmount */ + case H5VL_FILE_UNMOUNT: + { + H5I_type_t type = (H5I_type_t)HDva_arg(arguments, int); /* enum work-around */ + const char *name = HDva_arg(arguments, const char *); + H5G_loc_t loc; + + if(H5G_loc_real(obj, type, &loc) < 0) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a file or file object") + + /* Unmount */ + if(H5F__unmount(&loc, name) < 0) + HGOTO_ERROR(H5E_FILE, H5E_MOUNT, FAIL, "unable to unmount file") + + break; + } + + /* H5Fis_accessible */ + case H5VL_FILE_IS_ACCESSIBLE: + { + hid_t fapl_id = HDva_arg(arguments, hid_t); + const char *name = HDva_arg(arguments, const char *); + htri_t *ret = HDva_arg(arguments, htri_t *); + + /* Call private routine */ + if((*ret = H5F__is_hdf5(name, fapl_id)) < 0) + HGOTO_ERROR(H5E_IO, H5E_CANTINIT, FAIL, "error in HDF5 file check") + break; + } + + default: + HGOTO_ERROR(H5E_VOL, H5E_UNSUPPORTED, FAIL, "invalid specific operation") + } /* end switch */ + +done: + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5VL__native_file_specific() */ + + +/*------------------------------------------------------------------------- + * Function: H5VL__native_file_optional + * + * Purpose: Handles the file optional callback + * + * Return: SUCCEED/FAIL + * + *------------------------------------------------------------------------- + */ +herr_t +H5VL__native_file_optional(void *obj, hid_t H5_ATTR_UNUSED dxpl_id, void H5_ATTR_UNUSED **req, va_list arguments) +{ + H5F_t *f = NULL; /* File */ + H5VL_native_file_optional_t optional_type = HDva_arg(arguments, H5VL_native_file_optional_t); + herr_t ret_value = SUCCEED; /* Return value */ + + FUNC_ENTER_PACKAGE + + f = (H5F_t *)obj; + switch(optional_type) { + /* H5Fget_filesize */ + case H5VL_NATIVE_FILE_GET_SIZE: + { + haddr_t max_eof_eoa; /* Maximum of the EOA & EOF */ + haddr_t base_addr; /* Base address for the file */ + hsize_t *size = HDva_arg(arguments, hsize_t *); + + /* Go get the actual file size */ + if(H5F__get_max_eof_eoa(f, &max_eof_eoa) < 0) + HGOTO_ERROR(H5E_FILE, H5E_CANTGET, FAIL, "file can't get max eof/eoa ") + + base_addr = H5FD_get_base_addr(f->shared->lf); + + if(size) + *size = (hsize_t)(max_eof_eoa + base_addr); /* Convert relative base address for file to absolute address */ + + break; + } + + /* H5Fget_file_image */ + case H5VL_NATIVE_FILE_GET_FILE_IMAGE: + { + void *buf_ptr = HDva_arg(arguments, void *); + ssize_t *ret = HDva_arg(arguments, ssize_t *); + size_t buf_len = HDva_arg(arguments, size_t ); + + /* Do the actual work */ + if((*ret = H5F__get_file_image(f, buf_ptr, buf_len)) < 0) + HGOTO_ERROR(H5E_FILE, H5E_CANTGET, FAIL, "get file image failed") + break; + } + + /* H5Fget_freespace */ + case H5VL_NATIVE_FILE_GET_FREE_SPACE: + { + hsize_t tot_space; /* Amount of free space in the file */ + hssize_t *ret = HDva_arg(arguments, hssize_t *); + + /* Go get the actual amount of free space in the file */ + if(H5MF_get_freespace(f, &tot_space, NULL) < 0) + HGOTO_ERROR(H5E_FILE, H5E_CANTGET, FAIL, "unable to check free space for file") + *ret = (hssize_t)tot_space; + break; + } + + /* H5Fget_free_sections */ + case H5VL_NATIVE_FILE_GET_FREE_SECTIONS: + { + H5F_sect_info_t *sect_info = HDva_arg(arguments, H5F_sect_info_t *); + ssize_t *ret = HDva_arg(arguments, ssize_t *); + H5F_mem_t type = (H5F_mem_t)HDva_arg(arguments, int); /* enum work-around */ + size_t nsects = HDva_arg(arguments, size_t); + + /* Go get the free-space section information in the file */ + if((*ret = H5MF_get_free_sections(f, type, nsects, sect_info)) < 0) + HGOTO_ERROR(H5E_FILE, H5E_CANTGET, FAIL, "unable to check free space for file") + break; + } + + /* H5Fget_info1/2 */ + case H5VL_NATIVE_FILE_GET_INFO: + { + H5I_type_t type = (H5I_type_t)HDva_arg(arguments, int); /* enum work-around */ + H5F_info2_t *finfo = HDva_arg(arguments, H5F_info2_t *); + + /* Get the file struct. This call is careful to not return the file pointer + * for the top file in a mount hierarchy. + */ + if(NULL == (f = H5F__get_file(obj, type))) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "could not get a file struct") + + /* Get the file info */ + if(H5F__get_info(f, finfo) < 0) + HGOTO_ERROR(H5E_FILE, H5E_CANTGET, FAIL, "unable to retrieve file info") + + break; + } + + /* H5Fget_mdc_config */ + case H5VL_NATIVE_FILE_GET_MDC_CONF: + { + H5AC_cache_config_t *config_ptr = HDva_arg(arguments, H5AC_cache_config_t *); + + /* Go get the resize configuration */ + if(H5AC_get_cache_auto_resize_config(f->shared->cache, config_ptr) < 0) + HGOTO_ERROR(H5E_CACHE, H5E_SYSTEM, FAIL, "H5AC_get_cache_auto_resize_config() failed.") + break; + } + + /* H5Fget_mdc_hit_rate */ + case H5VL_NATIVE_FILE_GET_MDC_HR: + { + double *hit_rate_ptr = HDva_arg(arguments, double *); + + /* Go get the current hit rate */ + if(H5AC_get_cache_hit_rate(f->shared->cache, hit_rate_ptr) < 0) + HGOTO_ERROR(H5E_CACHE, H5E_SYSTEM, FAIL, "H5AC_get_cache_hit_rate() failed.") + break; + } + + /* H5Fget_mdc_size */ + case H5VL_NATIVE_FILE_GET_MDC_SIZE: + { + size_t *max_size_ptr = HDva_arg(arguments, size_t *); + size_t *min_clean_size_ptr = HDva_arg(arguments, size_t *); + size_t *cur_size_ptr = HDva_arg(arguments, size_t *); + int *cur_num_entries_ptr = HDva_arg(arguments, int *); + uint32_t cur_num_entries; + + /* Go get the size data */ + if(H5AC_get_cache_size(f->shared->cache, max_size_ptr, min_clean_size_ptr, + cur_size_ptr, &cur_num_entries) < 0) + HGOTO_ERROR(H5E_CACHE, H5E_SYSTEM, FAIL, "H5AC_get_cache_size() failed.") + + if(cur_num_entries_ptr != NULL) + *cur_num_entries_ptr = (int)cur_num_entries; + break; + } + + /* H5Fget_vfd_handle */ + case H5VL_NATIVE_FILE_GET_VFD_HANDLE: + { + void **file_handle = HDva_arg(arguments, void **); + hid_t fapl_id = HDva_arg(arguments, hid_t); + + /* Retrieve the VFD handle for the file */ + if(H5F_get_vfd_handle(f, fapl_id, file_handle) < 0) + HGOTO_ERROR(H5E_FILE, H5E_CANTGET, FAIL, "can't retrieve VFD handle") + break; + } + + /* H5Iget_file_id */ + case H5VL_NATIVE_FILE_GET_FILE_ID: + { + H5I_type_t type = (H5I_type_t)HDva_arg(arguments, int); /* enum work-around */ + hid_t *file_id = HDva_arg(arguments, hid_t *); + + if(NULL == (f = H5F__get_file(obj, type))) + HGOTO_ERROR(H5E_FILE, H5E_BADTYPE, FAIL, "not a file or file object") + if((*file_id = H5F__get_file_id(f)) < 0) + HGOTO_ERROR(H5E_FILE, H5E_CANTGET, FAIL, "can't get file ID") + break; + } + + /* H5Fclear_elink_file_cache */ + case H5VL_NATIVE_FILE_CLEAR_ELINK_CACHE: + { + /* Release the EFC */ + if(f->shared->efc) + if(H5F__efc_release(f->shared->efc) < 0) + HGOTO_ERROR(H5E_FILE, H5E_CANTRELEASE, FAIL, "can't release external file cache") + break; + } + + /* H5Freset_mdc_hit_rate_stats */ + case H5VL_NATIVE_FILE_RESET_MDC_HIT_RATE: + { + /* Reset the hit rate statistic */ + if(H5AC_reset_cache_hit_rate_stats(f->shared->cache) < 0) + HGOTO_ERROR(H5E_CACHE, H5E_SYSTEM, FAIL, "can't reset cache hit rate") + break; + } + + /* H5Fset_mdc_config */ + case H5VL_NATIVE_FILE_SET_MDC_CONFIG: + { + H5AC_cache_config_t *config_ptr = HDva_arg(arguments, H5AC_cache_config_t *); + + /* set the resize configuration */ + if(H5AC_set_cache_auto_resize_config(f->shared->cache, config_ptr) < 0) + HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "H5AC_set_cache_auto_resize_config() failed") + break; + } + + /* H5Fget_metadata_read_retry_info */ + case H5VL_NATIVE_FILE_GET_METADATA_READ_RETRY_INFO: + { + H5F_retry_info_t *info = HDva_arg(arguments, H5F_retry_info_t *); + + if(H5F_get_metadata_read_retry_info(f, info) < 0) + HGOTO_ERROR(H5E_CACHE, H5E_SYSTEM, FAIL, "can't get metadata read retry info") + + break; + } + + /* H5Fstart_swmr_write */ + case H5VL_NATIVE_FILE_START_SWMR_WRITE: + { + if(H5F__start_swmr_write(f) < 0) + HGOTO_ERROR(H5E_CACHE, H5E_SYSTEM, FAIL, "can't start SWMR write") + + break; + } + + /* H5Fstart_mdc_logging */ + case H5VL_NATIVE_FILE_START_MDC_LOGGING: + { + /* Call mdc logging function */ + if(H5C_start_logging(f->shared->cache) < 0) + HGOTO_ERROR(H5E_FILE, H5E_LOGFAIL, FAIL, "unable to start mdc logging") + + break; + } + + /* H5Fstop_mdc_logging */ + case H5VL_NATIVE_FILE_STOP_MDC_LOGGING: + { + /* Call mdc logging function */ + if(H5C_stop_logging(f->shared->cache) < 0) + HGOTO_ERROR(H5E_FILE, H5E_LOGFAIL, FAIL, "unable to stop mdc logging") + + break; + } + + /* H5Fget_mdc_logging_status */ + case H5VL_NATIVE_FILE_GET_MDC_LOGGING_STATUS: + { + hbool_t *is_enabled = HDva_arg(arguments, hbool_t *); + hbool_t *is_currently_logging = HDva_arg(arguments, hbool_t *); + + /* Call mdc logging function */ + if(H5C_get_logging_status(f->shared->cache, is_enabled, is_currently_logging) < 0) + HGOTO_ERROR(H5E_FILE, H5E_LOGFAIL, FAIL, "unable to get logging status") + + break; + } + + /* H5Fformat_convert */ + case H5VL_NATIVE_FILE_FORMAT_CONVERT: + { + /* Convert the format */ + if(H5F__format_convert(f) < 0) + HGOTO_ERROR(H5E_FILE, H5E_CANTCONVERT, FAIL, "can't convert file format") + + break; + } + + /* H5Freset_page_buffering_stats */ + case H5VL_NATIVE_FILE_RESET_PAGE_BUFFERING_STATS: + { + /* Sanity check */ + if(NULL == f->shared->page_buf) + HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "page buffering not enabled on file") + + /* Reset the statistics */ + if(H5PB_reset_stats(f->shared->page_buf) < 0) + HGOTO_ERROR(H5E_FILE, H5E_CANTGET, FAIL, "can't reset stats for page buffering") + + break; + } + + /* H5Fget_page_buffering_stats */ + case H5VL_NATIVE_FILE_GET_PAGE_BUFFERING_STATS: + { + unsigned *accesses = HDva_arg(arguments, unsigned *); + unsigned *hits = HDva_arg(arguments, unsigned *); + unsigned *misses = HDva_arg(arguments, unsigned *); + unsigned *evictions = HDva_arg(arguments, unsigned *); + unsigned *bypasses = HDva_arg(arguments, unsigned *); + + /* Sanity check */ + if(NULL == f->shared->page_buf) + HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "page buffering not enabled on file") + + /* Get the statistics */ + if(H5PB_get_stats(f->shared->page_buf, accesses, hits, misses, evictions, bypasses) < 0) + HGOTO_ERROR(H5E_FILE, H5E_CANTGET, FAIL, "can't retrieve stats for page buffering") + + break; + } + + /* H5Fget_mdc_image_info */ + case H5VL_NATIVE_FILE_GET_MDC_IMAGE_INFO: + { + haddr_t *image_addr = HDva_arg(arguments, haddr_t *); + hsize_t *image_len = HDva_arg(arguments, hsize_t *); + + /* Go get the address and size of the cache image */ + if(H5AC_get_mdc_image_info(f->shared->cache, image_addr, image_len) < 0) + HGOTO_ERROR(H5E_FILE, H5E_CANTGET, FAIL, "can't retrieve cache image info") + + break; + } + + /* H5Fget_eoa */ + case H5VL_NATIVE_FILE_GET_EOA: + { + haddr_t *eoa = HDva_arg(arguments, haddr_t *); + haddr_t rel_eoa; /* Relative address of EOA */ + + /* Sanity check */ + HDassert(eoa); + + /* This routine will work only for drivers with this feature enabled.*/ + /* We might introduce a new feature flag in the future */ + if(!H5F_HAS_FEATURE(f, H5FD_FEAT_SUPPORTS_SWMR_IO)) + HGOTO_ERROR(H5E_FILE, H5E_BADVALUE, FAIL, "must use a SWMR-compatible VFD for this public routine") + + /* The real work */ + if(HADDR_UNDEF == (rel_eoa = H5F_get_eoa(f, H5FD_MEM_DEFAULT))) + HGOTO_ERROR(H5E_FILE, H5E_CANTGET, FAIL, "get_eoa request failed") + + /* Set return value */ + /* (Note compensating for base address subtraction in internal routine) */ + *eoa = rel_eoa + H5F_get_base_addr(f); + + break; + } + + /* H5Fincrement_filesize */ + case H5VL_NATIVE_FILE_INCR_FILESIZE: + { + hsize_t increment = HDva_arg(arguments, hsize_t); + haddr_t max_eof_eoa; /* Maximum of the relative EOA & EOF */ + + /* This public routine will work only for drivers with this feature enabled.*/ + /* We might introduce a new feature flag in the future */ + if(!H5F_HAS_FEATURE(f, H5FD_FEAT_SUPPORTS_SWMR_IO)) + HGOTO_ERROR(H5E_FILE, H5E_BADVALUE, FAIL, "must use a SWMR-compatible VFD for this public routine") + + /* Get the maximum of EOA and EOF */ + if(H5F__get_max_eof_eoa(f, &max_eof_eoa) < 0) + HGOTO_ERROR(H5E_FILE, H5E_CANTGET, FAIL, "file can't get max eof/eoa ") + + /* Set EOA to the maximum value + increment */ + if(H5F__set_eoa(f, H5FD_MEM_DEFAULT, max_eof_eoa + increment) < 0) + HGOTO_ERROR(H5E_FILE, H5E_CANTSET, FAIL, "driver set_eoa request failed") + + break; + } + + /* H5Fset_latest_format, H5Fset_libver_bounds */ + case H5VL_NATIVE_FILE_SET_LIBVER_BOUNDS: + { + H5F_libver_t low = (H5F_libver_t)HDva_arg(arguments, int); /* enum work-around */ + H5F_libver_t high = (H5F_libver_t)HDva_arg(arguments, int); /* enum work-around */ + + /* Call internal set_libver_bounds function */ + if(H5F__set_libver_bounds(f, low, high) < 0) + HGOTO_ERROR(H5E_FILE, H5E_CANTSET, FAIL, "cannot set low/high bounds") + + break; + } + + default: + HGOTO_ERROR(H5E_VOL, H5E_UNSUPPORTED, FAIL, "invalid optional operation") + } /* end switch */ + +done: + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5VL__native_file_optional() */ + + +/*------------------------------------------------------------------------- + * Function: H5VL__native_file_close + * + * Purpose: Handles the file close callback + * + * Return: Success: SUCCEED + * Failure: FAIL (file will not be closed) + * + *------------------------------------------------------------------------- + */ +herr_t +H5VL__native_file_close(void *file, hid_t H5_ATTR_UNUSED dxpl_id, + void H5_ATTR_UNUSED **req) +{ + int nref; + H5F_t *f = (H5F_t *)file; + hid_t file_id = H5I_INVALID_HID; + herr_t ret_value = SUCCEED; /* Return value */ + + FUNC_ENTER_PACKAGE + + /* This routine should only be called when a file ID's ref count drops to zero */ + HDassert(H5F_ID_EXISTS(f)); + + /* Flush file if this is the last reference to this id and we have write + * intent, unless it will be flushed by the "shared" file being closed. + * This is only necessary to replicate previous behaviour, and could be + * disabled by an option/property to improve performance. + */ + if((H5F_NREFS(f) > 1) && (H5F_INTENT(f) & H5F_ACC_RDWR)) { + /* Get the file ID corresponding to the H5F_t struct */ + if(H5I_find_id(f, H5I_FILE, &file_id) < 0 || H5I_INVALID_HID == file_id) + HGOTO_ERROR(H5E_ATOM, H5E_CANTGET, FAIL, "invalid atom") + + /* Get the number of references outstanding for this file ID */ + if((nref = H5I_get_ref(file_id, FALSE)) < 0) + HGOTO_ERROR(H5E_ATOM, H5E_CANTGET, FAIL, "can't get ID ref count") + if(nref == 1) + if(H5F__flush(f) < 0) + HGOTO_ERROR(H5E_CACHE, H5E_CANTFLUSH, FAIL, "unable to flush cache") + } /* end if */ + + /* Close the file */ + if(H5F__close(f) < 0) + HGOTO_ERROR(H5E_FILE, H5E_CANTDEC, FAIL, "can't close file") + +done: + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5VL__native_file_close() */ + diff --git a/src/H5VLnative_group.c b/src/H5VLnative_group.c new file mode 100644 index 0000000..9c07b3d --- /dev/null +++ b/src/H5VLnative_group.c @@ -0,0 +1,363 @@ +/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * + * 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 COPYING file, which can be found at the root of the source code * + * distribution tree, or in https://support.hdfgroup.org/ftp/HDF5/releases. * + * If you do not have access to either file, you may request a copy from * + * help@hdfgroup.org. * + * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ + +/* + * Purpose: Group callbacks for the native VOL connector + * + */ + +#define H5G_FRIEND /* Suppress error about including H5Gpkg */ + +#include "H5private.h" /* Generic Functions */ +#include "H5Eprivate.h" /* Error handling */ +#include "H5Gpkg.h" /* Groups */ +#include "H5Iprivate.h" /* IDs */ +#include "H5Oprivate.h" /* Object headers */ +#include "H5Pprivate.h" /* Property lists */ +#include "H5VLprivate.h" /* Virtual Object Layer */ + +#include "H5VLnative_private.h" /* Native VOL connector */ + + + +/*------------------------------------------------------------------------- + * Function: H5VL__native_group_create + * + * Purpose: Handles the group create callback + * + * Return: Success: group pointer + * Failure: NULL + * + *------------------------------------------------------------------------- + */ +void * +H5VL__native_group_create(void *obj, const H5VL_loc_params_t *loc_params, const char *name, + hid_t gcpl_id, hid_t H5_ATTR_UNUSED gapl_id, hid_t H5_ATTR_UNUSED dxpl_id, + void H5_ATTR_UNUSED **req) +{ + H5P_genplist_t *plist; /* Property list pointer */ + H5G_loc_t loc; /* Location to create group */ + H5G_t *grp = NULL; /* New group created */ + hid_t lcpl_id; + void *ret_value; + + FUNC_ENTER_PACKAGE + + /* Get the property list structure */ + if(NULL == (plist = (H5P_genplist_t *)H5I_object(gcpl_id))) + HGOTO_ERROR(H5E_ATOM, H5E_BADATOM, NULL, "can't find object for ID") + + /* Get creation properties */ + if(H5P_get(plist, H5VL_PROP_GRP_LCPL_ID, &lcpl_id) < 0) + HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, NULL, "can't get property value for lcpl id") + + /* Set up the location */ + if(H5G_loc_real(obj, loc_params->obj_type, &loc) < 0) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, NULL, "not a file or file object") + + /* if name is NULL then this is from H5Gcreate_anon */ + if(name == NULL) { + H5G_obj_create_t gcrt_info; /* Information for group creation */ + + /* Set up group creation info */ + gcrt_info.gcpl_id = gcpl_id; + gcrt_info.cache_type = H5G_NOTHING_CACHED; + HDmemset(&gcrt_info.cache, 0, sizeof(gcrt_info.cache)); + + /* Create the new group & get its ID */ + if(NULL == (grp = H5G__create(loc.oloc->file, &gcrt_info))) + HGOTO_ERROR(H5E_SYM, H5E_CANTINIT, NULL, "unable to create group") + } /* end if */ + /* otherwise it's from H5Gcreate */ + else { + /* Create the new group & get its ID */ + if(NULL == (grp = H5G__create_named(&loc, name, lcpl_id, gcpl_id))) + HGOTO_ERROR(H5E_SYM, H5E_CANTINIT, NULL, "unable to create group") + } /* end else */ + + ret_value = (void *)grp; + +done: + if(name == NULL) { + /* Release the group's object header, if it was created */ + if(grp) { + H5O_loc_t *oloc; /* Object location for group */ + + /* Get the new group's object location */ + if(NULL == (oloc = H5G_oloc(grp))) + HDONE_ERROR(H5E_SYM, H5E_CANTGET, NULL, "unable to get object location of group") + + /* Decrement refcount on group's object header in memory */ + if(H5O_dec_rc_by_loc(oloc) < 0) + HDONE_ERROR(H5E_SYM, H5E_CANTDEC, NULL, "unable to decrement refcount on newly created object") + } /* end if */ + } /* end if */ + + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5VL__native_group_create() */ + + +/*------------------------------------------------------------------------- + * Function: H5VL__native_group_open + * + * Purpose: Handles the group open callback + * + * Return: Success: group pointer + * Failure: NULL + * + *------------------------------------------------------------------------- + */ +void * +H5VL__native_group_open(void *obj, const H5VL_loc_params_t *loc_params, const char *name, + hid_t H5_ATTR_UNUSED gapl_id, hid_t H5_ATTR_UNUSED dxpl_id, void H5_ATTR_UNUSED **req) +{ + H5G_loc_t loc; /* Location to open group */ + H5G_t *grp = NULL; /* New group opend */ + void *ret_value; + + FUNC_ENTER_PACKAGE + + /* Set up the location */ + if(H5G_loc_real(obj, loc_params->obj_type, &loc) < 0) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, NULL, "not a file or file object") + + /* Open the group */ + if((grp = H5G__open_name(&loc, name)) == NULL) + HGOTO_ERROR(H5E_SYM, H5E_CANTOPENOBJ, NULL, "unable to open group") + + ret_value = (void *)grp; + +done: + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5VL__native_group_open() */ + + +/*------------------------------------------------------------------------- + * Function: H5VL__native_group_get + * + * Purpose: Handles the group get callback + * + * Return: SUCCEED/FAIL + * + *------------------------------------------------------------------------- + */ +herr_t +H5VL__native_group_get(void *obj, H5VL_group_get_t get_type, + hid_t H5_ATTR_UNUSED dxpl_id, void H5_ATTR_UNUSED **req, va_list arguments) +{ + herr_t ret_value = SUCCEED; /* Return value */ + + FUNC_ENTER_PACKAGE + + switch(get_type) { + /* H5Gget_create_plist */ + case H5VL_GROUP_GET_GCPL: + { + hid_t *new_gcpl_id = HDva_arg(arguments, hid_t *); + H5G_t *grp = (H5G_t *)obj; + + if((*new_gcpl_id = H5G_get_create_plist(grp)) < 0) + HGOTO_ERROR(H5E_ARGS, H5E_CANTGET, FAIL, "can't get creation property list for group") + break; + } + + /* H5Gget_info */ + case H5VL_GROUP_GET_INFO: + { + const H5VL_loc_params_t *loc_params = HDva_arg(arguments, const H5VL_loc_params_t *); + H5G_info_t *group_info = HDva_arg(arguments, H5G_info_t *); + H5G_loc_t loc; + + if(H5G_loc_real(obj, loc_params->obj_type, &loc) < 0) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a file or file object") + + if(loc_params->type == H5VL_OBJECT_BY_SELF) { + /* H5Gget_info */ + + /* Retrieve the group's information */ + if(H5G__obj_info(loc.oloc, group_info) < 0) + HGOTO_ERROR(H5E_SYM, H5E_CANTGET, FAIL, "can't retrieve group info") + } /* end if */ + else if(loc_params->type == H5VL_OBJECT_BY_NAME) { + /* H5Gget_info_by_name */ + + /* Retrieve the group's information */ + if(H5G__get_info_by_name(&loc, loc_params->loc_data.loc_by_name.name, group_info) < 0) + HGOTO_ERROR(H5E_SYM, H5E_CANTGET, FAIL, "can't retrieve group info") + } /* end else-if */ + else if(loc_params->type == H5VL_OBJECT_BY_IDX) { + /* H5Gget_info_by_idx */ + + /* Retrieve the group's information */ + if(H5G__get_info_by_idx(&loc, loc_params->loc_data.loc_by_idx.name, loc_params->loc_data.loc_by_idx.idx_type, + loc_params->loc_data.loc_by_idx.order, loc_params->loc_data.loc_by_idx.n, group_info) < 0) + HGOTO_ERROR(H5E_SYM, H5E_CANTGET, FAIL, "can't retrieve group info") + } /* end else-if */ + else + HGOTO_ERROR(H5E_VOL, H5E_UNSUPPORTED, FAIL, "unknown get info parameters") + break; + } + + default: + HGOTO_ERROR(H5E_VOL, H5E_CANTGET, FAIL, "can't get this type of information from group") + } /* end switch */ + +done: + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5VL__native_group_get() */ + + +/*------------------------------------------------------------------------- + * Function: H5VL__native_group_specific + * + * Purpose: Handles the group specific callback + * + * Return: SUCCEED/FAIL + * + *------------------------------------------------------------------------- + */ +herr_t +H5VL__native_group_specific(void *obj, H5VL_group_specific_t specific_type, + hid_t H5_ATTR_UNUSED dxpl_id, void H5_ATTR_UNUSED **req, va_list arguments) +{ + H5G_t *grp = (H5G_t *)obj; + herr_t ret_value = SUCCEED; /* Return value */ + + FUNC_ENTER_PACKAGE + + switch(specific_type) { + case H5VL_GROUP_FLUSH: + { + hid_t group_id = HDva_arg(arguments, hid_t); + + /* Flush object's metadata to file */ + if(H5O_flush_common(&grp->oloc, group_id) < 0) + HGOTO_ERROR(H5E_SYM, H5E_CANTFLUSH, FAIL, "unable to flush group") + + break; + } + + case H5VL_GROUP_REFRESH: + { + hid_t group_id = HDva_arg(arguments, hid_t); + + /* Call private function to refresh group object */ + if((H5O_refresh_metadata(group_id, grp->oloc)) < 0) + HGOTO_ERROR(H5E_SYM, H5E_CANTLOAD, FAIL, "unable to refresh group") + + break; + } + + default: + HGOTO_ERROR(H5E_VOL, H5E_UNSUPPORTED, FAIL, "invalid specific operation") + } /* end switch */ + +done: + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5VL__native_group_specific() */ + + +/*------------------------------------------------------------------------- + * Function: H5VL__native_group_optional + * + * Purpose: Handles the group optional callback + * + * Return: SUCCEED/FAIL + * + *------------------------------------------------------------------------- + */ +herr_t +H5VL__native_group_optional(void *obj, hid_t H5_ATTR_UNUSED dxpl_id, + void H5_ATTR_UNUSED **req, va_list arguments) +{ + H5VL_native_group_optional_t optional_type; + herr_t ret_value = SUCCEED; /* Return value */ + + FUNC_ENTER_PACKAGE + + optional_type = HDva_arg(arguments, H5VL_native_group_optional_t); + switch(optional_type) { +#ifndef H5_NO_DEPRECATED_SYMBOLS + /* H5Giterate (deprecated) */ + case H5VL_NATIVE_GROUP_ITERATE_OLD: + { + const H5VL_loc_params_t *loc_params = HDva_arg(arguments, const H5VL_loc_params_t *); + hsize_t idx = HDva_arg(arguments, hsize_t); + hsize_t *last_obj = HDva_arg(arguments, hsize_t *); + const H5G_link_iterate_t *lnk_op = HDva_arg(arguments, const H5G_link_iterate_t *); + void *op_data = HDva_arg(arguments, void *); + H5G_loc_t grp_loc; + + /* Get the location struct for the object */ + if(H5G_loc_real(obj, loc_params->obj_type, &grp_loc) < 0) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a file or file object") + + /* Call the actual iteration routine */ + if((ret_value = H5G_iterate(&grp_loc, loc_params->loc_data.loc_by_name.name, H5_INDEX_NAME, H5_ITER_INC, idx, last_obj, lnk_op, op_data)) < 0) + HERROR(H5E_VOL, H5E_BADITER, "error iterating over group's links"); + + break; + } + + /* H5Gget_objinfo (deprecated) */ + case H5VL_NATIVE_GROUP_GET_OBJINFO: + { + const H5VL_loc_params_t *loc_params = HDva_arg(arguments, const H5VL_loc_params_t *); + hbool_t follow_link = (hbool_t)HDva_arg(arguments, unsigned); + H5G_stat_t *statbuf = HDva_arg(arguments, H5G_stat_t *); + H5G_loc_t grp_loc; + + /* Get the location struct for the object */ + if(H5G_loc_real(obj, loc_params->obj_type, &grp_loc) < 0) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a file or file object") + + /* Call the actual group objinfo routine */ + if(H5G__get_objinfo(&grp_loc, loc_params->loc_data.loc_by_name.name, follow_link, statbuf) < 0) + HGOTO_ERROR(H5E_SYM, H5E_CANTGET, FAIL, "cannot stat object") + + break; + } +#endif /* H5_NO_DEPRECATED_SYMBOLS */ + + default: + HGOTO_ERROR(H5E_VOL, H5E_UNSUPPORTED, FAIL, "invalid optional operation") + } /* end switch */ + +done: + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5VL__native_group_optional() */ + + +/*------------------------------------------------------------------------- + * Function: H5VL__native_group_close + * + * Purpose: Handles the group close callback + * + * Return: Success: SUCCEED + * Failure: FAIL (group will not be closed) + * + *------------------------------------------------------------------------- + */ +herr_t +H5VL__native_group_close(void *grp, hid_t H5_ATTR_UNUSED dxpl_id, void H5_ATTR_UNUSED **req) +{ + herr_t ret_value = SUCCEED; /* Return value */ + + FUNC_ENTER_PACKAGE + + if(H5G_close((H5G_t *)grp) < 0) + HGOTO_ERROR(H5E_SYM, H5E_CLOSEERROR, FAIL, "can't close group") + +done: + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5VL__native_group_close() */ + diff --git a/src/H5VLnative_link.c b/src/H5VLnative_link.c new file mode 100644 index 0000000..98d2ccd --- /dev/null +++ b/src/H5VLnative_link.c @@ -0,0 +1,435 @@ +/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * + * 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 COPYING file, which can be found at the root of the source code * + * distribution tree, or in https://support.hdfgroup.org/ftp/HDF5/releases. * + * If you do not have access to either file, you may request a copy from * + * help@hdfgroup.org. * + * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ + +/* + * Purpose: Link callbacks for the native VOL connector + * + */ + +#define H5L_FRIEND /* Suppress error about including H5Lpkg */ + +#include "H5private.h" /* Generic Functions */ +#include "H5Eprivate.h" /* Error handling */ +#include "H5Gprivate.h" /* Groups */ +#include "H5Iprivate.h" /* IDs */ +#include "H5Lpkg.h" /* Links */ +#include "H5Pprivate.h" /* Property lists */ +#include "H5VLprivate.h" /* Virtual Object Layer */ + +#include "H5VLnative_private.h" /* Native VOL connector */ + + + +/*------------------------------------------------------------------------- + * Function: H5VL__native_link_create + * + * Purpose: Handles the link create callback + * + * Return: SUCCEED/FAIL + * + *------------------------------------------------------------------------- + */ +herr_t +H5VL__native_link_create(H5VL_link_create_type_t create_type, void *obj, + const H5VL_loc_params_t *loc_params, hid_t lcpl_id, hid_t H5_ATTR_UNUSED lapl_id, + hid_t H5_ATTR_UNUSED dxpl_id, void H5_ATTR_UNUSED **req) +{ + H5P_genplist_t *plist; /* Property list pointer */ + herr_t ret_value = SUCCEED; /* Return value */ + + FUNC_ENTER_PACKAGE + + /* Get the plist structure */ + if(NULL == (plist = (H5P_genplist_t *)H5I_object(lcpl_id))) + HGOTO_ERROR(H5E_ATOM, H5E_BADATOM, FAIL, "can't find object for ID"); + + switch(create_type) { + case H5VL_LINK_CREATE_HARD: + { + H5G_loc_t cur_loc; + H5G_loc_t link_loc; + void *cur_obj; + H5VL_loc_params_t cur_params; + + if(H5P_get(plist, H5VL_PROP_LINK_TARGET, &cur_obj) < 0) + HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, FAIL, "can't get property value for current location id") + if(H5P_get(plist, H5VL_PROP_LINK_TARGET_LOC_PARAMS, &cur_params) < 0) + HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, FAIL, "can't get property value for current name") + + if(NULL != cur_obj && H5G_loc_real(cur_obj, cur_params.obj_type, &cur_loc) < 0) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a file or file object") + if(NULL != obj && H5G_loc_real(obj, loc_params->obj_type, &link_loc) < 0) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a file or file object") + + /* H5Lcreate_hard */ + if(H5VL_OBJECT_BY_NAME == cur_params.type) { + H5G_loc_t *cur_loc_p, *link_loc_p; + + /* Set up current & new location pointers */ + cur_loc_p = &cur_loc; + link_loc_p = &link_loc; + if(NULL == cur_obj) + cur_loc_p = link_loc_p; + else if(NULL == obj) + link_loc_p = cur_loc_p; + else if(cur_loc_p->oloc->file != link_loc_p->oloc->file) + HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "source and destination should be in the same file.") + + /* Create the link */ + if((ret_value = H5L_create_hard(cur_loc_p, cur_params.loc_data.loc_by_name.name, + link_loc_p, loc_params->loc_data.loc_by_name.name, lcpl_id)) < 0) + HGOTO_ERROR(H5E_LINK, H5E_CANTINIT, FAIL, "unable to create link") + } /* end if */ + else { /* H5Olink */ + /* Link to the object */ + if(H5L_link(&link_loc, loc_params->loc_data.loc_by_name.name, &cur_loc, lcpl_id) < 0) + HGOTO_ERROR(H5E_OHDR, H5E_CANTINIT, FAIL, "unable to create link") + } /* end else */ + break; + } + + case H5VL_LINK_CREATE_SOFT: + { + char *target_name; + H5G_loc_t link_loc; /* Group location for new link */ + + if(H5G_loc_real(obj, loc_params->obj_type, &link_loc) < 0) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a file or file object") + + if(H5P_get(plist, H5VL_PROP_LINK_TARGET_NAME, &target_name) < 0) + HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, FAIL, "can't get property value for targe name") + + /* Create the link */ + if((ret_value = H5L_create_soft(target_name, &link_loc, loc_params->loc_data.loc_by_name.name, lcpl_id)) < 0) + HGOTO_ERROR(H5E_LINK, H5E_CANTINIT, FAIL, "unable to create link") + break; + } + + case H5VL_LINK_CREATE_UD: + { + H5G_loc_t link_loc; /* Group location for new link */ + H5L_type_t link_type; + void *udata; + size_t udata_size; + + if(H5G_loc_real(obj, loc_params->obj_type, &link_loc) < 0) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a file or file object") + + if(H5P_get(plist, H5VL_PROP_LINK_TYPE, &link_type) < 0) + HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, FAIL, "can't get property value for link type") + if(H5P_get(plist, H5VL_PROP_LINK_UDATA, &udata) < 0) + HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, FAIL, "can't get property value for udata") + if(H5P_get(plist, H5VL_PROP_LINK_UDATA_SIZE, &udata_size) < 0) + HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, FAIL, "can't get property value for udata size") + + /* Create link */ + if(H5L__create_ud(&link_loc, loc_params->loc_data.loc_by_name.name, udata, udata_size, + link_type, lcpl_id) < 0) + HGOTO_ERROR(H5E_LINK, H5E_CANTINIT, FAIL, "unable to create link") + break; + } + + default: + HGOTO_ERROR(H5E_LINK, H5E_CANTINIT, FAIL, "invalid link creation call") + } /* end switch */ + +done: + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5VL__native_link_create() */ + + +/*------------------------------------------------------------------------- + * Function: H5VL__native_link_copy + * + * Purpose: Handles the link copy callback + * + * Return: SUCCEED/FAIL + * + *------------------------------------------------------------------------- + */ +herr_t +H5VL__native_link_copy(void *src_obj, const H5VL_loc_params_t *loc_params1, + void *dst_obj, const H5VL_loc_params_t *loc_params2, hid_t lcpl_id, + hid_t H5_ATTR_UNUSED lapl_id, hid_t H5_ATTR_UNUSED dxpl_id, + void H5_ATTR_UNUSED **req) +{ + H5G_loc_t src_loc, *src_loc_p; + H5G_loc_t dst_loc, *dst_loc_p; + herr_t ret_value = SUCCEED; /* Return value */ + + FUNC_ENTER_PACKAGE + + if(NULL != src_obj && H5G_loc_real(src_obj, loc_params1->obj_type, &src_loc) < 0) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a file or file object") + if(NULL != dst_obj && H5G_loc_real(dst_obj, loc_params2->obj_type, &dst_loc) < 0) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a file or file object") + + /* Set up src & dst location pointers */ + src_loc_p = &src_loc; + dst_loc_p = &dst_loc; + if(NULL == src_obj) + src_loc_p = dst_loc_p; + else if(NULL == dst_obj) + dst_loc_p = src_loc_p; + + /* Copy the link */ + if(H5L_move(src_loc_p, loc_params1->loc_data.loc_by_name.name, + dst_loc_p, loc_params2->loc_data.loc_by_name.name, + TRUE, lcpl_id) < 0) + HGOTO_ERROR(H5E_LINK, H5E_CANTCOPY, FAIL, "unable to copy link") + +done: + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5VL__native_link_copy() */ + + +/*------------------------------------------------------------------------- + * Function: H5VL__native_link_move + * + * Purpose: Handles the link move callback + * + * Return: SUCCEED/FAIL + * + *------------------------------------------------------------------------- + */ +herr_t +H5VL__native_link_move(void *src_obj, const H5VL_loc_params_t *loc_params1, + void *dst_obj, const H5VL_loc_params_t *loc_params2, hid_t lcpl_id, + hid_t H5_ATTR_UNUSED lapl_id, hid_t H5_ATTR_UNUSED dxpl_id, + void H5_ATTR_UNUSED **req) +{ + H5G_loc_t src_loc, *src_loc_p; + H5G_loc_t dst_loc, *dst_loc_p; + herr_t ret_value = SUCCEED; /* Return value */ + + FUNC_ENTER_PACKAGE + + if(NULL != src_obj && H5G_loc_real(src_obj, loc_params1->obj_type, &src_loc) < 0) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a file or file object") + if(NULL != dst_obj && H5G_loc_real(dst_obj, loc_params2->obj_type, &dst_loc) < 0) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a file or file object") + + /* Set up src & dst location pointers */ + src_loc_p = &src_loc; + dst_loc_p = &dst_loc; + if(NULL == src_obj) + src_loc_p = dst_loc_p; + else if(NULL == dst_obj) + dst_loc_p = src_loc_p; + + /* Move the link */ + if(H5L_move(src_loc_p, loc_params1->loc_data.loc_by_name.name, + dst_loc_p, loc_params2->loc_data.loc_by_name.name, + FALSE, lcpl_id) < 0) + HGOTO_ERROR(H5E_LINK, H5E_CANTMOVE, FAIL, "unable to move link") + +done: + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5VL__native_link_move() */ + + +/*------------------------------------------------------------------------- + * Function: H5VL__native_link_get + * + * Purpose: Handles the link get callback + * + * Return: SUCCEED/FAIL + * + *------------------------------------------------------------------------- + */ +herr_t +H5VL__native_link_get(void *obj, const H5VL_loc_params_t *loc_params, H5VL_link_get_t get_type, + hid_t H5_ATTR_UNUSED dxpl_id, void H5_ATTR_UNUSED **req, va_list arguments) +{ + H5G_loc_t loc; + herr_t ret_value = SUCCEED; /* Return value */ + + FUNC_ENTER_PACKAGE + + if(H5G_loc_real(obj, loc_params->obj_type, &loc) < 0) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a file or file object") + + switch(get_type) { + /* H5Lget_info/H5Lget_info_by_idx */ + case H5VL_LINK_GET_INFO: + { + H5L_info_t *linfo = HDva_arg(arguments, H5L_info_t *); + + /* Get the link information */ + if(loc_params->type == H5VL_OBJECT_BY_NAME) { /* H5Lget_info */ + if(H5L_get_info(&loc, loc_params->loc_data.loc_by_name.name, linfo) < 0) + HGOTO_ERROR(H5E_LINK, H5E_NOTFOUND, FAIL, "unable to get link info") + } /* end if */ + else if(loc_params->type == H5VL_OBJECT_BY_IDX) { /* H5Lget_info_by_idx */ + if(H5L_get_info_by_idx(&loc, loc_params->loc_data.loc_by_idx.name, loc_params->loc_data.loc_by_idx.idx_type, + loc_params->loc_data.loc_by_idx.order, loc_params->loc_data.loc_by_idx.n, linfo) < 0) + HGOTO_ERROR(H5E_LINK, H5E_NOTFOUND, FAIL, "unable to get link info") + } /* end else-if */ + else + HGOTO_ERROR(H5E_LINK, H5E_NOTFOUND, FAIL, "unable to get link info") + break; + } + + /* H5Lget_name_by_idx */ + case H5VL_LINK_GET_NAME: + { + char *name = HDva_arg(arguments, char *); + size_t size = HDva_arg(arguments, size_t); + ssize_t *ret = HDva_arg(arguments, ssize_t *); + + /* Get the link name */ + if((*ret = H5L_get_name_by_idx(&loc, loc_params->loc_data.loc_by_idx.name, loc_params->loc_data.loc_by_idx.idx_type, + loc_params->loc_data.loc_by_idx.order, loc_params->loc_data.loc_by_idx.n, name, size)) < 0) + HGOTO_ERROR(H5E_LINK, H5E_NOTFOUND, FAIL, "unable to get link info") + + break; + } + + /* H5Lget_val/H5Lget_val_by_idx */ + case H5VL_LINK_GET_VAL: + { + void *buf = HDva_arg(arguments, void *); + size_t size = HDva_arg(arguments, size_t); + + /* Get the link information */ + if(loc_params->type == H5VL_OBJECT_BY_NAME) { /* H5Lget_val */ + if(H5L_get_val(&loc, loc_params->loc_data.loc_by_name.name, buf, size) < 0) + HGOTO_ERROR(H5E_LINK, H5E_NOTFOUND, FAIL, "unable to get link value") + } + else if(loc_params->type == H5VL_OBJECT_BY_IDX) { /* H5Lget_val_by_idx */ + + if(H5L_get_val_by_idx(&loc, loc_params->loc_data.loc_by_idx.name, loc_params->loc_data.loc_by_idx.idx_type, + loc_params->loc_data.loc_by_idx.order, loc_params->loc_data.loc_by_idx.n, buf, size) < 0) + HGOTO_ERROR(H5E_LINK, H5E_NOTFOUND, FAIL, "unable to get link val") + } + else + HGOTO_ERROR(H5E_LINK, H5E_NOTFOUND, FAIL, "unable to get link val") + + break; + } + + default: + HGOTO_ERROR(H5E_VOL, H5E_CANTGET, FAIL, "can't get this type of information from link") + } /* end switch */ + +done: + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5VL__native_link_get() */ + + +/*------------------------------------------------------------------------- + * Function: H5VL__native_link_specific + * + * Purpose: Handles the link specific callback + * + * Return: SUCCEED/FAIL + * + *------------------------------------------------------------------------- + */ +herr_t +H5VL__native_link_specific(void *obj, const H5VL_loc_params_t *loc_params, H5VL_link_specific_t specific_type, + hid_t H5_ATTR_UNUSED dxpl_id, void H5_ATTR_UNUSED **req, va_list arguments) +{ + herr_t ret_value = SUCCEED; /* Return value */ + + FUNC_ENTER_PACKAGE + + switch(specific_type) { + case H5VL_LINK_EXISTS: + { + htri_t *ret = HDva_arg(arguments, htri_t *); + H5G_loc_t loc; + + if(H5G_loc_real(obj, loc_params->obj_type, &loc) < 0) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a file or file object") + + /* Check for the existence of the link */ + if((*ret = H5L_exists(&loc, loc_params->loc_data.loc_by_name.name)) < 0) + HGOTO_ERROR(H5E_LINK, H5E_NOTFOUND, FAIL, "unable to specific link info") + break; + } + + case H5VL_LINK_ITER: + { + H5G_loc_t loc; + hbool_t recursive = (hbool_t)HDva_arg(arguments, unsigned); + H5_index_t idx_type = (H5_index_t)HDva_arg(arguments, int); /* enum work-around */ + H5_iter_order_t order = (H5_iter_order_t)HDva_arg(arguments, int); /* enum work-around */ + hsize_t *idx_p = HDva_arg(arguments, hsize_t *); + H5L_iterate_t op = HDva_arg(arguments, H5L_iterate_t); + void *op_data = HDva_arg(arguments, void *); + + /* Get the location */ + if(H5G_loc_real(obj, loc_params->obj_type, &loc) < 0) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a location") + + /* Visit or iterate over the links */ + if(loc_params->type == H5VL_OBJECT_BY_SELF) { + if(recursive) { + /* H5Lvisit */ + if((ret_value = H5G_visit(&loc, ".", idx_type, order, op, op_data)) < 0) + HGOTO_ERROR(H5E_LINK, H5E_BADITER, FAIL, "link visitation failed") + } /* end if */ + else { + /* H5Literate */ + if((ret_value = H5L_iterate(&loc, ".", idx_type, order, idx_p, op, op_data)) < 0) + HGOTO_ERROR(H5E_LINK, H5E_BADITER, FAIL, "error iterating over links") + } /* end else */ + } /* end if */ + else if(loc_params->type == H5VL_OBJECT_BY_NAME) { + if(recursive) { + /* H5Lvisit_by_name */ + if((ret_value = H5G_visit(&loc, loc_params->loc_data.loc_by_name.name, idx_type, order, op, op_data)) < 0) + HGOTO_ERROR(H5E_LINK, H5E_BADITER, FAIL, "link visitation failed") + } /* end if */ + else { + /* H5Literate_by_name */ + if((ret_value = H5L_iterate(&loc, loc_params->loc_data.loc_by_name.name, idx_type, order, idx_p, op, op_data)) < 0) + HGOTO_ERROR(H5E_LINK, H5E_BADITER, FAIL, "error iterating over links") + } /* end else */ + } /* end else-if */ + else + HGOTO_ERROR(H5E_LINK, H5E_UNSUPPORTED, FAIL, "unknown link iterate params") + + break; + } + + case H5VL_LINK_DELETE: + { + H5G_loc_t loc; + + if(H5G_loc_real(obj, loc_params->obj_type, &loc) < 0) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a file or file object") + + /* Unlink */ + if(loc_params->type == H5VL_OBJECT_BY_NAME) { /* H5Ldelete */ + if(H5L_delete(&loc, loc_params->loc_data.loc_by_name.name) < 0) + HGOTO_ERROR(H5E_LINK, H5E_CANTDELETE, FAIL, "unable to delete link") + } /* end if */ + else if(loc_params->type == H5VL_OBJECT_BY_IDX) { /* H5Ldelete_by_idx */ + if(H5L_delete_by_idx(&loc, loc_params->loc_data.loc_by_idx.name, loc_params->loc_data.loc_by_idx.idx_type, + loc_params->loc_data.loc_by_idx.order, loc_params->loc_data.loc_by_idx.n) < 0) + HGOTO_ERROR(H5E_LINK, H5E_CANTDELETE, FAIL, "unable to delete link") + } /* end else-if */ + else + HGOTO_ERROR(H5E_LINK, H5E_CANTDELETE, FAIL, "unable to delete link") + break; + } + + default: + HGOTO_ERROR(H5E_VOL, H5E_UNSUPPORTED, FAIL, "invalid specific operation") + } /* end switch */ + +done: + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5VL__native_link_specific() */ + diff --git a/src/H5VLnative_object.c b/src/H5VLnative_object.c new file mode 100644 index 0000000..0b1d73a --- /dev/null +++ b/src/H5VLnative_object.c @@ -0,0 +1,482 @@ +/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * + * 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 COPYING file, which can be found at the root of the source code * + * distribution tree, or in https://support.hdfgroup.org/ftp/HDF5/releases. * + * If you do not have access to either file, you may request a copy from * + * help@hdfgroup.org. * + * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ + +/* + * Purpose: Object callbacks for the native VOL connector + * + */ + +#define H5O_FRIEND /* Suppress error about including H5Opkg */ +#define H5R_FRIEND /* Suppress error about including H5Rpkg */ + +#include "H5private.h" /* Generic Functions */ +#include "H5Eprivate.h" /* Error handling */ +#include "H5Fprivate.h" /* Files */ +#include "H5Gprivate.h" /* Groups */ +#include "H5Iprivate.h" /* IDs */ +#include "H5Opkg.h" /* Object headers */ +#include "H5Pprivate.h" /* Property lists */ +#include "H5Rpkg.h" /* References */ +#include "H5VLprivate.h" /* Virtual Object Layer */ + +#include "H5VLnative_private.h" /* Native VOL connector */ + + +/*------------------------------------------------------------------------- + * Function: H5VL__native_object_open + * + * Purpose: Handles the object open callback + * + * Return: Success: object pointer + * Failure: NULL + * + *------------------------------------------------------------------------- + */ +void * +H5VL__native_object_open(void *obj, const H5VL_loc_params_t *loc_params, H5I_type_t *opened_type, + hid_t H5_ATTR_UNUSED dxpl_id, void H5_ATTR_UNUSED **req) +{ + H5G_loc_t loc; + void *ret_value = NULL; + + FUNC_ENTER_PACKAGE + + if(H5G_loc_real(obj, loc_params->obj_type, &loc) < 0) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, NULL, "not a file or file object") + + switch(loc_params->type) { + case H5VL_OBJECT_BY_NAME: + { + /* Open the object */ + if(NULL == (ret_value = H5O_open_name(&loc, loc_params->loc_data.loc_by_name.name, opened_type))) + HGOTO_ERROR(H5E_OHDR, H5E_CANTOPENOBJ, NULL, "unable to open object by name") + break; + } + + case H5VL_OBJECT_BY_IDX: + { + /* Open the object */ + if(NULL == (ret_value = H5O_open_by_idx(&loc, loc_params->loc_data.loc_by_idx.name, loc_params->loc_data.loc_by_idx.idx_type, + loc_params->loc_data.loc_by_idx.order, loc_params->loc_data.loc_by_idx.n, opened_type))) + HGOTO_ERROR(H5E_OHDR, H5E_CANTOPENOBJ, NULL, "unable to open object by index") + break; + } + + case H5VL_OBJECT_BY_ADDR: + { + /* Open the object */ + if(NULL == (ret_value = H5O_open_by_addr(&loc, loc_params->loc_data.loc_by_addr.addr, opened_type))) + HGOTO_ERROR(H5E_OHDR, H5E_CANTOPENOBJ, NULL, "unable to open object by address") + break; + } + + case H5VL_OBJECT_BY_REF: + { + hid_t temp_id = H5I_INVALID_HID; + H5F_t *file = NULL; + + /* Get the file pointer from the entry */ + file = loc.oloc->file; + + /* Create reference */ + if((temp_id = H5R__dereference(file, loc_params->loc_data.loc_by_ref.lapl_id, + loc_params->loc_data.loc_by_ref.ref_type, + loc_params->loc_data.loc_by_ref._ref)) < 0) + HGOTO_ERROR(H5E_REFERENCE, H5E_CANTOPENOBJ, NULL, "unable to dereference object") + + *opened_type = H5I_get_type(temp_id); + if(NULL == (ret_value = H5I_remove(temp_id))) + HGOTO_ERROR(H5E_SYM, H5E_CANTOPENOBJ, NULL, "unable to open object") + break; + } + + case H5VL_OBJECT_BY_SELF: + default: + HGOTO_ERROR(H5E_VOL, H5E_UNSUPPORTED, NULL, "unknown open parameters") + } /* end switch */ + +done: + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5VL__native_object_open() */ + + +/*------------------------------------------------------------------------- + * Function: H5VL__native_object_copy + * + * Purpose: Handles the object copy callback + * + * Return: SUCCEED/FAIL + * + *------------------------------------------------------------------------- + */ +herr_t +H5VL__native_object_copy(void *src_obj, const H5VL_loc_params_t *loc_params1, const char *src_name, + void *dst_obj, const H5VL_loc_params_t *loc_params2, const char *dst_name, + hid_t ocpypl_id, hid_t lcpl_id, hid_t H5_ATTR_UNUSED dxpl_id, void H5_ATTR_UNUSED **req) +{ + H5G_loc_t src_loc; /* Source object group location */ + H5G_loc_t dst_loc; /* Destination group location */ + herr_t ret_value = FAIL; + + FUNC_ENTER_PACKAGE + + /* get location for objects */ + if(H5G_loc_real(src_obj, loc_params1->obj_type, &src_loc) < 0) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a file or file object") + if(H5G_loc_real(dst_obj, loc_params2->obj_type, &dst_loc) < 0) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a file or file object") + + /* Copy the object */ + if((ret_value = H5O_copy(&src_loc, src_name, &dst_loc, dst_name, ocpypl_id, lcpl_id)) < 0) + HGOTO_ERROR(H5E_SYM, H5E_CANTCOPY, FAIL, "unable to copy object") + +done: + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5VL__native_object_copy() */ + + +/*------------------------------------------------------------------------- + * Function: H5VL__native_object_get + * + * Purpose: Handles the object get callback + * + * Return: SUCCEED/FAIL + * + *------------------------------------------------------------------------- + */ +herr_t +H5VL__native_object_get(void *obj, const H5VL_loc_params_t *loc_params, H5VL_object_get_t get_type, + hid_t H5_ATTR_UNUSED dxpl_id, void H5_ATTR_UNUSED **req, va_list arguments) +{ + herr_t ret_value = SUCCEED; /* Return value */ + H5G_loc_t loc; /* Location of group */ + + FUNC_ENTER_PACKAGE + + if(H5G_loc_real(obj, loc_params->obj_type, &loc) < 0) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a file or file object") + + switch(get_type) { + /* H5Rget_region */ + case H5VL_REF_GET_REGION: + { + hid_t *ret = HDva_arg(arguments, hid_t *); + H5R_type_t H5_ATTR_UNUSED ref_type = (H5R_type_t)HDva_arg(arguments, int); /* enum work-around */ + void *ref = HDva_arg(arguments, void *); + H5S_t *space = NULL; /* Dataspace object */ + + /* Get the dataspace with the correct region selected */ + if((space = H5R__get_region(loc.oloc->file, ref)) == NULL) + HGOTO_ERROR(H5E_REFERENCE, H5E_CANTGET, FAIL, "unable to retrieve region") + + /* Atomize */ + if((*ret = H5I_register(H5I_DATASPACE, space, TRUE)) < 0) + HGOTO_ERROR(H5E_ATOM, H5E_CANTREGISTER, FAIL, "unable to register dataspace atom") + + break; + } + + /* H5Rget_obj_type1/2 */ + case H5VL_REF_GET_TYPE: + { + H5O_type_t *obj_type = HDva_arg(arguments, H5O_type_t *); + H5R_type_t ref_type = (H5R_type_t)HDva_arg(arguments, int); /* enum work-around */ + void *ref = HDva_arg(arguments, void *); + + /* Get the object information */ + if(H5R__get_obj_type(loc.oloc->file, ref_type, ref, obj_type) < 0) + HGOTO_ERROR(H5E_REFERENCE, H5E_CANTGET, FAIL, "unable to determine object type") + break; + } + + /* H5Rget_name */ + case H5VL_REF_GET_NAME: + { + ssize_t *ret = HDva_arg(arguments, ssize_t *); + char *name = HDva_arg(arguments, char *); + size_t size = HDva_arg(arguments, size_t); + H5R_type_t ref_type = (H5R_type_t)HDva_arg(arguments, int); /* enum work-around */ + void *ref = HDva_arg(arguments, void *); + + /* Get name */ + if((*ret = H5R__get_name(loc.oloc->file, ref_type, ref, name, size)) < 0) + HGOTO_ERROR(H5E_REFERENCE, H5E_CANTGET, FAIL, "unable to determine object path") + break; + } + + /* H5Iget_name */ + case H5VL_ID_GET_NAME: + { + ssize_t *ret = HDva_arg(arguments, ssize_t *); + char *name = HDva_arg(arguments, char *); + size_t size = HDva_arg(arguments, size_t); + + /* Retrieve object's name */ + if((*ret = H5G_get_name(&loc, name, size, NULL)) < 0) + HGOTO_ERROR(H5E_ATOM, H5E_CANTGET, FAIL, "can't retrieve object name") + + break; + } + + default: + HGOTO_ERROR(H5E_VOL, H5E_CANTGET, FAIL, "can't get this type of information from object") + } /* end switch */ + +done: + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5VL__native_object_get() */ + + +/*------------------------------------------------------------------------- + * Function: H5VL__native_object_specific + * + * Purpose: Handles the object specific callback + * + * Return: SUCCEED/FAIL + * + *------------------------------------------------------------------------- + */ +herr_t +H5VL__native_object_specific(void *obj, const H5VL_loc_params_t *loc_params, H5VL_object_specific_t specific_type, + hid_t H5_ATTR_UNUSED dxpl_id, void H5_ATTR_UNUSED **req, va_list arguments) +{ + H5G_loc_t loc; + herr_t ret_value = SUCCEED; /* Return value */ + + FUNC_ENTER_PACKAGE + + if(H5G_loc_real(obj, loc_params->obj_type, &loc) < 0) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a file or file object") + + switch(specific_type) { + /* H5Oincr_refcount / H5Odecr_refcount */ + case H5VL_OBJECT_CHANGE_REF_COUNT: + { + int update_ref = HDva_arg(arguments, int); + H5O_loc_t *oloc = loc.oloc; + + if(H5O_link(oloc, update_ref) < 0) + HGOTO_ERROR(H5E_OHDR, H5E_LINKCOUNT, FAIL, "modifying object link count failed") + + break; + } + + /* H5Oexists_by_name */ + case H5VL_OBJECT_EXISTS: + { + htri_t *ret = HDva_arg(arguments, htri_t *); + + if(loc_params->type == H5VL_OBJECT_BY_NAME) { + /* Check if the object exists */ + if((*ret = H5G_loc_exists(&loc, loc_params->loc_data.loc_by_name.name)) < 0) + HGOTO_ERROR(H5E_OHDR, H5E_CANTGET, FAIL, "unable to determine if '%s' exists", loc_params->loc_data.loc_by_name.name) + } /* end if */ + else + HGOTO_ERROR(H5E_VOL, H5E_UNSUPPORTED, FAIL, "unknown object exists parameters") + break; + } + + case H5VL_OBJECT_VISIT: + { + H5_index_t idx_type = (H5_index_t)HDva_arg(arguments, int); /* enum work-around */ + H5_iter_order_t order = (H5_iter_order_t)HDva_arg(arguments, int); /* enum work-around */ + H5O_iterate_t op = HDva_arg(arguments, H5O_iterate_t); + void *op_data = HDva_arg(arguments, void *); + unsigned fields = HDva_arg(arguments, unsigned); + + /* Call internal object visitation routine */ + if(loc_params->type == H5VL_OBJECT_BY_SELF) { + /* H5Ovisit */ + if((ret_value = H5O__visit(&loc, ".", idx_type, order, op, op_data, fields)) < 0) + HGOTO_ERROR(H5E_OHDR, H5E_BADITER, FAIL, "object visitation failed") + } /* end if */ + else if(loc_params->type == H5VL_OBJECT_BY_NAME) { + /* H5Ovisit_by_name */ + if((ret_value = H5O__visit(&loc, loc_params->loc_data.loc_by_name.name, idx_type, order, op, op_data, fields)) < 0) + HGOTO_ERROR(H5E_OHDR, H5E_BADITER, FAIL, "object visitation failed") + } /* end else-if */ + else + HGOTO_ERROR(H5E_VOL, H5E_UNSUPPORTED, FAIL, "unknown object visit params"); + break; + } + + case H5VL_OBJECT_FLUSH: + { + hid_t oid = HDva_arg(arguments, hid_t); + + /* Flush the object's metadata */ + if(H5O_flush(loc.oloc, oid) < 0) + HGOTO_ERROR(H5E_OHDR, H5E_CANTFLUSH, FAIL, "unable to flush object") + + break; + } + + case H5VL_OBJECT_REFRESH: + { + hid_t oid = HDva_arg(arguments, hid_t); + H5O_loc_t *oloc = loc.oloc; + + /* Refresh the metadata */ + if(H5O_refresh_metadata(oid, *oloc) < 0) + HGOTO_ERROR(H5E_OHDR, H5E_CANTLOAD, FAIL, "unable to refresh object") + + break; + } + + case H5VL_REF_CREATE: + { + void *ref = HDva_arg(arguments, void *); + const char *name = HDva_arg(arguments, char *); + H5R_type_t ref_type = (H5R_type_t)HDva_arg(arguments, int); /* enum work-around */ + hid_t space_id = HDva_arg(arguments, hid_t); + H5S_t *space = NULL; /* Pointer to dataspace containing region */ + + if(space_id != (-1) && (NULL == (space = (H5S_t *)H5I_object_verify(space_id, H5I_DATASPACE)))) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a dataspace") + + /* Create reference */ + if(H5R__create(ref, &loc, name, ref_type, space) < 0) + HGOTO_ERROR(H5E_REFERENCE, H5E_CANTCREATE, FAIL, "unable to create reference") + + break; + } + + default: + HGOTO_ERROR(H5E_VOL, H5E_CANTGET, FAIL, "can't recognize this operation type") + } /* end switch */ + +done: + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5VL__native_object_specific() */ + + +/*------------------------------------------------------------------------- + * Function: H5VL__native_object_optional + * + * Purpose: Handles the object optional callback + * + * Return: SUCCEED/FAIL + * + *------------------------------------------------------------------------- + */ +herr_t +H5VL__native_object_optional(void *obj, hid_t H5_ATTR_UNUSED dxpl_id, + void H5_ATTR_UNUSED **req, va_list arguments) +{ + H5VL_native_object_optional_t optional_type = HDva_arg(arguments, H5VL_native_object_optional_t); + H5VL_loc_params_t *loc_params = HDva_arg(arguments, H5VL_loc_params_t *); + H5G_loc_t loc; /* Location of group */ + herr_t ret_value = SUCCEED; /* Return value */ + + FUNC_ENTER_PACKAGE + + if(H5G_loc_real(obj, loc_params->obj_type, &loc) < 0) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a file or file object") + + switch(optional_type) { + /* H5Oget_info / H5Oget_info_by_name / H5Oget_info_by_idx */ + case H5VL_NATIVE_OBJECT_GET_INFO: + { + H5O_info_t *obj_info = HDva_arg(arguments, H5O_info_t *); + unsigned fields = HDva_arg(arguments, unsigned); + + if(loc_params->type == H5VL_OBJECT_BY_SELF) { /* H5Oget_info */ + /* Retrieve the object's information */ + if(H5G_loc_info(&loc, ".", obj_info, fields) < 0) + HGOTO_ERROR(H5E_OHDR, H5E_NOTFOUND, FAIL, "object not found") + } /* end if */ + else if(loc_params->type == H5VL_OBJECT_BY_NAME) { /* H5Oget_info_by_name */ + /* Retrieve the object's information */ + if(H5G_loc_info(&loc, loc_params->loc_data.loc_by_name.name, obj_info, fields) < 0) + HGOTO_ERROR(H5E_OHDR, H5E_NOTFOUND, FAIL, "object not found") + } /* end else-if */ + else if(loc_params->type == H5VL_OBJECT_BY_IDX) { /* H5Oget_info_by_idx */ + H5G_loc_t obj_loc; /* Location used to open group */ + H5G_name_t obj_path; /* Opened object group hier. path */ + H5O_loc_t obj_oloc; /* Opened object object location */ + + /* Set up opened group location to fill in */ + obj_loc.oloc = &obj_oloc; + obj_loc.path = &obj_path; + H5G_loc_reset(&obj_loc); + + /* Find the object's location, according to the order in the index */ + if(H5G_loc_find_by_idx(&loc, loc_params->loc_data.loc_by_idx.name, + loc_params->loc_data.loc_by_idx.idx_type, + loc_params->loc_data.loc_by_idx.order, + loc_params->loc_data.loc_by_idx.n, &obj_loc/*out*/) < 0) + HGOTO_ERROR(H5E_OHDR, H5E_NOTFOUND, FAIL, "group not found") + + /* Retrieve the object's information */ + if(H5O_get_info(obj_loc.oloc, obj_info, fields) < 0) { + H5G_loc_free(&obj_loc); + HGOTO_ERROR(H5E_OHDR, H5E_CANTGET, FAIL, "can't retrieve object info") + } /* end if */ + + /* Release the object location */ + if(H5G_loc_free(&obj_loc) < 0) + HGOTO_ERROR(H5E_OHDR, H5E_CANTRELEASE, FAIL, "can't free location") + } /* end else-if */ + else + HGOTO_ERROR(H5E_OHDR, H5E_UNSUPPORTED, FAIL, "unknown get info parameters") + break; + } + + /* H5Oget_comment / H5Oget_comment_by_name */ + case H5VL_NATIVE_OBJECT_GET_COMMENT: + { + char *comment = HDva_arg(arguments, char *); + size_t bufsize = HDva_arg(arguments, size_t); + ssize_t *ret = HDva_arg(arguments, ssize_t *); + + /* Retrieve the object's comment */ + if(loc_params->type == H5VL_OBJECT_BY_SELF) { /* H5Oget_comment */ + if((*ret = H5G_loc_get_comment(&loc, ".", comment/*out*/, bufsize)) < 0) + HGOTO_ERROR(H5E_OHDR, H5E_NOTFOUND, FAIL, "object not found") + } /* end if */ + else if(loc_params->type == H5VL_OBJECT_BY_NAME) { /* H5Oget_comment_by_name */ + if((*ret = H5G_loc_get_comment(&loc, loc_params->loc_data.loc_by_name.name, comment/*out*/, bufsize)) < 0) + HGOTO_ERROR(H5E_OHDR, H5E_NOTFOUND, FAIL, "object not found") + } /* end else-if */ + else + HGOTO_ERROR(H5E_VOL, H5E_UNSUPPORTED, FAIL, "unknown set_coment parameters") + break; + } + + /* H5Oset_comment */ + case H5VL_NATIVE_OBJECT_SET_COMMENT: + { + const char *comment = HDva_arg(arguments, char *); + + if(loc_params->type == H5VL_OBJECT_BY_SELF) { /* H5Oset_comment */ + /* (Re)set the object's comment */ + if(H5G_loc_set_comment(&loc, ".", comment) < 0) + HGOTO_ERROR(H5E_OHDR, H5E_NOTFOUND, FAIL, "object not found") + } /* end if */ + else if(loc_params->type == H5VL_OBJECT_BY_NAME) { /* H5Oset_comment_by_name */ + /* (Re)set the object's comment */ + if(H5G_loc_set_comment(&loc, loc_params->loc_data.loc_by_name.name, comment) < 0) + HGOTO_ERROR(H5E_OHDR, H5E_NOTFOUND, FAIL, "object not found") + } /* end else-if */ + else + HGOTO_ERROR(H5E_VOL, H5E_UNSUPPORTED, FAIL, "unknown set_coment parameters") + break; + } + + default: + HGOTO_ERROR(H5E_VOL, H5E_CANTGET, FAIL, "can't perform this operation on object"); + } /* end switch */ + +done: + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5VL__native_object_optional() */ + diff --git a/src/H5VLnative_private.h b/src/H5VLnative_private.h index 79a6e1c..1bf4da2 100644 --- a/src/H5VLnative_private.h +++ b/src/H5VLnative_private.h @@ -11,30 +11,78 @@ * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ /* - * Purpose: The private header file for the native VOL driver. + * Purpose: The private header file for the native VOL connector. */ #ifndef _H5VLnative_private_H #define _H5VLnative_private_H -/* Include driver's public header */ -#include "H5VLnative.h" - -/* Initializer function for native VOL driver */ -#define H5VL_NATIVE (H5VL_native_init()) - +#include "H5VLnative.h" /* Native VOL connector */ #ifdef __cplusplus extern "C" { #endif -H5_DLL hid_t H5VL_native_get_driver_id(void); -H5_DLL hid_t H5VL_native_init(void); -H5_DLL hid_t H5VL_native_register(H5I_type_t type, const void *obj, hbool_t app_ref); -H5_DLL herr_t H5VL_native_unregister(hid_t obj_id); +/* Atrribute callbacks */ +H5_DLL void *H5VL__native_attr_create(void *obj, const H5VL_loc_params_t *loc_params, const char *attr_name, hid_t acpl_id, hid_t aapl_id, hid_t dxpl_id, void **req); +void *H5VL__native_attr_open(void *obj, const H5VL_loc_params_t *loc_params, const char *attr_name, hid_t aapl_id, hid_t dxpl_id, void **req); +H5_DLL herr_t H5VL__native_attr_read(void *attr, hid_t dtype_id, void *buf, hid_t dxpl_id, void **req); +H5_DLL herr_t H5VL__native_attr_write(void *attr, hid_t dtype_id, const void *buf, hid_t dxpl_id, void **req); +H5_DLL herr_t H5VL__native_attr_get(void *obj, H5VL_attr_get_t get_type, hid_t dxpl_id, void **req, va_list arguments); +H5_DLL herr_t H5VL__native_attr_specific(void *obj, const H5VL_loc_params_t *loc_params, H5VL_attr_specific_t specific_type, hid_t dxpl_id, void **req, va_list arguments); +H5_DLL herr_t H5VL__native_attr_optional(void *obj, hid_t dxpl_id, void **req, va_list arguments); +H5_DLL herr_t H5VL__native_attr_close(void *attr, hid_t dxpl_id, void **req); + +/* Dataset callbacks */ +H5_DLL void *H5VL__native_dataset_create(void *obj, const H5VL_loc_params_t *loc_params, const char *name, hid_t dcpl_id, hid_t dapl_id, hid_t dxpl_id, void **req); +H5_DLL void *H5VL__native_dataset_open(void *obj, const H5VL_loc_params_t *loc_params, const char *name, hid_t dapl_id, hid_t dxpl_id, void **req); +H5_DLL herr_t H5VL__native_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); +H5_DLL herr_t H5VL__native_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); +H5_DLL herr_t H5VL__native_dataset_get(void *dset, H5VL_dataset_get_t get_type, hid_t dxpl_id, void **req, va_list arguments); +H5_DLL herr_t H5VL__native_dataset_specific(void *dset, H5VL_dataset_specific_t specific_type, hid_t dxpl_id, void **req, va_list arguments); +H5_DLL herr_t H5VL__native_dataset_optional(void *dset, hid_t dxpl_id, void **req, va_list arguments); +H5_DLL herr_t H5VL__native_dataset_close(void *dset, hid_t dxpl_id, void **req); + +/* File callbacks */ +H5_DLL void *H5VL__native_file_create(const char *name, unsigned flags, hid_t fcpl_id, hid_t fapl_id, hid_t dxpl_id, void **req); +H5_DLL void *H5VL__native_file_open(const char *name, unsigned flags, hid_t fapl_id, hid_t dxpl_id, void **req); +H5_DLL herr_t H5VL__native_file_get(void *file, H5VL_file_get_t get_type, hid_t dxpl_id, void **req, va_list arguments); +H5_DLL herr_t H5VL__native_file_specific(void *file, H5VL_file_specific_t specific_type, hid_t dxpl_id, void **req, va_list arguments); +H5_DLL herr_t H5VL__native_file_optional(void *file, hid_t dxpl_id, void **req, va_list arguments); +H5_DLL herr_t H5VL__native_file_close(void *file, hid_t dxpl_id, void **req); + +/* Group callbacks */ +H5_DLL void *H5VL__native_group_create(void *obj, const H5VL_loc_params_t *loc_params, const char *name, hid_t gcpl_id, hid_t gapl_id, hid_t dxpl_id, void **req); +H5_DLL void *H5VL__native_group_open(void *obj, const H5VL_loc_params_t *loc_params, const char *name, hid_t gapl_id, hid_t dxpl_id, void **req); +H5_DLL herr_t H5VL__native_group_get(void *obj, H5VL_group_get_t get_type, hid_t dxpl_id, void **req, va_list arguments); +H5_DLL herr_t H5VL__native_group_specific(void *obj, H5VL_group_specific_t specific_type, hid_t dxpl_id, void **req, va_list arguments); +H5_DLL herr_t H5VL__native_group_optional(void *obj, hid_t dxpl_id, void **req, va_list arguments); +H5_DLL herr_t H5VL__native_group_close(void *grp, hid_t dxpl_id, void **req); + +/* Link callbacks */ +H5_DLL herr_t H5VL__native_link_create(H5VL_link_create_type_t create_type, void *obj, const H5VL_loc_params_t *loc_params, hid_t lcpl_id, hid_t lapl_id, hid_t dxpl_id, void **req); +H5_DLL herr_t H5VL__native_link_copy(void *src_obj, const H5VL_loc_params_t *loc_params1, void *dst_obj, const H5VL_loc_params_t *loc_params2, hid_t lcpl_id, hid_t lapl_id, hid_t dxpl_id, void **req); +H5_DLL herr_t H5VL__native_link_move(void *src_obj, const H5VL_loc_params_t *loc_params1, void *dst_obj, const H5VL_loc_params_t *loc_params2, hid_t lcpl_id, hid_t lapl_id, hid_t dxpl_id, void **req); +H5_DLL herr_t H5VL__native_link_get(void *obj, const H5VL_loc_params_t *loc_params, H5VL_link_get_t get_type, hid_t dxpl_id, void **req, va_list arguments); +H5_DLL herr_t H5VL__native_link_specific(void *obj, const H5VL_loc_params_t *loc_params, H5VL_link_specific_t specific_type, hid_t dxpl_id, void **req, va_list arguments); + +/* Object callbacks */ +H5_DLL void *H5VL__native_object_open(void *obj, const H5VL_loc_params_t *loc_params, H5I_type_t *opened_type, hid_t dxpl_id, void **req); +H5_DLL herr_t H5VL__native_object_copy(void *src_obj, const H5VL_loc_params_t *loc_params1, const char *src_name, void *dst_obj, const H5VL_loc_params_t *loc_params2, const char *dst_name, hid_t ocpypl_id, hid_t lcpl_id, hid_t dxpl_id, void **req); +H5_DLL herr_t H5VL__native_object_get(void *obj, const H5VL_loc_params_t *loc_params, H5VL_object_get_t get_type, hid_t dxpl_id, void **req, va_list arguments); +H5_DLL herr_t H5VL__native_object_specific(void *obj, const H5VL_loc_params_t *loc_params, H5VL_object_specific_t specific_type, hid_t dxpl_id, void **req, va_list arguments); +H5_DLL herr_t H5VL__native_object_optional(void *obj, hid_t dxpl_id, void **req, va_list arguments); + +/* Datatype callbacks */ +H5_DLL void *H5VL__native_datatype_commit(void *obj, const 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); +H5_DLL void *H5VL__native_datatype_open(void *obj, const H5VL_loc_params_t *loc_params, const char *name, hid_t tapl_id, hid_t dxpl_id, void **req); +H5_DLL herr_t H5VL__native_datatype_get(void *dt, H5VL_datatype_get_t get_type, hid_t dxpl_id, void **req, va_list arguments); +H5_DLL herr_t H5VL__native_datatype_specific(void *dt, H5VL_datatype_specific_t specific_type, hid_t dxpl_id, void **req, va_list arguments); +H5_DLL herr_t H5VL__native_datatype_close(void *dt, hid_t dxpl_id, void **req); #ifdef __cplusplus } #endif #endif /* _H5VLnative_private_H */ + diff --git a/src/H5VLpassthru.c b/src/H5VLpassthru.c new file mode 100644 index 0000000..8b83e2e --- /dev/null +++ b/src/H5VLpassthru.c @@ -0,0 +1,2702 @@ +/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * + * 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 COPYING file, which can be found at the root of the source code * + * distribution tree, or in https://support.hdfgroup.org/ftp/HDF5/releases. * + * If you do not have access to either file, you may request a copy from * + * help@hdfgroup.org. * + * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ + +/* + * Purpose: This is a "pass through" VOL connector, which forwards each + * VOL callback to an underlying connector. + * + * It is designed as an example VOL connector for developers to + * use when creating new connectors, especially connectors that + * are outside of the HDF5 library. As such, it should _NOT_ + * include _any_ private HDF5 header files. This connector should + * therefore only make public HDF5 API calls and use standard C / + * POSIX calls. + */ + + +/* Header files needed */ +/* (Public HDF5 and standard C / POSIX only) */ +#include <assert.h> +#include <stdio.h> +#include <stdlib.h> +#include <string.h> +#include "hdf5.h" +#include "H5VLpassthru.h" + + +/**********/ +/* Macros */ +/**********/ + +/* Whether to display log messge when callback is invoked */ +/* (Uncomment to enable) */ +/* #define ENABLE_PASSTHRU_LOGGING */ + +/* Hack for missing va_copy() in old Visual Studio editions + * (from H5win2_defs.h - used on VS2012 and earlier) + */ +#if defined(_WIN32) && defined(_MSC_VER) && (_MSC_VER < 1800) +#define va_copy(D,S) ((D) = (S)) +#endif + +/************/ +/* Typedefs */ +/************/ + +/* The pass through VOL info object */ +typedef struct H5VL_pass_through_t { + hid_t under_vol_id; /* ID for underlying VOL connector */ + void *under_object; /* Info object for underlying VOL connector */ +} H5VL_pass_through_t; + +/* The pass through VOL wrapper context */ +typedef struct H5VL_pass_through_wrap_ctx_t { + hid_t under_vol_id; /* VOL ID for under VOL */ + void *under_wrap_ctx; /* Object wrapping context for under VOL */ +} H5VL_pass_through_wrap_ctx_t; + + +/********************* */ +/* Function prototypes */ +/********************* */ + +/* Helper routines */ +static herr_t H5VL_pass_through_file_specific_reissue(void *obj, hid_t connector_id, + H5VL_file_specific_t specific_type, hid_t dxpl_id, void **req, ...); +static herr_t H5VL_pass_through_request_specific_reissue(void *obj, hid_t connector_id, + H5VL_request_specific_t specific_type, ...); +static H5VL_pass_through_t *H5VL_pass_through_new_obj(void *under_obj, + hid_t under_vol_id); +static herr_t H5VL_pass_through_free_obj(H5VL_pass_through_t *obj); + +/* "Management" callbacks */ +static herr_t H5VL_pass_through_init(hid_t vipl_id); +static herr_t H5VL_pass_through_term(void); +static void *H5VL_pass_through_info_copy(const void *info); +static herr_t H5VL_pass_through_info_cmp(int *cmp_value, const void *info1, const void *info2); +static herr_t H5VL_pass_through_info_free(void *info); +static herr_t H5VL_pass_through_info_to_str(const void *info, char **str); +static herr_t H5VL_pass_through_str_to_info(const char *str, void **info); +static void *H5VL_pass_through_get_object(const void *obj); +static herr_t H5VL_pass_through_get_wrap_ctx(const void *obj, void **wrap_ctx); +static herr_t H5VL_pass_through_free_wrap_ctx(void *obj); +static void *H5VL_pass_through_wrap_object(void *obj, void *wrap_ctx); + +/* Attribute callbacks */ +static void *H5VL_pass_through_attr_create(void *obj, const H5VL_loc_params_t *loc_params, const char *name, hid_t acpl_id, hid_t aapl_id, hid_t dxpl_id, void **req); +static void *H5VL_pass_through_attr_open(void *obj, const H5VL_loc_params_t *loc_params, const char *name, hid_t aapl_id, hid_t dxpl_id, void **req); +static herr_t H5VL_pass_through_attr_read(void *attr, hid_t mem_type_id, void *buf, hid_t dxpl_id, void **req); +static herr_t H5VL_pass_through_attr_write(void *attr, hid_t mem_type_id, const void *buf, hid_t dxpl_id, void **req); +static herr_t H5VL_pass_through_attr_get(void *obj, H5VL_attr_get_t get_type, hid_t dxpl_id, void **req, va_list arguments); +static herr_t H5VL_pass_through_attr_specific(void *obj, const H5VL_loc_params_t *loc_params, H5VL_attr_specific_t specific_type, hid_t dxpl_id, void **req, va_list arguments); +static herr_t H5VL_pass_through_attr_optional(void *obj, hid_t dxpl_id, void **req, va_list arguments); +static herr_t H5VL_pass_through_attr_close(void *attr, hid_t dxpl_id, void **req); + +/* Dataset callbacks */ +static void *H5VL_pass_through_dataset_create(void *obj, const 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_pass_through_dataset_open(void *obj, const H5VL_loc_params_t *loc_params, const char *name, hid_t dapl_id, hid_t dxpl_id, void **req); +static herr_t H5VL_pass_through_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_pass_through_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_pass_through_dataset_get(void *dset, H5VL_dataset_get_t get_type, hid_t dxpl_id, void **req, va_list arguments); +static herr_t H5VL_pass_through_dataset_specific(void *obj, H5VL_dataset_specific_t specific_type, hid_t dxpl_id, void **req, va_list arguments); +static herr_t H5VL_pass_through_dataset_optional(void *obj, hid_t dxpl_id, void **req, va_list arguments); +static herr_t H5VL_pass_through_dataset_close(void *dset, hid_t dxpl_id, void **req); + +/* Datatype callbacks */ +static void *H5VL_pass_through_datatype_commit(void *obj, const 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_pass_through_datatype_open(void *obj, const H5VL_loc_params_t *loc_params, const char *name, hid_t tapl_id, hid_t dxpl_id, void **req); +static herr_t H5VL_pass_through_datatype_get(void *dt, H5VL_datatype_get_t get_type, hid_t dxpl_id, void **req, va_list arguments); +static herr_t H5VL_pass_through_datatype_specific(void *obj, H5VL_datatype_specific_t specific_type, hid_t dxpl_id, void **req, va_list arguments); +static herr_t H5VL_pass_through_datatype_optional(void *obj, hid_t dxpl_id, void **req, va_list arguments); +static herr_t H5VL_pass_through_datatype_close(void *dt, hid_t dxpl_id, void **req); + +/* File callbacks */ +static void *H5VL_pass_through_file_create(const char *name, unsigned flags, hid_t fcpl_id, hid_t fapl_id, hid_t dxpl_id, void **req); +static void *H5VL_pass_through_file_open(const char *name, unsigned flags, hid_t fapl_id, hid_t dxpl_id, void **req); +static herr_t H5VL_pass_through_file_get(void *file, H5VL_file_get_t get_type, hid_t dxpl_id, void **req, va_list arguments); +static herr_t H5VL_pass_through_file_specific(void *file, H5VL_file_specific_t specific_type, hid_t dxpl_id, void **req, va_list arguments); +static herr_t H5VL_pass_through_file_optional(void *file, hid_t dxpl_id, void **req, va_list arguments); +static herr_t H5VL_pass_through_file_close(void *file, hid_t dxpl_id, void **req); + +/* Group callbacks */ +static void *H5VL_pass_through_group_create(void *obj, const H5VL_loc_params_t *loc_params, const char *name, hid_t gcpl_id, hid_t gapl_id, hid_t dxpl_id, void **req); +static void *H5VL_pass_through_group_open(void *obj, const H5VL_loc_params_t *loc_params, const char *name, hid_t gapl_id, hid_t dxpl_id, void **req); +static herr_t H5VL_pass_through_group_get(void *obj, H5VL_group_get_t get_type, hid_t dxpl_id, void **req, va_list arguments); +static herr_t H5VL_pass_through_group_specific(void *obj, H5VL_group_specific_t specific_type, hid_t dxpl_id, void **req, va_list arguments); +static herr_t H5VL_pass_through_group_optional(void *obj, hid_t dxpl_id, void **req, va_list arguments); +static herr_t H5VL_pass_through_group_close(void *grp, hid_t dxpl_id, void **req); + +/* Link callbacks */ +static herr_t H5VL_pass_through_link_create(H5VL_link_create_type_t create_type, void *obj, const H5VL_loc_params_t *loc_params, hid_t lcpl_id, hid_t lapl_id, hid_t dxpl_id, void **req); +static herr_t H5VL_pass_through_link_copy(void *src_obj, const H5VL_loc_params_t *loc_params1, void *dst_obj, const H5VL_loc_params_t *loc_params2, hid_t lcpl_id, hid_t lapl_id, hid_t dxpl_id, void **req); +static herr_t H5VL_pass_through_link_move(void *src_obj, const H5VL_loc_params_t *loc_params1, void *dst_obj, const H5VL_loc_params_t *loc_params2, hid_t lcpl_id, hid_t lapl_id, hid_t dxpl_id, void **req); +static herr_t H5VL_pass_through_link_get(void *obj, const H5VL_loc_params_t *loc_params, H5VL_link_get_t get_type, hid_t dxpl_id, void **req, va_list arguments); +static herr_t H5VL_pass_through_link_specific(void *obj, const H5VL_loc_params_t *loc_params, H5VL_link_specific_t specific_type, hid_t dxpl_id, void **req, va_list arguments); +static herr_t H5VL_pass_through_link_optional(void *obj, hid_t dxpl_id, void **req, va_list arguments); + +/* Object callbacks */ +static void *H5VL_pass_through_object_open(void *obj, const H5VL_loc_params_t *loc_params, H5I_type_t *opened_type, hid_t dxpl_id, void **req); +static herr_t H5VL_pass_through_object_copy(void *src_obj, const H5VL_loc_params_t *src_loc_params, const char *src_name, void *dst_obj, const H5VL_loc_params_t *dst_loc_params, const char *dst_name, hid_t ocpypl_id, hid_t lcpl_id, hid_t dxpl_id, void **req); +static herr_t H5VL_pass_through_object_get(void *obj, const H5VL_loc_params_t *loc_params, H5VL_object_get_t get_type, hid_t dxpl_id, void **req, va_list arguments); +static herr_t H5VL_pass_through_object_specific(void *obj, const H5VL_loc_params_t *loc_params, H5VL_object_specific_t specific_type, hid_t dxpl_id, void **req, va_list arguments); +static herr_t H5VL_pass_through_object_optional(void *obj, hid_t dxpl_id, void **req, va_list arguments); + +/* Async request callbacks */ +static herr_t H5VL_pass_through_request_wait(void *req, uint64_t timeout, H5ES_status_t *status); +static herr_t H5VL_pass_through_request_notify(void *obj, H5VL_request_notify_t cb, void *ctx); +static herr_t H5VL_pass_through_request_cancel(void *req); +static herr_t H5VL_pass_through_request_specific(void *req, H5VL_request_specific_t specific_type, va_list arguments); +static herr_t H5VL_pass_through_request_optional(void *req, va_list arguments); +static herr_t H5VL_pass_through_request_free(void *req); + +/*******************/ +/* Local variables */ +/*******************/ + +/* Pass through VOL connector class struct */ +static const H5VL_class_t H5VL_pass_through_g = { + H5VL_PASSTHRU_VERSION, /* version */ + (H5VL_class_value_t)H5VL_PASSTHRU_VALUE, /* value */ + H5VL_PASSTHRU_NAME, /* name */ + 0, /* capability flags */ + H5VL_pass_through_init, /* initialize */ + H5VL_pass_through_term, /* terminate */ + sizeof(H5VL_pass_through_t), /* info size */ + H5VL_pass_through_info_copy, /* info copy */ + H5VL_pass_through_info_cmp, /* info compare */ + H5VL_pass_through_info_free, /* info free */ + H5VL_pass_through_info_to_str, /* info to str */ + H5VL_pass_through_str_to_info, /* str to info */ + H5VL_pass_through_get_object, /* get_object */ + H5VL_pass_through_get_wrap_ctx, /* get_wrap_ctx */ + H5VL_pass_through_wrap_object, /* wrap_object */ + H5VL_pass_through_free_wrap_ctx, /* free_wrap_ctx */ + { /* attribute_cls */ + H5VL_pass_through_attr_create, /* create */ + H5VL_pass_through_attr_open, /* open */ + H5VL_pass_through_attr_read, /* read */ + H5VL_pass_through_attr_write, /* write */ + H5VL_pass_through_attr_get, /* get */ + H5VL_pass_through_attr_specific, /* specific */ + H5VL_pass_through_attr_optional, /* optional */ + H5VL_pass_through_attr_close /* close */ + }, + { /* dataset_cls */ + H5VL_pass_through_dataset_create, /* create */ + H5VL_pass_through_dataset_open, /* open */ + H5VL_pass_through_dataset_read, /* read */ + H5VL_pass_through_dataset_write, /* write */ + H5VL_pass_through_dataset_get, /* get */ + H5VL_pass_through_dataset_specific, /* specific */ + H5VL_pass_through_dataset_optional, /* optional */ + H5VL_pass_through_dataset_close /* close */ + }, + { /* datatype_cls */ + H5VL_pass_through_datatype_commit, /* commit */ + H5VL_pass_through_datatype_open, /* open */ + H5VL_pass_through_datatype_get, /* get_size */ + H5VL_pass_through_datatype_specific, /* specific */ + H5VL_pass_through_datatype_optional, /* optional */ + H5VL_pass_through_datatype_close /* close */ + }, + { /* file_cls */ + H5VL_pass_through_file_create, /* create */ + H5VL_pass_through_file_open, /* open */ + H5VL_pass_through_file_get, /* get */ + H5VL_pass_through_file_specific, /* specific */ + H5VL_pass_through_file_optional, /* optional */ + H5VL_pass_through_file_close /* close */ + }, + { /* group_cls */ + H5VL_pass_through_group_create, /* create */ + H5VL_pass_through_group_open, /* open */ + H5VL_pass_through_group_get, /* get */ + H5VL_pass_through_group_specific, /* specific */ + H5VL_pass_through_group_optional, /* optional */ + H5VL_pass_through_group_close /* close */ + }, + { /* link_cls */ + H5VL_pass_through_link_create, /* create */ + H5VL_pass_through_link_copy, /* copy */ + H5VL_pass_through_link_move, /* move */ + H5VL_pass_through_link_get, /* get */ + H5VL_pass_through_link_specific, /* specific */ + H5VL_pass_through_link_optional, /* optional */ + }, + { /* object_cls */ + H5VL_pass_through_object_open, /* open */ + H5VL_pass_through_object_copy, /* copy */ + H5VL_pass_through_object_get, /* get */ + H5VL_pass_through_object_specific, /* specific */ + H5VL_pass_through_object_optional, /* optional */ + }, + { /* request_cls */ + H5VL_pass_through_request_wait, /* wait */ + H5VL_pass_through_request_notify, /* notify */ + H5VL_pass_through_request_cancel, /* cancel */ + H5VL_pass_through_request_specific, /* specific */ + H5VL_pass_through_request_optional, /* optional */ + H5VL_pass_through_request_free /* free */ + }, + NULL /* optional */ +}; + +/* The connector identification number, initialized at runtime */ +static hid_t H5VL_PASSTHRU_g = H5I_INVALID_HID; + + +/*------------------------------------------------------------------------- + * Function: H5VL__pass_through_new_obj + * + * Purpose: Create a new pass through object for an underlying object + * + * Return: Success: Pointer to the new pass through object + * Failure: NULL + * + * Programmer: Quincey Koziol + * Monday, December 3, 2018 + * + *------------------------------------------------------------------------- + */ +static H5VL_pass_through_t * +H5VL_pass_through_new_obj(void *under_obj, hid_t under_vol_id) +{ + H5VL_pass_through_t *new_obj; + + new_obj = (H5VL_pass_through_t *)calloc(1, sizeof(H5VL_pass_through_t)); + new_obj->under_object = under_obj; + new_obj->under_vol_id = under_vol_id; + H5Iinc_ref(new_obj->under_vol_id); + + return new_obj; +} /* end H5VL__pass_through_new_obj() */ + + +/*------------------------------------------------------------------------- + * Function: H5VL__pass_through_free_obj + * + * Purpose: Release a pass through object + * + * Return: Success: 0 + * Failure: -1 + * + * Programmer: Quincey Koziol + * Monday, December 3, 2018 + * + *------------------------------------------------------------------------- + */ +static herr_t +H5VL_pass_through_free_obj(H5VL_pass_through_t *obj) +{ + H5Idec_ref(obj->under_vol_id); + free(obj); + + return 0; +} /* end H5VL__pass_through_free_obj() */ + + +/*------------------------------------------------------------------------- + * Function: H5VL_pass_through_register + * + * Purpose: Register the pass-through VOL connector and retrieve an ID + * for it. + * + * Return: Success: The ID for the pass-through VOL connector + * Failure: -1 + * + * Programmer: Quincey Koziol + * Wednesday, November 28, 2018 + * + *------------------------------------------------------------------------- + */ +hid_t +H5VL_pass_through_register(void) +{ + /* Clear the error stack */ + H5Eclear2(H5E_DEFAULT); + + /* Singleton register the pass-through VOL connector ID */ + if(H5I_VOL != H5Iget_type(H5VL_PASSTHRU_g)) + H5VL_PASSTHRU_g = H5VLregister_connector(&H5VL_pass_through_g, H5P_DEFAULT); + + return H5VL_PASSTHRU_g; +} /* end H5VL_pass_through_register() */ + + +/*------------------------------------------------------------------------- + * Function: H5VL_pass_through_init + * + * Purpose: Initialize this VOL connector, performing any necessary + * operations for the connector that will apply to all containers + * accessed with the connector. + * + * Return: Success: 0 + * Failure: -1 + * + *------------------------------------------------------------------------- + */ +static herr_t +H5VL_pass_through_init(hid_t vipl_id) +{ +#ifdef ENABLE_PASSTHRU_LOGGING + printf("------- PASS THROUGH VOL INIT\n"); +#endif + + /* Shut compiler up about unused parameter */ + vipl_id = vipl_id; + + return 0; +} /* end H5VL_pass_through_init() */ + + +/*--------------------------------------------------------------------------- + * Function: H5VL_pass_through_term + * + * Purpose: Terminate this VOL connector, performing any necessary + * operations for the connector that release connector-wide + * resources (usually created / initialized with the 'init' + * callback). + * + * Return: Success: 0 + * Failure: (Can't fail) + * + *--------------------------------------------------------------------------- + */ +static herr_t +H5VL_pass_through_term(void) +{ +#ifdef ENABLE_PASSTHRU_LOGGING + printf("------- PASS THROUGH VOL TERM\n"); +#endif + + /* Reset VOL ID */ + H5VL_PASSTHRU_g = H5I_INVALID_HID; + + return 0; +} /* end H5VL_pass_through_term() */ + + +/*--------------------------------------------------------------------------- + * Function: H5VL_pass_through_info_copy + * + * Purpose: Duplicate the connector's info object. + * + * Returns: Success: New connector info object + * Failure: NULL + * + *--------------------------------------------------------------------------- + */ +static void * +H5VL_pass_through_info_copy(const void *_info) +{ + const H5VL_pass_through_info_t *info = (const H5VL_pass_through_info_t *)_info; + H5VL_pass_through_info_t *new_info; + +#ifdef ENABLE_PASSTHRU_LOGGING + printf("------- PASS THROUGH VOL INFO Copy\n"); +#endif + + /* Allocate new VOL info struct for the pass through connector */ + new_info = (H5VL_pass_through_info_t *)calloc(1, sizeof(H5VL_pass_through_info_t)); + + /* Increment reference count on underlying VOL ID, and copy the VOL info */ + new_info->under_vol_id = info->under_vol_id; + H5Iinc_ref(new_info->under_vol_id); + if(info->under_vol_info) + H5VLcopy_connector_info(new_info->under_vol_id, &(new_info->under_vol_info), info->under_vol_info); + + return new_info; +} /* end H5VL_pass_through_info_copy() */ + + +/*--------------------------------------------------------------------------- + * Function: H5VL_pass_through_info_cmp + * + * Purpose: Compare two of the connector's info objects, setting *cmp_value, + * following the same rules as strcmp(). + * + * Return: Success: 0 + * Failure: -1 + * + *--------------------------------------------------------------------------- + */ +static herr_t +H5VL_pass_through_info_cmp(int *cmp_value, const void *_info1, const void *_info2) +{ + const H5VL_pass_through_info_t *info1 = (const H5VL_pass_through_info_t *)_info1; + const H5VL_pass_through_info_t *info2 = (const H5VL_pass_through_info_t *)_info2; + +#ifdef ENABLE_PASSTHRU_LOGGING + printf("------- PASS THROUGH VOL INFO Compare\n"); +#endif + + /* Sanity checks */ + assert(info1); + assert(info2); + + /* Initialize comparison value */ + *cmp_value = 0; + + /* Compare under VOL connector classes */ + H5VLcmp_connector_cls(cmp_value, info1->under_vol_id, info2->under_vol_id); + if(*cmp_value != 0) + return 0; + + /* Compare under VOL connector info objects */ + H5VLcmp_connector_info(cmp_value, info1->under_vol_id, info1->under_vol_info, info2->under_vol_info); + if(*cmp_value != 0) + return 0; + + return 0; +} /* end H5VL_pass_through_info_cmp() */ + + +/*--------------------------------------------------------------------------- + * Function: H5VL_pass_through_info_free + * + * Purpose: Release an info object for the connector. + * + * Return: Success: 0 + * Failure: -1 + * + *--------------------------------------------------------------------------- + */ +static herr_t +H5VL_pass_through_info_free(void *_info) +{ + H5VL_pass_through_info_t *info = (H5VL_pass_through_info_t *)_info; + +#ifdef ENABLE_PASSTHRU_LOGGING + printf("------- PASS THROUGH VOL INFO Free\n"); +#endif + + /* Release underlying VOL ID and info */ + if(info->under_vol_info) + H5VLfree_connector_info(info->under_vol_id, info->under_vol_info); + H5Idec_ref(info->under_vol_id); + + /* Free pass through info object itself */ + free(info); + + return 0; +} /* end H5VL_pass_through_info_free() */ + + +/*--------------------------------------------------------------------------- + * Function: H5VL_pass_through_info_to_str + * + * Purpose: Serialize an info object for this connector into a string + * + * Return: Success: 0 + * Failure: -1 + * + *--------------------------------------------------------------------------- + */ +static herr_t +H5VL_pass_through_info_to_str(const void *_info, char **str) +{ + const H5VL_pass_through_info_t *info = (const H5VL_pass_through_info_t *)_info; + H5VL_class_value_t under_value = (H5VL_class_value_t)-1; + char *under_vol_string = NULL; + size_t under_vol_str_len = 0; + +#ifdef ENABLE_PASSTHRU_LOGGING + printf("------- PASS THROUGH VOL INFO To String\n"); +#endif + + /* Get value and string for underlying VOL connector */ + H5VLget_value(info->under_vol_id, &under_value); + H5VLconnector_info_to_str(info->under_vol_info, info->under_vol_id, &under_vol_string); + + /* Determine length of underlying VOL info string */ + if(under_vol_string) + under_vol_str_len = strlen(under_vol_string); + + /* Allocate space for our info */ + *str = (char *)H5allocate_memory(32 + under_vol_str_len, (hbool_t)0); + assert(*str); + + /* Encode our info + * Normally we'd use snprintf() here for a little extra safety, but that + * call had problems on Windows until recently. So, to be as platform-independent + * as we can, we're using sprintf() instead. + */ + sprintf(*str, "under_vol=%u;under_info={%s}", (unsigned)under_value, (under_vol_string ? under_vol_string : "")); + + return 0; +} /* end H5VL_pass_through_info_to_str() */ + + +/*--------------------------------------------------------------------------- + * Function: H5VL_pass_through_str_to_info + * + * Purpose: Deserialize a string into an info object for this connector. + * + * Return: Success: 0 + * Failure: -1 + * + *--------------------------------------------------------------------------- + */ +static herr_t +H5VL_pass_through_str_to_info(const char *str, void **_info) +{ + H5VL_pass_through_info_t *info; + unsigned under_vol_value; + const char *under_vol_info_start, *under_vol_info_end; + hid_t under_vol_id; + void *under_vol_info = NULL; + +#ifdef ENABLE_PASSTHRU_LOGGING + printf("------- PASS THROUGH VOL INFO String To Info\n"); +#endif + + /* Retrieve the underlying VOL connector value and info */ + sscanf(str, "under_vol=%u;", &under_vol_value); + under_vol_id = H5VLregister_connector_by_value((H5VL_class_value_t)under_vol_value, H5P_DEFAULT); + under_vol_info_start = strchr(str, '{'); + under_vol_info_end = strrchr(str, '}'); + assert(under_vol_info_end > under_vol_info_start); + if(under_vol_info_end != (under_vol_info_start + 1)) { + char *under_vol_info_str; + + under_vol_info_str = (char *)malloc((size_t)(under_vol_info_end - under_vol_info_start)); + memcpy(under_vol_info_str, under_vol_info_start + 1, (size_t)((under_vol_info_end - under_vol_info_start) - 1)); + *(under_vol_info_str + (under_vol_info_end - under_vol_info_start)) = '\0'; + + H5VLconnector_str_to_info(under_vol_info_str, under_vol_id, &under_vol_info); + + free(under_vol_info_str); + } /* end else */ + + /* Allocate new pass-through VOL connector info and set its fields */ + info = (H5VL_pass_through_info_t *)calloc(1, sizeof(H5VL_pass_through_info_t)); + info->under_vol_id = under_vol_id; + info->under_vol_info = under_vol_info; + + /* Set return value */ + *_info = info; + + return 0; +} /* end H5VL_pass_through_str_to_info() */ + + +/*--------------------------------------------------------------------------- + * Function: H5VL_pass_through_get_object + * + * Purpose: Retrieve the 'data' for a VOL object. + * + * Return: Success: 0 + * Failure: -1 + * + *--------------------------------------------------------------------------- + */ +static void * +H5VL_pass_through_get_object(const void *obj) +{ + const H5VL_pass_through_t *o = (const H5VL_pass_through_t *)obj; + +#ifdef ENABLE_PASSTHRU_LOGGING + printf("------- PASS THROUGH VOL Get object\n"); +#endif + + return H5VLget_object(o->under_object, o->under_vol_id); +} /* end H5VL_pass_through_get_object() */ + + +/*--------------------------------------------------------------------------- + * Function: H5VL_pass_through_get_wrap_ctx + * + * Purpose: Retrieve a "wrapper context" for an object + * + * Return: Success: 0 + * Failure: -1 + * + *--------------------------------------------------------------------------- + */ +static herr_t +H5VL_pass_through_get_wrap_ctx(const void *obj, void **wrap_ctx) +{ + const H5VL_pass_through_t *o = (const H5VL_pass_through_t *)obj; + H5VL_pass_through_wrap_ctx_t *new_wrap_ctx; + +#ifdef ENABLE_PASSTHRU_LOGGING + printf("------- PASS THROUGH VOL WRAP CTX Get\n"); +#endif + + /* Allocate new VOL object wrapping context for the pass through connector */ + new_wrap_ctx = (H5VL_pass_through_wrap_ctx_t *)calloc(1, sizeof(H5VL_pass_through_wrap_ctx_t)); + + /* Increment reference count on underlying VOL ID, and copy the VOL info */ + new_wrap_ctx->under_vol_id = o->under_vol_id; + H5Iinc_ref(new_wrap_ctx->under_vol_id); + H5VLget_wrap_ctx(o->under_object, o->under_vol_id, &new_wrap_ctx->under_wrap_ctx); + + /* Set wrap context to return */ + *wrap_ctx = new_wrap_ctx; + + return 0; +} /* end H5VL_pass_through_get_wrap_ctx() */ + + +/*--------------------------------------------------------------------------- + * Function: H5VL_pass_through_wrap_object + * + * Purpose: Use a "wrapper context" to wrap a data object + * + * Return: Success: 0 + * Failure: -1 + * + *--------------------------------------------------------------------------- + */ +static void * +H5VL_pass_through_wrap_object(void *obj, void *_wrap_ctx) +{ + H5VL_pass_through_wrap_ctx_t *wrap_ctx = (H5VL_pass_through_wrap_ctx_t *)_wrap_ctx; + H5VL_pass_through_t *new_obj; + void *under; + +#ifdef ENABLE_PASSTHRU_LOGGING + printf("------- PASS THROUGH VOL WRAP Object\n"); +#endif + + /* Wrap the object with the underlying VOL */ + under = H5VLwrap_object(obj, wrap_ctx->under_vol_id, wrap_ctx->under_wrap_ctx); + if(under) + new_obj = H5VL_pass_through_new_obj(under, wrap_ctx->under_vol_id); + else + new_obj = NULL; + + return new_obj; +} /* end H5VL_pass_through_wrap_object() */ + + +/*--------------------------------------------------------------------------- + * Function: H5VL_pass_through_free_wrap_ctx + * + * Purpose: Release a "wrapper context" for an object + * + * Return: Success: 0 + * Failure: -1 + * + *--------------------------------------------------------------------------- + */ +static herr_t +H5VL_pass_through_free_wrap_ctx(void *_wrap_ctx) +{ + H5VL_pass_through_wrap_ctx_t *wrap_ctx = (H5VL_pass_through_wrap_ctx_t *)_wrap_ctx; + +#ifdef ENABLE_PASSTHRU_LOGGING + printf("------- PASS THROUGH VOL WRAP CTX Free\n"); +#endif + + /* Release underlying VOL ID and wrap context */ + if(wrap_ctx->under_wrap_ctx) + H5VLfree_wrap_ctx(wrap_ctx->under_wrap_ctx, wrap_ctx->under_vol_id); + H5Idec_ref(wrap_ctx->under_vol_id); + + /* Free pass through wrap context object itself */ + free(wrap_ctx); + + return 0; +} /* end H5VL_pass_through_free_wrap_ctx() */ + + +/*------------------------------------------------------------------------- + * Function: H5VL_pass_through_attr_create + * + * Purpose: Creates an attribute on an object. + * + * Return: Success: Pointer to attribute object + * Failure: NULL + * + *------------------------------------------------------------------------- + */ +static void * +H5VL_pass_through_attr_create(void *obj, const H5VL_loc_params_t *loc_params, + const char *name, hid_t acpl_id, hid_t aapl_id, hid_t dxpl_id, void **req) +{ + H5VL_pass_through_t *attr; + H5VL_pass_through_t *o = (H5VL_pass_through_t *)obj; + void *under; + +#ifdef ENABLE_PASSTHRU_LOGGING + printf("------- PASS THROUGH VOL ATTRIBUTE Create\n"); +#endif + + under = H5VLattr_create(o->under_object, loc_params, o->under_vol_id, name, acpl_id, aapl_id, dxpl_id, req); + if(under) { + attr = H5VL_pass_through_new_obj(under, o->under_vol_id); + + /* Check for async request */ + if(req && *req) + *req = H5VL_pass_through_new_obj(*req, o->under_vol_id); + } /* end if */ + else + attr = NULL; + + return (void*)attr; +} /* end H5VL_pass_through_attr_create() */ + + +/*------------------------------------------------------------------------- + * Function: H5VL_pass_through_attr_open + * + * Purpose: Opens an attribute on an object. + * + * Return: Success: Pointer to attribute object + * Failure: NULL + * + *------------------------------------------------------------------------- + */ +static void * +H5VL_pass_through_attr_open(void *obj, const H5VL_loc_params_t *loc_params, + const char *name, hid_t aapl_id, hid_t dxpl_id, void **req) +{ + H5VL_pass_through_t *attr; + H5VL_pass_through_t *o = (H5VL_pass_through_t *)obj; + void *under; + +#ifdef ENABLE_PASSTHRU_LOGGING + printf("------- PASS THROUGH VOL ATTRIBUTE Open\n"); +#endif + + under = H5VLattr_open(o->under_object, loc_params, o->under_vol_id, name, aapl_id, dxpl_id, req); + if(under) { + attr = H5VL_pass_through_new_obj(under, o->under_vol_id); + + /* Check for async request */ + if(req && *req) + *req = H5VL_pass_through_new_obj(*req, o->under_vol_id); + } /* end if */ + else + attr = NULL; + + return (void *)attr; +} /* end H5VL_pass_through_attr_open() */ + + +/*------------------------------------------------------------------------- + * Function: H5VL_pass_through_attr_read + * + * Purpose: Reads data from attribute. + * + * Return: Success: 0 + * Failure: -1 + * + *------------------------------------------------------------------------- + */ +static herr_t +H5VL_pass_through_attr_read(void *attr, hid_t mem_type_id, void *buf, + hid_t dxpl_id, void **req) +{ + H5VL_pass_through_t *o = (H5VL_pass_through_t *)attr; + herr_t ret_value; + +#ifdef ENABLE_PASSTHRU_LOGGING + printf("------- PASS THROUGH VOL ATTRIBUTE Read\n"); +#endif + + ret_value = H5VLattr_read(o->under_object, o->under_vol_id, mem_type_id, buf, dxpl_id, req); + + /* Check for async request */ + if(req && *req) + *req = H5VL_pass_through_new_obj(*req, o->under_vol_id); + + return ret_value; +} /* end H5VL_pass_through_attr_read() */ + + +/*------------------------------------------------------------------------- + * Function: H5VL_pass_through_attr_write + * + * Purpose: Writes data to attribute. + * + * Return: Success: 0 + * Failure: -1 + * + *------------------------------------------------------------------------- + */ +static herr_t +H5VL_pass_through_attr_write(void *attr, hid_t mem_type_id, const void *buf, + hid_t dxpl_id, void **req) +{ + H5VL_pass_through_t *o = (H5VL_pass_through_t *)attr; + herr_t ret_value; + +#ifdef ENABLE_PASSTHRU_LOGGING + printf("------- PASS THROUGH VOL ATTRIBUTE Write\n"); +#endif + + ret_value = H5VLattr_write(o->under_object, o->under_vol_id, mem_type_id, buf, dxpl_id, req); + + /* Check for async request */ + if(req && *req) + *req = H5VL_pass_through_new_obj(*req, o->under_vol_id); + + return ret_value; +} /* end H5VL_pass_through_attr_write() */ + + +/*------------------------------------------------------------------------- + * Function: H5VL_pass_through_attr_get + * + * Purpose: Gets information about an attribute + * + * Return: Success: 0 + * Failure: -1 + * + *------------------------------------------------------------------------- + */ +static herr_t +H5VL_pass_through_attr_get(void *obj, H5VL_attr_get_t get_type, hid_t dxpl_id, + void **req, va_list arguments) +{ + H5VL_pass_through_t *o = (H5VL_pass_through_t *)obj; + herr_t ret_value; + +#ifdef ENABLE_PASSTHRU_LOGGING + printf("------- PASS THROUGH VOL ATTRIBUTE Get\n"); +#endif + + ret_value = H5VLattr_get(o->under_object, o->under_vol_id, get_type, dxpl_id, req, arguments); + + /* Check for async request */ + if(req && *req) + *req = H5VL_pass_through_new_obj(*req, o->under_vol_id); + + return ret_value; +} /* end H5VL_pass_through_attr_get() */ + + +/*------------------------------------------------------------------------- + * Function: H5VL_pass_through_attr_specific + * + * Purpose: Specific operation on attribute + * + * Return: Success: 0 + * Failure: -1 + * + *------------------------------------------------------------------------- + */ +static herr_t +H5VL_pass_through_attr_specific(void *obj, const H5VL_loc_params_t *loc_params, + H5VL_attr_specific_t specific_type, hid_t dxpl_id, void **req, va_list arguments) +{ + H5VL_pass_through_t *o = (H5VL_pass_through_t *)obj; + herr_t ret_value; + +#ifdef ENABLE_PASSTHRU_LOGGING + printf("------- PASS THROUGH VOL ATTRIBUTE Specific\n"); +#endif + + ret_value = H5VLattr_specific(o->under_object, loc_params, o->under_vol_id, specific_type, dxpl_id, req, arguments); + + /* Check for async request */ + if(req && *req) + *req = H5VL_pass_through_new_obj(*req, o->under_vol_id); + + return ret_value; +} /* end H5VL_pass_through_attr_specific() */ + + +/*------------------------------------------------------------------------- + * Function: H5VL_pass_through_attr_optional + * + * Purpose: Perform a connector-specific operation on an attribute + * + * Return: Success: 0 + * Failure: -1 + * + *------------------------------------------------------------------------- + */ +static herr_t +H5VL_pass_through_attr_optional(void *obj, hid_t dxpl_id, void **req, + va_list arguments) +{ + H5VL_pass_through_t *o = (H5VL_pass_through_t *)obj; + herr_t ret_value; + +#ifdef ENABLE_PASSTHRU_LOGGING + printf("------- PASS THROUGH VOL ATTRIBUTE Optional\n"); +#endif + + ret_value = H5VLattr_optional(o->under_object, o->under_vol_id, dxpl_id, req, arguments); + + /* Check for async request */ + if(req && *req) + *req = H5VL_pass_through_new_obj(*req, o->under_vol_id); + + return ret_value; +} /* end H5VL_pass_through_attr_optional() */ + + +/*------------------------------------------------------------------------- + * Function: H5VL_pass_through_attr_close + * + * Purpose: Closes an attribute. + * + * Return: Success: 0 + * Failure: -1, attr not closed. + * + *------------------------------------------------------------------------- + */ +static herr_t +H5VL_pass_through_attr_close(void *attr, hid_t dxpl_id, void **req) +{ + H5VL_pass_through_t *o = (H5VL_pass_through_t *)attr; + herr_t ret_value; + +#ifdef ENABLE_PASSTHRU_LOGGING + printf("------- PASS THROUGH VOL ATTRIBUTE Close\n"); +#endif + + ret_value = H5VLattr_close(o->under_object, o->under_vol_id, dxpl_id, req); + + /* Check for async request */ + if(req && *req) + *req = H5VL_pass_through_new_obj(*req, o->under_vol_id); + + /* Release our wrapper, if underlying attribute was closed */ + if(ret_value >= 0) + H5VL_pass_through_free_obj(o); + + return ret_value; +} /* end H5VL_pass_through_attr_close() */ + + +/*------------------------------------------------------------------------- + * Function: H5VL_pass_through_dataset_create + * + * Purpose: Creates a dataset in a container + * + * Return: Success: Pointer to a dataset object + * Failure: NULL + * + *------------------------------------------------------------------------- + */ +static void * +H5VL_pass_through_dataset_create(void *obj, const H5VL_loc_params_t *loc_params, + const char *name, hid_t dcpl_id, hid_t dapl_id, hid_t dxpl_id, void **req) +{ + H5VL_pass_through_t *dset; + H5VL_pass_through_t *o = (H5VL_pass_through_t *)obj; + void *under; + +#ifdef ENABLE_PASSTHRU_LOGGING + printf("------- PASS THROUGH VOL DATASET Create\n"); +#endif + + under = H5VLdataset_create(o->under_object, loc_params, o->under_vol_id, name, dcpl_id, dapl_id, dxpl_id, req); + if(under) { + dset = H5VL_pass_through_new_obj(under, o->under_vol_id); + + /* Check for async request */ + if(req && *req) + *req = H5VL_pass_through_new_obj(*req, o->under_vol_id); + } /* end if */ + else + dset = NULL; + + return (void *)dset; +} /* end H5VL_pass_through_dataset_create() */ + + +/*------------------------------------------------------------------------- + * Function: H5VL_pass_through_dataset_open + * + * Purpose: Opens a dataset in a container + * + * Return: Success: Pointer to a dataset object + * Failure: NULL + * + *------------------------------------------------------------------------- + */ +static void * +H5VL_pass_through_dataset_open(void *obj, const H5VL_loc_params_t *loc_params, + const char *name, hid_t dapl_id, hid_t dxpl_id, void **req) +{ + H5VL_pass_through_t *dset; + H5VL_pass_through_t *o = (H5VL_pass_through_t *)obj; + void *under; + +#ifdef ENABLE_PASSTHRU_LOGGING + printf("------- PASS THROUGH VOL DATASET Open\n"); +#endif + + under = H5VLdataset_open(o->under_object, loc_params, o->under_vol_id, name, dapl_id, dxpl_id, req); + if(under) { + dset = H5VL_pass_through_new_obj(under, o->under_vol_id); + + /* Check for async request */ + if(req && *req) + *req = H5VL_pass_through_new_obj(*req, o->under_vol_id); + } /* end if */ + else + dset = NULL; + + return (void *)dset; +} /* end H5VL_pass_through_dataset_open() */ + + +/*------------------------------------------------------------------------- + * Function: H5VL_pass_through_dataset_read + * + * Purpose: Reads data elements from a dataset into a buffer. + * + * Return: Success: 0 + * Failure: -1 + * + *------------------------------------------------------------------------- + */ +static herr_t +H5VL_pass_through_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_pass_through_t *o = (H5VL_pass_through_t *)dset; + herr_t ret_value; + +#ifdef ENABLE_PASSTHRU_LOGGING + printf("------- PASS THROUGH VOL DATASET Read\n"); +#endif + + ret_value = H5VLdataset_read(o->under_object, o->under_vol_id, mem_type_id, mem_space_id, file_space_id, plist_id, buf, req); + + /* Check for async request */ + if(req && *req) + *req = H5VL_pass_through_new_obj(*req, o->under_vol_id); + + return ret_value; +} /* end H5VL_pass_through_dataset_read() */ + + +/*------------------------------------------------------------------------- + * Function: H5VL_pass_through_dataset_write + * + * Purpose: Writes data elements from a buffer into a dataset. + * + * Return: Success: 0 + * Failure: -1 + * + *------------------------------------------------------------------------- + */ +static herr_t +H5VL_pass_through_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_pass_through_t *o = (H5VL_pass_through_t *)dset; + herr_t ret_value; + +#ifdef ENABLE_PASSTHRU_LOGGING + printf("------- PASS THROUGH VOL DATASET Write\n"); +#endif + + ret_value = H5VLdataset_write(o->under_object, o->under_vol_id, mem_type_id, mem_space_id, file_space_id, plist_id, buf, req); + + /* Check for async request */ + if(req && *req) + *req = H5VL_pass_through_new_obj(*req, o->under_vol_id); + + return ret_value; +} /* end H5VL_pass_through_dataset_write() */ + + +/*------------------------------------------------------------------------- + * Function: H5VL_pass_through_dataset_get + * + * Purpose: Gets information about a dataset + * + * Return: Success: 0 + * Failure: -1 + * + *------------------------------------------------------------------------- + */ +static herr_t +H5VL_pass_through_dataset_get(void *dset, H5VL_dataset_get_t get_type, + hid_t dxpl_id, void **req, va_list arguments) +{ + H5VL_pass_through_t *o = (H5VL_pass_through_t *)dset; + herr_t ret_value; + +#ifdef ENABLE_PASSTHRU_LOGGING + printf("------- PASS THROUGH VOL DATASET Get\n"); +#endif + + ret_value = H5VLdataset_get(o->under_object, o->under_vol_id, get_type, dxpl_id, req, arguments); + + /* Check for async request */ + if(req && *req) + *req = H5VL_pass_through_new_obj(*req, o->under_vol_id); + + return ret_value; +} /* end H5VL_pass_through_dataset_get() */ + + +/*------------------------------------------------------------------------- + * Function: H5VL_pass_through_dataset_specific + * + * Purpose: Specific operation on a dataset + * + * Return: Success: 0 + * Failure: -1 + * + *------------------------------------------------------------------------- + */ +static herr_t +H5VL_pass_through_dataset_specific(void *obj, H5VL_dataset_specific_t specific_type, + hid_t dxpl_id, void **req, va_list arguments) +{ + H5VL_pass_through_t *o = (H5VL_pass_through_t *)obj; + herr_t ret_value; + +#ifdef ENABLE_PASSTHRU_LOGGING + printf("------- PASS THROUGH VOL H5Dspecific\n"); +#endif + + ret_value = H5VLdataset_specific(o->under_object, o->under_vol_id, specific_type, dxpl_id, req, arguments); + + /* Check for async request */ + if(req && *req) + *req = H5VL_pass_through_new_obj(*req, o->under_vol_id); + + return ret_value; +} /* end H5VL_pass_through_dataset_specific() */ + + +/*------------------------------------------------------------------------- + * Function: H5VL_pass_through_dataset_optional + * + * Purpose: Perform a connector-specific operation on a dataset + * + * Return: Success: 0 + * Failure: -1 + * + *------------------------------------------------------------------------- + */ +static herr_t +H5VL_pass_through_dataset_optional(void *obj, hid_t dxpl_id, void **req, + va_list arguments) +{ + H5VL_pass_through_t *o = (H5VL_pass_through_t *)obj; + herr_t ret_value; + +#ifdef ENABLE_PASSTHRU_LOGGING + printf("------- PASS THROUGH VOL DATASET Optional\n"); +#endif + + ret_value = H5VLdataset_optional(o->under_object, o->under_vol_id, dxpl_id, req, arguments); + + /* Check for async request */ + if(req && *req) + *req = H5VL_pass_through_new_obj(*req, o->under_vol_id); + + return ret_value; +} /* end H5VL_pass_through_dataset_optional() */ + + +/*------------------------------------------------------------------------- + * Function: H5VL_pass_through_dataset_close + * + * Purpose: Closes a dataset. + * + * Return: Success: 0 + * Failure: -1, dataset not closed. + * + *------------------------------------------------------------------------- + */ +static herr_t +H5VL_pass_through_dataset_close(void *dset, hid_t dxpl_id, void **req) +{ + H5VL_pass_through_t *o = (H5VL_pass_through_t *)dset; + herr_t ret_value; + +#ifdef ENABLE_PASSTHRU_LOGGING + printf("------- PASS THROUGH VOL DATASET Close\n"); +#endif + + ret_value = H5VLdataset_close(o->under_object, o->under_vol_id, dxpl_id, req); + + /* Check for async request */ + if(req && *req) + *req = H5VL_pass_through_new_obj(*req, o->under_vol_id); + + /* Release our wrapper, if underlying dataset was closed */ + if(ret_value >= 0) + H5VL_pass_through_free_obj(o); + + return ret_value; +} /* end H5VL_pass_through_dataset_close() */ + + +/*------------------------------------------------------------------------- + * Function: H5VL_pass_through_datatype_commit + * + * Purpose: Commits a datatype inside a container. + * + * Return: Success: Pointer to datatype object + * Failure: NULL + * + *------------------------------------------------------------------------- + */ +static void * +H5VL_pass_through_datatype_commit(void *obj, const 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_pass_through_t *dt; + H5VL_pass_through_t *o = (H5VL_pass_through_t *)obj; + void *under; + +#ifdef ENABLE_PASSTHRU_LOGGING + printf("------- PASS THROUGH VOL DATATYPE Commit\n"); +#endif + + under = H5VLdatatype_commit(o->under_object, loc_params, o->under_vol_id, name, type_id, lcpl_id, tcpl_id, tapl_id, dxpl_id, req); + if(under) { + dt = H5VL_pass_through_new_obj(under, o->under_vol_id); + + /* Check for async request */ + if(req && *req) + *req = H5VL_pass_through_new_obj(*req, o->under_vol_id); + } /* end if */ + else + dt = NULL; + + return (void *)dt; +} /* end H5VL_pass_through_datatype_commit() */ + + +/*------------------------------------------------------------------------- + * Function: H5VL_pass_through_datatype_open + * + * Purpose: Opens a named datatype inside a container. + * + * Return: Success: Pointer to datatype object + * Failure: NULL + * + *------------------------------------------------------------------------- + */ +static void * +H5VL_pass_through_datatype_open(void *obj, const H5VL_loc_params_t *loc_params, + const char *name, hid_t tapl_id, hid_t dxpl_id, void **req) +{ + H5VL_pass_through_t *dt; + H5VL_pass_through_t *o = (H5VL_pass_through_t *)obj; + void *under; + +#ifdef ENABLE_PASSTHRU_LOGGING + printf("------- PASS THROUGH VOL DATATYPE Open\n"); +#endif + + under = H5VLdatatype_open(o->under_object, loc_params, o->under_vol_id, name, tapl_id, dxpl_id, req); + if(under) { + dt = H5VL_pass_through_new_obj(under, o->under_vol_id); + + /* Check for async request */ + if(req && *req) + *req = H5VL_pass_through_new_obj(*req, o->under_vol_id); + } /* end if */ + else + dt = NULL; + + return (void *)dt; +} /* end H5VL_pass_through_datatype_open() */ + + +/*------------------------------------------------------------------------- + * Function: H5VL_pass_through_datatype_get + * + * Purpose: Get information about a datatype + * + * Return: Success: 0 + * Failure: -1 + * + *------------------------------------------------------------------------- + */ +static herr_t +H5VL_pass_through_datatype_get(void *dt, H5VL_datatype_get_t get_type, + hid_t dxpl_id, void **req, va_list arguments) +{ + H5VL_pass_through_t *o = (H5VL_pass_through_t *)dt; + herr_t ret_value; + +#ifdef ENABLE_PASSTHRU_LOGGING + printf("------- PASS THROUGH VOL DATATYPE Get\n"); +#endif + + ret_value = H5VLdatatype_get(o->under_object, o->under_vol_id, get_type, dxpl_id, req, arguments); + + /* Check for async request */ + if(req && *req) + *req = H5VL_pass_through_new_obj(*req, o->under_vol_id); + + return ret_value; +} /* end H5VL_pass_through_datatype_get() */ + + +/*------------------------------------------------------------------------- + * Function: H5VL_pass_through_datatype_specific + * + * Purpose: Specific operations for datatypes + * + * Return: Success: 0 + * Failure: -1 + * + *------------------------------------------------------------------------- + */ +static herr_t +H5VL_pass_through_datatype_specific(void *obj, H5VL_datatype_specific_t specific_type, + hid_t dxpl_id, void **req, va_list arguments) +{ + H5VL_pass_through_t *o = (H5VL_pass_through_t *)obj; + herr_t ret_value; + +#ifdef ENABLE_PASSTHRU_LOGGING + printf("------- PASS THROUGH VOL DATATYPE Specific\n"); +#endif + + ret_value = H5VLdatatype_specific(o->under_object, o->under_vol_id, specific_type, dxpl_id, req, arguments); + + /* Check for async request */ + if(req && *req) + *req = H5VL_pass_through_new_obj(*req, o->under_vol_id); + + return ret_value; +} /* end H5VL_pass_through_datatype_specific() */ + + +/*------------------------------------------------------------------------- + * Function: H5VL_pass_through_datatype_optional + * + * Purpose: Perform a connector-specific operation on a datatype + * + * Return: Success: 0 + * Failure: -1 + * + *------------------------------------------------------------------------- + */ +static herr_t +H5VL_pass_through_datatype_optional(void *obj, hid_t dxpl_id, void **req, + va_list arguments) +{ + H5VL_pass_through_t *o = (H5VL_pass_through_t *)obj; + herr_t ret_value; + +#ifdef ENABLE_PASSTHRU_LOGGING + printf("------- PASS THROUGH VOL DATATYPE Optional\n"); +#endif + + ret_value = H5VLdatatype_optional(o->under_object, o->under_vol_id, dxpl_id, req, arguments); + + /* Check for async request */ + if(req && *req) + *req = H5VL_pass_through_new_obj(*req, o->under_vol_id); + + return ret_value; +} /* end H5VL_pass_through_datatype_optional() */ + + +/*------------------------------------------------------------------------- + * Function: H5VL_pass_through_datatype_close + * + * Purpose: Closes a datatype. + * + * Return: Success: 0 + * Failure: -1, datatype not closed. + * + *------------------------------------------------------------------------- + */ +static herr_t +H5VL_pass_through_datatype_close(void *dt, hid_t dxpl_id, void **req) +{ + H5VL_pass_through_t *o = (H5VL_pass_through_t *)dt; + herr_t ret_value; + +#ifdef ENABLE_PASSTHRU_LOGGING + printf("------- PASS THROUGH VOL DATATYPE Close\n"); +#endif + + assert(o->under_object); + + ret_value = H5VLdatatype_close(o->under_object, o->under_vol_id, dxpl_id, req); + + /* Check for async request */ + if(req && *req) + *req = H5VL_pass_through_new_obj(*req, o->under_vol_id); + + /* Release our wrapper, if underlying datatype was closed */ + if(ret_value >= 0) + H5VL_pass_through_free_obj(o); + + return ret_value; +} /* end H5VL_pass_through_datatype_close() */ + + +/*------------------------------------------------------------------------- + * Function: H5VL_pass_through_file_create + * + * Purpose: Creates a container using this connector + * + * Return: Success: Pointer to a file object + * Failure: NULL + * + *------------------------------------------------------------------------- + */ +static void * +H5VL_pass_through_file_create(const char *name, unsigned flags, hid_t fcpl_id, + hid_t fapl_id, hid_t dxpl_id, void **req) +{ + H5VL_pass_through_info_t *info; + H5VL_pass_through_t *file; + hid_t under_fapl_id; + void *under; + +#ifdef ENABLE_PASSTHRU_LOGGING + printf("------- PASS THROUGH VOL FILE Create\n"); +#endif + + /* Get copy of our VOL info from FAPL */ + H5Pget_vol_info(fapl_id, (void **)&info); + + /* Copy the FAPL */ + under_fapl_id = H5Pcopy(fapl_id); + + /* Set the VOL ID and info for the underlying FAPL */ + H5Pset_vol(under_fapl_id, info->under_vol_id, info->under_vol_info); + + /* Open the file with the underlying VOL connector */ + under = H5VLfile_create(name, flags, fcpl_id, under_fapl_id, dxpl_id, req); + if(under) { + file = H5VL_pass_through_new_obj(under, info->under_vol_id); + + /* Check for async request */ + if(req && *req) + *req = H5VL_pass_through_new_obj(*req, info->under_vol_id); + } /* end if */ + else + file = NULL; + + /* Close underlying FAPL */ + H5Pclose(under_fapl_id); + + /* Release copy of our VOL info */ + H5VL_pass_through_info_free(info); + + return (void *)file; +} /* end H5VL_pass_through_file_create() */ + + +/*------------------------------------------------------------------------- + * Function: H5VL_pass_through_file_open + * + * Purpose: Opens a container created with this connector + * + * Return: Success: Pointer to a file object + * Failure: NULL + * + *------------------------------------------------------------------------- + */ +static void * +H5VL_pass_through_file_open(const char *name, unsigned flags, hid_t fapl_id, + hid_t dxpl_id, void **req) +{ + H5VL_pass_through_info_t *info; + H5VL_pass_through_t *file; + hid_t under_fapl_id; + void *under; + +#ifdef ENABLE_PASSTHRU_LOGGING + printf("------- PASS THROUGH VOL FILE Open\n"); +#endif + + /* Get copy of our VOL info from FAPL */ + H5Pget_vol_info(fapl_id, (void **)&info); + + /* Copy the FAPL */ + under_fapl_id = H5Pcopy(fapl_id); + + /* Set the VOL ID and info for the underlying FAPL */ + H5Pset_vol(under_fapl_id, info->under_vol_id, info->under_vol_info); + + /* Open the file with the underlying VOL connector */ + under = H5VLfile_open(name, flags, under_fapl_id, dxpl_id, req); + if(under) { + file = H5VL_pass_through_new_obj(under, info->under_vol_id); + + /* Check for async request */ + if(req && *req) + *req = H5VL_pass_through_new_obj(*req, info->under_vol_id); + } /* end if */ + else + file = NULL; + + /* Close underlying FAPL */ + H5Pclose(under_fapl_id); + + /* Release copy of our VOL info */ + H5VL_pass_through_info_free(info); + + return (void *)file; +} /* end H5VL_pass_through_file_open() */ + + +/*------------------------------------------------------------------------- + * Function: H5VL_pass_through_file_get + * + * Purpose: Get info about a file + * + * Return: Success: 0 + * Failure: -1 + * + *------------------------------------------------------------------------- + */ +static herr_t +H5VL_pass_through_file_get(void *file, H5VL_file_get_t get_type, hid_t dxpl_id, + void **req, va_list arguments) +{ + H5VL_pass_through_t *o = (H5VL_pass_through_t *)file; + herr_t ret_value; + +#ifdef ENABLE_PASSTHRU_LOGGING + printf("------- PASS THROUGH VOL FILE Get\n"); +#endif + + ret_value = H5VLfile_get(o->under_object, o->under_vol_id, get_type, dxpl_id, req, arguments); + + /* Check for async request */ + if(req && *req) + *req = H5VL_pass_through_new_obj(*req, o->under_vol_id); + + return ret_value; +} /* end H5VL_pass_through_file_get() */ + + +/*------------------------------------------------------------------------- + * Function: H5VL_pass_through_file_specific_reissue + * + * Purpose: Re-wrap vararg arguments into a va_list and reissue the + * file specific callback to the underlying VOL connector. + * + * Return: Success: 0 + * Failure: -1 + * + *------------------------------------------------------------------------- + */ +static herr_t +H5VL_pass_through_file_specific_reissue(void *obj, hid_t connector_id, + H5VL_file_specific_t specific_type, hid_t dxpl_id, void **req, ...) +{ + va_list arguments; + herr_t ret_value; + + va_start(arguments, req); + ret_value = H5VLfile_specific(obj, connector_id, specific_type, dxpl_id, req, arguments); + va_end(arguments); + + return ret_value; +} /* end H5VL_pass_through_file_specific_reissue() */ + + +/*------------------------------------------------------------------------- + * Function: H5VL_pass_through_file_specific + * + * Purpose: Specific operation on file + * + * Return: Success: 0 + * Failure: -1 + * + *------------------------------------------------------------------------- + */ +static herr_t +H5VL_pass_through_file_specific(void *file, H5VL_file_specific_t specific_type, + hid_t dxpl_id, void **req, va_list arguments) +{ + H5VL_pass_through_t *o = (H5VL_pass_through_t *)file; + hid_t under_vol_id = -1; + herr_t ret_value; + +#ifdef ENABLE_PASSTHRU_LOGGING + printf("------- PASS THROUGH VOL FILE Specific\n"); +#endif + + /* Unpack arguments to get at the child file pointer when mounting a file */ + if(specific_type == H5VL_FILE_MOUNT) { + H5I_type_t loc_type; + const char *name; + H5VL_pass_through_t *child_file; + hid_t plist_id; + + /* Retrieve parameters for 'mount' operation, so we can unwrap the child file */ + loc_type = (H5I_type_t)va_arg(arguments, int); /* enum work-around */ + name = va_arg(arguments, const char *); + child_file = (H5VL_pass_through_t *)va_arg(arguments, void *); + plist_id = va_arg(arguments, hid_t); + + /* Keep the correct underlying VOL ID for possible async request token */ + under_vol_id = o->under_vol_id; + + /* Re-issue 'file specific' call, using the unwrapped pieces */ + ret_value = H5VL_pass_through_file_specific_reissue(o->under_object, o->under_vol_id, specific_type, dxpl_id, req, (int)loc_type, name, child_file->under_object, plist_id); + } /* end if */ + else if(specific_type == H5VL_FILE_IS_ACCESSIBLE) { + H5VL_pass_through_info_t *info; + hid_t fapl_id, under_fapl_id; + const char *name; + htri_t *ret; + + /* Get the arguments for the 'is accessible' check */ + fapl_id = va_arg(arguments, hid_t); + name = va_arg(arguments, const char *); + ret = va_arg(arguments, htri_t *); + + /* Get copy of our VOL info from FAPL */ + H5Pget_vol_info(fapl_id, (void **)&info); + + /* Copy the FAPL */ + under_fapl_id = H5Pcopy(fapl_id); + + /* Set the VOL ID and info for the underlying FAPL */ + H5Pset_vol(under_fapl_id, info->under_vol_id, info->under_vol_info); + + /* Keep the correct underlying VOL ID for possible async request token */ + under_vol_id = info->under_vol_id; + + /* Re-issue 'file specific' call */ + ret_value = H5VL_pass_through_file_specific_reissue(NULL, info->under_vol_id, specific_type, dxpl_id, req, under_fapl_id, name, ret); + + /* Close underlying FAPL */ + H5Pclose(under_fapl_id); + + /* Release copy of our VOL info */ + H5VL_pass_through_info_free(info); + } /* end else-if */ + else { + va_list my_arguments; + + /* Make a copy of the argument list for later, if reopening */ + if(specific_type == H5VL_FILE_REOPEN) + va_copy(my_arguments, arguments); + + /* Keep the correct underlying VOL ID for possible async request token */ + under_vol_id = o->under_vol_id; + + ret_value = H5VLfile_specific(o->under_object, o->under_vol_id, specific_type, dxpl_id, req, arguments); + + /* Wrap file struct pointer, if we reopened one */ + if(specific_type == H5VL_FILE_REOPEN) { + if(ret_value >= 0) { + void **ret = va_arg(my_arguments, void **); + + if(ret && *ret) + *ret = H5VL_pass_through_new_obj(*ret, o->under_vol_id); + } /* end if */ + + /* Finish use of copied vararg list */ + va_end(my_arguments); + } /* end if */ + } /* end else */ + + /* Check for async request */ + if(req && *req) + *req = H5VL_pass_through_new_obj(*req, under_vol_id); + + return ret_value; +} /* end H5VL_pass_through_file_specific() */ + + +/*------------------------------------------------------------------------- + * Function: H5VL_pass_through_file_optional + * + * Purpose: Perform a connector-specific operation on a file + * + * Return: Success: 0 + * Failure: -1 + * + *------------------------------------------------------------------------- + */ +static herr_t +H5VL_pass_through_file_optional(void *file, hid_t dxpl_id, void **req, + va_list arguments) +{ + H5VL_pass_through_t *o = (H5VL_pass_through_t *)file; + herr_t ret_value; + +#ifdef ENABLE_PASSTHRU_LOGGING + printf("------- PASS THROUGH VOL File Optional\n"); +#endif + + ret_value = H5VLfile_optional(o->under_object, o->under_vol_id, dxpl_id, req, arguments); + + /* Check for async request */ + if(req && *req) + *req = H5VL_pass_through_new_obj(*req, o->under_vol_id); + + return ret_value; +} /* end H5VL_pass_through_file_optional() */ + + +/*------------------------------------------------------------------------- + * Function: H5VL_pass_through_file_close + * + * Purpose: Closes a file. + * + * Return: Success: 0 + * Failure: -1, file not closed. + * + *------------------------------------------------------------------------- + */ +static herr_t +H5VL_pass_through_file_close(void *file, hid_t dxpl_id, void **req) +{ + H5VL_pass_through_t *o = (H5VL_pass_through_t *)file; + herr_t ret_value; + +#ifdef ENABLE_PASSTHRU_LOGGING + printf("------- PASS THROUGH VOL FILE Close\n"); +#endif + + ret_value = H5VLfile_close(o->under_object, o->under_vol_id, dxpl_id, req); + + /* Check for async request */ + if(req && *req) + *req = H5VL_pass_through_new_obj(*req, o->under_vol_id); + + /* Release our wrapper, if underlying file was closed */ + if(ret_value >= 0) + H5VL_pass_through_free_obj(o); + + return ret_value; +} /* end H5VL_pass_through_file_close() */ + + +/*------------------------------------------------------------------------- + * Function: H5VL_pass_through_group_create + * + * Purpose: Creates a group inside a container + * + * Return: Success: Pointer to a group object + * Failure: NULL + * + *------------------------------------------------------------------------- + */ +static void * +H5VL_pass_through_group_create(void *obj, const H5VL_loc_params_t *loc_params, + const char *name, hid_t gcpl_id, hid_t gapl_id, hid_t dxpl_id, void **req) +{ + H5VL_pass_through_t *group; + H5VL_pass_through_t *o = (H5VL_pass_through_t *)obj; + void *under; + +#ifdef ENABLE_PASSTHRU_LOGGING + printf("------- PASS THROUGH VOL GROUP Create\n"); +#endif + + under = H5VLgroup_create(o->under_object, loc_params, o->under_vol_id, name, gcpl_id, gapl_id, dxpl_id, req); + if(under) { + group = H5VL_pass_through_new_obj(under, o->under_vol_id); + + /* Check for async request */ + if(req && *req) + *req = H5VL_pass_through_new_obj(*req, o->under_vol_id); + } /* end if */ + else + group = NULL; + + return (void *)group; +} /* end H5VL_pass_through_group_create() */ + + +/*------------------------------------------------------------------------- + * Function: H5VL_pass_through_group_open + * + * Purpose: Opens a group inside a container + * + * Return: Success: Pointer to a group object + * Failure: NULL + * + *------------------------------------------------------------------------- + */ +static void * +H5VL_pass_through_group_open(void *obj, const H5VL_loc_params_t *loc_params, + const char *name, hid_t gapl_id, hid_t dxpl_id, void **req) +{ + H5VL_pass_through_t *group; + H5VL_pass_through_t *o = (H5VL_pass_through_t *)obj; + void *under; + +#ifdef ENABLE_PASSTHRU_LOGGING + printf("------- PASS THROUGH VOL GROUP Open\n"); +#endif + + under = H5VLgroup_open(o->under_object, loc_params, o->under_vol_id, name, gapl_id, dxpl_id, req); + if(under) { + group = H5VL_pass_through_new_obj(under, o->under_vol_id); + + /* Check for async request */ + if(req && *req) + *req = H5VL_pass_through_new_obj(*req, o->under_vol_id); + } /* end if */ + else + group = NULL; + + return (void *)group; +} /* end H5VL_pass_through_group_open() */ + + +/*------------------------------------------------------------------------- + * Function: H5VL_pass_through_group_get + * + * Purpose: Get info about a group + * + * Return: Success: 0 + * Failure: -1 + * + *------------------------------------------------------------------------- + */ +static herr_t +H5VL_pass_through_group_get(void *obj, H5VL_group_get_t get_type, hid_t dxpl_id, + void **req, va_list arguments) +{ + H5VL_pass_through_t *o = (H5VL_pass_through_t *)obj; + herr_t ret_value; + +#ifdef ENABLE_PASSTHRU_LOGGING + printf("------- PASS THROUGH VOL GROUP Get\n"); +#endif + + ret_value = H5VLgroup_get(o->under_object, o->under_vol_id, get_type, dxpl_id, req, arguments); + + /* Check for async request */ + if(req && *req) + *req = H5VL_pass_through_new_obj(*req, o->under_vol_id); + + return ret_value; +} /* end H5VL_pass_through_group_get() */ + + +/*------------------------------------------------------------------------- + * Function: H5VL_pass_through_group_specific + * + * Purpose: Specific operation on a group + * + * Return: Success: 0 + * Failure: -1 + * + *------------------------------------------------------------------------- + */ +static herr_t +H5VL_pass_through_group_specific(void *obj, H5VL_group_specific_t specific_type, + hid_t dxpl_id, void **req, va_list arguments) +{ + H5VL_pass_through_t *o = (H5VL_pass_through_t *)obj; + herr_t ret_value; + +#ifdef ENABLE_PASSTHRU_LOGGING + printf("------- PASS THROUGH VOL GROUP Specific\n"); +#endif + + ret_value = H5VLgroup_specific(o->under_object, o->under_vol_id, specific_type, dxpl_id, req, arguments); + + /* Check for async request */ + if(req && *req) + *req = H5VL_pass_through_new_obj(*req, o->under_vol_id); + + return ret_value; +} /* end H5VL_pass_through_group_specific() */ + + +/*------------------------------------------------------------------------- + * Function: H5VL_pass_through_group_optional + * + * Purpose: Perform a connector-specific operation on a group + * + * Return: Success: 0 + * Failure: -1 + * + *------------------------------------------------------------------------- + */ +static herr_t +H5VL_pass_through_group_optional(void *obj, hid_t dxpl_id, void **req, + va_list arguments) +{ + H5VL_pass_through_t *o = (H5VL_pass_through_t *)obj; + herr_t ret_value; + +#ifdef ENABLE_PASSTHRU_LOGGING + printf("------- PASS THROUGH VOL GROUP Optional\n"); +#endif + + ret_value = H5VLgroup_optional(o->under_object, o->under_vol_id, dxpl_id, req, arguments); + + /* Check for async request */ + if(req && *req) + *req = H5VL_pass_through_new_obj(*req, o->under_vol_id); + + return ret_value; +} /* end H5VL_pass_through_group_optional() */ + + +/*------------------------------------------------------------------------- + * Function: H5VL_pass_through_group_close + * + * Purpose: Closes a group. + * + * Return: Success: 0 + * Failure: -1, group not closed. + * + *------------------------------------------------------------------------- + */ +static herr_t +H5VL_pass_through_group_close(void *grp, hid_t dxpl_id, void **req) +{ + H5VL_pass_through_t *o = (H5VL_pass_through_t *)grp; + herr_t ret_value; + +#ifdef ENABLE_PASSTHRU_LOGGING + printf("------- PASS THROUGH VOL H5Gclose\n"); +#endif + + ret_value = H5VLgroup_close(o->under_object, o->under_vol_id, dxpl_id, req); + + /* Check for async request */ + if(req && *req) + *req = H5VL_pass_through_new_obj(*req, o->under_vol_id); + + /* Release our wrapper, if underlying file was closed */ + if(ret_value >= 0) + H5VL_pass_through_free_obj(o); + + return ret_value; +} /* end H5VL_pass_through_group_close() */ + + +/*------------------------------------------------------------------------- + * Function: H5VL_pass_through_link_create + * + * Purpose: Creates a hard / soft / UD / external link. + * + * Return: Success: 0 + * Failure: -1 + * + *------------------------------------------------------------------------- + */ +static herr_t +H5VL_pass_through_link_create(H5VL_link_create_type_t create_type, void *obj, const H5VL_loc_params_t *loc_params, hid_t lcpl_id, hid_t lapl_id, hid_t dxpl_id, void **req) +{ + H5VL_pass_through_t *o = (H5VL_pass_through_t *)obj; + hid_t under_vol_id = -1; + herr_t ret_value; + +#ifdef ENABLE_PASSTHRU_LOGGING + printf("------- PASS THROUGH VOL LINK Create\n"); +#endif + + /* Try to retrieve the "under" VOL id */ + if(o) + under_vol_id = o->under_vol_id; + + /* Fix up the link target object for hard link creation */ + if(H5VL_LINK_CREATE_HARD == create_type) { + void *cur_obj; + + /* Retrieve the object for the link target */ + H5Pget(lcpl_id, H5VL_PROP_LINK_TARGET, &cur_obj); + + /* If it's a non-NULL pointer, find the 'under object' and re-set the property */ + if(cur_obj) { + /* Check if we still need the "under" VOL ID */ + if(under_vol_id < 0) + under_vol_id = ((H5VL_pass_through_t *)cur_obj)->under_vol_id; + + /* Set the object for the link target */ + H5Pset(lcpl_id, H5VL_PROP_LINK_TARGET, &(((H5VL_pass_through_t *)cur_obj)->under_object)); + } /* end if */ + } /* end if */ + + ret_value = H5VLlink_create(create_type, (o ? o->under_object : NULL), loc_params, under_vol_id, lcpl_id, lapl_id, dxpl_id, req); + + /* Check for async request */ + if(req && *req) + *req = H5VL_pass_through_new_obj(*req, under_vol_id); + + return ret_value; +} /* end H5VL_pass_through_link_create() */ + + +/*------------------------------------------------------------------------- + * Function: H5VL_pass_through_link_copy + * + * Purpose: Renames an object within an HDF5 container and copies it to a new + * group. The original name SRC is unlinked from the group graph + * and then inserted with the new name DST (which can specify a + * new path for the object) as an atomic operation. The names + * are interpreted relative to SRC_LOC_ID and + * DST_LOC_ID, which are either file IDs or group ID. + * + * Return: Success: 0 + * Failure: -1 + * + *------------------------------------------------------------------------- + */ +static herr_t +H5VL_pass_through_link_copy(void *src_obj, const H5VL_loc_params_t *loc_params1, + void *dst_obj, const H5VL_loc_params_t *loc_params2, hid_t lcpl_id, + hid_t lapl_id, hid_t dxpl_id, void **req) +{ + H5VL_pass_through_t *o_src = (H5VL_pass_through_t *)src_obj; + H5VL_pass_through_t *o_dst = (H5VL_pass_through_t *)dst_obj; + hid_t under_vol_id = -1; + herr_t ret_value; + +#ifdef ENABLE_PASSTHRU_LOGGING + printf("------- PASS THROUGH VOL LINK Copy\n"); +#endif + + /* Retrieve the "under" VOL id */ + if(o_src) + under_vol_id = o_src->under_vol_id; + else if(o_dst) + under_vol_id = o_dst->under_vol_id; + assert(under_vol_id > 0); + + ret_value = H5VLlink_copy((o_src ? o_src->under_object : NULL), loc_params1, (o_dst ? o_dst->under_object : NULL), loc_params2, under_vol_id, lcpl_id, lapl_id, dxpl_id, req); + + /* Check for async request */ + if(req && *req) + *req = H5VL_pass_through_new_obj(*req, under_vol_id); + + return ret_value; +} /* end H5VL_pass_through_link_copy() */ + + +/*------------------------------------------------------------------------- + * Function: H5VL_pass_through_link_move + * + * Purpose: Moves a link within an HDF5 file to a new group. The original + * name SRC is unlinked from the group graph + * and then inserted with the new name DST (which can specify a + * new path for the object) as an atomic operation. The names + * are interpreted relative to SRC_LOC_ID and + * DST_LOC_ID, which are either file IDs or group ID. + * + * Return: Success: 0 + * Failure: -1 + * + *------------------------------------------------------------------------- + */ +static herr_t +H5VL_pass_through_link_move(void *src_obj, const H5VL_loc_params_t *loc_params1, + void *dst_obj, const H5VL_loc_params_t *loc_params2, hid_t lcpl_id, + hid_t lapl_id, hid_t dxpl_id, void **req) +{ + H5VL_pass_through_t *o_src = (H5VL_pass_through_t *)src_obj; + H5VL_pass_through_t *o_dst = (H5VL_pass_through_t *)dst_obj; + hid_t under_vol_id = -1; + herr_t ret_value; + +#ifdef ENABLE_PASSTHRU_LOGGING + printf("------- PASS THROUGH VOL LINK Move\n"); +#endif + + /* Retrieve the "under" VOL id */ + if(o_src) + under_vol_id = o_src->under_vol_id; + else if(o_dst) + under_vol_id = o_dst->under_vol_id; + assert(under_vol_id > 0); + + ret_value = H5VLlink_move((o_src ? o_src->under_object : NULL), loc_params1, (o_dst ? o_dst->under_object : NULL), loc_params2, under_vol_id, lcpl_id, lapl_id, dxpl_id, req); + + /* Check for async request */ + if(req && *req) + *req = H5VL_pass_through_new_obj(*req, under_vol_id); + + return ret_value; +} /* end H5VL_pass_through_link_move() */ + + +/*------------------------------------------------------------------------- + * Function: H5VL_pass_through_link_get + * + * Purpose: Get info about a link + * + * Return: Success: 0 + * Failure: -1 + * + *------------------------------------------------------------------------- + */ +static herr_t +H5VL_pass_through_link_get(void *obj, const H5VL_loc_params_t *loc_params, + H5VL_link_get_t get_type, hid_t dxpl_id, void **req, va_list arguments) +{ + H5VL_pass_through_t *o = (H5VL_pass_through_t *)obj; + herr_t ret_value; + +#ifdef ENABLE_PASSTHRU_LOGGING + printf("------- PASS THROUGH VOL LINK Get\n"); +#endif + + ret_value = H5VLlink_get(o->under_object, loc_params, o->under_vol_id, get_type, dxpl_id, req, arguments); + + /* Check for async request */ + if(req && *req) + *req = H5VL_pass_through_new_obj(*req, o->under_vol_id); + + return ret_value; +} /* end H5VL_pass_through_link_get() */ + + +/*------------------------------------------------------------------------- + * Function: H5VL_pass_through_link_specific + * + * Purpose: Specific operation on a link + * + * Return: Success: 0 + * Failure: -1 + * + *------------------------------------------------------------------------- + */ +static herr_t +H5VL_pass_through_link_specific(void *obj, const H5VL_loc_params_t *loc_params, + H5VL_link_specific_t specific_type, hid_t dxpl_id, void **req, va_list arguments) +{ + H5VL_pass_through_t *o = (H5VL_pass_through_t *)obj; + herr_t ret_value; + +#ifdef ENABLE_PASSTHRU_LOGGING + printf("------- PASS THROUGH VOL LINK Specific\n"); +#endif + + ret_value = H5VLlink_specific(o->under_object, loc_params, o->under_vol_id, specific_type, dxpl_id, req, arguments); + + /* Check for async request */ + if(req && *req) + *req = H5VL_pass_through_new_obj(*req, o->under_vol_id); + + return ret_value; +} /* end H5VL_pass_through_link_specific() */ + + +/*------------------------------------------------------------------------- + * Function: H5VL_pass_through_link_optional + * + * Purpose: Perform a connector-specific operation on a link + * + * Return: Success: 0 + * Failure: -1 + * + *------------------------------------------------------------------------- + */ +static herr_t +H5VL_pass_through_link_optional(void *obj, hid_t dxpl_id, void **req, + va_list arguments) +{ + H5VL_pass_through_t *o = (H5VL_pass_through_t *)obj; + herr_t ret_value; + +#ifdef ENABLE_PASSTHRU_LOGGING + printf("------- PASS THROUGH VOL LINK Optional\n"); +#endif + + ret_value = H5VLlink_optional(o->under_object, o->under_vol_id, dxpl_id, req, arguments); + + /* Check for async request */ + if(req && *req) + *req = H5VL_pass_through_new_obj(*req, o->under_vol_id); + + return ret_value; +} /* end H5VL_pass_through_link_optional() */ + + +/*------------------------------------------------------------------------- + * Function: H5VL_pass_through_object_open + * + * Purpose: Opens an object inside a container. + * + * Return: Success: Pointer to object + * Failure: NULL + * + *------------------------------------------------------------------------- + */ +static void * +H5VL_pass_through_object_open(void *obj, const H5VL_loc_params_t *loc_params, + H5I_type_t *opened_type, hid_t dxpl_id, void **req) +{ + H5VL_pass_through_t *new_obj; + H5VL_pass_through_t *o = (H5VL_pass_through_t *)obj; + void *under; + +#ifdef ENABLE_PASSTHRU_LOGGING + printf("------- PASS THROUGH VOL OBJECT Open\n"); +#endif + + under = H5VLobject_open(o->under_object, loc_params, o->under_vol_id, opened_type, dxpl_id, req); + if(under) { + new_obj = H5VL_pass_through_new_obj(under, o->under_vol_id); + + /* Check for async request */ + if(req && *req) + *req = H5VL_pass_through_new_obj(*req, o->under_vol_id); + } /* end if */ + else + new_obj = NULL; + + return (void *)new_obj; +} /* end H5VL_pass_through_object_open() */ + + +/*------------------------------------------------------------------------- + * Function: H5VL_pass_through_object_copy + * + * Purpose: Copies an object inside a container. + * + * Return: Success: 0 + * Failure: -1 + * + *------------------------------------------------------------------------- + */ +static herr_t +H5VL_pass_through_object_copy(void *src_obj, const H5VL_loc_params_t *src_loc_params, + const char *src_name, void *dst_obj, const H5VL_loc_params_t *dst_loc_params, + const char *dst_name, hid_t ocpypl_id, hid_t lcpl_id, hid_t dxpl_id, + void **req) +{ + H5VL_pass_through_t *o_src = (H5VL_pass_through_t *)src_obj; + H5VL_pass_through_t *o_dst = (H5VL_pass_through_t *)dst_obj; + herr_t ret_value; + +#ifdef ENABLE_PASSTHRU_LOGGING + printf("------- PASS THROUGH VOL OBJECT Copy\n"); +#endif + + ret_value = H5VLobject_copy(o_src->under_object, src_loc_params, src_name, o_dst->under_object, dst_loc_params, dst_name, o_src->under_vol_id, ocpypl_id, lcpl_id, dxpl_id, req); + + /* Check for async request */ + if(req && *req) + *req = H5VL_pass_through_new_obj(*req, o_src->under_vol_id); + + return ret_value; +} /* end H5VL_pass_through_object_copy() */ + + +/*------------------------------------------------------------------------- + * Function: H5VL_pass_through_object_get + * + * Purpose: Get info about an object + * + * Return: Success: 0 + * Failure: -1 + * + *------------------------------------------------------------------------- + */ +static herr_t +H5VL_pass_through_object_get(void *obj, const H5VL_loc_params_t *loc_params, H5VL_object_get_t get_type, hid_t dxpl_id, void **req, va_list arguments) +{ + H5VL_pass_through_t *o = (H5VL_pass_through_t *)obj; + herr_t ret_value; + +#ifdef ENABLE_PASSTHRU_LOGGING + printf("------- PASS THROUGH VOL OBJECT Get\n"); +#endif + + ret_value = H5VLobject_get(o->under_object, loc_params, o->under_vol_id, get_type, dxpl_id, req, arguments); + + /* Check for async request */ + if(req && *req) + *req = H5VL_pass_through_new_obj(*req, o->under_vol_id); + + return ret_value; +} /* end H5VL_pass_through_object_get() */ + + +/*------------------------------------------------------------------------- + * Function: H5VL_pass_through_object_specific + * + * Purpose: Specific operation on an object + * + * Return: Success: 0 + * Failure: -1 + * + *------------------------------------------------------------------------- + */ +static herr_t +H5VL_pass_through_object_specific(void *obj, const H5VL_loc_params_t *loc_params, + H5VL_object_specific_t specific_type, hid_t dxpl_id, void **req, + va_list arguments) +{ + H5VL_pass_through_t *o = (H5VL_pass_through_t *)obj; + herr_t ret_value; + +#ifdef ENABLE_PASSTHRU_LOGGING + printf("------- PASS THROUGH VOL OBJECT Specific\n"); +#endif + + ret_value = H5VLobject_specific(o->under_object, loc_params, o->under_vol_id, specific_type, dxpl_id, req, arguments); + + /* Check for async request */ + if(req && *req) + *req = H5VL_pass_through_new_obj(*req, o->under_vol_id); + + return ret_value; +} /* end H5VL_pass_through_object_specific() */ + + +/*------------------------------------------------------------------------- + * Function: H5VL_pass_through_object_optional + * + * Purpose: Perform a connector-specific operation for an object + * + * Return: Success: 0 + * Failure: -1 + * + *------------------------------------------------------------------------- + */ +static herr_t +H5VL_pass_through_object_optional(void *obj, hid_t dxpl_id, void **req, + va_list arguments) +{ + H5VL_pass_through_t *o = (H5VL_pass_through_t *)obj; + herr_t ret_value; + +#ifdef ENABLE_PASSTHRU_LOGGING + printf("------- PASS THROUGH VOL OBJECT Optional\n"); +#endif + + ret_value = H5VLobject_optional(o->under_object, o->under_vol_id, dxpl_id, req, arguments); + + /* Check for async request */ + if(req && *req) + *req = H5VL_pass_through_new_obj(*req, o->under_vol_id); + + return ret_value; +} /* end H5VL_pass_through_object_optional() */ + + +/*------------------------------------------------------------------------- + * Function: H5VL_pass_through_request_wait + * + * Purpose: Wait (with a timeout) for an async operation to complete + * + * Note: Releases the request if the operation has completed and the + * connector callback succeeds + * + * Return: Success: 0 + * Failure: -1 + * + *------------------------------------------------------------------------- + */ +static herr_t +H5VL_pass_through_request_wait(void *obj, uint64_t timeout, + H5ES_status_t *status) +{ + H5VL_pass_through_t *o = (H5VL_pass_through_t *)obj; + herr_t ret_value; + +#ifdef ENABLE_PASSTHRU_LOGGING + printf("------- PASS THROUGH VOL REQUEST Wait\n"); +#endif + + ret_value = H5VLrequest_wait(o->under_object, o->under_vol_id, timeout, status); + + if(ret_value >= 0 && *status != H5ES_STATUS_IN_PROGRESS) + H5VL_pass_through_free_obj(o); + + return ret_value; +} /* end H5VL_pass_through_request_wait() */ + + +/*------------------------------------------------------------------------- + * Function: H5VL_pass_through_request_notify + * + * Purpose: Registers a user callback to be invoked when an asynchronous + * operation completes + * + * Note: Releases the request, if connector callback succeeds + * + * Return: Success: 0 + * Failure: -1 + * + *------------------------------------------------------------------------- + */ +static herr_t +H5VL_pass_through_request_notify(void *obj, H5VL_request_notify_t cb, void *ctx) +{ + H5VL_pass_through_t *o = (H5VL_pass_through_t *)obj; + herr_t ret_value; + +#ifdef ENABLE_PASSTHRU_LOGGING + printf("------- PASS THROUGH VOL REQUEST Wait\n"); +#endif + + ret_value = H5VLrequest_notify(o->under_object, o->under_vol_id, cb, ctx); + + if(ret_value >= 0) + H5VL_pass_through_free_obj(o); + + return ret_value; +} /* end H5VL_pass_through_request_notify() */ + + +/*------------------------------------------------------------------------- + * Function: H5VL_pass_through_request_cancel + * + * Purpose: Cancels an asynchronous operation + * + * Note: Releases the request, if connector callback succeeds + * + * Return: Success: 0 + * Failure: -1 + * + *------------------------------------------------------------------------- + */ +static herr_t +H5VL_pass_through_request_cancel(void *obj) +{ + H5VL_pass_through_t *o = (H5VL_pass_through_t *)obj; + herr_t ret_value; + +#ifdef ENABLE_PASSTHRU_LOGGING + printf("------- PASS THROUGH VOL REQUEST Cancel\n"); +#endif + + ret_value = H5VLrequest_cancel(o->under_object, o->under_vol_id); + + if(ret_value >= 0) + H5VL_pass_through_free_obj(o); + + return ret_value; +} /* end H5VL_pass_through_request_cancel() */ + + +/*------------------------------------------------------------------------- + * Function: H5VL_pass_through_request_specific_reissue + * + * Purpose: Re-wrap vararg arguments into a va_list and reissue the + * request specific callback to the underlying VOL connector. + * + * Return: Success: 0 + * Failure: -1 + * + *------------------------------------------------------------------------- + */ +static herr_t +H5VL_pass_through_request_specific_reissue(void *obj, hid_t connector_id, + H5VL_request_specific_t specific_type, ...) +{ + va_list arguments; + herr_t ret_value; + + va_start(arguments, specific_type); + ret_value = H5VLrequest_specific(obj, connector_id, specific_type, arguments); + va_end(arguments); + + return ret_value; +} /* end H5VL_pass_through_request_specific_reissue() */ + + +/*------------------------------------------------------------------------- + * Function: H5VL_pass_through_request_specific + * + * Purpose: Specific operation on a request + * + * Return: Success: 0 + * Failure: -1 + * + *------------------------------------------------------------------------- + */ +static herr_t +H5VL_pass_through_request_specific(void *obj, H5VL_request_specific_t specific_type, + va_list arguments) +{ + herr_t ret_value = -1; + +#ifdef ENABLE_PASSTHRU_LOGGING + printf("------- PASS THROUGH VOL REQUEST Specific\n"); +#endif + + if(H5VL_REQUEST_WAITANY == specific_type || + H5VL_REQUEST_WAITSOME == specific_type || + H5VL_REQUEST_WAITALL == specific_type) { + va_list tmp_arguments; + size_t req_count; + + /* Sanity check */ + assert(obj == NULL); + + /* Get enough info to call the underlying connector */ + va_copy(tmp_arguments, arguments); + req_count = va_arg(tmp_arguments, size_t); + + /* Can only use a request to invoke the underlying VOL connector when there's >0 requests */ + if(req_count > 0) { + void **req_array; + void **under_req_array; + uint64_t timeout; + H5VL_pass_through_t *o; + size_t u; /* Local index variable */ + + /* Get the request array */ + req_array = va_arg(tmp_arguments, void **); + + /* Get a request to use for determining the underlying VOL connector */ + o = (H5VL_pass_through_t *)req_array[0]; + + /* Create array of underlying VOL requests */ + under_req_array = (void **)malloc(req_count * sizeof(void **)); + for(u = 0; u < req_count; u++) + under_req_array[u] = ((H5VL_pass_through_t *)req_array[u])->under_object; + + /* Remove the timeout value from the vararg list (it's used in all the calls below) */ + timeout = va_arg(tmp_arguments, uint64_t); + + /* Release requests that have completed */ + if(H5VL_REQUEST_WAITANY == specific_type) { + size_t *index; /* Pointer to the index of completed request */ + H5ES_status_t *status; /* Pointer to the request's status */ + + /* Retrieve the remaining arguments */ + index = va_arg(tmp_arguments, size_t *); + assert(*index <= req_count); + status = va_arg(tmp_arguments, H5ES_status_t *); + + /* Reissue the WAITANY 'request specific' call */ + ret_value = H5VL_pass_through_request_specific_reissue(o->under_object, o->under_vol_id, specific_type, req_count, under_req_array, timeout, index, status); + + /* Release the completed request, if it completed */ + if(ret_value >= 0 && *status != H5ES_STATUS_IN_PROGRESS) { + H5VL_pass_through_t *tmp_o; + + tmp_o = (H5VL_pass_through_t *)req_array[*index]; + H5VL_pass_through_free_obj(tmp_o); + } /* end if */ + } /* end if */ + else if(H5VL_REQUEST_WAITSOME == specific_type) { + size_t *outcount; /* # of completed requests */ + unsigned *array_of_indices; /* Array of indices for completed requests */ + H5ES_status_t *array_of_statuses; /* Array of statuses for completed requests */ + + /* Retrieve the remaining arguments */ + outcount = va_arg(tmp_arguments, size_t *); + assert(*outcount <= req_count); + array_of_indices = va_arg(tmp_arguments, unsigned *); + array_of_statuses = va_arg(tmp_arguments, H5ES_status_t *); + + /* Reissue the WAITSOME 'request specific' call */ + ret_value = H5VL_pass_through_request_specific_reissue(o->under_object, o->under_vol_id, specific_type, req_count, under_req_array, timeout, outcount, array_of_indices, array_of_statuses); + + /* If any requests completed, release them */ + if(ret_value >= 0 && *outcount > 0) { + unsigned *idx_array; /* Array of indices of completed requests */ + + /* Retrieve the array of completed request indices */ + idx_array = va_arg(tmp_arguments, unsigned *); + + /* Release the completed requests */ + for(u = 0; u < *outcount; u++) { + H5VL_pass_through_t *tmp_o; + + tmp_o = (H5VL_pass_through_t *)req_array[idx_array[u]]; + H5VL_pass_through_free_obj(tmp_o); + } /* end for */ + } /* end if */ + } /* end else-if */ + else { /* H5VL_REQUEST_WAITALL == specific_type */ + H5ES_status_t *array_of_statuses; /* Array of statuses for completed requests */ + + /* Retrieve the remaining arguments */ + array_of_statuses = va_arg(tmp_arguments, H5ES_status_t *); + + /* Reissue the WAITALL 'request specific' call */ + ret_value = H5VL_pass_through_request_specific_reissue(o->under_object, o->under_vol_id, specific_type, req_count, under_req_array, timeout, array_of_statuses); + + /* Release the completed requests */ + if(ret_value >= 0) { + for(u = 0; u < req_count; u++) { + if(array_of_statuses[u] != H5ES_STATUS_IN_PROGRESS) { + H5VL_pass_through_t *tmp_o; + + tmp_o = (H5VL_pass_through_t *)req_array[u]; + H5VL_pass_through_free_obj(tmp_o); + } /* end if */ + } /* end for */ + } /* end if */ + } /* end else */ + + /* Release array of requests for underlying connector */ + free(under_req_array); + } /* end if */ + + /* Finish use of copied vararg list */ + va_end(tmp_arguments); + } /* end if */ + else + assert(0 && "Unknown 'specific' operation"); + + return ret_value; +} /* end H5VL_pass_through_request_specific() */ + + +/*------------------------------------------------------------------------- + * Function: H5VL_pass_through_request_optional + * + * Purpose: Perform a connector-specific operation for a request + * + * Return: Success: 0 + * Failure: -1 + * + *------------------------------------------------------------------------- + */ +static herr_t +H5VL_pass_through_request_optional(void *obj, va_list arguments) +{ + H5VL_pass_through_t *o = (H5VL_pass_through_t *)obj; + herr_t ret_value; + +#ifdef ENABLE_PASSTHRU_LOGGING + printf("------- PASS THROUGH VOL REQUEST Optional\n"); +#endif + + ret_value = H5VLrequest_optional(o->under_object, o->under_vol_id, arguments); + + return ret_value; +} /* end H5VL_pass_through_request_optional() */ + + +/*------------------------------------------------------------------------- + * Function: H5VL_pass_through_request_free + * + * Purpose: Releases a request, allowing the operation to complete without + * application tracking + * + * Return: Success: 0 + * Failure: -1 + * + *------------------------------------------------------------------------- + */ +static herr_t +H5VL_pass_through_request_free(void *obj) +{ + H5VL_pass_through_t *o = (H5VL_pass_through_t *)obj; + herr_t ret_value; + +#ifdef ENABLE_PASSTHRU_LOGGING + printf("------- PASS THROUGH VOL REQUEST Free\n"); +#endif + + ret_value = H5VLrequest_free(o->under_object, o->under_vol_id); + + if(ret_value >= 0) + H5VL_pass_through_free_obj(o); + + return ret_value; +} /* end H5VL_pass_through_request_free() */ + diff --git a/src/H5VLpassthru.h b/src/H5VLpassthru.h new file mode 100644 index 0000000..e640636 --- /dev/null +++ b/src/H5VLpassthru.h @@ -0,0 +1,46 @@ +/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * + * 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 COPYING file, which can be found at the root of the source code * + * distribution tree, or in https://support.hdfgroup.org/ftp/HDF5/releases. * + * If you do not have access to either file, you may request a copy from * + * help@hdfgroup.org. * + * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ + +/* + * Purpose: The public header file for the pass-through VOL connector. + */ + +#ifndef _H5VLpassthru_H +#define _H5VLpassthru_H + +/* Identifier for the pass-through VOL connector */ +#define H5VL_PASSTHRU (H5VL_pass_through_register()) + +/* Characteristics of the pass-through VOL connector */ +#define H5VL_PASSTHRU_NAME "pass_through" +#define H5VL_PASSTHRU_VALUE 505 /* VOL connector ID */ +#define H5VL_PASSTHRU_VERSION 0 + +/* Pass-through VOL connector info */ +typedef struct H5VL_pass_through_info_t { + hid_t under_vol_id; /* VOL ID for under VOL */ + void *under_vol_info; /* VOL info for under VOL */ +} H5VL_pass_through_info_t; + + +#ifdef __cplusplus +extern "C" { +#endif + +H5_DLL hid_t H5VL_pass_through_register(void); + +#ifdef __cplusplus +} +#endif + +#endif /* _H5VLpassthru_H */ + diff --git a/src/H5VLprivate.h b/src/H5VLprivate.h index 003e6f5..ef5a81e 100644 --- a/src/H5VLprivate.h +++ b/src/H5VLprivate.h @@ -26,39 +26,50 @@ /* Library Private Typedefs */ /****************************/ -/* Internal struct to track VOL driver information for objects */ +/* Internal struct to track VOL connector information for objects */ typedef struct H5VL_t { - const H5VL_class_t *cls; /* Pointer to driver class struct */ + const H5VL_class_t *cls; /* Pointer to connector class struct */ int64_t nrefs; /* Number of references by objects using this struct */ - hid_t id; /* Identifier for the VOL driver */ + hid_t id; /* Identifier for the VOL connector */ } H5VL_t; /* Internal vol object structure returned to the API */ typedef struct H5VL_object_t { - void *data; /* Pointer to driver-managed data for this object */ - H5VL_t *driver; /* Pointer to VOL driver struct */ + void *data; /* Pointer to connector-managed data for this object */ + H5VL_t *connector; /* Pointer to VOL connector struct */ } H5VL_object_t; -/* Internal structure to hold the driver ID & info for FAPLs */ -typedef struct H5VL_driver_prop_t { - hid_t driver_id; /* VOL driver's ID */ - const void *driver_info; /* VOL driver info, for open callbacks */ -} H5VL_driver_prop_t; +/* Internal structure to hold the connector ID & info for FAPLs */ +typedef struct H5VL_connector_prop_t { + hid_t connector_id; /* VOL connector's ID */ + const void *connector_info; /* VOL connector info, for open callbacks */ +} H5VL_connector_prop_t; + +/* Which kind of VOL connector field to use for searching */ +typedef enum H5VL_get_connector_kind_t { + H5VL_GET_CONNECTOR_BY_NAME, /* Name field is set */ + H5VL_GET_CONNECTOR_BY_VALUE /* Value field is set */ +} H5VL_get_connector_kind_t; + /*****************************/ /* Library Private Variables */ /*****************************/ + /******************************/ /* Library Private Prototypes */ /******************************/ /* Utility functions */ H5_DLL herr_t H5VL_init(void); +H5_DLL herr_t H5VL_cmp_connector_cls(int *cmp_value, const H5VL_class_t *cls1, const H5VL_class_t *cls2); +H5_DLL herr_t H5VL_conn_copy(H5VL_connector_prop_t *value); +H5_DLL herr_t H5VL_conn_free(const H5VL_connector_prop_t *info); -/* Functions that deal with VOL drivers */ -H5_DLL hid_t H5VL_register_driver(const void *cls, size_t size, hbool_t app_ref); -H5_DLL ssize_t H5VL_get_driver_name(hid_t id, char *name/*out*/, size_t size); +/* Functions that deal with VOL connectors */ +H5_DLL hid_t H5VL_register_connector(const void *cls, hbool_t app_ref, hid_t vipl_id); +H5_DLL ssize_t H5VL_get_connector_name(hid_t id, char *name/*out*/, size_t size); /* NOTE: The object and ID functions below deal in VOL objects (i.e.; * H5VL_object_t). Similar non-VOL calls exist in H5Iprivate.h. Use @@ -72,78 +83,103 @@ H5_DLL ssize_t H5VL_get_driver_name(hid_t id, char *name/*out*/, size_t size); /* Functions that manipulate VOL objects */ H5_DLL void *H5VL_object(hid_t id); +H5_DLL void *H5VL_object_data(const H5VL_object_t *vol_obj); H5_DLL void *H5VL_object_verify(hid_t id, H5I_type_t obj_type); -H5_DLL void *H5VL_driver_data(H5VL_object_t *obj); H5_DLL H5VL_object_t *H5VL_vol_object(hid_t id); H5_DLL herr_t H5VL_free_object(H5VL_object_t *obj); +/* Functions that wrap / unwrap VOL objects */ +H5_DLL herr_t H5VL_get_wrap_ctx(const H5VL_class_t *connector, void *obj, + void **wrap_ctx); +H5_DLL herr_t H5VL_free_wrap_ctx(const H5VL_class_t *connector, void *wrap_ctx); +H5_DLL herr_t H5VL_set_vol_wrapper(void *obj, const H5VL_t *vol_connector); +H5_DLL herr_t H5VL_reset_vol_wrapper(void); +H5_DLL void * H5VL_wrap_object(const H5VL_class_t *connector, void *wrap_ctx, + void *obj); + /* ID registration functions */ -H5_DLL hid_t H5VL_register(H5I_type_t type, const void *object, H5VL_t *vol_driver, hbool_t app_ref); -H5_DLL hid_t H5VL_register_using_vol_id(H5I_type_t type, const void *obj, hid_t driver_id, hbool_t app_ref); -H5_DLL herr_t H5VL_register_using_existing_id(H5I_type_t type, void *object, H5VL_t *vol_driver, hbool_t app_ref, hid_t existing_id); +H5_DLL hid_t H5VL_register(H5I_type_t type, void *object, H5VL_t *vol_connector, hbool_t app_ref); +H5_DLL hid_t H5VL_wrap_register(H5I_type_t type, void *obj, hbool_t app_ref); +H5_DLL hid_t H5VL_register_using_vol_id(H5I_type_t type, void *obj, hid_t connector_id, hbool_t app_ref); +H5_DLL herr_t H5VL_register_using_existing_id(H5I_type_t type, void *object, H5VL_t *vol_connector, hbool_t app_ref, hid_t existing_id); + +/********************************** + * VOL connector callback wrappers + *********************************/ + +/* Connector "management" functions */ +H5_DLL int H5VL_copy_connector_info(const H5VL_class_t *connector, void **dst_info, + const void *src_info); +H5_DLL herr_t H5VL_cmp_connector_info(const H5VL_class_t *connector, int *cmp_value, + const void *info1, const void *info2); +H5_DLL herr_t H5VL_free_connector_info(const H5VL_class_t *connector, void *info); /* Attribute functions */ -H5_DLL void *H5VL_attr_create(void *obj, H5VL_loc_params_t loc_params, const H5VL_class_t *cls, const char *attr_name, hid_t acpl_id, hid_t aapl_id, hid_t dxpl_id, void **req); -H5_DLL void *H5VL_attr_open(void *obj, H5VL_loc_params_t loc_params, const H5VL_class_t *cls, const char *name, hid_t aapl_id, hid_t dxpl_id, void **req); -H5_DLL herr_t H5VL_attr_read(void *attr, const H5VL_class_t *cls, hid_t dtype_id, void *buf, hid_t dxpl_id, void **req); -H5_DLL herr_t H5VL_attr_write(void *attr, const H5VL_class_t *cls, hid_t dtype_id, const void *buf, hid_t dxpl_id, void **req); -H5_DLL herr_t H5VL_attr_get(void *obj, const H5VL_class_t *cls, H5VL_attr_get_t get_type, hid_t dxpl_id, void **req, ...); -H5_DLL herr_t H5VL_attr_specific(void *obj, H5VL_loc_params_t loc_params, const H5VL_class_t *cls, H5VL_attr_specific_t specific_type, hid_t dxpl_id, void **req, ...); -H5_DLL herr_t H5VL_attr_optional(void *obj, const H5VL_class_t *cls, hid_t dxpl_id, void **req, ...); -H5_DLL herr_t H5VL_attr_close(void *attr, const H5VL_class_t *cls, hid_t dxpl_id, void **req); +H5_DLL void *H5VL_attr_create(const H5VL_object_t *vol_obj, const H5VL_loc_params_t *loc_params, const char *attr_name, hid_t acpl_id, hid_t aapl_id, hid_t dxpl_id, void **req); +H5_DLL void *H5VL_attr_open(const H5VL_object_t *vol_obj, const H5VL_loc_params_t *loc_params, const char *name, hid_t aapl_id, hid_t dxpl_id, void **req); +H5_DLL herr_t H5VL_attr_read(const H5VL_object_t *vol_obj, hid_t dtype_id, void *buf, hid_t dxpl_id, void **req); +H5_DLL herr_t H5VL_attr_write(const H5VL_object_t *vol_obj, hid_t dtype_id, const void *buf, hid_t dxpl_id, void **req); +H5_DLL herr_t H5VL_attr_get(const H5VL_object_t *vol_obj, H5VL_attr_get_t get_type, hid_t dxpl_id, void **req, ...); +H5_DLL herr_t H5VL_attr_specific(const H5VL_object_t *vol_obj, const H5VL_loc_params_t *loc_params, H5VL_attr_specific_t specific_type, hid_t dxpl_id, void **req, ...); +H5_DLL herr_t H5VL_attr_optional(const H5VL_object_t *vol_obj, hid_t dxpl_id, void **req, ...); +H5_DLL herr_t H5VL_attr_close(const H5VL_object_t *vol_obj, hid_t dxpl_id, void **req); /* Dataset functions */ -H5_DLL void *H5VL_dataset_create(void *obj, H5VL_loc_params_t loc_params, const H5VL_class_t *cls, const char *name, hid_t dcpl_id, hid_t dapl_id, hid_t dxpl_id, void **req); -H5_DLL void *H5VL_dataset_open(void *obj, H5VL_loc_params_t loc_params, const H5VL_class_t *cls, const char *name, hid_t dapl_id, hid_t dxpl_id, void **req); -H5_DLL herr_t H5VL_dataset_read(void *dset, const H5VL_class_t *cls, hid_t mem_type_id, hid_t mem_space_id, hid_t file_space_id, hid_t plist_id, void *buf, void **req); -H5_DLL herr_t H5VL_dataset_write(void *dset, const H5VL_class_t *cls, hid_t mem_type_id, hid_t mem_space_id, hid_t file_space_id, hid_t plist_id, const void *buf, void **req); -H5_DLL herr_t H5VL_dataset_get(void *dset, const H5VL_class_t *cls, H5VL_dataset_get_t get_type, hid_t dxpl_id, void **req, ...); -H5_DLL herr_t H5VL_dataset_specific(void *obj, const H5VL_class_t *cls, H5VL_dataset_specific_t specific_type, hid_t dxpl_id, void **req, ...); -H5_DLL herr_t H5VL_dataset_optional(void *obj, const H5VL_class_t *cls, hid_t dxpl_id, void **req, ...); -H5_DLL herr_t H5VL_dataset_close(void *dset, const H5VL_class_t *cls, hid_t dxpl_id, void **req); +H5_DLL void *H5VL_dataset_create(const H5VL_object_t *vol_obj, const H5VL_loc_params_t *loc_params, const char *name, hid_t dcpl_id, hid_t dapl_id, hid_t dxpl_id, void **req); +H5_DLL void *H5VL_dataset_open(const H5VL_object_t *vol_obj, const H5VL_loc_params_t *loc_params, const char *name, hid_t dapl_id, hid_t dxpl_id, void **req); +H5_DLL herr_t H5VL_dataset_read(const H5VL_object_t *vol_obj, hid_t mem_type_id, hid_t mem_space_id, hid_t file_space_id, hid_t plist_id, void *buf, void **req); +H5_DLL herr_t H5VL_dataset_write(const H5VL_object_t *vol_obj, hid_t mem_type_id, hid_t mem_space_id, hid_t file_space_id, hid_t plist_id, const void *buf, void **req); +H5_DLL herr_t H5VL_dataset_get(const H5VL_object_t *vol_obj, H5VL_dataset_get_t get_type, hid_t dxpl_id, void **req, ...); +H5_DLL herr_t H5VL_dataset_specific(const H5VL_object_t *cls, H5VL_dataset_specific_t specific_type, hid_t dxpl_id, void **req, ...); +H5_DLL herr_t H5VL_dataset_optional(const H5VL_object_t *vol_obj, hid_t dxpl_id, void **req, ...); +H5_DLL herr_t H5VL_dataset_close(const H5VL_object_t *vol_obj, hid_t dxpl_id, void **req); /* File functions */ -H5_DLL void *H5VL_file_create(const H5VL_class_t *cls, const char *name, unsigned flags, hid_t fcpl_id, hid_t fapl_id, hid_t dxpl_id, void **req); -H5_DLL void *H5VL_file_open(const H5VL_class_t *cls, const char *name, unsigned flags, hid_t fapl_id, hid_t dxpl_id, void **req); -H5_DLL herr_t H5VL_file_get(void *file, const H5VL_class_t *cls, H5VL_file_get_t get_type, hid_t dxpl_id, void **req, ...); -H5_DLL herr_t H5VL_file_specific(void *obj, const H5VL_class_t *cls, H5VL_file_specific_t specific_type, hid_t dxpl_id, void **req, ...); -H5_DLL herr_t H5VL_file_optional(void *obj, const H5VL_class_t *cls, hid_t dxpl_id, void **req, ...); -H5_DLL herr_t H5VL_file_close(void *file, const H5VL_class_t *cls, hid_t dxpl_id, void **req); +H5_DLL void *H5VL_file_create(const H5VL_connector_prop_t *connector_prop, const char *name, unsigned flags, hid_t fcpl_id, hid_t fapl_id, hid_t dxpl_id, void **req); +H5_DLL void *H5VL_file_open(const H5VL_connector_prop_t *connector_prop, const char *name, unsigned flags, hid_t fapl_id, hid_t dxpl_id, void **req); +H5_DLL herr_t H5VL_file_get(const H5VL_object_t *vol_obj, H5VL_file_get_t get_type, hid_t dxpl_id, void **req, ...); +H5_DLL herr_t H5VL_file_specific(const H5VL_object_t *vol_obj, H5VL_file_specific_t specific_type, hid_t dxpl_id, void **req, ...); +H5_DLL herr_t H5VL_file_optional(const H5VL_object_t *vol_obj, hid_t dxpl_id, void **req, ...); +H5_DLL herr_t H5VL_file_close(const H5VL_object_t *vol_obj, hid_t dxpl_id, void **req); /* Group functions */ -H5_DLL void *H5VL_group_create(void *obj, H5VL_loc_params_t loc_params, const H5VL_class_t *cls, const char *name, hid_t gcpl_id, hid_t gapl_id, hid_t dxpl_id, void **req); -H5_DLL void *H5VL_group_open(void *obj, H5VL_loc_params_t loc_params, const H5VL_class_t *cls, const char *name, hid_t gapl_id, hid_t dxpl_id, void **req); -H5_DLL herr_t H5VL_group_get(void *obj, const H5VL_class_t *cls, H5VL_group_get_t get_type, hid_t dxpl_id, void **req, ...); -H5_DLL herr_t H5VL_group_specific(void *obj, const H5VL_class_t *cls, H5VL_group_specific_t specific_type, hid_t dxpl_id, void **req, ...); -H5_DLL herr_t H5VL_group_optional(void *obj, const H5VL_class_t *cls, hid_t dxpl_id, void **req, ...); -H5_DLL herr_t H5VL_group_close(void *grp, const H5VL_class_t *cls, hid_t dxpl_id, void **req); +H5_DLL void *H5VL_group_create(const H5VL_object_t *vol_obj, const H5VL_loc_params_t *loc_params, const char *name, hid_t gcpl_id, hid_t gapl_id, hid_t dxpl_id, void **req); +H5_DLL void *H5VL_group_open(const H5VL_object_t *vol_obj, const H5VL_loc_params_t *loc_params, const char *name, hid_t gapl_id, hid_t dxpl_id, void **req); +H5_DLL herr_t H5VL_group_get(const H5VL_object_t *vol_obj, H5VL_group_get_t get_type, hid_t dxpl_id, void **req, ...); +H5_DLL herr_t H5VL_group_specific(const H5VL_object_t *vol_obj, H5VL_group_specific_t specific_type, hid_t dxpl_id, void **req, ...); +H5_DLL herr_t H5VL_group_optional(const H5VL_object_t *vol_obj, hid_t dxpl_id, void **req, ...); +H5_DLL herr_t H5VL_group_close(const H5VL_object_t *vol_obj, hid_t dxpl_id, void **req); /* Link functions */ -H5_DLL herr_t H5VL_link_create(H5VL_link_create_type_t create_type, void *obj, H5VL_loc_params_t loc_params, const H5VL_class_t *cls, hid_t lcpl_id, hid_t lapl_id, hid_t dxpl_id, void **req); -H5_DLL herr_t H5VL_link_copy(void *src_obj, H5VL_loc_params_t loc_params1, void *dst_obj, H5VL_loc_params_t loc_params2, const H5VL_class_t *cls, hid_t lcpl_id, hid_t lapl_id, hid_t dxpl_id, void **req); -H5_DLL herr_t H5VL_link_move(void *src_obj, H5VL_loc_params_t loc_params1, void *dst_obj, H5VL_loc_params_t loc_params2, const H5VL_class_t *cls, hid_t lcpl_id, hid_t lapl_id, hid_t dxpl_id, void **req); -H5_DLL herr_t H5VL_link_get(void *obj, H5VL_loc_params_t loc_params, const H5VL_class_t *cls, H5VL_link_get_t get_type, hid_t dxpl_id, void **req, ...); -H5_DLL herr_t H5VL_link_specific(void *obj, H5VL_loc_params_t loc_params, const H5VL_class_t *cls, H5VL_link_specific_t specific_type, hid_t dxpl_id, void **req, ...); -H5_DLL herr_t H5VL_link_optional(void *obj, const H5VL_class_t *cls, hid_t dxpl_id, void **req, ...); +H5_DLL herr_t H5VL_link_create(H5VL_link_create_type_t create_type, const H5VL_object_t *vol_obj, const H5VL_loc_params_t *loc_params, hid_t lcpl_id, hid_t lapl_id, hid_t dxpl_id, void **req); +H5_DLL herr_t H5VL_link_copy(const H5VL_object_t *src_vol_obj, const H5VL_loc_params_t *loc_params1, const H5VL_object_t *dst_vol_obj, const H5VL_loc_params_t *loc_params2, hid_t lcpl_id, hid_t lapl_id, hid_t dxpl_id, void **req); +H5_DLL herr_t H5VL_link_move(const H5VL_object_t *src_vol_obj, const H5VL_loc_params_t *loc_params1, const H5VL_object_t *dst_vol_obj, const H5VL_loc_params_t *loc_params2, hid_t lcpl_id, hid_t lapl_id, hid_t dxpl_id, void **req); +H5_DLL herr_t H5VL_link_get(const H5VL_object_t *vol_obj, const H5VL_loc_params_t *loc_params, H5VL_link_get_t get_type, hid_t dxpl_id, void **req, ...); +H5_DLL herr_t H5VL_link_specific(const H5VL_object_t *vol_obj, const H5VL_loc_params_t *loc_params, H5VL_link_specific_t specific_type, hid_t dxpl_id, void **req, ...); +H5_DLL herr_t H5VL_link_optional(const H5VL_object_t *vol_obj, hid_t dxpl_id, void **req, ...); /* Object functions */ -H5_DLL void *H5VL_object_open(void *obj, H5VL_loc_params_t loc_params, const H5VL_class_t *cls, H5I_type_t *opened_type, hid_t dxpl_id, void **req); -H5_DLL herr_t H5VL_object_copy(void *src_obj, H5VL_loc_params_t loc_params1, const H5VL_class_t *cls1, const char *src_name, void *dst_obj, H5VL_loc_params_t loc_params2, const H5VL_class_t *cls2, const char *dst_name, hid_t ocpypl_id, hid_t lcpl_id, hid_t dxpl_id, void **req); -H5_DLL herr_t H5VL_object_get(void *obj, H5VL_loc_params_t loc_params, const H5VL_class_t *cls, H5VL_object_get_t get_type, hid_t dxpl_id, void **req, ...); -H5_DLL herr_t H5VL_object_specific(void *obj, H5VL_loc_params_t loc_params, const H5VL_class_t *cls, H5VL_object_specific_t specific_type, hid_t dxpl_id, void **req, ...); -H5_DLL herr_t H5VL_object_optional(void *obj, const H5VL_class_t *cls, hid_t dxpl_id, void **req, ...); +H5_DLL void *H5VL_object_open(const H5VL_object_t *vol_obj, const H5VL_loc_params_t *params, H5I_type_t *opened_type, hid_t dxpl_id, void **req); +H5_DLL herr_t H5VL_object_copy(const H5VL_object_t *src_obj, const H5VL_loc_params_t *src_loc_params, const char *src_name, const H5VL_object_t *dst_obj, const H5VL_loc_params_t *dst_loc_params, const char *dst_name, hid_t ocpypl_id, hid_t lcpl_id, hid_t dxpl_id, void **req); +H5_DLL herr_t H5VL_object_get(const H5VL_object_t *vol_obj, const H5VL_loc_params_t *loc_params, H5VL_object_get_t get_type, hid_t dxpl_id, void **req, ...); +H5_DLL herr_t H5VL_object_specific(const H5VL_object_t *vol_obj, const H5VL_loc_params_t *loc_params, H5VL_object_specific_t specific_type, hid_t dxpl_id, void **req, ...); +H5_DLL herr_t H5VL_object_optional(const H5VL_object_t *vol_obj, hid_t dxpl_id, void **req, ...); /* Datatype functions */ -H5_DLL void *H5VL_datatype_commit(void *obj, H5VL_loc_params_t loc_params, const H5VL_class_t *cls, 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); -H5_DLL void *H5VL_datatype_open(void *obj, H5VL_loc_params_t loc_params, const H5VL_class_t *cls, const char *name, hid_t tapl_id, hid_t dxpl_id, void **req); -H5_DLL herr_t H5VL_datatype_get(void *dt, const H5VL_class_t *cls, H5VL_datatype_get_t get_type, hid_t dxpl_id, void **req, ...); -H5_DLL herr_t H5VL_datatype_specific(void *obj, const H5VL_class_t *cls, H5VL_datatype_specific_t specific_type, hid_t dxpl_id, void **req, ...); -H5_DLL herr_t H5VL_datatype_optional(void *obj, const H5VL_class_t *cls, hid_t dxpl_id, void **req, ...); -H5_DLL herr_t H5VL_datatype_close(void *dt, const H5VL_class_t *cls, hid_t dxpl_id, void **req); +H5_DLL void *H5VL_datatype_commit(const H5VL_object_t *vol_obj, const 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); +H5_DLL void *H5VL_datatype_open(const H5VL_object_t *vol_obj, const H5VL_loc_params_t *loc_params, const char *name, hid_t tapl_id, hid_t dxpl_id, void **req); +H5_DLL herr_t H5VL_datatype_get(const H5VL_object_t *vol_obj, H5VL_datatype_get_t get_type, hid_t dxpl_id, void **req, ...); +H5_DLL herr_t H5VL_datatype_specific(const H5VL_object_t *vol_obj, H5VL_datatype_specific_t specific_type, hid_t dxpl_id, void **req, ...); +H5_DLL herr_t H5VL_datatype_optional(const H5VL_object_t *vol_obj, hid_t dxpl_id, void **req, ...); +H5_DLL herr_t H5VL_datatype_close(const H5VL_object_t *vol_obj, hid_t dxpl_id, void **req); /* Asynchronous functions */ -H5_DLL herr_t H5VL_request_cancel(void **req, const H5VL_class_t *cls, H5ES_status_t *status); -H5_DLL herr_t H5VL_request_test(void **req, const H5VL_class_t *cls, H5ES_status_t *status); -H5_DLL herr_t H5VL_request_wait(void **req, const H5VL_class_t *cls, H5ES_status_t *status); +H5_DLL herr_t H5VL_request_wait(const H5VL_object_t *vol_obj, uint64_t timeout, H5ES_status_t *status); +H5_DLL herr_t H5VL_request_notify(const H5VL_object_t *vol_obj, H5VL_request_notify_t cb, void *ctx); +H5_DLL herr_t H5VL_request_cancel(const H5VL_object_t *vol_obj); +H5_DLL herr_t H5VL_request_specific(const H5VL_object_t *vol_obj, H5VL_request_specific_t specific_type, ...); +H5_DLL herr_t H5VL_request_optional(const H5VL_object_t *vol_obj, ...); +H5_DLL herr_t H5VL_request_free(const H5VL_object_t *vol_obj); + #endif /* _H5VLprivate_H */ diff --git a/src/H5VLpublic.h b/src/H5VLpublic.h index 600de0d..22cf12b 100644 --- a/src/H5VLpublic.h +++ b/src/H5VLpublic.h @@ -52,7 +52,7 @@ /* Group creation property names */ #define H5VL_PROP_GRP_LCPL_ID "group_lcpl_id" -/* Default VOL driver value */ +/* Default VOL connector value */ #define H5VL_VOL_DEFAULT 0 @@ -112,19 +112,19 @@ typedef enum H5VL_datatype_specific_t { typedef enum H5VL_file_get_t { H5VL_FILE_GET_FAPL, /* file access property list */ H5VL_FILE_GET_FCPL, /* file creation property list */ - H5VL_FILE_GET_INTENT, /* file intent */ + H5VL_FILE_GET_INTENT, /* file intent */ H5VL_FILE_GET_NAME, /* file name */ H5VL_FILE_GET_OBJ_COUNT, /* object count in file */ - H5VL_FILE_GET_OBJ_IDS, /* object ids in file */ - H5VL_OBJECT_GET_FILE /* retrieve or resurrect file of object */ + H5VL_FILE_GET_OBJ_IDS /* object ids in file */ } H5VL_file_get_t; /* types for file SPECIFIC callback */ typedef enum H5VL_file_specific_t { H5VL_FILE_FLUSH, /* Flush file */ - H5VL_FILE_IS_ACCESSIBLE, /* Check if a file is accessible */ + H5VL_FILE_REOPEN, /* Reopen the file */ H5VL_FILE_MOUNT, /* Mount a file */ - H5VL_FILE_UNMOUNT /* Un-Mount a file */ + H5VL_FILE_UNMOUNT, /* Unmount a file */ + H5VL_FILE_IS_ACCESSIBLE /* Check if a file is accessible */ } H5VL_file_specific_t; /* types for group GET callback */ @@ -162,21 +162,29 @@ typedef enum H5VL_link_specific_t { /* types for object GET callback */ typedef enum H5VL_object_get_t { - H5VL_REF_GET_NAME, /* object name */ + H5VL_REF_GET_NAME, /* object name, for reference */ H5VL_REF_GET_REGION, /* dataspace of region */ - H5VL_REF_GET_TYPE /* type of object */ + H5VL_REF_GET_TYPE, /* type of object */ + H5VL_ID_GET_NAME /* object name, for hid_t */ } H5VL_object_get_t; /* types for object SPECIFIC callback */ typedef enum H5VL_object_specific_t { - H5VL_OBJECT_CHANGE_REF_COUNT, /* H5Oincr/decr_refcount */ - H5VL_OBJECT_EXISTS, /* H5Oexists_by_name */ - H5VL_OBJECT_VISIT, /* H5Ovisit(_by_name) */ - H5VL_REF_CREATE, /* H5Rcreate */ - H5VL_OBJECT_FLUSH, - H5VL_OBJECT_REFRESH + H5VL_OBJECT_CHANGE_REF_COUNT, /* H5Oincr/decr_refcount */ + H5VL_OBJECT_EXISTS, /* H5Oexists_by_name */ + H5VL_OBJECT_VISIT, /* H5Ovisit(_by_name) */ + H5VL_REF_CREATE, /* H5Rcreate */ + H5VL_OBJECT_FLUSH, /* H5{D|G|O|T}flush */ + H5VL_OBJECT_REFRESH /* H5{D|G|O|T}refresh */ } H5VL_object_specific_t; +/* types for async request SPECIFIC callback */ +typedef enum H5VL_request_specific_t { + H5VL_REQUEST_WAITANY, /* Wait until any request completes */ + H5VL_REQUEST_WAITSOME, /* Wait until at least one requesst completes */ + H5VL_REQUEST_WAITALL /* Wait until all requests complete */ +} H5VL_request_specific_t; + /* types for different ways that objects are located in an HDF5 container */ typedef enum H5VL_loc_type_t { H5VL_OBJECT_BY_SELF, @@ -229,14 +237,14 @@ typedef struct H5VL_loc_params_t { /* H5A routines */ typedef struct H5VL_attr_class_t { - void *(*create)(void *obj, H5VL_loc_params_t loc_params, const char *attr_name, + void *(*create)(void *obj, const H5VL_loc_params_t *loc_params, const char *attr_name, hid_t acpl_id, hid_t aapl_id, hid_t dxpl_id, void **req); - void *(*open)(void *obj, H5VL_loc_params_t loc_params, const char *attr_name, + void *(*open)(void *obj, const H5VL_loc_params_t *loc_params, const char *attr_name, hid_t aapl_id, hid_t dxpl_id, void **req); herr_t (*read)(void *attr, hid_t mem_type_id, void *buf, hid_t dxpl_id, void **req); herr_t (*write)(void *attr, hid_t mem_type_id, const void *buf, hid_t dxpl_id, void **req); herr_t (*get)(void *obj, H5VL_attr_get_t get_type, hid_t dxpl_id, void **req, va_list arguments); - herr_t (*specific)(void *obj, H5VL_loc_params_t loc_params, H5VL_attr_specific_t specific_type, + herr_t (*specific)(void *obj, const H5VL_loc_params_t *loc_params, H5VL_attr_specific_t specific_type, hid_t dxpl_id, void **req, va_list arguments); herr_t (*optional)(void *obj, hid_t dxpl_id, void **req, va_list arguments); herr_t (*close) (void *attr, hid_t dxpl_id, void **req); @@ -244,9 +252,9 @@ typedef struct H5VL_attr_class_t { /* H5D routines */ typedef struct H5VL_dataset_class_t { - void *(*create)(void *obj, H5VL_loc_params_t loc_params, const char *name, + void *(*create)(void *obj, const H5VL_loc_params_t *loc_params, const char *name, hid_t dcpl_id, hid_t dapl_id, hid_t dxpl_id, void **req); - void *(*open)(void *obj, H5VL_loc_params_t loc_params, const char *name, + void *(*open)(void *obj, const H5VL_loc_params_t *loc_params, const char *name, hid_t dapl_id, hid_t dxpl_id, void **req); herr_t (*read)(void *dset, hid_t mem_type_id, hid_t mem_space_id, hid_t file_space_id, hid_t xfer_plist_id, void * buf, void **req); @@ -261,9 +269,9 @@ typedef struct H5VL_dataset_class_t { /* H5T routines*/ typedef struct H5VL_datatype_class_t { - void *(*commit)(void *obj, H5VL_loc_params_t loc_params, const char *name, hid_t type_id, + void *(*commit)(void *obj, const 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); - void *(*open)(void *obj, H5VL_loc_params_t loc_params, const char * name, + void *(*open)(void *obj, const H5VL_loc_params_t *loc_params, const char * name, hid_t tapl_id, hid_t dxpl_id, void **req); herr_t (*get) (void *obj, H5VL_datatype_get_t get_type, hid_t dxpl_id, void **req, va_list arguments); herr_t (*specific)(void *obj, H5VL_datatype_specific_t specific_type, @@ -286,9 +294,9 @@ typedef struct H5VL_file_class_t { /* H5G routines */ typedef struct H5VL_group_class_t { - void *(*create)(void *obj, H5VL_loc_params_t loc_params, const char *name, + void *(*create)(void *obj, const H5VL_loc_params_t *loc_params, const char *name, hid_t gcpl_id, hid_t gapl_id, hid_t dxpl_id, void **req); - void *(*open)(void *obj, H5VL_loc_params_t loc_params, const char *name, + void *(*open)(void *obj, const H5VL_loc_params_t *loc_params, const char *name, hid_t gapl_id, hid_t dxpl_id, void **req); herr_t (*get)(void *obj, H5VL_group_get_t get_type, hid_t dxpl_id, void **req, va_list arguments); herr_t (*specific)(void *obj, H5VL_group_specific_t specific_type, @@ -299,86 +307,84 @@ typedef struct H5VL_group_class_t { /* H5L routines */ typedef struct H5VL_link_class_t { - herr_t (*create)(H5VL_link_create_type_t create_type, void *obj, H5VL_loc_params_t loc_params, + herr_t (*create)(H5VL_link_create_type_t create_type, void *obj, const H5VL_loc_params_t *loc_params, hid_t lcpl_id, hid_t lapl_id, hid_t dxpl_id, void **req); - herr_t (*copy)(void *src_obj, H5VL_loc_params_t loc_params1, - void *dst_obj, H5VL_loc_params_t loc_params2, + herr_t (*copy)(void *src_obj, const H5VL_loc_params_t *loc_params1, + void *dst_obj, const H5VL_loc_params_t *loc_params2, hid_t lcpl, hid_t lapl, hid_t dxpl_id, void **req); - herr_t (*move)(void *src_obj, H5VL_loc_params_t loc_params1, - void *dst_obj, H5VL_loc_params_t loc_params2, + herr_t (*move)(void *src_obj, const H5VL_loc_params_t *loc_params1, + void *dst_obj, const H5VL_loc_params_t *loc_params2, hid_t lcpl, hid_t lapl, hid_t dxpl_id, void **req); - herr_t (*get)(void *obj, H5VL_loc_params_t loc_params, H5VL_link_get_t get_type, + herr_t (*get)(void *obj, const H5VL_loc_params_t *loc_params, H5VL_link_get_t get_type, hid_t dxpl_id, void **req, va_list arguments); - herr_t (*specific)(void *obj, H5VL_loc_params_t loc_params, H5VL_link_specific_t specific_type, + herr_t (*specific)(void *obj, const H5VL_loc_params_t *loc_params, H5VL_link_specific_t specific_type, hid_t dxpl_id, void **req, va_list arguments); herr_t (*optional)(void *obj, hid_t dxpl_id, void **req, va_list arguments); } H5VL_link_class_t; /* H5O routines */ typedef struct H5VL_object_class_t { - void *(*open)(void *obj, H5VL_loc_params_t loc_params, H5I_type_t *opened_type, + void *(*open)(void *obj, const H5VL_loc_params_t *loc_params, H5I_type_t *opened_type, hid_t dxpl_id, void **req); - herr_t (*copy)(void *src_obj, H5VL_loc_params_t loc_params1, const char *src_name, - void *dst_obj, H5VL_loc_params_t loc_params2, const char *dst_name, + herr_t (*copy)(void *src_obj, const H5VL_loc_params_t *loc_params1, const char *src_name, + void *dst_obj, const H5VL_loc_params_t *loc_params2, const char *dst_name, hid_t ocpypl_id, hid_t lcpl_id, hid_t dxpl_id, void **req); - herr_t (*get)(void *obj, H5VL_loc_params_t loc_params, H5VL_object_get_t get_type, + herr_t (*get)(void *obj, const H5VL_loc_params_t *loc_params, H5VL_object_get_t get_type, hid_t dxpl_id, void **req, va_list arguments); - herr_t (*specific)(void *obj, H5VL_loc_params_t loc_params, H5VL_object_specific_t specific_type, + herr_t (*specific)(void *obj, const H5VL_loc_params_t *loc_params, H5VL_object_specific_t specific_type, hid_t dxpl_id, void **req, va_list arguments); herr_t (*optional)(void *obj, hid_t dxpl_id, void **req, va_list arguments); } H5VL_object_class_t; -/* H5AO routines */ -typedef struct H5VL_async_class_t { - herr_t (*cancel)(void **, H5ES_status_t *); - herr_t (*test) (void **, H5ES_status_t *); - herr_t (*wait) (void **, H5ES_status_t *); -} H5VL_async_class_t; - -/* VOL category (internal, external, etc.) - * XXX: This is intended to replace the H5VL_class_value_t struct, which seems - * difficult to manage. It's currently unused so I don't break struct - * compatibility with existing VOLs. - */ -typedef enum H5VL_category_t { - H5VL_INTERNAL, /* Internal VOL driver */ - H5VL_EXTERNAL /* External VOL driver (plugin) */ -} H5VL_category_t; - -/* enum value to identify the class of a VOL driver (mostly for comparison purposes) */ -typedef enum H5VL_class_value_t { - H5_VOL_NATIVE = 0, /* This should be first */ - H5_VOL_MAX_LIB_VALUE = 128 /* This should be last */ -} H5VL_class_value_t; - -/* Class information for each VOL driver */ -/* XXX: We should consider adding a UUID/GUID field to this struct - * as well as a H5VLregister_by_uuid() API call for people who - * really care about getting a particular VOL driver. - * XXX: We should also consider adding enough information so that - * files can be opened without specifying the VOL driver. - * e.g.: If we stored a UUID and version, we could search for - * a matching VOL driver so a user did not have to make any - * H5VL calls. +/* Asynchronous request 'notify' callback */ +typedef herr_t (*H5VL_request_notify_t)(void *ctx, H5ES_status_t status); + +/* Async request operation routines */ +typedef struct H5VL_request_class_t { + herr_t (*wait)(void *req, uint64_t timeout, H5ES_status_t *status); + herr_t (*notify)(void *req, H5VL_request_notify_t cb, void *ctx); + herr_t (*cancel)(void *req); + herr_t (*specific)(void *req, H5VL_request_specific_t specific_type, va_list arguments); + herr_t (*optional)(void *req, va_list arguments); + herr_t (*free)(void *req); +} H5VL_request_class_t; + +/* + * VOL connector identifiers. Values 0 through 255 are for connectors defined + * by the HDF5 library. Values 256 through 511 are available for testing new + * filters. Subsequent values should be obtained from the HDF5 development + * team at help@hdfgroup.org. */ +typedef int H5VL_class_value_t; + +/* VOL connector identifier values */ +#define H5_VOL_INVALID (-1) /* Invalid ID for VOL connector iD */ +#define H5_VOL_NATIVE 0 /* Native HDF5 file formnat VOL connector */ +#define H5_VOL_RESERVED 256 /* VOL connector IDs below this value are reserved for library use */ +#define H5_VOL_MAX 65535 /* Maximum VOL connector ID */ + +/* Capability flags for connector */ +#define H5VL_CAP_FLAG_NONE 0 /* No special connector capabilities */ +#define H5VL_CAP_FLAG_THREADSAFE 0x01 /* Connector is threadsafe */ + +/* Class information for each VOL connector */ typedef struct H5VL_class_t { - /* XXX: How do we identify unique VOL drivers? - * This is unclear, but for now we'll keep - * all the ID fields from the original VOL - * branch. - */ - unsigned int version; /* VOL driver version # - * XXX: Is this supposed to be a VOL driver - * version number or a VOL API version - * number? Maybe we need both? - */ - H5VL_class_value_t value; /* value to identify driver */ - const char *name; /* Plugin name (MUST be unique!) */ - herr_t (*initialize)(hid_t vipl_id); /* Plugin initialization callback */ - herr_t (*terminate)(hid_t vtpl_id); /* Plugin termination callback */ - size_t fapl_size; /* size of the vol info in the fapl property */ - void * (*fapl_copy)(const void *info); /* callback to create a copy of the vol info */ - herr_t (*fapl_free)(void *info); /* callback to release the vol info copy */ + unsigned int version; /* VOL connector class struct version # */ + H5VL_class_value_t value; /* Value to identify connector */ + const char *name; /* Connector name (MUST be unique!) */ + unsigned cap_flags; /* Capability flags for connector */ + herr_t (*initialize)(hid_t vipl_id); /* Connector initialization callback */ + herr_t (*terminate)(void); /* Connector termination callback */ + size_t info_size; /* Size of the VOL info */ + void * (*info_copy)(const void *info); /* Callback to create a copy of the VOL info */ + herr_t (*info_cmp)(int *cmp_value, const void *info1, const void *info2); /* Callback to compare VOL info */ + herr_t (*info_free)(void *info); /* Callback to release the VOL info copy */ + herr_t (*info_to_str)(const void *info, char **str); /* Callback to serialize connector's info into a string */ + herr_t (*str_to_info)(const char *str, void **info); /* Callback to deserialize a string into connector's info */ + void * (*get_object)(const void *obj); /* Callback to retrieve underlying object */ + herr_t (*get_wrap_ctx)(const void *obj, void **wrap_ctx); /* Callback to retrieve the object wrapping context for the connector */ + void* (*wrap_object)(void *obj, void *wrap_ctx); /* Callback to wrap a library object */ + herr_t (*free_wrap_ctx)(void *wrap_ctx); /* Callback to release the object wrapping context for the connector */ /* Data Model */ H5VL_attr_class_t attr_cls; /* attribute class callbacks */ @@ -390,7 +396,9 @@ typedef struct H5VL_class_t { H5VL_object_class_t object_cls; /* object class callbacks */ /* Services */ - H5VL_async_class_t async_cls; /* asynchronous class callbacks */ + H5VL_request_class_t request_cls; /* asynchronous request class callbacks */ + + /* Catch-all */ herr_t (*optional)(void *obj, hid_t dxpl_id, void **req, va_list arguments); /* Optional callback */ } H5VL_class_t; @@ -407,92 +415,118 @@ typedef struct H5VL_class_t { extern "C" { #endif -/* VOL Driver/Plugin Functionality */ -H5_DLL herr_t H5VLinitialize(hid_t driver_id, hid_t vipl_id); -H5_DLL herr_t H5VLterminate(hid_t driver_id, hid_t vtpl_id); -H5_DLL herr_t H5VLclose(hid_t driver_id); -H5_DLL hid_t H5VLregister_driver(const H5VL_class_t *cls); -H5_DLL hid_t H5VLregister_driver_by_name(const char *driver_name); -H5_DLL herr_t H5VLunregister_driver(hid_t driver_id); -H5_DLL htri_t H5VLis_driver_registered(const char *name); -H5_DLL hid_t H5VLget_driver_id(const char *name); -H5_DLL ssize_t H5VLget_driver_name(hid_t id, char *name/*out*/, size_t size); -H5_DLL hid_t H5VLregister(H5I_type_t obj_type, const void *obj, hid_t driver_id); -H5_DLL void *H5VLobject(hid_t id); -H5_DLL herr_t H5VLget_object(hid_t obj_id, void **obj); - -/* Attributes */ -H5_DLL void *H5VLattr_create(void *obj, H5VL_loc_params_t loc_params, hid_t driver_id, const char *attr_name, hid_t acpl_id, hid_t aapl_id, hid_t dxpl_id, void **req); -H5_DLL void *H5VLattr_open(void *obj, H5VL_loc_params_t loc_params, hid_t driver_id, const char *name, hid_t aapl_id, hid_t dxpl_id, void **req); -H5_DLL herr_t H5VLattr_read(void *attr, hid_t driver_id, hid_t dtype_id, void *buf, hid_t dxpl_id, void **req); -H5_DLL herr_t H5VLattr_write(void *attr, hid_t driver_id, hid_t dtype_id, const void *buf, hid_t dxpl_id, void **req); -H5_DLL herr_t H5VLattr_get(void *obj, hid_t driver_id, H5VL_attr_get_t get_type, hid_t dxpl_id, void **req, va_list arguments); -H5_DLL herr_t H5VLattr_specific(void *obj, H5VL_loc_params_t loc_params, hid_t driver_id, H5VL_attr_specific_t specific_type, hid_t dxpl_id, void **req, va_list arguments); -H5_DLL herr_t H5VLattr_optional(void *obj, hid_t driver_id, hid_t dxpl_id, void **req, va_list arguments); -H5_DLL herr_t H5VLattr_close(void *attr, hid_t driver_id, hid_t dxpl_id, void **req); - -/* Datasets */ -H5_DLL void *H5VLdataset_create(void *obj, H5VL_loc_params_t loc_params, hid_t driver_id, const char *name, hid_t dcpl_id, hid_t dapl_id, hid_t dxpl_id, void **req); -H5_DLL void *H5VLdataset_open(void *obj, H5VL_loc_params_t loc_params, hid_t driver_id, const char *name, hid_t dapl_id, hid_t dxpl_id, void **req); -H5_DLL herr_t H5VLdataset_read(void *dset, hid_t driver_id, hid_t mem_type_id, hid_t mem_space_id, hid_t file_space_id, hid_t plist_id, void *buf, void **req); -H5_DLL herr_t H5VLdataset_write(void *dset, hid_t driver_id, hid_t mem_type_id, hid_t mem_space_id, hid_t file_space_id, hid_t plist_id, const void *buf, void **req); -H5_DLL herr_t H5VLdataset_get(void *dset, hid_t driver_id, H5VL_dataset_get_t get_type, hid_t dxpl_id, void **req, va_list arguments); -H5_DLL herr_t H5VLdataset_specific(void *obj, hid_t driver_id, H5VL_dataset_specific_t specific_type, hid_t dxpl_id, void **req, va_list arguments); -H5_DLL herr_t H5VLdataset_optional(void *obj, hid_t driver_id, hid_t dxpl_id, void **req, va_list arguments); -H5_DLL herr_t H5VLdataset_close(void *dset, hid_t driver_id, hid_t dxpl_id, void **req); - -/* Files */ +/* VOL Connector Functionality */ +H5_DLL hid_t H5VLregister_connector(const H5VL_class_t *cls, hid_t vipl_id); +H5_DLL hid_t H5VLregister_connector_by_name(const char *connector_name, hid_t vipl_id); +H5_DLL hid_t H5VLregister_connector_by_value(H5VL_class_value_t connector_value, hid_t vipl_id); +H5_DLL htri_t H5VLis_connector_registered(const char *name); +H5_DLL hid_t H5VLget_connector_id(const char *name); +H5_DLL ssize_t H5VLget_connector_name(hid_t id, char *name/*out*/, size_t size); +H5_DLL herr_t H5VLclose(hid_t connector_id); +H5_DLL herr_t H5VLunregister_connector(hid_t connector_id); + + +/***************************************************************************** + * VOL callback wrappers and helper routines, for _VOL_connector_ authors only! * + * (Not part of the public API for _application_ developers) * + *****************************************************************************/ + +/* Helper routines for VOL connector authors */ +H5_DLL herr_t H5VLcmp_connector_cls(int *cmp, hid_t connector_id1, hid_t connector_id2); + + +/* Public wrappers for generic callbacks */ +H5_DLL herr_t H5VLinitialize(hid_t connector_id, hid_t vipl_id); +H5_DLL herr_t H5VLterminate(hid_t connector_id); +H5_DLL herr_t H5VLget_cap_flags(hid_t connector_id, unsigned *cap_flags); +H5_DLL herr_t H5VLget_value(hid_t connector_id, H5VL_class_value_t *conn_value); +H5_DLL herr_t H5VLcopy_connector_info(hid_t connector_id, void **dst_vol_info, void *src_vol_info); +H5_DLL herr_t H5VLcmp_connector_info(int *cmp, hid_t connector_id, const void *info1, + const void *info2); +H5_DLL herr_t H5VLfree_connector_info(hid_t connector_id, void *vol_info); +H5_DLL herr_t H5VLconnector_info_to_str(const void *info, hid_t connector_id, char **str); +H5_DLL herr_t H5VLconnector_str_to_info(const char *str, hid_t connector_id, void **info); +H5_DLL void *H5VLget_object(void *obj, hid_t connector_id); +H5_DLL herr_t H5VLget_wrap_ctx(void *obj, hid_t connector_id, void **wrap_ctx); +H5_DLL void *H5VLwrap_object(void *obj, hid_t connector_id, void *wrap_ctx); +H5_DLL herr_t H5VLfree_wrap_ctx(void *wrap_ctx, hid_t connector_id); + +/* Public wrappers for attribute callbacks */ +H5_DLL void *H5VLattr_create(void *obj, const H5VL_loc_params_t *loc_params, hid_t connector_id, const char *attr_name, hid_t acpl_id, hid_t aapl_id, hid_t dxpl_id, void **req); +H5_DLL void *H5VLattr_open(void *obj, const H5VL_loc_params_t *loc_params, hid_t connector_id, const char *name, hid_t aapl_id, hid_t dxpl_id, void **req); +H5_DLL herr_t H5VLattr_read(void *attr, hid_t connector_id, hid_t dtype_id, void *buf, hid_t dxpl_id, void **req); +H5_DLL herr_t H5VLattr_write(void *attr, hid_t connector_id, hid_t dtype_id, const void *buf, hid_t dxpl_id, void **req); +H5_DLL herr_t H5VLattr_get(void *obj, hid_t connector_id, H5VL_attr_get_t get_type, hid_t dxpl_id, void **req, va_list arguments); +H5_DLL herr_t H5VLattr_specific(void *obj, const H5VL_loc_params_t *loc_params, hid_t connector_id, H5VL_attr_specific_t specific_type, hid_t dxpl_id, void **req, va_list arguments); +H5_DLL herr_t H5VLattr_optional(void *obj, hid_t connector_id, hid_t dxpl_id, void **req, va_list arguments); +H5_DLL herr_t H5VLattr_close(void *attr, hid_t connector_id, hid_t dxpl_id, void **req); + +/* Public wrappers for dataset callbacks */ +H5_DLL void *H5VLdataset_create(void *obj, const H5VL_loc_params_t *loc_params, hid_t connector_id, const char *name, hid_t dcpl_id, hid_t dapl_id, hid_t dxpl_id, void **req); +H5_DLL void *H5VLdataset_open(void *obj, const H5VL_loc_params_t *loc_params, hid_t connector_id, const char *name, hid_t dapl_id, hid_t dxpl_id, void **req); +H5_DLL herr_t H5VLdataset_read(void *dset, hid_t connector_id, hid_t mem_type_id, hid_t mem_space_id, hid_t file_space_id, hid_t plist_id, void *buf, void **req); +H5_DLL herr_t H5VLdataset_write(void *dset, hid_t connector_id, hid_t mem_type_id, hid_t mem_space_id, hid_t file_space_id, hid_t plist_id, const void *buf, void **req); +H5_DLL herr_t H5VLdataset_get(void *dset, hid_t connector_id, H5VL_dataset_get_t get_type, hid_t dxpl_id, void **req, va_list arguments); +H5_DLL herr_t H5VLdataset_specific(void *obj, hid_t connector_id, H5VL_dataset_specific_t specific_type, hid_t dxpl_id, void **req, va_list arguments); +H5_DLL herr_t H5VLdataset_optional(void *obj, hid_t connector_id, hid_t dxpl_id, void **req, va_list arguments); +H5_DLL herr_t H5VLdataset_close(void *dset, hid_t connector_id, hid_t dxpl_id, void **req); + +/* Public wrappers for file callbacks */ H5_DLL void *H5VLfile_create(const char *name, unsigned flags, hid_t fcpl_id, hid_t fapl_id, hid_t dxpl_id, void **req); H5_DLL void *H5VLfile_open(const char *name, unsigned flags, hid_t fapl_id, hid_t dxpl_id, void **req); -H5_DLL herr_t H5VLfile_get(void *file, hid_t driver_id, H5VL_file_get_t get_type, hid_t dxpl_id, void **req, va_list arguments); -H5_DLL herr_t H5VLfile_specific(void *obj, hid_t driver_id, H5VL_file_specific_t specific_type, hid_t dxpl_id, void **req, va_list arguments); -H5_DLL herr_t H5VLfile_optional(void *obj, hid_t driver_id, hid_t dxpl_id, void **req, va_list arguments); -H5_DLL herr_t H5VLfile_close(void *file, hid_t driver_id, hid_t dxpl_id, void **req); - -/* Groups */ -H5_DLL void *H5VLgroup_create(void *obj, H5VL_loc_params_t loc_params, hid_t driver_id, const char *name, hid_t gcpl_id, hid_t gapl_id, hid_t dxpl_id, void **req); -H5_DLL void *H5VLgroup_open(void *obj, H5VL_loc_params_t loc_params, hid_t driver_id, const char *name, hid_t gapl_id, hid_t dxpl_id, void **req); -H5_DLL herr_t H5VLgroup_get(void *obj, hid_t driver_id, H5VL_group_get_t get_type, hid_t dxpl_id, void **req, va_list arguments); -H5_DLL herr_t H5VLgroup_specific(void *obj, hid_t driver_id, H5VL_group_specific_t specific_type, hid_t dxpl_id, void **req, va_list arguments); -H5_DLL herr_t H5VLgroup_optional(void *obj, hid_t driver_id, hid_t dxpl_id, void **req, va_list arguments); -H5_DLL herr_t H5VLgroup_close(void *grp, hid_t driver_id, hid_t dxpl_id, void **req); - -/* Links */ -H5_DLL herr_t H5VLlink_create(H5VL_link_create_type_t create_type, void *obj, H5VL_loc_params_t loc_params, hid_t driver_id, hid_t lcpl_id, hid_t lapl_id, hid_t dxpl_id, void **req); -H5_DLL herr_t H5VLlink_copy(void *src_obj, H5VL_loc_params_t loc_params1, - void *dst_obj, H5VL_loc_params_t loc_params2, hid_t driver_id, +H5_DLL herr_t H5VLfile_get(void *file, hid_t connector_id, H5VL_file_get_t get_type, hid_t dxpl_id, void **req, va_list arguments); +H5_DLL herr_t H5VLfile_specific(void *obj, hid_t connector_id, H5VL_file_specific_t specific_type, hid_t dxpl_id, void **req, va_list arguments); +H5_DLL herr_t H5VLfile_optional(void *obj, hid_t connector_id, hid_t dxpl_id, void **req, va_list arguments); +H5_DLL herr_t H5VLfile_close(void *file, hid_t connector_id, hid_t dxpl_id, void **req); + +/* Public wrappers for group callbacks */ +H5_DLL void *H5VLgroup_create(void *obj, const H5VL_loc_params_t *loc_params, hid_t connector_id, const char *name, hid_t gcpl_id, hid_t gapl_id, hid_t dxpl_id, void **req); +H5_DLL void *H5VLgroup_open(void *obj, const H5VL_loc_params_t *loc_params, hid_t connector_id, const char *name, hid_t gapl_id, hid_t dxpl_id, void **req); +H5_DLL herr_t H5VLgroup_get(void *obj, hid_t connector_id, H5VL_group_get_t get_type, hid_t dxpl_id, void **req, va_list arguments); +H5_DLL herr_t H5VLgroup_specific(void *obj, hid_t connector_id, H5VL_group_specific_t specific_type, hid_t dxpl_id, void **req, va_list arguments); +H5_DLL herr_t H5VLgroup_optional(void *obj, hid_t connector_id, hid_t dxpl_id, void **req, va_list arguments); +H5_DLL herr_t H5VLgroup_close(void *grp, hid_t connector_id, hid_t dxpl_id, void **req); + +/* Public wrappers for link callbacks */ +H5_DLL herr_t H5VLlink_create(H5VL_link_create_type_t create_type, void *obj, const H5VL_loc_params_t *loc_params, hid_t connector_id, hid_t lcpl_id, hid_t lapl_id, hid_t dxpl_id, void **req); +H5_DLL herr_t H5VLlink_copy(void *src_obj, const H5VL_loc_params_t *loc_params1, + void *dst_obj, const H5VL_loc_params_t *loc_params2, hid_t connector_id, hid_t lcpl_id, hid_t lapl_id, hid_t dxpl_id, void **req); -H5_DLL herr_t H5VLlink_move(void *src_obj, H5VL_loc_params_t loc_params1, - void *dst_obj, H5VL_loc_params_t loc_params2, hid_t driver_id, +H5_DLL herr_t H5VLlink_move(void *src_obj, const H5VL_loc_params_t *loc_params1, + void *dst_obj, const H5VL_loc_params_t *loc_params2, hid_t connector_id, hid_t lcpl_id, hid_t lapl_id, hid_t dxpl_id, void **req); -H5_DLL herr_t H5VLlink_get(void *obj, H5VL_loc_params_t loc_params, hid_t driver_id, H5VL_link_get_t get_type, hid_t dxpl_id, void **req, va_list arguments); -H5_DLL herr_t H5VLlink_specific(void *obj, H5VL_loc_params_t loc_params, hid_t driver_id, H5VL_link_specific_t specific_type, hid_t dxpl_id, void **req, va_list arguments); -H5_DLL herr_t H5VLlink_optional(void *obj, hid_t driver_id, hid_t dxpl_id, void **req, va_list arguments); - -/* Objects */ -H5_DLL void *H5VLobject_open(void *obj, H5VL_loc_params_t loc_params, hid_t driver_id, H5I_type_t *opened_type, hid_t dxpl_id, void **req); -H5_DLL herr_t H5VLobject_copy(void *src_obj, H5VL_loc_params_t loc_params1, hid_t driver_id1, const char *src_name, - void *dst_obj, H5VL_loc_params_t loc_params2, hid_t driver_id2, const char *dst_name, - hid_t ocpypl_id, hid_t lcpl_id, hid_t dxpl_id, void **req); -H5_DLL herr_t H5VLobject_get(void *obj, H5VL_loc_params_t loc_params, hid_t driver_id, H5VL_object_get_t get_type, hid_t dxpl_id, void **req, va_list arguments); -H5_DLL herr_t H5VLobject_specific(void *obj, H5VL_loc_params_t loc_params, hid_t driver_id, H5VL_object_specific_t specific_type, hid_t dxpl_id, void **req, va_list arguments); -H5_DLL herr_t H5VLobject_optional(void *obj, hid_t driver_id, hid_t dxpl_id, void **req, va_list arguments); - -/* Datatypes */ -H5_DLL void *H5VLdatatype_commit(void *obj, H5VL_loc_params_t loc_params, hid_t driver_id, 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); -H5_DLL void *H5VLdatatype_open(void *obj, H5VL_loc_params_t loc_params, hid_t driver_id, const char *name, hid_t tapl_id, hid_t dxpl_id, void **req); -H5_DLL herr_t H5VLdatatype_get(void *dt, hid_t driver_id, H5VL_datatype_get_t get_type, hid_t dxpl_id, void **req, va_list arguments); -H5_DLL herr_t H5VLdatatype_specific(void *obj, hid_t driver_id, H5VL_datatype_specific_t specific_type, hid_t dxpl_id, void **req, va_list arguments); -H5_DLL herr_t H5VLdatatype_optional(void *obj, hid_t driver_id, hid_t dxpl_id, void **req, va_list arguments); -H5_DLL herr_t H5VLdatatype_close(void *dt, hid_t driver_id, hid_t dxpl_id, void **req); - -/* Asynchronous Requests */ -H5_DLL herr_t H5VLrequest_cancel(void **req, hid_t driver_id, H5ES_status_t *status); -H5_DLL herr_t H5VLrequest_test(void **req, hid_t driver_id, H5ES_status_t *status); -H5_DLL herr_t H5VLrequest_wait(void **req, hid_t driver_id, H5ES_status_t *status); +H5_DLL herr_t H5VLlink_get(void *obj, const H5VL_loc_params_t *loc_params, hid_t connector_id, H5VL_link_get_t get_type, hid_t dxpl_id, void **req, va_list arguments); +H5_DLL herr_t H5VLlink_specific(void *obj, const H5VL_loc_params_t *loc_params, hid_t connector_id, H5VL_link_specific_t specific_type, hid_t dxpl_id, void **req, va_list arguments); +H5_DLL herr_t H5VLlink_optional(void *obj, hid_t connector_id, hid_t dxpl_id, void **req, va_list arguments); + +/* Public wrappers for object callbacks */ +H5_DLL void *H5VLobject_open(void *obj, const H5VL_loc_params_t *loc_params, hid_t connector_id, H5I_type_t *opened_type, hid_t dxpl_id, void **req); +H5_DLL herr_t H5VLobject_copy(void *src_obj, const H5VL_loc_params_t *loc_params1, const char *src_name, + void *dst_obj, const H5VL_loc_params_t *loc_params2, const char *dst_name, + hid_t connector_id, hid_t ocpypl_id, hid_t lcpl_id, hid_t dxpl_id, void **req); +H5_DLL herr_t H5VLobject_get(void *obj, const H5VL_loc_params_t *loc_params, hid_t connector_id, H5VL_object_get_t get_type, hid_t dxpl_id, void **req, va_list arguments); +H5_DLL herr_t H5VLobject_specific(void *obj, const H5VL_loc_params_t *loc_params, hid_t connector_id, H5VL_object_specific_t specific_type, hid_t dxpl_id, void **req, va_list arguments); +H5_DLL herr_t H5VLobject_optional(void *obj, hid_t connector_id, hid_t dxpl_id, void **req, va_list arguments); + +/* Public wrappers for named datatype callbacks */ +H5_DLL void *H5VLdatatype_commit(void *obj, const H5VL_loc_params_t *loc_params, hid_t connector_id, 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); +H5_DLL void *H5VLdatatype_open(void *obj, const H5VL_loc_params_t *loc_params, hid_t connector_id, const char *name, hid_t tapl_id, hid_t dxpl_id, void **req); +H5_DLL herr_t H5VLdatatype_get(void *dt, hid_t connector_id, H5VL_datatype_get_t get_type, hid_t dxpl_id, void **req, va_list arguments); +H5_DLL herr_t H5VLdatatype_specific(void *obj, hid_t connector_id, H5VL_datatype_specific_t specific_type, hid_t dxpl_id, void **req, va_list arguments); +H5_DLL herr_t H5VLdatatype_optional(void *obj, hid_t connector_id, hid_t dxpl_id, void **req, va_list arguments); +H5_DLL herr_t H5VLdatatype_close(void *dt, hid_t connector_id, hid_t dxpl_id, void **req); + +/* Public wrappers for asynchronous request callbacks */ +H5_DLL herr_t H5VLrequest_wait(void *req, hid_t connector_id, uint64_t timeout, H5ES_status_t *status); +H5_DLL herr_t H5VLrequest_notify(void *req, hid_t connector_id, H5VL_request_notify_t cb, void *ctx); +H5_DLL herr_t H5VLrequest_cancel(void *req, hid_t connector_id); +H5_DLL herr_t H5VLrequest_specific(void *req, hid_t connector_id, H5VL_request_specific_t specific_type, va_list arguments); +H5_DLL herr_t H5VLrequest_optional(void *req, hid_t connector_id, va_list arguments); +H5_DLL herr_t H5VLrequest_free(void *req, hid_t connector_id); #ifdef __cplusplus } #endif #endif /* _H5VLpublic_H */ + @@ -586,7 +586,9 @@ static int H5Z__flush_file_cb(void *obj_ptr, hid_t H5_ATTR_UNUSED obj_id, void *key) { H5F_t *f = (H5F_t *)obj_ptr; /* File object for operations */ +#ifdef H5_HAVE_PARALLEL H5Z_object_t *object = (H5Z_object_t *)key; +#endif /* H5_HAVE_PARALLEL */ int ret_value = FALSE; /* Return value */ FUNC_ENTER_STATIC @@ -695,11 +697,11 @@ H5Z_filter_avail(H5Z_filter_t id) HGOTO_DONE(TRUE) key.id = (int)id; - if (NULL != (filter_info = (const H5Z_class2_t *)H5PL_load(H5PL_TYPE_FILTER, key))) { - if (H5Z_register(filter_info) < 0) + if(NULL != (filter_info = (const H5Z_class2_t *)H5PL_load(H5PL_TYPE_FILTER, &key))) { + if(H5Z_register(filter_info) < 0) HGOTO_ERROR(H5E_PLINE, H5E_CANTINIT, FAIL, "unable to register loaded filter") HGOTO_DONE(TRUE) - } + } /* end if */ done: FUNC_LEAVE_NOAPI(ret_value) @@ -1287,7 +1289,7 @@ H5Z_pipeline(const H5O_pline_t *pline, unsigned flags, /* Try loading the filter */ key.id = (int)(pline->filter[idx].id); - if(NULL != (filter_info = (const H5Z_class2_t *)H5PL_load(H5PL_TYPE_FILTER, key))) { + if(NULL != (filter_info = (const H5Z_class2_t *)H5PL_load(H5PL_TYPE_FILTER, &key))) { /* Register the filter we loaded */ if(H5Z_register(filter_info) < 0) HGOTO_ERROR(H5E_PLINE, H5E_CANTINIT, FAIL, "unable to register filter") diff --git a/src/H5Zpublic.h b/src/H5Zpublic.h index 0df05f0..a2a44fa 100644 --- a/src/H5Zpublic.h +++ b/src/H5Zpublic.h @@ -25,7 +25,7 @@ * Filter identifiers. Values 0 through 255 are for filters defined by the * HDF5 library. Values 256 through 511 are available for testing new * filters. Subsequent values should be obtained from the HDF5 development - * team at hdf5dev@ncsa.uiuc.edu. These values will never change because they + * team at help@hdfgroup.org. These values will never change because they * appear in the HDF5 files. */ typedef int H5Z_filter_t; diff --git a/src/H5private.h b/src/H5private.h index 63f6858..f58faec 100644 --- a/src/H5private.h +++ b/src/H5private.h @@ -1393,6 +1393,9 @@ typedef off_t h5_stat_size_t; #ifndef HDstrtok #define HDstrtok(X,Y) strtok(X,Y) #endif /* HDstrtok */ +#ifndef HDstrtok_r + #define HDstrtok_r(X,Y,Z) strtok_r(X,Y,Z) +#endif /* HDstrtok */ #ifndef HDstrtol #define HDstrtol(S,R,N) strtol(S,R,N) #endif /* HDstrtol */ @@ -1495,6 +1498,9 @@ typedef off_t h5_stat_size_t; #ifndef HDva_arg #define HDva_arg(A,T) va_arg(A,T) #endif /* HDva_arg */ +#ifndef HDva_copy +#define HDva_copy(D,S) va_copy(D,S) +#endif /* HDva_copy */ #ifndef HDva_end #define HDva_end(A) va_end(A) #endif /* HDva_end */ @@ -2086,10 +2092,11 @@ H5_DLL herr_t H5CX_pop(void); /* * Use this macro for API functions that shouldn't perform _any_ initialization * of the library or an interface, just perform tracing, etc. Examples - * are: H5allocate_memory, H5is_library_threadsafe, etc. + * are: H5allocate_memory, H5is_library_threadsafe, public VOL callback + * wrappers (e.g. H5VLfile_create, H5VLdataset_read, etc.), etc. * */ -#define FUNC_ENTER_API_NOINIT {{ \ +#define FUNC_ENTER_API_NOINIT {{{ \ FUNC_ENTER_API_COMMON \ H5_PUSH_FUNC \ BEGIN_MPE_LOG \ @@ -2102,7 +2109,7 @@ H5_DLL herr_t H5CX_pop(void); * are: H5close, H5check_version, etc. * */ -#define FUNC_ENTER_API_NOINIT_NOERR_NOFS {{ \ +#define FUNC_ENTER_API_NOINIT_NOERR_NOFS {{{{ \ FUNC_ENTER_API_VARS \ FUNC_ENTER_COMMON_NOERR(H5_IS_API(FUNC)); \ FUNC_ENTER_API_THREADSAFE; \ @@ -2289,14 +2296,14 @@ H5_DLL herr_t H5CX_pop(void); (void)H5E_dump_api_stack(TRUE); \ FUNC_LEAVE_API_THREADSAFE \ return(ret_value); \ -}} /*end scope from beginning of FUNC_ENTER*/ +}}} /*end scope from beginning of FUNC_ENTER*/ /* Use this macro to match the FUNC_ENTER_API_NOINIT_NOERR_NOFS macro */ #define FUNC_LEAVE_API_NOFS(ret_value) \ FUNC_LEAVE_API_COMMON(ret_value); \ FUNC_LEAVE_API_THREADSAFE \ return(ret_value); \ -}} /*end scope from beginning of FUNC_ENTER*/ +}}}} /*end scope from beginning of FUNC_ENTER*/ #define FUNC_LEAVE_NOAPI(ret_value) \ ; \ diff --git a/src/H5system.c b/src/H5system.c index 2d29650..f47d057 100644 --- a/src/H5system.c +++ b/src/H5system.c @@ -121,7 +121,7 @@ HDfprintf(FILE *stream, const char *fmt, ...) HDassert(stream); HDassert(fmt); - va_start (ap, fmt); + HDva_start (ap, fmt); while (*fmt) { fwidth = prec = 0; zerofill = 0; @@ -170,7 +170,7 @@ HDfprintf(FILE *stream, const char *fmt, ...) s = rest; } /* end if */ else if ('*'==*s) { - fwidth = va_arg(ap, int); + fwidth = HDva_arg(ap, int); if(fwidth < 0) { leftjust = 1; fwidth = -fwidth; @@ -185,7 +185,7 @@ HDfprintf(FILE *stream, const char *fmt, ...) prec = (int)HDstrtol(s, &rest, 10); s = rest; } else if('*'==*s) { - prec = va_arg(ap, int); + prec = HDva_arg(ap, int); s++; } if(prec < 1) @@ -272,16 +272,16 @@ HDfprintf(FILE *stream, const char *fmt, ...) case 'd': case 'i': if(!HDstrcmp(modifier, "h")) { - short x = (short)va_arg(ap, int); + short x = (short)HDva_arg(ap, int); n = fprintf(stream, format_templ, x); } else if(!*modifier) { - int x = va_arg(ap, int); + int x = HDva_arg(ap, int); n = fprintf(stream, format_templ, x); } else if(!HDstrcmp(modifier, "l")) { - long x = va_arg(ap, long); + long x = HDva_arg(ap, long); n = fprintf(stream, format_templ, x); } else { - int64_t x = va_arg(ap, int64_t); + int64_t x = HDva_arg(ap, int64_t); n = fprintf(stream, format_templ, x); } break; @@ -291,16 +291,16 @@ HDfprintf(FILE *stream, const char *fmt, ...) case 'x': case 'X': if(!HDstrcmp(modifier, "h")) { - unsigned short x = (unsigned short)va_arg(ap, unsigned int); + unsigned short x = (unsigned short)HDva_arg(ap, unsigned int); n = fprintf(stream, format_templ, x); } else if(!*modifier) { - unsigned int x = va_arg(ap, unsigned int); + unsigned int x = HDva_arg(ap, unsigned int); n = fprintf(stream, format_templ, x); } else if(!HDstrcmp(modifier, "l")) { - unsigned long x = va_arg(ap, unsigned long); + unsigned long x = HDva_arg(ap, unsigned long); n = fprintf(stream, format_templ, x); } else { - uint64_t x = va_arg(ap, uint64_t); + uint64_t x = HDva_arg(ap, uint64_t); n = fprintf(stream, format_templ, x); } break; @@ -311,10 +311,10 @@ HDfprintf(FILE *stream, const char *fmt, ...) case 'g': case 'G': if(!HDstrcmp(modifier, "h")) { - float x = (float)va_arg(ap, double); + float x = (float)HDva_arg(ap, double); n = fprintf(stream, format_templ, (double)x); } else if(!*modifier || !HDstrcmp(modifier, "l")) { - double x = va_arg(ap, double); + double x = HDva_arg(ap, double); n = fprintf(stream, format_templ, x); } else { /* @@ -322,10 +322,10 @@ HDfprintf(FILE *stream, const char *fmt, ...) * `double' are the same thing. */ #if H5_SIZEOF_LONG_DOUBLE != H5_SIZEOF_DOUBLE - long double x = va_arg(ap, long double); + long double x = HDva_arg(ap, long double); n = fprintf(stream, format_templ, x); #else - double x = va_arg(ap, double); + double x = HDva_arg(ap, double); n = fprintf(stream, format_templ, x); #endif } @@ -333,7 +333,7 @@ HDfprintf(FILE *stream, const char *fmt, ...) case 'a': { - haddr_t x = va_arg(ap, haddr_t); + haddr_t x = HDva_arg(ap, haddr_t); if(H5F_addr_defined(x)) { len = 0; @@ -379,7 +379,7 @@ HDfprintf(FILE *stream, const char *fmt, ...) case 'c': { - char x = (char)va_arg(ap, int); + char x = (char)HDva_arg(ap, int); n = fprintf(stream, format_templ, x); } break; @@ -387,7 +387,7 @@ HDfprintf(FILE *stream, const char *fmt, ...) case 's': case 'p': { - char *x = va_arg(ap, char*); + char *x = HDva_arg(ap, char*); n = fprintf(stream, format_templ, x); } break; @@ -399,7 +399,7 @@ HDfprintf(FILE *stream, const char *fmt, ...) case 't': { - htri_t tri_var = va_arg(ap, htri_t); + htri_t tri_var = HDva_arg(ap, htri_t); if(tri_var > 0) fprintf(stream, "TRUE"); @@ -423,7 +423,7 @@ HDfprintf(FILE *stream, const char *fmt, ...) nout++; } } - va_end(ap); + HDva_end(ap); return nout; } /* end HDfprintf() */ @@ -492,7 +492,8 @@ HDstrtoll(const char *s, const char **rest, int base) /* Optional minus or plus sign */ if ('+'==*s) { s++; - } else if ('-'==*s) { + } + else if ('-'==*s) { sign = -1; s++; } @@ -501,10 +502,12 @@ HDstrtoll(const char *s, const char **rest, int base) if (0==base && '0'==*s && ('x'==s[1] || 'X'==s[1])) { base = 16; s += 2; - } else if (0==base && '0'==*s) { + } + else if (0==base && '0'==*s) { base = 8; s++; - } else if (0==base) { + } + else if (0==base) { base = 10; } @@ -525,7 +528,8 @@ HDstrtoll(const char *s, const char **rest, int base) if (acc*base+digit < acc) { overflow = TRUE; - } else { + } + else { acc = acc*base + digit; } } @@ -536,7 +540,8 @@ HDstrtoll(const char *s, const char **rest, int base) if (overflow) { if (sign>0) { acc = ((uint64_t)1<<(8*sizeof(int64_t)-1))-1; - } else { + } + else { acc = (int64_t)((uint64_t)1<<(8*sizeof(int64_t)-1)); } errno = ERANGE; @@ -843,9 +848,9 @@ int c99_snprintf(char* str, size_t size, const char* format, ...) int count; va_list ap; - va_start(ap, format); + HDva_start(ap, format); count = c99_vsnprintf(str, size, format, ap); - va_end(ap); + HDva_end(ap); return count; } diff --git a/src/H5trace.c b/src/H5trace.c index 08db09a..9a13193 100644 --- a/src/H5trace.c +++ b/src/H5trace.c @@ -135,7 +135,7 @@ H5_trace(const double *returning, const char *func, const char *type, ...) if(!out) return 0.0F; /*tracing is off*/ - va_start(ap, type); + HDva_start(ap, type); if(H5_debug_g.ttop) { if(returning) { @@ -227,7 +227,7 @@ H5_trace(const double *returning, const char *func, const char *type, ...) * name is the null pointer then don't print the argument or the * following `='. This is used for return values. */ - argname = va_arg(ap, char *); + argname = HDva_arg(ap, char *); if(argname) { unsigned n = (unsigned)MAX (0, (int)HDstrlen(argname) - 3); @@ -243,7 +243,7 @@ H5_trace(const double *returning, const char *func, const char *type, ...) /* The value */ if(ptr) - vp = va_arg(ap, void *); + vp = HDva_arg(ap, void *); switch(type[0]) { case 'a': if(ptr) { @@ -253,7 +253,7 @@ H5_trace(const double *returning, const char *func, const char *type, ...) HDfprintf(out, "NULL"); } /* end if */ else { - haddr_t addr = va_arg(ap, haddr_t); + haddr_t addr = HDva_arg(ap, haddr_t); HDfprintf(out, "%a", addr); } /* end else */ @@ -267,8 +267,8 @@ H5_trace(const double *returning, const char *func, const char *type, ...) HDfprintf(out, "NULL"); } /* end if */ else { - /* Can't pass hbool_t to va_arg() */ - hbool_t bool_var = (hbool_t)va_arg(ap, int); + /* Can't pass hbool_t to HDva_arg() */ + hbool_t bool_var = (hbool_t)HDva_arg(ap, int); if(TRUE == bool_var) HDfprintf(out, "TRUE"); else if(!bool_var) @@ -286,7 +286,7 @@ H5_trace(const double *returning, const char *func, const char *type, ...) HDfprintf(out, "NULL"); } /* end if */ else { - double dbl = va_arg(ap, double); + double dbl = HDva_arg(ap, double); HDfprintf(out, "%g", dbl); } /* end else */ @@ -302,7 +302,7 @@ H5_trace(const double *returning, const char *func, const char *type, ...) HDfprintf(out, "NULL"); } /* end if */ else { - H5D_alloc_time_t alloc_time = (H5D_alloc_time_t)va_arg(ap, int); + H5D_alloc_time_t alloc_time = (H5D_alloc_time_t)HDva_arg(ap, int); switch(alloc_time) { case H5D_ALLOC_TIME_ERROR: @@ -340,7 +340,7 @@ H5_trace(const double *returning, const char *func, const char *type, ...) HDfprintf(out, "NULL"); } /* end if */ else { - H5FD_mpio_collective_opt_t opt = (H5FD_mpio_collective_opt_t)va_arg(ap, int); + H5FD_mpio_collective_opt_t opt = (H5FD_mpio_collective_opt_t)HDva_arg(ap, int); switch(opt) { case H5FD_MPIO_COLLECTIVE_IO: @@ -366,7 +366,7 @@ H5_trace(const double *returning, const char *func, const char *type, ...) HDfprintf(out, "NULL"); } /* end if */ else { - H5D_fill_time_t fill_time = (H5D_fill_time_t)va_arg(ap, int); + H5D_fill_time_t fill_time = (H5D_fill_time_t)HDva_arg(ap, int); switch(fill_time) { case H5D_FILL_TIME_ERROR: @@ -400,7 +400,7 @@ H5_trace(const double *returning, const char *func, const char *type, ...) HDfprintf(out, "NULL"); } /* end if */ else { - H5D_fill_value_t fill_value = (H5D_fill_value_t)va_arg(ap, int); + H5D_fill_value_t fill_value = (H5D_fill_value_t)HDva_arg(ap, int); switch(fill_value) { case H5D_FILL_VALUE_ERROR: @@ -434,7 +434,7 @@ H5_trace(const double *returning, const char *func, const char *type, ...) HDfprintf(out, "NULL"); } /* end if */ else { - H5FD_mpio_chunk_opt_t opt = (H5FD_mpio_chunk_opt_t)va_arg(ap, int); + H5FD_mpio_chunk_opt_t opt = (H5FD_mpio_chunk_opt_t)HDva_arg(ap, int); switch(opt) { case H5FD_MPIO_CHUNK_DEFAULT: @@ -464,7 +464,7 @@ H5_trace(const double *returning, const char *func, const char *type, ...) HDfprintf(out, "NULL"); } /* end if */ else { - H5D_mpio_actual_io_mode_t actual_io_mode = (H5D_mpio_actual_io_mode_t)va_arg(ap, int); + H5D_mpio_actual_io_mode_t actual_io_mode = (H5D_mpio_actual_io_mode_t)HDva_arg(ap, int); switch(actual_io_mode) { case H5D_MPIO_NO_COLLECTIVE: @@ -502,7 +502,7 @@ H5_trace(const double *returning, const char *func, const char *type, ...) HDfprintf(out, "NULL"); } /* end if */ else { - H5D_chunk_index_t idx = (H5D_chunk_index_t)va_arg(ap, int); + H5D_chunk_index_t idx = (H5D_chunk_index_t)HDva_arg(ap, int); switch(idx) { case H5D_CHUNK_IDX_BTREE: @@ -548,7 +548,7 @@ H5_trace(const double *returning, const char *func, const char *type, ...) HDfprintf(out, "NULL"); } /* end if */ else { - H5D_layout_t layout = (H5D_layout_t)va_arg(ap, int); + H5D_layout_t layout = (H5D_layout_t)HDva_arg(ap, int); switch(layout) { case H5D_LAYOUT_ERROR: @@ -590,7 +590,7 @@ H5_trace(const double *returning, const char *func, const char *type, ...) HDfprintf(out, "NULL"); } /* end if */ else { - H5D_mpio_no_collective_cause_t nocol_cause_mode = (H5D_mpio_no_collective_cause_t)va_arg(ap, int); + H5D_mpio_no_collective_cause_t nocol_cause_mode = (H5D_mpio_no_collective_cause_t)HDva_arg(ap, int); hbool_t flag_already_displayed = FALSE; /* Check for all bit-flags which might be set */ @@ -637,7 +637,7 @@ H5_trace(const double *returning, const char *func, const char *type, ...) HDfprintf(out, "NULL"); } /* end if */ else { - H5D_mpio_actual_chunk_opt_mode_t chunk_opt_mode = (H5D_mpio_actual_chunk_opt_mode_t)va_arg(ap, int); + H5D_mpio_actual_chunk_opt_mode_t chunk_opt_mode = (H5D_mpio_actual_chunk_opt_mode_t)HDva_arg(ap, int); switch(chunk_opt_mode) { case H5D_MPIO_NO_CHUNK_OPTIMIZATION: @@ -667,7 +667,7 @@ H5_trace(const double *returning, const char *func, const char *type, ...) HDfprintf(out, "NULL"); } /* end if */ else { - H5D_space_status_t space_status = (H5D_space_status_t)va_arg(ap, int); + H5D_space_status_t space_status = (H5D_space_status_t)HDva_arg(ap, int); switch(space_status) { case H5D_SPACE_STATUS_NOT_ALLOCATED: @@ -701,7 +701,7 @@ H5_trace(const double *returning, const char *func, const char *type, ...) HDfprintf(out, "NULL"); } /* end if */ else { - H5FD_mpio_xfer_t transfer = (H5FD_mpio_xfer_t)va_arg(ap, int); + H5FD_mpio_xfer_t transfer = (H5FD_mpio_xfer_t)HDva_arg(ap, int); switch(transfer) { case H5FD_MPIO_INDEPENDENT: @@ -727,7 +727,7 @@ H5_trace(const double *returning, const char *func, const char *type, ...) HDfprintf(out, "NULL"); } /* end if */ else { - H5D_vds_view_t view = (H5D_vds_view_t)va_arg(ap, int); + H5D_vds_view_t view = (H5D_vds_view_t)HDva_arg(ap, int); switch(view) { case H5D_VDS_ERROR: @@ -763,7 +763,7 @@ H5_trace(const double *returning, const char *func, const char *type, ...) HDfprintf(out, "NULL"); } /* end if */ else { - herr_t status = va_arg(ap, herr_t); + herr_t status = HDva_arg(ap, herr_t); if(status >= 0) HDfprintf(out, "SUCCEED"); @@ -782,7 +782,7 @@ H5_trace(const double *returning, const char *func, const char *type, ...) HDfprintf(out, "NULL"); } /* end if */ else { - H5E_direction_t direction = (H5E_direction_t)va_arg(ap, int); + H5E_direction_t direction = (H5E_direction_t)HDva_arg(ap, int); switch(direction) { case H5E_WALK_UPWARD: @@ -808,7 +808,7 @@ H5_trace(const double *returning, const char *func, const char *type, ...) HDfprintf(out, "NULL"); } /* end if */ else { - H5E_error2_t *error = va_arg(ap, H5E_error2_t *); + H5E_error2_t *error = HDva_arg(ap, H5E_error2_t *); HDfprintf(out, "0x%lx", (unsigned long)error); } /* end else */ @@ -822,7 +822,7 @@ H5_trace(const double *returning, const char *func, const char *type, ...) HDfprintf(out, "NULL"); } /* end if */ else { - H5ES_status_t status = (H5ES_status_t)va_arg(ap, int); + H5ES_status_t status = (H5ES_status_t)HDva_arg(ap, int); switch(status) { case H5ES_STATUS_IN_PROGRESS: @@ -834,8 +834,8 @@ H5_trace(const double *returning, const char *func, const char *type, ...) case H5ES_STATUS_FAIL: HDfprintf(out, "H5ES_STATUS_FAIL"); break; - case H5ES_STATUS_CANCEL: - HDfprintf(out, "H5ES_STATUS_CANCEL"); + case H5ES_STATUS_CANCELED: + HDfprintf(out, "H5ES_STATUS_CANCELED"); break; default: @@ -853,7 +853,7 @@ H5_trace(const double *returning, const char *func, const char *type, ...) HDfprintf(out, "NULL"); } /* end if */ else { - H5E_type_t etype = (H5E_type_t)va_arg(ap, int); + H5E_type_t etype = (H5E_type_t)HDva_arg(ap, int); switch(etype) { case H5E_MAJOR: @@ -887,7 +887,7 @@ H5_trace(const double *returning, const char *func, const char *type, ...) HDfprintf(out, "NULL"); } /* end if */ else { - H5F_close_degree_t degree = (H5F_close_degree_t)va_arg(ap, int); + H5F_close_degree_t degree = (H5F_close_degree_t)HDva_arg(ap, int); switch(degree) { case H5F_CLOSE_DEFAULT: @@ -921,7 +921,7 @@ H5_trace(const double *returning, const char *func, const char *type, ...) HDfprintf(out, "NULL"); } /* end if */ else { - H5F_fspace_strategy_t fs_strategy = (H5F_fspace_strategy_t)va_arg(ap, int); + H5F_fspace_strategy_t fs_strategy = (H5F_fspace_strategy_t)HDva_arg(ap, int); switch(fs_strategy) { case H5F_FSPACE_STRATEGY_FSM_AGGR: @@ -956,7 +956,7 @@ H5_trace(const double *returning, const char *func, const char *type, ...) HDfprintf(out, "NULL"); } /* end if */ else { - H5F_mem_t mem_type = (H5F_mem_t)va_arg(ap, int); + H5F_mem_t mem_type = (H5F_mem_t)HDva_arg(ap, int); switch(mem_type) { case H5FD_MEM_NOLIST: @@ -1007,7 +1007,7 @@ H5_trace(const double *returning, const char *func, const char *type, ...) HDfprintf(out, "NULL"); } /* end if */ else { - H5F_scope_t scope = (H5F_scope_t)va_arg(ap, int); + H5F_scope_t scope = (H5F_scope_t)HDva_arg(ap, int); switch(scope) { case H5F_SCOPE_LOCAL: @@ -1042,7 +1042,7 @@ H5_trace(const double *returning, const char *func, const char *type, ...) HDfprintf(out, "NULL"); } /* end if */ else { - H5F_libver_t libver_vers = (H5F_libver_t)va_arg(ap, int); + H5F_libver_t libver_vers = (H5F_libver_t)HDva_arg(ap, int); switch(libver_vers) { case H5F_LIBVER_EARLIEST: @@ -1084,7 +1084,7 @@ H5_trace(const double *returning, const char *func, const char *type, ...) HDfprintf(out, "NULL"); } /* end if */ else { - H5G_obj_t obj_type = (H5G_obj_t)va_arg(ap, int); + H5G_obj_t obj_type = (H5G_obj_t)HDva_arg(ap, int); switch(obj_type) { case H5G_UNKNOWN: @@ -1132,7 +1132,7 @@ H5_trace(const double *returning, const char *func, const char *type, ...) HDfprintf(out, "NULL"); } /* end if */ else { - H5G_stat_t *statbuf = va_arg(ap, H5G_stat_t*); + H5G_stat_t *statbuf = HDva_arg(ap, H5G_stat_t*); HDfprintf(out, "0x%lx", (unsigned long)statbuf); } @@ -1166,7 +1166,7 @@ H5_trace(const double *returning, const char *func, const char *type, ...) HDfprintf(out, "NULL"); } /* end if */ else { - hsize_t hsize = va_arg(ap, hsize_t); + hsize_t hsize = HDva_arg(ap, hsize_t); if(H5S_UNLIMITED == hsize) HDfprintf(out, "H5S_UNLIMITED"); @@ -1196,7 +1196,7 @@ H5_trace(const double *returning, const char *func, const char *type, ...) HDfprintf(out, "NULL"); } /* end if */ else { - hssize_t hssize = va_arg(ap, hssize_t); + hssize_t hssize = HDva_arg(ap, hssize_t); HDfprintf(out, "%Hd", hssize); asize[argno] = (hssize_t)hssize; @@ -1217,7 +1217,7 @@ H5_trace(const double *returning, const char *func, const char *type, ...) HDfprintf(out, "NULL"); } /* end if */ else { - hid_t obj = va_arg(ap, hid_t); + hid_t obj = HDva_arg(ap, hid_t); if(H5P_DEFAULT == obj) HDfprintf(out, "H5P_DEFAULT"); @@ -1355,10 +1355,6 @@ H5_trace(const double *returning, const char *func, const char *type, ...) HDfprintf(out, "%ld (attr)", (long)obj); break; - case H5I_REFERENCE: - HDfprintf(out, "%ld (reference)", (long)obj); - break; - case H5I_VFL: HDfprintf(out, "%ld (file driver)", (long)obj); break; @@ -1409,7 +1405,7 @@ H5_trace(const double *returning, const char *func, const char *type, ...) HDfprintf(out, "NULL"); } /* end if */ else { - H5_index_t idx_type = (H5_index_t)va_arg(ap, int); + H5_index_t idx_type = (H5_index_t)HDva_arg(ap, int); switch(idx_type) { case H5_INDEX_UNKNOWN: @@ -1443,7 +1439,7 @@ H5_trace(const double *returning, const char *func, const char *type, ...) HDfprintf(out, "NULL"); } /* end if */ else { - H5_iter_order_t order = (H5_iter_order_t)va_arg(ap, int); + H5_iter_order_t order = (H5_iter_order_t)HDva_arg(ap, int); switch(order) { case H5_ITER_UNKNOWN: @@ -1490,7 +1486,7 @@ H5_trace(const double *returning, const char *func, const char *type, ...) HDfprintf(out, "NULL"); } /* end if */ else { - int is = va_arg(ap, int); + int is = HDva_arg(ap, int); HDfprintf (out, "%d", is); asize[argno] = is; @@ -1505,7 +1501,7 @@ H5_trace(const double *returning, const char *func, const char *type, ...) HDfprintf(out, "NULL"); } /* end if */ else { - H5I_type_t id_type = (H5I_type_t)va_arg(ap, int); + H5I_type_t id_type = (H5I_type_t)HDva_arg(ap, int); switch (id_type) { case H5I_UNINIT: @@ -1540,10 +1536,6 @@ H5_trace(const double *returning, const char *func, const char *type, ...) HDfprintf(out, "H5I_ATTR"); break; - case H5I_REFERENCE: - HDfprintf(out, "H5I_REFERENCE"); - break; - case H5I_VFL: HDfprintf(out, "H5I_VFL"); break; @@ -1600,7 +1592,7 @@ H5_trace(const double *returning, const char *func, const char *type, ...) HDfprintf(out, "NULL"); } /* end if */ else { - unsigned iu = va_arg(ap, unsigned); + unsigned iu = HDva_arg(ap, unsigned); HDfprintf(out, "%u", iu); asize[argno] = iu; @@ -1623,7 +1615,7 @@ H5_trace(const double *returning, const char *func, const char *type, ...) HDfprintf(out, "NULL"); } /* end if */ else { - H5L_type_t link_type = (H5L_type_t)va_arg(ap, int); + H5L_type_t link_type = (H5L_type_t)HDva_arg(ap, int); switch(link_type) { case H5L_TYPE_ERROR: @@ -1670,7 +1662,7 @@ H5_trace(const double *returning, const char *func, const char *type, ...) } /* end if */ #ifdef H5_HAVE_PARALLEL else { - MPI_Comm comm = va_arg(ap, MPI_Comm); + MPI_Comm comm = HDva_arg(ap, MPI_Comm); HDfprintf(out, "%ld", (long)comm); } /* end else */ @@ -1686,7 +1678,7 @@ H5_trace(const double *returning, const char *func, const char *type, ...) } /* end if */ #ifdef H5_HAVE_PARALLEL else { - MPI_Info info = va_arg(ap, MPI_Info); + MPI_Info info = HDva_arg(ap, MPI_Info); HDfprintf(out, "%ld", (long)info); } /* end else */ @@ -1701,7 +1693,7 @@ H5_trace(const double *returning, const char *func, const char *type, ...) HDfprintf(out, "NULL"); } /* end if */ else { - H5FD_mem_t mt = (H5FD_mem_t)va_arg(ap, int); + H5FD_mem_t mt = (H5FD_mem_t)HDva_arg(ap, int); switch(mt) { case H5FD_MEM_NOLIST: @@ -1760,7 +1752,7 @@ H5_trace(const double *returning, const char *func, const char *type, ...) HDfprintf(out, "NULL"); } /* end if */ else { - off_t offset = va_arg(ap, off_t); + off_t offset = HDva_arg(ap, off_t); HDfprintf (out, "%ld", (long)offset); } /* end else */ @@ -1776,7 +1768,7 @@ H5_trace(const double *returning, const char *func, const char *type, ...) HDfprintf(out, "NULL"); } /* end if */ else { - H5O_type_t objtype = (H5O_type_t)va_arg(ap, int); + H5O_type_t objtype = (H5O_type_t)HDva_arg(ap, int); switch(objtype) { case H5O_TYPE_UNKNOWN: @@ -1820,7 +1812,7 @@ H5_trace(const double *returning, const char *func, const char *type, ...) HDfprintf(out, "NULL"); } /* end if */ else { - hid_t pclass_id = va_arg(ap, hid_t); + hid_t pclass_id = HDva_arg(ap, hid_t); char *class_name = NULL; H5P_genclass_t *pclass; @@ -1844,7 +1836,7 @@ H5_trace(const double *returning, const char *func, const char *type, ...) HDfprintf(out, "NULL"); } /* end if */ else { - hobj_ref_t ref = va_arg(ap, hobj_ref_t); + hobj_ref_t ref = HDva_arg(ap, hobj_ref_t); HDfprintf(out, "Reference Object=%a", ref); } /* end else */ @@ -1860,7 +1852,7 @@ H5_trace(const double *returning, const char *func, const char *type, ...) HDfprintf(out, "NULL"); } /* end if */ else { - H5R_type_t reftype = (H5R_type_t)va_arg(ap, int); + H5R_type_t reftype = (H5R_type_t)HDva_arg(ap, int); switch(reftype) { case H5R_BADTYPE: @@ -1902,7 +1894,7 @@ H5_trace(const double *returning, const char *func, const char *type, ...) HDfprintf(out, "NULL"); } /* end if */ else { - H5S_class_t cls = (H5S_class_t)va_arg(ap, int); + H5S_class_t cls = (H5S_class_t)HDva_arg(ap, int); switch(cls) { case H5S_NO_CLASS: @@ -1936,7 +1928,7 @@ H5_trace(const double *returning, const char *func, const char *type, ...) HDfprintf(out, "NULL"); } /* end if */ else { - H5S_seloper_t so = (H5S_seloper_t)va_arg(ap, int); + H5S_seloper_t so = (H5S_seloper_t)HDva_arg(ap, int); switch(so) { case H5S_SELECT_NOOP: @@ -1994,7 +1986,7 @@ H5_trace(const double *returning, const char *func, const char *type, ...) HDfprintf(out, "NULL"); } /* end if */ else { - H5S_sel_type st = (H5S_sel_type)va_arg(ap, int); + H5S_sel_type st = (H5S_sel_type)HDva_arg(ap, int); switch(st) { case H5S_SEL_ERROR: @@ -2042,7 +2034,7 @@ H5_trace(const double *returning, const char *func, const char *type, ...) HDfprintf(out, "NULL"); } /* end if */ else { - const char *str = va_arg(ap, const char *); + const char *str = HDva_arg(ap, const char *); HDfprintf(out, "\"%s\"", str); } /* end else */ @@ -2058,7 +2050,7 @@ H5_trace(const double *returning, const char *func, const char *type, ...) HDfprintf(out, "NULL"); } /* end if */ else { - H5T_cset_t cset = (H5T_cset_t)va_arg(ap, int); + H5T_cset_t cset = (H5T_cset_t)HDva_arg(ap, int); switch(cset) { case H5T_CSET_ERROR: @@ -2105,7 +2097,7 @@ H5_trace(const double *returning, const char *func, const char *type, ...) HDfprintf(out, "NULL"); } /* end if */ else { - H5T_direction_t direct = (H5T_direction_t)va_arg(ap, int); + H5T_direction_t direct = (H5T_direction_t)HDva_arg(ap, int); switch(direct) { case H5T_DIR_DEFAULT: @@ -2135,7 +2127,7 @@ H5_trace(const double *returning, const char *func, const char *type, ...) HDfprintf(out, "NULL"); } /* end if */ else { - H5T_pers_t pers = (H5T_pers_t)va_arg(ap, int); + H5T_pers_t pers = (H5T_pers_t)HDva_arg(ap, int); switch(pers) { case H5T_PERS_DONTCARE: @@ -2165,7 +2157,7 @@ H5_trace(const double *returning, const char *func, const char *type, ...) HDfprintf(out, "NULL"); } /* end if */ else { - H5T_norm_t norm = (H5T_norm_t)va_arg(ap, int); + H5T_norm_t norm = (H5T_norm_t)HDva_arg(ap, int); switch(norm) { case H5T_NORM_ERROR: @@ -2199,7 +2191,7 @@ H5_trace(const double *returning, const char *func, const char *type, ...) HDfprintf(out, "NULL"); } /* end if */ else { - H5T_order_t order = (H5T_order_t)va_arg(ap, int); + H5T_order_t order = (H5T_order_t)HDva_arg(ap, int); switch(order) { case H5T_ORDER_ERROR: @@ -2241,7 +2233,7 @@ H5_trace(const double *returning, const char *func, const char *type, ...) HDfprintf(out, "NULL"); } /* end if */ else { - H5T_pad_t pad = (H5T_pad_t)va_arg(ap, int); + H5T_pad_t pad = (H5T_pad_t)HDva_arg(ap, int); switch(pad) { case H5T_PAD_ERROR: @@ -2279,7 +2271,7 @@ H5_trace(const double *returning, const char *func, const char *type, ...) HDfprintf(out, "NULL"); } /* end if */ else { - H5T_sign_t sign = (H5T_sign_t)va_arg(ap, int); + H5T_sign_t sign = (H5T_sign_t)HDva_arg(ap, int); switch(sign) { case H5T_SGN_ERROR: @@ -2313,7 +2305,7 @@ H5_trace(const double *returning, const char *func, const char *type, ...) HDfprintf(out, "NULL"); } /* end if */ else { - H5T_class_t type_class = (H5T_class_t)va_arg(ap, int); + H5T_class_t type_class = (H5T_class_t)HDva_arg(ap, int); switch(type_class) { case H5T_NO_CLASS: @@ -2383,7 +2375,7 @@ H5_trace(const double *returning, const char *func, const char *type, ...) HDfprintf(out, "NULL"); } /* end if */ else { - H5T_str_t str = (H5T_str_t)va_arg(ap, int); + H5T_str_t str = (H5T_str_t)HDva_arg(ap, int); switch(str) { case H5T_STR_ERROR: @@ -2439,7 +2431,7 @@ H5_trace(const double *returning, const char *func, const char *type, ...) HDfprintf(out, "NULL"); } /* end if */ else { - htri_t tri_var = va_arg (ap, htri_t); + htri_t tri_var = HDva_arg (ap, htri_t); if(tri_var>0) HDfprintf (out, "TRUE"); @@ -2469,7 +2461,7 @@ H5_trace(const double *returning, const char *func, const char *type, ...) HDfprintf(out, "NULL"); } /* end if */ else { - unsigned long iul = va_arg(ap, unsigned long); + unsigned long iul = HDva_arg(ap, unsigned long); HDfprintf(out, "%lu", iul); asize[argno] = (hssize_t)iul; @@ -2493,7 +2485,7 @@ H5_trace(const double *returning, const char *func, const char *type, ...) HDfprintf(out, "NULL"); } /* end if */ else { - unsigned long long iull = va_arg(ap, unsigned long long); + unsigned long long iull = HDva_arg(ap, unsigned long long); HDfprintf(out, "%llu", iull); asize[argno] = (hssize_t)iull; @@ -2516,7 +2508,7 @@ H5_trace(const double *returning, const char *func, const char *type, ...) HDfprintf(out, "NULL"); } /* end if */ else { - H5VL_attr_get_t get = (H5VL_attr_get_t)va_arg(ap, int); + H5VL_attr_get_t get = (H5VL_attr_get_t)HDva_arg(ap, int); switch(get) { case H5VL_ATTR_GET_SPACE: @@ -2551,7 +2543,7 @@ H5_trace(const double *returning, const char *func, const char *type, ...) HDfprintf(out, "NULL"); } /* end if */ else { - H5VL_attr_specific_t specific = (H5VL_attr_specific_t)va_arg(ap, int); + H5VL_attr_specific_t specific = (H5VL_attr_specific_t)HDva_arg(ap, int); switch(specific) { case H5VL_ATTR_DELETE: @@ -2572,6 +2564,22 @@ H5_trace(const double *returning, const char *func, const char *type, ...) } /* end switch */ } /* end else */ break; + case 'C': + if(ptr) { + if(vp) + HDfprintf (out, "0x%lx", (unsigned long)vp); + else + HDfprintf(out, "NULL"); + } /* end if */ + else { + H5VL_class_value_t class_val = (H5VL_class_value_t)HDva_arg(ap, H5VL_class_value_t); + + if(H5_VOL_NATIVE == class_val) + HDfprintf(out, "H5_VOL_NATIVE"); + else + HDfprintf(out, "%ld", (long)class_val); + } /* end else */ + break; case 'c': if(ptr) { if(vp) @@ -2580,7 +2588,7 @@ H5_trace(const double *returning, const char *func, const char *type, ...) HDfprintf(out, "NULL"); } /* end if */ else { - H5VL_dataset_get_t get = (H5VL_dataset_get_t)va_arg(ap, int); + H5VL_dataset_get_t get = (H5VL_dataset_get_t)HDva_arg(ap, int); switch(get) { case H5VL_DATASET_GET_SPACE: @@ -2618,7 +2626,7 @@ H5_trace(const double *returning, const char *func, const char *type, ...) HDfprintf(out, "NULL"); } /* end if */ else { - H5VL_dataset_specific_t specific = (H5VL_dataset_specific_t)va_arg(ap, int); + H5VL_dataset_specific_t specific = (H5VL_dataset_specific_t)HDva_arg(ap, int); switch(specific) { case H5VL_DATASET_SET_EXTENT: @@ -2644,7 +2652,7 @@ H5_trace(const double *returning, const char *func, const char *type, ...) HDfprintf(out, "NULL"); } /* end if */ else { - H5VL_datatype_get_t get = (H5VL_datatype_get_t)va_arg(ap, int); + H5VL_datatype_get_t get = (H5VL_datatype_get_t)HDva_arg(ap, int); switch(get) { case H5VL_DATATYPE_GET_BINARY: @@ -2667,7 +2675,7 @@ H5_trace(const double *returning, const char *func, const char *type, ...) HDfprintf(out, "NULL"); } /* end if */ else { - H5VL_datatype_specific_t specific = (H5VL_datatype_specific_t)va_arg(ap, int); + H5VL_datatype_specific_t specific = (H5VL_datatype_specific_t)HDva_arg(ap, int); switch(specific) { case H5VL_DATATYPE_FLUSH: @@ -2690,7 +2698,7 @@ H5_trace(const double *returning, const char *func, const char *type, ...) HDfprintf(out, "NULL"); } /* end if */ else { - H5VL_file_get_t get = (H5VL_file_get_t)va_arg(ap, int); + H5VL_file_get_t get = (H5VL_file_get_t)HDva_arg(ap, int); switch(get) { case H5VL_FILE_GET_FAPL: @@ -2711,9 +2719,6 @@ H5_trace(const double *returning, const char *func, const char *type, ...) case H5VL_FILE_GET_OBJ_IDS: HDfprintf(out, "H5VL_FILE_GET_OBJ_IDS"); break; - case H5VL_OBJECT_GET_FILE: - HDfprintf(out, "H5VL_OBJECT_GET_FILE"); - break; default: HDfprintf(out, "%ld", (long)get); break; @@ -2728,12 +2733,15 @@ H5_trace(const double *returning, const char *func, const char *type, ...) HDfprintf(out, "NULL"); } /* end if */ else { - H5VL_file_specific_t specific = (H5VL_file_specific_t)va_arg(ap, int); + H5VL_file_specific_t specific = (H5VL_file_specific_t)HDva_arg(ap, int); switch(specific) { case H5VL_FILE_FLUSH: HDfprintf(out, "H5VL_FILE_FLUSH"); break; + case H5VL_FILE_REOPEN: + HDfprintf(out, "H5VL_FILE_REOPEN"); + break; case H5VL_FILE_MOUNT: HDfprintf(out, "H5VL_FILE_MOUNT"); break; @@ -2757,7 +2765,7 @@ H5_trace(const double *returning, const char *func, const char *type, ...) HDfprintf(out, "NULL"); } /* end if */ else { - H5VL_group_get_t get = (H5VL_group_get_t)va_arg(ap, int); + H5VL_group_get_t get = (H5VL_group_get_t)HDva_arg(ap, int); switch(get) { case H5VL_GROUP_GET_GCPL: @@ -2780,7 +2788,7 @@ H5_trace(const double *returning, const char *func, const char *type, ...) HDfprintf(out, "NULL"); } /* end if */ else { - H5VL_group_specific_t specific = (H5VL_group_specific_t)va_arg(ap, int); + H5VL_group_specific_t specific = (H5VL_group_specific_t)HDva_arg(ap, int); switch(specific) { case H5VL_GROUP_FLUSH: @@ -2803,7 +2811,7 @@ H5_trace(const double *returning, const char *func, const char *type, ...) HDfprintf(out, "NULL"); } /* end if */ else { - H5VL_link_create_type_t create = (H5VL_link_create_type_t)va_arg(ap, int); + H5VL_link_create_type_t create = (H5VL_link_create_type_t)HDva_arg(ap, int); switch(create) { case H5VL_LINK_CREATE_HARD: @@ -2829,7 +2837,7 @@ H5_trace(const double *returning, const char *func, const char *type, ...) HDfprintf(out, "NULL"); } /* end if */ else { - H5VL_link_get_t get = (H5VL_link_get_t)va_arg(ap, int); + H5VL_link_get_t get = (H5VL_link_get_t)HDva_arg(ap, int); switch(get) { case H5VL_LINK_GET_INFO: @@ -2855,7 +2863,7 @@ H5_trace(const double *returning, const char *func, const char *type, ...) HDfprintf(out, "NULL"); } /* end if */ else { - H5VL_link_specific_t specific = (H5VL_link_specific_t)va_arg(ap, int); + H5VL_link_specific_t specific = (H5VL_link_specific_t)HDva_arg(ap, int); switch(specific) { case H5VL_LINK_DELETE: @@ -2881,7 +2889,7 @@ H5_trace(const double *returning, const char *func, const char *type, ...) HDfprintf(out, "NULL"); } /* end if */ else { - H5VL_object_get_t get = (H5VL_object_get_t)va_arg(ap, int); + H5VL_object_get_t get = (H5VL_object_get_t)HDva_arg(ap, int); switch(get) { case H5VL_REF_GET_REGION: @@ -2893,6 +2901,9 @@ H5_trace(const double *returning, const char *func, const char *type, ...) case H5VL_REF_GET_NAME: HDfprintf(out, "H5VL_REF_GET_NAME"); break; + case H5VL_ID_GET_NAME: + HDfprintf(out, "H5VL_ID_GET_NAME"); + break; default: HDfprintf(out, "%ld", (long)get); break; @@ -2907,7 +2918,7 @@ H5_trace(const double *returning, const char *func, const char *type, ...) HDfprintf(out, "NULL"); } /* end if */ else { - H5VL_object_specific_t specific = (H5VL_object_specific_t)va_arg(ap, int); + H5VL_object_specific_t specific = (H5VL_object_specific_t)HDva_arg(ap, int); switch(specific) { case H5VL_OBJECT_CHANGE_REF_COUNT: @@ -2934,6 +2945,32 @@ H5_trace(const double *returning, const char *func, const char *type, ...) } /* end switch */ } /* end else */ break; + case 'r': + if(ptr) { + if(vp) + HDfprintf (out, "0x%lx", (unsigned long)vp); + else + HDfprintf(out, "NULL"); + } /* end if */ + else { + H5VL_request_specific_t specific = (H5VL_request_specific_t)HDva_arg(ap, int); + + switch(specific) { + case H5VL_REQUEST_WAITANY: + HDfprintf(out, "H5VL_REQUEST_WAITANY"); + break; + case H5VL_REQUEST_WAITSOME: + HDfprintf(out, "H5VL_REQUEST_WAITSOME"); + break; + case H5VL_REQUEST_WAITALL: + HDfprintf(out, "H5VL_REQUEST_WAITALL"); + break; + default: + HDfprintf(out, "%ld", (long)specific); + break; + } /* end switch */ + } /* end else */ + break; default: HDfprintf(out, "BADTYPE(Z%c)", type[1]); goto error; @@ -2961,7 +2998,7 @@ H5_trace(const double *returning, const char *func, const char *type, ...) HDfprintf(out, "NULL"); } /* end if */ else { - vp = va_arg (ap, void *); + vp = HDva_arg (ap, void *); if(vp) HDfprintf(out, "0x%lx", (unsigned long)vp); @@ -2987,7 +3024,7 @@ H5_trace(const double *returning, const char *func, const char *type, ...) HDfprintf(out, "NULL"); } /* end if */ else { - size_t size = va_arg(ap, size_t); + size_t size = HDva_arg(ap, size_t); HDfprintf(out, "%Zu", size); asize[argno] = (hssize_t)size; @@ -3004,7 +3041,7 @@ H5_trace(const double *returning, const char *func, const char *type, ...) HDfprintf(out, "NULL"); } /* end if */ else { - H5Z_SO_scale_type_t scale_type = (H5Z_SO_scale_type_t)va_arg(ap, int); + H5Z_SO_scale_type_t scale_type = (H5Z_SO_scale_type_t)HDva_arg(ap, int); switch(scale_type) { case H5Z_SO_FLOAT_DSCALE: @@ -3034,7 +3071,7 @@ H5_trace(const double *returning, const char *func, const char *type, ...) HDfprintf(out, "NULL"); } /* end if */ else { - H5Z_class2_t *filter = va_arg(ap, H5Z_class2_t*); + H5Z_class2_t *filter = HDva_arg(ap, H5Z_class2_t*); HDfprintf(out, "0x%lx", (unsigned long)filter); } /* end else */ @@ -3048,7 +3085,7 @@ H5_trace(const double *returning, const char *func, const char *type, ...) HDfprintf(out, "NULL"); } /* end if */ else { - H5Z_EDC_t edc = (H5Z_EDC_t)va_arg(ap, int); + H5Z_EDC_t edc = (H5Z_EDC_t)HDva_arg(ap, int); if(H5Z_DISABLE_EDC == edc) HDfprintf(out, "H5Z_DISABLE_EDC"); @@ -3067,7 +3104,7 @@ H5_trace(const double *returning, const char *func, const char *type, ...) HDfprintf(out, "NULL"); } /* end if */ else { - H5Z_filter_t id = va_arg(ap, H5Z_filter_t); + H5Z_filter_t id = HDva_arg(ap, H5Z_filter_t); if(H5Z_FILTER_DEFLATE == id) HDfprintf(out, "H5Z_FILTER_DEFLATE"); @@ -3093,7 +3130,7 @@ H5_trace(const double *returning, const char *func, const char *type, ...) HDfprintf(out, "NULL"); } /* end if */ else { - ssize_t ssize = va_arg(ap, ssize_t); + ssize_t ssize = HDva_arg(ap, ssize_t); HDfprintf(out, "%Zd", ssize); asize[argno] = (hssize_t)ssize; @@ -3121,7 +3158,7 @@ H5_trace(const double *returning, const char *func, const char *type, ...) (event_time.etime - *returning)); error: - va_end(ap); + HDva_end(ap); if(returning) HDfprintf(out, ";\n"); else { diff --git a/src/H5win32defs.h b/src/H5win32defs.h index 4522228..140afc3 100644 --- a/src/H5win32defs.h +++ b/src/H5win32defs.h @@ -62,9 +62,17 @@ typedef __int64 h5_stat_size_t; #define HDstat(S,B) _stati64(S,B) #define HDstrcasecmp(A,B) _stricmp(A,B) #define HDstrdup(S) _strdup(S) +#define HDstrtok_r(X,Y,Z) strtok_s(X,Y,Z) #define HDtzset() _tzset() #define HDunlink(S) _unlink(S) #define HDwrite(F,M,Z) _write(F,M,Z) +#if (_MSC_VER < 1800) +/* va_copy() does not exist on pre-2013 Visual Studio. Since va_lists are + * just pointers into the stack in those CRTs, the usual work-around + * is to just define the operation as a pointer copy. + */ +#define HDva_copy(D,S) ((D) = (S)) +#endif /* MSC_VER < 1800 */ #ifdef H5_HAVE_VISUAL_STUDIO diff --git a/src/Makefile.am b/src/Makefile.am index ffdf844..c0be29c 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -114,7 +114,10 @@ libhdf5_la_SOURCES= H5.c H5checksum.c H5dbg.c H5system.c H5timer.c H5trace.c \ H5Topaque.c \ H5Torder.c \ H5Tpad.c H5Tprecis.c H5Tstrpad.c H5Tvisit.c H5Tvlen.c H5TS.c \ - H5VL.c H5VLint.c H5VLnative.c \ + H5VL.c H5VLcallback.c H5VLint.c H5VLnative.c \ + H5VLnative_attr.c H5VLnative_dataset.c H5VLnative_datatype.c \ + H5VLnative_file.c H5VLnative_group.c H5VLnative_link.c H5VLnative_object.c \ + H5VLpassthru.c \ H5VM.c H5WB.c H5Z.c \ H5Zdeflate.c H5Zfletcher32.c H5Znbit.c H5Zshuffle.c \ H5Zscaleoffset.c H5Zszip.c H5Ztrans.c @@ -141,7 +144,7 @@ include_HEADERS = hdf5.h H5api_adpt.h H5overflow.h H5pubconf.h H5public.h H5vers H5MMpublic.h H5Opublic.h H5Ppublic.h \ H5PLextern.h H5PLpublic.h \ H5Rpublic.h H5Spublic.h H5Tpublic.h \ - H5VLnative.h H5VLpublic.h H5Zpublic.h + H5VLnative.h H5VLpassthru.h H5VLpublic.h H5Zpublic.h # install libhdf5.settings in lib directory settingsdir=$(libdir) @@ -52,7 +52,8 @@ #include "H5FDwindows.h" /* Win32 I/O */ #endif -/* Virtual object layer drivers */ -#include "H5VLnative.h" /* Native VOL driver */ +/* Virtual object layer (VOL) connectors */ +#include "H5VLnative.h" /* Native VOL connector */ +#include "H5VLpassthru.h" /* Pass-through VOL connector */ #endif diff --git a/test/CMakeTests.cmake b/test/CMakeTests.cmake index 3ad9de7..26faba6 100644 --- a/test/CMakeTests.cmake +++ b/test/CMakeTests.cmake @@ -843,6 +843,7 @@ if (HDF5_ENABLE_DEPRECATED_SYMBOLS) -D "TEST_ARGS:STRING=" -D "TEST_EXPECT=0" -D "TEST_MASK_ERROR=true" + -D "ERROR_APPEND=1" -D "TEST_OUTPUT=err_compat.txt" -D "TEST_REFERENCE=err_compat_1" -D "TEST_FOLDER=${PROJECT_BINARY_DIR}/H5TEST" @@ -877,6 +878,7 @@ else () -D "TEST_ARGS:STRING=" -D "TEST_EXPECT=0" -D "TEST_MASK_ERROR=true" + -D "ERROR_APPEND=1" -D "TEST_OUTPUT=error_test.txt" -D "TEST_REFERENCE=error_test_1" -D "TEST_FOLDER=${PROJECT_BINARY_DIR}/H5TEST" @@ -943,6 +945,7 @@ if (BUILD_SHARED_LIBS) -D "TEST_ARGS:STRING=" -D "TEST_EXPECT=0" -D "TEST_MASK_ERROR=true" + -D "ERROR_APPEND=1" -D "TEST_OUTPUT=err_compat.txt" -D "TEST_REFERENCE=err_compat_1" -D "TEST_FOLDER=${PROJECT_BINARY_DIR}/H5TEST-shared" @@ -977,6 +980,7 @@ if (BUILD_SHARED_LIBS) -D "TEST_ARGS:STRING=" -D "TEST_EXPECT=0" -D "TEST_MASK_ERROR=true" + -D "ERROR_APPEND=1" -D "TEST_OUTPUT=error_test.txt" -D "TEST_REFERENCE=error_test_1" -D "TEST_FOLDER=${PROJECT_BINARY_DIR}/H5TEST-shared" @@ -1123,6 +1127,16 @@ endif () ############################################################################## ############################################################################## +### V O L T E S T S ### +############################################################################## +############################################################################## + +if (HDF5_TEST_VOL) + include (CMakeVOLTests.cmake) +endif () + +############################################################################## +############################################################################## ### T H E G E N E R A T O R S ### ############################################################################## ############################################################################## diff --git a/test/CMakeVOLTests.cmake b/test/CMakeVOLTests.cmake new file mode 100644 index 0000000..39fa2a6 --- /dev/null +++ b/test/CMakeVOLTests.cmake @@ -0,0 +1,322 @@ + +# 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 COPYING file, which can be found at the root of the source code +# distribution tree, or in https://support.hdfgroup.org/ftp/HDF5/releases. +# If you do not have access to either file, you may request a copy from +# help@hdfgroup.org. +# + +############################################################################## +############################################################################## +### T E S T I N G ### +############################################################################## +############################################################################## +# included from CMakeTests.cmake + +set (VOL_LIST + vol_native + vol_pass_through1 + vol_pass_through2 +) + +set (vol_native native) +set (vol_pass_through1 "pass_through under_vol=0\;under_info={}") +set (vol_pass_through2 "pass_through under_vol=505\;under_info={under_vol=0\;under_info={}}") + +foreach (voltest ${VOL_LIST}) + file (MAKE_DIRECTORY "${PROJECT_BINARY_DIR}/${voltest}") + file (MAKE_DIRECTORY "${PROJECT_BINARY_DIR}/${voltest}/testfiles") + file (MAKE_DIRECTORY "${PROJECT_BINARY_DIR}/${voltest}/testfiles/plist_files") + if (BUILD_SHARED_LIBS) + file (MAKE_DIRECTORY "${PROJECT_BINARY_DIR}/${voltest}-shared") + file (MAKE_DIRECTORY "${PROJECT_BINARY_DIR}/${voltest}-shared/testfiles") + file (MAKE_DIRECTORY "${PROJECT_BINARY_DIR}/${voltest}-shared/testfiles/plist_files") + endif () +endforeach () + +foreach (voltest ${VOL_LIST}) + foreach (h5_tfile ${HDF5_TEST_FILES}) + HDFTEST_COPY_FILE("${HDF5_TOOLS_DIR}/testfiles/${h5_tfile}" "${PROJECT_BINARY_DIR}/${voltest}/${h5_tfile}" "HDF5_VOLTEST_LIB_files") + if (BUILD_SHARED_LIBS) + HDFTEST_COPY_FILE("${HDF5_TOOLS_DIR}/testfiles/${h5_tfile}" "${PROJECT_BINARY_DIR}/${voltest}-shared/${h5_tfile}" "HDF5_VOLTEST_LIBSH_files") + endif () + endforeach () +endforeach () + +foreach (voltest ${VOL_LIST}) + foreach (ref_file ${HDF5_REFERENCE_FILES}) + HDFTEST_COPY_FILE("${HDF5_TEST_SOURCE_DIR}/testfiles/${ref_file}" "${PROJECT_BINARY_DIR}/${voltest}/${ref_file}" "HDF5_VOLTEST_LIB_files") + if (BUILD_SHARED_LIBS) + HDFTEST_COPY_FILE("${HDF5_TEST_SOURCE_DIR}/testfiles/${ref_file}" "${PROJECT_BINARY_DIR}/${voltest}-shared/${ref_file}" "HDF5_VOLTEST_LIBSH_files") + endif () + endforeach () +endforeach () + +foreach (voltest ${VOL_LIST}) + foreach (h5_file ${HDF5_REFERENCE_TEST_FILES}) + HDFTEST_COPY_FILE("${HDF5_TEST_SOURCE_DIR}/${h5_file}" "${HDF5_TEST_BINARY_DIR}/${voltest}/${h5_file}" "HDF5_VOLTEST_LIB_files") + if (BUILD_SHARED_LIBS) + HDFTEST_COPY_FILE("${HDF5_TEST_SOURCE_DIR}/${h5_file}" "${HDF5_TEST_BINARY_DIR}/${voltest}-shared/${h5_file}" "HDF5_VOLTEST_LIBSH_files") + endif () + endforeach () +endforeach () + +foreach (voltest ${VOL_LIST}) + foreach (plistfile ${HDF5_REFERENCE_PLIST_FILES}) + HDFTEST_COPY_FILE("${HDF5_TEST_SOURCE_DIR}/testfiles/plist_files/${plistfile}" "${PROJECT_BINARY_DIR}/${voltest}/testfiles/plist_files/${plistfile}" "HDF5_VOLTEST_LIB_files") + HDFTEST_COPY_FILE("${HDF5_TEST_SOURCE_DIR}/testfiles/plist_files/def_${plistfile}" "${PROJECT_BINARY_DIR}/${voltest}/testfiles/plist_files/def_${plistfile}" "HDF5_VOLTEST_LIB_files") + if (BUILD_SHARED_LIBS) + HDFTEST_COPY_FILE("${HDF5_TEST_SOURCE_DIR}/testfiles/plist_files/${plistfile}" "${PROJECT_BINARY_DIR}/${voltest}-shared/testfiles/plist_files/${plistfile}" "HDF5_VOLTEST_LIBSH_files") + HDFTEST_COPY_FILE("${HDF5_TEST_SOURCE_DIR}/testfiles/plist_files/def_${plistfile}" "${PROJECT_BINARY_DIR}/${voltest}-shared/testfiles/plist_files/def_${plistfile}" "HDF5_VOLTEST_LIBSH_files") + endif () + endforeach () +endforeach () + +add_custom_target(HDF5_VOLTEST_LIB_files ALL COMMENT "Copying files needed by HDF5_VOLTEST_LIB tests" DEPENDS ${HDF5_VOLTEST_LIB_files_list}) +if (BUILD_SHARED_LIBS) + add_custom_target(HDF5_VOLTEST_LIBSH_files ALL COMMENT "Copying files needed by HDF5_VOLTEST_LIBSH tests" DEPENDS ${HDF5_VOLTEST_LIBSH_files_list}) +endif () + +############################################################################## +############################################################################## +### V O L T E S T S ### +############################################################################## +############################################################################## + + set (H5_VOL_SKIP_TESTS + cache + accum + fheap + big + vol + error_test + err_compat + tcheck_version + testmeta + links_env + ) + if (NOT CYGWIN) + list (REMOVE_ITEM H5_VOL_SKIP_TESTS big cache) + endif () + + # Windows only macro + macro (CHECK_VOL_TEST voltest volname volinfo resultcode) + if ("${voltest}" STREQUAL "flush1" OR "${voltest}" STREQUAL "flush2") + if ("${volname}" STREQUAL "multi" OR "${volname}" STREQUAL "split") + if (NOT BUILD_SHARED_LIBS AND NOT ${HDF_CFG_NAME} MATCHES "Debug") + add_test (NAME VOL-${volname}-${voltest} + COMMAND "${CMAKE_COMMAND}" + -D "TEST_PROGRAM=$<TARGET_FILE:${voltest}>" + -D "TEST_ARGS:STRING=" + -D "TEST_VOL:STRING=${volinfo}" + -D "TEST_EXPECT=${resultcode}" + -D "TEST_OUTPUT=${volname}-${voltest}" + -D "TEST_FOLDER=${PROJECT_BINARY_DIR}/${volname}" + -P "${HDF_RESOURCES_DIR}/volTest.cmake" + ) + set_tests_properties (VOL-${volname}-${voltest} PROPERTIES + ENVIRONMENT "srcdir=${HDF5_TEST_BINARY_DIR}/${volname}" + WORKING_DIRECTORY ${HDF5_TEST_BINARY_DIR}/${volname} + ) + if (BUILD_SHARED_LIBS) + add_test (NAME VOL-${volname}-${test}-shared + COMMAND "${CMAKE_COMMAND}" + -D "TEST_PROGRAM=$<TARGET_FILE:${voltest}-shared>" + -D "TEST_ARGS:STRING=" + -D "TEST_VOL:STRING=${volinfo}" + -D "TEST_EXPECT=${resultcode}" + -D "TEST_OUTPUT=${volname}-${voltest}-shared" + -D "TEST_FOLDER=${PROJECT_BINARY_DIR}/${volname}-shared" + -P "${HDF_RESOURCES_DIR}/volTest.cmake" + ) + set_tests_properties (VOL-${volname}-${voltest}-shared PROPERTIES + ENVIRONMENT "srcdir=${HDF5_TEST_BINARY_DIR}/${volname}-shared" + WORKING_DIRECTORY ${HDF5_TEST_BINARY_DIR}/${volname}-shared + ) + endif () + else () + add_test (NAME VOL-${volname}-${voltest} + COMMAND ${CMAKE_COMMAND} -E echo "SKIP VOL-${volname}-${voltest}" + ) + if (BUILD_SHARED_LIBS) + add_test (NAME VOL-${volname}-${test}-shared + COMMAND ${CMAKE_COMMAND} -E echo "SKIP VOL-${volname}-${voltest}-shared" + ) + endif () + endif () + else () + add_test (NAME VOL-${volname}-${voltest} + COMMAND "${CMAKE_COMMAND}" + -D "TEST_PROGRAM=$<TARGET_FILE:${voltest}>" + -D "TEST_ARGS:STRING=" + -D "TEST_VOL:STRING=${volinfo}" + -D "TEST_EXPECT=${resultcode}" + -D "TEST_OUTPUT=${volname}-${voltest}" + -D "TEST_FOLDER=${PROJECT_BINARY_DIR}/${volname}" + -P "${HDF_RESOURCES_DIR}/volTest.cmake" + ) + set_tests_properties (VOL-${volname}-${voltest} PROPERTIES + ENVIRONMENT "srcdir=${HDF5_TEST_BINARY_DIR}/${volname}" + WORKING_DIRECTORY ${HDF5_TEST_BINARY_DIR}/${volname} + ) + if (BUILD_SHARED_LIBS) + add_test (NAME VOL-${volname}-${test}-shared + COMMAND "${CMAKE_COMMAND}" + -D "TEST_PROGRAM=$<TARGET_FILE:${voltest}-shared>" + -D "TEST_ARGS:STRING=" + -D "TEST_VOL:STRING=${volinfo}" + -D "TEST_EXPECT=${resultcode}" + -D "TEST_OUTPUT=${volname}-${voltest}-shared" + -D "TEST_FOLDER=${PROJECT_BINARY_DIR}/${volname}-shared" + -P "${HDF_RESOURCES_DIR}/volTest.cmake" + ) + set_tests_properties (VOL-${volname}-${voltest}-shared PROPERTIES + ENVIRONMENT "srcdir=${HDF5_TEST_BINARY_DIR}/${volname}-shared" + WORKING_DIRECTORY ${HDF5_TEST_BINARY_DIR}/${volname}-shared + ) + endif () + endif () + else () + add_test (NAME VOL-${volname}-${voltest} + COMMAND "${CMAKE_COMMAND}" + -D "TEST_PROGRAM=$<TARGET_FILE:${voltest}>" + -D "TEST_ARGS:STRING=" + -D "TEST_VOL:STRING=${volinfo}" + -D "TEST_EXPECT=${resultcode}" + -D "TEST_OUTPUT=${volname}-${voltest}" + -D "TEST_FOLDER=${PROJECT_BINARY_DIR}/${volname}" + -P "${HDF_RESOURCES_DIR}/volTest.cmake" + ) + set_tests_properties (VOL-${volname}-${voltest} PROPERTIES + ENVIRONMENT "srcdir=${HDF5_TEST_BINARY_DIR}/${volname};HDF5TestExpress=${HDF_TEST_EXPRESS}" + WORKING_DIRECTORY ${HDF5_TEST_BINARY_DIR}/${volname} + ) + if (BUILD_SHARED_LIBS AND NOT "${voltest}" STREQUAL "cache") + add_test (NAME VOL-${volname}-${voltest}-shared + COMMAND "${CMAKE_COMMAND}" + -D "TEST_PROGRAM=$<TARGET_FILE:${voltest}-shared>" + -D "TEST_ARGS:STRING=" + -D "TEST_VOL:STRING=${volinfo}" + -D "TEST_EXPECT=${resultcode}" + -D "TEST_OUTPUT=${volname}-${voltest}-shared" + -D "TEST_FOLDER=${PROJECT_BINARY_DIR}/${volname}-shared" + -P "${HDF_RESOURCES_DIR}/volTest.cmake" + ) + set_tests_properties (VOL-${volname}-${voltest}-shared PROPERTIES + ENVIRONMENT "srcdir=${HDF5_TEST_BINARY_DIR}/${volname}-shared;HDF5TestExpress=${HDF_TEST_EXPRESS}" + WORKING_DIRECTORY ${HDF5_TEST_BINARY_DIR}/${volname}-shared + ) + endif () + endif () + endmacro () + + macro (DO_VOL_TEST voltest volname volinfo resultcode) + #message(STATUS "${voltest}-${volname} with ${volinfo}") + add_test (NAME VOL-${volname}-${voltest} + COMMAND "${CMAKE_COMMAND}" + -D "TEST_PROGRAM=$<TARGET_FILE:${voltest}>" + -D "TEST_ARGS:STRING=" + -D "TEST_VOL:STRING=${volinfo}" + -D "TEST_EXPECT=${resultcode}" + -D "TEST_OUTPUT=${volname}-${voltest}" + -D "TEST_FOLDER=${PROJECT_BINARY_DIR}/${volname}" + -P "${HDF_RESOURCES_DIR}/volTest.cmake" + ) + set_tests_properties (VOL-${volname}-${voltest} PROPERTIES + ENVIRONMENT "srcdir=${HDF5_TEST_BINARY_DIR}/${volname}" + WORKING_DIRECTORY ${HDF5_TEST_BINARY_DIR}/${volname} + ) + if (BUILD_SHARED_LIBS) + add_test (NAME VOL-${volname}-${voltest}-shared + COMMAND "${CMAKE_COMMAND}" + -D "TEST_PROGRAM=$<TARGET_FILE:${voltest}-shared>" + -D "TEST_ARGS:STRING=" + -D "TEST_VOL:STRING=${volinfo}" + -D "TEST_EXPECT=${resultcode}" + -D "TEST_OUTPUT=${volname}-${voltest}-shared" + -D "TEST_FOLDER=${PROJECT_BINARY_DIR}/${volname}-shared" + -P "${HDF_RESOURCES_DIR}/volTest.cmake" + ) + set_tests_properties (VOL-${volname}-${voltest}-shared PROPERTIES + ENVIRONMENT "srcdir=${HDF5_TEST_BINARY_DIR}/${volname}-shared" + WORKING_DIRECTORY ${HDF5_TEST_BINARY_DIR}/${volname}-shared + ) + endif () + endmacro () + + macro (ADD_VOL_TEST volname volinfo resultcode) + #message(STATUS "volname=${volname} volinfo=${volinfo}") + foreach (test ${H5_TESTS}) + if (NOT ${test} IN_LIST H5_VOL_SKIP_TESTS) + if (WIN32) + CHECK_VOL_TEST (${test} ${volname} "${volinfo}" ${resultcode}) + else () + DO_VOL_TEST (${test} ${volname} "${volinfo}" ${resultcode}) + endif () + endif () + endforeach () + set_tests_properties (VOL-${volname}-flush2 PROPERTIES DEPENDS VOL-${volname}-flush1) + set_tests_properties (VOL-${volname}-flush1 PROPERTIES TIMEOUT 10) + set_tests_properties (VOL-${volname}-flush2 PROPERTIES TIMEOUT 10) + set_tests_properties (VOL-${volname}-istore PROPERTIES TIMEOUT 1800) + if (NOT CYGWIN) + set_tests_properties (VOL-${volname}-cache PROPERTIES TIMEOUT 1800) + endif () + if (BUILD_SHARED_LIBS) + set_tests_properties (VOL-${volname}-flush2-shared PROPERTIES DEPENDS VOL-${volname}-flush1-shared) + set_tests_properties (VOL-${volname}-flush1-shared PROPERTIES TIMEOUT 10) + set_tests_properties (VOL-${volname}-flush2-shared PROPERTIES TIMEOUT 10) + set_tests_properties (VOL-${volname}-istore-shared PROPERTIES TIMEOUT 1800) + if (NOT CYGWIN AND NOT WIN32) + set_tests_properties (VOL-${volname}-cache-shared PROPERTIES TIMEOUT 1800) + endif () + endif () + if (HDF5_TEST_FHEAP_VOL) + add_test (NAME VOL-${volname}-fheap + COMMAND "${CMAKE_COMMAND}" + -D "TEST_PROGRAM=$<TARGET_FILE:fheap>" + -D "TEST_ARGS:STRING=" + -D "TEST_VOL:STRING=${volinfo}" + -D "TEST_EXPECT=${resultcode}" + -D "TEST_OUTPUT=${volname}-fheap" + -D "TEST_FOLDER=${PROJECT_BINARY_DIR}/${volname}" + -P "${HDF_RESOURCES_DIR}/volTest.cmake" + ) + set_tests_properties (VOL-${volname}-fheap PROPERTIES + TIMEOUT 1800 + ENVIRONMENT "srcdir=${HDF5_TEST_BINARY_DIR}/${volname};HDF5TestExpress=${HDF_TEST_EXPRESS}" + WORKING_DIRECTORY ${HDF5_TEST_BINARY_DIR}/${volname} + ) + if (BUILD_SHARED_LIBS) + add_test (NAME VOL-${volname}-fheap-shared + COMMAND "${CMAKE_COMMAND}" + -D "TEST_PROGRAM=$<TARGET_FILE:fheap-shared>" + -D "TEST_ARGS:STRING=" + -D "TEST_VOL:STRING=${volinfo}" + -D "TEST_EXPECT=${resultcode}" + -D "TEST_OUTPUT=${volname}-fheap-shared" + -D "TEST_FOLDER=${PROJECT_BINARY_DIR}/${volname}-shared" + -P "${HDF_RESOURCES_DIR}/volTest.cmake" + ) + set_tests_properties (VOL-${volname}-fheap-shared PROPERTIES + TIMEOUT 1800 + ENVIRONMENT "srcdir=${HDF5_TEST_BINARY_DIR}/${volname}-shared;HDF5TestExpress=${HDF_TEST_EXPRESS}" + WORKING_DIRECTORY ${HDF5_TEST_BINARY_DIR}/${volname}-shared + ) + endif () + endif () + endmacro () + + # Run test with different Virtual File Driver + foreach (volname ${VOL_LIST}) + #message(STATUS "volname=${volname}") + foreach (volinfo IN LISTS ${volname}) + #message(STATUS "${volname} volinfo=${volinfo}") + ADD_VOL_TEST (${volname} "${volinfo}" 0) + endforeach () + endforeach () + diff --git a/test/Makefile.am b/test/Makefile.am index 61dcda8..1526eca 100644 --- a/test/Makefile.am +++ b/test/Makefile.am @@ -144,6 +144,11 @@ if DIRECT_VFD_CONDITIONAL VFD_LIST += direct endif +# Test with just the native connector, with a single pass-through connector +# and with a doubly-stacked pass-through. +VOL_LIST = native "pass_through under_vol=0;under_info={}" \ + "pass_through under_vol=505;under_info={under_vol=0;under_info={}}" + # Additional target for running timing test timings _timings: testmeta @for timing in $(TIMINGS) dummy; do \ diff --git a/test/accum.c b/test/accum.c index 40829f9..87628d8 100644 --- a/test/accum.c +++ b/test/accum.c @@ -91,14 +91,23 @@ main(void) unsigned nerrors = 0; /* track errors */ hbool_t api_ctx_pushed = FALSE; /* Whether API context pushed */ hid_t fid = -1; + hid_t fapl = -1; /* File access property list */ H5F_t * f = NULL; /* File for all tests */ /* Test Setup */ puts("Testing the metadata accumulator"); + /* File access property list */ + if((fapl = h5_fileaccess()) < 0) + FAIL_STACK_ERROR + /* Create a test file */ - if((fid = H5Fcreate(FILENAME, H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT)) < 0) FAIL_STACK_ERROR + if((fid = H5Fcreate(FILENAME, H5F_ACC_TRUNC, H5P_DEFAULT, fapl)) < 0) FAIL_STACK_ERROR + + /* Closing and remove the file */ + if(H5Pclose(fapl) < 0) + FAIL_STACK_ERROR /* Push API context */ if(H5CX_push() < 0) FAIL_STACK_ERROR diff --git a/test/cache_image.c b/test/cache_image.c index 4d6b065..10e9a8a 100644 --- a/test/cache_image.c +++ b/test/cache_image.c @@ -586,12 +586,12 @@ open_hdf5_file(hbool_t create_file, hbool_t mdci_sbem_expected, /* create a file access propertly list. */ if ( pass ) { - fapl_id = H5Pcreate(H5P_FILE_ACCESS); + fapl_id = h5_fileaccess(); if ( fapl_id < 0 ) { pass = FALSE; - failure_mssg = "H5Pcreate() failed.\n"; + failure_mssg = "h5_fileaccess() failed.\n"; } } @@ -928,12 +928,12 @@ attempt_swmr_open_hdf5_file(const hbool_t create_file, /* create a file access propertly list. */ if ( pass ) { - fapl_id = H5Pcreate(H5P_FILE_ACCESS); + fapl_id = h5_fileaccess(); if ( fapl_id < 0 ) { pass = FALSE; - failure_mssg = "H5Pcreate() failed.\n"; + failure_mssg = "h5_fileaccess() failed.\n"; } } @@ -6688,12 +6688,12 @@ cache_image_api_error_check_4(void) */ if ( pass ) { - fapl_id = H5Pcreate(H5P_FILE_ACCESS); + fapl_id = h5_fileaccess(); if ( fapl_id < 0 ) { pass = FALSE; - failure_mssg = "H5Pcreate() failed.\n"; + failure_mssg = "h5_fileaccess() failed.\n"; } } diff --git a/test/cache_tagging.c b/test/cache_tagging.c index 8d90eb6..752dd27 100644 --- a/test/cache_tagging.c +++ b/test/cache_tagging.c @@ -440,14 +440,20 @@ check_file_creation_tags(hid_t fcpl_id, int type) /* Variable Declarations */ hid_t fid = -1; /* File Identifier */ int verbose = FALSE; /* verbose test outout */ + hid_t fapl = -1; /* File access prop list */ haddr_t root_tag = 0; haddr_t sbe_tag = 0; /* Testing Macro */ TESTING("tag application during file creation"); + /* Create Fapl */ + if ( (fapl = h5_fileaccess()) < 0 ) TEST_ERROR; + /* Create a test file with provided fcpl_t */ - if ( (fid = H5Fcreate(FILENAME, H5F_ACC_TRUNC, fcpl_id, H5P_DEFAULT)) < 0 ) TEST_ERROR; + if ( (fid = H5Fcreate(FILENAME, H5F_ACC_TRUNC, fcpl_id, fapl)) < 0 ) TEST_ERROR; + + if ( H5Pclose(fapl) < 0 ) TEST_ERROR; #ifndef NDEBUG /* if verbose, print cache index to screen before verification . */ @@ -521,6 +527,7 @@ check_file_open_tags(hid_t fcpl, int type) /* Variable Declarations */ hid_t fid = -1; /* File Identifier */ int verbose = FALSE; /* verbose file outout */ + hid_t fapl = -1; /* File access prop list */ haddr_t root_tag; /* Root Group Tag */ haddr_t sbe_tag; /* Sblock Extension Tag */ @@ -531,8 +538,13 @@ check_file_open_tags(hid_t fcpl, int type) /* Setup */ /* ===== */ + /* Create Fapl */ + if ( (fapl = h5_fileaccess()) < 0 ) TEST_ERROR; + /* Create a test file with provided fcpl_t */ - if ( (fid = H5Fcreate(FILENAME, H5F_ACC_TRUNC, fcpl, H5P_DEFAULT)) < 0 ) TEST_ERROR; + if ( (fid = H5Fcreate(FILENAME, H5F_ACC_TRUNC, fcpl, fapl)) < 0 ) TEST_ERROR; + + if ( H5Pclose(fapl) < 0 ) TEST_ERROR; /* determine tag value of root group's object header */ if ( get_object_header_tag(fid, &root_tag) < 0 ) TEST_ERROR; @@ -628,6 +640,7 @@ check_group_creation_tags(void) hid_t fid = -1; /* File Identifier */ hid_t gid = -1; /* Group Identifier */ int verbose = FALSE; /* verbose file outout */ + hid_t fapl = -1; /* File access prop list */ haddr_t root_tag = HADDR_UNDEF; /* Root Group Tag */ haddr_t g_tag; /* Group Tag */ @@ -638,8 +651,13 @@ check_group_creation_tags(void) /* Setup */ /* ===== */ + /* Create Fapl */ + if ( (fapl = h5_fileaccess()) < 0 ) TEST_ERROR; + /* Create a test file with provided fcpl_t */ - if ( (fid = H5Fcreate(FILENAME, H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT)) < 0 ) TEST_ERROR; + if ( (fid = H5Fcreate(FILENAME, H5F_ACC_TRUNC, H5P_DEFAULT, fapl)) < 0 ) TEST_ERROR; + + if ( H5Pclose(fapl) < 0 ) TEST_ERROR; /* determine tag value of root group's object header */ if ( get_object_header_tag(fid, &root_tag) < 0 ) TEST_ERROR; @@ -733,7 +751,7 @@ check_multi_group_creation_tags(void) TESTING("tag application during multiple group creation"); /* Create Fapl */ - if ( (fapl = H5Pcreate(H5P_FILE_ACCESS)) < 0 ) TEST_ERROR; + if ( (fapl = h5_fileaccess()) < 0 ) TEST_ERROR; /* Set latest version of library */ if ( H5Pset_libver_bounds(fapl, H5F_LIBVER_LATEST, H5F_LIBVER_LATEST) < 0 ) TEST_ERROR; @@ -816,6 +834,7 @@ check_multi_group_creation_tags(void) /* Close open objects and file */ /* =========================== */ + if ( H5Pclose(fapl) < 0 ) TEST_ERROR; if ( H5Fclose(fid) < 0 ) TEST_ERROR; /* ========================================== */ @@ -855,15 +874,21 @@ check_link_iteration_tags(void) haddr_t root_tag = 0; /* Root Group Tag Value */ char dsetname[500]; /* Name of dataset */ H5G_info_t ginfo; /* Group Info Struct */ + hid_t fapl = -1; /* File access prop list */ hid_t root_group = -1; /* Root Group Identifier */ /* Testing Macro */ TESTING("tag application during iteration over links in a group"); + /* Create Fapl */ + if ( (fapl = h5_fileaccess()) < 0 ) TEST_ERROR; + /* =========== */ /* Create File */ /* =========== */ - if ( (fid = H5Fcreate(FILENAME, H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT)) < 0 ) TEST_ERROR; + if ( (fid = H5Fcreate(FILENAME, H5F_ACC_TRUNC, H5P_DEFAULT, fapl)) < 0 ) TEST_ERROR; + + if ( H5Pclose(fapl) < 0 ) TEST_ERROR; /* Get root group tag */ if ( get_object_header_tag(fid, &root_tag) < 0 ) TEST_ERROR; @@ -975,7 +1000,7 @@ check_dense_attribute_tags(void) TESTING("tag application during dense attribute manipulation"); /* Create Fapl */ - if ( (fapl = H5Pcreate(H5P_FILE_ACCESS)) < 0 ) TEST_ERROR; + if ( (fapl = h5_fileaccess()) < 0 ) TEST_ERROR; if ( H5Pset_libver_bounds(fapl, H5F_LIBVER_LATEST, H5F_LIBVER_LATEST) < 0 ) TEST_ERROR; /* Create Dcpl */ @@ -986,6 +1011,8 @@ check_dense_attribute_tags(void) /* =========== */ if ( (fid = H5Fcreate(FILENAME, H5F_ACC_TRUNC, H5P_DEFAULT, fapl)) < 0 ) TEST_ERROR; + if ( H5Pclose(fapl) < 0 ) TEST_ERROR; + /* determine tag value of root group's object header */ if ( get_object_header_tag(fid, &root_tag) < 0 ) TEST_ERROR; @@ -1145,6 +1172,7 @@ check_group_open_tags(void) hid_t fid = -1; /* File Identifier */ hid_t gid = -1; /* Group Identifier */ int verbose = FALSE; /* verbose file output */ + hid_t fapl = -1; /* File access prop list */ haddr_t root_tag = HADDR_UNDEF; haddr_t g_tag; @@ -1155,8 +1183,13 @@ check_group_open_tags(void) /* Setup */ /* ===== */ + /* Create Fapl */ + if ( (fapl = h5_fileaccess()) < 0 ) TEST_ERROR; + /* Create a test file with provided fcpl_t */ - if ( (fid = H5Fcreate(FILENAME, H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT)) < 0 ) TEST_ERROR; + if ( (fid = H5Fcreate(FILENAME, H5F_ACC_TRUNC, H5P_DEFAULT, fapl)) < 0 ) TEST_ERROR; + + if ( H5Pclose(fapl) < 0 ) TEST_ERROR; /* determine tag value of root group's object header */ if ( get_object_header_tag(fid, &root_tag) < 0 ) TEST_ERROR; @@ -1248,6 +1281,7 @@ check_attribute_creation_tags(hid_t fcpl, int type) hid_t gid = -1; /* Group Identifier */ hid_t sid = -1; /* Dataspace Identifier */ int verbose = FALSE; /* verbose file outout */ + hid_t fapl = -1; /* File access prop list */ haddr_t root_tag = 0; /* Root group tag */ haddr_t g_tag = 0; hsize_t dims1[2] = {DIMS, DIMS}; /* dimensions */ @@ -1260,8 +1294,11 @@ check_attribute_creation_tags(hid_t fcpl, int type) /* Setup */ /* ===== */ + /* Create Fapl */ + if ( (fapl = h5_fileaccess()) < 0 ) TEST_ERROR; + /* Create a test file with provided fcpl_t */ - if ( (fid = H5Fcreate(FILENAME, H5F_ACC_TRUNC, fcpl, H5P_DEFAULT)) < 0 ) TEST_ERROR; + if ( (fid = H5Fcreate(FILENAME, H5F_ACC_TRUNC, fcpl, fapl)) < 0 ) TEST_ERROR; /* determine tag value of root group's object header */ if ( get_object_header_tag(fid, &root_tag) < 0 ) TEST_ERROR; @@ -1341,6 +1378,7 @@ check_attribute_creation_tags(hid_t fcpl, int type) if ( H5Aclose(aid) < 0 ) TEST_ERROR; if ( H5Gclose(gid) < 0 ) TEST_ERROR; + if ( H5Pclose(fapl) < 0 ) TEST_ERROR; if ( H5Fclose(fid) < 0 ) TEST_ERROR; /* ========================================== */ @@ -1377,6 +1415,7 @@ check_attribute_open_tags(hid_t fcpl, int type) hid_t gid = -1; /* Group Identifier */ hid_t sid = -1; /* Dataspace Identifier */ int verbose = FALSE; /* verbose file outout */ + hid_t fapl = -1; /* File access prop list */ haddr_t root_tag = 0; haddr_t g_tag = 0; hsize_t dims1[2] = {DIMS, DIMS}; /* dimensions */ @@ -1389,8 +1428,13 @@ check_attribute_open_tags(hid_t fcpl, int type) /* Setup */ /* ===== */ + /* Create Fapl */ + if ( (fapl = h5_fileaccess()) < 0 ) TEST_ERROR; + /* Create a test file with provided fcpl_t */ - if ( (fid = H5Fcreate(FILENAME, H5F_ACC_TRUNC, fcpl, H5P_DEFAULT)) < 0 ) TEST_ERROR; + if ( (fid = H5Fcreate(FILENAME, H5F_ACC_TRUNC, fcpl, fapl)) < 0 ) TEST_ERROR; + + if ( H5Pclose(fapl) < 0 ) TEST_ERROR; /* determine tag value of root group's object header */ if ( get_object_header_tag(fid, &root_tag) < 0 ) TEST_ERROR; @@ -1510,6 +1554,7 @@ check_attribute_rename_tags(hid_t fcpl, int type) int verbose = FALSE; /* verbose file outout */ int *data = NULL; /* data buffer */ int i,j,k = 0; /* iterators */ + hid_t fapl = -1; /* File access prop list */ haddr_t root_tag = 0; haddr_t g_tag = 0; hsize_t dims1[2] = {DIMS, DIMS}; /* dimensions */ @@ -1530,8 +1575,13 @@ check_attribute_rename_tags(hid_t fcpl, int type) /* Allocate array */ if ( (NULL == (data = (int *)HDcalloc(DIMS * DIMS, sizeof(int)))) ) TEST_ERROR; + /* Create Fapl */ + if ( (fapl = h5_fileaccess()) < 0 ) TEST_ERROR; + /* Create a test file with provided fcpl_t */ - if ( (fid = H5Fcreate(FILENAME, H5F_ACC_TRUNC, fcpl, H5P_DEFAULT)) < 0 ) TEST_ERROR; + if ( (fid = H5Fcreate(FILENAME, H5F_ACC_TRUNC, fcpl, fapl)) < 0 ) TEST_ERROR; + + if ( H5Pclose(fapl) < 0 ) TEST_ERROR; /* determine tag value of root group's object header */ if ( get_object_header_tag(fid, &root_tag) < 0 ) TEST_ERROR; @@ -1689,6 +1739,7 @@ check_attribute_delete_tags(hid_t fcpl, int type) int verbose = FALSE; /* verbose file outout */ int *data = NULL; /* data buffer */ int i,j,k = 0; /* iterators */ + hid_t fapl = -1; /* File access prop list */ haddr_t root_tag = 0; haddr_t g_tag = 0; hsize_t dims1[2] = {DIMS, DIMS}; /* dimensions */ @@ -1709,8 +1760,13 @@ check_attribute_delete_tags(hid_t fcpl, int type) /* Allocate array */ if ( (NULL == (data = (int *)HDcalloc(DIMS * DIMS, sizeof(int)))) ) TEST_ERROR; + /* Create Fapl */ + if ( (fapl = h5_fileaccess()) < 0 ) TEST_ERROR; + /* Create a test file with provided fcpl_t */ - if ( (fid = H5Fcreate(FILENAME, H5F_ACC_TRUNC, fcpl, H5P_DEFAULT)) < 0 ) TEST_ERROR; + if ( (fid = H5Fcreate(FILENAME, H5F_ACC_TRUNC, fcpl, fapl)) < 0 ) TEST_ERROR; + + if ( H5Pclose(fapl) < 0 ) TEST_ERROR; /* determine tag value of root group's object header */ if ( get_object_header_tag(fid, &root_tag) < 0 ) TEST_ERROR; @@ -1847,6 +1903,7 @@ check_dataset_creation_tags(hid_t fcpl, int type) hid_t dcpl = -1; /* dataset creation pl */ hsize_t cdims[2] = {1,1}; /* chunk dimensions */ int fillval = 0; + hid_t fapl = -1; /* File access prop list */ haddr_t root_tag = 0; haddr_t d_tag = 0; hsize_t dims1[2] = {DIMS, DIMS}; /* dimensions */ @@ -1859,7 +1916,12 @@ check_dataset_creation_tags(hid_t fcpl, int type) /* Setup */ /* ===== */ - if ( (fid = H5Fcreate(FILENAME, H5F_ACC_TRUNC, fcpl, H5P_DEFAULT)) < 0 ) TEST_ERROR; + /* Create Fapl */ + if ( (fapl = h5_fileaccess()) < 0 ) TEST_ERROR; + + if ( (fid = H5Fcreate(FILENAME, H5F_ACC_TRUNC, fcpl, fapl)) < 0 ) TEST_ERROR; + + if ( H5Pclose(fapl) < 0 ) TEST_ERROR; /* determine tag value of root group's object header */ if ( get_object_header_tag(fid, &root_tag) < 0 ) TEST_ERROR; @@ -1974,6 +2036,7 @@ check_dataset_creation_earlyalloc_tags(hid_t fcpl, int type) hid_t dcpl = -1; /* dataset creation pl */ hsize_t cdims[2] = {1,1}; /* chunk dimensions */ int fillval = 0; + hid_t fapl = -1; /* File access prop list */ haddr_t root_tag = 0; haddr_t d_tag = 0; hsize_t dims1[2] = {DIMS, DIMS}; /* dimensions */ @@ -1987,7 +2050,12 @@ check_dataset_creation_earlyalloc_tags(hid_t fcpl, int type) /* Setup */ /* ===== */ - if ( (fid = H5Fcreate(FILENAME, H5F_ACC_TRUNC, fcpl, H5P_DEFAULT)) < 0 ) TEST_ERROR; + /* Create Fapl */ + if ( (fapl = h5_fileaccess()) < 0 ) TEST_ERROR; + + if ( (fid = H5Fcreate(FILENAME, H5F_ACC_TRUNC, fcpl, fapl)) < 0 ) TEST_ERROR; + + if ( H5Pclose(fapl) < 0 ) TEST_ERROR; /* determine tag value of root group's object header */ if ( get_object_header_tag(fid, &root_tag) < 0 ) TEST_ERROR; @@ -2105,6 +2173,7 @@ check_dataset_open_tags(void) hid_t dcpl = -1; /* dataset creation pl */ hsize_t cdims[2] = {1,1}; /* chunk dimensions */ int fillval = 0; + hid_t fapl = -1; /* File access prop list */ haddr_t root_tag = 0; haddr_t d_tag = 0; hsize_t dims1[2] = {DIMS, DIMS}; /* dimensions */ @@ -2117,8 +2186,13 @@ check_dataset_open_tags(void) /* Open File */ /* ========= */ + /* Create Fapl */ + if ( (fapl = h5_fileaccess()) < 0 ) TEST_ERROR; + /* Create file */ - if ( (fid = H5Fcreate(FILENAME, H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT)) < 0 ) TEST_ERROR; + if ( (fid = H5Fcreate(FILENAME, H5F_ACC_TRUNC, H5P_DEFAULT, fapl)) < 0 ) TEST_ERROR; + + if ( H5Pclose(fapl) < 0 ) TEST_ERROR; /* determine tag value of root group's object header */ if ( get_object_header_tag(fid, &root_tag) < 0 ) TEST_ERROR; @@ -2225,6 +2299,7 @@ check_dataset_write_tags(void) hid_t dcpl = -1; /* dataset creation pl */ hsize_t cdims[2] = {1,1}; /* chunk dimensions */ int fillval = 0; + hid_t fapl = -1; /* File access prop list */ haddr_t root_tag = 0; haddr_t d_tag = 0; hsize_t dims1[2] = {DIMS, DIMS}; /* dimensions */ @@ -2242,8 +2317,13 @@ check_dataset_write_tags(void) /* Allocate array */ if ( (NULL == (data = (int *)HDcalloc(DIMS * DIMS, sizeof(int)))) ) TEST_ERROR; + /* Create Fapl */ + if ( (fapl = h5_fileaccess()) < 0 ) TEST_ERROR; + /* Create file */ - if ( (fid = H5Fcreate(FILENAME, H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT)) < 0 ) TEST_ERROR; + if ( (fid = H5Fcreate(FILENAME, H5F_ACC_TRUNC, H5P_DEFAULT, fapl)) < 0 ) TEST_ERROR; + + if ( H5Pclose(fapl) < 0 ) TEST_ERROR; /* determine tag value of root group's object header */ if ( get_object_header_tag(fid, &root_tag) < 0 ) TEST_ERROR; @@ -2360,6 +2440,7 @@ check_attribute_write_tags(hid_t fcpl, int type) int verbose = FALSE; /* verbose file outout */ int *data = NULL; /* data buffer */ int i,j,k = 0; /* iterators */ + hid_t fapl = -1; /* File access prop list */ haddr_t root_tag = 0; haddr_t g_tag = 0; hsize_t dims1[2] = {DIMS, DIMS}; /* dimensions */ @@ -2375,8 +2456,13 @@ check_attribute_write_tags(hid_t fcpl, int type) /* Allocate array */ if ( (NULL == (data = (int *)HDcalloc(DIMS * DIMS, sizeof(int)))) ) TEST_ERROR; + /* Create Fapl */ + if ( (fapl = h5_fileaccess()) < 0 ) TEST_ERROR; + /* Create a test file with provided fcpl_t */ - if ( (fid = H5Fcreate(FILENAME, H5F_ACC_TRUNC, fcpl, H5P_DEFAULT)) < 0 ) TEST_ERROR; + if ( (fid = H5Fcreate(FILENAME, H5F_ACC_TRUNC, fcpl, fapl)) < 0 ) TEST_ERROR; + + if ( H5Pclose(fapl) < 0 ) TEST_ERROR; /* determine tag value of root group's object header */ if ( get_object_header_tag(fid, &root_tag) < 0 ) TEST_ERROR; @@ -2508,6 +2594,7 @@ check_dataset_read_tags(void) hid_t dcpl = -1; /* dataset creation pl */ hsize_t cdims[2] = {1,1}; /* chunk dimensions */ int fillval = 0; + hid_t fapl = -1; /* File access prop list */ haddr_t root_tag = 0; haddr_t d_tag = 0; hsize_t dims1[2] = {DIMS, DIMS}; /* dimensions */ @@ -2525,8 +2612,13 @@ check_dataset_read_tags(void) /* Allocate array */ if ( (NULL == (data = (int *)HDcalloc(DIMS * DIMS, sizeof(int)))) ) TEST_ERROR; + /* Create Fapl */ + if ( (fapl = h5_fileaccess()) < 0 ) TEST_ERROR; + /* Create file */ - if ( (fid = H5Fcreate(FILENAME, H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT)) < 0 ) TEST_ERROR; + if ( (fid = H5Fcreate(FILENAME, H5F_ACC_TRUNC, H5P_DEFAULT, fapl)) < 0 ) TEST_ERROR; + + if ( H5Pclose(fapl) < 0 ) TEST_ERROR; /* determine tag value of root group's object header */ if ( get_object_header_tag(fid, &root_tag) < 0 ) TEST_ERROR; @@ -2639,6 +2731,7 @@ check_dataset_size_retrieval(void) hid_t dcpl = -1; /* dataset creation pl */ hsize_t cdims[2] = {1,1}; /* chunk dimensions */ int fillval = 0; + hid_t fapl = -1; /* File access prop list */ haddr_t root_tag = 0; haddr_t d_tag = 0; hsize_t dims1[2] = {DIMS, DIMS}; /* dimensions */ @@ -2657,8 +2750,13 @@ check_dataset_size_retrieval(void) /* Allocate array */ if ( (NULL == (data = (int *)HDcalloc(DIMS * DIMS, sizeof(int)))) ) TEST_ERROR; + /* Create Fapl */ + if ( (fapl = h5_fileaccess()) < 0 ) TEST_ERROR; + /* Create file */ - if ( (fid = H5Fcreate(FILENAME, H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT)) < 0 ) TEST_ERROR; + if ( (fid = H5Fcreate(FILENAME, H5F_ACC_TRUNC, H5P_DEFAULT, fapl)) < 0 ) TEST_ERROR; + + if ( H5Pclose(fapl) < 0 ) TEST_ERROR; /* determine tag value of root group's object header */ if ( get_object_header_tag(fid, &root_tag) < 0 ) TEST_ERROR; @@ -2772,6 +2870,7 @@ check_dataset_extend_tags(void) hid_t dcpl = -1; /* dataset creation pl */ hsize_t cdims[2] = {1,1}; /* chunk dimensions */ int fillval = 0; + hid_t fapl = -1; /* File access prop list */ haddr_t root_tag = 0; haddr_t d_tag = 0; hsize_t dims1[2] = {DIMS, DIMS}; /* dimensions */ @@ -2790,8 +2889,13 @@ check_dataset_extend_tags(void) /* Allocate array */ if ( (NULL == (data = (int *)HDcalloc(DIMS * DIMS, sizeof(int)))) ) TEST_ERROR; + /* Create Fapl */ + if ( (fapl = h5_fileaccess()) < 0 ) TEST_ERROR; + /* Create file */ - if ( (fid = H5Fcreate(FILENAME, H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT)) < 0 ) TEST_ERROR; + if ( (fid = H5Fcreate(FILENAME, H5F_ACC_TRUNC, H5P_DEFAULT, fapl)) < 0 ) TEST_ERROR; + + if ( H5Pclose(fapl) < 0 ) TEST_ERROR; /* determine tag value of root group's object header */ if ( get_object_header_tag(fid, &root_tag) < 0 ) TEST_ERROR; @@ -2900,6 +3004,7 @@ check_object_info_tags(void) hid_t fid = -1; /* File Identifier */ hid_t gid = -1; /* Group Identifier */ int verbose = FALSE; /* verbose file output */ + hid_t fapl = -1; /* File access prop list */ haddr_t root_tag = HADDR_UNDEF; haddr_t g_tag; H5O_info_t oinfo; /* Object info struct */ @@ -2911,8 +3016,13 @@ check_object_info_tags(void) /* Setup */ /* ===== */ + /* Create Fapl */ + if ( (fapl = h5_fileaccess()) < 0 ) TEST_ERROR; + /* Create a test file */ - if ( (fid = H5Fcreate(FILENAME, H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT)) < 0 ) TEST_ERROR; + if ( (fid = H5Fcreate(FILENAME, H5F_ACC_TRUNC, H5P_DEFAULT, fapl)) < 0 ) TEST_ERROR; + + if ( H5Pclose(fapl) < 0 ) TEST_ERROR; /* determine tag value of root group's object header */ if ( get_object_header_tag(fid, &root_tag) < 0 ) TEST_ERROR; @@ -3003,6 +3113,7 @@ check_object_copy_tags(void) hid_t fid = -1; /* File Identifier */ hid_t gid = -1; /* Group Identifier */ int verbose = FALSE; /* verbose file output */ + hid_t fapl = -1; /* File access prop list */ haddr_t root_tag = HADDR_UNDEF; haddr_t g_tag; haddr_t copy_tag; @@ -3014,8 +3125,13 @@ check_object_copy_tags(void) /* Setup */ /* ===== */ + /* Create Fapl */ + if ( (fapl = h5_fileaccess()) < 0 ) TEST_ERROR; + /* Create a test file */ - if ( (fid = H5Fcreate(FILENAME, H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT)) < 0 ) TEST_ERROR; + if ( (fid = H5Fcreate(FILENAME, H5F_ACC_TRUNC, H5P_DEFAULT, fapl)) < 0 ) TEST_ERROR; + + if ( H5Pclose(fapl) < 0 ) TEST_ERROR; /* determine tag value of root group's object header */ if ( get_object_header_tag(fid, &root_tag) < 0 ) TEST_ERROR; @@ -3121,6 +3237,7 @@ check_link_removal_tags(hid_t fcpl, int type) hid_t dcpl = -1; /* dataset creation pl */ hsize_t cdims[2] = {1,1}; /* chunk dimensions */ int fillval = 0; + hid_t fapl = -1; /* File access prop list */ haddr_t root_tag = 0; haddr_t d_tag = 0; haddr_t g_tag = 0; @@ -3139,8 +3256,13 @@ check_link_removal_tags(hid_t fcpl, int type) /* Allocate array */ if ( (NULL == (data = (int *)HDcalloc(DIMS * DIMS, sizeof(int)))) ) TEST_ERROR; + /* Create Fapl */ + if ( (fapl = h5_fileaccess()) < 0 ) TEST_ERROR; + /* Create file */ - if ( (fid = H5Fcreate(FILENAME, H5F_ACC_TRUNC, fcpl, H5P_DEFAULT)) < 0 ) TEST_ERROR; + if ( (fid = H5Fcreate(FILENAME, H5F_ACC_TRUNC, fcpl, fapl)) < 0 ) TEST_ERROR; + + if ( H5Pclose(fapl) < 0 ) TEST_ERROR; /* determine tag value of root group's object header */ if ( get_object_header_tag(fid, &root_tag) < 0 ) TEST_ERROR; @@ -3274,6 +3396,7 @@ check_link_getname_tags(void) hid_t dcpl = -1; /* dataset creation pl */ hsize_t cdims[2] = {1,1}; /* chunk dimensions */ int fillval = 0; + hid_t fapl = -1; /* File access prop list */ haddr_t root_tag = 0; haddr_t d_tag = 0; haddr_t g_tag = 0; @@ -3292,8 +3415,13 @@ check_link_getname_tags(void) /* Allocate array */ if ( (NULL == (data = (int *)HDcalloc(DIMS * DIMS, sizeof(int)))) ) TEST_ERROR; + /* Create Fapl */ + if ( (fapl = h5_fileaccess()) < 0 ) TEST_ERROR; + /* Create file */ - if ( (fid = H5Fcreate(FILENAME, H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT)) < 0 ) TEST_ERROR; + if ( (fid = H5Fcreate(FILENAME, H5F_ACC_TRUNC, H5P_DEFAULT, fapl)) < 0 ) TEST_ERROR; + + if ( H5Pclose(fapl) < 0 ) TEST_ERROR; /* determine tag value of root group's object header */ if ( get_object_header_tag(fid, &root_tag) < 0 ) TEST_ERROR; @@ -3414,6 +3542,7 @@ check_external_link_creation_tags(void) hid_t fid2 = -1; /* File Identifier */ hid_t gid = -1; /* Dataspace Identifier */ int verbose = FALSE; /* verbose file outout */ + hid_t fapl = -1; /* File access prop list */ haddr_t root_tag = 0; /* Testing Macro */ @@ -3423,21 +3552,26 @@ check_external_link_creation_tags(void) /* Setup */ /* ===== */ + /* Create Fapl */ + if ( (fapl = h5_fileaccess()) < 0 ) TEST_ERROR; + /* Create a test file */ - if ( (fid = H5Fcreate(FILENAME, H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT)) < 0 ) TEST_ERROR; + if ( (fid = H5Fcreate(FILENAME, H5F_ACC_TRUNC, H5P_DEFAULT, fapl)) < 0 ) TEST_ERROR; /* determine tag value of root group's object header */ if ( get_object_header_tag(fid, &root_tag) < 0 ) TEST_ERROR; /* Close and Reopen the file */ if ( H5Fclose(fid) < 0 ) TEST_ERROR; - if ( (fid = H5Fopen(FILENAME, H5F_ACC_RDWR, H5P_DEFAULT)) < 0 ) TEST_ERROR; + if ( (fid = H5Fopen(FILENAME, H5F_ACC_RDWR, fapl)) < 0 ) TEST_ERROR; /* Evict as much as we can from the cache so we can track full tag path */ if ( evict_entries(fid) < 0 ) TEST_ERROR; /* Create a second file */ - if ( (fid2 = H5Fcreate(FILENAME2, H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT)) < 0 ) TEST_ERROR; + if ( (fid2 = H5Fcreate(FILENAME2, H5F_ACC_TRUNC, H5P_DEFAULT, fapl)) < 0 ) TEST_ERROR; + + if ( H5Pclose(fapl) < 0 ) TEST_ERROR; /* Create group in second file */ if ( (gid = H5Gcreate2(fid2, GROUPNAME, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0 ) TEST_ERROR; @@ -3514,6 +3648,7 @@ check_external_link_open_tags(void) hid_t gid = -1; /* Dataspace Identifier */ hid_t xid = -1; /* Dataspace Identifier */ int verbose = FALSE; /* verbose file outout */ + hid_t fapl = -1; /* File access prop list */ haddr_t root_tag = 0; haddr_t root2_tag = 0; @@ -3524,14 +3659,19 @@ check_external_link_open_tags(void) /* Setup */ /* ===== */ + /* Create Fapl */ + if ( (fapl = h5_fileaccess()) < 0 ) TEST_ERROR; + /* Create a test file */ - if ( (fid = H5Fcreate(FILENAME, H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT)) < 0 ) TEST_ERROR; + if ( (fid = H5Fcreate(FILENAME, H5F_ACC_TRUNC, H5P_DEFAULT, fapl)) < 0 ) TEST_ERROR; /* determine tag value of root group's object header */ if ( get_object_header_tag(fid, &root_tag) < 0 ) TEST_ERROR; /* Create a second file */ - if ( (fid2 = H5Fcreate(FILENAME2, H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT)) < 0 ) TEST_ERROR; + if ( (fid2 = H5Fcreate(FILENAME2, H5F_ACC_TRUNC, H5P_DEFAULT, fapl)) < 0 ) TEST_ERROR; + + if ( H5Pclose(fapl) < 0 ) TEST_ERROR; /* determine tag value of root group's object header */ if ( get_object_header_tag(fid2, &root2_tag) < 0 ) TEST_ERROR; @@ -3638,6 +3778,7 @@ check_invalid_tag_application(void) hid_t fid = -1; haddr_t addr; H5HL_t * lheap = NULL; + hid_t fapl = -1; /* File access prop list */ hbool_t api_ctx_pushed = FALSE; /* Whether API context pushed */ #endif /* H5C_DO_TAGGING_SANITY_CHECKS */ @@ -3645,8 +3786,13 @@ check_invalid_tag_application(void) TESTING("failure on invalid tag application"); #if H5C_DO_TAGGING_SANITY_CHECKS + /* Create Fapl */ + if ( (fapl = h5_fileaccess()) < 0 ) TEST_ERROR; + /* Create a test file */ - if ( (fid = H5Fcreate(FILENAME, H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT)) < 0 ) TEST_ERROR; + if ( (fid = H5Fcreate(FILENAME, H5F_ACC_TRUNC, H5P_DEFAULT, fapl)) < 0 ) TEST_ERROR; + + if ( H5Pclose(fapl) < 0 ) TEST_ERROR; /* Push API context */ if(H5CX_push() < 0) TEST_ERROR diff --git a/test/chunk_info.c b/test/chunk_info.c deleted file mode 100644 index e3006cc..0000000 --- a/test/chunk_info.c +++ /dev/null @@ -1,150 +0,0 @@ -/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * - * Copyright by The HDF Group. * - * Copyright by the Board of Trustees of the University of Illinois. * - * 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 COPYING file, which can be found at the root of the source code * - * distribution tree, or in https://support.hdfgroup.org/ftp/HDF5/releases. * - * If you do not have access to either file, you may request a copy from * - * help@hdfgroup.org. * - * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ - -/* - * Programmer: Pedro Vicente <pvn@hdfgroup.edu> - * April 7, 2008 - * - * Purpose: Tests the H5Dget_chunk_info API function - * This program writes a 4x4 dataset by iterating on 2x2 chunks - * at a time - */ - - -#include "h5test.h" - -#define PRINT_DATA -#define H5FILE_NAME "chunk_info.h5" -#define DATASETNAME "2d" -#define RANK 2 - - -int main( void ) -{ - - hid_t fid; /* file ID */ - hid_t did; /* dataset ID */ - hid_t f_sid; /* file space ID */ - hid_t m_sid; /* memory space ID */ - hid_t pid; /* property list ID */ - hsize_t start[2]; /* chunk location to start writing */ - hsize_t dims[2] = { 4, 4}; - hsize_t chunk_dims[2] = { 2, 2 }; - int chunk_data[2][2] = { {1, 1}, {1, 1} }; - int buf[4][4]; - int fillvalue = 0; - int i, j, ii, jj; - - /* create a new file using default properties. */ - if ((fid = H5Fcreate(H5FILE_NAME, H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT)) < 0) TEST_ERROR; - /* create the file space */ - if ((f_sid = H5Screate_simple(RANK, dims, dims)) < 0) TEST_ERROR; - /* create the memory space with chunk dimensions */ - if ((m_sid = H5Screate_simple(RANK, chunk_dims, chunk_dims)) < 0) TEST_ERROR; - start[0] = 0; - start[1] = 0; - if (H5Sselect_hyperslab(m_sid, H5S_SELECT_SET, start, NULL, chunk_dims, NULL) < 0) TEST_ERROR; - - TESTING("chunk info"); - - /*------------------------------------------------------------------------- - * create a dataset - *------------------------------------------------------------------------- - */ - - /* modify dataset creation properties, i.e. enable chunking. */ - if ((pid = H5Pcreate (H5P_DATASET_CREATE)) < 0) TEST_ERROR; - if (H5Pset_chunk(pid, RANK, chunk_dims) < 0) TEST_ERROR; - if (H5Pset_fill_value(pid, H5T_NATIVE_INT, &fillvalue) < 0) TEST_ERROR; - - /* create a new dataset */ - if((did = H5Dcreate2(fid , DATASETNAME, H5T_NATIVE_INT, f_sid, H5P_DEFAULT, pid, H5P_DEFAULT)) < 0) TEST_ERROR; - - - /*------------------------------------------------------------------------- - * write the dataset in 2x2 chunks - *------------------------------------------------------------------------- - */ - - /* iterate in dim 0 */ - for (j = 0; j < chunk_dims[0]; j++) - { - - /* reset start in dim 1 */ - start[1] = 0; - - /* iterate in dim 1 */ - for (i = 0; i < chunk_dims[1]; i++) - { - - /* select file hyperslab to save a 2x2 chunk */ - if (H5Sselect_hyperslab(f_sid, H5S_SELECT_SET, start, NULL, chunk_dims, NULL) < 0) TEST_ERROR; - - /* write the data to the hyperslab. */ - if (H5Dwrite(did, H5T_NATIVE_INT, m_sid, f_sid, H5P_DEFAULT, chunk_data) < 0) TEST_ERROR; - - /* read back and display complete dataset 4x4 */ - if (H5Dread(did, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, H5P_DEFAULT, buf) < 0) TEST_ERROR; - - -#if defined (PRINT_DATA) - printf("\n"); - printf("dataset: \n"); - for (jj = 0; jj < dims[0]; jj++) { - for (ii = 0; ii < dims[1]; ii++) printf("%d ", buf[jj][ii]); - printf("\n"); - } -#endif - - - /* increment start in dim 1 */ - start[1] += 2; - - - } - - /* increment start in dim 0 */ - start[0] += 2; - } - - - - /*------------------------------------------------------------------------- - * close - *------------------------------------------------------------------------- - */ - - if (H5Dclose(did) < 0) TEST_ERROR - if (H5Sclose(f_sid) < 0) TEST_ERROR - if (H5Sclose(m_sid) < 0) TEST_ERROR - if (H5Pclose(pid) < 0) TEST_ERROR - if (H5Fclose(fid) < 0) TEST_ERROR - - PASSED(); - - puts("All chunk info tests passed."); - return 0; - - -error: - H5Dclose( did ); - H5Sclose( f_sid ); - H5Sclose( m_sid ); - H5Pclose( pid ); - H5Fclose( fid ); - H5_FAILED(); - return 1; -} - - - diff --git a/test/cmpd_dset.c b/test/cmpd_dset.c index 5d6cfc7..b011bc2 100644 --- a/test/cmpd_dset.c +++ b/test/cmpd_dset.c @@ -2032,7 +2032,7 @@ error: *------------------------------------------------------------------------- */ static unsigned -test_ooo_order(char *filename) +test_ooo_order(char *filename, hid_t fapl_id) { hid_t file = -1; /* File ID */ hid_t dtype = -1; /* Datatype IDs */ @@ -2042,7 +2042,7 @@ test_ooo_order(char *filename) TESTING("that compound member insertion order is preserved") /* Create the file */ - if ((file = H5Fcreate (filename, H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT)) < 0) + if ((file = H5Fcreate (filename, H5F_ACC_TRUNC, H5P_DEFAULT, fapl_id)) < 0) TEST_ERROR /* Create the compound */ @@ -2242,7 +2242,7 @@ main (int argc, char *argv[]) nerrors += test_pack_ooo(); puts("Testing compound member ordering:"); - nerrors += test_ooo_order(fname); + nerrors += test_ooo_order(fname, fapl_id); /* Verify symbol table messages are cached */ nerrors += (h5_verify_cached_stabs(FILENAME, fapl_id) < 0 ? 1 : 0); diff --git a/test/dsets.c b/test/dsets.c index 050bd8f..5cd376a 100644 --- a/test/dsets.c +++ b/test/dsets.c @@ -826,7 +826,7 @@ test_compact_io(hid_t fapl) **************************************/ /* Create a copy of file access property list */ - if((new_fapl = H5Pcreate(H5P_FILE_ACCESS)) < 0) TEST_ERROR + if((new_fapl = new_fapl = h5_fileaccess()) < 0) TEST_ERROR /* Loop through all the combinations of low/high library format bounds, skipping invalid combinations. @@ -1334,6 +1334,19 @@ test_conv_buffer(hid_t fid) return 0; error: + H5E_BEGIN_TRY { + H5Pclose(xfer_list); + H5Sclose(space); + H5Tclose(arr_type1); + H5Tclose(arr_type2); + H5Tclose(arr_type3); + H5Tclose(ctype1); + H5Tclose(ctype2); + H5Tclose(arr_type4); + H5Tclose(arr_type5); + H5Dclose(dataset); + } H5E_END_TRY; + return -1; } diff --git a/test/dtypes.c b/test/dtypes.c index 3253d6c..7e5a992 100644 --- a/test/dtypes.c +++ b/test/dtypes.c @@ -6957,13 +6957,13 @@ test_delete_obj_named_fileid(hid_t fapl) /* Verify file ID from dataset matches correct file */ dset_fid = H5Iget_file_id(dset); - if(dset_fid != filea1) TEST_ERROR + if(!H5F__same_file_test(dset_fid, filea1)) TEST_ERROR H5Fclose(dset_fid); /* Verify file ID from datatype (from dataset) matches correct file */ type = H5Dget_type(dset); type_fid = H5Iget_file_id(type); - if(type_fid != filea1) TEST_ERROR + if(!H5F__same_file_test(type_fid, filea1)) TEST_ERROR H5Fclose(type_fid); H5Tclose(type); @@ -6979,13 +6979,13 @@ test_delete_obj_named_fileid(hid_t fapl) /* Verify file ID from dataset matches correct file */ dset_fid = H5Iget_file_id(dset); - if(dset_fid != filea1) TEST_ERROR + if(!H5F__same_file_test(dset_fid, filea1)) TEST_ERROR H5Fclose(dset_fid); /* Verify file ID from datatype (from dataset) matches correct file */ type = H5Dget_type(dset); type_fid = H5Iget_file_id(type); - if(type_fid != filea1) TEST_ERROR + if(!H5F__same_file_test(type_fid, filea1)) TEST_ERROR H5Fclose(type_fid); H5Tclose(type); @@ -7007,13 +7007,13 @@ test_delete_obj_named_fileid(hid_t fapl) /* Verify file ID from dataset matches correct file */ attr_fid = H5Iget_file_id(attr); - if(attr_fid != filea1) TEST_ERROR + if(!H5F__same_file_test(attr_fid, filea1)) TEST_ERROR H5Fclose(attr_fid); /* Verify file ID from datatype (from dataset) matches correct file */ type = H5Aget_type(attr); type_fid = H5Iget_file_id(type); - if(type_fid != filea1) TEST_ERROR + if(!H5F__same_file_test(type_fid, filea1)) TEST_ERROR H5Fclose(type_fid); H5Tclose(type); @@ -7029,13 +7029,13 @@ test_delete_obj_named_fileid(hid_t fapl) /* Verify file ID from dataset matches correct file */ attr_fid = H5Iget_file_id(attr); - if(attr_fid != filea1) TEST_ERROR + if(!H5F__same_file_test(attr_fid, filea1)) TEST_ERROR H5Fclose(attr_fid); /* Verify file ID from datatype (from dataset) matches correct file */ type = H5Aget_type(attr); type_fid = H5Iget_file_id(type); - if(type_fid != filea1) TEST_ERROR + if(!H5F__same_file_test(type_fid, filea1)) TEST_ERROR H5Fclose(type_fid); H5Tclose(type); diff --git a/test/echo_vol.c b/test/echo_vol.c index 02c0fb3..7f59832 100644 --- a/test/echo_vol.c +++ b/test/echo_vol.c @@ -23,11 +23,19 @@ static const H5VL_class_t echo_vol_g = { 0, /* version */ (H5VL_class_value_t)501, /* value */ "echo", /* name */ + 0, /* capability flags */ NULL, /* initialize */ NULL, /* terminate */ - (size_t)0, /* fapl size */ - NULL, /* fapl copy */ - NULL, /* fapl free */ + (size_t)0, /* info size */ + NULL, /* info copy */ + NULL, /* info compare */ + NULL, /* info free */ + NULL, /* info to str */ + NULL, /* str to info */ + NULL, /* get_object */ + NULL, /* get_wrap_ctx */ + NULL, /* wrap_object */ + NULL, /* free_wrap_ctx */ { /* attribute_cls */ NULL, /* create */ NULL, /* open */ @@ -87,10 +95,13 @@ static const H5VL_class_t echo_vol_g = { NULL, /* specific */ NULL /* optional */ }, - { /* async_cls */ + { /* request_cls */ + NULL, /* wait */ + NULL, /* notify */ NULL, /* cancel */ - NULL, /* test */ - NULL /* wait */ + NULL, /* specific */ + NULL, /* optional */ + NULL /* free */ }, NULL /* optional */ }; diff --git a/test/enc_dec_plist.c b/test/enc_dec_plist.c index 36db2d0..dc9a62e 100644 --- a/test/enc_dec_plist.c +++ b/test/enc_dec_plist.c @@ -460,8 +460,6 @@ main(void) FAIL_STACK_ERROR if((H5Pset_mdc_image_config(fapl, &my_cache_image_config)) < 0) FAIL_STACK_ERROR - if((H5Pset_core_write_tracking(fapl, TRUE, 1024 * 1024)) < 0) - FAIL_STACK_ERROR /* Test encoding & decoding property list */ if(test_encode_decode(fapl) < 0) diff --git a/test/file_image.c b/test/file_image.c index 12f0a18..0dba236 100644 --- a/test/file_image.c +++ b/test/file_image.c @@ -579,7 +579,8 @@ test_core(void) reset_udata(udata); file = H5Fopen(copied_filename, H5F_ACC_RDONLY, fapl); VERIFY(file >= 0, "H5Fopen failed"); - VERIFY(udata->used_callbacks == MALLOC, "opening a core file used the wrong callbacks"); + VERIFY((udata->used_callbacks == MALLOC) || + (udata->used_callbacks == MALLOC | UDATA_COPY | UDATA_FREE), "opening a core file used the wrong callbacks"); VERIFY(udata->malloc_src == H5FD_FILE_IMAGE_OP_FILE_OPEN, "Malloc callback came from wrong sourc in core open"); /* Close file */ diff --git a/test/freespace.c b/test/freespace.c index 0011bd2..947b2ce 100644 --- a/test/freespace.c +++ b/test/freespace.c @@ -2862,14 +2862,8 @@ main(void) { hid_t fapl = -1; /* File access property list for data files */ unsigned nerrors = 0; /* Cumulative error count */ - const char *env_h5_drvr = NULL; /* File Driver value from environment */ hbool_t api_ctx_pushed = FALSE; /* Whether API context pushed */ - /* Get the VFD to use */ - env_h5_drvr = HDgetenv("HDF5_DRIVER"); - if(env_h5_drvr == NULL) - env_h5_drvr = "nomatch"; - h5_reset(); if((fapl = h5_fileaccess()) < 0) { diff --git a/test/gen_plist.c b/test/gen_plist.c index 62693bd..af248be 100644 --- a/test/gen_plist.c +++ b/test/gen_plist.c @@ -363,9 +363,6 @@ main(void) if((ret = H5Pset_mdc_image_config(fapl1, &my_cache_image_config)) < 0) assert(ret > 0); - if((ret = H5Pset_core_write_tracking(fapl1, TRUE, (size_t)(1024 * 1024))) < 0) - assert(ret > 0); - if((ret = encode_plist(fapl1, little_endian, word_length, "testfiles/plist_files/fapl_")) < 0) assert(ret > 0); @@ -476,7 +473,7 @@ encode_plist(hid_t plist_id, int little_endian, int word_length, const char *fil HDassert(ret > 0); fd = HDopen(filename, O_RDWR | O_CREAT | O_TRUNC, H5_POSIX_CREATE_MODE_RW); - HDassert(fd > 0); + HDassert(fd >= 0); write_size = HDwrite(fd, temp_buf, temp_size); HDassert(write_size == (ssize_t)temp_size); diff --git a/test/h5test.c b/test/h5test.c index c1cc55b..0226aa7 100644 --- a/test/h5test.c +++ b/test/h5test.c @@ -42,7 +42,16 @@ * use for HDF5 file access. The first word in the * value is the name of the driver and subsequent data * is interpreted according to the driver. See - * h5_fileaccess() for details. + * h5_get_vfd_fapl() for details. + * + * HDF5_VOL_CONNECTOR: This string describes what VOL connector to + * use for HDF5 file access. The first word in the + * value is the name of the connector and subsequent data + * is interpreted according to the connector. See + * h5_get_vol_fapl() for details. + * + * HDF5_LIBVER_BOUNDS: This string describes what library version bounds to + * use for HDF5 file access. See h5_get_libver_fapl() for details. * * HDF5_PREFIX: A string to add to the beginning of all serial test * file names. This can be used to run tests in a @@ -792,11 +801,11 @@ h5_rmprefix(const char *filename) * Function: h5_fileaccess * * Purpose: Returns a file access template which is the default template - * but with a file driver set according to the constant or - * environment variable HDF5_DRIVER + * but with a file driver, VOL connector, or libver bound set + * according to a constant or environment variable * - * Return: Success: A file access property list - * Failure: -1 + * Return: Success: A file access property list + * Failure: H5I_INVALID_HID * * Programmer: Robb Matzke * Thursday, November 19, 1998 @@ -806,135 +815,39 @@ h5_rmprefix(const char *filename) hid_t h5_fileaccess(void) { - const char *val = NULL; - const char *name; - char s[1024]; - hid_t fapl = -1; - - /* First use the environment variable, then the constant */ - val = HDgetenv("HDF5_DRIVER"); -#ifdef HDF5_DRIVER - if(!val) - val = HDF5_DRIVER; -#endif - - if((fapl = H5Pcreate(H5P_FILE_ACCESS)) < 0) - return -1; - if(!val || !*val) - return fapl; /* use default */ - - HDstrncpy(s, val, sizeof s); - s[sizeof(s)-1] = '\0'; - if(NULL == (name = HDstrtok(s, " \t\n\r"))) - return fapl; - - if(!HDstrcmp(name, "sec2")) { - /* Unix read() and write() system calls */ - if (H5Pset_fapl_sec2(fapl) < 0) - return -1; - } - else if(!HDstrcmp(name, "stdio")) { - /* Standard C fread() and fwrite() system calls */ - if (H5Pset_fapl_stdio(fapl) < 0) - return -1; - } - else if(!HDstrcmp(name, "core")) { - /* In-memory driver settings (backing store on, 1 MB increment) */ - if(H5Pset_fapl_core(fapl, (size_t)1, TRUE) < 0) - return -1; - } - else if(!HDstrcmp(name, "core_paged")) { - /* In-memory driver with write tracking and paging on */ - if(H5Pset_fapl_core(fapl, (size_t)1, TRUE) < 0) - return -1; - if(H5Pset_core_write_tracking(fapl, TRUE, (size_t)4096) < 0) - return -1; - } - else if(!HDstrcmp(name, "split")) { - /* Split meta data and raw data each using default driver */ - if(H5Pset_fapl_split(fapl, - "-m.h5", H5P_DEFAULT, - "-r.h5", H5P_DEFAULT) < 0) - return -1; - } - else if(!HDstrcmp(name, "multi")) { - /* Multi-file driver, general case of the split driver */ - H5FD_mem_t memb_map[H5FD_MEM_NTYPES]; - hid_t memb_fapl[H5FD_MEM_NTYPES]; - const char *memb_name[H5FD_MEM_NTYPES]; - char *sv[H5FD_MEM_NTYPES]; - haddr_t memb_addr[H5FD_MEM_NTYPES]; - H5FD_mem_t mt; - - HDmemset(memb_map, 0, sizeof memb_map); - HDmemset(memb_fapl, 0, sizeof memb_fapl); - HDmemset(memb_name, 0, sizeof memb_name); - HDmemset(memb_addr, 0, sizeof memb_addr); + hid_t fapl_id = H5I_INVALID_HID; - HDassert(HDstrlen(multi_letters)==H5FD_MEM_NTYPES); - for(mt = H5FD_MEM_DEFAULT; mt < H5FD_MEM_NTYPES; H5_INC_ENUM(H5FD_mem_t, mt)) { - memb_fapl[mt] = H5P_DEFAULT; - if(NULL == (sv[mt] = (char *)HDmalloc(H5TEST_MULTI_FILENAME_LEN))) - return -1; - HDsprintf(sv[mt], "%%s-%c.h5", multi_letters[mt]); - memb_name[mt] = sv[mt]; - memb_addr[mt] = (haddr_t)MAX(mt - 1, 0) * (HADDR_MAX / 10); - } /* end for */ - - if(H5Pset_fapl_multi(fapl, memb_map, memb_fapl, memb_name, memb_addr, FALSE) < 0) - return -1; - - for(mt = H5FD_MEM_DEFAULT; mt < H5FD_MEM_NTYPES; H5_INC_ENUM(H5FD_mem_t, mt)) - HDfree(sv[mt]); - } - else if(!HDstrcmp(name, "family")) { - hsize_t fam_size = 100*1024*1024; /*100 MB*/ + if((fapl_id = H5Pcreate(H5P_FILE_ACCESS)) < 0) + goto error; - /* Family of files, each 1MB and using the default driver */ - if((val = HDstrtok(NULL, " \t\n\r"))) - fam_size = (hsize_t)(HDstrtod(val, NULL) * 1024*1024); - if(H5Pset_fapl_family(fapl, fam_size, H5P_DEFAULT)<0) - return -1; - } - else if(!HDstrcmp(name, "log")) { - unsigned log_flags = H5FD_LOG_LOC_IO | H5FD_LOG_ALLOC; + /* Attempt to set up a file driver first */ + if(h5_get_vfd_fapl(fapl_id) < 0) + goto error; - /* Log file access */ - if((val = HDstrtok(NULL, " \t\n\r"))) - log_flags = (unsigned)HDstrtol(val, NULL, 0); - if(H5Pset_fapl_log(fapl, NULL, log_flags, (size_t)0) < 0) - return -1; - } - else if(!HDstrcmp(name, "direct")) { -#ifdef H5_HAVE_DIRECT - /* Linux direct read() and write() system calls. Set memory boundary, file block size, - * and copy buffer size to the default values. */ - if(H5Pset_fapl_direct(fapl, 1024, 4096, 8 * 4096) < 0) - return -1; -#endif - } - else if(!HDstrcmp(name, "latest")) { - /* use the latest format */ - if(H5Pset_libver_bounds(fapl, H5F_LIBVER_LATEST, H5F_LIBVER_LATEST) < 0) - return -1; - } - else { - /* Unknown driver */ - return -1; - } + /* Next, try to set up a VOL connector */ + if(h5_get_vol_fapl(fapl_id) < 0) + goto error; + + /* Finally, check for libver bounds */ + if(h5_get_libver_fapl(fapl_id) < 0) + goto error; + + return fapl_id; - return fapl; -} +error: + if(fapl_id != H5I_INVALID_HID) + H5Pclose(fapl_id); + return H5I_INVALID_HID; +} /* end h5_fileaccess() */ /*------------------------------------------------------------------------- * Function: h5_get_vfd_fapl * - * Purpose: Returns a file access property list which is the default - * fapl but with a file driver set according to the constant or - * environment variable HDF5_DRIVER. + * Purpose: Sets the file driver for a FAPL according to the value specified + * in the constant or environment variable "HDF5_DRIVER". * - * Return: Success: A file access property list ID + * Return: Success: 0 * Failure: -1 * * Programmer: Dana Robinson @@ -942,60 +855,59 @@ h5_fileaccess(void) * *------------------------------------------------------------------------- */ -hid_t -h5_get_vfd_fapl(void) +herr_t +h5_get_vfd_fapl(hid_t fapl) { const char *env = NULL; /* HDF5_DRIVER environment variable */ const char *tok = NULL; /* strtok pointer */ + char *lasts = NULL; /* Context pointer for strtok_r() call */ char buf[1024]; /* buffer for tokenizing HDF5_DRIVER */ - hid_t fapl = -1; /* fapl to be returned */ /* Get the environment variable, if it exists */ env = HDgetenv("HDF5_DRIVER"); - - /* Create a default fapl */ - if((fapl = H5Pcreate(H5P_FILE_ACCESS)) < 0) - return -1; +#ifdef HDF5_DRIVER + /* Use the environment variable, then the compile-time constant */ + if(!env) + env = HDF5_DRIVER; +#endif /* If the environment variable was not set, just return - * the default fapl. + * without modifying the FAPL. */ if(!env || !*env) - return fapl; + goto done; /* Get the first 'word' of the environment variable. * If it's nothing (environment variable was whitespace) * just return the default fapl. */ HDstrncpy(buf, env, sizeof(buf)); - HDmemset(buf, 0, sizeof(buf)); - if(NULL == (tok = HDstrtok(buf, " \t\n\r"))) - return fapl; + buf[sizeof(buf) - 1] = '\0'; + if(NULL == (tok = HDstrtok_r(buf, " \t\n\r", &lasts))) + goto done; if(!HDstrcmp(tok, "sec2")) { /* POSIX (section 2) read() and write() system calls */ if(H5Pset_fapl_sec2(fapl) < 0) - return -1; + goto error; } else if(!HDstrcmp(tok, "stdio")) { /* Standard C fread() and fwrite() system calls */ if(H5Pset_fapl_stdio(fapl) < 0) - return -1; + goto error; } else if(!HDstrcmp(tok, "core")) { /* In-memory driver settings (backing store on, 1 MB increment) */ - if(H5Pset_fapl_core(fapl, (size_t)1, TRUE) < 0) - return -1; + if(H5Pset_fapl_core(fapl, (size_t)H5_MB, TRUE) < 0) + goto error; } else if(!HDstrcmp(tok, "core_paged")) { /* In-memory driver with write tracking and paging on */ - if(H5Pset_fapl_core(fapl, (size_t)1, TRUE) < 0) - return -1; + if(H5Pset_fapl_core(fapl, (size_t)H5_MB, TRUE) < 0) + goto error; if(H5Pset_core_write_tracking(fapl, TRUE, (size_t)4096) < 0) - return -1; + goto error; } else if(!HDstrcmp(tok, "split")) { /* Split meta data and raw data each using default driver */ - if(H5Pset_fapl_split(fapl, - "-m.h5", H5P_DEFAULT, - "-r.h5", H5P_DEFAULT) < 0) - return -1; + if(H5Pset_fapl_split(fapl, "-m.h5", H5P_DEFAULT, "-r.h5", H5P_DEFAULT) < 0) + goto error; } else if(!HDstrcmp(tok, "multi")) { /* Multi-file driver, general case of the split driver */ H5FD_mem_t memb_map[H5FD_MEM_NTYPES]; @@ -1021,47 +933,218 @@ h5_get_vfd_fapl(void) } /* end for */ if(H5Pset_fapl_multi(fapl, memb_map, memb_fapl, memb_name, memb_addr, FALSE) < 0) - return -1; + goto error; for(mt = H5FD_MEM_DEFAULT; mt < H5FD_MEM_NTYPES; H5_INC_ENUM(H5FD_mem_t, mt)) HDfree(sv[mt]); } else if(!HDstrcmp(tok, "family")) { /* Family of files, each 1MB and using the default driver */ - hsize_t fam_size = 100*1024*1024; /*100 MB*/ + hsize_t fam_size = 100 * 1024 * 1024; /* 100 MB */ /* Was a family size specified in the environment variable? */ - if((tok = HDstrtok(NULL, " \t\n\r"))) - fam_size = (hsize_t)(HDstrtod(tok, NULL) * 1024*1024); + if((tok = HDstrtok_r(NULL, " \t\n\r", &lasts))) + fam_size = (hsize_t)(HDstrtod(tok, NULL) * 1024 * 1024); if(H5Pset_fapl_family(fapl, fam_size, H5P_DEFAULT) < 0) - return -1; + goto error; } else if(!HDstrcmp(tok, "log")) { /* Log file access */ unsigned log_flags = H5FD_LOG_LOC_IO | H5FD_LOG_ALLOC; /* Were special log file flags specified in the environment variable? */ - if((tok = HDstrtok(NULL, " \t\n\r"))) + if((tok = HDstrtok_r(NULL, " \t\n\r", &lasts))) log_flags = (unsigned)HDstrtol(tok, NULL, 0); if(H5Pset_fapl_log(fapl, NULL, log_flags, (size_t)0) < 0) - return -1; + goto error; #ifdef H5_HAVE_DIRECT } else if(!HDstrcmp(tok, "direct")) { /* Linux direct read() and write() system calls. Set memory boundary, * file block size, and copy buffer size to the default values. */ - if(H5Pset_fapl_direct(fapl, 1024, 4096, 8*4096)<0) - return -1; + if(H5Pset_fapl_direct(fapl, 1024, 4096, 8 * 4096) < 0) + goto error; #endif } else { /* Unknown driver */ - return -1; + goto error; } /* end if */ - return fapl; +done: + return 0; + +error: + return -1; } /* end h5_get_vfd_fapl() */ /*------------------------------------------------------------------------- + * Function: h5_get_libver_fapl + * + * Purpose: Sets the library version bounds for a FAPL according to the + * value in the constant or environment variable "HDF5_LIBVER_BOUNDS". + * + * Return: Success: 0 + * Failure: -1 + * + * Programmer: Quincey Koziol + * November 2018 + * + *------------------------------------------------------------------------- + */ +herr_t +h5_get_libver_fapl(hid_t fapl) +{ + const char *env = NULL; /* HDF5_DRIVER environment variable */ + const char *tok = NULL; /* strtok pointer */ + char *lasts = NULL; /* Context pointer for strtok_r() call */ + char buf[1024]; /* buffer for tokenizing HDF5_DRIVER */ + + /* Get the environment variable, if it exists */ + env = HDgetenv("HDF5_LIBVER_BOUNDS"); +#ifdef HDF5_LIBVER_BOUNDS + /* Use the environment variable, then the compile-time constant */ + if(!env) + env = HDF5_LIBVER_BOUNDS; +#endif + + /* If the environment variable was not set, just return + * without modifying the FAPL. + */ + if(!env || !*env) + goto done; + + /* Get the first 'word' of the environment variable. + * If it's nothing (environment variable was whitespace) + * just return the default fapl. + */ + HDstrncpy(buf, env, sizeof(buf)); + buf[sizeof(buf) - 1] = '\0'; + if(NULL == (tok = HDstrtok_r(buf, " \t\n\r", &lasts))) + goto done; + + if(!HDstrcmp(tok, "latest")) { + /* use the latest format */ + if(H5Pset_libver_bounds(fapl, H5F_LIBVER_LATEST, H5F_LIBVER_LATEST) < 0) + goto error; + } /* end if */ + else { + /* Unknown setting */ + goto error; + } /* end else */ + +done: + return 0; + +error: + return -1; +} /* end h5_get_libver_fapl() */ + + +/*------------------------------------------------------------------------- + * Function: h5_get_vol_fapl + * + * Purpose: Returns a file access property list which is the default + * fapl but with a VOL connector set according to the constant + * or environment variable HDF5_VOL_CONNECTOR. + * + * Return: Success: 0 + * Failure: -1 + * + * Programmer: Jordan Henderson + * November 2018 + * + *------------------------------------------------------------------------- + */ +herr_t +h5_get_vol_fapl(hid_t fapl) +{ + const char *env = NULL; + const char *tok = NULL; + char *lasts = NULL; /* Context pointer for strtok_r() call */ + htri_t connector_is_registered; + char buf[1024]; /* Buffer for tokenizing HDF5_VOL_CONNECTOR */ + void *vol_info = NULL; /* VOL connector info */ + hid_t connector_id = -1; + + /* Get the environment variable, if it exists */ + env = HDgetenv("HDF5_VOL_CONNECTOR"); +#ifdef HDF5_VOL_CONNECTOR + /* Use the environment variable, then the compile-time constant */ + if(!env) + env = HDF5_VOL_CONNECTOR; +#endif + + /* If the environment variable was not set, just return. */ + if(!env || !*env) + goto done; + + /* Get the first 'word' of the environment variable. + * If it's nothing (environment variable was whitespace) just return. + */ + HDstrncpy(buf, env, sizeof(buf)); + buf[sizeof(buf) - 1] = '\0'; + if(NULL == (tok = HDstrtok_r(buf, " \t\n\r", &lasts))) + goto done; + + /* First, check to see if the connector is already registered */ + if((connector_is_registered = H5VLis_connector_registered(tok)) < 0) + goto done; + else if(connector_is_registered) { + /* Retrieve the ID of the already-registered VOL connector */ + if((connector_id = H5VLget_connector_id(tok)) < 0) + goto error; + } /* end else-if */ + else { + /* Check for VOL connectors that ship with the library */ + if(!HDstrcmp(tok, "native")) { + connector_id = H5VL_NATIVE; + if(H5Iinc_ref(connector_id) < 0) + goto error; + } else if(!HDstrcmp(tok, "pass_through")) { + connector_id = H5VL_PASSTHRU; + if(H5Iinc_ref(connector_id) < 0) + goto error; + } else { + /* Register the VOL connector */ + /* (NOTE: No provisions for vipl_id currently) */ + if((connector_id = H5VLregister_connector_by_name(tok, H5P_DEFAULT)) < 0) + goto error; + } /* end else */ + } /* end else */ + + /* Was there any connector info specified in the environment variable? */ + if(NULL != (tok = HDstrtok_r(NULL, " \t\n\r", &lasts))) + if(H5VLconnector_str_to_info(tok, connector_id, &vol_info) < 0) + goto error; + + /* Set the VOL connector in the FAPL */ + if(H5Pset_vol(fapl, connector_id, vol_info) < 0) + goto error; + + /* Release VOL connector info, if there was any */ + if(vol_info) + if(H5VLfree_connector_info(connector_id, vol_info) < 0) + goto error; + + /* Close the connector ID */ + if(connector_id >= 0) + if(H5VLunregister_connector(connector_id) < 0) + goto error; + +done: + return 0; + +error: + if(vol_info) + H5VLfree_connector_info(connector_id, vol_info); + if(connector_id >= 0) + H5VLunregister_connector(connector_id); + + return -1; +} /* end h5_get_vol_fapl() */ + + +/*------------------------------------------------------------------------- * Function: h5_no_hwconv * * Purpose: Turn off hardware data type conversions. @@ -1908,14 +1991,14 @@ error: * Purpose: Returns a disposable, generally non-functional, * VOL class struct. * - * In some of the test code, we need a disposable VOL driver + * In some of the test code, we need a disposable VOL connector * but we don't want to mess with the real VFDs and we also - * don't have access to the internals of the real VOL drivers + * don't have access to the internals of the real VOL connectors * (which use static globals and functions) to easily duplicate - * them (e.g.: for testing VOL driver ID handling). + * them (e.g.: for testing VOL connector ID handling). * * This API call will return a pointer to a VOL class that - * can be used to construct a test VOL using H5VLregister_driver(). + * can be used to construct a test VOL using H5VLregister_connector(). * * Return: Success: A pointer to a VOL class struct * Failure: NULL @@ -1931,7 +2014,7 @@ h5_get_dummy_vol_class(void) if(NULL == (vol_class = (H5VL_class_t *)HDcalloc((size_t)1, sizeof(H5VL_class_t)))) TEST_ERROR; - /* Fill in the minimum parameters to make a VOL driver class that + /* Fill in the minimum parameters to make a VOL connector class that * can be registered. */ vol_class->name = "dummy"; diff --git a/test/h5test.h b/test/h5test.h index 2fb0e0c..c72f389 100644 --- a/test/h5test.h +++ b/test/h5test.h @@ -144,12 +144,10 @@ H5TEST_DLL herr_t h5_verify_cached_stabs(const char *base_name[], hid_t fapl); H5TEST_DLL H5FD_class_t *h5_get_dummy_vfd_class(void); H5TEST_DLL H5VL_class_t *h5_get_dummy_vol_class(void); -/* Functions that will replace VFD-dependent functions that violate - * the single responsibility principle. Unlike their predecessors, - * these new functions do not have hidden side effects. - */ -/* h5_fileaccess() replacement */ -H5TEST_DLL hid_t h5_get_vfd_fapl(void); +/* Functions that will replace components of a FAPL */ +H5TEST_DLL herr_t h5_get_vfd_fapl(hid_t fapl_id); +H5TEST_DLL herr_t h5_get_vol_fapl(hid_t fapl_id); +H5TEST_DLL herr_t h5_get_libver_fapl(hid_t fapl_id); /* h5_clean_files() replacements */ H5TEST_DLL void h5_delete_test_file(const char *base_name, hid_t fapl); diff --git a/test/links.c b/test/links.c index e0dc39e..b10d0ad 100644 --- a/test/links.c +++ b/test/links.c @@ -7743,7 +7743,6 @@ done: case H5I_FILE: case H5I_DATASPACE: case H5I_ATTR: - case H5I_REFERENCE: case H5I_VFL: case H5I_VOL: case H5I_GENPROP_CLS: @@ -7832,7 +7831,6 @@ done: case H5I_FILE: case H5I_DATASPACE: case H5I_ATTR: - case H5I_REFERENCE: case H5I_VFL: case H5I_VOL: case H5I_GENPROP_CLS: diff --git a/test/links_env.c b/test/links_env.c index b32fb32..0cd690a 100644 --- a/test/links_env.c +++ b/test/links_env.c @@ -148,11 +148,6 @@ main(void) { hid_t fapl; /* File access property lists */ int nerrors = 0; /* Error from tests */ - const char *env_h5_drvr; /* File Driver value from environment */ - - env_h5_drvr = HDgetenv("HDF5_DRIVER"); - if(env_h5_drvr == NULL) - env_h5_drvr = "nomatch"; h5_reset(); fapl = h5_fileaccess(); diff --git a/test/objcopy.c b/test/objcopy.c index f13537e..6ee2f72 100644 --- a/test/objcopy.c +++ b/test/objcopy.c @@ -2151,7 +2151,7 @@ test_copy_dataset_versionbounds(hid_t fcpl_src, hid_t fapl_src) buf[i][j] = 10000 + 100*i+j; /* Create a file access property list for destination file */ - if ((fapl_dst = H5Pcreate(H5P_FILE_ACCESS)) < 0) TEST_ERROR + if ((fapl_dst = h5_fileaccess()) < 0) TEST_ERROR /* Initialize the filenames */ h5_fixname(FILENAME[4], fapl_src, src_fname, sizeof src_fname); @@ -7854,6 +7854,7 @@ test_copy_old_layout(hid_t fcpl_dst, hid_t fapl, hbool_t test_open) { hid_t fid_src = -1, fid_dst = -1; /* File IDs */ hid_t did = -1, did2 = -1; /* Dataset IDs */ + hid_t src_fapl = -1; /* Source file FAPL ID */ const char *src_filename = H5_get_srcdir_filename(FILE_OLD_LAYOUT); /* Corrected test file name */ char dst_filename[NAME_BUF_SIZE]; @@ -7869,8 +7870,14 @@ test_copy_old_layout(hid_t fcpl_dst, hid_t fapl, hbool_t test_open) /* Reset file address checking info */ addr_reset(); + /* Setup */ + if((src_fapl = h5_fileaccess()) < 0) TEST_ERROR + /* open source file (read-only) */ - if((fid_src = H5Fopen(src_filename, H5F_ACC_RDONLY, H5P_DEFAULT)) < 0) TEST_ERROR + if((fid_src = H5Fopen(src_filename, H5F_ACC_RDONLY, src_fapl)) < 0) TEST_ERROR + + /* Close source FAPL */ + if(H5Pclose(src_fapl) < 0) TEST_ERROR /* create destination file */ if((fid_dst = H5Fcreate(dst_filename, H5F_ACC_TRUNC, fcpl_dst, fapl)) < 0) TEST_ERROR @@ -7914,6 +7921,7 @@ test_copy_old_layout(hid_t fcpl_dst, hid_t fapl, hbool_t test_open) error: H5E_BEGIN_TRY { + H5Pclose(src_fapl); H5Dclose(did2); H5Dclose(did); H5Fclose(fid_dst); diff --git a/test/ohdr.c b/test/ohdr.c index 2b57ada..cca7e7e 100644 --- a/test/ohdr.c +++ b/test/ohdr.c @@ -486,7 +486,7 @@ test_unknown(unsigned bogus_id, char *filename, hid_t fapl) FAIL_STACK_ERROR /* Open FILE_BOGUS */ - if((fid_bogus = H5Fopen(testfile, H5F_ACC_RDONLY, H5P_DEFAULT)) < 0) + if((fid_bogus = H5Fopen(testfile, H5F_ACC_RDONLY, fapl)) < 0) FAIL_STACK_ERROR /* Set up location ID depending on bogus_id */ diff --git a/test/swmr.c b/test/swmr.c index 3b2af4e..bab91bd 100644 --- a/test/swmr.c +++ b/test/swmr.c @@ -6500,10 +6500,9 @@ test_refresh_concur(hid_t in_fapl, hbool_t new_format) HDexit(EXIT_FAILURE); /* Wait for notification from parent process */ - while(child_notify != 1) { + while(child_notify != 1) if(HDread(out_pdf[0], &child_notify, sizeof(int)) < 0) HDexit(EXIT_FAILURE); - } /* Open the file 2 times */ if((child_fid1 = H5Fopen(filename, H5F_ACC_RDONLY|H5F_ACC_SWMR_READ, fapl)) < 0) @@ -6540,10 +6539,9 @@ test_refresh_concur(hid_t in_fapl, hbool_t new_format) HDexit(EXIT_FAILURE); /* Wait for notification from parent process */ - while(child_notify != 3) { + while(child_notify != 3) if(HDread(out_pdf[0], &child_notify, sizeof(int)) < 0) HDexit(EXIT_FAILURE); - } /* Refresh dataset via did1 */ if(H5Drefresh(child_did1) < 0) diff --git a/test/tattr.c b/test/tattr.c index 3a7cf2c..63a0580 100644 --- a/test/tattr.c +++ b/test/tattr.c @@ -143,6 +143,10 @@ float attr_data5=-5.123F; /* Test data for 5th attribute */ #define DIM1 100 #define RANK 2 +/* Used by test_attr_info_null_info_pointer() */ +#define GET_INFO_NULL_POINTER_ATTR_NAME "NullInfoPointerAttr" + + /* Attribute iteration struct */ typedef struct { H5_iter_order_t order; /* Direction of iteration */ @@ -5875,6 +5879,65 @@ test_attr_info_by_idx(hbool_t new_format, hid_t fcpl, hid_t fapl) } /* test_attr_info_by_idx() */ +/*************************************************************** +** +** test_attr_info_null_info_pointer(): A test to ensure that +** passing a NULL attribute info pointer to H5Aget_info +** (_by_name/_by_idx) doesn't cause bad behavior. +** +****************************************************************/ +static void +test_attr_info_null_info_pointer(hid_t fcpl, hid_t fapl) +{ + herr_t err_ret = -1; + hid_t fid; + hid_t attr; + hid_t sid; + + /* Create dataspace for dataset & attributes */ + sid = H5Screate(H5S_SCALAR); + CHECK(sid, FAIL, "H5Screate"); + + /* Create file */ + fid = H5Fcreate(FILENAME, H5F_ACC_TRUNC, fcpl, fapl); + CHECK(fid, FAIL, "H5Fcreate"); + + /* Create attribute */ + attr = H5Acreate2(fid, GET_INFO_NULL_POINTER_ATTR_NAME, H5T_NATIVE_UINT, sid, H5P_DEFAULT, H5P_DEFAULT); + CHECK(attr, FAIL, "H5Acreate2"); + + H5E_BEGIN_TRY { + err_ret = H5Aget_info(attr, NULL); + } H5E_END_TRY; + + CHECK(err_ret, SUCCEED, "H5Aget_info"); + + H5E_BEGIN_TRY { + err_ret = H5Aget_info_by_name(fid, ".", GET_INFO_NULL_POINTER_ATTR_NAME, NULL, H5P_DEFAULT); + } H5E_END_TRY; + + CHECK(err_ret, SUCCEED, "H5Aget_info_by_name"); + + H5E_BEGIN_TRY { + err_ret = H5Aget_info_by_idx(fid, ".", H5_INDEX_NAME, H5_ITER_INC, 0, NULL, H5P_DEFAULT); + } H5E_END_TRY; + + CHECK(err_ret, SUCCEED, "H5Aget_info_by_idx"); + + /* Close dataspace */ + err_ret = H5Sclose(sid); + CHECK(err_ret, FAIL, "H5Sclose"); + + /* Close attribute */ + err_ret = H5Aclose(attr); + CHECK(err_ret, FAIL, "H5Aclose"); + + /* Close file */ + err_ret = H5Fclose(fid); + CHECK(err_ret, FAIL, "H5Fclose"); +} + + /**************************************************************** ** ** test_attr_delete_by_idx(): Test basic H5A (attribute) code. @@ -10875,6 +10938,7 @@ test_attr(void) test_attr_null_space(my_fcpl, my_fapl); /* Test storing attribute with NULL dataspace */ test_attr_deprec(fcpl, my_fapl); /* Test deprecated API routines */ test_attr_many(new_format, my_fcpl, my_fapl); /* Test storing lots of attributes */ + test_attr_info_null_info_pointer(my_fcpl, my_fapl); /* Test passing a NULL attribute info pointer to H5Aget_info(_by_name/_by_idx) */ /* Attribute creation order tests */ test_attr_corder_create_basic(my_fcpl, my_fapl);/* Test creating an object w/attribute creation order info */ @@ -10919,6 +10983,7 @@ test_attr(void) test_attr_null_space(fcpl, my_fapl); /* Test storing attribute with NULL dataspace */ test_attr_deprec(fcpl, my_fapl); /* Test deprecated API routines */ test_attr_many(new_format, fcpl, my_fapl); /* Test storing lots of attributes */ + test_attr_info_null_info_pointer(fcpl, my_fapl); /* Test passing a NULL attribute info pointer to H5Aget_info(_by_name/_by_idx) */ /* New attribute API routine tests, on old-format storage */ test_attr_info_by_idx(new_format, fcpl, my_fapl); /* Test querying attribute info by index */ diff --git a/test/testfiles/error_test_1 b/test/testfiles/error_test_1 index 473c53e..f0e4a62 100644 --- a/test/testfiles/error_test_1 +++ b/test/testfiles/error_test_1 @@ -41,25 +41,28 @@ HDF5-DIAG: Error detected in HDF5 (version (number)) thread (IDs): #000: (file name) line (number) in H5Dread(): can't read data major: Dataset minor: Read failed - #001: (file name) line (number) in H5VL_dataset_read(): read failed + #001: (file name) line (number) in H5VL_dataset_read(): dataset read failed major: Virtual Object Layer minor: Read failed - #002: (file name) line (number) in H5VL_native_dataset_read(): can't read data + #002: (file name) line (number) in H5VL__dataset_read(): dataset read failed + major: Virtual Object Layer + minor: Read failed + #003: (file name) line (number) in H5VL__native_dataset_read(): can't read data major: Dataset minor: Read failed - #003: (file name) line (number) in H5D__read(): can't read data + #004: (file name) line (number) in H5D__read(): can't read data major: Dataset minor: Read failed - #004: (file name) line (number) in H5D__chunk_read(): unable to read raw data chunk + #005: (file name) line (number) in H5D__chunk_read(): unable to read raw data chunk major: Low-level I/O minor: Read failed - #005: (file name) line (number) in H5D__chunk_lock(): data pipeline read failed + #006: (file name) line (number) in H5D__chunk_lock(): data pipeline read failed major: Dataset minor: Filter operation failed - #006: (file name) line (number) in H5Z_pipeline(): required filter 'bogus' is not registered + #007: (file name) line (number) in H5Z_pipeline(): required filter 'bogus' is not registered major: Data filters minor: Read failed - #007: (file name) line (number) in H5PL_load(): filter plugins disabled + #008: (file name) line (number) in H5PL_load(): filter plugins disabled major: Plugin for dynamically loaded library minor: Unable to load metadata into cache diff --git a/test/testfiles/plist_files/def_fapl_32be b/test/testfiles/plist_files/def_fapl_32be Binary files differindex 6e94011..53ef572 100644 --- a/test/testfiles/plist_files/def_fapl_32be +++ b/test/testfiles/plist_files/def_fapl_32be diff --git a/test/testfiles/plist_files/def_fapl_32le b/test/testfiles/plist_files/def_fapl_32le Binary files differindex 6e94011..53ef572 100644 --- a/test/testfiles/plist_files/def_fapl_32le +++ b/test/testfiles/plist_files/def_fapl_32le diff --git a/test/testfiles/plist_files/def_fapl_64be b/test/testfiles/plist_files/def_fapl_64be Binary files differindex 6e94011..53ef572 100644 --- a/test/testfiles/plist_files/def_fapl_64be +++ b/test/testfiles/plist_files/def_fapl_64be diff --git a/test/testfiles/plist_files/def_fapl_64le b/test/testfiles/plist_files/def_fapl_64le Binary files differindex 6e94011..53ef572 100644 --- a/test/testfiles/plist_files/def_fapl_64le +++ b/test/testfiles/plist_files/def_fapl_64le diff --git a/test/testfiles/plist_files/fapl_32be b/test/testfiles/plist_files/fapl_32be Binary files differindex 237b291..d89a44c 100644 --- a/test/testfiles/plist_files/fapl_32be +++ b/test/testfiles/plist_files/fapl_32be diff --git a/test/testfiles/plist_files/fapl_32le b/test/testfiles/plist_files/fapl_32le Binary files differindex 237b291..d89a44c 100644 --- a/test/testfiles/plist_files/fapl_32le +++ b/test/testfiles/plist_files/fapl_32le diff --git a/test/testfiles/plist_files/fapl_64be b/test/testfiles/plist_files/fapl_64be Binary files differindex 237b291..d89a44c 100644 --- a/test/testfiles/plist_files/fapl_64be +++ b/test/testfiles/plist_files/fapl_64be diff --git a/test/testfiles/plist_files/fapl_64le b/test/testfiles/plist_files/fapl_64le Binary files differindex 237b291..d89a44c 100644 --- a/test/testfiles/plist_files/fapl_64le +++ b/test/testfiles/plist_files/fapl_64le diff --git a/test/testfiles/plist_files/lapl_32be b/test/testfiles/plist_files/lapl_32be Binary files differindex 9d81759..eee238e 100644 --- a/test/testfiles/plist_files/lapl_32be +++ b/test/testfiles/plist_files/lapl_32be diff --git a/test/testfiles/plist_files/lapl_32le b/test/testfiles/plist_files/lapl_32le Binary files differindex 9d81759..eee238e 100644 --- a/test/testfiles/plist_files/lapl_32le +++ b/test/testfiles/plist_files/lapl_32le diff --git a/test/testfiles/plist_files/lapl_64be b/test/testfiles/plist_files/lapl_64be Binary files differindex 9d81759..eee238e 100644 --- a/test/testfiles/plist_files/lapl_64be +++ b/test/testfiles/plist_files/lapl_64be diff --git a/test/testfiles/plist_files/lapl_64le b/test/testfiles/plist_files/lapl_64le Binary files differindex 9d81759..eee238e 100644 --- a/test/testfiles/plist_files/lapl_64le +++ b/test/testfiles/plist_files/lapl_64le diff --git a/test/tfile.c b/test/tfile.c index 12a0eca..8a8b889 100644 --- a/test/tfile.c +++ b/test/tfile.c @@ -1430,7 +1430,6 @@ test_obj_count_and_id(hid_t fid1, hid_t fid2, hid_t did, hid_t gid1, case H5I_DATATYPE: case H5I_DATASPACE: case H5I_ATTR: - case H5I_REFERENCE: case H5I_VFL: case H5I_VOL: case H5I_GENPROP_CLS: @@ -1600,6 +1599,7 @@ test_file_is_accessible(void) { hid_t fid; /* File opened with read-write permission */ hid_t fcpl_id; /* File creation property list */ + hid_t fapl = -1; /* File access property list */ int fd; /* POSIX file descriptor */ ssize_t nbytes; /* Number of bytes written */ unsigned u; /* Local index variable */ @@ -1610,8 +1610,12 @@ test_file_is_accessible(void) /* Output message about test being performed */ MESSAGE(5, ("Testing Detection of HDF5 Files\n")); + /* Get FAPL */ + fapl = h5_fileaccess(); + CHECK(fapl, FAIL, "H5Pcreate"); + /* Create a file */ - fid = H5Fcreate(FILE1, H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT); + fid = H5Fcreate(FILE1, H5F_ACC_TRUNC, H5P_DEFAULT, fapl); CHECK(fid, FAIL, "H5Fcreate"); /* Close file */ @@ -1619,7 +1623,7 @@ test_file_is_accessible(void) CHECK(ret, FAIL, "H5Fclose"); /* Verify that the file is an HDF5 file */ - status = H5Fis_accessible(FILE1, H5P_DEFAULT); + status = H5Fis_accessible(FILE1, fapl); VERIFY(status, TRUE, "H5Fis_accessible"); @@ -1631,7 +1635,7 @@ test_file_is_accessible(void) CHECK(ret, FAIL, "H5Pset_userblock"); /* Create file with non-default user block */ - fid = H5Fcreate(FILE1, H5F_ACC_TRUNC, fcpl_id, H5P_DEFAULT); + fid = H5Fcreate(FILE1, H5F_ACC_TRUNC, fcpl_id, fapl); CHECK(fid, FAIL, "H5Fcreate"); /* Release file-creation property list */ @@ -1643,7 +1647,7 @@ test_file_is_accessible(void) CHECK(ret, FAIL, "H5Fclose"); /* Verify that the file is an HDF5 file */ - status = H5Fis_accessible(FILE1, H5P_DEFAULT); + status = H5Fis_accessible(FILE1, fapl); VERIFY(status, TRUE, "H5Fis_accessible"); @@ -1664,9 +1668,13 @@ test_file_is_accessible(void) CHECK(ret, FAIL, "HDclose"); /* Verify that the file is not an HDF5 file */ - status = H5Fis_accessible(FILE1, H5P_DEFAULT); + status = H5Fis_accessible(FILE1, fapl); VERIFY(status, FALSE, "H5Fis_accessible"); + /* Close property list */ + ret = H5Pclose(fapl); + CHECK(ret, FAIL, "H5Pclose"); + } /* end test_file_is_accessible() */ @@ -1683,6 +1691,7 @@ test_file_ishdf5(void) { hid_t file; /* File opened with read-write permission */ hid_t fcpl; /* File creation property list */ + hid_t fapl = -1; /* File access property list */ int fd; /* File Descriptor */ ssize_t nbytes; /* Number of bytes written */ unsigned u; /* Local index variable */ @@ -1693,8 +1702,12 @@ test_file_ishdf5(void) /* Output message about test being performed */ MESSAGE(5, ("Testing Detection of HDF5 Files (using deprecated H5Fis_hdf5() call)\n")); + /* Get FAPL */ + fapl = h5_fileaccess(); + CHECK(fapl, FAIL, "H5Pcreate"); + /* Create a file */ - file = H5Fcreate(FILE1, H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT); + file = H5Fcreate(FILE1, H5F_ACC_TRUNC, H5P_DEFAULT, fapl); CHECK(file, FAIL, "H5Fcreate"); /* Close file */ @@ -1714,7 +1727,7 @@ test_file_ishdf5(void) CHECK(ret, FAIL, "H5Pset_userblock"); /* Create file with non-default user block */ - file = H5Fcreate(FILE1, H5F_ACC_TRUNC, fcpl, H5P_DEFAULT); + file = H5Fcreate(FILE1, H5F_ACC_TRUNC, fcpl, fapl); CHECK(file, FAIL, "H5Fcreate"); /* Release file-creation property list */ @@ -1750,6 +1763,10 @@ test_file_ishdf5(void) status = H5Fis_hdf5(FILE1); VERIFY(status, FALSE, "H5Fis_hdf5"); + /* Close property list */ + ret = H5Pclose(fapl); + CHECK(ret, FAIL, "H5Pclose"); + } /* end test_file_ishdf5() */ #endif /* H5_NO_DEPRECATED_SYMBOLS */ @@ -2240,10 +2257,8 @@ test_file_double_file_dataset_open(hbool_t new_format) MESSAGE(5, ("Testing double file and dataset open/close\n")); /* Setting up test file */ - - fapl = H5Pcreate(H5P_FILE_ACCESS); + fapl = h5_fileaccess(); CHECK(fapl, FAIL, "H5Pcreate"); - if(new_format) { ret = H5Pset_libver_bounds(fapl, H5F_LIBVER_LATEST, H5F_LIBVER_LATEST); CHECK(ret, FAIL, "H5Pset_libver_bounds"); @@ -4165,10 +4180,7 @@ test_file_freespace(const char *env_h5_drvr) /* Check that there is the right amount of free space in the file */ free_space = H5Fget_freespace(file); CHECK(free_space, FAIL, "H5Fget_freespace"); - if(new_format) - VERIFY(free_space, expected_fs_del, "H5Fget_freespace"); - else - VERIFY(free_space, expected_fs_del, "H5Fget_freespace"); + VERIFY(free_space, expected_fs_del, "H5Fget_freespace"); /* Close file */ ret = H5Fclose(file); diff --git a/test/tmisc.c b/test/tmisc.c index 2a977bf..fef94dd 100644 --- a/test/tmisc.c +++ b/test/tmisc.c @@ -3481,15 +3481,15 @@ test_misc19(void) HDfree(vfd_cls); -/* Check H5I operations on virtual object drivers */ +/* Check H5I operations on virtual object connectors */ /* Get a VOL class to register */ vol_cls = h5_get_dummy_vol_class(); CHECK(vol_cls, NULL, "h5_get_dummy_vol_class"); - /* Register a VOL driver */ - volid = H5VLregister_driver(vol_cls); - CHECK(volid, FAIL, "H5VLregister_driver"); + /* Register a VOL connector */ + volid = H5VLregister_connector(vol_cls, H5P_DEFAULT); + CHECK(volid, FAIL, "H5VLregister_connector"); /* Check the reference count */ rc = H5Iget_ref(volid); @@ -3499,23 +3499,23 @@ test_misc19(void) rc = H5Iinc_ref(volid); VERIFY(rc, 2, "H5Iinc_ref"); - /* Unregister the VOL driver normally */ - ret = H5VLunregister_driver(volid); - CHECK(ret, FAIL, "H5VLunregister_driver"); + /* Unregister the VOL connector normally */ + ret = H5VLunregister_connector(volid); + CHECK(ret, FAIL, "H5VLunregister_connector"); /* Check the reference count */ rc = H5Iget_ref(volid); VERIFY(rc, 1, "H5Iget_ref"); - /* Unregister the VOL driver by decrementing the reference count */ + /* Unregister the VOL connector by decrementing the reference count */ rc = H5Idec_ref(volid); VERIFY(rc, 0, "H5Idec_ref"); - /* Try unregistering the VOL driver again (should fail) */ + /* Try unregistering the VOL connector again (should fail) */ H5E_BEGIN_TRY { - ret = H5VLunregister_driver(volid); + ret = H5VLunregister_connector(volid); } H5E_END_TRY; - VERIFY(ret, FAIL, "H5VLunregister_driver"); + VERIFY(ret, FAIL, "H5VLunregister_connector"); HDfree(vol_cls); diff --git a/test/ttsafe_error.c b/test/ttsafe_error.c index e04ddf3..56d87ee 100644 --- a/test/ttsafe_error.c +++ b/test/ttsafe_error.c @@ -74,28 +74,31 @@ tts_error(void) expected_g[0].min_num = H5E_CANTINIT; expected_g[1].maj_num = H5E_VOL; - expected_g[1].min_num = H5E_CANTINIT; + expected_g[1].min_num = H5E_CANTCREATE; - expected_g[2].maj_num = H5E_DATASET; - expected_g[2].min_num = H5E_CANTINIT; + expected_g[2].maj_num = H5E_VOL; + expected_g[2].min_num = H5E_CANTCREATE; expected_g[3].maj_num = H5E_DATASET; expected_g[3].min_num = H5E_CANTINIT; - expected_g[4].maj_num = H5E_LINK; + expected_g[4].maj_num = H5E_DATASET; expected_g[4].min_num = H5E_CANTINIT; expected_g[5].maj_num = H5E_LINK; - expected_g[5].min_num = H5E_CANTINSERT; + expected_g[5].min_num = H5E_CANTINIT; - expected_g[6].maj_num = H5E_SYM; - expected_g[6].min_num = H5E_NOTFOUND; + expected_g[6].maj_num = H5E_LINK; + expected_g[6].min_num = H5E_CANTINSERT; expected_g[7].maj_num = H5E_SYM; - expected_g[7].min_num = H5E_CALLBACK; + expected_g[7].min_num = H5E_NOTFOUND; - expected_g[8].maj_num = H5E_LINK; - expected_g[8].min_num = H5E_EXISTS; + expected_g[8].maj_num = H5E_SYM; + expected_g[8].min_num = H5E_CALLBACK; + + expected_g[9].maj_num = H5E_LINK; + expected_g[9].min_num = H5E_EXISTS; /* set up mutex for global count of errors */ H5TS_mutex_init(&error_mutex_g); @@ -121,7 +124,7 @@ tts_error(void) H5TS_wait_for_thread(threads[i]); if (error_flag_g) { - TestErrPrintf("At least one thread reported a value that was different from the exected value\n"); + TestErrPrintf("At least one thread reported a value that was different from the expected value\n"); HDprintf("(Update this test if the error stack changed!)\n"); } diff --git a/test/tvlstr.c b/test/tvlstr.c index 3315d68..da6195c 100644 --- a/test/tvlstr.c +++ b/test/tvlstr.c @@ -23,12 +23,16 @@ #define DATAFILE "tvlstr.h5" #define DATAFILE2 "tvlstr2.h5" +#define DATAFILE3 "sel2el.h5" + +#define DATASET "1Darray" /* 1-D dataset with fixed dimensions */ #define SPACE1_RANK 1 #define SPACE1_DIM1 4 +#define NUMP 4 -#define VLSTR_TYPE "vl_string_type" +#define VLSTR_TYPE "vl_string_type" /* Definitions for the VL re-writing test */ #define REWRITE_NDATASETS 32 @@ -846,6 +850,101 @@ static void test_vl_rewrite(void) } /* end test_vl_rewrite() */ /**************************************************************** + ** + ** test_write_same_element(): + ** Tests writing to the same element of VL string using + ** H5Sselect_element. + ** + ****************************************************************/ +static void test_write_same_element(void) +{ + hid_t file1, dataset1; + hid_t mspace, fspace, dtype; + hsize_t fdim[] = {SPACE1_DIM1}; + char *val[SPACE1_DIM1] = {"But", "reuniting", "is a", "great joy"}; + hsize_t marray[] = {NUMP}; + hsize_t coord[SPACE1_RANK][NUMP]; + herr_t ret; + + char *wdata[SPACE1_DIM1] = {"Parting", "is such a", "sweet", "sorrow."}; + + file1 = H5Fcreate(DATAFILE3, H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT); + CHECK(file1, FAIL, "H5Fcreate"); + + dtype = H5Tcopy(H5T_C_S1); + CHECK(dtype, FAIL, "H5Tcopy"); + + ret = H5Tset_size(dtype, H5T_VARIABLE); + CHECK(ret, FAIL, "H5Tset_size"); + + fspace = H5Screate_simple(SPACE1_RANK, fdim, NULL); + CHECK(fspace, FAIL, "H5Screate_simple"); + + dataset1 = H5Dcreate2(file1, DATASET, dtype, fspace, H5P_DEFAULT, + H5P_DEFAULT, H5P_DEFAULT); + CHECK(dataset1, FAIL, "H5Dcreate"); + + ret = H5Dwrite(dataset1, dtype, H5S_ALL, H5S_ALL, H5P_DEFAULT, wdata); + CHECK(ret, FAIL, "H5Dwrite"); + + ret = H5Dclose(dataset1); + CHECK(ret, FAIL, "H5Dclose"); + + ret = H5Tclose(dtype); + CHECK(ret, FAIL, "H5Tclose"); + + ret = H5Sclose(fspace); + CHECK(ret, FAIL, "H5Sclose"); + + ret = H5Fclose(file1); + CHECK(ret, FAIL, "H5Fclose"); + + /* + * Open the file. Select the same points, write values to those point locations. + */ + file1 = H5Fopen(DATAFILE3, H5F_ACC_RDWR, H5P_DEFAULT); + CHECK(file1, FAIL, "H5Fopen"); + + dataset1 = H5Dopen2(file1, DATASET, H5P_DEFAULT); + CHECK(dataset1, FAIL, "H5Dopen"); + + fspace = H5Dget_space(dataset1); + CHECK(fspace, FAIL, "H5Dget_space"); + + dtype = H5Dget_type(dataset1); + CHECK(dtype, FAIL, "H5Dget_type"); + + mspace = H5Screate_simple(1, marray, NULL); + CHECK(mspace, FAIL, "H5Screate_simple"); + + coord[0][0] = 0; + coord[0][1] = 2; + coord[0][2] = 2; + coord[0][3] = 0; + + ret = H5Sselect_elements(fspace, H5S_SELECT_SET, NUMP, (const hsize_t *)&coord); + CHECK(ret, FAIL, "H5Sselect_elements"); + + ret = H5Dwrite(dataset1, dtype, mspace, fspace, H5P_DEFAULT, val); + CHECK(ret, FAIL, "H5Dwrite"); + + ret = H5Tclose(dtype); + CHECK(ret, FAIL, "H5Tclose"); + + ret = H5Dclose(dataset1); + CHECK(ret, FAIL, "H5Dclose"); + + ret = H5Sclose(fspace); + CHECK(ret, FAIL, "H5Dclose"); + + ret = H5Sclose(mspace); + CHECK(ret, FAIL, "H5Sclose"); + + ret = H5Fclose(file1); + CHECK(ret, FAIL, "H5Fclose"); +} /* test_write_same_element */ + +/**************************************************************** ** ** test_vlstrings(): Main VL string testing routine. ** @@ -869,9 +968,10 @@ test_vlstrings(void) /* Test writing VL datasets in files with lots of unlinking */ test_vl_rewrite(); + /* Test writing to the same element more than once using H5Sselect_elements */ + test_write_same_element(); } /* test_vlstrings() */ - /*------------------------------------------------------------------------- * Function: cleanup_vlstrings * @@ -891,5 +991,6 @@ cleanup_vlstrings(void) { HDremove(DATAFILE); HDremove(DATAFILE2); + HDremove(DATAFILE3); } diff --git a/test/vds_swmr_gen.c b/test/vds_swmr_gen.c index 24c6131..1cb9744 100644 --- a/test/vds_swmr_gen.c +++ b/test/vds_swmr_gen.c @@ -61,7 +61,7 @@ main(void) map_start = 0; /* All SWMR files need to use the latest file format */ - if((faplid = H5Pcreate(H5P_FILE_ACCESS)) < 0) + if((faplid = h5_fileaccess()) < 0) TEST_ERROR if(H5Pset_libver_bounds(faplid, H5F_LIBVER_LATEST, H5F_LIBVER_LATEST) < 0) TEST_ERROR diff --git a/test/vds_swmr_reader.c b/test/vds_swmr_reader.c index 16f3abe..d0ec77b 100644 --- a/test/vds_swmr_reader.c +++ b/test/vds_swmr_reader.c @@ -18,6 +18,7 @@ int main(void) { hid_t fid = -1; /* HDF5 file ID */ + hid_t faplid = -1; /* file access property list ID */ hid_t did = -1; /* dataset ID */ hid_t msid = -1; /* memory dataspace ID */ hid_t fsid = -1; /* file dataspace ID */ @@ -34,7 +35,9 @@ main(void) /* Open the VDS file and dataset */ - if((fid = H5Fopen(VDS_FILE_NAME, H5F_ACC_RDONLY | H5F_ACC_SWMR_READ, H5P_DEFAULT)) < 0) + if((faplid = h5_fileaccess()) < 0) + TEST_ERROR + if((fid = H5Fopen(VDS_FILE_NAME, H5F_ACC_RDONLY | H5F_ACC_SWMR_READ, faplid)) < 0) TEST_ERROR if((did = H5Dopen2(fid, VDS_DSET_NAME, H5P_DEFAULT)) < 0) TEST_ERROR @@ -103,6 +106,8 @@ main(void) } while (dims[0] < N_PLANES_TO_WRITE); /* Close file and dataset */ + if(H5Pclose(faplid) < 0) + TEST_ERROR if(H5Sclose(msid) < 0) TEST_ERROR if(H5Dclose(did) < 0) @@ -120,6 +125,8 @@ error: H5E_BEGIN_TRY { if(fid >= 0) (void)H5Fclose(fid); + if(faplid >= 0) + (void)H5Pclose(faplid); if(did >= 0) (void)H5Dclose(did); if(msid >= 0) diff --git a/test/vds_swmr_writer.c b/test/vds_swmr_writer.c index 7824aa0..d62ecaf 100644 --- a/test/vds_swmr_writer.c +++ b/test/vds_swmr_writer.c @@ -56,7 +56,7 @@ main(int argc, char *argv[]) /* Open the source file and dataset */ /* All SWMR files need to use the latest file format */ - if((faplid = H5Pcreate(H5P_FILE_ACCESS)) < 0) + if((faplid = h5_fileaccess()) < 0) TEST_ERROR if(H5Pset_libver_bounds(faplid, H5F_LIBVER_LATEST, H5F_LIBVER_LATEST) < 0) TEST_ERROR @@ -19,7 +19,6 @@ */ #include "h5test.h" -#include "H5VLnative_private.h" #define NATIVE_VOL_TEST_FILENAME "native_vol_test" @@ -41,13 +40,21 @@ */ static const H5VL_class_t fake_vol_g = { 0, /* version */ - (H5VL_class_value_t)999, /* value */ + (H5VL_class_value_t)501, /* value */ FAKE_VOL_NAME, /* name */ + 0, /* capability flags */ NULL, /* initialize */ NULL, /* terminate */ - (size_t)0, /* fapl size */ - NULL, /* fapl copy */ - NULL, /* fapl free */ + (size_t)0, /* info size */ + NULL, /* info copy */ + NULL, /* info compare */ + NULL, /* info free */ + NULL, /* info to str */ + NULL, /* str to info */ + NULL, /* get_object */ + NULL, /* get_wrap_ctx */ + NULL, /* wrap_object */ + NULL, /* free_wrap_ctx */ { /* attribute_cls */ NULL, /* create */ NULL, /* open */ @@ -107,10 +114,13 @@ static const H5VL_class_t fake_vol_g = { NULL, /* specific */ NULL /* optional */ }, - { /* async_cls */ + { /* request_cls */ + NULL, /* wait */ + NULL, /* notify */ NULL, /* cancel */ - NULL, /* test */ - NULL /* wait */ + NULL, /* specific */ + NULL, /* optional */ + NULL /* free */ }, NULL /* optional */ }; @@ -120,7 +130,7 @@ static const H5VL_class_t fake_vol_g = { * Function: test_vol_registration() * * Purpose: Tests if we can load, register, and close a simple - * VOL driver. + * VOL connector. * * Return: SUCCEED/FAIL * @@ -130,28 +140,48 @@ static herr_t test_vol_registration(void) { htri_t is_registered; - hid_t vol_id = -1; + hid_t vol_id = -1, vol_id2 = -1; TESTING("VOL registration"); - /* The test/fake VOL driver should not be registered at the start of the test */ - if ((is_registered = H5VLis_driver_registered(FAKE_VOL_NAME)) < 0) + /* The test/fake VOL connector should not be registered at the start of the test */ + if ((is_registered = H5VLis_connector_registered(FAKE_VOL_NAME)) < 0) FAIL_STACK_ERROR; if (is_registered > 0) - FAIL_PUTS_ERROR("native VOL driver is inappropriately registered"); + FAIL_PUTS_ERROR("native VOL connector is inappropriately registered"); /* Load a VOL interface */ - if ((vol_id = H5VLregister_driver(&fake_vol_g)) < 0) + if ((vol_id = H5VLregister_connector(&fake_vol_g, H5P_DEFAULT)) < 0) FAIL_STACK_ERROR; - /* The test/fake VOL driver should be registered now */ - if ((is_registered = H5VLis_driver_registered(FAKE_VOL_NAME)) < 0) + /* The test/fake VOL connector should be registered now */ + if ((is_registered = H5VLis_connector_registered(FAKE_VOL_NAME)) < 0) FAIL_STACK_ERROR; if (0 == is_registered) - FAIL_PUTS_ERROR("native VOL driver is un-registered"); + FAIL_PUTS_ERROR("native VOL connector is un-registered"); - /* Close the VOL interface */ - if (H5VLclose(vol_id) < 0) + /* Re-register a VOL connector */ + if ((vol_id2 = H5VLregister_connector(&fake_vol_g, H5P_DEFAULT)) < 0) + FAIL_STACK_ERROR; + + /* The test/fake VOL connector should still be registered now */ + if ((is_registered = H5VLis_connector_registered(FAKE_VOL_NAME)) < 0) + FAIL_STACK_ERROR; + if (0 == is_registered) + FAIL_PUTS_ERROR("native VOL connector is un-registered"); + + /* Unregister the second test/fake VOL ID */ + if (H5VLunregister_connector(vol_id2) < 0) + FAIL_STACK_ERROR; + + /* The test/fake VOL connector should still be registered now */ + if ((is_registered = H5VLis_connector_registered(FAKE_VOL_NAME)) < 0) + FAIL_STACK_ERROR; + if (0 == is_registered) + FAIL_PUTS_ERROR("native VOL connector is un-registered"); + + /* Unregister the original test/fake VOL ID */ + if (H5VLunregister_connector(vol_id) < 0) FAIL_STACK_ERROR; PASSED(); @@ -159,7 +189,7 @@ test_vol_registration(void) error: H5E_BEGIN_TRY { - H5VLclose(vol_id); + H5VLunregister_connector(vol_id); } H5E_END_TRY; return FAIL; @@ -169,7 +199,7 @@ error: /*------------------------------------------------------------------------- * Function: test_native_vol_init() * - * Purpose: Tests if the native VOL driver gets initialized. + * Purpose: Tests if the native VOL connector gets initialized. * * Return: SUCCEED/FAIL * @@ -180,13 +210,13 @@ test_native_vol_init(void) { htri_t is_registered; - TESTING("Native VOL driver initialization"); + TESTING("Native VOL connector initialization"); - /* The native VOL driver should always be registered */ - if ((is_registered = H5VLis_driver_registered(H5VL_NATIVE_NAME)) < 0) + /* The native VOL connector should always be registered */ + if ((is_registered = H5VLis_connector_registered(H5VL_NATIVE_NAME)) < 0) FAIL_STACK_ERROR; if (0 == is_registered) - FAIL_PUTS_ERROR("native VOL driver is un-registered"); + FAIL_PUTS_ERROR("native VOL connector is un-registered"); PASSED(); return SUCCEED; @@ -200,7 +230,7 @@ error: /*------------------------------------------------------------------------- * Function: test_basic_file_operation() * - * Purpose: Uses the native VOL driver to test basic VOL file operations + * Purpose: Uses the native VOL connector to test basic VOL file operations * * Return: SUCCEED/FAIL * @@ -212,6 +242,7 @@ test_basic_file_operation(void) hid_t fid = H5I_INVALID_HID; hid_t fid_reopen = H5I_INVALID_HID; hid_t fapl_id = H5I_INVALID_HID; + hid_t fapl_id2 = H5I_INVALID_HID; hid_t fcpl_id = H5I_INVALID_HID; ssize_t obj_count; @@ -224,8 +255,25 @@ test_basic_file_operation(void) TESTING("Basic VOL file operations"); + /* Retrieve the file access property for testing */ + fapl_id = h5_fileaccess(); + + /* Set the file close degree to a non-default value, to make the H5Pequal + * work out. This is kinda odd, but the library's current behavior with + * a default value is to return the value chosen (H5F_CLOSE_SEMI) instead + * of the default value (H5F_CLOSE_DEFAULT) from the property and then + * the H5Pequal doesn't detect that the property lists are the same. Since + * this is the documented behavior for file close degree for many years, + * I'm not fighting it, just getting the testing to verify that the VOL + * connector property is returned correctly. -QAK, 2018/11/17 + */ + if(H5Pset_fclose_degree(fapl_id, H5F_CLOSE_SEMI) < 0) + TEST_ERROR; + if(H5Pset_metadata_read_attempts(fapl_id, 9) < 0) + FAIL_STACK_ERROR + /* H5Fcreate */ - if ((fid = H5Fcreate(NATIVE_VOL_TEST_FILENAME, H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT)) < 0) + if ((fid = H5Fcreate(NATIVE_VOL_TEST_FILENAME, H5F_ACC_TRUNC, H5P_DEFAULT, fapl_id)) < 0) TEST_ERROR; /* H5Fget_obj_count */ @@ -243,9 +291,11 @@ test_basic_file_operation(void) TEST_ERROR; /* H5Fget_access_plist */ - if ((fapl_id = H5Fget_access_plist(fid)) < 0) + if ((fapl_id2 = H5Fget_access_plist(fid)) < 0) TEST_ERROR; - if (H5Pclose(fapl_id) < 0) + if (H5Pequal(fapl_id, fapl_id2) != TRUE) + TEST_ERROR; + if (H5Pclose(fapl_id2) < 0) TEST_ERROR; /* H5Fget_create_plist */ @@ -287,19 +337,41 @@ test_basic_file_operation(void) TEST_ERROR; /* H5Fis_accessible */ - if (H5Fis_accessible(NATIVE_VOL_TEST_FILENAME, H5P_DEFAULT) < 0) + if (H5Fis_accessible(NATIVE_VOL_TEST_FILENAME, fapl_id) < 0) TEST_ERROR; /* H5Fopen */ - if ((fid = H5Fopen(NATIVE_VOL_TEST_FILENAME, H5F_ACC_RDWR, H5P_DEFAULT)) < 0) + if ((fid = H5Fopen(NATIVE_VOL_TEST_FILENAME, H5F_ACC_RDWR, fapl_id)) < 0) + TEST_ERROR; + + /* H5Fget_access_plist */ + if ((fapl_id2 = H5Fget_access_plist(fid)) < 0) TEST_ERROR; + if (H5Pequal(fapl_id, fapl_id2) != TRUE) + TEST_ERROR; + if (H5Pclose(fapl_id2) < 0) + TEST_ERROR; + if ((fid_reopen = H5Freopen(fid)) < 0) TEST_ERROR; + + /* H5Fget_access_plist */ + if ((fapl_id2 = H5Fget_access_plist(fid_reopen)) < 0) + TEST_ERROR; + if (H5Pequal(fapl_id, fapl_id2) != TRUE) + TEST_ERROR; + if (H5Pclose(fapl_id2) < 0) + TEST_ERROR; + if (H5Fclose(fid) < 0) TEST_ERROR; if (H5Fclose(fid_reopen) < 0) TEST_ERROR; + /* H5Pclose */ + if (H5Pclose(fapl_id) < 0) + TEST_ERROR; + HDremove(NATIVE_VOL_TEST_FILENAME); PASSED(); @@ -310,6 +382,7 @@ error: H5Fclose(fid); H5Fclose(fid_reopen); H5Pclose(fapl_id); + H5Pclose(fapl_id2); H5Pclose(fcpl_id); } H5E_END_TRY; @@ -321,7 +394,7 @@ error: /*------------------------------------------------------------------------- * Function: test_basic_group_operation() * - * Purpose: Uses the native VOL driver to test basic VOL group operations + * Purpose: Uses the native VOL connector to test basic VOL group operations * * Return: SUCCEED/FAIL * @@ -412,7 +485,7 @@ error: /*------------------------------------------------------------------------- * Function: test_basic_dataset_operation() * - * Purpose: Uses the native VOL driver to test basic VOL dataset operations + * Purpose: Uses the native VOL connector to test basic VOL dataset operations * * Return: SUCCEED/FAIL * @@ -581,7 +654,7 @@ error: /*------------------------------------------------------------------------- * Function: test_basic_attribute_operation() * - * Purpose: Uses the native VOL driver to test basic VOL attribute operations + * Purpose: Uses the native VOL connector to test basic VOL attribute operations * * Return: SUCCEED/FAIL * @@ -679,7 +752,7 @@ error: /*------------------------------------------------------------------------- * Function: test_basic_object_operation() * - * Purpose: Uses the native VOL driver to test basic VOL object operations + * Purpose: Uses the native VOL connector to test basic VOL object operations * * Return: SUCCEED/FAIL * @@ -743,7 +816,7 @@ error: /*------------------------------------------------------------------------- * Function: test_basic_link_operation() * - * Purpose: Uses the native VOL driver to test basic VOL link operations + * Purpose: Uses the native VOL connector to test basic VOL link operations * * Return: SUCCEED/FAIL * @@ -808,7 +881,7 @@ error: /*------------------------------------------------------------------------- * Function: test_basic_datatype_operation() * - * Purpose: Uses the native VOL driver to test basic VOL datatype operations + * Purpose: Uses the native VOL connector to test basic VOL datatype operations * * Return: SUCCEED/FAIL * @@ -890,7 +963,7 @@ error: /*------------------------------------------------------------------------- * Function: test_echo_vol_operation() * - * Purpose: Uses the echo VOL driver to test basic VOL operations + * Purpose: Uses the echo VOL connector to test basic VOL operations * via the H5VL public API. * * Return: SUCCEED/FAIL diff --git a/testpar/CMakeTests.cmake b/testpar/CMakeTests.cmake index 87470f3..dffb813 100644 --- a/testpar/CMakeTests.cmake +++ b/testpar/CMakeTests.cmake @@ -27,47 +27,12 @@ endforeach () set_property (TEST TEST_PAR_t_pflush1 PROPERTY PASS_REGULAR_EXPRESSION "PASSED") set_tests_properties (TEST_PAR_t_pflush2 PROPERTIES DEPENDS TEST_PAR_t_pflush1) -if (HDF5_TEST_VFD) - - set (VFD_LIST - sec2 - stdio - core - split - multi - family - ) - - set (H5P_VFD_TESTS - t_pflush1 - t_pflush2 - ) - - if (DIRECT_VFD) - set (VFD_LIST ${VFD_LIST} direct) - endif () - - macro (ADD_VFD_TEST vfdname resultcode) - if (NOT HDF5_ENABLE_USING_MEMCHECKER) - foreach (test ${H5P_VFD_TESTS}) - add_test ( - NAME TEST_PAR_VFD-${vfdname}-${test} - COMMAND "${CMAKE_COMMAND}" - -D "TEST_PROGRAM=$<TARGET_FILE:${test}>" - -D "TEST_ARGS:STRING=" - -D "TEST_VFD:STRING=${vfdname}" - -D "TEST_EXPECT=${resultcode}" - -D "TEST_OUTPUT=${test}" - -D "TEST_FOLDER=${PROJECT_BINARY_DIR}" - -P "${HDF_RESOURCES_DIR}/vfdTest.cmake" - ) - endforeach () - endif () - endmacro () - - # Run test with different Virtual File Driver - foreach (vfd ${VFD_LIST}) - ADD_VFD_TEST (${vfd} 0) - endforeach () +############################################################################## +############################################################################## +### V F D T E S T S ### +############################################################################## +############################################################################## +if (HDF5_TEST_VFD) + include (CMakeVFDTests.cmake) endif () diff --git a/testpar/CMakeVFDTests.cmake b/testpar/CMakeVFDTests.cmake new file mode 100644 index 0000000..b6b065f --- /dev/null +++ b/testpar/CMakeVFDTests.cmake @@ -0,0 +1,57 @@ +# +# 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 COPYING file, which can be found at the root of the source code +# distribution tree, or in https://support.hdfgroup.org/ftp/HDF5/releases. +# If you do not have access to either file, you may request a copy from +# help@hdfgroup.org. +# + +############################################################################## +############################################################################## +### T E S T I N G ### +############################################################################## +############################################################################## + set (VFD_LIST + sec2 + stdio + core + split + multi + family + ) + + set (H5P_VFD_TESTS + t_pflush1 + t_pflush2 + ) + + if (DIRECT_VFD) + set (VFD_LIST ${VFD_LIST} direct) + endif () + + macro (ADD_VFD_TEST vfdname resultcode) + if (NOT HDF5_ENABLE_USING_MEMCHECKER) + foreach (test ${H5P_VFD_TESTS}) + add_test ( + NAME TEST_PAR_VFD-${vfdname}-${test} + COMMAND "${CMAKE_COMMAND}" + -D "TEST_PROGRAM=$<TARGET_FILE:${test}>" + -D "TEST_ARGS:STRING=" + -D "TEST_VFD:STRING=${vfdname}" + -D "TEST_EXPECT=${resultcode}" + -D "TEST_OUTPUT=${test}" + -D "TEST_FOLDER=${PROJECT_BINARY_DIR}" + -P "${HDF_RESOURCES_DIR}/vfdTest.cmake" + ) + endforeach () + endif () + endmacro () + + # Run test with different Virtual File Driver + foreach (vfd ${VFD_LIST}) + ADD_VFD_TEST (${vfd} 0) + endforeach () diff --git a/testpar/t_filters_parallel.c b/testpar/t_filters_parallel.c index f436c8f..1f26e0d 100644 --- a/testpar/t_filters_parallel.c +++ b/testpar/t_filters_parallel.c @@ -32,9 +32,28 @@ char filenames[1][256]; int nerrors = 0; size_t cur_filter_idx = 0; +#define GZIP_INDEX 0 +#define FLETCHER32_INDEX 1 #define ARRAY_SIZE(a) sizeof(a) / sizeof(a[0]) +/* + * Used to check if a filter is available before running a test. + */ +#define CHECK_CUR_FILTER_AVAIL() \ +{ \ + htri_t filter_is_avail; \ + \ + if (cur_filter_idx == GZIP_INDEX) { \ + if ((filter_is_avail = H5Zfilter_avail(H5Z_FILTER_DEFLATE)) != TRUE) { \ + if (MAINPROCESS) { \ + HDputs(" - SKIPPED - Deflate filter not available"); \ + } \ + return; \ + } \ + } \ +} + static herr_t set_dcpl_filter(hid_t dcpl); #if MPI_VERSION >= 3 @@ -144,9 +163,9 @@ static herr_t set_dcpl_filter(hid_t dcpl) { switch (cur_filter_idx) { - case 0: + case GZIP_INDEX: return H5Pset_deflate(dcpl, DEFAULT_DEFLATE_LEVEL); - case 1: + case FLETCHER32_INDEX: return H5Pset_fletcher32(dcpl); default: return H5Pset_deflate(dcpl, DEFAULT_DEFLATE_LEVEL); @@ -178,7 +197,9 @@ test_write_one_chunk_filtered_dataset(void) hid_t file_id = -1, dset_id = -1, plist_id = -1; hid_t filespace = -1, memspace = -1; - if (MAINPROCESS) puts("Testing write to one-chunk filtered dataset"); + if (MAINPROCESS) HDputs("Testing write to one-chunk filtered dataset"); + + CHECK_CUR_FILTER_AVAIL(); /* Set up file access property list with parallel I/O access */ plist_id = H5Pcreate(H5P_FILE_ACCESS); @@ -238,9 +259,9 @@ test_write_one_chunk_filtered_dataset(void) start[1] = 0; if (VERBOSE_MED) { - printf("Process %d is writing with count[ %llu, %llu ], stride[ %llu, %llu ], start[ %llu, %llu ], block size[ %llu, %llu ]\n", + HDprintf("Process %d is writing with count[ %llu, %llu ], stride[ %llu, %llu ], start[ %llu, %llu ], block size[ %llu, %llu ]\n", mpi_rank, count[0], count[1], stride[0], stride[1], start[0], start[1], block[0], block[1]); - fflush(stdout); + HDfflush(stdout); } /* Select hyperslab in the file */ @@ -292,7 +313,7 @@ test_write_one_chunk_filtered_dataset(void) VRFY((H5Dread(dset_id, HDF5_DATATYPE_NAME, H5S_ALL, H5S_ALL, plist_id, read_buf) >= 0), "Dataset read succeeded"); - VRFY((0 == memcmp(read_buf, correct_buf, correct_buf_size)), + VRFY((0 == HDmemcmp(read_buf, correct_buf, correct_buf_size)), "Data verification succeeded"); if (correct_buf) HDfree(correct_buf); @@ -333,7 +354,9 @@ test_write_filtered_dataset_no_overlap(void) hid_t file_id = -1, dset_id = -1, plist_id = -1; hid_t filespace = -1, memspace = -1; - if (MAINPROCESS) puts("Testing write to unshared filtered chunks"); + if (MAINPROCESS) HDputs("Testing write to unshared filtered chunks"); + + CHECK_CUR_FILTER_AVAIL(); /* Set up file access property list with parallel I/O access */ plist_id = H5Pcreate(H5P_FILE_ACCESS); @@ -394,9 +417,9 @@ test_write_filtered_dataset_no_overlap(void) start[1] = 0; if (VERBOSE_MED) { - printf("Process %d is writing with count[ %llu, %llu ], stride[ %llu, %llu ], start[ %llu, %llu ], block size[ %llu, %llu ]\n", + HDprintf("Process %d is writing with count[ %llu, %llu ], stride[ %llu, %llu ], start[ %llu, %llu ], block size[ %llu, %llu ]\n", mpi_rank, count[0], count[1], stride[0], stride[1], start[0], start[1], block[0], block[1]); - fflush(stdout); + HDfflush(stdout); } /* Select hyperslab in the file */ @@ -450,7 +473,7 @@ test_write_filtered_dataset_no_overlap(void) VRFY((H5Dread(dset_id, HDF5_DATATYPE_NAME, H5S_ALL, H5S_ALL, plist_id, read_buf) >= 0), "Dataset read succeeded"); - VRFY((0 == memcmp(read_buf, correct_buf, correct_buf_size)), + VRFY((0 == HDmemcmp(read_buf, correct_buf, correct_buf_size)), "Data verification succeeded"); if (correct_buf) HDfree(correct_buf); @@ -492,7 +515,9 @@ test_write_filtered_dataset_overlap(void) hid_t file_id = -1, dset_id = -1, plist_id = -1; hid_t filespace = -1, memspace = -1; - if (MAINPROCESS) puts("Testing write to shared filtered chunks"); + if (MAINPROCESS) HDputs("Testing write to shared filtered chunks"); + + CHECK_CUR_FILTER_AVAIL(); /* Set up file access property list with parallel I/O access */ plist_id = H5Pcreate(H5P_FILE_ACCESS); @@ -553,9 +578,9 @@ test_write_filtered_dataset_overlap(void) start[1] = 0; if (VERBOSE_MED) { - printf("Process %d is writing with count[ %llu, %llu ], stride[ %llu, %llu ], start[ %llu, %llu ], block size[ %llu, %llu ]\n", + HDprintf("Process %d is writing with count[ %llu, %llu ], stride[ %llu, %llu ], start[ %llu, %llu ], block size[ %llu, %llu ]\n", mpi_rank, count[0], count[1], stride[0], stride[1], start[0], start[1], block[0], block[1]); - fflush(stdout); + HDfflush(stdout); } /* Select hyperslab in the file */ @@ -609,7 +634,7 @@ test_write_filtered_dataset_overlap(void) VRFY((H5Dread(dset_id, HDF5_DATATYPE_NAME, H5S_ALL, H5S_ALL, plist_id, read_buf) >= 0), "Dataset read succeeded"); - VRFY((0 == memcmp(read_buf, correct_buf, correct_buf_size)), + VRFY((0 == HDmemcmp(read_buf, correct_buf, correct_buf_size)), "Data verification succeeded"); if (correct_buf) HDfree(correct_buf); @@ -654,7 +679,9 @@ test_write_filtered_dataset_single_no_selection(void) hid_t file_id = -1, dset_id = -1, plist_id = -1; hid_t filespace = -1, memspace = -1; - if (MAINPROCESS) puts("Testing write to filtered chunks with a single process having no selection"); + if (MAINPROCESS) HDputs("Testing write to filtered chunks with a single process having no selection"); + + CHECK_CUR_FILTER_AVAIL(); /* Set up file access property list with parallel I/O access */ plist_id = H5Pcreate(H5P_FILE_ACCESS); @@ -718,9 +745,9 @@ test_write_filtered_dataset_single_no_selection(void) start[1] = 0; if (VERBOSE_MED) { - printf("Process %d is writing with count[ %llu, %llu ], stride[ %llu, %llu ], start[ %llu, %llu ], block size[ %llu, %llu ]\n", + HDprintf("Process %d is writing with count[ %llu, %llu ], stride[ %llu, %llu ], start[ %llu, %llu ], block size[ %llu, %llu ]\n", mpi_rank, count[0], count[1], stride[0], stride[1], start[0], start[1], block[0], block[1]); - fflush(stdout); + HDfflush(stdout); } /* Select hyperslab in the file */ @@ -782,7 +809,7 @@ test_write_filtered_dataset_single_no_selection(void) VRFY((H5Dread(dset_id, HDF5_DATATYPE_NAME, H5S_ALL, H5S_ALL, plist_id, read_buf) >= 0), "Dataset read succeeded"); - VRFY((0 == memcmp(read_buf, correct_buf, correct_buf_size)), + VRFY((0 == HDmemcmp(read_buf, correct_buf, correct_buf_size)), "Data verification succeeded"); if (correct_buf) HDfree(correct_buf); @@ -823,7 +850,9 @@ test_write_filtered_dataset_all_no_selection(void) hid_t file_id = -1, dset_id = -1, plist_id = -1; hid_t filespace = -1, memspace = -1; - if (MAINPROCESS) puts("Testing write to filtered chunks with all processes having no selection"); + if (MAINPROCESS) HDputs("Testing write to filtered chunks with all processes having no selection"); + + CHECK_CUR_FILTER_AVAIL(); /* Set up file access property list with parallel I/O access */ plist_id = H5Pcreate(H5P_FILE_ACCESS); @@ -912,7 +941,7 @@ test_write_filtered_dataset_all_no_selection(void) VRFY((H5Dread(dset_id, HDF5_DATATYPE_NAME, H5S_ALL, H5S_ALL, plist_id, read_buf) >= 0), "Dataset read succeeded"); - VRFY((0 == memcmp(read_buf, correct_buf, correct_buf_size)), + VRFY((0 == HDmemcmp(read_buf, correct_buf, correct_buf_size)), "Data verification succeeded"); if (correct_buf) HDfree(correct_buf); @@ -949,7 +978,9 @@ test_write_filtered_dataset_point_selection(void) hid_t file_id = -1, dset_id = -1, plist_id = -1; hid_t filespace = -1, memspace = -1; - if (MAINPROCESS) puts("Testing write to filtered chunks with point selection"); + if (MAINPROCESS) HDputs("Testing write to filtered chunks with point selection"); + + CHECK_CUR_FILTER_AVAIL(); /* Set up file access property list with parallel I/O access */ plist_id = H5Pcreate(H5P_FILE_ACCESS); @@ -1058,7 +1089,7 @@ test_write_filtered_dataset_point_selection(void) VRFY((H5Dread(dset_id, HDF5_DATATYPE_NAME, H5S_ALL, H5S_ALL, plist_id, read_buf) >= 0), "Dataset read succeeded"); - VRFY((0 == memcmp(read_buf, correct_buf, correct_buf_size)), + VRFY((0 == HDmemcmp(read_buf, correct_buf, correct_buf_size)), "Data verification succeeded"); if (coords) HDfree(coords); @@ -1102,7 +1133,9 @@ test_write_filtered_dataset_interleaved_write(void) hid_t file_id = -1, dset_id = -1, plist_id = -1; hid_t filespace = -1, memspace = -1; - if (MAINPROCESS) puts("Testing interleaved write to filtered chunks"); + if (MAINPROCESS) HDputs("Testing interleaved write to filtered chunks"); + + CHECK_CUR_FILTER_AVAIL(); /* Set up file access property list with parallel I/O access */ plist_id = H5Pcreate(H5P_FILE_ACCESS); @@ -1163,9 +1196,9 @@ test_write_filtered_dataset_interleaved_write(void) start[1] = 0; if (VERBOSE_MED) { - printf("Process %d is writing with count[ %llu, %llu ], stride[ %llu, %llu ], start[ %llu, %llu ], block size[ %llu, %llu ]\n", + HDprintf("Process %d is writing with count[ %llu, %llu ], stride[ %llu, %llu ], start[ %llu, %llu ], block size[ %llu, %llu ]\n", mpi_rank, count[0], count[1], stride[0], stride[1], start[0], start[1], block[0], block[1]); - fflush(stdout); + HDfflush(stdout); } /* Select hyperslab in the file */ @@ -1225,7 +1258,7 @@ test_write_filtered_dataset_interleaved_write(void) VRFY((H5Dread(dset_id, HDF5_DATATYPE_NAME, H5S_ALL, H5S_ALL, plist_id, read_buf) >= 0), "Dataset read succeeded"); - VRFY((0 == memcmp(read_buf, correct_buf, correct_buf_size)), + VRFY((0 == HDmemcmp(read_buf, correct_buf, correct_buf_size)), "Data verification succeeded"); if (correct_buf) HDfree(correct_buf); @@ -1265,7 +1298,9 @@ test_write_3d_filtered_dataset_no_overlap_separate_pages(void) hid_t file_id = -1, dset_id = -1, plist_id = -1; hid_t filespace = -1, memspace = -1; - if (MAINPROCESS) puts("Testing write to unshared filtered chunks on separate pages in 3D dataset"); + if (MAINPROCESS) HDputs("Testing write to unshared filtered chunks on separate pages in 3D dataset"); + + CHECK_CUR_FILTER_AVAIL(); /* Set up file access property list with parallel I/O access */ plist_id = H5Pcreate(H5P_FILE_ACCESS); @@ -1333,9 +1368,9 @@ test_write_3d_filtered_dataset_no_overlap_separate_pages(void) start[2] = (hsize_t) mpi_rank; if (VERBOSE_MED) { - printf("Process %d is writing with count[ %llu, %llu, %llu ], stride[ %llu, %llu, %llu ], start[ %llu, %llu, %llu ], block size[ %llu, %llu, %llu ]\n", + HDprintf("Process %d is writing with count[ %llu, %llu, %llu ], stride[ %llu, %llu, %llu ], start[ %llu, %llu, %llu ], block size[ %llu, %llu, %llu ]\n", mpi_rank, count[0], count[1], count[2], stride[0], stride[1], stride[2], start[0], start[1], start[2], block[0], block[1], block[2]); - fflush(stdout); + HDfflush(stdout); } /* Select hyperslab in the file */ @@ -1385,7 +1420,7 @@ test_write_3d_filtered_dataset_no_overlap_separate_pages(void) VRFY((H5Dread(dset_id, HDF5_DATATYPE_NAME, H5S_ALL, H5S_ALL, plist_id, read_buf) >= 0), "Dataset read succeeded"); - VRFY((0 == memcmp(read_buf, correct_buf, correct_buf_size)), + VRFY((0 == HDmemcmp(read_buf, correct_buf, correct_buf_size)), "Data verification succeeded"); if (correct_buf) HDfree(correct_buf); @@ -1426,7 +1461,9 @@ test_write_3d_filtered_dataset_no_overlap_same_pages(void) hid_t file_id, dset_id, plist_id; hid_t filespace, memspace; - if (MAINPROCESS) puts("Testing write to unshared filtered chunks on the same pages in 3D dataset"); + if (MAINPROCESS) HDputs("Testing write to unshared filtered chunks on the same pages in 3D dataset"); + + CHECK_CUR_FILTER_AVAIL(); /* Set up file access property list with parallel I/O access */ plist_id = H5Pcreate(H5P_FILE_ACCESS); @@ -1494,9 +1531,9 @@ test_write_3d_filtered_dataset_no_overlap_same_pages(void) start[2] = 0; if (VERBOSE_MED) { - printf("Process %d is writing with count[ %llu, %llu, %llu ], stride[ %llu, %llu, %llu ], start[ %llu, %llu, %llu ], block size[ %llu, %llu, %llu ]\n", + HDprintf("Process %d is writing with count[ %llu, %llu, %llu ], stride[ %llu, %llu, %llu ], start[ %llu, %llu, %llu ], block size[ %llu, %llu, %llu ]\n", mpi_rank, count[0], count[1], count[2], stride[0], stride[1], stride[2], start[0], start[1], start[2], block[0], block[1], block[2]); - fflush(stdout); + HDfflush(stdout); } /* Select hyperslab in the file */ @@ -1549,7 +1586,7 @@ test_write_3d_filtered_dataset_no_overlap_same_pages(void) VRFY((H5Dread(dset_id, HDF5_DATATYPE_NAME, H5S_ALL, H5S_ALL, plist_id, read_buf) >= 0), "Dataset read succeeded"); - VRFY((0 == memcmp(read_buf, correct_buf, correct_buf_size)), + VRFY((0 == HDmemcmp(read_buf, correct_buf, correct_buf_size)), "Data verification succeeded"); if (correct_buf) HDfree(correct_buf); @@ -1590,7 +1627,9 @@ test_write_3d_filtered_dataset_overlap(void) hid_t file_id = -1, dset_id = -1, plist_id = -1; hid_t filespace = -1, memspace = -1; - if (MAINPROCESS) puts("Testing write to shared filtered chunks in 3D dataset"); + if (MAINPROCESS) HDputs("Testing write to shared filtered chunks in 3D dataset"); + + CHECK_CUR_FILTER_AVAIL(); /* Set up file access property list with parallel I/O access */ plist_id = H5Pcreate(H5P_FILE_ACCESS); @@ -1658,9 +1697,9 @@ test_write_3d_filtered_dataset_overlap(void) start[2] = 0; if (VERBOSE_MED) { - printf("Process %d is writing with count[ %llu, %llu, %llu ], stride[ %llu, %llu, %llu ], start[ %llu, %llu, %llu ], block size[ %llu, %llu, %llu ]\n", + HDprintf("Process %d is writing with count[ %llu, %llu, %llu ], stride[ %llu, %llu, %llu ], start[ %llu, %llu, %llu ], block size[ %llu, %llu, %llu ]\n", mpi_rank, count[0], count[1], count[2], stride[0], stride[1], stride[2], start[0], start[1], start[2], block[0], block[1], block[2]); - fflush(stdout); + HDfflush(stdout); } /* Select hyperslab in the file */ @@ -1722,7 +1761,7 @@ test_write_3d_filtered_dataset_overlap(void) VRFY((H5Dread(dset_id, HDF5_DATATYPE_NAME, H5S_ALL, H5S_ALL, plist_id, read_buf) >= 0), "Dataset read succeeded"); - VRFY((0 == memcmp(read_buf, correct_buf, correct_buf_size)), + VRFY((0 == HDmemcmp(read_buf, correct_buf, correct_buf_size)), "Data verification succeeded"); if (correct_buf) HDfree(correct_buf); @@ -1762,7 +1801,9 @@ test_write_cmpd_filtered_dataset_no_conversion_unshared(void) hid_t file_id = -1, dset_id = -1, plist_id = -1, memtype = -1; hid_t filespace = -1, memspace = -1; - if (MAINPROCESS) puts("Testing write to unshared filtered chunks in Compound Datatype dataset without Datatype conversion"); + if (MAINPROCESS) HDputs("Testing write to unshared filtered chunks in Compound Datatype dataset without Datatype conversion"); + + CHECK_CUR_FILTER_AVAIL(); /* Set up file access property list with parallel I/O access */ plist_id = H5Pcreate(H5P_FILE_ACCESS); @@ -1834,9 +1875,9 @@ test_write_cmpd_filtered_dataset_no_conversion_unshared(void) start[1] = ((hsize_t) mpi_rank * WRITE_COMPOUND_FILTERED_CHUNKS_NO_CONVERSION_UNSHARED_CH_NCOLS); if (VERBOSE_MED) { - printf("Process %d is writing with count[ %llu, %llu ], stride[ %llu, %llu ], start[ %llu, %llu ], block size[ %llu, %llu ]\n", + HDprintf("Process %d is writing with count[ %llu, %llu ], stride[ %llu, %llu ], start[ %llu, %llu ], block size[ %llu, %llu ]\n", mpi_rank, count[0], count[1], stride[0], stride[1], start[0], start[1], block[0], block[1]); - fflush(stdout); + HDfflush(stdout); } /* Select hyperslab in the file */ @@ -1902,7 +1943,7 @@ test_write_cmpd_filtered_dataset_no_conversion_unshared(void) VRFY((H5Dread(dset_id, memtype, H5S_ALL, H5S_ALL, plist_id, read_buf) >= 0), "Dataset read succeeded"); - VRFY((0 == memcmp(read_buf, correct_buf, correct_buf_size)), + VRFY((0 == HDmemcmp(read_buf, correct_buf, correct_buf_size)), "Data verification succeeded"); if (correct_buf) HDfree(correct_buf); @@ -1943,7 +1984,9 @@ test_write_cmpd_filtered_dataset_no_conversion_shared(void) hid_t file_id, dset_id, plist_id, memtype; hid_t filespace, memspace; - if (MAINPROCESS) puts("Testing write to shared filtered chunks in Compound Datatype dataset without Datatype conversion"); + if (MAINPROCESS) HDputs("Testing write to shared filtered chunks in Compound Datatype dataset without Datatype conversion"); + + CHECK_CUR_FILTER_AVAIL(); /* Set up file access property list with parallel I/O access */ plist_id = H5Pcreate(H5P_FILE_ACCESS); @@ -2015,9 +2058,9 @@ test_write_cmpd_filtered_dataset_no_conversion_shared(void) start[1] = 0; if (VERBOSE_MED) { - printf("Process %d is writing with count[ %llu, %llu ], stride[ %llu, %llu ], start[ %llu, %llu ], block size[ %llu, %llu ]\n", + HDprintf("Process %d is writing with count[ %llu, %llu ], stride[ %llu, %llu ], start[ %llu, %llu ], block size[ %llu, %llu ]\n", mpi_rank, count[0], count[1], stride[0], stride[1], start[0], start[1], block[0], block[1]); - fflush(stdout); + HDfflush(stdout); } /* Select hyperslab in the file */ @@ -2086,7 +2129,7 @@ test_write_cmpd_filtered_dataset_no_conversion_shared(void) VRFY((H5Dread(dset_id, memtype, H5S_ALL, H5S_ALL, plist_id, read_buf) >= 0), "Dataset read succeeded"); - VRFY((0 == memcmp(read_buf, correct_buf, correct_buf_size)), + VRFY((0 == HDmemcmp(read_buf, correct_buf, correct_buf_size)), "Data verification succeeded"); if (correct_buf) HDfree(correct_buf); @@ -2132,7 +2175,9 @@ test_write_cmpd_filtered_dataset_type_conversion_unshared(void) hid_t file_id = -1, dset_id = -1, plist_id = -1, filetype = -1, memtype = -1; hid_t filespace = -1, memspace = -1; - if (MAINPROCESS) puts("Testing write to unshared filtered chunks in Compound Datatype dataset with Datatype conversion"); + if (MAINPROCESS) HDputs("Testing write to unshared filtered chunks in Compound Datatype dataset with Datatype conversion"); + + CHECK_CUR_FILTER_AVAIL(); /* Set up file access property list with parallel I/O access */ plist_id = H5Pcreate(H5P_FILE_ACCESS); @@ -2215,9 +2260,9 @@ test_write_cmpd_filtered_dataset_type_conversion_unshared(void) start[1] = ((hsize_t) mpi_rank * WRITE_COMPOUND_FILTERED_CHUNKS_TYPE_CONVERSION_UNSHARED_CH_NCOLS); if (VERBOSE_MED) { - printf("Process %d is writing with count[ %llu, %llu ], stride[ %llu, %llu ], start[ %llu, %llu ], block size[ %llu, %llu ]\n", + HDprintf("Process %d is writing with count[ %llu, %llu ], stride[ %llu, %llu ], start[ %llu, %llu ], block size[ %llu, %llu ]\n", mpi_rank, count[0], count[1], stride[0], stride[1], start[0], start[1], block[0], block[1]); - fflush(stdout); + HDfflush(stdout); } /* Select hyperslab in the file */ @@ -2269,7 +2314,7 @@ test_write_cmpd_filtered_dataset_type_conversion_unshared(void) VRFY((H5Dread(dset_id, memtype, H5S_ALL, H5S_ALL, plist_id, read_buf) >= 0), "Dataset read succeeded"); - VRFY((0 == memcmp(read_buf, correct_buf, correct_buf_size)), + VRFY((0 == HDmemcmp(read_buf, correct_buf, correct_buf_size)), "Data verification succeeded"); if (correct_buf) HDfree(correct_buf); @@ -2316,7 +2361,9 @@ test_write_cmpd_filtered_dataset_type_conversion_shared(void) hid_t file_id, dset_id, plist_id, filetype, memtype; hid_t filespace, memspace; - if (MAINPROCESS) puts("Testing write to shared filtered chunks in Compound Datatype dataset with Datatype conversion"); + if (MAINPROCESS) HDputs("Testing write to shared filtered chunks in Compound Datatype dataset with Datatype conversion"); + + CHECK_CUR_FILTER_AVAIL(); /* Set up file access property list with parallel I/O access */ plist_id = H5Pcreate(H5P_FILE_ACCESS); @@ -2399,9 +2446,9 @@ test_write_cmpd_filtered_dataset_type_conversion_shared(void) start[1] = 0; if (VERBOSE_MED) { - printf("Process %d is writing with count[ %llu, %llu ], stride[ %llu, %llu ], start[ %llu, %llu ], block size[ %llu, %llu ]\n", + HDprintf("Process %d is writing with count[ %llu, %llu ], stride[ %llu, %llu ], start[ %llu, %llu ], block size[ %llu, %llu ]\n", mpi_rank, count[0], count[1], stride[0], stride[1], start[0], start[1], block[0], block[1]); - fflush(stdout); + HDfflush(stdout); } /* Select hyperslab in the file */ @@ -2453,7 +2500,7 @@ test_write_cmpd_filtered_dataset_type_conversion_shared(void) VRFY((H5Dread(dset_id, memtype, H5S_ALL, H5S_ALL, plist_id, read_buf) >= 0), "Dataset read succeeded"); - VRFY((0 == memcmp(read_buf, correct_buf, correct_buf_size)), + VRFY((0 == HDmemcmp(read_buf, correct_buf, correct_buf_size)), "Data verification succeeded"); if (correct_buf) HDfree(correct_buf); @@ -2503,6 +2550,10 @@ test_read_one_chunk_filtered_dataset(void) int *recvcounts = NULL; int *displs = NULL; + if (MAINPROCESS) HDputs("Testing read from one-chunk filtered dataset"); + + CHECK_CUR_FILTER_AVAIL(); + dataset_dims[0] = (hsize_t) READ_ONE_CHUNK_FILTERED_DATASET_NROWS; dataset_dims[1] = (hsize_t) READ_ONE_CHUNK_FILTERED_DATASET_NCOLS; @@ -2517,8 +2568,6 @@ test_read_one_chunk_filtered_dataset(void) + ((C_DATATYPE) i / (READ_ONE_CHUNK_FILTERED_DATASET_CH_NROWS / mpi_size * READ_ONE_CHUNK_FILTERED_DATASET_CH_NCOLS)); if (MAINPROCESS) { - puts("Testing read from one-chunk filtered dataset"); - plist_id = H5Pcreate(H5P_FILE_ACCESS); VRFY((plist_id >= 0), "FAPL creation succeeded"); @@ -2606,9 +2655,9 @@ test_read_one_chunk_filtered_dataset(void) start[1] = 0; if (VERBOSE_MED) { - printf("Process %d is reading with count[ %llu, %llu ], stride[ %llu, %llu ], start[ %llu, %llu ], block size[ %llu, %llu ]\n", + HDprintf("Process %d is reading with count[ %llu, %llu ], stride[ %llu, %llu ], start[ %llu, %llu ], block size[ %llu, %llu ]\n", mpi_rank, count[0], count[1], stride[0], stride[1], start[0], start[1], block[0], block[1]); - fflush(stdout); + HDfflush(stdout); } VRFY((H5Sselect_hyperslab(filespace, H5S_SELECT_SET, start, stride, count, block) >= 0), @@ -2648,7 +2697,7 @@ test_read_one_chunk_filtered_dataset(void) VRFY((MPI_SUCCESS == MPI_Allgatherv(read_buf, (int) flat_dims[0], C_DATATYPE_MPI, global_buf, recvcounts, displs, C_DATATYPE_MPI, comm)), "MPI_Allgatherv succeeded"); - VRFY((0 == memcmp(global_buf, correct_buf, correct_buf_size)), + VRFY((0 == HDmemcmp(global_buf, correct_buf, correct_buf_size)), "Data verification succeeded"); if (displs) HDfree(displs); @@ -2698,6 +2747,10 @@ test_read_filtered_dataset_no_overlap(void) int *recvcounts = NULL; int *displs = NULL; + if (MAINPROCESS) HDputs("Testing read from unshared filtered chunks"); + + CHECK_CUR_FILTER_AVAIL(); + dataset_dims[0] = (hsize_t) READ_UNSHARED_FILTERED_CHUNKS_NROWS; dataset_dims[1] = (hsize_t) READ_UNSHARED_FILTERED_CHUNKS_NCOLS; @@ -2714,8 +2767,6 @@ test_read_filtered_dataset_no_overlap(void) ); if (MAINPROCESS) { - puts("Testing read from unshared filtered chunks"); - plist_id = H5Pcreate(H5P_FILE_ACCESS); VRFY((plist_id >= 0), "FAPL creation succeeded"); @@ -2803,9 +2854,9 @@ test_read_filtered_dataset_no_overlap(void) start[1] = 0; if (VERBOSE_MED) { - printf("Process %d is reading with count[ %llu, %llu ], stride[ %llu, %llu ], start[ %llu, %llu ], block size[ %llu, %llu ]\n", + HDprintf("Process %d is reading with count[ %llu, %llu ], stride[ %llu, %llu ], start[ %llu, %llu ], block size[ %llu, %llu ]\n", mpi_rank, count[0], count[1], stride[0], stride[1], start[0], start[1], block[0], block[1]); - fflush(stdout); + HDfflush(stdout); } VRFY((H5Sselect_hyperslab(filespace, H5S_SELECT_SET, start, stride, count, block) >= 0), @@ -2845,7 +2896,7 @@ test_read_filtered_dataset_no_overlap(void) VRFY((MPI_SUCCESS == MPI_Allgatherv(read_buf, (int) flat_dims[0], C_DATATYPE_MPI, global_buf, recvcounts, displs, C_DATATYPE_MPI, comm)), "MPI_Allgatherv succeeded"); - VRFY((0 == memcmp(global_buf, correct_buf, correct_buf_size)), + VRFY((0 == HDmemcmp(global_buf, correct_buf, correct_buf_size)), "Data verification succeeded"); if (displs) HDfree(displs); @@ -2896,6 +2947,10 @@ test_read_filtered_dataset_overlap(void) int *recvcounts = NULL; int *displs = NULL; + if (MAINPROCESS) HDputs("Testing read from shared filtered chunks"); + + CHECK_CUR_FILTER_AVAIL(); + dataset_dims[0] = (hsize_t) READ_SHARED_FILTERED_CHUNKS_NROWS; dataset_dims[1] = (hsize_t) READ_SHARED_FILTERED_CHUNKS_NCOLS; @@ -2913,8 +2968,6 @@ test_read_filtered_dataset_overlap(void) ); if (MAINPROCESS) { - puts("Testing read from shared filtered chunks"); - plist_id = H5Pcreate(H5P_FILE_ACCESS); VRFY((plist_id >= 0), "FAPL creation succeeded"); @@ -3002,9 +3055,9 @@ test_read_filtered_dataset_overlap(void) start[1] = 0; if (VERBOSE_MED) { - printf("Process %d is reading with count[ %llu, %llu ], stride[ %llu, %llu ], start[ %llu, %llu ], block size[ %llu, %llu ]\n", + HDprintf("Process %d is reading with count[ %llu, %llu ], stride[ %llu, %llu ], start[ %llu, %llu ], block size[ %llu, %llu ]\n", mpi_rank, count[0], count[1], stride[0], stride[1], start[0], start[1], block[0], block[1]); - fflush(stdout); + HDfflush(stdout); } VRFY((H5Sselect_hyperslab(filespace, H5S_SELECT_SET, start, stride, count, block) >= 0), @@ -3059,7 +3112,7 @@ test_read_filtered_dataset_overlap(void) } } - VRFY((0 == memcmp(global_buf, correct_buf, correct_buf_size)), + VRFY((0 == HDmemcmp(global_buf, correct_buf, correct_buf_size)), "Data verification succeeded"); if (displs) HDfree(displs); @@ -3111,6 +3164,10 @@ test_read_filtered_dataset_single_no_selection(void) int *recvcounts = NULL; int *displs = NULL; + if (MAINPROCESS) HDputs("Testing read from filtered chunks with a single process having no selection"); + + CHECK_CUR_FILTER_AVAIL(); + dataset_dims[0] = (hsize_t) READ_SINGLE_NO_SELECTION_FILTERED_CHUNKS_NROWS; dataset_dims[1] = (hsize_t) READ_SINGLE_NO_SELECTION_FILTERED_CHUNKS_NCOLS; @@ -3133,8 +3190,6 @@ test_read_filtered_dataset_single_no_selection(void) 0, segment_length * sizeof(*correct_buf)); if (MAINPROCESS) { - puts("Testing read from filtered chunks with a single process having no selection"); - plist_id = H5Pcreate(H5P_FILE_ACCESS); VRFY((plist_id >= 0), "FAPL creation succeeded"); @@ -3225,9 +3280,9 @@ test_read_filtered_dataset_single_no_selection(void) start[1] = 0; if (VERBOSE_MED) { - printf("Process %d is reading with count[ %llu, %llu ], stride[ %llu, %llu ], start[ %llu, %llu ], block size[ %llu, %llu ]\n", + HDprintf("Process %d is reading with count[ %llu, %llu ], stride[ %llu, %llu ], start[ %llu, %llu ], block size[ %llu, %llu ]\n", mpi_rank, count[0], count[1], stride[0], stride[1], start[0], start[1], block[0], block[1]); - fflush(stdout); + HDfflush(stdout); } if (mpi_rank == READ_SINGLE_NO_SELECTION_FILTERED_CHUNKS_NO_SELECT_PROC) @@ -3275,7 +3330,7 @@ test_read_filtered_dataset_single_no_selection(void) VRFY((MPI_SUCCESS == MPI_Allgatherv(read_buf, (int) flat_dims[0], C_DATATYPE_MPI, global_buf, recvcounts, displs, C_DATATYPE_MPI, comm)), "MPI_Allgatherv succeeded"); - VRFY((0 == memcmp(global_buf, correct_buf, correct_buf_size)), + VRFY((0 == HDmemcmp(global_buf, correct_buf, correct_buf_size)), "Data verification succeeded"); if (displs) HDfree(displs); @@ -3319,6 +3374,10 @@ test_read_filtered_dataset_all_no_selection(void) hid_t file_id = -1, dset_id = -1, plist_id = -1; hid_t filespace = -1, memspace = -1; + if (MAINPROCESS) HDputs("Testing read from filtered chunks with all processes having no selection"); + + CHECK_CUR_FILTER_AVAIL(); + dataset_dims[0] = (hsize_t) READ_ALL_NO_SELECTION_FILTERED_CHUNKS_NROWS; dataset_dims[1] = (hsize_t) READ_ALL_NO_SELECTION_FILTERED_CHUNKS_NCOLS; @@ -3329,8 +3388,6 @@ test_read_filtered_dataset_all_no_selection(void) VRFY((NULL != correct_buf), "HDcalloc succeeded"); if (MAINPROCESS) { - puts("Testing read from filtered chunks with all processes having no selection"); - plist_id = H5Pcreate(H5P_FILE_ACCESS); VRFY((plist_id >= 0), "FAPL creation succeeded"); @@ -3460,6 +3517,10 @@ test_read_filtered_dataset_point_selection(void) int *recvcounts = NULL; int *displs = NULL; + if (MAINPROCESS) HDputs("Testing read from filtered chunks with point selection"); + + CHECK_CUR_FILTER_AVAIL(); + dataset_dims[0] = (hsize_t) READ_POINT_SELECTION_FILTERED_CHUNKS_NROWS; dataset_dims[1] = (hsize_t) READ_POINT_SELECTION_FILTERED_CHUNKS_NCOLS; @@ -3477,8 +3538,6 @@ test_read_filtered_dataset_point_selection(void) ); if (MAINPROCESS) { - puts("Testing read from filtered chunks with point selection"); - plist_id = H5Pcreate(H5P_FILE_ACCESS); VRFY((plist_id >= 0), "FAPL creation succeeded"); @@ -3615,7 +3674,7 @@ test_read_filtered_dataset_point_selection(void) } } - VRFY((0 == memcmp(global_buf, correct_buf, correct_buf_size)), + VRFY((0 == HDmemcmp(global_buf, correct_buf, correct_buf_size)), "Data verification succeeded"); if (displs) HDfree(displs); @@ -3669,6 +3728,10 @@ test_read_filtered_dataset_interleaved_read(void) int *recvcounts = NULL; int *displs = NULL; + if (MAINPROCESS) HDputs("Testing interleaved read from filtered chunks"); + + CHECK_CUR_FILTER_AVAIL(); + dataset_dims[0] = (hsize_t) INTERLEAVED_READ_FILTERED_DATASET_NROWS; dataset_dims[1] = (hsize_t) INTERLEAVED_READ_FILTERED_DATASET_NCOLS; @@ -3692,8 +3755,6 @@ test_read_filtered_dataset_interleaved_read(void) ); if (MAINPROCESS) { - puts("Testing interleaved read from filtered chunks"); - plist_id = H5Pcreate(H5P_FILE_ACCESS); VRFY((plist_id >= 0), "FAPL creation succeeded"); @@ -3781,9 +3842,9 @@ test_read_filtered_dataset_interleaved_read(void) start[1] = 0; if (VERBOSE_MED) { - printf("Process %d is reading with count[ %llu, %llu ], stride[ %llu, %llu ], start[ %llu, %llu ], block size[ %llu, %llu ]\n", + HDprintf("Process %d is reading with count[ %llu, %llu ], stride[ %llu, %llu ], start[ %llu, %llu ], block size[ %llu, %llu ]\n", mpi_rank, count[0], count[1], stride[0], stride[1], start[0], start[1], block[0], block[1]); - fflush(stdout); + HDfflush(stdout); } VRFY((H5Sselect_hyperslab(filespace, H5S_SELECT_SET, start, stride, count, block) >= 0), @@ -3838,7 +3899,7 @@ test_read_filtered_dataset_interleaved_read(void) } } - VRFY((0 == memcmp(global_buf, correct_buf, correct_buf_size)), + VRFY((0 == HDmemcmp(global_buf, correct_buf, correct_buf_size)), "Data verification succeeded"); if (displs) HDfree(displs); @@ -3889,6 +3950,10 @@ test_read_3d_filtered_dataset_no_overlap_separate_pages(void) hid_t file_id = -1, dset_id = -1, plist_id = -1; hid_t filespace = -1, memspace = -1; + if (MAINPROCESS) HDputs("Testing read from unshared filtered chunks on separate pages in 3D dataset"); + + CHECK_CUR_FILTER_AVAIL(); + dataset_dims[0] = (hsize_t) READ_UNSHARED_FILTERED_CHUNKS_3D_SEP_PAGE_NROWS; dataset_dims[1] = (hsize_t) READ_UNSHARED_FILTERED_CHUNKS_3D_SEP_PAGE_NCOLS; dataset_dims[2] = (hsize_t) READ_UNSHARED_FILTERED_CHUNKS_3D_SEP_PAGE_DEPTH; @@ -3903,8 +3968,6 @@ test_read_3d_filtered_dataset_no_overlap_separate_pages(void) correct_buf[i] = (C_DATATYPE) ((i % (hsize_t) mpi_size) + (i / (hsize_t) mpi_size)); if (MAINPROCESS) { - puts("Testing read from unshared filtered chunks on separate pages in 3D dataset"); - plist_id = H5Pcreate(H5P_FILE_ACCESS); VRFY((plist_id >= 0), "FAPL creation succeeded"); @@ -3998,9 +4061,9 @@ test_read_3d_filtered_dataset_no_overlap_separate_pages(void) start[2] = (hsize_t) mpi_rank; if (VERBOSE_MED) { - printf("Process %d is reading with count[ %llu, %llu ], stride[ %llu, %llu ], start[ %llu, %llu ], block size[ %llu, %llu ]\n", + HDprintf("Process %d is reading with count[ %llu, %llu ], stride[ %llu, %llu ], start[ %llu, %llu ], block size[ %llu, %llu ]\n", mpi_rank, count[0], count[1], stride[0], stride[1], start[0], start[1], block[0], block[1]); - fflush(stdout); + HDfflush(stdout); } VRFY((H5Sselect_hyperslab(filespace, H5S_SELECT_SET, start, stride, count, block) >= 0), @@ -4043,7 +4106,7 @@ test_read_3d_filtered_dataset_no_overlap_separate_pages(void) VRFY((MPI_SUCCESS == MPI_Allgather(read_buf, (int) flat_dims[0], C_DATATYPE_MPI, global_buf, 1, resized_vector_type, comm)), "MPI_Allgather succeeded"); - VRFY((0 == memcmp(global_buf, correct_buf, correct_buf_size)), + VRFY((0 == HDmemcmp(global_buf, correct_buf, correct_buf_size)), "Data verification succeeded"); VRFY((MPI_SUCCESS == MPI_Type_free(&vector_type)), "MPI_Type_free succeeded"); @@ -4096,6 +4159,10 @@ test_read_3d_filtered_dataset_no_overlap_same_pages(void) int *recvcounts = NULL; int *displs = NULL; + if (MAINPROCESS) HDputs("Testing read from unshared filtered chunks on the same pages in 3D dataset"); + + CHECK_CUR_FILTER_AVAIL(); + dataset_dims[0] = (hsize_t) READ_UNSHARED_FILTERED_CHUNKS_3D_SAME_PAGE_NROWS; dataset_dims[1] = (hsize_t) READ_UNSHARED_FILTERED_CHUNKS_3D_SAME_PAGE_NCOLS; dataset_dims[2] = (hsize_t) READ_UNSHARED_FILTERED_CHUNKS_3D_SAME_PAGE_DEPTH; @@ -4113,8 +4180,6 @@ test_read_3d_filtered_dataset_no_overlap_same_pages(void) ); if (MAINPROCESS) { - puts("Testing read from unshared filtered chunks on the same pages in 3D dataset"); - plist_id = H5Pcreate(H5P_FILE_ACCESS); VRFY((plist_id >= 0), "FAPL creation succeeded"); @@ -4208,9 +4273,9 @@ test_read_3d_filtered_dataset_no_overlap_same_pages(void) start[2] = 0; if (VERBOSE_MED) { - printf("Process %d is reading with count[ %llu, %llu ], stride[ %llu, %llu ], start[ %llu, %llu ], block size[ %llu, %llu ]\n", + HDprintf("Process %d is reading with count[ %llu, %llu ], stride[ %llu, %llu ], start[ %llu, %llu ], block size[ %llu, %llu ]\n", mpi_rank, count[0], count[1], stride[0], stride[1], start[0], start[1], block[0], block[1]); - fflush(stdout); + HDfflush(stdout); } VRFY((H5Sselect_hyperslab(filespace, H5S_SELECT_SET, start, stride, count, block) >= 0), @@ -4250,7 +4315,7 @@ test_read_3d_filtered_dataset_no_overlap_same_pages(void) VRFY((MPI_SUCCESS == MPI_Allgatherv(read_buf, (int) flat_dims[0], C_DATATYPE_MPI, global_buf, recvcounts, displs, C_DATATYPE_MPI, comm)), "MPI_Allgatherv succeeded"); - VRFY((0 == memcmp(global_buf, correct_buf, correct_buf_size)), + VRFY((0 == HDmemcmp(global_buf, correct_buf, correct_buf_size)), "Data verification succeeded"); if (displs) HDfree(displs); @@ -4302,6 +4367,10 @@ test_read_3d_filtered_dataset_overlap(void) hid_t file_id = -1, dset_id = -1, plist_id = -1; hid_t filespace = -1, memspace = -1; + if (MAINPROCESS) HDputs("Testing read from shared filtered chunks in 3D dataset"); + + CHECK_CUR_FILTER_AVAIL(); + dataset_dims[0] = (hsize_t) READ_SHARED_FILTERED_CHUNKS_3D_NROWS; dataset_dims[1] = (hsize_t) READ_SHARED_FILTERED_CHUNKS_3D_NCOLS; dataset_dims[2] = (hsize_t) READ_SHARED_FILTERED_CHUNKS_3D_DEPTH; @@ -4328,8 +4397,6 @@ test_read_3d_filtered_dataset_overlap(void) ); if (MAINPROCESS) { - puts("Testing read from shared filtered chunks in 3D dataset"); - plist_id = H5Pcreate(H5P_FILE_ACCESS); VRFY((plist_id >= 0), "FAPL creation succeeded"); @@ -4423,9 +4490,9 @@ test_read_3d_filtered_dataset_overlap(void) start[2] = 0; if (VERBOSE_MED) { - printf("Process %d is reading with count[ %llu, %llu ], stride[ %llu, %llu ], start[ %llu, %llu ], block size[ %llu, %llu ]\n", + HDprintf("Process %d is reading with count[ %llu, %llu ], stride[ %llu, %llu ], start[ %llu, %llu ], block size[ %llu, %llu ]\n", mpi_rank, count[0], count[1], stride[0], stride[1], start[0], start[1], block[0], block[1]); - fflush(stdout); + HDfflush(stdout); } VRFY((H5Sselect_hyperslab(filespace, H5S_SELECT_SET, start, stride, count, block) >= 0), @@ -4473,7 +4540,7 @@ test_read_3d_filtered_dataset_overlap(void) VRFY((MPI_SUCCESS == MPI_Allgather(read_buf, (int) flat_dims[0], C_DATATYPE_MPI, global_buf, 1, resized_vector_type, comm)), "MPI_Allgatherv succeeded"); - VRFY((0 == memcmp(global_buf, correct_buf, correct_buf_size)), + VRFY((0 == HDmemcmp(global_buf, correct_buf, correct_buf_size)), "Data verification succeeded"); VRFY((MPI_SUCCESS == MPI_Type_free(&vector_type)), "MPI_Type_free succeeded"); @@ -4525,6 +4592,10 @@ test_read_cmpd_filtered_dataset_no_conversion_unshared(void) int *recvcounts = NULL; int *displs = NULL; + if (MAINPROCESS) HDputs("Testing read from unshared filtered chunks in Compound Datatype dataset without Datatype conversion"); + + CHECK_CUR_FILTER_AVAIL(); + dataset_dims[0] = (hsize_t) READ_COMPOUND_FILTERED_CHUNKS_NO_CONVERSION_UNSHARED_NROWS; dataset_dims[1] = (hsize_t) READ_COMPOUND_FILTERED_CHUNKS_NO_CONVERSION_UNSHARED_NCOLS; @@ -4563,8 +4634,6 @@ test_read_cmpd_filtered_dataset_no_conversion_unshared(void) "Datatype insertion succeeded"); if (MAINPROCESS) { - puts("Testing read from unshared filtered chunks in Compound Datatype dataset without Datatype conversion"); - plist_id = H5Pcreate(H5P_FILE_ACCESS); VRFY((plist_id >= 0), "FAPL creation succeeded"); @@ -4652,9 +4721,9 @@ test_read_cmpd_filtered_dataset_no_conversion_unshared(void) start[1] = ((hsize_t) mpi_rank * READ_COMPOUND_FILTERED_CHUNKS_NO_CONVERSION_UNSHARED_CH_NCOLS); if (VERBOSE_MED) { - printf("Process %d is reading with count[ %llu, %llu ], stride[ %llu, %llu ], start[ %llu, %llu ], block size[ %llu, %llu ]\n", + HDprintf("Process %d is reading with count[ %llu, %llu ], stride[ %llu, %llu ], start[ %llu, %llu ], block size[ %llu, %llu ]\n", mpi_rank, count[0], count[1], stride[0], stride[1], start[0], start[1], block[0], block[1]); - fflush(stdout); + HDfflush(stdout); } VRFY((H5Sselect_hyperslab(filespace, H5S_SELECT_SET, start, stride, count, block) >= 0), @@ -4694,7 +4763,7 @@ test_read_cmpd_filtered_dataset_no_conversion_unshared(void) VRFY((MPI_SUCCESS == MPI_Allgatherv(read_buf, (int) (flat_dims[0] * sizeof(COMPOUND_C_DATATYPE)), MPI_BYTE, global_buf, recvcounts, displs, MPI_BYTE, comm)), "MPI_Allgatherv succeeded"); - VRFY((0 == memcmp(global_buf, correct_buf, correct_buf_size)), + VRFY((0 == HDmemcmp(global_buf, correct_buf, correct_buf_size)), "Data verification succeeded"); if (displs) HDfree(displs); @@ -4746,6 +4815,10 @@ test_read_cmpd_filtered_dataset_no_conversion_shared(void) int *recvcounts = NULL; int *displs = NULL; + if (MAINPROCESS) HDputs("Testing read from shared filtered chunks in Compound Datatype dataset without Datatype conversion"); + + CHECK_CUR_FILTER_AVAIL(); + dataset_dims[0] = (hsize_t) READ_COMPOUND_FILTERED_CHUNKS_NO_CONVERSION_SHARED_NROWS; dataset_dims[1] = (hsize_t) READ_COMPOUND_FILTERED_CHUNKS_NO_CONVERSION_SHARED_NCOLS; @@ -4787,8 +4860,6 @@ test_read_cmpd_filtered_dataset_no_conversion_shared(void) "Datatype insertion succeeded"); if (MAINPROCESS) { - puts("Testing read from shared filtered chunks in Compound Datatype dataset without Datatype conversion"); - plist_id = H5Pcreate(H5P_FILE_ACCESS); VRFY((plist_id >= 0), "FAPL creation succeeded"); @@ -4876,9 +4947,9 @@ test_read_cmpd_filtered_dataset_no_conversion_shared(void) start[1] = 0; if (VERBOSE_MED) { - printf("Process %d is reading with count[ %llu, %llu ], stride[ %llu, %llu ], start[ %llu, %llu ], block size[ %llu, %llu ]\n", + HDprintf("Process %d is reading with count[ %llu, %llu ], stride[ %llu, %llu ], start[ %llu, %llu ], block size[ %llu, %llu ]\n", mpi_rank, count[0], count[1], stride[0], stride[1], start[0], start[1], block[0], block[1]); - fflush(stdout); + HDfflush(stdout); } VRFY((H5Sselect_hyperslab(filespace, H5S_SELECT_SET, start, stride, count, block) >= 0), @@ -4918,7 +4989,7 @@ test_read_cmpd_filtered_dataset_no_conversion_shared(void) VRFY((MPI_SUCCESS == MPI_Allgatherv(read_buf, (int) (flat_dims[0] * sizeof(COMPOUND_C_DATATYPE)), MPI_BYTE, global_buf, recvcounts, displs, MPI_BYTE, comm)), "MPI_Allgatherv succeeded"); - VRFY((0 == memcmp(global_buf, correct_buf, correct_buf_size)), + VRFY((0 == HDmemcmp(global_buf, correct_buf, correct_buf_size)), "Data verification succeeded"); if (displs) HDfree(displs); @@ -4970,6 +5041,10 @@ test_read_cmpd_filtered_dataset_type_conversion_unshared(void) int *recvcounts = NULL; int *displs = NULL; + if (MAINPROCESS) HDputs("Testing read from unshared filtered chunks in Compound Datatype dataset with Datatype conversion"); + + CHECK_CUR_FILTER_AVAIL(); + dataset_dims[0] = (hsize_t) READ_COMPOUND_FILTERED_CHUNKS_TYPE_CONVERSION_UNSHARED_NROWS; dataset_dims[1] = (hsize_t) READ_COMPOUND_FILTERED_CHUNKS_TYPE_CONVERSION_UNSHARED_NCOLS; @@ -5019,8 +5094,6 @@ test_read_cmpd_filtered_dataset_type_conversion_unshared(void) "Datatype insertion succeeded"); if (MAINPROCESS) { - puts("Testing read from unshared filtered chunks in Compound Datatype dataset with Datatype conversion"); - plist_id = H5Pcreate(H5P_FILE_ACCESS); VRFY((plist_id >= 0), "FAPL creation succeeded"); @@ -5108,9 +5181,9 @@ test_read_cmpd_filtered_dataset_type_conversion_unshared(void) start[1] = ((hsize_t) mpi_rank * READ_COMPOUND_FILTERED_CHUNKS_TYPE_CONVERSION_UNSHARED_CH_NCOLS); if (VERBOSE_MED) { - printf("Process %d is reading with count[ %llu, %llu ], stride[ %llu, %llu ], start[ %llu, %llu ], block size[ %llu, %llu ]\n", + HDprintf("Process %d is reading with count[ %llu, %llu ], stride[ %llu, %llu ], start[ %llu, %llu ], block size[ %llu, %llu ]\n", mpi_rank, count[0], count[1], stride[0], stride[1], start[0], start[1], block[0], block[1]); - fflush(stdout); + HDfflush(stdout); } VRFY((H5Sselect_hyperslab(filespace, H5S_SELECT_SET, start, stride, count, block) >= 0), @@ -5150,7 +5223,7 @@ test_read_cmpd_filtered_dataset_type_conversion_unshared(void) VRFY((MPI_SUCCESS == MPI_Allgatherv(read_buf, (int) (flat_dims[0] * sizeof(COMPOUND_C_DATATYPE)), MPI_BYTE, global_buf, recvcounts, displs, MPI_BYTE, comm)), "MPI_Allgatherv succeeded"); - VRFY((0 == memcmp(global_buf, correct_buf, correct_buf_size)), + VRFY((0 == HDmemcmp(global_buf, correct_buf, correct_buf_size)), "Data verification succeeded"); if (displs) HDfree(displs); @@ -5203,6 +5276,10 @@ test_read_cmpd_filtered_dataset_type_conversion_shared(void) int *recvcounts = NULL; int *displs = NULL; + if (MAINPROCESS) HDputs("Testing read from shared filtered chunks in Compound Datatype dataset with Datatype conversion"); + + CHECK_CUR_FILTER_AVAIL(); + dataset_dims[0] = (hsize_t) READ_COMPOUND_FILTERED_CHUNKS_TYPE_CONVERSION_SHARED_NROWS; dataset_dims[1] = (hsize_t) READ_COMPOUND_FILTERED_CHUNKS_TYPE_CONVERSION_SHARED_NCOLS; @@ -5255,8 +5332,6 @@ test_read_cmpd_filtered_dataset_type_conversion_shared(void) "Datatype insertion succeeded"); if (MAINPROCESS) { - puts("Testing read from shared filtered chunks in Compound Datatype dataset with Datatype conversion"); - plist_id = H5Pcreate(H5P_FILE_ACCESS); VRFY((plist_id >= 0), "FAPL creation succeeded"); @@ -5344,9 +5419,9 @@ test_read_cmpd_filtered_dataset_type_conversion_shared(void) start[1] = 0; if (VERBOSE_MED) { - printf("Process %d is reading with count[ %llu, %llu ], stride[ %llu, %llu ], start[ %llu, %llu ], block size[ %llu, %llu ]\n", + HDprintf("Process %d is reading with count[ %llu, %llu ], stride[ %llu, %llu ], start[ %llu, %llu ], block size[ %llu, %llu ]\n", mpi_rank, count[0], count[1], stride[0], stride[1], start[0], start[1], block[0], block[1]); - fflush(stdout); + HDfflush(stdout); } VRFY((H5Sselect_hyperslab(filespace, H5S_SELECT_SET, start, stride, count, block) >= 0), @@ -5386,7 +5461,7 @@ test_read_cmpd_filtered_dataset_type_conversion_shared(void) VRFY((MPI_SUCCESS == MPI_Allgatherv(read_buf, (int) (flat_dims[0] * sizeof(COMPOUND_C_DATATYPE)), MPI_BYTE, global_buf, recvcounts, displs, MPI_BYTE, comm)), "MPI_Allgatherv succeeded"); - VRFY((0 == memcmp(global_buf, correct_buf, correct_buf_size)), + VRFY((0 == HDmemcmp(global_buf, correct_buf, correct_buf_size)), "Data verification succeeded"); if (displs) HDfree(displs); @@ -5427,7 +5502,9 @@ test_write_serial_read_parallel(void) hid_t file_id = -1, dset_id = -1, plist_id = -1; hid_t filespace = -1; - if (MAINPROCESS) puts("Testing write file serially; read file in parallel"); + if (MAINPROCESS) HDputs("Testing write file serially; read file in parallel"); + + CHECK_CUR_FILTER_AVAIL(); dataset_dims[0] = (hsize_t) WRITE_SERIAL_READ_PARALLEL_NROWS; dataset_dims[1] = (hsize_t) WRITE_SERIAL_READ_PARALLEL_NCOLS; @@ -5527,7 +5604,7 @@ test_write_serial_read_parallel(void) VRFY((H5Dread(dset_id, HDF5_DATATYPE_NAME, H5S_ALL, H5S_ALL, plist_id, read_buf) >= 0), "Dataset read succeeded"); - VRFY((0 == memcmp(read_buf, correct_buf, correct_buf_size)), + VRFY((0 == HDmemcmp(read_buf, correct_buf, correct_buf_size)), "Data verification succeeded"); if (correct_buf) HDfree(correct_buf); @@ -5568,7 +5645,9 @@ test_write_parallel_read_serial(void) hid_t file_id = -1, dset_id = -1, plist_id = -1; hid_t filespace = -1, memspace = -1; - if (MAINPROCESS) puts("Testing write file in parallel; read serially"); + if (MAINPROCESS) HDputs("Testing write file in parallel; read serially"); + + CHECK_CUR_FILTER_AVAIL(); /* Set up file access property list with parallel I/O access */ plist_id = H5Pcreate(H5P_FILE_ACCESS); @@ -5636,9 +5715,9 @@ test_write_parallel_read_serial(void) offset[2] = 0; if (VERBOSE_MED) { - printf("Process %d is writing with count[ %llu, %llu, %llu ], stride[ %llu, %llu, %llu ], offset[ %llu, %llu, %llu ], block size[ %llu, %llu, %llu ]\n", + HDprintf("Process %d is writing with count[ %llu, %llu, %llu ], stride[ %llu, %llu, %llu ], offset[ %llu, %llu, %llu ], block size[ %llu, %llu, %llu ]\n", mpi_rank, count[0], count[1], count[2], stride[0], stride[1], stride[2], offset[0], offset[1], offset[2], block[0], block[1], block[2]); - fflush(stdout); + HDfflush(stdout); } /* Select hyperslab in the file */ @@ -5707,7 +5786,7 @@ test_write_parallel_read_serial(void) VRFY((H5Dread(dset_id, HDF5_DATATYPE_NAME, H5S_ALL, H5S_ALL, H5P_DEFAULT, read_buf) >= 0), "Dataset read succeeded"); - VRFY((0 == memcmp(read_buf, correct_buf, correct_buf_size)), + VRFY((0 == HDmemcmp(read_buf, correct_buf, correct_buf_size)), "Data verification succeeded"); VRFY((H5Dclose(dset_id) >= 0), "Dataset close succeeded"); @@ -5741,7 +5820,9 @@ test_shrinking_growing_chunks(void) hid_t file_id = -1, dset_id = -1, plist_id = -1; hid_t filespace = -1, memspace = -1; - if (MAINPROCESS) puts("Testing continually shrinking/growing chunks"); + if (MAINPROCESS) HDputs("Testing continually shrinking/growing chunks"); + + CHECK_CUR_FILTER_AVAIL(); /* Set up file access property list with parallel I/O access */ plist_id = H5Pcreate(H5P_FILE_ACCESS); @@ -5803,9 +5884,9 @@ test_shrinking_growing_chunks(void) start[1] = 0; if (VERBOSE_MED) { - printf("Process %d is writing with count[ %llu, %llu ], stride[ %llu, %llu ], start[ %llu, %llu ], block size[ %llu, %llu ]\n", + HDprintf("Process %d is writing with count[ %llu, %llu ], stride[ %llu, %llu ], start[ %llu, %llu ], block size[ %llu, %llu ]\n", mpi_rank, count[0], count[1], stride[0], stride[1], start[0], start[1], block[0], block[1]); - fflush(stdout); + HDfflush(stdout); } /* Select hyperslab in the file */ @@ -5868,8 +5949,8 @@ main(int argc, char** argv) if (mpi_size <= 0) { if (MAINPROCESS) { - printf("The Parallel Filters tests require at least 1 rank.\n"); - printf("Quitting...\n"); + HDprintf("The Parallel Filters tests require at least 1 rank.\n"); + HDprintf("Quitting...\n"); } MPI_Abort(MPI_COMM_WORLD, 1); @@ -5877,16 +5958,16 @@ main(int argc, char** argv) if (H5dont_atexit() < 0) { if (MAINPROCESS) { - printf("Failed to turn off atexit processing. Continue.\n"); + HDprintf("Failed to turn off atexit processing. Continue.\n"); } } H5open(); if (MAINPROCESS) { - printf("==========================\n"); - printf("Parallel Filters tests\n"); - printf("==========================\n\n"); + HDprintf("==========================\n"); + HDprintf("Parallel Filters tests\n"); + HDprintf("==========================\n\n"); } if (VERBOSE_MED) h5_show_hostname(); @@ -5942,9 +6023,9 @@ main(int argc, char** argv) VRFY((H5Fclose(file_id) >= 0), "File close succeeded"); if (MAINPROCESS) { - printf("\n=================================================================\n"); - printf("Re-running Parallel Filters tests with Fletcher32 checksum filter\n"); - printf("=================================================================\n\n"); + HDprintf("\n=================================================================\n"); + HDprintf("Re-running Parallel Filters tests with Fletcher32 checksum filter\n"); + HDprintf("=================================================================\n\n"); } for (i = 0; i < ARRAY_SIZE(tests); i++) { @@ -5959,12 +6040,12 @@ main(int argc, char** argv) if (nerrors) goto exit; - if (MAINPROCESS) puts("All Parallel Filters tests passed\n"); + if (MAINPROCESS) HDputs("All Parallel Filters tests passed\n"); exit: if (nerrors) if (MAINPROCESS) - printf("*** %d TEST ERROR%s OCCURRED ***\n", nerrors, + HDprintf("*** %d TEST ERROR%s OCCURRED ***\n", nerrors, nerrors > 1 ? "S" : ""); ALARM_OFF; diff --git a/tools/test/h5copy/CMakeTests.cmake b/tools/test/h5copy/CMakeTests.cmake index 924ade1..f31068b 100644 --- a/tools/test/h5copy/CMakeTests.cmake +++ b/tools/test/h5copy/CMakeTests.cmake @@ -30,6 +30,7 @@ set (LIST_OTHER_TEST_FILES ${HDF5_TOOLS_TEST_H5COPY_SOURCE_DIR}/testfiles/h5copy_misc1.out + ${HDF5_TOOLS_TEST_H5COPY_SOURCE_DIR}/testfiles/h5copy_misc1.err ${HDF5_TOOLS_TEST_H5COPY_SOURCE_DIR}/testfiles/tudfilter.h5.txt ${HDF5_TOOLS_TEST_H5COPY_SOURCE_DIR}/testfiles/tudfilter.h5_ERR.txt ${HDF5_TOOLS_TEST_H5COPY_SOURCE_DIR}/testfiles/h5copy_plugin_fail_ERR.out.h5.txt @@ -250,6 +251,7 @@ -D "TEST_OUTPUT=./testfiles/${testname}.out.out" -D "TEST_EXPECT=${resultcode}" -D "TEST_REFERENCE=./testfiles/${testname}.out" + -D "TEST_ERRREF=./testfiles/${testname}.err" -D "TEST_MASK=true" -P "${HDF_RESOURCES_EXT_DIR}/runTest.cmake" ) diff --git a/tools/test/h5copy/testfiles/h5copy_misc1.err b/tools/test/h5copy/testfiles/h5copy_misc1.err new file mode 100644 index 0000000..2c2c867 --- /dev/null +++ b/tools/test/h5copy/testfiles/h5copy_misc1.err @@ -0,0 +1 @@ +h5copy error: group </g1> doesn't exist. Use -p to create parent groups. diff --git a/tools/test/h5copy/testfiles/h5copy_misc1.out b/tools/test/h5copy/testfiles/h5copy_misc1.out index 1624f2b..1c7181b 100644 --- a/tools/test/h5copy/testfiles/h5copy_misc1.out +++ b/tools/test/h5copy/testfiles/h5copy_misc1.out @@ -1,3 +1,2 @@ Copying file <./testfiles/h5copytst.h5> and object </simple> to file <./testfiles/h5copy_misc1.out.h5> and object </g1/g2/simple> Error in copy...Exiting -h5copy error: group </g1> doesn't exist. Use -p to create parent groups. diff --git a/tools/test/h5copy/testh5copy.sh.in b/tools/test/h5copy/testh5copy.sh.in index 203bfef..50758b5 100644 --- a/tools/test/h5copy/testh5copy.sh.in +++ b/tools/test/h5copy/testh5copy.sh.in @@ -60,6 +60,7 @@ $SRC_H5COPY_TESTFILES/h5copy_extlinks_trg.h5 # List of expect files that will be copied over to local test dir LIST_OTHER_TEST_FILES=" $SRC_H5COPY_TESTFILES/h5copy_misc1.out +$SRC_H5COPY_TESTFILES/h5copy_misc1.err " H5COPY=../../src/h5copy/h5copy # The tool name @@ -396,6 +397,7 @@ CMP_OUTPUT() TOOLTEST_FAIL() { expectout="$TESTDIR/$1" + expecterr="$TESTDIR/`basename $1 .out`.err" actualout="$TESTDIR/$1.actualout" actualerr="$TESTDIR/$1.actualerr" actualout_sav=${actualout}-sav @@ -426,10 +428,7 @@ TOOLTEST_FAIL() echo " PASSED" # Verifying output text from h5copy if [ "$expectout" != "SKIP" ]; then - # combine stderr to stdout to compare the output at once. - # We may seperate stdout and stderr later. - cat $actualerr >> $actualout - CMP_OUTPUT $expectout $actualout + CMP_OUTPUT $expecterr $actualerr fi else echo "*FAILED*" diff --git a/tools/test/h5diff/CMakeTests.cmake b/tools/test/h5diff/CMakeTests.cmake index e06f069..24646b0 100644 --- a/tools/test/h5diff/CMakeTests.cmake +++ b/tools/test/h5diff/CMakeTests.cmake @@ -168,21 +168,12 @@ ${HDF5_TOOLS_TEST_H5DIFF_SOURCE_DIR}/testfiles/h5diff_452.txt ${HDF5_TOOLS_TEST_H5DIFF_SOURCE_DIR}/testfiles/h5diff_453.txt ${HDF5_TOOLS_TEST_H5DIFF_SOURCE_DIR}/testfiles/h5diff_454.txt - ${HDF5_TOOLS_TEST_H5DIFF_SOURCE_DIR}/testfiles/h5diff_454_ERR.txt - ${HDF5_TOOLS_TEST_H5DIFF_SOURCE_DIR}/testfiles/h5diff_454_ERR.err + ${HDF5_TOOLS_TEST_H5DIFF_SOURCE_DIR}/testfiles/dangling_link.err ${HDF5_TOOLS_TEST_H5DIFF_SOURCE_DIR}/testfiles/h5diff_455.txt - ${HDF5_TOOLS_TEST_H5DIFF_SOURCE_DIR}/testfiles/h5diff_455_ERR.txt - ${HDF5_TOOLS_TEST_H5DIFF_SOURCE_DIR}/testfiles/h5diff_455_ERR.err ${HDF5_TOOLS_TEST_H5DIFF_SOURCE_DIR}/testfiles/h5diff_456.txt ${HDF5_TOOLS_TEST_H5DIFF_SOURCE_DIR}/testfiles/h5diff_457.txt - ${HDF5_TOOLS_TEST_H5DIFF_SOURCE_DIR}/testfiles/h5diff_457_ERR.txt - ${HDF5_TOOLS_TEST_H5DIFF_SOURCE_DIR}/testfiles/h5diff_457_ERR.err ${HDF5_TOOLS_TEST_H5DIFF_SOURCE_DIR}/testfiles/h5diff_458.txt - ${HDF5_TOOLS_TEST_H5DIFF_SOURCE_DIR}/testfiles/h5diff_458_ERR.txt - ${HDF5_TOOLS_TEST_H5DIFF_SOURCE_DIR}/testfiles/h5diff_458_ERR.err ${HDF5_TOOLS_TEST_H5DIFF_SOURCE_DIR}/testfiles/h5diff_459.txt - ${HDF5_TOOLS_TEST_H5DIFF_SOURCE_DIR}/testfiles/h5diff_459_ERR.txt - ${HDF5_TOOLS_TEST_H5DIFF_SOURCE_DIR}/testfiles/h5diff_459_ERR.err ${HDF5_TOOLS_TEST_H5DIFF_SOURCE_DIR}/testfiles/h5diff_465.txt ${HDF5_TOOLS_TEST_H5DIFF_SOURCE_DIR}/testfiles/h5diff_466.txt ${HDF5_TOOLS_TEST_H5DIFF_SOURCE_DIR}/testfiles/h5diff_467.txt @@ -238,7 +229,6 @@ ${HDF5_TOOLS_TEST_H5DIFF_SOURCE_DIR}/testfiles/h5diff_63.txt ${HDF5_TOOLS_TEST_H5DIFF_SOURCE_DIR}/testfiles/h5diff_600.txt ${HDF5_TOOLS_TEST_H5DIFF_SOURCE_DIR}/testfiles/h5diff_601.txt - ${HDF5_TOOLS_TEST_H5DIFF_SOURCE_DIR}/testfiles/h5diff_601_ERR.txt ${HDF5_TOOLS_TEST_H5DIFF_SOURCE_DIR}/testfiles/h5diff_601_ERR.err ${HDF5_TOOLS_TEST_H5DIFF_SOURCE_DIR}/testfiles/h5diff_603.txt ${HDF5_TOOLS_TEST_H5DIFF_SOURCE_DIR}/testfiles/h5diff_604.txt @@ -293,6 +283,7 @@ ${HDF5_TOOLS_TEST_H5DIFF_SOURCE_DIR}/testfiles/h5diff_8625.txt ${HDF5_TOOLS_TEST_H5DIFF_SOURCE_DIR}/testfiles/h5diff_8639.txt ${HDF5_TOOLS_TEST_H5DIFF_SOURCE_DIR}/testfiles/h5diff_ud.txt + ${HDF5_TOOLS_TEST_H5DIFF_SOURCE_DIR}/testfiles/h5diff_udfail.err ${HDF5_TOOLS_TEST_H5DIFF_SOURCE_DIR}/testfiles/h5diff_udfail.txt ${HDF5_TOOLS_TEST_H5DIFF_SOURCE_DIR}/testfiles/h5diff_v1.txt ${HDF5_TOOLS_TEST_H5DIFF_SOURCE_DIR}/testfiles/h5diff_v2.txt @@ -400,47 +391,6 @@ endif () endmacro () - macro (ADD_H5_ERR_TEST resultfile resultcode) - # If using memchecker add tests without using scripts - if (HDF5_ENABLE_USING_MEMCHECKER) - add_test (NAME H5DIFF_ERR-${resultfile} COMMAND $<TARGET_FILE:h5diff> --enable-error-stack ${ARGN}) - set_tests_properties (H5DIFF_ERR-${resultfile} PROPERTIES WORKING_DIRECTORY "${PROJECT_BINARY_DIR}/testfiles") - if (NOT "${resultcode}" STREQUAL "0") - set_tests_properties (H5DIFF_ERR-${resultfile} PROPERTIES WILL_FAIL "true") - endif () - if (NOT "${last_test}" STREQUAL "") - set_tests_properties (H5DIFF_ERR-${resultfile} PROPERTIES DEPENDS ${last_test}) - endif () - else () - # Remove any output file left over from previous test run - add_test ( - NAME H5DIFF_ERR-${resultfile}-clear-objects - COMMAND ${CMAKE_COMMAND} - -E remove - testfiles/${resultfile}_ERR.out - testfiles/${resultfile}_ERR.out.err - ) - if (NOT "${last_test}" STREQUAL "") - set_tests_properties (H5DIFF_ERR-${resultfile}-clear-objects PROPERTIES DEPENDS ${last_test}) - endif () - add_test ( - NAME H5DIFF_ERR-${resultfile} - COMMAND "${CMAKE_COMMAND}" - -D "TEST_PROGRAM=$<TARGET_FILE:h5diff>" - -D "TEST_ARGS:STRING=--enable-error-stack;${ARGN}" - -D "TEST_FOLDER=${PROJECT_BINARY_DIR}/testfiles" - -D "TEST_OUTPUT=${resultfile}_ERR.out" - -D "TEST_EXPECT=${resultcode}" - -D "TEST_REFERENCE=${resultfile}_ERR.txt" - -D "TEST_MASK_ERROR=true" - -D "TEST_APPEND=EXIT CODE:" - -P "${HDF_RESOURCES_EXT_DIR}/runTest.cmake" - ) - set_tests_properties (H5DIFF_ERR-${resultfile} PROPERTIES DEPENDS H5DIFF_ERR-${resultfile}-clear-objects) - endif () - set (last_test "H5DIFF_ERR-${resultfile}") - endmacro () - macro (ADD_PH5_TEST resultfile resultcode) # If using memchecker add tests without using scripts if (HDF5_ENABLE_USING_MEMCHECKER) @@ -529,53 +479,6 @@ endif () endmacro () - macro (ADD_H5_UD_ERR_TEST testname resultcode resultfile) - if (NOT HDF5_ENABLE_USING_MEMCHECKER) - # Remove any output file left over from previous test run - add_test ( - NAME H5DIFF_UD_ERR-${testname}-clearall-objects - COMMAND ${CMAKE_COMMAND} - -E remove - testfiles/${resultfile}_ERR.out - testfiles/${resultfile}_ERR.out.err - ) - if ("${resultcode}" STREQUAL "2") - add_test ( - NAME H5DIFF_UD_ERR-${testname} - COMMAND "${CMAKE_COMMAND}" - -D "TEST_PROGRAM=$<TARGET_FILE:h5diff-shared>" - -D "TEST_ARGS:STRING=--enable-error-stack;${ARGN}" - -D "TEST_FOLDER=${PROJECT_BINARY_DIR}/testfiles" - -D "TEST_OUTPUT=${resultfile}_ERR.out" - -D "TEST_EXPECT=${resultcode}" - -D "TEST_REFERENCE=${resultfile}_ERR.txt" - -D "TEST_MASK_ERROR=true" - -D "TEST_APPEND=EXIT CODE:" - -D "TEST_ENV_VAR=HDF5_PLUGIN_PATH" - -D "TEST_ENV_VALUE=${CMAKE_BINARY_DIR}" - -P "${HDF_RESOURCES_EXT_DIR}/runTest.cmake" - ) - else () - add_test ( - NAME H5DIFF_UD_ERR-${testname} - COMMAND "${CMAKE_COMMAND}" - -D "TEST_PROGRAM=$<TARGET_FILE:h5diff-shared>" - -D "TEST_ARGS:STRING=--enable-error-stack;${ARGN}" - -D "TEST_FOLDER=${PROJECT_BINARY_DIR}/testfiles" - -D "TEST_OUTPUT=${resultfile}_ERR.out" - -D "TEST_EXPECT=${resultcode}" - -D "TEST_REFERENCE=${resultfile}_ERR.txt" - -D "TEST_MASK_ERROR=true" - -D "TEST_APPEND=EXIT CODE:" - -D "TEST_ENV_VAR=HDF5_PLUGIN_PATH" - -D "TEST_ENV_VALUE=${CMAKE_BINARY_DIR}/plugins" - -P "${HDF_RESOURCES_EXT_DIR}/runTest.cmake" - ) - endif () - set_tests_properties (H5DIFF_UD_ERR-${testname} PROPERTIES DEPENDS H5DIFF_UD_ERR-${testname}-clearall-objects) - endif () - endmacro () - ############################################################################## ############################################################################## ### T H E T E S T S ### @@ -798,26 +701,16 @@ h5diff_453.out.err h5diff_454.out h5diff_454.out.err - h5diff_454_ERR.out - h5diff_454_ERR.out.err h5diff_455.out h5diff_455.out.err - h5diff_455_ERR.out - h5diff_455_ERR.out.err h5diff_456.out h5diff_456.out.err h5diff_457.out h5diff_457.out.err - h5diff_457_ERR.out - h5diff_457_ERR.out.err h5diff_458.out h5diff_458.out.err - h5diff_458_ERR.out - h5diff_458_ERR.out.err h5diff_459.out h5diff_459.out.err - h5diff_459_ERR.out - h5diff_459_ERR.out.err h5diff_465.out h5diff_465.out.err h5diff_466.out @@ -922,8 +815,6 @@ h5diff_600.out.err h5diff_601.out h5diff_601.out.err - h5diff_601_ERR.out - h5diff_601_ERR.out.err h5diff_603.out h5diff_603.out.err h5diff_604.out @@ -1181,7 +1072,6 @@ ADD_H5_TEST (h5diff_600 1 ${FILE1}) # 6.1: Check if non-exist object name is specified ADD_H5_TEST (h5diff_601 2 ${FILE1} ${FILE1} nono_obj) -ADD_H5_ERR_TEST (h5diff_601 2 ${FILE1} ${FILE1} nono_obj) # ############################################################################## # # -d @@ -1481,26 +1371,21 @@ ADD_H5_TEST (h5diff_453 2 --follow-symlinks -v --no-dangling-links ${FILE13} $ # dangling link found for soft links (obj to obj) ADD_H5_TEST (h5diff_454 2 --follow-symlinks -v --no-dangling-links ${FILE13} ${FILE13} /softlink_dset2 /softlink_noexist) -ADD_H5_ERR_TEST (h5diff_454 2 --follow-symlinks -v --no-dangling-links ${FILE13} ${FILE13} /softlink_dset2 /softlink_noexist) # dangling link found for soft links (obj to obj) Both dangle links ADD_H5_TEST (h5diff_455 2 --follow-symlinks -v --no-dangling-links ${FILE13} ${FILE13} /softlink_noexist /softlink_noexist) -ADD_H5_ERR_TEST (h5diff_455 2 --follow-symlinks -v --no-dangling-links ${FILE13} ${FILE13} /softlink_noexist /softlink_noexist) # dangling link found for ext links (FILE to FILE) ADD_H5_TEST (h5diff_456 2 --follow-symlinks -v --no-dangling-links ${FILE15} ${FILE15}) # dangling link found for ext links (obj to obj). target file exist ADD_H5_TEST (h5diff_457 2 --follow-symlinks -v --no-dangling-links ${FILE15} ${FILE15} /ext_link_dset1 /ext_link_noexist1) -ADD_H5_ERR_TEST (h5diff_457 2 --follow-symlinks -v --no-dangling-links ${FILE15} ${FILE15} /ext_link_dset1 /ext_link_noexist1) # dangling link found for ext links (obj to obj). target file NOT exist ADD_H5_TEST (h5diff_458 2 --follow-symlinks -v --no-dangling-links ${FILE15} ${FILE15} /ext_link_dset1 /ext_link_noexist2) -ADD_H5_ERR_TEST (h5diff_458 2 --follow-symlinks -v --no-dangling-links ${FILE15} ${FILE15} /ext_link_dset1 /ext_link_noexist2) # dangling link found for ext links (obj to obj). Both dangle links ADD_H5_TEST (h5diff_459 2 --follow-symlinks -v --no-dangling-links ${FILE15} ${FILE15} /ext_link_noexist1 /ext_link_noexist2) -ADD_H5_ERR_TEST (h5diff_459 2 --follow-symlinks -v --no-dangling-links ${FILE15} ${FILE15} /ext_link_noexist1 /ext_link_noexist2) # dangling link --follow-symlinks (obj vs obj) # (HDFFV-7836) diff --git a/tools/test/h5diff/h5diff_plugin.sh.in b/tools/test/h5diff/h5diff_plugin.sh.in index 212f5d6..341cba5 100644 --- a/tools/test/h5diff/h5diff_plugin.sh.in +++ b/tools/test/h5diff/h5diff_plugin.sh.in @@ -62,6 +62,7 @@ LIST_HDF5_TEST_FILES=" $SRC_H5DIFF_TESTFILES/tudfilter.h5 $SRC_H5DIFF_TESTFILES/tudfilter2.h5 $SRC_H5DIFF_TESTFILES/h5diff_ud.txt +$SRC_H5DIFF_TESTFILES/h5diff_udfail.err $SRC_H5DIFF_TESTFILES/h5diff_udfail.txt " @@ -204,7 +205,7 @@ VERIFY() { TOOLTEST() { expect="$TESTDIR/$1" actual="$TESTDIR/`basename $1 .txt`.out" - actual_err="$TESTDIR/`basename $1 .txt`.err" + actual_err="$TESTDIR/`basename $1 .txt`.out.err" actual_sav=${actual}-sav actual_err_sav=${actual_err}-sav shift @@ -287,6 +288,90 @@ TOOLTEST() { rm -f $actual_sorted $expect_sorted fi } +# Same as TOOLSET except only err file checked +TOOLTEST_ERR() { + expect="$TESTDIR/$1" + expect_err="$TESTDIR/`basename $1 .txt`.err" + actual="$TESTDIR/`basename $1 .txt`.out" + actual_err="$TESTDIR/`basename $1 .txt`.out.err" + actual_sav=${actual}-sav + actual_err_sav=${actual_err}-sav + shift + if test -n "$pmode"; then + RUNCMD=$RUNPARALLEL + else + RUNCMD=$RUNSERIAL + fi + + # Run test. + TESTING $H5DIFF $@ + ( + #echo "#############################" + #echo "Expected output for '$H5DIFF $@'" + #echo "#############################" + cd $TESTDIR + eval $ENVCMD $RUNCMD $H5DIFF_BIN "$@" + ) >$actual 2>$actual_err + EXIT_CODE=$? + # save actual and actual_err in case they are needed later. + cp $actual $actual_sav + STDOUT_FILTER $actual + cp $actual_err $actual_err_sav + STDERR_FILTER $actual_err + # don't add exit code check in pmode, as it causes failure. (exit code + # is from mpirun not tool) + # if any problem occurs relate to an exit code, it will be caught in + # serial mode, so the test is fullfilled. + if test $h5haveexitcode = 'yes' -a -z "$pmode"; then + echo "EXIT CODE: $EXIT_CODE" >> $actual + fi + + if [ ! -f $expect ]; then + # Create the expect file if it doesn't yet exist. + echo " CREATED" + cp $actual $expect + echo " Expected result (*.ddl) missing" + nerrors="`expr $nerrors + 1`" + elif $CMP $expect_err $actual_err; then + echo " PASSED" + elif test $h5haveexitcode = 'yes' -a -z "$pmode"; then + echo "*FAILED*" + echo " Expected result ($expect_err) differs from actual result ($actual_err)" + nerrors="`expr $nerrors + 1`" + test yes = "$verbose" && $DIFF $expect_err $actual_err |sed 's/^/ /' + else + # parallel mode output are often of different ordering from serial + # output. If the sorted expect_err and actual_err files compare the same, + # it is safe to assume the actual output match the expected file. + expect_sorted=expect_sorted + actual_sorted=actual_sorted + sort $expect_err -o $expect_sorted + sort $actual_err -o $actual_sorted + mv $expect_sorted.noexit $expect_sorted + if $CMP $expect_sorted $actual_sorted; then + echo " PASSED" + else + echo "*FAILED*" + nerrors="`expr $nerrors + 1`" + if test yes = "$verbose"; then + echo "====Expected result ($expect_sorted) differs from actual result ($actual_sorted)" + $DIFF $expect_sorted $actual_sorted |sed 's/^/ /' + echo "====The actual output ($actual_sav)" + sed 's/^/ /' < $actual_sav + echo "====The actual stderr ($actual_err_sav)" + sed 's/^/ /' < $actual_err_sav + echo "====End of actual stderr ($actual_err_sav)" + echo "" + fi + fi + fi + + # Clean up output file + if test -z "$HDF5_NOCLEANUP"; then + rm -f $actual $actual_err $actual_sav $actual_err_sav + rm -f $actual_sorted $expect_sorted + fi +} ############################################################################## ### T H E T E S T S diff --git a/tools/test/h5diff/testfiles/h5diff_459_ERR.err b/tools/test/h5diff/testfiles/dangling_link.err index 82802a1..82802a1 100644 --- a/tools/test/h5diff/testfiles/h5diff_459_ERR.err +++ b/tools/test/h5diff/testfiles/dangling_link.err diff --git a/tools/test/h5diff/testfiles/h5diff_454_ERR.err b/tools/test/h5diff/testfiles/h5diff_454_ERR.err deleted file mode 100644 index 82802a1..0000000 --- a/tools/test/h5diff/testfiles/h5diff_454_ERR.err +++ /dev/null @@ -1,4 +0,0 @@ -H5tools-DIAG: Error detected in HDF5:tools (version (number)) thread (IDs): - #000: (file name) line (number) in h5diff(): treat dangling link as error - major: Failure in tools library - minor: error in function diff --git a/tools/test/h5diff/testfiles/h5diff_454_ERR.txt b/tools/test/h5diff/testfiles/h5diff_454_ERR.txt deleted file mode 100644 index 4501071..0000000 --- a/tools/test/h5diff/testfiles/h5diff_454_ERR.txt +++ /dev/null @@ -1,6 +0,0 @@ -Warning: </softlink_noexist> is a dangling link. -H5tools-DIAG: Error detected in HDF5:tools (version (number)) thread (IDs): - #000: (file name) line (number) in h5diff(): treat dangling link as error - major: Failure in tools library - minor: error in function -EXIT CODE: 2 diff --git a/tools/test/h5diff/testfiles/h5diff_455_ERR.err b/tools/test/h5diff/testfiles/h5diff_455_ERR.err deleted file mode 100644 index 82802a1..0000000 --- a/tools/test/h5diff/testfiles/h5diff_455_ERR.err +++ /dev/null @@ -1,4 +0,0 @@ -H5tools-DIAG: Error detected in HDF5:tools (version (number)) thread (IDs): - #000: (file name) line (number) in h5diff(): treat dangling link as error - major: Failure in tools library - minor: error in function diff --git a/tools/test/h5diff/testfiles/h5diff_455_ERR.txt b/tools/test/h5diff/testfiles/h5diff_455_ERR.txt deleted file mode 100644 index 4501071..0000000 --- a/tools/test/h5diff/testfiles/h5diff_455_ERR.txt +++ /dev/null @@ -1,6 +0,0 @@ -Warning: </softlink_noexist> is a dangling link. -H5tools-DIAG: Error detected in HDF5:tools (version (number)) thread (IDs): - #000: (file name) line (number) in h5diff(): treat dangling link as error - major: Failure in tools library - minor: error in function -EXIT CODE: 2 diff --git a/tools/test/h5diff/testfiles/h5diff_457_ERR.err b/tools/test/h5diff/testfiles/h5diff_457_ERR.err deleted file mode 100644 index 82802a1..0000000 --- a/tools/test/h5diff/testfiles/h5diff_457_ERR.err +++ /dev/null @@ -1,4 +0,0 @@ -H5tools-DIAG: Error detected in HDF5:tools (version (number)) thread (IDs): - #000: (file name) line (number) in h5diff(): treat dangling link as error - major: Failure in tools library - minor: error in function diff --git a/tools/test/h5diff/testfiles/h5diff_457_ERR.txt b/tools/test/h5diff/testfiles/h5diff_457_ERR.txt deleted file mode 100644 index 9d73750..0000000 --- a/tools/test/h5diff/testfiles/h5diff_457_ERR.txt +++ /dev/null @@ -1,6 +0,0 @@ -Warning: </ext_link_noexist1> is a dangling link. -H5tools-DIAG: Error detected in HDF5:tools (version (number)) thread (IDs): - #000: (file name) line (number) in h5diff(): treat dangling link as error - major: Failure in tools library - minor: error in function -EXIT CODE: 2 diff --git a/tools/test/h5diff/testfiles/h5diff_458_ERR.err b/tools/test/h5diff/testfiles/h5diff_458_ERR.err deleted file mode 100644 index 82802a1..0000000 --- a/tools/test/h5diff/testfiles/h5diff_458_ERR.err +++ /dev/null @@ -1,4 +0,0 @@ -H5tools-DIAG: Error detected in HDF5:tools (version (number)) thread (IDs): - #000: (file name) line (number) in h5diff(): treat dangling link as error - major: Failure in tools library - minor: error in function diff --git a/tools/test/h5diff/testfiles/h5diff_458_ERR.txt b/tools/test/h5diff/testfiles/h5diff_458_ERR.txt deleted file mode 100644 index b084914..0000000 --- a/tools/test/h5diff/testfiles/h5diff_458_ERR.txt +++ /dev/null @@ -1,6 +0,0 @@ -Warning: </ext_link_noexist2> is a dangling link. -H5tools-DIAG: Error detected in HDF5:tools (version (number)) thread (IDs): - #000: (file name) line (number) in h5diff(): treat dangling link as error - major: Failure in tools library - minor: error in function -EXIT CODE: 2 diff --git a/tools/test/h5diff/testfiles/h5diff_459_ERR.txt b/tools/test/h5diff/testfiles/h5diff_459_ERR.txt deleted file mode 100644 index 9d73750..0000000 --- a/tools/test/h5diff/testfiles/h5diff_459_ERR.txt +++ /dev/null @@ -1,6 +0,0 @@ -Warning: </ext_link_noexist1> is a dangling link. -H5tools-DIAG: Error detected in HDF5:tools (version (number)) thread (IDs): - #000: (file name) line (number) in h5diff(): treat dangling link as error - major: Failure in tools library - minor: error in function -EXIT CODE: 2 diff --git a/tools/test/h5diff/testfiles/h5diff_600.txt b/tools/test/h5diff/testfiles/h5diff_600.txt index f3b346a..13d627c 100644 --- a/tools/test/h5diff/testfiles/h5diff_600.txt +++ b/tools/test/h5diff/testfiles/h5diff_600.txt @@ -142,5 +142,4 @@ usage: h5diff [OPTIONS] file1 file2 [obj1[ obj2]] Use h5diff file1 file1 /g1/dset1 /g1/dset2 to compare '/g1/dset1' and '/g1/dset2' in the same file -h5diff error: missing file names EXIT CODE: 1 diff --git a/tools/test/h5diff/testfiles/h5diff_601_ERR.txt b/tools/test/h5diff/testfiles/h5diff_601_ERR.txt deleted file mode 100644 index b58124a..0000000 --- a/tools/test/h5diff/testfiles/h5diff_601_ERR.txt +++ /dev/null @@ -1,6 +0,0 @@ -Object </nono_obj> could not be found in <h5diff_basic1.h5> -H5tools-DIAG: Error detected in HDF5:tools (version (number)) thread (IDs): - #000: (file name) line (number) in h5diff(): Error: Object could not be found - major: Failure in tools library - minor: error in function -EXIT CODE: 2 diff --git a/tools/test/h5diff/testfiles/h5diff_udfail.err b/tools/test/h5diff/testfiles/h5diff_udfail.err new file mode 100644 index 0000000..d51de38 --- /dev/null +++ b/tools/test/h5diff/testfiles/h5diff_udfail.err @@ -0,0 +1,12 @@ + +file1 file2 +--------------------------------------- + x x / + x x /dynlibud + +group : </> and </> +0 differences found +dataset: </dynlibud> and </dynlibud> +0 differences found +Warning: dataset </dynlibud> cannot be read, user defined filter is not available +EXIT CODE: 2 diff --git a/tools/test/h5diff/testfiles/h5diff_udfail.txt b/tools/test/h5diff/testfiles/h5diff_udfail.txt index d51de38..e6000fc 100644 --- a/tools/test/h5diff/testfiles/h5diff_udfail.txt +++ b/tools/test/h5diff/testfiles/h5diff_udfail.txt @@ -8,5 +8,4 @@ group : </> and </> 0 differences found dataset: </dynlibud> and </dynlibud> 0 differences found -Warning: dataset </dynlibud> cannot be read, user defined filter is not available EXIT CODE: 2 diff --git a/tools/test/h5diff/testh5diff.sh.in b/tools/test/h5diff/testh5diff.sh.in index c464f94..557d2ff 100644 --- a/tools/test/h5diff/testh5diff.sh.in +++ b/tools/test/h5diff/testh5diff.sh.in @@ -226,6 +226,7 @@ $SRC_H5DIFF_TESTFILES/h5diff_451.txt $SRC_H5DIFF_TESTFILES/h5diff_452.txt $SRC_H5DIFF_TESTFILES/h5diff_453.txt $SRC_H5DIFF_TESTFILES/h5diff_454.txt +$SRC_H5DIFF_TESTFILES/dangling_link.err $SRC_H5DIFF_TESTFILES/h5diff_455.txt $SRC_H5DIFF_TESTFILES/h5diff_456.txt $SRC_H5DIFF_TESTFILES/h5diff_457.txt @@ -286,6 +287,7 @@ $SRC_H5DIFF_TESTFILES/h5diff_62.txt $SRC_H5DIFF_TESTFILES/h5diff_63.txt $SRC_H5DIFF_TESTFILES/h5diff_600.txt $SRC_H5DIFF_TESTFILES/h5diff_601.txt +$SRC_H5DIFF_TESTFILES/h5diff_601_ERR.err $SRC_H5DIFF_TESTFILES/h5diff_603.txt $SRC_H5DIFF_TESTFILES/h5diff_604.txt $SRC_H5DIFF_TESTFILES/h5diff_605.txt @@ -462,8 +464,9 @@ TESTING() { # TOOLTEST() { expect="$TESTDIR/$1" + expect_err="$TESTDIR/`basename $1 .txt`.err" actual="$TESTDIR/`basename $1 .txt`.out" - actual_err="$TESTDIR/`basename $1 .txt`.err" + actual_err="$TESTDIR/`basename $1 .txt`.out.err" actual_sav=${actual}-sav actual_err_sav=${actual_err}-sav shift @@ -488,7 +491,6 @@ TOOLTEST() { STDOUT_FILTER $actual cp $actual_err $actual_err_sav STDERR_FILTER $actual_err - cat $actual_err >> $actual # don't add exit code check in pmode, as it causes failure. (exit code # is from mpirun not tool) # if any problem occurs relate to an exit code, it will be caught in diff --git a/tools/test/h5dump/errfiles/filter_fail.err b/tools/test/h5dump/errfiles/filter_fail.err index 6c936b7..07b0aa0 100644 --- a/tools/test/h5dump/errfiles/filter_fail.err +++ b/tools/test/h5dump/errfiles/filter_fail.err @@ -2,25 +2,28 @@ HDF5-DIAG: Error detected in HDF5 (version (number)) thread (IDs): #000: (file name) line (number) in H5Dread(): can't read data major: Dataset minor: Read failed - #001: (file name) line (number) in H5VL_dataset_read(): read failed + #001: (file name) line (number) in H5VL_dataset_read(): dataset read failed major: Virtual Object Layer minor: Read failed - #002: (file name) line (number) in H5VL_native_dataset_read(): can't read data + #002: (file name) line (number) in H5VL__dataset_read(): dataset read failed + major: Virtual Object Layer + minor: Read failed + #003: (file name) line (number) in H5VL__native_dataset_read(): can't read data major: Dataset minor: Read failed - #003: (file name) line (number) in H5D__read(): can't read data + #004: (file name) line (number) in H5D__read(): can't read data major: Dataset minor: Read failed - #004: (file name) line (number) in H5D__chunk_read(): unable to read raw data chunk + #005: (file name) line (number) in H5D__chunk_read(): unable to read raw data chunk major: Low-level I/O minor: Read failed - #005: (file name) line (number) in H5D__chunk_lock(): data pipeline read failed + #006: (file name) line (number) in H5D__chunk_lock(): data pipeline read failed major: Dataset minor: Filter operation failed - #006: (file name) line (number) in H5Z_pipeline(): required filter 'filter_fail_test' is not registered + #007: (file name) line (number) in H5Z_pipeline(): required filter 'filter_fail_test' is not registered major: Data filters minor: Read failed - #007: (file name) line (number) in H5PL_load(): filter plugins disabled + #008: (file name) line (number) in H5PL_load(): filter plugins disabled major: Plugin for dynamically loaded library minor: Unable to load metadata into cache h5dump error: unable to print data diff --git a/tools/test/h5dump/errfiles/tall-1.err b/tools/test/h5dump/errfiles/tall-1.err index 64d5aca..2d2b289 100644 --- a/tools/test/h5dump/errfiles/tall-1.err +++ b/tools/test/h5dump/errfiles/tall-1.err @@ -2,33 +2,36 @@ HDF5-DIAG: Error detected in HDF5 (version (number)) thread (IDs): #000: (file name) line (number) in H5Oopen(): unable to open object major: Object header minor: Can't open object - #001: (file name) line (number) in H5VL_object_open(): open failed + #001: (file name) line (number) in H5VL_object_open(): object open failed major: Virtual Object Layer minor: Can't open object - #002: (file name) line (number) in H5VL_native_object_open(): unable to open object by name + #002: (file name) line (number) in H5VL__object_open(): object open failed + major: Virtual Object Layer + minor: Can't open object + #003: (file name) line (number) in H5VL__native_object_open(): unable to open object by name major: Object header minor: Can't open object - #003: (file name) line (number) in H5O_open_name(): object not found + #004: (file name) line (number) in H5O_open_name(): object not found major: Object header minor: Object not found - #004: (file name) line (number) in H5G_loc_find(): can't find object + #005: (file name) line (number) in H5G_loc_find(): can't find object major: Symbol table minor: Object not found - #005: (file name) line (number) in H5G_traverse(): internal path traversal failed + #006: (file name) line (number) in H5G_traverse(): internal path traversal failed major: Symbol table minor: Object not found - #006: (file name) line (number) in H5G__traverse_real(): special link traversal failed + #007: (file name) line (number) in H5G__traverse_real(): special link traversal failed major: Links minor: Link traversal failure - #007: (file name) line (number) in H5G__traverse_special(): user-defined link traversal failed + #008: (file name) line (number) in H5G__traverse_special(): user-defined link traversal failed major: Links minor: Link traversal failure - #008: (file name) line (number) in H5G__traverse_ud(): traversal callback returned invalid ID + #009: (file name) line (number) in H5G__traverse_ud(): traversal callback returned invalid ID major: Symbol table minor: Unable to find atom information (already closed?) - #009: (file name) line (number) in H5L__extern_traverse(): unable to open external file, external link file name = 'somefile' + #010: (file name) line (number) in H5L__extern_traverse(): unable to open external file, external link file name = 'somefile' major: Links minor: Unable to open file - #010: (file name) line (number) in H5F_prefix_open_file(): unable to open file, file name = 'somefile', temp_file_name = 'somefile' + #011: (file name) line (number) in H5F_prefix_open_file(): unable to open file, file name = 'somefile', temp_file_name = 'somefile' major: File accessibility minor: Unable to open file diff --git a/tools/test/h5dump/errfiles/tall-2A.err b/tools/test/h5dump/errfiles/tall-2A.err index 64d5aca..2d2b289 100644 --- a/tools/test/h5dump/errfiles/tall-2A.err +++ b/tools/test/h5dump/errfiles/tall-2A.err @@ -2,33 +2,36 @@ HDF5-DIAG: Error detected in HDF5 (version (number)) thread (IDs): #000: (file name) line (number) in H5Oopen(): unable to open object major: Object header minor: Can't open object - #001: (file name) line (number) in H5VL_object_open(): open failed + #001: (file name) line (number) in H5VL_object_open(): object open failed major: Virtual Object Layer minor: Can't open object - #002: (file name) line (number) in H5VL_native_object_open(): unable to open object by name + #002: (file name) line (number) in H5VL__object_open(): object open failed + major: Virtual Object Layer + minor: Can't open object + #003: (file name) line (number) in H5VL__native_object_open(): unable to open object by name major: Object header minor: Can't open object - #003: (file name) line (number) in H5O_open_name(): object not found + #004: (file name) line (number) in H5O_open_name(): object not found major: Object header minor: Object not found - #004: (file name) line (number) in H5G_loc_find(): can't find object + #005: (file name) line (number) in H5G_loc_find(): can't find object major: Symbol table minor: Object not found - #005: (file name) line (number) in H5G_traverse(): internal path traversal failed + #006: (file name) line (number) in H5G_traverse(): internal path traversal failed major: Symbol table minor: Object not found - #006: (file name) line (number) in H5G__traverse_real(): special link traversal failed + #007: (file name) line (number) in H5G__traverse_real(): special link traversal failed major: Links minor: Link traversal failure - #007: (file name) line (number) in H5G__traverse_special(): user-defined link traversal failed + #008: (file name) line (number) in H5G__traverse_special(): user-defined link traversal failed major: Links minor: Link traversal failure - #008: (file name) line (number) in H5G__traverse_ud(): traversal callback returned invalid ID + #009: (file name) line (number) in H5G__traverse_ud(): traversal callback returned invalid ID major: Symbol table minor: Unable to find atom information (already closed?) - #009: (file name) line (number) in H5L__extern_traverse(): unable to open external file, external link file name = 'somefile' + #010: (file name) line (number) in H5L__extern_traverse(): unable to open external file, external link file name = 'somefile' major: Links minor: Unable to open file - #010: (file name) line (number) in H5F_prefix_open_file(): unable to open file, file name = 'somefile', temp_file_name = 'somefile' + #011: (file name) line (number) in H5F_prefix_open_file(): unable to open file, file name = 'somefile', temp_file_name = 'somefile' major: File accessibility minor: Unable to open file diff --git a/tools/test/h5dump/errfiles/tall-2A0.err b/tools/test/h5dump/errfiles/tall-2A0.err index 64d5aca..2d2b289 100644 --- a/tools/test/h5dump/errfiles/tall-2A0.err +++ b/tools/test/h5dump/errfiles/tall-2A0.err @@ -2,33 +2,36 @@ HDF5-DIAG: Error detected in HDF5 (version (number)) thread (IDs): #000: (file name) line (number) in H5Oopen(): unable to open object major: Object header minor: Can't open object - #001: (file name) line (number) in H5VL_object_open(): open failed + #001: (file name) line (number) in H5VL_object_open(): object open failed major: Virtual Object Layer minor: Can't open object - #002: (file name) line (number) in H5VL_native_object_open(): unable to open object by name + #002: (file name) line (number) in H5VL__object_open(): object open failed + major: Virtual Object Layer + minor: Can't open object + #003: (file name) line (number) in H5VL__native_object_open(): unable to open object by name major: Object header minor: Can't open object - #003: (file name) line (number) in H5O_open_name(): object not found + #004: (file name) line (number) in H5O_open_name(): object not found major: Object header minor: Object not found - #004: (file name) line (number) in H5G_loc_find(): can't find object + #005: (file name) line (number) in H5G_loc_find(): can't find object major: Symbol table minor: Object not found - #005: (file name) line (number) in H5G_traverse(): internal path traversal failed + #006: (file name) line (number) in H5G_traverse(): internal path traversal failed major: Symbol table minor: Object not found - #006: (file name) line (number) in H5G__traverse_real(): special link traversal failed + #007: (file name) line (number) in H5G__traverse_real(): special link traversal failed major: Links minor: Link traversal failure - #007: (file name) line (number) in H5G__traverse_special(): user-defined link traversal failed + #008: (file name) line (number) in H5G__traverse_special(): user-defined link traversal failed major: Links minor: Link traversal failure - #008: (file name) line (number) in H5G__traverse_ud(): traversal callback returned invalid ID + #009: (file name) line (number) in H5G__traverse_ud(): traversal callback returned invalid ID major: Symbol table minor: Unable to find atom information (already closed?) - #009: (file name) line (number) in H5L__extern_traverse(): unable to open external file, external link file name = 'somefile' + #010: (file name) line (number) in H5L__extern_traverse(): unable to open external file, external link file name = 'somefile' major: Links minor: Unable to open file - #010: (file name) line (number) in H5F_prefix_open_file(): unable to open file, file name = 'somefile', temp_file_name = 'somefile' + #011: (file name) line (number) in H5F_prefix_open_file(): unable to open file, file name = 'somefile', temp_file_name = 'somefile' major: File accessibility minor: Unable to open file diff --git a/tools/test/h5dump/errfiles/tall-2B.err b/tools/test/h5dump/errfiles/tall-2B.err index 64d5aca..2d2b289 100644 --- a/tools/test/h5dump/errfiles/tall-2B.err +++ b/tools/test/h5dump/errfiles/tall-2B.err @@ -2,33 +2,36 @@ HDF5-DIAG: Error detected in HDF5 (version (number)) thread (IDs): #000: (file name) line (number) in H5Oopen(): unable to open object major: Object header minor: Can't open object - #001: (file name) line (number) in H5VL_object_open(): open failed + #001: (file name) line (number) in H5VL_object_open(): object open failed major: Virtual Object Layer minor: Can't open object - #002: (file name) line (number) in H5VL_native_object_open(): unable to open object by name + #002: (file name) line (number) in H5VL__object_open(): object open failed + major: Virtual Object Layer + minor: Can't open object + #003: (file name) line (number) in H5VL__native_object_open(): unable to open object by name major: Object header minor: Can't open object - #003: (file name) line (number) in H5O_open_name(): object not found + #004: (file name) line (number) in H5O_open_name(): object not found major: Object header minor: Object not found - #004: (file name) line (number) in H5G_loc_find(): can't find object + #005: (file name) line (number) in H5G_loc_find(): can't find object major: Symbol table minor: Object not found - #005: (file name) line (number) in H5G_traverse(): internal path traversal failed + #006: (file name) line (number) in H5G_traverse(): internal path traversal failed major: Symbol table minor: Object not found - #006: (file name) line (number) in H5G__traverse_real(): special link traversal failed + #007: (file name) line (number) in H5G__traverse_real(): special link traversal failed major: Links minor: Link traversal failure - #007: (file name) line (number) in H5G__traverse_special(): user-defined link traversal failed + #008: (file name) line (number) in H5G__traverse_special(): user-defined link traversal failed major: Links minor: Link traversal failure - #008: (file name) line (number) in H5G__traverse_ud(): traversal callback returned invalid ID + #009: (file name) line (number) in H5G__traverse_ud(): traversal callback returned invalid ID major: Symbol table minor: Unable to find atom information (already closed?) - #009: (file name) line (number) in H5L__extern_traverse(): unable to open external file, external link file name = 'somefile' + #010: (file name) line (number) in H5L__extern_traverse(): unable to open external file, external link file name = 'somefile' major: Links minor: Unable to open file - #010: (file name) line (number) in H5F_prefix_open_file(): unable to open file, file name = 'somefile', temp_file_name = 'somefile' + #011: (file name) line (number) in H5F_prefix_open_file(): unable to open file, file name = 'somefile', temp_file_name = 'somefile' major: File accessibility minor: Unable to open file diff --git a/tools/test/h5dump/errfiles/tarray1_big.err b/tools/test/h5dump/errfiles/tarray1_big.err index b2cc6b7..ff22495 100644 --- a/tools/test/h5dump/errfiles/tarray1_big.err +++ b/tools/test/h5dump/errfiles/tarray1_big.err @@ -2,39 +2,48 @@ HDF5-DIAG: Error detected in HDF5 (version (number)) thread (IDs): #000: (file name) line (number) in H5Rdereference2(): unable to dereference object major: References minor: Can't open object - #001: (file name) line (number) in H5VL_object_open(): open failed + #001: (file name) line (number) in H5VL_object_open(): object open failed major: Virtual Object Layer minor: Can't open object - #002: (file name) line (number) in H5VL_native_object_open(): unable to dereference object + #002: (file name) line (number) in H5VL__object_open(): object open failed + major: Virtual Object Layer + minor: Can't open object + #003: (file name) line (number) in H5VL__native_object_open(): unable to dereference object major: References minor: Can't open object - #003: (file name) line (number) in H5R__dereference(): Undefined reference pointer + #004: (file name) line (number) in H5R__dereference(): Undefined reference pointer major: Invalid arguments to routine minor: Bad value HDF5-DIAG: Error detected in HDF5 (version (number)) thread (IDs): #000: (file name) line (number) in H5Rdereference2(): unable to dereference object major: References minor: Can't open object - #001: (file name) line (number) in H5VL_object_open(): open failed + #001: (file name) line (number) in H5VL_object_open(): object open failed + major: Virtual Object Layer + minor: Can't open object + #002: (file name) line (number) in H5VL__object_open(): object open failed major: Virtual Object Layer minor: Can't open object - #002: (file name) line (number) in H5VL_native_object_open(): unable to dereference object + #003: (file name) line (number) in H5VL__native_object_open(): unable to dereference object major: References minor: Can't open object - #003: (file name) line (number) in H5R__dereference(): Undefined reference pointer + #004: (file name) line (number) in H5R__dereference(): Undefined reference pointer major: Invalid arguments to routine minor: Bad value HDF5-DIAG: Error detected in HDF5 (version (number)) thread (IDs): #000: (file name) line (number) in H5Rdereference2(): unable to dereference object major: References minor: Can't open object - #001: (file name) line (number) in H5VL_object_open(): open failed + #001: (file name) line (number) in H5VL_object_open(): object open failed + major: Virtual Object Layer + minor: Can't open object + #002: (file name) line (number) in H5VL__object_open(): object open failed major: Virtual Object Layer minor: Can't open object - #002: (file name) line (number) in H5VL_native_object_open(): unable to dereference object + #003: (file name) line (number) in H5VL__native_object_open(): unable to dereference object major: References minor: Can't open object - #003: (file name) line (number) in H5R__dereference(): Undefined reference pointer + #004: (file name) line (number) in H5R__dereference(): Undefined reference pointer major: Invalid arguments to routine minor: Bad value H5tools-DIAG: Error detected in HDF5:tools (version (number)) thread (IDs): diff --git a/tools/test/h5dump/errfiles/tattr-3.err b/tools/test/h5dump/errfiles/tattr-3.err index 3190c3d..8481acf 100644 --- a/tools/test/h5dump/errfiles/tattr-3.err +++ b/tools/test/h5dump/errfiles/tattr-3.err @@ -5,13 +5,16 @@ HDF5-DIAG: Error detected in HDF5 (version (number)) thread (IDs): #001: (file name) line (number) in H5VL_attr_open(): attribute open failed major: Virtual Object Layer minor: Can't open object - #002: (file name) line (number) in H5VL_native_attr_open(): unable to open attribute: 'attr' + #002: (file name) line (number) in H5VL__attr_open(): attribute open failed + major: Virtual Object Layer + minor: Can't open object + #003: (file name) line (number) in H5VL__native_attr_open(): unable to open attribute: 'attr' major: Attribute minor: Can't open object - #003: (file name) line (number) in H5A__open(): unable to load attribute info from object header for attribute: 'attr' + #004: (file name) line (number) in H5A__open(): unable to load attribute info from object header for attribute: 'attr' major: Attribute minor: Can't open object - #004: (file name) line (number) in H5O__attr_open_by_name(): can't locate attribute: 'attr' + #005: (file name) line (number) in H5O__attr_open_by_name(): can't locate attribute: 'attr' major: Attribute minor: Object not found h5dump error: unable to open attribute "attr" diff --git a/tools/test/h5dump/errfiles/tattrregR.err b/tools/test/h5dump/errfiles/tattrregR.err index d89b053..8a1539c 100644 --- a/tools/test/h5dump/errfiles/tattrregR.err +++ b/tools/test/h5dump/errfiles/tattrregR.err @@ -2,26 +2,32 @@ HDF5-DIAG: Error detected in HDF5 (version (number)) thread (IDs): #000: (file name) line (number) in H5Rdereference2(): unable to dereference object major: References minor: Can't open object - #001: (file name) line (number) in H5VL_object_open(): open failed + #001: (file name) line (number) in H5VL_object_open(): object open failed major: Virtual Object Layer minor: Can't open object - #002: (file name) line (number) in H5VL_native_object_open(): unable to dereference object + #002: (file name) line (number) in H5VL__object_open(): object open failed + major: Virtual Object Layer + minor: Can't open object + #003: (file name) line (number) in H5VL__native_object_open(): unable to dereference object major: References minor: Can't open object - #003: (file name) line (number) in H5R__dereference(): Undefined reference pointer + #004: (file name) line (number) in H5R__dereference(): Undefined reference pointer major: Invalid arguments to routine minor: Bad value HDF5-DIAG: Error detected in HDF5 (version (number)) thread (IDs): #000: (file name) line (number) in H5Rdereference2(): unable to dereference object major: References minor: Can't open object - #001: (file name) line (number) in H5VL_object_open(): open failed + #001: (file name) line (number) in H5VL_object_open(): object open failed + major: Virtual Object Layer + minor: Can't open object + #002: (file name) line (number) in H5VL__object_open(): object open failed major: Virtual Object Layer minor: Can't open object - #002: (file name) line (number) in H5VL_native_object_open(): unable to dereference object + #003: (file name) line (number) in H5VL__native_object_open(): unable to dereference object major: References minor: Can't open object - #003: (file name) line (number) in H5R__dereference(): Undefined reference pointer + #004: (file name) line (number) in H5R__dereference(): Undefined reference pointer major: Invalid arguments to routine minor: Bad value H5tools-DIAG: Error detected in HDF5:tools (version (number)) thread (IDs): diff --git a/tools/test/h5dump/errfiles/tcomp-3.err b/tools/test/h5dump/errfiles/tcomp-3.err index 3462761..fc59b0b 100644 --- a/tools/test/h5dump/errfiles/tcomp-3.err +++ b/tools/test/h5dump/errfiles/tcomp-3.err @@ -2,24 +2,27 @@ HDF5-DIAG: Error detected in HDF5 (version (number)) thread (IDs): #000: (file name) line (number) in H5Topen2(): unable to open named datatype major: Datatype minor: Can't open object - #001: (file name) line (number) in H5VL_datatype_open(): open failed + #001: (file name) line (number) in H5VL_datatype_open(): datatype open failed major: Virtual Object Layer minor: Can't open object - #002: (file name) line (number) in H5VL_native_datatype_open(): unable to open named datatype + #002: (file name) line (number) in H5VL__datatype_open(): datatype open failed + major: Virtual Object Layer + minor: Can't open object + #003: (file name) line (number) in H5VL__native_datatype_open(): unable to open named datatype major: Datatype minor: Can't open object - #003: (file name) line (number) in H5T__open_name(): not found + #004: (file name) line (number) in H5T__open_name(): not found major: Datatype minor: Object not found - #004: (file name) line (number) in H5G_loc_find(): can't find object + #005: (file name) line (number) in H5G_loc_find(): can't find object major: Symbol table minor: Object not found - #005: (file name) line (number) in H5G_traverse(): internal path traversal failed + #006: (file name) line (number) in H5G_traverse(): internal path traversal failed major: Symbol table minor: Object not found - #006: (file name) line (number) in H5G__traverse_real(): traversal operator failed + #007: (file name) line (number) in H5G__traverse_real(): traversal operator failed major: Symbol table minor: Callback failed - #007: (file name) line (number) in H5G__loc_find_cb(): object '#6632' doesn't exist + #008: (file name) line (number) in H5G__loc_find_cb(): object '#6632' doesn't exist major: Symbol table minor: Object not found diff --git a/tools/test/h5dump/errfiles/tdataregR.err b/tools/test/h5dump/errfiles/tdataregR.err index d89b053..8a1539c 100644 --- a/tools/test/h5dump/errfiles/tdataregR.err +++ b/tools/test/h5dump/errfiles/tdataregR.err @@ -2,26 +2,32 @@ HDF5-DIAG: Error detected in HDF5 (version (number)) thread (IDs): #000: (file name) line (number) in H5Rdereference2(): unable to dereference object major: References minor: Can't open object - #001: (file name) line (number) in H5VL_object_open(): open failed + #001: (file name) line (number) in H5VL_object_open(): object open failed major: Virtual Object Layer minor: Can't open object - #002: (file name) line (number) in H5VL_native_object_open(): unable to dereference object + #002: (file name) line (number) in H5VL__object_open(): object open failed + major: Virtual Object Layer + minor: Can't open object + #003: (file name) line (number) in H5VL__native_object_open(): unable to dereference object major: References minor: Can't open object - #003: (file name) line (number) in H5R__dereference(): Undefined reference pointer + #004: (file name) line (number) in H5R__dereference(): Undefined reference pointer major: Invalid arguments to routine minor: Bad value HDF5-DIAG: Error detected in HDF5 (version (number)) thread (IDs): #000: (file name) line (number) in H5Rdereference2(): unable to dereference object major: References minor: Can't open object - #001: (file name) line (number) in H5VL_object_open(): open failed + #001: (file name) line (number) in H5VL_object_open(): object open failed + major: Virtual Object Layer + minor: Can't open object + #002: (file name) line (number) in H5VL__object_open(): object open failed major: Virtual Object Layer minor: Can't open object - #002: (file name) line (number) in H5VL_native_object_open(): unable to dereference object + #003: (file name) line (number) in H5VL__native_object_open(): unable to dereference object major: References minor: Can't open object - #003: (file name) line (number) in H5R__dereference(): Undefined reference pointer + #004: (file name) line (number) in H5R__dereference(): Undefined reference pointer major: Invalid arguments to routine minor: Bad value H5tools-DIAG: Error detected in HDF5:tools (version (number)) thread (IDs): diff --git a/tools/test/h5dump/errfiles/tdset-2.err b/tools/test/h5dump/errfiles/tdset-2.err index b2a60cd..2d70b35 100644 --- a/tools/test/h5dump/errfiles/tdset-2.err +++ b/tools/test/h5dump/errfiles/tdset-2.err @@ -5,44 +5,50 @@ HDF5-DIAG: Error detected in HDF5 (version (number)) thread (IDs): #001: (file name) line (number) in H5VL_dataset_open(): dataset open failed major: Virtual Object Layer minor: Can't open object - #002: (file name) line (number) in H5VL_native_dataset_open(): unable to open dataset + #002: (file name) line (number) in H5VL__dataset_open(): dataset open failed + major: Virtual Object Layer + minor: Can't open object + #003: (file name) line (number) in H5VL__native_dataset_open(): unable to open dataset major: Dataset minor: Can't open object - #003: (file name) line (number) in H5D__open_name(): not found + #004: (file name) line (number) in H5D__open_name(): not found major: Dataset minor: Object not found - #004: (file name) line (number) in H5G_loc_find(): can't find object + #005: (file name) line (number) in H5G_loc_find(): can't find object major: Symbol table minor: Object not found - #005: (file name) line (number) in H5G_traverse(): internal path traversal failed + #006: (file name) line (number) in H5G_traverse(): internal path traversal failed major: Symbol table minor: Object not found - #006: (file name) line (number) in H5G__traverse_real(): traversal operator failed + #007: (file name) line (number) in H5G__traverse_real(): traversal operator failed major: Symbol table minor: Callback failed - #007: (file name) line (number) in H5G__loc_find_cb(): object 'dset3' doesn't exist + #008: (file name) line (number) in H5G__loc_find_cb(): object 'dset3' doesn't exist major: Symbol table minor: Object not found HDF5-DIAG: Error detected in HDF5 (version (number)) thread (IDs): #000: (file name) line (number) in H5Lget_info(): unable to get link info major: Links minor: Can't get value - #001: (file name) line (number) in H5VL_link_get(): get failed + #001: (file name) line (number) in H5VL_link_get(): link get failed major: Virtual Object Layer minor: Can't get value - #002: (file name) line (number) in H5VL_native_link_get(): unable to get link info + #002: (file name) line (number) in H5VL__link_get(): link get failed + major: Virtual Object Layer + minor: Can't get value + #003: (file name) line (number) in H5VL__native_link_get(): unable to get link info major: Links minor: Object not found - #003: (file name) line (number) in H5L_get_info(): name doesn't exist + #004: (file name) line (number) in H5L_get_info(): name doesn't exist major: Links minor: Object already exists - #004: (file name) line (number) in H5G_traverse(): internal path traversal failed + #005: (file name) line (number) in H5G_traverse(): internal path traversal failed major: Symbol table minor: Object not found - #005: (file name) line (number) in H5G__traverse_real(): traversal operator failed + #006: (file name) line (number) in H5G__traverse_real(): traversal operator failed major: Symbol table minor: Callback failed - #006: (file name) line (number) in H5L__get_info_cb(): name doesn't exist + #007: (file name) line (number) in H5L__get_info_cb(): name doesn't exist major: Links minor: Object not found h5dump error: unable to get link info from "dset3" diff --git a/tools/test/h5dump/errfiles/textlink.err b/tools/test/h5dump/errfiles/textlink.err index f516638..aaf3144 100644 --- a/tools/test/h5dump/errfiles/textlink.err +++ b/tools/test/h5dump/errfiles/textlink.err @@ -2,67 +2,73 @@ HDF5-DIAG: Error detected in HDF5 (version (number)) thread (IDs): #000: (file name) line (number) in H5Oopen(): unable to open object major: Object header minor: Can't open object - #001: (file name) line (number) in H5VL_object_open(): open failed + #001: (file name) line (number) in H5VL_object_open(): object open failed major: Virtual Object Layer minor: Can't open object - #002: (file name) line (number) in H5VL_native_object_open(): unable to open object by name + #002: (file name) line (number) in H5VL__object_open(): object open failed + major: Virtual Object Layer + minor: Can't open object + #003: (file name) line (number) in H5VL__native_object_open(): unable to open object by name major: Object header minor: Can't open object - #003: (file name) line (number) in H5O_open_name(): object not found + #004: (file name) line (number) in H5O_open_name(): object not found major: Object header minor: Object not found - #004: (file name) line (number) in H5G_loc_find(): can't find object + #005: (file name) line (number) in H5G_loc_find(): can't find object major: Symbol table minor: Object not found - #005: (file name) line (number) in H5G_traverse(): internal path traversal failed + #006: (file name) line (number) in H5G_traverse(): internal path traversal failed major: Symbol table minor: Object not found - #006: (file name) line (number) in H5G__traverse_real(): special link traversal failed + #007: (file name) line (number) in H5G__traverse_real(): special link traversal failed major: Links minor: Link traversal failure - #007: (file name) line (number) in H5G__traverse_special(): user-defined link traversal failed + #008: (file name) line (number) in H5G__traverse_special(): user-defined link traversal failed major: Links minor: Link traversal failure - #008: (file name) line (number) in H5G__traverse_ud(): traversal callback returned invalid ID + #009: (file name) line (number) in H5G__traverse_ud(): traversal callback returned invalid ID major: Symbol table minor: Unable to find atom information (already closed?) - #009: (file name) line (number) in H5L__extern_traverse(): unable to open external file, external link file name = 'filename' + #010: (file name) line (number) in H5L__extern_traverse(): unable to open external file, external link file name = 'filename' major: Links minor: Unable to open file - #010: (file name) line (number) in H5F_prefix_open_file(): unable to open file, file name = 'filename', temp_file_name = 'filename' + #011: (file name) line (number) in H5F_prefix_open_file(): unable to open file, file name = 'filename', temp_file_name = 'filename' major: File accessibility minor: Unable to open file HDF5-DIAG: Error detected in HDF5 (version (number)) thread (IDs): #000: (file name) line (number) in H5Oopen(): unable to open object major: Object header minor: Can't open object - #001: (file name) line (number) in H5VL_object_open(): open failed + #001: (file name) line (number) in H5VL_object_open(): object open failed + major: Virtual Object Layer + minor: Can't open object + #002: (file name) line (number) in H5VL__object_open(): object open failed major: Virtual Object Layer minor: Can't open object - #002: (file name) line (number) in H5VL_native_object_open(): unable to open object by name + #003: (file name) line (number) in H5VL__native_object_open(): unable to open object by name major: Object header minor: Can't open object - #003: (file name) line (number) in H5O_open_name(): object not found + #004: (file name) line (number) in H5O_open_name(): object not found major: Object header minor: Object not found - #004: (file name) line (number) in H5G_loc_find(): can't find object + #005: (file name) line (number) in H5G_loc_find(): can't find object major: Symbol table minor: Object not found - #005: (file name) line (number) in H5G_traverse(): internal path traversal failed + #006: (file name) line (number) in H5G_traverse(): internal path traversal failed major: Symbol table minor: Object not found - #006: (file name) line (number) in H5G__traverse_real(): special link traversal failed + #007: (file name) line (number) in H5G__traverse_real(): special link traversal failed major: Links minor: Link traversal failure - #007: (file name) line (number) in H5G__traverse_special(): user-defined link traversal failed + #008: (file name) line (number) in H5G__traverse_special(): user-defined link traversal failed major: Links minor: Link traversal failure - #008: (file name) line (number) in H5G__traverse_ud(): traversal callback returned invalid ID + #009: (file name) line (number) in H5G__traverse_ud(): traversal callback returned invalid ID major: Symbol table minor: Unable to find atom information (already closed?) - #009: (file name) line (number) in H5L__extern_traverse(): unable to open external file, external link file name = 'anotherfile' + #010: (file name) line (number) in H5L__extern_traverse(): unable to open external file, external link file name = 'anotherfile' major: Links minor: Unable to open file - #010: (file name) line (number) in H5F_prefix_open_file(): unable to open file, file name = 'anotherfile', temp_file_name = 'anotherfile' + #011: (file name) line (number) in H5F_prefix_open_file(): unable to open file, file name = 'anotherfile', temp_file_name = 'anotherfile' major: File accessibility minor: Unable to open file diff --git a/tools/test/h5dump/errfiles/textlinkfar.err b/tools/test/h5dump/errfiles/textlinkfar.err index ba06406..8245291 100644 --- a/tools/test/h5dump/errfiles/textlinkfar.err +++ b/tools/test/h5dump/errfiles/textlinkfar.err @@ -2,55 +2,58 @@ HDF5-DIAG: Error detected in HDF5 (version (number)) thread (IDs): #000: (file name) line (number) in H5Oopen(): unable to open object major: Object header minor: Can't open object - #001: (file name) line (number) in H5VL_object_open(): open failed + #001: (file name) line (number) in H5VL_object_open(): object open failed major: Virtual Object Layer minor: Can't open object - #002: (file name) line (number) in H5VL_native_object_open(): unable to open object by name + #002: (file name) line (number) in H5VL__object_open(): object open failed + major: Virtual Object Layer + minor: Can't open object + #003: (file name) line (number) in H5VL__native_object_open(): unable to open object by name major: Object header minor: Can't open object - #003: (file name) line (number) in H5O_open_name(): object not found + #004: (file name) line (number) in H5O_open_name(): object not found major: Object header minor: Object not found - #004: (file name) line (number) in H5G_loc_find(): can't find object + #005: (file name) line (number) in H5G_loc_find(): can't find object major: Symbol table minor: Object not found - #005: (file name) line (number) in H5G_traverse(): internal path traversal failed + #006: (file name) line (number) in H5G_traverse(): internal path traversal failed major: Symbol table minor: Object not found - #006: (file name) line (number) in H5G__traverse_real(): special link traversal failed + #007: (file name) line (number) in H5G__traverse_real(): special link traversal failed major: Links minor: Link traversal failure - #007: (file name) line (number) in H5G__traverse_special(): user-defined link traversal failed + #008: (file name) line (number) in H5G__traverse_special(): user-defined link traversal failed major: Links minor: Link traversal failure - #008: (file name) line (number) in H5G__traverse_ud(): traversal callback returned invalid ID + #009: (file name) line (number) in H5G__traverse_ud(): traversal callback returned invalid ID major: Symbol table minor: Unable to find atom information (already closed?) - #009: (file name) line (number) in H5L__extern_traverse(): unable to open object + #010: (file name) line (number) in H5L__extern_traverse(): unable to open object major: Links minor: Can't open object - #010: (file name) line (number) in H5O_open_name(): object not found + #011: (file name) line (number) in H5O_open_name(): object not found major: Object header minor: Object not found - #011: (file name) line (number) in H5G_loc_find(): can't find object + #012: (file name) line (number) in H5G_loc_find(): can't find object major: Symbol table minor: Object not found - #012: (file name) line (number) in H5G_traverse(): internal path traversal failed + #013: (file name) line (number) in H5G_traverse(): internal path traversal failed major: Symbol table minor: Object not found - #013: (file name) line (number) in H5G__traverse_real(): special link traversal failed + #014: (file name) line (number) in H5G__traverse_real(): special link traversal failed major: Links minor: Link traversal failure - #014: (file name) line (number) in H5G__traverse_special(): symbolic link traversal failed + #015: (file name) line (number) in H5G__traverse_special(): symbolic link traversal failed major: Links minor: Link traversal failure - #015: (file name) line (number) in H5G__traverse_slink(): unable to follow symbolic link + #016: (file name) line (number) in H5G__traverse_slink(): unable to follow symbolic link major: Symbol table minor: Object not found - #016: (file name) line (number) in H5G__traverse_real(): traversal operator failed + #017: (file name) line (number) in H5G__traverse_real(): traversal operator failed major: Symbol table minor: Callback failed - #017: (file name) line (number) in H5G__traverse_slink_cb(): component not found + #018: (file name) line (number) in H5G__traverse_slink_cb(): component not found major: Symbol table minor: Object not found HDF5-DIAG: Error detected in HDF5 (version (number)) thread (IDs): diff --git a/tools/test/h5dump/errfiles/textlinksrc.err b/tools/test/h5dump/errfiles/textlinksrc.err index ba06406..8245291 100644 --- a/tools/test/h5dump/errfiles/textlinksrc.err +++ b/tools/test/h5dump/errfiles/textlinksrc.err @@ -2,55 +2,58 @@ HDF5-DIAG: Error detected in HDF5 (version (number)) thread (IDs): #000: (file name) line (number) in H5Oopen(): unable to open object major: Object header minor: Can't open object - #001: (file name) line (number) in H5VL_object_open(): open failed + #001: (file name) line (number) in H5VL_object_open(): object open failed major: Virtual Object Layer minor: Can't open object - #002: (file name) line (number) in H5VL_native_object_open(): unable to open object by name + #002: (file name) line (number) in H5VL__object_open(): object open failed + major: Virtual Object Layer + minor: Can't open object + #003: (file name) line (number) in H5VL__native_object_open(): unable to open object by name major: Object header minor: Can't open object - #003: (file name) line (number) in H5O_open_name(): object not found + #004: (file name) line (number) in H5O_open_name(): object not found major: Object header minor: Object not found - #004: (file name) line (number) in H5G_loc_find(): can't find object + #005: (file name) line (number) in H5G_loc_find(): can't find object major: Symbol table minor: Object not found - #005: (file name) line (number) in H5G_traverse(): internal path traversal failed + #006: (file name) line (number) in H5G_traverse(): internal path traversal failed major: Symbol table minor: Object not found - #006: (file name) line (number) in H5G__traverse_real(): special link traversal failed + #007: (file name) line (number) in H5G__traverse_real(): special link traversal failed major: Links minor: Link traversal failure - #007: (file name) line (number) in H5G__traverse_special(): user-defined link traversal failed + #008: (file name) line (number) in H5G__traverse_special(): user-defined link traversal failed major: Links minor: Link traversal failure - #008: (file name) line (number) in H5G__traverse_ud(): traversal callback returned invalid ID + #009: (file name) line (number) in H5G__traverse_ud(): traversal callback returned invalid ID major: Symbol table minor: Unable to find atom information (already closed?) - #009: (file name) line (number) in H5L__extern_traverse(): unable to open object + #010: (file name) line (number) in H5L__extern_traverse(): unable to open object major: Links minor: Can't open object - #010: (file name) line (number) in H5O_open_name(): object not found + #011: (file name) line (number) in H5O_open_name(): object not found major: Object header minor: Object not found - #011: (file name) line (number) in H5G_loc_find(): can't find object + #012: (file name) line (number) in H5G_loc_find(): can't find object major: Symbol table minor: Object not found - #012: (file name) line (number) in H5G_traverse(): internal path traversal failed + #013: (file name) line (number) in H5G_traverse(): internal path traversal failed major: Symbol table minor: Object not found - #013: (file name) line (number) in H5G__traverse_real(): special link traversal failed + #014: (file name) line (number) in H5G__traverse_real(): special link traversal failed major: Links minor: Link traversal failure - #014: (file name) line (number) in H5G__traverse_special(): symbolic link traversal failed + #015: (file name) line (number) in H5G__traverse_special(): symbolic link traversal failed major: Links minor: Link traversal failure - #015: (file name) line (number) in H5G__traverse_slink(): unable to follow symbolic link + #016: (file name) line (number) in H5G__traverse_slink(): unable to follow symbolic link major: Symbol table minor: Object not found - #016: (file name) line (number) in H5G__traverse_real(): traversal operator failed + #017: (file name) line (number) in H5G__traverse_real(): traversal operator failed major: Symbol table minor: Callback failed - #017: (file name) line (number) in H5G__traverse_slink_cb(): component not found + #018: (file name) line (number) in H5G__traverse_slink_cb(): component not found major: Symbol table minor: Object not found HDF5-DIAG: Error detected in HDF5 (version (number)) thread (IDs): diff --git a/tools/test/h5dump/errfiles/tgroup-2.err b/tools/test/h5dump/errfiles/tgroup-2.err index af220b8..27557f3 100644 --- a/tools/test/h5dump/errfiles/tgroup-2.err +++ b/tools/test/h5dump/errfiles/tgroup-2.err @@ -2,25 +2,28 @@ HDF5-DIAG: Error detected in HDF5 (version (number)) thread (IDs): #000: (file name) line (number) in H5Gopen2(): unable to open group major: Symbol table minor: Can't open object - #001: (file name) line (number) in H5VL_group_open(): open failed + #001: (file name) line (number) in H5VL_group_open(): group open failed major: Virtual Object Layer minor: Can't open object - #002: (file name) line (number) in H5VL_native_group_open(): unable to open group + #002: (file name) line (number) in H5VL__group_open(): group open failed + major: Virtual Object Layer + minor: Can't open object + #003: (file name) line (number) in H5VL__native_group_open(): unable to open group major: Symbol table minor: Can't open object - #003: (file name) line (number) in H5G__open_name(): group not found + #004: (file name) line (number) in H5G__open_name(): group not found major: Symbol table minor: Object not found - #004: (file name) line (number) in H5G_loc_find(): can't find object + #005: (file name) line (number) in H5G_loc_find(): can't find object major: Symbol table minor: Object not found - #005: (file name) line (number) in H5G_traverse(): internal path traversal failed + #006: (file name) line (number) in H5G_traverse(): internal path traversal failed major: Symbol table minor: Object not found - #006: (file name) line (number) in H5G__traverse_real(): traversal operator failed + #007: (file name) line (number) in H5G__traverse_real(): traversal operator failed major: Symbol table minor: Callback failed - #007: (file name) line (number) in H5G__loc_find_cb(): object 'y' doesn't exist + #008: (file name) line (number) in H5G__loc_find_cb(): object 'y' doesn't exist major: Symbol table minor: Object not found h5dump error: unable to open group "/y" diff --git a/tools/test/h5dump/errfiles/torderlinks1.err b/tools/test/h5dump/errfiles/torderlinks1.err index 1336de5..ce31ced 100644 --- a/tools/test/h5dump/errfiles/torderlinks1.err +++ b/tools/test/h5dump/errfiles/torderlinks1.err @@ -2,33 +2,36 @@ HDF5-DIAG: Error detected in HDF5 (version (number)) thread (IDs): #000: (file name) line (number) in H5Oopen(): unable to open object major: Object header minor: Can't open object - #001: (file name) line (number) in H5VL_object_open(): open failed + #001: (file name) line (number) in H5VL_object_open(): object open failed major: Virtual Object Layer minor: Can't open object - #002: (file name) line (number) in H5VL_native_object_open(): unable to open object by name + #002: (file name) line (number) in H5VL__object_open(): object open failed + major: Virtual Object Layer + minor: Can't open object + #003: (file name) line (number) in H5VL__native_object_open(): unable to open object by name major: Object header minor: Can't open object - #003: (file name) line (number) in H5O_open_name(): object not found + #004: (file name) line (number) in H5O_open_name(): object not found major: Object header minor: Object not found - #004: (file name) line (number) in H5G_loc_find(): can't find object + #005: (file name) line (number) in H5G_loc_find(): can't find object major: Symbol table minor: Object not found - #005: (file name) line (number) in H5G_traverse(): internal path traversal failed + #006: (file name) line (number) in H5G_traverse(): internal path traversal failed major: Symbol table minor: Object not found - #006: (file name) line (number) in H5G__traverse_real(): special link traversal failed + #007: (file name) line (number) in H5G__traverse_real(): special link traversal failed major: Links minor: Link traversal failure - #007: (file name) line (number) in H5G__traverse_special(): user-defined link traversal failed + #008: (file name) line (number) in H5G__traverse_special(): user-defined link traversal failed major: Links minor: Link traversal failure - #008: (file name) line (number) in H5G__traverse_ud(): traversal callback returned invalid ID + #009: (file name) line (number) in H5G__traverse_ud(): traversal callback returned invalid ID major: Symbol table minor: Unable to find atom information (already closed?) - #009: (file name) line (number) in H5L__extern_traverse(): unable to open external file, external link file name = 'fname' + #010: (file name) line (number) in H5L__extern_traverse(): unable to open external file, external link file name = 'fname' major: Links minor: Unable to open file - #010: (file name) line (number) in H5F_prefix_open_file(): unable to open file, file name = 'fname', temp_file_name = 'fname' + #011: (file name) line (number) in H5F_prefix_open_file(): unable to open file, file name = 'fname', temp_file_name = 'fname' major: File accessibility minor: Unable to open file diff --git a/tools/test/h5dump/errfiles/torderlinks2.err b/tools/test/h5dump/errfiles/torderlinks2.err index 1336de5..ce31ced 100644 --- a/tools/test/h5dump/errfiles/torderlinks2.err +++ b/tools/test/h5dump/errfiles/torderlinks2.err @@ -2,33 +2,36 @@ HDF5-DIAG: Error detected in HDF5 (version (number)) thread (IDs): #000: (file name) line (number) in H5Oopen(): unable to open object major: Object header minor: Can't open object - #001: (file name) line (number) in H5VL_object_open(): open failed + #001: (file name) line (number) in H5VL_object_open(): object open failed major: Virtual Object Layer minor: Can't open object - #002: (file name) line (number) in H5VL_native_object_open(): unable to open object by name + #002: (file name) line (number) in H5VL__object_open(): object open failed + major: Virtual Object Layer + minor: Can't open object + #003: (file name) line (number) in H5VL__native_object_open(): unable to open object by name major: Object header minor: Can't open object - #003: (file name) line (number) in H5O_open_name(): object not found + #004: (file name) line (number) in H5O_open_name(): object not found major: Object header minor: Object not found - #004: (file name) line (number) in H5G_loc_find(): can't find object + #005: (file name) line (number) in H5G_loc_find(): can't find object major: Symbol table minor: Object not found - #005: (file name) line (number) in H5G_traverse(): internal path traversal failed + #006: (file name) line (number) in H5G_traverse(): internal path traversal failed major: Symbol table minor: Object not found - #006: (file name) line (number) in H5G__traverse_real(): special link traversal failed + #007: (file name) line (number) in H5G__traverse_real(): special link traversal failed major: Links minor: Link traversal failure - #007: (file name) line (number) in H5G__traverse_special(): user-defined link traversal failed + #008: (file name) line (number) in H5G__traverse_special(): user-defined link traversal failed major: Links minor: Link traversal failure - #008: (file name) line (number) in H5G__traverse_ud(): traversal callback returned invalid ID + #009: (file name) line (number) in H5G__traverse_ud(): traversal callback returned invalid ID major: Symbol table minor: Unable to find atom information (already closed?) - #009: (file name) line (number) in H5L__extern_traverse(): unable to open external file, external link file name = 'fname' + #010: (file name) line (number) in H5L__extern_traverse(): unable to open external file, external link file name = 'fname' major: Links minor: Unable to open file - #010: (file name) line (number) in H5F_prefix_open_file(): unable to open file, file name = 'fname', temp_file_name = 'fname' + #011: (file name) line (number) in H5F_prefix_open_file(): unable to open file, file name = 'fname', temp_file_name = 'fname' major: File accessibility minor: Unable to open file diff --git a/tools/test/h5dump/errfiles/tperror.err b/tools/test/h5dump/errfiles/tperror.err index 4df7265..b0b908b 100644 --- a/tools/test/h5dump/errfiles/tperror.err +++ b/tools/test/h5dump/errfiles/tperror.err @@ -5,44 +5,50 @@ HDF5-DIAG: Error detected in HDF5 (version (number)) thread (IDs): #001: (file name) line (number) in H5VL_dataset_open(): dataset open failed major: Virtual Object Layer minor: Can't open object - #002: (file name) line (number) in H5VL_native_dataset_open(): unable to open dataset + #002: (file name) line (number) in H5VL__dataset_open(): dataset open failed + major: Virtual Object Layer + minor: Can't open object + #003: (file name) line (number) in H5VL__native_dataset_open(): unable to open dataset major: Dataset minor: Can't open object - #003: (file name) line (number) in H5D__open_name(): not found + #004: (file name) line (number) in H5D__open_name(): not found major: Dataset minor: Object not found - #004: (file name) line (number) in H5G_loc_find(): can't find object + #005: (file name) line (number) in H5G_loc_find(): can't find object major: Symbol table minor: Object not found - #005: (file name) line (number) in H5G_traverse(): internal path traversal failed + #006: (file name) line (number) in H5G_traverse(): internal path traversal failed major: Symbol table minor: Object not found - #006: (file name) line (number) in H5G__traverse_real(): traversal operator failed + #007: (file name) line (number) in H5G__traverse_real(): traversal operator failed major: Symbol table minor: Callback failed - #007: (file name) line (number) in H5G__loc_find_cb(): object 'bogus' doesn't exist + #008: (file name) line (number) in H5G__loc_find_cb(): object 'bogus' doesn't exist major: Symbol table minor: Object not found HDF5-DIAG: Error detected in HDF5 (version (number)) thread (IDs): #000: (file name) line (number) in H5Lget_info(): unable to get link info major: Links minor: Can't get value - #001: (file name) line (number) in H5VL_link_get(): get failed + #001: (file name) line (number) in H5VL_link_get(): link get failed major: Virtual Object Layer minor: Can't get value - #002: (file name) line (number) in H5VL_native_link_get(): unable to get link info + #002: (file name) line (number) in H5VL__link_get(): link get failed + major: Virtual Object Layer + minor: Can't get value + #003: (file name) line (number) in H5VL__native_link_get(): unable to get link info major: Links minor: Object not found - #003: (file name) line (number) in H5L_get_info(): name doesn't exist + #004: (file name) line (number) in H5L_get_info(): name doesn't exist major: Links minor: Object already exists - #004: (file name) line (number) in H5G_traverse(): internal path traversal failed + #005: (file name) line (number) in H5G_traverse(): internal path traversal failed major: Symbol table minor: Object not found - #005: (file name) line (number) in H5G__traverse_real(): traversal operator failed + #006: (file name) line (number) in H5G__traverse_real(): traversal operator failed major: Symbol table minor: Callback failed - #006: (file name) line (number) in H5L__get_info_cb(): name doesn't exist + #007: (file name) line (number) in H5L__get_info_cb(): name doesn't exist major: Links minor: Object not found h5dump error: unable to get link info from "bogus" diff --git a/tools/test/h5dump/errfiles/tslink-D.err b/tools/test/h5dump/errfiles/tslink-D.err index ded6719..e650a33 100644 --- a/tools/test/h5dump/errfiles/tslink-D.err +++ b/tools/test/h5dump/errfiles/tslink-D.err @@ -5,30 +5,33 @@ HDF5-DIAG: Error detected in HDF5 (version (number)) thread (IDs): #001: (file name) line (number) in H5VL_dataset_open(): dataset open failed major: Virtual Object Layer minor: Can't open object - #002: (file name) line (number) in H5VL_native_dataset_open(): unable to open dataset + #002: (file name) line (number) in H5VL__dataset_open(): dataset open failed + major: Virtual Object Layer + minor: Can't open object + #003: (file name) line (number) in H5VL__native_dataset_open(): unable to open dataset major: Dataset minor: Can't open object - #003: (file name) line (number) in H5D__open_name(): not found + #004: (file name) line (number) in H5D__open_name(): not found major: Dataset minor: Object not found - #004: (file name) line (number) in H5G_loc_find(): can't find object + #005: (file name) line (number) in H5G_loc_find(): can't find object major: Symbol table minor: Object not found - #005: (file name) line (number) in H5G_traverse(): internal path traversal failed + #006: (file name) line (number) in H5G_traverse(): internal path traversal failed major: Symbol table minor: Object not found - #006: (file name) line (number) in H5G__traverse_real(): special link traversal failed + #007: (file name) line (number) in H5G__traverse_real(): special link traversal failed major: Links minor: Link traversal failure - #007: (file name) line (number) in H5G__traverse_special(): symbolic link traversal failed + #008: (file name) line (number) in H5G__traverse_special(): symbolic link traversal failed major: Links minor: Link traversal failure - #008: (file name) line (number) in H5G__traverse_slink(): unable to follow symbolic link + #009: (file name) line (number) in H5G__traverse_slink(): unable to follow symbolic link major: Symbol table minor: Object not found - #009: (file name) line (number) in H5G__traverse_real(): traversal operator failed + #010: (file name) line (number) in H5G__traverse_real(): traversal operator failed major: Symbol table minor: Callback failed - #010: (file name) line (number) in H5G__traverse_slink_cb(): component not found + #011: (file name) line (number) in H5G__traverse_slink_cb(): component not found major: Symbol table minor: Object not found diff --git a/tools/test/h5dump/testh5dump.sh.in b/tools/test/h5dump/testh5dump.sh.in index 42e4b07..af5d547 100644 --- a/tools/test/h5dump/testh5dump.sh.in +++ b/tools/test/h5dump/testh5dump.sh.in @@ -490,7 +490,6 @@ TOOLTEST() { STDOUT_FILTER $actual cp $actual_err $actual_err_sav STDERR_FILTER $actual_err - cat $actual_err >> $actual if [ ! -f $expect ]; then # Create the expect file if it doesn't yet exist. @@ -534,7 +533,6 @@ TOOLTEST2() { cd $TESTDIR $RUNSERIAL $DUMPER_BIN "$@" ) >$actual 2>$actual_err - cat $actual_err >> $actual if [ ! -f $expect ]; then # Create the expect file if it doesn't yet exist. @@ -593,7 +591,6 @@ TOOLTEST2A() { cd $TESTDIR $RUNSERIAL $DUMPER_BIN "$@" ) >$actual 2>$actual_err - cat $actual_err >> $actual if [ ! -f $expect ]; then # Create the expect file if it doesn't yet exist. @@ -660,7 +657,6 @@ TOOLTEST2B() { cd $TESTDIR $RUNSERIAL $DUMPER_BIN "$@" ) >$actual 2>$actual_err - cat $actual_err >> $actual if [ ! -f $expectdata ]; then # Create the expect data file if it doesn't yet exist. @@ -717,7 +713,6 @@ TOOLTEST3() { -e 's/H5Eget_auto[1-2]*/H5Eget_auto(1 or 2)/' \ -e 's/H5Eset_auto[1-2]*/H5Eset_auto(1 or 2)/' \ $actual_err > $actual_ext - cat $actual_ext >> $actual if [ ! -f $expect ]; then # Create the expect file if it doesn't yet exist. @@ -776,7 +771,6 @@ TOOLTEST4() { -e 's/H5Eget_auto[1-2]*/H5Eget_auto(1 or 2)/' \ -e 's/H5Eset_auto[1-2]*/H5Eset_auto(1 or 2)/' \ $actual_err > $actual_ext - #cat $actual_ext >> $actual if [ ! -f $expect ]; then # Create the expect file if it doesn't yet exist. @@ -842,7 +836,6 @@ TOOLTEST5() { -e 's/H5Eget_auto[1-2]*/H5Eget_auto(1 or 2)/' \ -e 's/H5Eset_auto[1-2]*/H5Eset_auto(1 or 2)/' \ $actual_err > $actual_ext - #cat $actual_ext >> $actual if [ ! -f $expect ]; then # Create the expect file if it doesn't yet exist. @@ -886,7 +879,6 @@ TOOLTEST_HELP() { cd $TESTDIR $RUNSERIAL $DUMPER_BIN "$@" ) >$actual 2>$actual_err - cat $actual_err >> $actual if [ ! -f $expectdata ]; then # Create the expect data file if it doesn't yet exist. diff --git a/tools/test/h5dump/testh5dumppbits.sh.in b/tools/test/h5dump/testh5dumppbits.sh.in index 9cf5c99..febce2c 100644 --- a/tools/test/h5dump/testh5dumppbits.sh.in +++ b/tools/test/h5dump/testh5dumppbits.sh.in @@ -235,7 +235,6 @@ TOOLTEST() { STDOUT_FILTER $actual cp $actual_err $actual_err_sav STDERR_FILTER $actual_err - cat $actual_err >> $actual if [ ! -f $expect ]; then # Create the expect file if it doesn't yet exist. @@ -278,7 +277,6 @@ TOOLTEST2() { cd $TESTDIR $RUNSERIAL $DUMPER_BIN "$@" ) >$actual 2>$actual_err - cat $actual_err >> $actual if [ ! -f $expect ]; then # Create the expect file if it doesn't yet exist. @@ -348,7 +346,6 @@ TOOLTEST3() { -e 's/H5Eget_auto[1-2]*/H5Eget_auto(1 or 2)/' \ -e 's/H5Eset_auto[1-2]*/H5Eset_auto(1 or 2)/' \ $actual_err > $actual_ext - cat $actual_ext >> $actual if [ ! -f $expect ]; then # Create the expect file if it doesn't yet exist. @@ -406,7 +403,6 @@ TOOLTEST4() { -e 's/H5Eget_auto[1-2]*/H5Eget_auto(1 or 2)/' \ -e 's/H5Eset_auto[1-2]*/H5Eset_auto(1 or 2)/' \ $actual_err > $actual_ext - #cat $actual_ext >> $actual if [ ! -f $expect ]; then # Create the expect file if it doesn't yet exist. diff --git a/tools/test/h5format_convert/CMakeTests.cmake b/tools/test/h5format_convert/CMakeTests.cmake index 2240813..5792d40 100644 --- a/tools/test/h5format_convert/CMakeTests.cmake +++ b/tools/test/h5format_convert/CMakeTests.cmake @@ -22,10 +22,8 @@ set (HDF5_REFERENCE_FILES h5fc_help.ddl h5fc_nooption.ddl - h5fc_nonexistfile.ddl h5fc_d_file.ddl h5fc_dname.ddl - h5fc_nonexistdset_file.ddl h5fc_v_non_chunked.ddl h5fc_v_bt1.ddl h5fc_v_ndata_bt1.ddl @@ -49,6 +47,12 @@ h5fc_v_err.ddl h5fc_v_err.ddl.err ) + set (HDF5_REFERENCE_ERR_FILES + h5fc_d_file.ddl.err + h5fc_dname.err + h5fc_nonexistfile.ddl.err + h5fc_nonexistdset_file.ddl.err + ) set (HDF5_REFERENCE_TEST_FILES h5fc_non_v3.h5 h5fc_edge_v3.h5 @@ -78,6 +82,10 @@ HDFTEST_COPY_FILE("${HDF5_TOOLS_TEST_H5FC_SOURCE_DIR}/testfiles/${ddl_file}" "${PROJECT_BINARY_DIR}/testfiles/${ddl_file}" "h5fc_files") endforeach () + foreach (h5_file ${HDF5_REFERENCE_ERR_FILES}) + HDFTEST_COPY_FILE("${HDF5_TOOLS_TEST_H5FC_SOURCE_DIR}/testfiles/${h5_file}" "${PROJECT_BINARY_DIR}/testfiles/${h5_file}" "h5fc_files") + endforeach () + foreach (h5_file ${HDF5_REFERENCE_TEST_FILES}) HDFTEST_COPY_FILE("${HDF5_TOOLS_TEST_H5FC_SOURCE_DIR}/testfiles/${h5_file}" "${PROJECT_BINARY_DIR}/testfiles/${h5_file}" "h5fc_files") endforeach () @@ -119,6 +127,7 @@ -D "TEST_OUTPUT=${testname}.out" -D "TEST_EXPECT=${resultcode}" -D "TEST_REFERENCE=${resultfile}" + -D "TEST_ERRREF=${resultfile}.err" -P "${HDF_RESOURCES_EXT_DIR}/runTest.cmake" ) set_tests_properties (H5FC-${testname}-${testfile} PROPERTIES DEPENDS "H5FC-${testname}-${testfile}-tmpfile") @@ -141,6 +150,42 @@ endif () endmacro () + macro (ADD_H5_NOERR_OUTPUT testname resultfile resultcode testfile) + # If using memchecker add tests without using scripts + if (NOT HDF5_ENABLE_USING_MEMCHECKER) + add_test ( + NAME H5FC-${testname}-clear-objects + COMMAND ${CMAKE_COMMAND} + -E remove + ./testfiles/outtmp.h5 + ./testfiles/${testname}.out + ./testfiles/${testname}.out.err + ) + if (NOT "${last_test}" STREQUAL "") + set_tests_properties (H5FC-${testname}-clear-objects PROPERTIES DEPENDS ${last_test}) + endif () + add_test ( + NAME H5FC-${testname}-${testfile}-tmpfile + COMMAND ${CMAKE_COMMAND} + -E copy_if_different ${HDF5_TOOLS_TEST_H5FC_SOURCE_DIR}/testfiles/${testfile} ./testfiles/outtmp.h5 + ) + set_tests_properties (H5FC-${testname}-${testfile}-tmpfile PROPERTIES DEPENDS "H5FC-${testname}-clear-objects") + add_test ( + NAME H5FC-${testname}-${testfile} + COMMAND "${CMAKE_COMMAND}" + -D "TEST_PROGRAM=$<TARGET_FILE:h5format_convert>" + -D "TEST_ARGS=${ARGN};outtmp.h5" + -D "TEST_FOLDER=${PROJECT_BINARY_DIR}/testfiles" + -D "TEST_OUTPUT=${testname}.out" + -D "TEST_EXPECT=${resultcode}" + -D "TEST_REFERENCE=${resultfile}" + -P "${HDF_RESOURCES_EXT_DIR}/runTest.cmake" + ) + set_tests_properties (H5FC-${testname}-${testfile} PROPERTIES DEPENDS "H5FC-${testname}-${testfile}-tmpfile") + set (last_test "H5FC-${testname}-${testfile}") + endif () + endmacro () + macro (ADD_H5_MASK_OUTPUT testname resultfile resultcode testfile) # If using memchecker add tests without using scripts if (NOT HDF5_ENABLE_USING_MEMCHECKER) @@ -433,17 +478,17 @@ # h5format_convert -d /GROUP/DSET_BT2 --verbose old_h5fc_ext_none.h5 (verbose, bt1 dataset) # h5format_convert -d /DSET_NDATA_BT2 -v -n old_h5fc_ext_none.h5 (verbose, noop, bt1+nodata dataset) # h5format_convert -v old_h5fc_ext_none.h5 (verbose, all datasets) - ADD_H5_OUTPUT (h5fc_v_non_chunked h5fc_v_non_chunked.ddl 0 old_h5fc_ext_none.h5 -d /DSET_CONTIGUOUS -v) - ADD_H5_OUTPUT (h5fc_v_bt1 h5fc_v_bt1.ddl 0 old_h5fc_ext_none.h5 -d /GROUP/DSET_BT2 --verbose) - ADD_H5_OUTPUT (h5fc_v_ndata_bt1 h5fc_v_ndata_bt1.ddl 0 old_h5fc_ext_none.h5 -d /DSET_NDATA_BT2 -v -n) - ADD_H5_OUTPUT (h5fc_v_all h5fc_v_all.ddl 0 old_h5fc_ext_none.h5 -v) + ADD_H5_NOERR_OUTPUT (h5fc_v_non_chunked h5fc_v_non_chunked.ddl 0 old_h5fc_ext_none.h5 -d /DSET_CONTIGUOUS -v) + ADD_H5_NOERR_OUTPUT (h5fc_v_bt1 h5fc_v_bt1.ddl 0 old_h5fc_ext_none.h5 -d /GROUP/DSET_BT2 --verbose) + ADD_H5_NOERR_OUTPUT (h5fc_v_ndata_bt1 h5fc_v_ndata_bt1.ddl 0 old_h5fc_ext_none.h5 -d /DSET_NDATA_BT2 -v -n) + ADD_H5_NOERR_OUTPUT (h5fc_v_all h5fc_v_all.ddl 0 old_h5fc_ext_none.h5 -v) # # # # h5format_convert -d /DSET_EA -v -n h5fc_ext_none.h5 (verbose, noop, one ea dataset) # h5format_convert -v -n h5fc_non_v3.h5 (verbose, noop, all datasets) - ADD_H5_OUTPUT (h5fc_v_n_1d h5fc_v_n_1d.ddl 0 h5fc_ext_none.h5 -d /DSET_EA -v -n) - ADD_H5_OUTPUT (h5fc_v_n_all h5fc_v_n_all.ddl 0 h5fc_non_v3.h5 -v -n) + ADD_H5_NOERR_OUTPUT (h5fc_v_n_1d h5fc_v_n_1d.ddl 0 h5fc_ext_none.h5 -d /DSET_EA -v -n) + ADD_H5_NOERR_OUTPUT (h5fc_v_n_all h5fc_v_n_all.ddl 0 h5fc_non_v3.h5 -v -n) # # # diff --git a/tools/test/h5format_convert/testfiles/h5fc_d_file-d.ddl b/tools/test/h5format_convert/testfiles/h5fc_d_file-d.ddl new file mode 100644 index 0000000..bc0229c --- /dev/null +++ b/tools/test/h5format_convert/testfiles/h5fc_d_file-d.ddl @@ -0,0 +1,25 @@ +usage: h5format_convert [OPTIONS] file_name + OPTIONS + -h, --help Print a usage message and exit + -V, --version Print version number and exit + -v, --verbose Turn on verbose mode + -d dname, --dname=dataset_name Pathname for the dataset + -n, --noop Perform all the steps except the actual conversion + +Examples of use: + +h5format_convert -d /group/dataset file_name + Convert the dataset </group/dataset> in the HDF5 file <file_name>: + a. chunked dataset: convert the chunk indexing type to version 1 B-tree + b. compact/contiguous dataset: downgrade the layout version to 3 + c. virtual dataset: no action + +h5format_convert file_name + Convert all datasets in the HDF5 file <file_name>: + a. chunked dataset: convert the chunk indexing type to version 1 B-tree + b. compact/contiguous dataset: downgrade the layout version to 3 + c. virtual dataset: no action + +h5format_convert -n -d /group/dataset file_name + Go through all the steps except the actual conversion when + converting the dataset </group/dataset> in the HDF5 file <file_name>. diff --git a/tools/test/h5format_convert/testfiles/h5fc_d_file.ddl b/tools/test/h5format_convert/testfiles/h5fc_d_file.ddl index 38fc432..bc0229c 100644 --- a/tools/test/h5format_convert/testfiles/h5fc_d_file.ddl +++ b/tools/test/h5format_convert/testfiles/h5fc_d_file.ddl @@ -23,4 +23,3 @@ h5format_convert file_name h5format_convert -n -d /group/dataset file_name Go through all the steps except the actual conversion when converting the dataset </group/dataset> in the HDF5 file <file_name>. -h5format_convert error: missing file name diff --git a/tools/test/h5format_convert/testfiles/h5fc_d_file.ddl.err b/tools/test/h5format_convert/testfiles/h5fc_d_file.ddl.err new file mode 100644 index 0000000..ceb0fe4 --- /dev/null +++ b/tools/test/h5format_convert/testfiles/h5fc_d_file.ddl.err @@ -0,0 +1 @@ +h5format_convert error: missing file name diff --git a/tools/test/h5format_convert/testfiles/h5fc_dname.ddl b/tools/test/h5format_convert/testfiles/h5fc_dname.ddl index 48564b7..bc0229c 100644 --- a/tools/test/h5format_convert/testfiles/h5fc_dname.ddl +++ b/tools/test/h5format_convert/testfiles/h5fc_dname.ddl @@ -23,4 +23,3 @@ h5format_convert file_name h5format_convert -n -d /group/dataset file_name Go through all the steps except the actual conversion when converting the dataset </group/dataset> in the HDF5 file <file_name>. -h5format_convert error: No dataset name diff --git a/tools/test/h5format_convert/testfiles/h5fc_dname.err b/tools/test/h5format_convert/testfiles/h5fc_dname.err new file mode 100644 index 0000000..361d8a9 --- /dev/null +++ b/tools/test/h5format_convert/testfiles/h5fc_dname.err @@ -0,0 +1 @@ +h5format_convert error: No dataset name diff --git a/tools/test/h5format_convert/testfiles/h5fc_nonexistdset_file.ddl b/tools/test/h5format_convert/testfiles/h5fc_nonexistdset_file.ddl.err index 39450c0..39450c0 100644 --- a/tools/test/h5format_convert/testfiles/h5fc_nonexistdset_file.ddl +++ b/tools/test/h5format_convert/testfiles/h5fc_nonexistdset_file.ddl.err diff --git a/tools/test/h5format_convert/testfiles/h5fc_nonexistfile.ddl b/tools/test/h5format_convert/testfiles/h5fc_nonexistfile.ddl.err index 706ea9d..706ea9d 100644 --- a/tools/test/h5format_convert/testfiles/h5fc_nonexistfile.ddl +++ b/tools/test/h5format_convert/testfiles/h5fc_nonexistfile.ddl.err diff --git a/tools/test/h5format_convert/testh5fc.sh.in b/tools/test/h5format_convert/testh5fc.sh.in index 585d389..2cdd445 100644 --- a/tools/test/h5format_convert/testh5fc.sh.in +++ b/tools/test/h5format_convert/testh5fc.sh.in @@ -103,13 +103,18 @@ $SRC_H5FORMCONV_TESTFILES/old_h5fc_ext3_isf.h5 $SRC_H5FORMCONV_TESTFILES/h5fc_err_level.h5 " +LIST_ERR_TEST_FILES=" +$SRC_H5FORMCONV_TESTFILES/h5fc_d_file.ddl.err +$SRC_H5FORMCONV_TESTFILES/h5fc_dname.err +$SRC_H5FORMCONV_TESTFILES/h5fc_nonexistfile.ddl.err +$SRC_H5FORMCONV_TESTFILES/h5fc_nonexistdset_file.ddl.err +" + LIST_OTHER_TEST_FILES=" $SRC_H5FORMCONV_TESTFILES/h5fc_help.ddl $SRC_H5FORMCONV_TESTFILES/h5fc_nooption.ddl -$SRC_H5FORMCONV_TESTFILES/h5fc_nonexistfile.ddl $SRC_H5FORMCONV_TESTFILES/h5fc_d_file.ddl $SRC_H5FORMCONV_TESTFILES/h5fc_dname.ddl -$SRC_H5FORMCONV_TESTFILES/h5fc_nonexistdset_file.ddl $SRC_H5FORMCONV_TESTFILES/h5fc_v_non_chunked.ddl $SRC_H5FORMCONV_TESTFILES/h5fc_v_bt1.ddl $SRC_H5FORMCONV_TESTFILES/h5fc_v_ndata_bt1.ddl @@ -137,7 +142,7 @@ $SRC_H5FORMCONV_TESTFILES/h5fc_v_err.ddl.err # # copy test files and expected output files from source dirs to test dir # -COPY_TESTFILES="$LIST_HDF5_TEST_FILES $LIST_OTHER_TEST_FILES" +COPY_TESTFILES="$LIST_HDF5_TEST_FILES $LIST_ERR_TEST_FILES $LIST_OTHER_TEST_FILES" COPY_TESTFILES_TO_TESTDIR() { @@ -193,6 +198,9 @@ TESTING() { echo "Testing $* $SPACES" | cut -c1-80 | tr -d '\012' } +# Source in the output filter function definitions. +. $srcdir/../../../bin/output_filter.sh + # Run a test and print PASS or *FAIL*. If a test fails then increment # the `nerrors' global variable and (if $verbose is set) display the # difference between the actual output and the expected output. The @@ -212,8 +220,9 @@ TESTING() { TOOLTEST_OUT() { # Prepare expected and actual output expect="$TESTDIR/$1" + expect_err="$TESTDIR/`basename $1 .ddl`.err" actual="$TESTDIR/`basename $1 .ddl`.out" - actual_err="$TESTDIR/`basename $1 .ddl`.err" + actual_err="$TESTDIR/`basename $1 .ddl`.out.err" actual_sav=${actual}-sav actual_err_sav=${actual_err}-sav @@ -233,7 +242,6 @@ TOOLTEST_OUT() { ) >$actual 2>$actual_err cp $actual $actual_sav cp $actual_err $actual_err_sav - cat $actual_err >> $actual # Compare output COMPARE_OUT $expect $actual @@ -251,7 +259,7 @@ TOOLTEST_MASK_OUT() { expect_err="$TESTDIR/$1.err" actual_ext="$TESTDIR/$1.ext" actual="$TESTDIR/`basename $1 .ddl`.out" - actual_err="$TESTDIR/`basename $1 .ddl`.err" + actual_err="$TESTDIR/`basename $1 .ddl`.out.err" actual_sav=${actual}-sav actual_err_sav=${actual_err}-sav @@ -305,6 +313,42 @@ TOOLTEST_MASK_OUT() { $RM $actual $actual_err $actual_sav $actual_err_sav fi } +# Same as TOOLTEST_OUT except only compares error outout +TOOLTEST_ERR() { + # Prepare expected and actual output + expect="$TESTDIR/$1" + expect_err="$TESTDIR/$1.err" + actual="$TESTDIR/`basename $1 .ddl`.out" + actual_err="$TESTDIR/`basename $1 .ddl`.out.err" + actual_sav=${actual}-sav + actual_err_sav=${actual_err}-sav + + # Prepare the test file + $RM $TESTDIR/$TMPOUTFILE + TFILE=$2 + if [ ! -z "$2" ] && [ -e $TESTDIR/$2 ] ; then + $CP $TESTDIR/$2 $TESTDIR/$TMPOUTFILE + TFILE=$TMPOUTFILE + fi + + # Run test. + TESTING $FORMCONV $3 $4 $5 $6 $2 + ( + cd $TESTDIR + $RUNSERIAL $FORMCONV_BIN $3 $4 $5 $6 $TFILE + ) >$actual 2>$actual_err + cp $actual $actual_sav + cp $actual_err $actual_err_sav + + # Compare output + COMPARE_OUT $expect_err $actual_err + + # Clean up output file + if test -z "$HDF5_NOCLEANUP"; then + $RM $actual $actual_err + $RM $actual $actual_err $actual_sav $actual_err_sav + fi +} # To check that the tool exits success, no output # Assume all short options @@ -406,7 +450,7 @@ COPY_TESTFILES_TO_TESTDIR # h5format_convert nonexist.h5 (no options, file does not exist) TOOLTEST_OUT h5fc_help.ddl '' --help TOOLTEST_OUT h5fc_nooption.ddl '' -TOOLTEST_OUT h5fc_nonexistfile.ddl nonexist.h5 +TOOLTEST_ERR h5fc_nonexistfile.ddl nonexist.h5 # # # h5format_convert -d old_h5fc_ext_none.h5 (just -d option, file exists) @@ -416,7 +460,7 @@ TOOLTEST_OUT h5fc_nonexistfile.ddl nonexist.h5 TOOLTEST_OUT h5fc_d_file.ddl old_h5fc_ext_none.h5 -d TOOLTEST_OUT h5fc_d_file.ddl old_h5fc_ext_none.h5 --dname TOOLTEST_OUT h5fc_dname.ddl '' --dname -TOOLTEST_OUT h5fc_nonexistdset_file.ddl old_h5fc_ext_none.h5 --dname=nonexist +TOOLTEST_ERR h5fc_nonexistdset_file.ddl old_h5fc_ext_none.h5 --dname=nonexist # # # diff --git a/tools/test/h5jam/CMakeTests.cmake b/tools/test/h5jam/CMakeTests.cmake index 66ff715..2d00b86 100644 --- a/tools/test/h5jam/CMakeTests.cmake +++ b/tools/test/h5jam/CMakeTests.cmake @@ -74,6 +74,8 @@ -D "TEST_FOLDER=${PROJECT_BINARY_DIR}" -D "TEST_OUTPUT=${expectfile}.out" -D "TEST_EXPECT=${resultcode}" + -D "TEST_ERRREF=testfiles/${expectfile}.txt" + -D "TEST_SKIP_COMPARE=1" -D "TEST_REFERENCE=testfiles/${expectfile}.txt" -P "${HDF_RESOURCES_EXT_DIR}/runTest.cmake" ) diff --git a/tools/test/h5jam/tellub.c b/tools/test/h5jam/tellub.c index 26c725d..aa779b3 100644 --- a/tools/test/h5jam/tellub.c +++ b/tools/test/h5jam/tellub.c @@ -104,7 +104,7 @@ main (int argc, const char *argv[]) hsize_t usize; htri_t testval; herr_t status; - hid_t plist = -1; + hid_t plist = H5I_INVALID_HID; h5tools_setprogname(PROGRAMNAME); h5tools_setstatus(EXIT_SUCCESS); diff --git a/tools/test/h5ls/CMakeTests.cmake b/tools/test/h5ls/CMakeTests.cmake index 488b271..116d097 100644 --- a/tools/test/h5ls/CMakeTests.cmake +++ b/tools/test/h5ls/CMakeTests.cmake @@ -47,6 +47,12 @@ ${HDF5_TOOLS_DIR}/testfiles/tdset_idx.h5 ) + set (LIST_ERR_TEST_FILES + ${HDF5_TOOLS_DIR}/test/h5ls/errfiles/nosuchfile.err + ${HDF5_TOOLS_DIR}/test/h5ls/errfiles/textlinksrc-nodangle-1.err + ${HDF5_TOOLS_DIR}/test/h5ls/errfiles/tgroup-1.err + ) + set (LIST_OTHER_TEST_FILES ${HDF5_TOOLS_DIR}/testfiles/help-1.ls ${HDF5_TOOLS_DIR}/testfiles/help-2.ls @@ -116,6 +122,10 @@ get_filename_component(fname "${listfiles}" NAME) HDFTEST_COPY_FILE("${listfiles}" "${PROJECT_BINARY_DIR}/testfiles/${fname}" "h5ls_files") endforeach () + foreach (listfiles ${LIST_ERR_TEST_FILES}) + get_filename_component(fname "${listfiles}" NAME) + HDFTEST_COPY_FILE("${listfiles}" "${PROJECT_BINARY_DIR}/testfiles/${fname}" "h5ls_files") + endforeach () add_custom_target(h5ls_files ALL COMMENT "Copying files needed by h5ls tests" DEPENDS ${h5ls_files_list}) ############################################################################## @@ -159,6 +169,42 @@ endif () endmacro () + macro (ADD_H5_ERR_TEST resultfile resultcode) + # If using memchecker add tests without using scripts + if (HDF5_ENABLE_USING_MEMCHECKER) + add_test (NAME H5LS-${resultfile} COMMAND $<TARGET_FILE:h5ls> ${ARGN}) + set_tests_properties (H5LS-${resultfile} PROPERTIES WORKING_DIRECTORY "${PROJECT_BINARY_DIR}/testfiles") + if ("${resultcode}" STREQUAL "1") + set_tests_properties (H5LS-${resultfile} PROPERTIES WILL_FAIL "true") + endif () + if (NOT "${last_test}" STREQUAL "") + set_tests_properties (H5LS-${resultfile} PROPERTIES DEPENDS ${last_test}) + endif () + else () + # Remove any output file left over from previous test run + add_test ( + NAME H5LS-${resultfile}-clear-objects + COMMAND ${CMAKE_COMMAND} + -E remove + testfiles/${resultfile}.out + testfiles/${resultfile}.out.err + ) + add_test ( + NAME H5LS-${resultfile} + COMMAND "${CMAKE_COMMAND}" + -D "TEST_PROGRAM=$<TARGET_FILE:h5ls>" + -D "TEST_ARGS=${ARGN}" + -D "TEST_FOLDER=${PROJECT_BINARY_DIR}/testfiles" + -D "TEST_OUTPUT=${resultfile}.out" + -D "TEST_EXPECT=${resultcode}" + -D "TEST_REFERENCE=${resultfile}.ls" + -D "TEST_ERRREF=${resultfile}.err" + -P "${HDF_RESOURCES_EXT_DIR}/runTest.cmake" + ) + set_tests_properties (H5LS-${resultfile} PROPERTIES DEPENDS H5LS-${resultfile}-clear-objects) + endif () + endmacro () + macro (ADD_H5_UD_TEST testname resultcode resultfile) if (NOT HDF5_ENABLE_USING_MEMCHECKER) # Remove any output file left over from previous test run @@ -341,7 +387,7 @@ # test for displaying groups # The following combination of arguments is expected to return an error message # and return value 1 - ADD_H5_TEST (tgroup-1 1 -w80 -r -g tgroup.h5) + ADD_H5_ERR_TEST (tgroup-1 1 -w80 -r -g tgroup.h5) ADD_H5_TEST (tgroup-2 0 -w80 -g tgroup.h5/g1) # test for files with groups that have long comments @@ -382,7 +428,7 @@ # tests for no-dangling-links # if this option is given on dangling link, h5ls should return exit code 1 # when used alone , expect to print out help and return exit code 1 - ADD_H5_TEST (textlinksrc-nodangle-1 1 -w80 --no-dangling-links textlinksrc.h5) + ADD_H5_ERR_TEST (textlinksrc-nodangle-1 1 -w80 --no-dangling-links textlinksrc.h5) # external dangling link - expected exit code 1 ADD_H5_TEST (textlinksrc-nodangle-2 1 -w80 --follow-symlinks --no-dangling-links textlinksrc.h5) # soft dangling link - expected exit code 1 @@ -444,7 +490,7 @@ endif () # test for non-existing file - ADD_H5_TEST (nosuchfile 1 nosuchfile.h5) + ADD_H5_ERR_TEST (nosuchfile 1 nosuchfile.h5) # test for variable length data types in verbose mode if (H5_WORDS_BIGENDIAN) diff --git a/tools/test/h5ls/errfiles/nosuchfile.err b/tools/test/h5ls/errfiles/nosuchfile.err new file mode 100644 index 0000000..8c4ee42 --- /dev/null +++ b/tools/test/h5ls/errfiles/nosuchfile.err @@ -0,0 +1 @@ +nosuchfile.h5: unable to open file diff --git a/tools/test/h5ls/errfiles/textlinksrc-nodangle-1.err b/tools/test/h5ls/errfiles/textlinksrc-nodangle-1.err new file mode 100644 index 0000000..8991fc1 --- /dev/null +++ b/tools/test/h5ls/errfiles/textlinksrc-nodangle-1.err @@ -0,0 +1,2 @@ +Error: --no-dangling-links must be used along with --follow-symlinks option! + diff --git a/tools/test/h5ls/errfiles/tgroup-1.err b/tools/test/h5ls/errfiles/tgroup-1.err new file mode 100644 index 0000000..ba4cf07 --- /dev/null +++ b/tools/test/h5ls/errfiles/tgroup-1.err @@ -0,0 +1,2 @@ +Error: 'recursive' option not compatible with 'group info' option! + diff --git a/tools/test/h5ls/testh5ls.sh.in b/tools/test/h5ls/testh5ls.sh.in index 8c6551b..353f1bb 100644 --- a/tools/test/h5ls/testh5ls.sh.in +++ b/tools/test/h5ls/testh5ls.sh.in @@ -53,6 +53,7 @@ SRC_H5REPACK_TESTFILES="$SRC_TOOLS/test/h5repack/testfiles" SRC_H5JAM_TESTFILES="$SRC_TOOLS/test/h5jam/testfiles" SRC_H5STAT_TESTFILES="$SRC_TOOLS/test/h5stat/testfiles" SRC_H5IMPORT_TESTFILES="$SRC_TOOLS/test/h5import/testfiles" +SRC_H5LS_ERRFILES="$SRC_TOOLS/test/h5ls/errfiles" TESTDIR=./testfiles test -d $TESTDIR || mkdir $TESTDIR @@ -93,6 +94,12 @@ $SRC_H5LS_TESTFILES/tvldtypes1.h5 $SRC_H5LS_TESTFILES/tdset_idx.h5 " +LIST_ERROR_TEST_FILES=" +$SRC_H5LS_ERRFILES/nosuchfile.err +$SRC_H5LS_ERRFILES/textlinksrc-nodangle-1.err +$SRC_H5LS_ERRFILES/tgroup-1.err +" + LIST_OTHER_TEST_FILES=" $SRC_H5LS_TESTFILES/help-1.ls $SRC_H5LS_TESTFILES/help-2.ls @@ -228,8 +235,9 @@ TESTING() { # $2 and on -- argument for the h5ls tool TOOLTEST() { expect="$TESTDIR/$1" + expect_err="$TESTDIR/`basename $1 .ls`.err" actual="$TESTDIR/`basename $1 .ls`.out" - actual_err="$TESTDIR/`basename $1 .ls`.err" + actual_err="$TESTDIR/`basename $1 .ls`.out.err" actual_sav=${actual}-sav actual_err_sav=${actual_err}-sav shift @@ -251,7 +259,6 @@ TOOLTEST() { STDOUT_FILTER $actual cp $actual_err $actual_err_sav STDERR_FILTER $actual_err - cat $actual_err >> $actual if [ $h5haveexitcode = 'yes' -a $exitcode -ne $retvalexpect ]; then echo "*FAILED*" nerrors="`expr $nerrors + 1`" diff --git a/tools/test/h5repack/CMakeTests.cmake b/tools/test/h5repack/CMakeTests.cmake index 3ee5e27..c2a2be7 100644 --- a/tools/test/h5repack/CMakeTests.cmake +++ b/tools/test/h5repack/CMakeTests.cmake @@ -16,39 +16,6 @@ ############################################################################## ############################################################################## - if (HDF5_TEST_VFD) - set (VFD_LIST - sec2 - stdio - core - split - multi - family - ) - - if (DIRECT_VFD) - set (VFD_LIST ${VFD_LIST} direct) - endif () - - macro (ADD_VFD_TEST vfdname resultcode) - add_test ( - NAME H5REPACK-VFD-${vfdname}-h5repacktest - COMMAND "${CMAKE_COMMAND}" - -D "TEST_PROGRAM=$<TARGET_FILE:h5repacktest>" - -D "TEST_ARGS:STRING=" - -D "TEST_VFD:STRING=${vfdname}" - -D "TEST_EXPECT=${resultcode}" - -D "TEST_OUTPUT=h5repacktest" - -D "TEST_FOLDER=${PROJECT_BINARY_DIR}" - -P "${HDF_RESOURCES_DIR}/vfdTest.cmake" - ) - if (NOT "${last_test}" STREQUAL "") - set_tests_properties (H5REPACK-VFD-${vfdname}-h5repacktest PROPERTIES DEPENDS ${last_test}) - endif () - set (last_test "H5REPACK-VFD-${vfdname}-h5repacktest") - endmacro () - endif () - # -------------------------------------------------------------------- # Copy all the HDF5 files from the source directory into the test directory # -------------------------------------------------------------------- @@ -377,7 +344,8 @@ -D "TEST_OUTPUT=${resultfile}-${testname}.out" -D "TEST_EXPECT=${resultcode}" -D "TEST_MASK_ERROR=true" - -D "TEST_REFERENCE=${resultfile}-${testname}.tst" + -D "TEST_REFERENCE=${resultfile}.mty" + -D "TEST_ERRREF=${resultfile}-${testname}.tst" -P "${HDF_RESOURCES_EXT_DIR}/runTest.cmake" ) set_tests_properties (H5REPACK_MASK-${testname} PROPERTIES DEPENDS H5REPACK_MASK-${testname}-clear-objects) @@ -1458,9 +1426,12 @@ if (BUILD_SHARED_LIBS) ADD_H5_UD_TEST (plugin_zero 0 h5repack_layout.h5 -v -f UD=250,0,0) endif () - if (HDF5_TEST_VFD) - # Run test with different Virtual File Driver - foreach (vfd ${VFD_LIST}) - ADD_VFD_TEST (${vfd} 0) - endforeach () - endif () +############################################################################## +############################################################################## +### V F D T E S T S ### +############################################################################## +############################################################################## + +if (HDF5_TEST_VFD) + include (CMakeVFDTests.cmake) +endif () diff --git a/tools/test/h5repack/CMakeVFDTests.cmake b/tools/test/h5repack/CMakeVFDTests.cmake new file mode 100644 index 0000000..2042f31 --- /dev/null +++ b/tools/test/h5repack/CMakeVFDTests.cmake @@ -0,0 +1,65 @@ +# +# 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 COPYING file, which can be found at the root of the source code +# distribution tree, or in https://support.hdfgroup.org/ftp/HDF5/releases. +# If you do not have access to either file, you may request a copy from +# help@hdfgroup.org. +# + +############################################################################## +############################################################################## +### T E S T I N G ### +############################################################################## +############################################################################## + + set (VFD_LIST + sec2 + stdio + core + split + multi + family + ) + + if (DIRECT_VFD) + set (VFD_LIST ${VFD_LIST} direct) + endif () + +############################################################################## +############################################################################## +### T H E T E S T S M A C R O S ### +############################################################################## +############################################################################## + + macro (ADD_VFD_TEST vfdname resultcode) + add_test ( + NAME H5REPACK-VFD-${vfdname}-h5repacktest + COMMAND "${CMAKE_COMMAND}" + -D "TEST_PROGRAM=$<TARGET_FILE:h5repacktest>" + -D "TEST_ARGS:STRING=" + -D "TEST_VFD:STRING=${vfdname}" + -D "TEST_EXPECT=${resultcode}" + -D "TEST_OUTPUT=h5repacktest" + -D "TEST_FOLDER=${PROJECT_BINARY_DIR}" + -P "${HDF_RESOURCES_DIR}/vfdTest.cmake" + ) + if (NOT "${last_test}" STREQUAL "") + set_tests_properties (H5REPACK-VFD-${vfdname}-h5repacktest PROPERTIES DEPENDS ${last_test}) + endif () + set (last_test "H5REPACK-VFD-${vfdname}-h5repacktest") + endmacro () + +############################################################################## +############################################################################## +### T H E T E S T S ### +############################################################################## +############################################################################## + + # Run test with different Virtual File Driver + foreach (vfd ${VFD_LIST}) + ADD_VFD_TEST (${vfd} 0) + endforeach () diff --git a/tools/test/h5repack/testfiles/h5repack_layout.h5-dset2_chunk_20x10-errstk.tst b/tools/test/h5repack/testfiles/h5repack_layout.h5-dset2_chunk_20x10-errstk.tst index 6009723..4e69148 100644 --- a/tools/test/h5repack/testfiles/h5repack_layout.h5-dset2_chunk_20x10-errstk.tst +++ b/tools/test/h5repack/testfiles/h5repack_layout.h5-dset2_chunk_20x10-errstk.tst @@ -2,40 +2,43 @@ HDF5-DIAG: Error detected in HDF5 (version (number)) thread (IDs): #000: (file name) line (number) in H5Dcreate2(): unable to create dataset major: Dataset minor: Unable to initialize object - #001: (file name) line (number) in H5VL_dataset_create(): create failed + #001: (file name) line (number) in H5VL_dataset_create(): dataset create failed major: Virtual Object Layer - minor: Unable to initialize object - #002: (file name) line (number) in H5VL_native_dataset_create(): unable to create dataset + minor: Unable to create file + #002: (file name) line (number) in H5VL__dataset_create(): dataset create failed + major: Virtual Object Layer + minor: Unable to create file + #003: (file name) line (number) in H5VL__native_dataset_create(): unable to create dataset major: Dataset minor: Unable to initialize object - #003: (file name) line (number) in H5D__create_named(): unable to create and link to dataset + #004: (file name) line (number) in H5D__create_named(): unable to create and link to dataset major: Dataset minor: Unable to initialize object - #004: (file name) line (number) in H5L_link_object(): unable to create new link to object + #005: (file name) line (number) in H5L_link_object(): unable to create new link to object major: Links minor: Unable to initialize object - #005: (file name) line (number) in H5L__create_real(): can't insert link + #006: (file name) line (number) in H5L__create_real(): can't insert link major: Links minor: Unable to insert object - #006: (file name) line (number) in H5G_traverse(): internal path traversal failed + #007: (file name) line (number) in H5G_traverse(): internal path traversal failed major: Symbol table minor: Object not found - #007: (file name) line (number) in H5G__traverse_real(): traversal operator failed + #008: (file name) line (number) in H5G__traverse_real(): traversal operator failed major: Symbol table minor: Callback failed - #008: (file name) line (number) in H5L__link_cb(): unable to create object + #009: (file name) line (number) in H5L__link_cb(): unable to create object major: Links minor: Unable to initialize object - #009: (file name) line (number) in H5O_obj_create(): unable to open object + #010: (file name) line (number) in H5O_obj_create(): unable to open object major: Object header minor: Can't open object - #010: (file name) line (number) in H5O__dset_create(): unable to create dataset + #011: (file name) line (number) in H5O__dset_create(): unable to create dataset major: Dataset minor: Unable to initialize object - #011: (file name) line (number) in H5D__create(): unable to construct layout information + #012: (file name) line (number) in H5D__create(): unable to construct layout information major: Dataset minor: Unable to initialize object - #012: (file name) line (number) in H5D__chunk_construct(): dimensionality of chunks doesn't match the dataspace + #013: (file name) line (number) in H5D__chunk_construct(): dimensionality of chunks doesn't match the dataspace major: Dataset minor: Bad value H5tools-DIAG: Error detected in HDF5:tools (version (number)) thread (IDs): diff --git a/tools/test/h5stat/CMakeTests.cmake b/tools/test/h5stat/CMakeTests.cmake index bd55ac1..ec8c9b1 100644 --- a/tools/test/h5stat/CMakeTests.cmake +++ b/tools/test/h5stat/CMakeTests.cmake @@ -39,23 +39,30 @@ h5stat_newgrat h5stat_newgrat-UG h5stat_newgrat-UA - h5stat_err1_links h5stat_idx h5stat_links1 h5stat_links2 h5stat_links3 h5stat_links4 h5stat_links5 - h5stat_err1_dims h5stat_dims1 h5stat_dims2 - h5stat_err1_numattrs - h5stat_err2_numattrs h5stat_numattrs1 h5stat_numattrs2 h5stat_numattrs3 h5stat_numattrs4 ) + set (HDF5_REFERENCE_ERR_FILES + h5stat_err_refcount + h5stat_err_old_layout + h5stat_err_old_fill + h5stat_err1_dims + h5stat_err1_links + h5stat_err1_numattrs + h5stat_err2_numattrs + h5stat_notexist + h5stat_nofile + ) set (HDF5_REFERENCE_TEST_FILES h5stat_err_refcount.h5 h5stat_err_old_layout.h5 @@ -71,6 +78,10 @@ HDFTEST_COPY_FILE("${HDF5_TOOLS_TEST_H5STAT_SOURCE_DIR}/testfiles/${ddl_file}.ddl" "${PROJECT_BINARY_DIR}/${ddl_file}.ddl" "h5stat_files") endforeach () + foreach (h5_file ${HDF5_REFERENCE_ERR_FILES}) + HDFTEST_COPY_FILE("${HDF5_TOOLS_TEST_H5STAT_SOURCE_DIR}/testfiles/${h5_file}.err" "${PROJECT_BINARY_DIR}/${h5_file}.err" "h5stat_files") + endforeach () + foreach (h5_file ${HDF5_REFERENCE_TEST_FILES}) HDFTEST_COPY_FILE("${HDF5_TOOLS_TEST_H5STAT_SOURCE_DIR}/testfiles/${h5_file}" "${PROJECT_BINARY_DIR}/${h5_file}" "h5stat_files") endforeach () @@ -118,6 +129,43 @@ endif () endmacro () + macro (ADD_H5_ERR_TEST resultfile resultcode) + # If using memchecker add tests without using scripts + if (HDF5_ENABLE_USING_MEMCHECKER) + add_test (NAME H5STAT-${resultfile} COMMAND $<TARGET_FILE:h5stat> ${ARGN}) + if (NOT "${resultcode}" STREQUAL "0") + set_tests_properties (H5STAT-${resultfile} PROPERTIES WILL_FAIL "true") + endif () + if (NOT "${last_test}" STREQUAL "") + set_tests_properties (H5STAT-${resultfile} PROPERTIES DEPENDS ${last_test}) + endif () + else (HDF5_ENABLE_USING_MEMCHECKER) + add_test ( + NAME H5STAT-${resultfile}-clear-objects + COMMAND ${CMAKE_COMMAND} + -E remove + ${resultfile}.out + ${resultfile}.out.err + ) + if (NOT "${last_test}" STREQUAL "") + set_tests_properties (H5STAT-${resultfile}-clear-objects PROPERTIES DEPENDS ${last_test}) + endif () + add_test ( + NAME H5STAT-${resultfile} + COMMAND "${CMAKE_COMMAND}" + -D "TEST_PROGRAM=$<TARGET_FILE:h5stat>" + -D "TEST_ARGS=${ARGN}" + -D "TEST_FOLDER=${PROJECT_BINARY_DIR}" + -D "TEST_OUTPUT=${resultfile}.out" + -D "TEST_EXPECT=${resultcode}" + -D "TEST_REFERENCE=${resultfile}.mty" + -D "TEST_ERRREF=${resultfile}.err" + -P "${HDF_RESOURCES_EXT_DIR}/runTest.cmake" + ) + set_tests_properties (H5STAT-${resultfile} PROPERTIES DEPENDS H5STAT-${resultfile}-clear-objects) + endif () + endmacro () + ############################################################################## ############################################################################## ### T H E T E S T S ### @@ -173,7 +221,7 @@ # -g -l 8 # --links=8 # --links=20 -g - ADD_H5_TEST (h5stat_err1_links 1 -l 0 h5stat_threshold.h5) + ADD_H5_ERR_TEST (h5stat_err1_links 1 -l 0 h5stat_threshold.h5) ADD_H5_TEST (h5stat_links1 0 -g -l 8 h5stat_threshold.h5) ADD_H5_TEST (h5stat_links2 0 --links=8 h5stat_threshold.h5) ADD_H5_TEST (h5stat_links3 0 --links=20 -g h5stat_threshold.h5) @@ -188,7 +236,7 @@ # -d --dims=-1 (incorrect threshold value) # -gd -m 5 # -d --di=15 - ADD_H5_TEST (h5stat_err1_dims 1 -d --dims=-1 h5stat_threshold.h5) + ADD_H5_ERR_TEST (h5stat_err1_dims 1 -d --dims=-1 h5stat_threshold.h5) ADD_H5_TEST (h5stat_dims1 0 -gd -m 5 h5stat_threshold.h5) ADD_H5_TEST (h5stat_dims2 0 -d --di=15 h5stat_threshold.h5) # @@ -198,8 +246,8 @@ # -AS -a 10 # -a 1 # -A --numattrs=25 - ADD_H5_TEST (h5stat_err1_numattrs 1 -a -2 h5stat_threshold.h5) - ADD_H5_TEST (h5stat_err2_numattrs 1 --numattrs h5stat_threshold.h5) + ADD_H5_ERR_TEST (h5stat_err1_numattrs 1 -a -2 h5stat_threshold.h5) + ADD_H5_ERR_TEST (h5stat_err2_numattrs 1 --numattrs h5stat_threshold.h5) ADD_H5_TEST (h5stat_numattrs1 0 -AS -a 10 h5stat_threshold.h5) ADD_H5_TEST (h5stat_numattrs2 0 -a 1 h5stat_threshold.h5) ADD_H5_TEST (h5stat_numattrs3 0 -A --numattrs=25 h5stat_threshold.h5) diff --git a/tools/test/h5stat/testfiles/h5stat_err1_dims.ddl b/tools/test/h5stat/testfiles/h5stat_err1_dims.err index 86d375b..86d375b 100644 --- a/tools/test/h5stat/testfiles/h5stat_err1_dims.ddl +++ b/tools/test/h5stat/testfiles/h5stat_err1_dims.err diff --git a/tools/test/h5stat/testfiles/h5stat_err1_links.ddl b/tools/test/h5stat/testfiles/h5stat_err1_links.err index d43207c..d43207c 100644 --- a/tools/test/h5stat/testfiles/h5stat_err1_links.ddl +++ b/tools/test/h5stat/testfiles/h5stat_err1_links.err diff --git a/tools/test/h5stat/testfiles/h5stat_err2_numattrs.ddl b/tools/test/h5stat/testfiles/h5stat_err1_numattrs.err index 01b6c18..01b6c18 100644 --- a/tools/test/h5stat/testfiles/h5stat_err2_numattrs.ddl +++ b/tools/test/h5stat/testfiles/h5stat_err1_numattrs.err diff --git a/tools/test/h5stat/testfiles/h5stat_err1_numattrs.ddl b/tools/test/h5stat/testfiles/h5stat_err2_numattrs.err index 01b6c18..01b6c18 100644 --- a/tools/test/h5stat/testfiles/h5stat_err1_numattrs.ddl +++ b/tools/test/h5stat/testfiles/h5stat_err2_numattrs.err diff --git a/tools/test/h5stat/testfiles/h5stat_err_old_fill.ddl b/tools/test/h5stat/testfiles/h5stat_err_old_fill.ddl index e751b7f..5cc1e32 100644 --- a/tools/test/h5stat/testfiles/h5stat_err_old_fill.ddl +++ b/tools/test/h5stat/testfiles/h5stat_err_old_fill.ddl @@ -1,2 +1 @@ Filename: h5stat_err_old_fill.h5 -h5stat error: unable to traverse objects/links in file "h5stat_err_old_fill.h5" diff --git a/tools/test/h5stat/testfiles/h5stat_err_old_fill.err b/tools/test/h5stat/testfiles/h5stat_err_old_fill.err new file mode 100644 index 0000000..8b886d2 --- /dev/null +++ b/tools/test/h5stat/testfiles/h5stat_err_old_fill.err @@ -0,0 +1 @@ +h5stat error: unable to traverse objects/links in file "h5stat_err_old_fill.h5" diff --git a/tools/test/h5stat/testfiles/h5stat_err_old_layout.ddl b/tools/test/h5stat/testfiles/h5stat_err_old_layout.ddl index a3e27e2..112190c 100644 --- a/tools/test/h5stat/testfiles/h5stat_err_old_layout.ddl +++ b/tools/test/h5stat/testfiles/h5stat_err_old_layout.ddl @@ -1,2 +1 @@ Filename: h5stat_err_old_layout.h5 -h5stat error: unable to traverse objects/links in file "h5stat_err_old_layout.h5" diff --git a/tools/test/h5stat/testfiles/h5stat_err_old_layout.err b/tools/test/h5stat/testfiles/h5stat_err_old_layout.err new file mode 100644 index 0000000..7aa2fa7 --- /dev/null +++ b/tools/test/h5stat/testfiles/h5stat_err_old_layout.err @@ -0,0 +1 @@ +h5stat error: unable to traverse objects/links in file "h5stat_err_old_layout.h5" diff --git a/tools/test/h5stat/testfiles/h5stat_err_refcount.ddl b/tools/test/h5stat/testfiles/h5stat_err_refcount.ddl index 1f1b491..41e533e 100644 --- a/tools/test/h5stat/testfiles/h5stat_err_refcount.ddl +++ b/tools/test/h5stat/testfiles/h5stat_err_refcount.ddl @@ -1,2 +1 @@ Filename: h5stat_err_refcount.h5 -h5stat error: unable to traverse objects/links in file "h5stat_err_refcount.h5" diff --git a/tools/test/h5stat/testfiles/h5stat_err_refcount.err b/tools/test/h5stat/testfiles/h5stat_err_refcount.err new file mode 100644 index 0000000..d176996 --- /dev/null +++ b/tools/test/h5stat/testfiles/h5stat_err_refcount.err @@ -0,0 +1 @@ +h5stat error: unable to traverse objects/links in file "h5stat_err_refcount.h5" diff --git a/tools/test/h5stat/testfiles/h5stat_nofile.ddl b/tools/test/h5stat/testfiles/h5stat_nofile.ddl index 7171320..01e39af 100644 --- a/tools/test/h5stat/testfiles/h5stat_nofile.ddl +++ b/tools/test/h5stat/testfiles/h5stat_nofile.ddl @@ -23,4 +23,3 @@ Usage: h5stat [OPTIONS] file -s, --freespace Print free space information -S, --summary Print summary of file space information --enable-error-stack Prints messages from the HDF5 error stack as they occur -h5stat error: missing file name diff --git a/tools/test/h5stat/testfiles/h5stat_nofile.err b/tools/test/h5stat/testfiles/h5stat_nofile.err new file mode 100644 index 0000000..3b7e979 --- /dev/null +++ b/tools/test/h5stat/testfiles/h5stat_nofile.err @@ -0,0 +1 @@ +h5stat error: missing file name diff --git a/tools/test/h5stat/testfiles/h5stat_notexist.ddl b/tools/test/h5stat/testfiles/h5stat_notexist.ddl index cc25e43..7f71941 100644 --- a/tools/test/h5stat/testfiles/h5stat_notexist.ddl +++ b/tools/test/h5stat/testfiles/h5stat_notexist.ddl @@ -1,2 +1 @@ Filename: notexist.h5 -h5stat error: unable to open file "notexist.h5" diff --git a/tools/test/h5stat/testfiles/h5stat_notexist.err b/tools/test/h5stat/testfiles/h5stat_notexist.err new file mode 100644 index 0000000..c1d9e54 --- /dev/null +++ b/tools/test/h5stat/testfiles/h5stat_notexist.err @@ -0,0 +1 @@ +h5stat error: unable to open file "notexist.h5" diff --git a/tools/test/h5stat/testh5stat.sh.in b/tools/test/h5stat/testh5stat.sh.in index 0a5127f..69b856e 100644 --- a/tools/test/h5stat/testh5stat.sh.in +++ b/tools/test/h5stat/testh5stat.sh.in @@ -79,6 +79,18 @@ $SRC_H5STAT_TESTFILES/h5stat_idx.h5 $SRC_H5STAT_TESTFILES/h5stat_threshold.h5 " +LIST_ERR_TEST_FILES=" +$SRC_H5STAT_TESTFILES/h5stat_err_refcount.err +$SRC_H5STAT_TESTFILES/h5stat_err_old_layout.err +$SRC_H5STAT_TESTFILES/h5stat_err_old_fill.err +$SRC_H5STAT_TESTFILES/h5stat_err1_links.err +$SRC_H5STAT_TESTFILES/h5stat_err1_dims.err +$SRC_H5STAT_TESTFILES/h5stat_err1_numattrs.err +$SRC_H5STAT_TESTFILES/h5stat_err2_numattrs.err +$SRC_H5STAT_TESTFILES/h5stat_notexist.err +$SRC_H5STAT_TESTFILES/h5stat_nofile.err +" + LIST_OTHER_TEST_FILES=" $SRC_H5STAT_TESTFILES/h5stat_err_refcount.ddl $SRC_H5STAT_TESTFILES/h5stat_err_old_layout.ddl @@ -100,17 +112,13 @@ $SRC_H5STAT_TESTFILES/h5stat_newgrat.ddl $SRC_H5STAT_TESTFILES/h5stat_newgrat-UG.ddl $SRC_H5STAT_TESTFILES/h5stat_newgrat-UA.ddl $SRC_H5STAT_TESTFILES/h5stat_idx.ddl -$SRC_H5STAT_TESTFILES/h5stat_err1_links.ddl $SRC_H5STAT_TESTFILES/h5stat_links1.ddl $SRC_H5STAT_TESTFILES/h5stat_links2.ddl $SRC_H5STAT_TESTFILES/h5stat_links3.ddl $SRC_H5STAT_TESTFILES/h5stat_links4.ddl $SRC_H5STAT_TESTFILES/h5stat_links5.ddl -$SRC_H5STAT_TESTFILES/h5stat_err1_dims.ddl $SRC_H5STAT_TESTFILES/h5stat_dims1.ddl $SRC_H5STAT_TESTFILES/h5stat_dims2.ddl -$SRC_H5STAT_TESTFILES/h5stat_err1_numattrs.ddl -$SRC_H5STAT_TESTFILES/h5stat_err2_numattrs.ddl $SRC_H5STAT_TESTFILES/h5stat_numattrs1.ddl $SRC_H5STAT_TESTFILES/h5stat_numattrs2.ddl $SRC_H5STAT_TESTFILES/h5stat_numattrs3.ddl @@ -120,7 +128,7 @@ $SRC_H5STAT_TESTFILES/h5stat_numattrs4.ddl # # copy test files and expected output files from source dirs to test dir # -COPY_TESTFILES="$LIST_HDF5_TEST_FILES $LIST_OTHER_TEST_FILES" +COPY_TESTFILES="$LIST_HDF5_TEST_FILES $LIST_ERR_TEST_FILES $LIST_OTHER_TEST_FILES" COPY_TESTFILES_TO_TESTDIR() { @@ -184,8 +192,9 @@ TESTING() { # TOOLTEST() { expect="$TESTDIR/$1" + expect_err="$TESTDIR/`basename $1 .ddl`.err" actual="$TESTDIR/`basename $1 .ddl`.out" - actual_err="$TESTDIR/`basename $1 .ddl`.err" + actual_err="$TESTDIR/`basename $1 .ddl`.out.err" actual_sav=${actual}-sav actual_err_sav=${actual_err}-sav shift @@ -202,14 +211,17 @@ TOOLTEST() { STDOUT_FILTER $actual cp $actual_err $actual_err_sav STDERR_FILTER $actual_err - cat $actual_err >> $actual if [ ! -f $expect ]; then - # Create the expect file if it doesn't yet exist. - echo " CREATED" - cp $actual $expect - echo " Expected result (*.ddl) missing" - nerrors="`expr $nerrors + 1`" + # Compare error files if the expect file doesn't exist. + if $CMP $expect_err $actual_err; then + echo " PASSED" + else + echo "*FAILED*" + echo " Expected result (*.err) differs from actual result (*.out.err)" + nerrors="`expr $nerrors + 1`" + test yes = "$verbose" && $DIFF $expect_err $actual_err |sed 's/^/ /' + fi elif $CMP $expect $actual; then echo " PASSED" else diff --git a/tools/test/misc/CMakeTestsClear.cmake b/tools/test/misc/CMakeTestsClear.cmake index a51d0e9..c46ac59 100644 --- a/tools/test/misc/CMakeTestsClear.cmake +++ b/tools/test/misc/CMakeTestsClear.cmake @@ -49,8 +49,6 @@ h5clear_missing_file.ddl h5clear_noclose_after_size.ddl h5clear_noclose_before_size.ddl - h5clear_no_mdc_image.ddl - h5clear_open_fail.ddl h5clear_status_noclose_after_size.ddl h5clear_usage.ddl h5clear_user_equal_after_size.ddl @@ -60,10 +58,17 @@ h5clear_user_less_after_size.ddl h5clear_user_less_before_size.ddl ) + set (HDF5_REFERENCE_ERR_FILES + h5clear_no_mdc_image.err + h5clear_open_fail.err + ) foreach (h5_file ${HDF5_TEST_FILES} ${HDF5_SEC2_TEST_FILES} ${HDF5_REFERENCE_TEST_FILES}) HDFTEST_COPY_FILE("${PROJECT_SOURCE_DIR}/testfiles/${h5_file}" "${PROJECT_BINARY_DIR}/testfiles/${h5_file}" "h5clear_files") endforeach () + foreach (h5_file ${HDF5_REFERENCE_ERR_FILES}) + HDFTEST_COPY_FILE("${PROJECT_SOURCE_DIR}/testfiles/${h5_file}" "${PROJECT_BINARY_DIR}/testfiles/${h5_file}" "h5clear_files") + endforeach () # make second copy of h5clear_sec2.h5 foreach (h5_file ${HDF5_SEC2_TEST_FILES}) HDFTEST_COPY_FILE("${PROJECT_SOURCE_DIR}/testfiles/${h5_file}" "${PROJECT_BINARY_DIR}/testfiles/orig_${h5_file}" "h5clear_files") @@ -108,6 +113,35 @@ endif () endmacro () + macro (ADD_H5_ERR_CMP testname resultfile resultcode) + if (NOT HDF5_ENABLE_USING_MEMCHECKER) + add_test ( + NAME H5CLEAR_CMP-${testname}-clear-objects + COMMAND ${CMAKE_COMMAND} + -E remove + testfiles/${testname}.out + testfiles/${testname}.out.err + ) + if (NOT "${last_test}" STREQUAL "") + set_tests_properties (H5CLEAR_CMP-${testname}-clear-objects PROPERTIES DEPENDS ${last_test}) + endif () + add_test ( + NAME H5CLEAR_CMP-${testname} + COMMAND "${CMAKE_COMMAND}" + -D "TEST_PROGRAM=$<TARGET_FILE:h5clear>" + -D "TEST_ARGS:STRING=${ARGN}" + -D "TEST_FOLDER=${PROJECT_BINARY_DIR}/testfiles" + -D "TEST_OUTPUT=${testname}.out" + -D "TEST_EXPECT=${resultcode}" + -D "TEST_REFERENCE=${resultfile}.mty" + -D "TEST_ERRREF=${resultfile}.err" + -P "${HDF_RESOURCES_EXT_DIR}/runTest.cmake" + ) + set_tests_properties (H5CLEAR_CMP-${testname} PROPERTIES DEPENDS H5CLEAR_CMP-${testname}-clear-objects) + set (last_test "H5CLEAR_CMP-${testname}") + endif () + endmacro () + macro (ADD_H5_CMP_WITH_COPY testname resultcode resultfile testfile) if (NOT HDF5_ENABLE_USING_MEMCHECKER) add_test ( @@ -144,6 +178,43 @@ endif () endmacro () + macro (ADD_H5_ERR_CMP_WITH_COPY testname resultcode resultfile testfile) + if (NOT HDF5_ENABLE_USING_MEMCHECKER) + add_test ( + NAME H5CLEAR_CMP-${testname}-clear-objects + COMMAND ${CMAKE_COMMAND} + -E remove + testfiles/${testname}.out + testfiles/${testname}.out.err + testfiles/${testfile} + ) + if (NOT "${last_test}" STREQUAL "") + set_tests_properties (H5CLEAR_CMP-${testname}-clear-objects PROPERTIES DEPENDS ${last_test}) + endif () + add_test ( + NAME H5CLEAR_CMP-copy_${testname} + COMMAND ${CMAKE_COMMAND} + -E copy_if_different + "${PROJECT_SOURCE_DIR}/testfiles/${testfile}" "${PROJECT_BINARY_DIR}/testfiles/${testfile}" + ) + set_tests_properties (H5CLEAR_CMP-copy_${testname} PROPERTIES DEPENDS H5CLEAR_CMP-${testname}-clear-objects) + add_test ( + NAME H5CLEAR_CMP-${testname} + COMMAND "${CMAKE_COMMAND}" + -D "TEST_PROGRAM=$<TARGET_FILE:h5clear>" + -D "TEST_ARGS:STRING=${ARGN};${testfile}" + -D "TEST_FOLDER=${PROJECT_BINARY_DIR}/testfiles" + -D "TEST_OUTPUT=${testname}.out" + -D "TEST_EXPECT=${resultcode}" + -D "TEST_REFERENCE=${resultfile}.mty" + -D "TEST_ERRREF=${resultfile}.err" + -P "${HDF_RESOURCES_EXT_DIR}/runTest.cmake" + ) + set_tests_properties (H5CLEAR_CMP-${testname} PROPERTIES DEPENDS H5CLEAR_CMP-copy_${testname}) + set (last_test "H5CLEAR_CMP-${testname}") + endif () + endmacro () + macro (ADD_H5_RETTEST testname resultcode) if (NOT HDF5_ENABLE_USING_MEMCHECKER) add_test ( @@ -347,11 +418,11 @@ endif() ADD_H5_CMP (h5clr_usage_junk h5clear_usage 1 "" junk.h5) ADD_H5_CMP (h5clr_usage_none h5clear_usage 1 "" orig_h5clear_sec2_v3.h5) ADD_H5_CMP (h5clr_missing_file_m h5clear_missing_file 1 "-m") - ADD_H5_CMP (h5clr_open_fail_s h5clear_open_fail 1 "-s" junk.h5) + ADD_H5_ERR_CMP (h5clr_open_fail_s h5clear_open_fail 1 "-s" junk.h5) ADD_H5_CMP (h5clr_missing_file_ms h5clear_missing_file 1 "-m" "-s") - ADD_H5_CMP (h5clr_open_fail_ms h5clear_open_fail 1 "-m" "-s" junk.h5) - ADD_H5_CMP (h5clr_no_mdc_image_m h5clear_no_mdc_image 0 "-m" orig_h5clear_sec2_v2.h5) - ADD_H5_CMP (h5clr_no_mdc_image_ms h5clear_no_mdc_image 0 "-s" "-m" orig_h5clear_sec2_v0.h5) + ADD_H5_ERR_CMP (h5clr_open_fail_ms h5clear_open_fail 1 "-m" "-s" junk.h5) + ADD_H5_ERR_CMP (h5clr_no_mdc_image_m h5clear_no_mdc_image 0 "-m" orig_h5clear_sec2_v2.h5) + ADD_H5_ERR_CMP (h5clr_no_mdc_image_ms h5clear_no_mdc_image 0 "-s" "-m" orig_h5clear_sec2_v0.h5) # # # @@ -382,8 +453,8 @@ endif() # # # h5clear_mdc_image.h5 already has cache image removed earlier, verify the expected warning from h5clear: - ADD_H5_CMP (h5clr_mdc_image_m h5clear_no_mdc_image 0 "-m" mod_h5clear_mdc_image.h5) - ADD_H5_CMP (h5clr_mdc_image_sm h5clear_no_mdc_image 0 "-s" "-m" mod_h5clear_mdc_image2.h5) + ADD_H5_ERR_CMP (h5clr_mdc_image_m h5clear_no_mdc_image 0 "-m" mod_h5clear_mdc_image.h5) + ADD_H5_ERR_CMP (h5clr_mdc_image_sm h5clear_no_mdc_image 0 "-s" "-m" mod_h5clear_mdc_image2.h5) # # # @@ -404,7 +475,7 @@ endif() # "h5clear -s --increment=0 h5clear_status_noclose.h5" (clear status_flag, EOA = MAX(EOA, EOF) + 0) # (no output, check exit code) # "h5clear --filesize h5clear_status_noclose.h5" (print EOA/EOF after the last action) - ADD_H5_CMP_WITH_COPY (h5clr_open_fail_nc_s 1 h5clear_open_fail h5clear_status_noclose.h5 "--filesize") + ADD_H5_ERR_CMP_WITH_COPY (h5clr_open_fail_nc_s 1 h5clear_open_fail h5clear_status_noclose.h5 "--filesize") ADD_H5_RETTEST (h5clr_mdc_image_nc "false" "-s" "--increment=0" h5clear_status_noclose.h5) ADD_H5_CMP (h5clr_no_mdc_image_nc_m h5clear_status_noclose_after_size 0 "--filesize" h5clear_status_noclose.h5) # diff --git a/tools/test/misc/testfiles/h5clear_missing_file.ddl b/tools/test/misc/testfiles/h5clear_missing_file.ddl index 13eb2c9..32dd549 100644 --- a/tools/test/misc/testfiles/h5clear_missing_file.ddl +++ b/tools/test/misc/testfiles/h5clear_missing_file.ddl @@ -20,4 +20,3 @@ h5clear --increment file_name h5clear --increment=512 file_name Set the EOA to the maximum of (EOA, EOF) + 512 for the file <file_name>. -h5clear error: missing file name diff --git a/tools/test/misc/testfiles/h5clear_missing_file.err b/tools/test/misc/testfiles/h5clear_missing_file.err new file mode 100644 index 0000000..ea21b76 --- /dev/null +++ b/tools/test/misc/testfiles/h5clear_missing_file.err @@ -0,0 +1 @@ +h5clear error: missing file name diff --git a/tools/test/misc/testfiles/h5clear_no_mdc_image.ddl b/tools/test/misc/testfiles/h5clear_no_mdc_image.err index f5acd71..f5acd71 100644 --- a/tools/test/misc/testfiles/h5clear_no_mdc_image.ddl +++ b/tools/test/misc/testfiles/h5clear_no_mdc_image.err diff --git a/tools/test/misc/testfiles/h5clear_open_fail.ddl b/tools/test/misc/testfiles/h5clear_open_fail.err index 895ecd4..895ecd4 100644 --- a/tools/test/misc/testfiles/h5clear_open_fail.ddl +++ b/tools/test/misc/testfiles/h5clear_open_fail.err diff --git a/tools/test/misc/testh5clear.sh.in b/tools/test/misc/testh5clear.sh.in index 11c2ff9..3f2b32f 100644 --- a/tools/test/misc/testh5clear.sh.in +++ b/tools/test/misc/testh5clear.sh.in @@ -62,10 +62,10 @@ test -d $TESTDIR || mkdir -p $TESTDIR # copy test files and expected output files from source dirs to test dir # COPY_TESTFILES=" +$SRC_H5CLEAR_TESTFILES/h5clear_open_fail.err +$SRC_H5CLEAR_TESTFILES/h5clear_no_mdc_image.err $SRC_H5CLEAR_TESTFILES/h5clear_usage.ddl -$SRC_H5CLEAR_TESTFILES/h5clear_open_fail.ddl $SRC_H5CLEAR_TESTFILES/h5clear_missing_file.ddl -$SRC_H5CLEAR_TESTFILES/h5clear_no_mdc_image.ddl $SRC_H5CLEAR_TESTFILES/h5clear_status_noclose_after_size.ddl $SRC_H5CLEAR_TESTFILES/h5clear_noclose_before_size.ddl $SRC_H5CLEAR_TESTFILES/h5clear_noclose_after_size.ddl @@ -179,8 +179,9 @@ TOOLTEST_OUT() { expected=$5 # Prepare expected and actual output expect="$TESTDIR/$expected" + expect_err="$TESTDIR/`basename $expected .ddl`.err" actual="$TESTDIR/`basename $expected .ddl`.out" - actual_err="$TESTDIR/`basename $expected .ddl`.err" + actual_err="$TESTDIR/`basename $expected .ddl`.out.err" actual_sav=${actual}-sav actual_err_sav=${actual_err}-sav @@ -192,7 +193,6 @@ TOOLTEST_OUT() { ) >$actual 2>$actual_err cp $actual $actual_sav cp $actual_err $actual_err_sav - cat $actual_err >> $actual # Compare output COMPARE_OUT $expect $actual @@ -202,6 +202,38 @@ TOOLTEST_OUT() { $RM $actual $actual_err $actual_sav $actual_err_sav fi } +# same as TOOLTEST_OUT just compare stderr +TOOLTEST_ERR() { + fname=$1 + option1=$2 + option2=$3 + option3=$4 + expected=$5 + # Prepare expected and actual output + expect_err="$TESTDIR/$expected" + expect="$TESTDIR/`basename $expected .err`.ddl" + actual="$TESTDIR/`basename $expected .err`.out" + actual_err="$TESTDIR/`basename $expected .err`.out.err" + actual_sav=${actual}-sav + actual_err_sav=${actual_err}-sav + + # Run test. + TESTING $H5CLEAR $option1 $option2 $option3 $option4 $fname + ( + cd $TESTDIR + $RUNSERIAL $H5CLEAR_BIN $option1 $option2 $option3 $option4 $fname + ) >$actual 2>$actual_err + cp $actual $actual_sav + cp $actual_err $actual_err_sav + + # Compare output + COMPARE_OUT $expect_err $actual_err + + # Clean up output file + if test -z "$HDF5_NOCLEANUP"; then + $RM $actual $actual_err $actual_sav $actual_err_sav + fi +} # $1 is the filename to open # $2 is the expected return from the open/check program @@ -274,11 +306,11 @@ TOOLTEST_OUT "" "" "" "" h5clear_usage.ddl TOOLTEST_OUT junk.h5 "" "" "" h5clear_usage.ddl TOOLTEST_OUT orig_h5clear_sec2_v3.h5 "" "" "" h5clear_usage.ddl TOOLTEST_OUT "" -m "" "" h5clear_missing_file.ddl -TOOLTEST_OUT junk.h5 -s "" "" h5clear_open_fail.ddl +TOOLTEST_ERR junk.h5 -s "" "" h5clear_open_fail.err TOOLTEST_OUT "" -m -s "" h5clear_missing_file.ddl -TOOLTEST_OUT junk.h5 -m -s "" h5clear_open_fail.ddl -TOOLTEST_OUT orig_h5clear_sec2_v2.h5 -m "" "" h5clear_no_mdc_image.ddl -TOOLTEST_OUT orig_h5clear_sec2_v0.h5 -s -m "" h5clear_no_mdc_image.ddl +TOOLTEST_ERR junk.h5 -m -s "" h5clear_open_fail.err +TOOLTEST_ERR orig_h5clear_sec2_v2.h5 -m "" "" h5clear_no_mdc_image.err +TOOLTEST_ERR orig_h5clear_sec2_v0.h5 -s -m "" h5clear_no_mdc_image.err # # # The following are tests to verify the expected exit code from h5clear: @@ -308,8 +340,8 @@ TOOLTEST h5clear_sec2_v0.h5 -l -m $FAIL # # # h5clear_mdc_image.h5 already has cache image removed earlier, verify the expected warning from h5clear: -TOOLTEST_OUT mod_h5clear_mdc_image.h5 -m "" "" h5clear_no_mdc_image.ddl -TOOLTEST_OUT mod_h5clear_mdc_image.h5 -s -m "" h5clear_no_mdc_image.ddl +TOOLTEST_ERR mod_h5clear_mdc_image.h5 -m "" "" h5clear_no_mdc_image.err +TOOLTEST_ERR mod_h5clear_mdc_image.h5 -s -m "" h5clear_no_mdc_image.err # # # @@ -342,16 +374,16 @@ OPEN_CHK h5clear_sec2_v2.h5 $SUCCEED # # # -# (1) h5clear_status_noclose.h5 +# (1) h5clear_status_noclose.h5 # "h5clear --filesize h5clear_status_noclose.h5" (unable to open the file because status_flag is on) -# "h5clear -s --increment=0 h5clear_status_noclose.h5" (clear status_flag, EOA = MAX(EOA, EOF) + 0) +# "h5clear -s --increment=0 h5clear_status_noclose.h5" (clear status_flag, EOA = MAX(EOA, EOF) + 0) # (no output, check exit code) # "h5clear --filesize h5clear_status_noclose_user.h5" (print EOA/EOF after the last action) -TOOLTEST_OUT h5clear_status_noclose.h5 --filesize "" "" h5clear_open_fail.ddl +TOOLTEST_ERR h5clear_status_noclose.h5 --filesize "" "" h5clear_open_fail.err TOOLTEST h5clear_status_noclose.h5 -s --increment=0 $SUCCEED TOOLTEST_OUT h5clear_status_noclose.h5 --filesize "" "" h5clear_status_noclose_after_size.ddl # -# (2) h5clear_fsm_persist_noclose.h5 +# (2) h5clear_fsm_persist_noclose.h5 # "h5clear --filesize h5clear_fsm_persist_noclose.h5" (print EOA/EOF before the next action) # "h5clear --increment=0 h5clear_fsm_persist_noclose.h5" (EOA = MAX(EOA, EOF)) (no output, check exit code) # "h5clear --filesize h5clear_fsm_persist_noclose.h5" (print EOA/EOF after the last action) @@ -364,7 +396,7 @@ TOOLTEST_OUT h5clear_fsm_persist_noclose.h5 --filesize "" "" h5clear_noclose_aft # "h5clear --increment h5clear_fsm_persist_equal.h5" (EOA = MAX(EOA, EOF) + 1M) (no output, check exit code) # "h5clear --filesize h5clear_fsm_persist_equal.h5" (print EOA/EOF after the last action) TOOLTEST_OUT h5clear_fsm_persist_equal.h5 --filesize "" "" h5clear_equal_before_size.ddl -TOOLTEST h5clear_fsm_persist_equal.h5 --increment "" $SUCCEED +TOOLTEST h5clear_fsm_persist_equal.h5 --increment "" $SUCCEED TOOLTEST_OUT h5clear_fsm_persist_equal.h5 --filesize "" "" h5clear_equal_after_size.ddl # # (4) h5clear_fsm_persist_greater.h5 @@ -372,7 +404,7 @@ TOOLTEST_OUT h5clear_fsm_persist_equal.h5 --filesize "" "" h5clear_equal_after_s # "h5clear --increment=0 h5clear_fsm_persist_greater.h5" (EOA = MAX(EOA, EOF) + 0) (no output, check exit code) # "h5clear --filesize h5clear_fsm_persist_greater.h5" (print EOA/EOF after the last action) TOOLTEST_OUT h5clear_fsm_persist_greater.h5 --filesize "" "" h5clear_greater_before_size.ddl -TOOLTEST h5clear_fsm_persist_greater.h5 --increment=0 "" $SUCCEED +TOOLTEST h5clear_fsm_persist_greater.h5 --increment=0 "" $SUCCEED TOOLTEST_OUT h5clear_fsm_persist_greater.h5 --filesize "" "" h5clear_greater_after_size.ddl # # (5) h5clear_fsm_persist_less.h5 @@ -380,7 +412,7 @@ TOOLTEST_OUT h5clear_fsm_persist_greater.h5 --filesize "" "" h5clear_greater_aft # "h5clear --increment=200 h5clear_fsm_persist_less.h5" (EOA = MAX(EOA, EOF) + 200) (no output, check exit code) # "h5clear --filesize h5clear_fsm_persist_less.h5" (print EOA/EOF after the last action) TOOLTEST_OUT h5clear_fsm_persist_less.h5 --filesize "" "" h5clear_less_before_size.ddl -TOOLTEST h5clear_fsm_persist_less.h5 --increment=200 "" $SUCCEED +TOOLTEST h5clear_fsm_persist_less.h5 --increment=200 "" $SUCCEED TOOLTEST_OUT h5clear_fsm_persist_less.h5 --filesize "" "" h5clear_less_after_size.ddl # # (6) h5clear_fsm_persist_user_equal.h5 @@ -388,7 +420,7 @@ TOOLTEST_OUT h5clear_fsm_persist_less.h5 --filesize "" "" h5clear_less_after_siz # "h5clear --increment h5clear_fsm_persist_user_equal.h5" (EOA = MAX(EOA, EOF) + 1M) (no output, check exit code) # "h5clear --filesize h5clear_fsm_persist_user_equal.h5" (print EOA/EOF after the last action) TOOLTEST_OUT h5clear_fsm_persist_user_equal.h5 --filesize "" "" h5clear_user_equal_before_size.ddl -TOOLTEST h5clear_fsm_persist_user_equal.h5 --increment "" $SUCCEED +TOOLTEST h5clear_fsm_persist_user_equal.h5 --increment "" $SUCCEED TOOLTEST_OUT h5clear_fsm_persist_user_equal.h5 --filesize "" "" h5clear_user_equal_after_size.ddl # # (7) h5clear_fsm_persist_user_greater.h5 @@ -396,7 +428,7 @@ TOOLTEST_OUT h5clear_fsm_persist_user_equal.h5 --filesize "" "" h5clear_user_equ # "h5clear --increment=0 h5clear_fsm_persist_user_greater.h5" (EOA = MAX(EOA, EOF) + 0) (no output, check exit code) # "h5clear --filesize h5clear_fsm_persist_user_greater.h5" (print EOA/EOF after the last action) TOOLTEST_OUT h5clear_fsm_persist_user_greater.h5 --filesize "" "" h5clear_user_greater_before_size.ddl -TOOLTEST h5clear_fsm_persist_user_greater.h5 --increment=0 "" $SUCCEED +TOOLTEST h5clear_fsm_persist_user_greater.h5 --increment=0 "" $SUCCEED TOOLTEST_OUT h5clear_fsm_persist_user_greater.h5 --filesize "" "" h5clear_user_greater_after_size.ddl # # (8) h5clear_fsm_persist_user_less.h5 @@ -404,7 +436,7 @@ TOOLTEST_OUT h5clear_fsm_persist_user_greater.h5 --filesize "" "" h5clear_user_g # "h5clear --increment=200 h5clear_fsm_persist_user_less.h5" (EOA = MAX(EOA, EOF) + 200) (no output, check exit code) # "h5clear --filesize h5clear_fsm_persist_user_less.h5" (print EOA/EOF after the last action) TOOLTEST_OUT h5clear_fsm_persist_user_less.h5 --filesize "" "" h5clear_user_less_before_size.ddl -TOOLTEST h5clear_fsm_persist_user_less.h5 --increment=200 "" $SUCCEED +TOOLTEST h5clear_fsm_persist_user_less.h5 --increment=200 "" $SUCCEED TOOLTEST_OUT h5clear_fsm_persist_user_less.h5 --filesize "" "" h5clear_user_less_after_size.ddl # # diff --git a/tools/testfiles/err_attr_dspace.ddl b/tools/testfiles/err_attr_dspace.ddl index 6c45322..48ef659 100644 --- a/tools/testfiles/err_attr_dspace.ddl +++ b/tools/testfiles/err_attr_dspace.ddl @@ -2,4 +2,3 @@ HDF5 "err_attr_dspace.h5" { GROUP "/" { } } -h5dump error: error getting attribute information diff --git a/tools/testfiles/non_existing.ddl b/tools/testfiles/non_existing.ddl index 4377f8d..4407eae 100644 --- a/tools/testfiles/non_existing.ddl +++ b/tools/testfiles/non_existing.ddl @@ -28,4 +28,3 @@ GROUP "/" { } } } -h5dump error: unable to open file "non_existing.h5" diff --git a/tools/testfiles/nosuchfile.ls b/tools/testfiles/nosuchfile.ls index 8c4ee42..e69de29 100644 --- a/tools/testfiles/nosuchfile.ls +++ b/tools/testfiles/nosuchfile.ls @@ -1 +0,0 @@ -nosuchfile.h5: unable to open file diff --git a/tools/testfiles/pbits/tnofilename-with-packed-bits.ddl b/tools/testfiles/pbits/tnofilename-with-packed-bits.ddl index 0a3beb0..19de76f 100644 --- a/tools/testfiles/pbits/tnofilename-with-packed-bits.ddl +++ b/tools/testfiles/pbits/tnofilename-with-packed-bits.ddl @@ -135,4 +135,3 @@ usage: h5dump [OPTIONS] files h5dump -d /foo -f family fam%05d.h5 -h5dump error: missing file name diff --git a/tools/testfiles/pbits/tpbitsCharLengthExceeded.ddl b/tools/testfiles/pbits/tpbitsCharLengthExceeded.ddl index b0683a7..b281827 100644 --- a/tools/testfiles/pbits/tpbitsCharLengthExceeded.ddl +++ b/tools/testfiles/pbits/tpbitsCharLengthExceeded.ddl @@ -15,4 +15,3 @@ DATASET "/DS08BITS" { } } } -h5dump error: Packed Bit offset+length value(9) too large. Max is 8 diff --git a/tools/testfiles/pbits/tpbitsCharOffsetExceeded.ddl b/tools/testfiles/pbits/tpbitsCharOffsetExceeded.ddl index 530fa05..ee56a5c 100644 --- a/tools/testfiles/pbits/tpbitsCharOffsetExceeded.ddl +++ b/tools/testfiles/pbits/tpbitsCharOffsetExceeded.ddl @@ -15,4 +15,3 @@ DATASET "/DS08BITS" { } } } -h5dump error: Packed Bit offset+length value(9) too large. Max is 8 diff --git a/tools/testfiles/pbits/tpbitsIncomplete.ddl b/tools/testfiles/pbits/tpbitsIncomplete.ddl index b353065..19de76f 100644 --- a/tools/testfiles/pbits/tpbitsIncomplete.ddl +++ b/tools/testfiles/pbits/tpbitsIncomplete.ddl @@ -135,4 +135,3 @@ usage: h5dump [OPTIONS] files h5dump -d /foo -f family fam%05d.h5 -h5dump error: Bad mask list(0,2,2,1,0,2,2,) diff --git a/tools/testfiles/pbits/tpbitsIntLengthExceeded.ddl b/tools/testfiles/pbits/tpbitsIntLengthExceeded.ddl index 1c919cd..1cba6d5 100644 --- a/tools/testfiles/pbits/tpbitsIntLengthExceeded.ddl +++ b/tools/testfiles/pbits/tpbitsIntLengthExceeded.ddl @@ -15,4 +15,3 @@ DATASET "/DS16BITS" { } } } -h5dump error: Packed Bit offset+length value(17) too large. Max is 16 diff --git a/tools/testfiles/pbits/tpbitsIntOffsetExceeded.ddl b/tools/testfiles/pbits/tpbitsIntOffsetExceeded.ddl index f3b2a8c..330d61f 100644 --- a/tools/testfiles/pbits/tpbitsIntOffsetExceeded.ddl +++ b/tools/testfiles/pbits/tpbitsIntOffsetExceeded.ddl @@ -15,4 +15,3 @@ DATASET "/DS16BITS" { } } } -h5dump error: Packed Bit offset+length value(17) too large. Max is 16 diff --git a/tools/testfiles/pbits/tpbitsLengthExceeded.ddl b/tools/testfiles/pbits/tpbitsLengthExceeded.ddl index ffe0da9..19de76f 100644 --- a/tools/testfiles/pbits/tpbitsLengthExceeded.ddl +++ b/tools/testfiles/pbits/tpbitsLengthExceeded.ddl @@ -135,4 +135,3 @@ usage: h5dump [OPTIONS] files h5dump -d /foo -f family fam%05d.h5 -h5dump error: Packed Bit offset+length value(65) too large. Max is 64 diff --git a/tools/testfiles/pbits/tpbitsLengthPositive.ddl b/tools/testfiles/pbits/tpbitsLengthPositive.ddl index 4502143..19de76f 100644 --- a/tools/testfiles/pbits/tpbitsLengthPositive.ddl +++ b/tools/testfiles/pbits/tpbitsLengthPositive.ddl @@ -135,4 +135,3 @@ usage: h5dump [OPTIONS] files h5dump -d /foo -f family fam%05d.h5 -h5dump error: Packed Bit length value(0) must be positive. diff --git a/tools/testfiles/pbits/tpbitsLongLengthExceeded.ddl b/tools/testfiles/pbits/tpbitsLongLengthExceeded.ddl index 812c300..44ec077 100644 --- a/tools/testfiles/pbits/tpbitsLongLengthExceeded.ddl +++ b/tools/testfiles/pbits/tpbitsLongLengthExceeded.ddl @@ -23,4 +23,3 @@ DATASET "/DS32BITS" { } } } -h5dump error: Packed Bit offset+length value(33) too large. Max is 32 diff --git a/tools/testfiles/pbits/tpbitsLongOffsetExceeded.ddl b/tools/testfiles/pbits/tpbitsLongOffsetExceeded.ddl index cbea722..c775557 100644 --- a/tools/testfiles/pbits/tpbitsLongOffsetExceeded.ddl +++ b/tools/testfiles/pbits/tpbitsLongOffsetExceeded.ddl @@ -23,4 +23,3 @@ DATASET "/DS32BITS" { } } } -h5dump error: Packed Bit offset+length value(33) too large. Max is 32 diff --git a/tools/testfiles/pbits/tpbitsMaxExceeded.ddl b/tools/testfiles/pbits/tpbitsMaxExceeded.ddl index 011f6c9..19de76f 100644 --- a/tools/testfiles/pbits/tpbitsMaxExceeded.ddl +++ b/tools/testfiles/pbits/tpbitsMaxExceeded.ddl @@ -135,4 +135,3 @@ usage: h5dump [OPTIONS] files h5dump -d /foo -f family fam%05d.h5 -h5dump error: Too many masks requested (max. 8). Mask list(0,1,0,1,1,1,2,1,3,1,4,1,5,1,6,1,7,1) diff --git a/tools/testfiles/pbits/tpbitsOffsetExceeded.ddl b/tools/testfiles/pbits/tpbitsOffsetExceeded.ddl index 857fe62..19de76f 100644 --- a/tools/testfiles/pbits/tpbitsOffsetExceeded.ddl +++ b/tools/testfiles/pbits/tpbitsOffsetExceeded.ddl @@ -135,4 +135,3 @@ usage: h5dump [OPTIONS] files h5dump -d /foo -f family fam%05d.h5 -h5dump error: Packed Bit offset value(64) must be between 0 and 63 diff --git a/tools/testfiles/pbits/tpbitsOffsetNegative.ddl b/tools/testfiles/pbits/tpbitsOffsetNegative.ddl index 9ac1160..19de76f 100644 --- a/tools/testfiles/pbits/tpbitsOffsetNegative.ddl +++ b/tools/testfiles/pbits/tpbitsOffsetNegative.ddl @@ -135,4 +135,3 @@ usage: h5dump [OPTIONS] files h5dump -d /foo -f family fam%05d.h5 -h5dump error: Bad mask list(-1,1) diff --git a/tools/testfiles/texceedsubblock.ddl b/tools/testfiles/texceedsubblock.ddl index 499e0d2..69ec706 100644 --- a/tools/testfiles/texceedsubblock.ddl +++ b/tools/testfiles/texceedsubblock.ddl @@ -1,3 +1,2 @@ HDF5 "taindices.h5" { } -h5dump error: number of block dims (2) exceed dataset dims (1) diff --git a/tools/testfiles/texceedsubcount.ddl b/tools/testfiles/texceedsubcount.ddl index 81e8c4a..69ec706 100644 --- a/tools/testfiles/texceedsubcount.ddl +++ b/tools/testfiles/texceedsubcount.ddl @@ -1,3 +1,2 @@ HDF5 "taindices.h5" { } -h5dump error: number of count dims (2) exceed dataset dims (1) diff --git a/tools/testfiles/texceedsubstart.ddl b/tools/testfiles/texceedsubstart.ddl index cb535a0..69ec706 100644 --- a/tools/testfiles/texceedsubstart.ddl +++ b/tools/testfiles/texceedsubstart.ddl @@ -1,3 +1,2 @@ HDF5 "taindices.h5" { } -h5dump error: number of start dims (2) exceed dataset dims (1) diff --git a/tools/testfiles/texceedsubstride.ddl b/tools/testfiles/texceedsubstride.ddl index bf85997..69ec706 100644 --- a/tools/testfiles/texceedsubstride.ddl +++ b/tools/testfiles/texceedsubstride.ddl @@ -1,3 +1,2 @@ HDF5 "taindices.h5" { } -h5dump error: number of stride dims (2) exceed dataset dims (1) diff --git a/tools/testfiles/textlinksrc-nodangle-1.ls b/tools/testfiles/textlinksrc-nodangle-1.ls index 6d1da9e..491f696 100644 --- a/tools/testfiles/textlinksrc-nodangle-1.ls +++ b/tools/testfiles/textlinksrc-nodangle-1.ls @@ -56,5 +56,3 @@ usage: h5ls [OPTIONS] file[/OBJECT] [file[/[OBJECT]...] Replaced by --follow-symlinks. -e, --errors Show all HDF5 error reporting Replaced by --enable-error-stack. -Error: --no-dangling-links must be used along with --follow-symlinks option! - diff --git a/tools/testfiles/tgroup-1.ls b/tools/testfiles/tgroup-1.ls index 069d43e..491f696 100644 --- a/tools/testfiles/tgroup-1.ls +++ b/tools/testfiles/tgroup-1.ls @@ -56,5 +56,3 @@ usage: h5ls [OPTIONS] file[/OBJECT] [file[/[OBJECT]...] Replaced by --follow-symlinks. -e, --errors Show all HDF5 error reporting Replaced by --enable-error-stack. -Error: 'recursive' option not compatible with 'group info' option! - diff --git a/tools/testfiles/tstarfile.ddl b/tools/testfiles/tstarfile.ddl index 87c3f87..1cd87f7 100644 --- a/tools/testfiles/tstarfile.ddl +++ b/tools/testfiles/tstarfile.ddl @@ -86,4 +86,3 @@ HDF5-DIAG: Error detected in HDF5 (version (number)) thread (IDs): #004: (file name) line (number) in H5L_get_info_cb(): name doesn't exist major: Symbol table minor: Object not found -h5dump error: unable to get link info from "Dataset1" |