diff options
165 files changed, 16651 insertions, 3103 deletions
@@ -150,6 +150,7 @@ ./examples/h5_ref2reg.c ./examples/h5_shared_mesg.c ./examples/ph5example.c +./examples/h5_vol_external_log_native.c ./examples/testh5cc.sh.in ./examples/README @@ -666,6 +667,7 @@ ./src/H5EAsblock.c ./src/H5EAstat.c ./src/H5EAtest.c +./src/H5ESpublic.h ./src/H5F.c ./src/H5Faccum.c ./src/H5Fcwfs.c @@ -936,6 +938,13 @@ ./src/H5TSprivate.h ./src/H5VM.c ./src/H5VMprivate.h +./src/H5VL.c +./src/H5VLint.c +./src/H5VLnative.c +./src/H5VLnative.h +./src/H5VLpkg.h +./src/H5VLprivate.h +./src/H5VLpublic.h ./src/H5WB.c ./src/H5WBprivate.h ./src/H5Z.c @@ -986,6 +995,8 @@ ./test/dynlib1.c ./test/dynlib2.c ./test/dynlib3.c +./test/dynlibvol1.c +./test/dynlibvol2.c ./test/earray.c ./test/efc.c ./test/enc_dec_plist.c @@ -1061,6 +1072,7 @@ ./test/ohdr.c ./test/objcopy.c ./test/plugin.c +./test/vol_test.c ./test/reserved.c ./test/pool.c ./test/set_extent.c @@ -1086,6 +1098,7 @@ ./test/testhdf5.h ./test/testlibinfo.sh.in ./test/test_plugin.sh.in +./test/test_vol_plugin.sh.in ./test/testmeta.c ./test/tfile.c ./test/tgenprop.c @@ -46,6 +46,7 @@ $Source = ""; "H5E_direction_t" => "Ed", "H5E_error_t" => "Ee", "H5E_type_t" => "Et", + "H5ES_status_t" => "Es", "H5F_close_degree_t" => "Fd", "H5F_file_space_type_t" => "Ff", "H5F_mem_t" => "Fm", @@ -77,7 +78,6 @@ $Source = ""; "hobj_ref_t" => "r", "H5R_type_t" => "Rt", "char" => "s", - "unsigned char" => "s", "H5S_class_t" => "Sc", "H5S_seloper_t" => "Ss", "H5S_sel_type" => "St", @@ -93,6 +93,21 @@ $Source = ""; "H5T_str_t" => "Tz", "unsigned long" => "Ul", "unsigned long long" => "UL", + "H5VL_attr_get_t" => "Va", + "H5VL_attr_specific_t" => "Vb", + "H5VL_dataset_get_t" => "Vc", + "H5VL_dataset_specific_t" => "Vd", + "H5VL_datatype_get_t" => "Ve", + "H5VL_datatype_specific_t" => "Vf", + "H5VL_file_get_t" => "Vg", + "H5VL_file_specific_t" => "Vh", + "H5VL_group_get_t" => "Vi", + "H5VL_group_specific_t" => "Vj", + "H5VL_link_create_type_t" => "Vk", + "H5VL_link_get_t" => "Vl", + "H5VL_link_specific_t" => "Vm", + "H5VL_object_get_t" => "Vn", + "H5VL_object_specific_t" => "Vo", "void" => "x", "FILE" => "x", "H5A_operator_t" => "x", @@ -118,6 +133,7 @@ $Source = ""; "H5G_iterate_t" => "x", "H5G_info_t" => "x", "H5I_free_t" => "x", + "H5I_iterate_func_t" => "x", "H5L_class_t" => "x", "H5L_elink_traverse_t" => "x", "H5L_iterate_t" => "x", @@ -140,6 +156,9 @@ $Source = ""; "H5T_cdata_t" => "x", "H5T_conv_t" => "x", "H5T_conv_except_func_t" => "x", + "H5VL_t" => "x", + "H5VL_class_t" => "x", + "H5VL_loc_params_t" => "x", "H5Z_func_t" => "x", "H5Z_filter_func_t" => "x", "va_list" => "x", diff --git a/c++/src/H5File.cpp b/c++/src/H5File.cpp index e4ac4a1..b121243 100644 --- a/c++/src/H5File.cpp +++ b/c++/src/H5File.cpp @@ -163,38 +163,43 @@ H5File::H5File(const H5File& original) : H5Location(original) } //-------------------------------------------------------------------------- -// Function: H5File::isHdf5 (static) -///\brief Determines whether a file in HDF5 format. (Static) +// Function: H5File::isAccessible +///\brief Determines whether a file is accessible by the fapl. (Static) ///\param name - IN: Name of the file -///\return true if the file is in HDF5 format, and false, otherwise +///\param access_plist - IN: File access property list. Default to +/// FileCreatPropList::DEFAULT +///\return true if the file is accessible, and false, otherwise ///\exception H5::FileIException // Programmer Binh-Minh Ribler - 2000 //-------------------------------------------------------------------------- -bool H5File::isHdf5(const char* name) +bool H5File::isAccessible(const char* name, const FileAccPropList& access_plist) { - // Calls C routine H5Fis_hdf5 to determine whether the file is in + // Calls C routine H5Fis_accessible to determine whether the file is in // HDF5 format. It returns positive value, 0, or negative value - htri_t ret_value = H5Fis_hdf5( name ); + hid_t access_plist_id = access_plist.getId(); + htri_t ret_value = H5Fis_accessible( name, access_plist_id ); if( ret_value > 0 ) return true; else if( ret_value == 0 ) return false; - else // Raise exception when H5Fis_hdf5 returns a negative value + else // Raise exception when H5Fis_accessible returns a negative value { - throw FileIException("H5File::isHdf5", "H5Fis_hdf5 returned negative value"); + throw FileIException("H5File::isAccessible", "H5Fis_accessible returned negative value"); } } //-------------------------------------------------------------------------- -// Function: H5File::isHdf5 (static) +// Function: H5File::isAccessible ///\brief This is an overloaded member function, provided for convenience. /// It takes an \c H5std_string for \a name. (Static) ///\param name - IN: Name of the file - \c H5std_string +///\param access_plist - IN: File access property list. Default to +/// FileCreatPropList::DEFAULT // Programmer Binh-Minh Ribler - 2000 //-------------------------------------------------------------------------- -bool H5File::isHdf5(const H5std_string& name ) +bool H5File::isAccessible(const H5std_string& name, const FileAccPropList& access_plist ) { - return( isHdf5( name.c_str()) ); + return( isAccessible(name.c_str(), access_plist) ); } //-------------------------------------------------------------------------- diff --git a/c++/src/H5File.h b/c++/src/H5File.h index 0ef85b5..c49fe51 100644 --- a/c++/src/H5File.h +++ b/c++/src/H5File.h @@ -71,9 +71,11 @@ class H5_DLLCPP H5File : public H5Location, public CommonFG { void getVFDHandle(const FileAccPropList& fapl, void **file_handle) const; void getVFDHandle(FileAccPropList& fapl, void **file_handle) const; // kept for backward compatibility - // Determines if a file, specified by its name, is in HDF5 format - static bool isHdf5(const char* name ); - static bool isHdf5(const H5std_string& name ); + // Determines if a file, specified by its name, can be accessed with the fapl + static bool isAccessible(const char* name, + const FileAccPropList& access_plist = FileAccPropList::DEFAULT); + static bool isAccessible(const H5std_string& name, + const FileAccPropList& access_plist = FileAccPropList::DEFAULT); // Reopens this file. void reOpen(); // added for better name diff --git a/config/cmake/ConfigureChecks.cmake b/config/cmake/ConfigureChecks.cmake index 444ce0b..a18493c 100644 --- a/config/cmake/ConfigureChecks.cmake +++ b/config/cmake/ConfigureChecks.cmake @@ -105,6 +105,7 @@ if (WINDOWS) # (This flag should be _unset_ for all machines, except for Windows) set (H5_HAVE_WINDOW_PATH 1) endif (WINDOWS) +SET (H5_DEFAULT_VOL H5VL_NATIVE) if (WINDOWS) #----------------------------------------------------------------------------- diff --git a/config/cmake/H5pubconf.h.in b/config/cmake/H5pubconf.h.in index 8235c54..ec4c47f 100644 --- a/config/cmake/H5pubconf.h.in +++ b/config/cmake/H5pubconf.h.in @@ -60,6 +60,9 @@ /* Define the default virtual file driver to compile */ #cmakedefine H5_DEFAULT_VFD @H5_DEFAULT_VFD@ +/* Define the default vol plugin to compile */ +#cmakedefine H5_DEFAULT_VOL @H5_DEFAULT_VOL@ + /* Define if `dev_t' is a scalar */ #cmakedefine H5_DEV_T_IS_SCALAR @H5_DEV_T_IS_SCALAR@ @@ -33268,7 +33268,7 @@ else fi -ac_config_files="$ac_config_files src/libhdf5.settings Makefile src/Makefile test/Makefile test/testcheck_version.sh test/testerror.sh test/H5srcdir_str.h test/testlibinfo.sh test/testlinks_env.sh test/test_plugin.sh testpar/Makefile perform/Makefile tools/Makefile tools/h5dump/Makefile tools/h5dump/testh5dump.sh tools/h5dump/testh5dumppbits.sh tools/h5dump/testh5dumpxml.sh tools/h5ls/testh5ls.sh tools/h5import/Makefile tools/h5import/h5importtestutil.sh tools/h5diff/Makefile tools/h5diff/testh5diff.sh tools/h5diff/testph5diff.sh tools/h5jam/Makefile tools/h5jam/testh5jam.sh tools/h5repack/Makefile tools/h5repack/h5repack.sh tools/h5repack/h5repack_plugin.sh tools/h5ls/Makefile tools/h5copy/Makefile tools/h5copy/testh5copy.sh tools/lib/Makefile tools/misc/Makefile tools/misc/h5cc tools/misc/testh5mkgrp.sh tools/misc/testh5repart.sh tools/h5stat/testh5stat.sh tools/h5stat/Makefile examples/Makefile examples/run-c-ex.sh examples/testh5cc.sh c++/Makefile c++/src/Makefile c++/src/h5c++ c++/test/Makefile c++/test/H5srcdir_str.h c++/examples/Makefile c++/examples/run-c++-ex.sh c++/examples/testh5c++.sh fortran/Makefile fortran/src/h5fc fortran/src/Makefile fortran/test/Makefile fortran/testpar/Makefile fortran/examples/Makefile fortran/examples/run-fortran-ex.sh fortran/examples/testh5fc.sh hl/Makefile hl/src/Makefile hl/test/Makefile hl/test/H5srcdir_str.h hl/tools/Makefile hl/tools/gif2h5/Makefile hl/tools/gif2h5/h52giftest.sh hl/examples/Makefile hl/examples/run-hlc-ex.sh hl/c++/Makefile hl/c++/src/Makefile hl/c++/test/Makefile hl/c++/examples/Makefile hl/c++/examples/run-hlc++-ex.sh hl/fortran/Makefile hl/fortran/src/Makefile hl/fortran/test/Makefile hl/fortran/examples/Makefile hl/fortran/examples/run-hlfortran-ex.sh" +ac_config_files="$ac_config_files src/libhdf5.settings Makefile src/Makefile test/Makefile test/testcheck_version.sh test/testerror.sh test/H5srcdir_str.h test/testlibinfo.sh test/testlinks_env.sh test/test_plugin.sh test/test_vol_plugin.sh testpar/Makefile perform/Makefile tools/Makefile tools/h5dump/Makefile tools/h5dump/testh5dump.sh tools/h5dump/testh5dumppbits.sh tools/h5dump/testh5dumpxml.sh tools/h5ls/testh5ls.sh tools/h5import/Makefile tools/h5import/h5importtestutil.sh tools/h5diff/Makefile tools/h5diff/testh5diff.sh tools/h5diff/testph5diff.sh tools/h5jam/Makefile tools/h5jam/testh5jam.sh tools/h5repack/Makefile tools/h5repack/h5repack.sh tools/h5repack/h5repack_plugin.sh tools/h5ls/Makefile tools/h5copy/Makefile tools/h5copy/testh5copy.sh tools/lib/Makefile tools/misc/Makefile tools/misc/h5cc tools/misc/testh5mkgrp.sh tools/misc/testh5repart.sh tools/h5stat/testh5stat.sh tools/h5stat/Makefile examples/Makefile examples/run-c-ex.sh examples/testh5cc.sh c++/Makefile c++/src/Makefile c++/src/h5c++ c++/test/Makefile c++/test/H5srcdir_str.h c++/examples/Makefile c++/examples/run-c++-ex.sh c++/examples/testh5c++.sh fortran/Makefile fortran/src/h5fc fortran/src/Makefile fortran/test/Makefile fortran/testpar/Makefile fortran/examples/Makefile fortran/examples/run-fortran-ex.sh fortran/examples/testh5fc.sh hl/Makefile hl/src/Makefile hl/test/Makefile hl/test/H5srcdir_str.h hl/tools/Makefile hl/tools/gif2h5/Makefile hl/tools/gif2h5/h52giftest.sh hl/examples/Makefile hl/examples/run-hlc-ex.sh hl/c++/Makefile hl/c++/src/Makefile hl/c++/test/Makefile hl/c++/examples/Makefile hl/c++/examples/run-hlc++-ex.sh hl/fortran/Makefile hl/fortran/src/Makefile hl/fortran/test/Makefile hl/fortran/examples/Makefile hl/fortran/examples/run-hlfortran-ex.sh" cat >confcache <<\_ACEOF @@ -34547,6 +34547,7 @@ do "test/testlibinfo.sh") CONFIG_FILES="$CONFIG_FILES test/testlibinfo.sh" ;; "test/testlinks_env.sh") CONFIG_FILES="$CONFIG_FILES test/testlinks_env.sh" ;; "test/test_plugin.sh") CONFIG_FILES="$CONFIG_FILES test/test_plugin.sh" ;; + "test/test_vol_plugin.sh") CONFIG_FILES="$CONFIG_FILES test/test_vol_plugin.sh" ;; "testpar/Makefile") CONFIG_FILES="$CONFIG_FILES testpar/Makefile" ;; "perform/Makefile") CONFIG_FILES="$CONFIG_FILES perform/Makefile" ;; "tools/Makefile") CONFIG_FILES="$CONFIG_FILES tools/Makefile" ;; diff --git a/configure.ac b/configure.ac index 88c61d6..bf8b8eb 100644 --- a/configure.ac +++ b/configure.ac @@ -4479,6 +4479,7 @@ AC_CONFIG_FILES([src/libhdf5.settings test/testlibinfo.sh test/testlinks_env.sh test/test_plugin.sh + test/test_vol_plugin.sh testpar/Makefile perform/Makefile tools/Makefile diff --git a/examples/CMakeLists.txt b/examples/CMakeLists.txt index 4cd72a0..318417d 100644 --- a/examples/CMakeLists.txt +++ b/examples/CMakeLists.txt @@ -34,6 +34,7 @@ set (examples h5_extlink h5_elink_unix2win h5_shared_mesg + h5_vol_external_log_native ) foreach (example ${examples}) diff --git a/examples/Makefile.am b/examples/Makefile.am index 5d0da93..55b6b09 100644 --- a/examples/Makefile.am +++ b/examples/Makefile.am @@ -37,7 +37,8 @@ EXAMPLE_PROG = h5_write h5_read h5_extend_write h5_chunk_read h5_compound \ h5_crtgrpd h5_subset h5_cmprss h5_rdwt h5_crtgrpar h5_extend \ h5_crtatt h5_crtgrp h5_crtdat \ h5_group h5_select h5_attribute h5_mount h5_reference h5_drivers \ - h5_ref2reg h5_extlink h5_elink_unix2win h5_shared_mesg + h5_ref2reg h5_extlink h5_elink_unix2win h5_shared_mesg \ + h5_vol_external_log_native TEST_SCRIPT=testh5cc.sh TEST_EXAMPLES_SCRIPT=$(INSTALL_SCRIPT_FILES) @@ -48,7 +49,8 @@ INSTALL_FILES = h5_write.c h5_read.c h5_extend_write.c h5_chunk_read.c \ h5_extend.c h5_crtatt.c h5_crtgrp.c h5_crtdat.c \ h5_compound.c h5_group.c h5_select.c h5_attribute.c h5_mount.c \ h5_reference.c h5_drivers.c h5_extlink.c h5_elink_unix2win.c \ - h5_ref2reg.c h5_shared_mesg.c ph5example.c + h5_ref2reg.c h5_shared_mesg.c ph5example.c \ + h5_vol_external_log_native.c @@ -117,6 +119,7 @@ h5_dtransform: $(srcdir)/h5_dtransform.c h5_extlink: $(srcdir)/h5_extlink.c $(EXTLINK_DIRS) h5_elink_unix2win: $(srcdir)/h5_elink_unix2win.c $(EXTLINK_DIRS) h5_shared_mesg: $(srcdir)/h5_shared_mesg.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/Makefile.in b/examples/Makefile.in index 71a9b4c..aaa595d 100644 --- a/examples/Makefile.in +++ b/examples/Makefile.in @@ -624,7 +624,8 @@ EXAMPLE_PROG = h5_write h5_read h5_extend_write h5_chunk_read h5_compound \ h5_crtgrpd h5_subset h5_cmprss h5_rdwt h5_crtgrpar h5_extend \ h5_crtatt h5_crtgrp h5_crtdat \ h5_group h5_select h5_attribute h5_mount h5_reference h5_drivers \ - h5_ref2reg h5_extlink h5_elink_unix2win h5_shared_mesg + h5_ref2reg h5_extlink h5_elink_unix2win h5_shared_mesg \ + h5_vol_external_log_native TEST_SCRIPT = testh5cc.sh TEST_EXAMPLES_SCRIPT = $(INSTALL_SCRIPT_FILES) @@ -636,7 +637,8 @@ INSTALL_FILES = h5_write.c h5_read.c h5_extend_write.c h5_chunk_read.c \ h5_extend.c h5_crtatt.c h5_crtgrp.c h5_crtdat.c \ h5_compound.c h5_group.c h5_select.c h5_attribute.c h5_mount.c \ h5_reference.c h5_drivers.c h5_extlink.c h5_elink_unix2win.c \ - h5_ref2reg.c h5_shared_mesg.c ph5example.c + h5_ref2reg.c h5_shared_mesg.c ph5example.c \ + h5_vol_external_log_native.c # The external link examples demonstrate how to use paths; they need @@ -1089,6 +1091,7 @@ h5_dtransform: $(srcdir)/h5_dtransform.c h5_extlink: $(srcdir)/h5_extlink.c $(EXTLINK_DIRS) h5_elink_unix2win: $(srcdir)/h5_elink_unix2win.c $(EXTLINK_DIRS) h5_shared_mesg: $(srcdir)/h5_shared_mesg.c +h5_vol_external_log_native: $(srcdir)/h5_vol_external_log_native.c # How to create EXAMPLEDIR if it doesn't already exist $(EXAMPLEDIR): diff --git a/examples/h5_vol_external_log_native.c b/examples/h5_vol_external_log_native.c new file mode 100644 index 0000000..74c05da --- /dev/null +++ b/examples/h5_vol_external_log_native.c @@ -0,0 +1,530 @@ +
+#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_plugin_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_plugin_name(oid, n, 50);
+ printf ("Visiting GROUP VOL name = %s %d\n", n, len);
+ }
+ if(H5Iget_type(oid) == H5I_DATASET)
+ printf("visiting dataset\n");
+ if(H5Iget_type(oid) == H5I_DATATYPE)
+ printf("visiting datatype\n");
+
+ return 1;
+} /* end h5_verify_cached_stabs_cb() */
+
+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_registered("native") == 1);
+
+ vol_id = H5VLregister (&H5VL_log_g);
+ assert(vol_id > 0);
+ assert(H5VLis_registered("log") == 1);
+
+ vol_id2 = H5VLget_plugin_id("log");
+ H5VLinitialize(vol_id2, H5P_DEFAULT);
+ H5VLclose(vol_id2);
+
+ native_plugin_id = H5VLget_plugin_id("native");
+ assert(native_plugin_id > 0);
+
+ acc_tpl = H5Pcreate (H5P_FILE_ACCESS);
+ H5Pset_vol(acc_tpl, vol_id, &under_fapl);
+
+ file_id = H5Fcreate(file_name, H5F_ACC_TRUNC, H5P_DEFAULT, acc_tpl);
+ len = H5VLget_plugin_name(file_id, name, 25);
+ printf ("FILE VOL name = %s %d\n", name, len);
+
+ group_id = H5Gcreate2(file_id, group_name, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT);
+ len = H5VLget_plugin_name(group_id, name, 50);
+ printf ("GROUP VOL name = %s %d\n", name, len);
+
+ int_id = H5Tcopy(H5T_NATIVE_INT);
+ H5Tcommit2(file_id, "int", int_id, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT);
+ len = H5VLget_plugin_name(int_id, name, 50);
+ printf ("DT COMMIT name = %s %d\n", name, len);
+ H5Tclose(int_id);
+
+ int_id = H5Topen2(file_id, "int", H5P_DEFAULT);
+ len = H5VLget_plugin_name(int_id, name, 50);
+ printf ("DT OPEN name = %s %d\n", name, len);
+ H5Tclose(int_id);
+
+ int_id = H5Oopen(file_id,"int",H5P_DEFAULT);
+ len = H5VLget_plugin_name(int_id, name, 50);
+ printf ("DT OOPEN name = %s %d\n", name, len);
+
+ len = H5Fget_name(file_id, name, 50);
+ printf("name = %d %s\n", len, name);
+
+ data = 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_plugin_name(datasetId, name, 50);
+ printf ("DSET name = %s %d\n", name, len);
+
+ H5Dwrite(datasetId, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, H5P_DEFAULT, data);
+ H5Dclose(datasetId);
+
+ H5Ovisit(file_id, H5_INDEX_NAME, H5_ITER_NATIVE, visit_cb, NULL);
+
+ free (data);
+ H5Oclose(int_id);
+ H5Sclose (space);
+ H5Gclose(group_id);
+#if 0
+
+ attr = H5Acreate2(group_id, "attr1", int_id, space, H5P_DEFAULT, H5P_DEFAULT);
+ int_id = H5Aget_type(attr);
+ len = H5VLget_plugin_name(int_id, name, 50);
+ printf ("DT OPEN name = %s %d\n", name, len);
+
+ H5Aclose (attr);
+
+ int_id = H5Oopen(file_id,"int",H5P_DEFAULT);
+ len = H5VLget_plugin_name(int_id, name, 50);
+ printf ("DT OOPEN name = %s %d\n", name, len);
+ H5Oclose(int_id);
+
+
+ H5Fclose(file_id);
+ file_id = H5Fopen(file_name, H5F_ACC_RDWR, H5P_DEFAULT);//acc_tpl);
+ H5Fflush(file_id, H5F_SCOPE_GLOBAL);
+#endif
+
+ H5Fclose(file_id);
+ H5Pclose(acc_tpl);
+ H5Pclose(under_fapl);
+
+ H5VLclose(native_plugin_id);
+ H5VLterminate(vol_id, H5P_DEFAULT);
+ H5VLunregister (vol_id);
+ assert(H5VLis_registered("log") == 0);
+ return 0;
+}
+
+static herr_t H5VL_log_init(hid_t vipl_id)
+{
+ printf("------- LOG INIT\n");
+ return 0;
+}
+
+static herr_t H5VL_log_term(hid_t vtpl_id)
+{
+ printf("------- LOG TERM\n");
+ return 0;
+}
+
+static void *
+H5VL_log_file_create(const char *name, unsigned flags, hid_t fcpl_id, hid_t fapl_id, hid_t dxpl_id, void **req)
+{
+ hid_t under_fapl;
+ H5VL_log_t *file;
+
+ file = (H5VL_log_t *)calloc(1, sizeof(H5VL_log_t));
+
+ under_fapl = *((hid_t *)H5Pget_vol_info(fapl_id));
+ file->under_object = H5VLfile_create(name, flags, fcpl_id, under_fapl, dxpl_id, req);
+
+ printf("------- LOG H5Fcreate\n");
+ return (void *)file;
+}
+
+static void *
+H5VL_log_file_open(const char *name, unsigned flags, hid_t fapl_id, hid_t dxpl_id, void **req)
+{
+ hid_t under_fapl;
+ H5VL_log_t *file;
+
+ file = (H5VL_log_t *)calloc(1, sizeof(H5VL_log_t));
+
+ under_fapl = *((hid_t *)H5Pget_vol_info(fapl_id));
+ file->under_object = H5VLfile_open(name, flags, under_fapl, dxpl_id, req);
+
+ printf("------- LOG H5Fopen\n");
+ return (void *)file;
+}
+
+static herr_t
+H5VL_log_file_get(void *file, H5VL_file_get_t get_type, hid_t dxpl_id, void **req, va_list arguments)
+{
+ H5VL_log_t *f = (H5VL_log_t *)file;
+
+ H5VLfile_get(f->under_object, native_plugin_id, get_type, dxpl_id, req, arguments);
+
+ printf("------- LOG H5Fget %d\n", get_type);
+ return 1;
+}
+static herr_t
+H5VL_log_file_close(void *file, hid_t dxpl_id, void **req)
+{
+ H5VL_log_t *f = (H5VL_log_t *)file;
+
+ H5VLfile_close(f->under_object, native_plugin_id, dxpl_id, req);
+ free(f);
+
+ printf("------- LOG H5Fclose\n");
+ return 1;
+}
+
+static void *
+H5VL_log_group_create(void *obj, H5VL_loc_params_t loc_params, const char *name,
+ hid_t gcpl_id, hid_t gapl_id, hid_t dxpl_id, void **req)
+{
+ H5VL_log_t *group;
+ H5VL_log_t *o = (H5VL_log_t *)obj;
+
+ group = (H5VL_log_t *)calloc(1, sizeof(H5VL_log_t));
+
+ group->under_object = H5VLgroup_create(o->under_object, loc_params, native_plugin_id, name, gcpl_id, gapl_id, dxpl_id, req);
+
+ printf("------- LOG H5Gcreate\n");
+ return (void *)group;
+}
+
+static herr_t
+H5VL_log_group_close(void *grp, hid_t dxpl_id, void **req)
+{
+ H5VL_log_t *g = (H5VL_log_t *)grp;
+
+ H5VLgroup_close(g->under_object, native_plugin_id, dxpl_id, req);
+ free(g);
+
+ printf("------- LOG H5Gclose\n");
+ return 1;
+}
+
+static void *
+H5VL_log_datatype_commit(void *obj, H5VL_loc_params_t loc_params, const char *name,
+ hid_t type_id, hid_t lcpl_id, hid_t tcpl_id, hid_t tapl_id, hid_t dxpl_id, void **req)
+{
+ H5VL_log_t *dt;
+ H5VL_log_t *o = (H5VL_log_t *)obj;
+
+ dt = (H5VL_log_t *)calloc(1, sizeof(H5VL_log_t));
+
+ dt->under_object = H5VLdatatype_commit(o->under_object, loc_params, native_plugin_id, name,
+ type_id, lcpl_id, tcpl_id, tapl_id, dxpl_id, req);
+
+ printf("------- LOG H5Tcommit\n");
+ return dt;
+}
+static void *
+H5VL_log_datatype_open(void *obj, H5VL_loc_params_t loc_params, const char *name, hid_t tapl_id, hid_t dxpl_id, void **req)
+{
+ H5VL_log_t *dt;
+ H5VL_log_t *o = (H5VL_log_t *)obj;
+
+ dt = (H5VL_log_t *)calloc(1, sizeof(H5VL_log_t));
+
+ dt->under_object = H5VLdatatype_open(o->under_object, loc_params, native_plugin_id, name, tapl_id, dxpl_id, req);
+
+ printf("------- LOG H5Topen\n");
+ return (void *)dt;
+}
+
+static herr_t
+H5VL_log_datatype_get(void *dt, H5VL_datatype_get_t get_type, hid_t dxpl_id, void **req, va_list arguments)
+{
+ H5VL_log_t *o = (H5VL_log_t *)dt;
+ herr_t ret_value;
+
+ ret_value = H5VLdatatype_get(o->under_object, native_plugin_id, get_type, dxpl_id, req, arguments);
+
+ printf("------- LOG datatype get\n");
+ return ret_value;
+}
+
+static herr_t
+H5VL_log_datatype_close(void *dt, hid_t dxpl_id, void **req)
+{
+ H5VL_log_t *type = (H5VL_log_t *)dt;
+
+ assert(type->under_object);
+
+ H5VLdatatype_close(type->under_object, native_plugin_id, dxpl_id, req);
+ free(type);
+
+ printf("------- LOG H5Tclose\n");
+ return 1;
+}
+
+static void *
+H5VL_log_object_open(void *obj, H5VL_loc_params_t loc_params, H5I_type_t *opened_type, hid_t dxpl_id, void **req)
+{
+ H5VL_log_t *new_obj;
+ H5VL_log_t *o = (H5VL_log_t *)obj;
+
+ new_obj = (H5VL_log_t *)calloc(1, sizeof(H5VL_log_t));
+
+ new_obj->under_object = H5VLobject_open(o->under_object, loc_params, native_plugin_id, opened_type, dxpl_id, req);
+
+ printf("------- LOG H5Oopen\n");
+ return (void *)new_obj;
+}
+
+static herr_t
+H5VL_log_object_specific(void *obj, H5VL_loc_params_t loc_params, H5VL_object_specific_t specific_type,
+ hid_t dxpl_id, void **req, va_list arguments)
+{
+ H5VL_log_t *o = (H5VL_log_t *)obj;
+
+ H5VLobject_specific(o->under_object, loc_params, native_plugin_id, specific_type, dxpl_id, req, arguments);
+
+ printf("------- LOG Object specific\n");
+ return 1;
+}
+
+static void *
+H5VL_log_dataset_create(void *obj, H5VL_loc_params_t loc_params, const char *name, hid_t dcpl_id, hid_t dapl_id, hid_t dxpl_id, void **req)
+{
+ H5VL_log_t *dset;
+ H5VL_log_t *o = (H5VL_log_t *)obj;
+
+ dset = (H5VL_log_t *)calloc(1, sizeof(H5VL_log_t));
+
+ dset->under_object = H5VLdataset_create(o->under_object, loc_params, native_plugin_id, name, dcpl_id, dapl_id, dxpl_id, req);
+
+ printf("------- LOG H5Dcreate\n");
+ return (void *)dset;
+}
+
+static void *
+H5VL_log_dataset_open(void *obj, H5VL_loc_params_t loc_params, const char *name, hid_t dapl_id, hid_t dxpl_id, void **req)
+{
+ H5VL_log_t *dset;
+ H5VL_log_t *o = (H5VL_log_t *)obj;
+
+ dset = (H5VL_log_t *)calloc(1, sizeof(H5VL_log_t));
+
+ dset->under_object = H5VLdataset_open(o->under_object, loc_params, native_plugin_id, name, dapl_id, dxpl_id, req);
+
+ printf("------- LOG H5Dopen\n");
+ return (void *)dset;
+}
+
+static herr_t
+H5VL_log_dataset_read(void *dset, hid_t mem_type_id, hid_t mem_space_id,
+ hid_t file_space_id, hid_t plist_id, void *buf, void **req)
+{
+ H5VL_log_t *d = (H5VL_log_t *)dset;
+
+ H5VLdataset_read(d->under_object, native_plugin_id, mem_type_id, mem_space_id, file_space_id,
+ plist_id, buf, req);
+
+ printf("------- LOG H5Dread\n");
+ return 1;
+}
+static herr_t
+H5VL_log_dataset_write(void *dset, hid_t mem_type_id, hid_t mem_space_id,
+ hid_t file_space_id, hid_t plist_id, const void *buf, void **req)
+{
+ H5VL_log_t *d = (H5VL_log_t *)dset;
+
+ H5VLdataset_write(d->under_object, native_plugin_id, mem_type_id, mem_space_id, file_space_id,
+ plist_id, buf, req);
+
+ printf("------- LOG H5Dwrite\n");
+ return 1;
+}
+static herr_t
+H5VL_log_dataset_close(void *dset, hid_t dxpl_id, void **req)
+{
+ H5VL_log_t *d = (H5VL_log_t *)dset;
+
+ H5VLdataset_close(d->under_object, native_plugin_id, dxpl_id, req);
+ free(d);
+
+ printf("------- LOG H5Dclose\n");
+ return 1;
+}
+
+#if 0
+static void *H5VL_log_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 herr_t H5VL_log_attr_close(void *attr, hid_t dxpl_id, void **req){
+
+/* Datatype callbacks */
+
+
+/* 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 herr_t H5VL_log_dataset_close(void *dset, hid_t dxpl_id, void **req){
+
+/* File callbacks */
+
+
+static void *H5VL_log_file_open(const char *name, unsigned flags, hid_t fapl_id, hid_t dxpl_id, void **req){
+
+
+/* Group callbacks */
+
+static void *H5VL_log_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_log_group_get(void *obj, H5VL_group_get_t get_type, hid_t dxpl_id, void **req, va_list arguments){
+
+
+/* Link callbacks */
+
+/* Object callbacks */
+
+
+#endif
diff --git a/examples/run-c-ex.sh.in b/examples/run-c-ex.sh.in index 9b2a2bb..142d02f 100644 --- a/examples/run-c-ex.sh.in +++ b/examples/run-c-ex.sh.in @@ -125,7 +125,9 @@ then RunTest h5_elink_unix2win &&\ rm h5_elink_unix2win &&\ RunTest h5_shared_mesg &&\ - rm h5_shared_mesg); then + rm h5_shared_mesg)&&\ + RunTest h5_vol_external_log_native &&\ + rm h5_vol_external_log_native; then EXIT_VALUE=${EXIT_SUCCESS} else EXIT_VALUE=${EXIT_FAILURE} diff --git a/fortran/doc/DevelGuide/masterindex.html b/fortran/doc/DevelGuide/masterindex.html index 9765ea0..b187d66 100644 --- a/fortran/doc/DevelGuide/masterindex.html +++ b/fortran/doc/DevelGuide/masterindex.html @@ -164,7 +164,7 @@ <a href="./src/H5Fff_f90.html#robo142" class="indexitem" >h5fget_name_f</a> <a href="./src/H5Fff_f90.html#robo143" class="indexitem" >h5fget_obj_count_f</a> <a href="./src/H5Fff_f90.html#robo144" class="indexitem" >h5fget_obj_ids_f</a> -<a href="./src/H5Fff_f90.html#robo145" class="indexitem" >h5fis_hdf5_f</a> +<a href="./src/H5Fff_f90.html#robo145" class="indexitem" >h5fis_accessible_f</a> <a href="./src/H5Fff_f90.html#robo146" class="indexitem" >h5fmount_f</a> <a href="./src/H5Fff_f90.html#robo147" class="indexitem" >h5fopen_f</a> <a href="./src/H5Fff_f90.html#robo148" class="indexitem" >h5freopen_f</a> diff --git a/fortran/doc/DevelGuide/robo_subroutines.html b/fortran/doc/DevelGuide/robo_subroutines.html index 0846c77..a5ce815 100644 --- a/fortran/doc/DevelGuide/robo_subroutines.html +++ b/fortran/doc/DevelGuide/robo_subroutines.html @@ -92,7 +92,7 @@ <a href="./src/H5Fff_f90.html#robo142" class="indexitem" >h5fget_name_f</a> <a href="./src/H5Fff_f90.html#robo143" class="indexitem" >h5fget_obj_count_f</a> <a href="./src/H5Fff_f90.html#robo144" class="indexitem" >h5fget_obj_ids_f</a> -<a href="./src/H5Fff_f90.html#robo145" class="indexitem" >h5fis_hdf5_f</a> +<a href="./src/H5Fff_f90.html#robo145" class="indexitem" >h5fis_accessible_f</a> <a href="./src/H5Fff_f90.html#robo146" class="indexitem" >h5fmount_f</a> <a href="./src/H5Fff_f90.html#robo147" class="indexitem" >h5fopen_f</a> <a href="./src/H5Fff_f90.html#robo148" class="indexitem" >h5freopen_f</a> diff --git a/fortran/doc/DevelGuide/src/H5Fff_f90.html b/fortran/doc/DevelGuide/src/H5Fff_f90.html index b0164c9..fd8e579 100644 --- a/fortran/doc/DevelGuide/src/H5Fff_f90.html +++ b/fortran/doc/DevelGuide/src/H5Fff_f90.html @@ -443,22 +443,24 @@ </pre> <hr /> -<a name="H5F2fh5fis5fhdf55ff"></a> -<a name="robo145"></a><h2>h5fis_hdf5_f</h2> +<a name="H5F2fh5fis5f5accessibleff"></a> +<a name="robo145"></a><h2>h5fis_accessible_f</h2> <p>[ <a href="#robo_top_of_doc">Top</a> ] [ <a href="#robo39">H5F</a> ] [ <a href="../robo_subroutines.html#robo_top_of_doc">Subroutines</a> ]</p> <p class="item_name">NAME</p> -<pre> <strong>h5fis_hdf5_f</strong> +<pre> <strong>h5fis_accessible_f</strong> </pre> <p class="item_name">PURPOSE</p> -<pre> Determines whether a file is in the <a href="./HDF5_f90.html#robo76">HDF5</a> format. +<pre> Check if the file can be opened with the given fapl. </pre> <p class="item_name">INPUTS</p> <pre> name - name of the file to check + fapl_id - the file access property list with which to + attempt to access the file. </pre> <p class="item_name">OUTPUTS</p> -<pre> status - indicates if file is and <a href="./HDF5_f90.html#robo76">HDF5</a> file - hdferr - Returns 0 if successful and -1 if fails +<pre> status - indicates if file is accessible + hdferr - Returns TRUE/FALSE if successful and -1 if fails </pre> <p class="item_name">AUTHOR</p> <pre> Elena Pourmal @@ -470,9 +472,11 @@ port). February 28, 2001 </pre> <p class="item_name">SOURCE</p> -<pre class="source"> SUBROUTINE <strong>h5fis_hdf5_f</strong><span class="sign">(</span>name<span class="sign">,</span> status<span class="sign">,</span> hdferr<span class="sign">)</span> +<pre class="source"> SUBROUTINE <strong>h5fis_accessible_f</strong><span class="sign">(</span>name<span class="sign">,</span> status<span class="sign">,</span> hdferr<span class="sign">)</span> IMPLICIT NONE CHARACTER<span class="sign">(</span>LEN<span class="sign">=</span><span class="sign">*</span><span class="sign">)</span><span class="sign">,</span> INTENT<span class="sign">(</span>IN<span class="sign">)</span> <span class="sign">:</span><span class="sign">:</span> name <span class="sign">!</span> Name of the file + INTEGER<span class="sign">(</span>HID_T<span class="sign">)</span><span class="sign">,</span> INTENT<span class="sign">(</span>IN<span class="sign">)</span> <span class="sign">:</span><span class="sign">:</span> fapl_id <span class="sign">!</span> Identifier <span class="keyword">for</span> file access property list + <span class="sign">!</span> with which to attempt to access the file LOGICAL<span class="sign">,</span> INTENT<span class="sign">(</span>OUT<span class="sign">)</span> <span class="sign">:</span><span class="sign">:</span> status <span class="sign">!</span> Indicates <span class="keyword">if</span> file <span class="sign">!</span> is an <a href="./HDF5_f90.html#robo76">HDF5</a> file INTEGER<span class="sign">,</span> INTENT<span class="sign">(</span>OUT<span class="sign">)</span> <span class="sign">:</span><span class="sign">:</span> hdferr <span class="sign">!</span> Error code diff --git a/fortran/doc/DevelGuide/toc_index.html b/fortran/doc/DevelGuide/toc_index.html index 94a2792..8460580 100644 --- a/fortran/doc/DevelGuide/toc_index.html +++ b/fortran/doc/DevelGuide/toc_index.html @@ -133,7 +133,7 @@ <li><a href="./src/H5Fff_f90.html#robo142">h5fget_name_f</a></li> <li><a href="./src/H5Fff_f90.html#robo143">h5fget_obj_count_f</a></li> <li><a href="./src/H5Fff_f90.html#robo144">h5fget_obj_ids_f</a></li> -<li><a href="./src/H5Fff_f90.html#robo145">h5fis_hdf5_f</a></li> +<li><a href="./src/H5Fff_f90.html#robo145">h5fis_accessible_f</a></li> <li><a href="./src/H5Fff_f90.html#robo146">h5fmount_f</a></li> <li><a href="./src/H5Fff_f90.html#robo147">h5fopen_f</a></li> <li><a href="./src/H5Fff_f90.html#robo148">h5freopen_f</a></li> diff --git a/fortran/src/H5Ff.c b/fortran/src/H5Ff.c index 4910aca..fbfb0b2 100644 --- a/fortran/src/H5Ff.c +++ b/fortran/src/H5Ff.c @@ -404,17 +404,18 @@ nh5fget_access_plist_c (hid_t_f *file_id, hid_t_f *access_id) return ret_value; } -/****if* H5Ff/h5fis_hdf5_c +/****if* H5Ff/h5fis_accessible_c * NAME - * h5fis_hdf5_c + * h5fis_accessible_c * PURPOSE - * Call H5Fis_hdf5 to determone if the file is an HDF5 file + * Call H5Fis_accessible to determone if the file is accessible with fapl * INPUTS * name - name of the file * namelen - name length + * acc_prp - identifier of access property list * OUTPUTS - * flag - 0 if file is not HDF5 file , positive if a file - * is an HDF5 file, and negative on failure. + * flag - 0 if file is not accessible , positive if a file + * is accessible, and negative on failure. * RETURNS * 0 on success, -1 on failure * AUTHOR @@ -425,14 +426,16 @@ nh5fget_access_plist_c (hid_t_f *file_id, hid_t_f *access_id) * SOURCE */ int_f -nh5fis_hdf5_c (_fcd name, int_f *namelen, int_f *flag) +nh5fis_accessible_c (_fcd name, int_f *namelen, hid_t_f *acc_prp, int_f *flag) /******/ { int ret_value = -1; char *c_name; int_f c_namelen; + hid_t c_acc_prp; htri_t status; + c_acc_prp = (hid_t)*acc_prp; /* * Convert FORTRAN name to C name */ @@ -443,7 +446,7 @@ nh5fis_hdf5_c (_fcd name, int_f *namelen, int_f *flag) /* * Call H5Fopen function. */ - status = H5Fis_hdf5(c_name); + status = H5Fis_accessible(c_name, c_acc_prp); *flag = (int_f)status; if (status >= 0) ret_value = 0; diff --git a/fortran/src/H5Fff.f90 b/fortran/src/H5Fff.f90 index faa1967..c3af8c4 100644 --- a/fortran/src/H5Fff.f90 +++ b/fortran/src/H5Fff.f90 @@ -494,19 +494,21 @@ CONTAINS END SUBROUTINE h5fget_access_plist_f -!****s* H5F/h5fis_hdf5_f +!****s* H5F/h5fis_accessible_f ! ! NAME -! h5fis_hdf5_f +! h5fis_accessible_f ! ! PURPOSE -! Determines whether a file is in the HDF5 format. +! Determines whether a file is accessible with the fapl. ! ! INPUTS ! name - name of the file to check ! OUTPUTS -! status - indicates if file is and HDF5 file +! status - indicates if file is accessible ! hdferr - Returns 0 if successful and -1 if fails +! OPTIONAL PARAMETERS +! access_prp - file access property list identifier ! AUTHOR ! Elena Pourmal ! August 12, 1999 @@ -517,36 +519,43 @@ CONTAINS ! port). February 28, 2001 ! ! SOURCE - SUBROUTINE h5fis_hdf5_f(name, status, hdferr) + SUBROUTINE h5fis_accessible_f(name, status, hdferr, access_prp) IMPLICIT NONE CHARACTER(LEN=*), INTENT(IN) :: name ! Name of the file LOGICAL, INTENT(OUT) :: status ! Indicates if file ! is an HDF5 file INTEGER, INTENT(OUT) :: hdferr ! Error code + INTEGER(HID_T), OPTIONAL, INTENT(IN) :: access_prp + ! File access property list + ! identifier !***** INTEGER :: namelen ! Length of the name character string + INTEGER(HID_T) :: access_prp_default INTEGER :: flag ! "TRUE/FALSE" flag from C routine ! to define status value. INTERFACE - INTEGER FUNCTION h5fis_hdf5_c(name, namelen, flag) + INTEGER FUNCTION h5fis_accessible_c(name, namelen, access_prp_default, flag) USE H5GLOBAL !DEC$IF DEFINED(HDF5F90_WINDOWS) - !DEC$ATTRIBUTES C,reference,decorate,alias:'H5FIS_HDF5_C':: h5fis_hdf5_c + !DEC$ATTRIBUTES C,reference,decorate,alias:'H5FIS_ACCESSIBLE_C':: h5fis_accessible_c !DEC$ENDIF !DEC$ATTRIBUTES reference :: name CHARACTER(LEN=*), INTENT(IN) :: name INTEGER :: namelen + INTEGER(HID_T), INTENT(IN) :: access_prp_default INTEGER :: flag - END FUNCTION h5fis_hdf5_c + END FUNCTION h5fis_accessible_c END INTERFACE namelen = LEN_TRIM(name) - hdferr = h5fis_hdf5_c(name, namelen, flag) + access_prp_default = H5P_DEFAULT_F + IF (PRESENT(access_prp)) access_prp_default = access_prp + hdferr = h5fis_accessible_c(name, namelen, access_prp_default, flag) status = .TRUE. IF (flag .EQ. 0) status = .FALSE. - END SUBROUTINE h5fis_hdf5_f + END SUBROUTINE h5fis_accessible_f !****s* H5F/h5fclose_f ! ! NAME diff --git a/fortran/src/H5f90proto.h b/fortran/src/H5f90proto.h index 34638ee..7c712d4 100644 --- a/fortran/src/H5f90proto.h +++ b/fortran/src/H5f90proto.h @@ -84,7 +84,7 @@ typedef struct H5O_info_t_f { #define nh5fflush_c H5_FC_FUNC_(h5fflush_c, H5FFLUSH_C) #define nh5fclose_c H5_FC_FUNC_(h5fclose_c, H5FCLOSE_C) #define nh5fopen_c H5_FC_FUNC_(h5fopen_c, H5FOPEN_C) -#define nh5fis_hdf5_c H5_FC_FUNC_(h5fis_hdf5_c, H5FIS_HDF5_C) +#define nh5fis_accessible_c H5_FC_FUNC_(h5fis_accessible_c, H5FIS_ACCESSIBLE_C) #define nh5fmount_c H5_FC_FUNC_(h5fmount_c, H5FMOUNT_C) #define nh5funmount_c H5_FC_FUNC_(h5funmount_c, H5FUNMOUNT_C) #define nh5freopen_c H5_FC_FUNC_(h5freopen_c, H5FREOPEN_C) @@ -99,7 +99,7 @@ typedef struct H5O_info_t_f { H5_FCDLL int_f nh5fcreate_c (_fcd name, int_f *namelen, int_f *access_flags, hid_t_f *crt_prp, hid_t_f *acc_prp, hid_t_f *file_id); H5_FCDLL int_f nh5fopen_c (_fcd name, int_f *namelen, int_f *access_flags, hid_t_f *acc_prp, hid_t_f *file_id); -H5_FCDLL int_f nh5fis_hdf5_c (_fcd name, int_f *namelen, int_f *flag); +H5_FCDLL int_f nh5fis_accessible_c (_fcd name, int_f *namelen, hid_t_f *acc_prp, int_f *flag); H5_FCDLL int_f nh5fclose_c (hid_t_f *file_id); H5_FCDLL int_f nh5fmount_c (hid_t_f *loc_id, _fcd dsetname, int_f *namelen, hid_t_f *file_id, hid_t_f *acc_prp); H5_FCDLL int_f nh5funmount_c (hid_t_f *loc_id, _fcd dsetname, int_f *namelen); diff --git a/fortran/src/hdf5_fortrandll.def.in b/fortran/src/hdf5_fortrandll.def.in index c9c5e76..b679aed 100644 --- a/fortran/src/hdf5_fortrandll.def.in +++ b/fortran/src/hdf5_fortrandll.def.in @@ -226,7 +226,7 @@ H5F_mp_H5FOPEN_F H5F_mp_H5FREOPEN_F H5F_mp_H5FGET_CREATE_PLIST_F H5F_mp_H5FGET_ACCESS_PLIST_F -H5F_mp_H5FIS_HDF5_F +H5F_mp_H5FIS_ACCESSIBLE_F H5F_mp_H5FGET_NAME_F H5F_mp_H5FGET_FILESIZE_F @H5_NOF03EXP@H5F_PROVISIONAL_mp_H5FGET_FILE_IMAGE_F diff --git a/fortran/test/tH5F.f90 b/fortran/test/tH5F.f90 index 931a046..6b62aea 100644 --- a/fortran/test/tH5F.f90 +++ b/fortran/test/tH5F.f90 @@ -196,15 +196,15 @@ CONTAINS ! !test whether files are in hdf5 format ! - CALL h5fis_hdf5_f(fix_filename1, status, error) - CALL check("h5fis_hdf5_f",error,total_error) + CALL h5fis_accessible_f(fix_filename1, status, error) + CALL check("h5fis_accessible_f",error,total_error) IF ( .NOT. status ) THEN write(*,*) "File ", fix_filename1, " is not in hdf5 format" stop END IF - CALL h5fis_hdf5_f(fix_filename2, status, error) - CALL check("h5fis_hdf5_f",error,total_error) + CALL h5fis_accessible_f(fix_filename2, status, error) + CALL check("h5fis_accessible_f",error,total_error) IF ( .NOT. status ) THEN write(*,*) "File ", fix_filename2, " is not in hdf5 format" stop diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index d5d57d4..c1df07b 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -159,6 +159,10 @@ set (H5EA_HDRS ) IDE_GENERATED_PROPERTIES ("H5EA" "${H5EA_HDRS}" "${H5EA_SRCS}" ) +set (H5ES_HDRS + ${HDF5_SRC_DIR}/H5ESpublic.h +) +IDE_GENERATED_PROPERTIES ("H5ES" "${H5ES_HDRS}" "" ) set (H5F_SRCS ${HDF5_SRC_DIR}/H5F.c @@ -610,6 +614,17 @@ set (H5VM_HDRS ) IDE_GENERATED_PROPERTIES ("H5VM" "${H5VM_HDRS}" "${H5VM_SRCS}" ) +SET (H5VL_SRCS + ${HDF5_SRC_DIR}/H5VL.c + ${HDF5_SRC_DIR}/H5VLint.c + ${HDF5_SRC_DIR}/H5VLnative.c +) +SET (H5VL_HDRS + ${HDF5_SRC_DIR}/H5VLpublic.h + ${HDF5_SRC_DIR}/H5VLpkg.h + ${HDF5_SRC_DIR}/H5VLnative.h +) +IDE_GENERATED_PROPERTIES ("H5VL" "${H5VL_HDRS}" "${H5VL_SRCS}" ) set (H5WB_SRCS ${HDF5_SRC_DIR}/H5WB.c @@ -681,6 +696,7 @@ set (common_SRCS ${H5T_SRCS} ${H5TS_SRCS} ${H5VM_SRCS} + ${H5VL_SRCS} ${H5WB_SRCS} ${H5Z_SRCS} ) @@ -715,6 +731,7 @@ set (H5_PUBLIC_HEADERS ${H5S_HDRS} ${H5SM_HDRS} ${H5T_HDRS} + ${H5VL_HDRS} ${H5Z_HDRS} ) @@ -760,6 +777,7 @@ set (H5_PRIVATE_HEADERS ${HDF5_SRC_DIR}/H5Tprivate.h ${HDF5_SRC_DIR}/H5TSprivate.h ${HDF5_SRC_DIR}/H5VMprivate.h + ${HDF5_SRC_DIR}/H5VLprivate.h ${HDF5_SRC_DIR}/H5WBprivate.h ${HDF5_SRC_DIR}/H5Zprivate.h ${HDF5_SRC_DIR}/H5win32defs.h @@ -31,7 +31,7 @@ #include "H5Pprivate.h" /* Property lists */ #include "H5Tprivate.h" /* Datatypes */ #include "H5SLprivate.h" /* Skip lists */ - +#include "H5VLprivate.h" /* Virtual Object Layer */ /****************/ /* Local Macros */ @@ -130,6 +130,7 @@ H5_init_library(void) H5_debug_g.pkg[H5_PKG_S].name = "s"; H5_debug_g.pkg[H5_PKG_T].name = "t"; H5_debug_g.pkg[H5_PKG_V].name = "v"; + H5_debug_g.pkg[H5_PKG_VL].name = "vl"; H5_debug_g.pkg[H5_PKG_Z].name = "z"; #ifdef H5_HAVE_MPE @@ -183,6 +184,8 @@ H5_init_library(void) */ if(H5E_init() < 0) HGOTO_ERROR(H5E_FUNC, H5E_CANTINIT, FAIL, "unable to initialize error interface") + if(H5VL_init() < 0) + HGOTO_ERROR(H5E_FUNC, H5E_CANTINIT, FAIL, "unable to initialize vol interface") if(H5P_init() < 0) HGOTO_ERROR(H5E_FUNC, H5E_CANTINIT, FAIL, "unable to initialize property list interface") if(H5T_init() < 0) @@ -281,6 +284,7 @@ H5_term_library(void) pending += DOWN(Z); pending += DOWN(FD); pending += DOWN(P); + pending += DOWN(VL); pending += DOWN(PL); /* Don't shut down the error code until other APIs which use it are shut down */ if(pending == 0) @@ -36,6 +36,7 @@ #include "H5Opkg.h" /* Object headers */ #include "H5Sprivate.h" /* Dataspace functions */ #include "H5SMprivate.h" /* Shared Object Header Messages */ +#include "H5VLprivate.h" /* VOL plugins */ /****************/ /* Local Macros */ @@ -92,7 +93,7 @@ static const H5I_class_t H5I_ATTR_CLS[1] = {{ H5I_ATTR, /* ID class value */ 0, /* Class flags */ 0, /* # of reserved IDs for class */ - (H5I_free_t)H5A_close /* Callback routine for closing objects of this class */ + (H5I_free_t)H5A_close_attr /* Callback routine for closing objects of this class */ }}; @@ -231,11 +232,11 @@ 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 UNUSED aapl_id) { - H5A_t *attr = NULL; /* Attribute created */ - H5G_loc_t loc; /* Object location */ - H5T_t *type; /* Datatype to use for attribute */ - H5S_t *space; /* Dataspace to use for attribute */ - hid_t ret_value; /* Return value */ + void *attr = NULL; /* attr token from VOL plugin */ + H5VL_object_t *obj = NULL; /* object token of loc_id */ + H5P_genplist_t *plist; /* Property list pointer */ + H5VL_loc_params_t loc_params; + hid_t ret_value; /* Return value */ FUNC_ENTER_API(FAIL) H5TRACE6("i", "i*siiii", loc_id, attr_name, type_id, space_id, acpl_id, aapl_id); @@ -243,29 +244,43 @@ H5Acreate2(hid_t loc_id, const char *attr_name, hid_t type_id, hid_t space_id, /* check arguments */ if(H5I_ATTR == H5I_get_type(loc_id)) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "location is not valid for an attribute") - if(H5G_loc(loc_id, &loc) < 0) - HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a location") - if(0 == (H5F_INTENT(loc.oloc->file) & H5F_ACC_RDWR)) - HGOTO_ERROR(H5E_ARGS, H5E_WRITEERROR, FAIL, "no write intent on file") if(!attr_name || !*attr_name) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "no attribute name") - if(NULL == (type = (H5T_t *)H5I_object_verify(type_id, H5I_DATATYPE))) - HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a type") - if(NULL == (space = (H5S_t *)H5I_object_verify(space_id, H5I_DATASPACE))) - HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a dataspace") - /* Go do the real work for attaching the attribute to the dataset */ - if(NULL == (attr = H5A_create(&loc, attr_name, type, space, acpl_id, H5AC_dxpl_id))) - HGOTO_ERROR(H5E_ATTR, H5E_CANTINIT, FAIL, "unable to create attribute") + /* Get correct property list */ + if(H5P_DEFAULT == acpl_id) + acpl_id = H5P_ATTRIBUTE_CREATE_DEFAULT; - /* Register the new attribute and get an ID for it */ - if((ret_value = H5I_register(H5I_ATTR, attr, TRUE)) < 0) - HGOTO_ERROR(H5E_ATOM, H5E_CANTREGISTER, FAIL, "unable to register attribute for ID") + /* Get the plist structure */ + if(NULL == (plist = (H5P_genplist_t *)H5I_object(acpl_id))) + HGOTO_ERROR(H5E_ATOM, H5E_BADATOM, FAIL, "can't find object for ID") + + /* set creation properties */ + if(H5P_set(plist, H5VL_PROP_ATTR_TYPE_ID, &type_id) < 0) + HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, FAIL, "can't set property value for datatype id") + if(H5P_set(plist, H5VL_PROP_ATTR_SPACE_ID, &space_id) < 0) + HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, FAIL, "can't set property value for space id") + + loc_params.type = H5VL_OBJECT_BY_SELF; + loc_params.obj_type = H5I_get_type(loc_id); + + /* get the location object */ + if(NULL == (obj = H5VL_get_object(loc_id))) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "invalid location identifier") + + /* Create the attribute through the VOL */ + if(NULL == (attr = H5VL_attr_create(obj->vol_obj, loc_params, obj->vol_info->vol_cls, attr_name, + acpl_id, aapl_id, H5AC_dxpl_id, H5_REQUEST_NULL))) + HGOTO_ERROR(H5E_SYM, H5E_CANTINIT, FAIL, "unable to create attribute") + + /* Get an atom for the attribute */ + if((ret_value = H5VL_register_id(H5I_ATTR, attr, obj->vol_info, TRUE)) < 0) + HGOTO_ERROR(H5E_ATOM, H5E_CANTREGISTER, FAIL, "unable to atomize attribute handle") done: - /* Cleanup on failure */ - if(ret_value < 0 && attr && H5A_close(attr) < 0) - HDONE_ERROR(H5E_ATTR, H5E_CANTFREE, FAIL, "can't close attribute") + if (ret_value < 0 && attr) + if(H5VL_attr_close(attr, obj->vol_info->vol_cls, H5AC_dxpl_id, H5_REQUEST_NULL) < 0) + HDONE_ERROR(H5E_ATTR, H5E_CLOSEERROR, FAIL, "unable to release attr") FUNC_LEAVE_API(ret_value) } /* H5Acreate2() */ @@ -304,18 +319,14 @@ done: /* ARGSUSED */ hid_t 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 UNUSED aapl_id, + hid_t type_id, hid_t space_id, hid_t acpl_id, hid_t aapl_id, hid_t lapl_id) { - H5A_t *attr = NULL; /* Attribute created */ - H5G_loc_t loc; /* Object location */ - 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 */ - hbool_t loc_found = FALSE; /* Entry at 'obj_name' found */ - H5T_t *type; /* Datatype to use for attribute */ - H5S_t *space; /* Dataspace to use for attribute */ - hid_t ret_value; /* Return value */ + void *attr = NULL; /* attr token from VOL plugin */ + H5VL_object_t *obj = NULL; /* object token of loc_id */ + H5P_genplist_t *plist; /* Property list pointer */ + H5VL_loc_params_t loc_params; + hid_t ret_value; /* Return value */ FUNC_ENTER_API(FAIL) H5TRACE8("i", "i*s*siiiii", loc_id, obj_name, attr_name, type_id, space_id, @@ -324,43 +335,47 @@ H5Acreate_by_name(hid_t loc_id, const char *obj_name, const char *attr_name, /* check arguments */ if(H5I_ATTR == H5I_get_type(loc_id)) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "location is not valid for an attribute") - if(H5G_loc(loc_id, &loc) < 0) - HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a location") - if(0 == (H5F_INTENT(loc.oloc->file) & H5F_ACC_RDWR)) - HGOTO_ERROR(H5E_ARGS, H5E_WRITEERROR, FAIL, "no write intent on file") if(!obj_name || !*obj_name) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "no object name") if(!attr_name || !*attr_name) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "no attribute name") - if(NULL == (type = (H5T_t *)H5I_object_verify(type_id, H5I_DATATYPE))) - HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a type") - if(NULL == (space = (H5S_t *)H5I_object_verify(space_id, H5I_DATASPACE))) - HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a dataspace") - - /* 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 */ - if(H5G_loc_find(&loc, obj_name, &obj_loc/*out*/, lapl_id, H5AC_ind_dxpl_id) < 0) - HGOTO_ERROR(H5E_ATTR, H5E_NOTFOUND, FAIL, "object not found") - loc_found = TRUE; - - /* Go do the real work for attaching the attribute to the dataset */ - if(NULL == (attr = H5A_create(&obj_loc, attr_name, type, space, acpl_id, H5AC_dxpl_id))) - HGOTO_ERROR(H5E_ATTR, H5E_CANTINIT, FAIL, "unable to create attribute") - - /* Register the new attribute and get an ID for it */ - if((ret_value = H5I_register(H5I_ATTR, attr, TRUE)) < 0) - HGOTO_ERROR(H5E_ATOM, H5E_CANTREGISTER, FAIL, "unable to register attribute for ID") -done: - /* Release resources */ - if(loc_found && H5G_loc_free(&obj_loc) < 0) - HDONE_ERROR(H5E_ATTR, H5E_CANTRELEASE, FAIL, "can't free location") - if(ret_value < 0 && attr && H5A_close(attr) < 0) - HDONE_ERROR(H5E_ATTR, H5E_CANTFREE, FAIL, "can't close attribute") + /* Get correct property list */ + if(H5P_DEFAULT == acpl_id) + acpl_id = H5P_ATTRIBUTE_CREATE_DEFAULT; + + /* Get the plist structure */ + if(NULL == (plist = (H5P_genplist_t *)H5I_object(acpl_id))) + HGOTO_ERROR(H5E_ATOM, H5E_BADATOM, FAIL, "can't find object for ID") + + /* set creation properties */ + if(H5P_set(plist, H5VL_PROP_ATTR_TYPE_ID, &type_id) < 0) + HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, FAIL, "can't set property value for datatype id") + if(H5P_set(plist, H5VL_PROP_ATTR_SPACE_ID, &space_id) < 0) + HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, FAIL, "can't set property value for space id") + + loc_params.type = H5VL_OBJECT_BY_NAME; + loc_params.obj_type = H5I_get_type(loc_id); + loc_params.loc_data.loc_by_name.name = obj_name; + loc_params.loc_data.loc_by_name.lapl_id = lapl_id; + + /* get the location object */ + if(NULL == (obj = H5VL_get_object(loc_id))) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "invalid location identifier") + + /* Create the attribute through the VOL */ + if(NULL == (attr = H5VL_attr_create(obj->vol_obj, loc_params, obj->vol_info->vol_cls, attr_name, + acpl_id, aapl_id, H5AC_dxpl_id, H5_REQUEST_NULL))) + HGOTO_ERROR(H5E_SYM, H5E_CANTINIT, FAIL, "unable to create attribute") + + /* Get an atom for the attribute */ + if((ret_value = H5VL_register_id(H5I_ATTR, attr, obj->vol_info, TRUE)) < 0) + HGOTO_ERROR(H5E_ATOM, H5E_CANTREGISTER, FAIL, "unable to atomize attribute handle") + +done: + if (ret_value < 0 && attr) + if(H5VL_attr_close (attr, obj->vol_info->vol_cls, H5AC_dxpl_id, H5_REQUEST_NULL) < 0) + HDONE_ERROR(H5E_ATTR, H5E_CLOSEERROR, FAIL, "unable to release attr") FUNC_LEAVE_API(ret_value) } /* H5Acreate_by_name() */ @@ -385,11 +400,12 @@ done: H5Aclose or resource leaks will develop. --------------------------------------------------------------------------*/ hid_t -H5Aopen(hid_t loc_id, const char *attr_name, hid_t UNUSED aapl_id) +H5Aopen(hid_t loc_id, const char *attr_name, hid_t aapl_id) { - H5G_loc_t loc; /* Object location */ - H5A_t *attr = NULL; /* Attribute opened */ - hid_t ret_value; + void *attr = NULL; /* attr token from VOL plugin */ + H5VL_object_t *obj = NULL; /* object token of loc_id */ + H5VL_loc_params_t loc_params; + hid_t ret_value; FUNC_ENTER_API(FAIL) H5TRACE3("i", "i*si", loc_id, attr_name, aapl_id); @@ -397,29 +413,29 @@ H5Aopen(hid_t loc_id, const char *attr_name, hid_t UNUSED aapl_id) /* check arguments */ if(H5I_ATTR == H5I_get_type(loc_id)) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "location is not valid for an attribute") - if(H5G_loc(loc_id, &loc) < 0) - HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a location") if(!attr_name || !*attr_name) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "no attribute name") - /* Read in attribute from object header */ - if(NULL == (attr = H5O_attr_open_by_name(loc.oloc, attr_name, H5AC_ind_dxpl_id))) - HGOTO_ERROR(H5E_ATTR, H5E_CANTINIT, FAIL, "unable to load attribute info from object header for attribute: '%s'", attr_name) + loc_params.type = H5VL_OBJECT_BY_SELF; + loc_params.obj_type = H5I_get_type(loc_id); - /* Finish initializing attribute */ - if(H5A_open_common(&loc, attr) < 0) - HGOTO_ERROR(H5E_ATTR, H5E_CANTINIT, FAIL, "unable to initialize attribute") + /* get the location object */ + if(NULL == (obj = H5VL_get_object(loc_id))) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "invalid location identifier") - /* Register the attribute and get an ID for it */ - if((ret_value = H5I_register(H5I_ATTR, attr, TRUE)) < 0) - HGOTO_ERROR(H5E_ATOM, H5E_CANTREGISTER, FAIL, "unable to register attribute for ID") + /* Open the attribute through the VOL */ + if(NULL == (attr = H5VL_attr_open(obj->vol_obj, loc_params, obj->vol_info->vol_cls, + attr_name, aapl_id, H5AC_ind_dxpl_id, H5_REQUEST_NULL))) + HGOTO_ERROR(H5E_SYM, H5E_CANTOPENOBJ, FAIL, "unable to open attribute") -done: - /* Cleanup on failure */ - if(ret_value < 0) - if(attr && H5A_close(attr) < 0) - HDONE_ERROR(H5E_ATTR, H5E_CANTFREE, FAIL, "can't close attribute") + /* Get an atom for the attribute */ + if((ret_value = H5VL_register_id(H5I_ATTR, attr, obj->vol_info, TRUE)) < 0) + HGOTO_ERROR(H5E_ATOM, H5E_CANTREGISTER, FAIL, "unable to atomize attribute handle") +done: + if (ret_value < 0 && attr) + if(H5VL_attr_close (attr, obj->vol_info->vol_cls, H5AC_dxpl_id, H5_REQUEST_NULL) < 0) + HDONE_ERROR(H5E_ATTR, H5E_CLOSEERROR, FAIL, "unable to release attr") FUNC_LEAVE_API(ret_value) } /* H5Aopen() */ @@ -447,11 +463,12 @@ done: --------------------------------------------------------------------------*/ hid_t H5Aopen_by_name(hid_t loc_id, const char *obj_name, const char *attr_name, - hid_t UNUSED aapl_id, hid_t lapl_id) + hid_t aapl_id, hid_t lapl_id) { - H5G_loc_t loc; /* Object location */ - H5A_t *attr = NULL; /* Attribute opened */ - hid_t ret_value; + void *attr = NULL; /* attr token from VOL plugin */ + H5VL_object_t *obj = NULL; /* object token of loc_id */ + H5VL_loc_params_t loc_params; + hid_t ret_value; FUNC_ENTER_API(FAIL) H5TRACE5("i", "i*s*sii", loc_id, obj_name, attr_name, aapl_id, lapl_id); @@ -459,8 +476,6 @@ H5Aopen_by_name(hid_t loc_id, const char *obj_name, const char *attr_name, /* check arguments */ if(H5I_ATTR == H5I_get_type(loc_id)) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "location is not valid for an attribute") - if(H5G_loc(loc_id, &loc) < 0) - HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a location") if(!obj_name || !*obj_name) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "no object name") if(!attr_name || !*attr_name) @@ -471,19 +486,28 @@ H5Aopen_by_name(hid_t loc_id, const char *obj_name, const char *attr_name, if(TRUE != H5P_isa_class(lapl_id, H5P_LINK_ACCESS)) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not link access property list ID") - /* Open the attribute on the object header */ - if(NULL == (attr = H5A_open_by_name(&loc, obj_name, attr_name, lapl_id, H5AC_ind_dxpl_id))) - HGOTO_ERROR(H5E_ATTR, H5E_CANTOPENOBJ, FAIL, "can't open attribute") + loc_params.type = H5VL_OBJECT_BY_NAME; + loc_params.loc_data.loc_by_name.name = obj_name; + loc_params.loc_data.loc_by_name.lapl_id = lapl_id; + loc_params.obj_type = H5I_get_type(loc_id); + + /* get the location object */ + if(NULL == (obj = H5VL_get_object(loc_id))) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "invalid location identifier") - /* Register the attribute and get an ID for it */ - if((ret_value = H5I_register(H5I_ATTR, attr, TRUE)) < 0) - HGOTO_ERROR(H5E_ATOM, H5E_CANTREGISTER, FAIL, "unable to register attribute for ID") + /* Open the attribute through the VOL */ + if(NULL == (attr = H5VL_attr_open(obj->vol_obj, loc_params, obj->vol_info->vol_cls, + attr_name, aapl_id, H5AC_ind_dxpl_id, H5_REQUEST_NULL))) + HGOTO_ERROR(H5E_SYM, H5E_CANTOPENOBJ, FAIL, "unable to open attribute") + + /* Get an atom for the attribute */ + if((ret_value = H5VL_register_id(H5I_ATTR, attr, obj->vol_info, TRUE)) < 0) + HGOTO_ERROR(H5E_ATOM, H5E_CANTREGISTER, FAIL, "unable to atomize attribute handle") done: - /* Cleanup on failure */ - if(ret_value < 0) - if(attr && H5A_close(attr) < 0) - HDONE_ERROR(H5E_ATTR, H5E_CANTFREE, FAIL, "can't close attribute") + if (ret_value < 0 && attr) + if(H5VL_attr_close (attr, obj->vol_info->vol_cls, H5AC_dxpl_id, H5_REQUEST_NULL) < 0) + HDONE_ERROR(H5E_ATTR, H5E_CLOSEERROR, FAIL, "unable to release attr") FUNC_LEAVE_API(ret_value) } /* H5Aopen_by_name() */ @@ -515,11 +539,12 @@ done: --------------------------------------------------------------------------*/ hid_t H5Aopen_by_idx(hid_t loc_id, const char *obj_name, H5_index_t idx_type, - H5_iter_order_t order, hsize_t n, hid_t UNUSED aapl_id, hid_t lapl_id) + H5_iter_order_t order, hsize_t n, hid_t aapl_id, hid_t lapl_id) { - H5A_t *attr = NULL; /* Attribute opened */ - H5G_loc_t loc; /* Object location */ - hid_t ret_value; /* Return value */ + void *attr = NULL; /* attr token from VOL plugin */ + H5VL_object_t *obj = NULL; /* object token of loc_id */ + H5VL_loc_params_t loc_params; + hid_t ret_value; /* Return value */ FUNC_ENTER_API(FAIL) H5TRACE7("i", "i*sIiIohii", loc_id, obj_name, idx_type, order, n, aapl_id, @@ -528,8 +553,6 @@ H5Aopen_by_idx(hid_t loc_id, const char *obj_name, H5_index_t idx_type, /* check arguments */ if(H5I_ATTR == H5I_get_type(loc_id)) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "location is not valid for an attribute") - if(H5G_loc(loc_id, &loc) < 0) - HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a location") if(!obj_name || !*obj_name) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "no object name") if(idx_type <= H5_INDEX_UNKNOWN || idx_type >= H5_INDEX_N) @@ -542,20 +565,31 @@ H5Aopen_by_idx(hid_t loc_id, const char *obj_name, H5_index_t idx_type, if(TRUE != H5P_isa_class(lapl_id, H5P_LINK_ACCESS)) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not link access property list ID") - /* Open the attribute in the object header */ - if(NULL == (attr = H5A_open_by_idx(&loc, obj_name, idx_type, order, n, lapl_id, H5AC_ind_dxpl_id))) - HGOTO_ERROR(H5E_ATTR, H5E_CANTOPENOBJ, FAIL, "unable to open attribute") + loc_params.type = H5VL_OBJECT_BY_IDX; + loc_params.loc_data.loc_by_idx.name = obj_name; + loc_params.loc_data.loc_by_idx.idx_type = idx_type; + loc_params.loc_data.loc_by_idx.order = order; + loc_params.loc_data.loc_by_idx.n = n; + loc_params.loc_data.loc_by_idx.lapl_id = lapl_id; + loc_params.obj_type = H5I_get_type(loc_id); - /* Register the attribute and get an ID for it */ - if((ret_value = H5I_register(H5I_ATTR, attr, TRUE)) < 0) - HGOTO_ERROR(H5E_ATOM, H5E_CANTREGISTER, FAIL, "unable to register attribute for ID") + /* get the location object */ + if(NULL == (obj = H5VL_get_object(loc_id))) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "invalid location identifier") -done: - /* Cleanup on failure */ - if(ret_value < 0) - if(attr && H5A_close(attr) < 0) - HDONE_ERROR(H5E_ATTR, H5E_CANTFREE, FAIL, "can't close attribute") + /* Open the attribute through the VOL */ + if(NULL == (attr = H5VL_attr_open(obj->vol_obj, loc_params, obj->vol_info->vol_cls, + NULL, aapl_id, H5AC_ind_dxpl_id, H5_REQUEST_NULL))) + HGOTO_ERROR(H5E_SYM, H5E_CANTOPENOBJ, FAIL, "unable to open attribute") + /* Get an atom for the attribute */ + if((ret_value = H5VL_register_id(H5I_ATTR, attr, obj->vol_info, TRUE)) < 0) + HGOTO_ERROR(H5E_ATOM, H5E_CANTREGISTER, FAIL, "unable to atomize attribute handle") + +done: + if (ret_value < 0 && attr) + if(H5VL_attr_close (attr, obj->vol_info->vol_cls, H5AC_dxpl_id, H5_REQUEST_NULL) < 0) + HDONE_ERROR(H5E_ATTR, H5E_CLOSEERROR, FAIL, "unable to release attr") FUNC_LEAVE_API(ret_value) } /* H5Aopen_by_idx() */ @@ -579,24 +613,22 @@ done: herr_t H5Awrite(hid_t attr_id, hid_t dtype_id, const void *buf) { - H5A_t *attr; /* Attribute object for ID */ - H5T_t *mem_type; /* Memory datatype */ + H5VL_object_t *attr; herr_t ret_value; /* Return value */ FUNC_ENTER_API(FAIL) H5TRACE3("e", "ii*x", attr_id, dtype_id, buf); /* check arguments */ - if(NULL == (attr = (H5A_t *)H5I_object_verify(attr_id, H5I_ATTR))) + if(NULL == (attr = (H5VL_object_t *)H5I_object_verify(attr_id, H5I_ATTR))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not an attribute") - if(NULL == (mem_type = (H5T_t *)H5I_object_verify(dtype_id, H5I_DATATYPE))) - HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a datatype") if(NULL == buf) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "null attribute buffer") - /* Go write the actual data to the attribute */ - if((ret_value = H5A_write(attr, mem_type, buf, H5AC_dxpl_id)) < 0) - HGOTO_ERROR(H5E_ATTR, H5E_WRITEERROR, FAIL, "unable to write attribute") + /* write the data through the VOL */ + if((ret_value = H5VL_attr_write(attr->vol_obj, attr->vol_info->vol_cls, + dtype_id, buf, H5AC_dxpl_id, H5_REQUEST_NULL)) < 0) + HGOTO_ERROR(H5E_ATTR, H5E_READERROR, FAIL, "can't read data") done: FUNC_LEAVE_API(ret_value) @@ -622,24 +654,22 @@ done: herr_t H5Aread(hid_t attr_id, hid_t dtype_id, void *buf) { - H5A_t *attr; /* Attribute object for ID */ - H5T_t *mem_type; /* Memory datatype */ + H5VL_object_t *attr; herr_t ret_value; /* Return value */ FUNC_ENTER_API(FAIL) H5TRACE3("e", "ii*x", attr_id, dtype_id, buf); /* check arguments */ - if(NULL == (attr = (H5A_t *)H5I_object_verify(attr_id, H5I_ATTR))) + if(NULL == (attr = (H5VL_object_t *)H5I_object_verify(attr_id, H5I_ATTR))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not an attribute") - if(NULL == (mem_type = (H5T_t *)H5I_object_verify(dtype_id, H5I_DATATYPE))) - HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a datatype") if(NULL == buf) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "null attribute buffer") - /* Go write the actual data to the attribute */ - if((ret_value = H5A_read(attr, mem_type, buf, H5AC_dxpl_id)) < 0) - HGOTO_ERROR(H5E_ATTR, H5E_READERROR, FAIL, "unable to read attribute") + /* Read the data through the VOL */ + if((ret_value = H5VL_attr_read(attr->vol_obj, attr->vol_info->vol_cls, + dtype_id, buf, H5AC_dxpl_id, H5_REQUEST_NULL)) < 0) + HGOTO_ERROR(H5E_ATTR, H5E_READERROR, FAIL, "can't read data") done: FUNC_LEAVE_API(ret_value) @@ -665,18 +695,20 @@ done: hid_t H5Aget_space(hid_t attr_id) { - H5A_t *attr; /* Attribute object for ID */ + H5VL_object_t *attr; hid_t ret_value; FUNC_ENTER_API(FAIL) H5TRACE1("i", "i", attr_id); /* check arguments */ - if(NULL == (attr = (H5A_t *)H5I_object_verify(attr_id, H5I_ATTR))) + if(NULL == (attr = (H5VL_object_t *)H5I_object_verify(attr_id, H5I_ATTR))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not an attribute") - if((ret_value = H5A_get_space(attr)) < 0) - HGOTO_ERROR(H5E_ARGS, H5E_CANTGET, FAIL, "can't get space ID of attribute") + /* get the dataspace through the VOL */ + if(H5VL_attr_get(attr->vol_obj, attr->vol_info->vol_cls, H5VL_ATTR_GET_SPACE, + H5AC_dxpl_id, H5_REQUEST_NULL, &ret_value) < 0) + HGOTO_ERROR(H5E_INTERNAL, H5E_CANTGET, FAIL, "unable to get data space") done: FUNC_LEAVE_API(ret_value) @@ -702,18 +734,20 @@ done: hid_t H5Aget_type(hid_t attr_id) { - H5A_t *attr; /* Attribute object for ID */ + H5VL_object_t *attr; hid_t ret_value; /* Return value */ FUNC_ENTER_API(FAIL) H5TRACE1("i", "i", attr_id); /* check arguments */ - if(NULL == (attr = (H5A_t *)H5I_object_verify(attr_id, H5I_ATTR))) + if(NULL == (attr = (H5VL_object_t *)H5I_object_verify(attr_id, H5I_ATTR))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not an attribute") - if((ret_value = H5A_get_type(attr)) < 0) - HGOTO_ERROR(H5E_ARGS, H5E_CANTGET, FAIL, "can't get space ID of attribute") + /* get the datatype through the VOL */ + if(H5VL_attr_get(attr->vol_obj, attr->vol_info->vol_cls, H5VL_ATTR_GET_TYPE, + H5AC_dxpl_id, H5_REQUEST_NULL, &ret_value) < 0) + HGOTO_ERROR(H5E_INTERNAL, H5E_CANTGET, FAIL, "unable to get type") done: FUNC_LEAVE_API(ret_value) @@ -742,20 +776,22 @@ done: hid_t H5Aget_create_plist(hid_t attr_id) { - H5A_t *attr; /* Attribute object for ID */ - hid_t ret_value; + H5VL_object_t *attr; + hid_t ret_value; FUNC_ENTER_API(FAIL) H5TRACE1("i", "i", attr_id); HDassert(H5P_LST_ATTRIBUTE_CREATE_ID_g != -1); - /* Get attribute and default attribute creation property list*/ - if(NULL == (attr = (H5A_t *)H5I_object_verify(attr_id, H5I_ATTR))) - HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not an attribute") + /* check arguments */ + if(NULL == (attr = (H5VL_object_t *)H5I_object_verify(attr_id, H5I_ATTR))) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not an attribute") - if((ret_value = H5A_get_create_plist(attr)) < 0) - HGOTO_ERROR(H5E_ARGS, H5E_CANTGET, FAIL, "can't get creation property list for attr") + /* get the acpl through the VOL */ + if(H5VL_attr_get(attr->vol_obj, attr->vol_info->vol_cls, H5VL_ATTR_GET_ACPL, + H5AC_dxpl_id, H5_REQUEST_NULL, &ret_value) < 0) + HGOTO_ERROR(H5E_INTERNAL, H5E_CANTGET, FAIL, "unable to get acpl") done: FUNC_LEAVE_API(ret_value) @@ -786,21 +822,27 @@ done: ssize_t H5Aget_name(hid_t attr_id, size_t buf_size, char *buf) { - H5A_t *my_attr; /* Attribute object for ID */ - ssize_t ret_value; + H5VL_object_t *attr; + H5VL_loc_params_t loc_params; + ssize_t ret_value; FUNC_ENTER_API(FAIL) H5TRACE3("Zs", "iz*s", attr_id, buf_size, buf); /* check arguments */ - if(NULL == (my_attr = (H5A_t *)H5I_object_verify(attr_id, H5I_ATTR))) + if(NULL == (attr = (H5VL_object_t *)H5I_object_verify(attr_id, H5I_ATTR))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not an attribute") if(!buf && buf_size) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "invalid buffer") - /* Call private function in turn */ - if(0 > (ret_value = H5A_get_name(my_attr, buf_size, buf))) - HGOTO_ERROR(H5E_ATTR, H5E_CANTGET, FAIL, "can't get attribute name") + loc_params.type = H5VL_OBJECT_BY_SELF; + loc_params.obj_type = H5I_get_type(attr_id); + + /* get the name through the VOL */ + if(H5VL_attr_get(attr->vol_obj, attr->vol_info->vol_cls, H5VL_ATTR_GET_NAME, + H5AC_ind_dxpl_id, H5_REQUEST_NULL, + loc_params, buf_size, buf, &ret_value) < 0) + HGOTO_ERROR(H5E_INTERNAL, H5E_CANTGET, FAIL, "unable to get name") done: FUNC_LEAVE_API(ret_value) @@ -829,8 +871,8 @@ H5Aget_name_by_idx(hid_t loc_id, const char *obj_name, H5_index_t idx_type, H5_iter_order_t order, hsize_t n, char *name /*out*/, size_t size, hid_t lapl_id) { - H5G_loc_t loc; /* Object location */ - H5A_t *attr = NULL; /* Attribute object for name */ + H5VL_object_t *obj; + H5VL_loc_params_t loc_params; ssize_t ret_value; /* Return value */ FUNC_ENTER_API(FAIL) @@ -840,8 +882,6 @@ H5Aget_name_by_idx(hid_t loc_id, const char *obj_name, H5_index_t idx_type, /* Check args */ if(H5I_ATTR == H5I_get_type(loc_id)) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "location is not valid for an attribute") - if(H5G_loc(loc_id, &loc) < 0) - HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a location") if(!obj_name || !*obj_name) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "no name") if(idx_type <= H5_INDEX_UNKNOWN || idx_type >= H5_INDEX_N) @@ -854,25 +894,24 @@ H5Aget_name_by_idx(hid_t loc_id, const char *obj_name, H5_index_t idx_type, if(TRUE != H5P_isa_class(lapl_id, H5P_LINK_ACCESS)) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not link access property list ID") - /* Open the attribute on the object header */ - if(NULL == (attr = H5A_open_by_idx(&loc, obj_name, idx_type, order, n, lapl_id, H5AC_ind_dxpl_id))) - HGOTO_ERROR(H5E_ATTR, H5E_CANTOPENOBJ, FAIL, "can't open attribute") + /* get the object */ + if(NULL == (obj = H5VL_get_object(loc_id))) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "invalid object identifier") - /* Get the length of the name */ - ret_value = (ssize_t)HDstrlen(attr->shared->name); + loc_params.type = H5VL_OBJECT_BY_IDX; + loc_params.loc_data.loc_by_idx.name = obj_name; + loc_params.loc_data.loc_by_idx.idx_type = idx_type; + loc_params.loc_data.loc_by_idx.order = order; + loc_params.loc_data.loc_by_idx.n = n; + loc_params.loc_data.loc_by_idx.lapl_id = lapl_id; + loc_params.obj_type = H5I_get_type(loc_id); - /* Copy the name into the user's buffer, if given */ - if(name) { - HDstrncpy(name, attr->shared->name, MIN((size_t)(ret_value + 1), size)); - if((size_t)ret_value >= size) - name[size - 1]='\0'; - } /* end if */ + /* get the name through the VOL */ + if(H5VL_attr_get(obj->vol_obj, obj->vol_info->vol_cls, H5VL_ATTR_GET_NAME, + H5AC_ind_dxpl_id, H5_REQUEST_NULL, loc_params, size, name, &ret_value) < 0) + HGOTO_ERROR(H5E_INTERNAL, H5E_CANTGET, FAIL, "unable to get name") done: - /* Release resources */ - if(attr && H5A_close(attr) < 0) - HDONE_ERROR(H5E_ATTR, H5E_CANTFREE, FAIL, "can't close attribute") - FUNC_LEAVE_API(ret_value) } /* end H5Aget_name_by_idx() */ @@ -897,18 +936,20 @@ done: hsize_t H5Aget_storage_size(hid_t attr_id) { - H5A_t *attr; /* Attribute object for ID */ + H5VL_object_t *attr; hsize_t ret_value; /* Return value */ FUNC_ENTER_API(0) H5TRACE1("h", "i", attr_id); - /* Check args */ - if(NULL == (attr = (H5A_t *)H5I_object_verify(attr_id, H5I_ATTR))) + /* check arguments */ + if(NULL == (attr = (H5VL_object_t *)H5I_object_verify(attr_id, H5I_ATTR))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, 0, "not an attribute") - /* Set return value */ - ret_value = attr->shared->data_size; + /* get the storage size through the VOL */ + if(H5VL_attr_get(attr->vol_obj, attr->vol_info->vol_cls, H5VL_ATTR_GET_STORAGE_SIZE, + H5AC_dxpl_id, H5_REQUEST_NULL, &ret_value) < 0) + HGOTO_ERROR(H5E_INTERNAL, H5E_CANTGET, 0, "unable to get acpl") done: FUNC_LEAVE_API(ret_value) @@ -931,19 +972,24 @@ done: herr_t H5Aget_info(hid_t attr_id, H5A_info_t *ainfo) { - H5A_t *attr; /* Attribute object for name */ + H5VL_object_t *attr; + H5VL_loc_params_t loc_params; herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_API(FAIL) H5TRACE2("e", "i*x", attr_id, ainfo); - /* Check args */ - if(NULL == (attr = (H5A_t *)H5I_object_verify(attr_id, H5I_ATTR))) + /* check arguments */ + if(NULL == (attr = (H5VL_object_t *)H5I_object_verify(attr_id, H5I_ATTR))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not an attribute") - /* Get the attribute information */ - if(H5A_get_info(attr, ainfo) < 0) - HGOTO_ERROR(H5E_ATTR, H5E_CANTGET, FAIL, "unable to get attribute info") + loc_params.type = H5VL_OBJECT_BY_SELF; + loc_params.obj_type = H5I_get_type(attr_id); + + /* get the attribute info through the VOL */ + if(H5VL_attr_get(attr->vol_obj, attr->vol_info->vol_cls, H5VL_ATTR_GET_INFO, + H5AC_ind_dxpl_id, H5_REQUEST_NULL, loc_params, ainfo) < 0) + HGOTO_ERROR(H5E_INTERNAL, H5E_CANTGET, FAIL, "unable to get attribute info") done: FUNC_LEAVE_API(ret_value) @@ -967,8 +1013,8 @@ herr_t H5Aget_info_by_name(hid_t loc_id, const char *obj_name, const char *attr_name, H5A_info_t *ainfo, hid_t lapl_id) { - H5G_loc_t loc; /* Object location */ - H5A_t *attr = NULL; /* Attribute object for name */ + H5VL_object_t *obj; + H5VL_loc_params_t loc_params; herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_API(FAIL) @@ -977,8 +1023,6 @@ H5Aget_info_by_name(hid_t loc_id, const char *obj_name, const char *attr_name, /* Check args */ if(H5I_ATTR == H5I_get_type(loc_id)) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "location is not valid for an attribute") - if(H5G_loc(loc_id, &loc) < 0) - HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a location") if(!obj_name || !*obj_name) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "no object name") if(!attr_name || !*attr_name) @@ -991,19 +1035,21 @@ H5Aget_info_by_name(hid_t loc_id, const char *obj_name, const char *attr_name, if(TRUE != H5P_isa_class(lapl_id, H5P_LINK_ACCESS)) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not link access property list ID") - /* Open the attribute on the object header */ - if(NULL == (attr = H5A_open_by_name(&loc, obj_name, attr_name, lapl_id, H5AC_ind_dxpl_id))) - HGOTO_ERROR(H5E_ATTR, H5E_CANTOPENOBJ, FAIL, "can't open attribute") + loc_params.type = H5VL_OBJECT_BY_NAME; + loc_params.loc_data.loc_by_name.name = obj_name; + loc_params.loc_data.loc_by_name.lapl_id = lapl_id; + loc_params.obj_type = H5I_get_type(loc_id); - /* Get the attribute information */ - if(H5A_get_info(attr, ainfo) < 0) - HGOTO_ERROR(H5E_ATTR, H5E_CANTGET, FAIL, "unable to get attribute info") + /* get the object */ + if(NULL == (obj = H5VL_get_object(loc_id))) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "invalid object identifier") -done: - /* Cleanup on failure */ - if(attr && H5A_close(attr) < 0) - HDONE_ERROR(H5E_ATTR, H5E_CANTFREE, FAIL, "can't close attribute") + /* get the attribute info through the VOL */ + if(H5VL_attr_get(obj->vol_obj, obj->vol_info->vol_cls, H5VL_ATTR_GET_INFO, + H5AC_ind_dxpl_id, H5_REQUEST_NULL, loc_params, ainfo, attr_name) < 0) + HGOTO_ERROR(H5E_INTERNAL, H5E_CANTGET, FAIL, "unable to get attribute info") +done: FUNC_LEAVE_API(ret_value) } /* end H5Aget_info_by_name() */ @@ -1026,8 +1072,8 @@ herr_t H5Aget_info_by_idx(hid_t loc_id, const char *obj_name, H5_index_t idx_type, H5_iter_order_t order, hsize_t n, H5A_info_t *ainfo, hid_t lapl_id) { - H5G_loc_t loc; /* Object location */ - H5A_t *attr = NULL; /* Attribute object for name */ + H5VL_object_t *obj; + H5VL_loc_params_t loc_params; herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_API(FAIL) @@ -1037,8 +1083,6 @@ H5Aget_info_by_idx(hid_t loc_id, const char *obj_name, H5_index_t idx_type, /* Check args */ if(H5I_ATTR == H5I_get_type(loc_id)) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "location is not valid for an attribute") - if(H5G_loc(loc_id, &loc) < 0) - HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a location") if(!obj_name || !*obj_name) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "no name") if(idx_type <= H5_INDEX_UNKNOWN || idx_type >= H5_INDEX_N) @@ -1053,19 +1097,24 @@ H5Aget_info_by_idx(hid_t loc_id, const char *obj_name, H5_index_t idx_type, if(TRUE != H5P_isa_class(lapl_id, H5P_LINK_ACCESS)) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not link access property list ID") - /* Open the attribute on the object header */ - if(NULL == (attr = H5A_open_by_idx(&loc, obj_name, idx_type, order, n, lapl_id, H5AC_ind_dxpl_id))) - HGOTO_ERROR(H5E_ATTR, H5E_CANTOPENOBJ, FAIL, "can't open attribute") + loc_params.type = H5VL_OBJECT_BY_IDX; + loc_params.loc_data.loc_by_idx.name = obj_name; + loc_params.loc_data.loc_by_idx.idx_type = idx_type; + loc_params.loc_data.loc_by_idx.order = order; + loc_params.loc_data.loc_by_idx.n = n; + loc_params.loc_data.loc_by_idx.lapl_id = lapl_id; + loc_params.obj_type = H5I_get_type(loc_id); - /* Get the attribute information */ - if(H5A_get_info(attr, ainfo) < 0) - HGOTO_ERROR(H5E_ATTR, H5E_CANTGET, FAIL, "unable to get attribute info") + /* get the object */ + if(NULL == (obj = H5VL_get_object(loc_id))) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "invalid object identifier") -done: - /* Release resources */ - if(attr && H5A_close(attr) < 0) - HDONE_ERROR(H5E_ATTR, H5E_CANTFREE, FAIL, "can't close attribute") + /* get the attribute info through the VOL */ + if(H5VL_attr_get(obj->vol_obj, obj->vol_info->vol_cls, H5VL_ATTR_GET_INFO, + H5AC_ind_dxpl_id, H5_REQUEST_NULL, loc_params, ainfo) < 0) + HGOTO_ERROR(H5E_INTERNAL, H5E_CANTGET, FAIL, "unable to get attribute info") +done: FUNC_LEAVE_API(ret_value) } /* end H5Aget_info_by_idx() */ @@ -1099,16 +1148,21 @@ H5Arename(hid_t loc_id, const char *old_name, const char *new_name) /* Avoid thrashing things if the names are the same */ if(HDstrcmp(old_name, new_name)) { - H5G_loc_t loc; /* Object location */ - - if(H5G_loc(loc_id, & loc) < 0) - HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a location") + H5VL_object_t *obj; + H5VL_loc_params_t loc_params; - /* Call private attribute rename routine */ - if(H5O_attr_rename(loc.oloc, H5AC_dxpl_id, old_name, new_name) < 0) - HGOTO_ERROR(H5E_ATTR, H5E_CANTRENAME, FAIL, "can't rename attribute") - } /* end if */ + loc_params.type = H5VL_OBJECT_BY_SELF; + loc_params.obj_type = H5I_get_type(loc_id); + /* get the location object */ + if(NULL == (obj = H5VL_get_object(loc_id))) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "invalid location identifier") + + /* rename the attribute info through the VOL */ + if((ret_value = H5VL_attr_specific(obj->vol_obj, loc_params, obj->vol_info->vol_cls, H5VL_ATTR_RENAME, + H5AC_dxpl_id, H5_REQUEST_NULL, old_name, new_name)) < 0) + HGOTO_ERROR(H5E_ATTR, H5E_CANTRENAME, FAIL, "can't rename attribute") + } done: FUNC_LEAVE_API(ret_value) } /* H5Arename() */ @@ -1154,13 +1208,21 @@ H5Arename_by_name(hid_t loc_id, const char *obj_name, const char *old_attr_name, /* Avoid thrashing things if the names are the same */ if(HDstrcmp(old_attr_name, new_attr_name)) { - H5G_loc_t loc; /* Object location */ + H5VL_object_t *obj; + H5VL_loc_params_t loc_params; + + loc_params.type = H5VL_OBJECT_BY_NAME; + loc_params.loc_data.loc_by_name.name = obj_name; + loc_params.loc_data.loc_by_name.lapl_id = lapl_id; + loc_params.obj_type = H5I_get_type(loc_id); - if(H5G_loc(loc_id, & loc) < 0) - HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a location") + /* get the location object */ + if(NULL == (obj = H5VL_get_object(loc_id))) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "invalid location identifier") - /* Call private attribute rename routine */ - if(H5A_rename_by_name(loc, obj_name, old_attr_name, new_attr_name, lapl_id) < 0) + /* rename the attribute info through the VOL */ + if((ret_value = H5VL_attr_specific(obj->vol_obj, loc_params, obj->vol_info->vol_cls, H5VL_ATTR_RENAME, + H5AC_dxpl_id, H5_REQUEST_NULL, old_attr_name, new_attr_name)) < 0) HGOTO_ERROR(H5E_ATTR, H5E_CANTRENAME, FAIL, "can't rename attribute") } /* end if */ @@ -1214,9 +1276,8 @@ herr_t H5Aiterate2(hid_t loc_id, H5_index_t idx_type, H5_iter_order_t order, hsize_t *idx, H5A_operator2_t op, void *op_data) { - H5A_attr_iter_op_t attr_op; /* Attribute operator */ - hsize_t start_idx; /* Index of attribute to start iterating at */ - hsize_t last_attr; /* Index of last attribute examined */ + H5VL_object_t *obj = NULL; /* object token of loc_id */ + H5VL_loc_params_t loc_params; herr_t ret_value; /* Return value */ FUNC_ENTER_API(FAIL) @@ -1230,18 +1291,18 @@ H5Aiterate2(hid_t loc_id, H5_index_t idx_type, H5_iter_order_t order, if(order <= H5_ITER_UNKNOWN || order >= H5_ITER_N) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "invalid iteration order specified") - /* Build attribute operator info */ - attr_op.op_type = H5A_ATTR_OP_APP2; - attr_op.u.app_op2 = op; + loc_params.type = H5VL_OBJECT_BY_SELF; + loc_params.obj_type = H5I_get_type(loc_id); - /* Call attribute iteration routine */ - last_attr = start_idx = (idx ? *idx : 0); - if((ret_value = H5O_attr_iterate(loc_id, H5AC_ind_dxpl_id, idx_type, order, start_idx, &last_attr, &attr_op, op_data)) < 0) - HERROR(H5E_ATTR, H5E_BADITER, "error iterating over attributes"); + /* get the loc object */ + if(NULL == (obj = H5VL_get_object(loc_id))) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "invalid location identifier") - /* Set the last attribute information */ - if(idx) - *idx = last_attr; + /* iterate over the links through the VOL */ + if((ret_value = H5VL_attr_specific(obj->vol_obj, loc_params, obj->vol_info->vol_cls, H5VL_ATTR_ITER, + H5AC_dxpl_id, H5_REQUEST_NULL, + idx_type, order, idx, op, op_data)) < 0) + HGOTO_ERROR(H5E_SYM, H5E_BADITER, FAIL, "attribute iteration failed") done: FUNC_LEAVE_API(ret_value) @@ -1296,16 +1357,9 @@ H5Aiterate_by_name(hid_t loc_id, const char *obj_name, H5_index_t idx_type, H5_iter_order_t order, hsize_t *idx, H5A_operator2_t op, void *op_data, hid_t lapl_id) { - H5G_loc_t loc; /* Object location */ - 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 */ - hbool_t loc_found = FALSE; /* Entry at 'obj_name' found */ - hid_t obj_loc_id = (-1); /* ID for object located */ - H5A_attr_iter_op_t attr_op; /* Attribute operator */ - hsize_t start_idx; /* Index of attribute to start iterating at */ - hsize_t last_attr; /* Index of last attribute examined */ - herr_t ret_value; /* Return value */ + H5VL_object_t *obj = NULL; /* object token of loc_id */ + H5VL_loc_params_t loc_params; + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_API(FAIL) H5TRACE8("e", "i*sIiIo*hx*xi", loc_id, obj_name, idx_type, order, idx, op, @@ -1314,8 +1368,6 @@ H5Aiterate_by_name(hid_t loc_id, const char *obj_name, H5_index_t idx_type, /* check arguments */ if(H5I_ATTR == H5I_get_type(loc_id)) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "location is not valid for an attribute") - if(H5G_loc(loc_id, &loc) < 0) - HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a location") if(!obj_name || !*obj_name) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "no object name") if(idx_type <= H5_INDEX_UNKNOWN || idx_type >= H5_INDEX_N) @@ -1328,42 +1380,22 @@ H5Aiterate_by_name(hid_t loc_id, const char *obj_name, H5_index_t idx_type, if(TRUE != H5P_isa_class(lapl_id, H5P_LINK_ACCESS)) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not link access property list ID") - /* 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 */ - if(H5G_loc_find(&loc, obj_name, &obj_loc/*out*/, lapl_id, H5AC_ind_dxpl_id) < 0) - HGOTO_ERROR(H5E_ATTR, H5E_NOTFOUND, FAIL, "object not found") - loc_found = TRUE; + loc_params.type = H5VL_OBJECT_BY_NAME; + loc_params.obj_type = H5I_get_type(loc_id); + loc_params.loc_data.loc_by_name.name = obj_name; + loc_params.loc_data.loc_by_name.lapl_id = lapl_id; - /* Open the object */ - if((obj_loc_id = H5O_open_by_loc(&obj_loc, lapl_id, H5AC_ind_dxpl_id, TRUE)) < 0) - HGOTO_ERROR(H5E_ATTR, H5E_CANTOPENOBJ, FAIL, "unable to open object") + /* get the loc object */ + if(NULL == (obj = H5VL_get_object(loc_id))) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "invalid location identifier") - /* Build attribute operator info */ - attr_op.op_type = H5A_ATTR_OP_APP2; - attr_op.u.app_op2 = op; - - /* Call attribute iteration routine */ - last_attr = start_idx = (idx ? *idx : 0); - if((ret_value = H5O_attr_iterate(obj_loc_id, H5AC_ind_dxpl_id, idx_type, order, start_idx, &last_attr, &attr_op, op_data)) < 0) - HERROR(H5E_ATTR, H5E_BADITER, "error iterating over attributes"); - - /* Set the last attribute information */ - if(idx) - *idx = last_attr; + /* iterate over the links through the VOL */ + if((ret_value = H5VL_attr_specific(obj->vol_obj, loc_params, obj->vol_info->vol_cls, H5VL_ATTR_ITER, + H5AC_dxpl_id, H5_REQUEST_NULL, + idx_type, order, idx, op, op_data)) < 0) + HGOTO_ERROR(H5E_SYM, H5E_BADITER, FAIL, "attribute iteration failed") done: - /* Release resources */ - if(obj_loc_id > 0) { - 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") - FUNC_LEAVE_API(ret_value) } /* H5Aiterate_by_name() */ @@ -1385,7 +1417,8 @@ done: herr_t H5Adelete(hid_t loc_id, const char *name) { - H5G_loc_t loc; /* Object location */ + H5VL_object_t *obj; + H5VL_loc_params_t loc_params; herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_API(FAIL) @@ -1394,14 +1427,20 @@ H5Adelete(hid_t loc_id, const char *name) /* check arguments */ if(H5I_ATTR == H5I_get_type(loc_id)) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "location is not valid for an attribute") - 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") - /* Delete the attribute from the location */ - if(H5O_attr_remove(loc.oloc, name, H5AC_dxpl_id) < 0) - HGOTO_ERROR(H5E_ATTR, H5E_CANTDELETE, FAIL, "unable to delete attribute") + loc_params.type = H5VL_OBJECT_BY_SELF; + loc_params.obj_type = H5I_get_type(loc_id); + + /* get the object */ + if(NULL == (obj = H5VL_get_object(loc_id))) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "invalid object identifier") + + /* Delete the attribute through the VOL */ + if((ret_value = H5VL_attr_specific(obj->vol_obj, loc_params, obj->vol_info->vol_cls, H5VL_ATTR_DELETE, + H5AC_dxpl_id, H5_REQUEST_NULL, name)) < 0) + HGOTO_ERROR(H5E_ATTR, H5E_CANTDELETE, FAIL, "unable to delete attribute") done: FUNC_LEAVE_API(ret_value) @@ -1428,11 +1467,8 @@ herr_t H5Adelete_by_name(hid_t loc_id, const char *obj_name, const char *attr_name, hid_t lapl_id) { - H5G_loc_t loc; /* Object location */ - 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 */ - hbool_t loc_found = FALSE; /* Entry at 'obj_name' found */ + H5VL_object_t *obj; + H5VL_loc_params_t loc_params; herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_API(FAIL) @@ -1441,8 +1477,6 @@ H5Adelete_by_name(hid_t loc_id, const char *obj_name, const char *attr_name, /* check arguments */ if(H5I_ATTR == H5I_get_type(loc_id)) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "location is not valid for an attribute") - if(H5G_loc(loc_id, &loc) < 0) - HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a location") if(!obj_name || !*obj_name) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "no object name") if(!attr_name || !*attr_name) @@ -1453,25 +1487,21 @@ H5Adelete_by_name(hid_t loc_id, const char *obj_name, const char *attr_name, if(TRUE != H5P_isa_class(lapl_id, H5P_LINK_ACCESS)) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not link access property list ID") - /* Set up opened group location to fill in */ - obj_loc.oloc = &obj_oloc; - obj_loc.path = &obj_path; - H5G_loc_reset(&obj_loc); + loc_params.type = H5VL_OBJECT_BY_NAME; + loc_params.loc_data.loc_by_name.name = obj_name; + loc_params.loc_data.loc_by_name.lapl_id = lapl_id; + loc_params.obj_type = H5I_get_type(loc_id); - /* Find the object's location */ - if(H5G_loc_find(&loc, obj_name, &obj_loc/*out*/, lapl_id, H5AC_ind_dxpl_id) < 0) - HGOTO_ERROR(H5E_ATTR, H5E_NOTFOUND, FAIL, "object not found") - loc_found = TRUE; + /* get the object */ + if(NULL == (obj = H5VL_get_object(loc_id))) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "invalid object identifier") - /* Delete the attribute from the location */ - if(H5O_attr_remove(obj_loc.oloc, attr_name, H5AC_dxpl_id) < 0) - HGOTO_ERROR(H5E_ATTR, H5E_CANTDELETE, FAIL, "unable to delete attribute") + /* Delete the attribute through the VOL */ + if((ret_value = H5VL_attr_specific(obj->vol_obj, loc_params, obj->vol_info->vol_cls, H5VL_ATTR_DELETE, + H5AC_dxpl_id, H5_REQUEST_NULL, attr_name)) < 0) + HGOTO_ERROR(H5E_ATTR, H5E_CANTDELETE, FAIL, "unable to delete attribute") done: - /* Release resources */ - if(loc_found && H5G_loc_free(&obj_loc) < 0) - HDONE_ERROR(H5E_ATTR, H5E_CANTRELEASE, FAIL, "can't free location") - FUNC_LEAVE_API(ret_value) } /* H5Adelete_by_name() */ @@ -1504,11 +1534,8 @@ herr_t H5Adelete_by_idx(hid_t loc_id, const char *obj_name, H5_index_t idx_type, H5_iter_order_t order, hsize_t n, hid_t lapl_id) { - H5G_loc_t loc; /* Object location */ - 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 */ - hbool_t loc_found = FALSE; /* Entry at 'obj_name' found */ + H5VL_object_t *obj; + H5VL_loc_params_t loc_params; herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_API(FAIL) @@ -1517,8 +1544,6 @@ H5Adelete_by_idx(hid_t loc_id, const char *obj_name, H5_index_t idx_type, /* check arguments */ if(H5I_ATTR == H5I_get_type(loc_id)) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "location is not valid for an attribute") - if(H5G_loc(loc_id, &loc) < 0) - HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a location") if(!obj_name || !*obj_name) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "no object name") if(idx_type <= H5_INDEX_UNKNOWN || idx_type >= H5_INDEX_N) @@ -1531,25 +1556,24 @@ H5Adelete_by_idx(hid_t loc_id, const char *obj_name, H5_index_t idx_type, if(TRUE != H5P_isa_class(lapl_id, H5P_LINK_ACCESS)) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not link access property list ID") - /* Set up opened group location to fill in */ - obj_loc.oloc = &obj_oloc; - obj_loc.path = &obj_path; - H5G_loc_reset(&obj_loc); + loc_params.type = H5VL_OBJECT_BY_IDX; + loc_params.loc_data.loc_by_idx.name = obj_name; + loc_params.loc_data.loc_by_idx.idx_type = idx_type; + loc_params.loc_data.loc_by_idx.order = order; + loc_params.loc_data.loc_by_idx.n = n; + loc_params.loc_data.loc_by_idx.lapl_id = lapl_id; + loc_params.obj_type = H5I_get_type(loc_id); - /* Find the object's location */ - if(H5G_loc_find(&loc, obj_name, &obj_loc/*out*/, lapl_id, H5AC_dxpl_id) < 0) - HGOTO_ERROR(H5E_ATTR, H5E_NOTFOUND, FAIL, "object not found") - loc_found = TRUE; + /* get the object */ + if(NULL == (obj = H5VL_get_object(loc_id))) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "invalid object identifier") - /* Delete the attribute from the location */ - if(H5O_attr_remove_by_idx(obj_loc.oloc, idx_type, order, n, H5AC_dxpl_id) < 0) - HGOTO_ERROR(H5E_ATTR, H5E_CANTDELETE, FAIL, "unable to delete attribute") + /* Delete the attribute through the VOL */ + if((ret_value = H5VL_attr_specific(obj->vol_obj, loc_params, obj->vol_info->vol_cls, H5VL_ATTR_DELETE, + H5AC_dxpl_id, H5_REQUEST_NULL, NULL)) < 0) + HGOTO_ERROR(H5E_ATTR, H5E_CANTDELETE, FAIL, "unable to delete attribute") done: - /* Release resources */ - if(loc_found && H5G_loc_free(&obj_loc) < 0) - HDONE_ERROR(H5E_ATTR, H5E_CANTRELEASE, FAIL, "can't free location") - FUNC_LEAVE_API(ret_value) } /* H5Adelete_by_idx() */ @@ -1607,7 +1631,8 @@ done: htri_t H5Aexists(hid_t obj_id, const char *attr_name) { - H5G_loc_t loc; /* Object location */ + H5VL_object_t *obj; + H5VL_loc_params_t loc_params; htri_t ret_value; /* Return value */ FUNC_ENTER_API(FAIL) @@ -1616,15 +1641,20 @@ H5Aexists(hid_t obj_id, const char *attr_name) /* check arguments */ if(H5I_ATTR == H5I_get_type(obj_id)) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "location is not valid for an attribute") - if(H5G_loc(obj_id, &loc) < 0) - HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a location") if(!attr_name || !*attr_name) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "no attribute name") - /* Check if the attribute exists */ - if((ret_value = H5O_attr_exists(loc.oloc, attr_name, H5AC_ind_dxpl_id)) < 0) - HGOTO_ERROR(H5E_ATTR, H5E_CANTGET, FAIL, "unable to determine if attribute exists") + /* get the object */ + if(NULL == (obj = H5VL_get_object(obj_id))) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "invalid object identifier") + + loc_params.type = H5VL_OBJECT_BY_SELF; + loc_params.obj_type = H5I_get_type(obj_id); + /* Check existence of attribute through the VOL */ + if(H5VL_attr_specific(obj->vol_obj, loc_params, obj->vol_info->vol_cls, H5VL_ATTR_EXISTS, + H5AC_ind_dxpl_id, H5_REQUEST_NULL, attr_name, &ret_value) < 0) + HGOTO_ERROR(H5E_ATTR, H5E_CANTGET, FAIL, "unable to determine if attribute exists") done: FUNC_LEAVE_API(ret_value) } /* H5Aexists() */ @@ -1647,7 +1677,8 @@ htri_t H5Aexists_by_name(hid_t loc_id, const char *obj_name, const char *attr_name, hid_t lapl_id) { - H5G_loc_t loc; /* Object location */ + H5VL_object_t *obj; + H5VL_loc_params_t loc_params; htri_t ret_value; /* Return value */ FUNC_ENTER_API(FAIL) @@ -1656,8 +1687,6 @@ H5Aexists_by_name(hid_t loc_id, const char *obj_name, const char *attr_name, /* check arguments */ if(H5I_ATTR == H5I_get_type(loc_id)) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "location is not valid for an attribute") - if(H5G_loc(loc_id, &loc) < 0) - HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a location") if(!obj_name || !*obj_name) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "no object name") if(!attr_name || !*attr_name) @@ -1668,10 +1697,56 @@ H5Aexists_by_name(hid_t loc_id, const char *obj_name, const char *attr_name, if(TRUE != H5P_isa_class(lapl_id, H5P_LINK_ACCESS)) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not link access property list ID") - if((ret_value = H5A_exists_by_name(loc, obj_name, attr_name, lapl_id)) < 0) + /* get the object */ + if(NULL == (obj = H5VL_get_object(loc_id))) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "invalid object identifier") + + loc_params.type = H5VL_OBJECT_BY_NAME; + loc_params.loc_data.loc_by_name.name = obj_name; + loc_params.loc_data.loc_by_name.lapl_id = lapl_id; + loc_params.obj_type = H5I_get_type(loc_id); + + /* Check existence of attribute through the VOL */ + if(H5VL_attr_specific(obj->vol_obj, loc_params, obj->vol_info->vol_cls, H5VL_ATTR_EXISTS, + H5AC_ind_dxpl_id, H5_REQUEST_NULL, attr_name, &ret_value) < 0) HGOTO_ERROR(H5E_ATTR, H5E_CANTGET, FAIL, "unable to determine if attribute exists") done: FUNC_LEAVE_API(ret_value) } /* H5Aexists_by_name() */ + +/*------------------------------------------------------------------------- + * Function: H5A_close_attr + * + * Purpose: Called when the ref count reaches zero on the attr_id + * + * Return: Success: Non-negative + * + * Failure: Negative + * + * Programmer: Mohamad Chaarawi + * June 2012 + * + *------------------------------------------------------------------------- + */ +herr_t +H5A_close_attr(void *_attr) +{ + H5VL_object_t *attr = (H5VL_object_t *)_attr; + herr_t ret_value = SUCCEED; /* Return value */ + + FUNC_ENTER_NOAPI_NOINIT + + /* Close the attr through the VOL*/ + if((ret_value = H5VL_attr_close(attr->vol_obj, attr->vol_info->vol_cls, + H5AC_dxpl_id, H5_REQUEST_NULL)) < 0) + HGOTO_ERROR(H5E_ATTR, H5E_CLOSEERROR, FAIL, "unable to close attribute") + + /* free attribute */ + if(H5VL_free_object(attr) < 0) + HGOTO_ERROR(H5E_ATTR, H5E_CANTDEC, FAIL, "unable to free VOL object") + +done: + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5A_close_attr() */ diff --git a/src/H5Adeprec.c b/src/H5Adeprec.c index 6342e18..28e4c3f 100644 --- a/src/H5Adeprec.c +++ b/src/H5Adeprec.c @@ -47,6 +47,7 @@ #include "H5Eprivate.h" /* Error handling */ #include "H5Iprivate.h" /* IDs */ #include "H5Opkg.h" /* Object headers */ +#include "H5VLprivate.h" /* Virtual Object Layer */ /****************/ @@ -162,10 +163,10 @@ hid_t H5Acreate1(hid_t loc_id, const char *name, hid_t type_id, hid_t space_id, hid_t plist_id) { - H5A_t *attr = NULL; /* Attribute created */ - H5G_loc_t loc; /* Object location */ - H5T_t *type; /* Datatype to use for attribute */ - H5S_t *space; /* Dataspace to use for attribute */ + void *attr = NULL; /* attr token from VOL plugin */ + H5VL_object_t *obj = NULL; /* object token of loc_id */ + H5VL_loc_params_t loc_params; + H5P_genplist_t *plist; /* Property list pointer */ hid_t ret_value; /* Return value */ FUNC_ENTER_API(FAIL) @@ -174,26 +175,44 @@ H5Acreate1(hid_t loc_id, const char *name, hid_t type_id, hid_t space_id, /* check arguments */ if(H5I_ATTR == H5I_get_type(loc_id)) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "location is not valid for an attribute") - if(H5G_loc(loc_id, &loc) < 0) - HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a location") - if(0 == (H5F_INTENT(loc.oloc->file) & H5F_ACC_RDWR)) - HGOTO_ERROR(H5E_ARGS, H5E_WRITEERROR, FAIL, "no write intent on file") if(!name || !*name) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "no name") - if(NULL == (type = (H5T_t *)H5I_object_verify(type_id, H5I_DATATYPE))) - HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a type") - if(NULL == (space = (H5S_t *)H5I_object_verify(space_id, H5I_DATASPACE))) - HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a dataspace") - /* Go do the real work for attaching the attribute to the dataset */ - if((attr = H5A_create(&loc, name, type, space, plist_id, H5AC_dxpl_id)) < 0) - HGOTO_ERROR(H5E_ATTR, H5E_CANTINIT, FAIL, "unable to create attribute") + /* Get correct property list */ + if(H5P_DEFAULT == plist_id) + plist_id = H5P_ATTRIBUTE_CREATE_DEFAULT; - /* Register the new attribute and get an ID for it */ - if((ret_value = H5I_register(H5I_ATTR, attr, TRUE)) < 0) - HGOTO_ERROR(H5E_ATOM, H5E_CANTREGISTER, FAIL, "unable to register attribute for ID") + /* Get the plist structure */ + if(NULL == (plist = (H5P_genplist_t *)H5I_object(plist_id))) + HGOTO_ERROR(H5E_ATOM, H5E_BADATOM, FAIL, "can't find object for ID") + + /* set creation properties */ + if(H5P_set(plist, H5VL_PROP_ATTR_TYPE_ID, &type_id) < 0) + HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, FAIL, "can't set property value for datatype id") + if(H5P_set(plist, H5VL_PROP_ATTR_SPACE_ID, &space_id) < 0) + HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, FAIL, "can't set property value for space id") + + loc_params.type = H5VL_OBJECT_BY_SELF; + loc_params.obj_type = H5I_get_type(loc_id); + + /* get the location object */ + if(NULL == (obj = H5VL_get_object(loc_id))) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "invalid location identifier") + + /* Create the attribute through the VOL */ + if(NULL == (attr = H5VL_attr_create(obj->vol_obj, loc_params, obj->vol_info->vol_cls, name, + plist_id, H5P_DEFAULT, H5AC_dxpl_id, H5_REQUEST_NULL))) + HGOTO_ERROR(H5E_SYM, H5E_CANTINIT, FAIL, "unable to create attribute") + + /* Get an atom for the attribute */ + if((ret_value = H5VL_register_id(H5I_ATTR, attr, obj->vol_info, TRUE)) < 0) + HGOTO_ERROR(H5E_ATOM, H5E_CANTREGISTER, FAIL, "unable to atomize attribute handle") done: + if (ret_value < 0 && attr) + if(H5VL_attr_close(attr, obj->vol_info->vol_cls, H5AC_dxpl_id, H5_REQUEST_NULL) < 0) + HDONE_ERROR(H5E_ATTR, H5E_CLOSEERROR, FAIL, "unable to release attr") + FUNC_LEAVE_API(ret_value) } /* H5Acreate1() */ @@ -223,8 +242,9 @@ done: hid_t H5Aopen_name(hid_t loc_id, const char *name) { - H5G_loc_t loc; /* Object location */ - H5A_t *attr = NULL; /* Attribute opened */ + void *attr = NULL; /* attr token from VOL plugin */ + H5VL_object_t *obj = NULL; /* object token of loc_id */ + H5VL_loc_params_t loc_params; hid_t ret_value; FUNC_ENTER_API(FAIL) @@ -233,24 +253,29 @@ H5Aopen_name(hid_t loc_id, const char *name) /* check arguments */ if(H5I_ATTR == H5I_get_type(loc_id)) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "location is not valid for an attribute") - 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") - /* Open the attribute on the object header */ - if(NULL == (attr = H5A_open_by_name(&loc, ".", name, H5P_LINK_ACCESS_DEFAULT, H5AC_ind_dxpl_id))) - HGOTO_ERROR(H5E_ATTR, H5E_CANTOPENOBJ, FAIL, "can't open attribute: '%s'", name) + loc_params.type = H5VL_OBJECT_BY_SELF; + loc_params.obj_type = H5I_get_type(loc_id); + + /* get the location object */ + if(NULL == (obj = H5VL_get_object(loc_id))) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "invalid location identifier") + + /* Open the attribute through the VOL */ + if(NULL == (attr = H5VL_attr_open(obj->vol_obj, loc_params, obj->vol_info->vol_cls, + name, H5P_DEFAULT, H5AC_ind_dxpl_id, H5_REQUEST_NULL))) + HGOTO_ERROR(H5E_SYM, H5E_CANTOPENOBJ, FAIL, "unable to open attribute") - /* Register the attribute and get an ID for it */ - if((ret_value = H5I_register(H5I_ATTR, attr, TRUE)) < 0) - HGOTO_ERROR(H5E_ATOM, H5E_CANTREGISTER, FAIL, "unable to register attribute for ID") + /* Get an atom for the attribute */ + if((ret_value = H5VL_register_id(H5I_ATTR, attr, obj->vol_info, TRUE)) < 0) + HGOTO_ERROR(H5E_ATOM, H5E_CANTREGISTER, FAIL, "unable to atomize attribute handle") done: - /* Cleanup on failure */ - if(ret_value < 0) - if(attr && H5A_close(attr) < 0) - HDONE_ERROR(H5E_ATTR, H5E_CANTFREE, FAIL, "can't close attribute") + if (ret_value < 0 && attr) + if(H5VL_attr_close(attr, obj->vol_info->vol_cls, H5AC_dxpl_id, H5_REQUEST_NULL) < 0) + HDONE_ERROR(H5E_ATTR, H5E_CLOSEERROR, FAIL, "unable to release attr") FUNC_LEAVE_API(ret_value) } /* H5Aopen_name() */ @@ -281,8 +306,9 @@ done: hid_t H5Aopen_idx(hid_t loc_id, unsigned idx) { - H5G_loc_t loc; /* Object location */ - H5A_t *attr = NULL; /* Attribute opened */ + void *attr = NULL; /* attr token from VOL plugin */ + H5VL_object_t *obj = NULL; /* object token of loc_id */ + H5VL_loc_params_t loc_params; hid_t ret_value; FUNC_ENTER_API(FAIL) @@ -291,22 +317,32 @@ H5Aopen_idx(hid_t loc_id, unsigned idx) /* check arguments */ if(H5I_ATTR == H5I_get_type(loc_id)) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "location is not valid for an attribute") - if(H5G_loc(loc_id, &loc) < 0) - HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a location") - /* Open the attribute in the object header */ - if(NULL == (attr = H5A_open_by_idx(&loc, ".", H5_INDEX_CRT_ORDER, H5_ITER_INC, (hsize_t)idx, H5P_LINK_ACCESS_DEFAULT, H5AC_ind_dxpl_id))) - HGOTO_ERROR(H5E_ATTR, H5E_CANTOPENOBJ, FAIL, "unable to open attribute") + 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_CRT_ORDER; + loc_params.loc_data.loc_by_idx.order = H5_ITER_INC; + loc_params.loc_data.loc_by_idx.n = (hsize_t)idx; + loc_params.loc_data.loc_by_idx.lapl_id = H5P_LINK_ACCESS_DEFAULT; + loc_params.obj_type = H5I_get_type(loc_id); - /* Register the attribute and get an ID for it */ - if((ret_value = H5I_register(H5I_ATTR, attr, TRUE)) < 0) - HGOTO_ERROR(H5E_ATOM, H5E_CANTREGISTER, FAIL, "unable to register attribute for ID") + /* get the location object */ + if(NULL == (obj = H5VL_get_object(loc_id))) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "invalid location identifier") + + /* Open the attribute through the VOL */ + if(NULL == (attr = H5VL_attr_open(obj->vol_obj, loc_params, obj->vol_info->vol_cls, + NULL, H5P_DEFAULT, H5AC_ind_dxpl_id, H5_REQUEST_NULL))) + HGOTO_ERROR(H5E_SYM, H5E_CANTOPENOBJ, FAIL, "unable to open attribute") + + /* Get an atom for the attribute */ + if((ret_value = H5VL_register_id(H5I_ATTR, attr, obj->vol_info, TRUE)) < 0) + HGOTO_ERROR(H5E_ATOM, H5E_CANTREGISTER, FAIL, "unable to atomize attribute handle") done: - /* Cleanup on failure */ - if(ret_value < 0) - if(attr && H5A_close(attr) < 0) - HDONE_ERROR(H5E_ATTR, H5E_CANTFREE, FAIL, "can't close attribute") + if (ret_value < 0 && attr) + if(H5VL_attr_close(attr, obj->vol_info->vol_cls, H5AC_dxpl_id, H5_REQUEST_NULL) < 0) + HDONE_ERROR(H5E_ATTR, H5E_CLOSEERROR, FAIL, "unable to release attr") FUNC_LEAVE_API(ret_value) } /* H5Aopen_idx() */ @@ -333,56 +369,27 @@ done: int H5Aget_num_attrs(hid_t loc_id) { - H5O_loc_t *loc; /* Object location for attribute */ - void *obj; - int ret_value; + H5VL_object_t *obj; + H5VL_loc_params_t loc_params; + H5O_info_t oinfo; + int ret_value; FUNC_ENTER_API(FAIL) H5TRACE1("Is", "i", loc_id); - /* check arguments */ - if(H5I_BADID == H5I_get_type(loc_id)) - HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "bad location ID") - if(H5I_FILE == H5I_get_type(loc_id) || H5I_ATTR == H5I_get_type(loc_id)) - HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "location is not valid for an attribute") - if(NULL == (obj = H5I_object(loc_id))) - HGOTO_ERROR(H5E_ARGS, H5E_BADATOM, FAIL, "illegal object atom") - switch(H5I_get_type (loc_id)) { - case H5I_DATASET: - if(NULL == (loc = H5D_oloc((H5D_t*)obj))) - HGOTO_ERROR(H5E_ATTR, H5E_CANTGET, FAIL, "can't get location for object") - break; - - case H5I_DATATYPE: - if(NULL == (loc = H5T_oloc((H5T_t*)obj))) - HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "target datatype is not committed") - break; - - case H5I_GROUP: - if(NULL == (loc = H5G_oloc((H5G_t*)obj))) - HGOTO_ERROR(H5E_ATTR, H5E_CANTGET, FAIL, "can't get location for object") - break; - - case H5I_UNINIT: - case H5I_BADID: - case H5I_FILE: - case H5I_DATASPACE: - case H5I_ATTR: - case H5I_REFERENCE: - case H5I_VFL: - 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, FAIL, "inappropriate attribute target") - } /*lint !e788 All appropriate cases are covered */ - - /* Look up the # of attributes for the object */ - if((ret_value = H5O_attr_count(loc, H5AC_ind_dxpl_id)) < 0) - HGOTO_ERROR(H5E_ATTR, H5E_CANTCOUNT, FAIL, "can't get attribute count for object") + loc_params.type = H5VL_OBJECT_BY_SELF; + loc_params.obj_type = H5I_get_type(loc_id); + + /* get the location object */ + if(NULL == (obj = H5VL_get_object(loc_id))) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "invalid location identifier") + + /* Get the group info through the VOL using the location token */ + if(H5VL_object_optional(obj->vol_obj, obj->vol_info->vol_cls, H5AC_ind_dxpl_id, H5_REQUEST_NULL, + H5VL_OBJECT_GET_INFO, loc_params, &oinfo) < 0) + HGOTO_ERROR(H5E_INTERNAL, H5E_CANTGET, FAIL, "unable to get group info") + + ret_value = oinfo.num_attrs; done: FUNC_LEAVE_API(ret_value) diff --git a/src/H5Aint.c b/src/H5Aint.c index 625bfa9..ea91306 100644 --- a/src/H5Aint.c +++ b/src/H5Aint.c @@ -43,7 +43,7 @@ #include "H5MMprivate.h" /* Memory management */ #include "H5Opkg.h" /* Object headers */ #include "H5SMprivate.h" /* Shared Object Header Messages */ - +#include "H5VLprivate.h" /* Virtual Object Layer */ /****************/ /* Local Macros */ @@ -239,7 +239,7 @@ H5A_create(const H5G_loc_t *loc, const char *name, const H5T_t *type, * (to maintain ref. count incr/decr similarity with "shared message" * type of datatype sharing) */ - if(H5T_committed(attr->shared->dt)) { + if(H5T_is_named(attr->shared->dt)) { /* Increment the reference count on the shared datatype */ if(H5T_link(attr->shared->dt, 1, dxpl_id) < 0) HGOTO_ERROR(H5E_OHDR, H5E_LINKCOUNT, NULL, "unable to adjust shared datatype link count") @@ -767,9 +767,17 @@ H5A_get_type(H5A_t *attr) if(H5T_lock(dt, FALSE) < 0) HGOTO_ERROR(H5E_DATATYPE, H5E_CANTINIT, FAIL, "unable to lock transient datatype") - /* Create an atom */ - if((ret_value = H5I_register(H5I_DATATYPE, dt, TRUE)) < 0) - HGOTO_ERROR(H5E_ATOM, H5E_CANTREGISTER, FAIL, "unable to register datatype") + if(H5T_is_named(dt)) { + /* If this is a committed datatype, we need to recreate the + 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) + HGOTO_ERROR(H5E_ATOM, H5E_CANTREGISTER, FAIL, "unable to atomize file handle") + } + 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) { @@ -1969,7 +1977,7 @@ H5A_attr_copy_file(const H5A_t *attr_src, H5F_t *file_dst, hbool_t *recompute_si if(H5T_set_loc(attr_dst->shared->dt, file_dst, H5T_LOC_DISK) < 0) HGOTO_ERROR(H5E_DATATYPE, H5E_CANTINIT, NULL, "cannot mark datatype on disk") - if(!H5T_committed(attr_src->shared->dt)) { + if(!H5T_is_named(attr_src->shared->dt)) { /* If the datatype is not named, it may have been shared in the * source file's heap. Un-share it for now. We'll try to shared * it in the destination file below. @@ -2191,7 +2199,7 @@ H5A_attr_post_copy_file(const H5O_loc_t *src_oloc, const H5A_t *attr_src, HDassert(file_src); HDassert(file_dst); - if(H5T_committed(attr_src->shared->dt)) { + if(H5T_is_named(attr_src->shared->dt)) { H5O_loc_t *src_oloc_dt; /* Pointer to source datatype's object location */ H5O_loc_t *dst_oloc_dt; /* Pointer to dest. datatype's object location */ @@ -2411,3 +2419,194 @@ done: FUNC_LEAVE_NOAPI(ret_value) } /* H5A_rename_by_name() */ + + +/*------------------------------------------------------------------------- + * Function: H5A_iterate + * + * Purpose: Iterates through attrs in an object + * + * Return: Success: 0 + * Failure: -1 + * + * Programmer: Mohamad Chaarawi + * June, 2013 + * + *------------------------------------------------------------------------- + */ +herr_t H5A_iterate(void *obj, H5VL_loc_params_t loc_params, H5_index_t idx_type, + H5_iter_order_t order, hsize_t *idx, H5A_operator2_t op, void *op_data) +{ + H5G_loc_t loc; /* Object location */ + 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 */ + hbool_t loc_found = FALSE; /* Entry at 'obj_name' found */ + hid_t obj_loc_id = (-1); /* ID for object located */ + H5A_attr_iter_op_t attr_op; /* Attribute operator */ + hsize_t start_idx; /* Index of attribute to start iterating at */ + hsize_t last_attr; /* Index of last attribute examined */ + void *temp_obj = NULL; + H5I_type_t obj_type; + herr_t ret_value = SUCCEED; /* 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, FAIL, "not a file or file object") + + /* Build attribute operator info */ + attr_op.op_type = H5A_ATTR_OP_APP2; + attr_op.u.app_op2 = op; + + /* Call attribute iteration routine */ + last_attr = start_idx = (idx ? *idx : 0); + + /* Iterate over the attributess */ + if(loc_params.type == H5VL_OBJECT_BY_SELF) { + if((obj_loc_id = H5VL_native_register(loc_params.obj_type, obj, TRUE)) < 0) + HGOTO_ERROR(H5E_ATOM, H5E_CANTREGISTER, FAIL, "unable to register object") + } + else if(loc_params.type == H5VL_OBJECT_BY_NAME) { + /* 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 */ + if(H5G_loc_find(&loc, loc_params.loc_data.loc_by_name.name, &obj_loc/*out*/, + loc_params.loc_data.loc_by_name.lapl_id, H5AC_ind_dxpl_id) < 0) + HGOTO_ERROR(H5E_ATTR, H5E_NOTFOUND, FAIL, "object not found"); + loc_found = TRUE; + + /* Open the object */ + if((obj_loc_id = H5O_open_by_loc(&obj_loc, loc_params.loc_data.loc_by_name.lapl_id, + H5AC_ind_dxpl_id, TRUE)) < 0) + HGOTO_ERROR(H5E_ATTR, H5E_CANTOPENOBJ, FAIL, "unable to open object"); + + /* get the native object from the ID created by the object header and create + a "VOL object" ID */ + obj_type = H5I_get_type(obj_loc_id); + if(NULL == (temp_obj = H5I_remove(obj_loc_id))) + HGOTO_ERROR(H5E_SYM, H5E_CANTOPENOBJ, FAIL, "unable to open object"); + /* Get an atom for the object */ + if((obj_loc_id = H5VL_native_register(obj_type, temp_obj, TRUE)) < 0) + HGOTO_ERROR(H5E_ATOM, H5E_CANTREGISTER, FAIL, "unable to register datatype"); + } + else { + HGOTO_ERROR(H5E_VOL, H5E_UNSUPPORTED, FAIL, "unknown link iterate params"); + } + + /* Do the real iteration */ + if((ret_value = H5O_attr_iterate(obj_loc_id, H5AC_ind_dxpl_id, idx_type, order, + start_idx, &last_attr, &attr_op, op_data)) < 0) + HGOTO_ERROR(H5E_ATTR, H5E_BADITER, FAIL, "error iterating over attributes"); + + /* Set the last attribute information */ + if(idx) + *idx = last_attr; + +done: + /* Release resources */ + if(loc_params.type == H5VL_OBJECT_BY_SELF) { + if(H5VL_native_unregister(obj_loc_id) < 0) + HDONE_ERROR(H5E_SYM, H5E_CANTRELEASE, FAIL, "unable to decrement vol plugin ref count") + if(obj_loc_id >= 0 && NULL == H5I_remove(obj_loc_id)) + HDONE_ERROR(H5E_SYM, H5E_CANTRELEASE, FAIL, "unable to free identifier"); + } + else if(loc_params.type == H5VL_OBJECT_BY_NAME) { + if(obj_loc_id >= 0) { + 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"); + } + else { + HDONE_ERROR(H5E_VOL, H5E_UNSUPPORTED, FAIL, "unknown link iterate params"); + } + + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5A_iterate() */ + + +/*------------------------------------------------------------------------- + * Function: H5A_delete + * + * Purpose: Deletes an attribute from a location + * + * Return: Success: 0 + * Failure: -1, attr not deleted. + * + * Programmer: Mohamad Chaarawi + * March, 2012 + * + *------------------------------------------------------------------------- + */ +herr_t +H5A_delete(void *obj, H5VL_loc_params_t loc_params, const char *attr_name) +{ + H5G_loc_t loc; /* Object location */ + 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 */ + hbool_t loc_found = FALSE; /* Entry at 'obj_name' found */ + herr_t ret_value = SUCCEED; /* 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, FAIL, "not a file or file object") + + if(H5VL_OBJECT_BY_SELF == loc_params.type) { /* H5Adelete */ + /* Delete the attribute from the location */ + if(H5O_attr_remove(loc.oloc, attr_name, H5AC_dxpl_id) < 0) + HGOTO_ERROR(H5E_ATTR, H5E_CANTDELETE, FAIL, "unable to delete attribute") + } + else if(H5VL_OBJECT_BY_NAME == loc_params.type) { /* H5Adelete_by_name */ + /* 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 */ + if(H5G_loc_find(&loc, loc_params.loc_data.loc_by_name.name, &obj_loc/*out*/, + loc_params.loc_data.loc_by_name.lapl_id, H5AC_ind_dxpl_id) < 0) + HGOTO_ERROR(H5E_ATTR, H5E_NOTFOUND, FAIL, "object not found") + loc_found = TRUE; + + /* Delete the attribute from the location */ + if(H5O_attr_remove(obj_loc.oloc, attr_name, H5AC_dxpl_id) < 0) + HGOTO_ERROR(H5E_ATTR, H5E_CANTDELETE, FAIL, "unable to delete attribute") + } + else if(H5VL_OBJECT_BY_IDX == loc_params.type) { /* H5Adelete_by_idx */ + /* 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 */ + if(H5G_loc_find(&loc, loc_params.loc_data.loc_by_idx.name, &obj_loc/*out*/, + loc_params.loc_data.loc_by_idx.lapl_id, H5AC_dxpl_id) < 0) + HGOTO_ERROR(H5E_ATTR, H5E_NOTFOUND, FAIL, "object not found") + loc_found = TRUE; + + /* Delete the attribute from the location */ + if(H5O_attr_remove_by_idx(obj_loc.oloc, 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, H5AC_dxpl_id) < 0) + HGOTO_ERROR(H5E_ATTR, H5E_CANTDELETE, FAIL, "unable to delete attribute") + } + else { + HGOTO_ERROR(H5E_VOL, H5E_UNSUPPORTED, FAIL, "unknown attribute remove parameters") + } + +done: + /* Release resources */ + if(loc_found && H5G_loc_free(&obj_loc) < 0) + HDONE_ERROR(H5E_ATTR, H5E_CANTRELEASE, FAIL, "can't free location") + + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5A_delete() */ diff --git a/src/H5Apkg.h b/src/H5Apkg.h index efa2b74..2c984d0 100644 --- a/src/H5Apkg.h +++ b/src/H5Apkg.h @@ -209,6 +209,9 @@ H5_DLL herr_t H5A_rename_by_name(H5G_loc_t loc, const char *obj_name, const char const char *new_attr_name, hid_t lapl_id); H5_DLL htri_t H5A_exists_by_name(H5G_loc_t loc, const char *obj_name, const char *attr_name, hid_t lapl_id); +H5_DLL herr_t H5A_iterate(void *obj, H5VL_loc_params_t loc_params, H5_index_t idx_type, + H5_iter_order_t order, hsize_t *idx, H5A_operator2_t op, void *op_data); +H5_DLL herr_t H5A_delete(void *obj, H5VL_loc_params_t loc_params, const char *attr_name); /* Attribute "dense" storage routines */ H5_DLL herr_t H5A_dense_create(H5F_t *f, hid_t dxpl_id, H5O_ainfo_t *ainfo); diff --git a/src/H5Atest.c b/src/H5Atest.c index 19b5547..2061ba3 100644 --- a/src/H5Atest.c +++ b/src/H5Atest.c @@ -100,7 +100,7 @@ H5A_is_shared_test(hid_t attr_id) FUNC_ENTER_NOAPI_NOINIT /* Check arguments */ - if(NULL == (attr = (H5A_t *)H5I_object_verify(attr_id, H5I_ATTR))) + if(NULL == (attr = (H5A_t *)H5VL_object_verify(attr_id, H5I_ATTR))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not an attribute") /* Check if attribute is shared */ @@ -133,7 +133,7 @@ H5A_get_shared_rc_test(hid_t attr_id, hsize_t *ref_count) FUNC_ENTER_NOAPI_NOINIT /* Check arguments */ - if(NULL == (attr = (H5A_t *)H5I_object_verify(attr_id, H5I_ATTR))) + if(NULL == (attr = (H5A_t *)H5VL_object_verify(attr_id, H5I_ATTR))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not an attribute") /* Sanity check */ @@ -31,7 +31,8 @@ #include "H5Eprivate.h" /* Error handling */ #include "H5FLprivate.h" /* Free lists */ #include "H5Iprivate.h" /* IDs */ - +#include "H5MMprivate.h" /* Memory management */ +#include "H5VLprivate.h" /* VOL plugins */ /****************/ /* Local Macros */ @@ -63,10 +64,6 @@ H5FL_BLK_EXTERN(vlen_fl_buf); /* Library Private Variables */ /*****************************/ -/* Declare extern the free list to manage blocks of type conversion data */ -H5FL_BLK_EXTERN(type_conv); - - /*******************/ /* Local Variables */ /*******************/ @@ -151,22 +148,18 @@ 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) { - H5G_loc_t loc; /* Object location to insert dataset into */ - H5D_t *dset = NULL; /* New dataset's info */ - const H5S_t *space; /* Dataspace for dataset */ - hid_t ret_value; /* Return value */ + void *dset = NULL; /* dset token from VOL plugin */ + H5VL_object_t *obj = NULL; /* object token of loc_id */ + H5VL_loc_params_t loc_params; + H5P_genplist_t *plist; /* Property list pointer */ + hid_t ret_value = FAIL; /* Return value */ FUNC_ENTER_API(FAIL) H5TRACE7("i", "i*siiiii", loc_id, name, type_id, space_id, lcpl_id, dcpl_id, dapl_id); - /* Check arguments */ - if(H5G_loc(loc_id, &loc) < 0) - HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a location ID") - if(H5I_DATATYPE != H5I_get_type(type_id)) - HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a datatype ID") - if(NULL == (space = (const H5S_t *)H5I_object_verify(space_id, H5I_DATASPACE))) - HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a dataspace ID") + if(!name || !*name) + HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "no name") /* Get correct property list */ if(H5P_DEFAULT == lcpl_id) @@ -189,17 +182,38 @@ H5Dcreate2(hid_t loc_id, const char *name, hid_t type_id, hid_t space_id, if(TRUE != H5P_isa_class(dapl_id, H5P_DATASET_ACCESS)) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not dataset access property list") - /* Create the new dataset & get its ID */ - if(NULL == (dset = H5D__create_named(&loc, name, type_id, space, lcpl_id, dcpl_id, dapl_id, H5AC_dxpl_id))) + /* Get the plist structure */ + if(NULL == (plist = (H5P_genplist_t *)H5I_object(dcpl_id))) + HGOTO_ERROR(H5E_ATOM, H5E_BADATOM, FAIL, "can't find object for ID") + + /* get the location object */ + if(NULL == (obj = (H5VL_object_t *)H5I_object(loc_id))) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "invalid location identifier") + + /* set creation properties */ + if(H5P_set(plist, H5VL_PROP_DSET_TYPE_ID, &type_id) < 0) + HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, FAIL, "can't set property value for datatype id") + if(H5P_set(plist, H5VL_PROP_DSET_SPACE_ID, &space_id) < 0) + HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, FAIL, "can't set property value for space id") + if(H5P_set(plist, H5VL_PROP_DSET_LCPL_ID, &lcpl_id) < 0) + HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, FAIL, "can't set property value for lcpl id") + + loc_params.type = H5VL_OBJECT_BY_SELF; + loc_params.obj_type = H5I_get_type(loc_id); + + /* Create the dataset through the VOL */ + if(NULL == (dset = H5VL_dataset_create(obj->vol_obj, loc_params, obj->vol_info->vol_cls, + name, dcpl_id, dapl_id, H5AC_dxpl_id, H5_REQUEST_NULL))) HGOTO_ERROR(H5E_DATASET, H5E_CANTINIT, FAIL, "unable to create dataset") - if((ret_value = H5I_register(H5I_DATASET, dset, TRUE)) < 0) - HGOTO_ERROR(H5E_DATASET, H5E_CANTREGISTER, FAIL, "unable to register dataset") + + /* Get an atom for the dataset */ + if((ret_value = H5VL_register_id(H5I_DATASET, dset, obj->vol_info, TRUE)) < 0) + HGOTO_ERROR(H5E_ATOM, H5E_CANTREGISTER, FAIL, "unable to atomize dataset handle") done: - if(ret_value < 0) - if(dset && H5D_close(dset) < 0) + if (ret_value < 0 && dset) + if(H5VL_dataset_close (dset, obj->vol_info->vol_cls, H5AC_dxpl_id, H5_REQUEST_NULL) < 0) HDONE_ERROR(H5E_DATASET, H5E_CLOSEERROR, FAIL, "unable to release dataset") - FUNC_LEAVE_API(ret_value) } /* end H5Dcreate2() */ @@ -243,21 +257,16 @@ hid_t H5Dcreate_anon(hid_t loc_id, hid_t type_id, hid_t space_id, hid_t dcpl_id, hid_t dapl_id) { - H5G_loc_t loc; /* Object location to insert dataset into */ - H5D_t *dset = NULL; /* New dataset's info */ - const H5S_t *space; /* Dataspace for dataset */ - hid_t ret_value; /* Return value */ + void *dset = NULL; /* dset token from VOL plugin */ + H5VL_object_t *obj = NULL; /* object token of loc_id */ + H5VL_loc_params_t loc_params; + H5P_genplist_t *plist; /* Property list pointer */ + hid_t ret_value; /* Return value */ FUNC_ENTER_API(FAIL) H5TRACE5("i", "iiiii", loc_id, type_id, space_id, dcpl_id, dapl_id); /* Check arguments */ - if(H5G_loc(loc_id, &loc) < 0) - HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a location ID") - if(H5I_DATATYPE != H5I_get_type(type_id)) - HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a datatype ID") - if(NULL == (space = (const H5S_t *)H5I_object_verify(space_id, H5I_DATASPACE))) - HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a dataspace ID") if(H5P_DEFAULT == dcpl_id) dcpl_id = H5P_DATASET_CREATE_DEFAULT; else @@ -271,33 +280,37 @@ H5Dcreate_anon(hid_t loc_id, hid_t type_id, hid_t space_id, hid_t dcpl_id, if(TRUE != H5P_isa_class(dapl_id, H5P_DATASET_ACCESS)) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not dataset access property list") - /* build and open the new dataset */ - if(NULL == (dset = H5D__create(loc.oloc->file, type_id, space, dcpl_id, dapl_id, H5AC_dxpl_id))) - HGOTO_ERROR(H5E_DATASET, H5E_CANTINIT, FAIL, "unable to create dataset") + /* get the location object */ + if(NULL == (obj = (H5VL_object_t *)H5I_object(loc_id))) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "invalid location identifier") - /* Register the new dataset to get an ID for it */ - if((ret_value = H5I_register(H5I_DATASET, dset, TRUE)) < 0) - HGOTO_ERROR(H5E_DATASET, H5E_CANTREGISTER, FAIL, "unable to register dataset") + /* Get the plist structure */ + if(NULL == (plist = (H5P_genplist_t *)H5I_object(dcpl_id))) + HGOTO_ERROR(H5E_ATOM, H5E_BADATOM, FAIL, "can't find object for ID") -done: - /* Release the dataset's object header, if it was created */ - if(dset) { - H5O_loc_t *oloc; /* Object location for dataset */ + /* set creation properties */ + if(H5P_set(plist, H5VL_PROP_DSET_TYPE_ID, &type_id) < 0) + HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, FAIL, "can't set property value for datatype id") + if(H5P_set(plist, H5VL_PROP_DSET_SPACE_ID, &space_id) < 0) + HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, FAIL, "can't set property value for space id") - /* Get the new dataset's object location */ - if(NULL == (oloc = H5D_oloc(dset))) - HDONE_ERROR(H5E_DATASET, H5E_CANTGET, FAIL, "unable to get object location of dataset") + loc_params.type = H5VL_OBJECT_BY_SELF; + loc_params.obj_type = H5I_get_type(loc_id); - /* Decrement refcount on dataset's object header in memory */ - if(H5O_dec_rc_by_loc(oloc, H5AC_dxpl_id) < 0) - HDONE_ERROR(H5E_DATASET, H5E_CANTDEC, FAIL, "unable to decrement refcount on newly created object") - } /* end if */ + /* Create the dataset through the VOL */ + if(NULL == (dset = H5VL_dataset_create(obj->vol_obj, loc_params, obj->vol_info->vol_cls, + NULL, dcpl_id, dapl_id, + H5AC_dxpl_id, H5_REQUEST_NULL))) + HGOTO_ERROR(H5E_DATASET, H5E_CANTINIT, FAIL, "unable to create dataset") - /* Cleanup on failure */ - if(ret_value < 0) - if(dset && H5D_close(dset) < 0) - HDONE_ERROR(H5E_DATASET, H5E_CLOSEERROR, FAIL, "unable to release dataset") + /* Get an atom for the dataset */ + if((ret_value = H5VL_register_id(H5I_DATASET, dset, obj->vol_info, TRUE)) < 0) + HGOTO_ERROR(H5E_ATOM, H5E_CANTREGISTER, FAIL, "unable to atomize dataset handle") +done: + if (ret_value < 0 && dset) + if(H5VL_dataset_close (dset, obj->vol_info->vol_cls, H5AC_dxpl_id, H5_REQUEST_NULL) < 0) + HDONE_ERROR(H5E_DATASET, H5E_CLOSEERROR, FAIL, "unable to release dataset") FUNC_LEAVE_API(ret_value) } /* end H5Dcreate_anon() */ @@ -322,22 +335,15 @@ done: hid_t H5Dopen2(hid_t loc_id, const char *name, hid_t dapl_id) { - H5D_t *dset = NULL; - H5G_loc_t loc; /* Object location of group */ - H5G_loc_t dset_loc; /* Object location of dataset */ - H5G_name_t path; /* Dataset group hier. path */ - H5O_loc_t oloc; /* Dataset object location */ - H5O_type_t obj_type; /* Type of object at location */ - hbool_t loc_found = FALSE; /* Location at 'name' found */ - hid_t dxpl_id = H5AC_dxpl_id; /* dxpl to use to open datset */ - hid_t ret_value; + void *dset = NULL; /* dset token from VOL plugin */ + H5VL_object_t *obj = NULL; /* object token of loc_id */ + H5VL_loc_params_t loc_params; + hid_t ret_value; FUNC_ENTER_API(FAIL) H5TRACE3("i", "i*si", loc_id, name, dapl_id); /* Check args */ - 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") @@ -348,42 +354,26 @@ H5Dopen2(hid_t loc_id, const char *name, hid_t dapl_id) if(TRUE != H5P_isa_class(dapl_id, H5P_DATASET_ACCESS)) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not dataset access property list") - /* Set up dataset location to fill in */ - dset_loc.oloc = &oloc; - dset_loc.path = &path; - H5G_loc_reset(&dset_loc); + loc_params.type = H5VL_OBJECT_BY_SELF; + loc_params.obj_type = H5I_get_type(loc_id); - /* Find the dataset object */ - if(H5G_loc_find(&loc, name, &dset_loc, dapl_id, dxpl_id) < 0) - HGOTO_ERROR(H5E_DATASET, H5E_NOTFOUND, FAIL, "not found") - loc_found = TRUE; + /* get the location object */ + if(NULL == (obj = (H5VL_object_t *)H5I_object(loc_id))) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "invalid location identifier") - /* Check that the object found is the correct type */ - if(H5O_obj_type(&oloc, &obj_type, dxpl_id) < 0) - HGOTO_ERROR(H5E_DATASET, H5E_CANTGET, FAIL, "can't get object type") - if(obj_type != H5O_TYPE_DATASET) - HGOTO_ERROR(H5E_DATASET, H5E_BADTYPE, FAIL, "not a dataset") + /* Create the dataset through the VOL */ + if(NULL == (dset = H5VL_dataset_open(obj->vol_obj, loc_params, obj->vol_info->vol_cls, name, + dapl_id, H5AC_dxpl_id, H5_REQUEST_NULL))) + HGOTO_ERROR(H5E_DATASET, H5E_CANTOPENOBJ, FAIL, "unable to open dataset") - /* Open the dataset */ - if(NULL == (dset = H5D_open(&dset_loc, dapl_id, dxpl_id))) - HGOTO_ERROR(H5E_DATASET, H5E_CANTINIT, FAIL, "can't open dataset") - - /* Register an atom for the dataset */ - if((ret_value = H5I_register(H5I_DATASET, dset, TRUE)) < 0) - HGOTO_ERROR(H5E_ATOM, H5E_CANTREGISTER, FAIL, "can't register dataset atom") + /* Get an atom for the dataset */ + if((ret_value = H5VL_register_id(H5I_DATASET, dset, obj->vol_info, TRUE)) < 0) + HGOTO_ERROR(H5E_ATOM, H5E_CANTREGISTER, FAIL, "unable to atomize dataset handle") done: - if(ret_value < 0) { - if(dset) { - if(H5D_close(dset) < 0) - HDONE_ERROR(H5E_DATASET, H5E_CLOSEERROR, FAIL, "unable to release dataset") - } /* end if */ - else { - if(loc_found && H5G_loc_free(&dset_loc) < 0) - HDONE_ERROR(H5E_DATASET, H5E_CANTRELEASE, FAIL, "can't free location") - } /* end else */ - } /* end if */ - + if (ret_value < 0 && dset) + if(H5VL_dataset_close (dset, obj->vol_info->vol_cls, H5AC_dxpl_id, H5_REQUEST_NULL) < 0) + HDONE_ERROR(H5E_DATASET, H5E_CLOSEERROR, FAIL, "unable to release dataset") FUNC_LEAVE_API(ret_value) } /* end H5Dopen2() */ @@ -411,8 +401,8 @@ H5Dclose(hid_t dset_id) H5TRACE1("e", "i", dset_id); /* Check args */ - if(NULL == H5I_object_verify(dset_id, H5I_DATASET)) - HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a dataset") + if(H5I_DATASET != H5I_get_type(dset_id)) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a dataset") /* * Decrement the counter on the dataset. It will be freed if the count @@ -449,18 +439,20 @@ done: hid_t H5Dget_space(hid_t dset_id) { - H5D_t *dset = NULL; - hid_t ret_value; + H5VL_object_t *dset; + hid_t ret_value = FAIL; FUNC_ENTER_API(FAIL) H5TRACE1("i", "i", dset_id); /* Check args */ - if(NULL == (dset = (H5D_t *)H5I_object_verify(dset_id, H5I_DATASET))) - HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a dataset") + if(NULL == (dset = (H5VL_object_t *)H5I_object_verify(dset_id, H5I_DATASET))) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "invalid dataset identifier") - if((ret_value = H5D_get_space(dset)) < 0) - HGOTO_ERROR(H5E_DATASET, H5E_CANTINIT, FAIL, "unable to get dataspace") + /* get the dataspace through the VOL */ + if(H5VL_dataset_get(dset->vol_obj, dset->vol_info->vol_cls, H5VL_DATASET_GET_SPACE, H5AC_dxpl_id, + H5_REQUEST_NULL, &ret_value) < 0) + HGOTO_ERROR(H5E_INTERNAL, H5E_CANTGET, FAIL, "unable to get data space") done: FUNC_LEAVE_API(ret_value) @@ -484,19 +476,20 @@ done: herr_t H5Dget_space_status(hid_t dset_id, H5D_space_status_t *allocation) { - H5D_t *dset = NULL; + H5VL_object_t *dset; herr_t ret_value = SUCCEED; FUNC_ENTER_API(FAIL) H5TRACE2("e", "i*Ds", dset_id, allocation); - /* Check arguments */ - if(NULL == (dset = (H5D_t *)H5I_object_verify(dset_id, H5I_DATASET))) - HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a dataset") + /* Check args */ + if(NULL == (dset = (H5VL_object_t *)H5I_object_verify(dset_id, H5I_DATASET))) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "invalid dataset identifier") - /* Read dataspace address and return */ - if(H5D__get_space_status(dset, allocation, H5AC_ind_dxpl_id) < 0) - HGOTO_ERROR(H5E_DATASET, H5E_CANTINIT, FAIL, "unable to get space status") + /* Read data space address through the VOL and return */ + if((ret_value = H5VL_dataset_get(dset->vol_obj, dset->vol_info->vol_cls, H5VL_DATASET_GET_SPACE_STATUS, + H5AC_ind_dxpl_id, H5_REQUEST_NULL, allocation)) < 0) + HGOTO_ERROR(H5E_INTERNAL, H5E_CANTGET, FAIL, "unable to get space status") done: FUNC_LEAVE_API(ret_value) @@ -522,19 +515,20 @@ done: hid_t H5Dget_type(hid_t dset_id) { - - H5D_t *dset; /* Dataset */ - hid_t ret_value; /* Return value */ + H5VL_object_t *dset; + hid_t ret_value = FAIL; /* Return value */ FUNC_ENTER_API(FAIL) H5TRACE1("i", "i", dset_id); /* Check args */ - if(NULL == (dset = (H5D_t *)H5I_object_verify(dset_id, H5I_DATASET))) - HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a dataset") + if(NULL == (dset = (H5VL_object_t *)H5I_object_verify(dset_id, H5I_DATASET))) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "invalid dataset identifier") - if((ret_value = H5D_get_type(dset)) < 0) - HGOTO_ERROR(H5E_DATASET, H5E_CANTINIT, FAIL, "unable to get dataspace") + /* get the datatype through the VOL */ + if(H5VL_dataset_get(dset->vol_obj, dset->vol_info->vol_cls, H5VL_DATASET_GET_TYPE, + H5AC_dxpl_id, H5_REQUEST_NULL, &ret_value) < 0) + HGOTO_ERROR(H5E_INTERNAL, H5E_CANTGET, FAIL, "unable to get datatype") done: FUNC_LEAVE_API(ret_value) @@ -560,18 +554,19 @@ done: hid_t H5Dget_create_plist(hid_t dset_id) { - H5D_t *dataset; /* Dataset structure */ - hid_t ret_value = SUCCEED; /* Return value */ + H5VL_object_t *dset; + hid_t ret_value = FAIL; /* Return value */ FUNC_ENTER_API(FAIL) H5TRACE1("i", "i", dset_id); /* Check args */ - if(NULL == (dataset = (H5D_t *)H5I_object_verify(dset_id, H5I_DATASET))) - HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a dataset") + if(NULL == (dset = (H5VL_object_t *)H5I_object_verify(dset_id, H5I_DATASET))) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "invalid dataset identifier") - if((ret_value = H5D_get_create_plist(dataset)) < 0) - HGOTO_ERROR(H5E_DATASET, H5E_CANTGET, FAIL, "Can't get creation plist") + if(H5VL_dataset_get(dset->vol_obj, dset->vol_info->vol_cls, H5VL_DATASET_GET_DCPL, H5AC_dxpl_id, + H5_REQUEST_NULL, &ret_value) < 0) + HGOTO_ERROR(H5E_INTERNAL, H5E_CANTGET, FAIL, "unable to get dataset creation properties") done: FUNC_LEAVE_API(ret_value) @@ -614,18 +609,19 @@ done: hid_t H5Dget_access_plist(hid_t dset_id) { - H5D_t *dset; /* Dataset structure */ - hid_t ret_value; /* Return value */ + H5VL_object_t *dset; + hid_t ret_value = FAIL; /* Return value */ FUNC_ENTER_API(FAIL) H5TRACE1("i", "i", dset_id); /* Check args */ - if (NULL == (dset = (H5D_t *)H5I_object_verify(dset_id, H5I_DATASET))) - HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a dataset") + if(NULL == (dset = (H5VL_object_t *)H5I_object_verify(dset_id, H5I_DATASET))) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "invalid dataset identifier") - if((ret_value = H5D_get_access_plist(dset)) < 0) - HGOTO_ERROR(H5E_DATASET, H5E_CANTGET, FAIL, "Can't get access plist") + if(H5VL_dataset_get(dset->vol_obj, dset->vol_info->vol_cls, H5VL_DATASET_GET_DAPL, + H5AC_dxpl_id, H5_REQUEST_NULL, &ret_value) < 0) + HGOTO_ERROR(H5E_INTERNAL, H5E_CANTGET, FAIL, "unable to get dataset access properties") done: FUNC_LEAVE_API(ret_value) @@ -653,19 +649,20 @@ done: hsize_t H5Dget_storage_size(hid_t dset_id) { - H5D_t *dset; /* Dataset to query */ + H5VL_object_t *dset; hsize_t ret_value; /* Return value */ FUNC_ENTER_API(0) H5TRACE1("h", "i", dset_id); /* Check args */ - if(NULL == (dset = (H5D_t *)H5I_object_verify(dset_id, H5I_DATASET))) - HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, 0, "not a dataset") + if(NULL == (dset = (H5VL_object_t *)H5I_object_verify(dset_id, H5I_DATASET))) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, 0, "invalid dataset identifier") - /* Set return value */ - if(H5D__get_storage_size(dset, H5AC_ind_dxpl_id, &ret_value) < 0) - HGOTO_ERROR(H5E_DATASET, H5E_CANTGET, 0, "can't get size of dataset's storage") + /* get storage size through the VOL */ + if(H5VL_dataset_get(dset->vol_obj, dset->vol_info->vol_cls, H5VL_DATASET_GET_STORAGE_SIZE, + H5AC_ind_dxpl_id, H5_REQUEST_NULL, &ret_value) < 0) + HGOTO_ERROR(H5E_INTERNAL, H5E_CANTGET, 0, "unable to get storage size") done: FUNC_LEAVE_API(ret_value) @@ -689,18 +686,20 @@ done: haddr_t H5Dget_offset(hid_t dset_id) { - H5D_t *dset; /* Dataset to query */ + H5VL_object_t *dset; haddr_t ret_value; /* Return value */ FUNC_ENTER_API(HADDR_UNDEF) H5TRACE1("a", "i", dset_id); /* Check args */ - if(NULL == (dset = (H5D_t *)H5I_object_verify(dset_id, H5I_DATASET))) - HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, HADDR_UNDEF, "not a dataset") + if(NULL == (dset = (H5VL_object_t *)H5I_object_verify(dset_id, H5I_DATASET))) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, HADDR_UNDEF, "invalid dataset identifier") - /* Set return value */ - ret_value = H5D__get_offset(dset); + /* get offset through the VOL */ + if(H5VL_dataset_get(dset->vol_obj, dset->vol_info->vol_cls, H5VL_DATASET_GET_OFFSET, + H5AC_dxpl_id, H5_REQUEST_NULL, &ret_value) < 0) + HGOTO_ERROR(H5E_INTERNAL, H5E_CANTGET, HADDR_UNDEF, "unable to get offset") done: FUNC_LEAVE_API(ret_value) @@ -820,7 +819,8 @@ H5Dvlen_reclaim(hid_t type_id, hid_t space_id, hid_t plist_id, void *buf) H5TRACE4("e", "iii*x", type_id, space_id, plist_id, buf); /* Check args */ - if(H5I_DATATYPE != H5I_get_type(type_id) || buf == NULL) + if((H5I_DATATYPE != H5I_get_type(type_id)) || + buf == NULL) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "invalid argument") if(NULL == (space = (H5S_t *)H5I_object_verify(space_id, H5I_DATASPACE))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "invalid dataspace") @@ -871,8 +871,7 @@ H5Dvlen_get_buf_size(hid_t dataset_id, hid_t type_id, hid_t space_id, hsize_t *size) { H5D_vlen_bufsize_t vlen_bufsize = {0, 0, 0, 0, 0, 0, 0}; - H5D_t *dset; /* Dataset for operation */ - H5S_t *fspace = NULL; /* Dataset's dataspace */ + H5VL_object_t *dset; /* Dataset for operation */ H5S_t *mspace = NULL; /* Memory dataspace */ char bogus; /* bogus value to pass to H5Diterate() */ H5S_t *space; /* Dataspace for iteration */ @@ -884,10 +883,11 @@ H5Dvlen_get_buf_size(hid_t dataset_id, hid_t type_id, hid_t space_id, /* Check args */ if(H5I_DATASET != H5I_get_type(dataset_id) || - H5I_DATATYPE != H5I_get_type(type_id) || size == NULL) + (H5I_DATATYPE != H5I_get_type(type_id)) || size == NULL) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "invalid argument") - if(NULL == (dset = (H5D_t *)H5I_object(dataset_id))) - HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a dataset") + /* get the dataset object */ + if(NULL == (dset = (H5VL_object_t *)H5I_object(dataset_id))) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "invalid dataset identifier") if(NULL == (space = (H5S_t *)H5I_object_verify(space_id, H5I_DATASPACE))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "invalid dataspace") if(!(H5S_has_extent(space))) @@ -895,16 +895,20 @@ H5Dvlen_get_buf_size(hid_t dataset_id, hid_t type_id, hid_t space_id, /* Save the dataset */ vlen_bufsize.dset = dset; + vlen_bufsize.fspace_id = FAIL; + vlen_bufsize.mspace_id = FAIL; - /* Get a copy of the dataset's dataspace */ - if(NULL == (fspace = H5S_copy(dset->shared->space, FALSE, TRUE))) - HGOTO_ERROR(H5E_DATASET, H5E_CANTCOPY, FAIL, "unable to get dataspace") - vlen_bufsize.fspace = fspace; + /* Get a copy of the dataspace ID */ + if(H5VL_dataset_get(dset->vol_obj, dset->vol_info->vol_cls, H5VL_DATASET_GET_SPACE, H5AC_dxpl_id, + H5_REQUEST_NULL, &vlen_bufsize.fspace_id) < 0) + HGOTO_ERROR(H5E_DATASPACE, H5E_CANTCOPY, FAIL, "can't copy dataspace") /* Create a scalar for the memory dataspace */ if(NULL == (mspace = H5S_create(H5S_SCALAR))) HGOTO_ERROR(H5E_DATASPACE, H5E_CANTCREATE, FAIL, "can't create dataspace") - vlen_bufsize.mspace = mspace; + /* Atomize */ + if((vlen_bufsize.mspace_id = H5I_register (H5I_DATASPACE, mspace, TRUE)) < 0) + HGOTO_ERROR(H5E_ATOM, H5E_CANTREGISTER, FAIL, "unable to register dataspace atom") /* Grab the temporary buffers required */ if(NULL == (vlen_bufsize.fl_tbuf = H5FL_BLK_MALLOC(vlen_fl_buf, (size_t)1))) @@ -935,10 +939,15 @@ H5Dvlen_get_buf_size(hid_t dataset_id, hid_t type_id, hid_t space_id, *size = vlen_bufsize.size; done: - if(fspace && H5S_close(fspace) < 0) - HDONE_ERROR(H5E_DATASET, H5E_CLOSEERROR, FAIL, "unable to release dataspace") - if(mspace && H5S_close(mspace) < 0) - HDONE_ERROR(H5E_DATASET, H5E_CLOSEERROR, FAIL, "unable to release dataspace") + if(ret_value < 0) { + if(mspace && H5S_close(mspace) < 0) + HDONE_ERROR(H5E_DATASPACE, H5E_CANTRELEASE, FAIL, "unable to release dataspace") + } /* end if */ + + if(vlen_bufsize.fspace_id && H5I_dec_app_ref(vlen_bufsize.fspace_id) < 0) + HGOTO_ERROR(H5E_DATASPACE, H5E_CANTDEC, FAIL, "problem freeing id") + if(vlen_bufsize.mspace_id && H5I_dec_app_ref(vlen_bufsize.mspace_id) < 0) + HGOTO_ERROR(H5E_DATASPACE, H5E_CANTDEC, FAIL, "problem freeing id") if(vlen_bufsize.fl_tbuf != NULL) vlen_bufsize.fl_tbuf = H5FL_BLK_FREE(vlen_fl_buf, vlen_bufsize.fl_tbuf); if(vlen_bufsize.vl_tbuf != NULL) @@ -966,23 +975,64 @@ done: herr_t H5Dset_extent(hid_t dset_id, const hsize_t size[]) { - H5D_t *dset; /* Dataset for this operation */ + H5VL_object_t *dset; herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_API(FAIL) H5TRACE2("e", "i*h", dset_id, size); /* Check args */ - if(NULL == (dset = (H5D_t *)H5I_object_verify(dset_id, H5I_DATASET))) - HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a dataset") + if(NULL == (dset = (H5VL_object_t *)H5I_object_verify(dset_id, H5I_DATASET))) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "invalid dataset identifier") + if(!size) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "no size specified") - /* Private function */ - if(H5D__set_extent(dset, size, H5AC_dxpl_id) < 0) - HGOTO_ERROR(H5E_DATASET, H5E_CANTINIT, FAIL, "unable to set extend dataset") + /* set the extent through the VOL */ + if((ret_value = H5VL_dataset_specific(dset->vol_obj, dset->vol_info->vol_cls, H5VL_DATASET_SET_EXTENT, + H5AC_dxpl_id, H5_REQUEST_NULL, size)) < 0) + HGOTO_ERROR(H5E_DATASET, H5E_CANTINIT, FAIL, "unable to set extent of dataset") done: FUNC_LEAVE_API(ret_value) } /* end H5Dset_extent() */ + +/*------------------------------------------------------------------------- + * Function: H5D_close_dataset + * + * Purpose: Called when the ref count reaches zero on the dataset_id + * + * Return: Success: Non-negative + * + * Failure: Negative + * + * Programmer: Mohamad Chaarawi + * June 2012 + * + *------------------------------------------------------------------------- + */ +herr_t +H5D_close_dataset(void *_dset) +{ + H5VL_object_t *dset = (H5VL_object_t *)_dset; + herr_t ret_value = SUCCEED; /* Return value */ + + FUNC_ENTER_NOAPI_NOINIT + + /* Close the dataset through the VOL */ + if((ret_value = H5VL_dataset_close(dset->vol_obj, dset->vol_info->vol_cls, + H5AC_dxpl_id, H5_REQUEST_NULL)) < 0) + HGOTO_ERROR(H5E_DATASET, H5E_CLOSEERROR, FAIL, "unable to close dataset") + +done: + /* MSC - Weird thing for datasets and filters: + Always decrement the ref count on the vol for datasets, since + the ID is removed even if the close fails */ + + /* free dset */ + if(H5VL_free_object(dset) < 0) + HGOTO_ERROR(H5E_DATASET, H5E_CANTDEC, FAIL, "unable to free VOL object") + + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5D_close_dataset() */ diff --git a/src/H5Ddbg.c b/src/H5Ddbg.c index a7c6dc1..e187fa2 100644 --- a/src/H5Ddbg.c +++ b/src/H5Ddbg.c @@ -108,7 +108,7 @@ H5Ddebug(hid_t dset_id) H5TRACE1("e", "i", dset_id); /* Check args */ - if(NULL == (dset = (H5D_t *)H5I_object_verify(dset_id, H5I_DATASET))) + if(NULL == (dset = (H5D_t *)H5VL_object_verify(dset_id, H5I_DATASET))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a dataset") /* Print B-tree information */ diff --git a/src/H5Ddeprec.c b/src/H5Ddeprec.c index c44b97b..cf68652 100644 --- a/src/H5Ddeprec.c +++ b/src/H5Ddeprec.c @@ -44,7 +44,7 @@ #include "H5Dpkg.h" /* Datasets */ #include "H5Eprivate.h" /* Error handling */ #include "H5Iprivate.h" /* IDs */ - +#include "H5VLprivate.h" /* VOL plugins */ /****************/ /* Local Macros */ @@ -165,42 +165,54 @@ hid_t H5Dcreate1(hid_t loc_id, const char *name, hid_t type_id, hid_t space_id, hid_t dcpl_id) { - H5G_loc_t loc; /* Object location to insert dataset into */ - H5D_t *dset = NULL; /* New dataset's info */ - const H5S_t *space; /* Dataspace for dataset */ - hid_t ret_value; /* Return value */ + void *dset = NULL; /* dset token from VOL plugin */ + H5VL_object_t *obj = NULL; /* object token of loc_id */ + H5VL_loc_params_t loc_params; + H5P_genplist_t *plist; /* Property list pointer */ + hid_t lcpl_id = H5P_LINK_CREATE_DEFAULT; + hid_t ret_value; /* Return value */ FUNC_ENTER_API(FAIL) H5TRACE5("i", "i*siii", loc_id, name, type_id, space_id, dcpl_id); - /* Check arguments */ - 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") - if(H5I_DATATYPE != H5I_get_type(type_id)) - HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a datatype ID") - if(NULL == (space = (const H5S_t *)H5I_object_verify(space_id,H5I_DATASPACE))) - HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a dataspace ID") if(H5P_DEFAULT == dcpl_id) dcpl_id = H5P_DATASET_CREATE_DEFAULT; else if(TRUE != H5P_isa_class(dcpl_id, H5P_DATASET_CREATE)) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not dataset create property list ID") - /* Build and open the new dataset */ - if(NULL == (dset = H5D__create_named(&loc, name, type_id, space, H5P_LINK_CREATE_DEFAULT, dcpl_id, H5P_DATASET_ACCESS_DEFAULT, H5AC_dxpl_id))) + /* Get the plist structure */ + if(NULL == (plist = (H5P_genplist_t *)H5I_object(dcpl_id))) + HGOTO_ERROR(H5E_ATOM, H5E_BADATOM, FAIL, "can't find object for ID") + + /* set creation properties */ + if(H5P_set(plist, H5VL_PROP_DSET_TYPE_ID, &type_id) < 0) + HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, FAIL, "can't set property value for datatype id") + if(H5P_set(plist, H5VL_PROP_DSET_SPACE_ID, &space_id) < 0) + HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, FAIL, "can't set property value for space id") + if(H5P_set(plist, H5VL_PROP_DSET_LCPL_ID, &lcpl_id) < 0) + HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, FAIL, "can't set property value for lcpl id") + + loc_params.type = H5VL_OBJECT_BY_SELF; + loc_params.obj_type = H5I_get_type(loc_id); + + /* get the location object */ + if(NULL == (obj = H5VL_get_object(loc_id))) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "invalid location identifier") + + /* Create the dataset through the VOL */ + if(NULL == (dset = H5VL_dataset_create(obj->vol_obj, loc_params, obj->vol_info->vol_cls, name, dcpl_id, + H5P_DATASET_ACCESS_DEFAULT, H5AC_dxpl_id, H5_REQUEST_NULL))) HGOTO_ERROR(H5E_DATASET, H5E_CANTINIT, FAIL, "unable to create dataset") - /* Register the new dataset to get an ID for it */ - if((ret_value = H5I_register(H5I_DATASET, dset, TRUE)) < 0) - HGOTO_ERROR(H5E_DATASET, H5E_CANTREGISTER, FAIL, "unable to register dataset") + /* Get an atom for the dataset */ + if((ret_value = H5VL_register_id(H5I_DATASET, dset, obj->vol_info, TRUE)) < 0) + HGOTO_ERROR(H5E_ATOM, H5E_CANTREGISTER, FAIL, "unable to atomize dataset handle") done: - if(ret_value < 0) - if(dset && H5D_close(dset) < 0) + if (ret_value < 0 && dset) + if(H5VL_dataset_close (dset, obj->vol_info->vol_cls, H5AC_dxpl_id, H5_REQUEST_NULL) < 0) HDONE_ERROR(H5E_DATASET, H5E_CLOSEERROR, FAIL, "unable to release dataset") - FUNC_LEAVE_API(ret_value) } /* end H5Dcreate1() */ @@ -225,62 +237,38 @@ done: hid_t H5Dopen1(hid_t loc_id, const char *name) { - H5D_t *dset = NULL; - H5G_loc_t loc; /* Object location of group */ - H5G_loc_t dset_loc; /* Object location of dataset */ - H5G_name_t path; /* Dataset group hier. path */ - H5O_loc_t oloc; /* Dataset object location */ - H5O_type_t obj_type; /* Type of object at location */ - hbool_t loc_found = FALSE; /* Location at 'name' found */ + void *dset = NULL; /* dset token from VOL plugin */ + H5VL_object_t *obj = NULL; /* object token of loc_id */ + H5VL_loc_params_t loc_params; hid_t dapl_id = H5P_DATASET_ACCESS_DEFAULT; /* dapl to use to open dataset */ - hid_t dxpl_id = H5AC_dxpl_id; /* dxpl to use to open datset */ hid_t ret_value; FUNC_ENTER_API(FAIL) H5TRACE2("i", "i*s", loc_id, name); /* Check args */ - 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") - /* Set up dataset location to fill in */ - dset_loc.oloc = &oloc; - dset_loc.path = &path; - H5G_loc_reset(&dset_loc); + loc_params.type = H5VL_OBJECT_BY_SELF; + loc_params.obj_type = H5I_get_type(loc_id); - /* Find the dataset object */ - if(H5G_loc_find(&loc, name, &dset_loc, H5P_DEFAULT, dxpl_id) < 0) - HGOTO_ERROR(H5E_DATASET, H5E_NOTFOUND, FAIL, "not found") - loc_found = TRUE; + /* get the location object */ + if(NULL == (obj = H5VL_get_object(loc_id))) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "invalid location identifier") - /* Check that the object found is the correct type */ - if(H5O_obj_type(&oloc, &obj_type, dxpl_id) < 0) - HGOTO_ERROR(H5E_DATASET, H5E_CANTGET, FAIL, "can't get object type") - if(obj_type != H5O_TYPE_DATASET) - HGOTO_ERROR(H5E_DATASET, H5E_BADTYPE, FAIL, "not a dataset") - - /* Open the dataset */ - if(NULL == (dset = H5D_open(&dset_loc, dapl_id, dxpl_id))) - HGOTO_ERROR(H5E_DATASET, H5E_CANTINIT, FAIL, "can't open dataset") + /* Create the dataset through the VOL */ + if(NULL == (dset = H5VL_dataset_open(obj->vol_obj, loc_params, obj->vol_info->vol_cls, name, dapl_id, H5AC_dxpl_id, H5_REQUEST_NULL))) + HGOTO_ERROR(H5E_DATASET, H5E_CANTINIT, FAIL, "unable to create dataset") - /* Register an atom for the dataset */ - if((ret_value = H5I_register(H5I_DATASET, dset, TRUE)) < 0) - HGOTO_ERROR(H5E_ATOM, H5E_CANTREGISTER, FAIL, "can't register dataset atom") + /* Get an atom for the dataset */ + if((ret_value = H5VL_register_id(H5I_DATASET, dset, obj->vol_info, TRUE)) < 0) + HGOTO_ERROR(H5E_ATOM, H5E_CANTREGISTER, FAIL, "unable to atomize dataset handle") done: - if(ret_value < 0) { - if(dset != NULL) { - if(H5D_close(dset) < 0) - HDONE_ERROR(H5E_DATASET, H5E_CLOSEERROR, FAIL, "unable to release dataset") - } /* end if */ - else { - if(loc_found && H5G_loc_free(&dset_loc) < 0) - HDONE_ERROR(H5E_SYM, H5E_CANTRELEASE, FAIL, "can't free location") - } /* end else */ - } /* end if */ - + if (ret_value < 0 && dset) + if(H5VL_dataset_close (dset, obj->vol_info->vol_cls, H5AC_dxpl_id, H5_REQUEST_NULL) < 0) + HDONE_ERROR(H5E_DATASET, H5E_CLOSEERROR, FAIL, "unable to release dataset") FUNC_LEAVE_API(ret_value) } /* end H5Dopen1() */ @@ -311,7 +299,7 @@ H5Dextend(hid_t dset_id, const hsize_t size[]) H5TRACE2("e", "i*h", dset_id, size); /* Check args */ - if(NULL == (dset = (H5D_t *)H5I_object_verify(dset_id, H5I_DATASET))) + if(NULL == (dset = (H5D_t *)H5VL_object_verify(dset_id, H5I_DATASET))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a dataset") if(!size) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "no size specified") diff --git a/src/H5Dint.c b/src/H5Dint.c index c839df3..7a7c60c 100644 --- a/src/H5Dint.c +++ b/src/H5Dint.c @@ -34,7 +34,7 @@ #include "H5Iprivate.h" /* IDs */ #include "H5Lprivate.h" /* Links */ #include "H5MMprivate.h" /* Memory management */ - +#include "H5VLprivate.h" /* Virtual Object Layer */ /****************/ /* Local Macros */ @@ -114,7 +114,7 @@ static const H5I_class_t H5I_DATASET_CLS[1] = {{ H5I_DATASET, /* ID class value */ 0, /* Class flags */ 0, /* # of reserved IDs for class */ - (H5I_free_t)H5D_close /* Callback routine for closing objects of this class */ + (H5I_free_t)H5D_close_dataset /* Callback routine for closing objects of this class */ }}; @@ -929,7 +929,7 @@ H5D_t * H5D__create(H5F_t *file, hid_t type_id, const H5S_t *space, hid_t dcpl_id, hid_t dapl_id, hid_t dxpl_id) { - const H5T_t *type; /* Datatype for dataset */ + const H5T_t *type, *dt; /* Datatype for dataset */ H5D_t *new_dset = NULL; H5P_genplist_t *dc_plist = NULL; /* New Property list */ hbool_t has_vl_type = FALSE; /* Flag to indicate a VL-type for dataset */ @@ -947,8 +947,10 @@ H5D__create(H5F_t *file, hid_t type_id, const H5S_t *space, hid_t dcpl_id, HDassert(H5I_GENPROP_LST == H5I_get_type(dxpl_id)); /* Get the dataset's datatype */ - if(NULL == (type = (const H5T_t *)H5I_object(type_id))) + if(NULL == (dt = (H5T_t *)H5I_object(type_id))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, NULL, "not a datatype") + /* If this is a named datatype, get the plugin pointer to the datatype */ + type = (const H5T_t *)H5T_get_actual_type(dt); /* Check if the datatype is "sensible" for use in a dataset */ if(H5T_is_sensible(type) != TRUE) @@ -2056,7 +2058,9 @@ herr_t H5D__vlen_get_buf_size(void UNUSED *elem, hid_t type_id, unsigned UNUSED ndim, const hsize_t *point, void *op_data) { H5D_vlen_bufsize_t *vlen_bufsize = (H5D_vlen_bufsize_t *)op_data; + H5VL_object_t *dset = (H5VL_object_t *)vlen_bufsize->dset; H5T_t *dt; /* Datatype for operation */ + H5S_t *fspace; /* File dataspace for operation */ herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_PACKAGE @@ -2073,12 +2077,17 @@ H5D__vlen_get_buf_size(void UNUSED *elem, hid_t type_id, unsigned UNUSED ndim, c HGOTO_ERROR(H5E_DATASET, H5E_NOSPACE, FAIL, "can't resize tbuf") /* Select point to read in */ - if(H5S_select_elements(vlen_bufsize->fspace, H5S_SELECT_SET, (size_t)1, point) < 0) + if(NULL == (fspace = (H5S_t *)H5I_object_verify(vlen_bufsize->fspace_id, H5I_DATASPACE))) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a dataspace") + if(H5S_select_elements(fspace, H5S_SELECT_SET, (size_t)1, point) < 0) HGOTO_ERROR(H5E_DATASET, H5E_CANTCREATE, FAIL, "can't select point") /* Read in the point (with the custom VL memory allocator) */ - if(H5D__read(vlen_bufsize->dset, type_id, vlen_bufsize->mspace, vlen_bufsize->fspace, vlen_bufsize->xfer_pid, vlen_bufsize->fl_tbuf) < 0) - HGOTO_ERROR(H5E_DATASET, H5E_READERROR, FAIL, "can't read point") + if(H5VL_dataset_read(dset->vol_obj, dset->vol_info->vol_cls, + type_id, vlen_bufsize->mspace_id, + vlen_bufsize->fspace_id, vlen_bufsize->xfer_pid, + vlen_bufsize->fl_tbuf, H5_REQUEST_NULL) < 0) + HGOTO_ERROR(H5E_DATASET, H5E_READERROR, FAIL, "can't read point") done: FUNC_LEAVE_NOAPI(ret_value) @@ -2720,8 +2729,18 @@ H5D_get_type(H5D_t *dset) if(H5T_lock(dt, FALSE) < 0) HGOTO_ERROR(H5E_DATASET, H5E_CANTINIT, FAIL, "unable to lock transient datatype") - if((ret_value = H5I_register(H5I_DATATYPE, dt, TRUE)) < 0) - HGOTO_ERROR(H5E_ATOM, H5E_CANTREGISTER, FAIL, "unable to register datatype") + /* Create an atom */ + if(H5T_is_named(dt)) { + /* If this is a committed datatype, we need to recreate the + 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) + HGOTO_ERROR(H5E_ATOM, H5E_CANTREGISTER, FAIL, "unable to register datatype") + } + 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 b91d7f8..e9c203f 100644 --- a/src/H5Dio.c +++ b/src/H5Dio.c @@ -30,6 +30,7 @@ #include "H5Iprivate.h" /* IDs */ #include "H5MMprivate.h" /* Memory management */ #include "H5Sprivate.h" /* Dataspace */ +#include "H5VLprivate.h" /* VOL plugins */ #ifdef H5_HAVE_PARALLEL /* Remove this if H5R_DATASET_REGION is no longer used in this file */ @@ -51,13 +52,6 @@ /* Local Prototypes */ /********************/ -/* Internal I/O routines */ -static herr_t H5D__write(H5D_t *dataset, hid_t mem_type_id, - const H5S_t *mem_space, const H5S_t *file_space, hid_t dset_xfer_plist, - const void *buf); -static herr_t H5D__pre_write(H5D_t *dset, hbool_t direct_write, hid_t mem_type_id, - const H5S_t *mem_space, const H5S_t *file_space, hid_t dxpl_id, const void *buf); - /* Setup/teardown routines */ static herr_t H5D__ioinfo_init(H5D_t *dset, #ifndef H5_HAVE_PARALLEL @@ -126,21 +120,18 @@ herr_t H5Dread(hid_t dset_id, hid_t mem_type_id, hid_t mem_space_id, hid_t file_space_id, hid_t plist_id, void *buf/*out*/) { - H5D_t *dset = NULL; - const H5S_t *mem_space = NULL; - const H5S_t *file_space = NULL; - herr_t ret_value = SUCCEED; /* Return value */ + H5VL_object_t *dset = NULL; + const H5S_t *mem_space = NULL; + const H5S_t *file_space = NULL; + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_API(FAIL) H5TRACE6("e", "iiiiix", dset_id, mem_type_id, mem_space_id, file_space_id, plist_id, buf); /* check arguments */ - if(NULL == (dset = (H5D_t *)H5I_object_verify(dset_id, H5I_DATASET))) - HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a dataset") - if(NULL == dset->oloc.file) - HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a dataset") - + if(NULL == (dset = (H5VL_object_t *)H5I_object_verify(dset_id, H5I_DATASET))) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a dataset") if(mem_space_id < 0 || file_space_id < 0) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a dataspace") @@ -168,8 +159,9 @@ H5Dread(hid_t dset_id, hid_t mem_type_id, hid_t mem_space_id, if(TRUE != H5P_isa_class(plist_id, H5P_DATASET_XFER)) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not xfer parms") - /* read raw data */ - if(H5D__read(dset, mem_type_id, mem_space, file_space, plist_id, buf/*out*/) < 0) + /* Read the data through the VOL */ + if((ret_value = H5VL_dataset_read(dset->vol_obj, dset->vol_info->vol_cls, mem_type_id, mem_space_id, + file_space_id, plist_id, buf, H5_REQUEST_NULL)) < 0) HGOTO_ERROR(H5E_DATASET, H5E_READERROR, FAIL, "can't read data") done: @@ -212,7 +204,7 @@ herr_t H5Dwrite(hid_t dset_id, hid_t mem_type_id, hid_t mem_space_id, hid_t file_space_id, hid_t dxpl_id, const void *buf) { - H5D_t *dset = NULL; + H5VL_object_t *dset = NULL; H5P_genplist_t *plist; /* Property list pointer */ const H5S_t *mem_space = NULL; const H5S_t *file_space = NULL; @@ -224,10 +216,8 @@ H5Dwrite(hid_t dset_id, hid_t mem_type_id, hid_t mem_space_id, dxpl_id, buf); /* check arguments */ - if(NULL == (dset = (H5D_t *)H5I_object_verify(dset_id, H5I_DATASET))) - HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a dataset") - if(NULL == dset->oloc.file) - HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a file") + if(NULL == (dset = (H5VL_object_t *)H5I_object_verify(dset_id, H5I_DATASET))) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a dataset") /* Get the default dataset transfer property list if the user didn't provide one */ if(H5P_DEFAULT == dxpl_id) @@ -267,8 +257,10 @@ H5Dwrite(hid_t dset_id, hid_t mem_type_id, hid_t mem_space_id, } /* end if */ } - if(H5D__pre_write(dset, direct_write, mem_type_id, mem_space, file_space, dxpl_id, buf) < 0) - HGOTO_ERROR(H5E_DATASET, H5E_WRITEERROR, FAIL, "can't prepare for writing data") + /* Write the data through the VOL */ + if((ret_value = H5VL_dataset_write(dset->vol_obj, dset->vol_info->vol_cls, 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: FUNC_LEAVE_API(ret_value) @@ -287,7 +279,7 @@ done: * *------------------------------------------------------------------------- */ -static herr_t +herr_t H5D__pre_write(H5D_t *dset, hbool_t direct_write, hid_t mem_type_id, const H5S_t *mem_space, const H5S_t *file_space, hid_t dxpl_id, const void *buf) @@ -586,7 +578,7 @@ done: * *------------------------------------------------------------------------- */ -static herr_t +herr_t H5D__write(H5D_t *dataset, hid_t mem_type_id, const H5S_t *mem_space, const H5S_t *file_space, hid_t dxpl_id, const void *buf) { diff --git a/src/H5Doh.c b/src/H5Doh.c index abf76d0..74521b9 100644 --- a/src/H5Doh.c +++ b/src/H5Doh.c @@ -332,7 +332,7 @@ H5O__dset_get_oloc(hid_t obj_id) FUNC_ENTER_STATIC /* Get the dataset */ - if(NULL == (dset = (H5D_t *)H5I_object(obj_id))) + if(NULL == (dset = (H5D_t *)H5VL_object(obj_id))) HGOTO_ERROR(H5E_OHDR, H5E_BADATOM, NULL, "couldn't get object from ID") /* Get the dataset's object header location */ diff --git a/src/H5Dpkg.h b/src/H5Dpkg.h index 5a785a3..ae37c98 100644 --- a/src/H5Dpkg.h +++ b/src/H5Dpkg.h @@ -479,9 +479,9 @@ typedef struct H5D_fill_buf_info_t { /* Internal data structure for computing variable-length dataset's total size */ typedef struct { - H5D_t *dset; /* Dataset for operation */ - H5S_t *fspace; /* Dataset's dataspace for operation */ - H5S_t *mspace; /* Memory dataspace for operation */ + void *dset; /* Dataset for operation */ + hid_t fspace_id; /* ID of the file dataset's dataspace we are working on */ + hid_t mspace_id; /* ID of the memory dataset's dataspace we are working on */ void *fl_tbuf; /* Ptr to the temporary buffer we are using for fixed-length data */ void *vl_tbuf; /* Ptr to the temporary buffer we are using for VL data */ hid_t xfer_pid; /* ID of the dataset xfer property list */ @@ -550,9 +550,12 @@ H5_DLL herr_t H5D__mark(const H5D_t *dataset, hid_t dxpl_id, unsigned flags); H5_DLL herr_t H5D__flush_real(H5D_t *dataset, hid_t dxpl_id); /* Internal I/O routines */ -H5_DLL herr_t H5D__read(H5D_t *dataset, hid_t mem_type_id, - const H5S_t *mem_space, const H5S_t *file_space, hid_t dset_xfer_plist, - void *buf/*out*/); +H5_DLL herr_t H5D__pre_write(H5D_t *dset, hbool_t direct_write, hid_t mem_type_id, + const H5S_t *mem_space, const H5S_t *file_space, hid_t dxpl_id, const void *buf); +H5_DLL herr_t H5D__read(H5D_t *dataset, hid_t mem_type_id, const H5S_t *mem_space, + const H5S_t *file_space, hid_t dset_xfer_plist, void *buf/*out*/); +H5_DLL herr_t H5D__write(H5D_t *dataset, hid_t mem_type_id, const H5S_t *mem_space, + const H5S_t *file_space, hid_t dset_xfer_plist, const void *buf); /* Functions that perform direct serial I/O operations */ H5_DLL herr_t H5D__select_read(const H5D_io_info_t *io_info, diff --git a/src/H5Dtest.c b/src/H5Dtest.c index eef3c91..e528494 100644 --- a/src/H5Dtest.c +++ b/src/H5Dtest.c @@ -90,7 +90,7 @@ H5D__layout_version_test(hid_t did, unsigned *version) FUNC_ENTER_PACKAGE /* Check args */ - if(NULL == (dset = (H5D_t *)H5I_object_verify(did, H5I_DATASET))) + if(NULL == (dset = (H5D_t *)H5VL_object_verify(did, H5I_DATASET))) HGOTO_ERROR(H5E_DATASET, H5E_BADTYPE, FAIL, "not a dataset") if(version) @@ -129,7 +129,7 @@ H5D__layout_contig_size_test(hid_t did, hsize_t *size) FUNC_ENTER_PACKAGE /* Check args */ - if(NULL == (dset = (H5D_t *)H5I_object_verify(did, H5I_DATASET))) + if(NULL == (dset = (H5D_t *)H5VL_object_verify(did, H5I_DATASET))) HGOTO_ERROR(H5E_DATASET, H5E_BADTYPE, FAIL, "not a dataset") if(size) { @@ -170,7 +170,7 @@ H5D__current_cache_size_test(hid_t did, size_t *nbytes_used, int *nused) FUNC_ENTER_PACKAGE /* Check args */ - if(NULL == (dset = (H5D_t *)H5I_object_verify(did, H5I_DATASET))) + if(NULL == (dset = (H5D_t *)H5VL_object_verify(did, H5I_DATASET))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a dataset") if(nbytes_used) { diff --git a/src/H5ESpublic.h b/src/H5ESpublic.h new file mode 100644 index 0000000..c6efd91 --- /dev/null +++ b/src/H5ESpublic.h @@ -0,0 +1,40 @@ +/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * + * 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 files COPYING and Copyright.html. COPYING can be found at the root * + * of the source code distribution tree; Copyright.html can be found at the * + * root level of an installed copy of the electronic HDF5 document set and * + * is linked from the top-level documents page. It can also be found at * + * http://hdfgroup.org/HDF5/doc/Copyright.html. If you do not have * + * access to either file, you may request a copy from help@hdfgroup.org. * + * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ + +/* + * Programmer: Mohamad Chaarawi <chaarawi@hdfgroup.org> + * July 24, 2014 + */ +#ifndef _H5ESpublic_H +#define _H5ESpublic_H + +/* Asynchronous operation status */ +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_t; + +#ifdef __cplusplus +extern "C" { +#endif + + +#ifdef __cplusplus +} +#endif + +#endif /* _H5ESpublic_H */ diff --git a/src/H5Edefin.h b/src/H5Edefin.h index 46087ee..a2ee62c 100644 --- a/src/H5Edefin.h +++ b/src/H5Edefin.h @@ -23,6 +23,7 @@ /* Major error IDs */ hid_t H5E_FUNC_g = FAIL; /* Function entry/exit */ hid_t H5E_FILE_g = FAIL; /* File accessibilty */ +hid_t H5E_VOL_g = FAIL; /* Virtual Object Layer */ hid_t H5E_SOHM_g = FAIL; /* Shared Object Header Messages */ hid_t H5E_SYM_g = FAIL; /* Symbol table */ hid_t H5E_PLUGIN_g = FAIL; /* Plugin for dynamically loaded library */ diff --git a/src/H5Einit.h b/src/H5Einit.h index 68dc004..b00dc10 100644 --- a/src/H5Einit.h +++ b/src/H5Einit.h @@ -34,6 +34,11 @@ if((msg = H5E_create_msg(cls, H5E_MAJOR, "File accessibilty"))==NULL) HGOTO_ERROR(H5E_ERROR, H5E_CANTINIT, FAIL, "error message initialization failed") if((H5E_FILE_g = H5I_register(H5I_ERROR_MSG, msg, FALSE))<0) HGOTO_ERROR(H5E_ERROR, H5E_CANTREGISTER, FAIL, "can't register error message") +assert(H5E_VOL_g==(-1)); +if((msg = H5E_create_msg(cls, H5E_MAJOR, "Virtual Object Layer"))==NULL) + HGOTO_ERROR(H5E_ERROR, H5E_CANTINIT, FAIL, "error message initialization failed") +if((H5E_VOL_g = H5I_register(H5I_ERROR_MSG, msg, FALSE))<0) + HGOTO_ERROR(H5E_ERROR, H5E_CANTREGISTER, FAIL, "can't register error message") assert(H5E_SOHM_g==(-1)); if((msg = H5E_create_msg(cls, H5E_MAJOR, "Shared Object Header Messages"))==NULL) HGOTO_ERROR(H5E_ERROR, H5E_CANTINIT, FAIL, "error message initialization failed") diff --git a/src/H5Epubgen.h b/src/H5Epubgen.h index 00af913..7f8a935 100644 --- a/src/H5Epubgen.h +++ b/src/H5Epubgen.h @@ -26,6 +26,7 @@ #define H5E_FUNC (H5OPEN H5E_FUNC_g) #define H5E_FILE (H5OPEN H5E_FILE_g) +#define H5E_VOL (H5OPEN H5E_VOL_g) #define H5E_SOHM (H5OPEN H5E_SOHM_g) #define H5E_SYM (H5OPEN H5E_SYM_g) #define H5E_PLUGIN (H5OPEN H5E_PLUGIN_g) @@ -59,6 +60,7 @@ #define H5E_CACHE (H5OPEN H5E_CACHE_g) H5_DLLVAR hid_t H5E_FUNC_g; /* Function entry/exit */ H5_DLLVAR hid_t H5E_FILE_g; /* File accessibilty */ +H5_DLLVAR hid_t H5E_VOL_g; /* Virtual Object Layer */ H5_DLLVAR hid_t H5E_SOHM_g; /* Shared Object Header Messages */ H5_DLLVAR hid_t H5E_SYM_g; /* Symbol table */ H5_DLLVAR hid_t H5E_PLUGIN_g; /* Plugin for dynamically loaded library */ diff --git a/src/H5Eterm.h b/src/H5Eterm.h index 867c78c..d263479 100644 --- a/src/H5Eterm.h +++ b/src/H5Eterm.h @@ -24,6 +24,7 @@ H5E_FUNC_g= H5E_FILE_g= +H5E_VOL_g= H5E_SOHM_g= H5E_SYM_g= H5E_PLUGIN_g= @@ -27,19 +27,12 @@ /* Headers */ /***********/ #include "H5private.h" /* Generic Functions */ -#include "H5Aprivate.h" /* Attributes */ -#include "H5ACprivate.h" /* Metadata cache */ -#include "H5Dprivate.h" /* Datasets */ #include "H5Eprivate.h" /* Error handling */ #include "H5Fpkg.h" /* File access */ -#include "H5FDprivate.h" /* File drivers */ -#include "H5Gprivate.h" /* Groups */ #include "H5Iprivate.h" /* IDs */ -#include "H5MFprivate.h" /* File memory management */ #include "H5MMprivate.h" /* Memory management */ #include "H5Pprivate.h" /* Property lists */ -#include "H5SMprivate.h" /* Shared Object Header Messages */ -#include "H5Tprivate.h" /* Datatypes */ +#include "H5VLprivate.h" /* VOL plugins */ /****************/ @@ -76,13 +69,17 @@ /* Local Variables */ /*******************/ +/* Declare a free list to manage the H5VL_t struct */ +H5FL_EXTERN(H5VL_t); +/* Declare a free list to manage the H5VL_object_t struct */ +H5FL_EXTERN(H5VL_object_t); /* File ID class */ static const H5I_class_t H5I_FILE_CLS[1] = {{ H5I_FILE, /* ID class value */ 0, /* Class flags */ 0, /* # of reserved IDs for class */ - (H5I_free_t)H5F_close /* Callback routine for closing objects of this class */ + (H5I_free_t)H5F_close_file /* Callback routine for closing objects of this class */ }}; @@ -102,6 +99,7 @@ static herr_t H5F__init_pub_interface(void) { herr_t ret_value = SUCCEED; /* Return value */ + FUNC_ENTER_STATIC /* @@ -210,22 +208,19 @@ H5F_term_interface(void) hid_t H5Fget_create_plist(hid_t file_id) { - H5F_t *file; /* File info */ - H5P_genplist_t *plist; /* Property list */ - hid_t ret_value; /* Return value */ + H5VL_object_t *obj = NULL; + hid_t ret_value; /* Return value */ FUNC_ENTER_API(FAIL) H5TRACE1("i", "i", file_id); - /* check args */ - if(NULL == (file = (H5F_t *)H5I_object_verify(file_id, H5I_FILE))) - HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a file") - if(NULL == (plist = (H5P_genplist_t *)H5I_object(file->shared->fcpl_id))) - HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a property list") + /* get the file object */ + if(NULL == (obj = (H5VL_object_t *)H5I_object(file_id))) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "invalid file identifier") - /* Create the property list object to return */ - if((ret_value = H5P_copy_plist(plist, TRUE)) < 0) - HGOTO_ERROR(H5E_INTERNAL, H5E_CANTINIT, FAIL, "unable to copy file creation properties") + if(H5VL_file_get(obj->vol_obj, obj->vol_info->vol_cls, H5VL_FILE_GET_FCPL, + H5AC_dxpl_id, H5_REQUEST_NULL, &ret_value) < 0) + HGOTO_ERROR(H5E_INTERNAL, H5E_CANTGET, FAIL, "unable to get file creation properties") done: FUNC_LEAVE_API(ret_value) @@ -256,26 +251,58 @@ done: hid_t H5Fget_access_plist(hid_t file_id) { - H5F_t *f; /* File info */ + H5VL_object_t *file = NULL; + hid_t fapl_id = FAIL; hid_t ret_value; /* Return value */ FUNC_ENTER_API(FAIL) H5TRACE1("i", "i", file_id); - /* Check args */ - if(NULL == (f = (H5F_t *)H5I_object_verify(file_id, H5I_FILE))) - HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a file") + /* get the file object */ + if(NULL == (file = (H5VL_object_t *)H5I_object(file_id))) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "invalid file identifier") - /* Retrieve the file's access property list */ - if((ret_value = H5F_get_access_plist(f, TRUE)) < 0) - HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, FAIL, "can't get file access property list") + if(H5VL_file_get(file->vol_obj, file->vol_info->vol_cls, H5VL_FILE_GET_FAPL, + H5AC_dxpl_id, H5_REQUEST_NULL, &fapl_id) < 0) + HGOTO_ERROR(H5E_INTERNAL, H5E_CANTGET, FAIL, "unable to get file creation properties") + ret_value = fapl_id; done: + if(ret_value < 0 && fapl_id != FAIL) + if(H5I_dec_ref(fapl_id) < 0) + HGOTO_ERROR(H5E_ATOM, H5E_CANTDEC, FAIL, "decrementing plist ID failed") + FUNC_LEAVE_API(ret_value) } /* end H5Fget_access_plist() */ /*------------------------------------------------------------------------- + * Function: H5F_get_all_count_cb + * + * Purpose: Get counter of all object types currently open. + * + * Return: Non-negative on success; negative on failure. + * + * Programmer: Mohamad Chaarawi + * May 2012 + * + *------------------------------------------------------------------------- + */ +static int +H5F_get_all_count_cb(void UNUSED *obj_ptr, hid_t UNUSED obj_id, void *key) +{ + H5F_trav_obj_cnt_t *udata = (H5F_trav_obj_cnt_t *)key; + int ret_value = H5_ITER_CONT; /* Return value */ + + FUNC_ENTER_NOAPI_NOINIT_NOERR + + *(udata->obj_count) = *(udata->obj_count)+1; + + FUNC_LEAVE_NOAPI(ret_value) +} /* H5F_get_all_count_cb */ + + +/*------------------------------------------------------------------------- * Function: H5Fget_obj_count * * Purpose: Public function returning the number of opened object IDs @@ -291,25 +318,50 @@ done: ssize_t H5Fget_obj_count(hid_t file_id, unsigned types) { - H5F_t *f = NULL; /* File to query */ - size_t obj_count = 0; /* Number of opened objects */ - ssize_t ret_value; /* Return value */ + ssize_t ret_value = 0; /* Return value */ FUNC_ENTER_API(FAIL) H5TRACE2("Zs", "iIu", file_id, types); - /* Check arguments */ - if(file_id != (hid_t)H5F_OBJ_ALL && (NULL == (f = (H5F_t *)H5I_object_verify(file_id, H5I_FILE)))) - HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "not a file id") - if(0 == (types & H5F_OBJ_ALL)) - HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "not an object type") + if(file_id != (hid_t)H5F_OBJ_ALL) { + H5VL_object_t *obj; - /* Perform the query */ - if(H5F_get_obj_count(f, types, TRUE, &obj_count) < 0) - HGOTO_ERROR(H5E_INTERNAL, H5E_BADITER, FAIL, "H5F_get_obj_count failed") + /* get the file object */ + if(NULL == (obj = (H5VL_object_t *)H5I_object_verify(file_id, H5I_FILE))) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a file id") - /* Set the return value */ - ret_value = (ssize_t)obj_count; + if(H5VL_file_get(obj->vol_obj, obj->vol_info->vol_cls, H5VL_FILE_GET_OBJ_COUNT, + H5AC_dxpl_id, H5_REQUEST_NULL, types, &ret_value) < 0) + HGOTO_ERROR(H5E_INTERNAL, H5E_CANTGET, FAIL, "unable to get object count in file(s)") + } + /* iterate over all open files and get the obj count for each */ + else { + H5F_trav_obj_cnt_t udata; + + udata.obj_count = &ret_value; + udata.types = types | H5F_OBJ_LOCAL; + + if(types & H5F_OBJ_FILE) { + if(H5I_iterate(H5I_FILE, H5F_get_all_count_cb, &udata, TRUE) < 0) + HGOTO_ERROR(H5E_FILE, H5E_BADITER, FAIL, "iteration failed(1)"); + } + if(types & H5F_OBJ_DATASET) { + if(H5I_iterate(H5I_DATASET, H5F_get_all_count_cb, &udata, TRUE) < 0) + HGOTO_ERROR(H5E_FILE, H5E_BADITER, FAIL, "iteration failed(1)"); + } + if(types & H5F_OBJ_GROUP) { + if(H5I_iterate(H5I_GROUP, H5F_get_all_count_cb, &udata, TRUE) < 0) + HGOTO_ERROR(H5E_FILE, H5E_BADITER, FAIL, "iteration failed(1)"); + } + if(types & H5F_OBJ_DATATYPE) { + if(H5I_iterate(H5I_DATATYPE, H5F_get_all_count_cb, &udata, TRUE) < 0) + HGOTO_ERROR(H5E_FILE, H5E_BADITER, FAIL, "iteration failed(1)"); + } + if(types & H5F_OBJ_ATTR) { + if(H5I_iterate(H5I_ATTR, H5F_get_all_count_cb, &udata, TRUE) < 0) + HGOTO_ERROR(H5E_FILE, H5E_BADITER, FAIL, "iteration failed(1)"); + } + } done: FUNC_LEAVE_API(ret_value) @@ -317,6 +369,37 @@ done: /*------------------------------------------------------------------------- + * Function: H5F_get_all_ids_cb + * + * Purpose: Get ids of all object types currently open. + * + * Return: Non-negative on success; negative on failure. + * + * Programmer: Mohamad Chaarawi + * May 2012 + * + *------------------------------------------------------------------------- + */ +static int +H5F_get_all_ids_cb(void UNUSED *obj_ptr, hid_t obj_id, void *key) +{ + H5F_trav_obj_ids_t *udata = (H5F_trav_obj_ids_t *)key; + int ret_value = H5_ITER_CONT; /* Return value */ + + FUNC_ENTER_NOAPI_NOINIT_NOERR + + 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; + +done: + FUNC_LEAVE_NOAPI(ret_value) +} /* H5F_get_all_ids_cb */ + + +/*------------------------------------------------------------------------- * Function: H5Fget_object_ids * * Purpose: Public function to return a list of opened object IDs. @@ -337,27 +420,58 @@ done: ssize_t H5Fget_obj_ids(hid_t file_id, unsigned types, size_t max_objs, hid_t *oid_list) { - H5F_t *f = NULL; /* File to query */ - size_t obj_id_count = 0; /* Number of open objects */ - ssize_t ret_value; /* Return value */ + ssize_t ret_value = 0; /* Return value */ FUNC_ENTER_API(FAIL) H5TRACE4("Zs", "iIuz*i", file_id, types, max_objs, oid_list); - /* Check arguments */ - if(file_id != (hid_t)H5F_OBJ_ALL && (NULL == (f = (H5F_t *)H5I_object_verify(file_id, H5I_FILE)))) - HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "not a file id") if(0 == (types & H5F_OBJ_ALL)) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "not an object type") if(!oid_list) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "object ID list is NULL") - /* Perform the query */ - if(H5F_get_obj_ids(f, types, max_objs, oid_list, TRUE, &obj_id_count) < 0) - HGOTO_ERROR(H5E_INTERNAL, H5E_BADITER, FAIL, "H5F_get_obj_ids failed") - - /* Set the return value */ - ret_value = (ssize_t)obj_id_count; + /* Check arguments */ + if(file_id != (hid_t)H5F_OBJ_ALL) { + H5VL_object_t *obj; + + /* get the file object */ + if(NULL == (obj = (H5VL_object_t *)H5I_object_verify(file_id, H5I_FILE))) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "invalid file identifier") + + if(H5VL_file_get(obj->vol_obj, obj->vol_info->vol_cls, H5VL_FILE_GET_OBJ_IDS, + H5AC_dxpl_id, H5_REQUEST_NULL, types, max_objs, oid_list, &ret_value) < 0) + HGOTO_ERROR(H5E_INTERNAL, H5E_CANTGET, FAIL, "unable to get object count in file(s)") + } + /* iterate over all open files and get the obj count for each */ + else if (oid_list && max_objs){ + H5F_trav_obj_ids_t udata; + + //udata.types = types | H5F_OBJ_LOCAL; + udata.max_objs = max_objs; + udata.oid_list = oid_list; + udata.obj_count = &ret_value; + + if(types & H5F_OBJ_FILE) { + if(H5I_iterate(H5I_FILE, H5F_get_all_ids_cb, &udata, TRUE) < 0) + HGOTO_ERROR(H5E_FILE, H5E_BADITER, FAIL, "iteration failed(1)"); + } + if(types & H5F_OBJ_DATASET) { + if(H5I_iterate(H5I_DATASET, H5F_get_all_ids_cb, &udata, TRUE) < 0) + HGOTO_ERROR(H5E_FILE, H5E_BADITER, FAIL, "iteration failed(1)"); + } + if(types & H5F_OBJ_GROUP) { + if(H5I_iterate(H5I_GROUP, H5F_get_all_ids_cb, &udata, TRUE) < 0) + HGOTO_ERROR(H5E_FILE, H5E_BADITER, FAIL, "iteration failed(1)"); + } + if(types & H5F_OBJ_DATATYPE) { + if(H5I_iterate(H5I_DATATYPE, H5F_get_all_ids_cb, &udata, TRUE) < 0) + HGOTO_ERROR(H5E_FILE, H5E_BADITER, FAIL, "iteration failed(1)"); + } + if(types & H5F_OBJ_ATTR) { + if(H5I_iterate(H5I_ATTR, H5F_get_all_ids_cb, &udata, TRUE) < 0) + HGOTO_ERROR(H5E_FILE, H5E_BADITER, FAIL, "iteration failed(1)"); + } + } done: FUNC_LEAVE_API(ret_value) @@ -381,8 +495,8 @@ done: herr_t H5Fget_vfd_handle(hid_t file_id, hid_t fapl, void **file_handle) { - H5F_t *file; /* File to query */ - herr_t ret_value = SUCCEED; /* Return value */ + H5VL_object_t *obj = NULL; + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_API(FAIL) H5TRACE3("e", "ii**x", file_id, fapl, file_handle); @@ -391,13 +505,13 @@ H5Fget_vfd_handle(hid_t file_id, hid_t fapl, void **file_handle) if(!file_handle) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "invalid file handle pointer") - /* Get the file */ - if(NULL == (file = (H5F_t *)H5I_object_verify(file_id, H5I_FILE))) - HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "not a file id") + /* get the file object */ + if(NULL == (obj = (H5VL_object_t *)H5I_object(file_id))) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "invalid file identifier") - /* Retrieve the VFD handle for the file */ - if(H5F_get_vfd_handle(file, fapl, file_handle) < 0) - HGOTO_ERROR(H5E_FILE, H5E_CANTGET, FAIL, "can't retrieve VFD handle") + if(H5VL_file_optional(obj->vol_obj, obj->vol_info->vol_cls, H5AC_dxpl_id, H5_REQUEST_NULL, + H5VL_FILE_GET_VFD_HANDLE, file_handle, fapl) < 0) + HGOTO_ERROR(H5E_INTERNAL, H5E_CANTGET, FAIL, "unable to get file handle") done: FUNC_LEAVE_API(ret_value) @@ -405,45 +519,46 @@ done: /*------------------------------------------------------------------------- - * Function: H5Fis_hdf5 + * Function: H5Fis_accessible * - * Purpose: Check the file signature to detect an HDF5 file. - * - * Bugs: This function is not robust: it only uses the default file - * driver when attempting to open the file when in fact it - * should use all known file drivers. + * Purpose: Check if the file can be opened with the given fapl. * * Return: Success: TRUE/FALSE * * Failure: Negative * - * Programmer: Unknown + * Programmer: Mohamad Chaarawi + * June 2012 * - * Modifications: - * Robb Matzke, 1999-08-02 - * Rewritten to use the virtual file layer. *------------------------------------------------------------------------- */ htri_t -H5Fis_hdf5(const char *name) +H5Fis_accessible(const char *name, hid_t fapl_id) { htri_t ret_value; /* Return value */ FUNC_ENTER_API(FAIL) - H5TRACE1("t", "*s", name); + H5TRACE2("t", "*si", name, fapl_id); - /* Check args and all the boring stuff. */ + /* Check args */ if(!name || !*name) HGOTO_ERROR(H5E_ARGS, H5E_BADRANGE, FAIL, "no file name specified") - /* call the private is_HDF5 function */ - if((ret_value = H5F_is_hdf5(name)) < 0) - HGOTO_ERROR(H5E_FILE, H5E_NOTHDF5, FAIL, "unable open file") + /* Check the file access property list */ + if(H5P_DEFAULT == fapl_id) + fapl_id = H5P_FILE_ACCESS_DEFAULT; + else + if(TRUE != H5P_isa_class(fapl_id, H5P_FILE_ACCESS)) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not file access property list") + + /* Call into the VOL to check if file is accessible */ + if(H5VL_file_specific(NULL, NULL, H5VL_FILE_IS_ACCESSIBLE, H5AC_dxpl_id, + H5_REQUEST_NULL, fapl_id, name, &ret_value) < 0) + HGOTO_ERROR(H5E_INTERNAL, H5E_CANTGET, FAIL, "unable to get file handle") done: - FUNC_LEAVE_API(ret_value) -} /* end H5Fis_hdf5() */ +} /* end H5Fis_accessible() */ /*------------------------------------------------------------------------- @@ -476,8 +591,12 @@ done: hid_t H5Fcreate(const char *filename, unsigned flags, hid_t fcpl_id, hid_t fapl_id) { - H5F_t *new_file = NULL; /*file struct for new file */ - hid_t ret_value; /*return value */ + void *file; /* file object returned from the plugin */ + H5P_genplist_t *plist; /* Property list pointer */ + hid_t plugin_id; /* VOL plugin identigier attached to fapl_id */ + H5VL_class_t *vol_cls = NULL; /* VOL Class structure for callback info */ + H5VL_t *vol_info = NULL; /* VOL info struct */ + hid_t ret_value; /* return value */ FUNC_ENTER_API(FAIL) H5TRACE4("i", "*sIuii", filename, flags, fcpl_id, fapl_id); @@ -508,33 +627,33 @@ H5Fcreate(const char *filename, unsigned flags, hid_t fcpl_id, hid_t fapl_id) if(TRUE != H5P_isa_class(fapl_id, H5P_FILE_ACCESS)) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not file access property list") - /* - * 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; + /* 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_get(plist, H5F_ACS_VOL_ID_NAME, &plugin_id) < 0) + HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, FAIL, "can't get vol plugin ID") - /* - * Create a new file or truncate an existing file. - */ - if(NULL == (new_file = H5F_open(filename, flags, fcpl_id, fapl_id, H5AC_dxpl_id))) + if(NULL == (vol_cls = (H5VL_class_t *)H5I_object_verify(plugin_id, H5I_VOL))) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a VOL plugin ID") + + /* create a new file or truncate an existing file through the VOL */ + if(NULL == (file = H5VL_file_create(vol_cls, filename, flags, fcpl_id, fapl_id, + H5AC_dxpl_id, H5_REQUEST_NULL))) HGOTO_ERROR(H5E_FILE, H5E_CANTOPENFILE, FAIL, "unable to create file") - /* Get an atom for the file */ - if((ret_value = H5I_register(H5I_FILE, new_file, TRUE)) < 0) - HGOTO_ERROR(H5E_ATOM, H5E_CANTREGISTER, FAIL, "unable to atomize file") + /* setup VOL info struct */ + if(NULL == (vol_info = H5FL_CALLOC(H5VL_t))) + HGOTO_ERROR(H5E_FILE, H5E_NOSPACE, FAIL, "can't allocate VL info struct") + vol_info->vol_cls = vol_cls; + vol_info->vol_id = plugin_id; + if(H5I_inc_ref(vol_info->vol_id, FALSE) < 0) + HGOTO_ERROR(H5E_ATOM, H5E_CANTINC, FAIL, "unable to increment ref count on VOL plugin") - /* Keep this ID in file object structure */ - new_file->file_id = ret_value; + /* Get an atom for the file */ + if((ret_value = H5VL_register_id(H5I_FILE, file, vol_info, TRUE)) < 0) + HGOTO_ERROR(H5E_ATOM, H5E_CANTREGISTER, FAIL, "unable to atomize file handle") done: - if(ret_value < 0 && new_file) - if(H5F_close(new_file) < 0) - HDONE_ERROR(H5E_FILE, H5E_CANTCLOSEFILE, FAIL, "problems closing file") - FUNC_LEAVE_API(ret_value) } /* end H5Fcreate() */ @@ -582,8 +701,12 @@ done: hid_t H5Fopen(const char *filename, unsigned flags, hid_t fapl_id) { - H5F_t *new_file = NULL; /*file struct for new file */ - hid_t ret_value; /*return value */ + void *file; /* file object returned from the plugin */ + H5P_genplist_t *plist; /* Property list pointer */ + hid_t plugin_id; /* VOL plugin identigier attached to fapl_id */ + H5VL_class_t *vol_cls = NULL; /* VOL Class structure for callback info */ + H5VL_t *vol_info = NULL; /* VOL info struct */ + hid_t ret_value; /* return value */ FUNC_ENTER_API(FAIL) H5TRACE3("i", "*sIui", filename, flags, fapl_id); @@ -601,21 +724,32 @@ H5Fopen(const char *filename, unsigned flags, hid_t fapl_id) if(TRUE != H5P_isa_class(fapl_id, H5P_FILE_ACCESS)) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not file access property list") - /* Open the file */ - if(NULL == (new_file = H5F_open(filename, flags, H5P_FILE_CREATE_DEFAULT, fapl_id, H5AC_dxpl_id))) - HGOTO_ERROR(H5E_FILE, H5E_CANTOPENFILE, FAIL, "unable to open file") + /* 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_get(plist, H5F_ACS_VOL_ID_NAME, &plugin_id) < 0) + HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, FAIL, "can't get vol plugin ID") + + if(NULL == (vol_cls = (H5VL_class_t *)H5I_object_verify(plugin_id, H5I_VOL))) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a VOL plugin ID") + + /* Open the file through the VOL layer */ + if(NULL == (file = H5VL_file_open(vol_cls, filename, flags, fapl_id, H5AC_dxpl_id, H5_REQUEST_NULL))) + HGOTO_ERROR(H5E_FILE, H5E_CANTOPENFILE, FAIL, "unable to create file") + + /* setup VOL info struct */ + if(NULL == (vol_info = H5FL_CALLOC(H5VL_t))) + HGOTO_ERROR(H5E_FILE, H5E_NOSPACE, FAIL, "can't allocate VL info struct") + vol_info->vol_cls = vol_cls; + vol_info->vol_id = plugin_id; + if(H5I_inc_ref(vol_info->vol_id, FALSE) < 0) + HGOTO_ERROR(H5E_ATOM, H5E_CANTINC, FAIL, "unable to increment ref count on VOL plugin") /* Get an atom for the file */ - if((ret_value = H5I_register(H5I_FILE, new_file, TRUE)) < 0) + if((ret_value = H5VL_register_id(H5I_FILE, file, vol_info, TRUE)) < 0) HGOTO_ERROR(H5E_ATOM, H5E_CANTREGISTER, FAIL, "unable to atomize file handle") - /* Keep this ID in file object structure */ - new_file->file_id = ret_value; - done: - if(ret_value < 0 && new_file && H5F_try_close(new_file) < 0) - HDONE_ERROR(H5E_FILE, H5E_CANTCLOSEFILE, FAIL, "problems closing file") - FUNC_LEAVE_API(ret_value) } /* end H5Fopen() */ @@ -637,103 +771,26 @@ done: herr_t H5Fflush(hid_t object_id, H5F_scope_t scope) { - H5F_t *f = NULL; /* File to flush */ - H5O_loc_t *oloc = NULL; /* Object location for ID */ + H5VL_object_t *obj = NULL; + H5I_type_t obj_type; herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_API(FAIL) H5TRACE2("e", "iFs", object_id, scope); - switch(H5I_get_type(object_id)) { - case H5I_FILE: - if(NULL == (f = (H5F_t *)H5I_object(object_id))) - HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "invalid file identifier") - break; - - case H5I_GROUP: - { - H5G_t *grp; - - if(NULL == (grp = (H5G_t *)H5I_object(object_id))) - HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "invalid group identifier") - oloc = H5G_oloc(grp); - } - break; - - case H5I_DATATYPE: - { - H5T_t *type; - - if(NULL == (type = (H5T_t *)H5I_object(object_id))) - HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "invalid type identifier") - oloc = H5T_oloc(type); - } - break; - - case H5I_DATASET: - { - H5D_t *dset; - - if(NULL == (dset = (H5D_t *)H5I_object(object_id))) - HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "invalid dataset identifier") - oloc = H5D_oloc(dset); - } - break; - - case H5I_ATTR: - { - H5A_t *attr; - - if(NULL == (attr = (H5A_t *)H5I_object(object_id))) - HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "invalid attribute identifier") - oloc = H5A_oloc(attr); - } - break; - - case H5I_UNINIT: - case H5I_BADID: - case H5I_DATASPACE: - case H5I_REFERENCE: - case H5I_VFL: - 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, FAIL, "not a file or file object") - } /* end switch */ - - if(!f) { - if(!oloc) - HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "object is not assocated with a file") - f = oloc->file; - } /* end if */ - if(!f) - HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "object is not associated with a file") + 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) { + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a file or file object") + } - /* Flush the file */ - /* - * 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, H5AC_dxpl_id) < 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, H5AC_dxpl_id, FALSE) < 0) - HGOTO_ERROR(H5E_FILE, H5E_CANTFLUSH, FAIL, "unable to flush file's cached information") - } /* end else */ - } /* end if */ + /* get the file object */ + if(NULL == (obj = H5VL_get_object(object_id))) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "invalid file identifier") + + if(H5VL_file_specific(obj->vol_obj, obj->vol_info->vol_cls, H5VL_FILE_FLUSH, H5AC_dxpl_id, + H5_REQUEST_NULL, obj_type, scope) < 0) + HGOTO_ERROR(H5E_FILE, H5E_CANTFLUSH, FAIL, "unable to flush file") done: FUNC_LEAVE_API(ret_value) @@ -764,37 +821,18 @@ done: herr_t H5Fclose(hid_t file_id) { - H5F_t *f = NULL; - int nref; - herr_t ret_value = SUCCEED; + herr_t ret_value = SUCCEED; FUNC_ENTER_API(FAIL) H5TRACE1("e", "i", file_id); /* Check/fix arguments. */ if(H5I_FILE != H5I_get_type(file_id)) - HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a file ID") - - /* 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(NULL == (f = (H5F_t *)H5I_object(file_id))) - HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "invalid file identifier") - if((f->shared->nrefs > 1) && (H5F_INTENT(f) & H5F_ACC_RDWR)) { - 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, H5AC_dxpl_id, FALSE) < 0) - HGOTO_ERROR(H5E_CACHE, H5E_CANTFLUSH, FAIL, "unable to flush cache") - } /* end if */ + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a file ID") - /* - * Decrement reference count on atom. When it reaches zero the file will - * be closed. - */ + /* Decrement reference count on atom. When it reaches zero the file will be closed. */ if(H5I_dec_app_ref(file_id) < 0) - HGOTO_ERROR(H5E_ATOM, H5E_CANTCLOSEFILE, FAIL, "decrementing file ID failed") + HGOTO_ERROR(H5E_ATOM, H5E_CANTCLOSEFILE, FAIL, "decrementing file ID failed") done: FUNC_LEAVE_API(ret_value) @@ -802,6 +840,41 @@ done: /*------------------------------------------------------------------------- + * Function: H5F_close_file + * + * Purpose: Called when the ref count reaches zero on the file_id + * + * Return: Success: Non-negative + * + * Failure: Negative + * + * Programmer: Mohamad Chaarawi + * June 2012 + * + *------------------------------------------------------------------------- + */ +herr_t +H5F_close_file(void *_file) +{ + H5VL_object_t *file = (H5VL_object_t *)_file; + herr_t ret_value = SUCCEED; /* Return value */ + + FUNC_ENTER_NOAPI_NOINIT + + /* Close the file through the VOL*/ + if((ret_value = H5VL_file_close(file->vol_obj, file->vol_info->vol_cls, + H5AC_dxpl_id, H5_REQUEST_NULL)) < 0) + HGOTO_ERROR(H5E_FILE, H5E_CANTCLOSEFILE, FAIL, "unable to close file") + + /* free file */ + if(H5VL_free_object(file) < 0) + HGOTO_ERROR(H5E_FILE, H5E_CANTDEC, FAIL, "unable to free VOL object") +done: + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5F_close_file() */ + + +/*------------------------------------------------------------------------- * Function: H5Freopen * * Purpose: Reopen a file. The new file handle which is returned points @@ -826,36 +899,29 @@ done: hid_t H5Freopen(hid_t file_id) { - H5F_t *old_file = NULL; - H5F_t *new_file = NULL; - hid_t ret_value; + H5VL_object_t *obj = NULL; + void *file; /* file token from VOL plugin */ + hid_t ret_value; FUNC_ENTER_API(FAIL) H5TRACE1("i", "i", file_id); - /* Check arguments */ - if(NULL == (old_file = (H5F_t *)H5I_object_verify(file_id, H5I_FILE))) - HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a file") + /* get the file object */ + if(NULL == (obj = (H5VL_object_t *)H5I_object(file_id))) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "invalid file identifier") - /* Get a new "top level" file struct, sharing the same "low level" file struct */ - if(NULL == (new_file = H5F_new(old_file->shared, 0, H5P_FILE_CREATE_DEFAULT, H5P_FILE_ACCESS_DEFAULT, NULL))) + if(H5VL_file_optional(obj->vol_obj, obj->vol_info->vol_cls, H5AC_dxpl_id, H5_REQUEST_NULL, + H5VL_FILE_REOPEN, &file) < 0) HGOTO_ERROR(H5E_FILE, H5E_CANTINIT, FAIL, "unable to reopen file") - /* Duplicate old file's names */ - new_file->open_name = H5MM_xstrdup(old_file->open_name); - new_file->actual_name = H5MM_xstrdup(old_file->actual_name); + if (NULL == file) + HGOTO_ERROR(H5E_FILE, H5E_CANTINIT, FAIL, "unable to reopen file") - if((ret_value = H5I_register(H5I_FILE, new_file, TRUE)) < 0) + /* Get an atom for the file */ + if((ret_value = H5VL_register_id(H5I_FILE, file, obj->vol_info, TRUE)) < 0) HGOTO_ERROR(H5E_ATOM, H5E_CANTREGISTER, FAIL, "unable to atomize file handle") - /* Keep this ID in file object structure */ - new_file->file_id = ret_value; - done: - if(ret_value < 0 && new_file) - if(H5F_dest(new_file, H5AC_dxpl_id, FALSE) < 0) - HDONE_ERROR(H5E_FILE, H5E_CANTCLOSEFILE, FAIL, "can't close file") - FUNC_LEAVE_API(ret_value) } /* end H5Freopen() */ @@ -883,21 +949,16 @@ H5Fget_intent(hid_t file_id, unsigned *intent_flags) /* If no intent flags were passed in, exit quietly */ if(intent_flags) { - H5F_t * file; /* Pointer to file structure */ - - /* Get the internal file structure */ - if(NULL == (file = (H5F_t *)H5I_object_verify(file_id, H5I_FILE))) - HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a file") - - /* 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. - */ - if(H5F_INTENT(file) & H5F_ACC_RDWR) - *intent_flags = H5F_ACC_RDWR; - else - *intent_flags = H5F_ACC_RDONLY; - } /* end if */ + H5VL_object_t *obj = NULL; + + /* get the file object */ + if(NULL == (obj = (H5VL_object_t *)H5I_object(file_id))) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "invalid file identifier") + + if((ret_value = H5VL_file_get(obj->vol_obj, obj->vol_info->vol_cls, H5VL_FILE_GET_INTENT, + H5AC_dxpl_id, H5_REQUEST_NULL, intent_flags)) < 0) + HGOTO_ERROR(H5E_INTERNAL, H5E_CANTGET, FAIL, "unable to get file intent") + } done: FUNC_LEAVE_API(ret_value) @@ -921,22 +982,19 @@ done: hssize_t H5Fget_freespace(hid_t file_id) { - H5F_t *file; /* File object for file ID */ - hsize_t tot_space; /* Amount of free space in the file */ + H5VL_object_t *obj = NULL; hssize_t ret_value; /* Return value */ FUNC_ENTER_API(FAIL) H5TRACE1("Hs", "i", file_id); - /* Check args */ - if(NULL == (file = (H5F_t *)H5I_object_verify(file_id, H5I_FILE))) - HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "not a file ID") - - /* Go get the actual amount of free space in the file */ - if(H5MF_get_freespace(file, H5AC_ind_dxpl_id, &tot_space, NULL) < 0) - HGOTO_ERROR(H5E_FILE, H5E_CANTGET, FAIL, "unable to check free space for file") + /* get the file object */ + if(NULL == (obj = (H5VL_object_t *)H5I_object(file_id))) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "invalid file identifier") - ret_value = (hssize_t)tot_space; + if(H5VL_file_optional(obj->vol_obj, obj->vol_info->vol_cls, H5AC_ind_dxpl_id, H5_REQUEST_NULL, + H5VL_FILE_GET_FREE_SPACE, &ret_value) < 0) + HGOTO_ERROR(H5E_INTERNAL, H5E_CANTGET, FAIL, "unable to get file free space") done: FUNC_LEAVE_API(ret_value) @@ -962,25 +1020,19 @@ done: herr_t H5Fget_filesize(hid_t file_id, hsize_t *size) { - H5F_t *file; /* File object for file ID */ - haddr_t eof; /* End of file address */ - haddr_t base_addr; /* Base address for the file */ - herr_t ret_value = SUCCEED; /* Return value */ + H5VL_object_t *file; + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_API(FAIL) H5TRACE2("e", "i*h", file_id, size); - /* Check args */ - if(NULL == (file = (H5F_t *)H5I_object_verify(file_id, H5I_FILE))) + /* get the file object */ + if(NULL == (file = (H5VL_object_t *)H5I_object_verify(file_id, H5I_FILE))) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "not a file ID") - /* Go get the actual file size */ - if(HADDR_UNDEF == (eof = H5FD_get_eof(file->shared->lf))) - HGOTO_ERROR(H5E_FILE, H5E_CANTGET, FAIL, "unable to get file size") - base_addr = H5FD_get_base_addr(file->shared->lf); - - if(size) - *size = (hsize_t)(eof + base_addr); /* Convert relative base address for file to absolute address */ + if(H5VL_file_optional(file->vol_obj, file->vol_info->vol_cls, H5AC_dxpl_id, H5_REQUEST_NULL, + H5VL_FILE_GET_SIZE, size) < 0) + HGOTO_ERROR(H5E_INTERNAL, H5E_CANTGET, FAIL, "unable to get file size") done: FUNC_LEAVE_API(ret_value) @@ -1031,19 +1083,20 @@ done: ssize_t H5Fget_file_image(hid_t file_id, void *buf_ptr, size_t buf_len) { - H5F_t *file; /* File object for file ID */ + H5VL_object_t *file; ssize_t ret_value; /* Return value */ FUNC_ENTER_API(FAIL) H5TRACE3("Zs", "i*xz", file_id, buf_ptr, buf_len); /* Check args */ - if(NULL == (file = (H5F_t *)H5I_object_verify(file_id, H5I_FILE))) + if(NULL == (file = (H5VL_object_t *)H5I_object_verify(file_id, H5I_FILE))) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "not a file ID") - /* call private get_file_image function */ - if((ret_value = H5F_get_file_image(file, buf_ptr, buf_len)) < 0) - HGOTO_ERROR(H5E_FILE, H5E_CANTGET, FAIL, "unable to get file image") + /* get image through the VOL */ + if(H5VL_file_optional(file->vol_obj, file->vol_info->vol_cls, H5AC_dxpl_id, H5_REQUEST_NULL, + H5VL_FILE_GET_FILE_IMAGE, buf_ptr, &ret_value, buf_len) < 0) + HGOTO_ERROR(H5E_INTERNAL, H5E_CANTGET, FAIL, "unable to get file image") done: FUNC_LEAVE_API(ret_value) @@ -1071,21 +1124,23 @@ done: herr_t H5Fget_mdc_config(hid_t file_id, H5AC_cache_config_t *config_ptr) { - H5F_t *file; /* File object for file ID */ - herr_t ret_value = SUCCEED; /* Return value */ + H5VL_object_t *obj = NULL; + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_API(FAIL) H5TRACE2("e", "i*x", file_id, config_ptr); - /* Check args */ - if(NULL == (file = (H5F_t *)H5I_object_verify(file_id, H5I_FILE))) - HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "not a file ID") + /* check args */ if((NULL == config_ptr) || (config_ptr->version != H5AC__CURR_CACHE_CONFIG_VERSION)) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "Bad config_ptr") - /* Go get the resize configuration */ - if(H5AC_get_cache_auto_resize_config(file->shared->cache, config_ptr) < 0) - HGOTO_ERROR(H5E_CACHE, H5E_SYSTEM, FAIL, "H5AC_get_cache_auto_resize_config() failed.") + /* get the file object */ + if(NULL == (obj = (H5VL_object_t *)H5I_object(file_id))) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "invalid file identifier") + + if(H5VL_file_optional(obj->vol_obj, obj->vol_info->vol_cls, H5AC_dxpl_id, H5_REQUEST_NULL, + H5VL_FILE_GET_MDC_CONF, config_ptr) < 0) + HGOTO_ERROR(H5E_INTERNAL, H5E_CANTGET, FAIL, "unable to get mdc configuration") done: FUNC_LEAVE_API(ret_value) @@ -1110,19 +1165,19 @@ done: herr_t H5Fset_mdc_config(hid_t file_id, H5AC_cache_config_t *config_ptr) { - H5F_t *file; /* File object for file ID */ - herr_t ret_value = SUCCEED; /* Return value */ + H5VL_object_t *obj = NULL; + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_API(FAIL) H5TRACE2("e", "i*x", file_id, config_ptr); - /* Check args */ - if(NULL == (file = (H5F_t *)H5I_object_verify(file_id, H5I_FILE))) - HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "not a file ID") + /* get the file object */ + if(NULL == (obj = (H5VL_object_t *)H5I_object(file_id))) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "invalid file identifier") - /* set the resize configuration */ - if(H5AC_set_cache_auto_resize_config(file->shared->cache, config_ptr) < 0) - HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "H5AC_set_cache_auto_resize_config() failed.") + if(H5VL_file_optional(obj->vol_obj, obj->vol_info->vol_cls, H5AC_dxpl_id, H5_REQUEST_NULL, + H5VL_FILE_SET_MDC_CONFIG, config_ptr) < 0) + HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "uanvle to set MDC configuration") done: FUNC_LEAVE_API(ret_value) @@ -1148,22 +1203,22 @@ done: herr_t H5Fget_mdc_hit_rate(hid_t file_id, double *hit_rate_ptr) { - H5F_t *file; /* File object for file ID */ + H5VL_object_t *file; herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_API(FAIL) H5TRACE2("e", "i*d", file_id, hit_rate_ptr); /* Check args */ - if(NULL == (file = (H5F_t *)H5I_object_verify(file_id, H5I_FILE))) + if(NULL == (file = (H5VL_object_t *)H5I_object_verify(file_id, H5I_FILE))) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "not a file ID") if(NULL == hit_rate_ptr) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "NULL hit rate pointer") - /* Go get the current hit rate */ - if(H5AC_get_cache_hit_rate(file->shared->cache, hit_rate_ptr) < 0) - HGOTO_ERROR(H5E_CACHE, H5E_SYSTEM, FAIL, "H5AC_get_cache_hit_rate() failed.") + if(H5VL_file_optional(file->vol_obj, file->vol_info->vol_cls, H5AC_dxpl_id, H5_REQUEST_NULL, + H5VL_FILE_GET_MDC_HR, hit_rate_ptr) < 0) + HGOTO_ERROR(H5E_INTERNAL, H5E_CANTGET, FAIL, "unable to get MDC hit rate") done: FUNC_LEAVE_API(ret_value) @@ -1191,8 +1246,7 @@ herr_t H5Fget_mdc_size(hid_t file_id, size_t *max_size_ptr, size_t *min_clean_size_ptr, size_t *cur_size_ptr, int *cur_num_entries_ptr) { - H5F_t *file; /* File object for file ID */ - int32_t cur_num_entries; + H5VL_object_t *file; herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_API(FAIL) @@ -1200,16 +1254,13 @@ H5Fget_mdc_size(hid_t file_id, size_t *max_size_ptr, size_t *min_clean_size_ptr, cur_size_ptr, cur_num_entries_ptr); /* Check args */ - if(NULL == (file = (H5F_t *)H5I_object_verify(file_id, H5I_FILE))) + if(NULL == (file = (H5VL_object_t *)H5I_object_verify(file_id, H5I_FILE))) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "not a file ID") - /* Go get the size data */ - if(H5AC_get_cache_size(file->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; + if(H5VL_file_optional(file->vol_obj, file->vol_info->vol_cls, H5AC_dxpl_id, + H5_REQUEST_NULL, H5VL_FILE_GET_MDC_SIZE, + max_size_ptr, min_clean_size_ptr, cur_size_ptr, cur_num_entries_ptr) < 0) + HGOTO_ERROR(H5E_INTERNAL, H5E_CANTGET, FAIL, "unable to get MDC size") done: FUNC_LEAVE_API(ret_value) @@ -1239,18 +1290,18 @@ done: herr_t H5Freset_mdc_hit_rate_stats(hid_t file_id) { - H5F_t *file; /* File object for file ID */ - herr_t ret_value = SUCCEED; /* Return value */ + H5VL_object_t *obj = NULL; + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_API(FAIL) H5TRACE1("e", "i", file_id); - /* Check args */ - if(NULL == (file = (H5F_t *)H5I_object_verify(file_id, H5I_FILE))) - HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "not a file ID") + /* get the file object */ + if(NULL == (obj = (H5VL_object_t *)H5I_object(file_id))) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "invalid file identifier") - /* Reset the hit rate statistic */ - if(H5AC_reset_cache_hit_rate_stats(file->shared->cache) < 0) + if(H5VL_file_optional(obj->vol_obj, obj->vol_info->vol_cls, H5AC_dxpl_id, H5_REQUEST_NULL, + H5VL_FILE_RESET_MDC_HIT_RATE) < 0) HGOTO_ERROR(H5E_CACHE, H5E_SYSTEM, FAIL, "can't reset cache hit rate") done: @@ -1283,40 +1334,26 @@ done: ssize_t H5Fget_name(hid_t obj_id, char *name/*out*/, size_t size) { - H5F_t *f; /* Top file in mount hierarchy */ - size_t len; - ssize_t ret_value; + H5VL_object_t *obj = NULL; + H5I_type_t type; + ssize_t ret_value; FUNC_ENTER_API(FAIL) H5TRACE3("Zs", "ixz", obj_id, name, size); - /* 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 *)H5I_object(obj_id))) - HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a file") - } /* end if */ - 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; - } /* end else */ - - len = HDstrlen(H5F_OPEN_NAME(f)); + 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") + } - if(name) { - HDstrncpy(name, H5F_OPEN_NAME(f), MIN(len + 1,size)); - if(len >= size) - name[size-1]='\0'; - } /* end if */ + /* get the file object */ + if(NULL == (obj = H5VL_get_object(obj_id))) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "invalid file identifier") - /* Set return value */ - ret_value = (ssize_t)len; + if(H5VL_file_get(obj->vol_obj, obj->vol_info->vol_cls, H5VL_FILE_GET_NAME, + H5AC_dxpl_id, H5_REQUEST_NULL, type, size, name, &ret_value) < 0) + HGOTO_ERROR(H5E_INTERNAL, H5E_CANTGET, FAIL, "unable to get file name") done: FUNC_LEAVE_API(ret_value) @@ -1343,8 +1380,9 @@ done: herr_t H5Fget_info2(hid_t obj_id, H5F_info2_t *finfo) { - H5F_t *f; /* Top file in mount hierarchy */ - herr_t ret_value = SUCCEED; /* Return value */ + H5VL_object_t *obj = NULL; + H5I_type_t type; + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_API(FAIL) H5TRACE2("e", "i*x", obj_id, finfo); @@ -1353,45 +1391,19 @@ H5Fget_info2(hid_t obj_id, H5F_info2_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 *)H5I_object(obj_id))) - HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a file") - } /* end if */ - 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; - } /* end else */ - HDassert(f->shared); - - /* Reset file info struct */ - HDmemset(finfo, 0, sizeof(*finfo)); + 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 size of the superblock and any superblock extensions */ - if(H5F_super_size(f, H5AC_ind_dxpl_id, &finfo->super.super_size, &finfo->super.super_ext_size) < 0) - HGOTO_ERROR(H5E_FILE, H5E_CANTGET, FAIL, "Unable to retrieve superblock sizes") - - /* Get the size of any persistent free space */ - if(H5MF_get_freespace(f, H5AC_ind_dxpl_id, &finfo->free.tot_space, &finfo->free.meta_size) < 0) - HGOTO_ERROR(H5E_FILE, H5E_CANTGET, FAIL, "Unable to retrieve free space information") - - /* Check for SOHM info */ - if(H5F_addr_defined(f->shared->sohm_addr)) - if(H5SM_ih_size(f, H5AC_ind_dxpl_id, &finfo->sohm.hdr_size, &finfo->sohm.msgs_info) < 0) - HGOTO_ERROR(H5E_FILE, H5E_CANTGET, FAIL, "Unable to retrieve SOHM index & heap storage info") - - /* Set version # fields */ - finfo->super.version = f->shared->sblock->super_vers; - finfo->sohm.version = f->shared->sohm_vers; - finfo->free.version = HDF5_FREESPACE_VERSION; + /* get the file object */ + if(NULL == (obj = H5VL_get_object(obj_id))) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "invalid file identifier") + if(H5VL_file_optional(obj->vol_obj, obj->vol_info->vol_cls, H5AC_ind_dxpl_id, H5_REQUEST_NULL, + H5VL_FILE_GET_INFO, type, finfo) < 0) + HGOTO_ERROR(H5E_INTERNAL, H5E_CANTGET, FAIL, "unable to get file info") done: FUNC_LEAVE_API(ret_value) } /* end H5Fget_info2() */ @@ -1416,22 +1428,21 @@ ssize_t H5Fget_free_sections(hid_t file_id, H5F_mem_t type, size_t nsects, H5F_sect_info_t *sect_info/*out*/) { - H5F_t *file; /* Top file in mount hierarchy */ - ssize_t ret_value; /* Return value */ + H5VL_object_t *file; + ssize_t ret_value; /* Return value */ FUNC_ENTER_API(FAIL) H5TRACE4("Zs", "iFmzx", file_id, type, nsects, sect_info); /* Check args */ - if(NULL == (file = (H5F_t *)H5I_object_verify(file_id, H5I_FILE))) - HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "not a file ID") + if(NULL == (file = (H5VL_object_t *)H5I_object_verify(file_id, H5I_FILE))) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "invalid file identifier") if(sect_info && nsects == 0) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "nsects must be > 0") - /* Go get the free-space section information in the file */ - if((ret_value = H5MF_get_free_sections(file, H5AC_ind_dxpl_id, type, nsects, sect_info)) < 0) - HGOTO_ERROR(H5E_FILE, H5E_CANTGET, FAIL, "unable to check free space for file") - + if(H5VL_file_optional(file->vol_obj, file->vol_info->vol_cls, H5AC_ind_dxpl_id, H5_REQUEST_NULL, + H5VL_FILE_GET_FREE_SECTIONS, sect_info, &ret_value, type, nsects) < 0) + HGOTO_ERROR(H5E_INTERNAL, H5E_CANTGET, FAIL, "unable to get file free sections") done: FUNC_LEAVE_API(ret_value) } /* end H5Fget_free_sections() */ @@ -1454,20 +1465,19 @@ done: herr_t H5Fclear_elink_file_cache(hid_t file_id) { - H5F_t *file; /* File */ + H5VL_object_t *file; herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_API(FAIL) H5TRACE1("e", "i", file_id); /* Check args */ - if(NULL == (file = (H5F_t *)H5I_object_verify(file_id, H5I_FILE))) - HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "not a file ID") + if(NULL == (file = (H5VL_object_t *)H5I_object_verify(file_id, H5I_FILE))) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "invalid file identifier") - /* Release the EFC */ - if(file->shared->efc) - if(H5F_efc_release(file->shared->efc) < 0) - HGOTO_ERROR(H5E_FILE, H5E_CANTRELEASE, FAIL, "can't release external file cache") + if(H5VL_file_optional(file->vol_obj, file->vol_info->vol_cls, H5AC_dxpl_id, H5_REQUEST_NULL, + H5VL_FILE_CLEAR_ELINK_CACHE) < 0) + HGOTO_ERROR(H5E_FILE, H5E_CANTRELEASE, FAIL, "can't release external file cache") done: FUNC_LEAVE_API(ret_value) @@ -107,7 +107,7 @@ static const H5I_class_t H5I_VFL_CLS[1] = {{ H5I_VFL, /* ID class value */ 0, /* Class flags */ 0, /* # of reserved IDs for class */ - (H5I_free_t)H5FD_free_cls /* Callback routine for closing objects of this class */ + (H5I_free_t)H5FD_free_cls /* Callback routine for closing objects of this class */ }}; diff --git a/src/H5FDfamily.c b/src/H5FDfamily.c index 1728d13..9f8696f 100644 --- a/src/H5FDfamily.c +++ b/src/H5FDfamily.c @@ -425,15 +425,9 @@ H5FD_family_fapl_copy(const void *_old_fa) HDmemcpy(new_fa, old_fa, sizeof(H5FD_family_fapl_t)); /* Deep copy the property list objects in the structure */ - if(old_fa->memb_fapl_id==H5P_FILE_ACCESS_DEFAULT) { - if(H5I_inc_ref(new_fa->memb_fapl_id, FALSE)<0) - HGOTO_ERROR(H5E_VFL, H5E_CANTINC, NULL, "unable to increment ref count on VFL driver") - } /* end if */ - else { - if(NULL == (plist = (H5P_genplist_t *)H5I_object(old_fa->memb_fapl_id))) - HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, NULL, "not a file access property list") - new_fa->memb_fapl_id = H5P_copy_plist(plist, FALSE); - } /* end else */ + if(NULL == (plist = (H5P_genplist_t *)H5I_object(old_fa->memb_fapl_id))) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, NULL, "not a file access property list") + new_fa->memb_fapl_id = H5P_copy_plist(plist, FALSE); /* Set return value */ ret_value=new_fa; diff --git a/src/H5Fdeprec.c b/src/H5Fdeprec.c index c5a500a..ae46fea 100644 --- a/src/H5Fdeprec.c +++ b/src/H5Fdeprec.c @@ -164,7 +164,7 @@ H5Fget_info1(hid_t obj_id, H5F_info1_t *finfo) * the top file in a mount hierarchy) */ if(H5I_get_type(obj_id) == H5I_FILE ) { - if(NULL == (f = (H5F_t *)H5I_object(obj_id))) + if(NULL == (f = (H5F_t *)H5VL_object(obj_id))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a file") } /* end if */ else { @@ -193,5 +193,46 @@ done: FUNC_LEAVE_API(ret_value) } /* end H5Fget_info1() */ + +/*------------------------------------------------------------------------- + * Function: H5Fis_hdf5 + * + * Purpose: Check the file signature to detect an HDF5 file. + * + * Bugs: This function is not robust: it only uses the default file + * driver when attempting to open the file when in fact it + * should use all known file drivers. + * + * Return: Success: TRUE/FALSE + * + * Failure: Negative + * + * Programmer: Unknown + * + * Modifications: + * Robb Matzke, 1999-08-02 + * Rewritten to use the virtual file layer. + *------------------------------------------------------------------------- + */ +htri_t +H5Fis_hdf5(const char *name) +{ + htri_t ret_value; /* Return value */ + + FUNC_ENTER_API(FAIL) + H5TRACE1("t", "*s", name); + + /* Check args and all the boring stuff. */ + if(!name || !*name) + HGOTO_ERROR(H5E_ARGS, H5E_BADRANGE, FAIL, "no file name specified") + + /* Call private routine */ + if((ret_value = H5F_is_hdf5(name, H5P_FILE_ACCESS_DEFAULT)) < 0) + HGOTO_ERROR(H5E_IO, H5E_CANTINIT, FAIL, "unable to open file") + +done: + FUNC_LEAVE_API(ret_value) +} /* end H5Fis_hdf5() */ + #endif /* H5_NO_DEPRECATED_SYMBOLS */ diff --git a/src/H5Fint.c b/src/H5Fint.c index 48a8d1f..48c0cc6 100644 --- a/src/H5Fint.c +++ b/src/H5Fint.c @@ -40,6 +40,7 @@ #include "H5Pprivate.h" /* Property lists */ #include "H5SMprivate.h" /* Shared Object Header Messages */ #include "H5Tprivate.h" /* Datatypes */ +#include "H5VLprivate.h" /* VOL plugins */ /****************/ @@ -76,9 +77,12 @@ typedef struct H5F_olist_t { /* Local Prototypes */ /********************/ -static int H5F_get_objects_cb(void *obj_ptr, hid_t obj_id, void *key); +/* private prototypes */ +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);/* Declare a free list to manage the H5F_t struct */ + const char *name, char ** /*out*/ actual_name); +static herr_t H5F_dest(H5F_t *f, hid_t dxpl_id, hbool_t flush); /*********************/ @@ -156,6 +160,7 @@ H5F_get_access_plist(H5F_t *f, hbool_t app_ref) H5P_genplist_t *old_plist; /* Old property list */ void *driver_info=NULL; unsigned efc_size = 0; + hid_t driver_id; hid_t ret_value = SUCCEED; FUNC_ENTER_NOAPI(FAIL) @@ -203,8 +208,19 @@ H5F_get_access_plist(H5F_t *f, hbool_t app_ref) * Since we're resetting the driver ID and info, close them if they * exist in this new property list. */ - if(H5P_facc_close(ret_value, NULL) < 0) - HGOTO_ERROR(H5E_PLIST, H5E_CANTFREE, FAIL, "can't free the old driver information") + /* Get driver ID property */ + if(H5P_get(new_plist, H5F_ACS_FILE_DRV_ID_NAME, &driver_id) < 0) + HGOTO_DONE(FAIL) /* Can't return errors when library is shutting down */ + + if(driver_id > 0) { + /* Get driver info property */ + if(H5P_get(new_plist, H5F_ACS_FILE_DRV_INFO_NAME, &driver_info) < 0) + HGOTO_DONE(FAIL) /* Can't return errors when library is shutting down */ + + /* Close the driver for the property list */ + if(H5FD_fapl_close(driver_id, driver_info) < 0) + HGOTO_DONE(FAIL) /* Can't return errors when library is shutting down */ + } /* end if */ /* Increment the reference count on the driver ID and insert it into the property list */ if(H5I_inc_ref(f->shared->lf->driver_id, FALSE) < 0) @@ -306,7 +322,8 @@ done: *--------------------------------------------------------------------------- */ herr_t -H5F_get_objects(const H5F_t *f, unsigned types, size_t max_nobjs, hid_t *obj_id_list, hbool_t app_ref, size_t *obj_id_count_ptr) +H5F_get_objects(const H5F_t *f, unsigned types, size_t max_nobjs, hid_t *obj_id_list, + hbool_t app_ref, size_t *obj_id_count_ptr) { size_t obj_id_count=0; /* Number of open IDs */ H5F_olist_t olist; /* Structure to hold search results */ @@ -412,7 +429,7 @@ done: * *------------------------------------------------------------------------- */ -static int +int H5F_get_objects_cb(void *obj_ptr, hid_t obj_id, void *key) { H5F_olist_t *olist = (H5F_olist_t *)key; /* Alias for search info */ @@ -462,6 +479,7 @@ H5F_get_objects_cb(void *obj_ptr, hid_t obj_id, void *key) case H5I_DATASPACE: case H5I_REFERENCE: case H5I_VFL: + case H5I_VOL: case H5I_GENPROP_CLS: case H5I_GENPROP_LST: case H5I_ERROR_CLASS: @@ -529,28 +547,34 @@ done: *------------------------------------------------------------------------- */ htri_t -H5F_is_hdf5(const char *name) +H5F_is_hdf5(const char *name, hid_t fapl_id) { - H5FD_t *file = NULL; /* Low-level file struct */ + H5F_t *file = NULL; /* Low-level file struct */ haddr_t sig_addr; /* Addess of hdf5 file signature */ htri_t ret_value; /* Return value */ FUNC_ENTER_NOAPI_NOINIT /* Open the file at the virtual file layer */ - if(NULL == (file = H5FD_open(name, H5F_ACC_RDONLY, H5P_FILE_ACCESS_DEFAULT, HADDR_UNDEF))) - HGOTO_ERROR(H5E_IO, H5E_CANTINIT, FAIL, "unable to open file") + //if(NULL == (file = H5FD_open(name, H5F_ACC_RDONLY, fapl_id, HADDR_UNDEF))) + //HGOTO_ERROR(H5E_IO, H5E_CANTINIT, FAIL, "unable to open file") + + /* Open the file */ + if(NULL == (file = H5F_open(name, H5F_ACC_RDONLY, H5P_FILE_CREATE_DEFAULT, + fapl_id, H5AC_ind_dxpl_id))) + HGOTO_ERROR(H5E_FILE, H5E_CANTINIT, FALSE, "unable to open file") /* The file is an hdf5 file if the hdf5 file signature can be found */ - if(H5FD_locate_signature(file, H5AC_ind_dxpl_g, &sig_addr) < 0) - HGOTO_ERROR(H5E_FILE, H5E_NOTHDF5, FAIL, "unable to locate file signature") + if(H5FD_locate_signature(file->shared->lf, H5AC_ind_dxpl_g, &sig_addr) < 0) + HGOTO_ERROR(H5E_FILE, H5E_NOTHDF5, FALSE, "unable to locate file signature") ret_value = (HADDR_UNDEF != sig_addr); done: /* Close the file */ if(file) - if(H5FD_close(file) < 0 && ret_value >= 0) - HDONE_ERROR(H5E_IO, H5E_CANTCLOSEFILE, FAIL, "unable to close file") + //if(H5FD_close(file) < 0 && ret_value >= 0) + if(H5F_close(file) < 0 && ret_value >= 0) + HDONE_ERROR(H5E_FILE, H5E_CANTCLOSEFILE, FAIL, "unable to close file") FUNC_LEAVE_NOAPI(ret_value) } /* end H5F_is_hdf5() */ @@ -578,7 +602,7 @@ 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, *ret_value; @@ -587,7 +611,7 @@ H5F_new(H5F_file_t *shared, unsigned flags, hid_t fcpl_id, hid_t fapl_id, H5FD_t if(NULL == (f = H5FL_CALLOC(H5F_t))) HGOTO_ERROR(H5E_FILE, H5E_NOSPACE, NULL, "can't allocate top file structure") - f->file_id = -1; + f->id_exists = FALSE; if(shared) { HDassert(lf == NULL); @@ -749,7 +773,7 @@ done: * *------------------------------------------------------------------------- */ -herr_t +static herr_t H5F_dest(H5F_t *f, hid_t dxpl_id, hbool_t flush) { herr_t ret_value = SUCCEED; /* Return value */ @@ -1235,7 +1259,6 @@ H5F_close(H5F_t *f) /* Sanity check */ HDassert(f); - HDassert(f->file_id > 0); /* This routine should only be called when a file ID's ref count drops to zero */ /* Perform checks for "semi" file close degree here, since closing the * file is not allowed if there are objects still open */ @@ -1256,7 +1279,7 @@ H5F_close(H5F_t *f) } /* end if */ /* Reset the file ID for this file */ - f->file_id = -1; + f->id_exists = FALSE; /* Attempt to close the file/mount hierarchy */ if(H5F_try_close(f) < 0) @@ -1430,6 +1453,50 @@ done: /*------------------------------------------------------------------------- + * Function: H5F_reopen + * + * Purpose: Reopen a file. The new file handle which is returned points + * to the same file as the specified file handle. Both handles + * share caches and other information. The only difference + * between the handles is that the new handle is not mounted + * anywhere and no files are mounted on it. + * + * Return: Success: New file ID + * + * Failure: FAIL + * + * Programmer: Robb Matzke + * Friday, October 16, 1998 + * + * Modifications: + * Quincey Koziol, May 14, 2002 + * Keep old file's read/write intent in reopened file. + * + *------------------------------------------------------------------------- + */ +H5F_t * +H5F_reopen(H5F_t *f) +{ + H5F_t *ret_value = NULL; + + FUNC_ENTER_NOAPI_NOINIT + + /* Get a new "top level" file struct, sharing the same "low level" file struct */ + /* Get a new "top level" file struct, sharing the same "low level" file struct */ + if(NULL == (ret_value = H5F_new(f->shared, 0, H5P_FILE_CREATE_DEFAULT, + H5P_FILE_ACCESS_DEFAULT, NULL))) + HGOTO_ERROR(H5E_FILE, H5E_CANTINIT, NULL, "unable to reopen file") + + /* Duplicate old file's names */ + ret_value->open_name = H5MM_xstrdup(f->open_name); + ret_value->actual_name = H5MM_xstrdup(f->actual_name); + +done: + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5F_reopen() */ + + +/*------------------------------------------------------------------------- * Function: H5F_get_id * * Purpose: Get the file ID, incrementing it, or "resurrecting" it as @@ -1451,17 +1518,17 @@ H5F_get_id(H5F_t *file, hbool_t app_ref) HDassert(file); - if(file->file_id == -1) { - /* Get an atom for the file */ - if((file->file_id = H5I_register(H5I_FILE, file, app_ref)) < 0) - HGOTO_ERROR(H5E_ATOM, H5E_CANTREGISTER, FAIL, "unable to atomize file") - } else { - /* Increment reference count on atom. */ - if(H5I_inc_ref(file->file_id, app_ref) < 0) + if (FAIL == (ret_value = H5I_get_id(file, H5I_FILE))) { + /* resurrect the ID - Register an ID with the native plugin */ + if((ret_value = H5VL_native_register(H5I_FILE, file, app_ref)) < 0) + HGOTO_ERROR(H5E_ATOM, H5E_CANTREGISTER, FAIL, "unable to register group") + file->id_exists = TRUE; + } + else { + /* Increment ref count on existing ID */ + if(H5I_inc_ref(ret_value, app_ref) < 0) HGOTO_ERROR(H5E_ATOM, H5E_CANTSET, FAIL, "incrementing file ID failed") - } /* end else */ - - ret_value = file->file_id; + } done: FUNC_LEAVE_NOAPI(ret_value) diff --git a/src/H5Fmount.c b/src/H5Fmount.c index ee7af97..fa230e2 100644 --- a/src/H5Fmount.c +++ b/src/H5Fmount.c @@ -28,11 +28,9 @@ #include "H5Iprivate.h" /* IDs */ #include "H5Pprivate.h" /* Property lists */ #include "H5MMprivate.h" /* Memory management */ +#include "H5VLprivate.h" /* VOL */ /* PRIVATE PROTOTYPES */ -static herr_t H5F_mount(H5G_loc_t *loc, const char *name, H5F_t *child, - hid_t plist_id, hid_t dxpl_id); -static herr_t H5F_unmount(H5G_loc_t *loc, const char *name, hid_t dxpl_id); static void H5F_mount_count_ids_recurse(H5F_t *f, unsigned *nopen_files, unsigned *nopen_objs); @@ -126,7 +124,7 @@ done: * *------------------------------------------------------------------------- */ -static herr_t +herr_t H5F_mount(H5G_loc_t *loc, const char *name, H5F_t *child, hid_t UNUSED plist_id, hid_t dxpl_id) { @@ -292,7 +290,7 @@ done: * *------------------------------------------------------------------------- */ -static herr_t +herr_t H5F_unmount(H5G_loc_t *loc, const char *name, hid_t dxpl_id) { H5G_t *child_group = NULL; /* Child's group in parent mtab */ @@ -470,28 +468,41 @@ H5F_is_mount(const H5F_t *file) herr_t H5Fmount(hid_t loc_id, const char *name, hid_t child_id, hid_t plist_id) { - H5G_loc_t loc; - H5F_t *child = NULL; - herr_t ret_value = SUCCEED; /* Return value */ + H5VL_object_t *obj; + H5VL_object_t *file; + H5I_type_t type; + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_API(FAIL) H5TRACE4("e", "i*sii", loc_id, name, child_id, plist_id); /* 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") - if(NULL == (child = (H5F_t *)H5I_object_verify(child_id, H5I_FILE))) - HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a file") if(H5P_DEFAULT == plist_id) plist_id = H5P_FILE_MOUNT_DEFAULT; else if(TRUE != H5P_isa_class(plist_id, H5P_FILE_MOUNT)) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not property list") - /* Do the mount */ - if(H5F_mount(&loc, name, child, plist_id, H5AC_dxpl_id) < 0) + type = H5I_get_type(loc_id); + if(H5I_FILE != type && H5I_GROUP != type) { + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a file or group object") + } + + /* get the group/file object */ + if(NULL == (obj = (H5VL_object_t *)H5I_object(loc_id))) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "invalid file identifier") + /* get the file object */ + if(NULL == (file = (H5VL_object_t *)H5I_object(child_id))) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "invalid file identifier") + + /* check if both objects are associated with the same VOL plugin */ + if (obj->vol_info->vol_cls->value != file->vol_info->vol_cls->value) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "Can't mount file onto object from different VOL plugin") + + if(H5VL_file_specific(obj->vol_obj, obj->vol_info->vol_cls, H5VL_FILE_MOUNT, H5AC_dxpl_id, + H5_REQUEST_NULL, type, name, file->vol_obj, plist_id) < 0) HGOTO_ERROR(H5E_FILE, H5E_MOUNT, FAIL, "unable to mount file") done: @@ -521,20 +532,28 @@ done: herr_t H5Funmount(hid_t loc_id, const char *name) { - H5G_loc_t loc; + H5VL_object_t *obj; + H5I_type_t type; herr_t ret_value=SUCCEED; /* Return value */ FUNC_ENTER_API(FAIL) H5TRACE2("e", "i*s", loc_id, name); /* Check args */ - 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") - /* Unmount */ - if (H5F_unmount(&loc, name, H5AC_dxpl_id) < 0) + type = H5I_get_type(loc_id); + if(H5I_FILE != type && H5I_GROUP != type) { + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a file or group object") + } + + /* get the group/file object */ + if(NULL == (obj = (H5VL_object_t *)H5I_object(loc_id))) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "invalid file identifier") + + if(H5VL_file_specific(obj->vol_obj, obj->vol_info->vol_cls, H5VL_FILE_UNMOUNT, H5AC_dxpl_id, + H5_REQUEST_NULL, type, name) < 0) HGOTO_ERROR(H5E_FILE, H5E_MOUNT, FAIL, "unable to unmount file") done: @@ -568,7 +587,7 @@ H5F_mount_count_ids_recurse(H5F_t *f, unsigned *nopen_files, unsigned *nopen_obj HDassert(nopen_objs); /* If this file is still open, increment number of file IDs open */ - if(f->file_id > 0) + if(f->id_exists) *nopen_files += 1; /* Increment number of open objects in file diff --git a/src/H5Fmpi.c b/src/H5Fmpi.c index 4d3ca34..4e1b096 100644 --- a/src/H5Fmpi.c +++ b/src/H5Fmpi.c @@ -204,7 +204,7 @@ H5Fset_mpi_atomicity(hid_t file_id, hbool_t flag) H5TRACE2("e", "ib", file_id, flag); /* Check args */ - if(NULL == (file = (H5F_t *)H5I_object_verify(file_id, H5I_FILE))) + if(NULL == (file = (H5F_t *)H5VL_object_verify(file_id, H5I_FILE))) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "not a file ID") /* Check VFD */ @@ -244,7 +244,7 @@ H5Fget_mpi_atomicity(hid_t file_id, hbool_t *flag) H5TRACE2("e", "i*b", file_id, flag); /* Check args */ - if(NULL == (file = (H5F_t *)H5I_object_verify(file_id, H5I_FILE))) + if(NULL == (file = (H5F_t *)H5VL_object_verify(file_id, H5I_FILE))) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "not a file ID") /* Check VFD */ diff --git a/src/H5Fpkg.h b/src/H5Fpkg.h index 53fe0d9..74d7e9a 100644 --- a/src/H5Fpkg.h +++ b/src/H5Fpkg.h @@ -33,6 +33,7 @@ /* Other public headers needed by this file */ #include "H5Bpublic.h" /* B-tree header, for H5B_NUM_BTREE_ID */ +#include "H5VLpublic.h" /* Other private headers needed by this file */ #include "H5private.h" /* Generic Functions */ @@ -265,12 +266,42 @@ struct H5F_t { H5F_file_t *shared; /* The shared file info */ unsigned nopen_objs; /* Number of open object headers*/ H5FO_t *obj_count; /* # of time each object is opened through top file structure */ - hid_t file_id; /* ID of this file */ + hbool_t id_exists; /* Whether an ID for this struct exists */ hbool_t closing; /* File is in the process of being closed */ struct H5F_t *parent; /* Parent file that this file is mounted to */ unsigned nmounts; /* Number of children mounted to this file */ }; +/* 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_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 */ +typedef struct { + size_t max_objs; + hid_t *oid_list; + ssize_t *obj_count; /* number of objects counted so far */ + unsigned types; /* types of objects to be counted */ +} H5F_trav_obj_ids_t; /*****************************/ /* Package Private Variables */ @@ -292,15 +323,17 @@ H5_DLLVAR const H5AC_class_t H5AC_SUPERBLOCK[1]; /* General routines */ H5_DLL herr_t H5F_init(void); H5_DLL herr_t H5F__term_deprec_interface(void); -H5F_t *H5F_new(H5F_file_t *shared, unsigned flags, hid_t fcpl_id, - hid_t fapl_id, H5FD_t *lf); -herr_t H5F_dest(H5F_t *f, hid_t dxpl_id, hbool_t flush); +H5_DLL H5F_t *H5F_reopen(H5F_t *f); H5_DLL herr_t H5F_flush(H5F_t *f, hid_t dxpl_id, hbool_t closing); -H5_DLL htri_t H5F_is_hdf5(const char *name); -H5_DLL 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); +H5_DLL htri_t H5F_is_hdf5(const char *name, hid_t fapl_id); +H5_DLL 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); +H5_DLL int H5F_get_objects_cb(void *obj_ptr, hid_t obj_id, void *key); H5_DLL herr_t H5F_close(H5F_t *f); /* File mount related routines */ +H5_DLL herr_t H5F_mount(H5G_loc_t *loc, const char *name, H5F_t *child, hid_t plist_id, hid_t dxpl_id); +H5_DLL herr_t H5F_unmount(H5G_loc_t *loc, const char *name, hid_t dxpl_id); H5_DLL herr_t H5F_close_mounts(H5F_t *f); H5_DLL int H5F_term_unmount_cb(void *obj_ptr, hid_t obj_id, void *key); H5_DLL herr_t H5F_mount_count_ids(H5F_t *f, unsigned *nopen_files, unsigned *nopen_objs); diff --git a/src/H5Fprivate.h b/src/H5Fprivate.h index fe81edc..5076712 100644 --- a/src/H5Fprivate.h +++ b/src/H5Fprivate.h @@ -34,6 +34,7 @@ /* Library Private Macros */ /**************************/ + /* * Encode and decode macros for file meta-data. * Currently, all file meta-data is little-endian. @@ -281,7 +282,7 @@ #define H5F_NOPEN_OBJS(F) ((F)->nopen_objs) #define H5F_INCR_NOPEN_OBJS(F) ((F)->nopen_objs++) #define H5F_DECR_NOPEN_OBJS(F) ((F)->nopen_objs--) -#define H5F_FILE_ID(F) ((F)->file_id) +#define H5F_FILE_ID(F) ((F)->id_exists) #define H5F_PARENT(F) ((F)->parent) #define H5F_NMOUNTS(F) ((F)->nmounts) #define H5F_DRIVER_ID(F) ((F)->shared->lf->driver_id) @@ -323,7 +324,7 @@ #define H5F_NOPEN_OBJS(F) (H5F_get_nopen_objs(F)) #define H5F_INCR_NOPEN_OBJS(F) (H5F_incr_nopen_objs(F)) #define H5F_DECR_NOPEN_OBJS(F) (H5F_decr_nopen_objs(F)) -#define H5F_FILE_ID(F) (H5F_get_file_id(F)) +#define H5F_FILE_ID(F) (H5F_file_id_exists(F)) #define H5F_PARENT(F) (H5F_get_parent(F)) #define H5F_NMOUNTS(F) (H5F_get_nmounts(F)) #define H5F_DRIVER_ID(F) (H5F_get_driver_id(F)) @@ -445,6 +446,8 @@ #define H5F_ACS_GARBG_COLCT_REF_NAME "gc_ref" /* Garbage-collect references */ #define H5F_ACS_FILE_DRV_ID_NAME "driver_id" /* File driver ID */ #define H5F_ACS_FILE_DRV_INFO_NAME "driver_info" /* File driver info */ +#define H5F_ACS_VOL_ID_NAME "vol_id" /* File VOL ID */ +#define H5F_ACS_VOL_INFO_NAME "vol_info" /* FILE VOL 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) */ @@ -554,6 +557,7 @@ struct H5B_class_t; struct H5UC_t; struct H5O_loc_t; struct H5HG_heap_t; +struct H5VL_class_t; struct H5P_genplist_t; /* Forward declarations for anonymous H5F objects */ @@ -571,7 +575,6 @@ typedef struct H5F_io_info_t { const struct H5P_genplist_t *dxpl; /* DXPL object */ } H5F_io_info_t; - /*****************************/ /* Library-private Variables */ /*****************************/ @@ -597,7 +600,7 @@ H5_DLL hbool_t H5F_same_shared(const H5F_t *f1, const H5F_t *f2); H5_DLL unsigned H5F_get_nopen_objs(const H5F_t *f); H5_DLL unsigned H5F_incr_nopen_objs(H5F_t *f); H5_DLL unsigned H5F_decr_nopen_objs(H5F_t *f); -H5_DLL hid_t H5F_get_file_id(const H5F_t *f); +H5_DLL hbool_t H5F_file_id_exists(const H5F_t *f); H5_DLL ssize_t H5F_get_file_image(H5F_t *f, void *buf_ptr, size_t buf_len); H5_DLL H5F_t *H5F_get_parent(const H5F_t *f); H5_DLL unsigned H5F_get_nmounts(const H5F_t *f); diff --git a/src/H5Fpublic.h b/src/H5Fpublic.h index f32b3e0..54d5ce0 100644 --- a/src/H5Fpublic.h +++ b/src/H5Fpublic.h @@ -174,7 +174,7 @@ extern "C" { #endif /* Functions in H5F.c */ -H5_DLL htri_t H5Fis_hdf5(const char *filename); +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); H5_DLL hid_t H5Fopen(const char *filename, unsigned flags, @@ -237,6 +237,7 @@ typedef struct H5F_info1_t { /* Function prototypes */ H5_DLL herr_t H5Fget_info1(hid_t obj_id, H5F_info1_t *finfo); +H5_DLL htri_t H5Fis_hdf5(const char *filename); #endif /* H5_NO_DEPRECATED_SYMBOLS */ diff --git a/src/H5Fquery.c b/src/H5Fquery.c index 6290614..4c25a71 100644 --- a/src/H5Fquery.c +++ b/src/H5Fquery.c @@ -263,15 +263,15 @@ H5F_get_nopen_objs(const H5F_t *f) * *------------------------------------------------------------------------- */ -hid_t -H5F_get_file_id(const H5F_t *f) +hbool_t +H5F_file_id_exists(const H5F_t *f) { /* Use FUNC_ENTER_NOAPI_NOINIT_NOERR here to avoid performance issues */ FUNC_ENTER_NOAPI_NOINIT_NOERR HDassert(f); - FUNC_LEAVE_NOAPI(f->file_id) + FUNC_LEAVE_NOAPI(f->id_exists) } /* end H5F_get_file_id() */ diff --git a/src/H5Ftest.c b/src/H5Ftest.c index 73b00a6..561b292 100644 --- a/src/H5Ftest.c +++ b/src/H5Ftest.c @@ -105,7 +105,7 @@ H5F_get_sohm_mesg_count_test(hid_t file_id, unsigned type_id, FUNC_ENTER_NOAPI_NOINIT /* Check arguments */ - if(NULL == (file = (H5F_t *)H5I_object_verify(file_id, H5I_FILE))) + if(NULL == (file = (H5F_t *)H5VL_object_verify(file_id, H5I_FILE))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a file") /* Retrieve count for message type */ @@ -142,7 +142,7 @@ H5F_check_cached_stab_test(hid_t file_id) FUNC_ENTER_NOAPI_NOINIT /* Check arguments */ - if(NULL == (file = (H5F_t *)H5I_object_verify(file_id, H5I_FILE))) + if(NULL == (file = (H5F_t *)H5VL_object_verify(file_id, H5I_FILE))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a file") /* Verify the cached stab info */ @@ -176,7 +176,7 @@ H5F_get_maxaddr_test(hid_t file_id, haddr_t *maxaddr) FUNC_ENTER_NOAPI_NOINIT /* Check arguments */ - if(NULL == (file = (H5F_t *)H5I_object_verify(file_id, H5I_FILE))) + if(NULL == (file = (H5F_t *)H5VL_object_verify(file_id, H5I_FILE))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a file") /* Retrieve maxaddr for file */ @@ -93,8 +93,9 @@ #include "H5Eprivate.h" /* Error handling */ #include "H5Gpkg.h" /* Groups */ #include "H5Iprivate.h" /* IDs */ +#include "H5MMprivate.h" /* Memory management */ #include "H5Pprivate.h" /* Property lists */ - +#include "H5VLprivate.h" /* VOL plugins */ /****************/ /* Local Macros */ @@ -135,7 +136,7 @@ static const H5I_class_t H5I_GROUP_CLS[1] = {{ H5I_GROUP, /* ID class value */ 0, /* Class flags */ 0, /* # of reserved IDs for class */ - (H5I_free_t)H5G_close /* Callback routine for closing objects of this class */ + (H5I_free_t)H5G_close_group /* Callback routine for closing objects of this class */ }}; @@ -272,19 +273,18 @@ H5G_term_interface(void) *------------------------------------------------------------------------- */ hid_t -H5Gcreate2(hid_t loc_id, const char *name, hid_t lcpl_id, hid_t gcpl_id, - hid_t gapl_id) +H5Gcreate2(hid_t loc_id, const char *name, hid_t lcpl_id, hid_t gcpl_id, hid_t gapl_id) { - H5G_loc_t loc; /* Location to create group */ - H5G_t *grp = NULL; /* New group created */ - hid_t ret_value; /* Return value */ + void *grp = NULL; /* group token from VOL plugin */ + H5VL_object_t *obj = NULL; /* object token of loc_id */ + H5VL_loc_params_t loc_params; + H5P_genplist_t *plist; /* Property list pointer */ + hid_t ret_value; /* Return value */ FUNC_ENTER_API(FAIL) H5TRACE5("i", "i*siii", loc_id, name, lcpl_id, gcpl_id, gapl_id); /* 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") @@ -309,17 +309,33 @@ H5Gcreate2(hid_t loc_id, const char *name, hid_t lcpl_id, hid_t gcpl_id, if(TRUE != H5P_isa_class(gapl_id, H5P_GROUP_ACCESS)) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not group access property list") - /* Create the new group & get its ID */ - if(NULL == (grp = H5G__create_named(&loc, name, lcpl_id, gcpl_id, gapl_id, H5AC_dxpl_id))) - HGOTO_ERROR(H5E_SYM, H5E_CANTINIT, FAIL, "unable to create group") - if((ret_value = H5I_register(H5I_GROUP, grp, TRUE)) < 0) - HGOTO_ERROR(H5E_ATOM, H5E_CANTREGISTER, FAIL, "unable to register group") + /* Get the plist structure */ + if(NULL == (plist = (H5P_genplist_t *)H5I_object(gcpl_id))) + HGOTO_ERROR(H5E_ATOM, H5E_BADATOM, FAIL, "can't find object for ID") + + if(H5P_set(plist, H5VL_PROP_GRP_LCPL_ID, &lcpl_id) < 0) + HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, FAIL, "can't set property value for lcpl id") + + loc_params.type = H5VL_OBJECT_BY_SELF; + loc_params.obj_type = H5I_get_type(loc_id); + + /* get the location object */ + if(NULL == (obj = (H5VL_object_t *)H5I_object(loc_id))) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "invalid location identifier") + + /* Create the group through the VOL */ + if(NULL == (grp = H5VL_group_create(obj->vol_obj, loc_params, obj->vol_info->vol_cls, name, + gcpl_id, gapl_id, H5AC_dxpl_id, H5_REQUEST_NULL))) + HGOTO_ERROR(H5E_SYM, H5E_CANTINIT, FAIL, "unable to create group") + + /* Get an atom for the group */ + if((ret_value = H5VL_register_id(H5I_GROUP, grp, obj->vol_info, TRUE)) < 0) + HGOTO_ERROR(H5E_ATOM, H5E_CANTREGISTER, FAIL, "unable to atomize group handle") done: - if(ret_value < 0) - if(grp && H5G_close(grp) < 0) + if (ret_value < 0 && grp) + if(H5VL_group_close (grp, obj->vol_info->vol_cls, H5AC_dxpl_id, H5_REQUEST_NULL) < 0) HDONE_ERROR(H5E_SYM, H5E_CLOSEERROR, FAIL, "unable to release group") - FUNC_LEAVE_API(ret_value) } /* end H5Gcreate2() */ @@ -362,18 +378,14 @@ done: hid_t H5Gcreate_anon(hid_t loc_id, hid_t gcpl_id, hid_t gapl_id) { - H5G_loc_t loc; - H5G_t *grp = NULL; - H5G_obj_create_t gcrt_info; /* Information for group creation */ - hid_t ret_value; + void *grp = NULL; /* group token from VOL plugin */ + H5VL_object_t *obj = NULL; /* object token of loc_id */ + H5VL_loc_params_t loc_params; + hid_t ret_value; /* Return value */ FUNC_ENTER_API(FAIL) H5TRACE3("i", "iii", loc_id, gcpl_id, gapl_id); - /* Check arguments */ - if(H5G_loc(loc_id, &loc) < 0) - HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a location") - /* Check group creation property list */ if(H5P_DEFAULT == gcpl_id) gcpl_id = H5P_GROUP_CREATE_DEFAULT; @@ -388,36 +400,26 @@ H5Gcreate_anon(hid_t loc_id, hid_t gcpl_id, hid_t gapl_id) if(TRUE != H5P_isa_class(gapl_id, H5P_GROUP_ACCESS)) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not group access property list") - /* 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)); + loc_params.type = H5VL_OBJECT_BY_SELF; + loc_params.obj_type = H5I_get_type(loc_id); - /* Create the new group & get its ID */ - if(NULL == (grp = H5G__create(loc.oloc->file, &gcrt_info, H5AC_dxpl_id))) - HGOTO_ERROR(H5E_SYM, H5E_CANTINIT, FAIL, "unable to create group") - if((ret_value = H5I_register(H5I_GROUP, grp, TRUE)) < 0) - HGOTO_ERROR(H5E_ATOM, H5E_CANTREGISTER, FAIL, "unable to register group") + /* get the location object */ + if(NULL == (obj = (H5VL_object_t *)H5I_object(loc_id))) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "invalid location identifier") -done: - /* Release the group's object header, if it was created */ - if(grp) { - H5O_loc_t *oloc; /* Object location for group */ + /* Create the group through the VOL */ + if(NULL == (grp = H5VL_group_create(obj->vol_obj, loc_params, obj->vol_info->vol_cls, NULL, + gcpl_id, gapl_id, H5AC_dxpl_id, H5_REQUEST_NULL))) + HGOTO_ERROR(H5E_SYM, H5E_CANTINIT, FAIL, "unable to create group") - /* Get the new group's object location */ - if(NULL == (oloc = H5G_oloc(grp))) - HDONE_ERROR(H5E_SYM, H5E_CANTGET, FAIL, "unable to get object location of group") + /* Get an atom for the group */ + if((ret_value = H5VL_register_id(H5I_GROUP, grp, obj->vol_info, TRUE)) < 0) + HGOTO_ERROR(H5E_ATOM, H5E_CANTREGISTER, FAIL, "unable to atomize group handle") - /* Decrement refcount on group's object header in memory */ - if(H5O_dec_rc_by_loc(oloc, H5AC_dxpl_id) < 0) - HDONE_ERROR(H5E_SYM, H5E_CANTDEC, FAIL, "unable to decrement refcount on newly created object") - } /* end if */ - - /* Cleanup on failure */ - if(ret_value < 0) - if(grp && H5G_close(grp) < 0) +done: + if (ret_value < 0 && grp) + if(H5VL_group_close (grp, obj->vol_info->vol_cls, H5AC_dxpl_id, H5_REQUEST_NULL) < 0) HDONE_ERROR(H5E_SYM, H5E_CLOSEERROR, FAIL, "unable to release group") - FUNC_LEAVE_API(ret_value) } /* end H5Gcreate_anon() */ @@ -442,16 +444,15 @@ done: hid_t H5Gopen2(hid_t loc_id, const char *name, hid_t gapl_id) { - H5G_t *grp = NULL; /* Group opened */ - H5G_loc_t loc; /* Location of parent for group */ - hid_t ret_value; /* Return value */ + void *grp = NULL; /* group token from VOL plugin */ + H5VL_object_t *obj = NULL; /* object token of loc_id */ + H5VL_loc_params_t loc_params; + hid_t ret_value; /* Return value */ FUNC_ENTER_API(FAIL) H5TRACE3("i", "i*si", loc_id, name, gapl_id); /* Check args */ - 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") @@ -462,20 +463,26 @@ H5Gopen2(hid_t loc_id, const char *name, hid_t gapl_id) if(TRUE != H5P_isa_class(gapl_id, H5P_GROUP_ACCESS)) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not group access property list") - /* Open the group */ - if((grp = H5G__open_name(&loc, name, gapl_id, H5AC_dxpl_id)) == NULL) - HGOTO_ERROR(H5E_SYM, H5E_CANTOPENOBJ, FAIL, "unable to open group") + loc_params.type = H5VL_OBJECT_BY_SELF; + loc_params.obj_type = H5I_get_type(loc_id); + + /* get the location object */ + if(NULL == (obj = (H5VL_object_t *)H5I_object(loc_id))) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "invalid location identifier") - /* Register an ID for the group */ - if((ret_value = H5I_register(H5I_GROUP, grp, TRUE)) < 0) - HGOTO_ERROR(H5E_ATOM, H5E_CANTREGISTER, FAIL, "unable to register group") + /* Create the group through the VOL */ + if(NULL == (grp = H5VL_group_open(obj->vol_obj, loc_params, obj->vol_info->vol_cls, + name, gapl_id, H5AC_dxpl_id, H5_REQUEST_NULL))) + HGOTO_ERROR(H5E_SYM, H5E_CANTOPENOBJ, FAIL, "unable to open group") + + /* Get an atom for the group */ + if((ret_value = H5VL_register_id(H5I_GROUP, grp, obj->vol_info, TRUE)) < 0) + HGOTO_ERROR(H5E_ATOM, H5E_CANTREGISTER, FAIL, "unable to atomize group handle") done: - if(ret_value < 0) { - if(grp && H5G_close(grp) < 0) + if (ret_value < 0 && grp) + if(H5VL_group_close (grp, obj->vol_info->vol_cls, H5AC_dxpl_id, H5_REQUEST_NULL) < 0) HDONE_ERROR(H5E_SYM, H5E_CLOSEERROR, FAIL, "unable to release group") - } /* end if */ - FUNC_LEAVE_API(ret_value) } /* end H5Gopen2() */ @@ -497,20 +504,21 @@ done: *------------------------------------------------------------------------- */ hid_t -H5Gget_create_plist(hid_t group_id) +H5Gget_create_plist(hid_t grp_id) { - H5G_t *group = NULL; - hid_t ret_value = FAIL; + H5VL_object_t *grp; + hid_t ret_value = FAIL; FUNC_ENTER_API(FAIL) - H5TRACE1("i", "i", group_id); + H5TRACE1("i", "i", grp_id); /* Check args */ - if(NULL == (group = (H5G_t *)H5I_object_verify(group_id, H5I_GROUP))) + if(NULL == (grp = (H5VL_object_t *)H5I_object_verify(grp_id, H5I_GROUP))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a group") - if((ret_value = H5G_get_create_plist(group)) < 0) - HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a group") + if(H5VL_group_get(grp->vol_obj, grp->vol_info->vol_cls, H5VL_GROUP_GET_GCPL, + H5AC_dxpl_id, H5_REQUEST_NULL, &ret_value) < 0) + HGOTO_ERROR(H5E_INTERNAL, H5E_CANTGET, FAIL, "unable to get group creation properties") done: FUNC_LEAVE_API(ret_value) @@ -518,101 +526,6 @@ done: /*------------------------------------------------------------------------- - * Function: H5G_get_create_plist - * - * Purpose: Private function for H5Gget_create_plist - * - * Return: Success: ID for a copy of the group creation - * property list. The property list ID should be - * released by calling H5Pclose(). - * - * Failure: FAIL - * - * Programmer: Quincey Koziol - * Tuesday, October 25, 2005 - * - *------------------------------------------------------------------------- - */ -hid_t -H5G_get_create_plist(H5G_t *grp) -{ - H5O_linfo_t linfo; /* Link info message */ - htri_t ginfo_exists; - htri_t linfo_exists; - htri_t pline_exists; - H5P_genplist_t *gcpl_plist; - H5P_genplist_t *new_plist; - hid_t new_gcpl_id = FAIL; - hid_t ret_value = FAIL; - - FUNC_ENTER_NOAPI(FAIL) - - /* Copy the default group creation property list */ - if(NULL == (gcpl_plist = (H5P_genplist_t *)H5I_object(H5P_LST_GROUP_CREATE_ID_g))) - HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "can't get default group creation property list") - if((new_gcpl_id = H5P_copy_plist(gcpl_plist, TRUE)) < 0) - HGOTO_ERROR(H5E_SYM, H5E_CANTGET, FAIL, "unable to copy the creation property list") - if(NULL == (new_plist = (H5P_genplist_t *)H5I_object(new_gcpl_id))) - HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "can't get property list") - - /* Retrieve any object creation properties */ - if(H5O_get_create_plist(&grp->oloc, H5AC_ind_dxpl_id, new_plist) < 0) - HGOTO_ERROR(H5E_SYM, H5E_CANTGET, FAIL, "can't get object creation info") - - /* Check for the group having a group info message */ - if((ginfo_exists = H5O_msg_exists(&(grp->oloc), H5O_GINFO_ID, H5AC_ind_dxpl_id)) < 0) - HGOTO_ERROR(H5E_SYM, H5E_CANTINIT, FAIL, "unable to read object header") - if(ginfo_exists) { - H5O_ginfo_t ginfo; /* Group info message */ - - /* Read the group info */ - if(NULL == H5O_msg_read(&(grp->oloc), H5O_GINFO_ID, &ginfo, H5AC_ind_dxpl_id)) - HGOTO_ERROR(H5E_SYM, H5E_BADMESG, FAIL, "can't get group info") - - /* Set the group info for the property list */ - if(H5P_set(new_plist, H5G_CRT_GROUP_INFO_NAME, &ginfo) < 0) - HGOTO_ERROR(H5E_PLIST, H5E_CANTSET, FAIL, "can't set group info") - } /* end if */ - - /* Check for the group having a link info message */ - if((linfo_exists = H5G__obj_get_linfo(&(grp->oloc), &linfo, H5AC_ind_dxpl_id)) < 0) - HGOTO_ERROR(H5E_SYM, H5E_CANTINIT, FAIL, "unable to read object header") - if(linfo_exists) { - /* Set the link info for the property list */ - if(H5P_set(new_plist, H5G_CRT_LINK_INFO_NAME, &linfo) < 0) - HGOTO_ERROR(H5E_PLIST, H5E_CANTSET, FAIL, "can't set link info") - } /* end if */ - - /* Check for the group having a pipeline message */ - if((pline_exists = H5O_msg_exists(&(grp->oloc), H5O_PLINE_ID, H5AC_ind_dxpl_id)) < 0) - HGOTO_ERROR(H5E_SYM, H5E_CANTGET, FAIL, "unable to read object header") - if(pline_exists) { - H5O_pline_t pline; /* Pipeline message */ - - /* Read the pipeline */ - if(NULL == H5O_msg_read(&(grp->oloc), H5O_PLINE_ID, &pline, H5AC_ind_dxpl_id)) - HGOTO_ERROR(H5E_SYM, H5E_BADMESG, FAIL, "can't get link pipeline") - - /* Set the pipeline for the property list */ - if(H5P_set(new_plist, H5O_CRT_PIPELINE_NAME, &pline) < 0) - HGOTO_ERROR(H5E_PLIST, H5E_CANTSET, FAIL, "can't set link pipeline") - } /* end if */ - - /* Set the return value */ - ret_value = new_gcpl_id; - -done: - if(ret_value < 0) { - if(new_gcpl_id > 0) - if(H5I_dec_app_ref(new_gcpl_id) < 0) - HDONE_ERROR(H5E_SYM, H5E_CANTDEC, FAIL, "can't free") - } /* end if */ - - FUNC_LEAVE_NOAPI(ret_value) -} /* end H5G_get_create_plist() */ - - -/*------------------------------------------------------------------------- * Function: H5Gget_info * * Purpose: Retrieve information about a group. @@ -626,29 +539,34 @@ done: *------------------------------------------------------------------------- */ herr_t -H5Gget_info(hid_t grp_id, H5G_info_t *grp_info) +H5Gget_info(hid_t loc_id, H5G_info_t *grp_info) { + H5VL_object_t *obj; H5I_type_t id_type; /* Type of ID */ - H5G_loc_t loc; /* Location of group */ + H5VL_loc_params_t loc_params; herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_API(FAIL) - H5TRACE2("e", "i*x", grp_id, grp_info); + H5TRACE2("e", "i*x", loc_id, grp_info); /* Check args */ - id_type = H5I_get_type(grp_id); + id_type = H5I_get_type(loc_id); if(!(H5I_GROUP == id_type || H5I_FILE == id_type)) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "invalid argument") if(!grp_info) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "no info struct") - /* Get group location */ - if(H5G_loc(grp_id, &loc) < 0) - HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a location") + /* get the location object */ + if(NULL == (obj = (H5VL_object_t *)H5I_object(loc_id))) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "invalid location identifier") - /* Retrieve the group's information */ - if(H5G__obj_info(loc.oloc, grp_info/*out*/, H5AC_ind_dxpl_id) < 0) - HGOTO_ERROR(H5E_SYM, H5E_CANTGET, FAIL, "can't retrieve group info") + loc_params.type = H5VL_OBJECT_BY_SELF; + loc_params.obj_type = id_type; + + /* Get the group info through the VOL using the location token */ + if((ret_value = H5VL_group_get(obj->vol_obj, obj->vol_info->vol_cls, H5VL_GROUP_GET_INFO, + H5AC_ind_dxpl_id, H5_REQUEST_NULL, loc_params, grp_info)) < 0) + HGOTO_ERROR(H5E_INTERNAL, H5E_CANTGET, FAIL, "unable to get group info") done: FUNC_LEAVE_API(ret_value) @@ -672,19 +590,14 @@ herr_t H5Gget_info_by_name(hid_t loc_id, const char *name, H5G_info_t *grp_info, hid_t lapl_id) { - H5G_loc_t loc; /* Location of group */ - H5G_loc_t grp_loc; /* Location used to open group */ - H5G_name_t grp_path; /* Opened object group hier. path */ - H5O_loc_t grp_oloc; /* Opened object object location */ - hbool_t loc_found = FALSE; /* Location at 'name' found */ + H5VL_object_t *obj; + H5VL_loc_params_t loc_params; herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_API(FAIL) H5TRACE4("e", "i*s*xi", loc_id, name, grp_info, lapl_id); /* Check args */ - 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") if(!grp_info) @@ -695,24 +608,21 @@ H5Gget_info_by_name(hid_t loc_id, const char *name, H5G_info_t *grp_info, if(TRUE != H5P_isa_class(lapl_id, H5P_LINK_ACCESS)) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not link access property list ID") - /* Set up opened group location to fill in */ - grp_loc.oloc = &grp_oloc; - grp_loc.path = &grp_path; - H5G_loc_reset(&grp_loc); + 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 = lapl_id; + loc_params.obj_type = H5I_get_type(loc_id); - /* Find the group object */ - if(H5G_loc_find(&loc, name, &grp_loc/*out*/, lapl_id, H5AC_ind_dxpl_id) < 0) - HGOTO_ERROR(H5E_SYM, H5E_NOTFOUND, FAIL, "group not found") - loc_found = TRUE; + /* get the location object */ + if(NULL == (obj = (H5VL_object_t *)H5I_object(loc_id))) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "invalid location identifier") - /* Retrieve the group's information */ - if(H5G__obj_info(grp_loc.oloc, grp_info/*out*/, H5AC_ind_dxpl_id) < 0) - HGOTO_ERROR(H5E_SYM, H5E_CANTGET, FAIL, "can't retrieve group info") + /* Get the group info through the VOL using the location token */ + if((ret_value = H5VL_group_get(obj->vol_obj, obj->vol_info->vol_cls, H5VL_GROUP_GET_INFO, + H5AC_ind_dxpl_id, H5_REQUEST_NULL, loc_params, grp_info)) < 0) + HGOTO_ERROR(H5E_INTERNAL, H5E_CANTGET, FAIL, "unable to get group info") done: - if(loc_found && H5G_loc_free(&grp_loc) < 0) - HDONE_ERROR(H5E_SYM, H5E_CANTRELEASE, FAIL, "can't free location") - FUNC_LEAVE_API(ret_value) } /* end H5Gget_info_by_name() */ @@ -735,11 +645,8 @@ herr_t H5Gget_info_by_idx(hid_t loc_id, const char *group_name, H5_index_t idx_type, H5_iter_order_t order, hsize_t n, H5G_info_t *grp_info, hid_t lapl_id) { - H5G_loc_t loc; /* Location of group */ - H5G_loc_t grp_loc; /* Location used to open group */ - H5G_name_t grp_path; /* Opened object group hier. path */ - H5O_loc_t grp_oloc; /* Opened object object location */ - hbool_t loc_found = FALSE; /* Entry at 'name' found */ + H5VL_object_t *obj; + H5VL_loc_params_t loc_params; herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_API(FAIL) @@ -747,8 +654,6 @@ H5Gget_info_by_idx(hid_t loc_id, const char *group_name, H5_index_t idx_type, lapl_id); /* Check args */ - if(H5G_loc(loc_id, &loc) < 0) - HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a location") if(!group_name || !*group_name) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "no name specified") if(idx_type <= H5_INDEX_UNKNOWN || idx_type >= H5_INDEX_N) @@ -763,25 +668,25 @@ H5Gget_info_by_idx(hid_t loc_id, const char *group_name, H5_index_t idx_type, if(TRUE != H5P_isa_class(lapl_id, H5P_LINK_ACCESS)) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not link access property list ID") - /* Set up opened group location to fill in */ - grp_loc.oloc = &grp_oloc; - grp_loc.path = &grp_path; - H5G_loc_reset(&grp_loc); + loc_params.type = H5VL_OBJECT_BY_IDX; + loc_params.loc_data.loc_by_idx.name = group_name; + loc_params.loc_data.loc_by_idx.idx_type = idx_type; + loc_params.loc_data.loc_by_idx.order = order; + loc_params.loc_data.loc_by_idx.n = n; + loc_params.loc_data.loc_by_idx.lapl_id = lapl_id; + loc_params.obj_type = H5I_get_type(loc_id); - /* Find the object's location, according to the order in the index */ - if(H5G_loc_find_by_idx(&loc, group_name, idx_type, order, n, &grp_loc/*out*/, lapl_id, H5AC_ind_dxpl_id) < 0) - HGOTO_ERROR(H5E_SYM, H5E_NOTFOUND, FAIL, "group not found") - loc_found = TRUE; + /* get the location object */ + if(NULL == (obj = (H5VL_object_t *)H5I_object(loc_id))) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "invalid location identifier") - /* Retrieve the group's information */ - if(H5G__obj_info(grp_loc.oloc, grp_info/*out*/, H5AC_ind_dxpl_id) < 0) - HGOTO_ERROR(H5E_SYM, H5E_CANTGET, FAIL, "can't retrieve group info") + /* Get the group info through the VOL using the location token */ + if((ret_value = H5VL_group_get(obj->vol_obj, obj->vol_info->vol_cls, + H5VL_GROUP_GET_INFO, H5AC_ind_dxpl_id, + H5_REQUEST_NULL, loc_params, grp_info)) < 0) + HGOTO_ERROR(H5E_INTERNAL, H5E_CANTGET, FAIL, "unable to get group info") done: - /* Release the object location */ - if(loc_found && H5G_loc_free(&grp_loc) < 0) - HDONE_ERROR(H5E_SYM, H5E_CANTRELEASE, FAIL, "can't free location") - FUNC_LEAVE_API(ret_value) } /* end H5Gget_info_by_idx() */ @@ -822,3 +727,38 @@ done: FUNC_LEAVE_API(ret_value) } /* end H5Gclose() */ + +/*------------------------------------------------------------------------- + * Function: H5G_close_group + * + * Purpose: Called when the ref count reaches zero on the group_id + * + * Return: Success: Non-negative + * + * Failure: Negative + * + * Programmer: Mohamad Chaarawi + * June 2012 + * + *------------------------------------------------------------------------- + */ +herr_t +H5G_close_group(void *_grp) +{ + H5VL_object_t *grp = (H5VL_object_t *)_grp; + herr_t ret_value = SUCCEED; /* Return value */ + + FUNC_ENTER_NOAPI_NOINIT + + /* Close the group through the VOL*/ + if((ret_value = H5VL_group_close(grp->vol_obj, grp->vol_info->vol_cls, + H5AC_dxpl_id, H5_REQUEST_NULL)) < 0) + HGOTO_ERROR(H5E_SYM, H5E_CLOSEERROR, FAIL, "unable to close group") + + /* free group */ + if(H5VL_free_object(grp) < 0) + HGOTO_ERROR(H5E_ATTR, H5E_CANTDEC, FAIL, "unable to free VOL object") + +done: + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5G_close_group() */ diff --git a/src/H5Gdeprec.c b/src/H5Gdeprec.c index 17920ab..c580f73 100644 --- a/src/H5Gdeprec.c +++ b/src/H5Gdeprec.c @@ -47,7 +47,7 @@ #include "H5Iprivate.h" /* IDs */ #include "H5Lprivate.h" /* Links */ #include "H5Pprivate.h" /* Property lists */ - +#include "H5VLprivate.h" /* VOL plugins */ /****************/ /* Local Macros */ @@ -77,10 +77,6 @@ typedef struct { /* Local Prototypes */ /********************/ -static herr_t H5G_link_hard(hid_t cur_loc_id, const char *cur_name, - hid_t new_loc_id, const char *new_name); -static herr_t H5G_move(hid_t src_loc_id, const char *src_name, - hid_t dst_loc_id, const char *dst_name); 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*/); @@ -225,24 +221,25 @@ H5G_map_obj_type(H5O_type_t obj_type) hid_t H5Gcreate1(hid_t loc_id, const char *name, size_t size_hint) { - H5G_loc_t loc; /* Location to create group */ - H5G_t *grp = NULL; /* New group created */ - hid_t tmp_gcpl = (-1); /* Temporary group creation property list */ - hid_t ret_value; /* Return value */ + void *grp = NULL; /* group token from VOL plugin */ + H5VL_object_t *obj = NULL; /* object token of loc_id */ + H5VL_loc_params_t loc_params; + H5P_genplist_t *plist; /* Property list pointer */ + hid_t tmp_gcpl = (-1); /* Temporary group creation property list */ + hid_t lcpl_id = H5P_LINK_CREATE_DEFAULT; + hid_t ret_value; /* Return value */ FUNC_ENTER_API(FAIL) H5TRACE3("i", "i*sz", loc_id, name, size_hint); /* 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 given") /* Check if we need to create a non-standard GCPL */ if(size_hint > 0) { - H5P_genplist_t *gc_plist; /* Property list created */ H5O_ginfo_t ginfo; /* Group info property */ + H5P_genplist_t *gc_plist; /* Property list created */ /* Get the default property list */ if(NULL == (gc_plist = (H5P_genplist_t *)H5I_object(H5P_GROUP_CREATE_DEFAULT))) @@ -268,20 +265,36 @@ H5Gcreate1(hid_t loc_id, const char *name, size_t size_hint) else tmp_gcpl = H5P_GROUP_CREATE_DEFAULT; - /* Create the new group & get its ID */ - if(NULL == (grp = H5G__create_named(&loc, name, H5P_LINK_CREATE_DEFAULT, - tmp_gcpl, H5P_GROUP_ACCESS_DEFAULT, H5AC_dxpl_id))) - HGOTO_ERROR(H5E_SYM, H5E_CANTINIT, FAIL, "unable to create group") - if((ret_value = H5I_register(H5I_GROUP, grp, TRUE)) < 0) - HGOTO_ERROR(H5E_ATOM, H5E_CANTREGISTER, FAIL, "unable to register group") + /* Get the plist structure */ + if(NULL == (plist = (H5P_genplist_t *)H5I_object(tmp_gcpl))) + HGOTO_ERROR(H5E_ATOM, H5E_BADATOM, FAIL, "can't find object for ID") + + /* get creation properties */ + if(H5P_set(plist, H5VL_PROP_GRP_LCPL_ID, &lcpl_id) < 0) + HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, FAIL, "can't get property value for lcpl id") + + loc_params.type = H5VL_OBJECT_BY_SELF; + loc_params.obj_type = H5I_get_type(loc_id); + + /* get the location object */ + if(NULL == (obj = (H5VL_object_t *)H5I_object(loc_id))) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "invalid location identifier") + + /* Create the group through the VOL */ + if(NULL == (grp = H5VL_group_create(obj->vol_obj, loc_params, obj->vol_info->vol_cls, name, tmp_gcpl, + H5P_GROUP_ACCESS_DEFAULT, H5AC_dxpl_id, H5_REQUEST_NULL))) + HGOTO_ERROR(H5E_SYM, H5E_CANTINIT, FAIL, "unable to create group") + + /* Get an atom for the group */ + if((ret_value = H5VL_register_id(H5I_GROUP, grp, obj->vol_info, TRUE)) < 0) + HGOTO_ERROR(H5E_ATOM, H5E_CANTREGISTER, FAIL, "unable to atomize group handle") done: if(tmp_gcpl > 0 && tmp_gcpl != H5P_GROUP_CREATE_DEFAULT) if(H5I_dec_ref(tmp_gcpl) < 0) HDONE_ERROR(H5E_SYM, H5E_CLOSEERROR, FAIL, "unable to release property list") - - if(ret_value < 0) - if(grp && H5G_close(grp) < 0) + if (ret_value < 0 && grp) + if(H5VL_group_close (grp, obj->vol_info->vol_cls, H5AC_dxpl_id, H5_REQUEST_NULL) < 0) HDONE_ERROR(H5E_SYM, H5E_CLOSEERROR, FAIL, "unable to release group") FUNC_LEAVE_API(ret_value) @@ -308,33 +321,38 @@ done: hid_t H5Gopen1(hid_t loc_id, const char *name) { - H5G_t *grp = NULL; /* Group opened */ - H5G_loc_t loc; /* Location of parent for group */ - hid_t ret_value; /* Return value */ + void *grp = NULL; /* group token from VOL plugin */ + H5VL_object_t *obj = NULL; /* object token of loc_id */ + H5VL_loc_params_t loc_params; + hid_t ret_value; /* Return value */ FUNC_ENTER_API(FAIL) H5TRACE2("i", "i*s", loc_id, name); /* Check args */ - 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") - /* Open the group */ - if((grp = H5G__open_name(&loc, name, H5P_DEFAULT, H5AC_dxpl_id)) == NULL) - HGOTO_ERROR(H5E_SYM, H5E_CANTOPENOBJ, FAIL, "unable to open group") + loc_params.type = H5VL_OBJECT_BY_SELF; + loc_params.obj_type = H5I_get_type(loc_id); - /* Register an atom for the group */ - if((ret_value = H5I_register(H5I_GROUP, grp, TRUE)) < 0) - HGOTO_ERROR(H5E_ATOM, H5E_CANTREGISTER, FAIL, "unable to register group") + /* get the location object */ + if(NULL == (obj = (H5VL_object_t *)H5I_object(loc_id))) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "invalid location identifier") + + /* Create the group through the VOL */ + if(NULL == (grp = H5VL_group_open(obj->vol_obj, loc_params, obj->vol_info->vol_cls, name, H5P_DEFAULT, + H5AC_dxpl_id, H5_REQUEST_NULL))) + HGOTO_ERROR(H5E_SYM, H5E_CANTINIT, FAIL, "unable to create group") + + /* Get an atom for the group */ + if((ret_value = H5VL_register_id(H5I_GROUP, grp, obj->vol_info, TRUE)) < 0) + HGOTO_ERROR(H5E_ATOM, H5E_CANTREGISTER, FAIL, "unable to atomize group handle") done: - if(ret_value < 0) { - if(grp && H5G_close(grp) < 0) + if (ret_value < 0 && grp) + if(H5VL_group_close (grp, obj->vol_info->vol_cls, H5AC_dxpl_id, H5_REQUEST_NULL) < 0) HDONE_ERROR(H5E_SYM, H5E_CLOSEERROR, FAIL, "unable to release group") - } /* end if */ - FUNC_LEAVE_API(ret_value) } /* end H5Gopen1() */ @@ -350,6 +368,8 @@ done: herr_t H5Glink(hid_t cur_loc_id, H5G_link_t type, const char *cur_name, const char *new_name) { + hid_t lcpl_id = H5P_LINK_CREATE_DEFAULT; + H5P_genplist_t *plist; /* Property list pointer */ herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_API(FAIL) @@ -361,20 +381,60 @@ H5Glink(hid_t cur_loc_id, H5G_link_t type, const char *cur_name, const char *new if(!new_name || !*new_name) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "no new name specified") + /* 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") + if(type == H5L_TYPE_HARD) { - if((ret_value = H5G_link_hard(cur_loc_id, cur_name, H5L_SAME_LOC, new_name)) < 0) - HGOTO_ERROR(H5E_LINK, H5E_CANTINIT, FAIL, "couldn't create link") + H5VL_object_t *obj = NULL; /* object token of loc_id */ + H5VL_loc_params_t loc_params1; + H5VL_loc_params_t loc_params2; + + loc_params1.type = H5VL_OBJECT_BY_NAME; + loc_params1.obj_type = H5I_get_type(cur_loc_id); + loc_params1.loc_data.loc_by_name.name = cur_name; + loc_params1.loc_data.loc_by_name.lapl_id = H5P_DEFAULT; + + loc_params2.type = H5VL_OBJECT_BY_NAME; + loc_params2.loc_data.loc_by_name.name = new_name; + loc_params2.loc_data.loc_by_name.lapl_id = H5P_DEFAULT; + + /* get the location object */ + if(NULL == (obj = (H5VL_object_t *)H5I_object(cur_loc_id))) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "invalid location identifier") + + /* set creation properties */ + if(H5P_set(plist, H5VL_PROP_LINK_TARGET, &obj->vol_obj) < 0) + HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, FAIL, "can't set property value for target") + 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") + + /* Create the link through the VOL */ + if((ret_value = H5VL_link_create(H5VL_LINK_CREATE_HARD, NULL, loc_params2, obj->vol_info->vol_cls, + lcpl_id, H5P_DEFAULT, H5AC_dxpl_id, H5_REQUEST_NULL)) < 0) + HGOTO_ERROR(H5E_SYM, H5E_CANTINIT, FAIL, "unable to create link") } /* end if */ else if(type == H5L_TYPE_SOFT) { - H5G_loc_t cur_loc; /* Group location for new link */ - - /* Finish checking arguments */ - if(H5G_loc(cur_loc_id, &cur_loc) < 0) - HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a location") - - /* Create the link */ - if(H5L_create_soft(cur_name, &cur_loc, new_name, H5P_DEFAULT, H5P_DEFAULT, H5AC_dxpl_id) < 0) - HGOTO_ERROR(H5E_LINK, H5E_CANTINIT, FAIL, "unable to create link") + H5VL_object_t *obj = NULL; /* object token of loc_id */ + H5VL_loc_params_t loc_params; + + loc_params.type = H5VL_OBJECT_BY_NAME; + loc_params.loc_data.loc_by_name.name = new_name; + loc_params.loc_data.loc_by_name.lapl_id = H5P_DEFAULT; + loc_params.obj_type = H5I_get_type(cur_loc_id); + + /* get the location object */ + if(NULL == (obj = (H5VL_object_t *)H5I_object(cur_loc_id))) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "invalid location identifier") + + /* set creation properties */ + if(H5P_set(plist, H5VL_PROP_LINK_TARGET_NAME, &cur_name) < 0) + 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, obj->vol_obj, loc_params, obj->vol_info->vol_cls, + lcpl_id, H5P_DEFAULT, H5AC_dxpl_id, 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") @@ -396,6 +456,8 @@ herr_t H5Glink2(hid_t cur_loc_id, const char *cur_name, H5G_link_t type, hid_t new_loc_id, const char *new_name) { + hid_t lcpl_id = H5P_LINK_CREATE_DEFAULT; + H5P_genplist_t *plist; /* Property list pointer */ herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_API(FAIL) @@ -407,25 +469,69 @@ H5Glink2(hid_t cur_loc_id, const char *cur_name, H5G_link_t type, if(!new_name || !*new_name) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "no new name specified") + /* 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") + if(type == H5L_TYPE_HARD) { - if((ret_value = H5G_link_hard(cur_loc_id, cur_name, new_loc_id, new_name)) < 0) - HGOTO_ERROR(H5E_LINK, H5E_CANTINIT, FAIL, "couldn't create link") + H5VL_object_t *obj1 = NULL; /* object token of loc_id */ + H5VL_object_t *obj2 = NULL; /* object token of loc_id */ + H5VL_loc_params_t loc_params1; + H5VL_loc_params_t loc_params2; + + loc_params1.type = H5VL_OBJECT_BY_NAME; + loc_params1.obj_type = H5I_get_type(cur_loc_id); + loc_params1.loc_data.loc_by_name.name = cur_name; + loc_params1.loc_data.loc_by_name.lapl_id = H5P_DEFAULT; + + loc_params2.type = H5VL_OBJECT_BY_NAME; + loc_params2.obj_type = H5I_get_type(new_loc_id); + loc_params2.loc_data.loc_by_name.name = new_name; + loc_params2.loc_data.loc_by_name.lapl_id = H5P_DEFAULT; + + /* get the location object */ + if(NULL == (obj1 = (H5VL_object_t *)H5I_object(cur_loc_id))) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "invalid location identifier") + if(NULL == (obj2 = (H5VL_object_t *)H5I_object(new_loc_id))) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "invalid location identifier") + + /* set creation properties */ + if(H5P_set(plist, H5VL_PROP_LINK_TARGET, &obj1->vol_obj) < 0) + HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, FAIL, "can't set property value for target 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 name") + + /* Create the link through the VOL */ + if((ret_value = H5VL_link_create(H5VL_LINK_CREATE_HARD, obj2->vol_obj, loc_params2, obj2->vol_info->vol_cls, + lcpl_id, H5P_DEFAULT, H5AC_dxpl_id, H5_REQUEST_NULL)) < 0) + HGOTO_ERROR(H5E_SYM, H5E_CANTINIT, FAIL, "unable to create link") } /* end if */ else if(type == H5L_TYPE_SOFT) { - H5G_loc_t new_loc; /* Group location for new link */ + H5VL_object_t *obj = NULL; /* 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 * new_loc_id is H5L_SAME_LOC */ if(new_loc_id == H5L_SAME_LOC) new_loc_id = cur_loc_id; - /* Finish checking arguments */ - if(H5G_loc(new_loc_id, &new_loc) < 0) - HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a location") + loc_params.type = H5VL_OBJECT_BY_NAME; + loc_params.loc_data.loc_by_name.name = new_name; + loc_params.loc_data.loc_by_name.lapl_id = H5P_DEFAULT; + loc_params.obj_type = H5I_get_type(new_loc_id); + + /* get the location object */ + if(NULL == (obj = (H5VL_object_t *)H5I_object(new_loc_id))) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "invalid location identifier") - /* Create the link */ - if(H5L_create_soft(cur_name, &new_loc, new_name, H5P_DEFAULT, H5P_DEFAULT, H5AC_dxpl_id) < 0) - HGOTO_ERROR(H5E_LINK, H5E_CANTINIT, FAIL, "unable to create link") + /* set creation properties */ + if(H5P_set(plist, H5VL_PROP_LINK_TARGET_NAME, &cur_name) < 0) + 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, obj->vol_obj, loc_params, obj->vol_info->vol_cls, + lcpl_id, H5P_DEFAULT, H5AC_dxpl_id, 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") @@ -436,60 +542,6 @@ done: /*------------------------------------------------------------------------- - * Function: H5G_link_hard - * - * Purpose: Creates a hard link from NEW_NAME to CUR_NAME. - * - * CUR_NAME must name an existing object. CUR_NAME and - * NEW_NAME are interpreted relative to CUR_LOC_ID and - * NEW_LOC_ID, which are either file IDs or group IDs. - * - * Return: Non-negative on success/Negative on failure - * - * Programmer: Quincey Koziol - * Monday, November 6, 2006 - * - *------------------------------------------------------------------------- - */ -static herr_t -H5G_link_hard(hid_t cur_loc_id, const char *cur_name, hid_t new_loc_id, - const char *new_name) -{ - H5G_loc_t cur_loc, *cur_loc_p; /* Information about current link's group */ - H5G_loc_t new_loc, *new_loc_p; /* Information about new link's group */ - herr_t ret_value = SUCCEED; /* Return value */ - - FUNC_ENTER_NOAPI_NOINIT - - /* Finish checking arguments */ - if(cur_loc_id == H5L_SAME_LOC && new_loc_id == H5L_SAME_LOC) - HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "source and destination should not be both H5L_SAME_LOC") - if(cur_loc_id != H5L_SAME_LOC && H5G_loc(cur_loc_id, &cur_loc) < 0) - HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a location") - if(new_loc_id != H5L_SAME_LOC && H5G_loc(new_loc_id, &new_loc) < 0) - HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a location") - - /* Set up current & new location pointers */ - cur_loc_p = &cur_loc; - new_loc_p = &new_loc; - if(cur_loc_id == H5L_SAME_LOC) - cur_loc_p = new_loc_p; - else if(new_loc_id == H5L_SAME_LOC) - new_loc_p = cur_loc_p; - else if(cur_loc_p->oloc->file != new_loc_p->oloc->file) - HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "source and destination should be in the same file.") - - /* Create the link */ - if(H5L_create_hard(cur_loc_p, cur_name, new_loc_p, new_name, - H5P_DEFAULT, H5P_DEFAULT, H5AC_dxpl_id) < 0) - HGOTO_ERROR(H5E_LINK, H5E_CANTINIT, FAIL, "unable to create link") - -done: - FUNC_LEAVE_NOAPI(ret_value) -} /* end H5G_link_hard() */ - - -/*------------------------------------------------------------------------- * Function: H5Gmove * * Purpose: Moves and renames a link. The new API to do this is H5Lmove. @@ -499,14 +551,31 @@ done: herr_t H5Gmove(hid_t src_loc_id, const char *src_name, const char *dst_name) { + H5VL_object_t *obj = NULL; /* object token of loc_id */ + H5VL_loc_params_t loc_params1; + H5VL_loc_params_t loc_params2; herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_API(FAIL) H5TRACE3("e", "i*s*s", src_loc_id, src_name, dst_name); - /* Call common routine to move the link */ - if(H5G_move(src_loc_id, src_name, H5L_SAME_LOC, dst_name) < 0) - HGOTO_ERROR(H5E_LINK, H5E_CANTINIT, FAIL, "couldn't move link") + loc_params1.type = H5VL_OBJECT_BY_NAME; + loc_params1.obj_type = H5I_get_type(src_loc_id); + loc_params1.loc_data.loc_by_name.name = src_name; + loc_params1.loc_data.loc_by_name.lapl_id = H5P_DEFAULT; + + 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; + + /* get the location object */ + if(NULL == (obj = (H5VL_object_t *)H5I_object(src_loc_id))) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "invalid location identifier") + + /* Create the link through the VOL */ + if((ret_value = H5VL_link_move(obj->vol_obj, loc_params1, NULL, loc_params2, obj->vol_info->vol_cls, + H5P_DEFAULT, H5P_DEFAULT, H5AC_dxpl_id, H5_REQUEST_NULL)) < 0) + HGOTO_ERROR(H5E_SYM, H5E_CANTINIT, FAIL, "unable to create link") done: FUNC_LEAVE_API(ret_value) @@ -524,14 +593,42 @@ herr_t H5Gmove2(hid_t src_loc_id, const char *src_name, hid_t dst_loc_id, const char *dst_name) { + H5VL_object_t *obj1 = NULL; /* object token of src_id */ + H5VL_loc_params_t loc_params1; + H5VL_object_t *obj2 = NULL; /* object token of dst_id */ + H5VL_loc_params_t loc_params2; herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_API(FAIL) H5TRACE4("e", "i*si*s", src_loc_id, src_name, dst_loc_id, dst_name); - /* Call common routine to move the link */ - if(H5G_move(src_loc_id, src_name, dst_loc_id, dst_name) < 0) - HGOTO_ERROR(H5E_LINK, H5E_CANTINIT, FAIL, "couldn't move link") + /* set location paramter for source object */ + loc_params1.type = H5VL_OBJECT_BY_NAME; + 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 paramter 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) { + /* get the location object */ + if(NULL == (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) { + /* get the location object */ + if(NULL == (obj2 = (H5VL_object_t *)H5I_object(dst_loc_id))) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "invalid location identifier") + } + + /* Move the link through the VOL */ + if((ret_value = H5VL_link_move(obj1->vol_obj, loc_params1, obj2->vol_obj, loc_params2, + obj1->vol_info->vol_cls, + H5P_DEFAULT, H5P_DEFAULT, H5AC_dxpl_id, H5_REQUEST_NULL)) < 0) + HGOTO_ERROR(H5E_SYM, H5E_CANTINIT, FAIL, "unable to create link") done: FUNC_LEAVE_API(ret_value) @@ -539,63 +636,6 @@ done: /*------------------------------------------------------------------------- - * Function: H5G_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: Quincey Koziol - * Monday, November 6, 2006 - * - *------------------------------------------------------------------------- - */ -static herr_t -H5G_move(hid_t src_loc_id, const char *src_name, hid_t dst_loc_id, - const char *dst_name) -{ - H5G_loc_t src_loc, *src_loc_p; /* Group info for source location */ - H5G_loc_t dst_loc, *dst_loc_p; /* Group info for destination location */ - herr_t ret_value = SUCCEED; /* Return value */ - - FUNC_ENTER_NOAPI_NOINIT - - /* Check arguments */ - if(src_loc_id == H5L_SAME_LOC && dst_loc_id == H5L_SAME_LOC) - HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "source and destination should not both be H5L_SAME_LOC") - if(src_loc_id != H5L_SAME_LOC && H5G_loc(src_loc_id, &src_loc) < 0) - HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a location") - if(dst_loc_id != H5L_SAME_LOC && H5G_loc(dst_loc_id, &dst_loc) < 0) - HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a location") - if(!src_name || !*src_name) - HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "no current name specified") - if(!dst_name || !*dst_name) - HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "no destination name specified") - - /* Set up src & dst location pointers */ - src_loc_p = &src_loc; - dst_loc_p = &dst_loc; - if(src_loc_id == H5L_SAME_LOC) - src_loc_p = dst_loc_p; - else if(dst_loc_id == H5L_SAME_LOC) - dst_loc_p = src_loc_p; - - /* Move the link */ - if(H5L_move(src_loc_p, src_name, dst_loc_p, dst_name, FALSE, H5P_DEFAULT, - H5P_DEFAULT, H5AC_dxpl_id) < 0) - HGOTO_ERROR(H5E_LINK, H5E_CANTMOVE, FAIL, "unable to move link") - -done: - FUNC_LEAVE_NOAPI(ret_value) -} /* end H5G_move() */ - - -/*------------------------------------------------------------------------- * Function: H5Gunlink * * Purpose: Removes a link. The new API is H5Ldelete/H5Ldelete_by_idx. @@ -605,21 +645,29 @@ done: herr_t H5Gunlink(hid_t loc_id, const char *name) { - H5G_loc_t loc; /* Group's location */ + H5VL_object_t *obj = NULL; /* object token of loc_id */ + H5VL_loc_params_t loc_params; herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_API(FAIL) H5TRACE2("e", "i*s", loc_id, name); - /* 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") - /* Call H5L routine... */ - if(H5L_delete(&loc, name, H5P_DEFAULT, H5AC_dxpl_id) < 0) - HGOTO_ERROR(H5E_LINK, H5E_CANTDELETE, FAIL, "couldn't delete link") + loc_params.type = H5VL_OBJECT_BY_NAME; + loc_params.obj_type = H5I_get_type(loc_id); + loc_params.loc_data.loc_by_name.name = name; + loc_params.loc_data.loc_by_name.lapl_id = H5P_LINK_ACCESS_DEFAULT; + + /* get the location object */ + if(NULL == (obj = (H5VL_object_t *)H5I_object(loc_id))) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "invalid location identifier") + + /* Delete the link through the VOL */ + if(H5VL_link_specific(obj->vol_obj, loc_params, obj->vol_info->vol_cls, H5VL_LINK_DELETE, + H5AC_dxpl_id, H5_REQUEST_NULL) < 0) + HGOTO_ERROR(H5E_SYM, H5E_CANTDELETE, FAIL, "unable to delete link") done: FUNC_LEAVE_API(ret_value) @@ -637,21 +685,30 @@ done: herr_t H5Gget_linkval(hid_t loc_id, const char *name, size_t size, char *buf/*out*/) { - H5G_loc_t loc; /* Group's location */ + H5VL_object_t *obj = NULL; /* object token of loc_id */ + H5VL_loc_params_t loc_params; herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_API(FAIL) H5TRACE4("e", "i*szx", loc_id, name, size, buf); /* Check arguments */ - if(H5G_loc(loc_id, &loc)) - HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a location") if(!name || !*name) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "no name specified") - /* Call the new link routine which provides this capability */ - if(H5L_get_val(&loc, name, buf, size, H5P_DEFAULT, H5AC_ind_dxpl_id) < 0) - HGOTO_ERROR(H5E_SYM, H5E_NOTFOUND, FAIL, "couldn't get link info") + loc_params.type = H5VL_OBJECT_BY_NAME; + loc_params.obj_type = H5I_get_type(loc_id); + loc_params.loc_data.loc_by_name.name = name; + loc_params.loc_data.loc_by_name.lapl_id = H5P_LINK_ACCESS_DEFAULT; + + /* get the location object */ + if(NULL == (obj = (H5VL_object_t *)H5I_object(loc_id))) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "invalid location identifier") + + /* Get the link info through the VOL */ + if((ret_value = H5VL_link_get(obj->vol_obj, loc_params, obj->vol_info->vol_cls, H5VL_LINK_GET_VAL, + H5AC_ind_dxpl_id, H5_REQUEST_NULL, buf, size)) < 0) + HGOTO_ERROR(H5E_INTERNAL, H5E_CANTGET, FAIL, "unable to get link value") done: FUNC_LEAVE_API(ret_value) @@ -775,6 +832,7 @@ 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 */ 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 */ @@ -784,6 +842,8 @@ H5Giterate(hid_t loc_id, const char *name, int *idx_p, H5G_iterate_t op, 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) @@ -800,7 +860,7 @@ H5Giterate(hid_t loc_id, const char *name, int *idx_p, H5G_iterate_t op, lnk_op.op_func.op_old = op; /* Call private function. */ - if((ret_value = H5G_iterate(loc_id, name, H5_INDEX_NAME, H5_ITER_INC, idx, &last_obj, &lnk_op, op_data, H5P_DEFAULT, H5AC_ind_dxpl_id)) < 0) + if((ret_value = H5G_iterate(&loc, name, H5_INDEX_NAME, H5_ITER_INC, idx, &last_obj, &lnk_op, op_data, H5P_DEFAULT, H5AC_ind_dxpl_id)) < 0) HGOTO_ERROR(H5E_SYM, H5E_BADITER, FAIL, "group iteration failed") /* Set the index we stopped at */ @@ -1094,7 +1154,8 @@ H5Gget_objname_by_idx(hid_t loc_id, hsize_t idx, char *name, size_t size) HGOTO_ERROR(H5E_DATASET, H5E_BADTYPE, FAIL, "not a group") /* Call internal function */ - if((ret_value = H5G_obj_get_name_by_idx(loc.oloc, H5_INDEX_NAME, H5_ITER_INC, idx, name, size, H5AC_ind_dxpl_id)) < 0) + if((ret_value = H5G_obj_get_name_by_idx(loc.oloc, H5_INDEX_NAME, H5_ITER_INC, + idx, name, size, H5AC_ind_dxpl_id)) < 0) HGOTO_ERROR(H5E_SYM, H5E_BADTYPE, FAIL, "can't get object name") done: diff --git a/src/H5Gint.c b/src/H5Gint.c index 6f42cc2..bfe0e93 100644 --- a/src/H5Gint.c +++ b/src/H5Gint.c @@ -44,7 +44,8 @@ #include "H5Iprivate.h" /* IDs */ #include "H5Lprivate.h" /* Links */ #include "H5MMprivate.h" /* Memory management */ - +#include "H5Pprivate.h" /* Property lists */ +#include "H5VLprivate.h" /* VOL */ /****************/ /* Local Macros */ @@ -806,11 +807,10 @@ done: *------------------------------------------------------------------------- */ herr_t -H5G_iterate(hid_t loc_id, const char *group_name, +H5G_iterate(H5G_loc_t *loc, const char *group_name, H5_index_t idx_type, H5_iter_order_t order, hsize_t skip, hsize_t *last_lnk, const H5G_link_iterate_t *lnk_op, void *op_data, hid_t lapl_id, hid_t dxpl_id) { - H5G_loc_t loc; /* Location of parent for group */ hid_t gid = -1; /* ID of group to iterate over */ H5G_t *grp = NULL; /* Pointer to group data structure to iterate over */ H5G_iter_appcall_ud_t udata; /* User data for callback */ @@ -827,11 +827,9 @@ H5G_iterate(hid_t loc_id, const char *group_name, * Open the group on which to operate. We also create a group ID which * we can pass to the application-defined operator. */ - if(H5G_loc(loc_id, &loc) < 0) - HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a location") - if(NULL == (grp = H5G__open_name(&loc, group_name, lapl_id, dxpl_id))) + if(NULL == (grp = H5G__open_name(loc, group_name, lapl_id, dxpl_id))) HGOTO_ERROR(H5E_SYM, H5E_CANTOPENOBJ, FAIL, "unable to open group") - if((gid = H5I_register(H5I_GROUP, grp, TRUE)) < 0) + if((gid = H5VL_native_register(H5I_GROUP, grp, TRUE)) < 0) HGOTO_ERROR(H5E_ATOM, H5E_CANTREGISTER, FAIL, "unable to register group") /* Set up user data for callback */ @@ -1072,7 +1070,7 @@ done: *------------------------------------------------------------------------- */ herr_t -H5G_visit(hid_t loc_id, const char *group_name, H5_index_t idx_type, +H5G_visit(H5G_loc_t *loc, const char *group_name, H5_index_t idx_type, H5_iter_order_t order, H5L_iterate_t op, void *op_data, hid_t lapl_id, hid_t dxpl_id) { @@ -1081,7 +1079,6 @@ H5G_visit(hid_t loc_id, const char *group_name, H5_index_t idx_type, htri_t linfo_exists; /* Whether the link info message exists */ hid_t gid = (-1); /* Group ID */ H5G_t *grp = NULL; /* Group opened */ - H5G_loc_t loc; /* Location of group passed in */ H5G_loc_t start_loc; /* Location of starting group */ unsigned rc; /* Reference count of object */ herr_t ret_value; /* Return value */ @@ -1091,16 +1088,12 @@ H5G_visit(hid_t loc_id, const char *group_name, H5_index_t idx_type, FUNC_ENTER_NOAPI(FAIL) - /* Check args */ - if(H5G_loc(loc_id, &loc) < 0) - HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a location") - /* Open the group to begin visiting within */ - if((grp = H5G__open_name(&loc, group_name, lapl_id, dxpl_id)) == NULL) + if((grp = H5G__open_name(loc, group_name, lapl_id, dxpl_id)) == NULL) HGOTO_ERROR(H5E_SYM, H5E_CANTOPENOBJ, FAIL, "unable to open group") /* Register an ID for the starting group */ - if((gid = H5I_register(H5I_GROUP, grp, TRUE)) < 0) + if((gid = H5VL_native_register(H5I_GROUP, grp, TRUE)) < 0) HGOTO_ERROR(H5E_ATOM, H5E_CANTREGISTER, FAIL, "unable to register group") /* Get the location of the starting group */ @@ -1191,3 +1184,97 @@ done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5G_visit() */ + +/*------------------------------------------------------------------------- + * Function: H5G_get_create_plist + * + * Purpose: Private function for H5Gget_create_plist + * + * Return: Success: ID for a copy of the group creation + * property list. The property list ID should be + * released by calling H5Pclose(). + * + * Failure: FAIL + * + * Programmer: Quincey Koziol + * Tuesday, October 25, 2005 + * + *------------------------------------------------------------------------- + */ +hid_t +H5G_get_create_plist(H5G_t *grp) +{ + H5O_linfo_t linfo; /* Link info message */ + htri_t ginfo_exists; + htri_t linfo_exists; + htri_t pline_exists; + H5P_genplist_t *gcpl_plist; + H5P_genplist_t *new_plist; + hid_t new_gcpl_id = FAIL; + hid_t ret_value = FAIL; + + FUNC_ENTER_NOAPI(FAIL) + + /* Copy the default group creation property list */ + if(NULL == (gcpl_plist = (H5P_genplist_t *)H5I_object(H5P_LST_GROUP_CREATE_ID_g))) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "can't get default group creation property list") + if((new_gcpl_id = H5P_copy_plist(gcpl_plist, TRUE)) < 0) + HGOTO_ERROR(H5E_SYM, H5E_CANTGET, FAIL, "unable to copy the creation property list") + if(NULL == (new_plist = (H5P_genplist_t *)H5I_object(new_gcpl_id))) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "can't get property list") + + /* Retrieve any object creation properties */ + if(H5O_get_create_plist(&grp->oloc, H5AC_ind_dxpl_id, new_plist) < 0) + HGOTO_ERROR(H5E_SYM, H5E_CANTGET, FAIL, "can't get object creation info") + + /* Check for the group having a group info message */ + if((ginfo_exists = H5O_msg_exists(&(grp->oloc), H5O_GINFO_ID, H5AC_ind_dxpl_id)) < 0) + HGOTO_ERROR(H5E_SYM, H5E_CANTINIT, FAIL, "unable to read object header") + if(ginfo_exists) { + H5O_ginfo_t ginfo; /* Group info message */ + + /* Read the group info */ + if(NULL == H5O_msg_read(&(grp->oloc), H5O_GINFO_ID, &ginfo, H5AC_ind_dxpl_id)) + HGOTO_ERROR(H5E_SYM, H5E_BADMESG, FAIL, "can't get group info") + + /* Set the group info for the property list */ + if(H5P_set(new_plist, H5G_CRT_GROUP_INFO_NAME, &ginfo) < 0) + HGOTO_ERROR(H5E_PLIST, H5E_CANTSET, FAIL, "can't set group info") + } /* end if */ + + /* Check for the group having a link info message */ + if((linfo_exists = H5G__obj_get_linfo(&(grp->oloc), &linfo, H5AC_ind_dxpl_id)) < 0) + HGOTO_ERROR(H5E_SYM, H5E_CANTINIT, FAIL, "unable to read object header") + if(linfo_exists) { + /* Set the link info for the property list */ + if(H5P_set(new_plist, H5G_CRT_LINK_INFO_NAME, &linfo) < 0) + HGOTO_ERROR(H5E_PLIST, H5E_CANTSET, FAIL, "can't set link info") + } /* end if */ + + /* Check for the group having a pipeline message */ + if((pline_exists = H5O_msg_exists(&(grp->oloc), H5O_PLINE_ID, H5AC_ind_dxpl_id)) < 0) + HGOTO_ERROR(H5E_SYM, H5E_CANTGET, FAIL, "unable to read object header") + if(pline_exists) { + H5O_pline_t pline; /* Pipeline message */ + + /* Read the pipeline */ + if(NULL == H5O_msg_read(&(grp->oloc), H5O_PLINE_ID, &pline, H5AC_ind_dxpl_id)) + HGOTO_ERROR(H5E_SYM, H5E_BADMESG, FAIL, "can't get link pipeline") + + /* Set the pipeline for the property list */ + if(H5P_set(new_plist, H5O_CRT_PIPELINE_NAME, &pline) < 0) + HGOTO_ERROR(H5E_PLIST, H5E_CANTSET, FAIL, "can't set link pipeline") + } /* end if */ + + /* Set the return value */ + ret_value = new_gcpl_id; + +done: + if(ret_value < 0) { + if(new_gcpl_id > 0) + if(H5I_dec_app_ref(new_gcpl_id) < 0) + HDONE_ERROR(H5E_SYM, H5E_CANTDEC, FAIL, "can't free") + } /* end if */ + + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5G_get_create_plist() */ diff --git a/src/H5Gloc.c b/src/H5Gloc.c index 9f0095a..3786967 100644 --- a/src/H5Gloc.c +++ b/src/H5Gloc.c @@ -41,7 +41,7 @@ #include "H5Gpkg.h" /* Groups */ #include "H5Iprivate.h" /* IDs */ #include "H5Lprivate.h" /* Links */ - +#include "H5VLprivate.h" /* Virtual Object Layer */ /****************/ /* Local Macros */ @@ -143,115 +143,109 @@ static herr_t H5G_loc_get_comment_cb(H5G_loc_t *grp_loc, const char *name, -/*------------------------------------------------------------------------- - * Function: H5G_loc +/*--------------------------------------------------------------------------- + * Function: H5G_loc_real * - * Purpose: Given an object ID return a location for the object. + * Purpose: utility routine to get object location * - * Return: Success: Group pointer. - * Failure: NULL + * Returns: Non-negative on success or negative on failure * - * Programmer: Quincey Koziol - * Tuesday, September 13, 2005 + * Programmer: Mohamad Chaarawi + * June, 2012 * - *------------------------------------------------------------------------- + *--------------------------------------------------------------------------- */ herr_t -H5G_loc(hid_t loc_id, H5G_loc_t *loc) +H5G_loc_real(void *obj, H5I_type_t type, H5G_loc_t *loc) { - herr_t ret_value = SUCCEED; /* Return value */ + herr_t ret_value = SUCCEED; - FUNC_ENTER_NOAPI(FAIL) + FUNC_ENTER_NOAPI_NOINIT - switch(H5I_get_type(loc_id)) { + switch(type) { case H5I_FILE: - { - H5F_t *f; - - /* Get the file struct */ - if(NULL == (f = (H5F_t *)H5I_object(loc_id))) - HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "invalid file ID") - - /* Construct a group location for root group of the file */ - if(H5G_root_loc(f, loc) < 0) - HGOTO_ERROR(H5E_SYM, H5E_BADVALUE, FAIL, "unable to create location for file") - } /* end case */ + /* Construct a group location for root group of the file */ + if(H5G_root_loc((H5F_t *)obj, loc) < 0) + HGOTO_ERROR(H5E_SYM, H5E_BADVALUE, FAIL, "unable to create location for file") break; - - case H5I_GENPROP_CLS: - case H5I_GENPROP_LST: - HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "unable to get group location of property list") - - case H5I_ERROR_CLASS: - case H5I_ERROR_MSG: - case H5I_ERROR_STACK: - HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "unable to get group location of error class, message or stack") - case H5I_GROUP: - { - H5G_t *group; - - if(NULL == (group = (H5G_t *)H5I_object(loc_id))) - HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "invalid group ID") - if(NULL == (loc->oloc = H5G_oloc(group))) - HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "unable to get object location of group") - if(NULL == (loc->path = H5G_nameof(group))) - HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "unable to get path of group") - } /* end case */ + if(NULL == (loc->oloc = H5G_oloc((H5G_t *)obj))) + HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "unable to get object location of group") + if(NULL == (loc->path = H5G_nameof((H5G_t *)obj))) + HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "unable to get path of group") break; - case H5I_DATATYPE: { - H5T_t *dt; + H5T_t *dt = NULL; - if(NULL == (dt = (H5T_t *)H5I_object(loc_id))) - HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "invalid type ID") + /* Get the actual datatype object if the VOL object is set */ + dt = (H5T_t *)H5T_get_actual_type((H5T_t *)obj); + if(NULL == (loc->oloc = H5T_oloc(dt))) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "unable to get object location of datatype") if(NULL == (loc->path = H5T_nameof(dt))) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "unable to get path of datatype") - } /* end case */ - break; - - case H5I_DATASPACE: - HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "unable to get group location of dataspace") - + break; + } case H5I_DATASET: - { - H5D_t *dset; - - if(NULL == (dset = (H5D_t *)H5I_object(loc_id))) - HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "invalid data ID") - if(NULL == (loc->oloc = H5D_oloc(dset))) - HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "unable to get object location of dataset") - if(NULL == (loc->path = H5D_nameof(dset))) - HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "unable to get path of dataset") - } /* end case */ + if(NULL == (loc->oloc = H5D_oloc((H5D_t *)obj))) + HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "unable to get object location of dataset") + if(NULL == (loc->path = H5D_nameof((H5D_t *)obj))) + HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "unable to get path of dataset") break; - case H5I_ATTR: - { - H5A_t *attr; - - if(NULL == (attr = (H5A_t *)H5I_object(loc_id))) - HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "invalid attribute ID") - if(NULL == (loc->oloc = H5A_oloc(attr))) - HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "unable to get object location of attribute") - if(NULL == (loc->path = H5A_nameof(attr))) - HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "unable to get path of attribute") - } /* end case */ + if(NULL == (loc->oloc = H5A_oloc((H5A_t *)obj))) + HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "unable to get object location of attribute") + if(NULL == (loc->path = H5A_nameof((H5A_t *)obj))) + HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "unable to get path of attribute") break; - - case H5I_REFERENCE: - HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "unable to get group location of reference") - 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_BADVALUE, FAIL, "invalid object ID") + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a file or file object") } /* end switch */ +done: + FUNC_LEAVE_NOAPI(ret_value) +} /* H5G_loc_real */ + + +/*------------------------------------------------------------------------- + * Function: H5G_loc + * + * Purpose: Given an object ID return a location for the object. + * + * Return: Success: Group pointer. + * Failure: NULL + * + * Programmer: Quincey Koziol + * Tuesday, September 13, 2005 + * + *------------------------------------------------------------------------- + */ +herr_t +H5G_loc(hid_t loc_id, H5G_loc_t *loc) +{ + void *obj = NULL; + herr_t ret_value = SUCCEED; /* Return value */ + + FUNC_ENTER_NOAPI(FAIL) + + /* get the object */ + if(NULL == (obj = H5VL_object(loc_id))) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "invalid identifier") + + if(H5G_loc_real(obj, H5I_get_type(loc_id), loc) < 0) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a file or file object") done: FUNC_LEAVE_NOAPI(ret_value) diff --git a/src/H5Gname.c b/src/H5Gname.c index bbeddb6..6f2c8ba 100644 --- a/src/H5Gname.c +++ b/src/H5Gname.c @@ -825,11 +825,11 @@ H5G_name_replace_cb(void *obj_ptr, hid_t obj_id, void *key) case H5I_DATATYPE: /* Avoid non-named datatypes */ - if(!H5T_is_named((H5T_t *)obj_ptr)) + if(!H5T_is_named((H5T_t*)obj_ptr)) HGOTO_DONE(SUCCEED) /* Do not exit search over IDs */ - oloc = H5T_oloc((H5T_t *)obj_ptr); - obj_path = H5T_nameof((H5T_t *)obj_ptr); + oloc = H5T_oloc((H5T_t*)obj_ptr); + obj_path = H5T_nameof((H5T_t*)obj_ptr); break; case H5I_UNINIT: @@ -839,6 +839,7 @@ H5G_name_replace_cb(void *obj_ptr, hid_t obj_id, void *key) case H5I_ATTR: case H5I_REFERENCE: case H5I_VFL: + case H5I_VOL: case H5I_GENPROP_CLS: case H5I_GENPROP_LST: case H5I_ERROR_CLASS: @@ -1317,7 +1318,7 @@ H5G_get_name_by_addr(hid_t file, hid_t lapl_id, hid_t dxpl_id, const H5O_loc_t * udata.path = NULL; /* Visit all the links in the file */ - if((status = H5G_visit(file, "/", H5_INDEX_NAME, H5_ITER_NATIVE, H5G_get_name_by_addr_cb, &udata, lapl_id, dxpl_id)) < 0) + if((status = H5G_visit(&root_loc, "/", H5_INDEX_NAME, H5_ITER_NATIVE, H5G_get_name_by_addr_cb, &udata, lapl_id, dxpl_id)) < 0) HGOTO_ERROR(H5E_SYM, H5E_BADITER, FAIL, "group traversal failed while looking for object name") else if(status > 0) found_obj = TRUE; diff --git a/src/H5Goh.c b/src/H5Goh.c index c6115db..36b2096 100644 --- a/src/H5Goh.c +++ b/src/H5Goh.c @@ -307,7 +307,7 @@ H5O_group_get_oloc(hid_t obj_id) FUNC_ENTER_NOAPI_NOINIT /* Get the group */ - if(NULL == (grp = (H5G_t *)H5I_object(obj_id))) + if(NULL == (grp = (H5G_t *)H5VL_object(obj_id))) HGOTO_ERROR(H5E_OHDR, H5E_BADATOM, NULL, "couldn't get object from ID") /* Get the group's object header location */ diff --git a/src/H5Gprivate.h b/src/H5Gprivate.h index 50f8bda..1fa92d8 100644 --- a/src/H5Gprivate.h +++ b/src/H5Gprivate.h @@ -217,10 +217,10 @@ H5_DLL char *H5G_normalize(const char *name); H5_DLL herr_t H5G_traverse(const H5G_loc_t *loc, const char *name, unsigned target, H5G_traverse_t op, void *op_data, hid_t lapl_id, hid_t dxpl_id); -H5_DLL herr_t H5G_iterate(hid_t loc_id, const char *group_name, +H5_DLL herr_t H5G_iterate(H5G_loc_t *loc, const char *group_name, H5_index_t idx_type, H5_iter_order_t order, hsize_t skip, hsize_t *last_lnk, const H5G_link_iterate_t *lnk_op, void *op_data, hid_t lapl_id, hid_t dxpl_id); -H5_DLL herr_t H5G_visit(hid_t loc_id, const char *group_name, +H5_DLL herr_t H5G_visit(H5G_loc_t *loc, const char *group_name, H5_index_t idx_type, H5_iter_order_t order, H5L_iterate_t op, void *op_data, hid_t lapl_id, hid_t dxpl_id); @@ -277,6 +277,7 @@ H5_DLL H5RS_str_t *H5G_build_fullpath_refstr_str(H5RS_str_t *path_r, const char /* * These functions operate on group "locations" */ +H5_DLL herr_t H5G_loc_real(void *obj, H5I_type_t type, H5G_loc_t *loc); H5_DLL herr_t H5G_loc(hid_t loc_id, H5G_loc_t *loc); H5_DLL herr_t H5G_loc_find(const H5G_loc_t *loc, const char *name, H5G_loc_t *obj_loc/*out*/, hid_t lapl_id, hid_t dxpl_id); diff --git a/src/H5Gtest.c b/src/H5Gtest.c index 2b5d32a..da9884a 100644 --- a/src/H5Gtest.c +++ b/src/H5Gtest.c @@ -36,6 +36,7 @@ #include "H5Gpkg.h" /* Groups */ #include "H5HLprivate.h" /* Local Heaps */ #include "H5Iprivate.h" /* IDs */ +#include "H5VLprivate.h" /* Virtual Object Layer */ /****************/ /* Local Macros */ @@ -102,7 +103,7 @@ H5G__is_empty_test(hid_t gid) FUNC_ENTER_PACKAGE /* Get group structure */ - if(NULL == (grp = (H5G_t *)H5I_object_verify(gid, H5I_GROUP))) + if(NULL == (grp = (H5G_t *)H5VL_object_verify(gid, H5I_GROUP))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a group") /* "New format" checks */ @@ -213,7 +214,7 @@ H5G__has_links_test(hid_t gid, unsigned *nmsgs) FUNC_ENTER_PACKAGE /* Get group structure */ - if(NULL == (grp = (H5G_t *)H5I_object_verify(gid, H5I_GROUP))) + if(NULL == (grp = (H5G_t *)H5VL_object_verify(gid, H5I_GROUP))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a group") /* Check if the group has any link messages */ @@ -271,7 +272,7 @@ H5G__has_stab_test(hid_t gid) FUNC_ENTER_PACKAGE /* Get group structure */ - if(NULL == (grp = (H5G_t *)H5I_object_verify(gid, H5I_GROUP))) + if(NULL == (grp = (H5G_t *)H5VL_object_verify(gid, H5I_GROUP))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a group") /* Check if the group has a symbol table message */ @@ -321,7 +322,7 @@ H5G__is_new_dense_test(hid_t gid) FUNC_ENTER_PACKAGE /* Get group structure */ - if(NULL == (grp = (H5G_t *)H5I_object_verify(gid, H5I_GROUP))) + if(NULL == (grp = (H5G_t *)H5VL_object_verify(gid, H5I_GROUP))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a group") /* Check if the group has a symbol table message */ @@ -391,7 +392,7 @@ H5G__new_dense_info_test(hid_t gid, hsize_t *name_count, hsize_t *corder_count) FUNC_ENTER_PACKAGE /* Get group structure */ - if(NULL == (grp = (H5G_t *)H5I_object_verify(gid, H5I_GROUP))) + if(NULL == (grp = (H5G_t *)H5VL_object_verify(gid, H5I_GROUP))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a group") /* Set metadata tag in dxpl_id */ @@ -471,7 +472,7 @@ H5G__lheap_size_test(hid_t gid, size_t *lheap_size) FUNC_ENTER_PACKAGE /* Get group structure */ - if(NULL == (grp = (H5G_t *)H5I_object_verify(gid, H5I_GROUP))) + if(NULL == (grp = (H5G_t *)H5VL_object_verify(gid, H5I_GROUP))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a group") /* Make certain the group has a symbol table message */ @@ -523,7 +524,7 @@ H5G__user_path_test(hid_t obj_id, char *user_path, size_t *user_path_len, unsign HDassert(obj_hidden); /* Get pointer to object for ID */ - if(NULL == (obj_ptr = H5I_object(obj_id))) + if(NULL == (obj_ptr = H5VL_object(obj_id))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "can't get object for ID") /* Get the symbol table entry */ @@ -551,6 +552,7 @@ H5G__user_path_test(hid_t obj_id, char *user_path, size_t *user_path_len, unsign case H5I_ATTR: case H5I_REFERENCE: case H5I_VFL: + case H5I_VOL: case H5I_GENPROP_CLS: case H5I_GENPROP_LST: case H5I_ERROR_CLASS: @@ -771,7 +773,7 @@ H5G__verify_cached_stabs_test(hid_t gid) HDassert(gid >= 0); /* Check args */ - if(NULL == (grp = (H5G_t *)H5I_object_verify(gid, H5I_GROUP))) + if(NULL == (grp = (H5G_t *)H5VL_object_verify(gid, H5I_GROUP))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a group") /* Set up metadata tagging */ diff --git a/src/H5Gtraverse.c b/src/H5Gtraverse.c index 72e3201..dbc52ba 100644 --- a/src/H5Gtraverse.c +++ b/src/H5Gtraverse.c @@ -45,7 +45,7 @@ #include "H5MMprivate.h" /* Memory management */ #include "H5Ppublic.h" /* Property Lists */ #include "H5WBprivate.h" /* Wrapped Buffers */ - +#include "H5VLprivate.h" /* VOL plugins */ /****************/ /* Local Macros */ @@ -207,7 +207,8 @@ 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, dxpl_id))) HGOTO_ERROR(H5E_SYM, H5E_CANTOPENOBJ, FAIL, "unable to open group") - if((cur_grp = H5I_register(H5I_GROUP, grp, FALSE)) < 0) + + if((cur_grp = H5VL_native_register(H5I_GROUP, grp, FALSE)) < 0) HGOTO_ERROR(H5E_SYM, H5E_CANTREGISTER, FAIL, "unable to register group") /* Check for generic default property list and use link access default if so */ @@ -49,6 +49,8 @@ #include "H5MMprivate.h" /* Memory management */ #include "H5Oprivate.h" /* Object headers */ #include "H5SLprivate.h" /* Skip Lists */ +#include "H5Tprivate.h" /* Datatypes */ +#include "H5VLprivate.h" /* Virtual Object Layer */ /* Define this to compile in support for dumping ID information */ /* #define H5I_DEBUG_OUTPUT */ @@ -79,7 +81,7 @@ typedef struct H5I_id_info_t { /* ID type structure used */ typedef struct { - const H5I_class_t *cls; /* Pointer to ID class */ + H5I_class_t *cls; /* Pointer to ID class */ unsigned init_count; /* # of times this type has been initialized*/ uint64_t id_count; /* Current number of IDs held */ uint64_t nextid; /* ID to use for the next atom */ @@ -92,11 +94,24 @@ typedef struct { void *ret_obj; /* Object to return */ } H5I_search_ud_t; +typedef struct { + H5I_iterate_func_t op; /* Application's callback routine */ + void *op_data; /* Application's user data */ +} H5I_iterate_pub_ud_t; + +/* User data for iterator callback for retrieveing an ID correponding to an object pointer */ +typedef struct { + const void *object; /* object pointer to search for */ + H5I_type_t obj_type; /* type of object we are searching for */ + hid_t ret_id; /* ID returned */ +} H5I_get_id_ud_t; + /* User data for iterator callback for ID iteration */ typedef struct { H5I_search_func_t user_func; /* 'User' function to invoke */ void *user_udata; /* User data to pass to 'user' function */ hbool_t app_ref; /* Whether this is an appl. ref. call */ + H5I_type_t obj_type; /* type of object we are iterating over */ } H5I_iterate_ud_t; /*-------------------- Locally scoped variables -----------------------------*/ @@ -121,6 +136,8 @@ H5FL_DEFINE_STATIC(H5I_id_type_t); /* Declare a free list to manage the H5I_class_t struct */ H5FL_DEFINE_STATIC(H5I_class_t); +H5FL_EXTERN(H5VL_object_t); + /*--------------------- Local function prototypes ---------------------------*/ static int H5I__destroy_type(H5I_type_t type); static void *H5I__remove_verify(hid_t id, H5I_type_t id_type); @@ -128,6 +145,7 @@ static void *H5I__remove_common(H5I_id_type_t *type_ptr, hid_t id); static int H5I__inc_type_ref(H5I_type_t type); static int H5I__get_type_ref(H5I_type_t type); static H5I_id_info_t *H5I__find_id(hid_t id); +static int H5I__iterate_pub_cb(void *obj, hid_t id, void *udata); #ifdef H5I_DEBUG_OUTPUT static herr_t H5I__debug(H5I_type_t type); #endif /* H5I_DEBUG_OUTPUT */ @@ -1895,14 +1913,89 @@ done: /*------------------------------------------------------------------------- + * Function: H5I__iterate_pub_cb + * + * Purpose: Callback routine for H5Iiterate, when it calls + * H5I_iterate. Calls "user" callback search function, and + * then sets return value, based on the result of that + * callback. + * + * Return: The value returned by the user callback + * + * Programmer: Neil Fortner + * Friday, October 11, 2013 + * + *------------------------------------------------------------------------- + */ +static herr_t +H5I__iterate_pub_cb(void UNUSED *obj, hid_t id, void *_udata) +{ + H5I_iterate_pub_ud_t *udata = (H5I_iterate_pub_ud_t *)_udata; /* User data for callback */ + herr_t ret_value; /* Callback return value */ + + FUNC_ENTER_NOAPI_NOINIT_NOERR + + ret_value = (*udata->op)(id, udata->op_data); + + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5I__iterate_pub_cb() */ + + +/*------------------------------------------------------------------------- + * Function: H5Iiterate + * + * Purpose: Call the callback funciton op for each member of the id + * type type. op takes as parameters the id and a + * passthrough of op_data, and returns an herr_t. A positive + * return from op will cause the iteration to stop and + * H5Iiterate will return the value returned by op. A + * negative return from op will cause the iteration to stop + * and H5Iiterate will return failure. A zero return from op + * will allow iteration to continue, as long as there are + * other ids remaining in type. + * + * Limitation: Currently there is no way to start searching from where a + * previous search left off. + * + * Return: The last value returned by op + * + * Programmer: Neil Fortner + * Friday, October 11, 2013 + * + *------------------------------------------------------------------------- + */ +herr_t +H5Iiterate(H5I_type_t type, H5I_iterate_func_t op, void *op_data) +{ + H5I_iterate_pub_ud_t int_udata; /* Internal user data */ + herr_t ret_value; /* Return value */ + + FUNC_ENTER_API(FAIL) + H5TRACE3("e", "Itx*x", type, op, op_data); + + /* Set up udata struct */ + int_udata.op = op; + int_udata.op_data = op_data; + + /* Note that H5I_iterate returns an error code. We ignore it + * here, as we can't do anything with it without revising the API. + */ + if((ret_value = H5I_iterate(type, H5I__iterate_pub_cb, &int_udata, TRUE)) < 0) + HGOTO_ERROR(H5E_ATOM, H5E_BADITER, FAIL, "can't iterate over ids") + +done: + FUNC_LEAVE_API(ret_value) +} /* end H5Iiterate() */ + + +/*------------------------------------------------------------------------- * Function: H5I__iterate_cb * * Purpose: Callback routine for H5I_iterate, invokes "user" callback * function, and then sets return value, based on the result of * that callback. * - * Return: Success: Non-negative on success - * Failure: Negative + * Return: Value returned by callback * * Programmer: Quincey Koziol * Thursday, October 3, 2013 @@ -1920,16 +2013,24 @@ H5I__iterate_cb(void *_item, void UNUSED *_key, void *_udata) /* Don't make callback if app_ref is set and the appl. ref count is 0 */ if((!udata->app_ref) || (item->app_count > 0)) { - herr_t cb_ret_val; + H5I_type_t type = udata->obj_type; + const void *obj_ptr = NULL; + + if(H5I_FILE == type || H5I_GROUP == type || H5I_DATASET == type || H5I_ATTR == type) { + const H5VL_object_t *obj = (const H5VL_object_t *)item->obj_ptr; + obj_ptr = obj->vol_obj; + } + 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; /* (Casting away const OK) */ - cb_ret_val = (*udata->user_func)((void *)item->obj_ptr, item->id, udata->user_udata); - if(cb_ret_val > 0) - 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 */ + ret_value = (*udata->user_func)((void *)obj_ptr, item->id, udata->user_udata); + } FUNC_LEAVE_NOAPI(ret_value) } /* end H5I__iterate_cb() */ @@ -1942,21 +2043,18 @@ H5I__iterate_cb(void *_item, void UNUSED *_key, void *_udata) * Stop if FUNC returns a non zero value (i.e. anything * other than H5_ITER_CONT). * - * If FUNC returns a positive value (i.e. H5_ITER_STOP), - * return SUCCEED. - * - * If FUNC returns a negative value (i.e. H5_ITER_ERROR), - * return FAIL. + * Returns the last value returned by the callback, or FAIL + * if an internal error occurred. * * The FUNC should take a pointer to the object and the * udata as arguments and return non-zero to terminate - * siteration, and zero to continue. + * iteration, and zero to continue. * * Limitation: Currently there is no way to start the iteration from * where a previous iteration left off. * - * Return: Success: SUCCEED - * Failure: FAIL + * Return: Success: Last value returned by callback + * Failure: FAIL or last value returned by callback * * Programmer: John Mainzer * Monday, December 6, 2011 @@ -1979,15 +2077,15 @@ H5I_iterate(H5I_type_t type, H5I_search_func_t func, void *udata, hbool_t app_re /* Only iterate through ID list if it is initialized and there are IDs in type */ if(type_ptr && type_ptr->init_count > 0 && type_ptr->id_count > 0) { H5I_iterate_ud_t iter_udata; /* User data for iteration callback */ - herr_t iter_status; /* Iteration status */ /* Set up iterator user data */ iter_udata.user_func = func; iter_udata.user_udata = udata; iter_udata.app_ref = app_ref; + iter_udata.obj_type = type; /* Iterate over IDs */ - if((iter_status = H5SL_iterate(type_ptr->ids, H5I__iterate_cb, &iter_udata)) < 0) + if((ret_value = H5SL_iterate(type_ptr->ids, H5I__iterate_cb, &iter_udata)) < 0) HGOTO_ERROR(H5E_ATOM, H5E_BADITER, FAIL, "iteration failed") } /* end if */ @@ -2086,8 +2184,10 @@ done: /*------------------------------------------------------------------------- * Function: H5Iget_file_id * - * Purpose: The public version of H5I_get_file_id(), obtains the file - * ID given an object ID. User has to close this ID. + * Purpose: Obtains the file ID given an object ID. User has to close + * this ID. This routine goes through the VOL to get the file + * struct and checks if an ID for that struct exists (increments + * ref count & returns this ID) or creates a new ID for it. * * Return: Success: file ID * @@ -2096,19 +2196,53 @@ done: * Programmer: Raymond Lu * Oct 27, 2003 * + * Modified: Mohamad Chaarawi + * September, 2012 + * Update for Virtual Object Layer *------------------------------------------------------------------------- */ hid_t H5Iget_file_id(hid_t obj_id) { - hid_t ret_value; /* Return value */ + H5VL_object_t *obj; + void *file = NULL; + H5I_type_t type; /* ID type */ + hid_t ret_value; /* Return value */ FUNC_ENTER_API(FAIL) H5TRACE1("i", "i", obj_id); - if((ret_value = H5I_get_file_id(obj_id, TRUE)) < 0) - HGOTO_ERROR(H5E_ATOM, H5E_CANTGET, FAIL, "can't retrieve file ID") + /* Get object type */ + type = H5I_TYPE(obj_id); + if(H5I_FILE == type || H5I_DATATYPE == type || H5I_GROUP == type || + H5I_DATASET == type || H5I_ATTR == type) { + /* get the object pointer*/ + if(NULL == (obj = H5VL_get_object(obj_id))) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "invalid identifier") + + /* Get the file through the VOL */ + if(H5VL_file_get(obj->vol_obj, obj->vol_info->vol_cls, H5VL_OBJECT_GET_FILE, + H5AC_dxpl_id, H5_REQUEST_NULL, type, &file) < 0) + HGOTO_ERROR(H5E_INTERNAL, H5E_CANTINIT, FAIL, "unable to get file") + + if (NULL == file) + HGOTO_ERROR(H5E_FILE, H5E_CANTINIT, FAIL, "unable to reopen file") + + /* Check if the ID already exists and procceed accordingly */ + if (FAIL == (ret_value = H5I_get_id(file, H5I_FILE))) { + /* Get an atom for the file */ + if((ret_value = H5VL_register_id(H5I_FILE, file, obj->vol_info, TRUE)) < 0) + HGOTO_ERROR(H5E_ATOM, H5E_CANTREGISTER, FAIL, "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, FAIL, "incrementing file ID failed") + } + } + else + HGOTO_ERROR(H5E_ARGS, H5E_BADRANGE, FAIL, "invalid object ID") done: FUNC_LEAVE_API(ret_value) } /* end H5Iget_file_id() */ @@ -2117,7 +2251,7 @@ done: /*------------------------------------------------------------------------- * Function: H5I_get_file_id * - * Purpose: The private version of H5Iget_file_id(), obtains the file + * Purpose: The native version of H5Iget_file_id(), obtains the file * ID given an object ID. * * Return: Success: file ID @@ -2126,24 +2260,27 @@ done: * Programmer: Raymond Lu * Oct 27, 2003 * + * Modified: Mohamad Chaarawi + * September, 2012 + * Update for Virtual Object Layer + * *------------------------------------------------------------------------- */ hid_t H5I_get_file_id(hid_t obj_id, hbool_t app_ref) { H5I_type_t type; /* ID type */ - hid_t ret_value; /* Return value */ + hid_t ret_value = FAIL; /* Return value */ FUNC_ENTER_NOAPI_NOINIT /* Get object type */ type = H5I_TYPE(obj_id); + + /* object is a file, just increment reference count on ID */ if(type == H5I_FILE) { - /* Increment reference count on file ID */ if(H5I_inc_ref(obj_id, app_ref) < 0) HGOTO_ERROR(H5E_ATOM, H5E_CANTSET, FAIL, "incrementing file ID failed") - - /* Set return value */ ret_value = obj_id; } /* end if */ else if(type == H5I_DATATYPE || type == H5I_GROUP || type == H5I_DATASET || type == H5I_ATTR) { @@ -2159,11 +2296,105 @@ H5I_get_file_id(hid_t obj_id, hbool_t app_ref) } /* end if */ else HGOTO_ERROR(H5E_ARGS, H5E_BADRANGE, FAIL, "invalid object ID") - done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5I_get_file_id() */ + +/*------------------------------------------------------------------------- + * Function: H5I__get_id_cb + * + * Purpose: Callback for searching for an ID with a specific pointer + * + * Return: Success: Non-negative + * Failure: Negative + * + * Programmer: Mohamad Chaarawi + * October 16, 2013 + * + *------------------------------------------------------------------------- + */ +static herr_t +H5I__get_id_cb(void *_item, void UNUSED *_key, void *_udata) +{ + H5I_id_info_t *item = (H5I_id_info_t *)_item; /* Pointer to the ID node */ + H5I_get_id_ud_t *udata = (H5I_get_id_ud_t *)_udata; /* Pointer to user data */ + H5I_type_t type = udata->obj_type; + const void *obj_ptr = NULL; + int ret_value = H5_ITER_CONT; /* Return value */ + + FUNC_ENTER_STATIC_NOERR + + /* Sanity check */ + HDassert(item); + HDassert(udata); + + if(H5I_FILE == type || H5I_GROUP == type || H5I_DATASET == type || H5I_ATTR == type) { + const H5VL_object_t *obj = (const H5VL_object_t *)item->obj_ptr; + obj_ptr = obj->vol_obj; + } + 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; + + if (obj_ptr == udata->object) { + udata->ret_id = item->id; + ret_value = H5_ITER_STOP; + } + + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5I__get_id_cb() */ + + +/*------------------------------------------------------------------------- + * Function: H5I_get_id + * + * Purpose: return ID of object + * + * Return: Success: id of object + * Failure: FAIL + * + * Programmer: Mohamad Chaarawi + * June 2012 + * + *------------------------------------------------------------------------- + */ +hid_t +H5I_get_id(const void *object, H5I_type_t type) +{ + hid_t ret_value = FAIL; /* Return value */ + H5I_id_type_t *type_ptr; /*ptr to the type */ + + FUNC_ENTER_NOAPI(FAIL) + + type_ptr = H5I_id_type_list_g[type]; + if (!type_ptr || type_ptr->init_count <= 0) + HGOTO_ERROR(H5E_ATOM, H5E_BADGROUP, FAIL, "invalid type") + + /* Only iterate through ID list if it is initialized and there are IDs in type */ + if(type_ptr && type_ptr->init_count > 0 && type_ptr->id_count > 0) { + H5I_get_id_ud_t udata; /* User data */ + herr_t iter_status; /* Iteration status */ + + /* Set up iterator user data */ + udata.object = object; + udata.obj_type = type; + udata.ret_id = FAIL; + + /* Iterate over IDs */ + if((iter_status = H5SL_iterate(type_ptr->ids, H5I__get_id_cb, &udata)) < 0) + HGOTO_ERROR(H5E_ATOM, H5E_BADITER, FAIL, "iteration failed") + + ret_value = udata.ret_id; + } /* end if */ + +done: + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5I_get_id() */ + #ifdef H5I_DEBUG_OUTPUT /*------------------------------------------------------------------------- diff --git a/src/H5Iprivate.h b/src/H5Iprivate.h index f438581..1bc1f24 100644 --- a/src/H5Iprivate.h +++ b/src/H5Iprivate.h @@ -24,9 +24,11 @@ /* Include package's public header */ #include "H5Ipublic.h" +#include "H5VLpublic.h" /* Private headers needed by this file */ #include "H5private.h" +#include "H5FLprivate.h" /* Free Lists */ /**************************/ /* Library Private Macros */ @@ -82,6 +84,7 @@ H5_DLL int H5I_dec_ref(hid_t id); H5_DLL int H5I_dec_app_ref(hid_t id); H5_DLL int H5I_dec_app_ref_always_close(hid_t id); H5_DLL herr_t H5I_dec_type_ref(H5I_type_t type); +H5_DLL hid_t H5I_get_id(const void *object, H5I_type_t type); #endif /* _H5Iprivate_H */ diff --git a/src/H5Ipublic.h b/src/H5Ipublic.h index 3bf3c66..e4f5abc 100644 --- a/src/H5Ipublic.h +++ b/src/H5Ipublic.h @@ -44,6 +44,7 @@ typedef enum H5I_type_t { H5I_ATTR, /*type ID for Attribute objects */ H5I_REFERENCE, /*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 */ H5I_GENPROP_LST, /*type ID for generic property lists */ H5I_ERROR_CLASS, /*type ID for error classes */ @@ -67,10 +68,14 @@ typedef int64_t hid_t; * (failure) then the object will remain in the ID type. */ typedef herr_t (*H5I_free_t)(void*); +typedef herr_t (*H5I_free2_t)(void*,void*); /* Type of the function to compare objects & keys */ typedef int (*H5I_search_func_t)(void *obj, hid_t id, void *key); +/* Type of the H5Iiterate callback function */ +typedef herr_t (*H5I_iterate_func_t)(hid_t id, void *udata); + #ifdef __cplusplus extern "C" { #endif @@ -93,6 +98,7 @@ H5_DLL int H5Iinc_type_ref(H5I_type_t type); H5_DLL int H5Idec_type_ref(H5I_type_t type); H5_DLL int H5Iget_type_ref(H5I_type_t type); H5_DLL void *H5Isearch(H5I_type_t type, H5I_search_func_t func, void *key); +H5_DLL herr_t H5Iiterate(H5I_type_t type, H5I_iterate_func_t op, void *op_data); H5_DLL herr_t H5Inmembers(H5I_type_t type, hsize_t *num_members); H5_DLL htri_t H5Itype_exists(H5I_type_t type); H5_DLL htri_t H5Iis_valid(hid_t id); @@ -36,6 +36,7 @@ #include "H5MMprivate.h" /* Memory management */ #include "H5Oprivate.h" /* File objects */ #include "H5Pprivate.h" /* Property lists */ +#include "H5VLprivate.h" /* Virtual Object Layer */ /****************/ /* Local Macros */ @@ -54,18 +55,6 @@ typedef struct { hid_t dxpl_id; /* DXPL to use in callback */ } H5L_trav_gi_t; -/* User data for path traversal routine for getting link info by index */ -typedef struct { - /* In */ - H5_index_t idx_type; /* Index to use */ - H5_iter_order_t order; /* Order to iterate in index */ - hsize_t n; /* Offset of link within index */ - hid_t dxpl_id; /* DXPL to use in callback */ - - /* Out */ - H5L_info_t *linfo; /* Buffer to return to user */ -} H5L_trav_gibi_t; - /* User data for path traversal callback to creating a link */ typedef struct { H5F_t *file; /* Pointer to the file */ @@ -101,47 +90,11 @@ typedef struct { void *buf; /* User buffer */ } H5L_trav_gv_t; -/* User data for path traversal routine for getting link value by index */ -typedef struct { - /* In */ - H5_index_t idx_type; /* Index to use */ - H5_iter_order_t order; /* Order to iterate in index */ - hsize_t n; /* Offset of link within index */ - hid_t dxpl_id; /* DXPL to use in callback */ - size_t size; /* Size of user buffer */ - - /* Out */ - void *buf; /* User buffer */ -} H5L_trav_gvbi_t; - /* User data for path traversal routine for removing link */ typedef struct { hid_t dxpl_id; /* DXPL to use in callback */ } H5L_trav_rm_t; -/* User data for path traversal routine for removing link by index */ -typedef struct { - /* In */ - H5_index_t idx_type; /* Index to use */ - H5_iter_order_t order; /* Order to iterate in index */ - hsize_t n; /* Offset of link within index */ - hid_t dxpl_id; /* DXPL to use in callback */ -} H5L_trav_rmbi_t; - -/* User data for path traversal routine for getting name by index */ -typedef struct { - /* In */ - H5_index_t idx_type; /* Index to use */ - H5_iter_order_t order; /* Order to iterate in index */ - hsize_t n; /* Offset of link within index */ - size_t size; /* Size of name buffer */ - hid_t dxpl_id; /* DXPL to use in callback */ - - /* Out */ - char *name; /* Buffer to return name to user */ - ssize_t name_len; /* Length of full name */ -} H5L_trav_gnbi_t; - /********************/ /* Local Prototypes */ /********************/ @@ -175,8 +128,6 @@ static herr_t H5L_move_dest_cb(H5G_loc_t *grp_loc/*in*/, const char *name, static herr_t H5L_exists_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 htri_t H5L_exists(const H5G_loc_t *loc, const char *name, hid_t lapl_id, - hid_t dxpl_id); static herr_t H5L_get_info_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*/); @@ -313,8 +264,10 @@ herr_t H5Lmove(hid_t src_loc_id, const char *src_name, hid_t dst_loc_id, const char *dst_name, hid_t lcpl_id, hid_t lapl_id) { - H5G_loc_t src_loc, *src_loc_p; - H5G_loc_t dst_loc, *dst_loc_p; + H5VL_object_t *obj1 = NULL; /* object token of src_id */ + H5VL_loc_params_t loc_params1; + H5VL_object_t *obj2 = NULL; /* object token of dst_id */ + H5VL_loc_params_t loc_params2; herr_t ret_value=SUCCEED; /* Return value */ FUNC_ENTER_API(FAIL) @@ -324,10 +277,6 @@ H5Lmove(hid_t src_loc_id, const char *src_name, hid_t dst_loc_id, /* Check arguments */ if(src_loc_id == H5L_SAME_LOC && dst_loc_id == H5L_SAME_LOC) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "source and destination should not both be H5L_SAME_LOC") - if(src_loc_id != H5L_SAME_LOC && H5G_loc(src_loc_id, &src_loc) < 0) - HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a location") - if(dst_loc_id != H5L_SAME_LOC && H5G_loc(dst_loc_id, &dst_loc) < 0) - HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a location") if(!src_name || !*src_name) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "no current name specified") if(!dst_name || !*dst_name) @@ -335,18 +284,47 @@ H5Lmove(hid_t src_loc_id, const char *src_name, hid_t dst_loc_id, if(lcpl_id != H5P_DEFAULT && (TRUE != H5P_isa_class(lcpl_id, H5P_LINK_CREATE))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a link creation property list") - /* Set up src & dst location pointers */ - src_loc_p = &src_loc; - dst_loc_p = &dst_loc; - if(src_loc_id == H5L_SAME_LOC) - src_loc_p = dst_loc_p; - else if(dst_loc_id == H5L_SAME_LOC) - dst_loc_p = src_loc_p; + /* Check the link create property list */ + if(H5P_DEFAULT == lcpl_id) + lcpl_id = H5P_LINK_CREATE_DEFAULT; + /* Check the link access property list */ + if(H5P_DEFAULT == lapl_id) + lapl_id = H5P_LINK_ACCESS_DEFAULT; - /* Move the link */ - if(H5L_move(src_loc_p, src_name, dst_loc_p, dst_name, FALSE, lcpl_id, - lapl_id, H5AC_dxpl_id) < 0) - HGOTO_ERROR(H5E_LINK, H5E_CANTMOVE, FAIL, "unable to move link") + /* set location paramter for source object */ + loc_params1.type = H5VL_OBJECT_BY_NAME; + loc_params1.loc_data.loc_by_name.name = src_name; + loc_params1.loc_data.loc_by_name.lapl_id = lapl_id; + loc_params1.obj_type = H5I_get_type(src_loc_id); + /* set location paramter 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 = lapl_id; + loc_params2.obj_type = H5I_get_type(dst_loc_id); + + if(H5L_SAME_LOC != src_loc_id) { + /* get the location object */ + if(NULL == (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) { + /* get the location object */ + if(NULL == (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(obj1 && obj2) { + if (obj1->vol_info->vol_cls->value != obj2->vol_info->vol_cls->value) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "Objects are accessed through different VOL plugins and can't be linked") + } + + /* Move the link through the VOL */ + if(H5VL_link_move((obj1 ? obj1->vol_obj : NULL), loc_params1, + (obj2 ? obj2->vol_obj : NULL), loc_params2, + (obj1 ? obj1->vol_info->vol_cls : obj2->vol_info->vol_cls), + lcpl_id, lapl_id, H5AC_dxpl_id, H5_REQUEST_NULL) < 0) + HGOTO_ERROR(H5E_SYM, H5E_CANTINIT, FAIL, "unable to create link") done: FUNC_LEAVE_API(ret_value) @@ -371,8 +349,10 @@ herr_t H5Lcopy(hid_t src_loc_id, const char *src_name, hid_t dst_loc_id, const char *dst_name, hid_t lcpl_id, hid_t lapl_id) { - H5G_loc_t src_loc, *src_loc_p; - H5G_loc_t dst_loc, *dst_loc_p; + H5VL_object_t *obj1 = NULL; /* object token of src_id */ + H5VL_loc_params_t loc_params1; + H5VL_object_t *obj2 = NULL; /* object token of dst_id */ + H5VL_loc_params_t loc_params2; herr_t ret_value=SUCCEED; /* Return value */ FUNC_ENTER_API(FAIL) @@ -382,10 +362,6 @@ H5Lcopy(hid_t src_loc_id, const char *src_name, hid_t dst_loc_id, /* Check arguments */ if(src_loc_id == H5L_SAME_LOC && dst_loc_id == H5L_SAME_LOC) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "source and destination should not both be H5L_SAME_LOC") - if(src_loc_id != H5L_SAME_LOC && H5G_loc(src_loc_id, &src_loc) < 0) - HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a location") - if(dst_loc_id != H5L_SAME_LOC && H5G_loc(dst_loc_id, &dst_loc) < 0) - HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a location") if(!src_name || !*src_name) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "no current name specified") if(!dst_name || !*dst_name) @@ -393,19 +369,47 @@ H5Lcopy(hid_t src_loc_id, const char *src_name, hid_t dst_loc_id, if(lcpl_id != H5P_DEFAULT && (TRUE != H5P_isa_class(lcpl_id, H5P_LINK_CREATE))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a link creation property list") - /* Set up src & dst location pointers */ - src_loc_p = &src_loc; - dst_loc_p = &dst_loc; - if(src_loc_id == H5L_SAME_LOC) - src_loc_p = dst_loc_p; - else if(dst_loc_id == H5L_SAME_LOC) - dst_loc_p = src_loc_p; - - /* Copy the link */ - if(H5L_move(src_loc_p, src_name, dst_loc_p, dst_name, TRUE, lcpl_id, - lapl_id, H5AC_dxpl_id) < 0) - HGOTO_ERROR(H5E_LINK, H5E_CANTMOVE, FAIL, "unable to move link") + /* Check the link create property list */ + if(H5P_DEFAULT == lcpl_id) + lcpl_id = H5P_LINK_CREATE_DEFAULT; + /* Check the link access property list */ + if(H5P_DEFAULT == lapl_id) + lapl_id = H5P_LINK_ACCESS_DEFAULT; + /* set location paramter for source object */ + loc_params1.type = H5VL_OBJECT_BY_NAME; + loc_params1.loc_data.loc_by_name.name = src_name; + loc_params1.loc_data.loc_by_name.lapl_id = lapl_id; + loc_params1.obj_type = H5I_get_type(src_loc_id); + /* set location paramter 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 = lapl_id; + loc_params2.obj_type = H5I_get_type(dst_loc_id); + + if(H5L_SAME_LOC != src_loc_id) { + /* get the location object */ + if(NULL == (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) { + /* get the location object */ + if(NULL == (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(obj1 && obj2) { + if (obj1->vol_info->vol_cls->value != obj2->vol_info->vol_cls->value) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "Objects are accessed through different VOL plugins and can't be linked") + } + + /* Move the link through the VOL */ + if(H5VL_link_copy((obj1 ? obj1->vol_obj : NULL), loc_params1, + (obj2 ? obj2->vol_obj : NULL), loc_params2, + (obj1 ? obj1->vol_info->vol_cls : obj2->vol_info->vol_cls), + lcpl_id, lapl_id, H5AC_dxpl_id, H5_REQUEST_NULL) < 0) + HGOTO_ERROR(H5E_SYM, H5E_CANTINIT, FAIL, "unable to create link") done: FUNC_LEAVE_API(ret_value) } /* end H5Lcopy() */ @@ -433,15 +437,17 @@ herr_t H5Lcreate_soft(const char *link_target, hid_t link_loc_id, const char *link_name, hid_t lcpl_id, hid_t lapl_id) { - H5G_loc_t link_loc; /* Group location for new link */ + H5VL_object_t *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 */ FUNC_ENTER_API(FAIL) H5TRACE5("e", "*si*sii", link_target, link_loc_id, link_name, lcpl_id, lapl_id); /* Check arguments */ - if(H5G_loc(link_loc_id, &link_loc) < 0) - HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a location") + if(link_loc_id == H5L_SAME_LOC) + HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "link location id should not be H5L_SAME_LOC") if(!link_target || !*link_target) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "no target specified") if(!link_name || !*link_name) @@ -449,9 +455,34 @@ H5Lcreate_soft(const char *link_target, if(lcpl_id != H5P_DEFAULT && (TRUE != H5P_isa_class(lcpl_id, H5P_LINK_CREATE))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a link creation property list") - /* Create the link */ - if(H5L_create_soft(link_target, &link_loc, link_name, lcpl_id, lapl_id, H5AC_dxpl_id) < 0) - HGOTO_ERROR(H5E_LINK, H5E_CANTINIT, FAIL, "unable to create link") + /* Check the group access property list */ + if(H5P_DEFAULT == lcpl_id) + lcpl_id = H5P_LINK_CREATE_DEFAULT; + /* Check the link access property list */ + if(H5P_DEFAULT == lapl_id) + lapl_id = H5P_LINK_ACCESS_DEFAULT; + + loc_params.type = H5VL_OBJECT_BY_NAME; + loc_params.loc_data.loc_by_name.name = link_name; + loc_params.loc_data.loc_by_name.lapl_id = lapl_id; + loc_params.obj_type = H5I_get_type(link_loc_id); + + /* get the location object */ + if(NULL == (obj = (H5VL_object_t *)H5VL_get_object(link_loc_id))) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "invalid location identifier") + + /* 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") + + /* set creation properties */ + if(H5P_set(plist, H5VL_PROP_LINK_TARGET_NAME, &link_target) < 0) + HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, FAIL, "can't get property value for target name") + + /* Create the link through the VOL */ + if(H5VL_link_create(H5VL_LINK_CREATE_SOFT, obj->vol_obj, loc_params, obj->vol_info->vol_cls, + lcpl_id, lapl_id, H5AC_dxpl_id, H5_REQUEST_NULL) < 0) + HGOTO_ERROR(H5E_SYM, H5E_CANTINIT, FAIL, "unable to create link") done: FUNC_LEAVE_API(ret_value) @@ -478,9 +509,12 @@ 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) { - H5G_loc_t cur_loc, *cur_loc_p; - H5G_loc_t new_loc, *new_loc_p; - herr_t ret_value = SUCCEED; /* Return value */ + H5VL_object_t *obj1 = NULL; /* object token of cur_loc_id */ + H5VL_object_t *obj2 = NULL; /* object token of new_loc_id */ + H5VL_loc_params_t loc_params1; + H5VL_loc_params_t loc_params2; + H5P_genplist_t *plist; /* Property list pointer */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_API(FAIL) H5TRACE6("e", "i*si*sii", cur_loc_id, cur_name, new_loc_id, new_name, lcpl_id, @@ -489,10 +523,6 @@ H5Lcreate_hard(hid_t cur_loc_id, const char *cur_name, /* Check arguments */ if(cur_loc_id == H5L_SAME_LOC && new_loc_id == H5L_SAME_LOC) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "source and destination should not be both H5L_SAME_LOC") - if(cur_loc_id != H5L_SAME_LOC && H5G_loc(cur_loc_id, &cur_loc) < 0) - HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a location") - if(new_loc_id != H5L_SAME_LOC && H5G_loc(new_loc_id, &new_loc) < 0) - HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a location") if(!cur_name || !*cur_name) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "no current name specified") if(!new_name || !*new_name) @@ -500,20 +530,54 @@ H5Lcreate_hard(hid_t cur_loc_id, const char *cur_name, if(lcpl_id != H5P_DEFAULT && (TRUE != H5P_isa_class(lcpl_id, H5P_LINK_CREATE))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a link creation property list") - /* Set up current & new location pointers */ - cur_loc_p = &cur_loc; - new_loc_p = &new_loc; - if(cur_loc_id == H5L_SAME_LOC) - cur_loc_p = new_loc_p; - else if(new_loc_id == H5L_SAME_LOC) - new_loc_p = cur_loc_p; - else if(cur_loc_p->oloc->file != new_loc_p->oloc->file) - HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "source and destination should be in the same file.") + /* Check the link create property list */ + if(H5P_DEFAULT == lcpl_id) + lcpl_id = H5P_LINK_CREATE_DEFAULT; + /* Check the link access property list */ + if(H5P_DEFAULT == lapl_id) + lapl_id = H5P_LINK_ACCESS_DEFAULT; - /* Create the link */ - if(H5L_create_hard(cur_loc_p, cur_name, new_loc_p, new_name, - lcpl_id, lapl_id, H5AC_dxpl_id) < 0) - HGOTO_ERROR(H5E_LINK, H5E_CANTINIT, FAIL, "unable to create link") + loc_params1.type = H5VL_OBJECT_BY_NAME; + loc_params1.obj_type = H5I_get_type(cur_loc_id); + loc_params1.loc_data.loc_by_name.name = cur_name; + loc_params1.loc_data.loc_by_name.lapl_id = lapl_id; + + loc_params2.type = H5VL_OBJECT_BY_NAME; + loc_params2.obj_type = H5I_get_type(new_loc_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 != cur_loc_id) { + /* get the location object */ + if(NULL == (obj1 = (H5VL_object_t *)H5VL_get_object(cur_loc_id))) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "invalid location identifier") + } + if(H5L_SAME_LOC != new_loc_id) { + /* get the location object */ + if(NULL == (obj2 = (H5VL_object_t *)H5VL_get_object(new_loc_id))) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "invalid location identifier") + } + /* Make sure that the VOL plugins are the same */ + if(obj1 && obj2) { + if (obj1->vol_info->vol_cls->value != obj2->vol_info->vol_cls->value) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "Objects are accessed through different VOL plugins and can't be linked") + } + + /* 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") + + /* set creation properties */ + if(H5P_set(plist, H5VL_PROP_LINK_TARGET, (obj1 ? &(obj1->vol_obj) : NULL)) < 0) + HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, FAIL, "can't set property value for target 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 name") + + /* Create the link through the VOL */ + if(H5VL_link_create(H5VL_LINK_CREATE_HARD, (obj2 ? (obj2->vol_obj) : NULL), loc_params2, + (obj1!=NULL ? obj1->vol_info->vol_cls : obj2->vol_info->vol_cls), + lcpl_id, lapl_id, H5AC_dxpl_id, H5_REQUEST_NULL) < 0) + HGOTO_ERROR(H5E_SYM, H5E_CANTINIT, FAIL, "unable to create link") done: FUNC_LEAVE_API(ret_value) @@ -548,7 +612,9 @@ 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) { - H5G_loc_t link_loc; + H5VL_object_t *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 */ FUNC_ENTER_API(FAIL) @@ -556,16 +622,43 @@ H5Lcreate_ud(hid_t link_loc_id, const char *link_name, H5L_type_t link_type, udata_size, lcpl_id, lapl_id); /* Check arguments */ - if(H5G_loc(link_loc_id, &link_loc) < 0) - HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a location") if(!link_name || !*link_name) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "no link name specified") if(link_type < H5L_TYPE_UD_MIN || link_type > H5L_TYPE_MAX) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "invalid link class") - /* Create external link */ - if(H5L_create_ud(&link_loc, link_name, udata, udata_size, link_type, lcpl_id, lapl_id, H5AC_dxpl_id) < 0) - HGOTO_ERROR(H5E_LINK, H5E_CANTINIT, FAIL, "unable to create link") + /* Check the group access property list */ + if(H5P_DEFAULT == lcpl_id) + lcpl_id = H5P_LINK_CREATE_DEFAULT; + /* Check the link access property list */ + if(H5P_DEFAULT == lapl_id) + lapl_id = H5P_LINK_ACCESS_DEFAULT; + + loc_params.type = H5VL_OBJECT_BY_NAME; + loc_params.loc_data.loc_by_name.name = link_name; + loc_params.loc_data.loc_by_name.lapl_id = lapl_id; + loc_params.obj_type = H5I_get_type(link_loc_id); + + /* get the location object */ + if(NULL == (obj = (H5VL_object_t *)H5I_object(link_loc_id))) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "invalid location identifier") + + /* 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") + + /* set creation properties */ + if(H5P_set(plist, H5VL_PROP_LINK_TYPE, &link_type) < 0) + HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, FAIL, "can't get property value from plist") + if(H5P_set(plist, H5VL_PROP_LINK_UDATA, &udata) < 0) + HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, FAIL, "can't get property value from plist") + if(H5P_set(plist, H5VL_PROP_LINK_UDATA_SIZE, &udata_size) < 0) + HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, FAIL, "can't get property value from plist") + + /* Create the link through the VOL */ + if(H5VL_link_create(H5VL_LINK_CREATE_UD, obj->vol_obj, loc_params, obj->vol_info->vol_cls, + lcpl_id, lapl_id, H5AC_dxpl_id, H5_REQUEST_NULL) < 0) + HGOTO_ERROR(H5E_SYM, H5E_CANTINIT, FAIL, "unable to create link") done: FUNC_LEAVE_API(ret_value) @@ -592,21 +685,30 @@ done: herr_t H5Ldelete(hid_t loc_id, const char *name, hid_t lapl_id) { - H5G_loc_t loc; /* Group's location */ + H5VL_object_t *obj = NULL; /* 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*si", loc_id, name, lapl_id); /* 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") - /* Unlink */ - if(H5L_delete(&loc, name, lapl_id, H5AC_dxpl_id) < 0) - HGOTO_ERROR(H5E_LINK, H5E_CANTDELETE, FAIL, "unable to delete link") + loc_params.type = H5VL_OBJECT_BY_NAME; + loc_params.obj_type = H5I_get_type(loc_id); + loc_params.loc_data.loc_by_name.name = name; + loc_params.loc_data.loc_by_name.lapl_id = lapl_id; + + /* get the location object */ + if(NULL == (obj = (H5VL_object_t *)H5I_object(loc_id))) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "invalid location identifier") + + /* Delete the link through the VOL */ + if(H5VL_link_specific(obj->vol_obj, loc_params, obj->vol_info->vol_cls, H5VL_LINK_DELETE, + H5AC_dxpl_id, H5_REQUEST_NULL) < 0) + HGOTO_ERROR(H5E_SYM, H5E_CANTDELETE, FAIL, "unable to delete link") done: FUNC_LEAVE_API(ret_value) @@ -636,16 +738,14 @@ herr_t H5Ldelete_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) { - H5G_loc_t loc; /* Group's location */ - H5L_trav_rmbi_t udata; /* User data for callback */ + H5VL_object_t *obj = NULL; /* object token of loc_id */ + H5VL_loc_params_t loc_params; herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_API(FAIL) H5TRACE6("e", "i*sIiIohi", loc_id, group_name, idx_type, order, n, lapl_id); /* Check arguments */ - if(H5G_loc(loc_id, &loc) < 0) - HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a location") if(!group_name || !*group_name) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "no name specified") if(idx_type <= H5_INDEX_UNKNOWN || idx_type >= H5_INDEX_N) @@ -658,15 +758,22 @@ H5Ldelete_by_idx(hid_t loc_id, const char *group_name, if(TRUE != H5P_isa_class(lapl_id, H5P_LINK_ACCESS)) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not link access property list ID") - /* Set up user data for unlink operation */ - udata.idx_type = idx_type; - udata.order = order; - udata.n = n; - udata.dxpl_id = H5AC_dxpl_id; + loc_params.type = H5VL_OBJECT_BY_IDX; + loc_params.loc_data.loc_by_idx.name = group_name; + loc_params.loc_data.loc_by_idx.idx_type = idx_type; + loc_params.loc_data.loc_by_idx.order = order; + loc_params.loc_data.loc_by_idx.n = n; + loc_params.loc_data.loc_by_idx.lapl_id = lapl_id; + loc_params.obj_type = H5I_get_type(loc_id); - /* Traverse the group hierarchy to remove the link */ - if(H5G_traverse(&loc, group_name, H5G_TARGET_SLINK|H5G_TARGET_UDLINK|H5G_TARGET_MOUNT, H5L_delete_by_idx_cb, &udata, lapl_id, H5AC_dxpl_id) < 0) - HGOTO_ERROR(H5E_SYM, H5E_EXISTS, FAIL, "name doesn't exist") + /* get the location object */ + if(NULL == (obj = (H5VL_object_t *)H5I_object(loc_id))) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "invalid location identifier") + + /* Delete the link through the VOL */ + if(H5VL_link_specific(obj->vol_obj, loc_params, obj->vol_info->vol_cls, H5VL_LINK_DELETE, + H5AC_dxpl_id, H5_REQUEST_NULL) < 0) + HGOTO_ERROR(H5E_SYM, H5E_CANTDELETE, FAIL, "unable to delete link") done: FUNC_LEAVE_API(ret_value) @@ -696,15 +803,14 @@ herr_t H5Lget_val(hid_t loc_id, const char *name, void *buf/*out*/, size_t size, hid_t lapl_id) { - H5G_loc_t loc; /* Group location for location to query */ + H5VL_object_t *obj = NULL; /* object token of loc_id */ + H5VL_loc_params_t loc_params; herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_API(FAIL) H5TRACE5("e", "i*sxzi", loc_id, name, buf, size, lapl_id); /* Check arguments */ - if(H5G_loc(loc_id, &loc)) - HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a location") if(!name || !*name) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "no name specified") if(H5P_DEFAULT == lapl_id) @@ -713,9 +819,19 @@ H5Lget_val(hid_t loc_id, const char *name, void *buf/*out*/, size_t size, if(TRUE != H5P_isa_class(lapl_id, H5P_LINK_ACCESS)) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not link access property list ID") - /* Get the link value */ - if(H5L_get_val(&loc, name, buf, size, lapl_id, H5AC_ind_dxpl_id) < 0) - HGOTO_ERROR(H5E_SYM, H5E_NOTFOUND, FAIL, "unable to get link value for '%s'", name) + loc_params.type = H5VL_OBJECT_BY_NAME; + loc_params.obj_type = H5I_get_type(loc_id); + loc_params.loc_data.loc_by_name.name = name; + loc_params.loc_data.loc_by_name.lapl_id = lapl_id; + + /* get the location object */ + if(NULL == (obj = (H5VL_object_t *)H5I_object(loc_id))) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "invalid location identifier") + + /* Get the link info through the VOL */ + if(H5VL_link_get(obj->vol_obj, loc_params, obj->vol_info->vol_cls, H5VL_LINK_GET_VAL, + H5AC_ind_dxpl_id, H5_REQUEST_NULL, buf, size) < 0) + HGOTO_ERROR(H5E_INTERNAL, H5E_CANTGET, FAIL, "unable to get link value") done: FUNC_LEAVE_API(ret_value) @@ -745,8 +861,8 @@ H5Lget_val_by_idx(hid_t loc_id, const char *group_name, H5_index_t idx_type, H5_iter_order_t order, hsize_t n, void *buf/*out*/, size_t size, hid_t lapl_id) { - H5G_loc_t loc; /* Group location for location to query */ - H5L_trav_gvbi_t udata; /* User data for callback */ + H5VL_object_t *obj = NULL; /* object token of loc_id */ + H5VL_loc_params_t loc_params; herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_API(FAIL) @@ -754,8 +870,6 @@ H5Lget_val_by_idx(hid_t loc_id, const char *group_name, H5_index_t idx_type, lapl_id); /* Check arguments */ - if(H5G_loc(loc_id, &loc)) - HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a location") if(!group_name || !*group_name) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "no name specified") if(idx_type <= H5_INDEX_UNKNOWN || idx_type >= H5_INDEX_N) @@ -768,18 +882,22 @@ H5Lget_val_by_idx(hid_t loc_id, const char *group_name, H5_index_t idx_type, if(TRUE != H5P_isa_class(lapl_id, H5P_LINK_ACCESS)) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not link access property list ID") - /* Set up user data for retrieving information */ - udata.idx_type = idx_type; - udata.order = order; - udata.n = n; - udata.dxpl_id = H5AC_ind_dxpl_id; - udata.buf = buf; - udata.size = size; + loc_params.type = H5VL_OBJECT_BY_IDX; + loc_params.loc_data.loc_by_idx.name = group_name; + loc_params.loc_data.loc_by_idx.idx_type = idx_type; + loc_params.loc_data.loc_by_idx.order = order; + loc_params.loc_data.loc_by_idx.n = n; + loc_params.loc_data.loc_by_idx.lapl_id = lapl_id; + loc_params.obj_type = H5I_get_type(loc_id); - /* Traverse the group hierarchy to locate the object to get info about */ - if(H5G_traverse(&loc, group_name, H5G_TARGET_SLINK | H5G_TARGET_UDLINK, H5L_get_val_by_idx_cb, &udata, lapl_id, H5AC_ind_dxpl_id) < 0) - HGOTO_ERROR(H5E_SYM, H5E_NOTFOUND, FAIL, "name doesn't exist") + /* get the location object */ + if(NULL == (obj = (H5VL_object_t *)H5I_object(loc_id))) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "invalid location identifier") + /* Get the link info through the VOL */ + if(H5VL_link_get(obj->vol_obj, loc_params, obj->vol_info->vol_cls, H5VL_LINK_GET_VAL, + H5AC_ind_dxpl_id, H5_REQUEST_NULL, buf, size) < 0) + HGOTO_ERROR(H5E_INTERNAL, H5E_CANTGET, FAIL, "unable to get link value") done: FUNC_LEAVE_API(ret_value) @@ -802,15 +920,14 @@ done: htri_t H5Lexists(hid_t loc_id, const char *name, hid_t lapl_id) { - H5G_loc_t loc; + H5VL_object_t *obj = NULL; /* object token of loc_id */ + H5VL_loc_params_t loc_params; htri_t ret_value; FUNC_ENTER_API(FAIL) H5TRACE3("t", "i*si", loc_id, name, lapl_id); /* Check arguments */ - if(H5G_loc(loc_id, &loc)) - HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a location") if(!name || !*name) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "no name specified") if(H5P_DEFAULT == lapl_id) @@ -819,9 +936,19 @@ H5Lexists(hid_t loc_id, const char *name, hid_t lapl_id) if(TRUE != H5P_isa_class(lapl_id, H5P_LINK_ACCESS)) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not link access property list ID") - /* Check for the existence of the link */ - if((ret_value = H5L_exists(&loc, name, lapl_id, H5AC_ind_dxpl_id)) < 0) - HGOTO_ERROR(H5E_SYM, H5E_NOTFOUND, FAIL, "unable to get link info") + loc_params.type = H5VL_OBJECT_BY_NAME; + loc_params.obj_type = H5I_get_type(loc_id); + loc_params.loc_data.loc_by_name.name = name; + loc_params.loc_data.loc_by_name.lapl_id = lapl_id; + + /* get the location object */ + if(NULL == (obj = (H5VL_object_t *)H5I_object(loc_id))) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "invalid location identifier") + + /* check link existence through the VOL */ + if(H5VL_link_specific(obj->vol_obj, loc_params, obj->vol_info->vol_cls, H5VL_LINK_EXISTS, + H5AC_ind_dxpl_id, H5_REQUEST_NULL, &ret_value) < 0) + HGOTO_ERROR(H5E_INTERNAL, H5E_CANTGET, FAIL, "unable to get link info") done: FUNC_LEAVE_API(ret_value) @@ -846,15 +973,13 @@ herr_t H5Lget_info(hid_t loc_id, const char *name, H5L_info_t *linfo /*out*/, hid_t lapl_id) { - H5G_loc_t loc; + H5VL_object_t *obj = NULL; /* object token of loc_id */ + H5VL_loc_params_t loc_params; herr_t ret_value = SUCCEED; FUNC_ENTER_API(FAIL) H5TRACE4("e", "i*sxi", loc_id, name, linfo, lapl_id); - /* Check arguments */ - if(H5G_loc(loc_id, &loc)) - HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a location") if(!name || !*name) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "no name specified") if(H5P_DEFAULT == lapl_id) @@ -863,9 +988,19 @@ H5Lget_info(hid_t loc_id, const char *name, H5L_info_t *linfo /*out*/, if(TRUE != H5P_isa_class(lapl_id, H5P_LINK_ACCESS)) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not link access property list ID") - /* Get the link information */ - if(H5L_get_info(&loc, name, linfo, lapl_id, H5AC_ind_dxpl_id) < 0) - HGOTO_ERROR(H5E_SYM, H5E_NOTFOUND, FAIL, "unable to get link info") + loc_params.type = H5VL_OBJECT_BY_NAME; + loc_params.obj_type = H5I_get_type(loc_id); + loc_params.loc_data.loc_by_name.name = name; + loc_params.loc_data.loc_by_name.lapl_id = lapl_id; + + /* get the location object */ + if(NULL == (obj = (H5VL_object_t *)H5I_object(loc_id))) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "invalid location identifier") + + /* Get the link info through the VOL */ + if(H5VL_link_get(obj->vol_obj, loc_params, obj->vol_info->vol_cls, H5VL_LINK_GET_INFO, + H5AC_ind_dxpl_id, H5_REQUEST_NULL, linfo) < 0) + HGOTO_ERROR(H5E_INTERNAL, H5E_CANTGET, FAIL, "unable to get link info") done: FUNC_LEAVE_API(ret_value) @@ -891,8 +1026,8 @@ H5Lget_info_by_idx(hid_t loc_id, const char *group_name, H5_index_t idx_type, H5_iter_order_t order, hsize_t n, H5L_info_t *linfo /*out*/, hid_t lapl_id) { - H5G_loc_t loc; /* Group location for group to query */ - H5L_trav_gibi_t udata; /* User data for callback */ + H5VL_object_t *obj = NULL; /* object token of loc_id */ + H5VL_loc_params_t loc_params; herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_API(FAIL) @@ -900,8 +1035,6 @@ H5Lget_info_by_idx(hid_t loc_id, const char *group_name, lapl_id); /* Check arguments */ - if(H5G_loc(loc_id, &loc)) - HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a location") if(!group_name || !*group_name) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "no name specified") if(idx_type <= H5_INDEX_UNKNOWN || idx_type >= H5_INDEX_N) @@ -914,17 +1047,22 @@ H5Lget_info_by_idx(hid_t loc_id, const char *group_name, if(TRUE != H5P_isa_class(lapl_id, H5P_LINK_ACCESS)) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not link access property list ID") - /* Set up user data for callback */ - udata.idx_type = idx_type; - udata.order = order; - udata.n = n; - udata.dxpl_id = H5AC_ind_dxpl_id; - udata.linfo = linfo; + loc_params.type = H5VL_OBJECT_BY_IDX; + loc_params.loc_data.loc_by_idx.name = group_name; + loc_params.loc_data.loc_by_idx.idx_type = idx_type; + loc_params.loc_data.loc_by_idx.order = order; + loc_params.loc_data.loc_by_idx.n = n; + loc_params.loc_data.loc_by_idx.lapl_id = lapl_id; + loc_params.obj_type = H5I_get_type(loc_id); - /* Traverse the group hierarchy to locate the object to get info about */ - if(H5G_traverse(&loc, group_name, H5G_TARGET_SLINK|H5G_TARGET_UDLINK, H5L_get_info_by_idx_cb, &udata, lapl_id, H5AC_ind_dxpl_id) < 0) - HGOTO_ERROR(H5E_SYM, H5E_NOTFOUND, FAIL, "unable to get link info") + /* get the location object */ + if(NULL == (obj = (H5VL_object_t *)H5I_object(loc_id))) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "invalid location identifier") + /* Get the link info through the VOL */ + if(H5VL_link_get(obj->vol_obj, loc_params, obj->vol_info->vol_cls, H5VL_LINK_GET_INFO, + H5AC_ind_dxpl_id, H5_REQUEST_NULL, linfo) < 0) + HGOTO_ERROR(H5E_INTERNAL, H5E_CANTGET, FAIL, "unable to get link info") done: FUNC_LEAVE_API(ret_value) @@ -1080,8 +1218,8 @@ H5Lget_name_by_idx(hid_t loc_id, const char *group_name, H5_index_t idx_type, H5_iter_order_t order, hsize_t n, char *name /*out*/, size_t size, hid_t lapl_id) { - H5G_loc_t loc; /* Location of group */ - H5L_trav_gnbi_t udata; /* User data for callback */ + H5VL_object_t *obj = NULL; /* object token of loc_id */ + H5VL_loc_params_t loc_params; ssize_t ret_value; /* Return value */ FUNC_ENTER_API(FAIL) @@ -1089,8 +1227,6 @@ H5Lget_name_by_idx(hid_t loc_id, const char *group_name, lapl_id); /* Check arguments */ - if(H5G_loc(loc_id, &loc)) - HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a location") if(!group_name || !*group_name) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "no name specified") if(idx_type <= H5_INDEX_UNKNOWN || idx_type >= H5_INDEX_N) @@ -1103,21 +1239,22 @@ H5Lget_name_by_idx(hid_t loc_id, const char *group_name, if(TRUE != H5P_isa_class(lapl_id, H5P_LINK_ACCESS)) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not link access property list ID") - /* Set up user data for callback */ - udata.idx_type = idx_type; - udata.order = order; - udata.n = n; - udata.dxpl_id = H5AC_ind_dxpl_id; - udata.name = name; - udata.size = size; - udata.name_len = -1; + loc_params.type = H5VL_OBJECT_BY_IDX; + loc_params.loc_data.loc_by_idx.name = group_name; + loc_params.loc_data.loc_by_idx.idx_type = idx_type; + loc_params.loc_data.loc_by_idx.order = order; + loc_params.loc_data.loc_by_idx.n = n; + loc_params.loc_data.loc_by_idx.lapl_id = lapl_id; + loc_params.obj_type = H5I_get_type(loc_id); - /* Traverse the group hierarchy to locate the link to get name of */ - if(H5G_traverse(&loc, group_name, H5G_TARGET_SLINK|H5G_TARGET_UDLINK, H5L_get_name_by_idx_cb, &udata, lapl_id, H5AC_ind_dxpl_id) < 0) - HGOTO_ERROR(H5E_SYM, H5E_EXISTS, FAIL, "name doesn't exist") + /* get the location object */ + if(NULL == (obj = (H5VL_object_t *)H5I_object(loc_id))) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "invalid location identifier") - /* Set the return value */ - ret_value = udata.name_len; + /* Get the link info through the VOL */ + if(H5VL_link_get(obj->vol_obj, loc_params, obj->vol_info->vol_cls, H5VL_LINK_GET_NAME, + H5AC_ind_dxpl_id, H5_REQUEST_NULL, name, size, &ret_value) < 0) + HGOTO_ERROR(H5E_INTERNAL, H5E_CANTGET, FAIL, "unable to get link name") done: FUNC_LEAVE_API(ret_value) @@ -1147,20 +1284,19 @@ done: *------------------------------------------------------------------------- */ herr_t -H5Literate(hid_t grp_id, H5_index_t idx_type, H5_iter_order_t order, +H5Literate(hid_t id, H5_index_t idx_type, H5_iter_order_t order, hsize_t *idx_p, H5L_iterate_t op, void *op_data) { + H5VL_object_t *obj = NULL; /* object token of loc_id */ + H5VL_loc_params_t loc_params; H5I_type_t id_type; /* Type of ID */ - H5G_link_iterate_t lnk_op; /* Link operator */ - hsize_t last_lnk; /* Index of last object looked at */ - hsize_t idx; /* Internal location to hold index */ herr_t ret_value; /* Return value */ FUNC_ENTER_API(FAIL) - H5TRACE6("e", "iIiIo*hx*x", grp_id, idx_type, order, idx_p, op, op_data); + H5TRACE6("e", "iIiIo*hx*x", id, idx_type, order, idx_p, op, op_data); /* Check arguments */ - id_type = H5I_get_type(grp_id); + id_type = H5I_get_type(id); if(!(H5I_GROUP == id_type || H5I_FILE == id_type)) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "invalid argument") if(idx_type <= H5_INDEX_UNKNOWN || idx_type >= H5_INDEX_N) @@ -1170,22 +1306,19 @@ H5Literate(hid_t grp_id, H5_index_t idx_type, H5_iter_order_t order, if(!op) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "no operator specified") - /* Set up iteration beginning/end info */ - idx = (idx_p == NULL ? 0 : *idx_p); - last_lnk = 0; + loc_params.type = H5VL_OBJECT_BY_SELF; + loc_params.obj_type = H5I_get_type(id); - /* Build link operator info */ - lnk_op.op_type = H5G_LINK_OP_NEW; - lnk_op.op_func.op_new = op; + /* get the location object */ + if(NULL == (obj = (H5VL_object_t *)H5I_object(id))) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "invalid location identifier") - /* Iterate over the links */ - if((ret_value = H5G_iterate(grp_id, ".", idx_type, order, idx, &last_lnk, &lnk_op, op_data, H5P_DEFAULT, H5AC_ind_dxpl_id)) < 0) + /* iterate over the links through the VOL */ + if((ret_value = H5VL_link_specific(obj->vol_obj, loc_params, obj->vol_info->vol_cls, H5VL_LINK_ITER, + H5AC_ind_dxpl_id, H5_REQUEST_NULL, + FALSE, idx_type, order, idx_p, op, op_data)) < 0) HGOTO_ERROR(H5E_SYM, H5E_BADITER, FAIL, "link iteration failed") - /* Set the index we stopped at */ - if(idx_p) - *idx_p = last_lnk; - done: FUNC_LEAVE_API(ret_value) } /* end H5Literate() */ @@ -1218,9 +1351,8 @@ H5Literate_by_name(hid_t loc_id, const char *group_name, H5_index_t idx_type, H5_iter_order_t order, hsize_t *idx_p, H5L_iterate_t op, void *op_data, hid_t lapl_id) { - H5G_link_iterate_t lnk_op; /* Link operator */ - hsize_t last_lnk; /* Index of last object looked at */ - hsize_t idx; /* Internal location to hold index */ + H5VL_object_t *obj = NULL; /* object token of loc_id */ + H5VL_loc_params_t loc_params; herr_t ret_value; /* Return value */ FUNC_ENTER_API(FAIL) @@ -1242,22 +1374,21 @@ H5Literate_by_name(hid_t loc_id, const char *group_name, if(TRUE != H5P_isa_class(lapl_id, H5P_LINK_ACCESS)) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not link access property list ID") - /* Set up iteration beginning/end info */ - idx = (idx_p == NULL ? 0 : *idx_p); - last_lnk = 0; + loc_params.type = H5VL_OBJECT_BY_NAME; + loc_params.obj_type = H5I_get_type(loc_id); + loc_params.loc_data.loc_by_name.name = group_name; + loc_params.loc_data.loc_by_name.lapl_id = lapl_id; - /* Build link operator info */ - lnk_op.op_type = H5G_LINK_OP_NEW; - lnk_op.op_func.op_new = op; + /* get the location object */ + if(NULL == (obj = (H5VL_object_t *)H5I_object(loc_id))) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "invalid location identifier") - /* Iterate over the links */ - if((ret_value = H5G_iterate(loc_id, group_name, idx_type, order, idx, &last_lnk, &lnk_op, op_data, lapl_id, H5AC_ind_dxpl_id)) < 0) + /* iterate over the links through the VOL */ + if((ret_value = H5VL_link_specific(obj->vol_obj, loc_params, obj->vol_info->vol_cls, H5VL_LINK_ITER, + H5AC_ind_dxpl_id, H5_REQUEST_NULL, + FALSE, idx_type, order, idx_p, op, op_data)) < 0) HGOTO_ERROR(H5E_SYM, H5E_BADITER, FAIL, "link iteration failed") - /* Set the index we stopped at */ - if(idx_p) - *idx_p = last_lnk; - done: FUNC_LEAVE_API(ret_value) } /* end H5Literate_by_name() */ @@ -1295,14 +1426,17 @@ herr_t H5Lvisit(hid_t grp_id, H5_index_t idx_type, H5_iter_order_t order, H5L_iterate_t op, void *op_data) { + H5VL_object_t *obj = NULL; /* object token of loc_id */ + H5VL_loc_params_t loc_params; H5I_type_t id_type; /* Type of ID */ herr_t ret_value; /* Return value */ FUNC_ENTER_API(FAIL) H5TRACE5("e", "iIiIox*x", grp_id, idx_type, order, op, op_data); - /* Check args */ id_type = H5I_get_type(grp_id); + + /* Check args */ if(!(H5I_GROUP == id_type || H5I_FILE == id_type)) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "invalid argument") if(idx_type <= H5_INDEX_UNKNOWN || idx_type >= H5_INDEX_N) @@ -1312,9 +1446,18 @@ H5Lvisit(hid_t grp_id, H5_index_t idx_type, H5_iter_order_t order, if(!op) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "no callback operator specified") - /* Call internal group visitation routine */ - if((ret_value = H5G_visit(grp_id, ".", idx_type, order, op, op_data, H5P_DEFAULT, H5AC_ind_dxpl_id)) < 0) - HGOTO_ERROR(H5E_SYM, H5E_BADITER, FAIL, "link visitation failed") + loc_params.type = H5VL_OBJECT_BY_SELF; + loc_params.obj_type = H5I_get_type(grp_id); + + /* get the location object */ + if(NULL == (obj = (H5VL_object_t *)H5I_object(grp_id))) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "invalid location identifier") + + /* iterate over the links through the VOL */ + if((ret_value = H5VL_link_specific(obj->vol_obj, loc_params, obj->vol_info->vol_cls, H5VL_LINK_ITER, + H5AC_ind_dxpl_id, H5_REQUEST_NULL, + TRUE, idx_type, order, NULL, op, op_data)) < 0) + HGOTO_ERROR(H5E_SYM, H5E_BADITER, FAIL, "link visit failed") done: FUNC_LEAVE_API(ret_value) @@ -1353,6 +1496,8 @@ herr_t H5Lvisit_by_name(hid_t loc_id, const char *group_name, H5_index_t idx_type, H5_iter_order_t order, H5L_iterate_t op, void *op_data, hid_t lapl_id) { + H5VL_object_t *obj = NULL; /* object token of loc_id */ + H5VL_loc_params_t loc_params; herr_t ret_value; /* Return value */ FUNC_ENTER_API(FAIL) @@ -1374,9 +1519,20 @@ H5Lvisit_by_name(hid_t loc_id, const char *group_name, H5_index_t idx_type, if(TRUE != H5P_isa_class(lapl_id, H5P_LINK_ACCESS)) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not link access property list ID") - /* Call internal group visitation routine */ - if((ret_value = H5G_visit(loc_id, group_name, idx_type, order, op, op_data, lapl_id, H5AC_ind_dxpl_id)) < 0) - HGOTO_ERROR(H5E_SYM, H5E_BADITER, FAIL, "link visitation failed") + loc_params.type = H5VL_OBJECT_BY_NAME; + loc_params.obj_type = H5I_get_type(loc_id); + loc_params.loc_data.loc_by_name.name = group_name; + loc_params.loc_data.loc_by_name.lapl_id = lapl_id; + + /* get the location object */ + if(NULL == (obj = (H5VL_object_t *)H5I_object(loc_id))) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "invalid location identifier") + + /* visit the links through the VOL */ + if((ret_value = H5VL_link_specific(obj->vol_obj, loc_params, obj->vol_info->vol_cls, H5VL_LINK_ITER, + H5AC_ind_dxpl_id, H5_REQUEST_NULL, + TRUE, idx_type, order, NULL, op, op_data)) < 0) + HGOTO_ERROR(H5E_SYM, H5E_BADITER, FAIL, "link visit failed") done: FUNC_LEAVE_API(ret_value) @@ -1755,7 +1911,7 @@ H5L_link_cb(H5G_loc_t *grp_loc/*in*/, const char *name, const H5O_link_t UNUSED /* Set up location for user-defined callback */ if((grp = H5G_open(&temp_loc, udata->dxpl_id)) == NULL) HGOTO_ERROR(H5E_SYM, H5E_CANTOPENOBJ, FAIL, "unable to open group") - if((grp_id = H5I_register(H5I_GROUP, grp, TRUE)) < 0) + if((grp_id = H5VL_native_register(H5I_GROUP, grp, TRUE)) < 0) HGOTO_ERROR(H5E_ATOM, H5E_CANTREGISTER, FAIL, "unable to register ID for group") /* Make callback */ @@ -2263,6 +2419,35 @@ done: /*------------------------------------------------------------------------- + * Function: H5L_get_val_by_idx + * + * Purpose: Get Value of a link + * + * Return: Non-negative on success/Negative on failure + * + * Programmer: Mohamad Chaarawi + * April, 2012 + * + *------------------------------------------------------------------------- + */ +herr_t +H5L_get_val_by_idx(H5G_loc_t *loc, const char *name, void *udata, hid_t lapl_id, hid_t dxpl_id) +{ + herr_t ret_value = SUCCEED; /* Return value */ + + FUNC_ENTER_NOAPI(FAIL) + + /* Traverse the group hierarchy to locate the object to get val about */ + if(H5G_traverse(loc, name, H5G_TARGET_SLINK|H5G_TARGET_UDLINK, H5L_get_val_by_idx_cb, + (H5L_trav_gvbi_t *)udata, lapl_id, dxpl_id) < 0) + HGOTO_ERROR(H5E_SYM, H5E_NOTFOUND, FAIL, "unable to get link val") + +done: + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5L_get_val_by_idx() */ + + +/*------------------------------------------------------------------------- * Function: H5L_delete_cb * * Purpose: Callback for deleting a link. This routine @@ -2393,6 +2578,39 @@ done: /*------------------------------------------------------------------------- + * Function: H5L_delete_by_idx + * + * Purpose: Delete a link from a group. + * + * Return: Non-negative on success/Negative on failure + * + * Programmer: Mohamad Chaarawi + * April, 2012 + * + *------------------------------------------------------------------------- + */ +herr_t +H5L_delete_by_idx(H5G_loc_t *loc, const char *name, void *udata, hid_t lapl_id, hid_t dxpl_id) +{ + herr_t ret_value = SUCCEED; /* Return value */ + + FUNC_ENTER_NOAPI(FAIL) + + /* Sanity check */ + HDassert(loc); + HDassert(name && *name); + + /* Traverse the group hierarchy to remove the link */ + if(H5G_traverse(loc, name, H5G_TARGET_SLINK|H5G_TARGET_UDLINK|H5G_TARGET_MOUNT, + H5L_delete_by_idx_cb, (H5L_trav_rmbi_t *)udata, lapl_id, dxpl_id) < 0) + HGOTO_ERROR(H5E_SYM, H5E_EXISTS, FAIL, "name doesn't exist") + +done: + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5L_delete_by_idx() */ + + +/*------------------------------------------------------------------------- * Function: H5L_move_dest_cb * * Purpose: Second callback for moving and renaming an object. This routine @@ -2467,7 +2685,7 @@ H5L_move_dest_cb(H5G_loc_t *grp_loc/*in*/, const char *name, /* Set up location for user-defined callback */ if((grp = H5G_open(&temp_loc, udata->dxpl_id)) == NULL) HGOTO_ERROR(H5E_SYM, H5E_CANTOPENOBJ, FAIL, "unable to open group") - if((grp_id = H5I_register(H5I_GROUP, grp, TRUE)) < 0) + if((grp_id = H5VL_native_register(H5I_GROUP, grp, TRUE)) < 0) HGOTO_ERROR(H5E_ATOM, H5E_CANTREGISTER, FAIL, "unable to register group ID") if(udata->copy) { @@ -2752,7 +2970,7 @@ H5L_exists_cb(H5G_loc_t UNUSED *grp_loc/*in*/, const char UNUSED *name, * *------------------------------------------------------------------------- */ -static htri_t +htri_t H5L_exists(const H5G_loc_t *loc, const char *name, hid_t lapl_id, hid_t dxpl_id) { hbool_t exists = FALSE; /* Whether the link exists in the group */ @@ -2897,6 +3115,35 @@ done: /*------------------------------------------------------------------------- + * Function: H5L_get_info_by_idx + * + * Purpose: Get_Info a link from a group. + * + * Return: Non-negative on success/Negative on failure + * + * Programmer: Mohamad Chaarawi + * April, 2012 + * + *------------------------------------------------------------------------- + */ +herr_t +H5L_get_info_by_idx(H5G_loc_t *loc, const char *name, void *udata, hid_t lapl_id, hid_t dxpl_id) +{ + herr_t ret_value = SUCCEED; /* Return value */ + + FUNC_ENTER_NOAPI(FAIL) + + /* Traverse the group hierarchy to locate the object to get info about */ + if(H5G_traverse(loc, name, H5G_TARGET_SLINK|H5G_TARGET_UDLINK, H5L_get_info_by_idx_cb, + (H5L_trav_gibi_t *)udata, lapl_id, dxpl_id) < 0) + HGOTO_ERROR(H5E_SYM, H5E_NOTFOUND, FAIL, "unable to get link info") + +done: + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5L_get_info_by_idx() */ + + +/*------------------------------------------------------------------------- * Function: H5L_get_default_lcpl * * Purpose: Accessor for the default Link Creation Property List @@ -2966,6 +3213,35 @@ done: /*------------------------------------------------------------------------- + * Function: H5L_get_name_by_idx + * + * Purpose: Get name of a link from a group. + * + * Return: Non-negative on success/Negative on failure + * + * Programmer: Mohamad Chaarawi + * April, 2012 + * + *------------------------------------------------------------------------- + */ +herr_t +H5L_get_name_by_idx(H5G_loc_t *loc, const char *name, void *udata, hid_t lapl_id, hid_t dxpl_id) +{ + herr_t ret_value = SUCCEED; /* Return value */ + + FUNC_ENTER_NOAPI(FAIL) + + /* Traverse the group hierarchy to locate the object to get name about */ + if(H5G_traverse(loc, name, H5G_TARGET_SLINK|H5G_TARGET_UDLINK, H5L_get_name_by_idx_cb, + (H5L_trav_gnbi_t *)udata, lapl_id, dxpl_id) < 0) + HGOTO_ERROR(H5E_SYM, H5E_NOTFOUND, FAIL, "unable to get link name") + +done: + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5L_get_name_by_idx() */ + + +/*------------------------------------------------------------------------- * Function: H5L_link_copy_file * * Purpose: Copy a link and the object it points to from one file to @@ -3098,3 +3374,83 @@ done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5L_link_copy_file() */ + +/*------------------------------------------------------------------------- + * Function: H5L_iterate + * + * Purpose: Iterates through links in a group + * + * Return: Success: 0 + * Failure: -1 + * + * Programmer: Mohamad Chaarawi + * August, 2014 + * + *------------------------------------------------------------------------- + */ +herr_t H5L_iterate(void *obj, H5VL_loc_params_t loc_params, hbool_t recursive, + H5_index_t idx_type, H5_iter_order_t order, hsize_t *idx_p, + H5L_iterate_t op, void *op_data, hid_t dxpl_id) +{ + H5G_loc_t loc; + herr_t ret_value; /* 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") + + if(!recursive) { + H5G_link_iterate_t lnk_op; /* Link operator */ + hsize_t last_lnk; /* Index of last object looked at */ + hsize_t idx; /* Internal location to hold index */ + + /* Set up iteration beginning/end info */ + idx = (idx_p == NULL ? 0 : *idx_p); + last_lnk = 0; + + /* Build link operator info */ + lnk_op.op_type = H5G_LINK_OP_NEW; + lnk_op.op_func.op_new = op; + + /* Iterate over the links */ + if(loc_params.type == H5VL_OBJECT_BY_SELF) { + if((ret_value = H5G_iterate(&loc, ".", idx_type, order, idx, &last_lnk, &lnk_op, op_data, + H5P_LINK_ACCESS_DEFAULT, dxpl_id)) < 0) + HGOTO_ERROR(H5E_SYM, H5E_BADITER, FAIL, "link iteration failed") + } + else if(loc_params.type == H5VL_OBJECT_BY_NAME) { + if((ret_value = H5G_iterate(&loc, loc_params.loc_data.loc_by_name.name, + idx_type, order, idx, &last_lnk, &lnk_op, op_data, + loc_params.loc_data.loc_by_name.lapl_id, dxpl_id)) < 0) + HGOTO_ERROR(H5E_SYM, H5E_BADITER, FAIL, "link iteration failed") + } + else { + HGOTO_ERROR(H5E_VOL, H5E_UNSUPPORTED, FAIL, "unknown link iterate params") + } + + /* Set the index we stopped at */ + if(idx_p) + *idx_p = last_lnk; + } + else { + /* Call internal group visitation routine */ + if(loc_params.type == H5VL_OBJECT_BY_SELF) { + if((ret_value = H5G_visit(&loc, ".", idx_type, order, op, op_data, + H5P_LINK_ACCESS_DEFAULT, dxpl_id)) < 0) + HGOTO_ERROR(H5E_SYM, H5E_BADITER, FAIL, "link visitation failed") + } + else if(loc_params.type == H5VL_OBJECT_BY_NAME) { + if((ret_value = H5G_visit(&loc, loc_params.loc_data.loc_by_name.name, + idx_type, order, op, op_data, + loc_params.loc_data.loc_by_name.lapl_id, dxpl_id)) < 0) + HGOTO_ERROR(H5E_SYM, H5E_BADITER, FAIL, "link visitation failed") + } + else { + HGOTO_ERROR(H5E_VOL, H5E_UNSUPPORTED, FAIL, "unknown link visit params") + } + } + +done: + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5L_iterate() */ diff --git a/src/H5Lexternal.c b/src/H5Lexternal.c index a5302e0..f529e95 100644 --- a/src/H5Lexternal.c +++ b/src/H5Lexternal.c @@ -28,6 +28,7 @@ #include "H5MMprivate.h" /* Memory management */ #include "H5Opublic.h" /* File objects */ #include "H5Pprivate.h" /* Property lists */ +#include "H5VLprivate.h" /* Virtual Object Layer */ static hid_t H5L_extern_traverse(const char UNUSED *link_name, hid_t cur_group, const void *udata, size_t UNUSED udata_size, hid_t lapl_id); @@ -447,6 +448,20 @@ H5L_extern_traverse(const char UNUSED *link_name, hid_t cur_group, if((ext_obj = H5O_open_name(&root_loc, obj_name, lapl_id, FALSE)) < 0) HGOTO_ERROR(H5E_SYM, H5E_CANTOPENOBJ, FAIL, "unable to open object") + /* get the native object from the ID created by the object header and create + a "VOL object" ID */ + { + void *temp_obj = NULL; + H5I_type_t obj_type; + + obj_type = H5I_get_type(ext_obj); + if(NULL == (temp_obj = H5I_remove(ext_obj))) + HGOTO_ERROR(H5E_SYM, H5E_CANTOPENOBJ, FAIL, "unable to open object") + /* Get an atom for the datatype */ + if((ext_obj = H5VL_native_register(obj_type, temp_obj, TRUE)) < 0) + HGOTO_ERROR(H5E_ATOM, H5E_CANTREGISTER, FAIL, "unable to register datatype") + } + /* Set return value */ ret_value = ext_obj; @@ -546,13 +561,16 @@ herr_t H5Lcreate_external(const char *file_name, const char *obj_name, hid_t link_loc_id, const char *link_name, hid_t lcpl_id, hid_t lapl_id) { - H5G_loc_t link_loc; /* Group location to create link */ char *norm_obj_name = NULL; /* Pointer to normalized current name */ void *ext_link_buf = NULL; /* Buffer to contain external link */ size_t buf_size; /* Size of buffer to hold external link */ size_t file_name_len; /* Length of file name string */ size_t norm_obj_name_len; /* Length of normalized object name string */ uint8_t *p; /* Pointer into external link buffer */ + H5VL_object_t *obj = NULL; /* object token of loc_id */ + H5VL_loc_params_t loc_params; + H5P_genplist_t *plist; /* Property list pointer */ + H5L_type_t link_type = H5L_TYPE_EXTERNAL; herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_API(FAIL) @@ -564,11 +582,13 @@ H5Lcreate_external(const char *file_name, const char *obj_name, HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "no file name specified") if(!obj_name || !*obj_name) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "no object name specified") - if(H5G_loc(link_loc_id, &link_loc) < 0) - HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a location") if(!link_name || !*link_name) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "no link name specified") + /* Check the group access property list */ + if(H5P_DEFAULT == lcpl_id) + lcpl_id = H5P_LINK_CREATE_DEFAULT; + /* Get normalized copy of the link target */ if(NULL == (norm_obj_name = H5G_normalize(obj_name))) HGOTO_ERROR(H5E_SYM, H5E_BADVALUE, FAIL, "can't normalize object name") @@ -587,9 +607,31 @@ H5Lcreate_external(const char *file_name, const char *obj_name, p += file_name_len; HDstrncpy((char *)p, norm_obj_name, buf_size - (file_name_len + 1)); /* External link's object */ - /* Create an external link */ - if(H5L_create_ud(&link_loc, link_name, ext_link_buf, buf_size, H5L_TYPE_EXTERNAL, lcpl_id, lapl_id, H5AC_dxpl_id) < 0) - HGOTO_ERROR(H5E_LINK, H5E_CANTINIT, FAIL, "unable to create link") + loc_params.type = H5VL_OBJECT_BY_NAME; + loc_params.loc_data.loc_by_name.name = link_name; + loc_params.loc_data.loc_by_name.lapl_id = lapl_id; + loc_params.obj_type = H5I_get_type(link_loc_id); + + /* get the location object */ + if(NULL == (obj = (H5VL_object_t *)H5I_object(link_loc_id))) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "invalid object identifier") + + /* 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") + + /* set creation properties */ + if(H5P_set(plist, H5VL_PROP_LINK_TYPE, &link_type) < 0) + HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, FAIL, "can't get property value from plist") + if(H5P_set(plist, H5VL_PROP_LINK_UDATA, &ext_link_buf) < 0) + HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, FAIL, "can't get property value from plist") + if(H5P_set(plist, H5VL_PROP_LINK_UDATA_SIZE, &buf_size) < 0) + HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, FAIL, "can't get property value from plist") + + /* Create the link through the VOL */ + if((ret_value = H5VL_link_create(H5VL_LINK_CREATE_UD, obj->vol_obj, loc_params, obj->vol_info->vol_cls, + lcpl_id, lapl_id, H5AC_dxpl_id, H5_REQUEST_NULL)) < 0) + HGOTO_ERROR(H5E_SYM, H5E_CANTINIT, FAIL, "unable to create link") done: H5MM_xfree(ext_link_buf); diff --git a/src/H5Lprivate.h b/src/H5Lprivate.h index f3079bc..badd18e 100644 --- a/src/H5Lprivate.h +++ b/src/H5Lprivate.h @@ -49,6 +49,53 @@ /****************************/ /* Library Private Typedefs */ /****************************/ +/* User data for path traversal routine for getting link value by index */ +typedef struct { + /* In */ + H5_index_t idx_type; /* Index to use */ + H5_iter_order_t order; /* Order to iterate in index */ + hsize_t n; /* Offset of link within index */ + hid_t dxpl_id; /* DXPL to use in callback */ + size_t size; /* Size of user buffer */ + + /* Out */ + void *buf; /* User buffer */ +} H5L_trav_gvbi_t; + +/* User data for path traversal routine for getting link info by index */ +typedef struct { + /* In */ + H5_index_t idx_type; /* Index to use */ + H5_iter_order_t order; /* Order to iterate in index */ + hsize_t n; /* Offset of link within index */ + hid_t dxpl_id; /* DXPL to use in callback */ + + /* Out */ + H5L_info_t *linfo; /* Buffer to return to user */ +} H5L_trav_gibi_t; + +/* User data for path traversal routine for getting name by index */ +typedef struct { + /* In */ + H5_index_t idx_type; /* Index to use */ + H5_iter_order_t order; /* Order to iterate in index */ + hsize_t n; /* Offset of link within index */ + size_t size; /* Size of name buffer */ + hid_t dxpl_id; /* DXPL to use in callback */ + + /* Out */ + char *name; /* Buffer to return name to user */ + ssize_t name_len; /* Length of full name */ +} H5L_trav_gnbi_t; + +/* User data for path traversal routine for removing link by index */ +typedef struct { + /* In */ + H5_index_t idx_type; /* Index to use */ + H5_iter_order_t order; /* Order to iterate in index */ + hsize_t n; /* Offset of link within index */ + hid_t dxpl_id; /* DXPL to use in callback */ +} H5L_trav_rmbi_t; /* Structure for external link traversal callback property */ typedef struct H5L_elink_cb_t { @@ -85,9 +132,21 @@ H5_DLL herr_t H5L_get_info(const H5G_loc_t *loc, const char *name, H5L_info_t *linkbuf/*out*/, hid_t lapl_id, hid_t dxpl_id); H5_DLL herr_t H5L_delete(H5G_loc_t *loc, const char *name, hid_t lapl_id, hid_t dxpl_id); +H5_DLL herr_t H5L_delete_by_idx(H5G_loc_t *loc, const char *name, + void *udata, hid_t lapl_id, hid_t dxpl_id); +H5_DLL htri_t H5L_exists(const H5G_loc_t *loc, const char *name, hid_t lapl_id, hid_t dxpl_id); +H5_DLL herr_t H5L_get_info_by_idx(H5G_loc_t *loc, const char *name, void *udata, + hid_t lapl_id, hid_t dxpl_id); +H5_DLL herr_t H5L_get_name_by_idx(H5G_loc_t *loc, const char *name, void *udata, + hid_t lapl_id, hid_t dxpl_id); H5_DLL herr_t H5L_get_val(H5G_loc_t *loc, const char *name, void *buf/*out*/, size_t size, hid_t lapl_id, hid_t dxpl_id); +H5_DLL herr_t H5L_get_val_by_idx(H5G_loc_t *loc, const char *name, void *udata, + hid_t lapl_id, hid_t dxpl_id); H5_DLL herr_t H5L_register_external(void); +H5_DLL herr_t H5L_iterate(void *obj, H5VL_loc_params_t loc_params, hbool_t recursive, + H5_index_t idx_type, H5_iter_order_t order, hsize_t *idx_p, + H5L_iterate_t op, void *op_data, hid_t dxpl_id); /* User-defined link functions */ H5_DLL herr_t H5L_register(const H5L_class_t *cls); @@ -46,7 +46,7 @@ #include "H5MFprivate.h" /* File memory management */ #include "H5Opkg.h" /* Object headers */ #include "H5SMprivate.h" /* Shared object header messages */ - +#include "H5VLprivate.h" /* Virtual Object Layer */ /****************/ /* Local Macros */ @@ -80,9 +80,6 @@ typedef struct { static herr_t H5O_delete_oh(H5F_t *f, hid_t dxpl_id, H5O_t *oh); static herr_t H5O_obj_type_real(H5O_t *oh, H5O_type_t *obj_type); -static herr_t H5O_visit(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, hid_t lapl_id, - hid_t dxpl_id); static herr_t H5O_get_hdr_info_real(const H5O_t *oh, H5O_hdr_info_t *hdr); static const H5O_obj_class_t *H5O_obj_class_real(H5O_t *oh); @@ -230,22 +227,34 @@ H5O_init_interface(void) hid_t H5Oopen(hid_t loc_id, const char *name, hid_t lapl_id) { - H5G_loc_t loc; - hid_t ret_value = FAIL; + H5VL_object_t *obj = NULL; /* object token of loc_id */ + H5I_type_t opened_type; + void *opened_obj = NULL; + H5VL_loc_params_t loc_params; + hid_t ret_value = FAIL; FUNC_ENTER_API(FAIL) H5TRACE3("i", "i*si", loc_id, name, lapl_id); - /* Check args */ - 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") - /* Open the object */ - if((ret_value = H5O_open_name(&loc, name, lapl_id, TRUE)) < 0) - HGOTO_ERROR(H5E_SYM, H5E_CANTOPENOBJ, FAIL, "unable to open object") + /* get the location object */ + if(NULL == (obj = (H5VL_object_t *)H5I_object(loc_id))) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "invalid location identifier") + 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 = lapl_id; + loc_params.obj_type = H5I_get_type(loc_id); + + /* Open the object through the VOL */ + if(NULL == (opened_obj = H5VL_object_open(obj->vol_obj, loc_params, obj->vol_info->vol_cls, &opened_type, + H5AC_dxpl_id, H5_REQUEST_NULL))) + HGOTO_ERROR(H5E_SYM, H5E_CANTOPENOBJ, FAIL, "unable to open object") + + if((ret_value = H5VL_register_id(opened_type, opened_obj, obj->vol_info, TRUE)) < 0) + HGOTO_ERROR(H5E_ATOM, H5E_CANTREGISTER, FAIL, "unable to atomize object handle") done: FUNC_LEAVE_API(ret_value) } /* end H5Oopen() */ @@ -278,19 +287,16 @@ 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) { - H5G_loc_t loc; - 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 */ - hbool_t loc_found = FALSE; /* Entry at 'name' found */ - hid_t ret_value = FAIL; + H5VL_object_t *obj = NULL; /* object token of loc_id */ + H5I_type_t opened_type; + void *opened_obj = NULL; + H5VL_loc_params_t loc_params; + hid_t ret_value = FAIL; FUNC_ENTER_API(FAIL) H5TRACE6("i", "i*sIiIohi", loc_id, group_name, idx_type, order, n, lapl_id); /* Check args */ - if(H5G_loc(loc_id, &loc) < 0) - HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a location") if(!group_name || !*group_name) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "no name specified") if(idx_type <= H5_INDEX_UNKNOWN || idx_type >= H5_INDEX_N) @@ -303,26 +309,27 @@ H5Oopen_by_idx(hid_t loc_id, const char *group_name, H5_index_t idx_type, if(TRUE != H5P_isa_class(lapl_id, H5P_LINK_ACCESS)) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not link access property list ID") - /* Set up opened group location to fill in */ - obj_loc.oloc = &obj_oloc; - obj_loc.path = &obj_path; - H5G_loc_reset(&obj_loc); + loc_params.type = H5VL_OBJECT_BY_IDX; + loc_params.loc_data.loc_by_idx.name = group_name; + loc_params.loc_data.loc_by_idx.idx_type = idx_type; + loc_params.loc_data.loc_by_idx.order = order; + loc_params.loc_data.loc_by_idx.n = n; + loc_params.loc_data.loc_by_idx.lapl_id = lapl_id; + loc_params.obj_type = H5I_get_type(loc_id); - /* Find the object's location, according to the order in the index */ - if(H5G_loc_find_by_idx(&loc, group_name, idx_type, order, n, &obj_loc/*out*/, lapl_id, H5AC_dxpl_id) < 0) - HGOTO_ERROR(H5E_SYM, H5E_NOTFOUND, FAIL, "group not found") - loc_found = TRUE; + /* get the location object */ + if(NULL == (obj = (H5VL_object_t *)H5I_object(loc_id))) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "invalid location identifier") - /* Open the object */ - if((ret_value = H5O_open_by_loc(&obj_loc, lapl_id, H5AC_dxpl_id, TRUE)) < 0) - HGOTO_ERROR(H5E_SYM, H5E_CANTOPENOBJ, FAIL, "unable to open object") + /* Open the object through the VOL */ + if(NULL == (opened_obj = H5VL_object_open(obj->vol_obj, loc_params, obj->vol_info->vol_cls, &opened_type, + H5AC_dxpl_id, H5_REQUEST_NULL))) + HGOTO_ERROR(H5E_SYM, H5E_CANTOPENOBJ, FAIL, "unable to open object") -done: - /* Release the object location if we failed after copying it */ - if(ret_value < 0 && loc_found) - if(H5G_loc_free(&obj_loc) < 0) - HDONE_ERROR(H5E_SYM, H5E_CANTRELEASE, FAIL, "can't free location") + if((ret_value = H5VL_register_id(opened_type, opened_obj, obj->vol_info, TRUE)) < 0) + HGOTO_ERROR(H5E_ATOM, H5E_CANTREGISTER, FAIL, "unable to atomize object handle") +done: FUNC_LEAVE_API(ret_value) } /* end H5Oopen_by_idx() */ @@ -365,36 +372,32 @@ done: hid_t H5Oopen_by_addr(hid_t loc_id, haddr_t addr) { - H5G_loc_t loc; - 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 */ - hid_t lapl_id = H5P_LINK_ACCESS_DEFAULT; /* lapl to use to open this object */ - hid_t ret_value = FAIL; + H5VL_object_t *obj = NULL; /* object token of loc_id */ + H5I_type_t opened_type; + void *opened_obj = NULL; + H5VL_loc_params_t loc_params; + hid_t ret_value = FAIL; FUNC_ENTER_API(FAIL) H5TRACE2("i", "ia", loc_id, addr); - /* Check args */ - if(H5G_loc(loc_id, &loc) < 0) - HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a location") - if(!H5F_addr_defined(addr)) - HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "no address supplied") + loc_params.type = H5VL_OBJECT_BY_ADDR; + loc_params.loc_data.loc_by_addr.addr = addr; + loc_params.obj_type = H5I_get_type(loc_id); - /* Set up opened group location to fill in */ - obj_loc.oloc = &obj_oloc; - obj_loc.path = &obj_path; - H5G_loc_reset(&obj_loc); - obj_loc.oloc->addr = addr; - obj_loc.oloc->file = loc.oloc->file; - H5G_name_reset(obj_loc.path); /* objects opened through this routine don't have a path name */ + /* get the location object */ + if(NULL == (obj = (H5VL_object_t *)H5I_object(loc_id))) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "invalid location identifier") - /* Open the object */ - if((ret_value = H5O_open_by_loc(&obj_loc, lapl_id, H5AC_dxpl_id, TRUE)) < 0) - HGOTO_ERROR(H5E_SYM, H5E_CANTOPENOBJ, FAIL, "unable to open object") + /* Open the object through the VOL */ + if(NULL == (opened_obj = H5VL_object_open(obj->vol_obj, loc_params, obj->vol_info->vol_cls, &opened_type, + H5AC_dxpl_id, H5_REQUEST_NULL))) + HGOTO_ERROR(H5E_SYM, H5E_CANTOPENOBJ, FAIL, "unable to open object") -done: + if((ret_value = H5VL_register_id(opened_type, opened_obj, obj->vol_info, TRUE)) < 0) + HGOTO_ERROR(H5E_ATOM, H5E_CANTREGISTER, FAIL, "unable to atomize object handle") +done: FUNC_LEAVE_API(ret_value) } /* end H5Oopen_by_addr() */ @@ -424,20 +427,19 @@ herr_t H5Olink(hid_t obj_id, hid_t new_loc_id, const char *new_name, hid_t lcpl_id, hid_t lapl_id) { - H5G_loc_t new_loc; - H5G_loc_t obj_loc; - herr_t ret_value = SUCCEED; /* Return value */ + H5VL_object_t *obj1 = NULL; /* object token of obj_id */ + H5VL_object_t *obj2 = NULL; /* object token of new_loc_id */ + H5VL_loc_params_t loc_params1; + H5VL_loc_params_t loc_params2; + H5P_genplist_t *plist; /* Property list pointer */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_API(FAIL) H5TRACE5("e", "ii*sii", obj_id, new_loc_id, new_name, lcpl_id, lapl_id); /* Check arguments */ - if(H5G_loc(obj_id, &obj_loc) < 0) - HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a location") if(new_loc_id == H5L_SAME_LOC) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "cannot use H5L_SAME_LOC when only one location is specified") - if(H5G_loc(new_loc_id, &new_loc) < 0) - HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a location") if(!new_name || !*new_name) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "no name specified") /* Avoid compiler warning on 32-bit machines */ @@ -448,9 +450,49 @@ H5Olink(hid_t obj_id, hid_t new_loc_id, const char *new_name, hid_t lcpl_id, if(lcpl_id != H5P_DEFAULT && (TRUE != H5P_isa_class(lcpl_id, H5P_LINK_CREATE))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a link creation property list") - /* Link to the object */ - if(H5L_link(&new_loc, new_name, &obj_loc, lcpl_id, lapl_id, H5AC_dxpl_id) < 0) - HGOTO_ERROR(H5E_LINK, H5E_CANTINIT, FAIL, "unable to create link") + /* Check the group access property list */ + if(H5P_DEFAULT == lcpl_id) + lcpl_id = H5P_LINK_CREATE_DEFAULT; + + loc_params1.type = H5VL_OBJECT_BY_SELF; + loc_params1.obj_type = H5I_get_type(obj_id); + + loc_params2.type = H5VL_OBJECT_BY_NAME; + loc_params2.obj_type = H5I_get_type(new_loc_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) { + /* get the location object */ + if(NULL == (obj1 = H5VL_get_object(obj_id))) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "invalid location identifier") + } + if(H5L_SAME_LOC != new_loc_id) { + /* get the location object */ + if(NULL == (obj2 = H5VL_get_object(new_loc_id))) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "invalid location identifier") + } + /* Make sure that the VOL plugins are the same */ + if(obj1 && obj2) { + if (obj1->vol_info->vol_cls->value != obj2->vol_info->vol_cls->value) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "Objects are accessed through different VOL plugins and can't be linked") + } + + /* 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") + + /* set creation properties */ + if(H5P_set(plist, H5VL_PROP_LINK_TARGET, &obj1->vol_obj) < 0) + HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, FAIL, "can't set property value for target 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") + + /* Create the link through the VOL */ + if(H5VL_link_create(H5VL_LINK_CREATE_HARD, obj2->vol_obj, loc_params2, + (obj1!=NULL ? obj1->vol_info->vol_cls : obj2->vol_info->vol_cls), + lcpl_id, lapl_id, H5AC_dxpl_id, H5_REQUEST_NULL) < 0) + HGOTO_ERROR(H5E_SYM, H5E_CANTINIT, FAIL, "unable to create link") done: FUNC_LEAVE_API(ret_value) @@ -480,17 +522,23 @@ done: herr_t H5Oincr_refcount(hid_t object_id) { - H5O_loc_t *oloc; + H5VL_object_t *obj = NULL; /* object token of loc_id */ + H5VL_loc_params_t loc_params; herr_t ret_value = SUCCEED; FUNC_ENTER_API(FAIL) H5TRACE1("e", "i", object_id); - /* Get the object's oloc so we can adjust its link count */ - if((oloc = H5O_get_loc(object_id)) == NULL) - HGOTO_ERROR(H5E_ATOM, H5E_BADVALUE, FAIL, "unable to get object location from ID") + loc_params.type = H5VL_OBJECT_BY_SELF; + loc_params.obj_type = H5I_get_type(object_id); + + /* get the location object */ + if(NULL == (obj = H5VL_get_object(object_id))) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "invalid location identifier") - if(H5O_link(oloc, 1, H5AC_dxpl_id) < 0) + /* change the ref count through the VOL */ + if(H5VL_object_specific(obj->vol_obj, loc_params, obj->vol_info->vol_cls, H5VL_OBJECT_CHANGE_REF_COUNT, + H5AC_dxpl_id, H5_REQUEST_NULL, 1) < 0) HGOTO_ERROR(H5E_OHDR, H5E_LINKCOUNT, FAIL, "modifying object link count failed") done: @@ -521,17 +569,23 @@ done: herr_t H5Odecr_refcount(hid_t object_id) { - H5O_loc_t *oloc; + H5VL_object_t *obj = NULL; /* object token of loc_id */ + H5VL_loc_params_t loc_params; herr_t ret_value = SUCCEED; FUNC_ENTER_API(FAIL) H5TRACE1("e", "i", object_id); - /* Get the object's oloc so we can adjust its link count */ - if((oloc = H5O_get_loc(object_id)) == NULL) - HGOTO_ERROR(H5E_ATOM, H5E_BADVALUE, FAIL, "unable to get object location from ID") + loc_params.type = H5VL_OBJECT_BY_SELF; + loc_params.obj_type = H5I_get_type(object_id); - if(H5O_link(oloc, -1, H5AC_dxpl_id) < 0) + /* get the location object */ + if(NULL == (obj = H5VL_get_object(object_id))) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "invalid location identifier") + + /* change the ref count through the VOL */ + if(H5VL_object_specific(obj->vol_obj, loc_params, obj->vol_info->vol_cls, H5VL_OBJECT_CHANGE_REF_COUNT, + H5AC_dxpl_id, H5_REQUEST_NULL, -1) < 0) HGOTO_ERROR(H5E_OHDR, H5E_LINKCOUNT, FAIL, "modifying object link count failed") done: @@ -555,15 +609,14 @@ done: htri_t H5Oexists_by_name(hid_t loc_id, const char *name, hid_t lapl_id) { - H5G_loc_t loc; /* Location info */ - htri_t ret_value = FAIL; /* Return value */ + H5VL_object_t *obj = NULL; /* object token of loc_id */ + H5VL_loc_params_t loc_params; + htri_t ret_value = FAIL; /* Return value */ FUNC_ENTER_API(FAIL) H5TRACE3("t", "i*si", loc_id, name, lapl_id); /* Check args */ - 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") if(H5P_DEFAULT == lapl_id) @@ -572,8 +625,18 @@ H5Oexists_by_name(hid_t loc_id, const char *name, hid_t lapl_id) if(TRUE != H5P_isa_class(lapl_id, H5P_LINK_ACCESS)) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not link access property list ID") - /* Check if the object exists */ - if((ret_value = H5G_loc_exists(&loc, name, lapl_id, H5AC_dxpl_id)) < 0) + 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 = lapl_id; + loc_params.obj_type = H5I_get_type(loc_id); + + /* get the location object */ + if(NULL == (obj = H5VL_get_object(loc_id))) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "invalid location identifier") + + /* change the ref count through the VOL */ + if(H5VL_object_specific(obj->vol_obj, loc_params, obj->vol_info->vol_cls, H5VL_OBJECT_EXISTS, + H5AC_dxpl_id, H5_REQUEST_NULL, &ret_value) < 0) HGOTO_ERROR(H5E_OHDR, H5E_CANTGET, FAIL, "unable to determine if '%s' exists", name) done: @@ -597,21 +660,28 @@ done: herr_t H5Oget_info(hid_t loc_id, H5O_info_t *oinfo) { - H5G_loc_t loc; /* Location of group */ + H5VL_object_t *obj = NULL; /* object token of loc_id */ + H5VL_loc_params_t loc_params; herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_API(FAIL) H5TRACE2("e", "i*x", loc_id, oinfo); /* Check args */ - if(H5G_loc(loc_id, &loc) < 0) - HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a location") if(!oinfo) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "no info struct") - /* Retrieve the object's information */ - if(H5G_loc_info(&loc, ".", TRUE, oinfo/*out*/, H5P_LINK_ACCESS_DEFAULT, H5AC_ind_dxpl_id) < 0) - HGOTO_ERROR(H5E_SYM, H5E_NOTFOUND, FAIL, "object not found") + loc_params.type = H5VL_OBJECT_BY_SELF; + loc_params.obj_type = H5I_get_type(loc_id); + + /* get the location object */ + if(NULL == (obj = H5VL_get_object(loc_id))) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "invalid location identifier") + + /* Get the group info through the VOL using the location token */ + if(H5VL_object_optional(obj->vol_obj, obj->vol_info->vol_cls, H5AC_ind_dxpl_id, H5_REQUEST_NULL, + H5VL_OBJECT_GET_INFO, loc_params, oinfo) < 0) + HGOTO_ERROR(H5E_INTERNAL, H5E_CANTGET, FAIL, "unable to get group info") done: FUNC_LEAVE_API(ret_value) @@ -634,15 +704,14 @@ done: herr_t H5Oget_info_by_name(hid_t loc_id, const char *name, H5O_info_t *oinfo, hid_t lapl_id) { - H5G_loc_t loc; /* Location of group */ + H5VL_object_t *obj = NULL; /* object token of loc_id */ + H5VL_loc_params_t loc_params; herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_API(FAIL) H5TRACE4("e", "i*s*xi", loc_id, name, oinfo, lapl_id); /* Check args */ - 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") if(!oinfo) @@ -653,9 +722,19 @@ H5Oget_info_by_name(hid_t loc_id, const char *name, H5O_info_t *oinfo, hid_t lap if(TRUE != H5P_isa_class(lapl_id, H5P_LINK_ACCESS)) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not link access property list ID") - /* Retrieve the object's information */ - if(H5G_loc_info(&loc, name, TRUE, oinfo/*out*/, lapl_id, H5AC_ind_dxpl_id) < 0) - HGOTO_ERROR(H5E_SYM, H5E_NOTFOUND, FAIL, "object not found") + 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 = lapl_id; + loc_params.obj_type = H5I_get_type(loc_id); + + /* get the location object */ + if(NULL == (obj = H5VL_get_object(loc_id))) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "invalid location identifier") + + /* Get the group info through the VOL using the location token */ + if(H5VL_object_optional(obj->vol_obj, obj->vol_info->vol_cls, H5AC_ind_dxpl_id, H5_REQUEST_NULL, + H5VL_OBJECT_GET_INFO, loc_params, oinfo) < 0) + HGOTO_ERROR(H5E_INTERNAL, H5E_CANTGET, FAIL, "unable to get group info") done: FUNC_LEAVE_API(ret_value) @@ -680,11 +759,8 @@ herr_t H5Oget_info_by_idx(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, hid_t lapl_id) { - H5G_loc_t loc; /* Location of group */ - 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 */ - hbool_t loc_found = FALSE; /* Entry at 'name' found */ + H5VL_object_t *obj = NULL; /* object token of loc_id */ + H5VL_loc_params_t loc_params; herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_API(FAIL) @@ -692,8 +768,6 @@ H5Oget_info_by_idx(hid_t loc_id, const char *group_name, H5_index_t idx_type, lapl_id); /* Check args */ - if(H5G_loc(loc_id, &loc) < 0) - HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a location") if(!group_name || !*group_name) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "no name specified") if(idx_type <= H5_INDEX_UNKNOWN || idx_type >= H5_INDEX_N) @@ -708,25 +782,24 @@ H5Oget_info_by_idx(hid_t loc_id, const char *group_name, H5_index_t idx_type, if(TRUE != H5P_isa_class(lapl_id, H5P_LINK_ACCESS)) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not link access property list ID") - /* Set up opened group location to fill in */ - obj_loc.oloc = &obj_oloc; - obj_loc.path = &obj_path; - H5G_loc_reset(&obj_loc); + loc_params.type = H5VL_OBJECT_BY_IDX; + loc_params.loc_data.loc_by_idx.name = group_name; + loc_params.loc_data.loc_by_idx.idx_type = idx_type; + loc_params.loc_data.loc_by_idx.order = order; + loc_params.loc_data.loc_by_idx.n = n; + loc_params.loc_data.loc_by_idx.lapl_id = lapl_id; + loc_params.obj_type = H5I_get_type(loc_id); - /* Find the object's location, according to the order in the index */ - if(H5G_loc_find_by_idx(&loc, group_name, idx_type, order, n, &obj_loc/*out*/, lapl_id, H5AC_ind_dxpl_id) < 0) - HGOTO_ERROR(H5E_SYM, H5E_NOTFOUND, FAIL, "group not found") - loc_found = TRUE; + /* get the location object */ + if(NULL == (obj = H5VL_get_object(loc_id))) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "invalid location identifier") - /* Retrieve the object's information */ - if(H5O_get_info(obj_loc.oloc, H5AC_ind_dxpl_id, TRUE, oinfo) < 0) - HGOTO_ERROR(H5E_SYM, H5E_CANTGET, FAIL, "can't retrieve object info") + /* Get the group info through the VOL using the location token */ + if(H5VL_object_optional(obj->vol_obj, obj->vol_info->vol_cls, H5AC_ind_dxpl_id, H5_REQUEST_NULL, + H5VL_OBJECT_GET_INFO, loc_params, oinfo) < 0) + HGOTO_ERROR(H5E_INTERNAL, H5E_CANTGET, FAIL, "unable to get group info") done: - /* Release the object location */ - if(loc_found && H5G_loc_free(&obj_loc) < 0) - HDONE_ERROR(H5E_SYM, H5E_CANTRELEASE, FAIL, "can't free location") - FUNC_LEAVE_API(ret_value) } /* end H5Oget_info_by_idx() */ @@ -751,19 +824,24 @@ done: herr_t H5Oset_comment(hid_t obj_id, const char *comment) { - H5G_loc_t loc; /* Location of group */ + H5VL_object_t *obj = NULL; /* object token of loc_id */ + H5VL_loc_params_t loc_params; herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_API(FAIL) H5TRACE2("e", "i*s", obj_id, comment); - /* Check args */ - if(H5G_loc(obj_id, &loc) < 0) - HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a location") + loc_params.type = H5VL_OBJECT_BY_SELF; + loc_params.obj_type = H5I_get_type(obj_id); - /* (Re)set the object's comment */ - if(H5G_loc_set_comment(&loc, ".", comment, H5P_LINK_ACCESS_DEFAULT, H5AC_ind_dxpl_id) < 0) - HGOTO_ERROR(H5E_SYM, H5E_NOTFOUND, FAIL, "object not found") + /* get the location object */ + if(NULL == (obj = H5VL_get_object(obj_id))) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "invalid location identifier") + + /* set comment on object through the VOL */ + if(H5VL_object_optional(obj->vol_obj, obj->vol_info->vol_cls, H5AC_ind_dxpl_id, H5_REQUEST_NULL, + H5VL_OBJECT_SET_COMMENT, loc_params, comment) < 0) + HGOTO_ERROR(H5E_SYM, H5E_CANTINIT, FAIL, "unable to set comment value") done: FUNC_LEAVE_API(ret_value) @@ -791,15 +869,14 @@ herr_t H5Oset_comment_by_name(hid_t loc_id, const char *name, const char *comment, hid_t lapl_id) { - H5G_loc_t loc; /* Location of group */ + H5VL_object_t *obj = NULL; /* object token of loc_id */ + H5VL_loc_params_t loc_params; herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_API(FAIL) H5TRACE4("e", "i*s*si", loc_id, name, comment, lapl_id); /* Check args */ - 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") if(H5P_DEFAULT == lapl_id) @@ -808,9 +885,19 @@ H5Oset_comment_by_name(hid_t loc_id, const char *name, const char *comment, if(TRUE != H5P_isa_class(lapl_id, H5P_LINK_ACCESS)) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not link access property list ID") - /* (Re)set the object's comment */ - if(H5G_loc_set_comment(&loc, name, comment, lapl_id, H5AC_ind_dxpl_id) < 0) - HGOTO_ERROR(H5E_SYM, H5E_NOTFOUND, FAIL, "object not found") + 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 = lapl_id; + loc_params.obj_type = H5I_get_type(loc_id); + + /* get the location object */ + if(NULL == (obj = H5VL_get_object(loc_id))) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "invalid location identifier") + + /* set comment on object through the VOL */ + if(H5VL_object_optional(obj->vol_obj, obj->vol_info->vol_cls, H5AC_ind_dxpl_id, H5_REQUEST_NULL, + H5VL_OBJECT_SET_COMMENT, loc_params, comment) < 0) + HGOTO_ERROR(H5E_SYM, H5E_CANTINIT, FAIL, "unable to set comment value") done: FUNC_LEAVE_API(ret_value) @@ -834,21 +921,25 @@ done: *------------------------------------------------------------------------- */ ssize_t -H5Oget_comment(hid_t obj_id, char *comment, size_t bufsize) +H5Oget_comment(hid_t loc_id, char *comment, size_t bufsize) { - H5G_loc_t loc; /* Location of group */ + H5VL_object_t *obj = NULL; /* object token of loc_id */ + H5VL_loc_params_t loc_params; ssize_t ret_value; /* Return value */ FUNC_ENTER_API(FAIL) - H5TRACE3("Zs", "i*sz", obj_id, comment, bufsize); + H5TRACE3("Zs", "i*sz", loc_id, comment, bufsize); - /* Check args */ - if(H5G_loc(obj_id, &loc) < 0) - HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a location") + loc_params.type = H5VL_OBJECT_BY_SELF; + loc_params.obj_type = H5I_get_type(loc_id); - /* Retrieve the object's comment */ - if((ret_value = H5G_loc_get_comment(&loc, ".", comment/*out*/, bufsize, H5P_LINK_ACCESS_DEFAULT, H5AC_ind_dxpl_id)) < 0) - HGOTO_ERROR(H5E_SYM, H5E_NOTFOUND, FAIL, "object not found") + /* get the location object */ + if(NULL == (obj = H5VL_get_object(loc_id))) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "invalid location identifier") + + if(H5VL_object_optional(obj->vol_obj, obj->vol_info->vol_cls, H5AC_ind_dxpl_id, H5_REQUEST_NULL, + H5VL_OBJECT_GET_COMMENT, loc_params, comment, bufsize, &ret_value) < 0) + HGOTO_ERROR(H5E_INTERNAL, H5E_CANTGET, FAIL, "unable to get object comment") done: FUNC_LEAVE_API(ret_value) @@ -875,15 +966,14 @@ ssize_t H5Oget_comment_by_name(hid_t loc_id, const char *name, char *comment, size_t bufsize, hid_t lapl_id) { - H5G_loc_t loc; /* Location of group */ + H5VL_object_t *obj = NULL; /* object token of loc_id */ + H5VL_loc_params_t loc_params; ssize_t ret_value; /* Return value */ FUNC_ENTER_API(FAIL) H5TRACE5("Zs", "i*s*szi", loc_id, name, comment, bufsize, lapl_id); /* Check args */ - 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") if(H5P_DEFAULT == lapl_id) @@ -892,9 +982,18 @@ H5Oget_comment_by_name(hid_t loc_id, const char *name, char *comment, size_t buf if(TRUE != H5P_isa_class(lapl_id, H5P_LINK_ACCESS)) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not link access property list ID") - /* Retrieve the object's comment */ - if((ret_value = H5G_loc_get_comment(&loc, name, comment/*out*/, bufsize, lapl_id, H5AC_ind_dxpl_id)) < 0) - HGOTO_ERROR(H5E_SYM, H5E_NOTFOUND, FAIL, "object not found") + 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 = lapl_id; + loc_params.obj_type = H5I_get_type(loc_id); + + /* get the location object */ + if(NULL == (obj = H5VL_get_object(loc_id))) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "invalid location identifier") + + if(H5VL_object_optional(obj->vol_obj, obj->vol_info->vol_cls, H5AC_ind_dxpl_id, H5_REQUEST_NULL, + H5VL_OBJECT_GET_COMMENT, loc_params, comment, bufsize, &ret_value) < 0) + HGOTO_ERROR(H5E_INTERNAL, H5E_CANTGET, FAIL, "unable to get object info") done: FUNC_LEAVE_API(ret_value) @@ -937,6 +1036,8 @@ herr_t H5Ovisit(hid_t obj_id, H5_index_t idx_type, H5_iter_order_t order, H5O_iterate_t op, void *op_data) { + H5VL_object_t *obj = NULL; /* object token of loc_id */ + H5VL_loc_params_t loc_params; herr_t ret_value; /* Return value */ FUNC_ENTER_API(FAIL) @@ -950,9 +1051,18 @@ H5Ovisit(hid_t obj_id, H5_index_t idx_type, H5_iter_order_t order, if(!op) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "no callback operator specified") - /* Call internal object visitation routine */ - if((ret_value = H5O_visit(obj_id, ".", idx_type, order, op, op_data, H5P_LINK_ACCESS_DEFAULT, H5AC_ind_dxpl_id)) < 0) - HGOTO_ERROR(H5E_SYM, H5E_BADITER, FAIL, "object visitation failed") + loc_params.type = H5VL_OBJECT_BY_SELF; + loc_params.obj_type = H5I_get_type(obj_id); + + /* get the location object */ + if(NULL == (obj = H5VL_get_object(obj_id))) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "invalid location identifier") + + /* iterate over the objects through the VOL */ + if((ret_value = H5VL_object_specific(obj->vol_obj, loc_params, obj->vol_info->vol_cls, + H5VL_OBJECT_VISIT, H5AC_ind_dxpl_id, H5_REQUEST_NULL, + idx_type, order, op, op_data)) < 0) + HGOTO_ERROR(H5E_SYM, H5E_BADITER, FAIL, "link iteration failed") done: FUNC_LEAVE_API(ret_value) @@ -995,6 +1105,8 @@ herr_t H5Ovisit_by_name(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, hid_t lapl_id) { + H5VL_object_t *obj = NULL; /* object token of loc_id */ + H5VL_loc_params_t loc_params; herr_t ret_value; /* Return value */ FUNC_ENTER_API(FAIL) @@ -1016,9 +1128,20 @@ H5Ovisit_by_name(hid_t loc_id, const char *obj_name, H5_index_t idx_type, if(TRUE != H5P_isa_class(lapl_id, H5P_LINK_ACCESS)) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not link access property list ID") - /* Call internal object visitation routine */ - if((ret_value = H5O_visit(loc_id, obj_name, idx_type, order, op, op_data, lapl_id, H5AC_ind_dxpl_id)) < 0) - HGOTO_ERROR(H5E_SYM, H5E_BADITER, FAIL, "object visitation failed") + loc_params.type = H5VL_OBJECT_BY_NAME; + loc_params.loc_data.loc_by_name.name = obj_name; + loc_params.loc_data.loc_by_name.lapl_id = lapl_id; + loc_params.obj_type = H5I_get_type(loc_id); + + /* get the location object */ + if(NULL == (obj = H5VL_get_object(loc_id))) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "invalid location identifier") + + /* iterate over the objects through the VOL */ + if((ret_value = H5VL_object_specific(obj->vol_obj, loc_params, obj->vol_info->vol_cls, + H5VL_OBJECT_VISIT, H5AC_ind_dxpl_id, H5_REQUEST_NULL, + idx_type, order, op, op_data)) < 0) + HGOTO_ERROR(H5E_SYM, H5E_BADITER, FAIL, "link iteration failed") done: FUNC_LEAVE_API(ret_value) @@ -1069,6 +1192,7 @@ H5Oclose(hid_t object_id) case H5I_ATTR: case H5I_REFERENCE: case H5I_VFL: + case H5I_VOL: case H5I_GENPROP_CLS: case H5I_GENPROP_LST: case H5I_ERROR_CLASS: @@ -1443,7 +1567,7 @@ H5O_close(H5O_loc_t *loc) #ifdef H5O_DEBUG if(H5DEBUG(O)) { - if(H5F_FILE_ID(loc->file)< 0 && 1 == H5F_NREFS(loc->file)) + if(H5F_FILE_ID(loc->file) && 1 == H5F_NREFS(loc->file)) HDfprintf(H5DEBUG(O), "< %a auto %lu remaining\n", loc->addr, (unsigned long)H5F_NOPEN_OBJS(loc->file)); @@ -1456,10 +1580,11 @@ H5O_close(H5O_loc_t *loc) * If the file open object count has reached the number of open mount points * (each of which has a group open in the file) attempt to close the file. */ - if(H5F_NOPEN_OBJS(loc->file) == H5F_NMOUNTS(loc->file)) + if(H5F_NOPEN_OBJS(loc->file) == H5F_NMOUNTS(loc->file)) { /* Attempt to close down the file hierarchy */ if(H5F_try_close(loc->file) < 0) HGOTO_ERROR(H5E_OHDR, H5E_CANTCLOSEFILE, FAIL, "problem attempting file close") + } /* Release location information */ if(H5O_loc_free(loc) < 0) @@ -2474,6 +2599,7 @@ H5O_get_loc(hid_t object_id) case H5I_ATTR: case H5I_REFERENCE: case H5I_VFL: + case H5I_VOL: case H5I_GENPROP_CLS: case H5I_GENPROP_LST: case H5I_ERROR_CLASS: @@ -3254,13 +3380,12 @@ done: * *------------------------------------------------------------------------- */ -static herr_t -H5O_visit(hid_t loc_id, const char *obj_name, H5_index_t idx_type, +herr_t +H5O_visit(H5G_loc_t *loc, const char *obj_name, H5_index_t idx_type, H5_iter_order_t order, H5O_iterate_t op, void *op_data, hid_t lapl_id, hid_t dxpl_id) { H5O_iter_visit_ud_t udata; /* User data for callback */ - H5G_loc_t loc; /* Location of reference object */ H5G_loc_t obj_loc; /* Location used to open object */ H5G_name_t obj_path; /* Opened object group hier. path */ H5O_loc_t obj_oloc; /* Opened object object location */ @@ -3274,17 +3399,13 @@ H5O_visit(hid_t loc_id, const char *obj_name, H5_index_t idx_type, /* Portably initialize user data struct to zeros */ HDmemset(&udata, 0, sizeof(udata)); - /* Check args */ - if(H5G_loc(loc_id, &loc) < 0) - HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a 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 */ - if(H5G_loc_find(&loc, obj_name, &obj_loc/*out*/, lapl_id, dxpl_id) < 0) + if(H5G_loc_find(loc, obj_name, &obj_loc/*out*/, lapl_id, dxpl_id) < 0) HGOTO_ERROR(H5E_OHDR, H5E_NOTFOUND, FAIL, "object not found") loc_found = TRUE; @@ -3297,6 +3418,21 @@ H5O_visit(hid_t loc_id, const char *obj_name, H5_index_t idx_type, if((obj_id = H5O_open_by_loc(&obj_loc, lapl_id, dxpl_id, TRUE)) < 0) HGOTO_ERROR(H5E_OHDR, H5E_CANTOPENOBJ, FAIL, "unable to open object") + /* get the native object from the ID created by the object header and create + a "VOL object" ID */ + { + void *temp_obj = NULL; + H5I_type_t obj_type; + + obj_type = H5I_get_type(obj_id); + if(NULL == (temp_obj = H5I_remove(obj_id))) + HGOTO_ERROR(H5E_SYM, H5E_CANTOPENOBJ, FAIL, "unable to open object") + + /* Get an atom for the datatype */ + if((obj_id = H5VL_native_register(obj_type, temp_obj, TRUE)) < 0) + HGOTO_ERROR(H5E_ATOM, H5E_CANTREGISTER, FAIL, "unable to register datatype") + } + /* Make callback for starting object */ if((ret_value = op(obj_id, ".", &oinfo, op_data)) < 0) HGOTO_ERROR(H5E_OHDR, H5E_BADITER, FAIL, "can't visit objects") @@ -3308,6 +3444,7 @@ H5O_visit(hid_t loc_id, const char *obj_name, H5_index_t idx_type, /* Check for object being a group */ if(oinfo.type == H5O_TYPE_GROUP) { H5G_loc_t start_loc; /* Location of starting group */ + H5G_loc_t vis_loc; /* Location of visited group */ /* Get the location of the starting group */ if(H5G_loc(obj_id, &start_loc) < 0) @@ -3343,8 +3480,12 @@ H5O_visit(hid_t loc_id, const char *obj_name, H5_index_t idx_type, HGOTO_ERROR(H5E_OHDR, H5E_CANTINSERT, FAIL, "can't insert object node into visited list") } /* end if */ + /* Get the location of the visited group */ + if(H5G_loc(obj_id, &vis_loc) < 0) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a location") /* Call internal group visitation routine */ - if((ret_value = H5G_visit(obj_id, ".", idx_type, order, H5O_visit_cb, &udata, lapl_id, dxpl_id)) < 0) + if((ret_value = H5G_visit(&vis_loc, ".", idx_type, order, H5O_visit_cb, &udata, + lapl_id, dxpl_id)) < 0) HGOTO_ERROR(H5E_OHDR, H5E_BADITER, FAIL, "object visitation failed") } /* end if */ diff --git a/src/H5Oattribute.c b/src/H5Oattribute.c index 30ec732..d87cb5f 100644 --- a/src/H5Oattribute.c +++ b/src/H5Oattribute.c @@ -726,7 +726,7 @@ H5O_attr_find_opened_attr(const H5O_loc_t *loc, H5A_t **attr, const char* name_t unsigned long attr_fnum; /* Attributes file serial number */ /* Get pointer to attribute */ - if(NULL == (*attr = (H5A_t *)H5I_object_verify(attr_id_list[u], H5I_ATTR))) + if(NULL == (*attr = (H5A_t *)H5VL_object_verify(attr_id_list[u], H5I_ATTR))) HGOTO_ERROR(H5E_ATTR, H5E_BADTYPE, FAIL, "not an attribute") /* Get file serial number for attribute */ diff --git a/src/H5Ocopy.c b/src/H5Ocopy.c index fc82407..6975397 100644 --- a/src/H5Ocopy.c +++ b/src/H5Ocopy.c @@ -45,7 +45,7 @@ #include "H5MMprivate.h" /* Memory management */ #include "H5Opkg.h" /* Object headers */ #include "H5Pprivate.h" /* Property lists */ - +#include "H5VLprivate.h" /* VOL */ /****************/ /* Local Macros */ @@ -205,10 +205,71 @@ herr_t H5Ocopy(hid_t src_loc_id, const char *src_name, hid_t dst_loc_id, const char *dst_name, hid_t ocpypl_id, hid_t lcpl_id) { - H5G_loc_t loc; /* Source group group location */ - H5G_loc_t src_loc; /* Source object group location */ - H5G_loc_t dst_loc; /* Destination group location */ + H5VL_object_t *obj1 = NULL; /* object token of src_id */ + H5VL_loc_params_t loc_params1; + H5VL_object_t *obj2 = NULL; /* object token of dst_id */ + H5VL_loc_params_t loc_params2; + herr_t ret_value = SUCCEED; /* Return value */ + FUNC_ENTER_API(FAIL) + H5TRACE6("e", "i*si*sii", src_loc_id, src_name, dst_loc_id, dst_name, + ocpypl_id, lcpl_id); + + /* Get correct property lists */ + if(H5P_DEFAULT == lcpl_id) { + if((lcpl_id = H5L_get_default_lcpl()) < 0) + HGOTO_ERROR(H5E_PLIST, H5E_CANTINIT, FAIL, "unable to get default lcpl") + } /* end if */ + else + if(TRUE != H5P_isa_class(lcpl_id, H5P_LINK_CREATE)) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not link creation property list") + + /* Get object copy property list */ + if(H5P_DEFAULT == ocpypl_id) + ocpypl_id = H5P_OBJECT_COPY_DEFAULT; + else + if(TRUE != H5P_isa_class(ocpypl_id, H5P_OBJECT_COPY)) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not object copy property list") + + /* get the object */ + if(NULL == (obj1 = (H5VL_object_t *)H5I_object(src_loc_id))) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "invalid location identifier") + loc_params1.type = H5VL_OBJECT_BY_SELF; + loc_params1.obj_type = H5I_get_type(src_loc_id); + + /* get the object */ + if(NULL == (obj2 = (H5VL_object_t *)H5I_object(dst_loc_id))) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "invalid location identifier") + loc_params2.type = H5VL_OBJECT_BY_SELF; + loc_params2.obj_type = H5I_get_type(dst_loc_id); + + /* Open the object through the VOL */ + if((ret_value = H5VL_object_copy(obj1->vol_obj, loc_params1, obj1->vol_info->vol_cls, src_name, + obj2->vol_obj, loc_params2, obj2->vol_info->vol_cls, dst_name, + ocpypl_id, lcpl_id, H5AC_dxpl_id, H5_REQUEST_NULL)) < 0) + HGOTO_ERROR(H5E_SYM, H5E_CANTINIT, FAIL, "unable to copy object") + +done: + FUNC_LEAVE_API(ret_value) +} /* end H5Ocopy() */ + + +/*------------------------------------------------------------------------- + * Function: H5O_copy + * + * Purpose: private version of H5Ocopy + * + * Return: Non-negative on success/Negative on failure + * + * Programmer: Mohamad Chaarawi + * April, 2012 + * + *------------------------------------------------------------------------- + */ +herr_t H5O_copy(H5G_loc_t *loc, const char *src_name, H5G_loc_t *dst_loc, const char *dst_name, + hid_t ocpypl_id, hid_t lcpl_id) +{ + H5G_loc_t src_loc; /* Source object group location */ /* for opening the destination object */ H5G_name_t src_path; /* Opened source object hier. path */ H5O_loc_t src_oloc; /* Opened source object object location */ @@ -217,19 +278,7 @@ H5Ocopy(hid_t src_loc_id, const char *src_name, hid_t dst_loc_id, herr_t ret_value = SUCCEED; /* Return value */ - FUNC_ENTER_API(FAIL) - H5TRACE6("e", "i*si*sii", src_loc_id, src_name, dst_loc_id, dst_name, - ocpypl_id, lcpl_id); - - /* Check arguments */ - if(H5G_loc(src_loc_id, &loc) < 0) - HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a location") - if(H5G_loc(dst_loc_id, &dst_loc) < 0) - HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a location") - if(!src_name || !*src_name) - HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "no source name specified") - if(!dst_name || !*dst_name) - HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "no destination name specified") + FUNC_ENTER_NOAPI_NOINIT /* check if destination name already exists */ { @@ -243,7 +292,7 @@ H5Ocopy(hid_t src_loc_id, const char *src_name, hid_t dst_loc_id, H5G_loc_reset(&tmp_loc); /* Check if object already exists in destination */ - if(H5G_loc_find(&dst_loc, dst_name, &tmp_loc, H5P_DEFAULT, H5AC_dxpl_id) >= 0) { + if(H5G_loc_find(dst_loc, dst_name, &tmp_loc, H5P_DEFAULT, H5AC_dxpl_id) >= 0) { H5G_name_free(&tmp_path); HGOTO_ERROR(H5E_SYM, H5E_EXISTS, FAIL, "destination object already exists") } /* end if */ @@ -255,7 +304,7 @@ H5Ocopy(hid_t src_loc_id, const char *src_name, hid_t dst_loc_id, H5G_loc_reset(&src_loc); /* Find the source object to copy */ - if(H5G_loc_find(&loc, src_name, &src_loc/*out*/, H5P_DEFAULT, H5AC_dxpl_id) < 0) + if(H5G_loc_find(loc, src_name, &src_loc/*out*/, H5P_DEFAULT, H5AC_dxpl_id) < 0) HGOTO_ERROR(H5E_SYM, H5E_NOTFOUND, FAIL, "source object not found") loc_found = TRUE; @@ -264,24 +313,8 @@ H5Ocopy(hid_t src_loc_id, const char *src_name, hid_t dst_loc_id, HGOTO_ERROR(H5E_OHDR, H5E_CANTOPENOBJ, FAIL, "unable to open object") obj_open = TRUE; - /* Get correct property lists */ - if(H5P_DEFAULT == lcpl_id) { - if((lcpl_id = H5L_get_default_lcpl()) < 0) - HGOTO_ERROR(H5E_PLIST, H5E_CANTINIT, FAIL, "unable to get default lcpl") - } /* end if */ - else - if(TRUE != H5P_isa_class(lcpl_id, H5P_LINK_CREATE)) - HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not link creation property list") - - /* Get object copy property list */ - if(H5P_DEFAULT == ocpypl_id) - ocpypl_id = H5P_OBJECT_COPY_DEFAULT; - else - if(TRUE != H5P_isa_class(ocpypl_id, H5P_OBJECT_COPY)) - HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not object copy property list") - /* Do the actual copying of the object */ - if(H5O_copy_obj(&src_loc, &dst_loc, dst_name, ocpypl_id, lcpl_id) < 0) + if(H5O_copy_obj(&src_loc, dst_loc, dst_name, ocpypl_id, lcpl_id) < 0) HGOTO_ERROR(H5E_OHDR, H5E_CANTCOPY, FAIL, "unable to copy object") done: @@ -290,8 +323,8 @@ done: if(obj_open && H5O_close(&src_oloc) < 0) HDONE_ERROR(H5E_OHDR, H5E_CLOSEERROR, FAIL, "unable to release object header") - FUNC_LEAVE_API(ret_value) -} /* end H5Ocopy() */ + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5O_copy() */ /*------------------------------------------------------------------------- @@ -1510,7 +1543,7 @@ H5O_copy_search_comm_dt_attr_cb(const H5A_t *attr, void *_udata) HGOTO_ERROR(H5E_OHDR, H5E_CANTGET, FAIL, "can't get attribute datatype") /* Check if the datatype is committed and search the skip list if so */ - if(H5T_committed(dt)) { + if(H5T_is_named(dt)) { /* Allocate key */ if(NULL == (key = H5FL_MALLOC(H5O_copy_search_comm_dt_key_t))) HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, FAIL, "memory allocation failed") @@ -1633,7 +1666,7 @@ H5O_copy_search_comm_dt_check(H5O_loc_t *obj_oloc, /* Check if the datatype is committed and search the skip list if so */ - if(H5T_committed(key->dt)) { + if(H5T_is_named(key->dt)) { /* Get datatype object fileno */ H5F_GET_FILENO(obj_oloc->file, key->fileno); @@ -1770,7 +1803,7 @@ H5O_copy_search_comm_dt(H5F_t *file_src, H5O_t *oh_src, HDassert(oh_src); HDassert(oloc_dst); HDassert(oloc_dst->file); - HDassert(H5F_FILE_ID(oloc_dst->file) >= 0); + HDassert(H5F_FILE_ID(oloc_dst->file)); HDassert(cpy_info); /* Allocate key */ @@ -1882,7 +1915,7 @@ H5O_copy_search_comm_dt(H5F_t *file_src, H5O_t *oh_src, /* Traverse the destination file, adding committed datatypes to the skip * list */ - if(H5G_visit(H5F_FILE_ID(oloc_dst->file), "/", H5_INDEX_NAME, H5_ITER_NATIVE, H5O_copy_search_comm_dt_cb, &udata, H5P_LINK_ACCESS_DEFAULT, dxpl_id) < 0) + if(H5G_visit(&dst_root_loc, "/", H5_INDEX_NAME, H5_ITER_NATIVE, H5O_copy_search_comm_dt_cb, &udata, H5P_LINK_ACCESS_DEFAULT, dxpl_id) < 0) HGOTO_ERROR(H5E_OHDR, H5E_BADITER, FAIL, "object visitation failed") cpy_info->dst_dt_list_complete = TRUE; } /* end if */ diff --git a/src/H5Odtype.c b/src/H5Odtype.c index cb6bf98..d2c5efd 100644 --- a/src/H5Odtype.c +++ b/src/H5Odtype.c @@ -1481,7 +1481,7 @@ H5O_dtype_can_share(const void *_mesg) HGOTO_ERROR(H5E_OHDR, H5E_BADTYPE, FAIL, "can't tell if datatype is immutable") /* Don't share committed datatypes */ - if((tri_ret = H5T_committed(mesg)) > 0) + if((tri_ret = H5T_is_named(mesg)) > 0) HGOTO_DONE(FALSE) else if(tri_ret < 0) HGOTO_ERROR(H5E_OHDR, H5E_BADTYPE, FAIL, "can't tell if datatype is shared") @@ -1606,12 +1606,12 @@ H5O_dtype_shared_post_copy_upd(const H5O_loc_t UNUSED *src_oloc, FUNC_ENTER_NOAPI_NOINIT_NOERR if(dt_dst->sh_loc.type == H5O_SHARE_TYPE_COMMITTED) { - HDassert(H5T_committed(dt_dst)); + HDassert(H5T_is_named(dt_dst)); dt_dst->oloc.file = dt_dst->sh_loc.file; dt_dst->oloc.addr = dt_dst->sh_loc.u.loc.oh_addr; } /* end if */ else - HDassert(!H5T_committed(dt_dst)); + HDassert(!H5T_is_named(dt_dst)); FUNC_LEAVE_NOAPI(SUCCEED) } /* end H5O_dtype_shared_post_copy_upd */ diff --git a/src/H5Opkg.h b/src/H5Opkg.h index 1f8a1cd..f990fdd 100644 --- a/src/H5Opkg.h +++ b/src/H5Opkg.h @@ -381,6 +381,12 @@ 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; /* H5O object header inherits cache-like properties from H5AC */ H5_DLLVAR const H5AC_class_t H5AC_OHDR[1]; @@ -533,6 +539,9 @@ H5_DLL int H5O_link_oh(H5F_t *f, int adjust, hid_t dxpl_id, H5O_t *oh, hbool_t * H5_DLL herr_t H5O_inc_rc(H5O_t *oh); H5_DLL herr_t H5O_dec_rc(H5O_t *oh); H5_DLL herr_t H5O_free(H5O_t *oh); +H5_DLL herr_t H5O_visit(H5G_loc_t *loc, const char *obj_name, H5_index_t idx_type, + H5_iter_order_t order, H5O_iterate_t op, void *op_data, hid_t lapl_id, + hid_t dxpl_id); /* Object header message routines */ H5_DLL herr_t H5O_msg_alloc(H5F_t *f, hid_t dxpl_id, H5O_t *oh, diff --git a/src/H5Oprivate.h b/src/H5Oprivate.h index d5cd621..1bb1af4 100644 --- a/src/H5Oprivate.h +++ b/src/H5Oprivate.h @@ -738,6 +738,9 @@ H5_DLL herr_t H5O_copy_header_map(const H5O_loc_t *oloc_src, H5O_loc_t *oloc_dst H5_DLL herr_t H5O_copy_expand_ref(H5F_t *file_src, void *_src_ref, hid_t dxpl_id, H5F_t *file_dst, void *_dst_ref, size_t ref_count, H5R_type_t ref_type, H5O_copy_t *cpy_info); +H5_DLL herr_t H5O_copy(H5G_loc_t *src_loc, const char *src_name, + H5G_loc_t *dst_loc, const char *dst_name, + hid_t ocpypl_id, hid_t lcpl_id); /* Debugging routines */ H5_DLL herr_t H5O_debug_id(unsigned type_id, H5F_t *f, hid_t dxpl_id, const void *mesg, FILE *stream, int indent, int fwidth); @@ -27,6 +27,7 @@ #include "H5Eprivate.h" /* Error handling */ #include "H5MMprivate.h" /* Memory management */ #include "H5PLprivate.h" /* Plugin */ +#include "H5VLprivate.h" /* VOL */ #include "H5Zprivate.h" /* Filter pipeline */ @@ -96,9 +97,10 @@ typedef const void *(*H5PL_get_plugin_info_t)(void); /* Type for the list of info for opened plugin libraries */ typedef struct H5PL_table_t { - H5PL_type_t pl_type; /* plugin type */ - int pl_id; /* ID for the plugin */ - H5PL_HANDLE handle; /* plugin handle */ + H5PL_type_t pl_type; /* plugin type */ + int pl_id; /* ID for the plugin */ + const char *pl_name; /* name of the plugin */ + H5PL_HANDLE handle; /* plugin handle */ } H5PL_table_t; @@ -107,9 +109,9 @@ typedef struct H5PL_table_t { /********************/ static herr_t H5PL__init_path_table(void); -static htri_t H5PL__find(H5PL_type_t plugin_type, int type_id, char *dir, const void **info); -static htri_t H5PL__open(H5PL_type_t pl_type, char *libname, int plugin_id, const void **pl_info); -static htri_t H5PL__search_table(H5PL_type_t plugin_type, int type_id, const void **info); +static htri_t H5PL__find(H5PL_type_t plugin_type, int type_id, const char *plugin_name, char *dir, const void **info); +static htri_t H5PL__open(H5PL_type_t pl_type, char *libname, int plugin_id, const char *plugin_name, const void **pl_info); +static htri_t H5PL__search_table(H5PL_type_t plugin_type, int type_id, const char *plugin_name, const void **info); static herr_t H5PL__close(H5PL_HANDLE handle); @@ -132,6 +134,11 @@ static size_t H5PL_table_alloc_g = 0; static size_t H5PL_table_used_g = 0; static H5PL_table_t *H5PL_table_g = NULL; +/* Table for opened vol plugin libraries */ +static size_t H5PL_vol_table_alloc_g = 0; +static size_t H5PL_vol_table_used_g = 0; +static H5PL_table_t *H5PL_vol_table_g = NULL; + /* Table of location paths for plugin libraries */ static char *H5PL_path_table_g[H5PL_MAX_PATH_NUM]; static size_t H5PL_num_paths_g = 0; @@ -231,10 +238,20 @@ H5PL_term_interface(void) for(u = 0; u < H5PL_table_used_g; u++) H5PL__close((H5PL_table_g[u]).handle); + /* Close opened dynamic vol libraries */ + for(u = 0; u < H5PL_vol_table_used_g; u++) { + H5PL__close((H5PL_vol_table_g[u]).handle); + HDfree(H5PL_vol_table_g[u].pl_name); + } + /* Free the table of dynamic libraries */ H5PL_table_g = (H5PL_table_t *)H5MM_xfree(H5PL_table_g); H5PL_table_used_g = H5PL_table_alloc_g = 0; + /* Free the table of dynamic vol libraries */ + H5PL_vol_table_g = (H5PL_table_t *)H5MM_xfree(H5PL_vol_table_g); + H5PL_vol_table_used_g = H5PL_vol_table_alloc_g = 0; + /* Free the table of search paths */ for(u = 0; u < H5PL_num_paths_g; u++) if(H5PL_path_table_g[u]) @@ -253,9 +270,9 @@ H5PL_term_interface(void) /*------------------------------------------------------------------------- * Function: H5PL_load * - * Purpose: Given the plugin type and identifier, this function searches - * and/or loads a dynamic plugin library first among the already - * opened libraries then in the designated location paths. + * Purpose: Given the plugin type and identifier and/or name, this function + * searches and/or loads a dynamic plugin library first among the + * already opened libraries then in the designated location paths. * * Return: Non-NULL on success/NULL on failure * @@ -265,7 +282,7 @@ H5PL_term_interface(void) *------------------------------------------------------------------------- */ const void * -H5PL_load(H5PL_type_t type, int id) +H5PL_load(H5PL_type_t type, int id, const char *name) { htri_t found; /* Whether the plugin was found */ const void *plugin_info = NULL; @@ -285,7 +302,7 @@ H5PL_load(H5PL_type_t type, int id) HGOTO_ERROR(H5E_PLUGIN, H5E_CANTINIT, NULL, "can't initialize search path table") /* Search in the table of already loaded plugin libraries */ - if((found = H5PL__search_table(type, id, &plugin_info)) < 0) + if((found = H5PL__search_table(type, id, name, &plugin_info)) < 0) HGOTO_ERROR(H5E_PLUGIN, H5E_CANTGET, NULL, "search in table failed") /* If not found, iterate through the path table to find the right dynamic library */ @@ -293,7 +310,7 @@ H5PL_load(H5PL_type_t type, int id) size_t i; /* Local index variable */ for(i = 0; i < H5PL_num_paths_g; i++) { - if((found = H5PL__find(type, id, H5PL_path_table_g[i], &plugin_info)) < 0) + if((found = H5PL__find(type, id, name, H5PL_path_table_g[i], &plugin_info)) < 0) HGOTO_ERROR(H5E_PLUGIN, H5E_CANTGET, NULL, "search in paths failed") /* Break out if found */ @@ -387,7 +404,7 @@ done: */ #ifndef H5_HAVE_WIN32_API static htri_t -H5PL__find(H5PL_type_t plugin_type, int type_id, char *dir, const void **info) +H5PL__find(H5PL_type_t plugin_type, int type_id, const char *plugin_name, char *dir, const void **info) { char *pathname = NULL; DIR *dirp = NULL; @@ -425,8 +442,8 @@ H5PL__find(H5PL_type_t plugin_type, int type_id, char *dir, const void **info) if(S_ISDIR(my_stat.st_mode)) continue; - /* Attempt to open the dynamic library as a filter library */ - if((found_in_dir = H5PL__open(plugin_type, pathname, type_id, info)) < 0) + /* Attempt to open the dynamic library */ + if((found_in_dir = H5PL__open(plugin_type, pathname, type_id, plugin_name, info)) < 0) HGOTO_ERROR(H5E_PLUGIN, H5E_CANTGET, FAIL, "search in directory failed") if(found_in_dir) { /* Indicate success */ @@ -449,7 +466,7 @@ done: } /* end H5PL__find() */ #else /* H5_HAVE_WIN32_API */ static htri_t -H5PL__find(H5PL_type_t plugin_type, int type_id, char *dir, const void **info) +H5PL__find(H5PL_type_t plugin_type, int type_id, const char *plugin_name, char *dir, const void **info) { WIN32_FIND_DATA fdFile; HANDLE hFind; @@ -482,7 +499,7 @@ H5PL__find(H5PL_type_t plugin_type, int type_id, char *dir, const void **info) if(fdFile.dwFileAttributes & FILE_ATTRIBUTE_DIRECTORY) continue; - if((found_in_dir = H5PL__open(plugin_type, pathname, type_id, info)) < 0) + if((found_in_dir = H5PL__open(plugin_type, pathname, type_id, plugin_name, info)) < 0) HGOTO_ERROR(H5E_PLUGIN, H5E_CANTGET, FAIL, "search in directory failed") if(found_in_dir) { /* Indicate success */ @@ -522,7 +539,7 @@ done: *------------------------------------------------------------------------- */ static htri_t -H5PL__open(H5PL_type_t pl_type, char *libname, int pl_id, const void **pl_info) +H5PL__open(H5PL_type_t pl_type, char *libname, int pl_id, const char *pl_name, const void **pl_info) { H5PL_HANDLE handle = NULL; htri_t ret_value = FALSE; @@ -546,45 +563,108 @@ H5PL__open(H5PL_type_t pl_type, char *libname, int pl_id, const void **pl_info) HGOTO_ERROR(H5E_PLUGIN, H5E_CLOSEERROR, FAIL, "can't close dynamic library") } /* end if */ else { - const H5Z_class2_t *plugin_info; - - /* Invoke H5PLget_plugin_info to verify this is the right library we are looking for. - * Move on if it isn't. - */ - if(NULL == (plugin_info = (const H5Z_class2_t *)(*get_plugin_info)())) { - if(H5PL__close(handle) < 0) - HGOTO_ERROR(H5E_PLUGIN, H5E_CLOSEERROR, FAIL, "can't close dynamic library") - HGOTO_ERROR(H5E_PLUGIN, H5E_CANTGET, FAIL, "can't get plugin info") - } /* end if */ - - /* Successfully found plugin library, check if it's the right one */ - if(plugin_info->id == pl_id) { - /* Expand the table if it is too small */ - if(H5PL_table_used_g >= H5PL_table_alloc_g) { - size_t n = MAX(H5Z_MAX_NFILTERS, 2 * H5PL_table_alloc_g); - H5PL_table_t *table = (H5PL_table_t *)H5MM_realloc(H5PL_table_g, n * sizeof(H5PL_table_t)); - - if(!table) - HGOTO_ERROR(H5E_RESOURCE, H5E_CANTALLOC, FAIL, "unable to extend dynamic library table") - - H5PL_table_g = table; - H5PL_table_alloc_g = n; - } /* end if */ - - (H5PL_table_g[H5PL_table_used_g]).handle = handle; - (H5PL_table_g[H5PL_table_used_g]).pl_type = pl_type; - (H5PL_table_g[H5PL_table_used_g]).pl_id = plugin_info->id; - H5PL_table_used_g++; - - /* Set the plugin info to return */ - *pl_info = (const void *)plugin_info; - - /* Indicate success */ - ret_value = TRUE; - } /* end if */ - else - if(H5PL__close(handle) < 0) - HGOTO_ERROR(H5E_PLUGIN, H5E_CLOSEERROR, FAIL, "can't close dynamic library") + switch(pl_type) { + case H5PL_TYPE_FILTER: + { + const H5Z_class2_t *plugin_info; + + /* Invoke H5PLget_plugin_info to verify this is the right library we are looking for. + * Move on if it isn't. + */ + if(NULL == (plugin_info = (const H5Z_class2_t *)(*get_plugin_info)())) { + if(H5PL__close(handle) < 0) + HGOTO_ERROR(H5E_PLUGIN, H5E_CLOSEERROR, FAIL, "can't close dynamic library") + HGOTO_ERROR(H5E_PLUGIN, H5E_CANTGET, FAIL, "can't get plugin info") + } /* end if */ + + /* Successfully found plugin library, check if it's the right one */ + if(plugin_info->id == pl_id) { + /* Expand the table if it is too small */ + if(H5PL_table_used_g >= H5PL_table_alloc_g) { + size_t n = MAX(H5Z_MAX_NFILTERS, 2 * H5PL_table_alloc_g); + H5PL_table_t *table = (H5PL_table_t *)H5MM_realloc(H5PL_table_g, n * sizeof(H5PL_table_t)); + + if(!table) + HGOTO_ERROR(H5E_RESOURCE, H5E_CANTALLOC, FAIL, "unable to extend dynamic library table") + + H5PL_table_g = table; + H5PL_table_alloc_g = n; + } /* end if */ + + (H5PL_table_g[H5PL_table_used_g]).handle = handle; + (H5PL_table_g[H5PL_table_used_g]).pl_type = pl_type; + (H5PL_table_g[H5PL_table_used_g]).pl_id = plugin_info->id; + H5PL_table_used_g++; + + /* Set the plugin info to return */ + *pl_info = (const void *)plugin_info; + + /* Indicate success */ + ret_value = TRUE; + } /* end if */ + else + if(H5PL__close(handle) < 0) + HGOTO_ERROR(H5E_PLUGIN, H5E_CLOSEERROR, FAIL, "can't close dynamic library") + + break; + } + case H5PL_TYPE_VOL: + { + const H5VL_class_t *plugin_info; + + /* Invoke H5PLget_plugin_info to verify this is the right library we are looking for. + * Move on if it isn't. + */ + if(NULL == (plugin_info = (const H5VL_class_t *)(*get_plugin_info)())) { + if(H5PL__close(handle) < 0) + HGOTO_ERROR(H5E_PLUGIN, H5E_CLOSEERROR, FAIL, "can't close dynamic library") + HGOTO_ERROR(H5E_PLUGIN, H5E_CANTGET, FAIL, "can't get plugin info") + } /* end if */ + + /* Successfully found plugin library, check if it's the right one */ + if((pl_id > H5_VOL_MAX_LIB_VALUE && plugin_info->value == pl_id) || + (pl_name && !strcmp(pl_name, plugin_info->name))) { + /* Expand the table if it is too small */ + if(H5PL_vol_table_used_g >= H5PL_vol_table_alloc_g) { + size_t n; + H5PL_table_t *table = NULL; + + if(0 == H5PL_vol_table_alloc_g) + n = 16; + else + n = 2 * H5PL_vol_table_alloc_g; + + table = (H5PL_table_t *)H5MM_realloc(H5PL_vol_table_g, n * sizeof(H5PL_table_t)); + if(!table) + HGOTO_ERROR(H5E_RESOURCE, H5E_CANTALLOC, FAIL, "unable to extend dynamic library table for vol plugins") + + H5PL_vol_table_g = table; + H5PL_vol_table_alloc_g = n; + } /* end if */ + + (H5PL_vol_table_g[H5PL_vol_table_used_g]).handle = handle; + (H5PL_vol_table_g[H5PL_vol_table_used_g]).pl_type = pl_type; + (H5PL_vol_table_g[H5PL_vol_table_used_g]).pl_id = plugin_info->value; + (H5PL_vol_table_g[H5PL_vol_table_used_g]).pl_name = HDstrdup(pl_name); + H5PL_vol_table_used_g++; + + /* Set the plugin info to return */ + *pl_info = (const void *)plugin_info; + + /* Indicate success */ + ret_value = TRUE; + } /* end if */ + else + if(H5PL__close(handle) < 0) + HGOTO_ERROR(H5E_PLUGIN, H5E_CLOSEERROR, FAIL, "can't close dynamic library") + + break; + } + case H5PL_TYPE_ERROR: + case H5PL_TYPE_NONE: + default: + HGOTO_ERROR(H5E_PLUGIN, H5E_BADVALUE, FAIL, "invalid plugin type") + } /* end switch */ } /* end if */ } /* end else */ @@ -609,14 +689,14 @@ done: *------------------------------------------------------------------------- */ static htri_t -H5PL__search_table(H5PL_type_t plugin_type, int type_id, const void **info) +H5PL__search_table(H5PL_type_t plugin_type, int type_id, const char *plugin_name, const void **info) { htri_t ret_value = FALSE; FUNC_ENTER_STATIC /* Search in the table of already opened dynamic libraries */ - if(H5PL_table_used_g > 0) { + if(H5PL_TYPE_FILTER == plugin_type && H5PL_table_used_g > 0) { size_t i; for(i = 0; i < H5PL_table_used_g; i++) { @@ -635,6 +715,26 @@ H5PL__search_table(H5PL_type_t plugin_type, int type_id, const void **info) } /* end if */ } /* end for */ } /* end if */ + else if(H5PL_TYPE_VOL == plugin_type && H5PL_vol_table_used_g > 0) { + size_t i; + + for(i = 0; i < H5PL_vol_table_used_g; i++) { + if((plugin_type == (H5PL_vol_table_g[i]).pl_type) && + (type_id == (H5PL_vol_table_g[i]).pl_id || !strcmp(plugin_name, (H5PL_vol_table_g[i]).pl_name))) { + H5PL_get_plugin_info_t get_plugin_info; + const H5VL_class_t *plugin_info; + + if(NULL == (get_plugin_info = (H5PL_get_plugin_info_t)H5PL_GET_LIB_FUNC((H5PL_vol_table_g[i]).handle, "H5PLget_plugin_info"))) + HGOTO_ERROR(H5E_DATATYPE, H5E_CANTGET, FAIL, "can't get function for H5PLget_plugin_info") + + if(NULL == (plugin_info = (const H5VL_class_t *)(*get_plugin_info)())) + HGOTO_ERROR(H5E_DATATYPE, H5E_CANTGET, FAIL, "can't get plugin info") + + *info = plugin_info; + HGOTO_DONE(TRUE) + } /* end if */ + } /* end for */ + } /* end if */ done: FUNC_LEAVE_NOAPI(ret_value) diff --git a/src/H5PLextern.h b/src/H5PLextern.h index 943e3aa..b5563e4 100644 --- a/src/H5PLextern.h +++ b/src/H5PLextern.h @@ -30,7 +30,8 @@ typedef enum H5PL_type_t { H5PL_TYPE_ERROR = -1, /*error */ H5PL_TYPE_FILTER = 0, /*filter */ - H5PL_TYPE_NONE = 1 /*this must be last! */ + H5PL_TYPE_VOL = 1, /*vol plugin */ + H5PL_TYPE_NONE = 2 /*this must be last! */ } H5PL_type_t; diff --git a/src/H5PLprivate.h b/src/H5PLprivate.h index b117613..237408d 100644 --- a/src/H5PLprivate.h +++ b/src/H5PLprivate.h @@ -46,7 +46,7 @@ /***************************************/ /* Internal API routines */ -H5_DLL const void *H5PL_load(H5PL_type_t plugin_type, int type_id); +H5_DLL const void *H5PL_load(H5PL_type_t plugin_type, int type_id, const char *plugin_name); H5_DLL htri_t H5PL_no_plugin(void); #endif /* _H5PLprivate_H */ diff --git a/src/H5Pacpl.c b/src/H5Pacpl.c index 0a0641c..89f4649 100644 --- a/src/H5Pacpl.c +++ b/src/H5Pacpl.c @@ -33,7 +33,9 @@ /* Headers */ /***********/ #include "H5private.h" /* Generic Functions */ +#include "H5Aprivate.h" /* Attributes */ #include "H5Eprivate.h" /* Error handling */ +#include "H5Iprivate.h" /* IDs */ #include "H5Ppkg.h" /* Property lists */ @@ -41,6 +43,9 @@ /* Local Macros */ /****************/ +/* Definitions for locations parameters */ +#define H5A_CRT_LOCATION_SIZE sizeof(H5VL_loc_params_t) +#define H5A_CRT_LOCATION_DEF {H5I_BADID} /******************/ /* Local Typedefs */ @@ -55,6 +60,8 @@ /********************/ /* Local Prototypes */ /********************/ +/* Property class callbacks */ +static herr_t H5P_acrt_reg_prop(H5P_genclass_t *pclass); /*********************/ @@ -70,7 +77,7 @@ const H5P_libclass_t H5P_CLS_ACRT[1] = {{ &H5P_CLS_ATTRIBUTE_CREATE_g, /* Pointer to class */ &H5P_CLS_ATTRIBUTE_CREATE_ID_g, /* Pointer to class ID */ &H5P_LST_ATTRIBUTE_CREATE_ID_g, /* Pointer to default property list ID */ - NULL, /* Default property registration routine */ + H5P_acrt_reg_prop, /* Default property registration routine */ NULL, /* Class creation callback */ NULL, /* Class creation callback info */ @@ -86,3 +93,43 @@ const H5P_libclass_t H5P_CLS_ACRT[1] = {{ /*****************************/ + +/*------------------------------------------------------------------------- + * Function: H5P_acrt_reg_prop + * + * Purpose: Register the attribute creation property list class's properties + * + * Return: Non-negative on success/Negative on failure + * + * Programmer: Mohamad Chaarawi + * April 5, 2012 + *------------------------------------------------------------------------- + */ +static herr_t +H5P_acrt_reg_prop(H5P_genclass_t *pclass) +{ + hid_t type_id = FAIL; + hid_t space_id = FAIL; + H5VL_loc_params_t loc_params = H5A_CRT_LOCATION_DEF; + herr_t ret_value = SUCCEED; /* Return value */ + + FUNC_ENTER_NOAPI_NOINIT + + /* Register the type ID property*/ + if(H5P_register_real(pclass, H5VL_PROP_ATTR_TYPE_ID, sizeof(hid_t), &type_id, + NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL) < 0) + HGOTO_ERROR(H5E_PLIST, H5E_CANTINSERT, FAIL, "can't insert property into class") + + /* Register the space ID property */ + if(H5P_register_real(pclass, H5VL_PROP_ATTR_SPACE_ID, sizeof(hid_t), &space_id, + NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL) < 0) + HGOTO_ERROR(H5E_PLIST, H5E_CANTINSERT, FAIL, "can't insert property into class") + + /* Register the lcpl ID property */ + if(H5P_register_real(pclass, H5VL_PROP_ATTR_LOC_PARAMS, H5A_CRT_LOCATION_SIZE, &loc_params, + NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL) < 0) + HGOTO_ERROR(H5E_PLIST, H5E_CANTINSERT, FAIL, "can't insert property into class") + +done: + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5P_acrt_reg_prop() */ diff --git a/src/H5Pdcpl.c b/src/H5Pdcpl.c index a753209..6e31af9 100644 --- a/src/H5Pdcpl.c +++ b/src/H5Pdcpl.c @@ -206,6 +206,9 @@ static hbool_t H5P_dcrt_def_layout_init_g = FALSE; static herr_t H5P__dcrt_reg_prop(H5P_genclass_t *pclass) { + hid_t type_id = FAIL; + hid_t space_id = FAIL; + hid_t lcpl_id = H5P_LINK_CREATE_DEFAULT; herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_STATIC @@ -234,6 +237,21 @@ H5P__dcrt_reg_prop(H5P_genclass_t *pclass) NULL, NULL, H5D_CRT_EXT_FILE_LIST_CMP, NULL) < 0) HGOTO_ERROR(H5E_PLIST, H5E_CANTINSERT, FAIL, "can't insert property into class") + /* Register the type ID property*/ + if(H5P_register_real(pclass, H5VL_PROP_DSET_TYPE_ID, sizeof(hid_t), &type_id, + NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL) < 0) + HGOTO_ERROR(H5E_PLIST, H5E_CANTINSERT, FAIL, "can't insert property into class") + + /* Register the space ID property */ + if(H5P_register_real(pclass, H5VL_PROP_DSET_SPACE_ID, sizeof(hid_t), &space_id, + NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL) < 0) + HGOTO_ERROR(H5E_PLIST, H5E_CANTINSERT, FAIL, "can't insert property into class") + + /* Register the lcpl ID property */ + if(H5P_register_real(pclass, H5VL_PROP_DSET_LCPL_ID, sizeof(hid_t), &lcpl_id, + NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL) < 0) + HGOTO_ERROR(H5E_PLIST, H5E_CANTINSERT, FAIL, "can't insert property into class") + done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5P__dcrt_reg_prop() */ diff --git a/src/H5Pfapl.c b/src/H5Pfapl.c index 089bfb9..c8ca821 100644 --- a/src/H5Pfapl.c +++ b/src/H5Pfapl.c @@ -39,6 +39,7 @@ #include "H5Eprivate.h" /* Error handling */ #include "H5Fprivate.h" /* Files */ #include "H5FDprivate.h" /* File drivers */ +#include "H5VLprivate.h" /* VOL plugins */ #include "H5Iprivate.h" /* IDs */ #include "H5MMprivate.h" /* Memory Management */ #include "H5Ppkg.h" /* Property lists */ @@ -46,6 +47,10 @@ /* Includes needed to set as default file driver */ #include "H5FDsec2.h" /* Posix unbuffered I/O file driver */ #include "H5FDstdio.h" /* Standard C buffered I/O */ + +/* Includes needed to set as default VOL driver */ +#include "H5VLnative.h" /* Native H5 VOL plugin */ + #ifdef H5_HAVE_WINDOWS #include "H5FDwindows.h" /* Windows buffered I/O */ #endif @@ -154,6 +159,14 @@ #define H5F_ACS_EFC_SIZE_DEF 0 #define H5F_ACS_EFC_SIZE_ENC H5P__encode_unsigned #define H5F_ACS_EFC_SIZE_DEC H5P__decode_unsigned + +/* Definition for VOL plugin */ +#define H5F_ACS_VOL_ID_SIZE sizeof(hid_t) +#define H5F_ACS_VOL_ID_DEF H5VL_NATIVE +/* Definition for vol info */ +#define H5F_ACS_VOL_INFO_SIZE sizeof(void*) +#define H5F_ACS_VOL_INFO_DEF NULL + /* Definition of pointer to initial file image info */ #define H5F_ACS_FILE_IMAGE_INFO_SIZE sizeof(H5FD_file_image_info_t) #define H5F_ACS_FILE_IMAGE_INFO_DEF H5FD_DEFAULT_FILE_IMAGE_INFO @@ -277,6 +290,8 @@ static const size_t H5F_def_core_write_tracking_page_size_g = H5F_ACS_CORE_WRITE static herr_t H5P_facc_reg_prop(H5P_genclass_t *pclass) { + const hid_t def_vol_id = H5F_ACS_VOL_ID_DEF; /* Default VOL plugin */ + void *vol_info = H5F_ACS_VOL_INFO_DEF; /* Default VOL plugin information*/ const hid_t def_driver_id = H5F_ACS_FILE_DRV_ID_DEF; /* Default VFL driver ID (initialized from a variable) */ herr_t ret_value = SUCCEED; /* Return value */ @@ -403,6 +418,16 @@ 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 ID */ + if(H5P_register_real(pclass, H5F_ACS_VOL_ID_NAME, H5F_ACS_VOL_ID_SIZE, &def_vol_id, + NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL) < 0) + HGOTO_ERROR(H5E_PLIST, H5E_CANTINSERT, FAIL, "can't insert property into class") + + /* Register the file VOL INFO */ + if(H5P_register_real(pclass, H5F_ACS_VOL_INFO_NAME, H5F_ACS_VOL_INFO_SIZE, &vol_info, + NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL) < 0) + HGOTO_ERROR(H5E_PLIST, H5E_CANTINSERT, FAIL, "can't insert property into class") + /* Register the initial file image info */ /* (Note: this property should not have an encode/decode callback -QAK) */ if(H5P_register_real(pclass, H5F_ACS_FILE_IMAGE_INFO_NAME, H5F_ACS_FILE_IMAGE_INFO_SIZE, &H5F_def_file_image_info_g, @@ -448,6 +473,7 @@ static herr_t H5P_facc_create(hid_t fapl_id, void UNUSED *copy_data) { hid_t driver_id; + hid_t vol_id; H5P_genplist_t *plist; /* Property list */ herr_t ret_value = SUCCEED; @@ -457,6 +483,21 @@ H5P_facc_create(hid_t fapl_id, void UNUSED *copy_data) if(NULL == (plist = (H5P_genplist_t *)H5I_object(fapl_id))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a property list") + /* Retrieve VOL plugin property */ + if(H5P_get(plist, H5F_ACS_VOL_ID_NAME, &vol_id) < 0) + HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, FAIL, "can't get vol plugin") + + if(vol_id > 0) { + void *vol_info; + + /* Retrieve VOL plugin info property */ + if(H5P_get(plist, H5F_ACS_VOL_INFO_NAME, &vol_info) < 0) + HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, FAIL, "can't get vol info") + /* Set the vol for the property list */ + if(H5VL_fapl_open(plist, vol_id, vol_info) < 0) + HGOTO_ERROR(H5E_PLIST, H5E_CANTSET, FAIL, "can't set vol") + } + /* Retrieve driver ID property */ if(H5P_get(plist, H5F_ACS_FILE_DRV_ID_NAME, &driver_id) < 0) HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, FAIL, "can't get driver ID") @@ -498,28 +539,45 @@ static herr_t H5P_facc_copy(hid_t dst_fapl_id, hid_t src_fapl_id, void UNUSED *copy_data) { hid_t driver_id; + hid_t vol_id; H5P_genplist_t *src_plist; /* Source property list */ + H5P_genplist_t *dst_plist; /* Destination property list */ herr_t ret_value = SUCCEED; FUNC_ENTER_NOAPI_NOINIT - /* Get driver ID from source property list */ if(NULL == (src_plist = (H5P_genplist_t *)H5I_object(src_fapl_id))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "can't get property list") + if(NULL == (dst_plist = (H5P_genplist_t *)H5I_object(dst_fapl_id))) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "can't get property list") + + /* get VOL plugin from source property list */ + if(H5P_get(src_plist, H5F_ACS_VOL_ID_NAME, &vol_id) < 0) + HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, FAIL, "can't get vol ID") + + if(vol_id > 0) { + void *vol_info; + + /* Retrieve VOL plugin property */ + if(H5P_get(dst_plist, H5F_ACS_VOL_INFO_NAME, &vol_info) < 0) + HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, FAIL, "can't get vol info") + + /* Set the vp; for the destination property list */ + if(H5VL_fapl_open(dst_plist, vol_id, vol_info) < 0) + HGOTO_ERROR(H5E_PLIST, H5E_CANTSET, FAIL, "can't set vol") + } /* end if */ + + /* Get driver ID from source property list */ if(H5P_get(src_plist, H5F_ACS_FILE_DRV_ID_NAME, &driver_id) < 0) HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, FAIL, "can't get driver ID") if(driver_id > 0) { - H5P_genplist_t *dst_plist; /* Destination property list */ void *driver_info; /* Get driver info from source property list */ if(H5P_get(src_plist, H5F_ACS_FILE_DRV_INFO_NAME, &driver_info) < 0) HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, FAIL, "can't get driver info") - /* Set the driver for the destination property list */ - if(NULL == (dst_plist = (H5P_genplist_t *)H5I_object(dst_fapl_id))) - HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "can't get property list") if(H5FD_fapl_open(dst_plist, driver_id, driver_info) < 0) HGOTO_ERROR(H5E_PLIST, H5E_CANTSET, FAIL, "can't set driver") } /* end if */ @@ -548,9 +606,10 @@ done: herr_t H5P_facc_close(hid_t fapl_id, void UNUSED *close_data) { - hid_t driver_id; + hid_t driver_id; + hid_t vol_id; H5P_genplist_t *plist; /* Property list */ - herr_t ret_value = SUCCEED; + herr_t ret_value = SUCCEED; FUNC_ENTER_NOAPI(FAIL) @@ -558,6 +617,22 @@ H5P_facc_close(hid_t fapl_id, void UNUSED *close_data) if(NULL == (plist = (H5P_genplist_t *)H5I_object(fapl_id))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a property list") + /* Get vol plugin */ + if(H5P_get(plist, H5F_ACS_VOL_ID_NAME, &vol_id) < 0) + HGOTO_DONE(FAIL) /* Can't return errors when library is shutting down */ + + if(vol_id > 0) { + void *vol_info; + + /* Retrieve VOL plugin info property */ + if(H5P_get(plist, H5F_ACS_VOL_INFO_NAME, &vol_info) < 0) + HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, FAIL, "can't get vol info") + + /* Close the driver for the property list */ + if(H5VL_fapl_close(vol_id, vol_info) < 0) + HGOTO_DONE(FAIL) /* Can't return errors when library is shutting down */ + } /* end if */ + /* Get driver ID property */ if(H5P_get(plist, H5F_ACS_FILE_DRV_ID_NAME, &driver_id) < 0) HGOTO_DONE(FAIL) /* Can't return errors when library is shutting down */ @@ -1975,6 +2050,170 @@ done: /*------------------------------------------------------------------------- + * Function: H5P_set_vol + * + * Purpose: Set the vol plugin 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. + * + * Return: Success: Non-negative + * Failure: Negative + * + * Programmer: Mohamad Chaarawi + * January, 2012 + * + *------------------------------------------------------------------------- + */ +herr_t +H5P_set_vol(H5P_genplist_t *plist, hid_t vol_id, const void *vol_info) +{ + hid_t old_vol_id; + void *old_vol_info; + herr_t ret_value=SUCCEED; /* Return value */ + + FUNC_ENTER_NOAPI(FAIL) + + if(TRUE == H5P_isa_class(plist->plist_id, H5P_FILE_ACCESS)) { + /* Get the current vol information */ + if(H5P_get(plist, H5F_ACS_VOL_ID_NAME, &old_vol_id) < 0) + HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, FAIL, "can't get vol class") + if(H5P_get(plist, H5F_ACS_VOL_INFO_NAME, &old_vol_info) < 0) + HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, FAIL, "can't get vol info") + + /* Close the vol for the property list */ + if(H5VL_fapl_close(old_vol_id, old_vol_info)<0) + HGOTO_ERROR(H5E_PLIST, H5E_CANTSET, FAIL, "can't reset vol") + + /* Set the vol for the property list */ + if(H5VL_fapl_open(plist, vol_id, vol_info)<0) + HGOTO_ERROR(H5E_PLIST, H5E_CANTSET, FAIL, "can't set vol") + } + else + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a file access property list"); + +done: + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5P_set_vol() */ + + +/*------------------------------------------------------------------------- + * Function: H5Pset_vol + * + * Purpose: Set the file vol plugin (VOL_ID) for a file access + * property list (PLIST_ID) + * + * Return: Success: Non-negative + * + * Failure: Negative + * + * Programmer: Mohamad Chaarawi + * April, 2012 + * + *------------------------------------------------------------------------- + */ +herr_t +H5Pset_vol(hid_t plist_id, hid_t new_vol_id, const void *new_vol_info) +{ + H5P_genplist_t *plist; /* Property list pointer */ + herr_t ret_value = SUCCEED; /* Return value */ + + FUNC_ENTER_API(FAIL) + H5TRACE3("e", "ii*x", plist_id, new_vol_id, new_vol_info); + + /* Check arguments */ + 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") + + /* 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") + +done: + FUNC_LEAVE_API(ret_value) +} /* end H5Pset_vol() */ + + +/*------------------------------------------------------------------------- + * 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. + * + * Programmer: Mohamad Chaarawi + * July, 2012 + * + *------------------------------------------------------------------------- + */ +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) ) { + if(H5P_get(plist, H5F_ACS_VOL_INFO_NAME, &ret_value) < 0) + HGOTO_ERROR(H5E_PLIST, H5E_CANTGET,NULL,"can't get vol 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. + * + * 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. + * + * Programmer: Mohamad Chaarawi + * July 2012 + * + *------------------------------------------------------------------------- + */ +void * +H5Pget_vol_info(hid_t plist_id) +{ + H5P_genplist_t *plist; /* Property list pointer */ + void *ret_value; /* Return value */ + + FUNC_ENTER_API(NULL) + + 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: H5Pset_file_image * * Purpose: Sets the initial file image. Some file drivers can initialize diff --git a/src/H5Pgcpl.c b/src/H5Pgcpl.c index b7d5106..0ce3ca8 100644 --- a/src/H5Pgcpl.c +++ b/src/H5Pgcpl.c @@ -128,6 +128,7 @@ static const H5O_linfo_t H5G_def_linfo_g = H5G_CRT_LINK_INFO_DEF; /* Defaul static herr_t H5P__gcrt_reg_prop(H5P_genclass_t *pclass) { + hid_t lcpl_id = H5P_LINK_CREATE_DEFAULT; herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_STATIC @@ -144,6 +145,11 @@ H5P__gcrt_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 lcpl ID property */ + if(H5P_register_real(pclass, H5VL_PROP_GRP_LCPL_ID, sizeof(hid_t), &lcpl_id, + NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL) < 0) + HGOTO_ERROR(H5E_PLIST, H5E_CANTINSERT, FAIL, "can't insert property into class") + done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5P__gcrt_reg_prop() */ diff --git a/src/H5Pint.c b/src/H5Pint.c index c71a39b..06ec48c 100644 --- a/src/H5Pint.c +++ b/src/H5Pint.c @@ -299,7 +299,7 @@ static const H5I_class_t H5I_GENPROPCLS_CLS[1] = {{ H5I_GENPROP_CLS, /* ID class value */ 0, /* Class flags */ 0, /* # of reserved IDs for class */ - (H5I_free_t)H5P_close_class /* Callback routine for closing objects of this class */ + (H5I_free_t)H5P_close_class /* Callback routine for closing objects of this class */ }}; /* Generic Property List ID class */ @@ -307,7 +307,7 @@ static const H5I_class_t H5I_GENPROPLST_CLS[1] = {{ H5I_GENPROP_LST, /* ID class value */ 0, /* Class flags */ 0, /* # of reserved IDs for class */ - (H5I_free_t)H5P_close /* Callback routine for closing objects of this class */ + (H5I_free_t)H5P_close /* Callback routine for closing objects of this class */ }}; diff --git a/src/H5Plcpl.c b/src/H5Plcpl.c index cde2035..7d2b7f4 100644 --- a/src/H5Plcpl.c +++ b/src/H5Plcpl.c @@ -51,6 +51,31 @@ #define H5L_CRT_INTERMEDIATE_GROUP_ENC H5P__encode_unsigned #define H5L_CRT_INTERMEDIATE_GROUP_DEC H5P__decode_unsigned +/* ======== VOL specific properties ========= */ +/* Definitions for target object ID */ +#define H5L_CRT_TARGET_SIZE sizeof(void *) +#define H5L_CRT_TARGET_DEF NULL + +/* 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} + +/* Definitions for target object NAME */ +#define H5L_CRT_TARGET_NAME_SIZE sizeof(char *) +#define H5L_CRT_TARGET_NAME_DEF NULL + +/* Definitions for link type */ +#define H5L_CRT_LINK_TYPE_SIZE sizeof(link_type) +#define H5L_CRT_LINK_TYPE_DEF H5L_TYPE_ERROR + +/* Definitions for UDATA */ +#define H5L_CRT_UDATA_SIZE sizeof(void *) +#define H5L_CRT_UDATA_DEF NULL + +/* Definitions for UDATA_SIZE */ +#define H5L_CRT_UDATA_SIZE_SIZE sizeof(size_t) +#define H5L_CRT_UDATA_SIZE_DEF 0 + /******************/ /* Local Typedefs */ /******************/ @@ -121,6 +146,12 @@ static const unsigned H5L_def_intmd_group_g = H5L_CRT_INTERMEDIATE_GROUP_DEF; herr_t H5P_lcrt_reg_prop(H5P_genclass_t *pclass) { + void* target = H5L_CRT_TARGET_DEF; + H5VL_loc_params_t loc_params = H5L_CRT_LOCATION_DEF; + char *target_name = H5L_CRT_TARGET_NAME_DEF; + H5L_type_t link_type = H5L_CRT_LINK_TYPE_DEF; + void *udata = H5L_CRT_UDATA_DEF; + size_t udata_size = H5L_CRT_UDATA_SIZE_DEF; herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_NOAPI(FAIL) @@ -131,6 +162,30 @@ H5P_lcrt_reg_prop(H5P_genclass_t *pclass) NULL, NULL, NULL, NULL) < 0) HGOTO_ERROR(H5E_PLIST, H5E_CANTINSERT, FAIL, "can't insert property into class") + if(H5P_register_real(pclass, H5VL_PROP_LINK_TARGET, H5L_CRT_TARGET_SIZE, &target, + NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL) < 0) + HGOTO_ERROR(H5E_PLIST, H5E_CANTINSERT, FAIL, "can't insert property into class") + + if(H5P_register_real(pclass, H5VL_PROP_LINK_TARGET_LOC_PARAMS, H5L_CRT_LOCATION_SIZE, &loc_params, + NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL) < 0) + HGOTO_ERROR(H5E_PLIST, H5E_CANTINSERT, FAIL, "can't insert property into class") + + if(H5P_register_real(pclass, H5VL_PROP_LINK_TARGET_NAME, H5L_CRT_TARGET_NAME_SIZE, &target_name, + NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL) < 0) + HGOTO_ERROR(H5E_PLIST, H5E_CANTINSERT, FAIL, "can't insert property into class") + + if(H5P_register_real(pclass, H5VL_PROP_LINK_TYPE, H5L_CRT_LINK_TYPE_SIZE, &link_type, + NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL) < 0) + HGOTO_ERROR(H5E_PLIST, H5E_CANTINSERT, FAIL, "can't insert property into class") + + if(H5P_register_real(pclass, H5VL_PROP_LINK_UDATA, H5L_CRT_UDATA_SIZE, &udata, + NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL) < 0) + HGOTO_ERROR(H5E_PLIST, H5E_CANTINSERT, FAIL, "can't insert property into class") + + if(H5P_register_real(pclass, H5VL_PROP_LINK_UDATA_SIZE, H5L_CRT_UDATA_SIZE_SIZE, &udata_size, + NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL) < 0) + HGOTO_ERROR(H5E_PLIST, H5E_CANTINSERT, FAIL, "can't insert property into class") + done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5P_lcrt_reg_prop() */ diff --git a/src/H5Pocpl.c b/src/H5Pocpl.c index 37beb90..94fb5b2 100644 --- a/src/H5Pocpl.c +++ b/src/H5Pocpl.c @@ -834,7 +834,7 @@ H5P__set_filter(H5P_genplist_t *plist, H5Z_filter_t filter, unsigned int flags, if(!filter_avail) { const H5Z_class2_t *filter_info; - if(NULL == (filter_info = (const H5Z_class2_t *)H5PL_load(H5PL_TYPE_FILTER, (int)filter))) + if(NULL == (filter_info = (const H5Z_class2_t *)H5PL_load(H5PL_TYPE_FILTER, (int)filter, NULL))) HGOTO_ERROR(H5E_PLINE, H5E_CANTLOAD, FAIL, "failed to load dynamically loaded plugin") if(H5Z_register(filter_info) < 0) HGOTO_ERROR(H5E_PLINE, H5E_CANTINIT, FAIL, "unable to register filter") diff --git a/src/H5Pprivate.h b/src/H5Pprivate.h index 7233818..b74b1cd4 100644 --- a/src/H5Pprivate.h +++ b/src/H5Pprivate.h @@ -21,6 +21,7 @@ /* Include package's public header */ #include "H5Ppublic.h" +#include "H5VLpublic.h" /* Private headers needed by this file */ #include "H5private.h" /* Generic Functions */ @@ -128,6 +129,8 @@ H5_DLL hid_t H5P_get_driver(H5P_genplist_t *plist); H5_DLL void * H5P_get_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 f56692c..4cd316d 100644 --- a/src/H5Ppublic.h +++ b/src/H5Ppublic.h @@ -308,6 +308,14 @@ H5_DLL herr_t H5Pset_driver(hid_t plist_id, hid_t driver_id, const void *driver_info); H5_DLL hid_t H5Pget_driver(hid_t plist_id); H5_DLL 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 H5Pset_vol(hid_t plist_id, hid_t vol_id, const void *vol_info); +H5_DLL hid_t H5Pget_vol(hid_t plist_id); +H5_DLL void *H5Pget_vol_info(hid_t plist_id); +*/ 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); @@ -36,6 +36,7 @@ #include "H5MMprivate.h" /* Memory management */ #include "H5Rpkg.h" /* References */ #include "H5Sprivate.h" /* Dataspaces */ +#include "H5VLprivate.h" /* VOL plugins */ /****************/ @@ -52,12 +53,6 @@ /* Local Prototypes */ /********************/ -static herr_t H5R_create(void *ref, H5G_loc_t *loc, const char *name, - H5R_type_t ref_type, H5S_t *space, hid_t dxpl_id); -static H5S_t * H5R_get_region(H5F_t *file, hid_t dxpl_id, const void *_ref); -static ssize_t H5R_get_name(H5F_t *file, hid_t lapl_id, hid_t dxpl_id, hid_t id, - H5R_type_t ref_type, const void *_ref, char *name, size_t size); - /*********************/ /* Package Variables */ @@ -210,7 +205,7 @@ H5R_term_interface(void) EXAMPLES REVISION LOG --------------------------------------------------------------------------*/ -static herr_t +herr_t H5R_create(void *_ref, H5G_loc_t *loc, const char *name, H5R_type_t ref_type, H5S_t *space, hid_t dxpl_id) { H5G_loc_t obj_loc; /* Group hier. location of object */ @@ -354,8 +349,8 @@ done: herr_t H5Rcreate(void *ref, hid_t loc_id, const char *name, H5R_type_t ref_type, hid_t space_id) { - H5G_loc_t loc; /* File location */ - H5S_t *space = NULL; /* Pointer to dataspace containing region */ + H5VL_object_t *obj = NULL; /* object token of loc_id */ + H5VL_loc_params_t loc_params; herr_t ret_value; /* Return value */ FUNC_ENTER_API(FAIL) @@ -364,8 +359,6 @@ H5Rcreate(void *ref, hid_t loc_id, const char *name, H5R_type_t ref_type, hid_t /* Check args */ if(ref == NULL) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "invalid reference pointer") - 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 given") if(ref_type <= H5R_BADTYPE || ref_type >= H5R_MAXTYPE) @@ -374,12 +367,19 @@ H5Rcreate(void *ref, hid_t loc_id, const char *name, H5R_type_t ref_type, hid_t HGOTO_ERROR(H5E_ARGS, H5E_UNSUPPORTED, FAIL, "reference type not supported") if(space_id == (-1) && ref_type == H5R_DATASET_REGION) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "reference region dataspace id must be valid") - 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((ret_value = H5R_create(ref, &loc, name, ref_type, space, H5AC_dxpl_id)) < 0) - HGOTO_ERROR(H5E_REFERENCE, H5E_CANTINIT, FAIL, "unable to create reference") + loc_params.type = H5VL_OBJECT_BY_SELF; + loc_params.obj_type = H5I_get_type(loc_id); + + /* get the file object */ + if(NULL == (obj = (H5VL_object_t *)H5I_object(loc_id))) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "invalid file identifier") + + /* create the ref through the VOL */ + if((ret_value = H5VL_object_specific(obj->vol_obj, loc_params, obj->vol_info->vol_cls, H5VL_REF_CREATE, + H5AC_dxpl_id, H5_REQUEST_NULL, + ref, name, ref_type, space_id)) < 0) + HGOTO_ERROR(H5E_OHDR, H5E_LINKCOUNT, FAIL, "modifying object link count failed") done: FUNC_LEAVE_API(ret_value) @@ -573,29 +573,40 @@ done: hid_t H5Rdereference2(hid_t obj_id, hid_t oapl_id, H5R_type_t ref_type, const void *_ref) { - H5G_loc_t loc; /* Group location */ - H5F_t *file = NULL; /* File object */ - hid_t ret_value; + H5VL_object_t *obj = NULL; /* object token of loc_id */ + H5I_type_t opened_type; + void *opened_obj = NULL; + H5VL_loc_params_t loc_params; + hid_t ret_value = FAIL; FUNC_ENTER_API(FAIL) H5TRACE4("i", "iiRt*x", obj_id, oapl_id, ref_type, _ref); /* Check args */ - if(H5G_loc(obj_id, &loc) < 0) - HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a location") - if(oapl_id < 0) + if(oapl_id < 0) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a property list") if(ref_type <= H5R_BADTYPE || ref_type >= H5R_MAXTYPE) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "invalid reference type") if(_ref == NULL) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "invalid reference pointer") - /* Get the file pointer from the entry */ - file = loc.oloc->file; + /* get the vol object */ + if(NULL == (obj = H5VL_get_object(obj_id))) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "invalid file identifier") + + loc_params.type = H5VL_OBJECT_BY_REF; + loc_params.loc_data.loc_by_ref.ref_type = ref_type; + loc_params.loc_data.loc_by_ref._ref = _ref; + loc_params.loc_data.loc_by_ref.lapl_id = oapl_id; + loc_params.obj_type = H5I_get_type(obj_id); + + /* Open the object through the VOL */ + if(NULL == (opened_obj = H5VL_object_open(obj->vol_obj, loc_params, obj->vol_info->vol_cls, &opened_type, + H5AC_dxpl_id, H5_REQUEST_NULL))) + HGOTO_ERROR(H5E_REFERENCE, H5E_CANTINIT, FAIL, "unable to dereference object") - /* Create reference */ - if((ret_value = H5R_dereference(file, oapl_id, H5AC_dxpl_id, ref_type, _ref, TRUE)) < 0) - HGOTO_ERROR(H5E_REFERENCE, H5E_CANTINIT, FAIL, "unable to dereference object") + if((ret_value = H5VL_register_id(opened_type, opened_obj, obj->vol_info, TRUE)) < 0) + HGOTO_ERROR(H5E_ATOM, H5E_CANTREGISTER, FAIL, "unable to atomize object handle") done: FUNC_LEAVE_API(ret_value) @@ -623,7 +634,7 @@ done: EXAMPLES REVISION LOG --------------------------------------------------------------------------*/ -static H5S_t * +H5S_t * H5R_get_region(H5F_t *file, hid_t dxpl_id, const void *_ref) { H5O_loc_t oloc; /* Object location */ @@ -697,28 +708,30 @@ done: hid_t H5Rget_region(hid_t id, H5R_type_t ref_type, const void *ref) { - H5G_loc_t loc; /* Object's group location */ - H5S_t *space = NULL; /* Dataspace object */ + H5VL_object_t *obj = NULL; /* object token of loc_id */ + H5VL_loc_params_t loc_params; hid_t ret_value; FUNC_ENTER_API(FAIL) H5TRACE3("i", "iRt*x", id, ref_type, ref); /* Check args */ - if(H5G_loc(id, &loc) < 0) - HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a location") if(ref_type != H5R_DATASET_REGION) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "invalid reference type") if(ref == NULL) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "invalid reference pointer") - /* Get the dataspace with the correct region selected */ - if((space = H5R_get_region(loc.oloc->file, H5AC_ind_dxpl_id, ref)) == NULL) - HGOTO_ERROR(H5E_REFERENCE, H5E_CANTCREATE, FAIL, "unable to create dataspace") + loc_params.type = H5VL_OBJECT_BY_SELF; + loc_params.obj_type = H5I_get_type(id); - /* Atomize */ - if((ret_value = H5I_register (H5I_DATASPACE, space, TRUE)) < 0) - HGOTO_ERROR(H5E_ATOM, H5E_CANTREGISTER, FAIL, "unable to register dataspace atom") + /* get the file object */ + if(NULL == (obj = (H5VL_object_t *)H5I_object(id))) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "invalid file identifier") + + /* Get the space id through the VOL */ + if(H5VL_object_get(obj->vol_obj, loc_params, obj->vol_info->vol_cls, H5VL_REF_GET_REGION, + H5AC_ind_dxpl_id, H5_REQUEST_NULL, &ret_value, ref_type, ref) < 0) + HGOTO_ERROR(H5E_INTERNAL, H5E_CANTGET, FAIL, "unable to get group info") done: FUNC_LEAVE_API(ret_value) @@ -838,23 +851,31 @@ herr_t H5Rget_obj_type2(hid_t id, H5R_type_t ref_type, const void *ref, H5O_type_t *obj_type) { - H5G_loc_t loc; /* Object location */ + H5VL_object_t *obj = NULL; /* object token of loc_id */ + H5VL_loc_params_t loc_params; herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_API(FAIL) H5TRACE4("e", "iRt*x*Ot", id, ref_type, ref, obj_type); /* Check args */ - if(H5G_loc(id, &loc) < 0) - HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a location") if(ref_type <= H5R_BADTYPE || ref_type >= H5R_MAXTYPE) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "invalid reference type") if(ref == NULL) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "invalid reference pointer") - /* Get the object information */ - if(H5R_get_obj_type(loc.oloc->file, H5AC_ind_dxpl_id, ref_type, ref, obj_type) < 0) - HGOTO_ERROR(H5E_REFERENCE, H5E_CANTINIT, FAIL, "unable to determine object type") + loc_params.type = H5VL_OBJECT_BY_SELF; + loc_params.obj_type = H5I_get_type(id); + + /* get the file object */ + if(NULL == (obj = (H5VL_object_t *)H5I_object(id))) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "invalid file identifier") + + /* get the object type through the VOL */ + if((ret_value = H5VL_object_get(obj->vol_obj, loc_params, obj->vol_info->vol_cls, + H5VL_REF_GET_TYPE, H5AC_ind_dxpl_id, + H5_REQUEST_NULL, obj_type, ref_type, ref)) < 0) + HGOTO_ERROR(H5E_INTERNAL, H5E_CANTGET, FAIL, "unable to get group info") done: FUNC_LEAVE_API(ret_value) @@ -889,10 +910,11 @@ done: EXAMPLES REVISION LOG --------------------------------------------------------------------------*/ -static ssize_t -H5R_get_name(H5F_t *f, hid_t lapl_id, hid_t dxpl_id, hid_t id, H5R_type_t ref_type, +ssize_t +H5R_get_name(H5G_loc_t *loc, hid_t lapl_id, hid_t dxpl_id, H5R_type_t ref_type, const void *_ref, char *name, size_t size) { + H5F_t *f; hid_t file_id = (-1); /* ID for file that the reference is in */ H5O_loc_t oloc; /* Object location describing object for reference */ ssize_t ret_value; /* Return value */ @@ -900,9 +922,12 @@ H5R_get_name(H5F_t *f, hid_t lapl_id, hid_t dxpl_id, hid_t id, H5R_type_t ref_ty FUNC_ENTER_NOAPI_NOINIT /* Check args */ - HDassert(f); HDassert(_ref); + /* Get the file pointer from the entry */ + f = loc->oloc->file; + HDassert(f); + /* Initialize the object location */ H5O_loc_reset(&oloc); oloc.file = f; @@ -945,8 +970,8 @@ H5R_get_name(H5F_t *f, hid_t lapl_id, hid_t dxpl_id, hid_t id, H5R_type_t ref_ty } /* end switch */ /* Retrieve file ID for name search */ - if((file_id = H5I_get_file_id(id, FALSE)) < 0) - HGOTO_ERROR(H5E_REFERENCE, H5E_CANTGET, FAIL, "can't retrieve file ID") + if((file_id = H5F_get_id(f, FALSE)) < 0) + HGOTO_ERROR(H5E_ATOM, H5E_CANTGET, FAIL, "can't get file ID") /* Get name, length, etc. */ if((ret_value = H5G_get_name_by_addr(file_id, lapl_id, dxpl_id, &oloc, name, size)) < 0) @@ -998,28 +1023,31 @@ ssize_t H5Rget_name(hid_t id, H5R_type_t ref_type, const void *_ref, char *name, size_t size) { - H5G_loc_t loc; /* Group location */ - H5F_t *file; /* File object */ + H5VL_object_t *obj = NULL; /* object token of loc_id */ + H5VL_loc_params_t loc_params; ssize_t ret_value; /* Return value */ FUNC_ENTER_API(FAIL) H5TRACE5("Zs", "iRt*x*sz", id, ref_type, _ref, name, size); /* Check args */ - if(H5G_loc(id, &loc) < 0) - HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a location") if(ref_type <= H5R_BADTYPE || ref_type >= H5R_MAXTYPE) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "invalid reference type") if(_ref == NULL) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "invalid reference pointer") - /* Get the file pointer from the entry */ - file = loc.oloc->file; + loc_params.type = H5VL_OBJECT_BY_SELF; + loc_params.obj_type = H5I_get_type(id); - /* Get name */ - if((ret_value = H5R_get_name(file, H5P_DEFAULT, H5AC_dxpl_id, id, ref_type, _ref, name, size)) < 0) - HGOTO_ERROR(H5E_REFERENCE, H5E_CANTINIT, FAIL, "unable to determine object path") + /* get the file object */ + if(NULL == (obj = (H5VL_object_t *)H5I_object(id))) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "invalid file identifier") + /* get the object type through the VOL */ + if(H5VL_object_get(obj->vol_obj, loc_params, obj->vol_info->vol_cls, H5VL_REF_GET_NAME, + H5AC_dxpl_id, H5_REQUEST_NULL, + &ret_value, name, size, ref_type, _ref) < 0) + HGOTO_ERROR(H5E_INTERNAL, H5E_CANTGET, FAIL, "unable to get group info") done: FUNC_LEAVE_API(ret_value) } /* end H5Rget_name() */ diff --git a/src/H5Rdeprec.c b/src/H5Rdeprec.c index ea30913..1a01e07 100644 --- a/src/H5Rdeprec.c +++ b/src/H5Rdeprec.c @@ -44,9 +44,11 @@ #include "H5ACprivate.h" /* Metadata cache */ #include "H5Eprivate.h" /* Error handling */ #include "H5Gprivate.h" /* Groups */ +#include "H5Iprivate.h" /* IDs */ #include "H5Oprivate.h" /* Object headers */ #include "H5Rpkg.h" /* References */ #include "H5Ppublic.h" /* for using H5P_DATASET_ACCESS_DEFAULT */ +#include "H5VLprivate.h" /* VOL plugins */ /****************/ @@ -157,7 +159,8 @@ H5R__term_deprec_interface(void) H5G_obj_t H5Rget_obj_type1(hid_t id, H5R_type_t ref_type, const void *ref) { - H5G_loc_t loc; /* Object location */ + H5VL_object_t *obj = NULL; /* object token of loc_id */ + H5VL_loc_params_t loc_params; H5O_type_t obj_type; /* Object type */ H5G_obj_t ret_value; /* Return value */ @@ -165,16 +168,22 @@ H5Rget_obj_type1(hid_t id, H5R_type_t ref_type, const void *ref) H5TRACE3("Go", "iRt*x", id, ref_type, ref); /* Check args */ - if(H5G_loc(id, &loc) < 0) - HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, H5G_UNKNOWN, "not a location") if(ref_type <= H5R_BADTYPE || ref_type >= H5R_MAXTYPE) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, H5G_UNKNOWN, "invalid reference type") if(ref == NULL) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, H5G_UNKNOWN, "invalid reference pointer") - /* Get the object information */ - if(H5R_get_obj_type(loc.oloc->file, H5AC_ind_dxpl_id, ref_type, ref, &obj_type) < 0) - HGOTO_ERROR(H5E_REFERENCE, H5E_CANTINIT, H5G_UNKNOWN, "unable to determine object type") + loc_params.type = H5VL_OBJECT_BY_SELF; + loc_params.obj_type = H5I_get_type(id); + + /* get the vol object */ + if(NULL == (obj = H5VL_get_object(id))) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "invalid file identifier") + + /* get the object type through the VOL */ + if((ret_value = H5VL_object_get(obj->vol_obj, loc_params, obj->vol_info->vol_cls, H5VL_REF_GET_TYPE, + H5AC_ind_dxpl_id, H5_REQUEST_NULL, &obj_type, ref_type, ref)) < 0) + HGOTO_ERROR(H5E_INTERNAL, H5E_CANTGET, FAIL, "unable to get group info") /* Set return value */ ret_value = H5G_map_obj_type(obj_type); @@ -209,27 +218,39 @@ done: hid_t H5Rdereference1(hid_t obj_id, H5R_type_t ref_type, const void *_ref) { - H5G_loc_t loc; /* Group location */ - H5F_t *file = NULL; /* File object */ - hid_t ret_value; + H5VL_object_t *obj = NULL; /* object token of loc_id */ + H5I_type_t opened_type; + void *opened_obj = NULL; + H5VL_loc_params_t loc_params; + hid_t ret_value = FAIL; FUNC_ENTER_API(FAIL) H5TRACE3("i", "iRt*x", obj_id, ref_type, _ref); /* Check args */ - if(H5G_loc(obj_id, &loc) < 0) - HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a location") if(ref_type <= H5R_BADTYPE || ref_type >= H5R_MAXTYPE) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "invalid reference type") if(_ref == NULL) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "invalid reference pointer") - /* Get the file pointer from the entry */ - file = loc.oloc->file; + /* get the vol object */ + if(NULL == (obj = H5VL_get_object(obj_id))) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "invalid file identifier") + + loc_params.type = H5VL_OBJECT_BY_REF; + loc_params.loc_data.loc_by_ref.ref_type = ref_type; + loc_params.loc_data.loc_by_ref._ref = _ref; + loc_params.loc_data.loc_by_ref.lapl_id = H5P_DATASET_ACCESS_DEFAULT; + loc_params.obj_type = H5I_get_type(obj_id); + + /* Open the object through the VOL */ + if(NULL == (opened_obj = H5VL_object_open(obj->vol_obj, loc_params, obj->vol_info->vol_cls, &opened_type, + H5AC_dxpl_id, H5_REQUEST_NULL))) + HGOTO_ERROR(H5E_SYM, H5E_CANTINIT, FAIL, "unable to open object") - /* Create reference */ - if((ret_value = H5R_dereference(file, H5P_DATASET_ACCESS_DEFAULT, H5AC_dxpl_id, ref_type, _ref, TRUE)) < 0) - HGOTO_ERROR(H5E_REFERENCE, H5E_CANTINIT, FAIL, "unable dereference object") + /* Get an atom for the object */ + if((ret_value = H5VL_register_id(opened_type, opened_obj, obj->vol_info, TRUE)) < 0) + HGOTO_ERROR(H5E_ATOM, H5E_CANTREGISTER, FAIL, "unable to atomize object handle") done: FUNC_LEAVE_API(ret_value) diff --git a/src/H5Rpkg.h b/src/H5Rpkg.h index fd16754..c74329f 100644 --- a/src/H5Rpkg.h +++ b/src/H5Rpkg.h @@ -33,6 +33,7 @@ /* Other private headers needed by this file */ #include "H5Fprivate.h" /* File access */ +#include "H5Sprivate.h" /* Dataspaces */ /**************************/ /* Package Private Macros */ @@ -60,6 +61,11 @@ H5_DLL herr_t H5R_get_obj_type(H5F_t *file, hid_t dxpl_id, H5R_type_t ref_type, const void *_ref, H5O_type_t *obj_type); H5_DLL hid_t H5R_dereference(H5F_t *file, hid_t dapl_id, hid_t dxpl_id, H5R_type_t ref_type, const void *_ref, hbool_t app_ref); +H5_DLL herr_t H5R_create(void *ref, H5G_loc_t *loc, const char *name, + H5R_type_t ref_type, H5S_t *space, hid_t dxpl_id); +H5_DLL H5S_t * H5R_get_region(H5F_t *file, hid_t dxpl_id, const void *_ref); +H5_DLL ssize_t H5R_get_name(H5G_loc_t *loc, hid_t lapl_id, hid_t dxpl_id, H5R_type_t ref_type, + const void *_ref, char *name, size_t size); #endif /* _H5Rpkg_H */ @@ -45,6 +45,7 @@ #include "H5MMprivate.h" /* Memory management */ #include "H5Pprivate.h" /* Property lists */ #include "H5Tpkg.h" /* Datatypes */ +#include "H5VLprivate.h" /* Virtual Object Layer */ /* Check for header needed for SGI floating-point code */ #ifdef H5_HAVE_SYS_FPU_H @@ -529,7 +530,7 @@ static const H5I_class_t H5I_DATATYPE_CLS[1] = {{ H5I_DATATYPE, /* ID class value */ 0, /* Class flags */ 8, /* # of reserved IDs for class */ - (H5I_free_t)H5T_close /* Callback routine for closing objects of this class */ + (H5I_free_t)H5T_close_datatype /* Callback routine for closing objects of this class */ }}; @@ -1691,7 +1692,7 @@ H5Tcopy(hid_t type_id) H5D_t *dset; /* Dataset for datatype */ /* The argument is a dataset handle */ - if(NULL == (dset = (H5D_t *)H5I_object(type_id))) + if(NULL == (dset = (H5D_t *)H5VL_object(type_id))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a dataset") if(NULL == (dt = H5D_typeof(dset))) HGOTO_ERROR(H5E_DATASET, H5E_CANTINIT, FAIL, "unable to get the dataset datatype") @@ -1758,13 +1759,13 @@ H5Tclose(hid_t type_id) /* Check args */ if(NULL == (dt = (H5T_t *)H5I_object_verify(type_id, H5I_DATATYPE))) - HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a datatype") + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a datatype") if(H5T_STATE_IMMUTABLE == dt->shared->state) - HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "immutable datatype") + HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "immutable datatype") /* When the reference count reaches zero the resources are freed */ if(H5I_dec_app_ref(type_id) < 0) - HGOTO_ERROR(H5E_ATOM, H5E_BADATOM, FAIL, "problem freeing id") + HGOTO_ERROR(H5E_ATOM, H5E_BADATOM, FAIL, "problem freeing id") done: FUNC_LEAVE_API(ret_value) @@ -2984,6 +2985,7 @@ H5T_decode(const unsigned char *buf) if(H5T_set_loc(ret_value, NULL, H5T_LOC_MEMORY) < 0) HGOTO_ERROR(H5E_DATATYPE, H5E_CANTINIT, NULL, "invalid datatype location") + ret_value->vol_obj = NULL; done: /* Release fake file structure */ if(f && H5F_fake_free(f) < 0) @@ -3105,6 +3107,7 @@ H5T__create(H5T_class_t type, size_t size) if(H5T_STRING != type || H5T_VARIABLE != size) dt->shared->size = size; + dt->vol_obj = NULL; /* Set return value */ ret_value = dt; @@ -3178,7 +3181,7 @@ H5T_copy(H5T_t *old_dt, H5T_copy_t method) /* Copy shared information (entry information is copied last) */ *(new_dt->shared) = *(old_dt->shared); - + new_dt->vol_obj = NULL; /* Check what sort of copy we are making */ switch (method) { case H5T_COPY_TRANSIENT: @@ -3493,6 +3496,7 @@ H5T__alloc(void) if(NULL == (dt->shared = H5FL_CALLOC(H5T_shared_t))) HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, NULL, "memory allocation failed") dt->shared->version = H5O_DTYPE_VERSION_1; + dt->vol_obj = NULL; /* Assign return value */ ret_value = dt; @@ -4964,8 +4968,10 @@ H5T_is_named(const H5T_t *dt) HDassert(dt); - if(dt->shared->state == H5T_STATE_OPEN || dt->shared->state == H5T_STATE_NAMED) + if(dt->vol_obj) ret_value = TRUE; + else + ret_value = (H5T_STATE_OPEN == dt->shared->state || H5T_STATE_NAMED == dt->shared->state); done: FUNC_LEAVE_NOAPI(ret_value) diff --git a/src/H5Tcommit.c b/src/H5Tcommit.c index 7359a56..315920e 100644 --- a/src/H5Tcommit.c +++ b/src/H5Tcommit.c @@ -37,9 +37,10 @@ #include "H5FOprivate.h" /* File objects */ #include "H5Iprivate.h" /* IDs */ #include "H5Lprivate.h" /* Links */ +#include "H5MMprivate.h" /* Memory management */ #include "H5Pprivate.h" /* Property lists */ #include "H5Tpkg.h" /* Datatypes */ - +#include "H5VLprivate.h" /* VOL plugins */ /****************/ /* Local Macros */ @@ -81,6 +82,10 @@ static H5T_t *H5T_open_oid(const H5G_loc_t *loc, hid_t dxpl_id); /* Local Variables */ /*******************/ +/* Declare a free list to manage the H5VL_t struct */ +H5FL_EXTERN(H5VL_t); +/* Declare a free list to manage the H5VL_object_t struct */ +H5FL_EXTERN(H5VL_object_t); /*-------------------------------------------------------------------------- @@ -120,22 +125,25 @@ H5T_init_commit_interface(void) */ herr_t H5Tcommit2(hid_t loc_id, const char *name, hid_t type_id, hid_t lcpl_id, - hid_t tcpl_id, hid_t tapl_id) + hid_t tcpl_id, hid_t tapl_id) { - H5G_loc_t loc; /* Location to create datatype */ - H5T_t *type; /* Datatype for ID */ - herr_t ret_value = SUCCEED; /* Return value */ + void *dt = NULL; /* datatype object created by VOL plugin */ + H5VL_object_t *new_obj = NULL; /* VOL object that holds the datatype object and the VOL info */ + H5T_t *type = NULL; /* high level datatype object that wraps the VOL object */ + H5VL_object_t *obj = NULL; /* object token of loc_id */ + H5VL_loc_params_t loc_params; + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_API(FAIL) H5TRACE6("e", "i*siiii", loc_id, name, type_id, lcpl_id, tcpl_id, tapl_id); /* 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") if(NULL == (type = (H5T_t *)H5I_object_verify(type_id, H5I_DATATYPE))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a datatype") + if(H5T_is_named(type)) + HGOTO_ERROR(H5E_ARGS, H5E_CANTSET, FAIL, "datatype is already committed") /* Get correct property list */ if(H5P_DEFAULT == lcpl_id) @@ -158,9 +166,28 @@ H5Tcommit2(hid_t loc_id, const char *name, hid_t type_id, hid_t lcpl_id, if(TRUE != H5P_isa_class(tapl_id, H5P_DATATYPE_ACCESS)) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not datatype access property list") - /* Commit the type */ - if(H5T__commit_named(&loc, name, type, lcpl_id, tcpl_id, tapl_id, H5AC_dxpl_id) < 0) - HGOTO_ERROR(H5E_DATATYPE, H5E_CANTINIT, FAIL, "unable to commit datatype") + loc_params.type = H5VL_OBJECT_BY_SELF; + loc_params.obj_type = H5I_get_type(loc_id); + + /* get the object from the loc_id */ + if(NULL == (obj = (H5VL_object_t *)H5I_object(loc_id))) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "invalid object identifier") + + /* commit the datatype through the VOL */ + if (NULL == (dt = H5VL_datatype_commit(obj->vol_obj, loc_params, obj->vol_info->vol_cls, + name, type_id, lcpl_id, tcpl_id, tapl_id, + H5AC_dxpl_id, H5_REQUEST_NULL))) + HGOTO_ERROR(H5E_SYM, 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->vol_info = obj->vol_info; + new_obj->vol_info->nrefs ++; + new_obj->vol_obj = dt; + + /* set the committed type object to the VOL pluging pointer in the H5T_t struct */ + type->vol_obj = new_obj; done: FUNC_LEAVE_API(ret_value) @@ -271,18 +298,21 @@ done: herr_t H5Tcommit_anon(hid_t loc_id, hid_t type_id, hid_t tcpl_id, hid_t tapl_id) { - H5G_loc_t loc; /* Group location for location */ - H5T_t *type = NULL; /* Datatype created */ - herr_t ret_value = SUCCEED; /* Return value */ + void *dt = NULL; /* datatype object created by VOL plugin */ + H5VL_object_t *new_obj = NULL; /* VOL object that holds the datatype object and the VOL info */ + H5T_t *type = NULL; /* high level datatype object that wraps the VOL object */ + H5VL_object_t *obj = NULL; /* object token of loc_id */ + H5VL_loc_params_t loc_params; + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_API(FAIL) H5TRACE4("e", "iiii", loc_id, type_id, tcpl_id, tapl_id); - /* Check arguments */ - if(H5G_loc(loc_id, &loc) < 0) - HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a location") + /* check args */ if(NULL == (type = (H5T_t *)H5I_object_verify(type_id, H5I_DATATYPE))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a datatype") + if(H5T_is_named(type)) + HGOTO_ERROR(H5E_ARGS, H5E_CANTSET, FAIL, "datatype is already committed") /* Get correct property list */ if(H5P_DEFAULT == tcpl_id) @@ -298,22 +328,28 @@ H5Tcommit_anon(hid_t loc_id, hid_t type_id, hid_t tcpl_id, hid_t tapl_id) if(TRUE != H5P_isa_class(tapl_id, H5P_DATATYPE_ACCESS)) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not datatype access property list") - /* Commit the type */ - if(H5T__commit(loc.oloc->file, type, tcpl_id, H5AC_dxpl_id) < 0) - HGOTO_ERROR(H5E_DATATYPE, H5E_CANTINIT, FAIL, "unable to commit datatype") + loc_params.type = H5VL_OBJECT_BY_SELF; + loc_params.obj_type = H5I_get_type(loc_id); - /* Release the datatype's object header */ - { - H5O_loc_t *oloc; /* Object location for datatype */ + /* get the file object */ + if(NULL == (obj = (H5VL_object_t *)H5I_object(loc_id))) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "invalid file identifier") - /* Get the new committed datatype's object location */ - if(NULL == (oloc = H5T_oloc(type))) - HGOTO_ERROR(H5E_DATATYPE, H5E_CANTGET, FAIL, "unable to get object location of committed datatype") + /* commite the datatype through the VOL */ + if (NULL == (dt = H5VL_datatype_commit(obj->vol_obj, loc_params, obj->vol_info->vol_cls, + NULL, type_id, H5P_DEFAULT, tcpl_id, tapl_id, + H5AC_dxpl_id, H5_REQUEST_NULL))) + HGOTO_ERROR(H5E_SYM, H5E_CANTINIT, FAIL, "unable to commit datatype") - /* Decrement refcount on committed datatype's object header in memory */ - if(H5O_dec_rc_by_loc(oloc, H5AC_dxpl_id) < 0) - HGOTO_ERROR(H5E_DATATYPE, H5E_CANTDEC, FAIL, "unable to decrement refcount on newly created object") - } /* end if */ + /* 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->vol_info = obj->vol_info; + new_obj->vol_info->nrefs ++; + new_obj->vol_obj = dt; + + /* set the committed type object to the VOL pluging pointer in the H5T_t struct */ + type->vol_obj = new_obj; done: FUNC_LEAVE_API(ret_value) @@ -470,7 +506,7 @@ H5Tcommitted(hid_t type_id) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a datatype") /* Set return value */ - ret_value = H5T_committed(type); + ret_value = H5T_is_named(type); done: FUNC_LEAVE_API(ret_value) @@ -478,30 +514,6 @@ done: /*------------------------------------------------------------------------- - * Function: H5T_committed - * - * Purpose: Determines if a datatype is committed or not. - * - * Return: Success: TRUE if committed, FALSE otherwise. - * - * Programmer: Quincey Koziol - * Wednesday, September 24, 2003 - * - *------------------------------------------------------------------------- - */ -htri_t -H5T_committed(const H5T_t *type) -{ - /* Use no-init for efficiency */ - FUNC_ENTER_NOAPI_NOINIT_NOERR - - HDassert(type); - - FUNC_LEAVE_NOAPI(H5T_STATE_OPEN == type->shared->state || H5T_STATE_NAMED == type->shared->state) -} /* end H5T_committed() */ - - -/*------------------------------------------------------------------------- * Function: H5T_link * * Purpose: Adjust the link count for an object header by adding @@ -551,23 +563,16 @@ done: hid_t H5Topen2(hid_t loc_id, const char *name, hid_t tapl_id) { - H5T_t *type = NULL; /* Datatype opened in file */ - H5G_loc_t loc; /* Group location of object to open */ - H5G_name_t path; /* Datatype group hier. path */ - H5O_loc_t oloc; /* Datatype object location */ - H5O_type_t obj_type; /* Type of object at location */ - H5G_loc_t type_loc; /* Group object for datatype */ - hbool_t obj_found = FALSE; /* Object at 'name' found */ - hid_t dxpl_id = H5AC_dxpl_id; /* dxpl to use to open datatype */ - hid_t ret_value = FAIL; /* Return value */ + void *vol_dt = NULL; /* datatype token created by VOL plugin */ + H5VL_object_t *obj = NULL; /* object token of loc_id */ + H5VL_loc_params_t loc_params; + hid_t ret_value = FAIL; /* Return value */ FUNC_ENTER_API(FAIL) H5TRACE3("i", "i*si", loc_id, name, tapl_id); /* Check args */ - if(H5G_loc(loc_id, &loc) < 0) - HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a location") - if(!name || !*name) + if(!name || !*name) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "no name") /* Get correct property list */ @@ -577,43 +582,26 @@ H5Topen2(hid_t loc_id, const char *name, hid_t tapl_id) if(TRUE != H5P_isa_class(tapl_id, H5P_DATATYPE_ACCESS)) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not datatype access property list") - /* Set up datatype location to fill in */ - type_loc.oloc = &oloc; - type_loc.path = &path; - H5G_loc_reset(&type_loc); - - /* - * Find the named datatype object header and read the datatype message - * from it. - */ - if(H5G_loc_find(&loc, name, &type_loc/*out*/, tapl_id, dxpl_id) < 0) - HGOTO_ERROR(H5E_DATATYPE, H5E_NOTFOUND, FAIL, "not found") - obj_found = TRUE; + loc_params.type = H5VL_OBJECT_BY_SELF; + loc_params.obj_type = H5I_get_type(loc_id); - /* Check that the object found is the correct type */ - if(H5O_obj_type(&oloc, &obj_type, dxpl_id) < 0) - HGOTO_ERROR(H5E_DATATYPE, H5E_CANTGET, FAIL, "can't get object type") - if(obj_type != H5O_TYPE_NAMED_DATATYPE) - HGOTO_ERROR(H5E_DATATYPE, H5E_BADTYPE, FAIL, "not a named datatype") + /* get the location object */ + if(NULL == (obj = (H5VL_object_t *)H5I_object(loc_id))) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "invalid file identifier") - /* Open it */ - if(NULL == (type = H5T_open(&type_loc, dxpl_id))) - HGOTO_ERROR(H5E_DATATYPE, H5E_CANTOPENOBJ, FAIL, "unable to open named datatype") + /* Create the datatype through the VOL */ + if(NULL == (vol_dt = H5VL_datatype_open(obj->vol_obj, loc_params, obj->vol_info->vol_cls, + name, tapl_id, H5AC_dxpl_id, H5_REQUEST_NULL))) + HGOTO_ERROR(H5E_SYM, H5E_CANTOPENOBJ, FAIL, "unable to open datatype") - /* Register the type and return the ID */ - if((ret_value = H5I_register(H5I_DATATYPE, type, TRUE)) < 0) - HGOTO_ERROR(H5E_DATATYPE, H5E_CANTREGISTER, FAIL, "unable to register named datatype") + /* Get an atom for the datatype */ + if((ret_value = H5VL_register_id(H5I_DATATYPE, vol_dt, obj->vol_info, TRUE)) < 0) + HGOTO_ERROR(H5E_ATOM, H5E_CANTREGISTER, FAIL, "unable to atomize datatype handle") done: - if(ret_value < 0) { - if(type != NULL) - H5T_close(type); - else { - if(obj_found && H5F_addr_defined(type_loc.oloc->addr)) - H5G_loc_free(&type_loc); - } /* end else */ - } /* end if */ - + if (ret_value < 0 && vol_dt) + if(H5VL_datatype_close (vol_dt, obj->vol_info->vol_cls, H5AC_dxpl_id, H5_REQUEST_NULL) < 0) + HDONE_ERROR(H5E_SYM, H5E_CLOSEERROR, FAIL, "unable to release datatype") FUNC_LEAVE_API(ret_value) } /* end H5Topen2() */ @@ -639,8 +627,7 @@ H5Tget_create_plist(hid_t dtype_id) { H5T_t *type; /* Datatype object for ID */ H5P_genplist_t *tcpl_plist; /* Existing datatype creation propertty list */ - hid_t new_tcpl_id = FAIL; /* New datatype creation property list */ - herr_t status; /* Generic status value */ + htri_t status; /* Generic status value */ hid_t ret_value; /* Return value */ FUNC_ENTER_API(FAIL) @@ -650,38 +637,31 @@ H5Tget_create_plist(hid_t dtype_id) if(NULL == (type = (H5T_t *)H5I_object_verify(dtype_id, H5I_DATATYPE))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a datatype") - /* Copy the default datatype creation property list */ - if(NULL == (tcpl_plist = (H5P_genplist_t *)H5I_object(H5P_LST_DATATYPE_CREATE_ID_g))) - HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "can't get default creation property list") - if((new_tcpl_id = H5P_copy_plist(tcpl_plist, TRUE)) < 0) - HGOTO_ERROR(H5E_DATATYPE, H5E_CANTGET, FAIL, "unable to copy the creation property list") - /* Check if the datatype is committed */ - if((status = H5T_committed(type)) < 0) + if((status = H5T_is_named(type)) < 0) HGOTO_ERROR(H5E_DATATYPE, H5E_CANTGET, FAIL, "can't check whether datatype is committed") - /* Retrieve further information, if the datatype is committed */ - if(status > 0) { - H5P_genplist_t *new_plist; /* New datatype creation property list */ - - /* Get property list object for new TCPL */ - if(NULL == (new_plist = (H5P_genplist_t *)H5I_object(new_tcpl_id))) - HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "can't get property list") - - /* Retrieve any object creation properties */ - if(H5O_get_create_plist(&type->oloc, H5AC_ind_dxpl_id, new_plist) < 0) - HGOTO_ERROR(H5E_DATATYPE, H5E_CANTGET, FAIL, "can't get object creation info") + /* If the datatype is not committed, just copy the default + creation property list and return that. */ + if(FALSE == status) { + /* Copy the default datatype creation property list */ + if(NULL == (tcpl_plist = (H5P_genplist_t *)H5I_object(H5P_LST_DATATYPE_CREATE_ID_g))) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "can't get default creation property list") + if((ret_value = H5P_copy_plist(tcpl_plist, TRUE)) < 0) + HGOTO_ERROR(H5E_DATATYPE, H5E_CANTGET, FAIL, "unable to copy the creation property list") + } + /* If the datatype is committed, let the VOL create the creation + property list ID. */ + else if(TRUE == status) { + H5VL_object_t *vol_dt = type->vol_obj; + + /* get the rest of the plist through the VOL */ + if(H5VL_datatype_get(vol_dt->vol_obj, vol_dt->vol_info->vol_cls, H5VL_DATATYPE_GET_TCPL, + H5AC_ind_dxpl_id, H5_REQUEST_NULL, &ret_value) < 0) + HGOTO_ERROR(H5E_INTERNAL, H5E_CANTGET, FAIL, "unable to get datatype") } /* end if */ - /* Set the return value */ - ret_value = new_tcpl_id; - done: - if(ret_value < 0) - if(new_tcpl_id > 0) - if(H5I_dec_app_ref(new_tcpl_id) < 0) - HDONE_ERROR(H5E_DATATYPE, H5E_CANTDEC, FAIL, "unable to close temporary object") - FUNC_LEAVE_API(ret_value) } /* end H5Tget_create_plist() */ @@ -886,3 +866,158 @@ H5T_update_shared(H5T_t *dt) FUNC_LEAVE_NOAPI(SUCCEED) } /* H5T_update_shared() */ + +/*------------------------------------------------------------------------- + * Function: H5T_get_named_type + * + * Purpose: returns the VOL object for the named datatype if it exists + * + * Return: Success: Pointer to the VOL Datatype object + * + * Failure: NULL + * + * Programmer: Mohamad Chaarawi + * June 2012 + * + *------------------------------------------------------------------------- + */ +H5VL_object_t * +H5T_get_named_type(const H5T_t *dt) +{ + H5VL_object_t *ret_value = NULL; /* Return value */ + + FUNC_ENTER_NOAPI_NOINIT_NOERR + + if(NULL != dt->vol_obj) + ret_value = dt->vol_obj; + + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5T_get_named_type() */ + + +/*------------------------------------------------------------------------- + * Function: H5T_get_actual_type + * + * Purpose: returns underlying native datatype created by native plugin + * if datatype is committed, otherwise return the datatype + * object associate with the ID. + * + * Return: Success: Pointer to the VOL Datatype object + * + * Failure: NULL + * + * Programmer: Mohamad Chaarawi + * September 2014 + * + *------------------------------------------------------------------------- + */ +H5T_t * +H5T_get_actual_type(const H5T_t *dt) +{ + H5T_t *ret_value = NULL; /* Return value */ + + FUNC_ENTER_NOAPI_NOINIT_NOERR + + /* Check if the datatype is committed */ + if(NULL == dt->vol_obj) + ret_value = dt; + else + ret_value = (H5T_t *)dt->vol_obj->vol_obj; + + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5T_get_actual_type() */ + + +/*------------------------------------------------------------------------- + * Function: H5T_construct_datatype + * + * Purpose: Create a Library datatype with a plugin specific datatype object + * + * Return: Success: A datatype identifier + * + * Failure: FAIL + * + * Programmer: Mohamad Chaarawi + * June, 2012 + * + *------------------------------------------------------------------------- + */ +H5T_t * +H5T_construct_datatype(H5VL_object_t *dt_obj) +{ + ssize_t nalloc; + void *buf = NULL; + H5T_t *dt = NULL; /* datatype token from VOL plugin */ + H5T_t *ret_value = NULL; + + FUNC_ENTER_NOAPI(NULL) + + /* get required buf size for encoding the datatype */ + if(H5VL_datatype_get(dt_obj->vol_obj, dt_obj->vol_info->vol_cls, H5VL_DATATYPE_GET_BINARY, + H5AC_dxpl_id, 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 */ + if (NULL == (buf = (void *) H5MM_malloc ((size_t)nalloc))) + HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, NULL, "can't allocate space for datatype") + + /* get binary description of the datatype */ + if(H5VL_datatype_get(dt_obj->vol_obj, dt_obj->vol_info->vol_cls, H5VL_DATATYPE_GET_BINARY, + H5AC_dxpl_id, 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((const unsigned char *)buf))) + HGOTO_ERROR(H5E_DATATYPE, H5E_CANTINIT, NULL, "can't decode datatype") + + dt->vol_obj = dt_obj; + + H5MM_free(buf); + + ret_value = dt; + +done: + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5T_construct_datatype() */ + + +/*------------------------------------------------------------------------- + * Function: H5T_close_datatype + * + * Purpose: Called when the ref count reaches zero on the datatype_id + * + * Return: Success: Non-negative + * + * Failure: Negative + * + * Programmer: Mohamad Chaarawi + * June 2012 + * + *------------------------------------------------------------------------- + */ +herr_t +H5T_close_datatype(void *type) +{ + H5T_t *dt = (H5T_t *)type; + herr_t ret_value = SUCCEED; /* Return value */ + + FUNC_ENTER_NOAPI_NOINIT + + if (NULL != dt->vol_obj) { + H5VL_object_t *vol_dt = dt->vol_obj; + + /* Close the datatype through the VOL*/ + if((ret_value = H5VL_datatype_close(vol_dt->vol_obj, vol_dt->vol_info->vol_cls, + H5AC_dxpl_id, H5_REQUEST_NULL)) < 0) + HGOTO_ERROR(H5E_DATATYPE, H5E_CLOSEERROR, FAIL, "unable to close datatype") + + /* free attribute */ + if(H5VL_free_object(vol_dt) < 0) + HGOTO_ERROR(H5E_ATTR, H5E_CANTDEC, FAIL, "unable to free VOL object") + } + + if((ret_value = H5T_close(dt)) < 0) + HGOTO_ERROR(H5E_DATATYPE, H5E_CLOSEERROR, FAIL, "unable to close datatype") + +done: + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5T_close_datatype() */ diff --git a/src/H5Tdeprec.c b/src/H5Tdeprec.c index a8881fb..1691917 100644 --- a/src/H5Tdeprec.c +++ b/src/H5Tdeprec.c @@ -47,7 +47,7 @@ #include "H5Iprivate.h" /* IDs */ #include "H5Ppublic.h" /* Property Lists */ #include "H5Tpkg.h" /* Datatypes */ - +#include "H5VLprivate.h" /* VOL plugins */ /****************/ /* Local Macros */ @@ -83,6 +83,10 @@ /* Local Variables */ /*******************/ +/* Declare a free list to manage the H5VL_t struct */ +H5FL_EXTERN(H5VL_t); +/* Declare a free list to manage the H5VL_object_t struct */ +H5FL_EXTERN(H5VL_object_t); /*-------------------------------------------------------------------------- @@ -149,25 +153,47 @@ H5T__term_deprec_interface(void) herr_t H5Tcommit1(hid_t loc_id, const char *name, hid_t type_id) { - H5G_loc_t loc; /* Location to create datatype */ - H5T_t *type; /* Datatype for ID */ - herr_t ret_value = SUCCEED; /* Return value */ + void *dt = NULL; /* datatype object created by VOL plugin */ + H5VL_object_t *new_obj = NULL; /* VOL object that holds the datatype object and the VOL info */ + H5T_t *type = NULL; /* high level datatype object that wraps the VOL object */ + H5VL_object_t *obj = NULL; /* 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*si", loc_id, name, type_id); /* Check arguments */ - if(H5G_loc(loc_id, &loc) < 0) - HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a location") + if (H5Tcommitted(type_id)) + HGOTO_ERROR(H5E_ARGS, H5E_CANTSET, FAIL, "datatype is already committed") if(!name || !*name) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "no name") if(NULL == (type = (H5T_t *)H5I_object_verify(type_id, H5I_DATATYPE))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a datatype") - /* Commit the datatype to the file, using default property list values */ - if(H5T__commit_named(&loc, name, type, H5P_LINK_CREATE_DEFAULT, - H5P_DATATYPE_CREATE_DEFAULT, H5P_DATATYPE_ACCESS_DEFAULT, H5AC_dxpl_id) < 0) - HGOTO_ERROR(H5E_DATATYPE, H5E_CANTINIT, FAIL, "unable to commit datatype") + loc_params.type = H5VL_OBJECT_BY_SELF; + loc_params.obj_type = H5I_get_type(loc_id); + + /* get the object from the loc_id */ + if(NULL == (obj = (H5VL_object_t *)H5I_object(loc_id))) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "invalid object identifier") + + /* commit the datatype through the VOL */ + if (NULL == (dt = H5VL_datatype_commit(obj->vol_obj, loc_params, obj->vol_info->vol_cls, + name, type_id, H5P_LINK_CREATE_DEFAULT, + H5P_DATATYPE_CREATE_DEFAULT, H5P_DATATYPE_ACCESS_DEFAULT, + H5AC_dxpl_id, H5_REQUEST_NULL))) + HGOTO_ERROR(H5E_SYM, 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->vol_info = obj->vol_info; + new_obj->vol_info->nrefs ++; + new_obj->vol_obj = dt; + + /* set the committed type object to the VOL pluging pointer in the H5T_t struct */ + type->vol_obj = new_obj; done: FUNC_LEAVE_API(ret_value) @@ -193,61 +219,40 @@ done: hid_t H5Topen1(hid_t loc_id, const char *name) { - H5T_t *type = NULL; - H5G_loc_t loc; - H5G_name_t path; /* Datatype group hier. path */ - H5O_loc_t oloc; /* Datatype object location */ - H5O_type_t obj_type; /* Type of object at location */ - H5G_loc_t type_loc; /* Group object for datatype */ - hbool_t obj_found = FALSE; /* Object at 'name' found */ - hid_t dxpl_id = H5AC_dxpl_id; /* dxpl to use to open datatype */ - hid_t ret_value = FAIL; + void *vol_dt = NULL; /* datatype token created by VOL plugin */ + H5T_t *dt = NULL; /* upper level H5T_t for datatype */ + H5VL_object_t *obj = NULL; /* object token of loc_id */ + H5VL_loc_params_t loc_params; + hid_t ret_value = FAIL; /* Return value */ FUNC_ENTER_API(FAIL) H5TRACE2("i", "i*s", loc_id, name); /* Check args */ - if(H5G_loc(loc_id, &loc) < 0) - HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a location") - if(!name || !*name) + if(!name || !*name) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "no name") - /* Set up datatype location to fill in */ - type_loc.oloc = &oloc; - type_loc.path = &path; - H5G_loc_reset(&type_loc); - - /* - * Find the named datatype object header and read the datatype message - * from it. - */ - if(H5G_loc_find(&loc, name, &type_loc/*out*/, H5P_DEFAULT, dxpl_id) < 0) - HGOTO_ERROR(H5E_DATATYPE, H5E_NOTFOUND, FAIL, "not found") - obj_found = TRUE; - - /* Check that the object found is the correct type */ - if(H5O_obj_type(&oloc, &obj_type, dxpl_id) < 0) - HGOTO_ERROR(H5E_DATATYPE, H5E_CANTGET, FAIL, "can't get object type") - if(obj_type != H5O_TYPE_NAMED_DATATYPE) - HGOTO_ERROR(H5E_DATATYPE, H5E_BADTYPE, FAIL, "not a named datatype") - - /* Open it */ - if((type = H5T_open(&type_loc, dxpl_id)) == NULL) - HGOTO_ERROR(H5E_DATATYPE, H5E_CANTOPENOBJ, FAIL, "unable to open named datatype") - - /* Register the type and return the ID */ - if((ret_value = H5I_register(H5I_DATATYPE, type, TRUE)) < 0) - HGOTO_ERROR(H5E_DATATYPE, H5E_CANTREGISTER, FAIL, "unable to register named datatype") + loc_params.type = H5VL_OBJECT_BY_SELF; + loc_params.obj_type = H5I_get_type(loc_id); + + /* get the location object */ + if(NULL == (obj = (H5VL_object_t *)H5I_object(loc_id))) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "invalid location identifier") + + /* Create the datatype through the VOL */ + if(NULL == (vol_dt = H5VL_datatype_open(obj->vol_obj, loc_params, obj->vol_info->vol_cls, + name, H5P_DATATYPE_ACCESS_DEFAULT, + H5AC_dxpl_id, H5_REQUEST_NULL))) + HGOTO_ERROR(H5E_SYM, H5E_CANTINIT, FAIL, "unable to open datatype") + + /* Get an atom for the datatype */ + if((ret_value = H5VL_register_id(H5I_DATATYPE, vol_dt, obj->vol_info, TRUE)) < 0) + HGOTO_ERROR(H5E_ATOM, H5E_CANTREGISTER, FAIL, "unable to atomize datatype handle") done: - if(ret_value < 0) { - if(type != NULL) - H5T_close(type); - else { - if(obj_found && H5F_addr_defined(type_loc.oloc->addr)) - H5G_loc_free(&type_loc); - } /* end else */ - } /* end if */ + if (ret_value < 0 && dt) + if(H5VL_datatype_close (vol_dt, obj->vol_info->vol_cls, H5AC_dxpl_id, H5_REQUEST_NULL) < 0) + HDONE_ERROR(H5E_SYM, H5E_CLOSEERROR, FAIL, "unable to release dataset") FUNC_LEAVE_API(ret_value) } /* end H5Topen1() */ diff --git a/src/H5Toh.c b/src/H5Toh.c index 7961706..096e655 100644 --- a/src/H5Toh.c +++ b/src/H5Toh.c @@ -216,14 +216,16 @@ done: static H5O_loc_t * H5O_dtype_get_oloc(hid_t obj_id) { - H5T_t *type; /* Datatype opened */ + H5T_t *type=NULL, *dt=NULL; /* Datatype opened */ H5O_loc_t *ret_value; /* Return value */ FUNC_ENTER_NOAPI_NOINIT /* Get the datatype */ - if(NULL == (type = (H5T_t *)H5I_object(obj_id))) + if(NULL == (dt = (H5T_t *)H5I_object(obj_id))) HGOTO_ERROR(H5E_OHDR, H5E_BADATOM, NULL, "couldn't get object from ID") + /* If this is a named datatype, get the plugin pointer to the datatype */ + type = (const H5T_t *)H5T_get_actual_type(dt); /* Get the datatype's object header location */ if(NULL == (ret_value = H5T_oloc(type))) diff --git a/src/H5Torder.c b/src/H5Torder.c index 35be454..b807464 100644 --- a/src/H5Torder.c +++ b/src/H5Torder.c @@ -236,6 +236,8 @@ H5Tset_order(hid_t type_id, H5T_order_t order) HGOTO_ERROR(H5E_DATATYPE, H5E_BADTYPE, FAIL, "not a datatype") if(order < H5T_ORDER_LE || order > H5T_ORDER_NONE || order == H5T_ORDER_MIXED) HGOTO_ERROR(H5E_DATATYPE, H5E_BADVALUE, FAIL, "illegal byte order") + if (NULL != dt->vol_obj) + HGOTO_ERROR(H5E_ARGS, H5E_CANTSET, FAIL, "datatype is already committed") if(H5T_STATE_TRANSIENT != dt->shared->state) HGOTO_ERROR(H5E_DATATYPE, H5E_CANTINIT, FAIL, "datatype is read-only") diff --git a/src/H5Tpkg.h b/src/H5Tpkg.h index bd37829..11e3de1 100644 --- a/src/H5Tpkg.h +++ b/src/H5Tpkg.h @@ -393,6 +393,7 @@ struct H5T_t { H5T_shared_t *shared; /* all other information */ H5O_loc_t oloc; /* Object location, if the type is a named type */ H5G_name_t path; /* group hier. path if the type is a named type */ + H5VL_object_t *vol_obj; }; /* The master list of soft conversion functions */ diff --git a/src/H5Tprecis.c b/src/H5Tprecis.c index b3975af..6a51bab 100644 --- a/src/H5Tprecis.c +++ b/src/H5Tprecis.c @@ -179,7 +179,9 @@ H5Tset_precision(hid_t type_id, size_t prec) if (NULL == (dt = H5I_object_verify(type_id,H5I_DATATYPE))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a datatype") if (H5T_STATE_TRANSIENT!=dt->shared->state) - HGOTO_ERROR(H5E_ARGS, H5E_CANTSET, FAIL, "datatype is read-only") + HGOTO_ERROR(H5E_ARGS, H5E_CANTSET, FAIL, "datatype is read-only") + if (NULL != dt->vol_obj) + HGOTO_ERROR(H5E_ARGS, H5E_CANTSET, FAIL, "datatype is committed") if (prec == 0) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "precision must be positive") if (H5T_ENUM==dt->shared->type && dt->shared->u.enumer.nmembs>0) diff --git a/src/H5Tprivate.h b/src/H5Tprivate.h index 558afaf..21179d1 100644 --- a/src/H5Tprivate.h +++ b/src/H5Tprivate.h @@ -24,11 +24,13 @@ /* Other public headers needed by this file */ #include "H5MMpublic.h" /* Memory management */ +#include "H5VLpublic.h" /* VOL */ /* Private headers needed by this file */ #include "H5private.h" /* Generic Functions */ #include "H5Gprivate.h" /* Groups */ #include "H5Rprivate.h" /* References */ +#include "H5VLprivate.h" /* VOL */ /* Macro for size of temporary buffers to contain a single element */ #define H5T_ELEM_BUF_SIZE 256 @@ -139,13 +141,15 @@ H5_DLL uint32_t H5T_hash(H5F_t * file, const H5T_t *dt); H5_DLL herr_t H5T_set_latest_version(H5T_t *dt); H5_DLL herr_t H5T_patch_file(H5T_t *dt, H5F_t *f); H5_DLL htri_t H5T_is_variable_str(const H5T_t *dt); +H5_DLL H5T_t *H5T_construct_datatype(H5VL_object_t *dt_obj); +H5_DLL H5VL_object_t *H5T_get_named_type(const H5T_t *dt); +H5_DLL H5T_t *H5T_get_actual_type(const H5T_t *dt); /* Reference specific functions */ H5_DLL H5R_type_t H5T_get_ref_type(const H5T_t *dt); /* Operations on named datatypes */ H5_DLL H5T_t *H5T_open(const H5G_loc_t *loc, hid_t dxpl_id); -H5_DLL htri_t H5T_committed(const H5T_t *type); H5_DLL int H5T_link(const H5T_t *type, int adjust, hid_t dxpl_id); H5_DLL herr_t H5T_update_shared(H5T_t *type); diff --git a/src/H5VL.c b/src/H5VL.c new file mode 100644 index 0000000..fd7443e --- /dev/null +++ b/src/H5VL.c @@ -0,0 +1,2490 @@ +/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * + * 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 files COPYING and Copyright.html. COPYING can be found at the root * + * of the source code distribution tree; Copyright.html can be found at the * + * root level of an installed copy of the electronic HDF5 document set and * + * is linked from the top-level documents page. It can also be found at * + * http://hdfgroup.org/HDF5/doc/Copyright.html. If you do not have * + * access to either file, you may request a copy from help@hdfgroup.org. * + * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ + +/* + * Programmer: Mohamad Chaarawi <chaarawi@hdfgroup.gov> + * January, 2012 + * + * 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 */ +/****************/ + +#define H5VL_PACKAGE /*suppress error about including H5VLpkg */ + +/* Interface initialization */ +#define H5_INTERFACE_INIT_FUNC H5VL_init_interface + +/***********/ +/* Headers */ +/***********/ +#include "H5private.h" /* Generic Functions */ +#include "H5Aprivate.h" /* Attributes */ +#include "H5Eprivate.h" /* Error handling */ +#include "H5Iprivate.h" /* IDs */ +#include "H5MMprivate.h" /* Memory management */ +#include "H5PLprivate.h" /* Plugins */ +#include "H5VLpkg.h" /* VOL package header */ +#include "H5VLprivate.h" /* VOL */ + +/********************/ +/* Local Prototypes */ +/********************/ +static herr_t H5VL_free_cls(H5VL_class_t *cls); + +/*******************/ +/* Local Variables */ +/*******************/ +typedef struct { + const char *name; + hid_t ret_id; +} H5VL_get_plugin_ud_t; + +/* VOL ID class */ +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 */ +}}; + + +/*------------------------------------------------------------------------- + * Function: H5VL_init + * + * Purpose: Initialize the interface from some other package. + * + * Return: Success: non-negative + * Failure: negative + * + * Programmer: Mohamad Chaarawi + * January, 2012 + * + *------------------------------------------------------------------------- + */ +herr_t +H5VL_init(void) +{ + herr_t ret_value = SUCCEED; /* Return value */ + + FUNC_ENTER_NOAPI(FAIL) + /* FUNC_ENTER() does all the work */ + +done: + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5VL_init() */ + + +/*------------------------------------------------------------------------- + * Function: H5VL_init_interface + * + * Purpose: Initialize the virtual object layer. + * + * Return: Success: Non-negative + * + * Failure: Negative + * + * Programmer: Mohamad Chaarawi + * January, 2012 + * + * Modifications: + * + *------------------------------------------------------------------------- + */ +static herr_t +H5VL_init_interface(void) +{ + herr_t ret_value = SUCCEED; /* Return value */ + + FUNC_ENTER_NOAPI_NOINIT + + /* register VOL ID type */ + if(H5I_register_type(H5I_VOL_CLS) < 0) + HGOTO_ERROR(H5E_VOL, H5E_CANTINIT, FAIL, "unable to initialize interface") + +done: + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5VL_init_interface() */ + + +/*------------------------------------------------------------------------- + * Function: H5VL_term_interface + * + * Purpose: Terminate this interface: free all memory and reset global + * variables to their initial values. Release all ID groups + * associated with this interface. + * + * Return: Success: Positive if anything was done that might + * have affected other interfaces; zero + * otherwise. + * + * Failure: Never fails. + * + * Programmer: Mohamad Chaarawi + * January, 2012 + * + * Modifications: + * + *------------------------------------------------------------------------- + */ +int +H5VL_term_interface(void) +{ + int n = 0, n1 = 0; + hbool_t term = TRUE; + + FUNC_ENTER_NOAPI_NOINIT_NOERR + + if(H5_interface_initialize_g) { + if((n1=H5I_nmembers(H5I_VOL))!=0) { + H5I_clear_type(H5I_VOL, FALSE, FALSE); + term = FALSE; + } else { + H5I_dec_type_ref(H5I_VOL); + } + + if (term) { + H5_interface_initialize_g = 0; + n = 1; + } + else { + n = n1; + } + } + + FUNC_LEAVE_NOAPI(n) +} + + +/*------------------------------------------------------------------------- + * 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 + * virtual object layer object identifiers (cf H5VL_init_interface). + * + * Return: Success: Non-negative + * + * Failure: Negative + * + * Programmer: Mohamad Chaarawi + * January, 2012 + * + * Modifications: + * + *------------------------------------------------------------------------- + */ +static herr_t +H5VL_free_cls(H5VL_class_t *cls) +{ + FUNC_ENTER_NOAPI_NOINIT_NOERR + + /* Sanity check */ + HDassert(cls); + + H5MM_free(cls); + + FUNC_LEAVE_NOAPI(SUCCEED) +} /* end H5VL_free_cls() */ + + +/*------------------------------------------------------------------------- + * Function: H5VL__get_plugin_cb + * + * Purpose: Callback routine to search through registered VLs + * + * Return: Success: The first object in the type for which FUNC + * returns non-zero. NULL if FUNC returned zero + * for every object in the type. + * Failure: NULL + * + * Programmer: Quincey Koziol + * Friday, March 30, 2012 + * + *------------------------------------------------------------------------- + */ +static int +H5VL__get_plugin_cb(void *obj, hid_t id, void *_op_data) +{ + H5VL_get_plugin_ud_t *op_data = (H5VL_get_plugin_ud_t *)_op_data; /* User data for callback */ + H5VL_class_t *cls = (H5VL_class_t *)obj; + int ret_value = H5_ITER_CONT; /* Callback return value */ + + FUNC_ENTER_STATIC_NOERR + + if(0 == strcmp(cls->name, op_data->name)) { + op_data->ret_id = id; + ret_value = H5_ITER_STOP; + } + + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5VL__get_plugin_cb() */ + + +/*------------------------------------------------------------------------- + * Function: H5VLregister + * + * Purpose: Registers a new vol plugin as a member of the virtual object + * layer class. + * + * Return: Success: A vol plugin ID which is good until the + * library is closed or the plugin is + * unregistered. + * + * Failure: A negative value. + * + * Programmer: Mohamad Chaarawi + * January, 2012 + * + *------------------------------------------------------------------------- + */ +hid_t +H5VLregister(const H5VL_class_t *cls) +{ + H5VL_get_plugin_ud_t op_data; + hid_t ret_value; + + FUNC_ENTER_API(FAIL) + H5TRACE1("i", "*x", cls); + + /* Check arguments */ + if(!cls) + HGOTO_ERROR(H5E_ARGS, H5E_UNINITIALIZED, FAIL, "null class pointer is disallowed") + + if(cls->value < H5_VOL_MAX_LIB_VALUE) + HGOTO_ERROR(H5E_VOL, H5E_CANTREGISTER, FAIL, + "registered class value must not be smaller than %d", H5_VOL_MAX_LIB_VALUE) + + if(!cls->name) + HGOTO_ERROR(H5E_VOL, H5E_CANTREGISTER, FAIL, "invalid VOL class name"); + + op_data.ret_id = FAIL; + op_data.name = cls->name; + + /* check if plugin is already registered */ + if(H5I_iterate(H5I_VOL, H5VL__get_plugin_cb, &op_data, TRUE) < 0) + HGOTO_ERROR(H5E_VOL, H5E_BADITER,FAIL, "can't iterate over VOL ids") + + if(op_data.ret_id != FAIL) + HGOTO_ERROR(H5E_VOL, H5E_CANTREGISTER, FAIL, "VOL plugin with the same name is already registered.") + + /* Create the new class ID */ + if((ret_value = H5VL_register(cls, sizeof(H5VL_class_t), TRUE)) < 0) + HGOTO_ERROR(H5E_ATOM, H5E_CANTREGISTER, FAIL, "unable to register vol plugin ID") + +done: + FUNC_LEAVE_API(ret_value) +} /* end H5VLregister() */ + + +/*------------------------------------------------------------------------- + * Function: H5VLregister_by_name + * + * Purpose: Registers a new vol plugin as a member of the virtual object + * layer class. + * + * Return: Success: A vol plugin ID which is good until the + * library is closed or the plugin is + * unregistered. + * + * Failure: A negative value. + * + * Programmer: Mohamad Chaarawi + * September, 2014 + * + *------------------------------------------------------------------------- + */ +hid_t +H5VLregister_by_name(const char *name) +{ + H5VL_get_plugin_ud_t op_data; + hid_t ret_value; + + FUNC_ENTER_API(FAIL) + H5TRACE1("i", "*s", name); + + /* Check arguments */ + if(!name) + HGOTO_ERROR(H5E_ARGS, H5E_UNINITIALIZED, FAIL, "null plugin name is disallowed") + + op_data.ret_id = FAIL; + op_data.name = name; + + /* check if plugin is already registered */ + if(H5I_iterate(H5I_VOL, H5VL__get_plugin_cb, &op_data, TRUE) < 0) + HGOTO_ERROR(H5E_VOL, H5E_BADITER,FAIL, "can't iterate over VOL ids") + + if(op_data.ret_id != FAIL) { + /* If plugin alread registered, increment ref count on ID and return ID */ + if(H5I_inc_ref(op_data.ret_id, TRUE) < 0) + HGOTO_ERROR(H5E_VOL, H5E_CANTINC, FAIL, "unable to increment ref count on VOL plugin") + ret_value = op_data.ret_id; + } + else { + const H5VL_class_t *cls; + + /* Try loading the plugin */ + if(NULL == (cls = (const H5VL_class_t *)H5PL_load(H5PL_TYPE_VOL, -1, name))) + HGOTO_ERROR(H5E_VOL, H5E_CANTINIT, FAIL, "unable to load VOL plugin") + + /* Register the plugin we loaded */ + if((ret_value = H5VL_register(cls, sizeof(H5VL_class_t), TRUE)) < 0) + HGOTO_ERROR(H5E_ATOM, H5E_CANTREGISTER, FAIL, "unable to register vol plugin ID") + } + +done: + FUNC_LEAVE_API(ret_value) +} /* end H5VLregister() */ + + +/*------------------------------------------------------------------------- + * Function: H5VLunregister + * + * Purpose: Removes a vol plugin ID from the library. This in no way affects + * file access property lists which have been defined to use + * this vol plugin or files which are already opened under with + * this plugin. + * + * Return: Success: Non-negative + * + * Failure: Negative + * + * Programmer: Mohamad Chaarawi + * January, 2012 + * + *------------------------------------------------------------------------- + */ +herr_t +H5VLunregister(hid_t vol_id) +{ + H5VL_class_t *cls = NULL; + herr_t ret_value = SUCCEED; /* Return value */ + + FUNC_ENTER_API(FAIL) + H5TRACE1("e", "i", vol_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 plugin") + + if(cls->value <= H5_VOL_MAX_LIB_VALUE) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "can't unregister an internal plugin") + + /* 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 plugin") + +done: + FUNC_LEAVE_API(ret_value) +} /* end H5VLunregister() */ + + +/*------------------------------------------------------------------------- + * Function: H5VLinitialize + * + * Purpose: Calls the plugin specific callback to init the plugin. + * + * Return: Non-negative on success/Negative on failure + * + * Programmer: Mohamad Chaarawi + * August 2014 + * + *------------------------------------------------------------------------- + */ +herr_t +H5VLinitialize(hid_t plugin_id, hid_t vipl_id) +{ + H5VL_class_t *cls = NULL; + herr_t ret_value = SUCCEED; /* Return value */ + + FUNC_ENTER_API(FAIL) + H5TRACE2("e", "ii", plugin_id, vipl_id); + + /* Check args */ + if(NULL == (cls = (H5VL_class_t *)H5I_object_verify(plugin_id, H5I_VOL))) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a VOL plugin ID") + + if(cls->initialize && cls->initialize(vipl_id) < 0) + HGOTO_ERROR(H5E_VOL, H5E_CANTCLOSEOBJ, FAIL, "VOL plugin did not initialize") + +done: + FUNC_LEAVE_API(ret_value) +} /* end H5VLinitialize() */ + + +/*------------------------------------------------------------------------- + * Function: H5VLterminate + * + * Purpose: + * + * Return: Non-negative on success/Negative on failure + * + * Programmer: Mohamad Chaarawi + * August 2014 + * + *------------------------------------------------------------------------- + */ +herr_t +H5VLterminate(hid_t plugin_id, hid_t vtpl_id) +{ + H5VL_class_t *cls = NULL; + herr_t ret_value = SUCCEED; /* Return value */ + + FUNC_ENTER_API(FAIL) + H5TRACE2("e", "ii", plugin_id, vtpl_id); + + /* Check args */ + if(NULL == (cls = (H5VL_class_t *)H5I_object_verify(plugin_id, H5I_VOL))) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a VOL plugin ID") + + if(cls->terminate && cls->terminate(vtpl_id) < 0) + HGOTO_ERROR(H5E_VOL, H5E_CANTCLOSEOBJ, FAIL, "VOL plugin did not terminate cleanly") + +done: + FUNC_LEAVE_API(ret_value) +} /* end H5VLterminate() */ + + +/*------------------------------------------------------------------------- + * Function: H5VLis_registered + * + * Purpose: Tests whether a VOL class has been registered or not + * + * Return: Positive if the VOL class has been registered + * Zero if it is unregistered + * Negative on error (if the class is not a valid class ID) + * + * Programmer: Mohamad Chaarawi + * June 2012 + * + *------------------------------------------------------------------------- + */ +htri_t +H5VLis_registered(const char *name) +{ + H5VL_get_plugin_ud_t op_data; + htri_t ret_value = FALSE; /* Return value */ + + FUNC_ENTER_API(FAIL) + H5TRACE1("t", "*s", name); + + op_data.ret_id = FAIL; + op_data.name = name; + + /* Check arguments */ + if(H5I_iterate(H5I_VOL, H5VL__get_plugin_cb, &op_data, TRUE) < 0) + HGOTO_ERROR(H5E_VOL, H5E_BADITER, FAIL, "can't iterate over VOL ids") + + if(op_data.ret_id != FAIL) + ret_value = TRUE; + +done: + FUNC_LEAVE_API(ret_value) +} /* end H5VLis_registered() */ + + +/*------------------------------------------------------------------------- + * Function: H5VLget_plugin_id + * + * Purpose: Retrieves the registered plugin ID for a VOL. + * + * Return: Positive if the VOL class has been registered + * Negative on error (if the class is not a valid class or not registered) + * + * Programmer: Mohamad Chaarawi + * August 2014 + * + *------------------------------------------------------------------------- + */ +hid_t +H5VLget_plugin_id(const char *name) +{ + H5VL_get_plugin_ud_t op_data; + hid_t ret_value = FAIL; /* Return value */ + + FUNC_ENTER_API(FAIL) + H5TRACE1("i", "*s", name); + + op_data.ret_id = FAIL; + op_data.name = name; + + /* Check arguments */ + if(H5I_iterate(H5I_VOL, H5VL__get_plugin_cb, &op_data, TRUE) < 0) + HGOTO_ERROR(H5E_VOL, H5E_BADITER,FAIL, "can't iterate over VOL ids") + + if(op_data.ret_id != FAIL) { + if(H5I_inc_ref(op_data.ret_id, TRUE) < 0) + HGOTO_ERROR(H5E_FILE, H5E_CANTINC, FAIL, "unable to increment ref count on VOL plugin") + + ret_value = op_data.ret_id; + } + +done: + FUNC_LEAVE_API(ret_value) +} /* end H5VLget_plugin_id() */ + + +/*------------------------------------------------------------------------- + * Function: H5VLget_plugin_name + * + * Purpose: Returns the plugin name for the VOL associated with the + * object or file ID + * + * Return: Success: The length of the plugin name + * Failure: Negative + * + * Programmer: Mohamad Chaarawi + * June, 2012 + * + *------------------------------------------------------------------------- + */ +ssize_t +H5VLget_plugin_name(hid_t obj_id, char *name/*out*/, size_t size) +{ + ssize_t ret_value; + + FUNC_ENTER_API(FAIL) + H5TRACE3("Zs", "ixz", obj_id, name, size); + + if((ret_value = H5VL_get_plugin_name(obj_id, name, size)) < 0) + HGOTO_ERROR(H5E_VOL, H5E_CANTGET, FAIL, "Can't get plugin name") + +done: + FUNC_LEAVE_API(ret_value) +} /* end H5VLget_plugin_name() */ + + +/*------------------------------------------------------------------------- + * Function: H5VLclose + * + * Purpose: Closes the specified VOL plugin. The VOL ID will no longer be + * valid for accessing the VOL. + * + * Return: Non-negative on success/Negative on failure + * + * Programmer: Mohamad Chaarawi + * August 2014 + * + *------------------------------------------------------------------------- + */ +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 plugin ID") + + if(H5I_dec_app_ref(vol_id) < 0) + HGOTO_ERROR(H5E_VOL, H5E_CANTRELEASE, FAIL, "unable to close VOL plugin ID") + +done: + FUNC_LEAVE_API(ret_value) +} /* end H5VLclose() */ + + +/*--------------------------------------------------------------------------- + * Function: H5VLobject_register + * + * Purpose: Public routine to create an HDF5 hid_t with library + * specific types, bypassing the limitation of H5Iregister. + * + * Returns: Non-negative on success or negative on failure + * + * Programmer: Mohamad Chaarawi + * June, 2012 + * + *--------------------------------------------------------------------------- + */ +hid_t +H5VLobject_register(void *obj, H5I_type_t obj_type, hid_t plugin_id) +{ + hid_t ret_value = FAIL; + + FUNC_ENTER_API(FAIL) + H5TRACE3("i", "*xIti", obj, obj_type, plugin_id); + + if(NULL == obj) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "invalid object to register") + + if ((ret_value = H5VL_object_register(obj, obj_type, plugin_id, TRUE)) < 0) + HGOTO_ERROR(H5E_ATOM, H5E_CANTREGISTER, FAIL, "unable to atomize dataset handle") + +done: + FUNC_LEAVE_API(ret_value) +} /* H5VLobject_register */ + + +/*--------------------------------------------------------------------------- + * Function: H5VLget_object + * + * Purpose: Retrieve 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. + * + * Returns: Non-negative on success or negative on failure + * + * Programmer: Mohamad Chaarawi + * July, 2013 + * + *--------------------------------------------------------------------------- + */ +herr_t +H5VLget_object(hid_t obj_id, void **obj) +{ + hid_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_get_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 through the VOL + * + * Return: Success: pointer to the new attr. + * Failure: NULL + * + * Programmer: Mohamad Chaarawi + * April, 2012 + * + *------------------------------------------------------------------------- + */ +void * +H5VLattr_create(void *obj, H5VL_loc_params_t loc_params, hid_t plugin_id, const char *name, + hid_t acpl_id, hid_t aapl_id, hid_t dxpl_id, void **req) +{ + H5VL_class_t *vol_cls = NULL; + void *ret_value = NULL; /* Return value */ + + FUNC_ENTER_API(NULL) + + if (NULL == obj) + HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, NULL, "invalid object") + if(NULL == (vol_cls = (H5VL_class_t *)H5I_object_verify(plugin_id, H5I_VOL))) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, NULL, "not a VOL plugin ID") + + if(NULL == (ret_value = H5VL_attr_create(obj, loc_params, vol_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 through the VOL + * + * Return: Success: pointer to the new attr. + * Failure: NULL + * + * Programmer: Mohamad Chaarawi + * March, 2012 + * + *------------------------------------------------------------------------- + */ +void * +H5VLattr_open(void *obj, H5VL_loc_params_t loc_params, hid_t plugin_id, const char *name, + hid_t aapl_id, hid_t dxpl_id, void **req) +{ + H5VL_class_t *vol_cls = NULL; + void *ret_value = NULL; /* Return value */ + + FUNC_ENTER_API(NULL) + + if (NULL == obj) + HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, NULL, "invalid object") + if(NULL == (vol_cls = (H5VL_class_t *)H5I_object_verify(plugin_id, H5I_VOL))) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, NULL, "not a VOL plugin ID") + + if(NULL == (ret_value = H5VL_attr_open(obj, loc_params, vol_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 attr through the VOL + * + * Return: Success: Non Negative + * + * Failure: Negative + * + * Programmer: Mohamad Chaarawi + * March, 2012 + * + *------------------------------------------------------------------------- + */ +herr_t H5VLattr_read(void *attr, hid_t plugin_id, hid_t mem_type_id, void *buf, hid_t dxpl_id, void **req) +{ + H5VL_class_t *vol_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 == (vol_cls = (H5VL_class_t *)H5I_object_verify(plugin_id, H5I_VOL))) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a VOL plugin ID") + + if((ret_value = H5VL_attr_read(attr, vol_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 attr through the VOL + * + * Return: Success: Non Negative + * Failure: Negative + * + * Programmer: Mohamad Chaarawi + * March, 2012 + * + *------------------------------------------------------------------------- + */ +herr_t H5VLattr_write(void *attr, hid_t plugin_id, hid_t mem_type_id, const void *buf, hid_t dxpl_id, void **req) +{ + H5VL_class_t *vol_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 == (vol_cls = (H5VL_class_t *)H5I_object_verify(plugin_id, H5I_VOL))) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a VOL plugin ID") + + if((ret_value = H5VL_attr_write(attr, vol_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: Get specific information about the attribute through the VOL + * + * Return: Success: non negative + * Failure: negative + * + * Programmer: Mohamad Chaarawi + * March, 2012 + * + *------------------------------------------------------------------------- + */ +herr_t +H5VLattr_get(void *obj, hid_t plugin_id, H5VL_attr_get_t get_type, + hid_t dxpl_id, void **req, va_list arguments) +{ + H5VL_class_t *vol_cls = NULL; + herr_t ret_value = SUCCEED; + + FUNC_ENTER_API(FAIL) + H5TRACE6("e", "*xiVai**xx", obj, plugin_id, get_type, dxpl_id, req, arguments); + + if (NULL == obj) + HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "invalid object") + if(NULL == (vol_cls = (H5VL_class_t *)H5I_object_verify(plugin_id, H5I_VOL))) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a VOL plugin ID") + + /* Bypass the H5VLint layer */ + if(NULL == vol_cls->attr_cls.get) + HGOTO_ERROR(H5E_VOL, H5E_UNSUPPORTED, FAIL, "vol plugin has no `attr get' method") + if((ret_value = (vol_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: specific operation on attributes through the VOL + * + * Return: Success: non negative + * Failure: negative + * + * Programmer: Mohamad Chaarawi + * March, 2012 + * + *------------------------------------------------------------------------- + */ +herr_t +H5VLattr_specific(void *obj, H5VL_loc_params_t loc_params, hid_t plugin_id, + H5VL_attr_specific_t specific_type, hid_t dxpl_id, void **req, va_list arguments) +{ + H5VL_class_t *vol_cls = NULL; + herr_t ret_value = SUCCEED; + + FUNC_ENTER_API(FAIL) + H5TRACE7("e", "*xxiVbi**xx", obj, loc_params, plugin_id, specific_type, + dxpl_id, req, arguments); + + if (NULL == obj) + HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "invalid object") + if(NULL == (vol_cls = (H5VL_class_t *)H5I_object_verify(plugin_id, H5I_VOL))) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a VOL plugin ID") + + /* Bypass the H5VLint layer */ + if(NULL == vol_cls->attr_cls.specific) + HGOTO_ERROR(H5E_VOL, H5E_UNSUPPORTED, FAIL, "vol plugin has no `attr specific' method") + if((ret_value = (vol_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: optional operation specific to plugins. + * + * Return: Success: non negative + * Failure: negative + * + * Programmer: Mohamad Chaarawi + * March, 2012 + * + *------------------------------------------------------------------------- + */ +herr_t +H5VLattr_optional(void *obj, hid_t plugin_id, hid_t dxpl_id, void **req, va_list arguments) +{ + H5VL_class_t *vol_cls = NULL; + herr_t ret_value = SUCCEED; + + FUNC_ENTER_API(FAIL) + H5TRACE5("e", "*xii**xx", obj, plugin_id, dxpl_id, req, arguments); + + if (NULL == obj) + HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "invalid object") + if(NULL == (vol_cls = (H5VL_class_t *)H5I_object_verify(plugin_id, H5I_VOL))) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a VOL plugin ID") + + /* Have to bypass the H5VLint layer due to unknown val_list arguments */ + if(NULL == vol_cls->attr_cls.optional) + HGOTO_ERROR(H5E_VOL, H5E_UNSUPPORTED, FAIL, "vol plugin has no `attr optional' method") + if((ret_value = (vol_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 through the VOL + * + * Return: Success: Non Negative + * Failure: Negative + * + * Programmer: Mohamad Chaarawi + * March, 2012 + * + *------------------------------------------------------------------------- + */ +herr_t +H5VLattr_close(void *attr, hid_t plugin_id, hid_t dxpl_id, void **req) +{ + H5VL_class_t *vol_cls = NULL; + herr_t ret_value = SUCCEED; + + FUNC_ENTER_API(FAIL) + H5TRACE4("e", "*xii**x", attr, plugin_id, dxpl_id, req); + + if (NULL == attr) + HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "invalid object") + if(NULL == (vol_cls = (H5VL_class_t *)H5I_object_verify(plugin_id, H5I_VOL))) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a VOL plugin ID") + + if((ret_value = H5VL_attr_close(attr, vol_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: H5VLdatatype_commit + * + * Purpose: Commits a datatype to the file through the VOL + * + * Return: Success: Positive + * Failure: Negative + * + * Programmer: Mohamad Chaarawi + * March, 2012 + * + *------------------------------------------------------------------------- + */ +void * +H5VLdatatype_commit(void *obj, H5VL_loc_params_t loc_params, hid_t plugin_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 *vol_cls = NULL; + void *ret_value = NULL; /* Return value */ + + FUNC_ENTER_API(NULL) + + if (NULL == obj) + HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, NULL, "invalid object") + if(NULL == (vol_cls = (H5VL_class_t *)H5I_object_verify(plugin_id, H5I_VOL))) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, NULL, "not a VOL plugin ID") + + if(NULL == (ret_value = H5VL_datatype_commit(obj, loc_params, vol_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 through the VOL + * + * Return: Success: User ID of the datatype. + * Failure: NULL + * + * Programmer: Mohamad Chaarawi + * March, 2012 + * + *------------------------------------------------------------------------- + */ +void * +H5VLdatatype_open(void *obj, H5VL_loc_params_t loc_params, hid_t plugin_id, const char *name, + hid_t tapl_id, hid_t dxpl_id, void **req) +{ + H5VL_class_t *vol_cls = NULL; + void *ret_value = NULL; /* Return value */ + + FUNC_ENTER_API(NULL) + + if (NULL == obj) + HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, NULL, "invalid object") + if(NULL == (vol_cls = (H5VL_class_t *)H5I_object_verify(plugin_id, H5I_VOL))) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, NULL, "not a VOL plugin ID") + + if(NULL == (ret_value = H5VL_datatype_open(obj, loc_params, vol_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: specific operation on datatypes through the VOL + * + * Return: Success: non negative + * Failure: negative + * + * Programmer: Mohamad Chaarawi + * March, 2012 + * + *------------------------------------------------------------------------- + */ +herr_t +H5VLdatatype_specific(void *obj, hid_t plugin_id, H5VL_datatype_specific_t specific_type, + hid_t dxpl_id, void **req, va_list arguments) +{ + H5VL_class_t *vol_cls = NULL; + herr_t ret_value = SUCCEED; + + FUNC_ENTER_API(FAIL) + H5TRACE6("e", "*xiVfi**xx", obj, plugin_id, specific_type, dxpl_id, req, + arguments); + + if (NULL == obj) + HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "invalid object") + if(NULL == (vol_cls = (H5VL_class_t *)H5I_object_verify(plugin_id, H5I_VOL))) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a VOL plugin ID") + + if(NULL == vol_cls->datatype_cls.specific) + HGOTO_ERROR(H5E_VOL, H5E_UNSUPPORTED, FAIL, "vol plugin has no `datatype specific' method") + if((ret_value = (vol_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: optional operation specific to plugins. + * + * Return: Success: non negative + * Failure: negative + * + * Programmer: Mohamad Chaarawi + * March, 2012 + * + *------------------------------------------------------------------------- + */ +herr_t +H5VLdatatype_optional(void *obj, hid_t plugin_id, hid_t dxpl_id, void **req, va_list arguments) +{ + H5VL_class_t *vol_cls = NULL; + herr_t ret_value = SUCCEED; + + FUNC_ENTER_API(FAIL) + H5TRACE5("e", "*xii**xx", obj, plugin_id, dxpl_id, req, arguments); + + if (NULL == obj) + HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "invalid object") + if(NULL == (vol_cls = (H5VL_class_t *)H5I_object_verify(plugin_id, H5I_VOL))) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a VOL plugin ID") + + if(NULL == vol_cls->datatype_cls.optional) + HGOTO_ERROR(H5E_VOL, H5E_UNSUPPORTED, FAIL, "vol plugin has no `datatype optional' method") + if((ret_value = (vol_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: Get specific information about the datatype through the VOL + * + * Return: Success: non negative + * Failure: negative + * + * Programmer: Mohamad Chaarawi + * June, 2013 + * + *------------------------------------------------------------------------- + */ +herr_t +H5VLdatatype_get(void *obj, hid_t plugin_id, H5VL_datatype_get_t get_type, + hid_t dxpl_id, void **req, va_list arguments) +{ + H5VL_class_t *vol_cls = NULL; + herr_t ret_value = SUCCEED; + + FUNC_ENTER_API(FAIL) + H5TRACE6("e", "*xiVei**xx", obj, plugin_id, get_type, dxpl_id, req, arguments); + + if(NULL == obj) + HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "invalid object") + if(NULL == (vol_cls = (H5VL_class_t *)H5I_object_verify(plugin_id, H5I_VOL))) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a VOL plugin ID") + + /* Bypass the H5VLint layer */ + if(NULL == vol_cls->datatype_cls.get) + HGOTO_ERROR(H5E_VOL, H5E_UNSUPPORTED, FAIL, "vol plugin has no `datatype get' method") + if((ret_value = (vol_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 through the VOL + * + * Return: Success: Positive + * Failure: Negative + * + * Programmer: Mohamad Chaarawi + * May, 2012 + * + *------------------------------------------------------------------------- + */ +herr_t +H5VLdatatype_close(void *dt, hid_t plugin_id, hid_t dxpl_id, void **req) +{ + H5VL_class_t *vol_cls = NULL; + herr_t ret_value = SUCCEED; + + FUNC_ENTER_API(FAIL) + H5TRACE4("e", "*xii**x", dt, plugin_id, dxpl_id, req); + + if (NULL == dt) + HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "invalid object") + if(NULL == (vol_cls = (H5VL_class_t *)H5I_object_verify(plugin_id, H5I_VOL))) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a VOL plugin ID") + + if((ret_value = H5VL_datatype_close(dt, vol_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: H5VLdataset_create + * + * Purpose: Creates a dataset through the VOL + * + * Return: Success: pointer to dataset + * Failure: NULL + * + * Programmer: Mohamad Chaarawi + * March, 2012 + * + *------------------------------------------------------------------------- + */ +void * +H5VLdataset_create(void *obj, H5VL_loc_params_t loc_params, hid_t plugin_id, const char *name, + hid_t dcpl_id, hid_t dapl_id, hid_t dxpl_id, void **req) +{ + H5VL_class_t *vol_cls = NULL; + void *ret_value = NULL; /* Return value */ + + FUNC_ENTER_API(NULL) + + if (NULL == obj) + HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, NULL, "invalid object") + if(NULL == (vol_cls = (H5VL_class_t *)H5I_object_verify(plugin_id, H5I_VOL))) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, NULL, "not a VOL plugin ID") + + if(NULL == (ret_value = H5VL_dataset_create(obj, loc_params, vol_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 through the VOL + * + * Return: Success: pointer to dataset + * Failure: NULL + * + * Programmer: Mohamad Chaarawi + * March, 2012 + * + *------------------------------------------------------------------------- + */ +void * +H5VLdataset_open(void *obj, H5VL_loc_params_t loc_params, hid_t plugin_id, const char *name, + hid_t dapl_id, hid_t dxpl_id, void **req) +{ + H5VL_class_t *vol_cls = NULL; + void *ret_value = NULL; /* Return value */ + + FUNC_ENTER_API(NULL) + + if (NULL == obj) + HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, NULL, "invalid object") + if(NULL == (vol_cls = (H5VL_class_t *)H5I_object_verify(plugin_id, H5I_VOL))) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, NULL, "not a VOL plugin ID") + + if(NULL == (ret_value = H5VL_dataset_open(obj, loc_params, vol_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 dataset through the VOL + * + * Return: Success: Non Negative + * Failure: Negative + * + * Programmer: Mohamad Chaarawi + * March, 2012 + * + *------------------------------------------------------------------------- + */ +herr_t +H5VLdataset_read(void *dset, hid_t plugin_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 *vol_cls = NULL; + herr_t ret_value = SUCCEED; + + FUNC_ENTER_API(FAIL) + H5TRACE8("e", "*xiiiii*x**x", dset, plugin_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 == (vol_cls = (H5VL_class_t *)H5I_object_verify(plugin_id, H5I_VOL))) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a VOL plugin ID") + + if((ret_value = H5VL_dataset_read(dset, vol_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 from dataset through the VOL + * + * Return: Success: Non Negative + * Failure: Negative + * + * Programmer: Mohamad Chaarawi + * March, 2012 + * + *------------------------------------------------------------------------- + */ +herr_t +H5VLdataset_write(void *dset, hid_t plugin_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 *vol_cls = NULL; + herr_t ret_value = SUCCEED; + + FUNC_ENTER_API(FAIL) + H5TRACE8("e", "*xiiiii*x**x", dset, plugin_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 == (vol_cls = (H5VL_class_t *)H5I_object_verify(plugin_id, H5I_VOL))) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a VOL plugin ID") + + if((ret_value = H5VL_dataset_write(dset, vol_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: Get specific information about the dataset through the VOL + * + * Return: Success: non negative + * Failure: negative + * + * Programmer: Mohamad Chaarawi + * March, 2012 + * + *------------------------------------------------------------------------- + */ +herr_t +H5VLdataset_get(void *dset, hid_t plugin_id, H5VL_dataset_get_t get_type, + hid_t dxpl_id, void **req, va_list arguments) +{ + H5VL_class_t *vol_cls = NULL; + herr_t ret_value = SUCCEED; + + FUNC_ENTER_API(FAIL) + H5TRACE6("e", "*xiVci**xx", dset, plugin_id, get_type, dxpl_id, req, arguments); + + if (NULL == dset) + HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "invalid object") + if(NULL == (vol_cls = (H5VL_class_t *)H5I_object_verify(plugin_id, H5I_VOL))) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a VOL plugin ID") + + /* Bypass the H5VLint layer */ + if(NULL == vol_cls->dataset_cls.get) + HGOTO_ERROR(H5E_VOL, H5E_UNSUPPORTED, FAIL, "vol plugin has no `dataset get' method") + if((ret_value = (vol_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: specific operation on datasets through the VOL + * + * Return: Success: non negative + * Failure: negative + * + * Programmer: Mohamad Chaarawi + * March, 2012 + * + *------------------------------------------------------------------------- + */ +herr_t +H5VLdataset_specific(void *obj, hid_t plugin_id, H5VL_dataset_specific_t specific_type, + hid_t dxpl_id, void **req, va_list arguments) +{ + H5VL_class_t *vol_cls = NULL; + herr_t ret_value = SUCCEED; + + FUNC_ENTER_API(FAIL) + H5TRACE6("e", "*xiVdi**xx", obj, plugin_id, specific_type, dxpl_id, req, + arguments); + + if (NULL == obj) + HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "invalid object") + if(NULL == (vol_cls = (H5VL_class_t *)H5I_object_verify(plugin_id, H5I_VOL))) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a VOL plugin ID") + + if(NULL == vol_cls->dataset_cls.specific) + HGOTO_ERROR(H5E_VOL, H5E_UNSUPPORTED, FAIL, "vol plugin has no `dataset specific' method") + if((ret_value = (vol_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: optional operation specific to plugins. + * + * Return: Success: non negative + * Failure: negative + * + * Programmer: Mohamad Chaarawi + * March, 2012 + * + *------------------------------------------------------------------------- + */ +herr_t +H5VLdataset_optional(void *obj, hid_t plugin_id, hid_t dxpl_id, void **req, va_list arguments) +{ + H5VL_class_t *vol_cls = NULL; + herr_t ret_value = SUCCEED; + + FUNC_ENTER_API(FAIL) + H5TRACE5("e", "*xii**xx", obj, plugin_id, dxpl_id, req, arguments); + + if (NULL == obj) + HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "invalid object") + if(NULL == (vol_cls = (H5VL_class_t *)H5I_object_verify(plugin_id, H5I_VOL))) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a VOL plugin ID") + + if(NULL == vol_cls->dataset_cls.optional) + HGOTO_ERROR(H5E_VOL, H5E_UNSUPPORTED, FAIL, "vol plugin has no `dataset optional' method") + if((ret_value = (vol_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 through the VOL + * + * Return: Success: Non Negative + * Failure: Negative + * + * Programmer: Mohamad Chaarawi + * March, 2012 + * + *------------------------------------------------------------------------- + */ +herr_t +H5VLdataset_close(void *dset, hid_t plugin_id, hid_t dxpl_id, void **req) +{ + H5VL_class_t *vol_cls = NULL; + herr_t ret_value = SUCCEED; + + FUNC_ENTER_API(FAIL) + H5TRACE4("e", "*xii**x", dset, plugin_id, dxpl_id, req); + + if (NULL == dset) + HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "invalid object") + if(NULL == (vol_cls = (H5VL_class_t *)H5I_object_verify(plugin_id, H5I_VOL))) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a VOL plugin ID") + + if((ret_value = H5VL_dataset_close(dset, vol_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 through the VOL + * + * Return: Success: pointer to file. + * Failure: NULL + * + * Programmer: Mohamad Chaarawi + * January, 2012 + * + *------------------------------------------------------------------------- + */ +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 */ + hid_t plugin_id; /* VOL plugin identigier attached to fapl_id */ + H5VL_class_t *vol_cls = NULL; + void *ret_value = NULL; /* Return value */ + + FUNC_ENTER_API(NULL) + + /* 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_get(plist, H5F_ACS_VOL_ID_NAME, &plugin_id) < 0) + HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, NULL, "can't get vol plugin ID") + + if(NULL == (vol_cls = (H5VL_class_t *)H5I_object_verify(plugin_id, H5I_VOL))) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, NULL, "not a VOL plugin ID") + + if(NULL == (ret_value = H5VL_file_create(vol_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 through the VOL. + * + * Return: Success: pointer to file. + * Failure: NULL + * + * Programmer: Mohamad Chaarawi + * January, 2012 + * + *------------------------------------------------------------------------- + */ +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 */ + hid_t plugin_id; /* VOL plugin id attached to fapl_id */ + H5VL_class_t *vol_cls = NULL; + void *ret_value = NULL; /* Return value */ + + FUNC_ENTER_API(NULL) + + /* 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_get(plist, H5F_ACS_VOL_ID_NAME, &plugin_id) < 0) + HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, NULL, "can't get vol plugin ID") + + if(NULL == (vol_cls = (H5VL_class_t *)H5I_object_verify(plugin_id, H5I_VOL))) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, NULL, "not a VOL plugin ID") + + if(NULL == (ret_value = H5VL_file_open(vol_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: Get specific information about the file through the VOL + * + * Return: Success: non negative + * Failure: negative + * + * Programmer: Mohamad Chaarawi + * February, 2012 + * + *------------------------------------------------------------------------- + */ +herr_t +H5VLfile_get(void *file, hid_t plugin_id, H5VL_file_get_t get_type, + hid_t dxpl_id, void **req, va_list arguments) +{ + H5VL_class_t *vol_cls = NULL; + herr_t ret_value = SUCCEED; + + FUNC_ENTER_API(FAIL) + H5TRACE6("e", "*xiVgi**xx", file, plugin_id, get_type, dxpl_id, req, arguments); + + if(NULL == file) + HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "invalid object") + if(NULL == (vol_cls = (H5VL_class_t *)H5I_object_verify(plugin_id, H5I_VOL))) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a VOL plugin ID") + + /* Bypass the H5VLint layer */ + if(NULL == vol_cls->file_cls.get) + HGOTO_ERROR(H5E_VOL, H5E_UNSUPPORTED, FAIL, "vol plugin has no `file get' method") + if((ret_value = (vol_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") + +done: + FUNC_LEAVE_API(ret_value) +} /* end H5VLfile_get() */ + + +/*------------------------------------------------------------------------- + * Function: H5VLfile_specific + * + * Purpose: perform File specific operations through the VOL + * + * Return: Success: non negative + * Failure: negative + * + * Programmer: Mohamad Chaarawi + * April, 2012 + * + *------------------------------------------------------------------------- + */ +herr_t +H5VLfile_specific(void *file, hid_t plugin_id, H5VL_file_specific_t specific_type, + hid_t dxpl_id, void **req, va_list arguments) +{ + H5VL_class_t *vol_cls = NULL; + herr_t ret_value = SUCCEED; + + FUNC_ENTER_API(FAIL) + H5TRACE6("e", "*xiVhi**xx", file, plugin_id, specific_type, dxpl_id, req, + arguments); + + if(specific_type == H5VL_FILE_IS_ACCESSIBLE) { + H5P_genplist_t *plist; /* Property list pointer */ + hid_t vol_id; /* VOL plugin identigier attached to fapl_id */ + 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_get(plist, H5F_ACS_VOL_ID_NAME, &vol_id) < 0) + HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, FAIL, "can't get vol plugin") + + if(NULL == (vol_cls = (H5VL_class_t *)H5I_object(vol_id))) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a VOL ID") + + if((ret_value = (vol_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 == (vol_cls = (H5VL_class_t *)H5I_object_verify(plugin_id, H5I_VOL))) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a VOL plugin ID") + + if(NULL == vol_cls->file_cls.specific) + HGOTO_ERROR(H5E_VOL, H5E_UNSUPPORTED, FAIL, "vol plugin has no `file specific' method") + if((ret_value = (vol_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: perform a plugin specific operation + * + * Return: Success: non negative + * Failure: negative + * + * Programmer: Mohamad Chaarawi + * April, 2012 + * + *------------------------------------------------------------------------- + */ +herr_t +H5VLfile_optional(void *file, hid_t plugin_id, hid_t dxpl_id, void **req, va_list arguments) +{ + H5VL_class_t *vol_cls = NULL; + herr_t ret_value = SUCCEED; + + FUNC_ENTER_API(FAIL) + H5TRACE5("e", "*xii**xx", file, plugin_id, dxpl_id, req, arguments); + + if(NULL == file) + HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "invalid object") + if(NULL == (vol_cls = (H5VL_class_t *)H5I_object_verify(plugin_id, H5I_VOL))) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a VOL plugin ID") + + if(NULL == vol_cls->file_cls.optional) + HGOTO_ERROR(H5E_VOL, H5E_UNSUPPORTED, FAIL, "vol plugin has no `file optional' method") + if((ret_value = (vol_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 through the VOL + * + * Return: Success: Non Negative + * Failure: Negative + * + * Programmer: Mohamad Chaarawi + * January, 2012 + * + *------------------------------------------------------------------------- + */ +herr_t +H5VLfile_close(void *file, hid_t plugin_id, hid_t dxpl_id, void **req) +{ + H5VL_class_t *vol_cls = NULL; + herr_t ret_value = SUCCEED; + + FUNC_ENTER_API(FAIL) + H5TRACE4("e", "*xii**x", file, plugin_id, dxpl_id, req); + + if(NULL == file) + HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "invalid object") + if(NULL == (vol_cls = (H5VL_class_t *)H5I_object_verify(plugin_id, H5I_VOL))) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a VOL plugin ID") + + if((ret_value = H5VL_file_close(file, vol_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 through the VOL + * Return: Success: pointer to new group. + * + * Failure: NULL + * + * Programmer: Mohamad Chaarawi + * March, 2012 + * + *------------------------------------------------------------------------- + */ +void * +H5VLgroup_create(void *obj, H5VL_loc_params_t loc_params, hid_t plugin_id, const char *name, + hid_t gcpl_id, hid_t gapl_id, hid_t dxpl_id, void **req) +{ + H5VL_class_t *vol_cls = NULL; + void *ret_value = NULL; /* Return value */ + + FUNC_ENTER_API(NULL) + + if (NULL == obj) + HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, NULL, "invalid object") + if(NULL == (vol_cls = (H5VL_class_t *)H5I_object_verify(plugin_id, H5I_VOL))) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, NULL, "not a VOL plugin ID") + + if(NULL == (ret_value = H5VL_group_create(obj, loc_params, vol_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 through the VOL + * + * Return: Success: pointer to new group. + * Failure: NULL + * + * Programmer: Mohamad Chaarawi + * March, 2012 + * + *------------------------------------------------------------------------- + */ +void * +H5VLgroup_open(void *obj, H5VL_loc_params_t loc_params, hid_t plugin_id, const char *name, + hid_t gapl_id, hid_t dxpl_id, void **req) +{ + H5VL_class_t *vol_cls = NULL; + void *ret_value = NULL; /* Return value */ + + FUNC_ENTER_API(NULL) + + if (NULL == obj) + HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, NULL, "invalid object") + if(NULL == (vol_cls = (H5VL_class_t *)H5I_object_verify(plugin_id, H5I_VOL))) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, NULL, "not a VOL plugin ID") + + if(NULL == (ret_value = H5VL_group_open(obj, loc_params, vol_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: Get specific information about the group through the VOL + * + * Return: Success: non negative + * Failure: negative + * + * Programmer: Mohamad Chaarawi + * February, 2012 + * + *------------------------------------------------------------------------- + */ +herr_t +H5VLgroup_get(void *obj, hid_t plugin_id, H5VL_group_get_t get_type, + hid_t dxpl_id, void **req, va_list arguments) +{ + H5VL_class_t *vol_cls = NULL; + herr_t ret_value = SUCCEED; + + FUNC_ENTER_API(FAIL) + H5TRACE6("e", "*xiVii**xx", obj, plugin_id, get_type, dxpl_id, req, arguments); + + if(NULL == obj) + HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "invalid object") + if(NULL == (vol_cls = (H5VL_class_t *)H5I_object_verify(plugin_id, H5I_VOL))) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a VOL plugin ID") + + /* Bypass the H5VLint layer */ + if(NULL == vol_cls->group_cls.get) + HGOTO_ERROR(H5E_VOL, H5E_UNSUPPORTED, FAIL, "vol plugin has no `group get' method") + if((ret_value = (vol_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: specific operation on groups through the VOL + * + * Return: Success: non negative + * Failure: negative + * + * Programmer: Mohamad Chaarawi + * March, 2012 + * + *------------------------------------------------------------------------- + */ +herr_t +H5VLgroup_specific(void *obj, hid_t plugin_id, H5VL_group_specific_t specific_type, + hid_t dxpl_id, void **req, va_list arguments) +{ + H5VL_class_t *vol_cls = NULL; + herr_t ret_value = SUCCEED; + + FUNC_ENTER_API(FAIL) + H5TRACE6("e", "*xiVji**xx", obj, plugin_id, specific_type, dxpl_id, req, + arguments); + + if (NULL == obj) + HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "invalid object") + if(NULL == (vol_cls = (H5VL_class_t *)H5I_object_verify(plugin_id, H5I_VOL))) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a VOL plugin ID") + + if(NULL == vol_cls->group_cls.specific) + HGOTO_ERROR(H5E_VOL, H5E_UNSUPPORTED, FAIL, "vol plugin has no `group specific' method") + if((ret_value = (vol_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: optional operation specific to plugins. + * + * Return: Success: non negative + * Failure: negative + * + * Programmer: Mohamad Chaarawi + * March, 2012 + * + *------------------------------------------------------------------------- + */ +herr_t +H5VLgroup_optional(void *obj, hid_t plugin_id, hid_t dxpl_id, void **req, va_list arguments) +{ + H5VL_class_t *vol_cls = NULL; + herr_t ret_value = SUCCEED; + + FUNC_ENTER_API(FAIL) + H5TRACE5("e", "*xii**xx", obj, plugin_id, dxpl_id, req, arguments); + + if (NULL == obj) + HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "invalid object") + if(NULL == (vol_cls = (H5VL_class_t *)H5I_object_verify(plugin_id, H5I_VOL))) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a VOL plugin ID") + + if(NULL == vol_cls->group_cls.optional) + HGOTO_ERROR(H5E_VOL, H5E_UNSUPPORTED, FAIL, "vol plugin has no `group optional' method") + if((ret_value = (vol_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 through the VOL + * + * Return: Success: Non Negative + * Failure: Negative + * + * Programmer: Mohamad Chaarawi + * March, 2012 + * + *------------------------------------------------------------------------- + */ +herr_t +H5VLgroup_close(void *grp, hid_t plugin_id, hid_t dxpl_id, void **req) +{ + H5VL_class_t *vol_cls = NULL; + herr_t ret_value = SUCCEED; + + FUNC_ENTER_API(FAIL) + H5TRACE4("e", "*xii**x", grp, plugin_id, dxpl_id, req); + + if(NULL == grp) + HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "invalid object") + if(NULL == (vol_cls = (H5VL_class_t *)H5I_object_verify(plugin_id, H5I_VOL))) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a VOL plugin ID") + + if((ret_value = H5VL_group_close(grp, vol_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 through the VOL + * + * Return: Non-negative on success/Negative on failure + * + * Programmer: Mohamad Chaarawi + * April, 2012 + * + *------------------------------------------------------------------------- + */ +herr_t +H5VLlink_create(H5VL_link_create_type_t create_type, void *obj, H5VL_loc_params_t loc_params, + hid_t plugin_id, hid_t lcpl_id, hid_t lapl_id, hid_t dxpl_id, void **req) +{ + H5VL_class_t *vol_cls = NULL; + herr_t ret_value = SUCCEED; + + FUNC_ENTER_API(FAIL) + H5TRACE8("e", "Vk*xxiiii**x", create_type, obj, loc_params, plugin_id, lcpl_id, + lapl_id, dxpl_id, req); + + if(NULL == obj) + HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "invalid object") + if(NULL == (vol_cls = (H5VL_class_t *)H5I_object_verify(plugin_id, H5I_VOL))) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a VOL plugin ID") + + if((ret_value = H5VL_link_create(create_type, obj, loc_params, vol_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: Copy a link from src to dst. + * + * Return: Non-negative on success/Negative on failure + * + * Programmer: Mohamad Chaarawi + * April, 2012 + * + *------------------------------------------------------------------------- + */ +herr_t +H5VLlink_copy(void *src_obj, H5VL_loc_params_t loc_params1, void *dst_obj, + H5VL_loc_params_t loc_params2, hid_t plugin_id, + hid_t lcpl_id, hid_t lapl_id, hid_t dxpl_id, void **req) +{ + H5VL_class_t *vol_cls = NULL; + herr_t ret_value = SUCCEED; + + FUNC_ENTER_API(FAIL) + H5TRACE9("e", "*xx*xxiiii**x", src_obj, loc_params1, dst_obj, loc_params2, + plugin_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 == (vol_cls = (H5VL_class_t *)H5I_object_verify(plugin_id, H5I_VOL))) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a VOL plugin ID") + + if((ret_value = H5VL_link_copy(src_obj, loc_params1, dst_obj, loc_params2, vol_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: Move a link from src to dst. + * + * Return: Non-negative on success/Negative on failure + * + * Programmer: Mohamad Chaarawi + * April, 2012 + * + *------------------------------------------------------------------------- + */ +herr_t +H5VLlink_move(void *src_obj, H5VL_loc_params_t loc_params1, void *dst_obj, + H5VL_loc_params_t loc_params2, hid_t plugin_id, + hid_t lcpl_id, hid_t lapl_id, hid_t dxpl_id, void **req) +{ + H5VL_class_t *vol_cls = NULL; + herr_t ret_value = SUCCEED; + + FUNC_ENTER_API(FAIL) + H5TRACE9("e", "*xx*xxiiii**x", src_obj, loc_params1, dst_obj, loc_params2, + plugin_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 == (vol_cls = (H5VL_class_t *)H5I_object_verify(plugin_id, H5I_VOL))) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a VOL plugin ID") + + if((ret_value = H5VL_link_move(src_obj, loc_params1, dst_obj, loc_params2, vol_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: Get specific information about the link through the VOL + * + * Return: Success: non negative + * + * Failure: negative + * + * Programmer: Mohamad Chaarawi + * April, 2012 + * + *------------------------------------------------------------------------- + */ +herr_t +H5VLlink_get(void *obj, H5VL_loc_params_t loc_params, hid_t plugin_id, H5VL_link_get_t get_type, + hid_t dxpl_id, void **req, va_list arguments) +{ + H5VL_class_t *vol_cls = NULL; + herr_t ret_value = SUCCEED; + + FUNC_ENTER_API(FAIL) + H5TRACE7("e", "*xxiVli**xx", obj, loc_params, plugin_id, get_type, dxpl_id, req, + arguments); + + if(NULL == obj) + HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "invalid object") + if(NULL == (vol_cls = (H5VL_class_t *)H5I_object_verify(plugin_id, H5I_VOL))) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a VOL plugin ID") + + if(NULL == vol_cls->link_cls.get) + HGOTO_ERROR(H5E_VOL, H5E_UNSUPPORTED, FAIL, "vol plugin has no `link get' method") + if((ret_value = (vol_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: specific operation on links through the VOL + * + * Return: Success: non negative + * Failure: negative + * + * Programmer: Mohamad Chaarawi + * March, 2012 + * + *------------------------------------------------------------------------- + */ +herr_t +H5VLlink_specific(void *obj, H5VL_loc_params_t loc_params, hid_t plugin_id, + H5VL_link_specific_t specific_type, hid_t dxpl_id, void **req, va_list arguments) +{ + H5VL_class_t *vol_cls = NULL; + herr_t ret_value = SUCCEED; + + FUNC_ENTER_API(FAIL) + H5TRACE7("e", "*xxiVmi**xx", obj, loc_params, plugin_id, specific_type, + dxpl_id, req, arguments); + + if (NULL == obj) + HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "invalid object") + if(NULL == (vol_cls = (H5VL_class_t *)H5I_object_verify(plugin_id, H5I_VOL))) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a VOL plugin ID") + + /* Bypass the H5VLint layer */ + if(NULL == vol_cls->link_cls.specific) + HGOTO_ERROR(H5E_VOL, H5E_UNSUPPORTED, FAIL, "vol plugin has no `link specific' method") + if((ret_value = (vol_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: optional operation specific to plugins. + * + * Return: Success: non negative + * Failure: negative + * + * Programmer: Mohamad Chaarawi + * March, 2012 + * + *------------------------------------------------------------------------- + */ +herr_t +H5VLlink_optional(void *obj, hid_t plugin_id, hid_t dxpl_id, void **req, va_list arguments) +{ + H5VL_class_t *vol_cls = NULL; + herr_t ret_value = SUCCEED; + + FUNC_ENTER_API(FAIL) + H5TRACE5("e", "*xii**xx", obj, plugin_id, dxpl_id, req, arguments); + + if (NULL == obj) + HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "invalid object") + if(NULL == (vol_cls = (H5VL_class_t *)H5I_object_verify(plugin_id, H5I_VOL))) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a VOL plugin ID") + + /* Have to bypass the H5VLint layer due to unknown val_list arguments */ + if(NULL == vol_cls->link_cls.optional) + HGOTO_ERROR(H5E_VOL, H5E_UNSUPPORTED, FAIL, "vol plugin has no `link optional' method") + if((ret_value = (vol_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 a object through the VOL + * + * Return: Success: User ID of the new object. + * Failure: NULL + * + * Programmer: Mohamad Chaarawi + * March, 2012 + * + *------------------------------------------------------------------------- + */ +void * +H5VLobject_open(void *obj, H5VL_loc_params_t params, hid_t plugin_id, H5I_type_t *opened_type, + hid_t dxpl_id, void **req) +{ + H5VL_class_t *vol_cls = NULL; + void *ret_value = NULL; /* Return value */ + + FUNC_ENTER_API(NULL) + + if (NULL == obj) + HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, NULL, "invalid object") + if(NULL == (vol_cls = (H5VL_class_t *)H5I_object_verify(plugin_id, H5I_VOL))) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, NULL, "not a VOL plugin ID") + + if(NULL == (ret_value = H5VL_object_open(obj, params, vol_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 destination through the VOL + * + * Return: Success: Non Negative + * Failure: Negative + * + * Programmer: Mohamad Chaarawi + * April, 2012 + * + *------------------------------------------------------------------------- + */ +herr_t +H5VLobject_copy(void *src_obj, H5VL_loc_params_t loc_params1, hid_t plugin_id1, const char *src_name, + void *dst_obj, H5VL_loc_params_t loc_params2, hid_t plugin_id2, const char *dst_name, + hid_t ocpypl_id, hid_t lcpl_id, hid_t dxpl_id, void **req) +{ + H5VL_class_t *vol_cls1 = NULL; + H5VL_class_t *vol_cls2 = NULL; + herr_t ret_value = SUCCEED; + + FUNC_ENTER_API(FAIL) + H5TRACE12("e", "*xxi*s*xxi*siii**x", src_obj, loc_params1, plugin_id1, + src_name, dst_obj, loc_params2, plugin_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 == (vol_cls1 = (H5VL_class_t *)H5I_object_verify(plugin_id1, H5I_VOL))) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a VOL plugin ID") + if(NULL == (vol_cls2 = (H5VL_class_t *)H5I_object_verify(plugin_id2, H5I_VOL))) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a VOL plugin ID") + + if((ret_value = H5VL_object_copy(src_obj, loc_params1, vol_cls1, src_name, + dst_obj, loc_params2, vol_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: Get specific information about the object through the VOL + * + * Return: Success: non negative + * + * Failure: negative + * + * Programmer: Mohamad Chaarawi + * February, 2012 + * + *------------------------------------------------------------------------- + */ +herr_t +H5VLobject_get(void *obj, H5VL_loc_params_t loc_params, hid_t plugin_id, H5VL_object_get_t get_type, + hid_t dxpl_id, void **req, va_list arguments) +{ + H5VL_class_t *vol_cls = NULL; + herr_t ret_value = SUCCEED; + + FUNC_ENTER_API(FAIL) + H5TRACE7("e", "*xxiVni**xx", obj, loc_params, plugin_id, get_type, dxpl_id, req, + arguments); + + if(NULL == obj) + HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "invalid object") + if(NULL == (vol_cls = (H5VL_class_t *)H5I_object_verify(plugin_id, H5I_VOL))) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a VOL plugin ID") + + if(NULL == vol_cls->object_cls.get) + HGOTO_ERROR(H5E_VOL, H5E_UNSUPPORTED, FAIL, "vol plugin has no `object get' method") + if((ret_value = (vol_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: specific operation on objects through the VOL + * + * Return: Success: non negative + * Failure: negative + * + * Programmer: Mohamad Chaarawi + * April, 2012 + * + *------------------------------------------------------------------------- + */ +herr_t +H5VLobject_specific(void *obj, H5VL_loc_params_t loc_params, hid_t plugin_id, + H5VL_object_specific_t specific_type, hid_t dxpl_id, void **req, va_list arguments) +{ + H5VL_class_t *vol_cls = NULL; + herr_t ret_value = SUCCEED; + + FUNC_ENTER_API(FAIL) + H5TRACE7("e", "*xxiVoi**xx", obj, loc_params, plugin_id, specific_type, + dxpl_id, req, arguments); + + if(NULL == obj) + HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "invalid object") + if(NULL == (vol_cls = (H5VL_class_t *)H5I_object_verify(plugin_id, H5I_VOL))) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a VOL plugin ID") + + /* Bypass the H5VLint layer */ + if(NULL == vol_cls->object_cls.specific) + HGOTO_ERROR(H5E_VOL, H5E_UNSUPPORTED, FAIL, "vol plugin has no `object specific' method") + if((ret_value = (vol_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: optional operation specific to plugins. + * + * Return: Success: non negative + * Failure: negative + * + * Programmer: Mohamad Chaarawi + * March, 2012 + * + *------------------------------------------------------------------------- + */ +herr_t +H5VLobject_optional(void *obj, hid_t plugin_id, hid_t dxpl_id, void **req, va_list arguments) +{ + H5VL_class_t *vol_cls = NULL; + herr_t ret_value = SUCCEED; + + FUNC_ENTER_API(FAIL) + H5TRACE5("e", "*xii**xx", obj, plugin_id, dxpl_id, req, arguments); + + if (NULL == obj) + HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "invalid object") + if(NULL == (vol_cls = (H5VL_class_t *)H5I_object_verify(plugin_id, H5I_VOL))) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a VOL plugin ID") + + /* Have to bypass the H5VLint layer due to unknown val_list arguments */ + if(NULL == vol_cls->object_cls.optional) + HGOTO_ERROR(H5E_VOL, H5E_UNSUPPORTED, FAIL, "vol plugin has no `object optional' method") + if((ret_value = (vol_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: H5VLrequest_cancel + * + * Purpose: Cancels a request through the VOL + * + * Return: Success: Non Negative + * Failure: Negative + * + * Programmer: Mohamad Chaarawi + * March, 2013 + * + *------------------------------------------------------------------------- + */ +herr_t +H5VLrequest_cancel(void **req, hid_t plugin_id, H5ES_status_t *status) +{ + H5VL_class_t *vol_cls = NULL; + herr_t ret_value = SUCCEED; + + FUNC_ENTER_API(FAIL) + H5TRACE3("e", "**xi*Es", req, plugin_id, status); + + if(NULL == (vol_cls = (H5VL_class_t *)H5I_object_verify(plugin_id, H5I_VOL))) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a VOL plugin ID") + + if((ret_value = H5VL_request_cancel(req, vol_cls, status)) < 0) + HGOTO_ERROR(H5E_VOL, H5E_CANTRELEASE, FAIL, "unable to cancel request") + +done: + FUNC_LEAVE_API(ret_value) +} /* end H5VLrequest_cancel() */ + + +/*------------------------------------------------------------------------- + * Function: H5VLrequest_test + * + * Purpose: Tests a request through the VOL + * + * Return: Success: Non Negative + * Failure: Negative + * + * Programmer: Mohamad Chaarawi + * March, 2013 + * + *------------------------------------------------------------------------- + */ +herr_t +H5VLrequest_test(void **req, hid_t plugin_id, H5ES_status_t *status) +{ + H5VL_class_t *vol_cls = NULL; + herr_t ret_value = SUCCEED; + + FUNC_ENTER_API(FAIL) + H5TRACE3("e", "**xi*Es", req, plugin_id, status); + + if(NULL == (vol_cls = (H5VL_class_t *)H5I_object_verify(plugin_id, H5I_VOL))) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a VOL plugin ID") + + if((ret_value = H5VL_request_test(req, vol_cls, status)) < 0) + HGOTO_ERROR(H5E_VOL, H5E_CANTRELEASE, FAIL, "unable to test request") + +done: + FUNC_LEAVE_API(ret_value) +} /* end H5VLrequest_test() */ + + +/*------------------------------------------------------------------------- + * Function: H5VLrequest_wait + * + * Purpose: Waits on a request through the VOL + * + * Return: Success: Non Negative + * Failure: Negative + * + * Programmer: Mohamad Chaarawi + * March, 2013 + * + *------------------------------------------------------------------------- + */ +herr_t +H5VLrequest_wait(void **req, hid_t plugin_id, H5ES_status_t *status) +{ + H5VL_class_t *vol_cls = NULL; + herr_t ret_value = SUCCEED; + + FUNC_ENTER_API(FAIL) + H5TRACE3("e", "**xi*Es", req, plugin_id, status); + + if(NULL == (vol_cls = (H5VL_class_t *)H5I_object_verify(plugin_id, H5I_VOL))) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a VOL plugin ID") + + if((ret_value = H5VL_request_wait(req, vol_cls, status)) < 0) + HGOTO_ERROR(H5E_VOL, H5E_CANTRELEASE, FAIL, "unable to wait on request") + +done: + FUNC_LEAVE_API(ret_value) +} /* end H5VLrequest_wait() */ diff --git a/src/H5VLint.c b/src/H5VLint.c new file mode 100644 index 0000000..142c762 --- /dev/null +++ b/src/H5VLint.c @@ -0,0 +1,2355 @@ +/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * + * 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 files COPYING and Copyright.html. COPYING can be found at the root * + * of the source code distribution tree; Copyright.html can be found at the * + * root level of an installed copy of the electronic HDF5 document set and * + * is linked from the top-level documents page. It can also be found at * + * http://hdfgroup.org/HDF5/doc/Copyright.html. If you do not have * + * access to either file, you may request a copy from help@hdfgroup.org. * + * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ + +/* + * Programmer: Mohamad Chaarawi <chaarawi@hdfgroup.gov> + * January, 2012 + * + * 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 */ +/****************/ + +#define H5VL_PACKAGE /*suppress error about including H5VLpkg */ +#define H5I_PACKAGE /*suppress error about including H5Ipkg */ + +/* Interface initialization */ +#define H5_INTERFACE_INIT_FUNC H5VL_int_init_interface + +/***********/ +/* Headers */ +/***********/ +#include "H5private.h" /* Generic Functions */ +#include "H5Dprivate.h" /* Datasets */ +#include "H5Eprivate.h" /* Error handling */ +#include "H5Iprivate.h" /* IDs */ +#include "H5Ipkg.h" /* IDs Package header */ +#include "H5Lprivate.h" /* Links */ +#include "H5MMprivate.h" /* Memory management */ +#include "H5Pprivate.h" /* Property lists */ +#include "H5Oprivate.h" /* Object headers */ +#include "H5VLpkg.h" /* VOL package header */ +#include "H5VLprivate.h" /* VOL */ + +/****************/ +/* Local Macros */ +/****************/ + +/******************/ +/* Local Typedefs */ +/******************/ + + +/********************/ +/* Package Typedefs */ +/********************/ + + +/********************/ +/* Local Prototypes */ +/********************/ + + +/*********************/ +/* Package Variables */ +/*********************/ + + +/*****************************/ +/* Library Private Variables */ +/*****************************/ + + +/*******************/ +/* Local Variables */ +/*******************/ + +/* 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); + + +/*-------------------------------------------------------------------------- +NAME + H5VL_int_init_interface -- Initialize interface-specific information +USAGE + herr_t H5VL_int_init_interface() + +RETURNS + Non-negative on success/Negative on failure +DESCRIPTION + Initializes any interface-specific data or routines. (Just calls + H5VL_init_iterface currently). + +--------------------------------------------------------------------------*/ +static herr_t +H5VL_int_init_interface(void) +{ + FUNC_ENTER_NOAPI_NOINIT_NOERR + + FUNC_LEAVE_NOAPI(H5VL_init()) +} /* H5VL_int_init_interface() */ + + +/*------------------------------------------------------------------------- + * Function: H5VL_register + * + * Purpose: Registers a new vol plugin as a member of the virtual object + * layer class. + * + * Return: Success: A vol plugin ID which is good until the + * library is closed or the driver is + * unregistered. + * + * Failure: A negative value. + * + * Programmer: Mohamad Chaarawi + * January, 2012 + *------------------------------------------------------------------------- + */ +hid_t +H5VL_register(const void *_cls, size_t size, hbool_t app_ref) +{ + const H5VL_class_t *cls = (const H5VL_class_t *)_cls; + H5VL_class_t *saved = NULL; + hid_t ret_value; + + FUNC_ENTER_NOAPI(FAIL) + + /* Check arguments */ + HDassert(cls); + + /* Copy the class structure so the caller can reuse or free it */ + if(NULL == (saved = (H5VL_class_t *)H5MM_malloc(size))) + HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, FAIL, + "memory allocation failed for vol plugin class struct") + HDmemcpy(saved, cls, size); + + /* Create the new class ID */ + if((ret_value = H5I_register(H5I_VOL, saved, app_ref)) < 0) + HGOTO_ERROR(H5E_ATOM, H5E_CANTREGISTER, FAIL, "unable to register vol plugin ID") + +done: + if(ret_value < 0) + if(saved) + H5MM_xfree(saved); + + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5VL_register() */ + +/*------------------------------------------------------------------------- + * Function: H5VL_register_id + * + * Purpose: Wrapper to register an object ID with a VOL aux struct + * and increment ref count on VOL plugin ID + * + * Return: Success:Positive Identifier + * Failure: A negative value. + * + * Programmer: Mohamad Chaarawi + * August, 2014 + *------------------------------------------------------------------------- + */ +hid_t +H5VL_register_id(H5I_type_t type, void *object, H5VL_t *vol_plugin, hbool_t app_ref) +{ + H5VL_object_t *new_obj = NULL; + hid_t ret_value = FAIL; + + FUNC_ENTER_NOAPI(FAIL) + + /* Check arguments */ + HDassert(object); + HDassert(vol_plugin); + + /* 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->vol_info = vol_plugin; + vol_plugin->nrefs ++; + new_obj->vol_obj = object; + + if(H5I_DATATYPE == type) { + H5T_t *dt = NULL; + + if(NULL == (dt = H5T_construct_datatype(new_obj))) + HGOTO_ERROR(H5E_DATATYPE, H5E_CANTINIT, FAIL, "can't construct datatype object"); + + if((ret_value = H5I_register(type, dt, app_ref)) < 0) + HGOTO_ERROR(H5E_ATOM, H5E_CANTREGISTER, FAIL, "unable to atomize handle") + } + else { + if((ret_value = H5I_register(type, new_obj, app_ref)) < 0) + HGOTO_ERROR(H5E_ATOM, H5E_CANTREGISTER, FAIL, "unable to atomize handle") + } + +done: + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5VL_register_id() */ + +/*------------------------------------------------------------------------- + * Function: H5VL_free_id + * + * Purpose: Wrapper to register an object ID with a VOL aux struct + * and increment ref count on VOL plugin ID + * + * Return: Success:Positive Identifier + * Failure: A negative value. + * + * Programmer: Mohamad Chaarawi + * August, 2014 + *------------------------------------------------------------------------- + */ +herr_t +H5VL_free_object(H5VL_object_t *obj) +{ + herr_t ret_value = SUCCEED; + + FUNC_ENTER_NOAPI(SUCCEED) + + /* Check arguments */ + HDassert(obj); + + obj->vol_info->nrefs --; + if (0 == obj->vol_info->nrefs) { + if(H5I_dec_ref(obj->vol_info->vol_id) < 0) + HGOTO_ERROR(H5E_VOL, H5E_CANTDEC, FAIL, "unable to decrement ref count on VOL plugin") + obj->vol_info = H5FL_FREE(H5VL_t, obj->vol_info); + } + + obj = H5FL_FREE(H5VL_object_t, obj); + +done: + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5VL_free_id() */ + + +/*------------------------------------------------------------------------- + * Function: H5VL_fapl_open + * + * Purpose: Mark a vol as used by a file access property list + * + * Return: Success: non-negative + * + * Failure: negative + * + * Programmer: Mohamad Chaarawi + * January, 2012 + * + *------------------------------------------------------------------------- + */ +herr_t +H5VL_fapl_open(H5P_genplist_t *plist, hid_t vol_id, const void *vol_info) +{ + void *copied_vol_info = NULL; /* Temporary VOL driver info */ + herr_t ret_value = SUCCEED; /* Return value */ + + FUNC_ENTER_NOAPI_NOINIT + + /* increment the refcount on the plugin id */ + if(H5I_inc_ref(vol_id, FALSE) < 0) + HGOTO_ERROR(H5E_FILE, H5E_CANTINC, FAIL, "unable to increment ref count on VOL plugin") + if(H5VL_fapl_copy(vol_id, vol_info, &copied_vol_info) < 0) + HGOTO_ERROR(H5E_FILE, H5E_CANTCOPY, FAIL, "can't copy VOL plugin info") + + /* Set the vol properties for the list */ + if(H5P_set(plist, H5F_ACS_VOL_ID_NAME, &vol_id) < 0) + HGOTO_ERROR(H5E_FILE, H5E_CANTSET, FAIL, "can't set vol ID") + if(H5P_set(plist, H5F_ACS_VOL_INFO_NAME, &copied_vol_info) < 0) + HGOTO_ERROR(H5E_FILE, H5E_CANTSET, FAIL, "can't set vol info") + copied_vol_info = NULL; + +done: + if(ret_value < 0) + if(copied_vol_info && H5VL_fapl_close(vol_id, copied_vol_info) < 0) + HDONE_ERROR(H5E_FILE, H5E_CANTCLOSEOBJ, FAIL, "can't close copy of driver info") + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5VL_fapl_open() */ + + +/*------------------------------------------------------------------------- + * Function: H5VL_fapl_copy + * + * Purpose: copies plugin specific info to the fapl + * + * Return: Success: non-negative + * Failure: negative + * + * Programmer: Mohamad Chaarawi + * July, 2012 + * + *------------------------------------------------------------------------- + */ +herr_t +H5VL_fapl_copy(hid_t vol_id, const void *vol_info, void **copied_info) +{ + H5VL_class_t *vol_cls; + void *new_info = NULL; + herr_t ret_value = SUCCEED; /* Return value */ + + FUNC_ENTER_NOAPI_NOINIT + + if(NULL == (vol_cls = (H5VL_class_t *)H5I_object(vol_id))) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a VOL ID") + + /* Copy old pl, if one exists */ + if(vol_info) { + /* Allow the driver to copy or do it ourselves */ + if(vol_cls->fapl_copy) { + new_info = (vol_cls->fapl_copy)(vol_info); + if(NULL == new_info) + HGOTO_ERROR(H5E_VOL, H5E_NOSPACE, FAIL, "property list copy failed") + } + else if(vol_cls->fapl_size > 0) { + if(NULL == (new_info = H5MM_malloc(vol_cls->fapl_size))) + HGOTO_ERROR(H5E_VOL, H5E_NOSPACE, FAIL, "property list allocation failed") + HDmemcpy(new_info, vol_info, vol_cls->fapl_size); + } else + HGOTO_ERROR(H5E_VOL, H5E_UNSUPPORTED, FAIL, "no way to copy plugin property list") + } /* end if */ + + /* Set copied value */ + *copied_info = new_info; + +done: + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5VL_fapl_copy() */ + + +/*------------------------------------------------------------------------- + * Function: H5VL_fapl_close + * + * Purpose: Closes a vol for a property list + * + * Return: Success: non-negative + * Failure: negative + * + * Programmer: Mohamad Chaarawi + * January, 2012 + * + * Modifications: + * + *------------------------------------------------------------------------- + */ +herr_t +H5VL_fapl_close(hid_t vol_id, void *vol_info) +{ + H5VL_class_t *vol_cls; + herr_t ret_value = SUCCEED; /* Return value */ + + FUNC_ENTER_NOAPI(FAIL) + + if(vol_id > 0) { + if(NULL == (vol_cls = (H5VL_class_t *)H5I_object(vol_id))) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a VOL ID") + + /* Allow driver to free or do it ourselves */ + if(vol_info && vol_cls->fapl_free) { + if((vol_cls->fapl_free)(vol_info) < 0) + HGOTO_ERROR(H5E_VOL, H5E_CANTINIT, FAIL, "plugin free request failed") + } /* end if */ + else + H5MM_xfree(vol_info); + + /* Decrement reference count for plugin */ + if(H5I_dec_ref(vol_id) < 0) + HGOTO_ERROR(H5E_VOL, H5E_CANTDEC, FAIL, "can't decrement reference count for plugin") + } + +done: + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5VL_fapl_close() */ + + +/*------------------------------------------------------------------------- + * Function: H5VL_get_plugin_name + * + * Purpose: Private version of H5VLget_plugin_name + * + * Return: Success: The length of the plugin name + * Failure: Negative + * + * Programmer: Mohamad Chaarawi + * June, 2012 + * + *------------------------------------------------------------------------- + */ +ssize_t +H5VL_get_plugin_name(hid_t id, char *name/*out*/, size_t size) +{ + H5VL_object_t *obj = NULL; + const H5VL_class_t *vol_cls = NULL; + size_t len; + ssize_t ret_value; + + FUNC_ENTER_NOAPI(FAIL) + + /* get the object pointer */ + if(NULL == (obj = H5VL_get_object(id))) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "invalid file identifier") + + vol_cls = obj->vol_info->vol_cls; + + len = HDstrlen(vol_cls->name); + if(name) { + HDstrncpy(name, vol_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_plugin_name() */ + + +/*------------------------------------------------------------------------- + * Function: H5VL_object_register + * + * Purpose: utility function to create a user id for an object created + * or opened through the VOL + * + * Return: Success: registered ID + * Failure: FAIL + * + * Programmer: Mohamad Chaarawi + * June, 2012 + * + *------------------------------------------------------------------------- + */ +hid_t +H5VL_object_register(void *obj, H5I_type_t obj_type, hid_t plugin_id, hbool_t app_ref) +{ + H5VL_class_t *vol_cls = NULL; + H5VL_t *vol_info = NULL; /* VOL info struct */ + hid_t ret_value = FAIL; + + FUNC_ENTER_NOAPI(FAIL) + + if(NULL == (vol_cls = (H5VL_class_t *)H5I_object_verify(plugin_id, H5I_VOL))) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a VOL plugin ID") + + /* setup VOL info struct */ + if(NULL == (vol_info = H5FL_CALLOC(H5VL_t))) + HGOTO_ERROR(H5E_FILE, H5E_NOSPACE, FAIL, "can't allocate VL info struct") + vol_info->vol_cls = vol_cls; + vol_info->vol_id = plugin_id; + if(H5I_inc_ref(vol_info->vol_id, FALSE) < 0) + HGOTO_ERROR(H5E_ATOM, H5E_CANTINC, FAIL, "unable to increment ref count on VOL plugin") + + /* Get an atom for the object */ + if((ret_value = H5VL_register_id(obj_type, obj, vol_info, app_ref)) < 0) + HGOTO_ERROR(H5E_ATOM, H5E_CANTREGISTER, FAIL, "unable to atomize object handle") + +done: + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5VL_object_register() */ + + +/*------------------------------------------------------------------------- + * Function: H5VL_get_object + * + * Purpose: utility function to return the object pointer associated with + * an hid_t. This routine is the same as H5I_object for all types + * except for named datatypes, where the vol_obj is returned that + * is attached to the H5T_t struct. + * + * Return: Success: object pointer + * Failure: NULL + * + * Programmer: Mohamad Chaarawi + * June, 2012 + * + *------------------------------------------------------------------------- + */ +H5VL_object_t * +H5VL_get_object(hid_t id) +{ + void *obj = NULL; + H5I_type_t obj_type = H5I_get_type(id); + H5VL_object_t *ret_value = NULL; + + FUNC_ENTER_NOAPI(NULL) + + if(H5I_FILE == obj_type || H5I_GROUP == obj_type || H5I_ATTR == obj_type || + 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") + + /* if this is a datatype, get the VOL object attached to the H5T_t struct */ + 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") + } + } + else + 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_get_object() */ + + +/*------------------------------------------------------------------------- + * Function: H5VL_object + * + * Purpose: utility function to return the VOL object pointer associated with + * an hid_t. + * + * Return: Success: object pointer + * Failure: NULL + * + * Programmer: Mohamad Chaarawi + * September, 2014 + * + *------------------------------------------------------------------------- + */ +void * +H5VL_object(hid_t id) +{ + H5VL_object_t *obj = 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 == (obj = (H5VL_object_t *)H5I_object(id))) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, NULL, "invalid identifier") + + ret_value = obj->vol_obj; + break; + case H5I_DATATYPE: + { + H5T_t *dt; + + /* get the object */ + 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 == (obj = H5T_get_named_type(dt))) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, NULL, "not a named datatype") + + ret_value = obj->vol_obj; + 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() */ + + +/*------------------------------------------------------------------------- + * Function: H5VL_object_verify + * + * Purpose: utility function to return the VOL object pointer associated with + * an hid_t. + * + * Return: Success: object pointer + * Failure: NULL + * + * Programmer: Mohamad Chaarawi + * September, 2014 + * + *------------------------------------------------------------------------- + */ +void * +H5VL_object_verify(hid_t id, H5I_type_t obj_type) +{ + H5VL_object_t *obj = NULL; + void *ret_value = NULL; + + FUNC_ENTER_NOAPI(NULL) + + /* Get the symbol table entry */ + switch(obj_type) { + case H5I_GROUP: + case H5I_DATASET: + case H5I_FILE: + case H5I_ATTR: + /* get the object */ + if(NULL == (obj = (H5VL_object_t *)H5I_object_verify(id, obj_type))) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, NULL, "invalid identifier") + + ret_value = obj->vol_obj; + break; + case H5I_DATATYPE: + { + H5T_t *dt; + + /* get the object */ + if(NULL == (dt = (H5T_t *)H5I_object_verify(id, obj_type))) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, NULL, "invalid identifier") + + /* Get the actual datatype object that should be the vol_obj */ + if(NULL == (obj = H5T_get_named_type(dt))) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, NULL, "not a named datatype") + + ret_value = obj->vol_obj; + 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_verify() */ + +void * +H5VL_plugin_object(H5VL_object_t *obj) +{ + FUNC_ENTER_NOAPI_NOINIT_NOERR + + FUNC_LEAVE_NOAPI(obj->vol_obj) +} /* end H5VL_plugin_object() */ + + +/*------------------------------------------------------------------------- + * Function: H5VL_attr_create + * + * Purpose: Creates an attribute through the VOL + * + * Return: Success: pointer to the new attr. + * + * Failure: NULL + * + * Programmer: Mohamad Chaarawi + * April, 2012 + * + *------------------------------------------------------------------------- + */ +void * +H5VL_attr_create(void *obj, H5VL_loc_params_t loc_params, const H5VL_class_t *vol_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 == vol_cls->attr_cls.create) + HGOTO_ERROR(H5E_VOL, H5E_UNSUPPORTED, NULL, "vol plugin has no `attr create' method") + + /* call the corresponding VOL create callback */ + if(NULL == (ret_value = (vol_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 + * + * Programmer: Mohamad Chaarawi + * March, 2012 + * + *------------------------------------------------------------------------- + */ +void * +H5VL_attr_open(void *obj, H5VL_loc_params_t loc_params, const H5VL_class_t *vol_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 == vol_cls->attr_cls.open) + HGOTO_ERROR(H5E_VOL, H5E_UNSUPPORTED, NULL, "vol plugin has no `attr open' method") + + /* call the corresponding VOL open callback */ + if(NULL == (ret_value = (vol_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 + * + * Programmer: Mohamad Chaarawi + * March, 2012 + * + *------------------------------------------------------------------------- + */ +herr_t H5VL_attr_read(void *attr, const H5VL_class_t *vol_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 == vol_cls->attr_cls.read) + HGOTO_ERROR(H5E_VOL, H5E_UNSUPPORTED, FAIL, "vol plugin has no `attr read' method") + if((ret_value = (vol_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 + * + * Programmer: Mohamad Chaarawi + * March, 2012 + * + *------------------------------------------------------------------------- + */ +herr_t H5VL_attr_write(void *attr, const H5VL_class_t *vol_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 == vol_cls->attr_cls.write) + HGOTO_ERROR(H5E_VOL, H5E_UNSUPPORTED, FAIL, "vol plugin has no `attr write' method") + if((ret_value = (vol_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 + * + * Programmer: Mohamad Chaarawi + * March, 2012 + * + *------------------------------------------------------------------------- + */ +herr_t +H5VL_attr_get(void *obj, const H5VL_class_t *vol_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 == vol_cls->attr_cls.get) + HGOTO_ERROR(H5E_VOL, H5E_UNSUPPORTED, FAIL, "vol plugin has no `attr get' method") + + va_start (arguments, req); + if((ret_value = (vol_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 + * + * Programmer: Mohamad Chaarawi + * March, 2012 + * + *------------------------------------------------------------------------- + */ +herr_t +H5VL_attr_specific(void *obj, H5VL_loc_params_t loc_params, const H5VL_class_t *vol_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 == vol_cls->attr_cls.specific) + HGOTO_ERROR(H5E_VOL, H5E_UNSUPPORTED, FAIL, "vol plugin has no `attr specific' method") + + va_start (arguments, req); + if((ret_value = (vol_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 plugins. + * + * Return: Success: non negative + * + * Failure: negative + * + * Programmer: Mohamad Chaarawi + * March, 2012 + * + *------------------------------------------------------------------------- + */ +herr_t +H5VL_attr_optional(void *obj, const H5VL_class_t *vol_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 == vol_cls->attr_cls.optional) + HGOTO_ERROR(H5E_VOL, H5E_UNSUPPORTED, FAIL, "vol plugin has no `attr optional' method") + + va_start (arguments, req); + if((ret_value = (vol_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: Success: Non Negative + * + * Failure: Negative + * + * Programmer: Mohamad Chaarawi + * March, 2012 + * + *------------------------------------------------------------------------- + */ +herr_t +H5VL_attr_close(void *attr, const H5VL_class_t *vol_cls, hid_t dxpl_id, void **req) +{ + herr_t ret_value = SUCCEED; + + FUNC_ENTER_NOAPI(FAIL) + + if(NULL == vol_cls->attr_cls.close) + HGOTO_ERROR(H5E_VOL, H5E_UNSUPPORTED, FAIL, "vol plugin has no `attr close' method") + if((ret_value = (vol_cls->attr_cls.close)(attr, dxpl_id, req)) < 0) + HGOTO_ERROR(H5E_VOL, H5E_CANTRELEASE, FAIL, "close failed") + +done: + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5VL_attr_close() */ + + +/*------------------------------------------------------------------------- + * Function: H5VL_datatype_commit + * + * Purpose: Commits a datatype to the file through the VOL + * + * Return: Success: Positive + * + * Failure: Negative + * + * Programmer: Mohamad Chaarawi + * March, 2012 + * + *------------------------------------------------------------------------- + */ +void * +H5VL_datatype_commit(void *obj, H5VL_loc_params_t loc_params, const H5VL_class_t *vol_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 == vol_cls->datatype_cls.commit) + HGOTO_ERROR(H5E_VOL, H5E_UNSUPPORTED, NULL, "vol plugin has no `datatype commit' method") + + /* call the corresponding VOL commit callback */ + if(NULL == (ret_value = (vol_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 + * + * Programmer: Mohamad Chaarawi + * March, 2012 + * + *------------------------------------------------------------------------- + */ +void * +H5VL_datatype_open(void *obj, H5VL_loc_params_t loc_params, const H5VL_class_t *vol_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 == vol_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 = (vol_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: Success: non negative + * + * Failure: negative + * + * Programmer: Mohamad Chaarawi + * June, 2013 + * + *------------------------------------------------------------------------- + */ +herr_t +H5VL_datatype_get(void *obj, const H5VL_class_t *vol_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) + + if(NULL == vol_cls->datatype_cls.get) + HGOTO_ERROR(H5E_VOL, H5E_UNSUPPORTED, FAIL, "vol plugin has no `datatype get' method") + va_start (arguments, req); + if((ret_value = (vol_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 + * + * Programmer: Mohamad Chaarawi + * March, 2012 + * + *------------------------------------------------------------------------- + */ +herr_t +H5VL_datatype_specific(void *obj, const H5VL_class_t *vol_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 == vol_cls->datatype_cls.specific) + HGOTO_ERROR(H5E_VOL, H5E_UNSUPPORTED, FAIL, "vol plugin has no `datatype specific' method") + + va_start (arguments, req); + if((ret_value = (vol_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 plugins. + * + * Return: Success: non negative + * + * Failure: negative + * + * Programmer: Mohamad Chaarawi + * March, 2012 + * + *------------------------------------------------------------------------- + */ +herr_t +H5VL_datatype_optional(void *obj, const H5VL_class_t *vol_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 == vol_cls->datatype_cls.optional) + HGOTO_ERROR(H5E_VOL, H5E_UNSUPPORTED, FAIL, "vol plugin has no `datatype optional' method") + + va_start (arguments, req); + if((ret_value = (vol_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: Success: Positive + * Failure: Negative + * + * Programmer: Mohamad Chaarawi + * May, 2012 + * + *------------------------------------------------------------------------- + */ +herr_t +H5VL_datatype_close(void *dt, const H5VL_class_t *vol_cls, hid_t dxpl_id, void **req) +{ + herr_t ret_value = SUCCEED; /* Return value */ + + FUNC_ENTER_NOAPI(FAIL) + + /* check if the corresponding VOL close callback exists */ + if(NULL == vol_cls->datatype_cls.close) + HGOTO_ERROR(H5E_VOL, H5E_UNSUPPORTED, FAIL, "vol plugin has no `datatype close' method") + + /* call the corresponding VOL close callback */ + if((ret_value = (vol_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_dataset_create + * + * Purpose: Creates a dataset through the VOL + * + * Return: Success: pointer to dataset + * + * Failure: NULL + * + * Programmer: Mohamad Chaarawi + * March, 2012 + * + *------------------------------------------------------------------------- + */ +void * +H5VL_dataset_create(void *obj, H5VL_loc_params_t loc_params, const H5VL_class_t *vol_cls, const char *name, + hid_t dcpl_id, hid_t dapl_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 == vol_cls->dataset_cls.create) + HGOTO_ERROR(H5E_VOL, H5E_UNSUPPORTED, NULL, "vol plugin has no `dataset create' method") + + /* call the corresponding VOL create callback */ + if(NULL == (ret_value = (vol_cls->dataset_cls.create) + (obj, loc_params, name, dcpl_id, dapl_id, dxpl_id, req))) + HGOTO_ERROR(H5E_VOL, H5E_CANTINIT, NULL, "create failed") + +done: + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5VL_dataset_create() */ + + +/*------------------------------------------------------------------------- + * Function: H5VL_dataset_open + * + * Purpose: Opens a dataset through the VOL + * + * Return: Success: pointer to dataset + * + * Failure: NULL + * + * Programmer: Mohamad Chaarawi + * March, 2012 + * + *------------------------------------------------------------------------- + */ +void * +H5VL_dataset_open(void *obj, H5VL_loc_params_t loc_params, const H5VL_class_t *vol_cls, const char *name, + hid_t dapl_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 == vol_cls->dataset_cls.open) + HGOTO_ERROR(H5E_VOL, H5E_UNSUPPORTED, NULL, "vol plugin has no 'dset open' method") + + /* call the corresponding VOL open callback */ + if(NULL == (ret_value = (vol_cls->dataset_cls.open) + (obj, loc_params, name, dapl_id, dxpl_id, req))) + HGOTO_ERROR(H5E_VOL, H5E_CANTOPENOBJ, NULL, "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 + * + * Programmer: Mohamad Chaarawi + * March, 2012 + * + *------------------------------------------------------------------------- + */ +herr_t +H5VL_dataset_read(void *dset, const H5VL_class_t *vol_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 == vol_cls->dataset_cls.read) + HGOTO_ERROR(H5E_VOL, H5E_UNSUPPORTED, FAIL, "vol plugin has no `dataset read' method") + if((ret_value = (vol_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 + * + * Programmer: Mohamad Chaarawi + * March, 2012 + * + *------------------------------------------------------------------------- + */ +herr_t +H5VL_dataset_write(void *dset, const H5VL_class_t *vol_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 == vol_cls->dataset_cls.write) + HGOTO_ERROR(H5E_VOL, H5E_UNSUPPORTED, FAIL, "vol plugin has no `dataset write' method") + if((ret_value = (vol_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 + * + * Programmer: Mohamad Chaarawi + * March, 2012 + * + *------------------------------------------------------------------------- + */ +herr_t +H5VL_dataset_get(void *dset, const H5VL_class_t *vol_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 == vol_cls->dataset_cls.get) + HGOTO_ERROR(H5E_VOL, H5E_UNSUPPORTED, FAIL, "vol plugin has no `dataset get' method") + + va_start (arguments, req); + if((ret_value = (vol_cls->dataset_cls.get)(dset, 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_dataset_get() */ + + +/*------------------------------------------------------------------------- + * Function: H5VL_dataset_specific + * + * Purpose: specific operation on datasets through the VOL + * + * Return: Success: non negative + * + * Failure: negative + * + * Programmer: Mohamad Chaarawi + * March, 2012 + * + *------------------------------------------------------------------------- + */ +herr_t +H5VL_dataset_specific(void *obj, const H5VL_class_t *vol_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 == vol_cls->dataset_cls.specific) + HGOTO_ERROR(H5E_VOL, H5E_UNSUPPORTED, FAIL, "vol plugin has no `dataset specific' method") + + va_start (arguments, req); + if((ret_value = (vol_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() */ + + +/*------------------------------------------------------------------------- + * Function: H5VL_dataset_optional + * + * Purpose: optional operation specific to plugins. + * + * Return: Success: non negative + * + * Failure: negative + * + * Programmer: Mohamad Chaarawi + * March, 2012 + * + *------------------------------------------------------------------------- + */ +herr_t +H5VL_dataset_optional(void *obj, const H5VL_class_t *vol_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 == vol_cls->dataset_cls.optional) + HGOTO_ERROR(H5E_VOL, H5E_UNSUPPORTED, FAIL, "vol plugin has no `dataset optional' method") + + va_start (arguments, req); + if((ret_value = (vol_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); + +done: + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5VL_dataset_optional() */ + + +/*------------------------------------------------------------------------- + * Function: H5VL_dataset_close + * + * Purpose: Closes a dataset through the VOL + * + * Return: Success: Non Negative + * + * Failure: Negative + * + * Programmer: Mohamad Chaarawi + * March, 2012 + * + *------------------------------------------------------------------------- + */ +herr_t +H5VL_dataset_close(void *dset, const H5VL_class_t *vol_cls, hid_t dxpl_id, void **req) +{ + herr_t ret_value = SUCCEED; + + FUNC_ENTER_NOAPI(FAIL) + + if(NULL == vol_cls->dataset_cls.close) + HGOTO_ERROR(H5E_VOL, H5E_UNSUPPORTED, FAIL, "vol plugin has no `dset close' method") + if((ret_value = (vol_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 + * + * Programmer: Mohamad Chaarawi + * January, 2012 + * + *------------------------------------------------------------------------- + */ +void * +H5VL_file_create(const H5VL_class_t *vol_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 == vol_cls->file_cls.create) + HGOTO_ERROR(H5E_VOL, H5E_UNSUPPORTED, NULL, "vol plugin has no `file create' method") + /* call the corresponding VOL create callback */ + if(NULL == (ret_value = (vol_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 + * + * Programmer: Mohamad Chaarawi + * January, 2012 + * + *------------------------------------------------------------------------- + */ +void * +H5VL_file_open(const H5VL_class_t *vol_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) + + /* check if the corresponding VOL create callback exists */ + if(NULL == vol_cls->file_cls.open) + HGOTO_ERROR(H5E_VOL, H5E_UNSUPPORTED, NULL, "vol plugin has no `file open' method") + /* call the corresponding VOL create callback */ + if(NULL == (ret_value = (vol_cls->file_cls.open)(name, flags, fapl_id, dxpl_id, req))) + HGOTO_ERROR(H5E_VOL, H5E_CANTINIT, NULL, "open failed") + +done: + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5VL_file_open() */ + + +/*------------------------------------------------------------------------- + * Function: H5VL_file_get + * + * Purpose: Get specific information about the file through the VOL + * + * Return: Success: non negative + * + * Failure: negative + * + * Programmer: Mohamad Chaarawi + * February, 2012 + * + *------------------------------------------------------------------------- + */ +herr_t +H5VL_file_get(void *file, const H5VL_class_t *vol_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 == vol_cls->file_cls.get) + HGOTO_ERROR(H5E_VOL, H5E_UNSUPPORTED, FAIL, "vol plugin has no `file get' method") + + va_start(arguments, req); + if((ret_value = (vol_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() */ + + +/*------------------------------------------------------------------------- + * Function: H5VL_file_specific + * + * Purpose: perform File specific operations through the VOL + * + * Return: Success: non negative + * Failure: negative + * + * Programmer: Mohamad Chaarawi + * April, 2012 + * + *------------------------------------------------------------------------- + */ +herr_t +H5VL_file_specific(void *file, const H5VL_class_t *vol_cls, H5VL_file_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(specific_type == H5VL_FILE_IS_ACCESSIBLE) { + H5P_genplist_t *plist; /* Property list pointer */ + hid_t vol_id; /* VOL plugin identigier attached to fapl_id */ + 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_get(plist, H5F_ACS_VOL_ID_NAME, &vol_id) < 0) + HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, FAIL, "can't get vol plugin") + + if(NULL == (vol_cls = (H5VL_class_t *)H5I_object(vol_id))) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a VOL ID") + + va_start (arguments, req); + if((ret_value = (vol_cls->file_cls.specific) + (file, specific_type, dxpl_id, req, arguments)) < 0) + HGOTO_ERROR(H5E_VOL, H5E_CANTGET, FAIL, "specific failed") + va_end (arguments); + } + else { + if(NULL == vol_cls->file_cls.specific) + HGOTO_ERROR(H5E_VOL, H5E_UNSUPPORTED, FAIL, "vol plugin has no `file specific' method") + + va_start (arguments, req); + if((ret_value = (vol_cls->file_cls.specific) + (file, 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_file_specific() */ + + +/*------------------------------------------------------------------------- + * Function: H5VL_file_optional + * + * Purpose: perform a plugin specific operation + * + * Return: Success: non negative + * Failure: negative + * + * Programmer: Mohamad Chaarawi + * April, 2012 + * + *------------------------------------------------------------------------- + */ +herr_t +H5VL_file_optional(void *file, const H5VL_class_t *vol_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 == vol_cls->file_cls.optional) + HGOTO_ERROR(H5E_VOL, H5E_UNSUPPORTED, FAIL, "vol plugin has no `file optional' method") + + va_start (arguments, req); + if((ret_value = (vol_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: Success: Non Negative + * + * Failure: Negative + * + * Programmer: Mohamad Chaarawi + * January, 2012 + * + *------------------------------------------------------------------------- + */ +herr_t +H5VL_file_close(void *file, const H5VL_class_t *vol_cls, hid_t dxpl_id, void **req) +{ + herr_t ret_value = SUCCEED; + + FUNC_ENTER_NOAPI(FAIL) + + if(NULL == vol_cls->file_cls.close) + HGOTO_ERROR(H5E_VOL, H5E_UNSUPPORTED, FAIL, "vol plugin has no `file close' method") + if((ret_value = (vol_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 + * + * Programmer: Mohamad Chaarawi + * March, 2012 + * + *------------------------------------------------------------------------- + */ +void * +H5VL_group_create(void *obj, H5VL_loc_params_t loc_params, const H5VL_class_t *vol_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 == vol_cls->group_cls.create) + HGOTO_ERROR(H5E_VOL, H5E_UNSUPPORTED, NULL, "vol plugin has no `group create' method") + + /* call the corresponding VOL create callback */ + if(NULL == (ret_value = (vol_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 + * + * Programmer: Mohamad Chaarawi + * March, 2012 + * + *------------------------------------------------------------------------- + */ +void * +H5VL_group_open(void *obj, H5VL_loc_params_t loc_params, const H5VL_class_t *vol_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 == vol_cls->group_cls.open) + HGOTO_ERROR(H5E_VOL, H5E_UNSUPPORTED, NULL, "vol plugin has no `group open' method") + + if(NULL == (ret_value = (vol_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 + * + * Programmer: Mohamad Chaarawi + * February, 2012 + * + *------------------------------------------------------------------------- + */ +herr_t +H5VL_group_get(void *obj, const H5VL_class_t *vol_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 == vol_cls->group_cls.get) + HGOTO_ERROR(H5E_VOL, H5E_UNSUPPORTED, FAIL, "vol plugin has no `group get' method") + + va_start (arguments, req); + if((ret_value = (vol_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 + * + * Programmer: Mohamad Chaarawi + * March, 2012 + * + *------------------------------------------------------------------------- + */ +herr_t +H5VL_group_specific(void *obj, const H5VL_class_t *vol_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 == vol_cls->group_cls.specific) + HGOTO_ERROR(H5E_VOL, H5E_UNSUPPORTED, FAIL, "vol plugin has no `group specific' method") + + va_start (arguments, req); + if((ret_value = (vol_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 plugins. + * + * Return: Success: non negative + * + * Failure: negative + * + * Programmer: Mohamad Chaarawi + * March, 2012 + * + *------------------------------------------------------------------------- + */ +herr_t +H5VL_group_optional(void *obj, const H5VL_class_t *vol_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 == vol_cls->group_cls.optional) + HGOTO_ERROR(H5E_VOL, H5E_UNSUPPORTED, FAIL, "vol plugin has no `group optional' method") + + va_start (arguments, req); + if((ret_value = (vol_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: Success: Non Negative + * + * Failure: Negative + * + * Programmer: Mohamad Chaarawi + * March, 2012 + * + *------------------------------------------------------------------------- + */ +herr_t +H5VL_group_close(void *grp, const H5VL_class_t *vol_cls, hid_t dxpl_id, void **req) +{ + herr_t ret_value = SUCCEED; + + FUNC_ENTER_NOAPI(FAIL) + + if(NULL == vol_cls->group_cls.close) + HGOTO_ERROR(H5E_VOL, H5E_UNSUPPORTED, FAIL, "vol plugin has no `group close' method") + if((ret_value = (vol_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 + * + * Programmer: Mohamad Chaarawi + * April, 2012 + * + *------------------------------------------------------------------------- + */ +herr_t +H5VL_link_create(H5VL_link_create_type_t create_type, void *obj, H5VL_loc_params_t loc_params, + const H5VL_class_t *vol_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 == vol_cls->link_cls.create) + HGOTO_ERROR(H5E_VOL, H5E_UNSUPPORTED, FAIL, "vol plugin has no `link create' method") + /* call the corresponding VOL create callback */ + if((ret_value = (vol_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 + * + * Programmer: Mohamad Chaarawi + * April, 2012 + * + *------------------------------------------------------------------------- + */ +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 *vol_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 == vol_cls->link_cls.copy) + HGOTO_ERROR(H5E_VOL, H5E_UNSUPPORTED, FAIL, "vol plugin has no `link copy' method") + + /* call the corresponding VOL copy callback */ + if((ret_value = (vol_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 + * + * Programmer: Mohamad Chaarawi + * April, 2012 + * + *------------------------------------------------------------------------- + */ +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 *vol_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 == vol_cls->link_cls.move) + HGOTO_ERROR(H5E_VOL, H5E_UNSUPPORTED, FAIL, "vol plugin has no `link move' method") + + /* call the corresponding VOL move callback */ + if((ret_value = (vol_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 + * + * Programmer: Mohamad Chaarawi + * April, 2012 + * + *------------------------------------------------------------------------- + */ +herr_t +H5VL_link_get(void *obj, H5VL_loc_params_t loc_params, const H5VL_class_t *vol_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 == vol_cls->link_cls.get) + HGOTO_ERROR(H5E_VOL, H5E_UNSUPPORTED, FAIL, "vol plugin has no `link get' method") + + va_start (arguments, req); + if((ret_value = (vol_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 + * + * Programmer: Mohamad Chaarawi + * March, 2012 + * + *------------------------------------------------------------------------- + */ +herr_t +H5VL_link_specific(void *obj, H5VL_loc_params_t loc_params, const H5VL_class_t *vol_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 == vol_cls->link_cls.specific) + HGOTO_ERROR(H5E_VOL, H5E_UNSUPPORTED, FAIL, "vol plugin has no `link specific' method") + + va_start (arguments, req); + if((ret_value = (vol_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 plugins. + * + * Return: Success: non negative + * + * Failure: negative + * + * Programmer: Mohamad Chaarawi + * March, 2012 + * + *------------------------------------------------------------------------- + */ +herr_t +H5VL_link_optional(void *obj, const H5VL_class_t *vol_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 == vol_cls->link_cls.optional) + HGOTO_ERROR(H5E_VOL, H5E_UNSUPPORTED, FAIL, "vol plugin has no `link optional' method") + + va_start (arguments, req); + if((ret_value = (vol_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 + * + * Programmer: Mohamad Chaarawi + * March, 2012 + * + *------------------------------------------------------------------------- + */ +void * +H5VL_object_open(void *obj, H5VL_loc_params_t params, const H5VL_class_t *vol_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 == vol_cls->object_cls.open) + HGOTO_ERROR(H5E_VOL, H5E_UNSUPPORTED, NULL, "vol plugin has no `object open' method") + + /* call the corresponding VOL open callback */ + if(NULL == (ret_value = (vol_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 + * + * Programmer: Mohamad Chaarawi + * April, 2012 + * + *------------------------------------------------------------------------- + */ +herr_t +H5VL_object_copy(void *src_obj, H5VL_loc_params_t loc_params1, const H5VL_class_t *vol_cls1, const char *src_name, + void *dst_obj, H5VL_loc_params_t loc_params2, const H5VL_class_t *vol_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 plugins are the same */ + if (vol_cls1->value != vol_cls2->value) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "Objects are accessed through different VOL plugins and can't be linked") + + if(NULL == vol_cls1->object_cls.copy) + HGOTO_ERROR(H5E_VOL, H5E_UNSUPPORTED, FAIL, "vol plugin has no `object copy' method") + + if((ret_value = (vol_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 + * + * Programmer: Mohamad Chaarawi + * February, 2012 + * + *------------------------------------------------------------------------- + */ +herr_t +H5VL_object_get(void *obj, H5VL_loc_params_t loc_params, const H5VL_class_t *vol_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 == vol_cls->object_cls.get) + HGOTO_ERROR(H5E_VOL, H5E_UNSUPPORTED, FAIL, "vol plugin has no `object get' method") + + va_start (arguments, req); + if((ret_value = (vol_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 + * + * Programmer: Mohamad Chaarawi + * April, 2012 + * + *------------------------------------------------------------------------- + */ +herr_t +H5VL_object_specific(void *obj, H5VL_loc_params_t loc_params, const H5VL_class_t *vol_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 == vol_cls->object_cls.specific) + HGOTO_ERROR(H5E_VOL, H5E_UNSUPPORTED, FAIL, "vol plugin has no `object specific' method") + + va_start (arguments, req); + if((ret_value = (vol_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 plugins. + * + * Return: Success: non negative + * + * Failure: negative + * + * Programmer: Mohamad Chaarawi + * March, 2012 + * + *------------------------------------------------------------------------- + */ +herr_t +H5VL_object_optional(void *obj, const H5VL_class_t *vol_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 == vol_cls->object_cls.optional) + HGOTO_ERROR(H5E_VOL, H5E_UNSUPPORTED, FAIL, "vol plugin has no `object optional' method") + + va_start (arguments, req); + if((ret_value = (vol_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_request_cancel + * + * Purpose: Cancels a request through the VOL + * + * Return: Success: Non Negative + * Failure: Negative + * + * Programmer: Mohamad Chaarawi + * March, 2013 + * + *------------------------------------------------------------------------- + */ +herr_t +H5VL_request_cancel(void **req, const H5VL_class_t *vol_cls, H5ES_status_t *status) +{ + herr_t ret_value = SUCCEED; + + FUNC_ENTER_NOAPI(FAIL) + + if(NULL == vol_cls->async_cls.cancel) + HGOTO_ERROR(H5E_VOL, H5E_UNSUPPORTED, FAIL, "vol plugin has no `async cancel' method"); + if((ret_value = (vol_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 a request through the VOL + * + * Return: Success: Non Negative + * Failure: Negative + * + * Programmer: Mohamad Chaarawi + * March, 2013 + * + *------------------------------------------------------------------------- + */ +herr_t +H5VL_request_test(void **req, const H5VL_class_t *vol_cls, H5ES_status_t *status) +{ + herr_t ret_value = SUCCEED; + + FUNC_ENTER_NOAPI(FAIL) + + if(NULL == vol_cls->async_cls.test) + HGOTO_ERROR(H5E_VOL, H5E_UNSUPPORTED, FAIL, "vol plugin has no `async test' method"); + if((ret_value = (vol_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() */ + + +/*------------------------------------------------------------------------- + * Function: H5VL_request_wait + * + * Purpose: Waits a request through the VOL + * + * Return: Success: Non Negative + * Failure: Negative + * + * Programmer: Mohamad Chaarawi + * March, 2013 + * + *------------------------------------------------------------------------- + */ +herr_t +H5VL_request_wait(void **req, const H5VL_class_t *vol_cls, H5ES_status_t *status) +{ + herr_t ret_value = SUCCEED; + + FUNC_ENTER_NOAPI(FAIL) + + if(NULL == vol_cls->async_cls.wait) + HGOTO_ERROR(H5E_VOL, H5E_UNSUPPORTED, FAIL, "vol plugin has no `async wait' method"); + if((ret_value = (vol_cls->async_cls.wait)(req, status)) < 0) + HGOTO_ERROR(H5E_VOL, H5E_CANTRELEASE, FAIL, "request wait failed") + +done: + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5VL_request_wait() */ diff --git a/src/H5VLnative.c b/src/H5VLnative.c new file mode 100644 index 0000000..9675655 --- /dev/null +++ b/src/H5VLnative.c @@ -0,0 +1,3413 @@ +/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * + * 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 files COPYING and Copyright.html. COPYING can be found at the root * + * of the source code distribution tree; Copyright.html can be found at the * + * root level of an installed copy of the electronic HDF5 document set and * + * is linked from the top-level documents page. It can also be found at * + * http://hdfgroup.org/HDF5/doc/Copyright.html. If you do not have * + * access to either file, you may request a copy from help@hdfgroup.org. * + * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ + +/* + * Programmer: Mohamad Chaarawi <chaarawi@hdfgroup.gov> + * January, 2012 + * + * Purpose: The native VOL plugin where access is to a single HDF5 file + * using HDF5 VFDs. + */ + +#define H5A_PACKAGE /*suppress error about including H5Apkg */ +#define H5D_PACKAGE /*suppress error about including H5Dpkg */ +#define H5F_PACKAGE /*suppress error about including H5Fpkg */ +#define H5G_PACKAGE /*suppress error about including H5Gpkg */ +#define H5L_PACKAGE /*suppress error about including H5Lpkg */ +#define H5O_PACKAGE /*suppress error about including H5Opkg */ +#define H5R_PACKAGE /*suppress error about including H5Rpkg */ +#define H5T_PACKAGE /*suppress error about including H5Tpkg */ + +/* Interface initialization */ +#define H5_INTERFACE_INIT_FUNC H5VL_native_init_interface + +#include "H5private.h" /* Generic Functions */ +#include "H5Apkg.h" /* Attribute pkg */ +#include "H5Dpkg.h" /* Dataset pkg */ +#include "H5Eprivate.h" /* Error handling */ +#include "H5Fpkg.h" /* File pkg */ +#include "H5Gpkg.h" /* Groups */ +#include "H5HGprivate.h" /* Global Heaps */ +#include "H5Iprivate.h" /* IDs */ +#include "H5Lpkg.h" /* links headers */ +#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 plugins */ +#include "H5VLnative.h" /* Native VOL plugin */ + +/* + * The vol identification number. + */ +static hid_t H5VL_NATIVE_g = 0; + + +/* Prototypes */ +static H5F_t *H5VL_native_get_file(void *obj, H5I_type_t type); + +/* 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); + +/* 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_close(void *dt, 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_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_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); + +static H5VL_class_t H5VL_native_g = { + HDF5_VOL_NATIVE_VERSION_1, /* Version number */ + H5_VOL_NATIVE, /* Plugin value */ + "native", /* Plugin name */ + NULL, /* initialize */ + NULL, /* terminate */ + 0, /* fapl_size */ + NULL, /* fapl_copy */ + NULL, /* fapl_free */ + { /* 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 */ + }, + { /* 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 */ + NULL, /* optional */ + H5VL_native_dataset_close /* close */ + }, + { /* datatype_cls */ + H5VL_native_datatype_commit, /* commit */ + H5VL_native_datatype_open, /* open */ + H5VL_native_datatype_get, /* get */ + NULL, /* specific */ + NULL, /* optional */ + 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 */ + }, + { /* group_cls */ + H5VL_native_group_create, /* create */ + H5VL_native_group_open, /* open */ + H5VL_native_group_get, /* get */ + NULL, /* specific */ + NULL, /* 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 */ + 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 */ + }, + { /* async_cls */ + NULL, /* cancel */ + NULL, /* test */ + NULL /* wait */ + }, + NULL +}; + + +/*-------------------------------------------------------------------------- +NAME + H5VL_native_init_interface -- Initialize interface-specific information +USAGE + herr_t H5VL_native_init_interface() + +RETURNS + Non-negative on success/Negative on failure +DESCRIPTION + Initializes any interface-specific data or routines. (Just calls + H5VL_native_init currently). + +--------------------------------------------------------------------------*/ +static herr_t +H5VL_native_init_interface(void) +{ + FUNC_ENTER_NOAPI_NOINIT_NOERR + H5VL_native_init(); + FUNC_LEAVE_NOAPI(SUCCEED) +} /* H5VL_native_init_interface() */ + + +/*------------------------------------------------------------------------- + * Function: H5VL_native_init + * + * Purpose: Initialize this vol plugin by registering the driver with the + * library. + * + * Return: Success: The ID for the native plugin. + * Failure: Negative. + * + * Programmer: Mohamad Chaarawi + * January, 2012 + * + *------------------------------------------------------------------------- + */ +hid_t +H5VL_native_init(void) +{ + hid_t ret_value = FAIL; /* Return value */ + + FUNC_ENTER_NOAPI(FAIL) + + /* Register the Native VOL, if it isn't already */ + if(NULL == H5I_object_verify(H5VL_NATIVE_g, H5I_VOL)) { + if((H5VL_NATIVE_g = H5VL_register((const H5VL_class_t *)&H5VL_native_g, + sizeof(H5VL_class_t), TRUE)) < 0) + HGOTO_ERROR(H5E_ATOM, H5E_CANTINSERT, FAIL, "can't create ID for native plugin") + } + + /* Set return value */ + ret_value = H5VL_NATIVE_g; + +done: + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5VL_native_init() */ + + +/*--------------------------------------------------------------------------- + * Function: H5VL_native_get_file + * + * Purpose: utility routine to get file object + * + * Returns: Non-negative on success or negative on failure + * + * Programmer: Mohamad Chaarawi + * June, 2012 + * + *--------------------------------------------------------------------------- + */ +static H5F_t * +H5VL_native_get_file(void *obj, H5I_type_t type) +{ + H5F_t *ret_value = NULL; /* File to flush */ + 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") + } /* end switch */ + + if(!ret_value) { + if(!oloc) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, NULL, "object is not assocated with a file") + ret_value = oloc->file; + } /* end if */ + 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 plugin + * as an auxilary object + * + * Returns: Non-negative on success or negative on failure + * + * Programmer: Mohamad Chaarawi + * June, 2012 + * + *--------------------------------------------------------------------------- + */ +hid_t +H5VL_native_register(H5I_type_t type, void *obj, hbool_t app_ref) +{ + hid_t ret_value = FAIL; + + FUNC_ENTER_NOAPI_NOINIT + + HDassert(obj); + + /* make sure this is from the internal Native plugin not from the API */ + if(type == H5I_DATATYPE) { + HDassert(((H5T_t *)obj)->vol_obj == NULL); + } + + /* Get an atom for the object */ + if ((ret_value = H5VL_object_register(obj, type, H5VL_NATIVE_g, app_ref)) < 0) + HGOTO_ERROR(H5E_ATOM, H5E_CANTREGISTER, FAIL, "unable to atomize object handle") + +#if 0 + else { + H5VL_t *vol_info = NULL; /* VOL info struct */ + H5VL_object_t *new_obj = NULL; + + /* setup VOL object */ + if(NULL == (new_obj = H5FL_CALLOC(H5VL_object_t))) + HGOTO_ERROR(H5E_VOL, H5E_NOSPACE, NULL, "can't allocate top object structure") + new_obj->vol_obj = obj; + + /* setup VOL info struct */ + if(NULL == (vol_info = H5FL_CALLOC(H5VL_t))) + HGOTO_ERROR(H5E_FILE, H5E_NOSPACE, NULL, "can't allocate VL info struct") + vol_info->vol_cls = &H5VL_native_g; + vol_info->nrefs = 1; + vol_info->vol_id = H5VL_NATIVE_g; + if(H5I_inc_ref(vol_info->id, FALSE) < 0) + HGOTO_ERROR(H5E_ATOM, H5E_CANTINC, NULL, "unable to increment ref count on VOL plugin") + new_obj->vol_info = vol_info; + + if((ret_value = H5I_register(obj_type, new_obj, app_ref)) < 0) + HGOTO_ERROR(H5E_ATOM, H5E_CANTREGISTER, FAIL, "unable to register object ID") + } +#endif + +done: + FUNC_LEAVE_NOAPI(ret_value) +} /* H5VL_native_register */ + + +/*--------------------------------------------------------------------------- + * Function: H5VL_native_unregister + * + * Purpose: utility routine to decrement ref count on Native VOL plugin + * + * Returns: Non-negative on success or negative on failure + * + * Programmer: Mohamad Chaarawi + * August, 2014 + * + *--------------------------------------------------------------------------- + */ +herr_t +H5VL_native_unregister(hid_t obj_id) +{ + H5VL_object_t *obj = NULL; + herr_t ret_value = SUCCEED; + + FUNC_ENTER_NOAPI_NOINIT + + /* get the plugin pointer */ + if (NULL == (obj = (H5VL_object_t *)H5VL_get_object(obj_id))) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "invalid ID") + + /* free object */ + if(H5VL_free_object(obj) < 0) + HGOTO_ERROR(H5E_FILE, H5E_CANTDEC, FAIL, "unable to free VOL object") + +done: + FUNC_LEAVE_NOAPI(ret_value) +} /* H5VL_native_unregister */ + + +/*------------------------------------------------------------------------- + * Function: H5Pset_fapl_native + * + * Purpose: Modify the file access property list to use the H5VL_NATIVE + * plugin defined in this source file. + * + * Return: Non-negative on success/Negative on failure + * + * Programmer: Mohamad Chaarawi + * January, 2012 + * + *------------------------------------------------------------------------- + */ +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_g, NULL); + +done: + FUNC_LEAVE_API(ret_value) +} /* end H5Pset_fapl_native() */ + + +/*------------------------------------------------------------------------- + * Function: H5VL_native_attr_create + * + * Purpose: Creates an attribute on an object. + * + * Return: Success: attr id. + * Failure: NULL + * + * Programmer: Mohamad Chaarawi + * March, 2012 + * + *------------------------------------------------------------------------- + */ +static void * +H5VL_native_attr_create(void *obj, H5VL_loc_params_t loc_params, const char *attr_name, hid_t acpl_id, + hid_t UNUSED aapl_id, hid_t dxpl_id, void 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(type_id))) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, NULL, "not a datatype") + /* If this is a named datatype, get the plugin pointer to the datatype */ + type = (H5T_t *)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, dxpl_id))) + HGOTO_ERROR(H5E_ATTR, H5E_CANTINIT, NULL, "unable to create attribute") + } + else if(loc_params.type == H5VL_OBJECT_BY_NAME) { /* H5Acreate_by_name */ + 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 */ + if(H5G_loc_find(&loc, loc_params.loc_data.loc_by_name.name, &obj_loc/*out*/, + loc_params.loc_data.loc_by_name.lapl_id, H5AC_ind_dxpl_id) < 0) + HGOTO_ERROR(H5E_ATTR, H5E_NOTFOUND, NULL, "object not found") + loc_found = TRUE; + + /* Go do the real work for attaching the attribute to the dataset */ + if(NULL == (attr = H5A_create(&obj_loc, attr_name, type, space, acpl_id, dxpl_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 UNUSED aapl_id, hid_t dxpl_id, void 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 */ + /* Read in attribute from object header */ + if(NULL == (attr = H5O_attr_open_by_name(loc.oloc, attr_name, dxpl_id))) + HGOTO_ERROR(H5E_ATTR, H5E_CANTINIT, NULL, "unable to load attribute info from object header for attribute: '%s'", attr_name) + /* Finish initializing attribute */ + if(H5A_open_common(&loc, attr) < 0) + HGOTO_ERROR(H5E_ATTR, H5E_CANTINIT, NULL, "unable to initialize attribute") + } + 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, + loc_params.loc_data.loc_by_name.lapl_id, dxpl_id))) + 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, + loc_params.loc_data.loc_by_idx.lapl_id, dxpl_id))) + 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 dxpl_id, void 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, dxpl_id)) < 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 dxpl_id, void 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, dxpl_id)) < 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 dxpl_id, void 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, + loc_params.loc_data.loc_by_idx.lapl_id, + dxpl_id))) + 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, + loc_params.loc_data.loc_by_name.lapl_id, + dxpl_id))) + 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, + loc_params.loc_data.loc_by_idx.lapl_id, + dxpl_id))) + 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 dxpl_id, void UNUSED **req, va_list arguments) +{ + herr_t ret_value = SUCCEED; /* Return value */ + + FUNC_ENTER_NOAPI_NOINIT + + switch (specific_type) { + case H5VL_ATTR_DELETE: + { + char *attr_name = va_arg (arguments, char *); + + if(H5A_delete(obj, loc_params, attr_name) < 0) + HGOTO_ERROR(H5E_ATTR, H5E_CANTDELETE, FAIL, "error deleting attribute") + break; + } + case H5VL_ATTR_EXISTS: + { + const char *attr_name = va_arg (arguments, const char *); + htri_t *ret = va_arg (arguments, htri_t *); + 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") + + if(loc_params.type == H5VL_OBJECT_BY_SELF) { /* H5Aexists */ + /* Check if the attribute exists */ + if((*ret = H5O_attr_exists(loc.oloc, attr_name, dxpl_id)) < 0) + HGOTO_ERROR(H5E_ATTR, H5E_CANTGET, FAIL, "unable to determine if attribute exists") + } + else if(loc_params.type == H5VL_OBJECT_BY_NAME) { /* H5Aopen_by_name */ + /* Check if the attribute exists */ + if((*ret = H5A_exists_by_name(loc, loc_params.loc_data.loc_by_name.name, attr_name, + loc_params.loc_data.loc_by_name.lapl_id)) < 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((ret_value = H5A_iterate(obj, loc_params, idx_type, order, idx, op, op_data)) < 0) + HGOTO_ERROR(H5E_ATTR, H5E_BADITER, FAIL, "error iterating over attributes") + 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 *); + 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") + + if(loc_params.type == H5VL_OBJECT_BY_SELF) { /* H5Arename */ + /* Call attribute rename routine */ + if(H5O_attr_rename(loc.oloc, dxpl_id, 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, loc_params.loc_data.loc_by_name.lapl_id) < 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 UNUSED dxpl_id, void 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_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 tapl_id, hid_t dxpl_id, void UNUSED **req) +{ + H5G_loc_t loc; /* Location to commit datatype */ + H5T_t *dt; /* Datatype for ID */ + H5T_t *type; /* 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"); + + if(NULL != name) { /* H5Tcommit */ + /* Commit the type */ + if(H5T__commit_named(&loc, name, type, lcpl_id, tcpl_id, tapl_id, dxpl_id) < 0) + HGOTO_ERROR(H5E_DATATYPE, H5E_CANTINIT, NULL, "unable to commit datatype") + } + else { /* H5Tcommit_anon */ + /* Commit the type */ + if(H5T__commit(loc.oloc->file, type, tcpl_id, dxpl_id) < 0) + HGOTO_ERROR(H5E_DATATYPE, H5E_CANTINIT, NULL, "unable to commit datatype") + + /* Release the datatype's object header */ + { + H5O_loc_t *oloc; /* Object location for datatype */ + + /* Get the new committed datatype's object location */ + if(NULL == (oloc = H5T_oloc(type))) + HGOTO_ERROR(H5E_DATATYPE, H5E_CANTGET, NULL, "unable to get object location of committed datatype") + + /* Decrement refcount on committed datatype's object header in memory */ + if(H5O_dec_rc_by_loc(oloc, dxpl_id) < 0) + HGOTO_ERROR(H5E_DATATYPE, H5E_CANTDEC, NULL, "unable to decrement refcount on newly created object") + } /* end if */ + } + ret_value = (void *)type; + +done: + 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 id. + * Failure: NULL + * + * Programmer: Mohamad Chaarawi + * March, 2012 + * + *------------------------------------------------------------------------- + */ +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 UNUSED **req) +{ + H5T_t *type = NULL; /* Datatype opened in file */ + H5G_loc_t loc; /* Group location of object to open */ + H5G_name_t path; /* Datatype group hier. path */ + H5O_loc_t oloc; /* Datatype object location */ + H5O_type_t obj_type; /* Type of object at location */ + H5G_loc_t type_loc; /* Group object for datatype */ + hbool_t obj_found = FALSE; /* Object at 'name' found */ + 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") + + /* Set up datatype location to fill in */ + type_loc.oloc = &oloc; + type_loc.path = &path; + H5G_loc_reset(&type_loc); + + /* + * Find the named datatype object header and read the datatype message + * from it. + */ + if(H5G_loc_find(&loc, name, &type_loc/*out*/, tapl_id, dxpl_id) < 0) + HGOTO_ERROR(H5E_DATATYPE, H5E_NOTFOUND, NULL, "not found") + obj_found = TRUE; + + /* Check that the object found is the correct type */ + if(H5O_obj_type(&oloc, &obj_type, dxpl_id) < 0) + HGOTO_ERROR(H5E_DATATYPE, H5E_CANTGET, NULL, "can't get object type") + if(obj_type != H5O_TYPE_NAMED_DATATYPE) + HGOTO_ERROR(H5E_DATATYPE, H5E_BADTYPE, NULL, "not a named datatype") + + /* Open it */ + if(NULL == (type = H5T_open(&type_loc, dxpl_id))) + HGOTO_ERROR(H5E_DATATYPE, H5E_CANTOPENOBJ, NULL, "unable to open named datatype") + + type->vol_obj = NULL; + ret_value = (void *)type; +done: + if(NULL == type) + if(obj_found && H5F_addr_defined(type_loc.oloc->addr)) + H5G_loc_free(&type_loc); + 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 dxpl_id, void 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 *); + H5P_genplist_t *tcpl_plist = NULL; /* New datatype creation property list */ + hid_t tcpl_id; + + /* Copy the default datatype creation property list */ + if(NULL == (tcpl_plist = (H5P_genplist_t *)H5I_object(H5P_LST_DATATYPE_CREATE_ID_g))) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "can't get default creation property list") + if((tcpl_id = H5P_copy_plist(tcpl_plist, TRUE)) < 0) + HGOTO_ERROR(H5E_DATATYPE, H5E_CANTGET, FAIL, "unable to copy the creation property list") + + tcpl_plist = NULL; + + /* Get property list object for new TCPL */ + if(NULL == (tcpl_plist = (H5P_genplist_t *)H5I_object(tcpl_id))) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "can't get property list"); + + /* Retrieve any object creation properties */ + if(H5O_get_create_plist(&dt->oloc, dxpl_id, tcpl_plist) < 0) + HGOTO_ERROR(H5E_DATATYPE, H5E_CANTGET, FAIL, "can't get object creation info"); + + *ret_id = tcpl_id; + 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_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 UNUSED dxpl_id, void 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() */ + + +/*------------------------------------------------------------------------- + * Function: H5VL_native_dataset_create + * + * Purpose: Creates a dataset inside a native h5 file. + * + * Return: Success: dataset id. + * Failure: NULL + * + * Programmer: Mohamad Chaarawi + * March, 2012 + * + *------------------------------------------------------------------------- + */ +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 UNUSED **req) +{ + H5P_genplist_t *plist; /* Property list pointer */ + H5G_loc_t loc; /* Object location to insert dataset into */ + hid_t type_id, space_id, lcpl_id; + 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, dxpl_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, dxpl_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, dxpl_id) < 0) + HDONE_ERROR(H5E_DATASET, H5E_CANTDEC, NULL, "unable to decrement refcount on newly created object") + } /* end if */ + } + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5VL_native_dataset_create() */ + + +/*------------------------------------------------------------------------- + * Function: H5VL_native_dataset_open + * + * Purpose: Opens a dataset inside a native h5 file. + * + * Return: Success: dataset id. + * Failure: NULL + * + * Programmer: Mohamad Chaarawi + * March, 2012 + * + *------------------------------------------------------------------------- + */ +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 UNUSED **req) +{ + H5D_t *dset = NULL; + H5G_loc_t loc; /* Object location of group */ + H5G_loc_t dset_loc; /* Object location of dataset */ + H5G_name_t path; /* Dataset group hier. path */ + H5O_loc_t oloc; /* Dataset object location */ + H5O_type_t obj_type; /* Type of object at location */ + hbool_t loc_found = FALSE; /* Location at 'name' found */ + 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") + + /* Set up dataset location to fill in */ + dset_loc.oloc = &oloc; + dset_loc.path = &path; + H5G_loc_reset(&dset_loc); + + /* Find the dataset object */ + if(H5G_loc_find(&loc, name, &dset_loc, dapl_id, dxpl_id) < 0) + HGOTO_ERROR(H5E_DATASET, H5E_NOTFOUND, NULL, "not found") + loc_found = TRUE; + + /* Check that the object found is the correct type */ + if(H5O_obj_type(&oloc, &obj_type, dxpl_id) < 0) + HGOTO_ERROR(H5E_DATASET, H5E_CANTGET, NULL, "can't get object type") + if(obj_type != H5O_TYPE_DATASET) + HGOTO_ERROR(H5E_DATASET, H5E_BADTYPE, NULL, "not a dataset") + + /* Open the dataset */ + if(NULL == (dset = H5D_open(&dset_loc, dapl_id, dxpl_id))) + HGOTO_ERROR(H5E_DATASET, H5E_CANTINIT, NULL, "can't open dataset") + + ret_value = (void *)dset; + +done: + if(NULL == dset && loc_found && H5G_loc_free(&dset_loc) < 0) + HDONE_ERROR(H5E_DATASET, H5E_CANTRELEASE, NULL, "can't free location") + 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: Success: 0 + * Failure: -1, dataset not readd. + * + * Programmer: Mohamad Chaarawi + * March, 2012 + * + *------------------------------------------------------------------------- + */ +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 plist_id, void *buf, void 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, "not a dataset") + + if(H5S_ALL != mem_space_id) + if(NULL == (mem_space = (const H5S_t *)H5I_object_verify(mem_space_id, H5I_DATASPACE))) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a data space") + + if(H5S_ALL != file_space_id) + if(NULL == (file_space = (const H5S_t *)H5I_object_verify(file_space_id, H5I_DATASPACE))) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a data space") + + /* read raw data */ + if(H5D__read(dset, mem_type_id, mem_space, file_space, plist_id, 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: Success: 0 + * Failure: -1, dataset not writed. + * + * Programmer: Mohamad Chaarawi + * March, 2012 + * + *------------------------------------------------------------------------- + */ +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 dxpl_id, const void *buf, void UNUSED **req) +{ + H5D_t *dset = (H5D_t *)obj; + const H5S_t *mem_space = NULL; + const H5S_t *file_space = NULL; + H5P_genplist_t *plist; /* Property list pointer */ + hbool_t direct_write = FALSE; + 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, "not a dataset") + + /* Get the dataset transfer property list */ + if(NULL == (plist = (H5P_genplist_t *)H5I_object(dxpl_id))) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a dataset transfer property list") + + /* Retrieve the 'direct write' flag */ + if(H5P_get(plist, H5D_XFER_DIRECT_CHUNK_WRITE_FLAG_NAME, &direct_write) < 0) + HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, FAIL, "error getting flag for direct chunk write") + + if(!direct_write) { + if(H5S_ALL != mem_space_id) + if(NULL == (mem_space = (const H5S_t *)H5I_object_verify(mem_space_id, H5I_DATASPACE))) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a data space") + + if(H5S_ALL != file_space_id) + if(NULL == (file_space = (const H5S_t *)H5I_object_verify(file_space_id, H5I_DATASPACE))) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a data space") + } /* end if */ + + if(H5D__pre_write(dset, direct_write, mem_type_id, mem_space, file_space, dxpl_id, buf) < 0) + HGOTO_ERROR(H5E_DATASET, H5E_WRITEERROR, FAIL, "can't prepare for writing 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: Success: 0 + * Failure: -1 + * + * Programmer: Mohamad Chaarawi + * March, 2012 + * + *------------------------------------------------------------------------- + */ +static herr_t +H5VL_native_dataset_get(void *obj, H5VL_dataset_get_t get_type, hid_t dxpl_id, + void 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, dxpl_id) < 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, dxpl_id, ret) < 0) + HGOTO_ERROR(H5E_DATASET, H5E_CANTGET, 0, "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: Success: 0 + * Failure: -1 + * + * Programmer: Mohamad Chaarawi + * August, 2014 + * + *------------------------------------------------------------------------- + */ +static herr_t +H5VL_native_dataset_specific(void *obj, H5VL_dataset_specific_t specific_type, + hid_t dxpl_id, void 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, dxpl_id) < 0) + HGOTO_ERROR(H5E_DATASET, H5E_CANTINIT, FAIL, "unable to set extent of 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_close + * + * Purpose: Closes a dataset. + * + * Return: Success: 0 + * Failure: -1, dataset not closed. + * + * Programmer: Mohamad Chaarawi + * March, 2012 + * + *------------------------------------------------------------------------- + */ +static herr_t +H5VL_native_dataset_close(void *dset, hid_t UNUSED dxpl_id, void 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: the file id. + * Failure: NULL + * + * Programmer: Mohamad Chaarawi + * January, 2012 + * + *------------------------------------------------------------------------- + */ +static void * +H5VL_native_file_create(const char *name, unsigned flags, hid_t fcpl_id, hid_t fapl_id, + hid_t dxpl_id, void 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, dxpl_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: file id. + * Failure: NULL + * + * Programmer: Mohamad Chaarawi + * January, 2012 + * + *------------------------------------------------------------------------- + */ +static void * +H5VL_native_file_open(const char *name, unsigned flags, hid_t fapl_id, hid_t dxpl_id, void 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, dxpl_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) < 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: Success: 0 + * Failure: -1 + * + * Programmer: Mohamad Chaarawi + * February, 2012 + * + *------------------------------------------------------------------------- + */ +static herr_t +H5VL_native_file_get(void *obj, H5VL_file_get_t get_type, hid_t UNUSED dxpl_id, void 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_INTERNAL, 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_INTERNAL, 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_INTERNAL, 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 *ret = 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. + */ + if(H5F_INTENT(f) & H5F_ACC_RDWR) + *ret = H5F_ACC_RDWR; + else + *ret = H5F_ACC_RDONLY; + 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'; + } /* end if */ + + /* Set the return value for the API call */ + *ret = (ssize_t)len; + break; + } + /* H5I_get_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: Success: 0 + * Failure: -1 + * + * Programmer: Mohamad Chaarawi + * April, 2012 + * + *------------------------------------------------------------------------- + */ +static herr_t +H5VL_native_file_specific(void *obj, H5VL_file_specific_t specific_type, hid_t dxpl_id, + void UNUSED **req, va_list arguments) +{ + herr_t ret_value = SUCCEED; /* Return value */ + + FUNC_ENTER_NOAPI_NOINIT + + switch (specific_type) { + /* H5Fmount */ + 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 */ + + 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, dxpl_id) < 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, dxpl_id, FALSE) < 0) + HGOTO_ERROR(H5E_FILE, H5E_CANTFLUSH, FAIL, "unable to flush file's cached information") + } /* end else */ + } /* end if */ + 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, dxpl_id) < 0) + HGOTO_ERROR(H5E_FILE, H5E_MOUNT, FAIL, "unable to mount file") + + break; + } + /* H5Fmount */ + 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, dxpl_id) < 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, "unable to open file") + 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 plugin specific operation on a native file + * + * Return: Success: 0 + * Failure: -1 + * + * Programmer: Mohamad Chaarawi + * May, 2012 + * + *------------------------------------------------------------------------- + */ +static herr_t +H5VL_native_file_optional(void *obj, hid_t dxpl_id, void 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 eof; /* End of file address */ + haddr_t base_addr; /* Base address for the file */ + hsize_t *ret = va_arg (arguments, hsize_t *); + + f = (H5F_t *)obj; + /* Go get the actual file size */ + if(HADDR_UNDEF == (eof = H5FD_get_eof(f->shared->lf))) + HGOTO_ERROR(H5E_FILE, H5E_CANTGET, FAIL, "unable to get file size") + base_addr = H5FD_get_base_addr(f->shared->lf); + + if(ret) + *ret = (hsize_t)(eof + 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, dxpl_id, &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, dxpl_id, 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 *); + + if(NULL == (f = H5VL_native_get_file(obj, type))) { + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a file or file object") + } + + /* 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) + */ + HDassert(f->shared); + + /* Reset file info struct */ + HDmemset(finfo, 0, sizeof(*finfo)); + + /* Get the size of the superblock and any superblock extensions */ + if(H5F_super_size(f, dxpl_id, &finfo->super.super_size, + &finfo->super.super_ext_size) < 0) + HGOTO_ERROR(H5E_FILE, H5E_CANTGET, FAIL, "Unable to retrieve superblock sizes") + + /* Get the size of any persistent free space */ + if(H5MF_get_freespace(f, dxpl_id, &finfo->free.tot_space, + &finfo->free.meta_size) < 0) + HGOTO_ERROR(H5E_FILE, H5E_CANTGET, FAIL, "Unable to retrieve free space information") + + /* Check for SOHM info */ + if(H5F_addr_defined(f->shared->sohm_addr)) + if(H5SM_ih_size(f, dxpl_id, &finfo->sohm.hdr_size, &finfo->sohm.msgs_info) < 0) + HGOTO_ERROR(H5E_FILE, H5E_CANTGET, FAIL, "Unable to retrieve SOHM index & heap storage info") + + /* Set version # fields */ + finfo->super.version = f->shared->sblock->super_vers; + finfo->sohm.version = f->shared->sohm_vers; + finfo->free.version = HDF5_FREESPACE_VERSION; + 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 *); + int32_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 = va_arg (arguments, hid_t); + + f = (H5F_t *)obj; + /* Retrieve the VFD handle for the file */ + if(H5F_get_vfd_handle(f, fapl, 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; + 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; + } + 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: Success: 0 + * Failure: -1, file not closed. + * + * Programmer: Mohamad Chaarawi + * January, 2012 + * + *------------------------------------------------------------------------- + */ +static herr_t +H5VL_native_file_close(void *file, hid_t dxpl_id, void UNUSED **req) +{ + int nref; + H5F_t *f = (H5F_t *)file; + hid_t file_id = FAIL; + herr_t ret_value = SUCCEED; /* Return value */ + + FUNC_ENTER_NOAPI_NOINIT + + HDassert(f->id_exists); /* This routine should only be called when a file ID's ref count drops to zero */ + + /* 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((f->shared->nrefs > 1) && (H5F_INTENT(f) & H5F_ACC_RDWR)) { + /* get the file ID corresponding to the H5F_t struct */ + if((file_id = H5I_get_id(f, H5I_FILE)) < 0) + 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, dxpl_id, FALSE) < 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() */ + + +/*------------------------------------------------------------------------- + * Function: H5VL_native_group_create + * + * Purpose: Creates a group inside a native h5 file. + * + * Return: Success: group id. + * Failure: NULL + * + * Programmer: Mohamad Chaarawi + * January, 2012 + * + *------------------------------------------------------------------------- + */ +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 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 plist 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") + + 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, dxpl_id))) + 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, gapl_id, dxpl_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, dxpl_id) < 0) + HDONE_ERROR(H5E_SYM, H5E_CANTDEC, NULL, "unable to decrement refcount on newly created object") + } /* end if */ + } + 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: group id. + * Failure: NULL + * + * Programmer: Mohamad Chaarawi + * January, 2012 + * + *------------------------------------------------------------------------- + */ +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 UNUSED **req) +{ + H5G_loc_t loc; /* Location to open group */ + H5G_t *grp = NULL; /* New group opend */ + void *ret_value; + + 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 group */ + if((grp = H5G__open_name(&loc, name, gapl_id, dxpl_id)) == 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 certain data about a group + * + * Return: Success: 0 + * Failure: -1 + * + * Programmer: Mohamad Chaarawi + * February, 2012 + * + *------------------------------------------------------------------------- + */ +static herr_t +H5VL_native_group_get(void *obj, H5VL_group_get_t get_type, hid_t dxpl_id, void 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 *grp_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, grp_info, dxpl_id) < 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 */ + H5G_loc_t grp_loc; /* Location used to open group */ + H5G_name_t grp_path; /* Opened object group hier. path */ + H5O_loc_t grp_oloc; /* Opened object object location */ + + /* Set up opened group location to fill in */ + grp_loc.oloc = &grp_oloc; + grp_loc.path = &grp_path; + H5G_loc_reset(&grp_loc); + + /* Find the group object */ + if(H5G_loc_find(&loc, loc_params.loc_data.loc_by_name.name, &grp_loc/*out*/, + loc_params.loc_data.loc_by_name.lapl_id, dxpl_id) < 0) + HGOTO_ERROR(H5E_SYM, H5E_NOTFOUND, FAIL, "group not found") + + /* Retrieve the group's information */ + if(H5G__obj_info(grp_loc.oloc, grp_info/*out*/, dxpl_id) < 0) { + H5G_loc_free(&grp_loc); + HGOTO_ERROR(H5E_SYM, H5E_CANTGET, FAIL, "can't retrieve group info") + } + + /* Release the object location */ + if(H5G_loc_free(&grp_loc) < 0) + HDONE_ERROR(H5E_SYM, H5E_CANTRELEASE, FAIL, "can't free location") + } + else if(loc_params.type == H5VL_OBJECT_BY_IDX) { /* H5Gget_info_by_idx */ + H5G_loc_t grp_loc; /* Location used to open group */ + H5G_name_t grp_path; /* Opened object group hier. path */ + H5O_loc_t grp_oloc; /* Opened object object location */ + + /* Set up opened group location to fill in */ + grp_loc.oloc = &grp_oloc; + grp_loc.path = &grp_path; + H5G_loc_reset(&grp_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, &grp_loc/*out*/, + loc_params.loc_data.loc_by_idx.lapl_id, + dxpl_id) < 0) + HGOTO_ERROR(H5E_SYM, H5E_NOTFOUND, FAIL, "group not found") + + /* Retrieve the group's information */ + if(H5G__obj_info(grp_loc.oloc, grp_info/*out*/, dxpl_id) < 0) { + H5G_loc_free(&grp_loc); + HGOTO_ERROR(H5E_SYM, H5E_CANTGET, FAIL, "can't retrieve group info") + } + + /* Release the object location */ + if(H5G_loc_free(&grp_loc) < 0) + HDONE_ERROR(H5E_SYM, H5E_CANTRELEASE, FAIL, "can't free location") + } + 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_close + * + * Purpose: Closes a group. + * + * Return: Success: 0 + * Failure: -1, group not closed. + * + * Programmer: Mohamad Chaarawi + * March, 2012 + * + *------------------------------------------------------------------------- + */ +static herr_t +H5VL_native_group_close(void *grp, hid_t UNUSED dxpl_id, void 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 lapl_id, hid_t dxpl_id, void 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, lapl_id, dxpl_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, + lapl_id, dxpl_id) < 0) + HGOTO_ERROR(H5E_LINK, 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, lapl_id, dxpl_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, lapl_id, dxpl_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 lapl_id, hid_t dxpl_id, void 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, lapl_id, dxpl_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 lapl_id, hid_t dxpl_id, void 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, lapl_id, dxpl_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 dxpl_id, void 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, + loc_params.loc_data.loc_by_name.lapl_id, dxpl_id) < 0) + HGOTO_ERROR(H5E_SYM, H5E_NOTFOUND, FAIL, "unable to get link info") + } + else if(loc_params.type == H5VL_OBJECT_BY_IDX) { /* H5Lget_info_by_idx */ + H5L_trav_gibi_t udata; /* User data for callback */ + + /* Set up user data for retrieving information */ + udata.idx_type = loc_params.loc_data.loc_by_idx.idx_type; + udata.order = loc_params.loc_data.loc_by_idx.order; + udata.n = loc_params.loc_data.loc_by_idx.n; + udata.dxpl_id = dxpl_id; + udata.linfo = linfo; + if(H5L_get_info_by_idx(&loc, loc_params.loc_data.loc_by_idx.name, &udata, + loc_params.loc_data.loc_by_idx.lapl_id, dxpl_id) < 0) + HGOTO_ERROR(H5E_SYM, H5E_NOTFOUND, FAIL, "unable to get link info") + } + else + HGOTO_ERROR(H5E_SYM, 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 *); + H5L_trav_gnbi_t udata; /* User data for callback */ + + /* Set up user data for callback */ + udata.idx_type = loc_params.loc_data.loc_by_idx.idx_type; + udata.order = loc_params.loc_data.loc_by_idx.order; + udata.n = loc_params.loc_data.loc_by_idx.n; + udata.dxpl_id = dxpl_id; + udata.name = name; + udata.size = size; + udata.name_len = -1; + + /* Get the link name */ + if(H5L_get_name_by_idx(&loc, loc_params.loc_data.loc_by_idx.name, &udata, + loc_params.loc_data.loc_by_idx.lapl_id, dxpl_id) < 0) + HGOTO_ERROR(H5E_SYM, H5E_NOTFOUND, FAIL, "unable to get link info") + + *ret = udata.name_len; + 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, + loc_params.loc_data.loc_by_name.lapl_id, dxpl_id) < 0) + HGOTO_ERROR(H5E_SYM, H5E_NOTFOUND, FAIL, "unable to get link value") + } + else if(loc_params.type == H5VL_OBJECT_BY_IDX) { /* H5Lget_val_by_idx */ + H5L_trav_gvbi_t udata; /* User data for callback */ + + /* Set up user data for retrieving information */ + udata.idx_type = loc_params.loc_data.loc_by_idx.idx_type; + udata.order = loc_params.loc_data.loc_by_idx.order; + udata.n = loc_params.loc_data.loc_by_idx.n; + udata.dxpl_id = dxpl_id; + udata.buf = buf; + udata.size = size; + + if(H5L_get_val_by_idx(&loc, loc_params.loc_data.loc_by_idx.name, &udata, + loc_params.loc_data.loc_by_idx.lapl_id, dxpl_id) < 0) + HGOTO_ERROR(H5E_SYM, H5E_NOTFOUND, FAIL, "unable to get link val") + } + else + HGOTO_ERROR(H5E_SYM, 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 dxpl_id, void 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, + loc_params.loc_data.loc_by_name.lapl_id, dxpl_id)) < 0) + HGOTO_ERROR(H5E_SYM, H5E_NOTFOUND, FAIL, "unable to specific link info") + break; + } + case H5VL_LINK_ITER: + { + hbool_t recursive = va_arg (arguments, hbool_t); + 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 *); + + if((ret_value = H5L_iterate(obj, loc_params, recursive, idx_type, order, + idx_p, op, op_data, dxpl_id)) < 0) + HGOTO_ERROR(H5E_SYM, H5E_BADITER, FAIL, "error iterating over links") + 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, + loc_params.loc_data.loc_by_name.lapl_id, dxpl_id) < 0) + HGOTO_ERROR(H5E_LINK, H5E_CANTDELETE, FAIL, "unable to delete link") + } + else if(loc_params.type == H5VL_OBJECT_BY_IDX) { /* H5Ldelete_by_idx */ + H5L_trav_rmbi_t udata; /* User data for callback */ + + /* Set up user data for unlink operation */ + udata.idx_type = loc_params.loc_data.loc_by_idx.idx_type; + udata.order = loc_params.loc_data.loc_by_idx.order; + udata.n = loc_params.loc_data.loc_by_idx.n; + udata.dxpl_id = dxpl_id; + + if(H5L_delete_by_idx(&loc, loc_params.loc_data.loc_by_idx.name, &udata, + loc_params.loc_data.loc_by_idx.lapl_id, dxpl_id) < 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 dxpl_id, void UNUSED **req) +{ + H5G_loc_t loc; + 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 */ + hbool_t loc_found = FALSE; /* Entry at 'name' found */ + hid_t temp_id = FAIL; + 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((temp_id = H5O_open_name(&loc, loc_params.loc_data.loc_by_name.name, + loc_params.loc_data.loc_by_name.lapl_id, TRUE)) < 0) + HGOTO_ERROR(H5E_SYM, H5E_CANTOPENOBJ, NULL, "unable to open object") + break; + } + case H5VL_OBJECT_BY_IDX: + { + /* 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*/, loc_params.loc_data.loc_by_idx.lapl_id, + dxpl_id) < 0) + HGOTO_ERROR(H5E_SYM, H5E_NOTFOUND, NULL, "group not found") + loc_found = TRUE; + + /* Open the object */ + if((temp_id = H5O_open_by_loc(&obj_loc, loc_params.loc_data.loc_by_idx.lapl_id, + dxpl_id, TRUE)) < 0) + HGOTO_ERROR(H5E_SYM, H5E_CANTOPENOBJ, NULL, "unable to open object") + break; + } + case H5VL_OBJECT_BY_ADDR: + { + if(!H5F_addr_defined(loc_params.loc_data.loc_by_addr.addr)) + HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, NULL, "no address supplied") + + /* Set up opened group location to fill in */ + obj_loc.oloc = &obj_oloc; + obj_loc.path = &obj_path; + H5G_loc_reset(&obj_loc); + obj_loc.oloc->addr = loc_params.loc_data.loc_by_addr.addr; + obj_loc.oloc->file = loc.oloc->file; + H5G_name_reset(obj_loc.path); /* objects opened through this routine don't have a path name */ + + /* Open the object */ + if((temp_id = H5O_open_by_loc(&obj_loc, H5P_LINK_ACCESS_DEFAULT, + dxpl_id, TRUE)) < 0) + HGOTO_ERROR(H5E_SYM, H5E_CANTOPENOBJ, NULL, "unable to open object") + break; + } + case H5VL_OBJECT_BY_REF: + { + 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, + dxpl_id, + loc_params.loc_data.loc_by_ref.ref_type, + loc_params.loc_data.loc_by_ref._ref, + TRUE)) < 0) + HGOTO_ERROR(H5E_REFERENCE, H5E_CANTINIT, NULL, "unable to dereference object") + break; + } + case H5VL_OBJECT_BY_SELF: + default: + HGOTO_ERROR(H5E_VOL, H5E_UNSUPPORTED, NULL, "unknown open parameters") + } + + *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") + +done: + /* Release the object location if we failed after copying it */ + if(temp_id < 0 && loc_found) + if(H5G_loc_free(&obj_loc) < 0) + HDONE_ERROR(H5E_SYM, H5E_CANTRELEASE, NULL, "can't free location") + 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 UNUSED dxpl_id, void 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 a file + * + * Return: Success: 0 + * Failure: -1 + * + * 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 dxpl_id, void 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 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, dxpl_id, ref)) == NULL) + HGOTO_ERROR(H5E_REFERENCE, H5E_CANTCREATE, FAIL, "unable to create dataspace") + + /* 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, dxpl_id, ref_type, ref, obj_type) < 0) + HGOTO_ERROR(H5E_REFERENCE, H5E_CANTINIT, 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, H5P_DEFAULT, dxpl_id, ref_type, ref, name, size)) < 0) + HGOTO_ERROR(H5E_REFERENCE, H5E_CANTINIT, 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 plugin specific operation for an objectibute + * + * Return: Success: 0 + * Failure: -1 + * + * Programmer: Mohamad Chaarawi + * April, 2012 + * + *------------------------------------------------------------------------- + */ +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 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, dxpl_id) < 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, + loc_params.loc_data.loc_by_name.lapl_id, dxpl_id)) < 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 *); + + /* 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, + H5P_LINK_ACCESS_DEFAULT, dxpl_id)) < 0) + HGOTO_ERROR(H5E_SYM, 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, loc_params.loc_data.loc_by_name.lapl_id, dxpl_id)) < 0) + HGOTO_ERROR(H5E_SYM, H5E_BADITER, FAIL, "object visitation failed") + } + else + HGOTO_ERROR(H5E_VOL, H5E_UNSUPPORTED, FAIL, "unknown object visit params"); + 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, dxpl_id) < 0) + HGOTO_ERROR(H5E_REFERENCE, H5E_CANTINIT, 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 plugin 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 dxpl_id, void 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 *); + + if(loc_params.type == H5VL_OBJECT_BY_SELF) { /* H5Oget_info */ + /* Retrieve the object's information */ + if(H5G_loc_info(&loc, ".", TRUE, obj_info, H5P_LINK_ACCESS_DEFAULT, + dxpl_id) < 0) + HGOTO_ERROR(H5E_SYM, 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, TRUE, obj_info, + loc_params.loc_data.loc_by_name.lapl_id, dxpl_id) < 0) + HGOTO_ERROR(H5E_SYM, 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*/, + loc_params.loc_data.loc_by_idx.lapl_id, + dxpl_id) < 0) + HGOTO_ERROR(H5E_SYM, H5E_NOTFOUND, FAIL, "group not found") + + /* Retrieve the object's information */ + if(H5O_get_info(obj_loc.oloc, dxpl_id, TRUE, obj_info) < 0) { + H5G_loc_free(&obj_loc); + HGOTO_ERROR(H5E_SYM, H5E_CANTGET, FAIL, "can't retrieve object info") + } + + /* Release the object location */ + if(H5G_loc_free(&obj_loc) < 0) + HDONE_ERROR(H5E_SYM, 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, + H5P_LINK_ACCESS_DEFAULT, dxpl_id)) < 0) + HGOTO_ERROR(H5E_SYM, 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, + loc_params.loc_data.loc_by_name.lapl_id, dxpl_id)) < 0) + HGOTO_ERROR(H5E_SYM, 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, H5P_LINK_ACCESS_DEFAULT, dxpl_id) < 0) + HGOTO_ERROR(H5E_SYM, 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, + loc_params.loc_data.loc_by_name.lapl_id, dxpl_id) < 0) + HGOTO_ERROR(H5E_SYM, 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() */ diff --git a/src/H5VLnative.h b/src/H5VLnative.h new file mode 100644 index 0000000..ae0e601 --- /dev/null +++ b/src/H5VLnative.h @@ -0,0 +1,39 @@ +/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * + * 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 files COPYING and Copyright.html. COPYING can be found at the root * + * of the source code distribution tree; Copyright.html can be found at the * + * root level of an installed copy of the electronic HDF5 document set and * + * is linked from the top-level documents page. It can also be found at * + * http://hdfgroup.org/HDF5/doc/Copyright.html. If you do not have * + * access to either file, you may request a copy from help@hdfgroup.org. * + * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ + +/* + * Programmer: Mohamad Chaarawi <chaarawi@hdfgroup.gov> + * January, 2012 + * + * Purpose: The public header file for the Native VOL plugin. + */ +#ifndef H5VLnative_H +#define H5VLnative_H + +#define H5VL_NATIVE (H5VL_native_init()) +#define HDF5_VOL_NATIVE_VERSION_1 1 /* Version number of Native VOL plugin */ + +#ifdef __cplusplus +extern "C" { +#endif + +H5_DLL hid_t H5VL_native_init(void); +H5_DLL herr_t H5Pset_fapl_native(hid_t fapl_id); + +#ifdef __cplusplus +} +#endif + +#endif diff --git a/src/H5VLpkg.h b/src/H5VLpkg.h new file mode 100644 index 0000000..1b1d7b7 --- /dev/null +++ b/src/H5VLpkg.h @@ -0,0 +1,65 @@ +/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * + * 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 files COPYING and Copyright.html. COPYING can be found at the root * + * of the source code distribution tree; Copyright.html can be found at the * + * root level of an installed copy of the electronic HDF5 document set and * + * is linked from the top-level documents page. It can also be found at * + * http://hdfgroup.org/HDF5/doc/Copyright.html. If you do not have * + * access to either file, you may request a copy from help@hdfgroup.org. * + * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ + +/* + * Programmer: Mohamad Chaarawi <chaarawi@hdfgroup.org> + * January, 2012 + * + * Purpose: This file contains declarations which are visible only within + * the H5VL package. Source files outside the H5VL package should + * include H5VLprivate.h instead. + */ +#ifndef H5VL_PACKAGE +#error "Do not include this file outside the H5VL package!" +#endif + +#ifndef _H5VLpkg_H +#define _H5VLpkg_H + +/* Get package's private header */ +#include "H5VLprivate.h" /* File drivers */ + +/* Other private headers needed by this file */ +#include "H5FLprivate.h" /* Free lists */ + +/**************************/ +/* Package Private Macros */ +/**************************/ + + +/****************************/ +/* Package Private Typedefs */ +/****************************/ + + +/*****************************/ +/* Package Private Variables */ +/*****************************/ + + +/******************************/ +/* Package Private Prototypes */ +/******************************/ + + +/* +H5_DLL haddr_t H5VL_alloc_real(H5VL_t *file, hid_t dxpl_id, H5VL_mem_t type, + hsize_t size, haddr_t *align_addr, hsize_t *align_size); +H5_DLL herr_t H5VL_free_real(H5VL_t *file, hid_t dxpl_id, H5VL_mem_t type, + haddr_t addr, hsize_t size); +*/ + +#endif /* _H5VLpkg_H */ + diff --git a/src/H5VLprivate.h b/src/H5VLprivate.h new file mode 100644 index 0000000..92e90d7 --- /dev/null +++ b/src/H5VLprivate.h @@ -0,0 +1,149 @@ +/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * + * 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 files COPYING and Copyright.html. COPYING can be found at the root * + * of the source code distribution tree; Copyright.html can be found at the * + * root level of an installed copy of the electronic HDF5 document set and * + * is linked from the top-level documents page. It can also be found at * + * http://hdfgroup.org/HDF5/doc/Copyright.html. If you do not have * + * access to either file, you may request a copy from help@hdfgroup.org. * + * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ + +/* + * Programmer: Mohamad Chaarawi <chaarawi@hdfgroup.gov> + * January, 2011 + */ +#ifndef _H5VLprivate_H +#define _H5VLprivate_H + +#include "H5VLpublic.h" + +/**************************/ +/* Library Private Macros */ +/**************************/ + +/****************************/ +/* Library Private Typedefs */ +/****************************/ + +#define H5_REQUEST_NULL NULL +#define H5_EVENT_STACK_NULL ((hid_t)-1) + +/* Internal struct to track VOL information with objects */ +typedef struct H5VL_t { + const H5VL_class_t *vol_cls; /* constant plugin class info */ + int nrefs; /* number of references by objects using this struct */ + hid_t vol_id; /* identifier for the VOL class */ +} H5VL_t; + +/* The internal vol object structure returned to the API */ +typedef struct H5VL_object_t { + void *vol_obj; /* pointer to object created by plugin */ + H5VL_t *vol_info; /* pointer to VOL info struct */ +} H5VL_object_t; + + + +/*****************************/ +/* Library Private Variables */ +/*****************************/ + +/******************************/ +/* Library Private Prototypes */ +/******************************/ + +/* Forward declarations for prototype arguments */ +struct H5P_genplist_t; +struct H5F_t; + +H5_DLL herr_t H5VL_init(void); +H5_DLL int H5VL_term_interface(void); +H5_DLL hid_t H5VL_register_id(H5I_type_t type, void *object, H5VL_t *vol_plugin, hbool_t app_ref); +H5_DLL herr_t H5VL_free_object(H5VL_object_t *obj); +H5_DLL hid_t H5VL_register(const void *cls, size_t size, hbool_t app_ref); +H5_DLL hid_t H5VL_object_register(void *obj, H5I_type_t obj_type, hid_t plugin_id, hbool_t app_ref); +H5_DLL ssize_t H5VL_get_plugin_name(hid_t id, char *name/*out*/, size_t size); +H5_DLL H5VL_object_t *H5VL_get_object(hid_t id); +H5_DLL void *H5VL_object(hid_t id); +H5_DLL void *H5VL_object_verify(hid_t id, H5I_type_t obj_type); +H5_DLL void *H5VL_plugin_object(H5VL_object_t *obj); + +H5_DLL void *H5VL_attr_create(void *obj, H5VL_loc_params_t loc_params, const H5VL_class_t *vol_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 *vol_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 *vol_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 *vol_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 *vol_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 *vol_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 *vol_cls, hid_t dxpl_id, void **req, ...); +H5_DLL herr_t H5VL_attr_close(void *attr, const H5VL_class_t *vol_cls, hid_t dxpl_id, void **req); + +H5_DLL void *H5VL_dataset_create(void *obj, H5VL_loc_params_t loc_params, const H5VL_class_t *vol_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 *vol_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 *vol_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 *vol_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 *vol_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 *vol_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 *vol_cls, hid_t dxpl_id, void **req, ...); +H5_DLL herr_t H5VL_dataset_close(void *dset, const H5VL_class_t *vol_cls, hid_t dxpl_id, void **req); + +H5_DLL void *H5VL_datatype_commit(void *obj, H5VL_loc_params_t loc_params, const H5VL_class_t *vol_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 *vol_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 *vol_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 *vol_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 *vol_cls, hid_t dxpl_id, void **req, ...); +H5_DLL herr_t H5VL_datatype_close(void *dt, const H5VL_class_t *vol_cls, hid_t dxpl_id, void **req); + +H5_DLL void *H5VL_file_create(const H5VL_class_t *vol_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 *vol_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 *vol_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 *vol_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 *vol_cls, hid_t dxpl_id, void **req, ...); +H5_DLL herr_t H5VL_file_close(void *file, const H5VL_class_t *vol_cls, hid_t dxpl_id, void **req); + +H5_DLL void *H5VL_group_create(void *obj, H5VL_loc_params_t loc_params, const H5VL_class_t *vol_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 *vol_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 *vol_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 *vol_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 *vol_cls, hid_t dxpl_id, void **req, ...); +H5_DLL herr_t H5VL_group_close(void *grp, const H5VL_class_t *vol_cls, hid_t dxpl_id, void **req); + +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 *vol_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 *vol_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 *vol_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 *vol_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 *vol_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 *vol_cls, hid_t dxpl_id, void **req, ...); + +H5_DLL void *H5VL_object_open(void *obj, H5VL_loc_params_t loc_params, const H5VL_class_t *vol_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 *vol_cls1, const char *src_name, + void *dst_obj, H5VL_loc_params_t loc_params2, const H5VL_class_t *vol_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 *vol_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 *vol_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 *vol_cls, hid_t dxpl_id, void **req, ...); + +H5_DLL herr_t H5VL_request_cancel(void **req, const H5VL_class_t *vol_cls, H5ES_status_t *status); +H5_DLL herr_t H5VL_request_test(void **req, const H5VL_class_t *vol_cls, H5ES_status_t *status); +H5_DLL herr_t H5VL_request_wait(void **req, const H5VL_class_t *vol_cls, H5ES_status_t *status); + +H5_DLL herr_t H5VL_fapl_open(struct H5P_genplist_t *plist, hid_t vol_id, const void *vol_info); +H5_DLL herr_t H5VL_fapl_copy(hid_t vol_id, const void *vol_info, void **copied_info); +H5_DLL herr_t H5VL_fapl_close(hid_t vol_id, void *vol_info); + +H5_DLL herr_t H5F_close_file(void *file); +H5_DLL herr_t H5A_close_attr(void *attr); +H5_DLL herr_t H5D_close_dataset(void *dset); +H5_DLL herr_t H5G_close_group(void *grp); +H5_DLL herr_t H5T_close_datatype(void *dt); + +H5_DLL hid_t H5VL_native_register(H5I_type_t type, void *obj, hbool_t app_ref); +H5_DLL herr_t H5VL_native_unregister(hid_t obj_id); +#endif /* _H5VLprivate_H */ diff --git a/src/H5VLpublic.h b/src/H5VLpublic.h new file mode 100644 index 0000000..220b6ed --- /dev/null +++ b/src/H5VLpublic.h @@ -0,0 +1,437 @@ +/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * + * 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 files COPYING and Copyright.html. COPYING can be found at the root * + * of the source code distribution tree; Copyright.html can be found at the * + * root level of an installed copy of the electronic HDF5 document set and * + * is linked from the top-level documents page. It can also be found at * + * http://hdfgroup.org/HDF5/doc/Copyright.html. If you do not have * + * access to either file, you may request a copy from help@hdfgroup.org. * + * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ + +/* + * Programmer: Mohamad Chaarawi <chaarawi@hdfgroup.org> + * January 23, 2012 + */ +#ifndef _H5VLpublic_H +#define _H5VLpublic_H + +#include <stdarg.h> + +#include "H5public.h" +#include "H5Apublic.h" /* Attributes */ +#include "H5ESpublic.h" /* Event Stack */ +#include "H5Fpublic.h" /* Files */ +#include "H5Lpublic.h" /* Links */ +#include "H5Opublic.h" /* Objects */ +#include "H5Rpublic.h" /* References */ + +/* Dataset creation property names */ +#define H5VL_PROP_DSET_TYPE_ID "dataset_type_id" +#define H5VL_PROP_DSET_SPACE_ID "dataset_space_id" +#define H5VL_PROP_DSET_LCPL_ID "dataset_lcpl_id" + +/* Attribute creation property names */ +#define H5VL_PROP_ATTR_TYPE_ID "attr_type_id" +#define H5VL_PROP_ATTR_SPACE_ID "attr_space_id" +#define H5VL_PROP_ATTR_LOC_PARAMS "attr_location" + +/* Link creation property names */ +#define H5VL_PROP_LINK_TARGET "target_location_object" +#define H5VL_PROP_LINK_TARGET_LOC_PARAMS "target_params" +#define H5VL_PROP_LINK_TARGET_NAME "target_name" +#define H5VL_PROP_LINK_TYPE "link type" +#define H5VL_PROP_LINK_UDATA "udata" +#define H5VL_PROP_LINK_UDATA_SIZE "udata size" + +/* Group creation property names */ +#define H5VL_PROP_GRP_LCPL_ID "group_lcpl_id" + +/* types for attribute GET callback */ +typedef enum H5VL_attr_get_t { + H5VL_ATTR_GET_ACPL, /* creation property list */ + H5VL_ATTR_GET_INFO, /* info */ + H5VL_ATTR_GET_NAME, /* access property list */ + H5VL_ATTR_GET_SPACE, /* dataspace */ + H5VL_ATTR_GET_STORAGE_SIZE, /* storage size */ + H5VL_ATTR_GET_TYPE /* datatype */ +} H5VL_attr_get_t; + +/* types for attribute SPECFIC callback */ +typedef enum H5VL_attr_specific_t { + H5VL_ATTR_DELETE, /* H5Adelete(_by_name/idx) */ + H5VL_ATTR_EXISTS, /* H5Aexists(_by_name) */ + H5VL_ATTR_ITER, /* H5Aiterate(_by_name) */ + H5VL_ATTR_RENAME /* H5Arename(_by_name) */ +} H5VL_attr_specific_t; + +/* types for dataset GET callback */ +typedef enum H5VL_dataset_get_t { + H5VL_DATASET_GET_DAPL, /* access property list */ + H5VL_DATASET_GET_DCPL, /* creation property list */ + H5VL_DATASET_GET_OFFSET, /* offset */ + H5VL_DATASET_GET_SPACE, /* dataspace */ + H5VL_DATASET_GET_SPACE_STATUS, /* space status */ + H5VL_DATASET_GET_STORAGE_SIZE, /* storage size */ + H5VL_DATASET_GET_TYPE /* datatype */ +} H5VL_dataset_get_t; + +/* types for dataset SPECFIC callback */ +typedef enum H5VL_dataset_specific_t { + H5VL_DATASET_SET_EXTENT /* H5Dset_extent */ +} H5VL_dataset_specific_t; + +/* types for datatype GET callback */ +typedef enum H5VL_datatype_get_t { + H5VL_DATATYPE_GET_BINARY, /* get serialized form of transient type */ + H5VL_DATATYPE_GET_TCPL /* datatype creation property list */ +} H5VL_datatype_get_t; + +/* types for datatype SPECFIC callback */ +typedef enum H5VL_datatype_specific_t { + H5VL_DATATYPE_SPECIFIC_INVALID +} H5VL_datatype_specific_t; + +/* types for file GET callback */ +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_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_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_MOUNT, /* Mount a file */ + H5VL_FILE_UNMOUNT /* Un-Mount a file */ +} H5VL_file_specific_t; + +/* types for group GET callback */ +typedef enum H5VL_group_get_t { + H5VL_GROUP_GET_GCPL, /* group creation property list */ + H5VL_GROUP_GET_INFO /* group info */ +} H5VL_group_get_t; + +/* types for group SPECFIC callback */ +typedef enum H5VL_group_specific_t { + H5VL_GROUP_SPECIFIC_INVALID +} H5VL_group_specific_t; + +/* link create types for VOL */ +typedef enum H5VL_link_create_type_t { + H5VL_LINK_CREATE_HARD, + H5VL_LINK_CREATE_SOFT, + H5VL_LINK_CREATE_UD +} H5VL_link_create_type_t; + +/* types for link GET callback */ +typedef enum H5VL_link_get_t { + H5VL_LINK_GET_INFO, /* link info */ + H5VL_LINK_GET_NAME, /* link name */ + H5VL_LINK_GET_VAL /* link value */ +} H5VL_link_get_t; + +/* types for link SPECIFIC callback */ +typedef enum H5VL_link_specific_t { + H5VL_LINK_DELETE, /* H5Ldelete(_by_idx) */ + H5VL_LINK_EXISTS, /* link existence */ + H5VL_LINK_ITER /* H5Literate/visit(_by_name) */ +} H5VL_link_specific_t; + +/* types for object GET callback */ +typedef enum H5VL_object_get_t { + H5VL_REF_GET_NAME, /* object name */ + H5VL_REF_GET_REGION, /* dataspace of region */ + H5VL_REF_GET_TYPE /* type of object */ +} 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_specific_t; + +/* types for different ways that objects are located in an HDF5 container */ +typedef enum H5VL_loc_type_t { + H5VL_OBJECT_BY_SELF, + H5VL_OBJECT_BY_NAME, + H5VL_OBJECT_BY_IDX, + H5VL_OBJECT_BY_ADDR, + H5VL_OBJECT_BY_REF +} H5VL_loc_type_t; + +struct H5VL_loc_by_name { + const char *name; + hid_t lapl_id; +}; + +struct H5VL_loc_by_idx { + const char *name; + H5_index_t idx_type; + H5_iter_order_t order; + hsize_t n; + hid_t lapl_id; +}; + +struct H5VL_loc_by_addr { + haddr_t addr; +}; + +struct H5VL_loc_by_ref { + H5R_type_t ref_type; + const void *_ref; + hid_t lapl_id; +}; + +/* Structure to hold parameters for object locations. + either: BY_ID, BY_NAME, BY_IDX, BY_ADDR, BY_REF */ +typedef struct H5VL_loc_params_t { + H5I_type_t obj_type; + H5VL_loc_type_t type; + union{ + struct H5VL_loc_by_name loc_by_name; + struct H5VL_loc_by_idx loc_by_idx; + struct H5VL_loc_by_addr loc_by_addr; + struct H5VL_loc_by_ref loc_by_ref; + } loc_data; +} H5VL_loc_params_t; + +#define H5VL_VOL_DEFAULT 0 /* Default VOL plugin value */ + +/* H5A routines */ +typedef struct H5VL_attr_class_t { + void *(*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); + void *(*open)(void *obj, 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, + 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); +} 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, + 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, + 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); + herr_t (*write)(void *dset, hid_t mem_type_id, hid_t mem_space_id, hid_t file_space_id, + hid_t xfer_plist_id, const void * buf, void **req); + herr_t (*get)(void *obj, H5VL_dataset_get_t get_type, hid_t dxpl_id, void **req, va_list arguments); + herr_t (*specific)(void *obj, H5VL_dataset_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 *dset, hid_t dxpl_id, void **req); +} 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, + 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, + 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, + 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 *dt, hid_t dxpl_id, void **req); +} H5VL_datatype_class_t; + +/* H5F routines */ +typedef struct H5VL_file_class_t { + void *(*create)(const char *name, unsigned flags, hid_t fcpl_id, + hid_t fapl_id, hid_t dxpl_id, void **req); + void *(*open)(const char *name, unsigned flags, hid_t fapl_id, hid_t dxpl_id, void **req); + herr_t (*get)(void *obj, H5VL_file_get_t get_type, hid_t dxpl_id, void **req, va_list arguments); + herr_t (*specific)(void *obj, H5VL_file_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 *file, hid_t dxpl_id, void **req); +} 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, + 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, + 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, + 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 *grp, hid_t dxpl_id, void **req); +} 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, + 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, + 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, + 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, + 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, + 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, + 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, + 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, + 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, + 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; + +/* enum value to identify the class of a VOL plugin (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 */ +typedef struct H5VL_class_t { + unsigned int version; /* Class version # */ + H5VL_class_value_t value; /* value to identify plugin */ + const char *name; /* Plugin name */ + 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 */ + + /* Data Model */ + H5VL_attr_class_t attr_cls; /* attribute class callbacks */ + H5VL_dataset_class_t dataset_cls; /* dataset class callbacks */ + H5VL_datatype_class_t datatype_cls; /* datatype class callbacks */ + H5VL_file_class_t file_cls; /* file class callbacks */ + H5VL_group_class_t group_cls; /* group class callbacks */ + H5VL_link_class_t link_cls; /* link class callbacks */ + H5VL_object_class_t object_cls; /* object class callbacks */ + + /* Services */ + H5VL_async_class_t async_cls; /* asynchronous class callbacks */ + herr_t (*optional)(void *obj, hid_t dxpl_id, void **req, va_list arguments); /* Optional callback */ +} H5VL_class_t; + +#ifdef __cplusplus +extern "C" { +#endif + +H5_DLL void *H5VLattr_create(void *obj, H5VL_loc_params_t loc_params, hid_t plugin_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 plugin_id, const char *name, hid_t aapl_id, hid_t dxpl_id, void **req); +H5_DLL herr_t H5VLattr_read(void *attr, hid_t plugin_id, hid_t dtype_id, void *buf, hid_t dxpl_id, void **req); +H5_DLL herr_t H5VLattr_write(void *attr, hid_t plugin_id, hid_t dtype_id, const void *buf, hid_t dxpl_id, void **req); +H5_DLL herr_t H5VLattr_get(void *obj, hid_t plugin_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 plugin_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 plugin_id, hid_t dxpl_id, void **req, va_list arguments); +H5_DLL herr_t H5VLattr_close(void *attr, hid_t plugin_id, hid_t dxpl_id, void **req); + +H5_DLL void *H5VLdataset_create(void *obj, H5VL_loc_params_t loc_params, hid_t plugin_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 plugin_id, const char *name, hid_t dapl_id, hid_t dxpl_id, void **req); +H5_DLL herr_t H5VLdataset_read(void *dset, hid_t plugin_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 plugin_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 plugin_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 plugin_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 plugin_id, hid_t dxpl_id, void **req, va_list arguments); +H5_DLL herr_t H5VLdataset_close(void *dset, hid_t plugin_id, hid_t dxpl_id, void **req); + +H5_DLL void *H5VLdatatype_commit(void *obj, H5VL_loc_params_t loc_params, hid_t plugin_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 plugin_id, const char *name, hid_t tapl_id, hid_t dxpl_id, void **req); +H5_DLL herr_t H5VLdatatype_get(void *dt, hid_t plugin_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 plugin_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 plugin_id, hid_t dxpl_id, void **req, va_list arguments); +H5_DLL herr_t H5VLdatatype_close(void *dt, hid_t plugin_id, hid_t dxpl_id, void **req); + +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 plugin_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 plugin_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 plugin_id, hid_t dxpl_id, void **req, va_list arguments); +H5_DLL herr_t H5VLfile_close(void *file, hid_t plugin_id, hid_t dxpl_id, void **req); + +H5_DLL void *H5VLgroup_create(void *obj, H5VL_loc_params_t loc_params, hid_t plugin_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 plugin_id, const char *name, hid_t gapl_id, hid_t dxpl_id, void **req); +H5_DLL herr_t H5VLgroup_get(void *obj, hid_t plugin_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 plugin_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 plugin_id, hid_t dxpl_id, void **req, va_list arguments); +H5_DLL herr_t H5VLgroup_close(void *grp, hid_t plugin_id, hid_t dxpl_id, void **req); + +H5_DLL herr_t H5VLlink_create(H5VL_link_create_type_t create_type, void *obj, H5VL_loc_params_t loc_params, hid_t plugin_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 plugin_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 plugin_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 plugin_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 plugin_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 plugin_id, hid_t dxpl_id, void **req, va_list arguments); + +H5_DLL void *H5VLobject_open(void *obj, H5VL_loc_params_t loc_params, hid_t plugin_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 plugin_id1, const char *src_name, + void *dst_obj, H5VL_loc_params_t loc_params2, hid_t plugin_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 plugin_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 plugin_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 plugin_id, hid_t dxpl_id, void **req, va_list arguments); + +H5_DLL herr_t H5VLrequest_cancel(void **req, hid_t plugin_id, H5ES_status_t *status); +H5_DLL herr_t H5VLrequest_test(void **req, hid_t plugin_id, H5ES_status_t *status); +H5_DLL herr_t H5VLrequest_wait(void **req, hid_t plugin_id, H5ES_status_t *status); + +/* Function prototypes */ +H5_DLL herr_t H5VLinitialize(hid_t plugin_id, hid_t vipl_id); +H5_DLL herr_t H5VLterminate(hid_t plugin_id, hid_t vtpl_id); +H5_DLL hid_t H5VLget_plugin_id(const char *name); +H5_DLL herr_t H5VLclose(hid_t plugin_id); +H5_DLL hid_t H5VLregister(const H5VL_class_t *cls); +H5_DLL hid_t H5VLregister_by_name(const char *plugin_name); +H5_DLL herr_t H5VLunregister(hid_t plugin_id); +H5_DLL htri_t H5VLis_registered(const char *name); +H5_DLL ssize_t H5VLget_plugin_name(hid_t id, char *name/*out*/, size_t size); +H5_DLL hid_t H5VLobject_register(void *obj, H5I_type_t obj_type, hid_t plugin_id); +H5_DLL herr_t H5VLget_object(hid_t obj_id, void **obj); +#if 0 +H5_DLL herr_t H5VLioctl(hid_t loc_id or vol_id, <class enum>, ...); +#endif + +#ifdef __cplusplus +} +#endif + +#endif /* _H5VLpublic_H */ @@ -668,8 +668,8 @@ H5Zfilter_avail(H5Z_filter_t id) else if(ret_value == FALSE) { const H5Z_class2_t *filter_info; - if(NULL != (filter_info = (const H5Z_class2_t *)H5PL_load(H5PL_TYPE_FILTER, (int)id))) - ret_value = TRUE; + if(NULL != (filter_info = (const H5Z_class2_t *)H5PL_load(H5PL_TYPE_FILTER, (int)id, NULL))) + ret_value = TRUE; } /* end if */ done: @@ -1330,20 +1330,20 @@ H5Z_pipeline(const H5O_pline_t *pline, unsigned flags, */ if((fclass_idx = H5Z_find_idx(pline->filter[idx].id)) < 0) { hbool_t issue_error = FALSE; - const H5Z_class2_t *filter_info; - - /* Try loading the filter */ - if(NULL != (filter_info = (const H5Z_class2_t *)H5PL_load(H5PL_TYPE_FILTER, (int)(pline->filter[idx].id)))) { - /* Register the filter we loaded */ - if(H5Z_register(filter_info) < 0) - HGOTO_ERROR(H5E_PLINE, H5E_CANTINIT, FAIL, "unable to register filter") - - /* Search in the table of registered filters again to find the dynamic filter just loaded and registered */ - if((fclass_idx = H5Z_find_idx(pline->filter[idx].id)) < 0) - issue_error = TRUE; - } /* end if */ - else - issue_error = TRUE; + const H5Z_class2_t *filter_info; + + /* Try loading the filter */ + if(NULL != (filter_info = (const H5Z_class2_t *)H5PL_load(H5PL_TYPE_FILTER, (int)(pline->filter[idx].id), NULL))) { + /* Register the filter we loaded */ + if(H5Z_register(filter_info) < 0) + HGOTO_ERROR(H5E_PLINE, H5E_CANTINIT, FAIL, "unable to register filter") + + /* Search in the table of registered filters again to find the dynamic filter just loaded and registered */ + if((fclass_idx = H5Z_find_idx(pline->filter[idx].id)) < 0) + issue_error = TRUE; + } /* end if */ + else + issue_error = TRUE; /* Check for error */ if(issue_error) { diff --git a/src/H5err.txt b/src/H5err.txt index 0917909..e7ff958 100644 --- a/src/H5err.txt +++ b/src/H5err.txt @@ -68,6 +68,7 @@ MAJOR, H5E_PLINE, Data filters MAJOR, H5E_EFL, External file list MAJOR, H5E_REFERENCE, References MAJOR, H5E_VFL, Virtual File Layer +MAJOR, H5E_VOL, Virtual Object Layer MAJOR, H5E_TST, Ternary Search Trees MAJOR, H5E_RS, Reference Counted Strings MAJOR, H5E_ERROR, Error API diff --git a/src/H5private.h b/src/H5private.h index f971504..5eae84b 100644 --- a/src/H5private.h +++ b/src/H5private.h @@ -1576,6 +1576,7 @@ typedef enum { H5_PKG_S, /*Data spaces */ H5_PKG_T, /*Data types */ H5_PKG_V, /*Vector functions */ + H5_PKG_VL, /*VOL functions */ H5_PKG_Z, /*Raw data filters */ H5_NPKGS /*Must be last */ } H5_pkg_t; @@ -1652,6 +1653,10 @@ extern char H5libhdf5_settings[]; /* embedded library information */ CALLTIME=H5_trace(NULL,FUNC,T,#A0,A0,#A1,A1,#A2,A2,#A3,A3, \ #A4,A4,#A5,A5,#A6,A6,#A7,A7,#A8,A8,#A9,A9, \ #A10,A10) +#define H5TRACE12(R,T,A0,A1,A2,A3,A4,A5,A6,A7,A8,A9,A10,A11) RTYPE=R; \ + CALLTIME=H5_trace(NULL,FUNC,T,#A0,A0,#A1,A1,#A2,A2,#A3,A3, \ + #A4,A4,#A5,A5,#A6,A6,#A7,A7,#A8,A8,#A9,A9, \ + #A10,A10,#A11,A11) #define H5TRACE_RETURN(V) if (RTYPE) { \ H5_trace(&CALLTIME,FUNC,RTYPE,NULL,V); \ RTYPE=NULL; \ @@ -1670,6 +1675,7 @@ extern char H5libhdf5_settings[]; /* embedded library information */ #define H5TRACE9(R,T,A0,A1,A2,A3,A4,A5,A6,A7,A8) /*void*/ #define H5TRACE10(R,T,A0,A1,A2,A3,A4,A5,A6,A7,A8,A9) /*void*/ #define H5TRACE11(R,T,A0,A1,A2,A3,A4,A5,A6,A7,A8,A9,A10) /*void*/ +#define H5TRACE12(R,T,A0,A1,A2,A3,A4,A5,A6,A7,A8,A9,A10,A11) /*void*/ #define H5TRACE_RETURN(V) /*void*/ #endif diff --git a/src/H5trace.c b/src/H5trace.c index 28b09f0..ddf376c 100644 --- a/src/H5trace.c +++ b/src/H5trace.c @@ -767,6 +767,37 @@ H5_trace(const double *returning, const char *func, const char *type, ...) } /* end else */ break; + case 's': + if(ptr) { + if(vp) + fprintf(out, "0x%lx", (unsigned long)vp); + else + fprintf(out, "NULL"); + } /* end if */ + else { + H5ES_status_t status = (H5ES_status_t)va_arg(ap, int); + + switch(status) { + case H5ES_STATUS_IN_PROGRESS: + fprintf(out, "H5ES_STATUS_IN_PROGRESS"); + break; + case H5ES_STATUS_SUCCEED: + fprintf(out, "H5ES_STATUS_SUCCEED"); + break; + case H5ES_STATUS_FAIL: + fprintf(out, "H5ES_STATUS_FAIL"); + break; + case H5ES_STATUS_CANCEL: + fprintf(out, "H5ES_STATUS_CANCEL"); + break; + + default: + fprintf(out, "%ld", (long)status); + break; + } /* end switch */ + } /* end else */ + break; + default: fprintf(out, "BADTYPE(E%c)", type[1]); goto error; @@ -1247,6 +1278,10 @@ H5_trace(const double *returning, const char *func, const char *type, ...) fprintf(out, "%ld (file driver)", (long)obj); break; + case H5I_VOL: + fprintf(out, "%ld (VOL plugin)", (long)obj); + break; + case H5I_GENPROP_CLS: fprintf(out, "%ld (genprop class)", (long)obj); break; @@ -1428,6 +1463,10 @@ H5_trace(const double *returning, const char *func, const char *type, ...) fprintf(out, "H5I_VFL"); break; + case H5I_VOL: + fprintf(out, "H5I_VOL"); + break; + case H5I_GENPROP_CLS: fprintf(out, "H5I_GENPROP_CLS"); break; @@ -2382,6 +2421,418 @@ H5_trace(const double *returning, const char *func, const char *type, ...) } /* end switch */ break; + case 'V': + switch(type[1]) { + case 'a': + if(ptr) { + if(vp) + fprintf (out, "0x%lx", (unsigned long)vp); + else + fprintf(out, "NULL"); + } /* end if */ + else { + H5VL_attr_get_t get = (H5VL_attr_get_t)va_arg(ap, int); + + switch(get) { + case H5VL_ATTR_GET_SPACE: + fprintf(out, "H5VL_ATTR_GET_SPACE"); + break; + case H5VL_ATTR_GET_TYPE: + fprintf(out, "H5VL_ATTR_GET_TYPE"); + break; + case H5VL_ATTR_GET_ACPL: + fprintf(out, "H5VL_ATTR_GET_ACPL"); + break; + case H5VL_ATTR_GET_NAME: + fprintf(out, "H5VL_ATTR_GET_NAME"); + break; + case H5VL_ATTR_GET_STORAGE_SIZE: + fprintf(out, "H5VL_ATTR_GET_STORAGE_SIZE"); + break; + case H5VL_ATTR_GET_INFO: + fprintf(out, "H5VL_ATTR_GET_INFO"); + break; + default: + fprintf(out, "%ld", (long)get); + break; + } /* end switch */ + } /* end else */ + break; + case 'b': + if(ptr) { + if(vp) + fprintf (out, "0x%lx", (unsigned long)vp); + else + fprintf(out, "NULL"); + } /* end if */ + else { + H5VL_attr_specific_t specific = (H5VL_attr_specific_t)va_arg(ap, int); + + switch(specific) { + case H5VL_ATTR_DELETE: + fprintf(out, "H5VL_ATTR_DELETE"); + break; + case H5VL_ATTR_EXISTS: + fprintf(out, "H5VL_ATTR_EXISTS"); + break; + case H5VL_ATTR_ITER: + fprintf(out, "H5VL_ATTR_ITER"); + break; + case H5VL_ATTR_RENAME: + fprintf(out, "H5VL_ATTR_RENAME"); + break; + default: + fprintf(out, "%ld", (long)specific); + break; + } /* end switch */ + } /* end else */ + break; + case 'c': + if(ptr) { + if(vp) + fprintf (out, "0x%lx", (unsigned long)vp); + else + fprintf(out, "NULL"); + } /* end if */ + else { + H5VL_dataset_get_t get = (H5VL_dataset_get_t)va_arg(ap, int); + + switch(get) { + case H5VL_DATASET_GET_SPACE: + fprintf(out, "H5VL_DATASET_GET_SPACE"); + break; + case H5VL_DATASET_GET_SPACE_STATUS: + fprintf(out, "H5VL_DATASET_GET_SPACE_STATUS"); + break; + case H5VL_DATASET_GET_TYPE: + fprintf(out, "H5VL_DATASET_GET_TYPE"); + break; + case H5VL_DATASET_GET_DCPL: + fprintf(out, "H5VL_DATASET_GET_DCPL"); + break; + case H5VL_DATASET_GET_DAPL: + fprintf(out, "H5VL_DATASET_GET_DAPL"); + break; + case H5VL_DATASET_GET_STORAGE_SIZE: + fprintf(out, "H5VL_DATASET_GET_STORAGE_SIZE"); + break; + case H5VL_DATASET_GET_OFFSET: + fprintf(out, "H5VL_DATASET_GET_OFFSET"); + break; + default: + fprintf(out, "%ld", (long)get); + break; + } /* end switch */ + } /* end else */ + break; + case 'd': + if(ptr) { + if(vp) + fprintf (out, "0x%lx", (unsigned long)vp); + else + fprintf(out, "NULL"); + } /* end if */ + else { + H5VL_dataset_specific_t specific = (H5VL_dataset_specific_t)va_arg(ap, int); + + switch(specific) { + case H5VL_DATASET_SET_EXTENT: + fprintf(out, "H5VL_DATASET_SPECIFIC_SPACE"); + break; + default: + fprintf(out, "%ld", (long)specific); + break; + } /* end switch */ + } /* end else */ + break; + case 'e': + if(ptr) { + if(vp) + fprintf (out, "0x%lx", (unsigned long)vp); + else + fprintf(out, "NULL"); + } /* end if */ + else { + H5VL_datatype_get_t get = (H5VL_datatype_get_t)va_arg(ap, int); + + switch(get) { + case H5VL_DATATYPE_GET_BINARY: + fprintf(out, "H5VL_DATATYPE_GET_BINARY"); + break; + case H5VL_DATATYPE_GET_TCPL: + fprintf(out, "H5VL_DATATYPE_GET_TCPL"); + break; + default: + fprintf(out, "%ld", (long)get); + break; + } /* end switch */ + } /* end else */ + break; + case 'f': + if(ptr) { + if(vp) + fprintf (out, "0x%lx", (unsigned long)vp); + else + fprintf(out, "NULL"); + } /* end if */ + else { + H5VL_datatype_specific_t specific = (H5VL_datatype_specific_t)va_arg(ap, int); + + switch(specific) { + case H5VL_DATATYPE_SPECIFIC_INVALID: + default: + fprintf(out, "%ld", (long)specific); + break; + } /* end switch */ + } /* end else */ + break; + case 'g': + if(ptr) { + if(vp) + fprintf (out, "0x%lx", (unsigned long)vp); + else + fprintf(out, "NULL"); + } /* end if */ + else { + H5VL_file_get_t get = (H5VL_file_get_t)va_arg(ap, int); + + switch(get) { + case H5VL_FILE_GET_FAPL: + fprintf(out, "H5VL_FILE_GET_FAPL"); + break; + case H5VL_FILE_GET_FCPL: + fprintf(out, "H5VL_FILE_GET_FCPL"); + break; + case H5VL_FILE_GET_INTENT: + fprintf(out, "H5VL_FILE_GET_INTENT"); + break; + case H5VL_FILE_GET_NAME: + fprintf(out, "H5VL_FILE_GET_NAME"); + break; + case H5VL_FILE_GET_OBJ_COUNT: + fprintf(out, "H5VL_FILE_GET_OBJ_COUNT"); + break; + case H5VL_FILE_GET_OBJ_IDS: + fprintf(out, "H5VL_FILE_GET_OBJ_IDS"); + break; + case H5VL_OBJECT_GET_FILE: + fprintf(out, "H5VL_OBJECT_GET_FILE"); + break; + default: + fprintf(out, "%ld", (long)get); + break; + } /* end switch */ + } /* end else */ + break; + case 'h': + if(ptr) { + if(vp) + fprintf (out, "0x%lx", (unsigned long)vp); + else + fprintf(out, "NULL"); + } /* end if */ + else { + H5VL_file_specific_t specific = (H5VL_file_specific_t)va_arg(ap, int); + + switch(specific) { + case H5VL_FILE_FLUSH: + fprintf(out, "H5VL_FILE_FLUSH"); + break; + case H5VL_FILE_MOUNT: + fprintf(out, "H5VL_FILE_MOUNT"); + break; + case H5VL_FILE_UNMOUNT: + fprintf(out, "H5VL_FILE_UNMOUNT"); + break; + case H5VL_FILE_IS_ACCESSIBLE: + fprintf(out, "H5VL_FILE_IS_ACCESSIBLE"); + break; + default: + fprintf(out, "%ld", (long)specific); + break; + } /* end switch */ + } /* end else */ + break; + case 'i': + if(ptr) { + if(vp) + fprintf (out, "0x%lx", (unsigned long)vp); + else + fprintf(out, "NULL"); + } /* end if */ + else { + H5VL_group_get_t get = (H5VL_group_get_t)va_arg(ap, int); + + switch(get) { + case H5VL_GROUP_GET_GCPL: + fprintf(out, "H5VL_GROUP_GET_GCPL"); + break; + case H5VL_GROUP_GET_INFO: + fprintf(out, "H5VL_GROUP_GET_INFO"); + break; + default: + fprintf(out, "%ld", (long)get); + break; + } /* end switch */ + } /* end else */ + break; + case 'j': + if(ptr) { + if(vp) + fprintf (out, "0x%lx", (unsigned long)vp); + else + fprintf(out, "NULL"); + } /* end if */ + else { + H5VL_group_specific_t specific = (H5VL_group_specific_t)va_arg(ap, int); + + switch(specific) { + case H5VL_GROUP_SPECIFIC_INVALID: + default: + fprintf(out, "%ld", (long)specific); + break; + } /* end switch */ + } /* end else */ + break; + case 'k': + if(ptr) { + if(vp) + fprintf (out, "0x%lx", (unsigned long)vp); + else + fprintf(out, "NULL"); + } /* end if */ + else { + H5VL_link_create_type_t create = (H5VL_link_create_type_t)va_arg(ap, int); + + switch(create) { + case H5VL_LINK_CREATE_HARD: + fprintf(out, "H5VL_LINK_CREATE_HARD"); + break; + case H5VL_LINK_CREATE_SOFT: + fprintf(out, "H5VL_LINK_CREATE_SOFT"); + break; + case H5VL_LINK_CREATE_UD: + fprintf(out, "H5VL_LINK_CREATE_UD"); + break; + default: + fprintf(out, "%ld", (long)create); + break; + } /* end switch */ + } /* end else */ + break; + case 'l': + if(ptr) { + if(vp) + fprintf (out, "0x%lx", (unsigned long)vp); + else + fprintf(out, "NULL"); + } /* end if */ + else { + H5VL_link_get_t get = (H5VL_link_get_t)va_arg(ap, int); + + switch(get) { + case H5VL_LINK_GET_INFO: + fprintf(out, "H5VL_LINK_GET_INFO"); + break; + case H5VL_LINK_GET_NAME: + fprintf(out, "H5VL_LINK_GET_NAME"); + break; + case H5VL_LINK_GET_VAL: + fprintf(out, "H5VL_LINK_GET_VAL"); + break; + default: + fprintf(out, "%ld", (long)get); + break; + } /* end switch */ + } /* end else */ + break; + case 'm': + if(ptr) { + if(vp) + fprintf (out, "0x%lx", (unsigned long)vp); + else + fprintf(out, "NULL"); + } /* end if */ + else { + H5VL_link_specific_t specific = (H5VL_link_specific_t)va_arg(ap, int); + + switch(specific) { + case H5VL_LINK_DELETE: + fprintf(out, "H5VL_LINK_DELETE"); + break; + case H5VL_LINK_EXISTS: + fprintf(out, "H5VL_LINK_EXISTS"); + break; + case H5VL_LINK_ITER: + fprintf(out, "H5VL_LINK_ITER"); + break; + default: + fprintf(out, "%ld", (long)specific); + break; + } /* end switch */ + } /* end else */ + break; + case 'n': + if(ptr) { + if(vp) + fprintf (out, "0x%lx", (unsigned long)vp); + else + fprintf(out, "NULL"); + } /* end if */ + else { + H5VL_object_get_t get = (H5VL_object_get_t)va_arg(ap, int); + + switch(get) { + case H5VL_REF_GET_REGION: + fprintf(out, "H5VL_REF_GET_REGION"); + break; + case H5VL_REF_GET_TYPE: + fprintf(out, "H5VL_REF_GET_TYPE"); + break; + case H5VL_REF_GET_NAME: + fprintf(out, "H5VL_REF_GET_NAME"); + break; + default: + fprintf(out, "%ld", (long)get); + break; + } /* end switch */ + } /* end else */ + break; + case 'o': + if(ptr) { + if(vp) + fprintf (out, "0x%lx", (unsigned long)vp); + else + fprintf(out, "NULL"); + } /* end if */ + else { + H5VL_object_specific_t specific = (H5VL_object_specific_t)va_arg(ap, int); + + switch(specific) { + case H5VL_OBJECT_CHANGE_REF_COUNT: + fprintf(out, "H5VL_OBJECT_CHANGE_REF_COUNT"); + break; + case H5VL_OBJECT_EXISTS: + fprintf(out, "H5VL_OBJECT_EXISTS"); + break; + case H5VL_OBJECT_VISIT: + fprintf(out, "H5VL_OBJECT_VISIT"); + break; + case H5VL_REF_CREATE: + fprintf(out, "H5VL_REF_CREATE"); + break; + default: + fprintf(out, "%ld", (long)specific); + break; + } /* end switch */ + } /* end else */ + break; + default: + fprintf(out, "BADTYPE(Z%c)", type[1]); + goto error; + } /* end switch */ + break; + case 'x': if(ptr) { if(vp) { diff --git a/src/Makefile.am b/src/Makefile.am index 4b55144..11525fb 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -58,6 +58,7 @@ libhdf5_la_SOURCES= H5.c H5checksum.c H5dbg.c H5system.c H5timer.c H5trace.c \ H5Fsfile.c H5Fsuper.c H5Fsuper_cache.c H5Ftest.c \ H5FA.c H5FAcache.c H5FAdbg.c H5FAdblock.c H5FAdblkpage.c H5FAhdr.c \ H5FAstat.c H5FAtest.c \ + H5VL.c H5VLint.c H5VLnative.c \ H5FD.c H5FDcore.c \ H5FDdirect.c H5FDfamily.c H5FDint.c H5FDlog.c H5FDmpi.c H5FDmpio.c \ H5FDmulti.c H5FDsec2.c H5FDspace.c H5FDstdio.c \ @@ -113,10 +114,11 @@ libhdf5_la_SOURCES= H5.c H5checksum.c H5dbg.c H5system.c H5timer.c H5trace.c \ include_HEADERS = hdf5.h H5api_adpt.h H5overflow.h H5pubconf.h H5public.h H5version.h \ H5Apublic.h H5ACpublic.h \ H5Cpublic.h H5Dpublic.h \ - H5Epubgen.h H5Epublic.h H5Fpublic.h \ + H5Epubgen.h H5Epublic.h H5ESpublic.h H5Fpublic.h \ H5FDpublic.h H5FDcore.h H5FDdirect.h \ H5FDfamily.h H5FDlog.h H5FDmpi.h H5FDmpio.h \ H5FDmulti.h H5FDsec2.h H5FDstdio.h \ + H5VLpublic.h H5VLnative.h \ H5Gpublic.h H5Ipublic.h H5Lpublic.h \ H5MMpublic.h H5Opublic.h H5Ppublic.h \ H5PLextern.h \ diff --git a/src/Makefile.in b/src/Makefile.in index 721295b..7e7a5e7 100644 --- a/src/Makefile.in +++ b/src/Makefile.in @@ -162,15 +162,16 @@ am_libhdf5_la_OBJECTS = H5.lo H5checksum.lo H5dbg.lo H5system.lo \ H5Fefc.lo H5Ffake.lo H5Fio.lo H5Fmount.lo H5Fmpi.lo \ H5Fquery.lo H5Fsfile.lo H5Fsuper.lo H5Fsuper_cache.lo \ H5Ftest.lo H5FA.lo H5FAcache.lo H5FAdbg.lo H5FAdblock.lo \ - H5FAdblkpage.lo H5FAhdr.lo H5FAstat.lo H5FAtest.lo H5FD.lo \ - H5FDcore.lo H5FDdirect.lo H5FDfamily.lo H5FDint.lo H5FDlog.lo \ - H5FDmpi.lo H5FDmpio.lo H5FDmulti.lo H5FDsec2.lo H5FDspace.lo \ - H5FDstdio.lo H5FL.lo H5FO.lo H5FS.lo H5FScache.lo H5FSdbg.lo \ - H5FSsection.lo H5FSstat.lo H5FStest.lo H5G.lo H5Gbtree2.lo \ - H5Gcache.lo H5Gcompact.lo H5Gdense.lo H5Gdeprec.lo H5Gent.lo \ - H5Gint.lo H5Glink.lo H5Gloc.lo H5Gname.lo H5Gnode.lo H5Gobj.lo \ - H5Goh.lo H5Groot.lo H5Gstab.lo H5Gtest.lo H5Gtraverse.lo \ - H5HF.lo H5HFbtree2.lo H5HFcache.lo H5HFdbg.lo H5HFdblock.lo \ + H5FAdblkpage.lo H5FAhdr.lo H5FAstat.lo H5FAtest.lo H5VL.lo \ + H5VLint.lo H5VLnative.lo H5FD.lo H5FDcore.lo H5FDdirect.lo \ + H5FDfamily.lo H5FDint.lo H5FDlog.lo H5FDmpi.lo H5FDmpio.lo \ + H5FDmulti.lo H5FDsec2.lo H5FDspace.lo H5FDstdio.lo H5FL.lo \ + H5FO.lo H5FS.lo H5FScache.lo H5FSdbg.lo H5FSsection.lo \ + H5FSstat.lo H5FStest.lo H5G.lo H5Gbtree2.lo H5Gcache.lo \ + H5Gcompact.lo H5Gdense.lo H5Gdeprec.lo H5Gent.lo H5Gint.lo \ + H5Glink.lo H5Gloc.lo H5Gname.lo H5Gnode.lo H5Gobj.lo H5Goh.lo \ + H5Groot.lo H5Gstab.lo H5Gtest.lo H5Gtraverse.lo H5HF.lo \ + H5HFbtree2.lo H5HFcache.lo H5HFdbg.lo H5HFdblock.lo \ H5HFdtable.lo H5HFhdr.lo H5HFhuge.lo H5HFiblock.lo H5HFiter.lo \ H5HFman.lo H5HFsection.lo H5HFspace.lo H5HFstat.lo H5HFtest.lo \ H5HFtiny.lo H5HG.lo H5HGcache.lo H5HGdbg.lo H5HGquery.lo \ @@ -764,6 +765,7 @@ libhdf5_la_SOURCES = H5.c H5checksum.c H5dbg.c H5system.c H5timer.c H5trace.c \ H5Fsfile.c H5Fsuper.c H5Fsuper_cache.c H5Ftest.c \ H5FA.c H5FAcache.c H5FAdbg.c H5FAdblock.c H5FAdblkpage.c H5FAhdr.c \ H5FAstat.c H5FAtest.c \ + H5VL.c H5VLint.c H5VLnative.c \ H5FD.c H5FDcore.c \ H5FDdirect.c H5FDfamily.c H5FDint.c H5FDlog.c H5FDmpi.c H5FDmpio.c \ H5FDmulti.c H5FDsec2.c H5FDspace.c H5FDstdio.c \ @@ -819,10 +821,11 @@ libhdf5_la_SOURCES = H5.c H5checksum.c H5dbg.c H5system.c H5timer.c H5trace.c \ include_HEADERS = hdf5.h H5api_adpt.h H5overflow.h H5pubconf.h H5public.h H5version.h \ H5Apublic.h H5ACpublic.h \ H5Cpublic.h H5Dpublic.h \ - H5Epubgen.h H5Epublic.h H5Fpublic.h \ + H5Epubgen.h H5Epublic.h H5ESpublic.h H5Fpublic.h \ H5FDpublic.h H5FDcore.h H5FDdirect.h \ H5FDfamily.h H5FDlog.h H5FDmpi.h H5FDmpio.h \ H5FDmulti.h H5FDsec2.h H5FDstdio.h \ + H5VLpublic.h H5VLnative.h \ H5Gpublic.h H5Ipublic.h H5Lpublic.h \ H5MMpublic.h H5Opublic.h H5Ppublic.h \ H5PLextern.h \ @@ -1214,6 +1217,9 @@ distclean-compile: @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/H5Tvisit.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/H5Tvlen.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/H5UC.Plo@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/H5VL.Plo@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/H5VLint.Plo@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/H5VLnative.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/H5VM.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/H5WB.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/H5Z.Plo@am__quote@ @@ -38,6 +38,10 @@ #include "H5Spublic.h" /* Dataspaces */ #include "H5Tpublic.h" /* Datatypes */ #include "H5Zpublic.h" /* Data filters */ +#include "H5VLpublic.h" /* VOL plugins */ + +/* Predefined VOL plugins */ +#include "H5VLnative.h" /* Native HDF5 plugin */ /* Predefined file drivers */ #include "H5FDcore.h" /* Files stored entirely in memory */ diff --git a/test/Makefile.am b/test/Makefile.am index b5ebcf3..6d5e5ce 100644 --- a/test/Makefile.am +++ b/test/Makefile.am @@ -28,7 +28,9 @@ TEST_SCRIPT = testerror.sh testlibinfo.sh testcheck_version.sh testlinks_env.sh SCRIPT_DEPEND = error_test$(EXEEXT) err_compat$(EXEEXT) links_env$(EXEEXT) if HAVE_SHARED_CONDITIONAL TEST_SCRIPT += test_plugin.sh + TEST_SCRIPT += test_vol_plugin.sh SCRIPT_DEPEND += plugin$(EXEEXT) + SCRIPT_DEPEND += vol_test$(EXEEXT) endif check_SCRIPTS = $(TEST_SCRIPT) @@ -57,6 +59,7 @@ TEST_PROG= testhdf5 lheap ohdr stab gheap cache cache_api cache_tagging \ check_PROGRAMS=$(TEST_PROG) error_test err_compat tcheck_version testmeta links_env if HAVE_SHARED_CONDITIONAL check_PROGRAMS+= plugin + check_PROGRAMS+= vol_test endif # These programs generate test files for the tests. They don't need to be @@ -81,10 +84,13 @@ if HAVE_SHARED_CONDITIONAL # The libdynlib1 and libdynlib2 library for testing plugin module plugin.c. # Build it as shared library if configure is enabled for shared library. - lib_LTLIBRARIES=libdynlib1.la libdynlib2.la libdynlib3.la + lib_LTLIBRARIES=libdynlib1.la libdynlib2.la libdynlib3.la libdynlibvol1.la libdynlibvol2.la libdynlib1_la_SOURCES=dynlib1.c libdynlib2_la_SOURCES=dynlib2.c libdynlib3_la_SOURCES=dynlib3.c + libdynlibvol1_la_SOURCES=dynlibvol1.c + libdynlibvol2_la_SOURCES=dynlibvol2.c + install-exec-hook: $(RM) $(DESTDIR)$(libdir)/*dynlib* @@ -142,6 +148,7 @@ CHECK_CLEANFILES+=accum.h5 cmpd_dset.h5 compact_dataset.h5 dataset.h5 dset_offse tmisc[0-9]*.h5 set_extent[1-5].h5 ext[12].bin \ getname.h5 getname[1-3].h5 sec2_file.h5 direct_file.h5 \ family_file000[0-3][0-9].h5 new_family_v16_000[0-3][0-9].h5 \ + log_file1.h5 log_file2.h5 \ multi_file-[rs].h5 core_file plugin.h5 \ new_move_[ab].h5 ntypes.h5 dangle.h5 error_test.h5 err_compat.h5 \ dtransform.h5 test_filters.h5 get_file_name.h5 tstint[1-2].h5 \ @@ -159,6 +166,6 @@ testhdf5_SOURCES=testhdf5.c tarray.c tattr.c tchecksum.c tconfig.c tfile.c \ tvlstr.c tvltypes.c # Temporary files. -DISTCLEANFILES=testerror.sh testlibinfo.sh testcheck_version.sh testlinks_env.sh test_plugin.sh +DISTCLEANFILES=testerror.sh testlibinfo.sh testcheck_version.sh testlinks_env.sh test_plugin.sh test_vol_plugin.sh include $(top_srcdir)/config/conclude.am diff --git a/test/Makefile.in b/test/Makefile.in index 2a43aaf..8723a03 100644 --- a/test/Makefile.in +++ b/test/Makefile.in @@ -102,14 +102,16 @@ DIST_COMMON = $(top_srcdir)/config/commence.am \ $(srcdir)/testcheck_version.sh.in $(srcdir)/testerror.sh.in \ $(srcdir)/H5srcdir_str.h.in $(srcdir)/testlibinfo.sh.in \ $(srcdir)/testlinks_env.sh.in $(srcdir)/test_plugin.sh.in \ - $(top_srcdir)/bin/depcomp $(top_srcdir)/bin/test-driver \ - COPYING -@HAVE_SHARED_CONDITIONAL_TRUE@am__append_1 = test_plugin.sh -@HAVE_SHARED_CONDITIONAL_TRUE@am__append_2 = plugin$(EXEEXT) + $(srcdir)/test_vol_plugin.sh.in $(top_srcdir)/bin/depcomp \ + $(top_srcdir)/bin/test-driver COPYING +@HAVE_SHARED_CONDITIONAL_TRUE@am__append_1 = test_plugin.sh \ +@HAVE_SHARED_CONDITIONAL_TRUE@ test_vol_plugin.sh +@HAVE_SHARED_CONDITIONAL_TRUE@am__append_2 = plugin$(EXEEXT) \ +@HAVE_SHARED_CONDITIONAL_TRUE@ vol_test$(EXEEXT) check_PROGRAMS = $(am__EXEEXT_1) error_test$(EXEEXT) \ err_compat$(EXEEXT) tcheck_version$(EXEEXT) testmeta$(EXEEXT) \ links_env$(EXEEXT) $(am__EXEEXT_2) -@HAVE_SHARED_CONDITIONAL_TRUE@am__append_3 = plugin +@HAVE_SHARED_CONDITIONAL_TRUE@am__append_3 = plugin vol_test @BUILD_ALL_CONDITIONAL_TRUE@noinst_PROGRAMS = $(am__EXEEXT_3) @DIRECT_VFD_CONDITIONAL_TRUE@am__append_4 = direct TESTS = $(am__EXEEXT_1) $(TEST_SCRIPT) @@ -121,7 +123,8 @@ am__configure_deps = $(am__aclocal_m4_deps) $(CONFIGURE_DEPENDENCIES) \ mkinstalldirs = $(SHELL) $(top_srcdir)/bin/mkinstalldirs CONFIG_HEADER = $(top_builddir)/src/H5config.h CONFIG_CLEAN_FILES = testcheck_version.sh testerror.sh H5srcdir_str.h \ - testlibinfo.sh testlinks_env.sh test_plugin.sh + testlibinfo.sh testlinks_env.sh test_plugin.sh \ + test_vol_plugin.sh CONFIG_CLEAN_VPATH_FILES = am__vpath_adj_setup = srcdirstrip=`echo "$(srcdir)" | sed 's|.|.|g'`; am__vpath_adj = case $$p in \ @@ -174,6 +177,20 @@ am__libdynlib3_la_SOURCES_DIST = dynlib3.c libdynlib3_la_OBJECTS = $(am_libdynlib3_la_OBJECTS) @HAVE_SHARED_CONDITIONAL_TRUE@am_libdynlib3_la_rpath = -rpath \ @HAVE_SHARED_CONDITIONAL_TRUE@ $(libdir) +libdynlibvol1_la_LIBADD = +am__libdynlibvol1_la_SOURCES_DIST = dynlibvol1.c +@HAVE_SHARED_CONDITIONAL_TRUE@am_libdynlibvol1_la_OBJECTS = \ +@HAVE_SHARED_CONDITIONAL_TRUE@ dynlibvol1.lo +libdynlibvol1_la_OBJECTS = $(am_libdynlibvol1_la_OBJECTS) +@HAVE_SHARED_CONDITIONAL_TRUE@am_libdynlibvol1_la_rpath = -rpath \ +@HAVE_SHARED_CONDITIONAL_TRUE@ $(libdir) +libdynlibvol2_la_LIBADD = +am__libdynlibvol2_la_SOURCES_DIST = dynlibvol2.c +@HAVE_SHARED_CONDITIONAL_TRUE@am_libdynlibvol2_la_OBJECTS = \ +@HAVE_SHARED_CONDITIONAL_TRUE@ dynlibvol2.lo +libdynlibvol2_la_OBJECTS = $(am_libdynlibvol2_la_OBJECTS) +@HAVE_SHARED_CONDITIONAL_TRUE@am_libdynlibvol2_la_rpath = -rpath \ +@HAVE_SHARED_CONDITIONAL_TRUE@ $(libdir) libh5test_la_LIBADD = am_libh5test_la_OBJECTS = h5test.lo testframe.lo cache_common.lo libh5test_la_OBJECTS = $(am_libh5test_la_OBJECTS) @@ -196,7 +213,8 @@ am__EXEEXT_1 = testhdf5$(EXEEXT) lheap$(EXEEXT) ohdr$(EXEEXT) \ freespace$(EXEEXT) mf$(EXEEXT) farray$(EXEEXT) earray$(EXEEXT) \ btree2$(EXEEXT) fheap$(EXEEXT) file_image$(EXEEXT) \ unregister$(EXEEXT) -@HAVE_SHARED_CONDITIONAL_TRUE@am__EXEEXT_2 = plugin$(EXEEXT) +@HAVE_SHARED_CONDITIONAL_TRUE@am__EXEEXT_2 = plugin$(EXEEXT) \ +@HAVE_SHARED_CONDITIONAL_TRUE@ vol_test$(EXEEXT) am__EXEEXT_3 = gen_bad_ohdr$(EXEEXT) gen_bogus$(EXEEXT) \ gen_cross$(EXEEXT) gen_deflate$(EXEEXT) gen_filters$(EXEEXT) \ gen_new_array$(EXEEXT) gen_new_fill$(EXEEXT) \ @@ -522,6 +540,10 @@ vfd_SOURCES = vfd.c vfd_OBJECTS = vfd.$(OBJEXT) vfd_LDADD = $(LDADD) vfd_DEPENDENCIES = libh5test.la $(LIBHDF5) +vol_test_SOURCES = vol_test.c +vol_test_OBJECTS = vol_test.$(OBJEXT) +vol_test_LDADD = $(LDADD) +vol_test_DEPENDENCIES = libh5test.la $(LIBHDF5) AM_V_P = $(am__v_P_@AM_V@) am__v_P_ = $(am__v_P_@AM_DEFAULT_V@) am__v_P_0 = false @@ -557,7 +579,8 @@ am__v_CCLD_ = $(am__v_CCLD_@AM_DEFAULT_V@) am__v_CCLD_0 = @echo " CCLD " $@; am__v_CCLD_1 = SOURCES = $(libdynlib1_la_SOURCES) $(libdynlib2_la_SOURCES) \ - $(libdynlib3_la_SOURCES) $(libh5test_la_SOURCES) accum.c \ + $(libdynlib3_la_SOURCES) $(libdynlibvol1_la_SOURCES) \ + $(libdynlibvol2_la_SOURCES) $(libh5test_la_SOURCES) accum.c \ app_ref.c big.c bittests.c btree2.c cache.c cache_api.c \ cache_tagging.c cmpd_dset.c cross_read.c dangle.c dsets.c \ dt_arith.c dtransform.c dtypes.c earray.c efc.c \ @@ -573,10 +596,12 @@ SOURCES = $(libdynlib1_la_SOURCES) $(libdynlib2_la_SOURCES) \ mount.c mtime.c ntypes.c objcopy.c ohdr.c plugin.c pool.c \ reserved.c set_extent.c space_overflow.c stab.c \ tcheck_version.c $(testhdf5_SOURCES) testmeta.c \ - $(ttsafe_SOURCES) unlink.c unregister.c vfd.c + $(ttsafe_SOURCES) unlink.c unregister.c vfd.c vol_test.c DIST_SOURCES = $(am__libdynlib1_la_SOURCES_DIST) \ $(am__libdynlib2_la_SOURCES_DIST) \ - $(am__libdynlib3_la_SOURCES_DIST) $(libh5test_la_SOURCES) \ + $(am__libdynlib3_la_SOURCES_DIST) \ + $(am__libdynlibvol1_la_SOURCES_DIST) \ + $(am__libdynlibvol2_la_SOURCES_DIST) $(libh5test_la_SOURCES) \ accum.c app_ref.c big.c bittests.c btree2.c cache.c \ cache_api.c cache_tagging.c cmpd_dset.c cross_read.c dangle.c \ dsets.c dt_arith.c dtransform.c dtypes.c earray.c efc.c \ @@ -592,7 +617,7 @@ DIST_SOURCES = $(am__libdynlib1_la_SOURCES_DIST) \ mount.c mtime.c ntypes.c objcopy.c ohdr.c plugin.c pool.c \ reserved.c set_extent.c space_overflow.c stab.c \ tcheck_version.c $(testhdf5_SOURCES) testmeta.c \ - $(ttsafe_SOURCES) unlink.c unregister.c vfd.c + $(ttsafe_SOURCES) unlink.c unregister.c vfd.c vol_test.c am__can_run_installinfo = \ case $$AM_UPDATE_INFO_DIR in \ n|no|NO) false;; \ @@ -1093,15 +1118,16 @@ CHECK_CLEANFILES = *.chkexe *.chklog *.clog accum.h5 cmpd_dset.h5 \ tmisc[0-9]*.h5 set_extent[1-5].h5 ext[12].bin getname.h5 \ getname[1-3].h5 sec2_file.h5 direct_file.h5 \ family_file000[0-3][0-9].h5 new_family_v16_000[0-3][0-9].h5 \ - multi_file-[rs].h5 core_file plugin.h5 new_move_[ab].h5 \ - ntypes.h5 dangle.h5 error_test.h5 err_compat.h5 dtransform.h5 \ - test_filters.h5 get_file_name.h5 tstint[1-2].h5 \ - unlink_chunked.h5 btree2.h5 objcopy_src.h5 objcopy_dst.h5 \ - objcopy_ext.dat trefer1.h5 trefer2.h5 app_ref.h5 farray.h5 \ - earray.h5 efc[0-5].h5 log_vfd_out.log new_multi_file_v16-r.h5 \ - new_multi_file_v16-s.h5 split_get_file_image_test-m.h5 \ - split_get_file_image_test-r.h5 file_image_core_test.h5.copy \ - unregister_filter_1.h5 unregister_filter_2.h5 + log_file1.h5 log_file2.h5 multi_file-[rs].h5 core_file \ + plugin.h5 new_move_[ab].h5 ntypes.h5 dangle.h5 error_test.h5 \ + err_compat.h5 dtransform.h5 test_filters.h5 get_file_name.h5 \ + tstint[1-2].h5 unlink_chunked.h5 btree2.h5 objcopy_src.h5 \ + objcopy_dst.h5 objcopy_ext.dat trefer1.h5 trefer2.h5 \ + app_ref.h5 farray.h5 earray.h5 efc[0-5].h5 log_vfd_out.log \ + new_multi_file_v16-r.h5 new_multi_file_v16-s.h5 \ + split_get_file_image_test-m.h5 split_get_file_image_test-r.h5 \ + file_image_core_test.h5.copy unregister_filter_1.h5 \ + unregister_filter_2.h5 # Test script for error_test and err_compat TEST_SCRIPT = testerror.sh testlibinfo.sh testcheck_version.sh \ @@ -1140,10 +1166,12 @@ BUILD_ALL_PROGS = gen_bad_ohdr gen_bogus gen_cross gen_deflate gen_filters gen_n @HAVE_SHARED_CONDITIONAL_FALSE@noinst_LTLIBRARIES = libh5test.la @HAVE_SHARED_CONDITIONAL_TRUE@noinst_LTLIBRARIES = libh5test.la -@HAVE_SHARED_CONDITIONAL_TRUE@lib_LTLIBRARIES = libdynlib1.la libdynlib2.la libdynlib3.la +@HAVE_SHARED_CONDITIONAL_TRUE@lib_LTLIBRARIES = libdynlib1.la libdynlib2.la libdynlib3.la libdynlibvol1.la libdynlibvol2.la @HAVE_SHARED_CONDITIONAL_TRUE@libdynlib1_la_SOURCES = dynlib1.c @HAVE_SHARED_CONDITIONAL_TRUE@libdynlib2_la_SOURCES = dynlib2.c @HAVE_SHARED_CONDITIONAL_TRUE@libdynlib3_la_SOURCES = dynlib3.c +@HAVE_SHARED_CONDITIONAL_TRUE@libdynlibvol1_la_SOURCES = dynlibvol1.c +@HAVE_SHARED_CONDITIONAL_TRUE@libdynlibvol2_la_SOURCES = dynlibvol2.c libh5test_la_SOURCES = h5test.c testframe.c cache_common.c # Use libhd5test.la to compile all of the tests @@ -1164,7 +1192,7 @@ testhdf5_SOURCES = testhdf5.c tarray.c tattr.c tchecksum.c tconfig.c tfile.c \ # Temporary files. -DISTCLEANFILES = testerror.sh testlibinfo.sh testcheck_version.sh testlinks_env.sh test_plugin.sh +DISTCLEANFILES = testerror.sh testlibinfo.sh testcheck_version.sh testlinks_env.sh test_plugin.sh test_vol_plugin.sh # Automake needs to be taught how to build lib, progs, and tests targets. # These will be filled in automatically for the most part (e.g., @@ -1232,6 +1260,8 @@ testlinks_env.sh: $(top_builddir)/config.status $(srcdir)/testlinks_env.sh.in cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ test_plugin.sh: $(top_builddir)/config.status $(srcdir)/test_plugin.sh.in cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ +test_vol_plugin.sh: $(top_builddir)/config.status $(srcdir)/test_vol_plugin.sh.in + cd $(top_builddir) && $(SHELL) ./config.status $(subdir)/$@ install-libLTLIBRARIES: $(lib_LTLIBRARIES) @$(NORMAL_INSTALL) @@ -1288,6 +1318,12 @@ libdynlib2.la: $(libdynlib2_la_OBJECTS) $(libdynlib2_la_DEPENDENCIES) $(EXTRA_li libdynlib3.la: $(libdynlib3_la_OBJECTS) $(libdynlib3_la_DEPENDENCIES) $(EXTRA_libdynlib3_la_DEPENDENCIES) $(AM_V_CCLD)$(LINK) $(am_libdynlib3_la_rpath) $(libdynlib3_la_OBJECTS) $(libdynlib3_la_LIBADD) $(LIBS) +libdynlibvol1.la: $(libdynlibvol1_la_OBJECTS) $(libdynlibvol1_la_DEPENDENCIES) $(EXTRA_libdynlibvol1_la_DEPENDENCIES) + $(AM_V_CCLD)$(LINK) $(am_libdynlibvol1_la_rpath) $(libdynlibvol1_la_OBJECTS) $(libdynlibvol1_la_LIBADD) $(LIBS) + +libdynlibvol2.la: $(libdynlibvol2_la_OBJECTS) $(libdynlibvol2_la_DEPENDENCIES) $(EXTRA_libdynlibvol2_la_DEPENDENCIES) + $(AM_V_CCLD)$(LINK) $(am_libdynlibvol2_la_rpath) $(libdynlibvol2_la_OBJECTS) $(libdynlibvol2_la_LIBADD) $(LIBS) + libh5test.la: $(libh5test_la_OBJECTS) $(libh5test_la_DEPENDENCIES) $(EXTRA_libh5test_la_DEPENDENCIES) $(AM_V_CCLD)$(LINK) $(am_libh5test_la_rpath) $(libh5test_la_OBJECTS) $(libh5test_la_LIBADD) $(LIBS) @@ -1613,6 +1649,10 @@ vfd$(EXEEXT): $(vfd_OBJECTS) $(vfd_DEPENDENCIES) $(EXTRA_vfd_DEPENDENCIES) @rm -f vfd$(EXEEXT) $(AM_V_CCLD)$(LINK) $(vfd_OBJECTS) $(vfd_LDADD) $(LIBS) +vol_test$(EXEEXT): $(vol_test_OBJECTS) $(vol_test_DEPENDENCIES) $(EXTRA_vol_test_DEPENDENCIES) + @rm -f vol_test$(EXEEXT) + $(AM_V_CCLD)$(LINK) $(vol_test_OBJECTS) $(vol_test_LDADD) $(LIBS) + mostlyclean-compile: -rm -f *.$(OBJEXT) @@ -1638,6 +1678,8 @@ distclean-compile: @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/dynlib1.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/dynlib2.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/dynlib3.Plo@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/dynlibvol1.Plo@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/dynlibvol2.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/earray.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/efc.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/enc_dec_plist.Po@am__quote@ @@ -1729,6 +1771,7 @@ distclean-compile: @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/unlink.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/unregister.Po@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/vfd.Po@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/vol_test.Po@am__quote@ .c.o: @am__fastdepCC_TRUE@ $(AM_V_CC)$(COMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ $< diff --git a/test/accum.c b/test/accum.c index a924517..b76f92f 100644 --- a/test/accum.c +++ b/test/accum.c @@ -93,7 +93,7 @@ main(void) if((fid = H5Fcreate(FILENAME, H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT)) < 0) FAIL_STACK_ERROR /* Get H5F_t * to internal file structure */ - if(NULL == (f = (H5F_t *)H5I_object(fid))) FAIL_STACK_ERROR + if(NULL == (f = (H5F_t *)H5VL_object(fid))) FAIL_STACK_ERROR /* We'll be writing lots of garbage data, so extend the file a ways. 10MB should do. */ diff --git a/test/btree2.c b/test/btree2.c index d8abc84..0fad793 100644 --- a/test/btree2.c +++ b/test/btree2.c @@ -26,6 +26,14 @@ #define H5B2_TESTING #include "H5B2pkg.h" +/* + * This file needs to access private information from the H5F package. + * This file also needs to access the file testing code. + */ +#define H5F_PACKAGE +#define H5F_TESTING +#include "H5Fpkg.h" /* File access */ + /* Other private headers that this test requires */ #include "H5Iprivate.h" @@ -104,7 +112,7 @@ create_file(hid_t *file, H5F_t **f, hid_t fapl) TEST_ERROR /* Get a pointer to the internal file object */ - if(NULL == (*f = (H5F_t *)H5I_object(*file))) + if(NULL == (*f = (H5F_t *)H5VL_object(*file))) STACK_ERROR /* Ignore metadata tags in the file's cache */ @@ -2806,7 +2814,7 @@ HDfprintf(stderr,"curr_time=%lu\n",(unsigned long)curr_time); TEST_ERROR /* Get a pointer to the internal file object */ - if(NULL == (f = (H5F_t *)H5I_object(file))) + if(NULL == (f = (H5F_t *)H5VL_object(file))) STACK_ERROR /* Ignore metadata tags in the file's cache */ @@ -2845,7 +2853,7 @@ HDfprintf(stderr,"curr_time=%lu\n",(unsigned long)curr_time); FAIL_STACK_ERROR /* Get a pointer to the internal file object */ - if(NULL == (f = (H5F_t *)H5I_object(file))) + if(NULL == (f = (H5F_t *)H5VL_object(file))) FAIL_STACK_ERROR /* Ignore metadata tags in the file's cache */ @@ -6375,7 +6383,7 @@ gen_l4_btree2(const char *filename, hid_t fapl, const H5B2_create_t *cparam, STACK_ERROR /* Get a pointer to the internal file object */ - if(NULL == (f = (H5F_t *)H5I_object(file))) + if(NULL == (f = (H5F_t *)H5VL_object(file))) STACK_ERROR /* Ignore metadata tags in the file's cache */ @@ -6531,7 +6539,7 @@ HDfprintf(stderr, "curr_time = %lu\n", (unsigned long)curr_time); FAIL_STACK_ERROR /* Get a pointer to the internal file object */ - if(NULL == (f = (H5F_t *)H5I_object(file))) + if(NULL == (f = (H5F_t *)H5VL_object(file))) FAIL_STACK_ERROR /* Ignore metadata tags in the file's cache */ @@ -6627,7 +6635,7 @@ HDfprintf(stderr, "curr_time = %lu\n", (unsigned long)curr_time); FAIL_STACK_ERROR /* Get a pointer to the internal file object */ - if(NULL == (f = (H5F_t *)H5I_object(file))) + if(NULL == (f = (H5F_t *)H5VL_object(file))) FAIL_STACK_ERROR /* Ignore metadata tags in the file's cache */ @@ -6716,7 +6724,7 @@ HDfprintf(stderr, "curr_time = %lu\n", (unsigned long)curr_time); FAIL_STACK_ERROR /* Get a pointer to the internal file object */ - if(NULL == (f = (H5F_t *)H5I_object(file))) + if(NULL == (f = (H5F_t *)H5VL_object(file))) FAIL_STACK_ERROR /* Ignore metadata tags in the file's cache */ @@ -6802,7 +6810,7 @@ HDfprintf(stderr, "curr_time = %lu\n", (unsigned long)curr_time); FAIL_STACK_ERROR /* Get a pointer to the internal file object */ - if(NULL == (f = (H5F_t *)H5I_object(file))) + if(NULL == (f = (H5F_t *)H5VL_object(file))) FAIL_STACK_ERROR /* Ignore metadata tags in the file's cache */ @@ -7153,7 +7161,7 @@ test_delete(hid_t fapl, const H5B2_create_t *cparam) STACK_ERROR /* Get a pointer to the internal file object */ - if(NULL == (f = (H5F_t *)H5I_object(file))) + if(NULL == (f = (H5F_t *)H5VL_object(file))) STACK_ERROR /* Ignore metadata tags in the file's cache */ @@ -7198,7 +7206,7 @@ test_delete(hid_t fapl, const H5B2_create_t *cparam) STACK_ERROR /* Get a pointer to the internal file object */ - if(NULL == (f = (H5F_t *)H5I_object(file))) + if(NULL == (f = (H5F_t *)H5VL_object(file))) STACK_ERROR /* Ignore metadata tags in the file's cache */ @@ -7256,7 +7264,7 @@ test_delete(hid_t fapl, const H5B2_create_t *cparam) STACK_ERROR /* Get a pointer to the internal file object */ - if(NULL == (f = (H5F_t *)H5I_object(file))) + if(NULL == (f = (H5F_t *)H5VL_object(file))) STACK_ERROR /* Ignore metadata tags in the file's cache */ @@ -7314,7 +7322,7 @@ test_delete(hid_t fapl, const H5B2_create_t *cparam) STACK_ERROR /* Get a pointer to the internal file object */ - if(NULL == (f = (H5F_t *)H5I_object(file))) + if(NULL == (f = (H5F_t *)H5VL_object(file))) STACK_ERROR /* Ignore metadata tags in the file's cache */ diff --git a/test/cache_api.c b/test/cache_api.c index b1ccef1..34a3cbc 100644 --- a/test/cache_api.c +++ b/test/cache_api.c @@ -234,7 +234,7 @@ check_fapl_mdc_api_calls(void) /* get a pointer to the files internal data structure */ if ( pass ) { - file_ptr = (H5F_t *)H5I_object_verify(file_id, H5I_FILE); + file_ptr = (H5F_t *)H5VL_object_verify(file_id, H5I_FILE); if ( file_ptr == NULL ) { @@ -383,7 +383,7 @@ check_fapl_mdc_api_calls(void) /* get a pointer to the files internal data structure */ if ( pass ) { - file_ptr = (H5F_t *)H5I_object_verify(file_id, H5I_FILE); + file_ptr = (H5F_t *)H5VL_object_verify(file_id, H5I_FILE); if ( file_ptr == NULL ) { diff --git a/test/cache_common.c b/test/cache_common.c index 7b26714..90c640b 100644 --- a/test/cache_common.c +++ b/test/cache_common.c @@ -2555,7 +2555,7 @@ setup_cache(size_t max_cache_size, } else { - file_ptr = (H5F_t *)H5I_object_verify(fid, H5I_FILE); + file_ptr = (H5F_t *)H5VL_object_verify(fid, H5I_FILE); if ( file_ptr == NULL ) { @@ -2757,7 +2757,7 @@ takedown_cache(H5F_t * file_ptr, if ( H5F_addr_defined(saved_actual_base_addr) ) { if ( NULL == file_ptr ) { - file_ptr = (H5F_t *)H5I_object_verify(saved_fid, H5I_FILE); + file_ptr = (H5F_t *)H5VL_object_verify(saved_fid, H5I_FILE); HDassert ( file_ptr ); } @@ -5125,7 +5125,7 @@ check_and_validate_cache_hit_rate(hid_t file_id, /* get a pointer to the files internal data structure */ if ( pass ) { - file_ptr = (H5F_t *)H5I_object_verify(file_id, H5I_FILE); + file_ptr = (H5F_t *)H5VL_object_verify(file_id, H5I_FILE); if ( file_ptr == NULL ) { @@ -5263,7 +5263,7 @@ check_and_validate_cache_size(hid_t file_id, /* get a pointer to the files internal data structure */ if ( pass ) { - file_ptr = (H5F_t *)H5I_object_verify(file_id, H5I_FILE); + file_ptr = (H5F_t *)H5VL_object_verify(file_id, H5I_FILE); if ( file_ptr == NULL ) { @@ -5446,7 +5446,7 @@ validate_mdc_config(hid_t file_id, /* get a pointer to the files internal data structure */ if ( pass ) { - file_ptr = (H5F_t *)H5I_object_verify(file_id, H5I_FILE); + file_ptr = (H5F_t *)H5VL_object_verify(file_id, H5I_FILE); if ( file_ptr == NULL ) { diff --git a/test/cache_tagging.c b/test/cache_tagging.c index 30ca1de..bd34c70 100644 --- a/test/cache_tagging.c +++ b/test/cache_tagging.c @@ -237,7 +237,7 @@ static int print_index(hid_t fid) { H5C_cache_entry_t *next_entry_ptr = NULL; /* entry pointer */ /* Get Internal File / Cache Pointers */ - if ( NULL == (f = (H5F_t *)H5I_object(fid)) ) TEST_ERROR; + if ( NULL == (f = (H5F_t *)H5VL_object(fid)) ) TEST_ERROR; cache_ptr = f->shared->cache; /* Initial (debugging) loop */ @@ -294,7 +294,7 @@ static int verify_no_unknown_tags(hid_t fid) H5C_cache_entry_t *next_entry_ptr = NULL; /* entry pointer */ /* Get Internal File / Cache Pointers */ - if ( NULL == (f = (H5F_t *)H5I_object(fid)) ) TEST_ERROR; + if ( NULL == (f = (H5F_t *)H5VL_object(fid)) ) TEST_ERROR; cache_ptr = f->shared->cache; for (i = 0; i < H5C__HASH_TABLE_LEN; i++) { @@ -346,7 +346,7 @@ static int mark_all_entries_investigated(hid_t fid) H5C_cache_entry_t *next_entry_ptr = NULL; /* entry pointer */ /* Get Internal File / Cache Pointers */ - if ( NULL == (f = (H5F_t *)H5I_object(fid)) ) TEST_ERROR; + if ( NULL == (f = (H5F_t *)H5VL_object(fid)) ) TEST_ERROR; cache_ptr = f->shared->cache; for (i = 0; i < H5C__HASH_TABLE_LEN; i++) { @@ -403,7 +403,7 @@ static int verify_tag(hid_t fid, int id, haddr_t tag) H5C_cache_entry_t *next_entry_ptr = NULL; /* entry pointer */ /* Get Internal File / Cache Pointers */ - if ( NULL == (f = (H5F_t *)H5I_object(fid)) ) TEST_ERROR; + if ( NULL == (f = (H5F_t *)H5VL_object(fid)) ) TEST_ERROR; cache_ptr = f->shared->cache; for (i = 0; i < H5C__HASH_TABLE_LEN; i++) { @@ -448,7 +448,7 @@ static int evict_entries(hid_t fid) H5F_t * f = NULL; /* File Pointer */ /* Get Internal File / Cache Pointers */ - if ( NULL == (f = (H5F_t *)H5I_object(fid)) ) TEST_ERROR; + if ( NULL == (f = (H5F_t *)H5VL_object(fid)) ) TEST_ERROR; /* Mark all entries investigated */ mark_all_entries_investigated(fid); @@ -493,7 +493,7 @@ static int get_new_object_header_tag(hid_t fid, haddr_t *tag) int found = FALSE; /* If entry is found */ /* Get Internal File / Cache Pointers */ - if ( NULL == (f = (H5F_t *)H5I_object(fid)) ) TEST_ERROR; + if ( NULL == (f = (H5F_t *)H5VL_object(fid)) ) TEST_ERROR; cache_ptr = f->shared->cache; for (i = 0; i < H5C__HASH_TABLE_LEN; i++) { @@ -3845,7 +3845,7 @@ check_invalid_tag_application(void) if ( (fid = H5Fcreate(FILENAME, H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT)) < 0 ) TEST_ERROR; /* Get internal file pointer*/ - if ( NULL == (f = (H5F_t *)H5I_object(fid)) ) TEST_ERROR; + if ( NULL == (f = (H5F_t *)H5VL_object(fid)) ) TEST_ERROR; /* Create dxpl */ if ( (dxpl_id = H5Pcreate(H5P_DATASET_XFER)) < 0) TEST_ERROR; diff --git a/test/dynlibvol1.c b/test/dynlibvol1.c new file mode 100644 index 0000000..1f8ae0e --- /dev/null +++ b/test/dynlibvol1.c @@ -0,0 +1,366 @@ +
+#include <stdio.h>
+#include <stdlib.h>
+#include <assert.h>
+#include "H5PLextern.h"
+#include "hdf5.h"
+
+#define LOG 501
+
+static herr_t H5VL_log_init(hid_t vipl_id);
+static herr_t H5VL_log_term(hid_t vtpl_id);
+
+/* Datatype callbacks */
+static void *H5VL_log_datatype_commit(void *obj, H5VL_loc_params_t loc_params, const char *name, hid_t type_id, hid_t lcpl_id, hid_t tcpl_id, hid_t tapl_id, hid_t dxpl_id, void **req);
+static void *H5VL_log_datatype_open(void *obj, H5VL_loc_params_t loc_params, const char *name, hid_t tapl_id, hid_t dxpl_id, void **req);
+static herr_t H5VL_log_datatype_get(void *dt, H5VL_datatype_get_t get_type, hid_t dxpl_id, void **req, va_list arguments);
+static herr_t H5VL_log_datatype_close(void *dt, hid_t dxpl_id, void **req);
+
+/* Dataset callbacks */
+static void *H5VL_log_dataset_create(void *obj, H5VL_loc_params_t loc_params, const char *name, hid_t dcpl_id, hid_t dapl_id, hid_t dxpl_id, void **req);
+static void *H5VL_log_dataset_open(void *obj, H5VL_loc_params_t loc_params, const char *name, hid_t dapl_id, hid_t dxpl_id, void **req);
+static herr_t H5VL_log_dataset_read(void *dset, hid_t mem_type_id, hid_t mem_space_id,
+ hid_t file_space_id, hid_t plist_id, void *buf, void **req);
+static herr_t H5VL_log_dataset_write(void *dset, hid_t mem_type_id, hid_t mem_space_id,
+ hid_t file_space_id, hid_t plist_id, const void *buf, void **req);
+static herr_t H5VL_log_dataset_close(void *dset, hid_t dxpl_id, void **req);
+
+/* File callbacks */
+static void *H5VL_log_file_create(const char *name, unsigned flags, hid_t fcpl_id, hid_t fapl_id, hid_t dxpl_id, void **req);
+static void *H5VL_log_file_open(const char *name, unsigned flags, hid_t fapl_id, hid_t dxpl_id, void **req);
+static herr_t H5VL_log_file_get(void *file, H5VL_file_get_t get_type, hid_t dxpl_id, void **req, va_list arguments);
+static herr_t H5VL_log_file_close(void *file, hid_t dxpl_id, void **req);
+
+/* Group callbacks */
+static void *H5VL_log_group_create(void *obj, H5VL_loc_params_t loc_params, const char *name, hid_t gcpl_id, hid_t gapl_id, hid_t dxpl_id, void **req);
+static herr_t H5VL_log_group_close(void *grp, hid_t dxpl_id, void **req);
+
+/* Link callbacks */
+
+/* Object callbacks */
+static void *H5VL_log_object_open(void *obj, H5VL_loc_params_t loc_params, H5I_type_t *opened_type, hid_t dxpl_id, void **req);
+static herr_t H5VL_log_object_specific(void *obj, H5VL_loc_params_t loc_params, H5VL_object_specific_t specific_type, hid_t dxpl_id, void **req, va_list arguments);
+
+hid_t native_plugin_id = -1;
+
+static const H5VL_class_t H5VL_log1_g = {
+ 0,
+ LOG,
+ "log1", /* name */
+ H5VL_log_init, /* initialize */
+ H5VL_log_term, /* terminate */
+ sizeof(hid_t),
+ NULL,
+ NULL,
+ { /* attribute_cls */
+ NULL, //H5VL_log_attr_create, /* create */
+ NULL, //H5VL_log_attr_open, /* open */
+ NULL, //H5VL_log_attr_read, /* read */
+ NULL, //H5VL_log_attr_write, /* write */
+ NULL, //H5VL_log_attr_get, /* get */
+ NULL, //H5VL_log_attr_specific, /* specific */
+ NULL, //H5VL_log_attr_optional, /* optional */
+ NULL //H5VL_log_attr_close /* close */
+ },
+ { /* dataset_cls */
+ H5VL_log_dataset_create, /* create */
+ H5VL_log_dataset_open, /* open */
+ H5VL_log_dataset_read, /* read */
+ H5VL_log_dataset_write, /* write */
+ NULL, //H5VL_log_dataset_get, /* get */
+ NULL, //H5VL_log_dataset_specific, /* specific */
+ NULL, //H5VL_log_dataset_optional, /* optional */
+ H5VL_log_dataset_close /* close */
+ },
+ { /* datatype_cls */
+ H5VL_log_datatype_commit, /* commit */
+ H5VL_log_datatype_open, /* open */
+ H5VL_log_datatype_get, /* get_size */
+ NULL, //H5VL_log_datatype_specific, /* specific */
+ NULL, //H5VL_log_datatype_optional, /* optional */
+ H5VL_log_datatype_close /* close */
+ },
+ { /* file_cls */
+ H5VL_log_file_create, /* create */
+ H5VL_log_file_open, /* open */
+ H5VL_log_file_get, /* get */
+ NULL, //H5VL_log_file_specific, /* specific */
+ NULL, //H5VL_log_file_optional, /* optional */
+ H5VL_log_file_close /* close */
+ },
+ { /* group_cls */
+ H5VL_log_group_create, /* create */
+ NULL, //H5VL_log_group_open, /* open */
+ NULL, //H5VL_log_group_get, /* get */
+ NULL, //H5VL_log_group_specific, /* specific */
+ NULL, //H5VL_log_group_optional, /* optional */
+ H5VL_log_group_close /* close */
+ },
+ { /* link_cls */
+ NULL, //H5VL_log_link_create, /* create */
+ NULL, //H5VL_log_link_copy, /* copy */
+ NULL, //H5VL_log_link_move, /* move */
+ NULL, //H5VL_log_link_get, /* get */
+ NULL, //H5VL_log_link_specific, /* specific */
+ NULL, //H5VL_log_link_optional, /* optional */
+ },
+ { /* object_cls */
+ H5VL_log_object_open, /* open */
+ NULL, //H5VL_log_object_copy, /* copy */
+ NULL, //H5VL_log_object_get, /* get */
+ H5VL_log_object_specific, /* specific */
+ NULL, //H5VL_log_object_optional, /* optional */
+ },
+ {
+ NULL,
+ NULL,
+ NULL
+ },
+ NULL
+};
+
+typedef struct H5VL_log_t {
+ void *under_object;
+} H5VL_log_t;
+
+H5PL_type_t H5PLget_plugin_type(void) {return H5PL_TYPE_VOL;}
+const void *H5PLget_plugin_info(void) {return &H5VL_log1_g;}
+
+static herr_t H5VL_log_init(hid_t vipl_id)
+{
+ printf("------- LOG INIT\n");
+ return 0;
+}
+
+static herr_t H5VL_log_term(hid_t vtpl_id)
+{
+ printf("------- LOG TERM\n");
+ return 0;
+}
+
+static void *
+H5VL_log_file_create(const char *name, unsigned flags, hid_t fcpl_id, hid_t fapl_id, hid_t dxpl_id, void **req)
+{
+ hid_t under_fapl;
+ H5VL_log_t *file;
+
+ native_plugin_id = H5VLget_plugin_id("native");
+ assert(native_plugin_id > 0);
+
+ file = (H5VL_log_t *)calloc(1, sizeof(H5VL_log_t));
+
+ under_fapl = *((hid_t *)H5Pget_vol_info(fapl_id));
+ file->under_object = H5VLfile_create(name, flags, fcpl_id, under_fapl, dxpl_id, req);
+
+ printf("------- LOG H5Fcreate\n");
+ return (void *)file;
+}
+
+static void *
+H5VL_log_file_open(const char *name, unsigned flags, hid_t fapl_id, hid_t dxpl_id, void **req)
+{
+ hid_t under_fapl;
+ H5VL_log_t *file;
+
+ file = (H5VL_log_t *)calloc(1, sizeof(H5VL_log_t));
+
+ under_fapl = *((hid_t *)H5Pget_vol_info(fapl_id));
+ file->under_object = H5VLfile_open(name, flags, under_fapl, dxpl_id, req);
+
+ printf("------- LOG H5Fopen\n");
+ return (void *)file;
+}
+
+static herr_t
+H5VL_log_file_get(void *file, H5VL_file_get_t get_type, hid_t dxpl_id, void **req, va_list arguments)
+{
+ H5VL_log_t *f = (H5VL_log_t *)file;
+
+ H5VLfile_get(f->under_object, native_plugin_id, get_type, dxpl_id, req, arguments);
+
+ printf("------- LOG H5Fget %d\n", get_type);
+ return 1;
+}
+static herr_t
+H5VL_log_file_close(void *file, hid_t dxpl_id, void **req)
+{
+ H5VL_log_t *f = (H5VL_log_t *)file;
+
+ H5VLfile_close(f->under_object, native_plugin_id, dxpl_id, req);
+ free(f);
+
+ printf("------- LOG H5Fclose\n");
+ return 1;
+}
+
+static void *
+H5VL_log_group_create(void *obj, H5VL_loc_params_t loc_params, const char *name,
+ hid_t gcpl_id, hid_t gapl_id, hid_t dxpl_id, void **req)
+{
+ H5VL_log_t *group;
+ H5VL_log_t *o = (H5VL_log_t *)obj;
+
+ group = (H5VL_log_t *)calloc(1, sizeof(H5VL_log_t));
+
+ group->under_object = H5VLgroup_create(o->under_object, loc_params, native_plugin_id, name, gcpl_id, gapl_id, dxpl_id, req);
+
+ printf("------- LOG H5Gcreate\n");
+ return (void *)group;
+}
+
+static herr_t
+H5VL_log_group_close(void *grp, hid_t dxpl_id, void **req)
+{
+ H5VL_log_t *g = (H5VL_log_t *)grp;
+
+ H5VLgroup_close(g->under_object, native_plugin_id, dxpl_id, req);
+ free(g);
+
+ printf("------- LOG H5Gclose\n");
+ return 1;
+}
+
+static void *
+H5VL_log_datatype_commit(void *obj, H5VL_loc_params_t loc_params, const char *name,
+ hid_t type_id, hid_t lcpl_id, hid_t tcpl_id, hid_t tapl_id, hid_t dxpl_id, void **req)
+{
+ H5VL_log_t *dt;
+ H5VL_log_t *o = (H5VL_log_t *)obj;
+
+ dt = (H5VL_log_t *)calloc(1, sizeof(H5VL_log_t));
+
+ dt->under_object = H5VLdatatype_commit(o->under_object, loc_params, native_plugin_id, name,
+ type_id, lcpl_id, tcpl_id, tapl_id, dxpl_id, req);
+
+ printf("------- LOG H5Tcommit\n");
+ return dt;
+}
+static void *
+H5VL_log_datatype_open(void *obj, H5VL_loc_params_t loc_params, const char *name, hid_t tapl_id, hid_t dxpl_id, void **req)
+{
+ H5VL_log_t *dt;
+ H5VL_log_t *o = (H5VL_log_t *)obj;
+
+ dt = (H5VL_log_t *)calloc(1, sizeof(H5VL_log_t));
+
+ dt->under_object = H5VLdatatype_open(o->under_object, loc_params, native_plugin_id, name, tapl_id, dxpl_id, req);
+
+ printf("------- LOG H5Topen\n");
+ return (void *)dt;
+}
+
+static herr_t
+H5VL_log_datatype_get(void *dt, H5VL_datatype_get_t get_type, hid_t dxpl_id, void **req, va_list arguments)
+{
+ H5VL_log_t *o = (H5VL_log_t *)dt;
+ herr_t ret_value;
+
+ ret_value = H5VLdatatype_get(o->under_object, native_plugin_id, get_type, dxpl_id, req, arguments);
+
+ printf("------- LOG datatype get\n");
+ return ret_value;
+}
+
+static herr_t
+H5VL_log_datatype_close(void *dt, hid_t dxpl_id, void **req)
+{
+ H5VL_log_t *type = (H5VL_log_t *)dt;
+
+ assert(type->under_object);
+
+ H5VLdatatype_close(type->under_object, native_plugin_id, dxpl_id, req);
+ free(type);
+
+ printf("------- LOG H5Tclose\n");
+ return 1;
+}
+
+static void *
+H5VL_log_object_open(void *obj, H5VL_loc_params_t loc_params, H5I_type_t *opened_type, hid_t dxpl_id, void **req)
+{
+ H5VL_log_t *new_obj;
+ H5VL_log_t *o = (H5VL_log_t *)obj;
+
+ new_obj = (H5VL_log_t *)calloc(1, sizeof(H5VL_log_t));
+
+ new_obj->under_object = H5VLobject_open(o->under_object, loc_params, native_plugin_id, opened_type, dxpl_id, req);
+
+ printf("------- LOG H5Oopen\n");
+ return (void *)new_obj;
+}
+
+static herr_t
+H5VL_log_object_specific(void *obj, H5VL_loc_params_t loc_params, H5VL_object_specific_t specific_type,
+ hid_t dxpl_id, void **req, va_list arguments)
+{
+ H5VL_log_t *o = (H5VL_log_t *)obj;
+
+ H5VLobject_specific(o->under_object, loc_params, native_plugin_id, specific_type, dxpl_id, req, arguments);
+
+ printf("------- LOG Object specific\n");
+ return 1;
+}
+
+static void *
+H5VL_log_dataset_create(void *obj, H5VL_loc_params_t loc_params, const char *name, hid_t dcpl_id, hid_t dapl_id, hid_t dxpl_id, void **req)
+{
+ H5VL_log_t *dset;
+ H5VL_log_t *o = (H5VL_log_t *)obj;
+
+ dset = (H5VL_log_t *)calloc(1, sizeof(H5VL_log_t));
+
+ dset->under_object = H5VLdataset_create(o->under_object, loc_params, native_plugin_id, name, dcpl_id, dapl_id, dxpl_id, req);
+
+ printf("------- LOG H5Dcreate\n");
+ return (void *)dset;
+}
+
+static void *
+H5VL_log_dataset_open(void *obj, H5VL_loc_params_t loc_params, const char *name, hid_t dapl_id, hid_t dxpl_id, void **req)
+{
+ H5VL_log_t *dset;
+ H5VL_log_t *o = (H5VL_log_t *)obj;
+
+ dset = (H5VL_log_t *)calloc(1, sizeof(H5VL_log_t));
+
+ dset->under_object = H5VLdataset_open(o->under_object, loc_params, native_plugin_id, name, dapl_id, dxpl_id, req);
+
+ printf("------- LOG H5Dopen\n");
+ return (void *)dset;
+}
+
+static herr_t
+H5VL_log_dataset_read(void *dset, hid_t mem_type_id, hid_t mem_space_id,
+ hid_t file_space_id, hid_t plist_id, void *buf, void **req)
+{
+ H5VL_log_t *d = (H5VL_log_t *)dset;
+
+ H5VLdataset_read(d->under_object, native_plugin_id, mem_type_id, mem_space_id, file_space_id,
+ plist_id, buf, req);
+
+ printf("------- LOG H5Dread\n");
+ return 1;
+}
+static herr_t
+H5VL_log_dataset_write(void *dset, hid_t mem_type_id, hid_t mem_space_id,
+ hid_t file_space_id, hid_t plist_id, const void *buf, void **req)
+{
+ H5VL_log_t *d = (H5VL_log_t *)dset;
+
+ H5VLdataset_write(d->under_object, native_plugin_id, mem_type_id, mem_space_id, file_space_id,
+ plist_id, buf, req);
+
+ printf("------- LOG H5Dwrite\n");
+ return 1;
+}
+static herr_t
+H5VL_log_dataset_close(void *dset, hid_t dxpl_id, void **req)
+{
+ H5VL_log_t *d = (H5VL_log_t *)dset;
+
+ H5VLdataset_close(d->under_object, native_plugin_id, dxpl_id, req);
+ free(d);
+
+ printf("------- LOG H5Dclose\n");
+ return 1;
+}
diff --git a/test/dynlibvol2.c b/test/dynlibvol2.c new file mode 100644 index 0000000..1877c21 --- /dev/null +++ b/test/dynlibvol2.c @@ -0,0 +1,366 @@ +
+#include <stdio.h>
+#include <stdlib.h>
+#include <assert.h>
+#include "H5PLextern.h"
+#include "hdf5.h"
+
+#define LOG 502
+
+static herr_t H5VL_log_init(hid_t vipl_id);
+static herr_t H5VL_log_term(hid_t vtpl_id);
+
+/* Datatype callbacks */
+static void *H5VL_log_datatype_commit(void *obj, H5VL_loc_params_t loc_params, const char *name, hid_t type_id, hid_t lcpl_id, hid_t tcpl_id, hid_t tapl_id, hid_t dxpl_id, void **req);
+static void *H5VL_log_datatype_open(void *obj, H5VL_loc_params_t loc_params, const char *name, hid_t tapl_id, hid_t dxpl_id, void **req);
+static herr_t H5VL_log_datatype_get(void *dt, H5VL_datatype_get_t get_type, hid_t dxpl_id, void **req, va_list arguments);
+static herr_t H5VL_log_datatype_close(void *dt, hid_t dxpl_id, void **req);
+
+/* Dataset callbacks */
+static void *H5VL_log_dataset_create(void *obj, H5VL_loc_params_t loc_params, const char *name, hid_t dcpl_id, hid_t dapl_id, hid_t dxpl_id, void **req);
+static void *H5VL_log_dataset_open(void *obj, H5VL_loc_params_t loc_params, const char *name, hid_t dapl_id, hid_t dxpl_id, void **req);
+static herr_t H5VL_log_dataset_read(void *dset, hid_t mem_type_id, hid_t mem_space_id,
+ hid_t file_space_id, hid_t plist_id, void *buf, void **req);
+static herr_t H5VL_log_dataset_write(void *dset, hid_t mem_type_id, hid_t mem_space_id,
+ hid_t file_space_id, hid_t plist_id, const void *buf, void **req);
+static herr_t H5VL_log_dataset_close(void *dset, hid_t dxpl_id, void **req);
+
+/* File callbacks */
+static void *H5VL_log_file_create(const char *name, unsigned flags, hid_t fcpl_id, hid_t fapl_id, hid_t dxpl_id, void **req);
+static void *H5VL_log_file_open(const char *name, unsigned flags, hid_t fapl_id, hid_t dxpl_id, void **req);
+static herr_t H5VL_log_file_get(void *file, H5VL_file_get_t get_type, hid_t dxpl_id, void **req, va_list arguments);
+static herr_t H5VL_log_file_close(void *file, hid_t dxpl_id, void **req);
+
+/* Group callbacks */
+static void *H5VL_log_group_create(void *obj, H5VL_loc_params_t loc_params, const char *name, hid_t gcpl_id, hid_t gapl_id, hid_t dxpl_id, void **req);
+static herr_t H5VL_log_group_close(void *grp, hid_t dxpl_id, void **req);
+
+/* Link callbacks */
+
+/* Object callbacks */
+static void *H5VL_log_object_open(void *obj, H5VL_loc_params_t loc_params, H5I_type_t *opened_type, hid_t dxpl_id, void **req);
+static herr_t H5VL_log_object_specific(void *obj, H5VL_loc_params_t loc_params, H5VL_object_specific_t specific_type, hid_t dxpl_id, void **req, va_list arguments);
+
+hid_t native_plugin_id = -1;
+
+static const H5VL_class_t H5VL_log2_g = {
+ 0,
+ LOG,
+ "log2", /* name */
+ H5VL_log_init, /* initialize */
+ H5VL_log_term, /* terminate */
+ sizeof(hid_t),
+ NULL,
+ NULL,
+ { /* attribute_cls */
+ NULL, //H5VL_log_attr_create, /* create */
+ NULL, //H5VL_log_attr_open, /* open */
+ NULL, //H5VL_log_attr_read, /* read */
+ NULL, //H5VL_log_attr_write, /* write */
+ NULL, //H5VL_log_attr_get, /* get */
+ NULL, //H5VL_log_attr_specific, /* specific */
+ NULL, //H5VL_log_attr_optional, /* optional */
+ NULL //H5VL_log_attr_close /* close */
+ },
+ { /* dataset_cls */
+ H5VL_log_dataset_create, /* create */
+ H5VL_log_dataset_open, /* open */
+ H5VL_log_dataset_read, /* read */
+ H5VL_log_dataset_write, /* write */
+ NULL, //H5VL_log_dataset_get, /* get */
+ NULL, //H5VL_log_dataset_specific, /* specific */
+ NULL, //H5VL_log_dataset_optional, /* optional */
+ H5VL_log_dataset_close /* close */
+ },
+ { /* datatype_cls */
+ H5VL_log_datatype_commit, /* commit */
+ H5VL_log_datatype_open, /* open */
+ H5VL_log_datatype_get, /* get_size */
+ NULL, //H5VL_log_datatype_specific, /* specific */
+ NULL, //H5VL_log_datatype_optional, /* optional */
+ H5VL_log_datatype_close /* close */
+ },
+ { /* file_cls */
+ H5VL_log_file_create, /* create */
+ H5VL_log_file_open, /* open */
+ H5VL_log_file_get, /* get */
+ NULL, //H5VL_log_file_specific, /* specific */
+ NULL, //H5VL_log_file_optional, /* optional */
+ H5VL_log_file_close /* close */
+ },
+ { /* group_cls */
+ H5VL_log_group_create, /* create */
+ NULL, //H5VL_log_group_open, /* open */
+ NULL, //H5VL_log_group_get, /* get */
+ NULL, //H5VL_log_group_specific, /* specific */
+ NULL, //H5VL_log_group_optional, /* optional */
+ H5VL_log_group_close /* close */
+ },
+ { /* link_cls */
+ NULL, //H5VL_log_link_create, /* create */
+ NULL, //H5VL_log_link_copy, /* copy */
+ NULL, //H5VL_log_link_move, /* move */
+ NULL, //H5VL_log_link_get, /* get */
+ NULL, //H5VL_log_link_specific, /* specific */
+ NULL, //H5VL_log_link_optional, /* optional */
+ },
+ { /* object_cls */
+ H5VL_log_object_open, /* open */
+ NULL, //H5VL_log_object_copy, /* copy */
+ NULL, //H5VL_log_object_get, /* get */
+ H5VL_log_object_specific, /* specific */
+ NULL, //H5VL_log_object_optional, /* optional */
+ },
+ {
+ NULL,
+ NULL,
+ NULL
+ },
+ NULL
+};
+
+typedef struct H5VL_log_t {
+ void *under_object;
+} H5VL_log_t;
+
+H5PL_type_t H5PLget_plugin_type(void) {return H5PL_TYPE_VOL;}
+const void *H5PLget_plugin_info(void) {return &H5VL_log2_g;}
+
+static herr_t H5VL_log_init(hid_t vipl_id)
+{
+ printf("------- LOG INIT\n");
+ return 0;
+}
+
+static herr_t H5VL_log_term(hid_t vtpl_id)
+{
+ printf("------- LOG TERM\n");
+ return 0;
+}
+
+static void *
+H5VL_log_file_create(const char *name, unsigned flags, hid_t fcpl_id, hid_t fapl_id, hid_t dxpl_id, void **req)
+{
+ hid_t under_fapl;
+ H5VL_log_t *file;
+
+ native_plugin_id = H5VLget_plugin_id("native");
+ assert(native_plugin_id > 0);
+
+ file = (H5VL_log_t *)calloc(1, sizeof(H5VL_log_t));
+
+ under_fapl = *((hid_t *)H5Pget_vol_info(fapl_id));
+ file->under_object = H5VLfile_create(name, flags, fcpl_id, under_fapl, dxpl_id, req);
+
+ printf("------- LOG H5Fcreate\n");
+ return (void *)file;
+}
+
+static void *
+H5VL_log_file_open(const char *name, unsigned flags, hid_t fapl_id, hid_t dxpl_id, void **req)
+{
+ hid_t under_fapl;
+ H5VL_log_t *file;
+
+ file = (H5VL_log_t *)calloc(1, sizeof(H5VL_log_t));
+
+ under_fapl = *((hid_t *)H5Pget_vol_info(fapl_id));
+ file->under_object = H5VLfile_open(name, flags, under_fapl, dxpl_id, req);
+
+ printf("------- LOG H5Fopen\n");
+ return (void *)file;
+}
+
+static herr_t
+H5VL_log_file_get(void *file, H5VL_file_get_t get_type, hid_t dxpl_id, void **req, va_list arguments)
+{
+ H5VL_log_t *f = (H5VL_log_t *)file;
+
+ H5VLfile_get(f->under_object, native_plugin_id, get_type, dxpl_id, req, arguments);
+
+ printf("------- LOG H5Fget %d\n", get_type);
+ return 1;
+}
+static herr_t
+H5VL_log_file_close(void *file, hid_t dxpl_id, void **req)
+{
+ H5VL_log_t *f = (H5VL_log_t *)file;
+
+ H5VLfile_close(f->under_object, native_plugin_id, dxpl_id, req);
+ free(f);
+
+ printf("------- LOG H5Fclose\n");
+ return 1;
+}
+
+static void *
+H5VL_log_group_create(void *obj, H5VL_loc_params_t loc_params, const char *name,
+ hid_t gcpl_id, hid_t gapl_id, hid_t dxpl_id, void **req)
+{
+ H5VL_log_t *group;
+ H5VL_log_t *o = (H5VL_log_t *)obj;
+
+ group = (H5VL_log_t *)calloc(1, sizeof(H5VL_log_t));
+
+ group->under_object = H5VLgroup_create(o->under_object, loc_params, native_plugin_id, name, gcpl_id, gapl_id, dxpl_id, req);
+
+ printf("------- LOG H5Gcreate\n");
+ return (void *)group;
+}
+
+static herr_t
+H5VL_log_group_close(void *grp, hid_t dxpl_id, void **req)
+{
+ H5VL_log_t *g = (H5VL_log_t *)grp;
+
+ H5VLgroup_close(g->under_object, native_plugin_id, dxpl_id, req);
+ free(g);
+
+ printf("------- LOG H5Gclose\n");
+ return 1;
+}
+
+static void *
+H5VL_log_datatype_commit(void *obj, H5VL_loc_params_t loc_params, const char *name,
+ hid_t type_id, hid_t lcpl_id, hid_t tcpl_id, hid_t tapl_id, hid_t dxpl_id, void **req)
+{
+ H5VL_log_t *dt;
+ H5VL_log_t *o = (H5VL_log_t *)obj;
+
+ dt = (H5VL_log_t *)calloc(1, sizeof(H5VL_log_t));
+
+ dt->under_object = H5VLdatatype_commit(o->under_object, loc_params, native_plugin_id, name,
+ type_id, lcpl_id, tcpl_id, tapl_id, dxpl_id, req);
+
+ printf("------- LOG H5Tcommit\n");
+ return dt;
+}
+static void *
+H5VL_log_datatype_open(void *obj, H5VL_loc_params_t loc_params, const char *name, hid_t tapl_id, hid_t dxpl_id, void **req)
+{
+ H5VL_log_t *dt;
+ H5VL_log_t *o = (H5VL_log_t *)obj;
+
+ dt = (H5VL_log_t *)calloc(1, sizeof(H5VL_log_t));
+
+ dt->under_object = H5VLdatatype_open(o->under_object, loc_params, native_plugin_id, name, tapl_id, dxpl_id, req);
+
+ printf("------- LOG H5Topen\n");
+ return (void *)dt;
+}
+
+static herr_t
+H5VL_log_datatype_get(void *dt, H5VL_datatype_get_t get_type, hid_t dxpl_id, void **req, va_list arguments)
+{
+ H5VL_log_t *o = (H5VL_log_t *)dt;
+ herr_t ret_value;
+
+ ret_value = H5VLdatatype_get(o->under_object, native_plugin_id, get_type, dxpl_id, req, arguments);
+
+ printf("------- LOG datatype get\n");
+ return ret_value;
+}
+
+static herr_t
+H5VL_log_datatype_close(void *dt, hid_t dxpl_id, void **req)
+{
+ H5VL_log_t *type = (H5VL_log_t *)dt;
+
+ assert(type->under_object);
+
+ H5VLdatatype_close(type->under_object, native_plugin_id, dxpl_id, req);
+ free(type);
+
+ printf("------- LOG H5Tclose\n");
+ return 1;
+}
+
+static void *
+H5VL_log_object_open(void *obj, H5VL_loc_params_t loc_params, H5I_type_t *opened_type, hid_t dxpl_id, void **req)
+{
+ H5VL_log_t *new_obj;
+ H5VL_log_t *o = (H5VL_log_t *)obj;
+
+ new_obj = (H5VL_log_t *)calloc(1, sizeof(H5VL_log_t));
+
+ new_obj->under_object = H5VLobject_open(o->under_object, loc_params, native_plugin_id, opened_type, dxpl_id, req);
+
+ printf("------- LOG H5Oopen\n");
+ return (void *)new_obj;
+}
+
+static herr_t
+H5VL_log_object_specific(void *obj, H5VL_loc_params_t loc_params, H5VL_object_specific_t specific_type,
+ hid_t dxpl_id, void **req, va_list arguments)
+{
+ H5VL_log_t *o = (H5VL_log_t *)obj;
+
+ H5VLobject_specific(o->under_object, loc_params, native_plugin_id, specific_type, dxpl_id, req, arguments);
+
+ printf("------- LOG Object specific\n");
+ return 1;
+}
+
+static void *
+H5VL_log_dataset_create(void *obj, H5VL_loc_params_t loc_params, const char *name, hid_t dcpl_id, hid_t dapl_id, hid_t dxpl_id, void **req)
+{
+ H5VL_log_t *dset;
+ H5VL_log_t *o = (H5VL_log_t *)obj;
+
+ dset = (H5VL_log_t *)calloc(1, sizeof(H5VL_log_t));
+
+ dset->under_object = H5VLdataset_create(o->under_object, loc_params, native_plugin_id, name, dcpl_id, dapl_id, dxpl_id, req);
+
+ printf("------- LOG H5Dcreate\n");
+ return (void *)dset;
+}
+
+static void *
+H5VL_log_dataset_open(void *obj, H5VL_loc_params_t loc_params, const char *name, hid_t dapl_id, hid_t dxpl_id, void **req)
+{
+ H5VL_log_t *dset;
+ H5VL_log_t *o = (H5VL_log_t *)obj;
+
+ dset = (H5VL_log_t *)calloc(1, sizeof(H5VL_log_t));
+
+ dset->under_object = H5VLdataset_open(o->under_object, loc_params, native_plugin_id, name, dapl_id, dxpl_id, req);
+
+ printf("------- LOG H5Dopen\n");
+ return (void *)dset;
+}
+
+static herr_t
+H5VL_log_dataset_read(void *dset, hid_t mem_type_id, hid_t mem_space_id,
+ hid_t file_space_id, hid_t plist_id, void *buf, void **req)
+{
+ H5VL_log_t *d = (H5VL_log_t *)dset;
+
+ H5VLdataset_read(d->under_object, native_plugin_id, mem_type_id, mem_space_id, file_space_id,
+ plist_id, buf, req);
+
+ printf("------- LOG H5Dread\n");
+ return 1;
+}
+static herr_t
+H5VL_log_dataset_write(void *dset, hid_t mem_type_id, hid_t mem_space_id,
+ hid_t file_space_id, hid_t plist_id, const void *buf, void **req)
+{
+ H5VL_log_t *d = (H5VL_log_t *)dset;
+
+ H5VLdataset_write(d->under_object, native_plugin_id, mem_type_id, mem_space_id, file_space_id,
+ plist_id, buf, req);
+
+ printf("------- LOG H5Dwrite\n");
+ return 1;
+}
+static herr_t
+H5VL_log_dataset_close(void *dset, hid_t dxpl_id, void **req)
+{
+ H5VL_log_t *d = (H5VL_log_t *)dset;
+
+ H5VLdataset_close(d->under_object, native_plugin_id, dxpl_id, req);
+ free(d);
+
+ printf("------- LOG H5Dclose\n");
+ return 1;
+}
diff --git a/test/earray.c b/test/earray.c index 2d0a399..5eb4adb 100644 --- a/test/earray.c +++ b/test/earray.c @@ -26,6 +26,14 @@ #define H5EA_TESTING #include "H5EApkg.h" /* Extensible Arrays */ +/* + * This file needs to access private information from the H5F package. + * This file also needs to access the file testing code. + */ +#define H5F_PACKAGE +#define H5F_TESTING +#include "H5Fpkg.h" /* File access */ + /* Other private headers that this test requires */ #include "H5Iprivate.h" /* IDs */ #include "H5VMprivate.h" /* Vectors and arrays */ @@ -319,7 +327,7 @@ create_file(hid_t fapl, hid_t *file, H5F_t **f) FAIL_STACK_ERROR /* Get a pointer to the internal file object */ - if(NULL == (*f = (H5F_t *)H5I_object(*file))) + if(NULL == (*f = (H5F_t *)H5VL_object(*file))) FAIL_STACK_ERROR /* Ignore metadata tags in the file's cache */ @@ -451,7 +459,7 @@ reopen_file(hid_t *file, H5F_t **f, hid_t fapl, hid_t dxpl, FAIL_STACK_ERROR /* Get a pointer to the internal file object */ - if(NULL == (*f = (H5F_t *)H5I_object(*file))) + if(NULL == (*f = (H5F_t *)H5VL_object(*file))) FAIL_STACK_ERROR /* Ignore metadata tags in the file's cache */ @@ -1156,7 +1164,7 @@ test_open_twice(hid_t fapl, H5EA_create_t *cparam, earray_test_param_t *tparam) FAIL_STACK_ERROR /* Get a pointer to the internal file object */ - if(NULL == (f2 = (H5F_t *)H5I_object(file2))) + if(NULL == (f2 = (H5F_t *)H5VL_object(file2))) FAIL_STACK_ERROR /* Open the extensible array through the second file handle */ diff --git a/test/farray.c b/test/farray.c index 7a79aaa..ce81f7d 100644 --- a/test/farray.c +++ b/test/farray.c @@ -26,6 +26,14 @@ #define H5FA_TESTING #include "H5FApkg.h" /* Fixed Arrays */ +/* + * This file needs to access private information from the H5F package. + * This file also needs to access the file testing code. + */ +#define H5F_PACKAGE +#define H5F_TESTING +#include "H5Fpkg.h" /* File access */ + /* Other private headers that this test requires */ #include "H5Iprivate.h" /* IDs */ #include "H5VMprivate.h" /* Vectors and arrays */ @@ -155,7 +163,7 @@ create_file(hid_t fapl, hid_t *file, H5F_t **f) FAIL_STACK_ERROR /* Get a pointer to the internal file object */ - if(NULL == (*f = (H5F_t *)H5I_object(*file))) + if(NULL == (*f = (H5F_t *)H5VL_object(*file))) FAIL_STACK_ERROR /* Ignore metadata tags in the file's cache */ @@ -291,7 +299,7 @@ reopen_file(hid_t *file, H5F_t **f, hid_t fapl, hid_t dxpl, FAIL_STACK_ERROR /* Get a pointer to the internal file object */ - if(NULL == (*f = (H5F_t *)H5I_object(*file))) + if(NULL == (*f = (H5F_t *)H5VL_object(*file))) FAIL_STACK_ERROR /* Ignore metadata tags in the file's cache */ @@ -675,7 +683,7 @@ test_open_twice(hid_t fapl, H5FA_create_t *cparam, farray_test_param_t *tparam) FAIL_STACK_ERROR /* Get a pointer to the internal file object */ - if(NULL == (f2 = (H5F_t *)H5I_object(file2))) + if(NULL == (f2 = (H5F_t *)H5VL_object(file2))) FAIL_STACK_ERROR /* Open the fixed array through the second file handle */ diff --git a/test/fheap.c b/test/fheap.c index 96b0673..32c8f05 100644 --- a/test/fheap.c +++ b/test/fheap.c @@ -597,7 +597,7 @@ reopen_file(hid_t *file, H5F_t **f, const char *filename, hid_t fapl, hid_t dxpl FAIL_STACK_ERROR /* Get a pointer to the internal file object */ - if(NULL == (*f = (H5F_t *)H5I_object(*file))) + if(NULL == (*f = (H5F_t *)H5VL_object(*file))) FAIL_STACK_ERROR /* Ignore metadata tags in the file's cache */ @@ -648,7 +648,7 @@ open_heap(char *filename, hid_t fapl, hid_t dxpl, const H5HF_create_t *cparam, /* Check for deleting the entire heap */ if(tparam->del_dir != FHEAP_DEL_HEAP) { /* Get a pointer to the internal file object */ - if(NULL == (*f = (H5F_t *)H5I_object(*file))) + if(NULL == (*f = (H5F_t *)H5VL_object(*file))) FAIL_STACK_ERROR /* Ignore metadata tags in the file's cache */ @@ -690,7 +690,7 @@ open_heap(char *filename, hid_t fapl, hid_t dxpl, const H5HF_create_t *cparam, FAIL_STACK_ERROR /* Get a pointer to the internal file object */ - if(NULL == (*f = (H5F_t *)H5I_object(*file))) + if(NULL == (*f = (H5F_t *)H5VL_object(*file))) FAIL_STACK_ERROR /* Ignore metadata tags in the file's cache */ @@ -1860,7 +1860,7 @@ test_create(hid_t fapl, H5HF_create_t *cparam, fheap_test_param_t UNUSED *tparam FAIL_STACK_ERROR /* Get a pointer to the internal file object */ - if(NULL == (f = (H5F_t *)H5I_object(file))) + if(NULL == (f = (H5F_t *)H5VL_object(file))) FAIL_STACK_ERROR /* Ignore metadata tags in the file's cache */ @@ -1977,7 +1977,7 @@ test_reopen(hid_t fapl, H5HF_create_t *cparam, fheap_test_param_t UNUSED *tparam FAIL_STACK_ERROR /* Get a pointer to the internal file object */ - if(NULL == (f = (H5F_t *)H5I_object(file))) + if(NULL == (f = (H5F_t *)H5VL_object(file))) STACK_ERROR /* Ignore metadata tags in the file's cache */ @@ -2020,7 +2020,7 @@ test_reopen(hid_t fapl, H5HF_create_t *cparam, fheap_test_param_t UNUSED *tparam FAIL_STACK_ERROR /* Get a pointer to the internal file object */ - if(NULL == (f = (H5F_t *)H5I_object(file))) + if(NULL == (f = (H5F_t *)H5VL_object(file))) FAIL_STACK_ERROR /* Ignore metadata tags in the file's cache */ @@ -2126,7 +2126,7 @@ test_open_twice(hid_t fapl, H5HF_create_t *cparam, fheap_test_param_t UNUSED *tp FAIL_STACK_ERROR /* Get a pointer to the internal file object */ - if(NULL == (f = (H5F_t *)H5I_object(file))) + if(NULL == (f = (H5F_t *)H5VL_object(file))) STACK_ERROR /* Ignore metadata tags in the file's cache */ @@ -2178,7 +2178,7 @@ test_open_twice(hid_t fapl, H5HF_create_t *cparam, fheap_test_param_t UNUSED *tp FAIL_STACK_ERROR /* Get a pointer to the internal file object */ - if(NULL == (f2 = (H5F_t *)H5I_object(file2))) + if(NULL == (f2 = (H5F_t *)H5VL_object(file2))) FAIL_STACK_ERROR /* Ignore metadata tags in the file's cache */ @@ -2296,7 +2296,7 @@ test_delete_open(hid_t fapl, H5HF_create_t *cparam, fheap_test_param_t UNUSED *t FAIL_STACK_ERROR /* Get a pointer to the internal file object */ - if(NULL == (f = (H5F_t *)H5I_object(file))) + if(NULL == (f = (H5F_t *)H5VL_object(file))) STACK_ERROR /* Ignore metadata tags in the file's cache */ @@ -2369,7 +2369,7 @@ test_delete_open(hid_t fapl, H5HF_create_t *cparam, fheap_test_param_t UNUSED *t FAIL_STACK_ERROR /* Get a pointer to the internal file object */ - if(NULL == (f = (H5F_t *)H5I_object(file))) + if(NULL == (f = (H5F_t *)H5VL_object(file))) FAIL_STACK_ERROR /* Ignore metadata tags in the file's cache */ @@ -2455,7 +2455,7 @@ test_id_limits(hid_t fapl, H5HF_create_t *cparam) FAIL_STACK_ERROR /* Get a pointer to the internal file object */ - if(NULL == (f = (H5F_t *)H5I_object(file))) + if(NULL == (f = (H5F_t *)H5VL_object(file))) FAIL_STACK_ERROR /* Ignore metadata tags in the file's cache */ @@ -2798,7 +2798,7 @@ test_filtered_create(hid_t fapl, H5HF_create_t *cparam) FAIL_STACK_ERROR /* Get a pointer to the internal file object */ - if(NULL == (f = (H5F_t *)H5I_object(file))) + if(NULL == (f = (H5F_t *)H5VL_object(file))) FAIL_STACK_ERROR /* Ignore metadata tags in the file's cache */ @@ -2841,7 +2841,7 @@ test_filtered_create(hid_t fapl, H5HF_create_t *cparam) FAIL_STACK_ERROR /* Get a pointer to the internal file object */ - if(NULL == (f = (H5F_t *)H5I_object(file))) + if(NULL == (f = (H5F_t *)H5VL_object(file))) FAIL_STACK_ERROR /* Ignore metadata tags in the file's cache */ @@ -2921,7 +2921,7 @@ test_size(hid_t fapl, H5HF_create_t *cparam) FAIL_STACK_ERROR /* Get a pointer to the internal file object */ - if(NULL == (f = (H5F_t *)H5I_object(file))) + if(NULL == (f = (H5F_t *)H5VL_object(file))) FAIL_STACK_ERROR /* Ignore metadata tags in the file's cache */ @@ -2975,7 +2975,7 @@ test_size(hid_t fapl, H5HF_create_t *cparam) FAIL_STACK_ERROR /* Get a pointer to the internal file object */ - if(NULL == (f = (H5F_t *)H5I_object(file))) + if(NULL == (f = (H5F_t *)H5VL_object(file))) FAIL_STACK_ERROR /* Ignore metadata tags in the file's cache */ @@ -3064,7 +3064,7 @@ test_reopen_hdr(hid_t fapl, H5HF_create_t *cparam) FAIL_STACK_ERROR /* Get a pointer to the internal file object */ - if(NULL == (f = (H5F_t *)H5I_object(file1))) + if(NULL == (f = (H5F_t *)H5VL_object(file1))) FAIL_STACK_ERROR /* Ignore metadata tags in the file's cache */ @@ -3108,7 +3108,7 @@ test_reopen_hdr(hid_t fapl, H5HF_create_t *cparam) FAIL_STACK_ERROR /* Get a pointer to the internal file object (file1) */ - if(NULL == (f = (H5F_t *)H5I_object(file1))) + if(NULL == (f = (H5F_t *)H5VL_object(file1))) FAIL_STACK_ERROR /* Ignore metadata tags in the file's cache */ @@ -3130,7 +3130,7 @@ test_reopen_hdr(hid_t fapl, H5HF_create_t *cparam) /* Get a pointer to the internal file object (file2) */ - if(NULL == (f = (H5F_t *)H5I_object(file2))) + if(NULL == (f = (H5F_t *)H5VL_object(file2))) FAIL_STACK_ERROR /* Reopen the heap */ @@ -3203,7 +3203,7 @@ test_man_insert_weird(hid_t fapl, H5HF_create_t *cparam, fheap_test_param_t *tpa FAIL_STACK_ERROR /* Get a pointer to the internal file object */ - if(NULL == (f = (H5F_t *)H5I_object(file))) + if(NULL == (f = (H5F_t *)H5VL_object(file))) FAIL_STACK_ERROR /* Ignore metadata tags in the file's cache */ @@ -3313,7 +3313,7 @@ test_man_insert_first(hid_t fapl, H5HF_create_t *cparam, fheap_test_param_t *tpa FAIL_STACK_ERROR /* Get a pointer to the internal file object */ - if(NULL == (f = (H5F_t *)H5I_object(file))) + if(NULL == (f = (H5F_t *)H5VL_object(file))) FAIL_STACK_ERROR /* Ignore metadata tags in the file's cache */ @@ -3414,7 +3414,7 @@ test_man_insert_second(hid_t fapl, H5HF_create_t *cparam, fheap_test_param_t *tp TEST_ERROR /* Get a pointer to the internal file object */ - if(NULL == (f = (H5F_t *)H5I_object(file))) + if(NULL == (f = (H5F_t *)H5VL_object(file))) STACK_ERROR /* Ignore metadata tags in the file's cache */ @@ -3511,7 +3511,7 @@ test_man_insert_root_mult(hid_t fapl, H5HF_create_t *cparam, fheap_test_param_t TEST_ERROR /* Get a pointer to the internal file object */ - if(NULL == (f = (H5F_t *)H5I_object(file))) + if(NULL == (f = (H5F_t *)H5VL_object(file))) STACK_ERROR /* Ignore metadata tags in the file's cache */ @@ -3610,7 +3610,7 @@ test_man_insert_force_indirect(hid_t fapl, H5HF_create_t *cparam, fheap_test_par TEST_ERROR /* Get a pointer to the internal file object */ - if(NULL == (f = (H5F_t *)H5I_object(file))) + if(NULL == (f = (H5F_t *)H5VL_object(file))) STACK_ERROR /* Ignore metadata tags in the file's cache */ @@ -3716,7 +3716,7 @@ test_man_insert_fill_second(hid_t fapl, H5HF_create_t *cparam, fheap_test_param_ TEST_ERROR /* Get a pointer to the internal file object */ - if(NULL == (f = (H5F_t *)H5I_object(file))) + if(NULL == (f = (H5F_t *)H5VL_object(file))) STACK_ERROR /* Ignore metadata tags in the file's cache */ @@ -3823,7 +3823,7 @@ test_man_insert_third_direct(hid_t fapl, H5HF_create_t *cparam, fheap_test_param TEST_ERROR /* Get a pointer to the internal file object */ - if(NULL == (f = (H5F_t *)H5I_object(file))) + if(NULL == (f = (H5F_t *)H5VL_object(file))) STACK_ERROR /* Ignore metadata tags in the file's cache */ @@ -3934,7 +3934,7 @@ test_man_fill_first_row(hid_t fapl, H5HF_create_t *cparam, fheap_test_param_t *t TEST_ERROR /* Get a pointer to the internal file object */ - if(NULL == (f = (H5F_t *)H5I_object(file))) + if(NULL == (f = (H5F_t *)H5VL_object(file))) STACK_ERROR /* Ignore metadata tags in the file's cache */ @@ -4030,7 +4030,7 @@ test_man_start_second_row(hid_t fapl, H5HF_create_t *cparam, fheap_test_param_t TEST_ERROR /* Get a pointer to the internal file object */ - if(NULL == (f = (H5F_t *)H5I_object(file))) + if(NULL == (f = (H5F_t *)H5VL_object(file))) STACK_ERROR /* Ignore metadata tags in the file's cache */ @@ -4133,7 +4133,7 @@ test_man_fill_second_row(hid_t fapl, H5HF_create_t *cparam, fheap_test_param_t * TEST_ERROR /* Get a pointer to the internal file object */ - if(NULL == (f = (H5F_t *)H5I_object(file))) + if(NULL == (f = (H5F_t *)H5VL_object(file))) STACK_ERROR /* Ignore metadata tags in the file's cache */ @@ -4234,7 +4234,7 @@ test_man_start_third_row(hid_t fapl, H5HF_create_t *cparam, fheap_test_param_t * TEST_ERROR /* Get a pointer to the internal file object */ - if(NULL == (f = (H5F_t *)H5I_object(file))) + if(NULL == (f = (H5F_t *)H5VL_object(file))) STACK_ERROR /* Ignore metadata tags in the file's cache */ @@ -4345,7 +4345,7 @@ test_man_fill_fourth_row(hid_t fapl, H5HF_create_t *cparam, fheap_test_param_t * TEST_ERROR /* Get a pointer to the internal file object */ - if(NULL == (f = (H5F_t *)H5I_object(file))) + if(NULL == (f = (H5F_t *)H5VL_object(file))) STACK_ERROR /* Ignore metadata tags in the file's cache */ @@ -4442,7 +4442,7 @@ test_man_fill_all_root_direct(hid_t fapl, H5HF_create_t *cparam, fheap_test_para TEST_ERROR /* Get a pointer to the internal file object */ - if(NULL == (f = (H5F_t *)H5I_object(file))) + if(NULL == (f = (H5F_t *)H5VL_object(file))) STACK_ERROR /* Ignore metadata tags in the file's cache */ @@ -4538,7 +4538,7 @@ test_man_first_recursive_indirect(hid_t fapl, H5HF_create_t *cparam, fheap_test_ TEST_ERROR /* Get a pointer to the internal file object */ - if(NULL == (f = (H5F_t *)H5I_object(file))) + if(NULL == (f = (H5F_t *)H5VL_object(file))) STACK_ERROR /* Ignore metadata tags in the file's cache */ @@ -4640,7 +4640,7 @@ test_man_second_direct_recursive_indirect(hid_t fapl, H5HF_create_t *cparam, fhe TEST_ERROR /* Get a pointer to the internal file object */ - if(NULL == (f = (H5F_t *)H5I_object(file))) + if(NULL == (f = (H5F_t *)H5VL_object(file))) STACK_ERROR /* Ignore metadata tags in the file's cache */ @@ -4750,7 +4750,7 @@ test_man_fill_first_recursive_indirect(hid_t fapl, H5HF_create_t *cparam, fheap_ TEST_ERROR /* Get a pointer to the internal file object */ - if(NULL == (f = (H5F_t *)H5I_object(file))) + if(NULL == (f = (H5F_t *)H5VL_object(file))) STACK_ERROR /* Ignore metadata tags in the file's cache */ @@ -4853,7 +4853,7 @@ test_man_second_recursive_indirect(hid_t fapl, H5HF_create_t *cparam, fheap_test TEST_ERROR /* Get a pointer to the internal file object */ - if(NULL == (f = (H5F_t *)H5I_object(file))) + if(NULL == (f = (H5F_t *)H5VL_object(file))) STACK_ERROR /* Ignore metadata tags in the file's cache */ @@ -4964,7 +4964,7 @@ test_man_fill_second_recursive_indirect(hid_t fapl, H5HF_create_t *cparam, fheap TEST_ERROR /* Get a pointer to the internal file object */ - if(NULL == (f = (H5F_t *)H5I_object(file))) + if(NULL == (f = (H5F_t *)H5VL_object(file))) STACK_ERROR /* Ignore metadata tags in the file's cache */ @@ -5072,7 +5072,7 @@ test_man_fill_recursive_indirect_row(hid_t fapl, H5HF_create_t *cparam, fheap_te TEST_ERROR /* Get a pointer to the internal file object */ - if(NULL == (f = (H5F_t *)H5I_object(file))) + if(NULL == (f = (H5F_t *)H5VL_object(file))) STACK_ERROR /* Create absolute heap */ @@ -5170,7 +5170,7 @@ test_man_start_2nd_recursive_indirect(hid_t fapl, H5HF_create_t *cparam, fheap_t TEST_ERROR /* Get a pointer to the internal file object */ - if(NULL == (f = (H5F_t *)H5I_object(file))) + if(NULL == (f = (H5F_t *)H5VL_object(file))) STACK_ERROR /* Ignore metadata tags in the file's cache */ @@ -5279,7 +5279,7 @@ test_man_recursive_indirect_two_deep(hid_t fapl, H5HF_create_t *cparam, fheap_te TEST_ERROR /* Get a pointer to the internal file object */ - if(NULL == (f = (H5F_t *)H5I_object(file))) + if(NULL == (f = (H5F_t *)H5VL_object(file))) STACK_ERROR /* Ignore metadata tags in the file's cache */ @@ -5382,7 +5382,7 @@ test_man_start_3rd_recursive_indirect(hid_t fapl, H5HF_create_t *cparam, fheap_t TEST_ERROR /* Get a pointer to the internal file object */ - if(NULL == (f = (H5F_t *)H5I_object(file))) + if(NULL == (f = (H5F_t *)H5VL_object(file))) STACK_ERROR /* Ignore metadata tags in the file's cache */ @@ -5492,7 +5492,7 @@ test_man_fill_first_3rd_recursive_indirect(hid_t fapl, H5HF_create_t *cparam, fh TEST_ERROR /* Get a pointer to the internal file object */ - if(NULL == (f = (H5F_t *)H5I_object(file))) + if(NULL == (f = (H5F_t *)H5VL_object(file))) STACK_ERROR /* Ignore metadata tags in the file's cache */ @@ -5603,7 +5603,7 @@ test_man_fill_3rd_recursive_indirect_row(hid_t fapl, H5HF_create_t *cparam, fhea TEST_ERROR /* Get a pointer to the internal file object */ - if(NULL == (f = (H5F_t *)H5I_object(file))) + if(NULL == (f = (H5F_t *)H5VL_object(file))) STACK_ERROR /* Ignore metadata tags in the file's cache */ @@ -5710,7 +5710,7 @@ test_man_fill_all_3rd_recursive_indirect(hid_t fapl, H5HF_create_t *cparam, fhea TEST_ERROR /* Get a pointer to the internal file object */ - if(NULL == (f = (H5F_t *)H5I_object(file))) + if(NULL == (f = (H5F_t *)H5VL_object(file))) STACK_ERROR /* Ignore metadata tags in the file's cache */ @@ -5818,7 +5818,7 @@ test_man_start_4th_recursive_indirect(hid_t fapl, H5HF_create_t *cparam, fheap_t TEST_ERROR /* Get a pointer to the internal file object */ - if(NULL == (f = (H5F_t *)H5I_object(file))) + if(NULL == (f = (H5F_t *)H5VL_object(file))) STACK_ERROR /* Ignore metadata tags in the file's cache */ @@ -5933,7 +5933,7 @@ test_man_fill_first_4th_recursive_indirect(hid_t fapl, H5HF_create_t *cparam, fh TEST_ERROR /* Get a pointer to the internal file object */ - if(NULL == (f = (H5F_t *)H5I_object(file))) + if(NULL == (f = (H5F_t *)H5VL_object(file))) STACK_ERROR /* Ignore metadata tags in the file's cache */ @@ -6053,7 +6053,7 @@ test_man_fill_4th_recursive_indirect_row(hid_t fapl, H5HF_create_t *cparam, fhea TEST_ERROR /* Get a pointer to the internal file object */ - if(NULL == (f = (H5F_t *)H5I_object(file))) + if(NULL == (f = (H5F_t *)H5VL_object(file))) STACK_ERROR /* Ignore metadata tags in the file's cache */ @@ -6165,7 +6165,7 @@ test_man_fill_all_4th_recursive_indirect(hid_t fapl, H5HF_create_t *cparam, fhea TEST_ERROR /* Get a pointer to the internal file object */ - if(NULL == (f = (H5F_t *)H5I_object(file))) + if(NULL == (f = (H5F_t *)H5VL_object(file))) STACK_ERROR /* Ignore metadata tags in the file's cache */ @@ -6280,7 +6280,7 @@ test_man_start_5th_recursive_indirect(hid_t fapl, H5HF_create_t *cparam, fheap_t TEST_ERROR /* Get a pointer to the internal file object */ - if(NULL == (f = (H5F_t *)H5I_object(file))) + if(NULL == (f = (H5F_t *)H5VL_object(file))) STACK_ERROR /* Ignore metadata tags in the file's cache */ @@ -6414,7 +6414,7 @@ test_man_remove_bogus(hid_t fapl, H5HF_create_t *cparam, fheap_test_param_t *tpa TEST_ERROR /* Get a pointer to the internal file object */ - if(NULL == (f = (H5F_t *)H5I_object(file))) + if(NULL == (f = (H5F_t *)H5VL_object(file))) STACK_ERROR /* Ignore metadata tags in the file's cache */ @@ -6567,7 +6567,7 @@ test_man_remove_one(hid_t fapl, H5HF_create_t *cparam, fheap_test_param_t *tpara TEST_ERROR /* Get a pointer to the internal file object */ - if(NULL == (f = (H5F_t *)H5I_object(file))) + if(NULL == (f = (H5F_t *)H5VL_object(file))) STACK_ERROR /* Ignore metadata tags in the file's cache */ @@ -6608,7 +6608,7 @@ test_man_remove_one(hid_t fapl, H5HF_create_t *cparam, fheap_test_param_t *tpara FAIL_STACK_ERROR /* Get a pointer to the internal file object */ - if(NULL == (f = (H5F_t *)H5I_object(file))) + if(NULL == (f = (H5F_t *)H5VL_object(file))) FAIL_STACK_ERROR /* Ignore metadata tags in the file's cache */ @@ -6731,7 +6731,7 @@ test_man_remove_two(hid_t fapl, H5HF_create_t *cparam, fheap_test_param_t *tpara TEST_ERROR /* Get a pointer to the internal file object */ - if(NULL == (f = (H5F_t *)H5I_object(file))) + if(NULL == (f = (H5F_t *)H5VL_object(file))) STACK_ERROR /* Ignore metadata tags in the file's cache */ @@ -6772,7 +6772,7 @@ test_man_remove_two(hid_t fapl, H5HF_create_t *cparam, fheap_test_param_t *tpara FAIL_STACK_ERROR /* Get a pointer to the internal file object */ - if(NULL == (f = (H5F_t *)H5I_object(file))) + if(NULL == (f = (H5F_t *)H5VL_object(file))) FAIL_STACK_ERROR /* Ignore metadata tags in the file's cache */ @@ -6924,7 +6924,7 @@ test_man_remove_one_larger(hid_t fapl, H5HF_create_t *cparam, fheap_test_param_t TEST_ERROR /* Get a pointer to the internal file object */ - if(NULL == (f = (H5F_t *)H5I_object(file))) + if(NULL == (f = (H5F_t *)H5VL_object(file))) STACK_ERROR /* Ignore metadata tags in the file's cache */ @@ -6965,7 +6965,7 @@ test_man_remove_one_larger(hid_t fapl, H5HF_create_t *cparam, fheap_test_param_t FAIL_STACK_ERROR /* Get a pointer to the internal file object */ - if(NULL == (f = (H5F_t *)H5I_object(file))) + if(NULL == (f = (H5F_t *)H5VL_object(file))) FAIL_STACK_ERROR /* Ignore metadata tags in the file's cache */ @@ -7093,7 +7093,7 @@ test_man_remove_two_larger(hid_t fapl, H5HF_create_t *cparam, fheap_test_param_t TEST_ERROR /* Get a pointer to the internal file object */ - if(NULL == (f = (H5F_t *)H5I_object(file))) + if(NULL == (f = (H5F_t *)H5VL_object(file))) STACK_ERROR /* Ignore metadata tags in the file's cache */ @@ -7134,7 +7134,7 @@ test_man_remove_two_larger(hid_t fapl, H5HF_create_t *cparam, fheap_test_param_t FAIL_STACK_ERROR /* Get a pointer to the internal file object */ - if(NULL == (f = (H5F_t *)H5I_object(file))) + if(NULL == (f = (H5F_t *)H5VL_object(file))) FAIL_STACK_ERROR /* Ignore metadata tags in the file's cache */ @@ -7337,7 +7337,7 @@ test_man_remove_three_larger(hid_t fapl, H5HF_create_t *cparam, fheap_test_param TEST_ERROR /* Get a pointer to the internal file object */ - if(NULL == (f = (H5F_t *)H5I_object(file))) + if(NULL == (f = (H5F_t *)H5VL_object(file))) STACK_ERROR /* Ignore metadata tags in the file's cache */ @@ -7378,7 +7378,7 @@ test_man_remove_three_larger(hid_t fapl, H5HF_create_t *cparam, fheap_test_param FAIL_STACK_ERROR /* Get a pointer to the internal file object */ - if(NULL == (f = (H5F_t *)H5I_object(file))) + if(NULL == (f = (H5F_t *)H5VL_object(file))) FAIL_STACK_ERROR /* Ignore metadata tags in the file's cache */ @@ -7636,7 +7636,7 @@ test_man_incr_insert_remove(hid_t fapl, H5HF_create_t *cparam, fheap_test_param_ FAIL_STACK_ERROR /* Get a pointer to the internal file object */ - if(NULL == (f = (H5F_t *)H5I_object(file))) + if(NULL == (f = (H5F_t *)H5VL_object(file))) STACK_ERROR /* Ignore metadata tags in the file's cache */ @@ -13839,7 +13839,7 @@ test_filtered_huge(hid_t fapl, H5HF_create_t *cparam, fheap_test_param_t *tparam FAIL_STACK_ERROR /* Get a pointer to the internal file object */ - if(NULL == (f = (H5F_t *)H5I_object(file))) + if(NULL == (f = (H5F_t *)H5VL_object(file))) FAIL_STACK_ERROR /* Ignore metadata tags in the file's cache */ @@ -15019,7 +15019,7 @@ test_filtered_man_root_direct(hid_t fapl, H5HF_create_t *cparam, fheap_test_para FAIL_STACK_ERROR /* Get a pointer to the internal file object */ - if(NULL == (f = (H5F_t *)H5I_object(file))) + if(NULL == (f = (H5F_t *)H5VL_object(file))) FAIL_STACK_ERROR /* Ignore metadata tags in the file's cache */ @@ -15205,7 +15205,7 @@ test_filtered_man_root_indirect(hid_t fapl, H5HF_create_t *cparam, fheap_test_pa FAIL_STACK_ERROR /* Get a pointer to the internal file object */ - if(NULL == (f = (H5F_t *)H5I_object(file))) + if(NULL == (f = (H5F_t *)H5VL_object(file))) FAIL_STACK_ERROR /* Ignore metadata tags in the file's cache */ @@ -15269,7 +15269,7 @@ test_filtered_man_root_indirect(hid_t fapl, H5HF_create_t *cparam, fheap_test_pa FAIL_STACK_ERROR /* Get a pointer to the internal file object */ - if(NULL == (f = (H5F_t *)H5I_object(file))) + if(NULL == (f = (H5F_t *)H5VL_object(file))) FAIL_STACK_ERROR /* Ignore metadata tags in the file's cache */ @@ -15305,7 +15305,7 @@ test_filtered_man_root_indirect(hid_t fapl, H5HF_create_t *cparam, fheap_test_pa FAIL_STACK_ERROR /* Get a pointer to the internal file object */ - if(NULL == (f = (H5F_t *)H5I_object(file))) + if(NULL == (f = (H5F_t *)H5VL_object(file))) FAIL_STACK_ERROR /* Ignore metadata tags in the file's cache */ @@ -15342,7 +15342,7 @@ test_filtered_man_root_indirect(hid_t fapl, H5HF_create_t *cparam, fheap_test_pa FAIL_STACK_ERROR /* Get a pointer to the internal file object */ - if(NULL == (f = (H5F_t *)H5I_object(file))) + if(NULL == (f = (H5F_t *)H5VL_object(file))) FAIL_STACK_ERROR /* Ignore metadata tags in the file's cache */ @@ -15378,7 +15378,7 @@ test_filtered_man_root_indirect(hid_t fapl, H5HF_create_t *cparam, fheap_test_pa FAIL_STACK_ERROR /* Get a pointer to the internal file object */ - if(NULL == (f = (H5F_t *)H5I_object(file))) + if(NULL == (f = (H5F_t *)H5VL_object(file))) FAIL_STACK_ERROR /* Ignore metadata tags in the file's cache */ @@ -16019,7 +16019,7 @@ test_write(hid_t fapl, H5HF_create_t *cparam, fheap_test_param_t *tparam) FAIL_STACK_ERROR /* Get a pointer to the internal file object */ - if(NULL == (f = (H5F_t *)H5I_object(file))) + if(NULL == (f = (H5F_t *)H5VL_object(file))) FAIL_STACK_ERROR /* Ignore metadata tags in the file's cache */ @@ -16086,7 +16086,7 @@ test_write(hid_t fapl, H5HF_create_t *cparam, fheap_test_param_t *tparam) FAIL_STACK_ERROR /* Get a pointer to the internal file object */ - if(NULL == (f = (H5F_t *)H5I_object(file))) + if(NULL == (f = (H5F_t *)H5VL_object(file))) FAIL_STACK_ERROR /* Ignore metadata tags in the file's cache */ @@ -16251,7 +16251,7 @@ test_bug1(hid_t fapl, H5HF_create_t *cparam, fheap_test_param_t *tparam) FAIL_STACK_ERROR /* Get a pointer to the internal file object */ - if(NULL == (f = (H5F_t *)H5I_object(file))) + if(NULL == (f = (H5F_t *)H5VL_object(file))) FAIL_STACK_ERROR /* Ignore metadata tags in the file's cache */ @@ -16281,7 +16281,7 @@ test_bug1(hid_t fapl, H5HF_create_t *cparam, fheap_test_param_t *tparam) FAIL_STACK_ERROR /* Get a pointer to the internal file object */ - if(NULL == (f = (H5F_t *)H5I_object(file))) + if(NULL == (f = (H5F_t *)H5VL_object(file))) FAIL_STACK_ERROR /* Ignore metadata tags in the file's cache */ diff --git a/test/freespace.c b/test/freespace.c index 9ab0d75..456cc48 100644 --- a/test/freespace.c +++ b/test/freespace.c @@ -480,7 +480,7 @@ test_fs_create(hid_t fapl) FAIL_STACK_ERROR /* Get a pointer to the internal file object */ - if(NULL == (f = (H5F_t *)H5I_object(file))) + if(NULL == (f = (H5F_t *)H5VL_object(file))) FAIL_STACK_ERROR /* initialize creation parameters for free-space manager */ @@ -619,7 +619,7 @@ test_fs_sect_add(hid_t fapl) FAIL_STACK_ERROR /* Get a pointer to the internal file object */ - if(NULL == (f = (H5F_t *)H5I_object(file))) + if(NULL == (f = (H5F_t *)H5VL_object(file))) FAIL_STACK_ERROR init_cparam(&cparam); @@ -680,7 +680,7 @@ test_fs_sect_add(hid_t fapl) FAIL_STACK_ERROR /* Get a pointer to the internal file object */ - if(NULL == (f = (H5F_t *)H5I_object(file))) + if(NULL == (f = (H5F_t *)H5VL_object(file))) FAIL_STACK_ERROR init_cparam(&cparam); @@ -750,7 +750,7 @@ test_fs_sect_add(hid_t fapl) FAIL_STACK_ERROR /* Get a pointer to the internal file object */ - if(NULL == (f = (H5F_t *)H5I_object(file))) + if(NULL == (f = (H5F_t *)H5VL_object(file))) FAIL_STACK_ERROR TEST_set_eoa((haddr_t)TEST_SECT_ADDR150); /* set end of file address for shrinking */ @@ -819,7 +819,7 @@ test_fs_sect_add(hid_t fapl) FAIL_STACK_ERROR /* Get a pointer to the internal file object */ - if(NULL == (f = (H5F_t *)H5I_object(file))) + if(NULL == (f = (H5F_t *)H5VL_object(file))) FAIL_STACK_ERROR TEST_set_eoa((haddr_t)TEST_SECT_ADDR150); /* set end of file address for shrinking */ @@ -940,7 +940,7 @@ test_fs_sect_find(hid_t fapl) FAIL_STACK_ERROR /* Get a pointer to the internal file object */ - if(NULL == (f = (H5F_t *)H5I_object(file))) + if(NULL == (f = (H5F_t *)H5VL_object(file))) FAIL_STACK_ERROR init_cparam(&cparam); @@ -1324,7 +1324,7 @@ test_fs_sect_merge(hid_t fapl) FAIL_STACK_ERROR /* Get a pointer to the internal file object */ - if(NULL == (f = (H5F_t *)H5I_object(file))) + if(NULL == (f = (H5F_t *)H5VL_object(file))) FAIL_STACK_ERROR init_cparam(&cparam); @@ -1451,7 +1451,7 @@ test_fs_sect_merge(hid_t fapl) FAIL_STACK_ERROR /* Get a pointer to the internal file object */ - if(NULL == (f = (H5F_t *)H5I_object(file))) + if(NULL == (f = (H5F_t *)H5VL_object(file))) FAIL_STACK_ERROR init_cparam(&cparam); @@ -1553,7 +1553,7 @@ test_fs_sect_merge(hid_t fapl) FAIL_STACK_ERROR /* Get a pointer to the internal file object */ - if(NULL == (f = (H5F_t *)H5I_object(file))) + if(NULL == (f = (H5F_t *)H5VL_object(file))) FAIL_STACK_ERROR init_cparam(&cparam); @@ -1788,7 +1788,7 @@ test_fs_sect_shrink(hid_t fapl) FAIL_STACK_ERROR /* Get a pointer to the internal file object */ - if(NULL == (f = (H5F_t *)H5I_object(file))) + if(NULL == (f = (H5F_t *)H5VL_object(file))) FAIL_STACK_ERROR init_cparam(&cparam); @@ -1887,7 +1887,7 @@ test_fs_sect_shrink(hid_t fapl) FAIL_STACK_ERROR /* Get a pointer to the internal file object */ - if(NULL == (f = (H5F_t *)H5I_object(file))) + if(NULL == (f = (H5F_t *)H5VL_object(file))) FAIL_STACK_ERROR init_cparam(&cparam); @@ -1987,7 +1987,7 @@ test_fs_sect_shrink(hid_t fapl) FAIL_STACK_ERROR /* Get a pointer to the internal file object */ - if(NULL == (f = (H5F_t *)H5I_object(file))) + if(NULL == (f = (H5F_t *)H5VL_object(file))) FAIL_STACK_ERROR init_cparam(&cparam); @@ -2124,7 +2124,7 @@ test_fs_sect_change_class(hid_t fapl) FAIL_STACK_ERROR /* Get a pointer to the internal file object */ - if(NULL == (f = (H5F_t *)H5I_object(file))) + if(NULL == (f = (H5F_t *)H5VL_object(file))) FAIL_STACK_ERROR init_cparam(&cparam); @@ -2230,7 +2230,7 @@ test_fs_sect_change_class(hid_t fapl) FAIL_STACK_ERROR /* Get a pointer to the internal file object */ - if(NULL == (f = (H5F_t *)H5I_object(file))) + if(NULL == (f = (H5F_t *)H5VL_object(file))) FAIL_STACK_ERROR init_cparam(&cparam); @@ -2412,7 +2412,7 @@ test_fs_sect_extend(hid_t fapl) FAIL_STACK_ERROR /* Get a pointer to the internal file object */ - if(NULL == (f = (H5F_t *)H5I_object(file))) + if(NULL == (f = (H5F_t *)H5VL_object(file))) FAIL_STACK_ERROR /* @@ -2763,7 +2763,7 @@ test_fs_sect_iterate(hid_t fapl) FAIL_STACK_ERROR /* Get a pointer to the internal file object */ - if(NULL == (f = (H5F_t *)H5I_object(file))) + if(NULL == (f = (H5F_t *)H5VL_object(file))) FAIL_STACK_ERROR init_cparam(&cparam); diff --git a/test/gheap.c b/test/gheap.c index f30935a..6233139 100644 --- a/test/gheap.c +++ b/test/gheap.c @@ -30,6 +30,14 @@ #include "H5Iprivate.h" #include "H5Pprivate.h" +/* + * This file needs to access private information from the H5F package. + * This file also needs to access the file testing code. + */ +#define H5F_PACKAGE +#define H5F_TESTING +#include "H5Fpkg.h" /* File access */ + /* Macros for printing error messages in loops. These print up to * GHEAP_REPEATED_ERR_LIM errors, and suppress the rest */ #define GHEAP_REPEATED_ERR_LIM 20 @@ -92,7 +100,7 @@ test_1 (hid_t fapl) h5_fixname(FILENAME[0], fapl, filename, sizeof filename); if((file = H5Fcreate(filename, H5F_ACC_TRUNC, H5P_DEFAULT, fapl)) < 0) goto error; - if(NULL == (f = (H5F_t *)H5I_object(file))) { + if(NULL == (f = (H5F_t *)H5VL_object(file))) { H5_FAILED(); puts(" Unable to create file"); goto error; @@ -187,7 +195,7 @@ test_2 (hid_t fapl) h5_fixname(FILENAME[1], fapl, filename, sizeof filename); if((file = H5Fcreate(filename, H5F_ACC_TRUNC, H5P_DEFAULT, fapl)) < 0) goto error; - if(NULL == (f = (H5F_t *)H5I_object(file))) { + if(NULL == (f = (H5F_t *)H5VL_object(file))) { H5_FAILED(); puts(" Unable to create file"); goto error; @@ -274,7 +282,7 @@ test_3 (hid_t fapl) h5_fixname(FILENAME[2], fapl, filename, sizeof filename); if((file = H5Fcreate(filename, H5F_ACC_TRUNC, H5P_DEFAULT, fapl)) < 0) goto error; - if(NULL == (f = (H5F_t *)H5I_object(file))) { + if(NULL == (f = (H5F_t *)H5VL_object(file))) { H5_FAILED(); puts(" Unable to create file"); goto error; @@ -353,7 +361,7 @@ test_4 (hid_t fapl) h5_fixname(FILENAME[3], fapl, filename, sizeof filename); if((file = H5Fcreate(filename, H5F_ACC_TRUNC, H5P_DEFAULT, fapl)) < 0) goto error; - if(NULL == (f = (H5F_t *)H5I_object(file))) { + if(NULL == (f = (H5F_t *)H5VL_object(file))) { H5_FAILED(); puts(" Unable to create file"); goto error; @@ -440,7 +448,7 @@ test_ooo_indices(hid_t fapl) h5_fixname(FILENAME[4], fapl, filename, sizeof filename); if((file = H5Fcreate(filename, H5F_ACC_TRUNC, H5P_DEFAULT, fapl)) < 0) goto error; - if(NULL == (f = (H5F_t *)H5I_object(file))) { + if(NULL == (f = (H5F_t *)H5VL_object(file))) { H5_FAILED(); puts(" Unable to create file"); goto error; @@ -481,7 +489,7 @@ test_ooo_indices(hid_t fapl) if (H5Fclose(file)<0) goto error; if((file = H5Fopen(filename, H5F_ACC_RDWR, fapl)) < 0) goto error; - if(NULL == (f = (H5F_t *)H5I_object(file))) { + if(NULL == (f = (H5F_t *)H5VL_object(file))) { H5_FAILED(); puts(" Unable to open file"); goto error; diff --git a/test/lheap.c b/test/lheap.c index 51ae25b..40ee47a 100644 --- a/test/lheap.c +++ b/test/lheap.c @@ -25,6 +25,14 @@ #include "H5HLprivate.h" #include "H5Iprivate.h" +/* + * This file needs to access private information from the H5F package. + * This file also needs to access the file testing code. + */ +#define H5F_PACKAGE +#define H5F_TESTING +#include "H5Fpkg.h" /* File access */ + const char *FILENAME[] = { "lheap", NULL @@ -79,7 +87,7 @@ main(void) h5_fixname(FILENAME[0], fapl, filename, sizeof filename); if ((file=H5Fcreate(filename, H5F_ACC_TRUNC, H5P_DEFAULT, fapl))<0) goto error; - if(NULL == (f = (H5F_t *)H5I_object(file))) { + if(NULL == (f = (H5F_t *)H5VL_object(file))) { H5_FAILED(); H5Eprint2(H5E_DEFAULT, stdout); goto error; @@ -127,7 +135,7 @@ main(void) TESTING("local heap read"); h5_fixname(FILENAME[0], fapl, filename, sizeof filename); if((file = H5Fopen(filename, H5F_ACC_RDONLY, fapl)) < 0) goto error; - if(NULL == (f = (H5F_t *)H5I_object(file))) { + if(NULL == (f = (H5F_t *)H5VL_object(file))) { H5_FAILED(); H5Eprint2(H5E_DEFAULT, stdout); goto error; @@ -228,7 +228,7 @@ test_mf_eoa(const char *env_h5_drvr, hid_t fapl) FAIL_STACK_ERROR /* Get a pointer to the internal file object */ - if(NULL == (f = (H5F_t *)H5I_object(file))) + if(NULL == (f = (H5F_t *)H5VL_object(file))) FAIL_STACK_ERROR H5MF_aggr_query(f, &(f->shared->meta_aggr), &ma_addr, &ma_size); @@ -270,7 +270,7 @@ test_mf_eoa(const char *env_h5_drvr, hid_t fapl) FAIL_STACK_ERROR /* Get a pointer to the internal file object */ - if(NULL == (f = (H5F_t *)H5I_object(file))) + if(NULL == (f = (H5F_t *)H5VL_object(file))) FAIL_STACK_ERROR H5MF_xfree(f, type, H5P_DATASET_XFER_DEFAULT, addr1, (hsize_t)TEST_BLOCK_SIZE30); @@ -371,7 +371,7 @@ test_mf_eoa_shrink(const char *env_h5_drvr, hid_t fapl) FAIL_STACK_ERROR /* Get a pointer to the internal file object */ - if(NULL == (f = (H5F_t *)H5I_object(file))) + if(NULL == (f = (H5F_t *)H5VL_object(file))) FAIL_STACK_ERROR H5MF_aggr_query(f, &(f->shared->meta_aggr), &ma_addr, &ma_size); @@ -403,7 +403,7 @@ test_mf_eoa_shrink(const char *env_h5_drvr, hid_t fapl) FAIL_STACK_ERROR /* Get a pointer to the internal file object */ - if(NULL == (f = (H5F_t *)H5I_object(file))) + if(NULL == (f = (H5F_t *)H5VL_object(file))) FAIL_STACK_ERROR H5MF_aggr_query(f, &(f->shared->meta_aggr), &ma_addr, &ma_size); @@ -448,7 +448,7 @@ test_mf_eoa_shrink(const char *env_h5_drvr, hid_t fapl) FAIL_STACK_ERROR /* Get a pointer to the internal file object */ - if(NULL == (f = (H5F_t *)H5I_object(file))) + if(NULL == (f = (H5F_t *)H5VL_object(file))) FAIL_STACK_ERROR H5MF_aggr_query(f, &(f->shared->meta_aggr), &ma_addr, &ma_size); @@ -497,7 +497,7 @@ test_mf_eoa_shrink(const char *env_h5_drvr, hid_t fapl) FAIL_STACK_ERROR /* Get a pointer to the internal file object */ - if(NULL == (f = (H5F_t *)H5I_object(file))) + if(NULL == (f = (H5F_t *)H5VL_object(file))) FAIL_STACK_ERROR H5MF_aggr_query(f, &(f->shared->meta_aggr), &ma_addr, &ma_size); @@ -540,7 +540,7 @@ test_mf_eoa_shrink(const char *env_h5_drvr, hid_t fapl) FAIL_STACK_ERROR /* Get a pointer to the internal file object */ - if(NULL == (f = (H5F_t *)H5I_object(file))) + if(NULL == (f = (H5F_t *)H5VL_object(file))) FAIL_STACK_ERROR H5MF_aggr_query(f, &(f->shared->meta_aggr), &ma_addr, &ma_size); @@ -650,7 +650,7 @@ test_mf_eoa_extend(const char *env_h5_drvr, hid_t fapl) FAIL_STACK_ERROR /* Get a pointer to the internal file object */ - if(NULL == (f = (H5F_t *)H5I_object(file))) + if(NULL == (f = (H5F_t *)H5VL_object(file))) FAIL_STACK_ERROR H5MF_aggr_query(f, &(f->shared->meta_aggr), &ma_addr, &ma_size); @@ -681,7 +681,7 @@ test_mf_eoa_extend(const char *env_h5_drvr, hid_t fapl) FAIL_STACK_ERROR /* Get a pointer to the internal file object */ - if(NULL == (f = (H5F_t *)H5I_object(file))) + if(NULL == (f = (H5F_t *)H5VL_object(file))) FAIL_STACK_ERROR /* should succeed */ @@ -728,7 +728,7 @@ test_mf_eoa_extend(const char *env_h5_drvr, hid_t fapl) TEST_ERROR /* Get a pointer to the internal file object */ - if(NULL == (f = (H5F_t *)H5I_object(file))) + if(NULL == (f = (H5F_t *)H5VL_object(file))) FAIL_STACK_ERROR H5MF_aggr_query(f, &(f->shared->meta_aggr), &ma_addr, &ma_size); @@ -847,7 +847,7 @@ test_mf_tmp(const char *env_h5_drvr, hid_t fapl) FAIL_STACK_ERROR /* Get a pointer to the internal file object */ - if(NULL == (f = (H5F_t *)H5I_object(file))) + if(NULL == (f = (H5F_t *)H5VL_object(file))) FAIL_STACK_ERROR /* Retrieve the file's maxaddr */ @@ -901,7 +901,7 @@ test_mf_tmp(const char *env_h5_drvr, hid_t fapl) FAIL_STACK_ERROR /* Get a pointer to the internal file object */ - if(NULL == (f = (H5F_t *)H5I_object(file))) + if(NULL == (f = (H5F_t *)H5VL_object(file))) FAIL_STACK_ERROR /* Allocate 1/3 of the file as temporary address space */ @@ -1008,7 +1008,7 @@ test_mf_fs_start(hid_t fapl) FAIL_STACK_ERROR /* Get a pointer to the internal file object */ - if(NULL == (f = (H5F_t *)H5I_object(file))) + if(NULL == (f = (H5F_t *)H5VL_object(file))) FAIL_STACK_ERROR /* Start up free-space manager */ @@ -1126,7 +1126,7 @@ test_mf_fs_alloc_free(hid_t fapl) FAIL_STACK_ERROR /* Get a pointer to the internal file object */ - if(NULL == (f = (H5F_t *)H5I_object(file))) + if(NULL == (f = (H5F_t *)H5VL_object(file))) FAIL_STACK_ERROR type = H5FD_MEM_SUPER; @@ -1213,7 +1213,7 @@ test_mf_fs_alloc_free(hid_t fapl) FAIL_STACK_ERROR /* Get a pointer to the internal file object */ - if(NULL == (f = (H5F_t *)H5I_object(file))) + if(NULL == (f = (H5F_t *)H5VL_object(file))) FAIL_STACK_ERROR type = H5FD_MEM_SUPER; @@ -1298,7 +1298,7 @@ test_mf_fs_alloc_free(hid_t fapl) FAIL_STACK_ERROR /* Get a pointer to the internal file object */ - if(NULL == (f = (H5F_t *)H5I_object(file))) + if(NULL == (f = (H5F_t *)H5VL_object(file))) FAIL_STACK_ERROR type = H5FD_MEM_SUPER; @@ -1484,7 +1484,7 @@ test_mf_fs_extend(hid_t fapl) FAIL_STACK_ERROR /* Get a pointer to the internal file object */ - if(NULL == (f = (H5F_t *)H5I_object(file))) + if(NULL == (f = (H5F_t *)H5VL_object(file))) FAIL_STACK_ERROR type = H5FD_MEM_SUPER; @@ -1602,7 +1602,7 @@ test_mf_fs_extend(hid_t fapl) FAIL_STACK_ERROR /* Get a pointer to the internal file object */ - if(NULL == (f = (H5F_t *)H5I_object(file))) + if(NULL == (f = (H5F_t *)H5VL_object(file))) FAIL_STACK_ERROR type = H5FD_MEM_SUPER; @@ -1715,7 +1715,7 @@ test_mf_fs_extend(hid_t fapl) FAIL_STACK_ERROR /* Get a pointer to the internal file object */ - if(NULL == (f = (H5F_t *)H5I_object(file))) + if(NULL == (f = (H5F_t *)H5VL_object(file))) FAIL_STACK_ERROR type = H5FD_MEM_SUPER; @@ -1828,7 +1828,7 @@ test_mf_fs_extend(hid_t fapl) FAIL_STACK_ERROR /* Get a pointer to the internal file object */ - if(NULL == (f = (H5F_t *)H5I_object(file))) + if(NULL == (f = (H5F_t *)H5VL_object(file))) FAIL_STACK_ERROR type = H5FD_MEM_SUPER; @@ -2020,7 +2020,7 @@ test_mf_fs_absorb(const char *env_h5_drvr, hid_t fapl) FAIL_STACK_ERROR /* Get a pointer to the internal file object */ - if(NULL == (f = (H5F_t *)H5I_object(file))) + if(NULL == (f = (H5F_t *)H5VL_object(file))) FAIL_STACK_ERROR type = H5FD_MEM_SUPER; @@ -2090,7 +2090,7 @@ test_mf_fs_absorb(const char *env_h5_drvr, hid_t fapl) FAIL_STACK_ERROR /* Get a pointer to the internal file object */ - if(NULL == (f = (H5F_t *)H5I_object(file))) + if(NULL == (f = (H5F_t *)H5VL_object(file))) FAIL_STACK_ERROR type = H5FD_MEM_SUPER; @@ -2219,7 +2219,7 @@ test_mf_aggr_alloc1(const char *env_h5_drvr, hid_t fapl) FAIL_STACK_ERROR /* Get a pointer to the internal file object */ - if(NULL == (f = (H5F_t *)H5I_object(file))) + if(NULL == (f = (H5F_t *)H5VL_object(file))) FAIL_STACK_ERROR /* Allocate first block from meta_aggr */ @@ -2255,7 +2255,7 @@ test_mf_aggr_alloc1(const char *env_h5_drvr, hid_t fapl) FAIL_STACK_ERROR /* Get a pointer to the internal file object */ - if(NULL == (f = (H5F_t *)H5I_object(file))) + if(NULL == (f = (H5F_t *)H5VL_object(file))) FAIL_STACK_ERROR /* Free the two blocks */ @@ -2350,7 +2350,7 @@ test_mf_aggr_alloc2(const char *env_h5_drvr, hid_t fapl) FAIL_STACK_ERROR /* Get a pointer to the internal file object */ - if(NULL == (f = (H5F_t *)H5I_object(file))) + if(NULL == (f = (H5F_t *)H5VL_object(file))) FAIL_STACK_ERROR type = H5FD_MEM_SUPER; @@ -2396,7 +2396,7 @@ test_mf_aggr_alloc2(const char *env_h5_drvr, hid_t fapl) FAIL_STACK_ERROR /* Get a pointer to the internal file object */ - if(NULL == (f = (H5F_t *)H5I_object(file))) + if(NULL == (f = (H5F_t *)H5VL_object(file))) FAIL_STACK_ERROR H5MF_xfree(f, type, H5P_DATASET_XFER_DEFAULT, addr1, (hsize_t)TEST_BLOCK_SIZE30+TEST_BLOCK_SIZE50+TEST_BLOCK_SIZE2058); @@ -2504,7 +2504,7 @@ test_mf_aggr_alloc3(const char *env_h5_drvr, hid_t fapl) FAIL_STACK_ERROR /* Get a pointer to the internal file object */ - if(NULL == (f = (H5F_t *)H5I_object(file))) + if(NULL == (f = (H5F_t *)H5VL_object(file))) FAIL_STACK_ERROR /* Allocate first block from meta_aggr */ @@ -2665,7 +2665,7 @@ test_mf_aggr_alloc4(const char *env_h5_drvr, hid_t fapl) FAIL_STACK_ERROR /* Get a pointer to the internal file object */ - if(NULL == (f = (H5F_t *)H5I_object(file))) + if(NULL == (f = (H5F_t *)H5VL_object(file))) FAIL_STACK_ERROR /* Allocate first block from meta_aggr */ @@ -2811,7 +2811,7 @@ test_mf_aggr_alloc5(const char *env_h5_drvr, hid_t fapl) FAIL_STACK_ERROR /* Get a pointer to the internal file object */ - if(NULL == (f = (H5F_t *)H5I_object(file))) + if(NULL == (f = (H5F_t *)H5VL_object(file))) FAIL_STACK_ERROR /* Allocate first block from meta_aggr */ @@ -2943,7 +2943,7 @@ test_mf_aggr_alloc6(const char *env_h5_drvr, hid_t fapl) FAIL_STACK_ERROR /* Get a pointer to the internal file object */ - if(NULL == (f = (H5F_t *)H5I_object(file))) + if(NULL == (f = (H5F_t *)H5VL_object(file))) FAIL_STACK_ERROR type = H5FD_MEM_SUPER; @@ -3108,7 +3108,7 @@ test_mf_aggr_alloc7(const char *env_h5_drvr, hid_t fapl) FAIL_STACK_ERROR /* Get a pointer to the internal file object */ - if(NULL == (f = (H5F_t *)H5I_object(file))) + if(NULL == (f = (H5F_t *)H5VL_object(file))) FAIL_STACK_ERROR /* Allocate the first block from meta_aggr */ @@ -3269,7 +3269,7 @@ test_mf_aggr_extend(const char *env_h5_drvr, hid_t fapl) FAIL_STACK_ERROR /* Get a pointer to the internal file object */ - if(NULL == (f = (H5F_t *)H5I_object(file))) + if(NULL == (f = (H5F_t *)H5VL_object(file))) FAIL_STACK_ERROR /* Allocate the first block from meta_aggr */ @@ -3360,7 +3360,7 @@ test_mf_aggr_extend(const char *env_h5_drvr, hid_t fapl) FAIL_STACK_ERROR /* Get a pointer to the internal file object */ - if(NULL == (f = (H5F_t *)H5I_object(file))) + if(NULL == (f = (H5F_t *)H5VL_object(file))) FAIL_STACK_ERROR /* Allocate the first block from meta_aggr */ @@ -3430,7 +3430,7 @@ test_mf_aggr_extend(const char *env_h5_drvr, hid_t fapl) FAIL_STACK_ERROR /* Get a pointer to the internal file object */ - if(NULL == (f = (H5F_t *)H5I_object(file))) + if(NULL == (f = (H5F_t *)H5VL_object(file))) FAIL_STACK_ERROR /* Allocate first block from meta_aggr */ @@ -3562,7 +3562,7 @@ test_mf_aggr_absorb(const char *env_h5_drvr, hid_t fapl) FAIL_STACK_ERROR /* Get a pointer to the internal file object */ - if(NULL == (f = (H5F_t *)H5I_object(file))) + if(NULL == (f = (H5F_t *)H5VL_object(file))) FAIL_STACK_ERROR /* Allocate block A from meta_aggr */ @@ -3609,7 +3609,7 @@ test_mf_aggr_absorb(const char *env_h5_drvr, hid_t fapl) FAIL_STACK_ERROR /* Get a pointer to the internal file object */ - if(NULL == (f = (H5F_t *)H5I_object(file))) + if(NULL == (f = (H5F_t *)H5VL_object(file))) FAIL_STACK_ERROR /* Allocate block A from meta_aggr */ @@ -3668,7 +3668,7 @@ test_mf_aggr_absorb(const char *env_h5_drvr, hid_t fapl) FAIL_STACK_ERROR /* Get a pointer to the internal file object */ - if(NULL == (f = (H5F_t *)H5I_object(file))) + if(NULL == (f = (H5F_t *)H5VL_object(file))) FAIL_STACK_ERROR /* Allocate block A from meta_aggr */ @@ -3815,7 +3815,7 @@ test_mf_align_eoa(const char *env_h5_drvr, hid_t fapl, hid_t new_fapl) FAIL_STACK_ERROR /* Get a pointer to the internal file object */ - if(NULL == (f = (H5F_t *)H5I_object(file))) + if(NULL == (f = (H5F_t *)H5VL_object(file))) FAIL_STACK_ERROR /* calculate fragment for alignment of block 30 */ @@ -3897,7 +3897,7 @@ test_mf_align_eoa(const char *env_h5_drvr, hid_t fapl, hid_t new_fapl) FAIL_STACK_ERROR /* Get a pointer to the internal file object */ - if(NULL == (f = (H5F_t *)H5I_object(file))) + if(NULL == (f = (H5F_t *)H5VL_object(file))) FAIL_STACK_ERROR /* allocate a block of 50 from meta_aggr */ @@ -3919,7 +3919,7 @@ test_mf_align_eoa(const char *env_h5_drvr, hid_t fapl, hid_t new_fapl) FAIL_STACK_ERROR /* Get a pointer to the internal file object */ - if(NULL == (f = (H5F_t *)H5I_object(file))) + if(NULL == (f = (H5F_t *)H5VL_object(file))) FAIL_STACK_ERROR /* shrink the block */ @@ -3952,7 +3952,7 @@ test_mf_align_eoa(const char *env_h5_drvr, hid_t fapl, hid_t new_fapl) FAIL_STACK_ERROR /* Get a pointer to the internal file object */ - if(NULL == (f = (H5F_t *)H5I_object(file))) + if(NULL == (f = (H5F_t *)H5VL_object(file))) FAIL_STACK_ERROR /* allocate a block of 50 */ @@ -3974,7 +3974,7 @@ test_mf_align_eoa(const char *env_h5_drvr, hid_t fapl, hid_t new_fapl) FAIL_STACK_ERROR /* Get a pointer to the internal file object */ - if(NULL == (f = (H5F_t *)H5I_object(file))) + if(NULL == (f = (H5F_t *)H5VL_object(file))) FAIL_STACK_ERROR /* try to extend the block */ @@ -4078,7 +4078,7 @@ test_mf_align_fs(const char *env_h5_drvr, hid_t fapl, hid_t new_fapl) FAIL_STACK_ERROR /* Get a pointer to the internal file object */ - if(NULL == (f = (H5F_t *)H5I_object(file))) + if(NULL == (f = (H5F_t *)H5VL_object(file))) FAIL_STACK_ERROR type = H5FD_MEM_SUPER; @@ -4148,7 +4148,7 @@ test_mf_align_fs(const char *env_h5_drvr, hid_t fapl, hid_t new_fapl) FAIL_STACK_ERROR /* Get a pointer to the internal file object */ - if(NULL == (f = (H5F_t *)H5I_object(file))) + if(NULL == (f = (H5F_t *)H5VL_object(file))) FAIL_STACK_ERROR type = H5FD_MEM_SUPER; @@ -4238,7 +4238,7 @@ test_mf_align_fs(const char *env_h5_drvr, hid_t fapl, hid_t new_fapl) FAIL_STACK_ERROR /* Get a pointer to the internal file object */ - if(NULL == (f = (H5F_t *)H5I_object(file))) + if(NULL == (f = (H5F_t *)H5VL_object(file))) FAIL_STACK_ERROR type = H5FD_MEM_SUPER; @@ -4463,7 +4463,7 @@ test_mf_align_alloc1(const char *env_h5_drvr, hid_t fapl, hid_t new_fapl) FAIL_STACK_ERROR /* Get a pointer to the internal file object */ - if(NULL == (f = (H5F_t *)H5I_object(file))) + if(NULL == (f = (H5F_t *)H5VL_object(file))) FAIL_STACK_ERROR /* calculate fragment for alignment of block 30 */ @@ -4721,7 +4721,7 @@ test_mf_align_alloc2(const char *env_h5_drvr, hid_t fapl, hid_t new_fapl) FAIL_STACK_ERROR /* Get a pointer to the internal file object */ - if(NULL == (f = (H5F_t *)H5I_object(file))) + if(NULL == (f = (H5F_t *)H5VL_object(file))) FAIL_STACK_ERROR /* calculate fragment for alignment of block 30 */ @@ -5063,7 +5063,7 @@ test_mf_align_alloc3(const char *env_h5_drvr, hid_t fapl, hid_t new_fapl) FAIL_STACK_ERROR /* Get a pointer to the internal file object */ - if(NULL == (f = (H5F_t *)H5I_object(file))) + if(NULL == (f = (H5F_t *)H5VL_object(file))) FAIL_STACK_ERROR /* calculate fragment for alignment of block 30 */ @@ -5362,7 +5362,7 @@ test_mf_align_alloc4(const char *env_h5_drvr, hid_t fapl, hid_t new_fapl) FAIL_STACK_ERROR /* Get a pointer to the internal file object */ - if(NULL == (f = (H5F_t *)H5I_object(file))) + if(NULL == (f = (H5F_t *)H5VL_object(file))) FAIL_STACK_ERROR /* get alignment setting */ @@ -5575,7 +5575,7 @@ test_mf_align_alloc5(const char *env_h5_drvr, hid_t fapl, hid_t new_fapl) FAIL_STACK_ERROR /* Get a pointer to the internal file object */ - if(NULL == (f = (H5F_t *)H5I_object(file))) + if(NULL == (f = (H5F_t *)H5VL_object(file))) FAIL_STACK_ERROR /* get alignment setting */ @@ -5841,7 +5841,7 @@ test_mf_align_alloc6(const char *env_h5_drvr, hid_t fapl, hid_t new_fapl) FAIL_STACK_ERROR /* Get a pointer to the internal file object */ - if(NULL == (f = (H5F_t *)H5I_object(file))) + if(NULL == (f = (H5F_t *)H5VL_object(file))) FAIL_STACK_ERROR /* get alignment setting */ @@ -6018,7 +6018,7 @@ test_mf_fs_persist(hid_t fapl_new, hid_t fcpl) FAIL_STACK_ERROR /* Get a pointer to the internal file object */ - if(NULL == (f = (H5F_t *)H5I_object(file))) + if(NULL == (f = (H5F_t *)H5VL_object(file))) FAIL_STACK_ERROR /* Allocate 6 blocks */ @@ -6052,7 +6052,7 @@ test_mf_fs_persist(hid_t fapl_new, hid_t fcpl) FAIL_STACK_ERROR /* Get a pointer to the internal file object */ - if(NULL == (f = (H5F_t *)H5I_object(file))) + if(NULL == (f = (H5F_t *)H5VL_object(file))) FAIL_STACK_ERROR /* Verify that H5FD_MEM_SUPER free-space manager is there */ @@ -6094,7 +6094,7 @@ test_mf_fs_persist(hid_t fapl_new, hid_t fcpl) FAIL_STACK_ERROR /* Get a pointer to the internal file object */ - if(NULL == (f = (H5F_t *)H5I_object(file))) + if(NULL == (f = (H5F_t *)H5VL_object(file))) FAIL_STACK_ERROR /* Verify that H5FD_MEM_SUPER free-space manager is there */ @@ -6144,7 +6144,7 @@ test_mf_fs_gone(hid_t fapl_new, hid_t fcpl) FAIL_STACK_ERROR /* Get a pointer to the internal file object */ - if(NULL == (f = (H5F_t *)H5I_object(file))) + if(NULL == (f = (H5F_t *)H5VL_object(file))) FAIL_STACK_ERROR /* Allocate 4 blocks */ @@ -6178,7 +6178,7 @@ test_mf_fs_gone(hid_t fapl_new, hid_t fcpl) FAIL_STACK_ERROR /* Get a pointer to the internal file object */ - if(NULL == (f = (H5F_t *)H5I_object(file))) + if(NULL == (f = (H5F_t *)H5VL_object(file))) FAIL_STACK_ERROR /* Verify that the H5FD_MEM_SUPER free-space manager is not there */ @@ -6197,7 +6197,7 @@ test_mf_fs_gone(hid_t fapl_new, hid_t fcpl) FAIL_STACK_ERROR /* Get a pointer to the internal file object */ - if(NULL == (f = (H5F_t *)H5I_object(file))) + if(NULL == (f = (H5F_t *)H5VL_object(file))) FAIL_STACK_ERROR /* Verify that H5FD_MEM_SUPER free-space manager is there */ @@ -6231,7 +6231,7 @@ test_mf_fs_gone(hid_t fapl_new, hid_t fcpl) FAIL_STACK_ERROR /* Get a pointer to the internal file object */ - if(NULL == (f = (H5F_t *)H5I_object(file))) + if(NULL == (f = (H5F_t *)H5VL_object(file))) FAIL_STACK_ERROR /* Verify that the H5FD_MEM_SUPER free-space manager is not there */ @@ -6279,7 +6279,7 @@ test_mf_fs_split(hid_t fapl_new, hid_t fcpl) FAIL_STACK_ERROR /* Get a pointer to the internal file object */ - if(NULL == (f = (H5F_t *)H5I_object(file))) + if(NULL == (f = (H5F_t *)H5VL_object(file))) FAIL_STACK_ERROR /* Allocate 4 blocks of type H5FD_MEM_SUPER */ @@ -6324,7 +6324,7 @@ test_mf_fs_split(hid_t fapl_new, hid_t fcpl) FAIL_STACK_ERROR /* Get a pointer to the internal file object */ - if(NULL == (f = (H5F_t *)H5I_object(file))) + if(NULL == (f = (H5F_t *)H5VL_object(file))) FAIL_STACK_ERROR /* Verify that the H5FD_MEM_SUPER free-space manager is there */ @@ -6408,7 +6408,7 @@ test_mf_fs_split(hid_t fapl_new, hid_t fcpl) FAIL_STACK_ERROR /* Get a pointer to the internal file object */ - if(NULL == (f = (H5F_t *)H5I_object(file))) + if(NULL == (f = (H5F_t *)H5VL_object(file))) FAIL_STACK_ERROR /* Verify that the free-space manager for H5FD_MEM_DRAW is not there */ @@ -6452,7 +6452,7 @@ test_mf_fs_split(hid_t fapl_new, hid_t fcpl) FAIL_STACK_ERROR /* Get a pointer to the internal file object */ - if(NULL == (f = (H5F_t *)H5I_object(file))) + if(NULL == (f = (H5F_t *)H5VL_object(file))) FAIL_STACK_ERROR /* Verify that the H5FD_MEM_SUPER free-space manager is there */ @@ -6514,7 +6514,7 @@ test_mf_fs_multi(hid_t fapl_new, hid_t fcpl) FAIL_STACK_ERROR /* Get a pointer to the internal file object */ - if(NULL == (f = (H5F_t *)H5I_object(file))) + if(NULL == (f = (H5F_t *)H5VL_object(file))) FAIL_STACK_ERROR /* Allocate 4 blocks of type H5FD_MEM_SUPER */ @@ -6559,7 +6559,7 @@ test_mf_fs_multi(hid_t fapl_new, hid_t fcpl) FAIL_STACK_ERROR /* Get a pointer to the internal file object */ - if(NULL == (f = (H5F_t *)H5I_object(file))) + if(NULL == (f = (H5F_t *)H5VL_object(file))) FAIL_STACK_ERROR /* Verify that the H5FD_MEM_SUPER free-space manager is there */ @@ -6641,7 +6641,7 @@ test_mf_fs_multi(hid_t fapl_new, hid_t fcpl) FAIL_STACK_ERROR /* Get a pointer to the internal file object */ - if(NULL == (f = (H5F_t *)H5I_object(file))) + if(NULL == (f = (H5F_t *)H5VL_object(file))) FAIL_STACK_ERROR /* Verify that the free-space manager for H5FD_MEM_SUPER is there */ @@ -6707,7 +6707,7 @@ test_mf_fs_multi(hid_t fapl_new, hid_t fcpl) FAIL_STACK_ERROR /* Get a pointer to the internal file object */ - if(NULL == (f = (H5F_t *)H5I_object(file))) + if(NULL == (f = (H5F_t *)H5VL_object(file))) FAIL_STACK_ERROR /* If H5FD_MEM_SUPER is there, should not find block #1 & #3 */ @@ -6972,7 +6972,7 @@ test_filespace_strategy_threshold(hid_t fapl_new) FAIL_STACK_ERROR /* Get a pointer to the internal file object */ - if(NULL == (f = (H5F_t *)H5I_object(file))) + if(NULL == (f = (H5F_t *)H5VL_object(file))) FAIL_STACK_ERROR /* Allocate 6 blocks */ @@ -7016,7 +7016,7 @@ test_filespace_strategy_threshold(hid_t fapl_new) FAIL_STACK_ERROR /* Get a pointer to the internal file object */ - if(NULL == (f = (H5F_t *)H5I_object(file))) + if(NULL == (f = (H5F_t *)H5VL_object(file))) FAIL_STACK_ERROR switch(fs_type) { @@ -7124,7 +7124,7 @@ test_filespace_gone(hid_t fapl_new) FAIL_STACK_ERROR /* Get a pointer to the internal file object */ - if(NULL == (f = (H5F_t *)H5I_object(file))) + if(NULL == (f = (H5F_t *)H5VL_object(file))) FAIL_STACK_ERROR /* Allocate 6 blocks */ @@ -7192,7 +7192,7 @@ test_filespace_gone(hid_t fapl_new) FAIL_STACK_ERROR /* Get a pointer to the internal file object */ - if(NULL == (f = (H5F_t *)H5I_object(file))) + if(NULL == (f = (H5F_t *)H5VL_object(file))) FAIL_STACK_ERROR /* free-space manager should be empty */ @@ -7391,7 +7391,7 @@ test_dichotomy(const char *env_h5_drvr, hid_t fapl) FAIL_STACK_ERROR /* Get a pointer to the internal file object */ - if(NULL == (f = (H5F_t *)H5I_object(file))) + if(NULL == (f = (H5F_t *)H5VL_object(file))) FAIL_STACK_ERROR /* Allocate the first block of type H5FD_MEM_SUPER */ diff --git a/test/ohdr.c b/test/ohdr.c index 502a8b1..0e29e71 100644 --- a/test/ohdr.c +++ b/test/ohdr.c @@ -73,7 +73,7 @@ test_cont(char *filename, hid_t fapl) /* Create the file to operate on */ if((file = H5Fcreate(filename, H5F_ACC_TRUNC, H5P_DEFAULT, fapl)) < 0) TEST_ERROR - if(NULL == (f = (H5F_t *)H5I_object(file))) FAIL_STACK_ERROR + if(NULL == (f = (H5F_t *)H5VL_object(file))) FAIL_STACK_ERROR if (H5AC_ignore_tags(f) < 0) { H5_FAILED(); H5Eprint2(H5E_DEFAULT, stdout); @@ -200,7 +200,7 @@ test_ohdr_cache(char *filename, hid_t fapl) FAIL_STACK_ERROR if(H5Pclose(my_fapl) < 0) FAIL_STACK_ERROR - if(NULL == (f = (H5F_t *)H5I_object(file))) + if(NULL == (f = (H5F_t *)H5VL_object(file))) FAIL_STACK_ERROR if(H5AC_ignore_tags(f) < 0) FAIL_STACK_ERROR @@ -348,7 +348,7 @@ main(void) /* Create the file to operate on */ if((file = H5Fcreate(filename, H5F_ACC_TRUNC, H5P_DEFAULT, fapl)) < 0) TEST_ERROR - if(NULL == (f = (H5F_t *)H5I_object(file))) + if(NULL == (f = (H5F_t *)H5VL_object(file))) FAIL_STACK_ERROR if (H5AC_ignore_tags(f) < 0) { H5_FAILED(); @@ -449,7 +449,7 @@ main(void) FAIL_STACK_ERROR if((file = H5Fopen(filename, H5F_ACC_RDWR, fapl)) < 0) FAIL_STACK_ERROR - if(NULL == (f = (H5F_t *)H5I_object(file))) + if(NULL == (f = (H5F_t *)H5VL_object(file))) FAIL_STACK_ERROR if (H5AC_ignore_tags(f) < 0) FAIL_STACK_ERROR diff --git a/test/test_vol_plugin.sh.in b/test/test_vol_plugin.sh.in new file mode 100644 index 0000000..ae6c768 --- /dev/null +++ b/test/test_vol_plugin.sh.in @@ -0,0 +1,80 @@ +#! /bin/sh +# +# Copyright by The HDF Group. +# All rights reserved. +# +# This file is part of HDF5. The full HDF5 copyright notice, including +# terms governing use, modification, and redistribution, is contained in +# the files COPYING and Copyright.html. COPYING can be found at the root +# of the source code distribution tree; Copyright.html can be found at the +# root level of an installed copy of the electronic document set and is +# linked from the top-level documents page. It can also be found at +# http://hdfgroup.org/HDF5/doc/Copyright.html. If you do not have access +# to either file, you may request a copy from help@hdfgroup.org. +# +srcdir=@srcdir@ +TOP_BUILDDIR=@top_builddir@ + +# Determine backward compatibility options enabled +DEPRECATED_SYMBOLS="@DEPRECATED_SYMBOLS@" + +EXIT_SUCCESS=0 +EXIT_FAILURE=1 + +nerrors=0 +verbose=yes +exit_code=$EXIT_SUCCESS + +TEST_NAME=vol_test +TEST_BIN=`pwd`/$TEST_NAME +FROM_DIR=`pwd`/.libs +PLUGIN_LIB="$FROM_DIR/libdynlibvol1.* $FROM_DIR/libdynlibvol2.*" +PLUGIN_LIBDIR=voltestdir +CP="cp -p" # Use -p to preserve mode,ownership,timestamps +RM="rm -rf" + +# Print a line-line message left justified in a field of 70 characters +# beginning with the word "Testing". +# +TESTING() { + SPACES=" " + echo "Testing $* $SPACES" | cut -c1-70 | tr -d '\012' +} + +# Main Body +# Create test directories if not exists yet. +test -d $PLUGIN_LIBDIR || mkdir -p $PLUGIN_LIBDIR +if [ $? != 0 ]; then + echo "Failed to create test directory($PLUGIN_LIBDIR)" + exit $EXIT_FAILURE +fi + +# copy plugin library for test +$CP $PLUGIN_LIB $PLUGIN_LIBDIR +if [ $? != 0 ]; then + echo "Failed to copy plugin library ($PLUGIN_LIB) for test." + exit $EXIT_FAILURE +fi + +# setup plugin path +ENVCMD="env HDF5_PLUGIN_PATH=${PLUGIN_LIBDIR}" + +# Run the test +$ENVCMD $TEST_BIN +if [ $? != 0 ]; then + nerrors=`expr $nerrors + 1` +fi + +# print results +if test $nerrors -ne 0 ; then + echo "$nerrors errors encountered" + exit_code=$EXIT_FAILURE +else + echo "All VOL Plugin API tests passed." + exit_code=$EXIT_SUCCESS +fi + +# Clean up temporary files/directories and leave +$RM $PLUGIN_LIBDIR + +exit $exit_code diff --git a/test/testfiles/err_compat_1 b/test/testfiles/err_compat_1 index d471e13..cea08f7 100644 --- a/test/testfiles/err_compat_1 +++ b/test/testfiles/err_compat_1 @@ -12,18 +12,12 @@ HDF5-DIAG: Error detected in HDF5 (version (number)) thread (IDs): minor: Bad value HDF5-DIAG: Error detected in HDF5 (version (number)) thread (IDs): - #000: (file name) line (number) in H5Dcreate2(): not a location ID + #000: (file name) line (number) in H5Dcreate2(): invalid location identifier major: Invalid arguments to routine minor: Inappropriate type - #001: (file name) line (number) in H5G_loc(): invalid object ID - major: Invalid arguments to routine - minor: Bad value ********* Print error stack in customized way ********* - error #000: (file name) in H5G_loc(): line (number) - major: Invalid arguments to routine - minor: Bad value - error #001: (file name) in H5Dcreate2(): line (number) + error #000: (file name) in H5Dcreate2(): line (number) major: Invalid arguments to routine minor: Inappropriate type @@ -33,19 +27,13 @@ HDF5-DIAG: Error detected in HDF5 (version (number)) thread (IDs): minor: Can't get value ********* Print error stack in customized way ********* - error #000: (file name) in H5G_loc(): line (number) - major: Invalid arguments to routine - minor: Bad value - error #001: (file name) in H5Dcreate2(): line (number) + error #000: (file name) in H5Dcreate2(): line (number) major: Invalid arguments to routine minor: Inappropriate type HDF5-DIAG: Error detected in HDF5 (version (number)) thread (IDs): - #000: (file name) line (number) in H5Dcreate2(): not a location ID + #000: (file name) line (number) in H5Dcreate2(): invalid location identifier major: Invalid arguments to routine minor: Inappropriate type - #001: (file name) line (number) in H5G_loc(): invalid object ID - major: Invalid arguments to routine - minor: Bad value HDF5-DIAG: Error detected in HDF5 (version (number)) thread (IDs): #000: (file name) line (number) in main(): Error test failed diff --git a/test/testfiles/error_test_1 b/test/testfiles/error_test_1 index 0acd288..0efab28 100644 --- a/test/testfiles/error_test_1 +++ b/test/testfiles/error_test_1 @@ -41,19 +41,25 @@ 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 H5D__read(): can't read data + #001: (file name) line (number) in H5VL_dataset_read(): read failed + major: Virtual Object Layer + minor: Read failed + #002: (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 major: Dataset minor: Read failed - #002: (file name) line (number) in H5D__chunk_read(): unable to read raw data chunk + #004: (file name) line (number) in H5D__chunk_read(): unable to read raw data chunk major: Low-level I/O minor: Read failed - #003: (file name) line (number) in H5D__chunk_lock(): data pipeline read failed + #005: (file name) line (number) in H5D__chunk_lock(): data pipeline read failed major: Data filters minor: Filter operation failed - #004: (file name) line (number) in H5Z_pipeline(): required filter 'bogus' is not registered + #006: (file name) line (number) in H5Z_pipeline(): required filter 'bogus' is not registered major: Data filters minor: Read failed - #005: (file name) line (number) in H5PL_load(): required dynamically loaded plugin filter '305' is not available + #007: (file name) line (number) in H5PL_load(): required dynamically loaded plugin filter '305' is not available major: Plugin for dynamically loaded library minor: Unable to load metadata into cache diff --git a/test/tfile.c b/test/tfile.c index 4bef41c..3a942c0 100644 --- a/test/tfile.c +++ b/test/tfile.c @@ -1577,15 +1577,47 @@ test_file_freespace(void) VERIFY(mod_filesize, empty_filesize, "H5Fget_freespace"); } /* end test_file_freespace() */ +static void +test_file_isaccessible_helper(const char *filename, htri_t expected) +{ + htri_t status; /* Whether a file is an HDF5 file */ + hid_t fapl; /* File access property list */ + herr_t ret; + + fapl = H5Pcreate(H5P_FILE_ACCESS); + CHECK(fapl, FAIL, "H5Pcreate"); + + /* Verify that the file is an HDF5 file with the sec2 default driver*/ + status = H5Fis_accessible(filename, fapl); + VERIFY(status, expected, "H5Fis_accessible"); + + /* Verify that the file is an HDF5 file with the core VFD*/ + ret = H5Pset_fapl_core(fapl, (size_t)1024, 0); + CHECK(ret, FAIL, "H5Pset_fapl_core"); + status = H5Fis_accessible(filename, fapl); + VERIFY(status, expected, "H5Fis_accessible"); + +#ifdef H5_HAVE_DIRECT + /* Verify that the file is an HDF5 file with the direct VFD*/ + ret = H5Pset_fapl_direct(fapl, 1024, 4096, 8*4096); + CHECK(ret, FAIL, "H5Pset_fapl_direct"); + status = H5Fis_accessible(filename, fapl); + VERIFY(status, expected, "H5Fis_accessible"); +#endif + + ret = H5Pclose (fapl); + CHECK(ret, FAIL, "H5Pclose"); +} + /**************************************************************** ** -** test_file_ishdf5(): low-level file test routine. -** This test checks whether the H5Fis_hdf5() routine is working +** test_file_isaccessible(): low-level file test routine. +** This test checks whether the H5Fis_accessible() routine is working ** correctly in variuous situations. ** *****************************************************************/ static void -test_file_ishdf5(void) +test_file_isaccessible(void) { hid_t file; /* File opened with read-write permission */ hid_t fcpl; /* File creation property list */ @@ -1593,7 +1625,6 @@ test_file_ishdf5(void) ssize_t nbytes; /* Number of bytes written */ unsigned u; /* Local index variable */ unsigned char buf[1024]; /* Buffer of data to write */ - htri_t status; /* Whether a file is an HDF5 file */ herr_t ret; /* Output message about test being performed */ @@ -1608,9 +1639,7 @@ test_file_ishdf5(void) CHECK(ret, FAIL, "H5Fclose"); /* Verify that the file is an HDF5 file */ - status = H5Fis_hdf5(FILE1); - VERIFY(status, TRUE, "H5Fis_hdf5"); - + test_file_isaccessible_helper(FILE1, TRUE); /* Create a file creation property list with a non-default user block size */ fcpl = H5Pcreate(H5P_FILE_CREATE); @@ -1632,9 +1661,7 @@ test_file_ishdf5(void) CHECK(ret, FAIL, "H5Fclose"); /* Verify that the file is an HDF5 file */ - status = H5Fis_hdf5(FILE1); - VERIFY(status, TRUE, "H5Fis_hdf5"); - + test_file_isaccessible_helper(FILE1, TRUE); /* Create non-HDF5 file and check it */ fd=HDopen(FILE1, O_RDWR|O_CREAT|O_TRUNC, 0666); @@ -1652,11 +1679,10 @@ test_file_ishdf5(void) ret = HDclose(fd); CHECK(ret, FAIL, "HDclose"); - /* Verify that the file is not an HDF5 file */ - status = H5Fis_hdf5(FILE1); - VERIFY(status, FALSE, "H5Fis_hdf5"); + /* Verify that the file is NOT an HDF5 file */ + test_file_isaccessible_helper(FILE1, FALSE); -} /* end test_file_ishdf5() */ +} /* end test_file_isaccessible() */ /**************************************************************** ** @@ -3660,7 +3686,7 @@ test_file(void) test_file_perm(); /* Test file access permissions */ test_file_perm2(); /* Test file access permission again */ test_file_freespace(); /* Test file free space information */ - test_file_ishdf5(); /* Test detecting HDF5 files correctly */ + test_file_isaccessible(); /* Test detecting HDF5 files correctly */ test_file_open_dot(); /* Test opening objects with "." for a name */ #ifndef H5_CANNOT_OPEN_TWICE test_file_open_overlap(); /* Test opening files in an overlapping manner */ diff --git a/test/tmisc.c b/test/tmisc.c index cac6b04..725a720 100644 --- a/test/tmisc.c +++ b/test/tmisc.c @@ -2666,8 +2666,8 @@ test_misc15(void) CHECK(ret, FAIL, "H5Fclose"); /* Verify that the file is still OK */ - ret = H5Fis_hdf5(MISC15_FILE); - CHECK(ret, FAIL, "H5Fis_hdf5"); + ret = H5Fis_accessible(MISC15_FILE, H5P_DEFAULT); + CHECK(ret, FAIL, "H5Fis_accessible"); file = H5Fopen(MISC15_FILE, H5F_ACC_RDONLY, H5P_DEFAULT); CHECK(file, FAIL, "H5Fopen"); diff --git a/test/ttsafe_error.c b/test/ttsafe_error.c index b81a7ad..0f89946 100644 --- a/test/ttsafe_error.c +++ b/test/ttsafe_error.c @@ -52,7 +52,7 @@ /* Having a common dataset name is an error */ #define DATASETNAME "commonname" -#define EXPECTED_ERROR_DEPTH 8 +#define EXPECTED_ERROR_DEPTH 9 #define WRITE_NUMBER 37 static herr_t error_callback(hid_t , void *); @@ -67,7 +67,7 @@ typedef struct err_num_struct { hid_t min_num; } err_num_t; -err_num_t expected[8]; +err_num_t expected[9]; int error_flag = 0; int error_count = 0; @@ -85,23 +85,29 @@ void tts_error(void) expected[0].maj_num = H5E_DATASET; expected[0].min_num = H5E_CANTINIT; - expected[1].maj_num = H5E_DATASET; + expected[1].maj_num = H5E_VOL; expected[1].min_num = H5E_CANTINIT; - expected[2].maj_num = H5E_LINK; + expected[2].maj_num = H5E_DATASET; expected[2].min_num = H5E_CANTINIT; - expected[3].maj_num = H5E_SYM; - expected[3].min_num = H5E_CANTINSERT; + expected[3].maj_num = H5E_DATASET; + expected[3].min_num = H5E_CANTINIT; - expected[4].maj_num = H5E_SYM; - expected[4].min_num = H5E_NOTFOUND; + expected[4].maj_num = H5E_LINK; + expected[4].min_num = H5E_CANTINIT; expected[5].maj_num = H5E_SYM; - expected[5].min_num = H5E_CALLBACK; + expected[5].min_num = H5E_CANTINSERT; expected[6].maj_num = H5E_SYM; - expected[6].min_num = H5E_EXISTS; + expected[6].min_num = H5E_NOTFOUND; + + expected[7].maj_num = H5E_SYM; + expected[7].min_num = H5E_CALLBACK; + + expected[8].maj_num = H5E_SYM; + expected[8].min_num = H5E_EXISTS; /* set up mutex for global count of errors */ H5TS_mutex_init(&error_mutex); @@ -106,10 +106,6 @@ test_sec2(void) if(H5FD_SEC2 != H5Pget_driver(access_fapl)) TEST_ERROR; - /* ...and close the property list */ - if(H5Pclose(access_fapl) < 0) - TEST_ERROR; - /* Check file handle API */ if(H5Fget_vfd_handle(file, H5P_DEFAULT, (void **)&fhandle) < 0) TEST_ERROR; @@ -129,6 +125,14 @@ test_sec2(void) if(H5Fclose(file) < 0) TEST_ERROR; + /* Verify that the file is an HDF5 file */ + if(H5Fis_accessible(filename, access_fapl) != TRUE) + TEST_ERROR; + + /* ...and close the property list */ + if(H5Pclose(access_fapl) < 0) + TEST_ERROR; + h5_cleanup(FILENAME, fapl); PASSED(); return 0; @@ -216,10 +220,6 @@ test_direct(void) if(H5FD_DIRECT != H5Pget_driver(access_fapl)) TEST_ERROR; - /* ...and close the property list */ - if (H5Pclose(access_fapl) < 0) - TEST_ERROR; - /* Check file handle API */ if(H5Fget_vfd_handle(file, H5P_DEFAULT, (void **)&fhandle) < 0) TEST_ERROR; @@ -333,6 +333,14 @@ test_direct(void) HDassert(check); HDfree(check); + /* Verify that the file is an HDF5 file */ + if(H5Fis_accessible(filename, access_fapl) != TRUE) + TEST_ERROR; + + /* ...and close the property list */ + if(H5Pclose(access_fapl) < 0) + TEST_ERROR; + h5_cleanup(FILENAME, fapl); PASSED(); return 0; @@ -438,12 +446,19 @@ test_core(void) if(H5Fclose(file) < 0) TEST_ERROR; + /* Verify that the file is an HDF5 file */ + if(H5Fis_accessible(filename, fapl) != TRUE) + TEST_ERROR; /* Open the file with backing store off for read and write. * Changes won't be saved in file. */ if(H5Pset_fapl_core(fapl, (size_t)CORE_INCREMENT, FALSE) < 0) TEST_ERROR; + /* Verify that the file is an HDF5 file */ + if(H5Fis_accessible(filename, fapl) != TRUE) + TEST_ERROR; + if((file=H5Fopen(filename, H5F_ACC_RDWR, fapl)) < 0) TEST_ERROR; @@ -501,6 +516,10 @@ test_core(void) if(H5Fclose(file) < 0) TEST_ERROR; + /* Verify that the file is an HDF5 file */ + if(H5Fis_accessible(filename, fapl) != TRUE) + TEST_ERROR; + /* Open the file with backing store on for read and write. * Changes will be saved in file. */ if(H5Pset_fapl_core(fapl, (size_t)CORE_INCREMENT, TRUE) < 0) @@ -610,6 +629,12 @@ test_family_opens(char *fname, hid_t fa_pl) /* Case 1: reopen file with 1st member file name and default property list */ HDsnprintf(first_name, sizeof(first_name), fname, 0); + /* Verify that the file is not accessible */ + H5E_BEGIN_TRY { + if(H5Fis_accessible(first_name, H5P_DEFAULT) != FALSE) + TEST_ERROR; + } H5E_END_TRY; + H5E_BEGIN_TRY { file = H5Fopen(first_name, H5F_ACC_RDWR, H5P_DEFAULT); } H5E_END_TRY; @@ -617,6 +642,11 @@ test_family_opens(char *fname, hid_t fa_pl) TEST_ERROR /* Case 2: reopen file with correct name template but default property list */ + + /* Verify that the file is not accessible */ + if(H5Fis_accessible(fname, H5P_DEFAULT) != FALSE) + TEST_ERROR; + H5E_BEGIN_TRY { file = H5Fopen(fname, H5F_ACC_RDWR, H5P_DEFAULT); } H5E_END_TRY; @@ -627,6 +657,10 @@ test_family_opens(char *fname, hid_t fa_pl) if(H5Pset_fapl_family(fa_pl, (hsize_t)128, H5P_DEFAULT) < 0) TEST_ERROR; + /* Verify that the file is not accessible */ + if(H5Fis_accessible(fname, fa_pl) != FALSE) + TEST_ERROR; + H5E_BEGIN_TRY { file = H5Fopen(fname, H5F_ACC_RDWR, fa_pl); } H5E_END_TRY; @@ -644,6 +678,10 @@ test_family_opens(char *fname, hid_t fa_pl) if(H5Pset_fapl_family(fa_pl, (hsize_t)FAMILY_SIZE, H5P_DEFAULT) < 0) TEST_ERROR; + /* Verify that the file is not accessible */ + if(H5Fis_accessible(wrong_name, fa_pl) != FALSE) + TEST_ERROR; + H5E_BEGIN_TRY { file = H5Fopen(wrong_name, H5F_ACC_RDWR, fa_pl); } H5E_END_TRY; @@ -707,6 +745,10 @@ test_family(void) if(H5Pset_fapl_family(fapl, (hsize_t)H5F_FAMILY_DEFAULT, H5P_DEFAULT) < 0) TEST_ERROR; + /* Verify that the file is accessible with correct fapl */ + if(H5Fis_accessible(filename, fapl) != TRUE) + TEST_ERROR; + if((file=H5Fopen(filename, H5F_ACC_RDWR, fapl)) < 0) TEST_ERROR; @@ -871,6 +913,10 @@ test_family_compat(void) HDsnprintf(pathname_individual, sizeof(pathname_individual), pathname, counter); } + /* Verify that the file is accessible */ + if(H5Fis_accessible(newname, fapl) != TRUE) + TEST_ERROR; + /* Make sure we can open the file. Use the read and write mode to flush the * superblock. */ if((file = H5Fopen(newname, H5F_ACC_RDWR, fapl)) < 0) @@ -939,6 +985,10 @@ test_multi_opens(char *fname) HDsnprintf(super_name, sizeof(super_name), "%%s-%c.h5", 's'); HDsnprintf(sf_name, sizeof(sf_name), super_name, fname); + /* Verify that the file is accessible */ + if(H5Fis_accessible(sf_name, H5P_DEFAULT) != FALSE) + return -1; + H5E_BEGIN_TRY { file = H5Fopen(sf_name, H5F_ACC_RDWR, H5P_DEFAULT); } H5E_END_TRY; @@ -1031,6 +1081,10 @@ test_multi(void) if(test_multi_opens(filename) < 0) TEST_ERROR; + /* Verify that the file is an HDF5 file */ + if(H5Fis_accessible(filename, fapl) != TRUE) + TEST_ERROR; + /* Reopen the file */ if((file = H5Fopen(filename, H5F_ACC_RDWR, fapl)) < 0) TEST_ERROR; @@ -1232,6 +1286,10 @@ test_multi_compat(void) sprintf(newname_r, "%s-%c.h5", FILENAME[9], 'r'); h5_make_local_copy(filename_r, newname_r); + /* Verify that the file is accessible */ + if(H5Fis_accessible(newname, fapl) != TRUE) + TEST_ERROR; + /* Reopen the file for read only. Verify 1.8 library can open file * created with 1.6 library. */ if((file=H5Fopen(newname, H5F_ACC_RDONLY, fapl)) < 0) @@ -1367,10 +1425,6 @@ test_log(void) if(H5FD_LOG != H5Pget_driver(access_fapl)) TEST_ERROR; - /* ...and close the property list */ - if(H5Pclose(access_fapl) < 0) - TEST_ERROR; - /* Check file handle API */ if(H5Fget_vfd_handle(file, H5P_DEFAULT, (void **)&fhandle) < 0) TEST_ERROR; @@ -1390,6 +1444,14 @@ test_log(void) if(H5Fclose(file) < 0) TEST_ERROR; + /* Verify that the file is accessible with log vfd */ + if(H5Fis_accessible(filename, access_fapl) != TRUE) + TEST_ERROR; + + /* ...and close the property list */ + if(H5Pclose(access_fapl) < 0) + TEST_ERROR; + h5_cleanup(FILENAME, fapl); PASSED(); return 0; @@ -1445,10 +1507,6 @@ test_stdio(void) if(H5FD_STDIO != H5Pget_driver(access_fapl)) TEST_ERROR; - /* ...and close the property list */ - if(H5Pclose(access_fapl) < 0) - TEST_ERROR; - /* Check file handle API */ if(H5Fget_vfd_handle(file, H5P_DEFAULT, (void **)&fhandle) < 0) TEST_ERROR; @@ -1468,6 +1526,14 @@ test_stdio(void) if(H5Fclose(file) < 0) TEST_ERROR; + /* Verify that the file is accessible with stdio vfd */ + if(H5Fis_accessible(filename, access_fapl) != TRUE) + TEST_ERROR; + + /* ...and close the property list */ + if(H5Pclose(access_fapl) < 0) + TEST_ERROR; + h5_cleanup(FILENAME, fapl); PASSED(); return 0; @@ -1535,10 +1601,6 @@ test_windows(void) if(H5FD_WINDOWS!= H5Pget_driver(access_fapl)) TEST_ERROR; - /* ...and close the property list */ - if(H5Pclose(access_fapl) < 0) - TEST_ERROR; - /* Check file handle API */ if(H5Fget_vfd_handle(file, H5P_DEFAULT, (void **)&fhandle) < 0) TEST_ERROR; @@ -1558,6 +1620,14 @@ test_windows(void) if(H5Fclose(file) < 0) TEST_ERROR; + /* Verify that the file is accessible with windows vfd */ + if(H5Fis_accessible(filename, access_fapl) != TRUE) + TEST_ERROR; + + /* ...and close the property list */ + if(H5Pclose(access_fapl) < 0) + TEST_ERROR; + h5_cleanup(FILENAME, fapl); PASSED(); return 0; diff --git a/test/vol_test.c b/test/vol_test.c new file mode 100644 index 0000000..2d84066 --- /dev/null +++ b/test/vol_test.c @@ -0,0 +1,136 @@ +
+#include <stdio.h>
+#include <stdlib.h>
+#include <assert.h>
+#include "hdf5.h"
+
+hid_t native_plugin_id = -1;
+
+static herr_t
+visit_cb(hid_t oid, const char *name,
+ const H5O_info_t *oinfo, void *udata)
+{
+ ssize_t len;
+ char n[25];
+
+ if(H5Iget_type(oid) == H5I_GROUP) {
+ len = H5VLget_plugin_name(oid, n, 50);
+ printf ("Visiting GROUP VOL name = %s %zd\n", n, len);
+ }
+ if(H5Iget_type(oid) == H5I_DATASET)
+ printf("visiting dataset\n");
+ if(H5Iget_type(oid) == H5I_DATATYPE)
+ printf("visiting datatype\n");
+
+ return 1;
+}
+
+int main(int argc, char **argv) {
+ const char group_name[]="/Group";
+ const char dataset_name[]="Data";
+ char fullpath[500];
+ hid_t file_id;
+ hid_t group_id;
+ hid_t dataspaceId;
+ hid_t datasetId;
+ hid_t acc_tpl;
+ hid_t under_fapl;
+ hid_t vol_id, vol_id2;
+ hid_t int_id;
+ hid_t space;
+ const unsigned int nelem=60;
+ int *data;
+ int n;
+ unsigned int i;
+ hsize_t dims[1];
+ ssize_t len;
+ char name[25];
+ static hsize_t ds_size[2] = {10, 20};
+
+ for(n=1 ; n<3 ; n++) {
+ char pl_name[10];
+ char file_name[50];
+
+ sprintf(pl_name, "log%d", n);
+ sprintf(file_name, "log_file%d.h5", n);
+
+ vol_id = H5VLregister_by_name (pl_name);
+ assert(vol_id > 0);
+ assert(H5VLis_registered(pl_name) == 1);
+
+ under_fapl = H5Pcreate (H5P_FILE_ACCESS);
+ H5Pset_fapl_native(under_fapl);
+ assert(H5VLis_registered("native") == 1);
+
+ vol_id2 = H5VLget_plugin_id(pl_name);
+ H5VLinitialize(vol_id2, H5P_DEFAULT);
+ H5VLclose(vol_id2);
+
+ native_plugin_id = H5VLget_plugin_id("native");
+ assert(native_plugin_id > 0);
+
+ acc_tpl = H5Pcreate (H5P_FILE_ACCESS);
+ H5Pset_vol(acc_tpl, vol_id, &under_fapl);
+
+ file_id = H5Fcreate(file_name, H5F_ACC_TRUNC, H5P_DEFAULT, acc_tpl);
+ len = H5VLget_plugin_name(file_id, name, 25);
+ printf ("FILE VOL name = %s %zd\n", name, len);
+
+ group_id = H5Gcreate2(file_id, group_name, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT);
+ len = H5VLget_plugin_name(group_id, name, 50);
+ printf ("GROUP VOL name = %s %zd\n", name, len);
+
+ int_id = H5Tcopy(H5T_NATIVE_INT);
+ H5Tcommit2(file_id, "int", int_id, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT);
+ len = H5VLget_plugin_name(int_id, name, 50);
+ printf ("DT COMMIT name = %s %zd\n", name, len);
+ H5Tclose(int_id);
+
+ int_id = H5Topen2(file_id, "int", H5P_DEFAULT);
+ len = H5VLget_plugin_name(int_id, name, 50);
+ printf ("DT OPEN name = %s %zd\n", name, len);
+ H5Tclose(int_id);
+
+ int_id = H5Oopen(file_id,"int",H5P_DEFAULT);
+ len = H5VLget_plugin_name(int_id, name, 50);
+ printf ("DT OOPEN name = %s %zd\n", name, len);
+
+ len = H5Fget_name(file_id, name, 50);
+ printf("name = %zd %s\n", len, name);
+
+ data = (int *)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_plugin_name(datasetId, name, 50);
+ printf ("DSET name = %s %zd\n", name, len);
+
+ H5Dwrite(datasetId, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, H5P_DEFAULT, data);
+ H5Dclose(datasetId);
+
+ H5Ovisit(file_id, H5_INDEX_NAME, H5_ITER_NATIVE, visit_cb, NULL);
+
+ free (data);
+ H5Oclose(int_id);
+ H5Sclose (space);
+ H5Gclose(group_id);
+
+ H5Fclose(file_id);
+ H5Pclose(acc_tpl);
+ H5Pclose(under_fapl);
+
+ H5VLclose(native_plugin_id);
+ H5VLterminate(vol_id, H5P_DEFAULT);
+ H5VLunregister (vol_id);
+ assert(H5VLis_registered(pl_name) == 0);
+ }
+ return 0;
+}
diff --git a/testpar/t_cache.c b/testpar/t_cache.c index 7ce148a..c56abe9 100644 --- a/testpar/t_cache.c +++ b/testpar/t_cache.c @@ -3921,7 +3921,7 @@ setup_cache_for_test(hid_t * fid_ptr, world_mpi_rank, fcn_name); } } else { - file_ptr = (H5F_t *)H5I_object_verify(fid, H5I_FILE); + file_ptr = (H5F_t *)H5VL_object_verify(fid, H5I_FILE); } if ( file_ptr == NULL ) { diff --git a/tools/h5dump/Makefile.am b/tools/h5dump/Makefile.am index cee4801..69227f8 100644 --- a/tools/h5dump/Makefile.am +++ b/tools/h5dump/Makefile.am @@ -24,8 +24,8 @@ include $(top_srcdir)/config/commence.am AM_CPPFLAGS+=-I$(top_srcdir)/src -I$(top_srcdir)/tools/lib # Test programs and scripts -TEST_PROG=h5dumpgentest -TEST_SCRIPT=testh5dump.sh testh5dumppbits.sh testh5dumpxml.sh +TEST_PROG= h5dumpgentest +TEST_SCRIPT= testh5dump.sh testh5dumppbits.sh testh5dumpxml.sh check_PROGRAMS=$(TEST_PROG) binread check_SCRIPTS=$(TEST_SCRIPT) @@ -46,6 +46,6 @@ h5dump_SOURCES=h5dump.c h5dump_ddl.c h5dump_xml.c # Temporary files. *.h5 are generated by h5dumpgentest. They should # copied to the testfiles/ directory if update is required. CHECK_CLEANFILES+=*.h5 *.bin -DISTCLEANFILES=testh5dump.sh testh5dumppbits.sh testh5dumpxml.sh +DISTCLEANFILES= #testh5dump.sh testh5dumppbits.sh testh5dumpxml.sh include $(top_srcdir)/config/conclude.am diff --git a/tools/h5dump/Makefile.in b/tools/h5dump/Makefile.in index 8cb1661..c1f00d6 100644 --- a/tools/h5dump/Makefile.in +++ b/tools/h5dump/Makefile.in @@ -696,7 +696,7 @@ LDADD = $(LIBH5TOOLS) $(LIBHDF5) # Source files for the program h5dump_SOURCES = h5dump.c h5dump_ddl.c h5dump_xml.c -DISTCLEANFILES = testh5dump.sh testh5dumppbits.sh testh5dumpxml.sh +DISTCLEANFILES = #testh5dump.sh testh5dumppbits.sh testh5dumpxml.sh # Automake needs to be taught how to build lib, progs, and tests targets. # These will be filled in automatically for the most part (e.g., diff --git a/tools/h5dump/errfiles/filter_fail.err b/tools/h5dump/errfiles/filter_fail.err index db21044..061a0e3 100644 --- a/tools/h5dump/errfiles/filter_fail.err +++ b/tools/h5dump/errfiles/filter_fail.err @@ -2,19 +2,25 @@ 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 H5D__read(): can't read data + #001: (file name) line (number) in H5VL_dataset_read(): read failed + major: Virtual Object Layer + minor: Read failed + #002: (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 major: Dataset minor: Read failed - #002: (file name) line (number) in H5D__chunk_read(): unable to read raw data chunk + #004: (file name) line (number) in H5D__chunk_read(): unable to read raw data chunk major: Low-level I/O minor: Read failed - #003: (file name) line (number) in H5D__chunk_lock(): data pipeline read failed + #005: (file name) line (number) in H5D__chunk_lock(): data pipeline read failed major: Data filters minor: Filter operation failed - #004: (file name) line (number) in H5Z_pipeline(): required filter 'filter_fail_test' is not registered + #006: (file name) line (number) in H5Z_pipeline(): required filter 'filter_fail_test' is not registered major: Data filters minor: Read failed - #005: (file name) line (number) in H5PL_load(): required dynamically loaded plugin filter '312' is not available + #007: (file name) line (number) in H5PL_load(): required dynamically loaded plugin filter '312' is not available major: Plugin for dynamically loaded library minor: Unable to load metadata into cache h5dump error: unable to print data diff --git a/tools/h5dump/errfiles/tall-1.err b/tools/h5dump/errfiles/tall-1.err index ba691d0..2313f50 100644 --- a/tools/h5dump/errfiles/tall-1.err +++ b/tools/h5dump/errfiles/tall-1.err @@ -2,24 +2,30 @@ HDF5-DIAG: Error detected in HDF5 (version (number)) thread (IDs): #000: (file name) line (number) in H5Oopen(): unable to open object major: Symbol table minor: Can't open object - #001: (file name) line (number) in H5O_open_name(): object not found + #001: (file name) line (number) in H5VL_object_open(): 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 + major: Symbol table + minor: Can't open object + #003: (file name) line (number) in H5O_open_name(): object not found major: Symbol table minor: Object not found - #002: (file name) line (number) in H5G_loc_find(): can't find object + #004: (file name) line (number) in H5G_loc_find(): can't find object major: Symbol table minor: Object not found - #003: (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 - #004: (file name) line (number) in H5G_traverse_real(): special link traversal failed + #006: (file name) line (number) in H5G_traverse_real(): special link traversal failed major: Links minor: Link traversal failure - #005: (file name) line (number) in H5G__traverse_special(): user-defined link traversal failed + #007: (file name) line (number) in H5G__traverse_special(): user-defined link traversal failed major: Links minor: Link traversal failure - #006: (file name) line (number) in H5G_traverse_ud(): traversal callback returned invalid ID + #008: (file name) line (number) in H5G_traverse_ud(): traversal callback returned invalid ID major: Symbol table minor: Unable to find atom information (already closed?) - #007: (file name) line (number) in H5L_extern_traverse(): unable to open external file, external link file name = 'somefile', temp_file_name = 'somefile' + #009: (file name) line (number) in H5L_extern_traverse(): unable to open external file, external link file name = 'somefile', temp_file_name = 'somefile' major: Links minor: Unable to open file diff --git a/tools/h5dump/errfiles/tall-2A.err b/tools/h5dump/errfiles/tall-2A.err index ba691d0..2313f50 100644 --- a/tools/h5dump/errfiles/tall-2A.err +++ b/tools/h5dump/errfiles/tall-2A.err @@ -2,24 +2,30 @@ HDF5-DIAG: Error detected in HDF5 (version (number)) thread (IDs): #000: (file name) line (number) in H5Oopen(): unable to open object major: Symbol table minor: Can't open object - #001: (file name) line (number) in H5O_open_name(): object not found + #001: (file name) line (number) in H5VL_object_open(): 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 + major: Symbol table + minor: Can't open object + #003: (file name) line (number) in H5O_open_name(): object not found major: Symbol table minor: Object not found - #002: (file name) line (number) in H5G_loc_find(): can't find object + #004: (file name) line (number) in H5G_loc_find(): can't find object major: Symbol table minor: Object not found - #003: (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 - #004: (file name) line (number) in H5G_traverse_real(): special link traversal failed + #006: (file name) line (number) in H5G_traverse_real(): special link traversal failed major: Links minor: Link traversal failure - #005: (file name) line (number) in H5G__traverse_special(): user-defined link traversal failed + #007: (file name) line (number) in H5G__traverse_special(): user-defined link traversal failed major: Links minor: Link traversal failure - #006: (file name) line (number) in H5G_traverse_ud(): traversal callback returned invalid ID + #008: (file name) line (number) in H5G_traverse_ud(): traversal callback returned invalid ID major: Symbol table minor: Unable to find atom information (already closed?) - #007: (file name) line (number) in H5L_extern_traverse(): unable to open external file, external link file name = 'somefile', temp_file_name = 'somefile' + #009: (file name) line (number) in H5L_extern_traverse(): unable to open external file, external link file name = 'somefile', temp_file_name = 'somefile' major: Links minor: Unable to open file diff --git a/tools/h5dump/errfiles/tall-2A0.err b/tools/h5dump/errfiles/tall-2A0.err index ba691d0..2313f50 100644 --- a/tools/h5dump/errfiles/tall-2A0.err +++ b/tools/h5dump/errfiles/tall-2A0.err @@ -2,24 +2,30 @@ HDF5-DIAG: Error detected in HDF5 (version (number)) thread (IDs): #000: (file name) line (number) in H5Oopen(): unable to open object major: Symbol table minor: Can't open object - #001: (file name) line (number) in H5O_open_name(): object not found + #001: (file name) line (number) in H5VL_object_open(): 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 + major: Symbol table + minor: Can't open object + #003: (file name) line (number) in H5O_open_name(): object not found major: Symbol table minor: Object not found - #002: (file name) line (number) in H5G_loc_find(): can't find object + #004: (file name) line (number) in H5G_loc_find(): can't find object major: Symbol table minor: Object not found - #003: (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 - #004: (file name) line (number) in H5G_traverse_real(): special link traversal failed + #006: (file name) line (number) in H5G_traverse_real(): special link traversal failed major: Links minor: Link traversal failure - #005: (file name) line (number) in H5G__traverse_special(): user-defined link traversal failed + #007: (file name) line (number) in H5G__traverse_special(): user-defined link traversal failed major: Links minor: Link traversal failure - #006: (file name) line (number) in H5G_traverse_ud(): traversal callback returned invalid ID + #008: (file name) line (number) in H5G_traverse_ud(): traversal callback returned invalid ID major: Symbol table minor: Unable to find atom information (already closed?) - #007: (file name) line (number) in H5L_extern_traverse(): unable to open external file, external link file name = 'somefile', temp_file_name = 'somefile' + #009: (file name) line (number) in H5L_extern_traverse(): unable to open external file, external link file name = 'somefile', temp_file_name = 'somefile' major: Links minor: Unable to open file diff --git a/tools/h5dump/errfiles/tall-2B.err b/tools/h5dump/errfiles/tall-2B.err index ba691d0..2313f50 100644 --- a/tools/h5dump/errfiles/tall-2B.err +++ b/tools/h5dump/errfiles/tall-2B.err @@ -2,24 +2,30 @@ HDF5-DIAG: Error detected in HDF5 (version (number)) thread (IDs): #000: (file name) line (number) in H5Oopen(): unable to open object major: Symbol table minor: Can't open object - #001: (file name) line (number) in H5O_open_name(): object not found + #001: (file name) line (number) in H5VL_object_open(): 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 + major: Symbol table + minor: Can't open object + #003: (file name) line (number) in H5O_open_name(): object not found major: Symbol table minor: Object not found - #002: (file name) line (number) in H5G_loc_find(): can't find object + #004: (file name) line (number) in H5G_loc_find(): can't find object major: Symbol table minor: Object not found - #003: (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 - #004: (file name) line (number) in H5G_traverse_real(): special link traversal failed + #006: (file name) line (number) in H5G_traverse_real(): special link traversal failed major: Links minor: Link traversal failure - #005: (file name) line (number) in H5G__traverse_special(): user-defined link traversal failed + #007: (file name) line (number) in H5G__traverse_special(): user-defined link traversal failed major: Links minor: Link traversal failure - #006: (file name) line (number) in H5G_traverse_ud(): traversal callback returned invalid ID + #008: (file name) line (number) in H5G_traverse_ud(): traversal callback returned invalid ID major: Symbol table minor: Unable to find atom information (already closed?) - #007: (file name) line (number) in H5L_extern_traverse(): unable to open external file, external link file name = 'somefile', temp_file_name = 'somefile' + #009: (file name) line (number) in H5L_extern_traverse(): unable to open external file, external link file name = 'somefile', temp_file_name = 'somefile' major: Links minor: Unable to open file diff --git a/tools/h5dump/errfiles/tarray1_big.err b/tools/h5dump/errfiles/tarray1_big.err index 457afdd..5b11b7b 100644 --- a/tools/h5dump/errfiles/tarray1_big.err +++ b/tools/h5dump/errfiles/tarray1_big.err @@ -2,57 +2,75 @@ HDF5-DIAG: Error detected in HDF5 (version (number)) thread (IDs): #000: (file name) line (number) in H5Rdereference2(): unable to dereference object major: References minor: Unable to initialize object - #001: (file name) line (number) in H5R_dereference(): Unable to read dataset region information + #001: (file name) line (number) in H5VL_object_open(): 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 + major: References + minor: Unable to initialize object + #003: (file name) line (number) in H5R_dereference(): Unable to read dataset region information major: References minor: Read failed - #002: (file name) line (number) in H5HG_read(): unable to protect global heap + #004: (file name) line (number) in H5HG_read(): unable to protect global heap major: Heap minor: Unable to protect metadata - #003: (file name) line (number) in H5HG_protect(): unable to protect global heap + #005: (file name) line (number) in H5HG_protect(): unable to protect global heap major: Heap minor: Unable to protect metadata - #004: (file name) line (number) in H5AC_protect(): H5C_protect() failed. + #006: (file name) line (number) in H5AC_protect(): H5C_protect() failed. major: Object cache minor: Unable to protect metadata - #005: (file name) line (number) in H5C_protect(): incorrect cache entry type + #007: (file name) line (number) in H5C_protect(): incorrect cache entry type major: Object cache minor: Inappropriate type HDF5-DIAG: Error detected in HDF5 (version (number)) thread (IDs): #000: (file name) line (number) in H5Rdereference2(): unable to dereference object major: References minor: Unable to initialize object - #001: (file name) line (number) in H5R_dereference(): Unable to read dataset region information + #001: (file name) line (number) in H5VL_object_open(): 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 + major: References + minor: Unable to initialize object + #003: (file name) line (number) in H5R_dereference(): Unable to read dataset region information major: References minor: Read failed - #002: (file name) line (number) in H5HG_read(): unable to protect global heap + #004: (file name) line (number) in H5HG_read(): unable to protect global heap major: Heap minor: Unable to protect metadata - #003: (file name) line (number) in H5HG_protect(): unable to protect global heap + #005: (file name) line (number) in H5HG_protect(): unable to protect global heap major: Heap minor: Unable to protect metadata - #004: (file name) line (number) in H5AC_protect(): H5C_protect() failed. + #006: (file name) line (number) in H5AC_protect(): H5C_protect() failed. major: Object cache minor: Unable to protect metadata - #005: (file name) line (number) in H5C_protect(): incorrect cache entry type + #007: (file name) line (number) in H5C_protect(): incorrect cache entry type major: Object cache minor: Inappropriate type HDF5-DIAG: Error detected in HDF5 (version (number)) thread (IDs): #000: (file name) line (number) in H5Rdereference2(): unable to dereference object major: References minor: Unable to initialize object - #001: (file name) line (number) in H5R_dereference(): Unable to read dataset region information + #001: (file name) line (number) in H5VL_object_open(): 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 + major: References + minor: Unable to initialize object + #003: (file name) line (number) in H5R_dereference(): Unable to read dataset region information major: References minor: Read failed - #002: (file name) line (number) in H5HG_read(): unable to protect global heap + #004: (file name) line (number) in H5HG_read(): unable to protect global heap major: Heap minor: Unable to protect metadata - #003: (file name) line (number) in H5HG_protect(): unable to protect global heap + #005: (file name) line (number) in H5HG_protect(): unable to protect global heap major: Heap minor: Unable to protect metadata - #004: (file name) line (number) in H5AC_protect(): H5C_protect() failed. + #006: (file name) line (number) in H5AC_protect(): H5C_protect() failed. major: Object cache minor: Unable to protect metadata - #005: (file name) line (number) in H5C_protect(): incorrect cache entry type + #007: (file name) line (number) in H5C_protect(): incorrect cache entry type major: Object cache minor: Inappropriate type H5tools-DIAG: Error detected in HDF5:tools (version (number)) thread (IDs): diff --git a/tools/h5dump/errfiles/tattr-3.err b/tools/h5dump/errfiles/tattr-3.err index ce8ddda..70ba935 100644 --- a/tools/h5dump/errfiles/tattr-3.err +++ b/tools/h5dump/errfiles/tattr-3.err @@ -1,8 +1,14 @@ HDF5-DIAG: Error detected in HDF5 (version (number)) thread (IDs): - #000: (file name) line (number) in H5Aopen(): unable to load attribute info from object header for attribute: 'attr' + #000: (file name) line (number) in H5Aopen(): unable to open attribute + major: Symbol table + minor: Can't open object + #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 load attribute info from object header for attribute: 'attr' major: Attribute minor: Unable to initialize object - #001: (file name) line (number) in H5O_attr_open_by_name(): can't locate attribute: 'attr' + #003: (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/h5dump/errfiles/tattrregR.err b/tools/h5dump/errfiles/tattrregR.err index 7ab9afd..65e38a1 100644 --- a/tools/h5dump/errfiles/tattrregR.err +++ b/tools/h5dump/errfiles/tattrregR.err @@ -2,38 +2,50 @@ HDF5-DIAG: Error detected in HDF5 (version (number)) thread (IDs): #000: (file name) line (number) in H5Rdereference2(): unable to dereference object major: References minor: Unable to initialize object - #001: (file name) line (number) in H5R_dereference(): Unable to read dataset region information + #001: (file name) line (number) in H5VL_object_open(): 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 + major: References + minor: Unable to initialize object + #003: (file name) line (number) in H5R_dereference(): Unable to read dataset region information major: References minor: Read failed - #002: (file name) line (number) in H5HG_read(): unable to protect global heap + #004: (file name) line (number) in H5HG_read(): unable to protect global heap major: Heap minor: Unable to protect metadata - #003: (file name) line (number) in H5HG_protect(): unable to protect global heap + #005: (file name) line (number) in H5HG_protect(): unable to protect global heap major: Heap minor: Unable to protect metadata - #004: (file name) line (number) in H5AC_protect(): H5C_protect() failed. + #006: (file name) line (number) in H5AC_protect(): H5C_protect() failed. major: Object cache minor: Unable to protect metadata - #005: (file name) line (number) in H5C_protect(): incorrect cache entry type + #007: (file name) line (number) in H5C_protect(): incorrect cache entry type major: Object cache minor: Inappropriate type HDF5-DIAG: Error detected in HDF5 (version (number)) thread (IDs): #000: (file name) line (number) in H5Rdereference2(): unable to dereference object major: References minor: Unable to initialize object - #001: (file name) line (number) in H5R_dereference(): Unable to read dataset region information + #001: (file name) line (number) in H5VL_object_open(): 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 + major: References + minor: Unable to initialize object + #003: (file name) line (number) in H5R_dereference(): Unable to read dataset region information major: References minor: Read failed - #002: (file name) line (number) in H5HG_read(): unable to protect global heap + #004: (file name) line (number) in H5HG_read(): unable to protect global heap major: Heap minor: Unable to protect metadata - #003: (file name) line (number) in H5HG_protect(): unable to protect global heap + #005: (file name) line (number) in H5HG_protect(): unable to protect global heap major: Heap minor: Unable to protect metadata - #004: (file name) line (number) in H5AC_protect(): H5C_protect() failed. + #006: (file name) line (number) in H5AC_protect(): H5C_protect() failed. major: Object cache minor: Unable to protect metadata - #005: (file name) line (number) in H5C_protect(): incorrect cache entry type + #007: (file name) line (number) in H5C_protect(): incorrect cache entry type major: Object cache minor: Inappropriate type H5tools-DIAG: Error detected in HDF5:tools (version (number)) thread (IDs): diff --git a/tools/h5dump/errfiles/tcomp-3.err b/tools/h5dump/errfiles/tcomp-3.err index ee47ee5..1e798d0 100644 --- a/tools/h5dump/errfiles/tcomp-3.err +++ b/tools/h5dump/errfiles/tcomp-3.err @@ -1,16 +1,22 @@ HDF5-DIAG: Error detected in HDF5 (version (number)) thread (IDs): - #000: (file name) line (number) in H5Topen2(): not found + #000: (file name) line (number) in H5Topen2(): unable to open datatype + major: Symbol table + minor: Can't open object + #001: (file name) line (number) in H5VL_datatype_open(): open failed + major: Virtual Object Layer + minor: Can't open object + #002: (file name) line (number) in H5VL_native_datatype_open(): not found major: Datatype minor: Object not found - #001: (file name) line (number) in H5G_loc_find(): can't find object + #003: (file name) line (number) in H5G_loc_find(): can't find object major: Symbol table minor: Object not found - #002: (file name) line (number) in H5G_traverse(): internal path traversal failed + #004: (file name) line (number) in H5G_traverse(): internal path traversal failed major: Symbol table minor: Object not found - #003: (file name) line (number) in H5G_traverse_real(): traversal operator failed + #005: (file name) line (number) in H5G_traverse_real(): traversal operator failed major: Symbol table minor: Callback failed - #004: (file name) line (number) in H5G_loc_find_cb(): object '#6632' doesn't exist + #006: (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/h5dump/errfiles/tdataregR.err b/tools/h5dump/errfiles/tdataregR.err index 7ab9afd..65e38a1 100644 --- a/tools/h5dump/errfiles/tdataregR.err +++ b/tools/h5dump/errfiles/tdataregR.err @@ -2,38 +2,50 @@ HDF5-DIAG: Error detected in HDF5 (version (number)) thread (IDs): #000: (file name) line (number) in H5Rdereference2(): unable to dereference object major: References minor: Unable to initialize object - #001: (file name) line (number) in H5R_dereference(): Unable to read dataset region information + #001: (file name) line (number) in H5VL_object_open(): 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 + major: References + minor: Unable to initialize object + #003: (file name) line (number) in H5R_dereference(): Unable to read dataset region information major: References minor: Read failed - #002: (file name) line (number) in H5HG_read(): unable to protect global heap + #004: (file name) line (number) in H5HG_read(): unable to protect global heap major: Heap minor: Unable to protect metadata - #003: (file name) line (number) in H5HG_protect(): unable to protect global heap + #005: (file name) line (number) in H5HG_protect(): unable to protect global heap major: Heap minor: Unable to protect metadata - #004: (file name) line (number) in H5AC_protect(): H5C_protect() failed. + #006: (file name) line (number) in H5AC_protect(): H5C_protect() failed. major: Object cache minor: Unable to protect metadata - #005: (file name) line (number) in H5C_protect(): incorrect cache entry type + #007: (file name) line (number) in H5C_protect(): incorrect cache entry type major: Object cache minor: Inappropriate type HDF5-DIAG: Error detected in HDF5 (version (number)) thread (IDs): #000: (file name) line (number) in H5Rdereference2(): unable to dereference object major: References minor: Unable to initialize object - #001: (file name) line (number) in H5R_dereference(): Unable to read dataset region information + #001: (file name) line (number) in H5VL_object_open(): 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 + major: References + minor: Unable to initialize object + #003: (file name) line (number) in H5R_dereference(): Unable to read dataset region information major: References minor: Read failed - #002: (file name) line (number) in H5HG_read(): unable to protect global heap + #004: (file name) line (number) in H5HG_read(): unable to protect global heap major: Heap minor: Unable to protect metadata - #003: (file name) line (number) in H5HG_protect(): unable to protect global heap + #005: (file name) line (number) in H5HG_protect(): unable to protect global heap major: Heap minor: Unable to protect metadata - #004: (file name) line (number) in H5AC_protect(): H5C_protect() failed. + #006: (file name) line (number) in H5AC_protect(): H5C_protect() failed. major: Object cache minor: Unable to protect metadata - #005: (file name) line (number) in H5C_protect(): incorrect cache entry type + #007: (file name) line (number) in H5C_protect(): incorrect cache entry type major: Object cache minor: Inappropriate type H5tools-DIAG: Error detected in HDF5:tools (version (number)) thread (IDs): diff --git a/tools/h5dump/errfiles/tdset-2.err b/tools/h5dump/errfiles/tdset-2.err index d9b92f3..143cc9d 100644 --- a/tools/h5dump/errfiles/tdset-2.err +++ b/tools/h5dump/errfiles/tdset-2.err @@ -1,33 +1,45 @@ HDF5-DIAG: Error detected in HDF5 (version (number)) thread (IDs): - #000: (file name) line (number) in H5Dopen2(): not found + #000: (file name) line (number) in H5Dopen2(): unable to open dataset + major: Dataset + minor: Can't open object + #001: (file name) line (number) in H5VL_dataset_open(): open failed + major: Virtual Object Layer + minor: Can't open object + #002: (file name) line (number) in H5VL_native_dataset_open(): not found major: Dataset minor: Object not found - #001: (file name) line (number) in H5G_loc_find(): can't find object + #003: (file name) line (number) in H5G_loc_find(): can't find object major: Symbol table minor: Object not found - #002: (file name) line (number) in H5G_traverse(): internal path traversal failed + #004: (file name) line (number) in H5G_traverse(): internal path traversal failed major: Symbol table minor: Object not found - #003: (file name) line (number) in H5G_traverse_real(): traversal operator failed + #005: (file name) line (number) in H5G_traverse_real(): traversal operator failed major: Symbol table minor: Callback failed - #004: (file name) line (number) in H5G_loc_find_cb(): object 'dset3' doesn't exist + #006: (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: Internal error (too specific to document in detail) + minor: Can't get value + #001: (file name) line (number) in H5VL_link_get(): 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 major: Symbol table minor: Object not found - #001: (file name) line (number) in H5L_get_info(): name doesn't exist + #003: (file name) line (number) in H5L_get_info(): name doesn't exist major: Symbol table minor: Object already exists - #002: (file name) line (number) in H5G_traverse(): internal path traversal failed + #004: (file name) line (number) in H5G_traverse(): internal path traversal failed major: Symbol table minor: Object not found - #003: (file name) line (number) in H5G_traverse_real(): traversal operator failed + #005: (file name) line (number) in H5G_traverse_real(): traversal operator failed major: Symbol table minor: Callback failed - #004: (file name) line (number) in H5L_get_info_cb(): name doesn't exist + #006: (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 "dset3" diff --git a/tools/h5dump/errfiles/textlink.err b/tools/h5dump/errfiles/textlink.err index 03c0550..f208ac6 100644 --- a/tools/h5dump/errfiles/textlink.err +++ b/tools/h5dump/errfiles/textlink.err @@ -2,49 +2,61 @@ HDF5-DIAG: Error detected in HDF5 (version (number)) thread (IDs): #000: (file name) line (number) in H5Oopen(): unable to open object major: Symbol table minor: Can't open object - #001: (file name) line (number) in H5O_open_name(): object not found + #001: (file name) line (number) in H5VL_object_open(): 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 + major: Symbol table + minor: Can't open object + #003: (file name) line (number) in H5O_open_name(): object not found major: Symbol table minor: Object not found - #002: (file name) line (number) in H5G_loc_find(): can't find object + #004: (file name) line (number) in H5G_loc_find(): can't find object major: Symbol table minor: Object not found - #003: (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 - #004: (file name) line (number) in H5G_traverse_real(): special link traversal failed + #006: (file name) line (number) in H5G_traverse_real(): special link traversal failed major: Links minor: Link traversal failure - #005: (file name) line (number) in H5G__traverse_special(): user-defined link traversal failed + #007: (file name) line (number) in H5G__traverse_special(): user-defined link traversal failed major: Links minor: Link traversal failure - #006: (file name) line (number) in H5G_traverse_ud(): traversal callback returned invalid ID + #008: (file name) line (number) in H5G_traverse_ud(): traversal callback returned invalid ID major: Symbol table minor: Unable to find atom information (already closed?) - #007: (file name) line (number) in H5L_extern_traverse(): unable to open external file, external link file name = 'filename', temp_file_name = 'filename' + #009: (file name) line (number) in H5L_extern_traverse(): unable to open external file, external link file name = 'filename', temp_file_name = 'filename' major: Links 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: Symbol table minor: Can't open object - #001: (file name) line (number) in H5O_open_name(): object not found + #001: (file name) line (number) in H5VL_object_open(): 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 + major: Symbol table + minor: Can't open object + #003: (file name) line (number) in H5O_open_name(): object not found major: Symbol table minor: Object not found - #002: (file name) line (number) in H5G_loc_find(): can't find object + #004: (file name) line (number) in H5G_loc_find(): can't find object major: Symbol table minor: Object not found - #003: (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 - #004: (file name) line (number) in H5G_traverse_real(): special link traversal failed + #006: (file name) line (number) in H5G_traverse_real(): special link traversal failed major: Links minor: Link traversal failure - #005: (file name) line (number) in H5G__traverse_special(): user-defined link traversal failed + #007: (file name) line (number) in H5G__traverse_special(): user-defined link traversal failed major: Links minor: Link traversal failure - #006: (file name) line (number) in H5G_traverse_ud(): traversal callback returned invalid ID + #008: (file name) line (number) in H5G_traverse_ud(): traversal callback returned invalid ID major: Symbol table minor: Unable to find atom information (already closed?) - #007: (file name) line (number) in H5L_extern_traverse(): unable to open external file, external link file name = 'anotherfile', temp_file_name = 'anotherfile' + #009: (file name) line (number) in H5L_extern_traverse(): unable to open external file, external link file name = 'anotherfile', temp_file_name = 'anotherfile' major: Links minor: Unable to open file diff --git a/tools/h5dump/errfiles/textlinkfar.err b/tools/h5dump/errfiles/textlinkfar.err index 969e17c..6a563cf 100644 --- a/tools/h5dump/errfiles/textlinkfar.err +++ b/tools/h5dump/errfiles/textlinkfar.err @@ -2,49 +2,55 @@ HDF5-DIAG: Error detected in HDF5 (version (number)) thread (IDs): #000: (file name) line (number) in H5Oopen(): unable to open object major: Symbol table minor: Can't open object - #001: (file name) line (number) in H5O_open_name(): object not found + #001: (file name) line (number) in H5VL_object_open(): 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 + major: Symbol table + minor: Can't open object + #003: (file name) line (number) in H5O_open_name(): object not found major: Symbol table minor: Object not found - #002: (file name) line (number) in H5G_loc_find(): can't find object + #004: (file name) line (number) in H5G_loc_find(): can't find object major: Symbol table minor: Object not found - #003: (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 - #004: (file name) line (number) in H5G_traverse_real(): special link traversal failed + #006: (file name) line (number) in H5G_traverse_real(): special link traversal failed major: Links minor: Link traversal failure - #005: (file name) line (number) in H5G__traverse_special(): user-defined link traversal failed + #007: (file name) line (number) in H5G__traverse_special(): user-defined link traversal failed major: Links minor: Link traversal failure - #006: (file name) line (number) in H5G_traverse_ud(): traversal callback returned invalid ID + #008: (file name) line (number) in H5G_traverse_ud(): traversal callback returned invalid ID major: Symbol table minor: Unable to find atom information (already closed?) - #007: (file name) line (number) in H5L_extern_traverse(): unable to open object + #009: (file name) line (number) in H5L_extern_traverse(): unable to open object major: Symbol table minor: Can't open object - #008: (file name) line (number) in H5O_open_name(): object not found + #010: (file name) line (number) in H5O_open_name(): object not found major: Symbol table minor: Object not found - #009: (file name) line (number) in H5G_loc_find(): can't find object + #011: (file name) line (number) in H5G_loc_find(): can't find object major: Symbol table minor: Object not found - #010: (file name) line (number) in H5G_traverse(): internal path traversal failed + #012: (file name) line (number) in H5G_traverse(): internal path traversal failed major: Symbol table minor: Object not found - #011: (file name) line (number) in H5G_traverse_real(): special link traversal failed + #013: (file name) line (number) in H5G_traverse_real(): special link traversal failed major: Links minor: Link traversal failure - #012: (file name) line (number) in H5G__traverse_special(): symbolic link traversal failed + #014: (file name) line (number) in H5G__traverse_special(): symbolic link traversal failed major: Links minor: Link traversal failure - #013: (file name) line (number) in H5G_traverse_slink(): unable to follow symbolic link + #015: (file name) line (number) in H5G_traverse_slink(): unable to follow symbolic link major: Symbol table minor: Object not found - #014: (file name) line (number) in H5G_traverse_real(): traversal operator failed + #016: (file name) line (number) in H5G_traverse_real(): traversal operator failed major: Symbol table minor: Callback failed - #015: (file name) line (number) in H5G_traverse_slink_cb(): component not found + #017: (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/h5dump/errfiles/textlinksrc.err b/tools/h5dump/errfiles/textlinksrc.err index 969e17c..6a563cf 100644 --- a/tools/h5dump/errfiles/textlinksrc.err +++ b/tools/h5dump/errfiles/textlinksrc.err @@ -2,49 +2,55 @@ HDF5-DIAG: Error detected in HDF5 (version (number)) thread (IDs): #000: (file name) line (number) in H5Oopen(): unable to open object major: Symbol table minor: Can't open object - #001: (file name) line (number) in H5O_open_name(): object not found + #001: (file name) line (number) in H5VL_object_open(): 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 + major: Symbol table + minor: Can't open object + #003: (file name) line (number) in H5O_open_name(): object not found major: Symbol table minor: Object not found - #002: (file name) line (number) in H5G_loc_find(): can't find object + #004: (file name) line (number) in H5G_loc_find(): can't find object major: Symbol table minor: Object not found - #003: (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 - #004: (file name) line (number) in H5G_traverse_real(): special link traversal failed + #006: (file name) line (number) in H5G_traverse_real(): special link traversal failed major: Links minor: Link traversal failure - #005: (file name) line (number) in H5G__traverse_special(): user-defined link traversal failed + #007: (file name) line (number) in H5G__traverse_special(): user-defined link traversal failed major: Links minor: Link traversal failure - #006: (file name) line (number) in H5G_traverse_ud(): traversal callback returned invalid ID + #008: (file name) line (number) in H5G_traverse_ud(): traversal callback returned invalid ID major: Symbol table minor: Unable to find atom information (already closed?) - #007: (file name) line (number) in H5L_extern_traverse(): unable to open object + #009: (file name) line (number) in H5L_extern_traverse(): unable to open object major: Symbol table minor: Can't open object - #008: (file name) line (number) in H5O_open_name(): object not found + #010: (file name) line (number) in H5O_open_name(): object not found major: Symbol table minor: Object not found - #009: (file name) line (number) in H5G_loc_find(): can't find object + #011: (file name) line (number) in H5G_loc_find(): can't find object major: Symbol table minor: Object not found - #010: (file name) line (number) in H5G_traverse(): internal path traversal failed + #012: (file name) line (number) in H5G_traverse(): internal path traversal failed major: Symbol table minor: Object not found - #011: (file name) line (number) in H5G_traverse_real(): special link traversal failed + #013: (file name) line (number) in H5G_traverse_real(): special link traversal failed major: Links minor: Link traversal failure - #012: (file name) line (number) in H5G__traverse_special(): symbolic link traversal failed + #014: (file name) line (number) in H5G__traverse_special(): symbolic link traversal failed major: Links minor: Link traversal failure - #013: (file name) line (number) in H5G_traverse_slink(): unable to follow symbolic link + #015: (file name) line (number) in H5G_traverse_slink(): unable to follow symbolic link major: Symbol table minor: Object not found - #014: (file name) line (number) in H5G_traverse_real(): traversal operator failed + #016: (file name) line (number) in H5G_traverse_real(): traversal operator failed major: Symbol table minor: Callback failed - #015: (file name) line (number) in H5G_traverse_slink_cb(): component not found + #017: (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/h5dump/errfiles/tgroup-2.err b/tools/h5dump/errfiles/tgroup-2.err index 3659b5c..42c926f 100644 --- a/tools/h5dump/errfiles/tgroup-2.err +++ b/tools/h5dump/errfiles/tgroup-2.err @@ -2,19 +2,25 @@ 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 H5G__open_name(): group not found + #001: (file name) line (number) in H5VL_group_open(): 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 + major: Symbol table + minor: Can't open object + #003: (file name) line (number) in H5G__open_name(): group not found major: Symbol table minor: Object not found - #002: (file name) line (number) in H5G_loc_find(): can't find object + #004: (file name) line (number) in H5G_loc_find(): can't find object major: Symbol table minor: Object not found - #003: (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 - #004: (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 - #005: (file name) line (number) in H5G_loc_find_cb(): object 'y' doesn't exist + #007: (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/h5dump/errfiles/torderlinks1.err b/tools/h5dump/errfiles/torderlinks1.err index 780c7e6..b39f6b8 100644 --- a/tools/h5dump/errfiles/torderlinks1.err +++ b/tools/h5dump/errfiles/torderlinks1.err @@ -2,24 +2,30 @@ HDF5-DIAG: Error detected in HDF5 (version (number)) thread (IDs): #000: (file name) line (number) in H5Oopen(): unable to open object major: Symbol table minor: Can't open object - #001: (file name) line (number) in H5O_open_name(): object not found + #001: (file name) line (number) in H5VL_object_open(): 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 + major: Symbol table + minor: Can't open object + #003: (file name) line (number) in H5O_open_name(): object not found major: Symbol table minor: Object not found - #002: (file name) line (number) in H5G_loc_find(): can't find object + #004: (file name) line (number) in H5G_loc_find(): can't find object major: Symbol table minor: Object not found - #003: (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 - #004: (file name) line (number) in H5G_traverse_real(): special link traversal failed + #006: (file name) line (number) in H5G_traverse_real(): special link traversal failed major: Links minor: Link traversal failure - #005: (file name) line (number) in H5G__traverse_special(): user-defined link traversal failed + #007: (file name) line (number) in H5G__traverse_special(): user-defined link traversal failed major: Links minor: Link traversal failure - #006: (file name) line (number) in H5G_traverse_ud(): traversal callback returned invalid ID + #008: (file name) line (number) in H5G_traverse_ud(): traversal callback returned invalid ID major: Symbol table minor: Unable to find atom information (already closed?) - #007: (file name) line (number) in H5L_extern_traverse(): unable to open external file, external link file name = 'fname', temp_file_name = 'fname' + #009: (file name) line (number) in H5L_extern_traverse(): unable to open external file, external link file name = 'fname', temp_file_name = 'fname' major: Links minor: Unable to open file diff --git a/tools/h5dump/errfiles/torderlinks2.err b/tools/h5dump/errfiles/torderlinks2.err index 780c7e6..b39f6b8 100644 --- a/tools/h5dump/errfiles/torderlinks2.err +++ b/tools/h5dump/errfiles/torderlinks2.err @@ -2,24 +2,30 @@ HDF5-DIAG: Error detected in HDF5 (version (number)) thread (IDs): #000: (file name) line (number) in H5Oopen(): unable to open object major: Symbol table minor: Can't open object - #001: (file name) line (number) in H5O_open_name(): object not found + #001: (file name) line (number) in H5VL_object_open(): 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 + major: Symbol table + minor: Can't open object + #003: (file name) line (number) in H5O_open_name(): object not found major: Symbol table minor: Object not found - #002: (file name) line (number) in H5G_loc_find(): can't find object + #004: (file name) line (number) in H5G_loc_find(): can't find object major: Symbol table minor: Object not found - #003: (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 - #004: (file name) line (number) in H5G_traverse_real(): special link traversal failed + #006: (file name) line (number) in H5G_traverse_real(): special link traversal failed major: Links minor: Link traversal failure - #005: (file name) line (number) in H5G__traverse_special(): user-defined link traversal failed + #007: (file name) line (number) in H5G__traverse_special(): user-defined link traversal failed major: Links minor: Link traversal failure - #006: (file name) line (number) in H5G_traverse_ud(): traversal callback returned invalid ID + #008: (file name) line (number) in H5G_traverse_ud(): traversal callback returned invalid ID major: Symbol table minor: Unable to find atom information (already closed?) - #007: (file name) line (number) in H5L_extern_traverse(): unable to open external file, external link file name = 'fname', temp_file_name = 'fname' + #009: (file name) line (number) in H5L_extern_traverse(): unable to open external file, external link file name = 'fname', temp_file_name = 'fname' major: Links minor: Unable to open file diff --git a/tools/h5dump/errfiles/tperror.err b/tools/h5dump/errfiles/tperror.err index 19a7a73..84a2065 100644 --- a/tools/h5dump/errfiles/tperror.err +++ b/tools/h5dump/errfiles/tperror.err @@ -1,33 +1,45 @@ HDF5-DIAG: Error detected in HDF5 (version (number)) thread (IDs): - #000: (file name) line (number) in H5Dopen2(): not found + #000: (file name) line (number) in H5Dopen2(): unable to open dataset + major: Dataset + minor: Can't open object + #001: (file name) line (number) in H5VL_dataset_open(): open failed + major: Virtual Object Layer + minor: Can't open object + #002: (file name) line (number) in H5VL_native_dataset_open(): not found major: Dataset minor: Object not found - #001: (file name) line (number) in H5G_loc_find(): can't find object + #003: (file name) line (number) in H5G_loc_find(): can't find object major: Symbol table minor: Object not found - #002: (file name) line (number) in H5G_traverse(): internal path traversal failed + #004: (file name) line (number) in H5G_traverse(): internal path traversal failed major: Symbol table minor: Object not found - #003: (file name) line (number) in H5G_traverse_real(): traversal operator failed + #005: (file name) line (number) in H5G_traverse_real(): traversal operator failed major: Symbol table minor: Callback failed - #004: (file name) line (number) in H5G_loc_find_cb(): object 'bogus' doesn't exist + #006: (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: Internal error (too specific to document in detail) + minor: Can't get value + #001: (file name) line (number) in H5VL_link_get(): 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 major: Symbol table minor: Object not found - #001: (file name) line (number) in H5L_get_info(): name doesn't exist + #003: (file name) line (number) in H5L_get_info(): name doesn't exist major: Symbol table minor: Object already exists - #002: (file name) line (number) in H5G_traverse(): internal path traversal failed + #004: (file name) line (number) in H5G_traverse(): internal path traversal failed major: Symbol table minor: Object not found - #003: (file name) line (number) in H5G_traverse_real(): traversal operator failed + #005: (file name) line (number) in H5G_traverse_real(): traversal operator failed major: Symbol table minor: Callback failed - #004: (file name) line (number) in H5L_get_info_cb(): name doesn't exist + #006: (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 "bogus" diff --git a/tools/h5dump/errfiles/tslink-D.err b/tools/h5dump/errfiles/tslink-D.err index b98e324..59b0b31 100644 --- a/tools/h5dump/errfiles/tslink-D.err +++ b/tools/h5dump/errfiles/tslink-D.err @@ -1,25 +1,31 @@ HDF5-DIAG: Error detected in HDF5 (version (number)) thread (IDs): - #000: (file name) line (number) in H5Dopen2(): not found + #000: (file name) line (number) in H5Dopen2(): unable to open dataset + major: Dataset + minor: Can't open object + #001: (file name) line (number) in H5VL_dataset_open(): open failed + major: Virtual Object Layer + minor: Can't open object + #002: (file name) line (number) in H5VL_native_dataset_open(): not found major: Dataset minor: Object not found - #001: (file name) line (number) in H5G_loc_find(): can't find object + #003: (file name) line (number) in H5G_loc_find(): can't find object major: Symbol table minor: Object not found - #002: (file name) line (number) in H5G_traverse(): internal path traversal failed + #004: (file name) line (number) in H5G_traverse(): internal path traversal failed major: Symbol table minor: Object not found - #003: (file name) line (number) in H5G_traverse_real(): special link traversal failed + #005: (file name) line (number) in H5G_traverse_real(): special link traversal failed major: Links minor: Link traversal failure - #004: (file name) line (number) in H5G__traverse_special(): symbolic link traversal failed + #006: (file name) line (number) in H5G__traverse_special(): symbolic link traversal failed major: Links minor: Link traversal failure - #005: (file name) line (number) in H5G_traverse_slink(): unable to follow symbolic link + #007: (file name) line (number) in H5G_traverse_slink(): unable to follow symbolic link major: Symbol table minor: Object not found - #006: (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 - #007: (file name) line (number) in H5G_traverse_slink_cb(): component not found + #009: (file name) line (number) in H5G_traverse_slink_cb(): component not found major: Symbol table minor: Object not found diff --git a/tools/h5jam/h5jam.c b/tools/h5jam/h5jam.c index ab38f65..19c0a41 100644 --- a/tools/h5jam/h5jam.c +++ b/tools/h5jam/h5jam.c @@ -250,7 +250,7 @@ main (int argc, const char *argv[]) leave (EXIT_FAILURE); } - testval = H5Fis_hdf5 (ub_file); + testval = H5Fis_accessible (ub_file, H5P_DEFAULT); if (testval > 0) { error_msg("-u <user_file> cannot be HDF5 file, but it appears to be an HDF5 file.\n"); @@ -264,7 +264,7 @@ main (int argc, const char *argv[]) leave (EXIT_FAILURE); } - testval = H5Fis_hdf5 (input_file); + testval = H5Fis_accessible (input_file, H5P_DEFAULT); if (testval <= 0) { error_msg("Input HDF5 file \"%s\" is not HDF5 format.\n", input_file); diff --git a/tools/h5jam/h5unjam.c b/tools/h5jam/h5unjam.c index 40358c6..7b4dc91 100644 --- a/tools/h5jam/h5unjam.c +++ b/tools/h5jam/h5unjam.c @@ -245,7 +245,7 @@ main(int argc, const char *argv[]) goto done; } - testval = H5Fis_hdf5(input_file); + testval = H5Fis_accessible(input_file, H5P_DEFAULT); if (testval <= 0) { error_msg("Input HDF5 file \"%s\" is not HDF\n", input_file); diff --git a/tools/h5jam/tellub.c b/tools/h5jam/tellub.c index b4f87af..c6e7fbe 100644 --- a/tools/h5jam/tellub.c +++ b/tools/h5jam/tellub.c @@ -155,7 +155,7 @@ main (int argc, const char *argv[]) ifname = HDstrdup (argv[opt_ind]); - testval = H5Fis_hdf5 (ifname); + testval = H5Fis_accessible (ifname, H5P_DEFAULT); if (testval <= 0) { diff --git a/tools/misc/h5debug.c b/tools/misc/h5debug.c index 617e614..5967954 100644 --- a/tools/misc/h5debug.c +++ b/tools/misc/h5debug.c @@ -256,7 +256,7 @@ main(int argc, char *argv[]) HDfprintf(stderr, "cannot open file\n"); HDexit(1); } /* end if */ - if(NULL == (f = (H5F_t *)H5I_object(fid))) { + if(NULL == (f = (H5F_t *)H5VL_object(fid))) { HDfprintf(stderr, "cannot obtain H5F_t pointer\n"); HDexit(2); } /* end if */ diff --git a/tools/misc/repart_test.c b/tools/misc/repart_test.c index e6da779..bf2c9b9 100644 --- a/tools/misc/repart_test.c +++ b/tools/misc/repart_test.c @@ -79,6 +79,9 @@ test_family_h5repart_opens(void) if((file=H5Fopen(FILENAME[1], H5F_ACC_RDWR, fapl))<0) goto error; + if(H5Pclose(fapl)<0) + goto error; + if(H5Fclose(file)<0) goto error; diff --git a/vms/src/h5pubconf.h b/vms/src/h5pubconf.h index 0291588..9ba7392 100644 --- a/vms/src/h5pubconf.h +++ b/vms/src/h5pubconf.h @@ -35,6 +35,9 @@ /* Define the default virtual file driver to compile */ #define H5_DEFAULT_VFD H5FD_SEC2 +/* Define the default vol plugin to compile */ +#define H5_DEFAULT_VOL H5VL_NATIVE + /* Define if `dev_t' is a scalar */ #define H5_DEV_T_IS_SCALAR 1 |