From b56de62ae06434c5966fc07664c44d91b407c515 Mon Sep 17 00:00:00 2001 From: Mohamad Chaarawi Date: Wed, 4 Apr 2012 16:48:46 -0500 Subject: [svn-r22250] - fix most of issues from code review - object open routines fall back to the generic VL object open in case the specific call back is not impemented - H5L VOL create/copy/move routines - make VOL create routines have similar interface and stuff parameters in creation plist - some bug fixes --- src/H5.c | 4 +- src/H5A.c | 25 +++ src/H5Adeprec.c | 6 +- src/H5D.c | 30 ++- src/H5Ddeprec.c | 14 +- src/H5Dprivate.h | 3 + src/H5F.c | 61 +++--- src/H5Ftest.c | 18 +- src/H5G.c | 12 +- src/H5Gdeprec.c | 15 +- src/H5Gint.c | 18 +- src/H5Gloc.c | 6 +- src/H5Gprivate.h | 2 + src/H5I.c | 24 +-- src/H5L.c | 152 +++++++------- src/H5Lexternal.c | 25 ++- src/H5Lprivate.h | 5 + src/H5O.c | 39 ++-- src/H5Pdcpl.c | 18 ++ src/H5Pgcpl.c | 6 + src/H5Plcpl.c | 44 ++++ src/H5R.c | 20 +- src/H5Rdeprec.c | 18 +- src/H5Tconv.c | 70 ++++--- src/H5VL.c | 618 +++++++++++++++++++++++++++++++++++++----------------- src/H5VLdummy.c | 2 +- src/H5VLnative.c | 320 ++++++++++++++++++++++++++-- src/H5VLprivate.h | 11 +- src/H5VLpublic.h | 38 ++-- 29 files changed, 1168 insertions(+), 456 deletions(-) diff --git a/src/H5.c b/src/H5.c index ddc6fcb..4a0fa15 100644 --- a/src/H5.c +++ b/src/H5.c @@ -268,6 +268,7 @@ H5_term_library(void) * that depend on them. -QAK */ if(pending == 0) { + pending += DOWN(VL); pending += DOWN(AC); pending += DOWN(Z); pending += DOWN(FD); @@ -282,8 +283,9 @@ H5_term_library(void) if(pending == 0) pending += DOWN(SL); /* Don't shut down the free list code until _everything_ else is down */ - if(pending == 0) + if(pending == 0) { pending += DOWN(FL); + } } } while(pending && ntries++ < 100); diff --git a/src/H5A.c b/src/H5A.c index cc6a7a5..725d89a 100644 --- a/src/H5A.c +++ b/src/H5A.c @@ -245,7 +245,22 @@ H5Acreate2(hid_t loc_id, const char *attr_name, hid_t type_id, hid_t space_id, /* 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") +#if 0 + hid_t ret_value; /* Return value */ + + FUNC_ENTER_API(FAIL) + H5TRACE6("i", "i*siiii", loc_id, attr_name, type_id, space_id, acpl_id, aapl_id); + /* check arguments */ + if(H5I_ATTR_PUBLIC == H5I_get_type(loc_id)) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "location is not valid for an attribute") + if(!attr_name || !*attr_name) + HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "no attribute name") + + /* Create the attribute through the VOL */ + if((ret_value = H5VL_attr_create(loc_id, attr_name, type_id, space_id, acpl_id, aapl_id)) < 0) + HGOTO_ERROR(H5E_SYM, H5E_CANTINIT, FAIL, "unable to create group") +#endif done: FUNC_LEAVE_API(ret_value) } /* H5Acreate2() */ @@ -330,6 +345,16 @@ H5Acreate_by_name(hid_t loc_id, const char *obj_name, const char *attr_name, 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") +#if 0 + /* Get the token for the Object location through the VOL */ + if(H5VL_object_lookup (loc_id, H5VL_OBJECT_LOOKUP_BY_NAME, &location, obj_name, lapl_id) < 0) + HGOTO_ERROR(H5E_SYM, H5E_CANTINIT, FAIL, "unable to locate object") + + /* Create the attribute through the VOL */ + if((ret_value = H5VL_attr_create(loc_id, attr_name, type_id, space_id, acpl_id, aapl_id)) < 0) + HGOTO_ERROR(H5E_SYM, H5E_CANTINIT, FAIL, "unable to create group") +#endif + done: /* Release resources */ if(loc_found && H5G_loc_free(&obj_loc) < 0) diff --git a/src/H5Adeprec.c b/src/H5Adeprec.c index 8c3801a..806b721 100644 --- a/src/H5Adeprec.c +++ b/src/H5Adeprec.c @@ -307,7 +307,7 @@ H5Aget_num_attrs(hid_t id) { H5O_loc_t *loc; /* Object location for attribute */ void *obj; - H5VL_id_wrapper_t *uid_info; /* user id structure */ + H5VL_id_wrapper_t *id_wrapper; /* user id structure */ hid_t loc_id; H5I_type_t id_type; int ret_value; @@ -323,9 +323,9 @@ H5Aget_num_attrs(hid_t id) if (H5I_FILE_PUBLIC == id_type || H5I_GROUP_PUBLIC == id_type || H5I_DATASET_PUBLIC == id_type || H5I_DATATYPE_PUBLIC == id_type || H5I_ATTR_PUBLIC == id_type) { - if(NULL == (uid_info = (H5VL_id_wrapper_t *)H5I_object(id))) + if(NULL == (id_wrapper = (H5VL_id_wrapper_t *)H5I_object(id))) HGOTO_ERROR(H5E_ATOM, H5E_BADTYPE, NULL, "invalid user identifier") - loc_id = uid_info->obj_id; + loc_id = id_wrapper->obj_id; } else { loc_id = id; diff --git a/src/H5D.c b/src/H5D.c index 99a2b19..3dae982 100644 --- a/src/H5D.c +++ b/src/H5D.c @@ -123,6 +123,7 @@ hid_t H5Dcreate2(hid_t loc_id, const char *name, hid_t type_id, hid_t space_id, hid_t lcpl_id, hid_t dcpl_id, hid_t dapl_id) { + H5P_genplist_t *plist; /* Property list pointer */ hid_t ret_value; /* Return value */ FUNC_ENTER_API(FAIL) @@ -153,9 +154,20 @@ H5Dcreate2(hid_t loc_id, const char *name, hid_t type_id, hid_t space_id, if(TRUE != H5P_isa_class(dapl_id, H5P_DATASET_ACCESS)) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not dataset access property list") + /* Get the plist structure */ + if(NULL == (plist = (H5P_genplist_t *)H5I_object(dcpl_id))) + HGOTO_ERROR(H5E_ATOM, H5E_BADATOM, FAIL, "can't find object for ID") + + /* set creation properties */ + if(H5P_set(plist, H5D_CRT_TYPE_ID_NAME, &type_id) < 0) + HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, FAIL, "can't set property value for datatype id") + if(H5P_set(plist, H5D_CRT_SPACE_ID_NAME, &space_id) < 0) + HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, FAIL, "can't set property value for space id") + if(H5P_set(plist, H5D_CRT_LCPL_ID_NAME, &lcpl_id) < 0) + HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, FAIL, "can't set property value for lcpl id") + /* Create the dataset through the VOL */ - if((ret_value = H5VL_dataset_create(loc_id, name, type_id, space_id, - lcpl_id, dcpl_id, dapl_id)) < 0) + if((ret_value = H5VL_dataset_create(loc_id, name, dcpl_id, dapl_id)) < 0) HGOTO_ERROR(H5E_DATASET, H5E_CANTINIT, FAIL, "unable to create dataset") done: @@ -203,6 +215,7 @@ hid_t H5Dcreate_anon(hid_t loc_id, hid_t type_id, hid_t space_id, hid_t dcpl_id, hid_t dapl_id) { + H5P_genplist_t *plist; /* Property list pointer */ hid_t ret_value; /* Return value */ FUNC_ENTER_API(FAIL) @@ -222,9 +235,18 @@ H5Dcreate_anon(hid_t loc_id, hid_t type_id, hid_t space_id, hid_t dcpl_id, if(TRUE != H5P_isa_class(dapl_id, H5P_DATASET_ACCESS)) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not dataset access property list") + /* Get the plist structure */ + if(NULL == (plist = (H5P_genplist_t *)H5I_object(dcpl_id))) + HGOTO_ERROR(H5E_ATOM, H5E_BADATOM, FAIL, "can't find object for ID") + + /* set creation properties */ + if(H5P_set(plist, H5D_CRT_TYPE_ID_NAME, &type_id) < 0) + HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, FAIL, "can't set property value for datatype id") + if(H5P_set(plist, H5D_CRT_SPACE_ID_NAME, &space_id) < 0) + HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, FAIL, "can't set property value for space id") + /* Create the dataset through the VOL */ - if((ret_value = H5VL_dataset_create(loc_id, NULL, type_id, space_id, - 0, dcpl_id, dapl_id)) < 0) + if((ret_value = H5VL_dataset_create(loc_id, NULL, dcpl_id, dapl_id)) < 0) HGOTO_ERROR(H5E_DATASET, H5E_CANTINIT, FAIL, "unable to create dataset") done: diff --git a/src/H5Ddeprec.c b/src/H5Ddeprec.c index db3f0f9..e41e059 100644 --- a/src/H5Ddeprec.c +++ b/src/H5Ddeprec.c @@ -141,6 +141,7 @@ hid_t H5Dcreate1(hid_t loc_id, const char *name, hid_t type_id, hid_t space_id, hid_t dcpl_id) { + H5P_genplist_t *plist; /* Property list pointer */ hid_t ret_value; /* Return value */ FUNC_ENTER_API(FAIL) @@ -152,9 +153,18 @@ H5Dcreate1(hid_t loc_id, const char *name, hid_t type_id, hid_t space_id, if(TRUE != H5P_isa_class(dcpl_id, H5P_DATASET_CREATE)) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not dataset create property list ID") + /* Get the plist structure */ + if(NULL == (plist = (H5P_genplist_t *)H5I_object(dcpl_id))) + HGOTO_ERROR(H5E_ATOM, H5E_BADATOM, FAIL, "can't find object for ID") + + /* set creation properties */ + if(H5P_set(plist, H5D_CRT_TYPE_ID_NAME, &type_id) < 0) + HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, FAIL, "can't set property value for datatype id") + if(H5P_set(plist, H5D_CRT_SPACE_ID_NAME, &space_id) < 0) + HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, FAIL, "can't set property value for space id") + /* Create the dataset through the VOL */ - if((ret_value = H5VL_dataset_create(loc_id, name, type_id, space_id, H5P_LINK_CREATE_DEFAULT, - dcpl_id, H5P_DATASET_ACCESS_DEFAULT)) < 0) + if((ret_value = H5VL_dataset_create(loc_id, name, dcpl_id, H5P_DATASET_ACCESS_DEFAULT)) < 0) HGOTO_ERROR(H5E_DATASET, H5E_CANTINIT, FAIL, "unable to create dataset") done: diff --git a/src/H5Dprivate.h b/src/H5Dprivate.h index 6c9c21d..c7a8cdc 100644 --- a/src/H5Dprivate.h +++ b/src/H5Dprivate.h @@ -47,6 +47,9 @@ #define H5D_CRT_FILL_VALUE_NAME "fill_value" /* Fill value */ #define H5D_CRT_ALLOC_TIME_STATE_NAME "alloc_time_state" /* Space allocation time state */ #define H5D_CRT_EXT_FILE_LIST_NAME "efl" /* External file list */ +#define H5D_CRT_TYPE_ID_NAME "dataset_type_id" /* datatype id */ +#define H5D_CRT_SPACE_ID_NAME "dataset_space_id" /* dataspace id */ +#define H5D_CRT_LCPL_ID_NAME "dataset_lcpl_id" /* lcpl id */ /* ======== Dataset access property names ======== */ #define H5D_ACS_DATA_CACHE_NUM_SLOTS_NAME "rdcc_nslots" /* Size of raw data chunk cache(slots) */ diff --git a/src/H5F.c b/src/H5F.c index bf8b89a..b5fd25f 100644 --- a/src/H5F.c +++ b/src/H5F.c @@ -36,9 +36,6 @@ #include "H5Tprivate.h" /* Datatypes */ #include "H5VLprivate.h" /* VOL plugins */ -/* Declare a free list to manage the H5VL_id_wrapper_t struct */ -H5FL_DEFINE_STATIC(H5VL_id_wrapper_t); - /* Struct only used by functions H5F_get_objects and H5F_get_objects_cb */ typedef struct H5F_olist_t { H5I_type_t obj_type; /* Type of object to look for */ @@ -368,7 +365,7 @@ ssize_t H5Fget_obj_count(hid_t uid, unsigned types) { H5F_t *f = NULL; /* File to query */ - H5VL_id_wrapper_t *uid_info; /* user id structure */ + H5VL_id_wrapper_t *id_wrapper; /* user id structure */ hid_t id; ssize_t ret_value; /* Return value */ @@ -376,9 +373,9 @@ H5Fget_obj_count(hid_t uid, unsigned types) H5TRACE2("Zs", "iIu", uid, types); if (H5I_FILE_PUBLIC == H5I_get_type(uid)) { - if(NULL == (uid_info = (H5VL_id_wrapper_t *)H5I_object(uid))) + if(NULL == (id_wrapper = (H5VL_id_wrapper_t *)H5I_object(uid))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "invalid user identifier") - id = uid_info->obj_id; + id = id_wrapper->obj_id; } else { id = uid; @@ -453,7 +450,7 @@ ssize_t H5Fget_obj_ids(hid_t uid, unsigned types, size_t max_objs, hid_t *oid_list) { H5F_t *f = NULL; /* File to query */ - H5VL_id_wrapper_t *uid_info; /* user id structure */ + H5VL_id_wrapper_t *id_wrapper; /* user id structure */ hid_t id; ssize_t ret_value; /* Return value */ @@ -461,9 +458,9 @@ H5Fget_obj_ids(hid_t uid, unsigned types, size_t max_objs, hid_t *oid_list) H5TRACE4("Zs", "iIuz*i", uid, types, max_objs, oid_list); if (H5I_FILE_PUBLIC == H5I_get_type(uid)) { - if(NULL == (uid_info = (H5VL_id_wrapper_t *)H5I_object(uid))) + if(NULL == (id_wrapper = (H5VL_id_wrapper_t *)H5I_object(uid))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "invalid user identifier") - id = uid_info->obj_id; + id = id_wrapper->obj_id; } else { id = uid; @@ -1889,7 +1886,7 @@ H5Freopen(hid_t uid) { H5F_t *old_file = NULL; H5F_t *new_file = NULL; - H5VL_id_wrapper_t *uid_info, *new_uid_info; + H5VL_id_wrapper_t *id_wrapper, *new_id_wrapper; hid_t file_id, new_file_id, ret_value; FUNC_ENTER_API(FAIL) @@ -1898,10 +1895,10 @@ H5Freopen(hid_t uid) /* Get the file */ if(H5I_FILE_PUBLIC != H5I_get_type(uid)) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a user ID") - if(NULL == (uid_info = (H5VL_id_wrapper_t *)H5I_object(uid))) + if(NULL == (id_wrapper = (H5VL_id_wrapper_t *)H5I_object(uid))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "invalid user identifier") - file_id = uid_info->obj_id; + file_id = id_wrapper->obj_id; /* Check arguments */ if(NULL == (old_file = (H5F_t *)H5I_object_verify(file_id, H5I_FILE))) @@ -1925,13 +1922,13 @@ H5Freopen(hid_t uid) new_file->file_id = new_file_id; #if 1 /*MSC - This needs to go through the VOL */ - if(NULL == (new_uid_info = H5FL_MALLOC(H5VL_id_wrapper_t))) + if(NULL == (new_id_wrapper = (H5VL_id_wrapper_t *)H5MM_malloc(sizeof(H5VL_id_wrapper_t)))) HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, FAIL, "memory allocation failed") - new_uid_info->obj_id = new_file_id; - new_uid_info->vol_plugin = uid_info->vol_plugin; - new_uid_info->vol_plugin->nrefs ++; + new_id_wrapper->obj_id = new_file_id; + new_id_wrapper->vol_plugin = id_wrapper->vol_plugin; + new_id_wrapper->vol_plugin->nrefs ++; - if((ret_value = H5I_register(H5I_FILE_PUBLIC, new_uid_info, TRUE)) < 0) + if((ret_value = H5I_register(H5I_FILE_PUBLIC, new_id_wrapper, TRUE)) < 0) HGOTO_ERROR(H5E_ATOM, H5E_CANTREGISTER, FAIL, "unable to atomize file handle") #endif @@ -1999,19 +1996,19 @@ H5F_get_id(H5F_t *file, hbool_t app_ref) HDassert(file); if(file->file_id == -1) { - H5VL_id_wrapper_t *uid_info; /* user id structure */ + H5VL_id_wrapper_t *id_wrapper; /* user id structure */ /* 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") /* Create a new id that points to a struct that holds the file id and the VOL id */ - if(NULL == (uid_info = H5FL_MALLOC(H5VL_id_wrapper_t))) + if(NULL == (id_wrapper = (H5VL_id_wrapper_t *)H5MM_malloc(sizeof(H5VL_id_wrapper_t)))) HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, FAIL, "memory allocation failed") - uid_info->obj_id = file->file_id; - uid_info->vol_plugin = file->vol_cls; - uid_info->vol_plugin->nrefs ++; + id_wrapper->obj_id = file->file_id; + id_wrapper->vol_plugin = file->vol_cls; + id_wrapper->vol_plugin->nrefs ++; - if((H5I_register(H5I_FILE_PUBLIC, uid_info, TRUE)) < 0) + if((H5I_register(H5I_FILE_PUBLIC, id_wrapper, TRUE)) < 0) HGOTO_ERROR(H5E_ATOM, H5E_CANTREGISTER, FAIL, "unable to atomize file handle") } else { /* Increment reference count on atom. */ @@ -2486,7 +2483,7 @@ herr_t H5Fset_mdc_config(hid_t uid, H5AC_cache_config_t *config_ptr) { H5F_t *file; /* File object for file ID */ - H5VL_id_wrapper_t *uid_info; /* user id structure */ + H5VL_id_wrapper_t *id_wrapper; /* user id structure */ herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_API(FAIL) @@ -2494,11 +2491,11 @@ H5Fset_mdc_config(hid_t uid, H5AC_cache_config_t *config_ptr) if(H5I_FILE_PUBLIC != H5I_get_type(uid)) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a user ID") - if(NULL == (uid_info = (H5VL_id_wrapper_t *)H5I_object(uid))) + if(NULL == (id_wrapper = (H5VL_id_wrapper_t *)H5I_object(uid))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "invalid user identifier") /* Check args */ - if(NULL == (file = (H5F_t *)H5I_object_verify(uid_info->obj_id, H5I_FILE))) + if(NULL == (file = (H5F_t *)H5I_object_verify(id_wrapper->obj_id, H5I_FILE))) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "not a file ID") /* set the resize configuration */ @@ -2605,7 +2602,7 @@ herr_t H5Freset_mdc_hit_rate_stats(hid_t uid) { H5F_t *file; /* File object for file ID */ - H5VL_id_wrapper_t *uid_info; /* user id structure */ + H5VL_id_wrapper_t *id_wrapper; /* user id structure */ herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_API(FAIL) @@ -2613,11 +2610,11 @@ H5Freset_mdc_hit_rate_stats(hid_t uid) if(H5I_FILE_PUBLIC != H5I_get_type(uid)) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a user ID") - if(NULL == (uid_info = (H5VL_id_wrapper_t *)H5I_object(uid))) + if(NULL == (id_wrapper = (H5VL_id_wrapper_t *)H5I_object(uid))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "invalid user identifier") /* Check args */ - if(NULL == (file = (H5F_t *)H5I_object_verify(uid_info->obj_id, H5I_FILE))) + if(NULL == (file = (H5F_t *)H5I_object_verify(id_wrapper->obj_id, H5I_FILE))) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "not a file ID") /* Reset the hit rate statistic */ @@ -2792,7 +2789,7 @@ herr_t H5Fclear_elink_file_cache(hid_t uid) { H5F_t *file; /* File */ - H5VL_id_wrapper_t *uid_info; /* user id structure */ + H5VL_id_wrapper_t *id_wrapper; /* user id structure */ herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_API(FAIL) @@ -2801,10 +2798,10 @@ H5Fclear_elink_file_cache(hid_t uid) /* Check args */ if(H5I_FILE_PUBLIC != H5I_get_type(uid)) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a user ID") - if(NULL == (uid_info = (H5VL_id_wrapper_t *)H5I_object(uid))) + if(NULL == (id_wrapper = (H5VL_id_wrapper_t *)H5I_object(uid))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "invalid user identifier") - if(NULL == (file = (H5F_t *)H5I_object_verify(uid_info->obj_id, H5I_FILE))) + if(NULL == (file = (H5F_t *)H5I_object_verify(id_wrapper->obj_id, H5I_FILE))) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "not a file ID") /* Release the EFC */ diff --git a/src/H5Ftest.c b/src/H5Ftest.c index b885205..7c15757 100644 --- a/src/H5Ftest.c +++ b/src/H5Ftest.c @@ -100,16 +100,16 @@ H5F_get_sohm_mesg_count_test(hid_t uid, unsigned type_id, size_t *mesg_count) { H5F_t *file; /* File info */ - H5VL_id_wrapper_t *uid_info; + H5VL_id_wrapper_t *id_wrapper; hid_t file_id; herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_NOAPI_NOINIT if (H5I_FILE_PUBLIC == H5I_get_type(uid)) { - if(NULL == (uid_info = (H5VL_id_wrapper_t *)H5I_object(uid))) + if(NULL == (id_wrapper = (H5VL_id_wrapper_t *)H5I_object(uid))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "invalid user identifier") - file_id = uid_info->obj_id; + file_id = id_wrapper->obj_id; } else { file_id = uid; @@ -148,16 +148,16 @@ herr_t H5F_check_cached_stab_test(hid_t uid) { H5F_t *file; /* File info */ - H5VL_id_wrapper_t *uid_info; + H5VL_id_wrapper_t *id_wrapper; hid_t file_id; herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_NOAPI_NOINIT if (H5I_FILE_PUBLIC == H5I_get_type(uid)) { - if(NULL == (uid_info = (H5VL_id_wrapper_t *)H5I_object(uid))) + if(NULL == (id_wrapper = (H5VL_id_wrapper_t *)H5I_object(uid))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "invalid user identifier") - file_id = uid_info->obj_id; + file_id = id_wrapper->obj_id; } else { file_id = uid; @@ -193,16 +193,16 @@ herr_t H5F_get_maxaddr_test(hid_t uid, haddr_t *maxaddr) { H5F_t *file; /* File info */ - H5VL_id_wrapper_t *uid_info; + H5VL_id_wrapper_t *id_wrapper; hid_t file_id; herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_NOAPI_NOINIT if (H5I_FILE_PUBLIC == H5I_get_type(uid)) { - if(NULL == (uid_info = (H5VL_id_wrapper_t *)H5I_object(uid))) + if(NULL == (id_wrapper = (H5VL_id_wrapper_t *)H5I_object(uid))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "invalid user identifier") - file_id = uid_info->obj_id; + file_id = id_wrapper->obj_id; } else { file_id = uid; diff --git a/src/H5G.c b/src/H5G.c index ffa39f4..52ad222 100644 --- a/src/H5G.c +++ b/src/H5G.c @@ -263,6 +263,7 @@ H5G_term_interface(void) hid_t H5Gcreate2(hid_t loc_id, const char *name, hid_t lcpl_id, hid_t gcpl_id, hid_t gapl_id) { + H5P_genplist_t *plist; /* Property list pointer */ hid_t ret_value; /* Return value */ FUNC_ENTER_API(FAIL) @@ -293,8 +294,15 @@ H5Gcreate2(hid_t loc_id, const char *name, hid_t lcpl_id, hid_t gcpl_id, hid_t g if(TRUE != H5P_isa_class(gapl_id, H5P_GROUP_ACCESS)) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not group access property list") + /* Get the plist structure */ + if(NULL == (plist = (H5P_genplist_t *)H5I_object(gcpl_id))) + HGOTO_ERROR(H5E_ATOM, H5E_BADATOM, FAIL, "can't find object for ID") + + if(H5P_set(plist, H5G_CRT_LCPL_ID_NAME, &lcpl_id) < 0) + HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, FAIL, "can't set property value for lcpl id") + /* Create the group through the VOL */ - if((ret_value = H5VL_group_create(loc_id, name, lcpl_id, gcpl_id, gapl_id)) < 0) + if((ret_value = H5VL_group_create(loc_id, name, gcpl_id, gapl_id)) < 0) HGOTO_ERROR(H5E_SYM, H5E_CANTINIT, FAIL, "unable to create group") done: @@ -360,7 +368,7 @@ H5Gcreate_anon(hid_t loc_id, hid_t gcpl_id, hid_t gapl_id) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not group access property list") /* Create the group through the VOL */ - if((ret_value = H5VL_group_create(loc_id, NULL, 0, gcpl_id, gapl_id)) < 0) + if((ret_value = H5VL_group_create(loc_id, NULL, gcpl_id, gapl_id)) < 0) HGOTO_ERROR(H5E_SYM, H5E_CANTINIT, FAIL, "unable to create group") done: diff --git a/src/H5Gdeprec.c b/src/H5Gdeprec.c index 8f419b9..e5c419b 100644 --- a/src/H5Gdeprec.c +++ b/src/H5Gdeprec.c @@ -202,6 +202,8 @@ hid_t H5Gcreate1(hid_t loc_id, const char *name, size_t size_hint) { hid_t tmp_gcpl = (-1); /* Temporary group creation property list */ + hid_t lcpl_id = H5P_LINK_CREATE_DEFAULT; + H5P_genplist_t *plist; hid_t ret_value; /* Return value */ FUNC_ENTER_API(FAIL) @@ -213,8 +215,8 @@ H5Gcreate1(hid_t loc_id, const char *name, size_t size_hint) /* Check if we need to create a non-standard GCPL */ if(size_hint > 0) { - H5P_genplist_t *gc_plist; /* Property list created */ H5O_ginfo_t ginfo; /* Group info property */ + H5P_genplist_t *gc_plist; /* Property list created */ /* Get the default property list */ if(NULL == (gc_plist = (H5P_genplist_t *)H5I_object(H5P_GROUP_CREATE_DEFAULT))) @@ -240,9 +242,16 @@ H5Gcreate1(hid_t loc_id, const char *name, size_t size_hint) else tmp_gcpl = H5P_GROUP_CREATE_DEFAULT; + /* Get the plist structure */ + if(NULL == (plist = (H5P_genplist_t *)H5I_object(tmp_gcpl))) + HGOTO_ERROR(H5E_ATOM, H5E_BADATOM, FAIL, "can't find object for ID") + + /* get creation properties */ + if(H5P_set(plist, H5G_CRT_LCPL_ID_NAME, &lcpl_id) < 0) + HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, FAIL, "can't get property value for lcpl id") + /* Create the group through the VOL */ - if((ret_value = H5VL_group_create(loc_id, name, H5P_LINK_CREATE_DEFAULT, tmp_gcpl, - H5P_GROUP_ACCESS_DEFAULT)) < 0) + if((ret_value = H5VL_group_create(loc_id, name, tmp_gcpl, H5P_GROUP_ACCESS_DEFAULT)) < 0) HGOTO_ERROR(H5E_SYM, H5E_CANTINIT, FAIL, "unable to create group") done: diff --git a/src/H5Gint.c b/src/H5Gint.c index 497babc..ee0295c 100644 --- a/src/H5Gint.c +++ b/src/H5Gint.c @@ -45,6 +45,7 @@ #include "H5Lprivate.h" /* Links */ #include "H5MMprivate.h" /* Memory management */ #include "H5Pprivate.h" /* Property lists */ +#include "H5VLprivate.h" /* VOL */ /****************/ /* Local Macros */ @@ -107,7 +108,6 @@ H5FL_DEFINE(H5G_shared_t); /* Declare the free list to manage H5_obj_t's */ H5FL_DEFINE(H5_obj_t); - /*****************************/ /* Library Private Variables */ /*****************************/ @@ -814,6 +814,8 @@ H5G_iterate(hid_t loc_id, const char *group_name, hid_t gid = -1; /* ID of group to iterate over */ H5G_t *grp = NULL; /* Pointer to group data structure to iterate over */ H5G_iter_appcall_ud_t udata; /* User data for callback */ + H5VL_id_wrapper_t *id_wrapper1; /* user id structure of the location where the group will be opend */ + H5VL_id_wrapper_t *id_wrapper2; /* user id structure of new opend group*/ herr_t ret_value; /* Return value */ FUNC_ENTER_NOAPI(FAIL) @@ -823,6 +825,10 @@ H5G_iterate(hid_t loc_id, const char *group_name, HDassert(last_lnk); HDassert(lnk_op && lnk_op->op_func.op_new); + /* get the ID struct */ + if(NULL == (id_wrapper1 = (H5VL_id_wrapper_t *)H5I_object(loc_id))) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "invalid user identifier") + /* * Open the group on which to operate. We also create a group ID which * we can pass to the application-defined operator. @@ -834,6 +840,16 @@ H5G_iterate(hid_t loc_id, const char *group_name, if((gid = H5I_register(H5I_GROUP, grp, TRUE)) < 0) HGOTO_ERROR(H5E_ATOM, H5E_CANTREGISTER, FAIL, "unable to register group") + /* Create a new id that points to a struct that holds the group id and the VOL plugin */ + /* Allocate new id structure */ + if(NULL == (id_wrapper2 = (H5VL_id_wrapper_t *)H5MM_malloc(sizeof(H5VL_id_wrapper_t)))) + HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, FAIL, "memory allocation failed") + id_wrapper2->obj_id = gid; + id_wrapper2->vol_plugin = id_wrapper1->vol_plugin; + + if((gid = H5I_register(H5I_GROUP_PUBLIC, id_wrapper2, TRUE)) < 0) + HGOTO_ERROR(H5E_ATOM, H5E_CANTREGISTER, FAIL, "unable to atomize group handle") + /* Set up user data for callback */ udata.gid = gid; udata.lnk_op = *lnk_op; diff --git a/src/H5Gloc.c b/src/H5Gloc.c index 25a50fd..d5b0d21 100644 --- a/src/H5Gloc.c +++ b/src/H5Gloc.c @@ -159,7 +159,7 @@ static herr_t H5G_loc_get_comment_cb(H5G_loc_t *grp_loc, const char *name, herr_t H5G_loc(hid_t id, H5G_loc_t *loc) { - H5VL_id_wrapper_t *uid_info; /* user id structure */ + H5VL_id_wrapper_t *id_wrapper; /* user id structure */ hid_t loc_id; H5I_type_t id_type; herr_t ret_value = SUCCEED; /* Return value */ @@ -174,9 +174,9 @@ H5G_loc(hid_t id, H5G_loc_t *loc) if (H5I_FILE_PUBLIC == id_type || H5I_GROUP_PUBLIC == id_type || H5I_DATASET_PUBLIC == id_type || H5I_DATATYPE_PUBLIC == id_type || H5I_ATTR_PUBLIC == id_type) { - if(NULL == (uid_info = (H5VL_id_wrapper_t *)H5I_object(id))) + if(NULL == (id_wrapper = (H5VL_id_wrapper_t *)H5I_object(id))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "invalid user identifier") - loc_id = uid_info->obj_id; + loc_id = id_wrapper->obj_id; } else { loc_id = id; diff --git a/src/H5Gprivate.h b/src/H5Gprivate.h index cacd947..680f2c5 100644 --- a/src/H5Gprivate.h +++ b/src/H5Gprivate.h @@ -98,6 +98,8 @@ H5G_CRT_GINFO_EST_NAME_LEN \ } +#define H5G_CRT_LCPL_ID_NAME "group_lcpl_id" + /* If the module using this macro is allowed access to the private variables, access them directly */ #ifdef H5G_PACKAGE #define H5G_MOUNTED(G) ((G)->shared->mounted) diff --git a/src/H5I.c b/src/H5I.c index 9ff2afd..d60d405 100644 --- a/src/H5I.c +++ b/src/H5I.c @@ -1012,7 +1012,7 @@ void * H5I_object_verify(hid_t id, H5I_type_t id_type) { H5I_id_info_t *id_ptr = NULL; /*ptr to the new atom */ - H5VL_id_wrapper_t *uid_info; /* user id structure */ + H5VL_id_wrapper_t *id_wrapper; /* user id structure */ void *ret_value = NULL; /*return value */ FUNC_ENTER_NOAPI(NULL) @@ -1026,9 +1026,9 @@ H5I_object_verify(hid_t id, H5I_type_t id_type) (H5I_DATATYPE_PUBLIC == H5I_get_type(id) && H5I_DATATYPE_PUBLIC != id_type) || (H5I_DATASET_PUBLIC == H5I_get_type(id) && H5I_DATASET_PUBLIC != id_type) || (H5I_ATTR_PUBLIC == H5I_get_type(id) && H5I_ATTR_PUBLIC != id_type)) { - if(NULL == (uid_info = (H5VL_id_wrapper_t *)H5I_object(id))) + if(NULL == (id_wrapper = (H5VL_id_wrapper_t *)H5I_object(id))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "invalid user identifier") - id = uid_info->obj_id; + id = id_wrapper->obj_id; } #endif @@ -2158,7 +2158,7 @@ done: hid_t H5Iget_file_id(hid_t uid) { - H5VL_id_wrapper_t *uid_info; /* user id structure */ + H5VL_id_wrapper_t *id_wrapper; /* user id structure */ hid_t id; hid_t ret_value; /* Return value */ @@ -2168,9 +2168,9 @@ H5Iget_file_id(hid_t uid) if (H5I_FILE_PUBLIC == H5I_get_type(uid) || H5I_GROUP_PUBLIC == H5I_get_type(uid) || H5I_DATASET_PUBLIC == H5I_get_type(uid) || H5I_DATATYPE_PUBLIC == H5I_get_type(uid) || H5I_ATTR_PUBLIC == H5I_get_type(uid)) { - if(NULL == (uid_info = (H5VL_id_wrapper_t *)H5I_object(uid))) + if(NULL == (id_wrapper = (H5VL_id_wrapper_t *)H5I_object(uid))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "invalid user identifier") - id = uid_info->obj_id; + id = id_wrapper->obj_id; } else { id = uid; @@ -2291,16 +2291,16 @@ H5VL_replace_with_uids(hid_t *old_list, ssize_t num_ids) /* Only iterate through hash table if there are IDs in group */ if(type_ptr->ids > 0) { H5I_id_info_t *id_ptr; /*ptr to the new ID */ - H5VL_id_wrapper_t *uid_info; /* user id structure */ + H5VL_id_wrapper_t *id_wrapper; /* user id structure */ unsigned i; /*counter */ /* Start at the beginning of the array */ for(i = 0; i < type_ptr->hash_size; i++) { id_ptr = type_ptr->id_list[i]; while(id_ptr) { - if(NULL == (uid_info = (H5VL_id_wrapper_t *)H5I_object(id_ptr->id))) + if(NULL == (id_wrapper = (H5VL_id_wrapper_t *)H5I_object(id_ptr->id))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "invalid user identifier") - if (uid_info->obj_id == old_list[j]) { + if (id_wrapper->obj_id == old_list[j]) { old_list[j] = id_ptr->id; ret_value ++; replaced = TRUE; @@ -2357,16 +2357,16 @@ H5VL_inc_ref_uid(hid_t id, hbool_t app_ref) /* Only iterate through hash table if there are IDs in group */ if(type_ptr->ids > 0) { H5I_id_info_t *id_ptr; /*ptr to the new ID */ - H5VL_id_wrapper_t *uid_info; /* user id structure */ + H5VL_id_wrapper_t *id_wrapper; /* user id structure */ unsigned i; /*counter */ /* Start at the beginning of the array */ for(i = 0; i < type_ptr->hash_size; i++) { id_ptr = type_ptr->id_list[i]; while(id_ptr) { - if(NULL == (uid_info = (H5VL_id_wrapper_t *)H5I_object(id_ptr->id))) + if(NULL == (id_wrapper = (H5VL_id_wrapper_t *)H5I_object(id_ptr->id))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "invalid user identifier") - if (uid_info->obj_id == id) { + if (id_wrapper->obj_id == id) { /* Increment reference count on atom. */ if((ret_value = H5I_inc_ref(id_ptr->id, app_ref)) < 0) HGOTO_ERROR(H5E_ATOM, H5E_CANTSET, FAIL, "incrementing file ID failed") diff --git a/src/H5L.c b/src/H5L.c index 6d455fb..35dbaa9 100644 --- a/src/H5L.c +++ b/src/H5L.c @@ -314,8 +314,6 @@ herr_t H5Lmove(hid_t src_loc_id, const char *src_name, hid_t dst_loc_id, const char *dst_name, hid_t lcpl_id, hid_t lapl_id) { - H5G_loc_t src_loc, *src_loc_p; - H5G_loc_t dst_loc, *dst_loc_p; herr_t ret_value=SUCCEED; /* Return value */ FUNC_ENTER_API(FAIL) @@ -325,10 +323,6 @@ H5Lmove(hid_t src_loc_id, const char *src_name, hid_t dst_loc_id, /* Check arguments */ if(src_loc_id == H5L_SAME_LOC && dst_loc_id == H5L_SAME_LOC) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "source and destination should not both be H5L_SAME_LOC") - if(src_loc_id != H5L_SAME_LOC && H5G_loc(src_loc_id, &src_loc) < 0) - HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a location") - if(dst_loc_id != H5L_SAME_LOC && H5G_loc(dst_loc_id, &dst_loc) < 0) - HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a location") if(!src_name || !*src_name) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "no current name specified") if(!dst_name || !*dst_name) @@ -336,18 +330,10 @@ H5Lmove(hid_t src_loc_id, const char *src_name, hid_t dst_loc_id, if(lcpl_id != H5P_DEFAULT && (TRUE != H5P_isa_class(lcpl_id, H5P_LINK_CREATE))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a link creation property list") - /* Set up src & dst location pointers */ - src_loc_p = &src_loc; - dst_loc_p = &dst_loc; - if(src_loc_id == H5L_SAME_LOC) - src_loc_p = dst_loc_p; - else if(dst_loc_id == H5L_SAME_LOC) - dst_loc_p = src_loc_p; - - /* Move the link */ - if(H5L_move(src_loc_p, src_name, dst_loc_p, dst_name, FALSE, lcpl_id, - lapl_id, H5AC_dxpl_id) < 0) - HGOTO_ERROR(H5E_LINK, H5E_CANTMOVE, FAIL, "unable to move link") + /* Create the link through the VOL */ + if((ret_value = H5VL_link_move(src_loc_id, src_name, dst_loc_id, dst_name, + FALSE, lcpl_id, lapl_id)) < 0) + HGOTO_ERROR(H5E_SYM, H5E_CANTINIT, FAIL, "unable to create link") done: FUNC_LEAVE_API(ret_value) @@ -372,8 +358,6 @@ herr_t H5Lcopy(hid_t src_loc_id, const char *src_name, hid_t dst_loc_id, const char *dst_name, hid_t lcpl_id, hid_t lapl_id) { - H5G_loc_t src_loc, *src_loc_p; - H5G_loc_t dst_loc, *dst_loc_p; herr_t ret_value=SUCCEED; /* Return value */ FUNC_ENTER_API(FAIL) @@ -383,10 +367,6 @@ H5Lcopy(hid_t src_loc_id, const char *src_name, hid_t dst_loc_id, /* Check arguments */ if(src_loc_id == H5L_SAME_LOC && dst_loc_id == H5L_SAME_LOC) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "source and destination should not both be H5L_SAME_LOC") - if(src_loc_id != H5L_SAME_LOC && H5G_loc(src_loc_id, &src_loc) < 0) - HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a location") - if(dst_loc_id != H5L_SAME_LOC && H5G_loc(dst_loc_id, &dst_loc) < 0) - HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a location") if(!src_name || !*src_name) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "no current name specified") if(!dst_name || !*dst_name) @@ -394,18 +374,10 @@ H5Lcopy(hid_t src_loc_id, const char *src_name, hid_t dst_loc_id, if(lcpl_id != H5P_DEFAULT && (TRUE != H5P_isa_class(lcpl_id, H5P_LINK_CREATE))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a link creation property list") - /* Set up src & dst location pointers */ - src_loc_p = &src_loc; - dst_loc_p = &dst_loc; - if(src_loc_id == H5L_SAME_LOC) - src_loc_p = dst_loc_p; - else if(dst_loc_id == H5L_SAME_LOC) - dst_loc_p = src_loc_p; - - /* Copy the link */ - if(H5L_move(src_loc_p, src_name, dst_loc_p, dst_name, TRUE, lcpl_id, - lapl_id, H5AC_dxpl_id) < 0) - HGOTO_ERROR(H5E_LINK, H5E_CANTMOVE, FAIL, "unable to move link") + /* Create the link through the VOL */ + if((ret_value = H5VL_link_move(src_loc_id, src_name, dst_loc_id, dst_name, + TRUE, lcpl_id, lapl_id)) < 0) + HGOTO_ERROR(H5E_SYM, H5E_CANTINIT, FAIL, "unable to create link") done: FUNC_LEAVE_API(ret_value) @@ -434,15 +406,15 @@ herr_t H5Lcreate_soft(const char *link_target, hid_t link_loc_id, const char *link_name, hid_t lcpl_id, hid_t lapl_id) { - H5G_loc_t link_loc; /* Group location for new link */ + H5P_genplist_t *plist; /* Property list pointer */ herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_API(FAIL) H5TRACE5("e", "*si*sii", link_target, link_loc_id, link_name, lcpl_id, lapl_id); /* Check arguments */ - if(H5G_loc(link_loc_id, &link_loc) < 0) - HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a location") + if(link_loc_id == H5L_SAME_LOC) + HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "link location id should not be H5L_SAME_LOC") if(!link_target || !*link_target) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "no target specified") if(!link_name || !*link_name) @@ -450,9 +422,22 @@ H5Lcreate_soft(const char *link_target, if(lcpl_id != H5P_DEFAULT && (TRUE != H5P_isa_class(lcpl_id, H5P_LINK_CREATE))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a link creation property list") - /* Create the link */ - if(H5L_create_soft(link_target, &link_loc, link_name, lcpl_id, lapl_id, H5AC_dxpl_id) < 0) - HGOTO_ERROR(H5E_LINK, H5E_CANTINIT, FAIL, "unable to create link") + /* Check the group access property list */ + if(H5P_DEFAULT == lcpl_id) + lcpl_id = H5P_LINK_CREATE_DEFAULT; + + /* Get the plist structure */ + if(NULL == (plist = (H5P_genplist_t *)H5I_object(lcpl_id))) + HGOTO_ERROR(H5E_ATOM, H5E_BADATOM, FAIL, "can't find object for ID") + + /* set creation properties */ + if(H5P_set(plist, H5L_CRT_TARGET_NAME_NAME, &link_target) < 0) + HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, FAIL, "can't get property value for target name") + + /* Create the link through the VOL */ + if((ret_value = H5VL_link_create(H5VL_CREATE_SOFT_LINK, link_loc_id, link_name, + lcpl_id, lapl_id)) < 0) + HGOTO_ERROR(H5E_SYM, H5E_CANTINIT, FAIL, "unable to create link") done: FUNC_LEAVE_API(ret_value) @@ -479,8 +464,7 @@ herr_t H5Lcreate_hard(hid_t cur_loc_id, const char *cur_name, hid_t new_loc_id, const char *new_name, hid_t lcpl_id, hid_t lapl_id) { - H5G_loc_t cur_loc, *cur_loc_p; - H5G_loc_t new_loc, *new_loc_p; + H5P_genplist_t *plist; /* Property list pointer */ herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_API(FAIL) @@ -490,10 +474,6 @@ H5Lcreate_hard(hid_t cur_loc_id, const char *cur_name, /* Check arguments */ if(cur_loc_id == H5L_SAME_LOC && new_loc_id == H5L_SAME_LOC) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "source and destination should not be both H5L_SAME_LOC") - if(cur_loc_id != H5L_SAME_LOC && H5G_loc(cur_loc_id, &cur_loc) < 0) - HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a location") - if(new_loc_id != H5L_SAME_LOC && H5G_loc(new_loc_id, &new_loc) < 0) - HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a location") if(!cur_name || !*cur_name) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "no current name specified") if(!new_name || !*new_name) @@ -501,20 +481,24 @@ H5Lcreate_hard(hid_t cur_loc_id, const char *cur_name, if(lcpl_id != H5P_DEFAULT && (TRUE != H5P_isa_class(lcpl_id, H5P_LINK_CREATE))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a link creation property list") - /* Set up current & new location pointers */ - cur_loc_p = &cur_loc; - new_loc_p = &new_loc; - if(cur_loc_id == H5L_SAME_LOC) - cur_loc_p = new_loc_p; - else if(new_loc_id == H5L_SAME_LOC) - new_loc_p = cur_loc_p; - else if(cur_loc_p->oloc->file != new_loc_p->oloc->file) - HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "source and destination should be in the same file.") + /* Check the group access property list */ + if(H5P_DEFAULT == lcpl_id) + lcpl_id = H5P_LINK_CREATE_DEFAULT; - /* Create the link */ - if(H5L_create_hard(cur_loc_p, cur_name, new_loc_p, new_name, - lcpl_id, lapl_id, H5AC_dxpl_id) < 0) - HGOTO_ERROR(H5E_LINK, H5E_CANTINIT, FAIL, "unable to create link") + /* Get the plist structure */ + if(NULL == (plist = (H5P_genplist_t *)H5I_object(lcpl_id))) + HGOTO_ERROR(H5E_ATOM, H5E_BADATOM, FAIL, "can't find object for ID") + + /* set creation properties */ + if(H5P_set(plist, H5L_CRT_TARGET_ID_NAME, &cur_loc_id) < 0) + HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, FAIL, "can't get property value for current location id") + if(H5P_set(plist, H5L_CRT_TARGET_NAME_NAME, &cur_name) < 0) + HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, FAIL, "can't get property value for target name") + + /* Create the link through the VOL */ + if((ret_value = H5VL_link_create(H5VL_CREATE_HARD_LINK, new_loc_id, new_name, + lcpl_id, lapl_id)) < 0) + HGOTO_ERROR(H5E_SYM, H5E_CANTINIT, FAIL, "unable to create link") done: FUNC_LEAVE_API(ret_value) @@ -549,7 +533,7 @@ herr_t H5Lcreate_ud(hid_t link_loc_id, const char *link_name, H5L_type_t link_type, const void *udata, size_t udata_size, hid_t lcpl_id, hid_t lapl_id) { - H5G_loc_t link_loc; + H5P_genplist_t *plist; /* Property list pointer */ herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_API(FAIL) @@ -557,16 +541,31 @@ H5Lcreate_ud(hid_t link_loc_id, const char *link_name, H5L_type_t link_type, udata_size, lcpl_id, lapl_id); /* Check arguments */ - if(H5G_loc(link_loc_id, &link_loc) < 0) - HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a location") if(!link_name || !*link_name) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "no link name specified") if(link_type < H5L_TYPE_UD_MIN || link_type > H5L_TYPE_MAX) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "invalid link class") - /* Create external link */ - if(H5L_create_ud(&link_loc, link_name, udata, udata_size, link_type, lcpl_id, lapl_id, H5AC_dxpl_id) < 0) - HGOTO_ERROR(H5E_LINK, H5E_CANTINIT, FAIL, "unable to create link") + /* Check the group access property list */ + if(H5P_DEFAULT == lcpl_id) + lcpl_id = H5P_LINK_CREATE_DEFAULT; + + /* Get the plist structure */ + if(NULL == (plist = (H5P_genplist_t *)H5I_object(lcpl_id))) + HGOTO_ERROR(H5E_ATOM, H5E_BADATOM, FAIL, "can't find object for ID") + + /* set creation properties */ + if(H5P_set(plist, H5L_CRT_LINK_TYPE_NAME, &link_type) < 0) + HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, FAIL, "can't get property value from plist") + if(H5P_set(plist, H5L_CRT_UDATA_NAME, &udata) < 0) + HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, FAIL, "can't get property value from plist") + if(H5P_set(plist, H5L_CRT_UDATA_SIZE_NAME, &udata_size) < 0) + HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, FAIL, "can't get property value from plist") + + /* Create the link through the VOL */ + if((ret_value = H5VL_link_create(H5VL_CREATE_UD_LINK, link_loc_id, link_name, + lcpl_id, lapl_id)) < 0) + HGOTO_ERROR(H5E_SYM, H5E_CANTINIT, FAIL, "unable to create link") done: FUNC_LEAVE_API(ret_value) @@ -1155,7 +1154,7 @@ H5Literate(hid_t id, H5_index_t idx_type, H5_iter_order_t order, H5G_link_iterate_t lnk_op; /* Link operator */ hsize_t last_lnk; /* Index of last object looked at */ hsize_t idx; /* Internal location to hold index */ - H5VL_id_wrapper_t *uid_info; /* user id structure */ + H5VL_id_wrapper_t *id_wrapper; /* user id structure */ hid_t grp_id; herr_t ret_value; /* Return value */ @@ -1164,21 +1163,24 @@ H5Literate(hid_t id, H5_index_t idx_type, H5_iter_order_t order, /* Check arguments */ id_type = H5I_get_type(id); + +#if 0 /* get the actual ID from an upper ID level */ /* MSC - this is a workaround to allow the test suite to pass and at some point needs to be removed once all high level operations that needs to go through the VOL actually go through the VOL*/ if (H5I_FILE_PUBLIC == id_type || H5I_GROUP_PUBLIC == id_type) { - if(NULL == (uid_info = (H5VL_id_wrapper_t *)H5I_object(id))) + if(NULL == (id_wrapper = (H5VL_id_wrapper_t *)H5I_object(id))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "invalid user identifier") - grp_id = uid_info->obj_id; + grp_id = id_wrapper->obj_id; id_type = H5I_get_type(grp_id); } else { grp_id = id; } +#endif - if(!(H5I_GROUP == id_type || H5I_FILE == id_type)) + if(!(H5I_GROUP_PUBLIC == id_type || H5I_FILE_PUBLIC == id_type)) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "invalid argument") if(idx_type <= H5_INDEX_UNKNOWN || idx_type >= H5_INDEX_N) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "invalid index type specified") @@ -1196,7 +1198,7 @@ H5Literate(hid_t id, H5_index_t idx_type, H5_iter_order_t order, lnk_op.op_func.op_new = op; /* Iterate over the links */ - if((ret_value = H5G_iterate(grp_id, ".", idx_type, order, idx, &last_lnk, &lnk_op, op_data, H5P_DEFAULT, H5AC_ind_dxpl_id)) < 0) + if((ret_value = H5G_iterate(id, ".", idx_type, order, idx, &last_lnk, &lnk_op, op_data, H5P_DEFAULT, H5AC_ind_dxpl_id)) < 0) HGOTO_ERROR(H5E_SYM, H5E_BADITER, FAIL, "link iteration failed") /* Set the index we stopped at */ @@ -1313,7 +1315,7 @@ H5Lvisit(hid_t uid, H5_index_t idx_type, H5_iter_order_t order, H5L_iterate_t op, void *op_data) { H5I_type_t id_type; /* Type of ID */ - H5VL_id_wrapper_t *uid_info; /* user id structure */ + H5VL_id_wrapper_t *id_wrapper; /* user id structure */ hid_t grp_id; herr_t ret_value; /* Return value */ @@ -1323,9 +1325,9 @@ H5Lvisit(hid_t uid, H5_index_t idx_type, H5_iter_order_t order, id_type = H5I_get_type(uid); if (H5I_FILE_PUBLIC == id_type) { - if(NULL == (uid_info = (H5VL_id_wrapper_t *)H5I_object(uid))) + if(NULL == (id_wrapper = (H5VL_id_wrapper_t *)H5I_object(uid))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "invalid user identifier") - grp_id = uid_info->obj_id; + grp_id = id_wrapper->obj_id; id_type = H5I_get_type(grp_id); } else { diff --git a/src/H5Lexternal.c b/src/H5Lexternal.c index 62e7a5e..c57edd9 100644 --- a/src/H5Lexternal.c +++ b/src/H5Lexternal.c @@ -544,6 +544,8 @@ H5Lcreate_external(const char *file_name, const char *obj_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 */ + H5P_genplist_t *plist; /* Property list pointer */ + H5L_type_t link_type = H5L_TYPE_EXTERNAL; herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_API(FAIL) @@ -560,6 +562,10 @@ H5Lcreate_external(const char *file_name, const char *obj_name, if(!link_name || !*link_name) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "no link name specified") + /* Check the group access property list */ + if(H5P_DEFAULT == lcpl_id) + lcpl_id = H5P_LINK_CREATE_DEFAULT; + /* Get normalized copy of the link target */ if(NULL == (norm_obj_name = H5G_normalize(obj_name))) HGOTO_ERROR(H5E_SYM, H5E_BADVALUE, FAIL, "can't normalize object name") @@ -576,9 +582,22 @@ 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 */ - /* Create an external link */ - if(H5L_create_ud(&link_loc, link_name, ext_link_buf, buf_size, H5L_TYPE_EXTERNAL, lcpl_id, lapl_id, H5AC_dxpl_id) < 0) - HGOTO_ERROR(H5E_LINK, H5E_CANTINIT, FAIL, "unable to create link") + /* Get the plist structure */ + if(NULL == (plist = (H5P_genplist_t *)H5I_object(lcpl_id))) + HGOTO_ERROR(H5E_ATOM, H5E_BADATOM, FAIL, "can't find object for ID") + + /* set creation properties */ + if(H5P_set(plist, H5L_CRT_LINK_TYPE_NAME, &link_type) < 0) + HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, FAIL, "can't get property value from plist") + if(H5P_set(plist, H5L_CRT_UDATA_NAME, &ext_link_buf) < 0) + HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, FAIL, "can't get property value from plist") + if(H5P_set(plist, H5L_CRT_UDATA_SIZE_NAME, &buf_size) < 0) + HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, FAIL, "can't get property value from plist") + + /* Create the link through the VOL */ + if((ret_value = H5VL_link_create(H5VL_CREATE_UD_LINK, link_loc_id, link_name, + lcpl_id, lapl_id)) < 0) + HGOTO_ERROR(H5E_SYM, H5E_CANTINIT, FAIL, "unable to create link") done: H5MM_xfree(ext_link_buf); diff --git a/src/H5Lprivate.h b/src/H5Lprivate.h index f3079bc..70a5d76 100644 --- a/src/H5Lprivate.h +++ b/src/H5Lprivate.h @@ -37,6 +37,11 @@ /* ======== Link creation property names ======== */ #define H5L_CRT_INTERMEDIATE_GROUP_NAME "intermediate_group" /* Create intermediate groups flag */ +#define H5L_CRT_TARGET_ID_NAME "target location id" +#define H5L_CRT_TARGET_NAME_NAME "target name" +#define H5L_CRT_LINK_TYPE_NAME "link type" +#define H5L_CRT_UDATA_NAME "udata" +#define H5L_CRT_UDATA_SIZE_NAME "udata size" /* ======== Link access property names ======== */ #define H5L_ACS_NLINKS_NAME "max soft links" /* Number of soft links to traverse */ diff --git a/src/H5O.c b/src/H5O.c index ae03519..8230de2 100644 --- a/src/H5O.c +++ b/src/H5O.c @@ -245,7 +245,7 @@ H5Oopen(hid_t loc_id, const char *name, hid_t lapl_id) HGOTO_ERROR(H5E_SYM, H5E_CANTINIT, FAIL, "unable to locate object") /* Open the object through the VOL */ - if((ret_value = H5VL_object_open(loc_id, location, lapl_id)) < 0) + if((ret_value = H5VL_object_open_by_loc(loc_id, location, lapl_id)) < 0) HGOTO_ERROR(H5E_SYM, H5E_CANTINIT, FAIL, "unable to open object") done: @@ -309,7 +309,7 @@ H5Oopen_by_idx(hid_t loc_id, const char *group_name, H5_index_t idx_type, HGOTO_ERROR(H5E_SYM, H5E_CANTINIT, FAIL, "unable to locate object") /* Open the object through the VOL */ - if((ret_value = H5VL_object_open(loc_id, location, lapl_id)) < 0) + if((ret_value = H5VL_object_open_by_loc(loc_id, location, lapl_id)) < 0) HGOTO_ERROR(H5E_SYM, H5E_CANTINIT, FAIL, "unable to open object") done: @@ -371,7 +371,7 @@ H5Oopen_by_addr(hid_t loc_id, haddr_t addr) HGOTO_ERROR(H5E_SYM, H5E_CANTINIT, FAIL, "unable to locate object") /* Open the object through the VOL */ - if((ret_value = H5VL_object_open(loc_id, location, lapl_id)) < 0) + if((ret_value = H5VL_object_open_by_loc(loc_id, location, lapl_id)) < 0) HGOTO_ERROR(H5E_SYM, H5E_CANTINIT, FAIL, "unable to open object") done: @@ -592,27 +592,12 @@ H5Oget_info(hid_t loc_id, H5O_info_t *oinfo) if(!oinfo) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "no info struct") - /* Check id */ - if(H5I_GROUP_PUBLIC != H5I_get_type(loc_id) && H5I_DATASET_PUBLIC != H5I_get_type(loc_id) && - H5I_DATATYPE_PUBLIC != H5I_get_type(loc_id) && H5I_FILE_PUBLIC != H5I_get_type(loc_id)) { - H5G_loc_t loc; /* Location of group */ - - if(H5G_loc(loc_id, &loc) < 0) - HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a location") - - if(H5G_loc_info(&loc, ".", TRUE, oinfo/*out*/, H5P_LINK_ACCESS_DEFAULT, - H5AC_ind_dxpl_id) < 0) - HGOTO_ERROR(H5E_SYM, H5E_NOTFOUND, FAIL, "object not found") - } - - else { - /* Get the token for the Object location through the VOL */ - if(H5VL_object_lookup (loc_id, H5VL_OBJECT_LOOKUP, &location) < 0) - HGOTO_ERROR(H5E_SYM, H5E_CANTINIT, FAIL, "unable to locate object") - /* Get the group info through the VOL using the location token */ - if((ret_value = H5VL_object_get(loc_id, H5VL_OBJECT_GET_INFO, oinfo, location)) < 0) - HGOTO_ERROR(H5E_INTERNAL, H5E_CANTGET, FAIL, "unable to get group info") - } + /* Get the token for the Object location through the VOL */ + if(H5VL_object_lookup (loc_id, H5VL_OBJECT_LOOKUP, &location) < 0) + HGOTO_ERROR(H5E_SYM, H5E_CANTINIT, FAIL, "unable to locate object") + /* Get the group info through the VOL using the location token */ + if((ret_value = H5VL_object_get(loc_id, H5VL_OBJECT_GET_INFO, oinfo, location)) < 0) + HGOTO_ERROR(H5E_INTERNAL, H5E_CANTGET, FAIL, "unable to get group info") done: if (NULL != location) { @@ -2417,7 +2402,7 @@ done: H5O_loc_t * H5O_get_loc(hid_t id) { - H5VL_id_wrapper_t *uid_info; /* user id structure */ + H5VL_id_wrapper_t *id_wrapper; /* user id structure */ hid_t object_id; H5I_type_t id_type; H5O_loc_t *ret_value; /* Return value */ @@ -2432,9 +2417,9 @@ H5O_get_loc(hid_t id) that needs to go through the VOL actually go through the VOL*/ if (H5I_GROUP_PUBLIC == id_type || H5I_DATASET_PUBLIC == id_type || H5I_DATATYPE_PUBLIC == id_type) { - if(NULL == (uid_info = (H5VL_id_wrapper_t *)H5I_object(id))) + if(NULL == (id_wrapper = (H5VL_id_wrapper_t *)H5I_object(id))) HGOTO_ERROR(H5E_ATOM, H5E_BADTYPE, NULL, "invalid user identifier") - object_id = uid_info->obj_id; + object_id = id_wrapper->obj_id; } else { object_id = id; diff --git a/src/H5Pdcpl.c b/src/H5Pdcpl.c index 6a3067d..f07aa87 100644 --- a/src/H5Pdcpl.c +++ b/src/H5Pdcpl.c @@ -180,6 +180,9 @@ H5P_dcrt_reg_prop(H5P_genclass_t *pclass) H5O_fill_t fill = H5D_CRT_FILL_VALUE_DEF; /* Default fill value */ unsigned alloc_time_state = H5D_CRT_ALLOC_TIME_STATE_DEF; /* Default allocation time state */ H5O_efl_t efl = H5D_CRT_EXT_FILE_LIST_DEF; /* Default external file list */ + hid_t type_id = FAIL; + hid_t space_id = FAIL; + hid_t lcpl_id = H5P_LINK_CREATE_DEFAULT; herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_NOAPI_NOINIT @@ -200,6 +203,21 @@ H5P_dcrt_reg_prop(H5P_genclass_t *pclass) if(H5P_register_real(pclass, H5D_CRT_EXT_FILE_LIST_NAME, H5D_CRT_EXT_FILE_LIST_SIZE, &efl, NULL, NULL, NULL, NULL, NULL, H5D_CRT_EXT_FILE_LIST_CMP, NULL) < 0) HGOTO_ERROR(H5E_PLIST, H5E_CANTINSERT, FAIL, "can't insert property into class") + /* Register the type ID property*/ + if(H5P_register_real(pclass, H5D_CRT_TYPE_ID_NAME, sizeof(hid_t), &type_id, + NULL, NULL, NULL, NULL, NULL, NULL, NULL) < 0) + HGOTO_ERROR(H5E_PLIST, H5E_CANTINSERT, FAIL, "can't insert property into class") + + /* Register the space ID property */ + if(H5P_register_real(pclass, H5D_CRT_SPACE_ID_NAME, sizeof(hid_t), &space_id, + NULL, NULL, NULL, NULL, NULL, NULL, NULL) < 0) + HGOTO_ERROR(H5E_PLIST, H5E_CANTINSERT, FAIL, "can't insert property into class") + + /* Register the lcpl ID property */ + if(H5P_register_real(pclass, H5D_CRT_LCPL_ID_NAME, sizeof(hid_t), &lcpl_id, + NULL, NULL, NULL, NULL, NULL, NULL, NULL) < 0) + HGOTO_ERROR(H5E_PLIST, H5E_CANTINSERT, FAIL, "can't insert property into class") + done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5P_dcrt_reg_prop() */ diff --git a/src/H5Pgcpl.c b/src/H5Pgcpl.c index 983929d..eb35a6d 100644 --- a/src/H5Pgcpl.c +++ b/src/H5Pgcpl.c @@ -108,6 +108,7 @@ H5P_gcrt_reg_prop(H5P_genclass_t *pclass) { H5O_ginfo_t ginfo = H5G_CRT_GROUP_INFO_DEF; /* Default group info settings */ H5O_linfo_t linfo = H5G_CRT_LINK_INFO_DEF; /* Default link info settings */ + hid_t lcpl_id = H5P_LINK_CREATE_DEFAULT; herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_NOAPI_NOINIT @@ -120,6 +121,11 @@ H5P_gcrt_reg_prop(H5P_genclass_t *pclass) if(H5P_register_real(pclass, H5G_CRT_LINK_INFO_NAME, H5G_CRT_LINK_INFO_SIZE, &linfo, NULL, NULL, NULL, NULL, NULL, NULL, NULL) < 0) HGOTO_ERROR(H5E_PLIST, H5E_CANTINSERT, FAIL, "can't insert property into class") + /* Register the lcpl ID property */ + if(H5P_register_real(pclass, H5G_CRT_LCPL_ID_NAME, sizeof(hid_t), &lcpl_id, + NULL, NULL, NULL, NULL, NULL, NULL, NULL) < 0) + HGOTO_ERROR(H5E_PLIST, H5E_CANTINSERT, FAIL, "can't insert property into class") + done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5P_gcrt_reg_prop() */ diff --git a/src/H5Plcpl.c b/src/H5Plcpl.c index 60b4e37..ae701f2 100644 --- a/src/H5Plcpl.c +++ b/src/H5Plcpl.c @@ -49,6 +49,25 @@ #define H5L_CRT_INTERMEDIATE_GROUP_SIZE sizeof(unsigned) #define H5L_CRT_INTERMEDIATE_GROUP_DEF 0 +/* Definitions for target object ID */ +#define H5L_CRT_TARGET_ID_SIZE sizeof(hid_t) +#define H5L_CRT_TARGET_ID_DEF 0 + +/* Definitions for target object NAME */ +#define H5L_CRT_TARGET_NAME_SIZE sizeof(char *) +#define H5L_CRT_TARGET_NAME_DEF NULL + +/* Definitions for link type */ +#define H5L_CRT_LINK_TYPE_SIZE sizeof(link_type) +#define H5L_CRT_LINK_TYPE_DEF H5L_TYPE_ERROR + +/* Definitions for UDATA */ +#define H5L_CRT_UDATA_SIZE sizeof(void *) +#define H5L_CRT_UDATA_DEF NULL + +/* Definitions for UDATA_SIZE */ +#define H5L_CRT_UDATA_SIZE_SIZE sizeof(size_t) +#define H5L_CRT_UDATA_SIZE_DEF 0 /******************/ /* Local Typedefs */ @@ -114,6 +133,11 @@ herr_t H5P_lcrt_reg_prop(H5P_genclass_t *pclass) { unsigned intmd_group = H5L_CRT_INTERMEDIATE_GROUP_DEF; /* Default setting for creating intermediate groups */ + hid_t target_id = H5L_CRT_TARGET_ID_DEF; + char *target_name = H5L_CRT_TARGET_NAME_DEF; + H5L_type_t link_type = H5L_CRT_LINK_TYPE_DEF; + void *udata = H5L_CRT_UDATA_DEF; + size_t udata_size = H5L_CRT_UDATA_SIZE_DEF; herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_NOAPI(FAIL) @@ -122,6 +146,26 @@ H5P_lcrt_reg_prop(H5P_genclass_t *pclass) if(H5P_register_real(pclass, H5L_CRT_INTERMEDIATE_GROUP_NAME, H5L_CRT_INTERMEDIATE_GROUP_SIZE, &intmd_group, NULL, NULL, NULL, NULL, NULL, NULL, NULL) < 0) HGOTO_ERROR(H5E_PLIST, H5E_CANTINSERT, FAIL, "can't insert property into class") + if(H5P_register_real(pclass, H5L_CRT_TARGET_ID_NAME, H5L_CRT_TARGET_ID_SIZE, &target_id, + NULL, NULL, NULL, NULL, NULL, NULL, NULL) < 0) + HGOTO_ERROR(H5E_PLIST, H5E_CANTINSERT, FAIL, "can't insert property into class") + + if(H5P_register_real(pclass, H5L_CRT_TARGET_NAME_NAME, H5L_CRT_TARGET_NAME_SIZE, &target_name, + NULL, NULL, NULL, NULL, NULL, NULL, NULL) < 0) + HGOTO_ERROR(H5E_PLIST, H5E_CANTINSERT, FAIL, "can't insert property into class") + + if(H5P_register_real(pclass, H5L_CRT_LINK_TYPE_NAME, H5L_CRT_LINK_TYPE_SIZE, &link_type, + NULL, NULL, NULL, NULL, NULL, NULL, NULL) < 0) + HGOTO_ERROR(H5E_PLIST, H5E_CANTINSERT, FAIL, "can't insert property into class") + + if(H5P_register_real(pclass, H5L_CRT_UDATA_NAME, H5L_CRT_UDATA_SIZE, &udata, + NULL, NULL, NULL, NULL, NULL, NULL, NULL) < 0) + HGOTO_ERROR(H5E_PLIST, H5E_CANTINSERT, FAIL, "can't insert property into class") + + if(H5P_register_real(pclass, H5L_CRT_UDATA_SIZE_NAME, H5L_CRT_UDATA_SIZE_SIZE, &udata_size, + NULL, NULL, NULL, NULL, NULL, NULL, NULL) < 0) + HGOTO_ERROR(H5E_PLIST, H5E_CANTINSERT, FAIL, "can't insert property into class") + done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5P_lcrt_reg_prop() */ diff --git a/src/H5R.c b/src/H5R.c index 65ac7da..a8b2f1b 100644 --- a/src/H5R.c +++ b/src/H5R.c @@ -29,6 +29,7 @@ #include "H5MMprivate.h" /* Memory management */ #include "H5Rpkg.h" /* References */ #include "H5Sprivate.h" /* Dataspaces */ +#include "H5VLprivate.h" /* VOL plugins */ /* Local macro definitions */ @@ -523,29 +524,28 @@ done: hid_t H5Rdereference2(hid_t obj_id, hid_t oapl_id, H5R_type_t ref_type, const void *_ref) { - H5G_loc_t loc; /* Group location */ - H5F_t *file = NULL; /* File object */ + void *location = NULL; /* a pointer to VOL specific token that indicates + the location of the object */ hid_t ret_value; FUNC_ENTER_API(FAIL) H5TRACE4("i", "iiRt*x", obj_id, oapl_id, ref_type, _ref); /* Check args */ - if(H5G_loc(obj_id, &loc) < 0) - HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a location") - if(oapl_id < 0) + if(oapl_id < 0) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a property list") if(ref_type <= H5R_BADTYPE || ref_type >= H5R_MAXTYPE) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "invalid reference type") if(_ref == NULL) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "invalid reference pointer") - /* Get the file pointer from the entry */ - file = loc.oloc->file; + /* Get the token for the Object location through the VOL */ + if(H5VL_object_lookup (obj_id, H5VL_OBJECT_LOOKUP_BY_REF, &location, ref_type, _ref) < 0) + HGOTO_ERROR(H5E_SYM, H5E_CANTINIT, FAIL, "unable to locate object") - /* Create reference */ - if((ret_value = H5R_dereference(file, oapl_id, H5AC_dxpl_id, ref_type, _ref, TRUE)) < 0) - HGOTO_ERROR(H5E_REFERENCE, H5E_CANTINIT, FAIL, "unable dereference object") + /* Open the object through the VOL */ + if((ret_value = H5VL_object_open_by_loc(obj_id, location, oapl_id)) < 0) + HGOTO_ERROR(H5E_SYM, H5E_CANTINIT, FAIL, "unable to open object") done: FUNC_LEAVE_API(ret_value) diff --git a/src/H5Rdeprec.c b/src/H5Rdeprec.c index d0c79a8..bf75a0a 100644 --- a/src/H5Rdeprec.c +++ b/src/H5Rdeprec.c @@ -47,6 +47,7 @@ #include "H5Oprivate.h" /* Object headers */ #include "H5Rpkg.h" /* References */ #include "H5Ppublic.h" /* for using H5P_DATASET_ACCESS_DEFAULT */ +#include "H5VLprivate.h" /* VOL plugins */ #ifndef H5_NO_DEPRECATED_SYMBOLS /****************/ @@ -184,27 +185,26 @@ done: hid_t H5Rdereference1(hid_t obj_id, H5R_type_t ref_type, const void *_ref) { - H5G_loc_t loc; /* Group location */ - H5F_t *file = NULL; /* File object */ + void *location = NULL; /* a pointer to VOL specific token that indicates + the location of the object */ hid_t ret_value; FUNC_ENTER_API(FAIL) H5TRACE3("i", "iRt*x", obj_id, ref_type, _ref); /* Check args */ - if(H5G_loc(obj_id, &loc) < 0) - HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a location") if(ref_type <= H5R_BADTYPE || ref_type >= H5R_MAXTYPE) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "invalid reference type") if(_ref == NULL) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "invalid reference pointer") - /* Get the file pointer from the entry */ - file = loc.oloc->file; + /* Get the token for the Object location through the VOL */ + if(H5VL_object_lookup (obj_id, H5VL_OBJECT_LOOKUP_BY_REF, &location, ref_type, _ref) < 0) + HGOTO_ERROR(H5E_SYM, H5E_CANTINIT, FAIL, "unable to locate object") - /* Create reference */ - if((ret_value = H5R_dereference(file, H5P_DATASET_ACCESS_DEFAULT, H5AC_dxpl_id, ref_type, _ref, TRUE)) < 0) - HGOTO_ERROR(H5E_REFERENCE, H5E_CANTINIT, FAIL, "unable dereference object") + /* Open the object through the VOL */ + if((ret_value = H5VL_object_open_by_loc(obj_id, location, H5P_DATASET_ACCESS_DEFAULT)) < 0) + HGOTO_ERROR(H5E_SYM, H5E_CANTINIT, FAIL, "unable to open object") done: FUNC_LEAVE_API(ret_value) diff --git a/src/H5Tconv.c b/src/H5Tconv.c index 6795ef1..516ac92 100644 --- a/src/H5Tconv.c +++ b/src/H5Tconv.c @@ -629,7 +629,8 @@ case H5T_CONV_INIT: \ /* Sanity check and initialize statistics */ \ cdata->need_bkg = H5T_BKG_NO; \ - if (NULL==(st=(H5T_t*)H5I_object(src_id)) || NULL==(dt=(H5T_t*)H5I_object(dst_id))) \ + if (NULL==(st=(H5T_t*)H5I_object_verify(src_id, H5I_DATATYPE)) || \ + NULL==(dt=(H5T_t*)H5I_object_verify(dst_id, H5I_DATATYPE))) \ HGOTO_ERROR(H5E_DATATYPE, H5E_CANTINIT, FAIL, \ "unable to dereference datatype object ID") \ if (st->shared->size!=sizeof(ST) || dt->shared->size!=sizeof(DT)) \ @@ -676,7 +677,8 @@ HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, FAIL, "unable to get conversion exception callback") \ \ /* Get source and destination datatypes */ \ - if(NULL == (st = (H5T_t *)H5I_object(src_id)) || NULL == (dt = (H5T_t *)H5I_object(dst_id))) \ + if (NULL==(st=(H5T_t*)H5I_object_verify(src_id, H5I_DATATYPE)) || \ + NULL==(dt=(H5T_t*)H5I_object_verify(dst_id, H5I_DATATYPE))) \ HGOTO_ERROR(H5E_DATATYPE, H5E_CANTINIT, FAIL, "unable to dereference datatype object ID") \ \ /* Get source & destination precisions into a variable */ \ @@ -1050,7 +1052,7 @@ H5T_conv_order_opt(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, switch(cdata->command) { case H5T_CONV_INIT: /* Capability query */ - if(NULL == (src = (H5T_t *)H5I_object(src_id)) || NULL == (dst = (H5T_t *)H5I_object(dst_id))) + if(NULL == (src = (H5T_t *)H5I_object_verify(src_id, H5I_DATATYPE)) || NULL == (dst = (H5T_t *)H5I_object_verify(dst_id, H5I_DATATYPE))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a datatype") if(src->shared->size != dst->shared->size || 0 != src->shared->u.atomic.offset || @@ -1093,7 +1095,7 @@ H5T_conv_order_opt(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, case H5T_CONV_CONV: /* The conversion */ - if(NULL == (src = (H5T_t *)H5I_object(src_id)) || NULL == (dst = (H5T_t *)H5I_object(dst_id))) + if(NULL == (src = (H5T_t *)H5I_object_verify(src_id, H5I_DATATYPE)) || NULL == (dst = (H5T_t *)H5I_object_verify(dst_id, H5I_DATATYPE))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a datatype") /* Check for "no op" reference conversion */ @@ -1458,8 +1460,8 @@ H5T_conv_order(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, size_t nelmts, switch(cdata->command) { case H5T_CONV_INIT: /* Capability query */ - if(NULL == (src = (H5T_t *)H5I_object(src_id)) || - NULL == (dst = (H5T_t *)H5I_object(dst_id))) + if(NULL == (src = (H5T_t *)H5I_object_verify(src_id, H5I_DATATYPE)) || + NULL == (dst = (H5T_t *)H5I_object_verify(dst_id, H5I_DATATYPE))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a datatype") if(src->shared->size != dst->shared->size || 0 != src->shared->u.atomic.offset || 0 != dst->shared->u.atomic.offset || @@ -1495,7 +1497,7 @@ H5T_conv_order(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, size_t nelmts, case H5T_CONV_CONV: /* The conversion */ - if(NULL == (src = (H5T_t *)H5I_object(src_id))) + if(NULL == (src = (H5T_t *)H5I_object_verify(src_id, H5I_DATATYPE))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a datatype") buf_stride = buf_stride ? buf_stride : src->shared->size; @@ -1563,8 +1565,8 @@ H5T_conv_b_b(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, size_t nelmts, switch(cdata->command) { case H5T_CONV_INIT: /* Capability query */ - if(NULL == (src = (H5T_t *)H5I_object(src_id)) || - NULL == (dst = (H5T_t *)H5I_object(dst_id))) + if(NULL == (src = (H5T_t *)H5I_object_verify(src_id, H5I_DATATYPE)) || + NULL == (dst = (H5T_t *)H5I_object_verify(dst_id, H5I_DATATYPE))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a datatype") if(H5T_ORDER_LE != src->shared->u.atomic.order && H5T_ORDER_BE != src->shared->u.atomic.order) @@ -1580,7 +1582,7 @@ H5T_conv_b_b(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, size_t nelmts, case H5T_CONV_CONV: /* Get the datatypes */ - if(NULL == (src = (H5T_t *)H5I_object(src_id)) || NULL == (dst = (H5T_t *)H5I_object(dst_id))) + if(NULL == (src = (H5T_t *)H5I_object_verify(src_id, H5I_DATATYPE)) || NULL == (dst = (H5T_t *)H5I_object_verify(dst_id, H5I_DATATYPE))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a datatype") /* @@ -2108,7 +2110,7 @@ H5T_conv_struct(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, size_t nelmts, * otherwise initialize the `priv' field of `cdata' with information * that remains (almost) constant for this conversion path. */ - if (NULL == (src = (H5T_t *)H5I_object(src_id)) || NULL == (dst = (H5T_t *)H5I_object(dst_id))) + if (NULL == (src = (H5T_t *)H5I_object_verify(src_id, H5I_DATATYPE)) || NULL == (dst = (H5T_t *)H5I_object_verify(dst_id, H5I_DATATYPE))) HGOTO_ERROR(H5E_DATATYPE, H5E_BADTYPE, FAIL, "not a datatype") if(H5T_COMPOUND != src->shared->type) HGOTO_ERROR(H5E_DATATYPE, H5E_BADTYPE, FAIL, "not a H5T_COMPOUND datatype") @@ -2130,7 +2132,7 @@ H5T_conv_struct(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, size_t nelmts, /* * Conversion. */ - if(NULL == (src = (H5T_t *)H5I_object(src_id)) || NULL == (dst = (H5T_t *)H5I_object(dst_id))) + if(NULL == (src = (H5T_t *)H5I_object_verify(src_id, H5I_DATATYPE)) || NULL == (dst = (H5T_t *)H5I_object_verify(dst_id, H5I_DATATYPE))) HGOTO_ERROR(H5E_DATATYPE, H5E_BADTYPE, FAIL, "not a datatype") HDassert(priv); HDassert(bkg && cdata->need_bkg); @@ -2358,7 +2360,7 @@ H5T_conv_struct_opt(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, * otherwise initialize the `priv' field of `cdata' with information * that remains (almost) constant for this conversion path. */ - if(NULL == (src = (H5T_t *)H5I_object(src_id)) || NULL == (dst = (H5T_t *)H5I_object(dst_id))) + if(NULL == (src = (H5T_t *)H5I_object_verify(src_id, H5I_DATATYPE)) || NULL == (dst = (H5T_t *)H5I_object_verify(dst_id, H5I_DATATYPE))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a datatype") if(H5T_COMPOUND != src->shared->type) HGOTO_ERROR(H5E_DATATYPE, H5E_BADTYPE, FAIL, "not a H5T_COMPOUND datatype") @@ -2417,7 +2419,7 @@ H5T_conv_struct_opt(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, /* * Conversion. */ - if(NULL == (src = (H5T_t *)H5I_object(src_id)) || NULL == (dst = (H5T_t *)H5I_object(dst_id))) + if(NULL == (src = (H5T_t *)H5I_object_verify(src_id, H5I_DATATYPE)) || NULL == (dst = (H5T_t *)H5I_object_verify(dst_id, H5I_DATATYPE))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a datatype") /* Update cached data if necessary */ @@ -2739,7 +2741,7 @@ H5T_conv_enum(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, size_t nelmts, * the `priv' field of `cdata' with information about the underlying * integer conversion. */ - if(NULL == (src = (H5T_t *)H5I_object(src_id)) || NULL == (dst = (H5T_t *)H5I_object(dst_id))) + if(NULL == (src = (H5T_t *)H5I_object_verify(src_id, H5I_DATATYPE)) || NULL == (dst = (H5T_t *)H5I_object_verify(dst_id, H5I_DATATYPE))) HGOTO_ERROR(H5E_DATATYPE, H5E_BADTYPE, FAIL, "not a datatype") if(H5T_ENUM != src->shared->type) HGOTO_ERROR(H5E_DATATYPE, H5E_BADTYPE, FAIL, "not a H5T_ENUM datatype") @@ -2766,7 +2768,7 @@ H5T_conv_enum(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, size_t nelmts, break; case H5T_CONV_CONV: - if(NULL == (src = (H5T_t *)H5I_object(src_id)) || NULL == (dst = (H5T_t *)H5I_object(dst_id))) + if(NULL == (src = (H5T_t *)H5I_object_verify(src_id, H5I_DATATYPE)) || NULL == (dst = (H5T_t *)H5I_object_verify(dst_id, H5I_DATATYPE))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a datatype") if(H5T_ENUM != src->shared->type) HGOTO_ERROR(H5E_DATATYPE, H5E_BADTYPE, FAIL, "not a H5T_ENUM datatype") @@ -2970,7 +2972,7 @@ H5T_conv_vlen(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, size_t nelmts, * information that remains (almost) constant for this * conversion path. */ - if(NULL == (src = (H5T_t *)H5I_object(src_id)) || NULL == (dst = (H5T_t *)H5I_object(dst_id))) + if(NULL == (src = (H5T_t *)H5I_object_verify(src_id, H5I_DATATYPE)) || NULL == (dst = (H5T_t *)H5I_object_verify(dst_id, H5I_DATATYPE))) HGOTO_ERROR(H5E_DATATYPE, H5E_BADTYPE, FAIL, "not a datatype") if(H5T_VLEN != src->shared->type) HGOTO_ERROR(H5E_DATATYPE, H5E_BADTYPE, FAIL, "not a H5T_VLEN datatype") @@ -2995,7 +2997,7 @@ H5T_conv_vlen(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, size_t nelmts, /* * Conversion. */ - if(NULL == (src = (H5T_t *)H5I_object(src_id)) || NULL == (dst = (H5T_t *)H5I_object(dst_id))) + if(NULL == (src = (H5T_t *)H5I_object_verify(src_id, H5I_DATATYPE)) || NULL == (dst = (H5T_t *)H5I_object_verify(dst_id, H5I_DATATYPE))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a datatype") /* Initialize source & destination strides */ @@ -3278,7 +3280,7 @@ H5T_conv_array(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, size_t nelmts, * information that remains (almost) constant for this * conversion path. */ - if(NULL == (src = (H5T_t *)H5I_object(src_id)) || NULL == (dst = (H5T_t *)H5I_object(dst_id))) + if(NULL == (src = (H5T_t *)H5I_object_verify(src_id, H5I_DATATYPE)) || NULL == (dst = (H5T_t *)H5I_object_verify(dst_id, H5I_DATATYPE))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a datatype") HDassert(H5T_ARRAY==src->shared->type); HDassert(H5T_ARRAY==dst->shared->type); @@ -3303,7 +3305,7 @@ H5T_conv_array(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, size_t nelmts, /* * Conversion. */ - if (NULL == (src = (H5T_t *)H5I_object(src_id)) || NULL == (dst = (H5T_t *)H5I_object(dst_id))) + if (NULL == (src = (H5T_t *)H5I_object_verify(src_id, H5I_DATATYPE)) || NULL == (dst = (H5T_t *)H5I_object_verify(dst_id, H5I_DATATYPE))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a datatype") /* @@ -3436,7 +3438,8 @@ H5T_conv_i_i(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, size_t nelmts, switch(cdata->command) { case H5T_CONV_INIT: - if(NULL == (src = (H5T_t *)H5I_object(src_id)) || NULL == (dst = (H5T_t *)H5I_object(dst_id))) + if(NULL == (src = (H5T_t *)H5I_object_verify(src_id, H5I_DATATYPE)) || + NULL == (dst = (H5T_t *)H5I_object_verify(dst_id, H5I_DATATYPE))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a datatype") if(H5T_ORDER_LE != src->shared->u.atomic.order && H5T_ORDER_BE != src->shared->u.atomic.order) HGOTO_ERROR(H5E_DATATYPE, H5E_UNSUPPORTED, FAIL, "unsupported byte order") @@ -3452,7 +3455,8 @@ H5T_conv_i_i(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, size_t nelmts, case H5T_CONV_CONV: /* Get the datatypes */ - if(NULL == (src = (H5T_t *)H5I_object(src_id)) || NULL == (dst = (H5T_t *)H5I_object(dst_id))) + if(NULL == (src = (H5T_t *)H5I_object_verify(src_id, H5I_DATATYPE)) || + NULL == (dst = (H5T_t *)H5I_object_verify(dst_id, H5I_DATATYPE))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a datatype") /* @@ -3858,7 +3862,8 @@ H5T_conv_f_f(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, size_t nelmts, switch(cdata->command) { case H5T_CONV_INIT: - if(NULL == (src_p = (H5T_t *)H5I_object(src_id)) || NULL == (dst_p = (H5T_t *)H5I_object(dst_id))) + if(NULL == (src_p = (H5T_t *)H5I_object_verify(src_id, H5I_DATATYPE)) || + NULL == (dst_p = (H5T_t *)H5I_object_verify(dst_id, H5I_DATATYPE))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a datatype") src = src_p->shared->u.atomic; dst = dst_p->shared->u.atomic; @@ -3878,7 +3883,8 @@ H5T_conv_f_f(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, size_t nelmts, case H5T_CONV_CONV: /* Get the datatypes */ - if(NULL == (src_p = (H5T_t *)H5I_object(src_id)) || NULL == (dst_p = (H5T_t *)H5I_object(dst_id))) + if(NULL == (src_p = (H5T_t *)H5I_object_verify(src_id, H5I_DATATYPE)) || + NULL == (dst_p = (H5T_t *)H5I_object_verify(dst_id, H5I_DATATYPE))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a datatype") src = src_p->shared->u.atomic; dst = dst_p->shared->u.atomic; @@ -4403,7 +4409,7 @@ H5T_conv_s_s(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, size_t nelmts, switch(cdata->command) { case H5T_CONV_INIT: - if(NULL == (src = (H5T_t *)H5I_object(src_id)) || NULL == (dst = (H5T_t *)H5I_object(dst_id))) + if(NULL == (src = (H5T_t *)H5I_object_verify(src_id, H5I_DATATYPE)) || NULL == (dst = (H5T_t *)H5I_object_verify(dst_id, H5I_DATATYPE))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a datatype") if(8 * src->shared->size != src->shared->u.atomic.prec || 8 * dst->shared->size != dst->shared->u.atomic.prec) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "bad precision") @@ -4427,7 +4433,7 @@ H5T_conv_s_s(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, size_t nelmts, case H5T_CONV_CONV: /* Get the datatypes */ - if(NULL == (src = (H5T_t *)H5I_object(src_id)) || NULL == (dst = (H5T_t *)H5I_object(dst_id))) + if(NULL == (src = (H5T_t *)H5I_object_verify(src_id, H5I_DATATYPE)) || NULL == (dst = (H5T_t *)H5I_object_verify(dst_id, H5I_DATATYPE))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a datatype") /* @@ -8697,7 +8703,8 @@ H5T_conv_f_i(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, size_t nelmts, switch(cdata->command) { case H5T_CONV_INIT: - if(NULL == (src_p = (H5T_t*)H5I_object(src_id)) || NULL == (dst_p = (H5T_t*)H5I_object(dst_id))) + if(NULL == (src_p = (H5T_t*)H5I_object_verify(src_id, H5I_DATATYPE)) || + NULL == (dst_p = (H5T_t*)H5I_object_verify(dst_id, H5I_DATATYPE))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a datatype") src = src_p->shared->u.atomic; dst = dst_p->shared->u.atomic; @@ -8715,7 +8722,8 @@ H5T_conv_f_i(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, size_t nelmts, case H5T_CONV_CONV: /* Get the datatypes */ - if(NULL == (src_p = (H5T_t*)H5I_object(src_id)) || NULL == (dst_p = (H5T_t*)H5I_object(dst_id))) + if(NULL == (src_p = (H5T_t*)H5I_object_verify(src_id, H5I_DATATYPE)) || + NULL == (dst_p = (H5T_t*)H5I_object_verify(dst_id, H5I_DATATYPE))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a datatype") src = src_p->shared->u.atomic; dst = dst_p->shared->u.atomic; @@ -9286,7 +9294,8 @@ H5T_conv_i_f(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, size_t nelmts, switch(cdata->command) { case H5T_CONV_INIT: - if(NULL == (src_p = (H5T_t *)H5I_object(src_id)) || NULL == (dst_p = (H5T_t *)H5I_object(dst_id))) + if(NULL == (src_p = (H5T_t *)H5I_object_verify(src_id, H5I_DATATYPE)) || + NULL == (dst_p = (H5T_t *)H5I_object_verify(dst_id, H5I_DATATYPE))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a datatype") src = src_p->shared->u.atomic; dst = dst_p->shared->u.atomic; @@ -9304,7 +9313,8 @@ H5T_conv_i_f(hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, size_t nelmts, case H5T_CONV_CONV: /* Get the datatypes */ - if(NULL == (src_p = (H5T_t *)H5I_object(src_id)) || NULL == (dst_p = (H5T_t *)H5I_object(dst_id))) + if(NULL == (src_p = (H5T_t *)H5I_object_verify(src_id, H5I_DATATYPE)) || + NULL == (dst_p = (H5T_t *)H5I_object_verify(dst_id, H5I_DATATYPE))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a datatype") src = src_p->shared->u.atomic; dst = dst_p->shared->u.atomic; diff --git a/src/H5VL.c b/src/H5VL.c index dd624c8..4dde009 100644 --- a/src/H5VL.c +++ b/src/H5VL.c @@ -41,15 +41,13 @@ #include "H5Eprivate.h" /* Error handling */ #include "H5Iprivate.h" /* IDs */ #include "H5Ipkg.h" /* IDs Package header */ +#include "H5Lprivate.h" /* Links */ #include "H5MMprivate.h" /* Memory management */ #include "H5Pprivate.h" /* Property lists */ #include "H5Oprivate.h" /* Object headers */ #include "H5VLpkg.h" /* VOL package header */ #include "H5VLprivate.h" /* VOL */ -/* Declare a free list to manage the H5VL_id_wrapper_t struct */ -H5FL_DEFINE_STATIC(H5VL_id_wrapper_t); - /********************/ /* Local Prototypes */ /********************/ @@ -154,19 +152,63 @@ done: int H5VL_term_interface(void) { - int n = 0; + int n = 0, n1 = 0, n2 = 0, n3 = 0, n4 = 0, n5 = 0, n6 = 0; + hbool_t term = TRUE; FUNC_ENTER_NOAPI_NOINIT_NOERR if(H5_interface_initialize_g) { - if((n=H5I_nmembers(H5I_VOL))!=0) { + if((n1=H5I_nmembers(H5I_VOL))!=0) { H5I_clear_type(H5I_VOL, FALSE, FALSE); + term = FALSE; } else { H5I_dec_type_ref(H5I_VOL); - H5_interface_initialize_g = 0; - n = 1; /*H5I*/ } + + if((n2=H5I_nmembers(H5I_FILE_PUBLIC))!=0) { + H5I_clear_type(H5I_FILE_PUBLIC, FALSE, FALSE); + term = FALSE; + } else { + H5I_dec_type_ref(H5I_FILE_PUBLIC); + } + + if((n3=H5I_nmembers(H5I_DATASET_PUBLIC))!=0) { + H5I_clear_type(H5I_DATASET_PUBLIC, FALSE, FALSE); + term = FALSE; + } else { + H5I_dec_type_ref(H5I_DATASET_PUBLIC); + } + + if((n4=H5I_nmembers(H5I_DATATYPE_PUBLIC))!=0) { + H5I_clear_type(H5I_DATATYPE_PUBLIC, FALSE, FALSE); + term = FALSE; + } else { + H5I_dec_type_ref(H5I_DATATYPE_PUBLIC); + } + + if((n5=H5I_nmembers(H5I_GROUP_PUBLIC))!=0) { + H5I_clear_type(H5I_GROUP_PUBLIC, FALSE, FALSE); + term = FALSE; + } else { + H5I_dec_type_ref(H5I_GROUP_PUBLIC); + } + + if((n6=H5I_nmembers(H5I_ATTR_PUBLIC))!=0) { + H5I_clear_type(H5I_ATTR_PUBLIC, FALSE, FALSE); + term = FALSE; + } else { + H5I_dec_type_ref(H5I_ATTR_PUBLIC); + } + + if (term) { + H5_interface_initialize_g = 0; + n = 1; + } + else { + n = n1 + n2 + n3 + n4 + n5 + n6; + } } + FUNC_LEAVE_NOAPI(n) } @@ -516,7 +558,7 @@ hid_t H5VL_file_open(const char *name, unsigned flags, hid_t fapl_id) { H5VL_class_t *vol_plugin; /* VOL for file */ - H5VL_id_wrapper_t *uid_info; /* user id structure */ + H5VL_id_wrapper_t *id_wrapper; /* user id structure */ H5P_genplist_t *plist; /* Property list pointer */ hid_t file_id; hid_t ret_value; /* Return value */ @@ -538,13 +580,13 @@ H5VL_file_open(const char *name, unsigned flags, hid_t fapl_id) /* Create a new id that points to a struct that holds the file id and the VOL plugin */ /* Allocate new id structure */ - if(NULL == (uid_info = H5FL_MALLOC(H5VL_id_wrapper_t))) + if(NULL == (id_wrapper = (H5VL_id_wrapper_t *)H5MM_malloc(sizeof(H5VL_id_wrapper_t)))) HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, FAIL, "memory allocation failed") - uid_info->obj_id = file_id; - uid_info->vol_plugin = vol_plugin; + id_wrapper->obj_id = file_id; + id_wrapper->vol_plugin = vol_plugin; vol_plugin->nrefs ++; - if((ret_value = H5I_register(H5I_FILE_PUBLIC, uid_info, TRUE)) < 0) + if((ret_value = H5I_register(H5I_FILE_PUBLIC, id_wrapper, TRUE)) < 0) HGOTO_ERROR(H5E_ATOM, H5E_CANTREGISTER, FAIL, "unable to atomize file handle") done: FUNC_LEAVE_NOAPI(ret_value) @@ -570,7 +612,7 @@ hid_t H5VL_file_create(const char *name, unsigned flags, hid_t fcpl_id, hid_t fapl_id) { H5VL_class_t *vol_plugin; /* VOL for file */ - H5VL_id_wrapper_t *uid_info; /* user id structure */ + H5VL_id_wrapper_t *id_wrapper; /* user id structure */ H5P_genplist_t *plist; /* Property list pointer */ hid_t file_id; hid_t ret_value; /* Return value */ @@ -592,13 +634,13 @@ H5VL_file_create(const char *name, unsigned flags, hid_t fcpl_id, hid_t fapl_id) /* Create a new id that points to a struct that holds the file id and the VOL id */ /* Allocate new id structure */ - if(NULL == (uid_info = H5FL_MALLOC(H5VL_id_wrapper_t))) + if(NULL == (id_wrapper = (H5VL_id_wrapper_t *)H5MM_malloc(sizeof(H5VL_id_wrapper_t)))) HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, FAIL, "memory allocation failed") - uid_info->obj_id = file_id; - uid_info->vol_plugin = vol_plugin; + id_wrapper->obj_id = file_id; + id_wrapper->vol_plugin = vol_plugin; vol_plugin->nrefs ++; - if((ret_value = H5I_register(H5I_FILE_PUBLIC, uid_info, TRUE)) < 0) + if((ret_value = H5I_register(H5I_FILE_PUBLIC, id_wrapper, TRUE)) < 0) HGOTO_ERROR(H5E_ATOM, H5E_CANTREGISTER, FAIL, "unable to atomize file handle") done: @@ -623,7 +665,7 @@ done: herr_t H5VL_file_close(hid_t uid) { - H5VL_id_wrapper_t *uid_info; /* user id structure */ + H5VL_id_wrapper_t *id_wrapper; /* user id structure */ herr_t ret_value = SUCCEED; FUNC_ENTER_NOAPI(FAIL) @@ -633,15 +675,15 @@ H5VL_file_close(hid_t uid) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a user ID") /* get the ID struct */ - if(NULL == (uid_info = (H5VL_id_wrapper_t *)H5I_object(uid))) + if(NULL == (id_wrapper = (H5VL_id_wrapper_t *)H5I_object(uid))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "invalid user identifier") - if(NULL == uid_info->vol_plugin->file_cls.close) + if(NULL == id_wrapper->vol_plugin->file_cls.close) HGOTO_ERROR(H5E_VOL, H5E_UNSUPPORTED, FAIL, "vol plugin has no `file close' method") - if((ret_value = (uid_info->vol_plugin->file_cls.close)(uid_info->obj_id)) < 0) + if((ret_value = (id_wrapper->vol_plugin->file_cls.close)(id_wrapper->obj_id)) < 0) HGOTO_ERROR(H5E_VOL, H5E_CANTCLOSEFILE, FAIL, "close failed") - uid_info->vol_plugin->nrefs--; + id_wrapper->vol_plugin->nrefs--; if(H5I_dec_app_ref(uid) < 0) HGOTO_ERROR(H5E_FILE, H5E_CANTINC, FAIL, "unable to decrement ref count on user ID") @@ -667,7 +709,7 @@ done: herr_t H5VL_file_flush(hid_t uid, H5F_scope_t scope) { - H5VL_id_wrapper_t *uid_info; /* user id structure */ + H5VL_id_wrapper_t *id_wrapper; /* user id structure */ herr_t ret_value = SUCCEED; FUNC_ENTER_NOAPI(FAIL) @@ -677,12 +719,12 @@ H5VL_file_flush(hid_t uid, H5F_scope_t scope) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a user ID") /* get the ID struct */ - if(NULL == (uid_info = (H5VL_id_wrapper_t *)H5I_object(uid))) + if(NULL == (id_wrapper = (H5VL_id_wrapper_t *)H5I_object(uid))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "invalid user identifier") - if(NULL == uid_info->vol_plugin->file_cls.flush) + if(NULL == id_wrapper->vol_plugin->file_cls.flush) HGOTO_ERROR(H5E_VOL, H5E_UNSUPPORTED, FAIL, "vol plugin has no `file flush' method") - if((ret_value = (uid_info->vol_plugin->file_cls.flush)(uid_info->obj_id, scope)) < 0) + if((ret_value = (id_wrapper->vol_plugin->file_cls.flush)(id_wrapper->obj_id, scope)) < 0) HGOTO_ERROR(H5E_VOL, H5E_CANTFLUSH, FAIL, "flush failed") done: @@ -707,7 +749,7 @@ done: herr_t H5VL_file_get(hid_t uid, H5VL_file_get_t get_type, ...) { - H5VL_id_wrapper_t *uid_info; /* user id structure */ + H5VL_id_wrapper_t *id_wrapper; /* user id structure */ va_list arguments; /* argument list passed from the API call */ H5I_type_t id_type; /* Type of ID */ herr_t ret_value = SUCCEED; @@ -722,14 +764,14 @@ H5VL_file_get(hid_t uid, H5VL_file_get_t get_type, ...) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a user ID") /* get the ID struct */ - if(NULL == (uid_info = (H5VL_id_wrapper_t *)H5I_object(uid))) + if(NULL == (id_wrapper = (H5VL_id_wrapper_t *)H5I_object(uid))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "invalid user identifier") - if(NULL == uid_info->vol_plugin->file_cls.get) + if(NULL == id_wrapper->vol_plugin->file_cls.get) HGOTO_ERROR(H5E_VOL, H5E_UNSUPPORTED, FAIL, "vol plugin has no `file get' method") va_start(arguments, get_type); - if((ret_value = (uid_info->vol_plugin->file_cls.get)(uid_info->obj_id, get_type, arguments)) < 0) + if((ret_value = (id_wrapper->vol_plugin->file_cls.get)(id_wrapper->obj_id, get_type, arguments)) < 0) HGOTO_ERROR(H5E_VOL, H5E_CANTGET, FAIL, "get failed") va_end(arguments); @@ -754,36 +796,36 @@ done: *------------------------------------------------------------------------- */ hid_t -H5VL_group_create(hid_t uid, const char *name, hid_t lcpl_id, hid_t gcpl_id, hid_t gapl_id) +H5VL_group_create(hid_t uid, const char *name, hid_t gcpl_id, hid_t gapl_id) { - H5VL_id_wrapper_t *uid_info1; /* user id structure of the location where the group will be created */ - H5VL_id_wrapper_t *uid_info2; /* user id structure of new created group*/ + H5VL_id_wrapper_t *id_wrapper1; /* user id structure of the location where the group will be created */ + H5VL_id_wrapper_t *id_wrapper2; /* user id structure of new created group*/ hid_t group_id; /* actual group ID */ hid_t ret_value; /* Return value */ FUNC_ENTER_NOAPI(FAIL) /* get the ID struct */ - if(NULL == (uid_info1 = (H5VL_id_wrapper_t *)H5I_object(uid))) + if(NULL == (id_wrapper1 = (H5VL_id_wrapper_t *)H5I_object(uid))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "invalid user identifier") /* check if the corresponding VOL create callback exists */ - if(NULL == uid_info1->vol_plugin->group_cls.create) + if(NULL == id_wrapper1->vol_plugin->group_cls.create) HGOTO_ERROR(H5E_VOL, H5E_UNSUPPORTED, FAIL, "vol plugin has no `group create' method") /* call the corresponding VOL create callback */ - if((group_id = (uid_info1->vol_plugin->group_cls.create) - (uid_info1->obj_id, name, lcpl_id, gcpl_id, gapl_id)) < 0) + if((group_id = (id_wrapper1->vol_plugin->group_cls.create) + (id_wrapper1->obj_id, name, gcpl_id, gapl_id)) < 0) HGOTO_ERROR(H5E_VOL, H5E_CANTINIT, FAIL, "create failed") /* Create a new id that points to a struct that holds the group id and the VOL plugin */ /* Allocate new id structure */ - if(NULL == (uid_info2 = H5FL_MALLOC(H5VL_id_wrapper_t))) + if(NULL == (id_wrapper2 = (H5VL_id_wrapper_t *)H5MM_malloc(sizeof(H5VL_id_wrapper_t)))) HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, FAIL, "memory allocation failed") - uid_info2->obj_id = group_id; - uid_info2->vol_plugin = uid_info1->vol_plugin; + id_wrapper2->obj_id = group_id; + id_wrapper2->vol_plugin = id_wrapper1->vol_plugin; - if((ret_value = H5I_register(H5I_GROUP_PUBLIC, uid_info2, TRUE)) < 0) + if((ret_value = H5I_register(H5I_GROUP_PUBLIC, id_wrapper2, TRUE)) < 0) HGOTO_ERROR(H5E_ATOM, H5E_CANTREGISTER, FAIL, "unable to atomize group handle") done: @@ -807,37 +849,48 @@ done: *------------------------------------------------------------------------- */ hid_t -H5VL_group_open(hid_t uid, const char *name, hid_t gapl_id) +H5VL_group_open(hid_t loc_id, const char *name, hid_t gapl_id) { - H5VL_id_wrapper_t *uid_info1; /* user id structure of the location where the group will be opend */ - H5VL_id_wrapper_t *uid_info2; /* user id structure of new opend group*/ + H5VL_id_wrapper_t *id_wrapper1; /* user id structure of the location where the group will be opend */ + H5VL_id_wrapper_t *id_wrapper2; /* user id structure of new opend group*/ hid_t group_id; /* actual group ID */ hid_t ret_value; /* Return value */ FUNC_ENTER_NOAPI(FAIL) /* get the ID struct */ - if(NULL == (uid_info1 = (H5VL_id_wrapper_t *)H5I_object(uid))) + if(NULL == (id_wrapper1 = (H5VL_id_wrapper_t *)H5I_object(loc_id))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "invalid user identifier") - /* check if the corresponding VOL open callback exists */ - if(NULL == uid_info1->vol_plugin->group_cls.open) - HGOTO_ERROR(H5E_VOL, H5E_UNSUPPORTED, FAIL, "vol plugin has no `group open' method") - /* call the corresponding VOL open callback */ - if((group_id = (uid_info1->vol_plugin->group_cls.open) - (uid_info1->obj_id, name, gapl_id)) < 0) - HGOTO_ERROR(H5E_VOL, H5E_CANTINIT, FAIL, "open failed") + /* check if the type specific corresponding VOL open callback exists */ + if(NULL == id_wrapper1->vol_plugin->group_cls.open) { + void *location = NULL; /* a pointer to VOL specific token that indicates + the location of the object */ - /* Create a new id that points to a struct that holds the group id and the VOL plugin */ - /* Allocate new id structure */ - if(NULL == (uid_info2 = H5FL_MALLOC(H5VL_id_wrapper_t))) - HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, FAIL, "memory allocation failed") - uid_info2->obj_id = group_id; - uid_info2->vol_plugin = uid_info1->vol_plugin; - - if((ret_value = H5I_register(H5I_GROUP_PUBLIC, uid_info2, TRUE)) < 0) - HGOTO_ERROR(H5E_ATOM, H5E_CANTREGISTER, FAIL, "unable to atomize group handle") + /* Get the token for the Object location through the VOL */ + if(H5VL_object_lookup (loc_id, H5VL_OBJECT_LOOKUP_BY_NAME, &location, name, gapl_id) < 0) + HGOTO_ERROR(H5E_SYM, H5E_CANTINIT, FAIL, "unable to locate object") + /* Open the object through the VOL */ + if((ret_value = H5VL_object_open_by_loc(loc_id, location, gapl_id)) < 0) + HGOTO_ERROR(H5E_SYM, H5E_CANTINIT, FAIL, "unable to open object") + } + else { + /* call the corresponding VOL open callback */ + if((group_id = (id_wrapper1->vol_plugin->group_cls.open) + (id_wrapper1->obj_id, name, gapl_id)) < 0) + HGOTO_ERROR(H5E_VOL, H5E_CANTINIT, FAIL, "open failed") + + /* Create a new id that points to a struct that holds the group id and the VOL plugin */ + /* Allocate new id structure */ + if(NULL == (id_wrapper2 = (H5VL_id_wrapper_t *)H5MM_malloc(sizeof(H5VL_id_wrapper_t)))) + HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, FAIL, "memory allocation failed") + id_wrapper2->obj_id = group_id; + id_wrapper2->vol_plugin = id_wrapper1->vol_plugin; + + if((ret_value = H5I_register(H5I_GROUP_PUBLIC, id_wrapper2, TRUE)) < 0) + HGOTO_ERROR(H5E_ATOM, H5E_CANTREGISTER, FAIL, "unable to atomize group handle") + } done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5VL_group_open() */ @@ -860,7 +913,7 @@ done: herr_t H5VL_group_close(hid_t uid) { - H5VL_id_wrapper_t *uid_info; /* user id structure */ + H5VL_id_wrapper_t *id_wrapper; /* user id structure */ herr_t ret_value = SUCCEED; FUNC_ENTER_NOAPI(FAIL) @@ -870,17 +923,24 @@ H5VL_group_close(hid_t uid) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a user ID") /* get the ID struct */ - if(NULL == (uid_info = (H5VL_id_wrapper_t *)H5I_object(uid))) + if(NULL == (id_wrapper = (H5VL_id_wrapper_t *)H5I_object(uid))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "invalid user identifier") - if(NULL == uid_info->vol_plugin->group_cls.close) - HGOTO_ERROR(H5E_VOL, H5E_UNSUPPORTED, FAIL, "vol plugin has no `group close' method") - if((ret_value = (uid_info->vol_plugin->group_cls.close)(uid_info->obj_id)) < 0) - HGOTO_ERROR(H5E_VOL, H5E_CANTRELEASE, FAIL, "close failed") + /* if the VOL class does not implement a specific group close + callback, try the generic object close */ + if(NULL == id_wrapper->vol_plugin->group_cls.close) { + if(H5VL_object_close(uid) < 0) + HGOTO_ERROR(H5E_SYM, H5E_CANTRELEASE, FAIL, "unable to close object") + } + else { + if((ret_value = (id_wrapper->vol_plugin->group_cls.close)(id_wrapper->obj_id)) < 0) + HGOTO_ERROR(H5E_VOL, H5E_CANTRELEASE, FAIL, "close failed") - if(H5I_dec_app_ref(uid) < 0) - HGOTO_ERROR(H5E_VOL, H5E_CANTDEC, FAIL, "unable to decrement ref count on user ID") + id_wrapper->vol_plugin->nrefs--; + if(H5I_dec_app_ref(uid) < 0) + HGOTO_ERROR(H5E_VOL, H5E_CANTDEC, FAIL, "unable to decrement ref count on user ID") + } done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5VL_group_close() */ @@ -903,7 +963,7 @@ done: herr_t H5VL_group_get(hid_t uid, H5VL_group_get_t get_type, ...) { - H5VL_id_wrapper_t *uid_info; /* user id structure */ + H5VL_id_wrapper_t *id_wrapper; /* user id structure */ va_list arguments; /* argument list passed from the API call */ H5I_type_t id_type; /* Type of ID */ herr_t ret_value = SUCCEED; @@ -916,15 +976,15 @@ H5VL_group_get(hid_t uid, H5VL_group_get_t get_type, ...) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a user ID") /* get the ID struct */ - if(NULL == (uid_info = (H5VL_id_wrapper_t *)H5I_object(uid))) + if(NULL == (id_wrapper = (H5VL_id_wrapper_t *)H5I_object(uid))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "invalid user identifier") - if(NULL == uid_info->vol_plugin->group_cls.get) + if(NULL == id_wrapper->vol_plugin->group_cls.get) HGOTO_ERROR(H5E_VOL, H5E_UNSUPPORTED, FAIL, "vol plugin has no `group get' method") va_start (arguments, get_type); - if((ret_value = (uid_info->vol_plugin->group_cls.get)(uid_info->obj_id, get_type, - arguments)) < 0) + if((ret_value = (id_wrapper->vol_plugin->group_cls.get) + (id_wrapper->obj_id, get_type, arguments)) < 0) HGOTO_ERROR(H5E_VOL, H5E_CANTGET, FAIL, "get failed") va_end (arguments); @@ -934,7 +994,7 @@ done: /*------------------------------------------------------------------------- - * Function: H5VL_object_open + * Function: H5VL_object_open_by_loc * * Purpose: Opens a object through the VOL * @@ -949,10 +1009,10 @@ done: *------------------------------------------------------------------------- */ hid_t -H5VL_object_open(hid_t uid, void *obj_loc, hid_t lapl_id) +H5VL_object_open_by_loc(hid_t uid, void *obj_loc, hid_t lapl_id) { - H5VL_id_wrapper_t *uid_info1; /* user id structure of the location where the object will be opend */ - H5VL_id_wrapper_t *uid_info2; /* user id structure of new opend object*/ + H5VL_id_wrapper_t *id_wrapper1; /* user id structure of the location where the object will be opend */ + H5VL_id_wrapper_t *id_wrapper2; /* user id structure of new opend object*/ H5I_type_t id_type; hid_t object_id; /* actual object ID */ hid_t ret_value; /* Return value */ @@ -960,41 +1020,41 @@ H5VL_object_open(hid_t uid, void *obj_loc, hid_t lapl_id) FUNC_ENTER_NOAPI(FAIL) /* get the ID struct */ - if(NULL == (uid_info1 = (H5VL_id_wrapper_t *)H5I_object(uid))) + if(NULL == (id_wrapper1 = (H5VL_id_wrapper_t *)H5I_object(uid))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "invalid user identifier") /* check if the corresponding VOL open callback exists */ - if(NULL == uid_info1->vol_plugin->object_cls.open) + if(NULL == id_wrapper1->vol_plugin->object_cls.open) HGOTO_ERROR(H5E_VOL, H5E_UNSUPPORTED, FAIL, "vol plugin has no `object open' method") /* call the corresponding VOL open callback */ - if((object_id = (uid_info1->vol_plugin->object_cls.open) - (uid_info1->obj_id, obj_loc, lapl_id)) < 0) + if((object_id = (id_wrapper1->vol_plugin->object_cls.open) + (id_wrapper1->obj_id, obj_loc, lapl_id)) < 0) HGOTO_ERROR(H5E_VOL, H5E_CANTINIT, FAIL, "open failed") /* Create a new id that points to a struct that holds the object id and the VOL plugin */ /* Allocate new id structure */ - if(NULL == (uid_info2 = H5FL_MALLOC(H5VL_id_wrapper_t))) + if(NULL == (id_wrapper2 = (H5VL_id_wrapper_t *)H5MM_malloc(sizeof(H5VL_id_wrapper_t)))) HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, FAIL, "memory allocation failed") - uid_info2->obj_id = object_id; - uid_info2->vol_plugin = uid_info1->vol_plugin; + id_wrapper2->obj_id = object_id; + id_wrapper2->vol_plugin = id_wrapper1->vol_plugin; id_type = H5I_get_type(object_id); if (H5I_FILE == id_type) { - if((ret_value = H5I_register(H5I_FILE_PUBLIC, uid_info2, TRUE)) < 0) + if((ret_value = H5I_register(H5I_FILE_PUBLIC, id_wrapper2, TRUE)) < 0) HGOTO_ERROR(H5E_ATOM, H5E_CANTREGISTER, FAIL, "unable to atomize object handle") } else if (H5I_GROUP == id_type) { - if((ret_value = H5I_register(H5I_GROUP_PUBLIC, uid_info2, TRUE)) < 0) + if((ret_value = H5I_register(H5I_GROUP_PUBLIC, id_wrapper2, TRUE)) < 0) HGOTO_ERROR(H5E_ATOM, H5E_CANTREGISTER, FAIL, "unable to atomize object handle") } else if (H5I_DATATYPE == id_type) { - if((ret_value = H5I_register(H5I_DATATYPE_PUBLIC, uid_info2, TRUE)) < 0) + if((ret_value = H5I_register(H5I_DATATYPE_PUBLIC, id_wrapper2, TRUE)) < 0) HGOTO_ERROR(H5E_ATOM, H5E_CANTREGISTER, FAIL, "unable to atomize object handle") } else if (H5I_DATASET == id_type) { - if((ret_value = H5I_register(H5I_DATASET_PUBLIC, uid_info2, TRUE)) < 0) + if((ret_value = H5I_register(H5I_DATASET_PUBLIC, id_wrapper2, TRUE)) < 0) HGOTO_ERROR(H5E_ATOM, H5E_CANTREGISTER, FAIL, "unable to atomize object handle") } else { @@ -1003,7 +1063,7 @@ H5VL_object_open(hid_t uid, void *obj_loc, hid_t lapl_id) done: FUNC_LEAVE_NOAPI(ret_value) -} /* end H5VL_object_open() */ +} /* end H5VL_object_open_by_loc() */ /*------------------------------------------------------------------------- @@ -1023,7 +1083,7 @@ done: herr_t H5VL_object_close(hid_t uid) { - H5VL_id_wrapper_t *uid_info; /* user id structure */ + H5VL_id_wrapper_t *id_wrapper; /* user id structure */ H5I_type_t id_type; herr_t ret_value = SUCCEED; @@ -1049,14 +1109,15 @@ H5VL_object_close(hid_t uid) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a user ID") /* get the ID struct */ - if(NULL == (uid_info = (H5VL_id_wrapper_t *)H5I_object(uid))) + if(NULL == (id_wrapper = (H5VL_id_wrapper_t *)H5I_object(uid))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "invalid user identifier") - if(NULL == uid_info->vol_plugin->object_cls.close) + if(NULL == id_wrapper->vol_plugin->object_cls.close) HGOTO_ERROR(H5E_VOL, H5E_UNSUPPORTED, FAIL, "vol plugin has no `object close' method") - if((ret_value = (uid_info->vol_plugin->object_cls.close)(uid_info->obj_id)) < 0) + if((ret_value = (id_wrapper->vol_plugin->object_cls.close)(id_wrapper->obj_id)) < 0) HGOTO_ERROR(H5E_VOL, H5E_CANTRELEASE, FAIL, "close failed") + id_wrapper->vol_plugin->nrefs--; if(H5I_dec_app_ref(uid) < 0) HGOTO_ERROR(H5E_VOL, H5E_CANTDEC, FAIL, "unable to decrement ref count on user ID") @@ -1082,7 +1143,7 @@ done: herr_t H5VL_object_lookup(hid_t uid, H5VL_object_lookup_t lookup_type, ...) { - H5VL_id_wrapper_t *uid_info; /* user id structure */ + H5VL_id_wrapper_t *id_wrapper; /* user id structure */ va_list arguments; /* argument list passed from the API call */ H5I_type_t id_type; herr_t ret_value = SUCCEED; @@ -1097,15 +1158,15 @@ H5VL_object_lookup(hid_t uid, H5VL_object_lookup_t lookup_type, ...) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a user ID") /* lookup the ID struct */ - if(NULL == (uid_info = (H5VL_id_wrapper_t *)H5I_object(uid))) + if(NULL == (id_wrapper = (H5VL_id_wrapper_t *)H5I_object(uid))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "invalid user identifier") - if(NULL == uid_info->vol_plugin->object_cls.lookup) + if(NULL == id_wrapper->vol_plugin->object_cls.lookup) HGOTO_ERROR(H5E_VOL, H5E_UNSUPPORTED, FAIL, "vol plugin has no `object lookup' method") va_start (arguments, lookup_type); - if((ret_value = (uid_info->vol_plugin->object_cls.lookup)(uid_info->obj_id, lookup_type, - arguments)) < 0) + if((ret_value = (id_wrapper->vol_plugin->object_cls.lookup)(id_wrapper->obj_id, lookup_type, + arguments)) < 0) HGOTO_ERROR(H5E_VOL, H5E_CANTGET, FAIL, "lookup of object location failed") va_end (arguments); done: @@ -1130,7 +1191,7 @@ done: herr_t H5VL_object_get(hid_t uid, H5VL_object_get_t get_type, ...) { - H5VL_id_wrapper_t *uid_info; /* user id structure */ + H5VL_id_wrapper_t *id_wrapper; /* user id structure */ va_list arguments; /* argument list passed from the API call */ H5I_type_t id_type; herr_t ret_value = SUCCEED; @@ -1145,15 +1206,15 @@ H5VL_object_get(hid_t uid, H5VL_object_get_t get_type, ...) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a user ID") /* get the ID struct */ - if(NULL == (uid_info = (H5VL_id_wrapper_t *)H5I_object(uid))) + if(NULL == (id_wrapper = (H5VL_id_wrapper_t *)H5I_object(uid))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "invalid user identifier") - if(NULL == uid_info->vol_plugin->object_cls.get) + if(NULL == id_wrapper->vol_plugin->object_cls.get) HGOTO_ERROR(H5E_VOL, H5E_UNSUPPORTED, FAIL, "vol plugin has no `object get' method") va_start (arguments, get_type); - if((ret_value = (uid_info->vol_plugin->object_cls.get)(uid_info->obj_id, get_type, - arguments)) < 0) + if((ret_value = (id_wrapper->vol_plugin->object_cls.get)(id_wrapper->obj_id, get_type, + arguments)) < 0) HGOTO_ERROR(H5E_VOL, H5E_CANTGET, FAIL, "get failed") va_end (arguments); done: @@ -1179,33 +1240,33 @@ herr_t H5VL_datatype_commit(hid_t uid, const char *name, hid_t type_id, hid_t lcpl_id, hid_t tcpl_id, hid_t tapl_id) { - H5VL_id_wrapper_t *uid_info1; /* user id structure of the location where the datatype will be commitd */ + H5VL_id_wrapper_t *id_wrapper1; /* user id structure of the location where the datatype will be commitd */ herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_NOAPI(FAIL) /* get the ID struct */ - if(NULL == (uid_info1 = (H5VL_id_wrapper_t *)H5I_object(uid))) + if(NULL == (id_wrapper1 = (H5VL_id_wrapper_t *)H5I_object(uid))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "invalid user identifier") /* check if the corresponding VOL commit callback exists */ - if(NULL == uid_info1->vol_plugin->datatype_cls.commit) + if(NULL == id_wrapper1->vol_plugin->datatype_cls.commit) HGOTO_ERROR(H5E_VOL, H5E_UNSUPPORTED, FAIL, "vol plugin has no `datatype commit' method") /* call the corresponding VOL commit callback */ - if((ret_value = (uid_info1->vol_plugin->datatype_cls.commit) - (uid_info1->obj_id, name, type_id, lcpl_id, tcpl_id, tapl_id)) < 0) + if((ret_value = (id_wrapper1->vol_plugin->datatype_cls.commit) + (id_wrapper1->obj_id, name, type_id, lcpl_id, tcpl_id, tapl_id)) < 0) HGOTO_ERROR(H5E_VOL, H5E_CANTINIT, FAIL, "commit failed") #if 0 /* Create a new id that points to a struct that holds the datatype id and the VOL plugin */ /* Allocate new id structure */ - if(NULL == (uid_info2 = H5FL_MALLOC(H5VL_id_wrapper_t))) + if(NULL == (id_wrapper2 = (H5VL_id_wrapper_t *)H5MM_malloc(sizeof(H5VL_id_wrapper_t)))) HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, FAIL, "memory allocation failed") - uid_info2->obj_id = type_id; - uid_info2->vol_plugin = uid_info1->vol_plugin; + id_wrapper2->obj_id = type_id; + id_wrapper2->vol_plugin = id_wrapper1->vol_plugin; - if((ret_value = H5I_register(H5I_DATATYPE_PUBLIC, uid_info2, TRUE)) < 0) + if((ret_value = H5I_register(H5I_DATATYPE_PUBLIC, id_wrapper2, TRUE)) < 0) HGOTO_ERROR(H5E_ATOM, H5E_CANTREGISTER, FAIL, "unable to atomize datatype handle") #endif @@ -1230,38 +1291,48 @@ done: *------------------------------------------------------------------------- */ hid_t -H5VL_datatype_open(hid_t uid, const char *name, hid_t tapl_id) +H5VL_datatype_open(hid_t loc_id, const char *name, hid_t tapl_id) { - H5VL_id_wrapper_t *uid_info1; /* user id structure of the location where the datatype will be opend */ - H5VL_id_wrapper_t *uid_info2; /* user id structure of new opend datatype*/ + H5VL_id_wrapper_t *id_wrapper1; /* user id structure of the location where the datatype will be opend */ + H5VL_id_wrapper_t *id_wrapper2; /* user id structure of new opend datatype*/ hid_t datatype_id; /* actual datatype ID */ hid_t ret_value; /* Return value */ FUNC_ENTER_NOAPI(FAIL) /* get the ID struct */ - if(NULL == (uid_info1 = (H5VL_id_wrapper_t *)H5I_object(uid))) + if(NULL == (id_wrapper1 = (H5VL_id_wrapper_t *)H5I_object(loc_id))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "invalid user identifier") - /* check if the corresponding VOL open callback exists */ - if(NULL == uid_info1->vol_plugin->datatype_cls.open) - HGOTO_ERROR(H5E_VOL, H5E_UNSUPPORTED, FAIL, "vol plugin has no `datatype open' method") + /* check if the type specific corresponding VOL open callback exists */ + if(NULL == id_wrapper1->vol_plugin->datatype_cls.open) { + void *location = NULL; /* a pointer to VOL specific token that indicates + the location of the object */ - /* call the corresponding VOL open callback */ - if((datatype_id = (uid_info1->vol_plugin->datatype_cls.open) - (uid_info1->obj_id, name, tapl_id)) < 0) - HGOTO_ERROR(H5E_VOL, H5E_CANTINIT, FAIL, "open failed") - - /* Create a new id that points to a struct that holds the datatype id and the VOL plugin */ - /* Allocate new id structure */ - if(NULL == (uid_info2 = H5FL_MALLOC(H5VL_id_wrapper_t))) - HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, FAIL, "memory allocation failed") - uid_info2->obj_id = datatype_id; - uid_info2->vol_plugin = uid_info1->vol_plugin; - - if((ret_value = H5I_register(H5I_DATATYPE_PUBLIC, uid_info2, TRUE)) < 0) - HGOTO_ERROR(H5E_ATOM, H5E_CANTREGISTER, FAIL, "unable to atomize datatype handle") + /* Get the token for the Object location through the VOL */ + if(H5VL_object_lookup (loc_id, H5VL_OBJECT_LOOKUP_BY_NAME, &location, name, tapl_id) < 0) + HGOTO_ERROR(H5E_SYM, H5E_CANTINIT, FAIL, "unable to locate object") + /* Open the object through the VOL */ + if((ret_value = H5VL_object_open_by_loc(loc_id, location, tapl_id)) < 0) + HGOTO_ERROR(H5E_SYM, H5E_CANTINIT, FAIL, "unable to open object") + } + else { + /* call the corresponding VOL open callback */ + if((datatype_id = (id_wrapper1->vol_plugin->datatype_cls.open) + (id_wrapper1->obj_id, name, tapl_id)) < 0) + HGOTO_ERROR(H5E_VOL, H5E_CANTINIT, FAIL, "open failed") + + /* Create a new id that points to a struct that holds the datatype id and the VOL plugin */ + /* Allocate new id structure */ + if(NULL == (id_wrapper2 = (H5VL_id_wrapper_t *)H5MM_malloc(sizeof(H5VL_id_wrapper_t)))) + HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, FAIL, "memory allocation failed") + id_wrapper2->obj_id = datatype_id; + id_wrapper2->vol_plugin = id_wrapper1->vol_plugin; + + if((ret_value = H5I_register(H5I_DATATYPE_PUBLIC, id_wrapper2, TRUE)) < 0) + HGOTO_ERROR(H5E_ATOM, H5E_CANTREGISTER, FAIL, "unable to atomize datatype handle") + } done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5VL_datatype_open() */ @@ -1283,37 +1354,36 @@ done: *------------------------------------------------------------------------- */ hid_t -H5VL_dataset_create(hid_t uid, const char *name, hid_t dtype_id, hid_t space_id, - hid_t lcpl_id, hid_t dcpl_id, hid_t dapl_id) +H5VL_dataset_create(hid_t uid, const char *name, hid_t dcpl_id, hid_t dapl_id) { - H5VL_id_wrapper_t *uid_info1; /* user id structure of the location where the dataset will be created */ - H5VL_id_wrapper_t *uid_info2; /* user id structure of new created dataset*/ + H5VL_id_wrapper_t *id_wrapper1; /* user id structure of the location where the dataset will be created */ + H5VL_id_wrapper_t *id_wrapper2; /* user id structure of new created dataset*/ hid_t dataset_id; /* actual dataset ID */ hid_t ret_value; /* Return value */ FUNC_ENTER_NOAPI(FAIL) /* get the ID struct */ - if(NULL == (uid_info1 = (H5VL_id_wrapper_t *)H5I_object(uid))) + if(NULL == (id_wrapper1 = (H5VL_id_wrapper_t *)H5I_object(uid))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "invalid user identifier") /* check if the corresponding VOL create callback exists */ - if(NULL == uid_info1->vol_plugin->dataset_cls.create) + if(NULL == id_wrapper1->vol_plugin->dataset_cls.create) HGOTO_ERROR(H5E_VOL, H5E_UNSUPPORTED, FAIL, "vol plugin has no `dataset create' method") /* call the corresponding VOL create callback */ - if((dataset_id = (uid_info1->vol_plugin->dataset_cls.create) - (uid_info1->obj_id, name, dtype_id, space_id, lcpl_id, dcpl_id, dapl_id)) < 0) + if((dataset_id = (id_wrapper1->vol_plugin->dataset_cls.create) + (id_wrapper1->obj_id, name, dcpl_id, dapl_id)) < 0) HGOTO_ERROR(H5E_VOL, H5E_CANTINIT, FAIL, "create failed") /* Create a new id that points to a struct that holds the dataset id and the VOL plugin */ /* Allocate new id structure */ - if(NULL == (uid_info2 = H5FL_MALLOC(H5VL_id_wrapper_t))) + if(NULL == (id_wrapper2 = (H5VL_id_wrapper_t *)H5MM_malloc(sizeof(H5VL_id_wrapper_t)))) HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, FAIL, "memory allocation failed") - uid_info2->obj_id = dataset_id; - uid_info2->vol_plugin = uid_info1->vol_plugin; + id_wrapper2->obj_id = dataset_id; + id_wrapper2->vol_plugin = id_wrapper1->vol_plugin; - if((ret_value = H5I_register(H5I_DATASET_PUBLIC, uid_info2, TRUE)) < 0) + if((ret_value = H5I_register(H5I_DATASET_PUBLIC, id_wrapper2, TRUE)) < 0) HGOTO_ERROR(H5E_ATOM, H5E_CANTREGISTER, FAIL, "unable to atomize dataset handle") done: @@ -1337,37 +1407,48 @@ done: *------------------------------------------------------------------------- */ hid_t -H5VL_dataset_open(hid_t uid, const char *name, hid_t dapl_id) +H5VL_dataset_open(hid_t loc_id, const char *name, hid_t dapl_id) { - H5VL_id_wrapper_t *uid_info1; /* user id structure of the location where the dataset will be opend */ - H5VL_id_wrapper_t *uid_info2; /* user id structure of new opend dataset*/ + H5VL_id_wrapper_t *id_wrapper1; /* user id structure of the location where the dataset will be opend */ + H5VL_id_wrapper_t *id_wrapper2; /* user id structure of new opend dataset*/ hid_t dataset_id; /* actual dataset ID */ hid_t ret_value; /* Return value */ FUNC_ENTER_NOAPI(FAIL) /* get the ID struct */ - if(NULL == (uid_info1 = (H5VL_id_wrapper_t *)H5I_object(uid))) + if(NULL == (id_wrapper1 = (H5VL_id_wrapper_t *)H5I_object(loc_id))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "invalid user identifier") - /* check if the corresponding VOL open callback exists */ - if(NULL == uid_info1->vol_plugin->dataset_cls.open) - HGOTO_ERROR(H5E_VOL, H5E_UNSUPPORTED, FAIL, "vol plugin has no `dataset open' method") - /* call the corresponding VOL open callback */ - if((dataset_id = (uid_info1->vol_plugin->dataset_cls.open) - (uid_info1->obj_id, name, dapl_id)) < 0) - HGOTO_ERROR(H5E_VOL, H5E_CANTINIT, FAIL, "open failed") - - /* Create a new id that points to a struct that holds the dataset id and the VOL plugin */ - /* Allocate new id structure */ - if(NULL == (uid_info2 = H5FL_MALLOC(H5VL_id_wrapper_t))) - HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, FAIL, "memory allocation failed") - uid_info2->obj_id = dataset_id; - uid_info2->vol_plugin = uid_info1->vol_plugin; + /* check if the type specific corresponding VOL open callback exists */ + if(NULL == id_wrapper1->vol_plugin->dataset_cls.open) { + void *location = NULL; /* a pointer to VOL specific token that indicates + the location of the object */ - if((ret_value = H5I_register(H5I_DATASET_PUBLIC, uid_info2, TRUE)) < 0) - HGOTO_ERROR(H5E_ATOM, H5E_CANTREGISTER, FAIL, "unable to atomize dataset handle") + /* Get the token for the Object location through the VOL */ + if(H5VL_object_lookup (loc_id, H5VL_OBJECT_LOOKUP_BY_NAME, &location, name, dapl_id) < 0) + HGOTO_ERROR(H5E_SYM, H5E_CANTINIT, FAIL, "unable to locate object") + /* Open the object through the VOL */ + if((ret_value = H5VL_object_open_by_loc(loc_id, location, dapl_id)) < 0) + HGOTO_ERROR(H5E_SYM, H5E_CANTINIT, FAIL, "unable to open object") + } + else { + /* call the corresponding VOL open callback */ + if((dataset_id = (id_wrapper1->vol_plugin->dataset_cls.open) + (id_wrapper1->obj_id, name, dapl_id)) < 0) + HGOTO_ERROR(H5E_VOL, H5E_CANTINIT, FAIL, "open failed") + + /* Create a new id that points to a struct that holds the dataset id and the VOL plugin */ + /* Allocate new id structure */ + if(NULL == (id_wrapper2 = (H5VL_id_wrapper_t *)H5MM_malloc(sizeof(H5VL_id_wrapper_t)))) + HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, FAIL, "memory allocation failed") + id_wrapper2->obj_id = dataset_id; + id_wrapper2->vol_plugin = id_wrapper1->vol_plugin; + + if((ret_value = H5I_register(H5I_DATASET_PUBLIC, id_wrapper2, TRUE)) < 0) + HGOTO_ERROR(H5E_ATOM, H5E_CANTREGISTER, FAIL, "unable to atomize dataset handle") + } done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5VL_dataset_open() */ @@ -1390,7 +1471,7 @@ done: herr_t H5VL_dataset_close(hid_t uid) { - H5VL_id_wrapper_t *uid_info; /* user id structure */ + H5VL_id_wrapper_t *id_wrapper; /* user id structure */ herr_t ret_value = SUCCEED; FUNC_ENTER_NOAPI(FAIL) @@ -1400,17 +1481,23 @@ H5VL_dataset_close(hid_t uid) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a user ID") /* get the ID struct */ - if(NULL == (uid_info = (H5VL_id_wrapper_t *)H5I_object(uid))) + if(NULL == (id_wrapper = (H5VL_id_wrapper_t *)H5I_object(uid))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "invalid user identifier") + + /* if the VOL class does not implement a specific dataset close + callback, try the generic object close */ + if(NULL == id_wrapper->vol_plugin->dataset_cls.close){ + if(H5VL_object_close(uid) < 0) + HGOTO_ERROR(H5E_SYM, H5E_CANTRELEASE, FAIL, "unable to close object") + } + else { + if((ret_value = (id_wrapper->vol_plugin->dataset_cls.close)(id_wrapper->obj_id)) < 0) + HGOTO_ERROR(H5E_VOL, H5E_CANTRELEASE, FAIL, "close failed") - if(NULL == uid_info->vol_plugin->dataset_cls.close) - HGOTO_ERROR(H5E_VOL, H5E_UNSUPPORTED, FAIL, "vol plugin has no `dataset close' method") - if((ret_value = (uid_info->vol_plugin->dataset_cls.close)(uid_info->obj_id)) < 0) - HGOTO_ERROR(H5E_VOL, H5E_CANTRELEASE, FAIL, "close failed") - - if(H5I_dec_app_ref(uid) < 0) - HGOTO_ERROR(H5E_VOL, H5E_CANTDEC, FAIL, "unable to decrement ref count on user ID") - + id_wrapper->vol_plugin->nrefs--; + if(H5I_dec_app_ref(uid) < 0) + HGOTO_ERROR(H5E_VOL, H5E_CANTDEC, FAIL, "unable to decrement ref count on user ID") + } done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5VL_dataset_close() */ @@ -1433,7 +1520,7 @@ done: herr_t H5VL_dataset_read(hid_t uid, hid_t mem_type_id, hid_t mem_space_id, hid_t file_space_id, hid_t plist_id, void *buf) { - H5VL_id_wrapper_t *uid_info; /* user id structure */ + H5VL_id_wrapper_t *id_wrapper; /* user id structure */ herr_t ret_value = SUCCEED; FUNC_ENTER_NOAPI(FAIL) @@ -1443,13 +1530,13 @@ herr_t H5VL_dataset_read(hid_t uid, hid_t mem_type_id, hid_t mem_space_id, HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a user ID") /* get the ID struct */ - if(NULL == (uid_info = (H5VL_id_wrapper_t *)H5I_object(uid))) + if(NULL == (id_wrapper = (H5VL_id_wrapper_t *)H5I_object(uid))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "invalid user identifier") - if(NULL == uid_info->vol_plugin->dataset_cls.read) + if(NULL == id_wrapper->vol_plugin->dataset_cls.read) HGOTO_ERROR(H5E_VOL, H5E_UNSUPPORTED, FAIL, "vol plugin has no `dataset read' method") - if((ret_value = (uid_info->vol_plugin->dataset_cls.read) - (uid_info->obj_id, mem_type_id, mem_space_id, file_space_id, plist_id, buf)) < 0) + if((ret_value = (id_wrapper->vol_plugin->dataset_cls.read) + (id_wrapper->obj_id, mem_type_id, mem_space_id, file_space_id, plist_id, buf)) < 0) HGOTO_ERROR(H5E_VOL, H5E_CANTRELEASE, FAIL, "read failed") done: @@ -1474,7 +1561,7 @@ done: herr_t H5VL_dataset_write(hid_t uid, hid_t mem_type_id, hid_t mem_space_id, hid_t file_space_id, hid_t plist_id, const void *buf) { - H5VL_id_wrapper_t *uid_info; /* user id structure */ + H5VL_id_wrapper_t *id_wrapper; /* user id structure */ herr_t ret_value = SUCCEED; FUNC_ENTER_NOAPI(FAIL) @@ -1484,13 +1571,13 @@ herr_t H5VL_dataset_write(hid_t uid, hid_t mem_type_id, hid_t mem_space_id, HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a user ID") /* get the ID struct */ - if(NULL == (uid_info = (H5VL_id_wrapper_t *)H5I_object(uid))) + if(NULL == (id_wrapper = (H5VL_id_wrapper_t *)H5I_object(uid))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "invalid user identifier") - if(NULL == uid_info->vol_plugin->dataset_cls.write) + if(NULL == id_wrapper->vol_plugin->dataset_cls.write) HGOTO_ERROR(H5E_VOL, H5E_UNSUPPORTED, FAIL, "vol plugin has no `dataset write' method") - if((ret_value = (uid_info->vol_plugin->dataset_cls.write) - (uid_info->obj_id, mem_type_id, mem_space_id, file_space_id, plist_id, buf)) < 0) + if((ret_value = (id_wrapper->vol_plugin->dataset_cls.write) + (id_wrapper->obj_id, mem_type_id, mem_space_id, file_space_id, plist_id, buf)) < 0) HGOTO_ERROR(H5E_VOL, H5E_CANTRELEASE, FAIL, "write failed") done: @@ -1514,7 +1601,7 @@ done: */ herr_t H5VL_dataset_set_extent(hid_t uid, const hsize_t size[]) { - H5VL_id_wrapper_t *uid_info; /* user id structure */ + H5VL_id_wrapper_t *id_wrapper; /* user id structure */ herr_t ret_value = SUCCEED; FUNC_ENTER_NOAPI(FAIL) @@ -1524,12 +1611,12 @@ herr_t H5VL_dataset_set_extent(hid_t uid, const hsize_t size[]) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a dataset ID") /* get the ID struct */ - if(NULL == (uid_info = (H5VL_id_wrapper_t *)H5I_object(uid))) + if(NULL == (id_wrapper = (H5VL_id_wrapper_t *)H5I_object(uid))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "invalid user identifier") - if(NULL == uid_info->vol_plugin->dataset_cls.set_extent) + if(NULL == id_wrapper->vol_plugin->dataset_cls.set_extent) HGOTO_ERROR(H5E_VOL, H5E_UNSUPPORTED, FAIL, "vol plugin has no `dataset set_extent' method") - if((ret_value = (uid_info->vol_plugin->dataset_cls.set_extent)(uid_info->obj_id, size)) < 0) + if((ret_value = (id_wrapper->vol_plugin->dataset_cls.set_extent)(id_wrapper->obj_id, size)) < 0) HGOTO_ERROR(H5E_VOL, H5E_CANTINIT, FAIL, "set_extent failed") done: @@ -1554,7 +1641,7 @@ done: herr_t H5VL_dataset_get(hid_t uid, H5VL_dataset_get_t get_type, ...) { - H5VL_id_wrapper_t *uid_info; /* user id structure */ + H5VL_id_wrapper_t *id_wrapper; /* user id structure */ va_list arguments; /* argument list passed from the API call */ herr_t ret_value = SUCCEED; @@ -1565,17 +1652,160 @@ H5VL_dataset_get(hid_t uid, H5VL_dataset_get_t get_type, ...) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a user ID") /* get the ID struct */ - if(NULL == (uid_info = (H5VL_id_wrapper_t *)H5I_object(uid))) + if(NULL == (id_wrapper = (H5VL_id_wrapper_t *)H5I_object(uid))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "invalid user identifier") - if(NULL == uid_info->vol_plugin->dataset_cls.get) + if(NULL == id_wrapper->vol_plugin->dataset_cls.get) HGOTO_ERROR(H5E_VOL, H5E_UNSUPPORTED, FAIL, "vol plugin has no `dataset get' method") va_start (arguments, get_type); - if((ret_value = (uid_info->vol_plugin->dataset_cls.get)(uid_info->obj_id, get_type, + if((ret_value = (id_wrapper->vol_plugin->dataset_cls.get)(id_wrapper->obj_id, get_type, arguments)) < 0) HGOTO_ERROR(H5E_VOL, H5E_CANTGET, FAIL, "get failed") va_end (arguments); done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5VL_dataset_get() */ + + +/*------------------------------------------------------------------------- + * Function: H5VL_link_create + * + * Purpose: Creates a hard link through the VOL + * + * Return: Non-negative on success/Negative on failure + * + * Programmer: Mohamad Chaarawi + * April, 2012 + * + *------------------------------------------------------------------------- + */ +herr_t +H5VL_link_create(H5VL_link_create_type_t create_type, hid_t loc_id, const char *new_name, + hid_t lcpl_id, hid_t lapl_id) +{ + H5VL_class_t *vol_plugin = NULL; /* VOL plugin */ + hid_t new_id; /* unwrapped IDs */ + herr_t ret_value = SUCCEED; /* Return value */ + + FUNC_ENTER_NOAPI(FAIL) + + /* unwrap the higher level user ids. */ + if(H5L_SAME_LOC != loc_id) { + H5VL_id_wrapper_t *id_wrapper; + + /* get the ID struct */ + if(NULL == (id_wrapper = (H5VL_id_wrapper_t *)H5I_object(loc_id))) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "invalid user identifier") + + /* set the vol plugin sturcture if it hasn't been done yet */ + if (NULL == vol_plugin) + vol_plugin = id_wrapper->vol_plugin; + + new_id = id_wrapper->obj_id; + } + else { + new_id = loc_id; + } + + /* unwrap the high level ID if the creation call is H5Lcreate_hard */ + if(H5VL_CREATE_HARD_LINK == create_type) { + H5P_genplist_t *plist; /* Property list pointer */ + hid_t cur_id; + + /* Get the plist structure */ + if(NULL == (plist = (H5P_genplist_t *)H5I_object(lcpl_id))) + HGOTO_ERROR(H5E_ATOM, H5E_BADATOM, FAIL, "can't find object for ID") + + if(H5P_get(plist, H5L_CRT_TARGET_ID_NAME, &cur_id) < 0) + HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, FAIL, "can't get property value for current location id") + + /* Only one of the IDs can be H5L_SAME_LOC, and the other one must + be of the wrapper type. Get the VOL plugin struct in case the + link id is H5L_SAME_LOC*/ + if (H5L_SAME_LOC != cur_id) { + H5VL_id_wrapper_t *id_wrapper; + + /* get the ID struct */ + if(NULL == (id_wrapper = (H5VL_id_wrapper_t *)H5I_object(cur_id))) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "invalid user identifier") + + vol_plugin = id_wrapper->vol_plugin; + if(H5P_set(plist, H5L_CRT_TARGET_ID_NAME, &(id_wrapper->obj_id)) < 0) + HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, FAIL, "can't get property value for current location id") + } + } + + /* check if the corresponding VOL create callback exists */ + if(NULL == vol_plugin->link_cls.create) + HGOTO_ERROR(H5E_VOL, H5E_UNSUPPORTED, FAIL, "vol plugin has no `link create' method") + + /* call the corresponding VOL create callback */ + if((ret_value = (vol_plugin->link_cls.create) + (create_type, new_id, new_name, lcpl_id, lapl_id)) < 0) + HGOTO_ERROR(H5E_VOL, H5E_CANTINIT, FAIL, "link create failed") + +done: + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5VL_link_create() */ + + +/*------------------------------------------------------------------------- + * Function: H5VL_link_create + * + * Purpose: Copy or move a link from src to dst. + * + * Return: Non-negative on success/Negative on failure + * + * Programmer: Mohamad Chaarawi + * April, 2012 + * + *------------------------------------------------------------------------- + */ +H5_DLL herr_t H5VL_link_move(hid_t src_loc_id, const char *src_name, hid_t dst_loc_id, + const char *dst_name, hbool_t copy_flag, hid_t lcpl_id, hid_t lapl_id) +{ + H5VL_class_t *vol_plugin = NULL; /* VOL plugin */ + H5VL_id_wrapper_t *id_wrapper; + hid_t new_src_id, new_dst_id; /* unwrapped IDs */ + herr_t ret_value = SUCCEED; /* Return value */ + + FUNC_ENTER_NOAPI(FAIL) + + /* unwrap the higher level user ids. */ + if(H5L_SAME_LOC != src_loc_id) { + /* get the ID struct */ + if(NULL == (id_wrapper = (H5VL_id_wrapper_t *)H5I_object(src_loc_id))) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "invalid user identifier") + + vol_plugin = id_wrapper->vol_plugin; + new_src_id = id_wrapper->obj_id; + } + else { + new_src_id = src_loc_id; + } + + if(H5L_SAME_LOC != dst_loc_id) { + /* get the ID struct */ + if(NULL == (id_wrapper = (H5VL_id_wrapper_t *)H5I_object(dst_loc_id))) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "invalid user identifier") + if(NULL == vol_plugin) + vol_plugin = id_wrapper->vol_plugin; + new_dst_id = id_wrapper->obj_id; + } + else { + new_dst_id = dst_loc_id; + } + + /* check if the corresponding VOL move callback exists */ + if(NULL == vol_plugin->link_cls.move) + HGOTO_ERROR(H5E_VOL, H5E_UNSUPPORTED, FAIL, "vol plugin has no `link move' method") + + /* call the corresponding VOL move callback */ + if((ret_value = (vol_plugin->link_cls.move) + (new_src_id, src_name, new_dst_id, dst_name, copy_flag, lcpl_id, lapl_id)) < 0) + HGOTO_ERROR(H5E_VOL, H5E_CANTINIT, FAIL, "link move failed") + +done: + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5VL_link_move() */ diff --git a/src/H5VLdummy.c b/src/H5VLdummy.c index 334345a..8f4131a 100644 --- a/src/H5VLdummy.c +++ b/src/H5VLdummy.c @@ -101,7 +101,7 @@ H5VL_class_t H5VL_dummy_g = { NULL, /* create */ NULL, /* delete */ NULL, /* move */ - NULL /* copy */ + NULL }, { /* object_cls */ NULL, diff --git a/src/H5VLnative.c b/src/H5VLnative.c index 91f1efa..808bc4d 100644 --- a/src/H5VLnative.c +++ b/src/H5VLnative.c @@ -24,6 +24,7 @@ #define H5D_PACKAGE /*suppress error about including H5Dpkg */ #define H5F_PACKAGE /*suppress error about including H5Fpkg */ #define H5G_PACKAGE /*suppress error about including H5Gpkg */ +#define H5L_PACKAGE /*suppress error about including H5Lpkg */ #define H5O_PACKAGE /*suppress error about including H5Opkg */ #define H5T_PACKAGE /*suppress error about including H5Tpkg */ @@ -38,9 +39,11 @@ #include "H5Eprivate.h" /* Error handling */ #include "H5Fprivate.h" /* File access */ #include "H5Fpkg.h" /* File pkg */ -#include "H5FLprivate.h" /* Free lists */ #include "H5Gpkg.h" /* Groups */ +#include "H5HGprivate.h" /* Global Heaps */ #include "H5Iprivate.h" /* IDs */ +#include "H5Lprivate.h" /* links */ +#include "H5Lpkg.h" /* links headers */ #include "H5MFprivate.h" /* File memory management */ #include "H5MMprivate.h" /* Memory management */ #include "H5Opkg.h" /* Object headers */ @@ -63,8 +66,7 @@ static herr_t H5VL_native_file_flush(hid_t fid, H5F_scope_t scope); static herr_t H5VL_native_file_get(hid_t file_id, H5VL_file_get_t get_type, va_list arguments); static herr_t H5VL_native_file_close(hid_t fid); -static hid_t H5VL_native_dataset_create(hid_t loc_id, const char *name, hid_t type_id, hid_t space_id, - hid_t lcpl_id, hid_t dcpl_id, hid_t dapl_id); +static hid_t H5VL_native_dataset_create(hid_t loc_id, const char *name, hid_t dcpl_id, hid_t dapl_id); static hid_t H5VL_native_dataset_open(hid_t loc_id, const char *name, hid_t dapl_id); static herr_t H5VL_native_dataset_read(hid_t dset_id, hid_t mem_type_id, hid_t mem_space_id, hid_t file_space_id, hid_t plist_id, void *buf); @@ -78,12 +80,16 @@ static herr_t H5VL_native_datatype_commit(hid_t loc_id, const char *name, hid_t hid_t lcpl_id, hid_t tcpl_id, hid_t tapl_id); static hid_t H5VL_native_datatype_open(hid_t loc_id, const char *name, hid_t tapl_id); -static hid_t H5VL_native_group_create(hid_t loc_id, const char *name, hid_t lcpl_id, - hid_t gcpl_id, hid_t gapl_id); +static hid_t H5VL_native_group_create(hid_t loc_id, const char *name, hid_t gcpl_id, hid_t gapl_id); static hid_t H5VL_native_group_open(hid_t loc_id, const char *name, hid_t gapl_id); static herr_t H5VL_native_group_get(hid_t obj_id, H5VL_group_get_t get_type, va_list arguments); static herr_t H5VL_native_group_close(hid_t group_id); +static herr_t H5VL_native_link_create(H5VL_link_create_type_t create_type, hid_t loc_id, + const char *link_name, hid_t lcpl_id, hid_t lapl_id); +static herr_t H5VL_native_link_move(hid_t src_loc_id, const char *src_name, hid_t dst_loc_id, + const char *dst_name, hbool_t copy_flag, hid_t lcpl_id, hid_t lapl_id); + static hid_t H5VL_native_object_open(hid_t loc_id, void *location, hid_t lapl_id); static herr_t H5VL_native_object_get(hid_t id, H5VL_object_get_t get_type, va_list arguments); static herr_t H5VL_native_object_lookup(hid_t loc_id, H5VL_object_lookup_t lookup_type, va_list arguments); @@ -128,10 +134,10 @@ H5VL_class_t H5VL_native_g = { H5VL_native_file_close /* close */ }, { /* link_cls */ - NULL, /* create */ - NULL, /* delete */ - NULL, /* move */ - NULL /* copy */ + H5VL_native_link_create, /* create */ + H5VL_native_link_move, /* move */ + NULL, /* get */ + NULL /* delete */ }, { /* object_cls */ H5VL_native_object_open, /* open */ @@ -748,14 +754,24 @@ done: *------------------------------------------------------------------------- */ static hid_t -H5VL_native_group_create(hid_t loc_id, const char *name, hid_t lcpl_id, hid_t gcpl_id, hid_t gapl_id) +H5VL_native_group_create(hid_t loc_id, const char *name, hid_t gcpl_id, hid_t gapl_id) { - H5G_loc_t loc; /* Location to create group */ + H5P_genplist_t *plist; /* Property list pointer */ + H5G_loc_t loc; /* Location to create group */ H5G_t *grp = NULL; /* New group created */ - hid_t ret_value; + hid_t lcpl_id; + hid_t ret_value; FUNC_ENTER_NOAPI_NOINIT + /* Get the plist structure */ + if(NULL == (plist = (H5P_genplist_t *)H5I_object(gcpl_id))) + HGOTO_ERROR(H5E_ATOM, H5E_BADATOM, FAIL, "can't find object for ID") + + /* get creation properties */ + if(H5P_get(plist, H5G_CRT_LCPL_ID_NAME, &lcpl_id) < 0) + HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, FAIL, "can't get property value for lcpl id") + if(H5G_loc(loc_id, &loc) < 0) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a location") @@ -1197,14 +1213,65 @@ H5VL_native_object_lookup(hid_t loc_id, H5VL_object_lookup_t lookup_type, va_lis obj_addr = va_arg (arguments, haddr_t); break; } + case H5VL_OBJECT_LOOKUP_BY_REF: + { + H5R_type_t ref_type = va_arg (arguments, H5R_type_t); + void *_ref = va_arg (arguments, void *); + H5F_t *file = NULL; /* File object */ + + /* Get the file pointer from the entry */ + file = loc.oloc->file; + + HDassert(_ref); + HDassert(ref_type > H5R_BADTYPE || ref_type < H5R_MAXTYPE); + HDassert(file); + + switch(ref_type) { + case H5R_OBJECT: + obj_addr = *(const hobj_ref_t *)_ref; /* Only object references currently supported */ + break; + + case H5R_DATASET_REGION: + { + H5HG_t hobjid; /* Heap object ID */ + uint8_t *buf; /* Buffer to store serialized selection in */ + const uint8_t *p; /* Pointer to OID to store */ + + /* Get the heap ID for the dataset region */ + p = (const uint8_t *)_ref; + H5F_addr_decode(file, &p, &(hobjid.addr)); + INT32DECODE(p, hobjid.idx); + + /* Get the dataset region from the heap (allocate inside routine) */ + if(NULL == (buf = (uint8_t *)H5HG_read(file, H5AC_dxpl_id, + &hobjid, NULL, NULL))) + HGOTO_ERROR(H5E_REFERENCE, H5E_READERROR, FAIL, "Unable to read dataset region information") + + /* Get the object oid for the dataset */ + p = buf; + H5F_addr_decode(file, &p, &(obj_addr)); + + /* Free the buffer allocated in H5HG_read() */ + H5MM_xfree(buf); + } /* end case */ + break; + + case H5R_BADTYPE: + case H5R_MAXTYPE: + default: + HDassert("unknown reference type" && 0); + HGOTO_ERROR(H5E_REFERENCE, H5E_UNSUPPORTED, FAIL, "internal error (unknown reference type)") + } /* end switch */ + break; + } default: HGOTO_ERROR(H5E_VOL, H5E_CANTGET, FAIL, "can't lookup this object") - } + } /* end switch */ *location[0] = obj_addr; done: /* Release the object location if we failed after copying it */ - if(ret_value == FAIL && loc_found) + if(loc_found) if(H5G_loc_free(&obj_loc) < 0) HDONE_ERROR(H5E_SYM, H5E_CANTRELEASE, FAIL, "can't free location") @@ -1336,16 +1403,29 @@ done: *------------------------------------------------------------------------- */ static hid_t -H5VL_native_dataset_create(hid_t loc_id, const char *name, hid_t type_id, hid_t space_id, - hid_t lcpl_id, hid_t dcpl_id, hid_t dapl_id) +H5VL_native_dataset_create(hid_t loc_id, const char *name, hid_t dcpl_id, hid_t dapl_id) { + H5P_genplist_t *plist; /* Property list pointer */ H5G_loc_t loc; /* Object location to insert dataset into */ + hid_t type_id, space_id, lcpl_id; H5D_t *dset = NULL; /* New dataset's info */ const H5S_t *space; /* Dataspace for dataset */ - hid_t ret_value; + hid_t ret_value; FUNC_ENTER_NOAPI_NOINIT + /* Get the plist structure */ + if(NULL == (plist = (H5P_genplist_t *)H5I_object(dcpl_id))) + HGOTO_ERROR(H5E_ATOM, H5E_BADATOM, FAIL, "can't find object for ID") + + /* get creation properties */ + if(H5P_get(plist, H5D_CRT_TYPE_ID_NAME, &type_id) < 0) + HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, FAIL, "can't get property value for datatype id") + if(H5P_get(plist, H5D_CRT_SPACE_ID_NAME, &space_id) < 0) + HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, FAIL, "can't get property value for space id") + if(H5P_get(plist, H5D_CRT_LCPL_ID_NAME, &lcpl_id) < 0) + HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, FAIL, "can't get property value for lcpl id") + /* Check arguments */ if(H5G_loc(loc_id, &loc) < 0) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a location ID") @@ -1355,7 +1435,7 @@ H5VL_native_dataset_create(hid_t loc_id, const char *name, hid_t type_id, hid_t HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a dataspace ID") /* H5Dcreate_anon */ - if (NULL == name && lcpl_id == 0) { + 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, FAIL, "unable to create dataset") @@ -1374,7 +1454,7 @@ H5VL_native_dataset_create(hid_t loc_id, const char *name, hid_t type_id, hid_t HGOTO_ERROR(H5E_DATASET, H5E_CANTREGISTER, FAIL, "unable to register dataset") } done: - if(NULL == name && lcpl_id == 0) { + if(NULL == name) { /* Release the dataset's object header, if it was created */ if(dset) { H5O_loc_t *oloc; /* Object location for dataset */ @@ -1775,3 +1855,205 @@ H5VL_native_dataset_get(hid_t id, H5VL_dataset_get_t get_type, va_list arguments done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5VL_native_dataset_get() */ + + +/*------------------------------------------------------------------------- + * Function: H5VL_native_link_create + * + * Purpose: Creates an hard link from NEW_NAME to CUR_NAME. + * + * Return: Non-negative on success/Negative on failure + * + * Programmer: Mohamad Chaarawi + * April, 2012 + * + *------------------------------------------------------------------------- + */ +static herr_t +H5VL_native_link_create(H5VL_link_create_type_t create_type, hid_t loc_id, const char *link_name, + hid_t lcpl_id, hid_t lapl_id) +{ + + H5P_genplist_t *plist; /* Property list pointer */ + herr_t ret_value = SUCCEED; /* Return value */ + + FUNC_ENTER_NOAPI_NOINIT + + /* Get the plist structure */ + if(NULL == (plist = (H5P_genplist_t *)H5I_object(lcpl_id))) + HGOTO_ERROR(H5E_ATOM, H5E_BADATOM, FAIL, "can't find object for ID"); + + switch (create_type) { + case H5VL_CREATE_HARD_LINK: + { + H5G_loc_t cur_loc, *cur_loc_p; + H5G_loc_t new_loc, *new_loc_p; + hid_t cur_loc_id; + char *cur_name; + + if(H5P_get(plist, H5L_CRT_TARGET_ID_NAME, &cur_loc_id) < 0) + HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, FAIL, "can't get property value for current location id") + if(H5P_get(plist, H5L_CRT_TARGET_NAME_NAME, &cur_name) < 0) + HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, FAIL, "can't get property value for current name") + + if(cur_loc_id != H5L_SAME_LOC && H5G_loc(cur_loc_id, &cur_loc) < 0) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a location") + if(loc_id != H5L_SAME_LOC && H5G_loc(loc_id, &new_loc) < 0) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a location") + + /* Set up current & new location pointers */ + cur_loc_p = &cur_loc; + new_loc_p = &new_loc; + if(cur_loc_id == H5L_SAME_LOC) + cur_loc_p = new_loc_p; + else if(loc_id == H5L_SAME_LOC) + new_loc_p = cur_loc_p; + else if(cur_loc_p->oloc->file != new_loc_p->oloc->file) + HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "source and destination should be in the same file.") + + /* Create the link */ + if((ret_value = H5L_create_hard(cur_loc_p, cur_name, new_loc_p, link_name, + lcpl_id, lapl_id, H5AC_dxpl_id)) < 0) + HGOTO_ERROR(H5E_LINK, H5E_CANTINIT, FAIL, "unable to create link") + break; + } + case H5VL_CREATE_SOFT_LINK: + { + char *target_name; + H5G_loc_t link_loc; /* Group location for new link */ + + if(H5G_loc(loc_id, &link_loc) < 0) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a location") + + if(H5P_get(plist, H5L_CRT_TARGET_NAME_NAME, &target_name) < 0) + HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, FAIL, "can't get property value for targe name") + + /* Create the link */ + if((ret_value = H5L_create_soft(target_name, &link_loc, link_name, + lcpl_id, lapl_id, H5AC_dxpl_id)) < 0) + HGOTO_ERROR(H5E_LINK, H5E_CANTINIT, FAIL, "unable to create link") + break; + } + case H5VL_CREATE_UD_LINK: + { + H5G_loc_t link_loc; /* Group location for new link */ + H5L_type_t link_type; + void *udata; + size_t udata_size; + + if(H5G_loc(loc_id, &link_loc) < 0) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a location") + + if(H5P_get(plist, H5L_CRT_LINK_TYPE_NAME, &link_type) < 0) + HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, FAIL, "can't get property value for link type") + if(H5P_get(plist, H5L_CRT_UDATA_NAME, &udata) < 0) + HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, FAIL, "can't get property value for udata") + if(H5P_get(plist, H5L_CRT_UDATA_SIZE_NAME, &udata_size) < 0) + HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, FAIL, "can't get property value for udata size") + + /* Create link */ + if(H5L_create_ud(&link_loc, link_name, udata, udata_size, link_type, lcpl_id, lapl_id, H5AC_dxpl_id) < 0) + HGOTO_ERROR(H5E_LINK, H5E_CANTINIT, FAIL, "unable to create link") + break; + } + default: + HGOTO_ERROR(H5E_LINK, H5E_CANTINIT, FAIL, "invalid link creation call") + } +done: + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5VL_native_link_create() */ + + +/*------------------------------------------------------------------------- + * Function: H5VL_native_link_move + * + * Purpose: Renames an object within an HDF5 file and moves it to a new + * group. The original name SRC is unlinked from the group graph + * and then inserted with the new name DST (which can specify a + * new path for the object) as an atomic operation. The names + * are interpreted relative to SRC_LOC_ID and + * DST_LOC_ID, which are either file IDs or group ID. + * + * Return: Non-negative on success/Negative on failure + * + * Programmer: Mohamad Chaarawi + * April, 2012 + * + *------------------------------------------------------------------------- + */ +static herr_t +H5VL_native_link_move(hid_t src_loc_id, const char *src_name, hid_t dst_loc_id, + const char *dst_name, hbool_t copy_flag, hid_t lcpl_id, hid_t lapl_id) +{ + H5G_loc_t src_loc, *src_loc_p; + H5G_loc_t dst_loc, *dst_loc_p; + herr_t ret_value = SUCCEED; /* Return value */ + + FUNC_ENTER_NOAPI_NOINIT + + if(src_loc_id != H5L_SAME_LOC && H5G_loc(src_loc_id, &src_loc) < 0) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a location") + if(dst_loc_id != H5L_SAME_LOC && H5G_loc(dst_loc_id, &dst_loc) < 0) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a location") + + /* Set up src & dst location pointers */ + src_loc_p = &src_loc; + dst_loc_p = &dst_loc; + if(src_loc_id == H5L_SAME_LOC) + src_loc_p = dst_loc_p; + else if(dst_loc_id == H5L_SAME_LOC) + dst_loc_p = src_loc_p; + + /* Move/Copy the link */ + if(H5L_move(src_loc_p, src_name, dst_loc_p, dst_name, copy_flag, lcpl_id, + lapl_id, H5AC_dxpl_id) < 0) + HGOTO_ERROR(H5E_LINK, H5E_CANTMOVE, FAIL, "unable to move link") + +done: + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5VL_native_link_move() */ + +#if 0 + +/*------------------------------------------------------------------------- + * Function: H5VL_native_attr_create + * + * Purpose: Creates an attribute on an object. + * + * Return: Success: attr id. + * Failure: NULL + * + * Programmer: Mohamad Chaarawi + * March, 2012 + * + *------------------------------------------------------------------------- + */ +static hid_t +H5VL_native_attr_create(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) +{ + H5G_loc_t loc; /* Object location */ + H5T_t *type; /* Datatype to use for attribute */ + H5S_t *space; /* Dataspace to use for attribute */ + hid_t ret_value; + + FUNC_ENTER_NOAPI_NOINIT + + if(H5G_loc(loc_id, &loc) < 0) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a location") + if(0 == (H5F_INTENT(loc.oloc->file) & H5F_ACC_RDWR)) + HGOTO_ERROR(H5E_ARGS, H5E_WRITEERROR, FAIL, "no write intent on file") + if(NULL == (type = (H5T_t *)H5I_object_verify(type_id, H5I_DATATYPE))) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a type") + if(NULL == (space = (H5S_t *)H5I_object_verify(space_id, H5I_DATASPACE))) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a data space") + + /* 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") + +done: + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5VL_native_attr_create() */ + +#endif diff --git a/src/H5VLprivate.h b/src/H5VLprivate.h index f3bce81..f9e3145 100644 --- a/src/H5VLprivate.h +++ b/src/H5VLprivate.h @@ -61,7 +61,7 @@ H5_DLL herr_t H5VL_file_close(hid_t file_id); H5_DLL herr_t H5VL_file_flush(hid_t file_id, H5F_scope_t scope); H5_DLL herr_t H5VL_file_get(hid_t uid, H5VL_file_get_t get_type, ...); -H5_DLL hid_t H5VL_dataset_create(hid_t uid, const char *name, hid_t dtype_id, hid_t space_id, hid_t lcpl_id, hid_t dcpl_id, hid_t dapl_id); +H5_DLL hid_t H5VL_dataset_create(hid_t uid, const char *name, hid_t dcpl_id, hid_t dapl_id); H5_DLL hid_t H5VL_dataset_open(hid_t uid, const char *name, hid_t dapl_id); H5_DLL herr_t H5VL_dataset_close(hid_t uid); H5_DLL herr_t H5VL_dataset_read(hid_t dset_id, hid_t mem_type_id, hid_t mem_space_id, hid_t file_space_id, hid_t plist_id, void *buf); @@ -72,12 +72,17 @@ H5_DLL herr_t H5VL_dataset_get(hid_t uid, H5VL_dataset_get_t get_type, ...); H5_DLL herr_t H5VL_datatype_commit(hid_t loc_id, const char *name, hid_t type_id, hid_t lcpl_id, hid_t tcpl_id, hid_t tapl_id); H5_DLL hid_t H5VL_datatype_open(hid_t loc_id, const char *name, hid_t tapl_id); -H5_DLL hid_t H5VL_group_create(hid_t uid, const char *name, hid_t lcpl_id, hid_t gcpl_id, hid_t gapl_id); +H5_DLL hid_t H5VL_group_create(hid_t uid, const char *name, hid_t gcpl_id, hid_t gapl_id); H5_DLL hid_t H5VL_group_open(hid_t uid, const char *name, hid_t gapl_id); H5_DLL herr_t H5VL_group_close(hid_t uid); H5_DLL herr_t H5VL_group_get(hid_t uid, H5VL_group_get_t get_type, ...); -H5_DLL hid_t H5VL_object_open(hid_t uid, void *obj_loc, hid_t lapl_id); +H5_DLL herr_t H5VL_link_create(H5VL_link_create_type_t create_type, hid_t loc_id, + const char *link_name, hid_t lcpl_id, hid_t lapl_id); +H5_DLL herr_t H5VL_link_move(hid_t src_loc_id, const char *src_name, hid_t dst_loc_id, + const char *dst_name, hbool_t copy_flag, hid_t lcpl_id, hid_t lapl_id); + +H5_DLL hid_t H5VL_object_open_by_loc(hid_t uid, void *obj_loc, hid_t lapl_id); H5_DLL herr_t H5VL_object_close(hid_t uid); H5_DLL herr_t H5VL_object_get(hid_t uid, H5VL_object_get_t get_type, ...); H5_DLL herr_t H5VL_object_lookup(hid_t uid, H5VL_object_lookup_t lookup_type, ...); diff --git a/src/H5VLpublic.h b/src/H5VLpublic.h index 80ed8bc..11e8344 100644 --- a/src/H5VLpublic.h +++ b/src/H5VLpublic.h @@ -59,6 +59,13 @@ typedef enum H5VL_group_get_t { H5VL_GROUP_GET_INFO = 1 /*group info */ } H5VL_group_get_t; +/* types for all link get API routines */ +typedef enum H5VL_link_get_t { + H5VL_LINK_GET_INFO = 0, /*link info */ + H5VL_LINK_GET_NAME = 1, /*link name */ + H5VL_LINK_GET_VAL = 2 /*link value */ +} H5VL_link_get_t; + /* types for all object get API routines */ typedef enum H5VL_object_get_t { H5VL_OBJECT_GET_INFO = 0, /*object info */ @@ -70,9 +77,17 @@ typedef enum H5VL_object_lookup_t { H5VL_OBJECT_LOOKUP = 0, H5VL_OBJECT_LOOKUP_BY_NAME = 1, H5VL_OBJECT_LOOKUP_BY_IDX = 2, - H5VL_OBJECT_LOOKUP_BY_ADDR = 3 + H5VL_OBJECT_LOOKUP_BY_ADDR = 3, + H5VL_OBJECT_LOOKUP_BY_REF = 4 } H5VL_object_lookup_t; +/* types for all object lookup API routines */ +typedef enum H5VL_link_create_type_t { + H5VL_CREATE_HARD_LINK = 0, + H5VL_CREATE_SOFT_LINK = 1, + H5VL_CREATE_UD_LINK = 2 +} H5VL_link_create_type_t; + #define H5VL_VOL_DEFAULT 0 /* Default VOL plugin value */ /* H5F routines */ @@ -86,8 +101,7 @@ typedef struct H5VL_file_class_t { /* H5D routines */ typedef struct H5VL_dataset_class_t { - hid_t (*create)(hid_t loc_id, const char *name, hid_t dtype_id, hid_t space_id, - hid_t lcpl_id, hid_t dcpl_id, hid_t dapl_id); + hid_t (*create)(hid_t loc_id, const char *name, hid_t dcpl_id, hid_t dapl_id); hid_t (*open) (hid_t loc_id, const char *name, hid_t dapl_id); herr_t (*read) (hid_t dataset_id, hid_t mem_type_id, hid_t mem_space_id, hid_t file_space_id, hid_t xfer_plist_id, void * buf); @@ -100,8 +114,7 @@ typedef struct H5VL_dataset_class_t { /* H5A routines */ typedef struct H5VL_attribute_class_t { - hid_t (*create)( hid_t loc_id, const char *attr_name, hid_t type_id, hid_t space_id, - hid_t acpl_id, hid_t aapl_id); + hid_t (*create)( hid_t loc_id, const char *attr_name, hid_t acpl_id, hid_t aapl_id); hid_t (*open) (hid_t obj_id, const char *attr_name, hid_t aapl_id); herr_t (*read) (hid_t attr_id, hid_t mem_type_id, void *buf ); herr_t (*write) (hid_t attr_id, hid_t mem_type_id, const void *buf ); @@ -118,18 +131,17 @@ typedef struct H5VL_datatype_class_t { /* H5L routines */ typedef struct H5VL_link_class_t { - herr_t (*create) (hid_t obj_id, const char *name, hid_t loc_id, const char *link_name, - hid_t lcpl_id, hid_t lapl_id); - herr_t (*delete) (hid_t loc_id, const char *name, hid_t lapl_id); - herr_t (*move) (hid_t src_loc_id, const char *src_name, hid_t dst_loc_id, - const char *dest_name, hid_t lcpl, hid_t lapl); - herr_t (*copy) (hid_t src_loc_id, const char *src_name, hid_t dest_loc_id, - const char *dest_name, hid_t lcpl_id, hid_t lapl_id); + herr_t (*create)(H5VL_link_create_type_t create_type, hid_t link_loc_id, const char *link_name, + hid_t lcpl_id, hid_t lapl_id); + herr_t (*move) (hid_t src_loc_id, const char *src_name, hid_t dst_loc_id, + const char *dest_name, hbool_t copy_flag, hid_t lcpl, hid_t lapl); + herr_t (*get) (hid_t loc_id, H5VL_link_get_t get_type, va_list arguments); + herr_t (*delete)(hid_t loc_id, const char *name, hid_t lapl_id); } H5VL_link_class_t; /* H5G routines */ typedef struct H5VL_group_class_t { - hid_t (*create)(hid_t loc_id, const char *name, hid_t lcpl_id, hid_t gcpl_id, hid_t gapl_id); + hid_t (*create)(hid_t loc_id, const char *name, hid_t gcpl_id, hid_t gapl_id); hid_t (*open) (hid_t loc_id, const char *name, hid_t gapl_id); herr_t (*get) (hid_t file_id, H5VL_group_get_t get_type, va_list arguments); herr_t (*close) (hid_t group_id); -- cgit v0.12