From f9e9c1ad0eeabce09b2f8613427b83daebbf8cb0 Mon Sep 17 00:00:00 2001 From: Allen Byrne Date: Wed, 19 Dec 2018 12:58:51 -0600 Subject: HDFFV-10664 Add new functions and constants to java interface --- MANIFEST | 4 + java/src/hdf/hdf5lib/H5.java | 158 ++++++++++++++++-------- java/src/hdf/hdf5lib/HDF5Constants.java | 54 +++++++++ java/src/jni/CMakeLists.txt | 2 + java/src/jni/Makefile.am | 2 +- java/src/jni/h5Constants.c | 41 ++++++- java/src/jni/h5vlImp.c | 206 ++++++++++++++++++++++++++++++++ java/src/jni/h5vlImp.h | 91 ++++++++++++++ java/test/CMakeLists.txt | 1 + java/test/Makefile.am | 1 + java/test/TestH5VL.java | 117 ++++++++++++++++++ java/test/junit.sh.in | 21 ++++ java/test/testfiles/JUnit-TestH5VL.txt | 11 ++ 13 files changed, 655 insertions(+), 54 deletions(-) create mode 100644 java/src/jni/h5vlImp.c create mode 100644 java/src/jni/h5vlImp.h create mode 100644 java/test/TestH5VL.java create mode 100644 java/test/testfiles/JUnit-TestH5VL.txt diff --git a/MANIFEST b/MANIFEST index d840e73..c3c7ffc 100644 --- a/MANIFEST +++ b/MANIFEST @@ -2884,6 +2884,8 @@ ./java/src/jni/h5sImp.h ./java/src/jni/h5tImp.c ./java/src/jni/h5tImp.h +./java/src/jni/h5vlImp.c +./java/src/jni/h5vlImp.h ./java/src/jni/h5zImp.c ./java/src/jni/h5zImp.h @@ -3122,6 +3124,7 @@ ./java/test/testfiles/JUnit-TestH5Tparams.txt ./java/test/testfiles/JUnit-TestH5Tbasic.txt ./java/test/testfiles/JUnit-TestH5T.txt +./java/test/testfiles/JUnit-TestH5VL.txt ./java/test/testfiles/JUnit-TestH5Z.txt ./java/test/h5ex_g_iterate.orig ./java/test/TestH5.java @@ -3159,6 +3162,7 @@ ./java/test/TestH5Tparams.java ./java/test/TestH5Tbasic.java ./java/test/TestH5T.java +./java/test/TestH5VL.java ./java/test/TestH5Z.java ./java/test/TestAll.java diff --git a/java/src/hdf/hdf5lib/H5.java b/java/src/hdf/hdf5lib/H5.java index bce0034..e354207 100644 --- a/java/src/hdf/hdf5lib/H5.java +++ b/java/src/hdf/hdf5lib/H5.java @@ -499,9 +499,9 @@ public class H5 implements java.io.Serializable { private synchronized static native boolean H5is_library_threadsafe(); // /////// unimplemented //////// - // H5_DLL herr_t H5free_memory(void *mem); - // H5_DLL void *H5allocate_memory(size_t size, hbool_t clear); - // H5_DLL void *H5resize_memory(void *mem, size_t size); + // herr_t H5free_memory(void *mem); + // void *H5allocate_memory(size_t size, hbool_t clear); + // void *H5resize_memory(void *mem, size_t size); // //////////////////////////////////////////////////////////// // // @@ -2402,10 +2402,10 @@ public class H5 implements java.io.Serializable { public synchronized static native void H5Drefresh(long dset_id) throws HDF5LibraryException; // /////// unimplemented //////// - // H5_DLL herr_t H5Ddebug(hid_t dset_id); - // H5_DLL herr_t H5Dget_chunk_storage_size(hid_t dset_id, const hsize_t *offset, hsize_t *chunk_bytes); - // H5_DLL herr_t H5Dformat_convert(hid_t dset_id); - // H5_DLL herr_t H5Dget_chunk_index_type(hid_t did, H5D_chunk_index_t *idx_type); + // herr_t H5Ddebug(hid_t dset_id); + // herr_t H5Dget_chunk_storage_size(hid_t dset_id, const hsize_t *offset, hsize_t *chunk_bytes); + // herr_t H5Dformat_convert(hid_t dset_id); + // herr_t H5Dget_chunk_index_type(hid_t did, H5D_chunk_index_t *idx_type); // herr_t H5Dgather(hid_t src_space_id, const void *src_buf, hid_t type_id, // size_t dst_buf_size, void *dst_buf, H5D_gather_func_t op, void *op_data); @@ -3230,20 +3230,20 @@ public class H5 implements java.io.Serializable { throws HDF5LibraryException, NullPointerException; // /////// unimplemented //////// - // H5_DLL herr_t H5Fget_eoa(hid_t file_id, haddr_t *eoa); - // H5_DLL herr_t H5Fincrement_filesize(hid_t file_id, hsize_t increment); + // herr_t H5Fget_eoa(hid_t file_id, haddr_t *eoa); + // herr_t H5Fincrement_filesize(hid_t file_id, hsize_t increment); // ssize_t H5Fget_file_image(hid_t file_id, void * buf_ptr, size_t buf_len); // herr_t H5Fget_metadata_read_retry_info(hid_t file_id, H5F_retry_info_t *info); // ssize_t H5Fget_free_sections(hid_t file_id, H5F_mem_t type, size_t nsects, H5F_sect_info_t *sect_info/*out*/); - // H5_DLL herr_t H5Fset_libver_bounds(hid_t file_id, H5F_libver_t low, H5F_libver_t high); - // H5_DLL herr_t H5Fformat_convert(hid_t fid); - // H5_DLL herr_t H5Freset_page_buffering_stats(hid_t file_id); - // H5_DLL herr_t H5Fget_page_buffering_stats(hid_t file_id, unsigned accesses[2], + // herr_t H5Fset_libver_bounds(hid_t file_id, H5F_libver_t low, H5F_libver_t high); + // herr_t H5Fformat_convert(hid_t fid); + // herr_t H5Freset_page_buffering_stats(hid_t file_id); + // herr_t H5Fget_page_buffering_stats(hid_t file_id, unsigned accesses[2], // unsigned hits[2], unsigned misses[2], unsigned evictions[2], unsigned bypasses[2]); - // H5_DLL herr_t H5Fget_mdc_image_info(hid_t file_id, haddr_t *image_addr, hsize_t *image_size); + // herr_t H5Fget_mdc_image_info(hid_t file_id, haddr_t *image_addr, hsize_t *image_size); // #ifdef H5_HAVE_PARALLEL - // H5_DLL herr_t H5Fset_mpi_atomicity(hid_t file_id, hbool_t flag); - // H5_DLL herr_t H5Fget_mpi_atomicity(hid_t file_id, hbool_t *flag); + // herr_t H5Fset_mpi_atomicity(hid_t file_id, hbool_t flag); + // herr_t H5Fget_mpi_atomicity(hid_t file_id, hbool_t *flag); // #endif /* H5_HAVE_PARALLEL */ // /** @@ -3303,25 +3303,25 @@ public class H5 implements java.io.Serializable { // //////////////////////////////////////////////////////////// // /////// unimplemented //////// - // H5_DLL hid_t H5FDregister(const H5FD_class_t *cls); - // H5_DLL herr_t H5FDunregister(hid_t driver_id); - // H5_DLL H5FD_t *H5FDopen(const char *name, unsigned flags, hid_t fapl_id, haddr_t maxaddr); - // H5_DLL herr_t H5FDclose(H5FD_t *file); - // H5_DLL int H5FDcmp(const H5FD_t *f1, const H5FD_t *f2); - // H5_DLL int H5FDquery(const H5FD_t *f, unsigned long *flags); - // H5_DLL haddr_t H5FDalloc(H5FD_t *file, H5FD_mem_t type, hid_t dxpl_id, hsize_t size); - // H5_DLL herr_t H5FDfree(H5FD_t *file, H5FD_mem_t type, hid_t dxpl_id, haddr_t addr, hsize_t size); - // H5_DLL haddr_t H5FDget_eoa(H5FD_t *file, H5FD_mem_t type); - // H5_DLL herr_t H5FDset_eoa(H5FD_t *file, H5FD_mem_t type, haddr_t eoa); - // H5_DLL haddr_t H5FDget_eof(H5FD_t *file, H5FD_mem_t type); - // H5_DLL herr_t H5FDget_vfd_handle(H5FD_t *file, hid_t fapl, void**file_handle); - // H5_DLL herr_t H5FDread(H5FD_t *file, H5FD_mem_t type, hid_t dxpl_id, haddr_t addr, size_t size, void *buf/*out*/); - // H5_DLL herr_t H5FDwrite(H5FD_t *file, H5FD_mem_t type, hid_t dxpl_id, haddr_t addr, size_t size, const void *buf); - // H5_DLL herr_t H5FDflush(H5FD_t *file, hid_t dxpl_id, hbool_t closing); - // H5_DLL herr_t H5FDtruncate(H5FD_t *file, hid_t dxpl_id, hbool_t closing); - // H5_DLL herr_t H5FDlock(H5FD_t *file, hbool_t rw); - // H5_DLL herr_t H5FDunlock(H5FD_t *file); - // H5_DLL herr_t H5FDdriver_query(hid_t driver_id, unsigned long *flags/*out*/); + // hid_t H5FDregister(const H5FD_class_t *cls); + // herr_t H5FDunregister(hid_t driver_id); + // H5FD_t *H5FDopen(const char *name, unsigned flags, hid_t fapl_id, haddr_t maxaddr); + // herr_t H5FDclose(H5FD_t *file); + // int H5FDcmp(const H5FD_t *f1, const H5FD_t *f2); + // int H5FDquery(const H5FD_t *f, unsigned long *flags); + // haddr_t H5FDalloc(H5FD_t *file, H5FD_mem_t type, hid_t dxpl_id, hsize_t size); + // herr_t H5FDfree(H5FD_t *file, H5FD_mem_t type, hid_t dxpl_id, haddr_t addr, hsize_t size); + // haddr_t H5FDget_eoa(H5FD_t *file, H5FD_mem_t type); + // herr_t H5FDset_eoa(H5FD_t *file, H5FD_mem_t type, haddr_t eoa); + // haddr_t H5FDget_eof(H5FD_t *file, H5FD_mem_t type); + // herr_t H5FDget_vfd_handle(H5FD_t *file, hid_t fapl, void**file_handle); + // herr_t H5FDread(H5FD_t *file, H5FD_mem_t type, hid_t dxpl_id, haddr_t addr, size_t size, void *buf/*out*/); + // herr_t H5FDwrite(H5FD_t *file, H5FD_mem_t type, hid_t dxpl_id, haddr_t addr, size_t size, const void *buf); + // herr_t H5FDflush(H5FD_t *file, hid_t dxpl_id, hbool_t closing); + // herr_t H5FDtruncate(H5FD_t *file, hid_t dxpl_id, hbool_t closing); + // herr_t H5FDlock(H5FD_t *file, hbool_t rw); + // herr_t H5FDunlock(H5FD_t *file); + // herr_t H5FDdriver_query(hid_t driver_id, unsigned long *flags/*out*/); // //////////////////////////////////////////////////////////// // // @@ -3794,7 +3794,7 @@ public class H5 implements java.io.Serializable { // //////////////////////////////////////////////////////////// // // - // H5I: HDF5 1.8 Identifier Interface API Functions // + // H5I: HDF5 Identifier Interface API Functions // // // // //////////////////////////////////////////////////////////// @@ -3950,12 +3950,20 @@ public class H5 implements java.io.Serializable { // hid_t H5Iregister(H5I_type_t type, const void *object); + // typedef herr_t (*H5I_free_t)(void *); // H5I_type_t H5Iregister_type(size_t hash_size, unsigned reserved, H5I_free_t free_func); // void *H5Iremove_verify(hid_t id, H5I_type_t id_type); + // Type of the function to compare objects & keys + // typedef int (*H5I_search_func_t)(void *obj, hid_t id, void *key); // void *H5Isearch(H5I_type_t type, H5I_search_func_t func, void *key); + // Type of the H5Iiterate callback function + // typedef herr_t (*H5I_iterate_func_t)(hid_t id, void *udata); + // herr_t H5Iiterate(H5I_type_t type, H5I_iterate_func_t op, void *op_data); + + // ////////////////////////////////////////////////////////////////// // H5L: Link Interface Functions // // ////////////////////////////////////////////////////////////////// @@ -4983,9 +4991,9 @@ public class H5 implements java.io.Serializable { public synchronized static native void H5Orefresh(long object_id) throws HDF5LibraryException; // /////// unimplemented //////// - // H5_DLL herr_t H5Odisable_mdc_flushes(hid_t object_id); - // H5_DLL herr_t H5Oenable_mdc_flushes(hid_t object_id); - // H5_DLL herr_t H5Oare_mdc_flushes_disabled(hid_t object_id, hbool_t *are_disabled); + // herr_t H5Odisable_mdc_flushes(hid_t object_id); + // herr_t H5Oenable_mdc_flushes(hid_t object_id); + // herr_t H5Oare_mdc_flushes_disabled(hid_t object_id, hbool_t *are_disabled); // //////////////////////////////////////////////////////////// // // @@ -5270,6 +5278,27 @@ public class H5 implements java.io.Serializable { private synchronized static native long _H5Pcopy(long plist) throws HDF5LibraryException; + // Define property list class callback function pointer types + // typedef herr_t (*H5P_cls_create_func_t)(hid_t prop_id, void *create_data); + // typedef herr_t (*H5P_cls_copy_func_t)(hid_t new_prop_id, hid_t old_prop_id, void *copy_data); + // typedef herr_t (*H5P_cls_close_func_t)(hid_t prop_id, void *close_data); + + // Define property list callback function pointer types + // typedef herr_t (*H5P_prp_cb1_t)(const char *name, size_t size, void *value); + // typedef herr_t (*H5P_prp_cb2_t)(hid_t prop_id, const char *name, size_t size, void *value); + // typedef H5P_prp_cb1_t H5P_prp_create_func_t; + // typedef H5P_prp_cb2_t H5P_prp_set_func_t; + // typedef H5P_prp_cb2_t H5P_prp_get_func_t; + // typedef herr_t (*H5P_prp_encode_func_t)(const void *value, void **buf, size_t *size); + // typedef herr_t (*H5P_prp_decode_func_t)(const void **buf, void *value); + // typedef H5P_prp_cb2_t H5P_prp_delete_func_t; + // typedef H5P_prp_cb1_t H5P_prp_copy_func_t; + // typedef int (*H5P_prp_compare_func_t)(const void *value1, const void *value2, size_t size); + // typedef H5P_prp_cb1_t H5P_prp_close_func_t; + + // Define property list iteration function type + // typedef herr_t (*H5P_iterate_t)(hid_t id, const char *name, void *iter_data); + public static long H5Pcreate_class_nocb(long parent_class, String name) throws HDF5LibraryException { long id = _H5Pcreate_class_nocb(parent_class, name); if (id > 0) { @@ -6433,6 +6462,11 @@ public class H5 implements java.io.Serializable { public synchronized static native void H5Pset_evict_on_close(long fapl_id, boolean evict_on_close) throws HDF5LibraryException; + // ///// unimplemented ///// + // herr_t H5Pset_vol(hid_t plist_id, hid_t new_vol_id, const void *new_vol_info); + // herr_t H5Pget_vol_id(hid_t plist_id, hid_t *vol_id); + // herr_t H5Pget_vol_info(hid_t plist_id, void **vol_info); + // Dataset creation property list (DCPL) routines // /** @@ -7811,13 +7845,13 @@ public class H5 implements java.io.Serializable { // herr_t H5Pget_core_write_tracking(hid_t fapl_id, hbool_t *is_enabled, size_t *page_size); // #ifdef H5_HAVE_PARALLEL // herr_t H5Pset_all_coll_metadata_ops(hid_t accpl_id, hbool_t is_collective); - // H5_DLL herr_t H5Pget_all_coll_metadata_ops(hid_t plist_id, hbool_t *is_collective); + // herr_t H5Pget_all_coll_metadata_ops(hid_t plist_id, hbool_t *is_collective); // herr_t H5Pset_coll_metadata_write(hid_t fapl_id, hbool_t is_collective); // herr_t H5Pget_coll_metadata_write(hid_t fapl_id, hbool_t *is_collective); // #endif /* H5_HAVE_PARALLEL */ - // H5_DLL herr_t H5Pset_mdc_image_config(hid_t plist_id, H5AC_cache_image_config_t *config_ptr); - // H5_DLL herr_t H5Pget_mdc_image_config(hid_t plist_id, H5AC_cache_image_config_t *config_ptr /*out*/); - // H5_DLL herr_t H5Pset_page_buffer_size(hid_t plist_id, size_t buf_size, unsigned min_meta_per, unsigned min_raw_per); + // herr_t H5Pset_mdc_image_config(hid_t plist_id, H5AC_cache_image_config_t *config_ptr); + // herr_t H5Pget_mdc_image_config(hid_t plist_id, H5AC_cache_image_config_t *config_ptr /*out*/); + // herr_t H5Pset_page_buffer_size(hid_t plist_id, size_t buf_size, unsigned min_meta_per, unsigned min_raw_per); // herr_t H5Pget_page_buffer_size(hid_t fapl_id, size_t *buf_size, unsigned *min_meta_perc, unsigned *min_raw_perc); // herr_t H5Pset_object_flush_cb (hid_t fapl_id, H5F_flush_cb_t func, void *user_data); // herr_t H5Pget_object_flush_cb (hid_t fapl_id, H5F_flush_cb_t *func, void **user_data); @@ -7840,9 +7874,9 @@ public class H5 implements java.io.Serializable { // herr_t H5Pget_type_conv_cb(hid_t plist, H5T_conv_except_func_t *func, void **op_data) // herr_t H5Pset_type_conv_cb( hid_t plist, H5T_conv_except_func_t func, void *op_data) // #ifdef H5_HAVE_PARALLEL - // H5_DLL herr_t H5Pget_mpio_actual_chunk_opt_mode(hid_t plist_id, H5D_mpio_actual_chunk_opt_mode_t *actual_chunk_opt_mode); - // H5_DLL herr_t H5Pget_mpio_actual_io_mode(hid_t plist_id, H5D_mpio_actual_io_mode_t *actual_io_mode); - // H5_DLL herr_t H5Pget_mpio_no_collective_cause(hid_t plist_id, uint32_t *local_no_collective_cause, uint32_t *global_no_collective_cause); + // herr_t H5Pget_mpio_actual_chunk_opt_mode(hid_t plist_id, H5D_mpio_actual_chunk_opt_mode_t *actual_chunk_opt_mode); + // herr_t H5Pget_mpio_actual_io_mode(hid_t plist_id, H5D_mpio_actual_io_mode_t *actual_io_mode); + // herr_t H5Pget_mpio_no_collective_cause(hid_t plist_id, uint32_t *local_no_collective_cause, uint32_t *global_no_collective_cause); // #endif /* H5_HAVE_PARALLEL */ // Link creation property list (LCPL) routines // @@ -8785,16 +8819,17 @@ public class H5 implements java.io.Serializable { // /////// unimplemented //////// // #ifdef NEW_HYPERSLAB_API - // H5_DLL hid_t H5Scombine_hyperslab(hid_t space_id, H5S_seloper_t op, + // hid_t H5Scombine_hyperslab(hid_t space_id, H5S_seloper_t op, // const hsize_t start[], // const hsize_t _stride[], // const hsize_t count[], // const hsize_t _block[]); - // H5_DLL herr_t H5Sselect_select(hid_t space1_id, H5S_seloper_t op, + // herr_t H5Sselect_select(hid_t space1_id, H5S_seloper_t op, // hid_t space2_id); - // H5_DLL hid_t H5Scombine_select(hid_t space1_id, H5S_seloper_t op, + // hid_t H5Scombine_select(hid_t space1_id, H5S_seloper_t op, // hid_t space2_id); // #endif /* NEW_HYPERSLAB_API */ + // herr_t H5Sselect_copy(hid_t dst_id, hid_t src_id); @@ -10273,6 +10308,25 @@ public class H5 implements java.io.Serializable { // //////////////////////////////////////////////////////////// // // + // H5VL: VOL Interface Functions // + // // + // //////////////////////////////////////////////////////////// + + /// VOL Connector Functionality + public synchronized static native long H5VLregister_connector_by_name(String connector_name, long vipl_id); + public synchronized static native long H5VLregister_connector_by_value(int connector_value, long vipl_id); + public synchronized static native boolean H5VLis_connector_registered(String name); + public synchronized static native long H5VLget_connector_id(String name); + public synchronized static native String H5VLget_connector_name(long object_id); + public synchronized static native void H5VLclose(long connector_id); + public synchronized static native void H5VLunregister_connector(long connector_id); + + // /////// unimplemented //////// + // hid_t H5VLregister_connector(const H5VL_class_t *cls, hid_t vipl_id); + + + // //////////////////////////////////////////////////////////// + // // // H5Z: Filter Interface Functions // // // // //////////////////////////////////////////////////////////// @@ -10283,9 +10337,9 @@ public class H5 implements java.io.Serializable { public synchronized static native int H5Zunregister(int filter) throws HDF5LibraryException, NullPointerException; -} + // /////// unimplemented //////// -// /////// unimplemented //////// + // herr_t H5Zregister(const void *cls); -// herr_t H5Zregister(const void *cls); +} diff --git a/java/src/hdf/hdf5lib/HDF5Constants.java b/java/src/hdf/hdf5lib/HDF5Constants.java index 0760e7f..a0c2ed6 100644 --- a/java/src/hdf/hdf5lib/HDF5Constants.java +++ b/java/src/hdf/hdf5lib/HDF5Constants.java @@ -195,6 +195,11 @@ public class HDF5Constants { public static final long H5E_WALK_UPWARD = H5E_WALK_UPWARD(); public static final long H5E_WRITEERROR = H5E_WRITEERROR(); + private static final int H5ES_STATUS_IN_PROGRESS = H5ES_STATUS_IN_PROGRESS(); + private static final int H5ES_STATUS_SUCCEED = H5ES_STATUS_SUCCEED(); + private static final int H5ES_STATUS_FAIL = H5ES_STATUS_FAIL(); + private static final int H5ES_STATUS_CANCELED = H5ES_STATUS_CANCELED(); + public static final int H5F_ACC_CREAT = H5F_ACC_CREAT(); public static final int H5F_ACC_EXCL = H5F_ACC_EXCL(); public static final int H5F_ACC_RDONLY = H5F_ACC_RDONLY(); @@ -389,7 +394,10 @@ public class HDF5Constants { public static final int H5PL_TYPE_ERROR = H5PL_TYPE_ERROR(); public static final int H5PL_TYPE_FILTER = H5PL_TYPE_FILTER(); + public static final int H5PL_TYPE_VOL = H5PL_TYPE_VOL(); + public static final int H5PL_TYPE_NONE = H5PL_TYPE_NONE(); public static final int H5PL_FILTER_PLUGIN = H5PL_FILTER_PLUGIN(); + public static final int H5PL_VOL_PLUGIN = H5PL_VOL_PLUGIN(); public static final int H5PL_ALL_PLUGIN = H5PL_ALL_PLUGIN(); public static final int H5R_BADTYPE = H5R_BADTYPE(); @@ -625,6 +633,18 @@ public class HDF5Constants { public static final long H5T_VARIABLE = H5T_VARIABLE(); public static final int H5T_VLEN = H5T_VLEN(); public static final int H5T_VL_T = H5T_VL_T(); + + public static final int H5VL_CAP_FLAG_NONE = H5VL_CAP_FLAG_NONE(); + public static final int H5VL_CAP_FLAG_THREADSAFE = H5VL_CAP_FLAG_THREADSAFE(); + public static final long H5VL_NATIVE = H5VL_NATIVE(); + public static final String H5VL_NATIVE_NAME = H5VL_NATIVE_NAME(); + public static final int H5VL_NATIVE_VALUE = H5VL_NATIVE_VALUE(); + public static final int H5VL_NATIVE_VERSION = H5VL_NATIVE_VERSION(); + public static final int H5_VOL_INVALID = H5_VOL_INVALID(); + public static final int H5_VOL_NATIVE = H5_VOL_NATIVE(); + public static final int H5_VOL_RESERVED = H5_VOL_RESERVED(); + public static final int H5_VOL_MAX = H5_VOL_MAX(); + public static final int H5Z_CB_CONT = H5Z_CB_CONT(); public static final int H5Z_CB_ERROR = H5Z_CB_ERROR(); public static final int H5Z_CB_FAIL = H5Z_CB_FAIL(); @@ -989,6 +1009,14 @@ public class HDF5Constants { private static native final long H5E_WRITEERROR(); + private static native final int H5ES_STATUS_IN_PROGRESS(); + + private static native final int H5ES_STATUS_SUCCEED(); + + private static native final int H5ES_STATUS_FAIL(); + + private static native final int H5ES_STATUS_CANCELED(); + private static native final int H5F_ACC_CREAT(); private static native final int H5F_ACC_EXCL(); @@ -1361,10 +1389,16 @@ public class HDF5Constants { private static native final int H5PL_TYPE_FILTER(); + private static native final int H5PL_TYPE_VOL(); + + private static native final int H5PL_TYPE_NONE(); + private static native final int H5PL_FILTER_PLUGIN(); private static native final int H5PL_ALL_PLUGIN(); + private static native final int H5PL_VOL_PLUGIN(); + private static native final int H5R_BADTYPE(); private static native final int H5R_DATASET_REGION(); @@ -1831,6 +1865,26 @@ public class HDF5Constants { private static native final int H5T_VL_T(); + private static native final int H5VL_CAP_FLAG_NONE(); + + private static native final int H5VL_CAP_FLAG_THREADSAFE(); + + private static native final long H5VL_NATIVE(); + + private static native final String H5VL_NATIVE_NAME(); + + private static native final int H5VL_NATIVE_VALUE(); + + private static native final int H5VL_NATIVE_VERSION(); + + private static native final int H5_VOL_INVALID(); + + private static native final int H5_VOL_NATIVE(); + + private static native final int H5_VOL_RESERVED(); + + private static native final int H5_VOL_MAX(); + private static native final int H5Z_CB_CONT(); private static native final int H5Z_CB_ERROR(); diff --git a/java/src/jni/CMakeLists.txt b/java/src/jni/CMakeLists.txt index 50e76e1..00c2b34 100644 --- a/java/src/jni/CMakeLists.txt +++ b/java/src/jni/CMakeLists.txt @@ -19,6 +19,7 @@ set (HDF5_JAVA_JNI_CSRCS ${HDF5_JAVA_JNI_SOURCE_DIR}/h5sImp.c ${HDF5_JAVA_JNI_SOURCE_DIR}/h5tImp.c ${HDF5_JAVA_JNI_SOURCE_DIR}/h5util.c + ${HDF5_JAVA_JNI_SOURCE_DIR}/h5vlImp.c ${HDF5_JAVA_JNI_SOURCE_DIR}/h5zImp.c ${HDF5_JAVA_JNI_SOURCE_DIR}/nativeData.c ) @@ -40,6 +41,7 @@ set (HDF5_JAVA_JNI_CHDRS ${HDF5_JAVA_JNI_SOURCE_DIR}/h5sImp.h ${HDF5_JAVA_JNI_SOURCE_DIR}/h5tImp.h ${HDF5_JAVA_JNI_SOURCE_DIR}/h5util.h + ${HDF5_JAVA_JNI_SOURCE_DIR}/h5vlImp.h ${HDF5_JAVA_JNI_SOURCE_DIR}/h5zImp.h ${HDF5_JAVA_JNI_SOURCE_DIR}/nativeData.h ) diff --git a/java/src/jni/Makefile.am b/java/src/jni/Makefile.am index 6ded371..370b08b 100644 --- a/java/src/jni/Makefile.am +++ b/java/src/jni/Makefile.am @@ -34,7 +34,7 @@ libhdf5_java_la_LDFLAGS = -avoid-version -shared -export-dynamic -version-info $ # Source files for the library libhdf5_java_la_SOURCES=exceptionImp.c h5Constants.c nativeData.c h5util.c h5Imp.c \ h5aImp.c h5dImp.c h5eImp.c h5fImp.c h5gImp.c h5iImp.c h5lImp.c h5oImp.c \ - h5pImp.c h5plImp.c h5rImp.c h5sImp.c h5tImp.c h5zImp.c + h5pImp.c h5plImp.c h5rImp.c h5sImp.c h5tImp.c h5vlImp.c h5zImp.c # HDF5 Java (JNI) library depends on HDF5 Library. libhdf5_java_la_LIBADD=$(LIBHDF5) diff --git a/java/src/jni/h5Constants.c b/java/src/jni/h5Constants.c index b13dc76..e88fa55 100644 --- a/java/src/jni/h5Constants.c +++ b/java/src/jni/h5Constants.c @@ -21,8 +21,10 @@ extern "C" { #endif /* __cplusplus */ -#include #include "hdf5.h" +#include +#include +#include "h5jni.h" #pragma GCC diagnostic push #pragma GCC diagnostic ignored "-Wmissing-prototypes" @@ -352,6 +354,15 @@ Java_hdf_hdf5lib_HDF5Constants_H5E_1WALK_1UPWARD(JNIEnv *env, jclass cls) { retu JNIEXPORT jlong JNICALL Java_hdf_hdf5lib_HDF5Constants_H5E_1WRITEERROR(JNIEnv *env, jclass cls) { return H5E_WRITEERROR; } +JNIEXPORT jlong JNICALL +Java_hdf_hdf5lib_HDF5Constants_H5ES_1STATUS_1IN_1PROGRESS(JNIEnv *env, jclass cls) { return H5ES_STATUS_IN_PROGRESS; } +JNIEXPORT jlong JNICALL +Java_hdf_hdf5lib_HDF5Constants_H5ES_1STATUS_1SUCCEED(JNIEnv *env, jclass cls) { return H5ES_STATUS_SUCCEED; } +JNIEXPORT jlong JNICALL +Java_hdf_hdf5lib_HDF5Constants_H5ES_1STATUS_1FAIL(JNIEnv *env, jclass cls) { return H5ES_STATUS_FAIL; } +JNIEXPORT jlong JNICALL +Java_hdf_hdf5lib_HDF5Constants_H5ES_1STATUS_1CANCELED(JNIEnv *env, jclass cls) { return H5ES_STATUS_CANCELED; } + /* Java does not have unsigned native types */ #pragma GCC diagnostic push #pragma GCC diagnostic ignored "-Wsign-conversion" @@ -761,8 +772,14 @@ Java_hdf_hdf5lib_HDF5Constants_H5PL_1TYPE_1ERROR(JNIEnv *env, jclass cls) { retu JNIEXPORT jint JNICALL Java_hdf_hdf5lib_HDF5Constants_H5PL_1TYPE_1FILTER(JNIEnv *env, jclass cls) { return H5PL_TYPE_FILTER; } JNIEXPORT jint JNICALL +Java_hdf_hdf5lib_HDF5Constants_H5PL_1TYPE_1VOL(JNIEnv *env, jclass cls) { return H5PL_TYPE_VOL; } +JNIEXPORT jint JNICALL +Java_hdf_hdf5lib_HDF5Constants_H5PL_1TYPE_1NONE(JNIEnv *env, jclass cls) { return H5PL_TYPE_NONE; } +JNIEXPORT jint JNICALL Java_hdf_hdf5lib_HDF5Constants_H5PL_1FILTER_1PLUGIN(JNIEnv *env, jclass cls) { return H5PL_FILTER_PLUGIN; } JNIEXPORT jint JNICALL +Java_hdf_hdf5lib_HDF5Constants_H5PL_1VOL_1PLUGIN(JNIEnv *env, jclass cls) { return H5PL_VOL_PLUGIN; } +JNIEXPORT jint JNICALL Java_hdf_hdf5lib_HDF5Constants_H5PL_1ALL_1PLUGIN(JNIEnv *env, jclass cls) { return H5PL_ALL_PLUGIN; } JNIEXPORT jint JNICALL @@ -1237,6 +1254,28 @@ JNIEXPORT jint JNICALL Java_hdf_hdf5lib_HDF5Constants_H5T_1VL_1T(JNIEnv *env, jclass cls) { return sizeof(hvl_t); } JNIEXPORT jint JNICALL +Java_hdf_hdf5lib_HDF5Constants_H5VL_1CAP_1FLAG_1NONE(JNIEnv *env, jclass cls) { return H5VL_CAP_FLAG_NONE; } +JNIEXPORT jint JNICALL +Java_hdf_hdf5lib_HDF5Constants_H5VL_1CAP_1FLAG_1THREADSAFE(JNIEnv *env, jclass cls) { return H5VL_CAP_FLAG_THREADSAFE; } +JNIEXPORT jlong JNICALL +Java_hdf_hdf5lib_HDF5Constants_H5VL_1NATIVE(JNIEnv *env, jclass cls) { return H5VL_NATIVE; } +JNIEXPORT jobject JNICALL +Java_hdf_hdf5lib_HDF5Constants_H5VL_1NATIVE_1NAME(JNIEnv *env, jclass cls) { return (jstring)ENVPTR->NewStringUTF(ENVPAR H5VL_NATIVE_NAME); } +JNIEXPORT jint JNICALL +Java_hdf_hdf5lib_HDF5Constants_H5VL_1NATIVE_1VALUE(JNIEnv *env, jclass cls) { return H5VL_NATIVE_VALUE; } +JNIEXPORT jint JNICALL +Java_hdf_hdf5lib_HDF5Constants_H5VL_1NATIVE_1VERSION(JNIEnv *env, jclass cls) { return H5VL_NATIVE_VERSION; } + +JNIEXPORT jint JNICALL +Java_hdf_hdf5lib_HDF5Constants_H5_1VOL_1INVALID(JNIEnv *env, jclass cls) { return H5_VOL_INVALID; } +JNIEXPORT jint JNICALL +Java_hdf_hdf5lib_HDF5Constants_H5_1VOL_1NATIVE(JNIEnv *env, jclass cls) { return H5_VOL_NATIVE; } +JNIEXPORT jint JNICALL +Java_hdf_hdf5lib_HDF5Constants_H5_1VOL_1RESERVED(JNIEnv *env, jclass cls) { return H5_VOL_RESERVED; } +JNIEXPORT jint JNICALL +Java_hdf_hdf5lib_HDF5Constants_H5_1VOL_1MAX(JNIEnv *env, jclass cls) { return H5_VOL_MAX; } + +JNIEXPORT jint JNICALL Java_hdf_hdf5lib_HDF5Constants_H5Z_1CB_1CONT(JNIEnv *env, jclass cls) { return H5Z_CB_CONT; } JNIEXPORT jint JNICALL Java_hdf_hdf5lib_HDF5Constants_H5Z_1CB_1ERROR(JNIEnv *env, jclass cls) { return H5Z_CB_ERROR; } diff --git a/java/src/jni/h5vlImp.c b/java/src/jni/h5vlImp.c new file mode 100644 index 0000000..89ea703 --- /dev/null +++ b/java/src/jni/h5vlImp.c @@ -0,0 +1,206 @@ +/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * + * Copyright by The HDF Group. * + * Copyright by the Board of Trustees of the University of Illinois. * + * All rights reserved. * + * * + * This file is part of HDF5. The full HDF5 copyright notice, including * + * terms governing use, modification, and redistribution, is contained in * + * the COPYING file, which can be found at the root of the source code * + * distribution tree, or in https://support.hdfgroup.org/ftp/HDF5/releases. * + * If you do not have access to either file, you may request a copy from * + * help@hdfgroup.org. * + * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ + +/* + * For details of the HDF libraries, see the HDF Documentation at: + * http://hdfgroup.org/HDF5/doc/ + * + */ + +#ifdef __cplusplus +extern "C" { +#endif /* __cplusplus */ + +#include "hdf5.h" +#include +#include +#include "h5jni.h" +#include "h5vlImp.h" + +/* + * Class: hdf_hdf5lib_H5 + * Method: H5VLregister_connector_by_name + * Signature: (Ljava/lang/String;J)J + */ +JNIEXPORT jlong JNICALL +Java_hdf_hdf5lib_H5_H5VLregister_1connector_1by_1name + (JNIEnv *env, jclass clss, jobject connector_name, jlong vipl_id) +{ + hid_t status = -1; + const char *vlName; + + PIN_JAVA_STRING(connector_name, vlName); + if (vlName != NULL) { + status = H5VLregister_connector_by_name(vlName, (hid_t)vipl_id); + + UNPIN_JAVA_STRING(connector_name, vlName); + + if (status < 0) + h5libraryError(env); + } + + return (jlong)status; +} /* end Java_hdf_hdf5lib_H5_H5VLregister_1connector_1by_1name */ + +/* + * Class: hdf_hdf5lib_H5 + * Method: H5VLregister_connector_by_value + * Signature: (IJ)J + */ +JNIEXPORT jlong JNICALL +Java_hdf_hdf5lib_H5_H5VLregister_1connector_1by_1value + (JNIEnv *env, jclass clss, jint connector_value, jlong vipl_id) +{ + hid_t status = H5VLregister_connector_by_value((H5VL_class_value_t)connector_value, (hid_t)vipl_id); + + if (status < 0) + h5libraryError(env); + + return (jlong)status; +} /* end Java_hdf_hdf5lib_H5_H5VLregister_1connector_1by_1value */ + +/* + * Class: hdf_hdf5lib_H5 + * Method: H5VLis_connector_registered + * Signature: (Ljava/lang/String;)Z + */ +JNIEXPORT jboolean JNICALL +Java_hdf_hdf5lib_H5_H5VLis_1connector_1registered + (JNIEnv *env, jclass clss, jobject connector_name) +{ + htri_t bval = JNI_FALSE; + const char *vlName; + + PIN_JAVA_STRING(connector_name, vlName); + if (vlName != NULL) { + bval = H5VLis_connector_registered(vlName); + + UNPIN_JAVA_STRING(connector_name, vlName); + + if (bval > 0) + bval = JNI_TRUE; + else if (bval < 0) + h5libraryError(env); + } + + return (jboolean)bval; +} /* end Java_hdf_hdf5lib_H5_H5VLis_1connector_1registered */ + +/* + * Class: hdf_hdf5lib_H5 + * Method: H5VLget_connector_id + * Signature: (Ljava/lang/String;)J + */ +JNIEXPORT jlong JNICALL +Java_hdf_hdf5lib_H5_H5VLget_1connector_1id + (JNIEnv *env, jclass clss, jobject connector_name) +{ + hid_t status = -1; + const char *vlName; + + PIN_JAVA_STRING(connector_name, vlName); + if (vlName != NULL) { + status = H5VLget_connector_id(vlName); + + UNPIN_JAVA_STRING(connector_name, vlName); + + if (status < 0) + h5libraryError(env); + } + + return (jlong)status; +} /* end Java_hdf_hdf5lib_H5_H5VLget_1connector_1id */ + +/* + * Class: hdf_hdf5lib_H5 + * Method: H5VLget_connector_name + * Signature: (J)Ljava/lang/String; + */ + +JNIEXPORT jobject JNICALL +Java_hdf_hdf5lib_H5_H5VLget_1connector_1name + (JNIEnv *env, jclass clss, jlong object_id) +{ + char *vlName; + ssize_t buf_size; + ssize_t status; + jstring str = NULL; + + /* get the length of the comment */ + buf_size = H5VLget_connector_name((hid_t)object_id, NULL, 0); + if (buf_size < 0) { + H5Eprint2(H5E_DEFAULT, NULL); + + h5badArgument(env, "H5VLget_connector_name: buf_size < 0"); + } /* end if */ + else if (buf_size > 0) { + buf_size++; /* add extra space for the null terminator */ + vlName = (char *)HDmalloc(sizeof(char) * (size_t)buf_size); + if (vlName == NULL) { + /* exception -- out of memory */ + h5outOfMemory(env, "H5VLget_connector_name: malloc failed"); + } /* end if */ + else { + status = H5VLget_connector_name((hid_t)object_id, vlName, (size_t)buf_size); + + if (status < 0) { + h5libraryError(env); + } /* end if */ + else { + /* may throw OutOfMemoryError */ + str = ENVPTR->NewStringUTF(ENVPAR vlName); + if (str == NULL) { + h5JNIFatalError(env, "H5VLget_connector_name: return string not allocated"); + } /* end if */ + } /* end else */ + HDfree(vlName); + } + } /* end else if */ + + return (jstring)str; +} /* end Java_hdf_hdf5lib_H5_H5VLget_1connector_1name */ + +/* + * Class: hdf_hdf5lib_H5 + * Method: H5VLclose + * Signature: (J)V + */ +JNIEXPORT void JNICALL +Java_hdf_hdf5lib_H5_H5VLclose + (JNIEnv *env, jclass clss, jlong connector_id) +{ + herr_t retValue = H5VLclose((hid_t)connector_id); + + if (retValue < 0) + h5libraryError(env); +} /* end Java_hdf_hdf5lib_H5_H5VLclose */ + +/* + * Class: hdf_hdf5lib_H5 + * Method: H5VLunregister_connector + * Signature: (J)V + */ +JNIEXPORT void JNICALL +Java_hdf_hdf5lib_H5_H5VLunregister_1connector + (JNIEnv *env, jclass clss, jlong connector_id) +{ + herr_t retValue = H5VLunregister_connector((hid_t)connector_id); + + if (retValue < 0) + h5libraryError(env); +} /* end Java_hdf_hdf5lib_H5_H5VLunregister_1connector */ + + +#ifdef __cplusplus +} /* end extern "C" */ +#endif /* __cplusplus */ diff --git a/java/src/jni/h5vlImp.h b/java/src/jni/h5vlImp.h new file mode 100644 index 0000000..af824a9 --- /dev/null +++ b/java/src/jni/h5vlImp.h @@ -0,0 +1,91 @@ +/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * + * Copyright by The HDF Group. * + * Copyright by the Board of Trustees of the University of Illinois. * + * All rights reserved. * + * * + * This file is part of HDF5. The full HDF5 copyright notice, including * + * terms governing use, modification, and redistribution, is contained in * + * the COPYING file, which can be found at the root of the source code * + * distribution tree, or in https://support.hdfgroup.org/ftp/HDF5/releases. * + * If you do not have access to either file, you may request a copy from * + * help@hdfgroup.org. * + * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ + +#include +/* Header for class hdf_hdf5lib_H5_H5VL */ + +#ifndef _Included_hdf_hdf5lib_H5_H5VL +#define _Included_hdf_hdf5lib_H5_H5VL + +#ifdef __cplusplus +extern "C" { +#endif /* __cplusplus */ +/* + * Class: hdf_hdf5lib_H5 + * Method: H5VLregister_connector_by_name + * Signature: (Ljava/lang/String;J)J + */ +JNIEXPORT jlong JNICALL +Java_hdf_hdf5lib_H5_H5VLregister_1connector_1by_1name + (JNIEnv *, jclass, jobject, jlong); + +/* + * Class: hdf_hdf5lib_H5 + * Method: H5VLregister_connector_by_value + * Signature: (IJ)J + */ +JNIEXPORT jlong JNICALL +Java_hdf_hdf5lib_H5_H5VLregister_1connector_1by_1value + (JNIEnv *, jclass, jint, jlong); + +/* + * Class: hdf_hdf5lib_H5 + * Method: H5VLis_connector_registered + * Signature: (Ljava/lang/String;)Z + */ +JNIEXPORT jboolean JNICALL +Java_hdf_hdf5lib_H5_H5VLis_connector_registered + (JNIEnv *, jclass, jobject); + +/* + * Class: hdf_hdf5lib_H5 + * Method: H5VLget_connector_id + * Signature: (Ljava/lang/String;)J + */ +JNIEXPORT jlong JNICALL +Java_hdf_hdf5lib_H5_H5VLget_1connector_1id + (JNIEnv *, jclass, jobject); + +/* + * Class: hdf_hdf5lib_H5 + * Method: H5VLget_connector_name + * Signature: (J)Ljava/lang/String; + */ + +JNIEXPORT jobject JNICALL +Java_hdf_hdf5lib_H5_H5VLget_1connector_1name + (JNIEnv *, jclass, jlong); + +/* + * Class: hdf_hdf5lib_H5 + * Method: H5VLclose + * Signature: (J)V + */ +JNIEXPORT void JNICALL +Java_hdf_hdf5lib_H5_H5VLclose + (JNIEnv *, jclass, jlong); + +/* + * Class: hdf_hdf5lib_H5 + * Method: H5VLunregister_connector + * Signature: (J)V + */ +JNIEXPORT void JNICALL +Java_hdf_hdf5lib_H5_H5VLunregister_1connector + (JNIEnv *, jclass, jlong); + +#ifdef __cplusplus +} /* end extern "C" */ +#endif /* __cplusplus */ + +#endif /* _Included_hdf_hdf5lib_H5_H5VL */ diff --git a/java/test/CMakeLists.txt b/java/test/CMakeLists.txt index b76f572..937b129 100644 --- a/java/test/CMakeLists.txt +++ b/java/test/CMakeLists.txt @@ -38,6 +38,7 @@ set (HDF5_JAVA_TEST_SOURCES TestH5Ocreate TestH5Ocopy TestH5PL + TestH5VL TestH5Z ) diff --git a/java/test/Makefile.am b/java/test/Makefile.am index 6635ef7..af99d92 100644 --- a/java/test/Makefile.am +++ b/java/test/Makefile.am @@ -69,6 +69,7 @@ noinst_JAVA = \ TestH5Ocreate.java \ TestH5Ocopy.java \ TestH5PL.java \ + TestH5VL.java \ TestH5Z.java \ TestH5E.java \ TestH5Edefault.java \ diff --git a/java/test/TestH5VL.java b/java/test/TestH5VL.java new file mode 100644 index 0000000..0397be1 --- /dev/null +++ b/java/test/TestH5VL.java @@ -0,0 +1,117 @@ +/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * + * Copyright by The HDF Group. * + * Copyright by the Board of Trustees of the University of Illinois. * + * All rights reserved. * + * * + * This file is part of HDF5. The full HDF5 copyright notice, including * + * terms governing use, modification, and redistribution, is contained in * + * the COPYING file, which can be found at the root of the source code * + * distribution tree, or in https://support.hdfgroup.org/ftp/HDF5/releases. * + * If you do not have access to either file, you may request a copy from * + * help@hdfgroup.org. * + * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ + +package test; + +import static org.junit.Assert.assertEquals; +import static org.junit.Assert.assertFalse; +import static org.junit.Assert.assertTrue; +import static org.junit.Assert.fail; +import hdf.hdf5lib.H5; +import hdf.hdf5lib.HDF5Constants; +import hdf.hdf5lib.exceptions.HDF5LibraryException; + +import java.io.File; + +import org.junit.After; +import org.junit.Before; +import org.junit.Rule; +import org.junit.Test; +import org.junit.rules.TestName; + +public class TestH5VL { + @Rule public TestName testname = new TestName(); + + private final void _deleteFile(String filename) { + File file = new File(filename); + + if (file.exists()) { + try {file.delete();} catch (SecurityException e) {} + } + } + + @Before + public void checkOpenIDs() { + assertTrue("H5 open ids is 0",H5.getOpenIDCount()==0); + System.out.print(testname.getMethodName()); + } + @After + public void nextTestName() { + System.out.println(); + } + + @Test + public void testH5VLnative_init() { + try { + boolean is_registered; + + is_registered = H5.H5VLis_connector_registered(HDF5Constants.H5VL_NATIVE_NAME); + assertTrue("H5.H5VLis_connector_registered H5VL_NATIVE_NAME", is_registered); + + is_registered = H5.H5VLis_connector_registered("FAKE_VOL_NAME"); + assertFalse("H5.H5VLis_connector_registered FAKE_VOL_NAME", is_registered); + } + catch (Throwable err) { + err.printStackTrace(); + fail("H5.H5VLis_connector_registered " + err); + } + } + + @Test + public void testH5VLget_connector_id() { + try { + long native_id = H5.H5VLget_connector_id(HDF5Constants.H5VL_NATIVE_NAME); + assertTrue("H5.H5VLget_connector_id H5VL_NATIVE_NAME", native_id >= 0); + assertEquals(HDF5Constants.H5VL_NATIVE, native_id); + } + catch (Throwable err) { + err.printStackTrace(); + fail("H5.H5VLget_connector_id " + err); + } + } + + @Test + public void testH5VLget_connector_name() { + String H5_FILE = "testFvl.h5"; + + long H5fid = H5.H5Fcreate(H5_FILE, HDF5Constants.H5F_ACC_TRUNC, + HDF5Constants.H5P_DEFAULT, HDF5Constants.H5P_DEFAULT); + H5.H5Fflush(H5fid, HDF5Constants.H5F_SCOPE_LOCAL); + + try { + String native_name = H5.H5VLget_connector_name(H5fid); + assertTrue("H5.H5VLget_connector_name H5VL_NATIVE", native_name.compareToIgnoreCase(HDF5Constants.H5VL_NATIVE_NAME)==0); + } + catch (Throwable err) { + err.printStackTrace(); + fail("H5.H5VLget_connector_name " + err); + } + finally { + if (H5fid > 0) { + try {H5.H5Fclose(H5fid);} catch (Exception ex) {} + } + _deleteFile(H5_FILE); + } + } + + @Test(expected = HDF5LibraryException.class) + public void testH5VLclose_NegativeID() throws Throwable { + H5.H5VLclose(-1); + } + + @Test(expected = HDF5LibraryException.class) + public void testH5VLunregister_connector_NegativeID() throws Throwable { + H5.H5VLunregister_connector(-1); + } +} + diff --git a/java/test/junit.sh.in b/java/test/junit.sh.in index 350fb7b..42e16ee 100644 --- a/java/test/junit.sh.in +++ b/java/test/junit.sh.in @@ -989,6 +989,27 @@ else test yes = "$verbose" && $DIFF JUnit-TestH5PL.txt JUnit-TestH5PL.out |sed 's/^/ /' fi +echo "$JAVAEXE $JAVAEXEFLAGS -Xmx1024M -Dorg.slf4j.simpleLogger.defaultLog=trace -Djava.library.path=$BLDLIBDIR -cp $CLASSPATH -ea org.junit.runner.JUnitCore test.TestH5VL" +TESTING JUnit-TestH5VL +($RUNSERIAL $JAVAEXE $JAVAEXEFLAGS -Xmx1024M -Dorg.slf4j.simpleLogger.defaultLog=trace -Djava.library.path=$BLDLIBDIR -cp $CLASSPATH -ea org.junit.runner.JUnitCore test.TestH5VL > JUnit-TestH5VL.ext) + +# Extract file name, line number, version and thread IDs because they may be different +sed -e 's/thread [0-9]*/thread (IDs)/' -e 's/: .*\.c /: (file name) /' \ + -e 's/line [0-9]*/line (number)/' \ + -e 's/Time: [0-9]*\.[0-9]*/Time: XXXX/' \ + -e 's/v[1-9]*\.[0-9]*\./version (number)\./' \ + -e 's/[1-9]*\.[0-9]*\.[0-9]*[^)]*/version (number)/' \ + JUnit-TestH5VL.ext > JUnit-TestH5VL.out + +if diff JUnit-TestH5VL.out JUnit-TestH5VL.txt > /dev/null; then + echo " PASSED JUnit-TestH5VL" +else + echo "**FAILED** JUnit-TestH5VL" + echo " Expected result differs from actual result" + nerrors="`expr $nerrors + 1`" + test yes = "$verbose" && $DIFF JUnit-TestH5VL.txt JUnit-TestH5VL.out |sed 's/^/ /' +fi + echo "$JAVAEXE $JAVAEXEFLAGS -Xmx1024M -Dorg.slf4j.simpleLogger.defaultLog=trace -Djava.library.path=$BLDLIBDIR -cp $CLASSPATH -ea org.junit.runner.JUnitCore test.TestH5Z" TESTING JUnit-TestH5Z ($RUNSERIAL $JAVAEXE $JAVAEXEFLAGS -Xmx1024M -Dorg.slf4j.simpleLogger.defaultLog=trace -Djava.library.path=$BLDLIBDIR -cp $CLASSPATH -ea org.junit.runner.JUnitCore test.TestH5Z > JUnit-TestH5Z.ext) diff --git a/java/test/testfiles/JUnit-TestH5VL.txt b/java/test/testfiles/JUnit-TestH5VL.txt new file mode 100644 index 0000000..caadf26 --- /dev/null +++ b/java/test/testfiles/JUnit-TestH5VL.txt @@ -0,0 +1,11 @@ +JUnit version 4.11 +.testH5VLget_connector_id +.testH5VLnative_init +.testH5VLget_connector_name +.testH5VLclose_NegativeID +.testH5VLunregister_connector_NegativeID + +Time: XXXX + +OK (5 tests) + -- cgit v0.12 From 0bcae40c8a6030189693f6a428a60643ea3947f9 Mon Sep 17 00:00:00 2001 From: Allen Byrne Date: Wed, 19 Dec 2018 14:44:29 -0600 Subject: TRILABS special text removal --- config/cmake_ext_mod/runTest.cmake | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/config/cmake_ext_mod/runTest.cmake b/config/cmake_ext_mod/runTest.cmake index 0bc2db0..75f704a 100644 --- a/config/cmake_ext_mod/runTest.cmake +++ b/config/cmake_ext_mod/runTest.cmake @@ -121,6 +121,11 @@ endif () message (STATUS "COMMAND Error: ${TEST_ERROR}") +# remove special output +file (READ ${TEST_FOLDER}/${TEST_OUTPUT} TEST_STREAM) +string (REGEX REPLACE "^.*_pmi_alps[^\n]+\n" "" TEST_STREAM "${TEST_STREAM}") +file (WRITE ${TEST_FOLDER}/${TEST_OUTPUT} "${TEST_STREAM}") + # if the output file needs Storage text removed if (TEST_MASK) file (READ ${TEST_FOLDER}/${TEST_OUTPUT} TEST_STREAM) -- cgit v0.12 From c4913dd55f553a204ed2ecc56e7d03079ac0ba23 Mon Sep 17 00:00:00 2001 From: Allen Byrne Date: Wed, 19 Dec 2018 15:41:15 -0600 Subject: TRILABS special output removal --- config/cmake_ext_mod/runTest.cmake | 2 ++ 1 file changed, 2 insertions(+) diff --git a/config/cmake_ext_mod/runTest.cmake b/config/cmake_ext_mod/runTest.cmake index 75f704a..79b4175 100644 --- a/config/cmake_ext_mod/runTest.cmake +++ b/config/cmake_ext_mod/runTest.cmake @@ -93,6 +93,8 @@ if (EXISTS ${TEST_FOLDER}/${TEST_OUTPUT}.err) if (TEST_MASK_FILE) STRING(REGEX REPLACE "CurrentDir is [^\n]+\n" "CurrentDir is (dir name)\n" TEST_STREAM "${TEST_STREAM}") endif () + # remove special output + string (REGEX REPLACE "^.*_pmi_alps[^\n]+\n" "" TEST_STREAM "${TEST_STREAM}") if (NOT ERROR_APPEND) # append error output to the stdout output file -- cgit v0.12 From ec4902ae8d8bd009bb835d3a0bba335845f2c07d Mon Sep 17 00:00:00 2001 From: Allen Byrne Date: Wed, 19 Dec 2018 15:43:33 -0600 Subject: Special text removal not conditional --- config/cmake_ext_mod/runTest.cmake | 1 - 1 file changed, 1 deletion(-) diff --git a/config/cmake_ext_mod/runTest.cmake b/config/cmake_ext_mod/runTest.cmake index 79b4175..8181ff0 100644 --- a/config/cmake_ext_mod/runTest.cmake +++ b/config/cmake_ext_mod/runTest.cmake @@ -151,7 +151,6 @@ if (TEST_MASK_ERROR) # the error stack remains in the .err file file (READ ${TEST_FOLDER}/${TEST_OUTPUT}.err TEST_STREAM) endif () - string (REGEX REPLACE "^.*_pmi_alps[^\n]+\n" "" TEST_STREAM "${TEST_STREAM}") string (REGEX REPLACE "thread [0-9]*:" "thread (IDs):" TEST_STREAM "${TEST_STREAM}") string (REGEX REPLACE ": ([^\n]*)[.]c " ": (file name) " TEST_STREAM "${TEST_STREAM}") string (REGEX REPLACE " line [0-9]*" " line (number)" TEST_STREAM "${TEST_STREAM}") -- cgit v0.12 From 371ed6a518efad31dc806cbc91f8da31e4643f66 Mon Sep 17 00:00:00 2001 From: Quincey Koziol Date: Wed, 19 Dec 2018 16:30:11 -0600 Subject: Fix return value type for get name operation. --- src/H5Gdeprec.c | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/H5Gdeprec.c b/src/H5Gdeprec.c index 1c86707..9178606 100644 --- a/src/H5Gdeprec.c +++ b/src/H5Gdeprec.c @@ -771,6 +771,7 @@ H5Gget_comment(hid_t loc_id, const char *name, size_t bufsize, char *buf) { H5VL_object_t *vol_obj; /* Object token of loc_id */ H5VL_loc_params_t loc_params; + ssize_t op_ret; /* Return value from operation */ int ret_value; /* Return value */ FUNC_ENTER_API(FAIL) @@ -796,9 +797,12 @@ H5Gget_comment(hid_t loc_id, const char *name, size_t bufsize, char *buf) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "invalid location identifier") /* Get the comment */ - if(H5VL_object_optional(vol_obj, H5P_DATASET_XFER_DEFAULT, H5_REQUEST_NULL, H5VL_NATIVE_OBJECT_GET_COMMENT, &loc_params, buf, bufsize, &ret_value) < 0) + if(H5VL_object_optional(vol_obj, H5P_DATASET_XFER_DEFAULT, H5_REQUEST_NULL, H5VL_NATIVE_OBJECT_GET_COMMENT, &loc_params, buf, bufsize, &op_ret) < 0) HGOTO_ERROR(H5E_SYM, H5E_CANTGET, FAIL, "unable to get comment value") + /* Set return value */ + ret_value = (int)op_ret; + done: FUNC_LEAVE_API(ret_value) } /* end H5Gget_comment() */ -- cgit v0.12 From 3587fe2638c45c087e970a3bdca07a9ffa7d435c Mon Sep 17 00:00:00 2001 From: Quincey Koziol Date: Wed, 19 Dec 2018 16:54:02 -0600 Subject: Switch return value to -1 --- src/H5Gdeprec.c | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/src/H5Gdeprec.c b/src/H5Gdeprec.c index 9178606..3e0574c 100644 --- a/src/H5Gdeprec.c +++ b/src/H5Gdeprec.c @@ -774,17 +774,17 @@ H5Gget_comment(hid_t loc_id, const char *name, size_t bufsize, char *buf) ssize_t op_ret; /* Return value from operation */ int ret_value; /* Return value */ - FUNC_ENTER_API(FAIL) + FUNC_ENTER_API(-1) H5TRACE4("Is", "i*sz*s", loc_id, name, bufsize, buf); if(!name || !*name) - HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "no name specified") + HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, -1, "no name specified") if(bufsize > 0 && !buf) - HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "no buffer specified") + HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, -1, "no buffer specified") /* Set up collective metadata if appropriate */ if(H5CX_set_loc(loc_id) < 0) - HGOTO_ERROR(H5E_SYM, H5E_CANTSET, FAIL, "can't set collective metadata read info") + HGOTO_ERROR(H5E_SYM, H5E_CANTSET, -1, "can't set collective metadata read info") /* Fill in location struct fields */ loc_params.type = H5VL_OBJECT_BY_NAME; @@ -794,11 +794,11 @@ H5Gget_comment(hid_t loc_id, const char *name, size_t bufsize, char *buf) /* Get the location object */ if(NULL == (vol_obj = H5VL_vol_object(loc_id))) - HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "invalid location identifier") + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, -1, "invalid location identifier") /* Get the comment */ if(H5VL_object_optional(vol_obj, H5P_DATASET_XFER_DEFAULT, H5_REQUEST_NULL, H5VL_NATIVE_OBJECT_GET_COMMENT, &loc_params, buf, bufsize, &op_ret) < 0) - HGOTO_ERROR(H5E_SYM, H5E_CANTGET, FAIL, "unable to get comment value") + HGOTO_ERROR(H5E_SYM, H5E_CANTGET, -1, "unable to get comment value") /* Set return value */ ret_value = (int)op_ret; -- cgit v0.12 From f1d8d889b40689ae7c8089359d35716764789928 Mon Sep 17 00:00:00 2001 From: Quincey Koziol Date: Wed, 19 Dec 2018 17:16:45 -0600 Subject: Correct core VFD to run with a 1MB increment instead of a 1 byte increment! --- test/h5test.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/test/h5test.c b/test/h5test.c index 47ddd34..0226aa7 100644 --- a/test/h5test.c +++ b/test/h5test.c @@ -896,11 +896,11 @@ h5_get_vfd_fapl(hid_t fapl) goto error; } else if(!HDstrcmp(tok, "core")) { /* In-memory driver settings (backing store on, 1 MB increment) */ - if(H5Pset_fapl_core(fapl, (size_t)1, TRUE) < 0) + if(H5Pset_fapl_core(fapl, (size_t)H5_MB, TRUE) < 0) goto error; } else if(!HDstrcmp(tok, "core_paged")) { /* In-memory driver with write tracking and paging on */ - if(H5Pset_fapl_core(fapl, (size_t)1, TRUE) < 0) + if(H5Pset_fapl_core(fapl, (size_t)H5_MB, TRUE) < 0) goto error; if(H5Pset_core_write_tracking(fapl, TRUE, (size_t)4096) < 0) goto error; -- cgit v0.12 From 9cfe7fd18d01d6fc84ac2e8902c955452b64259d Mon Sep 17 00:00:00 2001 From: Dana Robinson Date: Wed, 19 Dec 2018 17:41:50 -0800 Subject: Split the native VOL connector code into multiple files and moved the attribute code over. --- MANIFEST | 7 + src/CMakeLists.txt | 7 + src/H5VLnative.c | 596 -------------------------------------------- src/H5VLnative.h | 10 + src/H5VLnative_attr.c | 615 ++++++++++++++++++++++++++++++++++++++++++++++ src/H5VLnative_dataset.c | 13 + src/H5VLnative_datatype.c | 13 + src/H5VLnative_file.c | 13 + src/H5VLnative_group.c | 13 + src/H5VLnative_link.c | 13 + src/H5VLnative_object.c | 13 + src/Makefile.am | 5 +- 12 files changed, 721 insertions(+), 597 deletions(-) create mode 100644 src/H5VLnative_attr.c create mode 100644 src/H5VLnative_dataset.c create mode 100644 src/H5VLnative_datatype.c create mode 100644 src/H5VLnative_file.c create mode 100644 src/H5VLnative_group.c create mode 100644 src/H5VLnative_link.c create mode 100644 src/H5VLnative_object.c diff --git a/MANIFEST b/MANIFEST index d840e73..625d949 100644 --- a/MANIFEST +++ b/MANIFEST @@ -894,6 +894,13 @@ ./src/H5VLmodule.h ./src/H5VLnative.c ./src/H5VLnative.h +./src/H5VLnative_attr.c +./src/H5VLnative_dataset.c +./src/H5VLnative_datatype.c +./src/H5VLnative_file.c +./src/H5VLnative_group.c +./src/H5VLnative_link.c +./src/H5VLnative_object.c ./src/H5VLpassthru.c ./src/H5VLpassthru.h ./src/H5VLpkg.h diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 778505f..bac113a 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -628,6 +628,13 @@ set (H5VL_SOURCES ${HDF5_SRC_DIR}/H5VLcallback.c ${HDF5_SRC_DIR}/H5VLint.c ${HDF5_SRC_DIR}/H5VLnative.c + ${HDF5_SRC_DIR}/H5VLnative_attr.c + ${HDF5_SRC_DIR}/H5VLnative_dataset.c + ${HDF5_SRC_DIR}/H5VLnative_datatype.c + ${HDF5_SRC_DIR}/H5VLnative_file.c + ${HDF5_SRC_DIR}/H5VLnative_group.c + ${HDF5_SRC_DIR}/H5VLnative_link.c + ${HDF5_SRC_DIR}/H5VLnative_object.c ${HDF5_SRC_DIR}/H5VLpassthru.c ) set (H5VL_HDRS diff --git a/src/H5VLnative.c b/src/H5VLnative.c index 1e78d8e..b34b001 100644 --- a/src/H5VLnative.c +++ b/src/H5VLnative.c @@ -15,7 +15,6 @@ * using HDF5 VFDs. */ -#define H5A_FRIEND /* Suppress error about including H5Apkg */ #define H5D_FRIEND /* Suppress error about including H5Dpkg */ #define H5F_FRIEND /* Suppress error about including H5Fpkg */ #define H5G_FRIEND /* Suppress error about including H5Gpkg */ @@ -26,7 +25,6 @@ #include "H5private.h" /* Generic Functions */ -#include "H5Apkg.h" /* Attributes */ #include "H5Dpkg.h" /* Datasets */ #include "H5Eprivate.h" /* Error handling */ #include "H5Fpkg.h" /* Files */ @@ -52,16 +50,6 @@ static hid_t H5VL_NATIVE_ID_g = H5I_INVALID_HID; /* Prototypes */ static herr_t H5VL__native_term(void); -/* Atrribute callbacks */ -static void *H5VL__native_attr_create(void *obj, const H5VL_loc_params_t *loc_params, const char *attr_name, hid_t acpl_id, hid_t aapl_id, hid_t dxpl_id, void **req); -static void *H5VL__native_attr_open(void *obj, const H5VL_loc_params_t *loc_params, const char *attr_name, hid_t aapl_id, hid_t dxpl_id, void **req); -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, const H5VL_loc_params_t *loc_params, H5VL_attr_specific_t specific_type, hid_t dxpl_id, void **req, va_list arguments); -static herr_t H5VL__native_attr_optional(void *obj, hid_t dxpl_id, void **req, va_list arguments); -static herr_t H5VL__native_attr_close(void *attr, hid_t dxpl_id, void **req); - /* Dataset callbacks */ static void *H5VL__native_dataset_create(void *obj, const H5VL_loc_params_t *loc_params, const char *name, hid_t dcpl_id, hid_t dapl_id, hid_t dxpl_id, void **req); static void *H5VL__native_dataset_open(void *obj, const H5VL_loc_params_t *loc_params, const char *name, hid_t dapl_id, hid_t dxpl_id, void **req); @@ -259,590 +247,6 @@ H5VL__native_term(void) /*------------------------------------------------------------------------- - * Function: H5VL__native_attr_create - * - * Purpose: Creates an attribute on an object. - * - * Return: Success: Pointer to attribute object - * Failure: NULL - * - *------------------------------------------------------------------------- - */ -static void * -H5VL__native_attr_create(void *obj, const H5VL_loc_params_t *loc_params, const char *attr_name, - hid_t acpl_id, hid_t H5_ATTR_UNUSED aapl_id, hid_t H5_ATTR_UNUSED dxpl_id, - void H5_ATTR_UNUSED **req) -{ - H5G_loc_t loc; /* Object location */ - H5G_loc_t obj_loc; /* Location used to open group */ - hbool_t loc_found = FALSE; - H5P_genplist_t *plist; /* Property list pointer */ - hid_t type_id, space_id; - H5T_t *type, *dt; /* Datatype to use for attribute */ - H5S_t *space; /* Dataspace to use for attribute */ - H5A_t *attr = NULL; - void *ret_value = NULL; - - FUNC_ENTER_STATIC - - /* Get the plist structure */ - if(NULL == (plist = (H5P_genplist_t *)H5I_object(acpl_id))) - HGOTO_ERROR(H5E_ATOM, H5E_BADATOM, NULL, "can't find object for ID") - - /* get creation properties */ - if(H5P_get(plist, H5VL_PROP_ATTR_TYPE_ID, &type_id) < 0) - HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, NULL, "can't get property value for datatype id") - if(H5P_get(plist, H5VL_PROP_ATTR_SPACE_ID, &space_id) < 0) - HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, NULL, "can't get property value for space id") - - if(H5G_loc_real(obj, loc_params->obj_type, &loc) < 0) - HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, NULL, "not a file or file object") - if(0 == (H5F_INTENT(loc.oloc->file) & H5F_ACC_RDWR)) - HGOTO_ERROR(H5E_ARGS, H5E_WRITEERROR, NULL, "no write intent on file") - - if(NULL == (dt = (H5T_t *)H5I_object_verify(type_id, H5I_DATATYPE))) - HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, NULL, "not a datatype") - /* If this is a named datatype, get the connector's pointer to the datatype */ - type = H5T_get_actual_type(dt); - - if(NULL == (space = (H5S_t *)H5I_object_verify(space_id, H5I_DATASPACE))) - HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, NULL, "not a data space") - - if(loc_params->type == H5VL_OBJECT_BY_SELF) { - /* H5Acreate */ - /* Go do the real work for attaching the attribute to the dataset */ - if(NULL == (attr = H5A__create(&loc, attr_name, type, space, acpl_id))) - HGOTO_ERROR(H5E_ATTR, H5E_CANTINIT, NULL, "unable to create attribute") - } /* end if */ - else if(loc_params->type == H5VL_OBJECT_BY_NAME) { - /* H5Acreate_by_name */ - if(NULL == (attr = H5A__create_by_name(&loc, loc_params->loc_data.loc_by_name.name, attr_name, type, space, acpl_id))) - HGOTO_ERROR(H5E_ATTR, H5E_CANTINIT, NULL, "unable to create attribute") - } /* end else-if */ - else - HGOTO_ERROR(H5E_VOL, H5E_UNSUPPORTED, NULL, "unknown attribute create parameters") - - ret_value = (void *)attr; - -done: - /* Release resources */ - if(loc_found && H5G_loc_free(&obj_loc) < 0) - HDONE_ERROR(H5E_ATTR, H5E_CANTRELEASE, NULL, "can't free location") - - FUNC_LEAVE_NOAPI(ret_value) -} /* end H5VL__native_attr_create() */ - - -/*------------------------------------------------------------------------- - * Function: H5VL__native_attr_open - * - * Purpose: Opens an attr inside a native H5 file. - * - * Return: Success: Pointer to attribute object - * Failure: NULL - * - * Programmer: Mohamad Chaarawi - * March, 2012 - * - *------------------------------------------------------------------------- - */ -static void * -H5VL__native_attr_open(void *obj, const H5VL_loc_params_t *loc_params, const char *attr_name, - hid_t H5_ATTR_UNUSED aapl_id, hid_t H5_ATTR_UNUSED dxpl_id, void H5_ATTR_UNUSED **req) -{ - H5G_loc_t loc; /* Object location */ - H5A_t *attr = NULL; /* Attribute opened */ - void *ret_value; - - FUNC_ENTER_STATIC - - /* check arguments */ - if(H5G_loc_real(obj, loc_params->obj_type, &loc) < 0) - HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, NULL, "not a file or file object") - - if(loc_params->type == H5VL_OBJECT_BY_SELF) { - /* H5Aopen */ - /* Open the attribute */ - if(NULL == (attr = H5A__open(&loc, attr_name))) - HGOTO_ERROR(H5E_ATTR, H5E_CANTOPENOBJ, NULL, "unable to open attribute: '%s'", attr_name) - } /* end if */ - else if(loc_params->type == H5VL_OBJECT_BY_NAME) { - /* H5Aopen_by_name */ - /* Open the attribute on the object header */ - if(NULL == (attr = H5A__open_by_name(&loc, loc_params->loc_data.loc_by_name.name, attr_name))) - HGOTO_ERROR(H5E_ATTR, H5E_CANTOPENOBJ, NULL, "can't open attribute") - } /* end else-if */ - else if(loc_params->type == H5VL_OBJECT_BY_IDX) { - /* H5Aopen_by_idx */ - /* Open the attribute in the object header */ - if(NULL == (attr = H5A__open_by_idx(&loc, loc_params->loc_data.loc_by_idx.name, - loc_params->loc_data.loc_by_idx.idx_type, - loc_params->loc_data.loc_by_idx.order, - loc_params->loc_data.loc_by_idx.n))) - HGOTO_ERROR(H5E_ATTR, H5E_CANTOPENOBJ, NULL, "unable to open attribute") - } /* end else-if */ - else - HGOTO_ERROR(H5E_VOL, H5E_UNSUPPORTED, NULL, "unknown attribute open parameters") - - ret_value = (void *)attr; - -done: - FUNC_LEAVE_NOAPI(ret_value) -} /* end H5VL__native_attr_open() */ - - -/*------------------------------------------------------------------------- - * Function: H5VL__native_attr_read - * - * Purpose: Reads data from attribute. - * - * Return: Non-negative on success/Negative on failure - * - * Programmer: Mohamad Chaarawi - * March, 2012 - * - *------------------------------------------------------------------------- - */ -static herr_t -H5VL__native_attr_read(void *attr, hid_t dtype_id, void *buf, - hid_t H5_ATTR_UNUSED dxpl_id, void H5_ATTR_UNUSED **req) -{ - H5T_t *mem_type; /* Memory datatype */ - herr_t ret_value; /* Return value */ - - FUNC_ENTER_STATIC - - if(NULL == (mem_type = (H5T_t *)H5I_object_verify(dtype_id, H5I_DATATYPE))) - HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a datatype") - - /* Go write the actual data to the attribute */ - if((ret_value = H5A__read((H5A_t*)attr, mem_type, buf)) < 0) - HGOTO_ERROR(H5E_ATTR, H5E_READERROR, FAIL, "unable to read attribute") - -done: - FUNC_LEAVE_NOAPI(ret_value) -} /* end H5VL__native_attr_read() */ - - -/*------------------------------------------------------------------------- - * Function: H5VL__native_attr_write - * - * Purpose: Writes data to attribute. - * - * Return: Non-negative on success/Negative on failure - * - * Programmer: Mohamad Chaarawi - * March, 2012 - * - *------------------------------------------------------------------------- - */ -static herr_t -H5VL__native_attr_write(void *attr, hid_t dtype_id, const void *buf, - hid_t H5_ATTR_UNUSED dxpl_id, void H5_ATTR_UNUSED **req) -{ - H5T_t *mem_type; /* Memory datatype */ - herr_t ret_value; /* Return value */ - - FUNC_ENTER_STATIC - - if(NULL == (mem_type = (H5T_t *)H5I_object_verify(dtype_id, H5I_DATATYPE))) - HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a datatype") - - /* Go write the actual data to the attribute */ - if((ret_value = H5A__write((H5A_t*)attr, mem_type, buf)) < 0) - HGOTO_ERROR(H5E_ATTR, H5E_WRITEERROR, FAIL, "unable to write attribute") - -done: - FUNC_LEAVE_NOAPI(ret_value) -} /* end H5VL__native_attr_write() */ - - -/*------------------------------------------------------------------------- - * Function: H5VL__native_attr_get - * - * Purpose: Gets information about an attribute - * - * Return: Success: 0 - * Failure: -1 - * - * Programmer: Mohamad Chaarawi - * March, 2012 - * - *------------------------------------------------------------------------- - */ -static herr_t -H5VL__native_attr_get(void *obj, H5VL_attr_get_t get_type, - hid_t H5_ATTR_UNUSED dxpl_id, void H5_ATTR_UNUSED **req, va_list arguments) -{ - herr_t ret_value = SUCCEED; /* Return value */ - - FUNC_ENTER_STATIC - - switch(get_type) { - /* H5Aget_space */ - case H5VL_ATTR_GET_SPACE: - { - hid_t *ret_id = HDva_arg(arguments, hid_t *); - H5A_t *attr = (H5A_t *)obj; - - if((*ret_id = H5A_get_space(attr)) < 0) - HGOTO_ERROR(H5E_ARGS, H5E_CANTGET, FAIL, "can't get space ID of attribute") - break; - } - - /* H5Aget_type */ - case H5VL_ATTR_GET_TYPE: - { - hid_t *ret_id = HDva_arg(arguments, hid_t *); - H5A_t *attr = (H5A_t *)obj; - - if((*ret_id = H5A__get_type(attr)) < 0) - HGOTO_ERROR(H5E_ARGS, H5E_CANTGET, FAIL, "can't get datatype ID of attribute") - break; - } - - /* H5Aget_create_plist */ - case H5VL_ATTR_GET_ACPL: - { - hid_t *ret_id = HDva_arg(arguments, hid_t *); - H5A_t *attr = (H5A_t *)obj; - - if((*ret_id = H5A__get_create_plist(attr)) < 0) - HGOTO_ERROR(H5E_ARGS, H5E_CANTGET, FAIL, "can't get creation property list for attr") - - break; - } - - /* H5Aget_name */ - case H5VL_ATTR_GET_NAME: - { - const H5VL_loc_params_t *loc_params = HDva_arg(arguments, const H5VL_loc_params_t *); - size_t buf_size = HDva_arg(arguments, size_t); - char *buf = HDva_arg(arguments, char *); - ssize_t *ret_val = HDva_arg(arguments, ssize_t *); - H5A_t *attr = NULL; - - if(H5VL_OBJECT_BY_SELF == loc_params->type) { - attr = (H5A_t *)obj; - /* Call private function in turn */ - if(0 > (*ret_val = H5A__get_name(attr, buf_size, buf))) - HGOTO_ERROR(H5E_ATTR, H5E_CANTGET, FAIL, "can't get attribute name") - } - else if(H5VL_OBJECT_BY_IDX == loc_params->type) { - H5G_loc_t loc; - - /* check arguments */ - if(H5G_loc_real(obj, loc_params->obj_type, &loc) < 0) - HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a file or file object") - - /* Open the attribute on the object header */ - if(NULL == (attr = H5A__open_by_idx(&loc, loc_params->loc_data.loc_by_idx.name, - loc_params->loc_data.loc_by_idx.idx_type, - loc_params->loc_data.loc_by_idx.order, - loc_params->loc_data.loc_by_idx.n))) - HGOTO_ERROR(H5E_ATTR, H5E_CANTOPENOBJ, FAIL, "can't open attribute") - - /* Get the length of the name */ - *ret_val = (ssize_t)HDstrlen(attr->shared->name); - - /* Copy the name into the user's buffer, if given */ - if(buf) { - HDstrncpy(buf, attr->shared->name, MIN((size_t)(*ret_val + 1), buf_size)); - if((size_t)(*ret_val) >= buf_size) - buf[buf_size - 1]='\0'; - } /* end if */ - - /* Release resources */ - if(attr && H5A__close(attr) < 0) - HGOTO_ERROR(H5E_ATTR, H5E_CANTFREE, FAIL, "can't close attribute") - } - else - HGOTO_ERROR(H5E_SYM, H5E_CANTGET, FAIL, "can't get name of attr") - - break; - } - - /* H5Aget_info */ - case H5VL_ATTR_GET_INFO: - { - const H5VL_loc_params_t *loc_params = HDva_arg(arguments, const H5VL_loc_params_t *); - H5A_info_t *ainfo = HDva_arg(arguments, H5A_info_t *); - H5A_t *attr = NULL; - - if(H5VL_OBJECT_BY_SELF == loc_params->type) { - attr = (H5A_t *)obj; - if(H5A__get_info(attr, ainfo) < 0) - HGOTO_ERROR(H5E_ARGS, H5E_CANTGET, FAIL, "can't get attribute info") - } - else if(H5VL_OBJECT_BY_NAME == loc_params->type) { - char *attr_name = HDva_arg(arguments, char *); - H5G_loc_t loc; - - /* check arguments */ - if(H5G_loc_real(obj, loc_params->obj_type, &loc) < 0) - HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a file or file object") - - /* Open the attribute on the object header */ - if(NULL == (attr = H5A__open_by_name(&loc, loc_params->loc_data.loc_by_name.name, attr_name))) - HGOTO_ERROR(H5E_ATTR, H5E_CANTOPENOBJ, FAIL, "can't open attribute") - - /* Get the attribute information */ - if(H5A__get_info(attr, ainfo) < 0) - HGOTO_ERROR(H5E_ATTR, H5E_CANTGET, FAIL, "unable to get attribute info") - - /* Release resources */ - if(attr && H5A__close(attr) < 0) - HGOTO_ERROR(H5E_ATTR, H5E_CANTFREE, FAIL, "can't close attribute") - } - else if(H5VL_OBJECT_BY_IDX == loc_params->type) { - H5G_loc_t loc; - - /* check arguments */ - if(H5G_loc_real(obj, loc_params->obj_type, &loc) < 0) - HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a file or file object") - - /* Open the attribute on the object header */ - if(NULL == (attr = H5A__open_by_idx(&loc, loc_params->loc_data.loc_by_idx.name, - loc_params->loc_data.loc_by_idx.idx_type, - loc_params->loc_data.loc_by_idx.order, - loc_params->loc_data.loc_by_idx.n))) - HGOTO_ERROR(H5E_ATTR, H5E_CANTOPENOBJ, FAIL, "can't open attribute") - - /* Get the attribute information */ - if(H5A__get_info(attr, ainfo) < 0) - HGOTO_ERROR(H5E_ATTR, H5E_CANTGET, FAIL, "unable to get attribute info") - - /* Release resources */ - if(attr && H5A__close(attr) < 0) - HGOTO_ERROR(H5E_ATTR, H5E_CANTFREE, FAIL, "can't close attribute") - } - else - HGOTO_ERROR(H5E_SYM, H5E_CANTGET, FAIL, "can't get name of attr") - - break; - } - - case H5VL_ATTR_GET_STORAGE_SIZE: - { - hsize_t *ret = HDva_arg(arguments, hsize_t *); - H5A_t *attr = (H5A_t *)obj; - - /* Set return value */ - *ret = attr->shared->data_size; - break; - } - - default: - HGOTO_ERROR(H5E_VOL, H5E_CANTGET, FAIL, "can't get this type of information from attr") - } /* end switch */ - -done: - FUNC_LEAVE_NOAPI(ret_value) -} /* end H5VL__native_attr_get() */ - - -/*------------------------------------------------------------------------- - * Function: H5VL__native_attr_specific - * - * Purpose: Specific operation on attribute - * - * Return: Success: 0 - * Failure: -1 - * - * Programmer: Mohamad Chaarawi - * August, 2014 - * - *------------------------------------------------------------------------- - */ -static herr_t -H5VL__native_attr_specific(void *obj, const H5VL_loc_params_t *loc_params, H5VL_attr_specific_t specific_type, - hid_t H5_ATTR_UNUSED dxpl_id, void H5_ATTR_UNUSED **req, va_list arguments) -{ - H5G_loc_t loc; - herr_t ret_value = SUCCEED; /* Return value */ - - FUNC_ENTER_STATIC - - /* Get location for passed-in object */ - if(H5G_loc_real(obj, loc_params->obj_type, &loc) < 0) - HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a file or file object") - - switch(specific_type) { - case H5VL_ATTR_DELETE: - { - char *attr_name = HDva_arg(arguments, char *); - - if(H5VL_OBJECT_BY_SELF == loc_params->type) { - /* H5Adelete */ - /* Delete the attribute from the location */ - if(H5O__attr_remove(loc.oloc, attr_name) < 0) - HGOTO_ERROR(H5E_ATTR, H5E_CANTDELETE, FAIL, "unable to delete attribute") - } /* end if */ - else if(H5VL_OBJECT_BY_NAME == loc_params->type) { - /* H5Adelete_by_name */ - /* Delete the attribute */ - if(H5A__delete_by_name(&loc, loc_params->loc_data.loc_by_name.name, attr_name) < 0) - HGOTO_ERROR(H5E_ATTR, H5E_CANTDELETE, FAIL, "unable to delete attribute") - } /* end else-if */ - else if(H5VL_OBJECT_BY_IDX == loc_params->type) { - /* H5Adelete_by_idx */ - /* Delete the attribute from the location */ - if(H5A__delete_by_idx(&loc, loc_params->loc_data.loc_by_idx.name, loc_params->loc_data.loc_by_idx.idx_type, - loc_params->loc_data.loc_by_idx.order, loc_params->loc_data.loc_by_idx.n) < 0) - HGOTO_ERROR(H5E_ATTR, H5E_CANTDELETE, FAIL, "unable to delete attribute") - } /* end else-if */ - else - HGOTO_ERROR(H5E_VOL, H5E_UNSUPPORTED, FAIL, "unknown attribute remove parameters") - break; - } - - case H5VL_ATTR_EXISTS: - { - const char *attr_name = HDva_arg(arguments, const char *); - htri_t *ret = HDva_arg(arguments, htri_t *); - - if(loc_params->type == H5VL_OBJECT_BY_SELF) { /* H5Aexists */ - /* Check if the attribute exists */ - if((*ret = H5O__attr_exists(loc.oloc, attr_name)) < 0) - HGOTO_ERROR(H5E_ATTR, H5E_CANTGET, FAIL, "unable to determine if attribute exists") - } /* end if */ - else if(loc_params->type == H5VL_OBJECT_BY_NAME) { /* H5Aexists_by_name */ - /* Check if the attribute exists */ - if((*ret = H5A__exists_by_name(loc, loc_params->loc_data.loc_by_name.name, attr_name)) < 0) - HGOTO_ERROR(H5E_ATTR, H5E_CANTGET, FAIL, "unable to determine if attribute exists") - } /* end else-if */ - else - HGOTO_ERROR(H5E_VOL, H5E_UNSUPPORTED, FAIL, "unknown parameters") - break; - } - - case H5VL_ATTR_ITER: - { - H5_index_t idx_type = (H5_index_t)HDva_arg(arguments, int); /* enum work-around */ - H5_iter_order_t order = (H5_iter_order_t)HDva_arg(arguments, int); /* enum work-around */ - hsize_t *idx = HDva_arg(arguments, hsize_t *); - H5A_operator2_t op = HDva_arg(arguments, H5A_operator2_t); - void *op_data = HDva_arg(arguments, void *); - - if(loc_params->type == H5VL_OBJECT_BY_SELF) { /* H5Aiterate2 */ - /* Iterate over attributes */ - if((ret_value = H5A__iterate(&loc, ".", idx_type, order, idx, op, op_data)) < 0) - HGOTO_ERROR(H5E_ATTR, H5E_BADITER, FAIL, "error iterating over attributes") - } /* end if */ - else if(loc_params->type == H5VL_OBJECT_BY_NAME) { /* H5Aiterate_by_name */ - /* Iterate over attributes by name */ - if((ret_value = H5A__iterate(&loc, loc_params->loc_data.loc_by_name.name, idx_type, order, idx, op, op_data)) < 0) - HGOTO_ERROR(H5E_ATTR, H5E_BADITER, FAIL, "attribute iteration failed"); - } /* end else-if */ - else - HGOTO_ERROR(H5E_VOL, H5E_UNSUPPORTED, FAIL, "unknown parameters") - break; - } - - /* H5Arename/rename_by_name */ - case H5VL_ATTR_RENAME: - { - const char *old_name = HDva_arg(arguments, const char *); - const char *new_name = HDva_arg(arguments, const char *); - - if(loc_params->type == H5VL_OBJECT_BY_SELF) { /* H5Arename */ - /* Call attribute rename routine */ - if(H5O__attr_rename(loc.oloc, old_name, new_name) < 0) - HGOTO_ERROR(H5E_ATTR, H5E_CANTRENAME, FAIL, "can't rename attribute") - } /* end if */ - else if(loc_params->type == H5VL_OBJECT_BY_NAME) { /* H5Arename_by_name */ - /* Call attribute rename routine */ - if(H5A__rename_by_name(loc, loc_params->loc_data.loc_by_name.name, old_name, new_name) < 0) - HGOTO_ERROR(H5E_ATTR, H5E_CANTRENAME, FAIL, "can't rename attribute") - } /* end else-if */ - else - HGOTO_ERROR(H5E_VOL, H5E_UNSUPPORTED, FAIL, "unknown attribute rename parameters") - break; - } - - default: - HGOTO_ERROR(H5E_VOL, H5E_UNSUPPORTED, FAIL, "invalid specific operation") - } /* end switch */ - -done: - FUNC_LEAVE_NOAPI(ret_value) -} /* end H5VL__native_attr_specific() */ - - -/*------------------------------------------------------------------------- - * Function: H5VL__native_attr_optional - * - * Purpose: Perform a connector-specific operation on a native attribute - * - * Return: SUCCEED/FAIL - * - *------------------------------------------------------------------------- - */ -static herr_t -H5VL__native_attr_optional(void H5_ATTR_UNUSED *obj, hid_t H5_ATTR_UNUSED dxpl_id, - void H5_ATTR_UNUSED **req, va_list arguments) -{ - H5VL_native_attr_optional_t optional_type; - herr_t ret_value = SUCCEED; /* Return value */ - - FUNC_ENTER_STATIC - - optional_type = HDva_arg(arguments, H5VL_native_attr_optional_t); - switch(optional_type) { -#ifndef H5_NO_DEPRECATED_SYMBOLS - case H5VL_NATIVE_ATTR_ITERATE_OLD: - { - hid_t loc_id = HDva_arg(arguments, hid_t); - unsigned *attr_num = HDva_arg(arguments, unsigned *); - H5A_operator1_t op = HDva_arg(arguments, H5A_operator1_t); - void *op_data = HDva_arg(arguments, void *); - - /* Call the actual iteration routine */ - if((ret_value = H5A__iterate_old(loc_id, attr_num, op, op_data)) < 0) - HERROR(H5E_VOL, H5E_BADITER, "error iterating over attributes"); - - break; - } -#endif /* H5_NO_DEPRECATED_SYMBOLS */ - - default: - HGOTO_ERROR(H5E_VOL, H5E_UNSUPPORTED, FAIL, "invalid optional operation") - } /* end switch */ - -done: - FUNC_LEAVE_NOAPI(ret_value) -} /* end H5VL__native_attr_optional() */ - - -/*------------------------------------------------------------------------- - * Function: H5VL__native_attr_close - * - * Purpose: Closes an attribute. - * - * Return: Success: 0 - * Failure: -1, attr not closed. - * - * Programmer: Mohamad Chaarawi - * March, 2012 - * - *------------------------------------------------------------------------- - */ -static herr_t -H5VL__native_attr_close(void *attr, hid_t H5_ATTR_UNUSED dxpl_id, void H5_ATTR_UNUSED **req) -{ - herr_t ret_value = SUCCEED; /* Return value */ - - FUNC_ENTER_STATIC - - if(H5A__close((H5A_t*)attr) < 0) - HGOTO_ERROR(H5E_SYM, H5E_CANTDEC, FAIL, "can't close attribute") - -done: - FUNC_LEAVE_NOAPI(ret_value) -} /* end H5VL__native_attr_close() */ - - -/*------------------------------------------------------------------------- * Function: H5VL__native_dataset_create * * Purpose: Creates a dataset in a native HDF5 file diff --git a/src/H5VLnative.h b/src/H5VLnative.h index e1f85f8..d129865 100644 --- a/src/H5VLnative.h +++ b/src/H5VLnative.h @@ -85,8 +85,18 @@ typedef int H5VL_native_object_optional_t; extern "C" { #endif +/* Private functions */ H5_DLL hid_t H5VL_native_register(void); +/* Atrribute callbacks */ +H5_DLL void *H5VL__native_attr_create(void *obj, const H5VL_loc_params_t *loc_params, const char *attr_name, hid_t acpl_id, hid_t aapl_id, hid_t dxpl_id, void **req); +void *H5VL__native_attr_open(void *obj, const H5VL_loc_params_t *loc_params, const char *attr_name, hid_t aapl_id, hid_t dxpl_id, void **req); +H5_DLL herr_t H5VL__native_attr_read(void *attr, hid_t dtype_id, void *buf, hid_t dxpl_id, void **req); +H5_DLL herr_t H5VL__native_attr_write(void *attr, hid_t dtype_id, const void *buf, hid_t dxpl_id, void **req); +H5_DLL herr_t H5VL__native_attr_get(void *obj, H5VL_attr_get_t get_type, hid_t dxpl_id, void **req, va_list arguments); +H5_DLL herr_t H5VL__native_attr_specific(void *obj, const H5VL_loc_params_t *loc_params, H5VL_attr_specific_t specific_type, hid_t dxpl_id, void **req, va_list arguments); +H5_DLL herr_t H5VL__native_attr_optional(void *obj, hid_t dxpl_id, void **req, va_list arguments); +H5_DLL herr_t H5VL__native_attr_close(void *attr, hid_t dxpl_id, void **req); #ifdef __cplusplus } diff --git a/src/H5VLnative_attr.c b/src/H5VLnative_attr.c new file mode 100644 index 0000000..9688291 --- /dev/null +++ b/src/H5VLnative_attr.c @@ -0,0 +1,615 @@ +/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * + * Copyright by The HDF Group. * + * All rights reserved. * + * * + * This file is part of HDF5. The full HDF5 copyright notice, including * + * terms governing use, modification, and redistribution, is contained in * + * the COPYING file, which can be found at the root of the source code * + * distribution tree, or in https://support.hdfgroup.org/ftp/HDF5/releases. * + * If you do not have access to either file, you may request a copy from * + * help@hdfgroup.org. * + * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ + +/* + * Purpose: Attribute code for the native VOL connector. + * + */ + +#define H5A_FRIEND /* Suppress error about including H5Apkg */ + +#include "H5private.h" /* Generic Functions */ +#include "H5Apkg.h" /* Attributes */ +#include "H5Eprivate.h" /* Error handling */ +#include "H5Fprivate.h" /* Files */ +#include "H5Gprivate.h" /* Groups */ +#include "H5Iprivate.h" /* IDs */ +#include "H5Pprivate.h" /* Property lists */ +#include "H5Sprivate.h" /* Dataspaces */ +#include "H5Tprivate.h" /* Datatypes */ +#include "H5VLprivate.h" /* Virtual Object Layer */ + +#include "H5VLnative.h" /* Native VOL connector */ + + + +/*------------------------------------------------------------------------- + * Function: H5VL__native_attr_create + * + * Purpose: Handles the attribute create callback + * + * Return: Success: attribute pointer + * Failure: NULL + * + *------------------------------------------------------------------------- + */ +void * +H5VL__native_attr_create(void *obj, const H5VL_loc_params_t *loc_params, const char *attr_name, + hid_t acpl_id, hid_t H5_ATTR_UNUSED aapl_id, hid_t H5_ATTR_UNUSED dxpl_id, + void H5_ATTR_UNUSED **req) +{ + H5G_loc_t loc; /* Object location */ + H5G_loc_t obj_loc; /* Location used to open group */ + hbool_t loc_found = FALSE; + H5P_genplist_t *plist; /* Property list pointer */ + hid_t type_id, space_id; + H5T_t *type, *dt; /* Datatype to use for attribute */ + H5S_t *space; /* Dataspace to use for attribute */ + H5A_t *attr = NULL; + void *ret_value = NULL; + + FUNC_ENTER_PACKAGE + + /* Get the plist structure */ + if(NULL == (plist = (H5P_genplist_t *)H5I_object(acpl_id))) + HGOTO_ERROR(H5E_ATOM, H5E_BADATOM, NULL, "can't find object for ID") + + /* get creation properties */ + if(H5P_get(plist, H5VL_PROP_ATTR_TYPE_ID, &type_id) < 0) + HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, NULL, "can't get property value for datatype id") + if(H5P_get(plist, H5VL_PROP_ATTR_SPACE_ID, &space_id) < 0) + HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, NULL, "can't get property value for space id") + + if(H5G_loc_real(obj, loc_params->obj_type, &loc) < 0) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, NULL, "not a file or file object") + if(0 == (H5F_INTENT(loc.oloc->file) & H5F_ACC_RDWR)) + HGOTO_ERROR(H5E_ARGS, H5E_WRITEERROR, NULL, "no write intent on file") + + if(NULL == (dt = (H5T_t *)H5I_object_verify(type_id, H5I_DATATYPE))) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, NULL, "not a datatype") + /* If this is a named datatype, get the connector's pointer to the datatype */ + type = H5T_get_actual_type(dt); + + if(NULL == (space = (H5S_t *)H5I_object_verify(space_id, H5I_DATASPACE))) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, NULL, "not a data space") + + if(loc_params->type == H5VL_OBJECT_BY_SELF) { + /* H5Acreate */ + /* Go do the real work for attaching the attribute to the dataset */ + if(NULL == (attr = H5A__create(&loc, attr_name, type, space, acpl_id))) + HGOTO_ERROR(H5E_ATTR, H5E_CANTINIT, NULL, "unable to create attribute") + } /* end if */ + else if(loc_params->type == H5VL_OBJECT_BY_NAME) { + /* H5Acreate_by_name */ + if(NULL == (attr = H5A__create_by_name(&loc, loc_params->loc_data.loc_by_name.name, attr_name, type, space, acpl_id))) + HGOTO_ERROR(H5E_ATTR, H5E_CANTINIT, NULL, "unable to create attribute") + } /* end else-if */ + else + HGOTO_ERROR(H5E_VOL, H5E_UNSUPPORTED, NULL, "unknown attribute create parameters") + + ret_value = (void *)attr; + +done: + /* Release resources */ + if(loc_found && H5G_loc_free(&obj_loc) < 0) + HDONE_ERROR(H5E_ATTR, H5E_CANTRELEASE, NULL, "can't free location") + + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5VL__native_attr_create() */ + + +/*------------------------------------------------------------------------- + * Function: H5VL__native_attr_open + * + * Purpose: Handles the attribute open callback + * + * Return: Success: attribute pointer + * Failure: NULL + * + * Programmer: Mohamad Chaarawi + * March, 2012 + * + *------------------------------------------------------------------------- + */ +void * +H5VL__native_attr_open(void *obj, const H5VL_loc_params_t *loc_params, const char *attr_name, + hid_t H5_ATTR_UNUSED aapl_id, hid_t H5_ATTR_UNUSED dxpl_id, void H5_ATTR_UNUSED **req) +{ + H5G_loc_t loc; /* Object location */ + H5A_t *attr = NULL; /* Attribute opened */ + void *ret_value; + + FUNC_ENTER_PACKAGE + + /* check arguments */ + if(H5G_loc_real(obj, loc_params->obj_type, &loc) < 0) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, NULL, "not a file or file object") + + if(loc_params->type == H5VL_OBJECT_BY_SELF) { + /* H5Aopen */ + /* Open the attribute */ + if(NULL == (attr = H5A__open(&loc, attr_name))) + HGOTO_ERROR(H5E_ATTR, H5E_CANTOPENOBJ, NULL, "unable to open attribute: '%s'", attr_name) + } /* end if */ + else if(loc_params->type == H5VL_OBJECT_BY_NAME) { + /* H5Aopen_by_name */ + /* Open the attribute on the object header */ + if(NULL == (attr = H5A__open_by_name(&loc, loc_params->loc_data.loc_by_name.name, attr_name))) + HGOTO_ERROR(H5E_ATTR, H5E_CANTOPENOBJ, NULL, "can't open attribute") + } /* end else-if */ + else if(loc_params->type == H5VL_OBJECT_BY_IDX) { + /* H5Aopen_by_idx */ + /* Open the attribute in the object header */ + if(NULL == (attr = H5A__open_by_idx(&loc, loc_params->loc_data.loc_by_idx.name, + loc_params->loc_data.loc_by_idx.idx_type, + loc_params->loc_data.loc_by_idx.order, + loc_params->loc_data.loc_by_idx.n))) + HGOTO_ERROR(H5E_ATTR, H5E_CANTOPENOBJ, NULL, "unable to open attribute") + } /* end else-if */ + else + HGOTO_ERROR(H5E_VOL, H5E_UNSUPPORTED, NULL, "unknown attribute open parameters") + + ret_value = (void *)attr; + +done: + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5VL__native_attr_open() */ + + +/*------------------------------------------------------------------------- + * Function: H5VL__native_attr_read + * + * Purpose: Handles the attribute read callback + * + * Return: SUCCEED/FAIL + * + * Programmer: Mohamad Chaarawi + * March, 2012 + * + *------------------------------------------------------------------------- + */ +herr_t +H5VL__native_attr_read(void *attr, hid_t dtype_id, void *buf, + hid_t H5_ATTR_UNUSED dxpl_id, void H5_ATTR_UNUSED **req) +{ + H5T_t *mem_type; /* Memory datatype */ + herr_t ret_value; /* Return value */ + + FUNC_ENTER_PACKAGE + + if(NULL == (mem_type = (H5T_t *)H5I_object_verify(dtype_id, H5I_DATATYPE))) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a datatype") + + /* Go write the actual data to the attribute */ + if((ret_value = H5A__read((H5A_t*)attr, mem_type, buf)) < 0) + HGOTO_ERROR(H5E_ATTR, H5E_READERROR, FAIL, "unable to read attribute") + +done: + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5VL__native_attr_read() */ + + +/*------------------------------------------------------------------------- + * Function: H5VL__native_attr_write + * + * Purpose: Handles the attribute write callback + * + * Return: SUCCEED/FAIL + * + * Programmer: Mohamad Chaarawi + * March, 2012 + * + *------------------------------------------------------------------------- + */ +herr_t +H5VL__native_attr_write(void *attr, hid_t dtype_id, const void *buf, + hid_t H5_ATTR_UNUSED dxpl_id, void H5_ATTR_UNUSED **req) +{ + H5T_t *mem_type; /* Memory datatype */ + herr_t ret_value; /* Return value */ + + FUNC_ENTER_PACKAGE + + if(NULL == (mem_type = (H5T_t *)H5I_object_verify(dtype_id, H5I_DATATYPE))) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a datatype") + + /* Go write the actual data to the attribute */ + if((ret_value = H5A__write((H5A_t*)attr, mem_type, buf)) < 0) + HGOTO_ERROR(H5E_ATTR, H5E_WRITEERROR, FAIL, "unable to write attribute") + +done: + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5VL__native_attr_write() */ + + +/*------------------------------------------------------------------------- + * Function: H5VL__native_attr_get + * + * Purpose: Handles the attribute get callback + * + * Return: SUCCEED/FAIL + * + * Programmer: Mohamad Chaarawi + * March, 2012 + * + *------------------------------------------------------------------------- + */ +herr_t +H5VL__native_attr_get(void *obj, H5VL_attr_get_t get_type, + hid_t H5_ATTR_UNUSED dxpl_id, void H5_ATTR_UNUSED **req, va_list arguments) +{ + herr_t ret_value = SUCCEED; /* Return value */ + + FUNC_ENTER_PACKAGE + + switch(get_type) { + /* H5Aget_space */ + case H5VL_ATTR_GET_SPACE: + { + hid_t *ret_id = HDva_arg(arguments, hid_t *); + H5A_t *attr = (H5A_t *)obj; + + if((*ret_id = H5A_get_space(attr)) < 0) + HGOTO_ERROR(H5E_ARGS, H5E_CANTGET, FAIL, "can't get space ID of attribute") + break; + } + + /* H5Aget_type */ + case H5VL_ATTR_GET_TYPE: + { + hid_t *ret_id = HDva_arg(arguments, hid_t *); + H5A_t *attr = (H5A_t *)obj; + + if((*ret_id = H5A__get_type(attr)) < 0) + HGOTO_ERROR(H5E_ARGS, H5E_CANTGET, FAIL, "can't get datatype ID of attribute") + break; + } + + /* H5Aget_create_plist */ + case H5VL_ATTR_GET_ACPL: + { + hid_t *ret_id = HDva_arg(arguments, hid_t *); + H5A_t *attr = (H5A_t *)obj; + + if((*ret_id = H5A__get_create_plist(attr)) < 0) + HGOTO_ERROR(H5E_ARGS, H5E_CANTGET, FAIL, "can't get creation property list for attr") + + break; + } + + /* H5Aget_name */ + case H5VL_ATTR_GET_NAME: + { + const H5VL_loc_params_t *loc_params = HDva_arg(arguments, const H5VL_loc_params_t *); + size_t buf_size = HDva_arg(arguments, size_t); + char *buf = HDva_arg(arguments, char *); + ssize_t *ret_val = HDva_arg(arguments, ssize_t *); + H5A_t *attr = NULL; + + if(H5VL_OBJECT_BY_SELF == loc_params->type) { + attr = (H5A_t *)obj; + /* Call private function in turn */ + if(0 > (*ret_val = H5A__get_name(attr, buf_size, buf))) + HGOTO_ERROR(H5E_ATTR, H5E_CANTGET, FAIL, "can't get attribute name") + } + else if(H5VL_OBJECT_BY_IDX == loc_params->type) { + H5G_loc_t loc; + + /* check arguments */ + if(H5G_loc_real(obj, loc_params->obj_type, &loc) < 0) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a file or file object") + + /* Open the attribute on the object header */ + if(NULL == (attr = H5A__open_by_idx(&loc, loc_params->loc_data.loc_by_idx.name, + loc_params->loc_data.loc_by_idx.idx_type, + loc_params->loc_data.loc_by_idx.order, + loc_params->loc_data.loc_by_idx.n))) + HGOTO_ERROR(H5E_ATTR, H5E_CANTOPENOBJ, FAIL, "can't open attribute") + + /* Get the length of the name */ + *ret_val = (ssize_t)HDstrlen(attr->shared->name); + + /* Copy the name into the user's buffer, if given */ + if(buf) { + HDstrncpy(buf, attr->shared->name, MIN((size_t)(*ret_val + 1), buf_size)); + if((size_t)(*ret_val) >= buf_size) + buf[buf_size - 1]='\0'; + } /* end if */ + + /* Release resources */ + if(attr && H5A__close(attr) < 0) + HGOTO_ERROR(H5E_ATTR, H5E_CANTFREE, FAIL, "can't close attribute") + } + else + HGOTO_ERROR(H5E_SYM, H5E_CANTGET, FAIL, "can't get name of attr") + + break; + } + + /* H5Aget_info */ + case H5VL_ATTR_GET_INFO: + { + const H5VL_loc_params_t *loc_params = HDva_arg(arguments, const H5VL_loc_params_t *); + H5A_info_t *ainfo = HDva_arg(arguments, H5A_info_t *); + H5A_t *attr = NULL; + + if(H5VL_OBJECT_BY_SELF == loc_params->type) { + attr = (H5A_t *)obj; + if(H5A__get_info(attr, ainfo) < 0) + HGOTO_ERROR(H5E_ARGS, H5E_CANTGET, FAIL, "can't get attribute info") + } + else if(H5VL_OBJECT_BY_NAME == loc_params->type) { + char *attr_name = HDva_arg(arguments, char *); + H5G_loc_t loc; + + /* check arguments */ + if(H5G_loc_real(obj, loc_params->obj_type, &loc) < 0) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a file or file object") + + /* Open the attribute on the object header */ + if(NULL == (attr = H5A__open_by_name(&loc, loc_params->loc_data.loc_by_name.name, attr_name))) + HGOTO_ERROR(H5E_ATTR, H5E_CANTOPENOBJ, FAIL, "can't open attribute") + + /* Get the attribute information */ + if(H5A__get_info(attr, ainfo) < 0) + HGOTO_ERROR(H5E_ATTR, H5E_CANTGET, FAIL, "unable to get attribute info") + + /* Release resources */ + if(attr && H5A__close(attr) < 0) + HGOTO_ERROR(H5E_ATTR, H5E_CANTFREE, FAIL, "can't close attribute") + } + else if(H5VL_OBJECT_BY_IDX == loc_params->type) { + H5G_loc_t loc; + + /* check arguments */ + if(H5G_loc_real(obj, loc_params->obj_type, &loc) < 0) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a file or file object") + + /* Open the attribute on the object header */ + if(NULL == (attr = H5A__open_by_idx(&loc, loc_params->loc_data.loc_by_idx.name, + loc_params->loc_data.loc_by_idx.idx_type, + loc_params->loc_data.loc_by_idx.order, + loc_params->loc_data.loc_by_idx.n))) + HGOTO_ERROR(H5E_ATTR, H5E_CANTOPENOBJ, FAIL, "can't open attribute") + + /* Get the attribute information */ + if(H5A__get_info(attr, ainfo) < 0) + HGOTO_ERROR(H5E_ATTR, H5E_CANTGET, FAIL, "unable to get attribute info") + + /* Release resources */ + if(attr && H5A__close(attr) < 0) + HGOTO_ERROR(H5E_ATTR, H5E_CANTFREE, FAIL, "can't close attribute") + } + else + HGOTO_ERROR(H5E_SYM, H5E_CANTGET, FAIL, "can't get name of attr") + + break; + } + + case H5VL_ATTR_GET_STORAGE_SIZE: + { + hsize_t *ret = HDva_arg(arguments, hsize_t *); + H5A_t *attr = (H5A_t *)obj; + + /* Set return value */ + *ret = attr->shared->data_size; + break; + } + + default: + HGOTO_ERROR(H5E_VOL, H5E_CANTGET, FAIL, "can't get this type of information from attr") + } /* end switch */ + +done: + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5VL__native_attr_get() */ + + +/*------------------------------------------------------------------------- + * Function: H5VL__native_attr_specific + * + * Purpose: Handles the attribute specific callback + * + * Return: SUCCEED/FAIL + * + * Programmer: Mohamad Chaarawi + * August, 2014 + * + *------------------------------------------------------------------------- + */ +herr_t +H5VL__native_attr_specific(void *obj, const H5VL_loc_params_t *loc_params, H5VL_attr_specific_t specific_type, + hid_t H5_ATTR_UNUSED dxpl_id, void H5_ATTR_UNUSED **req, va_list arguments) +{ + H5G_loc_t loc; + herr_t ret_value = SUCCEED; /* Return value */ + + FUNC_ENTER_PACKAGE + + /* Get location for passed-in object */ + if(H5G_loc_real(obj, loc_params->obj_type, &loc) < 0) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a file or file object") + + switch(specific_type) { + case H5VL_ATTR_DELETE: + { + char *attr_name = HDva_arg(arguments, char *); + + if(H5VL_OBJECT_BY_SELF == loc_params->type) { + /* H5Adelete */ + /* Delete the attribute from the location */ + if(H5O__attr_remove(loc.oloc, attr_name) < 0) + HGOTO_ERROR(H5E_ATTR, H5E_CANTDELETE, FAIL, "unable to delete attribute") + } /* end if */ + else if(H5VL_OBJECT_BY_NAME == loc_params->type) { + /* H5Adelete_by_name */ + /* Delete the attribute */ + if(H5A__delete_by_name(&loc, loc_params->loc_data.loc_by_name.name, attr_name) < 0) + HGOTO_ERROR(H5E_ATTR, H5E_CANTDELETE, FAIL, "unable to delete attribute") + } /* end else-if */ + else if(H5VL_OBJECT_BY_IDX == loc_params->type) { + /* H5Adelete_by_idx */ + /* Delete the attribute from the location */ + if(H5A__delete_by_idx(&loc, loc_params->loc_data.loc_by_idx.name, loc_params->loc_data.loc_by_idx.idx_type, + loc_params->loc_data.loc_by_idx.order, loc_params->loc_data.loc_by_idx.n) < 0) + HGOTO_ERROR(H5E_ATTR, H5E_CANTDELETE, FAIL, "unable to delete attribute") + } /* end else-if */ + else + HGOTO_ERROR(H5E_VOL, H5E_UNSUPPORTED, FAIL, "unknown attribute remove parameters") + break; + } + + case H5VL_ATTR_EXISTS: + { + const char *attr_name = HDva_arg(arguments, const char *); + htri_t *ret = HDva_arg(arguments, htri_t *); + + if(loc_params->type == H5VL_OBJECT_BY_SELF) { /* H5Aexists */ + /* Check if the attribute exists */ + if((*ret = H5O__attr_exists(loc.oloc, attr_name)) < 0) + HGOTO_ERROR(H5E_ATTR, H5E_CANTGET, FAIL, "unable to determine if attribute exists") + } /* end if */ + else if(loc_params->type == H5VL_OBJECT_BY_NAME) { /* H5Aexists_by_name */ + /* Check if the attribute exists */ + if((*ret = H5A__exists_by_name(loc, loc_params->loc_data.loc_by_name.name, attr_name)) < 0) + HGOTO_ERROR(H5E_ATTR, H5E_CANTGET, FAIL, "unable to determine if attribute exists") + } /* end else-if */ + else + HGOTO_ERROR(H5E_VOL, H5E_UNSUPPORTED, FAIL, "unknown parameters") + break; + } + + case H5VL_ATTR_ITER: + { + H5_index_t idx_type = (H5_index_t)HDva_arg(arguments, int); /* enum work-around */ + H5_iter_order_t order = (H5_iter_order_t)HDva_arg(arguments, int); /* enum work-around */ + hsize_t *idx = HDva_arg(arguments, hsize_t *); + H5A_operator2_t op = HDva_arg(arguments, H5A_operator2_t); + void *op_data = HDva_arg(arguments, void *); + + if(loc_params->type == H5VL_OBJECT_BY_SELF) { /* H5Aiterate2 */ + /* Iterate over attributes */ + if((ret_value = H5A__iterate(&loc, ".", idx_type, order, idx, op, op_data)) < 0) + HGOTO_ERROR(H5E_ATTR, H5E_BADITER, FAIL, "error iterating over attributes") + } /* end if */ + else if(loc_params->type == H5VL_OBJECT_BY_NAME) { /* H5Aiterate_by_name */ + /* Iterate over attributes by name */ + if((ret_value = H5A__iterate(&loc, loc_params->loc_data.loc_by_name.name, idx_type, order, idx, op, op_data)) < 0) + HGOTO_ERROR(H5E_ATTR, H5E_BADITER, FAIL, "attribute iteration failed"); + } /* end else-if */ + else + HGOTO_ERROR(H5E_VOL, H5E_UNSUPPORTED, FAIL, "unknown parameters") + break; + } + + /* H5Arename/rename_by_name */ + case H5VL_ATTR_RENAME: + { + const char *old_name = HDva_arg(arguments, const char *); + const char *new_name = HDva_arg(arguments, const char *); + + if(loc_params->type == H5VL_OBJECT_BY_SELF) { /* H5Arename */ + /* Call attribute rename routine */ + if(H5O__attr_rename(loc.oloc, old_name, new_name) < 0) + HGOTO_ERROR(H5E_ATTR, H5E_CANTRENAME, FAIL, "can't rename attribute") + } /* end if */ + else if(loc_params->type == H5VL_OBJECT_BY_NAME) { /* H5Arename_by_name */ + /* Call attribute rename routine */ + if(H5A__rename_by_name(loc, loc_params->loc_data.loc_by_name.name, old_name, new_name) < 0) + HGOTO_ERROR(H5E_ATTR, H5E_CANTRENAME, FAIL, "can't rename attribute") + } /* end else-if */ + else + HGOTO_ERROR(H5E_VOL, H5E_UNSUPPORTED, FAIL, "unknown attribute rename parameters") + break; + } + + default: + HGOTO_ERROR(H5E_VOL, H5E_UNSUPPORTED, FAIL, "invalid specific operation") + } /* end switch */ + +done: + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5VL__native_attr_specific() */ + + +/*------------------------------------------------------------------------- + * Function: H5VL__native_attr_optional + * + * Purpose: Handles the attribute optional callback + * + * Return: SUCCEED/FAIL + * + *------------------------------------------------------------------------- + */ +herr_t +H5VL__native_attr_optional(void H5_ATTR_UNUSED *obj, hid_t H5_ATTR_UNUSED dxpl_id, + void H5_ATTR_UNUSED **req, va_list arguments) +{ + H5VL_native_attr_optional_t optional_type; + herr_t ret_value = SUCCEED; /* Return value */ + + FUNC_ENTER_PACKAGE + + optional_type = HDva_arg(arguments, H5VL_native_attr_optional_t); + switch(optional_type) { +#ifndef H5_NO_DEPRECATED_SYMBOLS + case H5VL_NATIVE_ATTR_ITERATE_OLD: + { + hid_t loc_id = HDva_arg(arguments, hid_t); + unsigned *attr_num = HDva_arg(arguments, unsigned *); + H5A_operator1_t op = HDva_arg(arguments, H5A_operator1_t); + void *op_data = HDva_arg(arguments, void *); + + /* Call the actual iteration routine */ + if((ret_value = H5A__iterate_old(loc_id, attr_num, op, op_data)) < 0) + HERROR(H5E_VOL, H5E_BADITER, "error iterating over attributes"); + + break; + } +#endif /* H5_NO_DEPRECATED_SYMBOLS */ + + default: + HGOTO_ERROR(H5E_VOL, H5E_UNSUPPORTED, FAIL, "invalid optional operation") + } /* end switch */ + +done: + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5VL__native_attr_optional() */ + + +/*------------------------------------------------------------------------- + * Function: H5VL__native_attr_close + * + * Purpose: Handles the attribute close callback + * + * Return: Success: SUCCEED + * Failure: FAIL, attribute not closed + * + * Programmer: Mohamad Chaarawi + * March, 2012 + * + *------------------------------------------------------------------------- + */ +herr_t +H5VL__native_attr_close(void *attr, hid_t H5_ATTR_UNUSED dxpl_id, void H5_ATTR_UNUSED **req) +{ + herr_t ret_value = SUCCEED; /* Return value */ + + FUNC_ENTER_PACKAGE + + if(H5A__close((H5A_t*)attr) < 0) + HGOTO_ERROR(H5E_SYM, H5E_CANTDEC, FAIL, "can't close attribute") + +done: + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5VL__native_attr_close() */ + diff --git a/src/H5VLnative_dataset.c b/src/H5VLnative_dataset.c new file mode 100644 index 0000000..636b48b --- /dev/null +++ b/src/H5VLnative_dataset.c @@ -0,0 +1,13 @@ +/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * + * Copyright by The HDF Group. * + * All rights reserved. * + * * + * This file is part of HDF5. The full HDF5 copyright notice, including * + * terms governing use, modification, and redistribution, is contained in * + * the COPYING file, which can be found at the root of the source code * + * distribution tree, or in https://support.hdfgroup.org/ftp/HDF5/releases. * + * If you do not have access to either file, you may request a copy from * + * help@hdfgroup.org. * + * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ + + diff --git a/src/H5VLnative_datatype.c b/src/H5VLnative_datatype.c new file mode 100644 index 0000000..636b48b --- /dev/null +++ b/src/H5VLnative_datatype.c @@ -0,0 +1,13 @@ +/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * + * Copyright by The HDF Group. * + * All rights reserved. * + * * + * This file is part of HDF5. The full HDF5 copyright notice, including * + * terms governing use, modification, and redistribution, is contained in * + * the COPYING file, which can be found at the root of the source code * + * distribution tree, or in https://support.hdfgroup.org/ftp/HDF5/releases. * + * If you do not have access to either file, you may request a copy from * + * help@hdfgroup.org. * + * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ + + diff --git a/src/H5VLnative_file.c b/src/H5VLnative_file.c new file mode 100644 index 0000000..636b48b --- /dev/null +++ b/src/H5VLnative_file.c @@ -0,0 +1,13 @@ +/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * + * Copyright by The HDF Group. * + * All rights reserved. * + * * + * This file is part of HDF5. The full HDF5 copyright notice, including * + * terms governing use, modification, and redistribution, is contained in * + * the COPYING file, which can be found at the root of the source code * + * distribution tree, or in https://support.hdfgroup.org/ftp/HDF5/releases. * + * If you do not have access to either file, you may request a copy from * + * help@hdfgroup.org. * + * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ + + diff --git a/src/H5VLnative_group.c b/src/H5VLnative_group.c new file mode 100644 index 0000000..636b48b --- /dev/null +++ b/src/H5VLnative_group.c @@ -0,0 +1,13 @@ +/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * + * Copyright by The HDF Group. * + * All rights reserved. * + * * + * This file is part of HDF5. The full HDF5 copyright notice, including * + * terms governing use, modification, and redistribution, is contained in * + * the COPYING file, which can be found at the root of the source code * + * distribution tree, or in https://support.hdfgroup.org/ftp/HDF5/releases. * + * If you do not have access to either file, you may request a copy from * + * help@hdfgroup.org. * + * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ + + diff --git a/src/H5VLnative_link.c b/src/H5VLnative_link.c new file mode 100644 index 0000000..636b48b --- /dev/null +++ b/src/H5VLnative_link.c @@ -0,0 +1,13 @@ +/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * + * Copyright by The HDF Group. * + * All rights reserved. * + * * + * This file is part of HDF5. The full HDF5 copyright notice, including * + * terms governing use, modification, and redistribution, is contained in * + * the COPYING file, which can be found at the root of the source code * + * distribution tree, or in https://support.hdfgroup.org/ftp/HDF5/releases. * + * If you do not have access to either file, you may request a copy from * + * help@hdfgroup.org. * + * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ + + diff --git a/src/H5VLnative_object.c b/src/H5VLnative_object.c new file mode 100644 index 0000000..636b48b --- /dev/null +++ b/src/H5VLnative_object.c @@ -0,0 +1,13 @@ +/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * + * Copyright by The HDF Group. * + * All rights reserved. * + * * + * This file is part of HDF5. The full HDF5 copyright notice, including * + * terms governing use, modification, and redistribution, is contained in * + * the COPYING file, which can be found at the root of the source code * + * distribution tree, or in https://support.hdfgroup.org/ftp/HDF5/releases. * + * If you do not have access to either file, you may request a copy from * + * help@hdfgroup.org. * + * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ + + diff --git a/src/Makefile.am b/src/Makefile.am index 69b51b2..c0be29c 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -114,7 +114,10 @@ libhdf5_la_SOURCES= H5.c H5checksum.c H5dbg.c H5system.c H5timer.c H5trace.c \ H5Topaque.c \ H5Torder.c \ H5Tpad.c H5Tprecis.c H5Tstrpad.c H5Tvisit.c H5Tvlen.c H5TS.c \ - H5VL.c H5VLcallback.c H5VLint.c H5VLnative.c H5VLpassthru.c \ + H5VL.c H5VLcallback.c H5VLint.c H5VLnative.c \ + H5VLnative_attr.c H5VLnative_dataset.c H5VLnative_datatype.c \ + H5VLnative_file.c H5VLnative_group.c H5VLnative_link.c H5VLnative_object.c \ + H5VLpassthru.c \ H5VM.c H5WB.c H5Z.c \ H5Zdeflate.c H5Zfletcher32.c H5Znbit.c H5Zshuffle.c \ H5Zscaleoffset.c H5Zszip.c H5Ztrans.c -- cgit v0.12 From aad96a8c736dfbb49b2b27ebdaf3a5c8a5d72942 Mon Sep 17 00:00:00 2001 From: Dana Robinson Date: Wed, 19 Dec 2018 19:19:05 -0800 Subject: Moved the remainder of the code into separate files. --- src/H5VLnative.c | 2880 +-------------------------------------------- src/H5VLnative.h | 47 + src/H5VLnative_attr.c | 22 +- src/H5VLnative_dataset.c | 562 +++++++++ src/H5VLnative_datatype.c | 252 ++++ src/H5VLnative_file.c | 798 +++++++++++++ src/H5VLnative_group.c | 350 ++++++ src/H5VLnative_link.c | 422 +++++++ src/H5VLnative_object.c | 469 ++++++++ 9 files changed, 2906 insertions(+), 2896 deletions(-) diff --git a/src/H5VLnative.c b/src/H5VLnative.c index b34b001..82ff470 100644 --- a/src/H5VLnative.c +++ b/src/H5VLnative.c @@ -11,101 +11,24 @@ * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ /* - * Purpose: The native VOL connector where access is to a single HDF5 file + * Purpose: The native VOL connector where access is to a single HDF5 file * using HDF5 VFDs. */ -#define H5D_FRIEND /* Suppress error about including H5Dpkg */ -#define H5F_FRIEND /* Suppress error about including H5Fpkg */ -#define H5G_FRIEND /* Suppress error about including H5Gpkg */ -#define H5L_FRIEND /* Suppress error about including H5Lpkg */ -#define H5O_FRIEND /* Suppress error about including H5Opkg */ -#define H5R_FRIEND /* Suppress error about including H5Rpkg */ -#define H5T_FRIEND /* Suppress error about including H5Tpkg */ - - #include "H5private.h" /* Generic Functions */ -#include "H5Dpkg.h" /* Datasets */ #include "H5Eprivate.h" /* Error handling */ -#include "H5Fpkg.h" /* Files */ -#include "H5Gpkg.h" /* Groups */ #include "H5Iprivate.h" /* IDs */ -#include "H5Lpkg.h" /* Links */ -#include "H5MFprivate.h" /* File memory management */ -#include "H5MMprivate.h" /* Memory management */ -#include "H5Opkg.h" /* Object headers */ #include "H5Pprivate.h" /* Property lists */ -#include "H5Rpkg.h" /* References */ -#include "H5SMprivate.h" /* Shared Object Header Messages */ -#include "H5Tpkg.h" /* Datatypes */ #include "H5VLprivate.h" /* Virtual Object Layer */ + #include "H5VLnative.h" /* Native VOL connector */ -/* - * The VOL connector identification number. - */ +/* The VOL connector identification number */ static hid_t H5VL_NATIVE_ID_g = H5I_INVALID_HID; - /* Prototypes */ static herr_t H5VL__native_term(void); -/* Dataset callbacks */ -static void *H5VL__native_dataset_create(void *obj, const H5VL_loc_params_t *loc_params, const char *name, hid_t dcpl_id, hid_t dapl_id, hid_t dxpl_id, void **req); -static void *H5VL__native_dataset_open(void *obj, const H5VL_loc_params_t *loc_params, const char *name, hid_t dapl_id, hid_t dxpl_id, void **req); -static herr_t H5VL__native_dataset_read(void *dset, hid_t mem_type_id, hid_t mem_space_id, - hid_t file_space_id, hid_t plist_id, void *buf, void **req); -static herr_t H5VL__native_dataset_write(void *dset, hid_t mem_type_id, hid_t mem_space_id, - hid_t file_space_id, hid_t plist_id, const void *buf, void **req); -static herr_t H5VL__native_dataset_get(void *dset, H5VL_dataset_get_t get_type, hid_t dxpl_id, void **req, va_list arguments); -static herr_t H5VL__native_dataset_specific(void *dset, H5VL_dataset_specific_t specific_type, hid_t dxpl_id, void **req, va_list arguments); -static herr_t H5VL__native_dataset_optional(void *dset, hid_t dxpl_id, void **req, va_list arguments); -static herr_t H5VL__native_dataset_close(void *dset, hid_t dxpl_id, void **req); - -/* File callbacks */ -static void *H5VL__native_file_create(const char *name, unsigned flags, hid_t fcpl_id, hid_t fapl_id, hid_t dxpl_id, void **req); -static void *H5VL__native_file_open(const char *name, unsigned flags, hid_t fapl_id, hid_t dxpl_id, void **req); -static herr_t H5VL__native_file_get(void *file, H5VL_file_get_t get_type, hid_t dxpl_id, void **req, va_list arguments); -static herr_t H5VL__native_file_specific(void *file, H5VL_file_specific_t specific_type, hid_t dxpl_id, void **req, va_list arguments); -static herr_t H5VL__native_file_optional(void *file, hid_t dxpl_id, void **req, va_list arguments); -static herr_t H5VL__native_file_close(void *file, hid_t dxpl_id, void **req); - -/* Group callbacks */ -static void *H5VL__native_group_create(void *obj, const H5VL_loc_params_t *loc_params, const char *name, hid_t gcpl_id, hid_t gapl_id, hid_t dxpl_id, void **req); -static void *H5VL__native_group_open(void *obj, const H5VL_loc_params_t *loc_params, const char *name, hid_t gapl_id, hid_t dxpl_id, void **req); -static herr_t H5VL__native_group_get(void *obj, H5VL_group_get_t get_type, hid_t dxpl_id, void **req, va_list arguments); -static herr_t H5VL__native_group_specific(void *obj, H5VL_group_specific_t specific_type, hid_t dxpl_id, void **req, va_list arguments); -static herr_t H5VL__native_group_optional(void *obj, 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, - const H5VL_loc_params_t *loc_params, hid_t lcpl_id, hid_t lapl_id, hid_t dxpl_id, void **req); -static herr_t H5VL__native_link_copy(void *src_obj, const H5VL_loc_params_t *loc_params1, - void *dst_obj, const H5VL_loc_params_t *loc_params2, - hid_t lcpl_id, hid_t lapl_id, hid_t dxpl_id, void **req); -static herr_t H5VL__native_link_move(void *src_obj, const H5VL_loc_params_t *loc_params1, - void *dst_obj, const H5VL_loc_params_t *loc_params2, - hid_t lcpl_id, hid_t lapl_id, hid_t dxpl_id, void **req); -static herr_t H5VL__native_link_get(void *obj, const H5VL_loc_params_t *loc_params, H5VL_link_get_t get_type, hid_t dxpl_id, void **req, va_list arguments); -static herr_t H5VL__native_link_specific(void *obj, const H5VL_loc_params_t *loc_params, H5VL_link_specific_t specific_type, hid_t dxpl_id, void **req, va_list arguments); - -/* Object callbacks */ -static void *H5VL__native_object_open(void *obj, const H5VL_loc_params_t *loc_params, H5I_type_t *opened_type, hid_t dxpl_id, void **req); -static herr_t H5VL__native_object_copy(void *src_obj, const H5VL_loc_params_t *loc_params1, const char *src_name, - void *dst_obj, const H5VL_loc_params_t *loc_params2, const char *dst_name, - hid_t ocpypl_id, hid_t lcpl_id, hid_t dxpl_id, void **req); -static herr_t H5VL__native_object_get(void *obj, const H5VL_loc_params_t *loc_params, H5VL_object_get_t get_type, hid_t dxpl_id, void **req, va_list arguments); -static herr_t H5VL__native_object_specific(void *obj, const H5VL_loc_params_t *loc_params, H5VL_object_specific_t specific_type, hid_t dxpl_id, void **req, va_list arguments); -static herr_t H5VL__native_object_optional(void *obj, hid_t dxpl_id, void **req, va_list arguments); - -/* Datatype callbacks */ -static void *H5VL__native_datatype_commit(void *obj, const H5VL_loc_params_t *loc_params, const char *name, hid_t type_id, hid_t lcpl_id, hid_t tcpl_id, hid_t tapl_id, hid_t dxpl_id, void **req); -static void *H5VL__native_datatype_open(void *obj, const H5VL_loc_params_t *loc_params, const char *name, hid_t tapl_id, hid_t dxpl_id, void **req); -static herr_t H5VL__native_datatype_get(void *dt, H5VL_datatype_get_t get_type, hid_t dxpl_id, void **req, va_list arguments); -static herr_t H5VL__native_datatype_specific(void *dt, H5VL_datatype_specific_t specific_type, hid_t dxpl_id, void **req, va_list arguments); -static herr_t H5VL__native_datatype_close(void *dt, hid_t dxpl_id, void **req); - /* Native VOL connector class struct */ static H5VL_class_t H5VL_native_cls_g = { H5VL_NATIVE_VERSION, /* version */ @@ -198,7 +121,7 @@ static H5VL_class_t H5VL_native_cls_g = { /*------------------------------------------------------------------------- * Function: H5VL_native_register * - * Purpose: Register the native VOL connector and retrieve an ID for it. + * Purpose: Register the native VOL connector and retrieve an ID for it. * * Return: Success: The ID for the native connector * Failure: H5I_INVALID_HID @@ -245,2798 +168,3 @@ H5VL__native_term(void) FUNC_LEAVE_NOAPI(SUCCEED) } /* end H5VL__native_term() */ - -/*------------------------------------------------------------------------- - * Function: H5VL__native_dataset_create - * - * Purpose: Creates a dataset in a native HDF5 file - * - * Return: Success: Pointer to a dataset struct - * Failure: NULL - * - *------------------------------------------------------------------------- - */ -static void * -H5VL__native_dataset_create(void *obj, const H5VL_loc_params_t *loc_params, - const char *name, hid_t dcpl_id, hid_t dapl_id, hid_t H5_ATTR_UNUSED dxpl_id, - void H5_ATTR_UNUSED **req) -{ - H5P_genplist_t *plist; /* Property list pointer */ - H5G_loc_t loc; /* Object location to insert dataset into */ - hid_t type_id = H5I_INVALID_HID; - hid_t space_id = H5I_INVALID_HID; - hid_t lcpl_id = H5I_INVALID_HID; - H5D_t *dset = NULL; /* New dataset's info */ - const H5S_t *space; /* Dataspace for dataset */ - void *ret_value; - - FUNC_ENTER_STATIC - - /* Get the plist structure */ - if(NULL == (plist = (H5P_genplist_t *)H5I_object(dcpl_id))) - HGOTO_ERROR(H5E_ATOM, H5E_BADATOM, NULL, "can't find object for ID") - - /* Get creation properties */ - if(H5P_get(plist, H5VL_PROP_DSET_TYPE_ID, &type_id) < 0) - HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, NULL, "can't get property value for datatype id") - if(H5P_get(plist, H5VL_PROP_DSET_SPACE_ID, &space_id) < 0) - HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, NULL, "can't get property value for space id") - if(H5P_get(plist, H5VL_PROP_DSET_LCPL_ID, &lcpl_id) < 0) - HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, NULL, "can't get property value for lcpl id") - - /* Check arguments */ - if(H5G_loc_real(obj, loc_params->obj_type, &loc) < 0) - HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, NULL, "not a file or file object") - if(H5I_DATATYPE != H5I_get_type(type_id)) - HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, NULL, "not a datatype ID") - if(NULL == (space = (const H5S_t *)H5I_object_verify(space_id, H5I_DATASPACE))) - HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, NULL, "not a dataspace ID") - - /* H5Dcreate_anon */ - if(NULL == name) { - /* build and open the new dataset */ - if(NULL == (dset = H5D__create(loc.oloc->file, type_id, space, dcpl_id, dapl_id))) - HGOTO_ERROR(H5E_DATASET, H5E_CANTINIT, NULL, "unable to create dataset") - } /* end if */ - /* H5Dcreate2 */ - else { - /* Create the new dataset & get its ID */ - if(NULL == (dset = H5D__create_named(&loc, name, type_id, space, lcpl_id, dcpl_id, dapl_id))) - HGOTO_ERROR(H5E_DATASET, H5E_CANTINIT, NULL, "unable to create dataset") - } /* end else */ - - ret_value = (void *)dset; - -done: - if(NULL == name) { - /* Release the dataset's object header, if it was created */ - if(dset) { - H5O_loc_t *oloc; /* Object location for dataset */ - - /* Get the new dataset's object location */ - if(NULL == (oloc = H5D_oloc(dset))) - HDONE_ERROR(H5E_DATASET, H5E_CANTGET, NULL, "unable to get object location of dataset") - - /* Decrement refcount on dataset's object header in memory */ - if(H5O_dec_rc_by_loc(oloc) < 0) - HDONE_ERROR(H5E_DATASET, H5E_CANTDEC, NULL, "unable to decrement refcount on newly created object") - } /* end if */ - } /* end if */ - - FUNC_LEAVE_NOAPI(ret_value) -} /* end H5VL__native_dataset_create() */ - - -/*------------------------------------------------------------------------- - * Function: H5VL__native_dataset_open - * - * Purpose: Opens a dataset in a native HDF5 file. - * - * Return: Success: Pointer to a dataset struct - * Failure: NULL - * - *------------------------------------------------------------------------- - */ -static void * -H5VL__native_dataset_open(void *obj, const H5VL_loc_params_t *loc_params, const char *name, - hid_t dapl_id, hid_t H5_ATTR_UNUSED dxpl_id, void H5_ATTR_UNUSED **req) -{ - H5D_t *dset = NULL; - H5G_loc_t loc; /* Object location of group */ - void *ret_value = NULL; - - FUNC_ENTER_STATIC - - if(H5G_loc_real(obj, loc_params->obj_type, &loc) < 0) - HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, NULL, "not a file or file object") - - /* Open the dataset */ - if(NULL == (dset = H5D__open_name(&loc, name, dapl_id))) - HGOTO_ERROR(H5E_DATASET, H5E_CANTOPENOBJ, NULL, "unable to open dataset") - - ret_value = (void *)dset; - -done: - FUNC_LEAVE_NOAPI(ret_value) -} /* end H5VL__native_dataset_open() */ - - -/*------------------------------------------------------------------------- - * Function: H5VL__native_dataset_read - * - * Purpose: Reads raw data from a dataset into a buffer. - * - * Return: SUCCEED/FAIL - * - *------------------------------------------------------------------------- - */ -static herr_t -H5VL__native_dataset_read(void *obj, hid_t mem_type_id, hid_t mem_space_id, - hid_t file_space_id, hid_t H5_ATTR_UNUSED dxpl_id, void *buf, - void H5_ATTR_UNUSED **req) -{ - H5D_t *dset = (H5D_t *)obj; - const H5S_t *mem_space = NULL; - const H5S_t *file_space = NULL; - herr_t ret_value = SUCCEED; /* Return value */ - - FUNC_ENTER_STATIC - - /* Check arguments */ - if(NULL == dset->oloc.file) - HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "dataset is not associated with a file") - - /* Get validated dataspace pointers */ - if(H5S_get_validated_dataspace(mem_space_id, &mem_space) < 0) - HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "could not get a validated dataspace from mem_space_id") - if(H5S_get_validated_dataspace(file_space_id, &file_space) < 0) - HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "could not get a validated dataspace from file_space_id") - - /* Read raw data */ - if(H5D__read(dset, mem_type_id, mem_space, file_space, buf/*out*/) < 0) - HGOTO_ERROR(H5E_DATASET, H5E_READERROR, FAIL, "can't read data") - -done: - FUNC_LEAVE_NOAPI(ret_value) -} /* end H5VL__native_dataset_read() */ - - -/*------------------------------------------------------------------------- - * Function: H5VL__native_dataset_write - * - * Purpose: Writes raw data from a buffer into a dataset. - * - * Return: SUCCEED/FAIL - * - *------------------------------------------------------------------------- - */ -static herr_t -H5VL__native_dataset_write(void *obj, hid_t mem_type_id, hid_t mem_space_id, - hid_t file_space_id, hid_t H5_ATTR_UNUSED dxpl_id, const void *buf, - void H5_ATTR_UNUSED **req) -{ - H5D_t *dset = (H5D_t *)obj; - const H5S_t *mem_space = NULL; - const H5S_t *file_space = NULL; - herr_t ret_value = SUCCEED; /* Return value */ - - FUNC_ENTER_STATIC - - /* check arguments */ - if(NULL == dset->oloc.file) - HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "dataset is not associated with a file") - - /* Get validated dataspace pointers */ - if(H5S_get_validated_dataspace(mem_space_id, &mem_space) < 0) - HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "could not get a validated dataspace from mem_space_id") - if(H5S_get_validated_dataspace(file_space_id, &file_space) < 0) - HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "could not get a validated dataspace from file_space_id") - - /* Write the data */ - if(H5D__write(dset, mem_type_id, mem_space, file_space, buf) < 0) - HGOTO_ERROR(H5E_DATASET, H5E_WRITEERROR, FAIL, "can't write data") - -done: - FUNC_LEAVE_NOAPI(ret_value) -} /* end H5VL__native_dataset_write() */ - - -/*------------------------------------------------------------------------- - * Function: H5VL__native_dataset_get - * - * Purpose: Gets certain information about a dataset - * - * Return: SUCCEED/FAIL - * - *------------------------------------------------------------------------- - */ -static herr_t -H5VL__native_dataset_get(void *obj, H5VL_dataset_get_t get_type, - hid_t H5_ATTR_UNUSED dxpl_id, void H5_ATTR_UNUSED **req, va_list arguments) -{ - H5D_t *dset = (H5D_t *)obj; - herr_t ret_value = SUCCEED; /* Return value */ - - FUNC_ENTER_STATIC - - switch(get_type) { - /* H5Dget_space */ - case H5VL_DATASET_GET_SPACE: - { - hid_t *ret_id = HDva_arg(arguments, hid_t *); - - if((*ret_id = H5D__get_space(dset)) < 0) - HGOTO_ERROR(H5E_ARGS, H5E_CANTGET, FAIL, "can't get space ID of dataset") - - break; - } - - /* H5Dget_space_statuc */ - case H5VL_DATASET_GET_SPACE_STATUS: - { - H5D_space_status_t *allocation = HDva_arg(arguments, H5D_space_status_t *); - - /* Read data space address and return */ - if(H5D__get_space_status(dset, allocation) < 0) - HGOTO_ERROR(H5E_DATASET, H5E_CANTINIT, FAIL, "unable to get space status") - - break; - } - - /* H5Dget_type */ - case H5VL_DATASET_GET_TYPE: - { - hid_t *ret_id = HDva_arg(arguments, hid_t *); - - if((*ret_id = H5D__get_type(dset)) < 0) - HGOTO_ERROR(H5E_ARGS, H5E_CANTGET, FAIL, "can't get datatype ID of dataset") - - break; - } - - /* H5Dget_create_plist */ - case H5VL_DATASET_GET_DCPL: - { - hid_t *ret_id = HDva_arg(arguments, hid_t *); - - if((*ret_id = H5D_get_create_plist(dset)) < 0) - HGOTO_ERROR(H5E_ARGS, H5E_CANTGET, FAIL, "can't get creation property list for dataset") - - break; - } - - /* H5Dget_access_plist */ - case H5VL_DATASET_GET_DAPL: - { - hid_t *ret_id = HDva_arg(arguments, hid_t *); - - if((*ret_id = H5D_get_access_plist(dset)) < 0) - HGOTO_ERROR(H5E_ARGS, H5E_CANTGET, FAIL, "can't get access property list for dataset") - - break; - } - - /* H5Dget_storage_size */ - case H5VL_DATASET_GET_STORAGE_SIZE: - { - hsize_t *ret = HDva_arg(arguments, hsize_t *); - - /* Set return value */ - if(H5D__get_storage_size(dset, ret) < 0) - HGOTO_ERROR(H5E_DATASET, H5E_CANTGET, FAIL, "can't get size of dataset's storage") - break; - } - - /* H5Dget_offset */ - case H5VL_DATASET_GET_OFFSET: - { - haddr_t *ret = HDva_arg(arguments, haddr_t *); - - /* Set return value */ - *ret = H5D__get_offset(dset); - if(!H5F_addr_defined(*ret)) - *ret = HADDR_UNDEF; - break; - } - - default: - HGOTO_ERROR(H5E_VOL, H5E_CANTGET, FAIL, "can't get this type of information from dataset") - } /* end switch */ - -done: - FUNC_LEAVE_NOAPI(ret_value) -} /* end H5VL__native_dataset_get() */ - - -/*------------------------------------------------------------------------- - * Function: H5VL__native_dataset_specific - * - * Purpose: Specific operation on dataset - * - * Return: SUCCEED/FAIL - * - *------------------------------------------------------------------------- - */ -static herr_t -H5VL__native_dataset_specific(void *obj, H5VL_dataset_specific_t specific_type, - hid_t H5_ATTR_UNUSED dxpl_id, void H5_ATTR_UNUSED **req, va_list arguments) -{ - H5D_t *dset = (H5D_t *)obj; - herr_t ret_value = SUCCEED; /* Return value */ - - FUNC_ENTER_STATIC - - switch(specific_type) { - /* H5Dspecific_space */ - case H5VL_DATASET_SET_EXTENT: - { - const hsize_t *size = HDva_arg(arguments, const hsize_t *); - - if(H5D__set_extent(dset, size) < 0) - HGOTO_ERROR(H5E_DATASET, H5E_CANTINIT, FAIL, "unable to set extent of dataset") - break; - } - - case H5VL_DATASET_FLUSH: - { - hid_t dset_id = HDva_arg(arguments, hid_t); - - /* Flush the dataset */ - if(H5D__flush(dset, dset_id) < 0) - HGOTO_ERROR(H5E_DATASET, H5E_CANTFLUSH, FAIL, "unable to flush dataset") - - break; - } - - case H5VL_DATASET_REFRESH: - { - hid_t dset_id = HDva_arg(arguments, hid_t); - - /* Refresh the dataset */ - if((H5D__refresh(dset_id, dset)) < 0) - HGOTO_ERROR(H5E_DATASET, H5E_CANTLOAD, FAIL, "unable to refresh dataset") - - break; - } - - default: - HGOTO_ERROR(H5E_VOL, H5E_UNSUPPORTED, FAIL, "invalid specific operation") - } /* end switch */ - -done: - FUNC_LEAVE_NOAPI(ret_value) -} /* end H5VL__native_dataset_specific() */ - - -/*------------------------------------------------------------------------- - * Function: H5VL__native_dataset_optional - * - * Purpose: Perform a connector-specific operation on a native dataset - * - * Return: SUCCEED/FAIL - * - *------------------------------------------------------------------------- - */ -static herr_t -H5VL__native_dataset_optional(void *obj, hid_t H5_ATTR_UNUSED dxpl_id, - void H5_ATTR_UNUSED **req, va_list arguments) -{ - H5D_t *dset = NULL; /* Dataset */ - H5VL_native_dataset_optional_t optional_type = HDva_arg(arguments, H5VL_native_dataset_optional_t); - herr_t ret_value = SUCCEED; /* Return value */ - - FUNC_ENTER_STATIC - - switch(optional_type) { - case H5VL_NATIVE_DATASET_FORMAT_CONVERT: - { - dset = (H5D_t *)obj; - - switch(dset->shared->layout.type) { - case H5D_CHUNKED: - /* Convert the chunk indexing type to version 1 B-tree if not */ - if(dset->shared->layout.u.chunk.idx_type != H5D_CHUNK_IDX_BTREE) - if((H5D__format_convert(dset)) < 0) - HGOTO_ERROR(H5E_DATASET, H5E_CANTLOAD, FAIL, "unable to downgrade chunk indexing type for dataset") - break; - - case H5D_CONTIGUOUS: - case H5D_COMPACT: - /* Downgrade the layout version to 3 if greater than 3 */ - if(dset->shared->layout.version > H5O_LAYOUT_VERSION_DEFAULT) - if((H5D__format_convert(dset)) < 0) - HGOTO_ERROR(H5E_DATASET, H5E_CANTLOAD, FAIL, "unable to downgrade layout version for dataset") - break; - - case H5D_VIRTUAL: - /* Nothing to do even though layout is version 4 */ - break; - - case H5D_LAYOUT_ERROR: - case H5D_NLAYOUTS: - HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "invalid dataset layout type") - - default: - HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "unknown dataset layout type") - } /* end switch */ - - break; - } - - case H5VL_NATIVE_DATASET_GET_CHUNK_INDEX_TYPE: - { - H5D_chunk_index_t *idx_type = HDva_arg(arguments, H5D_chunk_index_t *); - - dset = (H5D_t *)obj; - - /* Make sure the dataset is chunked */ - if(H5D_CHUNKED != dset->shared->layout.type) - HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a chunked dataset") - - /* Get the chunk indexing type */ - *idx_type = dset->shared->layout.u.chunk.idx_type; - - break; - } - - case H5VL_NATIVE_DATASET_GET_CHUNK_STORAGE_SIZE: - { - hsize_t *offset = HDva_arg(arguments, hsize_t *); - hsize_t *chunk_nbytes = HDva_arg(arguments, hsize_t *); - - dset = (H5D_t *)obj; - - /* Make sure the dataset is chunked */ - if(H5D_CHUNKED != dset->shared->layout.type) - HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a chunked dataset") - - /* Call private function */ - if(H5D__get_chunk_storage_size(dset, offset, chunk_nbytes) < 0) - HGOTO_ERROR(H5E_DATASET, H5E_CANTGET, FAIL, "can't get storage size of chunk") - - break; - } - - case H5VL_NATIVE_DATASET_CHUNK_READ: - { - const hsize_t *offset = HDva_arg(arguments, hsize_t *); - uint32_t *filters = HDva_arg(arguments, uint32_t *); - void *buf = HDva_arg(arguments, void *); - hsize_t offset_copy[H5O_LAYOUT_NDIMS]; /* Internal copy of chunk offset */ - - dset = (H5D_t *)obj; - - /* Check arguments */ - if(NULL == dset->oloc.file) - HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "dataset is not associated with a file") - if(H5D_CHUNKED != dset->shared->layout.type) - HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a chunked dataset") - - /* Copy the user's offset array so we can be sure it's terminated properly. - * (we don't want to mess with the user's buffer). - */ - if(H5D__get_offset_copy(dset, offset, offset_copy) < 0) - HGOTO_ERROR(H5E_DATASET, H5E_CANTALLOC, FAIL, "failure to copy offset array") - - /* Read the raw chunk */ - if(H5D__chunk_direct_read(dset, offset_copy, filters, buf) < 0) - HGOTO_ERROR(H5E_DATASET, H5E_READERROR, FAIL, "can't read unprocessed chunk data") - - break; - } - - case H5VL_NATIVE_DATASET_CHUNK_WRITE: - { - uint32_t filters = HDva_arg(arguments, uint32_t); - const hsize_t *offset = HDva_arg(arguments, const hsize_t *); - uint32_t data_size_32 = HDva_arg(arguments, uint32_t); - const void *buf = HDva_arg(arguments, const void *); - hsize_t offset_copy[H5O_LAYOUT_NDIMS]; /* Internal copy of chunk offset */ - - dset = (H5D_t *)obj; - - /* Check arguments */ - if(NULL == dset->oloc.file) - HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "dataset is not associated with a file") - if(H5D_CHUNKED != dset->shared->layout.type) - HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a chunked dataset") - - /* Copy the user's offset array so we can be sure it's terminated properly. - * (we don't want to mess with the user's buffer). - */ - if(H5D__get_offset_copy(dset, offset, offset_copy) < 0) - HGOTO_ERROR(H5E_DATASET, H5E_CANTALLOC, FAIL, "failure to copy offset array") - - /* Write chunk */ - if(H5D__chunk_direct_write(dset, filters, offset_copy, data_size_32, buf) < 0) - HGOTO_ERROR(H5E_DATASET, H5E_WRITEERROR, FAIL, "can't write unprocessed chunk data") - - break; - } - - default: - HGOTO_ERROR(H5E_VOL, H5E_UNSUPPORTED, FAIL, "invalid optional operation") - } /* end switch */ - -done: - FUNC_LEAVE_NOAPI(ret_value) -} /* end H5VL__native_dataset_optional() */ - - -/*------------------------------------------------------------------------- - * Function: H5VL__native_dataset_close - * - * Purpose: Closes a dataset. - * - * Return: Success: SUCCEED - * Failure: FAIL (dataset will not be closed) - * - *------------------------------------------------------------------------- - */ -static herr_t -H5VL__native_dataset_close(void *dset, hid_t H5_ATTR_UNUSED dxpl_id, - void H5_ATTR_UNUSED **req) -{ - herr_t ret_value = SUCCEED; /* Return value */ - - FUNC_ENTER_STATIC - - if(H5D_close((H5D_t*)dset) < 0) - HGOTO_ERROR(H5E_DATASET, H5E_CANTDEC, FAIL, "can't close dataset") - -done: - FUNC_LEAVE_NOAPI(ret_value) -} /* end H5VL__native_dataset_close() */ - - -/*------------------------------------------------------------------------- - * Function: H5VL__native_file_create - * - * Purpose: Creates a file as a native HDF5 file. - * - * Return: Success: A pointer to an H5F_t file struct - * - * Failure: NULL - * - *------------------------------------------------------------------------- - */ -static void * -H5VL__native_file_create(const char *name, unsigned flags, hid_t fcpl_id, hid_t fapl_id, - hid_t H5_ATTR_UNUSED dxpl_id, void H5_ATTR_UNUSED **req) -{ - H5F_t *new_file = NULL; - void *ret_value = NULL; - - FUNC_ENTER_STATIC - - /* Adjust bit flags by turning on the creation bit and making sure that - * the EXCL or TRUNC bit is set. All newly-created files are opened for - * reading and writing. - */ - if(0 == (flags & (H5F_ACC_EXCL|H5F_ACC_TRUNC))) - flags |= H5F_ACC_EXCL; /*default*/ - flags |= H5F_ACC_RDWR | H5F_ACC_CREAT; - - /* Create the file */ - if(NULL == (new_file = H5F_open(name, flags, fcpl_id, fapl_id))) - HGOTO_ERROR(H5E_FILE, H5E_CANTOPENFILE, NULL, "unable to create file") - new_file->id_exists = TRUE; - - ret_value = (void *)new_file; - -done: - if(NULL == ret_value && new_file) - if(H5F__close(new_file) < 0) - HDONE_ERROR(H5E_FILE, H5E_CANTCLOSEFILE, NULL, "problems closing file") - - FUNC_LEAVE_NOAPI(ret_value) -} /* end H5VL__native_file_create() */ - - -/*------------------------------------------------------------------------- - * Function: H5VL__native_file_open - * - * Purpose: Opens a file as a native HDF5 file. - * - * Return: Success: A pointer to an H5F_t file struct - * - * Failure: NULL - * - *------------------------------------------------------------------------- - */ -static void * -H5VL__native_file_open(const char *name, unsigned flags, hid_t fapl_id, - hid_t H5_ATTR_UNUSED dxpl_id, void H5_ATTR_UNUSED **req) -{ - H5F_t *new_file = NULL; - void *ret_value = NULL; - - FUNC_ENTER_STATIC - - /* Open the file */ - if(NULL == (new_file = H5F_open(name, flags, H5P_FILE_CREATE_DEFAULT, fapl_id))) - HGOTO_ERROR(H5E_FILE, H5E_CANTOPENFILE, NULL, "unable to open file") - new_file->id_exists = TRUE; - - ret_value = (void *)new_file; - -done: - if(NULL == ret_value && new_file && H5F_try_close(new_file, NULL) < 0) - HDONE_ERROR(H5E_FILE, H5E_CANTCLOSEFILE, NULL, "problems closing file") - - FUNC_LEAVE_NOAPI(ret_value) -} /* end H5VL__native_file_open() */ - - -/*------------------------------------------------------------------------- - * Function: H5VL__native_file_get - * - * Purpose: Get info about a file - * - * Return: SUCCEED/FAIL - * - *------------------------------------------------------------------------- - */ -static herr_t -H5VL__native_file_get(void *obj, H5VL_file_get_t get_type, - hid_t H5_ATTR_UNUSED dxpl_id, void H5_ATTR_UNUSED **req, va_list arguments) -{ - H5F_t *f = NULL; /* File struct */ - herr_t ret_value = SUCCEED; /* Return value */ - - FUNC_ENTER_STATIC - - switch(get_type) { - /* H5Fget_access_plist */ - case H5VL_FILE_GET_FAPL: - { - H5P_genplist_t *new_plist; /* New property list */ - hid_t *plist_id = HDva_arg(arguments, hid_t *); - - f = (H5F_t *)obj; - - /* Retrieve the file's access property list */ - if((*plist_id = H5F_get_access_plist(f, TRUE)) < 0) - HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, FAIL, "can't get file access property list") - - if(NULL == (new_plist = (H5P_genplist_t *)H5I_object(*plist_id))) - HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a property list") - break; - } - - /* H5Fget_create_plist */ - case H5VL_FILE_GET_FCPL: - { - H5P_genplist_t *plist; /* Property list */ - hid_t *plist_id = HDva_arg(arguments, hid_t *); - - f = (H5F_t *)obj; - if(NULL == (plist = (H5P_genplist_t *)H5I_object(f->shared->fcpl_id))) - HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a property list") - - /* Create the property list object to return */ - if((*plist_id = H5P_copy_plist(plist, TRUE)) < 0) - HGOTO_ERROR(H5E_PLIST, H5E_CANTINIT, FAIL, "unable to copy file creation properties") - - break; - } - - /* H5Fget_obj_count */ - case H5VL_FILE_GET_OBJ_COUNT: - { - unsigned types = HDva_arg(arguments, unsigned); - ssize_t *ret = HDva_arg(arguments, ssize_t *); - size_t obj_count = 0; /* Number of opened objects */ - - f = (H5F_t *)obj; - /* Perform the query */ - if(H5F_get_obj_count(f, types, TRUE, &obj_count) < 0) - HGOTO_ERROR(H5E_FILE, H5E_BADITER, FAIL, "H5F_get_obj_count failed") - - /* Set the return value */ - *ret = (ssize_t)obj_count; - break; - } - - /* H5Fget_obj_ids */ - case H5VL_FILE_GET_OBJ_IDS: - { - unsigned types = HDva_arg(arguments, unsigned); - size_t max_objs = HDva_arg(arguments, size_t); - hid_t *oid_list = HDva_arg(arguments, hid_t *); - ssize_t *ret = HDva_arg(arguments, ssize_t *); - size_t obj_count = 0; /* Number of opened objects */ - - f = (H5F_t *)obj; - /* Perform the query */ - if(H5F_get_obj_ids(f, types, max_objs, oid_list, TRUE, &obj_count) < 0) - HGOTO_ERROR(H5E_FILE, H5E_BADITER, FAIL, "H5F_get_obj_ids failed") - - /* Set the return value */ - *ret = (ssize_t)obj_count; - break; - } - - /* H5Fget_intent */ - case H5VL_FILE_GET_INTENT: - { - unsigned *intent_flags = HDva_arg(arguments, unsigned *); - - f = (H5F_t *)obj; - - /* HDF5 uses some flags internally that users don't know about. - * Simplify things for them so that they only get either H5F_ACC_RDWR - * or H5F_ACC_RDONLY and any SWMR flags. - */ - if(H5F_INTENT(f) & H5F_ACC_RDWR) { - *intent_flags = H5F_ACC_RDWR; - - /* Check for SWMR write access on the file */ - if(H5F_INTENT(f) & H5F_ACC_SWMR_WRITE) - *intent_flags |= H5F_ACC_SWMR_WRITE; - } /* end if */ - else { - *intent_flags = H5F_ACC_RDONLY; - - /* Check for SWMR read access on the file */ - if(H5F_INTENT(f) & H5F_ACC_SWMR_READ) - *intent_flags |= H5F_ACC_SWMR_READ; - } /* end else */ - - break; - } - - /* H5Fget_name */ - case H5VL_FILE_GET_NAME: - { - H5I_type_t type = (H5I_type_t)HDva_arg(arguments, int); /* enum work-around */ - size_t size = HDva_arg(arguments, size_t); - char *name = HDva_arg(arguments, char *); - ssize_t *ret = HDva_arg(arguments, ssize_t *); - size_t len; - - if(NULL == (f = H5F__get_file(obj, type))) - HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a file or file object") - - len = HDstrlen(H5F_OPEN_NAME(f)); - - if(name) { - HDstrncpy(name, H5F_OPEN_NAME(f), MIN(len + 1,size)); - if(len >= size) - name[size-1]='\0'; - } /* end if */ - - /* Set the return value for the API call */ - *ret = (ssize_t)len; - break; - } - - default: - HGOTO_ERROR(H5E_VOL, H5E_CANTGET, FAIL, "can't get this type of information") - } /* end switch */ - -done: - FUNC_LEAVE_NOAPI(ret_value) -} /* end H5VL__native_file_get() */ - - -/*------------------------------------------------------------------------- - * Function: H5VL__native_file_specific - * - * Purpose: Specific operation on file - * - * Return: SUCCEED/FAIL - * - *------------------------------------------------------------------------- - */ -static herr_t -H5VL__native_file_specific(void *obj, H5VL_file_specific_t specific_type, - hid_t H5_ATTR_UNUSED dxpl_id, void H5_ATTR_UNUSED **req, va_list arguments) -{ - herr_t ret_value = SUCCEED; /* Return value */ - - FUNC_ENTER_STATIC - - switch(specific_type) { - /* H5Fflush */ - case H5VL_FILE_FLUSH: - { - H5I_type_t type = (H5I_type_t)HDva_arg(arguments, int); /* enum work-around */ - H5F_scope_t scope = (H5F_scope_t)HDva_arg(arguments, int); /* enum work-around */ - H5F_t *f = NULL; /* File to flush */ - - /* Get the file for the object */ - if(NULL == (f = H5F__get_file(obj, type))) - HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a file or file object") - - /* Nothing to do if the file is read only. This determination is - * made at the shared open(2) flags level, implying that opening a - * file twice, once for read-only and once for read-write, and then - * calling H5Fflush() with the read-only handle, still causes data - * to be flushed. - */ - if(H5F_ACC_RDWR & H5F_INTENT(f)) { - /* Flush other files, depending on scope */ - if(H5F_SCOPE_GLOBAL == scope) { - /* Call the flush routine for mounted file hierarchies */ - if(H5F_flush_mounts(f) < 0) - HGOTO_ERROR(H5E_FILE, H5E_CANTFLUSH, FAIL, "unable to flush mounted file hierarchy") - } /* end if */ - else { - /* Call the flush routine, for this file */ - if(H5F__flush(f) < 0) - HGOTO_ERROR(H5E_FILE, H5E_CANTFLUSH, FAIL, "unable to flush file's cached information") - } /* end else */ - } /* end if */ - break; - } - - /* H5Freopen */ - case H5VL_FILE_REOPEN: - { - void **ret = HDva_arg(arguments, void **); - H5F_t *new_file = NULL; - - /* Reopen the file through the VOL connector */ - if(NULL == (new_file = H5F__reopen((H5F_t *)obj))) - HGOTO_ERROR(H5E_FILE, H5E_CANTINIT, FAIL, "unable to reopen file") - new_file->id_exists = TRUE; - - *ret = (void *)new_file; - break; - } - - /* H5Fmount */ - case H5VL_FILE_MOUNT: - { - H5I_type_t type = (H5I_type_t)HDva_arg(arguments, int); /* enum work-around */ - const char *name = HDva_arg(arguments, const char *); - H5F_t *child = HDva_arg(arguments, H5F_t *); - hid_t plist_id = HDva_arg(arguments, hid_t); - H5G_loc_t loc; - - if(H5G_loc_real(obj, type, &loc) < 0) - HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a file or file object") - - /* Do the mount */ - if(H5F__mount(&loc, name, child, plist_id) < 0) - HGOTO_ERROR(H5E_FILE, H5E_MOUNT, FAIL, "unable to mount file") - - break; - } - - /* H5Funmount */ - case H5VL_FILE_UNMOUNT: - { - H5I_type_t type = (H5I_type_t)HDva_arg(arguments, int); /* enum work-around */ - const char *name = HDva_arg(arguments, const char *); - H5G_loc_t loc; - - if(H5G_loc_real(obj, type, &loc) < 0) - HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a file or file object") - - /* Unmount */ - if(H5F__unmount(&loc, name) < 0) - HGOTO_ERROR(H5E_FILE, H5E_MOUNT, FAIL, "unable to unmount file") - - break; - } - - /* H5Fis_accessible */ - case H5VL_FILE_IS_ACCESSIBLE: - { - hid_t fapl_id = HDva_arg(arguments, hid_t); - const char *name = HDva_arg(arguments, const char *); - htri_t *ret = HDva_arg(arguments, htri_t *); - - /* Call private routine */ - if((*ret = H5F__is_hdf5(name, fapl_id)) < 0) - HGOTO_ERROR(H5E_IO, H5E_CANTINIT, FAIL, "error in HDF5 file check") - break; - } - - default: - HGOTO_ERROR(H5E_VOL, H5E_UNSUPPORTED, FAIL, "invalid specific operation") - } /* end switch */ - -done: - FUNC_LEAVE_NOAPI(ret_value) -} /* end H5VL__native_file_specific() */ - - -/*------------------------------------------------------------------------- - * Function: H5VL__native_file_optional - * - * Purpose: Perform a connector-specific operation on a native file - * - * Return: SUCCEED/FAIL - * - *------------------------------------------------------------------------- - */ -static herr_t -H5VL__native_file_optional(void *obj, hid_t H5_ATTR_UNUSED dxpl_id, void H5_ATTR_UNUSED **req, va_list arguments) -{ - H5F_t *f = NULL; /* File */ - H5VL_native_file_optional_t optional_type = HDva_arg(arguments, H5VL_native_file_optional_t); - herr_t ret_value = SUCCEED; /* Return value */ - - FUNC_ENTER_STATIC - - f = (H5F_t *)obj; - switch(optional_type) { - /* H5Fget_filesize */ - case H5VL_NATIVE_FILE_GET_SIZE: - { - haddr_t max_eof_eoa; /* Maximum of the EOA & EOF */ - haddr_t base_addr; /* Base address for the file */ - hsize_t *size = HDva_arg(arguments, hsize_t *); - - /* Go get the actual file size */ - if(H5F__get_max_eof_eoa(f, &max_eof_eoa) < 0) - HGOTO_ERROR(H5E_FILE, H5E_CANTGET, FAIL, "file can't get max eof/eoa ") - - base_addr = H5FD_get_base_addr(f->shared->lf); - - if(size) - *size = (hsize_t)(max_eof_eoa + base_addr); /* Convert relative base address for file to absolute address */ - - break; - } - - /* H5Fget_file_image */ - case H5VL_NATIVE_FILE_GET_FILE_IMAGE: - { - void *buf_ptr = HDva_arg(arguments, void *); - ssize_t *ret = HDva_arg(arguments, ssize_t *); - size_t buf_len = HDva_arg(arguments, size_t ); - - /* Do the actual work */ - if((*ret = H5F__get_file_image(f, buf_ptr, buf_len)) < 0) - HGOTO_ERROR(H5E_FILE, H5E_CANTGET, FAIL, "get file image failed") - break; - } - - /* H5Fget_freespace */ - case H5VL_NATIVE_FILE_GET_FREE_SPACE: - { - hsize_t tot_space; /* Amount of free space in the file */ - hssize_t *ret = HDva_arg(arguments, hssize_t *); - - /* Go get the actual amount of free space in the file */ - if(H5MF_get_freespace(f, &tot_space, NULL) < 0) - HGOTO_ERROR(H5E_FILE, H5E_CANTGET, FAIL, "unable to check free space for file") - *ret = (hssize_t)tot_space; - break; - } - - /* H5Fget_free_sections */ - case H5VL_NATIVE_FILE_GET_FREE_SECTIONS: - { - H5F_sect_info_t *sect_info = HDva_arg(arguments, H5F_sect_info_t *); - ssize_t *ret = HDva_arg(arguments, ssize_t *); - H5F_mem_t type = (H5F_mem_t)HDva_arg(arguments, int); /* enum work-around */ - size_t nsects = HDva_arg(arguments, size_t); - - /* Go get the free-space section information in the file */ - if((*ret = H5MF_get_free_sections(f, type, nsects, sect_info)) < 0) - HGOTO_ERROR(H5E_FILE, H5E_CANTGET, FAIL, "unable to check free space for file") - break; - } - - /* H5Fget_info1/2 */ - case H5VL_NATIVE_FILE_GET_INFO: - { - H5I_type_t type = (H5I_type_t)HDva_arg(arguments, int); /* enum work-around */ - H5F_info2_t *finfo = HDva_arg(arguments, H5F_info2_t *); - - /* Get the file struct. This call is careful to not return the file pointer - * for the top file in a mount hierarchy. - */ - if(NULL == (f = H5F__get_file(obj, type))) - HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "could not get a file struct") - - /* Get the file info */ - if(H5F__get_info(f, finfo) < 0) - HGOTO_ERROR(H5E_FILE, H5E_CANTGET, FAIL, "unable to retrieve file info") - - break; - } - - /* H5Fget_mdc_config */ - case H5VL_NATIVE_FILE_GET_MDC_CONF: - { - H5AC_cache_config_t *config_ptr = HDva_arg(arguments, H5AC_cache_config_t *); - - /* Go get the resize configuration */ - if(H5AC_get_cache_auto_resize_config(f->shared->cache, config_ptr) < 0) - HGOTO_ERROR(H5E_CACHE, H5E_SYSTEM, FAIL, "H5AC_get_cache_auto_resize_config() failed.") - break; - } - - /* H5Fget_mdc_hit_rate */ - case H5VL_NATIVE_FILE_GET_MDC_HR: - { - double *hit_rate_ptr = HDva_arg(arguments, double *); - - /* Go get the current hit rate */ - if(H5AC_get_cache_hit_rate(f->shared->cache, hit_rate_ptr) < 0) - HGOTO_ERROR(H5E_CACHE, H5E_SYSTEM, FAIL, "H5AC_get_cache_hit_rate() failed.") - break; - } - - /* H5Fget_mdc_size */ - case H5VL_NATIVE_FILE_GET_MDC_SIZE: - { - size_t *max_size_ptr = HDva_arg(arguments, size_t *); - size_t *min_clean_size_ptr = HDva_arg(arguments, size_t *); - size_t *cur_size_ptr = HDva_arg(arguments, size_t *); - int *cur_num_entries_ptr = HDva_arg(arguments, int *); - uint32_t cur_num_entries; - - /* Go get the size data */ - if(H5AC_get_cache_size(f->shared->cache, max_size_ptr, min_clean_size_ptr, - cur_size_ptr, &cur_num_entries) < 0) - HGOTO_ERROR(H5E_CACHE, H5E_SYSTEM, FAIL, "H5AC_get_cache_size() failed.") - - if(cur_num_entries_ptr != NULL) - *cur_num_entries_ptr = (int)cur_num_entries; - break; - } - - /* H5Fget_vfd_handle */ - case H5VL_NATIVE_FILE_GET_VFD_HANDLE: - { - void **file_handle = HDva_arg(arguments, void **); - hid_t fapl_id = HDva_arg(arguments, hid_t); - - /* Retrieve the VFD handle for the file */ - if(H5F_get_vfd_handle(f, fapl_id, file_handle) < 0) - HGOTO_ERROR(H5E_FILE, H5E_CANTGET, FAIL, "can't retrieve VFD handle") - break; - } - - /* H5Iget_file_id */ - case H5VL_NATIVE_FILE_GET_FILE_ID: - { - H5I_type_t type = (H5I_type_t)HDva_arg(arguments, int); /* enum work-around */ - hid_t *file_id = HDva_arg(arguments, hid_t *); - - if(NULL == (f = H5F__get_file(obj, type))) - HGOTO_ERROR(H5E_FILE, H5E_BADTYPE, FAIL, "not a file or file object") - if((*file_id = H5F__get_file_id(f)) < 0) - HGOTO_ERROR(H5E_FILE, H5E_CANTGET, FAIL, "can't get file ID") - break; - } - - /* H5Fclear_elink_file_cache */ - case H5VL_NATIVE_FILE_CLEAR_ELINK_CACHE: - { - /* Release the EFC */ - if(f->shared->efc) - if(H5F__efc_release(f->shared->efc) < 0) - HGOTO_ERROR(H5E_FILE, H5E_CANTRELEASE, FAIL, "can't release external file cache") - break; - } - - /* H5Freset_mdc_hit_rate_stats */ - case H5VL_NATIVE_FILE_RESET_MDC_HIT_RATE: - { - /* Reset the hit rate statistic */ - if(H5AC_reset_cache_hit_rate_stats(f->shared->cache) < 0) - HGOTO_ERROR(H5E_CACHE, H5E_SYSTEM, FAIL, "can't reset cache hit rate") - break; - } - - /* H5Fset_mdc_config */ - case H5VL_NATIVE_FILE_SET_MDC_CONFIG: - { - H5AC_cache_config_t *config_ptr = HDva_arg(arguments, H5AC_cache_config_t *); - - /* set the resize configuration */ - if(H5AC_set_cache_auto_resize_config(f->shared->cache, config_ptr) < 0) - HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "H5AC_set_cache_auto_resize_config() failed") - break; - } - - /* H5Fget_metadata_read_retry_info */ - case H5VL_NATIVE_FILE_GET_METADATA_READ_RETRY_INFO: - { - H5F_retry_info_t *info = HDva_arg(arguments, H5F_retry_info_t *); - - if(H5F_get_metadata_read_retry_info(f, info) < 0) - HGOTO_ERROR(H5E_CACHE, H5E_SYSTEM, FAIL, "can't get metadata read retry info") - - break; - } - - /* H5Fstart_swmr_write */ - case H5VL_NATIVE_FILE_START_SWMR_WRITE: - { - if(H5F__start_swmr_write(f) < 0) - HGOTO_ERROR(H5E_CACHE, H5E_SYSTEM, FAIL, "can't start SWMR write") - - break; - } - - /* H5Fstart_mdc_logging */ - case H5VL_NATIVE_FILE_START_MDC_LOGGING: - { - /* Call mdc logging function */ - if(H5C_start_logging(f->shared->cache) < 0) - HGOTO_ERROR(H5E_FILE, H5E_LOGFAIL, FAIL, "unable to start mdc logging") - - break; - } - - /* H5Fstop_mdc_logging */ - case H5VL_NATIVE_FILE_STOP_MDC_LOGGING: - { - /* Call mdc logging function */ - if(H5C_stop_logging(f->shared->cache) < 0) - HGOTO_ERROR(H5E_FILE, H5E_LOGFAIL, FAIL, "unable to stop mdc logging") - - break; - } - - /* H5Fget_mdc_logging_status */ - case H5VL_NATIVE_FILE_GET_MDC_LOGGING_STATUS: - { - hbool_t *is_enabled = HDva_arg(arguments, hbool_t *); - hbool_t *is_currently_logging = HDva_arg(arguments, hbool_t *); - - /* Call mdc logging function */ - if(H5C_get_logging_status(f->shared->cache, is_enabled, is_currently_logging) < 0) - HGOTO_ERROR(H5E_FILE, H5E_LOGFAIL, FAIL, "unable to get logging status") - - break; - } - - /* H5Fformat_convert */ - case H5VL_NATIVE_FILE_FORMAT_CONVERT: - { - /* Convert the format */ - if(H5F__format_convert(f) < 0) - HGOTO_ERROR(H5E_FILE, H5E_CANTCONVERT, FAIL, "can't convert file format") - - break; - } - - /* H5Freset_page_buffering_stats */ - case H5VL_NATIVE_FILE_RESET_PAGE_BUFFERING_STATS: - { - /* Sanity check */ - if(NULL == f->shared->page_buf) - HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "page buffering not enabled on file") - - /* Reset the statistics */ - if (H5PB_reset_stats(f->shared->page_buf) < 0) - HGOTO_ERROR(H5E_FILE, H5E_CANTGET, FAIL, "can't reset stats for page buffering") - - break; - } - - /* H5Fget_page_buffering_stats */ - case H5VL_NATIVE_FILE_GET_PAGE_BUFFERING_STATS: - { - unsigned *accesses = HDva_arg(arguments, unsigned *); - unsigned *hits = HDva_arg(arguments, unsigned *); - unsigned *misses = HDva_arg(arguments, unsigned *); - unsigned *evictions = HDva_arg(arguments, unsigned *); - unsigned *bypasses = HDva_arg(arguments, unsigned *); - - /* Sanity check */ - if(NULL == f->shared->page_buf) - HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "page buffering not enabled on file") - - /* Get the statistics */ - if(H5PB_get_stats(f->shared->page_buf, accesses, hits, misses, evictions, bypasses) < 0) - HGOTO_ERROR(H5E_FILE, H5E_CANTGET, FAIL, "can't retrieve stats for page buffering") - - break; - } - - /* H5Fget_mdc_image_info */ - case H5VL_NATIVE_FILE_GET_MDC_IMAGE_INFO: - { - haddr_t *image_addr = HDva_arg(arguments, haddr_t *); - hsize_t *image_len = HDva_arg(arguments, hsize_t *); - - /* Go get the address and size of the cache image */ - if(H5AC_get_mdc_image_info(f->shared->cache, image_addr, image_len) < 0) - HGOTO_ERROR(H5E_FILE, H5E_CANTGET, FAIL, "can't retrieve cache image info") - - break; - } - - /* H5Fget_eoa */ - case H5VL_NATIVE_FILE_GET_EOA: - { - haddr_t *eoa = HDva_arg(arguments, haddr_t *); - haddr_t rel_eoa; /* Relative address of EOA */ - - /* Sanity check */ - HDassert(eoa); - - /* This routine will work only for drivers with this feature enabled.*/ - /* We might introduce a new feature flag in the future */ - if(!H5F_HAS_FEATURE(f, H5FD_FEAT_SUPPORTS_SWMR_IO)) - HGOTO_ERROR(H5E_FILE, H5E_BADVALUE, FAIL, "must use a SWMR-compatible VFD for this public routine") - - /* The real work */ - if(HADDR_UNDEF == (rel_eoa = H5F_get_eoa(f, H5FD_MEM_DEFAULT))) - HGOTO_ERROR(H5E_FILE, H5E_CANTGET, FAIL, "get_eoa request failed") - - /* Set return value */ - /* (Note compensating for base address subtraction in internal routine) */ - *eoa = rel_eoa + H5F_get_base_addr(f); - - break; - } - - /* H5Fincrement_filesize */ - case H5VL_NATIVE_FILE_INCR_FILESIZE: - { - hsize_t increment = HDva_arg(arguments, hsize_t); - haddr_t max_eof_eoa; /* Maximum of the relative EOA & EOF */ - - /* This public routine will work only for drivers with this feature enabled.*/ - /* We might introduce a new feature flag in the future */ - if(!H5F_HAS_FEATURE(f, H5FD_FEAT_SUPPORTS_SWMR_IO)) - HGOTO_ERROR(H5E_FILE, H5E_BADVALUE, FAIL, "must use a SWMR-compatible VFD for this public routine") - - /* Get the maximum of EOA and EOF */ - if(H5F__get_max_eof_eoa(f, &max_eof_eoa) < 0) - HGOTO_ERROR(H5E_FILE, H5E_CANTGET, FAIL, "file can't get max eof/eoa ") - - /* Set EOA to the maximum value + increment */ - if(H5F__set_eoa(f, H5FD_MEM_DEFAULT, max_eof_eoa + increment) < 0) - HGOTO_ERROR(H5E_FILE, H5E_CANTSET, FAIL, "driver set_eoa request failed") - - break; - } - - /* H5Fset_latest_format, H5Fset_libver_bounds */ - case H5VL_NATIVE_FILE_SET_LIBVER_BOUNDS: - { - H5F_libver_t low = (H5F_libver_t)HDva_arg(arguments, int); /* enum work-around */ - H5F_libver_t high = (H5F_libver_t)HDva_arg(arguments, int); /* enum work-around */ - - /* Call internal set_libver_bounds function */ - if(H5F__set_libver_bounds(f, low, high) < 0) - HGOTO_ERROR(H5E_FILE, H5E_CANTSET, FAIL, "cannot set low/high bounds") - - break; - } - - default: - HGOTO_ERROR(H5E_VOL, H5E_UNSUPPORTED, FAIL, "invalid optional operation") - } /* end switch */ - -done: - FUNC_LEAVE_NOAPI(ret_value) -} /* end H5VL__native_file_optional() */ - - -/*------------------------------------------------------------------------- - * Function: H5VL__native_file_close - * - * Purpose: Closes a file. - * - * Return: SUCCEED/FAIL (the file will not be closed on failure) - * - *------------------------------------------------------------------------- - */ -static herr_t -H5VL__native_file_close(void *file, hid_t H5_ATTR_UNUSED dxpl_id, - void H5_ATTR_UNUSED **req) -{ - int nref; - H5F_t *f = (H5F_t *)file; - hid_t file_id = H5I_INVALID_HID; - herr_t ret_value = SUCCEED; /* Return value */ - - FUNC_ENTER_STATIC - - /* This routine should only be called when a file ID's ref count drops to zero */ - HDassert(H5F_ID_EXISTS(f)); - - /* Flush file if this is the last reference to this id and we have write - * intent, unless it will be flushed by the "shared" file being closed. - * This is only necessary to replicate previous behaviour, and could be - * disabled by an option/property to improve performance. - */ - if((H5F_NREFS(f) > 1) && (H5F_INTENT(f) & H5F_ACC_RDWR)) { - /* Get the file ID corresponding to the H5F_t struct */ - if(H5I_find_id(f, H5I_FILE, &file_id) < 0 || H5I_INVALID_HID == file_id) - HGOTO_ERROR(H5E_ATOM, H5E_CANTGET, FAIL, "invalid atom") - - /* Get the number of references outstanding for this file ID */ - if((nref = H5I_get_ref(file_id, FALSE)) < 0) - HGOTO_ERROR(H5E_ATOM, H5E_CANTGET, FAIL, "can't get ID ref count") - if(nref == 1) - if(H5F__flush(f) < 0) - HGOTO_ERROR(H5E_CACHE, H5E_CANTFLUSH, FAIL, "unable to flush cache") - } /* end if */ - - /* Close the file */ - if(H5F__close(f) < 0) - HGOTO_ERROR(H5E_FILE, H5E_CANTDEC, FAIL, "can't close file") - -done: - FUNC_LEAVE_NOAPI(ret_value) -} /* end H5VL__native_file_close() */ - - -/*------------------------------------------------------------------------- - * Function: H5VL__native_group_create - * - * Purpose: Creates a group inside a native h5 file. - * - * Return: Success: Pointer to a group struct - * - * Failure: NULL - * - *------------------------------------------------------------------------- - */ -static void * -H5VL__native_group_create(void *obj, const H5VL_loc_params_t *loc_params, const char *name, - hid_t gcpl_id, hid_t H5_ATTR_UNUSED gapl_id, hid_t H5_ATTR_UNUSED dxpl_id, - void H5_ATTR_UNUSED **req) -{ - H5P_genplist_t *plist; /* Property list pointer */ - H5G_loc_t loc; /* Location to create group */ - H5G_t *grp = NULL; /* New group created */ - hid_t lcpl_id; - void *ret_value; - - FUNC_ENTER_STATIC - - /* Get the property list structure */ - if(NULL == (plist = (H5P_genplist_t *)H5I_object(gcpl_id))) - HGOTO_ERROR(H5E_ATOM, H5E_BADATOM, NULL, "can't find object for ID") - - /* Get creation properties */ - if(H5P_get(plist, H5VL_PROP_GRP_LCPL_ID, &lcpl_id) < 0) - HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, NULL, "can't get property value for lcpl id") - - /* Set up the location */ - if(H5G_loc_real(obj, loc_params->obj_type, &loc) < 0) - HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, NULL, "not a file or file object") - - /* if name is NULL then this is from H5Gcreate_anon */ - if(name == NULL) { - H5G_obj_create_t gcrt_info; /* Information for group creation */ - - /* Set up group creation info */ - gcrt_info.gcpl_id = gcpl_id; - gcrt_info.cache_type = H5G_NOTHING_CACHED; - HDmemset(&gcrt_info.cache, 0, sizeof(gcrt_info.cache)); - - /* Create the new group & get its ID */ - if(NULL == (grp = H5G__create(loc.oloc->file, &gcrt_info))) - HGOTO_ERROR(H5E_SYM, H5E_CANTINIT, NULL, "unable to create group") - } /* end if */ - /* otherwise it's from H5Gcreate */ - else { - /* Create the new group & get its ID */ - if(NULL == (grp = H5G__create_named(&loc, name, lcpl_id, gcpl_id))) - HGOTO_ERROR(H5E_SYM, H5E_CANTINIT, NULL, "unable to create group") - } /* end else */ - - ret_value = (void *)grp; - -done: - if(name == NULL) { - /* Release the group's object header, if it was created */ - if(grp) { - H5O_loc_t *oloc; /* Object location for group */ - - /* Get the new group's object location */ - if(NULL == (oloc = H5G_oloc(grp))) - HDONE_ERROR(H5E_SYM, H5E_CANTGET, NULL, "unable to get object location of group") - - /* Decrement refcount on group's object header in memory */ - if(H5O_dec_rc_by_loc(oloc) < 0) - HDONE_ERROR(H5E_SYM, H5E_CANTDEC, NULL, "unable to decrement refcount on newly created object") - } /* end if */ - } /* end if */ - - FUNC_LEAVE_NOAPI(ret_value) -} /* end H5VL__native_group_create() */ - - -/*------------------------------------------------------------------------- - * Function: H5VL__native_group_open - * - * Purpose: Opens a group inside a native h5 file. - * - * Return: Success: Pointer to a group struct - * - * Failure: NULL - * - *------------------------------------------------------------------------- - */ -static void * -H5VL__native_group_open(void *obj, const H5VL_loc_params_t *loc_params, const char *name, - hid_t H5_ATTR_UNUSED gapl_id, hid_t H5_ATTR_UNUSED dxpl_id, void H5_ATTR_UNUSED **req) -{ - H5G_loc_t loc; /* Location to open group */ - H5G_t *grp = NULL; /* New group opend */ - void *ret_value; - - FUNC_ENTER_STATIC - - /* Set up the location */ - if(H5G_loc_real(obj, loc_params->obj_type, &loc) < 0) - HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, NULL, "not a file or file object") - - /* Open the group */ - if((grp = H5G__open_name(&loc, name)) == NULL) - HGOTO_ERROR(H5E_SYM, H5E_CANTOPENOBJ, NULL, "unable to open group") - - ret_value = (void *)grp; - -done: - FUNC_LEAVE_NOAPI(ret_value) -} /* end H5VL__native_group_open() */ - - -/*------------------------------------------------------------------------- - * Function: H5VL__native_group_get - * - * Purpose: Get info about a group - * - * Return: SUCCEED/FAIL - * - *------------------------------------------------------------------------- - */ -static herr_t -H5VL__native_group_get(void *obj, H5VL_group_get_t get_type, - hid_t H5_ATTR_UNUSED dxpl_id, void H5_ATTR_UNUSED **req, va_list arguments) -{ - herr_t ret_value = SUCCEED; /* Return value */ - - FUNC_ENTER_STATIC - - switch(get_type) { - /* H5Gget_create_plist */ - case H5VL_GROUP_GET_GCPL: - { - hid_t *new_gcpl_id = HDva_arg(arguments, hid_t *); - H5G_t *grp = (H5G_t *)obj; - - if((*new_gcpl_id = H5G_get_create_plist(grp)) < 0) - HGOTO_ERROR(H5E_ARGS, H5E_CANTGET, FAIL, "can't get creation property list for group") - break; - } - - /* H5Gget_info */ - case H5VL_GROUP_GET_INFO: - { - const H5VL_loc_params_t *loc_params = HDva_arg(arguments, const H5VL_loc_params_t *); - H5G_info_t *group_info = HDva_arg(arguments, H5G_info_t *); - H5G_loc_t loc; - - if(H5G_loc_real(obj, loc_params->obj_type, &loc) < 0) - HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a file or file object") - - if(loc_params->type == H5VL_OBJECT_BY_SELF) { - /* H5Gget_info */ - - /* Retrieve the group's information */ - if(H5G__obj_info(loc.oloc, group_info) < 0) - HGOTO_ERROR(H5E_SYM, H5E_CANTGET, FAIL, "can't retrieve group info") - } /* end if */ - else if(loc_params->type == H5VL_OBJECT_BY_NAME) { - /* H5Gget_info_by_name */ - - /* Retrieve the group's information */ - if(H5G__get_info_by_name(&loc, loc_params->loc_data.loc_by_name.name, group_info) < 0) - HGOTO_ERROR(H5E_SYM, H5E_CANTGET, FAIL, "can't retrieve group info") - } /* end else-if */ - else if(loc_params->type == H5VL_OBJECT_BY_IDX) { - /* H5Gget_info_by_idx */ - - /* Retrieve the group's information */ - if(H5G__get_info_by_idx(&loc, loc_params->loc_data.loc_by_idx.name, loc_params->loc_data.loc_by_idx.idx_type, - loc_params->loc_data.loc_by_idx.order, loc_params->loc_data.loc_by_idx.n, group_info) < 0) - HGOTO_ERROR(H5E_SYM, H5E_CANTGET, FAIL, "can't retrieve group info") - } /* end else-if */ - else - HGOTO_ERROR(H5E_VOL, H5E_UNSUPPORTED, FAIL, "unknown get info parameters") - break; - } - - default: - HGOTO_ERROR(H5E_VOL, H5E_CANTGET, FAIL, "can't get this type of information from group") - } /* end switch */ - -done: - FUNC_LEAVE_NOAPI(ret_value) -} /* end H5VL__native_group_get() */ - - -/*------------------------------------------------------------------------- - * Function: H5VL__native_group_specific - * - * Purpose: Specific operations for groups - * - * Return: SUCCEED/FAIL - * - *------------------------------------------------------------------------- - */ -static herr_t -H5VL__native_group_specific(void *obj, H5VL_group_specific_t specific_type, - hid_t H5_ATTR_UNUSED dxpl_id, void H5_ATTR_UNUSED **req, va_list arguments) -{ - H5G_t *grp = (H5G_t *)obj; - herr_t ret_value = SUCCEED; /* Return value */ - - FUNC_ENTER_STATIC - - switch(specific_type) { - case H5VL_GROUP_FLUSH: - { - hid_t group_id = HDva_arg(arguments, hid_t); - - /* Flush object's metadata to file */ - if(H5O_flush_common(&grp->oloc, group_id) < 0) - HGOTO_ERROR(H5E_SYM, H5E_CANTFLUSH, FAIL, "unable to flush group") - - break; - } - - case H5VL_GROUP_REFRESH: - { - hid_t group_id = HDva_arg(arguments, hid_t); - - /* Call private function to refresh group object */ - if((H5O_refresh_metadata(group_id, grp->oloc)) < 0) - HGOTO_ERROR(H5E_SYM, H5E_CANTLOAD, FAIL, "unable to refresh group") - - break; - } - - default: - HGOTO_ERROR(H5E_VOL, H5E_UNSUPPORTED, FAIL, "invalid specific operation") - } /* end switch */ - -done: - FUNC_LEAVE_NOAPI(ret_value) -} /* end H5VL__native_group_specific() */ - - -/*------------------------------------------------------------------------- - * Function: H5VL__native_group_optional - * - * Purpose: Perform a connector-specific operation on a native group - * - * Return: SUCCEED/FAIL - * - *------------------------------------------------------------------------- - */ -static herr_t -H5VL__native_group_optional(void *obj, hid_t H5_ATTR_UNUSED dxpl_id, - void H5_ATTR_UNUSED **req, va_list arguments) -{ - H5VL_native_group_optional_t optional_type; - herr_t ret_value = SUCCEED; /* Return value */ - - FUNC_ENTER_STATIC - - optional_type = HDva_arg(arguments, H5VL_native_group_optional_t); - switch(optional_type) { -#ifndef H5_NO_DEPRECATED_SYMBOLS - /* H5Giterate (deprecated) */ - case H5VL_NATIVE_GROUP_ITERATE_OLD: - { - const H5VL_loc_params_t *loc_params = HDva_arg(arguments, const H5VL_loc_params_t *); - hsize_t idx = HDva_arg(arguments, hsize_t); - hsize_t *last_obj = HDva_arg(arguments, hsize_t *); - const H5G_link_iterate_t *lnk_op = HDva_arg(arguments, const H5G_link_iterate_t *); - void *op_data = HDva_arg(arguments, void *); - H5G_loc_t grp_loc; - - /* Get the location struct for the object */ - if(H5G_loc_real(obj, loc_params->obj_type, &grp_loc) < 0) - HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a file or file object") - - /* Call the actual iteration routine */ - if((ret_value = H5G_iterate(&grp_loc, loc_params->loc_data.loc_by_name.name, H5_INDEX_NAME, H5_ITER_INC, idx, last_obj, lnk_op, op_data)) < 0) - HERROR(H5E_VOL, H5E_BADITER, "error iterating over group's links"); - - break; - } - - /* H5Gget_objinfo (deprecated) */ - case H5VL_NATIVE_GROUP_GET_OBJINFO: - { - const H5VL_loc_params_t *loc_params = HDva_arg(arguments, const H5VL_loc_params_t *); - hbool_t follow_link = (hbool_t)HDva_arg(arguments, unsigned); - H5G_stat_t *statbuf = HDva_arg(arguments, H5G_stat_t *); - H5G_loc_t grp_loc; - - /* Get the location struct for the object */ - if(H5G_loc_real(obj, loc_params->obj_type, &grp_loc) < 0) - HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a file or file object") - - /* Call the actual group objinfo routine */ - if(H5G__get_objinfo(&grp_loc, loc_params->loc_data.loc_by_name.name, follow_link, statbuf) < 0) - HGOTO_ERROR(H5E_SYM, H5E_CANTGET, FAIL, "cannot stat object") - - break; - } -#endif /* H5_NO_DEPRECATED_SYMBOLS */ - - default: - HGOTO_ERROR(H5E_VOL, H5E_UNSUPPORTED, FAIL, "invalid optional operation") - } /* end switch */ - -done: - FUNC_LEAVE_NOAPI(ret_value) -} /* end H5VL__native_group_optional() */ - - -/*------------------------------------------------------------------------- - * Function: H5VL__native_group_close - * - * Purpose: Closes a group. - * - * Return: SUCCEED/FAIL (the group will not be closed on failure) - * - *------------------------------------------------------------------------- - */ -static herr_t -H5VL__native_group_close(void *grp, hid_t H5_ATTR_UNUSED dxpl_id, void H5_ATTR_UNUSED **req) -{ - herr_t ret_value = SUCCEED; /* Return value */ - - FUNC_ENTER_STATIC - - 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, - const H5VL_loc_params_t *loc_params, hid_t lcpl_id, hid_t H5_ATTR_UNUSED lapl_id, - hid_t H5_ATTR_UNUSED dxpl_id, void H5_ATTR_UNUSED **req) -{ - H5P_genplist_t *plist; /* Property list pointer */ - herr_t ret_value = SUCCEED; /* Return value */ - - FUNC_ENTER_STATIC - - /* Get the plist structure */ - if(NULL == (plist = (H5P_genplist_t *)H5I_object(lcpl_id))) - HGOTO_ERROR(H5E_ATOM, H5E_BADATOM, FAIL, "can't find object for ID"); - - switch(create_type) { - case H5VL_LINK_CREATE_HARD: - { - H5G_loc_t cur_loc; - H5G_loc_t link_loc; - void *cur_obj; - H5VL_loc_params_t cur_params; - - if(H5P_get(plist, H5VL_PROP_LINK_TARGET, &cur_obj) < 0) - HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, FAIL, "can't get property value for current location id") - if(H5P_get(plist, H5VL_PROP_LINK_TARGET_LOC_PARAMS, &cur_params) < 0) - HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, FAIL, "can't get property value for current name") - - if(NULL != cur_obj && H5G_loc_real(cur_obj, cur_params.obj_type, &cur_loc) < 0) - HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a file or file object") - if(NULL != obj && H5G_loc_real(obj, loc_params->obj_type, &link_loc) < 0) - HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a file or file object") - - /* H5Lcreate_hard */ - if(H5VL_OBJECT_BY_NAME == cur_params.type) { - H5G_loc_t *cur_loc_p, *link_loc_p; - - /* Set up current & new location pointers */ - cur_loc_p = &cur_loc; - link_loc_p = &link_loc; - if(NULL == cur_obj) - cur_loc_p = link_loc_p; - else if(NULL == obj) - link_loc_p = cur_loc_p; - else if(cur_loc_p->oloc->file != link_loc_p->oloc->file) - HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "source and destination should be in the same file.") - - /* Create the link */ - if((ret_value = H5L_create_hard(cur_loc_p, cur_params.loc_data.loc_by_name.name, - link_loc_p, loc_params->loc_data.loc_by_name.name, lcpl_id)) < 0) - HGOTO_ERROR(H5E_LINK, H5E_CANTINIT, FAIL, "unable to create link") - } /* end if */ - else { /* H5Olink */ - /* Link to the object */ - if(H5L_link(&link_loc, loc_params->loc_data.loc_by_name.name, &cur_loc, lcpl_id) < 0) - HGOTO_ERROR(H5E_OHDR, H5E_CANTINIT, FAIL, "unable to create link") - } /* end else */ - break; - } - - case H5VL_LINK_CREATE_SOFT: - { - char *target_name; - H5G_loc_t link_loc; /* Group location for new link */ - - if(H5G_loc_real(obj, loc_params->obj_type, &link_loc) < 0) - HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a file or file object") - - if(H5P_get(plist, H5VL_PROP_LINK_TARGET_NAME, &target_name) < 0) - HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, FAIL, "can't get property value for targe name") - - /* Create the link */ - if((ret_value = H5L_create_soft(target_name, &link_loc, loc_params->loc_data.loc_by_name.name, lcpl_id)) < 0) - HGOTO_ERROR(H5E_LINK, H5E_CANTINIT, FAIL, "unable to create link") - break; - } - - case H5VL_LINK_CREATE_UD: - { - H5G_loc_t link_loc; /* Group location for new link */ - H5L_type_t link_type; - void *udata; - size_t udata_size; - - if(H5G_loc_real(obj, loc_params->obj_type, &link_loc) < 0) - HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a file or file object") - - if(H5P_get(plist, H5VL_PROP_LINK_TYPE, &link_type) < 0) - HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, FAIL, "can't get property value for link type") - if(H5P_get(plist, H5VL_PROP_LINK_UDATA, &udata) < 0) - HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, FAIL, "can't get property value for udata") - if(H5P_get(plist, H5VL_PROP_LINK_UDATA_SIZE, &udata_size) < 0) - HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, FAIL, "can't get property value for udata size") - - /* Create link */ - if(H5L__create_ud(&link_loc, loc_params->loc_data.loc_by_name.name, udata, udata_size, - link_type, lcpl_id) < 0) - HGOTO_ERROR(H5E_LINK, H5E_CANTINIT, FAIL, "unable to create link") - break; - } - - default: - HGOTO_ERROR(H5E_LINK, H5E_CANTINIT, FAIL, "invalid link creation call") - } /* end switch */ - -done: - FUNC_LEAVE_NOAPI(ret_value) -} /* end H5VL__native_link_create() */ - - -/*------------------------------------------------------------------------- - * Function: H5VL__native_link_copy - * - * Purpose: 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, const H5VL_loc_params_t *loc_params1, - void *dst_obj, const H5VL_loc_params_t *loc_params2, hid_t lcpl_id, - hid_t H5_ATTR_UNUSED lapl_id, hid_t H5_ATTR_UNUSED dxpl_id, - void H5_ATTR_UNUSED **req) -{ - H5G_loc_t src_loc, *src_loc_p; - H5G_loc_t dst_loc, *dst_loc_p; - herr_t ret_value = SUCCEED; /* Return value */ - - FUNC_ENTER_STATIC - - if(NULL != src_obj && H5G_loc_real(src_obj, loc_params1->obj_type, &src_loc) < 0) - HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a file or file object") - if(NULL != dst_obj && H5G_loc_real(dst_obj, loc_params2->obj_type, &dst_loc) < 0) - HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a file or file object") - - /* Set up src & dst location pointers */ - src_loc_p = &src_loc; - dst_loc_p = &dst_loc; - if(NULL == src_obj) - src_loc_p = dst_loc_p; - else if(NULL == dst_obj) - dst_loc_p = src_loc_p; - - /* Copy the link */ - if(H5L_move(src_loc_p, loc_params1->loc_data.loc_by_name.name, - dst_loc_p, loc_params2->loc_data.loc_by_name.name, - TRUE, lcpl_id) < 0) - HGOTO_ERROR(H5E_LINK, H5E_CANTCOPY, FAIL, "unable to copy link") - -done: - FUNC_LEAVE_NOAPI(ret_value) -} /* end H5VL__native_link_copy() */ - - -/*------------------------------------------------------------------------- - * Function: H5VL__native_link_move - * - * Purpose: Renames an object within an HDF5 file and moves it to a new - * group. The original name SRC is unlinked from the group graph - * and then inserted with the new name DST (which can specify a - * new path for the object) as an atomic operation. The names - * are interpreted relative to SRC_LOC_ID and - * DST_LOC_ID, which are either file IDs or group ID. - * - * Return: Non-negative on success/Negative on failure - * - * Programmer: Mohamad Chaarawi - * April, 2012 - * - *------------------------------------------------------------------------- - */ -static herr_t -H5VL__native_link_move(void *src_obj, const H5VL_loc_params_t *loc_params1, - void *dst_obj, const H5VL_loc_params_t *loc_params2, hid_t lcpl_id, - hid_t H5_ATTR_UNUSED lapl_id, hid_t H5_ATTR_UNUSED dxpl_id, - void H5_ATTR_UNUSED **req) -{ - H5G_loc_t src_loc, *src_loc_p; - H5G_loc_t dst_loc, *dst_loc_p; - herr_t ret_value = SUCCEED; /* Return value */ - - FUNC_ENTER_STATIC - - if(NULL != src_obj && H5G_loc_real(src_obj, loc_params1->obj_type, &src_loc) < 0) - HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a file or file object") - if(NULL != dst_obj && H5G_loc_real(dst_obj, loc_params2->obj_type, &dst_loc) < 0) - HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a file or file object") - - /* Set up src & dst location pointers */ - src_loc_p = &src_loc; - dst_loc_p = &dst_loc; - if(NULL == src_obj) - src_loc_p = dst_loc_p; - else if(NULL == dst_obj) - dst_loc_p = src_loc_p; - - /* Move the link */ - if(H5L_move(src_loc_p, loc_params1->loc_data.loc_by_name.name, - dst_loc_p, loc_params2->loc_data.loc_by_name.name, - FALSE, lcpl_id) < 0) - HGOTO_ERROR(H5E_LINK, H5E_CANTMOVE, FAIL, "unable to move link") - -done: - FUNC_LEAVE_NOAPI(ret_value) -} /* end H5VL__native_link_move() */ - - -/*------------------------------------------------------------------------- - * Function: H5VL__native_link_get - * - * Purpose: Get info about a link - * - * Return: Success: 0 - * Failure: -1 - * - * Programmer: Mohamad Chaarawi - * April, 2012 - * - *------------------------------------------------------------------------- - */ -static herr_t -H5VL__native_link_get(void *obj, const H5VL_loc_params_t *loc_params, H5VL_link_get_t get_type, - hid_t H5_ATTR_UNUSED dxpl_id, void H5_ATTR_UNUSED **req, va_list arguments) -{ - H5G_loc_t loc; - herr_t ret_value = SUCCEED; /* Return value */ - - FUNC_ENTER_STATIC - - if(H5G_loc_real(obj, loc_params->obj_type, &loc) < 0) - HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a file or file object") - - switch(get_type) { - /* H5Lget_info/H5Lget_info_by_idx */ - case H5VL_LINK_GET_INFO: - { - H5L_info_t *linfo = HDva_arg(arguments, H5L_info_t *); - - /* Get the link information */ - if(loc_params->type == H5VL_OBJECT_BY_NAME) { /* H5Lget_info */ - if(H5L_get_info(&loc, loc_params->loc_data.loc_by_name.name, linfo) < 0) - HGOTO_ERROR(H5E_LINK, H5E_NOTFOUND, FAIL, "unable to get link info") - } /* end if */ - else if(loc_params->type == H5VL_OBJECT_BY_IDX) { /* H5Lget_info_by_idx */ - if(H5L_get_info_by_idx(&loc, loc_params->loc_data.loc_by_idx.name, loc_params->loc_data.loc_by_idx.idx_type, - loc_params->loc_data.loc_by_idx.order, loc_params->loc_data.loc_by_idx.n, linfo) < 0) - HGOTO_ERROR(H5E_LINK, H5E_NOTFOUND, FAIL, "unable to get link info") - } /* end else-if */ - else - HGOTO_ERROR(H5E_LINK, H5E_NOTFOUND, FAIL, "unable to get link info") - break; - } - - /* H5Lget_name_by_idx */ - case H5VL_LINK_GET_NAME: - { - char *name = HDva_arg(arguments, char *); - size_t size = HDva_arg(arguments, size_t); - ssize_t *ret = HDva_arg(arguments, ssize_t *); - - /* Get the link name */ - if((*ret = H5L_get_name_by_idx(&loc, loc_params->loc_data.loc_by_idx.name, loc_params->loc_data.loc_by_idx.idx_type, - loc_params->loc_data.loc_by_idx.order, loc_params->loc_data.loc_by_idx.n, name, size)) < 0) - HGOTO_ERROR(H5E_LINK, H5E_NOTFOUND, FAIL, "unable to get link info") - - break; - } - - /* H5Lget_val/H5Lget_val_by_idx */ - case H5VL_LINK_GET_VAL: - { - void *buf = HDva_arg(arguments, void *); - size_t size = HDva_arg(arguments, size_t); - - /* Get the link information */ - if(loc_params->type == H5VL_OBJECT_BY_NAME) { /* H5Lget_val */ - if(H5L_get_val(&loc, loc_params->loc_data.loc_by_name.name, buf, size) < 0) - HGOTO_ERROR(H5E_LINK, H5E_NOTFOUND, FAIL, "unable to get link value") - } - else if(loc_params->type == H5VL_OBJECT_BY_IDX) { /* H5Lget_val_by_idx */ - - if(H5L_get_val_by_idx(&loc, loc_params->loc_data.loc_by_idx.name, loc_params->loc_data.loc_by_idx.idx_type, - loc_params->loc_data.loc_by_idx.order, loc_params->loc_data.loc_by_idx.n, buf, size) < 0) - HGOTO_ERROR(H5E_LINK, H5E_NOTFOUND, FAIL, "unable to get link val") - } - else - HGOTO_ERROR(H5E_LINK, H5E_NOTFOUND, FAIL, "unable to get link val") - - break; - } - - default: - HGOTO_ERROR(H5E_VOL, H5E_CANTGET, FAIL, "can't get this type of information from link") - } /* end switch */ - -done: - FUNC_LEAVE_NOAPI(ret_value) -} /* end H5VL__native_link_get() */ - - -/*------------------------------------------------------------------------- - * Function: H5VL__native_link_specific - * - * Purpose: Specific operation on a link - * - * Return: Success: 0 - * Failure: -1 - * - * Programmer: Mohamad Chaarawi - * April, 2012 - * - *------------------------------------------------------------------------- - */ -static herr_t -H5VL__native_link_specific(void *obj, const H5VL_loc_params_t *loc_params, H5VL_link_specific_t specific_type, - hid_t H5_ATTR_UNUSED dxpl_id, void H5_ATTR_UNUSED **req, va_list arguments) -{ - herr_t ret_value = SUCCEED; /* Return value */ - - FUNC_ENTER_STATIC - - switch(specific_type) { - case H5VL_LINK_EXISTS: - { - htri_t *ret = HDva_arg(arguments, htri_t *); - H5G_loc_t loc; - - if(H5G_loc_real(obj, loc_params->obj_type, &loc) < 0) - HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a file or file object") - - /* Check for the existence of the link */ - if((*ret = H5L_exists(&loc, loc_params->loc_data.loc_by_name.name)) < 0) - HGOTO_ERROR(H5E_LINK, H5E_NOTFOUND, FAIL, "unable to specific link info") - break; - } - - case H5VL_LINK_ITER: - { - H5G_loc_t loc; - hbool_t recursive = (hbool_t)HDva_arg(arguments, unsigned); - H5_index_t idx_type = (H5_index_t)HDva_arg(arguments, int); /* enum work-around */ - H5_iter_order_t order = (H5_iter_order_t)HDva_arg(arguments, int); /* enum work-around */ - hsize_t *idx_p = HDva_arg(arguments, hsize_t *); - H5L_iterate_t op = HDva_arg(arguments, H5L_iterate_t); - void *op_data = HDva_arg(arguments, void *); - - /* Get the location */ - if(H5G_loc_real(obj, loc_params->obj_type, &loc) < 0) - HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a location") - - /* Visit or iterate over the links */ - if(loc_params->type == H5VL_OBJECT_BY_SELF) { - if(recursive) { - /* H5Lvisit */ - if((ret_value = H5G_visit(&loc, ".", idx_type, order, op, op_data)) < 0) - HGOTO_ERROR(H5E_LINK, H5E_BADITER, FAIL, "link visitation failed") - } /* end if */ - else { - /* H5Literate */ - if((ret_value = H5L_iterate(&loc, ".", idx_type, order, idx_p, op, op_data)) < 0) - HGOTO_ERROR(H5E_LINK, H5E_BADITER, FAIL, "error iterating over links") - } /* end else */ - } /* end if */ - else if(loc_params->type == H5VL_OBJECT_BY_NAME) { - if(recursive) { - /* H5Lvisit_by_name */ - if((ret_value = H5G_visit(&loc, loc_params->loc_data.loc_by_name.name, idx_type, order, op, op_data)) < 0) - HGOTO_ERROR(H5E_LINK, H5E_BADITER, FAIL, "link visitation failed") - } /* end if */ - else { - /* H5Literate_by_name */ - if((ret_value = H5L_iterate(&loc, loc_params->loc_data.loc_by_name.name, idx_type, order, idx_p, op, op_data)) < 0) - HGOTO_ERROR(H5E_LINK, H5E_BADITER, FAIL, "error iterating over links") - } /* end else */ - } /* end else-if */ - else - HGOTO_ERROR(H5E_LINK, H5E_UNSUPPORTED, FAIL, "unknown link iterate params") - - break; - } - - case H5VL_LINK_DELETE: - { - H5G_loc_t loc; - - if(H5G_loc_real(obj, loc_params->obj_type, &loc) < 0) - HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a file or file object") - - /* Unlink */ - if(loc_params->type == H5VL_OBJECT_BY_NAME) { /* H5Ldelete */ - if(H5L_delete(&loc, loc_params->loc_data.loc_by_name.name) < 0) - HGOTO_ERROR(H5E_LINK, H5E_CANTDELETE, FAIL, "unable to delete link") - } /* end if */ - else if(loc_params->type == H5VL_OBJECT_BY_IDX) { /* H5Ldelete_by_idx */ - if(H5L_delete_by_idx(&loc, loc_params->loc_data.loc_by_idx.name, loc_params->loc_data.loc_by_idx.idx_type, - loc_params->loc_data.loc_by_idx.order, loc_params->loc_data.loc_by_idx.n) < 0) - HGOTO_ERROR(H5E_LINK, H5E_CANTDELETE, FAIL, "unable to delete link") - } /* end else-if */ - else - HGOTO_ERROR(H5E_LINK, H5E_CANTDELETE, FAIL, "unable to delete link") - break; - } - - default: - HGOTO_ERROR(H5E_VOL, H5E_UNSUPPORTED, FAIL, "invalid specific operation") - } /* end switch */ - -done: - FUNC_LEAVE_NOAPI(ret_value) -} /* end H5VL__native_link_specific() */ - - -/*------------------------------------------------------------------------- - * Function: H5VL__native_object_open - * - * Purpose: Opens an 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, const H5VL_loc_params_t *loc_params, H5I_type_t *opened_type, - hid_t H5_ATTR_UNUSED dxpl_id, void H5_ATTR_UNUSED **req) -{ - H5G_loc_t loc; - void *ret_value = NULL; - - FUNC_ENTER_STATIC - - if(H5G_loc_real(obj, loc_params->obj_type, &loc) < 0) - HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, NULL, "not a file or file object") - - switch(loc_params->type) { - case H5VL_OBJECT_BY_NAME: - { - /* Open the object */ - if(NULL == (ret_value = H5O_open_name(&loc, loc_params->loc_data.loc_by_name.name, opened_type))) - HGOTO_ERROR(H5E_OHDR, H5E_CANTOPENOBJ, NULL, "unable to open object by name") - break; - } - - case H5VL_OBJECT_BY_IDX: - { - /* Open the object */ - if(NULL == (ret_value = H5O_open_by_idx(&loc, loc_params->loc_data.loc_by_idx.name, loc_params->loc_data.loc_by_idx.idx_type, - loc_params->loc_data.loc_by_idx.order, loc_params->loc_data.loc_by_idx.n, opened_type))) - HGOTO_ERROR(H5E_OHDR, H5E_CANTOPENOBJ, NULL, "unable to open object by index") - break; - } - - case H5VL_OBJECT_BY_ADDR: - { - /* Open the object */ - if(NULL == (ret_value = H5O_open_by_addr(&loc, loc_params->loc_data.loc_by_addr.addr, opened_type))) - HGOTO_ERROR(H5E_OHDR, H5E_CANTOPENOBJ, NULL, "unable to open object by address") - break; - } - - case H5VL_OBJECT_BY_REF: - { - hid_t temp_id = H5I_INVALID_HID; - H5F_t *file = NULL; - - /* Get the file pointer from the entry */ - file = loc.oloc->file; - - /* Create reference */ - if((temp_id = H5R__dereference(file, loc_params->loc_data.loc_by_ref.lapl_id, - loc_params->loc_data.loc_by_ref.ref_type, - loc_params->loc_data.loc_by_ref._ref)) < 0) - HGOTO_ERROR(H5E_REFERENCE, H5E_CANTOPENOBJ, NULL, "unable to dereference object") - - *opened_type = H5I_get_type(temp_id); - if(NULL == (ret_value = H5I_remove(temp_id))) - HGOTO_ERROR(H5E_SYM, H5E_CANTOPENOBJ, NULL, "unable to open object") - break; - } - - case H5VL_OBJECT_BY_SELF: - default: - HGOTO_ERROR(H5E_VOL, H5E_UNSUPPORTED, NULL, "unknown open parameters") - } /* end switch */ - -done: - FUNC_LEAVE_NOAPI(ret_value) -} /* end H5VL__native_object_open() */ - - -/*------------------------------------------------------------------------- - * Function: H5VL__native_object_copy - * - * Purpose: Copies an object inside a native h5 file. - * - * Return: Success: 0 - * Failure: -1 - * - * Programmer: Mohamad Chaarawi - * March, 2012 - * - *------------------------------------------------------------------------- - */ -static herr_t -H5VL__native_object_copy(void *src_obj, const H5VL_loc_params_t *loc_params1, const char *src_name, - void *dst_obj, const H5VL_loc_params_t *loc_params2, const char *dst_name, - hid_t ocpypl_id, hid_t lcpl_id, hid_t H5_ATTR_UNUSED dxpl_id, void H5_ATTR_UNUSED **req) -{ - H5G_loc_t src_loc; /* Source object group location */ - H5G_loc_t dst_loc; /* Destination group location */ - herr_t ret_value = FAIL; - - FUNC_ENTER_STATIC - - /* get location for objects */ - if(H5G_loc_real(src_obj, loc_params1->obj_type, &src_loc) < 0) - HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a file or file object") - if(H5G_loc_real(dst_obj, loc_params2->obj_type, &dst_loc) < 0) - HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a file or file object") - - /* Copy the object */ - if((ret_value = H5O_copy(&src_loc, src_name, &dst_loc, dst_name, ocpypl_id, lcpl_id)) < 0) - HGOTO_ERROR(H5E_SYM, H5E_CANTCOPY, FAIL, "unable to copy object") - -done: - FUNC_LEAVE_NOAPI(ret_value) -} /* end H5VL__native_object_copy() */ - - -/*------------------------------------------------------------------------- - * Function: H5VL__native_object_get - * - * Purpose: Gets certain data about an object - * - * Return: SUCCEED/FAIL - * - * Programmer: Mohamad Chaarawi - * March, 2012 - * - *------------------------------------------------------------------------- - */ -static herr_t -H5VL__native_object_get(void *obj, const H5VL_loc_params_t *loc_params, H5VL_object_get_t get_type, - hid_t H5_ATTR_UNUSED dxpl_id, void H5_ATTR_UNUSED **req, va_list arguments) -{ - herr_t ret_value = SUCCEED; /* Return value */ - H5G_loc_t loc; /* Location of group */ - - FUNC_ENTER_STATIC - - if(H5G_loc_real(obj, loc_params->obj_type, &loc) < 0) - HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a file or file object") - - switch(get_type) { - /* H5Rget_region */ - case H5VL_REF_GET_REGION: - { - hid_t *ret = HDva_arg(arguments, hid_t *); - H5R_type_t H5_ATTR_UNUSED ref_type = (H5R_type_t)HDva_arg(arguments, int); /* enum work-around */ - void *ref = HDva_arg(arguments, void *); - H5S_t *space = NULL; /* Dataspace object */ - - /* Get the dataspace with the correct region selected */ - if((space = H5R__get_region(loc.oloc->file, ref)) == NULL) - HGOTO_ERROR(H5E_REFERENCE, H5E_CANTGET, FAIL, "unable to retrieve region") - - /* Atomize */ - if((*ret = H5I_register(H5I_DATASPACE, space, TRUE)) < 0) - HGOTO_ERROR(H5E_ATOM, H5E_CANTREGISTER, FAIL, "unable to register dataspace atom") - - break; - } - - /* H5Rget_obj_type1/2 */ - case H5VL_REF_GET_TYPE: - { - H5O_type_t *obj_type = HDva_arg(arguments, H5O_type_t *); - H5R_type_t ref_type = (H5R_type_t)HDva_arg(arguments, int); /* enum work-around */ - void *ref = HDva_arg(arguments, void *); - - /* Get the object information */ - if(H5R__get_obj_type(loc.oloc->file, ref_type, ref, obj_type) < 0) - HGOTO_ERROR(H5E_REFERENCE, H5E_CANTGET, FAIL, "unable to determine object type") - break; - } - - /* H5Rget_name */ - case H5VL_REF_GET_NAME: - { - ssize_t *ret = HDva_arg(arguments, ssize_t *); - char *name = HDva_arg(arguments, char *); - size_t size = HDva_arg(arguments, size_t); - H5R_type_t ref_type = (H5R_type_t)HDva_arg(arguments, int); /* enum work-around */ - void *ref = HDva_arg(arguments, void *); - - /* Get name */ - if((*ret = H5R__get_name(loc.oloc->file, ref_type, ref, name, size)) < 0) - HGOTO_ERROR(H5E_REFERENCE, H5E_CANTGET, FAIL, "unable to determine object path") - break; - } - - /* H5Iget_name */ - case H5VL_ID_GET_NAME: - { - ssize_t *ret = HDva_arg(arguments, ssize_t *); - char *name = HDva_arg(arguments, char *); - size_t size = HDva_arg(arguments, size_t); - - /* Retrieve object's name */ - if((*ret = H5G_get_name(&loc, name, size, NULL)) < 0) - HGOTO_ERROR(H5E_ATOM, H5E_CANTGET, FAIL, "can't retrieve object name") - - break; - } - - default: - HGOTO_ERROR(H5E_VOL, H5E_CANTGET, FAIL, "can't get this type of information from object") - } /* end switch */ - -done: - FUNC_LEAVE_NOAPI(ret_value) -} /* end H5VL__native_object_get() */ - - -/*------------------------------------------------------------------------- - * Function: H5VL__native_object_specific - * - * Purpose: Specific operation on an object - * - * Return: SUCCEED/FAIL - * - *------------------------------------------------------------------------- - */ -static herr_t -H5VL__native_object_specific(void *obj, const H5VL_loc_params_t *loc_params, H5VL_object_specific_t specific_type, - hid_t H5_ATTR_UNUSED dxpl_id, void H5_ATTR_UNUSED **req, va_list arguments) -{ - H5G_loc_t loc; - herr_t ret_value = SUCCEED; /* Return value */ - - FUNC_ENTER_STATIC - - if(H5G_loc_real(obj, loc_params->obj_type, &loc) < 0) - HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a file or file object") - - switch(specific_type) { - /* H5Oincr_refcount / H5Odecr_refcount */ - case H5VL_OBJECT_CHANGE_REF_COUNT: - { - int update_ref = HDva_arg(arguments, int); - H5O_loc_t *oloc = loc.oloc; - - if(H5O_link(oloc, update_ref) < 0) - HGOTO_ERROR(H5E_OHDR, H5E_LINKCOUNT, FAIL, "modifying object link count failed") - - break; - } - - /* H5Oexists_by_name */ - case H5VL_OBJECT_EXISTS: - { - htri_t *ret = HDva_arg(arguments, htri_t *); - - if(loc_params->type == H5VL_OBJECT_BY_NAME) { - /* Check if the object exists */ - if((*ret = H5G_loc_exists(&loc, loc_params->loc_data.loc_by_name.name)) < 0) - HGOTO_ERROR(H5E_OHDR, H5E_CANTGET, FAIL, "unable to determine if '%s' exists", loc_params->loc_data.loc_by_name.name) - } /* end if */ - else - HGOTO_ERROR(H5E_VOL, H5E_UNSUPPORTED, FAIL, "unknown object exists parameters") - break; - } - - case H5VL_OBJECT_VISIT: - { - H5_index_t idx_type = (H5_index_t)HDva_arg(arguments, int); /* enum work-around */ - H5_iter_order_t order = (H5_iter_order_t)HDva_arg(arguments, int); /* enum work-around */ - H5O_iterate_t op = HDva_arg(arguments, H5O_iterate_t); - void *op_data = HDva_arg(arguments, void *); - unsigned fields = HDva_arg(arguments, unsigned); - - /* Call internal object visitation routine */ - if(loc_params->type == H5VL_OBJECT_BY_SELF) { - /* H5Ovisit */ - if((ret_value = H5O__visit(&loc, ".", idx_type, order, op, op_data, fields)) < 0) - HGOTO_ERROR(H5E_OHDR, H5E_BADITER, FAIL, "object visitation failed") - } /* end if */ - else if(loc_params->type == H5VL_OBJECT_BY_NAME) { - /* H5Ovisit_by_name */ - if((ret_value = H5O__visit(&loc, loc_params->loc_data.loc_by_name.name, idx_type, order, op, op_data, fields)) < 0) - HGOTO_ERROR(H5E_OHDR, H5E_BADITER, FAIL, "object visitation failed") - } /* end else-if */ - else - HGOTO_ERROR(H5E_VOL, H5E_UNSUPPORTED, FAIL, "unknown object visit params"); - break; - } - - case H5VL_OBJECT_FLUSH: - { - hid_t oid = HDva_arg(arguments, hid_t); - - /* Flush the object's metadata */ - if(H5O_flush(loc.oloc, oid) < 0) - HGOTO_ERROR(H5E_OHDR, H5E_CANTFLUSH, FAIL, "unable to flush object") - - break; - } - - case H5VL_OBJECT_REFRESH: - { - hid_t oid = HDva_arg(arguments, hid_t); - H5O_loc_t *oloc = loc.oloc; - - /* Refresh the metadata */ - if(H5O_refresh_metadata(oid, *oloc) < 0) - HGOTO_ERROR(H5E_OHDR, H5E_CANTLOAD, FAIL, "unable to refresh object") - - break; - } - - case H5VL_REF_CREATE: - { - void *ref = HDva_arg(arguments, void *); - const char *name = HDva_arg(arguments, char *); - H5R_type_t ref_type = (H5R_type_t)HDva_arg(arguments, int); /* enum work-around */ - hid_t space_id = HDva_arg(arguments, hid_t); - H5S_t *space = NULL; /* Pointer to dataspace containing region */ - - if(space_id != (-1) && (NULL == (space = (H5S_t *)H5I_object_verify(space_id, H5I_DATASPACE)))) - HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a dataspace") - - /* Create reference */ - if(H5R__create(ref, &loc, name, ref_type, space) < 0) - HGOTO_ERROR(H5E_REFERENCE, H5E_CANTCREATE, FAIL, "unable to create reference") - - break; - } - - default: - HGOTO_ERROR(H5E_VOL, H5E_CANTGET, FAIL, "can't recognize this operation type") - } /* end switch */ - -done: - FUNC_LEAVE_NOAPI(ret_value) -} /* end H5VL__native_object_specific() */ - - -/*------------------------------------------------------------------------- - * Function: H5VL__native_object_optional - * - * Purpose: Perform a connector-specific operation for an objectibute - * - * Return: Success: 0 - * Failure: -1 - * - * Programmer: Mohamad Chaarawi - * April, 2012 - * - *------------------------------------------------------------------------- - */ -static herr_t -H5VL__native_object_optional(void *obj, hid_t H5_ATTR_UNUSED dxpl_id, - void H5_ATTR_UNUSED **req, va_list arguments) -{ - H5VL_native_object_optional_t optional_type = HDva_arg(arguments, H5VL_native_object_optional_t); - H5VL_loc_params_t *loc_params = HDva_arg(arguments, H5VL_loc_params_t *); - H5G_loc_t loc; /* Location of group */ - herr_t ret_value = SUCCEED; /* Return value */ - - FUNC_ENTER_STATIC - - if(H5G_loc_real(obj, loc_params->obj_type, &loc) < 0) - HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a file or file object") - - switch(optional_type) { - /* H5Oget_info / H5Oget_info_by_name / H5Oget_info_by_idx */ - case H5VL_NATIVE_OBJECT_GET_INFO: - { - H5O_info_t *obj_info = HDva_arg(arguments, H5O_info_t *); - unsigned fields = HDva_arg(arguments, unsigned); - - if(loc_params->type == H5VL_OBJECT_BY_SELF) { /* H5Oget_info */ - /* Retrieve the object's information */ - if(H5G_loc_info(&loc, ".", obj_info, fields) < 0) - HGOTO_ERROR(H5E_OHDR, H5E_NOTFOUND, FAIL, "object not found") - } /* end if */ - else if(loc_params->type == H5VL_OBJECT_BY_NAME) { /* H5Oget_info_by_name */ - /* Retrieve the object's information */ - if(H5G_loc_info(&loc, loc_params->loc_data.loc_by_name.name, obj_info, fields) < 0) - HGOTO_ERROR(H5E_OHDR, H5E_NOTFOUND, FAIL, "object not found") - } /* end else-if */ - else if(loc_params->type == H5VL_OBJECT_BY_IDX) { /* H5Oget_info_by_idx */ - H5G_loc_t obj_loc; /* Location used to open group */ - H5G_name_t obj_path; /* Opened object group hier. path */ - H5O_loc_t obj_oloc; /* Opened object object location */ - - /* Set up opened group location to fill in */ - obj_loc.oloc = &obj_oloc; - obj_loc.path = &obj_path; - H5G_loc_reset(&obj_loc); - - /* Find the object's location, according to the order in the index */ - if(H5G_loc_find_by_idx(&loc, loc_params->loc_data.loc_by_idx.name, - loc_params->loc_data.loc_by_idx.idx_type, - loc_params->loc_data.loc_by_idx.order, - loc_params->loc_data.loc_by_idx.n, &obj_loc/*out*/) < 0) - HGOTO_ERROR(H5E_OHDR, H5E_NOTFOUND, FAIL, "group not found") - - /* Retrieve the object's information */ - if(H5O_get_info(obj_loc.oloc, obj_info, fields) < 0) { - H5G_loc_free(&obj_loc); - HGOTO_ERROR(H5E_OHDR, H5E_CANTGET, FAIL, "can't retrieve object info") - } /* end if */ - - /* Release the object location */ - if(H5G_loc_free(&obj_loc) < 0) - HGOTO_ERROR(H5E_OHDR, H5E_CANTRELEASE, FAIL, "can't free location") - } /* end else-if */ - else - HGOTO_ERROR(H5E_OHDR, H5E_UNSUPPORTED, FAIL, "unknown get info parameters") - break; - } - - /* H5Oget_comment / H5Oget_comment_by_name */ - case H5VL_NATIVE_OBJECT_GET_COMMENT: - { - char *comment = HDva_arg(arguments, char *); - size_t bufsize = HDva_arg(arguments, size_t); - ssize_t *ret = HDva_arg(arguments, ssize_t *); - - /* Retrieve the object's comment */ - if(loc_params->type == H5VL_OBJECT_BY_SELF) { /* H5Oget_comment */ - if((*ret = H5G_loc_get_comment(&loc, ".", comment/*out*/, bufsize)) < 0) - HGOTO_ERROR(H5E_OHDR, H5E_NOTFOUND, FAIL, "object not found") - } /* end if */ - else if(loc_params->type == H5VL_OBJECT_BY_NAME) { /* H5Oget_comment_by_name */ - if((*ret = H5G_loc_get_comment(&loc, loc_params->loc_data.loc_by_name.name, comment/*out*/, bufsize)) < 0) - HGOTO_ERROR(H5E_OHDR, H5E_NOTFOUND, FAIL, "object not found") - } /* end else-if */ - else - HGOTO_ERROR(H5E_VOL, H5E_UNSUPPORTED, FAIL, "unknown set_coment parameters") - break; - } - - /* H5Oset_comment */ - case H5VL_NATIVE_OBJECT_SET_COMMENT: - { - const char *comment = HDva_arg(arguments, char *); - - if(loc_params->type == H5VL_OBJECT_BY_SELF) { /* H5Oset_comment */ - /* (Re)set the object's comment */ - if(H5G_loc_set_comment(&loc, ".", comment) < 0) - HGOTO_ERROR(H5E_OHDR, H5E_NOTFOUND, FAIL, "object not found") - } /* end if */ - else if(loc_params->type == H5VL_OBJECT_BY_NAME) { /* H5Oset_comment_by_name */ - /* (Re)set the object's comment */ - if(H5G_loc_set_comment(&loc, loc_params->loc_data.loc_by_name.name, comment) < 0) - HGOTO_ERROR(H5E_OHDR, H5E_NOTFOUND, FAIL, "object not found") - } /* end else-if */ - else - HGOTO_ERROR(H5E_VOL, H5E_UNSUPPORTED, FAIL, "unknown set_coment parameters") - break; - } - - default: - HGOTO_ERROR(H5E_VOL, H5E_CANTGET, FAIL, "can't perform this operation on object"); - } /* end switch */ - -done: - FUNC_LEAVE_NOAPI(ret_value) -} /* end H5VL__native_object_optional() */ - - -/*------------------------------------------------------------------------- - * 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, const H5VL_loc_params_t *loc_params, const char *name, - hid_t type_id, hid_t lcpl_id, hid_t tcpl_id, hid_t H5_ATTR_UNUSED tapl_id, - hid_t H5_ATTR_UNUSED dxpl_id, void H5_ATTR_UNUSED **req) -{ - H5G_loc_t loc; /* Location to commit datatype */ - H5T_t *dt; /* Datatype for ID */ - H5T_t *type = NULL; /* copy of the original type which will be committed */ - void *ret_value = NULL; /* Return value */ - - FUNC_ENTER_STATIC - - /* check arguments */ - if(H5G_loc_real(obj, loc_params->obj_type, &loc) < 0) - HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, NULL, "not a file or file object") - - if(NULL == (dt = (H5T_t *)H5I_object_verify(type_id, H5I_DATATYPE))) - HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, NULL, "not a datatype") - - /* Check arguments. We cannot commit an immutable type because H5Tclose() - * normally fails on such types (try H5Tclose(H5T_NATIVE_INT)) but closing - * a named type should always succeed. - */ - if(H5T_STATE_NAMED == dt->shared->state || H5T_STATE_OPEN == dt->shared->state) - HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, NULL, "datatype is already committed") - if(H5T_STATE_IMMUTABLE == dt->shared->state) - HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, NULL, "datatype is immutable") - - /* Check for a "sensible" datatype to store on disk */ - if(H5T_is_sensible(dt) <= 0) - HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, NULL, "datatype is not sensible") - - /* Copy the datatype - the copied one will be the type that is - * committed, and attached to original datatype above the VOL - * layer - */ - if(NULL == (type = H5T_copy(dt, H5T_COPY_TRANSIENT))) - HGOTO_ERROR(H5E_DATATYPE, H5E_CANTINIT, NULL, "unable to copy"); - - /* Commit the datatype */ - if(NULL != name) { - /* H5Tcommit */ - if(H5T__commit_named(&loc, name, type, lcpl_id, tcpl_id) < 0) - HGOTO_ERROR(H5E_DATATYPE, H5E_CANTINIT, NULL, "unable to commit datatype") - } /* end if */ - else { - /* H5Tcommit_anon */ - if(H5T__commit_anon(loc.oloc->file, type, tcpl_id) < 0) - HGOTO_ERROR(H5E_DATATYPE, H5E_CANTINIT, NULL, "unable to commit datatype") - } /* end else */ - - ret_value = (void *)type; - -done: - if(NULL == ret_value && type) - H5T_close(type); - - FUNC_LEAVE_NOAPI(ret_value) -} /* end H5VL__native_datatype_commit() */ - - -/*------------------------------------------------------------------------- - * Function: H5VL__native_datatype_open - * - * Purpose: Opens a named datatype inside a native h5 file. - * - * Return: Success: datatype pointer - * Failure: NULL - * - *------------------------------------------------------------------------- - */ -static void * -H5VL__native_datatype_open(void *obj, const H5VL_loc_params_t *loc_params, const char *name, - hid_t H5_ATTR_UNUSED tapl_id, hid_t H5_ATTR_UNUSED dxpl_id, void H5_ATTR_UNUSED **req) -{ - H5T_t *type = NULL; /* Datatype opened in file */ - H5G_loc_t loc; /* Group location of object to open */ - void *ret_value = NULL; - - FUNC_ENTER_STATIC - - if(H5G_loc_real(obj, loc_params->obj_type, &loc) < 0) - HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, NULL, "not a file or file object") - - /* Open the datatype */ - if(NULL == (type = H5T__open_name(&loc, name))) - HGOTO_ERROR(H5E_DATATYPE, H5E_CANTOPENOBJ, NULL, "unable to open named datatype") - - type->vol_obj = NULL; - - ret_value = (void *)type; - -done: - FUNC_LEAVE_NOAPI(ret_value) -} /* end H5VL__native_datatype_open() */ - - -/*------------------------------------------------------------------------- - * Function: H5VL__native_datatype_get - * - * Purpose: Get information about a datatype - * - * Return: Success: 0 - * Failure: -1 - * - * Programmer: Mohamad Chaarawi - * June, 2013 - * - *------------------------------------------------------------------------- - */ -static herr_t -H5VL__native_datatype_get(void *obj, H5VL_datatype_get_t get_type, - hid_t H5_ATTR_UNUSED dxpl_id, void H5_ATTR_UNUSED **req, va_list arguments) -{ - H5T_t *dt = (H5T_t *)obj; - herr_t ret_value = SUCCEED; /* Return value */ - - FUNC_ENTER_STATIC - - switch (get_type) { - case H5VL_DATATYPE_GET_BINARY: - { - ssize_t *nalloc = HDva_arg(arguments, ssize_t *); - void *buf = HDva_arg(arguments, void *); - size_t size = HDva_arg(arguments, size_t); - - if(H5T_encode(dt, (unsigned char *)buf, &size) < 0) - HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "can't determine serialized length of datatype") - - *nalloc = (ssize_t) size; - break; - } - - /* H5Tget_create_plist */ - case H5VL_DATATYPE_GET_TCPL: - { - hid_t *ret_id = HDva_arg(arguments, hid_t *); - - if(H5I_INVALID_HID == (*ret_id = H5T__get_create_plist(dt))) - HGOTO_ERROR(H5E_DATATYPE, H5E_CANTGET, FAIL, "can't get object creation info"); - - break; - } - - default: - HGOTO_ERROR(H5E_VOL, H5E_CANTGET, FAIL, "can't get this type of information from datatype") - } /* end switch */ - -done: - FUNC_LEAVE_NOAPI(ret_value) -} /* end H5VL__native_datatype_get() */ - - -/*------------------------------------------------------------------------- - * Function: H5VL__native_datatype_specific - * - * Purpose: Specific operations for datatype - * - * Return: SUCCEED/FAIL - * - *------------------------------------------------------------------------- - */ -static herr_t -H5VL__native_datatype_specific(void *obj, H5VL_datatype_specific_t specific_type, - hid_t H5_ATTR_UNUSED dxpl_id, void H5_ATTR_UNUSED **req, va_list arguments) -{ - H5T_t *dt = (H5T_t *)obj; - herr_t ret_value = SUCCEED; /* Return value */ - - FUNC_ENTER_STATIC - - switch(specific_type) { - case H5VL_DATATYPE_FLUSH: - { - hid_t type_id = HDva_arg(arguments, hid_t); - - /* To flush metadata and invoke flush callback if there is */ - if (H5O_flush_common(&dt->oloc, type_id) < 0) - HGOTO_ERROR(H5E_DATATYPE, H5E_CANTFLUSH, FAIL, "unable to flush datatype") - - break; - } - - case H5VL_DATATYPE_REFRESH: - { - hid_t type_id = HDva_arg(arguments, hid_t); - - /* Call private function to refresh datatype object */ - if ((H5O_refresh_metadata(type_id, dt->oloc)) < 0) - HGOTO_ERROR(H5E_DATATYPE, H5E_CANTLOAD, FAIL, "unable to refresh datatype") - - break; - } - - default: - HGOTO_ERROR(H5E_VOL, H5E_UNSUPPORTED, FAIL, "invalid specific operation") - } /* end switch */ - -done: - FUNC_LEAVE_NOAPI(ret_value) -} /* end H5VL__native_datatype_specific() */ - - -/*------------------------------------------------------------------------- - * Function: H5VL__native_datatype_close - * - * Purpose: Closes a datatype. - * - * Return: Success: 0 - * Failure: -1, datatype not closed. - * - * Programmer: Mohamad Chaarawi - * March, 2012 - * - *------------------------------------------------------------------------- - */ -static herr_t -H5VL__native_datatype_close(void *dt, hid_t H5_ATTR_UNUSED dxpl_id, void H5_ATTR_UNUSED **req) -{ - herr_t ret_value = SUCCEED; /* Return value */ - - FUNC_ENTER_STATIC - - if(H5T_close((H5T_t*)dt) < 0) - HGOTO_ERROR(H5E_SYM, H5E_CANTDEC, FAIL, "can't close datatype") - -done: - FUNC_LEAVE_NOAPI(ret_value) -} /* end H5VL__native_datatype_close() */ - diff --git a/src/H5VLnative.h b/src/H5VLnative.h index d129865..a033a07 100644 --- a/src/H5VLnative.h +++ b/src/H5VLnative.h @@ -98,6 +98,53 @@ H5_DLL herr_t H5VL__native_attr_specific(void *obj, const H5VL_loc_params_t *loc H5_DLL herr_t H5VL__native_attr_optional(void *obj, hid_t dxpl_id, void **req, va_list arguments); H5_DLL herr_t H5VL__native_attr_close(void *attr, hid_t dxpl_id, void **req); +/* Dataset callbacks */ +H5_DLL void *H5VL__native_dataset_create(void *obj, const H5VL_loc_params_t *loc_params, const char *name, hid_t dcpl_id, hid_t dapl_id, hid_t dxpl_id, void **req); +H5_DLL void *H5VL__native_dataset_open(void *obj, const H5VL_loc_params_t *loc_params, const char *name, hid_t dapl_id, hid_t dxpl_id, void **req); +H5_DLL herr_t H5VL__native_dataset_read(void *dset, hid_t mem_type_id, hid_t mem_space_id, hid_t file_space_id, hid_t plist_id, void *buf, void **req); +H5_DLL herr_t H5VL__native_dataset_write(void *dset, hid_t mem_type_id, hid_t mem_space_id, hid_t file_space_id, hid_t plist_id, const void *buf, void **req); +H5_DLL herr_t H5VL__native_dataset_get(void *dset, H5VL_dataset_get_t get_type, hid_t dxpl_id, void **req, va_list arguments); +H5_DLL herr_t H5VL__native_dataset_specific(void *dset, H5VL_dataset_specific_t specific_type, hid_t dxpl_id, void **req, va_list arguments); +H5_DLL herr_t H5VL__native_dataset_optional(void *dset, hid_t dxpl_id, void **req, va_list arguments); +H5_DLL herr_t H5VL__native_dataset_close(void *dset, hid_t dxpl_id, void **req); + +/* File callbacks */ +H5_DLL void *H5VL__native_file_create(const char *name, unsigned flags, hid_t fcpl_id, hid_t fapl_id, hid_t dxpl_id, void **req); +H5_DLL void *H5VL__native_file_open(const char *name, unsigned flags, hid_t fapl_id, hid_t dxpl_id, void **req); +H5_DLL herr_t H5VL__native_file_get(void *file, H5VL_file_get_t get_type, hid_t dxpl_id, void **req, va_list arguments); +H5_DLL herr_t H5VL__native_file_specific(void *file, H5VL_file_specific_t specific_type, hid_t dxpl_id, void **req, va_list arguments); +H5_DLL herr_t H5VL__native_file_optional(void *file, hid_t dxpl_id, void **req, va_list arguments); +H5_DLL herr_t H5VL__native_file_close(void *file, hid_t dxpl_id, void **req); + +/* Group callbacks */ +H5_DLL void *H5VL__native_group_create(void *obj, const H5VL_loc_params_t *loc_params, const char *name, hid_t gcpl_id, hid_t gapl_id, hid_t dxpl_id, void **req); +H5_DLL void *H5VL__native_group_open(void *obj, const H5VL_loc_params_t *loc_params, const char *name, hid_t gapl_id, hid_t dxpl_id, void **req); +H5_DLL herr_t H5VL__native_group_get(void *obj, H5VL_group_get_t get_type, hid_t dxpl_id, void **req, va_list arguments); +H5_DLL herr_t H5VL__native_group_specific(void *obj, H5VL_group_specific_t specific_type, hid_t dxpl_id, void **req, va_list arguments); +H5_DLL herr_t H5VL__native_group_optional(void *obj, hid_t dxpl_id, void **req, va_list arguments); +H5_DLL herr_t H5VL__native_group_close(void *grp, hid_t dxpl_id, void **req); + +/* Link callbacks */ +H5_DLL herr_t H5VL__native_link_create(H5VL_link_create_type_t create_type, void *obj, const H5VL_loc_params_t *loc_params, hid_t lcpl_id, hid_t lapl_id, hid_t dxpl_id, void **req); +H5_DLL herr_t H5VL__native_link_copy(void *src_obj, const H5VL_loc_params_t *loc_params1, void *dst_obj, const H5VL_loc_params_t *loc_params2, hid_t lcpl_id, hid_t lapl_id, hid_t dxpl_id, void **req); +H5_DLL herr_t H5VL__native_link_move(void *src_obj, const H5VL_loc_params_t *loc_params1, void *dst_obj, const H5VL_loc_params_t *loc_params2, hid_t lcpl_id, hid_t lapl_id, hid_t dxpl_id, void **req); +H5_DLL herr_t H5VL__native_link_get(void *obj, const H5VL_loc_params_t *loc_params, H5VL_link_get_t get_type, hid_t dxpl_id, void **req, va_list arguments); +H5_DLL herr_t H5VL__native_link_specific(void *obj, const H5VL_loc_params_t *loc_params, H5VL_link_specific_t specific_type, hid_t dxpl_id, void **req, va_list arguments); + +/* Object callbacks */ +H5_DLL void *H5VL__native_object_open(void *obj, const H5VL_loc_params_t *loc_params, H5I_type_t *opened_type, hid_t dxpl_id, void **req); +H5_DLL herr_t H5VL__native_object_copy(void *src_obj, const H5VL_loc_params_t *loc_params1, const char *src_name, void *dst_obj, const H5VL_loc_params_t *loc_params2, const char *dst_name, hid_t ocpypl_id, hid_t lcpl_id, hid_t dxpl_id, void **req); +H5_DLL herr_t H5VL__native_object_get(void *obj, const H5VL_loc_params_t *loc_params, H5VL_object_get_t get_type, hid_t dxpl_id, void **req, va_list arguments); +H5_DLL herr_t H5VL__native_object_specific(void *obj, const H5VL_loc_params_t *loc_params, H5VL_object_specific_t specific_type, hid_t dxpl_id, void **req, va_list arguments); +H5_DLL herr_t H5VL__native_object_optional(void *obj, hid_t dxpl_id, void **req, va_list arguments); + +/* Datatype callbacks */ +H5_DLL void *H5VL__native_datatype_commit(void *obj, const H5VL_loc_params_t *loc_params, const char *name, hid_t type_id, hid_t lcpl_id, hid_t tcpl_id, hid_t tapl_id, hid_t dxpl_id, void **req); +H5_DLL void *H5VL__native_datatype_open(void *obj, const H5VL_loc_params_t *loc_params, const char *name, hid_t tapl_id, hid_t dxpl_id, void **req); +H5_DLL herr_t H5VL__native_datatype_get(void *dt, H5VL_datatype_get_t get_type, hid_t dxpl_id, void **req, va_list arguments); +H5_DLL herr_t H5VL__native_datatype_specific(void *dt, H5VL_datatype_specific_t specific_type, hid_t dxpl_id, void **req, va_list arguments); +H5_DLL herr_t H5VL__native_datatype_close(void *dt, hid_t dxpl_id, void **req); + #ifdef __cplusplus } #endif diff --git a/src/H5VLnative_attr.c b/src/H5VLnative_attr.c index 9688291..7940b7d 100644 --- a/src/H5VLnative_attr.c +++ b/src/H5VLnative_attr.c @@ -11,7 +11,7 @@ * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ /* - * Purpose: Attribute code for the native VOL connector. + * Purpose: Attribute callbacks for the native VOL connector * */ @@ -115,9 +115,6 @@ done: * Return: Success: attribute pointer * Failure: NULL * - * Programmer: Mohamad Chaarawi - * March, 2012 - * *------------------------------------------------------------------------- */ void * @@ -172,9 +169,6 @@ done: * * Return: SUCCEED/FAIL * - * Programmer: Mohamad Chaarawi - * March, 2012 - * *------------------------------------------------------------------------- */ herr_t @@ -205,9 +199,6 @@ done: * * Return: SUCCEED/FAIL * - * Programmer: Mohamad Chaarawi - * March, 2012 - * *------------------------------------------------------------------------- */ herr_t @@ -238,9 +229,6 @@ done: * * Return: SUCCEED/FAIL * - * Programmer: Mohamad Chaarawi - * March, 2012 - * *------------------------------------------------------------------------- */ herr_t @@ -421,9 +409,6 @@ done: * * Return: SUCCEED/FAIL * - * Programmer: Mohamad Chaarawi - * August, 2014 - * *------------------------------------------------------------------------- */ herr_t @@ -592,10 +577,7 @@ done: * Purpose: Handles the attribute close callback * * Return: Success: SUCCEED - * Failure: FAIL, attribute not closed - * - * Programmer: Mohamad Chaarawi - * March, 2012 + * Failure: FAIL (attribute will not be closed) * *------------------------------------------------------------------------- */ diff --git a/src/H5VLnative_dataset.c b/src/H5VLnative_dataset.c index 636b48b..2316255 100644 --- a/src/H5VLnative_dataset.c +++ b/src/H5VLnative_dataset.c @@ -10,4 +10,566 @@ * help@hdfgroup.org. * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ +/* + * Purpose: Dataset callbacks for the native VOL connector + * + */ + +#define H5D_FRIEND /* Suppress error about including H5Dpkg */ + +#include "H5private.h" /* Generic Functions */ +#include "H5Dpkg.h" /* Datasets */ +#include "H5Eprivate.h" /* Error handling */ +#include "H5Fprivate.h" /* Files */ +#include "H5Gprivate.h" /* Groups */ +#include "H5Iprivate.h" /* IDs */ +#include "H5Pprivate.h" /* Property lists */ +#include "H5Sprivate.h" /* Dataspaces */ +#include "H5VLprivate.h" /* Virtual Object Layer */ + +#include "H5VLnative.h" /* Native VOL connector */ + + + +/*------------------------------------------------------------------------- + * Function: H5VL__native_dataset_create + * + * Purpose: Handles the dataset create callback + * + * Return: Success: dataset pointer + * Failure: NULL + * + *------------------------------------------------------------------------- + */ +void * +H5VL__native_dataset_create(void *obj, const H5VL_loc_params_t *loc_params, + const char *name, hid_t dcpl_id, hid_t dapl_id, hid_t H5_ATTR_UNUSED dxpl_id, + void H5_ATTR_UNUSED **req) +{ + H5P_genplist_t *plist; /* Property list pointer */ + H5G_loc_t loc; /* Object location to insert dataset into */ + hid_t type_id = H5I_INVALID_HID; + hid_t space_id = H5I_INVALID_HID; + hid_t lcpl_id = H5I_INVALID_HID; + H5D_t *dset = NULL; /* New dataset's info */ + const H5S_t *space; /* Dataspace for dataset */ + void *ret_value; + + FUNC_ENTER_PACKAGE + + /* Get the plist structure */ + if(NULL == (plist = (H5P_genplist_t *)H5I_object(dcpl_id))) + HGOTO_ERROR(H5E_ATOM, H5E_BADATOM, NULL, "can't find object for ID") + + /* Get creation properties */ + if(H5P_get(plist, H5VL_PROP_DSET_TYPE_ID, &type_id) < 0) + HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, NULL, "can't get property value for datatype id") + if(H5P_get(plist, H5VL_PROP_DSET_SPACE_ID, &space_id) < 0) + HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, NULL, "can't get property value for space id") + if(H5P_get(plist, H5VL_PROP_DSET_LCPL_ID, &lcpl_id) < 0) + HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, NULL, "can't get property value for lcpl id") + + /* Check arguments */ + if(H5G_loc_real(obj, loc_params->obj_type, &loc) < 0) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, NULL, "not a file or file object") + if(H5I_DATATYPE != H5I_get_type(type_id)) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, NULL, "not a datatype ID") + if(NULL == (space = (const H5S_t *)H5I_object_verify(space_id, H5I_DATASPACE))) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, NULL, "not a dataspace ID") + + /* H5Dcreate_anon */ + if(NULL == name) { + /* build and open the new dataset */ + if(NULL == (dset = H5D__create(loc.oloc->file, type_id, space, dcpl_id, dapl_id))) + HGOTO_ERROR(H5E_DATASET, H5E_CANTINIT, NULL, "unable to create dataset") + } /* end if */ + /* H5Dcreate2 */ + else { + /* Create the new dataset & get its ID */ + if(NULL == (dset = H5D__create_named(&loc, name, type_id, space, lcpl_id, dcpl_id, dapl_id))) + HGOTO_ERROR(H5E_DATASET, H5E_CANTINIT, NULL, "unable to create dataset") + } /* end else */ + + ret_value = (void *)dset; + +done: + if(NULL == name) { + /* Release the dataset's object header, if it was created */ + if(dset) { + H5O_loc_t *oloc; /* Object location for dataset */ + + /* Get the new dataset's object location */ + if(NULL == (oloc = H5D_oloc(dset))) + HDONE_ERROR(H5E_DATASET, H5E_CANTGET, NULL, "unable to get object location of dataset") + + /* Decrement refcount on dataset's object header in memory */ + if(H5O_dec_rc_by_loc(oloc) < 0) + HDONE_ERROR(H5E_DATASET, H5E_CANTDEC, NULL, "unable to decrement refcount on newly created object") + } /* end if */ + } /* end if */ + + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5VL__native_dataset_create() */ + + +/*------------------------------------------------------------------------- + * Function: H5VL__native_dataset_open + * + * Purpose: Handles the dataset open callback + * + * Return: Success: dataset pointer + * Failure: NULL + * + *------------------------------------------------------------------------- + */ +void * +H5VL__native_dataset_open(void *obj, const H5VL_loc_params_t *loc_params, const char *name, + hid_t dapl_id, hid_t H5_ATTR_UNUSED dxpl_id, void H5_ATTR_UNUSED **req) +{ + H5D_t *dset = NULL; + H5G_loc_t loc; /* Object location of group */ + void *ret_value = NULL; + + FUNC_ENTER_PACKAGE + + if(H5G_loc_real(obj, loc_params->obj_type, &loc) < 0) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, NULL, "not a file or file object") + + /* Open the dataset */ + if(NULL == (dset = H5D__open_name(&loc, name, dapl_id))) + HGOTO_ERROR(H5E_DATASET, H5E_CANTOPENOBJ, NULL, "unable to open dataset") + + ret_value = (void *)dset; + +done: + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5VL__native_dataset_open() */ + + +/*------------------------------------------------------------------------- + * Function: H5VL__native_dataset_read + * + * Purpose: Handles the dataset read callback + * + * Return: SUCCEED/FAIL + * + *------------------------------------------------------------------------- + */ +herr_t +H5VL__native_dataset_read(void *obj, hid_t mem_type_id, hid_t mem_space_id, + hid_t file_space_id, hid_t H5_ATTR_UNUSED dxpl_id, void *buf, + void H5_ATTR_UNUSED **req) +{ + H5D_t *dset = (H5D_t *)obj; + const H5S_t *mem_space = NULL; + const H5S_t *file_space = NULL; + herr_t ret_value = SUCCEED; /* Return value */ + + FUNC_ENTER_PACKAGE + + /* Check arguments */ + if(NULL == dset->oloc.file) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "dataset is not associated with a file") + + /* Get validated dataspace pointers */ + if(H5S_get_validated_dataspace(mem_space_id, &mem_space) < 0) + HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "could not get a validated dataspace from mem_space_id") + if(H5S_get_validated_dataspace(file_space_id, &file_space) < 0) + HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "could not get a validated dataspace from file_space_id") + + /* Read raw data */ + if(H5D__read(dset, mem_type_id, mem_space, file_space, buf/*out*/) < 0) + HGOTO_ERROR(H5E_DATASET, H5E_READERROR, FAIL, "can't read data") + +done: + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5VL__native_dataset_read() */ + + +/*------------------------------------------------------------------------- + * Function: H5VL__native_dataset_write + * + * Purpose: Handles the dataset write callback + * + * Return: SUCCEED/FAIL + * + *------------------------------------------------------------------------- + */ +herr_t +H5VL__native_dataset_write(void *obj, hid_t mem_type_id, hid_t mem_space_id, + hid_t file_space_id, hid_t H5_ATTR_UNUSED dxpl_id, const void *buf, + void H5_ATTR_UNUSED **req) +{ + H5D_t *dset = (H5D_t *)obj; + const H5S_t *mem_space = NULL; + const H5S_t *file_space = NULL; + herr_t ret_value = SUCCEED; /* Return value */ + + FUNC_ENTER_PACKAGE + + /* check arguments */ + if(NULL == dset->oloc.file) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "dataset is not associated with a file") + + /* Get validated dataspace pointers */ + if(H5S_get_validated_dataspace(mem_space_id, &mem_space) < 0) + HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "could not get a validated dataspace from mem_space_id") + if(H5S_get_validated_dataspace(file_space_id, &file_space) < 0) + HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "could not get a validated dataspace from file_space_id") + + /* Write the data */ + if(H5D__write(dset, mem_type_id, mem_space, file_space, buf) < 0) + HGOTO_ERROR(H5E_DATASET, H5E_WRITEERROR, FAIL, "can't write data") + +done: + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5VL__native_dataset_write() */ + + +/*------------------------------------------------------------------------- + * Function: H5VL__native_dataset_get + * + * Purpose: Handles the dataset get callback + * + * Return: SUCCEED/FAIL + * + *------------------------------------------------------------------------- + */ +herr_t +H5VL__native_dataset_get(void *obj, H5VL_dataset_get_t get_type, + hid_t H5_ATTR_UNUSED dxpl_id, void H5_ATTR_UNUSED **req, va_list arguments) +{ + H5D_t *dset = (H5D_t *)obj; + herr_t ret_value = SUCCEED; /* Return value */ + + FUNC_ENTER_PACKAGE + + switch(get_type) { + /* H5Dget_space */ + case H5VL_DATASET_GET_SPACE: + { + hid_t *ret_id = HDva_arg(arguments, hid_t *); + + if((*ret_id = H5D__get_space(dset)) < 0) + HGOTO_ERROR(H5E_ARGS, H5E_CANTGET, FAIL, "can't get space ID of dataset") + + break; + } + + /* H5Dget_space_statuc */ + case H5VL_DATASET_GET_SPACE_STATUS: + { + H5D_space_status_t *allocation = HDva_arg(arguments, H5D_space_status_t *); + + /* Read data space address and return */ + if(H5D__get_space_status(dset, allocation) < 0) + HGOTO_ERROR(H5E_DATASET, H5E_CANTINIT, FAIL, "unable to get space status") + + break; + } + + /* H5Dget_type */ + case H5VL_DATASET_GET_TYPE: + { + hid_t *ret_id = HDva_arg(arguments, hid_t *); + + if((*ret_id = H5D__get_type(dset)) < 0) + HGOTO_ERROR(H5E_ARGS, H5E_CANTGET, FAIL, "can't get datatype ID of dataset") + + break; + } + + /* H5Dget_create_plist */ + case H5VL_DATASET_GET_DCPL: + { + hid_t *ret_id = HDva_arg(arguments, hid_t *); + + if((*ret_id = H5D_get_create_plist(dset)) < 0) + HGOTO_ERROR(H5E_ARGS, H5E_CANTGET, FAIL, "can't get creation property list for dataset") + + break; + } + + /* H5Dget_access_plist */ + case H5VL_DATASET_GET_DAPL: + { + hid_t *ret_id = HDva_arg(arguments, hid_t *); + + if((*ret_id = H5D_get_access_plist(dset)) < 0) + HGOTO_ERROR(H5E_ARGS, H5E_CANTGET, FAIL, "can't get access property list for dataset") + + break; + } + + /* H5Dget_storage_size */ + case H5VL_DATASET_GET_STORAGE_SIZE: + { + hsize_t *ret = HDva_arg(arguments, hsize_t *); + + /* Set return value */ + if(H5D__get_storage_size(dset, ret) < 0) + HGOTO_ERROR(H5E_DATASET, H5E_CANTGET, FAIL, "can't get size of dataset's storage") + break; + } + + /* H5Dget_offset */ + case H5VL_DATASET_GET_OFFSET: + { + haddr_t *ret = HDva_arg(arguments, haddr_t *); + + /* Set return value */ + *ret = H5D__get_offset(dset); + if(!H5F_addr_defined(*ret)) + *ret = HADDR_UNDEF; + break; + } + + default: + HGOTO_ERROR(H5E_VOL, H5E_CANTGET, FAIL, "can't get this type of information from dataset") + } /* end switch */ + +done: + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5VL__native_dataset_get() */ + + +/*------------------------------------------------------------------------- + * Function: H5VL__native_dataset_specific + * + * Purpose: Handles the dataset specific callback + * + * Return: SUCCEED/FAIL + * + *------------------------------------------------------------------------- + */ +herr_t +H5VL__native_dataset_specific(void *obj, H5VL_dataset_specific_t specific_type, + hid_t H5_ATTR_UNUSED dxpl_id, void H5_ATTR_UNUSED **req, va_list arguments) +{ + H5D_t *dset = (H5D_t *)obj; + herr_t ret_value = SUCCEED; /* Return value */ + + FUNC_ENTER_PACKAGE + + switch(specific_type) { + /* H5Dspecific_space */ + case H5VL_DATASET_SET_EXTENT: + { + const hsize_t *size = HDva_arg(arguments, const hsize_t *); + + if(H5D__set_extent(dset, size) < 0) + HGOTO_ERROR(H5E_DATASET, H5E_CANTINIT, FAIL, "unable to set extent of dataset") + break; + } + + case H5VL_DATASET_FLUSH: + { + hid_t dset_id = HDva_arg(arguments, hid_t); + + /* Flush the dataset */ + if(H5D__flush(dset, dset_id) < 0) + HGOTO_ERROR(H5E_DATASET, H5E_CANTFLUSH, FAIL, "unable to flush dataset") + + break; + } + + case H5VL_DATASET_REFRESH: + { + hid_t dset_id = HDva_arg(arguments, hid_t); + + /* Refresh the dataset */ + if((H5D__refresh(dset_id, dset)) < 0) + HGOTO_ERROR(H5E_DATASET, H5E_CANTLOAD, FAIL, "unable to refresh dataset") + + break; + } + + default: + HGOTO_ERROR(H5E_VOL, H5E_UNSUPPORTED, FAIL, "invalid specific operation") + } /* end switch */ + +done: + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5VL__native_dataset_specific() */ + + +/*------------------------------------------------------------------------- + * Function: H5VL__native_dataset_optional + * + * Purpose: Handles the dataset optional callback + * + * Return: SUCCEED/FAIL + * + *------------------------------------------------------------------------- + */ +herr_t +H5VL__native_dataset_optional(void *obj, hid_t H5_ATTR_UNUSED dxpl_id, + void H5_ATTR_UNUSED **req, va_list arguments) +{ + H5D_t *dset = NULL; /* Dataset */ + H5VL_native_dataset_optional_t optional_type = HDva_arg(arguments, H5VL_native_dataset_optional_t); + herr_t ret_value = SUCCEED; /* Return value */ + + FUNC_ENTER_PACKAGE + + switch(optional_type) { + case H5VL_NATIVE_DATASET_FORMAT_CONVERT: + { + dset = (H5D_t *)obj; + + switch(dset->shared->layout.type) { + case H5D_CHUNKED: + /* Convert the chunk indexing type to version 1 B-tree if not */ + if(dset->shared->layout.u.chunk.idx_type != H5D_CHUNK_IDX_BTREE) + if((H5D__format_convert(dset)) < 0) + HGOTO_ERROR(H5E_DATASET, H5E_CANTLOAD, FAIL, "unable to downgrade chunk indexing type for dataset") + break; + + case H5D_CONTIGUOUS: + case H5D_COMPACT: + /* Downgrade the layout version to 3 if greater than 3 */ + if(dset->shared->layout.version > H5O_LAYOUT_VERSION_DEFAULT) + if((H5D__format_convert(dset)) < 0) + HGOTO_ERROR(H5E_DATASET, H5E_CANTLOAD, FAIL, "unable to downgrade layout version for dataset") + break; + + case H5D_VIRTUAL: + /* Nothing to do even though layout is version 4 */ + break; + + case H5D_LAYOUT_ERROR: + case H5D_NLAYOUTS: + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "invalid dataset layout type") + + default: + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "unknown dataset layout type") + } /* end switch */ + + break; + } + + case H5VL_NATIVE_DATASET_GET_CHUNK_INDEX_TYPE: + { + H5D_chunk_index_t *idx_type = HDva_arg(arguments, H5D_chunk_index_t *); + + dset = (H5D_t *)obj; + + /* Make sure the dataset is chunked */ + if(H5D_CHUNKED != dset->shared->layout.type) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a chunked dataset") + + /* Get the chunk indexing type */ + *idx_type = dset->shared->layout.u.chunk.idx_type; + + break; + } + + case H5VL_NATIVE_DATASET_GET_CHUNK_STORAGE_SIZE: + { + hsize_t *offset = HDva_arg(arguments, hsize_t *); + hsize_t *chunk_nbytes = HDva_arg(arguments, hsize_t *); + + dset = (H5D_t *)obj; + + /* Make sure the dataset is chunked */ + if(H5D_CHUNKED != dset->shared->layout.type) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a chunked dataset") + + /* Call private function */ + if(H5D__get_chunk_storage_size(dset, offset, chunk_nbytes) < 0) + HGOTO_ERROR(H5E_DATASET, H5E_CANTGET, FAIL, "can't get storage size of chunk") + + break; + } + + case H5VL_NATIVE_DATASET_CHUNK_READ: + { + const hsize_t *offset = HDva_arg(arguments, hsize_t *); + uint32_t *filters = HDva_arg(arguments, uint32_t *); + void *buf = HDva_arg(arguments, void *); + hsize_t offset_copy[H5O_LAYOUT_NDIMS]; /* Internal copy of chunk offset */ + + dset = (H5D_t *)obj; + + /* Check arguments */ + if(NULL == dset->oloc.file) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "dataset is not associated with a file") + if(H5D_CHUNKED != dset->shared->layout.type) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a chunked dataset") + + /* Copy the user's offset array so we can be sure it's terminated properly. + * (we don't want to mess with the user's buffer). + */ + if(H5D__get_offset_copy(dset, offset, offset_copy) < 0) + HGOTO_ERROR(H5E_DATASET, H5E_CANTALLOC, FAIL, "failure to copy offset array") + + /* Read the raw chunk */ + if(H5D__chunk_direct_read(dset, offset_copy, filters, buf) < 0) + HGOTO_ERROR(H5E_DATASET, H5E_READERROR, FAIL, "can't read unprocessed chunk data") + + break; + } + + case H5VL_NATIVE_DATASET_CHUNK_WRITE: + { + uint32_t filters = HDva_arg(arguments, uint32_t); + const hsize_t *offset = HDva_arg(arguments, const hsize_t *); + uint32_t data_size_32 = HDva_arg(arguments, uint32_t); + const void *buf = HDva_arg(arguments, const void *); + hsize_t offset_copy[H5O_LAYOUT_NDIMS]; /* Internal copy of chunk offset */ + + dset = (H5D_t *)obj; + + /* Check arguments */ + if(NULL == dset->oloc.file) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "dataset is not associated with a file") + if(H5D_CHUNKED != dset->shared->layout.type) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a chunked dataset") + + /* Copy the user's offset array so we can be sure it's terminated properly. + * (we don't want to mess with the user's buffer). + */ + if(H5D__get_offset_copy(dset, offset, offset_copy) < 0) + HGOTO_ERROR(H5E_DATASET, H5E_CANTALLOC, FAIL, "failure to copy offset array") + + /* Write chunk */ + if(H5D__chunk_direct_write(dset, filters, offset_copy, data_size_32, buf) < 0) + HGOTO_ERROR(H5E_DATASET, H5E_WRITEERROR, FAIL, "can't write unprocessed chunk data") + + break; + } + + default: + HGOTO_ERROR(H5E_VOL, H5E_UNSUPPORTED, FAIL, "invalid optional operation") + } /* end switch */ + +done: + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5VL__native_dataset_optional() */ + + +/*------------------------------------------------------------------------- + * Function: H5VL__native_dataset_close + * + * Purpose: Handles the dataset close callback + * + * Return: Success: SUCCEED + * Failure: FAIL (dataset will not be closed) + * + *------------------------------------------------------------------------- + */ +herr_t +H5VL__native_dataset_close(void *dset, hid_t H5_ATTR_UNUSED dxpl_id, + void H5_ATTR_UNUSED **req) +{ + herr_t ret_value = SUCCEED; /* Return value */ + + FUNC_ENTER_PACKAGE + + if(H5D_close((H5D_t*)dset) < 0) + HGOTO_ERROR(H5E_DATASET, H5E_CANTDEC, FAIL, "can't close dataset") + +done: + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5VL__native_dataset_close() */ diff --git a/src/H5VLnative_datatype.c b/src/H5VLnative_datatype.c index 636b48b..a81edb4 100644 --- a/src/H5VLnative_datatype.c +++ b/src/H5VLnative_datatype.c @@ -10,4 +10,256 @@ * help@hdfgroup.org. * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ +/* + * Purpose: Datatype callbacks for the native VOL connector + * + */ + +#define H5T_FRIEND /* Suppress error about including H5Tpkg */ + +#include "H5private.h" /* Generic Functions */ +#include "H5Eprivate.h" /* Error handling */ +#include "H5Gprivate.h" /* Groups */ +#include "H5Iprivate.h" /* IDs */ +#include "H5Oprivate.h" /* Object headers */ +#include "H5Pprivate.h" /* Property lists */ +#include "H5Tpkg.h" /* Datatypes */ +#include "H5VLprivate.h" /* Virtual Object Layer */ + +#include "H5VLnative.h" /* Native VOL connector */ + + + +/*------------------------------------------------------------------------- + * Function: H5VL__native_datatype_commit + * + * Purpose: Handles the datatype commit callback + * + * Return: Success: datatype pointer + * Failure: NULL + * + *------------------------------------------------------------------------- + */ +void * +H5VL__native_datatype_commit(void *obj, const H5VL_loc_params_t *loc_params, const char *name, + hid_t type_id, hid_t lcpl_id, hid_t tcpl_id, hid_t H5_ATTR_UNUSED tapl_id, + hid_t H5_ATTR_UNUSED dxpl_id, void H5_ATTR_UNUSED **req) +{ + H5G_loc_t loc; /* Location to commit datatype */ + H5T_t *dt; /* Datatype for ID */ + H5T_t *type = NULL; /* copy of the original type which will be committed */ + void *ret_value = NULL; /* Return value */ + + FUNC_ENTER_PACKAGE + + /* check arguments */ + if(H5G_loc_real(obj, loc_params->obj_type, &loc) < 0) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, NULL, "not a file or file object") + + if(NULL == (dt = (H5T_t *)H5I_object_verify(type_id, H5I_DATATYPE))) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, NULL, "not a datatype") + + /* Check arguments. We cannot commit an immutable type because H5Tclose() + * normally fails on such types (try H5Tclose(H5T_NATIVE_INT)) but closing + * a named type should always succeed. + */ + if(H5T_STATE_NAMED == dt->shared->state || H5T_STATE_OPEN == dt->shared->state) + HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, NULL, "datatype is already committed") + if(H5T_STATE_IMMUTABLE == dt->shared->state) + HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, NULL, "datatype is immutable") + + /* Check for a "sensible" datatype to store on disk */ + if(H5T_is_sensible(dt) <= 0) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, NULL, "datatype is not sensible") + + /* Copy the datatype - the copied one will be the type that is + * committed, and attached to original datatype above the VOL + * layer + */ + if(NULL == (type = H5T_copy(dt, H5T_COPY_TRANSIENT))) + HGOTO_ERROR(H5E_DATATYPE, H5E_CANTINIT, NULL, "unable to copy"); + + /* Commit the datatype */ + if(NULL != name) { + /* H5Tcommit */ + if(H5T__commit_named(&loc, name, type, lcpl_id, tcpl_id) < 0) + HGOTO_ERROR(H5E_DATATYPE, H5E_CANTINIT, NULL, "unable to commit datatype") + } /* end if */ + else { + /* H5Tcommit_anon */ + if(H5T__commit_anon(loc.oloc->file, type, tcpl_id) < 0) + HGOTO_ERROR(H5E_DATATYPE, H5E_CANTINIT, NULL, "unable to commit datatype") + } /* end else */ + + ret_value = (void *)type; + +done: + if(NULL == ret_value && type) + H5T_close(type); + + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5VL__native_datatype_commit() */ + + +/*------------------------------------------------------------------------- + * Function: H5VL__native_datatype_open + * + * Purpose: Handles the datatype open callback + * + * Return: Success: datatype pointer + * Failure: NULL + * + *------------------------------------------------------------------------- + */ +void * +H5VL__native_datatype_open(void *obj, const H5VL_loc_params_t *loc_params, const char *name, + hid_t H5_ATTR_UNUSED tapl_id, hid_t H5_ATTR_UNUSED dxpl_id, void H5_ATTR_UNUSED **req) +{ + H5T_t *type = NULL; /* Datatype opened in file */ + H5G_loc_t loc; /* Group location of object to open */ + void *ret_value = NULL; + + FUNC_ENTER_PACKAGE + + if(H5G_loc_real(obj, loc_params->obj_type, &loc) < 0) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, NULL, "not a file or file object") + + /* Open the datatype */ + if(NULL == (type = H5T__open_name(&loc, name))) + HGOTO_ERROR(H5E_DATATYPE, H5E_CANTOPENOBJ, NULL, "unable to open named datatype") + + type->vol_obj = NULL; + + ret_value = (void *)type; + +done: + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5VL__native_datatype_open() */ + + +/*------------------------------------------------------------------------- + * Function: H5VL__native_datatype_get + * + * Purpose: Handles the datatype get callback + * + * Return: SUCCEED/FAIL + * + *------------------------------------------------------------------------- + */ +herr_t +H5VL__native_datatype_get(void *obj, H5VL_datatype_get_t get_type, + hid_t H5_ATTR_UNUSED dxpl_id, void H5_ATTR_UNUSED **req, va_list arguments) +{ + H5T_t *dt = (H5T_t *)obj; + herr_t ret_value = SUCCEED; /* Return value */ + + FUNC_ENTER_PACKAGE + + switch (get_type) { + case H5VL_DATATYPE_GET_BINARY: + { + ssize_t *nalloc = HDva_arg(arguments, ssize_t *); + void *buf = HDva_arg(arguments, void *); + size_t size = HDva_arg(arguments, size_t); + + if(H5T_encode(dt, (unsigned char *)buf, &size) < 0) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "can't determine serialized length of datatype") + + *nalloc = (ssize_t) size; + break; + } + + /* H5Tget_create_plist */ + case H5VL_DATATYPE_GET_TCPL: + { + hid_t *ret_id = HDva_arg(arguments, hid_t *); + + if(H5I_INVALID_HID == (*ret_id = H5T__get_create_plist(dt))) + HGOTO_ERROR(H5E_DATATYPE, H5E_CANTGET, FAIL, "can't get object creation info"); + + break; + } + + default: + HGOTO_ERROR(H5E_VOL, H5E_CANTGET, FAIL, "can't get this type of information from datatype") + } /* end switch */ + +done: + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5VL__native_datatype_get() */ + + +/*------------------------------------------------------------------------- + * Function: H5VL__native_datatype_specific + * + * Purpose: Handles the datatype specific callback + * + * Return: SUCCEED/FAIL + * + *------------------------------------------------------------------------- + */ +herr_t +H5VL__native_datatype_specific(void *obj, H5VL_datatype_specific_t specific_type, + hid_t H5_ATTR_UNUSED dxpl_id, void H5_ATTR_UNUSED **req, va_list arguments) +{ + H5T_t *dt = (H5T_t *)obj; + herr_t ret_value = SUCCEED; /* Return value */ + + FUNC_ENTER_PACKAGE + + switch(specific_type) { + case H5VL_DATATYPE_FLUSH: + { + hid_t type_id = HDva_arg(arguments, hid_t); + + /* To flush metadata and invoke flush callback if there is */ + if(H5O_flush_common(&dt->oloc, type_id) < 0) + HGOTO_ERROR(H5E_DATATYPE, H5E_CANTFLUSH, FAIL, "unable to flush datatype") + + break; + } + + case H5VL_DATATYPE_REFRESH: + { + hid_t type_id = HDva_arg(arguments, hid_t); + + /* Call private function to refresh datatype object */ + if((H5O_refresh_metadata(type_id, dt->oloc)) < 0) + HGOTO_ERROR(H5E_DATATYPE, H5E_CANTLOAD, FAIL, "unable to refresh datatype") + + break; + } + + default: + HGOTO_ERROR(H5E_VOL, H5E_UNSUPPORTED, FAIL, "invalid specific operation") + } /* end switch */ + +done: + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5VL__native_datatype_specific() */ + + +/*------------------------------------------------------------------------- + * Function: H5VL__native_datatype_close + * + * Purpose: Handles the datatype close callback + * + * Return: Success: SUCCEED + * Failure: FAIL (datatype will not be closed) + * + *------------------------------------------------------------------------- + */ +herr_t +H5VL__native_datatype_close(void *dt, hid_t H5_ATTR_UNUSED dxpl_id, void H5_ATTR_UNUSED **req) +{ + herr_t ret_value = SUCCEED; /* Return value */ + + FUNC_ENTER_PACKAGE + + if(H5T_close((H5T_t*)dt) < 0) + HGOTO_ERROR(H5E_SYM, H5E_CANTDEC, FAIL, "can't close datatype") + +done: + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5VL__native_datatype_close() */ diff --git a/src/H5VLnative_file.c b/src/H5VLnative_file.c index 636b48b..77d6844 100644 --- a/src/H5VLnative_file.c +++ b/src/H5VLnative_file.c @@ -10,4 +10,802 @@ * help@hdfgroup.org. * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ +/* + * Purpose: File callbacks for the native VOL connector + * + */ + +#define H5F_FRIEND /* Suppress error about including H5Fpkg */ + +#include "H5private.h" /* Generic Functions */ +#include "H5ACprivate.h" /* Metadata cache */ +#include "H5Cprivate.h" /* Cache */ +#include "H5Eprivate.h" /* Error handling */ +#include "H5Fpkg.h" /* Files */ +#include "H5Gprivate.h" /* Groups */ +#include "H5Iprivate.h" /* IDs */ +#include "H5MFprivate.h" /* File memory management */ +#include "H5Pprivate.h" /* Property lists */ +#include "H5PBprivate.h" /* Page buffering */ +#include "H5VLprivate.h" /* Virtual Object Layer */ + +#include "H5VLnative.h" /* Native VOL connector */ + + + +/*------------------------------------------------------------------------- + * Function: H5VL__native_file_create + * + * Purpose: Handles the file create callback + * + * Return: Success: file pointer + * Failure: NULL + * + *------------------------------------------------------------------------- + */ +void * +H5VL__native_file_create(const char *name, unsigned flags, hid_t fcpl_id, hid_t fapl_id, + hid_t H5_ATTR_UNUSED dxpl_id, void H5_ATTR_UNUSED **req) +{ + H5F_t *new_file = NULL; + void *ret_value = NULL; + + FUNC_ENTER_PACKAGE + + /* Adjust bit flags by turning on the creation bit and making sure that + * the EXCL or TRUNC bit is set. All newly-created files are opened for + * reading and writing. + */ + if(0 == (flags & (H5F_ACC_EXCL|H5F_ACC_TRUNC))) + flags |= H5F_ACC_EXCL; /* default */ + flags |= H5F_ACC_RDWR | H5F_ACC_CREAT; + + /* Create the file */ + if(NULL == (new_file = H5F_open(name, flags, fcpl_id, fapl_id))) + HGOTO_ERROR(H5E_FILE, H5E_CANTOPENFILE, NULL, "unable to create file") + new_file->id_exists = TRUE; + + ret_value = (void *)new_file; + +done: + if(NULL == ret_value && new_file) + if(H5F__close(new_file) < 0) + HDONE_ERROR(H5E_FILE, H5E_CANTCLOSEFILE, NULL, "problems closing file") + + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5VL__native_file_create() */ + + +/*------------------------------------------------------------------------- + * Function: H5VL__native_file_open + * + * Purpose: Handles the file open callback + * + * Return: Success: file pointer + * Failure: NULL + * + *------------------------------------------------------------------------- + */ +void * +H5VL__native_file_open(const char *name, unsigned flags, hid_t fapl_id, + hid_t H5_ATTR_UNUSED dxpl_id, void H5_ATTR_UNUSED **req) +{ + H5F_t *new_file = NULL; + void *ret_value = NULL; + + FUNC_ENTER_PACKAGE + + /* Open the file */ + if(NULL == (new_file = H5F_open(name, flags, H5P_FILE_CREATE_DEFAULT, fapl_id))) + HGOTO_ERROR(H5E_FILE, H5E_CANTOPENFILE, NULL, "unable to open file") + new_file->id_exists = TRUE; + + ret_value = (void *)new_file; + +done: + if(NULL == ret_value && new_file && H5F_try_close(new_file, NULL) < 0) + HDONE_ERROR(H5E_FILE, H5E_CANTCLOSEFILE, NULL, "problems closing file") + + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5VL__native_file_open() */ + + +/*------------------------------------------------------------------------- + * Function: H5VL__native_file_get + * + * Purpose: Handles the file get callback + * + * Return: SUCCEED/FAIL + * + *------------------------------------------------------------------------- + */ +herr_t +H5VL__native_file_get(void *obj, H5VL_file_get_t get_type, + hid_t H5_ATTR_UNUSED dxpl_id, void H5_ATTR_UNUSED **req, va_list arguments) +{ + H5F_t *f = NULL; /* File struct */ + herr_t ret_value = SUCCEED; /* Return value */ + + FUNC_ENTER_PACKAGE + + switch(get_type) { + /* H5Fget_access_plist */ + case H5VL_FILE_GET_FAPL: + { + H5P_genplist_t *new_plist; /* New property list */ + hid_t *plist_id = HDva_arg(arguments, hid_t *); + + f = (H5F_t *)obj; + + /* Retrieve the file's access property list */ + if((*plist_id = H5F_get_access_plist(f, TRUE)) < 0) + HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, FAIL, "can't get file access property list") + + if(NULL == (new_plist = (H5P_genplist_t *)H5I_object(*plist_id))) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a property list") + break; + } + + /* H5Fget_create_plist */ + case H5VL_FILE_GET_FCPL: + { + H5P_genplist_t *plist; /* Property list */ + hid_t *plist_id = HDva_arg(arguments, hid_t *); + + f = (H5F_t *)obj; + if(NULL == (plist = (H5P_genplist_t *)H5I_object(f->shared->fcpl_id))) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a property list") + + /* Create the property list object to return */ + if((*plist_id = H5P_copy_plist(plist, TRUE)) < 0) + HGOTO_ERROR(H5E_PLIST, H5E_CANTINIT, FAIL, "unable to copy file creation properties") + + break; + } + + /* H5Fget_obj_count */ + case H5VL_FILE_GET_OBJ_COUNT: + { + unsigned types = HDva_arg(arguments, unsigned); + ssize_t *ret = HDva_arg(arguments, ssize_t *); + size_t obj_count = 0; /* Number of opened objects */ + + f = (H5F_t *)obj; + /* Perform the query */ + if(H5F_get_obj_count(f, types, TRUE, &obj_count) < 0) + HGOTO_ERROR(H5E_FILE, H5E_BADITER, FAIL, "H5F_get_obj_count failed") + + /* Set the return value */ + *ret = (ssize_t)obj_count; + break; + } + + /* H5Fget_obj_ids */ + case H5VL_FILE_GET_OBJ_IDS: + { + unsigned types = HDva_arg(arguments, unsigned); + size_t max_objs = HDva_arg(arguments, size_t); + hid_t *oid_list = HDva_arg(arguments, hid_t *); + ssize_t *ret = HDva_arg(arguments, ssize_t *); + size_t obj_count = 0; /* Number of opened objects */ + + f = (H5F_t *)obj; + /* Perform the query */ + if(H5F_get_obj_ids(f, types, max_objs, oid_list, TRUE, &obj_count) < 0) + HGOTO_ERROR(H5E_FILE, H5E_BADITER, FAIL, "H5F_get_obj_ids failed") + + /* Set the return value */ + *ret = (ssize_t)obj_count; + break; + } + + /* H5Fget_intent */ + case H5VL_FILE_GET_INTENT: + { + unsigned *intent_flags = HDva_arg(arguments, unsigned *); + + f = (H5F_t *)obj; + + /* HDF5 uses some flags internally that users don't know about. + * Simplify things for them so that they only get either H5F_ACC_RDWR + * or H5F_ACC_RDONLY and any SWMR flags. + */ + if(H5F_INTENT(f) & H5F_ACC_RDWR) { + *intent_flags = H5F_ACC_RDWR; + + /* Check for SWMR write access on the file */ + if(H5F_INTENT(f) & H5F_ACC_SWMR_WRITE) + *intent_flags |= H5F_ACC_SWMR_WRITE; + } /* end if */ + else { + *intent_flags = H5F_ACC_RDONLY; + + /* Check for SWMR read access on the file */ + if(H5F_INTENT(f) & H5F_ACC_SWMR_READ) + *intent_flags |= H5F_ACC_SWMR_READ; + } /* end else */ + + break; + } + + /* H5Fget_name */ + case H5VL_FILE_GET_NAME: + { + H5I_type_t type = (H5I_type_t)HDva_arg(arguments, int); /* enum work-around */ + size_t size = HDva_arg(arguments, size_t); + char *name = HDva_arg(arguments, char *); + ssize_t *ret = HDva_arg(arguments, ssize_t *); + size_t len; + + if(NULL == (f = H5F__get_file(obj, type))) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a file or file object") + + len = HDstrlen(H5F_OPEN_NAME(f)); + + if(name) { + HDstrncpy(name, H5F_OPEN_NAME(f), MIN(len + 1,size)); + if(len >= size) + name[size-1]='\0'; + } /* end if */ + + /* Set the return value for the API call */ + *ret = (ssize_t)len; + break; + } + + default: + HGOTO_ERROR(H5E_VOL, H5E_CANTGET, FAIL, "can't get this type of information") + } /* end switch */ + +done: + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5VL__native_file_get() */ + + +/*------------------------------------------------------------------------- + * Function: H5VL__native_file_specific + * + * Purpose: Handles the file specific callback + * + * Return: SUCCEED/FAIL + * + *------------------------------------------------------------------------- + */ +herr_t +H5VL__native_file_specific(void *obj, H5VL_file_specific_t specific_type, + hid_t H5_ATTR_UNUSED dxpl_id, void H5_ATTR_UNUSED **req, va_list arguments) +{ + herr_t ret_value = SUCCEED; /* Return value */ + + FUNC_ENTER_PACKAGE + + switch(specific_type) { + /* H5Fflush */ + case H5VL_FILE_FLUSH: + { + H5I_type_t type = (H5I_type_t)HDva_arg(arguments, int); /* enum work-around */ + H5F_scope_t scope = (H5F_scope_t)HDva_arg(arguments, int); /* enum work-around */ + H5F_t *f = NULL; /* File to flush */ + + /* Get the file for the object */ + if(NULL == (f = H5F__get_file(obj, type))) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a file or file object") + + /* Nothing to do if the file is read only. This determination is + * made at the shared open(2) flags level, implying that opening a + * file twice, once for read-only and once for read-write, and then + * calling H5Fflush() with the read-only handle, still causes data + * to be flushed. + */ + if(H5F_ACC_RDWR & H5F_INTENT(f)) { + /* Flush other files, depending on scope */ + if(H5F_SCOPE_GLOBAL == scope) { + /* Call the flush routine for mounted file hierarchies */ + if(H5F_flush_mounts(f) < 0) + HGOTO_ERROR(H5E_FILE, H5E_CANTFLUSH, FAIL, "unable to flush mounted file hierarchy") + } /* end if */ + else { + /* Call the flush routine, for this file */ + if(H5F__flush(f) < 0) + HGOTO_ERROR(H5E_FILE, H5E_CANTFLUSH, FAIL, "unable to flush file's cached information") + } /* end else */ + } /* end if */ + break; + } + + /* H5Freopen */ + case H5VL_FILE_REOPEN: + { + void **ret = HDva_arg(arguments, void **); + H5F_t *new_file = NULL; + + /* Reopen the file through the VOL connector */ + if(NULL == (new_file = H5F__reopen((H5F_t *)obj))) + HGOTO_ERROR(H5E_FILE, H5E_CANTINIT, FAIL, "unable to reopen file") + new_file->id_exists = TRUE; + + *ret = (void *)new_file; + break; + } + + /* H5Fmount */ + case H5VL_FILE_MOUNT: + { + H5I_type_t type = (H5I_type_t)HDva_arg(arguments, int); /* enum work-around */ + const char *name = HDva_arg(arguments, const char *); + H5F_t *child = HDva_arg(arguments, H5F_t *); + hid_t plist_id = HDva_arg(arguments, hid_t); + H5G_loc_t loc; + + if(H5G_loc_real(obj, type, &loc) < 0) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a file or file object") + + /* Do the mount */ + if(H5F__mount(&loc, name, child, plist_id) < 0) + HGOTO_ERROR(H5E_FILE, H5E_MOUNT, FAIL, "unable to mount file") + + break; + } + + /* H5Funmount */ + case H5VL_FILE_UNMOUNT: + { + H5I_type_t type = (H5I_type_t)HDva_arg(arguments, int); /* enum work-around */ + const char *name = HDva_arg(arguments, const char *); + H5G_loc_t loc; + + if(H5G_loc_real(obj, type, &loc) < 0) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a file or file object") + + /* Unmount */ + if(H5F__unmount(&loc, name) < 0) + HGOTO_ERROR(H5E_FILE, H5E_MOUNT, FAIL, "unable to unmount file") + + break; + } + + /* H5Fis_accessible */ + case H5VL_FILE_IS_ACCESSIBLE: + { + hid_t fapl_id = HDva_arg(arguments, hid_t); + const char *name = HDva_arg(arguments, const char *); + htri_t *ret = HDva_arg(arguments, htri_t *); + + /* Call private routine */ + if((*ret = H5F__is_hdf5(name, fapl_id)) < 0) + HGOTO_ERROR(H5E_IO, H5E_CANTINIT, FAIL, "error in HDF5 file check") + break; + } + + default: + HGOTO_ERROR(H5E_VOL, H5E_UNSUPPORTED, FAIL, "invalid specific operation") + } /* end switch */ + +done: + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5VL__native_file_specific() */ + + +/*------------------------------------------------------------------------- + * Function: H5VL__native_file_optional + * + * Purpose: Handles the file optional callback + * + * Return: SUCCEED/FAIL + * + *------------------------------------------------------------------------- + */ +herr_t +H5VL__native_file_optional(void *obj, hid_t H5_ATTR_UNUSED dxpl_id, void H5_ATTR_UNUSED **req, va_list arguments) +{ + H5F_t *f = NULL; /* File */ + H5VL_native_file_optional_t optional_type = HDva_arg(arguments, H5VL_native_file_optional_t); + herr_t ret_value = SUCCEED; /* Return value */ + + FUNC_ENTER_PACKAGE + + f = (H5F_t *)obj; + switch(optional_type) { + /* H5Fget_filesize */ + case H5VL_NATIVE_FILE_GET_SIZE: + { + haddr_t max_eof_eoa; /* Maximum of the EOA & EOF */ + haddr_t base_addr; /* Base address for the file */ + hsize_t *size = HDva_arg(arguments, hsize_t *); + + /* Go get the actual file size */ + if(H5F__get_max_eof_eoa(f, &max_eof_eoa) < 0) + HGOTO_ERROR(H5E_FILE, H5E_CANTGET, FAIL, "file can't get max eof/eoa ") + + base_addr = H5FD_get_base_addr(f->shared->lf); + + if(size) + *size = (hsize_t)(max_eof_eoa + base_addr); /* Convert relative base address for file to absolute address */ + + break; + } + + /* H5Fget_file_image */ + case H5VL_NATIVE_FILE_GET_FILE_IMAGE: + { + void *buf_ptr = HDva_arg(arguments, void *); + ssize_t *ret = HDva_arg(arguments, ssize_t *); + size_t buf_len = HDva_arg(arguments, size_t ); + + /* Do the actual work */ + if((*ret = H5F__get_file_image(f, buf_ptr, buf_len)) < 0) + HGOTO_ERROR(H5E_FILE, H5E_CANTGET, FAIL, "get file image failed") + break; + } + + /* H5Fget_freespace */ + case H5VL_NATIVE_FILE_GET_FREE_SPACE: + { + hsize_t tot_space; /* Amount of free space in the file */ + hssize_t *ret = HDva_arg(arguments, hssize_t *); + + /* Go get the actual amount of free space in the file */ + if(H5MF_get_freespace(f, &tot_space, NULL) < 0) + HGOTO_ERROR(H5E_FILE, H5E_CANTGET, FAIL, "unable to check free space for file") + *ret = (hssize_t)tot_space; + break; + } + + /* H5Fget_free_sections */ + case H5VL_NATIVE_FILE_GET_FREE_SECTIONS: + { + H5F_sect_info_t *sect_info = HDva_arg(arguments, H5F_sect_info_t *); + ssize_t *ret = HDva_arg(arguments, ssize_t *); + H5F_mem_t type = (H5F_mem_t)HDva_arg(arguments, int); /* enum work-around */ + size_t nsects = HDva_arg(arguments, size_t); + + /* Go get the free-space section information in the file */ + if((*ret = H5MF_get_free_sections(f, type, nsects, sect_info)) < 0) + HGOTO_ERROR(H5E_FILE, H5E_CANTGET, FAIL, "unable to check free space for file") + break; + } + + /* H5Fget_info1/2 */ + case H5VL_NATIVE_FILE_GET_INFO: + { + H5I_type_t type = (H5I_type_t)HDva_arg(arguments, int); /* enum work-around */ + H5F_info2_t *finfo = HDva_arg(arguments, H5F_info2_t *); + + /* Get the file struct. This call is careful to not return the file pointer + * for the top file in a mount hierarchy. + */ + if(NULL == (f = H5F__get_file(obj, type))) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "could not get a file struct") + + /* Get the file info */ + if(H5F__get_info(f, finfo) < 0) + HGOTO_ERROR(H5E_FILE, H5E_CANTGET, FAIL, "unable to retrieve file info") + + break; + } + + /* H5Fget_mdc_config */ + case H5VL_NATIVE_FILE_GET_MDC_CONF: + { + H5AC_cache_config_t *config_ptr = HDva_arg(arguments, H5AC_cache_config_t *); + + /* Go get the resize configuration */ + if(H5AC_get_cache_auto_resize_config(f->shared->cache, config_ptr) < 0) + HGOTO_ERROR(H5E_CACHE, H5E_SYSTEM, FAIL, "H5AC_get_cache_auto_resize_config() failed.") + break; + } + + /* H5Fget_mdc_hit_rate */ + case H5VL_NATIVE_FILE_GET_MDC_HR: + { + double *hit_rate_ptr = HDva_arg(arguments, double *); + + /* Go get the current hit rate */ + if(H5AC_get_cache_hit_rate(f->shared->cache, hit_rate_ptr) < 0) + HGOTO_ERROR(H5E_CACHE, H5E_SYSTEM, FAIL, "H5AC_get_cache_hit_rate() failed.") + break; + } + + /* H5Fget_mdc_size */ + case H5VL_NATIVE_FILE_GET_MDC_SIZE: + { + size_t *max_size_ptr = HDva_arg(arguments, size_t *); + size_t *min_clean_size_ptr = HDva_arg(arguments, size_t *); + size_t *cur_size_ptr = HDva_arg(arguments, size_t *); + int *cur_num_entries_ptr = HDva_arg(arguments, int *); + uint32_t cur_num_entries; + + /* Go get the size data */ + if(H5AC_get_cache_size(f->shared->cache, max_size_ptr, min_clean_size_ptr, + cur_size_ptr, &cur_num_entries) < 0) + HGOTO_ERROR(H5E_CACHE, H5E_SYSTEM, FAIL, "H5AC_get_cache_size() failed.") + + if(cur_num_entries_ptr != NULL) + *cur_num_entries_ptr = (int)cur_num_entries; + break; + } + + /* H5Fget_vfd_handle */ + case H5VL_NATIVE_FILE_GET_VFD_HANDLE: + { + void **file_handle = HDva_arg(arguments, void **); + hid_t fapl_id = HDva_arg(arguments, hid_t); + + /* Retrieve the VFD handle for the file */ + if(H5F_get_vfd_handle(f, fapl_id, file_handle) < 0) + HGOTO_ERROR(H5E_FILE, H5E_CANTGET, FAIL, "can't retrieve VFD handle") + break; + } + + /* H5Iget_file_id */ + case H5VL_NATIVE_FILE_GET_FILE_ID: + { + H5I_type_t type = (H5I_type_t)HDva_arg(arguments, int); /* enum work-around */ + hid_t *file_id = HDva_arg(arguments, hid_t *); + + if(NULL == (f = H5F__get_file(obj, type))) + HGOTO_ERROR(H5E_FILE, H5E_BADTYPE, FAIL, "not a file or file object") + if((*file_id = H5F__get_file_id(f)) < 0) + HGOTO_ERROR(H5E_FILE, H5E_CANTGET, FAIL, "can't get file ID") + break; + } + + /* H5Fclear_elink_file_cache */ + case H5VL_NATIVE_FILE_CLEAR_ELINK_CACHE: + { + /* Release the EFC */ + if(f->shared->efc) + if(H5F__efc_release(f->shared->efc) < 0) + HGOTO_ERROR(H5E_FILE, H5E_CANTRELEASE, FAIL, "can't release external file cache") + break; + } + + /* H5Freset_mdc_hit_rate_stats */ + case H5VL_NATIVE_FILE_RESET_MDC_HIT_RATE: + { + /* Reset the hit rate statistic */ + if(H5AC_reset_cache_hit_rate_stats(f->shared->cache) < 0) + HGOTO_ERROR(H5E_CACHE, H5E_SYSTEM, FAIL, "can't reset cache hit rate") + break; + } + + /* H5Fset_mdc_config */ + case H5VL_NATIVE_FILE_SET_MDC_CONFIG: + { + H5AC_cache_config_t *config_ptr = HDva_arg(arguments, H5AC_cache_config_t *); + + /* set the resize configuration */ + if(H5AC_set_cache_auto_resize_config(f->shared->cache, config_ptr) < 0) + HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "H5AC_set_cache_auto_resize_config() failed") + break; + } + + /* H5Fget_metadata_read_retry_info */ + case H5VL_NATIVE_FILE_GET_METADATA_READ_RETRY_INFO: + { + H5F_retry_info_t *info = HDva_arg(arguments, H5F_retry_info_t *); + + if(H5F_get_metadata_read_retry_info(f, info) < 0) + HGOTO_ERROR(H5E_CACHE, H5E_SYSTEM, FAIL, "can't get metadata read retry info") + + break; + } + + /* H5Fstart_swmr_write */ + case H5VL_NATIVE_FILE_START_SWMR_WRITE: + { + if(H5F__start_swmr_write(f) < 0) + HGOTO_ERROR(H5E_CACHE, H5E_SYSTEM, FAIL, "can't start SWMR write") + + break; + } + + /* H5Fstart_mdc_logging */ + case H5VL_NATIVE_FILE_START_MDC_LOGGING: + { + /* Call mdc logging function */ + if(H5C_start_logging(f->shared->cache) < 0) + HGOTO_ERROR(H5E_FILE, H5E_LOGFAIL, FAIL, "unable to start mdc logging") + + break; + } + + /* H5Fstop_mdc_logging */ + case H5VL_NATIVE_FILE_STOP_MDC_LOGGING: + { + /* Call mdc logging function */ + if(H5C_stop_logging(f->shared->cache) < 0) + HGOTO_ERROR(H5E_FILE, H5E_LOGFAIL, FAIL, "unable to stop mdc logging") + + break; + } + + /* H5Fget_mdc_logging_status */ + case H5VL_NATIVE_FILE_GET_MDC_LOGGING_STATUS: + { + hbool_t *is_enabled = HDva_arg(arguments, hbool_t *); + hbool_t *is_currently_logging = HDva_arg(arguments, hbool_t *); + + /* Call mdc logging function */ + if(H5C_get_logging_status(f->shared->cache, is_enabled, is_currently_logging) < 0) + HGOTO_ERROR(H5E_FILE, H5E_LOGFAIL, FAIL, "unable to get logging status") + + break; + } + + /* H5Fformat_convert */ + case H5VL_NATIVE_FILE_FORMAT_CONVERT: + { + /* Convert the format */ + if(H5F__format_convert(f) < 0) + HGOTO_ERROR(H5E_FILE, H5E_CANTCONVERT, FAIL, "can't convert file format") + + break; + } + + /* H5Freset_page_buffering_stats */ + case H5VL_NATIVE_FILE_RESET_PAGE_BUFFERING_STATS: + { + /* Sanity check */ + if(NULL == f->shared->page_buf) + HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "page buffering not enabled on file") + + /* Reset the statistics */ + if(H5PB_reset_stats(f->shared->page_buf) < 0) + HGOTO_ERROR(H5E_FILE, H5E_CANTGET, FAIL, "can't reset stats for page buffering") + + break; + } + + /* H5Fget_page_buffering_stats */ + case H5VL_NATIVE_FILE_GET_PAGE_BUFFERING_STATS: + { + unsigned *accesses = HDva_arg(arguments, unsigned *); + unsigned *hits = HDva_arg(arguments, unsigned *); + unsigned *misses = HDva_arg(arguments, unsigned *); + unsigned *evictions = HDva_arg(arguments, unsigned *); + unsigned *bypasses = HDva_arg(arguments, unsigned *); + + /* Sanity check */ + if(NULL == f->shared->page_buf) + HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "page buffering not enabled on file") + + /* Get the statistics */ + if(H5PB_get_stats(f->shared->page_buf, accesses, hits, misses, evictions, bypasses) < 0) + HGOTO_ERROR(H5E_FILE, H5E_CANTGET, FAIL, "can't retrieve stats for page buffering") + + break; + } + + /* H5Fget_mdc_image_info */ + case H5VL_NATIVE_FILE_GET_MDC_IMAGE_INFO: + { + haddr_t *image_addr = HDva_arg(arguments, haddr_t *); + hsize_t *image_len = HDva_arg(arguments, hsize_t *); + + /* Go get the address and size of the cache image */ + if(H5AC_get_mdc_image_info(f->shared->cache, image_addr, image_len) < 0) + HGOTO_ERROR(H5E_FILE, H5E_CANTGET, FAIL, "can't retrieve cache image info") + + break; + } + + /* H5Fget_eoa */ + case H5VL_NATIVE_FILE_GET_EOA: + { + haddr_t *eoa = HDva_arg(arguments, haddr_t *); + haddr_t rel_eoa; /* Relative address of EOA */ + + /* Sanity check */ + HDassert(eoa); + + /* This routine will work only for drivers with this feature enabled.*/ + /* We might introduce a new feature flag in the future */ + if(!H5F_HAS_FEATURE(f, H5FD_FEAT_SUPPORTS_SWMR_IO)) + HGOTO_ERROR(H5E_FILE, H5E_BADVALUE, FAIL, "must use a SWMR-compatible VFD for this public routine") + + /* The real work */ + if(HADDR_UNDEF == (rel_eoa = H5F_get_eoa(f, H5FD_MEM_DEFAULT))) + HGOTO_ERROR(H5E_FILE, H5E_CANTGET, FAIL, "get_eoa request failed") + + /* Set return value */ + /* (Note compensating for base address subtraction in internal routine) */ + *eoa = rel_eoa + H5F_get_base_addr(f); + + break; + } + + /* H5Fincrement_filesize */ + case H5VL_NATIVE_FILE_INCR_FILESIZE: + { + hsize_t increment = HDva_arg(arguments, hsize_t); + haddr_t max_eof_eoa; /* Maximum of the relative EOA & EOF */ + + /* This public routine will work only for drivers with this feature enabled.*/ + /* We might introduce a new feature flag in the future */ + if(!H5F_HAS_FEATURE(f, H5FD_FEAT_SUPPORTS_SWMR_IO)) + HGOTO_ERROR(H5E_FILE, H5E_BADVALUE, FAIL, "must use a SWMR-compatible VFD for this public routine") + + /* Get the maximum of EOA and EOF */ + if(H5F__get_max_eof_eoa(f, &max_eof_eoa) < 0) + HGOTO_ERROR(H5E_FILE, H5E_CANTGET, FAIL, "file can't get max eof/eoa ") + + /* Set EOA to the maximum value + increment */ + if(H5F__set_eoa(f, H5FD_MEM_DEFAULT, max_eof_eoa + increment) < 0) + HGOTO_ERROR(H5E_FILE, H5E_CANTSET, FAIL, "driver set_eoa request failed") + + break; + } + + /* H5Fset_latest_format, H5Fset_libver_bounds */ + case H5VL_NATIVE_FILE_SET_LIBVER_BOUNDS: + { + H5F_libver_t low = (H5F_libver_t)HDva_arg(arguments, int); /* enum work-around */ + H5F_libver_t high = (H5F_libver_t)HDva_arg(arguments, int); /* enum work-around */ + + /* Call internal set_libver_bounds function */ + if(H5F__set_libver_bounds(f, low, high) < 0) + HGOTO_ERROR(H5E_FILE, H5E_CANTSET, FAIL, "cannot set low/high bounds") + + break; + } + + default: + HGOTO_ERROR(H5E_VOL, H5E_UNSUPPORTED, FAIL, "invalid optional operation") + } /* end switch */ + +done: + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5VL__native_file_optional() */ + + +/*------------------------------------------------------------------------- + * Function: H5VL__native_file_close + * + * Purpose: Handles the file close callback + * + * Return: Success: SUCCEED + * Failure: FAIL (file will not be closed) + * + *------------------------------------------------------------------------- + */ +herr_t +H5VL__native_file_close(void *file, hid_t H5_ATTR_UNUSED dxpl_id, + void H5_ATTR_UNUSED **req) +{ + int nref; + H5F_t *f = (H5F_t *)file; + hid_t file_id = H5I_INVALID_HID; + herr_t ret_value = SUCCEED; /* Return value */ + + FUNC_ENTER_PACKAGE + + /* This routine should only be called when a file ID's ref count drops to zero */ + HDassert(H5F_ID_EXISTS(f)); + + /* Flush file if this is the last reference to this id and we have write + * intent, unless it will be flushed by the "shared" file being closed. + * This is only necessary to replicate previous behaviour, and could be + * disabled by an option/property to improve performance. + */ + if((H5F_NREFS(f) > 1) && (H5F_INTENT(f) & H5F_ACC_RDWR)) { + /* Get the file ID corresponding to the H5F_t struct */ + if(H5I_find_id(f, H5I_FILE, &file_id) < 0 || H5I_INVALID_HID == file_id) + HGOTO_ERROR(H5E_ATOM, H5E_CANTGET, FAIL, "invalid atom") + + /* Get the number of references outstanding for this file ID */ + if((nref = H5I_get_ref(file_id, FALSE)) < 0) + HGOTO_ERROR(H5E_ATOM, H5E_CANTGET, FAIL, "can't get ID ref count") + if(nref == 1) + if(H5F__flush(f) < 0) + HGOTO_ERROR(H5E_CACHE, H5E_CANTFLUSH, FAIL, "unable to flush cache") + } /* end if */ + + /* Close the file */ + if(H5F__close(f) < 0) + HGOTO_ERROR(H5E_FILE, H5E_CANTDEC, FAIL, "can't close file") + +done: + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5VL__native_file_close() */ diff --git a/src/H5VLnative_group.c b/src/H5VLnative_group.c index 636b48b..20b1b79 100644 --- a/src/H5VLnative_group.c +++ b/src/H5VLnative_group.c @@ -10,4 +10,354 @@ * help@hdfgroup.org. * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ +/* + * Purpose: Group callbacks for the native VOL connector + * + */ + +#define H5G_FRIEND /* Suppress error about including H5Gpkg */ + +#include "H5private.h" /* Generic Functions */ +#include "H5Eprivate.h" /* Error handling */ +#include "H5Gpkg.h" /* Groups */ +#include "H5Iprivate.h" /* IDs */ +#include "H5Oprivate.h" /* Object headers */ +#include "H5Pprivate.h" /* Property lists */ +#include "H5VLprivate.h" /* Virtual Object Layer */ + +#include "H5VLnative.h" /* Native VOL connector */ + + + +/*------------------------------------------------------------------------- + * Function: H5VL__native_group_create + * + * Purpose: Handles the group create callback + * + * Return: Success: group pointer + * Failure: NULL + * + *------------------------------------------------------------------------- + */ +void * +H5VL__native_group_create(void *obj, const H5VL_loc_params_t *loc_params, const char *name, + hid_t gcpl_id, hid_t H5_ATTR_UNUSED gapl_id, hid_t H5_ATTR_UNUSED dxpl_id, + void H5_ATTR_UNUSED **req) +{ + H5P_genplist_t *plist; /* Property list pointer */ + H5G_loc_t loc; /* Location to create group */ + H5G_t *grp = NULL; /* New group created */ + hid_t lcpl_id; + void *ret_value; + + FUNC_ENTER_PACKAGE + + /* Get the property list structure */ + if(NULL == (plist = (H5P_genplist_t *)H5I_object(gcpl_id))) + HGOTO_ERROR(H5E_ATOM, H5E_BADATOM, NULL, "can't find object for ID") + + /* Get creation properties */ + if(H5P_get(plist, H5VL_PROP_GRP_LCPL_ID, &lcpl_id) < 0) + HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, NULL, "can't get property value for lcpl id") + + /* Set up the location */ + if(H5G_loc_real(obj, loc_params->obj_type, &loc) < 0) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, NULL, "not a file or file object") + + /* if name is NULL then this is from H5Gcreate_anon */ + if(name == NULL) { + H5G_obj_create_t gcrt_info; /* Information for group creation */ + + /* Set up group creation info */ + gcrt_info.gcpl_id = gcpl_id; + gcrt_info.cache_type = H5G_NOTHING_CACHED; + HDmemset(&gcrt_info.cache, 0, sizeof(gcrt_info.cache)); + + /* Create the new group & get its ID */ + if(NULL == (grp = H5G__create(loc.oloc->file, &gcrt_info))) + HGOTO_ERROR(H5E_SYM, H5E_CANTINIT, NULL, "unable to create group") + } /* end if */ + /* otherwise it's from H5Gcreate */ + else { + /* Create the new group & get its ID */ + if(NULL == (grp = H5G__create_named(&loc, name, lcpl_id, gcpl_id))) + HGOTO_ERROR(H5E_SYM, H5E_CANTINIT, NULL, "unable to create group") + } /* end else */ + + ret_value = (void *)grp; + +done: + if(name == NULL) { + /* Release the group's object header, if it was created */ + if(grp) { + H5O_loc_t *oloc; /* Object location for group */ + + /* Get the new group's object location */ + if(NULL == (oloc = H5G_oloc(grp))) + HDONE_ERROR(H5E_SYM, H5E_CANTGET, NULL, "unable to get object location of group") + + /* Decrement refcount on group's object header in memory */ + if(H5O_dec_rc_by_loc(oloc) < 0) + HDONE_ERROR(H5E_SYM, H5E_CANTDEC, NULL, "unable to decrement refcount on newly created object") + } /* end if */ + } /* end if */ + + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5VL__native_group_create() */ + + +/*------------------------------------------------------------------------- + * Function: H5VL__native_group_open + * + * Purpose: Handles the group open callback + * + * Return: Success: group pointer + * Failure: NULL + * + *------------------------------------------------------------------------- + */ +void * +H5VL__native_group_open(void *obj, const H5VL_loc_params_t *loc_params, const char *name, + hid_t H5_ATTR_UNUSED gapl_id, hid_t H5_ATTR_UNUSED dxpl_id, void H5_ATTR_UNUSED **req) +{ + H5G_loc_t loc; /* Location to open group */ + H5G_t *grp = NULL; /* New group opend */ + void *ret_value; + + FUNC_ENTER_PACKAGE + + /* Set up the location */ + if(H5G_loc_real(obj, loc_params->obj_type, &loc) < 0) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, NULL, "not a file or file object") + + /* Open the group */ + if((grp = H5G__open_name(&loc, name)) == NULL) + HGOTO_ERROR(H5E_SYM, H5E_CANTOPENOBJ, NULL, "unable to open group") + + ret_value = (void *)grp; + +done: + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5VL__native_group_open() */ + + +/*------------------------------------------------------------------------- + * Function: H5VL__native_group_get + * + * Purpose: Handles the group get callback + * + * Return: SUCCEED/FAIL + * + *------------------------------------------------------------------------- + */ +herr_t +H5VL__native_group_get(void *obj, H5VL_group_get_t get_type, + hid_t H5_ATTR_UNUSED dxpl_id, void H5_ATTR_UNUSED **req, va_list arguments) +{ + herr_t ret_value = SUCCEED; /* Return value */ + + FUNC_ENTER_PACKAGE + + switch(get_type) { + /* H5Gget_create_plist */ + case H5VL_GROUP_GET_GCPL: + { + hid_t *new_gcpl_id = HDva_arg(arguments, hid_t *); + H5G_t *grp = (H5G_t *)obj; + + if((*new_gcpl_id = H5G_get_create_plist(grp)) < 0) + HGOTO_ERROR(H5E_ARGS, H5E_CANTGET, FAIL, "can't get creation property list for group") + break; + } + + /* H5Gget_info */ + case H5VL_GROUP_GET_INFO: + { + const H5VL_loc_params_t *loc_params = HDva_arg(arguments, const H5VL_loc_params_t *); + H5G_info_t *group_info = HDva_arg(arguments, H5G_info_t *); + H5G_loc_t loc; + + if(H5G_loc_real(obj, loc_params->obj_type, &loc) < 0) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a file or file object") + + if(loc_params->type == H5VL_OBJECT_BY_SELF) { + /* H5Gget_info */ + + /* Retrieve the group's information */ + if(H5G__obj_info(loc.oloc, group_info) < 0) + HGOTO_ERROR(H5E_SYM, H5E_CANTGET, FAIL, "can't retrieve group info") + } /* end if */ + else if(loc_params->type == H5VL_OBJECT_BY_NAME) { + /* H5Gget_info_by_name */ + + /* Retrieve the group's information */ + if(H5G__get_info_by_name(&loc, loc_params->loc_data.loc_by_name.name, group_info) < 0) + HGOTO_ERROR(H5E_SYM, H5E_CANTGET, FAIL, "can't retrieve group info") + } /* end else-if */ + else if(loc_params->type == H5VL_OBJECT_BY_IDX) { + /* H5Gget_info_by_idx */ + + /* Retrieve the group's information */ + if(H5G__get_info_by_idx(&loc, loc_params->loc_data.loc_by_idx.name, loc_params->loc_data.loc_by_idx.idx_type, + loc_params->loc_data.loc_by_idx.order, loc_params->loc_data.loc_by_idx.n, group_info) < 0) + HGOTO_ERROR(H5E_SYM, H5E_CANTGET, FAIL, "can't retrieve group info") + } /* end else-if */ + else + HGOTO_ERROR(H5E_VOL, H5E_UNSUPPORTED, FAIL, "unknown get info parameters") + break; + } + + default: + HGOTO_ERROR(H5E_VOL, H5E_CANTGET, FAIL, "can't get this type of information from group") + } /* end switch */ + +done: + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5VL__native_group_get() */ + + +/*------------------------------------------------------------------------- + * Function: H5VL__native_group_specific + * + * Purpose: Handles the group specific callback + * + * Return: SUCCEED/FAIL + * + *------------------------------------------------------------------------- + */ +herr_t +H5VL__native_group_specific(void *obj, H5VL_group_specific_t specific_type, + hid_t H5_ATTR_UNUSED dxpl_id, void H5_ATTR_UNUSED **req, va_list arguments) +{ + H5G_t *grp = (H5G_t *)obj; + herr_t ret_value = SUCCEED; /* Return value */ + + FUNC_ENTER_PACKAGE + + switch(specific_type) { + case H5VL_GROUP_FLUSH: + { + hid_t group_id = HDva_arg(arguments, hid_t); + + /* Flush object's metadata to file */ + if(H5O_flush_common(&grp->oloc, group_id) < 0) + HGOTO_ERROR(H5E_SYM, H5E_CANTFLUSH, FAIL, "unable to flush group") + + break; + } + + case H5VL_GROUP_REFRESH: + { + hid_t group_id = HDva_arg(arguments, hid_t); + + /* Call private function to refresh group object */ + if((H5O_refresh_metadata(group_id, grp->oloc)) < 0) + HGOTO_ERROR(H5E_SYM, H5E_CANTLOAD, FAIL, "unable to refresh group") + + break; + } + + default: + HGOTO_ERROR(H5E_VOL, H5E_UNSUPPORTED, FAIL, "invalid specific operation") + } /* end switch */ + +done: + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5VL__native_group_specific() */ + + +/*------------------------------------------------------------------------- + * Function: H5VL__native_group_optional + * + * Purpose: Handles the group optional callback + * + * Return: SUCCEED/FAIL + * + *------------------------------------------------------------------------- + */ +herr_t +H5VL__native_group_optional(void *obj, hid_t H5_ATTR_UNUSED dxpl_id, + void H5_ATTR_UNUSED **req, va_list arguments) +{ + H5VL_native_group_optional_t optional_type; + herr_t ret_value = SUCCEED; /* Return value */ + + FUNC_ENTER_PACKAGE + + optional_type = HDva_arg(arguments, H5VL_native_group_optional_t); + switch(optional_type) { +#ifndef H5_NO_DEPRECATED_SYMBOLS + /* H5Giterate (deprecated) */ + case H5VL_NATIVE_GROUP_ITERATE_OLD: + { + const H5VL_loc_params_t *loc_params = HDva_arg(arguments, const H5VL_loc_params_t *); + hsize_t idx = HDva_arg(arguments, hsize_t); + hsize_t *last_obj = HDva_arg(arguments, hsize_t *); + const H5G_link_iterate_t *lnk_op = HDva_arg(arguments, const H5G_link_iterate_t *); + void *op_data = HDva_arg(arguments, void *); + H5G_loc_t grp_loc; + + /* Get the location struct for the object */ + if(H5G_loc_real(obj, loc_params->obj_type, &grp_loc) < 0) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a file or file object") + + /* Call the actual iteration routine */ + if((ret_value = H5G_iterate(&grp_loc, loc_params->loc_data.loc_by_name.name, H5_INDEX_NAME, H5_ITER_INC, idx, last_obj, lnk_op, op_data)) < 0) + HERROR(H5E_VOL, H5E_BADITER, "error iterating over group's links"); + + break; + } + + /* H5Gget_objinfo (deprecated) */ + case H5VL_NATIVE_GROUP_GET_OBJINFO: + { + const H5VL_loc_params_t *loc_params = HDva_arg(arguments, const H5VL_loc_params_t *); + hbool_t follow_link = (hbool_t)HDva_arg(arguments, unsigned); + H5G_stat_t *statbuf = HDva_arg(arguments, H5G_stat_t *); + H5G_loc_t grp_loc; + + /* Get the location struct for the object */ + if(H5G_loc_real(obj, loc_params->obj_type, &grp_loc) < 0) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a file or file object") + + /* Call the actual group objinfo routine */ + if(H5G__get_objinfo(&grp_loc, loc_params->loc_data.loc_by_name.name, follow_link, statbuf) < 0) + HGOTO_ERROR(H5E_SYM, H5E_CANTGET, FAIL, "cannot stat object") + + break; + } +#endif /* H5_NO_DEPRECATED_SYMBOLS */ + + default: + HGOTO_ERROR(H5E_VOL, H5E_UNSUPPORTED, FAIL, "invalid optional operation") + } /* end switch */ + +done: + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5VL__native_group_optional() */ + + +/*------------------------------------------------------------------------- + * Function: H5VL__native_group_close + * + * Purpose: Handles the group close callback + * + * Return: Success: SUCCEED + * Failure: FAIL (group will not be closed) + * + *------------------------------------------------------------------------- + */ +herr_t +H5VL__native_group_close(void *grp, hid_t H5_ATTR_UNUSED dxpl_id, void H5_ATTR_UNUSED **req) +{ + herr_t ret_value = SUCCEED; /* Return value */ + + FUNC_ENTER_PACKAGE + + if(H5G_close((H5G_t *)grp) < 0) + HGOTO_ERROR(H5E_SYM, H5E_CLOSEERROR, FAIL, "can't close group") + +done: + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5VL__native_group_close() */ diff --git a/src/H5VLnative_link.c b/src/H5VLnative_link.c index 636b48b..6f276ad 100644 --- a/src/H5VLnative_link.c +++ b/src/H5VLnative_link.c @@ -10,4 +10,426 @@ * help@hdfgroup.org. * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ +/* + * Purpose: Link callbacks for the native VOL connector + * + */ + +#define H5L_FRIEND /* Suppress error about including H5Lpkg */ + +#include "H5private.h" /* Generic Functions */ +#include "H5Eprivate.h" /* Error handling */ +#include "H5Gprivate.h" /* Groups */ +#include "H5Iprivate.h" /* IDs */ +#include "H5Lpkg.h" /* Links */ +#include "H5Pprivate.h" /* Property lists */ +#include "H5VLprivate.h" /* Virtual Object Layer */ + +#include "H5VLnative.h" /* Native VOL connector */ + + + +/*------------------------------------------------------------------------- + * Function: H5VL__native_link_create + * + * Purpose: Handles the link create callback + * + * Return: SUCCEED/FAIL + * + *------------------------------------------------------------------------- + */ +herr_t +H5VL__native_link_create(H5VL_link_create_type_t create_type, void *obj, + const H5VL_loc_params_t *loc_params, hid_t lcpl_id, hid_t H5_ATTR_UNUSED lapl_id, + hid_t H5_ATTR_UNUSED dxpl_id, void H5_ATTR_UNUSED **req) +{ + H5P_genplist_t *plist; /* Property list pointer */ + herr_t ret_value = SUCCEED; /* Return value */ + + FUNC_ENTER_PACKAGE + + /* Get the plist structure */ + if(NULL == (plist = (H5P_genplist_t *)H5I_object(lcpl_id))) + HGOTO_ERROR(H5E_ATOM, H5E_BADATOM, FAIL, "can't find object for ID"); + + switch(create_type) { + case H5VL_LINK_CREATE_HARD: + { + H5G_loc_t cur_loc; + H5G_loc_t link_loc; + void *cur_obj; + H5VL_loc_params_t cur_params; + + if(H5P_get(plist, H5VL_PROP_LINK_TARGET, &cur_obj) < 0) + HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, FAIL, "can't get property value for current location id") + if(H5P_get(plist, H5VL_PROP_LINK_TARGET_LOC_PARAMS, &cur_params) < 0) + HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, FAIL, "can't get property value for current name") + + if(NULL != cur_obj && H5G_loc_real(cur_obj, cur_params.obj_type, &cur_loc) < 0) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a file or file object") + if(NULL != obj && H5G_loc_real(obj, loc_params->obj_type, &link_loc) < 0) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a file or file object") + + /* H5Lcreate_hard */ + if(H5VL_OBJECT_BY_NAME == cur_params.type) { + H5G_loc_t *cur_loc_p, *link_loc_p; + + /* Set up current & new location pointers */ + cur_loc_p = &cur_loc; + link_loc_p = &link_loc; + if(NULL == cur_obj) + cur_loc_p = link_loc_p; + else if(NULL == obj) + link_loc_p = cur_loc_p; + else if(cur_loc_p->oloc->file != link_loc_p->oloc->file) + HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "source and destination should be in the same file.") + + /* Create the link */ + if((ret_value = H5L_create_hard(cur_loc_p, cur_params.loc_data.loc_by_name.name, + link_loc_p, loc_params->loc_data.loc_by_name.name, lcpl_id)) < 0) + HGOTO_ERROR(H5E_LINK, H5E_CANTINIT, FAIL, "unable to create link") + } /* end if */ + else { /* H5Olink */ + /* Link to the object */ + if(H5L_link(&link_loc, loc_params->loc_data.loc_by_name.name, &cur_loc, lcpl_id) < 0) + HGOTO_ERROR(H5E_OHDR, H5E_CANTINIT, FAIL, "unable to create link") + } /* end else */ + break; + } + + case H5VL_LINK_CREATE_SOFT: + { + char *target_name; + H5G_loc_t link_loc; /* Group location for new link */ + + if(H5G_loc_real(obj, loc_params->obj_type, &link_loc) < 0) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a file or file object") + + if(H5P_get(plist, H5VL_PROP_LINK_TARGET_NAME, &target_name) < 0) + HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, FAIL, "can't get property value for targe name") + + /* Create the link */ + if((ret_value = H5L_create_soft(target_name, &link_loc, loc_params->loc_data.loc_by_name.name, lcpl_id)) < 0) + HGOTO_ERROR(H5E_LINK, H5E_CANTINIT, FAIL, "unable to create link") + break; + } + + case H5VL_LINK_CREATE_UD: + { + H5G_loc_t link_loc; /* Group location for new link */ + H5L_type_t link_type; + void *udata; + size_t udata_size; + + if(H5G_loc_real(obj, loc_params->obj_type, &link_loc) < 0) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a file or file object") + + if(H5P_get(plist, H5VL_PROP_LINK_TYPE, &link_type) < 0) + HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, FAIL, "can't get property value for link type") + if(H5P_get(plist, H5VL_PROP_LINK_UDATA, &udata) < 0) + HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, FAIL, "can't get property value for udata") + if(H5P_get(plist, H5VL_PROP_LINK_UDATA_SIZE, &udata_size) < 0) + HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, FAIL, "can't get property value for udata size") + + /* Create link */ + if(H5L__create_ud(&link_loc, loc_params->loc_data.loc_by_name.name, udata, udata_size, + link_type, lcpl_id) < 0) + HGOTO_ERROR(H5E_LINK, H5E_CANTINIT, FAIL, "unable to create link") + break; + } + + default: + HGOTO_ERROR(H5E_LINK, H5E_CANTINIT, FAIL, "invalid link creation call") + } /* end switch */ + +done: + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5VL__native_link_create() */ + + +/*------------------------------------------------------------------------- + * Function: H5VL__native_link_copy + * + * Purpose: Handles the link copy callback + * + * Return: SUCCEED/FAIL + * + *------------------------------------------------------------------------- + */ +herr_t +H5VL__native_link_copy(void *src_obj, const H5VL_loc_params_t *loc_params1, + void *dst_obj, const H5VL_loc_params_t *loc_params2, hid_t lcpl_id, + hid_t H5_ATTR_UNUSED lapl_id, hid_t H5_ATTR_UNUSED dxpl_id, + void H5_ATTR_UNUSED **req) +{ + H5G_loc_t src_loc, *src_loc_p; + H5G_loc_t dst_loc, *dst_loc_p; + herr_t ret_value = SUCCEED; /* Return value */ + + FUNC_ENTER_PACKAGE + + if(NULL != src_obj && H5G_loc_real(src_obj, loc_params1->obj_type, &src_loc) < 0) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a file or file object") + if(NULL != dst_obj && H5G_loc_real(dst_obj, loc_params2->obj_type, &dst_loc) < 0) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a file or file object") + + /* Set up src & dst location pointers */ + src_loc_p = &src_loc; + dst_loc_p = &dst_loc; + if(NULL == src_obj) + src_loc_p = dst_loc_p; + else if(NULL == dst_obj) + dst_loc_p = src_loc_p; + + /* Copy the link */ + if(H5L_move(src_loc_p, loc_params1->loc_data.loc_by_name.name, + dst_loc_p, loc_params2->loc_data.loc_by_name.name, + TRUE, lcpl_id) < 0) + HGOTO_ERROR(H5E_LINK, H5E_CANTCOPY, FAIL, "unable to copy link") + +done: + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5VL__native_link_copy() */ + + +/*------------------------------------------------------------------------- + * Function: H5VL__native_link_move + * + * Purpose: Handles the link move callback + * + * Return: SUCCEED/FAIL + * + *------------------------------------------------------------------------- + */ +herr_t +H5VL__native_link_move(void *src_obj, const H5VL_loc_params_t *loc_params1, + void *dst_obj, const H5VL_loc_params_t *loc_params2, hid_t lcpl_id, + hid_t H5_ATTR_UNUSED lapl_id, hid_t H5_ATTR_UNUSED dxpl_id, + void H5_ATTR_UNUSED **req) +{ + H5G_loc_t src_loc, *src_loc_p; + H5G_loc_t dst_loc, *dst_loc_p; + herr_t ret_value = SUCCEED; /* Return value */ + + FUNC_ENTER_PACKAGE + + if(NULL != src_obj && H5G_loc_real(src_obj, loc_params1->obj_type, &src_loc) < 0) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a file or file object") + if(NULL != dst_obj && H5G_loc_real(dst_obj, loc_params2->obj_type, &dst_loc) < 0) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a file or file object") + + /* Set up src & dst location pointers */ + src_loc_p = &src_loc; + dst_loc_p = &dst_loc; + if(NULL == src_obj) + src_loc_p = dst_loc_p; + else if(NULL == dst_obj) + dst_loc_p = src_loc_p; + + /* Move the link */ + if(H5L_move(src_loc_p, loc_params1->loc_data.loc_by_name.name, + dst_loc_p, loc_params2->loc_data.loc_by_name.name, + FALSE, lcpl_id) < 0) + HGOTO_ERROR(H5E_LINK, H5E_CANTMOVE, FAIL, "unable to move link") + +done: + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5VL__native_link_move() */ + + +/*------------------------------------------------------------------------- + * Function: H5VL__native_link_get + * + * Purpose: Handles the link get callback + * + * Return: SUCCEED/FAIL + * + *------------------------------------------------------------------------- + */ +herr_t +H5VL__native_link_get(void *obj, const H5VL_loc_params_t *loc_params, H5VL_link_get_t get_type, + hid_t H5_ATTR_UNUSED dxpl_id, void H5_ATTR_UNUSED **req, va_list arguments) +{ + H5G_loc_t loc; + herr_t ret_value = SUCCEED; /* Return value */ + + FUNC_ENTER_PACKAGE + + if(H5G_loc_real(obj, loc_params->obj_type, &loc) < 0) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a file or file object") + + switch(get_type) { + /* H5Lget_info/H5Lget_info_by_idx */ + case H5VL_LINK_GET_INFO: + { + H5L_info_t *linfo = HDva_arg(arguments, H5L_info_t *); + + /* Get the link information */ + if(loc_params->type == H5VL_OBJECT_BY_NAME) { /* H5Lget_info */ + if(H5L_get_info(&loc, loc_params->loc_data.loc_by_name.name, linfo) < 0) + HGOTO_ERROR(H5E_LINK, H5E_NOTFOUND, FAIL, "unable to get link info") + } /* end if */ + else if(loc_params->type == H5VL_OBJECT_BY_IDX) { /* H5Lget_info_by_idx */ + if(H5L_get_info_by_idx(&loc, loc_params->loc_data.loc_by_idx.name, loc_params->loc_data.loc_by_idx.idx_type, + loc_params->loc_data.loc_by_idx.order, loc_params->loc_data.loc_by_idx.n, linfo) < 0) + HGOTO_ERROR(H5E_LINK, H5E_NOTFOUND, FAIL, "unable to get link info") + } /* end else-if */ + else + HGOTO_ERROR(H5E_LINK, H5E_NOTFOUND, FAIL, "unable to get link info") + break; + } + + /* H5Lget_name_by_idx */ + case H5VL_LINK_GET_NAME: + { + char *name = HDva_arg(arguments, char *); + size_t size = HDva_arg(arguments, size_t); + ssize_t *ret = HDva_arg(arguments, ssize_t *); + + /* Get the link name */ + if((*ret = H5L_get_name_by_idx(&loc, loc_params->loc_data.loc_by_idx.name, loc_params->loc_data.loc_by_idx.idx_type, + loc_params->loc_data.loc_by_idx.order, loc_params->loc_data.loc_by_idx.n, name, size)) < 0) + HGOTO_ERROR(H5E_LINK, H5E_NOTFOUND, FAIL, "unable to get link info") + + break; + } + + /* H5Lget_val/H5Lget_val_by_idx */ + case H5VL_LINK_GET_VAL: + { + void *buf = HDva_arg(arguments, void *); + size_t size = HDva_arg(arguments, size_t); + + /* Get the link information */ + if(loc_params->type == H5VL_OBJECT_BY_NAME) { /* H5Lget_val */ + if(H5L_get_val(&loc, loc_params->loc_data.loc_by_name.name, buf, size) < 0) + HGOTO_ERROR(H5E_LINK, H5E_NOTFOUND, FAIL, "unable to get link value") + } + else if(loc_params->type == H5VL_OBJECT_BY_IDX) { /* H5Lget_val_by_idx */ + + if(H5L_get_val_by_idx(&loc, loc_params->loc_data.loc_by_idx.name, loc_params->loc_data.loc_by_idx.idx_type, + loc_params->loc_data.loc_by_idx.order, loc_params->loc_data.loc_by_idx.n, buf, size) < 0) + HGOTO_ERROR(H5E_LINK, H5E_NOTFOUND, FAIL, "unable to get link val") + } + else + HGOTO_ERROR(H5E_LINK, H5E_NOTFOUND, FAIL, "unable to get link val") + + break; + } + + default: + HGOTO_ERROR(H5E_VOL, H5E_CANTGET, FAIL, "can't get this type of information from link") + } /* end switch */ + +done: + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5VL__native_link_get() */ + + +/*------------------------------------------------------------------------- + * Function: H5VL__native_link_specific + * + * Purpose: Handles the link specific callback + * + * Return: SUCCEED/FAIL + * + *------------------------------------------------------------------------- + */ +herr_t +H5VL__native_link_specific(void *obj, const H5VL_loc_params_t *loc_params, H5VL_link_specific_t specific_type, + hid_t H5_ATTR_UNUSED dxpl_id, void H5_ATTR_UNUSED **req, va_list arguments) +{ + herr_t ret_value = SUCCEED; /* Return value */ + + FUNC_ENTER_PACKAGE + + switch(specific_type) { + case H5VL_LINK_EXISTS: + { + htri_t *ret = HDva_arg(arguments, htri_t *); + H5G_loc_t loc; + + if(H5G_loc_real(obj, loc_params->obj_type, &loc) < 0) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a file or file object") + + /* Check for the existence of the link */ + if((*ret = H5L_exists(&loc, loc_params->loc_data.loc_by_name.name)) < 0) + HGOTO_ERROR(H5E_LINK, H5E_NOTFOUND, FAIL, "unable to specific link info") + break; + } + + case H5VL_LINK_ITER: + { + H5G_loc_t loc; + hbool_t recursive = (hbool_t)HDva_arg(arguments, unsigned); + H5_index_t idx_type = (H5_index_t)HDva_arg(arguments, int); /* enum work-around */ + H5_iter_order_t order = (H5_iter_order_t)HDva_arg(arguments, int); /* enum work-around */ + hsize_t *idx_p = HDva_arg(arguments, hsize_t *); + H5L_iterate_t op = HDva_arg(arguments, H5L_iterate_t); + void *op_data = HDva_arg(arguments, void *); + + /* Get the location */ + if(H5G_loc_real(obj, loc_params->obj_type, &loc) < 0) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a location") + + /* Visit or iterate over the links */ + if(loc_params->type == H5VL_OBJECT_BY_SELF) { + if(recursive) { + /* H5Lvisit */ + if((ret_value = H5G_visit(&loc, ".", idx_type, order, op, op_data)) < 0) + HGOTO_ERROR(H5E_LINK, H5E_BADITER, FAIL, "link visitation failed") + } /* end if */ + else { + /* H5Literate */ + if((ret_value = H5L_iterate(&loc, ".", idx_type, order, idx_p, op, op_data)) < 0) + HGOTO_ERROR(H5E_LINK, H5E_BADITER, FAIL, "error iterating over links") + } /* end else */ + } /* end if */ + else if(loc_params->type == H5VL_OBJECT_BY_NAME) { + if(recursive) { + /* H5Lvisit_by_name */ + if((ret_value = H5G_visit(&loc, loc_params->loc_data.loc_by_name.name, idx_type, order, op, op_data)) < 0) + HGOTO_ERROR(H5E_LINK, H5E_BADITER, FAIL, "link visitation failed") + } /* end if */ + else { + /* H5Literate_by_name */ + if((ret_value = H5L_iterate(&loc, loc_params->loc_data.loc_by_name.name, idx_type, order, idx_p, op, op_data)) < 0) + HGOTO_ERROR(H5E_LINK, H5E_BADITER, FAIL, "error iterating over links") + } /* end else */ + } /* end else-if */ + else + HGOTO_ERROR(H5E_LINK, H5E_UNSUPPORTED, FAIL, "unknown link iterate params") + + break; + } + + case H5VL_LINK_DELETE: + { + H5G_loc_t loc; + + if(H5G_loc_real(obj, loc_params->obj_type, &loc) < 0) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a file or file object") + + /* Unlink */ + if(loc_params->type == H5VL_OBJECT_BY_NAME) { /* H5Ldelete */ + if(H5L_delete(&loc, loc_params->loc_data.loc_by_name.name) < 0) + HGOTO_ERROR(H5E_LINK, H5E_CANTDELETE, FAIL, "unable to delete link") + } /* end if */ + else if(loc_params->type == H5VL_OBJECT_BY_IDX) { /* H5Ldelete_by_idx */ + if(H5L_delete_by_idx(&loc, loc_params->loc_data.loc_by_idx.name, loc_params->loc_data.loc_by_idx.idx_type, + loc_params->loc_data.loc_by_idx.order, loc_params->loc_data.loc_by_idx.n) < 0) + HGOTO_ERROR(H5E_LINK, H5E_CANTDELETE, FAIL, "unable to delete link") + } /* end else-if */ + else + HGOTO_ERROR(H5E_LINK, H5E_CANTDELETE, FAIL, "unable to delete link") + break; + } + + default: + HGOTO_ERROR(H5E_VOL, H5E_UNSUPPORTED, FAIL, "invalid specific operation") + } /* end switch */ + +done: + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5VL__native_link_specific() */ diff --git a/src/H5VLnative_object.c b/src/H5VLnative_object.c index 636b48b..b739526 100644 --- a/src/H5VLnative_object.c +++ b/src/H5VLnative_object.c @@ -10,4 +10,473 @@ * help@hdfgroup.org. * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ +/* + * Purpose: Object callbacks for the native VOL connector + * + */ + +#define H5O_FRIEND /* Suppress error about including H5Opkg */ +#define H5R_FRIEND /* Suppress error about including H5Rpkg */ + +#include "H5private.h" /* Generic Functions */ +#include "H5Eprivate.h" /* Error handling */ +#include "H5Fprivate.h" /* Files */ +#include "H5Gprivate.h" /* Groups */ +#include "H5Iprivate.h" /* IDs */ +#include "H5Opkg.h" /* Object headers */ +#include "H5Pprivate.h" /* Property lists */ +#include "H5Rpkg.h" /* References */ +#include "H5VLprivate.h" /* Virtual Object Layer */ + +#include "H5VLnative.h" /* Native VOL connector */ + + +/*------------------------------------------------------------------------- + * Function: H5VL__native_object_open + * + * Purpose: Handles the object open callback + * + * Return: Success: object pointer + * Failure: NULL + * + *------------------------------------------------------------------------- + */ +void * +H5VL__native_object_open(void *obj, const H5VL_loc_params_t *loc_params, H5I_type_t *opened_type, + hid_t H5_ATTR_UNUSED dxpl_id, void H5_ATTR_UNUSED **req) +{ + H5G_loc_t loc; + void *ret_value = NULL; + + FUNC_ENTER_PACKAGE + + if(H5G_loc_real(obj, loc_params->obj_type, &loc) < 0) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, NULL, "not a file or file object") + + switch(loc_params->type) { + case H5VL_OBJECT_BY_NAME: + { + /* Open the object */ + if(NULL == (ret_value = H5O_open_name(&loc, loc_params->loc_data.loc_by_name.name, opened_type))) + HGOTO_ERROR(H5E_OHDR, H5E_CANTOPENOBJ, NULL, "unable to open object by name") + break; + } + + case H5VL_OBJECT_BY_IDX: + { + /* Open the object */ + if(NULL == (ret_value = H5O_open_by_idx(&loc, loc_params->loc_data.loc_by_idx.name, loc_params->loc_data.loc_by_idx.idx_type, + loc_params->loc_data.loc_by_idx.order, loc_params->loc_data.loc_by_idx.n, opened_type))) + HGOTO_ERROR(H5E_OHDR, H5E_CANTOPENOBJ, NULL, "unable to open object by index") + break; + } + + case H5VL_OBJECT_BY_ADDR: + { + /* Open the object */ + if(NULL == (ret_value = H5O_open_by_addr(&loc, loc_params->loc_data.loc_by_addr.addr, opened_type))) + HGOTO_ERROR(H5E_OHDR, H5E_CANTOPENOBJ, NULL, "unable to open object by address") + break; + } + + case H5VL_OBJECT_BY_REF: + { + hid_t temp_id = H5I_INVALID_HID; + H5F_t *file = NULL; + + /* Get the file pointer from the entry */ + file = loc.oloc->file; + + /* Create reference */ + if((temp_id = H5R__dereference(file, loc_params->loc_data.loc_by_ref.lapl_id, + loc_params->loc_data.loc_by_ref.ref_type, + loc_params->loc_data.loc_by_ref._ref)) < 0) + HGOTO_ERROR(H5E_REFERENCE, H5E_CANTOPENOBJ, NULL, "unable to dereference object") + + *opened_type = H5I_get_type(temp_id); + if(NULL == (ret_value = H5I_remove(temp_id))) + HGOTO_ERROR(H5E_SYM, H5E_CANTOPENOBJ, NULL, "unable to open object") + break; + } + + case H5VL_OBJECT_BY_SELF: + default: + HGOTO_ERROR(H5E_VOL, H5E_UNSUPPORTED, NULL, "unknown open parameters") + } /* end switch */ + +done: + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5VL__native_object_open() */ + + +/*------------------------------------------------------------------------- + * Function: H5VL__native_object_copy + * + * Purpose: Handles the object copy callback + * + * Return: SUCCEED/FAIL + * + *------------------------------------------------------------------------- + */ +herr_t +H5VL__native_object_copy(void *src_obj, const H5VL_loc_params_t *loc_params1, const char *src_name, + void *dst_obj, const H5VL_loc_params_t *loc_params2, const char *dst_name, + hid_t ocpypl_id, hid_t lcpl_id, hid_t H5_ATTR_UNUSED dxpl_id, void H5_ATTR_UNUSED **req) +{ + H5G_loc_t src_loc; /* Source object group location */ + H5G_loc_t dst_loc; /* Destination group location */ + herr_t ret_value = FAIL; + + FUNC_ENTER_PACKAGE + + /* get location for objects */ + if(H5G_loc_real(src_obj, loc_params1->obj_type, &src_loc) < 0) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a file or file object") + if(H5G_loc_real(dst_obj, loc_params2->obj_type, &dst_loc) < 0) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a file or file object") + + /* Copy the object */ + if((ret_value = H5O_copy(&src_loc, src_name, &dst_loc, dst_name, ocpypl_id, lcpl_id)) < 0) + HGOTO_ERROR(H5E_SYM, H5E_CANTCOPY, FAIL, "unable to copy object") + +done: + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5VL__native_object_copy() */ + + +/*------------------------------------------------------------------------- + * Function: H5VL__native_object_get + * + * Purpose: Handles the object get callback + * + * Return: SUCCEED/FAIL + * + *------------------------------------------------------------------------- + */ +herr_t +H5VL__native_object_get(void *obj, const H5VL_loc_params_t *loc_params, H5VL_object_get_t get_type, + hid_t H5_ATTR_UNUSED dxpl_id, void H5_ATTR_UNUSED **req, va_list arguments) +{ + herr_t ret_value = SUCCEED; /* Return value */ + H5G_loc_t loc; /* Location of group */ + + FUNC_ENTER_PACKAGE + + if(H5G_loc_real(obj, loc_params->obj_type, &loc) < 0) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a file or file object") + + switch(get_type) { + /* H5Rget_region */ + case H5VL_REF_GET_REGION: + { + hid_t *ret = HDva_arg(arguments, hid_t *); + H5R_type_t H5_ATTR_UNUSED ref_type = (H5R_type_t)HDva_arg(arguments, int); /* enum work-around */ + void *ref = HDva_arg(arguments, void *); + H5S_t *space = NULL; /* Dataspace object */ + + /* Get the dataspace with the correct region selected */ + if((space = H5R__get_region(loc.oloc->file, ref)) == NULL) + HGOTO_ERROR(H5E_REFERENCE, H5E_CANTGET, FAIL, "unable to retrieve region") + + /* Atomize */ + if((*ret = H5I_register(H5I_DATASPACE, space, TRUE)) < 0) + HGOTO_ERROR(H5E_ATOM, H5E_CANTREGISTER, FAIL, "unable to register dataspace atom") + + break; + } + + /* H5Rget_obj_type1/2 */ + case H5VL_REF_GET_TYPE: + { + H5O_type_t *obj_type = HDva_arg(arguments, H5O_type_t *); + H5R_type_t ref_type = (H5R_type_t)HDva_arg(arguments, int); /* enum work-around */ + void *ref = HDva_arg(arguments, void *); + + /* Get the object information */ + if(H5R__get_obj_type(loc.oloc->file, ref_type, ref, obj_type) < 0) + HGOTO_ERROR(H5E_REFERENCE, H5E_CANTGET, FAIL, "unable to determine object type") + break; + } + + /* H5Rget_name */ + case H5VL_REF_GET_NAME: + { + ssize_t *ret = HDva_arg(arguments, ssize_t *); + char *name = HDva_arg(arguments, char *); + size_t size = HDva_arg(arguments, size_t); + H5R_type_t ref_type = (H5R_type_t)HDva_arg(arguments, int); /* enum work-around */ + void *ref = HDva_arg(arguments, void *); + + /* Get name */ + if((*ret = H5R__get_name(loc.oloc->file, ref_type, ref, name, size)) < 0) + HGOTO_ERROR(H5E_REFERENCE, H5E_CANTGET, FAIL, "unable to determine object path") + break; + } + + /* H5Iget_name */ + case H5VL_ID_GET_NAME: + { + ssize_t *ret = HDva_arg(arguments, ssize_t *); + char *name = HDva_arg(arguments, char *); + size_t size = HDva_arg(arguments, size_t); + + /* Retrieve object's name */ + if((*ret = H5G_get_name(&loc, name, size, NULL)) < 0) + HGOTO_ERROR(H5E_ATOM, H5E_CANTGET, FAIL, "can't retrieve object name") + + break; + } + + default: + HGOTO_ERROR(H5E_VOL, H5E_CANTGET, FAIL, "can't get this type of information from object") + } /* end switch */ + +done: + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5VL__native_object_get() */ + + +/*------------------------------------------------------------------------- + * Function: H5VL__native_object_specific + * + * Purpose: Handles the object specific callback + * + * Return: SUCCEED/FAIL + * + *------------------------------------------------------------------------- + */ +herr_t +H5VL__native_object_specific(void *obj, const H5VL_loc_params_t *loc_params, H5VL_object_specific_t specific_type, + hid_t H5_ATTR_UNUSED dxpl_id, void H5_ATTR_UNUSED **req, va_list arguments) +{ + H5G_loc_t loc; + herr_t ret_value = SUCCEED; /* Return value */ + + FUNC_ENTER_PACKAGE + + if(H5G_loc_real(obj, loc_params->obj_type, &loc) < 0) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a file or file object") + + switch(specific_type) { + /* H5Oincr_refcount / H5Odecr_refcount */ + case H5VL_OBJECT_CHANGE_REF_COUNT: + { + int update_ref = HDva_arg(arguments, int); + H5O_loc_t *oloc = loc.oloc; + + if(H5O_link(oloc, update_ref) < 0) + HGOTO_ERROR(H5E_OHDR, H5E_LINKCOUNT, FAIL, "modifying object link count failed") + + break; + } + + /* H5Oexists_by_name */ + case H5VL_OBJECT_EXISTS: + { + htri_t *ret = HDva_arg(arguments, htri_t *); + + if(loc_params->type == H5VL_OBJECT_BY_NAME) { + /* Check if the object exists */ + if((*ret = H5G_loc_exists(&loc, loc_params->loc_data.loc_by_name.name)) < 0) + HGOTO_ERROR(H5E_OHDR, H5E_CANTGET, FAIL, "unable to determine if '%s' exists", loc_params->loc_data.loc_by_name.name) + } /* end if */ + else + HGOTO_ERROR(H5E_VOL, H5E_UNSUPPORTED, FAIL, "unknown object exists parameters") + break; + } + + case H5VL_OBJECT_VISIT: + { + H5_index_t idx_type = (H5_index_t)HDva_arg(arguments, int); /* enum work-around */ + H5_iter_order_t order = (H5_iter_order_t)HDva_arg(arguments, int); /* enum work-around */ + H5O_iterate_t op = HDva_arg(arguments, H5O_iterate_t); + void *op_data = HDva_arg(arguments, void *); + unsigned fields = HDva_arg(arguments, unsigned); + + /* Call internal object visitation routine */ + if(loc_params->type == H5VL_OBJECT_BY_SELF) { + /* H5Ovisit */ + if((ret_value = H5O__visit(&loc, ".", idx_type, order, op, op_data, fields)) < 0) + HGOTO_ERROR(H5E_OHDR, H5E_BADITER, FAIL, "object visitation failed") + } /* end if */ + else if(loc_params->type == H5VL_OBJECT_BY_NAME) { + /* H5Ovisit_by_name */ + if((ret_value = H5O__visit(&loc, loc_params->loc_data.loc_by_name.name, idx_type, order, op, op_data, fields)) < 0) + HGOTO_ERROR(H5E_OHDR, H5E_BADITER, FAIL, "object visitation failed") + } /* end else-if */ + else + HGOTO_ERROR(H5E_VOL, H5E_UNSUPPORTED, FAIL, "unknown object visit params"); + break; + } + + case H5VL_OBJECT_FLUSH: + { + hid_t oid = HDva_arg(arguments, hid_t); + + /* Flush the object's metadata */ + if(H5O_flush(loc.oloc, oid) < 0) + HGOTO_ERROR(H5E_OHDR, H5E_CANTFLUSH, FAIL, "unable to flush object") + + break; + } + + case H5VL_OBJECT_REFRESH: + { + hid_t oid = HDva_arg(arguments, hid_t); + H5O_loc_t *oloc = loc.oloc; + + /* Refresh the metadata */ + if(H5O_refresh_metadata(oid, *oloc) < 0) + HGOTO_ERROR(H5E_OHDR, H5E_CANTLOAD, FAIL, "unable to refresh object") + + break; + } + + case H5VL_REF_CREATE: + { + void *ref = HDva_arg(arguments, void *); + const char *name = HDva_arg(arguments, char *); + H5R_type_t ref_type = (H5R_type_t)HDva_arg(arguments, int); /* enum work-around */ + hid_t space_id = HDva_arg(arguments, hid_t); + H5S_t *space = NULL; /* Pointer to dataspace containing region */ + + if(space_id != (-1) && (NULL == (space = (H5S_t *)H5I_object_verify(space_id, H5I_DATASPACE)))) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a dataspace") + + /* Create reference */ + if(H5R__create(ref, &loc, name, ref_type, space) < 0) + HGOTO_ERROR(H5E_REFERENCE, H5E_CANTCREATE, FAIL, "unable to create reference") + + break; + } + + default: + HGOTO_ERROR(H5E_VOL, H5E_CANTGET, FAIL, "can't recognize this operation type") + } /* end switch */ + +done: + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5VL__native_object_specific() */ + + +/*------------------------------------------------------------------------- + * Function: H5VL__native_object_optional + * + * Purpose: Handles the object optional callback + * + * Return: SUCCEED/FAIL + * + *------------------------------------------------------------------------- + */ +herr_t +H5VL__native_object_optional(void *obj, hid_t H5_ATTR_UNUSED dxpl_id, + void H5_ATTR_UNUSED **req, va_list arguments) +{ + H5VL_native_object_optional_t optional_type = HDva_arg(arguments, H5VL_native_object_optional_t); + H5VL_loc_params_t *loc_params = HDva_arg(arguments, H5VL_loc_params_t *); + H5G_loc_t loc; /* Location of group */ + herr_t ret_value = SUCCEED; /* Return value */ + + FUNC_ENTER_PACKAGE + + if(H5G_loc_real(obj, loc_params->obj_type, &loc) < 0) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a file or file object") + + switch(optional_type) { + /* H5Oget_info / H5Oget_info_by_name / H5Oget_info_by_idx */ + case H5VL_NATIVE_OBJECT_GET_INFO: + { + H5O_info_t *obj_info = HDva_arg(arguments, H5O_info_t *); + unsigned fields = HDva_arg(arguments, unsigned); + + if(loc_params->type == H5VL_OBJECT_BY_SELF) { /* H5Oget_info */ + /* Retrieve the object's information */ + if(H5G_loc_info(&loc, ".", obj_info, fields) < 0) + HGOTO_ERROR(H5E_OHDR, H5E_NOTFOUND, FAIL, "object not found") + } /* end if */ + else if(loc_params->type == H5VL_OBJECT_BY_NAME) { /* H5Oget_info_by_name */ + /* Retrieve the object's information */ + if(H5G_loc_info(&loc, loc_params->loc_data.loc_by_name.name, obj_info, fields) < 0) + HGOTO_ERROR(H5E_OHDR, H5E_NOTFOUND, FAIL, "object not found") + } /* end else-if */ + else if(loc_params->type == H5VL_OBJECT_BY_IDX) { /* H5Oget_info_by_idx */ + H5G_loc_t obj_loc; /* Location used to open group */ + H5G_name_t obj_path; /* Opened object group hier. path */ + H5O_loc_t obj_oloc; /* Opened object object location */ + + /* Set up opened group location to fill in */ + obj_loc.oloc = &obj_oloc; + obj_loc.path = &obj_path; + H5G_loc_reset(&obj_loc); + + /* Find the object's location, according to the order in the index */ + if(H5G_loc_find_by_idx(&loc, loc_params->loc_data.loc_by_idx.name, + loc_params->loc_data.loc_by_idx.idx_type, + loc_params->loc_data.loc_by_idx.order, + loc_params->loc_data.loc_by_idx.n, &obj_loc/*out*/) < 0) + HGOTO_ERROR(H5E_OHDR, H5E_NOTFOUND, FAIL, "group not found") + + /* Retrieve the object's information */ + if(H5O_get_info(obj_loc.oloc, obj_info, fields) < 0) { + H5G_loc_free(&obj_loc); + HGOTO_ERROR(H5E_OHDR, H5E_CANTGET, FAIL, "can't retrieve object info") + } /* end if */ + + /* Release the object location */ + if(H5G_loc_free(&obj_loc) < 0) + HGOTO_ERROR(H5E_OHDR, H5E_CANTRELEASE, FAIL, "can't free location") + } /* end else-if */ + else + HGOTO_ERROR(H5E_OHDR, H5E_UNSUPPORTED, FAIL, "unknown get info parameters") + break; + } + + /* H5Oget_comment / H5Oget_comment_by_name */ + case H5VL_NATIVE_OBJECT_GET_COMMENT: + { + char *comment = HDva_arg(arguments, char *); + size_t bufsize = HDva_arg(arguments, size_t); + ssize_t *ret = HDva_arg(arguments, ssize_t *); + + /* Retrieve the object's comment */ + if(loc_params->type == H5VL_OBJECT_BY_SELF) { /* H5Oget_comment */ + if((*ret = H5G_loc_get_comment(&loc, ".", comment/*out*/, bufsize)) < 0) + HGOTO_ERROR(H5E_OHDR, H5E_NOTFOUND, FAIL, "object not found") + } /* end if */ + else if(loc_params->type == H5VL_OBJECT_BY_NAME) { /* H5Oget_comment_by_name */ + if((*ret = H5G_loc_get_comment(&loc, loc_params->loc_data.loc_by_name.name, comment/*out*/, bufsize)) < 0) + HGOTO_ERROR(H5E_OHDR, H5E_NOTFOUND, FAIL, "object not found") + } /* end else-if */ + else + HGOTO_ERROR(H5E_VOL, H5E_UNSUPPORTED, FAIL, "unknown set_coment parameters") + break; + } + + /* H5Oset_comment */ + case H5VL_NATIVE_OBJECT_SET_COMMENT: + { + const char *comment = HDva_arg(arguments, char *); + + if(loc_params->type == H5VL_OBJECT_BY_SELF) { /* H5Oset_comment */ + /* (Re)set the object's comment */ + if(H5G_loc_set_comment(&loc, ".", comment) < 0) + HGOTO_ERROR(H5E_OHDR, H5E_NOTFOUND, FAIL, "object not found") + } /* end if */ + else if(loc_params->type == H5VL_OBJECT_BY_NAME) { /* H5Oset_comment_by_name */ + /* (Re)set the object's comment */ + if(H5G_loc_set_comment(&loc, loc_params->loc_data.loc_by_name.name, comment) < 0) + HGOTO_ERROR(H5E_OHDR, H5E_NOTFOUND, FAIL, "object not found") + } /* end else-if */ + else + HGOTO_ERROR(H5E_VOL, H5E_UNSUPPORTED, FAIL, "unknown set_coment parameters") + break; + } + + default: + HGOTO_ERROR(H5E_VOL, H5E_CANTGET, FAIL, "can't perform this operation on object"); + } /* end switch */ + +done: + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5VL__native_object_optional() */ -- cgit v0.12 From 2bbd1589fee5b92f5aee8e1da1e725202ae93885 Mon Sep 17 00:00:00 2001 From: Quincey Koziol Date: Thu, 20 Dec 2018 10:19:19 -0600 Subject: Correct typo --- src/H5FDdirect.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/H5FDdirect.c b/src/H5FDdirect.c index 958f53c..d1a8fc8 100644 --- a/src/H5FDdirect.c +++ b/src/H5FDdirect.c @@ -418,7 +418,7 @@ static void * H5FD_direct_fapl_copy(const void *_old_fa) { const H5FD_direct_fapl_t *old_fa = (const H5FD_direct_fapl_t*)_old_fa; - H5FD_direct_fapl_t *new_fa = H5MM_calloc(1, sizeof(H5FD_direct_fapl_t)); + H5FD_direct_fapl_t *new_fa = H5MM_calloc(sizeof(H5FD_direct_fapl_t)); FUNC_ENTER_NOAPI_NOINIT_NOERR -- cgit v0.12 From 9e8cacaa5531f418f5d9d447c1251eb705da785a Mon Sep 17 00:00:00 2001 From: Quincey Koziol Date: Thu, 20 Dec 2018 11:52:09 -0600 Subject: Remove core VFD-specific property list call and regenerate encoded property lists. --- test/gen_plist.c | 5 +---- test/testfiles/plist_files/def_fapl_32be | Bin 1652 -> 1651 bytes test/testfiles/plist_files/def_fapl_32le | Bin 1652 -> 1651 bytes test/testfiles/plist_files/def_fapl_64be | Bin 1652 -> 1651 bytes test/testfiles/plist_files/def_fapl_64le | Bin 1652 -> 1651 bytes test/testfiles/plist_files/fapl_32be | Bin 1654 -> 1653 bytes test/testfiles/plist_files/fapl_32le | Bin 1654 -> 1653 bytes test/testfiles/plist_files/fapl_64be | Bin 1654 -> 1653 bytes test/testfiles/plist_files/fapl_64le | Bin 1654 -> 1653 bytes test/testfiles/plist_files/lapl_32be | Bin 1757 -> 1756 bytes test/testfiles/plist_files/lapl_32le | Bin 1757 -> 1756 bytes test/testfiles/plist_files/lapl_64be | Bin 1757 -> 1756 bytes test/testfiles/plist_files/lapl_64le | Bin 1757 -> 1756 bytes 13 files changed, 1 insertion(+), 4 deletions(-) diff --git a/test/gen_plist.c b/test/gen_plist.c index 62693bd..af248be 100644 --- a/test/gen_plist.c +++ b/test/gen_plist.c @@ -363,9 +363,6 @@ main(void) if((ret = H5Pset_mdc_image_config(fapl1, &my_cache_image_config)) < 0) assert(ret > 0); - if((ret = H5Pset_core_write_tracking(fapl1, TRUE, (size_t)(1024 * 1024))) < 0) - assert(ret > 0); - if((ret = encode_plist(fapl1, little_endian, word_length, "testfiles/plist_files/fapl_")) < 0) assert(ret > 0); @@ -476,7 +473,7 @@ encode_plist(hid_t plist_id, int little_endian, int word_length, const char *fil HDassert(ret > 0); fd = HDopen(filename, O_RDWR | O_CREAT | O_TRUNC, H5_POSIX_CREATE_MODE_RW); - HDassert(fd > 0); + HDassert(fd >= 0); write_size = HDwrite(fd, temp_buf, temp_size); HDassert(write_size == (ssize_t)temp_size); diff --git a/test/testfiles/plist_files/def_fapl_32be b/test/testfiles/plist_files/def_fapl_32be index cd8a33a..53ef572 100644 Binary files a/test/testfiles/plist_files/def_fapl_32be and b/test/testfiles/plist_files/def_fapl_32be differ diff --git a/test/testfiles/plist_files/def_fapl_32le b/test/testfiles/plist_files/def_fapl_32le index cd8a33a..53ef572 100644 Binary files a/test/testfiles/plist_files/def_fapl_32le and b/test/testfiles/plist_files/def_fapl_32le differ diff --git a/test/testfiles/plist_files/def_fapl_64be b/test/testfiles/plist_files/def_fapl_64be index cd8a33a..53ef572 100644 Binary files a/test/testfiles/plist_files/def_fapl_64be and b/test/testfiles/plist_files/def_fapl_64be differ diff --git a/test/testfiles/plist_files/def_fapl_64le b/test/testfiles/plist_files/def_fapl_64le index cd8a33a..53ef572 100644 Binary files a/test/testfiles/plist_files/def_fapl_64le and b/test/testfiles/plist_files/def_fapl_64le differ diff --git a/test/testfiles/plist_files/fapl_32be b/test/testfiles/plist_files/fapl_32be index b0ad12e..d89a44c 100644 Binary files a/test/testfiles/plist_files/fapl_32be and b/test/testfiles/plist_files/fapl_32be differ diff --git a/test/testfiles/plist_files/fapl_32le b/test/testfiles/plist_files/fapl_32le index b0ad12e..d89a44c 100644 Binary files a/test/testfiles/plist_files/fapl_32le and b/test/testfiles/plist_files/fapl_32le differ diff --git a/test/testfiles/plist_files/fapl_64be b/test/testfiles/plist_files/fapl_64be index b0ad12e..d89a44c 100644 Binary files a/test/testfiles/plist_files/fapl_64be and b/test/testfiles/plist_files/fapl_64be differ diff --git a/test/testfiles/plist_files/fapl_64le b/test/testfiles/plist_files/fapl_64le index b0ad12e..d89a44c 100644 Binary files a/test/testfiles/plist_files/fapl_64le and b/test/testfiles/plist_files/fapl_64le differ diff --git a/test/testfiles/plist_files/lapl_32be b/test/testfiles/plist_files/lapl_32be index f93e19a..eee238e 100644 Binary files a/test/testfiles/plist_files/lapl_32be and b/test/testfiles/plist_files/lapl_32be differ diff --git a/test/testfiles/plist_files/lapl_32le b/test/testfiles/plist_files/lapl_32le index f93e19a..eee238e 100644 Binary files a/test/testfiles/plist_files/lapl_32le and b/test/testfiles/plist_files/lapl_32le differ diff --git a/test/testfiles/plist_files/lapl_64be b/test/testfiles/plist_files/lapl_64be index f93e19a..eee238e 100644 Binary files a/test/testfiles/plist_files/lapl_64be and b/test/testfiles/plist_files/lapl_64be differ diff --git a/test/testfiles/plist_files/lapl_64le b/test/testfiles/plist_files/lapl_64le index f93e19a..eee238e 100644 Binary files a/test/testfiles/plist_files/lapl_64le and b/test/testfiles/plist_files/lapl_64le differ -- cgit v0.12 From a06249a21b95bb17c87de34c0f53d2ea55690a60 Mon Sep 17 00:00:00 2001 From: Dana Robinson Date: Thu, 20 Dec 2018 10:47:00 -0800 Subject: Moved private native VOL connector functions to H5VLnative_private.h. --- MANIFEST | 1 + src/CMakeLists.txt | 1 + src/H5Adeprec.c | 3 +- src/H5D.c | 3 +- src/H5Dio.c | 3 +- src/H5F.c | 3 +- src/H5Fdeprec.c | 3 +- src/H5Fint.c | 3 +- src/H5Gdeprec.c | 3 +- src/H5O.c | 3 +- src/H5Odeprec.c | 3 +- src/H5Pfapl.c | 2 +- src/H5VLnative.c | 3 +- src/H5VLnative.h | 58 ------------------------------- src/H5VLnative_attr.c | 2 +- src/H5VLnative_dataset.c | 2 +- src/H5VLnative_datatype.c | 2 +- src/H5VLnative_file.c | 2 +- src/H5VLnative_group.c | 2 +- src/H5VLnative_link.c | 2 +- src/H5VLnative_object.c | 2 +- src/H5VLnative_private.h | 88 +++++++++++++++++++++++++++++++++++++++++++++++ 22 files changed, 118 insertions(+), 76 deletions(-) create mode 100644 src/H5VLnative_private.h diff --git a/MANIFEST b/MANIFEST index 625d949..b8df8f3 100644 --- a/MANIFEST +++ b/MANIFEST @@ -901,6 +901,7 @@ ./src/H5VLnative_group.c ./src/H5VLnative_link.c ./src/H5VLnative_object.c +./src/H5VLnative_private.h ./src/H5VLpassthru.c ./src/H5VLpassthru.h ./src/H5VLpkg.h diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index bac113a..c9a2fda 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -876,6 +876,7 @@ set (H5_PRIVATE_HEADERS ${HDF5_SRC_DIR}/H5UCprivate.h + ${HDF5_SRC_DIR}/H5VLnative_private.h ${HDF5_SRC_DIR}/H5VLpkg.h ${HDF5_SRC_DIR}/H5VLprivate.h diff --git a/src/H5Adeprec.c b/src/H5Adeprec.c index 0a92ec8..b438cd2 100644 --- a/src/H5Adeprec.c +++ b/src/H5Adeprec.c @@ -44,7 +44,8 @@ #include "H5Iprivate.h" /* IDs */ #include "H5Opkg.h" /* Object headers */ #include "H5VLprivate.h" /* Virtual object layer */ -#include "H5VLnative.h" /* Native VOL connector */ + +#include "H5VLnative_private.h" /* Native VOL connector */ /****************/ diff --git a/src/H5D.c b/src/H5D.c index b4880f0..fc350f2 100644 --- a/src/H5D.c +++ b/src/H5D.c @@ -28,7 +28,8 @@ #include "H5FLprivate.h" /* Free lists */ #include "H5Iprivate.h" /* IDs */ #include "H5VLprivate.h" /* Virtual Object Layer */ -#include "H5VLnative.h" /* Native VOL connector */ + +#include "H5VLnative_private.h" /* Native VOL connector */ /****************/ diff --git a/src/H5Dio.c b/src/H5Dio.c index 026f64e..fe85d23 100644 --- a/src/H5Dio.c +++ b/src/H5Dio.c @@ -29,7 +29,8 @@ #include "H5Iprivate.h" /* IDs */ #include "H5MMprivate.h" /* Memory management */ #include "H5Sprivate.h" /* Dataspace */ -#include "H5VLnative.h" /* Native VOL connector */ + +#include "H5VLnative_private.h" /* Native VOL connector */ #ifdef H5_HAVE_PARALLEL /* Remove this if H5R_DATASET_REGION is no longer used in this file */ diff --git a/src/H5F.c b/src/H5F.c index fc063a0..3cb7807 100644 --- a/src/H5F.c +++ b/src/H5F.c @@ -37,7 +37,8 @@ #include "H5Pprivate.h" /* Property lists */ #include "H5Tprivate.h" /* Datatypes */ #include "H5VLprivate.h" /* Virtual Object Layer */ -#include "H5VLnative.h" /* Native VOL connector */ + +#include "H5VLnative_private.h" /* Native VOL connector */ /****************/ diff --git a/src/H5Fdeprec.c b/src/H5Fdeprec.c index 7cefb06..18e915f 100644 --- a/src/H5Fdeprec.c +++ b/src/H5Fdeprec.c @@ -41,7 +41,8 @@ #include "H5Fpkg.h" /* File access */ #include "H5Iprivate.h" /* IDs */ #include "H5SMprivate.h" /* Shared object header messages */ -#include "H5VLnative.h" /* Native VOL connector */ + +#include "H5VLnative_private.h" /* Native VOL connector */ /****************/ diff --git a/src/H5Fint.c b/src/H5Fint.c index ddeddb6..8de1769 100644 --- a/src/H5Fint.c +++ b/src/H5Fint.c @@ -38,7 +38,8 @@ #include "H5SMprivate.h" /* Shared Object Header Messages */ #include "H5Tprivate.h" /* Datatypes */ #include "H5VLprivate.h" /* Virtual Object Layer */ -#include "H5VLnative.h" /* Native VOL connector */ + +#include "H5VLnative_private.h" /* Native VOL connector */ /****************/ diff --git a/src/H5Gdeprec.c b/src/H5Gdeprec.c index 3e0574c..cb03b5e 100644 --- a/src/H5Gdeprec.c +++ b/src/H5Gdeprec.c @@ -44,7 +44,8 @@ #include "H5Lprivate.h" /* Links */ #include "H5Pprivate.h" /* Property lists */ #include "H5VLprivate.h" /* Virtual Object Layer */ -#include "H5VLnative.h" /* Native VOL connector */ + +#include "H5VLnative_private.h" /* Native VOL connector */ /****************/ diff --git a/src/H5O.c b/src/H5O.c index 30250a1..4e2f603 100644 --- a/src/H5O.c +++ b/src/H5O.c @@ -37,7 +37,8 @@ #include "H5Iprivate.h" /* IDs */ #include "H5Lprivate.h" /* Links */ #include "H5Opkg.h" /* Object headers */ -#include "H5VLnative.h" /* Native VOL connector */ + +#include "H5VLnative_private.h" /* Native VOL connector */ /****************/ diff --git a/src/H5Odeprec.c b/src/H5Odeprec.c index bd04cdb..7aefc67 100644 --- a/src/H5Odeprec.c +++ b/src/H5Odeprec.c @@ -36,7 +36,8 @@ #include "H5Eprivate.h" /* Error handling */ #include "H5Iprivate.h" /* IDs */ #include "H5Opkg.h" /* Object headers */ -#include "H5VLnative.h" /* Native VOL connector */ + +#include "H5VLnative_private.h" /* Native VOL connector */ /****************/ diff --git a/src/H5Pfapl.c b/src/H5Pfapl.c index 4e23221..452ea3f 100644 --- a/src/H5Pfapl.c +++ b/src/H5Pfapl.c @@ -49,7 +49,7 @@ #endif /* Includes needed to set default VOL connector */ -#include "H5VLnative.h" /* Native VOL connector */ +#include "H5VLnative_private.h" /* Native VOL connector */ /****************/ diff --git a/src/H5VLnative.c b/src/H5VLnative.c index 82ff470..fe0fd4e 100644 --- a/src/H5VLnative.c +++ b/src/H5VLnative.c @@ -21,7 +21,8 @@ #include "H5Pprivate.h" /* Property lists */ #include "H5VLprivate.h" /* Virtual Object Layer */ -#include "H5VLnative.h" /* Native VOL connector */ +#include "H5VLnative_private.h" /* Native VOL connector */ + /* The VOL connector identification number */ static hid_t H5VL_NATIVE_ID_g = H5I_INVALID_HID; diff --git a/src/H5VLnative.h b/src/H5VLnative.h index a033a07..916151b 100644 --- a/src/H5VLnative.h +++ b/src/H5VLnative.h @@ -80,7 +80,6 @@ typedef int H5VL_native_object_optional_t; #define H5VL_NATIVE_OBJECT_GET_INFO 1 /* H5Oget_info(_by_idx, _by_name)(2) */ #define H5VL_NATIVE_OBJECT_SET_COMMENT 2 /* H5G|H5Oset_comment, H5Oset_comment_by_name */ - #ifdef __cplusplus extern "C" { #endif @@ -88,63 +87,6 @@ extern "C" { /* Private functions */ H5_DLL hid_t H5VL_native_register(void); -/* Atrribute callbacks */ -H5_DLL void *H5VL__native_attr_create(void *obj, const H5VL_loc_params_t *loc_params, const char *attr_name, hid_t acpl_id, hid_t aapl_id, hid_t dxpl_id, void **req); -void *H5VL__native_attr_open(void *obj, const H5VL_loc_params_t *loc_params, const char *attr_name, hid_t aapl_id, hid_t dxpl_id, void **req); -H5_DLL herr_t H5VL__native_attr_read(void *attr, hid_t dtype_id, void *buf, hid_t dxpl_id, void **req); -H5_DLL herr_t H5VL__native_attr_write(void *attr, hid_t dtype_id, const void *buf, hid_t dxpl_id, void **req); -H5_DLL herr_t H5VL__native_attr_get(void *obj, H5VL_attr_get_t get_type, hid_t dxpl_id, void **req, va_list arguments); -H5_DLL herr_t H5VL__native_attr_specific(void *obj, const H5VL_loc_params_t *loc_params, H5VL_attr_specific_t specific_type, hid_t dxpl_id, void **req, va_list arguments); -H5_DLL herr_t H5VL__native_attr_optional(void *obj, hid_t dxpl_id, void **req, va_list arguments); -H5_DLL herr_t H5VL__native_attr_close(void *attr, hid_t dxpl_id, void **req); - -/* Dataset callbacks */ -H5_DLL void *H5VL__native_dataset_create(void *obj, const H5VL_loc_params_t *loc_params, const char *name, hid_t dcpl_id, hid_t dapl_id, hid_t dxpl_id, void **req); -H5_DLL void *H5VL__native_dataset_open(void *obj, const H5VL_loc_params_t *loc_params, const char *name, hid_t dapl_id, hid_t dxpl_id, void **req); -H5_DLL herr_t H5VL__native_dataset_read(void *dset, hid_t mem_type_id, hid_t mem_space_id, hid_t file_space_id, hid_t plist_id, void *buf, void **req); -H5_DLL herr_t H5VL__native_dataset_write(void *dset, hid_t mem_type_id, hid_t mem_space_id, hid_t file_space_id, hid_t plist_id, const void *buf, void **req); -H5_DLL herr_t H5VL__native_dataset_get(void *dset, H5VL_dataset_get_t get_type, hid_t dxpl_id, void **req, va_list arguments); -H5_DLL herr_t H5VL__native_dataset_specific(void *dset, H5VL_dataset_specific_t specific_type, hid_t dxpl_id, void **req, va_list arguments); -H5_DLL herr_t H5VL__native_dataset_optional(void *dset, hid_t dxpl_id, void **req, va_list arguments); -H5_DLL herr_t H5VL__native_dataset_close(void *dset, hid_t dxpl_id, void **req); - -/* File callbacks */ -H5_DLL void *H5VL__native_file_create(const char *name, unsigned flags, hid_t fcpl_id, hid_t fapl_id, hid_t dxpl_id, void **req); -H5_DLL void *H5VL__native_file_open(const char *name, unsigned flags, hid_t fapl_id, hid_t dxpl_id, void **req); -H5_DLL herr_t H5VL__native_file_get(void *file, H5VL_file_get_t get_type, hid_t dxpl_id, void **req, va_list arguments); -H5_DLL herr_t H5VL__native_file_specific(void *file, H5VL_file_specific_t specific_type, hid_t dxpl_id, void **req, va_list arguments); -H5_DLL herr_t H5VL__native_file_optional(void *file, hid_t dxpl_id, void **req, va_list arguments); -H5_DLL herr_t H5VL__native_file_close(void *file, hid_t dxpl_id, void **req); - -/* Group callbacks */ -H5_DLL void *H5VL__native_group_create(void *obj, const H5VL_loc_params_t *loc_params, const char *name, hid_t gcpl_id, hid_t gapl_id, hid_t dxpl_id, void **req); -H5_DLL void *H5VL__native_group_open(void *obj, const H5VL_loc_params_t *loc_params, const char *name, hid_t gapl_id, hid_t dxpl_id, void **req); -H5_DLL herr_t H5VL__native_group_get(void *obj, H5VL_group_get_t get_type, hid_t dxpl_id, void **req, va_list arguments); -H5_DLL herr_t H5VL__native_group_specific(void *obj, H5VL_group_specific_t specific_type, hid_t dxpl_id, void **req, va_list arguments); -H5_DLL herr_t H5VL__native_group_optional(void *obj, hid_t dxpl_id, void **req, va_list arguments); -H5_DLL herr_t H5VL__native_group_close(void *grp, hid_t dxpl_id, void **req); - -/* Link callbacks */ -H5_DLL herr_t H5VL__native_link_create(H5VL_link_create_type_t create_type, void *obj, const H5VL_loc_params_t *loc_params, hid_t lcpl_id, hid_t lapl_id, hid_t dxpl_id, void **req); -H5_DLL herr_t H5VL__native_link_copy(void *src_obj, const H5VL_loc_params_t *loc_params1, void *dst_obj, const H5VL_loc_params_t *loc_params2, hid_t lcpl_id, hid_t lapl_id, hid_t dxpl_id, void **req); -H5_DLL herr_t H5VL__native_link_move(void *src_obj, const H5VL_loc_params_t *loc_params1, void *dst_obj, const H5VL_loc_params_t *loc_params2, hid_t lcpl_id, hid_t lapl_id, hid_t dxpl_id, void **req); -H5_DLL herr_t H5VL__native_link_get(void *obj, const H5VL_loc_params_t *loc_params, H5VL_link_get_t get_type, hid_t dxpl_id, void **req, va_list arguments); -H5_DLL herr_t H5VL__native_link_specific(void *obj, const H5VL_loc_params_t *loc_params, H5VL_link_specific_t specific_type, hid_t dxpl_id, void **req, va_list arguments); - -/* Object callbacks */ -H5_DLL void *H5VL__native_object_open(void *obj, const H5VL_loc_params_t *loc_params, H5I_type_t *opened_type, hid_t dxpl_id, void **req); -H5_DLL herr_t H5VL__native_object_copy(void *src_obj, const H5VL_loc_params_t *loc_params1, const char *src_name, void *dst_obj, const H5VL_loc_params_t *loc_params2, const char *dst_name, hid_t ocpypl_id, hid_t lcpl_id, hid_t dxpl_id, void **req); -H5_DLL herr_t H5VL__native_object_get(void *obj, const H5VL_loc_params_t *loc_params, H5VL_object_get_t get_type, hid_t dxpl_id, void **req, va_list arguments); -H5_DLL herr_t H5VL__native_object_specific(void *obj, const H5VL_loc_params_t *loc_params, H5VL_object_specific_t specific_type, hid_t dxpl_id, void **req, va_list arguments); -H5_DLL herr_t H5VL__native_object_optional(void *obj, hid_t dxpl_id, void **req, va_list arguments); - -/* Datatype callbacks */ -H5_DLL void *H5VL__native_datatype_commit(void *obj, const H5VL_loc_params_t *loc_params, const char *name, hid_t type_id, hid_t lcpl_id, hid_t tcpl_id, hid_t tapl_id, hid_t dxpl_id, void **req); -H5_DLL void *H5VL__native_datatype_open(void *obj, const H5VL_loc_params_t *loc_params, const char *name, hid_t tapl_id, hid_t dxpl_id, void **req); -H5_DLL herr_t H5VL__native_datatype_get(void *dt, H5VL_datatype_get_t get_type, hid_t dxpl_id, void **req, va_list arguments); -H5_DLL herr_t H5VL__native_datatype_specific(void *dt, H5VL_datatype_specific_t specific_type, hid_t dxpl_id, void **req, va_list arguments); -H5_DLL herr_t H5VL__native_datatype_close(void *dt, hid_t dxpl_id, void **req); - #ifdef __cplusplus } #endif diff --git a/src/H5VLnative_attr.c b/src/H5VLnative_attr.c index 7940b7d..7d9f0ac 100644 --- a/src/H5VLnative_attr.c +++ b/src/H5VLnative_attr.c @@ -28,7 +28,7 @@ #include "H5Tprivate.h" /* Datatypes */ #include "H5VLprivate.h" /* Virtual Object Layer */ -#include "H5VLnative.h" /* Native VOL connector */ +#include "H5VLnative_private.h" /* Native VOL connector */ diff --git a/src/H5VLnative_dataset.c b/src/H5VLnative_dataset.c index 2316255..8f7351c 100644 --- a/src/H5VLnative_dataset.c +++ b/src/H5VLnative_dataset.c @@ -27,7 +27,7 @@ #include "H5Sprivate.h" /* Dataspaces */ #include "H5VLprivate.h" /* Virtual Object Layer */ -#include "H5VLnative.h" /* Native VOL connector */ +#include "H5VLnative_private.h" /* Native VOL connector */ diff --git a/src/H5VLnative_datatype.c b/src/H5VLnative_datatype.c index a81edb4..3c9463d 100644 --- a/src/H5VLnative_datatype.c +++ b/src/H5VLnative_datatype.c @@ -26,7 +26,7 @@ #include "H5Tpkg.h" /* Datatypes */ #include "H5VLprivate.h" /* Virtual Object Layer */ -#include "H5VLnative.h" /* Native VOL connector */ +#include "H5VLnative_private.h" /* Native VOL connector */ diff --git a/src/H5VLnative_file.c b/src/H5VLnative_file.c index 77d6844..994af16 100644 --- a/src/H5VLnative_file.c +++ b/src/H5VLnative_file.c @@ -29,7 +29,7 @@ #include "H5PBprivate.h" /* Page buffering */ #include "H5VLprivate.h" /* Virtual Object Layer */ -#include "H5VLnative.h" /* Native VOL connector */ +#include "H5VLnative_private.h" /* Native VOL connector */ diff --git a/src/H5VLnative_group.c b/src/H5VLnative_group.c index 20b1b79..9c07b3d 100644 --- a/src/H5VLnative_group.c +++ b/src/H5VLnative_group.c @@ -25,7 +25,7 @@ #include "H5Pprivate.h" /* Property lists */ #include "H5VLprivate.h" /* Virtual Object Layer */ -#include "H5VLnative.h" /* Native VOL connector */ +#include "H5VLnative_private.h" /* Native VOL connector */ diff --git a/src/H5VLnative_link.c b/src/H5VLnative_link.c index 6f276ad..98d2ccd 100644 --- a/src/H5VLnative_link.c +++ b/src/H5VLnative_link.c @@ -25,7 +25,7 @@ #include "H5Pprivate.h" /* Property lists */ #include "H5VLprivate.h" /* Virtual Object Layer */ -#include "H5VLnative.h" /* Native VOL connector */ +#include "H5VLnative_private.h" /* Native VOL connector */ diff --git a/src/H5VLnative_object.c b/src/H5VLnative_object.c index b739526..0b1d73a 100644 --- a/src/H5VLnative_object.c +++ b/src/H5VLnative_object.c @@ -28,7 +28,7 @@ #include "H5Rpkg.h" /* References */ #include "H5VLprivate.h" /* Virtual Object Layer */ -#include "H5VLnative.h" /* Native VOL connector */ +#include "H5VLnative_private.h" /* Native VOL connector */ /*------------------------------------------------------------------------- diff --git a/src/H5VLnative_private.h b/src/H5VLnative_private.h new file mode 100644 index 0000000..1bf4da2 --- /dev/null +++ b/src/H5VLnative_private.h @@ -0,0 +1,88 @@ +/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * + * Copyright by The HDF Group. * + * All rights reserved. * + * * + * This file is part of HDF5. The full HDF5 copyright notice, including * + * terms governing use, modification, and redistribution, is contained in * + * the COPYING file, which can be found at the root of the source code * + * distribution tree, or in https://support.hdfgroup.org/ftp/HDF5/releases. * + * If you do not have access to either file, you may request a copy from * + * help@hdfgroup.org. * + * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ + +/* + * Purpose: The private header file for the native VOL connector. + */ + +#ifndef _H5VLnative_private_H +#define _H5VLnative_private_H + +#include "H5VLnative.h" /* Native VOL connector */ + +#ifdef __cplusplus +extern "C" { +#endif + +/* Atrribute callbacks */ +H5_DLL void *H5VL__native_attr_create(void *obj, const H5VL_loc_params_t *loc_params, const char *attr_name, hid_t acpl_id, hid_t aapl_id, hid_t dxpl_id, void **req); +void *H5VL__native_attr_open(void *obj, const H5VL_loc_params_t *loc_params, const char *attr_name, hid_t aapl_id, hid_t dxpl_id, void **req); +H5_DLL herr_t H5VL__native_attr_read(void *attr, hid_t dtype_id, void *buf, hid_t dxpl_id, void **req); +H5_DLL herr_t H5VL__native_attr_write(void *attr, hid_t dtype_id, const void *buf, hid_t dxpl_id, void **req); +H5_DLL herr_t H5VL__native_attr_get(void *obj, H5VL_attr_get_t get_type, hid_t dxpl_id, void **req, va_list arguments); +H5_DLL herr_t H5VL__native_attr_specific(void *obj, const H5VL_loc_params_t *loc_params, H5VL_attr_specific_t specific_type, hid_t dxpl_id, void **req, va_list arguments); +H5_DLL herr_t H5VL__native_attr_optional(void *obj, hid_t dxpl_id, void **req, va_list arguments); +H5_DLL herr_t H5VL__native_attr_close(void *attr, hid_t dxpl_id, void **req); + +/* Dataset callbacks */ +H5_DLL void *H5VL__native_dataset_create(void *obj, const H5VL_loc_params_t *loc_params, const char *name, hid_t dcpl_id, hid_t dapl_id, hid_t dxpl_id, void **req); +H5_DLL void *H5VL__native_dataset_open(void *obj, const H5VL_loc_params_t *loc_params, const char *name, hid_t dapl_id, hid_t dxpl_id, void **req); +H5_DLL herr_t H5VL__native_dataset_read(void *dset, hid_t mem_type_id, hid_t mem_space_id, hid_t file_space_id, hid_t plist_id, void *buf, void **req); +H5_DLL herr_t H5VL__native_dataset_write(void *dset, hid_t mem_type_id, hid_t mem_space_id, hid_t file_space_id, hid_t plist_id, const void *buf, void **req); +H5_DLL herr_t H5VL__native_dataset_get(void *dset, H5VL_dataset_get_t get_type, hid_t dxpl_id, void **req, va_list arguments); +H5_DLL herr_t H5VL__native_dataset_specific(void *dset, H5VL_dataset_specific_t specific_type, hid_t dxpl_id, void **req, va_list arguments); +H5_DLL herr_t H5VL__native_dataset_optional(void *dset, hid_t dxpl_id, void **req, va_list arguments); +H5_DLL herr_t H5VL__native_dataset_close(void *dset, hid_t dxpl_id, void **req); + +/* File callbacks */ +H5_DLL void *H5VL__native_file_create(const char *name, unsigned flags, hid_t fcpl_id, hid_t fapl_id, hid_t dxpl_id, void **req); +H5_DLL void *H5VL__native_file_open(const char *name, unsigned flags, hid_t fapl_id, hid_t dxpl_id, void **req); +H5_DLL herr_t H5VL__native_file_get(void *file, H5VL_file_get_t get_type, hid_t dxpl_id, void **req, va_list arguments); +H5_DLL herr_t H5VL__native_file_specific(void *file, H5VL_file_specific_t specific_type, hid_t dxpl_id, void **req, va_list arguments); +H5_DLL herr_t H5VL__native_file_optional(void *file, hid_t dxpl_id, void **req, va_list arguments); +H5_DLL herr_t H5VL__native_file_close(void *file, hid_t dxpl_id, void **req); + +/* Group callbacks */ +H5_DLL void *H5VL__native_group_create(void *obj, const H5VL_loc_params_t *loc_params, const char *name, hid_t gcpl_id, hid_t gapl_id, hid_t dxpl_id, void **req); +H5_DLL void *H5VL__native_group_open(void *obj, const H5VL_loc_params_t *loc_params, const char *name, hid_t gapl_id, hid_t dxpl_id, void **req); +H5_DLL herr_t H5VL__native_group_get(void *obj, H5VL_group_get_t get_type, hid_t dxpl_id, void **req, va_list arguments); +H5_DLL herr_t H5VL__native_group_specific(void *obj, H5VL_group_specific_t specific_type, hid_t dxpl_id, void **req, va_list arguments); +H5_DLL herr_t H5VL__native_group_optional(void *obj, hid_t dxpl_id, void **req, va_list arguments); +H5_DLL herr_t H5VL__native_group_close(void *grp, hid_t dxpl_id, void **req); + +/* Link callbacks */ +H5_DLL herr_t H5VL__native_link_create(H5VL_link_create_type_t create_type, void *obj, const H5VL_loc_params_t *loc_params, hid_t lcpl_id, hid_t lapl_id, hid_t dxpl_id, void **req); +H5_DLL herr_t H5VL__native_link_copy(void *src_obj, const H5VL_loc_params_t *loc_params1, void *dst_obj, const H5VL_loc_params_t *loc_params2, hid_t lcpl_id, hid_t lapl_id, hid_t dxpl_id, void **req); +H5_DLL herr_t H5VL__native_link_move(void *src_obj, const H5VL_loc_params_t *loc_params1, void *dst_obj, const H5VL_loc_params_t *loc_params2, hid_t lcpl_id, hid_t lapl_id, hid_t dxpl_id, void **req); +H5_DLL herr_t H5VL__native_link_get(void *obj, const H5VL_loc_params_t *loc_params, H5VL_link_get_t get_type, hid_t dxpl_id, void **req, va_list arguments); +H5_DLL herr_t H5VL__native_link_specific(void *obj, const H5VL_loc_params_t *loc_params, H5VL_link_specific_t specific_type, hid_t dxpl_id, void **req, va_list arguments); + +/* Object callbacks */ +H5_DLL void *H5VL__native_object_open(void *obj, const H5VL_loc_params_t *loc_params, H5I_type_t *opened_type, hid_t dxpl_id, void **req); +H5_DLL herr_t H5VL__native_object_copy(void *src_obj, const H5VL_loc_params_t *loc_params1, const char *src_name, void *dst_obj, const H5VL_loc_params_t *loc_params2, const char *dst_name, hid_t ocpypl_id, hid_t lcpl_id, hid_t dxpl_id, void **req); +H5_DLL herr_t H5VL__native_object_get(void *obj, const H5VL_loc_params_t *loc_params, H5VL_object_get_t get_type, hid_t dxpl_id, void **req, va_list arguments); +H5_DLL herr_t H5VL__native_object_specific(void *obj, const H5VL_loc_params_t *loc_params, H5VL_object_specific_t specific_type, hid_t dxpl_id, void **req, va_list arguments); +H5_DLL herr_t H5VL__native_object_optional(void *obj, hid_t dxpl_id, void **req, va_list arguments); + +/* Datatype callbacks */ +H5_DLL void *H5VL__native_datatype_commit(void *obj, const H5VL_loc_params_t *loc_params, const char *name, hid_t type_id, hid_t lcpl_id, hid_t tcpl_id, hid_t tapl_id, hid_t dxpl_id, void **req); +H5_DLL void *H5VL__native_datatype_open(void *obj, const H5VL_loc_params_t *loc_params, const char *name, hid_t tapl_id, hid_t dxpl_id, void **req); +H5_DLL herr_t H5VL__native_datatype_get(void *dt, H5VL_datatype_get_t get_type, hid_t dxpl_id, void **req, va_list arguments); +H5_DLL herr_t H5VL__native_datatype_specific(void *dt, H5VL_datatype_specific_t specific_type, hid_t dxpl_id, void **req, va_list arguments); +H5_DLL herr_t H5VL__native_datatype_close(void *dt, hid_t dxpl_id, void **req); + +#ifdef __cplusplus +} +#endif + +#endif /* _H5VLnative_private_H */ + -- cgit v0.12 From 7e8923957fdf18ce95e4947145950e382cf0585a Mon Sep 17 00:00:00 2001 From: Allen Byrne Date: Thu, 20 Dec 2018 15:11:17 -0600 Subject: HDFFV-10656 Add CHECK_VOL support to CMake --- CMakeLists.txt | 7 + MANIFEST | 8 + c++/test/CMakeTests.cmake | 63 ++----- c++/test/CMakeVFDTests.cmake | 65 +++++++ c++/test/CMakeVOLTests.cmake | 19 ++ config/cmake/volTest.cmake | 76 ++++++++ examples/CMakeTests.cmake | 18 +- release_docs/INSTALL_CMake.txt | 1 + test/CMakeTests.cmake | 10 + test/CMakeVOLTests.cmake | 322 ++++++++++++++++++++++++++++++++ testpar/CMakeTests.cmake | 20 ++ testpar/CMakeVFDTests.cmake | 57 ++++++ testpar/CMakeVOLTests.cmake | 19 ++ tools/test/h5repack/CMakeTests.cmake | 58 ++---- tools/test/h5repack/CMakeVFDTests.cmake | 65 +++++++ tools/test/h5repack/CMakeVOLTests.cmake | 55 ++++++ 16 files changed, 767 insertions(+), 96 deletions(-) create mode 100644 c++/test/CMakeVFDTests.cmake create mode 100644 c++/test/CMakeVOLTests.cmake create mode 100644 config/cmake/volTest.cmake create mode 100644 test/CMakeVOLTests.cmake create mode 100644 testpar/CMakeVFDTests.cmake create mode 100644 testpar/CMakeVOLTests.cmake create mode 100644 tools/test/h5repack/CMakeVFDTests.cmake create mode 100644 tools/test/h5repack/CMakeVOLTests.cmake diff --git a/CMakeLists.txt b/CMakeLists.txt index e2fb000..8433163 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -756,6 +756,13 @@ if (BUILD_TESTING) mark_as_advanced (HDF5_TEST_FHEAP_VFD) endif () + option (HDF5_TEST_VOL "Execute tests with different VOLs" OFF) + mark_as_advanced (HDF5_TEST_VOL) + if (HDF5_TEST_VOL) + option (HDF5_TEST_FHEAP_VOL "Execute tests with different VOLs" ON) + mark_as_advanced (HDF5_TEST_FHEAP_VOL) + endif () + option (HDF_TEST_EXPRESS "Control testing framework (0-3)" "0") mark_as_advanced (HDF_TEST_EXPRESS) diff --git a/MANIFEST b/MANIFEST index c3c7ffc..01e0e20 100644 --- a/MANIFEST +++ b/MANIFEST @@ -3207,6 +3207,7 @@ ./config/cmake/UseJavaSymlinks.cmake ./config/cmake/userblockTest.cmake ./config/cmake/vfdTest.cmake +./config/cmake/volTest.cmake ./config/cmake/wait_H5Tinit.cmake ./config/cmake_ext_mod/ConfigureChecks.cmake @@ -3247,6 +3248,8 @@ ./c++/src/CMakeLists.txt ./c++/test/CMakeLists.txt ./c++/test/CMakeTests.cmake +./c++/test/CMakeVFDTests.cmake +./c++/test/CMakeVOLTests.cmake ./examples/CMakeLists.txt ./examples/CMakeTests.cmake ./examples/run-all-ex.sh @@ -3286,10 +3289,13 @@ ./test/CMakeLists.txt ./test/CMakeTests.cmake ./test/CMakeVFDTests.cmake +./test/CMakeVOLTests.cmake ./test/flushrefreshTest.cmake ./test/ShellTests.cmake ./testpar/CMakeLists.txt ./testpar/CMakeTests.cmake +./testpar/CMakeVFDTests.cmake +./testpar/CMakeVOLTests.cmake ./tools/CMakeLists.txt ./tools/lib/CMakeLists.txt ./tools/src/CMakeLists.txt @@ -3322,6 +3328,8 @@ ./tools/src/h5repack/CMakeLists.txt ./tools/test/h5repack/CMakeLists.txt ./tools/test/h5repack/CMakeTests.cmake +./tools/test/h5repack/CMakeVFDTests.cmake +./tools/test/h5repack/CMakeVOLTests.cmake ./tools/src/h5stat/CMakeLists.txt ./tools/test/h5stat/CMakeLists.txt ./tools/test/h5stat/CMakeTests.cmake diff --git a/c++/test/CMakeTests.cmake b/c++/test/CMakeTests.cmake index 6de801e..a1c07f7 100644 --- a/c++/test/CMakeTests.cmake +++ b/c++/test/CMakeTests.cmake @@ -47,55 +47,22 @@ else () endif () set_tests_properties (CPP_testhdf5 PROPERTIES DEPENDS CPP_testhdf5-clear-objects) -if (HDF5_TEST_VFD) - - set (VFD_LIST - sec2 - stdio - core - split - multi - family - ) - - if (DIRECT_VFD) - set (VFD_LIST ${VFD_LIST} direct) - endif () +############################################################################## +############################################################################## +### V F D T E S T S ### +############################################################################## +############################################################################## - macro (ADD_VFD_TEST vfdname resultcode) - if (NOT HDF5_ENABLE_USING_MEMCHECKER) - file (MAKE_DIRECTORY "${PROJECT_BINARY_DIR}/${vfdname}") - add_test ( - NAME CPP_VFD-${vfdname}-cpp_testhdf5-clear-objects - COMMAND ${CMAKE_COMMAND} - -E remove - tattr_basic.h5 - tattr_compound.h5 - tattr_dtype.h5 - tattr_multi.h5 - tattr_scalar.h5 - tfattrs.h5 - titerate.h5 - ) - add_test ( - NAME CPP_VFD-${vfdname}-cpp_testhdf5 - COMMAND "${CMAKE_COMMAND}" - -D "TEST_PROGRAM=$" - -D "TEST_ARGS:STRING=" - -D "TEST_VFD:STRING=${vfdname}" - -D "TEST_EXPECT=${resultcode}" - -D "TEST_OUTPUT=cpp_testhdf5" - -D "TEST_FOLDER=${PROJECT_BINARY_DIR}/${vfdname}" - -P "${HDF_RESOURCES_DIR}/vfdTest.cmake" - ) - set_tests_properties (CPP_VFD-${vfdname}-cpp_testhdf5 PROPERTIES DEPENDS CPP_VFD-${vfdname}-cpp_testhdf5-clear-objects) - set_tests_properties (CPP_VFD-${vfdname}-cpp_testhdf5 PROPERTIES TIMEOUT 30) - endif () - endmacro () +if (HDF5_TEST_VFD) + include (CMakeVFDTests.cmake) +endif () - # Run test with different Virtual File Driver - foreach (vfd ${VFD_LIST}) - ADD_VFD_TEST (${vfd} 0) - endforeach () +############################################################################## +############################################################################## +### V O L T E S T S ### +############################################################################## +############################################################################## +if (HDF5_TEST_VOL) + include (CMakeVOLTests.cmake) endif () diff --git a/c++/test/CMakeVFDTests.cmake b/c++/test/CMakeVFDTests.cmake new file mode 100644 index 0000000..996a20f --- /dev/null +++ b/c++/test/CMakeVFDTests.cmake @@ -0,0 +1,65 @@ +# +# Copyright by The HDF Group. +# All rights reserved. +# +# This file is part of HDF5. The full HDF5 copyright notice, including +# terms governing use, modification, and redistribution, is contained in +# the COPYING file, which can be found at the root of the source code +# distribution tree, or in https://support.hdfgroup.org/ftp/HDF5/releases. +# If you do not have access to either file, you may request a copy from +# help@hdfgroup.org. +# + +############################################################################## +############################################################################## +### T E S T I N G ### +############################################################################## +############################################################################## + set (VFD_LIST + sec2 + stdio + core + split + multi + family + ) + + if (DIRECT_VFD) + set (VFD_LIST ${VFD_LIST} direct) + endif () + + macro (ADD_VFD_TEST vfdname resultcode) + if (NOT HDF5_ENABLE_USING_MEMCHECKER) + file (MAKE_DIRECTORY "${PROJECT_BINARY_DIR}/${vfdname}") + add_test ( + NAME CPP_VFD-${vfdname}-cpp_testhdf5-clear-objects + COMMAND ${CMAKE_COMMAND} + -E remove + tattr_basic.h5 + tattr_compound.h5 + tattr_dtype.h5 + tattr_multi.h5 + tattr_scalar.h5 + tfattrs.h5 + titerate.h5 + ) + add_test ( + NAME CPP_VFD-${vfdname}-cpp_testhdf5 + COMMAND "${CMAKE_COMMAND}" + -D "TEST_PROGRAM=$" + -D "TEST_ARGS:STRING=" + -D "TEST_VFD:STRING=${vfdname}" + -D "TEST_EXPECT=${resultcode}" + -D "TEST_OUTPUT=cpp_testhdf5" + -D "TEST_FOLDER=${PROJECT_BINARY_DIR}/${vfdname}" + -P "${HDF_RESOURCES_DIR}/vfdTest.cmake" + ) + set_tests_properties (CPP_VFD-${vfdname}-cpp_testhdf5 PROPERTIES DEPENDS CPP_VFD-${vfdname}-cpp_testhdf5-clear-objects) + set_tests_properties (CPP_VFD-${vfdname}-cpp_testhdf5 PROPERTIES TIMEOUT 30) + endif () + endmacro () + + # Run test with different Virtual File Driver + foreach (vfd ${VFD_LIST}) + ADD_VFD_TEST (${vfd} 0) + endforeach () diff --git a/c++/test/CMakeVOLTests.cmake b/c++/test/CMakeVOLTests.cmake new file mode 100644 index 0000000..be3ecc2 --- /dev/null +++ b/c++/test/CMakeVOLTests.cmake @@ -0,0 +1,19 @@ +# +# Copyright by The HDF Group. +# All rights reserved. +# +# This file is part of HDF5. The full HDF5 copyright notice, including +# terms governing use, modification, and redistribution, is contained in +# the COPYING file, which can be found at the root of the source code +# distribution tree, or in https://support.hdfgroup.org/ftp/HDF5/releases. +# If you do not have access to either file, you may request a copy from +# help@hdfgroup.org. +# + +############################################################################## +############################################################################## +### T E S T I N G ### +############################################################################## +############################################################################## + set (VOL_LIST + ) diff --git a/config/cmake/volTest.cmake b/config/cmake/volTest.cmake new file mode 100644 index 0000000..27da8a5 --- /dev/null +++ b/config/cmake/volTest.cmake @@ -0,0 +1,76 @@ +# +# Copyright by The HDF Group. +# All rights reserved. +# +# This file is part of HDF5. The full HDF5 copyright notice, including +# terms governing use, modification, and redistribution, is contained in +# the COPYING file, which can be found at the root of the source code +# distribution tree, or in https://support.hdfgroup.org/ftp/HDF5/releases. +# If you do not have access to either file, you may request a copy from +# help@hdfgroup.org. +# +# volTest.cmake executes a command and captures the output in a file. Command uses specified VOL. +# Exit status of command can also be compared. + +# arguments checking +if (NOT TEST_PROGRAM) + message (FATAL_ERROR "Require TEST_PROGRAM to be defined") +endif () +if (NOT TEST_FOLDER) + message ( FATAL_ERROR "Require TEST_FOLDER to be defined") +endif () +if (NOT TEST_VOL) + message (FATAL_ERROR "Require TEST_VOL to be defined") +endif () + +if (EXISTS ${TEST_FOLDER}/${TEST_OUTPUT}) + file (REMOVE ${TEST_FOLDER}/${TEST_OUTPUT}) +endif () + +if (EXISTS ${TEST_FOLDER}/${TEST_OUTPUT}.err) + file (REMOVE ${TEST_FOLDER}/${TEST_OUTPUT}.err) +endif () + +# if there is not an error reference file add the error output to the stdout file +#if (NOT TEST_ERRREF) +# set (ERROR_APPEND 1) +#endif () + +message (STATUS "USING ${TEST_VOL} ON COMMAND: ${TEST_PROGRAM} ${TEST_ARGS}") + +set (ENV{HDF5_VOL_CONNECTOR} "${TEST_VOL}") + +# run the test program, capture the stdout/stderr and the result var +execute_process ( + COMMAND ${TEST_PROGRAM} ${TEST_ARGS} + WORKING_DIRECTORY ${TEST_FOLDER} + RESULT_VARIABLE TEST_RESULT + OUTPUT_FILE ${TEST_OUTPUT}.out + ERROR_FILE ${TEST_OUTPUT}.err + OUTPUT_VARIABLE TEST_OUT + ERROR_VARIABLE TEST_ERROR +) + +message (STATUS "COMMAND Result: ${TEST_RESULT}") + +# if the .err file exists and ERRROR_APPEND is enabled +if (ERROR_APPEND AND EXISTS ${TEST_FOLDER}/${TEST_OUTPUT}.err) + file (READ ${TEST_FOLDER}/${TEST_OUTPUT}.err TEST_STREAM) + file (APPEND ${TEST_FOLDER}/${TEST_OUTPUT}.out "${TEST_STREAM}") +endif () + +# if the return value is !=${TEST_EXPECT} bail out +if (NOT "${TEST_RESULT}" STREQUAL "${TEST_EXPECT}") + if (NOT TEST_NOERRDISPLAY) + if (EXISTS ${TEST_FOLDER}/${TEST_OUTPUT}.out) + file (READ ${TEST_FOLDER}/${TEST_OUTPUT}.out TEST_STREAM) + message (STATUS "Output USING ${TEST_VOL}:\n${TEST_STREAM}") + endif () + endif () + message (FATAL_ERROR "Failed: Test program ${TEST_PROGRAM} exited != ${TEST_EXPECT}.\n${TEST_ERROR}") +endif () + +message (STATUS "COMMAND Error: ${TEST_ERROR}") + +# everything went fine... +message ("Passed: The ${TEST_PROGRAM} program used vol ${TEST_VOL}") diff --git a/examples/CMakeTests.cmake b/examples/CMakeTests.cmake index dd4766a..6b4504b 100644 --- a/examples/CMakeTests.cmake +++ b/examples/CMakeTests.cmake @@ -181,9 +181,9 @@ ### Windows pops up a modal permission dialog on this test if (H5_HAVE_PARALLEL AND NOT WIN32) if (HDF5_ENABLE_USING_MEMCHECKER) - add_test (NAME EXAMPLES-ph5example COMMAND $) + add_test (NAME EXAMPLES_PAR-ph5example COMMAND $) else () - add_test (NAME EXAMPLES-ph5example COMMAND "${CMAKE_COMMAND}" + add_test (NAME EXAMPLES_PAR-ph5example COMMAND "${CMAKE_COMMAND}" -D "TEST_PROGRAM=$" -D "TEST_ARGS:STRING=" -D "TEST_EXPECT=0" @@ -195,14 +195,14 @@ ) endif () if (NOT "${last_test}" STREQUAL "") - set_tests_properties (EXAMPLES-ph5example PROPERTIES DEPENDS ${last_test}) + set_tests_properties (EXAMPLES_PAR-ph5example PROPERTIES DEPENDS ${last_test}) endif () - set (last_test "EXAMPLES-ph5example") + set (last_test "EXAMPLES_PAR-ph5example") if (BUILD_SHARED_LIBS) if (HDF5_ENABLE_USING_MEMCHECKER) - add_test (NAME EXAMPLES-shared-ph5example COMMAND $) + add_test (NAME EXAMPLES_PAR-shared-ph5example COMMAND $) else () - add_test (NAME EXAMPLES-shared-ph5example COMMAND "${CMAKE_COMMAND}" + add_test (NAME EXAMPLES_PAR-shared-ph5example COMMAND "${CMAKE_COMMAND}" -D "TEST_PROGRAM=$" -D "TEST_ARGS:STRING=" -D "TEST_EXPECT=0" @@ -213,10 +213,10 @@ -P "${HDF_RESOURCES_EXT_DIR}/runTest.cmake" ) endif () - set_tests_properties (EXAMPLES-shared-ph5example PROPERTIES WORKING_DIRECTORY ${PROJECT_BINARY_DIR}/H5EX-shared) + set_tests_properties (EXAMPLES_PAR-shared-ph5example PROPERTIES WORKING_DIRECTORY ${PROJECT_BINARY_DIR}/H5EX-shared) if (NOT "${last_test}" STREQUAL "") - set_tests_properties (EXAMPLES-shared-ph5example PROPERTIES DEPENDS ${last_test}) + set_tests_properties (EXAMPLES_PAR-shared-ph5example PROPERTIES DEPENDS ${last_test}) endif () - set (last_test "EXAMPLES-shared-ph5example") + set (last_test "EXAMPLES_PAR-shared-ph5example") endif () endif () diff --git a/release_docs/INSTALL_CMake.txt b/release_docs/INSTALL_CMake.txt index edd876a..1c00fde 100644 --- a/release_docs/INSTALL_CMake.txt +++ b/release_docs/INSTALL_CMake.txt @@ -651,6 +651,7 @@ HDF5_PACKAGE_EXTLIBS "CPACK - include external libraries" HDF5_STRICT_FORMAT_CHECKS "Whether to perform strict file format checks" OFF HDF_TEST_EXPRESS "Control testing framework (0-3)" "0" HDF5_TEST_VFD "Execute tests with different VFDs" OFF +HDF5_TEST_VOL "Execute tests with different VOLs" OFF HDF5_USE_16_API_DEFAULT "Use the HDF5 1.6.x API by default" OFF HDF5_USE_18_API_DEFAULT "Use the HDF5 1.8.x API by default" OFF HDF5_USE_110_API_DEFAULT "Use the HDF5 1.10.x API by default" OFF diff --git a/test/CMakeTests.cmake b/test/CMakeTests.cmake index 1c26def..26faba6 100644 --- a/test/CMakeTests.cmake +++ b/test/CMakeTests.cmake @@ -1127,6 +1127,16 @@ endif () ############################################################################## ############################################################################## +### V O L T E S T S ### +############################################################################## +############################################################################## + +if (HDF5_TEST_VOL) + include (CMakeVOLTests.cmake) +endif () + +############################################################################## +############################################################################## ### T H E G E N E R A T O R S ### ############################################################################## ############################################################################## diff --git a/test/CMakeVOLTests.cmake b/test/CMakeVOLTests.cmake new file mode 100644 index 0000000..39fa2a6 --- /dev/null +++ b/test/CMakeVOLTests.cmake @@ -0,0 +1,322 @@ + +# Copyright by The HDF Group. +# All rights reserved. +# +# This file is part of HDF5. The full HDF5 copyright notice, including +# terms governing use, modification, and redistribution, is contained in +# the COPYING file, which can be found at the root of the source code +# distribution tree, or in https://support.hdfgroup.org/ftp/HDF5/releases. +# If you do not have access to either file, you may request a copy from +# help@hdfgroup.org. +# + +############################################################################## +############################################################################## +### T E S T I N G ### +############################################################################## +############################################################################## +# included from CMakeTests.cmake + +set (VOL_LIST + vol_native + vol_pass_through1 + vol_pass_through2 +) + +set (vol_native native) +set (vol_pass_through1 "pass_through under_vol=0\;under_info={}") +set (vol_pass_through2 "pass_through under_vol=505\;under_info={under_vol=0\;under_info={}}") + +foreach (voltest ${VOL_LIST}) + file (MAKE_DIRECTORY "${PROJECT_BINARY_DIR}/${voltest}") + file (MAKE_DIRECTORY "${PROJECT_BINARY_DIR}/${voltest}/testfiles") + file (MAKE_DIRECTORY "${PROJECT_BINARY_DIR}/${voltest}/testfiles/plist_files") + if (BUILD_SHARED_LIBS) + file (MAKE_DIRECTORY "${PROJECT_BINARY_DIR}/${voltest}-shared") + file (MAKE_DIRECTORY "${PROJECT_BINARY_DIR}/${voltest}-shared/testfiles") + file (MAKE_DIRECTORY "${PROJECT_BINARY_DIR}/${voltest}-shared/testfiles/plist_files") + endif () +endforeach () + +foreach (voltest ${VOL_LIST}) + foreach (h5_tfile ${HDF5_TEST_FILES}) + HDFTEST_COPY_FILE("${HDF5_TOOLS_DIR}/testfiles/${h5_tfile}" "${PROJECT_BINARY_DIR}/${voltest}/${h5_tfile}" "HDF5_VOLTEST_LIB_files") + if (BUILD_SHARED_LIBS) + HDFTEST_COPY_FILE("${HDF5_TOOLS_DIR}/testfiles/${h5_tfile}" "${PROJECT_BINARY_DIR}/${voltest}-shared/${h5_tfile}" "HDF5_VOLTEST_LIBSH_files") + endif () + endforeach () +endforeach () + +foreach (voltest ${VOL_LIST}) + foreach (ref_file ${HDF5_REFERENCE_FILES}) + HDFTEST_COPY_FILE("${HDF5_TEST_SOURCE_DIR}/testfiles/${ref_file}" "${PROJECT_BINARY_DIR}/${voltest}/${ref_file}" "HDF5_VOLTEST_LIB_files") + if (BUILD_SHARED_LIBS) + HDFTEST_COPY_FILE("${HDF5_TEST_SOURCE_DIR}/testfiles/${ref_file}" "${PROJECT_BINARY_DIR}/${voltest}-shared/${ref_file}" "HDF5_VOLTEST_LIBSH_files") + endif () + endforeach () +endforeach () + +foreach (voltest ${VOL_LIST}) + foreach (h5_file ${HDF5_REFERENCE_TEST_FILES}) + HDFTEST_COPY_FILE("${HDF5_TEST_SOURCE_DIR}/${h5_file}" "${HDF5_TEST_BINARY_DIR}/${voltest}/${h5_file}" "HDF5_VOLTEST_LIB_files") + if (BUILD_SHARED_LIBS) + HDFTEST_COPY_FILE("${HDF5_TEST_SOURCE_DIR}/${h5_file}" "${HDF5_TEST_BINARY_DIR}/${voltest}-shared/${h5_file}" "HDF5_VOLTEST_LIBSH_files") + endif () + endforeach () +endforeach () + +foreach (voltest ${VOL_LIST}) + foreach (plistfile ${HDF5_REFERENCE_PLIST_FILES}) + HDFTEST_COPY_FILE("${HDF5_TEST_SOURCE_DIR}/testfiles/plist_files/${plistfile}" "${PROJECT_BINARY_DIR}/${voltest}/testfiles/plist_files/${plistfile}" "HDF5_VOLTEST_LIB_files") + HDFTEST_COPY_FILE("${HDF5_TEST_SOURCE_DIR}/testfiles/plist_files/def_${plistfile}" "${PROJECT_BINARY_DIR}/${voltest}/testfiles/plist_files/def_${plistfile}" "HDF5_VOLTEST_LIB_files") + if (BUILD_SHARED_LIBS) + HDFTEST_COPY_FILE("${HDF5_TEST_SOURCE_DIR}/testfiles/plist_files/${plistfile}" "${PROJECT_BINARY_DIR}/${voltest}-shared/testfiles/plist_files/${plistfile}" "HDF5_VOLTEST_LIBSH_files") + HDFTEST_COPY_FILE("${HDF5_TEST_SOURCE_DIR}/testfiles/plist_files/def_${plistfile}" "${PROJECT_BINARY_DIR}/${voltest}-shared/testfiles/plist_files/def_${plistfile}" "HDF5_VOLTEST_LIBSH_files") + endif () + endforeach () +endforeach () + +add_custom_target(HDF5_VOLTEST_LIB_files ALL COMMENT "Copying files needed by HDF5_VOLTEST_LIB tests" DEPENDS ${HDF5_VOLTEST_LIB_files_list}) +if (BUILD_SHARED_LIBS) + add_custom_target(HDF5_VOLTEST_LIBSH_files ALL COMMENT "Copying files needed by HDF5_VOLTEST_LIBSH tests" DEPENDS ${HDF5_VOLTEST_LIBSH_files_list}) +endif () + +############################################################################## +############################################################################## +### V O L T E S T S ### +############################################################################## +############################################################################## + + set (H5_VOL_SKIP_TESTS + cache + accum + fheap + big + vol + error_test + err_compat + tcheck_version + testmeta + links_env + ) + if (NOT CYGWIN) + list (REMOVE_ITEM H5_VOL_SKIP_TESTS big cache) + endif () + + # Windows only macro + macro (CHECK_VOL_TEST voltest volname volinfo resultcode) + if ("${voltest}" STREQUAL "flush1" OR "${voltest}" STREQUAL "flush2") + if ("${volname}" STREQUAL "multi" OR "${volname}" STREQUAL "split") + if (NOT BUILD_SHARED_LIBS AND NOT ${HDF_CFG_NAME} MATCHES "Debug") + add_test (NAME VOL-${volname}-${voltest} + COMMAND "${CMAKE_COMMAND}" + -D "TEST_PROGRAM=$" + -D "TEST_ARGS:STRING=" + -D "TEST_VOL:STRING=${volinfo}" + -D "TEST_EXPECT=${resultcode}" + -D "TEST_OUTPUT=${volname}-${voltest}" + -D "TEST_FOLDER=${PROJECT_BINARY_DIR}/${volname}" + -P "${HDF_RESOURCES_DIR}/volTest.cmake" + ) + set_tests_properties (VOL-${volname}-${voltest} PROPERTIES + ENVIRONMENT "srcdir=${HDF5_TEST_BINARY_DIR}/${volname}" + WORKING_DIRECTORY ${HDF5_TEST_BINARY_DIR}/${volname} + ) + if (BUILD_SHARED_LIBS) + add_test (NAME VOL-${volname}-${test}-shared + COMMAND "${CMAKE_COMMAND}" + -D "TEST_PROGRAM=$" + -D "TEST_ARGS:STRING=" + -D "TEST_VOL:STRING=${volinfo}" + -D "TEST_EXPECT=${resultcode}" + -D "TEST_OUTPUT=${volname}-${voltest}-shared" + -D "TEST_FOLDER=${PROJECT_BINARY_DIR}/${volname}-shared" + -P "${HDF_RESOURCES_DIR}/volTest.cmake" + ) + set_tests_properties (VOL-${volname}-${voltest}-shared PROPERTIES + ENVIRONMENT "srcdir=${HDF5_TEST_BINARY_DIR}/${volname}-shared" + WORKING_DIRECTORY ${HDF5_TEST_BINARY_DIR}/${volname}-shared + ) + endif () + else () + add_test (NAME VOL-${volname}-${voltest} + COMMAND ${CMAKE_COMMAND} -E echo "SKIP VOL-${volname}-${voltest}" + ) + if (BUILD_SHARED_LIBS) + add_test (NAME VOL-${volname}-${test}-shared + COMMAND ${CMAKE_COMMAND} -E echo "SKIP VOL-${volname}-${voltest}-shared" + ) + endif () + endif () + else () + add_test (NAME VOL-${volname}-${voltest} + COMMAND "${CMAKE_COMMAND}" + -D "TEST_PROGRAM=$" + -D "TEST_ARGS:STRING=" + -D "TEST_VOL:STRING=${volinfo}" + -D "TEST_EXPECT=${resultcode}" + -D "TEST_OUTPUT=${volname}-${voltest}" + -D "TEST_FOLDER=${PROJECT_BINARY_DIR}/${volname}" + -P "${HDF_RESOURCES_DIR}/volTest.cmake" + ) + set_tests_properties (VOL-${volname}-${voltest} PROPERTIES + ENVIRONMENT "srcdir=${HDF5_TEST_BINARY_DIR}/${volname}" + WORKING_DIRECTORY ${HDF5_TEST_BINARY_DIR}/${volname} + ) + if (BUILD_SHARED_LIBS) + add_test (NAME VOL-${volname}-${test}-shared + COMMAND "${CMAKE_COMMAND}" + -D "TEST_PROGRAM=$" + -D "TEST_ARGS:STRING=" + -D "TEST_VOL:STRING=${volinfo}" + -D "TEST_EXPECT=${resultcode}" + -D "TEST_OUTPUT=${volname}-${voltest}-shared" + -D "TEST_FOLDER=${PROJECT_BINARY_DIR}/${volname}-shared" + -P "${HDF_RESOURCES_DIR}/volTest.cmake" + ) + set_tests_properties (VOL-${volname}-${voltest}-shared PROPERTIES + ENVIRONMENT "srcdir=${HDF5_TEST_BINARY_DIR}/${volname}-shared" + WORKING_DIRECTORY ${HDF5_TEST_BINARY_DIR}/${volname}-shared + ) + endif () + endif () + else () + add_test (NAME VOL-${volname}-${voltest} + COMMAND "${CMAKE_COMMAND}" + -D "TEST_PROGRAM=$" + -D "TEST_ARGS:STRING=" + -D "TEST_VOL:STRING=${volinfo}" + -D "TEST_EXPECT=${resultcode}" + -D "TEST_OUTPUT=${volname}-${voltest}" + -D "TEST_FOLDER=${PROJECT_BINARY_DIR}/${volname}" + -P "${HDF_RESOURCES_DIR}/volTest.cmake" + ) + set_tests_properties (VOL-${volname}-${voltest} PROPERTIES + ENVIRONMENT "srcdir=${HDF5_TEST_BINARY_DIR}/${volname};HDF5TestExpress=${HDF_TEST_EXPRESS}" + WORKING_DIRECTORY ${HDF5_TEST_BINARY_DIR}/${volname} + ) + if (BUILD_SHARED_LIBS AND NOT "${voltest}" STREQUAL "cache") + add_test (NAME VOL-${volname}-${voltest}-shared + COMMAND "${CMAKE_COMMAND}" + -D "TEST_PROGRAM=$" + -D "TEST_ARGS:STRING=" + -D "TEST_VOL:STRING=${volinfo}" + -D "TEST_EXPECT=${resultcode}" + -D "TEST_OUTPUT=${volname}-${voltest}-shared" + -D "TEST_FOLDER=${PROJECT_BINARY_DIR}/${volname}-shared" + -P "${HDF_RESOURCES_DIR}/volTest.cmake" + ) + set_tests_properties (VOL-${volname}-${voltest}-shared PROPERTIES + ENVIRONMENT "srcdir=${HDF5_TEST_BINARY_DIR}/${volname}-shared;HDF5TestExpress=${HDF_TEST_EXPRESS}" + WORKING_DIRECTORY ${HDF5_TEST_BINARY_DIR}/${volname}-shared + ) + endif () + endif () + endmacro () + + macro (DO_VOL_TEST voltest volname volinfo resultcode) + #message(STATUS "${voltest}-${volname} with ${volinfo}") + add_test (NAME VOL-${volname}-${voltest} + COMMAND "${CMAKE_COMMAND}" + -D "TEST_PROGRAM=$" + -D "TEST_ARGS:STRING=" + -D "TEST_VOL:STRING=${volinfo}" + -D "TEST_EXPECT=${resultcode}" + -D "TEST_OUTPUT=${volname}-${voltest}" + -D "TEST_FOLDER=${PROJECT_BINARY_DIR}/${volname}" + -P "${HDF_RESOURCES_DIR}/volTest.cmake" + ) + set_tests_properties (VOL-${volname}-${voltest} PROPERTIES + ENVIRONMENT "srcdir=${HDF5_TEST_BINARY_DIR}/${volname}" + WORKING_DIRECTORY ${HDF5_TEST_BINARY_DIR}/${volname} + ) + if (BUILD_SHARED_LIBS) + add_test (NAME VOL-${volname}-${voltest}-shared + COMMAND "${CMAKE_COMMAND}" + -D "TEST_PROGRAM=$" + -D "TEST_ARGS:STRING=" + -D "TEST_VOL:STRING=${volinfo}" + -D "TEST_EXPECT=${resultcode}" + -D "TEST_OUTPUT=${volname}-${voltest}-shared" + -D "TEST_FOLDER=${PROJECT_BINARY_DIR}/${volname}-shared" + -P "${HDF_RESOURCES_DIR}/volTest.cmake" + ) + set_tests_properties (VOL-${volname}-${voltest}-shared PROPERTIES + ENVIRONMENT "srcdir=${HDF5_TEST_BINARY_DIR}/${volname}-shared" + WORKING_DIRECTORY ${HDF5_TEST_BINARY_DIR}/${volname}-shared + ) + endif () + endmacro () + + macro (ADD_VOL_TEST volname volinfo resultcode) + #message(STATUS "volname=${volname} volinfo=${volinfo}") + foreach (test ${H5_TESTS}) + if (NOT ${test} IN_LIST H5_VOL_SKIP_TESTS) + if (WIN32) + CHECK_VOL_TEST (${test} ${volname} "${volinfo}" ${resultcode}) + else () + DO_VOL_TEST (${test} ${volname} "${volinfo}" ${resultcode}) + endif () + endif () + endforeach () + set_tests_properties (VOL-${volname}-flush2 PROPERTIES DEPENDS VOL-${volname}-flush1) + set_tests_properties (VOL-${volname}-flush1 PROPERTIES TIMEOUT 10) + set_tests_properties (VOL-${volname}-flush2 PROPERTIES TIMEOUT 10) + set_tests_properties (VOL-${volname}-istore PROPERTIES TIMEOUT 1800) + if (NOT CYGWIN) + set_tests_properties (VOL-${volname}-cache PROPERTIES TIMEOUT 1800) + endif () + if (BUILD_SHARED_LIBS) + set_tests_properties (VOL-${volname}-flush2-shared PROPERTIES DEPENDS VOL-${volname}-flush1-shared) + set_tests_properties (VOL-${volname}-flush1-shared PROPERTIES TIMEOUT 10) + set_tests_properties (VOL-${volname}-flush2-shared PROPERTIES TIMEOUT 10) + set_tests_properties (VOL-${volname}-istore-shared PROPERTIES TIMEOUT 1800) + if (NOT CYGWIN AND NOT WIN32) + set_tests_properties (VOL-${volname}-cache-shared PROPERTIES TIMEOUT 1800) + endif () + endif () + if (HDF5_TEST_FHEAP_VOL) + add_test (NAME VOL-${volname}-fheap + COMMAND "${CMAKE_COMMAND}" + -D "TEST_PROGRAM=$" + -D "TEST_ARGS:STRING=" + -D "TEST_VOL:STRING=${volinfo}" + -D "TEST_EXPECT=${resultcode}" + -D "TEST_OUTPUT=${volname}-fheap" + -D "TEST_FOLDER=${PROJECT_BINARY_DIR}/${volname}" + -P "${HDF_RESOURCES_DIR}/volTest.cmake" + ) + set_tests_properties (VOL-${volname}-fheap PROPERTIES + TIMEOUT 1800 + ENVIRONMENT "srcdir=${HDF5_TEST_BINARY_DIR}/${volname};HDF5TestExpress=${HDF_TEST_EXPRESS}" + WORKING_DIRECTORY ${HDF5_TEST_BINARY_DIR}/${volname} + ) + if (BUILD_SHARED_LIBS) + add_test (NAME VOL-${volname}-fheap-shared + COMMAND "${CMAKE_COMMAND}" + -D "TEST_PROGRAM=$" + -D "TEST_ARGS:STRING=" + -D "TEST_VOL:STRING=${volinfo}" + -D "TEST_EXPECT=${resultcode}" + -D "TEST_OUTPUT=${volname}-fheap-shared" + -D "TEST_FOLDER=${PROJECT_BINARY_DIR}/${volname}-shared" + -P "${HDF_RESOURCES_DIR}/volTest.cmake" + ) + set_tests_properties (VOL-${volname}-fheap-shared PROPERTIES + TIMEOUT 1800 + ENVIRONMENT "srcdir=${HDF5_TEST_BINARY_DIR}/${volname}-shared;HDF5TestExpress=${HDF_TEST_EXPRESS}" + WORKING_DIRECTORY ${HDF5_TEST_BINARY_DIR}/${volname}-shared + ) + endif () + endif () + endmacro () + + # Run test with different Virtual File Driver + foreach (volname ${VOL_LIST}) + #message(STATUS "volname=${volname}") + foreach (volinfo IN LISTS ${volname}) + #message(STATUS "${volname} volinfo=${volinfo}") + ADD_VOL_TEST (${volname} "${volinfo}" 0) + endforeach () + endforeach () + diff --git a/testpar/CMakeTests.cmake b/testpar/CMakeTests.cmake index 87470f3..ffe4cb5 100644 --- a/testpar/CMakeTests.cmake +++ b/testpar/CMakeTests.cmake @@ -27,6 +27,26 @@ endforeach () set_property (TEST TEST_PAR_t_pflush1 PROPERTY PASS_REGULAR_EXPRESSION "PASSED") set_tests_properties (TEST_PAR_t_pflush2 PROPERTIES DEPENDS TEST_PAR_t_pflush1) +############################################################################## +############################################################################## +### V F D T E S T S ### +############################################################################## +############################################################################## + +if (HDF5_TEST_VFD) + include (CMakeVFDTests.cmake) +endif () + +############################################################################## +############################################################################## +### V O L T E S T S ### +############################################################################## +############################################################################## + +if (HDF5_TEST_VOL) + include (CMakeVOLTests.cmake) +endif () + if (HDF5_TEST_VFD) set (VFD_LIST diff --git a/testpar/CMakeVFDTests.cmake b/testpar/CMakeVFDTests.cmake new file mode 100644 index 0000000..b6b065f --- /dev/null +++ b/testpar/CMakeVFDTests.cmake @@ -0,0 +1,57 @@ +# +# Copyright by The HDF Group. +# All rights reserved. +# +# This file is part of HDF5. The full HDF5 copyright notice, including +# terms governing use, modification, and redistribution, is contained in +# the COPYING file, which can be found at the root of the source code +# distribution tree, or in https://support.hdfgroup.org/ftp/HDF5/releases. +# If you do not have access to either file, you may request a copy from +# help@hdfgroup.org. +# + +############################################################################## +############################################################################## +### T E S T I N G ### +############################################################################## +############################################################################## + set (VFD_LIST + sec2 + stdio + core + split + multi + family + ) + + set (H5P_VFD_TESTS + t_pflush1 + t_pflush2 + ) + + if (DIRECT_VFD) + set (VFD_LIST ${VFD_LIST} direct) + endif () + + macro (ADD_VFD_TEST vfdname resultcode) + if (NOT HDF5_ENABLE_USING_MEMCHECKER) + foreach (test ${H5P_VFD_TESTS}) + add_test ( + NAME TEST_PAR_VFD-${vfdname}-${test} + COMMAND "${CMAKE_COMMAND}" + -D "TEST_PROGRAM=$" + -D "TEST_ARGS:STRING=" + -D "TEST_VFD:STRING=${vfdname}" + -D "TEST_EXPECT=${resultcode}" + -D "TEST_OUTPUT=${test}" + -D "TEST_FOLDER=${PROJECT_BINARY_DIR}" + -P "${HDF_RESOURCES_DIR}/vfdTest.cmake" + ) + endforeach () + endif () + endmacro () + + # Run test with different Virtual File Driver + foreach (vfd ${VFD_LIST}) + ADD_VFD_TEST (${vfd} 0) + endforeach () diff --git a/testpar/CMakeVOLTests.cmake b/testpar/CMakeVOLTests.cmake new file mode 100644 index 0000000..be3ecc2 --- /dev/null +++ b/testpar/CMakeVOLTests.cmake @@ -0,0 +1,19 @@ +# +# Copyright by The HDF Group. +# All rights reserved. +# +# This file is part of HDF5. The full HDF5 copyright notice, including +# terms governing use, modification, and redistribution, is contained in +# the COPYING file, which can be found at the root of the source code +# distribution tree, or in https://support.hdfgroup.org/ftp/HDF5/releases. +# If you do not have access to either file, you may request a copy from +# help@hdfgroup.org. +# + +############################################################################## +############################################################################## +### T E S T I N G ### +############################################################################## +############################################################################## + set (VOL_LIST + ) diff --git a/tools/test/h5repack/CMakeTests.cmake b/tools/test/h5repack/CMakeTests.cmake index ad468f0..d48f188 100644 --- a/tools/test/h5repack/CMakeTests.cmake +++ b/tools/test/h5repack/CMakeTests.cmake @@ -16,39 +16,6 @@ ############################################################################## ############################################################################## - if (HDF5_TEST_VFD) - set (VFD_LIST - sec2 - stdio - core - split - multi - family - ) - - if (DIRECT_VFD) - set (VFD_LIST ${VFD_LIST} direct) - endif () - - macro (ADD_VFD_TEST vfdname resultcode) - add_test ( - NAME H5REPACK-VFD-${vfdname}-h5repacktest - COMMAND "${CMAKE_COMMAND}" - -D "TEST_PROGRAM=$" - -D "TEST_ARGS:STRING=" - -D "TEST_VFD:STRING=${vfdname}" - -D "TEST_EXPECT=${resultcode}" - -D "TEST_OUTPUT=h5repacktest" - -D "TEST_FOLDER=${PROJECT_BINARY_DIR}" - -P "${HDF_RESOURCES_DIR}/vfdTest.cmake" - ) - if (NOT "${last_test}" STREQUAL "") - set_tests_properties (H5REPACK-VFD-${vfdname}-h5repacktest PROPERTIES DEPENDS ${last_test}) - endif () - set (last_test "H5REPACK-VFD-${vfdname}-h5repacktest") - endmacro () - endif () - # -------------------------------------------------------------------- # Copy all the HDF5 files from the source directory into the test directory # -------------------------------------------------------------------- @@ -1459,9 +1426,22 @@ if (BUILD_SHARED_LIBS) ADD_H5_UD_TEST (plugin_zero 0 h5repack_layout.h5 -v -f UD=250,0,0) endif () - if (HDF5_TEST_VFD) - # Run test with different Virtual File Driver - foreach (vfd ${VFD_LIST}) - ADD_VFD_TEST (${vfd} 0) - endforeach () - endif () +############################################################################## +############################################################################## +### V F D T E S T S ### +############################################################################## +############################################################################## + +if (HDF5_TEST_VFD) + include (CMakeVFDTests.cmake) +endif () + +############################################################################## +############################################################################## +### V O L T E S T S ### +############################################################################## +############################################################################## + +if (HDF5_TEST_VOL) + include (CMakeVOLTests.cmake) +endif () diff --git a/tools/test/h5repack/CMakeVFDTests.cmake b/tools/test/h5repack/CMakeVFDTests.cmake new file mode 100644 index 0000000..2042f31 --- /dev/null +++ b/tools/test/h5repack/CMakeVFDTests.cmake @@ -0,0 +1,65 @@ +# +# Copyright by The HDF Group. +# All rights reserved. +# +# This file is part of HDF5. The full HDF5 copyright notice, including +# terms governing use, modification, and redistribution, is contained in +# the COPYING file, which can be found at the root of the source code +# distribution tree, or in https://support.hdfgroup.org/ftp/HDF5/releases. +# If you do not have access to either file, you may request a copy from +# help@hdfgroup.org. +# + +############################################################################## +############################################################################## +### T E S T I N G ### +############################################################################## +############################################################################## + + set (VFD_LIST + sec2 + stdio + core + split + multi + family + ) + + if (DIRECT_VFD) + set (VFD_LIST ${VFD_LIST} direct) + endif () + +############################################################################## +############################################################################## +### T H E T E S T S M A C R O S ### +############################################################################## +############################################################################## + + macro (ADD_VFD_TEST vfdname resultcode) + add_test ( + NAME H5REPACK-VFD-${vfdname}-h5repacktest + COMMAND "${CMAKE_COMMAND}" + -D "TEST_PROGRAM=$" + -D "TEST_ARGS:STRING=" + -D "TEST_VFD:STRING=${vfdname}" + -D "TEST_EXPECT=${resultcode}" + -D "TEST_OUTPUT=h5repacktest" + -D "TEST_FOLDER=${PROJECT_BINARY_DIR}" + -P "${HDF_RESOURCES_DIR}/vfdTest.cmake" + ) + if (NOT "${last_test}" STREQUAL "") + set_tests_properties (H5REPACK-VFD-${vfdname}-h5repacktest PROPERTIES DEPENDS ${last_test}) + endif () + set (last_test "H5REPACK-VFD-${vfdname}-h5repacktest") + endmacro () + +############################################################################## +############################################################################## +### T H E T E S T S ### +############################################################################## +############################################################################## + + # Run test with different Virtual File Driver + foreach (vfd ${VFD_LIST}) + ADD_VFD_TEST (${vfd} 0) + endforeach () diff --git a/tools/test/h5repack/CMakeVOLTests.cmake b/tools/test/h5repack/CMakeVOLTests.cmake new file mode 100644 index 0000000..da19d59 --- /dev/null +++ b/tools/test/h5repack/CMakeVOLTests.cmake @@ -0,0 +1,55 @@ +# +# Copyright by The HDF Group. +# All rights reserved. +# +# This file is part of HDF5. The full HDF5 copyright notice, including +# terms governing use, modification, and redistribution, is contained in +# the COPYING file, which can be found at the root of the source code +# distribution tree, or in https://support.hdfgroup.org/ftp/HDF5/releases. +# If you do not have access to either file, you may request a copy from +# help@hdfgroup.org. +# + +############################################################################## +############################################################################## +### T E S T I N G ### +############################################################################## +############################################################################## + + set (VOL_LIST + ) + +############################################################################## +############################################################################## +### T H E T E S T S M A C R O S ### +############################################################################## +############################################################################## + + macro (ADD_VOL_TEST volname resultcode) + add_test ( + NAME H5REPACK-VOL-${volname}-h5repacktest + COMMAND "${CMAKE_COMMAND}" + -D "TEST_PROGRAM=$" + -D "TEST_ARGS:STRING=" + -D "TEST_VFD:STRING=${volname}" + -D "TEST_EXPECT=${resultcode}" + -D "TEST_OUTPUT=h5repacktest" + -D "TEST_FOLDER=${PROJECT_BINARY_DIR}" + -P "${HDF_RESOURCES_DIR}/volTest.cmake" + ) + if (NOT "${last_test}" STREQUAL "") + set_tests_properties (H5REPACK-VOL-${volname}-h5repacktest PROPERTIES DEPENDS ${last_test}) + endif () + set (last_test "H5REPACK-VOL-${volname}-h5repacktest") + endmacro () + +############################################################################## +############################################################################## +### T H E T E S T S ### +############################################################################## +############################################################################## + + # Run test with different VOL +# foreach (vol ${VOL_LIST}) +# ADD_VOL_TEST (${vol} 0) +# endforeach () -- cgit v0.12 From 3c8b00dbd8537528eb031ee0b8bb31297714fbf3 Mon Sep 17 00:00:00 2001 From: Allen Byrne Date: Thu, 20 Dec 2018 15:35:37 -0600 Subject: HDFFV-10656 remove moved source --- testpar/CMakeTests.cmake | 45 --------------------------------------------- 1 file changed, 45 deletions(-) diff --git a/testpar/CMakeTests.cmake b/testpar/CMakeTests.cmake index ffe4cb5..5f668cd 100644 --- a/testpar/CMakeTests.cmake +++ b/testpar/CMakeTests.cmake @@ -46,48 +46,3 @@ endif () if (HDF5_TEST_VOL) include (CMakeVOLTests.cmake) endif () - -if (HDF5_TEST_VFD) - - set (VFD_LIST - sec2 - stdio - core - split - multi - family - ) - - set (H5P_VFD_TESTS - t_pflush1 - t_pflush2 - ) - - if (DIRECT_VFD) - set (VFD_LIST ${VFD_LIST} direct) - endif () - - macro (ADD_VFD_TEST vfdname resultcode) - if (NOT HDF5_ENABLE_USING_MEMCHECKER) - foreach (test ${H5P_VFD_TESTS}) - add_test ( - NAME TEST_PAR_VFD-${vfdname}-${test} - COMMAND "${CMAKE_COMMAND}" - -D "TEST_PROGRAM=$" - -D "TEST_ARGS:STRING=" - -D "TEST_VFD:STRING=${vfdname}" - -D "TEST_EXPECT=${resultcode}" - -D "TEST_OUTPUT=${test}" - -D "TEST_FOLDER=${PROJECT_BINARY_DIR}" - -P "${HDF_RESOURCES_DIR}/vfdTest.cmake" - ) - endforeach () - endif () - endmacro () - - # Run test with different Virtual File Driver - foreach (vfd ${VFD_LIST}) - ADD_VFD_TEST (${vfd} 0) - endforeach () - -endif () -- cgit v0.12 From 99d1f614f1b8a07a0e1f9694cf3665ed47d3eaee Mon Sep 17 00:00:00 2001 From: Allen Byrne Date: Fri, 21 Dec 2018 10:39:15 -0600 Subject: Add reference file to list --- java/test/junit.sh.in | 1 + 1 file changed, 1 insertion(+) diff --git a/java/test/junit.sh.in b/java/test/junit.sh.in index 42e16ee..add1af4 100644 --- a/java/test/junit.sh.in +++ b/java/test/junit.sh.in @@ -101,6 +101,7 @@ $HDFTEST_HOME/testfiles/JUnit-TestH5Obasic.txt $HDFTEST_HOME/testfiles/JUnit-TestH5Ocreate.txt $HDFTEST_HOME/testfiles/JUnit-TestH5Ocopy.txt $HDFTEST_HOME/testfiles/JUnit-TestH5PL.txt +$HDFTEST_HOME/testfiles/JUnit-TestH5VL.txt $HDFTEST_HOME/testfiles/JUnit-TestH5Z.txt $HDFTEST_HOME/testfiles/JUnit-TestH5E.txt $HDFTEST_HOME/testfiles/JUnit-TestH5Edefault.txt -- cgit v0.12 From 909fa39bc75f850b0f32e48e9b0f1bcd9f1be573 Mon Sep 17 00:00:00 2001 From: Allen Byrne Date: Fri, 21 Dec 2018 11:41:02 -0600 Subject: Update option text --- CMakeLists.txt | 4 ++-- release_docs/INSTALL_CMake.txt | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/CMakeLists.txt b/CMakeLists.txt index 8433163..a16cb08 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -756,10 +756,10 @@ if (BUILD_TESTING) mark_as_advanced (HDF5_TEST_FHEAP_VFD) endif () - option (HDF5_TEST_VOL "Execute tests with different VOLs" OFF) + option (HDF5_TEST_VOL "Execute tests with different VOL connectors" OFF) mark_as_advanced (HDF5_TEST_VOL) if (HDF5_TEST_VOL) - option (HDF5_TEST_FHEAP_VOL "Execute tests with different VOLs" ON) + option (HDF5_TEST_FHEAP_VOL "Execute fheap test with different VOL connectors" ON) mark_as_advanced (HDF5_TEST_FHEAP_VOL) endif () diff --git a/release_docs/INSTALL_CMake.txt b/release_docs/INSTALL_CMake.txt index 1c00fde..8acd35f 100644 --- a/release_docs/INSTALL_CMake.txt +++ b/release_docs/INSTALL_CMake.txt @@ -651,7 +651,7 @@ HDF5_PACKAGE_EXTLIBS "CPACK - include external libraries" HDF5_STRICT_FORMAT_CHECKS "Whether to perform strict file format checks" OFF HDF_TEST_EXPRESS "Control testing framework (0-3)" "0" HDF5_TEST_VFD "Execute tests with different VFDs" OFF -HDF5_TEST_VOL "Execute tests with different VOLs" OFF +HDF5_TEST_VOL "Execute tests with different VOL connectors" OFF HDF5_USE_16_API_DEFAULT "Use the HDF5 1.6.x API by default" OFF HDF5_USE_18_API_DEFAULT "Use the HDF5 1.8.x API by default" OFF HDF5_USE_110_API_DEFAULT "Use the HDF5 1.10.x API by default" OFF -- cgit v0.12 From 991996b25122ff010b9af1bbb6cc05be491ce038 Mon Sep 17 00:00:00 2001 From: Allen Byrne Date: Fri, 21 Dec 2018 12:22:32 -0600 Subject: Remove unused CMake files --- MANIFEST | 3 -- c++/test/CMakeTests.cmake | 10 ------ c++/test/CMakeVOLTests.cmake | 19 ------------ testpar/CMakeTests.cmake | 10 ------ testpar/CMakeVOLTests.cmake | 19 ------------ tools/test/h5repack/CMakeTests.cmake | 10 ------ tools/test/h5repack/CMakeVOLTests.cmake | 55 --------------------------------- 7 files changed, 126 deletions(-) delete mode 100644 c++/test/CMakeVOLTests.cmake delete mode 100644 testpar/CMakeVOLTests.cmake delete mode 100644 tools/test/h5repack/CMakeVOLTests.cmake diff --git a/MANIFEST b/MANIFEST index 01e0e20..4bc4b19 100644 --- a/MANIFEST +++ b/MANIFEST @@ -3249,7 +3249,6 @@ ./c++/test/CMakeLists.txt ./c++/test/CMakeTests.cmake ./c++/test/CMakeVFDTests.cmake -./c++/test/CMakeVOLTests.cmake ./examples/CMakeLists.txt ./examples/CMakeTests.cmake ./examples/run-all-ex.sh @@ -3295,7 +3294,6 @@ ./testpar/CMakeLists.txt ./testpar/CMakeTests.cmake ./testpar/CMakeVFDTests.cmake -./testpar/CMakeVOLTests.cmake ./tools/CMakeLists.txt ./tools/lib/CMakeLists.txt ./tools/src/CMakeLists.txt @@ -3329,7 +3327,6 @@ ./tools/test/h5repack/CMakeLists.txt ./tools/test/h5repack/CMakeTests.cmake ./tools/test/h5repack/CMakeVFDTests.cmake -./tools/test/h5repack/CMakeVOLTests.cmake ./tools/src/h5stat/CMakeLists.txt ./tools/test/h5stat/CMakeLists.txt ./tools/test/h5stat/CMakeTests.cmake diff --git a/c++/test/CMakeTests.cmake b/c++/test/CMakeTests.cmake index a1c07f7..02bff3e 100644 --- a/c++/test/CMakeTests.cmake +++ b/c++/test/CMakeTests.cmake @@ -56,13 +56,3 @@ set_tests_properties (CPP_testhdf5 PROPERTIES DEPENDS CPP_testhdf5-clear-objects if (HDF5_TEST_VFD) include (CMakeVFDTests.cmake) endif () - -############################################################################## -############################################################################## -### V O L T E S T S ### -############################################################################## -############################################################################## - -if (HDF5_TEST_VOL) - include (CMakeVOLTests.cmake) -endif () diff --git a/c++/test/CMakeVOLTests.cmake b/c++/test/CMakeVOLTests.cmake deleted file mode 100644 index be3ecc2..0000000 --- a/c++/test/CMakeVOLTests.cmake +++ /dev/null @@ -1,19 +0,0 @@ -# -# Copyright by The HDF Group. -# All rights reserved. -# -# This file is part of HDF5. The full HDF5 copyright notice, including -# terms governing use, modification, and redistribution, is contained in -# the COPYING file, which can be found at the root of the source code -# distribution tree, or in https://support.hdfgroup.org/ftp/HDF5/releases. -# If you do not have access to either file, you may request a copy from -# help@hdfgroup.org. -# - -############################################################################## -############################################################################## -### T E S T I N G ### -############################################################################## -############################################################################## - set (VOL_LIST - ) diff --git a/testpar/CMakeTests.cmake b/testpar/CMakeTests.cmake index 5f668cd..dffb813 100644 --- a/testpar/CMakeTests.cmake +++ b/testpar/CMakeTests.cmake @@ -36,13 +36,3 @@ set_tests_properties (TEST_PAR_t_pflush2 PROPERTIES DEPENDS TEST_PAR_t_pflush1) if (HDF5_TEST_VFD) include (CMakeVFDTests.cmake) endif () - -############################################################################## -############################################################################## -### V O L T E S T S ### -############################################################################## -############################################################################## - -if (HDF5_TEST_VOL) - include (CMakeVOLTests.cmake) -endif () diff --git a/testpar/CMakeVOLTests.cmake b/testpar/CMakeVOLTests.cmake deleted file mode 100644 index be3ecc2..0000000 --- a/testpar/CMakeVOLTests.cmake +++ /dev/null @@ -1,19 +0,0 @@ -# -# Copyright by The HDF Group. -# All rights reserved. -# -# This file is part of HDF5. The full HDF5 copyright notice, including -# terms governing use, modification, and redistribution, is contained in -# the COPYING file, which can be found at the root of the source code -# distribution tree, or in https://support.hdfgroup.org/ftp/HDF5/releases. -# If you do not have access to either file, you may request a copy from -# help@hdfgroup.org. -# - -############################################################################## -############################################################################## -### T E S T I N G ### -############################################################################## -############################################################################## - set (VOL_LIST - ) diff --git a/tools/test/h5repack/CMakeTests.cmake b/tools/test/h5repack/CMakeTests.cmake index d48f188..c2a2be7 100644 --- a/tools/test/h5repack/CMakeTests.cmake +++ b/tools/test/h5repack/CMakeTests.cmake @@ -1435,13 +1435,3 @@ endif () if (HDF5_TEST_VFD) include (CMakeVFDTests.cmake) endif () - -############################################################################## -############################################################################## -### V O L T E S T S ### -############################################################################## -############################################################################## - -if (HDF5_TEST_VOL) - include (CMakeVOLTests.cmake) -endif () diff --git a/tools/test/h5repack/CMakeVOLTests.cmake b/tools/test/h5repack/CMakeVOLTests.cmake deleted file mode 100644 index da19d59..0000000 --- a/tools/test/h5repack/CMakeVOLTests.cmake +++ /dev/null @@ -1,55 +0,0 @@ -# -# Copyright by The HDF Group. -# All rights reserved. -# -# This file is part of HDF5. The full HDF5 copyright notice, including -# terms governing use, modification, and redistribution, is contained in -# the COPYING file, which can be found at the root of the source code -# distribution tree, or in https://support.hdfgroup.org/ftp/HDF5/releases. -# If you do not have access to either file, you may request a copy from -# help@hdfgroup.org. -# - -############################################################################## -############################################################################## -### T E S T I N G ### -############################################################################## -############################################################################## - - set (VOL_LIST - ) - -############################################################################## -############################################################################## -### T H E T E S T S M A C R O S ### -############################################################################## -############################################################################## - - macro (ADD_VOL_TEST volname resultcode) - add_test ( - NAME H5REPACK-VOL-${volname}-h5repacktest - COMMAND "${CMAKE_COMMAND}" - -D "TEST_PROGRAM=$" - -D "TEST_ARGS:STRING=" - -D "TEST_VFD:STRING=${volname}" - -D "TEST_EXPECT=${resultcode}" - -D "TEST_OUTPUT=h5repacktest" - -D "TEST_FOLDER=${PROJECT_BINARY_DIR}" - -P "${HDF_RESOURCES_DIR}/volTest.cmake" - ) - if (NOT "${last_test}" STREQUAL "") - set_tests_properties (H5REPACK-VOL-${volname}-h5repacktest PROPERTIES DEPENDS ${last_test}) - endif () - set (last_test "H5REPACK-VOL-${volname}-h5repacktest") - endmacro () - -############################################################################## -############################################################################## -### T H E T E S T S ### -############################################################################## -############################################################################## - - # Run test with different VOL -# foreach (vol ${VOL_LIST}) -# ADD_VOL_TEST (${vol} 0) -# endforeach () -- cgit v0.12 From 9152547b766919eefb7163e17f0c03052a2d73f2 Mon Sep 17 00:00:00 2001 From: Dana Robinson Date: Thu, 27 Dec 2018 08:56:43 -0800 Subject: H5VLregister_by_value() should not set _BY_NAME when searching for plugins. --- src/H5VL.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/H5VL.c b/src/H5VL.c index eedf68d..bf1201f 100644 --- a/src/H5VL.c +++ b/src/H5VL.c @@ -295,7 +295,7 @@ H5VLregister_connector_by_value(H5VL_class_value_t value, hid_t vipl_id) const H5VL_class_t *cls; /* Try loading the connector */ - key.vol.kind = H5VL_GET_CONNECTOR_BY_NAME; + key.vol.kind = H5VL_GET_CONNECTOR_BY_VALUE; key.vol.u.value = value; if(NULL == (cls = (const H5VL_class_t *)H5PL_load(H5PL_TYPE_VOL, &key))) HGOTO_ERROR(H5E_VOL, H5E_CANTINIT, H5I_INVALID_HID, "unable to load VOL connector") -- cgit v0.12