From f31fac3a23da12287384db7f6aa2937e9461d3fe Mon Sep 17 00:00:00 2001 From: Mohamad Chaarawi Date: Mon, 11 Jun 2012 17:00:40 -0500 Subject: [svn-r22452] - remove nrefs param - create a struct to hold parameters for object locations instead of calling into VOL to lookup and free object: * update the implementation for H5Oopen(_by_name/idx/ref) * H5Rderefence * H5Aopen(_by_name), H5Arename(_by_name) * other routines coming later --- src/H5A.c | 131 ++++++++++++++++------------------------ src/H5Adeprec.c | 15 +++-- src/H5Aint.c | 50 +++++++++++++++ src/H5Aprivate.h | 3 +- src/H5F.c | 2 - src/H5Gint.c | 2 - src/H5Gtraverse.c | 1 - src/H5I.c | 10 +-- src/H5L.c | 1 - src/H5O.c | 48 +++++---------- src/H5Pacpl.c | 8 +-- src/H5R.c | 19 ++---- src/H5Rdeprec.c | 17 ++---- src/H5VL.c | 31 ++++++++++ src/H5VLdummy.c | 25 ++++---- src/H5VLint.c | 93 +++++++--------------------- src/H5VLnative.c | 178 +++++++++++++++++++++++++++++++++++++++++------------- src/H5VLprivate.h | 4 +- src/H5VLpublic.h | 49 +++++++++++++-- 19 files changed, 400 insertions(+), 287 deletions(-) diff --git a/src/H5A.c b/src/H5A.c index ca35078..a41340b 100644 --- a/src/H5A.c +++ b/src/H5A.c @@ -218,7 +218,7 @@ H5Acreate2(hid_t loc_id, const char *attr_name, hid_t type_id, hid_t space_id, hid_t acpl_id, hid_t UNUSED aapl_id) { H5P_genplist_t *plist; /* Property list pointer */ - void *location = NULL; + H5VL_loc_params_t loc_params; hid_t ret_value; /* Return value */ FUNC_ENTER_API(FAIL) @@ -234,6 +234,9 @@ H5Acreate2(hid_t loc_id, const char *attr_name, hid_t type_id, hid_t space_id, if(H5P_DEFAULT == acpl_id) acpl_id = H5P_ATTRIBUTE_CREATE_DEFAULT; + loc_params.type = H5VL_OBJECT_LOOKUP_BY_ID; + loc_params.loc_data.loc_by_id.id = loc_id; + /* Get the plist structure */ if(NULL == (plist = (H5P_genplist_t *)H5I_object(acpl_id))) HGOTO_ERROR(H5E_ATOM, H5E_BADATOM, FAIL, "can't find object for ID") @@ -243,7 +246,7 @@ H5Acreate2(hid_t loc_id, const char *attr_name, hid_t type_id, hid_t space_id, HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, FAIL, "can't set property value for datatype id") if(H5P_set(plist, H5VL_ATTR_SPACE_ID, &space_id) < 0) HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, FAIL, "can't set property value for space id") - if(H5P_set(plist, H5VL_ATTR_LOCATION, &location) < 0) + if(H5P_set(plist, H5VL_ATTR_LOC_PARAMS, &loc_params) < 0) HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, FAIL, "can't set property value for location") /* Create the attribute through the VOL */ @@ -288,13 +291,12 @@ done: /* ARGSUSED */ hid_t H5Acreate_by_name(hid_t loc_id, const char *obj_name, const char *attr_name, - hid_t type_id, hid_t space_id, hid_t acpl_id, hid_t UNUSED aapl_id, + hid_t type_id, hid_t space_id, hid_t acpl_id, hid_t aapl_id, hid_t lapl_id) { H5P_genplist_t *plist; /* Property list pointer */ - void *location = NULL; /* a pointer to VOL specific token that indicates - the location of the object */ - hid_t ret_value; /* Return value */ + H5VL_loc_params_t loc_params; + hid_t ret_value; /* Return value */ FUNC_ENTER_API(FAIL) H5TRACE8("i", "i*s*siiiii", loc_id, obj_name, attr_name, type_id, space_id, @@ -308,14 +310,14 @@ H5Acreate_by_name(hid_t loc_id, const char *obj_name, const char *attr_name, if(!attr_name || !*attr_name) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "no attribute name") - /* Get the token for the Object location through the VOL */ - if(H5VL_object_lookup(loc_id, H5VL_OBJECT_LOOKUP_BY_NAME, &location, H5_REQUEST_NULL, obj_name, lapl_id) < 0) - HGOTO_ERROR(H5E_SYM, H5E_CANTINIT, FAIL, "unable to locate object") - /* Get correct property list */ if(H5P_DEFAULT == acpl_id) acpl_id = H5P_ATTRIBUTE_CREATE_DEFAULT; + loc_params.type = H5VL_OBJECT_LOOKUP_BY_NAME; + loc_params.loc_data.loc_by_name.name = obj_name; + loc_params.loc_data.loc_by_name.lapl_id = lapl_id; + /* Get the plist structure */ if(NULL == (plist = (H5P_genplist_t *)H5I_object(acpl_id))) HGOTO_ERROR(H5E_ATOM, H5E_BADATOM, FAIL, "can't find object for ID") @@ -325,7 +327,7 @@ H5Acreate_by_name(hid_t loc_id, const char *obj_name, const char *attr_name, HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, FAIL, "can't set property value for datatype id") if(H5P_set(plist, H5VL_ATTR_SPACE_ID, &space_id) < 0) HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, FAIL, "can't set property value for space id") - if(H5P_set(plist, H5VL_ATTR_LOCATION, &location) < 0) + if(H5P_set(plist, H5VL_ATTR_LOC_PARAMS, &loc_params) < 0) HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, FAIL, "can't set property value for location") /* Create the attribute through the VOL */ @@ -333,11 +335,6 @@ H5Acreate_by_name(hid_t loc_id, const char *obj_name, const char *attr_name, HGOTO_ERROR(H5E_SYM, H5E_CANTINIT, FAIL, "unable to create attribute") done: - if (NULL != location) { - /* free the location token through the VOL */ - if(H5VL_object_free_loc (loc_id, location, H5_REQUEST_NULL) < 0) - HGOTO_ERROR(H5E_SYM, H5E_CANTRELEASE, FAIL, "unable to free location token") - } FUNC_LEAVE_API(ret_value) } /* H5Acreate_by_name() */ @@ -533,6 +530,7 @@ done: hid_t H5Aopen(hid_t loc_id, const char *attr_name, hid_t aapl_id) { + H5VL_loc_params_t loc_params; hid_t ret_value; FUNC_ENTER_API(FAIL) @@ -544,9 +542,12 @@ H5Aopen(hid_t loc_id, const char *attr_name, hid_t aapl_id) if(!attr_name || !*attr_name) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "no attribute name") + loc_params.type = H5VL_OBJECT_LOOKUP_BY_ID; + loc_params.loc_data.loc_by_id.id = loc_id; + /* Open the attribute through the VOL */ - if((ret_value = H5VL_attr_open(loc_id, NULL, attr_name, aapl_id, H5_REQUEST_NULL)) < 0) - HGOTO_ERROR(H5E_DATASET, H5E_CANTINIT, FAIL, "unable to open attribute") + if((ret_value = H5VL_attr_open(loc_id, loc_params, attr_name, aapl_id, H5_REQUEST_NULL)) < 0) + HGOTO_ERROR(H5E_ATTR, H5E_CANTINIT, FAIL, "unable to open attribute") done: FUNC_LEAVE_API(ret_value) @@ -576,10 +577,9 @@ done: --------------------------------------------------------------------------*/ hid_t H5Aopen_by_name(hid_t loc_id, const char *obj_name, const char *attr_name, - hid_t UNUSED aapl_id, hid_t lapl_id) + hid_t aapl_id, hid_t lapl_id) { - void *location = NULL; /* a pointer to VOL specific token that indicates - the location of the object */ + H5VL_loc_params_t loc_params; hid_t ret_value; FUNC_ENTER_API(FAIL) @@ -598,20 +598,15 @@ H5Aopen_by_name(hid_t loc_id, const char *obj_name, const char *attr_name, if(TRUE != H5P_isa_class(lapl_id, H5P_LINK_ACCESS)) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not link access property list ID") - /* Get the token for the Object location through the VOL */ - if(H5VL_object_lookup(loc_id, H5VL_OBJECT_LOOKUP_BY_NAME, &location, H5_REQUEST_NULL, obj_name, lapl_id) < 0) - HGOTO_ERROR(H5E_SYM, H5E_CANTINIT, FAIL, "unable to locate object") + loc_params.type = H5VL_OBJECT_LOOKUP_BY_NAME; + loc_params.loc_data.loc_by_name.name = obj_name; + loc_params.loc_data.loc_by_name.lapl_id = lapl_id; /* Open the attribute through the VOL */ - if((ret_value = H5VL_attr_open(loc_id, location, attr_name, aapl_id, H5_REQUEST_NULL)) < 0) - HGOTO_ERROR(H5E_DATASET, H5E_CANTINIT, FAIL, "unable to open attribute") + if((ret_value = H5VL_attr_open(loc_id, loc_params, attr_name, aapl_id, H5_REQUEST_NULL)) < 0) + HGOTO_ERROR(H5E_ATTR, H5E_CANTINIT, FAIL, "unable to open attribute") done: - if (NULL != location) { - /* free the location token through the VOL */ - if(H5VL_object_free_loc (loc_id, location, H5_REQUEST_NULL) < 0) - HGOTO_ERROR(H5E_SYM, H5E_CANTRELEASE, FAIL, "unable to free location token") - } FUNC_LEAVE_API(ret_value) } /* H5Aopen_by_name() */ @@ -1643,9 +1638,8 @@ herr_t H5Aget_info_by_name(hid_t loc_id, const char *obj_name, const char *attr_name, H5A_info_t *ainfo, hid_t lapl_id) { + H5VL_loc_params_t loc_params; hid_t attr_id = -1; - void *location = NULL; /* a pointer to VOL specific token that indicates - the location of the object */ herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_API(FAIL) @@ -1665,23 +1659,14 @@ H5Aget_info_by_name(hid_t loc_id, const char *obj_name, const char *attr_name, else if(TRUE != H5P_isa_class(lapl_id, H5P_LINK_ACCESS)) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not link access property list ID") -#if 0 - /* Open the attribute on the object header */ - if(NULL == (attr = H5A_open_by_name(&loc, obj_name, attr_name, lapl_id, H5AC_ind_dxpl_id))) - HGOTO_ERROR(H5E_ATTR, H5E_CANTOPENOBJ, FAIL, "can't open attribute") - - /* Get the attribute information */ - if(H5A_get_info(attr, ainfo) < 0) - HGOTO_ERROR(H5E_ATTR, H5E_CANTGET, FAIL, "unable to get attribute info") -#endif - /* Get the token for the Object location through the VOL */ - if(H5VL_object_lookup(loc_id, H5VL_OBJECT_LOOKUP_BY_NAME, &location, H5_REQUEST_NULL, obj_name, lapl_id) < 0) - HGOTO_ERROR(H5E_SYM, H5E_CANTINIT, FAIL, "unable to locate object") + loc_params.type = H5VL_OBJECT_LOOKUP_BY_NAME; + loc_params.loc_data.loc_by_name.name = obj_name; + loc_params.loc_data.loc_by_name.lapl_id = lapl_id; /* Open the attribute through the VOL */ - if((attr_id = H5VL_attr_open(loc_id, location, attr_name, H5P_DEFAULT, H5_REQUEST_NULL)) < 0) - HGOTO_ERROR(H5E_DATASET, H5E_CANTINIT, FAIL, "unable to open attribute") + if((attr_id = H5VL_attr_open(loc_id, loc_params, attr_name, H5P_DEFAULT, H5_REQUEST_NULL)) < 0) + HGOTO_ERROR(H5E_ATTR, H5E_CANTINIT, FAIL, "unable to open attribute") /* get the attribute info through the VOL */ if(H5VL_attr_get(attr_id, H5VL_ATTR_GET_INFO, H5_REQUEST_NULL, ainfo) < 0) @@ -1691,11 +1676,6 @@ done: if(attr_id > 0 && H5VL_attr_close(attr_id, H5_REQUEST_NULL) < 0) HDONE_ERROR(H5E_ATTR, H5E_CANTFREE, FAIL, "can't close attribute") - if(NULL != location) { - /* free the location token through the VOL */ - if(H5VL_object_free_loc (loc_id, location, H5_REQUEST_NULL) < 0) - HGOTO_ERROR(H5E_SYM, H5E_CANTRELEASE, FAIL, "unable to free location token") - } FUNC_LEAVE_API(ret_value) } /* end H5Aget_info_by_name() */ @@ -1840,11 +1820,16 @@ H5Arename(hid_t loc_id, const char *old_name, const char *new_name) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "location is not valid for an attribute") /* Avoid thrashing things if the names are the same */ - if(HDstrcmp(old_name, new_name)) + if(HDstrcmp(old_name, new_name)) { + H5VL_loc_params_t loc_params; + + loc_params.type = H5VL_OBJECT_LOOKUP_BY_ID; + loc_params.loc_data.loc_by_id.id = loc_id; + /* rename the attribute info through the VOL */ - if(H5VL_object_misc(loc_id, H5VL_ATTR_RENAME, H5_REQUEST_NULL, NULL, old_name, new_name) < 0) + if(H5VL_object_misc(loc_id, H5VL_ATTR_RENAME, H5_REQUEST_NULL, loc_params, old_name, new_name) < 0) HGOTO_ERROR(H5E_ATTR, H5E_CANTRENAME, FAIL, "can't rename attribute") - + } done: FUNC_LEAVE_API(ret_value) } /* H5Arename() */ @@ -1890,21 +1875,15 @@ H5Arename_by_name(hid_t loc_id, const char *obj_name, const char *old_attr_name, /* Avoid thrashing things if the names are the same */ if(HDstrcmp(old_attr_name, new_attr_name)) { - void *location = NULL; + H5VL_loc_params_t loc_params; - /* Get the token for the Object location through the VOL */ - if(H5VL_object_lookup(loc_id, H5VL_OBJECT_LOOKUP_BY_NAME, &location, H5_REQUEST_NULL, obj_name, lapl_id) < 0) - HGOTO_ERROR(H5E_SYM, H5E_CANTINIT, FAIL, "unable to locate object") + loc_params.type = H5VL_OBJECT_LOOKUP_BY_NAME; + loc_params.loc_data.loc_by_name.name = obj_name; + loc_params.loc_data.loc_by_name.lapl_id = lapl_id; /* get the attribute info through the VOL */ - if(H5VL_object_misc(loc_id, H5VL_ATTR_RENAME, H5_REQUEST_NULL, location, old_attr_name, new_attr_name) < 0) + if(H5VL_object_misc(loc_id, H5VL_ATTR_RENAME, H5_REQUEST_NULL, loc_params, old_attr_name, new_attr_name) < 0) HGOTO_ERROR(H5E_INTERNAL, H5E_CANTGET, FAIL, "unable to get attribute info") - - if(NULL != location) { - /* free the location token through the VOL */ - if(H5VL_object_free_loc (loc_id, location, H5_REQUEST_NULL) < 0) - HGOTO_ERROR(H5E_SYM, H5E_CANTRELEASE, FAIL, "unable to free location token") - } } /* end if */ done: @@ -2039,11 +2018,11 @@ H5Aiterate_by_name(hid_t loc_id, const char *obj_name, H5_index_t idx_type, H5_iter_order_t order, hsize_t *idx, H5A_operator2_t op, void *op_data, hid_t lapl_id) { - void *location = NULL; hid_t obj_loc_id = (-1); /* ID for object located */ H5A_attr_iter_op_t attr_op; /* Attribute operator */ hsize_t start_idx; /* Index of attribute to start iterating at */ hsize_t last_attr; /* Index of last attribute examined */ + H5VL_loc_params_t loc_params; herr_t ret_value; /* Return value */ FUNC_ENTER_API(FAIL) @@ -2065,12 +2044,11 @@ H5Aiterate_by_name(hid_t loc_id, const char *obj_name, H5_index_t idx_type, if(TRUE != H5P_isa_class(lapl_id, H5P_LINK_ACCESS)) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not link access property list ID") - /* Get the token for the Object location through the VOL */ - if(H5VL_object_lookup (loc_id, H5VL_OBJECT_LOOKUP_BY_NAME, &location, H5_REQUEST_NULL, obj_name, lapl_id) < 0) - HGOTO_ERROR(H5E_SYM, H5E_CANTINIT, FAIL, "unable to locate object") + loc_params.type = H5VL_OBJECT_LOOKUP_BY_NAME; + loc_params.loc_data.loc_by_name.name = obj_name; /* Open the object through the VOL */ - if((obj_loc_id = H5VL_object_open_by_loc(loc_id, location, lapl_id, H5_REQUEST_NULL)) < 0) + if((obj_loc_id = H5VL_object_open(loc_id, loc_params, lapl_id, H5_REQUEST_NULL)) < 0) HGOTO_ERROR(H5E_SYM, H5E_CANTINIT, FAIL, "unable to open object") /* Build attribute operator info */ @@ -2093,11 +2071,6 @@ done: HDONE_ERROR(H5E_ATTR, H5E_CANTDEC, FAIL, "unable to close temporary object") } /* end if */ - if(NULL != location) { - /* free the location token through the VOL */ - if(H5VL_object_free_loc (loc_id, location, H5_REQUEST_NULL) < 0) - HGOTO_ERROR(H5E_SYM, H5E_CANTRELEASE, FAIL, "unable to free location token") - } FUNC_LEAVE_API(ret_value) } /* H5Aiterate_by_name() */ @@ -2132,7 +2105,7 @@ H5Adelete(hid_t loc_id, const char *name) /* Open the attribute through the VOL */ if(H5VL_attr_remove(loc_id, NULL, name, H5_REQUEST_NULL) < 0) - HGOTO_ERROR(H5E_DATASET, H5E_CANTDELETE, FAIL, "unable to delete attribute") + HGOTO_ERROR(H5E_ATTR, H5E_CANTDELETE, FAIL, "unable to delete attribute") done: FUNC_LEAVE_API(ret_value) @@ -2184,7 +2157,7 @@ H5Adelete_by_name(hid_t loc_id, const char *obj_name, const char *attr_name, /* Open the attribute through the VOL */ if(H5VL_attr_remove(loc_id, location, attr_name, H5_REQUEST_NULL) < 0) - HGOTO_ERROR(H5E_DATASET, H5E_CANTDELETE, FAIL, "unable to delete attribute") + HGOTO_ERROR(H5E_ATTR, H5E_CANTDELETE, FAIL, "unable to delete attribute") done: if(NULL != location) { @@ -2288,7 +2261,7 @@ H5Aclose(hid_t attr_id) /* Close the attribute through the VOL */ if((ret_value = H5VL_attr_close(attr_id, H5_REQUEST_NULL)) < 0) - HGOTO_ERROR(H5E_DATASET, H5E_CANTRELEASE, FAIL, "unable to close attribute") + HGOTO_ERROR(H5E_ATTR, H5E_CANTRELEASE, FAIL, "unable to close attribute") done: FUNC_LEAVE_API(ret_value) diff --git a/src/H5Adeprec.c b/src/H5Adeprec.c index 50f2cf1..6f6388c 100644 --- a/src/H5Adeprec.c +++ b/src/H5Adeprec.c @@ -139,7 +139,7 @@ hid_t H5Acreate1(hid_t loc_id, const char *name, hid_t type_id, hid_t space_id, hid_t plist_id) { - void *location = NULL; + H5VL_loc_params_t loc_params; H5P_genplist_t *plist; /* Property list pointer */ hid_t ret_value; /* Return value */ @@ -156,6 +156,9 @@ H5Acreate1(hid_t loc_id, const char *name, hid_t type_id, hid_t space_id, if(H5P_DEFAULT == plist_id) plist_id = H5P_ATTRIBUTE_CREATE_DEFAULT; + loc_params.type = H5VL_OBJECT_LOOKUP_BY_ID; + loc_params.loc_data.loc_by_id.id = loc_id; + /* Get the plist structure */ if(NULL == (plist = (H5P_genplist_t *)H5I_object(plist_id))) HGOTO_ERROR(H5E_ATOM, H5E_BADATOM, FAIL, "can't find object for ID") @@ -165,7 +168,7 @@ H5Acreate1(hid_t loc_id, const char *name, hid_t type_id, hid_t space_id, HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, FAIL, "can't set property value for datatype id") if(H5P_set(plist, H5VL_ATTR_SPACE_ID, &space_id) < 0) HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, FAIL, "can't set property value for space id") - if(H5P_set(plist, H5VL_ATTR_LOCATION, &location) < 0) + if(H5P_set(plist, H5VL_ATTR_LOC_PARAMS, &loc_params) < 0) HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, FAIL, "can't set property value for location") /* Create the attribute through the VOL */ @@ -202,6 +205,7 @@ done: hid_t H5Aopen_name(hid_t loc_id, const char *name) { + H5VL_loc_params_t loc_params; hid_t ret_value; FUNC_ENTER_API(FAIL) @@ -213,9 +217,12 @@ H5Aopen_name(hid_t loc_id, const char *name) if(!name || !*name) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "no name") + loc_params.type = H5VL_OBJECT_LOOKUP_BY_ID; + loc_params.loc_data.loc_by_id.id = loc_id; + /* Open the attribute through the VOL */ - if((ret_value = H5VL_attr_open(loc_id, NULL, name, H5P_DEFAULT, H5_REQUEST_NULL)) < 0) - HGOTO_ERROR(H5E_DATASET, H5E_CANTINIT, FAIL, "unable to open attribute") + if((ret_value = H5VL_attr_open(loc_id, loc_params, name, H5P_DEFAULT, H5_REQUEST_NULL)) < 0) + HGOTO_ERROR(H5E_ATTR, H5E_CANTINIT, FAIL, "unable to open attribute") done: FUNC_LEAVE_API(ret_value) diff --git a/src/H5Aint.c b/src/H5Aint.c index 74c5590..1bbbd31 100644 --- a/src/H5Aint.c +++ b/src/H5Aint.c @@ -1259,3 +1259,53 @@ done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5A_dense_post_copy_file_all */ + +/*------------------------------------------------------------------------- + * Function: H5A_rename_by_name + * + * Purpose: Private version of H5Arename_by_name + * + * Return: Success: Non-negative + * Failure: Negative + * + * Programmer: Quincey Koziol + * February 20, 2007 + * + *------------------------------------------------------------------------- + */ +herr_t +H5A_rename_by_name(H5G_loc_t loc, const char *obj_name, const char *old_attr_name, + const char *new_attr_name, hid_t lapl_id) +{ + H5G_loc_t obj_loc; /* Location used to open group */ + H5G_name_t obj_path; /* Opened object group hier. path */ + H5O_loc_t obj_oloc; /* Opened object object location */ + hbool_t loc_found = FALSE; /* Entry at 'obj_name' found */ + herr_t ret_value = SUCCEED; /* Return value */ + + FUNC_ENTER_NOAPI_NOINIT + + /* Avoid thrashing things if the names are the same */ + if(HDstrcmp(old_attr_name, new_attr_name)) { + /* Set up opened group location to fill in */ + obj_loc.oloc = &obj_oloc; + obj_loc.path = &obj_path; + H5G_loc_reset(&obj_loc); + + /* Find the object's location */ + if(H5G_loc_find(&loc, obj_name, &obj_loc/*out*/, lapl_id, H5AC_ind_dxpl_id) < 0) + HGOTO_ERROR(H5E_ATTR, H5E_NOTFOUND, FAIL, "object not found") + loc_found = TRUE; + + /* Call attribute rename routine */ + if(H5O_attr_rename(obj_loc.oloc, H5AC_dxpl_id, old_attr_name, new_attr_name) < 0) + HGOTO_ERROR(H5E_ATTR, H5E_CANTRENAME, FAIL, "can't rename attribute") + } /* end if */ + +done: + /* Release resources */ + if(loc_found && H5G_loc_free(&obj_loc) < 0) + HDONE_ERROR(H5E_ATTR, H5E_CANTRELEASE, FAIL, "can't free location") + + FUNC_LEAVE_NOAPI(ret_value) +} /* H5A_rename_by_name() */ diff --git a/src/H5Aprivate.h b/src/H5Aprivate.h index 448ece5..9e2cbb2 100644 --- a/src/H5Aprivate.h +++ b/src/H5Aprivate.h @@ -82,6 +82,7 @@ H5_DLL herr_t H5O_attr_iterate_real(hid_t loc_id, const H5O_loc_t *loc, H5_DLL herr_t H5O_attr_iterate(hid_t loc_id, hid_t dxpl_id, H5_index_t idx_type, H5_iter_order_t order, hsize_t skip, hsize_t *last_attr, const H5A_attr_iter_op_t *op, void *op_data); - +H5_DLL herr_t H5A_rename_by_name(H5G_loc_t loc, const char *obj_name, const char *old_attr_name, + const char *new_attr_name, hid_t lapl_id); #endif /* _H5Aprivate_H */ diff --git a/src/H5F.c b/src/H5F.c index 724477c..af71d09 100644 --- a/src/H5F.c +++ b/src/H5F.c @@ -338,7 +338,6 @@ H5F_get_access_plist(H5F_t *f, hbool_t app_ref) HGOTO_ERROR(H5E_PLIST, H5E_CANTSET, FAIL, "can't set file driver ID") /* Increment the reference count on the VOL struct and insert it into the property list */ - f->vol_cls->nrefs ++; if(H5P_set(new_plist, H5F_ACS_VOL_NAME, &(f->vol_cls)) < 0) HGOTO_ERROR(H5E_PLIST, H5E_CANTSET, FAIL, "can't set file VOL plugin") @@ -2157,7 +2156,6 @@ H5F_get_id(H5F_t *file, hbool_t app_ref) /* attach VOL information to the ID */ if (H5I_register_aux(file->file_id, file->vol_cls, (H5I_free_t)H5VL_close) < 0) HGOTO_ERROR(H5E_VOL, H5E_CANTINIT, FAIL, "can't attach vol info to ID") - file->vol_cls->nrefs++; } else { /* Increment reference count on atom. */ if(H5I_inc_ref(file->file_id, app_ref) < 0) diff --git a/src/H5Gint.c b/src/H5Gint.c index 1e204d8..5e220ed 100644 --- a/src/H5Gint.c +++ b/src/H5Gint.c @@ -839,7 +839,6 @@ H5G_iterate(hid_t loc_id, const char *group_name, vol_plugin = H5F_get_vol_cls(loc.oloc->file); if (H5I_register_aux(gid, vol_plugin, (H5I_free_t)H5VL_close) < 0) HGOTO_ERROR(H5E_VOL, H5E_CANTINIT, FAIL, "can't attach vol info to ID") - vol_plugin->nrefs++; /* Set up user data for callback */ udata.gid = gid; @@ -1119,7 +1118,6 @@ H5G_visit(hid_t loc_id, const char *group_name, H5_index_t idx_type, vol_plugin = H5F_get_vol_cls(loc.oloc->file); if (H5I_register_aux(gid, vol_plugin, (H5I_free_t)H5VL_close) < 0) HGOTO_ERROR(H5E_VOL, H5E_CANTINIT, FAIL, "can't attach vol info to ID") - vol_plugin->nrefs++; /* Set up user data */ udata.gid = gid; diff --git a/src/H5Gtraverse.c b/src/H5Gtraverse.c index 2ff5477..44362b2 100644 --- a/src/H5Gtraverse.c +++ b/src/H5Gtraverse.c @@ -215,7 +215,6 @@ H5G_traverse_ud(const H5G_loc_t *grp_loc/*in,out*/, const H5O_link_t *lnk, vol_plugin = H5F_get_vol_cls(grp_loc->oloc->file); if (H5I_register_aux(cur_grp, vol_plugin, (H5I_free_t)H5VL_close) < 0) HGOTO_ERROR(H5E_VOL, H5E_CANTINIT, FAIL, "can't attach vol info to ID") - vol_plugin->nrefs++; /* Check for generic default property list and use link access default if so */ if(_lapl_id == H5P_DEFAULT) { diff --git a/src/H5I.c b/src/H5I.c index f4b308f..51823f3 100644 --- a/src/H5I.c +++ b/src/H5I.c @@ -2299,10 +2299,12 @@ H5I_register_aux(hid_t id, void *aux_ptr, H5I_free_t free_func) FUNC_ENTER_NOAPI_NOINIT - if(NULL != (id_ptr = H5I_find_id(id))) { - id_ptr->aux_ptr = aux_ptr; - id_ptr->free_aux = free_func; - } + if(NULL == (id_ptr = H5I_find_id(id))) + HGOTO_ERROR(H5E_ATOM, H5E_CANTGET, FAIL, "Invalid ID") + + id_ptr->aux_ptr = aux_ptr; + id_ptr->free_aux = free_func; + done: FUNC_LEAVE_NOAPI(ret_value) diff --git a/src/H5L.c b/src/H5L.c index 97116ea..ec88fd5 100644 --- a/src/H5L.c +++ b/src/H5L.c @@ -1711,7 +1711,6 @@ H5L_link_cb(H5G_loc_t *grp_loc/*in*/, const char *name, const H5O_link_t UNUSED vol_plugin = H5F_get_vol_cls(grp_loc->oloc->file); if (H5I_register_aux(grp_id, vol_plugin, (H5I_free_t)H5VL_close) < 0) HGOTO_ERROR(H5E_VOL, H5E_CANTINIT, FAIL, "can't attach vol info to ID") - vol_plugin->nrefs++; /* Make callback */ if((link_class->create_func)(name, grp_id, udata->lnk->u.ud.udata, udata->lnk->u.ud.size, H5P_DEFAULT) < 0) diff --git a/src/H5O.c b/src/H5O.c index 2f09b6f..4df3970 100644 --- a/src/H5O.c +++ b/src/H5O.c @@ -227,9 +227,8 @@ H5O_init_interface(void) hid_t H5Oopen(hid_t loc_id, const char *name, hid_t lapl_id) { + H5VL_loc_params_t loc_params; hid_t ret_value = FAIL; - void *location = NULL; /* a pointer to VOL specific token that indicates - the location of the object */ FUNC_ENTER_API(FAIL) H5TRACE3("i", "i*si", loc_id, name, lapl_id); @@ -237,21 +236,14 @@ H5Oopen(hid_t loc_id, const char *name, hid_t lapl_id) if(!name || !*name) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "no name") - /* Get the token for the Object location through the VOL */ - if(H5VL_object_lookup (loc_id, H5VL_OBJECT_LOOKUP_BY_NAME, &location, H5_REQUEST_NULL, name, lapl_id) < 0) - HGOTO_ERROR(H5E_SYM, H5E_CANTINIT, FAIL, "unable to locate object") + loc_params.type = H5VL_OBJECT_LOOKUP_BY_NAME; + loc_params.loc_data.loc_by_name.name = name; /* Open the object through the VOL */ - if((ret_value = H5VL_object_open_by_loc(loc_id, location, lapl_id, H5_REQUEST_NULL)) < 0) + if((ret_value = H5VL_object_open(loc_id, loc_params, lapl_id, H5_REQUEST_NULL)) < 0) HGOTO_ERROR(H5E_SYM, H5E_CANTINIT, FAIL, "unable to open object") done: - if (NULL != location) { - /* free the location token through the VOL */ - if(H5VL_object_free_loc (loc_id, location, H5_REQUEST_NULL) < 0) - HGOTO_ERROR(H5E_SYM, H5E_CANTRELEASE, FAIL, "unable to free location token") - } - FUNC_LEAVE_API(ret_value) } /* end H5Oopen() */ @@ -283,7 +275,7 @@ hid_t H5Oopen_by_idx(hid_t loc_id, const char *group_name, H5_index_t idx_type, H5_iter_order_t order, hsize_t n, hid_t lapl_id) { - void *location = NULL; + H5VL_loc_params_t loc_params; hid_t ret_value = FAIL; FUNC_ENTER_API(FAIL) @@ -302,21 +294,17 @@ 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") - /* Get the token for the Object location through the VOL */ - if(H5VL_object_lookup(loc_id, H5VL_OBJECT_LOOKUP_BY_IDX, &location, H5_REQUEST_NULL, group_name, - idx_type, order, n, lapl_id) < 0) - HGOTO_ERROR(H5E_SYM, H5E_CANTINIT, FAIL, "unable to locate object") + loc_params.type = H5VL_OBJECT_LOOKUP_BY_IDX; + loc_params.loc_data.loc_by_idx.name = group_name; + loc_params.loc_data.loc_by_idx.idx_type = idx_type; + loc_params.loc_data.loc_by_idx.order = order; + loc_params.loc_data.loc_by_idx.n = n; /* Open the object through the VOL */ - if((ret_value = H5VL_object_open_by_loc(loc_id, location, lapl_id, H5_REQUEST_NULL)) < 0) + if((ret_value = H5VL_object_open(loc_id, loc_params, lapl_id, H5_REQUEST_NULL)) < 0) HGOTO_ERROR(H5E_SYM, H5E_CANTINIT, FAIL, "unable to open object") done: - if (NULL != location) { - /* free the location token through the VOL */ - if(H5VL_object_free_loc (loc_id, location, H5_REQUEST_NULL) < 0) - HGOTO_ERROR(H5E_SYM, H5E_CANTRELEASE, FAIL, "unable to free location token") - } FUNC_LEAVE_API(ret_value) } /* end H5Oopen_by_idx() */ @@ -360,26 +348,20 @@ hid_t H5Oopen_by_addr(hid_t loc_id, haddr_t addr) { hid_t lapl_id = H5P_LINK_ACCESS_DEFAULT; /* lapl to use to open this object */ - void *location = NULL; + H5VL_loc_params_t loc_params; hid_t ret_value = FAIL; FUNC_ENTER_API(FAIL) H5TRACE2("i", "ia", loc_id, addr); - /* Get the token for the Object location through the VOL */ - if(H5VL_object_lookup (loc_id, H5VL_OBJECT_LOOKUP_BY_ADDR, &location, H5_REQUEST_NULL, addr) < 0) - HGOTO_ERROR(H5E_SYM, H5E_CANTINIT, FAIL, "unable to locate object") + loc_params.type = H5VL_OBJECT_LOOKUP_BY_ADDR; + loc_params.loc_data.loc_by_addr.addr = addr; /* Open the object through the VOL */ - if((ret_value = H5VL_object_open_by_loc(loc_id, location, lapl_id, H5_REQUEST_NULL)) < 0) + if((ret_value = H5VL_object_open(loc_id, loc_params, lapl_id, H5_REQUEST_NULL)) < 0) HGOTO_ERROR(H5E_SYM, H5E_CANTINIT, FAIL, "unable to open object") done: - if (NULL != location) { - /* free the location token through the VOL */ - if(H5VL_object_free_loc (loc_id, location, H5_REQUEST_NULL) < 0) - HGOTO_ERROR(H5E_SYM, H5E_CANTRELEASE, FAIL, "unable to free location token") - } FUNC_LEAVE_API(ret_value) } /* end H5Oopen_by_addr() */ diff --git a/src/H5Pacpl.c b/src/H5Pacpl.c index 04ab1b9..e73ef21 100644 --- a/src/H5Pacpl.c +++ b/src/H5Pacpl.c @@ -44,8 +44,8 @@ /****************/ /* Definitions for UDATA */ -#define H5A_CRT_LOCATION_SIZE sizeof(void *) -#define H5A_CRT_LOCATION_DEF NULL +#define H5A_CRT_LOCATION_SIZE sizeof(H5VL_loc_params_t) +#define H5A_CRT_LOCATION_DEF {H5VL_OBJECT_LOOKUP_BY_ID, {{FAIL}}} /******************/ /* Local Typedefs */ @@ -105,7 +105,7 @@ H5P_acrt_reg_prop(H5P_genclass_t *pclass) { hid_t type_id = FAIL; hid_t space_id = FAIL; - void *location = H5A_CRT_LOCATION_DEF; + H5VL_loc_params_t loc_params = H5A_CRT_LOCATION_DEF; herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_NOAPI_NOINIT @@ -121,7 +121,7 @@ H5P_acrt_reg_prop(H5P_genclass_t *pclass) HGOTO_ERROR(H5E_PLIST, H5E_CANTINSERT, FAIL, "can't insert property into class") /* Register the lcpl ID property */ - if(H5P_register_real(pclass, H5VL_ATTR_LOCATION, H5A_CRT_LOCATION_SIZE, &location, + if(H5P_register_real(pclass, H5VL_ATTR_LOC_PARAMS, H5A_CRT_LOCATION_SIZE, &loc_params, NULL, NULL, NULL, NULL, NULL, NULL, NULL) < 0) HGOTO_ERROR(H5E_PLIST, H5E_CANTINSERT, FAIL, "can't insert property into class") diff --git a/src/H5R.c b/src/H5R.c index bfead4a..4ce37da 100644 --- a/src/H5R.c +++ b/src/H5R.c @@ -511,8 +511,7 @@ done: hid_t H5Rdereference2(hid_t obj_id, hid_t oapl_id, H5R_type_t ref_type, const void *_ref) { - void *location = NULL; /* a pointer to VOL specific token that indicates - the location of the object */ + H5VL_loc_params_t loc_params; hid_t ret_value; FUNC_ENTER_API(FAIL) @@ -526,15 +525,14 @@ H5Rdereference2(hid_t obj_id, hid_t oapl_id, H5R_type_t ref_type, const void *_r if(_ref == NULL) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "invalid reference pointer") - /* Get the token for the Object location through the VOL */ - if(H5VL_object_lookup (obj_id, H5VL_OBJECT_LOOKUP_BY_REF, &location, H5_REQUEST_NULL, - ref_type, _ref) < 0) - HGOTO_ERROR(H5E_SYM, H5E_CANTINIT, FAIL, "unable to locate object") - + loc_params.type = H5VL_OBJECT_LOOKUP_BY_REF; + loc_params.loc_data.loc_by_ref.ref_type = ref_type; + loc_params.loc_data.loc_by_ref._ref = _ref; /* Open the object through the VOL */ - if((ret_value = H5VL_object_open_by_loc(obj_id, location, oapl_id, H5_REQUEST_NULL)) < 0) + if((ret_value = H5VL_object_open(obj_id, loc_params, oapl_id, H5_REQUEST_NULL)) < 0) HGOTO_ERROR(H5E_SYM, H5E_CANTINIT, FAIL, "unable to open object") + #if 0 /* Create reference */ if((ret_value = H5R_dereference(file, oapl_id, H5AC_dxpl_id, ref_type, _ref, TRUE)) < 0) @@ -542,11 +540,6 @@ H5Rdereference2(hid_t obj_id, hid_t oapl_id, H5R_type_t ref_type, const void *_r #endif done: - if (NULL != location) { - /* free the location token through the VOL */ - if(H5VL_object_free_loc (obj_id, location, H5_REQUEST_NULL) < 0) - HGOTO_ERROR(H5E_SYM, H5E_CANTRELEASE, FAIL, "unable to free location token") - } FUNC_LEAVE_API(ret_value) } /* end H5Rdereference2() */ diff --git a/src/H5Rdeprec.c b/src/H5Rdeprec.c index e6d8d21..a595c90 100644 --- a/src/H5Rdeprec.c +++ b/src/H5Rdeprec.c @@ -182,8 +182,7 @@ done: hid_t H5Rdereference1(hid_t obj_id, H5R_type_t ref_type, const void *_ref) { - void *location = NULL; /* a pointer to VOL specific token that indicates - the location of the object */ + H5VL_loc_params_t loc_params; hid_t ret_value; FUNC_ENTER_API(FAIL) @@ -195,21 +194,15 @@ H5Rdereference1(hid_t obj_id, H5R_type_t ref_type, const void *_ref) if(_ref == NULL) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "invalid reference pointer") - /* Get the token for the Object location through the VOL */ - if(H5VL_object_lookup (obj_id, H5VL_OBJECT_LOOKUP_BY_REF, &location, H5_REQUEST_NULL, - ref_type, _ref) < 0) - HGOTO_ERROR(H5E_SYM, H5E_CANTINIT, FAIL, "unable to locate object") + loc_params.type = H5VL_OBJECT_LOOKUP_BY_REF; + loc_params.loc_data.loc_by_ref.ref_type = ref_type; + loc_params.loc_data.loc_by_ref._ref = _ref; /* Open the object through the VOL */ - if((ret_value = H5VL_object_open_by_loc(obj_id, location, H5P_DATASET_ACCESS_DEFAULT, H5_REQUEST_NULL)) < 0) + if((ret_value = H5VL_object_open(obj_id, loc_params, H5P_DATASET_ACCESS_DEFAULT, H5_REQUEST_NULL)) < 0) HGOTO_ERROR(H5E_SYM, H5E_CANTINIT, FAIL, "unable to open object") done: - if (NULL != location) { - /* free the location token through the VOL */ - if(H5VL_object_free_loc (obj_id, location, H5_REQUEST_NULL) < 0) - HGOTO_ERROR(H5E_SYM, H5E_CANTRELEASE, FAIL, "unable to free location token") - } FUNC_LEAVE_API(ret_value) } /* end H5Rdereference1() */ diff --git a/src/H5VL.c b/src/H5VL.c index f4412d2..2d7823f 100644 --- a/src/H5VL.c +++ b/src/H5VL.c @@ -268,6 +268,37 @@ done: /*------------------------------------------------------------------------- + * Function: H5VLis_registered + * + * Purpose: Tests whether a VOL class has been registered or not + * + * Return: Positive if the VOL class has been registered + * Zero if it is unregistered + * Negative on error (if the class is not a valid class ID) + * + * Programmer: Mohamad Chaarawi + * June 2012 + * + *------------------------------------------------------------------------- + */ +htri_t +H5VLis_registered(hid_t id) +{ + htri_t ret_value = FALSE; /* Return value */ + + FUNC_ENTER_API(FAIL) + H5TRACE1("t", "Ll", id); + + /* Check arguments */ + if(NULL != H5I_object_verify(id, H5I_VOL)) + ret_value = TRUE; + +done: + FUNC_LEAVE_API(ret_value) +} /* end H5VLis_registered() */ + + +/*------------------------------------------------------------------------- * Function: H5VLget_plugin_name * * Purpose: Returns the plugin name for the VOL associated with the diff --git a/src/H5VLdummy.c b/src/H5VLdummy.c index 7be5825..22d2500 100644 --- a/src/H5VLdummy.c +++ b/src/H5VLdummy.c @@ -55,21 +55,20 @@ static hid_t H5VL_DUMMY_g = 0; /* Prototypes */ static herr_t H5VL_dummy_term(void); -static hid_t H5VL_dummy_file_open(const char *name, unsigned flags, hid_t fapl_id); -static herr_t H5VL_dummy_file_close(hid_t fid); -static hid_t H5VL_dummy_file_create(const char *name, unsigned flags, hid_t fcpl_id, hid_t fapl_id); +static hid_t H5VL_dummy_file_open(const char *name, unsigned flags, hid_t fapl_id, hid_t req); +static herr_t H5VL_dummy_file_close(hid_t fid, hid_t req); +static hid_t H5VL_dummy_file_create(const char *name, unsigned flags, hid_t fcpl_id, hid_t fapl_id, hid_t req); H5VL_class_t H5VL_dummy_g = { "dummy", /* name */ - 0, /* nrefs */ - H5VL_dummy_init, + NULL, H5VL_dummy_term, /*terminate */ { /* attribute_cls */ NULL, /* create */ NULL, /* open */ NULL, /* read */ NULL, /* write */ - NULL, /* delete */ + NULL, /* get */ NULL, /* delete */ NULL /* close */ }, @@ -93,6 +92,7 @@ H5VL_class_t H5VL_dummy_g = { NULL, NULL, NULL, + NULL, H5VL_dummy_file_close /* close */ }, { /* group_cls */ @@ -105,6 +105,7 @@ H5VL_class_t H5VL_dummy_g = { NULL, /* create */ NULL, /* delete */ NULL, /* move */ + NULL, NULL }, { /* object_cls */ @@ -112,6 +113,10 @@ H5VL_class_t H5VL_dummy_g = { NULL, /* copy */ NULL, NULL, + NULL, + NULL, + NULL, + NULL, NULL } }; @@ -162,7 +167,6 @@ H5VL_dummy_init(void) /* Set return value */ ret_value = &H5VL_dummy_g; - ret_value->nrefs ++; FUNC_LEAVE_NOAPI(ret_value) } /* end H5VL_dummy_init() */ @@ -187,7 +191,6 @@ H5VL_dummy_term(void) /* Reset VOL ID */ H5VL_DUMMY_g = 0; - H5VL_dummy_g.nrefs = 0; FUNC_LEAVE_NOAPI(SUCCEED) } /* end H5VL_dummy_term() */ @@ -239,7 +242,7 @@ done: *------------------------------------------------------------------------- */ static hid_t -H5VL_dummy_file_open(const char *name, unsigned flags, hid_t fapl_id) +H5VL_dummy_file_open(const char *name, unsigned flags, hid_t fapl_id, hid_t req) { FUNC_ENTER_NOAPI_NOINIT_NOERR @@ -263,7 +266,7 @@ H5VL_dummy_file_open(const char *name, unsigned flags, hid_t fapl_id) *------------------------------------------------------------------------- */ static hid_t -H5VL_dummy_file_create(const char *name, unsigned flags, hid_t fcpl_id, hid_t fapl_id) +H5VL_dummy_file_create(const char *name, unsigned flags, hid_t fcpl_id, hid_t fapl_id, hid_t req) { FUNC_ENTER_NOAPI_NOINIT_NOERR @@ -287,7 +290,7 @@ H5VL_dummy_file_create(const char *name, unsigned flags, hid_t fcpl_id, hid_t fa *------------------------------------------------------------------------- */ static herr_t -H5VL_dummy_file_close(hid_t file_id) +H5VL_dummy_file_close(hid_t file_id, hid_t req) { FUNC_ENTER_NOAPI_NOINIT_NOERR diff --git a/src/H5VLint.c b/src/H5VLint.c index 00e64c8..6371ef3 100644 --- a/src/H5VLint.c +++ b/src/H5VLint.c @@ -189,9 +189,6 @@ H5VL_fapl_open(H5P_genplist_t *plist, H5VL_class_t *vol_cls) FUNC_ENTER_NOAPI(FAIL) - /* Increment the reference count on vol and copy vol info */ - vol_cls->nrefs++; - /* Set the vol properties for the list */ if(H5P_set(plist, H5F_ACS_VOL_NAME, &vol_cls) < 0) HGOTO_ERROR(H5E_FILE, H5E_CANTSET, FAIL, "can't set vol ID") @@ -223,10 +220,6 @@ H5VL_fapl_close(H5VL_class_t *vol_cls) FUNC_ENTER_NOAPI(FAIL) - if(NULL != vol_cls) { - vol_cls->nrefs--; - } - done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5VL_fapl_close() */ @@ -252,8 +245,6 @@ H5VL_close(H5VL_class_t *vol_plugin) FUNC_ENTER_NOAPI(FAIL) - vol_plugin->nrefs--; - done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5VL_close() */ @@ -336,7 +327,6 @@ H5VL_attr_create(hid_t id, const char *name, hid_t acpl_id, hid_t aapl_id, hid_t /* attach VOL information to the ID */ if (H5I_register_aux(ret_value, vol_plugin, (H5I_free_t)H5VL_close) < 0) HGOTO_ERROR(H5E_VOL, H5E_CANTINIT, FAIL, "can't attach vol info to ID") - vol_plugin->nrefs++; done: FUNC_LEAVE_NOAPI(ret_value) @@ -358,7 +348,7 @@ done: *------------------------------------------------------------------------- */ hid_t -H5VL_attr_open(hid_t id, void *location, const char *name, hid_t aapl_id, hid_t req) +H5VL_attr_open(hid_t id, H5VL_loc_params_t loc_params, const char *name, hid_t aapl_id, hid_t req) { H5VL_class_t *vol_plugin; /* VOL structure attached to id */ hid_t ret_value; /* Return value */ @@ -374,13 +364,12 @@ H5VL_attr_open(hid_t id, void *location, const char *name, hid_t aapl_id, hid_t } /* call the corresponding VOL open callback */ - if((ret_value = (vol_plugin->attr_cls.open) (id, location, name, aapl_id, req)) < 0) + if((ret_value = (vol_plugin->attr_cls.open) (id, loc_params, name, aapl_id, req)) < 0) HGOTO_ERROR(H5E_VOL, H5E_CANTINIT, FAIL, "open failed") /* attach VOL information to the ID */ if (H5I_register_aux(ret_value, vol_plugin, (H5I_free_t)H5VL_close) < 0) HGOTO_ERROR(H5E_VOL, H5E_CANTINIT, FAIL, "can't attach vol info to ID") - vol_plugin->nrefs++; done: FUNC_LEAVE_NOAPI(ret_value) @@ -500,7 +489,6 @@ H5VL_attr_get(hid_t id, H5VL_attr_get_t get_type, hid_t req, ...) /* attach VOL information to the ID */ if (H5I_register_aux(*ret_id, vol_plugin, (H5I_free_t)H5VL_close) < 0) HGOTO_ERROR(H5E_VOL, H5E_CANTINIT, FAIL, "can't attach vol info to ID") - vol_plugin->nrefs++; } va_end (arguments); } @@ -620,7 +608,6 @@ H5VL_datatype_commit(hid_t id, const char *name, hid_t type_id, hid_t lcpl_id, if (H5I_register_aux(type_id, vol_plugin, (H5I_free_t)H5VL_close) < 0) HGOTO_ERROR(H5E_VOL, H5E_CANTINIT, FAIL, "can't attach vol info to ID") - vol_plugin->nrefs++; done: FUNC_LEAVE_NOAPI(ret_value) @@ -651,24 +638,17 @@ H5VL_datatype_open(hid_t id, const char *name, hid_t tapl_id, hid_t req) if (NULL == (vol_plugin = (H5VL_class_t *)H5I_get_aux(id))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "ID does not contain VOL information") + /* check if the type specific corresponding VOL open callback exists */ if(NULL == vol_plugin->datatype_cls.open) { - void *location = NULL; /* a pointer to VOL specific token that indicates - the location of the object */ + H5VL_loc_params_t loc_params; - /* Get the token for the Object location through the VOL */ - if(H5VL_object_lookup (id, H5VL_OBJECT_LOOKUP_BY_NAME, &location, req, name, tapl_id) < 0) - HGOTO_ERROR(H5E_SYM, H5E_CANTINIT, FAIL, "unable to locate object") + loc_params.type = H5VL_OBJECT_LOOKUP_BY_NAME; + loc_params.loc_data.loc_by_name.name = name; - /* Open the object through the VOL */ - if((ret_value = H5VL_object_open_by_loc(id, location, tapl_id, req)) < 0) + /* Open the object class */ + if((ret_value = H5VL_object_open(id, loc_params, tapl_id, H5_REQUEST_NULL)) < 0) HGOTO_ERROR(H5E_SYM, H5E_CANTINIT, FAIL, "unable to open object") - - if (NULL != location) { - /* free the location token through the VOL */ - if(H5VL_object_free_loc (id, location, H5_REQUEST_NULL) < 0) - HGOTO_ERROR(H5E_SYM, H5E_CANTRELEASE, FAIL, "unable to free location token") - } } else { /* call the corresponding VOL open callback */ @@ -678,7 +658,6 @@ H5VL_datatype_open(hid_t id, const char *name, hid_t tapl_id, hid_t req) /* attach VOL information to the ID */ if (H5I_register_aux(ret_value, vol_plugin, (H5I_free_t)H5VL_close) < 0) HGOTO_ERROR(H5E_VOL, H5E_CANTINIT, FAIL, "can't attach vol info to ID") - vol_plugin->nrefs++; } done: FUNC_LEAVE_NOAPI(ret_value) @@ -758,7 +737,6 @@ H5VL_dataset_create(hid_t id, const char *name, hid_t dcpl_id, hid_t dapl_id, hi /* attach VOL information to the ID */ if (H5I_register_aux(ret_value, vol_plugin, (H5I_free_t)H5VL_close) < 0) HGOTO_ERROR(H5E_VOL, H5E_CANTINIT, FAIL, "can't attach vol info to ID") - vol_plugin->nrefs++; done: FUNC_LEAVE_NOAPI(ret_value) @@ -792,22 +770,14 @@ H5VL_dataset_open(hid_t id, const char *name, hid_t dapl_id, hid_t req) /* check if the type specific corresponding VOL open callback exists */ if(NULL == vol_plugin->dataset_cls.open) { - void *location = NULL; /* a pointer to VOL specific token that indicates - the location of the object */ + H5VL_loc_params_t loc_params; - /* Get the token for the Object location through the VOL */ - if(H5VL_object_lookup (id, H5VL_OBJECT_LOOKUP_BY_NAME, &location, req, name, dapl_id) < 0) - HGOTO_ERROR(H5E_SYM, H5E_CANTINIT, FAIL, "unable to locate object") + loc_params.type = H5VL_OBJECT_LOOKUP_BY_NAME; + loc_params.loc_data.loc_by_name.name = name; - /* Open the object through the VOL */ - if((ret_value = H5VL_object_open_by_loc(id, location, dapl_id, req)) < 0) + /* Open the object class */ + if((ret_value = H5VL_object_open(id, loc_params, dapl_id, H5_REQUEST_NULL)) < 0) HGOTO_ERROR(H5E_SYM, H5E_CANTINIT, FAIL, "unable to open object") - - if (NULL != location) { - /* free the location token through the VOL */ - if(H5VL_object_free_loc (id, location, H5_REQUEST_NULL) < 0) - HGOTO_ERROR(H5E_SYM, H5E_CANTRELEASE, FAIL, "unable to free location token") - } } else { /* call the corresponding VOL open callback */ @@ -817,7 +787,6 @@ H5VL_dataset_open(hid_t id, const char *name, hid_t dapl_id, hid_t req) /* attach VOL information to the ID */ if (H5I_register_aux(ret_value, vol_plugin, (H5I_free_t)H5VL_close) < 0) HGOTO_ERROR(H5E_VOL, H5E_CANTINIT, FAIL, "can't attach vol info to ID") - vol_plugin->nrefs++; } done: FUNC_LEAVE_NOAPI(ret_value) @@ -978,7 +947,6 @@ H5VL_dataset_get(hid_t id, H5VL_dataset_get_t get_type, hid_t req, ...) /* attach VOL information to the ID */ if (H5I_register_aux(*ret_id, vol_plugin, (H5I_free_t)H5VL_close) < 0) HGOTO_ERROR(H5E_VOL, H5E_CANTINIT, FAIL, "can't attach vol info to ID") - vol_plugin->nrefs++; } va_end (arguments); } @@ -1067,7 +1035,6 @@ H5VL_file_open(const char *name, unsigned flags, hid_t fapl_id, hid_t req) /* attach VOL information to the ID */ if (H5I_register_aux(ret_value, vol_plugin, (H5I_free_t)H5VL_close) < 0) HGOTO_ERROR(H5E_VOL, H5E_CANTINIT, FAIL, "can't attach vol info to ID") - vol_plugin->nrefs++; done: FUNC_LEAVE_NOAPI(ret_value) @@ -1113,7 +1080,6 @@ H5VL_file_create(const char *name, unsigned flags, hid_t fcpl_id, hid_t fapl_id, /* attach VOL information to the ID */ if (H5I_register_aux(ret_value, vol_plugin, (H5I_free_t)H5VL_close) < 0) HGOTO_ERROR(H5E_VOL, H5E_CANTINIT, FAIL, "can't attach vol info to ID") - vol_plugin->nrefs++; done: FUNC_LEAVE_NOAPI(ret_value) @@ -1275,7 +1241,6 @@ H5VL_file_optional(hid_t id, H5VL_file_optional_t optional_type, hid_t req, ...) /* attach VOL information to the ID */ if (H5I_register_aux(*ret_id, vol_plugin, (H5I_free_t)H5VL_close) < 0) HGOTO_ERROR(H5E_VOL, H5E_CANTINIT, FAIL, "can't attach vol info to ID") - vol_plugin->nrefs++; va_end (arguments); } @@ -1355,7 +1320,6 @@ H5VL_group_create(hid_t id, const char *name, hid_t gcpl_id, hid_t gapl_id, hid_ /* attach VOL information to the ID */ if (H5I_register_aux(ret_value, vol_plugin, (H5I_free_t)H5VL_close) < 0) HGOTO_ERROR(H5E_VOL, H5E_CANTINIT, FAIL, "can't attach vol info to ID") - vol_plugin->nrefs++; done: FUNC_LEAVE_NOAPI(ret_value) @@ -1389,22 +1353,14 @@ H5VL_group_open(hid_t id, const char *name, hid_t gapl_id, hid_t req) /* check if the type specific corresponding VOL open callback exists */ if(NULL == vol_plugin->group_cls.open) { - void *location = NULL; /* a pointer to VOL specific token that indicates - the location of the object */ + H5VL_loc_params_t loc_params; - /* Get the token for the Object location through the VOL */ - if(H5VL_object_lookup (id, H5VL_OBJECT_LOOKUP_BY_NAME, &location, req, name, gapl_id) < 0) - HGOTO_ERROR(H5E_SYM, H5E_CANTINIT, FAIL, "unable to locate object") + loc_params.type = H5VL_OBJECT_LOOKUP_BY_NAME; + loc_params.loc_data.loc_by_name.name = name; - /* Open the object through the VOL */ - if((ret_value = H5VL_object_open_by_loc(id, location, gapl_id, req)) < 0) + /* Open the object class */ + if((ret_value = H5VL_object_open(id, loc_params, gapl_id, H5_REQUEST_NULL)) < 0) HGOTO_ERROR(H5E_SYM, H5E_CANTINIT, FAIL, "unable to open object") - - if (NULL != location) { - /* free the location token through the VOL */ - if(H5VL_object_free_loc (id, location, H5_REQUEST_NULL) < 0) - HGOTO_ERROR(H5E_SYM, H5E_CANTRELEASE, FAIL, "unable to free location token") - } } else { /* call the corresponding VOL open callback */ @@ -1414,7 +1370,6 @@ H5VL_group_open(hid_t id, const char *name, hid_t gapl_id, hid_t req) /* attach VOL information to the ID */ if (H5I_register_aux(ret_value, vol_plugin, (H5I_free_t)H5VL_close) < 0) HGOTO_ERROR(H5E_VOL, H5E_CANTINIT, FAIL, "can't attach vol info to ID") - vol_plugin->nrefs++; } done: FUNC_LEAVE_NOAPI(ret_value) @@ -1718,7 +1673,7 @@ done: /*------------------------------------------------------------------------- - * Function: H5VL_object_open_by_loc + * Function: H5VL_object_open * * Purpose: Opens a object through the VOL * @@ -1732,7 +1687,7 @@ done: *------------------------------------------------------------------------- */ hid_t -H5VL_object_open_by_loc(hid_t id, void *obj_loc, hid_t lapl_id, hid_t req) +H5VL_object_open(hid_t id, H5VL_loc_params_t params, hid_t lapl_id, hid_t req) { H5VL_class_t *vol_plugin; /* VOL structure attached to id */ hid_t ret_value; /* Return value */ @@ -1747,17 +1702,16 @@ H5VL_object_open_by_loc(hid_t id, void *obj_loc, hid_t lapl_id, hid_t req) HGOTO_ERROR(H5E_VOL, H5E_UNSUPPORTED, FAIL, "vol plugin has no `object open' method") /* call the corresponding VOL open callback */ - if((ret_value = (vol_plugin->object_cls.open)(obj_loc, lapl_id, req)) < 0) + if((ret_value = (vol_plugin->object_cls.open)(id, params, lapl_id, req)) < 0) HGOTO_ERROR(H5E_VOL, H5E_CANTINIT, FAIL, "open failed") /* attach VOL information to the ID */ if (H5I_register_aux(ret_value, vol_plugin, (H5I_free_t)H5VL_close) < 0) HGOTO_ERROR(H5E_VOL, H5E_CANTINIT, FAIL, "can't attach vol info to ID") - vol_plugin->nrefs++; done: FUNC_LEAVE_NOAPI(ret_value) -} /* end H5VL_object_open_by_loc() */ +} /* end H5VL_object_open() */ /*------------------------------------------------------------------------- @@ -1988,12 +1942,9 @@ H5VL_object_misc(hid_t id, H5VL_object_misc_t misc_type, hid_t req, ...) va_start (arguments, req); ret_id = va_arg (arguments, hid_t *); - /* attach VOL information to the ID */ if (H5I_register_aux(*ret_id, vol_plugin, (H5I_free_t)H5VL_close) < 0) HGOTO_ERROR(H5E_VOL, H5E_CANTINIT, FAIL, "can't attach vol info to ID") - vol_plugin->nrefs++; - va_end (arguments); } done: diff --git a/src/H5VLnative.c b/src/H5VLnative.c index 1ef7b09..db9c0ab 100644 --- a/src/H5VLnative.c +++ b/src/H5VLnative.c @@ -65,7 +65,7 @@ static hid_t H5VL_NATIVE_g = 0; static herr_t H5VL_native_term(void); static hid_t H5VL_native_attr_create(hid_t loc_id, const char *attr_name, hid_t acpl_id, hid_t aapl_id, hid_t req); -static hid_t H5VL_native_attr_open(hid_t loc_id, void *location, const char *attr_name, hid_t aapl_id, hid_t req); +static hid_t H5VL_native_attr_open(hid_t loc_id, H5VL_loc_params_t loc_params, const char *attr_name, hid_t aapl_id, hid_t req); static herr_t H5VL_native_attr_read(hid_t attr_id, hid_t dtype_id, void *buf, hid_t req); static herr_t H5VL_native_attr_write(hid_t attr_id, hid_t dtype_id, const void *buf, hid_t req); static herr_t H5VL_native_attr_get(hid_t id, H5VL_attr_get_t get_type, hid_t req, va_list arguments); @@ -109,7 +109,7 @@ static herr_t H5VL_native_link_iterate(hid_t loc_id, const char *name, hbool_t r static herr_t H5VL_native_link_get(hid_t loc_id, H5VL_link_get_t get_type, hid_t req, va_list arguments); static herr_t H5VL_native_link_remove(hid_t loc_id, const char *name, void *udata, hid_t lapl_id, hid_t req); -static hid_t H5VL_native_object_open(void *location, hid_t lapl_id, hid_t req); +static hid_t H5VL_native_object_open(hid_t loc_id, H5VL_loc_params_t params, hid_t lapl_id, hid_t req); static herr_t H5VL_native_object_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, hid_t req); static herr_t H5VL_native_object_visit(hid_t loc_id, const char *obj_name, H5_index_t idx_type, @@ -124,7 +124,6 @@ static herr_t H5VL_native_object_close(hid_t object_id, hid_t req); static H5VL_class_t H5VL_native_g = { "native", /* name */ - 0, /* nrefs */ NULL, /* initialize */ H5VL_native_term, /* terminate */ { /* attribute_cls */ @@ -231,7 +230,6 @@ H5VL_native_init(void) /* Set return value */ ret_value = &H5VL_native_g; - ret_value->nrefs ++; FUNC_LEAVE_NOAPI(ret_value) } /* end H5VL_native_init() */ @@ -256,7 +254,6 @@ H5VL_native_term(void) /* Reset VOL ID */ H5VL_NATIVE_g = 0; - H5VL_native_g.nrefs = 0; FUNC_LEAVE_NOAPI(SUCCEED) } /* end H5VL_native_term() */ @@ -311,11 +308,13 @@ static hid_t H5VL_native_attr_create(hid_t loc_id, const char *attr_name, hid_t acpl_id, hid_t UNUSED aapl_id, hid_t UNUSED req) { H5G_loc_t loc; /* Object location */ + H5G_loc_t obj_loc; /* Location used to open group */ + hbool_t loc_found = FALSE; H5P_genplist_t *plist; /* Property list pointer */ hid_t type_id, space_id; H5T_t *type; /* Datatype to use for attribute */ H5S_t *space; /* Dataspace to use for attribute */ - void *location = NULL; + H5VL_loc_params_t loc_params; hid_t ret_value; FUNC_ENTER_NOAPI_NOINIT @@ -329,7 +328,7 @@ H5VL_native_attr_create(hid_t loc_id, const char *attr_name, hid_t acpl_id, hid_ HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, FAIL, "can't get property value for datatype id") if(H5P_get(plist, H5VL_ATTR_SPACE_ID, &space_id) < 0) HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, FAIL, "can't get property value for space id") - if(H5P_get(plist, H5VL_ATTR_LOCATION, &location) < 0) + if(H5P_get(plist, H5VL_ATTR_LOC_PARAMS, &loc_params) < 0) HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, FAIL, "can't get property value for lcpl id") if(H5G_loc(loc_id, &loc) < 0) @@ -341,21 +340,38 @@ H5VL_native_attr_create(hid_t loc_id, const char *attr_name, hid_t acpl_id, hid_ if(NULL == (space = (H5S_t *)H5I_object_verify(space_id, H5I_DATASPACE))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a data space") - if(NULL == location) { /* H5Acreate */ + if(loc_params.type == H5VL_OBJECT_LOOKUP_BY_ID) { /* H5Acreate */ /* Go do the real work for attaching the attribute to the dataset */ if((ret_value = H5A_create(&loc, attr_name, type, space, acpl_id, H5AC_dxpl_id)) < 0) HGOTO_ERROR(H5E_ATTR, H5E_CANTINIT, FAIL, "unable to create attribute") } - else { /* H5Acreate_by_name */ - H5G_loc_t *obj_loc = (H5G_loc_t *)location; + else if (loc_params.type == H5VL_OBJECT_LOOKUP_BY_NAME) { /* H5Acreate_by_name */ + H5G_name_t obj_path; /* Opened object group hier. path */ + H5O_loc_t obj_oloc; /* Opened object object location */ + + /* Set up opened group location to fill in */ + obj_loc.oloc = &obj_oloc; + obj_loc.path = &obj_path; + H5G_loc_reset(&obj_loc); + + /* Find the object's location */ + if(H5G_loc_find(&loc, loc_params.loc_data.loc_by_name.name, &obj_loc/*out*/, + loc_params.loc_data.loc_by_name.lapl_id, H5AC_ind_dxpl_id) < 0) + HGOTO_ERROR(H5E_ATTR, H5E_NOTFOUND, FAIL, "object not found") + loc_found = TRUE; /* Go do the real work for attaching the attribute to the dataset */ - if((ret_value = H5A_create(obj_loc, attr_name, type, space, acpl_id, H5AC_dxpl_id)) < 0) + if((ret_value = H5A_create(&obj_loc, attr_name, type, space, acpl_id, H5AC_dxpl_id)) < 0) HGOTO_ERROR(H5E_ATTR, H5E_CANTINIT, FAIL, "unable to create attribute") } - + else { + HGOTO_ERROR(H5E_VOL, H5E_UNSUPPORTED, FAIL, "unknown attribute create parameters") + } done: - FUNC_LEAVE_NOAPI(ret_value) + /* Release resources */ + if(loc_found && H5G_loc_free(&obj_loc) < 0) + HDONE_ERROR(H5E_ATTR, H5E_CANTRELEASE, FAIL, "can't free location") + FUNC_LEAVE_NOAPI(ret_value) } /* end H5VL_native_attr_create() */ @@ -373,7 +389,8 @@ done: *------------------------------------------------------------------------- */ static hid_t -H5VL_native_attr_open(hid_t loc_id, void *location, const char *attr_name, hid_t UNUSED aapl_id, hid_t UNUSED req) +H5VL_native_attr_open(hid_t loc_id, H5VL_loc_params_t loc_params, const char *attr_name, + hid_t UNUSED aapl_id, hid_t UNUSED req) { H5G_loc_t loc; /* Object location */ H5A_t *attr = NULL; /* Attribute opened */ @@ -387,22 +404,28 @@ H5VL_native_attr_open(hid_t loc_id, void *location, const char *attr_name, hid_t if(H5G_loc(loc_id, &loc) < 0) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a location") - if(NULL != location) { /* H5Aopen_by_name */ - H5G_loc_t *obj_loc = (H5G_loc_t *)location; - - /* Read in attribute from object header */ - if(NULL == (attr = H5O_attr_open_by_name(obj_loc->oloc, attr_name, H5AC_ind_dxpl_id))) - HGOTO_ERROR(H5E_ATTR, H5E_CANTINIT, FAIL, "unable to load attribute info from object header") - } - else { /* H5Aopen */ + if(loc_params.type == H5VL_OBJECT_LOOKUP_BY_ID) { /* H5Aopen */ /* Read in attribute from object header */ if(NULL == (attr = H5O_attr_open_by_name(loc.oloc, attr_name, H5AC_ind_dxpl_id))) HGOTO_ERROR(H5E_ATTR, H5E_CANTINIT, FAIL, "unable to load attribute info from object header for attribute: '%s'", attr_name) + /* Finish initializing attribute */ + if(H5A_open_common(&loc, attr) < 0) + HGOTO_ERROR(H5E_ATTR, H5E_CANTINIT, FAIL, "unable to initialize attribute") + } + else if(loc_params.type == H5VL_OBJECT_LOOKUP_BY_NAME) { /* H5Aopen_by_name */ + H5G_loc_t obj_loc; /* Location used to open group */ + H5G_name_t obj_path; /* Opened object group hier. path */ + H5O_loc_t obj_oloc; /* Opened object object location */ + hbool_t loc_found = FALSE; /* Entry at 'obj_name' found */ + + /* Open the attribute on the object header */ + if(NULL == (attr = H5A_open_by_name(&loc, loc_params.loc_data.loc_by_name.name, attr_name, + loc_params.loc_data.loc_by_name.lapl_id, H5AC_ind_dxpl_id))) + HGOTO_ERROR(H5E_ATTR, H5E_CANTOPENOBJ, FAIL, "can't open attribute") + } + else { + HGOTO_ERROR(H5E_VOL, H5E_UNSUPPORTED, FAIL, "unknown attribute open parameters") } - - /* Finish initializing attribute */ - if(H5A_open_common(&loc, attr) < 0) - HGOTO_ERROR(H5E_ATTR, H5E_CANTINIT, FAIL, "unable to initialize attribute") /* Register the attribute and get an ID for it */ if((ret_value = H5I_register(H5I_ATTR, attr, TRUE)) < 0) @@ -2596,22 +2619,91 @@ done: *------------------------------------------------------------------------- */ static hid_t -H5VL_native_object_open(void *location, hid_t lapl_id, hid_t UNUSED req) +H5VL_native_object_open(hid_t loc_id, H5VL_loc_params_t params, hid_t lapl_id, hid_t UNUSED req) { - H5G_loc_t *obj_loc = (H5G_loc_t *)location; + H5G_loc_t loc; + H5G_loc_t obj_loc; /* Location used to open group */ + H5G_name_t obj_path; /* Opened object group hier. path */ + H5O_loc_t obj_oloc; /* Opened object object location */ + hbool_t loc_found = FALSE; /* Entry at 'name' found */ hid_t ret_value = FAIL; FUNC_ENTER_NOAPI_NOINIT - /* Check args */ - if(!H5F_addr_defined(obj_loc->oloc->addr)) - HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "no address supplied") + if(H5G_loc(loc_id, &loc) < 0) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a location") - /* 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") + switch (params.type) { + case H5VL_OBJECT_LOOKUP_BY_NAME: + { + /* Open the object */ + if((ret_value = H5O_open_name(&loc, params.loc_data.loc_by_name.name, lapl_id, + TRUE)) < 0) + HGOTO_ERROR(H5E_SYM, H5E_CANTOPENOBJ, FAIL, "unable to open object") + break; + } + case H5VL_OBJECT_LOOKUP_BY_IDX: + { + /* Set up opened group location to fill in */ + obj_loc.oloc = &obj_oloc; + obj_loc.path = &obj_path; + H5G_loc_reset(&obj_loc); + + /* Find the object's location, according to the order in the index */ + if(H5G_loc_find_by_idx(&loc, params.loc_data.loc_by_idx.name, + params.loc_data.loc_by_idx.idx_type, + params.loc_data.loc_by_idx.order, params.loc_data.loc_by_idx.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") + break; + } + case H5VL_OBJECT_LOOKUP_BY_ADDR: + { + if(!H5F_addr_defined(params.loc_data.loc_by_addr.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 = params.loc_data.loc_by_addr.addr; + obj_loc.oloc->file = loc.oloc->file; + H5G_name_reset(obj_loc.path); /* objects opened through this routine don't have a path name */ + + /* Open the object */ + if((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") + break; + } + case H5VL_OBJECT_LOOKUP_BY_REF: + { + H5F_t *file = NULL; + + /* Get the file pointer from the entry */ + file = loc.oloc->file; + + /* Create reference */ + if((ret_value = H5R_dereference(file, lapl_id, H5AC_dxpl_id, + params.loc_data.loc_by_ref.ref_type, + params.loc_data.loc_by_ref._ref, + TRUE)) < 0) + HGOTO_ERROR(H5E_REFERENCE, H5E_CANTINIT, FAIL, "unable to dereference object") + break; + } + default: + HGOTO_ERROR(H5E_VOL, H5E_UNSUPPORTED, FAIL, "unknown open parameters") + } 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_NOAPI(ret_value) } /* end H5VL_native_object_open() */ @@ -2926,26 +3018,28 @@ H5VL_native_object_misc(hid_t loc_id, H5VL_object_misc_t misc_type, hid_t UNUSED /* H5Arename/rename_by_name */ case H5VL_ATTR_RENAME: { - void *location = va_arg (arguments, void *); - char *old_name = va_arg (arguments, char *); - char *new_name = va_arg (arguments, char *); + H5VL_loc_params_t loc_params = va_arg (arguments, H5VL_loc_params_t); + const char *old_name = va_arg (arguments, const char *); + const char *new_name = va_arg (arguments, const char *); H5G_loc_t loc; if(H5G_loc(loc_id, &loc) < 0) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a location") - if(NULL == location) { /* H5Arename */ + if(loc_params.type == H5VL_OBJECT_LOOKUP_BY_ID) { /* H5Arename */ /* Call attribute rename routine */ if(H5O_attr_rename(loc.oloc, H5AC_dxpl_id, old_name, new_name) < 0) HGOTO_ERROR(H5E_ATTR, H5E_CANTRENAME, FAIL, "can't rename attribute") } - else { - H5G_loc_t *obj_loc = (H5G_loc_t *)location; - + else if(loc_params.type == H5VL_OBJECT_LOOKUP_BY_NAME) { /* H5Arename_by_name */ /* Call attribute rename routine */ - if(H5O_attr_rename(obj_loc->oloc, H5AC_dxpl_id, old_name, new_name) < 0) + if(H5A_rename_by_name(loc, loc_params.loc_data.loc_by_name.name, old_name, + new_name, loc_params.loc_data.loc_by_name.lapl_id) < 0) HGOTO_ERROR(H5E_ATTR, H5E_CANTRENAME, FAIL, "can't rename attribute") } + else { + HGOTO_ERROR(H5E_VOL, H5E_UNSUPPORTED, FAIL, "unknown attribute rename parameters") + } break; } /* H5Oincr_refcount / H5Odecr_refcount */ diff --git a/src/H5VLprivate.h b/src/H5VLprivate.h index 01754ca..eeb4b3c 100644 --- a/src/H5VLprivate.h +++ b/src/H5VLprivate.h @@ -50,7 +50,7 @@ H5_DLL ssize_t H5VL_get_plugin_name(hid_t id, char *name/*out*/, size_t size); H5_DLL herr_t H5VL_close(H5VL_class_t *vol_plugin); H5_DLL hid_t H5VL_attr_create(hid_t loc_id, const char *attr_name, hid_t acpl_id, hid_t aapl_id, hid_t req); -H5_DLL hid_t H5VL_attr_open(hid_t loc_id, void *location, const char *name, hid_t aapl_id, hid_t req); +H5_DLL hid_t H5VL_attr_open(hid_t loc_id, H5VL_loc_params_t loc_params, const char *name, hid_t aapl_id, hid_t req); H5_DLL herr_t H5VL_attr_read(hid_t attr_id, hid_t dtype_id, void *buf, hid_t req); H5_DLL herr_t H5VL_attr_write(hid_t attr_id, hid_t dtype_id, const void *buf, hid_t req); H5_DLL herr_t H5VL_attr_get(hid_t id, H5VL_attr_get_t get_type, hid_t req, ...); @@ -92,7 +92,7 @@ H5_DLL herr_t H5VL_link_iterate(hid_t loc_id, const char *name, hbool_t recursiv H5_DLL herr_t H5VL_link_get(hid_t loc_id, H5VL_link_get_t get_type, hid_t req, ...); H5_DLL herr_t H5VL_link_remove(hid_t loc_id, const char *name, void *udata, hid_t lapl_id, hid_t req); -H5_DLL hid_t H5VL_object_open_by_loc(hid_t loc_id, void *obj_loc, hid_t lapl_id, hid_t req); +H5_DLL hid_t H5VL_object_open(hid_t loc_id, H5VL_loc_params_t params, hid_t lapl_id, hid_t req); H5_DLL herr_t H5VL_object_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, hid_t req); H5_DLL herr_t H5VL_object_visit(hid_t loc_id, const char *obj_name, H5_index_t idx_type, diff --git a/src/H5VLpublic.h b/src/H5VLpublic.h index 388debc..4e433e5 100644 --- a/src/H5VLpublic.h +++ b/src/H5VLpublic.h @@ -26,6 +26,7 @@ #include "H5Fpublic.h" #include "H5Lpublic.h" #include "H5Opublic.h" +#include "H5Rpublic.h" /* Dataset creation property names */ #define H5VL_DSET_TYPE_ID "dataset_type_id" @@ -35,7 +36,7 @@ /* Attribute creation property names */ #define H5VL_ATTR_TYPE_ID "attr_type_id" #define H5VL_ATTR_SPACE_ID "attr_space_id" -#define H5VL_ATTR_LOCATION "attr_location" +#define H5VL_ATTR_LOC_PARAMS "attr_location" /* Link creation property names */ #define H5VL_LINK_TARGET_ID "target location id" @@ -158,12 +159,50 @@ typedef enum H5VL_object_lookup_t { H5VL_OBJECT_LOOKUP_BY_REF = 4 } H5VL_object_lookup_t; +struct H5VL_loc_by_id { + hid_t id; +}; + +struct H5VL_loc_by_name { + const char *name; + hid_t lapl_id; +}; + +struct H5VL_loc_by_idx { + const char *name; + H5_index_t idx_type; + H5_iter_order_t order; + hsize_t n; + hid_t lapl_id; +}; + +struct H5VL_loc_by_addr { + haddr_t addr; +}; + +struct H5VL_loc_by_ref { + H5R_type_t ref_type; + const void *_ref; +}; + +/* Structure to hold parameters for object location */ +typedef struct H5VL_loc_params_t { + H5VL_object_lookup_t type; + union{ + struct H5VL_loc_by_id loc_by_id; + struct H5VL_loc_by_name loc_by_name; + struct H5VL_loc_by_idx loc_by_idx; + struct H5VL_loc_by_addr loc_by_addr; + struct H5VL_loc_by_ref loc_by_ref; + }loc_data; +} H5VL_loc_params_t; + #define H5VL_VOL_DEFAULT 0 /* Default VOL plugin value */ /* H5A routines */ typedef struct H5VL_attr_class_t { hid_t (*create)(hid_t loc_id, const char *attr_name, hid_t acpl_id, hid_t aapl_id, hid_t req); - hid_t (*open) (hid_t loc_id, void *location, const char *attr_name, hid_t aapl_id, hid_t req); + hid_t (*open) (hid_t loc_id, H5VL_loc_params_t loc_params, const char *attr_name, hid_t aapl_id, hid_t req); herr_t (*read) (hid_t attr_id, hid_t mem_type_id, void *buf, hid_t req); herr_t (*write) (hid_t attr_id, hid_t mem_type_id, const void *buf, hid_t req); herr_t (*get) (hid_t loc_id, H5VL_attr_get_t get_type, hid_t req, va_list arguments); @@ -226,7 +265,7 @@ typedef struct H5VL_link_class_t { /* H5O routines */ typedef struct H5VL_object_class_t { - hid_t (*open) (void *obj_loc, hid_t lapl_id, hid_t req); + hid_t (*open) (hid_t id, H5VL_loc_params_t params, hid_t lapl_id, hid_t req); 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, hid_t req); herr_t (*visit) (hid_t loc_id, const char *obj_name, H5_index_t idx_type, H5_iter_order_t order, @@ -242,7 +281,6 @@ typedef struct H5VL_object_class_t { /* Class information for each VOL driver */ typedef struct H5VL_class_t { const char *name; - unsigned nrefs; /* Ref count for times struct is pointed to */ herr_t (*initialize)(void); herr_t (*terminate)(void); H5VL_attr_class_t attr_cls; @@ -260,7 +298,8 @@ extern "C" { /* Function prototypes */ H5_DLL hid_t H5VLregister(const H5VL_class_t *cls); -H5_DLL herr_t H5VLunregister(hid_t driver_id); +H5_DLL herr_t H5VLunregister(hid_t plugin_id); +H5_DLL htri_t H5VLis_registered(hid_t id); H5_DLL ssize_t H5VLget_plugin_name(hid_t id, char *name/*out*/, size_t size); #ifdef __cplusplus -- cgit v0.12