From d17a7fa26e972714082c5061f29f6b9335e189f4 Mon Sep 17 00:00:00 2001 From: Mohamad Chaarawi Date: Thu, 22 Mar 2012 09:40:08 -0500 Subject: [svn-r22119] Changes: - add VOL implementation for H5O, H5D, and H5T functions - update the VOL interface with H5VLget routines - make upper level IDs of Type H5I_XXX_PUBLIC - bug fixes Comments: - some routines still don't go through VOL but have a workaround so they don't have to at the moment. --- src/H5D.c | 125 +----- src/H5Ddeprec.c | 70 +--- src/H5Dio.c | 92 +---- src/H5Dprivate.h | 7 + src/H5F.c | 33 +- src/H5Ftest.c | 6 +- src/H5G.c | 200 +--------- src/H5Gdeprec.c | 39 +- src/H5Gloc.c | 11 +- src/H5I.c | 175 +++++---- src/H5Iprivate.h | 13 +- src/H5Ipublic.h | 10 +- src/H5L.c | 4 +- src/H5O.c | 232 +++++------ src/H5T.c | 26 +- src/H5Tcommit.c | 67 +--- src/H5VL.c | 776 +++++++++++++++++++++++++++++++++--- src/H5VLdummy.c | 7 +- src/H5VLnative.c | 1133 ++++++++++++++++++++++++++++++++++++++++++++++++++--- src/H5VLnative.h | 5 - src/H5VLprivate.h | 21 + src/H5VLpublic.h | 41 +- test/links.c | 1 - test/tfile.c | 16 +- test/th5o.c | 14 +- 25 files changed, 2200 insertions(+), 924 deletions(-) diff --git a/src/H5D.c b/src/H5D.c index fb3d15b..e7774ca 100644 --- a/src/H5D.c +++ b/src/H5D.c @@ -31,7 +31,7 @@ #include "H5Eprivate.h" /* Error handling */ #include "H5FLprivate.h" /* Free lists */ #include "H5Iprivate.h" /* IDs */ - +#include "H5VLprivate.h" /* VOL plugins */ /****************/ /* Local Macros */ @@ -127,22 +127,14 @@ hid_t H5Dcreate2(hid_t loc_id, const char *name, hid_t type_id, hid_t space_id, hid_t lcpl_id, hid_t dcpl_id, hid_t dapl_id) { - H5G_loc_t loc; /* Object location to insert dataset into */ - H5D_t *dset = NULL; /* New dataset's info */ - const H5S_t *space; /* Dataspace for dataset */ hid_t ret_value; /* Return value */ FUNC_ENTER_API(FAIL) H5TRACE7("i", "i*siiiii", loc_id, name, type_id, space_id, lcpl_id, dcpl_id, dapl_id); - /* Check arguments */ - if(H5G_loc(loc_id, &loc) < 0) - HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a location ID") - if(H5I_DATATYPE != H5I_get_type(type_id)) - HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a datatype ID") - if(NULL == (space = (const H5S_t *)H5I_object_verify(space_id, H5I_DATASPACE))) - HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a dataspace ID") + if(!name || !*name) + HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "no name") /* Get correct property list */ if(H5P_DEFAULT == lcpl_id) @@ -165,23 +157,12 @@ H5Dcreate2(hid_t loc_id, const char *name, hid_t type_id, hid_t space_id, if(TRUE != H5P_isa_class(dapl_id, H5P_DATASET_ACCESS)) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not dataset access property list") -#if 0 /* Create the dataset through the VOL */ if((ret_value = H5VL_dataset_create(loc_id, name, type_id, space_id, lcpl_id, dcpl_id, dapl_id)) < 0) HGOTO_ERROR(H5E_DATASET, H5E_CANTINIT, FAIL, "unable to create dataset") -#endif - - /* Create the new dataset & get its ID */ - if(NULL == (dset = H5D__create_named(&loc, name, type_id, space, lcpl_id, dcpl_id, dapl_id, H5AC_dxpl_id))) - HGOTO_ERROR(H5E_DATASET, H5E_CANTINIT, FAIL, "unable to create dataset") - if((ret_value = H5I_register(H5I_DATASET, dset, TRUE)) < 0) - HGOTO_ERROR(H5E_DATASET, H5E_CANTREGISTER, FAIL, "unable to register dataset") done: - if(ret_value < 0) - if(dset && H5D_close(dset) < 0) - HDONE_ERROR(H5E_DATASET, H5E_CLOSEERROR, FAIL, "unable to release dataset") FUNC_LEAVE_API(ret_value) } /* end H5Dcreate2() */ @@ -226,21 +207,12 @@ hid_t H5Dcreate_anon(hid_t loc_id, hid_t type_id, hid_t space_id, hid_t dcpl_id, hid_t dapl_id) { - H5G_loc_t loc; /* Object location to insert dataset into */ - H5D_t *dset = NULL; /* New dataset's info */ - const H5S_t *space; /* Dataspace for dataset */ hid_t ret_value; /* Return value */ FUNC_ENTER_API(FAIL) H5TRACE5("i", "iiiii", loc_id, type_id, space_id, dcpl_id, dapl_id); /* Check arguments */ - if(H5G_loc(loc_id, &loc) < 0) - HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a location ID") - if(H5I_DATATYPE != H5I_get_type(type_id)) - HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a datatype ID") - if(NULL == (space = (const H5S_t *)H5I_object_verify(space_id, H5I_DATASPACE))) - HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a dataspace ID") if(H5P_DEFAULT == dcpl_id) dcpl_id = H5P_DATASET_CREATE_DEFAULT; else @@ -254,32 +226,11 @@ H5Dcreate_anon(hid_t loc_id, hid_t type_id, hid_t space_id, hid_t dcpl_id, if(TRUE != H5P_isa_class(dapl_id, H5P_DATASET_ACCESS)) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not dataset access property list") - /* build and open the new dataset */ - if(NULL == (dset = H5D_create(loc.oloc->file, type_id, space, dcpl_id, dapl_id, H5AC_dxpl_id))) + /* Create the dataset through the VOL */ + if((ret_value = H5VL_dataset_create(loc_id, NULL, type_id, space_id, + 0, dcpl_id, dapl_id)) < 0) HGOTO_ERROR(H5E_DATASET, H5E_CANTINIT, FAIL, "unable to create dataset") - - /* Register the new dataset to get an ID for it */ - if((ret_value = H5I_register(H5I_DATASET, dset, TRUE)) < 0) - HGOTO_ERROR(H5E_DATASET, H5E_CANTREGISTER, FAIL, "unable to register dataset") - done: - /* 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, FAIL, "unable to get object location of dataset") - - /* Decrement refcount on dataset's object header in memory */ - if(H5O_dec_rc_by_loc(oloc, H5AC_dxpl_id) < 0) - HDONE_ERROR(H5E_DATASET, H5E_CANTDEC, FAIL, "unable to decrement refcount on newly created object") - } /* end if */ - - /* Cleanup on failure */ - if(ret_value < 0) - if(dset && H5D_close(dset) < 0) - HDONE_ERROR(H5E_DATASET, H5E_CLOSEERROR, FAIL, "unable to release dataset") FUNC_LEAVE_API(ret_value) } /* end H5Dcreate_anon() */ @@ -305,22 +256,12 @@ done: hid_t H5Dopen2(hid_t loc_id, const char *name, hid_t dapl_id) { - H5D_t *dset = NULL; - H5G_loc_t loc; /* Object location of group */ - H5G_loc_t dset_loc; /* Object location of dataset */ - H5G_name_t path; /* Dataset group hier. path */ - H5O_loc_t oloc; /* Dataset object location */ - H5O_type_t obj_type; /* Type of object at location */ - hbool_t loc_found = FALSE; /* Location at 'name' found */ - hid_t dxpl_id = H5AC_dxpl_id; /* dxpl to use to open datset */ hid_t ret_value; FUNC_ENTER_API(FAIL) H5TRACE3("i", "i*si", loc_id, name, dapl_id); /* Check args */ - if(H5G_loc(loc_id, &loc) < 0) - HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a location") if(!name || !*name) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "no name") @@ -331,41 +272,10 @@ H5Dopen2(hid_t loc_id, const char *name, hid_t dapl_id) if(TRUE != H5P_isa_class(dapl_id, H5P_DATASET_ACCESS)) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not dataset access property list") - /* Set up dataset location to fill in */ - dset_loc.oloc = &oloc; - dset_loc.path = &path; - H5G_loc_reset(&dset_loc); - - /* Find the dataset object */ - if(H5G_loc_find(&loc, name, &dset_loc, dapl_id, dxpl_id) < 0) - HGOTO_ERROR(H5E_DATASET, H5E_NOTFOUND, FAIL, "not found") - loc_found = TRUE; - - /* Check that the object found is the correct type */ - if(H5O_obj_type(&oloc, &obj_type, dxpl_id) < 0) - HGOTO_ERROR(H5E_DATASET, H5E_CANTGET, FAIL, "can't get object type") - if(obj_type != H5O_TYPE_DATASET) - HGOTO_ERROR(H5E_DATASET, H5E_BADTYPE, FAIL, "not a dataset") - - /* Open the dataset */ - if(NULL == (dset = H5D_open(&dset_loc, dapl_id, dxpl_id))) - HGOTO_ERROR(H5E_DATASET, H5E_CANTINIT, FAIL, "can't open dataset") - - /* Register an atom for the dataset */ - if((ret_value = H5I_register(H5I_DATASET, dset, TRUE)) < 0) - HGOTO_ERROR(H5E_ATOM, H5E_CANTREGISTER, FAIL, "can't register dataset atom") - + /* Open the dataset through the VOL */ + if((ret_value = H5VL_dataset_open(loc_id, name, dapl_id)) < 0) + HGOTO_ERROR(H5E_DATASET, H5E_CANTINIT, FAIL, "unable to open dataset") done: - if(ret_value < 0) { - if(dset) { - if(H5D_close(dset) < 0) - HDONE_ERROR(H5E_DATASET, H5E_CLOSEERROR, FAIL, "unable to release dataset") - } /* end if */ - else { - if(loc_found && H5G_loc_free(&dset_loc) < 0) - HDONE_ERROR(H5E_DATASET, H5E_CANTRELEASE, FAIL, "can't free location") - } /* end else */ - } /* end if */ FUNC_LEAVE_API(ret_value) } /* end H5Dopen2() */ @@ -393,20 +303,9 @@ H5Dclose(hid_t dset_id) FUNC_ENTER_API(FAIL) H5TRACE1("e", "i", dset_id); - /* Check args */ - if(NULL == H5I_object_verify(dset_id, H5I_DATASET)) - HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a dataset") - - /* - * Decrement the counter on the dataset. It will be freed if the count - * reaches zero. - * - * Pass in TRUE for the 3rd parameter to tell the function to remove - * dataset's ID even though the freeing function might fail. Please - * see the comments in H5I_dec_ref for details. (SLU - 2010/9/7) - */ - if(H5I_dec_app_ref_always_close(dset_id) < 0) - HGOTO_ERROR(H5E_DATASET, H5E_CANTDEC, FAIL, "can't decrement count on dataset ID") + /* Close the dataset through the VOL */ + if((ret_value = H5VL_dataset_close(dset_id)) < 0) + HGOTO_ERROR(H5E_DATASET, H5E_CANTRELEASE, FAIL, "unable to close dataset") done: FUNC_LEAVE_API(ret_value) diff --git a/src/H5Ddeprec.c b/src/H5Ddeprec.c index 7e65149..db3f0f9 100644 --- a/src/H5Ddeprec.c +++ b/src/H5Ddeprec.c @@ -141,41 +141,23 @@ hid_t H5Dcreate1(hid_t loc_id, const char *name, hid_t type_id, hid_t space_id, hid_t dcpl_id) { - H5G_loc_t loc; /* Object location to insert dataset into */ - H5D_t *dset = NULL; /* New dataset's info */ - const H5S_t *space; /* Dataspace for dataset */ hid_t ret_value; /* Return value */ FUNC_ENTER_API(FAIL) H5TRACE5("i", "i*siii", loc_id, name, type_id, space_id, dcpl_id); - /* Check arguments */ - if(H5G_loc(loc_id, &loc) < 0) - HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a location ID") - if(!name || !*name) - HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "no name") - if(H5I_DATATYPE != H5I_get_type(type_id)) - HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a datatype ID") - if(NULL == (space = (const H5S_t *)H5I_object_verify(space_id,H5I_DATASPACE))) - HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a dataspace ID") if(H5P_DEFAULT == dcpl_id) dcpl_id = H5P_DATASET_CREATE_DEFAULT; else if(TRUE != H5P_isa_class(dcpl_id, H5P_DATASET_CREATE)) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not dataset create property list ID") - /* Build and open the new dataset */ - if(NULL == (dset = H5D__create_named(&loc, name, type_id, space, H5P_LINK_CREATE_DEFAULT, dcpl_id, H5P_DATASET_ACCESS_DEFAULT, H5AC_dxpl_id))) + /* Create the dataset through the VOL */ + if((ret_value = H5VL_dataset_create(loc_id, name, type_id, space_id, H5P_LINK_CREATE_DEFAULT, + dcpl_id, H5P_DATASET_ACCESS_DEFAULT)) < 0) HGOTO_ERROR(H5E_DATASET, H5E_CANTINIT, FAIL, "unable to create dataset") - /* Register the new dataset to get an ID for it */ - if((ret_value = H5I_register(H5I_DATASET, dset, TRUE)) < 0) - HGOTO_ERROR(H5E_DATASET, H5E_CANTREGISTER, FAIL, "unable to register dataset") - done: - if(ret_value < 0) - if(dset && H5D_close(dset) < 0) - HDONE_ERROR(H5E_DATASET, H5E_CLOSEERROR, FAIL, "unable to release dataset") FUNC_LEAVE_API(ret_value) } /* end H5Dcreate1() */ @@ -201,61 +183,21 @@ done: hid_t H5Dopen1(hid_t loc_id, const char *name) { - H5D_t *dset = NULL; - H5G_loc_t loc; /* Object location of group */ - H5G_loc_t dset_loc; /* Object location of dataset */ - H5G_name_t path; /* Dataset group hier. path */ - H5O_loc_t oloc; /* Dataset object location */ - H5O_type_t obj_type; /* Type of object at location */ - hbool_t loc_found = FALSE; /* Location at 'name' found */ hid_t dapl_id = H5P_DATASET_ACCESS_DEFAULT; /* dapl to use to open dataset */ - hid_t dxpl_id = H5AC_dxpl_id; /* dxpl to use to open datset */ hid_t ret_value; FUNC_ENTER_API(FAIL) H5TRACE2("i", "i*s", loc_id, name); /* Check args */ - if(H5G_loc(loc_id, &loc) < 0) - HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a location") if(!name || !*name) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "no name") - /* Set up dataset location to fill in */ - dset_loc.oloc = &oloc; - dset_loc.path = &path; - H5G_loc_reset(&dset_loc); - - /* Find the dataset object */ - if(H5G_loc_find(&loc, name, &dset_loc, H5P_DEFAULT, dxpl_id) < 0) - HGOTO_ERROR(H5E_DATASET, H5E_NOTFOUND, FAIL, "not found") - loc_found = TRUE; - - /* Check that the object found is the correct type */ - if(H5O_obj_type(&oloc, &obj_type, dxpl_id) < 0) - HGOTO_ERROR(H5E_DATASET, H5E_CANTGET, FAIL, "can't get object type") - if(obj_type != H5O_TYPE_DATASET) - HGOTO_ERROR(H5E_DATASET, H5E_BADTYPE, FAIL, "not a dataset") - - /* Open the dataset */ - if(NULL == (dset = H5D_open(&dset_loc, dapl_id, dxpl_id))) - HGOTO_ERROR(H5E_DATASET, H5E_CANTINIT, FAIL, "can't open dataset") - - /* Register an atom for the dataset */ - if((ret_value = H5I_register(H5I_DATASET, dset, TRUE)) < 0) - HGOTO_ERROR(H5E_ATOM, H5E_CANTREGISTER, FAIL, "can't register dataset atom") + /* Open the dataset through the VOL */ + if((ret_value = H5VL_dataset_open(loc_id, name, dapl_id)) < 0) + HGOTO_ERROR(H5E_DATASET, H5E_CANTINIT, FAIL, "unable to open dataset") done: - if(ret_value < 0) { - if(dset != NULL) { - if(H5D_close(dset) < 0) - HDONE_ERROR(H5E_DATASET, H5E_CLOSEERROR, FAIL, "unable to release dataset") - } /* end if */ - else { - if(loc_found && H5G_loc_free(&dset_loc) < 0) - HDONE_ERROR(H5E_SYM, H5E_CANTRELEASE, FAIL, "can't free location") - } /* end else */ - } /* end if */ FUNC_LEAVE_API(ret_value) } /* end H5Dopen1() */ diff --git a/src/H5Dio.c b/src/H5Dio.c index 248ea9e..49a8f25 100644 --- a/src/H5Dio.c +++ b/src/H5Dio.c @@ -28,6 +28,7 @@ #include "H5Eprivate.h" /* Error handling */ #include "H5FLprivate.h" /* Free Lists */ #include "H5Iprivate.h" /* IDs */ +#include "H5VLprivate.h" /* VOL plugins */ #ifdef H5_HAVE_PARALLEL /* Remove this if H5R_DATASET_REGION is no longer used in this file */ @@ -49,14 +50,6 @@ /* Local Prototypes */ /********************/ -/* Internal I/O routines */ -static herr_t H5D_read(H5D_t *dataset, hid_t mem_type_id, - const H5S_t *mem_space, const H5S_t *file_space, hid_t dset_xfer_plist, - void *buf/*out*/); -static herr_t H5D_write(H5D_t *dataset, hid_t mem_type_id, - const H5S_t *mem_space, const H5S_t *file_space, hid_t dset_xfer_plist, - const void *buf); - /* Setup/teardown routines */ static herr_t H5D_ioinfo_init(H5D_t *dset, const H5D_dxpl_cache_t *dxpl_cache, hid_t dxpl_id, const H5D_type_info_t *type_info, H5D_storage_t *store, @@ -121,58 +114,25 @@ herr_t H5Dread(hid_t dset_id, hid_t mem_type_id, hid_t mem_space_id, hid_t file_space_id, hid_t plist_id, void *buf/*out*/) { - H5D_t *dset = NULL; - const H5S_t *mem_space = NULL; - const H5S_t *file_space = NULL; - char fake_char; herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_API(FAIL) H5TRACE6("e", "iiiiix", dset_id, mem_type_id, mem_space_id, file_space_id, plist_id, buf); - /* check arguments */ - if(NULL == (dset = (H5D_t *)H5I_object_verify(dset_id, H5I_DATASET))) - HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a dataset") - if(NULL == dset->oloc.file) - HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a dataset") - if(H5S_ALL != mem_space_id) { - if(NULL == (mem_space = (const H5S_t *)H5I_object_verify(mem_space_id, H5I_DATASPACE))) - HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a data space") - - /* Check for valid selection */ - if(H5S_SELECT_VALID(mem_space) != TRUE) - HGOTO_ERROR(H5E_DATASPACE, H5E_BADRANGE, FAIL, "selection+offset not within extent") - } /* end if */ - if(H5S_ALL != file_space_id) { - if(NULL == (file_space = (const H5S_t *)H5I_object_verify(file_space_id, H5I_DATASPACE))) - HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a data space") - - /* Check for valid selection */ - if(H5S_SELECT_VALID(file_space) != TRUE) - HGOTO_ERROR(H5E_DATASPACE, H5E_BADRANGE, FAIL, "selection+offset not within extent") - } /* end if */ - /* Get the default dataset transfer property list if the user didn't provide one */ if (H5P_DEFAULT == plist_id) plist_id= H5P_DATASET_XFER_DEFAULT; else if(TRUE != H5P_isa_class(plist_id, H5P_DATASET_XFER)) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not xfer parms") - if(!buf && (NULL == file_space || H5S_GET_SELECT_NPOINTS(file_space) != 0)) - HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "no output buffer") - - /* If the buffer is nil, and 0 element is selected, make a fake buffer. - * This is for some MPI package like ChaMPIon on NCSA's tungsten which - * doesn't support this feature. - */ - if(!buf) - buf = &fake_char; - /* read raw data */ - if(H5D_read(dset, mem_type_id, mem_space, file_space, plist_id, buf/*out*/) < 0) + /* Read the data through the VOL */ + if((ret_value = H5VL_dataset_read(dset_id, mem_type_id, mem_space_id, + file_space_id, plist_id, buf)) < 0) HGOTO_ERROR(H5E_DATASET, H5E_READERROR, FAIL, "can't read data") + done: FUNC_LEAVE_API(ret_value) } /* end H5Dread() */ @@ -213,10 +173,6 @@ herr_t H5Dwrite(hid_t dset_id, hid_t mem_type_id, hid_t mem_space_id, hid_t file_space_id, hid_t dxpl_id, const void *buf) { - H5D_t *dset = NULL; - const H5S_t *mem_space = NULL; - const H5S_t *file_space = NULL; - char fake_char; herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_API(FAIL) @@ -224,26 +180,6 @@ H5Dwrite(hid_t dset_id, hid_t mem_type_id, hid_t mem_space_id, dxpl_id, buf); /* check arguments */ - if(NULL == (dset = (H5D_t *)H5I_object_verify(dset_id, H5I_DATASET))) - HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a dataset") - if(NULL == dset->oloc.file) - HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a dataset") - if(H5S_ALL != mem_space_id) { - if(NULL == (mem_space = (const H5S_t *)H5I_object_verify(mem_space_id, H5I_DATASPACE))) - HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a data space") - - /* Check for valid selection */ - if(H5S_SELECT_VALID(mem_space) != TRUE) - HGOTO_ERROR(H5E_DATASPACE, H5E_BADRANGE, FAIL, "memory selection+offset not within extent") - } /* end if */ - if(H5S_ALL != file_space_id) { - if(NULL == (file_space = (const H5S_t *)H5I_object_verify(file_space_id, H5I_DATASPACE))) - HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a data space") - - /* Check for valid selection */ - if(H5S_SELECT_VALID(file_space) != TRUE) - HGOTO_ERROR(H5E_DATASPACE, H5E_BADRANGE, FAIL, "file selection+offset not within extent") - } /* end if */ /* Get the default dataset transfer property list if the user didn't provide one */ if(H5P_DEFAULT == dxpl_id) @@ -251,18 +187,10 @@ H5Dwrite(hid_t dset_id, hid_t mem_type_id, hid_t mem_space_id, else if(TRUE != H5P_isa_class(dxpl_id, H5P_DATASET_XFER)) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not xfer parms") - if(!buf && (NULL == file_space || H5S_GET_SELECT_NPOINTS(file_space) != 0)) - HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "no output buffer") - - /* If the buffer is nil, and 0 element is selected, make a fake buffer. - * This is for some MPI package like ChaMPIon on NCSA's tungsten which - * doesn't support this feature. - */ - if(!buf) - buf = &fake_char; - /* write raw data */ - if(H5D_write(dset, mem_type_id, mem_space, file_space, dxpl_id, buf) < 0) + /* Write the data through the VOL */ + if((ret_value = H5VL_dataset_write(dset_id, mem_type_id, mem_space_id, + file_space_id, dxpl_id, buf)) < 0) HGOTO_ERROR(H5E_DATASET, H5E_WRITEERROR, FAIL, "can't write data") done: @@ -283,7 +211,7 @@ done: * *------------------------------------------------------------------------- */ -static herr_t +herr_t H5D_read(H5D_t *dataset, hid_t mem_type_id, const H5S_t *mem_space, const H5S_t *file_space, hid_t dxpl_id, void *buf/*out*/) { @@ -484,7 +412,7 @@ done: * *------------------------------------------------------------------------- */ -static herr_t +herr_t H5D_write(H5D_t *dataset, hid_t mem_type_id, const H5S_t *mem_space, const H5S_t *file_space, hid_t dxpl_id, const void *buf) { diff --git a/src/H5Dprivate.h b/src/H5Dprivate.h index 48966db..01071e6 100644 --- a/src/H5Dprivate.h +++ b/src/H5Dprivate.h @@ -156,6 +156,13 @@ typedef struct H5D_copy_file_ud_t { /******************************/ /* Library Private Prototypes */ /******************************/ +/* Internal I/O routines */ +H5_DLL herr_t H5D_read(H5D_t *dataset, hid_t mem_type_id, const H5S_t *mem_space, + const H5S_t *file_space, hid_t dset_xfer_plist, + void *buf/*out*/); +H5_DLL herr_t H5D_write(H5D_t *dataset, hid_t mem_type_id, const H5S_t *mem_space, + const H5S_t *file_space, hid_t dset_xfer_plist, + const void *buf); H5_DLL herr_t H5D_init(void); H5_DLL H5D_t *H5D_open(const H5G_loc_t *loc, hid_t dapl_id, hid_t dxpl_id); diff --git a/src/H5F.c b/src/H5F.c index 047fd39..72ed989 100644 --- a/src/H5F.c +++ b/src/H5F.c @@ -27,7 +27,6 @@ #include "H5Eprivate.h" /* Error handling */ #include "H5Fpkg.h" /* File access */ #include "H5FDprivate.h" /* File drivers */ -#include "H5VLprivate.h" /* VOL plugins */ #include "H5Gprivate.h" /* Groups */ #include "H5Iprivate.h" /* IDs */ #include "H5MFprivate.h" /* File memory management */ @@ -35,6 +34,7 @@ #include "H5Pprivate.h" /* Property lists */ #include "H5SMprivate.h" /* Shared Object Header Messages */ #include "H5Tprivate.h" /* Datatypes */ +#include "H5VLprivate.h" /* VOL plugins */ /* Declare a free list to manage the H5I_t struct */ H5FL_DEFINE_STATIC(H5I_t); @@ -377,7 +377,7 @@ H5Fget_obj_count(hid_t uid, unsigned types) FUNC_ENTER_API(FAIL) H5TRACE2("Zs", "iIu", uid, types); - if (H5I_UID == H5I_get_type(uid)) { + if (H5I_FILE_PUBLIC == H5I_get_type(uid)) { if(NULL == (uid_info = (H5I_t *)H5I_object(uid))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "invalid user identifier") id = uid_info->obj_id; @@ -462,7 +462,7 @@ H5Fget_obj_ids(hid_t uid, unsigned types, size_t max_objs, hid_t *oid_list) FUNC_ENTER_API(FAIL) H5TRACE4("Zs", "iIuz*i", uid, types, max_objs, oid_list); - if (H5I_UID == H5I_get_type(uid)) { + if (H5I_FILE_PUBLIC == H5I_get_type(uid)) { if(NULL == (uid_info = (H5I_t *)H5I_object(uid))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "invalid user identifier") id = uid_info->obj_id; @@ -483,6 +483,7 @@ H5Fget_obj_ids(hid_t uid, unsigned types, size_t max_objs, hid_t *oid_list) if (H5I_replace_with_uids (oid_list, ret_value) <= 0) HGOTO_ERROR(H5E_ATOM, H5E_CANTGET, FAIL, "can't get IDs") + done: FUNC_LEAVE_API(ret_value) } /* end H5Fget_obj_ids() */ @@ -683,7 +684,6 @@ H5F_get_objects_cb(void *obj_ptr, hid_t obj_id, void *key) case H5I_REFERENCE: case H5I_VFL: case H5I_VOL: - case H5I_UID: case H5I_GENPROP_CLS: case H5I_GENPROP_LST: case H5I_ERROR_CLASS: @@ -1909,7 +1909,7 @@ H5Freopen(hid_t uid) H5TRACE1("i", "i", file_id); /* Get the file */ - if(H5I_UID != H5I_get_type(uid)) + if(H5I_FILE_PUBLIC != H5I_get_type(uid)) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a user ID") if(NULL == (uid_info = (H5I_t *)H5I_object(uid))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "invalid user identifier") @@ -1941,12 +1941,9 @@ H5Freopen(hid_t uid) if(NULL == (new_uid_info = H5FL_MALLOC(H5I_t))) HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, FAIL, "memory allocation failed") new_uid_info->obj_id = new_file_id; - new_uid_info->vol_id = uid_info->vol_id; - /* increment ref count on the VOL id */ - if(H5I_inc_ref(uid_info->vol_id, FALSE) < 0) - HGOTO_ERROR(H5E_FILE, H5E_CANTINC, FAIL, "unable to increment ref count on vol plugin") + new_uid_info->vol_plugin = uid_info->vol_plugin; - if((ret_value = H5I_register(H5I_UID, new_uid_info, TRUE)) < 0) + if((ret_value = H5I_register(H5I_FILE_PUBLIC, new_uid_info, TRUE)) < 0) HGOTO_ERROR(H5E_ATOM, H5E_CANTREGISTER, FAIL, "unable to atomize file handle") #endif @@ -2023,13 +2020,13 @@ H5F_get_id(H5F_t *file, hbool_t app_ref) if(NULL == (uid_info = H5FL_MALLOC(H5I_t))) HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, FAIL, "memory allocation failed") uid_info->obj_id = file->file_id; - uid_info->vol_id = file->vol_id; + uid_info->vol_plugin = (H5VL_class_t *)H5I_object(file->vol_id); /* increment ref count on the VOL id */ - if(H5I_inc_ref(uid_info->vol_id, FALSE) < 0) + if(H5I_inc_ref(file->vol_id, FALSE) < 0) HGOTO_ERROR(H5E_FILE, H5E_CANTINC, FAIL, "unable to increment ref count on vol plugin") - if((H5I_register(H5I_UID, uid_info, TRUE)) < 0) + if((H5I_register(H5I_FILE_PUBLIC, uid_info, TRUE)) < 0) HGOTO_ERROR(H5E_ATOM, H5E_CANTREGISTER, FAIL, "unable to atomize file handle") } else { /* Increment reference count on atom. */ @@ -2510,7 +2507,7 @@ H5Fset_mdc_config(hid_t uid, H5AC_cache_config_t *config_ptr) FUNC_ENTER_API(FAIL) H5TRACE2("e", "i*x", uid, config_ptr); - if(H5I_UID != H5I_get_type(uid)) + if(H5I_FILE_PUBLIC != H5I_get_type(uid)) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a user ID") if(NULL == (uid_info = (H5I_t *)H5I_object(uid))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "invalid user identifier") @@ -2632,7 +2629,7 @@ H5Freset_mdc_hit_rate_stats(hid_t uid) FUNC_ENTER_API(FAIL) H5TRACE1("e", "i", uid); - if(H5I_UID != H5I_get_type(uid)) + if(H5I_FILE_PUBLIC != H5I_get_type(uid)) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a user ID") if(NULL == (uid_info = (H5I_t *)H5I_object(uid))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "invalid user identifier") @@ -2682,11 +2679,13 @@ H5Fget_name(hid_t uid, char *name/*out*/, size_t size) H5TRACE3("Zs", "ixz", uid, name, size); /* MSC - temp fix to handle later when all user level ids are of type UID */ - if (H5I_UID == H5I_get_type(uid)) { + if (H5I_FILE_PUBLIC == H5I_get_type(uid)) { argv[0] = &ret_value; argv[1] = &size; if(H5VL_file_get(uid, H5F_GET_NAME, (void *)name, 2, argv) < 0) HGOTO_ERROR(H5E_INTERNAL, H5E_CANTGET, FAIL, "unable to get file name") + + ret_value = *((ssize_t *)argv[0]); } else { H5F_t *f; /* Top file in mount hierarchy */ @@ -2825,7 +2824,7 @@ H5Fclear_elink_file_cache(hid_t uid) H5TRACE1("e", "i", uid); /* Check args */ - if(H5I_UID != H5I_get_type(uid)) + if(H5I_FILE_PUBLIC != H5I_get_type(uid)) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a user ID") if(NULL == (uid_info = (H5I_t *)H5I_object(uid))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "invalid user identifier") diff --git a/src/H5Ftest.c b/src/H5Ftest.c index 1dbfcf7..3e33b84 100644 --- a/src/H5Ftest.c +++ b/src/H5Ftest.c @@ -106,7 +106,7 @@ H5F_get_sohm_mesg_count_test(hid_t uid, unsigned type_id, FUNC_ENTER_NOAPI_NOINIT - if (H5I_UID == H5I_get_type(uid)) { + if (H5I_FILE_PUBLIC == H5I_get_type(uid)) { if(NULL == (uid_info = (H5I_t *)H5I_object(uid))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "invalid user identifier") file_id = uid_info->obj_id; @@ -154,7 +154,7 @@ H5F_check_cached_stab_test(hid_t uid) FUNC_ENTER_NOAPI_NOINIT - if (H5I_UID == H5I_get_type(uid)) { + if (H5I_FILE_PUBLIC == H5I_get_type(uid)) { if(NULL == (uid_info = (H5I_t *)H5I_object(uid))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "invalid user identifier") file_id = uid_info->obj_id; @@ -199,7 +199,7 @@ H5F_get_maxaddr_test(hid_t uid, haddr_t *maxaddr) FUNC_ENTER_NOAPI_NOINIT - if (H5I_UID == H5I_get_type(uid)) { + if (H5I_FILE_PUBLIC == H5I_get_type(uid)) { if(NULL == (uid_info = (H5I_t *)H5I_object(uid))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "invalid user identifier") file_id = uid_info->obj_id; diff --git a/src/H5G.c b/src/H5G.c index 3531d04..0ee943a 100644 --- a/src/H5G.c +++ b/src/H5G.c @@ -94,7 +94,7 @@ #include "H5Gpkg.h" /* Groups */ #include "H5Iprivate.h" /* IDs */ #include "H5Pprivate.h" /* Property lists */ - +#include "H5VLprivate.h" /* VOL plugins */ /****************/ /* Local Macros */ @@ -263,17 +263,12 @@ H5G_term_interface(void) hid_t H5Gcreate2(hid_t loc_id, const char *name, hid_t lcpl_id, hid_t gcpl_id, hid_t gapl_id) { - H5G_loc_t loc; /* Location to create group */ - H5G_t *grp = NULL; /* New group created */ hid_t ret_value; /* Return value */ FUNC_ENTER_API(FAIL) H5TRACE5("i", "i*siii", loc_id, name, lcpl_id, gcpl_id, gapl_id); /* Check arguments */ - if(H5G_loc(loc_id, &loc) < 0) - HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a location") - if(!name || !*name) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "no name") @@ -298,23 +293,11 @@ H5Gcreate2(hid_t loc_id, const char *name, hid_t lcpl_id, hid_t gcpl_id, hid_t g if(TRUE != H5P_isa_class(gapl_id, H5P_GROUP_ACCESS)) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not group access property list") -#if 0 /* Create the group through the VOL */ if((ret_value = H5VL_group_create(loc_id, name, lcpl_id, gcpl_id, gapl_id)) < 0) HGOTO_ERROR(H5E_SYM, H5E_CANTINIT, FAIL, "unable to create group") -#endif - - /* Create the new group & get its ID */ - if(NULL == (grp = H5G__create_named(&loc, name, lcpl_id, gcpl_id, gapl_id, H5AC_dxpl_id))) - HGOTO_ERROR(H5E_SYM, H5E_CANTINIT, FAIL, "unable to create group") - if((ret_value = H5I_register(H5I_GROUP, grp, TRUE)) < 0) - HGOTO_ERROR(H5E_ATOM, H5E_CANTREGISTER, FAIL, "unable to register group") done: - if(ret_value < 0) - if(grp && H5G_close(grp) < 0) - HDONE_ERROR(H5E_SYM, H5E_CLOSEERROR, FAIL, "unable to release group") - FUNC_LEAVE_API(ret_value) } /* end H5Gcreate2() */ @@ -357,18 +340,11 @@ done: hid_t H5Gcreate_anon(hid_t loc_id, hid_t gcpl_id, hid_t gapl_id) { - H5G_loc_t loc; - H5G_t *grp = NULL; - H5G_obj_create_t gcrt_info; /* Information for group creation */ hid_t ret_value; FUNC_ENTER_API(FAIL) H5TRACE3("i", "iii", loc_id, gcpl_id, gapl_id); - /* Check arguments */ - if(H5G_loc(loc_id, &loc) < 0) - HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a location") - /* Check group creation property list */ if(H5P_DEFAULT == gcpl_id) gcpl_id = H5P_GROUP_CREATE_DEFAULT; @@ -383,36 +359,11 @@ H5Gcreate_anon(hid_t loc_id, hid_t gcpl_id, hid_t gapl_id) if(TRUE != H5P_isa_class(gapl_id, H5P_GROUP_ACCESS)) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not group access property list") - /* Set up group creation info */ - gcrt_info.gcpl_id = gcpl_id; - gcrt_info.cache_type = H5G_NOTHING_CACHED; - HDmemset(&gcrt_info.cache, 0, sizeof(gcrt_info.cache)); - - /* Create the new group & get its ID */ - if(NULL == (grp = H5G__create(loc.oloc->file, &gcrt_info, H5AC_dxpl_id))) - HGOTO_ERROR(H5E_SYM, H5E_CANTINIT, FAIL, "unable to create group") - if((ret_value = H5I_register(H5I_GROUP, grp, TRUE)) < 0) - HGOTO_ERROR(H5E_ATOM, H5E_CANTREGISTER, FAIL, "unable to register group") + /* Create the group through the VOL */ + if((ret_value = H5VL_group_create(loc_id, NULL, 0, gcpl_id, gapl_id)) < 0) + HGOTO_ERROR(H5E_SYM, H5E_CANTINIT, FAIL, "unable to create group") done: - /* 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, FAIL, "unable to get object location of group") - - /* Decrement refcount on group's object header in memory */ - if(H5O_dec_rc_by_loc(oloc, H5AC_dxpl_id) < 0) - HDONE_ERROR(H5E_SYM, H5E_CANTDEC, FAIL, "unable to decrement refcount on newly created object") - } /* end if */ - - /* Cleanup on failure */ - if(ret_value < 0) - if(grp && H5G_close(grp) < 0) - HDONE_ERROR(H5E_SYM, H5E_CLOSEERROR, FAIL, "unable to release group") - FUNC_LEAVE_API(ret_value) } /* end H5Gcreate_anon() */ @@ -437,16 +388,12 @@ done: hid_t H5Gopen2(hid_t loc_id, const char *name, hid_t gapl_id) { - H5G_t *grp = NULL; /* Group opened */ - H5G_loc_t loc; /* Location of parent for group */ hid_t ret_value; /* Return value */ FUNC_ENTER_API(FAIL) H5TRACE3("i", "i*si", loc_id, name, gapl_id); /* Check args */ - if(H5G_loc(loc_id, &loc) < 0) - HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a location") if(!name || !*name) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "no name") @@ -457,20 +404,11 @@ H5Gopen2(hid_t loc_id, const char *name, hid_t gapl_id) if(TRUE != H5P_isa_class(gapl_id, H5P_GROUP_ACCESS)) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not group access property list") - /* Open the group */ - if((grp = H5G__open_name(&loc, name, gapl_id, H5AC_dxpl_id)) == NULL) - HGOTO_ERROR(H5E_SYM, H5E_CANTOPENOBJ, FAIL, "unable to open group") - - /* Register an ID for the group */ - if((ret_value = H5I_register(H5I_GROUP, grp, TRUE)) < 0) - HGOTO_ERROR(H5E_ATOM, H5E_CANTREGISTER, FAIL, "unable to register group") + /* Open the group through the VOL */ + if((ret_value = H5VL_group_open(loc_id, name, gapl_id)) < 0) + HGOTO_ERROR(H5E_SYM, H5E_CANTINIT, FAIL, "unable to open group") done: - if(ret_value < 0) { - if(grp && H5G_close(grp) < 0) - HDONE_ERROR(H5E_SYM, H5E_CLOSEERROR, FAIL, "unable to release group") - } /* end if */ - FUNC_LEAVE_API(ret_value) } /* end H5Gopen2() */ @@ -492,86 +430,17 @@ done: *------------------------------------------------------------------------- */ hid_t -H5Gget_create_plist(hid_t group_id) +H5Gget_create_plist(hid_t uid) { - H5O_linfo_t linfo; /* Link info message */ - htri_t ginfo_exists; - htri_t linfo_exists; - htri_t pline_exists; - H5G_t *grp = NULL; - H5P_genplist_t *gcpl_plist; - H5P_genplist_t *new_plist; - hid_t new_gcpl_id = FAIL; hid_t ret_value = FAIL; FUNC_ENTER_API(FAIL) - H5TRACE1("i", "i", group_id); + H5TRACE1("i", "i", uid); - /* Check args */ - if(NULL == (grp = (H5G_t *)H5I_object_verify(group_id, H5I_GROUP))) - HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a group") - - /* Copy the default group creation property list */ - if(NULL == (gcpl_plist = (H5P_genplist_t *)H5I_object(H5P_LST_GROUP_CREATE_g))) - HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "can't get default group creation property list") - if((new_gcpl_id = H5P_copy_plist(gcpl_plist, TRUE)) < 0) - HGOTO_ERROR(H5E_SYM, H5E_CANTGET, FAIL, "unable to copy the creation property list") - if(NULL == (new_plist = (H5P_genplist_t *)H5I_object(new_gcpl_id))) - HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "can't get property list") - - /* Retrieve any object creation properties */ - if(H5O_get_create_plist(&grp->oloc, H5AC_ind_dxpl_id, new_plist) < 0) - HGOTO_ERROR(H5E_SYM, H5E_CANTGET, FAIL, "can't get object creation info") - - /* Check for the group having a group info message */ - if((ginfo_exists = H5O_msg_exists(&(grp->oloc), H5O_GINFO_ID, H5AC_ind_dxpl_id)) < 0) - HGOTO_ERROR(H5E_SYM, H5E_CANTINIT, FAIL, "unable to read object header") - if(ginfo_exists) { - H5O_ginfo_t ginfo; /* Group info message */ - - /* Read the group info */ - if(NULL == H5O_msg_read(&(grp->oloc), H5O_GINFO_ID, &ginfo, H5AC_ind_dxpl_id)) - HGOTO_ERROR(H5E_SYM, H5E_BADMESG, FAIL, "can't get group info") - - /* Set the group info for the property list */ - if(H5P_set(new_plist, H5G_CRT_GROUP_INFO_NAME, &ginfo) < 0) - HGOTO_ERROR(H5E_PLIST, H5E_CANTSET, FAIL, "can't set group info") - } /* end if */ - - /* Check for the group having a link info message */ - if((linfo_exists = H5G__obj_get_linfo(&(grp->oloc), &linfo, H5AC_ind_dxpl_id)) < 0) - HGOTO_ERROR(H5E_SYM, H5E_CANTINIT, FAIL, "unable to read object header") - if(linfo_exists) { - /* Set the link info for the property list */ - if(H5P_set(new_plist, H5G_CRT_LINK_INFO_NAME, &linfo) < 0) - HGOTO_ERROR(H5E_PLIST, H5E_CANTSET, FAIL, "can't set link info") - } /* end if */ - - /* Check for the group having a pipeline message */ - if((pline_exists = H5O_msg_exists(&(grp->oloc), H5O_PLINE_ID, H5AC_ind_dxpl_id)) < 0) - HGOTO_ERROR(H5E_SYM, H5E_CANTGET, FAIL, "unable to read object header") - if(pline_exists) { - H5O_pline_t pline; /* Pipeline message */ - - /* Read the pipeline */ - if(NULL == H5O_msg_read(&(grp->oloc), H5O_PLINE_ID, &pline, H5AC_ind_dxpl_id)) - HGOTO_ERROR(H5E_SYM, H5E_BADMESG, FAIL, "can't get link pipeline") - - /* Set the pipeline for the property list */ - if(H5P_set(new_plist, H5O_CRT_PIPELINE_NAME, &pline) < 0) - HGOTO_ERROR(H5E_PLIST, H5E_CANTSET, FAIL, "can't set link pipeline") - } /* end if */ - - /* Set the return value */ - ret_value = new_gcpl_id; + if(H5VL_group_get(uid, H5G_GET_GCPL, &ret_value, 0, NULL) < 0) + HGOTO_ERROR(H5E_INTERNAL, H5E_CANTGET, FAIL, "unable to get group creation properties") done: - if(ret_value < 0) { - if(new_gcpl_id > 0) - if(H5I_dec_app_ref(new_gcpl_id) < 0) - HDONE_ERROR(H5E_SYM, H5E_CANTDEC, FAIL, "can't free") - } /* end if */ - FUNC_LEAVE_API(ret_value) } /* end H5Gget_create_plist() */ @@ -592,41 +461,13 @@ done: herr_t H5Gget_info(hid_t uid, H5G_info_t *grp_info) { - H5I_type_t id_type; /* Type of ID */ - H5G_loc_t loc; /* Location of group */ - H5I_t *uid_info; /* user id structure */ - hid_t grp_id; herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_API(FAIL) - H5TRACE2("e", "i*x", grp_id, grp_info); - - /* Check args */ - id_type = H5I_get_type(uid); - - if (H5I_UID == id_type) { - if(NULL == (uid_info = (H5I_t *)H5I_object(uid))) - HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "invalid user identifier") - grp_id = uid_info->obj_id; - id_type = H5I_get_type(grp_id); - } - else { - grp_id = uid; - } - - if(!(H5I_GROUP == id_type || H5I_FILE == id_type)) - HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "invalid argument") - if(!grp_info) - HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "no info struct") - - /* Get group location */ - if(H5G_loc(grp_id, &loc) < 0) - HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a location") - - /* Retrieve the group's information */ - if(H5G__obj_info(loc.oloc, grp_info/*out*/, H5AC_ind_dxpl_id) < 0) - HGOTO_ERROR(H5E_SYM, H5E_CANTGET, FAIL, "can't retrieve group info") + H5TRACE2("e", "i*x", uid, grp_info); + if((ret_value = H5VL_group_get(uid, H5G_GET_INFO, (void *)grp_info, 0, NULL)) < 0) + HGOTO_ERROR(H5E_INTERNAL, H5E_CANTGET, FAIL, "unable to get group info") done: FUNC_LEAVE_API(ret_value) } /* end H5Gget_info() */ @@ -784,16 +625,9 @@ H5Gclose(hid_t group_id) FUNC_ENTER_API(FAIL) H5TRACE1("e", "i", group_id); - /* Check args */ - if(NULL == H5I_object_verify(group_id,H5I_GROUP)) - HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a group") - - /* - * Decrement the counter on the group atom. It will be freed if the count - * reaches zero. - */ - if(H5I_dec_app_ref(group_id) < 0) - HGOTO_ERROR(H5E_SYM, H5E_CANTRELEASE, FAIL, "unable to close group") + /* Close the group through the VOL */ + if(H5VL_group_close(group_id) < 0) + HGOTO_ERROR(H5E_SYM, H5E_CANTRELEASE, FAIL, "unable to close group") done: FUNC_LEAVE_API(ret_value) diff --git a/src/H5Gdeprec.c b/src/H5Gdeprec.c index 9473011..8f419b9 100644 --- a/src/H5Gdeprec.c +++ b/src/H5Gdeprec.c @@ -47,7 +47,7 @@ #include "H5Iprivate.h" /* IDs */ #include "H5Lprivate.h" /* Links */ #include "H5Pprivate.h" /* Property lists */ - +#include "H5VLprivate.h" /* VOL plugins */ /****************/ /* Local Macros */ @@ -201,8 +201,6 @@ H5G_map_obj_type(H5O_type_t obj_type) hid_t H5Gcreate1(hid_t loc_id, const char *name, size_t size_hint) { - H5G_loc_t loc; /* Location to create group */ - H5G_t *grp = NULL; /* New group created */ hid_t tmp_gcpl = (-1); /* Temporary group creation property list */ hid_t ret_value; /* Return value */ @@ -210,8 +208,6 @@ H5Gcreate1(hid_t loc_id, const char *name, size_t size_hint) H5TRACE3("i", "i*sz", loc_id, name, size_hint); /* Check arguments */ - if(H5G_loc(loc_id, &loc) < 0) - HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a location") if(!name || !*name) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "no name given") @@ -244,22 +240,16 @@ H5Gcreate1(hid_t loc_id, const char *name, size_t size_hint) else tmp_gcpl = H5P_GROUP_CREATE_DEFAULT; - /* Create the new group & get its ID */ - if(NULL == (grp = H5G__create_named(&loc, name, H5P_LINK_CREATE_DEFAULT, - tmp_gcpl, H5P_GROUP_ACCESS_DEFAULT, H5AC_dxpl_id))) - HGOTO_ERROR(H5E_SYM, H5E_CANTINIT, FAIL, "unable to create group") - if((ret_value = H5I_register(H5I_GROUP, grp, TRUE)) < 0) - HGOTO_ERROR(H5E_ATOM, H5E_CANTREGISTER, FAIL, "unable to register group") + /* Create the group through the VOL */ + if((ret_value = H5VL_group_create(loc_id, name, H5P_LINK_CREATE_DEFAULT, tmp_gcpl, + H5P_GROUP_ACCESS_DEFAULT)) < 0) + HGOTO_ERROR(H5E_SYM, H5E_CANTINIT, FAIL, "unable to create group") done: if(tmp_gcpl > 0 && tmp_gcpl != H5P_GROUP_CREATE_DEFAULT) if(H5I_dec_ref(tmp_gcpl) < 0) HDONE_ERROR(H5E_SYM, H5E_CLOSEERROR, FAIL, "unable to release property list") - if(ret_value < 0) - if(grp && H5G_close(grp) < 0) - HDONE_ERROR(H5E_SYM, H5E_CLOSEERROR, FAIL, "unable to release group") - FUNC_LEAVE_API(ret_value) } /* end H5Gcreate1() */ @@ -284,33 +274,20 @@ done: hid_t H5Gopen1(hid_t loc_id, const char *name) { - H5G_t *grp = NULL; /* Group opened */ - H5G_loc_t loc; /* Location of parent for group */ hid_t ret_value; /* Return value */ FUNC_ENTER_API(FAIL) H5TRACE2("i", "i*s", loc_id, name); /* Check args */ - if(H5G_loc(loc_id, &loc) < 0) - HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a location") if(!name || !*name) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "no name") - /* Open the group */ - if((grp = H5G__open_name(&loc, name, H5P_DEFAULT, H5AC_dxpl_id)) == NULL) - HGOTO_ERROR(H5E_SYM, H5E_CANTOPENOBJ, FAIL, "unable to open group") - - /* Register an atom for the group */ - if((ret_value = H5I_register(H5I_GROUP, grp, TRUE)) < 0) - HGOTO_ERROR(H5E_ATOM, H5E_CANTREGISTER, FAIL, "unable to register group") + /* Open the group through the VOL */ + if((ret_value = H5VL_group_open(loc_id, name, H5P_DEFAULT)) < 0) + HGOTO_ERROR(H5E_SYM, H5E_CANTINIT, FAIL, "unable to create group") done: - if(ret_value < 0) { - if(grp && H5G_close(grp) < 0) - HDONE_ERROR(H5E_SYM, H5E_CLOSEERROR, FAIL, "unable to release group") - } /* end if */ - FUNC_LEAVE_API(ret_value) } /* end H5Gopen1() */ diff --git a/src/H5Gloc.c b/src/H5Gloc.c index f0c2a9c..b29776f 100644 --- a/src/H5Gloc.c +++ b/src/H5Gloc.c @@ -161,11 +161,19 @@ H5G_loc(hid_t id, H5G_loc_t *loc) { H5I_t *uid_info; /* user id structure */ hid_t loc_id; + H5I_type_t id_type; herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_NOAPI(FAIL) - if (H5I_UID == H5I_get_type(id)) { + id_type = H5I_get_type(id); + /* get the actual ID from an upper ID level */ + /* MSC - this is a workaround to allow the test suite to pass and + at some point needs to be removed once all high level operations + that needs to go through the VOL actually go through the VOL*/ + if (H5I_FILE_PUBLIC == id_type || H5I_GROUP_PUBLIC == id_type || + H5I_DATASET_PUBLIC == id_type || H5I_DATATYPE_PUBLIC == id_type || + H5I_ATTRIBUTE_PUBLIC == id_type) { if(NULL == (uid_info = (H5I_t *)H5I_object(id))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "invalid user identifier") loc_id = uid_info->obj_id; @@ -174,7 +182,6 @@ H5G_loc(hid_t id, H5G_loc_t *loc) loc_id = id; } switch(H5I_get_type(loc_id)) { - case H5I_UID: case H5I_FILE: { H5F_t *f; diff --git a/src/H5I.c b/src/H5I.c index ae0f5ad..8d4a3bd 100644 --- a/src/H5I.c +++ b/src/H5I.c @@ -126,6 +126,7 @@ static H5I_type_t H5I_next_type = (H5I_type_t) H5I_NTYPES; H5FL_DEFINE_STATIC(H5I_id_info_t); /*--------------------- Local function prototypes ---------------------------*/ +static herr_t H5I_free(H5I_t *id_struct); static H5I_id_info_t *H5I_find_id(hid_t id); #ifdef H5I_DEBUG_OUTPUT static herr_t H5I_debug(H5I_type_t type); @@ -152,22 +153,21 @@ H5I_init_interface(void) FUNC_ENTER_NOAPI_NOINIT /* Register high level file user id */ - if(H5I_register_type(H5I_UID, (size_t)H5I_UID_HASHSIZE, 0, (H5I_free_t)NULL)obj_id; - } - else { - id = uid; - } -#endif - if(H5I_IS_LIB_TYPE(id_type)) HGOTO_ERROR(H5E_ATOM, H5E_BADGROUP, NULL, "cannot call public function on library type") @@ -1048,11 +1070,18 @@ H5I_object_verify(hid_t id, H5I_type_t id_type) HDassert(id_type >= 1 && id_type < H5I_next_type); - if (H5I_UID == H5I_get_type(id) && H5I_UID != id_type) { + /* Temp workaround for tests to pass */ +#if 1 + if ((H5I_FILE_PUBLIC == H5I_get_type(id) && H5I_FILE_PUBLIC != id_type) || + (H5I_GROUP_PUBLIC == H5I_get_type(id) && H5I_GROUP_PUBLIC != id_type) || + (H5I_DATATYPE_PUBLIC == H5I_get_type(id) && H5I_DATATYPE_PUBLIC != id_type) || + (H5I_DATASET_PUBLIC == H5I_get_type(id) && H5I_DATASET_PUBLIC != id_type) || + (H5I_ATTRIBUTE_PUBLIC == H5I_get_type(id) && H5I_ATTRIBUTE_PUBLIC != id_type)) { if(NULL == (uid_info = (H5I_t *)H5I_object(id))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "invalid user identifier") id = uid_info->obj_id; } +#endif /* Verify that the type of the ID is correct & lookup the ID */ if(id_type == H5I_TYPE(id) && NULL != (id_ptr = H5I_find_id(id))) { @@ -1115,28 +1144,13 @@ done: *------------------------------------------------------------------------- */ H5I_type_t -H5Iget_type(hid_t uid) +H5Iget_type(hid_t id) { - H5I_t *uid_info; /* user id structure */ - hid_t id; H5I_type_t ret_value = H5I_BADID; /* Return value */ FUNC_ENTER_API(H5I_BADID) H5TRACE1("It", "i", id); - /* Check arguments */ - if(uid < 0) - HGOTO_ERROR(H5E_ATOM, H5E_BADATOM, FAIL, "invalid ID") - - if (H5I_UID == H5I_get_type(uid)) { - if(NULL == (uid_info = (H5I_t *)H5I_object(uid))) - HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "invalid user identifier") - id = uid_info->obj_id; - } - else { - id = uid; - } - ret_value = H5I_get_type(id); if(ret_value <= H5I_BADID || ret_value >= H5I_next_type || NULL == H5I_object(id)) @@ -1172,7 +1186,7 @@ H5Iremove_verify(hid_t id, H5I_type_t id_type) FUNC_ENTER_API(NULL) #if 0 - if (H5I_UID == H5I_get_type(uid)) { + if (H5I_FILE_PUBLIC == H5I_get_type(uid)) { if(NULL == (uid_info = (H5I_t *)H5I_object(uid))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "invalid user identifier") id = uid_info->obj_id; @@ -1327,7 +1341,7 @@ H5Idec_ref(hid_t uid) if(uid < 0) HGOTO_ERROR(H5E_ATOM, H5E_BADATOM, FAIL, "invalid ID") - if (H5I_UID == H5I_get_type(uid)) { + if (H5I_FILE_PUBLIC == H5I_get_type(uid) || H5I_GROUP_PUBLIC == H5I_get_type(uid)) { if(NULL == (uid_info = (H5I_t *)H5I_object(uid))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "invalid user identifier") @@ -1542,7 +1556,7 @@ H5Iinc_ref(hid_t uid) if(uid < 0) HGOTO_ERROR(H5E_ATOM, H5E_BADATOM, FAIL, "invalid ID") - if (H5I_UID == H5I_get_type(uid)) { + if (H5I_FILE_PUBLIC == H5I_get_type(uid) || H5I_GROUP_PUBLIC == H5I_get_type(uid)) { if(NULL == (uid_info = (H5I_t *)H5I_object(uid))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "invalid user identifier") @@ -1648,20 +1662,6 @@ H5Iget_ref(hid_t id) if(id < 0) HGOTO_ERROR(H5E_ATOM, H5E_BADATOM, FAIL, "invalid ID") -#if 0 - if (H5I_UID == H5I_get_type(uid)) { - if(NULL == (uid_info = (H5I_t *)H5I_object(uid))) - HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "invalid user identifier") - id = uid_info->obj_id; - } - else { - id = uid; - } - - /* Check arguments */ - if(id < 0) - HGOTO_ERROR(H5E_ATOM, H5E_BADATOM, FAIL, "invalid ID") -#endif /* Do actual retrieve operation */ if((ret_value = H5I_get_ref(id, TRUE)) < 0) HGOTO_ERROR(H5E_ATOM, H5E_CANTGET, FAIL, "can't get ID ref count") @@ -1996,17 +1996,6 @@ H5Iis_valid(hid_t id) FUNC_ENTER_API(FAIL) H5TRACE1("t", "i", id); -#if 0 - if (H5I_UID == H5I_get_type(uid)) { - if(NULL == (uid_info = (H5I_t *)H5I_object(uid))) - HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "invalid user identifier") - id = uid_info->obj_id; - } - else { - id = uid; - } -#endif - /* Find the ID */ if (NULL == (id_ptr = H5I_find_id(id))) ret_value = FALSE; @@ -2265,11 +2254,9 @@ H5Iget_file_id(hid_t uid) FUNC_ENTER_API(FAIL) H5TRACE1("i", "i", uid); - /* Check arguments */ - if(uid < 0) - HGOTO_ERROR(H5E_ATOM, H5E_BADATOM, FAIL, "invalid ID") - - if (H5I_UID == H5I_get_type(uid)) { + if (H5I_FILE_PUBLIC == H5I_get_type(uid) || H5I_GROUP_PUBLIC == H5I_get_type(uid) || + H5I_DATASET_PUBLIC == H5I_get_type(uid) || H5I_DATATYPE_PUBLIC == H5I_get_type(uid) || + H5I_ATTRIBUTE_PUBLIC == H5I_get_type(uid)) { if(NULL == (uid_info = (H5I_t *)H5I_object(uid))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "invalid user identifier") id = uid_info->obj_id; @@ -2277,7 +2264,7 @@ H5Iget_file_id(hid_t uid) else { id = uid; } - + if((ret_value = H5I_get_file_id(id, TRUE)) < 0) HGOTO_ERROR(H5E_ATOM, H5E_CANTGET, FAIL, "can't retrieve file ID") @@ -2313,7 +2300,7 @@ H5I_get_file_id(hid_t obj_id, hbool_t app_ref) /* Get object type */ type = H5I_TYPE(obj_id); - if(type == H5I_FILE) { + if(H5I_FILE == type) { /* Increment reference count on file ID */ if(H5I_inc_ref(obj_id, app_ref) < 0) HGOTO_ERROR(H5E_ATOM, H5E_CANTSET, FAIL, "incrementing file ID failed") @@ -2325,7 +2312,8 @@ H5I_get_file_id(hid_t obj_id, hbool_t app_ref) /* Set return value */ ret_value = obj_id; } /* end if */ - else if(type == H5I_DATATYPE || type == H5I_GROUP || type == H5I_DATASET || type == H5I_ATTR) { + else if(type == H5I_DATATYPE || type == H5I_GROUP || + type == H5I_DATASET || type == H5I_ATTR) { H5G_loc_t loc; /* Location of object */ /* Get the object location information */ @@ -2361,6 +2349,7 @@ int H5I_replace_with_uids(hid_t *old_list, ssize_t num_ids) { ssize_t j; + H5I_type_t type; int ret_value = 0; /* Return value */ FUNC_ENTER_NOAPI(FAIL) @@ -2369,13 +2358,22 @@ H5I_replace_with_uids(hid_t *old_list, ssize_t num_ids) H5I_id_type_t *type_ptr; /*ptr to the type */ hbool_t replaced = FALSE; - if (H5I_FILE != H5I_get_type(old_list[j])) { + type = H5I_get_type(old_list[j]); + + if (H5I_FILE == type) { + type_ptr = H5I_id_type_list_g[H5I_FILE_PUBLIC]; + } + else if (H5I_GROUP == type) { + type_ptr = H5I_id_type_list_g[H5I_GROUP_PUBLIC]; + } + else if (H5I_DATASET == type) { + type_ptr = H5I_id_type_list_g[H5I_DATASET_PUBLIC]; + } + else { ret_value ++; continue; } - - type_ptr = H5I_id_type_list_g[H5I_UID]; - + if(type_ptr == NULL || type_ptr->count <= 0) HGOTO_ERROR(H5E_ATOM, H5E_BADGROUP, FAIL, "invalid type") @@ -2412,8 +2410,7 @@ done: /*------------------------------------------------------------------------- * Function: H5I_inc_ref_uid * - * Purpose: change the ids used by the HDF5 libraries to the UIDs that - * are provided to the user + * Purpose: increment the ref count on the high level ID given the low level ID * * Return: How many IDs were replaced. * @@ -2423,14 +2420,25 @@ done: *------------------------------------------------------------------------- */ int -H5I_inc_ref_uid(hid_t fid, hbool_t app_ref) +H5I_inc_ref_uid(hid_t id, hbool_t app_ref) { H5I_id_type_t *type_ptr; /*ptr to the type */ + H5I_type_t type; int ret_value = 0; /* Return value */ FUNC_ENTER_NOAPI(FAIL) + + type = H5I_get_type(id); - type_ptr = H5I_id_type_list_g[H5I_UID]; + if (type == H5I_FILE) { + type_ptr = H5I_id_type_list_g[H5I_FILE_PUBLIC]; + } + else if (type = H5I_GROUP) { + type_ptr = H5I_id_type_list_g[H5I_GROUP_PUBLIC]; + } + else { + HGOTO_DONE(ret_value) + } if(type_ptr == NULL || type_ptr->count <= 0) HGOTO_ERROR(H5E_ATOM, H5E_BADGROUP, FAIL, "invalid type") @@ -2447,10 +2455,7 @@ H5I_inc_ref_uid(hid_t fid, hbool_t app_ref) while(id_ptr) { if(NULL == (uid_info = (H5I_t *)H5I_object(id_ptr->id))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "invalid user identifier") - if (uid_info->obj_id == fid) { - /* increment ref count on the VOL id */ - if(H5I_inc_ref(uid_info->vol_id, FALSE) < 0) - HGOTO_ERROR(H5E_FILE, H5E_CANTINC, FAIL, "unable to increment ref count on vol plugin") + if (uid_info->obj_id == id) { /* Increment reference count on atom. */ if((ret_value = H5I_inc_ref(id_ptr->id, app_ref)) < 0) HGOTO_ERROR(H5E_ATOM, H5E_CANTSET, FAIL, "incrementing file ID failed") diff --git a/src/H5Iprivate.h b/src/H5Iprivate.h index bc2f354..c8bf768 100644 --- a/src/H5Iprivate.h +++ b/src/H5Iprivate.h @@ -24,6 +24,7 @@ /* Include package's public header */ #include "H5Ipublic.h" +#include "H5VLpublic.h" /* Private headers needed by this file */ #include "H5private.h" @@ -34,18 +35,22 @@ /* Default sizes of the hash-tables for various atom types */ #define H5I_ERRSTACK_HASHSIZE 64 -#define H5I_FILEID_HASHSIZE 64 +#define H5I_FILEID_HASHSIZE 64 #define H5I_TEMPID_HASHSIZE 64 #define H5I_DATATYPEID_HASHSIZE 64 #define H5I_DATASPACEID_HASHSIZE 64 #define H5I_DATASETID_HASHSIZE 64 #define H5I_OID_HASHSIZE 64 -#define H5I_GROUPID_HASHSIZE 64 +#define H5I_GROUPID_HASHSIZE 64 #define H5I_ATTRID_HASHSIZE 64 #define H5I_REFID_HASHSIZE 64 #define H5I_VFL_HASHSIZE 64 #define H5I_VOL_HASHSIZE 64 -#define H5I_UID_HASHSIZE 64 +#define H5I_FILE_PUBLIC_HASHSIZE 64 +#define H5I_GROUP_PUBLIC_HASHSIZE 64 +#define H5I_DATASET_PUBLIC_HASHSIZE 64 +#define H5I_ATTRIBUTE_PUBLIC_HASHSIZE 64 +#define H5I_DATATYPE_PUBLIC_HASHSIZE 64 #define H5I_GENPROPCLS_HASHSIZE 64 #define H5I_GENPROPOBJ_HASHSIZE 128 #define H5I_ERRCLS_HASHSIZE 64 @@ -54,8 +59,8 @@ /* type of the ID passed to users */ typedef struct H5I_t { - hid_t vol_id; /* ID for VOL plugin */ hid_t obj_id; /* actual id for object */ + H5VL_class_t *vol_plugin; /* pointer to the VOL structure */ } H5I_t; /* Private Functions in H5I.c */ diff --git a/src/H5Ipublic.h b/src/H5Ipublic.h index d1a36b9..5416b6e 100644 --- a/src/H5Ipublic.h +++ b/src/H5Ipublic.h @@ -36,8 +36,8 @@ typedef enum H5I_type_t { H5I_UNINIT = (-2), /*uninitialized type */ H5I_BADID = (-1), /*invalid Type */ - H5I_FILE = 1, /*type ID for File objects */ - H5I_GROUP, /*type ID for Group objects */ + H5I_FILE = 1, /*type ID for File objects */ + H5I_GROUP, /*type ID for Group objects */ H5I_DATATYPE, /*type ID for Datatype objects */ H5I_DATASPACE, /*type ID for Dataspace objects */ H5I_DATASET, /*type ID for Dataset objects */ @@ -45,7 +45,11 @@ typedef enum H5I_type_t { H5I_REFERENCE, /*type ID for Reference objects */ H5I_VFL, /*type ID for virtual file layer */ H5I_VOL, /*type ID for virtual object layer */ - H5I_UID, /*type ID for upper level user ID objects */ + H5I_FILE_PUBLIC, /*type ID for upper level file ID objects */ + H5I_GROUP_PUBLIC, /*type ID for upper level group ID objects */ + H5I_DATASET_PUBLIC, /*type ID for upper level dataset ID objects */ + H5I_ATTRIBUTE_PUBLIC, /*type ID for upper level attribute ID objects */ + H5I_DATATYPE_PUBLIC, /*type ID for upper level datatype ID objects */ H5I_GENPROP_CLS, /*type ID for generic property list classes */ H5I_GENPROP_LST, /*type ID for generic property lists */ H5I_ERROR_CLASS, /*type ID for error classes */ diff --git a/src/H5L.c b/src/H5L.c index 924b3a9..4f757f1 100644 --- a/src/H5L.c +++ b/src/H5L.c @@ -1164,7 +1164,7 @@ H5Literate(hid_t uid, H5_index_t idx_type, H5_iter_order_t order, /* Check arguments */ id_type = H5I_get_type(uid); - if (H5I_UID == id_type) { + if (H5I_FILE_PUBLIC == id_type) { if(NULL == (uid_info = (H5I_t *)H5I_object(uid))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "invalid user identifier") grp_id = uid_info->obj_id; @@ -1318,7 +1318,7 @@ H5Lvisit(hid_t uid, H5_index_t idx_type, H5_iter_order_t order, id_type = H5I_get_type(uid); - if (H5I_UID == id_type) { + if (H5I_FILE_PUBLIC == id_type) { if(NULL == (uid_info = (H5I_t *)H5I_object(uid))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "invalid user identifier") grp_id = uid_info->obj_id; diff --git a/src/H5O.c b/src/H5O.c index 87a1cd2..1f94a14 100644 --- a/src/H5O.c +++ b/src/H5O.c @@ -230,22 +230,27 @@ H5O_init_interface(void) hid_t H5Oopen(hid_t loc_id, const char *name, hid_t lapl_id) { - H5G_loc_t loc; hid_t ret_value = FAIL; + void *location = NULL; /* a pointer to VOL specific token that indicates + the location of the object */ + void *argv[2]; FUNC_ENTER_API(FAIL) H5TRACE3("i", "i*si", loc_id, name, lapl_id); - /* Check args */ - if(H5G_loc(loc_id, &loc) < 0) - HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a location") if(!name || !*name) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "no name") - /* Open the object */ - if((ret_value = H5O_open_name(&loc, name, lapl_id, TRUE)) < 0) - HGOTO_ERROR(H5E_SYM, H5E_CANTOPENOBJ, FAIL, "unable to open object") + argv[0] = (void *)name; + argv[1] = &lapl_id; + + /* Get the token for the Object location through the VOL */ + if(H5VL_object_lookup (loc_id, H5O_LOOKUP_BY_NAME, &location, 2, argv) < 0) + HGOTO_ERROR(H5E_SYM, H5E_CANTINIT, FAIL, "unable to locate object") + /* Open the object through the VOL */ + if((ret_value = H5VL_object_open(loc_id, location, lapl_id)) < 0) + HGOTO_ERROR(H5E_SYM, H5E_CANTINIT, FAIL, "unable to open object") done: FUNC_LEAVE_API(ret_value) } /* end H5Oopen() */ @@ -278,19 +283,14 @@ hid_t H5Oopen_by_idx(hid_t loc_id, const char *group_name, H5_index_t idx_type, H5_iter_order_t order, hsize_t n, hid_t lapl_id) { - H5G_loc_t loc; - H5G_loc_t obj_loc; /* Location used to open group */ - H5G_name_t obj_path; /* Opened object group hier. path */ - H5O_loc_t obj_oloc; /* Opened object object location */ - hbool_t loc_found = FALSE; /* Entry at 'name' found */ + void *location = NULL; + void *argv[5]; hid_t ret_value = FAIL; FUNC_ENTER_API(FAIL) H5TRACE6("i", "i*sIiIohi", loc_id, group_name, idx_type, order, n, lapl_id); /* Check args */ - if(H5G_loc(loc_id, &loc) < 0) - HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a location") if(!group_name || !*group_name) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "no name specified") if(idx_type <= H5_INDEX_UNKNOWN || idx_type >= H5_INDEX_N) @@ -303,26 +303,21 @@ H5Oopen_by_idx(hid_t loc_id, const char *group_name, H5_index_t idx_type, if(TRUE != H5P_isa_class(lapl_id, H5P_LINK_ACCESS)) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not link access property list ID") - /* Set up opened group location to fill in */ - obj_loc.oloc = &obj_oloc; - obj_loc.path = &obj_path; - H5G_loc_reset(&obj_loc); + argv[0] = (void *)group_name; + argv[1] = &idx_type; + argv[2] = ℴ + argv[3] = &n; + argv[4] = &lapl_id; + + /* Get the token for the Object location through the VOL */ + if(H5VL_object_lookup (loc_id, H5O_LOOKUP_BY_IDX, &location, 5, argv) < 0) + HGOTO_ERROR(H5E_SYM, H5E_CANTINIT, FAIL, "unable to locate object") - /* Find the object's location, according to the order in the index */ - if(H5G_loc_find_by_idx(&loc, group_name, idx_type, order, n, &obj_loc/*out*/, lapl_id, H5AC_dxpl_id) < 0) - HGOTO_ERROR(H5E_SYM, H5E_NOTFOUND, FAIL, "group not found") - loc_found = TRUE; - - /* Open the object */ - if((ret_value = H5O_open_by_loc(&obj_loc, lapl_id, H5AC_dxpl_id, TRUE)) < 0) - HGOTO_ERROR(H5E_SYM, H5E_CANTOPENOBJ, FAIL, "unable to open object") + /* Open the object through the VOL */ + if((ret_value = H5VL_object_open(loc_id, location, lapl_id)) < 0) + HGOTO_ERROR(H5E_SYM, H5E_CANTINIT, FAIL, "unable to open object") done: - /* Release the object location if we failed after copying it */ - if(ret_value < 0 && loc_found) - if(H5G_loc_free(&obj_loc) < 0) - HDONE_ERROR(H5E_SYM, H5E_CANTRELEASE, FAIL, "can't free location") - FUNC_LEAVE_API(ret_value) } /* end H5Oopen_by_idx() */ @@ -365,33 +360,23 @@ done: hid_t H5Oopen_by_addr(hid_t loc_id, haddr_t addr) { - H5G_loc_t loc; - H5G_loc_t obj_loc; /* Location used to open group */ - H5G_name_t obj_path; /* Opened object group hier. path */ - H5O_loc_t obj_oloc; /* Opened object object location */ hid_t lapl_id = H5P_LINK_ACCESS_DEFAULT; /* lapl to use to open this object */ + void *location = NULL; + void *argv[1]; hid_t ret_value = FAIL; FUNC_ENTER_API(FAIL) H5TRACE2("i", "ia", loc_id, addr); - /* Check args */ - if(H5G_loc(loc_id, &loc) < 0) - HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a location") - if(!H5F_addr_defined(addr)) - HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "no address supplied") - - /* Set up opened group location to fill in */ - obj_loc.oloc = &obj_oloc; - obj_loc.path = &obj_path; - H5G_loc_reset(&obj_loc); - obj_loc.oloc->addr = addr; - obj_loc.oloc->file = loc.oloc->file; - H5G_name_reset(obj_loc.path); /* objects opened through this routine don't have a path name */ + argv[0] = &addr; + + /* Get the token for the Object location through the VOL */ + if(H5VL_object_lookup (loc_id, H5O_LOOKUP_BY_ADDR, &location, 1, argv) < 0) + HGOTO_ERROR(H5E_SYM, H5E_CANTINIT, FAIL, "unable to locate object") - /* Open the object */ - if((ret_value = H5O_open_by_loc(&obj_loc, lapl_id, H5AC_dxpl_id, TRUE)) < 0) - HGOTO_ERROR(H5E_SYM, H5E_CANTOPENOBJ, FAIL, "unable to open object") + /* Open the object through the VOL */ + if((ret_value = H5VL_object_open(loc_id, location, lapl_id)) < 0) + HGOTO_ERROR(H5E_SYM, H5E_CANTINIT, FAIL, "unable to open object") done: @@ -597,21 +582,22 @@ done: herr_t H5Oget_info(hid_t loc_id, H5O_info_t *oinfo) { - H5G_loc_t loc; /* Location of group */ + void *argv[1]; + hid_t lapl_id; herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_API(FAIL) H5TRACE2("e", "i*x", loc_id, oinfo); /* Check args */ - if(H5G_loc(loc_id, &loc) < 0) - HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a location") if(!oinfo) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "no info struct") - /* Retrieve the object's information */ - if(H5G_loc_info(&loc, ".", TRUE, oinfo/*out*/, H5P_LINK_ACCESS_DEFAULT, H5AC_ind_dxpl_id) < 0) - HGOTO_ERROR(H5E_SYM, H5E_NOTFOUND, FAIL, "object not found") + lapl_id = H5P_LINK_ACCESS_DEFAULT; + argv[0] = &lapl_id; + + if((ret_value = H5VL_object_get(loc_id, H5O_GET_INFO, (void *)oinfo, 1, argv)) < 0) + HGOTO_ERROR(H5E_INTERNAL, H5E_CANTGET, FAIL, "unable to get object info") done: FUNC_LEAVE_API(ret_value) @@ -634,15 +620,13 @@ done: herr_t H5Oget_info_by_name(hid_t loc_id, const char *name, H5O_info_t *oinfo, hid_t lapl_id) { - H5G_loc_t loc; /* Location of group */ + void *argv[2]; herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_API(FAIL) H5TRACE4("e", "i*s*xi", loc_id, name, oinfo, lapl_id); /* Check args */ - if(H5G_loc(loc_id, &loc) < 0) - HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a location") if(!name || !*name) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "no name") if(!oinfo) @@ -653,10 +637,10 @@ H5Oget_info_by_name(hid_t loc_id, const char *name, H5O_info_t *oinfo, hid_t lap if(TRUE != H5P_isa_class(lapl_id, H5P_LINK_ACCESS)) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not link access property list ID") - /* Retrieve the object's information */ - if(H5G_loc_info(&loc, name, TRUE, oinfo/*out*/, lapl_id, H5AC_ind_dxpl_id) < 0) - HGOTO_ERROR(H5E_SYM, H5E_NOTFOUND, FAIL, "object not found") - + argv[0] = &lapl_id; + argv[1] = (void *)name; + if((ret_value = H5VL_object_get(loc_id, H5O_GET_INFO, (void *)oinfo, 2, argv)) < 0) + HGOTO_ERROR(H5E_INTERNAL, H5E_CANTGET, FAIL, "unable to get object info") done: FUNC_LEAVE_API(ret_value) } /* end H5Oget_info_by_name() */ @@ -680,11 +664,7 @@ herr_t H5Oget_info_by_idx(hid_t loc_id, const char *group_name, H5_index_t idx_type, H5_iter_order_t order, hsize_t n, H5O_info_t *oinfo, hid_t lapl_id) { - H5G_loc_t loc; /* Location of group */ - H5G_loc_t obj_loc; /* Location used to open group */ - H5G_name_t obj_path; /* Opened object group hier. path */ - H5O_loc_t obj_oloc; /* Opened object object location */ - hbool_t loc_found = FALSE; /* Entry at 'name' found */ + void *argv[5]; herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_API(FAIL) @@ -692,8 +672,6 @@ H5Oget_info_by_idx(hid_t loc_id, const char *group_name, H5_index_t idx_type, lapl_id); /* Check args */ - if(H5G_loc(loc_id, &loc) < 0) - HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a location") if(!group_name || !*group_name) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "no name specified") if(idx_type <= H5_INDEX_UNKNOWN || idx_type >= H5_INDEX_N) @@ -708,25 +686,15 @@ H5Oget_info_by_idx(hid_t loc_id, const char *group_name, H5_index_t idx_type, if(TRUE != H5P_isa_class(lapl_id, H5P_LINK_ACCESS)) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not link access property list ID") - /* Set up opened group location to fill in */ - obj_loc.oloc = &obj_oloc; - obj_loc.path = &obj_path; - H5G_loc_reset(&obj_loc); - - /* Find the object's location, according to the order in the index */ - if(H5G_loc_find_by_idx(&loc, group_name, idx_type, order, n, &obj_loc/*out*/, lapl_id, H5AC_ind_dxpl_id) < 0) - HGOTO_ERROR(H5E_SYM, H5E_NOTFOUND, FAIL, "group not found") - loc_found = TRUE; - - /* Retrieve the object's information */ - if(H5O_get_info(obj_loc.oloc, H5AC_ind_dxpl_id, TRUE, oinfo) < 0) - HGOTO_ERROR(H5E_SYM, H5E_CANTGET, FAIL, "can't retrieve object info") + argv[0] = (void *)group_name; + argv[1] = &idx_type; + argv[2] = ℴ + argv[3] = &n; + argv[4] = &lapl_id; + if((ret_value = H5VL_object_get(loc_id, H5O_GET_INFO, (void *)oinfo, 5, argv)) < 0) + HGOTO_ERROR(H5E_INTERNAL, H5E_CANTGET, FAIL, "unable to get object info") done: - /* Release the object location */ - if(loc_found && H5G_loc_free(&obj_loc) < 0) - HDONE_ERROR(H5E_SYM, H5E_CANTRELEASE, FAIL, "can't free location") - FUNC_LEAVE_API(ret_value) } /* end H5Oget_info_by_idx() */ @@ -834,22 +802,21 @@ done: *------------------------------------------------------------------------- */ ssize_t -H5Oget_comment(hid_t obj_id, char *comment, size_t bufsize) +H5Oget_comment(hid_t loc_id, char *comment, size_t bufsize) { - H5G_loc_t loc; /* Location of group */ + void *argv[2]; ssize_t ret_value; /* Return value */ FUNC_ENTER_API(FAIL) - H5TRACE3("Zs", "i*sz", obj_id, comment, bufsize); + H5TRACE3("Zs", "i*sz", loc_id, comment, bufsize); - /* Check args */ - if(H5G_loc(obj_id, &loc) < 0) - HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a location") + argv[0] = &ret_value; + argv[1] = &bufsize; - /* Retrieve the object's comment */ - if((ret_value = H5G_loc_get_comment(&loc, ".", comment/*out*/, bufsize, H5P_LINK_ACCESS_DEFAULT, H5AC_ind_dxpl_id)) < 0) - HGOTO_ERROR(H5E_SYM, H5E_NOTFOUND, FAIL, "object not found") + if(H5VL_object_get(loc_id, H5O_GET_COMMENT, (void *)comment, 2, argv) < 0) + HGOTO_ERROR(H5E_INTERNAL, H5E_CANTGET, FAIL, "unable to get object comment") + ret_value = *((ssize_t *)argv[0]); done: FUNC_LEAVE_API(ret_value) } /* end H5Oget_comment() */ @@ -875,15 +842,13 @@ ssize_t H5Oget_comment_by_name(hid_t loc_id, const char *name, char *comment, size_t bufsize, hid_t lapl_id) { - H5G_loc_t loc; /* Location of group */ + void *argv[4]; ssize_t ret_value; /* Return value */ FUNC_ENTER_API(FAIL) H5TRACE5("Zs", "i*s*szi", loc_id, name, comment, bufsize, lapl_id); /* Check args */ - if(H5G_loc(loc_id, &loc) < 0) - HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a location") if(!name || !*name) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "no name") if(H5P_DEFAULT == lapl_id) @@ -892,9 +857,14 @@ H5Oget_comment_by_name(hid_t loc_id, const char *name, char *comment, size_t buf if(TRUE != H5P_isa_class(lapl_id, H5P_LINK_ACCESS)) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not link access property list ID") - /* Retrieve the object's comment */ - if((ret_value = H5G_loc_get_comment(&loc, name, comment/*out*/, bufsize, lapl_id, H5AC_ind_dxpl_id)) < 0) - HGOTO_ERROR(H5E_SYM, H5E_NOTFOUND, FAIL, "object not found") + argv[0] = &ret_value; + argv[1] = &bufsize; + argv[2] = (void *)name; + argv[3] = &lapl_id; + if(H5VL_object_get(loc_id, H5O_GET_COMMENT, (void *)comment, 4, argv) < 0) + HGOTO_ERROR(H5E_INTERNAL, H5E_CANTGET, FAIL, "unable to get object comment") + + ret_value = *((ssize_t *)argv[0]); done: FUNC_LEAVE_API(ret_value) @@ -1051,36 +1021,9 @@ H5Oclose(hid_t object_id) FUNC_ENTER_API(FAIL) H5TRACE1("e", "i", object_id); - /* Get the type of the object and close it in the correct way */ - switch(H5I_get_type(object_id)) { - case H5I_GROUP: - case H5I_DATATYPE: - case H5I_DATASET: - if(H5I_object(object_id) == NULL) - HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "not a valid object") - if(H5I_dec_app_ref(object_id) < 0) - HGOTO_ERROR(H5E_OHDR, H5E_CANTRELEASE, FAIL, "unable to close object") - break; - - case H5I_UNINIT: - case H5I_BADID: - case H5I_FILE: - case H5I_DATASPACE: - case H5I_ATTR: - case H5I_REFERENCE: - case H5I_VFL: - case H5I_VOL: - case H5I_UID: - case H5I_GENPROP_CLS: - case H5I_GENPROP_LST: - case H5I_ERROR_CLASS: - case H5I_ERROR_MSG: - case H5I_ERROR_STACK: - case H5I_NTYPES: - default: - HGOTO_ERROR(H5E_ARGS, H5E_CANTRELEASE, FAIL, "not a valid file object ID (dataset, group, or datatype)") - break; - } /* end switch */ + /* Close the object through the VOL */ + if(H5VL_object_close(object_id) < 0) + HGOTO_ERROR(H5E_SYM, H5E_CANTRELEASE, FAIL, "unable to close object") done: FUNC_LEAVE_API(ret_value) @@ -2448,12 +2391,32 @@ done: *------------------------------------------------------------------------- */ H5O_loc_t * -H5O_get_loc(hid_t object_id) +H5O_get_loc(hid_t id) { + H5I_t *uid_info; /* user id structure */ + hid_t object_id; + H5I_type_t id_type; H5O_loc_t *ret_value; /* Return value */ FUNC_ENTER_NOAPI_NOINIT + id_type = H5I_get_type(id); + + /* get the actual ID from an upper ID level */ + /* MSC - this is a workaround to allow the test suite to pass and + at some point needs to be removed once all high level operations + that needs to go through the VOL actually go through the VOL*/ + if (H5I_FILE_PUBLIC == id_type || H5I_GROUP_PUBLIC == id_type || + H5I_DATASET_PUBLIC == id_type || H5I_DATATYPE_PUBLIC == id_type || + H5I_ATTRIBUTE_PUBLIC == id_type) { + if(NULL == (uid_info = (H5I_t *)H5I_object(id))) + HGOTO_ERROR(H5E_ATOM, H5E_BADTYPE, NULL, "invalid user identifier") + object_id = uid_info->obj_id; + } + else { + object_id = id; + } + switch(H5I_get_type(object_id)) { case H5I_GROUP: if(NULL == (ret_value = H5O_OBJ_GROUP->get_oloc(object_id))) @@ -2478,7 +2441,6 @@ H5O_get_loc(hid_t object_id) case H5I_REFERENCE: case H5I_VFL: case H5I_VOL: - case H5I_UID: case H5I_GENPROP_CLS: case H5I_GENPROP_LST: case H5I_ERROR_CLASS: diff --git a/src/H5T.c b/src/H5T.c index fcc4ab3..1bc1f87 100644 --- a/src/H5T.c +++ b/src/H5T.c @@ -1716,16 +1716,22 @@ H5Tclose(hid_t type_id) FUNC_ENTER_API(FAIL) H5TRACE1("e", "i", type_id); - /* Check args */ - if(NULL == (dt = (H5T_t *)H5I_object_verify(type_id, H5I_DATATYPE))) - HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a datatype") - if(H5T_STATE_IMMUTABLE == dt->shared->state) - HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "immutable datatype") - - /* When the reference count reaches zero the resources are freed */ - if(H5I_dec_app_ref(type_id) < 0) - HGOTO_ERROR(H5E_ATOM, H5E_BADATOM, FAIL, "problem freeing id") - + /* if this is a named datatype, go through the VOL layer */ + if (H5I_DATATYPE_PUBLIC == H5I_get_type(type_id)) { + if(H5VL_object_close(type_id) < 0) + HGOTO_ERROR(H5E_SYM, H5E_CANTINIT, FAIL, "unable to free datatype") + } + else { + /* Check args */ + if(NULL == (dt = (H5T_t *)H5I_object_verify(type_id, H5I_DATATYPE))) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a datatype") + if(H5T_STATE_IMMUTABLE == dt->shared->state) + HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "immutable datatype") + + /* When the reference count reaches zero the resources are freed */ + if(H5I_dec_app_ref(type_id) < 0) + HGOTO_ERROR(H5E_ATOM, H5E_BADATOM, FAIL, "problem freeing id") + } done: FUNC_LEAVE_API(ret_value) } /* end H5Tclose() */ diff --git a/src/H5Tcommit.c b/src/H5Tcommit.c index a49d66e..7e90a2d 100644 --- a/src/H5Tcommit.c +++ b/src/H5Tcommit.c @@ -39,7 +39,7 @@ #include "H5Lprivate.h" /* Links */ #include "H5Pprivate.h" /* Property lists */ #include "H5Tpkg.h" /* Datatypes */ - +#include "H5VLprivate.h" /* VOL plugins */ /****************/ /* Local Macros */ @@ -120,22 +120,16 @@ H5T_init_commit_interface(void) */ herr_t H5Tcommit2(hid_t loc_id, const char *name, hid_t type_id, hid_t lcpl_id, - hid_t tcpl_id, hid_t tapl_id) + hid_t tcpl_id, hid_t tapl_id) { - H5G_loc_t loc; /* Location to create datatype */ - H5T_t *type; /* Datatype for ID */ herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_API(FAIL) H5TRACE6("e", "i*siiii", loc_id, name, type_id, lcpl_id, tcpl_id, tapl_id); /* Check arguments */ - if(H5G_loc(loc_id, &loc) < 0) - HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a location") if(!name || !*name) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "no name") - if(NULL == (type = (H5T_t *)H5I_object_verify(type_id, H5I_DATATYPE))) - HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a datatype") /* Get correct property list */ if(H5P_DEFAULT == lcpl_id) @@ -158,10 +152,9 @@ H5Tcommit2(hid_t loc_id, const char *name, hid_t type_id, hid_t lcpl_id, if(TRUE != H5P_isa_class(tapl_id, H5P_DATATYPE_ACCESS)) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not datatype access property list") - /* Commit the type */ - if(H5T__commit_named(&loc, name, type, lcpl_id, tcpl_id, tapl_id, H5AC_dxpl_id) < 0) - HGOTO_ERROR(H5E_DATATYPE, H5E_CANTINIT, FAIL, "unable to commit datatype") - + /* Open the object through the VOL */ + if((ret_value = H5VL_datatype_commit(loc_id, name, type_id, lcpl_id, tcpl_id, tapl_id)) < 0) + HGOTO_ERROR(H5E_SYM, H5E_CANTINIT, FAIL, "unable to open object") done: FUNC_LEAVE_API(ret_value) } /* end H5Tcommit2() */ @@ -551,23 +544,13 @@ done: hid_t H5Topen2(hid_t loc_id, const char *name, hid_t tapl_id) { - H5T_t *type = NULL; /* Datatype opened in file */ - H5G_loc_t loc; /* Group location of object to open */ - H5G_name_t path; /* Datatype group hier. path */ - H5O_loc_t oloc; /* Datatype object location */ - H5O_type_t obj_type; /* Type of object at location */ - H5G_loc_t type_loc; /* Group object for datatype */ - hbool_t obj_found = FALSE; /* Object at 'name' found */ - hid_t dxpl_id = H5AC_dxpl_id; /* dxpl to use to open datatype */ hid_t ret_value = FAIL; /* Return value */ FUNC_ENTER_API(FAIL) H5TRACE3("i", "i*si", loc_id, name, tapl_id); /* Check args */ - if(H5G_loc(loc_id, &loc) < 0) - HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a location") - if(!name || !*name) + if(!name || !*name) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "no name") /* Get correct property list */ @@ -577,43 +560,11 @@ H5Topen2(hid_t loc_id, const char *name, hid_t tapl_id) if(TRUE != H5P_isa_class(tapl_id, H5P_DATATYPE_ACCESS)) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not datatype access property list") - /* Set up datatype location to fill in */ - type_loc.oloc = &oloc; - type_loc.path = &path; - H5G_loc_reset(&type_loc); - - /* - * Find the named datatype object header and read the datatype message - * from it. - */ - if(H5G_loc_find(&loc, name, &type_loc/*out*/, tapl_id, dxpl_id) < 0) - HGOTO_ERROR(H5E_DATATYPE, H5E_NOTFOUND, FAIL, "not found") - obj_found = TRUE; - - /* Check that the object found is the correct type */ - if(H5O_obj_type(&oloc, &obj_type, dxpl_id) < 0) - HGOTO_ERROR(H5E_DATATYPE, H5E_CANTGET, FAIL, "can't get object type") - if(obj_type != H5O_TYPE_NAMED_DATATYPE) - HGOTO_ERROR(H5E_DATATYPE, H5E_BADTYPE, FAIL, "not a named datatype") - - /* Open it */ - if(NULL == (type = H5T_open(&type_loc, dxpl_id))) - HGOTO_ERROR(H5E_DATATYPE, H5E_CANTOPENOBJ, FAIL, "unable to open named datatype") - - /* Register the type and return the ID */ - if((ret_value = H5I_register(H5I_DATATYPE, type, TRUE)) < 0) - HGOTO_ERROR(H5E_DATATYPE, H5E_CANTREGISTER, FAIL, "unable to register named datatype") + /* Open the datatype through the VOL */ + if((ret_value = H5VL_datatype_open(loc_id, name, tapl_id)) < 0) + HGOTO_ERROR(H5E_SYM, H5E_CANTINIT, FAIL, "unable to open datatype") done: - if(ret_value < 0) { - if(type != NULL) - H5T_close(type); - else { - if(obj_found && H5F_addr_defined(type_loc.oloc->addr)) - H5G_loc_free(&type_loc); - } /* end else */ - } /* end if */ - FUNC_LEAVE_API(ret_value) } /* end H5Topen2() */ diff --git a/src/H5VL.c b/src/H5VL.c index 2b41794..126a3b0 100644 --- a/src/H5VL.c +++ b/src/H5VL.c @@ -27,7 +27,7 @@ /* Module Setup */ /****************/ -#define H5VL_PACKAGE /*suppress error about including H5FDpkg */ +#define H5VL_PACKAGE /*suppress error about including H5VLpkg */ /* Interface initialization */ #define H5_INTERFACE_INIT_FUNC H5VL_init_interface @@ -38,11 +38,12 @@ #include "H5private.h" /* Generic Functions */ #include "H5Dprivate.h" /* Datasets */ #include "H5Eprivate.h" /* Error handling */ -#include "H5VLpkg.h" /* VOL package header */ -#include "H5VLprivate.h" /* VOL */ #include "H5Iprivate.h" /* IDs */ #include "H5MMprivate.h" /* Memory management */ #include "H5Pprivate.h" /* Property lists */ +#include "H5Oprivate.h" /* Object headers */ +#include "H5VLpkg.h" /* VOL package header */ +#include "H5VLprivate.h" /* VOL */ /* Declare a free list to manage the H5I_t struct */ H5FL_DEFINE_STATIC(H5I_t); @@ -514,7 +515,7 @@ done: * Purpose: Opens a file through the VOL. * * Return: Success: User ID of the new file. This ID is of type - * H5I_UID which contains the VOL id and the actual file ID + * H5I_FILE_PUBLIC which contains the VOL id and the actual file ID * * Failure: FAIL * @@ -555,13 +556,14 @@ H5VL_file_open(const char *name, unsigned flags, hid_t fcpl_id, hid_t fapl_id, h if(NULL == (uid_info = H5FL_MALLOC(H5I_t))) HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, FAIL, "memory allocation failed") uid_info->obj_id = file_id; - uid_info->vol_id = plugin_id; + //uid_info->vol_id = plugin_id; + uid_info->vol_plugin = vol_plugin; /* increment ref count on the VOL id */ - if(H5I_inc_ref(uid_info->vol_id, FALSE) < 0) + if(H5I_inc_ref(plugin_id, FALSE) < 0) HGOTO_ERROR(H5E_FILE, H5E_CANTINC, FAIL, "unable to increment ref count on vol plugin") - if((ret_value = H5I_register(H5I_UID, uid_info, TRUE)) < 0) + if((ret_value = H5I_register(H5I_FILE_PUBLIC, uid_info, TRUE)) < 0) HGOTO_ERROR(H5E_ATOM, H5E_CANTREGISTER, FAIL, "unable to atomize file handle") done: FUNC_LEAVE_NOAPI(ret_value) @@ -574,7 +576,7 @@ done: * Purpose: Creates a file through the VOL * * Return: Success: User ID of the new file. This ID is of type - * H5I_UID which contains the VOL id and the actual file ID + * H5I_FILE_PUBLIC which contains the VOL id and the actual file ID * * Failure: FAIL * @@ -600,7 +602,6 @@ H5VL_file_create(const char *name, unsigned flags, hid_t fcpl_id, hid_t fapl_id) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a file access property list") if(H5P_get(plist, H5F_ACS_VOL_ID_NAME, &plugin_id) < 0) HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, FAIL, "can't get vol plugin ID") - //printf ("VOL REF COUNT: %d\n",H5I_get_ref (plugin_id, FALSE)); if(NULL == (vol_plugin = (H5VL_class_t *)H5I_object(plugin_id))) HGOTO_ERROR(H5E_VOL, H5E_BADVALUE, FAIL, "invalid vol plugin ID in file access property list") @@ -616,13 +617,14 @@ H5VL_file_create(const char *name, unsigned flags, hid_t fcpl_id, hid_t fapl_id) if(NULL == (uid_info = H5FL_MALLOC(H5I_t))) HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, FAIL, "memory allocation failed") uid_info->obj_id = file_id; - uid_info->vol_id = plugin_id; + uid_info->vol_plugin = vol_plugin; + //uid_info->vol_id = plugin_id; /* increment ref count on the VOL id */ - if(H5I_inc_ref(uid_info->vol_id, FALSE) < 0) + if(H5I_inc_ref(plugin_id, FALSE) < 0) HGOTO_ERROR(H5E_FILE, H5E_CANTINC, FAIL, "unable to increment ref count on vol plugin") - if((ret_value = H5I_register(H5I_UID, uid_info, TRUE)) < 0) + if((ret_value = H5I_register(H5I_FILE_PUBLIC, uid_info, TRUE)) < 0) HGOTO_ERROR(H5E_ATOM, H5E_CANTREGISTER, FAIL, "unable to atomize file handle") done: @@ -647,35 +649,37 @@ done: herr_t H5VL_file_close(hid_t uid) { - H5VL_class_t *vol_plugin; /* VOL for file */ H5I_t *uid_info; /* user id structure */ herr_t ret_value = SUCCEED; FUNC_ENTER_NOAPI(FAIL) /* Check/fix arguments. */ - if(H5I_UID != H5I_get_type(uid)) + if(H5I_FILE_PUBLIC != H5I_get_type(uid)) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a user ID") /* get the ID struct */ if(NULL == (uid_info = (H5I_t *)H5I_object(uid))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "invalid user identifier") +#if 0 /* get VOL plugin info */ if(NULL == (vol_plugin = (H5VL_class_t *)H5I_object(uid_info->vol_id))) HGOTO_ERROR(H5E_VOL, H5E_BADVALUE, FAIL, "invalid vol plugin ID in file") - - if(NULL == vol_plugin->file_cls.close) +#endif + if(NULL == uid_info->vol_plugin->file_cls.close) HGOTO_ERROR(H5E_VOL, H5E_UNSUPPORTED, FAIL, "vol plugin has no `file close' method") - if((ret_value = (vol_plugin->file_cls.close)(uid_info->obj_id)) < 0) + if((ret_value = (uid_info->vol_plugin->file_cls.close)(uid_info->obj_id)) < 0) HGOTO_ERROR(H5E_VOL, H5E_CANTCLOSEFILE, FAIL, "close failed") - +#if 0 /* decrement ref count on the VOL id */ if(H5I_dec_ref(uid_info->vol_id) < 0) HGOTO_ERROR(H5E_FILE, H5E_CANTDEC, FAIL, "unable to decrement ref count on vol plugin") +#endif if(H5I_dec_app_ref(uid) < 0) HGOTO_ERROR(H5E_FILE, H5E_CANTINC, FAIL, "unable to decrement ref count on user ID") + done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5VL_file_close() */ @@ -698,27 +702,22 @@ done: herr_t H5VL_file_flush(hid_t uid, H5F_scope_t scope) { - H5VL_class_t *vol_plugin; /* VOL for file */ H5I_t *uid_info; /* user id structure */ herr_t ret_value = SUCCEED; FUNC_ENTER_NOAPI(FAIL) /* Check/fix arguments. */ - if(H5I_UID != H5I_get_type(uid)) + if(H5I_FILE_PUBLIC != H5I_get_type(uid)) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a user ID") /* get the ID struct */ if(NULL == (uid_info = (H5I_t *)H5I_object(uid))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "invalid user identifier") - /* get VOL plugin info */ - if(NULL == (vol_plugin = (H5VL_class_t *)H5I_object(uid_info->vol_id))) - HGOTO_ERROR(H5E_VOL, H5E_BADVALUE, FAIL, "invalid vol plugin ID in file") - - if(NULL == vol_plugin->file_cls.flush) + if(NULL == uid_info->vol_plugin->file_cls.flush) HGOTO_ERROR(H5E_VOL, H5E_UNSUPPORTED, FAIL, "vol plugin has no `file flush' method") - if((ret_value = (vol_plugin->file_cls.flush)(uid_info->obj_id, scope)) < 0) + if((ret_value = (uid_info->vol_plugin->file_cls.flush)(uid_info->obj_id, scope)) < 0) HGOTO_ERROR(H5E_VOL, H5E_CANTFLUSH, FAIL, "flush failed") done: @@ -743,33 +742,28 @@ done: herr_t H5VL_file_get(hid_t uid, H5VL_file_get_t get_type, void *data, int argc, void **argv) { - H5VL_class_t *vol_plugin; /* VOL for file */ H5I_t *uid_info; /* user id structure */ herr_t ret_value = SUCCEED; FUNC_ENTER_NOAPI(FAIL) /* Check/fix arguments. */ - if(H5I_UID != H5I_get_type(uid)) + if(H5I_FILE_PUBLIC != H5I_get_type(uid)) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a user ID") /* get the ID struct */ if(NULL == (uid_info = (H5I_t *)H5I_object(uid))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "invalid user identifier") - /* get VOL plugin info */ - if(NULL == (vol_plugin = (H5VL_class_t *)H5I_object(uid_info->vol_id))) - HGOTO_ERROR(H5E_VOL, H5E_BADVALUE, FAIL, "invalid vol plugin ID in file") - - if(NULL == vol_plugin->file_cls.get) + if(NULL == uid_info->vol_plugin->file_cls.get) HGOTO_ERROR(H5E_VOL, H5E_UNSUPPORTED, FAIL, "vol plugin has no `file get' method") - if((ret_value = (vol_plugin->file_cls.get)(uid_info->obj_id, get_type, data, argc, argv)) < 0) + if((ret_value = (uid_info->vol_plugin->file_cls.get)(uid_info->obj_id, get_type, data, argc, argv)) < 0) HGOTO_ERROR(H5E_VOL, H5E_CANTGET, FAIL, "get failed") done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5VL_file_get() */ -#if 0 + /*------------------------------------------------------------------------- * Function: H5VL_group_create @@ -777,19 +771,18 @@ done: * Purpose: Creates a group through the VOL * * Return: Success: User ID of the new group. This ID is of type - * H5I_UID which contains the VOL id and the actual group ID + * H5I_GROUP_PUBLIC which contains the VOL id and the actual group ID * * Failure: FAIL * * Programmer: Mohamad Chaarawi - * January, 2012 + * March, 2012 * *------------------------------------------------------------------------- */ hid_t H5VL_group_create(hid_t uid, const char *name, hid_t lcpl_id, hid_t gcpl_id, hid_t gapl_id) { - H5VL_class_t *vol_plugin; /* VOL for group */ H5I_t *uid_info1; /* user id structure of the location where the group will be created */ H5I_t *uid_info2; /* user id structure of new created group*/ hid_t group_id; /* actual group ID */ @@ -797,23 +790,16 @@ H5VL_group_create(hid_t uid, const char *name, hid_t lcpl_id, hid_t gcpl_id, hid FUNC_ENTER_NOAPI(FAIL) - /* Check/fix arguments. */ - if(H5I_UID != H5I_get_type(uid)) - HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a user ID") - /* get the ID struct */ if(NULL == (uid_info1 = (H5I_t *)H5I_object(uid))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "invalid user identifier") - /* get VOL plugin info */ - if(NULL == (vol_plugin = (H5VL_class_t *)H5I_object(uid_info1->vol_id))) - HGOTO_ERROR(H5E_VOL, H5E_BADVALUE, FAIL, "invalid vol plugin ID in file") - /* check if the corresponding VOL create callback exists */ - if(NULL == vol_plugin->object_cls.create) + if(NULL == uid_info1->vol_plugin->group_cls.create) HGOTO_ERROR(H5E_VOL, H5E_UNSUPPORTED, FAIL, "vol plugin has no `group create' method") + /* call the corresponding VOL create callback */ - if((group_id = (vol_plugin->object_cls.create) + if((group_id = (uid_info1->vol_plugin->group_cls.create) (uid_info1->obj_id, name, lcpl_id, gcpl_id, gapl_id)) < 0) HGOTO_ERROR(H5E_VOL, H5E_CANTINIT, FAIL, "create failed") @@ -822,16 +808,698 @@ H5VL_group_create(hid_t uid, const char *name, hid_t lcpl_id, hid_t gcpl_id, hid if(NULL == (uid_info2 = H5FL_MALLOC(H5I_t))) HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, FAIL, "memory allocation failed") uid_info2->obj_id = group_id; - uid_info2->vol_id = uid_info1->vol_id; + uid_info2->vol_plugin = uid_info1->vol_plugin; - /* increment ref count on the VOL id */ - if(H5I_inc_ref(uid_info2->vol_id, FALSE) < 0) - HGOTO_ERROR(H5E_FILE, H5E_CANTINC, FAIL, "unable to increment ref count on vol plugin") - - if((ret_value = H5I_register(H5I_UID, uid_info2, TRUE)) < 0) + if((ret_value = H5I_register(H5I_GROUP_PUBLIC, uid_info2, TRUE)) < 0) HGOTO_ERROR(H5E_ATOM, H5E_CANTREGISTER, FAIL, "unable to atomize group handle") done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5VL_group_create() */ + + +/*------------------------------------------------------------------------- + * Function: H5VL_group_open + * + * Purpose: Opens a group through the VOL + * + * Return: Success: User ID of the new group. This ID is of type + * H5I_GROUP_PUBLIC which contains the VOL id and the actual group ID + * + * Failure: FAIL + * + * Programmer: Mohamad Chaarawi + * March, 2012 + * + *------------------------------------------------------------------------- + */ +hid_t +H5VL_group_open(hid_t uid, const char *name, hid_t gapl_id) +{ + H5I_t *uid_info1; /* user id structure of the location where the group will be opend */ + H5I_t *uid_info2; /* user id structure of new opend group*/ + hid_t group_id; /* actual group ID */ + hid_t ret_value; /* Return value */ + + FUNC_ENTER_NOAPI(FAIL) + + /* get the ID struct */ + if(NULL == (uid_info1 = (H5I_t *)H5I_object(uid))) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "invalid user identifier") + + /* check if the corresponding VOL open callback exists */ + if(NULL == uid_info1->vol_plugin->group_cls.open) + HGOTO_ERROR(H5E_VOL, H5E_UNSUPPORTED, FAIL, "vol plugin has no `group open' method") + /* call the corresponding VOL open callback */ + if((group_id = (uid_info1->vol_plugin->group_cls.open) + (uid_info1->obj_id, name, gapl_id)) < 0) + HGOTO_ERROR(H5E_VOL, H5E_CANTINIT, FAIL, "open failed") + + /* Create a new id that points to a struct that holds the group id and the VOL id */ + /* Allocate new id structure */ + if(NULL == (uid_info2 = H5FL_MALLOC(H5I_t))) + HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, FAIL, "memory allocation failed") + uid_info2->obj_id = group_id; + uid_info2->vol_plugin = uid_info1->vol_plugin; + + if((ret_value = H5I_register(H5I_GROUP_PUBLIC, uid_info2, TRUE)) < 0) + HGOTO_ERROR(H5E_ATOM, H5E_CANTREGISTER, FAIL, "unable to atomize group handle") + +done: + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5VL_group_open() */ + + +/*------------------------------------------------------------------------- + * Function: H5VL_group_close + * + * Purpose: Closes a group through the VOL + * + * Return: Success: Non Negative + * + * Failure: Negative + * + * Programmer: Mohamad Chaarawi + * March, 2012 + * + *------------------------------------------------------------------------- + */ +herr_t +H5VL_group_close(hid_t uid) +{ + H5I_t *uid_info; /* user id structure */ + herr_t ret_value = SUCCEED; + + FUNC_ENTER_NOAPI(FAIL) + + /* Check/fix arguments. */ + if(H5I_GROUP_PUBLIC != H5I_get_type(uid)) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a user ID") + + /* get the ID struct */ + if(NULL == (uid_info = (H5I_t *)H5I_object(uid))) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "invalid user identifier") + + if(NULL == uid_info->vol_plugin->group_cls.close) + HGOTO_ERROR(H5E_VOL, H5E_UNSUPPORTED, FAIL, "vol plugin has no `group close' method") + if((ret_value = (uid_info->vol_plugin->group_cls.close)(uid_info->obj_id)) < 0) + HGOTO_ERROR(H5E_VOL, H5E_CANTRELEASE, FAIL, "close failed") + + if(H5I_dec_app_ref(uid) < 0) + HGOTO_ERROR(H5E_VOL, H5E_CANTDEC, FAIL, "unable to decrement ref count on user ID") + +done: + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5VL_group_close() */ + + +/*------------------------------------------------------------------------- + * Function: H5VL_group_get + * + * Purpose: Get specific information about the group through the VOL + * + * Return: Success: non negative + * + * Failure: negative + * + * Programmer: Mohamad Chaarawi + * February, 2012 + * + *------------------------------------------------------------------------- + */ +herr_t +H5VL_group_get(hid_t uid, H5VL_group_get_t get_type, void *data, int argc, void **argv) +{ + H5I_t *uid_info; /* user id structure */ + herr_t ret_value = SUCCEED; + + FUNC_ENTER_NOAPI(FAIL) + + /* Check/fix arguments. */ + if(H5I_GROUP_PUBLIC != H5I_get_type(uid)) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a user ID") + + /* get the ID struct */ + if(NULL == (uid_info = (H5I_t *)H5I_object(uid))) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "invalid user identifier") + + if(NULL == uid_info->vol_plugin->group_cls.get) + HGOTO_ERROR(H5E_VOL, H5E_UNSUPPORTED, FAIL, "vol plugin has no `group get' method") + if((ret_value = (uid_info->vol_plugin->group_cls.get)(uid_info->obj_id, get_type, data, argc, argv)) < 0) + HGOTO_ERROR(H5E_VOL, H5E_CANTGET, FAIL, "get failed") + +done: + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5VL_group_get() */ + + +/*------------------------------------------------------------------------- + * Function: H5VL_object_open + * + * Purpose: Opens a object through the VOL + * + * Return: Success: User ID of the new object. This ID is of type + * H5I_OBJECT_PUBLIC which contains the VOL id and the actual object ID + * + * Failure: FAIL + * + * Programmer: Mohamad Chaarawi + * March, 2012 + * + *------------------------------------------------------------------------- + */ +hid_t +H5VL_object_open(hid_t uid, void *obj_loc, hid_t lapl_id) +{ + H5I_t *uid_info1; /* user id structure of the location where the object will be opend */ + H5I_t *uid_info2; /* user id structure of new opend object*/ + H5I_type_t id_type; + hid_t object_id; /* actual object ID */ + hid_t ret_value; /* Return value */ + + FUNC_ENTER_NOAPI(FAIL) + + /* get the ID struct */ + if(NULL == (uid_info1 = (H5I_t *)H5I_object(uid))) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "invalid user identifier") + + /* check if the corresponding VOL open callback exists */ + if(NULL == uid_info1->vol_plugin->object_cls.open) + HGOTO_ERROR(H5E_VOL, H5E_UNSUPPORTED, FAIL, "vol plugin has no `object open' method") + + /* call the corresponding VOL open callback */ + if((object_id = (uid_info1->vol_plugin->object_cls.open) + (uid_info1->obj_id, obj_loc, lapl_id)) < 0) + HGOTO_ERROR(H5E_VOL, H5E_CANTINIT, FAIL, "open failed") + + /* Create a new id that points to a struct that holds the object id and the VOL id */ + /* Allocate new id structure */ + if(NULL == (uid_info2 = H5FL_MALLOC(H5I_t))) + HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, FAIL, "memory allocation failed") + uid_info2->obj_id = object_id; + uid_info2->vol_plugin = uid_info1->vol_plugin; + + id_type = H5I_get_type(object_id); + + if (H5I_FILE == id_type) { + if((ret_value = H5I_register(H5I_FILE_PUBLIC, uid_info2, TRUE)) < 0) + HGOTO_ERROR(H5E_ATOM, H5E_CANTREGISTER, FAIL, "unable to atomize object handle") + } + else if (H5I_GROUP == id_type) { + if((ret_value = H5I_register(H5I_GROUP_PUBLIC, uid_info2, TRUE)) < 0) + HGOTO_ERROR(H5E_ATOM, H5E_CANTREGISTER, FAIL, "unable to atomize object handle") + } + else if (H5I_DATATYPE == id_type) { + if((ret_value = H5I_register(H5I_DATATYPE_PUBLIC, uid_info2, TRUE)) < 0) + HGOTO_ERROR(H5E_ATOM, H5E_CANTREGISTER, FAIL, "unable to atomize object handle") + } + else if (H5I_DATASET == id_type) { + if((ret_value = H5I_register(H5I_DATASET_PUBLIC, uid_info2, TRUE)) < 0) + HGOTO_ERROR(H5E_ATOM, H5E_CANTREGISTER, FAIL, "unable to atomize object handle") + } + else { + ret_value = object_id; + } + +done: + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5VL_object_open() */ + + +/*------------------------------------------------------------------------- + * Function: H5VL_object_close + * + * Purpose: Closes a object through the VOL + * + * Return: Success: Non Negative + * + * Failure: Negative + * + * Programmer: Mohamad Chaarawi + * March, 2012 + * + *------------------------------------------------------------------------- + */ +herr_t +H5VL_object_close(hid_t uid) +{ + H5I_t *uid_info; /* user id structure */ + H5I_type_t id_type; + herr_t ret_value = SUCCEED; + + FUNC_ENTER_NOAPI(FAIL) + + id_type = H5I_get_type(uid); + + /* In case of a named datatype being closed with H5Oopen after an + H5Tcommit, the id is still of type H5I_DATATYPE and not + H5I_DATATYPE_PUBLIC. In that case we just fall back to the + native implementation */ + if(H5I_DATATYPE == id_type) { + if(H5I_object(uid) == NULL) + HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "not a valid object") + if(H5I_dec_app_ref(uid) < 0) + HGOTO_ERROR(H5E_OHDR, H5E_CANTRELEASE, FAIL, "unable to close object") + HGOTO_DONE(ret_value) + } + + /* Check id */ + if(H5I_GROUP_PUBLIC != H5I_get_type(uid) && H5I_DATASET_PUBLIC != H5I_get_type(uid) && + H5I_DATATYPE_PUBLIC != H5I_get_type(uid)) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a user ID") + + /* get the ID struct */ + if(NULL == (uid_info = (H5I_t *)H5I_object(uid))) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "invalid user identifier") + + if(NULL == uid_info->vol_plugin->object_cls.close) + HGOTO_ERROR(H5E_VOL, H5E_UNSUPPORTED, FAIL, "vol plugin has no `object close' method") + if((ret_value = (uid_info->vol_plugin->object_cls.close)(uid_info->obj_id)) < 0) + HGOTO_ERROR(H5E_VOL, H5E_CANTRELEASE, FAIL, "close failed") + + if(H5I_dec_app_ref(uid) < 0) + HGOTO_ERROR(H5E_VOL, H5E_CANTDEC, FAIL, "unable to decrement ref count on user ID") + +done: + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5VL_object_close() */ + + +/*------------------------------------------------------------------------- + * Function: H5VL_object_lookup + * + * Purpose: Lookup the object location in the file + * + * Return: Success: non negative + * + * Failure: negative + * + * Programmer: Mohamad Chaarawi + * March, 2012 + * + *------------------------------------------------------------------------- + */ +herr_t +H5VL_object_lookup(hid_t uid, H5VL_object_lookup_t lookup_type, void **location, int argc, void **argv) +{ + H5I_t *uid_info; /* user id structure */ + herr_t ret_value = SUCCEED; + + FUNC_ENTER_NOAPI(FAIL) + + /* Check id */ + if(H5I_FILE_PUBLIC != H5I_get_type(uid) && H5I_GROUP_PUBLIC != H5I_get_type(uid)) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a user ID") + + /* lookup the ID struct */ + if(NULL == (uid_info = (H5I_t *)H5I_object(uid))) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "invalid user identifier") + + if(NULL == uid_info->vol_plugin->object_cls.lookup) + HGOTO_ERROR(H5E_VOL, H5E_UNSUPPORTED, FAIL, "vol plugin has no `object lookup' method") + if((ret_value = (uid_info->vol_plugin->object_cls.lookup)(uid_info->obj_id, lookup_type, + location, argc, argv)) < 0) + HGOTO_ERROR(H5E_VOL, H5E_CANTGET, FAIL, "lookup of object location failed") + +done: + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5VL_object_lookup() */ + + +/*------------------------------------------------------------------------- + * Function: H5VL_object_get + * + * Purpose: Get specific information about the object through the VOL + * + * Return: Success: non negative + * + * Failure: negative + * + * Programmer: Mohamad Chaarawi + * February, 2012 + * + *------------------------------------------------------------------------- + */ +herr_t +H5VL_object_get(hid_t uid, H5VL_object_get_t get_type, void *data, int argc, void **argv) +{ + H5I_t *uid_info; /* user id structure */ + herr_t ret_value = SUCCEED; + + FUNC_ENTER_NOAPI(FAIL) + + /* Check id */ + if(H5I_GROUP_PUBLIC != H5I_get_type(uid) && H5I_DATASET_PUBLIC != H5I_get_type(uid) && + H5I_DATATYPE_PUBLIC != H5I_get_type(uid) && H5I_FILE_PUBLIC != H5I_get_type(uid)) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a user ID") + + /* get the ID struct */ + if(NULL == (uid_info = (H5I_t *)H5I_object(uid))) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "invalid user identifier") + + if(NULL == uid_info->vol_plugin->object_cls.get) + HGOTO_ERROR(H5E_VOL, H5E_UNSUPPORTED, FAIL, "vol plugin has no `object get' method") + if((ret_value = (uid_info->vol_plugin->object_cls.get)(uid_info->obj_id, get_type, + data, argc, argv)) < 0) + HGOTO_ERROR(H5E_VOL, H5E_CANTGET, FAIL, "get failed") + +done: + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5VL_object_get() */ + + +/*------------------------------------------------------------------------- + * Function: H5VL_datatype_commit + * + * Purpose: Commits a datatype to the file through the VOL + * + * Return: Success: Positive + * + * Failure: Negative + * + * Programmer: Mohamad Chaarawi + * March, 2012 + * + *------------------------------------------------------------------------- + */ +herr_t +H5VL_datatype_commit(hid_t uid, const char *name, hid_t type_id, hid_t lcpl_id, + hid_t tcpl_id, hid_t tapl_id) +{ + H5I_t *uid_info1; /* user id structure of the location where the datatype will be commitd */ + herr_t ret_value = SUCCEED; /* Return value */ + + FUNC_ENTER_NOAPI(FAIL) + + /* get the ID struct */ + if(NULL == (uid_info1 = (H5I_t *)H5I_object(uid))) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "invalid user identifier") + + /* check if the corresponding VOL commit callback exists */ + if(NULL == uid_info1->vol_plugin->datatype_cls.commit) + HGOTO_ERROR(H5E_VOL, H5E_UNSUPPORTED, FAIL, "vol plugin has no `datatype commit' method") + + /* call the corresponding VOL commit callback */ + if((ret_value = (uid_info1->vol_plugin->datatype_cls.commit) + (uid_info1->obj_id, name, type_id, lcpl_id, tcpl_id, tapl_id)) < 0) + HGOTO_ERROR(H5E_VOL, H5E_CANTINIT, FAIL, "commit failed") + +#if 0 + /* Create a new id that points to a struct that holds the datatype id and the VOL id */ + /* Allocate new id structure */ + if(NULL == (uid_info2 = H5FL_MALLOC(H5I_t))) + HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, FAIL, "memory allocation failed") + uid_info2->obj_id = type_id; + uid_info2->vol_plugin = uid_info1->vol_plugin; + + if((ret_value = H5I_register(H5I_DATATYPE_PUBLIC, uid_info2, TRUE)) < 0) + HGOTO_ERROR(H5E_ATOM, H5E_CANTREGISTER, FAIL, "unable to atomize datatype handle") #endif + +done: + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5VL_datatype_commit() */ + + +/*------------------------------------------------------------------------- + * Function: H5VL_datatype_open + * + * Purpose: Opens a named datatype through the VOL + * + * Return: Success: User ID of the datatype. This ID is of type + * H5I_DATATYPE_PUBLIC which contains the VOL id and the actual datatype ID + * + * Failure: FAIL + * + * Programmer: Mohamad Chaarawi + * March, 2012 + * + *------------------------------------------------------------------------- + */ +hid_t +H5VL_datatype_open(hid_t uid, const char *name, hid_t tapl_id) +{ + H5I_t *uid_info1; /* user id structure of the location where the datatype will be opend */ + H5I_t *uid_info2; /* user id structure of new opend datatype*/ + hid_t datatype_id; /* actual datatype ID */ + hid_t ret_value; /* Return value */ + + FUNC_ENTER_NOAPI(FAIL) + + /* get the ID struct */ + if(NULL == (uid_info1 = (H5I_t *)H5I_object(uid))) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "invalid user identifier") + + /* check if the corresponding VOL open callback exists */ + if(NULL == uid_info1->vol_plugin->datatype_cls.open) + HGOTO_ERROR(H5E_VOL, H5E_UNSUPPORTED, FAIL, "vol plugin has no `datatype open' method") + + /* call the corresponding VOL open callback */ + if((datatype_id = (uid_info1->vol_plugin->datatype_cls.open) + (uid_info1->obj_id, name, tapl_id)) < 0) + HGOTO_ERROR(H5E_VOL, H5E_CANTINIT, FAIL, "open failed") + + /* Create a new id that points to a struct that holds the datatype id and the VOL id */ + /* Allocate new id structure */ + if(NULL == (uid_info2 = H5FL_MALLOC(H5I_t))) + HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, FAIL, "memory allocation failed") + uid_info2->obj_id = datatype_id; + uid_info2->vol_plugin = uid_info1->vol_plugin; + + if((ret_value = H5I_register(H5I_DATATYPE_PUBLIC, uid_info2, TRUE)) < 0) + HGOTO_ERROR(H5E_ATOM, H5E_CANTREGISTER, FAIL, "unable to atomize datatype handle") + +done: + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5VL_datatype_open() */ + + +/*------------------------------------------------------------------------- + * Function: H5VL_dataset_create + * + * Purpose: Creates a dataset through the VOL + * + * Return: Success: User ID of the new dataset. This ID is of type + * H5I_DATASET_PUBLIC which contains the VOL id and the actual dataset ID + * + * Failure: FAIL + * + * Programmer: Mohamad Chaarawi + * March, 2012 + * + *------------------------------------------------------------------------- + */ +hid_t +H5VL_dataset_create(hid_t uid, const char *name, hid_t dtype_id, hid_t space_id, + hid_t lcpl_id, hid_t dcpl_id, hid_t dapl_id) +{ + H5I_t *uid_info1; /* user id structure of the location where the dataset will be created */ + H5I_t *uid_info2; /* user id structure of new created dataset*/ + hid_t dataset_id; /* actual dataset ID */ + hid_t ret_value; /* Return value */ + + FUNC_ENTER_NOAPI(FAIL) + + /* get the ID struct */ + if(NULL == (uid_info1 = (H5I_t *)H5I_object(uid))) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "invalid user identifier") + + /* check if the corresponding VOL create callback exists */ + if(NULL == uid_info1->vol_plugin->dataset_cls.create) + HGOTO_ERROR(H5E_VOL, H5E_UNSUPPORTED, FAIL, "vol plugin has no `dataset create' method") + + /* call the corresponding VOL create callback */ + if((dataset_id = (uid_info1->vol_plugin->dataset_cls.create) + (uid_info1->obj_id, name, dtype_id, space_id, lcpl_id, dcpl_id, dapl_id)) < 0) + HGOTO_ERROR(H5E_VOL, H5E_CANTINIT, FAIL, "create failed") + + /* Create a new id that points to a struct that holds the dataset id and the VOL id */ + /* Allocate new id structure */ + if(NULL == (uid_info2 = H5FL_MALLOC(H5I_t))) + HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, FAIL, "memory allocation failed") + uid_info2->obj_id = dataset_id; + uid_info2->vol_plugin = uid_info1->vol_plugin; + + if((ret_value = H5I_register(H5I_DATASET_PUBLIC, uid_info2, TRUE)) < 0) + HGOTO_ERROR(H5E_ATOM, H5E_CANTREGISTER, FAIL, "unable to atomize dataset handle") + +done: + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5VL_dataset_create() */ + + +/*------------------------------------------------------------------------- + * Function: H5VL_dataset_open + * + * Purpose: Opens a dataset through the VOL + * + * Return: Success: User ID of the new dataset. This ID is of type + * H5I_DATASET_PUBLIC which contains the VOL id and the actual dataset ID + * + * Failure: FAIL + * + * Programmer: Mohamad Chaarawi + * March, 2012 + * + *------------------------------------------------------------------------- + */ +hid_t +H5VL_dataset_open(hid_t uid, const char *name, hid_t dapl_id) +{ + H5I_t *uid_info1; /* user id structure of the location where the dataset will be opend */ + H5I_t *uid_info2; /* user id structure of new opend dataset*/ + hid_t dataset_id; /* actual dataset ID */ + hid_t ret_value; /* Return value */ + + FUNC_ENTER_NOAPI(FAIL) + + /* get the ID struct */ + if(NULL == (uid_info1 = (H5I_t *)H5I_object(uid))) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "invalid user identifier") + + /* check if the corresponding VOL open callback exists */ + if(NULL == uid_info1->vol_plugin->dataset_cls.open) + HGOTO_ERROR(H5E_VOL, H5E_UNSUPPORTED, FAIL, "vol plugin has no `dataset open' method") + /* call the corresponding VOL open callback */ + if((dataset_id = (uid_info1->vol_plugin->dataset_cls.open) + (uid_info1->obj_id, name, dapl_id)) < 0) + HGOTO_ERROR(H5E_VOL, H5E_CANTINIT, FAIL, "open failed") + + /* Create a new id that points to a struct that holds the dataset id and the VOL id */ + /* Allocate new id structure */ + if(NULL == (uid_info2 = H5FL_MALLOC(H5I_t))) + HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, FAIL, "memory allocation failed") + uid_info2->obj_id = dataset_id; + uid_info2->vol_plugin = uid_info1->vol_plugin; + + if((ret_value = H5I_register(H5I_DATASET_PUBLIC, uid_info2, TRUE)) < 0) + HGOTO_ERROR(H5E_ATOM, H5E_CANTREGISTER, FAIL, "unable to atomize dataset handle") + +done: + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5VL_dataset_open() */ + + +/*------------------------------------------------------------------------- + * Function: H5VL_dataset_close + * + * Purpose: Closes a dataset through the VOL + * + * Return: Success: Non Negative + * + * Failure: Negative + * + * Programmer: Mohamad Chaarawi + * March, 2012 + * + *------------------------------------------------------------------------- + */ +herr_t +H5VL_dataset_close(hid_t uid) +{ + H5I_t *uid_info; /* user id structure */ + herr_t ret_value = SUCCEED; + + FUNC_ENTER_NOAPI(FAIL) + + /* Check/fix arguments. */ + if(H5I_DATASET_PUBLIC != H5I_get_type(uid)) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a user ID") + + /* get the ID struct */ + if(NULL == (uid_info = (H5I_t *)H5I_object(uid))) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "invalid user identifier") + + if(NULL == uid_info->vol_plugin->dataset_cls.close) + HGOTO_ERROR(H5E_VOL, H5E_UNSUPPORTED, FAIL, "vol plugin has no `dataset close' method") + if((ret_value = (uid_info->vol_plugin->dataset_cls.close)(uid_info->obj_id)) < 0) + HGOTO_ERROR(H5E_VOL, H5E_CANTRELEASE, FAIL, "close failed") + + if(H5I_dec_app_ref(uid) < 0) + HGOTO_ERROR(H5E_VOL, H5E_CANTDEC, FAIL, "unable to decrement ref count on user ID") + +done: + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5VL_dataset_close() */ + + +/*------------------------------------------------------------------------- + * Function: H5VL_dataset_read + * + * Purpose: Reads data from dataset through the VOL + * + * Return: Success: Non Negative + * + * Failure: Negative + * + * Programmer: Mohamad Chaarawi + * March, 2012 + * + *------------------------------------------------------------------------- + */ +herr_t H5VL_dataset_read(hid_t uid, hid_t mem_type_id, hid_t mem_space_id, + hid_t file_space_id, hid_t plist_id, void *buf) +{ + H5I_t *uid_info; /* user id structure */ + herr_t ret_value = SUCCEED; + + FUNC_ENTER_NOAPI(FAIL) + + /* Check/fix arguments. */ + if(H5I_DATASET_PUBLIC != H5I_get_type(uid)) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a user ID") + + /* get the ID struct */ + if(NULL == (uid_info = (H5I_t *)H5I_object(uid))) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "invalid user identifier") + + if(NULL == uid_info->vol_plugin->dataset_cls.read) + HGOTO_ERROR(H5E_VOL, H5E_UNSUPPORTED, FAIL, "vol plugin has no `dataset read' method") + if((ret_value = (uid_info->vol_plugin->dataset_cls.read) + (uid_info->obj_id, mem_type_id, mem_space_id, file_space_id, plist_id, buf)) < 0) + HGOTO_ERROR(H5E_VOL, H5E_CANTRELEASE, FAIL, "read failed") + +done: + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5VL_dataset_read() */ + + +/*------------------------------------------------------------------------- + * Function: H5VL_dataset_write + * + * Purpose: Writes data from dataset through the VOL + * + * Return: Success: Non Negative + * + * Failure: Negative + * + * Programmer: Mohamad Chaarawi + * March, 2012 + * + *------------------------------------------------------------------------- + */ +herr_t H5VL_dataset_write(hid_t uid, hid_t mem_type_id, hid_t mem_space_id, + hid_t file_space_id, hid_t plist_id, const void *buf) +{ + H5I_t *uid_info; /* user id structure */ + herr_t ret_value = SUCCEED; + + FUNC_ENTER_NOAPI(FAIL) + + /* Check/fix arguments. */ + if(H5I_DATASET_PUBLIC != H5I_get_type(uid)) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a user ID") + + /* get the ID struct */ + if(NULL == (uid_info = (H5I_t *)H5I_object(uid))) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "invalid user identifier") + + if(NULL == uid_info->vol_plugin->dataset_cls.write) + HGOTO_ERROR(H5E_VOL, H5E_UNSUPPORTED, FAIL, "vol plugin has no `dataset write' method") + if((ret_value = (uid_info->vol_plugin->dataset_cls.write) + (uid_info->obj_id, mem_type_id, mem_space_id, file_space_id, plist_id, buf)) < 0) + HGOTO_ERROR(H5E_VOL, H5E_CANTRELEASE, FAIL, "write failed") + +done: + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5VL_dataset_write() */ diff --git a/src/H5VLdummy.c b/src/H5VLdummy.c index bddf87c..b4fcfae 100644 --- a/src/H5VLdummy.c +++ b/src/H5VLdummy.c @@ -81,7 +81,8 @@ static const H5VL_class_t H5VL_dummy_g = { NULL /* write */ }, { /* datatype_cls */ - NULL /* open */ + NULL, /* commit */ + NULL /* open */ }, { /* link_cls */ NULL, /* create */ @@ -94,7 +95,9 @@ static const H5VL_class_t H5VL_dummy_g = { NULL, /* open */ NULL, /* close */ NULL, /* move */ - NULL /* copy */ + NULL, /* copy */ + NULL, /* lookup */ + NULL /* get */ } }; diff --git a/src/H5VLnative.c b/src/H5VLnative.c index e3b998a..ae5ec4e 100644 --- a/src/H5VLnative.c +++ b/src/H5VLnative.c @@ -21,34 +21,74 @@ * using HDF5 VFDs. */ +#define H5D_PACKAGE /*suppress error about including H5Dpkg */ #define H5F_PACKAGE /*suppress error about including H5Fpkg */ +#define H5G_PACKAGE /*suppress error about including H5Gpkg */ +#define H5O_PACKAGE /*suppress error about including H5Opkg */ +#define H5T_PACKAGE /*suppress error about including H5Tpkg */ /* Interface initialization */ #define H5_INTERFACE_INIT_FUNC H5VL_native_init_interface #include "H5private.h" /* Generic Functions */ +#include "H5Aprivate.h" /* Attributes */ +#include "H5Dpkg.h" /* Dataset pkg */ +#include "H5Dprivate.h" /* Datasets */ #include "H5Eprivate.h" /* Error handling */ #include "H5Fprivate.h" /* File access */ #include "H5Fpkg.h" /* File pkg */ -#include "H5VLprivate.h" /* VOL plugins */ -#include "H5VLnative.h" /* Native VOL plugin */ +#include "H5Gpkg.h" /* Groups */ #include "H5Iprivate.h" /* IDs */ +#include "H5MFprivate.h" /* File memory management */ #include "H5MMprivate.h" /* Memory management */ +#include "H5Opkg.h" /* Object headers */ #include "H5Pprivate.h" /* Property lists */ -#include "H5Dprivate.h" /* Datasets */ -#include "H5Aprivate.h" /* Attributes */ -#include "H5MFprivate.h" /* File memory management */ #include "H5SMprivate.h" /* Shared Object Header Messages */ +#include "H5Tpkg.h" /* Datatypes */ +#include "H5VLprivate.h" /* VOL plugins */ +#include "H5VLnative.h" /* Native VOL plugin */ /* The driver identification number, initialized at runtime */ static hid_t H5VL_NATIVE_g = 0; /* Prototypes */ -static herr_t H5VL_native_get(hid_t file_id, H5VL_file_get_t get_type, - void *data, int argc, void **argv); static herr_t H5VL_native_term(void); +static hid_t H5VL_native_file_open(const char *name, unsigned flags, hid_t fcpl_id, + hid_t fapl_id, hid_t dxpl_id); +static herr_t H5VL_native_file_close(hid_t fid); +static hid_t H5VL_native_file_create(const char *name, unsigned flags, hid_t fcpl_id, hid_t fapl_id); +static herr_t H5VL_native_file_flush(hid_t fid, H5F_scope_t scope); +static herr_t H5VL_native_file_get(hid_t file_id, H5VL_file_get_t get_type, + void *data, int argc, void **argv); + +static hid_t H5VL_native_dataset_create(hid_t loc_id, const char *name, hid_t type_id, hid_t space_id, + hid_t lcpl_id, hid_t dcpl_id, hid_t dapl_id); +static hid_t H5VL_native_dataset_open(hid_t loc_id, const char *name, hid_t dapl_id); +static herr_t H5VL_native_dataset_close(hid_t dataset_id); +static herr_t H5VL_native_dataset_read(hid_t dset_id, hid_t mem_type_id, hid_t mem_space_id, + hid_t file_space_id, hid_t plist_id, void *buf); +static herr_t H5VL_native_dataset_write(hid_t dset_id, hid_t mem_type_id, hid_t mem_space_id, + hid_t file_space_id, hid_t plist_id, const void *buf); + +static herr_t H5VL_native_datatype_commit(hid_t loc_id, const char *name, hid_t type_id, + hid_t lcpl_id, hid_t tcpl_id, hid_t tapl_id); +static hid_t H5VL_native_datatype_open(hid_t loc_id, const char *name, hid_t tapl_id); + +static hid_t H5VL_native_group_create(hid_t loc_id, const char *name, hid_t lcpl_id, + hid_t gcpl_id, hid_t gapl_id); +static hid_t H5VL_native_group_open(hid_t loc_id, const char *name, hid_t gapl_id); +static herr_t H5VL_native_group_close(hid_t group_id); +static herr_t H5VL_native_group_get(hid_t file_id, H5VL_group_get_t get_type, + void *data, int argc, void **argv); + +static hid_t H5VL_native_object_open(hid_t loc_id, void *location, hid_t lapl_id); +static herr_t H5VL_native_object_close(hid_t object_id); +static herr_t H5VL_native_object_get(hid_t id, H5VL_object_get_t get_type, void *data, + int argc, void **argv); +static herr_t H5VL_native_object_lookup(hid_t loc_id, H5VL_object_lookup_t lookup_type, + void **location, int argc, void **argv); static const H5VL_class_t H5VL_native_g = { "native", /* name */ @@ -57,21 +97,6 @@ static const H5VL_class_t H5VL_native_g = { NULL, /*fapl_get */ NULL, /*fapl_copy */ NULL, /*fapl_free */ - { /* file_cls */ - H5VL_native_open, /* open */ - H5VL_native_close, /* close */ - H5VL_native_create, /* create */ - H5VL_native_flush, /* flush */ - H5VL_native_get /* get */ - }, - { /* dataset_cls */ - NULL, /* open */ - NULL, /* close */ - NULL, /* create */ - NULL, /* read */ - NULL, /* write */ - NULL /* set_extent */ - }, { /* attribute_cls */ NULL, /* open */ NULL, /* close */ @@ -81,7 +106,29 @@ static const H5VL_class_t H5VL_native_g = { NULL /* write */ }, { /* datatype_cls */ - NULL /* open */ + H5VL_native_datatype_commit, /* commit */ + H5VL_native_datatype_open /* open */ + }, + { /* dataset_cls */ + H5VL_native_dataset_open, /* open */ + H5VL_native_dataset_close, /* close */ + H5VL_native_dataset_create, /* create */ + H5VL_native_dataset_read, /* read */ + H5VL_native_dataset_write, /* write */ + NULL /* set_extent */ + }, + { /* group_cls */ + H5VL_native_group_create, /* create */ + H5VL_native_group_open, /* open */ + H5VL_native_group_close, /* close */ + H5VL_native_group_get /* get */ + }, + { /* file_cls */ + H5VL_native_file_open, /* open */ + H5VL_native_file_close, /* close */ + H5VL_native_file_create, /* create */ + H5VL_native_file_flush, /* flush */ + H5VL_native_file_get /* get */ }, { /* link_cls */ NULL, /* create */ @@ -90,11 +137,12 @@ static const H5VL_class_t H5VL_native_g = { NULL /* copy */ }, { /* object_cls */ - NULL, /* create */ - NULL, /* open */ - NULL, /* close */ + H5VL_native_object_open, /* open */ + H5VL_native_object_close, /* close */ NULL, /* move */ - NULL /* copy */ + NULL, /* copy */ + H5VL_native_object_lookup, /* lookup */ + H5VL_native_object_get /* get */ } }; @@ -210,11 +258,11 @@ done: /*------------------------------------------------------------------------- - * Function: H5VL_native_open + * Function: H5VL_native_file_open * * Purpose: Opens a file as a native HDF5 file. * - * Return: Success: A pointer to a new file data structure. + * Return: Success: file id. * Failure: NULL * * Programmer: Mohamad Chaarawi @@ -222,8 +270,8 @@ done: * *------------------------------------------------------------------------- */ -hid_t -H5VL_native_open(const char *name, unsigned flags, hid_t fcpl_id, +static hid_t +H5VL_native_file_open(const char *name, unsigned flags, hid_t fcpl_id, hid_t fapl_id, hid_t dxpl_id) { H5F_t *new_file; /* file struct */ @@ -253,15 +301,15 @@ done: HDONE_ERROR(H5E_FILE, H5E_CANTCLOSEFILE, FAIL, "problems closing file") FUNC_LEAVE_NOAPI(ret_value) -} /* end H5VL_native_open() */ +} /* end H5VL_native_file_open() */ /*------------------------------------------------------------------------- - * Function: H5VL_native_create + * Function: H5VL_native_file_create * * Purpose: Creates a file as a native HDF5 file. * - * Return: Success: A pointer to a new file data structure. + * Return: Success: the file id. * Failure: NULL * * Programmer: Mohamad Chaarawi @@ -269,8 +317,8 @@ done: * *------------------------------------------------------------------------- */ -hid_t -H5VL_native_create(const char *name, unsigned flags, hid_t fcpl_id, hid_t fapl_id) +static hid_t +H5VL_native_file_create(const char *name, unsigned flags, hid_t fcpl_id, hid_t fapl_id) { H5F_t *new_file; /* file struct */ hid_t ret_value; @@ -302,11 +350,11 @@ done: HDONE_ERROR(H5E_FILE, H5E_CANTCLOSEFILE, FAIL, "problems closing file") FUNC_LEAVE_NOAPI(ret_value) -} /* end H5VL_native_create() */ +} /* end H5VL_native_file_create() */ /*------------------------------------------------------------------------- - * Function: H5VL_native_close + * Function: H5VL_native_file_close * * Purpose: Closes a file. * @@ -318,8 +366,8 @@ done: * *------------------------------------------------------------------------- */ -herr_t -H5VL_native_close(hid_t file_id) +static herr_t +H5VL_native_file_close(hid_t file_id) { int nref; H5F_t *f; @@ -356,11 +404,11 @@ H5VL_native_close(hid_t file_id) done: FUNC_LEAVE_NOAPI(ret_value) -} /* end H5VL_native_close() */ +} /* end H5VL_native_file_close() */ /*------------------------------------------------------------------------- - * Function: H5VL_native_flush + * Function: H5VL_native_file_flush * * Purpose: Flushs a native HDF5 file. * @@ -372,8 +420,8 @@ done: * *------------------------------------------------------------------------- */ -herr_t -H5VL_native_flush(hid_t object_id, H5F_scope_t scope) +static herr_t +H5VL_native_file_flush(hid_t object_id, H5F_scope_t scope) { H5F_t *f = NULL; /* File to flush */ H5O_loc_t *oloc = NULL; /* Object location for ID */ @@ -433,7 +481,6 @@ H5VL_native_flush(hid_t object_id, H5F_scope_t scope) case H5I_REFERENCE: case H5I_VFL: case H5I_VOL: - case H5I_UID: case H5I_GENPROP_CLS: case H5I_GENPROP_LST: case H5I_ERROR_CLASS: @@ -476,11 +523,11 @@ H5VL_native_flush(hid_t object_id, H5F_scope_t scope) done: FUNC_LEAVE_NOAPI(ret_value) -} /* end H5VL_native_flush() */ +} /* end H5VL_native_file_flush() */ /*------------------------------------------------------------------------- - * Function: H5VL_native_get + * Function: H5VL_native_file_get * * Purpose: Gets certain data about a file * @@ -493,7 +540,7 @@ done: *------------------------------------------------------------------------- */ static herr_t -H5VL_native_get(hid_t obj_id, H5VL_file_get_t get_type, void *data, int argc, void **argv) +H5VL_native_file_get(hid_t obj_id, H5VL_file_get_t get_type, void *data, int argc, void **argv) { H5F_t *f = NULL; /* File struct */ herr_t ret_value = SUCCEED; /* Return value */ @@ -623,7 +670,7 @@ H5VL_native_get(hid_t obj_id, H5VL_file_get_t get_type, void *data, int argc, vo case H5F_GET_NAME: { size_t len, size = *((size_t *)argv[1]); - ssize_t ret = *((ssize_t *)argv[1]); + ssize_t ret; char *name = (char *)data; len = HDstrlen(H5F_OPEN_NAME(f)); @@ -636,6 +683,8 @@ H5VL_native_get(hid_t obj_id, H5VL_file_get_t get_type, void *data, int argc, vo /* Set the return value for the API call */ ret = (ssize_t)len; + memcpy (argv[0], &ret, sizeof(ssize_t)); + break; } /* H5Fget_vfd_handle */ @@ -684,4 +733,990 @@ H5VL_native_get(hid_t obj_id, H5VL_file_get_t get_type, void *data, int argc, vo } done: FUNC_LEAVE_NOAPI(ret_value) +} /* end H5VL_native_file_get() */ + + +/*------------------------------------------------------------------------- + * Function: H5VL_native_group_create + * + * Purpose: Creates a group inside a native h5 file. + * + * Return: Success: group id. + * Failure: NULL + * + * Programmer: Mohamad Chaarawi + * January, 2012 + * + *------------------------------------------------------------------------- + */ +static hid_t +H5VL_native_group_create(hid_t loc_id, const char *name, hid_t lcpl_id, hid_t gcpl_id, hid_t gapl_id) +{ + H5G_loc_t loc; /* Location to create group */ + H5G_t *grp = NULL; /* New group created */ + hid_t ret_value; + + FUNC_ENTER_NOAPI_NOINIT + + if(H5G_loc(loc_id, &loc) < 0) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a location") + + /* 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, H5AC_dxpl_id))) + HGOTO_ERROR(H5E_SYM, H5E_CANTINIT, FAIL, "unable to create group") + } + /* otherwise it's from H5Gcreate */ + else { + /* Create the new group & get its ID */ + if(NULL == (grp = H5G__create_named(&loc, name, lcpl_id, gcpl_id, gapl_id, H5AC_dxpl_id))) + HGOTO_ERROR(H5E_SYM, H5E_CANTINIT, FAIL, "unable to create group") + } + + if((ret_value = H5I_register(H5I_GROUP, grp, TRUE)) < 0) + HGOTO_ERROR(H5E_ATOM, H5E_CANTREGISTER, FAIL, "unable to register group") + +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, FAIL, "unable to get object location of group") + + /* Decrement refcount on group's object header in memory */ + if(H5O_dec_rc_by_loc(oloc, H5AC_dxpl_id) < 0) + HDONE_ERROR(H5E_SYM, H5E_CANTDEC, FAIL, "unable to decrement refcount on newly created object") + } /* end if */ + } + + if(ret_value < 0) + if(grp && H5G_close(grp) < 0) + HDONE_ERROR(H5E_SYM, H5E_CLOSEERROR, FAIL, "unable to release group") + + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5VL_native_group_create() */ + + +/*------------------------------------------------------------------------- + * Function: H5VL_native_group_open + * + * Purpose: Opens a group inside a native h5 file. + * + * Return: Success: group id. + * Failure: NULL + * + * Programmer: Mohamad Chaarawi + * January, 2012 + * + *------------------------------------------------------------------------- + */ +static hid_t +H5VL_native_group_open(hid_t loc_id, const char *name, hid_t gapl_id) +{ + H5G_loc_t loc; /* Location to open group */ + H5G_t *grp = NULL; /* New group opend */ + hid_t ret_value; + + FUNC_ENTER_NOAPI_NOINIT + + if(H5G_loc(loc_id, &loc) < 0) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a location") + + /* Open the group */ + if((grp = H5G__open_name(&loc, name, gapl_id, H5AC_dxpl_id)) == NULL) + HGOTO_ERROR(H5E_SYM, H5E_CANTOPENOBJ, FAIL, "unable to open group") + + /* Register an ID for the group */ + if((ret_value = H5I_register(H5I_GROUP, grp, TRUE)) < 0) + HGOTO_ERROR(H5E_ATOM, H5E_CANTREGISTER, FAIL, "unable to register group") + +done: + if(ret_value < 0) + if(grp && H5G_close(grp) < 0) + HDONE_ERROR(H5E_SYM, H5E_CLOSEERROR, FAIL, "unable to release group") + + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5VL_native_group_open() */ + + +/*------------------------------------------------------------------------- + * Function: H5VL_native_group_close + * + * Purpose: Closes a group. + * + * Return: Success: 0 + * Failure: -1, group not closed. + * + * Programmer: Mohamad Chaarawi + * March, 2012 + * + *------------------------------------------------------------------------- + */ +static herr_t +H5VL_native_group_close(hid_t group_id) +{ + herr_t ret_value = SUCCEED; /* Return value */ + + FUNC_ENTER_NOAPI_NOINIT + + /* Check args */ + if(NULL == H5I_object_verify(group_id,H5I_GROUP)) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a group") + + /* + * Decrement the counter on the group atom. It will be freed if the count + * reaches zero. + */ + if(H5I_dec_app_ref(group_id) < 0) + HGOTO_ERROR(H5E_SYM, H5E_CANTRELEASE, FAIL, "unable to close group") + +done: + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5VL_native_group_close() */ + + +/*------------------------------------------------------------------------- + * Function: H5VL_native_group_get + * + * Purpose: Gets certain data about a file + * + * Return: Success: 0 + * Failure: -1 + * + * Programmer: Mohamad Chaarawi + * February, 2012 + * + *------------------------------------------------------------------------- + */ +static herr_t +H5VL_native_group_get(hid_t obj_id, H5VL_group_get_t get_type, void *data, int argc, void **argv) +{ + herr_t ret_value = SUCCEED; /* Return value */ + hid_t new_gcpl_id = FAIL; + FUNC_ENTER_NOAPI_NOINIT + + switch (get_type) { + /* H5Gget_create_plist */ + case H5G_GET_GCPL: + { + H5O_linfo_t linfo; /* Link info message */ + htri_t ginfo_exists; + htri_t linfo_exists; + htri_t pline_exists; + H5G_t *grp = NULL; + H5P_genplist_t *gcpl_plist; + H5P_genplist_t *new_plist; + + /* Check args */ + if(NULL == (grp = (H5G_t *)H5I_object_verify(obj_id, H5I_GROUP))) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a group") + + /* Copy the default group creation property list */ + if(NULL == (gcpl_plist = (H5P_genplist_t *)H5I_object(H5P_LST_GROUP_CREATE_g))) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "can't get default group creation property list") + if((new_gcpl_id = H5P_copy_plist(gcpl_plist, TRUE)) < 0) + HGOTO_ERROR(H5E_SYM, H5E_CANTGET, FAIL, "unable to copy the creation property list") + if(NULL == (new_plist = (H5P_genplist_t *)H5I_object(new_gcpl_id))) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "can't get property list") + + /* Retrieve any object creation properties */ + if(H5O_get_create_plist(&grp->oloc, H5AC_ind_dxpl_id, new_plist) < 0) + HGOTO_ERROR(H5E_SYM, H5E_CANTGET, FAIL, "can't get object creation info") + + /* Check for the group having a group info message */ + if((ginfo_exists = H5O_msg_exists(&(grp->oloc), H5O_GINFO_ID, H5AC_ind_dxpl_id)) < 0) + HGOTO_ERROR(H5E_SYM, H5E_CANTINIT, FAIL, "unable to read object header") + if(ginfo_exists) { + H5O_ginfo_t ginfo; /* Group info message */ + + /* Read the group info */ + if(NULL == H5O_msg_read(&(grp->oloc), H5O_GINFO_ID, &ginfo, H5AC_ind_dxpl_id)) + HGOTO_ERROR(H5E_SYM, H5E_BADMESG, FAIL, "can't get group info") + + /* Set the group info for the property list */ + if(H5P_set(new_plist, H5G_CRT_GROUP_INFO_NAME, &ginfo) < 0) + HGOTO_ERROR(H5E_PLIST, H5E_CANTSET, FAIL, "can't set group info") + } /* end if */ + + /* Check for the group having a link info message */ + if((linfo_exists = H5G__obj_get_linfo(&(grp->oloc), &linfo, H5AC_ind_dxpl_id)) < 0) + HGOTO_ERROR(H5E_SYM, H5E_CANTINIT, FAIL, "unable to read object header") + if(linfo_exists) { + /* Set the link info for the property list */ + if(H5P_set(new_plist, H5G_CRT_LINK_INFO_NAME, &linfo) < 0) + HGOTO_ERROR(H5E_PLIST, H5E_CANTSET, FAIL, "can't set link info") + } /* end if */ + + /* Check for the group having a pipeline message */ + if((pline_exists = H5O_msg_exists(&(grp->oloc), H5O_PLINE_ID, H5AC_ind_dxpl_id)) < 0) + HGOTO_ERROR(H5E_SYM, H5E_CANTGET, FAIL, "unable to read object header") + if(pline_exists) { + H5O_pline_t pline; /* Pipeline message */ + + /* Read the pipeline */ + if(NULL == H5O_msg_read(&(grp->oloc), H5O_PLINE_ID, &pline, H5AC_ind_dxpl_id)) + HGOTO_ERROR(H5E_SYM, H5E_BADMESG, FAIL, "can't get link pipeline") + + /* Set the pipeline for the property list */ + if(H5P_set(new_plist, H5O_CRT_PIPELINE_NAME, &pline) < 0) + HGOTO_ERROR(H5E_PLIST, H5E_CANTSET, FAIL, "can't set link pipeline") + } /* end if */ + + /* Set the return value */ + *((hid_t *)data) = new_gcpl_id; + break; + } + /* H5Fget_info2 */ + case H5G_GET_INFO: + { + H5I_type_t id_type; /* Type of ID */ + H5G_loc_t loc; /* Location of group */ + H5G_info_t *grp_info = (H5G_info_t *)data; + + /* Check args */ + id_type = H5I_get_type(obj_id); + if(!(H5I_GROUP == id_type || H5I_FILE == id_type)) + HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "invalid argument") + if(!grp_info) + HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "no info struct") + + /* Get group location */ + if(H5G_loc(obj_id, &loc) < 0) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a location") + + /* Retrieve the group's information */ + if(H5G__obj_info(loc.oloc, grp_info/*out*/, H5AC_ind_dxpl_id) < 0) + HGOTO_ERROR(H5E_SYM, H5E_CANTGET, FAIL, "can't retrieve group info") + break; + } + default: + HGOTO_ERROR(H5E_VOL, H5E_CANTGET, FAIL, "can't get this type of information from group") + } +done: + if (H5G_GET_GCPL == get_type) { + if(*((hid_t *)data) < 0) { + if(new_gcpl_id > 0) + if(H5I_dec_app_ref(new_gcpl_id) < 0) + HDONE_ERROR(H5E_SYM, H5E_CANTDEC, FAIL, "can't free") + } /* end if */ + } + FUNC_LEAVE_NOAPI(ret_value) } + + +/*------------------------------------------------------------------------- + * Function: H5VL_native_object_open + * + * Purpose: Opens a object inside a native h5 file. + * + * Return: Success: object id. + * Failure: NULL + * + * Programmer: Mohamad Chaarawi + * January, 2012 + * + *------------------------------------------------------------------------- + */ +static hid_t +H5VL_native_object_open(hid_t loc_id, void *location, hid_t lapl_id) +{ + hid_t ret_value = FAIL; + + FUNC_ENTER_NOAPI_NOINIT + + //obj_loc = (H5G_loc_t *)(*location); + /* Open the object */ + if((ret_value = H5O_open_by_loc((H5G_loc_t *)location, lapl_id, H5AC_dxpl_id, TRUE)) < 0) + HGOTO_ERROR(H5E_SYM, H5E_CANTOPENOBJ, FAIL, "unable to open object") +done: + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5VL_native_object_open() */ + + +/*------------------------------------------------------------------------- + * Function: H5VL_native_object_close + * + * Purpose: Closes a object. + * + * Return: Success: 0 + * Failure: -1, object not closed. + * + * Programmer: Mohamad Chaarawi + * March, 2012 + * + *------------------------------------------------------------------------- + */ +static herr_t +H5VL_native_object_close(hid_t object_id) +{ + herr_t ret_value = SUCCEED; /* Return value */ + + FUNC_ENTER_NOAPI_NOINIT + + /* Get the type of the object and close it in the correct way */ + switch(H5I_get_type(object_id)) { + case H5I_GROUP: + case H5I_DATATYPE: + case H5I_DATASET: + if(H5I_object(object_id) == NULL) + HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "not a valid object") + if(H5I_dec_app_ref(object_id) < 0) + HGOTO_ERROR(H5E_OHDR, H5E_CANTRELEASE, FAIL, "unable to close object") + break; + + case H5I_UNINIT: + case H5I_BADID: + case H5I_FILE: + case H5I_DATASPACE: + case H5I_ATTR: + case H5I_REFERENCE: + case H5I_VFL: + case H5I_VOL: + case H5I_GENPROP_CLS: + case H5I_GENPROP_LST: + case H5I_ERROR_CLASS: + case H5I_ERROR_MSG: + case H5I_ERROR_STACK: + case H5I_NTYPES: + default: + HGOTO_ERROR(H5E_ARGS, H5E_CANTRELEASE, FAIL, "not a valid file object ID (dataset, group, or datatype)") + break; + } /* end switch */ + +done: + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5VL_native_object_close() */ + + +/*------------------------------------------------------------------------- + * Function: H5VL_native_object_get + * + * Purpose: Gets certain data about a file + * + * Return: Success: 0 + * Failure: -1 + * + * Programmer: Mohamad Chaarawi + * February, 2012 + * + *------------------------------------------------------------------------- + */ +static herr_t +H5VL_native_object_get(hid_t id, H5VL_object_get_t get_type, void *data, int argc, void **argv) +{ + herr_t ret_value = SUCCEED; /* Return value */ + H5G_loc_t loc; /* Location of group */ + H5G_loc_t obj_loc; /* Location used to open group */ + hbool_t loc_found = FALSE; /* Entry at 'name' found */ + + FUNC_ENTER_NOAPI_NOINIT + + if(H5G_loc(id, &loc) < 0) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a location") + + switch (get_type) { + /* H5Oget_info / H5Oget_info_by_name / H5Oget_info_by_idx */ + case H5O_GET_INFO: + { + H5O_info_t *obj_info = (H5O_info_t *)data; + /* Retrieve the object's information */ + if(1 == argc) { + if(H5G_loc_info(&loc, ".", TRUE, obj_info/*out*/, H5P_LINK_ACCESS_DEFAULT, + H5AC_ind_dxpl_id) < 0) + HGOTO_ERROR(H5E_SYM, H5E_NOTFOUND, FAIL, "object not found") + } + else if(2 == argc) { + hid_t lapl_id = *((hid_t *)argv[0]); + char *name = (char *)argv[1]; + if(H5G_loc_info(&loc, name, TRUE, obj_info/*out*/, lapl_id, H5AC_ind_dxpl_id) < 0) + HGOTO_ERROR(H5E_SYM, H5E_NOTFOUND, FAIL, "object not found") + } + else if (5 == argc) { + H5G_name_t obj_path; /* Opened object group hier. path */ + H5O_loc_t obj_oloc; /* Opened object object location */ + char *group_name = (char *)argv[0]; + H5_index_t idx_type = *((H5_index_t *)argv[1]); + H5_iter_order_t order = *((H5_iter_order_t *)argv[2]); + hsize_t n = *((hsize_t *)argv[3]); + hid_t lapl_id = *((hid_t *)argv[4]); + + /* 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, group_name, idx_type, order, n, &obj_loc/*out*/, lapl_id, H5AC_ind_dxpl_id) < 0) + HGOTO_ERROR(H5E_SYM, H5E_NOTFOUND, FAIL, "group not found") + loc_found = TRUE; + + /* Retrieve the object's information */ + if(H5O_get_info(obj_loc.oloc, H5AC_ind_dxpl_id, TRUE, obj_info) < 0) + HGOTO_ERROR(H5E_SYM, H5E_CANTGET, FAIL, "can't retrieve object info") + } + break; + } + /* H5Oget_comment / H5Oget_comment_by_name */ + case H5O_GET_COMMENT: + { + size_t bufsize = *((size_t *)argv[1]); + ssize_t ret; + char *comment = (char *)data; + + if(2 == argc) { + /* Retrieve the object's comment */ + if((ret = H5G_loc_get_comment(&loc, ".", comment/*out*/, bufsize, + H5P_LINK_ACCESS_DEFAULT, H5AC_ind_dxpl_id)) < 0) + HGOTO_ERROR(H5E_SYM, H5E_NOTFOUND, FAIL, "object not found") + } + else if(4 == argc) { + char *name = (char *) argv[2]; + hid_t lapl_id = *((hid_t *)argv[3]); + + /* Retrieve the object's comment */ + if((ret = H5G_loc_get_comment(&loc, name, comment/*out*/, bufsize, lapl_id, H5AC_ind_dxpl_id)) < 0) + HGOTO_ERROR(H5E_SYM, H5E_NOTFOUND, FAIL, "object not found") + } + + memcpy (argv[0], &ret, sizeof(ssize_t)); + break; + } + default: + HGOTO_ERROR(H5E_VOL, H5E_CANTGET, FAIL, "can't get this type of information from object") + } +done: + /* Release the object location */ + if(loc_found && H5G_loc_free(&obj_loc) < 0) + HDONE_ERROR(H5E_SYM, H5E_CANTRELEASE, FAIL, "can't free location") + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5VL_native_object_get() */ + + +/*------------------------------------------------------------------------- + * Function: H5VL_native_object_lookup + * + * Purpose: Lookup the object location in the file + * + * Return: Success: 0 + * Failure: -1 + * + * Programmer: Mohamad Chaarawi + * March, 2012 + * + *------------------------------------------------------------------------- + */ +static herr_t +H5VL_native_object_lookup(hid_t loc_id, H5VL_object_lookup_t lookup_type, void **location, int argc, void **argv) +{ + H5G_loc_t loc; + H5G_loc_t *obj_loc; /* Location used to open group */ + hbool_t loc_found = FALSE; /* Entry at 'name' found */ + herr_t ret_value = SUCCEED; /* Return value */ + + FUNC_ENTER_NOAPI_NOINIT + + if(H5G_loc(loc_id, &loc) < 0) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a location") + + if (NULL == (*location = (H5G_loc_t *)malloc(sizeof(H5G_loc_t)))) + HGOTO_ERROR(H5E_SYM, H5E_CANTINIT, FAIL, "memory allocation failed for object location") + + obj_loc = (H5G_loc_t *)(*location); + + /* Set up opened group location to fill in */ + obj_loc->path = (H5G_name_t *)malloc(sizeof(H5G_name_t)); + obj_loc->oloc = (H5O_loc_t *)malloc(sizeof(H5O_loc_t)); + H5G_loc_reset(obj_loc); + + switch (lookup_type) { + case H5O_LOOKUP_BY_NAME: + { + char *name = (char *)argv[0]; + hid_t lapl_id = *((hid_t *)argv[1]); + + HDassert(&loc); + HDassert(name && *name); + + /* Find the object's location */ + if((ret_value = H5G_loc_find(&loc, name, obj_loc/*out*/, lapl_id, H5AC_dxpl_id)) < 0) + HGOTO_ERROR(H5E_SYM, H5E_NOTFOUND, FAIL, "object not found") + loc_found = TRUE; + break; + } + case H5O_LOOKUP_BY_IDX: + { + char *group_name = (char *)argv[0]; + H5_index_t idx_type = *((H5_index_t *)argv[1]); + H5_iter_order_t order = *((H5_iter_order_t *)argv[2]); + hsize_t n = *((hsize_t *)argv[3]); + hid_t lapl_id = *((hid_t *)argv[4]); + + /* Find the object's location, according to the order in the index */ + if((ret_value = H5G_loc_find_by_idx(&loc, group_name, idx_type, order, n, + obj_loc/*out*/, lapl_id, H5AC_dxpl_id)) < 0) + HGOTO_ERROR(H5E_SYM, H5E_NOTFOUND, FAIL, "group not found") + loc_found = TRUE; + break; + } + case H5O_LOOKUP_BY_ADDR: + { + haddr_t addr = *((haddr_t *)argv[0]); + + if(!H5F_addr_defined(addr)) + HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "no address supplied") + + obj_loc->oloc->addr = addr; + obj_loc->oloc->file = loc.oloc->file; + H5G_name_reset(obj_loc->path); /* objects opened through this routine don't have a path name */ + loc_found = TRUE; + break; + } + default: + HGOTO_ERROR(H5E_VOL, H5E_CANTGET, FAIL, "can't lookup this object") + } + +done: + /* Release the object location if we failed after copying it */ + if(ret_value == FAIL && loc_found) + if(H5G_loc_free(obj_loc) < 0) + HDONE_ERROR(H5E_SYM, H5E_CANTRELEASE, FAIL, "can't free location") + + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5VL_native_object_lookup() */ + + +/*------------------------------------------------------------------------- + * 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 herr_t +H5VL_native_datatype_commit(hid_t loc_id, const char *name, hid_t type_id, hid_t lcpl_id, + hid_t tcpl_id, hid_t tapl_id) +{ + H5G_loc_t loc; /* Location to commit datatype */ + H5T_t *type; /* Datatype for ID */ + herr_t ret_value = SUCCEED; /* Return value */ + + FUNC_ENTER_NOAPI_NOINIT + + if(H5G_loc(loc_id, &loc) < 0) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a location") + + if(NULL == (type = (H5T_t *)H5I_object_verify(type_id, H5I_DATATYPE))) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a datatype") + + /* Commit the type */ + if(H5T__commit_named(&loc, name, type, lcpl_id, tcpl_id, tapl_id, H5AC_dxpl_id) < 0) + HGOTO_ERROR(H5E_DATATYPE, H5E_CANTINIT, FAIL, "unable to commit datatype") + +done: + + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5VL_native_datatype_commit() */ + + +/*------------------------------------------------------------------------- + * Function: H5VL_native_datatype_open + * + * Purpose: Opens a named datatype inside a native h5 file. + * + * Return: Success: datatype id. + * Failure: NULL + * + * Programmer: Mohamad Chaarawi + * March, 2012 + * + *------------------------------------------------------------------------- + */ +static hid_t +H5VL_native_datatype_open(hid_t loc_id, const char *name, hid_t tapl_id) +{ + H5T_t *type = NULL; /* Datatype opened in file */ + H5G_loc_t loc; /* Group location of object to open */ + H5G_name_t path; /* Datatype group hier. path */ + H5O_loc_t oloc; /* Datatype object location */ + H5O_type_t obj_type; /* Type of object at location */ + H5G_loc_t type_loc; /* Group object for datatype */ + hbool_t obj_found = FALSE; /* Object at 'name' found */ + hid_t dxpl_id = H5AC_dxpl_id; /* dxpl to use to open datatype */ + hid_t ret_value = FAIL; + + FUNC_ENTER_NOAPI_NOINIT + + if(H5G_loc(loc_id, &loc) < 0) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a location") + + /* Set up datatype location to fill in */ + type_loc.oloc = &oloc; + type_loc.path = &path; + H5G_loc_reset(&type_loc); + + /* + * Find the named datatype object header and read the datatype message + * from it. + */ + if(H5G_loc_find(&loc, name, &type_loc/*out*/, tapl_id, dxpl_id) < 0) + HGOTO_ERROR(H5E_DATATYPE, H5E_NOTFOUND, FAIL, "not found") + obj_found = TRUE; + + /* Check that the object found is the correct type */ + if(H5O_obj_type(&oloc, &obj_type, dxpl_id) < 0) + HGOTO_ERROR(H5E_DATATYPE, H5E_CANTGET, FAIL, "can't get object type") + if(obj_type != H5O_TYPE_NAMED_DATATYPE) + HGOTO_ERROR(H5E_DATATYPE, H5E_BADTYPE, FAIL, "not a named datatype") + + /* Open it */ + if(NULL == (type = H5T_open(&type_loc, dxpl_id))) + HGOTO_ERROR(H5E_DATATYPE, H5E_CANTOPENOBJ, FAIL, "unable to open named datatype") + + /* Register the type and return the ID */ + if((ret_value = H5I_register(H5I_DATATYPE, type, TRUE)) < 0) + HGOTO_ERROR(H5E_DATATYPE, H5E_CANTREGISTER, FAIL, "unable to register named datatype") + +done: + if(ret_value < 0) { + if(type != NULL) + H5T_close(type); + else { + if(obj_found && H5F_addr_defined(type_loc.oloc->addr)) + H5G_loc_free(&type_loc); + } /* end else */ + } /* end if */ + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5VL_native_datatype_open() */ + + +/*------------------------------------------------------------------------- + * Function: H5VL_native_dataset_create + * + * Purpose: Creates a dataset inside a native h5 file. + * + * Return: Success: dataset id. + * Failure: NULL + * + * Programmer: Mohamad Chaarawi + * January, 2012 + * + *------------------------------------------------------------------------- + */ +static hid_t +H5VL_native_dataset_create(hid_t loc_id, const char *name, hid_t type_id, hid_t space_id, + hid_t lcpl_id, hid_t dcpl_id, hid_t dapl_id) +{ + H5G_loc_t loc; /* Object location to insert dataset into */ + H5D_t *dset = NULL; /* New dataset's info */ + const H5S_t *space; /* Dataspace for dataset */ + hid_t ret_value; + + FUNC_ENTER_NOAPI_NOINIT + + /* Check arguments */ + if(H5G_loc(loc_id, &loc) < 0) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a location ID") + if(H5I_DATATYPE != H5I_get_type(type_id)) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a datatype ID") + if(NULL == (space = (const H5S_t *)H5I_object_verify(space_id, H5I_DATASPACE))) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a dataspace ID") + + /* H5Dcreate_anon */ + if (NULL == name && lcpl_id == 0) { + /* build and open the new dataset */ + if(NULL == (dset = H5D_create(loc.oloc->file, type_id, space, dcpl_id, dapl_id, H5AC_dxpl_id))) + HGOTO_ERROR(H5E_DATASET, H5E_CANTINIT, FAIL, "unable to create dataset") + + /* Register the new dataset to get an ID for it */ + if((ret_value = H5I_register(H5I_DATASET, dset, TRUE)) < 0) + HGOTO_ERROR(H5E_DATASET, H5E_CANTREGISTER, FAIL, "unable to register dataset") + } + /* 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, H5AC_dxpl_id))) + HGOTO_ERROR(H5E_DATASET, H5E_CANTINIT, FAIL, "unable to create dataset") + if((ret_value = H5I_register(H5I_DATASET, dset, TRUE)) < 0) + HGOTO_ERROR(H5E_DATASET, H5E_CANTREGISTER, FAIL, "unable to register dataset") + } +done: + if(NULL == name && lcpl_id == 0) { + /* 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, FAIL, "unable to get object location of dataset") + + /* Decrement refcount on dataset's object header in memory */ + if(H5O_dec_rc_by_loc(oloc, H5AC_dxpl_id) < 0) + HDONE_ERROR(H5E_DATASET, H5E_CANTDEC, FAIL, "unable to decrement refcount on newly created object") + } /* end if */ + } + if(ret_value < 0) + if(dset && H5D_close(dset) < 0) + HDONE_ERROR(H5E_DATASET, H5E_CLOSEERROR, FAIL, "unable to release dataset") + + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5VL_native_dataset_create() */ + + +/*------------------------------------------------------------------------- + * Function: H5VL_native_dataset_open + * + * Purpose: Opens a dataset inside a native h5 file. + * + * Return: Success: dataset id. + * Failure: NULL + * + * Programmer: Mohamad Chaarawi + * January, 2012 + * + *------------------------------------------------------------------------- + */ +static hid_t +H5VL_native_dataset_open(hid_t loc_id, const char *name, hid_t dapl_id) +{ + H5D_t *dset = NULL; + H5G_loc_t loc; /* Object location of group */ + H5G_loc_t dset_loc; /* Object location of dataset */ + H5G_name_t path; /* Dataset group hier. path */ + H5O_loc_t oloc; /* Dataset object location */ + H5O_type_t obj_type; /* Type of object at location */ + hbool_t loc_found = FALSE; /* Location at 'name' found */ + hid_t dxpl_id = H5AC_dxpl_id; /* dxpl to use to open datset */ + hid_t ret_value; + + FUNC_ENTER_NOAPI_NOINIT + + if(H5G_loc(loc_id, &loc) < 0) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a location") + + /* Set up dataset location to fill in */ + dset_loc.oloc = &oloc; + dset_loc.path = &path; + H5G_loc_reset(&dset_loc); + + /* Find the dataset object */ + if(H5G_loc_find(&loc, name, &dset_loc, dapl_id, dxpl_id) < 0) + HGOTO_ERROR(H5E_DATASET, H5E_NOTFOUND, FAIL, "not found") + loc_found = TRUE; + + /* Check that the object found is the correct type */ + if(H5O_obj_type(&oloc, &obj_type, dxpl_id) < 0) + HGOTO_ERROR(H5E_DATASET, H5E_CANTGET, FAIL, "can't get object type") + if(obj_type != H5O_TYPE_DATASET) + HGOTO_ERROR(H5E_DATASET, H5E_BADTYPE, FAIL, "not a dataset") + + /* Open the dataset */ + if(NULL == (dset = H5D_open(&dset_loc, dapl_id, dxpl_id))) + HGOTO_ERROR(H5E_DATASET, H5E_CANTINIT, FAIL, "can't open dataset") + + /* Register an atom for the dataset */ + if((ret_value = H5I_register(H5I_DATASET, dset, TRUE)) < 0) + HGOTO_ERROR(H5E_ATOM, H5E_CANTREGISTER, FAIL, "can't register dataset atom") + +done: + if(ret_value < 0) { + if(dset) { + if(H5D_close(dset) < 0) + HDONE_ERROR(H5E_DATASET, H5E_CLOSEERROR, FAIL, "unable to release dataset") + } /* end if */ + else { + if(loc_found && H5G_loc_free(&dset_loc) < 0) + HDONE_ERROR(H5E_DATASET, H5E_CANTRELEASE, FAIL, "can't free location") + } /* end else */ + } /* end if */ + + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5VL_native_dataset_open() */ + + +/*------------------------------------------------------------------------- + * Function: H5VL_native_dataset_close + * + * Purpose: Closes a dataset. + * + * Return: Success: 0 + * Failure: -1, dataset not closed. + * + * Programmer: Mohamad Chaarawi + * March, 2012 + * + *------------------------------------------------------------------------- + */ +static herr_t +H5VL_native_dataset_close(hid_t dset_id) +{ + herr_t ret_value = SUCCEED; /* Return value */ + + FUNC_ENTER_NOAPI_NOINIT + + /* Check args */ + if(NULL == H5I_object_verify(dset_id, H5I_DATASET)) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a dataset") + + /* + * Decrement the counter on the dataset. It will be freed if the count + * reaches zero. + * + * Pass in TRUE for the 3rd parameter to tell the function to remove + * dataset's ID even though the freeing function might fail. Please + * see the comments in H5I_dec_ref for details. (SLU - 2010/9/7) + */ + if(H5I_dec_app_ref_always_close(dset_id) < 0) + HGOTO_ERROR(H5E_DATASET, H5E_CANTDEC, FAIL, "can't decrement count on dataset ID") + +done: + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5VL_native_dataset_close() */ + + +/*------------------------------------------------------------------------- + * Function: H5VL_native_dataset_read + * + * Purpose: Reads raw data from a dataset into a buffer. + * + * Return: Success: 0 + * Failure: -1, dataset not readd. + * + * Programmer: Mohamad Chaarawi + * March, 2012 + * + *------------------------------------------------------------------------- + */ +static herr_t +H5VL_native_dataset_read(hid_t dset_id, hid_t mem_type_id, hid_t mem_space_id, + hid_t file_space_id, hid_t plist_id, void *buf/*out*/) +{ + H5D_t *dset = NULL; + const H5S_t *mem_space = NULL; + const H5S_t *file_space = NULL; + char fake_char; + herr_t ret_value = SUCCEED; /* Return value */ + + FUNC_ENTER_NOAPI_NOINIT + + /* check arguments */ + if(NULL == (dset = (H5D_t *)H5I_object_verify(dset_id, H5I_DATASET))) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a dataset") + if(NULL == dset->oloc.file) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a dataset") + if(H5S_ALL != mem_space_id) { + if(NULL == (mem_space = (const H5S_t *)H5I_object_verify(mem_space_id, H5I_DATASPACE))) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a data space") + + /* Check for valid selection */ + if(H5S_SELECT_VALID(mem_space) != TRUE) + HGOTO_ERROR(H5E_DATASPACE, H5E_BADRANGE, FAIL, "selection+offset not within extent") + } /* end if */ + if(H5S_ALL != file_space_id) { + if(NULL == (file_space = (const H5S_t *)H5I_object_verify(file_space_id, H5I_DATASPACE))) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a data space") + + /* Check for valid selection */ + if(H5S_SELECT_VALID(file_space) != TRUE) + HGOTO_ERROR(H5E_DATASPACE, H5E_BADRANGE, FAIL, "selection+offset not within extent") + } /* end if */ + + if(!buf && (NULL == file_space || H5S_GET_SELECT_NPOINTS(file_space) != 0)) + HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "no output buffer") + + /* If the buffer is nil, and 0 element is selected, make a fake buffer. + * This is for some MPI package like ChaMPIon on NCSA's tungsten which + * doesn't support this feature. + */ + if(!buf) + buf = &fake_char; + + /* read raw data */ + if(H5D_read(dset, mem_type_id, mem_space, file_space, plist_id, buf/*out*/) < 0) + HGOTO_ERROR(H5E_DATASET, H5E_READERROR, FAIL, "can't read data") + +done: + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5VL_native_dataset_read() */ + + +/*------------------------------------------------------------------------- + * Function: H5VL_native_dataset_write + * + * Purpose: Writes raw data from a buffer into a dataset. + * + * Return: Success: 0 + * Failure: -1, dataset not writed. + * + * Programmer: Mohamad Chaarawi + * March, 2012 + * + *------------------------------------------------------------------------- + */ +static herr_t +H5VL_native_dataset_write(hid_t dset_id, hid_t mem_type_id, hid_t mem_space_id, + hid_t file_space_id, hid_t dxpl_id, const void *buf) +{ + H5D_t *dset = NULL; + const H5S_t *mem_space = NULL; + const H5S_t *file_space = NULL; + char fake_char; + herr_t ret_value = SUCCEED; /* Return value */ + + FUNC_ENTER_NOAPI_NOINIT + + /* check arguments */ + if(NULL == (dset = (H5D_t *)H5I_object_verify(dset_id, H5I_DATASET))) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a dataset") + if(NULL == dset->oloc.file) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a dataset") + if(H5S_ALL != mem_space_id) { + if(NULL == (mem_space = (const H5S_t *)H5I_object_verify(mem_space_id, H5I_DATASPACE))) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a data space") + + /* Check for valid selection */ + if(H5S_SELECT_VALID(mem_space) != TRUE) + HGOTO_ERROR(H5E_DATASPACE, H5E_BADRANGE, FAIL, "selection+offset not within extent") + } /* end if */ + if(H5S_ALL != file_space_id) { + if(NULL == (file_space = (const H5S_t *)H5I_object_verify(file_space_id, H5I_DATASPACE))) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a data space") + + /* Check for valid selection */ + if(H5S_SELECT_VALID(file_space) != TRUE) + HGOTO_ERROR(H5E_DATASPACE, H5E_BADRANGE, FAIL, "selection+offset not within extent") + } /* end if */ + + if(!buf && (NULL == file_space || H5S_GET_SELECT_NPOINTS(file_space) != 0)) + HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "no output buffer") + + /* If the buffer is nil, and 0 element is selected, make a fake buffer. + * This is for some MPI package like ChaMPIon on NCSA's tungsten which + * doesn't support this feature. + */ + if(!buf) + buf = &fake_char; + + /* write raw data */ + if(H5D_write(dset, mem_type_id, mem_space, file_space, dxpl_id, buf) < 0) + HGOTO_ERROR(H5E_DATASET, H5E_WRITEERROR, FAIL, "can't write data") + +done: + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5VL_native_dataset_write() */ diff --git a/src/H5VLnative.h b/src/H5VLnative.h index ab4dd20..36177ed 100644 --- a/src/H5VLnative.h +++ b/src/H5VLnative.h @@ -30,11 +30,6 @@ extern "C" { H5_DLL hid_t H5VL_native_init(void); H5_DLL herr_t H5Pset_fapl_native(hid_t fapl_id); -H5_DLL hid_t H5VL_native_open(const char *name, unsigned flags, hid_t fcpl_id, - hid_t fapl_id, hid_t dxpl_id); -H5_DLL herr_t H5VL_native_close(hid_t fid); -H5_DLL hid_t H5VL_native_create(const char *name, unsigned flags, hid_t fcpl_id, hid_t fapl_id); -H5_DLL herr_t H5VL_native_flush(hid_t fid, H5F_scope_t scope); #ifdef __cplusplus } diff --git a/src/H5VLprivate.h b/src/H5VLprivate.h index eab0d5c..867a05c 100644 --- a/src/H5VLprivate.h +++ b/src/H5VLprivate.h @@ -47,12 +47,33 @@ H5_DLL int H5VL_term_interface(void); H5_DLL H5VL_class_t *H5VL_get_class(hid_t id); //H5_DLL hsize_t H5VL_sb_size(H5F_t *file); H5_DLL hid_t H5VL_register(const void *cls, size_t size, hbool_t app_ref); + H5_DLL hid_t H5VL_file_open(const char *name, unsigned flags, hid_t fcpl_id, hid_t fapl_id, hid_t dxpl_id); H5_DLL hid_t H5VL_file_create(const char *name, unsigned flags, hid_t fcpl_id, hid_t fapl_id); H5_DLL herr_t H5VL_file_close(hid_t file_id); H5_DLL herr_t H5VL_file_flush(hid_t file_id, H5F_scope_t scope); H5_DLL herr_t H5VL_file_get(hid_t uid, H5VL_file_get_t get_type, void *data, int argc, void **argv); + +H5_DLL hid_t H5VL_dataset_create(hid_t uid, const char *name, hid_t dtype_id, hid_t space_id, hid_t lcpl_id, hid_t dcpl_id, hid_t dapl_id); +H5_DLL hid_t H5VL_dataset_open(hid_t uid, const char *name, hid_t dapl_id); +H5_DLL herr_t H5VL_dataset_close(hid_t uid); +H5_DLL herr_t H5VL_dataset_read(hid_t dset_id, hid_t mem_type_id, hid_t mem_space_id, hid_t file_space_id, hid_t plist_id, void *buf); +H5_DLL herr_t H5VL_dataset_write(hid_t dset_id, hid_t mem_type_id, hid_t mem_space_id, hid_t file_space_id, hid_t plist_id, const void *buf); + +H5_DLL herr_t H5VL_datatype_commit(hid_t loc_id, const char *name, hid_t type_id, hid_t lcpl_id, hid_t tcpl_id, hid_t tapl_id); +H5_DLL hid_t H5VL_datatype_open(hid_t loc_id, const char *name, hid_t tapl_id); + +H5_DLL hid_t H5VL_group_create(hid_t uid, const char *name, hid_t lcpl_id, hid_t gcpl_id, hid_t gapl_id); +H5_DLL hid_t H5VL_group_open(hid_t uid, const char *name, hid_t gapl_id); +H5_DLL herr_t H5VL_group_close(hid_t uid); +H5_DLL herr_t H5VL_group_get(hid_t uid, H5VL_group_get_t get_type, void *data, int argc, void **argv); + +H5_DLL hid_t H5VL_object_open(hid_t uid, void *obj_loc, hid_t lapl_id); +H5_DLL herr_t H5VL_object_close(hid_t uid); +H5_DLL herr_t H5VL_object_get(hid_t uid, H5VL_object_get_t get_type, void *data, int argc, void **argv); +H5_DLL herr_t H5VL_object_lookup(hid_t uid, H5VL_object_lookup_t lookup_type, void **location, int argc, void **argv); + H5_DLL herr_t H5VL_fapl_open(struct H5P_genplist_t *plist, hid_t vol_id, const void *vol_info); H5_DLL herr_t H5VL_fapl_copy(hid_t vol_id, const void *fapl, void **copied_fapl); H5_DLL herr_t H5VL_fapl_close(hid_t vol_id, void *fapl); diff --git a/src/H5VLpublic.h b/src/H5VLpublic.h index 9a800fe..b374d78 100644 --- a/src/H5VLpublic.h +++ b/src/H5VLpublic.h @@ -42,6 +42,25 @@ typedef enum H5VL_file_get_t { H5F_GET_FREE_SECTIONS = 13 /*file free selections */ } H5VL_file_get_t; +/* types for all group get API routines */ +typedef enum H5VL_group_get_t { + H5G_GET_GCPL = 0, /*group creation property list */ + H5G_GET_INFO = 1 /*group info */ +} H5VL_group_get_t; + +/* types for all object get API routines */ +typedef enum H5VL_object_get_t { + H5O_GET_INFO = 0, /*object info */ + H5O_GET_COMMENT = 1 /*object comment */ +} H5VL_object_get_t; + +/* types for all object lookup API routines */ +typedef enum H5VL_object_lookup_t { + H5O_LOOKUP_BY_NAME = 0, + H5O_LOOKUP_BY_IDX = 1, + H5O_LOOKUP_BY_ADDR = 2 +} H5VL_object_lookup_t; + #define H5VL_VOL_DEFAULT 0 /* Default VOL plugin value */ /* H5F routines */ @@ -80,6 +99,8 @@ typedef struct H5VL_attribute_class_t { /* H5T routines*/ typedef struct H5VL_datatype_class_t { + herr_t (*commit)(hid_t loc_id, const char *name, hid_t type_id, + hid_t lcpl_id, hid_t tcpl_id, hid_t tapl_id); hid_t (*open) (hid_t loc_id, const char * name, hid_t tapl_id); }H5VL_datatype_class_t; @@ -94,15 +115,24 @@ typedef struct H5VL_link_class_t { const char *dest_name, hid_t lcpl_id, hid_t lapl_id); } H5VL_link_class_t; +/* H5G routines */ +typedef struct H5VL_group_class_t { + hid_t (*create)(hid_t loc_id, const char *name, hid_t lcpl_id, hid_t gcpl_id, hid_t gapl_id); + hid_t (*open) (hid_t loc_id, const char *name, hid_t gapl_id); + herr_t (*close) (hid_t group_id); + herr_t (*get) (hid_t file_id, H5VL_group_get_t get_type, void *data, int argc, void **argv); +} H5VL_group_class_t; + /* H5O routines */ typedef struct H5VL_object_class_t { - hid_t (*create)(hid_t loc_id, const char *name, hid_t lcpl_id, hid_t gcpl_id, hid_t gapl_id); - hid_t (*open) (hid_t loc_id, const char *name, hid_t lapl_id); + hid_t (*open) (hid_t loc_id, void *obj_loc, hid_t lapl_id); herr_t (*close) (hid_t obj_id); herr_t (*move) (hid_t src_loc_id, const char *src_name, hid_t dst_loc_id, const char *dest_name, hid_t lcpl, hid_t lapl); herr_t (*copy) (hid_t src_loc_id, const char *src_name, hid_t dst_loc_id, const char *dst_name, hid_t ocpypl_id, hid_t lcpl_id ); + herr_t (*lookup)(hid_t loc_id, H5VL_object_lookup_t lookup_type, void **location, int argc, void **argv); + herr_t (*get) (hid_t loc_id, H5VL_object_get_t get_type, void *data, int argc, void **argv); } H5VL_object_class_t; /* Class information for each VOL driver */ @@ -110,13 +140,14 @@ typedef struct H5VL_class_t { const char *name; herr_t (*terminate)(void); size_t fapl_size; - void * (*fapl_get)(H5F_t *file); + void * (*fapl_get)(hid_t fid); void * (*fapl_copy)(const void *fapl); herr_t (*fapl_free)(void *fapl); - H5VL_file_class_t file_cls; - H5VL_dataset_class_t dataset_cls; H5VL_attribute_class_t attribute_cls; H5VL_datatype_class_t datatype_cls; + H5VL_dataset_class_t dataset_cls; + H5VL_group_class_t group_cls; + H5VL_file_class_t file_cls; H5VL_link_class_t link_cls; H5VL_object_class_t object_cls; } H5VL_class_t; diff --git a/test/links.c b/test/links.c index 966802a..329b9a2 100644 --- a/test/links.c +++ b/test/links.c @@ -6306,7 +6306,6 @@ external_link_strong(hid_t fapl, hbool_t new_format) if(H5Gclose(gid2) < 0) TEST_ERROR if(H5Fclose(fid2) < 0) TEST_ERROR - PASSED(); return 0; diff --git a/test/tfile.c b/test/tfile.c index ed33c91..773ff1d 100644 --- a/test/tfile.c +++ b/test/tfile.c @@ -701,7 +701,6 @@ test_file_close(void) ret = H5Fclose(fid2); CHECK(ret, FAIL, "H5Fclose"); - /* Test behavior while opening file multiple times with file close * degree WEAK */ ret = H5Pset_fclose_degree(fapl_id, H5F_CLOSE_WEAK); @@ -752,7 +751,6 @@ test_file_close(void) ret = H5Gclose(group_id3); CHECK(ret, FAIL, "H5Gclose"); - /* Test behavior while opening file multiple times with file close * degree DEFAULT */ ret = H5Pset_fclose_degree(fapl_id, H5F_CLOSE_DEFAULT); @@ -1123,7 +1121,7 @@ test_obj_count_and_id(hid_t fid1, hid_t fid2, hid_t did, hid_t gid1, fid4 = H5Fcreate(FILE3, H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT); CHECK(fid4, FAIL, "H5Fcreate"); - /* test object count of all files IDs open */ + /* test object count of all files open */ oid_count = H5Fget_obj_count(H5F_OBJ_ALL, H5F_OBJ_FILE); CHECK(oid_count, FAIL, "H5Fget_obj_count"); VERIFY(oid_count, OBJ_ID_COUNT_4, "H5Fget_obj_count"); @@ -1152,7 +1150,7 @@ test_obj_count_and_id(hid_t fid1, hid_t fid2, hid_t did, hid_t gid1, oid_count = H5Fget_obj_count(H5F_OBJ_ALL, H5F_OBJ_ALL); CHECK(oid_count, FAIL, "H5Fget_obj_count"); VERIFY(oid_count, OBJ_ID_COUNT_8, "H5Fget_obj_count"); - + if(oid_count > 0) { hid_t *oid_list; @@ -1168,19 +1166,19 @@ test_obj_count_and_id(hid_t fid1, hid_t fid2, hid_t did, hid_t gid1, id_type = H5Iget_type(oid_list[i]); switch(id_type) { - case H5I_FILE: + case H5I_FILE_PUBLIC: if(oid_list[i] != fid1 && oid_list[i] != fid2 - && oid_list[i] != fid3 && oid_list[i] != fid4) + && oid_list[i] != fid3 && oid_list[i] != fid4) ERROR("H5Fget_obj_ids"); break; - case H5I_GROUP: + case H5I_GROUP_PUBLIC: if(oid_list[i] != gid1 && oid_list[i] != gid2 - && oid_list[i] != gid3) + && oid_list[i] != gid3) ERROR("H5Fget_obj_ids"); break; - case H5I_DATASET: + case H5I_DATASET_PUBLIC: VERIFY(oid_list[i], did, "H5Fget_obj_ids"); break; diff --git a/test/th5o.c b/test/th5o.c index c46751e..c878b34 100644 --- a/test/th5o.c +++ b/test/th5o.c @@ -93,11 +93,11 @@ test_h5o_open(void) /* Make sure that each is the right kind of ID */ id_type = H5Iget_type(grp); - VERIFY(id_type, H5I_GROUP, "H5Iget_type for group ID"); + VERIFY(id_type, H5I_GROUP_PUBLIC, "H5Iget_type for group ID"); id_type = H5Iget_type(dtype); - VERIFY(id_type, H5I_DATATYPE, "H5Iget_type for datatype ID"); + VERIFY(id_type, H5I_DATATYPE_PUBLIC, "H5Iget_type for datatype ID"); id_type = H5Iget_type(dset); - VERIFY(id_type, H5I_DATASET, "H5Iget_type for dataset ID"); + VERIFY(id_type, H5I_DATASET_PUBLIC, "H5Iget_type for dataset ID"); /* Do something more complex with each of the IDs to make sure they "work" */ ret = H5Gget_info(grp, &ginfo); @@ -162,7 +162,7 @@ test_h5o_close(void) /* Create the group and close it with H5Oclose */ grp = H5Gcreate2(fid, "group", H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT); CHECK(grp, FAIL, "H5Gcreate2"); - VERIFY(H5Iget_type(grp), H5I_GROUP, "H5Iget_type"); + VERIFY(H5Iget_type(grp), H5I_GROUP_PUBLIC, "H5Iget_type"); ret = H5Oclose(grp); CHECK(ret, FAIL, "H5Oclose"); @@ -306,11 +306,11 @@ test_h5o_open_by_addr(void) /* Make sure that each is the right kind of ID */ id_type = H5Iget_type(grp); - VERIFY(id_type, H5I_GROUP, "H5Iget_type for group ID"); + VERIFY(id_type, H5I_GROUP_PUBLIC, "H5Iget_type for group ID"); id_type = H5Iget_type(dtype); - VERIFY(id_type, H5I_DATATYPE, "H5Iget_type for datatype ID"); + VERIFY(id_type, H5I_DATATYPE_PUBLIC, "H5Iget_type for datatype ID"); id_type = H5Iget_type(dset); - VERIFY(id_type, H5I_DATASET, "H5Iget_type for dataset ID"); + VERIFY(id_type, H5I_DATASET_PUBLIC, "H5Iget_type for dataset ID"); /* Do something more complex with each of the IDs to make sure they "work" */ ret = H5Gget_info(grp, &ginfo); -- cgit v0.12