From 34050a7d9c9ae16326711cfb69c575bfe75e422e Mon Sep 17 00:00:00 2001 From: Mohamad Chaarawi Date: Tue, 3 Jul 2012 15:19:47 -0500 Subject: [svn-r22511] - remove the internal file type and use the file ID created at the API level for the native implementation - work on fixing the named datatype issue.. still not resolved - branch still not stable and tests do not pass at this point --- src/H5A.c | 33 +++---- src/H5Adeprec.c | 8 +- src/H5D.c | 8 +- src/H5Ddeprec.c | 4 +- src/H5F.c | 164 ++++++++++++++++++++++++++++++---- src/H5Fefc.c | 56 +----------- src/H5Fint.c | 125 +++----------------------- src/H5G.c | 4 +- src/H5Gloc.c | 76 +++++++++++++++- src/H5Gname.c | 2 +- src/H5Gprivate.h | 1 + src/H5I.c | 65 ++++++++++---- src/H5Iprivate.h | 1 + src/H5Ipublic.h | 3 +- src/H5Lexternal.c | 23 +++-- src/H5O.c | 32 +++---- src/H5Ocopy.c | 2 +- src/H5T.c | 7 ++ src/H5Tcommit.c | 41 ++++++--- src/H5Tprecis.c | 2 +- src/H5VL.c | 1 - src/H5VLint.c | 37 +++++++- src/H5VLnative.c | 257 +++++++++++++++++++++--------------------------------- src/H5VLprivate.h | 1 + 24 files changed, 526 insertions(+), 427 deletions(-) diff --git a/src/H5A.c b/src/H5A.c index 793be98..257cdd4 100644 --- a/src/H5A.c +++ b/src/H5A.c @@ -241,6 +241,9 @@ H5Acreate2(hid_t loc_id, const char *attr_name, hid_t type_id, hid_t space_id, if(NULL == (plist = (H5P_genplist_t *)H5I_object(acpl_id))) HGOTO_ERROR(H5E_ATOM, H5E_BADATOM, FAIL, "can't find object for ID") + //if((temp_id = H5T_get_named_id(type_id)) < 0) + //HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "invalid type ID") + /* set creation properties */ if(H5P_set(plist, H5VL_ATTR_TYPE_ID, &type_id) < 0) HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, FAIL, "can't set property value for datatype id") @@ -253,7 +256,7 @@ H5Acreate2(hid_t loc_id, const char *attr_name, hid_t type_id, hid_t space_id, loc_params.obj_type = H5I_get_type(loc_id); /* get the file object */ - if(NULL == (obj = (void *)H5I_object(loc_id))) + if(NULL == (obj = (void *)H5VL_get_object(loc_id))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "invalid file identifier") /* get the plugin pointer */ if (NULL == (vol_plugin = (H5VL_t *)H5I_get_aux(loc_id))) @@ -356,7 +359,7 @@ H5Acreate_by_name(hid_t loc_id, const char *obj_name, const char *attr_name, loc_params.loc_data.loc_by_name.plist_id = lapl_id; /* get the file object */ - if(NULL == (obj = (void *)H5I_object(loc_id))) + if(NULL == (obj = (void *)H5VL_get_object(loc_id))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "invalid file identifier") /* get the plugin pointer */ @@ -426,7 +429,7 @@ H5Aopen(hid_t loc_id, const char *attr_name, hid_t aapl_id) loc_params.obj_type = H5I_get_type(loc_id); /* get the file object */ - if(NULL == (obj = (void *)H5I_object(loc_id))) + if(NULL == (obj = (void *)H5VL_get_object(loc_id))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "invalid file identifier") /* get the plugin pointer */ @@ -508,7 +511,7 @@ H5Aopen_by_name(hid_t loc_id, const char *obj_name, const char *attr_name, loc_params.obj_type = H5I_get_type(loc_id); /* get the file object */ - if(NULL == (obj = (void *)H5I_object(loc_id))) + if(NULL == (obj = (void *)H5VL_get_object(loc_id))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "invalid file identifier") /* get the plugin pointer */ @@ -599,7 +602,7 @@ H5Aopen_by_idx(hid_t loc_id, const char *obj_name, H5_index_t idx_type, loc_params.obj_type = H5I_get_type(loc_id); /* get the file object */ - if(NULL == (obj = (void *)H5I_object(loc_id))) + if(NULL == (obj = (void *)H5VL_get_object(loc_id))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "invalid file identifier") /* get the plugin pointer */ @@ -956,7 +959,7 @@ H5Aget_name_by_idx(hid_t loc_id, const char *obj_name, H5_index_t idx_type, if (NULL == (vol_plugin = (H5VL_t *)H5I_get_aux(loc_id))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "ID does not contain VOL information") /* get the dataset object */ - if(NULL == (obj = (void *)H5I_object(loc_id))) + if(NULL == (obj = (void *)H5VL_get_object(loc_id))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "invalid object identifier") loc_params.type = H5VL_OBJECT_BY_IDX; @@ -1121,7 +1124,7 @@ H5Aget_info_by_name(hid_t loc_id, const char *obj_name, const char *attr_name, if (NULL == (vol_plugin = (H5VL_t *)H5I_get_aux(loc_id))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "ID does not contain VOL information") /* get the dataset object */ - if(NULL == (obj = (void *)H5I_object(loc_id))) + if(NULL == (obj = (void *)H5VL_get_object(loc_id))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "invalid object identifier") /* get the attribute info through the VOL */ @@ -1204,7 +1207,7 @@ H5Aget_info_by_idx(hid_t loc_id, const char *obj_name, H5_index_t idx_type, if (NULL == (vol_plugin = (H5VL_t *)H5I_get_aux(loc_id))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "ID does not contain VOL information") /* get the dataset object */ - if(NULL == (obj = (void *)H5I_object(loc_id))) + if(NULL == (obj = (void *)H5VL_get_object(loc_id))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "invalid object identifier") /* get the attribute info through the VOL */ @@ -1277,7 +1280,7 @@ H5Arename(hid_t loc_id, const char *old_name, const char *new_name) loc_params.obj_type = H5I_get_type(loc_id); /* get the file object */ - if(NULL == (obj = (void *)H5I_object(loc_id))) + if(NULL == (obj = (void *)H5VL_get_object(loc_id))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "invalid file identifier") /* get the plugin pointer */ if (NULL == (vol_plugin = (H5VL_t *)H5I_get_aux(loc_id))) @@ -1343,7 +1346,7 @@ H5Arename_by_name(hid_t loc_id, const char *obj_name, const char *old_attr_name, loc_params.obj_type = H5I_get_type(loc_id); /* get the file object */ - if(NULL == (obj = (void *)H5I_object(loc_id))) + if(NULL == (obj = (void *)H5VL_get_object(loc_id))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "invalid file identifier") /* get the plugin pointer */ if (NULL == (vol_plugin = (H5VL_t *)H5I_get_aux(loc_id))) @@ -1597,7 +1600,7 @@ H5Adelete(hid_t loc_id, const char *name) if (NULL == (vol_plugin = (H5VL_t *)H5I_get_aux(loc_id))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "ID does not contain VOL information") /* get the dataset object */ - if(NULL == (obj = (void *)H5I_object(loc_id))) + if(NULL == (obj = (void *)H5VL_get_object(loc_id))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "invalid object identifier") /* Open the attribute through the VOL */ @@ -1659,7 +1662,7 @@ H5Adelete_by_name(hid_t loc_id, const char *obj_name, const char *attr_name, if (NULL == (vol_plugin = (H5VL_t *)H5I_get_aux(loc_id))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "ID does not contain VOL information") /* get the dataset object */ - if(NULL == (obj = (void *)H5I_object(loc_id))) + if(NULL == (obj = (void *)H5VL_get_object(loc_id))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "invalid object identifier") /* Open the attribute through the VOL */ @@ -1734,7 +1737,7 @@ H5Adelete_by_idx(hid_t loc_id, const char *obj_name, H5_index_t idx_type, if (NULL == (vol_plugin = (H5VL_t *)H5I_get_aux(loc_id))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "ID does not contain VOL information") /* get the dataset object */ - if(NULL == (obj = (void *)H5I_object(loc_id))) + if(NULL == (obj = (void *)H5VL_get_object(loc_id))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "invalid object identifier") /* Open the attribute through the VOL */ @@ -1828,7 +1831,7 @@ H5Aexists(hid_t obj_id, const char *attr_name) if (NULL == (vol_plugin = (H5VL_t *)H5I_get_aux(obj_id))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "ID does not contain VOL information") /* get the dataset object */ - if(NULL == (obj = (void *)H5I_object(obj_id))) + if(NULL == (obj = (void *)H5VL_get_object(obj_id))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "invalid object identifier") loc_params.type = H5VL_OBJECT_BY_SELF; @@ -1885,7 +1888,7 @@ H5Aexists_by_name(hid_t loc_id, const char *obj_name, const char *attr_name, if (NULL == (vol_plugin = (H5VL_t *)H5I_get_aux(loc_id))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "ID does not contain VOL information") /* get the dataset object */ - if(NULL == (obj = (void *)H5I_object(loc_id))) + if(NULL == (obj = (void *)H5VL_get_object(loc_id))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "invalid object identifier") loc_params.type = H5VL_OBJECT_BY_NAME; diff --git a/src/H5Adeprec.c b/src/H5Adeprec.c index 13debcf..b239142 100644 --- a/src/H5Adeprec.c +++ b/src/H5Adeprec.c @@ -173,7 +173,7 @@ H5Acreate1(hid_t loc_id, const char *name, hid_t type_id, hid_t space_id, loc_params.obj_type = H5I_get_type(loc_id); /* get the file object */ - if(NULL == (obj = (void *)H5I_object(loc_id))) + if(NULL == (obj = (void *)H5VL_get_object(loc_id))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "invalid file identifier") /* get the plugin pointer */ @@ -246,7 +246,7 @@ H5Aopen_name(hid_t loc_id, const char *name) loc_params.obj_type = H5I_get_type(loc_id); /* get the file object */ - if(NULL == (obj = (void *)H5I_object(loc_id))) + if(NULL == (obj = (void *)H5VL_get_object(loc_id))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "invalid file identifier") /* get the plugin pointer */ @@ -322,7 +322,7 @@ H5Aopen_idx(hid_t loc_id, unsigned idx) loc_params.obj_type = H5I_get_type(loc_id); /* get the file object */ - if(NULL == (obj = (void *)H5I_object(loc_id))) + if(NULL == (obj = (void *)H5VL_get_object(loc_id))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "invalid file identifier") /* get the plugin pointer */ if (NULL == (vol_plugin = (H5VL_t *)H5I_get_aux(loc_id))) @@ -384,7 +384,7 @@ H5Aget_num_attrs(hid_t loc_id) loc_params.obj_type = H5I_get_type(loc_id); /* get the file object */ - if(NULL == (obj = (void *)H5I_object(loc_id))) + if(NULL == (obj = (void *)H5VL_get_object(loc_id))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "invalid file identifier") /* get the plugin pointer */ if (NULL == (vol_plugin = (H5VL_t *)H5I_get_aux(loc_id))) diff --git a/src/H5D.c b/src/H5D.c index 3cd3e86..736f917 100644 --- a/src/H5D.c +++ b/src/H5D.c @@ -90,7 +90,7 @@ H5D__init_pub_interface(void) FUNC_ENTER_STATIC /* Initialize the atom group for the dataset IDs */ - if(H5I_register_type(H5I_DATASET, (size_t)H5I_DATASETID_HASHSIZE, H5D_RESERVED_ATOMS, NULL)file_id = ret_value; done: FUNC_LEAVE_API(ret_value) } /* end H5Fcreate() */ @@ -498,7 +566,7 @@ done: hid_t H5Fopen(const char *filename, unsigned flags, hid_t fapl_id) { - void *file; /*file token from VOL plugin */ + void *file = NULL; /*file token from VOL plugin */ H5VL_t *vol_plugin; /* VOL plugin information */ hid_t ret_value; /*return value */ @@ -536,6 +604,7 @@ H5Fopen(const char *filename, unsigned flags, hid_t fapl_id) if (H5I_register_aux(ret_value, vol_plugin, (H5I_free2_t)H5F_close_file) < 0) HGOTO_ERROR(H5E_VOL, H5E_CANTINIT, FAIL, "can't attach vol info to ID") + ((H5F_t *)file)->file_id = ret_value; done: FUNC_LEAVE_API(ret_value) } /* end H5Fopen() */ @@ -578,7 +647,7 @@ H5Fflush(hid_t object_id, H5F_scope_t scope) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "ID does not contain VOL information") /* get the file object */ - if(NULL == (obj = (void *)H5I_object(object_id))) + if(NULL == (obj = (void *)H5VL_get_object(object_id))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "invalid file identifier") loc_params.type = H5VL_OBJECT_BY_SELF; @@ -746,6 +815,7 @@ H5Freopen(hid_t file_id) HGOTO_ERROR(H5E_VOL, H5E_CANTINIT, FAIL, "can't attach vol info to ID") vol_plugin->nrefs ++; + ((H5F_t *)file)->file_id = ret_value; done: FUNC_LEAVE_API(ret_value) @@ -1224,7 +1294,7 @@ H5Fget_name(hid_t obj_id, char *name/*out*/, size_t size) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "ID does not contain VOL information") /* get the file object */ - if(NULL == (obj = (void *)H5I_object(obj_id))) + if(NULL == (obj = (void *)H5VL_get_object(obj_id))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "invalid file identifier") if(H5VL_file_get(obj, vol_plugin, H5VL_FILE_GET_NAME, H5_REQUEST_NULL, @@ -1279,7 +1349,7 @@ H5Fget_info2(hid_t obj_id, H5F_info2_t *finfo) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "ID does not contain VOL information") /* get the file object */ - if(NULL == (obj = (void *)H5I_object(obj_id))) + if(NULL == (obj = (void *)H5VL_get_object(obj_id))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "invalid file identifier") if((ret_value = H5VL_file_optional(obj, vol_plugin, H5VL_FILE_GET_INFO, H5_REQUEST_NULL, @@ -1374,3 +1444,63 @@ H5Fclear_elink_file_cache(hid_t file_id) done: FUNC_LEAVE_API(ret_value) } /* end H5Fclear_elink_file_cache() */ + + +/*------------------------------------------------------------------------- + * Function: H5F_get_id + * + * Purpose: Get the file ID, incrementing it, or "resurrecting" it as + * appropriate. + * + * Return: Non-negative on success/Negative on failure + * + * Programmer: Raymond Lu + * Oct 29, 2003 + * + *------------------------------------------------------------------------- + */ +hid_t +H5F_get_id(H5F_t *file, hbool_t app_ref) +{ + hid_t ret_value; + + FUNC_ENTER_NOAPI_NOINIT + + HDassert(file); + +#if 0 + if (FAIL == (ret_value = H5VL_get_id(file, H5I_FILE))) { + /* resurrect the ID */ + /* Get an atom for the file */ + if((ret_value = H5I_register(H5I_FILE, file, app_ref)) < 0) + HGOTO_ERROR(H5E_ATOM, H5E_CANTREGISTER, FAIL, "unable to atomize file handle") + /* attach VOL information to the ID */ + if (H5VL_native_register_aux(ret_value) < 0) + HGOTO_ERROR(H5E_VOL, H5E_CANTINIT, FAIL, "can't attach vol info to ID") + } + else { + /* Increment ref count on existing ID */ + if(H5I_inc_ref(ret_value, app_ref) < 0) + HGOTO_ERROR(H5E_ATOM, H5E_CANTSET, FAIL, "incrementing file ID failed") + } +#endif +#if 1 + if(file->file_id == -1) { + /* Get an atom for the file */ + if((file->file_id = H5I_register(H5I_FILE, file, app_ref)) < 0) + HGOTO_ERROR(H5E_ATOM, H5E_CANTREGISTER, FAIL, "unable to atomize file") + /* attach VOL information to the ID */ + if (H5VL_native_register_aux(file->file_id) < 0) + HGOTO_ERROR(H5E_VOL, H5E_CANTINIT, FAIL, "can't attach vol info to ID") + } else { + /* Increment reference count on atom. */ + if(H5I_inc_ref(file->file_id, app_ref) < 0) + HGOTO_ERROR(H5E_ATOM, H5E_CANTSET, FAIL, "incrementing file ID failed") + } /* end else */ + + ret_value = file->file_id; +#endif + +done: + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5F_get_id() */ diff --git a/src/H5Fefc.c b/src/H5Fefc.c index 11ecbc1..09a1cfb 100644 --- a/src/H5Fefc.c +++ b/src/H5Fefc.c @@ -157,16 +157,6 @@ H5F_efc_open(H5F_t *parent, const char *name, unsigned flags, hid_t fcpl_id, HDassert(parent->shared); HDassert(name); -#if 0 - /* get the VOL info from the fapl */ - if(NULL == (plist = (H5P_genplist_t *)H5I_object(fapl_id))) - HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, NULL, "not a file access property list") - if(H5P_get(plist, H5F_ACS_VOL_ID_NAME, &vol_id) < 0) - HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, NULL, "can't get vol plugin ID") - if(NULL == (vol_plugin = (H5VL_class_t *)H5I_object(vol_id))) - HGOTO_ERROR(H5E_VOL, H5E_BADVALUE, NULL, "invalid vol plugin ID in file access property list") -#endif - /* Get external file cache */ efc = parent->shared->efc; @@ -174,23 +164,10 @@ H5F_efc_open(H5F_t *parent, const char *name, unsigned flags, hid_t fcpl_id, * support this so clients do not have to make 2 different calls depending * on the state of the efc. */ if(!efc) { -#if 1 if(NULL == (ret_value = H5F_open(name, flags, fcpl_id, fapl_id, dxpl_id))) HGOTO_ERROR(H5E_FILE, H5E_CANTOPENFILE, NULL, "can't open file") -#endif -#if 0 - /* check if the corresponding VOL open callback exists */ - if(NULL == vol_plugin->file_cls.open) - HGOTO_ERROR(H5E_VOL, H5E_UNSUPPORTED, NULL, "vol plugin has no `file open' method") - /* call the corresponding VOL open callback */ - if(NULL == (ret_value = (vol_plugin->file_cls.open)(name, flags, fcpl_id, fapl_id, dxpl_id))) - HGOTO_ERROR(H5E_VOL, H5E_CANTINIT, NULL, "open failed") - ret_value->vol_id = vol_id; - /* increment the ref count on the vol ID */ - if(H5I_inc_ref(ret_value->vol_id, FALSE) < 0) - HGOTO_ERROR(H5E_VOL, H5E_CANTINC, NULL, "unable to increment ref count on VOL plugin") -#endif + /* Increment the number of open objects to prevent the file from being * closed out from under us - "simulate" having an open file id. Note * that this behaviour replaces the calls to H5F_incr_nopen_objs() and @@ -260,23 +237,10 @@ H5F_efc_open(H5F_t *parent, const char *name, unsigned flags, hid_t fcpl_id, } /* end if */ else { /* Cannot cache file, just open file and return */ -#if 1 if(NULL == (ret_value = H5F_open(name, flags, fcpl_id, fapl_id, dxpl_id))) HGOTO_ERROR(H5E_FILE, H5E_CANTOPENFILE, NULL, "can't open file") -#endif -#if 0 - /* check if the corresponding VOL open callback exists */ - if(NULL == vol_plugin->file_cls.open) - HGOTO_ERROR(H5E_VOL, H5E_UNSUPPORTED, NULL, "vol plugin has no `file open' method") - /* call the corresponding VOL open callback */ - if(NULL == (ret_value = (vol_plugin->file_cls.open)(name, flags, fcpl_id, fapl_id, dxpl_id))) - HGOTO_ERROR(H5E_VOL, H5E_CANTINIT, NULL, "open failed") - ret_value->vol_id = vol_id; - /* increment the ref count on the vol ID */ - if(H5I_inc_ref(ret_value->vol_id, FALSE) < 0) - HGOTO_ERROR(H5E_VOL, H5E_CANTINC, NULL, "unable to increment ref count on VOL plugin") -#endif + /* Increment the number of open objects to prevent the file from * being closed out from under us - "simulate" having an open * file id */ @@ -293,24 +257,12 @@ H5F_efc_open(H5F_t *parent, const char *name, unsigned flags, hid_t fcpl_id, /* Build new entry */ if(NULL == (ent->name = H5MM_strdup(name))) HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, NULL, "memory allocation failed") -#if 1 + /* Open the file */ if(NULL == (ent->file = H5F_open(name, flags, fcpl_id, fapl_id, dxpl_id))) HGOTO_ERROR(H5E_FILE, H5E_CANTOPENFILE, NULL, "can't open file") -#endif -#if 0 - /* check if the corresponding VOL open callback exists */ - if(NULL == vol_plugin->file_cls.open) - HGOTO_ERROR(H5E_VOL, H5E_UNSUPPORTED, NULL, "vol plugin has no `file open' method") - /* call the corresponding VOL open callback */ - if(NULL == (ent->file = (vol_plugin->file_cls.open)(name, flags, fcpl_id, fapl_id, dxpl_id))) - HGOTO_ERROR(H5E_VOL, H5E_CANTINIT, NULL, "open failed") - ent->file->vol_id = vol_id; - /* increment the ref count on the vol ID */ - if(H5I_inc_ref(ent->file->vol_id, FALSE) < 0) - HGOTO_ERROR(H5E_VOL, H5E_CANTINC, NULL, "unable to increment ref count on VOL plugin") -#endif + open_file = TRUE; /* Increment the number of open objects to prevent the file from being diff --git a/src/H5Fint.c b/src/H5Fint.c index 5edb2b5..a948d88 100644 --- a/src/H5Fint.c +++ b/src/H5Fint.c @@ -34,6 +34,7 @@ #include "H5Pprivate.h" /* Property lists */ #include "H5SMprivate.h" /* Shared Object Header Messages */ #include "H5Tprivate.h" /* Datatypes */ +#include "H5VLnative.h" /* Native Plugin */ #include "H5VLprivate.h" /* VOL plugins */ /* Struct only used by functions H5F_get_objects and H5F_get_objects_cb */ @@ -66,32 +67,6 @@ H5FL_DEFINE(H5F_file_t); /*------------------------------------------------------------------------- - * Function: H5F_init - * - * Purpose: Initialize the interface from some other layer. - * - * Return: Success: non-negative - * Failure: negative - * - * Programmer: Robb Matzke - * Wednesday, December 16, 1998 - * - *------------------------------------------------------------------------- - */ -herr_t -H5F_init(void) -{ - herr_t ret_value = SUCCEED; /* Return value */ - - FUNC_ENTER_NOAPI(FAIL) - /* FUNC_ENTER() does all the work */ - -done: - FUNC_LEAVE_NOAPI(ret_value) -} /* end H5F_init() */ - - -/*------------------------------------------------------------------------- * Function: H5F_init_interface * * Purpose: Initialize interface-specific information. @@ -111,60 +86,12 @@ H5F_init_interface(void) FUNC_ENTER_NOAPI_NOINIT - /* - * Initialize the atom group for the file IDs. - */ - if(H5I_register_type(H5I_FILE_PRIVATE, (size_t)H5I_FILEID_HASHSIZE, 0, (H5I_free_t)H5F_close)file_id = -1; + /* + if((file_id = H5VL_get_id(f, H5I_FILE)) < 0) + HGOTO_ERROR(H5E_ATOM, H5E_CANTGET, FAIL, "invalid atom") + H5I_remove(file_id); + */ + /* Attempt to close the file/mount hierarchy */ if(H5F_try_close(f) < 0) HGOTO_ERROR(H5E_FILE, H5E_CANTCLOSEFILE, FAIL, "can't close file") @@ -1575,6 +1507,7 @@ H5F_reopen(H5F_t *f) ret_value->open_name = H5MM_xstrdup(f->open_name); ret_value->actual_name = H5MM_xstrdup(f->actual_name); + /* if((ret_value->file_id = H5I_register(H5I_FILE_PRIVATE, ret_value, TRUE)) < 0) HGOTO_ERROR(H5E_ATOM, H5E_CANTREGISTER, NULL, "unable to atomize file handle") @@ -1582,48 +1515,10 @@ done: if(ret_value->file_id < 0 && ret_value) if(H5F_dest(ret_value, H5AC_dxpl_id, FALSE) < 0) HDONE_ERROR(H5E_FILE, H5E_CANTCLOSEFILE, NULL, "can't close file") - - FUNC_LEAVE_NOAPI(ret_value) -} /* end H5F_reopen() */ - - -/*------------------------------------------------------------------------- - * Function: H5F_get_id - * - * Purpose: Get the file ID, incrementing it, or "resurrecting" it as - * appropriate. - * - * Return: Non-negative on success/Negative on failure - * - * Programmer: Raymond Lu - * Oct 29, 2003 - * - *------------------------------------------------------------------------- - */ -hid_t -H5F_get_id(H5F_t *file, hbool_t app_ref) -{ - hid_t ret_value; - - FUNC_ENTER_NOAPI_NOINIT - - HDassert(file); - - if(file->file_id == -1) { - /* Get an atom for the file */ - if((file->file_id = H5I_register(H5I_FILE_PRIVATE, file, app_ref)) < 0) - HGOTO_ERROR(H5E_ATOM, H5E_CANTREGISTER, FAIL, "unable to atomize file") - } else { - /* Increment reference count on atom. */ - if(H5I_inc_ref(file->file_id, app_ref) < 0) - HGOTO_ERROR(H5E_ATOM, H5E_CANTSET, FAIL, "incrementing file ID failed") - } /* end else */ - - ret_value = file->file_id; - + */ done: FUNC_LEAVE_NOAPI(ret_value) -} /* end H5F_get_id() */ +} /* end H5F_reopen() */ /*------------------------------------------------------------------------- diff --git a/src/H5G.c b/src/H5G.c index 03e4ca3..b987312 100644 --- a/src/H5G.c +++ b/src/H5G.c @@ -781,14 +781,14 @@ done: *------------------------------------------------------------------------- */ herr_t -H5G_close_group(void *dset, H5VL_t *vol_plugin) +H5G_close_group(void *grp, H5VL_t *vol_plugin) { herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_NOAPI_NOINIT /* Close the group through the VOL*/ - if((ret_value = H5VL_group_close(dset, vol_plugin, H5_REQUEST_NULL)) < 0) + if((ret_value = H5VL_group_close(grp, vol_plugin, H5_REQUEST_NULL)) < 0) HGOTO_ERROR(H5E_SYM, H5E_CLOSEERROR, FAIL, "unable to close group") vol_plugin->nrefs --; diff --git a/src/H5Gloc.c b/src/H5Gloc.c index e513d17..58ae55a 100644 --- a/src/H5Gloc.c +++ b/src/H5Gloc.c @@ -126,7 +126,6 @@ static herr_t H5G_loc_get_comment_cb(H5G_loc_t *grp_loc, const char *name, const H5O_link_t *lnk, H5G_loc_t *obj_loc, void *_udata, H5G_own_loc_t *own_loc); - /*********************/ /* Package Variables */ /*********************/ @@ -143,6 +142,75 @@ static herr_t H5G_loc_get_comment_cb(H5G_loc_t *grp_loc, const char *name, +/*--------------------------------------------------------------------------- + * Function: H5G_loc_real + * + * Purpose: utility routine to get object location + * + * Returns: Non-negative on success or negative on failure + * + * Programmer: Mohamad Chaarawi + * June, 2012 + * + *--------------------------------------------------------------------------- + */ +herr_t +H5G_loc_real(void *obj, H5I_type_t type, H5G_loc_t *loc) +{ + herr_t ret_value = SUCCEED; + + FUNC_ENTER_NOAPI_NOINIT + + switch(type) { + case H5I_FILE: + /* Construct a group location for root group of the file */ + if(H5G_root_loc((H5F_t *)obj, loc) < 0) + HGOTO_ERROR(H5E_SYM, H5E_BADVALUE, FAIL, "unable to create location for file") + break; + case H5I_GROUP: + if(NULL == (loc->oloc = H5G_oloc((H5G_t *)obj))) + HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "unable to get object location of group") + if(NULL == (loc->path = H5G_nameof((H5G_t *)obj))) + HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "unable to get path of group") + break; + case H5I_DATATYPE: + if(NULL == (loc->oloc = H5T_oloc((H5T_t *)obj))) + HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "unable to get object location of datatype") + if(NULL == (loc->path = H5T_nameof((H5T_t *)obj))) + HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "unable to get path of datatype") + break; + case H5I_DATASET: + if(NULL == (loc->oloc = H5D_oloc((H5D_t *)obj))) + HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "unable to get object location of dataset") + if(NULL == (loc->path = H5D_nameof((H5D_t *)obj))) + HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "unable to get path of dataset") + break; + case H5I_ATTR: + if(NULL == (loc->oloc = H5A_oloc((H5A_t *)obj))) + HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "unable to get object location of attribute") + if(NULL == (loc->path = H5A_nameof((H5A_t *)obj))) + HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "unable to get path of attribute") + break; + case H5I_UNINIT: + case H5I_BADID: + case H5I_DATASPACE: + case H5I_REFERENCE: + case H5I_VFL: + case H5I_VOL: + case H5I_GENPROP_CLS: + case H5I_GENPROP_LST: + case H5I_ERROR_CLASS: + case H5I_ERROR_MSG: + case H5I_ERROR_STACK: + case H5I_NTYPES: + default: + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a file or file object") + } /* end switch */ +done: + FUNC_LEAVE_NOAPI(ret_value) +} /* H5G_loc_real */ + + /*------------------------------------------------------------------------- * Function: H5G_loc * @@ -163,6 +231,10 @@ H5G_loc(hid_t loc_id, H5G_loc_t *loc) FUNC_ENTER_NOAPI(FAIL) + if(H5G_loc_real(H5I_object(loc_id), H5I_get_type(loc_id), loc) < 0) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a file or file object") + +#if 0 switch(H5I_get_type(loc_id)) { case H5I_FILE: { @@ -253,7 +325,7 @@ H5G_loc(hid_t loc_id, H5G_loc_t *loc) default: HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "invalid object ID") } /* end switch */ - +#endif done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5G_loc() */ diff --git a/src/H5Gname.c b/src/H5Gname.c index 576d866..381518a 100644 --- a/src/H5Gname.c +++ b/src/H5Gname.c @@ -1304,7 +1304,7 @@ H5G_get_name_by_addr(hid_t file, hid_t lapl_id, hid_t dxpl_id, const H5O_loc_t * udata.path = NULL; /* Visit all the links in the file */ - if((status = H5G_visit(file, "/", H5_INDEX_NAME, H5_ITER_NATIVE, H5G_get_name_by_addr_cb, &udata, lapl_id, dxpl_id)) < 0) + if((status = H5G_visit(&root_loc, "/", H5_INDEX_NAME, H5_ITER_NATIVE, H5G_get_name_by_addr_cb, &udata, lapl_id, dxpl_id)) < 0) HGOTO_ERROR(H5E_SYM, H5E_BADITER, FAIL, "group traversal failed while looking for object name") else if(status > 0) found_obj = TRUE; diff --git a/src/H5Gprivate.h b/src/H5Gprivate.h index 371d096..328ef93 100644 --- a/src/H5Gprivate.h +++ b/src/H5Gprivate.h @@ -277,6 +277,7 @@ H5_DLL H5RS_str_t *H5G_build_fullpath_refstr_str(H5RS_str_t *path_r, const char /* * These functions operate on group "locations" */ +H5_DLL herr_t H5G_loc_real(void *obj, H5I_type_t type, H5G_loc_t *loc); H5_DLL herr_t H5G_loc(hid_t loc_id, H5G_loc_t *loc); H5_DLL herr_t H5G_loc_find(const H5G_loc_t *loc, const char *name, H5G_loc_t *obj_loc/*out*/, hid_t lapl_id, hid_t dxpl_id); diff --git a/src/H5I.c b/src/H5I.c index a7ae3b4..fbe4b19 100644 --- a/src/H5I.c +++ b/src/H5I.c @@ -137,7 +137,6 @@ H5FL_DEFINE_STATIC(H5I_id_info_t); /*--------------------- Local function prototypes ---------------------------*/ static H5I_id_info_t *H5I_find_id(hid_t id); static int H5I_search_cb(void *obj, hid_t id, void *udata); -static hid_t H5VL_get_id(void *object, H5I_type_t type); #ifdef H5I_DEBUG_OUTPUT static herr_t H5I_debug(H5I_type_t type); #endif /* H5I_DEBUG_OUTPUT */ @@ -1357,7 +1356,6 @@ H5I_dec_ref(hid_t id) --(id_ptr->count); ret_value = (int)id_ptr->count; } /* end else */ - done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5I_dec_ref() */ @@ -2248,19 +2246,10 @@ H5I_get_file_id(hid_t obj_id, hbool_t app_ref) FUNC_ENTER_NOAPI_NOINIT +#if 0 /* Get object type */ type = H5I_TYPE(obj_id); -#if 0 - 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") - /* Set return value */ - ret_value = obj_id; - } /* end if */ - else -#endif if(H5I_FILE == type || H5I_DATATYPE == type || H5I_GROUP == type || H5I_DATASET == type || H5I_ATTR == type) { H5VL_t *vol_plugin; @@ -2278,16 +2267,20 @@ H5I_get_file_id(hid_t obj_id, hbool_t app_ref) if (NULL == (obj = H5T_get_named_type((H5T_t *)obj))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a named datatype") } + /* Get the file through the VOL */ - if(H5VL_file_get(obj, vol_plugin, H5VL_OBJECT_GET_FILE, H5_REQUEST_NULL, - type, app_ref, &file) < 0) + if(H5VL_file_get(obj, vol_plugin, H5VL_OBJECT_GET_FILE, H5_REQUEST_NULL, type, &file) < 0) HGOTO_ERROR(H5E_INTERNAL, H5E_CANTINIT, FAIL, "unable to get file") if (NULL == file) HGOTO_ERROR(H5E_FILE, H5E_CANTINIT, FAIL, "unable to reopen file") + if((ret_value = H5F_get_id((H5F_t*)file, TRUE)) < 0) + HGOTO_ERROR(H5E_SYM, H5E_CANTGET, FAIL, "can't get file ID") + +#if 0 if (FAIL == (ret_value = H5VL_get_id(file, H5I_FILE))) { - /* Get an atom for the dataset */ + /* Get an atom for the file */ if((ret_value = H5I_register(H5I_FILE, file, TRUE)) < 0) HGOTO_ERROR(H5E_ATOM, H5E_CANTREGISTER, FAIL, "unable to atomize file handle") @@ -2301,10 +2294,49 @@ H5I_get_file_id(hid_t obj_id, hbool_t app_ref) if(H5I_inc_ref(ret_value, app_ref) < 0) HGOTO_ERROR(H5E_ATOM, H5E_CANTSET, FAIL, "incrementing file ID failed") } +#endif } /* end if */ else HGOTO_ERROR(H5E_ARGS, H5E_BADRANGE, FAIL, "invalid object ID") +#endif + /* Get object type */ + type = H5I_TYPE(obj_id); + if(type == H5I_FILE) { + /* Increment reference count on file ID */ + if(H5I_inc_ref(obj_id, app_ref) < 0) + HGOTO_ERROR(H5E_ATOM, H5E_CANTSET, FAIL, "incrementing file ID failed") + + /* Set return value */ + ret_value = obj_id; + } /* end if */ + else if(type == H5I_DATATYPE || type == H5I_GROUP || type == H5I_DATASET || type == H5I_ATTR) { + H5G_loc_t loc; /* Location of object */ + + if (H5I_DATATYPE == type) { + void *obj = NULL; + + /* get the dt object */ + if(NULL == (obj = (void *)H5I_object(obj_id))) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "invalid file identifier") + if (NULL == (obj = H5T_get_named_type((H5T_t *)obj))) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a named datatype") + if(H5G_loc_real(obj, type, &loc) < 0) { + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a file or file object") + } + } + else { + /* Get the object location information */ + if(H5G_loc(obj_id, &loc) < 0) + HGOTO_ERROR(H5E_ATOM, H5E_CANTGET, FAIL, "can't get object location") + } + + /* Get the file ID for the object */ + if((ret_value = H5F_get_id(loc.oloc->file, app_ref)) < 0) + HGOTO_ERROR(H5E_ATOM, H5E_CANTGET, FAIL, "can't get file ID") + } /* end if */ + else + HGOTO_ERROR(H5E_ARGS, H5E_BADRANGE, FAIL, "invalid object ID") done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5I_get_file_id() */ @@ -2386,7 +2418,7 @@ done: * *------------------------------------------------------------------------- */ -static hid_t +hid_t H5VL_get_id(void *object, H5I_type_t type) { hid_t ret_value = FAIL; /* Return value */ @@ -2409,6 +2441,7 @@ H5VL_get_id(void *object, H5I_type_t type) id_ptr = type_ptr->id_list[i]; while(id_ptr) { if (id_ptr->obj_ptr == object) { + ret_value = id_ptr->id; HGOTO_DONE(id_ptr->id); } id_ptr = id_ptr->next; diff --git a/src/H5Iprivate.h b/src/H5Iprivate.h index e15ea9c..428b02f 100644 --- a/src/H5Iprivate.h +++ b/src/H5Iprivate.h @@ -76,5 +76,6 @@ H5_DLL herr_t H5I_dec_type_ref(H5I_type_t type); H5_DLL int H5I_get_type_ref(H5I_type_t type); H5_DLL herr_t H5I_register_aux(hid_t id, void *aux_ptr, H5I_free2_t free_func); H5_DLL void *H5I_get_aux(hid_t id); +H5_DLL hid_t H5VL_get_id(void *object, H5I_type_t type); #endif /* _H5Iprivate_H */ diff --git a/src/H5Ipublic.h b/src/H5Ipublic.h index cded866..13cd3bf 100644 --- a/src/H5Ipublic.h +++ b/src/H5Ipublic.h @@ -36,8 +36,7 @@ typedef enum H5I_type_t { H5I_UNINIT = (-2), /*uninitialized type */ H5I_BADID = (-1), /*invalid Type */ - H5I_FILE_PRIVATE = 1, /*type ID for File objects */ - H5I_FILE, /*type ID for File 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 */ diff --git a/src/H5Lexternal.c b/src/H5Lexternal.c index c6562b3..d0729b1 100644 --- a/src/H5Lexternal.c +++ b/src/H5Lexternal.c @@ -28,6 +28,7 @@ #include "H5MMprivate.h" /* Memory management */ #include "H5Opublic.h" /* File objects */ #include "H5Pprivate.h" /* Property lists */ +#include "H5VLprivate.h" /* Virtual Object Layer */ static hid_t H5L_extern_traverse(const char UNUSED *link_name, hid_t cur_group, const void *udata, size_t UNUSED udata_size, hid_t lapl_id); @@ -539,11 +540,13 @@ herr_t H5Lcreate_external(const char *file_name, const char *obj_name, hid_t link_loc_id, const char *link_name, hid_t lcpl_id, hid_t lapl_id) { - H5G_loc_t link_loc; /* Group location to create link */ char *norm_obj_name = NULL; /* Pointer to normalized current name */ void *ext_link_buf = NULL; /* Buffer to contain external link */ size_t buf_size; /* Size of buffer to hold external link */ uint8_t *p; /* Pointer into external link buffer */ + void *obj = NULL; /* object token of loc_id */ + H5VL_t *vol_plugin; /* VOL plugin information */ + H5VL_loc_params_t loc_params; H5P_genplist_t *plist; /* Property list pointer */ H5L_type_t link_type = H5L_TYPE_EXTERNAL; herr_t ret_value = SUCCEED; /* Return value */ @@ -557,8 +560,6 @@ H5Lcreate_external(const char *file_name, const char *obj_name, HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "no file name specified") if(!obj_name || !*obj_name) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "no object name specified") - if(H5G_loc(link_loc_id, &link_loc) < 0) - HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a location") if(!link_name || !*link_name) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "no link name specified") @@ -582,6 +583,18 @@ H5Lcreate_external(const char *file_name, const char *obj_name, p += HDstrlen(file_name) + 1; HDstrcpy((char *)p, norm_obj_name); /* External link's object */ + loc_params.type = H5VL_OBJECT_BY_NAME; + loc_params.loc_data.loc_by_name.name = link_name; + loc_params.loc_data.loc_by_name.plist_id = lapl_id; + loc_params.obj_type = H5I_get_type(link_loc_id); + + /* get the file object */ + if(NULL == (obj = (void *)H5I_object(link_loc_id))) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "invalid file identifier") + /* get the plugin pointer */ + if (NULL == (vol_plugin = (H5VL_t *)H5I_get_aux(link_loc_id))) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "ID does not contain VOL information") + /* Get the plist structure */ if(NULL == (plist = (H5P_genplist_t *)H5I_object(lcpl_id))) HGOTO_ERROR(H5E_ATOM, H5E_BADATOM, FAIL, "can't find object for ID") @@ -595,8 +608,8 @@ H5Lcreate_external(const char *file_name, const char *obj_name, HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, FAIL, "can't get property value from plist") /* Create the link through the VOL */ - if((ret_value = H5VL_link_create(H5VL_LINK_CREATE_UD, link_loc_id, link_name, - lcpl_id, lapl_id)) < 0) + if((ret_value = H5VL_link_create(H5VL_LINK_CREATE_UD, obj, loc_params, vol_plugin, + lcpl_id, lapl_id, H5_REQUEST_NULL)) < 0) HGOTO_ERROR(H5E_SYM, H5E_CANTINIT, FAIL, "unable to create link") done: diff --git a/src/H5O.c b/src/H5O.c index 3392d07..ae50e33 100644 --- a/src/H5O.c +++ b/src/H5O.c @@ -481,7 +481,7 @@ H5Olink(hid_t obj_id, hid_t new_loc_id, const char *new_name, hid_t lcpl_id, if(H5L_SAME_LOC != obj_id) { /* get the file object */ - if(NULL == (obj1 = (void *)H5I_object(obj_id))) + if(NULL == (obj1 = (void *)H5VL_get_object(obj_id))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "invalid file identifier") /* get the plugin pointer */ if (NULL == (vol_plugin1 = (H5VL_t *)H5I_get_aux(obj_id))) @@ -489,7 +489,7 @@ H5Olink(hid_t obj_id, hid_t new_loc_id, const char *new_name, hid_t lcpl_id, } if(H5L_SAME_LOC != new_loc_id) { /* get the file object */ - if(NULL == (obj2 = (void *)H5I_object(new_loc_id))) + if(NULL == (obj2 = (void *)H5VL_get_object(new_loc_id))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "invalid file identifier") /* get the plugin pointer */ if (NULL == (vol_plugin2 = (H5VL_t *)H5I_get_aux(new_loc_id))) @@ -557,7 +557,7 @@ H5Oincr_refcount(hid_t object_id) loc_params.obj_type = H5I_get_type(object_id); /* get the file object */ - if(NULL == (obj = (void *)H5I_object(object_id))) + if(NULL == (obj = (void *)H5VL_get_object(object_id))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "invalid file identifier") /* get the plugin pointer */ if (NULL == (vol_plugin = (H5VL_t *)H5I_get_aux(object_id))) @@ -608,7 +608,7 @@ H5Odecr_refcount(hid_t object_id) loc_params.obj_type = H5I_get_type(object_id); /* get the file object */ - if(NULL == (obj = (void *)H5I_object(object_id))) + if(NULL == (obj = (void *)H5VL_get_object(object_id))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "invalid file identifier") /* get the plugin pointer */ if (NULL == (vol_plugin = (H5VL_t *)H5I_get_aux(object_id))) @@ -662,7 +662,7 @@ H5Oexists_by_name(hid_t loc_id, const char *name, hid_t lapl_id) loc_params.obj_type = H5I_get_type(loc_id); /* get the file object */ - if(NULL == (obj = (void *)H5I_object(loc_id))) + if(NULL == (obj = (void *)H5VL_get_object(loc_id))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "invalid file identifier") /* get the plugin pointer */ if (NULL == (vol_plugin = (H5VL_t *)H5I_get_aux(loc_id))) @@ -709,7 +709,7 @@ H5Oget_info(hid_t loc_id, H5O_info_t *oinfo) loc_params.obj_type = H5I_get_type(loc_id); /* get the file object */ - if(NULL == (obj = (void *)H5I_object(loc_id))) + if(NULL == (obj = (void *)H5VL_get_object(loc_id))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "invalid file identifier") /* get the plugin pointer */ if (NULL == (vol_plugin = (H5VL_t *)H5I_get_aux(loc_id))) @@ -766,7 +766,7 @@ H5Oget_info_by_name(hid_t loc_id, const char *name, H5O_info_t *oinfo, hid_t lap loc_params.obj_type = H5I_get_type(loc_id); /* get the file object */ - if(NULL == (obj = (void *)H5I_object(loc_id))) + if(NULL == (obj = (void *)H5VL_get_object(loc_id))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "invalid file identifier") /* get the plugin pointer */ @@ -834,7 +834,7 @@ H5Oget_info_by_idx(hid_t loc_id, const char *group_name, H5_index_t idx_type, loc_params.obj_type = H5I_get_type(loc_id); /* get the file object */ - if(NULL == (obj = (void *)H5I_object(loc_id))) + if(NULL == (obj = (void *)H5VL_get_object(loc_id))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "invalid file identifier") /* get the plugin pointer */ if (NULL == (vol_plugin = (H5VL_t *)H5I_get_aux(loc_id))) @@ -882,7 +882,7 @@ H5Oset_comment(hid_t obj_id, const char *comment) loc_params.obj_type = H5I_get_type(obj_id); /* get the file object */ - if(NULL == (obj = (void *)H5I_object(obj_id))) + if(NULL == (obj = (void *)H5VL_get_object(obj_id))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "invalid file identifier") /* get the plugin pointer */ if (NULL == (vol_plugin = (H5VL_t *)H5I_get_aux(obj_id))) @@ -941,7 +941,7 @@ H5Oset_comment_by_name(hid_t loc_id, const char *name, const char *comment, loc_params.obj_type = H5I_get_type(loc_id); /* get the file object */ - if(NULL == (obj = (void *)H5I_object(loc_id))) + if(NULL == (obj = (void *)H5VL_get_object(loc_id))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "invalid file identifier") /* get the plugin pointer */ if (NULL == (vol_plugin = (H5VL_t *)H5I_get_aux(loc_id))) @@ -987,7 +987,7 @@ H5Oget_comment(hid_t loc_id, char *comment, size_t bufsize) loc_params.obj_type = H5I_get_type(loc_id); /* get the file object */ - if(NULL == (obj = (void *)H5I_object(loc_id))) + if(NULL == (obj = (void *)H5VL_get_object(loc_id))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "invalid file identifier") /* get the plugin pointer */ if (NULL == (vol_plugin = (H5VL_t *)H5I_get_aux(loc_id))) @@ -1045,7 +1045,7 @@ H5Oget_comment_by_name(hid_t loc_id, const char *name, char *comment, size_t buf loc_params.obj_type = H5I_get_type(loc_id); /* get the file object */ - if(NULL == (obj = (void *)H5I_object(loc_id))) + if(NULL == (obj = (void *)H5VL_get_object(loc_id))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "invalid file identifier") /* get the plugin pointer */ if (NULL == (vol_plugin = (H5VL_t *)H5I_get_aux(loc_id))) @@ -1116,7 +1116,7 @@ H5Ovisit(hid_t obj_id, H5_index_t idx_type, H5_iter_order_t order, loc_params.obj_type = H5I_get_type(obj_id); /* get the file object */ - if(NULL == (obj = (void *)H5I_object(obj_id))) + if(NULL == (obj = (void *)H5VL_get_object(obj_id))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "invalid file identifier") /* get the plugin pointer */ if (NULL == (vol_plugin = (H5VL_t *)H5I_get_aux(obj_id))) @@ -1198,7 +1198,7 @@ H5Ovisit_by_name(hid_t loc_id, const char *obj_name, H5_index_t idx_type, loc_params.obj_type = H5I_get_type(loc_id); /* get the file object */ - if(NULL == (obj = (void *)H5I_object(loc_id))) + if(NULL == (obj = (void *)H5VL_get_object(loc_id))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "invalid file identifier") /* get the plugin pointer */ if (NULL == (vol_plugin = (H5VL_t *)H5I_get_aux(loc_id))) @@ -1638,7 +1638,7 @@ H5O_close(H5O_loc_t *loc) #ifdef H5O_DEBUG if(H5DEBUG(O)) { - if(H5F_FILE_ID(loc->file)< 0 && 1 == H5F_NREFS(loc->file)) + if(/*H5F_FILE_ID(loc->file)< 0 &&*/ 1 == H5F_NREFS(loc->file)) HDfprintf(H5DEBUG(O), "< %a auto %lu remaining\n", loc->addr, (unsigned long)H5F_NOPEN_OBJS(loc->file)); @@ -3539,7 +3539,7 @@ H5O_visit(H5G_loc_t *loc, const char *obj_name, H5_index_t idx_type, } /* end if */ /* Call internal group visitation routine */ - if((ret_value = H5G_visit(obj_id, ".", idx_type, order, H5O_visit_cb, &udata, lapl_id, dxpl_id)) < 0) + if((ret_value = H5G_visit(&obj_loc, ".", idx_type, order, H5O_visit_cb, &udata, lapl_id, dxpl_id)) < 0) HGOTO_ERROR(H5E_OHDR, H5E_BADITER, FAIL, "object visitation failed") } /* end if */ diff --git a/src/H5Ocopy.c b/src/H5Ocopy.c index 482f1ba..e805cc2 100644 --- a/src/H5Ocopy.c +++ b/src/H5Ocopy.c @@ -1914,7 +1914,7 @@ H5O_copy_search_comm_dt(H5F_t *file_src, H5O_t *oh_src, /* Traverse the destination file, adding committed datatypes to the skip * list */ - if(H5G_visit(H5F_FILE_ID(oloc_dst->file), "/", H5_INDEX_NAME, H5_ITER_NATIVE, H5O_copy_search_comm_dt_cb, &udata, H5P_LINK_ACCESS_DEFAULT, dxpl_id) < 0) + if(H5G_visit(&dst_root_loc, "/", H5_INDEX_NAME, H5_ITER_NATIVE, H5O_copy_search_comm_dt_cb, &udata, H5P_LINK_ACCESS_DEFAULT, dxpl_id) < 0) HGOTO_ERROR(H5E_OHDR, H5E_BADITER, FAIL, "object visitation failed") cpy_info->dst_dt_list_complete = TRUE; } /* end if */ diff --git a/src/H5T.c b/src/H5T.c index ef75d41..30dec9a 100644 --- a/src/H5T.c +++ b/src/H5T.c @@ -2953,6 +2953,7 @@ H5T_decode(const unsigned char *buf) if(H5T_set_loc(ret_value, NULL, H5T_LOC_MEMORY) < 0) HGOTO_ERROR(H5E_DATATYPE, H5E_CANTINIT, NULL, "invalid datatype location") + ret_value->vol_obj = NULL; done: /* Release fake file structure */ if(f && H5F_fake_free(f) < 0) @@ -3074,6 +3075,7 @@ H5T__create(H5T_class_t type, size_t size) if(H5T_STRING != type || H5T_VARIABLE != size) dt->shared->size = size; + dt->vol_obj = NULL; /* Set return value */ ret_value = dt; @@ -3139,6 +3141,10 @@ H5T_copy(const H5T_t *old_dt, H5T_copy_t method) /* check args */ HDassert(old_dt); + /* Check if the VOL_obj exists, then this type is the one we want to copy */ + //if(NULL != old->vol_obj) + // old_dt = (H5T_t *)(old->vol_obj); + /* Allocate space */ if(NULL == (new_dt = H5FL_MALLOC(H5T_t))) HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, NULL, "memory allocation failed"); @@ -3458,6 +3464,7 @@ H5T__alloc(void) if(NULL == (dt->shared = H5FL_CALLOC(H5T_shared_t))) HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, NULL, "memory allocation failed") dt->shared->version = H5O_DTYPE_VERSION_1; + dt->vol_obj = NULL; /* Assign return value */ ret_value = dt; diff --git a/src/H5Tcommit.c b/src/H5Tcommit.c index ae3bc53..707ef21 100644 --- a/src/H5Tcommit.c +++ b/src/H5Tcommit.c @@ -158,6 +158,22 @@ 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") + if(NULL == (type = (H5T_t *)H5I_object_verify(type_id, H5I_DATATYPE))) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a datatype") + /* + * Check arguments. We cannot commit an immutable type because H5Tclose() + * normally fails on such types (try H5Tclose(H5T_NATIVE_INT)) but closing + * a named type should always succeed. + */ + if(H5T_STATE_NAMED == type->shared->state || H5T_STATE_OPEN == type->shared->state) + HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "datatype is already committed") + if(H5T_STATE_IMMUTABLE == type->shared->state) + HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "datatype is immutable") + + /* Check for a "sensible" datatype to store on disk */ + if(H5T_is_sensible(type) <= 0) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "datatype is not sensible") + loc_params.type = H5VL_OBJECT_BY_SELF; loc_params.obj_type = H5I_get_type(loc_id); @@ -175,9 +191,6 @@ H5Tcommit2(hid_t loc_id, const char *name, hid_t type_id, hid_t lcpl_id, /* attach the vol object created using the commit call to the library datatype structure */ - if(NULL == (type = (H5T_t *)H5I_object_verify(type_id, H5I_DATATYPE))) - HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a datatype") - /* set the committed type object to the VOL pluging pointer in the H5T_t struct */ type->vol_obj = dt; @@ -491,6 +504,7 @@ done: htri_t H5Tcommitted(hid_t type_id) { + H5T_t *dt; H5T_t *type; /* Datatype to query */ htri_t ret_value; /* Return value */ @@ -502,11 +516,12 @@ H5Tcommitted(hid_t type_id) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a datatype") if (NULL == type->vol_obj) - ret_value = FALSE; + dt = type; else - ret_value = TRUE; + dt = (H5T_t *)type->vol_obj; + /* Set return value */ - //ret_value = H5T_committed(type); + ret_value = H5T_committed(dt); done: FUNC_LEAVE_API(ret_value) @@ -528,7 +543,6 @@ done: htri_t H5T_committed(const H5T_t *type) { - /* Use no-init for efficiency */ FUNC_ENTER_NOAPI_NOINIT_NOERR HDassert(type); @@ -590,10 +604,7 @@ H5Topen2(hid_t loc_id, const char *name, hid_t tapl_id) void *dt = NULL; /* datatype token from VOL plugin */ void *obj = NULL; /* object token of loc_id */ H5VL_t *vol_plugin; /* VOL plugin information */ - H5T_t *type = NULL; H5VL_loc_params_t loc_params; - ssize_t nalloc; - unsigned char *buf = NULL; hid_t ret_value = FAIL; /* Return value */ FUNC_ENTER_API(FAIL) @@ -703,13 +714,17 @@ H5Tget_create_plist(hid_t dtype_id) HGOTO_ERROR(H5E_DATATYPE, H5E_CANTGET, FAIL, "unable to copy the creation property list") /* Check if the datatype is committed */ - if((status = H5T_committed(type)) < 0) + if((status = H5Tcommitted(dtype_id)) < 0) HGOTO_ERROR(H5E_DATATYPE, H5E_CANTGET, FAIL, "can't check whether datatype is committed") /* Retrieve further information, if the datatype is committed */ if(status > 0) { H5P_genplist_t *new_plist; /* New datatype creation property list */ + /* get the named datatype object */ + if(NULL == (type = (H5T_t *)H5VL_get_object(dtype_id))) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "invalid file identifier") + /* Get property list object for new TCPL */ if(NULL == (new_plist = (H5P_genplist_t *)H5I_object(new_tcpl_id))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "can't get property list") @@ -987,7 +1002,7 @@ H5VL_create_datatype(void *dt_obj, H5VL_t *vol_plugin, hid_t req) FUNC_ENTER_NOAPI(FAIL) /* get required buf size for encoding the datatype */ - if((nalloc = H5VL_datatype_get_binary(dt_obj, vol_plugin, NULL, 0, H5_REQUEST_NULL)) < 0) + if((nalloc = H5VL_datatype_get_binary(dt_obj, vol_plugin, NULL, 0, req)) < 0) HGOTO_ERROR(H5E_SYM, H5E_CANTINIT, FAIL, "unable to get datatype size") /* allocate buffer to store binary description of the datatype */ @@ -995,7 +1010,7 @@ H5VL_create_datatype(void *dt_obj, H5VL_t *vol_plugin, hid_t req) HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, FAIL, "can't allocate space for datatype") /* get binary description of the datatype */ - if((nalloc = H5VL_datatype_get_binary(dt_obj, vol_plugin, buf, (size_t) nalloc, H5_REQUEST_NULL)) < 0) + if((nalloc = H5VL_datatype_get_binary(dt_obj, vol_plugin, buf, (size_t) nalloc, req)) < 0) HGOTO_ERROR(H5E_SYM, H5E_CANTINIT, FAIL, "unable to get datatype size") if(NULL == (dt = H5T_decode(buf))) diff --git a/src/H5Tprecis.c b/src/H5Tprecis.c index c5ac186..dd89b59 100644 --- a/src/H5Tprecis.c +++ b/src/H5Tprecis.c @@ -174,7 +174,7 @@ H5Tset_precision(hid_t type_id, size_t prec) FUNC_ENTER_API(FAIL) H5TRACE2("e", "iz", type_id, prec); - + /* Check args */ if (NULL == (dt = H5I_object_verify(type_id,H5I_DATATYPE))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a datatype") diff --git a/src/H5VL.c b/src/H5VL.c index 4a1bfa6..2c08e0e 100644 --- a/src/H5VL.c +++ b/src/H5VL.c @@ -380,7 +380,6 @@ H5VLregister_object(void *obj, H5I_type_t obj_type, const H5VL_class_t *cls) if (H5I_register_aux(ret_value, vol_plugin, (H5I_free2_t)H5A_close_attr) < 0) HGOTO_ERROR(H5E_VOL, H5E_CANTINIT, FAIL, "can't attach vol info to ID") break; - case H5I_FILE_PRIVATE: case H5I_UNINIT: case H5I_BADID: case H5I_DATASPACE: diff --git a/src/H5VLint.c b/src/H5VLint.c index 14f7d98..41d407c 100644 --- a/src/H5VLint.c +++ b/src/H5VLint.c @@ -336,7 +336,6 @@ H5VL_object_register(void *obj, H5I_type_t obj_type, H5VL_t *vol_plugin) HGOTO_ERROR(H5E_ATOM, H5E_CANTREGISTER, FAIL, "unable to atomize datatype handle") break; - case H5I_FILE_PRIVATE: case H5I_UNINIT: case H5I_BADID: case H5I_FILE: @@ -362,6 +361,42 @@ done: /*------------------------------------------------------------------------- + * Function: H5VL_get_object + * + * Purpose: utility function to return the object pointer associated with + * an hid_t. This routine is the same as H5I_object for all types + * except for named datatypes, where the vol_obj is returned that + * is attached to the H5T_t struct. + * + * Return: Success: object pointer + * Failure: NULL + * + * Programmer: Mohamad Chaarawi + * June, 2012 + * + *------------------------------------------------------------------------- + */ +void * +H5VL_get_object(hid_t id) +{ + void *ret_value = NULL; + + FUNC_ENTER_NOAPI(NULL) + + /* get the object */ + if(NULL == (ret_value = (void *)H5I_object(id))) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, NULL, "invalid file identifier") + + if (H5I_DATATYPE == H5I_get_type(id)) { + if (NULL == (ret_value = H5T_get_named_type((H5T_t *)ret_value))) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, NULL, "not a named datatype") + } +done: + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5VL_get_object() */ + + +/*------------------------------------------------------------------------- * Function: H5VL_attr_create * * Purpose: Creates an attribute through the VOL diff --git a/src/H5VLnative.c b/src/H5VLnative.c index b8f5550..413bb2f 100644 --- a/src/H5VLnative.c +++ b/src/H5VLnative.c @@ -63,7 +63,6 @@ static hid_t H5VL_NATIVE_g = 0; /* Prototypes */ static H5F_t *H5VL_native_get_file(void *obj, H5I_type_t type); -static herr_t H5VL_native_get_loc(void *obj, H5I_type_t type, H5G_loc_t *loc); static herr_t H5VL_native_term(void); /* Atrribute callbacks */ @@ -272,84 +271,6 @@ H5VL_native_term(void) /*--------------------------------------------------------------------------- - * Function: H5VL_native_get_loc - * - * Purpose: utility routine to get object location - * - * Returns: Non-negative on success or negative on failure - * - * Programmer: Mohamad Chaarawi - * June, 2012 - * - *--------------------------------------------------------------------------- - */ -static herr_t -H5VL_native_get_loc(void *obj, H5I_type_t type, H5G_loc_t *loc) -{ - herr_t ret_value = SUCCEED; - - FUNC_ENTER_NOAPI_NOINIT - - switch(type) { - case H5I_FILE: - /* Construct a group location for root group of the file */ - if(H5G_root_loc((H5F_t *)obj, loc) < 0) - HGOTO_ERROR(H5E_SYM, H5E_BADVALUE, FAIL, "unable to create location for file") - break; - case H5I_GROUP: - if(NULL == (loc->oloc = H5G_oloc((H5G_t *)obj))) - HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "unable to get object location of group") - if(NULL == (loc->path = H5G_nameof((H5G_t *)obj))) - HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "unable to get path of group") - break; - case H5I_DATATYPE: - if(NULL == (loc->oloc = H5T_oloc((H5T_t *)obj))) - HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "unable to get object location of datatype") - if(NULL == (loc->path = H5T_nameof((H5T_t *)obj))) - HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "unable to get path of datatype") -#if 0 - H5T_t *tmp_dt = (H5T_t *)obj; - H5T_t *dt = (H5T_t *)(tmp_dt->vol_obj); - if(NULL == (loc->oloc = H5T_oloc(dt))) - HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "unable to get object location of datatype") - if(NULL == (loc->path = H5T_nameof(dt))) - HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "unable to get path of datatype") -#endif - break; - case H5I_DATASET: - if(NULL == (loc->oloc = H5D_oloc((H5D_t *)obj))) - HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "unable to get object location of dataset") - if(NULL == (loc->path = H5D_nameof((H5D_t *)obj))) - HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "unable to get path of dataset") - break; - case H5I_ATTR: - if(NULL == (loc->oloc = H5A_oloc((H5A_t *)obj))) - HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "unable to get object location of attribute") - if(NULL == (loc->path = H5A_nameof((H5A_t *)obj))) - HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "unable to get path of attribute") - break; - case H5I_FILE_PRIVATE: - case H5I_UNINIT: - case H5I_BADID: - case H5I_DATASPACE: - case H5I_REFERENCE: - case H5I_VFL: - case H5I_VOL: - case H5I_GENPROP_CLS: - case H5I_GENPROP_LST: - case H5I_ERROR_CLASS: - case H5I_ERROR_MSG: - case H5I_ERROR_STACK: - case H5I_NTYPES: - default: - HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a file or file object") - } /* end switch */ -done: - FUNC_LEAVE_NOAPI(ret_value) -} /* H5VL_native_get_loc */ - - -/*--------------------------------------------------------------------------- * Function: H5VL_native_get_file * * Purpose: utility routine to get file object @@ -402,7 +323,6 @@ H5VL_native_get_file(void *obj, H5I_type_t type) oloc = H5A_oloc(attr); break; } - case H5I_FILE_PRIVATE: case H5I_UNINIT: case H5I_BADID: case H5I_DATASPACE: @@ -460,26 +380,25 @@ H5VL_native_register_aux(hid_t obj_id) switch(H5I_get_type(obj_id)) { case H5I_FILE: - if (H5I_register_aux(obj_id, vol_plugin, (H5I_free2_t)H5F_close_file) < 0) + if(H5I_register_aux(obj_id, vol_plugin, (H5I_free2_t)H5F_close_file) < 0) HGOTO_ERROR(H5E_VOL, H5E_CANTINIT, FAIL, "can't attach vol info to ID") break; case H5I_GROUP: - if (H5I_register_aux(obj_id, vol_plugin, (H5I_free2_t)H5G_close_group) < 0) + if(H5I_register_aux(obj_id, vol_plugin, (H5I_free2_t)H5G_close_group) < 0) HGOTO_ERROR(H5E_VOL, H5E_CANTINIT, FAIL, "can't attach vol info to ID") break; case H5I_DATATYPE: - if (H5I_register_aux(obj_id, vol_plugin, (H5I_free2_t)H5T_close_datatype) < 0) + if(H5I_register_aux(obj_id, vol_plugin, (H5I_free2_t)H5T_close_datatype) < 0) HGOTO_ERROR(H5E_VOL, H5E_CANTINIT, FAIL, "can't attach vol info to ID") break; case H5I_DATASET: - if (H5I_register_aux(obj_id, vol_plugin, (H5I_free2_t)H5D_close_dataset) < 0) + if(H5I_register_aux(obj_id, vol_plugin, (H5I_free2_t)H5D_close_dataset) < 0) HGOTO_ERROR(H5E_VOL, H5E_CANTINIT, FAIL, "can't attach vol info to ID") break; case H5I_ATTR: - if (H5I_register_aux(obj_id, vol_plugin, (H5I_free2_t)H5A_close_attr) < 0) + if(H5I_register_aux(obj_id, vol_plugin, (H5I_free2_t)H5A_close_attr) < 0) HGOTO_ERROR(H5E_VOL, H5E_CANTINIT, FAIL, "can't attach vol info to ID") break; - case H5I_FILE_PRIVATE: case H5I_UNINIT: case H5I_BADID: case H5I_DATASPACE: @@ -555,6 +474,7 @@ H5VL_native_attr_create(void *obj, H5VL_loc_params_t loc_params, const char *att H5P_genplist_t *plist; /* Property list pointer */ hid_t type_id, space_id; H5T_t *type; /* Datatype to use for attribute */ + H5T_t *named_type; /* Named Datatype to use for attribute */ H5S_t *space; /* Dataspace to use for attribute */ H5A_t *attr = NULL; void *ret_value = NULL; @@ -571,7 +491,7 @@ H5VL_native_attr_create(void *obj, H5VL_loc_params_t loc_params, const char *att if(H5P_get(plist, H5VL_ATTR_SPACE_ID, &space_id) < 0) HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, NULL, "can't get property value for space id") - if (H5VL_native_get_loc(obj, loc_params.obj_type, &loc) < 0) + if(H5G_loc_real(obj, loc_params.obj_type, &loc) < 0) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, NULL, "not a file or file object") if(0 == (H5F_INTENT(loc.oloc->file) & H5F_ACC_RDWR)) HGOTO_ERROR(H5E_ARGS, H5E_WRITEERROR, NULL, "no write intent on file") @@ -580,12 +500,17 @@ H5VL_native_attr_create(void *obj, H5VL_loc_params_t loc_params, const char *att if(NULL == (space = (H5S_t *)H5I_object_verify(space_id, H5I_DATASPACE))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, NULL, "not a data space") + //if(NULL != (named_type = (H5T_t *)H5T_get_named_type(type))) + if(H5T_STATE_OPEN == type->shared->state || H5T_STATE_NAMED == type->shared->state){ + type = (H5T_t *)(type->vol_obj); + } + if(loc_params.type == H5VL_OBJECT_BY_SELF) { /* H5Acreate */ /* Go do the real work for attaching the attribute to the dataset */ if(NULL == (attr = H5A_create(&loc, attr_name, type, space, acpl_id, H5AC_dxpl_id))) HGOTO_ERROR(H5E_ATTR, H5E_CANTINIT, NULL, "unable to create attribute") } - else if (loc_params.type == H5VL_OBJECT_BY_NAME) { /* H5Acreate_by_name */ + else if(loc_params.type == H5VL_OBJECT_BY_NAME) { /* H5Acreate_by_name */ H5G_name_t obj_path; /* Opened object group hier. path */ H5O_loc_t obj_oloc; /* Opened object object location */ @@ -607,7 +532,6 @@ H5VL_native_attr_create(void *obj, H5VL_loc_params_t loc_params, const char *att else { HGOTO_ERROR(H5E_VOL, H5E_UNSUPPORTED, NULL, "unknown attribute create parameters") } - ret_value = (void *)attr; done: @@ -642,7 +566,7 @@ H5VL_native_attr_open(void *obj, H5VL_loc_params_t loc_params, const char *attr_ FUNC_ENTER_NOAPI_NOINIT /* check arguments */ - if (H5VL_native_get_loc(obj, loc_params.obj_type, &loc) < 0) + if(H5G_loc_real(obj, loc_params.obj_type, &loc) < 0) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, NULL, "not a file or file object") if(loc_params.type == H5VL_OBJECT_BY_SELF) { /* H5Aopen */ @@ -771,7 +695,7 @@ H5VL_native_attr_get(void *obj, H5VL_attr_get_t get_type, hid_t UNUSED req, va_l H5G_loc_t loc; /* check arguments */ - if (H5VL_native_get_loc(obj, loc_params.obj_type, &loc) < 0) + if(H5G_loc_real(obj, loc_params.obj_type, &loc) < 0) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a file or file object") if(loc_params.type == H5VL_OBJECT_BY_SELF) { /* H5Aexists */ @@ -841,7 +765,7 @@ H5VL_native_attr_get(void *obj, H5VL_attr_get_t get_type, hid_t UNUSED req, va_l H5G_loc_t loc; /* check arguments */ - if (H5VL_native_get_loc(obj, loc_params.obj_type, &loc) < 0) + if(H5G_loc_real(obj, loc_params.obj_type, &loc) < 0) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a file or file object") /* Open the attribute on the object header */ @@ -889,7 +813,7 @@ H5VL_native_attr_get(void *obj, H5VL_attr_get_t get_type, hid_t UNUSED req, va_l H5G_loc_t loc; /* check arguments */ - if (H5VL_native_get_loc(obj, loc_params.obj_type, &loc) < 0) + if(H5G_loc_real(obj, loc_params.obj_type, &loc) < 0) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a file or file object") /* Open the attribute on the object header */ @@ -911,7 +835,7 @@ H5VL_native_attr_get(void *obj, H5VL_attr_get_t get_type, hid_t UNUSED req, va_l H5G_loc_t loc; /* check arguments */ - if (H5VL_native_get_loc(obj, loc_params.obj_type, &loc) < 0) + if(H5G_loc_real(obj, loc_params.obj_type, &loc) < 0) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a file or file object") /* Open the attribute on the object header */ @@ -981,7 +905,7 @@ H5VL_native_attr_remove(void *obj, H5VL_loc_params_t loc_params, const char *att FUNC_ENTER_NOAPI_NOINIT /* check arguments */ - if (H5VL_native_get_loc(obj, loc_params.obj_type, &loc) < 0) + if(H5G_loc_real(obj, loc_params.obj_type, &loc) < 0) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a file or file object") if(loc_params.type == H5VL_OBJECT_BY_SELF) { /* H5Adelete */ @@ -989,7 +913,7 @@ H5VL_native_attr_remove(void *obj, H5VL_loc_params_t loc_params, const char *att if(H5O_attr_remove(loc.oloc, attr_name, H5AC_dxpl_id) < 0) HGOTO_ERROR(H5E_ATTR, H5E_CANTDELETE, FAIL, "unable to delete attribute") } - else if (loc_params.type == H5VL_OBJECT_BY_NAME) { /* H5Adelete_by_name */ + else if(loc_params.type == H5VL_OBJECT_BY_NAME) { /* H5Adelete_by_name */ /* Set up opened group location to fill in */ obj_loc.oloc = &obj_oloc; obj_loc.path = &obj_path; @@ -1089,7 +1013,7 @@ H5VL_native_datatype_commit(void *obj, H5VL_loc_params_t loc_params, const char FUNC_ENTER_NOAPI_NOINIT /* check arguments */ - if (H5VL_native_get_loc(obj, loc_params.obj_type, &loc) < 0) + if(H5G_loc_real(obj, loc_params.obj_type, &loc) < 0) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, NULL, "not a file or file object") if(NULL == (dt = (H5T_t *)H5I_object_verify(type_id, H5I_DATATYPE))) @@ -1101,7 +1025,7 @@ H5VL_native_datatype_commit(void *obj, H5VL_loc_params_t loc_params, const char if(NULL == (type = H5T_copy(dt, H5T_COPY_TRANSIENT))) HGOTO_ERROR(H5E_DATATYPE, H5E_CANTINIT, NULL, "unable to copy"); - if (NULL != name) { /* H5Tcommit */ + if(NULL != name) { /* H5Tcommit */ /* 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, NULL, "unable to commit datatype") @@ -1164,7 +1088,7 @@ H5VL_native_datatype_open(void *obj, H5VL_loc_params_t loc_params, const char *n FUNC_ENTER_NOAPI_NOINIT - if (H5VL_native_get_loc(obj, loc_params.obj_type, &loc) < 0) + if(H5G_loc_real(obj, loc_params.obj_type, &loc) < 0) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, NULL, "not a file or file object") /* Set up datatype location to fill in */ @@ -1298,7 +1222,7 @@ H5VL_native_dataset_create(void *obj, H5VL_loc_params_t loc_params, const char * HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, NULL, "can't get property value for lcpl id") /* Check arguments */ - if (H5VL_native_get_loc(obj, loc_params.obj_type, &loc) < 0) + if(H5G_loc_real(obj, loc_params.obj_type, &loc) < 0) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, NULL, "not a file or file object") if(H5I_DATATYPE != H5I_get_type(type_id)) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, NULL, "not a datatype ID") @@ -1306,7 +1230,7 @@ H5VL_native_dataset_create(void *obj, H5VL_loc_params_t loc_params, const char * HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, NULL, "not a dataspace ID") /* H5Dcreate_anon */ - if (NULL == name) { + if(NULL == name) { /* 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, NULL, "unable to create dataset") @@ -1368,7 +1292,7 @@ H5VL_native_dataset_open(void *obj, H5VL_loc_params_t loc_params, const char *na FUNC_ENTER_NOAPI_NOINIT - if (H5VL_native_get_loc(obj, loc_params.obj_type, &loc) < 0) + if(H5G_loc_real(obj, loc_params.obj_type, &loc) < 0) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, NULL, "not a file or file object") /* Set up dataset location to fill in */ @@ -1703,11 +1627,11 @@ done: *------------------------------------------------------------------------- */ static void * -H5VL_native_file_create(const char *name, unsigned flags, hid_t fcpl_id, hid_t fapl_id, hid_t UNUSED req) +H5VL_native_file_create(const char *name, unsigned flags, hid_t fcpl_id, hid_t fapl_id, + hid_t UNUSED req) { H5F_t *new_file = NULL; - hid_t file_id = FAIL; - void *ret_value; + void *ret_value = NULL; FUNC_ENTER_NOAPI_NOINIT @@ -1716,26 +1640,29 @@ H5VL_native_file_create(const char *name, unsigned flags, hid_t fcpl_id, hid_t f * the EXCL or TRUNC bit is set. All newly-created files are opened for * reading and writing. */ - if (0==(flags & (H5F_ACC_EXCL|H5F_ACC_TRUNC))) + if(0==(flags & (H5F_ACC_EXCL|H5F_ACC_TRUNC))) flags |= H5F_ACC_EXCL; /*default*/ flags |= H5F_ACC_RDWR | H5F_ACC_CREAT; /* Create the file */ if(NULL == (new_file = H5F_open(name, flags, fcpl_id, fapl_id, H5AC_dxpl_id))) HGOTO_ERROR(H5E_FILE, H5E_CANTOPENFILE, NULL, "unable to create file") +#if 0 /* Get an atom for the file */ if((file_id = H5I_register(H5I_FILE_PRIVATE, new_file, TRUE)) < 0) HGOTO_ERROR(H5E_ATOM, H5E_CANTREGISTER, NULL, "unable to atomize file handle") /* store a pointer to the VOL class in the file structure */ new_file->vol_cls = &H5VL_native_g; new_file->file_id = file_id; - - ret_value = (void *)new_file; - -done: if(file_id < 0 && new_file && H5F_try_close(new_file) < 0) HDONE_ERROR(H5E_FILE, H5E_CANTCLOSEFILE, NULL, "problems closing file") +#endif + ret_value = (void *)new_file; +done: + if(NULL == ret_value && new_file) + if(H5F_close(new_file) < 0) + HDONE_ERROR(H5E_FILE, H5E_CANTCLOSEFILE, NULL, "problems closing file") FUNC_LEAVE_NOAPI(ret_value) } /* end H5VL_native_file_create() */ @@ -1757,25 +1684,27 @@ static void * H5VL_native_file_open(const char *name, unsigned flags, hid_t fapl_id, hid_t UNUSED req) { H5F_t *new_file = NULL; - hid_t file_id = FAIL; - void *ret_value; + void *ret_value = NULL; FUNC_ENTER_NOAPI_NOINIT /* Open the file */ if(NULL == (new_file = H5F_open(name, flags, H5P_FILE_CREATE_DEFAULT, fapl_id, H5AC_dxpl_id))) HGOTO_ERROR(H5E_FILE, H5E_CANTOPENFILE, NULL, "unable to open file") +#if 0 /* Get an atom for the file */ if((file_id = H5I_register(H5I_FILE_PRIVATE, new_file, TRUE)) < 0) HGOTO_ERROR(H5E_ATOM, H5E_CANTREGISTER, NULL, "unable to atomize file handle") /* store a pointer to the VOL class in the file structure */ new_file->vol_cls = &H5VL_native_g; new_file->file_id = file_id; - + if(file_id < 0 && new_file && H5F_try_close(new_file) < 0) + HDONE_ERROR(H5E_FILE, H5E_CANTCLOSEFILE, NULL, "problems closing file") +#endif ret_value = (void *)new_file; done: - if(file_id < 0 && new_file && H5F_try_close(new_file) < 0) + if(NULL == ret_value && new_file && H5F_try_close(new_file) < 0) HDONE_ERROR(H5E_FILE, H5E_CANTCLOSEFILE, NULL, "problems closing file") FUNC_LEAVE_NOAPI(ret_value) } /* end H5VL_native_file_open() */ @@ -1802,7 +1731,7 @@ H5VL_native_file_flush(void *obj, H5VL_loc_params_t loc_params, H5F_scope_t scop FUNC_ENTER_NOAPI_NOINIT - if (NULL == (f = H5VL_native_get_file(obj, loc_params.obj_type))) { + if(NULL == (f = H5VL_native_get_file(obj, loc_params.obj_type))) { HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a file or file object") } @@ -1941,7 +1870,7 @@ H5VL_native_file_get(void *obj, H5VL_file_get_t get_type, hid_t UNUSED req, va_l ssize_t *ret = va_arg (arguments, ssize_t *); size_t len; - if (NULL == (f = H5VL_native_get_file(obj, type))) { + if(NULL == (f = H5VL_native_get_file(obj, type))) { HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a file or file object") } @@ -1961,13 +1890,18 @@ H5VL_native_file_get(void *obj, H5VL_file_get_t get_type, hid_t UNUSED req, va_l case H5VL_OBJECT_GET_FILE: { H5I_type_t type = va_arg (arguments, H5I_type_t); - hbool_t app_ref = va_arg (arguments, hbool_t); void **ret = va_arg (arguments, void **); + + if(NULL == (f = H5VL_native_get_file(obj, type))) { + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a file or file object") + } +#if 0 + hbool_t app_ref = va_arg (arguments, hbool_t); H5F_t *file = NULL; hid_t file_id; H5G_loc_t loc; /* Location of object */ - if (H5VL_native_get_loc(obj, type, &loc) < 0) { + if(H5G_loc_real(obj, type, &loc) < 0) { HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a file or file object") } /* Get the file ID for the object */ @@ -1977,7 +1911,8 @@ H5VL_native_file_get(void *obj, H5VL_file_get_t get_type, hid_t UNUSED req, va_l /* return the file object */ if(NULL == (file = (H5F_t *)H5I_object(file_id))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "invalid file identifier") - *ret = (void*)file; +#endif + *ret = (void*)f; break; } default: @@ -2018,7 +1953,7 @@ H5VL_native_file_misc(void *obj, H5VL_file_misc_t misc_type, hid_t UNUSED req, v hid_t plist_id = va_arg (arguments, hid_t); H5G_loc_t loc; - if (H5VL_native_get_loc(obj, type, &loc) < 0) { + if(H5G_loc_real(obj, type, &loc) < 0) { HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a file or file object") } /* Do the mount */ @@ -2034,11 +1969,11 @@ H5VL_native_file_misc(void *obj, H5VL_file_misc_t misc_type, hid_t UNUSED req, v const char *name = va_arg (arguments, const char *); H5G_loc_t loc; - if (H5VL_native_get_loc(obj, type, &loc) < 0) { + if(H5G_loc_real(obj, type, &loc) < 0) { HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a file or file object") } /* Unmount */ - if (H5F_unmount(&loc, name, H5AC_dxpl_id) < 0) + if(H5F_unmount(&loc, name, H5AC_dxpl_id) < 0) HGOTO_ERROR(H5E_FILE, H5E_MOUNT, FAIL, "unable to unmount file") break; @@ -2145,7 +2080,7 @@ H5VL_native_file_optional(void *obj, H5VL_file_optional_t optional_type, hid_t U H5I_type_t type = va_arg (arguments, H5I_type_t); H5F_info2_t *finfo = va_arg (arguments, H5F_info2_t *); - if (NULL == (f = H5VL_native_get_file(obj, type))) { + if(NULL == (f = H5VL_native_get_file(obj, type))) { HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a file or file object") } @@ -2301,6 +2236,7 @@ H5VL_native_file_close(void *file, hid_t UNUSED req) { int nref; H5F_t *f = (H5F_t *)file; + hid_t file_id = FAIL; herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_NOAPI_NOINIT @@ -2310,19 +2246,27 @@ H5VL_native_file_close(void *file, hid_t UNUSED req) * This is only necessary to replicate previous behaviour, and could be * disabled by an option/property to improve performance. */ if((f->shared->nrefs > 1) && (H5F_INTENT(f) & H5F_ACC_RDWR)) { - if((nref = H5I_get_ref(f->file_id, FALSE)) < 0) + /* get the file ID corresponding to the H5F_t struct */ + if((file_id = H5VL_get_id(f, H5I_FILE)) < 0) + HGOTO_ERROR(H5E_ATOM, H5E_CANTGET, FAIL, "invalid atom") + /* get the number of references outstanding for this file ID */ + if((nref = H5I_get_ref(file_id, FALSE)) < 0) HGOTO_ERROR(H5E_ATOM, H5E_CANTGET, FAIL, "can't get ID ref count") if(nref == 1) if(H5F_flush(f, H5AC_dxpl_id, FALSE) < 0) HGOTO_ERROR(H5E_CACHE, H5E_CANTFLUSH, FAIL, "unable to flush cache") } /* end if */ - + /* close the file */ + if(H5F_close(f) < 0) + HGOTO_ERROR(H5E_FILE, H5E_CANTDEC, FAIL, "can't close file") +#if 0 /* * Decrement reference count on atom. When it reaches zero the file will * be closed. */ if(H5I_dec_app_ref(f->file_id) < 0) HGOTO_ERROR(H5E_ATOM, H5E_CANTCLOSEFILE, FAIL, "decrementing file ID failed") +#endif done: FUNC_LEAVE_NOAPI(ret_value) @@ -2362,11 +2306,11 @@ H5VL_native_group_create(void *obj, H5VL_loc_params_t loc_params, const char *na if(H5P_get(plist, H5VL_GRP_LCPL_ID, &lcpl_id) < 0) HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, NULL, "can't get property value for lcpl id") - if (H5VL_native_get_loc(obj, loc_params.obj_type, &loc) < 0) + if(H5G_loc_real(obj, loc_params.obj_type, &loc) < 0) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, NULL, "not a file or file object") /* if name is NULL then this is from H5Gcreate_anon */ - if (name == NULL) { + if(name == NULL) { H5G_obj_create_t gcrt_info; /* Information for group creation */ /* Set up group creation info */ gcrt_info.gcpl_id = gcpl_id; @@ -2386,7 +2330,7 @@ H5VL_native_group_create(void *obj, H5VL_loc_params_t loc_params, const char *na ret_value = (void *)grp; done: - if (name == NULL) { + if(name == NULL) { /* Release the group's object header, if it was created */ if(grp) { H5O_loc_t *oloc; /* Object location for group */ @@ -2426,7 +2370,7 @@ H5VL_native_group_open(void *obj, H5VL_loc_params_t loc_params, const char *name FUNC_ENTER_NOAPI_NOINIT - if (H5VL_native_get_loc(obj, loc_params.obj_type, &loc) < 0) + if(H5G_loc_real(obj, loc_params.obj_type, &loc) < 0) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, NULL, "not a file or file object") /* Open the group */ @@ -2478,7 +2422,7 @@ H5VL_native_group_get(void *obj, H5VL_group_get_t get_type, hid_t UNUSED req, va H5G_info_t *grp_info = va_arg (arguments, H5G_info_t *); H5G_loc_t loc; - if (H5VL_native_get_loc(obj, loc_params.obj_type, &loc) < 0) + if(H5G_loc_real(obj, loc_params.obj_type, &loc) < 0) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a file or file object") if(loc_params.type == H5VL_OBJECT_BY_SELF) { /* H5Gget_info */ @@ -2486,7 +2430,7 @@ H5VL_native_group_get(void *obj, H5VL_group_get_t get_type, hid_t UNUSED req, va if(H5G__obj_info(loc.oloc, grp_info, H5AC_ind_dxpl_id) < 0) HGOTO_ERROR(H5E_SYM, H5E_CANTGET, FAIL, "can't retrieve group info") } - else if (loc_params.type == H5VL_OBJECT_BY_NAME) { /* H5Gget_info_by_name */ + else if(loc_params.type == H5VL_OBJECT_BY_NAME) { /* H5Gget_info_by_name */ H5G_loc_t grp_loc; /* Location used to open group */ H5G_name_t grp_path; /* Opened object group hier. path */ H5O_loc_t grp_oloc; /* Opened object object location */ @@ -2511,7 +2455,7 @@ H5VL_native_group_get(void *obj, H5VL_group_get_t get_type, hid_t UNUSED req, va if(H5G_loc_free(&grp_loc) < 0) HDONE_ERROR(H5E_SYM, H5E_CANTRELEASE, FAIL, "can't free location") } - else if (loc_params.type == H5VL_OBJECT_BY_IDX) { /* H5Gget_info_by_idx */ + else if(loc_params.type == H5VL_OBJECT_BY_IDX) { /* H5Gget_info_by_idx */ H5G_loc_t grp_loc; /* Location used to open group */ H5G_name_t grp_path; /* Opened object group hier. path */ H5O_loc_t grp_oloc; /* Opened object object location */ @@ -2620,13 +2564,13 @@ H5VL_native_link_create(H5VL_link_create_type_t create_type, void *obj, H5VL_loc if(H5P_get(plist, H5VL_LINK_TARGET_LOC_PARAMS, &cur_params) < 0) HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, FAIL, "can't get property value for current name") - if (NULL != cur_obj && H5VL_native_get_loc(cur_obj, cur_params.obj_type, &cur_loc) < 0) + if(NULL != cur_obj && H5G_loc_real(cur_obj, cur_params.obj_type, &cur_loc) < 0) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a file or file object") - if (NULL != obj && H5VL_native_get_loc(obj, loc_params.obj_type, &link_loc) < 0) + if(NULL != obj && H5G_loc_real(obj, loc_params.obj_type, &link_loc) < 0) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a file or file object") /* H5Lcreate_hard */ - if (H5VL_OBJECT_BY_NAME == cur_params.type) { + if(H5VL_OBJECT_BY_NAME == cur_params.type) { H5G_loc_t *cur_loc_p, *link_loc_p; /* Set up current & new location pointers */ @@ -2658,7 +2602,7 @@ H5VL_native_link_create(H5VL_link_create_type_t create_type, void *obj, H5VL_loc char *target_name; H5G_loc_t link_loc; /* Group location for new link */ - if (H5VL_native_get_loc(obj, loc_params.obj_type, &link_loc) < 0) + if(H5G_loc_real(obj, loc_params.obj_type, &link_loc) < 0) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a file or file object") if(H5P_get(plist, H5VL_LINK_TARGET_NAME, &target_name) < 0) @@ -2677,7 +2621,7 @@ H5VL_native_link_create(H5VL_link_create_type_t create_type, void *obj, H5VL_loc void *udata; size_t udata_size; - if (H5VL_native_get_loc(obj, loc_params.obj_type, &link_loc) < 0) + if(H5G_loc_real(obj, loc_params.obj_type, &link_loc) < 0) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a file or file object") if(H5P_get(plist, H5VL_LINK_TYPE, &link_type) < 0) @@ -2729,9 +2673,9 @@ H5VL_native_link_move(void *src_obj, H5VL_loc_params_t loc_params1, FUNC_ENTER_NOAPI_NOINIT - if (NULL != src_obj && H5VL_native_get_loc(src_obj, loc_params1.obj_type, &src_loc) < 0) + if(NULL != src_obj && H5G_loc_real(src_obj, loc_params1.obj_type, &src_loc) < 0) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a file or file object") - if (NULL != dst_obj && H5VL_native_get_loc(dst_obj, loc_params2.obj_type, &dst_loc) < 0) + if(NULL != dst_obj && H5G_loc_real(dst_obj, loc_params2.obj_type, &dst_loc) < 0) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a file or file object") /* Set up src & dst location pointers */ @@ -2775,10 +2719,10 @@ static herr_t H5VL_native_link_iterate(void *obj, H5VL_loc_params_t loc_params, FUNC_ENTER_NOAPI_NOINIT - if (H5VL_native_get_loc(obj, loc_params.obj_type, &loc) < 0) + if(H5G_loc_real(obj, loc_params.obj_type, &loc) < 0) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a file or file object") - if (!recursive) { + if(!recursive) { H5G_link_iterate_t lnk_op; /* Link operator */ hsize_t last_lnk; /* Index of last object looked at */ hsize_t idx; /* Internal location to hold index */ @@ -2856,7 +2800,7 @@ H5VL_native_link_get(void *obj, H5VL_loc_params_t loc_params, H5VL_link_get_t ge FUNC_ENTER_NOAPI_NOINIT - if (H5VL_native_get_loc(obj, loc_params.obj_type, &loc) < 0) + if(H5G_loc_real(obj, loc_params.obj_type, &loc) < 0) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a file or file object") switch (get_type) { @@ -2990,7 +2934,7 @@ H5VL_native_link_remove(void *obj, H5VL_loc_params_t loc_params, hid_t UNUSED re FUNC_ENTER_NOAPI_NOINIT - if (H5VL_native_get_loc(obj, loc_params.obj_type, &loc) < 0) + if(H5G_loc_real(obj, loc_params.obj_type, &loc) < 0) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a file or file object") /* Unlink */ @@ -3046,7 +2990,7 @@ H5VL_native_object_open(void *obj, H5VL_loc_params_t loc_params, H5I_type_t *ope FUNC_ENTER_NOAPI_NOINIT - if (H5VL_native_get_loc(obj, loc_params.obj_type, &loc) < 0) + if(H5G_loc_real(obj, loc_params.obj_type, &loc) < 0) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, NULL, "not a file or file object") switch (loc_params.type) { @@ -3121,7 +3065,7 @@ H5VL_native_object_open(void *obj, H5VL_loc_params_t loc_params, H5I_type_t *ope } *opened_type = H5I_get_type (temp_id); - if (NULL == (ret_value = H5I_remove(temp_id))) { + if(NULL == (ret_value = H5I_remove(temp_id))) { HDONE_ERROR(H5E_SYM, H5E_CANTOPENOBJ, NULL, "unable to open object") } done: @@ -3158,9 +3102,9 @@ H5VL_native_object_copy(void *src_obj, H5VL_loc_params_t loc_params1, const char FUNC_ENTER_NOAPI_NOINIT /* get location for objects */ - if (H5VL_native_get_loc(src_obj, loc_params1.obj_type, &src_loc) < 0) + if(H5G_loc_real(src_obj, loc_params1.obj_type, &src_loc) < 0) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a file or file object") - if (H5VL_native_get_loc(dst_obj, loc_params2.obj_type, &dst_loc) < 0) + if(H5G_loc_real(dst_obj, loc_params2.obj_type, &dst_loc) < 0) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a file or file object") /* Open the object */ @@ -3194,7 +3138,7 @@ static herr_t H5VL_native_object_visit(void *obj, H5VL_loc_params_t loc_params, FUNC_ENTER_NOAPI_NOINIT - if (H5VL_native_get_loc(obj, loc_params.obj_type, &loc) < 0) + if(H5G_loc_real(obj, loc_params.obj_type, &loc) < 0) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a file or file object") /* Call internal object visitation routine */ @@ -3380,13 +3324,13 @@ H5VL_native_object_free_loc(void *location, hid_t UNUSED req) if(H5G_loc_free(obj_loc) < 0) HGOTO_ERROR(H5E_SYM, H5E_CANTRELEASE, FAIL, "can't free location") - if (NULL != obj_loc->oloc) { + if(NULL != obj_loc->oloc) { H5MM_free(obj_loc->oloc); } - if (NULL != obj_loc->path) { + if(NULL != obj_loc->path) { H5MM_free(obj_loc->path); } - if (NULL != obj_loc) { + if(NULL != obj_loc) { H5MM_free(obj_loc); } @@ -3418,7 +3362,7 @@ H5VL_native_object_misc(void *obj, H5VL_loc_params_t loc_params, H5VL_object_mis FUNC_ENTER_NOAPI_NOINIT - if (H5VL_native_get_loc(obj, loc_params.obj_type, &loc) < 0) + if(H5G_loc_real(obj, loc_params.obj_type, &loc) < 0) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a file or file object") switch (misc_type) { @@ -3561,7 +3505,7 @@ H5VL_native_object_get(void *obj, H5VL_loc_params_t loc_params, H5VL_object_get_ FUNC_ENTER_NOAPI_NOINIT - if (H5VL_native_get_loc(obj, loc_params.obj_type, &loc) < 0) + if(H5G_loc_real(obj, loc_params.obj_type, &loc) < 0) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a file or file object") switch (get_type) { @@ -3570,7 +3514,7 @@ H5VL_native_object_get(void *obj, H5VL_loc_params_t loc_params, H5VL_object_get_ { htri_t *ret = va_arg (arguments, htri_t *); - if (loc_params.type == H5VL_OBJECT_BY_NAME) { + if(loc_params.type == H5VL_OBJECT_BY_NAME) { /* Check if the object exists */ if((*ret = H5G_loc_exists(&loc, loc_params.loc_data.loc_by_name.name, loc_params.loc_data.loc_by_name.plist_id, H5AC_dxpl_id)) < 0) @@ -3593,13 +3537,13 @@ H5VL_native_object_get(void *obj, H5VL_loc_params_t loc_params, H5VL_object_get_ H5AC_ind_dxpl_id) < 0) HGOTO_ERROR(H5E_SYM, H5E_NOTFOUND, FAIL, "object not found") } - else if (loc_params.type == H5VL_OBJECT_BY_NAME) { /* H5Oget_info_by_name */ + else if(loc_params.type == H5VL_OBJECT_BY_NAME) { /* H5Oget_info_by_name */ /* Retrieve the object's information */ if(H5G_loc_info(&loc, loc_params.loc_data.loc_by_name.name, TRUE, obj_info, loc_params.loc_data.loc_by_name.plist_id, H5AC_ind_dxpl_id) < 0) HGOTO_ERROR(H5E_SYM, H5E_NOTFOUND, FAIL, "object not found") } - else if (loc_params.type == H5VL_OBJECT_BY_IDX) { /* H5Oget_info_by_idx */ + else if(loc_params.type == H5VL_OBJECT_BY_IDX) { /* H5Oget_info_by_idx */ H5G_loc_t obj_loc; /* Location used to open group */ H5G_name_t obj_path; /* Opened object group hier. path */ H5O_loc_t obj_oloc; /* Opened object object location */ @@ -3738,7 +3682,6 @@ H5VL_native_object_close(void UNUSED *obj, H5VL_loc_params_t loc_params, hid_t U case H5I_DATATYPE: case H5I_DATASET: break; - case H5I_FILE_PRIVATE: case H5I_UNINIT: case H5I_BADID: case H5I_FILE: diff --git a/src/H5VLprivate.h b/src/H5VLprivate.h index 746c332..965b2c6 100644 --- a/src/H5VLprivate.h +++ b/src/H5VLprivate.h @@ -48,6 +48,7 @@ H5_DLL H5VL_class_t *H5VL_get_class(hid_t id); H5_DLL hid_t H5VL_register(const void *cls, size_t size, hbool_t app_ref); H5_DLL hid_t H5VL_object_register(void *obj, H5I_type_t obj_type, H5VL_t *vol_plugin); H5_DLL ssize_t H5VL_get_plugin_name(hid_t id, char *name/*out*/, size_t size); +H5_DLL void *H5VL_get_object(hid_t id); H5_DLL herr_t H5VL_close(H5VL_class_t *vol_plugin); H5_DLL void *H5VL_attr_create(void *obj, H5VL_loc_params_t loc_params, H5VL_t *vol_plugin, const char *attr_name, hid_t acpl_id, hid_t aapl_id, hid_t req); -- cgit v0.12