diff options
Diffstat (limited to 'src')
91 files changed, 13541 insertions, 1742 deletions
diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 3370c99..7045012 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -184,6 +184,14 @@ set (H5EA_HDRS IDE_GENERATED_PROPERTIES ("H5EA" "${H5EA_HDRS}" "${H5EA_SOURCES}" ) +set (H5ES_SOURCES +) +set (H5ES_HDRS + ${HDF5_SRC_DIR}/H5ESpublic.h +) +IDE_GENERATED_PROPERTIES ("H5ES" "${H5ES_HDRS}" "${H5ES_SOURCES}" ) + + set (H5F_SOURCES ${HDF5_SRC_DIR}/H5F.c ${HDF5_SRC_DIR}/H5Faccum.c @@ -652,6 +660,18 @@ set (H5UC_HDRS IDE_GENERATED_PROPERTIES ("H5UC" "${H5UC_HDRS}" "${H5UC_SOURCES}" ) +set (H5VL_SOURCES + ${HDF5_SRC_DIR}/H5VL.c + ${HDF5_SRC_DIR}/H5VLint.c + ${HDF5_SRC_DIR}/H5VLnative.c +) +set (H5VL_HDRS + ${HDF5_SRC_DIR}/H5VLpkg.h + ${HDF5_SRC_DIR}/H5VLnative.h + ${HDF5_SRC_DIR}/H5VLpublic.h +) +IDE_GENERATED_PROPERTIES ("H5VL" "${H5VL_HDRS}" "${H5VL_SOURCES}" ) + set (H5VM_SOURCES ${HDF5_SRC_DIR}/H5VM.c ) @@ -731,6 +751,7 @@ set (common_SRCS ${H5ST_SOURCES} ${H5T_SOURCES} ${H5TS_SOURCES} + ${H5VL_SOURCES} ${H5VM_SOURCES} ${H5WB_SOURCES} ${H5Z_SOURCES} @@ -746,6 +767,7 @@ set (H5_PUBLIC_HEADERS ${H5D_HDRS} ${H5E_HDRS} ${H5EA_HDRS} + ${H5ES_HDRS} ${H5F_HDRS} ${H5FA_HDRS} ${H5FD_HDRS} @@ -767,6 +789,7 @@ set (H5_PUBLIC_HEADERS ${H5S_HDRS} ${H5SM_HDRS} ${H5T_HDRS} + ${H5VL_HDRS} ${H5Z_HDRS} ) @@ -812,6 +835,7 @@ set (H5_PRIVATE_HEADERS ${HDF5_SRC_DIR}/H5STprivate.h ${HDF5_SRC_DIR}/H5Tprivate.h ${HDF5_SRC_DIR}/H5TSprivate.h + ${HDF5_SRC_DIR}/H5VLprivate.h ${HDF5_SRC_DIR}/H5VMprivate.h ${HDF5_SRC_DIR}/H5WBprivate.h ${HDF5_SRC_DIR}/H5Zprivate.h @@ -173,6 +173,7 @@ H5_init_library(void) H5_debug_g.pkg[H5_PKG_S].name = "s"; H5_debug_g.pkg[H5_PKG_T].name = "t"; H5_debug_g.pkg[H5_PKG_V].name = "v"; + H5_debug_g.pkg[H5_PKG_VL].name = "vl"; H5_debug_g.pkg[H5_PKG_Z].name = "z"; /* @@ -213,6 +214,8 @@ H5_init_library(void) */ if(H5E_init() < 0) HGOTO_ERROR(H5E_FUNC, H5E_CANTINIT, FAIL, "unable to initialize error interface") + if(H5VL_init() < 0) + HGOTO_ERROR(H5E_FUNC, H5E_CANTINIT, FAIL, "unable to initialize vol interface") if(H5P_init() < 0) HGOTO_ERROR(H5E_FUNC, H5E_CANTINIT, FAIL, "unable to initialize property list interface") if(H5T_init() < 0) @@ -344,6 +347,7 @@ H5_term_library(void) pending += DOWN(AC); pending += DOWN(Z); pending += DOWN(FD); + pending += DOWN(VL); pending += DOWN(PL); /* Don't shut down the error code until other APIs which use it are shut down */ if(pending == 0) @@ -31,6 +31,7 @@ #include "H5MMprivate.h" /* Memory management */ #include "H5Opkg.h" /* Object headers */ #include "H5Sprivate.h" /* Dataspace functions */ +#include "H5VLprivate.h" /* Virtual Object Layer */ /****************/ @@ -251,10 +252,10 @@ hid_t H5Acreate2(hid_t loc_id, const char *attr_name, hid_t type_id, hid_t space_id, hid_t acpl_id, hid_t aapl_id) { - H5A_t *attr = NULL; /* Attribute created */ - H5G_loc_t loc; /* Object location */ - H5T_t *type; /* Datatype to use for attribute */ - H5S_t *space; /* Dataspace to use for attribute */ + void *attr = NULL; /* Attribute created */ + H5VL_object_t *vol_obj = NULL; /* Object token of loc_id */ + H5P_genplist_t *plist; /* Property list pointer */ + H5VL_loc_params_t loc_params; hid_t ret_value = H5I_INVALID_HID; /* Return value */ FUNC_ENTER_API(H5I_INVALID_HID) @@ -263,35 +264,50 @@ H5Acreate2(hid_t loc_id, const char *attr_name, hid_t type_id, hid_t space_id, /* Check arguments */ if(H5I_ATTR == H5I_get_type(loc_id)) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, H5I_INVALID_HID, "location is not valid for an attribute") - if(H5G_loc(loc_id, &loc) < 0) - HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, H5I_INVALID_HID, "not a location") - if(0 == (H5F_INTENT(loc.oloc->file) & H5F_ACC_RDWR)) - HGOTO_ERROR(H5E_ARGS, H5E_WRITEERROR, H5I_INVALID_HID, "no write intent on file") if(!attr_name) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, H5I_INVALID_HID, "attr_name parameter cannot be NULL") if(!*attr_name) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, H5I_INVALID_HID, "attr_name parameter cannot be an empty string") - if(NULL == (type = (H5T_t *)H5I_object_verify(type_id, H5I_DATATYPE))) - HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, H5I_INVALID_HID, "not a type") - if(NULL == (space = (H5S_t *)H5I_object_verify(space_id, H5I_DATASPACE))) - HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, H5I_INVALID_HID, "not a dataspace") + + /* Get correct property list */ + if(H5P_DEFAULT == acpl_id) + acpl_id = H5P_ATTRIBUTE_CREATE_DEFAULT; /* Verify access property list and set up collective metadata if appropriate */ if(H5CX_set_apl(&aapl_id, H5P_CLS_AACC, loc_id, TRUE) < 0) HGOTO_ERROR(H5E_ATTR, H5E_CANTSET, H5I_INVALID_HID, "can't set access property list info") + /* Get the property list structure for the acpl */ + if(NULL == (plist = (H5P_genplist_t *)H5I_object(acpl_id))) + HGOTO_ERROR(H5E_ATOM, H5E_BADATOM, FAIL, "can't find object for ID") + + /* Set creation properties */ + if(H5P_set(plist, H5VL_PROP_ATTR_TYPE_ID, &type_id) < 0) + HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, H5I_INVALID_HID, "can't set property value for datatype id") + if(H5P_set(plist, H5VL_PROP_ATTR_SPACE_ID, &space_id) < 0) + HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, H5I_INVALID_HID, "can't set property value for space id") + + /* Get the location object */ + if(NULL == (vol_obj = H5VL_get_object(loc_id))) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, H5I_INVALID_HID, "invalid location identifier") + + /* Set location parameters */ + loc_params.type = H5VL_OBJECT_BY_SELF; + loc_params.obj_type = H5I_get_type(loc_id); + /* Create the attribute */ - if(NULL == (attr = H5A__create(&loc, attr_name, type, space, acpl_id))) + if(NULL == (attr = H5VL_attr_create(vol_obj->data, loc_params, vol_obj->driver->cls, attr_name, + acpl_id, aapl_id, H5P_DATASET_XFER_DEFAULT, H5_REQUEST_NULL))) HGOTO_ERROR(H5E_ATTR, H5E_CANTINIT, H5I_INVALID_HID, "unable to create attribute") /* Register the new attribute and get an ID for it */ - if((ret_value = H5I_register(H5I_ATTR, attr, TRUE)) < 0) + if((ret_value = H5VL_register_id(H5I_ATTR, attr, vol_obj->driver, TRUE)) < 0) HGOTO_ERROR(H5E_ATOM, H5E_CANTREGISTER, H5I_INVALID_HID, "unable to atomize attribute handle") done: /* Cleanup on failure */ if(H5I_INVALID_HID == ret_value) - if(attr && H5A__close(attr) < 0) + if(attr && H5VL_attr_close(attr, vol_obj->driver->cls, H5P_DATASET_XFER_DEFAULT, H5_REQUEST_NULL) < 0) HDONE_ERROR(H5E_ATTR, H5E_CLOSEERROR, H5I_INVALID_HID, "can't close attribute") FUNC_LEAVE_API(ret_value) @@ -333,10 +349,10 @@ H5Acreate_by_name(hid_t loc_id, const char *obj_name, const char *attr_name, hid_t type_id, hid_t space_id, hid_t acpl_id, hid_t aapl_id, hid_t lapl_id) { - H5A_t *attr = NULL; /* Attribute created */ - H5G_loc_t loc; /* Object location */ - H5T_t *type; /* Datatype to use for attribute */ - H5S_t *space; /* Dataspace to use for attribute */ + void *attr = NULL; /* attr token from VOL plugin */ + H5VL_object_t *vol_obj = NULL; /* object token of loc_id */ + H5P_genplist_t *plist; /* Property list pointer */ + H5VL_loc_params_t loc_params; hid_t ret_value = H5I_INVALID_HID; /* Return value */ FUNC_ENTER_API(H5I_INVALID_HID) @@ -346,18 +362,14 @@ H5Acreate_by_name(hid_t loc_id, const char *obj_name, const char *attr_name, /* Check arguments */ if(H5I_ATTR == H5I_get_type(loc_id)) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, H5I_INVALID_HID, "location is not valid for an attribute") - if(H5G_loc(loc_id, &loc) < 0) - HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, H5I_INVALID_HID, "not a location") - if(0 == (H5F_INTENT(loc.oloc->file) & H5F_ACC_RDWR)) - HGOTO_ERROR(H5E_ARGS, H5E_WRITEERROR, H5I_INVALID_HID, "no write intent on file") if(!obj_name || !*obj_name) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, H5I_INVALID_HID, "no object name") if(!attr_name || !*attr_name) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, H5I_INVALID_HID, "no attribute name") - if(NULL == (type = (H5T_t *)H5I_object_verify(type_id, H5I_DATATYPE))) - HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, H5I_INVALID_HID, "not a type") - if(NULL == (space = (H5S_t *)H5I_object_verify(space_id, H5I_DATASPACE))) - HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, H5I_INVALID_HID, "not a dataspace") + + /* Get correct property list */ + if(H5P_DEFAULT == acpl_id) + acpl_id = H5P_ATTRIBUTE_CREATE_DEFAULT; /* Verify access property list and set up collective metadata if appropriate */ if(H5CX_set_apl(&aapl_id, H5P_CLS_AACC, loc_id, TRUE) < 0) @@ -369,18 +381,39 @@ H5Acreate_by_name(hid_t loc_id, const char *obj_name, const char *attr_name, H5CX_set_lapl(lapl_id); } + /* Get the plist structure */ + if(NULL == (plist = (H5P_genplist_t *)H5I_object(acpl_id))) + HGOTO_ERROR(H5E_ATOM, H5E_BADATOM, H5I_INVALID_HID, "can't find object for ID") + + /* Set creation properties */ + if(H5P_set(plist, H5VL_PROP_ATTR_TYPE_ID, &type_id) < 0) + HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, H5I_INVALID_HID, "can't set property value for datatype id") + if(H5P_set(plist, H5VL_PROP_ATTR_SPACE_ID, &space_id) < 0) + HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, H5I_INVALID_HID, "can't set property value for space id") + + /* Set up location struct */ + loc_params.type = H5VL_OBJECT_BY_NAME; + loc_params.obj_type = H5I_get_type(loc_id); + loc_params.loc_data.loc_by_name.name = obj_name; + loc_params.loc_data.loc_by_name.lapl_id = lapl_id; + + /* Get the location object */ + if(NULL == (vol_obj = H5VL_get_object(loc_id))) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, H5I_INVALID_HID, "invalid location identifier") + /* Create the attribute */ - if(NULL == (attr = H5A__create_by_name(&loc, obj_name, attr_name, type, space, acpl_id))) + if(NULL == (attr = H5VL_attr_create(vol_obj->data, loc_params, vol_obj->driver->cls, attr_name, + acpl_id, aapl_id, H5P_DATASET_XFER_DEFAULT, H5_REQUEST_NULL))) HGOTO_ERROR(H5E_ATTR, H5E_CANTINIT, H5I_INVALID_HID, "unable to create attribute") /* Register the new attribute and get an ID for it */ - if((ret_value = H5I_register(H5I_ATTR, attr, TRUE)) < 0) + if((ret_value = H5VL_register_id(H5I_ATTR, attr, vol_obj->driver, TRUE)) < 0) HGOTO_ERROR(H5E_ATOM, H5E_CANTREGISTER, H5I_INVALID_HID, "unable to atomize attribute handle") done: /* Cleanup on failure */ if(H5I_INVALID_HID == ret_value) - if(attr && H5A__close(attr) < 0) + if(attr && H5VL_attr_close (attr, vol_obj->driver->cls, H5P_DATASET_XFER_DEFAULT, H5_REQUEST_NULL) < 0) HDONE_ERROR(H5E_ATTR, H5E_CLOSEERROR, H5I_INVALID_HID, "can't close attribute") FUNC_LEAVE_API(ret_value) @@ -409,8 +442,9 @@ done: hid_t H5Aopen(hid_t loc_id, const char *attr_name, hid_t aapl_id) { - H5G_loc_t loc; /* Object location */ - H5A_t *attr = NULL; /* Attribute opened */ + void *attr = NULL; /* attr token from VOL driver */ + H5VL_object_t *vol_obj = NULL; /* object token of loc_id */ + H5VL_loc_params_t loc_params; hid_t ret_value = H5I_INVALID_HID; FUNC_ENTER_API(H5I_INVALID_HID) @@ -419,8 +453,6 @@ H5Aopen(hid_t loc_id, const char *attr_name, hid_t aapl_id) /* Check arguments */ if(H5I_ATTR == H5I_get_type(loc_id)) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, H5I_INVALID_HID, "location is not valid for an attribute") - if(H5G_loc(loc_id, &loc) < 0) - HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, H5I_INVALID_HID, "not a location") if(!attr_name) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, H5I_INVALID_HID, "name parameter cannot be NULL") if(!*attr_name) @@ -430,18 +462,27 @@ H5Aopen(hid_t loc_id, const char *attr_name, hid_t aapl_id) if(H5CX_set_apl(&aapl_id, H5P_CLS_AACC, loc_id, FALSE) < 0) HGOTO_ERROR(H5E_ATTR, H5E_CANTSET, H5I_INVALID_HID, "can't set access property list info") + /* Set location struct fields */ + loc_params.type = H5VL_OBJECT_BY_SELF; + loc_params.obj_type = H5I_get_type(loc_id); + + /* Get the location object */ + if(NULL == (vol_obj = H5VL_get_object(loc_id))) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, H5I_INVALID_HID, "invalid location identifier") + /* Open the attribute */ - if(NULL == (attr = H5A__open(&loc, attr_name))) + if(NULL == (attr = H5VL_attr_open(vol_obj->data, loc_params, vol_obj->driver->cls, + attr_name, aapl_id, H5P_DATASET_XFER_DEFAULT, H5_REQUEST_NULL))) HGOTO_ERROR(H5E_ATTR, H5E_CANTOPENOBJ, H5I_INVALID_HID, "unable to open attribute: '%s'", attr_name) /* Register the attribute and get an ID for it */ - if((ret_value = H5I_register(H5I_ATTR, attr, TRUE)) < 0) + if((ret_value = H5VL_register_id(H5I_ATTR, attr, vol_obj->driver, TRUE)) < 0) HGOTO_ERROR(H5E_ATOM, H5E_CANTREGISTER, H5I_INVALID_HID, "unable to atomize attribute handle") done: /* Cleanup on failure */ if(H5I_INVALID_HID == ret_value) - if(attr && H5A__close(attr) < 0) + if(attr && H5VL_attr_close(attr, vol_obj->driver->cls, H5P_DATASET_XFER_DEFAULT, H5_REQUEST_NULL) < 0) HDONE_ERROR(H5E_ATTR, H5E_CLOSEERROR, H5I_INVALID_HID, "can't close attribute") FUNC_LEAVE_API(ret_value) @@ -473,8 +514,9 @@ hid_t H5Aopen_by_name(hid_t loc_id, const char *obj_name, const char *attr_name, hid_t aapl_id, hid_t lapl_id) { - H5G_loc_t loc; /* Object location */ - H5A_t *attr = NULL; /* Attribute opened */ + void *attr = NULL; /* attr token from VOL driver */ + H5VL_object_t *vol_obj = NULL; /* object token of loc_id */ + H5VL_loc_params_t loc_params; hid_t ret_value = H5I_INVALID_HID; FUNC_ENTER_API(H5I_INVALID_HID) @@ -483,8 +525,6 @@ H5Aopen_by_name(hid_t loc_id, const char *obj_name, const char *attr_name, /* Check arguments */ if(H5I_ATTR == H5I_get_type(loc_id)) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, H5I_INVALID_HID, "location is not valid for an attribute") - if(H5G_loc(loc_id, &loc) < 0) - HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, H5I_INVALID_HID, "not a location") if(!obj_name || !*obj_name) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, H5I_INVALID_HID, "no object name") if(!attr_name || !*attr_name) @@ -500,19 +540,32 @@ H5Aopen_by_name(hid_t loc_id, const char *obj_name, const char *attr_name, HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, H5I_INVALID_HID, "not link access property list ID") H5CX_set_lapl(lapl_id); } + else + lapl_id = H5P_LINK_ACCESS_DEFAULT; + + /* Fill in location struct fields */ + loc_params.type = H5VL_OBJECT_BY_NAME; + loc_params.loc_data.loc_by_name.name = obj_name; + loc_params.loc_data.loc_by_name.lapl_id = lapl_id; + loc_params.obj_type = H5I_get_type(loc_id); + + /* Get the location object */ + if (NULL == (vol_obj = H5VL_get_object(loc_id))) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, H5I_INVALID_HID, "invalid location identifier") /* Open the attribute */ - if(NULL == (attr = H5A__open_by_name(&loc, obj_name, attr_name))) + if(NULL == (attr = H5VL_attr_open(vol_obj->data, loc_params, vol_obj->driver->cls, + attr_name, aapl_id, H5P_DATASET_XFER_DEFAULT, H5_REQUEST_NULL))) HGOTO_ERROR(H5E_ATTR, H5E_CANTOPENOBJ, H5I_INVALID_HID, "can't open attribute") /* Register the attribute and get an ID for it */ - if((ret_value = H5I_register(H5I_ATTR, attr, TRUE)) < 0) + if((ret_value = H5VL_register_id(H5I_ATTR, attr, vol_obj->driver, TRUE)) < 0) HGOTO_ERROR(H5E_ATOM, H5E_CANTREGISTER, H5I_INVALID_HID, "unable to atomize attribute handle") done: /* Cleanup on failure */ if(H5I_INVALID_HID == ret_value) - if(attr && H5A__close(attr) < 0) + if(attr && H5VL_attr_close (attr, vol_obj->driver->cls, H5P_DATASET_XFER_DEFAULT, H5_REQUEST_NULL) < 0) HDONE_ERROR(H5E_ATTR, H5E_CLOSEERROR, H5I_INVALID_HID, "can't close attribute") FUNC_LEAVE_API(ret_value) @@ -547,8 +600,9 @@ hid_t H5Aopen_by_idx(hid_t loc_id, const char *obj_name, H5_index_t idx_type, H5_iter_order_t order, hsize_t n, hid_t aapl_id, hid_t lapl_id) { - H5A_t *attr = NULL; /* Attribute opened */ - H5G_loc_t loc; /* Object location */ + void *attr = NULL; /* Attribute opened */ + H5VL_object_t *vol_obj = NULL; /* object token of loc_id */ + H5VL_loc_params_t loc_params; hid_t ret_value = H5I_INVALID_HID; /* Return value */ FUNC_ENTER_API(H5I_INVALID_HID) @@ -558,8 +612,6 @@ H5Aopen_by_idx(hid_t loc_id, const char *obj_name, H5_index_t idx_type, /* Check arguments */ if(H5I_ATTR == H5I_get_type(loc_id)) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, H5I_INVALID_HID, "location is not valid for an attribute") - if(H5G_loc(loc_id, &loc) < 0) - HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, H5I_INVALID_HID, "not a location") if(!obj_name || !*obj_name) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, H5I_INVALID_HID, "no object name") if(idx_type <= H5_INDEX_UNKNOWN || idx_type >= H5_INDEX_N) @@ -577,19 +629,35 @@ H5Aopen_by_idx(hid_t loc_id, const char *obj_name, H5_index_t idx_type, HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, H5I_INVALID_HID, "not link access property list ID") H5CX_set_lapl(lapl_id); } + else + lapl_id = H5P_LINK_ACCESS_DEFAULT; + + /* Fill in location struct parameters */ + loc_params.type = H5VL_OBJECT_BY_IDX; + loc_params.loc_data.loc_by_idx.name = obj_name; + loc_params.loc_data.loc_by_idx.idx_type = idx_type; + loc_params.loc_data.loc_by_idx.order = order; + loc_params.loc_data.loc_by_idx.n = n; + loc_params.loc_data.loc_by_idx.lapl_id = lapl_id; + loc_params.obj_type = H5I_get_type(loc_id); + + /* Get the location object */ + if(NULL == (vol_obj = H5VL_get_object(loc_id))) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, H5I_INVALID_HID, "invalid location identifier") /* Open the attribute */ - if(NULL == (attr = H5A__open_by_idx(&loc, obj_name, idx_type, order, n))) + if(NULL == (attr = H5VL_attr_open(vol_obj->data, loc_params, vol_obj->driver->cls, + NULL, aapl_id, H5P_DATASET_XFER_DEFAULT, H5_REQUEST_NULL))) HGOTO_ERROR(H5E_ATTR, H5E_CANTOPENOBJ, H5I_INVALID_HID, "unable to open attribute") /* Register the attribute and get an ID for it */ - if((ret_value = H5I_register(H5I_ATTR, attr, TRUE)) < 0) + if((ret_value = H5VL_register_id(H5I_ATTR, attr, vol_obj->driver, TRUE)) < 0) HGOTO_ERROR(H5E_ATOM, H5E_CANTREGISTER, H5I_INVALID_HID, "unable to atomize attribute handle") done: /* Cleanup on failure */ if(H5I_INVALID_HID == ret_value) - if(attr && H5A__close(attr) < 0) + if(attr && H5VL_attr_close(attr, vol_obj->driver->cls, H5P_DATASET_XFER_DEFAULT, H5_REQUEST_NULL) < 0) HDONE_ERROR(H5E_ATTR, H5E_CLOSEERROR, H5I_INVALID_HID, "can't close attribute") FUNC_LEAVE_API(ret_value) @@ -615,17 +683,16 @@ done: herr_t H5Awrite(hid_t attr_id, hid_t dtype_id, const void *buf) { - H5A_t *attr; /* Attribute object for ID */ - H5T_t *mem_type; /* Memory datatype */ + H5VL_object_t *vol_obj; /* Attribute object for ID */ herr_t ret_value; /* Return value */ FUNC_ENTER_API(FAIL) H5TRACE3("e", "ii*x", attr_id, dtype_id, buf); /* Check arguments */ - if(NULL == (attr = (H5A_t *)H5I_object_verify(attr_id, H5I_ATTR))) + if(NULL == (vol_obj = (H5VL_object_t *)H5I_object_verify(attr_id, H5I_ATTR))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not an attribute") - if(NULL == (mem_type = (H5T_t *)H5I_object_verify(dtype_id, H5I_DATATYPE))) + if(H5I_DATATYPE != H5I_get_type(dtype_id)) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a datatype") if(NULL == buf) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "buf parameter can't be NULL") @@ -635,7 +702,8 @@ H5Awrite(hid_t attr_id, hid_t dtype_id, const void *buf) HGOTO_ERROR(H5E_ATTR, H5E_CANTSET, FAIL, "can't set collective metadata read") /* Write the attribute data */ - if((ret_value = H5A__write(attr, mem_type, buf)) < 0) + if((ret_value = H5VL_attr_write(vol_obj->data, vol_obj->driver->cls, + dtype_id, buf, H5P_DATASET_XFER_DEFAULT, H5_REQUEST_NULL)) < 0) HGOTO_ERROR(H5E_ATTR, H5E_WRITEERROR, FAIL, "unable to write attribute") done: @@ -662,23 +730,23 @@ done: herr_t H5Aread(hid_t attr_id, hid_t dtype_id, void *buf) { - H5A_t *attr; /* Attribute object for ID */ - H5T_t *mem_type; /* Memory datatype */ + H5VL_object_t *vol_obj; /* Attribute object for ID */ herr_t ret_value; /* Return value */ FUNC_ENTER_API(FAIL) H5TRACE3("e", "ii*x", attr_id, dtype_id, buf); /* Check arguments */ - if(NULL == (attr = (H5A_t *)H5I_object_verify(attr_id, H5I_ATTR))) + if(NULL == (vol_obj = (H5VL_object_t *)H5I_object_verify(attr_id, H5I_ATTR))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not an attribute") - if(NULL == (mem_type = (H5T_t *)H5I_object_verify(dtype_id, H5I_DATATYPE))) + if(H5I_DATATYPE != H5I_get_type(dtype_id)) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a datatype") if(NULL == buf) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "buf parameter can't be NULL") /* Read the attribute data */ - if((ret_value = H5A__read(attr, mem_type, buf)) < 0) + if((ret_value = H5VL_attr_read(vol_obj->data, vol_obj->driver->cls, + dtype_id, buf, H5P_DATASET_XFER_DEFAULT, H5_REQUEST_NULL)) < 0) HGOTO_ERROR(H5E_ATTR, H5E_READERROR, FAIL, "unable to read attribute") done: @@ -705,18 +773,19 @@ done: hid_t H5Aget_space(hid_t attr_id) { - H5A_t *attr = NULL; /* Attribute object for ID */ + H5VL_object_t *vol_obj = NULL; /* Attribute object for ID */ hid_t ret_value = H5I_INVALID_HID; /* Return value */ FUNC_ENTER_API(H5I_INVALID_HID) H5TRACE1("i", "i", attr_id); /* Check arguments */ - if(NULL == (attr = (H5A_t *)H5I_object_verify(attr_id, H5I_ATTR))) + if(NULL == (vol_obj = (H5VL_object_t *)H5I_object_verify(attr_id, H5I_ATTR))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, H5I_INVALID_HID, "not an attribute") /* Get the dataspace */ - if((ret_value = H5A_get_space(attr)) < 0) + if(H5VL_attr_get(vol_obj->data, vol_obj->driver->cls, H5VL_ATTR_GET_SPACE, + H5P_DATASET_XFER_DEFAULT, H5_REQUEST_NULL, &ret_value) < 0) HGOTO_ERROR(H5E_ATTR, H5E_CANTGET, H5I_INVALID_HID, "unable to get dataspace of attribute") done: @@ -743,18 +812,19 @@ done: hid_t H5Aget_type(hid_t attr_id) { - H5A_t *attr = NULL; /* Attribute object for ID */ + H5VL_object_t *vol_obj = NULL; /* Attribute object for ID */ hid_t ret_value = H5I_INVALID_HID; /* Return value */ FUNC_ENTER_API(H5I_INVALID_HID) H5TRACE1("i", "i", attr_id); /* Check arguments */ - if(NULL == (attr = (H5A_t *)H5I_object_verify(attr_id, H5I_ATTR))) + if(NULL == (vol_obj = (H5VL_object_t *)H5I_object_verify(attr_id, H5I_ATTR))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, H5I_INVALID_HID, "not an attribute") /* Get the datatype */ - if((ret_value = H5A__get_type(attr)) < 0) + if(H5VL_attr_get(vol_obj->data, vol_obj->driver->cls, H5VL_ATTR_GET_TYPE, + H5P_DATASET_XFER_DEFAULT, H5_REQUEST_NULL, &ret_value) < 0) HGOTO_ERROR(H5E_ATTR, H5E_CANTGET, H5I_INVALID_HID, "unable to get datatype of attribute") done: @@ -784,7 +854,7 @@ done: hid_t H5Aget_create_plist(hid_t attr_id) { - H5A_t *attr = NULL; /* Attribute object for ID */ + H5VL_object_t *vol_obj = NULL; /* Attribute object for ID */ hid_t ret_value = H5I_INVALID_HID; /* Return value */ FUNC_ENTER_API(H5I_INVALID_HID) @@ -793,11 +863,12 @@ H5Aget_create_plist(hid_t attr_id) HDassert(H5P_LST_ATTRIBUTE_CREATE_ID_g != -1); /* Check arguments */ - if(NULL == (attr = (H5A_t *)H5I_object_verify(attr_id, H5I_ATTR))) + if(NULL == (vol_obj = (H5VL_object_t *)H5I_object_verify(attr_id, H5I_ATTR))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, H5I_INVALID_HID, "not an attribute") /* Get the acpl */ - if((ret_value = H5A__get_create_plist(attr)) < 0) + if(H5VL_attr_get(vol_obj->data, vol_obj->driver->cls, H5VL_ATTR_GET_ACPL, + H5P_DATASET_XFER_DEFAULT, H5_REQUEST_NULL, &ret_value) < 0) HGOTO_ERROR(H5E_ATTR, H5E_CANTGET, H5I_INVALID_HID, "unable to get creation property list for attribute") done: @@ -829,20 +900,27 @@ done: ssize_t H5Aget_name(hid_t attr_id, size_t buf_size, char *buf) { - H5A_t *attr = NULL; /* Attribute object for ID */ + H5VL_object_t *vol_obj = NULL; /* Attribute object for ID */ + H5VL_loc_params_t loc_params; ssize_t ret_value = -1; FUNC_ENTER_API((-1)) H5TRACE3("Zs", "iz*s", attr_id, buf_size, buf); /* check arguments */ - if(NULL == (attr = (H5A_t *)H5I_object_verify(attr_id, H5I_ATTR))) + if(NULL == (vol_obj = (H5VL_object_t *)H5I_object_verify(attr_id, H5I_ATTR))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, (-1), "not an attribute") if(!buf && buf_size) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, (-1), "buf cannot be NULL if buf_size is non-zero") + /* Set location struct parameters */ + loc_params.type = H5VL_OBJECT_BY_SELF; + loc_params.obj_type = H5I_get_type(attr_id); + /* Get the attribute name */ - if((ret_value = H5A__get_name(attr, buf_size, buf)) < 0) + if(H5VL_attr_get(vol_obj->data, vol_obj->driver->cls, H5VL_ATTR_GET_NAME, + H5P_DATASET_XFER_DEFAULT, H5_REQUEST_NULL, + loc_params, buf_size, buf, &ret_value) < 0) HGOTO_ERROR(H5E_ATTR, H5E_CANTGET, (-1), "unable to get attribute name") done: @@ -872,8 +950,8 @@ H5Aget_name_by_idx(hid_t loc_id, const char *obj_name, H5_index_t idx_type, H5_iter_order_t order, hsize_t n, char *name /*out*/, size_t size, hid_t lapl_id) { - H5G_loc_t loc; /* Object location */ - H5A_t *attr = NULL; /* Attribute object for name */ + H5VL_object_t *vol_obj; + H5VL_loc_params_t loc_params; ssize_t ret_value; /* Return value */ FUNC_ENTER_API(FAIL) @@ -883,8 +961,6 @@ H5Aget_name_by_idx(hid_t loc_id, const char *obj_name, H5_index_t idx_type, /* Check args */ if(H5I_ATTR == H5I_get_type(loc_id)) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "location is not valid for an attribute") - if(H5G_loc(loc_id, &loc) < 0) - HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a location") if(!obj_name || !*obj_name) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "no name") if(idx_type <= H5_INDEX_UNKNOWN || idx_type >= H5_INDEX_N) @@ -896,25 +972,24 @@ H5Aget_name_by_idx(hid_t loc_id, const char *obj_name, H5_index_t idx_type, if(H5CX_set_apl(&lapl_id, H5P_CLS_LACC, loc_id, FALSE) < 0) HGOTO_ERROR(H5E_ATTR, H5E_CANTSET, FAIL, "can't set access property list info") - /* Open the attribute on the object header */ - if(NULL == (attr = H5A__open_by_idx(&loc, obj_name, idx_type, order, n))) - HGOTO_ERROR(H5E_ATTR, H5E_CANTOPENOBJ, FAIL, "can't open attribute") + /* Get the object */ + if(NULL == (vol_obj = H5VL_get_object(loc_id))) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "invalid object identifier") - /* Get the length of the name */ - ret_value = (ssize_t)HDstrlen(attr->shared->name); + loc_params.type = H5VL_OBJECT_BY_IDX; + loc_params.loc_data.loc_by_idx.name = obj_name; + loc_params.loc_data.loc_by_idx.idx_type = idx_type; + loc_params.loc_data.loc_by_idx.order = order; + loc_params.loc_data.loc_by_idx.n = n; + loc_params.loc_data.loc_by_idx.lapl_id = lapl_id; + loc_params.obj_type = H5I_get_type(loc_id); - /* Get the name and store in the user's buffer */ - if(name) { - HDstrncpy(name, attr->shared->name, MIN((size_t)(ret_value + 1), size)); - if((size_t)ret_value >= size) - name[size - 1]='\0'; - } + /* Get the name */ + if(H5VL_attr_get(vol_obj->data, vol_obj->driver->cls, H5VL_ATTR_GET_NAME, + H5P_DATASET_XFER_DEFAULT, H5_REQUEST_NULL, loc_params, size, name, &ret_value) < 0) + HGOTO_ERROR(H5E_ATTR, H5E_CANTGET, FAIL, "unable to get name") done: - /* Release resources */ - if(attr && H5A__close(attr) < 0) - HDONE_ERROR(H5E_ATTR, H5E_CANTFREE, FAIL, "can't close attribute") - FUNC_LEAVE_API(ret_value) } /* end H5Aget_name_by_idx() */ @@ -939,18 +1014,20 @@ done: hsize_t H5Aget_storage_size(hid_t attr_id) { - H5A_t *attr; /* Attribute object for ID */ + H5VL_object_t *vol_obj; hsize_t ret_value; /* Return value */ FUNC_ENTER_API(0) H5TRACE1("h", "i", attr_id); /* Check arguments */ - if(NULL == (attr = (H5A_t *)H5I_object_verify(attr_id, H5I_ATTR))) + if(NULL == (vol_obj = (H5VL_object_t *)H5I_object_verify(attr_id, H5I_ATTR))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, 0, "not an attribute") /* Get the storage size */ - ret_value = attr->shared->data_size; + if(H5VL_attr_get(vol_obj->data, vol_obj->driver->cls, H5VL_ATTR_GET_STORAGE_SIZE, + H5P_DATASET_XFER_DEFAULT, H5_REQUEST_NULL, &ret_value) < 0) + HGOTO_ERROR(H5E_ATTR, H5E_CANTGET, 0, "unable to get acpl") done: FUNC_LEAVE_API(ret_value) @@ -973,18 +1050,23 @@ done: herr_t H5Aget_info(hid_t attr_id, H5A_info_t *ainfo) { - H5A_t *attr; /* Attribute object for name */ + H5VL_object_t *vol_obj; + H5VL_loc_params_t loc_params; herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_API(FAIL) H5TRACE2("e", "i*x", attr_id, ainfo); /* Check arguments */ - if(NULL == (attr = (H5A_t *)H5I_object_verify(attr_id, H5I_ATTR))) + if(NULL == (vol_obj = (H5VL_object_t *)H5I_object_verify(attr_id, H5I_ATTR))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not an attribute") + loc_params.type = H5VL_OBJECT_BY_SELF; + loc_params.obj_type = H5I_get_type(attr_id); + /* Get the attribute information */ - if(H5A__get_info(attr, ainfo) < 0) + if(H5VL_attr_get(vol_obj->data, vol_obj->driver->cls, H5VL_ATTR_GET_INFO, + H5P_DATASET_XFER_DEFAULT, H5_REQUEST_NULL, loc_params, ainfo) < 0) HGOTO_ERROR(H5E_ATTR, H5E_CANTGET, FAIL, "unable to get attribute info") done: @@ -1009,8 +1091,8 @@ herr_t H5Aget_info_by_name(hid_t loc_id, const char *obj_name, const char *attr_name, H5A_info_t *ainfo, hid_t lapl_id) { - H5G_loc_t loc; /* Object location */ - H5A_t *attr = NULL; /* Attribute object for name */ + H5VL_object_t *vol_obj; + H5VL_loc_params_t loc_params; herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_API(FAIL) @@ -1019,8 +1101,6 @@ H5Aget_info_by_name(hid_t loc_id, const char *obj_name, const char *attr_name, /* Check args */ if(H5I_ATTR == H5I_get_type(loc_id)) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "location is not valid for an attribute") - if(H5G_loc(loc_id, &loc) < 0) - HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a location") if(!obj_name || !*obj_name) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "no object name") if(!attr_name || !*attr_name) @@ -1032,19 +1112,21 @@ H5Aget_info_by_name(hid_t loc_id, const char *obj_name, const char *attr_name, if(H5CX_set_apl(&lapl_id, H5P_CLS_LACC, loc_id, FALSE) < 0) HGOTO_ERROR(H5E_ATTR, H5E_CANTSET, FAIL, "can't set access property list info") - /* Open the attribute on the object header */ - if(NULL == (attr = H5A__open_by_name(&loc, obj_name, attr_name))) - HGOTO_ERROR(H5E_ATTR, H5E_CANTOPENOBJ, FAIL, "can't open attribute") + loc_params.type = H5VL_OBJECT_BY_NAME; + loc_params.loc_data.loc_by_name.name = obj_name; + loc_params.loc_data.loc_by_name.lapl_id = lapl_id; + loc_params.obj_type = H5I_get_type(loc_id); + + /* Get the object */ + if(NULL == (vol_obj = H5VL_get_object(loc_id))) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "invalid object identifier") /* Get the attribute information */ - if(H5A__get_info(attr, ainfo) < 0) + if(H5VL_attr_get(vol_obj->data, vol_obj->driver->cls, H5VL_ATTR_GET_INFO, + H5P_DATASET_XFER_DEFAULT, H5_REQUEST_NULL, loc_params, ainfo, attr_name) < 0) HGOTO_ERROR(H5E_ATTR, H5E_CANTGET, FAIL, "unable to get attribute info") done: - /* Release resources */ - if(attr && H5A__close(attr) < 0) - HDONE_ERROR(H5E_ATTR, H5E_CANTFREE, FAIL, "can't close attribute") - FUNC_LEAVE_API(ret_value) } /* end H5Aget_info_by_name() */ @@ -1067,8 +1149,8 @@ herr_t H5Aget_info_by_idx(hid_t loc_id, const char *obj_name, H5_index_t idx_type, H5_iter_order_t order, hsize_t n, H5A_info_t *ainfo, hid_t lapl_id) { - H5G_loc_t loc; /* Object location */ - H5A_t *attr = NULL; /* Attribute object for name */ + H5VL_object_t *vol_obj; + H5VL_loc_params_t loc_params; herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_API(FAIL) @@ -1078,8 +1160,6 @@ H5Aget_info_by_idx(hid_t loc_id, const char *obj_name, H5_index_t idx_type, /* Check args */ if(H5I_ATTR == H5I_get_type(loc_id)) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "location is not valid for an attribute") - if(H5G_loc(loc_id, &loc) < 0) - HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a location") if(!obj_name || !*obj_name) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "no name") if(idx_type <= H5_INDEX_UNKNOWN || idx_type >= H5_INDEX_N) @@ -1093,19 +1173,24 @@ H5Aget_info_by_idx(hid_t loc_id, const char *obj_name, H5_index_t idx_type, if(H5CX_set_apl(&lapl_id, H5P_CLS_LACC, loc_id, FALSE) < 0) HGOTO_ERROR(H5E_ATTR, H5E_CANTSET, FAIL, "can't set access property list info") - /* Open the attribute on the object header */ - if(NULL == (attr = H5A__open_by_idx(&loc, obj_name, idx_type, order, n))) - HGOTO_ERROR(H5E_ATTR, H5E_CANTOPENOBJ, FAIL, "can't open attribute") + loc_params.type = H5VL_OBJECT_BY_IDX; + loc_params.loc_data.loc_by_idx.name = obj_name; + loc_params.loc_data.loc_by_idx.idx_type = idx_type; + loc_params.loc_data.loc_by_idx.order = order; + loc_params.loc_data.loc_by_idx.n = n; + loc_params.loc_data.loc_by_idx.lapl_id = lapl_id; + loc_params.obj_type = H5I_get_type(loc_id); + + /* Get the object */ + if(NULL == (vol_obj = H5VL_get_object(loc_id))) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "invalid object identifier") /* Get the attribute information */ - if(H5A__get_info(attr, ainfo) < 0) + if(H5VL_attr_get(vol_obj->data, vol_obj->driver->cls, H5VL_ATTR_GET_INFO, + H5P_DATASET_XFER_DEFAULT, H5_REQUEST_NULL, loc_params, ainfo) < 0) HGOTO_ERROR(H5E_ATTR, H5E_CANTGET, FAIL, "unable to get attribute info") done: - /* Release resources */ - if(attr && H5A__close(attr) < 0) - HDONE_ERROR(H5E_ATTR, H5E_CANTFREE, FAIL, "can't close attribute") - FUNC_LEAVE_API(ret_value) } /* end H5Aget_info_by_idx() */ @@ -1138,9 +1223,14 @@ H5Arename(hid_t loc_id, const char *old_name, const char *new_name) /* Avoid thrashing things if the names are the same */ if(HDstrcmp(old_name, new_name)) { - H5G_loc_t loc; /* Object location */ - - if(H5G_loc(loc_id, &loc) < 0) + H5VL_object_t *vol_obj; + H5VL_loc_params_t loc_params; + + loc_params.type = H5VL_OBJECT_BY_SELF; + loc_params.obj_type = H5I_get_type(loc_id); + + /* Get the location object */ + if(NULL == (vol_obj = H5VL_get_object(loc_id))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "invalid location identifier") /* Set up collective metadata if appropriate */ @@ -1148,7 +1238,8 @@ H5Arename(hid_t loc_id, const char *old_name, const char *new_name) HGOTO_ERROR(H5E_ATTR, H5E_CANTSET, FAIL, "can't set collective metadata read") /* Rename the attribute */ - if(H5O__attr_rename(loc.oloc, old_name, new_name) < 0) + if((ret_value = H5VL_attr_specific(vol_obj->data, loc_params, vol_obj->driver->cls, H5VL_ATTR_RENAME, + H5P_DATASET_XFER_DEFAULT, H5_REQUEST_NULL, old_name, new_name)) < 0) HGOTO_ERROR(H5E_ATTR, H5E_CANTRENAME, FAIL, "can't rename attribute") } @@ -1191,18 +1282,25 @@ H5Arename_by_name(hid_t loc_id, const char *obj_name, const char *old_attr_name, /* Avoid thrashing things if the names are the same */ if(HDstrcmp(old_attr_name, new_attr_name)) { - H5G_loc_t loc; /* Object location */ + H5VL_object_t *vol_obj; + H5VL_loc_params_t loc_params; /* Verify access property list and set up collective metadata if appropriate */ if(H5CX_set_apl(&lapl_id, H5P_CLS_LACC, loc_id, TRUE) < 0) HGOTO_ERROR(H5E_ATTR, H5E_CANTSET, FAIL, "can't set access property list info") + loc_params.type = H5VL_OBJECT_BY_NAME; + loc_params.loc_data.loc_by_name.name = obj_name; + loc_params.loc_data.loc_by_name.lapl_id = lapl_id; + loc_params.obj_type = H5I_get_type(loc_id); + /* Get the location object */ - if(H5G_loc(loc_id, &loc) < 0) + if(NULL == (vol_obj = H5VL_get_object(loc_id))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "invalid location identifier") /* Rename the attribute */ - if(H5A__rename_by_name(loc, obj_name, old_attr_name, new_attr_name) < 0) + if((ret_value = H5VL_attr_specific(vol_obj->data, loc_params, vol_obj->driver->cls, H5VL_ATTR_RENAME, + H5P_DATASET_XFER_DEFAULT, H5_REQUEST_NULL, old_attr_name, new_attr_name)) < 0) HGOTO_ERROR(H5E_ATTR, H5E_CANTRENAME, FAIL, "can't rename attribute") } @@ -1256,6 +1354,8 @@ herr_t H5Aiterate2(hid_t loc_id, H5_index_t idx_type, H5_iter_order_t order, hsize_t *idx, H5A_operator2_t op, void *op_data) { + H5VL_object_t *vol_obj = NULL; /* object token of loc_id */ + H5VL_loc_params_t loc_params; herr_t ret_value; /* Return value */ FUNC_ENTER_API(FAIL) @@ -1269,9 +1369,18 @@ H5Aiterate2(hid_t loc_id, H5_index_t idx_type, H5_iter_order_t order, if(order <= H5_ITER_UNKNOWN || order >= H5_ITER_N) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "invalid iteration order specified") + loc_params.type = H5VL_OBJECT_BY_SELF; + loc_params.obj_type = H5I_get_type(loc_id); + + /* get the loc object */ + if(NULL == (vol_obj = H5VL_get_object(loc_id))) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "invalid location identifier") + /* Iterate over attributes */ - if((ret_value = H5A__iterate(loc_id, idx_type, order, idx, op, op_data)) < 0) - HGOTO_ERROR(H5E_ATTR, H5E_BADITER, FAIL, "error iterating over attributes") + if((ret_value = H5VL_attr_specific(vol_obj->data, loc_params, vol_obj->driver->cls, H5VL_ATTR_ITER, + H5P_DATASET_XFER_DEFAULT, H5_REQUEST_NULL, + idx_type, order, idx, op, op_data)) < 0) + HERROR(H5E_ATTR, H5E_BADITER, "error iterating over attributes"); done: FUNC_LEAVE_API(ret_value) @@ -1326,7 +1435,8 @@ H5Aiterate_by_name(hid_t loc_id, const char *obj_name, H5_index_t idx_type, H5_iter_order_t order, hsize_t *idx, H5A_operator2_t op, void *op_data, hid_t lapl_id) { - H5G_loc_t loc; /* Object location */ + H5VL_object_t *vol_obj = NULL; /* object token of loc_id */ + H5VL_loc_params_t loc_params; herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_API(FAIL) @@ -1336,8 +1446,6 @@ H5Aiterate_by_name(hid_t loc_id, const char *obj_name, H5_index_t idx_type, /* check arguments */ if(H5I_ATTR == H5I_get_type(loc_id)) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "location is not valid for an attribute") - if(H5G_loc(loc_id, &loc) < 0) - HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a location") if(!obj_name || !*obj_name) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "no object name") if(idx_type <= H5_INDEX_UNKNOWN || idx_type >= H5_INDEX_N) @@ -1349,9 +1457,20 @@ H5Aiterate_by_name(hid_t loc_id, const char *obj_name, H5_index_t idx_type, if(H5CX_set_apl(&lapl_id, H5P_CLS_LACC, loc_id, FALSE) < 0) HGOTO_ERROR(H5E_ATTR, H5E_CANTSET, FAIL, "can't set access property list info") + loc_params.type = H5VL_OBJECT_BY_NAME; + loc_params.obj_type = H5I_get_type(loc_id); + loc_params.loc_data.loc_by_name.name = obj_name; + loc_params.loc_data.loc_by_name.lapl_id = lapl_id; + + /* get the loc object */ + if(NULL == (vol_obj = H5VL_get_object(loc_id))) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "invalid location identifier") + /* Iterate over attributes */ - if((ret_value = H5A__iterate_by_name(&loc, obj_name, idx_type, order, idx, op, op_data)) < 0) - HGOTO_ERROR(H5E_ATTR, H5E_BADITER, FAIL, "attribute iteration failed"); + if((ret_value = H5VL_attr_specific(vol_obj->data, loc_params, vol_obj->driver->cls, H5VL_ATTR_ITER, + H5P_DATASET_XFER_DEFAULT, H5_REQUEST_NULL, + idx_type, order, idx, op, op_data)) < 0) + HERROR(H5E_ATTR, H5E_BADITER, "attribute iteration failed"); done: FUNC_LEAVE_API(ret_value) @@ -1375,7 +1494,8 @@ done: herr_t H5Adelete(hid_t loc_id, const char *name) { - H5G_loc_t loc; /* Object location */ + H5VL_object_t *vol_obj = NULL; + H5VL_loc_params_t loc_params; herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_API(FAIL) @@ -1384,8 +1504,6 @@ H5Adelete(hid_t loc_id, const char *name) /* Check arguments */ if(H5I_ATTR == H5I_get_type(loc_id)) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "location is not valid for an attribute") - if(H5G_loc(loc_id, &loc) < 0) - HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a location") if(!name) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "name parameter cannot be NULL") if(!*name) @@ -1395,8 +1513,17 @@ H5Adelete(hid_t loc_id, const char *name) if(H5CX_set_loc(loc_id) < 0) HGOTO_ERROR(H5E_ATTR, H5E_CANTSET, FAIL, "can't set collective metadata read") + /* Fill in location struct fields */ + loc_params.type = H5VL_OBJECT_BY_SELF; + loc_params.obj_type = H5I_get_type(loc_id); + + /* Get the object */ + if(NULL == (vol_obj = H5VL_get_object(loc_id))) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "invalid object identifier") + /* Delete the attribute */ - if(H5O__attr_remove(loc.oloc, name) < 0) + if((ret_value = H5VL_attr_specific(vol_obj->data, loc_params, vol_obj->driver->cls, H5VL_ATTR_DELETE, + H5P_DATASET_XFER_DEFAULT, H5_REQUEST_NULL, name)) < 0) HGOTO_ERROR(H5E_ATTR, H5E_CANTDELETE, FAIL, "unable to delete attribute") done: @@ -1424,7 +1551,8 @@ herr_t H5Adelete_by_name(hid_t loc_id, const char *obj_name, const char *attr_name, hid_t lapl_id) { - H5G_loc_t loc; /* Object location */ + H5VL_object_t *vol_obj; + H5VL_loc_params_t loc_params; herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_API(FAIL) @@ -1433,8 +1561,6 @@ H5Adelete_by_name(hid_t loc_id, const char *obj_name, const char *attr_name, /* Check arguments */ if(H5I_ATTR == H5I_get_type(loc_id)) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "location is not valid for an attribute") - if(H5G_loc(loc_id, &loc) < 0) - HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a location") if(!obj_name || !*obj_name) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "no object name") if(!attr_name || !*attr_name) @@ -1444,8 +1570,19 @@ H5Adelete_by_name(hid_t loc_id, const char *obj_name, const char *attr_name, if(H5CX_set_apl(&lapl_id, H5P_CLS_LACC, loc_id, TRUE) < 0) HGOTO_ERROR(H5E_ATTR, H5E_CANTSET, FAIL, "can't set access property list info") + /* Fill in location struct fields */ + loc_params.type = H5VL_OBJECT_BY_NAME; + loc_params.loc_data.loc_by_name.name = obj_name; + loc_params.loc_data.loc_by_name.lapl_id = lapl_id; + loc_params.obj_type = H5I_get_type(loc_id); + + /* Get the object */ + if(NULL == (vol_obj = H5VL_get_object(loc_id))) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "invalid object identifier") + /* Delete the attribute */ - if(H5A__delete_by_name(&loc, obj_name, attr_name) < 0) + if((ret_value = H5VL_attr_specific(vol_obj->data, loc_params, vol_obj->driver->cls, H5VL_ATTR_DELETE, + H5P_DATASET_XFER_DEFAULT, H5_REQUEST_NULL, attr_name)) < 0) HGOTO_ERROR(H5E_ATTR, H5E_CANTDELETE, FAIL, "unable to delete attribute") done: @@ -1481,7 +1618,8 @@ herr_t H5Adelete_by_idx(hid_t loc_id, const char *obj_name, H5_index_t idx_type, H5_iter_order_t order, hsize_t n, hid_t lapl_id) { - H5G_loc_t loc; /* Object location */ + H5VL_object_t *vol_obj; + H5VL_loc_params_t loc_params; herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_API(FAIL) @@ -1490,8 +1628,6 @@ H5Adelete_by_idx(hid_t loc_id, const char *obj_name, H5_index_t idx_type, /* check arguments */ if(H5I_ATTR == H5I_get_type(loc_id)) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "location is not valid for an attribute") - if(H5G_loc(loc_id, &loc) < 0) - HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a location") if(!obj_name || !*obj_name) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "no object name") if(idx_type <= H5_INDEX_UNKNOWN || idx_type >= H5_INDEX_N) @@ -1503,8 +1639,21 @@ H5Adelete_by_idx(hid_t loc_id, const char *obj_name, H5_index_t idx_type, if(H5CX_set_apl(&lapl_id, H5P_CLS_LACC, loc_id, TRUE) < 0) HGOTO_ERROR(H5E_ATTR, H5E_CANTSET, FAIL, "can't set access property list info") - /* Delete the attribute from the location */ - if(H5A__delete_by_idx(&loc, obj_name, idx_type, order, n) < 0) + loc_params.type = H5VL_OBJECT_BY_IDX; + loc_params.loc_data.loc_by_idx.name = obj_name; + loc_params.loc_data.loc_by_idx.idx_type = idx_type; + loc_params.loc_data.loc_by_idx.order = order; + loc_params.loc_data.loc_by_idx.n = n; + loc_params.loc_data.loc_by_idx.lapl_id = lapl_id; + loc_params.obj_type = H5I_get_type(loc_id); + + /* get the object */ + if(NULL == (vol_obj = H5VL_get_object(loc_id))) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "invalid object identifier") + + /* Delete the attribute through the VOL */ + if((ret_value = H5VL_attr_specific(vol_obj->data, loc_params, vol_obj->driver->cls, H5VL_ATTR_DELETE, + H5P_DATASET_XFER_DEFAULT, H5_REQUEST_NULL, NULL)) < 0) HGOTO_ERROR(H5E_ATTR, H5E_CANTDELETE, FAIL, "unable to delete attribute") done: @@ -1561,7 +1710,8 @@ done: htri_t H5Aexists(hid_t obj_id, const char *attr_name) { - H5G_loc_t loc; /* Object location */ + H5VL_object_t *vol_obj; + H5VL_loc_params_t loc_params; htri_t ret_value; /* Return value */ FUNC_ENTER_API(FAIL) @@ -1570,13 +1720,19 @@ H5Aexists(hid_t obj_id, const char *attr_name) /* Check arguments */ if(H5I_ATTR == H5I_get_type(obj_id)) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "location is not valid for an attribute") - if(H5G_loc(obj_id, &loc) < 0) - HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a location") if(!attr_name || !*attr_name) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "no attribute name") + /* get the object */ + if(NULL == (vol_obj = H5VL_get_object(obj_id))) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "invalid object identifier") + + loc_params.type = H5VL_OBJECT_BY_SELF; + loc_params.obj_type = H5I_get_type(obj_id); + /* Check if the attribute exists */ - if((ret_value = H5O__attr_exists(loc.oloc, attr_name)) < 0) + if(H5VL_attr_specific(vol_obj->data, loc_params, vol_obj->driver->cls, H5VL_ATTR_EXISTS, + H5P_DATASET_XFER_DEFAULT, H5_REQUEST_NULL, attr_name, &ret_value) < 0) HGOTO_ERROR(H5E_ATTR, H5E_CANTGET, FAIL, "unable to determine if attribute exists") done: @@ -1601,7 +1757,8 @@ htri_t H5Aexists_by_name(hid_t loc_id, const char *obj_name, const char *attr_name, hid_t lapl_id) { - H5G_loc_t loc; /* Object location */ + H5VL_object_t *vol_obj; + H5VL_loc_params_t loc_params; htri_t ret_value; /* Return value */ FUNC_ENTER_API(FAIL) @@ -1610,8 +1767,6 @@ H5Aexists_by_name(hid_t loc_id, const char *obj_name, const char *attr_name, /* check arguments */ if(H5I_ATTR == H5I_get_type(loc_id)) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "location is not valid for an attribute") - if(H5G_loc(loc_id, &loc) < 0) - HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a location") if(!obj_name || !*obj_name) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "no object name") if(!attr_name || !*attr_name) @@ -1621,8 +1776,18 @@ H5Aexists_by_name(hid_t loc_id, const char *obj_name, const char *attr_name, if(H5CX_set_apl(&lapl_id, H5P_CLS_LACC, loc_id, FALSE) < 0) HGOTO_ERROR(H5E_ATTR, H5E_CANTSET, FAIL, "can't set access property list info") + /* get the object */ + if(NULL == (vol_obj = H5VL_get_object(loc_id))) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "invalid object identifier") + + loc_params.type = H5VL_OBJECT_BY_NAME; + loc_params.loc_data.loc_by_name.name = obj_name; + loc_params.loc_data.loc_by_name.lapl_id = lapl_id; + loc_params.obj_type = H5I_get_type(loc_id); + /* Check existence of attribute */ - if((ret_value = H5A__exists_by_name(loc, obj_name, attr_name)) < 0) + if(H5VL_attr_specific(vol_obj->data, loc_params, vol_obj->driver->cls, H5VL_ATTR_EXISTS, + H5P_DATASET_XFER_DEFAULT, H5_REQUEST_NULL, attr_name, &ret_value) < 0) HGOTO_ERROR(H5E_ATTR, H5E_CANTGET, FAIL, "unable to determine if attribute exists") done: diff --git a/src/H5Adeprec.c b/src/H5Adeprec.c index e88c8c3..47983ea 100644 --- a/src/H5Adeprec.c +++ b/src/H5Adeprec.c @@ -43,6 +43,7 @@ #include "H5Eprivate.h" /* Error handling */ #include "H5Iprivate.h" /* IDs */ #include "H5Opkg.h" /* Object headers */ +#include "H5VLprivate.h" /* Virtual object layer */ /****************/ @@ -113,10 +114,10 @@ hid_t H5Acreate1(hid_t loc_id, const char *name, hid_t type_id, hid_t space_id, hid_t acpl_id) { - H5A_t *attr = NULL; /* Attribute created */ - H5G_loc_t loc; /* Object location */ - H5T_t *type; /* Datatype to use for attribute */ - H5S_t *space; /* Dataspace to use for attribute */ + void *attr = NULL; /* attr token from VOL plugin */ + H5VL_object_t *vol_obj = NULL; /* object token of loc_id */ + H5VL_loc_params_t loc_params; + H5P_genplist_t *plist; /* Property list pointer */ hid_t ret_value = H5I_INVALID_HID; /* Return value */ FUNC_ENTER_API(H5I_INVALID_HID) @@ -125,33 +126,48 @@ H5Acreate1(hid_t loc_id, const char *name, hid_t type_id, hid_t space_id, /* Check arguments */ if(H5I_ATTR == H5I_get_type(loc_id)) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, H5I_INVALID_HID, "location is not valid for an attribute") - if(H5G_loc(loc_id, &loc) < 0) - HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, H5I_INVALID_HID, "not a location") - if(0 == (H5F_INTENT(loc.oloc->file) & H5F_ACC_RDWR)) - HGOTO_ERROR(H5E_ARGS, H5E_WRITEERROR, H5I_INVALID_HID, "no write intent on file") if(!name || !*name) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, H5I_INVALID_HID, "no name") - if(NULL == (type = (H5T_t *)H5I_object_verify(type_id, H5I_DATATYPE))) - HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, H5I_INVALID_HID, "not a type") - if(NULL == (space = (H5S_t *)H5I_object_verify(space_id, H5I_DATASPACE))) - HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, H5I_INVALID_HID, "not a dataspace") /* Set up collective metadata if appropriate */ if(H5CX_set_loc(loc_id) < 0) HGOTO_ERROR(H5E_ATTR, H5E_CANTSET, H5I_INVALID_HID, "can't set collective metadata read") + /* Get correct property list */ + if(H5P_DEFAULT == acpl_id) + acpl_id = H5P_ATTRIBUTE_CREATE_DEFAULT; + + /* Get the plist structure */ + if(NULL == (plist = (H5P_genplist_t *)H5I_object(acpl_id))) + HGOTO_ERROR(H5E_ATOM, H5E_BADATOM, H5I_INVALID_HID, "can't find object for ID") + + /* Set creation properties */ + if(H5P_set(plist, H5VL_PROP_ATTR_TYPE_ID, &type_id) < 0) + HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, H5I_INVALID_HID, "can't set property value for datatype id") + if(H5P_set(plist, H5VL_PROP_ATTR_SPACE_ID, &space_id) < 0) + HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, H5I_INVALID_HID, "can't set property value for space id") + + /* Set location parameters */ + loc_params.type = H5VL_OBJECT_BY_SELF; + loc_params.obj_type = H5I_get_type(loc_id); + + /* Get the location object */ + if(NULL == (vol_obj = H5VL_get_object(loc_id))) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, H5I_INVALID_HID, "invalid location identifier") + /* Create the attribute */ - if(NULL == (attr = H5A__create(&loc, name, type, space, acpl_id))) + if(NULL == (attr = H5VL_attr_create(vol_obj->data, loc_params, vol_obj->driver->cls, name, + acpl_id, H5P_DEFAULT, H5P_DATASET_XFER_DEFAULT, H5_REQUEST_NULL))) HGOTO_ERROR(H5E_ATTR, H5E_CANTINIT, H5I_INVALID_HID, "unable to create attribute") /* Register the new attribute and get an ID for it */ - if((ret_value = H5I_register(H5I_ATTR, attr, TRUE)) < 0) + if((ret_value = H5VL_register_id(H5I_ATTR, attr, vol_obj->driver, TRUE)) < 0) HGOTO_ERROR(H5E_ATOM, H5E_CANTREGISTER, H5I_INVALID_HID, "unable to register attribute for ID") done: /* Clean up on failure */ if(H5I_INVALID_HID == ret_value) - if(attr && H5A__close(attr) < 0) + if(attr && H5VL_attr_close(attr, vol_obj->driver->cls, H5P_DATASET_XFER_DEFAULT, H5_REQUEST_NULL) < 0) HDONE_ERROR(H5E_ATTR, H5E_CLOSEERROR, H5I_INVALID_HID, "can't close attribute") FUNC_LEAVE_API(ret_value) @@ -183,8 +199,9 @@ done: hid_t H5Aopen_name(hid_t loc_id, const char *name) { - H5G_loc_t loc; /* Object location */ - H5A_t *attr = NULL; /* Attribute opened */ + void *attr = NULL; /* attr token from VOL plugin */ + H5VL_object_t *vol_obj = NULL; /* object token of loc_id */ + H5VL_loc_params_t loc_params; hid_t ret_value = H5I_INVALID_HID; /* Return value */ FUNC_ENTER_API(H5I_INVALID_HID) @@ -193,23 +210,30 @@ H5Aopen_name(hid_t loc_id, const char *name) /* Check arguments */ if(H5I_ATTR == H5I_get_type(loc_id)) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, H5I_INVALID_HID, "location is not valid for an attribute") - if(H5G_loc(loc_id, &loc) < 0) - HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, H5I_INVALID_HID, "not a location") if(!name || !*name) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, H5I_INVALID_HID, "no name") + /* Set location parameters */ + loc_params.type = H5VL_OBJECT_BY_SELF; + loc_params.obj_type = H5I_get_type(loc_id); + + /* Get the location object */ + if (NULL == (vol_obj = H5VL_get_object(loc_id))) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, H5I_INVALID_HID, "invalid location identifier") + /* Open the attribute */ - if(NULL == (attr = H5A__open_by_name(&loc, ".", name))) - HGOTO_ERROR(H5E_ATTR, H5E_CANTOPENOBJ, H5I_INVALID_HID, "can't open attribute: '%s'", name) + if (NULL == (attr = H5VL_attr_open(vol_obj->data, loc_params, vol_obj->driver->cls, + name, H5P_DEFAULT, H5P_DATASET_XFER_DEFAULT, H5_REQUEST_NULL))) + HGOTO_ERROR(H5E_ATTR, H5E_CANTOPENOBJ, H5I_INVALID_HID, "unable to open attribute") /* Register the attribute and get an ID for it */ - if((ret_value = H5I_register(H5I_ATTR, attr, TRUE)) < 0) - HGOTO_ERROR(H5E_ATOM, H5E_CANTREGISTER, H5I_INVALID_HID, "unable to register attribute for ID") + if ((ret_value = H5VL_register_id(H5I_ATTR, attr, vol_obj->driver, TRUE)) < 0) + HGOTO_ERROR(H5E_ATOM, H5E_CANTREGISTER, H5I_INVALID_HID, "unable to atomize attribute handle") done: /* Clean up on failure */ if(H5I_INVALID_HID == ret_value) - if(attr && H5A__close(attr) < 0) + if(attr && H5VL_attr_close(attr, vol_obj->driver->cls, H5P_DATASET_XFER_DEFAULT, H5_REQUEST_NULL) < 0) HDONE_ERROR(H5E_ATTR, H5E_CLOSEERROR, H5I_INVALID_HID, "can't close attribute") FUNC_LEAVE_API(ret_value) @@ -241,8 +265,9 @@ done: hid_t H5Aopen_idx(hid_t loc_id, unsigned idx) { - H5G_loc_t loc; /* Object location */ - H5A_t *attr = NULL; /* Attribute opened */ + void *attr = NULL; /* attr token from VOL plugin */ + H5VL_object_t *vol_obj = NULL; /* object token of loc_id */ + H5VL_loc_params_t loc_params; hid_t ret_value = H5I_INVALID_HID; /* Return value */ FUNC_ENTER_API(H5I_INVALID_HID) @@ -250,22 +275,34 @@ H5Aopen_idx(hid_t loc_id, unsigned idx) /* Check arguments */ if(H5I_ATTR == H5I_get_type(loc_id)) - HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "location is not valid for an attribute") - if(H5G_loc(loc_id, &loc) < 0) - HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a location") + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, H5I_INVALID_HID, "location is not valid for an attribute") + + /* Set location parameters */ + loc_params.type = H5VL_OBJECT_BY_IDX; + loc_params.loc_data.loc_by_idx.name = "."; + loc_params.loc_data.loc_by_idx.idx_type = H5_INDEX_CRT_ORDER; + loc_params.loc_data.loc_by_idx.order = H5_ITER_INC; + loc_params.loc_data.loc_by_idx.n = (hsize_t)idx; + loc_params.loc_data.loc_by_idx.lapl_id = H5P_LINK_ACCESS_DEFAULT; + loc_params.obj_type = H5I_get_type(loc_id); + + /* Get the location object */ + if(NULL == (vol_obj = H5VL_get_object(loc_id))) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, H5I_INVALID_HID, "invalid location identifier") /* Open the attribute */ - if(NULL == (attr = H5A__open_by_idx(&loc, ".", H5_INDEX_CRT_ORDER, H5_ITER_INC, (hsize_t)idx))) + if(NULL == (attr = H5VL_attr_open(vol_obj->data, loc_params, vol_obj->driver->cls, + NULL, H5P_DEFAULT, H5P_DATASET_XFER_DEFAULT, H5_REQUEST_NULL))) HGOTO_ERROR(H5E_ATTR, H5E_CANTOPENOBJ, H5I_INVALID_HID, "unable to open attribute") /* Register the attribute and get an ID for it */ - if((ret_value = H5I_register(H5I_ATTR, attr, TRUE)) < 0) - HGOTO_ERROR(H5E_ATOM, H5E_CANTREGISTER, H5I_INVALID_HID, "unable to register attribute for ID") + if((ret_value = H5VL_register_id(H5I_ATTR, attr, vol_obj->driver, TRUE)) < 0) + HGOTO_ERROR(H5E_ATOM, H5E_CANTREGISTER, H5I_INVALID_HID, "unable to atomize attribute handle") done: /* Clean up on failure */ if(H5I_INVALID_HID == ret_value) - if(attr && H5A__close(attr) < 0) + if(attr && H5VL_attr_close(attr, vol_obj->driver->cls, H5P_DATASET_XFER_DEFAULT, H5_REQUEST_NULL) < 0) HDONE_ERROR(H5E_ATTR, H5E_CLOSEERROR, H5I_INVALID_HID, "can't close attribute") FUNC_LEAVE_API(ret_value) @@ -293,56 +330,27 @@ done: int H5Aget_num_attrs(hid_t loc_id) { - H5O_loc_t *loc; /* Object location for attribute */ - void *obj; + H5VL_object_t *vol_obj; + H5VL_loc_params_t loc_params; + H5O_info_t oinfo; int ret_value = -1; FUNC_ENTER_API((-1)) H5TRACE1("Is", "i", loc_id); - if(H5I_BADID == H5I_get_type(loc_id)) - HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, (-1), "bad location ID") - if(H5I_FILE == H5I_get_type(loc_id) || H5I_ATTR == H5I_get_type(loc_id)) - HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, (-1), "location is not valid for an attribute") - if(NULL == (obj = H5I_object(loc_id))) - HGOTO_ERROR(H5E_ARGS, H5E_BADATOM, (-1), "illegal object atom") - - switch(H5I_get_type (loc_id)) { - case H5I_DATASET: - if(NULL == (loc = H5D_oloc((H5D_t*)obj))) - HGOTO_ERROR(H5E_ATTR, H5E_CANTGET, (-1), "can't get location for object") - break; - - case H5I_DATATYPE: - if(NULL == (loc = H5T_oloc((H5T_t*)obj))) - HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, (-1), "target datatype is not committed") - break; - - case H5I_GROUP: - if(NULL == (loc = H5G_oloc((H5G_t*)obj))) - HGOTO_ERROR(H5E_ATTR, H5E_CANTGET, (-1), "can't get location for object") - break; - - case H5I_UNINIT: - case H5I_BADID: - case H5I_FILE: - case H5I_DATASPACE: - case H5I_ATTR: - case H5I_REFERENCE: - case H5I_VFL: - case H5I_GENPROP_CLS: - case H5I_GENPROP_LST: - case H5I_ERROR_CLASS: - case H5I_ERROR_MSG: - case H5I_ERROR_STACK: - case H5I_NTYPES: - default: - HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, (-1), "inappropriate attribute target") - } - - /* Look up the # of attributes for the object */ - if((ret_value = H5O__attr_count(loc)) < 0) - HGOTO_ERROR(H5E_ATTR, H5E_CANTCOUNT, (-1), "can't get attribute count for object") + loc_params.type = H5VL_OBJECT_BY_SELF; + loc_params.obj_type = H5I_get_type(loc_id); + + /* get the location object */ + if(NULL == (vol_obj = H5VL_get_object(loc_id))) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, (-1), "invalid location identifier") + + /* Get the number of attributes for the object */ + if(H5VL_object_optional(vol_obj->data, vol_obj->driver->cls, H5P_DATASET_XFER_DEFAULT, + H5_REQUEST_NULL, H5VL_OBJECT_GET_INFO, loc_params, &oinfo, H5O_INFO_ALL) < 0) + HGOTO_ERROR(H5E_ATTR, H5E_CANTGET, (-1), "unable to get attribute count for object") + + H5_CHECKED_ASSIGN(ret_value, int, oinfo.num_attrs, hsize_t); done: FUNC_LEAVE_API(ret_value) diff --git a/src/H5Aint.c b/src/H5Aint.c index 8268a01..80a3e98 100644 --- a/src/H5Aint.c +++ b/src/H5Aint.c @@ -42,6 +42,8 @@ #include "H5MMprivate.h" /* Memory management */ #include "H5Opkg.h" /* Object headers */ #include "H5SMprivate.h" /* Shared Object Header Messages */ +#include "H5VLprivate.h" /* Virtual Object Layer */ +#include "H5VLnative.h" /* Native VOL driver */ /****************/ @@ -404,11 +406,11 @@ done: /*------------------------------------------------------------------------- - * Function: H5A__open + * Function: H5A__open * - * Purpose: Open an attribute in an object header + * Purpose: Open an attribute in an object header * - * Return: Non-negative on success/Negative on failure + * Return: SUCCEED/FAIL * * Programmer: Quincey Koziol * December 9, 2017 @@ -917,8 +919,18 @@ H5A__get_type(H5A_t *attr) HGOTO_ERROR(H5E_DATATYPE, H5E_CANTINIT, H5I_INVALID_HID, "unable to lock transient datatype") /* Atomize */ - if ((ret_value = H5I_register(H5I_DATATYPE, dt, TRUE)) < 0) - HGOTO_ERROR(H5E_ATOM, H5E_CANTREGISTER, H5I_INVALID_HID, "unable to register datatype") + if (H5T_is_named(dt)) { + /* If this is a committed datatype, we need to recreate the + * two level IDs, where the VOL object is a copy of the + * returned datatype + */ + if ((ret_value = H5VL_native_register(H5I_DATATYPE, dt, TRUE)) < 0) + HGOTO_ERROR(H5E_ATOM, H5E_CANTREGISTER, H5I_INVALID_HID, "unable to atomize file handle") + } + else { + if ((ret_value = H5I_register(H5I_DATATYPE, dt, TRUE)) < 0) + HGOTO_ERROR(H5E_ATOM, H5E_CANTREGISTER, H5I_INVALID_HID, "unable to register datatype") + } done: if(H5I_INVALID_HID == ret_value) @@ -1134,20 +1146,23 @@ done: *------------------------------------------------------------------------- */ herr_t -H5A__close_cb(H5A_t *attr) +H5A__close_cb(H5VL_object_t *attr_vol_obj) { herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_PACKAGE /* Sanity check */ - HDassert(attr); - HDassert(attr->shared); + HDassert(attr_vol_obj); /* Close the attribute */ - if(H5A__close(attr) < 0) + if((ret_value = H5VL_attr_close(attr_vol_obj->data, attr_vol_obj->driver->cls, H5P_DATASET_XFER_DEFAULT, H5_REQUEST_NULL)) < 0) HGOTO_ERROR(H5E_ATTR, H5E_CLOSEERROR, FAIL, "problem closing attribute") + /* Free the VOL object */ + if(H5VL_free_object(attr_vol_obj) < 0) + HGOTO_ERROR(H5E_ATTR, H5E_CANTDEC, FAIL, "unable to free VOL object") + done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5A__close_cb() */ @@ -2339,7 +2354,7 @@ H5A__attr_post_copy_file(const H5O_loc_t *src_oloc, const H5A_t *attr_src, HDassert(file_src); HDassert(file_dst); - if(H5T_is_named(attr_src->shared->dt)) { + if (H5T_is_named(attr_src->shared->dt)) { H5O_loc_t *src_oloc_dt; /* Pointer to source datatype's object location */ H5O_loc_t *dst_oloc_dt; /* Pointer to dest. datatype's object location */ @@ -2596,16 +2611,20 @@ H5A__iterate_common(hid_t loc_id, H5_index_t idx_type, H5_iter_order_t order, * * Return: SUCCEED/FAIL * - * Programmer: Quincey Koziol - * December 6, 2017 - * *------------------------------------------------------------------------- */ herr_t -H5A__iterate(hid_t loc_id, H5_index_t idx_type, H5_iter_order_t order, +H5A__iterate(const H5G_loc_t *loc, const char *obj_name, H5_index_t idx_type, H5_iter_order_t order, hsize_t *idx, H5A_operator2_t op, void *op_data) { + H5G_loc_t obj_loc; /* Location used to open group */ + H5G_name_t obj_path; /* Opened object group hier. path */ + H5O_loc_t obj_oloc; /* Opened object object location */ + hbool_t loc_found = FALSE; /* Entry at 'obj_name' found */ + hid_t obj_loc_id = (-1); /* ID for object located */ H5A_attr_iter_op_t attr_op; /* Attribute operator */ + void *temp_obj = NULL; + H5I_type_t obj_type; herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_PACKAGE @@ -2614,11 +2633,37 @@ H5A__iterate(hid_t loc_id, H5_index_t idx_type, H5_iter_order_t order, attr_op.op_type = H5A_ATTR_OP_APP2; attr_op.u.app_op2 = op; + /* Set up opened group location to fill in */ + obj_loc.oloc = &obj_oloc; + obj_loc.path = &obj_path; + H5G_loc_reset(&obj_loc); + + /* Find the object's location */ + if(H5G_loc_find(loc, obj_name, &obj_loc) < 0) + HGOTO_ERROR(H5E_ATTR, H5E_NOTFOUND, FAIL, "object not found"); + loc_found = TRUE; + + /* Open the object */ + if(NULL == (temp_obj = H5O_open_by_loc(&obj_loc, &obj_type))) + HGOTO_ERROR(H5E_ATTR, H5E_CANTOPENOBJ, FAIL, "unable to open object"); + + /* Get an ID for the object */ + if((obj_loc_id = H5VL_native_register(obj_type, temp_obj, TRUE)) < 0) + HGOTO_ERROR(H5E_ATOM, H5E_CANTREGISTER, FAIL, "unable to register datatype"); + /* Call internal attribute iteration routine */ - if((ret_value = H5A__iterate_common(loc_id, idx_type, order, idx, &attr_op, op_data)) < 0) + if((ret_value = H5A__iterate_common(obj_loc_id, idx_type, order, idx, &attr_op, op_data)) < 0) HGOTO_ERROR(H5E_ATTR, H5E_BADITER, FAIL, "error iterating over attributes") done: + /* Release resources */ + if(obj_loc_id != H5I_INVALID_HID) { + if(H5I_dec_app_ref(obj_loc_id) < 0) + HDONE_ERROR(H5E_ATTR, H5E_CANTDEC, FAIL, "unable to close temporary object"); + } + else if(loc_found && H5G_loc_free(&obj_loc) < 0) + HDONE_ERROR(H5E_ATTR, H5E_CANTRELEASE, FAIL, "can't free location"); + FUNC_LEAVE_NOAPI(ret_value) } /* end H5A__iterate() */ @@ -2668,67 +2713,6 @@ done: /*------------------------------------------------------------------------- - * Function: H5A__iterate_by_name - * - * Purpose: Private version of H5Aiterate_by_name - * - * Return: SUCCEED/FAIL - * - * Programmer: Quincey Koziol - * December 6, 2017 - * - *------------------------------------------------------------------------- - */ -herr_t -H5A__iterate_by_name(const H5G_loc_t *loc, const char *obj_name, H5_index_t idx_type, H5_iter_order_t order, hsize_t *idx, H5A_operator2_t op, - void *op_data) -{ - H5G_loc_t obj_loc; /* Location used to open group */ - H5G_name_t obj_path; /* Opened object group hier. path */ - H5O_loc_t obj_oloc; /* Opened object object location */ - hbool_t loc_found = FALSE; /* Entry at 'obj_name' found */ - hid_t obj_loc_id = (-1); /* ID for object located */ - H5A_attr_iter_op_t attr_op; /* Attribute operator */ - herr_t ret_value = SUCCEED; /* Return value */ - - FUNC_ENTER_PACKAGE - - /* Set up opened group location to fill in */ - obj_loc.oloc = &obj_oloc; - obj_loc.path = &obj_path; - H5G_loc_reset(&obj_loc); - - /* Find the object's location */ - if(H5G_loc_find(loc, obj_name, &obj_loc/*out*/) < 0) - HGOTO_ERROR(H5E_ATTR, H5E_NOTFOUND, FAIL, "object not found") - loc_found = TRUE; - - /* Open the object */ - if((obj_loc_id = H5O_open_by_loc(&obj_loc, TRUE)) < 0) - HGOTO_ERROR(H5E_ATTR, H5E_CANTOPENOBJ, FAIL, "unable to open object") - - /* Build attribute operator info */ - attr_op.op_type = H5A_ATTR_OP_APP2; - attr_op.u.app_op2 = op; - - /* Call attribute iteration routine */ - if((ret_value = H5A__iterate_common(obj_loc_id, idx_type, order, idx, &attr_op, op_data)) < 0) - HGOTO_ERROR(H5E_ATTR, H5E_BADITER, FAIL, "error iterating over attributes") - -done: - /* Release resources */ - if(obj_loc_id > 0) { - if(H5I_dec_app_ref(obj_loc_id) < 0) - HDONE_ERROR(H5E_ATTR, H5E_CANTDEC, FAIL, "unable to close temporary object") - } - else if(loc_found && H5G_loc_free(&obj_loc) < 0) - HDONE_ERROR(H5E_ATTR, H5E_CANTRELEASE, FAIL, "can't free location") - - FUNC_LEAVE_NOAPI(ret_value) -} /* end H5A__iterate_by_name() */ - - -/*------------------------------------------------------------------------- * Function: H5A__delete_by_name * * Purpose: Private version of H5Adelete_by_name diff --git a/src/H5Apkg.h b/src/H5Apkg.h index 85f0254..91061cd 100644 --- a/src/H5Apkg.h +++ b/src/H5Apkg.h @@ -198,16 +198,13 @@ H5_DLL herr_t H5A__get_info(const H5A_t *attr, H5A_info_t *ainfo); H5_DLL hid_t H5A__get_create_plist(H5A_t* attr); H5_DLL herr_t H5A__free(H5A_t *attr); H5_DLL herr_t H5A__close(H5A_t *attr); -H5_DLL herr_t H5A__close_cb(H5A_t *attr); +H5_DLL herr_t H5A__close_cb(H5VL_object_t *attr_vol_obj); H5_DLL htri_t H5A__get_ainfo(H5F_t *f, H5O_t *oh, H5O_ainfo_t *ainfo); H5_DLL herr_t H5A__set_version(const H5F_t *f, H5A_t *attr); H5_DLL herr_t H5A__rename_by_name(H5G_loc_t loc, const char *obj_name, const char *old_attr_name, const char *new_attr_name); -H5_DLL herr_t H5A__iterate(hid_t loc_id, H5_index_t idx_type, H5_iter_order_t order, +H5_DLL herr_t H5A__iterate(const H5G_loc_t *loc, const char *obj_name,H5_index_t idx_type, H5_iter_order_t order, hsize_t *idx, H5A_operator2_t op, void *op_data); -H5_DLL herr_t H5A__iterate_by_name(const H5G_loc_t *loc, const char *obj_name, - H5_index_t idx_type, H5_iter_order_t order, hsize_t *idx, H5A_operator2_t op, - void *op_data); #ifndef H5_NO_DEPRECATED_SYMBOLS H5_DLL herr_t H5A__iterate_old(hid_t loc_id, unsigned *attr_num, H5A_operator1_t op, void *op_data); diff --git a/src/H5Atest.c b/src/H5Atest.c index 36c3d35..6fc1cbf 100644 --- a/src/H5Atest.c +++ b/src/H5Atest.c @@ -38,6 +38,7 @@ #include "H5Eprivate.h" /* Error handling */ #include "H5Iprivate.h" /* IDs */ #include "H5SMprivate.h" /* Shared object header messages */ +#include "H5VLprivate.h" /* Virtual Object Layer */ /****************/ @@ -96,7 +97,7 @@ H5A__is_shared_test(hid_t attr_id) FUNC_ENTER_PACKAGE /* Check arguments */ - if(NULL == (attr = (H5A_t *)H5I_object_verify(attr_id, H5I_ATTR))) + if(NULL == (attr = (H5A_t *)H5VL_object_verify(attr_id, H5I_ATTR))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not an attribute") /* Check if attribute is shared */ @@ -129,7 +130,7 @@ H5A__get_shared_rc_test(hid_t attr_id, hsize_t *ref_count) FUNC_ENTER_PACKAGE /* Check arguments */ - if(NULL == (attr = (H5A_t *)H5I_object_verify(attr_id, H5I_ATTR))) + if(NULL == (attr = (H5A_t *)H5VL_object_verify(attr_id, H5I_ATTR))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not an attribute") /* Push API context */ @@ -2472,7 +2472,11 @@ H5CX__pop_common(void) H5CX_node_t **head = H5CX_get_my_context(); /* Get the pointer to the head of the API context, for this thread */ H5CX_node_t *ret_value = NULL; /* Return value */ +#ifdef H5_HAVE_PARALLEL FUNC_ENTER_STATIC +#else + FUNC_ENTER_STATIC_NOERR +#endif /* Sanity check */ HDassert(head && *head); diff --git a/src/H5Ctest.c b/src/H5Ctest.c index 9da6350..340071a 100644 --- a/src/H5Ctest.c +++ b/src/H5Ctest.c @@ -40,6 +40,7 @@ #include "H5Eprivate.h" /* Error handling */ #include "H5Fpkg.h" /* Files */ #include "H5Iprivate.h" /* IDs */ +#include "H5VLprivate.h" /* Virtual Object Layer */ /****************/ @@ -142,7 +143,7 @@ H5C__verify_cork_tag_test(hid_t fid, haddr_t tag, hbool_t status) FUNC_ENTER_PACKAGE /* Get file pointer */ - if(NULL == (f = (H5F_t *)H5I_object_verify(fid, H5I_FILE))) + if(NULL == (f = (H5F_t *)H5VL_object_verify(fid, H5I_FILE))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a file") /* Get cache pointer */ @@ -27,6 +27,7 @@ #include "H5Eprivate.h" /* Error handling */ #include "H5FLprivate.h" /* Free lists */ #include "H5Iprivate.h" /* IDs */ +#include "H5VLprivate.h" /* Virtual Object Layer */ /****************/ @@ -102,9 +103,10 @@ 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) { - H5D_t *dset = NULL; /* New dataset's info */ - H5G_loc_t loc; /* Object location to insert dataset into */ - const H5S_t *space; /* Dataspace for dataset */ + void *dset = NULL; /* New dataset's info */ + H5VL_object_t *vol_obj = NULL; /* object token of loc_id */ + H5VL_loc_params_t loc_params; + H5P_genplist_t *plist = NULL; /* Property list pointer */ hid_t ret_value = H5I_INVALID_HID; /* Return value */ FUNC_ENTER_API(H5I_INVALID_HID) @@ -112,16 +114,10 @@ H5Dcreate2(hid_t loc_id, const char *name, hid_t type_id, hid_t space_id, dapl_id); /* Check arguments */ - if(H5G_loc(loc_id, &loc) < 0) - HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, H5I_INVALID_HID, "not a location ID") if(!name) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, H5I_INVALID_HID, "name parameter cannot be NULL") if(!*name) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, H5I_INVALID_HID, "name parameter cannot be an empty string") - if(H5I_DATATYPE != H5I_get_type(type_id)) - HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, H5I_INVALID_HID, "not a datatype ID") - if(NULL == (space = (const H5S_t *)H5I_object_verify(space_id, H5I_DATASPACE))) - HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, H5I_INVALID_HID, "not a dataspace ID") /* Get link creation property list */ if(H5P_DEFAULT == lcpl_id) @@ -141,17 +137,38 @@ H5Dcreate2(hid_t loc_id, const char *name, hid_t type_id, hid_t space_id, if(H5CX_set_apl(&dapl_id, H5P_CLS_DACC, loc_id, TRUE) < 0) HGOTO_ERROR(H5E_DATASET, H5E_CANTSET, H5I_INVALID_HID, "can't set access property list info") + /* Get the property list structure for the dcpl */ + if(NULL == (plist = (H5P_genplist_t *)H5I_object(dcpl_id))) + HGOTO_ERROR(H5E_ATOM, H5E_BADATOM, H5I_INVALID_HID, "can't find object for ID") + + /* Get the location object */ + if(NULL == (vol_obj = (H5VL_object_t *)H5I_object(loc_id))) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, H5I_INVALID_HID, "invalid location identifier") + + /* Set creation properties */ + if(H5P_set(plist, H5VL_PROP_DSET_TYPE_ID, &type_id) < 0) + HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, H5I_INVALID_HID, "can't set property value for datatype id") + if(H5P_set(plist, H5VL_PROP_DSET_SPACE_ID, &space_id) < 0) + HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, H5I_INVALID_HID, "can't set property value for space id") + if(H5P_set(plist, H5VL_PROP_DSET_LCPL_ID, &lcpl_id) < 0) + HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, H5I_INVALID_HID, "can't set property value for lcpl id") + + /* Set location parameters */ + loc_params.type = H5VL_OBJECT_BY_SELF; + loc_params.obj_type = H5I_get_type(loc_id); + /* Create the dataset */ - if(NULL == (dset = H5D__create_named(&loc, name, type_id, space, lcpl_id, dcpl_id, dapl_id))) + if(NULL == (dset = H5VL_dataset_create(vol_obj->data, loc_params, vol_obj->driver->cls, + name, dcpl_id, dapl_id, H5P_DATASET_XFER_DEFAULT, H5_REQUEST_NULL))) HGOTO_ERROR(H5E_DATASET, H5E_CANTINIT, H5I_INVALID_HID, "unable to create dataset") /* Get an atom for the dataset */ - if((ret_value = H5I_register(H5I_DATASET, dset, TRUE)) < 0) + if((ret_value = H5VL_register_id(H5I_DATASET, dset, vol_obj->driver, TRUE)) < 0) HGOTO_ERROR(H5E_ATOM, H5E_CANTREGISTER, H5I_INVALID_HID, "unable to atomize dataset handle") done: if(H5I_INVALID_HID == ret_value) - if(dset && H5D_close(dset) < 0) + if(dset && H5VL_dataset_close(dset, vol_obj->driver->cls, H5P_DATASET_XFER_DEFAULT, H5_REQUEST_NULL) < 0) HDONE_ERROR(H5E_DATASET, H5E_CLOSEERROR, H5I_INVALID_HID, "unable to release dataset") FUNC_LEAVE_API(ret_value) @@ -194,21 +211,16 @@ hid_t H5Dcreate_anon(hid_t loc_id, hid_t type_id, hid_t space_id, hid_t dcpl_id, hid_t dapl_id) { - H5G_loc_t loc; /* Object location to insert dataset into */ - H5D_t *dset = NULL; /* New dataset's info */ - const H5S_t *space; /* Dataspace for dataset */ + void *dset = NULL; /* dset token from VOL plugin */ + H5VL_object_t *vol_obj = NULL; /* object token of loc_id */ + H5VL_loc_params_t loc_params; + H5P_genplist_t *plist; /* Property list pointer */ hid_t ret_value = H5I_INVALID_HID; /* Return value */ FUNC_ENTER_API(H5I_INVALID_HID) H5TRACE5("i", "iiiii", loc_id, type_id, space_id, dcpl_id, dapl_id); /* Check arguments */ - if(H5G_loc(loc_id, &loc) < 0) - HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, H5I_INVALID_HID, "not a location ID") - if(H5I_DATATYPE != H5I_get_type(type_id)) - HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, H5I_INVALID_HID, "not a datatype ID") - if(NULL == (space = (const H5S_t *)H5I_object_verify(space_id, H5I_DATASPACE))) - HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, H5I_INVALID_HID, "not a dataspace ID") if(H5P_DEFAULT == dcpl_id) dcpl_id = H5P_DATASET_CREATE_DEFAULT; else @@ -219,31 +231,38 @@ H5Dcreate_anon(hid_t loc_id, hid_t type_id, hid_t space_id, hid_t dcpl_id, if(H5CX_set_apl(&dapl_id, H5P_CLS_DACC, loc_id, TRUE) < 0) HGOTO_ERROR(H5E_DATASET, H5E_CANTSET, H5I_INVALID_HID, "can't set access property list info") + /* get the location object */ + if(NULL == (vol_obj = (H5VL_object_t *)H5I_object(loc_id))) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, H5I_INVALID_HID, "invalid location identifier") + + /* Get the plist structure */ + if(NULL == (plist = (H5P_genplist_t *)H5I_object(dcpl_id))) + HGOTO_ERROR(H5E_ATOM, H5E_BADATOM, H5I_INVALID_HID, "can't find object for ID") + + /* set creation properties */ + if(H5P_set(plist, H5VL_PROP_DSET_TYPE_ID, &type_id) < 0) + HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, H5I_INVALID_HID, "can't set property value for datatype id") + if(H5P_set(plist, H5VL_PROP_DSET_SPACE_ID, &space_id) < 0) + HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, H5I_INVALID_HID, "can't set property value for space id") + + /* Set location parameters */ + loc_params.type = H5VL_OBJECT_BY_SELF; + loc_params.obj_type = H5I_get_type(loc_id); + /* Create the dataset */ - if(NULL == (dset = H5D__create(loc.oloc->file, type_id, space, dcpl_id, dapl_id))) + if(NULL == (dset = H5VL_dataset_create(vol_obj->data, loc_params, vol_obj->driver->cls, + NULL, dcpl_id, dapl_id, + H5P_DATASET_XFER_DEFAULT, H5_REQUEST_NULL))) HGOTO_ERROR(H5E_DATASET, H5E_CANTINIT, H5I_INVALID_HID, "unable to create dataset") /* Get an atom for the dataset */ - if((ret_value = H5I_register(H5I_DATASET, dset, TRUE)) < 0) + if((ret_value = H5VL_register_id(H5I_DATASET, dset, vol_obj->driver, TRUE)) < 0) HGOTO_ERROR(H5E_ATOM, H5E_CANTREGISTER, H5I_INVALID_HID, "unable to register dataset") done: - /* Release the dataset's object header, if it was created */ - if(dset) { - H5O_loc_t *oloc; /* Object location for dataset */ - - /* Get the new dataset's object location */ - if(NULL == (oloc = H5D_oloc(dset))) - HDONE_ERROR(H5E_DATASET, H5E_CANTGET, H5I_INVALID_HID, "unable to get object location of dataset") - - /* Decrement refcount on dataset's object header in memory */ - if(H5O_dec_rc_by_loc(oloc) < 0) - HDONE_ERROR(H5E_DATASET, H5E_CANTDEC, H5I_INVALID_HID, "unable to decrement refcount on newly created object") - } /* end if */ - /* Cleanup on failure */ if(H5I_INVALID_HID == ret_value) - if(dset && H5D_close(dset) < 0) + if(dset && H5VL_dataset_close (dset, vol_obj->driver->cls, H5P_DATASET_XFER_DEFAULT, H5_REQUEST_NULL) < 0) HDONE_ERROR(H5E_DATASET, H5E_CLOSEERROR, H5I_INVALID_HID, "unable to release dataset") FUNC_LEAVE_API(ret_value) @@ -268,16 +287,15 @@ done: hid_t H5Dopen2(hid_t loc_id, const char *name, hid_t dapl_id) { - H5D_t *dset = NULL; - H5G_loc_t loc; /* Object location of group */ + void *dset = NULL; /* dset token from VOL plugin */ + H5VL_object_t *vol_obj = NULL; /* object token of loc_id */ + H5VL_loc_params_t loc_params; hid_t ret_value = H5I_INVALID_HID; /* Return value */ FUNC_ENTER_API(H5I_INVALID_HID) H5TRACE3("i", "i*si", loc_id, name, dapl_id); /* Check args */ - if(H5G_loc(loc_id, &loc) < 0) - HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a location") if(!name) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, H5I_INVALID_HID, "name parameter cannot be NULL") if(!*name) @@ -287,17 +305,26 @@ H5Dopen2(hid_t loc_id, const char *name, hid_t dapl_id) if(H5CX_set_apl(&dapl_id, H5P_CLS_DACC, loc_id, FALSE) < 0) HGOTO_ERROR(H5E_DATASET, H5E_CANTSET, H5I_INVALID_HID, "can't set access property list info") + /* get the location object */ + if(NULL == (vol_obj = (H5VL_object_t *)H5I_object(loc_id))) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, H5I_INVALID_HID, "invalid location identifier") + + /* Set the location parameters */ + loc_params.type = H5VL_OBJECT_BY_SELF; + loc_params.obj_type = H5I_get_type(loc_id); + /* Open the dataset */ - if(NULL == (dset = H5D__open_name(&loc, name, dapl_id))) + if(NULL == (dset = H5VL_dataset_open(vol_obj->data, loc_params, vol_obj->driver->cls, name, + dapl_id, H5P_DATASET_XFER_DEFAULT, H5_REQUEST_NULL))) HGOTO_ERROR(H5E_DATASET, H5E_CANTOPENOBJ, H5I_INVALID_HID, "unable to open dataset") /* Register an atom for the dataset */ - if((ret_value = H5I_register(H5I_DATASET, dset, TRUE)) < 0) + if((ret_value = H5VL_register_id(H5I_DATASET, dset, vol_obj->driver, TRUE)) < 0) HGOTO_ERROR(H5E_ATOM, H5E_CANTREGISTER, H5I_INVALID_HID, "can't register dataset atom") done: if(H5I_INVALID_HID == ret_value) - if(dset && H5D_close(dset) < 0) + if(dset && H5VL_dataset_close(dset, vol_obj->driver->cls, H5P_DATASET_XFER_DEFAULT, H5_REQUEST_NULL) < 0) HDONE_ERROR(H5E_DATASET, H5E_CLOSEERROR, H5I_INVALID_HID, "unable to release dataset") FUNC_LEAVE_API(ret_value) } /* end H5Dopen2() */ @@ -323,7 +350,7 @@ H5Dclose(hid_t dset_id) H5TRACE1("e", "i", dset_id); /* Check args */ - if(NULL == H5I_object_verify(dset_id, H5I_DATASET)) + if(H5I_DATASET != H5I_get_type(dset_id)) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a dataset ID") /* Decrement the counter on the dataset. It will be freed if the count @@ -353,18 +380,19 @@ done: hid_t H5Dget_space(hid_t dset_id) { - H5D_t *dset = NULL; /* Dataset structure */ + H5VL_object_t *vol_obj = NULL; /* Dataset structure */ hid_t ret_value = H5I_INVALID_HID; /* Return value */ FUNC_ENTER_API(H5I_INVALID_HID) H5TRACE1("i", "i", dset_id); /* Check args */ - if(NULL == (dset = (H5D_t *)H5I_object_verify(dset_id, H5I_DATASET))) + if(NULL == (vol_obj = (H5VL_object_t *)H5I_object_verify(dset_id, H5I_DATASET))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, H5I_INVALID_HID, "invalid dataset identifier") /* Get the dataspace */ - if((ret_value = H5D__get_space(dset)) < 0) + if(H5VL_dataset_get(vol_obj->data, vol_obj->driver->cls, H5VL_DATASET_GET_SPACE, + H5P_DATASET_XFER_DEFAULT, H5_REQUEST_NULL, &ret_value) < 0) HGOTO_ERROR(H5E_DATASET, H5E_CANTGET, H5I_INVALID_HID, "unable to get dataspace") done: @@ -384,18 +412,19 @@ done: herr_t H5Dget_space_status(hid_t dset_id, H5D_space_status_t *allocation) { - H5D_t *dset = NULL; /* Dataset structure */ + H5VL_object_t *vol_obj = NULL; /* Dataset structure */ herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_API(FAIL) H5TRACE2("e", "i*Ds", dset_id, allocation); /* Check args */ - if(NULL == (dset = (H5D_t *)H5I_object_verify(dset_id, H5I_DATASET))) + if(NULL == (vol_obj = (H5VL_object_t *)H5I_object_verify(dset_id, H5I_DATASET))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "invalid dataset identifier") /* Get dataspace status */ - if(H5D__get_space_status(dset, allocation) < 0) + if((ret_value = H5VL_dataset_get(vol_obj->data, vol_obj->driver->cls, H5VL_DATASET_GET_SPACE_STATUS, + H5P_DATASET_XFER_DEFAULT, H5_REQUEST_NULL, allocation)) < 0) HGOTO_ERROR(H5E_DATASET, H5E_CANTGET, FAIL, "unable to get space status") done: @@ -419,18 +448,19 @@ done: hid_t H5Dget_type(hid_t dset_id) { - H5D_t *dset; /* Dataset structure */ + H5VL_object_t *vol_obj; /* Dataset structure */ hid_t ret_value = H5I_INVALID_HID; /* Return value */ FUNC_ENTER_API(H5I_INVALID_HID) H5TRACE1("i", "i", dset_id); /* Check args */ - if(NULL == (dset = (H5D_t *)H5I_object_verify(dset_id, H5I_DATASET))) + if(NULL == (vol_obj = (H5VL_object_t *)H5I_object_verify(dset_id, H5I_DATASET))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, H5I_INVALID_HID, "invalid dataset identifier") /* get the datatype */ - if((ret_value = H5D__get_type(dset)) < 0) + if(H5VL_dataset_get(vol_obj->data, vol_obj->driver->cls, H5VL_DATASET_GET_TYPE, + H5P_DATASET_XFER_DEFAULT, H5_REQUEST_NULL, &ret_value) < 0) HGOTO_ERROR(H5E_DATASET, H5E_CANTGET, H5I_INVALID_HID, "unable to get datatype") done: @@ -457,18 +487,19 @@ done: hid_t H5Dget_create_plist(hid_t dset_id) { - H5D_t *dataset; /* Dataset structure */ + H5VL_object_t *vol_obj; /* Dataset structure */ hid_t ret_value = H5I_INVALID_HID; /* Return value */ FUNC_ENTER_API(H5I_INVALID_HID) H5TRACE1("i", "i", dset_id); /* Check args */ - if(NULL == (dataset = (H5D_t *)H5I_object_verify(dset_id, H5I_DATASET))) + if(NULL == (vol_obj = (H5VL_object_t *)H5I_object_verify(dset_id, H5I_DATASET))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, H5I_INVALID_HID, "invalid dataset identifier") /* Get the dataset creation property list */ - if((ret_value = H5D_get_create_plist(dataset)) < 0) + if(H5VL_dataset_get(vol_obj->data, vol_obj->driver->cls, H5VL_DATASET_GET_DCPL, + H5P_DATASET_XFER_DEFAULT, H5_REQUEST_NULL, &ret_value) < 0) HGOTO_ERROR(H5E_DATASET, H5E_CANTGET, H5I_INVALID_HID, "unable to get dataset creation properties") done: @@ -512,18 +543,19 @@ done: hid_t H5Dget_access_plist(hid_t dset_id) { - H5D_t *dset; /* Dataset structure */ + H5VL_object_t *vol_obj; /* Dataset structure */ hid_t ret_value = H5I_INVALID_HID; /* Return value */ FUNC_ENTER_API(H5I_INVALID_HID) H5TRACE1("i", "i", dset_id); /* Check args */ - if(NULL == (dset = (H5D_t *)H5I_object_verify(dset_id, H5I_DATASET))) + if(NULL == (vol_obj = (H5VL_object_t *)H5I_object_verify(dset_id, H5I_DATASET))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, H5I_INVALID_HID, "invalid dataset identifier") /* Get the dataset access property list */ - if((ret_value = H5D_get_access_plist(dset)) < 0) + if(H5VL_dataset_get(vol_obj->data, vol_obj->driver->cls, H5VL_DATASET_GET_DAPL, + H5P_DATASET_XFER_DEFAULT, H5_REQUEST_NULL, &ret_value) < 0) HGOTO_ERROR(H5E_DATASET, H5E_CANTGET, H5I_INVALID_HID, "unable to get dataset access properties") done: @@ -549,18 +581,19 @@ done: hsize_t H5Dget_storage_size(hid_t dset_id) { - H5D_t *dset; /* Dataset for this operation */ + H5VL_object_t *vol_obj; /* Dataset for this operation */ hsize_t ret_value = 0; /* Return value */ FUNC_ENTER_API(0) H5TRACE1("h", "i", dset_id); /* Check args */ - if(NULL == (dset = (H5D_t *)H5I_object_verify(dset_id, H5I_DATASET))) + if(NULL == (vol_obj = (H5VL_object_t *)H5I_object_verify(dset_id, H5I_DATASET))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, 0, "invalid dataset identifier") /* Get the storage size */ - if(H5D__get_storage_size(dset, &ret_value) < 0) + if(H5VL_dataset_get(vol_obj->data, vol_obj->driver->cls, H5VL_DATASET_GET_STORAGE_SIZE, + H5P_DATASET_XFER_DEFAULT, H5_REQUEST_NULL, &ret_value) < 0) HGOTO_ERROR(H5E_DATASET, H5E_CANTGET, 0, "unable to get storage size") done: @@ -582,18 +615,20 @@ done: haddr_t H5Dget_offset(hid_t dset_id) { - H5D_t *dset; /* Dataset for this operation */ + H5VL_object_t *vol_obj; /* Dataset for this operation */ haddr_t ret_value = HADDR_UNDEF; /* Return value */ FUNC_ENTER_API(HADDR_UNDEF) H5TRACE1("a", "i", dset_id); /* Check args */ - if(NULL == (dset = (H5D_t *)H5I_object_verify(dset_id, H5I_DATASET))) + if(NULL == (vol_obj = (H5VL_object_t *)H5I_object_verify(dset_id, H5I_DATASET))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, HADDR_UNDEF, "invalid dataset identifier") /* Get the offset */ - ret_value = H5D__get_offset(dset); + if(H5VL_dataset_get(vol_obj->data, vol_obj->driver->cls, H5VL_DATASET_GET_OFFSET, + H5P_DATASET_XFER_DEFAULT, H5_REQUEST_NULL, &ret_value) < 0) + HGOTO_ERROR(H5E_DATASET, H5E_CANTGET, HADDR_UNDEF, "unable to get offset") done: FUNC_LEAVE_API(ret_value) @@ -775,8 +810,7 @@ H5Dvlen_get_buf_size(hid_t dataset_id, hid_t type_id, hid_t space_id, hsize_t *size) { H5D_vlen_bufsize_t vlen_bufsize = {0, 0, 0, 0, 0, 0}; - H5D_t *dset; /* Dataset for this operation */ - H5S_t *fspace = NULL; /* Dataset's dataspace */ + H5VL_object_t *vol_obj; /* Dataset for this operation */ H5S_t *mspace = NULL; /* Memory dataspace */ char bogus; /* bogus value to pass to H5Diterate() */ H5S_t *space; /* Dataspace for iteration */ @@ -791,7 +825,7 @@ H5Dvlen_get_buf_size(hid_t dataset_id, hid_t type_id, hid_t space_id, if(H5I_DATASET != H5I_get_type(dataset_id) || H5I_DATATYPE != H5I_get_type(type_id) || size == NULL) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "invalid argument") - if(NULL == (dset = (H5D_t *)H5I_object(dataset_id))) + if(NULL == (vol_obj = (H5VL_object_t *)H5I_object(dataset_id))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "invalid dataset identifier") if(NULL == (type = (H5T_t *)H5I_object_verify(type_id, H5I_DATATYPE))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not an valid base datatype") @@ -801,21 +835,20 @@ H5Dvlen_get_buf_size(hid_t dataset_id, hid_t type_id, hid_t space_id, HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "dataspace does not have extent set") /* Save the dataset */ - vlen_bufsize.dset = dset; + vlen_bufsize.dset_vol_obj = vol_obj; vlen_bufsize.fspace_id = H5I_INVALID_HID; vlen_bufsize.mspace_id = H5I_INVALID_HID; /* Get a copy of the dataset's dataspace */ - if(NULL == (fspace = H5S_copy(dset->shared->space, FALSE, TRUE))) + if(H5VL_dataset_get(vol_obj->data, vol_obj->driver->cls, H5VL_DATASET_GET_SPACE, + H5P_DATASET_XFER_DEFAULT, H5_REQUEST_NULL, &vlen_bufsize.fspace_id) < 0) HGOTO_ERROR(H5E_DATASET, H5E_CANTCOPY, FAIL, "can't copy dataspace") - if((vlen_bufsize.fspace_id = H5I_register(H5I_DATASPACE, fspace, TRUE)) < 0) - HGOTO_ERROR(H5E_ATOM, H5E_CANTREGISTER, FAIL, "unable to register file dataspace") /* Create a scalar for the memory dataspace */ if(NULL == (mspace = H5S_create(H5S_SCALAR))) HGOTO_ERROR(H5E_DATASPACE, H5E_CANTCREATE, FAIL, "can't create dataspace") if((vlen_bufsize.mspace_id = H5I_register(H5I_DATASPACE, mspace, TRUE)) < 0) - HGOTO_ERROR(H5E_ATOM, H5E_CANTREGISTER, FAIL, "unable to register memory dataspace") + HGOTO_ERROR(H5E_ATOM, H5E_CANTREGISTER, FAIL, "unable to register dataspace atom") /* Grab the temporary buffers required */ if(NULL == (vlen_bufsize.fl_tbuf = H5FL_BLK_MALLOC(vlen_fl_buf, (size_t)1))) @@ -842,17 +875,14 @@ H5Dvlen_get_buf_size(hid_t dataset_id, hid_t type_id, hid_t space_id, *size = vlen_bufsize.size; done: - if(ret_value < 0) { - if(fspace && H5S_close(fspace) < 0) - HDONE_ERROR(H5E_DATASPACE, H5E_CANTRELEASE, FAIL, "unable to release file dataspace") + if(ret_value < 0) if(mspace && H5S_close(mspace) < 0) - HDONE_ERROR(H5E_DATASPACE, H5E_CANTRELEASE, FAIL, "unable to release memory dataspace") - } + HDONE_ERROR(H5E_DATASPACE, H5E_CANTRELEASE, FAIL, "unable to release dataspace") if(vlen_bufsize.fspace_id && H5I_dec_app_ref(vlen_bufsize.fspace_id) < 0) - HGOTO_ERROR(H5E_DATASPACE, H5E_CANTDEC, FAIL, "problem freeing file dataspace id") + HGOTO_ERROR(H5E_DATASPACE, H5E_CANTDEC, FAIL, "problem freeing id") if(vlen_bufsize.mspace_id && H5I_dec_app_ref(vlen_bufsize.mspace_id) < 0) - HGOTO_ERROR(H5E_DATASPACE, H5E_CANTDEC, FAIL, "problem freeing memory dataspace id") + HGOTO_ERROR(H5E_DATASPACE, H5E_CANTDEC, FAIL, "problem freeing id") if(vlen_bufsize.fl_tbuf != NULL) vlen_bufsize.fl_tbuf = H5FL_BLK_FREE(vlen_fl_buf, vlen_bufsize.fl_tbuf); if(vlen_bufsize.vl_tbuf != NULL) @@ -875,14 +905,14 @@ done: herr_t H5Dset_extent(hid_t dset_id, const hsize_t size[]) { - H5D_t *dset; /* Dataset for this operation */ + H5VL_object_t *vol_obj; /* Dataset for this operation */ herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_API(FAIL) H5TRACE2("e", "i*h", dset_id, size); /* Check args */ - if(NULL == (dset = (H5D_t *)H5I_object_verify(dset_id, H5I_DATASET))) + if(NULL == (vol_obj = (H5VL_object_t *)H5I_object_verify(dset_id, H5I_DATASET))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "dset_id parameter is not a valid dataset identifier") if(!size) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "size array cannot be NULL") @@ -892,7 +922,8 @@ H5Dset_extent(hid_t dset_id, const hsize_t size[]) HGOTO_ERROR(H5E_DATASET, H5E_CANTSET, FAIL, "can't set collective metadata read info") /* Set the extent */ - if(H5D__set_extent(dset, size) < 0) + if ((ret_value = H5VL_dataset_specific(vol_obj->data, vol_obj->driver->cls, H5VL_DATASET_SET_EXTENT, + H5P_DATASET_XFER_DEFAULT, H5_REQUEST_NULL, size)) < 0) HGOTO_ERROR(H5E_DATASET, H5E_CANTSET, FAIL, "unable to set dataset extent") done: @@ -912,22 +943,26 @@ done: herr_t H5Dflush(hid_t dset_id) { - H5D_t *dset; /* Dataset for this operation */ + H5VL_object_t *vol_obj; /* Dataset for this operation */ herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_API(FAIL) H5TRACE1("e", "i", dset_id); /* Check args */ - if(NULL == (dset = (H5D_t *)H5I_object_verify(dset_id, H5I_DATASET))) + if(NULL == (vol_obj = (H5VL_object_t *)H5I_object_verify(dset_id, H5I_DATASET))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "dset_id parameter is not a valid dataset identifier") /* Set up collective metadata if appropriate */ if(H5CX_set_loc(dset_id) < 0) HGOTO_ERROR(H5E_DATASET, H5E_CANTSET, FAIL, "can't set collective metadata read info") - /* Flush dataset information cached in memory */ - if(H5D__flush(dset, dset_id) < 0) + /* Flush dataset information cached in memory + * XXX: Note that we need to pass the ID to the VOL since the H5F_flush_cb_t + * callback needs it and that's in the public API. + */ + if((ret_value = H5VL_dataset_specific(vol_obj->data, vol_obj->driver->cls, H5VL_DATASET_FLUSH, + H5P_DATASET_XFER_DEFAULT, H5_REQUEST_NULL, dset_id)) < 0) HGOTO_ERROR(H5E_DATASET, H5E_CANTFLUSH, FAIL, "unable to flush dataset") done: @@ -947,14 +982,14 @@ done: herr_t H5Drefresh(hid_t dset_id) { - H5D_t *dset; /* Dataset for this operation */ + H5VL_object_t *vol_obj; /* Dataset for this operation */ herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_API(FAIL) H5TRACE1("e", "i", dset_id); /* Check args */ - if(NULL == (dset = (H5D_t *)H5I_object_verify(dset_id, H5I_DATASET))) + if(NULL == (vol_obj = (H5VL_object_t *)H5I_object_verify(dset_id, H5I_DATASET))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "dset_id parameter is not a valid dataset identifier") /* Set up collective metadata if appropriate */ @@ -962,7 +997,8 @@ H5Drefresh(hid_t dset_id) HGOTO_ERROR(H5E_DATASET, H5E_CANTSET, FAIL, "can't set collective metadata read info") /* Refresh the dataset object */ - if((H5D__refresh(dset_id, dset)) < 0) + if((ret_value = H5VL_dataset_specific(vol_obj->data, vol_obj->driver->cls, H5VL_DATASET_REFRESH, + H5P_DATASET_XFER_DEFAULT, H5_REQUEST_NULL, dset_id)) < 0) HGOTO_ERROR(H5E_DATASET, H5E_CANTLOAD, FAIL, "unable to refresh dataset") done: @@ -990,47 +1026,24 @@ done: herr_t H5Dformat_convert(hid_t dset_id) { - H5D_t *dset; /* Dataset for this operation */ + H5VL_object_t *vol_obj; /* Dataset for this operation */ herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_API(FAIL) H5TRACE1("e", "i", dset_id); /* Check args */ - if(NULL == (dset = (H5D_t *)H5I_object_verify(dset_id, H5I_DATASET))) + if(NULL == (vol_obj = (H5VL_object_t *)H5I_object_verify(dset_id, H5I_DATASET))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "dset_id parameter is not a valid dataset identifier") /* Set up collective metadata if appropriate */ if(H5CX_set_loc(dset_id) < 0) HGOTO_ERROR(H5E_DATASET, H5E_CANTSET, FAIL, "can't set collective metadata read info") - switch(dset->shared->layout.type) { - case H5D_CHUNKED: - /* Convert the chunk indexing type to version 1 B-tree if not */ - if(dset->shared->layout.u.chunk.idx_type != H5D_CHUNK_IDX_BTREE) - if((H5D__format_convert(dset)) < 0) - HGOTO_ERROR(H5E_DATASET, H5E_CANTLOAD, FAIL, "unable to downgrade chunk indexing type for dataset") - break; - - case H5D_CONTIGUOUS: - case H5D_COMPACT: - /* Downgrade the layout version to 3 if greater than 3 */ - if(dset->shared->layout.version > H5O_LAYOUT_VERSION_DEFAULT) - if((H5D__format_convert(dset)) < 0) - HGOTO_ERROR(H5E_DATASET, H5E_CANTLOAD, FAIL, "unable to downgrade layout version for dataset") - break; - - case H5D_VIRTUAL: - /* Nothing to do even though layout is version 4 */ - break; - - case H5D_LAYOUT_ERROR: - case H5D_NLAYOUTS: - HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "invalid dataset layout type") - - default: - HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "unknown dataset layout type") - } /* end switch */ + /* Convert the dataset */ + if(H5VL_dataset_optional(vol_obj->data, vol_obj->driver->cls, H5P_DATASET_XFER_DEFAULT, + H5_REQUEST_NULL, H5VL_DATASET_FORMAT_CONVERT) < 0) + HGOTO_ERROR(H5E_DATASET, H5E_INTERNAL, FAIL, "can't convert dataset format") done: FUNC_LEAVE_API(ret_value) @@ -1052,25 +1065,22 @@ done: herr_t H5Dget_chunk_index_type(hid_t dset_id, H5D_chunk_index_t *idx_type) { - H5D_t *dset; /* Dataset for this operation */ + H5VL_object_t *vol_obj; /* Dataset for this operation */ herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_API(FAIL) H5TRACE2("e", "i*Dk", dset_id, idx_type); /* Check args */ - if(NULL == (dset = (H5D_t *)H5I_object_verify(dset_id, H5I_DATASET))) + if(NULL == (vol_obj = (H5VL_object_t *)H5I_object_verify(dset_id, H5I_DATASET))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "dset_id parameter is not a valid dataset identifier") if(NULL == idx_type) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "idx_type parameter cannot be NULL") - /* Should be a chunked dataset */ - if(dset->shared->layout.type != H5D_CHUNKED) - HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "dataset is not chunked") - /* Get the chunk indexing type */ - if(idx_type) - *idx_type = dset->shared->layout.u.chunk.idx_type; + if(H5VL_dataset_optional(vol_obj->data, vol_obj->driver->cls, H5P_DATASET_XFER_DEFAULT, + H5_REQUEST_NULL, H5VL_DATASET_GET_CHUNK_INDEX_TYPE, idx_type) < 0) + HGOTO_ERROR(H5E_DATASET, H5E_CANTGET, FAIL, "can't get chunk index type") done: FUNC_LEAVE_API(ret_value) @@ -1095,25 +1105,23 @@ done: herr_t H5Dget_chunk_storage_size(hid_t dset_id, const hsize_t *offset, hsize_t *chunk_nbytes) { - H5D_t *dset; /* Dataset for this operation */ + H5VL_object_t *vol_obj; /* Dataset for this operation */ herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_API(FAIL) H5TRACE3("e", "i*h*h", dset_id, offset, chunk_nbytes); /* Check arguments */ - if(NULL == (dset = (H5D_t *)H5I_object_verify(dset_id, H5I_DATASET))) + if(NULL == (vol_obj = (H5VL_object_t *)H5I_object_verify(dset_id, H5I_DATASET))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "dset_id parameter is not a valid dataset identifier") if(NULL == offset) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "offset parameter cannot be NULL") if(NULL == chunk_nbytes) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "chunk_nbytes parameter cannot be NULL") - if(H5D_CHUNKED != dset->shared->layout.type) - HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a chunked dataset") - /* Get the dataset creation property list */ - if(H5D__get_chunk_storage_size(dset, offset, chunk_nbytes) < 0) + if(H5VL_dataset_optional(vol_obj->data, vol_obj->driver->cls, H5P_DATASET_XFER_DEFAULT, + H5_REQUEST_NULL, H5VL_DATASET_GET_CHUNK_STORAGE_SIZE, offset, chunk_nbytes) < 0) HGOTO_ERROR(H5E_DATASET, H5E_CANTGET, FAIL, "can't get storage size of chunk") done: diff --git a/src/H5Ddbg.c b/src/H5Ddbg.c index 7220868..d11a5d8 100644 --- a/src/H5Ddbg.c +++ b/src/H5Ddbg.c @@ -26,6 +26,7 @@ #include "H5Dpkg.h" /* Datasets */ #include "H5Eprivate.h" /* Error handling */ #include "H5Iprivate.h" /* IDs */ +#include "H5VLprivate.h" /* Virtual Object Layer */ /****************/ @@ -79,7 +80,7 @@ H5Ddebug(hid_t dset_id) H5TRACE1("e", "i", dset_id); /* Check args */ - if(NULL == (dset = (H5D_t *)H5I_object_verify(dset_id, H5I_DATASET))) + if(NULL == (dset = (H5D_t *)H5VL_object_verify(dset_id, H5I_DATASET))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a dataset") /* Print B-tree information */ diff --git a/src/H5Ddeprec.c b/src/H5Ddeprec.c index ed520c4..4abba93 100644 --- a/src/H5Ddeprec.c +++ b/src/H5Ddeprec.c @@ -40,6 +40,7 @@ #include "H5Dpkg.h" /* Datasets */ #include "H5Eprivate.h" /* Error handling */ #include "H5Iprivate.h" /* IDs */ +#include "H5VLprivate.h" /* VOL plugins */ /****************/ @@ -112,9 +113,11 @@ hid_t H5Dcreate1(hid_t loc_id, const char *name, hid_t type_id, hid_t space_id, hid_t dcpl_id) { - H5G_loc_t loc; /* Object location to insert dataset into */ - H5D_t *dset = NULL; /* New dataset's info */ - const H5S_t *space; /* Dataspace for dataset */ + void *dset = NULL; /* dset token from VOL plugin */ + H5VL_object_t *vol_obj = NULL; /* object token of loc_id */ + H5VL_loc_params_t loc_params; + H5P_genplist_t *plist; /* Property list pointer */ + hid_t lcpl_id = H5P_LINK_CREATE_DEFAULT; hid_t dapl_id = H5P_DEFAULT; /* DAPL used by library */ hid_t ret_value = H5I_INVALID_HID; /* Return value */ @@ -126,12 +129,7 @@ H5Dcreate1(hid_t loc_id, const char *name, hid_t type_id, hid_t space_id, HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, H5I_INVALID_HID, "name parameter cannot be NULL") if(!*name) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, H5I_INVALID_HID, "name parameter cannot be an empty string") - if(H5G_loc(loc_id, &loc) < 0) - HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, H5I_INVALID_HID, "not a location ID") - if(H5I_DATATYPE != H5I_get_type(type_id)) - HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, H5I_INVALID_HID, "not a datatype ID") - if(NULL == (space = (const H5S_t *)H5I_object_verify(space_id,H5I_DATASPACE))) - HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, H5I_INVALID_HID, "not a dataspace ID") + if(H5P_DEFAULT == dcpl_id) dcpl_id = H5P_DATASET_CREATE_DEFAULT; else @@ -142,17 +140,38 @@ H5Dcreate1(hid_t loc_id, const char *name, hid_t type_id, hid_t space_id, if(H5CX_set_apl(&dapl_id, H5P_CLS_DACC, loc_id, TRUE) < 0) HGOTO_ERROR(H5E_DATASET, H5E_CANTSET, H5I_INVALID_HID, "can't set access property list info") - /* Build and open the new dataset */ - if(NULL == (dset = H5D__create_named(&loc, name, type_id, space, H5P_LINK_CREATE_DEFAULT, dcpl_id, dapl_id))) + /* Get the plist structure */ + if(NULL == (plist = (H5P_genplist_t *)H5I_object(dcpl_id))) + HGOTO_ERROR(H5E_ATOM, H5E_BADATOM, H5I_INVALID_HID, "can't find object for ID") + + /* set creation properties */ + if(H5P_set(plist, H5VL_PROP_DSET_TYPE_ID, &type_id) < 0) + HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, H5I_INVALID_HID, "can't set property value for datatype id") + if(H5P_set(plist, H5VL_PROP_DSET_SPACE_ID, &space_id) < 0) + HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, H5I_INVALID_HID, "can't set property value for space id") + if(H5P_set(plist, H5VL_PROP_DSET_LCPL_ID, &lcpl_id) < 0) + HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, H5I_INVALID_HID, "can't set property value for lcpl id") + + /* Set location parameters */ + loc_params.type = H5VL_OBJECT_BY_SELF; + loc_params.obj_type = H5I_get_type(loc_id); + + /* get the location object */ + if(NULL == (vol_obj = H5VL_get_object(loc_id))) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, H5I_INVALID_HID, "invalid location identifier") + + /* Create the dataset through the VOL */ + if(NULL == (dset = H5VL_dataset_create(vol_obj->data, loc_params, vol_obj->driver->cls, name, dcpl_id, + H5P_DATASET_ACCESS_DEFAULT, H5P_DATASET_XFER_DEFAULT, H5_REQUEST_NULL))) HGOTO_ERROR(H5E_DATASET, H5E_CANTINIT, H5I_INVALID_HID, "unable to create dataset") /* Get an atom for the dataset */ - if((ret_value = H5I_register(H5I_DATASET, dset, TRUE)) < 0) + if((ret_value = H5VL_register_id(H5I_DATASET, dset, vol_obj->driver, TRUE)) < 0) HGOTO_ERROR(H5E_ATOM, H5E_CANTREGISTER, H5I_INVALID_HID, "unable to register dataset") done: if (H5I_INVALID_HID == ret_value) - if(dset && H5D_close(dset) < 0) + if(dset && H5VL_dataset_close(dset, vol_obj->driver->cls, H5P_DATASET_XFER_DEFAULT, H5_REQUEST_NULL) < 0) HDONE_ERROR(H5E_DATASET, H5E_CLOSEERROR, H5I_INVALID_HID, "unable to release dataset") FUNC_LEAVE_API(ret_value) @@ -179,8 +198,9 @@ done: hid_t H5Dopen1(hid_t loc_id, const char *name) { - H5D_t *dset = NULL; - H5G_loc_t loc; /* Object location of group */ + void *dset = NULL; /* dset token from VOL plugin */ + H5VL_object_t *vol_obj = NULL; /* object token of loc_id */ + H5VL_loc_params_t loc_params; hid_t ret_value = H5I_INVALID_HID; /* Return value */ FUNC_ENTER_API(H5I_INVALID_HID) @@ -191,20 +211,27 @@ H5Dopen1(hid_t loc_id, const char *name) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, H5I_INVALID_HID, "name parameter cannot be NULL") if (!*name) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, H5I_INVALID_HID, "name parameter cannot be an empty string") - if(H5G_loc(loc_id, &loc) < 0) - HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, H5I_INVALID_HID, "not a location") + + /* Set location parameters */ + loc_params.type = H5VL_OBJECT_BY_SELF; + loc_params.obj_type = H5I_get_type(loc_id); + + /* get the location object */ + if(NULL == (vol_obj = H5VL_get_object(loc_id))) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, H5I_INVALID_HID, "invalid location identifier") /* Open the dataset */ - if(NULL == (dset = H5D__open_name(&loc, name, H5P_DATASET_ACCESS_DEFAULT))) + if(NULL == (dset = H5VL_dataset_open(vol_obj->data, loc_params, vol_obj->driver->cls, name, + H5P_DATASET_ACCESS_DEFAULT, H5P_DATASET_XFER_DEFAULT, H5_REQUEST_NULL))) HGOTO_ERROR(H5E_DATASET, H5E_CANTOPENOBJ, H5I_INVALID_HID, "unable to open dataset") /* Get an atom for the dataset */ - if((ret_value = H5I_register(H5I_DATASET, dset, TRUE)) < 0) + if((ret_value = H5VL_register_id(H5I_DATASET, dset, vol_obj->driver, TRUE)) < 0) HGOTO_ERROR(H5E_ATOM, H5E_CANTREGISTER, H5I_INVALID_HID, "can't register dataset atom") done: if(H5I_INVALID_HID == ret_value) - if(dset && H5D_close(dset) < 0) + if(dset && H5VL_dataset_close(dset, vol_obj->driver->cls, H5P_DATASET_XFER_DEFAULT, H5_REQUEST_NULL) < 0) HDONE_ERROR(H5E_DATASET, H5E_CLOSEERROR, H5I_INVALID_HID, "unable to release dataset") FUNC_LEAVE_API(ret_value) @@ -230,37 +257,64 @@ done: herr_t H5Dextend(hid_t dset_id, const hsize_t size[]) { - H5D_t *dset; /* Pointer to dataset to modify */ - hsize_t dset_dims[H5S_MAX_RANK]; /* Current dataset dimensions */ - unsigned u; /* Local index variable */ - herr_t ret_value = SUCCEED; /* Return value */ + H5VL_object_t *vol_obj = NULL; /* Dataset structure */ + hid_t sid = H5I_INVALID_HID; /* Dataspace ID */ + H5S_t *ds = NULL; /* Dataspace struct */ + int ndims; /* Dataset/space rank */ + hsize_t dset_dims[H5S_MAX_RANK]; /* Current dataset dimensions */ + int i; /* Local index variable */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_API(FAIL) H5TRACE2("e", "i*h", dset_id, size); /* Check args */ - if(NULL == (dset = (H5D_t *)H5I_object_verify(dset_id, H5I_DATASET))) - HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a dataset") + if(NULL == (vol_obj = (H5VL_object_t *)H5I_object_verify(dset_id, H5I_DATASET))) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "invalid dataset identifier") if(!size) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "no size specified") - /* Make certain that the dataset dimensions don't decrease */ - /* (Shrinking dimensions is possible with H5Dset_extent, but not H5Dextend) */ - if(H5S_get_simple_extent_dims(dset->shared->space, dset_dims, NULL) < 0) + /* Get the dataspace pointer for the dataset */ + if(H5VL_dataset_get(vol_obj->data, vol_obj->driver->cls, H5VL_DATASET_GET_SPACE, + H5P_DATASET_XFER_DEFAULT, H5_REQUEST_NULL, &sid) < 0) + HGOTO_ERROR(H5E_DATASET, H5E_CANTGET, FAIL, "unable to get dataspace") + if(H5I_INVALID_HID == sid) + HGOTO_ERROR(H5E_DATASET, H5E_CANTGET, FAIL, "received an invalid dataspace from the dataset") + if(NULL == (ds = (H5S_t *)H5I_object_verify(sid, H5I_DATASPACE))) + HGOTO_ERROR(H5E_DATASET, H5E_CANTGET, FAIL, "couldn't get dataspace structure from ID") + + /* Get the dataset's current extent */ + if(H5S_get_simple_extent_dims(ds, dset_dims, NULL) < 0) HGOTO_ERROR(H5E_DATASET, H5E_CANTGET, FAIL, "can't get dataset dimensions") - for(u = 0; u < dset->shared->ndims; u++) - if(size[u] > dset_dims[u]) - dset_dims[u] = size[u]; + + /* Get the dataset dimensions */ + ndims = H5S_GET_EXTENT_NDIMS(ds); + + /* Make certain that the dataset dimensions don't decrease in any dimension. + * + * (Shrinking dimensions is possible with H5Dset_extent, but not H5Dextend) + * + * XXX (VOL_MERGE): I feel like we should fail here instead of just silently + * not doing what we're supposed to do. + */ + for(i = 0; i < ndims; i++) + if(size[i] > dset_dims[i]) + dset_dims[i] = size[i]; /* Set up collective metadata if appropriate */ if(H5CX_set_loc(dset_id) < 0) HGOTO_ERROR(H5E_DATASET, H5E_CANTSET, FAIL, "can't set collective metadata read info") /* Increase size */ - if(H5D__set_extent(dset, dset_dims) < 0) - HGOTO_ERROR(H5E_DATASET, H5E_CANTINIT, FAIL, "unable to extend dataset") + if ((ret_value = H5VL_dataset_specific(vol_obj->data, vol_obj->driver->cls, H5VL_DATASET_SET_EXTENT, + H5P_DATASET_XFER_DEFAULT, H5_REQUEST_NULL, dset_dims)) < 0) + HGOTO_ERROR(H5E_DATASET, H5E_CANTSET, FAIL, "unable to extend dataset") done: + /* Close the dataspace */ + if(sid != H5I_INVALID_HID && H5I_dec_app_ref(sid) < 0) + HDONE_ERROR(H5E_DATASET, H5E_CLOSEERROR, FAIL, "can't close dataspace") + FUNC_LEAVE_API(ret_value) } /* end H5Dextend() */ #endif /* H5_NO_DEPRECATED_SYMBOLS */ diff --git a/src/H5Dint.c b/src/H5Dint.c index 9af391e..3436105 100644 --- a/src/H5Dint.c +++ b/src/H5Dint.c @@ -30,6 +30,8 @@ #include "H5Iprivate.h" /* IDs */ #include "H5Lprivate.h" /* Links */ #include "H5MMprivate.h" /* Memory management */ +#include "H5VLprivate.h" /* Virtual Object Layer */ +#include "H5VLnative.h" /* Native VOL driver */ /****************/ @@ -57,7 +59,7 @@ static herr_t H5D__open_oid(H5D_t *dataset, hid_t dapl_id); static herr_t H5D__init_storage(const H5D_io_info_t *io_info, hbool_t full_overwrite, hsize_t old_dim[]); static herr_t H5D__append_flush_setup(H5D_t *dset, hid_t dapl_id); -static herr_t H5D__close_cb(H5D_t *dset); +static herr_t H5D__close_cb(H5VL_object_t *dset_vol_obj); /*********************/ @@ -289,23 +291,29 @@ H5D_term_package(void) *------------------------------------------------------------------------- */ static herr_t -H5D__close_cb(H5D_t *dset) +H5D__close_cb(H5VL_object_t *dset_vol_obj) { herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_STATIC /* Sanity check */ - HDassert(dset); - HDassert(dset->oloc.file); - HDassert(dset->shared); - HDassert(dset->shared->fo_count > 0); + HDassert(dset_vol_obj); /* Close the dataset */ - if(H5D_close(dset) < 0) + if(H5VL_dataset_close(dset_vol_obj->data, dset_vol_obj->driver->cls, H5P_DATASET_XFER_DEFAULT, H5_REQUEST_NULL) < 0) HGOTO_ERROR(H5E_DATASET, H5E_CLOSEERROR, FAIL, "unable to close dataset"); done: + /* XXX: (MSC) Weird thing for datasets and filters: + * Always decrement the ref count on the VOL for datasets, since + * the ID is removed even if the close fails. + */ + + /* Free the VOL object */ + if(H5VL_free_object(dset_vol_obj) < 0) + HGOTO_ERROR(H5E_DATASET, H5E_CANTDEC, FAIL, "unable to free VOL object"); + FUNC_LEAVE_NOAPI(ret_value) } /* end H5D__close_cb() */ @@ -943,7 +951,8 @@ H5D_t * H5D__create(H5F_t *file, hid_t type_id, const H5S_t *space, hid_t dcpl_id, hid_t dapl_id) { - const H5T_t *type; /* Datatype for dataset */ + const H5T_t *type = NULL; /* Datatype for dataset (VOL pointer) */ + H5T_t *dt = NULL; /* Datatype for dataset (non-VOL pointer) */ H5D_t *new_dset = NULL; H5P_genplist_t *dc_plist = NULL; /* New Property list */ hbool_t has_vl_type = FALSE; /* Flag to indicate a VL-type for dataset */ @@ -964,8 +973,10 @@ H5D__create(H5F_t *file, hid_t type_id, const H5S_t *space, hid_t dcpl_id, HDassert(H5I_GENPROP_LST == H5I_get_type(dcpl_id)); /* Get the dataset's datatype */ - if(NULL == (type = (const H5T_t *)H5I_object(type_id))) + if(NULL == (dt = (const H5T_t *)H5I_object(type_id))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, NULL, "not a datatype") + /* If this is a named datatype, get the pointer via the VOL driver */ + type = (const H5T_t *)H5T_get_actual_type(dt); /* Check if the datatype is "sensible" for use in a dataset */ if(H5T_is_sensible(type) != TRUE) @@ -1812,11 +1823,13 @@ H5D_mult_refresh_close(hid_t dset_id) FUNC_ENTER_NOAPI(FAIL) - if(NULL == (dataset = (H5D_t *)H5I_object_verify(dset_id, H5I_DATASET))) + if(NULL == (dataset = (H5D_t *)H5VL_object_verify(dset_id, H5I_DATASET))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a dataset") /* check args */ - HDassert(dataset && dataset->oloc.file && dataset->shared); + HDassert(dataset); + HDassert(dataset->oloc.file); + HDassert(dataset->shared); HDassert(dataset->shared->fo_count > 0); if(dataset->shared->fo_count > 1) { @@ -2422,8 +2435,8 @@ H5D__vlen_get_buf_size(void H5_ATTR_UNUSED *elem, hid_t type_id, unsigned H5_ATTR_UNUSED ndim, const hsize_t *point, void *op_data) { H5D_vlen_bufsize_t *vlen_bufsize = (H5D_vlen_bufsize_t *)op_data; + H5VL_object_t *vol_obj = vlen_bufsize->dset_vol_obj; H5T_t *dt; /* Datatype for operation */ - H5S_t *mspace; /* Memory dataspace for operation */ H5S_t *fspace; /* File dataspace for operation */ herr_t ret_value = SUCCEED; /* Return value */ @@ -2440,10 +2453,6 @@ H5D__vlen_get_buf_size(void H5_ATTR_UNUSED *elem, hid_t type_id, if(NULL == (vlen_bufsize->fl_tbuf = H5FL_BLK_REALLOC(vlen_fl_buf, vlen_bufsize->fl_tbuf, H5T_get_size(dt)))) HGOTO_ERROR(H5E_DATASET, H5E_NOSPACE, FAIL, "can't resize tbuf") - /* Get the memory dataspace from the ID */ - if(NULL == (mspace = (H5S_t *)H5I_object_verify(vlen_bufsize->mspace_id, H5I_DATASPACE))) - HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a dataspace") - /* Select point to read in */ if(NULL == (fspace = (H5S_t *)H5I_object_verify(vlen_bufsize->fspace_id, H5I_DATASPACE))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a dataspace") @@ -2451,7 +2460,10 @@ H5D__vlen_get_buf_size(void H5_ATTR_UNUSED *elem, hid_t type_id, HGOTO_ERROR(H5E_DATASET, H5E_CANTCREATE, FAIL, "can't select point") /* Read in the point (with the custom VL memory allocator) */ - if(H5D__read(vlen_bufsize->dset, type_id, mspace, fspace, vlen_bufsize->fl_tbuf) < 0) + if(H5VL_dataset_read(vol_obj->data, vol_obj->driver->cls, + type_id, vlen_bufsize->mspace_id, + vlen_bufsize->fspace_id, H5P_DATASET_XFER_DEFAULT, + vlen_bufsize->fl_tbuf, H5_REQUEST_NULL) < 0) HGOTO_ERROR(H5E_DATASET, H5E_READERROR, FAIL, "can't read point") done: @@ -3384,8 +3396,19 @@ H5D__get_type(const H5D_t *dset) if(H5T_lock(dt, FALSE) < 0) HGOTO_ERROR(H5E_DATASET, H5E_CANTINIT, FAIL, "unable to lock transient datatype") - if((ret_value = H5I_register(H5I_DATATYPE, dt, TRUE)) < 0) - HGOTO_ERROR(H5E_ATOM, H5E_CANTREGISTER, FAIL, "unable to register datatype") + /* Create an atom */ + if(H5T_is_named(dt)) { + /* If this is a committed datatype, we need to recreate the + * two-level IDs, where the VOL object is a copy of the + * returned datatype. + */ + if((ret_value = H5VL_native_register(H5I_DATATYPE, dt, TRUE)) < 0) + HGOTO_ERROR(H5E_ATOM, H5E_CANTREGISTER, FAIL, "unable to register datatype") + } + else { + if((ret_value = H5I_register(H5I_DATATYPE, dt, TRUE)) < 0) + HGOTO_ERROR(H5E_ATOM, H5E_CANTREGISTER, FAIL, "unable to register datatype") + } done: if(ret_value < 0) diff --git a/src/H5Dio.c b/src/H5Dio.c index 88a9e4b..b6d4f1b 100644 --- a/src/H5Dio.c +++ b/src/H5Dio.c @@ -163,26 +163,22 @@ herr_t H5Dread(hid_t dset_id, hid_t mem_type_id, hid_t mem_space_id, hid_t file_space_id, hid_t dxpl_id, void *buf/*out*/) { - H5D_t *dset = NULL; - const H5S_t *mem_space = NULL; - const H5S_t *file_space = NULL; + H5VL_object_t *vol_obj = NULL; herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_API(FAIL) H5TRACE6("e", "iiiiix", dset_id, mem_type_id, mem_space_id, file_space_id, dxpl_id, buf); + /* Check arguments */ + if (mem_space_id < 0) + HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "invalid memory dataspace ID") + if (file_space_id < 0) + HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "invalid file dataspace ID") + /* Get dataset pointer */ - if (NULL == (dset = (H5D_t *)H5I_object_verify(dset_id, H5I_DATASET))) + if (NULL == (vol_obj = (H5VL_object_t *)H5I_object_verify(dset_id, H5I_DATASET))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "dset_id is not a dataset ID") - if (NULL == dset->oloc.file) - HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "dataset is not associated with a file") - - /* Get validated dataspace pointers */ - if (H5S_get_validated_dataspace(mem_space_id, &mem_space) < 0) - HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "could not get a validated dataspace from mem_space_id") - if (H5S_get_validated_dataspace(file_space_id, &file_space) < 0) - HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "could not get a validated dataspace from file_space_id") /* Get the default dataset transfer property list if the user didn't provide one */ if (H5P_DEFAULT == dxpl_id) @@ -195,7 +191,8 @@ H5Dread(hid_t dset_id, hid_t mem_type_id, hid_t mem_space_id, H5CX_set_dxpl(dxpl_id); /* Read the data */ - if (H5D__read(dset, mem_type_id, mem_space, file_space, buf/*out*/) < 0) + if ((ret_value = H5VL_dataset_read(vol_obj->data, vol_obj->driver->cls, mem_type_id, mem_space_id, + file_space_id, dxpl_id, buf, H5_REQUEST_NULL)) < 0) HGOTO_ERROR(H5E_DATASET, H5E_READERROR, FAIL, "can't read data") done: @@ -219,20 +216,15 @@ herr_t H5Dread_chunk(hid_t dset_id, hid_t dxpl_id, const hsize_t *offset, uint32_t *filters, void *buf) { - H5D_t *dset = NULL; - hsize_t offset_copy[H5O_LAYOUT_NDIMS]; /* Internal copy of chunk offset */ + H5VL_object_t *vol_obj = NULL; herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_API(FAIL) H5TRACE5("e", "ii*h*Iu*x", dset_id, dxpl_id, offset, filters, buf); /* Check arguments */ - if (NULL == (dset = (H5D_t *)H5I_object_verify(dset_id, H5I_DATASET))) + if (NULL == (vol_obj = (H5VL_object_t *)H5I_object_verify(dset_id, H5I_DATASET))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "dset_id is not a dataset ID") - if (NULL == dset->oloc.file) - HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "dataset is not associated with a file") - if (H5D_CHUNKED != dset->shared->layout.type) - HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a chunked dataset") if (!buf) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "buf cannot be NULL") if (!offset) @@ -250,14 +242,9 @@ H5Dread_chunk(hid_t dset_id, hid_t dxpl_id, const hsize_t *offset, uint32_t *fil /* Set DXPL for operation */ H5CX_set_dxpl(dxpl_id); - /* Copy the user's offset array so we can be sure it's terminated properly. - * (we don't want to mess with the user's buffer). - */ - if (H5D__get_offset_copy(dset, offset, offset_copy) < 0) - HGOTO_ERROR(H5E_DATASET, H5E_CANTALLOC, FAIL, "failure to copy offset array") - /* Read the raw chunk */ - if (H5D__chunk_direct_read(dset, offset_copy, filters, buf) < 0) + if (H5VL_dataset_optional(vol_obj->data, vol_obj->driver->cls, dxpl_id, + H5_REQUEST_NULL, H5VL_DATASET_CHUNK_READ, offset, filters, buf) < 0) HGOTO_ERROR(H5E_DATASET, H5E_READERROR, FAIL, "can't read unprocessed chunk data") done: @@ -298,28 +285,24 @@ done: */ herr_t H5Dwrite(hid_t dset_id, hid_t mem_type_id, hid_t mem_space_id, - hid_t file_space_id, hid_t dxpl_id, const void *buf) + hid_t file_space_id, hid_t dxpl_id, const void *buf) { - H5D_t *dset = NULL; - const H5S_t *mem_space = NULL; - const H5S_t *file_space = NULL; + H5VL_object_t *vol_obj = NULL; herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_API(FAIL) H5TRACE6("e", "iiiii*x", dset_id, mem_type_id, mem_space_id, file_space_id, dxpl_id, buf); + /* Check arguments */ + if (mem_space_id < 0) + HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "invalid memory dataspace ID") + if (file_space_id < 0) + HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "invalid file dataspace ID") + /* Get dataset pointer */ - if (NULL == (dset = (H5D_t *)H5I_object_verify(dset_id, H5I_DATASET))) + if (NULL == (vol_obj = (H5VL_object_t *)H5I_object_verify(dset_id, H5I_DATASET))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "dset_id is not a dataset ID") - if (NULL == dset->oloc.file) - HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "dataset is not associated with a file") - - /* Get validated dataspace pointers */ - if (H5S_get_validated_dataspace(mem_space_id, &mem_space) < 0) - HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "could not get a validated dataspace from mem_space_id") - if (H5S_get_validated_dataspace(file_space_id, &file_space) < 0) - HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "could not get a validated dataspace from file_space_id") /* Get the default dataset transfer property list if the user didn't provide one */ if (H5P_DEFAULT == dxpl_id) @@ -332,7 +315,8 @@ H5Dwrite(hid_t dset_id, hid_t mem_type_id, hid_t mem_space_id, H5CX_set_dxpl(dxpl_id); /* Write the data */ - if (H5D__write(dset, mem_type_id, mem_space, file_space, buf) < 0) + if ((ret_value = H5VL_dataset_write(vol_obj->data, vol_obj->driver->cls, mem_type_id, mem_space_id, + file_space_id, dxpl_id, buf, H5_REQUEST_NULL)) < 0) HGOTO_ERROR(H5E_DATASET, H5E_WRITEERROR, FAIL, "can't write data") done: @@ -356,8 +340,7 @@ herr_t H5Dwrite_chunk(hid_t dset_id, hid_t dxpl_id, uint32_t filters, const hsize_t *offset, size_t data_size, const void *buf) { - H5D_t *dset = NULL; - hsize_t offset_copy[H5O_LAYOUT_NDIMS]; /* Internal copy of chunk offset */ + H5VL_object_t *vol_obj = NULL; uint32_t data_size_32; /* Chunk data size (limited to 32-bits currently) */ herr_t ret_value = SUCCEED; /* Return value */ @@ -365,12 +348,8 @@ H5Dwrite_chunk(hid_t dset_id, hid_t dxpl_id, uint32_t filters, const hsize_t *of H5TRACE6("e", "iiIu*hz*x", dset_id, dxpl_id, filters, offset, data_size, buf); /* Check arguments */ - if (NULL == (dset = (H5D_t *)H5I_object_verify(dset_id, H5I_DATASET))) + if (NULL == (vol_obj = (H5VL_object_t *)H5I_object_verify(dset_id, H5I_DATASET))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "invalid dataset ID") - if (NULL == dset->oloc.file) - HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "dataset is not associated with a file") - if (H5D_CHUNKED != dset->shared->layout.type) - HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a chunked dataset") if (!buf) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "buf cannot be NULL") if (!offset) @@ -393,14 +372,9 @@ H5Dwrite_chunk(hid_t dset_id, hid_t dxpl_id, uint32_t filters, const hsize_t *of /* Set DXPL for operation */ H5CX_set_dxpl(dxpl_id); - /* Copy the user's offset array so we can be sure it's terminated properly. - * (we don't want to mess with the user's buffer). - */ - if (H5D__get_offset_copy(dset, offset, offset_copy) < 0) - HGOTO_ERROR(H5E_DATASET, H5E_CANTALLOC, FAIL, "failure to copy offset array") - /* Write chunk */ - if (H5D__chunk_direct_write(dset, filters, offset_copy, data_size_32, buf) < 0) + if (H5VL_dataset_optional(vol_obj->data, vol_obj->driver->cls, dxpl_id, + H5_REQUEST_NULL, H5VL_DATASET_CHUNK_WRITE, filters, offset, data_size_32, buf) < 0) HGOTO_ERROR(H5E_DATASET, H5E_WRITEERROR, FAIL, "can't write unprocessed chunk data") done: diff --git a/src/H5Doh.c b/src/H5Doh.c index 38d0914..017bab7 100644 --- a/src/H5Doh.c +++ b/src/H5Doh.c @@ -29,6 +29,7 @@ #include "H5FLprivate.h" /* Free lists */ #include "H5Iprivate.h" /* IDs */ #include "H5Opkg.h" /* Object headers */ +#include "H5VLprivate.h" /* Virtual Object Layer */ /****************/ @@ -47,7 +48,7 @@ static void *H5O__dset_get_copy_file_udata(void); static void H5O__dset_free_copy_file_udata(void *); static htri_t H5O__dset_isa(const H5O_t *loc); -static hid_t H5O__dset_open(const H5G_loc_t *obj_loc, hbool_t app_ref); +static void *H5O__dset_open(const H5G_loc_t *obj_loc, H5I_type_t *opened_type); static void *H5O__dset_create(H5F_t *f, void *_crt_info, H5G_loc_t *obj_loc); static H5O_loc_t *H5O__dset_get_oloc(hid_t obj_id); static herr_t H5O__dset_bh_info(const H5O_loc_t *loc, H5O_t *oh, @@ -217,17 +218,19 @@ done: * *------------------------------------------------------------------------- */ -static hid_t -H5O__dset_open(const H5G_loc_t *obj_loc, hbool_t app_ref) +static void * +H5O__dset_open(const H5G_loc_t *obj_loc, H5I_type_t *opened_type) { - H5D_t *dset = NULL; /* Dataset opened */ - hid_t dapl_id; /* dapl to use to open this dataset */ - hid_t ret_value = H5I_INVALID_HID; /* Return value */ + H5D_t *dset = NULL; /* Dataset opened */ + hid_t dapl_id; /* dapl to use to open this dataset */ + void *ret_value = NULL; /* Return value */ FUNC_ENTER_STATIC HDassert(obj_loc); + *opened_type = H5I_DATASET; + /* Get the LAPL (which is a superclass of DAPLs) from the API context, but * if it's the default link access property list or a custom link access * property list but not a dataset access property list, use the default @@ -242,9 +245,9 @@ H5O__dset_open(const H5G_loc_t *obj_loc, hbool_t app_ref) /* Check class of LAPL from API context */ if((is_lapl = H5P_isa_class(dapl_id, H5P_LINK_ACCESS)) < 0) - HGOTO_ERROR(H5E_DATASET, H5E_CANTGET, H5I_INVALID_HID, "unable to get LAPL status") + HGOTO_ERROR(H5E_DATASET, H5E_CANTGET, NULL, "unable to get LAPL status") if((is_dapl = H5P_isa_class(dapl_id, H5P_DATASET_ACCESS)) < 0) - HGOTO_ERROR(H5E_DATASET, H5E_CANTGET, H5I_INVALID_HID, "unable to get DAPL status") + HGOTO_ERROR(H5E_DATASET, H5E_CANTGET, NULL, "unable to get DAPL status") /* Switch to default DAPL if not an actual DAPL in the API context */ if(!is_dapl && is_lapl) @@ -253,16 +256,14 @@ H5O__dset_open(const H5G_loc_t *obj_loc, hbool_t app_ref) /* Open the dataset */ if(NULL == (dset = H5D_open(obj_loc, dapl_id))) - HGOTO_ERROR(H5E_DATASET, H5E_CANTOPENOBJ, H5I_INVALID_HID, "unable to open dataset") + HGOTO_ERROR(H5E_DATASET, H5E_CANTOPENOBJ, NULL, "unable to open dataset") - /* Register an ID for the dataset */ - if((ret_value = H5I_register(H5I_DATASET, dset, app_ref)) < 0) - HGOTO_ERROR(H5E_ATOM, H5E_CANTREGISTER, H5I_INVALID_HID, "unable to register dataset") + ret_value = (void *)dset; done: - if(H5I_INVALID_HID == ret_value) + if(NULL == ret_value) if(dset && H5D_close(dset) < 0) - HDONE_ERROR(H5E_DATASET, H5E_CLOSEERROR, H5I_INVALID_HID, "unable to release dataset") + HDONE_ERROR(H5E_DATASET, H5E_CLOSEERROR, NULL, "unable to release dataset") FUNC_LEAVE_NOAPI(ret_value) } /* end H5O__dset_open() */ @@ -339,7 +340,7 @@ H5O__dset_get_oloc(hid_t obj_id) FUNC_ENTER_STATIC /* Get the dataset */ - if(NULL == (dset = (H5D_t *)H5I_object(obj_id))) + if(NULL == (dset = (H5D_t *)H5VL_object(obj_id))) HGOTO_ERROR(H5E_OHDR, H5E_BADATOM, NULL, "couldn't get object from ID") /* Get the dataset's object header location */ diff --git a/src/H5Dpkg.h b/src/H5Dpkg.h index 591fcb1..c84c245 100644 --- a/src/H5Dpkg.h +++ b/src/H5Dpkg.h @@ -110,6 +110,15 @@ typedef struct H5D_type_info_t { hbool_t bkg_buf_allocated; /* Whether the background buffer was allocated */ } H5D_type_info_t; +/* types for dataset optional VOL operations */ +typedef enum H5VL_dataset_optional_t { + H5VL_DATASET_FORMAT_CONVERT, /* H5Dformat_convert (internal) */ + H5VL_DATASET_GET_CHUNK_INDEX_TYPE, /* H5Dget_chunk_index_type */ + H5VL_DATASET_GET_CHUNK_STORAGE_SIZE, /* H5Dget_chunk_storage_size */ + H5VL_DATASET_CHUNK_READ, /* H5Dchunk_read */ + H5VL_DATASET_CHUNK_WRITE, /* H5Dchunk_write */ +} H5VL_dataset_optional_t; + /* Forward declaration of structs used below */ struct H5D_io_info_t; struct H5D_chunk_map_t; @@ -510,7 +519,7 @@ typedef struct H5D_fill_buf_info_t { /* Internal data structure for computing variable-length dataset's total size */ typedef struct { - H5D_t *dset; /* Dataset for operation */ + H5VL_object_t *dset_vol_obj; /* VOL object for the dataset */ hid_t fspace_id; /* File dataspace ID of the dataset we are working on */ hid_t mspace_id; /* Memory dataspace ID of the dataset we are working on */ void *fl_tbuf; /* Ptr to the temporary buffer we are using for fixed-length data */ diff --git a/src/H5Dtest.c b/src/H5Dtest.c index ac1d05a..916ec72 100644 --- a/src/H5Dtest.c +++ b/src/H5Dtest.c @@ -32,6 +32,7 @@ #include "H5Dpkg.h" /* Datasets */ #include "H5Eprivate.h" /* Error handling */ #include "H5Iprivate.h" /* IDs */ +#include "H5VLprivate.h" /* Virtual Object Layer */ /****************/ @@ -88,7 +89,7 @@ H5D__layout_version_test(hid_t did, unsigned *version) FUNC_ENTER_PACKAGE /* Check args */ - if(NULL == (dset = (H5D_t *)H5I_object_verify(did, H5I_DATASET))) + if(NULL == (dset = (H5D_t *)H5VL_object_verify(did, H5I_DATASET))) HGOTO_ERROR(H5E_DATASET, H5E_BADTYPE, FAIL, "not a dataset") if(version) @@ -127,7 +128,7 @@ H5D__layout_contig_size_test(hid_t did, hsize_t *size) FUNC_ENTER_PACKAGE /* Check args */ - if(NULL == (dset = (H5D_t *)H5I_object_verify(did, H5I_DATASET))) + if(NULL == (dset = (H5D_t *)H5VL_object_verify(did, H5I_DATASET))) HGOTO_ERROR(H5E_DATASET, H5E_BADTYPE, FAIL, "not a dataset") if(size) { @@ -168,7 +169,7 @@ H5D__layout_compact_dirty_test(hid_t did, hbool_t *dirty) FUNC_ENTER_PACKAGE /* Check args */ - if(NULL == (dset = (H5D_t *)H5I_object_verify(did, H5I_DATASET))) + if(NULL == (dset = (H5D_t *)H5VL_object_verify(did, H5I_DATASET))) HGOTO_ERROR(H5E_DATASET, H5E_BADTYPE, FAIL, "not a dataset") if(dirty) { @@ -211,7 +212,7 @@ H5D__layout_type_test(hid_t did, H5D_layout_t *layout_type) HDassert(layout_type); /* Check args */ - if(NULL == (dset = (H5D_t *)H5I_object_verify(did, H5I_DATASET))) + if(NULL == (dset = (H5D_t *)H5VL_object_verify(did, H5I_DATASET))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a dataset") if(layout_type) @@ -250,7 +251,7 @@ H5D__layout_idx_type_test(hid_t did, H5D_chunk_index_t *idx_type) FUNC_ENTER_PACKAGE /* Check args */ - if(NULL == (dset = (H5D_t *)H5I_object_verify(did, H5I_DATASET))) + if(NULL == (dset = (H5D_t *)H5VL_object_verify(did, H5I_DATASET))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a dataset") if(dset->shared->layout.type != H5D_CHUNKED) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "dataset is not chunked") @@ -291,7 +292,7 @@ H5D__current_cache_size_test(hid_t did, size_t *nbytes_used, int *nused) FUNC_ENTER_PACKAGE /* Check args */ - if(NULL == (dset = (H5D_t *)H5I_object_verify(did, H5I_DATASET))) + if(NULL == (dset = (H5D_t *)H5VL_object_verify(did, H5I_DATASET))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a dataset") if(nbytes_used) { diff --git a/src/H5Dvirtual.c b/src/H5Dvirtual.c index 8867492..89974b2 100644 --- a/src/H5Dvirtual.c +++ b/src/H5Dvirtual.c @@ -58,7 +58,8 @@ #include "H5Oprivate.h" /* Object headers */ #include "H5Pprivate.h" /* Property Lists */ #include "H5Sprivate.h" /* Dataspaces */ - +#include "H5VLnative.h" /* Native VOL driver */ +#include "H5VLprivate.h" /* Virtual Object Layer */ /****************/ /* Local Macros */ @@ -2961,27 +2962,38 @@ done: static herr_t H5D__virtual_refresh_source_dset(H5D_t **dset) { - hid_t temp_id; /* Temporary dataset identifier */ - herr_t ret_value = SUCCEED; /* Return value */ + hid_t temp_id = H5I_INVALID_HID; /* Temporary dataset identifier */ + hid_t native_vol_id = H5I_INVALID_HID; /* ID for the native VOL driver */ + H5VL_object_t *vol_obj = NULL; /* VOL object stored with the ID */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_STATIC /* Sanity check */ HDassert(dset && *dset); + /* Get the native VOL driver's ID */ + if((native_vol_id = H5VL_native_get_driver_id()) < 0) + HGOTO_ERROR(H5E_DATASET, H5E_CANTGET, FAIL, "can't get native VOL driver ID") + /* Get a temporary identifier for this source dataset */ - if((temp_id = H5I_register(H5I_DATASET, *dset, FALSE)) < 0) - HGOTO_ERROR(H5E_DATASET, H5E_CANTREGISTER, FAIL, "can't register source dataset ID") + if((temp_id = H5VL_object_register(*dset, H5I_DATASET, native_vol_id, FALSE)) < 0) + HGOTO_ERROR(H5E_DATASET, H5E_CANTREGISTER, FAIL, "can't register (temporary) source dataset ID") /* Refresh source dataset */ if(H5D__refresh(temp_id, *dset) < 0) HGOTO_ERROR(H5E_DATASET, H5E_CANTFLUSH, FAIL, "unable to refresh source dataset") /* Discard the identifier & replace the dataset */ - if(NULL == (*dset = (H5D_t *)H5I_remove(temp_id))) + if(NULL == (vol_obj = (H5VL_object_t *)H5I_remove(temp_id))) HGOTO_ERROR(H5E_DATASET, H5E_CANTREMOVE, FAIL, "can't unregister source dataset ID") + *dset = (H5D_t *)(vol_obj->data); + vol_obj->data = NULL; done: + if(vol_obj && H5VL_free_object(vol_obj) < 0) + HDONE_ERROR(H5E_DATASET, H5E_CANTDEC, FAIL, "unable to free VOL object") + FUNC_LEAVE_NOAPI(ret_value) } /* end H5D__virtual_refresh_source_dsets() */ diff --git a/src/H5ESpublic.h b/src/H5ESpublic.h new file mode 100644 index 0000000..cb8eebf --- /dev/null +++ b/src/H5ESpublic.h @@ -0,0 +1,53 @@ +/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * + * Copyright by The HDF Group. * + * All rights reserved. * + * * + * This file is part of HDF5. The full HDF5 copyright notice, including * + * terms governing use, modification, and redistribution, is contained in * + * the COPYING file, which can be found at the root of the source code * + * distribution tree, or in https://support.hdfgroup.org/ftp/HDF5/releases. * + * If you do not have access to either file, you may request a copy from * + * help@hdfgroup.org. * + * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ + +#ifndef _H5ESpublic_H +#define _H5ESpublic_H + +/* Public headers needed by this file */ +#include "H5public.h" /* Generic Functions */ + +/*****************/ +/* Public Macros */ +/*****************/ + +/*******************/ +/* Public Typedefs */ +/*******************/ + +/* Asynchronous operation status */ +typedef enum H5ES_status_t { + H5ES_STATUS_IN_PROGRESS, /* Operation has not yet completed */ + H5ES_STATUS_SUCCEED, /* Operation has completed, successfully */ + H5ES_STATUS_FAIL, /* Operation has completed, but failed */ + H5ES_STATUS_CANCEL /* Operation has not completed and has been cancelled */ +} H5ES_status_t; + + +/********************/ +/* Public Variables */ +/********************/ + +/*********************/ +/* Public Prototypes */ +/*********************/ + +#ifdef __cplusplus +extern "C" { +#endif + +#ifdef __cplusplus +} +#endif + +#endif /* _H5ESpublic_H */ + @@ -29,12 +29,14 @@ #include "H5Eprivate.h" /* Error handling */ #include "H5Fpkg.h" /* File access */ #include "H5FDprivate.h" /* File drivers */ +#include "H5FLprivate.h" /* Free lists */ #include "H5Gprivate.h" /* Groups */ #include "H5Iprivate.h" /* IDs */ #include "H5MFprivate.h" /* File memory management */ #include "H5MMprivate.h" /* Memory management */ #include "H5Pprivate.h" /* Property lists */ #include "H5Tprivate.h" /* Datatypes */ +#include "H5VLprivate.h" /* Virtual Object Layer */ /****************/ @@ -55,7 +57,13 @@ /* Local Prototypes */ /********************/ -static herr_t H5F__close_cb(H5F_t *f); +static herr_t H5F__close_cb(H5VL_object_t *file_vol_obj); + +/* Callback for getting object counts in a file */ +static int H5F__get_all_count_cb(void H5_ATTR_UNUSED *obj_ptr, hid_t H5_ATTR_UNUSED obj_id, void *key); + +/* Callback for getting IDs for open objects in a file */ +static int H5F__get_all_ids_cb(void H5_ATTR_UNUSED *obj_ptr, hid_t obj_id, void *key); /*********************/ @@ -75,6 +83,11 @@ hbool_t H5_PKG_INIT_VAR = FALSE; /* Local Variables */ /*******************/ +/* Declare a free list to manage the H5VL_t struct */ +H5FL_EXTERN(H5VL_t); + +/* Declare a free list to manage the H5VL_object_t struct */ +H5FL_EXTERN(H5VL_object_t); /* File ID class */ static const H5I_class_t H5I_FILE_CLS[1] = {{ @@ -176,42 +189,22 @@ H5F_term_package(void) *------------------------------------------------------------------------- */ static herr_t -H5F__close_cb(H5F_t *f) +H5F__close_cb(H5VL_object_t *file_vol_obj) { herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_STATIC /* Sanity check */ - HDassert(f); - HDassert(f->file_id > 0); /* This routine should only be called when a file ID's ref count drops to zero */ - - /* Perform checks for "semi" file close degree here, since closing the - * file is not allowed if there are objects still open. - */ - if(f->shared->fc_degree == H5F_CLOSE_SEMI) { - unsigned nopen_files = 0; /* Number of open files in file/mount hierarchy */ - unsigned nopen_objs = 0; /* Number of open objects in file/mount hierarchy */ - - /* Get the number of open objects and open files on this file/mount hierarchy */ - if(H5F__mount_count_ids(f, &nopen_files, &nopen_objs) < 0) - HGOTO_ERROR(H5E_SYM, H5E_MOUNT, FAIL, "problem checking mount hierarchy") - - /* If there are no other file IDs open on this file/mount hier., but - * there are still open objects, issue an error and bail out now, - * without decrementing the file ID's reference count and triggering - * a "real" attempt at closing the file. - */ - if(nopen_files == 1 && nopen_objs > 0) - HGOTO_ERROR(H5E_FILE, H5E_CANTCLOSEFILE, FAIL, "can't close file, there are objects still open") - } /* end if */ + HDassert(file_vol_obj); - /* Reset the file ID for this file */ - f->file_id = -1; + /* Close the file */ + if(H5VL_file_close(file_vol_obj->data, file_vol_obj->driver->cls, H5P_DATASET_XFER_DEFAULT, H5_REQUEST_NULL) < 0) + HGOTO_ERROR(H5E_FILE, H5E_CANTCLOSEFILE, FAIL, "unable to close file"); - /* Attempt to close the file/mount hierarchy */ - if(H5F_try_close(f, NULL) < 0) - HGOTO_ERROR(H5E_FILE, H5E_CANTCLOSEFILE, FAIL, "unable to close file") + /* Free the VOL object */ + if(H5VL_free_object(file_vol_obj) < 0) + HGOTO_ERROR(H5E_FILE, H5E_CANTDEC, FAIL, "unable to free VOL object"); done: FUNC_LEAVE_NOAPI(ret_value) @@ -235,21 +228,19 @@ done: hid_t H5Fget_create_plist(hid_t file_id) { - H5F_t *file; /* File info */ - H5P_genplist_t *plist; /* Property list */ + H5VL_object_t *vol_obj; /* File info */ hid_t ret_value = H5I_INVALID_HID; /* Return value */ FUNC_ENTER_API(H5I_INVALID_HID) H5TRACE1("i", "i", file_id); /* check args */ - if(NULL == (file = (H5F_t *)H5I_object_verify(file_id, H5I_FILE))) + if(NULL == (vol_obj = (H5VL_object_t *)H5I_object(file_id))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, H5I_INVALID_HID, "invalid file identifier") - if(NULL == (plist = (H5P_genplist_t *)H5I_object(file->shared->fcpl_id))) - HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, H5I_INVALID_HID, "not a property list") /* Retrieve the file creation property list */ - if((ret_value = H5P_copy_plist(plist, TRUE)) < 0) + if(H5VL_file_get(vol_obj->data, vol_obj->driver->cls, H5VL_FILE_GET_FCPL, + H5P_DATASET_XFER_DEFAULT, H5_REQUEST_NULL, &ret_value) < 0) HGOTO_ERROR(H5E_PLIST, H5E_CANTCOPY, H5I_INVALID_HID, "unable to retrieve file creation properties") done: @@ -278,18 +269,19 @@ done: hid_t H5Fget_access_plist(hid_t file_id) { - H5F_t *file; /* File info */ + H5VL_object_t *vol_obj; /* File info */ hid_t ret_value = H5I_INVALID_HID; /* Return value */ FUNC_ENTER_API(H5I_INVALID_HID) H5TRACE1("i", "i", file_id); /* Check args */ - if(NULL == (file = (H5F_t *)H5I_object_verify(file_id, H5I_FILE))) + if(NULL == (vol_obj = (H5VL_object_t *)H5I_object(file_id))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, H5I_INVALID_HID, "invalid file identifier") /* Retrieve the file's access property list */ - if((ret_value = H5F_get_access_plist(file, TRUE)) < 0) + if(H5VL_file_get(vol_obj->data, vol_obj->driver->cls, H5VL_FILE_GET_FAPL, + H5P_DATASET_XFER_DEFAULT, H5_REQUEST_NULL, &ret_value) < 0) HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, H5I_INVALID_HID, "can't get file access property list") done: @@ -351,19 +343,16 @@ H5Fget_obj_count(hid_t file_id, unsigned types) * count the IDs in the file. */ if(file_id != (hid_t)H5F_OBJ_ALL) { - H5F_t *f = NULL; - size_t obj_count = 0; + H5VL_object_t *vol_obj; /* Get the file object */ - if(NULL == (f = (H5F_t *)H5I_object_verify(file_id, H5I_FILE))) + if(NULL == (vol_obj = (H5VL_object_t *)H5I_object_verify(file_id, H5I_FILE))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, (-1), "not a file id") /* Get the count */ - if(H5F_get_obj_count(f, types, TRUE, &obj_count) < 0) + if(H5VL_file_get(vol_obj->data, vol_obj->driver->cls, H5VL_FILE_GET_OBJ_COUNT, + H5P_DATASET_XFER_DEFAULT, H5_REQUEST_NULL, types, &ret_value) < 0) HGOTO_ERROR(H5E_FILE, H5E_CANTGET, (-1), "unable to get object count in file(s)") - - /* Set the return value */ - ret_value = (ssize_t)obj_count; } /* If we passed in the 'special' ID, get the count for everything open in the * library, iterating over all open files and getting the object count for each. @@ -466,19 +455,16 @@ H5Fget_obj_ids(hid_t file_id, unsigned types, size_t max_objs, hid_t *oid_list) * get the IDs from the file. */ if(file_id != (hid_t)H5F_OBJ_ALL) { - H5F_t *file = NULL; - size_t obj_id_count = 0; + H5VL_object_t *vol_obj; /* get the file object */ - if(NULL == (file = (H5F_t *)H5I_object_verify(file_id, H5I_FILE))) + if(NULL == (vol_obj = (H5VL_object_t *)H5I_object_verify(file_id, H5I_FILE))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, (-1), "invalid file identifier") /* Get the IDs */ - if(H5F_get_obj_ids(file, types, max_objs, oid_list, TRUE, &obj_id_count) < 0) + if(H5VL_file_get(vol_obj->data, vol_obj->driver->cls, H5VL_FILE_GET_OBJ_IDS, + H5P_DATASET_XFER_DEFAULT, H5_REQUEST_NULL, types, max_objs, oid_list, &ret_value) < 0) HGOTO_ERROR(H5E_FILE, H5E_CANTGET, (-1), "unable to get object ids in file(s)") - - /* Set the return value */ - ret_value = (ssize_t)obj_id_count; } /* If we passed in the 'special' ID, get the count for everything open in the * library, iterating over all open files and getting the object count for each. @@ -491,6 +477,8 @@ H5Fget_obj_ids(hid_t file_id, unsigned types, size_t max_objs, hid_t *oid_list) else { H5F_trav_obj_ids_t udata; + /* XXX (VOL MERGE): Unclear why this is commented out */ + //udata.types = types | H5F_OBJ_LOCAL; udata.max_objs = max_objs; udata.oid_list = oid_list; udata.obj_count = &ret_value; @@ -535,7 +523,7 @@ done: herr_t H5Fget_vfd_handle(hid_t file_id, hid_t fapl_id, void **file_handle) { - H5F_t *file; /* File info */ + H5VL_object_t *vol_obj; /* File info */ herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_API(FAIL) @@ -546,11 +534,12 @@ H5Fget_vfd_handle(hid_t file_id, hid_t fapl_id, void **file_handle) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "invalid file handle pointer") /* Get the file object */ - if(NULL == (file = (H5F_t *)H5I_object_verify(file_id, H5I_FILE))) + if(NULL == (vol_obj = (H5VL_object_t *)H5I_object(file_id))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "invalid file identifier") /* Retrieve the VFD handle for the file */ - if(H5F_get_vfd_handle(file, fapl_id, file_handle) < 0) + if(H5VL_file_optional(vol_obj->data, vol_obj->driver->cls, H5P_DATASET_XFER_DEFAULT, + H5_REQUEST_NULL, H5VL_FILE_GET_VFD_HANDLE, file_handle, fapl_id) < 0) HGOTO_ERROR(H5E_FILE, H5E_CANTGET, FAIL, "unable to get VFD handle") done: @@ -559,38 +548,41 @@ done: /*------------------------------------------------------------------------- - * Function: H5Fis_hdf5 + * Function: H5Fis_accessible * - * Purpose: Check the file signature to detect an HDF5 file. - * - * Bugs: This function is not robust: it only uses the default file - * driver when attempting to open the file when in fact it - * should use all known file drivers. + * Purpose: Check if the file can be opened with the given fapl. * * Return: TRUE/FALSE/FAIL * *------------------------------------------------------------------------- */ htri_t -H5Fis_hdf5(const char *name) +H5Fis_accessible(const char *name, hid_t fapl_id) { htri_t ret_value; /* Return value */ FUNC_ENTER_API(FAIL) - H5TRACE1("t", "*s", name); + H5TRACE2("t", "*si", name, fapl_id); /* Check args */ if(!name || !*name) HGOTO_ERROR(H5E_ARGS, H5E_BADRANGE, FAIL, "no file name specified") - /* call the private is_HDF5 function */ - /* (Should not trigger raw data I/O - QAK, 2018/01/03) */ - if((ret_value = H5F__is_hdf5(name)) < 0) - HGOTO_ERROR(H5E_FILE, H5E_NOTHDF5, FAIL, "unable open file") + /* Check the file access property list */ + if(H5P_DEFAULT == fapl_id) + fapl_id = H5P_FILE_ACCESS_DEFAULT; + else + if(TRUE != H5P_isa_class(fapl_id, H5P_FILE_ACCESS)) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not file access property list") + + /* Check if file is accessible */ + if(H5VL_file_specific(NULL, NULL, H5VL_FILE_IS_ACCESSIBLE, H5P_DATASET_XFER_DEFAULT, + H5_REQUEST_NULL, fapl_id, name, &ret_value) < 0) + HGOTO_ERROR(H5E_FILE, H5E_NOTHDF5, FAIL, "unable to determine if file is accessible as HDF5") done: FUNC_LEAVE_API(ret_value) -} /* end H5Fis_hdf5() */ +} /* end H5Fis_accessible() */ /*------------------------------------------------------------------------- @@ -621,7 +613,12 @@ done: hid_t H5Fcreate(const char *filename, unsigned flags, hid_t fcpl_id, hid_t fapl_id) { - H5F_t *new_file = NULL; /* file struct for new file */ + void *new_file = NULL; /* file struct for new file */ + + H5P_genplist_t *plist; /* Property list pointer */ + H5VL_class_t *cls = NULL; /* VOL Class structure for callback info */ + H5VL_t *driver = NULL; /* VOL driver struct */ + H5VL_driver_prop_t driver_prop; /* Property for vol driver ID & info */ hid_t ret_value; /* return value */ FUNC_ENTER_API(H5I_INVALID_HID) @@ -652,6 +649,14 @@ H5Fcreate(const char *filename, unsigned flags, hid_t fcpl_id, hid_t fapl_id) if(H5CX_set_apl(&fapl_id, H5P_CLS_FACC, H5I_INVALID_HID, TRUE) < 0) HGOTO_ERROR(H5E_FILE, H5E_CANTSET, H5I_INVALID_HID, "can't set access property list info") + /* get the VOL info from the fapl */ + if(NULL == (plist = (H5P_genplist_t *)H5I_object(fapl_id))) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, H5I_INVALID_HID, "not a file access property list") + if(H5P_peek(plist, H5F_ACS_VOL_DRV_NAME, &driver_prop) < 0) + HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, H5I_INVALID_HID, "can't get vol driver info") + if(NULL == (cls = (H5VL_class_t *)H5I_object_verify(driver_prop.driver_id, H5I_VOL))) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, H5I_INVALID_HID, "not a VOL driver ID") + /* Adjust bit flags by turning on the creation bit and making sure that * the EXCL or TRUNC bit is set. All newly-created files are opened for * reading and writing. @@ -660,21 +665,24 @@ H5Fcreate(const char *filename, unsigned flags, hid_t fcpl_id, hid_t fapl_id) flags |= H5F_ACC_EXCL; /*default*/ flags |= H5F_ACC_RDWR | H5F_ACC_CREAT; - /* Create a new file or truncate an existing file. */ - if(NULL == (new_file = H5F_open(filename, flags, fcpl_id, fapl_id))) + /* Create a new file or truncate an existing file through the VOL */ + if(NULL == (new_file = H5VL_file_create(cls, filename, flags, fcpl_id, fapl_id, + H5P_DATASET_XFER_DEFAULT, H5_REQUEST_NULL))) HGOTO_ERROR(H5E_FILE, H5E_CANTOPENFILE, H5I_INVALID_HID, "unable to create file") - /* Get an atom for the file */ - if((ret_value = H5I_register(H5I_FILE, new_file, TRUE)) < 0) - HGOTO_ERROR(H5E_ATOM, H5E_CANTREGISTER, H5I_INVALID_HID, "unable to atomize file") + /* Setup VOL driver struct */ + if(NULL == (driver = H5FL_CALLOC(H5VL_t))) + HGOTO_ERROR(H5E_FILE, H5E_NOSPACE, H5I_INVALID_HID, "can't allocate VL info struct") + driver->cls = cls; + driver->id = driver_prop.driver_id; + if(H5I_inc_ref(driver->id, FALSE) < 0) + HGOTO_ERROR(H5E_ATOM, H5E_CANTINC, H5I_INVALID_HID, "unable to increment ref count on VOL driver") - /* Keep this ID in file object structure */ - new_file->file_id = ret_value; + /* Get an atom for the file */ + if((ret_value = H5VL_register_id(H5I_FILE, new_file, driver, TRUE)) < 0) + HGOTO_ERROR(H5E_ATOM, H5E_CANTREGISTER, H5I_INVALID_HID, "unable to atomize file handle") done: - if(ret_value < 0 && new_file && H5F_try_close(new_file, NULL) < 0) - HDONE_ERROR(H5E_FILE, H5E_CANTCLOSEFILE, H5I_INVALID_HID, "problems closing file") - FUNC_LEAVE_API(ret_value) } /* end H5Fcreate() */ @@ -701,8 +709,12 @@ done: hid_t H5Fopen(const char *filename, unsigned flags, hid_t fapl_id) { - H5F_t *new_file = NULL; /* file struct for new file */ - hid_t ret_value; /* return value */ + void *new_file = NULL; /* file struct for new file */ + H5P_genplist_t *plist; /* Property list pointer */ + H5VL_driver_prop_t driver_prop; /* Property for vol driver ID & info */ + H5VL_class_t *cls = NULL; /* VOL class structure for callback info */ + H5VL_t *driver = NULL; /* VOL driver struct */ + hid_t ret_value; /* return value */ FUNC_ENTER_API(H5I_INVALID_HID) H5TRACE3("i", "*sIui", filename, flags, fapl_id); @@ -714,6 +726,7 @@ H5Fopen(const char *filename, unsigned flags, hid_t fapl_id) if((flags & ~H5F_ACC_PUBLIC_FLAGS) || (flags & H5F_ACC_TRUNC) || (flags & H5F_ACC_EXCL)) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, H5I_INVALID_HID, "invalid file open flags") + /* XXX (VOL MERGE): Might want to move SWMR flag checks to H5F_open() */ /* Asking for SWMR write access on a read-only file is invalid */ if((flags & H5F_ACC_SWMR_WRITE) && 0 == (flags & H5F_ACC_RDWR)) HGOTO_ERROR(H5E_FILE, H5E_CANTOPENFILE, H5I_INVALID_HID, "SWMR write access on a file open for read-only access is not allowed") @@ -725,21 +738,31 @@ H5Fopen(const char *filename, unsigned flags, hid_t fapl_id) if(H5CX_set_apl(&fapl_id, H5P_CLS_FACC, H5I_INVALID_HID, TRUE) < 0) HGOTO_ERROR(H5E_FILE, H5E_CANTSET, H5I_INVALID_HID, "can't set access property list info") - /* Open the file */ - if(NULL == (new_file = H5F_open(filename, flags, H5P_FILE_CREATE_DEFAULT, fapl_id))) + /* Get the VOL info from the fapl */ + if(NULL == (plist = (H5P_genplist_t *)H5I_object(fapl_id))) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, H5I_INVALID_HID, "not a file access property list") + if(H5P_peek(plist, H5F_ACS_VOL_DRV_NAME, &driver_prop) < 0) + HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, H5I_INVALID_HID, "can't get VOL driver info") + if(NULL == (cls = (H5VL_class_t *)H5I_object_verify(driver_prop.driver_id, H5I_VOL))) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, H5I_INVALID_HID, "invalid VOL driver ID") + + /* Open the file through the VOL layer */ + if(NULL == (new_file = H5VL_file_open(cls, filename, flags, fapl_id, H5P_DATASET_XFER_DEFAULT, H5_REQUEST_NULL))) HGOTO_ERROR(H5E_FILE, H5E_CANTOPENFILE, H5I_INVALID_HID, "unable to open file") - /* Get an atom for the file */ - if((ret_value = H5I_register(H5I_FILE, new_file, TRUE)) < 0) - HGOTO_ERROR(H5E_ATOM, H5E_CANTREGISTER, H5I_INVALID_HID, "unable to atomize file handle") + /* Setup VOL driver struct */ + if(NULL == (driver = H5FL_CALLOC(H5VL_t))) + HGOTO_ERROR(H5E_FILE, H5E_NOSPACE, H5I_INVALID_HID, "can't allocate VL info struct") + driver->cls = cls; + driver->id = driver_prop.driver_id; + if(H5I_inc_ref(driver->id, FALSE) < 0) + HGOTO_ERROR(H5E_ATOM, H5E_CANTINC, H5I_INVALID_HID, "unable to increment ref count on VOL driver") - /* Keep this ID in file object structure */ - new_file->file_id = ret_value; + /* Get an ID for the file */ + if((ret_value = H5VL_register_id(H5I_FILE, new_file, driver, TRUE)) < 0) + HGOTO_ERROR(H5E_ATOM, H5E_CANTREGISTER, H5I_INVALID_HID, "unable to atomize file handle") done: - if(ret_value < 0 && new_file && H5F_try_close(new_file, NULL) < 0) - HDONE_ERROR(H5E_FILE, H5E_CANTCLOSEFILE, H5I_INVALID_HID, "problems closing file") - FUNC_LEAVE_API(ret_value) } /* end H5Fopen() */ @@ -758,108 +781,28 @@ done: herr_t H5Fflush(hid_t object_id, H5F_scope_t scope) { - H5F_t *f = NULL; /* File to flush */ - H5O_loc_t *oloc = NULL; /* Object location for ID */ + H5VL_object_t *vol_obj = NULL; /* Object info */ + H5I_type_t obj_type; /* Type of object */ herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_API(FAIL) H5TRACE2("e", "iFs", object_id, scope); - switch(H5I_get_type(object_id)) { - case H5I_FILE: - if(NULL == (f = (H5F_t *)H5I_object(object_id))) - HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "invalid file identifier") - break; - - case H5I_GROUP: - { - H5G_t *grp; - - if(NULL == (grp = (H5G_t *)H5I_object(object_id))) - HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "invalid group identifier") - oloc = H5G_oloc(grp); - } - break; - - case H5I_DATATYPE: - { - H5T_t *type; - - if(NULL == (type = (H5T_t *)H5I_object(object_id))) - HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "invalid type identifier") - oloc = H5T_oloc(type); - } - break; - - case H5I_DATASET: - { - H5D_t *dset; - - if(NULL == (dset = (H5D_t *)H5I_object(object_id))) - HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "invalid dataset identifier") - oloc = H5D_oloc(dset); - } - break; - - case H5I_ATTR: - { - H5A_t *attr; - - if(NULL == (attr = (H5A_t *)H5I_object(object_id))) - HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "invalid attribute identifier") - oloc = H5A_oloc(attr); - } - break; - - case H5I_UNINIT: - case H5I_BADID: - case H5I_DATASPACE: - case H5I_REFERENCE: - case H5I_VFL: - case H5I_GENPROP_CLS: - case H5I_GENPROP_LST: - case H5I_ERROR_CLASS: - case H5I_ERROR_MSG: - case H5I_ERROR_STACK: - case H5I_NTYPES: - default: - HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a file or file object") - } /* end switch */ - - if(!f) { - if(!oloc) - HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "object is not assocated with a file") - f = oloc->file; - } /* end if */ - if(!f) - HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "object is not associated with a file") + /* Get the type of object we're flushing + sanity check */ + obj_type = H5I_get_type(object_id); + if(H5I_FILE != obj_type && H5I_GROUP != obj_type && H5I_DATATYPE != obj_type && + H5I_DATASET != obj_type && H5I_ATTR != obj_type) { + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a file or file object") + } - /* Flush the file */ - /* - * Nothing to do if the file is read only. This determination is - * made at the shared open(2) flags level, implying that opening a - * file twice, once for read-only and once for read-write, and then - * calling H5Fflush() with the read-only handle, still causes data - * to be flushed. - */ - if(H5F_ACC_RDWR & H5F_INTENT(f)) { - hid_t fapl_id = H5P_DEFAULT; /* FAPL to use */ - - /* Verify access property list and set up collective metadata if appropriate */ - if(H5CX_set_apl(&fapl_id, H5P_CLS_FACC, object_id, TRUE) < 0) - HGOTO_ERROR(H5E_FILE, H5E_CANTSET, FAIL, "can't set access property list info") - - /* Flush other files, depending on scope */ - if(H5F_SCOPE_GLOBAL == scope) { - /* Call the flush routine for mounted file hierarchies */ - if(H5F_flush_mounts(f) < 0) - HGOTO_ERROR(H5E_FILE, H5E_CANTFLUSH, FAIL, "unable to flush mounted file hierarchy") - } /* end if */ - else - /* Call the flush routine, for this file */ - if(H5F__flush(f) < 0) - HGOTO_ERROR(H5E_FILE, H5E_CANTFLUSH, FAIL, "unable to flush file's cached information") - } /* end if */ + /* get the file object */ + if(NULL == (vol_obj = H5VL_get_object(object_id))) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "invalid object identifier") + + /* Flush the object */ + if(H5VL_file_specific(vol_obj->data, vol_obj->driver->cls, H5VL_FILE_FLUSH, + H5P_DATASET_XFER_DEFAULT, H5_REQUEST_NULL, obj_type, scope) < 0) + HGOTO_ERROR(H5E_FILE, H5E_CANTFLUSH, FAIL, "unable to flush file") done: FUNC_LEAVE_API(ret_value) @@ -892,9 +835,11 @@ H5Fclose(hid_t file_id) if(H5I_FILE != H5I_get_type(file_id)) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a file ID") - /* Close the file */ - if(H5F__close(file_id) < 0) - HGOTO_ERROR(H5E_FILE, H5E_CANTCLOSEFILE, FAIL, "closing file ID failed") + /* Decrement reference count on atom. When it reaches zero the file will + * be closed. + */ + if(H5I_dec_app_ref(file_id) < 0) + HGOTO_ERROR(H5E_ATOM, H5E_CANTCLOSEFILE, FAIL, "decrementing file ID failed") done: FUNC_LEAVE_API(ret_value) @@ -919,33 +864,32 @@ done: hid_t H5Freopen(hid_t file_id) { - H5F_t *old_file = NULL; - H5F_t *new_file = NULL; + H5VL_object_t *vol_obj = NULL; + void *file; /* File token from VOL driver */ hid_t ret_value = H5I_INVALID_HID; /* Return value */ FUNC_ENTER_API(H5I_INVALID_HID) H5TRACE1("i", "i", file_id); /* Get the file object */ - if(NULL == (old_file = (H5F_t *)H5I_object_verify(file_id, H5I_FILE))) - HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, H5I_INVALID_HID, "not a file") + if(NULL == (vol_obj = (H5VL_object_t *)H5I_object_verify(file_id, H5I_FILE))) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, H5I_INVALID_HID, "invalid file identifier") /* Reopen the file */ - if(NULL == (new_file = H5F__reopen(old_file))) + if(H5VL_file_optional(vol_obj->data, vol_obj->driver->cls, H5P_DATASET_XFER_DEFAULT, + H5_REQUEST_NULL, H5VL_FILE_REOPEN, &file) < 0) + HGOTO_ERROR(H5E_FILE, H5E_CANTINIT, H5I_INVALID_HID, "unable to reopen file via the VOL driver") + + /* Make sure that worked */ + if(NULL == file) HGOTO_ERROR(H5E_FILE, H5E_CANTINIT, H5I_INVALID_HID, "unable to reopen file") /* Get an atom for the file */ - if((ret_value = H5I_register(H5I_FILE, new_file, TRUE)) < 0) + if((ret_value = H5VL_register_id(H5I_FILE, file, vol_obj->driver, TRUE)) < 0) HGOTO_ERROR(H5E_ATOM, H5E_CANTREGISTER, H5I_INVALID_HID, "unable to atomize file handle") - /* Keep this ID in file object structure */ - new_file->file_id = ret_value; - done: - if(H5I_INVALID_HID == ret_value) - if(new_file && H5F__dest(new_file, FALSE) < 0) - HDONE_ERROR(H5E_FILE, H5E_CANTCLOSEFILE, H5I_INVALID_HID, "can't close file") - + /* XXX (VOL MERGE): If registration fails, file will not be closed */ FUNC_LEAVE_API(ret_value) } /* end H5Freopen() */ @@ -970,31 +914,17 @@ H5Fget_intent(hid_t file_id, unsigned *intent_flags) /* If no intent flags were passed in, exit quietly */ if(intent_flags) { - H5F_t *file; /* Pointer to file structure */ + H5VL_object_t *vol_obj; /* File info */ /* Get the internal file structure */ - if(NULL == (file = (H5F_t *)H5I_object_verify(file_id, H5I_FILE))) - HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a file") - - /* HDF5 uses some flags internally that users don't know about. - * Simplify things for them so that they only get either H5F_ACC_RDWR - * or H5F_ACC_RDONLY. - */ - if(H5F_INTENT(file) & H5F_ACC_RDWR) { - *intent_flags = H5F_ACC_RDWR; - - /* Check for SWMR write access on the file */ - if(H5F_INTENT(file) & H5F_ACC_SWMR_WRITE) - *intent_flags |= H5F_ACC_SWMR_WRITE; - } /* end if */ - else { - *intent_flags = H5F_ACC_RDONLY; + if(NULL == (vol_obj = (H5VL_object_t *)H5I_object(file_id))) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "invalid file identifier") - /* Check for SWMR read access on the file */ - if(H5F_INTENT(file) & H5F_ACC_SWMR_READ) - *intent_flags |= H5F_ACC_SWMR_READ; - } /* end else */ - } /* end if */ + /* Get the flags */ + if((ret_value = H5VL_file_get(vol_obj->data, vol_obj->driver->cls, H5VL_FILE_GET_INTENT, + H5P_DATASET_XFER_DEFAULT, H5_REQUEST_NULL, intent_flags)) < 0) + HGOTO_ERROR(H5E_FILE, H5E_CANTGET, FAIL, "unable to get file's intent flags") + } done: FUNC_LEAVE_API(ret_value) @@ -1015,23 +945,21 @@ done: hssize_t H5Fget_freespace(hid_t file_id) { - H5F_t *file; /* File object for file ID */ - hsize_t tot_space; /* Amount of free space in the file */ + H5VL_object_t *vol_obj = NULL; hssize_t ret_value; /* Return value */ FUNC_ENTER_API((-1)) H5TRACE1("Hs", "i", file_id); /* Get the file object */ - if(NULL == (file = (H5F_t *)H5I_object_verify(file_id, H5I_FILE))) + if(NULL == (vol_obj = (H5VL_object_t *)H5I_object(file_id))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, (-1), "invalid file identifier") /* Get the amount of free space in the file */ - if(H5MF_get_freespace(file, &tot_space, NULL) < 0) + if(H5VL_file_optional(vol_obj->data, vol_obj->driver->cls, H5P_DATASET_XFER_DEFAULT, + H5_REQUEST_NULL, H5VL_FILE_GET_FREE_SPACE, &ret_value) < 0) HGOTO_ERROR(H5E_FILE, H5E_CANTGET, (-1), "unable to get file free space") - ret_value = (hssize_t)tot_space; - done: FUNC_LEAVE_API(ret_value) } /* end H5Fget_freespace() */ @@ -1051,9 +979,7 @@ done: herr_t H5Fget_filesize(hid_t file_id, hsize_t *size) { - H5F_t *file; /* File object for file ID */ - haddr_t max_eof_eoa; /* Maximum of the EOA & EOF */ - haddr_t base_addr; /* Base address for the file */ + H5VL_object_t *vol_obj; /* File info */ herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_API(FAIL) @@ -1062,18 +988,13 @@ H5Fget_filesize(hid_t file_id, hsize_t *size) /* Check args */ if(!size) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "size parameter cannot be NULL") - if(NULL == (file = (H5F_t *)H5I_object_verify(file_id, H5I_FILE))) + if(NULL == (vol_obj = (H5VL_object_t *)H5I_object_verify(file_id, H5I_FILE))) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "not a file ID") - /* Get the actual file size */ - if(H5F__get_max_eof_eoa(file, &max_eof_eoa) < 0) - HGOTO_ERROR(H5E_FILE, H5E_CANTGET, FAIL, "file can't get max eof/eoa ") - - base_addr = H5FD_get_base_addr(file->shared->lf); - - /* Convert relative base address for file to absolute address */ - if(size) - *size = (hsize_t)(max_eof_eoa + base_addr); + /* Get the file size */ + if(H5VL_file_optional(vol_obj->data, vol_obj->driver->cls, H5P_DATASET_XFER_DEFAULT, + H5_REQUEST_NULL, H5VL_FILE_GET_SIZE, size) < 0) + HGOTO_ERROR(H5E_FILE, H5E_CANTGET, FAIL, "unable to get file size") done: FUNC_LEAVE_API(ret_value) @@ -1122,19 +1043,19 @@ done: ssize_t H5Fget_file_image(hid_t file_id, void *buf_ptr, size_t buf_len) { - H5F_t *file; /* File object for file ID */ + H5VL_object_t *vol_obj; /* File object for file ID */ ssize_t ret_value; /* Return value */ FUNC_ENTER_API((-1)) H5TRACE3("Zs", "i*xz", file_id, buf_ptr, buf_len); /* Check args */ - if(NULL == (file = (H5F_t *)H5I_object_verify(file_id, H5I_FILE))) + if(NULL == (vol_obj = (H5VL_object_t *)H5I_object_verify(file_id, H5I_FILE))) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, (-1), "not a file ID") /* Get the file image */ - /* (Should not trigger raw data I/O - QAK, 2018/01/03) */ - if((ret_value = H5F__get_file_image(file, buf_ptr, buf_len)) < 0) + if(H5VL_file_optional(vol_obj->data, vol_obj->driver->cls, H5P_DATASET_XFER_DEFAULT, H5_REQUEST_NULL, + H5VL_FILE_GET_FILE_IMAGE, buf_ptr, &ret_value, buf_len) < 0) HGOTO_ERROR(H5E_FILE, H5E_CANTGET, (-1), "unable to get file image") done: @@ -1159,20 +1080,23 @@ done: herr_t H5Fget_mdc_config(hid_t file_id, H5AC_cache_config_t *config_ptr) { - H5F_t *file; /* File object for file ID */ + H5VL_object_t *vol_obj = NULL; herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_API(FAIL) H5TRACE2("e", "i*x", file_id, config_ptr); /* Check args */ - if(NULL == (file = (H5F_t *)H5I_object_verify(file_id, H5I_FILE))) - HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "not a file ID") if((NULL == config_ptr) || (config_ptr->version != H5AC__CURR_CACHE_CONFIG_VERSION)) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "Bad config_ptr") + /* Get the file object */ + if(NULL == (vol_obj = (H5VL_object_t *)H5I_object(file_id))) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "invalid file identifier") + /* Get the metadata cache configuration */ - if(H5AC_get_cache_auto_resize_config(file->shared->cache, config_ptr) < 0) + if(H5VL_file_optional(vol_obj->data, vol_obj->driver->cls, H5P_DATASET_XFER_DEFAULT, + H5_REQUEST_NULL, H5VL_FILE_GET_MDC_CONF, config_ptr) < 0) HGOTO_ERROR(H5E_FILE, H5E_CANTGET, FAIL, "unable to get metadata cache configuration") done: @@ -1194,18 +1118,19 @@ done: herr_t H5Fset_mdc_config(hid_t file_id, H5AC_cache_config_t *config_ptr) { - H5F_t *file; /* File object for file ID */ + H5VL_object_t *vol_obj = NULL; herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_API(FAIL) H5TRACE2("e", "i*x", file_id, config_ptr); /* Get the file object */ - if(NULL == (file = (H5F_t *)H5I_object_verify(file_id, H5I_FILE))) + if(NULL == (vol_obj = (H5VL_object_t *)H5I_object(file_id))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "invalid file identifier") /* Set the metadata cache configuration */ - if(H5AC_set_cache_auto_resize_config(file->shared->cache, config_ptr) < 0) + if(H5VL_file_optional(vol_obj->data, vol_obj->driver->cls, H5P_DATASET_XFER_DEFAULT, + H5_REQUEST_NULL, H5VL_FILE_SET_MDC_CONFIG, config_ptr) < 0) HGOTO_ERROR(H5E_FILE, H5E_CANTSET, FAIL, "unable to set metadata cache configuration") done: @@ -1228,21 +1153,21 @@ done: herr_t H5Fget_mdc_hit_rate(hid_t file_id, double *hit_rate_ptr) { - H5F_t *file; /* File object for file ID */ + H5VL_object_t *vol_obj; herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_API(FAIL) H5TRACE2("e", "i*d", file_id, hit_rate_ptr); /* Check args */ - if(NULL == (file = (H5F_t *)H5I_object_verify(file_id, H5I_FILE))) - HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "not a file ID") - if(NULL == hit_rate_ptr) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "NULL hit rate pointer") + if(NULL == (vol_obj = (H5VL_object_t *)H5I_object_verify(file_id, H5I_FILE))) + HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "not a file ID") /* Get the current hit rate */ - if(H5AC_get_cache_hit_rate(file->shared->cache, hit_rate_ptr) < 0) + if(H5VL_file_optional(vol_obj->data, vol_obj->driver->cls, H5P_DATASET_XFER_DEFAULT, + H5_REQUEST_NULL, H5VL_FILE_GET_MDC_HR, hit_rate_ptr) < 0) HGOTO_ERROR(H5E_FILE, H5E_CANTGET, FAIL, "unable to get MDC hit rate") done: @@ -1267,8 +1192,7 @@ herr_t H5Fget_mdc_size(hid_t file_id, size_t *max_size_ptr, size_t *min_clean_size_ptr, size_t *cur_size_ptr, int *cur_num_entries_ptr) { - H5F_t *file; /* File object for file ID */ - uint32_t cur_num_entries; + H5VL_object_t *vol_obj; herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_API(FAIL) @@ -1276,17 +1200,15 @@ H5Fget_mdc_size(hid_t file_id, size_t *max_size_ptr, size_t *min_clean_size_ptr, cur_size_ptr, cur_num_entries_ptr); /* Check args */ - if(NULL == (file = (H5F_t *)H5I_object_verify(file_id, H5I_FILE))) + if(NULL == (vol_obj = (H5VL_object_t *)H5I_object_verify(file_id, H5I_FILE))) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "not a file ID") /* Get the size data */ - if(H5AC_get_cache_size(file->shared->cache, max_size_ptr, - min_clean_size_ptr, cur_size_ptr, &cur_num_entries) < 0) + if(H5VL_file_optional(vol_obj->data, vol_obj->driver->cls, H5P_DATASET_XFER_DEFAULT, + H5_REQUEST_NULL, H5VL_FILE_GET_MDC_SIZE, + max_size_ptr, min_clean_size_ptr, cur_size_ptr, cur_num_entries_ptr) < 0) HGOTO_ERROR(H5E_FILE, H5E_CANTGET, FAIL, "unable to get MDC size") - if(cur_num_entries_ptr != NULL) - *cur_num_entries_ptr = (int)cur_num_entries; - done: FUNC_LEAVE_API(ret_value) } /* H5Fget_mdc_size() */ @@ -1311,18 +1233,19 @@ done: herr_t H5Freset_mdc_hit_rate_stats(hid_t file_id) { - H5F_t *file; /* File object for file ID */ + H5VL_object_t *vol_obj = NULL; herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_API(FAIL) H5TRACE1("e", "i", file_id); /* Get the file object */ - if(NULL == (file = (H5F_t *)H5I_object_verify(file_id, H5I_FILE))) + if(NULL == (vol_obj = (H5VL_object_t *)H5I_object(file_id))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "invalid file identifier") /* Reset the hit rate statistic */ - if(H5AC_reset_cache_hit_rate_stats(file->shared->cache) < 0) + if(H5VL_file_optional(vol_obj->data, vol_obj->driver->cls, H5P_DATASET_XFER_DEFAULT, + H5_REQUEST_NULL, H5VL_FILE_RESET_MDC_HIT_RATE) < 0) HGOTO_ERROR(H5E_FILE, H5E_CANTSET, FAIL, "can't reset cache hit rate") done: @@ -1354,40 +1277,26 @@ done: ssize_t H5Fget_name(hid_t obj_id, char *name/*out*/, size_t size) { - H5F_t *f; /* Top file in mount hierarchy */ - size_t len; + H5VL_object_t *vol_obj = NULL; + H5I_type_t type; ssize_t ret_value = -1; FUNC_ENTER_API((-1)) H5TRACE3("Zs", "ixz", obj_id, name, size); - /* For file IDs, get the file object directly */ - /* (This prevents the H5G_loc() call from returning the file pointer for - * the top file in a mount hierarchy) - */ - if(H5I_get_type(obj_id) == H5I_FILE ) { - if(NULL == (f = (H5F_t *)H5I_object(obj_id))) - HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, (-1), "not a file") - } /* end if */ - else { - H5G_loc_t loc; /* Object location */ - - /* Get symbol table entry */ - if(H5G_loc(obj_id, &loc) < 0) - HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, (-1), "not a valid object ID") - f = loc.oloc->file; - } /* end else */ - - len = HDstrlen(H5F_OPEN_NAME(f)); + /* Check the type */ + type = H5I_get_type(obj_id); + if(H5I_FILE != type && H5I_GROUP != type && H5I_DATATYPE != type && H5I_DATASET != type && H5I_ATTR != type) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, (-1), "not a file or file object") - if(name) { - HDstrncpy(name, H5F_OPEN_NAME(f), MIN(len + 1,size)); - if(len >= size) - name[size-1]='\0'; - } /* end if */ + /* Get the file object */ + if(NULL == (vol_obj = H5VL_get_object(obj_id))) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, (-1), "invalid file identifier") - /* Set return value */ - ret_value = (ssize_t)len; + /* Get the filename via the VOL */ + if(H5VL_file_get(vol_obj->data, vol_obj->driver->cls, H5VL_FILE_GET_NAME, + H5P_DATASET_XFER_DEFAULT, H5_REQUEST_NULL, type, size, name, &ret_value) < 0) + HGOTO_ERROR(H5E_FILE, H5E_CANTGET, (-1), "unable to get file name") done: FUNC_LEAVE_API(ret_value) @@ -1410,7 +1319,7 @@ done: herr_t H5Fget_info2(hid_t obj_id, H5F_info2_t *finfo) { - H5F_t *f; /* Top file in mount hierarchy */ + H5VL_object_t *vol_obj = NULL; H5I_type_t type; herr_t ret_value = SUCCEED; /* Return value */ @@ -1427,25 +1336,12 @@ H5Fget_info2(hid_t obj_id, H5F_info2_t *finfo) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a file or file object") /* Get the file object */ - if(type == H5I_FILE ) { - /* For file IDs, get the file object directly */ - /* (This prevents the H5G_loc() call from returning the file pointer for - * the top file in a mount hierarchy) - */ - if(NULL == (f = (H5F_t *)H5I_object(obj_id))) - HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "invalid file identifier") - } /* end if */ - else { - H5G_loc_t loc; /* Object location */ - - /* Get symbol table entry */ - if(H5G_loc(obj_id, &loc) < 0) - HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "invalid object identifier") - f = loc.oloc->file; - } /* end else */ + if(NULL == (vol_obj = H5VL_get_object(obj_id))) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "invalid object identifier") /* Get the file information */ - if(H5F__get_info(f, finfo) < 0) + if(H5VL_file_optional(vol_obj->data, vol_obj->driver->cls, H5P_DATASET_XFER_DEFAULT, H5_REQUEST_NULL, + H5VL_FILE_GET_INFO, type, finfo) < 0) HGOTO_ERROR(H5E_FILE, H5E_CANTGET, FAIL, "unable to retrieve file info") done: @@ -1466,7 +1362,7 @@ done: herr_t H5Fget_metadata_read_retry_info(hid_t file_id, H5F_retry_info_t *info) { - H5F_t *file; /* File object for file ID */ + H5VL_object_t *vol_obj = NULL; /* File object for file ID */ herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_API(FAIL) @@ -1477,11 +1373,12 @@ H5Fget_metadata_read_retry_info(hid_t file_id, H5F_retry_info_t *info) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "no info struct") /* Get the file pointer */ - if(NULL == (file = (H5F_t *)H5I_object_verify(file_id, H5I_FILE))) + if(NULL == (vol_obj = (H5VL_object_t *)H5I_object_verify(file_id, H5I_FILE))) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "not a file ID") /* Get the retry info */ - if(H5F_get_metadata_read_retry_info(file, info) < 0) + if(H5VL_file_optional(vol_obj->data, vol_obj->driver->cls, H5P_DATASET_XFER_DEFAULT, + H5_REQUEST_NULL, H5VL_FILE_GET_METADATA_READ_RETRY_INFO, info) < 0) HGOTO_ERROR(H5E_FILE, H5E_CANTRELEASE, FAIL, "can't get metadata read retry info") done: @@ -1507,20 +1404,21 @@ ssize_t H5Fget_free_sections(hid_t file_id, H5F_mem_t type, size_t nsects, H5F_sect_info_t *sect_info/*out*/) { - H5F_t *file; + H5VL_object_t *vol_obj = NULL; ssize_t ret_value = -1; /* Return value */ FUNC_ENTER_API((-1)) H5TRACE4("Zs", "iFmzx", file_id, type, nsects, sect_info); /* Check args */ - if(NULL == (file = (H5F_t *)H5I_object_verify(file_id, H5I_FILE))) + if(NULL == (vol_obj = (H5VL_object_t *)H5I_object_verify(file_id, H5I_FILE))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, (-1), "invalid file identifier") if(sect_info && nsects == 0) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, (-1), "nsects must be > 0") /* Get the free-space section information in the file */ - if((ret_value = H5MF_get_free_sections(file, type, nsects, sect_info)) < 0) + if(H5VL_file_optional(vol_obj->data, vol_obj->driver->cls, H5P_DATASET_XFER_DEFAULT, H5_REQUEST_NULL, + H5VL_FILE_GET_FREE_SECTIONS, sect_info, &ret_value, type, nsects) < 0) HGOTO_ERROR(H5E_FILE, H5E_CANTGET, (-1), "unable to get file free sections") done: @@ -1542,21 +1440,20 @@ done: herr_t H5Fclear_elink_file_cache(hid_t file_id) { - H5F_t *file; /* File */ + H5VL_object_t *vol_obj; /* File */ herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_API(FAIL) H5TRACE1("e", "i", file_id); /* Check args */ - if(NULL == (file = (H5F_t *)H5I_object_verify(file_id, H5I_FILE))) + if(NULL == (vol_obj = (H5VL_object_t *)H5I_object_verify(file_id, H5I_FILE))) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "not a file ID") - /* See if there's an EFC */ - if(file->shared->efc) - /* Release the EFC */ - if(H5F__efc_release(file->shared->efc) < 0) - HGOTO_ERROR(H5E_FILE, H5E_CANTRELEASE, FAIL, "can't release external file cache") + /* Release the EFC */ + if(H5VL_file_optional(vol_obj->data, vol_obj->driver->cls, H5P_DATASET_XFER_DEFAULT, + H5_REQUEST_NULL, H5VL_FILE_CLEAR_ELINK_CACHE) < 0) + HGOTO_ERROR(H5E_FILE, H5E_CANTRELEASE, FAIL, "can't release external file cache") done: FUNC_LEAVE_API(ret_value) @@ -1600,14 +1497,14 @@ done: herr_t H5Fstart_swmr_write(hid_t file_id) { - H5F_t *file = NULL; /* File info */ + H5VL_object_t *vol_obj = NULL; /* File info */ herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_API(FAIL) H5TRACE1("e", "i", file_id); /* Check args */ - if(NULL == (file = (H5F_t *)H5I_object_verify(file_id, H5I_FILE))) + if(NULL == (vol_obj = (H5VL_object_t *)H5I_object_verify(file_id, H5I_FILE))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "hid_t identifier is not a file ID") /* Set up collective metadata if appropriate */ @@ -1615,7 +1512,8 @@ H5Fstart_swmr_write(hid_t file_id) HGOTO_ERROR(H5E_FILE, H5E_CANTSET, FAIL, "can't set collective metadata read info") /* start SWMR writing */ - if(H5F__start_swmr_write(file) < 0) + if(H5VL_file_optional(vol_obj->data, vol_obj->driver->cls, H5P_DATASET_XFER_DEFAULT, + H5_REQUEST_NULL, H5VL_FILE_START_SWMR_WRITE) < 0) HGOTO_ERROR(H5E_FILE, H5E_SYSTEM, FAIL, "unable to start SWMR writing") done: @@ -1636,18 +1534,19 @@ done: herr_t H5Fstart_mdc_logging(hid_t file_id) { - H5F_t *file; /* File info */ - herr_t ret_value = SUCCEED; /* Return value */ + H5VL_object_t *vol_obj; /* File info */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_API(FAIL) H5TRACE1("e", "i", file_id); /* Sanity check */ - if(NULL == (file = (H5F_t *)H5I_object_verify(file_id, H5I_FILE))) + if(NULL == (vol_obj = (H5VL_object_t *)H5I_object_verify(file_id, H5I_FILE))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "hid_t identifier is not a file ID") /* Call mdc logging function */ - if(H5C_start_logging(file->shared->cache) < 0) + if(H5VL_file_optional(vol_obj->data, vol_obj->driver->cls, H5P_DATASET_XFER_DEFAULT, + H5_REQUEST_NULL, H5VL_FILE_START_MDC_LOGGING) < 0) HGOTO_ERROR(H5E_FILE, H5E_LOGFAIL, FAIL, "unable to start mdc logging") done: @@ -1669,18 +1568,19 @@ done: herr_t H5Fstop_mdc_logging(hid_t file_id) { - H5F_t *file; /* File info */ - herr_t ret_value = SUCCEED; /* Return value */ + H5VL_object_t *vol_obj; /* File info */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_API(FAIL) H5TRACE1("e", "i", file_id); /* Sanity check */ - if(NULL == (file = (H5F_t *)H5I_object_verify(file_id, H5I_FILE))) + if(NULL == (vol_obj = (H5VL_object_t *)H5I_object_verify(file_id, H5I_FILE))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "hid_t identifier is not a file ID") /* Call mdc logging function */ - if(H5C_stop_logging(file->shared->cache) < 0) + if(H5VL_file_optional(vol_obj->data, vol_obj->driver->cls, H5P_DATASET_XFER_DEFAULT, + H5_REQUEST_NULL, H5VL_FILE_STOP_MDC_LOGGING) < 0) HGOTO_ERROR(H5E_FILE, H5E_LOGFAIL, FAIL, "unable to stop mdc logging") done: @@ -1703,18 +1603,19 @@ herr_t H5Fget_mdc_logging_status(hid_t file_id, hbool_t *is_enabled, hbool_t *is_currently_logging) { - H5F_t *file; /* File info */ - herr_t ret_value = SUCCEED; /* Return value */ + H5VL_object_t *vol_obj; /* File info */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_API(FAIL) H5TRACE3("e", "i*b*b", file_id, is_enabled, is_currently_logging); /* Sanity check */ - if(NULL == (file = (H5F_t *)H5I_object_verify(file_id, H5I_FILE))) + if(NULL == (vol_obj = (H5VL_object_t *)H5I_object_verify(file_id, H5I_FILE))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "hid_t identifier is not a file ID") /* Call mdc logging function */ - if(H5C_get_logging_status(file->shared->cache, is_enabled, is_currently_logging) < 0) + if(H5VL_file_optional(vol_obj->data, vol_obj->driver->cls, H5P_DATASET_XFER_DEFAULT, + H5_REQUEST_NULL, H5VL_FILE_GET_MDC_LOGGING_STATUS, is_enabled, is_currently_logging) < 0) HGOTO_ERROR(H5E_FILE, H5E_LOGFAIL, FAIL, "unable to get logging status") done: @@ -1734,9 +1635,12 @@ done: * *------------------------------------------------------------------------- */ +/* XXX (VOL MERGE): This could go in the native VOL driver under 'optional' + */ herr_t H5Fset_libver_bounds(hid_t file_id, H5F_libver_t low, H5F_libver_t high) { + H5VL_object_t *vol_obj; /* File as VOL object */ H5F_t *f; /* File */ herr_t ret_value = SUCCEED; /* Return value */ @@ -1744,8 +1648,9 @@ H5Fset_libver_bounds(hid_t file_id, H5F_libver_t low, H5F_libver_t high) H5TRACE3("e", "iFvFv", file_id, low, high); /* Check args */ - if(NULL == (f = (H5F_t *)H5I_object_verify(file_id, H5I_FILE))) + if(NULL == (vol_obj = (H5VL_object_t *)H5I_object_verify(file_id, H5I_FILE))) HGOTO_ERROR(H5E_FILE, H5E_BADVALUE, FAIL, "not a file ID") + f = (H5F_t *)(vol_obj->data); /* Set up collective metadata if appropriate */ if(H5CX_set_loc(file_id) < 0) @@ -1774,26 +1679,23 @@ done: herr_t H5Fformat_convert(hid_t file_id) { - H5F_t *f = NULL; /* File */ + H5VL_object_t *vol_obj = NULL; /* File */ herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_API(FAIL) H5TRACE1("e", "i", file_id); /* Check args */ - if(H5I_FILE != H5I_get_type(file_id)) + if(NULL == (vol_obj = (H5VL_object_t *)H5I_object_verify(file_id, H5I_FILE))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "file_id parameter is not a valid file identifier") - /* Get file object */ - if(NULL == (f = (H5F_t *)H5I_object(file_id))) - HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "invalid file identifier") - /* Set up collective metadata if appropriate */ if(H5CX_set_loc(file_id) < 0) HGOTO_ERROR(H5E_FILE, H5E_CANTSET, FAIL, "can't set collective metadata read info") /* Convert the format */ - if(H5F__format_convert(f) < 0) + if(H5VL_file_optional(vol_obj->data, vol_obj->driver->cls, H5P_DATASET_XFER_DEFAULT, + H5_REQUEST_NULL, H5VL_FILE_FORMAT_CONVERT) < 0) HGOTO_ERROR(H5E_FILE, H5E_CANTCONVERT, FAIL, "can't convert file format") done: @@ -1813,20 +1715,19 @@ done: herr_t H5Freset_page_buffering_stats(hid_t file_id) { - H5F_t *file; /* File to reset stats on */ + H5VL_object_t *vol_obj; /* File to reset stats on */ herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_API(FAIL) H5TRACE1("e", "i", file_id); /* Check args */ - if(NULL == (file = (H5F_t *)H5I_object(file_id))) + if(NULL == (vol_obj = (H5VL_object_t *)H5I_object_verify(file_id, H5I_FILE))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "invalid file identifier") - if(NULL == file->shared->page_buf) - HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "page buffering not enabled on file") /* Reset the statistics */ - if(H5PB_reset_stats(file->shared->page_buf) < 0) + if(H5VL_file_optional(vol_obj->data, vol_obj->driver->cls, H5P_DATASET_XFER_DEFAULT, + H5_REQUEST_NULL, H5VL_FILE_RESET_PAGE_BUFFERING_STATS) < 0) HGOTO_ERROR(H5E_FILE, H5E_CANTSET, FAIL, "can't reset stats for page buffering") done: @@ -1847,23 +1748,23 @@ herr_t H5Fget_page_buffering_stats(hid_t file_id, unsigned accesses[2], unsigned hits[2], unsigned misses[2], unsigned evictions[2], unsigned bypasses[2]) { - H5F_t *file; /* File object */ - herr_t ret_value = SUCCEED; /* Return value */ + H5VL_object_t *vol_obj; /* File object */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_API(FAIL) H5TRACE6("e", "i*Iu*Iu*Iu*Iu*Iu", file_id, accesses, hits, misses, evictions, bypasses); /* Check args */ - if(NULL == (file = (H5F_t *)H5I_object_verify(file_id, H5I_FILE))) + if(NULL == (vol_obj = (H5VL_object_t *)H5I_object_verify(file_id, H5I_FILE))) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "not a file ID") - if(NULL == file->shared->page_buf) - HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "page buffering not enabled on file") if(NULL == accesses || NULL == hits || NULL == misses || NULL == evictions || NULL == bypasses) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "NULL input parameters for stats") /* Get the statistics */ - if(H5PB_get_stats(file->shared->page_buf, accesses, hits, misses, evictions, bypasses) < 0) + if(H5VL_file_optional(vol_obj->data, vol_obj->driver->cls, H5P_DATASET_XFER_DEFAULT, + H5_REQUEST_NULL, H5VL_FILE_GET_PAGE_BUFFERING_STATS, + accesses, hits, misses, evictions, bypasses) < 0) HGOTO_ERROR(H5E_FILE, H5E_CANTGET, FAIL, "can't retrieve stats for page buffering") done: @@ -1894,7 +1795,7 @@ H5Fget_mdc_image_info(hid_t file_id, haddr_t *image_addr, hsize_t *image_len) H5TRACE3("e", "i*a*h", file_id, image_addr, image_len); /* Check args */ - if(NULL == (file = (H5F_t *)H5I_object_verify(file_id, H5I_FILE))) + if(NULL == (file = (H5F_t *)H5VL_object_verify(file_id, H5I_FILE))) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "not a file ID") if(NULL == image_addr || NULL == image_len) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "NULL image addr or image len") @@ -1929,7 +1830,7 @@ H5Fget_eoa(hid_t file_id, haddr_t *eoa) H5TRACE2("e", "i*a", file_id, eoa); /* Check args */ - if(NULL == (file = (H5F_t *)H5I_object_verify(file_id, H5I_FILE))) + if(NULL == (file = (H5F_t *)H5VL_object_verify(file_id, H5I_FILE))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "hid_t identifier is not a file ID") /* This public routine will work only for drivers with this feature enabled.*/ @@ -1968,7 +1869,7 @@ H5Fincrement_filesize(hid_t file_id, hsize_t increment) H5TRACE2("e", "ih", file_id, increment); /* Check args */ - if(NULL == (file = (H5F_t *)H5I_object_verify(file_id, H5I_FILE))) + if(NULL == (file = (H5F_t *)H5VL_object_verify(file_id, H5I_FILE))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "hid_t identifier is not a file ID") /* This public routine will work only for drivers with this feature enabled.*/ diff --git a/src/H5Fdeprec.c b/src/H5Fdeprec.c index c91d0ea..6fee596 100644 --- a/src/H5Fdeprec.c +++ b/src/H5Fdeprec.c @@ -113,7 +113,7 @@ H5Fget_info1(hid_t obj_id, H5F_info1_t *finfo) * the top file in a mount hierarchy) */ if(H5I_get_type(obj_id) == H5I_FILE ) { - if(NULL == (f = (H5F_t *)H5I_object(obj_id))) + if(NULL == (f = (H5F_t *)H5VL_object(obj_id))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a file") } else { @@ -141,6 +141,41 @@ done: /*------------------------------------------------------------------------- + * Function: H5Fis_hdf5 + * + * Purpose: Check the file signature to detect an HDF5 file. + * + * Bugs: This function is not robust: it only uses the default file + * driver when attempting to open the file when in fact it + * should use all known file drivers. + * + * Return: TRUE/FALSE/FAIL + * + *------------------------------------------------------------------------- + */ +htri_t +H5Fis_hdf5(const char *name) +{ + htri_t ret_value; /* Return value */ + + FUNC_ENTER_API((-1)) + H5TRACE1("t", "*s", name); + + /* Check args and all the boring stuff. */ + if(!name || !*name) + HGOTO_ERROR(H5E_ARGS, H5E_BADRANGE, (-1), "no file name specified") + + /* call the private is_HDF5 function */ + if((ret_value = H5F__is_hdf5(name, H5P_FILE_ACCESS_DEFAULT)) < 0) + HGOTO_ERROR(H5E_FILE, H5E_NOTHDF5, (-1), "unable open file") + +done: + + FUNC_LEAVE_API(ret_value) +} /* end H5Fis_hdf5() */ + + +/*------------------------------------------------------------------------- * Function: H5Fset_latest_format * * Purpose: Enable switching between latest or non-latest format while @@ -174,20 +209,24 @@ done: * *------------------------------------------------------------------------- */ +/* XXX (VOL MERGE): This could go in the native VOL driver under 'optional'. + */ herr_t H5Fset_latest_format(hid_t file_id, hbool_t latest_format) { - H5F_t *f; /* File */ - H5F_libver_t low = H5F_LIBVER_LATEST; /* Low bound */ - H5F_libver_t high = H5F_LIBVER_LATEST; /* High bound */ - herr_t ret_value = SUCCEED; /* Return value */ + H5VL_object_t *vol_obj; /* File as VOL object */ + H5F_t *f; /* File */ + H5F_libver_t low = H5F_LIBVER_LATEST; /* Low bound */ + H5F_libver_t high = H5F_LIBVER_LATEST; /* High bound */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_API(FAIL) H5TRACE2("e", "ib", file_id, latest_format); /* Check args */ - if(NULL == (f = (H5F_t *)H5I_object_verify(file_id, H5I_FILE))) + if(NULL == (vol_obj = (H5VL_object_t *)H5I_object_verify(file_id, H5I_FILE))) HGOTO_ERROR(H5E_FILE, H5E_BADVALUE, FAIL, "not a file ID") + f = (H5F_t *)(vol_obj->data); /* 'low' and 'high' are both initialized to LATEST. * If latest format is not expected, set 'low' to EARLIEST diff --git a/src/H5Fint.c b/src/H5Fint.c index 39934d6..230a744 100644 --- a/src/H5Fint.c +++ b/src/H5Fint.c @@ -37,6 +37,9 @@ #include "H5Pprivate.h" /* Property lists */ #include "H5SMprivate.h" /* Shared Object Header Messages */ #include "H5Tprivate.h" /* Datatypes */ +#include "H5VLprivate.h" /* VOL drivers */ + +#include "H5VLnative.h" /* Native VOL driver */ /****************/ @@ -438,6 +441,7 @@ H5F__get_objects_cb(void *obj_ptr, hid_t obj_id, void *key) case H5I_DATASPACE: case H5I_REFERENCE: case H5I_VFL: + case H5I_VOL: case H5I_GENPROP_CLS: case H5I_GENPROP_LST: case H5I_ERROR_CLASS: @@ -782,15 +786,11 @@ done: * * Purpose: Check the file signature to detect an HDF5 file. * - * Bugs: This function is not robust: it only uses the default file - * driver when attempting to open the file when in fact it - * should use all known file drivers. - * * Return: TRUE/FALSE/FAIL *------------------------------------------------------------------------- */ htri_t -H5F__is_hdf5(const char *name) +H5F__is_hdf5(const char *name, hid_t fapl_id) { H5FD_t *file = NULL; /* Low-level file struct */ haddr_t sig_addr; /* Addess of hdf5 file signature */ @@ -799,7 +799,10 @@ H5F__is_hdf5(const char *name) FUNC_ENTER_PACKAGE /* Open the file */ - if(NULL == (file = H5FD_open(name, H5F_ACC_RDONLY, H5P_FILE_ACCESS_DEFAULT, HADDR_UNDEF))) + /* NOTE: This now uses the fapl_id that was passed in, so H5Fis_accessible() + * should work with arbitrary VFDs, unlike H5Fis_hdf5(). + */ + if(NULL == (file = H5FD_open(name, H5F_ACC_RDONLY, fapl_id, HADDR_UNDEF))) HGOTO_ERROR(H5E_IO, H5E_CANTINIT, FAIL, "unable to open file") /* The file is an hdf5 file if the hdf5 file signature can be found */ @@ -843,7 +846,7 @@ H5F__new(H5F_file_t *shared, unsigned flags, hid_t fcpl_id, hid_t fapl_id, H5FD_ if(NULL == (f = H5FL_CALLOC(H5F_t))) HGOTO_ERROR(H5E_FILE, H5E_NOSPACE, NULL, "can't allocate top file structure") - f->file_id = H5I_INVALID_HID; + f->id_exists = FALSE; if(shared) { HDassert(lf == NULL); @@ -1468,26 +1471,12 @@ H5F_open(const char *name, unsigned flags, hid_t fcpl_id, hid_t fapl_id) tent_flags = flags; if(NULL == (lf = H5FD_open(name, tent_flags, fapl_id, HADDR_UNDEF))) { - if(tent_flags == flags) { -#ifndef H5_USING_MEMCHECKER - time_t mytime = HDtime(NULL); - - HGOTO_ERROR(H5E_FILE, H5E_CANTOPENFILE, NULL, "unable to open file: time = %s, name = '%s', tent_flags = %x", HDctime(&mytime), name, tent_flags) -#else /* H5_USING_MEMCHECKER */ + if(tent_flags == flags) HGOTO_ERROR(H5E_FILE, H5E_CANTOPENFILE, NULL, "unable to open file: name = '%s', tent_flags = %x", name, tent_flags) -#endif /* H5_USING_MEMCHECKER */ - } /* end if */ H5E_clear_stack(NULL); tent_flags = flags; - if(NULL == (lf = H5FD_open(name, tent_flags, fapl_id, HADDR_UNDEF))) { -#ifndef H5_USING_MEMCHECKER - time_t mytime = HDtime(NULL); - - HGOTO_ERROR(H5E_FILE, H5E_CANTOPENFILE, NULL, "unable to open file: time = %s, name = '%s', tent_flags = %x", HDctime(&mytime), name, tent_flags) -#else /* H5_USING_MEMCHECKER */ + if(NULL == (lf = H5FD_open(name, tent_flags, fapl_id, HADDR_UNDEF))) HGOTO_ERROR(H5E_FILE, H5E_CANTOPENFILE, NULL, "unable to open file: name = '%s', tent_flags = %x", name, tent_flags) -#endif /* H5_USING_MEMCHECKER */ - } /* end if */ } /* end if */ /* Is the file already open? */ @@ -1893,41 +1882,60 @@ H5F__flush(H5F_t *f) /*------------------------------------------------------------------------- * Function: H5F__close * - * Purpose: Internal routine to close a file. + * Purpose: Closes a file or causes the close operation to be pended. + * This function is called two ways: from the API it gets called + * by H5Fclose->H5I_dec_ref->H5F__close when H5I_dec_ref() + * decrements the file ID reference count to zero. The file ID + * is removed from the H5I_FILE group by H5I_dec_ref() just + * before H5F__close() is called. If there are open object + * headers then the close is pended by moving the file to the + * H5I_FILE_CLOSING ID group (the f->closing contains the ID + * assigned to file). + * + * This function is also called directly from H5O_close() when + * the last object header is closed for the file and the file + * has a pending close. * * Return: SUCCEED/FAIL * *------------------------------------------------------------------------- */ herr_t -H5F__close(hid_t file_id) +H5F__close(H5F_t *f) { - H5F_t *f; /* File pointer */ herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_PACKAGE - /* Flush file if this is the last reference to this id and we have write - * intent, unless it will be flushed by the "shared" file being closed. - * This is only necessary to replicate previous behaviour, and could be - * disabled by an option/property to improve performance. + /* Sanity check */ + HDassert(f); + + /* Perform checks for "semi" file close degree here, since closing the + * file is not allowed if there are objects still open. */ - if(NULL == (f = (H5F_t *)H5I_object(file_id))) - HGOTO_ERROR(H5E_FILE, H5E_BADTYPE, FAIL, "invalid file identifier") - if((f->shared->nrefs > 1) && (H5F_INTENT(f) & H5F_ACC_RDWR)) { - int nref; /* Number of references to file ID */ - - if((nref = H5I_get_ref(file_id, FALSE)) < 0) - HGOTO_ERROR(H5E_FILE, H5E_CANTGET, FAIL, "can't get ID ref count") - if(nref == 1) - if(H5F__flush(f) < 0) - HGOTO_ERROR(H5E_FILE, H5E_CANTFLUSH, FAIL, "unable to flush cache") - } /* end if */ + if(f->shared->fc_degree == H5F_CLOSE_SEMI) { + unsigned nopen_files = 0; /* Number of open files in file/mount hierarchy */ + unsigned nopen_objs = 0; /* Number of open objects in file/mount hierarchy */ + + /* Get the number of open objects and open files on this file/mount hierarchy */ + if(H5F__mount_count_ids(f, &nopen_files, &nopen_objs) < 0) + HGOTO_ERROR(H5E_SYM, H5E_MOUNT, FAIL, "problem checking mount hierarchy") + + /* If there are no other file IDs open on this file/mount hier., but + * there are still open objects, issue an error and bail out now, + * without decrementing the file ID's reference count and triggering + * a "real" attempt at closing the file. + */ + if(nopen_files == 1 && nopen_objs > 0) + HGOTO_ERROR(H5E_FILE, H5E_CANTCLOSEFILE, FAIL, "can't close file, there are objects still open") + } + + /* Reset the file ID for this file */ + f->id_exists = FALSE; - /* Decrement reference count on file ID */ - /* (When it reaches zero the file will be closed) */ - if(H5I_dec_app_ref(file_id) < 0) - HGOTO_ERROR(H5E_FILE, H5E_CANTDEC, FAIL, "decrementing file ID failed") + /* Attempt to close the file/mount hierarchy */ + if(H5F_try_close(f, NULL) < 0) + HGOTO_ERROR(H5E_FILE, H5E_CANTCLOSEFILE, FAIL, "can't close file") done: FUNC_LEAVE_NOAPI(ret_value) @@ -2167,19 +2175,18 @@ H5F_get_id(H5F_t *file, hbool_t app_ref) HDassert(file); - if(file->file_id == -1) { - /* Get an atom for the file */ - if((file->file_id = H5I_register(H5I_FILE, file, app_ref)) < 0) - HGOTO_ERROR(H5E_ATOM, H5E_CANTREGISTER, H5I_INVALID_HID, "unable to atomize file") + if(H5I_find_id(file, H5I_FILE, &ret_value) < 0 || H5I_INVALID_HID == ret_value) { + /* resurrect the ID - Register an ID with the native driver */ + if((ret_value = H5VL_native_register(H5I_FILE, file, app_ref)) < 0) + HGOTO_ERROR(H5E_ATOM, H5E_CANTREGISTER, H5I_INVALID_HID, "unable to register group") + file->id_exists = TRUE; } else { /* Increment reference count on existing ID */ - if(H5I_inc_ref(file->file_id, app_ref) < 0) + if(H5I_inc_ref(ret_value, app_ref) < 0) HGOTO_ERROR(H5E_ATOM, H5E_CANTSET, H5I_INVALID_HID, "incrementing file ID failed") } - ret_value = file->file_id; - done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5F_get_id() */ @@ -3228,6 +3235,7 @@ H5F__start_swmr_write(H5F_t *f) H5G_name_t *obj_paths = NULL; /* Group hierarchy path */ size_t u; /* Local index variable */ hbool_t setup = FALSE; /* Boolean flag to indicate whether SWMR setting is enabled */ + H5VL_t *vol_driver = NULL; /* VOL driver for the file */ herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_PACKAGE @@ -3291,6 +3299,16 @@ H5F__start_swmr_write(H5F_t *f) if(H5F_get_obj_ids(f, H5F_OBJ_GROUP|H5F_OBJ_DATASET, grp_dset_count, obj_ids, FALSE, &grp_dset_count) < 0) HGOTO_ERROR(H5E_FILE, H5E_CANTGET, FAIL, "H5F_get_obj_ids failed") + /* Save the VOL driver for the refresh step */ + if(grp_dset_count > 0) { + H5VL_object_t *vol_obj = NULL; + + if(NULL == (vol_obj = H5VL_get_object(obj_ids[0]))) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "invalid object identifier") + + vol_driver = vol_obj->driver; + } + /* Refresh opened objects (groups, datasets) in the file */ for(u = 0; u < grp_dset_count; u++) { H5O_loc_t *oloc; /* object location */ @@ -3353,7 +3371,7 @@ H5F__start_swmr_write(H5F_t *f) /* Refresh (reopen) the objects (groups & datasets) in the file */ for(u = 0; u < grp_dset_count; u++) { - if(H5O_refresh_metadata_reopen(obj_ids[u], &obj_glocs[u], TRUE) < 0) + if(H5O_refresh_metadata_reopen(obj_ids[u], &obj_glocs[u], vol_driver, TRUE) < 0) HGOTO_ERROR(H5E_ATOM, H5E_CLOSEERROR, FAIL, "can't refresh-close object") } diff --git a/src/H5Fmount.c b/src/H5Fmount.c index e6106a2..310edd4 100644 --- a/src/H5Fmount.c +++ b/src/H5Fmount.c @@ -24,6 +24,7 @@ #include "H5Iprivate.h" /* IDs */ #include "H5MMprivate.h" /* Memory management */ #include "H5Pprivate.h" /* Property lists */ +#include "H5VLprivate.h" /* Virtual Object Layer */ /* PRIVATE PROTOTYPES */ static void H5F__mount_count_ids_recurse(H5F_t *f, unsigned *nopen_files, unsigned *nopen_objs); @@ -438,8 +439,8 @@ H5F_is_mount(const H5F_t *file) herr_t H5Fmount(hid_t loc_id, const char *name, hid_t child_id, hid_t plist_id) { - H5G_loc_t loc; /* Parent location */ - H5F_t *child = NULL; /* Child object */ + H5VL_object_t *loc_vol_obj = NULL; /* Parent object */ + H5VL_object_t *child_vol_obj = NULL; /* Child object */ H5I_type_t loc_type; /* ID type of location */ H5I_type_t child_type; /* ID type of child */ herr_t ret_value = SUCCEED; /* Return value */ @@ -469,15 +470,20 @@ H5Fmount(hid_t loc_id, const char *name, hid_t child_id, hid_t plist_id) HGOTO_ERROR(H5E_FILE, H5E_CANTSET, FAIL, "can't set collective metadata read info") /* Get the location object */ - if(H5G_loc(loc_id, &loc) < 0) + if(NULL == (loc_vol_obj = (H5VL_object_t *)H5I_object(loc_id))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "could not get location object") /* Get the child object */ - if(NULL == (child = (H5F_t *)H5I_object_verify(child_id, H5I_FILE))) + if(NULL == (child_vol_obj = (H5VL_object_t *)H5I_object(child_id))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "could not get child object") + /* Check if both objects are associated with the same VOL plugin */ + if(loc_vol_obj->driver->cls->value != child_vol_obj->driver->cls->value) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "Can't mount file onto object from different VOL driver") + /* Perform the mount operation */ - if(H5F__mount(&loc, name, child, plist_id) < 0) + if(H5VL_file_specific(loc_vol_obj->data, loc_vol_obj->driver->cls, H5VL_FILE_MOUNT, H5P_DATASET_XFER_DEFAULT, + H5_REQUEST_NULL, loc_type, name, child_vol_obj->data, plist_id) < 0) HGOTO_ERROR(H5E_FILE, H5E_MOUNT, FAIL, "unable to mount file") done: @@ -504,7 +510,7 @@ done: herr_t H5Funmount(hid_t loc_id, const char *name) { - H5G_loc_t loc; /* Parent location */ + H5VL_object_t *vol_obj = NULL; /* Parent object */ H5I_type_t loc_type; /* ID type of location */ herr_t ret_value = SUCCEED; /* Return value */ @@ -525,11 +531,12 @@ H5Funmount(hid_t loc_id, const char *name) HGOTO_ERROR(H5E_FILE, H5E_CANTSET, FAIL, "can't set collective metadata read info") /* Get the location object */ - if(H5G_loc(loc_id, &loc) < 0) + if(NULL == (vol_obj = (H5VL_object_t *)H5I_object(loc_id))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "could not get location object") /* Perform the unmount operation */ - if(H5F__unmount(&loc, name) < 0) + if(H5VL_file_specific(vol_obj->data, vol_obj->driver->cls, H5VL_FILE_UNMOUNT, + H5P_DATASET_XFER_DEFAULT, H5_REQUEST_NULL, loc_type, name) < 0) HGOTO_ERROR(H5E_FILE, H5E_MOUNT, FAIL, "unable to unmount file") done: @@ -563,7 +570,7 @@ H5F__mount_count_ids_recurse(H5F_t *f, unsigned *nopen_files, unsigned *nopen_ob HDassert(nopen_objs); /* If this file is still open, increment number of file IDs open */ - if(f->file_id > 0) + if(H5F_ID_EXISTS(f)) *nopen_files += 1; /* Increment number of open objects in file diff --git a/src/H5Fmpi.c b/src/H5Fmpi.c index 7620d95..6ddbfbb 100644 --- a/src/H5Fmpi.c +++ b/src/H5Fmpi.c @@ -231,7 +231,7 @@ H5Fset_mpi_atomicity(hid_t file_id, hbool_t flag) H5TRACE2("e", "ib", file_id, flag); /* Check args */ - if(NULL == (file = (H5F_t *)H5I_object_verify(file_id, H5I_FILE))) + if(NULL == (file = (H5F_t *)H5VL_object_verify(file_id, H5I_FILE))) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "not a file ID") /* Check VFD */ @@ -271,7 +271,7 @@ H5Fget_mpi_atomicity(hid_t file_id, hbool_t *flag) H5TRACE2("e", "i*b", file_id, flag); /* Check args */ - if(NULL == (file = (H5F_t *)H5I_object_verify(file_id, H5I_FILE))) + if(NULL == (file = (H5F_t *)H5VL_object_verify(file_id, H5I_FILE))) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "not a file ID") /* Check VFD */ diff --git a/src/H5Fpkg.h b/src/H5Fpkg.h index 44344f0..f8ab5a9 100644 --- a/src/H5Fpkg.h +++ b/src/H5Fpkg.h @@ -31,6 +31,7 @@ /* Other public headers needed by this file */ #include "H5Bpublic.h" /* B-tree header (for H5B_NUM_BTREE_ID) */ +#include "H5VLpublic.h" /* Virtual Object Layer */ /* Other private headers needed by this file */ #include "H5private.h" /* Generic Functions */ @@ -367,7 +368,7 @@ struct H5F_t { H5F_file_t *shared; /* The shared file info */ unsigned nopen_objs; /* Number of open object headers */ H5FO_t *obj_count; /* # of time each object is opened through top file structure */ - hid_t file_id; /* ID of this file */ + hbool_t id_exists; /* Whether an ID for this struct exists */ hbool_t closing; /* File is in the process of being closed */ struct H5F_t *parent; /* Parent file that this file is mounted to */ unsigned nmounts; /* Number of children mounted to this file */ @@ -377,6 +378,34 @@ struct H5F_t { #endif /* H5_HAVE_PARALLEL */ }; +/* types for file optional VOL operations */ +typedef enum H5VL_file_optional_t { + H5VL_FILE_CLEAR_ELINK_CACHE, /* Clear external link cache */ + H5VL_FILE_GET_FILE_IMAGE, /* file image */ + H5VL_FILE_GET_FREE_SECTIONS, /* file free selections */ + H5VL_FILE_GET_FREE_SPACE, /* file freespace */ + H5VL_FILE_GET_INFO, /* file info */ + H5VL_FILE_GET_MDC_CONF, /* file metadata cache configuration */ + H5VL_FILE_GET_MDC_HR, /* file metadata cache hit rate */ + H5VL_FILE_GET_MDC_SIZE, /* file metadata cache size */ + H5VL_FILE_GET_SIZE, /* file size */ + H5VL_FILE_GET_VFD_HANDLE, /* file VFD handle */ + H5VL_FILE_REOPEN, /* reopen the file */ + H5VL_FILE_RESET_MDC_HIT_RATE, /* get metadata cache hit rate */ + H5VL_FILE_SET_MDC_CONFIG, /* set metadata cache configuration */ + H5VL_FILE_GET_METADATA_READ_RETRY_INFO, + H5VL_FILE_START_SWMR_WRITE, + H5VL_FILE_START_MDC_LOGGING, + H5VL_FILE_STOP_MDC_LOGGING, + H5VL_FILE_GET_MDC_LOGGING_STATUS, + H5VL_FILE_SET_LATEST_FORMAT, + H5VL_FILE_FORMAT_CONVERT, + H5VL_FILE_RESET_PAGE_BUFFERING_STATS, + H5VL_FILE_GET_PAGE_BUFFERING_STATS, + H5VL_FILE_GET_MDC_IMAGE_INFO + +} H5VL_file_optional_t; + /* User data for traversal routine to get ID counts */ typedef struct { ssize_t *obj_count; /* number of objects counted so far */ @@ -384,6 +413,7 @@ typedef struct { } H5F_trav_obj_cnt_t; /* User data for traversal routine to get ID lists */ +/* XXX (VOL MERGE): Should the type of obj_count and max_objs be identical? */ typedef struct { size_t max_objs; hid_t *oid_list; @@ -411,12 +441,12 @@ H5_DLL H5F_t *H5F__reopen(H5F_t *f); H5_DLL H5F_t *H5F__new(H5F_file_t *shared, unsigned flags, hid_t fcpl_id, hid_t fapl_id, H5FD_t *lf); H5_DLL herr_t H5F__dest(H5F_t *f, hbool_t flush); H5_DLL herr_t H5F__flush(H5F_t *f); -H5_DLL htri_t H5F__is_hdf5(const char *name); +H5_DLL htri_t H5F__is_hdf5(const char *name, hid_t fapl_id); H5_DLL ssize_t H5F__get_file_image(H5F_t *f, void *buf_ptr, size_t buf_len); H5_DLL herr_t H5F__get_info(H5F_t *f, H5F_info2_t *finfo); H5_DLL herr_t H5F__format_convert(H5F_t *f); H5_DLL herr_t H5F__start_swmr_write(H5F_t *f); -H5_DLL herr_t H5F__close(hid_t file_id); +H5_DLL herr_t H5F__close(H5F_t *f); H5_DLL herr_t H5F__set_libver_bounds(H5F_t *f, H5F_libver_t low, H5F_libver_t high); /* File mount related routines */ diff --git a/src/H5Fprivate.h b/src/H5Fprivate.h index 1ce9374..6595677 100644 --- a/src/H5Fprivate.h +++ b/src/H5Fprivate.h @@ -286,7 +286,7 @@ typedef struct H5F_t H5F_t; #define H5F_NOPEN_OBJS(F) ((F)->nopen_objs) #define H5F_INCR_NOPEN_OBJS(F) ((F)->nopen_objs++) #define H5F_DECR_NOPEN_OBJS(F) ((F)->nopen_objs--) -#define H5F_FILE_ID(F) ((F)->file_id) +#define H5F_ID_EXISTS(F) ((F)->id_exists) #define H5F_PARENT(F) ((F)->parent) #define H5F_NMOUNTS(F) ((F)->nmounts) #define H5F_GET_READ_ATTEMPTS(F) ((F)->shared->read_attempts) @@ -343,7 +343,7 @@ typedef struct H5F_t H5F_t; #define H5F_NOPEN_OBJS(F) (H5F_get_nopen_objs(F)) #define H5F_INCR_NOPEN_OBJS(F) (H5F_incr_nopen_objs(F)) #define H5F_DECR_NOPEN_OBJS(F) (H5F_decr_nopen_objs(F)) -#define H5F_FILE_ID(F) (H5F_get_file_id(F)) +#define H5F_ID_EXISTS(F) (H5F_file_id_exists(F)) #define H5F_PARENT(F) (H5F_get_parent(F)) #define H5F_NMOUNTS(F) (H5F_get_nmounts(F)) #define H5F_GET_READ_ATTEMPTS(F) (H5F_get_read_attempts(F)) @@ -479,6 +479,7 @@ typedef struct H5F_t H5F_t; #define H5F_ACS_SDATA_BLOCK_SIZE_NAME "sdata_block_size" /* Minimum "small data" allocation block size (when aggregating "small" raw data allocations) */ #define H5F_ACS_GARBG_COLCT_REF_NAME "gc_ref" /* Garbage-collect references */ #define H5F_ACS_FILE_DRV_NAME "vfd_info" /* File driver ID & info */ +#define H5F_ACS_VOL_DRV_NAME "vol_driver_info" /* VOL driver ID & info */ #define H5F_ACS_CLOSE_DEGREE_NAME "close_degree" /* File close degree */ #define H5F_ACS_FAMILY_OFFSET_NAME "family_offset" /* Offset position in file for family file driver */ #define H5F_ACS_FAMILY_NEWSIZE_NAME "family_newsize" /* New member size of family driver. (private property only used by h5repart) */ @@ -728,7 +729,7 @@ H5_DLL hbool_t H5F_same_shared(const H5F_t *f1, const H5F_t *f2); H5_DLL unsigned H5F_get_nopen_objs(const H5F_t *f); H5_DLL unsigned H5F_incr_nopen_objs(H5F_t *f); H5_DLL unsigned H5F_decr_nopen_objs(H5F_t *f); -H5_DLL hid_t H5F_get_file_id(const H5F_t *f); +H5_DLL hbool_t H5F_file_id_exists(const H5F_t *f); H5_DLL H5F_t *H5F_get_parent(const H5F_t *f); H5_DLL unsigned H5F_get_nmounts(const H5F_t *f); H5_DLL unsigned H5F_get_read_attempts(const H5F_t *f); diff --git a/src/H5Fpublic.h b/src/H5Fpublic.h index 73c59f5..8e54e7f 100644 --- a/src/H5Fpublic.h +++ b/src/H5Fpublic.h @@ -223,7 +223,7 @@ extern "C" { #endif /* Functions in H5F.c */ -H5_DLL htri_t H5Fis_hdf5(const char *filename); +H5_DLL htri_t H5Fis_accessible(const char *container_name, hid_t fapl_id); H5_DLL hid_t H5Fcreate(const char *filename, unsigned flags, hid_t create_plist, hid_t access_plist); H5_DLL hid_t H5Fopen(const char *filename, unsigned flags, @@ -303,6 +303,7 @@ typedef struct H5F_info1_t { /* Function prototypes */ H5_DLL herr_t H5Fget_info1(hid_t obj_id, H5F_info1_t *finfo); H5_DLL herr_t H5Fset_latest_format(hid_t file_id, hbool_t latest_format); +H5_DLL htri_t H5Fis_hdf5(const char *filename); #endif /* H5_NO_DEPRECATED_SYMBOLS */ diff --git a/src/H5Fquery.c b/src/H5Fquery.c index 2500ea8..b036974 100644 --- a/src/H5Fquery.c +++ b/src/H5Fquery.c @@ -277,23 +277,23 @@ H5F_get_nopen_objs(const H5F_t *f) /*------------------------------------------------------------------------- - * Function: H5F_get_file_id + * Function: H5F_file_id_exists * - * Purpose: Retrieve the file's 'file_id' value + * Purpose: Determines if a file ID exists for this file struct * - * Return: 'file_id' on success/abort on failure (shouldn't fail) + * Return: TRUE/FALSE *------------------------------------------------------------------------- */ -hid_t -H5F_get_file_id(const H5F_t *f) +hbool_t +H5F_file_id_exists(const H5F_t *f) { /* Use FUNC_ENTER_NOAPI_NOINIT_NOERR here to avoid performance issues */ FUNC_ENTER_NOAPI_NOINIT_NOERR HDassert(f); - FUNC_LEAVE_NOAPI(f->file_id) -} /* end H5F_get_file_id() */ + FUNC_LEAVE_NOAPI(f->id_exists) +} /* end H5F_file_id_exists() */ /*------------------------------------------------------------------------- diff --git a/src/H5Ftest.c b/src/H5Ftest.c index df9c933..1183284 100644 --- a/src/H5Ftest.c +++ b/src/H5Ftest.c @@ -44,6 +44,7 @@ #include "H5Gpkg.h" /* Groups */ #include "H5Iprivate.h" /* IDs */ #include "H5SMpkg.h" /* Shared object header messages */ +#include "H5VLprivate.h" /* Virtual Object Layer */ /****************/ @@ -103,7 +104,7 @@ H5F__get_sohm_mesg_count_test(hid_t file_id, unsigned type_id, size_t *mesg_coun FUNC_ENTER_PACKAGE /* Check arguments */ - if(NULL == (file = (H5F_t *)H5I_object_verify(file_id, H5I_FILE))) + if(NULL == (file = (H5F_t *)H5VL_object_verify(file_id, H5I_FILE))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a file") /* Push API context */ @@ -148,7 +149,7 @@ H5F__check_cached_stab_test(hid_t file_id) FUNC_ENTER_PACKAGE /* Check arguments */ - if(NULL == (file = (H5F_t *)H5I_object_verify(file_id, H5I_FILE))) + if(NULL == (file = (H5F_t *)H5VL_object_verify(file_id, H5I_FILE))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a file") /* Push API context */ @@ -189,7 +190,7 @@ H5F__get_maxaddr_test(hid_t file_id, haddr_t *maxaddr) FUNC_ENTER_PACKAGE /* Check arguments */ - if(NULL == (file = (H5F_t *)H5I_object_verify(file_id, H5I_FILE))) + if(NULL == (file = (H5F_t *)H5VL_object_verify(file_id, H5I_FILE))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a file") /* Retrieve maxaddr for file */ @@ -222,7 +223,7 @@ H5F__get_sbe_addr_test(hid_t file_id, haddr_t *sbe_addr) FUNC_ENTER_PACKAGE /* Check arguments */ - if(NULL == (file = (H5F_t *)H5I_object_verify(file_id, H5I_FILE))) + if(NULL == (file = (H5F_t *)H5VL_object_verify(file_id, H5I_FILE))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a file") /* Retrieve maxaddr for file */ @@ -87,6 +87,7 @@ #include "H5Gpkg.h" /* Groups */ #include "H5Iprivate.h" /* IDs */ #include "H5Pprivate.h" /* Property lists */ +#include "H5VLprivate.h" /* Virtual Object Layer */ /****************/ @@ -108,6 +109,9 @@ /* Local Prototypes */ /********************/ +/* Group close callback */ +static herr_t H5G__close_cb(H5VL_object_t *grp_vol_obj); + /*********************/ /* Package Variables */ @@ -131,7 +135,7 @@ static const H5I_class_t H5I_GROUP_CLS[1] = {{ H5I_GROUP, /* ID class value */ 0, /* Class flags */ 0, /* # of reserved IDs for class */ - (H5I_free_t)H5G_close /* Callback routine for closing objects of this class */ + (H5I_free_t)H5G__close_cb /* Callback routine for closing objects of this class */ }}; /* Flag indicating "top" of interface has been initialized */ @@ -255,6 +259,38 @@ H5G_term_package(void) /*------------------------------------------------------------------------- + * Function: H5G__close_cb + * + * Purpose: Called when the ref count reaches zero on the group's ID + * + * Return: SUCCEED/FAIL + * + *------------------------------------------------------------------------- + */ +static herr_t +H5G__close_cb(H5VL_object_t *grp_vol_obj) +{ + herr_t ret_value = SUCCEED; /* Return value */ + + FUNC_ENTER_STATIC + + /* Sanity check */ + HDassert(grp_vol_obj); + + /* Close the group */ + if(H5VL_group_close(grp_vol_obj->data, grp_vol_obj->driver->cls, H5P_DATASET_XFER_DEFAULT, H5_REQUEST_NULL) < 0) + HGOTO_ERROR(H5E_SYM, H5E_CLOSEERROR, FAIL, "unable to close group") + + /* Free the VOL object */ + if(H5VL_free_object(grp_vol_obj) < 0) + HGOTO_ERROR(H5E_SYM, H5E_CANTDEC, FAIL, "unable to free VOL object") + +done: + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5G__close_cb() */ + + +/*------------------------------------------------------------------------- * Function: H5Gcreate2 * * Purpose: Creates a new group relative to LOC_ID, giving it the @@ -281,16 +317,16 @@ hid_t H5Gcreate2(hid_t loc_id, const char *name, hid_t lcpl_id, hid_t gcpl_id, hid_t gapl_id) { - H5G_t *grp = NULL; /* Structure for new group */ - H5G_loc_t loc; /* Location to create group */ + void *grp = NULL; /* Structure for new group */ + H5VL_object_t *vol_obj = NULL; /* object token of loc_id */ + H5VL_loc_params_t loc_params; + H5P_genplist_t *plist; /* Property list pointer */ hid_t ret_value = H5I_INVALID_HID; /* Return value */ FUNC_ENTER_API(H5I_INVALID_HID) H5TRACE5("i", "i*siii", loc_id, name, lcpl_id, gcpl_id, gapl_id); /* Check arguments */ - if(H5G_loc(loc_id, &loc) < 0) - HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, H5I_INVALID_HID, "not a location") if(!name) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, H5I_INVALID_HID, "name parameter cannot be NULL") if(!*name) @@ -314,17 +350,32 @@ H5Gcreate2(hid_t loc_id, const char *name, hid_t lcpl_id, hid_t gcpl_id, if(H5CX_set_apl(&gapl_id, H5P_CLS_GACC, loc_id, TRUE) < 0) HGOTO_ERROR(H5E_SYM, H5E_CANTSET, H5I_INVALID_HID, "can't set access property list info") + /* Get the gcpl structure and set the link properties on it */ + if (NULL == (plist = (H5P_genplist_t *)H5I_object(gcpl_id))) + HGOTO_ERROR(H5E_ATOM, H5E_BADATOM, H5I_INVALID_HID, "can't find object for ID") + if (H5P_set(plist, H5VL_PROP_GRP_LCPL_ID, &lcpl_id) < 0) + HGOTO_ERROR(H5E_PLIST, H5E_CANTSET, H5I_INVALID_HID, "can't set property value for lcpl id") + + /* get the location object */ + if (NULL == (vol_obj = (H5VL_object_t *)H5I_object(loc_id))) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, H5I_INVALID_HID, "invalid location identifier") + + /* Set the location parameters */ + loc_params.type = H5VL_OBJECT_BY_SELF; + loc_params.obj_type = H5I_get_type(loc_id); + /* Create the group */ - if(NULL == (grp = H5G__create_named(&loc, name, lcpl_id, gcpl_id))) + if(NULL == (grp = H5VL_group_create(vol_obj->data, loc_params, vol_obj->driver->cls, name, + gcpl_id, gapl_id, H5P_DATASET_XFER_DEFAULT, H5_REQUEST_NULL))) HGOTO_ERROR(H5E_SYM, H5E_CANTINIT, H5I_INVALID_HID, "unable to create group") /* Get an atom for the group */ - if((ret_value = H5I_register(H5I_GROUP, grp, TRUE)) < 0) + if((ret_value = H5VL_register_id(H5I_GROUP, grp, vol_obj->driver, TRUE)) < 0) HGOTO_ERROR(H5E_ATOM, H5E_CANTREGISTER, H5I_INVALID_HID, "unable to atomize group handle") done: if(H5I_INVALID_HID == ret_value) - if(grp && H5G_close(grp) < 0) + if(grp && H5VL_group_close(grp, vol_obj->driver->cls, H5P_DATASET_XFER_DEFAULT, H5_REQUEST_NULL) < 0) HDONE_ERROR(H5E_SYM, H5E_CLOSEERROR, H5I_INVALID_HID, "unable to release group") FUNC_LEAVE_API(ret_value) @@ -366,18 +417,14 @@ done: hid_t H5Gcreate_anon(hid_t loc_id, hid_t gcpl_id, hid_t gapl_id) { - H5G_t *grp = NULL; /* Structure for new group */ - H5G_loc_t loc; - H5G_obj_create_t gcrt_info; /* Information for group creation */ + void *grp = NULL; /* Structure for new group */ + H5VL_object_t *vol_obj = NULL; /* Object token for loc_id */ + H5VL_loc_params_t loc_params; hid_t ret_value = H5I_INVALID_HID; /* Return value */ FUNC_ENTER_API(H5I_INVALID_HID) H5TRACE3("i", "iii", loc_id, gcpl_id, gapl_id); - /* Check arguments */ - if(H5G_loc(loc_id, &loc) < 0) - HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, H5I_INVALID_HID, "not a location") - /* Check group creation property list */ if(H5P_DEFAULT == gcpl_id) gcpl_id = H5P_GROUP_CREATE_DEFAULT; @@ -389,36 +436,27 @@ H5Gcreate_anon(hid_t loc_id, hid_t gcpl_id, hid_t gapl_id) if(H5CX_set_apl(&gapl_id, H5P_CLS_GACC, loc_id, TRUE) < 0) HGOTO_ERROR(H5E_SYM, H5E_CANTSET, H5I_INVALID_HID, "can't set access property list info") - /* Set up group creation info */ - gcrt_info.gcpl_id = gcpl_id; - gcrt_info.cache_type = H5G_NOTHING_CACHED; - HDmemset(&gcrt_info.cache, 0, sizeof(gcrt_info.cache)); + /* Set location struct fields */ + loc_params.type = H5VL_OBJECT_BY_SELF; + loc_params.obj_type = H5I_get_type(loc_id); + + /* get the location object */ + if(NULL == (vol_obj = (H5VL_object_t *)H5I_object(loc_id))) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, H5I_INVALID_HID, "invalid location identifier") /* Create the group */ - if(NULL == (grp = H5G__create(loc.oloc->file, &gcrt_info))) - HGOTO_ERROR(H5E_SYM, H5E_CANTCREATE, H5I_INVALID_HID, "unable to create group") + if(NULL == (grp = H5VL_group_create(vol_obj->data, loc_params, vol_obj->driver->cls, NULL, + gcpl_id, gapl_id, H5P_DATASET_XFER_DEFAULT, H5_REQUEST_NULL))) + HGOTO_ERROR(H5E_SYM, H5E_CANTINIT, H5I_INVALID_HID, "unable to create group") /* Get an atom for the group */ - if((ret_value = H5I_register(H5I_GROUP, grp, TRUE)) < 0) - HGOTO_ERROR(H5E_ATOM, H5E_CANTREGISTER, H5I_INVALID_HID, "unable to register group") + if((ret_value = H5VL_register_id(H5I_GROUP, grp, vol_obj->driver, TRUE)) < 0) + HGOTO_ERROR(H5E_ATOM, H5E_CANTREGISTER, H5I_INVALID_HID, "unable to atomize group handle") done: - /* Release the group's object header, if it was created */ - if(grp) { - H5O_loc_t *oloc; /* Object location for group */ - - /* Get the new group's object location */ - if(NULL == (oloc = H5G_oloc(grp))) - HDONE_ERROR(H5E_SYM, H5E_CANTGET, H5I_INVALID_HID, "unable to get object location of group") - - /* Decrement refcount on group's object header in memory */ - if(H5O_dec_rc_by_loc(oloc) < 0) - HDONE_ERROR(H5E_SYM, H5E_CANTDEC, H5I_INVALID_HID, "unable to decrement refcount on newly created object") - } /* end if */ - /* Cleanup on failure */ if(H5I_INVALID_HID == ret_value) - if(grp && H5G_close(grp) < 0) + if(grp && H5VL_group_close(grp, vol_obj->driver->cls, H5P_DATASET_XFER_DEFAULT, H5_REQUEST_NULL) < 0) HDONE_ERROR(H5E_SYM, H5E_CLOSEERROR, H5I_INVALID_HID, "unable to release group") FUNC_LEAVE_API(ret_value) @@ -443,16 +481,15 @@ done: hid_t H5Gopen2(hid_t loc_id, const char *name, hid_t gapl_id) { - H5G_t *grp = NULL; /* Group opened */ - H5G_loc_t loc; /* Location of parent for group */ + void *grp = NULL; /* Group opened */ + H5VL_object_t *vol_obj = NULL; /* object token of loc_id */ + H5VL_loc_params_t loc_params; hid_t ret_value = H5I_INVALID_HID; /* Return value */ FUNC_ENTER_API(H5I_INVALID_HID) H5TRACE3("i", "i*si", loc_id, name, gapl_id); /* Check args */ - if(H5G_loc(loc_id, &loc) < 0) - HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, H5I_INVALID_HID, "not a location") if(!name) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, H5I_INVALID_HID, "name parameter cannot be NULL") if(!*name) @@ -462,17 +499,24 @@ H5Gopen2(hid_t loc_id, const char *name, hid_t gapl_id) if(H5CX_set_apl(&gapl_id, H5P_CLS_GACC, loc_id, FALSE) < 0) HGOTO_ERROR(H5E_SYM, H5E_CANTSET, H5I_INVALID_HID, "can't set access property list info") + /* Get the location object */ + if(NULL == (vol_obj = (H5VL_object_t *)H5I_object(loc_id))) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, H5I_INVALID_HID, "invalid location identifier") + /* Open the group */ - if(NULL == (grp = H5G__open_name(&loc, name))) + loc_params.type = H5VL_OBJECT_BY_SELF; + loc_params.obj_type = H5I_get_type(loc_id); + if(NULL == (grp = H5VL_group_open(vol_obj->data, loc_params, vol_obj->driver->cls, + name, gapl_id, H5P_DATASET_XFER_DEFAULT, H5_REQUEST_NULL))) HGOTO_ERROR(H5E_SYM, H5E_CANTOPENOBJ, H5I_INVALID_HID, "unable to open group") /* Register an ID for the group */ - if((ret_value = H5I_register(H5I_GROUP, grp, TRUE)) < 0) + if((ret_value = H5VL_register_id(H5I_GROUP, grp, vol_obj->driver, TRUE)) < 0) HGOTO_ERROR(H5E_ATOM, H5E_CANTREGISTER, H5I_INVALID_HID, "unable to register group") done: if(H5I_INVALID_HID == ret_value) - if(grp && H5G_close(grp) < 0) + if(grp && H5VL_group_close(grp, vol_obj->driver->cls, H5P_DATASET_XFER_DEFAULT, H5_REQUEST_NULL) < 0) HDONE_ERROR(H5E_SYM, H5E_CLOSEERROR, H5I_INVALID_HID, "unable to release group") FUNC_LEAVE_API(ret_value) @@ -495,18 +539,19 @@ done: hid_t H5Gget_create_plist(hid_t group_id) { - H5G_t *group = NULL; - hid_t ret_value = H5I_INVALID_HID; /* Return value */ + H5VL_object_t *vol_obj = NULL; + hid_t ret_value = H5I_INVALID_HID; FUNC_ENTER_API(H5I_INVALID_HID) H5TRACE1("i", "i", group_id); /* Check args */ - if(NULL == (group = (H5G_t *)H5I_object_verify(group_id, H5I_GROUP))) + if(NULL == (vol_obj = (H5VL_object_t *)H5I_object_verify(group_id, H5I_GROUP))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, H5I_INVALID_HID, "not a group ID") /* Get the group creation property list for the group */ - if((ret_value = H5G_get_create_plist(group)) < 0) + if(H5VL_group_get(vol_obj->data, vol_obj->driver->cls, H5VL_GROUP_GET_GCPL, + H5P_DATASET_XFER_DEFAULT, H5_REQUEST_NULL, &ret_value) < 0) HGOTO_ERROR(H5E_SYM, H5E_CANTGET, H5I_INVALID_HID, "can't get group's creation property list") done: @@ -526,8 +571,9 @@ done: herr_t H5Gget_info(hid_t loc_id, H5G_info_t *group_info) { - H5I_type_t id_type; /* Type of ID */ - H5G_loc_t loc; /* Location of group */ + H5VL_object_t *vol_obj; + H5I_type_t id_type; /* Type of ID */ + H5VL_loc_params_t loc_params; herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_API(FAIL) @@ -541,11 +587,14 @@ H5Gget_info(hid_t loc_id, H5G_info_t *group_info) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "group_info parameter cannot be NULL") /* Get group location */ - if(H5G_loc(loc_id, &loc) < 0) + if(NULL == (vol_obj = (H5VL_object_t *)H5I_object(loc_id))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "invalid location identifier") /* Retrieve the group's information */ - if(H5G__obj_info(loc.oloc, group_info) < 0) + loc_params.type = H5VL_OBJECT_BY_SELF; + loc_params.obj_type = id_type; + if((ret_value = H5VL_group_get(vol_obj->data, vol_obj->driver->cls, H5VL_GROUP_GET_INFO, + H5P_DATASET_XFER_DEFAULT, H5_REQUEST_NULL, loc_params, group_info)) < 0) HGOTO_ERROR(H5E_SYM, H5E_CANTGET, FAIL, "unable to get group info") done: @@ -567,15 +616,14 @@ herr_t H5Gget_info_by_name(hid_t loc_id, const char *name, H5G_info_t *group_info, hid_t lapl_id) { - H5G_loc_t loc; /* Location of group */ - herr_t ret_value = SUCCEED; /* Return value */ + H5VL_object_t *vol_obj; + H5VL_loc_params_t loc_params; + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_API(FAIL) H5TRACE4("e", "i*s*xi", loc_id, name, group_info, lapl_id); /* Check args */ - if(H5G_loc(loc_id, &loc) < 0) - HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a location") if(!name) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "name parameter cannot be NULL") if(!*name) @@ -587,8 +635,19 @@ H5Gget_info_by_name(hid_t loc_id, const char *name, H5G_info_t *group_info, if(H5CX_set_apl(&lapl_id, H5P_CLS_LACC, loc_id, FALSE) < 0) HGOTO_ERROR(H5E_SYM, H5E_CANTSET, FAIL, "can't set access property list info") + /* Get the location object */ + if (NULL == (vol_obj = (H5VL_object_t *)H5I_object(loc_id))) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "invalid location identifier") + + /* Set up location parameters */ + loc_params.type = H5VL_OBJECT_BY_NAME; + loc_params.loc_data.loc_by_name.name = name; + loc_params.loc_data.loc_by_name.lapl_id = lapl_id; + loc_params.obj_type = H5I_get_type(loc_id); + /* Retrieve the group's information */ - if(H5G__get_info_by_name(&loc, name, group_info/*out*/) < 0) + if((ret_value = H5VL_group_get(vol_obj->data, vol_obj->driver->cls, H5VL_GROUP_GET_INFO, + H5P_DATASET_XFER_DEFAULT, H5_REQUEST_NULL, loc_params, group_info)) < 0) HGOTO_ERROR(H5E_SYM, H5E_CANTGET, FAIL, "can't retrieve group info") done: @@ -610,7 +669,8 @@ herr_t H5Gget_info_by_idx(hid_t loc_id, const char *group_name, H5_index_t idx_type, H5_iter_order_t order, hsize_t n, H5G_info_t *group_info, hid_t lapl_id) { - H5G_loc_t loc; /* Location of group */ + H5VL_object_t *vol_obj; + H5VL_loc_params_t loc_params; herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_API(FAIL) @@ -618,8 +678,6 @@ H5Gget_info_by_idx(hid_t loc_id, const char *group_name, H5_index_t idx_type, lapl_id); /* Check args */ - if(H5G_loc(loc_id, &loc) < 0) - HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a location") if(!group_name) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "group_name parameter cannot be NULL") if(!*group_name) @@ -635,8 +693,22 @@ H5Gget_info_by_idx(hid_t loc_id, const char *group_name, H5_index_t idx_type, if(H5CX_set_apl(&lapl_id, H5P_CLS_LACC, loc_id, FALSE) < 0) HGOTO_ERROR(H5E_SYM, H5E_CANTSET, FAIL, "can't set access property list info") + /* get the location object */ + if(NULL == (vol_obj = (H5VL_object_t *)H5I_object(loc_id))) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "invalid location identifier") + + /* Set location parameters */ + loc_params.type = H5VL_OBJECT_BY_IDX; + loc_params.loc_data.loc_by_idx.name = group_name; + loc_params.loc_data.loc_by_idx.idx_type = idx_type; + loc_params.loc_data.loc_by_idx.order = order; + loc_params.loc_data.loc_by_idx.n = n; + loc_params.loc_data.loc_by_idx.lapl_id = lapl_id; + loc_params.obj_type = H5I_get_type(loc_id); + /* Retrieve the group's information */ - if(H5G__get_info_by_idx(&loc, group_name, idx_type, order, n, group_info/*out*/) < 0) + if((ret_value = H5VL_group_get(vol_obj->data, vol_obj->driver->cls, H5VL_GROUP_GET_INFO, + H5P_DATASET_XFER_DEFAULT, H5_REQUEST_NULL, loc_params, group_info)) < 0) HGOTO_ERROR(H5E_SYM, H5E_CANTGET, FAIL, "can't retrieve group info") done: @@ -663,7 +735,7 @@ H5Gclose(hid_t group_id) H5TRACE1("e", "i", group_id); /* Check args */ - if(NULL == H5I_object_verify(group_id,H5I_GROUP)) + if(NULL == H5I_object_verify(group_id, H5I_GROUP)) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a group") /* Decrement the counter on the group atom. It will be freed if the count @@ -692,22 +764,23 @@ done: herr_t H5Gflush(hid_t group_id) { - H5G_t *grp; /* Group for this operation */ - herr_t ret_value = SUCCEED; /* Return value */ + H5VL_object_t *vol_obj; /* Group for this operation */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_API(FAIL) H5TRACE1("e", "i", group_id); /* Check args */ - if(NULL == (grp = (H5G_t *)H5I_object_verify(group_id, H5I_GROUP))) + if(NULL == (vol_obj = (H5VL_object_t *)H5I_object_verify(group_id, H5I_GROUP))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a group ID") /* Set up collective metadata if appropriate */ if(H5CX_set_loc(group_id) < 0) HGOTO_ERROR(H5E_SYM, H5E_CANTSET, FAIL, "can't set collective metadata read info") - /* Flush metadata to file */ - if(H5O_flush_common(&grp->oloc, group_id) < 0) + /* Flush group's metadata to file */ + if((ret_value = H5VL_group_specific(vol_obj->data, vol_obj->driver->cls, H5VL_GROUP_FLUSH, + H5P_DATASET_XFER_DEFAULT, H5_REQUEST_NULL, group_id)) < 0) HGOTO_ERROR(H5E_SYM, H5E_CANTFLUSH, FAIL, "unable to flush group") done: @@ -730,14 +803,14 @@ done: herr_t H5Grefresh(hid_t group_id) { - H5G_t *grp; /* Group for this operation */ - herr_t ret_value = SUCCEED; /* Return value */ - + H5VL_object_t *vol_obj; /* Group for this operation */ + herr_t ret_value = SUCCEED; /* Return value */ + FUNC_ENTER_API(FAIL) H5TRACE1("e", "i", group_id); /* Check args */ - if(NULL == (grp = (H5G_t *)H5I_object_verify(group_id, H5I_GROUP))) + if(NULL == (vol_obj = (H5VL_object_t *)H5I_object_verify(group_id, H5I_GROUP))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a group ID") /* Set up collective metadata if appropriate */ @@ -745,7 +818,8 @@ H5Grefresh(hid_t group_id) HGOTO_ERROR(H5E_SYM, H5E_CANTSET, FAIL, "can't set collective metadata read info") /* Refresh group's metadata */ - if((H5O_refresh_metadata(group_id, grp->oloc)) < 0) + if((ret_value = H5VL_group_specific(vol_obj->data, vol_obj->driver->cls, H5VL_GROUP_REFRESH, + H5P_DATASET_XFER_DEFAULT, H5_REQUEST_NULL, group_id)) < 0) HGOTO_ERROR(H5E_SYM, H5E_CANTLOAD, FAIL, "unable to refresh group") done: diff --git a/src/H5Gdeprec.c b/src/H5Gdeprec.c index f8f668c..ab73e7e 100644 --- a/src/H5Gdeprec.c +++ b/src/H5Gdeprec.c @@ -43,6 +43,7 @@ #include "H5Iprivate.h" /* IDs */ #include "H5Lprivate.h" /* Links */ #include "H5Pprivate.h" /* Property lists */ +#include "H5VLprivate.h" /* VOL plugins */ /****************/ @@ -72,10 +73,6 @@ typedef struct { /* Local Prototypes */ /********************/ -static herr_t H5G__link(hid_t cur_loc_id, const char *cur_name, H5G_link_t type, - hid_t new_loc_id, const char *new_name, hid_t lcpl_id); -static herr_t H5G__move(hid_t src_loc_id, const char *src_name, - hid_t dst_loc_id, const char *dst_name, hid_t lcpl_id); static herr_t H5G__get_objinfo_cb(H5G_loc_t *grp_loc/*in*/, const char *name, const H5O_link_t *lnk, H5G_loc_t *obj_loc, void *_udata/*in,out*/, H5G_own_loc_t *own_loc/*out*/); @@ -174,17 +171,18 @@ H5G_map_obj_type(H5O_type_t obj_type) hid_t H5Gcreate1(hid_t loc_id, const char *name, size_t size_hint) { - H5G_loc_t loc; /* Location to create group */ - H5G_t *grp = NULL; /* New group created */ + void *grp = NULL; /* New group created */ + H5VL_object_t *vol_obj = NULL; /* object token of loc_id */ + H5VL_loc_params_t loc_params; + H5P_genplist_t *plist; /* Property list pointer */ hid_t tmp_gcpl = H5I_INVALID_HID; /* Temporary group creation property list */ + hid_t lcpl_id = H5P_LINK_CREATE_DEFAULT; hid_t ret_value = H5I_INVALID_HID; /* Return value */ FUNC_ENTER_API(H5I_INVALID_HID) H5TRACE3("i", "i*sz", loc_id, name, size_hint); /* Check arguments */ - if(H5G_loc(loc_id, &loc) < 0) - HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, H5I_INVALID_HID, "not a location") if(!name || !*name) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, H5I_INVALID_HID, "no name given") @@ -221,12 +219,28 @@ H5Gcreate1(hid_t loc_id, const char *name, size_t size_hint) if(H5CX_set_loc(loc_id) < 0) HGOTO_ERROR(H5E_SYM, H5E_CANTSET, H5I_INVALID_HID, "can't set collective metadata read info") + /* Get the plist structure */ + if(NULL == (plist = (H5P_genplist_t *)H5I_object(tmp_gcpl))) + HGOTO_ERROR(H5E_ATOM, H5E_BADATOM, H5I_INVALID_HID, "can't find object for ID") + + /* get creation properties */ + if(H5P_set(plist, H5VL_PROP_GRP_LCPL_ID, &lcpl_id) < 0) + HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, H5I_INVALID_HID, "can't get property value for lcpl id") + + loc_params.type = H5VL_OBJECT_BY_SELF; + loc_params.obj_type = H5I_get_type(loc_id); + + /* get the location object */ + if(NULL == (vol_obj = (H5VL_object_t *)H5I_object(loc_id))) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, H5I_INVALID_HID, "invalid location identifier") + /* Create the group */ - if(NULL == (grp = H5G__create_named(&loc, name, H5P_LINK_CREATE_DEFAULT, tmp_gcpl))) + if(NULL == (grp = H5VL_group_create(vol_obj->data, loc_params, vol_obj->driver->cls, name, tmp_gcpl, + H5P_GROUP_ACCESS_DEFAULT, H5P_DATASET_XFER_DEFAULT, H5_REQUEST_NULL))) HGOTO_ERROR(H5E_SYM, H5E_CANTINIT, H5I_INVALID_HID, "unable to create group") /* Get an atom for the group */ - if((ret_value = H5I_register(H5I_GROUP, grp, TRUE)) < 0) + if((ret_value = H5VL_register_id(H5I_GROUP, grp, vol_obj->driver, TRUE)) < 0) HGOTO_ERROR(H5E_ATOM, H5E_CANTREGISTER, H5I_INVALID_HID, "unable to register group") done: @@ -235,7 +249,7 @@ done: HDONE_ERROR(H5E_SYM, H5E_CLOSEERROR, H5I_INVALID_HID, "unable to release property list") if(H5I_INVALID_HID == ret_value) - if(grp && H5G_close(grp) < 0) + if(grp && H5VL_group_close(grp, vol_obj->driver->cls, H5P_DATASET_XFER_DEFAULT, H5_REQUEST_NULL) < 0) HDONE_ERROR(H5E_SYM, H5E_CLOSEERROR, H5I_INVALID_HID, "unable to release group") FUNC_LEAVE_API(ret_value) @@ -262,30 +276,38 @@ done: hid_t H5Gopen1(hid_t loc_id, const char *name) { - H5G_t *grp = NULL; /* Group opened */ - H5G_loc_t loc; /* Location of parent for group */ + void *grp = NULL; /* Group opened */ + H5VL_object_t *vol_obj = NULL; /* object token of loc_id */ + H5VL_loc_params_t loc_params; hid_t ret_value = H5I_INVALID_HID; /* Return value */ FUNC_ENTER_API(H5I_INVALID_HID) H5TRACE2("i", "i*s", loc_id, name); /* Check args */ - if(H5G_loc(loc_id, &loc) < 0) - HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, H5I_INVALID_HID, "not a location") if(!name || !*name) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, H5I_INVALID_HID, "no name") + /* Set location parameters */ + loc_params.type = H5VL_OBJECT_BY_SELF; + loc_params.obj_type = H5I_get_type(loc_id); + + /* get the location object */ + if (NULL == (vol_obj = (H5VL_object_t *)H5I_object(loc_id))) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, H5I_INVALID_HID, "invalid location identifier") + /* Open the group */ - if(NULL == (grp = H5G__open_name(&loc, name))) + if(NULL == (grp = H5VL_group_open(vol_obj->data, loc_params, vol_obj->driver->cls, name, H5P_DEFAULT, + H5P_DATASET_XFER_DEFAULT, H5_REQUEST_NULL))) HGOTO_ERROR(H5E_SYM, H5E_CANTOPENOBJ, H5I_INVALID_HID, "unable to open group") /* Get an atom for the group */ - if((ret_value = H5I_register(H5I_GROUP, grp, TRUE)) < 0) + if((ret_value = H5VL_register_id(H5I_GROUP, grp, vol_obj->driver, TRUE)) < 0) HGOTO_ERROR(H5E_ATOM, H5E_CANTREGISTER, H5I_INVALID_HID, "unable to register group") done: if(H5I_INVALID_HID == ret_value) - if(grp && H5G_close(grp) < 0) + if(grp && H5VL_group_close(grp, vol_obj->driver->cls, H5P_DATASET_XFER_DEFAULT, H5_REQUEST_NULL) < 0) HDONE_ERROR(H5E_SYM, H5E_CLOSEERROR, H5I_INVALID_HID, "unable to release group") FUNC_LEAVE_API(ret_value) @@ -303,6 +325,8 @@ done: herr_t H5Glink(hid_t cur_loc_id, H5G_link_t type, const char *cur_name, const char *new_name) { + hid_t lcpl_id = H5P_LINK_CREATE_DEFAULT; + H5P_genplist_t *plist; /* Property list pointer */ herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_API(FAIL) @@ -318,9 +342,64 @@ H5Glink(hid_t cur_loc_id, H5G_link_t type, const char *cur_name, const char *new if(H5CX_set_loc(cur_loc_id) < 0) HGOTO_ERROR(H5E_SYM, H5E_CANTSET, FAIL, "can't set collective metadata read info") + /* 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") + /* Create link */ - if(H5G__link(cur_loc_id, cur_name, type, H5L_SAME_LOC, new_name, H5P_LINK_CREATE_DEFAULT) < 0) - HGOTO_ERROR(H5E_SYM, H5E_CANTINIT, FAIL, "couldn't create link") + if(type == H5L_TYPE_HARD) { + H5VL_object_t *vol_obj = NULL; /* object token of loc_id */ + H5VL_loc_params_t loc_params1; + H5VL_loc_params_t loc_params2; + + loc_params1.type = H5VL_OBJECT_BY_NAME; + loc_params1.obj_type = H5I_get_type(cur_loc_id); + loc_params1.loc_data.loc_by_name.name = cur_name; + loc_params1.loc_data.loc_by_name.lapl_id = H5P_DEFAULT; + + loc_params2.type = H5VL_OBJECT_BY_NAME; + loc_params2.loc_data.loc_by_name.name = new_name; + loc_params2.loc_data.loc_by_name.lapl_id = H5P_DEFAULT; + + /* get the location object */ + if(NULL == (vol_obj = (H5VL_object_t *)H5I_object(cur_loc_id))) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "invalid location identifier") + + /* set creation properties */ + if(H5P_set(plist, H5VL_PROP_LINK_TARGET, &vol_obj->data) < 0) + HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, FAIL, "can't set property value for target") + if(H5P_set(plist, H5VL_PROP_LINK_TARGET_LOC_PARAMS, &loc_params1) < 0) + HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, FAIL, "can't set property value for target loc params") + + /* Create the link through the VOL */ + if((ret_value = H5VL_link_create(H5VL_LINK_CREATE_HARD, NULL, loc_params2, vol_obj->driver->cls, + lcpl_id, H5P_DEFAULT, H5P_DATASET_XFER_DEFAULT, H5_REQUEST_NULL)) < 0) + HGOTO_ERROR(H5E_SYM, H5E_CANTINIT, FAIL, "unable to create link") + } + else if(type == H5L_TYPE_SOFT) { + H5VL_object_t *vol_obj = NULL; /* object token of loc_id */ + H5VL_loc_params_t loc_params; + + loc_params.type = H5VL_OBJECT_BY_NAME; + loc_params.loc_data.loc_by_name.name = new_name; + loc_params.loc_data.loc_by_name.lapl_id = H5P_DEFAULT; + loc_params.obj_type = H5I_get_type(cur_loc_id); + + /* get the location object */ + if(NULL == (vol_obj = (H5VL_object_t *)H5I_object(cur_loc_id))) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "invalid location identifier") + + /* set creation properties */ + if(H5P_set(plist, H5VL_PROP_LINK_TARGET_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_LINK_CREATE_SOFT, vol_obj->data, loc_params, vol_obj->driver->cls, + lcpl_id, H5P_DEFAULT, H5P_DATASET_XFER_DEFAULT, H5_REQUEST_NULL)) < 0) + HGOTO_ERROR(H5E_SYM, H5E_CANTINIT, FAIL, "unable to create link") + } + else + HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "Not a valid link type") done: FUNC_LEAVE_API(ret_value) @@ -339,6 +418,8 @@ herr_t H5Glink2(hid_t cur_loc_id, const char *cur_name, H5G_link_t type, hid_t new_loc_id, const char *new_name) { + hid_t lcpl_id = H5P_LINK_CREATE_DEFAULT; + H5P_genplist_t *plist; /* Property list pointer */ herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_API(FAIL) @@ -354,84 +435,77 @@ H5Glink2(hid_t cur_loc_id, const char *cur_name, H5G_link_t type, if(H5CX_set_loc(cur_loc_id) < 0) HGOTO_ERROR(H5E_SYM, H5E_CANTSET, FAIL, "can't set collective metadata read info") - /* Create link */ - if(H5G__link(cur_loc_id, cur_name, type, new_loc_id, new_name, H5P_LINK_CREATE_DEFAULT) < 0) - HGOTO_ERROR(H5E_SYM, H5E_CANTINIT, FAIL, "couldn't create link") - -done: - FUNC_LEAVE_API(ret_value) -} /* end H5Glink2() */ - - -/*------------------------------------------------------------------------- - * Function: H5G__link - * - * Purpose: Internal routine to create a new link. - * - * Return: Non-negative on success/Negative on failure - * - * Programmer: Quincey Koziol - * Monday, December 18, 2017 - * - *------------------------------------------------------------------------- - */ -static herr_t -H5G__link(hid_t cur_loc_id, const char *cur_name, H5G_link_t type, - hid_t new_loc_id, const char *new_name, hid_t lcpl_id) -{ - H5G_loc_t new_loc; /* Information about new link's group */ - herr_t ret_value = SUCCEED; /* Return value */ - - FUNC_ENTER_STATIC + /* Get the plist structure */ + if(NULL == (plist = (H5P_genplist_t *)H5I_object(lcpl_id))) + HGOTO_ERROR(H5E_ATOM, H5E_BADATOM, FAIL, "can't find object for ID") /* Create the appropriate kind of link */ if(type == H5L_TYPE_HARD) { - H5G_loc_t cur_loc, *cur_loc_p; /* Information about current link's group */ - H5G_loc_t *new_loc_p; /* Information about new link's group */ - - /* Finish checking arguments */ - if(cur_loc_id == H5L_SAME_LOC && new_loc_id == H5L_SAME_LOC) - HGOTO_ERROR(H5E_SYM, 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_SYM, H5E_BADTYPE, FAIL, "not a location") - if(new_loc_id != H5L_SAME_LOC && H5G_loc(new_loc_id, &new_loc) < 0) - HGOTO_ERROR(H5E_SYM, 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(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_SYM, H5E_BADVALUE, FAIL, "source and destination should be in the same file.") - - /* Create the link */ - if(H5L_create_hard(cur_loc_p, cur_name, new_loc_p, new_name, lcpl_id) < 0) + H5VL_object_t *vol_obj1 = NULL; /* object token of loc_id */ + H5VL_object_t *vol_obj2 = NULL; /* object token of loc_id */ + H5VL_loc_params_t loc_params1; + H5VL_loc_params_t loc_params2; + + loc_params1.type = H5VL_OBJECT_BY_NAME; + loc_params1.obj_type = H5I_get_type(cur_loc_id); + loc_params1.loc_data.loc_by_name.name = cur_name; + loc_params1.loc_data.loc_by_name.lapl_id = H5P_DEFAULT; + + loc_params2.type = H5VL_OBJECT_BY_NAME; + loc_params2.obj_type = H5I_get_type(new_loc_id); + loc_params2.loc_data.loc_by_name.name = new_name; + loc_params2.loc_data.loc_by_name.lapl_id = H5P_DEFAULT; + + /* get the location object */ + if(NULL == (vol_obj1 = (H5VL_object_t *)H5I_object(cur_loc_id))) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "invalid location identifier") + if(NULL == (vol_obj2 = (H5VL_object_t *)H5I_object(new_loc_id))) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "invalid location identifier") + + /* set creation properties */ + if(H5P_set(plist, H5VL_PROP_LINK_TARGET, &vol_obj1->data) < 0) + HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, FAIL, "can't set property value for target id") + if(H5P_set(plist, H5VL_PROP_LINK_TARGET_LOC_PARAMS, &loc_params1) < 0) + HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, FAIL, "can't set property value for target name") + + /* Create the link through the VOL */ + if((ret_value = H5VL_link_create(H5VL_LINK_CREATE_HARD, vol_obj2->data, loc_params2, vol_obj2->driver->cls, + lcpl_id, H5P_DEFAULT, H5P_DATASET_XFER_DEFAULT, H5_REQUEST_NULL)) < 0) HGOTO_ERROR(H5E_SYM, H5E_CANTINIT, FAIL, "unable to create link") } else if(type == H5L_TYPE_SOFT) { - /* Soft links only need one location, the new_loc_id, but it's possible - * that new_loc_id is H5L_SAME_LOC - */ + H5VL_object_t *vol_obj = NULL; /* object token of loc_id */ + H5VL_loc_params_t loc_params; + + /* Soft links only need one location, the new_loc_id, but it's possible that + * new_loc_id is H5L_SAME_LOC */ if(new_loc_id == H5L_SAME_LOC) new_loc_id = cur_loc_id; - /* Finish checking arguments */ - if(H5G_loc(new_loc_id, &new_loc) < 0) - HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a location") + loc_params.type = H5VL_OBJECT_BY_NAME; + loc_params.loc_data.loc_by_name.name = new_name; + loc_params.loc_data.loc_by_name.lapl_id = H5P_DEFAULT; + loc_params.obj_type = H5I_get_type(new_loc_id); + + /* get the location object */ + if(NULL == (vol_obj = (H5VL_object_t *)H5I_object(new_loc_id))) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "invalid location identifier") - /* Create the link */ - if(H5L_create_soft(cur_name, &new_loc, new_name, lcpl_id) < 0) + /* set creation properties */ + if(H5P_set(plist, H5VL_PROP_LINK_TARGET_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_LINK_CREATE_SOFT, vol_obj->data, loc_params, vol_obj->driver->cls, + lcpl_id, H5P_DEFAULT, H5P_DATASET_XFER_DEFAULT, H5_REQUEST_NULL)) < 0) HGOTO_ERROR(H5E_SYM, H5E_CANTINIT, FAIL, "unable to create link") } else HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "not a valid link type") done: - FUNC_LEAVE_NOAPI(ret_value) -} /* end H5G__link() */ + FUNC_LEAVE_API(ret_value) +} /* end H5Glink2() */ /*------------------------------------------------------------------------- @@ -444,7 +518,10 @@ done: herr_t H5Gmove(hid_t src_loc_id, const char *src_name, const char *dst_name) { - herr_t ret_value = SUCCEED; /* Return value */ + H5VL_object_t *vol_obj = NULL; /* object token of loc_id */ + H5VL_loc_params_t loc_params1; + H5VL_loc_params_t loc_params2; + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_API(FAIL) H5TRACE3("e", "i*s*s", src_loc_id, src_name, dst_name); @@ -453,8 +530,22 @@ H5Gmove(hid_t src_loc_id, const char *src_name, const char *dst_name) if(H5CX_set_loc(src_loc_id) < 0) HGOTO_ERROR(H5E_SYM, H5E_CANTSET, FAIL, "can't set collective metadata read info") + loc_params1.type = H5VL_OBJECT_BY_NAME; + loc_params1.obj_type = H5I_get_type(src_loc_id); + loc_params1.loc_data.loc_by_name.name = src_name; + loc_params1.loc_data.loc_by_name.lapl_id = H5P_DEFAULT; + + loc_params2.type = H5VL_OBJECT_BY_NAME; + loc_params2.loc_data.loc_by_name.name = dst_name; + loc_params2.loc_data.loc_by_name.lapl_id = H5P_DEFAULT; + + /* get the location object */ + if(NULL == (vol_obj = (H5VL_object_t *)H5I_object(src_loc_id))) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "invalid location identifier") + /* Move the link */ - if(H5G__move(src_loc_id, src_name, H5L_SAME_LOC, dst_name, H5P_LINK_CREATE_DEFAULT) < 0) + if((ret_value = H5VL_link_move(vol_obj->data, loc_params1, NULL, loc_params2, vol_obj->driver->cls, + H5P_DEFAULT, H5P_DEFAULT, H5P_DATASET_XFER_DEFAULT, H5_REQUEST_NULL)) < 0) HGOTO_ERROR(H5E_SYM, H5E_CANTMOVE, FAIL, "couldn't move link") done: @@ -473,21 +564,45 @@ herr_t H5Gmove2(hid_t src_loc_id, const char *src_name, hid_t dst_loc_id, const char *dst_name) { + H5VL_object_t *vol_obj1 = NULL; /* object token of src_id */ + H5VL_loc_params_t loc_params1; + H5VL_object_t *vol_obj2 = NULL; /* object token of dst_id */ + H5VL_loc_params_t loc_params2; herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_API(FAIL) H5TRACE4("e", "i*si*s", src_loc_id, src_name, dst_loc_id, dst_name); - /* Check arguments */ - if(src_loc_id == H5L_SAME_LOC && dst_loc_id == H5L_SAME_LOC) - HGOTO_ERROR(H5E_SYM, H5E_BADVALUE, FAIL, "source and destination should not both be H5L_SAME_LOC") - /* Set up collective metadata if appropriate */ if(H5CX_set_loc(dst_loc_id) < 0) HGOTO_ERROR(H5E_SYM, H5E_CANTSET, FAIL, "can't set collective metadata read info") + /* Set location parameter for source object */ + loc_params1.type = H5VL_OBJECT_BY_NAME; + loc_params1.loc_data.loc_by_name.name = src_name; + loc_params1.loc_data.loc_by_name.lapl_id = H5P_DEFAULT; + loc_params1.obj_type = H5I_get_type(src_loc_id); + /* Set location parameter for destination object */ + loc_params2.type = H5VL_OBJECT_BY_NAME; + loc_params2.loc_data.loc_by_name.name = dst_name; + loc_params2.loc_data.loc_by_name.lapl_id = H5P_DEFAULT; + loc_params2.obj_type = H5I_get_type(dst_loc_id); + + if(H5L_SAME_LOC != src_loc_id) { + /* get the location object */ + if(NULL == (vol_obj1 = (H5VL_object_t *)H5I_object(src_loc_id))) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "invalid location identifier") + } + if(H5L_SAME_LOC != dst_loc_id) { + /* get the location object */ + if(NULL == (vol_obj2 = (H5VL_object_t *)H5I_object(dst_loc_id))) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "invalid location identifier") + } + /* Move the link */ - if(H5G__move(src_loc_id, src_name, dst_loc_id, dst_name, H5P_LINK_CREATE_DEFAULT) < 0) + if((ret_value = H5VL_link_move(vol_obj1->data, loc_params1, vol_obj2->data, loc_params2, + vol_obj1->driver->cls, H5P_DEFAULT, H5P_DEFAULT, + H5P_DATASET_XFER_DEFAULT, H5_REQUEST_NULL)) < 0) HGOTO_ERROR(H5E_SYM, H5E_CANTMOVE, FAIL, "unable to move link") done: @@ -496,60 +611,6 @@ done: /*------------------------------------------------------------------------- - * Function: H5G__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: Quincey Koziol - * Monday, November 6, 2006 - * - *------------------------------------------------------------------------- - */ -static herr_t -H5G__move(hid_t src_loc_id, const char *src_name, hid_t dst_loc_id, - const char *dst_name, hid_t lcpl_id) -{ - H5G_loc_t src_loc, *src_loc_p; /* Group info for source location */ - H5G_loc_t dst_loc, *dst_loc_p; /* Group info for destination location */ - herr_t ret_value = SUCCEED; /* Return value */ - - FUNC_ENTER_STATIC - - /* Check arguments */ - if(src_loc_id != H5L_SAME_LOC && H5G_loc(src_loc_id, &src_loc) < 0) - HGOTO_ERROR(H5E_SYM, H5E_BADTYPE, FAIL, "not a location") - if(dst_loc_id != H5L_SAME_LOC && H5G_loc(dst_loc_id, &dst_loc) < 0) - HGOTO_ERROR(H5E_SYM, H5E_BADTYPE, FAIL, "not a location") - if(!src_name || !*src_name) - HGOTO_ERROR(H5E_SYM, H5E_BADVALUE, FAIL, "no current name specified") - if(!dst_name || !*dst_name) - HGOTO_ERROR(H5E_SYM, H5E_BADVALUE, FAIL, "no destination name specified") - - /* 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) < 0) - HGOTO_ERROR(H5E_SYM, H5E_CANTMOVE, FAIL, "unable to move link") - -done: - FUNC_LEAVE_NOAPI(ret_value) -} /* end H5G__move() */ - - -/*------------------------------------------------------------------------- * Function: H5Gunlink * * Purpose: Removes a link. The new API is H5Ldelete/H5Ldelete_by_idx. @@ -559,15 +620,14 @@ done: herr_t H5Gunlink(hid_t loc_id, const char *name) { - H5G_loc_t loc; /* Group's location */ + H5VL_object_t *vol_obj = NULL; /* object token of loc_id */ + H5VL_loc_params_t loc_params; herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_API(FAIL) H5TRACE2("e", "i*s", loc_id, name); /* Check arguments */ - if(H5G_loc(loc_id, &loc) < 0) - HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a location") if(!name || !*name) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "no name") @@ -575,8 +635,18 @@ H5Gunlink(hid_t loc_id, const char *name) if(H5CX_set_loc(loc_id) < 0) HGOTO_ERROR(H5E_SYM, H5E_CANTSET, FAIL, "can't set collective metadata read info") + loc_params.type = H5VL_OBJECT_BY_NAME; + loc_params.obj_type = H5I_get_type(loc_id); + loc_params.loc_data.loc_by_name.name = name; + loc_params.loc_data.loc_by_name.lapl_id = H5P_LINK_ACCESS_DEFAULT; + + /* Get the location object */ + if(NULL == (vol_obj = (H5VL_object_t *)H5I_object(loc_id))) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "invalid location identifier") + /* Delete the link */ - if(H5L_delete(&loc, name) < 0) + if(H5VL_link_specific(vol_obj->data, loc_params, vol_obj->driver->cls, H5VL_LINK_DELETE, + H5P_DATASET_XFER_DEFAULT, H5_REQUEST_NULL) < 0) HGOTO_ERROR(H5E_SYM, H5E_CANTDELETE, FAIL, "couldn't delete link") done: @@ -595,15 +665,14 @@ done: herr_t H5Gget_linkval(hid_t loc_id, const char *name, size_t size, char *buf/*out*/) { - H5G_loc_t loc; /* Group's location */ + H5VL_object_t *vol_obj = NULL; /* object token of loc_id */ + H5VL_loc_params_t loc_params; herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_API(FAIL) H5TRACE4("e", "i*szx", loc_id, name, size, buf); /* Check arguments */ - if(H5G_loc(loc_id, &loc)) - HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a location") if(!name || !*name) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "no name specified") @@ -611,9 +680,19 @@ H5Gget_linkval(hid_t loc_id, const char *name, size_t size, char *buf/*out*/) if(H5CX_set_loc(loc_id) < 0) HGOTO_ERROR(H5E_SYM, H5E_CANTSET, FAIL, "can't set collective metadata read info") + loc_params.type = H5VL_OBJECT_BY_NAME; + loc_params.obj_type = H5I_get_type(loc_id); + loc_params.loc_data.loc_by_name.name = name; + loc_params.loc_data.loc_by_name.lapl_id = H5P_LINK_ACCESS_DEFAULT; + + /* Get the location object */ + if(NULL == (vol_obj = (H5VL_object_t *)H5I_object(loc_id))) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "invalid location identifier") + /* Get the link value */ - if(H5L_get_val(&loc, name, buf, size) < 0) - HGOTO_ERROR(H5E_SYM, H5E_NOTFOUND, FAIL, "couldn't get link info") + if((ret_value = H5VL_link_get(vol_obj->data, loc_params, vol_obj->driver->cls, H5VL_LINK_GET_VAL, + H5P_DATASET_XFER_DEFAULT, H5_REQUEST_NULL, buf, size)) < 0) + HGOTO_ERROR(H5E_SYM, H5E_CANTGET, FAIL, "unable to get link value") done: FUNC_LEAVE_API(ret_value) diff --git a/src/H5Gint.c b/src/H5Gint.c index 7e2f279..88ef82b 100644 --- a/src/H5Gint.c +++ b/src/H5Gint.c @@ -39,6 +39,7 @@ #include "H5Iprivate.h" /* IDs */ #include "H5Lprivate.h" /* Links */ #include "H5MMprivate.h" /* Memory management */ +#include "H5VLnative.h" /* Virtual Object Layer (native) */ /****************/ @@ -807,7 +808,7 @@ H5G_iterate(H5G_loc_t *loc, const char *group_name, */ if(NULL == (grp = H5G__open_name(loc, group_name))) HGOTO_ERROR(H5E_SYM, H5E_CANTOPENOBJ, FAIL, "unable to open group") - if((gid = H5I_register(H5I_GROUP, grp, TRUE)) < 0) + if((gid = H5VL_native_register(H5I_GROUP, grp, TRUE)) < 0) HGOTO_ERROR(H5E_ATOM, H5E_CANTREGISTER, FAIL, "unable to register group") /* Set up user data for callback */ @@ -1069,7 +1070,7 @@ H5G_visit(H5G_loc_t *loc, const char *group_name, H5_index_t idx_type, HGOTO_ERROR(H5E_SYM, H5E_CANTOPENOBJ, FAIL, "unable to open group") /* Register an ID for the starting group */ - if((gid = H5I_register(H5I_GROUP, grp, TRUE)) < 0) + if((gid = H5VL_native_register(H5I_GROUP, grp, TRUE)) < 0) HGOTO_ERROR(H5E_ATOM, H5E_CANTREGISTER, FAIL, "unable to register group") /* Get the location of the starting group */ diff --git a/src/H5Gloc.c b/src/H5Gloc.c index 2f935e8..2dacd94 100644 --- a/src/H5Gloc.c +++ b/src/H5Gloc.c @@ -137,29 +137,25 @@ static herr_t H5G__loc_get_comment_cb(H5G_loc_t *grp_loc, const char *name, /*------------------------------------------------------------------------- - * Function: H5G_loc + * Function: H5G_loc_real * - * Purpose: Given an object ID return a location for the object. + * Purpose: Utility routine to get object location * * Returns: SUCCEED/FAIL * *------------------------------------------------------------------------- */ herr_t -H5G_loc(hid_t loc_id, H5G_loc_t *loc) +H5G_loc_real(void *obj, H5I_type_t type, H5G_loc_t *loc) { herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_NOAPI(FAIL) - switch(H5I_get_type(loc_id)) { + switch(type) { case H5I_FILE: { - H5F_t *f = NULL; - - /* Get the file struct */ - if(NULL == (f = (H5F_t *)H5I_object(loc_id))) - HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "invalid file ID") + H5F_t *f = (H5F_t *)obj; /* Construct a group location for root group of the file */ if(H5G_root_loc(f, loc) < 0) @@ -169,10 +165,8 @@ H5G_loc(hid_t loc_id, H5G_loc_t *loc) case H5I_GROUP: { - H5G_t *group = NULL; + H5G_t *group = (H5G_t *)obj; - if(NULL == (group = (H5G_t *)H5I_object(loc_id))) - HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "invalid group ID") if(NULL == (loc->oloc = H5G_oloc(group))) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "unable to get object location of group") if(NULL == (loc->path = H5G_nameof(group))) @@ -184,8 +178,9 @@ H5G_loc(hid_t loc_id, H5G_loc_t *loc) { H5T_t *dt = NULL; - if(NULL == (dt = (H5T_t *)H5I_object(loc_id))) - HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "invalid type ID") + /* Get the actual datatype object if the VOL object is set */ + dt = H5T_get_actual_type((H5T_t *)obj); + if(NULL == (loc->oloc = H5T_oloc(dt))) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "unable to get object location of datatype") if(NULL == (loc->path = H5T_nameof(dt))) @@ -195,10 +190,8 @@ H5G_loc(hid_t loc_id, H5G_loc_t *loc) case H5I_DATASET: { - H5D_t *dset = NULL; + H5D_t *dset = (H5D_t *)obj; - if(NULL == (dset = (H5D_t *)H5I_object(loc_id))) - HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "invalid data ID") if(NULL == (loc->oloc = H5D_oloc(dset))) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "unable to get object location of dataset") if(NULL == (loc->path = H5D_nameof(dset))) @@ -208,10 +201,8 @@ H5G_loc(hid_t loc_id, H5G_loc_t *loc) case H5I_ATTR: { - H5A_t *attr = NULL; + H5A_t *attr = (H5A_t *)obj; - if(NULL == (attr = (H5A_t *)H5I_object(loc_id))) - HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "invalid attribute ID") if(NULL == (loc->oloc = H5A_oloc(attr))) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "unable to get object location of attribute") if(NULL == (loc->path = H5A_nameof(attr))) @@ -237,6 +228,9 @@ H5G_loc(hid_t loc_id, H5G_loc_t *loc) case H5I_VFL: HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "unable to get group location of a virtual file driver (VFD)") + case H5I_VOL: + HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "unable to get group location of a virtual object layer (VOL) driver") + case H5I_UNINIT: case H5I_BADID: case H5I_NTYPES: @@ -246,6 +240,36 @@ H5G_loc(hid_t loc_id, H5G_loc_t *loc) done: FUNC_LEAVE_NOAPI(ret_value) +} /* end H5G_loc_real() */ + + +/*------------------------------------------------------------------------- + * Function: H5G_loc + * + * Purpose: Given an object ID return a location for the object. + * + * Return: SUCCEED/FAIL + * + *------------------------------------------------------------------------- + */ +herr_t +H5G_loc(hid_t loc_id, H5G_loc_t *loc) +{ + void *obj = NULL; /* VOL object */ + herr_t ret_value = SUCCEED; /* Return value */ + + FUNC_ENTER_NOAPI(FAIL) + + /* Get the object from the VOL */ + if(NULL == (obj = H5VL_object(loc_id))) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "invalid location identifier") + + /* Fill in the struct */ + if(H5G_loc_real(obj, H5I_get_type(loc_id), loc) < 0) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "unable to fill in location struct") + +done: + FUNC_LEAVE_NOAPI(ret_value) } /* end H5G_loc() */ diff --git a/src/H5Gname.c b/src/H5Gname.c index 31ed0f1..b6b0c20 100644 --- a/src/H5Gname.c +++ b/src/H5Gname.c @@ -835,6 +835,7 @@ H5G_name_replace_cb(void *obj_ptr, hid_t obj_id, void *key) case H5I_ATTR: case H5I_REFERENCE: case H5I_VFL: + case H5I_VOL: case H5I_GENPROP_CLS: case H5I_GENPROP_LST: case H5I_ERROR_CLASS: diff --git a/src/H5Goh.c b/src/H5Goh.c index ec3d30d..f29529b 100644 --- a/src/H5Goh.c +++ b/src/H5Goh.c @@ -27,6 +27,7 @@ #include "H5Gpkg.h" /* Groups */ #include "H5Iprivate.h" /* IDs */ #include "H5Opkg.h" /* Object headers */ +#include "H5VLprivate.h" /* Virtual Object Layer */ /****************/ @@ -46,7 +47,7 @@ static void *H5O__group_get_copy_file_udata(void); static void H5O__group_free_copy_file_udata(void *udata); static htri_t H5O__group_isa(const H5O_t *loc); -static hid_t H5O__group_open(const H5G_loc_t *obj_loc, hbool_t app_ref); +static void *H5O__group_open(const H5G_loc_t *obj_loc, H5I_type_t *opened_type); static void *H5O__group_create(H5F_t *f, void *_crt_info, H5G_loc_t *obj_loc); static H5O_loc_t *H5O__group_get_oloc(hid_t obj_id); static herr_t H5O__group_bh_info(const H5O_loc_t *loc, H5O_t *oh, @@ -197,36 +198,36 @@ done: * * Purpose: Open a group at a particular location * - * Return: Success: Open object identifier - * Failure: Negative + * Return: Success: Pointer to group data + * Failure: NULL * * Programmer: Quincey Koziol * Monday, November 6, 2006 * *------------------------------------------------------------------------- */ -static hid_t -H5O__group_open(const H5G_loc_t *obj_loc, hbool_t app_ref) +static void * +H5O__group_open(const H5G_loc_t *obj_loc, H5I_type_t *opened_type) { - H5G_t *grp = NULL; /* Group opened */ - hid_t ret_value = H5I_INVALID_HID; /* Return value */ + H5G_t *grp = NULL; /* Group opened */ + void *ret_value = NULL; /* Return value */ FUNC_ENTER_STATIC HDassert(obj_loc); + *opened_type = H5I_GROUP; + /* Open the group */ if(NULL == (grp = H5G_open(obj_loc))) - HGOTO_ERROR(H5E_SYM, H5E_CANTOPENOBJ, FAIL, "unable to open group") + HGOTO_ERROR(H5E_SYM, H5E_CANTOPENOBJ, NULL, "unable to open group") - /* Register an ID for the group */ - if((ret_value = H5I_register(H5I_GROUP, grp, app_ref)) < 0) - HGOTO_ERROR(H5E_ATOM, H5E_CANTREGISTER, FAIL, "unable to register group") + ret_value = (void *)grp; done: - if(ret_value < 0) + if(NULL == ret_value) if(grp && H5G_close(grp) < 0) - HDONE_ERROR(H5E_SYM, H5E_CLOSEERROR, FAIL, "unable to release group") + HDONE_ERROR(H5E_SYM, H5E_CLOSEERROR, NULL, "unable to release group") FUNC_LEAVE_NOAPI(ret_value) } /* end H5O__group_open() */ @@ -303,7 +304,7 @@ H5O__group_get_oloc(hid_t obj_id) FUNC_ENTER_STATIC /* Get the group */ - if(NULL == (grp = (H5G_t *)H5I_object(obj_id))) + if(NULL == (grp = (H5G_t *)H5VL_object(obj_id))) HGOTO_ERROR(H5E_OHDR, H5E_BADATOM, NULL, "couldn't get object from ID") /* Get the group's object header location */ diff --git a/src/H5Gprivate.h b/src/H5Gprivate.h index c56b1c8..f4f04bc 100644 --- a/src/H5Gprivate.h +++ b/src/H5Gprivate.h @@ -268,6 +268,7 @@ H5_DLL H5RS_str_t *H5G_build_fullpath_refstr_str(H5RS_str_t *path_r, const char /* * These functions operate on group "locations" */ +H5_DLL herr_t H5G_loc_real(void *obj, H5I_type_t type, H5G_loc_t *loc); H5_DLL herr_t H5G_loc(hid_t loc_id, H5G_loc_t *loc); H5_DLL herr_t H5G_loc_copy(H5G_loc_t *dst, const H5G_loc_t *src, H5_copy_depth_t depth); H5_DLL herr_t H5G_loc_find(const H5G_loc_t *loc, const char *name, diff --git a/src/H5Gtest.c b/src/H5Gtest.c index 1899606..1995015 100644 --- a/src/H5Gtest.c +++ b/src/H5Gtest.c @@ -35,6 +35,8 @@ #include "H5Gpkg.h" /* Groups */ #include "H5HLprivate.h" /* Local Heaps */ #include "H5Iprivate.h" /* IDs */ +#include "H5VLprivate.h" /* Virtual Object Layer */ + /****************/ /* Local Macros */ @@ -102,7 +104,7 @@ H5G__is_empty_test(hid_t gid) FUNC_ENTER_PACKAGE /* Get group structure */ - if(NULL == (grp = (H5G_t *)H5I_object_verify(gid, H5I_GROUP))) + if(NULL == (grp = (H5G_t *)H5VL_object_verify(gid, H5I_GROUP))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a group") /* Set API context */ @@ -222,7 +224,7 @@ H5G__has_links_test(hid_t gid, unsigned *nmsgs) FUNC_ENTER_PACKAGE /* Get group structure */ - if(NULL == (grp = (H5G_t *)H5I_object_verify(gid, H5I_GROUP))) + if(NULL == (grp = (H5G_t *)H5VL_object_verify(gid, H5I_GROUP))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a group") /* Set API context */ @@ -289,7 +291,7 @@ H5G__has_stab_test(hid_t gid) FUNC_ENTER_PACKAGE /* Get group structure */ - if(NULL == (grp = (H5G_t *)H5I_object_verify(gid, H5I_GROUP))) + if(NULL == (grp = (H5G_t *)H5VL_object_verify(gid, H5I_GROUP))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a group") /* Set API context */ @@ -348,7 +350,7 @@ H5G__is_new_dense_test(hid_t gid) FUNC_ENTER_PACKAGE /* Get group structure */ - if(NULL == (grp = (H5G_t *)H5I_object_verify(gid, H5I_GROUP))) + if(NULL == (grp = (H5G_t *)H5VL_object_verify(gid, H5I_GROUP))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a group") /* Set API context */ @@ -427,7 +429,7 @@ H5G__new_dense_info_test(hid_t gid, hsize_t *name_count, hsize_t *corder_count) FUNC_ENTER_PACKAGE /* Get group structure */ - if(NULL == (grp = (H5G_t *)H5I_object_verify(gid, H5I_GROUP))) + if(NULL == (grp = (H5G_t *)H5VL_object_verify(gid, H5I_GROUP))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a group") /* Set API context */ @@ -515,7 +517,7 @@ H5G__lheap_size_test(hid_t gid, size_t *lheap_size) FUNC_ENTER_PACKAGE /* Get group structure */ - if(NULL == (grp = (H5G_t *)H5I_object_verify(gid, H5I_GROUP))) + if(NULL == (grp = (H5G_t *)H5VL_object_verify(gid, H5I_GROUP))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a group") /* Set API context */ @@ -576,7 +578,7 @@ H5G__user_path_test(hid_t obj_id, char *user_path, size_t *user_path_len, unsign HDassert(obj_hidden); /* Get pointer to object for ID */ - if(NULL == (obj_ptr = H5I_object(obj_id))) + if(NULL == (obj_ptr = H5VL_object(obj_id))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "can't get object for ID") /* Set API context */ @@ -609,6 +611,7 @@ H5G__user_path_test(hid_t obj_id, char *user_path, size_t *user_path_len, unsign case H5I_ATTR: case H5I_REFERENCE: case H5I_VFL: + case H5I_VOL: case H5I_GENPROP_CLS: case H5I_GENPROP_LST: case H5I_ERROR_CLASS: @@ -829,7 +832,7 @@ H5G__verify_cached_stabs_test(hid_t gid) HDassert(gid >= 0); /* Check args */ - if(NULL == (grp = (H5G_t *)H5I_object_verify(gid, H5I_GROUP))) + if(NULL == (grp = (H5G_t *)H5VL_object_verify(gid, H5I_GROUP))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a group") /* Set up metadata tagging */ diff --git a/src/H5Gtraverse.c b/src/H5Gtraverse.c index e412e7c..a103f53 100644 --- a/src/H5Gtraverse.c +++ b/src/H5Gtraverse.c @@ -43,6 +43,7 @@ #include "H5MMprivate.h" /* Memory management */ #include "H5Ppublic.h" /* Property Lists */ #include "H5WBprivate.h" /* Wrapped Buffers */ +#include "H5VLnative.h" /* Virtual Object Layer (native) */ /****************/ @@ -197,7 +198,7 @@ H5G__traverse_ud(const H5G_loc_t *grp_loc/*in,out*/, const H5O_link_t *lnk, /* Create a group ID to pass to the user-defined callback */ if(NULL == (grp = H5G_open(&grp_loc_copy))) HGOTO_ERROR(H5E_SYM, H5E_CANTOPENOBJ, FAIL, "unable to open group") - if((cur_grp = H5I_register(H5I_GROUP, grp, FALSE)) < 0) + if((cur_grp = H5VL_native_register(H5I_GROUP, grp, FALSE)) < 0) HGOTO_ERROR(H5E_SYM, H5E_CANTREGISTER, FAIL, "unable to register group") /* User-defined callback function */ @@ -41,6 +41,7 @@ #include "H5Oprivate.h" /* Object headers */ #include "H5SLprivate.h" /* Skip Lists */ #include "H5Tpkg.h" /* Datatypes */ +#include "H5VLprivate.h" /* Virtual Object Layer */ /* Local Macros */ @@ -74,11 +75,24 @@ typedef struct { void *ret_obj; /* Object to return */ } H5I_search_ud_t; +typedef struct { + H5I_iterate_func_t op; /* Application's callback routine */ + void *op_data; /* Application's user data */ +} H5I_iterate_pub_ud_t; + +/* User data for iterator callback for retrieving an ID corresponding to an object pointer */ +typedef struct { + const void *object; /* object pointer to search for */ + H5I_type_t obj_type; /* type of object we are searching for */ + hid_t ret_id; /* ID returned */ +} H5I_get_id_ud_t; + /* User data for iterator callback for ID iteration */ typedef struct { H5I_search_func_t user_func; /* 'User' function to invoke */ void *user_udata; /* User data to pass to 'user' function */ hbool_t app_ref; /* Whether this is an appl. ref. call */ + H5I_type_t obj_type; /* Type of object we are iterating over */ } H5I_iterate_ud_t; /* User data for H5I__clear_type_cb */ @@ -113,6 +127,8 @@ H5FL_DEFINE_STATIC(H5I_id_type_t); /* Declare a free list to manage the H5I_class_t struct */ H5FL_DEFINE_STATIC(H5I_class_t); +H5FL_EXTERN(H5VL_object_t); + /*--------------------- Local function prototypes ---------------------------*/ static htri_t H5I__clear_type_cb(void *_id, void *key, void *udata); static int H5I__destroy_type(H5I_type_t type); @@ -122,7 +138,9 @@ static int H5I__inc_type_ref(H5I_type_t type); static int H5I__get_type_ref(H5I_type_t type); static int H5I__search_cb(void *obj, hid_t id, void *_udata); static H5I_id_info_t *H5I__find_id(hid_t id); +static int H5I__iterate_pub_cb(void *obj, hid_t id, void *udata); static hid_t H5I__get_file_id(hid_t obj_id, H5I_type_t id_type); +static int H5I__find_id_cb(void *_item, void *_key, void *_udata); static int H5I__id_dump_cb(void *_item, void *_key, void *_udata); @@ -543,7 +561,7 @@ H5I__clear_type_cb(void *_id, void H5_ATTR_UNUSED *key, void *_udata) if(udata->force) { #ifdef H5I_DEBUG if(H5DEBUG(I)) { - fprintf(H5DEBUG(I), "H5I: free type=%d obj=0x%08lx " + HDfprintf(H5DEBUG(I), "H5I: free type=%d obj=0x%08lx " "failure ignored\n", (int)udata->type_ptr->cls->type_id, (unsigned long)(id->obj_ptr)); @@ -760,8 +778,9 @@ done: *------------------------------------------------------------------------- */ herr_t -H5I_register_with_id(H5I_type_t type, const void *object, hbool_t app_ref, hid_t id) +H5I_register_with_id(H5I_type_t type, void *object, H5VL_t *vol_driver, hbool_t app_ref, hid_t id) { + H5VL_object_t *new_vol_obj = NULL; /* pointer to new VOL object */ H5I_id_type_t *type_ptr; /* ptr to the type */ H5I_id_info_t *id_ptr; /* ptr to the new ID information */ herr_t ret_value = SUCCEED; /* return value */ @@ -770,6 +789,7 @@ H5I_register_with_id(H5I_type_t type, const void *object, hbool_t app_ref, hid_t /* Check arguments */ HDassert(object); + HDassert(vol_driver); /* Make sure ID is not already in use */ if(NULL != (id_ptr = H5I__find_id(id))) @@ -793,11 +813,29 @@ H5I_register_with_id(H5I_type_t type, const void *object, hbool_t app_ref, hid_t if(NULL == (id_ptr = H5FL_MALLOC(H5I_id_info_t))) HGOTO_ERROR(H5E_ATOM, H5E_NOSPACE, FAIL, "memory allocation failed") + /* Set up the new VOL object */ + if(NULL == (new_vol_obj = H5FL_CALLOC(H5VL_object_t))) + HGOTO_ERROR(H5E_ATOM, H5E_CANTALLOC, FAIL, "can't allocate memory for VOL object"); + new_vol_obj->driver = vol_driver; + new_vol_obj->data = object; + + /* Bump the reference count on the VOL driver */ + vol_driver->nrefs++; + /* Create the struct & insert requested ID */ id_ptr->id = id; id_ptr->count = 1; /* initial reference count*/ id_ptr->app_count = !!app_ref; - id_ptr->obj_ptr = object; + if(H5I_DATATYPE == type) { + void *dt = NULL; + + if(NULL == (dt = (void *)H5T_construct_datatype(new_vol_obj))) + HGOTO_ERROR(H5E_ATOM, H5E_CANTINIT, FAIL, "can't construct datatype object"); + + id_ptr->obj_ptr = dt; + } + else + id_ptr->obj_ptr = new_vol_obj; /* Insert into the type */ if(H5SL_insert(type_ptr->ids, id_ptr, &id_ptr->id) < 0) @@ -1842,6 +1880,91 @@ done: /*------------------------------------------------------------------------- + * Function: H5I__iterate_pub_cb + * + * Purpose: Callback routine for H5Iiterate, when it calls + * H5I_iterate. Calls "user" callback search function, and + * then sets return value, based on the result of that + * callback. + * + * Return: Success: H5_ITER_CONT (0) or H5_ITER_STOP (1) + * Failure: H5_ITER_ERROR (-1) + * + * Programmer: Neil Fortner + * Friday, October 11, 2013 + * + *------------------------------------------------------------------------- + */ +static int +H5I__iterate_pub_cb(void H5_ATTR_UNUSED *obj, hid_t id, void *_udata) +{ + H5I_iterate_pub_ud_t *udata = (H5I_iterate_pub_ud_t *)_udata; /* User data for callback */ + herr_t cb_ret_val; /* User callback return value */ + int ret_value = H5_ITER_ERROR; /* Callback return value */ + + FUNC_ENTER_STATIC_NOERR + + /* Invoke the callback */ + cb_ret_val = (*udata->op)(id, udata->op_data); + + /* Set the return value based on the callback's return value */ + if(cb_ret_val > 0) + ret_value = H5_ITER_STOP; /* terminate iteration early */ + else if(cb_ret_val < 0) + ret_value = H5_ITER_ERROR; /* indicate failure (which terminates iteration) */ + + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5I__iterate_pub_cb() */ + + +/*------------------------------------------------------------------------- + * Function: H5Iiterate + * + * Purpose: Call the callback funciton op for each member of the id + * type type. op takes as parameters the id and a + * passthrough of op_data, and returns an herr_t. A positive + * return from op will cause the iteration to stop and + * H5Iiterate will return the value returned by op. A + * negative return from op will cause the iteration to stop + * and H5Iiterate will return failure. A zero return from op + * will allow iteration to continue, as long as there are + * other ids remaining in type. + * + * Limitation: Currently there is no way to start searching from where a + * previous search left off. + * + * Return: The last value returned by op + * + * Programmer: Neil Fortner + * Friday, October 11, 2013 + * + *------------------------------------------------------------------------- + */ +herr_t +H5Iiterate(H5I_type_t type, H5I_iterate_func_t op, void *op_data) +{ + H5I_iterate_pub_ud_t int_udata; /* Internal user data */ + herr_t ret_value; /* Return value */ + + FUNC_ENTER_API(FAIL) + H5TRACE3("e", "Itx*x", type, op, op_data); + + /* Set up udata struct */ + int_udata.op = op; + int_udata.op_data = op_data; + + /* Note that H5I_iterate returns an error code. We ignore it + * here, as we can't do anything with it without revising the API. + */ + if ((ret_value = H5I_iterate(type, H5I__iterate_pub_cb, &int_udata, TRUE)) < 0) + HGOTO_ERROR(H5E_ATOM, H5E_BADITER, FAIL, "can't iterate over ids") + +done: + FUNC_LEAVE_API(ret_value) +} /* end H5Iiterate() */ + + +/*------------------------------------------------------------------------- * Function: H5I__iterate_cb * * Purpose: Callback routine for H5I_iterate, invokes "user" callback @@ -1866,10 +1989,26 @@ H5I__iterate_cb(void *_item, void H5_ATTR_UNUSED *_key, void *_udata) * its reference count is positive. */ if((!udata->app_ref) || (item->app_count > 0)) { + H5I_type_t type = udata->obj_type; + const void *obj_ptr = NULL; herr_t cb_ret_val; + /* The stored object pointer might be an H5VL_object_t, in which + * case we'll need to get the wrapped object struct (H5F_t *, etc.). + */ + if(H5I_FILE == type || H5I_GROUP == type || H5I_DATASET == type || H5I_ATTR == type) { + const H5VL_object_t *vol_obj = (const H5VL_object_t *)item->obj_ptr; + obj_ptr = vol_obj->data; + } + else if(H5I_DATATYPE == type) { + const H5T_t *dt = (const H5T_t *)item->obj_ptr; + obj_ptr = (void *)H5T_get_actual_type(dt); + } + else + obj_ptr = item->obj_ptr; + /* Invoke callback function */ - cb_ret_val = (*udata->user_func)((void *)item->obj_ptr, item->id, udata->user_udata); /* (Casting away const OK) */ + cb_ret_val = (*udata->user_func)((void *)obj_ptr, item->id, udata->user_udata); /* (Casting away const OK) */ /* Set the return value based on the callback's return value */ if(cb_ret_val > 0) @@ -1929,6 +2068,7 @@ H5I_iterate(H5I_type_t type, H5I_search_func_t func, void *udata, hbool_t app_re iter_udata.user_func = func; iter_udata.user_udata = udata; iter_udata.app_ref = app_ref; + iter_udata.obj_type = type; /* Iterate over IDs */ if ((iter_status = H5SL_iterate(type_ptr->ids, H5I__iterate_cb, &iter_udata)) < 0) @@ -1987,6 +2127,9 @@ done: * * Failure: -1 * + * NOTE: Not safe for arbitrary VOL drivers as it relies on + * private H5G calls. + * * Comments: Public function * If 'name' is non-NULL then write up to 'size' bytes into that * buffer and always return the length of the entry name. @@ -2072,34 +2215,136 @@ done: static hid_t H5I__get_file_id(hid_t obj_id, H5I_type_t type) { + H5VL_object_t *vol_obj = NULL; + void *file = NULL; hid_t ret_value = H5I_INVALID_HID; /* Return value */ FUNC_ENTER_STATIC - /* Process based on object type */ - if (type == H5I_FILE) { - /* Increment reference count on file ID */ - if(H5I_inc_ref(obj_id, TRUE) < 0) - HGOTO_ERROR(H5E_ATOM, H5E_CANTSET, H5I_INVALID_HID, "incrementing file ID failed") + /* Get the object pointer */ + if (NULL == (vol_obj = H5VL_get_object(obj_id))) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, H5I_INVALID_HID, "invalid identifier") - /* Set return value */ - ret_value = obj_id; + /* Get the file through the VOL */ + if (H5VL_file_get(vol_obj->data, vol_obj->driver->cls, H5VL_OBJECT_GET_FILE, H5P_DATASET_XFER_DEFAULT, H5_REQUEST_NULL, type, &file) < 0) + HGOTO_ERROR(H5E_FILE, H5E_CANTINIT, H5I_INVALID_HID, "unable to get file") + if (NULL == file) + HGOTO_ERROR(H5E_FILE, H5E_CANTINIT, H5I_INVALID_HID, "unable to get the file through the VOL") + + /* Check if the file's ID already exists */ + if (H5I_find_id(file, H5I_FILE, &ret_value) < 0) + HGOTO_ERROR(H5E_ATOM, H5E_CANTGET, H5I_INVALID_HID, "getting file ID failed") + + /* If the ID does not exist, register it with the VOL driver */ + if (H5I_INVALID_HID == ret_value) { + if ((ret_value = H5VL_register_id(H5I_FILE, file, vol_obj->driver, TRUE)) < 0) + HGOTO_ERROR(H5E_ATOM, H5E_CANTREGISTER, H5I_INVALID_HID, "unable to atomize file handle") } else { - H5G_loc_t loc; /* Location of object */ + /* Increment ref count on existing ID */ + if (H5I_inc_ref(ret_value, TRUE) < 0) + HGOTO_ERROR(H5E_ATOM, H5E_CANTSET, H5I_INVALID_HID, "incrementing file ID failed") + } + +done: + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5I__get_file_id() */ + + +/*------------------------------------------------------------------------- + * Function: H5I__find_id_cb + * + * Purpose: Callback for searching for an ID with a specific pointer + * + * Return: Success: H5_ITER_CONT (0) or H5_ITER_STOP (1) + * Failure: H5_ITER_ERROR (-1) + * + *------------------------------------------------------------------------- + */ +static int +H5I__find_id_cb(void *_item, void H5_ATTR_UNUSED *_key, void *_udata) +{ + H5I_id_info_t *item = (H5I_id_info_t *)_item; /* Pointer to the ID node */ + H5I_get_id_ud_t *udata = (H5I_get_id_ud_t *)_udata; /* Pointer to user data */ + H5I_type_t type = udata->obj_type; + const void *obj_ptr = NULL; + int ret_value = H5_ITER_CONT; /* Return value */ - /* Get the object location information */ - if(H5G_loc(obj_id, &loc) < 0) - HGOTO_ERROR(H5E_ATOM, H5E_CANTGET, H5I_INVALID_HID, "can't get object location") + FUNC_ENTER_STATIC_NOERR + + /* Sanity check */ + HDassert(item); + HDassert(udata); - /* Get the file ID for the object */ - if((ret_value = H5F_get_id(loc.oloc->file, TRUE)) < 0) - HGOTO_ERROR(H5E_ATOM, H5E_CANTGET, H5I_INVALID_HID, "can't get file ID") + /* Get a pointer to the VOL driver's data */ + if (H5I_FILE == type || H5I_GROUP == type || H5I_DATASET == type || H5I_ATTR == type) { + const H5VL_object_t *vol_obj = (const H5VL_object_t *)item->obj_ptr; + obj_ptr = vol_obj->data; + } + else if (H5I_DATATYPE == type) { + const H5T_t *dt = (const H5T_t *)item->obj_ptr; + obj_ptr = (void *)H5T_get_actual_type(dt); + } + else + obj_ptr = item->obj_ptr; + + /* Check for a match */ + if (obj_ptr == udata->object) { + udata->ret_id = item->id; + ret_value = H5_ITER_STOP; + } + + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5I__find_id_cb() */ + + +/*------------------------------------------------------------------------- + * Function: H5I_find_id + * + * Purpose: Return the ID of an object by searching through the ID list + * for the type. + * + * Return: SUCCEED/FAIL + * (id will be set to H5I_INVALID_HID on errors or not found) + * + *------------------------------------------------------------------------- + */ +herr_t +H5I_find_id(const void *object, H5I_type_t type, hid_t *id) +{ + H5I_id_type_t *type_ptr; /* Pointer to the type */ + herr_t ret_value = SUCCEED; /* Return value */ + + FUNC_ENTER_NOAPI(FAIL) + + HDassert(id); + + *id = H5I_INVALID_HID; + + type_ptr = H5I_id_type_list_g[type]; + if (!type_ptr || type_ptr->init_count <= 0) + HGOTO_ERROR(H5E_ATOM, H5E_BADGROUP, FAIL, "invalid type") + + /* Only iterate through ID list if it is initialized and there are IDs in type */ + if (type_ptr->init_count > 0 && type_ptr->id_count > 0) { + H5I_get_id_ud_t udata; /* User data */ + herr_t iter_status; /* Iteration status */ + + /* Set up iterator user data */ + udata.object = object; + udata.obj_type = type; + udata.ret_id = H5I_INVALID_HID; + + /* Iterate over IDs for the ID type */ + if ((iter_status = H5SL_iterate(type_ptr->ids, H5I__find_id_cb, &udata)) < 0) + HGOTO_ERROR(H5E_ATOM, H5E_BADITER, FAIL, "iteration failed") + + *id = udata.ret_id; } done: FUNC_LEAVE_NOAPI(ret_value) -} /* end H5I__get_file_id() */ +} /* end H5I_find_id() */ /*------------------------------------------------------------------------- @@ -2117,6 +2362,7 @@ H5I__id_dump_cb(void *_item, void H5_ATTR_UNUSED *_key, void *_udata) H5I_id_info_t *item = (H5I_id_info_t *)_item; /* Pointer to the ID node */ H5I_type_t type = *(H5I_type_t *)_udata; /* User data */ H5G_name_t *path = NULL; /* Path to file object */ + const void *obj_ptr = NULL; /* Pointer to VOL driver object */ FUNC_ENTER_STATIC_NOERR @@ -2128,17 +2374,31 @@ H5I__id_dump_cb(void *_item, void H5_ATTR_UNUSED *_key, void *_udata) switch (type) { case H5I_GROUP: { - path = H5G_nameof((H5G_t*)item->obj_ptr); + const H5VL_object_t *vol_obj = (const H5VL_object_t *)item->obj_ptr; + + obj_ptr = vol_obj->data; + + if(H5_VOL_NATIVE == vol_obj->driver->cls->value) + path = H5G_nameof((H5G_t *)obj_ptr); break; } case H5I_DATASET: { - path = H5D_nameof((H5D_t*)item->obj_ptr); + const H5VL_object_t *vol_obj = (const H5VL_object_t *)item->obj_ptr; + + obj_ptr = vol_obj->data; + + if(H5_VOL_NATIVE == vol_obj->driver->cls->value) + path = H5D_nameof((H5D_t *)obj_ptr); break; } case H5I_DATATYPE: { - path = H5T_nameof((H5T_t*)item->obj_ptr); + const H5T_t *dt = (const H5T_t *)item->obj_ptr; + + obj_ptr = (void *)H5T_get_actual_type(dt); + + path = H5T_nameof((H5T_t *)obj_ptr); break; } case H5I_UNINIT: @@ -2148,6 +2408,7 @@ H5I__id_dump_cb(void *_item, void H5_ATTR_UNUSED *_key, void *_udata) case H5I_ATTR: case H5I_REFERENCE: case H5I_VFL: + case H5I_VOL: case H5I_GENPROP_CLS: case H5I_GENPROP_LST: case H5I_ERROR_CLASS: diff --git a/src/H5Iprivate.h b/src/H5Iprivate.h index 6a0fc01..8fd7caa 100644 --- a/src/H5Iprivate.h +++ b/src/H5Iprivate.h @@ -25,6 +25,7 @@ /* Private headers needed by this file */ #include "H5private.h" +#include "H5VLprivate.h" /**************************/ /* Library Private Macros */ @@ -67,7 +68,7 @@ H5_DLL herr_t H5I_register_type(const H5I_class_t *cls); H5_DLL int64_t H5I_nmembers(H5I_type_t type); H5_DLL herr_t H5I_clear_type(H5I_type_t type, hbool_t force, hbool_t app_ref); H5_DLL hid_t H5I_register(H5I_type_t type, const void *object, hbool_t app_ref); -H5_DLL herr_t H5I_register_with_id(H5I_type_t type, const void *object, hbool_t app_ref, hid_t id); +H5_DLL herr_t H5I_register_with_id(H5I_type_t type, void *object, H5VL_t *vol_driver, hbool_t app_ref, hid_t id); H5_DLL void *H5I_subst(hid_t id, const void *new_object); H5_DLL void *H5I_object(hid_t id); H5_DLL void *H5I_object_verify(hid_t id, H5I_type_t id_type); @@ -80,6 +81,7 @@ H5_DLL int H5I_dec_ref(hid_t id); H5_DLL int H5I_dec_app_ref(hid_t id); H5_DLL int H5I_dec_app_ref_always_close(hid_t id); H5_DLL int H5I_dec_type_ref(H5I_type_t type); +H5_DLL herr_t H5I_find_id(const void *object, H5I_type_t type, hid_t *id /*out*/); /* Debugging functions */ H5_DLL herr_t H5I_dump_ids_for_type(H5I_type_t type); diff --git a/src/H5Ipublic.h b/src/H5Ipublic.h index c471e5a..f4b5cc9 100644 --- a/src/H5Ipublic.h +++ b/src/H5Ipublic.h @@ -44,6 +44,7 @@ typedef enum H5I_type_t { H5I_ATTR, /* type ID for Attribute objects */ H5I_REFERENCE, /* *DEPRECATED* type ID for Reference objects */ H5I_VFL, /* type ID for virtual file layer */ + H5I_VOL, /* type ID for virtual object layer */ H5I_GENPROP_CLS, /* type ID for generic property list classes */ H5I_GENPROP_LST, /* type ID for generic property lists */ H5I_ERROR_CLASS, /* type ID for error classes */ @@ -71,6 +72,9 @@ typedef herr_t (*H5I_free_t)(void *); /* Type of the function to compare objects & keys */ typedef int (*H5I_search_func_t)(void *obj, hid_t id, void *key); +/* Type of the H5Iiterate callback function */ +typedef herr_t (*H5I_iterate_func_t)(hid_t id, void *udata); + #ifdef __cplusplus extern "C" { #endif @@ -93,6 +97,7 @@ H5_DLL int H5Iinc_type_ref(H5I_type_t type); H5_DLL int H5Idec_type_ref(H5I_type_t type); H5_DLL int H5Iget_type_ref(H5I_type_t type); H5_DLL void *H5Isearch(H5I_type_t type, H5I_search_func_t func, void *key); +H5_DLL herr_t H5Iiterate(H5I_type_t type, H5I_iterate_func_t op, void *op_data); H5_DLL herr_t H5Inmembers(H5I_type_t type, hsize_t *num_members); H5_DLL htri_t H5Itype_exists(H5I_type_t type); H5_DLL htri_t H5Iis_valid(hid_t id); @@ -33,6 +33,9 @@ #include "H5MMprivate.h" /* Memory management */ #include "H5Oprivate.h" /* File objects */ #include "H5Pprivate.h" /* Property lists */ +#include "H5VLprivate.h" /* Virtual Object Layer */ +#include "H5VLnative.h" /* Virtual Object Layer (native) */ + /****************/ /* Local Macros */ @@ -272,8 +275,10 @@ 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; + H5VL_object_t *vol_obj1 = NULL; /* Object token of src_id */ + H5VL_loc_params_t loc_params1; + H5VL_object_t *vol_obj2 = NULL; /* Object token of dst_id */ + H5VL_loc_params_t loc_params2; herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_API(FAIL) @@ -283,10 +288,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) @@ -294,21 +295,49 @@ 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") + /* Check the link create property list */ + if(H5P_DEFAULT == lcpl_id) + lcpl_id = H5P_LINK_CREATE_DEFAULT; + /* Verify access property list and set up collective metadata if appropriate */ if(H5CX_set_apl(&lapl_id, H5P_CLS_LACC, ((src_loc_id != H5L_SAME_LOC) ? src_loc_id : dst_loc_id), TRUE) < 0) HGOTO_ERROR(H5E_LINK, H5E_CANTSET, FAIL, "can't set access property list info") - /* 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; + /* Set location paramter for source object */ + loc_params1.type = H5VL_OBJECT_BY_NAME; + loc_params1.loc_data.loc_by_name.name = src_name; + loc_params1.loc_data.loc_by_name.lapl_id = lapl_id; + loc_params1.obj_type = H5I_get_type(src_loc_id); + + /* Set location paramter for destination object */ + loc_params2.type = H5VL_OBJECT_BY_NAME; + loc_params2.loc_data.loc_by_name.name = dst_name; + loc_params2.loc_data.loc_by_name.lapl_id = lapl_id; + loc_params2.obj_type = H5I_get_type(dst_loc_id); + + if (H5L_SAME_LOC != src_loc_id) { + /* Get the location object */ + if (NULL == (vol_obj1 = (H5VL_object_t *)H5I_object(src_loc_id))) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "invalid location identifier") + } + if (H5L_SAME_LOC != dst_loc_id) { + /* Get the location object */ + if (NULL == (vol_obj2 = (H5VL_object_t *)H5I_object(dst_loc_id))) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "invalid location identifier") + } + + /* Make sure that the VOL drivers are the same */ + if (vol_obj1 && vol_obj2) { + if (vol_obj1->driver->cls->value != vol_obj2->driver->cls->value) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "Objects are accessed through different VOL plugins and can't be linked") + } /* Move the link */ - if(H5L_move(src_loc_p, src_name, dst_loc_p, dst_name, FALSE, lcpl_id) < 0) + if (H5VL_link_move((vol_obj1 ? vol_obj1->data : NULL), loc_params1, + (vol_obj2 ? vol_obj2->data : NULL), loc_params2, + (vol_obj1 ? vol_obj1->driver->cls : vol_obj2->driver->cls), + lcpl_id, lapl_id, H5P_DATASET_XFER_DEFAULT, H5_REQUEST_NULL) < 0) HGOTO_ERROR(H5E_LINK, H5E_CANTMOVE, FAIL, "unable to move link") done: @@ -334,8 +363,10 @@ 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; + H5VL_object_t *vol_obj1 = NULL; /* Object token of src_id */ + H5VL_loc_params_t loc_params1; + H5VL_object_t *vol_obj2 = NULL; /* Object token of dst_id */ + H5VL_loc_params_t loc_params2; herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_API(FAIL) @@ -345,10 +376,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) @@ -361,16 +388,45 @@ H5Lcopy(hid_t src_loc_id, const char *src_name, hid_t dst_loc_id, ((src_loc_id != H5L_SAME_LOC) ? src_loc_id : dst_loc_id), TRUE) < 0) HGOTO_ERROR(H5E_LINK, H5E_CANTSET, FAIL, "can't set access property list info") - /* 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; + /* Check the link create property list */ + if(H5P_DEFAULT == lcpl_id) + lcpl_id = H5P_LINK_CREATE_DEFAULT; + + + /* Set location paramter for source object */ + loc_params1.type = H5VL_OBJECT_BY_NAME; + loc_params1.loc_data.loc_by_name.name = src_name; + loc_params1.loc_data.loc_by_name.lapl_id = lapl_id; + loc_params1.obj_type = H5I_get_type(src_loc_id); + + /* Set location paramter for destination object */ + loc_params2.type = H5VL_OBJECT_BY_NAME; + loc_params2.loc_data.loc_by_name.name = dst_name; + loc_params2.loc_data.loc_by_name.lapl_id = lapl_id; + loc_params2.obj_type = H5I_get_type(dst_loc_id); + + if(H5L_SAME_LOC != src_loc_id) { + /* Get the location object */ + if(NULL == (vol_obj1 = (H5VL_object_t *)H5I_object(src_loc_id))) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "invalid location identifier") + } + if(H5L_SAME_LOC != dst_loc_id) { + /* Get the location object */ + if(NULL == (vol_obj2 = (H5VL_object_t *)H5I_object(dst_loc_id))) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "invalid location identifier") + } + + /* Make sure that the VOL plugins are the same */ + if(vol_obj1 && vol_obj2) { + if(vol_obj1->driver->cls->value != vol_obj2->driver->cls->value) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "Objects are accessed through different VOL plugins and can't be linked") + } /* Copy the link */ - if(H5L_move(src_loc_p, src_name, dst_loc_p, dst_name, TRUE, lcpl_id) < 0) + if(H5VL_link_copy((vol_obj1 ? vol_obj1->data : NULL), loc_params1, + (vol_obj2 ? vol_obj2->data : NULL), loc_params2, + (vol_obj1 ? vol_obj1->driver->cls : vol_obj2->driver->cls), + lcpl_id, lapl_id, H5P_DATASET_XFER_DEFAULT, H5_REQUEST_NULL) < 0) HGOTO_ERROR(H5E_LINK, H5E_CANTMOVE, FAIL, "unable to copy link") done: @@ -397,18 +453,20 @@ done: *------------------------------------------------------------------------- */ 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) +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 */ + H5VL_object_t *vol_obj = NULL; /* object token of loc_id */ + H5VL_loc_params_t loc_params; + H5P_genplist_t *plist = NULL; /* 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) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "link_target parameter cannot be NULL") if(!*link_target) @@ -420,12 +478,35 @@ H5Lcreate_soft(const char *link_target, hid_t link_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") + /* Check the group access property list */ + if(H5P_DEFAULT == lcpl_id) + lcpl_id = H5P_LINK_CREATE_DEFAULT; + + /* Set location fields */ + loc_params.type = H5VL_OBJECT_BY_NAME; + loc_params.loc_data.loc_by_name.name = link_name; + loc_params.loc_data.loc_by_name.lapl_id = lapl_id; + loc_params.obj_type = H5I_get_type(link_loc_id); + + /* get the location object */ + if(NULL == (vol_obj = (H5VL_object_t *)H5VL_get_object(link_loc_id))) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "invalid location identifier") + + /* 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, H5VL_PROP_LINK_TARGET_NAME, &link_target) < 0) + HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, FAIL, "can't get property value for target name") + /* Verify access property list and set up collective metadata if appropriate */ if(H5CX_set_apl(&lapl_id, H5P_CLS_LACC, link_loc_id, TRUE) < 0) HGOTO_ERROR(H5E_LINK, H5E_CANTSET, FAIL, "can't set access property list info") /* Create the link */ - if(H5L_create_soft(link_target, &link_loc, link_name, lcpl_id) < 0) + if(H5VL_link_create(H5VL_LINK_CREATE_SOFT, vol_obj->data, loc_params, vol_obj->driver->cls, + lcpl_id, lapl_id, H5P_DATASET_XFER_DEFAULT, H5_REQUEST_NULL) < 0) HGOTO_ERROR(H5E_LINK, H5E_CANTCREATE, FAIL, "unable to create soft link") done: @@ -453,8 +534,11 @@ 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; + H5VL_object_t *vol_obj1 = NULL; /* object token of cur_loc_id */ + H5VL_object_t *vol_obj2 = NULL; /* object token of new_loc_id */ + H5VL_loc_params_t loc_params1; + H5VL_loc_params_t loc_params2; + H5P_genplist_t *plist; /* Property list pointer */ herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_API(FAIL) @@ -464,10 +548,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) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "cur_name parameter cannot be NULL") if(!*cur_name) @@ -479,22 +559,56 @@ 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") + /* Check the link create property list */ + if(H5P_DEFAULT == lcpl_id) + lcpl_id = H5P_LINK_CREATE_DEFAULT; + /* Verify access property list and set up collective metadata if appropriate */ if(H5CX_set_apl(&lapl_id, H5P_CLS_LACC, cur_loc_id, TRUE) < 0) HGOTO_ERROR(H5E_LINK, H5E_CANTSET, FAIL, "can't set access property list info") - /* 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.") + /* Set up current & new location structs */ + loc_params1.type = H5VL_OBJECT_BY_NAME; + loc_params1.obj_type = H5I_get_type(cur_loc_id); + loc_params1.loc_data.loc_by_name.name = cur_name; + loc_params1.loc_data.loc_by_name.lapl_id = lapl_id; + + loc_params2.type = H5VL_OBJECT_BY_NAME; + loc_params2.obj_type = H5I_get_type(new_loc_id); + loc_params2.loc_data.loc_by_name.name = new_name; + loc_params2.loc_data.loc_by_name.lapl_id = lapl_id; + + if(H5L_SAME_LOC != cur_loc_id) { + /* Get the current location object */ + if (NULL == (vol_obj1 = (H5VL_object_t *)H5VL_get_object(cur_loc_id))) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "invalid location identifier") + } + if(H5L_SAME_LOC != new_loc_id) { + /* Get the new location object */ + if(NULL == (vol_obj2 = (H5VL_object_t *)H5VL_get_object(new_loc_id))) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "invalid location identifier") + } + + /* Make sure that the VOL drivers are the same */ + if(vol_obj1 && vol_obj2) { + if(vol_obj1->driver->cls->value != vol_obj2->driver->cls->value) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "Objects are accessed through different VOL drivers and can't be linked") + } + + /* Get the link creation plist structure */ + if(NULL == (plist = (H5P_genplist_t *)H5I_object(lcpl_id))) + HGOTO_ERROR(H5E_LINK, H5E_BADATOM, FAIL, "can't find object for ID") + + /* Set creation properties */ + if(H5P_set(plist, H5VL_PROP_LINK_TARGET, (vol_obj1 ? &(vol_obj1->data) : NULL)) < 0) + HGOTO_ERROR(H5E_LINK, H5E_CANTGET, FAIL, "can't set property value for target id") + if(H5P_set(plist, H5VL_PROP_LINK_TARGET_LOC_PARAMS, &loc_params1) < 0) + HGOTO_ERROR(H5E_LINK, H5E_CANTGET, FAIL, "can't set property value for target name") /* Create the link */ - if(H5L_create_hard(cur_loc_p, cur_name, new_loc_p, new_name, lcpl_id) < 0) + if(H5VL_link_create(H5VL_LINK_CREATE_HARD, (vol_obj2 ? (vol_obj2->data) : NULL), loc_params2, + (vol_obj1 != NULL ? vol_obj1->driver->cls : vol_obj2->driver->cls), + lcpl_id, lapl_id, H5P_DATASET_XFER_DEFAULT, H5_REQUEST_NULL) < 0) HGOTO_ERROR(H5E_LINK, H5E_CANTCREATE, FAIL, "unable to create hard link") done: @@ -530,7 +644,9 @@ 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; + H5VL_object_t *vol_obj = NULL; /* object token of loc_id */ + H5VL_loc_params_t loc_params; + H5P_genplist_t *plist; /* Property list pointer */ herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_API(FAIL) @@ -538,19 +654,43 @@ 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") + /* Check the group access property list */ + if(H5P_DEFAULT == lcpl_id) + lcpl_id = H5P_LINK_CREATE_DEFAULT; + /* Verify access property list and set up collective metadata if appropriate */ if(H5CX_set_apl(&lapl_id, H5P_CLS_LACC, link_loc_id, TRUE) < 0) HGOTO_ERROR(H5E_LINK, H5E_CANTSET, FAIL, "can't set access property list info") + loc_params.type = H5VL_OBJECT_BY_NAME; + loc_params.loc_data.loc_by_name.name = link_name; + loc_params.loc_data.loc_by_name.lapl_id = lapl_id; + loc_params.obj_type = H5I_get_type(link_loc_id); + + /* get the location object */ + if(NULL == (vol_obj = (H5VL_object_t *)H5I_object(link_loc_id))) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "invalid location identifier") + + /* 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, H5VL_PROP_LINK_TYPE, &link_type) < 0) + HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, FAIL, "can't get property value from plist") + if(H5P_set(plist, H5VL_PROP_LINK_UDATA, &udata) < 0) + HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, FAIL, "can't get property value from plist") + if(H5P_set(plist, H5VL_PROP_LINK_UDATA_SIZE, &udata_size) < 0) + HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, FAIL, "can't get property value from plist") + /* Create external link */ - if(H5L__create_ud(&link_loc, link_name, udata, udata_size, link_type, lcpl_id) < 0) + if(H5VL_link_create(H5VL_LINK_CREATE_UD, vol_obj->data, loc_params, vol_obj->driver->cls, + lcpl_id, lapl_id, H5P_DATASET_XFER_DEFAULT, H5_REQUEST_NULL) < 0) HGOTO_ERROR(H5E_LINK, H5E_CANTINIT, FAIL, "unable to create link") done: @@ -578,15 +718,14 @@ done: herr_t H5Ldelete(hid_t loc_id, const char *name, hid_t lapl_id) { - H5G_loc_t loc; /* Group's location */ + H5VL_object_t *vol_obj = NULL; /* Object token of loc_id */ + H5VL_loc_params_t loc_params; herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_API(FAIL) H5TRACE3("e", "i*si", loc_id, name, lapl_id); /* Check arguments */ - if(H5G_loc(loc_id, &loc) < 0) - HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a location") if(!name || !*name) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "no name") @@ -594,8 +733,19 @@ H5Ldelete(hid_t loc_id, const char *name, hid_t lapl_id) if(H5CX_set_apl(&lapl_id, H5P_CLS_LACC, loc_id, TRUE) < 0) HGOTO_ERROR(H5E_LINK, H5E_CANTSET, FAIL, "can't set access property list info") + /* Fill in the location struct fields */ + loc_params.type = H5VL_OBJECT_BY_NAME; + loc_params.obj_type = H5I_get_type(loc_id); + loc_params.loc_data.loc_by_name.name = name; + loc_params.loc_data.loc_by_name.lapl_id = lapl_id; + + /* get the location object */ + if(NULL == (vol_obj = (H5VL_object_t *)H5I_object(loc_id))) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "invalid location identifier") + /* Unlink */ - if(H5L_delete(&loc, name) < 0) + if(H5VL_link_specific(vol_obj->data, loc_params, vol_obj->driver->cls, H5VL_LINK_DELETE, + H5P_DATASET_XFER_DEFAULT, H5_REQUEST_NULL) < 0) HGOTO_ERROR(H5E_LINK, H5E_CANTDELETE, FAIL, "unable to delete link") done: @@ -626,15 +776,14 @@ herr_t H5Ldelete_by_idx(hid_t loc_id, const char *group_name, H5_index_t idx_type, H5_iter_order_t order, hsize_t n, hid_t lapl_id) { - H5G_loc_t loc; /* Group's location */ + H5VL_object_t *vol_obj = NULL; /* object token of loc_id */ + H5VL_loc_params_t loc_params; herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_API(FAIL) H5TRACE6("e", "i*sIiIohi", loc_id, group_name, idx_type, order, n, lapl_id); /* Check arguments */ - if(H5G_loc(loc_id, &loc) < 0) - HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a location") if(!group_name || !*group_name) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "no name specified") if(idx_type <= H5_INDEX_UNKNOWN || idx_type >= H5_INDEX_N) @@ -646,8 +795,21 @@ H5Ldelete_by_idx(hid_t loc_id, const char *group_name, H5_index_t idx_type, if(H5CX_set_apl(&lapl_id, H5P_CLS_LACC, loc_id, TRUE) < 0) HGOTO_ERROR(H5E_LINK, H5E_CANTSET, FAIL, "can't set access property list info") + loc_params.type = H5VL_OBJECT_BY_IDX; + loc_params.loc_data.loc_by_idx.name = group_name; + loc_params.loc_data.loc_by_idx.idx_type = idx_type; + loc_params.loc_data.loc_by_idx.order = order; + loc_params.loc_data.loc_by_idx.n = n; + loc_params.loc_data.loc_by_idx.lapl_id = lapl_id; + loc_params.obj_type = H5I_get_type(loc_id); + + /* Get the location object */ + if(NULL == (vol_obj = (H5VL_object_t *)H5I_object(loc_id))) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "invalid location identifier") + /* Delete the link */ - if(H5L_delete_by_idx(&loc, group_name, idx_type, order, n) < 0) + if(H5VL_link_specific(vol_obj->data, loc_params, vol_obj->driver->cls, H5VL_LINK_DELETE, + H5P_DATASET_XFER_DEFAULT, H5_REQUEST_NULL) < 0) HGOTO_ERROR(H5E_LINK, H5E_CANTDELETE, FAIL, "unable to delete link") done: @@ -678,15 +840,14 @@ herr_t H5Lget_val(hid_t loc_id, const char *name, void *buf/*out*/, size_t size, hid_t lapl_id) { - H5G_loc_t loc; /* Group location for location to query */ + H5VL_object_t *vol_obj = NULL; /* object token of loc_id */ + H5VL_loc_params_t loc_params; herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_API(FAIL) H5TRACE5("e", "i*sxzi", loc_id, name, buf, size, lapl_id); /* Check arguments */ - if(H5G_loc(loc_id, &loc)) - HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a location") if(!name || !*name) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "no name specified") @@ -694,8 +855,18 @@ H5Lget_val(hid_t loc_id, const char *name, void *buf/*out*/, size_t size, if(H5CX_set_apl(&lapl_id, H5P_CLS_LACC, loc_id, FALSE) < 0) HGOTO_ERROR(H5E_LINK, H5E_CANTSET, FAIL, "can't set access property list info") + loc_params.type = H5VL_OBJECT_BY_NAME; + loc_params.obj_type = H5I_get_type(loc_id); + loc_params.loc_data.loc_by_name.name = name; + loc_params.loc_data.loc_by_name.lapl_id = lapl_id; + + /* Get the location object */ + if(NULL == (vol_obj = (H5VL_object_t *)H5I_object(loc_id))) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "invalid location identifier") + /* Get the link value */ - if(H5L_get_val(&loc, name, buf, size) < 0) + if(H5VL_link_get(vol_obj->data, loc_params, vol_obj->driver->cls, H5VL_LINK_GET_VAL, + H5P_DATASET_XFER_DEFAULT, H5_REQUEST_NULL, buf, size) < 0) HGOTO_ERROR(H5E_LINK, H5E_CANTGET, FAIL, "unable to get link value for '%s'", name) done: @@ -726,7 +897,8 @@ H5Lget_val_by_idx(hid_t loc_id, const char *group_name, H5_index_t idx_type, H5_iter_order_t order, hsize_t n, void *buf/*out*/, size_t size, hid_t lapl_id) { - H5G_loc_t loc; /* Group location for location to query */ + H5VL_object_t *vol_obj = NULL; /* object token of loc_id */ + H5VL_loc_params_t loc_params; herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_API(FAIL) @@ -734,8 +906,6 @@ H5Lget_val_by_idx(hid_t loc_id, const char *group_name, H5_index_t idx_type, lapl_id); /* Check arguments */ - if(H5G_loc(loc_id, &loc)) - HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a location") if(!group_name || !*group_name) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "no name specified") if(idx_type <= H5_INDEX_UNKNOWN || idx_type >= H5_INDEX_N) @@ -747,8 +917,21 @@ H5Lget_val_by_idx(hid_t loc_id, const char *group_name, H5_index_t idx_type, if(H5CX_set_apl(&lapl_id, H5P_CLS_LACC, loc_id, FALSE) < 0) HGOTO_ERROR(H5E_LINK, H5E_CANTSET, FAIL, "can't set access property list info") + loc_params.type = H5VL_OBJECT_BY_IDX; + loc_params.loc_data.loc_by_idx.name = group_name; + loc_params.loc_data.loc_by_idx.idx_type = idx_type; + loc_params.loc_data.loc_by_idx.order = order; + loc_params.loc_data.loc_by_idx.n = n; + loc_params.loc_data.loc_by_idx.lapl_id = lapl_id; + loc_params.obj_type = H5I_get_type(loc_id); + + /* get the location object */ + if(NULL == (vol_obj = (H5VL_object_t *)H5I_object(loc_id))) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "invalid location identifier") + /* Get the link value */ - if(H5L_get_val_by_idx(&loc, group_name, idx_type, order, n, buf, size) < 0) + if(H5VL_link_get(vol_obj->data, loc_params, vol_obj->driver->cls, H5VL_LINK_GET_VAL, + H5P_DATASET_XFER_DEFAULT, H5_REQUEST_NULL, buf, size) < 0) HGOTO_ERROR(H5E_LINK, H5E_CANTGET, FAIL, "unable to get link value") done: @@ -771,15 +954,14 @@ done: htri_t H5Lexists(hid_t loc_id, const char *name, hid_t lapl_id) { - H5G_loc_t loc; + H5VL_object_t *vol_obj = NULL; /* object token of loc_id */ + H5VL_loc_params_t loc_params; htri_t ret_value = FAIL; /* Return value */ FUNC_ENTER_API(FAIL) H5TRACE3("t", "i*si", loc_id, name, lapl_id); /* Check arguments */ - if(H5G_loc(loc_id, &loc)) - HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a location") if(!name) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "name parameter cannot be NULL") if(!*name) @@ -789,8 +971,19 @@ H5Lexists(hid_t loc_id, const char *name, hid_t lapl_id) if(H5CX_set_apl(&lapl_id, H5P_CLS_LACC, loc_id, FALSE) < 0) HGOTO_ERROR(H5E_LINK, H5E_CANTSET, FAIL, "can't set access property list info") + /* Set location struct fields */ + loc_params.type = H5VL_OBJECT_BY_NAME; + loc_params.obj_type = H5I_get_type(loc_id); + loc_params.loc_data.loc_by_name.name = name; + loc_params.loc_data.loc_by_name.lapl_id = lapl_id; + + /* Get the location object */ + if(NULL == (vol_obj = (H5VL_object_t *)H5I_object(loc_id))) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "invalid location identifier") + /* Check for the existence of the link */ - if((ret_value = H5L_exists(&loc, name)) < 0) + if(H5VL_link_specific(vol_obj->data, loc_params, vol_obj->driver->cls, H5VL_LINK_EXISTS, + H5P_DATASET_XFER_DEFAULT, H5_REQUEST_NULL, &ret_value) < 0) HGOTO_ERROR(H5E_LINK, H5E_CANTGET, FAIL, "unable to get link info") done: @@ -816,15 +1009,14 @@ herr_t H5Lget_info(hid_t loc_id, const char *name, H5L_info_t *linfo /*out*/, hid_t lapl_id) { - H5G_loc_t loc; + H5VL_object_t *vol_obj = NULL; /* object token of loc_id */ + H5VL_loc_params_t loc_params; herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_API(FAIL) H5TRACE4("e", "i*sxi", loc_id, name, linfo, lapl_id); /* Check arguments */ - if(H5G_loc(loc_id, &loc)) - HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a location") if(!name || !*name) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "no name specified") @@ -832,8 +1024,18 @@ H5Lget_info(hid_t loc_id, const char *name, H5L_info_t *linfo /*out*/, if(H5CX_set_apl(&lapl_id, H5P_CLS_LACC, loc_id, TRUE) < 0) HGOTO_ERROR(H5E_LINK, H5E_CANTSET, FAIL, "can't set access property list info") + loc_params.type = H5VL_OBJECT_BY_NAME; + loc_params.obj_type = H5I_get_type(loc_id); + loc_params.loc_data.loc_by_name.name = name; + loc_params.loc_data.loc_by_name.lapl_id = lapl_id; + + /* get the location object */ + if(NULL == (vol_obj = (H5VL_object_t *)H5I_object(loc_id))) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "invalid location identifier") + /* Get the link information */ - if(H5L_get_info(&loc, name, linfo) < 0) + if(H5VL_link_get(vol_obj->data, loc_params, vol_obj->driver->cls, H5VL_LINK_GET_INFO, + H5P_DATASET_XFER_DEFAULT, H5_REQUEST_NULL, linfo) < 0) HGOTO_ERROR(H5E_LINK, H5E_CANTGET, FAIL, "unable to get link info") done: @@ -860,7 +1062,8 @@ H5Lget_info_by_idx(hid_t loc_id, const char *group_name, H5_index_t idx_type, H5_iter_order_t order, hsize_t n, H5L_info_t *linfo /*out*/, hid_t lapl_id) { - H5G_loc_t loc; /* Group location for group to query */ + H5VL_object_t *vol_obj = NULL; /* object token of loc_id */ + H5VL_loc_params_t loc_params; herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_API(FAIL) @@ -868,8 +1071,6 @@ H5Lget_info_by_idx(hid_t loc_id, const char *group_name, lapl_id); /* Check arguments */ - if(H5G_loc(loc_id, &loc)) - HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a location") if(!group_name || !*group_name) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "no name specified") if(idx_type <= H5_INDEX_UNKNOWN || idx_type >= H5_INDEX_N) @@ -881,8 +1082,21 @@ H5Lget_info_by_idx(hid_t loc_id, const char *group_name, if(H5CX_set_apl(&lapl_id, H5P_CLS_LACC, loc_id, FALSE) < 0) HGOTO_ERROR(H5E_LINK, H5E_CANTSET, FAIL, "can't set access property list info") + loc_params.type = H5VL_OBJECT_BY_IDX; + loc_params.loc_data.loc_by_idx.name = group_name; + loc_params.loc_data.loc_by_idx.idx_type = idx_type; + loc_params.loc_data.loc_by_idx.order = order; + loc_params.loc_data.loc_by_idx.n = n; + loc_params.loc_data.loc_by_idx.lapl_id = lapl_id; + loc_params.obj_type = H5I_get_type(loc_id); + + /* get the location object */ + if(NULL == (vol_obj = (H5VL_object_t *)H5I_object(loc_id))) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "invalid location identifier") + /* Get the link information */ - if(H5L_get_info_by_idx(&loc, group_name, idx_type, order, n, linfo) < 0) + if(H5VL_link_get(vol_obj->data, loc_params, vol_obj->driver->cls, H5VL_LINK_GET_INFO, + H5P_DATASET_XFER_DEFAULT, H5_REQUEST_NULL, linfo) < 0) HGOTO_ERROR(H5E_LINK, H5E_CANTGET, FAIL, "unable to get link info") done: @@ -1044,7 +1258,8 @@ H5Lget_name_by_idx(hid_t loc_id, const char *group_name, H5_index_t idx_type, H5_iter_order_t order, hsize_t n, char *name /*out*/, size_t size, hid_t lapl_id) { - H5G_loc_t loc; /* Location of group */ + H5VL_object_t *vol_obj = NULL; /* object token of loc_id */ + H5VL_loc_params_t loc_params; ssize_t ret_value = -1; /* Return value */ FUNC_ENTER_API((-1)) @@ -1052,8 +1267,6 @@ H5Lget_name_by_idx(hid_t loc_id, const char *group_name, lapl_id); /* Check arguments */ - if(H5G_loc(loc_id, &loc)) - HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, (-1), "not a location") if(!group_name || !*group_name) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, (-1), "no name specified") if(idx_type <= H5_INDEX_UNKNOWN || idx_type >= H5_INDEX_N) @@ -1065,8 +1278,22 @@ H5Lget_name_by_idx(hid_t loc_id, const char *group_name, if(H5CX_set_apl(&lapl_id, H5P_CLS_LACC, loc_id, TRUE) < 0) HGOTO_ERROR(H5E_LINK, H5E_CANTSET, (-1), "can't set access property list info") + /* Fill in location struct fields */ + loc_params.type = H5VL_OBJECT_BY_IDX; + loc_params.loc_data.loc_by_idx.name = group_name; + loc_params.loc_data.loc_by_idx.idx_type = idx_type; + loc_params.loc_data.loc_by_idx.order = order; + loc_params.loc_data.loc_by_idx.n = n; + loc_params.loc_data.loc_by_idx.lapl_id = lapl_id; + loc_params.obj_type = H5I_get_type(loc_id); + + /* Get the location object */ + if(NULL == (vol_obj = (H5VL_object_t *)H5I_object(loc_id))) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, (-1), "invalid location identifier") + /* Get the link information */ - if((ret_value = H5L_get_name_by_idx(&loc, group_name, idx_type, order, n, name, size)) < 0) + if(H5VL_link_get(vol_obj->data, loc_params, vol_obj->driver->cls, H5VL_LINK_GET_NAME, + H5P_DATASET_XFER_DEFAULT, H5_REQUEST_NULL, name, size, &ret_value) < 0) HGOTO_ERROR(H5E_LINK, H5E_CANTGET, (-1), "unable to get link name") done: @@ -1096,7 +1323,8 @@ herr_t H5Literate(hid_t group_id, H5_index_t idx_type, H5_iter_order_t order, hsize_t *idx_p, H5L_iterate_t op, void *op_data) { - H5G_loc_t loc; + H5VL_object_t *vol_obj = NULL; /* Object token of loc_id */ + H5VL_loc_params_t loc_params; H5I_type_t id_type; /* Type of ID */ herr_t ret_value; /* Return value */ @@ -1104,8 +1332,6 @@ H5Literate(hid_t group_id, H5_index_t idx_type, H5_iter_order_t order, H5TRACE6("e", "iIiIo*hx*x", group_id, idx_type, order, idx_p, op, op_data); /* Check arguments */ - if(H5G_loc(group_id, &loc) < 0) - HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a location") id_type = H5I_get_type(group_id); if (!(H5I_GROUP == id_type || H5I_FILE == id_type)) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "invalid argument") @@ -1116,8 +1342,18 @@ H5Literate(hid_t group_id, H5_index_t idx_type, H5_iter_order_t order, if (!op) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "no operator specified") + /* Get the location object */ + if (NULL == (vol_obj = (H5VL_object_t *)H5I_object(group_id))) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "invalid location identifier") + + /* Set location struct fields */ + loc_params.type = H5VL_OBJECT_BY_SELF; + loc_params.obj_type = H5I_get_type(group_id); + /* Iterate over the links */ - if((ret_value = H5L_iterate(&loc, ".", idx_type, order, idx_p, op, op_data)) < 0) + if((ret_value = H5VL_link_specific(vol_obj->data, loc_params, vol_obj->driver->cls, H5VL_LINK_ITER, + H5P_DATASET_XFER_DEFAULT, H5_REQUEST_NULL, + FALSE, idx_type, order, idx_p, op, op_data)) < 0) HGOTO_ERROR(H5E_LINK, H5E_BADITER, FAIL, "link iteration failed") done: @@ -1152,7 +1388,8 @@ H5Literate_by_name(hid_t loc_id, const char *group_name, H5_index_t idx_type, H5_iter_order_t order, hsize_t *idx_p, H5L_iterate_t op, void *op_data, hid_t lapl_id) { - H5G_loc_t loc; + H5VL_object_t *vol_obj = NULL; /* Object token of loc_id */ + H5VL_loc_params_t loc_params; herr_t ret_value; /* Return value */ FUNC_ENTER_API(FAIL) @@ -1160,8 +1397,6 @@ H5Literate_by_name(hid_t loc_id, const char *group_name, op_data, lapl_id); /* Check arguments */ - if(H5G_loc(loc_id, &loc) < 0) - HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a location") if(!group_name) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "group_name parameter cannot be NULL") if(!*group_name) @@ -1177,8 +1412,19 @@ H5Literate_by_name(hid_t loc_id, const char *group_name, if(H5CX_set_apl(&lapl_id, H5P_CLS_LACC, loc_id, FALSE) < 0) HGOTO_ERROR(H5E_LINK, H5E_CANTSET, FAIL, "can't set access property list info") + /* Get the location object */ + if(NULL == (vol_obj = (H5VL_object_t *)H5I_object(loc_id))) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "invalid location identifier") + + /* Set location struct fields */ + loc_params.type = H5VL_OBJECT_BY_NAME; + loc_params.obj_type = H5I_get_type(loc_id); + loc_params.loc_data.loc_by_name.name = group_name; + loc_params.loc_data.loc_by_name.lapl_id = lapl_id; + /* Iterate over the links */ - if((ret_value = H5L_iterate(&loc, group_name, idx_type, order, idx_p, op, op_data)) < 0) + if((ret_value = H5VL_link_specific(vol_obj->data, loc_params, vol_obj->driver->cls, H5VL_LINK_ITER, + H5P_DATASET_XFER_DEFAULT, H5_REQUEST_NULL, FALSE, idx_type, order, idx_p, op, op_data)) < 0) HGOTO_ERROR(H5E_LINK, H5E_BADITER, FAIL, "link iteration failed") done: @@ -1218,7 +1464,8 @@ herr_t H5Lvisit(hid_t group_id, H5_index_t idx_type, H5_iter_order_t order, H5L_iterate_t op, void *op_data) { - H5G_loc_t loc; + H5VL_object_t *vol_obj = NULL; /* Object token of loc_id */ + H5VL_loc_params_t loc_params; H5I_type_t id_type; /* Type of ID */ herr_t ret_value; /* Return value */ @@ -1226,8 +1473,6 @@ H5Lvisit(hid_t group_id, H5_index_t idx_type, H5_iter_order_t order, H5TRACE5("e", "iIiIox*x", group_id, idx_type, order, op, op_data); /* Check args */ - if(H5G_loc(group_id, &loc) < 0) - HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a location") id_type = H5I_get_type(group_id); if(!(H5I_GROUP == id_type || H5I_FILE == id_type)) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "invalid argument") @@ -1238,8 +1483,18 @@ H5Lvisit(hid_t group_id, H5_index_t idx_type, H5_iter_order_t order, if(!op) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "no callback operator specified") + /* Set location struct fields */ + loc_params.type = H5VL_OBJECT_BY_SELF; + loc_params.obj_type = H5I_get_type(group_id); + + /* Get the location object */ + if(NULL == (vol_obj = (H5VL_object_t *)H5I_object(group_id))) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "invalid location identifier") + /* Iterate over the links */ - if((ret_value = H5G_visit(&loc, ".", idx_type, order, op, op_data)) < 0) + if((ret_value = H5VL_link_specific(vol_obj->data, loc_params, vol_obj->driver->cls, H5VL_LINK_ITER, + H5P_DATASET_XFER_DEFAULT, H5_REQUEST_NULL, + TRUE, idx_type, order, NULL, op, op_data)) < 0) HGOTO_ERROR(H5E_LINK, H5E_BADITER, FAIL, "link visitation failed") done: @@ -1279,7 +1534,8 @@ herr_t H5Lvisit_by_name(hid_t loc_id, const char *group_name, H5_index_t idx_type, H5_iter_order_t order, H5L_iterate_t op, void *op_data, hid_t lapl_id) { - H5G_loc_t loc; + H5VL_object_t *vol_obj = NULL; /* Object token of loc_id */ + H5VL_loc_params_t loc_params; herr_t ret_value; /* Return value */ FUNC_ENTER_API(FAIL) @@ -1287,8 +1543,6 @@ H5Lvisit_by_name(hid_t loc_id, const char *group_name, H5_index_t idx_type, lapl_id); /* Check args */ - if(H5G_loc(loc_id, &loc) < 0) - HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a location") if(!group_name) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "group_name parameter cannot be NULL") if(!*group_name) @@ -1304,8 +1558,20 @@ H5Lvisit_by_name(hid_t loc_id, const char *group_name, H5_index_t idx_type, if(H5CX_set_apl(&lapl_id, H5P_CLS_LACC, loc_id, FALSE) < 0) HGOTO_ERROR(H5E_LINK, H5E_CANTSET, FAIL, "can't set access property list info") + /* get the location object */ + if(NULL == (vol_obj = (H5VL_object_t *)H5I_object(loc_id))) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "invalid location identifier") + + /* Set location struct fields */ + loc_params.type = H5VL_OBJECT_BY_NAME; + loc_params.obj_type = H5I_get_type(loc_id); + loc_params.loc_data.loc_by_name.name = group_name; + loc_params.loc_data.loc_by_name.lapl_id = lapl_id; + /* Visit the links */ - if((ret_value = H5G_visit(&loc, group_name, idx_type, order, op, op_data)) < 0) + if((ret_value = H5VL_link_specific(vol_obj->data, loc_params, vol_obj->driver->cls, H5VL_LINK_ITER, + H5P_DATASET_XFER_DEFAULT, H5_REQUEST_NULL, + TRUE, idx_type, order, NULL, op, op_data)) < 0) HGOTO_ERROR(H5E_LINK, H5E_BADITER, FAIL, "link visitation failed") done: @@ -1683,7 +1949,7 @@ H5L__link_cb(H5G_loc_t *grp_loc/*in*/, const char *name, const H5O_link_t H5_ATT /* Set up location for user-defined callback */ if(NULL == (grp = H5G_open(&temp_loc))) HGOTO_ERROR(H5E_LINK, H5E_CANTOPENOBJ, FAIL, "unable to open group") - if((grp_id = H5I_register(H5I_GROUP, grp, TRUE)) < 0) + if((grp_id = H5VL_native_register(H5I_GROUP, grp, TRUE)) < 0) HGOTO_ERROR(H5E_LINK, H5E_CANTREGISTER, FAIL, "unable to register ID for group") /* Make callback */ @@ -2468,7 +2734,7 @@ H5L__move_dest_cb(H5G_loc_t *grp_loc/*in*/, const char *name, /* Set up location for user-defined callback */ if(NULL == (grp = H5G_open(&temp_loc))) HGOTO_ERROR(H5E_LINK, H5E_CANTOPENOBJ, FAIL, "unable to open group") - if((grp_id = H5I_register(H5I_GROUP, grp, TRUE)) < 0) + if((grp_id = H5VL_native_register(H5I_GROUP, grp, TRUE)) < 0) HGOTO_ERROR(H5E_LINK, H5E_CANTREGISTER, FAIL, "unable to register group ID") if(udata->copy) { diff --git a/src/H5Lexternal.c b/src/H5Lexternal.c index 1cab17d..d9cc7a3 100644 --- a/src/H5Lexternal.c +++ b/src/H5Lexternal.c @@ -33,6 +33,8 @@ #include "H5MMprivate.h" /* Memory management */ #include "H5Opublic.h" /* File objects */ #include "H5Pprivate.h" /* Property lists */ +#include "H5VLprivate.h" /* Virtual Object Layer */ +#include "H5VLnative.h" /* Native VOL Driver */ /****************/ @@ -125,7 +127,9 @@ H5L__extern_traverse(const char H5_ATTR_UNUSED *link_name, hid_t cur_group, unsigned intent; /* File access permissions */ H5L_elink_cb_t cb_info; /* Callback info struct */ hid_t fapl_id = -1; /* File access property list for external link's file */ - hid_t ext_obj = -1; /* ID for external link's object */ + void *ext_obj = NULL; /* External link's object */ + hid_t ext_obj_id = H5I_INVALID_HID; /* ID for external link's object */ + H5I_type_t opened_type; /* ID type of external link's object */ char *parent_group_name = NULL;/* Temporary pointer to group name */ char local_group_name[H5L_EXT_TRAVERSE_BUF_SIZE]; /* Local buffer to hold group name */ H5P_genplist_t *fa_plist; /* File access property list pointer */ @@ -235,13 +239,18 @@ H5L__extern_traverse(const char H5_ATTR_UNUSED *link_name, hid_t cur_group, HGOTO_ERROR(H5E_LINK, H5E_BADVALUE, H5I_INVALID_HID, "unable to create location for file") /* Open the object referenced in the external file */ - if((ext_obj = H5O_open_name(&root_loc, obj_name, FALSE)) < 0) + if(NULL == (ext_obj = H5O_open_name(&root_loc, obj_name, &opened_type))) HGOTO_ERROR(H5E_LINK, H5E_CANTOPENOBJ, H5I_INVALID_HID, "unable to open object") + /* Get an ID for the external link's object */ + if((ext_obj_id = H5VL_native_register(opened_type, ext_obj, TRUE)) < 0) + HGOTO_ERROR(H5E_ATOM, H5E_CANTREGISTER, H5I_INVALID_HID, "unable to register external link object") + /* Set return value */ - ret_value = ext_obj; + ret_value = ext_obj_id; done: +/* XXX (VOL MERGE): Probably also want to consider closing ext_obj here on failures */ /* Release resources */ if(fapl_id > 0 && H5I_dec_ref(fapl_id) < 0) HDONE_ERROR(H5E_ATOM, H5E_CANTRELEASE, H5I_INVALID_HID, "unable to close atom for file access property list") @@ -251,7 +260,7 @@ done: parent_group_name = (char *)H5MM_xfree(parent_group_name); if(ret_value < 0) { /* Close object if it's open and something failed */ - if(ext_obj >= 0 && H5I_dec_ref(ext_obj) < 0) + if(ext_obj_id >= 0 && H5I_dec_ref(ext_obj_id) < 0) HDONE_ERROR(H5E_ATOM, H5E_CANTRELEASE, H5I_INVALID_HID, "unable to close atom for external object") } /* end if */ @@ -333,13 +342,16 @@ herr_t H5Lcreate_external(const char *file_name, const char *obj_name, hid_t link_loc_id, const char *link_name, hid_t lcpl_id, hid_t lapl_id) { - H5G_loc_t link_loc; /* Group location to create link */ - char *norm_obj_name = NULL; /* Pointer to normalized current name */ + H5VL_object_t *vol_obj = NULL; /* Object token of loc_id */ + H5VL_loc_params_t loc_params; + char *norm_obj_name = NULL; /* Pointer to normalized current name */ void *ext_link_buf = NULL; /* Buffer to contain external link */ size_t buf_size; /* Size of buffer to hold external link */ size_t file_name_len; /* Length of file name string */ size_t norm_obj_name_len; /* Length of normalized object name string */ 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) @@ -351,11 +363,13 @@ H5Lcreate_external(const char *file_name, const char *obj_name, HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "no file name specified") if(!obj_name || !*obj_name) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "no object name specified") - if(H5G_loc(link_loc_id, &link_loc) < 0) - HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a location") if(!link_name || !*link_name) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "no link name specified") + /* 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_LINK, H5E_BADVALUE, FAIL, "can't normalize object name") @@ -378,8 +392,30 @@ H5Lcreate_external(const char *file_name, const char *obj_name, if(H5CX_set_apl(&lapl_id, H5P_CLS_LACC, link_loc_id, TRUE) < 0) HGOTO_ERROR(H5E_LINK, H5E_CANTSET, FAIL, "can't set access property list info") + loc_params.type = H5VL_OBJECT_BY_NAME; + loc_params.loc_data.loc_by_name.name = link_name; + loc_params.loc_data.loc_by_name.lapl_id = lapl_id; + loc_params.obj_type = H5I_get_type(link_loc_id); + + /* get the location object */ + if(NULL == (vol_obj = (H5VL_object_t *)H5I_object(link_loc_id))) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "invalid object identifier") + + /* 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, H5VL_PROP_LINK_TYPE, &link_type) < 0) + HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, FAIL, "can't get property value from plist") + if(H5P_set(plist, H5VL_PROP_LINK_UDATA, &ext_link_buf) < 0) + HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, FAIL, "can't get property value from plist") + if(H5P_set(plist, H5VL_PROP_LINK_UDATA_SIZE, &buf_size) < 0) + HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, FAIL, "can't get property value from plist") + /* Create an external link */ - if(H5L__create_ud(&link_loc, link_name, ext_link_buf, buf_size, H5L_TYPE_EXTERNAL, lcpl_id) < 0) + if((ret_value = H5VL_link_create(H5VL_LINK_CREATE_UD, vol_obj->data, loc_params, vol_obj->driver->cls, + lcpl_id, lapl_id, H5P_DATASET_XFER_DEFAULT, H5_REQUEST_NULL)) < 0) HGOTO_ERROR(H5E_LINK, H5E_CANTINIT, FAIL, "unable to create external link") done: @@ -100,15 +100,16 @@ hid_t H5Oopen(hid_t loc_id, const char *name, hid_t lapl_id) { - H5G_loc_t loc; /* Location of group */ + H5VL_object_t *vol_obj = NULL; /* Object token of loc_id */ + H5I_type_t opened_type; + void *opened_obj = NULL; + H5VL_loc_params_t loc_params; hid_t ret_value = H5I_INVALID_HID; FUNC_ENTER_API(H5I_INVALID_HID) H5TRACE3("i", "i*si", loc_id, name, lapl_id); /* Check args */ - if(H5G_loc(loc_id, &loc) < 0) - HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, H5I_INVALID_HID, "not a location") if(!name) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, H5I_INVALID_HID, "name parameter cannot be NULL") if(!*name) @@ -118,10 +119,24 @@ H5Oopen(hid_t loc_id, const char *name, hid_t lapl_id) if(H5CX_set_apl(&lapl_id, H5P_CLS_LACC, loc_id, FALSE) < 0) HGOTO_ERROR(H5E_OHDR, H5E_CANTSET, H5I_INVALID_HID, "can't set access property list info") + /* Get the location object */ + if(NULL == (vol_obj = (H5VL_object_t *)H5I_object(loc_id))) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, H5I_INVALID_HID, "invalid location identifier") + + /* Set location struct fields */ + loc_params.type = H5VL_OBJECT_BY_NAME; + loc_params.loc_data.loc_by_name.name = name; + loc_params.loc_data.loc_by_name.lapl_id = lapl_id; + loc_params.obj_type = H5I_get_type(loc_id); + /* Open the object */ - if((ret_value = H5O_open_name(&loc, name, TRUE)) < 0) + if(NULL == (opened_obj = H5VL_object_open(vol_obj->data, loc_params, vol_obj->driver->cls, + &opened_type, H5P_DATASET_XFER_DEFAULT, H5_REQUEST_NULL))) HGOTO_ERROR(H5E_OHDR, H5E_CANTOPENOBJ, H5I_INVALID_HID, "unable to open object") + /* Get an atom for the object */ + if((ret_value = H5VL_register_id(opened_type, opened_obj, vol_obj->driver, TRUE)) < 0) + HGOTO_ERROR(H5E_ATOM, H5E_CANTREGISTER, H5I_INVALID_HID, "unable to atomize object handle") done: FUNC_LEAVE_API(ret_value) } /* end H5Oopen() */ @@ -154,15 +169,16 @@ hid_t H5Oopen_by_idx(hid_t loc_id, const char *group_name, H5_index_t idx_type, H5_iter_order_t order, hsize_t n, hid_t lapl_id) { - H5G_loc_t loc; /* Location of group */ + H5VL_object_t *vol_obj = NULL; /* object token of loc_id */ + H5I_type_t opened_type; + void *opened_obj = NULL; + H5VL_loc_params_t loc_params; hid_t ret_value = H5I_INVALID_HID; FUNC_ENTER_API(H5I_INVALID_HID) H5TRACE6("i", "i*sIiIohi", loc_id, group_name, idx_type, order, n, lapl_id); /* Check args */ - if(H5G_loc(loc_id, &loc) < 0) - HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, H5I_INVALID_HID, "not a location") if(!group_name || !*group_name) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, H5I_INVALID_HID, "no name specified") if(idx_type <= H5_INDEX_UNKNOWN || idx_type >= H5_INDEX_N) @@ -174,10 +190,26 @@ H5Oopen_by_idx(hid_t loc_id, const char *group_name, H5_index_t idx_type, if(H5CX_set_apl(&lapl_id, H5P_CLS_LACC, loc_id, FALSE) < 0) HGOTO_ERROR(H5E_OHDR, H5E_CANTSET, H5I_INVALID_HID, "can't set access property list info") + loc_params.type = H5VL_OBJECT_BY_IDX; + loc_params.loc_data.loc_by_idx.name = group_name; + loc_params.loc_data.loc_by_idx.idx_type = idx_type; + loc_params.loc_data.loc_by_idx.order = order; + loc_params.loc_data.loc_by_idx.n = n; + loc_params.loc_data.loc_by_idx.lapl_id = lapl_id; + loc_params.obj_type = H5I_get_type(loc_id); + + /* get the location object */ + if(NULL == (vol_obj = (H5VL_object_t *)H5I_object(loc_id))) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, H5I_INVALID_HID, "invalid location identifier") + /* Open the object */ - if((ret_value = H5O_open_by_idx(&loc, group_name, idx_type, order, n)) < 0) + if(NULL == (opened_obj = H5VL_object_open(vol_obj->data, loc_params, vol_obj->driver->cls, + &opened_type, H5P_DATASET_XFER_DEFAULT, H5_REQUEST_NULL))) HGOTO_ERROR(H5E_OHDR, H5E_CANTOPENOBJ, H5I_INVALID_HID, "unable to open object") + if((ret_value = H5VL_register_id(opened_type, opened_obj, vol_obj->driver, TRUE)) < 0) + HGOTO_ERROR(H5E_ATOM, H5E_CANTREGISTER, H5I_INVALID_HID, "unable to atomize object handle") + done: FUNC_LEAVE_API(ret_value) } /* end H5Oopen_by_idx() */ @@ -221,22 +253,32 @@ done: hid_t H5Oopen_by_addr(hid_t loc_id, haddr_t addr) { - H5G_loc_t loc; /* Location within file */ + H5VL_object_t *vol_obj = NULL; /* object token of loc_id */ + H5I_type_t opened_type; + void *opened_obj = NULL; + H5VL_loc_params_t loc_params; hid_t ret_value = H5I_INVALID_HID; /* Return value */ FUNC_ENTER_API(H5I_INVALID_HID) H5TRACE2("i", "ia", loc_id, addr); - /* Check args */ - if(H5G_loc(loc_id, &loc) < 0) - HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, H5I_INVALID_HID, "not a location") - if(!H5F_addr_defined(addr)) - HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, H5I_INVALID_HID, "no address supplied") + loc_params.type = H5VL_OBJECT_BY_ADDR; + loc_params.loc_data.loc_by_addr.addr = addr; + loc_params.obj_type = H5I_get_type(loc_id); + + /* Get the location object */ + if(NULL == (vol_obj = (H5VL_object_t *)H5I_object(loc_id))) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, H5I_INVALID_HID, "invalid location identifier") /* Open the object */ - if((ret_value = H5O_open_by_addr(&loc, addr)) < 0) + if(NULL == (opened_obj = H5VL_object_open(vol_obj->data, loc_params, vol_obj->driver->cls, &opened_type, + H5P_DATASET_XFER_DEFAULT, H5_REQUEST_NULL))) HGOTO_ERROR(H5E_OHDR, H5E_CANTOPENOBJ, H5I_INVALID_HID, "unable to open object") + /* Register the dataset ID */ + if((ret_value = H5VL_register_id(opened_type, opened_obj, vol_obj->driver, TRUE)) < 0) + HGOTO_ERROR(H5E_ATOM, H5E_CANTREGISTER, H5I_INVALID_HID, "unable to atomize object handle") + done: FUNC_LEAVE_API(ret_value) } /* end H5Oopen_by_addr() */ @@ -267,20 +309,19 @@ herr_t H5Olink(hid_t obj_id, hid_t new_loc_id, const char *new_name, hid_t lcpl_id, hid_t lapl_id) { - H5G_loc_t new_loc; /* Location of group to link from */ - H5G_loc_t obj_loc; /* Location of object to link to */ - herr_t ret_value = SUCCEED; /* Return value */ + H5VL_object_t *vol_obj1 = NULL; /* object token of obj_id */ + H5VL_object_t *vol_obj2 = NULL; /* object token of new_loc_id */ + H5VL_loc_params_t loc_params1; + H5VL_loc_params_t loc_params2; + H5P_genplist_t *plist; /* Property list pointer */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_API(FAIL) H5TRACE5("e", "ii*sii", obj_id, new_loc_id, new_name, lcpl_id, lapl_id); /* Check arguments */ - if(H5G_loc(obj_id, &obj_loc) < 0) - HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a location") if(new_loc_id == H5L_SAME_LOC) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "cannot use H5L_SAME_LOC when only one location is specified") - if(H5G_loc(new_loc_id, &new_loc) < 0) - HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a location") if(!new_name || !*new_name) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "no name specified") /* Avoid compiler warning on 32-bit machines */ @@ -291,12 +332,52 @@ H5Olink(hid_t obj_id, hid_t new_loc_id, const char *new_name, hid_t lcpl_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") + /* Check the group access property list */ + if(H5P_DEFAULT == lcpl_id) + lcpl_id = H5P_LINK_CREATE_DEFAULT; + /* Verify access property list and set up collective metadata if appropriate */ if(H5CX_set_apl(&lapl_id, H5P_CLS_LACC, obj_id, TRUE) < 0) HGOTO_ERROR(H5E_OHDR, H5E_CANTSET, FAIL, "can't set access property list info") - /* Link to the object */ - if(H5L_link(&new_loc, new_name, &obj_loc, lcpl_id) < 0) + loc_params1.type = H5VL_OBJECT_BY_SELF; + loc_params1.obj_type = H5I_get_type(obj_id); + + loc_params2.type = H5VL_OBJECT_BY_NAME; + loc_params2.obj_type = H5I_get_type(new_loc_id); + loc_params2.loc_data.loc_by_name.name = new_name; + loc_params2.loc_data.loc_by_name.lapl_id = lapl_id; + + if(H5L_SAME_LOC != obj_id) { + /* get the location object */ + if(NULL == (vol_obj1 = H5VL_get_object(obj_id))) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "invalid location identifier") + } + if(H5L_SAME_LOC != new_loc_id) { + /* get the location object */ + if(NULL == (vol_obj2 = H5VL_get_object(new_loc_id))) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "invalid location identifier") + } + /* Make sure that the VOL plugins are the same */ + if(vol_obj1 && vol_obj2) { + if (vol_obj1->driver->cls->value != vol_obj2->driver->cls->value) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "Objects are accessed through different VOL plugins and can't be linked") + } + + /* 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, H5VL_PROP_LINK_TARGET, &vol_obj1->data) < 0) + HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, FAIL, "can't set property value for target id") + if(H5P_set(plist, H5VL_PROP_LINK_TARGET_LOC_PARAMS, &loc_params1) < 0) + HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, FAIL, "can't set property value for target id") + + /* Create a link to the object */ + if(H5VL_link_create(H5VL_LINK_CREATE_HARD, vol_obj2->data, loc_params2, + (vol_obj1 != NULL ? vol_obj1->driver->cls : vol_obj2->driver->cls), + lcpl_id, lapl_id, H5P_DATASET_XFER_DEFAULT, H5_REQUEST_NULL) < 0) HGOTO_ERROR(H5E_OHDR, H5E_CANTCREATE, FAIL, "unable to create link") done: @@ -327,22 +408,27 @@ done: herr_t H5Oincr_refcount(hid_t object_id) { - H5O_loc_t *oloc; /* Object location */ - herr_t ret_value = SUCCEED; /* Return value */ + H5VL_object_t *vol_obj = NULL; /* object token of loc_id */ + H5VL_loc_params_t loc_params; + herr_t ret_value = SUCCEED; FUNC_ENTER_API(FAIL) H5TRACE1("e", "i", object_id); - /* Get the object's oloc so we can adjust its link count */ - if((oloc = H5O_get_loc(object_id)) == NULL) - HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "unable to get object location from ID") + loc_params.type = H5VL_OBJECT_BY_SELF; + loc_params.obj_type = H5I_get_type(object_id); + + /* Get the location object */ + if(NULL == (vol_obj = H5VL_get_object(object_id))) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "invalid location identifier") /* Set up collective metadata if appropriate */ if(H5CX_set_loc(object_id) < 0) HGOTO_ERROR(H5E_OHDR, H5E_CANTSET, FAIL, "can't set access property list info") /* Change the object's reference count */ - if(H5O_link(oloc, 1) < 0) + if(H5VL_object_specific(vol_obj->data, loc_params, vol_obj->driver->cls, H5VL_OBJECT_CHANGE_REF_COUNT, + H5P_DATASET_XFER_DEFAULT, H5_REQUEST_NULL, 1) < 0) HGOTO_ERROR(H5E_OHDR, H5E_LINKCOUNT, FAIL, "modifying object link count failed") done: @@ -373,22 +459,27 @@ done: herr_t H5Odecr_refcount(hid_t object_id) { - H5O_loc_t *oloc; /* Object location */ + H5VL_object_t *vol_obj = NULL; /* object token of loc_id */ + H5VL_loc_params_t loc_params; herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_API(FAIL) H5TRACE1("e", "i", object_id); - /* Get the object's oloc so we can adjust its link count */ - if((oloc = H5O_get_loc(object_id)) == NULL) - HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "unable to get object location from ID") + loc_params.type = H5VL_OBJECT_BY_SELF; + loc_params.obj_type = H5I_get_type(object_id); + + /* Get the location object */ + if(NULL == (vol_obj = H5VL_get_object(object_id))) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "invalid location identifier") /* Set up collective metadata if appropriate */ if(H5CX_set_loc(object_id) < 0) HGOTO_ERROR(H5E_OHDR, H5E_CANTSET, FAIL, "can't set access property list info") /* Change the object's reference count */ - if(H5O_link(oloc, -1) < 0) + if(H5VL_object_specific(vol_obj->data, loc_params, vol_obj->driver->cls, H5VL_OBJECT_CHANGE_REF_COUNT, + H5P_DATASET_XFER_DEFAULT, H5_REQUEST_NULL, -1) < 0) HGOTO_ERROR(H5E_OHDR, H5E_LINKCOUNT, FAIL, "modifying object link count failed") done: @@ -412,15 +503,14 @@ done: htri_t H5Oexists_by_name(hid_t loc_id, const char *name, hid_t lapl_id) { - H5G_loc_t loc; /* Location info */ + H5VL_object_t *vol_obj = NULL; /* Object token of loc_id */ + H5VL_loc_params_t loc_params; htri_t ret_value = FAIL; /* Return value */ FUNC_ENTER_API(FAIL) H5TRACE3("t", "i*si", loc_id, name, lapl_id); /* Check args */ - if(H5G_loc(loc_id, &loc) < 0) - HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a location") if(!name) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "name parameter cannot be NULL") if(!*name) @@ -430,8 +520,19 @@ H5Oexists_by_name(hid_t loc_id, const char *name, hid_t lapl_id) if(H5CX_set_apl(&lapl_id, H5P_CLS_LACC, loc_id, FALSE) < 0) HGOTO_ERROR(H5E_OHDR, H5E_CANTSET, FAIL, "can't set access property list info") + /* Get the location object */ + if(NULL == (vol_obj = H5VL_get_object(loc_id))) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "invalid location identifier") + + /* Set the location struct fields */ + loc_params.type = H5VL_OBJECT_BY_NAME; + loc_params.loc_data.loc_by_name.name = name; + loc_params.loc_data.loc_by_name.lapl_id = lapl_id; + loc_params.obj_type = H5I_get_type(loc_id); + /* Check if the object exists */ - if((ret_value = H5G_loc_exists(&loc, name)) < 0) + if(H5VL_object_specific(vol_obj->data, loc_params, vol_obj->driver->cls, H5VL_OBJECT_EXISTS, + H5P_DATASET_XFER_DEFAULT, H5_REQUEST_NULL, &ret_value) < 0) HGOTO_ERROR(H5E_OHDR, H5E_CANTGET, FAIL, "unable to determine if '%s' exists", name) done: @@ -456,22 +557,30 @@ done: herr_t H5Oget_info2(hid_t loc_id, H5O_info_t *oinfo, unsigned fields) { - H5G_loc_t loc; /* Location of group */ + H5VL_object_t *vol_obj = NULL; /* Object token of loc_id */ + H5VL_loc_params_t loc_params; herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_API(FAIL) H5TRACE3("e", "i*xIu", loc_id, oinfo, fields); /* Check args */ - if(H5G_loc(loc_id, &loc) < 0) - HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a location") if(!oinfo) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "oinfo parameter cannot be NULL") if(fields & ~H5O_INFO_ALL) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "invalid fields") + /* Set location struct fields */ + loc_params.type = H5VL_OBJECT_BY_SELF; + loc_params.obj_type = H5I_get_type(loc_id); + + /* Get the location object */ + if(NULL == (vol_obj = H5VL_get_object(loc_id))) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "invalid location identifier") + /* Retrieve the object's information */ - if(H5G_loc_info(&loc, ".", oinfo, fields) < 0) + if(H5VL_object_optional(vol_obj->data, vol_obj->driver->cls, H5P_DATASET_XFER_DEFAULT, + H5_REQUEST_NULL, H5VL_OBJECT_GET_INFO, loc_params, oinfo, fields) < 0) HGOTO_ERROR(H5E_OHDR, H5E_CANTGET, FAIL, "can't get info for object") done: @@ -497,15 +606,14 @@ herr_t H5Oget_info_by_name2(hid_t loc_id, const char *name, H5O_info_t *oinfo, unsigned fields, hid_t lapl_id) { - H5G_loc_t loc; /* Location of group */ + H5VL_object_t *vol_obj = NULL; /* object token of loc_id */ + H5VL_loc_params_t loc_params; herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_API(FAIL) H5TRACE5("e", "i*s*xIui", loc_id, name, oinfo, fields, lapl_id); /* Check args */ - if(H5G_loc(loc_id, &loc) < 0) - HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a location") if(!name) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "name parameter cannot be NULL") if(!*name) @@ -519,8 +627,19 @@ H5Oget_info_by_name2(hid_t loc_id, const char *name, H5O_info_t *oinfo, if(H5CX_set_apl(&lapl_id, H5P_CLS_LACC, loc_id, FALSE) < 0) HGOTO_ERROR(H5E_OHDR, H5E_CANTSET, FAIL, "can't set access property list info") + /* Fill out location struct */ + loc_params.type = H5VL_OBJECT_BY_NAME; + loc_params.loc_data.loc_by_name.name = name; + loc_params.loc_data.loc_by_name.lapl_id = lapl_id; + loc_params.obj_type = H5I_get_type(loc_id); + + /* Get the location object */ + if(NULL == (vol_obj = H5VL_get_object(loc_id))) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "invalid location identifier") + /* Retrieve the object's information */ - if(H5G_loc_info(&loc, name, oinfo/*out*/, fields) < 0) + if(H5VL_object_optional(vol_obj->data, vol_obj->driver->cls, H5P_DATASET_XFER_DEFAULT, H5_REQUEST_NULL, + H5VL_OBJECT_GET_INFO, loc_params, oinfo, fields) < 0) HGOTO_ERROR(H5E_OHDR, H5E_CANTGET, FAIL, "can't get info for object: '%s'", name) done: @@ -548,7 +667,8 @@ herr_t H5Oget_info_by_idx2(hid_t loc_id, const char *group_name, H5_index_t idx_type, H5_iter_order_t order, hsize_t n, H5O_info_t *oinfo, unsigned fields, hid_t lapl_id) { - H5G_loc_t loc; /* Location of group */ + H5VL_object_t *vol_obj = NULL; /* object token of loc_id */ + H5VL_loc_params_t loc_params; herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_API(FAIL) @@ -556,8 +676,6 @@ H5Oget_info_by_idx2(hid_t loc_id, const char *group_name, H5_index_t idx_type, fields, lapl_id); /* Check args */ - if(H5G_loc(loc_id, &loc) < 0) - HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a location") if(!group_name || !*group_name) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "no name specified") if(idx_type <= H5_INDEX_UNKNOWN || idx_type >= H5_INDEX_N) @@ -573,8 +691,21 @@ H5Oget_info_by_idx2(hid_t loc_id, const char *group_name, H5_index_t idx_type, if(H5CX_set_apl(&lapl_id, H5P_CLS_LACC, loc_id, FALSE) < 0) HGOTO_ERROR(H5E_OHDR, H5E_CANTSET, FAIL, "can't set access property list info") + loc_params.type = H5VL_OBJECT_BY_IDX; + loc_params.loc_data.loc_by_idx.name = group_name; + loc_params.loc_data.loc_by_idx.idx_type = idx_type; + loc_params.loc_data.loc_by_idx.order = order; + loc_params.loc_data.loc_by_idx.n = n; + loc_params.loc_data.loc_by_idx.lapl_id = lapl_id; + loc_params.obj_type = H5I_get_type(loc_id); + + /* Get the location object */ + if(NULL == (vol_obj = H5VL_get_object(loc_id))) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "invalid location identifier") + /* Retrieve the object's information */ - if(H5O__get_info_by_idx(&loc, group_name, idx_type, order, n, oinfo, fields) < 0) + if(H5VL_object_optional(vol_obj->data, vol_obj->driver->cls, H5P_DATASET_XFER_DEFAULT, H5_REQUEST_NULL, + H5VL_OBJECT_GET_INFO, loc_params, oinfo, fields) < 0) HGOTO_ERROR(H5E_OHDR, H5E_CANTGET, FAIL, "can't get info for object") done: @@ -602,22 +733,28 @@ done: herr_t H5Oset_comment(hid_t obj_id, const char *comment) { - H5G_loc_t loc; /* Location of group */ + H5VL_object_t *vol_obj = NULL; /* object token of loc_id */ + H5VL_loc_params_t loc_params; herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_API(FAIL) H5TRACE2("e", "i*s", obj_id, comment); - /* Check args */ - if(H5G_loc(obj_id, &loc) < 0) + /* Get the location object */ + if(NULL == (vol_obj = H5VL_get_object(obj_id))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "invalid location identifier") /* Set up collective metadata if appropriate */ if(H5CX_set_loc(obj_id) < 0) HGOTO_ERROR(H5E_OHDR, H5E_CANTSET, FAIL, "can't set collective metadata read info") + /* Fill in location struct fields */ + loc_params.type = H5VL_OBJECT_BY_SELF; + loc_params.obj_type = H5I_get_type(obj_id); + /* (Re)set the object's comment */ - if(H5G_loc_set_comment(&loc, ".", comment) < 0) + if(H5VL_object_optional(vol_obj->data, vol_obj->driver->cls, H5P_DATASET_XFER_DEFAULT, + H5_REQUEST_NULL, H5VL_OBJECT_SET_COMMENT, loc_params, comment) < 0) HGOTO_ERROR(H5E_OHDR, H5E_CANTSET, FAIL, "can't set comment for object") done: @@ -646,15 +783,14 @@ herr_t H5Oset_comment_by_name(hid_t loc_id, const char *name, const char *comment, hid_t lapl_id) { - H5G_loc_t loc; /* Location of group */ + H5VL_object_t *vol_obj = NULL; /* object token of loc_id */ + H5VL_loc_params_t loc_params; herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_API(FAIL) H5TRACE4("e", "i*s*si", loc_id, name, comment, lapl_id); /* Check args */ - if(H5G_loc(loc_id, &loc) < 0) - HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a location") if(!name || !*name) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "no name") @@ -662,8 +798,19 @@ H5Oset_comment_by_name(hid_t loc_id, const char *name, const char *comment, if(H5CX_set_apl(&lapl_id, H5P_CLS_LACC, loc_id, TRUE) < 0) HGOTO_ERROR(H5E_OHDR, H5E_CANTSET, FAIL, "can't set access property list info") + /* Fill in location struct fields */ + loc_params.type = H5VL_OBJECT_BY_NAME; + loc_params.loc_data.loc_by_name.name = name; + loc_params.loc_data.loc_by_name.lapl_id = lapl_id; + loc_params.obj_type = H5I_get_type(loc_id); + + /* Get the location object */ + if(NULL == (vol_obj = H5VL_get_object(loc_id))) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "invalid location identifier") + /* (Re)set the object's comment */ - if(H5G_loc_set_comment(&loc, name, comment) < 0) + if(H5VL_object_optional(vol_obj->data, vol_obj->driver->cls, H5P_DATASET_XFER_DEFAULT, H5_REQUEST_NULL, + H5VL_OBJECT_SET_COMMENT, loc_params, comment) < 0) HGOTO_ERROR(H5E_OHDR, H5E_CANTSET, FAIL, "can't set comment for object: '%s'", name) done: @@ -690,18 +837,24 @@ done: ssize_t H5Oget_comment(hid_t obj_id, char *comment, size_t bufsize) { - H5G_loc_t loc; /* Location of group */ + H5VL_object_t *vol_obj = NULL; /* object token of loc_id */ + H5VL_loc_params_t loc_params; ssize_t ret_value = -1; /* Return value */ FUNC_ENTER_API((-1)) H5TRACE3("Zs", "i*sz", obj_id, comment, bufsize); - /* Check args */ - if(H5G_loc(obj_id, &loc) < 0) - HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, (-1), "not a location") + /* Get the object */ + if (NULL == (vol_obj = H5VL_get_object(obj_id))) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, (-1), "invalid location identifier") + + /* Set fields in the location struct */ + loc_params.type = H5VL_OBJECT_BY_SELF; + loc_params.obj_type = H5I_get_type(obj_id); /* Retrieve the object's comment */ - if((ret_value = H5G_loc_get_comment(&loc, ".", comment/*out*/, bufsize)) < 0) + if (H5VL_object_optional(vol_obj->data, vol_obj->driver->cls, H5P_DATASET_XFER_DEFAULT, H5_REQUEST_NULL, + H5VL_OBJECT_GET_COMMENT, loc_params, comment, bufsize, &ret_value) < 0) HGOTO_ERROR(H5E_OHDR, H5E_CANTGET, (-1), "can't get comment for object") done: @@ -729,15 +882,14 @@ ssize_t H5Oget_comment_by_name(hid_t loc_id, const char *name, char *comment, size_t bufsize, hid_t lapl_id) { - H5G_loc_t loc; /* Location of group */ + H5VL_object_t *vol_obj = NULL; /* object token of loc_id */ + H5VL_loc_params_t loc_params; ssize_t ret_value = -1; /* Return value */ FUNC_ENTER_API((-1)) H5TRACE5("Zs", "i*s*szi", loc_id, name, comment, bufsize, lapl_id); /* Check args */ - if(H5G_loc(loc_id, &loc) < 0) - HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, (-1), "not a location") if(!name || !*name) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, (-1), "no name") @@ -745,8 +897,19 @@ H5Oget_comment_by_name(hid_t loc_id, const char *name, char *comment, size_t buf if(H5CX_set_apl(&lapl_id, H5P_CLS_LACC, loc_id, FALSE) < 0) HGOTO_ERROR(H5E_OHDR, H5E_CANTSET, (-1), "can't set access property list info") + /* Fill in location struct fields */ + loc_params.type = H5VL_OBJECT_BY_NAME; + loc_params.loc_data.loc_by_name.name = name; + loc_params.loc_data.loc_by_name.lapl_id = lapl_id; + loc_params.obj_type = H5I_get_type(loc_id); + + /* Get the location object */ + if(NULL == (vol_obj = H5VL_get_object(loc_id))) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, (-1), "invalid location identifier") + /* Retrieve the object's comment */ - if((ret_value = H5G_loc_get_comment(&loc, name, comment/*out*/, bufsize)) < 0) + if(H5VL_object_optional(vol_obj->data, vol_obj->driver->cls, H5P_DATASET_XFER_DEFAULT, H5_REQUEST_NULL, + H5VL_OBJECT_GET_COMMENT, loc_params, comment, bufsize, &ret_value) < 0) HGOTO_ERROR(H5E_OHDR, H5E_CANTGET, (-1), "can't get comment for object: '%s'", name) done: @@ -793,15 +956,14 @@ herr_t H5Ovisit2(hid_t obj_id, H5_index_t idx_type, H5_iter_order_t order, H5O_iterate_t op, void *op_data, unsigned fields) { - H5G_loc_t loc; + H5VL_object_t *vol_obj = NULL; /* Object token of loc_id */ + H5VL_loc_params_t loc_params; herr_t ret_value; /* Return value */ FUNC_ENTER_API(FAIL) H5TRACE6("e", "iIiIox*xIu", obj_id, idx_type, order, op, op_data, fields); /* Check args */ - if(H5G_loc(obj_id, &loc) < 0) - HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a location") if(idx_type <= H5_INDEX_UNKNOWN || idx_type >= H5_INDEX_N) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "invalid index type specified") if(order <= H5_ITER_UNKNOWN || order >= H5_ITER_N) @@ -811,8 +973,18 @@ H5Ovisit2(hid_t obj_id, H5_index_t idx_type, H5_iter_order_t order, if(fields & ~H5O_INFO_ALL) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "invalid fields") + /* Get the location object */ + if(NULL == (vol_obj = H5VL_get_object(obj_id))) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "invalid location identifier") + + /* Set location parameters */ + loc_params.type = H5VL_OBJECT_BY_SELF; + loc_params.obj_type = H5I_get_type(obj_id); + /* Visit the objects */ - if((ret_value = H5O__visit(&loc, ".", idx_type, order, op, op_data, fields)) < 0) + if((ret_value = H5VL_object_specific(vol_obj->data, loc_params, vol_obj->driver->cls, + H5VL_OBJECT_VISIT, H5P_DATASET_XFER_DEFAULT, H5_REQUEST_NULL, + idx_type, order, op, op_data, fields)) < 0) HGOTO_ERROR(H5E_OHDR, H5E_BADITER, FAIL, "object iteration failed") done: @@ -859,7 +1031,8 @@ herr_t H5Ovisit_by_name2(hid_t loc_id, const char *obj_name, H5_index_t idx_type, H5_iter_order_t order, H5O_iterate_t op, void *op_data, unsigned fields, hid_t lapl_id) { - H5G_loc_t loc; + H5VL_object_t *vol_obj = NULL; /* Object token of loc_id */ + H5VL_loc_params_t loc_params; herr_t ret_value; /* Return value */ FUNC_ENTER_API(FAIL) @@ -867,8 +1040,6 @@ H5Ovisit_by_name2(hid_t loc_id, const char *obj_name, H5_index_t idx_type, fields, lapl_id); /* Check args */ - if(H5G_loc(loc_id, &loc) < 0) - HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a location") if(!obj_name) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "obj_name parameter cannot be NULL") if(!*obj_name) @@ -886,8 +1057,20 @@ H5Ovisit_by_name2(hid_t loc_id, const char *obj_name, H5_index_t idx_type, if(H5CX_set_apl(&lapl_id, H5P_CLS_LACC, loc_id, FALSE) < 0) HGOTO_ERROR(H5E_OHDR, H5E_CANTSET, FAIL, "can't set access property list info") + /* Get the location object */ + if(NULL == (vol_obj = H5VL_get_object(loc_id))) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "invalid location identifier") + + /* Set location parameters */ + loc_params.type = H5VL_OBJECT_BY_NAME; + loc_params.loc_data.loc_by_name.name = obj_name; + loc_params.loc_data.loc_by_name.lapl_id = lapl_id; + loc_params.obj_type = H5I_get_type(loc_id); + /* Visit the objects */ - if((ret_value = H5O__visit(&loc, obj_name, idx_type, order, op, op_data, fields)) < 0) + if((ret_value = H5VL_object_specific(vol_obj->data, loc_params, vol_obj->driver->cls, + H5VL_OBJECT_VISIT, H5P_DATASET_XFER_DEFAULT, H5_REQUEST_NULL, + idx_type, order, op, op_data, fields)) < 0) HGOTO_ERROR(H5E_OHDR, H5E_BADITER, FAIL, "object iteration failed") done: @@ -938,6 +1121,7 @@ H5Oclose(hid_t object_id) case H5I_ATTR: case H5I_REFERENCE: case H5I_VFL: + case H5I_VOL: case H5I_GENPROP_CLS: case H5I_GENPROP_LST: case H5I_ERROR_CLASS: diff --git a/src/H5Oattribute.c b/src/H5Oattribute.c index 5183026..1d509e5 100644 --- a/src/H5Oattribute.c +++ b/src/H5Oattribute.c @@ -713,7 +713,7 @@ H5O__attr_find_opened_attr(const H5O_loc_t *loc, H5A_t **attr, const char* name_ unsigned long attr_fnum; /* Attributes file serial number */ /* Get pointer to attribute */ - if(NULL == (*attr = (H5A_t *)H5I_object_verify(attr_id_list[u], H5I_ATTR))) + if(NULL == (*attr = (H5A_t *)H5VL_object_verify(attr_id_list[u], H5I_ATTR))) HGOTO_ERROR(H5E_ATTR, H5E_BADTYPE, FAIL, "not an attribute") /* Get file serial number for attribute */ diff --git a/src/H5Ocopy.c b/src/H5Ocopy.c index 1ba4901..c03c352 100644 --- a/src/H5Ocopy.c +++ b/src/H5Ocopy.c @@ -43,6 +43,7 @@ #include "H5MMprivate.h" /* Memory management */ #include "H5Opkg.h" /* Object headers */ #include "H5Pprivate.h" /* Property lists */ +#include "H5VLprivate.h" /* Virtual Object Layer */ /****************/ @@ -197,10 +198,12 @@ H5FL_DEFINE(haddr_t); */ herr_t H5Ocopy(hid_t src_loc_id, const char *src_name, hid_t dst_loc_id, - const char *dst_name, hid_t ocpypl_id, hid_t lcpl_id) + const char *dst_name, hid_t ocpypl_id, hid_t lcpl_id) { - H5G_loc_t loc; /* Source group group location */ - H5G_loc_t dst_loc; /* Destination group location */ + H5VL_object_t *vol_obj1 = NULL; /* object token of src_id */ + H5VL_loc_params_t loc_params1; + H5VL_object_t *vol_obj2 = NULL; /* object token of dst_id */ + H5VL_loc_params_t loc_params2; herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_API(FAIL) @@ -208,10 +211,6 @@ H5Ocopy(hid_t src_loc_id, const char *src_name, hid_t dst_loc_id, ocpypl_id, lcpl_id); /* Check arguments */ - if(H5G_loc(src_loc_id, &loc) < 0) - HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a location") - if(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 source name specified") if(!dst_name || !*dst_name) @@ -235,8 +234,22 @@ H5Ocopy(hid_t src_loc_id, const char *src_name, hid_t dst_loc_id, if(H5CX_set_loc(src_loc_id) < 0) HGOTO_ERROR(H5E_OHDR, H5E_CANTSET, FAIL, "can't set collective metadata read info") + /* get the object */ + if(NULL == (vol_obj1 = (H5VL_object_t *)H5I_object(src_loc_id))) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "invalid location identifier") + loc_params1.type = H5VL_OBJECT_BY_SELF; + loc_params1.obj_type = H5I_get_type(src_loc_id); + + /* get the object */ + if(NULL == (vol_obj2 = (H5VL_object_t *)H5I_object(dst_loc_id))) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "invalid location identifier") + loc_params2.type = H5VL_OBJECT_BY_SELF; + loc_params2.obj_type = H5I_get_type(dst_loc_id); + /* Copy the object */ - if(H5O_copy(&loc, src_name, &dst_loc, dst_name, ocpypl_id, lcpl_id) < 0) + if((ret_value = H5VL_object_copy(vol_obj1->data, loc_params1, vol_obj1->driver->cls, src_name, + vol_obj2->data, loc_params2, vol_obj2->driver->cls, dst_name, + ocpypl_id, lcpl_id, H5P_DATASET_XFER_DEFAULT, H5_REQUEST_NULL)) < 0) HGOTO_ERROR(H5E_OHDR, H5E_CANTCOPY, FAIL, "unable to copy object") done: @@ -1784,7 +1797,7 @@ H5O__copy_search_comm_dt(H5F_t *file_src, H5O_t *oh_src, HDassert(oh_src); HDassert(oloc_dst); HDassert(oloc_dst->file); - HDassert(H5F_FILE_ID(oloc_dst->file) >= 0); + HDassert(H5F_ID_EXISTS(oloc_dst->file)); HDassert(cpy_info); /* Allocate key */ diff --git a/src/H5Odeprec.c b/src/H5Odeprec.c index 3441d8b..ead2028 100644 --- a/src/H5Odeprec.c +++ b/src/H5Odeprec.c @@ -34,6 +34,7 @@ #include "H5private.h" /* Generic Functions */ #include "H5CXprivate.h" /* API Contexts */ #include "H5Eprivate.h" /* Error handling */ +#include "H5Iprivate.h" /* IDs */ #include "H5Opkg.h" /* Object headers */ @@ -88,20 +89,28 @@ herr_t H5Oget_info1(hid_t loc_id, H5O_info_t *oinfo) { - H5G_loc_t loc; /* Location of group */ + H5VL_object_t *vol_obj = NULL; /* Object token of loc_id */ + H5VL_loc_params_t loc_params; herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_API(FAIL) H5TRACE2("e", "i*x", loc_id, oinfo); /* Check args */ - if(H5G_loc(loc_id, &loc) < 0) - HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a location") if(!oinfo) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "oinfo parameter cannot be NULL") + /* Set location struct fields */ + loc_params.type = H5VL_OBJECT_BY_SELF; + loc_params.obj_type = H5I_get_type(loc_id); + + /* Get the location object */ + if(NULL == (vol_obj = H5VL_get_object(loc_id))) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "invalid location identifier") + /* Retrieve the object's information */ - if(H5G_loc_info(&loc, ".", oinfo/*out*/, H5O_INFO_ALL) < 0) + if(H5VL_object_optional(vol_obj->data, vol_obj->driver->cls, H5P_DATASET_XFER_DEFAULT, + H5_REQUEST_NULL, H5VL_OBJECT_GET_INFO, loc_params, oinfo, H5O_INFO_ALL) < 0) HGOTO_ERROR(H5E_OHDR, H5E_CANTGET, FAIL, "can't get info for object") done: @@ -122,15 +131,14 @@ done: herr_t H5Oget_info_by_name1(hid_t loc_id, const char *name, H5O_info_t *oinfo, hid_t lapl_id) { - H5G_loc_t loc; /* Location of group */ + H5VL_object_t *vol_obj = NULL; /* object token of loc_id */ + H5VL_loc_params_t loc_params; herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_API(FAIL) H5TRACE4("e", "i*s*xi", loc_id, name, oinfo, lapl_id); /* Check args */ - if(H5G_loc(loc_id, &loc) < 0) - HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a location") if(!name) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "name parameter cannot be NULL") if(!*name) @@ -142,8 +150,19 @@ H5Oget_info_by_name1(hid_t loc_id, const char *name, H5O_info_t *oinfo, hid_t la if(H5CX_set_apl(&lapl_id, H5P_CLS_LACC, loc_id, FALSE) < 0) HGOTO_ERROR(H5E_OHDR, H5E_CANTSET, FAIL, "can't set access property list info") + /* Fill out location struct */ + loc_params.type = H5VL_OBJECT_BY_NAME; + loc_params.loc_data.loc_by_name.name = name; + loc_params.loc_data.loc_by_name.lapl_id = lapl_id; + loc_params.obj_type = H5I_get_type(loc_id); + + /* Get the location object */ + if(NULL == (vol_obj = H5VL_get_object(loc_id))) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "invalid location identifier") + /* Retrieve the object's information */ - if(H5G_loc_info(&loc, name, oinfo/*out*/, H5O_INFO_ALL) < 0) + if(H5VL_object_optional(vol_obj->data, vol_obj->driver->cls, H5P_DATASET_XFER_DEFAULT, H5_REQUEST_NULL, + H5VL_OBJECT_GET_INFO, loc_params, oinfo, H5O_INFO_ALL) < 0) HGOTO_ERROR(H5E_OHDR, H5E_CANTGET, FAIL, "can't get info for object: '%s'", name) done: @@ -169,9 +188,8 @@ herr_t H5Oget_info_by_idx1(hid_t loc_id, const char *group_name, H5_index_t idx_type, H5_iter_order_t order, hsize_t n, H5O_info_t *oinfo, hid_t lapl_id) { - H5G_loc_t loc; /* Location of group */ - H5G_loc_t obj_loc; /* Location used to open group */ - hbool_t loc_found = FALSE; /* Entry at 'name' found */ + H5VL_object_t *vol_obj = NULL; /* object token of loc_id */ + H5VL_loc_params_t loc_params; herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_API(FAIL) @@ -179,8 +197,6 @@ H5Oget_info_by_idx1(hid_t loc_id, const char *group_name, H5_index_t idx_type, lapl_id); /* Check args */ - if(H5G_loc(loc_id, &loc) < 0) - HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a location") if(!group_name || !*group_name) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "no name specified") if(idx_type <= H5_INDEX_UNKNOWN || idx_type >= H5_INDEX_N) @@ -194,15 +210,24 @@ H5Oget_info_by_idx1(hid_t loc_id, const char *group_name, H5_index_t idx_type, if(H5CX_set_apl(&lapl_id, H5P_CLS_LACC, loc_id, FALSE) < 0) HGOTO_ERROR(H5E_OHDR, H5E_CANTSET, FAIL, "can't set access property list info") + loc_params.type = H5VL_OBJECT_BY_IDX; + loc_params.loc_data.loc_by_idx.name = group_name; + loc_params.loc_data.loc_by_idx.idx_type = idx_type; + loc_params.loc_data.loc_by_idx.order = order; + loc_params.loc_data.loc_by_idx.n = n; + loc_params.loc_data.loc_by_idx.lapl_id = lapl_id; + loc_params.obj_type = H5I_get_type(loc_id); + + /* Get the location object */ + if(NULL == (vol_obj = H5VL_get_object(loc_id))) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "invalid location identifier") + /* Retrieve the object's information */ - if(H5O__get_info_by_idx(&loc, group_name, idx_type, order, n, oinfo, H5O_INFO_ALL) < 0) + if(H5VL_object_optional(vol_obj->data, vol_obj->driver->cls, H5P_DATASET_XFER_DEFAULT, H5_REQUEST_NULL, + H5VL_OBJECT_GET_INFO, loc_params, oinfo, H5O_INFO_ALL) < 0) HGOTO_ERROR(H5E_OHDR, H5E_CANTGET, FAIL, "can't get info for object") done: - /* Release the object location */ - if(loc_found && H5G_loc_free(&obj_loc) < 0) - HDONE_ERROR(H5E_OHDR, H5E_CANTRELEASE, FAIL, "can't free location") - FUNC_LEAVE_API(ret_value) } /* end H5Oget_info_by_idx1() */ @@ -243,15 +268,14 @@ herr_t H5Ovisit1(hid_t obj_id, H5_index_t idx_type, H5_iter_order_t order, H5O_iterate_t op, void *op_data) { - H5G_loc_t loc; + H5VL_object_t *vol_obj = NULL; /* Object token of loc_id */ + H5VL_loc_params_t loc_params; herr_t ret_value; /* Return value */ FUNC_ENTER_API(FAIL) H5TRACE5("e", "iIiIox*x", obj_id, idx_type, order, op, op_data); /* Check args */ - if(H5G_loc(obj_id, &loc) < 0) - HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a location") if(idx_type <= H5_INDEX_UNKNOWN || idx_type >= H5_INDEX_N) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "invalid index type specified") if(order <= H5_ITER_UNKNOWN || order >= H5_ITER_N) @@ -259,8 +283,18 @@ H5Ovisit1(hid_t obj_id, H5_index_t idx_type, H5_iter_order_t order, if(!op) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "no callback operator specified") + /* Get the location object */ + if(NULL == (vol_obj = H5VL_get_object(obj_id))) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "invalid location identifier") + + /* Set location parameters */ + loc_params.type = H5VL_OBJECT_BY_SELF; + loc_params.obj_type = H5I_get_type(obj_id); + /* Visit the objects */ - if((ret_value = H5O__visit(&loc, ".", idx_type, order, op, op_data, H5O_INFO_ALL)) < 0) + if((ret_value = H5VL_object_specific(vol_obj->data, loc_params, vol_obj->driver->cls, + H5VL_OBJECT_VISIT, H5P_DATASET_XFER_DEFAULT, H5_REQUEST_NULL, + idx_type, order, op, op_data, H5O_INFO_ALL)) < 0) HGOTO_ERROR(H5E_OHDR, H5E_BADITER, FAIL, "object visitation failed") done: @@ -304,7 +338,8 @@ herr_t H5Ovisit_by_name1(hid_t loc_id, const char *obj_name, H5_index_t idx_type, H5_iter_order_t order, H5O_iterate_t op, void *op_data, hid_t lapl_id) { - H5G_loc_t loc; + H5VL_object_t *vol_obj = NULL; /* Object token of loc_id */ + H5VL_loc_params_t loc_params; herr_t ret_value; /* Return value */ FUNC_ENTER_API(FAIL) @@ -312,8 +347,6 @@ H5Ovisit_by_name1(hid_t loc_id, const char *obj_name, H5_index_t idx_type, lapl_id); /* Check args */ - if(H5G_loc(loc_id, &loc) < 0) - HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a location") if(!obj_name) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "obj_name parameter cannot be NULL") if(!*obj_name) @@ -329,8 +362,20 @@ H5Ovisit_by_name1(hid_t loc_id, const char *obj_name, H5_index_t idx_type, if(H5CX_set_apl(&lapl_id, H5P_CLS_LACC, loc_id, FALSE) < 0) HGOTO_ERROR(H5E_OHDR, H5E_CANTSET, FAIL, "can't set access property list info") + /* Get the location object */ + if(NULL == (vol_obj = H5VL_get_object(loc_id))) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "invalid location identifier") + + /* Set location parameters */ + loc_params.type = H5VL_OBJECT_BY_NAME; + loc_params.loc_data.loc_by_name.name = obj_name; + loc_params.loc_data.loc_by_name.lapl_id = lapl_id; + loc_params.obj_type = H5I_get_type(loc_id); + /* Visit the objects */ - if((ret_value = H5O__visit(&loc, obj_name, idx_type, order, op, op_data, H5O_INFO_ALL)) < 0) + if((ret_value = H5VL_object_specific(vol_obj->data, loc_params, vol_obj->driver->cls, + H5VL_OBJECT_VISIT, H5P_DATASET_XFER_DEFAULT, H5_REQUEST_NULL, + idx_type, order, op, op_data, H5O_INFO_ALL)) < 0) HGOTO_ERROR(H5E_OHDR, H5E_BADITER, FAIL, "object visitation failed") done: diff --git a/src/H5Ofill.c b/src/H5Ofill.c index c131c76..adf36b9 100644 --- a/src/H5Ofill.c +++ b/src/H5Ofill.c @@ -344,7 +344,7 @@ H5O_fill_old_decode(H5F_t *f, H5O_t *open_oh, if((exists = H5O_msg_exists_oh(open_oh, H5O_DTYPE_ID)) < 0) HGOTO_ERROR(H5E_SYM, H5E_NOTFOUND, NULL, "unable to read object header") if(exists) { - if((dt = H5O_msg_read_oh(f, open_oh, H5O_DTYPE_ID, NULL)) < 0) + if(NULL == (dt = (H5T_t *)H5O_msg_read_oh(f, open_oh, H5O_DTYPE_ID, NULL))) HGOTO_ERROR(H5E_SYM, H5E_CANTGET, NULL, "can't read DTYPE message") /* Verify size */ if(fill->size != H5T_GET_SIZE(dt)) diff --git a/src/H5Oflush.c b/src/H5Oflush.c index 2302d4c..b27f01b 100644 --- a/src/H5Oflush.c +++ b/src/H5Oflush.c @@ -27,6 +27,7 @@ /****************/ #include "H5Omodule.h" /* This source code file is part of the H5O module */ +#define H5T_FRIEND /* Suppress error about including H5Tpkg */ /***********/ /* Headers */ @@ -40,6 +41,7 @@ #include "H5Gprivate.h" /* Groups */ #include "H5Iprivate.h" /* IDs */ #include "H5Opkg.h" /* Objects */ +#include "H5Tpkg.h" /* Datatypes */ /********************/ /* Local Prototypes */ @@ -70,22 +72,28 @@ static herr_t H5O__refresh_metadata_close(hid_t oid, H5O_loc_t oloc, herr_t H5Oflush(hid_t obj_id) { - H5O_loc_t *oloc; /* Object location */ + H5VL_object_t *vol_obj = NULL; /* Object token */ + H5VL_loc_params_t loc_params; herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_API(FAIL) H5TRACE1("e", "i", obj_id); /* Check args */ - if(NULL == (oloc = H5O_get_loc(obj_id))) + if(NULL == (vol_obj = H5VL_get_object(obj_id))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "invalid object identifier") /* Set up collective metadata if appropriate */ if(H5CX_set_loc(obj_id) < 0) HGOTO_ERROR(H5E_DATATYPE, H5E_CANTSET, FAIL, "can't set access property list info") + /* Set location parameters */ + loc_params.type = H5VL_OBJECT_BY_SELF; + loc_params.obj_type = H5I_get_type(obj_id); + /* Flush the object */ - if(H5O_flush(oloc, obj_id) < 0) + if((ret_value = H5VL_object_specific(vol_obj->data, loc_params, vol_obj->driver->cls, + H5VL_OBJECT_FLUSH, H5P_DATASET_XFER_DEFAULT, H5_REQUEST_NULL, obj_id)) < 0) HGOTO_ERROR(H5E_OHDR, H5E_CANTFLUSH, FAIL, "unable to flush object") done: @@ -116,7 +124,7 @@ H5O_flush(H5O_loc_t *oloc, hid_t obj_id) FUNC_ENTER_NOAPI(FAIL) /* Get the object pointer */ - if(NULL == (obj_ptr = H5I_object(obj_id))) + if(NULL == (obj_ptr = H5VL_object(obj_id))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "invalid object identifier") /* Get the object class */ @@ -229,22 +237,28 @@ done: herr_t H5Orefresh(hid_t oid) { - H5O_loc_t *oloc; /* object location */ - herr_t ret_value = SUCCEED; /* return value */ - + H5VL_object_t *vol_obj = NULL; /* Object token */ + H5VL_loc_params_t loc_params; + herr_t ret_value = SUCCEED; /* Return value */ + FUNC_ENTER_API(FAIL) H5TRACE1("e", "i", oid); /* Check args */ - if(NULL == (oloc = H5O_get_loc(oid))) + if(NULL == (vol_obj = H5VL_get_object(oid))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "invalid object identifier") /* Set up collective metadata if appropriate */ if(H5CX_set_loc(oid) < 0) HGOTO_ERROR(H5E_OHDR, H5E_CANTSET, FAIL, "can't set access property list info") + /* Set location parameters */ + loc_params.type = H5VL_OBJECT_BY_SELF; + loc_params.obj_type = H5I_get_type(oid); + /* Refresh the object */ - if(H5O_refresh_metadata(oid, *oloc) < 0) + if((ret_value = H5VL_object_specific(vol_obj->data, loc_params, vol_obj->driver->cls, + H5VL_OBJECT_REFRESH, H5P_DATASET_XFER_DEFAULT, H5_REQUEST_NULL, oid)) < 0) HGOTO_ERROR(H5E_OHDR, H5E_CANTLOAD, FAIL, "unable to refresh object") done: @@ -275,6 +289,7 @@ done: herr_t H5O_refresh_metadata(hid_t oid, H5O_loc_t oloc) { + H5VL_object_t *vol_obj = NULL; /* VOL object associated with the ID */ hbool_t objs_incr = FALSE; /* Whether the object count in the file was incremented */ herr_t ret_value = SUCCEED; /* Return value */ @@ -285,6 +300,7 @@ H5O_refresh_metadata(hid_t oid, H5O_loc_t oloc) H5G_loc_t obj_loc; H5O_loc_t obj_oloc; H5G_name_t obj_path; + H5O_shared_t cached_H5O_shared; /* Create empty object location */ obj_loc.oloc = &obj_oloc; @@ -297,13 +313,36 @@ H5O_refresh_metadata(hid_t oid, H5O_loc_t oloc) H5F_incr_nopen_objs(oloc.file); objs_incr = TRUE; + /* Save important datatype state */ + if(H5I_get_type(oid) == H5I_DATATYPE) + if(H5T_save_refresh_state(oid, &cached_H5O_shared) < 0) + HGOTO_ERROR(H5E_DATATYPE, H5E_CANTOPENOBJ, FAIL, "unable to save datatype state") + + /* Get the VOL object from the ID */ + if(NULL == (vol_obj = H5VL_get_object(oid))) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "invalid object identifier") + + /* Bump the number of references on the VOL driver. + * If you don't do this, VDS refreshes can accidentally close the driver. + */ + vol_obj->driver->nrefs++; + /* Close object & evict its metadata */ if((H5O__refresh_metadata_close(oid, oloc, &obj_loc)) < 0) HGOTO_ERROR(H5E_OHDR, H5E_CANTLOAD, FAIL, "unable to refresh object") /* Re-open the object, re-fetching its metadata */ - if((H5O_refresh_metadata_reopen(oid, &obj_loc, FALSE)) < 0) + if((H5O_refresh_metadata_reopen(oid, &obj_loc, vol_obj->driver, FALSE)) < 0) HGOTO_ERROR(H5E_OHDR, H5E_CANTLOAD, FAIL, "unable to refresh object") + + /* Restore the number of references on the VOL driver */ + vol_obj->driver->nrefs--; + + /* Restore important datatype state */ + if(H5I_get_type(oid) == H5I_DATATYPE) + if(H5T_restore_refresh_state(oid, &cached_H5O_shared) < 0) + HGOTO_ERROR(H5E_DATATYPE, H5E_CANTOPENOBJ, FAIL, "unable to restore datatype state") + } /* end if */ done: @@ -350,7 +389,7 @@ H5O__refresh_metadata_close(hid_t oid, H5O_loc_t oloc, H5G_loc_t *obj_loc) H5G_loc_copy(obj_loc, &tmp_loc, H5_COPY_DEEP); } /* end if */ - /* Get object's type */ + /* Handle close for multiple dataset opens */ if(H5I_get_type(oid) == H5I_DATASET) if(H5D_mult_refresh_close(oid) < 0) HGOTO_ERROR(H5E_DATASET, H5E_CANTOPENOBJ, FAIL, "unable to prepare refresh for dataset") @@ -400,7 +439,7 @@ done: *------------------------------------------------------------------------- */ herr_t -H5O_refresh_metadata_reopen(hid_t oid, H5G_loc_t *obj_loc, hbool_t start_swmr) +H5O_refresh_metadata_reopen(hid_t oid, H5G_loc_t *obj_loc, H5VL_t *vol_driver, hbool_t start_swmr) { void *object = NULL; /* Object for this operation */ H5I_type_t type; /* Type of object for the ID */ @@ -410,6 +449,7 @@ H5O_refresh_metadata_reopen(hid_t oid, H5G_loc_t *obj_loc, hbool_t start_swmr) /* Sanity check */ HDassert(obj_loc); + HDassert(vol_driver); /* Get object's type */ type = H5I_get_type(oid); @@ -443,6 +483,7 @@ H5O_refresh_metadata_reopen(hid_t oid, H5G_loc_t *obj_loc, hbool_t start_swmr) case H5I_ATTR: case H5I_REFERENCE: case H5I_VFL: + case H5I_VOL: case H5I_GENPROP_CLS: case H5I_GENPROP_LST: case H5I_ERROR_CLASS: @@ -455,7 +496,7 @@ H5O_refresh_metadata_reopen(hid_t oid, H5G_loc_t *obj_loc, hbool_t start_swmr) } /* end switch */ /* Re-register ID for the object */ - if((H5I_register_with_id(type, object, TRUE, oid)) < 0) + if((H5I_register_with_id(type, object, vol_driver, TRUE, oid)) < 0) HGOTO_ERROR(H5E_ATOM, H5E_CANTREGISTER, FAIL, "unable to re-register object ID after refresh") done: diff --git a/src/H5Oint.c b/src/H5Oint.c index 44809e1..c569226 100644 --- a/src/H5Oint.c +++ b/src/H5Oint.c @@ -42,6 +42,8 @@ #include "H5MMprivate.h" /* Memory management */ #endif /* H5O_ENABLE_BOGUS */ #include "H5Opkg.h" /* Object headers */ +#include "H5VLprivate.h" /* Virtual Object Layer */ +#include "H5VLnative.h" /* Virtual Object Layer (native) */ /****************/ @@ -515,26 +517,26 @@ done: /*------------------------------------------------------------------------- * Function: H5O_open_name * - * Purpose: Opens an object within an HDF5 file. + * Purpose: Opens an object by name * - * Return: Success: Open object identifier - * Failure: H5I_INVALID_HID + * Return: Success: Pointer to object data + * Failure: NULL * * Programmer: Quincey Koziol * March 5 2007 * *------------------------------------------------------------------------- */ -hid_t -H5O_open_name(const H5G_loc_t *loc, const char *name, hbool_t app_ref) +void * +H5O_open_name(const H5G_loc_t *loc, const char *name, H5I_type_t *opened_type) { H5G_loc_t obj_loc; /* Location used to open group */ H5G_name_t obj_path; /* Opened object group hier. path */ H5O_loc_t obj_oloc; /* Opened object object location */ hbool_t loc_found = FALSE; /* Entry at 'name' found */ - hid_t ret_value = H5I_INVALID_HID; + void *ret_value = NULL; /* Return value */ - FUNC_ENTER_NOAPI(H5I_INVALID_HID) + FUNC_ENTER_NOAPI(NULL) /* Check args */ HDassert(loc); @@ -547,17 +549,17 @@ H5O_open_name(const H5G_loc_t *loc, const char *name, hbool_t app_ref) /* Find the object's location */ if(H5G_loc_find(loc, name, &obj_loc/*out*/) < 0) - HGOTO_ERROR(H5E_OHDR, H5E_NOTFOUND, H5I_INVALID_HID, "object not found") + HGOTO_ERROR(H5E_OHDR, H5E_NOTFOUND, NULL, "object not found") loc_found = TRUE; /* Open the object */ - if((ret_value = H5O_open_by_loc(&obj_loc, app_ref)) < 0) - HGOTO_ERROR(H5E_OHDR, H5E_CANTOPENOBJ, H5I_INVALID_HID, "unable to open object") + if(NULL == (ret_value = H5O_open_by_loc(&obj_loc, opened_type))) + HGOTO_ERROR(H5E_OHDR, H5E_CANTOPENOBJ, NULL, "unable to open object") done: - if(ret_value < 0 && loc_found) - if(H5G_loc_free(&obj_loc) < 0) - HDONE_ERROR(H5E_OHDR, H5E_CANTRELEASE, H5I_INVALID_HID, "can't free location") + if(NULL == ret_value) + if(loc_found && H5G_loc_free(&obj_loc) < 0) + HDONE_ERROR(H5E_OHDR, H5E_CANTRELEASE, NULL, "can't free location") FUNC_LEAVE_NOAPI(ret_value) } /* end H5O_open_name() */ @@ -568,25 +570,25 @@ done: * * Purpose: Internal routine to open an object by index within group * - * Return: Success: Open object identifier - * Failure: H5I_INVALID_HID + * Return: Success: Pointer to object data + * Failure: NULL * * Programmer: Quincey Koziol * December 28, 2017 * *------------------------------------------------------------------------- */ -hid_t +void * H5O_open_by_idx(const H5G_loc_t *loc, const char *name, H5_index_t idx_type, - H5_iter_order_t order, hsize_t n) + H5_iter_order_t order, hsize_t n, H5I_type_t *opened_type) { H5G_loc_t obj_loc; /* Location used to open group */ H5G_name_t obj_path; /* Opened object group hier. path */ H5O_loc_t obj_oloc; /* Opened object object location */ hbool_t loc_found = FALSE; /* Entry at 'name' found */ - hid_t ret_value = H5I_INVALID_HID; /* Return value */ + void *ret_value = NULL; /* Return value */ - FUNC_ENTER_NOAPI(H5I_INVALID_HID) + FUNC_ENTER_NOAPI(NULL) /* Check arguments */ HDassert(loc); @@ -598,18 +600,18 @@ H5O_open_by_idx(const H5G_loc_t *loc, const char *name, H5_index_t idx_type, /* Find the object's location, according to the order in the index */ if(H5G_loc_find_by_idx(loc, name, idx_type, order, n, &obj_loc/*out*/) < 0) - HGOTO_ERROR(H5E_OHDR, H5E_NOTFOUND, H5I_INVALID_HID, "group not found") + HGOTO_ERROR(H5E_OHDR, H5E_NOTFOUND, NULL, "group not found") loc_found = TRUE; /* Open the object */ - if((ret_value = H5O_open_by_loc(&obj_loc, TRUE)) < 0) - HGOTO_ERROR(H5E_OHDR, H5E_CANTOPENOBJ, H5I_INVALID_HID, "unable to open object") + if(NULL == (ret_value = H5O_open_by_loc(&obj_loc, opened_type))) + HGOTO_ERROR(H5E_OHDR, H5E_CANTOPENOBJ, NULL, "unable to open object") done: /* Release the object location if we failed after copying it */ - if(ret_value < 0 && loc_found) - if(H5G_loc_free(&obj_loc) < 0) - HDONE_ERROR(H5E_OHDR, H5E_CANTRELEASE, H5I_INVALID_HID, "can't free location") + if(NULL == ret_value) + if(loc_found && H5G_loc_free(&obj_loc) < 0) + HDONE_ERROR(H5E_OHDR, H5E_CANTRELEASE, NULL, "can't free location") FUNC_LEAVE_NOAPI(ret_value) } /* end H5O_open_by_idx() */ @@ -620,23 +622,23 @@ done: * * Purpose: Internal routine to open an object by its address * - * Return: Success: Open object identifier - * Failure: H5I_INVALID_HID + * Return: Success: Pointer to object data + * Failure: NULL * * Programmer: Quincey Koziol * December 28, 2017 * *------------------------------------------------------------------------- */ -hid_t -H5O_open_by_addr(const H5G_loc_t *loc, haddr_t addr) +void * +H5O_open_by_addr(const H5G_loc_t *loc, haddr_t addr, H5I_type_t *opened_type) { H5G_loc_t obj_loc; /* Location used to open group */ H5G_name_t obj_path; /* Opened object group hier. path */ H5O_loc_t obj_oloc; /* Opened object object location */ - hid_t ret_value = H5I_INVALID_HID; /* Return value */ + void *ret_value = NULL; /* Return value */ - FUNC_ENTER_NOAPI(H5I_INVALID_HID) + FUNC_ENTER_NOAPI(NULL) /* Check arguments */ HDassert(loc); @@ -650,8 +652,8 @@ H5O_open_by_addr(const H5G_loc_t *loc, haddr_t addr) H5G_name_reset(obj_loc.path); /* objects opened through this routine don't have a path name */ /* Open the object */ - if((ret_value = H5O_open_by_loc(&obj_loc, TRUE)) < 0) - HGOTO_ERROR(H5E_OHDR, H5E_CANTOPENOBJ, H5I_INVALID_HID, "unable to open object") + if(NULL == (ret_value = H5O_open_by_loc(&obj_loc, opened_type))) + HGOTO_ERROR(H5E_OHDR, H5E_CANTOPENOBJ, NULL, "unable to open object") done: FUNC_LEAVE_NOAPI(ret_value) @@ -661,34 +663,34 @@ done: /*------------------------------------------------------------------------- * Function: H5O_open_by_loc * - * Purpose: Opens an object and returns an ID given its group loction. + * Purpose: Opens an object * - * Return: Success: Open object identifier - * Failure: H5I_INVALID_HID + * Return: Success: Pointer to object data + * Failure: NULL * * Programmer: James Laird * July 25 2006 * *------------------------------------------------------------------------- */ -hid_t -H5O_open_by_loc(const H5G_loc_t *obj_loc, hbool_t app_ref) +void * +H5O_open_by_loc(const H5G_loc_t *obj_loc, H5I_type_t *opened_type) { const H5O_obj_class_t *obj_class; /* Class of object for location */ - hid_t ret_value = H5I_INVALID_HID; /* Return value */ + void *ret_value = NULL; /* Return value */ - FUNC_ENTER_NOAPI(H5I_INVALID_HID) + FUNC_ENTER_NOAPI(NULL) HDassert(obj_loc); /* Get the object class for this location */ if(NULL == (obj_class = H5O__obj_class(obj_loc->oloc))) - HGOTO_ERROR(H5E_OHDR, H5E_CANTGET, H5I_INVALID_HID, "unable to determine object class") + HGOTO_ERROR(H5E_OHDR, H5E_CANTGET, NULL, "unable to determine object class") /* Call the object class's 'open' routine */ HDassert(obj_class->open); - if((ret_value = obj_class->open(obj_loc, app_ref)) < 0) - HGOTO_ERROR(H5E_OHDR, H5E_CANTOPENOBJ, H5I_INVALID_HID, "unable to open object") + if(NULL == (ret_value = obj_class->open(obj_loc, opened_type))) + HGOTO_ERROR(H5E_OHDR, H5E_CANTOPENOBJ, NULL, "unable to open object") done: FUNC_LEAVE_NOAPI(ret_value) @@ -733,7 +735,7 @@ H5O_close(H5O_loc_t *loc, hbool_t *file_closed /*out*/) #ifdef H5O_DEBUG if(H5DEBUG(O)) { - if(H5F_FILE_ID(loc->file)< 0 && 1 == H5F_NREFS(loc->file)) + if(FALSE == H5F_ID_EXISTS(loc->file) && 1 == H5F_NREFS(loc->file)) HDfprintf(H5DEBUG(O), "< %a auto %lu remaining\n", loc->addr, (unsigned long)H5F_NOPEN_OBJS(loc->file)); else HDfprintf(H5DEBUG(O), "< %a\n", loc->addr); @@ -1766,6 +1768,7 @@ H5O_get_loc(hid_t object_id) case H5I_ATTR: case H5I_REFERENCE: case H5I_VFL: + case H5I_VOL: case H5I_GENPROP_CLS: case H5I_GENPROP_LST: case H5I_ERROR_CLASS: @@ -2622,6 +2625,8 @@ H5O__visit(H5G_loc_t *loc, const char *obj_name, H5_index_t idx_type, H5O_loc_t obj_oloc; /* Opened object object location */ hbool_t loc_found = FALSE; /* Entry at 'name' found */ H5O_info_t oinfo; /* Object info struct */ + void *obj = NULL; /* Object */ + H5I_type_t opened_type; /* ID type of object */ hid_t obj_id = H5I_INVALID_HID; /* ID of object */ herr_t ret_value = FAIL; /* Return value */ @@ -2649,9 +2654,13 @@ H5O__visit(H5G_loc_t *loc, const char *obj_name, H5_index_t idx_type, /* Open the object */ /* (Takes ownership of the obj_loc information) */ - if((obj_id = H5O_open_by_loc(&obj_loc, TRUE)) < 0) + if(NULL == (obj = H5O_open_by_loc(&obj_loc, &opened_type))) HGOTO_ERROR(H5E_OHDR, H5E_CANTOPENOBJ, FAIL, "unable to open object") + /* Get an ID for the visited object */ + if((obj_id = H5VL_native_register(opened_type, obj, TRUE)) < 0) + HGOTO_ERROR(H5E_ATOM, H5E_CANTREGISTER, FAIL, "unable to register visited object") + /* Make callback for starting object */ if((ret_value = op(obj_id, ".", &oinfo, op_data)) < 0) HGOTO_ERROR(H5E_OHDR, H5E_BADITER, FAIL, "can't visit objects") @@ -2663,6 +2672,7 @@ H5O__visit(H5G_loc_t *loc, const char *obj_name, H5_index_t idx_type, /* Check for object being a group */ if(oinfo.type == H5O_TYPE_GROUP) { H5G_loc_t start_loc; /* Location of starting group */ + H5G_loc_t vis_loc; /* Location of visited group */ /* Get the location of the starting group */ if(H5G_loc(obj_id, &start_loc) < 0) @@ -2697,12 +2707,17 @@ H5O__visit(H5G_loc_t *loc, const char *obj_name, H5_index_t idx_type, HGOTO_ERROR(H5E_OHDR, H5E_CANTINSERT, FAIL, "can't insert object node into visited list") } + /* Get the location of the visited group */ + if(H5G_loc(obj_id, &vis_loc) < 0) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a location") + /* Call internal group visitation routine */ - if((ret_value = H5G_visit(&start_loc, ".", idx_type, order, H5O__visit_cb, &udata)) < 0) + if((ret_value = H5G_visit(&vis_loc, ".", idx_type, order, H5O__visit_cb, &udata)) < 0) HGOTO_ERROR(H5E_OHDR, H5E_BADITER, FAIL, "object visitation failed") } /* end if */ done: +/* XXX (VOL MERGE): Probably also want to consider closing obj here on failures */ if(obj_id != H5I_INVALID_HID) { if(H5I_dec_app_ref(obj_id) < 0) HDONE_ERROR(H5E_OHDR, H5E_CANTRELEASE, FAIL, "unable to close object") diff --git a/src/H5Opkg.h b/src/H5Opkg.h index ea654d2..7254edb 100644 --- a/src/H5Opkg.h +++ b/src/H5Opkg.h @@ -339,7 +339,7 @@ typedef struct H5O_obj_class_t { void *(*get_copy_file_udata)(void); /*retrieve user data for 'copy file' operation */ void (*free_copy_file_udata)(void *); /*free user data for 'copy file' operation */ htri_t (*isa)(const H5O_t *); /*if a header matches an object class */ - hid_t (*open)(const H5G_loc_t *, hbool_t ); /*open an object of this class */ + void *(*open)(const H5G_loc_t *, H5I_type_t *); /*open an object of this class */ void *(*create)(H5F_t *, void *, H5G_loc_t *); /*create an object of this class */ H5O_loc_t *(*get_oloc)(hid_t ); /*get the object header location for an object */ herr_t (*bh_info)(const H5O_loc_t *loc, H5O_t *oh, H5_ih_info_t *bh_info); /*get the index & heap info for an object */ @@ -414,6 +414,12 @@ typedef struct H5O_chk_cache_ud_t { H5O_common_cache_ud_t common; /* Common object header cache callback info */ } H5O_chk_cache_ud_t; +/* types for object optional VOL operations */ +typedef enum H5VL_object_optional_t { + H5VL_OBJECT_GET_COMMENT, /* get object comment */ + H5VL_OBJECT_GET_INFO, /* get object info */ + H5VL_OBJECT_SET_COMMENT /* set object comment */ +} H5VL_object_optional_t; /* Header message ID to class mapping */ H5_DLLVAR const H5O_msg_class_t *const H5O_msg_class_g[H5O_MSG_TYPES]; diff --git a/src/H5Oprivate.h b/src/H5Oprivate.h index 4a401b5..048e13e 100644 --- a/src/H5Oprivate.h +++ b/src/H5Oprivate.h @@ -43,6 +43,7 @@ typedef struct H5O_fill_t H5O_fill_t; #include "H5HGprivate.h" /* Global Heaps */ #include "H5SLprivate.h" /* Skip lists */ #include "H5Tprivate.h" /* Datatype functions */ +#include "H5VLprivate.h" #include "H5Zprivate.h" /* I/O pipeline filters */ /* Forward references of package typedefs */ @@ -866,10 +867,10 @@ H5_DLL herr_t H5O_init(void); H5_DLL herr_t H5O_create(H5F_t *f, size_t size_hint, size_t initial_rc, hid_t ocpl_id, H5O_loc_t *loc/*out*/); H5_DLL herr_t H5O_open(H5O_loc_t *loc); -H5_DLL hid_t H5O_open_by_idx(const H5G_loc_t *loc, const char *name, - H5_index_t idx_type, H5_iter_order_t order, hsize_t n); -H5_DLL hid_t H5O_open_by_addr(const H5G_loc_t *loc, haddr_t addr); -H5_DLL hid_t H5O_open_by_loc(const H5G_loc_t *obj_loc, hbool_t app_ref); +H5_DLL void *H5O_open_by_idx(const H5G_loc_t *loc, const char *name, + H5_index_t idx_type, H5_iter_order_t order, hsize_t n, H5I_type_t *opened_type/*out*/); +H5_DLL void *H5O_open_by_addr(const H5G_loc_t *loc, haddr_t addr, H5I_type_t *opened_type/*out*/); +H5_DLL void *H5O_open_by_loc(const H5G_loc_t *obj_loc, H5I_type_t *opened_type/*out*/); H5_DLL herr_t H5O_close(H5O_loc_t *loc, hbool_t *file_closed/*out*/); H5_DLL int H5O_link(const H5O_loc_t *loc, int adjust); H5_DLL H5O_t *H5O_protect(const H5O_loc_t *loc, unsigned prot_flags, hbool_t pin_all_chunks); @@ -887,7 +888,7 @@ H5_DLL herr_t H5O_get_hdr_info(const H5O_loc_t *oloc, H5O_hdr_info_t *hdr); H5_DLL herr_t H5O_get_info(const H5O_loc_t *oloc, H5O_info_t *oinfo, unsigned fields); H5_DLL herr_t H5O_obj_type(const H5O_loc_t *loc, H5O_type_t *obj_type); H5_DLL herr_t H5O_get_create_plist(const H5O_loc_t *loc, struct H5P_genplist_t *oc_plist); -H5_DLL hid_t H5O_open_name(const H5G_loc_t *loc, const char *name, hbool_t app_ref); +H5_DLL void *H5O_open_name(const H5G_loc_t *loc, const char *name, H5I_type_t *opened_type/*out*/); H5_DLL herr_t H5O_get_nlinks(const H5O_loc_t *loc, hsize_t *nlinks); H5_DLL void *H5O_obj_create(H5F_t *f, H5O_type_t obj_type, void *crt_info, H5G_loc_t *obj_loc); H5_DLL haddr_t H5O_get_oh_addr(const H5O_t *oh); @@ -945,7 +946,7 @@ H5_DLL herr_t H5O_msg_get_flags(const H5O_loc_t *loc, unsigned type_id, uint8_t H5_DLL herr_t H5O_flush(H5O_loc_t *oloc, hid_t obj_id); H5_DLL herr_t H5O_flush_common(H5O_loc_t *oloc, hid_t obj_id); H5_DLL herr_t H5O_refresh_metadata(hid_t oid, H5O_loc_t oloc); -H5_DLL herr_t H5O_refresh_metadata_reopen(hid_t oid, H5G_loc_t *obj_loc, hbool_t start_swmr); +H5_DLL herr_t H5O_refresh_metadata_reopen(hid_t oid, H5G_loc_t *obj_loc, H5VL_t *vol_driver, hbool_t start_swmr); /* Object copying routines */ H5_DLL herr_t H5O_copy_header_map(const H5O_loc_t *oloc_src, H5O_loc_t *oloc_dst /*out */, diff --git a/src/H5PLint.c b/src/H5PLint.c index b190746..166b300 100644 --- a/src/H5PLint.c +++ b/src/H5PLint.c @@ -30,6 +30,7 @@ #include "H5Eprivate.h" /* Error handling */ #include "H5MMprivate.h" /* Memory management */ #include "H5PLpkg.h" /* Plugin */ +#include "H5VLprivate.h" /* Virtual Object Layer */ #include "H5Zprivate.h" /* Filter pipeline */ @@ -250,6 +251,10 @@ H5PL_load(H5PL_type_t type, H5PL_key_t key) if ((H5PL_plugin_control_mask_g & H5PL_FILTER_PLUGIN) == 0) HGOTO_ERROR(H5E_PLUGIN, H5E_CANTLOAD, NULL, "filter plugins disabled") break; + case H5PL_TYPE_VOL: + if((H5PL_plugin_control_mask_g & H5PL_VOL_PLUGIN) == 0) + HGOTO_ERROR(H5E_PLUGIN, H5E_CANTLOAD, NULL, "Virtual Object Layer (VOL) driver plugins disabled") + break; case H5PL_TYPE_ERROR: case H5PL_TYPE_NONE: default: @@ -352,6 +357,22 @@ H5PL__open(const char *path, H5PL_type_t type, H5PL_key_t key, hbool_t *success, break; } + case H5PL_TYPE_VOL: + { + const H5VL_class_t *cls = NULL; + + /* Get the plugin info */ + if (NULL == (cls = (const H5VL_class_t *)(*get_plugin_info)())) + HGOTO_ERROR(H5E_PLUGIN, H5E_CANTGET, FAIL, "can't get VOL driver info from plugin") + + /* If the plugin names match, we're done. Set the output parameters. */ + if (cls->name && !HDstrcmp(cls->name, key.name)) { + *plugin_info = (const void *)cls; + *success = TRUE; + } + + break; + } case H5PL_TYPE_ERROR: case H5PL_TYPE_NONE: default: diff --git a/src/H5PLprivate.h b/src/H5PLprivate.h index cc2e258..2af1b70 100644 --- a/src/H5PLprivate.h +++ b/src/H5PLprivate.h @@ -36,6 +36,7 @@ /* The key that will be used to find the plugin */ typedef union H5PL_key_t { int id; /* filters */ + const char *name; /* VOL drivers */ } H5PL_key_t; diff --git a/src/H5PLpublic.h b/src/H5PLpublic.h index fe5bdfb..8e022cc 100644 --- a/src/H5PLpublic.h +++ b/src/H5PLpublic.h @@ -32,11 +32,13 @@ typedef enum H5PL_type_t { H5PL_TYPE_ERROR = -1, /* Error */ H5PL_TYPE_FILTER = 0, /* Filter */ - H5PL_TYPE_NONE = 1 /* This must be last! */ + H5PL_TYPE_VOL = 1, /* VOL driver */ + H5PL_TYPE_NONE = 2 /* This must be last! */ } H5PL_type_t; /* Common dynamic plugin type flags used by the set/get_loading_state functions */ #define H5PL_FILTER_PLUGIN 0x0001 +#define H5PL_VOL_PLUGIN 0x0002 #define H5PL_ALL_PLUGIN 0xFFFF #ifdef __cplusplus diff --git a/src/H5Pacpl.c b/src/H5Pacpl.c index 530ede3..2322c76 100644 --- a/src/H5Pacpl.c +++ b/src/H5Pacpl.c @@ -33,12 +33,17 @@ #include "H5private.h" /* Generic Functions */ #include "H5Eprivate.h" /* Error handling */ #include "H5Ppkg.h" /* Property lists */ +#include "H5VLprivate.h" /* Virtual Object Layer */ /****************/ /* Local Macros */ /****************/ +/* Definitions for locations parameters */ +#define H5A_CRT_LOCATION_SIZE sizeof(H5VL_loc_params_t) +#define H5A_CRT_LOCATION_DEF H5I_BADID + /******************/ /* Local Typedefs */ @@ -54,6 +59,9 @@ /* Local Prototypes */ /********************/ +/* Property class callbacks */ +static herr_t H5P_acrt_reg_prop(H5P_genclass_t *pclass); + /*********************/ /* Package Variables */ @@ -68,7 +76,7 @@ const H5P_libclass_t H5P_CLS_ACRT[1] = {{ &H5P_CLS_ATTRIBUTE_CREATE_g, /* Pointer to class */ &H5P_CLS_ATTRIBUTE_CREATE_ID_g, /* Pointer to class ID */ &H5P_LST_ATTRIBUTE_CREATE_ID_g, /* Pointer to default property list ID */ - NULL, /* Default property registration routine */ + H5P_acrt_reg_prop, /* Default property registration routine */ NULL, /* Class creation callback */ NULL, /* Class creation callback info */ @@ -83,4 +91,44 @@ const H5P_libclass_t H5P_CLS_ACRT[1] = {{ /* Library Private Variables */ /*****************************/ + +/*------------------------------------------------------------------------- + * Function: H5P_acrt_reg_prop + * + * Purpose: Register the attribute creation property list class's properties + * + * Return: SUCCEED/FAIL + * + *------------------------------------------------------------------------- + */ +static herr_t +H5P_acrt_reg_prop(H5P_genclass_t *pclass) +{ + hid_t type_id = H5I_INVALID_HID; + hid_t space_id = H5I_INVALID_HID; + H5VL_loc_params_t loc_params; + herr_t ret_value = SUCCEED; + + FUNC_ENTER_NOAPI_NOINIT + + /* Register the type ID property*/ + if(H5P__register_real(pclass, H5VL_PROP_ATTR_TYPE_ID, sizeof(hid_t), &type_id, + NULL, NULL, 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, H5VL_PROP_ATTR_SPACE_ID, sizeof(hid_t), &space_id, + NULL, NULL, 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 */ + HDmemset(&loc_params, 0, sizeof(H5VL_loc_params_t)); + loc_params.obj_type = H5A_CRT_LOCATION_DEF; + if(H5P__register_real(pclass, H5VL_PROP_ATTR_LOC_PARAMS, H5A_CRT_LOCATION_SIZE, &loc_params, + NULL, NULL, 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_acrt_reg_prop() */ diff --git a/src/H5Pdcpl.c b/src/H5Pdcpl.c index 7e9fc52..a5a16bb 100644 --- a/src/H5Pdcpl.c +++ b/src/H5Pdcpl.c @@ -240,6 +240,9 @@ static hbool_t H5P_dcrt_def_layout_init_g = FALSE; static herr_t H5P__dcrt_reg_prop(H5P_genclass_t *pclass) { + hid_t type_id = H5I_INVALID_HID; + hid_t space_id = H5I_INVALID_HID; + hid_t lcpl_id = H5P_LINK_CREATE_DEFAULT; herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_STATIC @@ -268,6 +271,21 @@ H5P__dcrt_reg_prop(H5P_genclass_t *pclass) H5D_CRT_EXT_FILE_LIST_DEL, H5D_CRT_EXT_FILE_LIST_COPY, H5D_CRT_EXT_FILE_LIST_CMP, H5D_CRT_EXT_FILE_LIST_CLOSE) < 0) HGOTO_ERROR(H5E_PLIST, H5E_CANTINSERT, FAIL, "can't insert property into class") + /* Register the type ID property*/ + if(H5P__register_real(pclass, H5VL_PROP_DSET_TYPE_ID, sizeof(hid_t), &type_id, + NULL, NULL, NULL, NULL, NULL, NULL, NULL, H5P_ignore_cmp, 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, H5VL_PROP_DSET_SPACE_ID, sizeof(hid_t), &space_id, + NULL, NULL, NULL, NULL, NULL, NULL, NULL, H5P_ignore_cmp, 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, H5VL_PROP_DSET_LCPL_ID, sizeof(hid_t), &lcpl_id, + NULL, NULL, NULL, NULL, NULL, NULL, NULL, H5P_ignore_cmp, 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/H5Pfapl.c b/src/H5Pfapl.c index 5320da1..0340b67 100644 --- a/src/H5Pfapl.c +++ b/src/H5Pfapl.c @@ -39,6 +39,7 @@ #include "H5Iprivate.h" /* IDs */ #include "H5MMprivate.h" /* Memory Management */ #include "H5Ppkg.h" /* Property lists */ +#include "H5VLprivate.h" /* VOL drivers */ /* Includes needed to set as default file driver */ #include "H5FDsec2.h" /* Posix unbuffered I/O file driver */ @@ -47,6 +48,9 @@ #include "H5FDwindows.h" /* Win32 I/O */ #endif +/* Includes needed to set the default VOL driver */ +#include "H5VLnative.h" /* Native HDF5 file VOL driver */ + /****************/ /* Local Macros */ @@ -258,6 +262,16 @@ #define H5F_ACS_PAGE_BUFFER_MIN_RAW_PERC_DEF 0 #define H5F_ACS_PAGE_BUFFER_MIN_RAW_PERC_ENC H5P__encode_unsigned #define H5F_ACS_PAGE_BUFFER_MIN_RAW_PERC_DEC H5P__decode_unsigned +/* Definition for file VOL driver properties (ID, etc.) */ +#define H5F_ACS_VOL_SIZE sizeof(H5VL_driver_prop_t) +#define H5F_ACS_VOL_DEF {H5_DEFAULT_VOL, NULL} +#define H5F_ACS_VOL_CRT H5P__facc_vol_create +#define H5F_ACS_VOL_SET H5P__facc_vol_set +#define H5F_ACS_VOL_GET H5P__facc_vol_get +#define H5F_ACS_VOL_DEL H5P__facc_vol_del +#define H5F_ACS_VOL_COPY H5P__facc_vol_copy +#define H5F_ACS_VOL_CMP H5P__facc_vol_cmp +#define H5F_ACS_VOL_CLOSE H5P__facc_vol_close /******************/ @@ -320,6 +334,15 @@ static int H5P__facc_cache_image_config_cmp(const void *_config1, const void *_c static herr_t H5P__facc_cache_image_config_enc(const void *value, void **_pp, size_t *size); static herr_t H5P__facc_cache_image_config_dec(const void **_pp, void *_value); +/* VOL driver callbacks */ +static herr_t H5P__facc_vol_create(const char *name, size_t size, void *value); +static herr_t H5P__facc_vol_set(hid_t prop_id, const char *name, size_t size, void *value); +static herr_t H5P__facc_vol_get(hid_t prop_id, const char *name, size_t size, void *value); +static herr_t H5P__facc_vol_del(hid_t prop_id, const char *name, size_t size, void *value); +static herr_t H5P__facc_vol_copy(const char *name, size_t size, void *value); +static int H5P__facc_vol_cmp(const void *value1, const void *value2, size_t size); +static herr_t H5P__facc_vol_close(const char *name, size_t size, void *value); + /*********************/ /* Package Variables */ @@ -414,6 +437,7 @@ static herr_t H5P__facc_reg_prop(H5P_genclass_t *pclass) { const H5FD_driver_prop_t def_driver_prop = H5F_ACS_FILE_DRV_DEF; /* Default VFL driver ID & info (initialized from a variable) */ + const H5VL_driver_prop_t def_vol_prop = H5F_ACS_VOL_DEF; /* Default VOL driver ID & info (initialized from a variable) */ herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_STATIC @@ -644,6 +668,13 @@ H5P__facc_reg_prop(H5P_genclass_t *pclass) NULL, NULL, NULL, NULL) < 0) HGOTO_ERROR(H5E_PLIST, H5E_CANTINSERT, FAIL, "can't insert property into class") + /* Register the file VOL driver ID & info */ + /* (Note: this property should not have an encode/decode callback -QAK) */ + if(H5P__register_real(pclass, H5F_ACS_VOL_DRV_NAME, H5F_ACS_VOL_SIZE, &def_vol_prop, + H5F_ACS_VOL_CRT, H5F_ACS_VOL_SET, H5F_ACS_VOL_GET, NULL, NULL, + H5F_ACS_VOL_DEL, H5F_ACS_VOL_COPY, H5F_ACS_VOL_CMP, H5F_ACS_VOL_CLOSE) < 0) + HGOTO_ERROR(H5E_PLIST, H5E_CANTINSERT, FAIL, "can't insert property into class") + done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5P__facc_reg_prop() */ @@ -4939,3 +4970,495 @@ done: FUNC_LEAVE_API(ret_value) } /* end H5Pget_page_buffer_size() */ + +/*------------------------------------------------------------------------- + * Function: H5P_set_vol + * + * Purpose: Set the VOL driver for a file access property list + * (PLIST_ID). The vol properties will + * be copied into the property list and the reference count on + * the vol will be incremented. + * + * Return: SUCCEED/FAIL + * + *------------------------------------------------------------------------- + */ +herr_t +H5P_set_vol(H5P_genplist_t *plist, hid_t vol_id, const void *vol_info) +{ + herr_t ret_value = SUCCEED; /* Return value */ + + FUNC_ENTER_NOAPI(FAIL) + + if(NULL == H5I_object_verify(vol_id, H5I_VOL)) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a VOL driver ID") + + if(TRUE == H5P_isa_class(plist->plist_id, H5P_FILE_ACCESS)) { + H5VL_driver_prop_t vol_prop; /* Property for VOL ID & info */ + + /* Prepare the VOL driver property */ + vol_prop.driver_id = vol_id; + vol_prop.driver_info = vol_info; + + /* Set the driver ID & info property */ + if(H5P_set(plist, H5F_ACS_VOL_DRV_NAME, &vol_prop) < 0) + HGOTO_ERROR(H5E_PLIST, H5E_CANTSET, FAIL, "can't set VOL driver ID & info") + } + else + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a file access property list"); + +done: + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5P_set_vol() */ + + +/*------------------------------------------------------------------------- + * Function: H5Pset_vol + * + * Purpose: Set the file VOL driver (VOL_ID) for a file access + * property list (PLIST_ID) + * + * Return: Success: Non-negative + * Failure: Negative + * + *------------------------------------------------------------------------- + */ +herr_t +H5Pset_vol(hid_t plist_id, hid_t new_vol_id, const void *new_vol_info) +{ + H5P_genplist_t *plist; /* Property list pointer */ + herr_t ret_value = SUCCEED; /* Return value */ + + FUNC_ENTER_API(FAIL) + H5TRACE3("e", "ii*x", plist_id, new_vol_id, new_vol_info); + + /* Check arguments */ + if(NULL == (plist = (H5P_genplist_t *)H5I_object_verify(plist_id, H5I_GENPROP_LST))) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a property list") + if(NULL == H5I_object_verify(new_vol_id, H5I_VOL)) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a file vol ID") + + /* Set the vol */ + if(H5P_set_vol(plist, new_vol_id, new_vol_info) < 0) + HGOTO_ERROR(H5E_PLIST, H5E_CANTSET, FAIL, "can't set vol") + +done: + FUNC_LEAVE_API(ret_value) +} /* end H5Pset_vol() */ + + +/*------------------------------------------------------------------------- + * Function: H5P_get_vol_info + * + * Purpose: Returns a pointer directly to the file vol-specific + * information of a file access property list. + * + * Return: Success: Ptr to *uncopied* vol specific data + * structure if any. + * + * Failure: NULL. Null is also returned if the vol has + * not registered any vol-specific properties + * although no error is pushed on the stack in + * this case. + * + *------------------------------------------------------------------------- + */ +void * +H5P_get_vol_info(H5P_genplist_t *plist) +{ + void *ret_value = NULL; + + FUNC_ENTER_NOAPI(NULL) + + /* Get the current vol info */ + if(TRUE == H5P_isa_class(plist->plist_id, H5P_FILE_ACCESS)) { + H5VL_driver_prop_t driver_prop; /* Property for vol driver ID & info */ + + if(H5P_peek(plist, H5F_ACS_VOL_DRV_NAME, &driver_prop) < 0) + HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, NULL, "can't get vol driver info") + ret_value = (void *)driver_prop.driver_info; + } else + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, NULL, "not a file access property list") + +done: + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5P_get_vol_info() */ + + +/*------------------------------------------------------------------------- + * Function: H5Pget_vol_info + * + * Purpose: Returns a pointer directly to the file vol-specific + * information of a file access property list. + * + * XXX (VOL MERGE): This API call seems like a REALLY bad idea - DER + * + * Return: Success: Ptr to *uncopied* vol specific data + * structure if any. + * + * Failure: NULL. Null is also returned if the vol has + * not registered any vol-specific properties + * although no error is pushed on the stack in + * this case. + * + *------------------------------------------------------------------------- + */ +void * +H5Pget_vol_info(hid_t plist_id) +{ + H5P_genplist_t *plist; /* Property list pointer */ + void *ret_value; /* Return value */ + + FUNC_ENTER_API(NULL) + H5TRACE1("*x", "i", plist_id); + + if(NULL == (plist = (H5P_genplist_t *)H5I_object_verify(plist_id, H5I_GENPROP_LST))) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, NULL, "not a property list") + + if(NULL == (ret_value = H5P_get_vol_info(plist))) + HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, NULL, "can't get vol info") + +done: + FUNC_LEAVE_API(ret_value) +} /* end H5Pget_vol_info() */ + + +/*------------------------------------------------------------------------- + * Function: H5P__vol_copy + * + * Purpose: Copy VOL driver ID & info. + * + * Note: This is an "in-place" copy, since this routine gets called + * after the top-level copy has been performed and this routine + * finishes the "deep" part of the copy. + * + * Return: Success: Non-negative + * Failure: Negative + * + *------------------------------------------------------------------------- + */ +static herr_t +H5P__vol_copy(void *value) +{ + herr_t ret_value = SUCCEED; /* Return value */ + + FUNC_ENTER_STATIC + + if(value) { + H5VL_driver_prop_t *info = (H5VL_driver_prop_t *)value; /* Driver ID & info struct */ + + /* Copy the driver ID & info, if there is one */ + if(info->driver_id > 0) { + /* Increment the reference count on driver ID and copy driver info */ + if(H5I_inc_ref(info->driver_id, FALSE) < 0) + HGOTO_ERROR(H5E_PLIST, H5E_CANTINC, FAIL, "unable to increment ref count on VOL driver ID") + + /* Copy driver info, if it exists */ + if(info->driver_info) { + H5VL_class_t *driver; /* Pointer to driver */ + void *new_driver; /* Copy of driver info */ + + /* Retrieve the driver for the ID */ + if(NULL == (driver = (H5VL_class_t *)H5I_object(info->driver_id))) + HGOTO_ERROR(H5E_PLIST, H5E_BADTYPE, FAIL, "not a VOL driver ID") + + /* Allow the driver to copy or do it ourselves */ + if(driver->fapl_copy) { + if(NULL == (new_driver = (driver->fapl_copy)(info->driver_info))) + HGOTO_ERROR(H5E_PLIST, H5E_CANTCOPY, FAIL, "driver info copy failed") + } + else if(driver->fapl_size > 0) { + if(NULL == (new_driver = H5MM_malloc(driver->fapl_size))) + HGOTO_ERROR(H5E_PLIST, H5E_CANTALLOC, FAIL, "driver info allocation failed") + HDmemcpy(new_driver, info->driver_info, driver->fapl_size); + } + else + HGOTO_ERROR(H5E_PLIST, H5E_UNSUPPORTED, FAIL, "no way to copy driver info") + + /* Set the driver info for the copy */ + info->driver_info = new_driver; + } + } + } + +done: + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5P__vol_copy() */ + + +/*------------------------------------------------------------------------- + * Function: H5P__vol_free + * + * Purpose: Free VOL driver ID & info. + * + * Return: Success: Non-negative + * Failure: Negative + * + *------------------------------------------------------------------------- + */ +static herr_t +H5P__vol_free(void *value) +{ + herr_t ret_value = SUCCEED; /* Return value */ + + FUNC_ENTER_STATIC + + if(value) { + H5VL_driver_prop_t *info = (H5VL_driver_prop_t *)value; /* Driver ID & info struct */ + + /* Free the driver info (if it exists) and decrement the ID */ + if(info->driver_id > 0) { + if(info->driver_info) { + H5VL_class_t *driver; /* Pointer to driver */ + + /* Retrieve the driver for the ID */ + if(NULL == (driver = (H5VL_class_t *)H5I_object(info->driver_id))) + HGOTO_ERROR(H5E_PLIST, H5E_BADTYPE, FAIL, "not a VOL driver ID") + + /* Allow the driver to free info or do it ourselves */ + if(driver->fapl_free) { + if((driver->fapl_free)((void *)info->driver_info) < 0) /* Casting away const OK -QAK */ + HGOTO_ERROR(H5E_PLIST, H5E_CANTFREE, FAIL, "driver info free request failed") + } + else + H5MM_xfree((void *)info->driver_info); /* Casting away const OK -QAK */ + } + + /* Decrement reference count for driver ID */ + if(H5I_dec_ref(info->driver_id) < 0) + HGOTO_ERROR(H5E_PLIST, H5E_CANTDEC, FAIL, "can't decrement reference count for driver ID") + } + } + +done: + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5P__vol_free() */ + + +/*------------------------------------------------------------------------- + * Function: H5P__facc_vol_create + * + * Purpose: Create callback for the VOL driver ID & info property. + * + * Return: Success: Non-negative + * Failure: Negative + * + *------------------------------------------------------------------------- + */ +static herr_t +H5P__facc_vol_create(const char H5_ATTR_UNUSED *name, size_t H5_ATTR_UNUSED size, void *value) +{ + herr_t ret_value = SUCCEED; /* Return value */ + + FUNC_ENTER_STATIC + + /* Make copy of the VOL driver */ + if(H5P__vol_copy(value) < 0) + HGOTO_ERROR(H5E_PLIST, H5E_CANTCOPY, FAIL, "can't copy VOL driver") + +done: + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5P__facc_vol_create() */ + + +/*------------------------------------------------------------------------- + * Function: H5P__facc_vol_set + * + * Purpose: Copies a VOL driver property when it's set for a property list + * + * Return: Success: Non-negative + * Failure: Negative + * + *------------------------------------------------------------------------- + */ +static herr_t +H5P__facc_vol_set(hid_t H5_ATTR_UNUSED prop_id, const char H5_ATTR_UNUSED *name, + size_t H5_ATTR_UNUSED size, void *value) +{ + herr_t ret_value = SUCCEED; /* Return value */ + + FUNC_ENTER_STATIC + + /* Sanity check */ + HDassert(value); + + /* Make copy of VOL driver ID & info */ + if(H5P__vol_copy(value) < 0) + HGOTO_ERROR(H5E_PLIST, H5E_CANTCOPY, FAIL, "can't copy VOL driver") + +done: + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5P__facc_vol_set() */ + + +/*------------------------------------------------------------------------- + * Function: H5P__facc_vol_get + * + * Purpose: Copies a VOL driver property when it's retrieved from a property list + * + * Return: Success: Non-negative + * Failure: Negative + * + *------------------------------------------------------------------------- + */ +static herr_t +H5P__facc_vol_get(hid_t H5_ATTR_UNUSED prop_id, const char H5_ATTR_UNUSED *name, + size_t H5_ATTR_UNUSED size, void *value) +{ + herr_t ret_value = SUCCEED; /* Return value */ + + FUNC_ENTER_STATIC + + /* Sanity check */ + HDassert(value); + + /* Make copy of VOL driver */ + if(H5P__vol_copy(value) < 0) + HGOTO_ERROR(H5E_PLIST, H5E_CANTCOPY, FAIL, "can't copy VOL driver") + +done: + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5P__facc_vol_get() */ + + +/*------------------------------------------------------------------------- + * Function: H5P__facc_vol_del + * + * Purpose: Frees memory used to store the VOL driver ID & info property + * + * Return: Success: Non-negative + * Failure: Negative + * + *------------------------------------------------------------------------- + */ +static herr_t +H5P__facc_vol_del(hid_t H5_ATTR_UNUSED prop_id, const char H5_ATTR_UNUSED *name, size_t H5_ATTR_UNUSED size, void *value) +{ + herr_t ret_value = SUCCEED; /* Return value */ + + FUNC_ENTER_STATIC + + /* Free the VOL driver ID & info */ + if(H5P__vol_free(value) < 0) + HGOTO_ERROR(H5E_PLIST, H5E_CANTRELEASE, FAIL, "can't release VOL driver") + +done: + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5P__facc_vol_del() */ + + +/*------------------------------------------------------------------------- + * Function: H5P__facc_vol_copy + * + * Purpose: Copy callback for the VOL driver ID & info property. + * + * Return: Success: Non-negative + * Failure: Negative + * + *------------------------------------------------------------------------- + */ +static herr_t +H5P__facc_vol_copy(const char H5_ATTR_UNUSED *name, size_t H5_ATTR_UNUSED size, void *value) +{ + herr_t ret_value = SUCCEED; /* Return value */ + + FUNC_ENTER_STATIC + + /* Make copy of VOL driver */ + if(H5P__vol_copy(value) < 0) + HGOTO_ERROR(H5E_PLIST, H5E_CANTCOPY, FAIL, "can't copy VOL driver") + +done: + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5P__facc_vol_copy() */ + + +/*------------------------------------------------------------------------- + * Function: H5P__facc_vol_cmp + * + * Purpose: Callback routine which is called whenever the VOL driver + * ID & info property in the file access property list + * is compared. + * + * Return: positive if VALUE1 is greater than VALUE2, negative if + * VALUE2 is greater than VALUE1 and zero if VALUE1 and + * VALUE2 are equal. + * + *------------------------------------------------------------------------- + */ +static int +H5P__facc_vol_cmp(const void *_info1, const void *_info2, size_t H5_ATTR_UNUSED size) +{ + const H5VL_driver_prop_t *info1 = (const H5VL_driver_prop_t *)_info1; /* Create local aliases for values */ + const H5VL_driver_prop_t *info2 = (const H5VL_driver_prop_t *)_info2; + H5VL_class_t *cls1, *cls2; /* Driver class for each property */ + int cmp_value; /* Value from comparison */ + herr_t ret_value = 0; /* Return value */ + + FUNC_ENTER_STATIC_NOERR + + /* Sanity check */ + HDassert(info1); + HDassert(info2); + HDassert(size == sizeof(H5VL_driver_prop_t)); + + /* Compare drivers */ + if(NULL == (cls1 = (H5VL_class_t *)H5I_object(info1->driver_id))) + HGOTO_DONE(-1) + if(NULL == (cls2 = (H5VL_class_t *)H5I_object(info2->driver_id))) + HGOTO_DONE(1) + if(cls1->name == NULL && cls2->name != NULL) + HGOTO_DONE(-1); + if(cls1->name != NULL && cls2->name == NULL) + HGOTO_DONE(1); + if(0 != (cmp_value = HDstrcmp(cls1->name, cls2->name))) + HGOTO_DONE(cmp_value); + + /* Compare driver info */ + if(cls1->fapl_size < cls2->fapl_size) + HGOTO_DONE(-1) + if(cls1->fapl_size > cls2->fapl_size) + HGOTO_DONE(1) + HDassert(cls1->fapl_size == cls2->fapl_size); + + if(info1->driver_info == NULL && info2->driver_info != NULL) + HGOTO_DONE(-1); + if(info1->driver_info != NULL && info2->driver_info == NULL) + HGOTO_DONE(1); + if(info1->driver_info) { + HDassert(cls1->fapl_size > 0); + if(0 != (cmp_value = HDmemcmp(info1->driver_info, info2->driver_info, cls1->fapl_size))) + HGOTO_DONE(cmp_value); + } + +done: + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5P__facc_vol_cmp() */ + + +/*------------------------------------------------------------------------- + * Function: H5P__facc_vol_close + * + * Purpose: Close callback for the VOL driver ID & info property. + * + * Return: Success: Non-negative + * Failure: Negative + * + *------------------------------------------------------------------------- + */ +static herr_t +H5P__facc_vol_close(const char H5_ATTR_UNUSED *name, size_t H5_ATTR_UNUSED size, void *value) +{ + herr_t ret_value = SUCCEED; /* Return value */ + + FUNC_ENTER_STATIC + + /* Free the VOL driver */ + if(H5P__vol_free(value) < 0) + HGOTO_ERROR(H5E_PLIST, H5E_CANTRELEASE, FAIL, "can't release VOL driver") + +done: + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5P__facc_vol_close() */ + + diff --git a/src/H5Pgcpl.c b/src/H5Pgcpl.c index e2fdcea..ab289e4 100644 --- a/src/H5Pgcpl.c +++ b/src/H5Pgcpl.c @@ -128,6 +128,7 @@ static const H5O_linfo_t H5G_def_linfo_g = H5G_CRT_LINK_INFO_DEF; /* Defaul static herr_t H5P__gcrt_reg_prop(H5P_genclass_t *pclass) { + hid_t lcpl_id = H5P_LINK_CREATE_DEFAULT; herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_STATIC @@ -144,6 +145,11 @@ H5P__gcrt_reg_prop(H5P_genclass_t *pclass) 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, H5VL_PROP_GRP_LCPL_ID, sizeof(hid_t), &lcpl_id, + NULL, NULL, 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/H5Pint.c b/src/H5Pint.c index 179f883..e2ae792 100644 --- a/src/H5Pint.c +++ b/src/H5Pint.c @@ -5452,3 +5452,22 @@ H5P_get_class(const H5P_genplist_t *plist) FUNC_LEAVE_NOAPI(plist->pclass) } /* end H5P_get_class() */ + +/*------------------------------------------------------------------------- + * Function: H5P_ignore_cmp + * + * Purpose: Callback routine to ignore comparing property values. + * + * Return: zero + * + *------------------------------------------------------------------------- + */ +int +H5P_ignore_cmp(const void H5_ATTR_UNUSED *val1, const void H5_ATTR_UNUSED *val2, + size_t H5_ATTR_UNUSED size) +{ + FUNC_ENTER_NOAPI_NOINIT_NOERR + + FUNC_LEAVE_NOAPI(0) +} /* end H5P_ignore_cmp() */ + diff --git a/src/H5Plcpl.c b/src/H5Plcpl.c index 1d45bed..6568ecd 100644 --- a/src/H5Plcpl.c +++ b/src/H5Plcpl.c @@ -48,6 +48,31 @@ #define H5L_CRT_INTERMEDIATE_GROUP_ENC H5P__encode_unsigned #define H5L_CRT_INTERMEDIATE_GROUP_DEC H5P__decode_unsigned +/* ======== VOL specific properties ========= */ +/* Definitions for target object ID */ +#define H5L_CRT_TARGET_SIZE sizeof(void *) +#define H5L_CRT_TARGET_DEF NULL + +/* Definitions for Location params */ +#define H5L_CRT_LOCATION_SIZE sizeof(H5VL_loc_params_t) +#define H5L_CRT_LOCATION_DEF {H5I_BADID, H5VL_OBJECT_BY_SELF, {HADDR_UNDEF}} + +/* 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 */ /******************/ @@ -118,6 +143,12 @@ static const unsigned H5L_def_intmd_group_g = H5L_CRT_INTERMEDIATE_GROUP_DEF; herr_t H5P_lcrt_reg_prop(H5P_genclass_t *pclass) { + void* target = H5L_CRT_TARGET_DEF; + H5VL_loc_params_t loc_params = H5L_CRT_LOCATION_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) @@ -128,6 +159,30 @@ H5P_lcrt_reg_prop(H5P_genclass_t *pclass) NULL, NULL, NULL, NULL) < 0) HGOTO_ERROR(H5E_PLIST, H5E_CANTINSERT, FAIL, "can't insert property into class") + if(H5P__register_real(pclass, H5VL_PROP_LINK_TARGET, H5L_CRT_TARGET_SIZE, &target, + NULL, NULL, 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, H5VL_PROP_LINK_TARGET_LOC_PARAMS, H5L_CRT_LOCATION_SIZE, &loc_params, + NULL, NULL, 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, H5VL_PROP_LINK_TARGET_NAME, H5L_CRT_TARGET_NAME_SIZE, &target_name, + NULL, NULL, 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, H5VL_PROP_LINK_TYPE, H5L_CRT_LINK_TYPE_SIZE, &link_type, + NULL, NULL, 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, H5VL_PROP_LINK_UDATA, H5L_CRT_UDATA_SIZE, &udata, + NULL, NULL, 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, H5VL_PROP_LINK_UDATA_SIZE, H5L_CRT_UDATA_SIZE_SIZE, &udata_size, + NULL, NULL, 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/H5Pprivate.h b/src/H5Pprivate.h index 7792671..cd749cb 100644 --- a/src/H5Pprivate.h +++ b/src/H5Pprivate.h @@ -177,6 +177,8 @@ H5_DLL hid_t H5P_peek_driver(H5P_genplist_t *plist); H5_DLL const void *H5P_peek_driver_info(H5P_genplist_t *plist); H5_DLL herr_t H5P_set_driver(H5P_genplist_t *plist, hid_t new_driver_id, const void *new_driver_info); +H5_DLL herr_t H5P_set_vol(H5P_genplist_t *plist, hid_t vol_id, const void *vol_info); +H5_DLL void * H5P_get_vol_info(H5P_genplist_t *plist); H5_DLL herr_t H5P_set_vlen_mem_manager(H5P_genplist_t *plist, H5MM_allocate_t alloc_func, void *alloc_info, H5MM_free_t free_func, void *free_info); @@ -204,6 +206,8 @@ H5_DLL herr_t H5P_fill_value_defined(H5P_genplist_t *plist, H5D_fill_value_t *status); H5_DLL herr_t H5P_get_fill_value(H5P_genplist_t *plist, const struct H5T_t *type, void *value); +H5_DLL int H5P_ignore_cmp(const void H5_ATTR_UNUSED *val1, const void H5_ATTR_UNUSED *val2, + size_t H5_ATTR_UNUSED size); #endif /* _H5Pprivate_H */ diff --git a/src/H5Ppublic.h b/src/H5Ppublic.h index c5596e5..77d8ebb 100644 --- a/src/H5Ppublic.h +++ b/src/H5Ppublic.h @@ -313,6 +313,8 @@ H5_DLL herr_t H5Pset_driver(hid_t plist_id, hid_t driver_id, const void *driver_info); H5_DLL hid_t H5Pget_driver(hid_t plist_id); H5_DLL const void *H5Pget_driver_info(hid_t plist_id); +H5_DLL herr_t H5Pset_vol(hid_t plist_id, hid_t new_vol_id, const void *new_vol_info); +H5_DLL void *H5Pget_vol_info(hid_t plist_id); H5_DLL herr_t H5Pset_family_offset(hid_t fapl_id, hsize_t offset); H5_DLL herr_t H5Pget_family_offset(hid_t fapl_id, hsize_t *offset); H5_DLL herr_t H5Pset_multi_type(hid_t fapl_id, H5FD_mem_t type); @@ -91,8 +91,8 @@ herr_t H5Rcreate(void *ref, hid_t loc_id, const char *name, H5R_type_t ref_type, hid_t space_id) { - H5G_loc_t loc; /* File location */ - H5S_t *space = NULL; /* Pointer to dataspace containing region */ + H5VL_object_t *vol_obj = NULL; /* Object token of loc_id */ + H5VL_loc_params_t loc_params; herr_t ret_value; /* Return value */ FUNC_ENTER_API(FAIL) @@ -101,8 +101,6 @@ H5Rcreate(void *ref, hid_t loc_id, const char *name, H5R_type_t ref_type, hid_t /* Check args */ if (ref == NULL) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "invalid reference pointer") - if(H5G_loc(loc_id, &loc) < 0) - HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a location") if(!name || !*name) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "no name given") if(ref_type <= H5R_BADTYPE || ref_type >= H5R_MAXTYPE) @@ -111,15 +109,27 @@ H5Rcreate(void *ref, hid_t loc_id, const char *name, H5R_type_t ref_type, hid_t HGOTO_ERROR(H5E_ARGS, H5E_UNSUPPORTED, FAIL, "reference type not supported") if(space_id == (-1) && ref_type == H5R_DATASET_REGION) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "reference region dataspace id must be valid") - if(space_id != (-1) && (NULL == (space = (H5S_t *)H5I_object_verify(space_id, H5I_DATASPACE)))) - HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a dataspace") + + /* Set up collective metadata if appropriate */ + if(H5CX_set_loc(loc_id) < 0) + HGOTO_ERROR(H5E_REFERENCE, H5E_CANTSET, FAIL, "can't set access property list info") + + /* Set location parameters */ + loc_params.type = H5VL_OBJECT_BY_SELF; + loc_params.obj_type = H5I_get_type(loc_id); + + /* Get the file object */ + if (NULL == (vol_obj = (H5VL_object_t *)H5I_object(loc_id))) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "invalid file identifier") /* Set up collective metadata if appropriate */ if(H5CX_set_loc(loc_id) < 0) HGOTO_ERROR(H5E_REFERENCE, H5E_CANTSET, FAIL, "can't set access property list info") /* Create reference */ - if((ret_value = H5R__create(ref, &loc, name, ref_type, space)) < 0) + if((ret_value = H5VL_object_specific(vol_obj->data, loc_params, vol_obj->driver->cls, H5VL_REF_CREATE, + H5P_DATASET_XFER_DEFAULT, H5_REQUEST_NULL, + ref, name, ref_type, space_id)) < 0) HGOTO_ERROR(H5E_REFERENCE, H5E_CANTCREATE, FAIL, "unable to create reference") done: @@ -157,16 +167,16 @@ 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 */ + H5VL_object_t *vol_obj = NULL; /* object token of loc_id */ + H5I_type_t opened_type; + void *opened_obj = NULL; + H5VL_loc_params_t loc_params; hid_t ret_value = H5I_INVALID_HID; /* Return value */ FUNC_ENTER_API(H5I_INVALID_HID) 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, H5I_INVALID_HID, "not a location") if(oapl_id < 0) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, H5I_INVALID_HID, "not a property list") if(ref_type <= H5R_BADTYPE || ref_type >= H5R_MAXTYPE) @@ -178,13 +188,25 @@ H5Rdereference2(hid_t obj_id, hid_t oapl_id, H5R_type_t ref_type, const void *_r if(H5CX_set_apl(&oapl_id, H5P_CLS_DACC, obj_id, FALSE) < 0) HGOTO_ERROR(H5E_REFERENCE, H5E_CANTSET, FAIL, "can't set access property list info") - /* Get the file pointer from the entry */ - file = loc.oloc->file; + /* Get the VOL object */ + if(NULL == (vol_obj = H5VL_get_object(obj_id))) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, H5I_INVALID_HID, "invalid file identifier") + + /* Set location parameters */ + loc_params.type = H5VL_OBJECT_BY_REF; + loc_params.loc_data.loc_by_ref.ref_type = ref_type; + loc_params.loc_data.loc_by_ref._ref = _ref; + loc_params.loc_data.loc_by_ref.lapl_id = oapl_id; + loc_params.obj_type = H5I_get_type(obj_id); /* Dereference */ - if((ret_value = H5R__dereference(file, oapl_id, ref_type, _ref)) < 0) + if(NULL == (opened_obj = H5VL_object_open(vol_obj->data, loc_params, vol_obj->driver->cls, + &opened_type, H5P_DATASET_XFER_DEFAULT, H5_REQUEST_NULL))) HGOTO_ERROR(H5E_REFERENCE, H5E_CANTOPENOBJ, H5I_INVALID_HID, "unable to dereference object") + if((ret_value = H5VL_register_id(opened_type, opened_obj, vol_obj->driver, TRUE)) < 0) + HGOTO_ERROR(H5E_ATOM, H5E_CANTREGISTER, H5I_INVALID_HID, "unable to register object handle") + done: FUNC_LEAVE_API(ret_value) } /* end H5Rdereference2() */ @@ -216,29 +238,32 @@ done: hid_t H5Rget_region(hid_t id, H5R_type_t ref_type, const void *ref) { - H5G_loc_t loc; /* Object's group location */ - H5S_t *space = NULL; /* Dataspace object */ + H5VL_object_t *vol_obj = NULL; /* object token of loc_id */ + H5VL_loc_params_t loc_params; hid_t ret_value = H5I_INVALID_HID; /* Return value */ FUNC_ENTER_API(H5I_INVALID_HID) H5TRACE3("i", "iRt*x", id, ref_type, ref); /* Check args */ - if(H5G_loc(id, &loc) < 0) - HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, H5I_INVALID_HID, "not a location") if(ref_type != H5R_DATASET_REGION) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, H5I_INVALID_HID, "invalid reference type") if(ref == NULL) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, H5I_INVALID_HID, "invalid reference pointer") + /* Set location parameters */ + loc_params.type = H5VL_OBJECT_BY_SELF; + loc_params.obj_type = H5I_get_type(id); + + /* get the file object */ + if(NULL == (vol_obj = (H5VL_object_t *)H5I_object(id))) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, H5I_INVALID_HID, "invalid file identifier") + /* Get the dataspace with the correct region selected */ - if(NULL == (space = H5R__get_region(loc.oloc->file, ref))) + if(H5VL_object_get(vol_obj->data, loc_params, vol_obj->driver->cls, H5VL_REF_GET_REGION, + H5P_DATASET_XFER_DEFAULT, H5_REQUEST_NULL, &ret_value, ref_type, ref) < 0) HGOTO_ERROR(H5E_REFERENCE, H5E_CANTGET, H5I_INVALID_HID, "unable to retrieve dataspace") - /* Atomize */ - if((ret_value = H5I_register(H5I_DATASPACE, space, TRUE)) < 0) - HGOTO_ERROR(H5E_ATOM, H5E_CANTREGISTER, H5I_INVALID_HID, "unable to register dataspace atom") - done: FUNC_LEAVE_API(ret_value) } /* end H5Rget_region() */ @@ -271,22 +296,31 @@ herr_t H5Rget_obj_type2(hid_t id, H5R_type_t ref_type, const void *ref, H5O_type_t *obj_type) { - H5G_loc_t loc; /* Object location */ + H5VL_object_t *vol_obj = NULL; /* object token of loc_id */ + H5VL_loc_params_t loc_params; herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_API(FAIL) H5TRACE4("e", "iRt*x*Ot", id, ref_type, ref, obj_type); /* Check args */ - if(H5G_loc(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") + /* Set location parameters */ + loc_params.type = H5VL_OBJECT_BY_SELF; + loc_params.obj_type = H5I_get_type(id); + + /* Get the file object */ + if(NULL == (vol_obj = (H5VL_object_t *)H5I_object(id))) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "invalid file identifier") + /* Get the object type */ - if(H5R__get_obj_type(loc.oloc->file, ref_type, ref, obj_type) < 0) + if(H5VL_object_get(vol_obj->data, loc_params, vol_obj->driver->cls, + H5VL_REF_GET_TYPE, H5P_DATASET_XFER_DEFAULT, + H5_REQUEST_NULL, obj_type, ref_type, ref) < 0) HGOTO_ERROR(H5E_REFERENCE, H5E_CANTGET, FAIL, "unable to determine object type") done: @@ -331,26 +365,31 @@ ssize_t H5Rget_name(hid_t id, H5R_type_t ref_type, const void *_ref, char *name, size_t size) { - H5G_loc_t loc; /* Group location */ - H5F_t *file; /* File object */ + H5VL_object_t *vol_obj = NULL; /* object token of loc_id */ + H5VL_loc_params_t loc_params; ssize_t ret_value = -1; /* Return value */ FUNC_ENTER_API((-1)) H5TRACE5("Zs", "iRt*x*sz", id, ref_type, _ref, name, size); /* Check args */ - if(H5G_loc(id, &loc) < 0) - HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, (-1), "not a location") if(ref_type <= H5R_BADTYPE || ref_type >= H5R_MAXTYPE) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, (-1), "invalid reference type") if(_ref == NULL) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, (-1), "invalid reference pointer") - /* Get the file pointer from the entry */ - file = loc.oloc->file; + /* Set location parameters */ + loc_params.type = H5VL_OBJECT_BY_SELF; + loc_params.obj_type = H5I_get_type(id); + + /* Get the file object */ + if(NULL == (vol_obj = (H5VL_object_t *)H5I_object(id))) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, (-1), "invalid file identifier") /* Get name */ - if((ret_value = H5R__get_name(file, id, ref_type, _ref, name, size)) < 0) + if(H5VL_object_get(vol_obj->data, loc_params, vol_obj->driver->cls, H5VL_REF_GET_NAME, + H5P_DATASET_XFER_DEFAULT, H5_REQUEST_NULL, + &ret_value, name, size, ref_type, _ref) < 0) HGOTO_ERROR(H5E_REFERENCE, H5E_CANTGET, (-1), "unable to determine object path") done: diff --git a/src/H5Rdeprec.c b/src/H5Rdeprec.c index 41765cf..9c1fcc5 100644 --- a/src/H5Rdeprec.c +++ b/src/H5Rdeprec.c @@ -42,6 +42,7 @@ #include "H5CXprivate.h" /* API Contexts */ #include "H5Eprivate.h" /* Error handling */ #include "H5Gprivate.h" /* Groups */ +#include "H5Iprivate.h" /* IDs */ #include "H5Oprivate.h" /* Object headers */ #include "H5Rpkg.h" /* References */ @@ -102,7 +103,8 @@ H5G_obj_t H5Rget_obj_type1(hid_t id, H5R_type_t ref_type, const void *ref) { - H5G_loc_t loc; /* Object location */ + H5VL_object_t *vol_obj = NULL; /* object token of loc_id */ + H5VL_loc_params_t loc_params; H5O_type_t obj_type; /* Object type */ H5G_obj_t ret_value; /* Return value */ @@ -110,15 +112,22 @@ H5Rget_obj_type1(hid_t id, H5R_type_t ref_type, const void *ref) H5TRACE3("Go", "iRt*x", id, ref_type, ref); /* Check args */ - if (H5G_loc(id, &loc) < 0) - HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, H5G_UNKNOWN, "not a location") if (ref_type <= H5R_BADTYPE || ref_type >= H5R_MAXTYPE) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, H5G_UNKNOWN, "invalid reference type") if (ref == NULL) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, H5G_UNKNOWN, "invalid reference pointer") + /* Set location parameters */ + loc_params.type = H5VL_OBJECT_BY_SELF; + loc_params.obj_type = H5I_get_type(id); + + /* Get the vol object */ + if (NULL == (vol_obj = H5VL_get_object(id))) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, H5G_UNKNOWN, "invalid file identifier") + /* Get the object information */ - if(H5R__get_obj_type(loc.oloc->file, ref_type, ref, &obj_type) < 0) + if (H5VL_object_get(vol_obj->data, loc_params, vol_obj->driver->cls, H5VL_REF_GET_TYPE, + H5P_DATASET_XFER_DEFAULT, H5_REQUEST_NULL, &obj_type, ref_type, ref) < 0) HGOTO_ERROR(H5E_REFERENCE, H5E_CANTGET, H5G_UNKNOWN, "unable to determine object type") /* Set return value */ @@ -148,28 +157,40 @@ 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 */ + H5VL_object_t *vol_obj = NULL; /* object token of loc_id */ + H5I_type_t opened_type; + void *opened_obj = NULL; + H5VL_loc_params_t loc_params; hid_t ret_value = H5I_INVALID_HID; /* Return value */ FUNC_ENTER_API(H5I_INVALID_HID) H5TRACE3("i", "iRt*x", obj_id, ref_type, _ref); /* Check args */ - if (H5G_loc(obj_id, &loc) < 0) - HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, H5I_INVALID_HID, "not a location") if (ref_type <= H5R_BADTYPE || ref_type >= H5R_MAXTYPE) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, H5I_INVALID_HID, "invalid reference type") if (_ref == NULL) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, H5I_INVALID_HID, "invalid reference pointer") - /* Get the file pointer from the entry */ - file = loc.oloc->file; + /* Get the VOL object */ + if (NULL == (vol_obj = H5VL_get_object(obj_id))) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, H5I_INVALID_HID, "invalid file identifier") + + loc_params.type = H5VL_OBJECT_BY_REF; + loc_params.loc_data.loc_by_ref.ref_type = ref_type; + loc_params.loc_data.loc_by_ref._ref = _ref; + loc_params.loc_data.loc_by_ref.lapl_id = H5P_DATASET_ACCESS_DEFAULT; + loc_params.obj_type = H5I_get_type(obj_id); /* Dereference */ - if((ret_value = H5R__dereference(file, H5P_DATASET_ACCESS_DEFAULT, ref_type, _ref)) < 0) + if (NULL == (opened_obj = H5VL_object_open(vol_obj->data, loc_params, vol_obj->driver->cls, &opened_type, + H5P_DATASET_XFER_DEFAULT, H5_REQUEST_NULL))) HGOTO_ERROR(H5E_REFERENCE, H5E_CANTOPENOBJ, H5I_INVALID_HID, "unable to dereference object") + /* Get an atom for the object */ + if ((ret_value = H5VL_register_id(opened_type, opened_obj, vol_obj->driver, TRUE)) < 0) + HGOTO_ERROR(H5E_ATOM, H5E_CANTREGISTER, H5I_INVALID_HID, "unable to atomize object handle") + done: FUNC_LEAVE_API(ret_value) } /* end H5Rdereference1() */ diff --git a/src/H5Rint.c b/src/H5Rint.c index 1bbe217..52a4ee1 100644 --- a/src/H5Rint.c +++ b/src/H5Rint.c @@ -692,8 +692,7 @@ done: REVISION LOG --------------------------------------------------------------------------*/ ssize_t -H5R__get_name(H5F_t *f, hid_t id, H5R_type_t ref_type, const void *_ref, - char *name, size_t size) +H5R__get_name(H5F_t *f, H5R_type_t ref_type, const void *_ref, char *name, size_t size) { hid_t file_id = H5I_INVALID_HID; /* ID for file that the reference is in */ H5O_loc_t oloc; /* Object location describing object for reference */ diff --git a/src/H5Rpkg.h b/src/H5Rpkg.h index 504d2af..1c1c8eb 100644 --- a/src/H5Rpkg.h +++ b/src/H5Rpkg.h @@ -54,7 +54,7 @@ H5_DLL herr_t H5R__create(void *ref, H5G_loc_t *loc, const char *name, H5R_type_ H5_DLL hid_t H5R__dereference(H5F_t *file, hid_t dapl_id, H5R_type_t ref_type, const void *_ref); H5_DLL H5S_t *H5R__get_region(H5F_t *file, const void *_ref); H5_DLL herr_t H5R__get_obj_type(H5F_t *file, H5R_type_t ref_type, const void *_ref, H5O_type_t *obj_type); -H5_DLL ssize_t H5R__get_name(H5F_t *file, hid_t id, H5R_type_t ref_type, const void *_ref, char *name, size_t size); +H5_DLL ssize_t H5R__get_name(H5F_t *file, H5R_type_t ref_type, const void *_ref, char *name, size_t size); #endif /* _H5Rpkg_H */ diff --git a/src/H5Spublic.h b/src/H5Spublic.h index 09b474a..d7a5d29 100644 --- a/src/H5Spublic.h +++ b/src/H5Spublic.h @@ -131,6 +131,7 @@ H5_DLL H5S_class_t H5Sget_simple_extent_type(hid_t space_id); H5_DLL herr_t H5Sset_extent_none(hid_t space_id); H5_DLL herr_t H5Sextent_copy(hid_t dst_id,hid_t src_id); H5_DLL htri_t H5Sextent_equal(hid_t sid1, hid_t sid2); +H5_DLL herr_t H5Sselect_copy(hid_t dst_id, hid_t src_id); H5_DLL herr_t H5Sselect_all(hid_t spaceid); H5_DLL herr_t H5Sselect_none(hid_t spaceid); H5_DLL herr_t H5Soffset_simple(hid_t space_id, const hssize_t *offset); diff --git a/src/H5Sselect.c b/src/H5Sselect.c index 2ce3f10..ea10517 100644 --- a/src/H5Sselect.c +++ b/src/H5Sselect.c @@ -89,6 +89,52 @@ H5S_select_offset(H5S_t *space, const hssize_t *offset) /*-------------------------------------------------------------------------- NAME + H5Sselect_copy + PURPOSE + Copy a selection from one dataspace to another + USAGE + herr_t H5Sselect_copy(dst, src) + hid_t dst; OUT: ID of the destination dataspace + hid_t src; IN: ID of the source dataspace + + RETURNS + Non-negative on success/Negative on failure + DESCRIPTION + Copies all the selection information (including offset) from the source + dataspace to the destination dataspace. + + GLOBAL VARIABLES + COMMENTS, BUGS, ASSUMPTIONS + EXAMPLES + REVISION LOG +--------------------------------------------------------------------------*/ +herr_t +H5Sselect_copy(hid_t dst_id, hid_t src_id) +{ + H5S_t *src; + H5S_t *dst; + herr_t ret_value = SUCCEED; + + FUNC_ENTER_API(FAIL) + H5TRACE2("e", "ii", dst_id, src_id); + + /* Check args */ + if(NULL == (src = (H5S_t *)H5I_object_verify(src_id, H5I_DATASPACE))) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a dataspace") + if(NULL == (dst = (H5S_t *)H5I_object_verify(dst_id, H5I_DATASPACE))) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a dataspace") + + /* Copy */ + if(H5S_select_copy(dst, src, FALSE) < 0) + HGOTO_ERROR(H5E_DATASPACE, H5E_CANTCOPY, FAIL, "can't copy selection") + +done: + FUNC_LEAVE_API(ret_value) +} /* end H5Sselect_copy() */ + + +/*-------------------------------------------------------------------------- + NAME H5S_select_copy PURPOSE Copy a selection from one dataspace to another @@ -41,6 +41,7 @@ #include "H5MMprivate.h" /* Memory management */ #include "H5Pprivate.h" /* Property lists */ #include "H5Tpkg.h" /* Datatypes */ +#include "H5VLprivate.h" /* Virtual Object Layer */ /****************/ @@ -1607,6 +1608,21 @@ H5T__close_cb(H5T_t *dt) HDassert(dt); HDassert(dt->shared); + /* If this datatype is VOL-managed (i.e.: has a VOL object), + * close it through the VOL driver. + */ + if(NULL != dt->vol_obj) { + + /* Close the driver-managed datatype data */ + if(H5VL_datatype_close(dt->vol_obj->data, dt->vol_obj->driver->cls, H5P_DATASET_XFER_DEFAULT, H5_REQUEST_NULL) < 0) + HGOTO_ERROR(H5E_DATATYPE, H5E_CLOSEERROR, FAIL, "unable to close datatype"); + + /* Free the VOL object */ + if(H5VL_free_object(dt->vol_obj) < 0) + HGOTO_ERROR(H5E_ATTR, H5E_CANTDEC, FAIL, "unable to free VOL object"); + dt->vol_obj = NULL; + } + /* Close the datatype */ if(H5T_close(dt) < 0) HGOTO_ERROR(H5E_DATATYPE, H5E_CLOSEERROR, FAIL, "unable to close datatype"); @@ -1650,11 +1666,11 @@ H5Tcreate(H5T_class_t type, size_t size) /* create the type */ if(NULL == (dt = H5T__create(type, size))) - HGOTO_ERROR(H5E_DATATYPE, H5E_CANTINIT, FAIL, "unable to create type") + HGOTO_ERROR(H5E_DATATYPE, H5E_CANTINIT, FAIL, "unable to create type") /* Get an ID for the datatype */ if((ret_value = H5I_register(H5I_DATATYPE, dt, TRUE)) < 0) - HGOTO_ERROR(H5E_DATATYPE, H5E_CANTREGISTER, FAIL, "unable to register datatype ID") + HGOTO_ERROR(H5E_DATATYPE, H5E_CANTREGISTER, FAIL, "unable to register datatype ID") done: FUNC_LEAVE_API(ret_value) @@ -1701,7 +1717,7 @@ H5Tcopy(hid_t type_id) H5D_t *dset; /* Dataset for datatype */ /* The argument is a dataset handle */ - if(NULL == (dset = (H5D_t *)H5I_object(type_id))) + if(NULL == (dset = (H5D_t *)H5VL_object(type_id))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, H5I_INVALID_HID, "not a dataset") if(NULL == (dt = H5D_typeof(dset))) HGOTO_ERROR(H5E_DATASET, H5E_CANTINIT, H5I_INVALID_HID, "unable to get the dataset datatype") @@ -1716,6 +1732,7 @@ H5Tcopy(hid_t type_id) case H5I_ATTR: case H5I_REFERENCE: case H5I_VFL: + case H5I_VOL: case H5I_GENPROP_CLS: case H5I_GENPROP_LST: case H5I_ERROR_CLASS: @@ -3039,6 +3056,8 @@ H5T_decode(size_t buf_size, const unsigned char *buf) if(H5T_set_loc(ret_value, NULL, H5T_LOC_MEMORY) < 0) HGOTO_ERROR(H5E_DATATYPE, H5E_CANTINIT, NULL, "invalid datatype location") + /* No VOL object */ + ret_value->vol_obj = NULL; done: /* Release fake file structure */ if(f && H5F_fake_free(f) < 0) @@ -3162,6 +3181,9 @@ H5T__create(H5T_class_t type, size_t size) if(H5T_STRING != type || H5T_VARIABLE != size) dt->shared->size = size; + /* No VOL object */ + dt->vol_obj = NULL; + /* Set return value */ ret_value = dt; @@ -3215,6 +3237,9 @@ H5T_copy(H5T_t *old_dt, H5T_copy_t method) /* Copy shared information (entry information is copied last) */ *(new_dt->shared) = *(old_dt->shared); + /* No VOL object */ + new_dt->vol_obj = NULL; + /* Check what sort of copy we are making */ switch (method) { case H5T_COPY_TRANSIENT: @@ -3543,6 +3568,9 @@ H5T__alloc(void) HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, NULL, "memory allocation failed") dt->shared->version = H5O_DTYPE_VERSION_1; + /* No VOL object initially */ + dt->vol_obj = NULL; + /* Assign return value */ ret_value = dt; @@ -3643,7 +3671,8 @@ done: * * Purpose: Frees a datatype and all associated memory. * - * Hote: Does _not_ deal with open named datatypes, etc. + * Note: Does _not_ deal with open named datatypes, etc. so this + * should never see a type managed by a VOL driver. * * Return: Non-negative on success/Negative on failure * @@ -5115,8 +5144,10 @@ H5T_is_named(const H5T_t *dt) HDassert(dt); - if(dt->shared->state == H5T_STATE_OPEN || dt->shared->state == H5T_STATE_NAMED) + if(dt->vol_obj) ret_value = TRUE; + else + ret_value = (H5T_STATE_OPEN == dt->shared->state || H5T_STATE_NAMED == dt->shared->state); done: FUNC_LEAVE_NOAPI(ret_value) @@ -5158,6 +5189,20 @@ H5T_convert_committed_datatype(H5T_t *dt, H5F_t *f) if(H5G_name_free(&dt->path) < 0) HGOTO_ERROR(H5E_DATATYPE, H5E_CANTOPENOBJ, FAIL, "unable to reset path") + /* If the datatype is committed through the VOL, close it */ + if (NULL != dt->vol_obj) { + H5VL_object_t *vol_obj = dt->vol_obj; + + /* Close the datatype through the VOL*/ + if ((ret_value = H5VL_datatype_close(vol_obj->data, vol_obj->driver->cls, H5P_DATASET_XFER_DEFAULT, H5_REQUEST_NULL)) < 0) + HGOTO_ERROR(H5E_DATATYPE, H5E_CLOSEERROR, FAIL, "unable to close datatype"); + + /* Free the datatype and set the VOL object pointer to NULL */ + if (H5VL_free_object(vol_obj) < 0) + HGOTO_ERROR(H5E_ATTR, H5E_CANTDEC, FAIL, "unable to free VOL object"); + dt->vol_obj = NULL; + } + dt->shared->state = H5T_STATE_TRANSIENT; } diff --git a/src/H5Tcommit.c b/src/H5Tcommit.c index ce537dc..8f7b4de 100644 --- a/src/H5Tcommit.c +++ b/src/H5Tcommit.c @@ -30,12 +30,15 @@ #include "H5ACprivate.h" /* Metadata cache */ #include "H5CXprivate.h" /* API Contexts */ #include "H5Eprivate.h" /* Error handling */ +#include "H5FLprivate.h" /* Free lists */ #include "H5FOprivate.h" /* File objects */ #include "H5Iprivate.h" /* IDs */ #include "H5Lprivate.h" /* Links */ #include "H5MMprivate.h" /* Memory Management */ +#include "H5Oprivate.h" /* Object headers */ #include "H5Pprivate.h" /* Property lists */ #include "H5Tpkg.h" /* Datatypes */ +#include "H5VLprivate.h" /* Virtual Object Layer */ /****************/ @@ -78,6 +81,12 @@ static H5T_t *H5T__open_oid(const H5G_loc_t *loc); /* Local Variables */ /*******************/ +/* Declare a free list to manage the H5VL_t struct */ +H5FL_EXTERN(H5VL_t); + +/* Declare a free list to manage the H5VL_object_t struct */ +H5FL_EXTERN(H5VL_object_t); + /*------------------------------------------------------------------------- @@ -94,22 +103,25 @@ herr_t H5Tcommit2(hid_t loc_id, const char *name, hid_t type_id, hid_t lcpl_id, hid_t tcpl_id, hid_t tapl_id) { - H5G_loc_t loc; /* Location to create datatype */ - H5T_t *type = NULL; /* Datatype for ID */ + void *data = NULL; /* VOL-managed datatype data */ + H5VL_object_t *new_obj = NULL; /* VOL object that holds the datatype object and the VOL info */ + H5T_t *dt = NULL; /* High level datatype object that wraps the VOL object */ + H5VL_object_t *vol_obj = NULL; /* object token of loc_id */ + H5VL_loc_params_t loc_params; herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_API(FAIL) H5TRACE6("e", "i*siiii", loc_id, name, type_id, lcpl_id, tcpl_id, tapl_id); /* Check arguments */ - if(H5G_loc(loc_id, &loc) < 0) - HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a location") if(!name) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "name parameter cannot be NULL") if(!*name) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "name parameter cannot be an empty string") - if(NULL == (type = (H5T_t *)H5I_object_verify(type_id, H5I_DATATYPE))) + if(NULL == (dt = (H5T_t *)H5I_object_verify(type_id, H5I_DATATYPE))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a datatype") + if(H5T_is_named(dt)) + HGOTO_ERROR(H5E_ARGS, H5E_CANTSET, FAIL, "datatype is already committed") /* Get correct property list */ if(H5P_DEFAULT == lcpl_id) @@ -119,7 +131,7 @@ H5Tcommit2(hid_t loc_id, const char *name, hid_t type_id, hid_t lcpl_id, HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not link creation property list") /* Get correct property list */ - if(H5P_DEFAULT == tcpl_id) + if (H5P_DEFAULT == tcpl_id) tcpl_id = H5P_DATATYPE_CREATE_DEFAULT; else if(TRUE != H5P_isa_class(tcpl_id, H5P_DATATYPE_CREATE)) @@ -129,10 +141,30 @@ H5Tcommit2(hid_t loc_id, const char *name, hid_t type_id, hid_t lcpl_id, if(H5CX_set_apl(&tapl_id, H5P_CLS_TACC, loc_id, TRUE) < 0) HGOTO_ERROR(H5E_DATATYPE, H5E_CANTSET, FAIL, "can't set access property list info") + /* Fill in location struct fields */ + loc_params.type = H5VL_OBJECT_BY_SELF; + loc_params.obj_type = H5I_get_type(loc_id); + + /* Get the object from the loc_id */ + if(NULL == (vol_obj = (H5VL_object_t *)H5I_object(loc_id))) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "invalid object identifier") + /* Commit the type */ - if(H5T__commit_named(&loc, name, type, lcpl_id, tcpl_id) < 0) + if(NULL == (data = H5VL_datatype_commit(vol_obj->data, loc_params, vol_obj->driver->cls, + name, type_id, lcpl_id, tcpl_id, tapl_id, + H5P_DATASET_XFER_DEFAULT, H5_REQUEST_NULL))) HGOTO_ERROR(H5E_DATATYPE, H5E_CANTINIT, FAIL, "unable to commit datatype") + /* Set up VOL object */ + if(NULL == (new_obj = H5FL_CALLOC(H5VL_object_t))) + HGOTO_ERROR(H5E_VOL, H5E_NOSPACE, FAIL, "can't allocate top object structure") + new_obj->driver = vol_obj->driver; + new_obj->driver->nrefs ++; + new_obj->data = data; + + /* Set the committed type object to the VOL driver pointer in the H5T_t struct */ + dt->vol_obj = new_obj; + done: FUNC_LEAVE_API(ret_value) } /* end H5Tcommit2() */ @@ -237,16 +269,17 @@ done: herr_t H5Tcommit_anon(hid_t loc_id, hid_t type_id, hid_t tcpl_id, hid_t tapl_id) { - H5G_loc_t loc; /* Group location for location */ + void *dt = NULL; /* datatype object created by VOL plugin */ + H5VL_object_t *new_obj = NULL; /* VOL object that holds the datatype object and the VOL info */ H5T_t *type = NULL; /* Datatype created */ + H5VL_object_t *vol_obj = NULL; /* object token of loc_id */ + H5VL_loc_params_t loc_params; herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_API(FAIL) H5TRACE4("e", "iiii", loc_id, type_id, tcpl_id, tapl_id); /* Check arguments */ - if(H5G_loc(loc_id, &loc) < 0) - HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a location") if(NULL == (type = (H5T_t *)H5I_object_verify(type_id, H5I_DATATYPE))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a datatype") if(H5T_is_named(type)) @@ -263,10 +296,30 @@ H5Tcommit_anon(hid_t loc_id, hid_t type_id, hid_t tcpl_id, hid_t tapl_id) if(H5CX_set_apl(&tapl_id, H5P_CLS_TACC, loc_id, TRUE) < 0) HGOTO_ERROR(H5E_DATATYPE, H5E_CANTSET, FAIL, "can't set access property list info") + /* Fill in location struct fields */ + loc_params.type = H5VL_OBJECT_BY_SELF; + loc_params.obj_type = H5I_get_type(loc_id); + + /* Get the file object */ + if(NULL == (vol_obj = (H5VL_object_t *)H5I_object(loc_id))) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "invalid file identifier") + /* Commit the datatype */ - if(H5T__commit_anon(loc.oloc->file, type, tcpl_id) < 0) + if(NULL == (dt = H5VL_datatype_commit(vol_obj->data, loc_params, vol_obj->driver->cls, + NULL, type_id, H5P_DEFAULT, tcpl_id, tapl_id, + H5P_DATASET_XFER_DEFAULT, H5_REQUEST_NULL))) HGOTO_ERROR(H5E_DATATYPE, H5E_CANTINIT, FAIL, "unable to commit datatype") + /* Setup VOL object */ + if(NULL == (new_obj = H5FL_CALLOC(H5VL_object_t))) + HGOTO_ERROR(H5E_VOL, H5E_NOSPACE, FAIL, "can't allocate top object structure") + new_obj->driver = vol_obj->driver; + new_obj->driver->nrefs ++; + new_obj->data = dt; + + /* Set the committed type object to the VOL pluging pointer in the H5T_t struct */ + type->vol_obj = new_obj; + done: FUNC_LEAVE_API(ret_value) } /* end H5Tcommit_anon() */ @@ -515,16 +568,15 @@ done: hid_t H5Topen2(hid_t loc_id, const char *name, hid_t tapl_id) { - H5T_t *type = NULL; /* Datatype opened in file */ - H5G_loc_t loc; /* Group location of object to open */ + void *dt = NULL; /* datatype token created by VOL driver */ + H5VL_object_t *vol_obj = NULL; /* object token of loc_id */ + H5VL_loc_params_t loc_params; hid_t ret_value = H5I_INVALID_HID; /* Return value */ FUNC_ENTER_API(H5I_INVALID_HID) H5TRACE3("i", "i*si", loc_id, name, tapl_id); /* Check args */ - if(H5G_loc(loc_id, &loc) < 0) - HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, H5I_INVALID_HID, "not a location") if(!name) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, H5I_INVALID_HID, "name parameter cannot be NULL") if(!*name) @@ -534,19 +586,28 @@ H5Topen2(hid_t loc_id, const char *name, hid_t tapl_id) if(H5CX_set_apl(&tapl_id, H5P_CLS_TACC, loc_id, FALSE) < 0) HGOTO_ERROR(H5E_DATATYPE, H5E_CANTSET, FAIL, "can't set access property list info") + /* Fill in location struct fields */ + loc_params.type = H5VL_OBJECT_BY_SELF; + loc_params.obj_type = H5I_get_type(loc_id); + + /* get the location object */ + if(NULL == (vol_obj = (H5VL_object_t *)H5I_object(loc_id))) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, H5I_INVALID_HID, "invalid file identifier") + /* Open the datatype */ - if(NULL == (type = H5T__open_name(&loc, name))) + if(NULL == (dt = H5VL_datatype_open(vol_obj->data, loc_params, vol_obj->driver->cls, + name, tapl_id, H5P_DATASET_XFER_DEFAULT, H5_REQUEST_NULL))) HGOTO_ERROR(H5E_DATATYPE, H5E_CANTOPENOBJ, H5I_INVALID_HID, "unable to open named datatype") /* Register the type and return the ID */ - if((ret_value = H5I_register(H5I_DATATYPE, type, TRUE)) < 0) + if((ret_value = H5VL_register_id(H5I_DATATYPE, dt, vol_obj->driver, TRUE)) < 0) HGOTO_ERROR(H5E_ATOM, H5E_CANTREGISTER, H5I_INVALID_HID, "unable to register named datatype") done: /* Cleanup on error */ if(H5I_INVALID_HID == ret_value) - if(type != NULL) - (void)H5T_close(type); + if(dt && H5VL_datatype_close(dt, vol_obj->driver->cls, H5P_DATASET_XFER_DEFAULT, H5_REQUEST_NULL) < 0) + HDONE_ERROR(H5E_DATATYPE, H5E_CLOSEERROR, H5I_INVALID_HID, "unable to release datatype") FUNC_LEAVE_API(ret_value) } /* end H5Topen2() */ @@ -600,7 +661,11 @@ H5Tget_create_plist(hid_t dtype_id) } /* If the datatype is committed, retrieve further information */ else { - if((ret_value = H5T__get_create_plist(type)) < 0) + H5VL_object_t *vol_obj = type->vol_obj; + + /* Get the property list through the VOL */ + if(H5VL_datatype_get(vol_obj->data, vol_obj->driver->cls, H5VL_DATATYPE_GET_TCPL, + H5P_DATASET_XFER_DEFAULT, H5_REQUEST_NULL, &ret_value) < 0) HGOTO_ERROR(H5E_DATATYPE, H5E_CANTGET, H5I_INVALID_HID, "can't get object creation info") } @@ -641,8 +706,10 @@ H5Tflush(hid_t type_id) HGOTO_ERROR(H5E_DATATYPE, H5E_CANTSET, FAIL, "can't set access property list info") /* Flush metadata for named datatype */ - if(H5O_flush_common(&dt->oloc, type_id) < 0) - HGOTO_ERROR(H5E_DATATYPE, H5E_CANTFLUSH, FAIL, "unable to flush datatype") + if(dt->vol_obj) + if((ret_value = H5VL_datatype_specific(dt->vol_obj->data, dt->vol_obj->driver->cls, H5VL_DATATYPE_FLUSH, + H5P_DATASET_XFER_DEFAULT, H5_REQUEST_NULL, type_id)) < 0) + HGOTO_ERROR(H5E_DATATYPE, H5E_CANTFLUSH, FAIL, "unable to flush datatype") done: FUNC_LEAVE_API(ret_value) @@ -681,8 +748,10 @@ H5Trefresh(hid_t type_id) HGOTO_ERROR(H5E_DATATYPE, H5E_CANTSET, FAIL, "can't set access property list info") /* Refresh the datatype's metadata */ - if((H5O_refresh_metadata(type_id, dt->oloc)) < 0) - HGOTO_ERROR(H5E_DATATYPE, H5E_CANTLOAD, FAIL, "unable to refresh datatype") + if(dt->vol_obj) + if((ret_value = H5VL_datatype_specific(dt->vol_obj->data, dt->vol_obj->driver->cls, H5VL_DATATYPE_REFRESH, + H5P_DATASET_XFER_DEFAULT, H5_REQUEST_NULL, type_id)) < 0) + HGOTO_ERROR(H5E_DATATYPE, H5E_CANTLOAD, FAIL, "unable to refresh datatype") done: FUNC_LEAVE_API(ret_value) @@ -865,6 +934,7 @@ H5T_open(const H5G_loc_t *loc) else { if(NULL == (dt = H5FL_MALLOC(H5T_t))) HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, NULL, "can't allocate space for datatype") + dt->vol_obj = NULL; #if defined(H5_USING_MEMCHECKER) || !defined(NDEBUG) /* Clear object location */ @@ -1014,3 +1084,187 @@ H5T_update_shared(H5T_t *dt) FUNC_LEAVE_NOAPI(SUCCEED) } /* H5T_update_shared() */ + +/*------------------------------------------------------------------------- + * Function: H5T_construct_datatype + * + * Purpose: Create a Library datatype with a plugin specific datatype object + * + * Return: Success: A type structure + * Failure: NULL + * + *------------------------------------------------------------------------- + */ +H5T_t * +H5T_construct_datatype(H5VL_object_t *vol_obj) +{ + ssize_t nalloc; + void *buf = NULL; + H5T_t *dt = NULL; /* datatype token from VOL plugin */ + H5T_t *ret_value = NULL; + + FUNC_ENTER_NOAPI(NULL) + + /* get required buf size for encoding the datatype */ + if(H5VL_datatype_get(vol_obj->data, vol_obj->driver->cls, H5VL_DATATYPE_GET_BINARY, + H5P_DATASET_XFER_DEFAULT, H5_REQUEST_NULL, &nalloc, NULL, 0) < 0) + HGOTO_ERROR(H5E_DATATYPE, H5E_CANTINIT, NULL, "unable to get datatype serialized size") + + /* allocate buffer to store binary description of the datatype */ + if(NULL == (buf = (void *)H5MM_calloc((size_t)nalloc))) + HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, NULL, "can't allocate space for datatype") + + /* get binary description of the datatype */ + if(H5VL_datatype_get(vol_obj->data, vol_obj->driver->cls, H5VL_DATATYPE_GET_BINARY, + H5P_DATASET_XFER_DEFAULT, H5_REQUEST_NULL, &nalloc, buf, (size_t)nalloc) < 0) + HGOTO_ERROR(H5E_DATATYPE, H5E_CANTINIT, NULL, "unable to get serialized datatype") + + if(NULL == (dt = H5T_decode((size_t)nalloc, (const unsigned char *)buf))) + HGOTO_ERROR(H5E_DATATYPE, H5E_CANTINIT, NULL, "can't decode datatype") + + dt->vol_obj = vol_obj; + + ret_value = dt; + +done: + if(buf) + buf = H5MM_xfree(buf); + + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5T_construct_datatype() */ + + +/*------------------------------------------------------------------------- + * Function: H5T_get_named_type + * + * Purpose: Returns the VOL object for the named datatype if it exists + * + * Return: Success: Pointer to the VOL object for the datatype + * Failure: NULL + * + *------------------------------------------------------------------------- + */ +H5VL_object_t * +H5T_get_named_type(const H5T_t *dt) +{ + H5VL_object_t *ret_value = NULL; /* Return value */ + + FUNC_ENTER_NOAPI_NOINIT_NOERR + + if(NULL != dt->vol_obj) + ret_value = dt->vol_obj; + + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5T_get_named_type() */ + + +/*------------------------------------------------------------------------- + * Function: H5T_get_actual_type + * + * Purpose: Returns underlying native datatype created by native driver + * if datatype is committed, otherwise return the datatype + * object associate with the ID. + * + * Return: Success: Pointer to the VOL-managed data for this datatype + * Failure: NULL + * + *------------------------------------------------------------------------- + */ +H5T_t * +H5T_get_actual_type(H5T_t *dt) +{ + H5T_t *ret_value = NULL; /* Return value */ + + FUNC_ENTER_NOAPI_NOINIT_NOERR + + /* Check if the datatype is committed */ + if(NULL == dt->vol_obj) + ret_value = dt; + else + ret_value = (H5T_t *)dt->vol_obj->data; + + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5T_get_actual_type() */ + + +/*------------------------------------------------------------------------- + * Function: H5T_save_refresh_state + * + * Purpose: Save state for datatype reconstuction after a refresh. + * + * Return: SUCCEED/FAIL + * + *------------------------------------------------------------------------- + */ +herr_t +H5T_save_refresh_state(hid_t tid, H5O_shared_t *cached_H5O_shared) +{ + H5T_t *dt = NULL; /* High level datatype object that wraps the VOL object */ + H5T_t *vol_dt = NULL; /* H5T_t pointer stored in the datatype's vol_obj field */ + herr_t ret_value = SUCCEED; /* Return value */ + + FUNC_ENTER_NOAPI(FAIL) + + HDassert(cached_H5O_shared); + + if(NULL == (dt = (H5T_t *)H5I_object_verify(tid, H5I_DATATYPE))) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "tid is not a datatype ID") + vol_dt = (H5T_t *)(dt->vol_obj->data); + if(NULL == vol_dt) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "tid is not not a named datatype ID") + + /* Increase the count on the file object */ + vol_dt->shared->fo_count += 1; + + /* Increment object count for the object in the top file */ + if(H5FO_top_incr(vol_dt->sh_loc.file, vol_dt->sh_loc.u.loc.oh_addr) < 0) + HGOTO_ERROR(H5E_DATATYPE, H5E_CANTINC, FAIL, "can't increment object count") + + /* Cache the H5O_shared_t data */ + HDmemcpy(cached_H5O_shared, &(vol_dt->sh_loc), sizeof(H5O_shared_t)); + +done: + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5T_save_refresh_state() */ + + +/*------------------------------------------------------------------------- + * Function: H5T_restore_refresh_state + * + * Purpose: Restore state for datatype reconstuction after a refresh. + * + * Return: SUCCEED/FAIL + * + *------------------------------------------------------------------------- + */ +herr_t +H5T_restore_refresh_state(hid_t tid, H5O_shared_t *cached_H5O_shared) +{ + H5T_t *dt = NULL; /* High level datatype object that wraps the VOL object */ + H5T_t *vol_dt = NULL; /* H5T_t pointer stored in the datatype's vol_obj field */ + herr_t ret_value = SUCCEED; /* Return value */ + + FUNC_ENTER_NOAPI(FAIL) + + HDassert(cached_H5O_shared); + + if(NULL == (dt = (H5T_t *)H5I_object_verify(tid, H5I_DATATYPE))) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "tid not a datatype ID") + vol_dt = (H5T_t *)(dt->vol_obj->data); + if(NULL == vol_dt) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "tid is not not a named datatype ID") + + /* Restore the H5O_shared_t data */ + HDmemcpy(&(vol_dt->sh_loc), cached_H5O_shared, sizeof(H5O_shared_t)); + + /* Decrement the ref. count for this object in the top file */ + if(H5FO_top_decr(vol_dt->sh_loc.file, vol_dt->sh_loc.u.loc.oh_addr) < 0) + HGOTO_ERROR(H5E_DATATYPE, H5E_CANTDEC, FAIL, "can't decrement object count") + + /* Decrease the count on the file object */ + vol_dt->shared->fo_count -= 1; + +done: + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5T_restore_refresh_state() */ + diff --git a/src/H5Tconv.c b/src/H5Tconv.c index 563de65..e6d83bb 100644 --- a/src/H5Tconv.c +++ b/src/H5Tconv.c @@ -7480,7 +7480,7 @@ H5T__conv_llong_double (hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, * *------------------------------------------------------------------------- */ -#if H5T_CONV_INTERNAL_LLONG_LDOUBLE +#ifdef H5T_CONV_INTERNAL_LLONG_LDOUBLE herr_t H5T__conv_llong_ldouble (hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, size_t nelmts, size_t buf_stride, size_t H5_ATTR_UNUSED bkg_stride, @@ -7548,7 +7548,7 @@ H5T__conv_ullong_double (hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, * *------------------------------------------------------------------------- */ -#if H5T_CONV_INTERNAL_ULLONG_LDOUBLE +#ifdef H5T_CONV_INTERNAL_ULLONG_LDOUBLE herr_t H5T__conv_ullong_ldouble (hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, size_t nelmts, size_t buf_stride, size_t H5_ATTR_UNUSED bkg_stride, @@ -8244,7 +8244,7 @@ H5_GCC_DIAG_ON(float-equal) * *------------------------------------------------------------------------- */ -#if H5T_CONV_INTERNAL_LDOUBLE_LLONG +#ifdef H5T_CONV_INTERNAL_LDOUBLE_LLONG herr_t H5T__conv_ldouble_llong (hid_t src_id, hid_t dst_id, H5T_cdata_t *cdata, size_t nelmts, size_t buf_stride, size_t H5_ATTR_UNUSED bkg_stride, diff --git a/src/H5Tdeprec.c b/src/H5Tdeprec.c index a7f54a7..1b59c6b 100644 --- a/src/H5Tdeprec.c +++ b/src/H5Tdeprec.c @@ -43,6 +43,7 @@ #include "H5Iprivate.h" /* IDs */ #include "H5Ppublic.h" /* Property Lists */ #include "H5Tpkg.h" /* Datatypes */ +#include "H5VLprivate.h" /* VOL plugins */ /****************/ @@ -79,6 +80,12 @@ /* Local Variables */ /*******************/ +/* Declare a free list to manage the H5VL_t struct */ +H5FL_EXTERN(H5VL_t); + +/* Declare a free list to manage the H5VL_object_t struct */ +H5FL_EXTERN(H5VL_object_t); + #ifndef H5_NO_DEPRECATED_SYMBOLS @@ -100,29 +107,52 @@ herr_t H5Tcommit1(hid_t loc_id, const char *name, hid_t type_id) { - H5G_loc_t loc; /* Location to create datatype */ - H5T_t *type; /* Datatype for ID */ + void *data = NULL; /* VOL-managed datatype data */ + H5VL_object_t *new_obj = NULL; /* VOL object that holds the datatype object and the VOL info */ + H5T_t *dt = NULL; /* High level datatype object that wraps the VOL object */ + H5VL_object_t *vol_obj = NULL; /* Object token of loc_id */ + H5VL_loc_params_t loc_params; herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_API(FAIL) H5TRACE3("e", "i*si", loc_id, name, type_id); /* Check arguments */ - if(H5G_loc(loc_id, &loc) < 0) - HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a location") if(!name || !*name) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "no name") - if(NULL == (type = (H5T_t *)H5I_object_verify(type_id, H5I_DATATYPE))) + if(NULL == (dt = (H5T_t *)H5I_object_verify(type_id, H5I_DATATYPE))) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a datatype") + if(H5T_is_named(dt)) + HGOTO_ERROR(H5E_ARGS, H5E_CANTSET, FAIL, "datatype is already committed") /* Set up collective metadata if appropriate */ if(H5CX_set_loc(loc_id) < 0) HGOTO_ERROR(H5E_DATATYPE, H5E_CANTSET, FAIL, "can't set access property list info") + loc_params.type = H5VL_OBJECT_BY_SELF; + loc_params.obj_type = H5I_get_type(loc_id); + + /* get the object from the loc_id */ + if(NULL == (vol_obj = (H5VL_object_t *)H5I_object(loc_id))) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "invalid object identifier") + /* Commit the datatype */ - if(H5T__commit_named(&loc, name, type, H5P_LINK_CREATE_DEFAULT, H5P_DATATYPE_CREATE_DEFAULT) < 0) + if(NULL == (data = H5VL_datatype_commit(vol_obj->data, loc_params, vol_obj->driver->cls, + name, type_id, H5P_LINK_CREATE_DEFAULT, + H5P_DATATYPE_CREATE_DEFAULT, H5P_DATATYPE_ACCESS_DEFAULT, + H5P_DATASET_XFER_DEFAULT, H5_REQUEST_NULL))) HGOTO_ERROR(H5E_DATATYPE, H5E_CANTINIT, FAIL, "unable to commit datatype") + /* Set up VOL object */ + if(NULL == (new_obj = H5FL_CALLOC(H5VL_object_t))) + HGOTO_ERROR(H5E_VOL, H5E_NOSPACE, FAIL, "can't allocate top object structure") + new_obj->driver = vol_obj->driver; + new_obj->driver->nrefs ++; + new_obj->data = data; + + /* Set the committed type object to the VOL pluging pointer in the H5T_t struct */ + dt->vol_obj = new_obj; + done: FUNC_LEAVE_API(ret_value) } /* end H5Tcommit1() */ @@ -147,31 +177,39 @@ done: hid_t H5Topen1(hid_t loc_id, const char *name) { - H5T_t *type = NULL; - H5G_loc_t loc; + void *dt = NULL; /* Datatype token created by VOL plugin */ + H5VL_object_t *vol_obj = NULL; /* Object token of loc_id */ + H5VL_loc_params_t loc_params; hid_t ret_value = H5I_INVALID_HID; /* Return value */ FUNC_ENTER_API(H5I_INVALID_HID) H5TRACE2("i", "i*s", loc_id, name); /* Check args */ - if(H5G_loc(loc_id, &loc) < 0) - HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, H5I_INVALID_HID, "not a location") if(!name || !*name) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, H5I_INVALID_HID, "no name") + loc_params.type = H5VL_OBJECT_BY_SELF; + loc_params.obj_type = H5I_get_type(loc_id); + + /* Get the location object */ + if(NULL == (vol_obj = (H5VL_object_t *)H5I_object(loc_id))) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, H5I_INVALID_HID, "invalid location identifier") + /* Open the datatype */ - if(NULL == (type = H5T__open_name(&loc, name))) + if(NULL == (dt = H5VL_datatype_open(vol_obj->data, loc_params, vol_obj->driver->cls, + name, H5P_DATATYPE_ACCESS_DEFAULT, + H5P_DATASET_XFER_DEFAULT, H5_REQUEST_NULL))) HGOTO_ERROR(H5E_DATATYPE, H5E_CANTOPENOBJ, H5I_INVALID_HID, "unable to open named datatype") /* Register the type and return the ID */ - if((ret_value = H5I_register(H5I_DATATYPE, type, TRUE)) < 0) + if((ret_value = H5VL_register_id(H5I_DATATYPE, dt, vol_obj->driver, TRUE)) < 0) HGOTO_ERROR(H5E_ATOM, H5E_CANTREGISTER, H5I_INVALID_HID, "unable to register named datatype") done: /* Cleanup on error */ if(H5I_INVALID_HID == ret_value) - if(type && H5T_close(type) < 0) + if(dt && H5VL_datatype_close(dt, vol_obj->driver->cls, H5P_DATASET_XFER_DEFAULT, H5_REQUEST_NULL) < 0) HDONE_ERROR(H5E_DATATYPE, H5E_CLOSEERROR, H5I_INVALID_HID, "unable to close datatype") FUNC_LEAVE_API(ret_value) diff --git a/src/H5Toh.c b/src/H5Toh.c index c5ee994..b21ce72 100644 --- a/src/H5Toh.c +++ b/src/H5Toh.c @@ -44,7 +44,7 @@ /********************/ static htri_t H5O__dtype_isa(const H5O_t *loc); -static hid_t H5O__dtype_open(const H5G_loc_t *obj_loc, hbool_t app_ref); +static void *H5O__dtype_open(const H5G_loc_t *obj_loc, H5I_type_t *opened_type); static void *H5O__dtype_create(H5F_t *f, void *_crt_info, H5G_loc_t *obj_loc); static H5O_loc_t *H5O__dtype_get_oloc(hid_t obj_id); @@ -125,28 +125,28 @@ done: * *------------------------------------------------------------------------- */ -static hid_t -H5O__dtype_open(const H5G_loc_t *obj_loc, hbool_t app_ref) +static void * +H5O__dtype_open(const H5G_loc_t *obj_loc, H5I_type_t *opened_type) { - H5T_t *type = NULL; /* Datatype opened */ - hid_t ret_value = H5I_INVALID_HID; /* Return value */ + H5T_t *type = NULL; /* Datatype opened */ + void *ret_value = NULL; /* Return value */ FUNC_ENTER_STATIC HDassert(obj_loc); + *opened_type = H5I_DATATYPE; + /* Open the datatype */ if(NULL == (type = H5T_open(obj_loc))) - HGOTO_ERROR(H5E_DATATYPE, H5E_CANTOPENOBJ, FAIL, "unable to open datatype") + HGOTO_ERROR(H5E_DATATYPE, H5E_CANTOPENOBJ, NULL, "unable to open datatype") - /* Register an ID for the datatype */ - if((ret_value = H5I_register(H5I_DATATYPE, type, app_ref)) < 0) - HGOTO_ERROR(H5E_ATOM, H5E_CANTREGISTER, FAIL, "unable to register datatype") + ret_value = (void *)type; done: - if(ret_value < 0) + if(NULL == ret_value) if(type && H5T_close(type) < 0) - HDONE_ERROR(H5E_DATATYPE, H5E_CLOSEERROR, FAIL, "unable to release datatype") + HDONE_ERROR(H5E_DATATYPE, H5E_CLOSEERROR, NULL, "unable to release datatype") FUNC_LEAVE_NOAPI(ret_value) } /* end H5O__dtype_open() */ @@ -212,14 +212,17 @@ done: static H5O_loc_t * H5O__dtype_get_oloc(hid_t obj_id) { - H5T_t *type; /* Datatype opened */ + H5T_t *type = NULL; /* Datatype opened */ + H5T_t *dt = NULL; H5O_loc_t *ret_value = NULL; /* Return value */ FUNC_ENTER_STATIC /* Get the datatype */ - if(NULL == (type = (H5T_t *)H5I_object(obj_id))) + if(NULL == (dt = (H5T_t *)H5I_object(obj_id))) HGOTO_ERROR(H5E_OHDR, H5E_BADATOM, NULL, "couldn't get object from ID") + /* If this is a named datatype, get the VOL driver pointer to the datatype */ + type = (H5T_t *)H5T_get_actual_type(dt); /* Get the datatype's object header location */ if(NULL == (ret_value = H5T_oloc(type))) diff --git a/src/H5Torder.c b/src/H5Torder.c index 1995a03..d687d03 100644 --- a/src/H5Torder.c +++ b/src/H5Torder.c @@ -210,6 +210,8 @@ H5Tset_order(hid_t type_id, H5T_order_t order) HGOTO_ERROR(H5E_DATATYPE, H5E_BADTYPE, FAIL, "not a datatype") if(order < H5T_ORDER_LE || order > H5T_ORDER_NONE || order == H5T_ORDER_MIXED) HGOTO_ERROR(H5E_DATATYPE, H5E_BADVALUE, FAIL, "illegal byte order") + if(NULL != dt->vol_obj) + HGOTO_ERROR(H5E_ARGS, H5E_CANTSET, FAIL, "datatype is already committed") if(H5T_STATE_TRANSIENT != dt->shared->state) HGOTO_ERROR(H5E_DATATYPE, H5E_CANTINIT, FAIL, "datatype is read-only") diff --git a/src/H5Tpkg.h b/src/H5Tpkg.h index 04e9451..c909f18 100644 --- a/src/H5Tpkg.h +++ b/src/H5Tpkg.h @@ -320,6 +320,7 @@ struct H5T_t { H5T_shared_t *shared; /* all other information */ H5O_loc_t oloc; /* Object location, if the type is a named type */ H5G_name_t path; /* group hier. path if the type is a named type */ + H5VL_object_t *vol_obj; /* pointer to VOL object when working with committed datatypes */ }; /* The master list of soft conversion functions */ diff --git a/src/H5Tprecis.c b/src/H5Tprecis.c index 59bac8b..bd28fc2 100644 --- a/src/H5Tprecis.c +++ b/src/H5Tprecis.c @@ -154,6 +154,8 @@ H5Tset_precision(hid_t type_id, size_t prec) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a datatype") if (H5T_STATE_TRANSIENT!=dt->shared->state) HGOTO_ERROR(H5E_ARGS, H5E_CANTSET, FAIL, "datatype is read-only") + if (NULL != dt->vol_obj) + HGOTO_ERROR(H5E_ARGS, H5E_CANTSET, FAIL, "datatype is committed") if (prec == 0) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "precision must be positive") if (H5T_ENUM==dt->shared->type && dt->shared->u.enumer.nmembs>0) diff --git a/src/H5Tprivate.h b/src/H5Tprivate.h index 9dae53b..c0a6d8d 100644 --- a/src/H5Tprivate.h +++ b/src/H5Tprivate.h @@ -30,6 +30,7 @@ typedef struct H5T_t H5T_t; #include "H5private.h" /* Generic Functions */ #include "H5Gprivate.h" /* Groups */ #include "H5Rprivate.h" /* References */ +#include "H5VLprivate.h" /* VOL Drivers */ /* Macro for size of temporary buffers to contain a single element */ #define H5T_ELEM_BUF_SIZE 256 @@ -98,7 +99,7 @@ typedef struct H5T_subset_info_t { } H5T_subset_info_t; /* Forward declarations for prototype arguments */ -struct H5O_t; +struct H5O_shared_t; /* The native endianness of the platform */ H5_DLLVAR H5T_order_t H5T_native_order_g; @@ -138,6 +139,11 @@ H5_DLL herr_t H5T_set_version(H5F_t *f, H5T_t *dt); H5_DLL herr_t H5T_patch_file(H5T_t *dt, H5F_t *f); H5_DLL herr_t H5T_patch_vlen_file(H5T_t *dt, H5F_t *f); H5_DLL htri_t H5T_is_variable_str(const H5T_t *dt); +H5_DLL H5T_t *H5T_construct_datatype(H5VL_object_t *dt_obj); +H5_DLL H5VL_object_t *H5T_get_named_type(const H5T_t *dt); +H5_DLL H5T_t *H5T_get_actual_type(H5T_t *dt); +H5_DLL herr_t H5T_save_refresh_state(hid_t tid, struct H5O_shared_t *cached_H5O_shared); +H5_DLL herr_t H5T_restore_refresh_state(hid_t tid, struct H5O_shared_t *cached_H5O_shared); /* Reference specific functions */ H5_DLL H5R_type_t H5T_get_ref_type(const H5T_t *dt); diff --git a/src/H5VL.c b/src/H5VL.c new file mode 100644 index 0000000..24e558c --- /dev/null +++ b/src/H5VL.c @@ -0,0 +1,2296 @@ +/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * + * Copyright by The HDF Group. * + * All rights reserved. * + * * + * This file is part of HDF5. The full HDF5 copyright notice, including * + * terms governing use, modification, and redistribution, is contained in * + * the COPYING file, which can be found at the root of the source code * + * distribution tree, or in https://support.hdfgroup.org/ftp/HDF5/releases. * + * If you do not have access to either file, you may request a copy from * + * help@hdfgroup.org. * + * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ + +/* + * Purpose: The Virtual Object Layer as described in documentation. + * The pupose is to provide an abstraction on how to access the + * underlying HDF5 container, whether in a local file with + * a specific file format, or remotely on other machines, etc... + */ + +/****************/ +/* Module Setup */ +/****************/ + +#include "H5VLmodule.h" /* This source code file is part of the H5VL module */ + + +/***********/ +/* Headers */ +/***********/ + +#include "H5private.h" /* Generic Functions */ +#include "H5Aprivate.h" /* Attributes */ +#include "H5Eprivate.h" /* Error handling */ +#include "H5Iprivate.h" /* IDs */ +#include "H5MMprivate.h" /* Memory management */ +#include "H5PLprivate.h" /* Plugins */ +#include "H5VLpkg.h" /* Virtual Object Layer */ + + +/****************/ +/* Local Macros */ +/****************/ + +/******************/ +/* Local Typedefs */ +/******************/ + +/* Information needed for iterating over the registered VOL driver hid_t IDs. + * The name of the new VOL driver that is being registered is stored in the + * name field and the found_id field is initialized to H5I_INVALID_HID (-1). + * If we find a VOL driver with the same name, we set the found_id field to + * the existing ID for return to the function. + */ +typedef struct { + const char *name; /* The name of the VOL driver to check */ + hid_t found_id; /* The library ID if we found a match */ +} H5VL_get_driver_ud_t; + +/********************/ +/* Local Prototypes */ +/********************/ +static int H5VL__get_driver_cb(void *obj, hid_t id, void *_op_data); + +/*********************/ +/* Package Variables */ +/*********************/ + +/*****************************/ +/* Library Private Variables */ +/*****************************/ + +/*******************/ +/* Local Variables */ +/*******************/ + + +/*------------------------------------------------------------------------- + * Function: H5VL__get_driver_cb + * + * Purpose: Callback routine to search through registered VOLs + * + * Return: Success: H5_ITER_STOP if the class and op_data name + * members match. H5_ITER_CONT otherwise. + * + * Failure: Can't fail + * + *------------------------------------------------------------------------- + */ +static int +H5VL__get_driver_cb(void *obj, hid_t id, void *_op_data) +{ + H5VL_get_driver_ud_t *op_data = (H5VL_get_driver_ud_t *)_op_data; /* User data for callback */ + H5VL_class_t *cls = (H5VL_class_t *)obj; + int ret_value = H5_ITER_CONT; /* Callback return value */ + + FUNC_ENTER_STATIC_NOERR + + if (0 == HDstrcmp(cls->name, op_data->name)) { + op_data->found_id = id; + ret_value = H5_ITER_STOP; + } + + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5VL__get_driver_cb() */ + + +/*------------------------------------------------------------------------- + * Function: H5VLinitialize + * + * Purpose: Calls the driver-specific callback to initialize the driver. + * + * Return: Success: Non-negative + * + * Failure: Negative + * + *------------------------------------------------------------------------- + */ +herr_t +H5VLinitialize(hid_t driver_id, hid_t vipl_id) +{ + H5VL_class_t *cls = NULL; + herr_t ret_value = SUCCEED; /* Return value */ + + FUNC_ENTER_API(FAIL) + H5TRACE2("e", "ii", driver_id, vipl_id); + + /* Check args */ + if (NULL == (cls = (H5VL_class_t *)H5I_object_verify(driver_id, H5I_VOL))) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a VOL driver ID") + + if (cls->initialize && cls->initialize(vipl_id) < 0) + HGOTO_ERROR(H5E_VOL, H5E_CANTCLOSEOBJ, FAIL, "VOL driver did not initialize") + +done: + FUNC_LEAVE_API(ret_value) +} /* end H5VLinitialize() */ + + +/*------------------------------------------------------------------------- + * Function: H5VLterminate + * + * Purpose: Calls the driver-specific callback to terminate the driver. + * + * Return: Success: Non-negative + * + * Failure: Negative + * + *------------------------------------------------------------------------- + */ +herr_t +H5VLterminate(hid_t driver_id, hid_t vtpl_id) +{ + H5VL_class_t *cls = NULL; + herr_t ret_value = SUCCEED; /* Return value */ + + FUNC_ENTER_API(FAIL) + H5TRACE2("e", "ii", driver_id, vtpl_id); + + /* Check args */ + if (NULL == (cls = (H5VL_class_t *)H5I_object_verify(driver_id, H5I_VOL))) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a VOL driver ID") + + if (cls->terminate && cls->terminate(vtpl_id) < 0) + HGOTO_ERROR(H5E_VOL, H5E_CANTCLOSEOBJ, FAIL, "VOL driver did not terminate cleanly") + +done: + FUNC_LEAVE_API(ret_value) +} /* end H5VLterminate() */ + + +/*------------------------------------------------------------------------- + * Function: H5VLclose + * + * Purpose: Closes the specified VOL driver. The VOL ID will no longer + * be valid for accessing the VOL. + * + * Return: Success: Non-negative + * + * Failure: Negative + * + *------------------------------------------------------------------------- + */ +herr_t +H5VLclose(hid_t vol_id) +{ + herr_t ret_value = SUCCEED; /* Return value */ + + FUNC_ENTER_API(FAIL) + H5TRACE1("e", "i", vol_id); + + /* Check args */ + if(NULL == H5I_object_verify(vol_id, H5I_VOL)) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a VOL driver ID") + + if(H5I_dec_app_ref(vol_id) < 0) + HGOTO_ERROR(H5E_VOL, H5E_CANTRELEASE, FAIL, "unable to close VOL driver ID") + +done: + FUNC_LEAVE_API(ret_value) +} /* end H5VLclose() */ + + +/*------------------------------------------------------------------------- + * Function: H5VLregister + * + * Purpose: Registers a new VOL driver as a member of the virtual object + * layer class. + * + * Return: Success: A VOL driver ID which is good until the + * library is closed or the driver is + * unregistered. + * + * Failure: A negative value (H5I_INVALID_HID). + * + *------------------------------------------------------------------------- + */ +hid_t +H5VLregister(const H5VL_class_t *cls) +{ + H5VL_get_driver_ud_t op_data; + hid_t ret_value = H5I_INVALID_HID; + + FUNC_ENTER_API(FAIL) + H5TRACE1("i", "*x", cls); + + /* Check arguments */ + if (!cls) + HGOTO_ERROR(H5E_ARGS, H5E_UNINITIALIZED, H5I_INVALID_HID, "VOL driver class pointer cannot be NULL") + if (!cls->name) + HGOTO_ERROR(H5E_VOL, H5E_CANTREGISTER, H5I_INVALID_HID, "VOL driver class name cannot be the NULL pointer"); + /* XXX: Should probably come up with a max length so we can use strnlen()? */ + if (0 == HDstrlen(cls->name)) + HGOTO_ERROR(H5E_VOL, H5E_CANTREGISTER, H5I_INVALID_HID, "VOL driver class name cannot be the empty string"); + + op_data.found_id = H5I_INVALID_HID; + op_data.name = cls->name; + + /* check if driver is already registered */ + if (H5I_iterate(H5I_VOL, H5VL__get_driver_cb, &op_data, TRUE) < 0) + HGOTO_ERROR(H5E_VOL, H5E_BADITER, H5I_INVALID_HID, "can't iterate over VOL IDs") + + /* XXX: Does this need to be an error? Users probably don't care as long + * as their VOL driver is available. + */ + if (op_data.found_id != H5I_INVALID_HID) + HGOTO_ERROR(H5E_VOL, H5E_CANTREGISTER, H5I_INVALID_HID, "VOL driver with the same name is already registered.") + + /* Create the new class ID */ + if ((ret_value = H5VL_register(cls, sizeof(H5VL_class_t), TRUE)) < 0) + HGOTO_ERROR(H5E_ATOM, H5E_CANTREGISTER, H5I_INVALID_HID, "unable to register VOL driver") + +done: + FUNC_LEAVE_API(ret_value) +} /* end H5VLregister() */ + + +/*------------------------------------------------------------------------- + * Function: H5VLregister_by_name + * + * Purpose: Registers a new VOL driver as a member of the virtual object + * layer class. + * + * Return: Success: A VOL driver ID which is good until the + * library is closed or the driver is + * unregistered. + * + * Failure: A negative value. + * + *------------------------------------------------------------------------- + */ +hid_t +H5VLregister_by_name(const char *name) +{ + H5VL_get_driver_ud_t op_data; + hid_t ret_value = H5I_INVALID_HID; + + FUNC_ENTER_API(FAIL) + H5TRACE1("i", "*s", name); + + /* Check arguments */ + if (!name) + HGOTO_ERROR(H5E_ARGS, H5E_UNINITIALIZED, H5I_INVALID_HID, "null VOL driver name is disallowed") + if (0 == HDstrlen(name)) + HGOTO_ERROR(H5E_ARGS, H5E_UNINITIALIZED, H5I_INVALID_HID, "zero-length VOL driver name is disallowed") + + op_data.found_id = H5I_INVALID_HID; + op_data.name = name; + + /* Check if driver is already registered */ + if (H5I_iterate(H5I_VOL, H5VL__get_driver_cb, &op_data, TRUE) < 0) + HGOTO_ERROR(H5E_VOL, H5E_BADITER, H5I_INVALID_HID, "can't iterate over VOL ids") + + if (op_data.found_id != H5I_INVALID_HID) { + /* If driver alread registered, increment ref count on ID and return ID */ + if (H5I_inc_ref(op_data.found_id, TRUE) < 0) + HGOTO_ERROR(H5E_VOL, H5E_CANTINC, H5I_INVALID_HID, "unable to increment ref count on VOL driver") + ret_value = op_data.found_id; + } + else { + H5PL_key_t key; + const H5VL_class_t *cls; + + /* Try loading the driver */ + key.name = name; + if (NULL == (cls = (const H5VL_class_t *)H5PL_load(H5PL_TYPE_VOL, key))) + HGOTO_ERROR(H5E_VOL, H5E_CANTINIT, H5I_INVALID_HID, "unable to load VOL driver") + + /* Register the driver we loaded */ + if ((ret_value = H5VL_register(cls, sizeof(H5VL_class_t), TRUE)) < 0) + HGOTO_ERROR(H5E_ATOM, H5E_CANTREGISTER, H5I_INVALID_HID, "unable to register VOL driver ID") + } + +done: + FUNC_LEAVE_API(ret_value) +} /* end H5VLregister_by_name() */ + + +/*------------------------------------------------------------------------- + * Function: H5VLunregister + * + * Purpose: Removes a vol driver ID from the library. This in no way affects + * file access property lists which have been defined to use + * this vol driver or files which are already opened under with + * this driver. + * + * Return: Success: Non-negative + * + * Failure: Negative + * + *------------------------------------------------------------------------- + */ +herr_t +H5VLunregister(hid_t vol_id) +{ + H5VL_class_t *cls = NULL; + herr_t ret_value = SUCCEED; /* Return value */ + + FUNC_ENTER_API(FAIL) + H5TRACE1("e", "i", vol_id); + + /* Check arguments */ + if (NULL == (cls = (H5VL_class_t *)H5I_object_verify(vol_id, H5I_VOL))) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a vol driver") + + /* The H5VL_class_t struct will be freed by this function */ + if (H5I_dec_app_ref(vol_id) < 0) + HGOTO_ERROR(H5E_VOL, H5E_CANTDEC, FAIL, "unable to unregister vol driver") + +done: + FUNC_LEAVE_API(ret_value) +} /* end H5VLunregister() */ + + +/*------------------------------------------------------------------------- + * Function: H5VLis_registered + * + * Purpose: Tests whether a VOL class has been registered or not + * + * Return: Positive if the VOL class has been registered + * + * Zero if it is unregistered + * + * Negative on error (if the class is not a valid class ID) + * + *------------------------------------------------------------------------- + */ +htri_t +H5VLis_registered(const char *name) +{ + H5VL_get_driver_ud_t op_data; + htri_t ret_value = FALSE; /* Return value */ + + FUNC_ENTER_API(FAIL) + H5TRACE1("t", "*s", name); + + op_data.found_id = H5I_INVALID_HID; + op_data.name = name; + + /* Check arguments */ + if (H5I_iterate(H5I_VOL, H5VL__get_driver_cb, &op_data, TRUE) < 0) + HGOTO_ERROR(H5E_VOL, H5E_BADITER, FAIL, "can't iterate over VOL ids") + + if (op_data.found_id != H5I_INVALID_HID) + ret_value = TRUE; + +done: + FUNC_LEAVE_API(ret_value) +} /* end H5VLis_registered() */ + + +/*------------------------------------------------------------------------- + * Function: H5VLget_driver_id + * + * Purpose: Retrieves the ID for a registered VOL driver. + * + * Return: Positive if the VOL class has been registered + * Negative on error (if the class is not a valid class or not registered) + * + *------------------------------------------------------------------------- + */ +hid_t +H5VLget_driver_id(const char *name) +{ + H5VL_get_driver_ud_t op_data; + hid_t ret_value = H5I_INVALID_HID; /* Return value */ + + FUNC_ENTER_API(H5I_INVALID_HID) + H5TRACE1("i", "*s", name); + + op_data.found_id = H5I_INVALID_HID; + op_data.name = name; + + /* Check arguments */ + if (H5I_iterate(H5I_VOL, H5VL__get_driver_cb, &op_data, TRUE) < 0) + HGOTO_ERROR(H5E_VOL, H5E_BADITER, H5I_INVALID_HID, "can't iterate over VOL driver IDs") + + if (op_data.found_id != H5I_INVALID_HID) { + if (H5I_inc_ref(op_data.found_id, TRUE) < 0) + HGOTO_ERROR(H5E_FILE, H5E_CANTINC, H5I_INVALID_HID, "unable to increment ref count on VOL driver") + + ret_value = op_data.found_id; + } + +done: + FUNC_LEAVE_API(ret_value) +} /* end H5VLget_driver_id() */ + + +/*------------------------------------------------------------------------- + * Function: H5VLget_driver_name + * + * Purpose: Returns the driver name for the VOL associated with the + * object or file ID + * + * Return: Success: The length of the driver name + * + * Failure: Negative + * + *------------------------------------------------------------------------- + */ +ssize_t +H5VLget_driver_name(hid_t obj_id, char *name/*out*/, size_t size) +{ + ssize_t ret_value = -1; + + FUNC_ENTER_API(FAIL) + H5TRACE3("Zs", "ixz", obj_id, name, size); + + if ((ret_value = H5VL_get_driver_name(obj_id, name, size)) < 0) + HGOTO_ERROR(H5E_VOL, H5E_CANTGET, FAIL, "Can't get driver name") + +done: + FUNC_LEAVE_API(ret_value) +} /* end H5VLget_driver_name() */ + + +/*--------------------------------------------------------------------------- + * Function: H5VLobject_register + * + * Purpose: Public routine to create an HDF5 hid_t with library + * specific types, bypassing the limitation of H5Iregister. + * + * Return: Success: Non-negative + * + * Failure: Negative + * + *--------------------------------------------------------------------------- + */ +hid_t +H5VLobject_register(void *obj, H5I_type_t obj_type, hid_t driver_id) +{ + hid_t ret_value = FAIL; + + FUNC_ENTER_API(FAIL) + H5TRACE3("i", "*xIti", obj, obj_type, driver_id); + + if (NULL == obj) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "invalid object to register") + + if ((ret_value = H5VL_object_register(obj, obj_type, driver_id, TRUE)) < 0) + HGOTO_ERROR(H5E_ATOM, H5E_CANTREGISTER, FAIL, "unable to register object") + +done: + FUNC_LEAVE_API(ret_value) +} /* H5VLobject_register */ + + +/*------------------------------------------------------------------------- + * Function: H5VLobject + * + * Purpose: Public utility function to return the VOL object pointer + * associated with an hid_t. + * + * Return: Success: object pointer + * Failure: NULL + * + * Programmer: Jordan Henderson + * January, 2018 + * + *------------------------------------------------------------------------- + */ +void * +H5VLobject(hid_t id) +{ + void *ret_value = NULL; + + FUNC_ENTER_API(NULL) + H5TRACE1("*x", "i", id); + + if (NULL == (ret_value = H5VL_object(id))) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, NULL, "invalid identifier") + +done: + FUNC_LEAVE_API(ret_value) +} /* end H5VLobject() */ + + +/*--------------------------------------------------------------------------- + * Function: H5VLget_object + * + * Purpose: Retrieves the object pointer associated with the ID. This + * also optionally returns the H5VL_t struct that this ID + * belongs to, if the user passes a valid pointer value. + * + * Return: Success: Non-negative + * + * Failure: Negative + * + *--------------------------------------------------------------------------- + */ +herr_t +H5VLget_object(hid_t obj_id, void **obj) +{ + herr_t ret_value = SUCCEED; + + FUNC_ENTER_API(FAIL) + H5TRACE2("e", "i**x", obj_id, obj); + + /* Check args */ + if (!obj) + HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "invalid object pointer") + + if (NULL == (*obj = H5VL_get_object(obj_id))) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "ID does not contain a valid object") + +done: + FUNC_LEAVE_API(ret_value) +} /* H5VLget_object */ + + +/*------------------------------------------------------------------------- + * Function: H5VLattr_create + * + * Purpose: Creates an attribute + * + * Return: Success: Pointer to the new attribute + * + * Failure: NULL + * + *------------------------------------------------------------------------- + */ +void * +H5VLattr_create(void *obj, H5VL_loc_params_t loc_params, hid_t driver_id, const char *name, + hid_t acpl_id, hid_t aapl_id, hid_t dxpl_id, void **req) +{ + H5VL_class_t *cls = NULL; + void *ret_value = NULL; /* Return value */ + + FUNC_ENTER_API(NULL) + H5TRACE8("*x", "*xxi*siii**x", obj, loc_params, driver_id, name, acpl_id, + aapl_id, dxpl_id, req); + + if (NULL == obj) + HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, NULL, "invalid object") + if(NULL == (cls = (H5VL_class_t *)H5I_object_verify(driver_id, H5I_VOL))) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, NULL, "not a VOL driver ID") + + if(NULL == (ret_value = H5VL_attr_create(obj, loc_params, cls, name, + acpl_id, aapl_id, dxpl_id, req))) + HGOTO_ERROR(H5E_VOL, H5E_CANTINIT, NULL, "unable to create attribute") + +done: + FUNC_LEAVE_API(ret_value) +} /* end H5VLattr_create() */ + + +/*------------------------------------------------------------------------- + * Function: H5VLattr_open + * + * Purpose: Opens an attribute + * + * Return: Success: Pointer to the new attribute + * + * Failure: NULL + * + *------------------------------------------------------------------------- + */ +void * +H5VLattr_open(void *obj, H5VL_loc_params_t loc_params, hid_t driver_id, const char *name, + hid_t aapl_id, hid_t dxpl_id, void **req) +{ + H5VL_class_t *cls = NULL; + void *ret_value = NULL; /* Return value */ + + FUNC_ENTER_API(NULL) + H5TRACE7("*x", "*xxi*sii**x", obj, loc_params, driver_id, name, aapl_id, + dxpl_id, req); + + if (NULL == obj) + HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, NULL, "invalid object") + if(NULL == (cls = (H5VL_class_t *)H5I_object_verify(driver_id, H5I_VOL))) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, NULL, "not a VOL driver ID") + + if(NULL == (ret_value = H5VL_attr_open(obj, loc_params, cls, name, aapl_id, + dxpl_id, req))) + HGOTO_ERROR(H5E_VOL, H5E_CANTINIT, NULL, "unable to open attribute") + +done: + FUNC_LEAVE_API(ret_value) +} /* end H5VLattr_open() */ + + +/*------------------------------------------------------------------------- + * Function: H5VLattr_read + * + * Purpose: Reads data from an attribute + * + * Return: Success: Non-negative + * + * Failure: Negative + * + *------------------------------------------------------------------------- + */ +herr_t H5VLattr_read(void *attr, hid_t driver_id, hid_t mem_type_id, void *buf, hid_t dxpl_id, void **req) +{ + H5VL_class_t *cls = NULL; + herr_t ret_value = SUCCEED; + + FUNC_ENTER_API(FAIL) + + if (NULL == attr) + HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "invalid object") + if(NULL == (cls = (H5VL_class_t *)H5I_object_verify(driver_id, H5I_VOL))) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a VOL driver ID") + + if((ret_value = H5VL_attr_read(attr, cls, mem_type_id, buf, dxpl_id, req)) < 0) + HGOTO_ERROR(H5E_VOL, H5E_CANTINIT, FAIL, "unable to read attribute") + +done: + FUNC_LEAVE_API(ret_value) +} /* end H5VLattr_read() */ + + +/*------------------------------------------------------------------------- + * Function: H5VLattr_write + * + * Purpose: Writes data to an attribute + * + * Return: Success: Non-negative + * + * Failure: Negative + * + *------------------------------------------------------------------------- + */ +herr_t H5VLattr_write(void *attr, hid_t driver_id, hid_t mem_type_id, const void *buf, hid_t dxpl_id, void **req) +{ + H5VL_class_t *cls = NULL; + herr_t ret_value = SUCCEED; + + FUNC_ENTER_API(FAIL) + + if (NULL == attr) + HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "invalid object") + if(NULL == (cls = (H5VL_class_t *)H5I_object_verify(driver_id, H5I_VOL))) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a VOL driver ID") + + if((ret_value = H5VL_attr_write(attr, cls, mem_type_id, buf, dxpl_id, req)) < 0) + HGOTO_ERROR(H5E_VOL, H5E_CANTINIT, FAIL, "unable to write attribute") + +done: + FUNC_LEAVE_API(ret_value) +} /* end H5VLattr_write() */ + + +/*------------------------------------------------------------------------- + * Function: H5VLattr_get + * + * Purpose: Gets information about the attribute + * + * Return: Success: Non-negative + * + * Failure: Negative + * + *------------------------------------------------------------------------- + */ +herr_t +H5VLattr_get(void *obj, hid_t driver_id, H5VL_attr_get_t get_type, + hid_t dxpl_id, void **req, va_list arguments) +{ + H5VL_class_t *cls = NULL; + herr_t ret_value = SUCCEED; + + FUNC_ENTER_API(FAIL) + H5TRACE6("e", "*xiVai**xx", obj, driver_id, get_type, dxpl_id, req, arguments); + + if (NULL == obj) + HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "invalid object") + if(NULL == (cls = (H5VL_class_t *)H5I_object_verify(driver_id, H5I_VOL))) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a VOL driver ID") + + /* Bypass the H5VLint layer */ + if(NULL == cls->attr_cls.get) + HGOTO_ERROR(H5E_VOL, H5E_UNSUPPORTED, FAIL, "vol driver has no `attr get' method") + if((ret_value = (cls->attr_cls.get)(obj, get_type, dxpl_id, req, arguments)) < 0) + HGOTO_ERROR(H5E_VOL, H5E_CANTGET, FAIL, "Unable to get attribute information") + +done: + FUNC_LEAVE_API(ret_value) +} /* end H5VLattr_get() */ + + +/*------------------------------------------------------------------------- + * Function: H5VLattr_specific + * + * Purpose: Performs a driver-specific operation on an attribute + * + * Return: Success: Non-negative + * + * Failure: Negative + * + *------------------------------------------------------------------------- + */ +herr_t +H5VLattr_specific(void *obj, H5VL_loc_params_t loc_params, hid_t driver_id, + H5VL_attr_specific_t specific_type, hid_t dxpl_id, void **req, va_list arguments) +{ + H5VL_class_t *cls = NULL; + herr_t ret_value = SUCCEED; + + FUNC_ENTER_API(FAIL) + H5TRACE7("e", "*xxiVbi**xx", obj, loc_params, driver_id, specific_type, + dxpl_id, req, arguments); + + if (NULL == obj) + HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "invalid object") + if(NULL == (cls = (H5VL_class_t *)H5I_object_verify(driver_id, H5I_VOL))) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a VOL driver ID") + + /* Bypass the H5VLint layer */ + if(NULL == cls->attr_cls.specific) + HGOTO_ERROR(H5E_VOL, H5E_UNSUPPORTED, FAIL, "vol driver has no `attr specific' method") + if((ret_value = (cls->attr_cls.specific) + (obj, loc_params, specific_type, dxpl_id, req, arguments)) < 0) + HGOTO_ERROR(H5E_VOL, H5E_CANTOPERATE, FAIL, "Unable to execute attribute specific callback") + +done: + FUNC_LEAVE_API(ret_value) +} /* end H5VLattr_specific() */ + + +/*------------------------------------------------------------------------- + * Function: H5VLattr_optional + * + * Purpose: Performs an optional driver-specific operation on an attribute + * + * Return: Success: Non-negative + * + * Failure: Negative + * + *------------------------------------------------------------------------- + */ +herr_t +H5VLattr_optional(void *obj, hid_t driver_id, hid_t dxpl_id, void **req, va_list arguments) +{ + H5VL_class_t *cls = NULL; + herr_t ret_value = SUCCEED; + + FUNC_ENTER_API(FAIL) + H5TRACE5("e", "*xii**xx", obj, driver_id, dxpl_id, req, arguments); + + if (NULL == obj) + HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "invalid object") + if(NULL == (cls = (H5VL_class_t *)H5I_object_verify(driver_id, H5I_VOL))) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a VOL driver ID") + + /* Have to bypass the H5VLint layer due to unknown val_list arguments */ + if(NULL == cls->attr_cls.optional) + HGOTO_ERROR(H5E_VOL, H5E_UNSUPPORTED, FAIL, "vol driver has no `attr optional' method") + if((ret_value = (cls->attr_cls.optional)(obj, dxpl_id, req, arguments)) < 0) + HGOTO_ERROR(H5E_VOL, H5E_CANTOPERATE, FAIL, "Unable to execute attribute optional callback") + +done: + FUNC_LEAVE_API(ret_value) +} /* end H5VLattr_optional() */ + + +/*------------------------------------------------------------------------- + * Function: H5VLattr_close + * + * Purpose: Closes an attribute + * + * Return: Success: Non-negative + * + * Failure: Negative + * + *------------------------------------------------------------------------- + */ +herr_t +H5VLattr_close(void *attr, hid_t driver_id, hid_t dxpl_id, void **req) +{ + H5VL_class_t *cls = NULL; + herr_t ret_value = SUCCEED; + + FUNC_ENTER_API(FAIL) + H5TRACE4("e", "*xii**x", attr, driver_id, dxpl_id, req); + + if (NULL == attr) + HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "invalid object") + if(NULL == (cls = (H5VL_class_t *)H5I_object_verify(driver_id, H5I_VOL))) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a VOL driver ID") + + if((ret_value = H5VL_attr_close(attr, cls, dxpl_id, req)) < 0) + HGOTO_ERROR(H5E_VOL, H5E_CANTRELEASE, FAIL, "unable to close attribute") + +done: + FUNC_LEAVE_API(ret_value) +} /* end H5VLattr_close() */ + + +/*------------------------------------------------------------------------- + * Function: H5VLdataset_create + * + * Purpose: Creates a dataset + * + * Return: Success: Pointer to the new dataset + * + * Failure: NULL + * + *------------------------------------------------------------------------- + */ +void * +H5VLdataset_create(void *obj, H5VL_loc_params_t loc_params, hid_t driver_id, const char *name, + hid_t dcpl_id, hid_t dapl_id, hid_t dxpl_id, void **req) +{ + H5VL_class_t *cls = NULL; + void *ret_value = NULL; /* Return value */ + + FUNC_ENTER_API(NULL) + H5TRACE8("*x", "*xxi*siii**x", obj, loc_params, driver_id, name, dcpl_id, + dapl_id, dxpl_id, req); + + if (NULL == obj) + HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, NULL, "invalid object") + if(NULL == (cls = (H5VL_class_t *)H5I_object_verify(driver_id, H5I_VOL))) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, NULL, "not a VOL driver ID") + + if(NULL == (ret_value = H5VL_dataset_create(obj, loc_params, cls, name, + dcpl_id, dapl_id, dxpl_id, req))) + HGOTO_ERROR(H5E_VOL, H5E_CANTINIT, NULL, "unable to create dataset") + +done: + FUNC_LEAVE_API(ret_value) +} /* end H5VLdataset_create() */ + + +/*------------------------------------------------------------------------- + * Function: H5VLdataset_open + * + * Purpose: Opens a dataset + * + * Return: Success: Pointer to the new dataset + * + * Failure: NULL + * + *------------------------------------------------------------------------- + */ +void * +H5VLdataset_open(void *obj, H5VL_loc_params_t loc_params, hid_t driver_id, const char *name, + hid_t dapl_id, hid_t dxpl_id, void **req) +{ + H5VL_class_t *cls = NULL; + void *ret_value = NULL; + + FUNC_ENTER_API(NULL) + H5TRACE7("*x", "*xxi*sii**x", obj, loc_params, driver_id, name, dapl_id, + dxpl_id, req); + + if (NULL == obj) + HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, NULL, "invalid object") + if(NULL == (cls = (H5VL_class_t *)H5I_object_verify(driver_id, H5I_VOL))) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, NULL, "not a VOL driver ID") + + if(NULL == (ret_value = H5VL_dataset_open(obj, loc_params, cls, name, dapl_id, dxpl_id, req))) + HGOTO_ERROR(H5E_VOL, H5E_CANTINIT, NULL, "unable to open dataset") + +done: + FUNC_LEAVE_API(ret_value) +} /* end H5VLdataset_open() */ + + +/*------------------------------------------------------------------------- + * Function: H5VLdataset_read + * + * Purpose: Reads data from a dataset + * + * Return: Success: Non-negative + * + * Failure: Negative + * + *------------------------------------------------------------------------- + */ +herr_t +H5VLdataset_read(void *dset, hid_t driver_id, hid_t mem_type_id, hid_t mem_space_id, + hid_t file_space_id, hid_t plist_id, void *buf, void **req) +{ + H5VL_class_t *cls = NULL; + herr_t ret_value = SUCCEED; + + FUNC_ENTER_API(FAIL) + H5TRACE8("e", "*xiiiii*x**x", dset, driver_id, mem_type_id, mem_space_id, + file_space_id, plist_id, buf, req); + + if (NULL == dset) + HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "invalid object") + if(NULL == (cls = (H5VL_class_t *)H5I_object_verify(driver_id, H5I_VOL))) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a VOL driver ID") + + if((ret_value = H5VL_dataset_read(dset, cls, mem_type_id, mem_space_id, file_space_id, + plist_id, buf, req)) < 0) + HGOTO_ERROR(H5E_VOL, H5E_CANTINIT, FAIL, "unable to read dataset") + +done: + FUNC_LEAVE_API(ret_value) +} /* end H5VLdataset_read() */ + + +/*------------------------------------------------------------------------- + * Function: H5VLdataset_write + * + * Purpose: Writes data to a dataset + * + * Return: Success: Non-negative + * + * Failure: Negative + * + *------------------------------------------------------------------------- + */ +herr_t +H5VLdataset_write(void *dset, hid_t driver_id, hid_t mem_type_id, hid_t mem_space_id, + hid_t file_space_id, hid_t plist_id, const void *buf, void **req) +{ + H5VL_class_t *cls = NULL; + herr_t ret_value = SUCCEED; + + FUNC_ENTER_API(FAIL) + H5TRACE8("e", "*xiiiii*x**x", dset, driver_id, mem_type_id, mem_space_id, + file_space_id, plist_id, buf, req); + + if (NULL == dset) + HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "invalid object") + if(NULL == (cls = (H5VL_class_t *)H5I_object_verify(driver_id, H5I_VOL))) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a VOL driver ID") + + if((ret_value = H5VL_dataset_write(dset, cls, mem_type_id, mem_space_id, file_space_id, + plist_id, buf, req)) < 0) + HGOTO_ERROR(H5E_VOL, H5E_CANTINIT, FAIL, "unable to write dataset") + +done: + FUNC_LEAVE_API(ret_value) +} /* end H5VLdataset_write() */ + + +/*------------------------------------------------------------------------- + * Function: H5VLdataset_get + * + * Purpose: Gets information about a dataset + * + * Return: Success: Non-negative + * + * Failure: Negative + * + *------------------------------------------------------------------------- + */ +herr_t +H5VLdataset_get(void *dset, hid_t driver_id, H5VL_dataset_get_t get_type, + hid_t dxpl_id, void **req, va_list arguments) +{ + H5VL_class_t *cls = NULL; + herr_t ret_value = SUCCEED; + + FUNC_ENTER_API(FAIL) + H5TRACE6("e", "*xiVci**xx", dset, driver_id, get_type, dxpl_id, req, arguments); + + if (NULL == dset) + HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "invalid object") + if(NULL == (cls = (H5VL_class_t *)H5I_object_verify(driver_id, H5I_VOL))) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a VOL driver ID") + + /* Bypass the H5VLint layer */ + if(NULL == cls->dataset_cls.get) + HGOTO_ERROR(H5E_VOL, H5E_UNSUPPORTED, FAIL, "vol driver has no `dataset get' method") + if((ret_value = (cls->dataset_cls.get)(dset, get_type, dxpl_id, req, arguments)) < 0) + HGOTO_ERROR(H5E_VOL, H5E_CANTGET, FAIL, "Unable to execute dataset get callback") + +done: + FUNC_LEAVE_API(ret_value) +} /* end H5VLdataset_get() */ + + +/*------------------------------------------------------------------------- + * Function: H5VLdataset_specific + * + * Purpose: Performs a driver-specific operation on a dataset + * + * Return: Success: Non-negative + * + * Failure: Negative + * + *------------------------------------------------------------------------- + */ +herr_t +H5VLdataset_specific(void *obj, hid_t driver_id, H5VL_dataset_specific_t specific_type, + hid_t dxpl_id, void **req, va_list arguments) +{ + H5VL_class_t *cls = NULL; + herr_t ret_value = SUCCEED; + + FUNC_ENTER_API(FAIL) + H5TRACE6("e", "*xiVdi**xx", obj, driver_id, specific_type, dxpl_id, req, + arguments); + + if (NULL == obj) + HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "invalid object") + if(NULL == (cls = (H5VL_class_t *)H5I_object_verify(driver_id, H5I_VOL))) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a VOL driver ID") + + if(NULL == cls->dataset_cls.specific) + HGOTO_ERROR(H5E_VOL, H5E_UNSUPPORTED, FAIL, "vol driver has no `dataset specific' method") + if((ret_value = (cls->dataset_cls.specific) + (obj, specific_type, dxpl_id, req, arguments)) < 0) + HGOTO_ERROR(H5E_VOL, H5E_CANTOPERATE, FAIL, "Unable to execute dataset specific callback") + +done: + FUNC_LEAVE_API(ret_value) +} /* end H5VLdataset_specific() */ + + +/*------------------------------------------------------------------------- + * Function: H5VLdataset_optional + * + * Purpose: Performs an optional driver-specific operation on a dataset + * + * Return: Success: Non-negative + * + * Failure: Negative + * + *------------------------------------------------------------------------- + */ +herr_t +H5VLdataset_optional(void *obj, hid_t driver_id, hid_t dxpl_id, void **req, va_list arguments) +{ + H5VL_class_t *cls = NULL; + herr_t ret_value = SUCCEED; + + FUNC_ENTER_API(FAIL) + H5TRACE5("e", "*xii**xx", obj, driver_id, dxpl_id, req, arguments); + + if (NULL == obj) + HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "invalid object") + if(NULL == (cls = (H5VL_class_t *)H5I_object_verify(driver_id, H5I_VOL))) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a VOL driver ID") + + if(NULL == cls->dataset_cls.optional) + HGOTO_ERROR(H5E_VOL, H5E_UNSUPPORTED, FAIL, "vol driver has no `dataset optional' method") + if((ret_value = (cls->dataset_cls.optional)(obj, dxpl_id, req, arguments)) < 0) + HGOTO_ERROR(H5E_VOL, H5E_CANTOPERATE, FAIL, "Unable to execute dataset optional callback") + +done: + FUNC_LEAVE_API(ret_value) +} /* end H5VLdataset_optional() */ + + +/*------------------------------------------------------------------------- + * Function: H5VLdataset_close + * + * Purpose: Closes a dataset + * + * Return: Success: Non-negative + * + * Failure: Negative + * + *------------------------------------------------------------------------- + */ +herr_t +H5VLdataset_close(void *dset, hid_t driver_id, hid_t dxpl_id, void **req) +{ + H5VL_class_t *cls = NULL; + herr_t ret_value = SUCCEED; + + FUNC_ENTER_API(FAIL) + H5TRACE4("e", "*xii**x", dset, driver_id, dxpl_id, req); + + if (NULL == dset) + HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "invalid object") + if(NULL == (cls = (H5VL_class_t *)H5I_object_verify(driver_id, H5I_VOL))) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a VOL driver ID") + + if((ret_value = H5VL_dataset_close(dset, cls, dxpl_id, req)) < 0) + HGOTO_ERROR(H5E_VOL, H5E_CANTRELEASE, FAIL, "unable to close dataset") + +done: + FUNC_LEAVE_API(ret_value) +} /* end H5VLdataset_close() */ + + +/*------------------------------------------------------------------------- + * Function: H5VLfile_create + * + * Purpose: Creates a file + * + * Return: Success: Pointer to the new file + * + * Failure: NULL + * + *------------------------------------------------------------------------- + */ +void * +H5VLfile_create(const char *name, unsigned flags, hid_t fcpl_id, hid_t fapl_id, + hid_t dxpl_id, void **req) +{ + H5P_genplist_t *plist; /* Property list pointer */ + H5VL_driver_prop_t driver_prop; /* Property for vol driver ID & info */ + H5VL_class_t *cls = NULL; + void *ret_value = NULL; + + FUNC_ENTER_API(NULL) + H5TRACE6("*x", "*sIuiii**x", name, flags, fcpl_id, fapl_id, dxpl_id, req); + + /* get the VOL info from the fapl */ + if(NULL == (plist = (H5P_genplist_t *)H5I_object(fapl_id))) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, NULL, "not a file access property list") + if(H5P_peek(plist, H5F_ACS_VOL_DRV_NAME, &driver_prop) < 0) + HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, NULL, "can't get vol driver info") + + if(NULL == (cls = (H5VL_class_t *)H5I_object_verify(driver_prop.driver_id, H5I_VOL))) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, NULL, "not a VOL driver ID") + + if(NULL == (ret_value = H5VL_file_create(cls, name, flags, fcpl_id, fapl_id, + dxpl_id, req))) + HGOTO_ERROR(H5E_VOL, H5E_CANTINIT, NULL, "unable to create file") + +done: + FUNC_LEAVE_API(ret_value) +} /* end H5VLfile_create() */ + + +/*------------------------------------------------------------------------- + * Function: H5VLfile_open + * + * Purpose: Opens a file + * + * Return: Success: Pointer to the new file + * + * Failure: NULL + * + *------------------------------------------------------------------------- + */ +void * +H5VLfile_open(const char *name, unsigned flags, hid_t fapl_id, hid_t dxpl_id, void **req) +{ + H5P_genplist_t *plist; /* Property list pointer */ + H5VL_driver_prop_t driver_prop; /* Property for vol driver ID & info */ + H5VL_class_t *cls = NULL; + void *ret_value = NULL; + + FUNC_ENTER_API(NULL) + H5TRACE5("*x", "*sIuii**x", name, flags, fapl_id, dxpl_id, req); + + /* get the VOL info from the fapl */ + if(NULL == (plist = (H5P_genplist_t *)H5I_object(fapl_id))) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, NULL, "not a file access property list") + if(H5P_peek(plist, H5F_ACS_VOL_DRV_NAME, &driver_prop) < 0) + HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, NULL, "can't get vol driver info") + + if(NULL == (cls = (H5VL_class_t *)H5I_object_verify(driver_prop.driver_id, H5I_VOL))) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, NULL, "not a VOL driver ID") + + if(NULL == (ret_value = H5VL_file_open(cls, name, flags, fapl_id, dxpl_id, req))) + HGOTO_ERROR(H5E_VOL, H5E_CANTINIT, NULL, "unable to create file") + +done: + FUNC_LEAVE_API(ret_value) +} /* end H5VLfile_open() */ + + +/*------------------------------------------------------------------------- + * Function: H5VLfile_get + * + * Purpose: Gets information about the file + * + * Return: Success: Non-negative + * + * Failure: Negative + * + *------------------------------------------------------------------------- + */ +herr_t +H5VLfile_get(void *file, hid_t driver_id, H5VL_file_get_t get_type, + hid_t dxpl_id, void **req, va_list arguments) +{ + H5VL_class_t *cls = NULL; + herr_t ret_value = SUCCEED; + + FUNC_ENTER_API(FAIL) + H5TRACE6("e", "*xiVgi**xx", file, driver_id, get_type, dxpl_id, req, arguments); + + if(NULL == file) + HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "invalid object") + if(NULL == (cls = (H5VL_class_t *)H5I_object_verify(driver_id, H5I_VOL))) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a VOL driver ID") + + /* Bypass the H5VLint layer */ + if(NULL == cls->file_cls.get) + HGOTO_ERROR(H5E_VOL, H5E_UNSUPPORTED, FAIL, "vol driver has no `file get' method") + if((ret_value = (cls->file_cls.get)(file, get_type, dxpl_id, req, arguments)) < 0) + HGOTO_ERROR(H5E_VOL, H5E_CANTGET, FAIL, "Unable to execute file get callback") + +done: + FUNC_LEAVE_API(ret_value) +} /* end H5VLfile_get() */ + + +/*------------------------------------------------------------------------- + * Function: H5VLfile_specific + * + * Purpose: Performs a driver-specific operation on a file + * + * Return: Success: Non-negative + * + * Failure: Negative + * + *------------------------------------------------------------------------- + */ +herr_t +H5VLfile_specific(void *file, hid_t driver_id, H5VL_file_specific_t specific_type, + hid_t dxpl_id, void **req, va_list arguments) +{ + H5VL_class_t *cls = NULL; + herr_t ret_value = SUCCEED; + + FUNC_ENTER_API(FAIL) + H5TRACE6("e", "*xiVhi**xx", file, driver_id, specific_type, dxpl_id, req, + arguments); + + if(specific_type == H5VL_FILE_IS_ACCESSIBLE) { + H5P_genplist_t *plist; /* Property list pointer */ + H5VL_driver_prop_t driver_prop; /* Property for vol driver ID & info */ + hid_t fapl_id; + + fapl_id = va_arg (arguments, hid_t); + + /* get the VOL info from the fapl */ + if(NULL == (plist = (H5P_genplist_t *)H5I_object(fapl_id))) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a file access property list") + + if(H5P_peek(plist, H5F_ACS_VOL_DRV_NAME, &driver_prop) < 0) + HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, FAIL, "can't get vol driver info") + + if(NULL == (cls = (H5VL_class_t *)H5I_object_verify(driver_prop.driver_id, H5I_VOL))) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a VOL driver ID") + + if((ret_value = (cls->file_cls.specific) + (file, specific_type, dxpl_id, req, arguments)) < 0) + HGOTO_ERROR(H5E_VOL, H5E_CANTGET, FAIL, "specific failed") + } + else { + if(NULL == file) + HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "invalid object") + if(NULL == (cls = (H5VL_class_t *)H5I_object_verify(driver_id, H5I_VOL))) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a VOL driver ID") + + if(NULL == cls->file_cls.specific) + HGOTO_ERROR(H5E_VOL, H5E_UNSUPPORTED, FAIL, "vol driver has no `file specific' method") + if((ret_value = (cls->file_cls.specific) + (file, specific_type, dxpl_id, req, arguments)) < 0) + HGOTO_ERROR(H5E_VOL, H5E_CANTOPERATE, FAIL, "Unable to execute file specific callback") + } + +done: + FUNC_LEAVE_API(ret_value) +} /* end H5VLfile_specific() */ + + +/*------------------------------------------------------------------------- + * Function: H5VLfile_optional + * + * Purpose: Performs an optional driver-specific operation on a file + * + * Return: Success: Non-negative + * + * Failure: Negative + * + *------------------------------------------------------------------------- + */ +herr_t +H5VLfile_optional(void *file, hid_t driver_id, hid_t dxpl_id, void **req, va_list arguments) +{ + H5VL_class_t *cls = NULL; + herr_t ret_value = SUCCEED; + + FUNC_ENTER_API(FAIL) + H5TRACE5("e", "*xii**xx", file, driver_id, dxpl_id, req, arguments); + + if(NULL == file) + HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "invalid object") + if(NULL == (cls = (H5VL_class_t *)H5I_object_verify(driver_id, H5I_VOL))) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a VOL driver ID") + + if(NULL == cls->file_cls.optional) + HGOTO_ERROR(H5E_VOL, H5E_UNSUPPORTED, FAIL, "vol driver has no `file optional' method") + if((ret_value = (cls->file_cls.optional)(file, dxpl_id, req, arguments)) < 0) + HGOTO_ERROR(H5E_VOL, H5E_CANTOPERATE, FAIL, "Unable to execute file optional callback") + +done: + FUNC_LEAVE_API(ret_value) +} /* end H5VLfile_optional() */ + + +/*------------------------------------------------------------------------- + * Function: H5VLfile_close + * + * Purpose: Closes a file + * + * Return: Success: Non-negative + * + * Failure: Negative + * + *------------------------------------------------------------------------- + */ +herr_t +H5VLfile_close(void *file, hid_t driver_id, hid_t dxpl_id, void **req) +{ + H5VL_class_t *cls = NULL; + herr_t ret_value = SUCCEED; + + FUNC_ENTER_API(FAIL) + H5TRACE4("e", "*xii**x", file, driver_id, dxpl_id, req); + + if(NULL == file) + HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "invalid object") + if(NULL == (cls = (H5VL_class_t *)H5I_object_verify(driver_id, H5I_VOL))) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a VOL driver ID") + + if((ret_value = H5VL_file_close(file, cls, dxpl_id, req)) < 0) + HGOTO_ERROR(H5E_VOL, H5E_CANTRELEASE, FAIL, "unable to close file") + +done: + FUNC_LEAVE_API(ret_value) +} /* end H5VLfile_close() */ + + +/*------------------------------------------------------------------------- + * Function: H5VLgroup_create + * + * Purpose: Creates a group + * + * Return: Success: Pointer to the new group + * + * Failure: NULL + * + *------------------------------------------------------------------------- + */ +void * +H5VLgroup_create(void *obj, H5VL_loc_params_t loc_params, hid_t driver_id, const char *name, + hid_t gcpl_id, hid_t gapl_id, hid_t dxpl_id, void **req) +{ + H5VL_class_t *cls = NULL; + void *ret_value = NULL; + + FUNC_ENTER_API(NULL) + H5TRACE8("*x", "*xxi*siii**x", obj, loc_params, driver_id, name, gcpl_id, + gapl_id, dxpl_id, req); + + if (NULL == obj) + HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, NULL, "invalid object") + if(NULL == (cls = (H5VL_class_t *)H5I_object_verify(driver_id, H5I_VOL))) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, NULL, "not a VOL driver ID") + + if(NULL == (ret_value = H5VL_group_create(obj, loc_params, cls, name, + gcpl_id, gapl_id, dxpl_id, req))) + HGOTO_ERROR(H5E_VOL, H5E_CANTINIT, NULL, "unable to create group") + +done: + FUNC_LEAVE_API(ret_value) +} /* end H5VLgroup_create() */ + + +/*------------------------------------------------------------------------- + * Function: H5VLgroup_open + * + * Purpose: Opens a group + * + * Return: Success: Pointer to the new group + * + * Failure: NULL + * + *------------------------------------------------------------------------- + */ +void * +H5VLgroup_open(void *obj, H5VL_loc_params_t loc_params, hid_t driver_id, const char *name, + hid_t gapl_id, hid_t dxpl_id, void **req) +{ + H5VL_class_t *cls = NULL; + void *ret_value = NULL; + + FUNC_ENTER_API(NULL) + H5TRACE7("*x", "*xxi*sii**x", obj, loc_params, driver_id, name, gapl_id, + dxpl_id, req); + + if (NULL == obj) + HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, NULL, "invalid object") + if(NULL == (cls = (H5VL_class_t *)H5I_object_verify(driver_id, H5I_VOL))) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, NULL, "not a VOL driver ID") + + if(NULL == (ret_value = H5VL_group_open(obj, loc_params, cls, name, + gapl_id, dxpl_id, req))) + HGOTO_ERROR(H5E_VOL, H5E_CANTINIT, NULL, "unable to open group") + +done: + FUNC_LEAVE_API(ret_value) +} /* end H5VLgroup_open() */ + + +/*------------------------------------------------------------------------- + * Function: H5VLgroup_get + * + * Purpose: Gets information about the group + * + * Return: Success: Non-negative + * + * Failure: Negative + * + *------------------------------------------------------------------------- + */ +herr_t +H5VLgroup_get(void *obj, hid_t driver_id, H5VL_group_get_t get_type, + hid_t dxpl_id, void **req, va_list arguments) +{ + H5VL_class_t *cls = NULL; + herr_t ret_value = SUCCEED; + + FUNC_ENTER_API(FAIL) + H5TRACE6("e", "*xiVii**xx", obj, driver_id, get_type, dxpl_id, req, arguments); + + if(NULL == obj) + HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "invalid object") + if(NULL == (cls = (H5VL_class_t *)H5I_object_verify(driver_id, H5I_VOL))) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a VOL driver ID") + + /* Bypass the H5VLint layer */ + if(NULL == cls->group_cls.get) + HGOTO_ERROR(H5E_VOL, H5E_UNSUPPORTED, FAIL, "vol driver has no `group get' method") + if((ret_value = (cls->group_cls.get)(obj, get_type, dxpl_id, req, arguments)) < 0) + HGOTO_ERROR(H5E_VOL, H5E_CANTGET, FAIL, "Unable to execute group get callback") + +done: + FUNC_LEAVE_API(ret_value) +} /* end H5VLgroup_get() */ + + +/*------------------------------------------------------------------------- + * Function: H5VLgroup_specific + * + * Purpose: Performs a driver-specific operation on a group + * + * Return: Success: Non-negative + * + * Failure: Negative + * + *------------------------------------------------------------------------- + */ +herr_t +H5VLgroup_specific(void *obj, hid_t driver_id, H5VL_group_specific_t specific_type, + hid_t dxpl_id, void **req, va_list arguments) +{ + H5VL_class_t *cls = NULL; + herr_t ret_value = SUCCEED; + + FUNC_ENTER_API(FAIL) + H5TRACE6("e", "*xiVji**xx", obj, driver_id, specific_type, dxpl_id, req, + arguments); + + if (NULL == obj) + HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "invalid object") + if(NULL == (cls = (H5VL_class_t *)H5I_object_verify(driver_id, H5I_VOL))) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a VOL driver ID") + + if(NULL == cls->group_cls.specific) + HGOTO_ERROR(H5E_VOL, H5E_UNSUPPORTED, FAIL, "vol driver has no `group specific' method") + if((ret_value = (cls->group_cls.specific) + (obj, specific_type, dxpl_id, req, arguments)) < 0) + HGOTO_ERROR(H5E_VOL, H5E_CANTOPERATE, FAIL, "Unable to execute group specific callback") + +done: + FUNC_LEAVE_API(ret_value) +} /* end H5VLgroup_specific() */ + + +/*------------------------------------------------------------------------- + * Function: H5VLgroup_optional + * + * Purpose: Performs an optional driver-specific operation on a group + * + * Return: Success: Non-negative + * + * Failure: Negative + * + *------------------------------------------------------------------------- + */ +herr_t +H5VLgroup_optional(void *obj, hid_t driver_id, hid_t dxpl_id, void **req, va_list arguments) +{ + H5VL_class_t *cls = NULL; + herr_t ret_value = SUCCEED; + + FUNC_ENTER_API(FAIL) + H5TRACE5("e", "*xii**xx", obj, driver_id, dxpl_id, req, arguments); + + if (NULL == obj) + HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "invalid object") + if(NULL == (cls = (H5VL_class_t *)H5I_object_verify(driver_id, H5I_VOL))) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a VOL driver ID") + + if(NULL == cls->group_cls.optional) + HGOTO_ERROR(H5E_VOL, H5E_UNSUPPORTED, FAIL, "vol driver has no `group optional' method") + if((ret_value = (cls->group_cls.optional)(obj, dxpl_id, req, arguments)) < 0) + HGOTO_ERROR(H5E_VOL, H5E_CANTOPERATE, FAIL, "Unable to execute group optional callback") + +done: + FUNC_LEAVE_API(ret_value) +} /* end H5VLgroup_optional() */ + + +/*------------------------------------------------------------------------- + * Function: H5VLgroup_close + * + * Purpose: Closes a group + * + * Return: Success: Non-negative + * + * Failure: Negative + * + *------------------------------------------------------------------------- + */ +herr_t +H5VLgroup_close(void *grp, hid_t driver_id, hid_t dxpl_id, void **req) +{ + H5VL_class_t *cls = NULL; + herr_t ret_value = SUCCEED; + + FUNC_ENTER_API(FAIL) + H5TRACE4("e", "*xii**x", grp, driver_id, dxpl_id, req); + + if(NULL == grp) + HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "invalid object") + if(NULL == (cls = (H5VL_class_t *)H5I_object_verify(driver_id, H5I_VOL))) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a VOL driver ID") + + if((ret_value = H5VL_group_close(grp, cls, dxpl_id, req)) < 0) + HGOTO_ERROR(H5E_VOL, H5E_CANTRELEASE, FAIL, "unable to close group") + +done: + FUNC_LEAVE_API(ret_value) +} /* end H5VLgroup_close() */ + + +/*------------------------------------------------------------------------- + * Function: H5VLlink_create + * + * Purpose: Creates a hard link + * + * Return: Success: Non-negative + * + * Failure: Negative + * + *------------------------------------------------------------------------- + */ +herr_t +H5VLlink_create(H5VL_link_create_type_t create_type, void *obj, H5VL_loc_params_t loc_params, + hid_t driver_id, hid_t lcpl_id, hid_t lapl_id, hid_t dxpl_id, void **req) +{ + H5VL_class_t *cls = NULL; + herr_t ret_value = SUCCEED; + + FUNC_ENTER_API(FAIL) + H5TRACE8("e", "Vk*xxiiii**x", create_type, obj, loc_params, driver_id, lcpl_id, + lapl_id, dxpl_id, req); + + if(NULL == obj) + HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "invalid object") + if(NULL == (cls = (H5VL_class_t *)H5I_object_verify(driver_id, H5I_VOL))) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a VOL driver ID") + + if((ret_value = H5VL_link_create(create_type, obj, loc_params, cls, lcpl_id, lapl_id, dxpl_id, req)) < 0) + HGOTO_ERROR(H5E_VOL, H5E_CANTINIT, FAIL, "unable to create link") + +done: + FUNC_LEAVE_API(ret_value) +} /* end H5VLlink_create() */ + + +/*------------------------------------------------------------------------- + * Function: H5VLlink_copy + * + * Purpose: Copies a link to a new location + * + * Return: Success: Non-negative + * + * Failure: Negative + * + *------------------------------------------------------------------------- + */ +herr_t +H5VLlink_copy(void *src_obj, H5VL_loc_params_t loc_params1, void *dst_obj, + H5VL_loc_params_t loc_params2, hid_t driver_id, + hid_t lcpl_id, hid_t lapl_id, hid_t dxpl_id, void **req) +{ + H5VL_class_t *cls = NULL; + herr_t ret_value = SUCCEED; + + FUNC_ENTER_API(FAIL) + H5TRACE9("e", "*xx*xxiiii**x", src_obj, loc_params1, dst_obj, loc_params2, + driver_id, lcpl_id, lapl_id, dxpl_id, req); + + if(NULL == src_obj || NULL == dst_obj) + HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "invalid object") + if(NULL == (cls = (H5VL_class_t *)H5I_object_verify(driver_id, H5I_VOL))) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a VOL driver ID") + + if((ret_value = H5VL_link_copy(src_obj, loc_params1, dst_obj, loc_params2, cls, + lcpl_id, lapl_id, dxpl_id, req)) < 0) + HGOTO_ERROR(H5E_VOL, H5E_CANTINIT, FAIL, "unable to copy object") + +done: + FUNC_LEAVE_API(ret_value) +} /* end H5VLlink_copy() */ + + +/*------------------------------------------------------------------------- + * Function: H5VLlink_move + * + * Purpose: Moves a link to another location + * + * Return: Success: Non-negative + * + * Failure: Negative + * + *------------------------------------------------------------------------- + */ +herr_t +H5VLlink_move(void *src_obj, H5VL_loc_params_t loc_params1, void *dst_obj, + H5VL_loc_params_t loc_params2, hid_t driver_id, + hid_t lcpl_id, hid_t lapl_id, hid_t dxpl_id, void **req) +{ + H5VL_class_t *cls = NULL; + herr_t ret_value = SUCCEED; + + FUNC_ENTER_API(FAIL) + H5TRACE9("e", "*xx*xxiiii**x", src_obj, loc_params1, dst_obj, loc_params2, + driver_id, lcpl_id, lapl_id, dxpl_id, req); + + if(NULL == src_obj || NULL == dst_obj) + HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "invalid object") + if(NULL == (cls = (H5VL_class_t *)H5I_object_verify(driver_id, H5I_VOL))) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a VOL driver ID") + + if((ret_value = H5VL_link_move(src_obj, loc_params1, dst_obj, loc_params2, cls, + lcpl_id, lapl_id, dxpl_id, req)) < 0) + HGOTO_ERROR(H5E_VOL, H5E_CANTINIT, FAIL, "unable to move object") + +done: + FUNC_LEAVE_API(ret_value) +} /* end H5VLlink_move() */ + + +/*------------------------------------------------------------------------- + * Function: H5VLlink_get + * + * Purpose: Gets information about a link + * + * Return: Success: Non-negative + * + * Failure: Negative + * + *------------------------------------------------------------------------- + */ +herr_t +H5VLlink_get(void *obj, H5VL_loc_params_t loc_params, hid_t driver_id, H5VL_link_get_t get_type, + hid_t dxpl_id, void **req, va_list arguments) +{ + H5VL_class_t *cls = NULL; + herr_t ret_value = SUCCEED; + + FUNC_ENTER_API(FAIL) + H5TRACE7("e", "*xxiVli**xx", obj, loc_params, driver_id, get_type, dxpl_id, req, + arguments); + + if(NULL == obj) + HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "invalid object") + if(NULL == (cls = (H5VL_class_t *)H5I_object_verify(driver_id, H5I_VOL))) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a VOL driver ID") + + if(NULL == cls->link_cls.get) + HGOTO_ERROR(H5E_VOL, H5E_UNSUPPORTED, FAIL, "vol driver has no `link get' method") + if((ret_value = (cls->link_cls.get) + (obj, loc_params, get_type, dxpl_id, req, arguments)) < 0) + HGOTO_ERROR(H5E_VOL, H5E_CANTOPERATE, FAIL, "Unable to execute link get callback") + +done: + FUNC_LEAVE_API(ret_value) +} /* end H5VLlink_get() */ + + +/*------------------------------------------------------------------------- + * Function: H5VLlink_specific + * + * Purpose: Performs a driver-specific operation on a link + * + * Return: Success: Non-negative + * + * Failure: Negative + * + *------------------------------------------------------------------------- + */ +herr_t +H5VLlink_specific(void *obj, H5VL_loc_params_t loc_params, hid_t driver_id, + H5VL_link_specific_t specific_type, hid_t dxpl_id, void **req, va_list arguments) +{ + H5VL_class_t *cls = NULL; + herr_t ret_value = SUCCEED; + + FUNC_ENTER_API(FAIL) + H5TRACE7("e", "*xxiVmi**xx", obj, loc_params, driver_id, specific_type, + dxpl_id, req, arguments); + + if (NULL == obj) + HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "invalid object") + if(NULL == (cls = (H5VL_class_t *)H5I_object_verify(driver_id, H5I_VOL))) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a VOL driver ID") + + /* Bypass the H5VLint layer */ + if(NULL == cls->link_cls.specific) + HGOTO_ERROR(H5E_VOL, H5E_UNSUPPORTED, FAIL, "vol driver has no `link specific' method") + if((ret_value = (cls->link_cls.specific) + (obj, loc_params, specific_type, dxpl_id, req, arguments)) < 0) + HGOTO_ERROR(H5E_VOL, H5E_CANTOPERATE, FAIL, "Unable to execute link specific callback") + +done: + FUNC_LEAVE_API(ret_value) +} /* end H5VLlink_specific() */ + + +/*------------------------------------------------------------------------- + * Function: H5VLlink_optional + * + * Purpose: Performs an optional driver-specific operation on a link + * + * Return: Success: Non-negative + * + * Failure: Negative + * + *------------------------------------------------------------------------- + */ +herr_t +H5VLlink_optional(void *obj, hid_t driver_id, hid_t dxpl_id, void **req, va_list arguments) +{ + H5VL_class_t *cls = NULL; + herr_t ret_value = SUCCEED; + + FUNC_ENTER_API(FAIL) + H5TRACE5("e", "*xii**xx", obj, driver_id, dxpl_id, req, arguments); + + if (NULL == obj) + HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "invalid object") + if(NULL == (cls = (H5VL_class_t *)H5I_object_verify(driver_id, H5I_VOL))) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a VOL driver ID") + + /* Have to bypass the H5VLint layer due to unknown val_list arguments */ + if(NULL == cls->link_cls.optional) + HGOTO_ERROR(H5E_VOL, H5E_UNSUPPORTED, FAIL, "vol driver has no `link optional' method") + if((ret_value = (cls->link_cls.optional)(obj, dxpl_id, req, arguments)) < 0) + HGOTO_ERROR(H5E_VOL, H5E_CANTOPERATE, FAIL, "Unable to execute link optional callback") + +done: + FUNC_LEAVE_API(ret_value) +} /* end H5VLlink_optional() */ + + +/*------------------------------------------------------------------------- + * Function: H5VLobject_open + * + * Purpose: Opens an object + * + * Return: Success: Pointer to the new object + * + * Failure: NULL + * + *------------------------------------------------------------------------- + */ +void * +H5VLobject_open(void *obj, H5VL_loc_params_t params, hid_t driver_id, H5I_type_t *opened_type, + hid_t dxpl_id, void **req) +{ + H5VL_class_t *cls = NULL; + void *ret_value = NULL; + + FUNC_ENTER_API(NULL) + H5TRACE6("*x", "*xxi*Iti**x", obj, params, driver_id, opened_type, dxpl_id, req); + + if (NULL == obj) + HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, NULL, "invalid object") + if(NULL == (cls = (H5VL_class_t *)H5I_object_verify(driver_id, H5I_VOL))) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, NULL, "not a VOL driver ID") + + if(NULL == (ret_value = H5VL_object_open(obj, params, cls, opened_type, dxpl_id, req))) + HGOTO_ERROR(H5E_VOL, H5E_CANTINIT, NULL, "unable to create group") + +done: + FUNC_LEAVE_API(ret_value) +} /* end H5VLobject_open() */ + + +/*------------------------------------------------------------------------- + * Function: H5VLobject_copy + * + * Purpose: Copies an object to another location + * + * Return: Success: Non-negative + * + * Failure: Negative + * + *------------------------------------------------------------------------- + */ +herr_t +H5VLobject_copy(void *src_obj, H5VL_loc_params_t loc_params1, hid_t driver_id1, const char *src_name, + void *dst_obj, H5VL_loc_params_t loc_params2, hid_t driver_id2, const char *dst_name, + hid_t ocpypl_id, hid_t lcpl_id, hid_t dxpl_id, void **req) +{ + H5VL_class_t *cls1 = NULL; + H5VL_class_t *cls2 = NULL; + herr_t ret_value = SUCCEED; + + FUNC_ENTER_API(FAIL) + H5TRACE12("e", "*xxi*s*xxi*siii**x", src_obj, loc_params1, driver_id1, + src_name, dst_obj, loc_params2, driver_id2, dst_name, ocpypl_id, + lcpl_id, dxpl_id, req); + + if(NULL == src_obj || NULL == dst_obj) + HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "invalid object") + if(NULL == (cls1 = (H5VL_class_t *)H5I_object_verify(driver_id1, H5I_VOL))) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a VOL driver ID") + if(NULL == (cls2 = (H5VL_class_t *)H5I_object_verify(driver_id2, H5I_VOL))) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a VOL driver ID") + + if((ret_value = H5VL_object_copy(src_obj, loc_params1, cls1, src_name, + dst_obj, loc_params2, cls2, dst_name, + ocpypl_id, lcpl_id, dxpl_id, req)) < 0) + HGOTO_ERROR(H5E_VOL, H5E_CANTINIT, FAIL, "unable to move object") + +done: + FUNC_LEAVE_API(ret_value) +} /* end H5VLobject_copy() */ + + +/*------------------------------------------------------------------------- + * Function: H5VLobject_get + * + * Purpose: Gets information about an object + * + * Return: Success: Non-negative + * + * Failure: Negative + * + *------------------------------------------------------------------------- + */ +herr_t +H5VLobject_get(void *obj, H5VL_loc_params_t loc_params, hid_t driver_id, H5VL_object_get_t get_type, + hid_t dxpl_id, void **req, va_list arguments) +{ + H5VL_class_t *cls = NULL; + herr_t ret_value = SUCCEED; + + FUNC_ENTER_API(FAIL) + H5TRACE7("e", "*xxiVni**xx", obj, loc_params, driver_id, get_type, dxpl_id, req, + arguments); + + if(NULL == obj) + HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "invalid object") + if(NULL == (cls = (H5VL_class_t *)H5I_object_verify(driver_id, H5I_VOL))) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a VOL driver ID") + + if(NULL == cls->object_cls.get) + HGOTO_ERROR(H5E_VOL, H5E_UNSUPPORTED, FAIL, "vol driver has no `object get' method") + if((ret_value = (cls->object_cls.get) + (obj, loc_params, get_type, dxpl_id, req, arguments)) < 0) + HGOTO_ERROR(H5E_VOL, H5E_CANTOPERATE, FAIL, "Unable to execute object get callback") + +done: + FUNC_LEAVE_API(ret_value) +} /* end H5VLobject_get() */ + + +/*------------------------------------------------------------------------- + * Function: H5VLobject_specific + * + * Purpose: Performs a driver-specific operation on an object + * + * Return: Success: Non-negative + * + * Failure: Negative + * + *------------------------------------------------------------------------- + */ +herr_t +H5VLobject_specific(void *obj, H5VL_loc_params_t loc_params, hid_t driver_id, + H5VL_object_specific_t specific_type, hid_t dxpl_id, void **req, va_list arguments) +{ + H5VL_class_t *cls = NULL; + herr_t ret_value = SUCCEED; + + FUNC_ENTER_API(FAIL) + H5TRACE7("e", "*xxiVoi**xx", obj, loc_params, driver_id, specific_type, + dxpl_id, req, arguments); + + if(NULL == obj) + HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "invalid object") + if(NULL == (cls = (H5VL_class_t *)H5I_object_verify(driver_id, H5I_VOL))) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a VOL driver ID") + + /* Bypass the H5VLint layer */ + if(NULL == cls->object_cls.specific) + HGOTO_ERROR(H5E_VOL, H5E_UNSUPPORTED, FAIL, "vol driver has no `object specific' method") + if((ret_value = (cls->object_cls.specific) + (obj, loc_params, specific_type, dxpl_id, req, arguments)) < 0) + HGOTO_ERROR(H5E_VOL, H5E_CANTOPERATE, FAIL, "Unable to execute object specific callback") + +done: + FUNC_LEAVE_API(ret_value) +} /* end H5VLobject_specific() */ + + +/*------------------------------------------------------------------------- + * Function: H5VLobject_optional + * + * Purpose: Performs an optional driver-specific operation on an object + * + * Return: Success: Non-negative + * + * Failure: Negative + * + *------------------------------------------------------------------------- + */ +herr_t +H5VLobject_optional(void *obj, hid_t driver_id, hid_t dxpl_id, void **req, va_list arguments) +{ + H5VL_class_t *cls = NULL; + herr_t ret_value = SUCCEED; + + FUNC_ENTER_API(FAIL) + H5TRACE5("e", "*xii**xx", obj, driver_id, dxpl_id, req, arguments); + + if (NULL == obj) + HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "invalid object") + if(NULL == (cls = (H5VL_class_t *)H5I_object_verify(driver_id, H5I_VOL))) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a VOL driver ID") + + /* Have to bypass the H5VLint layer due to unknown val_list arguments */ + if(NULL == cls->object_cls.optional) + HGOTO_ERROR(H5E_VOL, H5E_UNSUPPORTED, FAIL, "vol driver has no `object optional' method") + if((ret_value = (cls->object_cls.optional)(obj, dxpl_id, req, arguments)) < 0) + HGOTO_ERROR(H5E_VOL, H5E_CANTOPERATE, FAIL, "Unable to execute object optional callback") + +done: + FUNC_LEAVE_API(ret_value) +} /* end H5VLobject_optional() */ + + +/*------------------------------------------------------------------------- + * Function: H5VLdatatype_commit + * + * Purpose: Commits a datatype to the file + * + * Return: Success: Pointer to the new datatype + * + * Failure: NULL + * + *------------------------------------------------------------------------- + */ +void * +H5VLdatatype_commit(void *obj, H5VL_loc_params_t loc_params, hid_t driver_id, const char *name, + hid_t type_id, hid_t lcpl_id, hid_t tcpl_id, hid_t tapl_id, hid_t dxpl_id, void **req) +{ + H5VL_class_t *cls = NULL; + void *ret_value = NULL; + + FUNC_ENTER_API(NULL) + H5TRACE10("*x", "*xxi*siiiii**x", obj, loc_params, driver_id, name, type_id, + lcpl_id, tcpl_id, tapl_id, dxpl_id, req); + + if (NULL == obj) + HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, NULL, "invalid object") + if(NULL == (cls = (H5VL_class_t *)H5I_object_verify(driver_id, H5I_VOL))) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, NULL, "not a VOL driver ID") + + if(NULL == (ret_value = H5VL_datatype_commit(obj, loc_params, cls, name, type_id, + lcpl_id, tcpl_id, tapl_id, dxpl_id, req))) + HGOTO_ERROR(H5E_VOL, H5E_CANTINIT, NULL, "unable to commit datatype") + +done: + FUNC_LEAVE_API(ret_value) +} /* end H5VLdatatype_commit() */ + + +/*------------------------------------------------------------------------- + * Function: H5VLdatatype_open + * + * Purpose: Opens a named datatype + * + * Return: Success: Pointer to the new datatype + * + * Failure: NULL + * + *------------------------------------------------------------------------- + */ +void * +H5VLdatatype_open(void *obj, H5VL_loc_params_t loc_params, hid_t driver_id, const char *name, + hid_t tapl_id, hid_t dxpl_id, void **req) +{ + H5VL_class_t *cls = NULL; + void *ret_value = NULL; + + FUNC_ENTER_API(NULL) + H5TRACE7("*x", "*xxi*sii**x", obj, loc_params, driver_id, name, tapl_id, + dxpl_id, req); + + if (NULL == obj) + HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, NULL, "invalid object") + if(NULL == (cls = (H5VL_class_t *)H5I_object_verify(driver_id, H5I_VOL))) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, NULL, "not a VOL driver ID") + + if(NULL == (ret_value = H5VL_datatype_open(obj, loc_params, cls, name, + tapl_id, dxpl_id, req))) + HGOTO_ERROR(H5E_VOL, H5E_CANTINIT, NULL, "unable to open datatype") + +done: + FUNC_LEAVE_API(ret_value) +} /* end H5VLdatatype_open() */ + + +/*------------------------------------------------------------------------- + * Function: H5VLdatatype_specific + * + * Purpose: Performs a driver-specific operation on a datatype + * + * Return: Success: Non-negative + * + * Failure: Negative + * + *------------------------------------------------------------------------- + */ +herr_t +H5VLdatatype_specific(void *obj, hid_t driver_id, H5VL_datatype_specific_t specific_type, + hid_t dxpl_id, void **req, va_list arguments) +{ + H5VL_class_t *cls = NULL; + herr_t ret_value = SUCCEED; + + FUNC_ENTER_API(FAIL) + H5TRACE6("e", "*xiVfi**xx", obj, driver_id, specific_type, dxpl_id, req, + arguments); + + if (NULL == obj) + HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "invalid object") + if(NULL == (cls = (H5VL_class_t *)H5I_object_verify(driver_id, H5I_VOL))) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a VOL driver ID") + + if(NULL == cls->datatype_cls.specific) + HGOTO_ERROR(H5E_VOL, H5E_UNSUPPORTED, FAIL, "vol driver has no `datatype specific' method") + if((ret_value = (cls->datatype_cls.specific) + (obj, specific_type, dxpl_id, req, arguments)) < 0) + HGOTO_ERROR(H5E_VOL, H5E_CANTOPERATE, FAIL, "Unable to execute datatype specific callback") + +done: + FUNC_LEAVE_API(ret_value) +} /* end H5VLdatatype_specific() */ + + +/*------------------------------------------------------------------------- + * Function: H5VLdatatype_optional + * + * Purpose: Performs an optional driver-specific operation on a datatype + * + * Return: Success: Non-negative + * + * Failure: Negative + * + *------------------------------------------------------------------------- + */ +herr_t +H5VLdatatype_optional(void *obj, hid_t driver_id, hid_t dxpl_id, void **req, va_list arguments) +{ + H5VL_class_t *cls = NULL; + herr_t ret_value = SUCCEED; + + FUNC_ENTER_API(FAIL) + H5TRACE5("e", "*xii**xx", obj, driver_id, dxpl_id, req, arguments); + + if (NULL == obj) + HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "invalid object") + if(NULL == (cls = (H5VL_class_t *)H5I_object_verify(driver_id, H5I_VOL))) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a VOL driver ID") + + if(NULL == cls->datatype_cls.optional) + HGOTO_ERROR(H5E_VOL, H5E_UNSUPPORTED, FAIL, "vol driver has no `datatype optional' method") + if((ret_value = (cls->datatype_cls.optional)(obj, dxpl_id, req, arguments)) < 0) + HGOTO_ERROR(H5E_VOL, H5E_CANTOPERATE, FAIL, "Unable to execute datatype optional callback") + +done: + FUNC_LEAVE_API(ret_value) +} /* end H5VLdatatype_optional() */ + + +/*------------------------------------------------------------------------- + * Function: H5VLdatatype_get + * + * Purpose: Gets information about the datatype + * + * Return: Success: Non-negative + * + * Failure: Negative + * + *------------------------------------------------------------------------- + */ +herr_t +H5VLdatatype_get(void *obj, hid_t driver_id, H5VL_datatype_get_t get_type, + hid_t dxpl_id, void **req, va_list arguments) +{ + H5VL_class_t *cls = NULL; + herr_t ret_value = SUCCEED; + + FUNC_ENTER_API(FAIL) + H5TRACE6("e", "*xiVei**xx", obj, driver_id, get_type, dxpl_id, req, arguments); + + if(NULL == obj) + HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "invalid object") + if(NULL == (cls = (H5VL_class_t *)H5I_object_verify(driver_id, H5I_VOL))) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a VOL driver ID") + + /* Bypass the H5VLint layer */ + if(NULL == cls->datatype_cls.get) + HGOTO_ERROR(H5E_VOL, H5E_UNSUPPORTED, FAIL, "vol driver has no `datatype get' method") + if((ret_value = (cls->datatype_cls.get)(obj, get_type, dxpl_id, req, arguments)) < 0) + HGOTO_ERROR(H5E_VOL, H5E_CANTGET, FAIL, "Unable to execute datatype get callback") + +done: + FUNC_LEAVE_API(ret_value) +} /* end H5VLdatatype_get() */ + + +/*------------------------------------------------------------------------- + * Function: H5VLdatatype_close + * + * Purpose: Closes a datatype + * + * Return: Success: Non-negative + * + * Failure: Negative + * + *------------------------------------------------------------------------- + */ +herr_t +H5VLdatatype_close(void *dt, hid_t driver_id, hid_t dxpl_id, void **req) +{ + H5VL_class_t *cls = NULL; + herr_t ret_value = SUCCEED; + + FUNC_ENTER_API(FAIL) + H5TRACE4("e", "*xii**x", dt, driver_id, dxpl_id, req); + + if (NULL == dt) + HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "invalid object") + if(NULL == (cls = (H5VL_class_t *)H5I_object_verify(driver_id, H5I_VOL))) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a VOL driver ID") + + if((ret_value = H5VL_datatype_close(dt, cls, dxpl_id, req)) < 0) + HGOTO_ERROR(H5E_VOL, H5E_CANTRELEASE, FAIL, "unable to close datatype") + +done: + FUNC_LEAVE_API(ret_value) +} /* end H5VLdatatype_close() */ + + +/*------------------------------------------------------------------------- + * Function: H5VLrequest_cancel + * + * Purpose: Cancels a request + * + * Return: Success: Non-negative + * + * Failure: Negative + * + *------------------------------------------------------------------------- + */ +herr_t +H5VLrequest_cancel(void **req, hid_t driver_id, H5ES_status_t *status) +{ + H5VL_class_t *cls = NULL; + herr_t ret_value = SUCCEED; + + FUNC_ENTER_API(FAIL) + H5TRACE3("e", "**xi*Es", req, driver_id, status); + + if (NULL == (cls = (H5VL_class_t *)H5I_object_verify(driver_id, H5I_VOL))) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a VOL driver ID") + + if ((ret_value = H5VL_request_cancel(req, cls, status)) < 0) + HGOTO_ERROR(H5E_VOL, H5E_CANTRELEASE, FAIL, "unable to cancel request") + +done: + FUNC_LEAVE_API(ret_value) +} /* end H5VLrequest_cancel() */ + + +/*------------------------------------------------------------------------- + * Function: H5VLrequest_test + * + * Purpose: Tests a request + * + * Return: Success: Non-negative + * + * Failure: Negative + * + *------------------------------------------------------------------------- + */ +herr_t +H5VLrequest_test(void **req, hid_t driver_id, H5ES_status_t *status) +{ + H5VL_class_t *cls = NULL; + herr_t ret_value = SUCCEED; + + FUNC_ENTER_API(FAIL) + H5TRACE3("e", "**xi*Es", req, driver_id, status); + + if (NULL == (cls = (H5VL_class_t *)H5I_object_verify(driver_id, H5I_VOL))) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a VOL driver ID") + + if ((ret_value = H5VL_request_test(req, cls, status)) < 0) + HGOTO_ERROR(H5E_VOL, H5E_CANTRELEASE, FAIL, "unable to test request") + +done: + FUNC_LEAVE_API(ret_value) +} /* end H5VLrequest_test() */ + + +/*------------------------------------------------------------------------- + * Function: H5VLrequest_wait + * + * Purpose: Waits on a request + * + * Return: Success: Non-negative + * + * Failure: Negative + * + *------------------------------------------------------------------------- + */ +herr_t +H5VLrequest_wait(void **req, hid_t driver_id, H5ES_status_t *status) +{ + H5VL_class_t *cls = NULL; + herr_t ret_value = SUCCEED; + + FUNC_ENTER_API(FAIL) + H5TRACE3("e", "**xi*Es", req, driver_id, status); + + if (NULL == (cls = (H5VL_class_t *)H5I_object_verify(driver_id, H5I_VOL))) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a VOL driver ID") + + if ((ret_value = H5VL_request_wait(req, cls, status)) < 0) + HGOTO_ERROR(H5E_VOL, H5E_CANTRELEASE, FAIL, "unable to wait on request") + + +done: + FUNC_LEAVE_API(ret_value) +} /* end H5VLrequest_wait() */ + + diff --git a/src/H5VLint.c b/src/H5VLint.c new file mode 100644 index 0000000..78ba6d9 --- /dev/null +++ b/src/H5VLint.c @@ -0,0 +1,2192 @@ +/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * + * Copyright by The HDF Group. * + * All rights reserved. * + * * + * This file is part of HDF5. The full HDF5 copyright notice, including * + * terms governing use, modification, and redistribution, is contained in * + * the COPYING file, which can be found at the root of the source code * + * distribution tree, or in https://support.hdfgroup.org/ftp/HDF5/releases. * + * If you do not have access to either file, you may request a copy from * + * help@hdfgroup.org. * + * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ + +/* + * Purpose: The Virtual Object Layer as described in documentation. + * The pupose is to provide an abstraction on how to access the + * underlying HDF5 container, whether in a local file with + * a specific file format, or remotely on other machines, etc... + */ + + +/****************/ +/* Module Setup */ +/****************/ + +#include "H5VLmodule.h" /* This source code file is part of the H5VL module */ + + +/***********/ +/* Headers */ +/***********/ + +#include "H5private.h" /* Generic Functions */ +#include "H5Eprivate.h" /* Error handling */ +#include "H5FLprivate.h" /* Free lists */ +#include "H5Iprivate.h" /* IDs */ +#include "H5MMprivate.h" /* Memory management */ +#include "H5Pprivate.h" /* Property lists */ +#include "H5Tprivate.h" /* Datatypes */ +#include "H5VLpkg.h" /* Virtual Object Layer */ + + +/****************/ +/* Local Macros */ +/****************/ + +/******************/ +/* Local Typedefs */ +/******************/ + +/********************/ +/* Package Typedefs */ +/********************/ + +/********************/ +/* Local Prototypes */ +/********************/ + +static herr_t H5VL_free_cls(H5VL_class_t *cls); + +/*********************/ +/* Package Variables */ +/*********************/ + +/* Package initialization variable */ +hbool_t H5_PKG_INIT_VAR = FALSE; + +/*****************************/ +/* Library Private Variables */ +/*****************************/ + +/*******************/ +/* Local Variables */ +/*******************/ + +/* VOL ID class */ +static const H5I_class_t H5I_VOL_CLS[1] = {{ + H5I_VOL, /* ID class value */ + 0, /* Class flags */ + 0, /* # of reserved IDs for class */ + (H5I_free_t)H5VL_free_cls /* Callback routine for closing objects of this class */ +}}; + +/* Declare a free list to manage the H5VL_t struct */ +H5FL_DEFINE(H5VL_t); + +/* Declare a free list to manage the H5VL_object_t struct */ +H5FL_DEFINE(H5VL_object_t); + + +/*------------------------------------------------------------------------- + * Function: H5VL_init + * + * Purpose: Initialize the interface from some other package + * + * Return: Success: Non-negative + * + * Failure: Negative + * + *------------------------------------------------------------------------- + */ +herr_t +H5VL_init(void) +{ + herr_t ret_value = SUCCEED; /* Return value */ + + FUNC_ENTER_NOAPI(FAIL) + + /* FUNC_ENTER() does all the work */ + +done: + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5VL_init() */ + + +/*------------------------------------------------------------------------- + * Function: H5VL__init_package + * + * Purpose: Initialize interface-specific information + * + * Return: Success: Non-negative + * + * Failure: Negative + * + *------------------------------------------------------------------------- + */ +herr_t +H5VL__init_package(void) +{ + herr_t ret_value = SUCCEED; /* Return value */ + + FUNC_ENTER_PACKAGE + + /* Initialize the atom group for the VL IDs */ + if (H5I_register_type(H5I_VOL_CLS) < 0) + HGOTO_ERROR(H5E_VOL, H5E_CANTINIT, FAIL, "unable to initialize H5VL interface"); + +done: + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5VL__init_package() */ + + +/*------------------------------------------------------------------------- + * Function: H5VL_term_package + * + * Purpose: Terminate various H5VL objects + * + * Return: Success: Positive if anything was done that might + * affect other interfaces; zero otherwise. + * Failure: Negative + * + *------------------------------------------------------------------------- + */ +int +H5VL_term_package(void) +{ + int n = 0; + + FUNC_ENTER_NOAPI_NOINIT_NOERR + + if (H5_PKG_INIT_VAR) { + if (H5I_nmembers(H5I_VOL) > 0) { + (void)H5I_clear_type(H5I_VOL, FALSE, FALSE); + n++; + } + else { + /* Destroy the VOL driver ID group */ + n += (H5I_dec_type_ref(H5I_VOL) > 0); + + /* Mark interface as closed */ + if (0 == n) + H5_PKG_INIT_VAR = FALSE; + } + } + + FUNC_LEAVE_NOAPI(n) +} /* end H5VL_term_package() */ + + +/*------------------------------------------------------------------------- + * Function: H5VL_free_cls + * + * Purpose: Frees a file VOL class struct and returns an indication of + * success. This function is used as the free callback for the + * virtual object layer object identifiers + * (c.f.: H5VL_init_interface). + * + * Return: SUCCEED/FAIL + * + *------------------------------------------------------------------------- + */ +static herr_t +H5VL_free_cls(H5VL_class_t *cls) +{ + herr_t ret_value = SUCCEED; + + FUNC_ENTER_NOAPI_NOINIT + + /* Sanity check */ + HDassert(cls); + + /* XXX: Need to retrieve the VOL termination property list for the + * terminate operation - JTH + */ + if (cls->terminate && cls->terminate(H5P_DEFAULT) < 0) + HGOTO_ERROR(H5E_VOL, H5E_CANTCLOSEOBJ, FAIL, "VOL driver did not terminate cleanly"); + + /* XXX (VOL MERGE): We'll leak memory if the name string was dynamically allocated. */ + H5MM_xfree(cls); + +done: + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5VL_free_cls() */ + + +/*------------------------------------------------------------------------- + * Function: H5VL_register_id + * + * Purpose: Wrapper to register an object ID with a VOL aux struct + * and increment ref count on VOL driver ID + * + * Return: Success: A valid HDF5 ID + * Failure: H5I_INVALID_HID + * + *------------------------------------------------------------------------- + */ +hid_t +H5VL_register_id(H5I_type_t type, void *object, H5VL_t *vol_driver, hbool_t app_ref) +{ + H5VL_object_t *new_obj = NULL; + hid_t ret_value = H5I_INVALID_HID; + + FUNC_ENTER_NOAPI(H5I_INVALID_HID) + + /* Check arguments */ + HDassert(object); + HDassert(vol_driver); + + /* setup VOL object */ + if (NULL == (new_obj = H5FL_CALLOC(H5VL_object_t))) + HGOTO_ERROR(H5E_VOL, H5E_CANTALLOC, H5I_INVALID_HID, "can't allocate top object structure"); + new_obj->driver = vol_driver; + new_obj->data = object; + + vol_driver->nrefs++; + + if (H5I_DATATYPE == type) { + + H5T_t *dt = NULL; + + if (NULL == (dt = H5T_construct_datatype(new_obj))) + HGOTO_ERROR(H5E_DATATYPE, H5E_CANTINIT, H5I_INVALID_HID, "can't construct datatype object"); + + if ((ret_value = H5I_register(type, dt, app_ref)) < 0) + HGOTO_ERROR(H5E_ATOM, H5E_CANTREGISTER, H5I_INVALID_HID, "unable to atomize handle"); + } + else { + if ((ret_value = H5I_register(type, new_obj, app_ref)) < 0) + HGOTO_ERROR(H5E_ATOM, H5E_CANTREGISTER, H5I_INVALID_HID, "unable to atomize handle"); + } + +done: + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5VL_register_id() */ + + +/*------------------------------------------------------------------------- + * Function: H5VL_free_object + * + * Purpose: Wrapper to unregister an object ID with a VOL aux struct + * and decrement ref count on VOL driver ID + * + * Return: SUCCEED/FAIL + * + *------------------------------------------------------------------------- + */ +herr_t +H5VL_free_object(H5VL_object_t *vol_obj) +{ + herr_t ret_value = SUCCEED; + + FUNC_ENTER_NOAPI(SUCCEED) + + /* Check arguments */ + HDassert(vol_obj); + + vol_obj->driver->nrefs --; + + if (0 == vol_obj->driver->nrefs) { + if (H5I_dec_ref(vol_obj->driver->id) < 0) + HGOTO_ERROR(H5E_VOL, H5E_CANTDEC, FAIL, "unable to decrement ref count on VOL driver"); + vol_obj->driver = H5FL_FREE(H5VL_t, vol_obj->driver); + } + + vol_obj = H5FL_FREE(H5VL_object_t, vol_obj); + +done: + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5VL_free_object() */ + + +/*------------------------------------------------------------------------- + * Function: H5VL_register + * + * Purpose: Registers a new VOL driver as a member of the virtual object + * layer class. + * + * Return: Success: A VOL driver ID which is good until the + * library is closed or the driver is unregistered. + * + * Failure: H5I_INVALID_HID + * + *------------------------------------------------------------------------- + */ +hid_t +H5VL_register(const void *_cls, size_t size, hbool_t app_ref) +{ + const H5VL_class_t *cls = (const H5VL_class_t *)_cls; + H5VL_class_t *saved = NULL; + hid_t ret_value = H5I_INVALID_HID; + + FUNC_ENTER_NOAPI(H5I_INVALID_HID) + + /* Check arguments */ + HDassert(cls); + + /* Copy the class structure so the caller can reuse or free it */ + if (NULL == (saved = (H5VL_class_t *)H5MM_calloc(size))) + HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, H5I_INVALID_HID, "memory allocation failed for VOL driver class struct"); + HDmemcpy(saved, cls, size); + + /* Create the new class ID */ + if ((ret_value = H5I_register(H5I_VOL, saved, app_ref)) < 0) + HGOTO_ERROR(H5E_ATOM, H5E_CANTREGISTER, H5I_INVALID_HID, "unable to register VOL driver ID"); + +done: + if (ret_value < 0) + if (saved) + H5MM_xfree(saved); + + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5VL_register() */ + + +/*------------------------------------------------------------------------- + * Function: H5VL_object_register + * + * Purpose: Utility function to create a user ID for an object created + * or opened through the VOL + * + * Return: Success: A valid HDF5 ID + * Failure: H5I_INVALID_HID + * + *------------------------------------------------------------------------- + */ +hid_t +H5VL_object_register(void *obj, H5I_type_t obj_type, hid_t driver_id, hbool_t app_ref) +{ + H5VL_class_t *cls = NULL; + H5VL_t *driver = NULL; /* VOL driver struct */ + hid_t ret_value = H5I_INVALID_HID; + + FUNC_ENTER_NOAPI(FAIL) + + if (NULL == (cls = (H5VL_class_t *)H5I_object_verify(driver_id, H5I_VOL))) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, H5I_INVALID_HID, "not a VOL driver ID"); + + /* Setup VOL info struct */ + if (NULL == (driver = H5FL_CALLOC(H5VL_t))) + HGOTO_ERROR(H5E_FILE, H5E_NOSPACE, H5I_INVALID_HID, "can't allocate VOL info struct"); + driver->cls = cls; + driver->id = driver_id; + if (H5I_inc_ref(driver->id, FALSE) < 0) + HGOTO_ERROR(H5E_ATOM, H5E_CANTINC, H5I_INVALID_HID, "unable to increment ref count on VOL driver"); + + /* Get an ID for the VOL object */ + if ((ret_value = H5VL_register_id(obj_type, obj, driver, app_ref)) < 0) + HGOTO_ERROR(H5E_ATOM, H5E_CANTREGISTER, H5I_INVALID_HID, "unable to register object handle"); + +done: + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5VL_object_register() */ + + +/*------------------------------------------------------------------------- + * Function: H5VL_get_driver_name + * + * Purpose: Private version of H5VLget_driver_name + * + * Return: Success: The length of the driver name + * Failure: Negative + * + *------------------------------------------------------------------------- + */ +ssize_t +H5VL_get_driver_name(hid_t id, char *name /*out*/, size_t size) +{ + H5VL_object_t *vol_obj = NULL; + const H5VL_class_t *cls = NULL; + size_t len; + ssize_t ret_value = -1; + + FUNC_ENTER_NOAPI(FAIL) + + /* get the object pointer */ + if (NULL == (vol_obj = H5VL_get_object(id))) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "invalid file identifier"); + + cls = vol_obj->driver->cls; + + len = HDstrlen(cls->name); + if (name) { + HDstrncpy(name, cls->name, MIN(len + 1,size)); + if (len >= size) + name[size-1]='\0'; + } + + /* Set the return value for the API call */ + ret_value = (ssize_t)len; + +done: + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5VL_get_driver_name() */ + + +/*------------------------------------------------------------------------- + * Function: H5VL_get_object + * + * Purpose: Utility function to return the object pointer associated with + * a hid_t. This routine is the same as H5I_object for all types + * except for named datatypes, where the vol_obj is returned that + * is attached to the H5T_t struct. + * + * Return: Success: object pointer + * Failure: NULL + * + *------------------------------------------------------------------------- + */ +H5VL_object_t * +H5VL_get_object(hid_t id) +{ + void *obj = NULL; + H5I_type_t obj_type = H5I_get_type(id); + H5VL_object_t *ret_value = NULL; + + FUNC_ENTER_NOAPI(NULL) + + if (H5I_FILE == obj_type || H5I_GROUP == obj_type || H5I_ATTR == obj_type || + H5I_DATASET == obj_type || H5I_DATATYPE == obj_type) { + /* get the object */ + if (NULL == (obj = H5I_object(id))) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, NULL, "invalid identifier"); + + /* if this is a datatype, get the VOL object attached to the H5T_t struct */ + if (H5I_DATATYPE == obj_type) { + if (NULL == (obj = H5T_get_named_type((H5T_t *)obj))) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, NULL, "not a named datatype"); + } + } + else + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, NULL, "invalid identifier type to function"); + + + ret_value = (H5VL_object_t *)obj; +done: + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5VL_get_object() */ + + +/*------------------------------------------------------------------------- + * Function: H5VL_object + * + * Purpose: Utility function to return the VOL object pointer associated with + * a hid_t. + * + * Return: Success: object pointer + * Failure: NULL + * + *------------------------------------------------------------------------- + */ +void * +H5VL_object(hid_t id) +{ + H5VL_object_t *vol_obj = NULL; + void *ret_value = NULL; + + FUNC_ENTER_NOAPI(NULL) + + /* Get the symbol table entry */ + switch (H5I_get_type(id)) { + case H5I_GROUP: + case H5I_DATASET: + case H5I_FILE: + case H5I_ATTR: + /* get the object */ + if (NULL == (vol_obj = (H5VL_object_t *)H5I_object(id))) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, NULL, "invalid identifier"); + + ret_value = vol_obj->data; + break; + case H5I_DATATYPE: + { + H5T_t *dt = NULL; + + /* get the object */ + if (NULL == (dt = (H5T_t *)H5I_object(id))) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, NULL, "invalid identifier"); + + /* Get the actual datatype object that should be the vol_obj */ + if (NULL == (vol_obj = H5T_get_named_type(dt))) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, NULL, "not a named datatype"); + + ret_value = vol_obj->data; + break; + } + case H5I_UNINIT: + case H5I_BADID: + case H5I_DATASPACE: + case H5I_REFERENCE: + case H5I_VFL: + case H5I_VOL: + case H5I_GENPROP_CLS: + case H5I_GENPROP_LST: + case H5I_ERROR_CLASS: + case H5I_ERROR_MSG: + case H5I_ERROR_STACK: + case H5I_NTYPES: + default: + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, NULL, "unknown data object type"); + } +done: + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5VL_object() */ + + +/*------------------------------------------------------------------------- + * Function: H5VL_object_verify + * + * Purpose: Utility function to return the VOL object pointer associated + * with an identifier. + * + * Return: Success: object pointer + * Failure: NULL + * + *------------------------------------------------------------------------- + */ +void * +H5VL_object_verify(hid_t id, H5I_type_t obj_type) +{ + H5VL_object_t *vol_obj = NULL; + void *ret_value = NULL; + + FUNC_ENTER_NOAPI(NULL) + + /* Get the symbol table entry */ + switch (obj_type) { + case H5I_GROUP: + case H5I_DATASET: + case H5I_FILE: + case H5I_ATTR: + /* get the object */ + if (NULL == (vol_obj = (H5VL_object_t *)H5I_object_verify(id, obj_type))) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, NULL, "invalid identifier"); + + ret_value = vol_obj->data; + break; + case H5I_DATATYPE: + { + H5T_t *dt = NULL; + + /* get the object */ + if (NULL == (dt = (H5T_t *)H5I_object_verify(id, obj_type))) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, NULL, "invalid identifier"); + + /* Get the actual datatype object that should be the vol_obj */ + if (NULL == (vol_obj = H5T_get_named_type(dt))) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, NULL, "not a named datatype"); + + ret_value = vol_obj->data; + break; + } + case H5I_UNINIT: + case H5I_BADID: + case H5I_DATASPACE: + case H5I_REFERENCE: + case H5I_VFL: + case H5I_VOL: + case H5I_GENPROP_CLS: + case H5I_GENPROP_LST: + case H5I_ERROR_CLASS: + case H5I_ERROR_MSG: + case H5I_ERROR_STACK: + case H5I_NTYPES: + default: + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, NULL, "unknown data object type") + } +done: + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5VL_object_verify() */ + + +/* XXX (VOL MERGE): This could be a macro like in H5F */ +void * +H5VL_driver_object(H5VL_object_t *vol_obj) +{ + FUNC_ENTER_NOAPI_NOINIT_NOERR + + FUNC_LEAVE_NOAPI(vol_obj->data) +} /* end H5VL_driver_object() */ + + +/*------------------------------------------------------------------------- + * Function: H5VL_attr_create + * + * Purpose: Creates an attribute through the VOL + * + * Return: Success: pointer to the new attribute + * + * Failure: NULL + * + *------------------------------------------------------------------------- + */ +void * +H5VL_attr_create(void *obj, H5VL_loc_params_t loc_params, const H5VL_class_t *cls, const char *name, + hid_t acpl_id, hid_t aapl_id, hid_t dxpl_id, void **req) +{ + void *ret_value; /* Return value */ + + FUNC_ENTER_NOAPI(NULL) + + /* check if the corresponding VOL create callback exists */ + if (NULL == cls->attr_cls.create) + HGOTO_ERROR(H5E_VOL, H5E_UNSUPPORTED, NULL, "VOL driver has no 'attr create' method") + + /* call the corresponding VOL create callback */ + if (NULL == (ret_value = (cls->attr_cls.create) + (obj, loc_params, name, acpl_id, aapl_id, dxpl_id, req))) + HGOTO_ERROR(H5E_VOL, H5E_CANTINIT, NULL, "create failed") + +done: + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5VL_attr_create() */ + + +/*------------------------------------------------------------------------- + * Function: H5VL_attr_open + * + * Purpose: Opens an attribute through the VOL + * + * Return: Success: pointer to the new attr. + * + * Failure: NULL + * + *------------------------------------------------------------------------- + */ +void * +H5VL_attr_open(void *obj, H5VL_loc_params_t loc_params, const H5VL_class_t *cls, const char *name, + hid_t aapl_id, hid_t dxpl_id, void **req) +{ + void *ret_value; /* Return value */ + + FUNC_ENTER_NOAPI(NULL) + + /* check if the type specific corresponding VOL open callback exists */ + if(NULL == cls->attr_cls.open) + HGOTO_ERROR(H5E_VOL, H5E_UNSUPPORTED, NULL, "VOL driver has no 'attr open' method") + + /* call the corresponding VOL open callback */ + if(NULL == (ret_value = (cls->attr_cls.open) + (obj, loc_params, name, aapl_id, dxpl_id, req))) + HGOTO_ERROR(H5E_VOL, H5E_CANTOPENOBJ, NULL, "attribute open failed") + +done: + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5VL_attr_open() */ + + +/*------------------------------------------------------------------------- + * Function: H5VL_attr_read + * + * Purpose: Reads data from attr through the VOL + * + * Return: Success: Non Negative + * + * Failure: Negative + * + *------------------------------------------------------------------------- + */ +herr_t H5VL_attr_read(void *attr, const H5VL_class_t *cls, hid_t mem_type_id, void *buf, + hid_t dxpl_id, void **req) +{ + herr_t ret_value = SUCCEED; + + FUNC_ENTER_NOAPI(FAIL) + + if(NULL == cls->attr_cls.read) + HGOTO_ERROR(H5E_VOL, H5E_UNSUPPORTED, FAIL, "VOL driver has no 'attr read' method") + if((ret_value = (cls->attr_cls.read)(attr, mem_type_id, buf, dxpl_id, req)) < 0) + HGOTO_ERROR(H5E_VOL, H5E_CANTRELEASE, FAIL, "read failed") + +done: + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5VL_attr_read() */ + + +/*------------------------------------------------------------------------- + * Function: H5VL_attr_write + * + * Purpose: Writes data to attr through the VOL + * + * Return: Success: Non Negative + * + * Failure: Negative + * + *------------------------------------------------------------------------- + */ +herr_t H5VL_attr_write(void *attr, const H5VL_class_t *cls, hid_t mem_type_id, const void *buf, + hid_t dxpl_id, void **req) +{ + herr_t ret_value = SUCCEED; + + FUNC_ENTER_NOAPI(FAIL) + + if(NULL == cls->attr_cls.write) + HGOTO_ERROR(H5E_VOL, H5E_UNSUPPORTED, FAIL, "VOL driver has no 'attr write' method") + if((ret_value = (cls->attr_cls.write)(attr, mem_type_id, buf, dxpl_id, req)) < 0) + HGOTO_ERROR(H5E_VOL, H5E_CANTRELEASE, FAIL, "write failed") + +done: + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5VL_attr_write() */ + + +/*------------------------------------------------------------------------- + * Function: H5VL_attr_get + * + * Purpose: Get specific information about the attribute through the VOL + * + * Return: Success: non negative + * + * Failure: negative + * + *------------------------------------------------------------------------- + */ +herr_t +H5VL_attr_get(void *obj, const H5VL_class_t *cls, H5VL_attr_get_t get_type, + hid_t dxpl_id, void **req, ...) +{ + va_list arguments; /* argument list passed from the API call */ + herr_t ret_value = SUCCEED; + + FUNC_ENTER_NOAPI(FAIL) + + if(NULL == cls->attr_cls.get) + HGOTO_ERROR(H5E_VOL, H5E_UNSUPPORTED, FAIL, "VOL driver has no 'attr get' method") + + va_start (arguments, req); + if((ret_value = (cls->attr_cls.get)(obj, get_type, dxpl_id, req, arguments)) < 0) + HGOTO_ERROR(H5E_VOL, H5E_CANTGET, FAIL, "get failed") + va_end (arguments); + +done: + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5VL_attr_get() */ + + +/*------------------------------------------------------------------------- + * Function: H5VL_attr_specific + * + * Purpose: specific operation on attributes through the VOL + * + * Return: Success: non negative + * + * Failure: negative + * + *------------------------------------------------------------------------- + */ +herr_t +H5VL_attr_specific(void *obj, H5VL_loc_params_t loc_params, const H5VL_class_t *cls, + H5VL_attr_specific_t specific_type, hid_t dxpl_id, void **req, ...) +{ + va_list arguments; /* argument list passed from the API call */ + herr_t ret_value = SUCCEED; + + FUNC_ENTER_NOAPI(FAIL) + + if(NULL == cls->attr_cls.specific) + HGOTO_ERROR(H5E_VOL, H5E_UNSUPPORTED, FAIL, "VOL driver has no 'attr specific' method") + + va_start (arguments, req); + if((ret_value = (cls->attr_cls.specific)(obj, loc_params, specific_type, dxpl_id, req, arguments)) < 0) + HGOTO_ERROR(H5E_VOL, H5E_CANTOPERATE, FAIL, "Unable to execute attribute specific callback") + va_end (arguments); + +done: + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5VL_attr_specific() */ + + +/*------------------------------------------------------------------------- + * Function: H5VL_attr_optional + * + * Purpose: optional operation specific to drivers. + * + * Return: Success: non negative + * + * Failure: negative + * + *------------------------------------------------------------------------- + */ +herr_t +H5VL_attr_optional(void *obj, const H5VL_class_t *cls, hid_t dxpl_id, void **req, ...) +{ + va_list arguments; /* argument list passed from the API call */ + herr_t ret_value = SUCCEED; + + FUNC_ENTER_NOAPI(FAIL) + + if(NULL == cls->attr_cls.optional) + HGOTO_ERROR(H5E_VOL, H5E_UNSUPPORTED, FAIL, "VOL driver has no 'attr optional' method") + + va_start (arguments, req); + if((ret_value = (cls->attr_cls.optional)(obj, dxpl_id, req, arguments)) < 0) + HGOTO_ERROR(H5E_VOL, H5E_CANTOPERATE, FAIL, "Unable to execute attribute optional callback") + va_end (arguments); + +done: + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5VL_attr_optional() */ + + +/*------------------------------------------------------------------------- + * Function: H5VL_attr_close + * + * Purpose: Closes an attribute through the VOL + * + * Return: SUCCEED/FAIL + * + *------------------------------------------------------------------------- + */ +herr_t +H5VL_attr_close(void *attr, const H5VL_class_t *cls, hid_t dxpl_id, void **req) +{ + herr_t ret_value = SUCCEED; + + HDassert(attr); + HDassert(cls); + + FUNC_ENTER_NOAPI(FAIL) + + /* Check if the corresponding VOL callback exists */ + if (NULL == cls->attr_cls.close) + HGOTO_ERROR(H5E_VOL, H5E_UNSUPPORTED, FAIL, "VOL driver has no 'attr close' method"); + + /* Call the corresponding VOL callback */ + if ((ret_value = (cls->attr_cls.close)(attr, dxpl_id, req)) < 0) + HGOTO_ERROR(H5E_VOL, H5E_CANTRELEASE, FAIL, "close failed"); + +done: + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5VL_attr_close() */ + + +/*------------------------------------------------------------------------- + * Function: H5VL_dataset_create + * + * Purpose: Creates a dataset through the VOL + * + * Return: Success: pointer to dataset + * + * Failure: NULL + * + *------------------------------------------------------------------------- + */ +void * +H5VL_dataset_create(void *obj, H5VL_loc_params_t loc_params, const H5VL_class_t *cls, const char *name, + hid_t dcpl_id, hid_t dapl_id, hid_t dxpl_id, void **req) +{ + void *ret_value; /* Return value */ + + FUNC_ENTER_NOAPI(NULL) + + /* check if the corresponding VOL create callback exists */ + if(NULL == cls->dataset_cls.create) + HGOTO_ERROR(H5E_VOL, H5E_UNSUPPORTED, NULL, "VOL driver has no 'dataset create' method") + + /* call the corresponding VOL create callback */ + if(NULL == (ret_value = (cls->dataset_cls.create) + (obj, loc_params, name, dcpl_id, dapl_id, dxpl_id, req))) + HGOTO_ERROR(H5E_VOL, H5E_CANTINIT, NULL, "create failed") + +done: + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5VL_dataset_create() */ + + +/*------------------------------------------------------------------------- + * Function: H5VL_dataset_open + * + * Purpose: Opens a dataset through the VOL + * + * Return: Success: pointer to dataset + * + * Failure: NULL + * + *------------------------------------------------------------------------- + */ +void * +H5VL_dataset_open(void *obj, H5VL_loc_params_t loc_params, const H5VL_class_t *cls, const char *name, + hid_t dapl_id, hid_t dxpl_id, void **req) +{ + void *ret_value; /* Return value */ + + FUNC_ENTER_NOAPI(NULL) + + /* check if the type specific corresponding VOL open callback exists */ + if(NULL == cls->dataset_cls.open) + HGOTO_ERROR(H5E_VOL, H5E_UNSUPPORTED, NULL, "VOL driver has no 'dset open' method") + + /* call the corresponding VOL open callback */ + if(NULL == (ret_value = (cls->dataset_cls.open) + (obj, loc_params, name, dapl_id, dxpl_id, req))) + HGOTO_ERROR(H5E_VOL, H5E_CANTOPENOBJ, NULL, "dataset open failed") + +done: + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5VL_dataset_open() */ + + +/*------------------------------------------------------------------------- + * Function: H5VL_dataset_read + * + * Purpose: Reads data from dataset through the VOL +* + * Return: Success: Non Negative + * + * Failure: Negative + * + *------------------------------------------------------------------------- + */ +herr_t +H5VL_dataset_read(void *dset, const H5VL_class_t *cls, hid_t mem_type_id, hid_t mem_space_id, + hid_t file_space_id, hid_t plist_id, void *buf, void **req) +{ + herr_t ret_value = SUCCEED; + + FUNC_ENTER_NOAPI(FAIL) + + if(NULL == cls->dataset_cls.read) + HGOTO_ERROR(H5E_VOL, H5E_UNSUPPORTED, FAIL, "VOL driver has no 'dataset read' method") + if((ret_value = (cls->dataset_cls.read) + (dset, mem_type_id, mem_space_id, file_space_id, plist_id, buf, req)) < 0) + HGOTO_ERROR(H5E_VOL, H5E_READERROR, FAIL, "read failed") + +done: + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5VL_dataset_read() */ + + +/*------------------------------------------------------------------------- + * Function: H5VL_dataset_write + * + * Purpose: Writes data from dataset through the VOL + * + * Return: Success: Non Negative + * + * Failure: Negative + * + *------------------------------------------------------------------------- + */ +herr_t +H5VL_dataset_write(void *dset, const H5VL_class_t *cls, hid_t mem_type_id, hid_t mem_space_id, + hid_t file_space_id, hid_t plist_id, const void *buf, void **req) +{ + herr_t ret_value = SUCCEED; + + FUNC_ENTER_NOAPI(FAIL) + + if(NULL == cls->dataset_cls.write) + HGOTO_ERROR(H5E_VOL, H5E_UNSUPPORTED, FAIL, "VOL driver has no 'dataset write' method") + if((ret_value = (cls->dataset_cls.write) + (dset, mem_type_id, mem_space_id, file_space_id, plist_id, buf, req)) < 0) + HGOTO_ERROR(H5E_VOL, H5E_WRITEERROR, FAIL, "write failed") + +done: + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5VL_dataset_write() */ + + +/*------------------------------------------------------------------------- + * Function: H5VL_dataset_get + * + * Purpose: Get specific information about the dataset through the VOL + * + * Return: Success: non negative + * + * Failure: negative + * + *------------------------------------------------------------------------- + */ +herr_t +H5VL_dataset_get(void *dset, const H5VL_class_t *cls, H5VL_dataset_get_t get_type, + hid_t dxpl_id, void **req, ...) +{ + va_list arguments; /* argument list passed from the API call */ + herr_t ret_value = SUCCEED; + + FUNC_ENTER_NOAPI(FAIL) + + if(NULL == cls->dataset_cls.get) + HGOTO_ERROR(H5E_VOL, H5E_UNSUPPORTED, FAIL, "VOL driver has no 'dataset get' method") + + va_start (arguments, req); + if((ret_value = (cls->dataset_cls.get)(dset, get_type, dxpl_id, req, 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_dataset_specific + * + * Purpose: specific operation on datasets through the VOL + * + * Return: Success: non negative + * + * Failure: negative + * + *------------------------------------------------------------------------- + */ +herr_t +H5VL_dataset_specific(void *obj, const H5VL_class_t *cls, H5VL_dataset_specific_t specific_type, + hid_t dxpl_id, void **req, ...) +{ + va_list arguments; /* argument list passed from the API call */ + herr_t ret_value = SUCCEED; + + FUNC_ENTER_NOAPI(FAIL) + + if(NULL == cls->dataset_cls.specific) + HGOTO_ERROR(H5E_VOL, H5E_UNSUPPORTED, FAIL, "VOL driver has no 'dataset specific' method") + + va_start (arguments, req); + if((ret_value = (cls->dataset_cls.specific) + (obj, specific_type, dxpl_id, req, arguments)) < 0) + HGOTO_ERROR(H5E_VOL, H5E_CANTOPERATE, FAIL, "Unable to execute dataset specific callback") + va_end (arguments); + +done: + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5VL_dataset_specific() */ + + +/*------------------------------------------------------------------------- + * Function: H5VL_dataset_optional + * + * Purpose: optional operation specific to drivers. + * + * Return: Success: non negative + * + * Failure: negative + * + *------------------------------------------------------------------------- + */ +herr_t +H5VL_dataset_optional(void *obj, const H5VL_class_t *cls, hid_t dxpl_id, void **req, ...) +{ + va_list arguments; /* argument list passed from the API call */ + herr_t ret_value = SUCCEED; + + FUNC_ENTER_NOAPI(FAIL) + + if(NULL == cls->dataset_cls.optional) + HGOTO_ERROR(H5E_VOL, H5E_UNSUPPORTED, FAIL, "VOL driver has no 'dataset optional' method") + + va_start (arguments, req); + if((ret_value = (cls->dataset_cls.optional)(obj, dxpl_id, req, arguments)) < 0) + HGOTO_ERROR(H5E_VOL, H5E_CANTOPERATE, FAIL, "Unable to execute dataset optional callback") + va_end (arguments); + +done: + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5VL_dataset_optional() */ + + +/*------------------------------------------------------------------------- + * Function: H5VL_dataset_close + * + * Purpose: Closes a dataset through the VOL + * + * Return: SUCCEED/FAIL + * + *------------------------------------------------------------------------- + */ +herr_t +H5VL_dataset_close(void *dset, const H5VL_class_t *cls, hid_t dxpl_id, void **req) +{ + herr_t ret_value = SUCCEED; + + FUNC_ENTER_NOAPI(FAIL) + + HDassert(dset); + HDassert(cls); + + /* Check if the corresponding VOL callback exists */ + if (NULL == cls->dataset_cls.close) + HGOTO_ERROR(H5E_VOL, H5E_UNSUPPORTED, FAIL, "VOL driver has no 'dset close' method"); + + /* Call the corresponding VOL callback */ + if ((ret_value = (cls->dataset_cls.close)(dset, dxpl_id, req)) < 0) + HGOTO_ERROR(H5E_VOL, H5E_CANTRELEASE, FAIL, "close failed"); + +done: + + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5VL_dataset_close() */ + + +/*------------------------------------------------------------------------- + * Function: H5VL_file_create + * + * Purpose: Creates a file through the VOL + * + * Return: Success: pointer to file. + * + * Failure: NULL + * + *------------------------------------------------------------------------- + */ +void * +H5VL_file_create(const H5VL_class_t *cls, const char *name, unsigned flags, hid_t fcpl_id, + hid_t fapl_id, hid_t dxpl_id, void **req) +{ + void *ret_value = NULL; /* Return value */ + + FUNC_ENTER_NOAPI(NULL) + + /* check if the corresponding VOL create callback exists */ + if(NULL == cls->file_cls.create) + HGOTO_ERROR(H5E_VOL, H5E_UNSUPPORTED, NULL, "VOL driver has no 'file create' method") + /* call the corresponding VOL create callback */ + if(NULL == (ret_value = (cls->file_cls.create)(name, flags, fcpl_id, fapl_id, dxpl_id, req))) + HGOTO_ERROR(H5E_VOL, H5E_CANTINIT, NULL, "create failed") + +done: + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5VL_file_create() */ + + +/*------------------------------------------------------------------------- + * Function: H5VL_file_open + * + * Purpose: Opens a file through the VOL. + * + * Return: Success: pointer to file. + * + * Failure: NULL + * + *------------------------------------------------------------------------- + */ +void * +H5VL_file_open(const H5VL_class_t *cls, const char *name, unsigned flags, hid_t fapl_id, + hid_t dxpl_id, void **req) +{ + void *ret_value = NULL; /* Return value */ + + FUNC_ENTER_NOAPI(NULL) + + /* check if the corresponding VOL create callback exists */ + if(NULL == cls->file_cls.open) + HGOTO_ERROR(H5E_VOL, H5E_UNSUPPORTED, NULL, "VOL driver has no 'file open' method") + /* call the corresponding VOL create callback */ + if(NULL == (ret_value = (cls->file_cls.open)(name, flags, fapl_id, dxpl_id, req))) + HGOTO_ERROR(H5E_VOL, H5E_CANTINIT, NULL, "open failed") + +done: + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5VL_file_open() */ + + +/*------------------------------------------------------------------------- + * Function: H5VL_file_get + * + * Purpose: Get specific information about the file through the VOL + * + * Return: Success: non negative + * + * Failure: negative + * + *------------------------------------------------------------------------- + */ +herr_t +H5VL_file_get(void *file, const H5VL_class_t *cls, H5VL_file_get_t get_type, + hid_t dxpl_id, void **req, ...) +{ + va_list arguments; /* argument list passed from the API call */ + herr_t ret_value = SUCCEED; + + FUNC_ENTER_NOAPI(FAIL) + + if(NULL == cls->file_cls.get) + HGOTO_ERROR(H5E_VOL, H5E_UNSUPPORTED, FAIL, "VOL driver has no 'file get' method") + + va_start(arguments, req); + if((ret_value = (cls->file_cls.get)(file, get_type, dxpl_id, req, arguments)) < 0) + HGOTO_ERROR(H5E_VOL, H5E_CANTGET, FAIL, "get failed") + va_end(arguments); + +done: + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5VL_file_get() */ + + +/*------------------------------------------------------------------------- + * Function: H5VL_file_specific + * + * Purpose: perform File specific operations through the VOL + * + * Return: Success: non negative + * Failure: negative + * + *------------------------------------------------------------------------- + */ +herr_t +H5VL_file_specific(void *file, const H5VL_class_t *cls, H5VL_file_specific_t specific_type, + hid_t dxpl_id, void **req, ...) +{ + va_list arguments; /* argument list passed from the API call */ + herr_t ret_value = SUCCEED; + + FUNC_ENTER_NOAPI(FAIL) + + if(specific_type == H5VL_FILE_IS_ACCESSIBLE) { + H5P_genplist_t *plist; /* Property list pointer */ + H5VL_driver_prop_t driver_prop; /* Property for VOL driver ID & info */ + va_list tmp_args; /* argument list passed from the API call */ + hid_t fapl_id; + + va_start (tmp_args, req); + fapl_id = va_arg (tmp_args, hid_t); + va_end (tmp_args); + + /* get the VOL info from the fapl */ + if(NULL == (plist = (H5P_genplist_t *)H5I_object(fapl_id))) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a file access property list") + + if(H5P_peek(plist, H5F_ACS_VOL_DRV_NAME, &driver_prop) < 0) + HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, FAIL, "can't get VOL driver info") + + if(NULL == (cls = (H5VL_class_t *)H5I_object_verify(driver_prop.driver_id, H5I_VOL))) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a VOL driver ID") + + va_start (arguments, req); + if((ret_value = (cls->file_cls.specific) + (file, specific_type, dxpl_id, req, arguments)) < 0) + HGOTO_ERROR(H5E_VOL, H5E_CANTGET, FAIL, "specific failed") + va_end (arguments); + } + else { + if(NULL == cls->file_cls.specific) + HGOTO_ERROR(H5E_VOL, H5E_UNSUPPORTED, FAIL, "VOL driver has no 'file specific' method") + + va_start (arguments, req); + if((ret_value = (cls->file_cls.specific) + (file, specific_type, dxpl_id, req, arguments)) < 0) + HGOTO_ERROR(H5E_VOL, H5E_CANTGET, FAIL, "specific failed") + va_end (arguments); + } + +done: + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5VL_file_specific() */ + + +/*------------------------------------------------------------------------- + * Function: H5VL_file_optional + * + * Purpose: perform a driver specific operation + * + * Return: Success: non negative + * Failure: negative + * + *------------------------------------------------------------------------- + */ +herr_t +H5VL_file_optional(void *file, const H5VL_class_t *cls, hid_t dxpl_id, void **req, ...) +{ + va_list arguments; /* argument list passed from the API call */ + herr_t ret_value = SUCCEED; + + FUNC_ENTER_NOAPI(FAIL) + + if(NULL == cls->file_cls.optional) + HGOTO_ERROR(H5E_VOL, H5E_UNSUPPORTED, FAIL, "VOL driver has no 'file optional' method") + + va_start (arguments, req); + if((ret_value = (cls->file_cls.optional)(file, dxpl_id, req, arguments)) < 0) + HGOTO_ERROR(H5E_VOL, H5E_CANTGET, FAIL, "optional failed") + va_end (arguments); + +done: + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5VL_file_optional() */ + + +/*------------------------------------------------------------------------- + * Function: H5VL_file_close + * + * Purpose: Closes a file through the VOL + * + * Return: SUCCEED/FAIL + * + *------------------------------------------------------------------------- + */ +herr_t +H5VL_file_close(void *file, const H5VL_class_t *cls, hid_t dxpl_id, void **req) +{ + herr_t ret_value = SUCCEED; + + FUNC_ENTER_NOAPI(FAIL) + + HDassert(file); + HDassert(cls); + + /* Check if the corresponding VOL callback exists */ + if (NULL == cls->file_cls.close) + HGOTO_ERROR(H5E_VOL, H5E_UNSUPPORTED, FAIL, "VOL driver has no 'file close' method"); + + /* Call the corresponding VOL callback */ + if ((ret_value = (cls->file_cls.close)(file, dxpl_id, req)) < 0) + HGOTO_ERROR(H5E_VOL, H5E_CANTCLOSEFILE, FAIL, "close failed"); + +done: + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5VL_file_close() */ + + +/*------------------------------------------------------------------------- + * Function: H5VL_group_create + * + * Purpose: Creates a group through the VOL + * + * Return: Success: pointer to new group. + * + * Failure: NULL + * + *------------------------------------------------------------------------- + */ +void * +H5VL_group_create(void *obj, H5VL_loc_params_t loc_params, const H5VL_class_t *cls, const char *name, + hid_t gcpl_id, hid_t gapl_id, hid_t dxpl_id, void **req) +{ + void *ret_value = NULL; /* Return value */ + + FUNC_ENTER_NOAPI(NULL) + + /* check if the corresponding VOL create callback exists */ + if(NULL == cls->group_cls.create) + HGOTO_ERROR(H5E_VOL, H5E_UNSUPPORTED, NULL, "VOL driver has no 'group create' method") + + /* call the corresponding VOL create callback */ + if(NULL == (ret_value = (cls->group_cls.create) + (obj, loc_params, name, gcpl_id, gapl_id, dxpl_id, req))) + HGOTO_ERROR(H5E_VOL, H5E_CANTINIT, NULL, "create failed") + +done: + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5VL_group_create() */ + + +/*------------------------------------------------------------------------- + * Function: H5VL_group_open + * + * Purpose: Opens a group through the VOL + * + * Return: Success: pointer to new group. + * + * Failure: NULL + * + *------------------------------------------------------------------------- + */ +void * +H5VL_group_open(void *obj, H5VL_loc_params_t loc_params, const H5VL_class_t *cls, const char *name, + hid_t gapl_id, hid_t dxpl_id, void **req) +{ + void *ret_value; /* Return value */ + + FUNC_ENTER_NOAPI(NULL) + + if(NULL == cls->group_cls.open) + HGOTO_ERROR(H5E_VOL, H5E_UNSUPPORTED, NULL, "VOL driver has no 'group open' method") + + if(NULL == (ret_value = (cls->group_cls.open) + (obj, loc_params, name, gapl_id, dxpl_id, req))) + HGOTO_ERROR(H5E_VOL, H5E_CANTOPENOBJ, NULL, "open failed") + +done: + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5VL_group_open() */ + + +/*------------------------------------------------------------------------- + * Function: H5VL_group_get + * + * Purpose: Get specific information about the group through the VOL + * + * Return: Success: non negative + * + * Failure: negative + * + *------------------------------------------------------------------------- + */ +herr_t +H5VL_group_get(void *obj, const H5VL_class_t *cls, H5VL_group_get_t get_type, + hid_t dxpl_id, void **req, ...) +{ + va_list arguments; /* argument list passed from the API call */ + herr_t ret_value = SUCCEED; + + FUNC_ENTER_NOAPI(FAIL) + + if(NULL == cls->group_cls.get) + HGOTO_ERROR(H5E_VOL, H5E_UNSUPPORTED, FAIL, "VOL driver has no 'group get' method") + + va_start (arguments, req); + if((ret_value = (cls->group_cls.get) + (obj, get_type, dxpl_id, req, arguments)) < 0) + HGOTO_ERROR(H5E_VOL, H5E_CANTGET, FAIL, "get failed") + va_end (arguments); + +done: + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5VL_group_get() */ + + +/*------------------------------------------------------------------------- + * Function: H5VL_group_specific + * + * Purpose: specific operation on groups through the VOL + * + * Return: Success: non negative + * + * Failure: negative + * + *------------------------------------------------------------------------- + */ +herr_t +H5VL_group_specific(void *obj, const H5VL_class_t *cls, H5VL_group_specific_t specific_type, + hid_t dxpl_id, void **req, ...) +{ + va_list arguments; /* argument list passed from the API call */ + herr_t ret_value = SUCCEED; + + FUNC_ENTER_NOAPI(FAIL) + + if(NULL == cls->group_cls.specific) + HGOTO_ERROR(H5E_VOL, H5E_UNSUPPORTED, FAIL, "VOL driver has no 'group specific' method") + + va_start (arguments, req); + if((ret_value = (cls->group_cls.specific) + (obj, specific_type, dxpl_id, req, arguments)) < 0) + HGOTO_ERROR(H5E_VOL, H5E_CANTOPERATE, FAIL, "Unable to execute group specific callback") + va_end (arguments); + +done: + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5VL_group_specific() */ + + +/*------------------------------------------------------------------------- + * Function: H5VL_group_optional + * + * Purpose: optional operation specific to drivers. + * + * Return: Success: non negative + * + * Failure: negative + * + *------------------------------------------------------------------------- + */ +herr_t +H5VL_group_optional(void *obj, const H5VL_class_t *cls, hid_t dxpl_id, void **req, ...) +{ + va_list arguments; /* argument list passed from the API call */ + herr_t ret_value = SUCCEED; + + FUNC_ENTER_NOAPI(FAIL) + + if(NULL == cls->group_cls.optional) + HGOTO_ERROR(H5E_VOL, H5E_UNSUPPORTED, FAIL, "VOL driver has no 'group optional' method") + + va_start (arguments, req); + if((ret_value = (cls->group_cls.optional)(obj, dxpl_id, req, arguments)) < 0) + HGOTO_ERROR(H5E_VOL, H5E_CANTOPERATE, FAIL, "Unable to execute group optional callback") + va_end (arguments); + +done: + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5VL_group_optional() */ + + +/*------------------------------------------------------------------------- + * Function: H5VL_group_close + * + * Purpose: Closes a group through the VOL + * + * Return: SUCCEED/FAIL + * + *------------------------------------------------------------------------- + */ +herr_t +H5VL_group_close(void *grp, const H5VL_class_t *cls, hid_t dxpl_id, void **req) +{ + herr_t ret_value = SUCCEED; + + HDassert(grp); + HDassert(cls); + + FUNC_ENTER_NOAPI(FAIL) + + /* Check if the corresponding VOL callback exists */ + if (NULL == cls->group_cls.close) + HGOTO_ERROR(H5E_VOL, H5E_UNSUPPORTED, FAIL, "VOL driver has no 'group close' method"); + + /* Call the corresponding VOL callback */ + if ((ret_value = (cls->group_cls.close)(grp, dxpl_id, req)) < 0) + HGOTO_ERROR(H5E_VOL, H5E_CANTRELEASE, FAIL, "close failed"); + +done: + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5VL_group_close() */ + + +/*------------------------------------------------------------------------- + * Function: H5VL_link_create + * + * Purpose: Creates a hard link through the VOL + * + * Return: Non-negative on success/Negative on failure + * + *------------------------------------------------------------------------- + */ +herr_t +H5VL_link_create(H5VL_link_create_type_t create_type, void *obj, H5VL_loc_params_t loc_params, + const H5VL_class_t *cls, hid_t lcpl_id, hid_t lapl_id, hid_t dxpl_id, void **req) +{ + herr_t ret_value = SUCCEED; /* Return value */ + + FUNC_ENTER_NOAPI(FAIL) + + /* check if the corresponding VOL create callback exists */ + if(NULL == cls->link_cls.create) + HGOTO_ERROR(H5E_VOL, H5E_UNSUPPORTED, FAIL, "VOL driver has no 'link create' method") + /* call the corresponding VOL create callback */ + if((ret_value = (cls->link_cls.create) + (create_type, obj, loc_params, lcpl_id, lapl_id, dxpl_id, req)) < 0) + HGOTO_ERROR(H5E_VOL, H5E_CANTINIT, FAIL, "link create failed") + +done: + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5VL_link_create() */ + + +/*------------------------------------------------------------------------- + * Function: H5VL_link_copy + * + * Purpose: Copys a link from src to dst. + * + * Return: Non-negative on success/Negative on failure + * + *------------------------------------------------------------------------- + */ +herr_t +H5VL_link_copy(void *src_obj, H5VL_loc_params_t loc_params1, void *dst_obj, + H5VL_loc_params_t loc_params2, const H5VL_class_t *cls, + hid_t lcpl_id, hid_t lapl_id, hid_t dxpl_id, void **req) +{ + herr_t ret_value = SUCCEED; /* Return value */ + + FUNC_ENTER_NOAPI(FAIL) + + /* check if the corresponding VOL copy callback exists */ + if(NULL == cls->link_cls.copy) + HGOTO_ERROR(H5E_VOL, H5E_UNSUPPORTED, FAIL, "VOL driver has no 'link copy' method") + + /* call the corresponding VOL copy callback */ + if((ret_value = (cls->link_cls.copy) + (src_obj, loc_params1, dst_obj, loc_params2, lcpl_id, + lapl_id, dxpl_id, req)) < 0) + HGOTO_ERROR(H5E_VOL, H5E_CANTINIT, FAIL, "link copy failed") + +done: + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5VL_link_copy() */ + + +/*------------------------------------------------------------------------- + * Function: H5VL_link_move + * + * Purpose: Moves a link from src to dst. + * + * Return: Non-negative on success/Negative on failure + * + *------------------------------------------------------------------------- + */ +herr_t +H5VL_link_move(void *src_obj, H5VL_loc_params_t loc_params1, void *dst_obj, + H5VL_loc_params_t loc_params2, const H5VL_class_t *cls, + hid_t lcpl_id, hid_t lapl_id, hid_t dxpl_id, void **req) +{ + herr_t ret_value = SUCCEED; /* Return value */ + + FUNC_ENTER_NOAPI(FAIL) + + /* check if the corresponding VOL move callback exists */ + if(NULL == cls->link_cls.move) + HGOTO_ERROR(H5E_VOL, H5E_UNSUPPORTED, FAIL, "VOL driver has no 'link move' method") + + /* call the corresponding VOL move callback */ + if((ret_value = (cls->link_cls.move) + (src_obj, loc_params1, dst_obj, loc_params2, lcpl_id, + lapl_id, dxpl_id, req)) < 0) + HGOTO_ERROR(H5E_VOL, H5E_CANTINIT, FAIL, "link move failed") + +done: + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5VL_link_move() */ + + +/*------------------------------------------------------------------------- + * Function: H5VL_link_get + * + * Purpose: Get specific information about the link through the VOL + * + * Return: Success: non negative + * + * Failure: negative + * + *------------------------------------------------------------------------- + */ +herr_t +H5VL_link_get(void *obj, H5VL_loc_params_t loc_params, const H5VL_class_t *cls, H5VL_link_get_t get_type, + hid_t dxpl_id, void **req, ...) +{ + va_list arguments; /* argument list passed from the API call */ + herr_t ret_value = SUCCEED; + + FUNC_ENTER_NOAPI(FAIL) + + if(NULL == cls->link_cls.get) + HGOTO_ERROR(H5E_VOL, H5E_UNSUPPORTED, FAIL, "VOL driver has no 'link get' method") + + va_start (arguments, req); + if((ret_value = (cls->link_cls.get) + (obj, loc_params, get_type, dxpl_id, req, arguments)) < 0) + HGOTO_ERROR(H5E_VOL, H5E_CANTGET, FAIL, "get failed") + va_end (arguments); + +done: + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5VL_link_get() */ + + +/*------------------------------------------------------------------------- + * Function: H5VL_link_specific + * + * Purpose: specific operation on links through the VOL + * + * Return: Success: non negative + * + * Failure: negative + * + *------------------------------------------------------------------------- + */ +herr_t +H5VL_link_specific(void *obj, H5VL_loc_params_t loc_params, const H5VL_class_t *cls, + H5VL_link_specific_t specific_type, hid_t dxpl_id, void **req, ...) +{ + va_list arguments; /* argument list passed from the API call */ + herr_t ret_value = SUCCEED; + + FUNC_ENTER_NOAPI(FAIL) + + if(NULL == cls->link_cls.specific) + HGOTO_ERROR(H5E_VOL, H5E_UNSUPPORTED, FAIL, "VOL driver has no 'link specific' method") + + va_start (arguments, req); + if((ret_value = (cls->link_cls.specific) + (obj, loc_params, specific_type, dxpl_id, req, arguments)) < 0) + HGOTO_ERROR(H5E_VOL, H5E_CANTOPERATE, FAIL, "Unable to execute link specific callback") + va_end (arguments); + +done: + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5VL_link_specific() */ + + +/*------------------------------------------------------------------------- + * Function: H5VL_link_optional + * + * Purpose: optional operation specific to drivers. + * + * Return: Success: non negative + * + * Failure: negative + * + *------------------------------------------------------------------------- + */ +herr_t +H5VL_link_optional(void *obj, const H5VL_class_t *cls, hid_t dxpl_id, void **req, ...) +{ + va_list arguments; /* argument list passed from the API call */ + herr_t ret_value = SUCCEED; + + FUNC_ENTER_NOAPI(FAIL) + + if(NULL == cls->link_cls.optional) + HGOTO_ERROR(H5E_VOL, H5E_UNSUPPORTED, FAIL, "VOL driver has no 'link optional' method") + + va_start (arguments, req); + if((ret_value = (cls->link_cls.optional)(obj, dxpl_id, req, arguments)) < 0) + HGOTO_ERROR(H5E_VOL, H5E_CANTOPERATE, FAIL, "Unable to execute link optional callback") + va_end (arguments); + +done: + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5VL_link_optional() */ + + +/*------------------------------------------------------------------------- + * Function: H5VL_object_open + * + * Purpose: Opens a object through the VOL + * + * Return: Success: User ID of the new object. + * + * Failure: NULL + * + *------------------------------------------------------------------------- + */ +void * +H5VL_object_open(void *obj, H5VL_loc_params_t params, const H5VL_class_t *cls, H5I_type_t *opened_type, + hid_t dxpl_id, void **req) +{ + void *ret_value; /* Return value */ + + FUNC_ENTER_NOAPI(NULL) + + /* check if the corresponding VOL open callback exists */ + if(NULL == cls->object_cls.open) + HGOTO_ERROR(H5E_VOL, H5E_UNSUPPORTED, NULL, "VOL driver has no 'object open' method") + + /* call the corresponding VOL open callback */ + if(NULL == (ret_value = (cls->object_cls.open) + (obj, params, opened_type, dxpl_id, req))) + HGOTO_ERROR(H5E_VOL, H5E_CANTOPENOBJ, NULL, "open failed") + +done: + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5VL_object_open() */ + + +/*------------------------------------------------------------------------- + * Function: H5VL_object_copy + * + * Purpose: Copies an object to another destination through the VOL + * + * Return: Success: Non Negative + * Failure: Negative + * + *------------------------------------------------------------------------- + */ +herr_t +H5VL_object_copy(void *src_obj, H5VL_loc_params_t loc_params1, const H5VL_class_t *cls1, const char *src_name, + void *dst_obj, H5VL_loc_params_t loc_params2, const H5VL_class_t *cls2, const char *dst_name, + hid_t ocpypl_id, hid_t lcpl_id, hid_t dxpl_id, void **req) +{ + herr_t ret_value = SUCCEED; + + FUNC_ENTER_NOAPI(FAIL) + + /* Make sure that the VOL drivers are the same */ + if (cls1->value != cls2->value) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "Objects are accessed through different VOL drivers and can't be linked") + + if(NULL == cls1->object_cls.copy) + HGOTO_ERROR(H5E_VOL, H5E_UNSUPPORTED, FAIL, "VOL driver has no 'object copy' method") + + if((ret_value = (cls1->object_cls.copy) + (src_obj, loc_params1, src_name, dst_obj, loc_params2, dst_name, ocpypl_id, + lcpl_id, dxpl_id, req)) < 0) + HGOTO_ERROR(H5E_VOL, H5E_CANTRELEASE, FAIL, "copy failed") + +done: + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5VL_object_copy() */ + + +/*------------------------------------------------------------------------- + * Function: H5VL_object_get + * + * Purpose: Get specific information about the object through the VOL + * + * Return: Success: non negative + * + * Failure: negative + * + *------------------------------------------------------------------------- + */ +herr_t +H5VL_object_get(void *obj, H5VL_loc_params_t loc_params, const H5VL_class_t *cls, H5VL_object_get_t get_type, + hid_t dxpl_id, void **req, ...) +{ + va_list arguments; /* argument list passed from the API call */ + herr_t ret_value = SUCCEED; + + FUNC_ENTER_NOAPI(FAIL) + + if(NULL == cls->object_cls.get) + HGOTO_ERROR(H5E_VOL, H5E_UNSUPPORTED, FAIL, "VOL driver has no 'object get' method") + + va_start (arguments, req); + if((ret_value = (cls->object_cls.get) + (obj, loc_params, get_type, dxpl_id, req, arguments)) < 0) + HGOTO_ERROR(H5E_VOL, H5E_CANTGET, FAIL, "get failed") + va_end (arguments); + +done: + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5VL_object_get() */ + + +/*------------------------------------------------------------------------- + * Function: H5VL_object_specific + * + * Purpose: specific operation on objects through the VOL + * + * Return: Success: non negative + * Failure: negative + * + *------------------------------------------------------------------------- + */ +herr_t +H5VL_object_specific(void *obj, H5VL_loc_params_t loc_params, const H5VL_class_t *cls, + H5VL_object_specific_t specific_type, hid_t dxpl_id, void **req, ...) +{ + va_list arguments; /* argument list passed from the API call */ + herr_t ret_value = SUCCEED; + + FUNC_ENTER_NOAPI(FAIL) + + if(NULL == cls->object_cls.specific) + HGOTO_ERROR(H5E_VOL, H5E_UNSUPPORTED, FAIL, "VOL driver has no 'object specific' method") + + va_start (arguments, req); + if((ret_value = (cls->object_cls.specific) + (obj, loc_params, specific_type, dxpl_id, req, arguments)) < 0) + HGOTO_ERROR(H5E_VOL, H5E_CANTGET, FAIL, "specific failed") + va_end (arguments); + +done: + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5VL_object_specific() */ + + +/*------------------------------------------------------------------------- + * Function: H5VL_object_optional + * + * Purpose: optional operation specific to drivers. + * + * Return: Success: non negative + * + * Failure: negative + * + *------------------------------------------------------------------------- + */ +herr_t +H5VL_object_optional(void *obj, const H5VL_class_t *cls, hid_t dxpl_id, void **req, ...) +{ + va_list arguments; /* argument list passed from the API call */ + herr_t ret_value = SUCCEED; + + FUNC_ENTER_NOAPI(FAIL) + + if(NULL == cls->object_cls.optional) + HGOTO_ERROR(H5E_VOL, H5E_UNSUPPORTED, FAIL, "VOL driver has no 'object optional' method") + + va_start (arguments, req); + if((ret_value = (cls->object_cls.optional)(obj, dxpl_id, req, arguments)) < 0) + HGOTO_ERROR(H5E_VOL, H5E_CANTOPERATE, FAIL, "Unable to execute object optional callback") + va_end (arguments); + +done: + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5VL_object_optional() */ + + +/*------------------------------------------------------------------------- + * Function: H5VL_datatype_commit + * + * Purpose: Commits a datatype to the file through the VOL + * + * Return: Success: Positive + * + * Failure: Negative + * + *------------------------------------------------------------------------- + */ +void * +H5VL_datatype_commit(void *obj, H5VL_loc_params_t loc_params, const H5VL_class_t *cls, const char *name, + hid_t type_id, hid_t lcpl_id, hid_t tcpl_id, hid_t tapl_id, + hid_t dxpl_id, void **req) +{ + void *ret_value = NULL; /* Return value */ + + FUNC_ENTER_NOAPI(NULL) + + /* check if the corresponding VOL commit callback exists */ + if(NULL == cls->datatype_cls.commit) + HGOTO_ERROR(H5E_VOL, H5E_UNSUPPORTED, NULL, "VOL driver has no 'datatype commit' method") + + /* call the corresponding VOL commit callback */ + if(NULL == (ret_value = (cls->datatype_cls.commit) + (obj, loc_params, name, type_id, lcpl_id, tcpl_id, tapl_id, dxpl_id, req))) + HGOTO_ERROR(H5E_VOL, H5E_CANTINIT, NULL, "commit failed") + +done: + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5VL_datatype_commit() */ + + +/*------------------------------------------------------------------------- + * Function: H5VL_datatype_open + * + * Purpose: Opens a named datatype through the VOL + * + * Return: Success: User ID of the datatype. + * + * Failure: NULL + * + *------------------------------------------------------------------------- + */ +void * +H5VL_datatype_open(void *obj, H5VL_loc_params_t loc_params, const H5VL_class_t *cls, const char *name, + hid_t tapl_id, hid_t dxpl_id, void **req) +{ + void *ret_value = NULL; /* Return value */ + + FUNC_ENTER_NOAPI(NULL) + + /* check if the type specific corresponding VOL open callback exists */ + if(NULL == cls->datatype_cls.open) + HGOTO_ERROR(H5E_VOL, H5E_CANTINIT, NULL, "no datatype open callback"); + + /* call the corresponding VOL open callback */ + if(NULL == (ret_value = (cls->datatype_cls.open) + (obj, loc_params, name, tapl_id, dxpl_id, req))) + HGOTO_ERROR(H5E_VOL, H5E_CANTOPENOBJ, NULL, "open failed") + +done: + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5VL_datatype_open() */ + + +/*------------------------------------------------------------------------- + * Function: H5VL_datatype_get + * + * Purpose: Get specific information about the datatype through the VOL + * + * Return: SUCCEED/FAIL + * + *------------------------------------------------------------------------- + */ +herr_t +H5VL_datatype_get(void *obj, const H5VL_class_t *cls, H5VL_datatype_get_t get_type, + hid_t dxpl_id, void **req, ...) +{ + va_list arguments; /* argument list passed from the API call */ + herr_t ret_value = SUCCEED; + + FUNC_ENTER_NOAPI(FAIL) + + /* Check if the corresponding VOL callback exists */ + if (NULL == cls->datatype_cls.get) + HGOTO_ERROR(H5E_VOL, H5E_UNSUPPORTED, FAIL, "VOL driver has no 'datatype get' method"); + va_start (arguments, req); + + /* Call the corresponding VOL callback */ + if ((ret_value = (cls->datatype_cls.get)(obj, get_type, dxpl_id, req, arguments)) < 0) + HGOTO_ERROR(H5E_VOL, H5E_CANTGET, FAIL, "get failed"); + va_end (arguments); + +done: + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5VL_datatype_get() */ + + +/*------------------------------------------------------------------------- + * Function: H5VL_datatype_specific + * + * Purpose: specific operation on datatypes through the VOL + * + * Return: Success: non negative + * + * Failure: negative + * + *------------------------------------------------------------------------- + */ +herr_t +H5VL_datatype_specific(void *obj, const H5VL_class_t *cls, H5VL_datatype_specific_t specific_type, + hid_t dxpl_id, void **req, ...) +{ + va_list arguments; /* argument list passed from the API call */ + herr_t ret_value = SUCCEED; + + FUNC_ENTER_NOAPI(FAIL) + + if(NULL == cls->datatype_cls.specific) + HGOTO_ERROR(H5E_VOL, H5E_UNSUPPORTED, FAIL, "VOL driver has no 'datatype specific' method") + + va_start (arguments, req); + if((ret_value = (cls->datatype_cls.specific) + (obj, specific_type, dxpl_id, req, arguments)) < 0) + HGOTO_ERROR(H5E_VOL, H5E_CANTOPERATE, FAIL, "Unable to execute datatype specific callback") + va_end (arguments); + +done: + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5VL_datatype_specific() */ + + +/*------------------------------------------------------------------------- + * Function: H5VL_datatype_optional + * + * Purpose: optional operation specific to drivers. + * + * Return: Success: non negative + * + * Failure: negative + * + *------------------------------------------------------------------------- + */ +herr_t +H5VL_datatype_optional(void *obj, const H5VL_class_t *cls, hid_t dxpl_id, void **req, ...) +{ + va_list arguments; /* argument list passed from the API call */ + herr_t ret_value = SUCCEED; + + FUNC_ENTER_NOAPI(FAIL) + + if(NULL == cls->datatype_cls.optional) + HGOTO_ERROR(H5E_VOL, H5E_UNSUPPORTED, FAIL, "VOL driver has no 'datatype optional' method") + + va_start (arguments, req); + if((ret_value = (cls->datatype_cls.optional)(obj, dxpl_id, req, arguments)) < 0) + HGOTO_ERROR(H5E_VOL, H5E_CANTOPERATE, FAIL, "Unable to execute datatype optional callback") + va_end (arguments); + +done: + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5VL_datatype_optional() */ + + +/*------------------------------------------------------------------------- + * Function: H5VL_datatype_close + * + * Purpose: Closes a datatype through the VOL + * + * Return: SUCCEED/FAIL + * + *------------------------------------------------------------------------- + */ +herr_t +H5VL_datatype_close(void *dt, const H5VL_class_t *cls, hid_t dxpl_id, void **req) +{ + herr_t ret_value = SUCCEED; /* Return value */ + + FUNC_ENTER_NOAPI(FAIL) + + /* Check if the corresponding VOL callback exists */ + if (NULL == cls->datatype_cls.close) + HGOTO_ERROR(H5E_VOL, H5E_UNSUPPORTED, FAIL, "VOL driver has no 'datatype close' method"); + + /* Call the corresponding VOL callback */ + if ((ret_value = (cls->datatype_cls.close)(dt, dxpl_id, req)) < 0) + HGOTO_ERROR(H5E_VOL, H5E_CANTRELEASE, FAIL, "close failed"); + +done: + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5VL_datatype_close() */ + + +/*------------------------------------------------------------------------- + * Function: H5VL_request_cancel + * + * Purpose: Cancels an asynchronous request through the VOL + * + * Return: SUCCEED/FAIL + * + *------------------------------------------------------------------------- + */ +herr_t +H5VL_request_cancel(void **req, const H5VL_class_t *cls, H5ES_status_t *status) +{ + herr_t ret_value = SUCCEED; + + FUNC_ENTER_NOAPI(FAIL) + + HDassert(req); + HDassert(cls); + HDassert(status); + + /* Check if the corresponding VOL callback exists */ + if (NULL == cls->async_cls.cancel) + HGOTO_ERROR(H5E_VOL, H5E_UNSUPPORTED, FAIL, "VOL driver has no 'async cancel' method"); + + /* Call the corresponding VOL callback */ + if ((ret_value = (cls->async_cls.cancel)(req, status)) < 0) + HGOTO_ERROR(H5E_VOL, H5E_CANTRELEASE, FAIL, "request cancel failed"); + +done: + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5VL_request_cancel() */ + + +/*------------------------------------------------------------------------- + * Function: H5VL_request_test + * + * Purpose: Tests an asynchronous request through the VOL + * + * Return: SUCCEED/FAIL + * + *------------------------------------------------------------------------- + */ +herr_t +H5VL_request_test(void **req, const H5VL_class_t *cls, H5ES_status_t *status) +{ + herr_t ret_value = SUCCEED; + + FUNC_ENTER_NOAPI(FAIL) + + HDassert(req); + HDassert(cls); + HDassert(status); + + /* Check if the corresponding VOL callback exists */ + if (NULL == cls->async_cls.test) + HGOTO_ERROR(H5E_VOL, H5E_UNSUPPORTED, FAIL, "VOL driver has no 'async test' method"); + + /* Call the corresponding VOL callback */ + if ((ret_value = (cls->async_cls.test)(req, status)) < 0) + HGOTO_ERROR(H5E_VOL, H5E_CANTRELEASE, FAIL, "request test failed"); + +done: + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5VL_request_test() */ + + +/*------------------------------------------------------------------------- + * Function: H5VL_request_wait + * + * Purpose: Waits on an asychronous request through the VOL + * + * Return: SUCCEED/FAIL + * + *------------------------------------------------------------------------- + */ +herr_t +H5VL_request_wait(void **req, const H5VL_class_t *cls, H5ES_status_t *status) +{ + herr_t ret_value = SUCCEED; + + FUNC_ENTER_NOAPI(FAIL) + + HDassert(req); + HDassert(cls); + HDassert(status); + + /* Check if the corresponding VOL callback exists */ + if (NULL == cls->async_cls.wait) + HGOTO_ERROR(H5E_VOL, H5E_UNSUPPORTED, FAIL, "VOL driver has no 'async wait' method"); + + /* Call the corresponding VOL callback */ + if ((ret_value = (cls->async_cls.wait)(req, status)) < 0) + HGOTO_ERROR(H5E_VOL, H5E_CANTRELEASE, FAIL, "request wait failed"); + +done: + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5VL_request_wait() */ + diff --git a/src/H5VLmodule.h b/src/H5VLmodule.h new file mode 100644 index 0000000..1ae0d61 --- /dev/null +++ b/src/H5VLmodule.h @@ -0,0 +1,31 @@ +/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * + * Copyright by The HDF Group. * + * All rights reserved. * + * * + * This file is part of HDF5. The full HDF5 copyright notice, including * + * terms governing use, modification, and redistribution, is contained in * + * the COPYING file, which can be found at the root of the source code * + * distribution tree, or in https://support.hdfgroup.org/ftp/HDF5/releases. * + * If you do not have access to either file, you may request a copy from * + * help@hdfgroup.org. * + * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ + +/* + * Purpose: This file contains declarations which define macros for the + * H5VL package. Including this header means that the source file + * is part of the H5VL package. + */ + +#ifndef _H5VLmodule_H +#define _H5VLmodule_H + +/* Define the proper control macros for the generic FUNC_ENTER/LEAVE and error + * reporting macros. + */ +#define H5VL_MODULE +#define H5_MY_PKG H5VL +#define H5_MY_PKG_ERR H5E_VOL +#define H5_MY_PKG_INIT YES + +#endif /* _H5VLmodule_H */ + diff --git a/src/H5VLnative.c b/src/H5VLnative.c new file mode 100644 index 0000000..acfceed --- /dev/null +++ b/src/H5VLnative.c @@ -0,0 +1,3533 @@ +/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * + * Copyright by The HDF Group. * + * All rights reserved. * + * * + * This file is part of HDF5. The full HDF5 copyright notice, including * + * terms governing use, modification, and redistribution, is contained in * + * the COPYING file, which can be found at the root of the source code * + * distribution tree, or in https://support.hdfgroup.org/ftp/HDF5/releases. * + * If you do not have access to either file, you may request a copy from * + * help@hdfgroup.org. * + * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ + +/* + * Purpose: The native VOL driver where access is to a single HDF5 file + * using HDF5 VFDs. + */ + +#define H5A_FRIEND /* Suppress error about including H5Apkg */ +#define H5D_FRIEND /* Suppress error about including H5Dpkg */ +#define H5F_FRIEND /* Suppress error about including H5Fpkg */ +#define H5G_FRIEND /* Suppress error about including H5Gpkg */ +#define H5L_FRIEND /* Suppress error about including H5Lpkg */ +#define H5O_FRIEND /* Suppress error about including H5Opkg */ +#define H5R_FRIEND /* Suppress error about including H5Rpkg */ +#define H5T_FRIEND /* Suppress error about including H5Tpkg */ + + +#include "H5private.h" /* Generic Functions */ +#include "H5Apkg.h" /* Attributes */ +#include "H5Dpkg.h" /* Datasets */ +#include "H5Eprivate.h" /* Error handling */ +#include "H5Fpkg.h" /* Files */ +#include "H5Gpkg.h" /* Groups */ +#include "H5Iprivate.h" /* IDs */ +#include "H5Lpkg.h" /* Links */ +#include "H5MFprivate.h" /* File memory management */ +#include "H5MMprivate.h" /* Memory management */ +#include "H5Opkg.h" /* Object headers */ +#include "H5Pprivate.h" /* Property lists */ +#include "H5Rpkg.h" /* References */ +#include "H5SMprivate.h" /* Shared Object Header Messages */ +#include "H5Tpkg.h" /* Datatypes */ +#include "H5VLprivate.h" /* VOL drivers */ +#include "H5VLnative.h" /* Native VOL driver */ + +/* + * The VOL driver identification number. + */ +static hid_t H5VL_NATIVE_ID_g = H5I_INVALID_HID; + + +/* Prototypes */ +static H5F_t *H5VL_native_get_file(void *obj, H5I_type_t type); +static herr_t H5VL__native_term(void); + +/* Atrribute callbacks */ +static void *H5VL_native_attr_create(void *obj, H5VL_loc_params_t loc_params, const char *attr_name, hid_t acpl_id, hid_t aapl_id, hid_t dxpl_id, void **req); +static void *H5VL_native_attr_open(void *obj, H5VL_loc_params_t loc_params, const char *attr_name, hid_t aapl_id, hid_t dxpl_id, void **req); +static herr_t H5VL_native_attr_read(void *attr, hid_t dtype_id, void *buf, hid_t dxpl_id, void **req); +static herr_t H5VL_native_attr_write(void *attr, hid_t dtype_id, const void *buf, hid_t dxpl_id, void **req); +static herr_t H5VL_native_attr_get(void *obj, H5VL_attr_get_t get_type, hid_t dxpl_id, void **req, va_list arguments); +static herr_t H5VL_native_attr_specific(void *obj, H5VL_loc_params_t loc_params, H5VL_attr_specific_t specific_type, hid_t dxpl_id, void **req, va_list arguments); +static herr_t H5VL_native_attr_close(void *attr, hid_t dxpl_id, void **req); + +/* Dataset callbacks */ +static void *H5VL_native_dataset_create(void *obj, H5VL_loc_params_t loc_params, const char *name, hid_t dcpl_id, hid_t dapl_id, hid_t dxpl_id, void **req); +static void *H5VL_native_dataset_open(void *obj, H5VL_loc_params_t loc_params, const char *name, hid_t dapl_id, hid_t dxpl_id, void **req); +static herr_t H5VL_native_dataset_read(void *dset, hid_t mem_type_id, hid_t mem_space_id, + hid_t file_space_id, hid_t plist_id, void *buf, void **req); +static herr_t H5VL_native_dataset_write(void *dset, hid_t mem_type_id, hid_t mem_space_id, + hid_t file_space_id, hid_t plist_id, const void *buf, void **req); +static herr_t H5VL_native_dataset_get(void *dset, H5VL_dataset_get_t get_type, hid_t dxpl_id, void **req, va_list arguments); +static herr_t H5VL_native_dataset_specific(void *dset, H5VL_dataset_specific_t specific_type, hid_t dxpl_id, void **req, va_list arguments); +static herr_t H5VL_native_dataset_optional(void *dset, hid_t dxpl_id, void **req, va_list arguments); +static herr_t H5VL_native_dataset_close(void *dset, hid_t dxpl_id, void **req); + +/* File callbacks */ +static void *H5VL_native_file_create(const char *name, unsigned flags, hid_t fcpl_id, hid_t fapl_id, hid_t dxpl_id, void **req); +static void *H5VL_native_file_open(const char *name, unsigned flags, hid_t fapl_id, hid_t dxpl_id, void **req); +static herr_t H5VL_native_file_get(void *file, H5VL_file_get_t get_type, hid_t dxpl_id, void **req, va_list arguments); +static herr_t H5VL_native_file_specific(void *file, H5VL_file_specific_t specific_type, hid_t dxpl_id, void **req, va_list arguments); +static herr_t H5VL_native_file_optional(void *file, hid_t dxpl_id, void **req, va_list arguments); +static herr_t H5VL_native_file_close(void *file, hid_t dxpl_id, void **req); + +/* Group callbacks */ +static void *H5VL_native_group_create(void *obj, H5VL_loc_params_t loc_params, const char *name, hid_t gcpl_id, hid_t gapl_id, hid_t dxpl_id, void **req); +static void *H5VL_native_group_open(void *obj, H5VL_loc_params_t loc_params, const char *name, hid_t gapl_id, hid_t dxpl_id, void **req); +static herr_t H5VL_native_group_get(void *obj, H5VL_group_get_t get_type, hid_t dxpl_id, void **req, va_list arguments); +static herr_t H5VL_native_group_specific(void *dset, H5VL_group_specific_t specific_type, hid_t dxpl_id, void **req, va_list arguments); +static herr_t H5VL_native_group_close(void *grp, hid_t dxpl_id, void **req); + +/* Link callbacks */ +static herr_t H5VL_native_link_create(H5VL_link_create_type_t create_type, void *obj, + H5VL_loc_params_t loc_params, hid_t lcpl_id, hid_t lapl_id, hid_t dxpl_id, void **req); +static herr_t H5VL_native_link_copy(void *src_obj, H5VL_loc_params_t loc_params1, + void *dst_obj, H5VL_loc_params_t loc_params2, + hid_t lcpl_id, hid_t lapl_id, hid_t dxpl_id, void **req); +static herr_t H5VL_native_link_move(void *src_obj, H5VL_loc_params_t loc_params1, + void *dst_obj, H5VL_loc_params_t loc_params2, + hid_t lcpl_id, hid_t lapl_id, hid_t dxpl_id, void **req); +static herr_t H5VL_native_link_get(void *obj, H5VL_loc_params_t loc_params, H5VL_link_get_t get_type, hid_t dxpl_id, void **req, va_list arguments); +static herr_t H5VL_native_link_specific(void *obj, H5VL_loc_params_t loc_params, H5VL_link_specific_t specific_type, hid_t dxpl_id, void **req, va_list arguments); + +/* Object callbacks */ +static void *H5VL_native_object_open(void *obj, H5VL_loc_params_t loc_params, H5I_type_t *opened_type, hid_t dxpl_id, void **req); +static herr_t H5VL_native_object_copy(void *src_obj, H5VL_loc_params_t loc_params1, const char *src_name, + void *dst_obj, H5VL_loc_params_t loc_params2, const char *dst_name, + hid_t ocpypl_id, hid_t lcpl_id, hid_t dxpl_id, void **req); +static herr_t H5VL_native_object_get(void *obj, H5VL_loc_params_t loc_params, H5VL_object_get_t get_type, hid_t dxpl_id, void **req, va_list arguments); +static herr_t H5VL_native_object_specific(void *obj, H5VL_loc_params_t loc_params, H5VL_object_specific_t specific_type, hid_t dxpl_id, void **req, va_list arguments); +static herr_t H5VL_native_object_optional(void *obj, hid_t dxpl_id, void **req, va_list arguments); + +/* Datatype callbacks */ +static void *H5VL_native_datatype_commit(void *obj, H5VL_loc_params_t loc_params, const char *name, hid_t type_id, hid_t lcpl_id, hid_t tcpl_id, hid_t tapl_id, hid_t dxpl_id, void **req); +static void *H5VL_native_datatype_open(void *obj, H5VL_loc_params_t loc_params, const char *name, hid_t tapl_id, hid_t dxpl_id, void **req); +static herr_t H5VL_native_datatype_get(void *dt, H5VL_datatype_get_t get_type, hid_t dxpl_id, void **req, va_list arguments); +static herr_t H5VL_native_datatype_specific(void *dt, H5VL_datatype_specific_t specific_type, hid_t dxpl_id, void **req, va_list arguments); +static herr_t H5VL_native_datatype_close(void *dt, hid_t dxpl_id, void **req); + +/* Native VOL driver class struct */ +static H5VL_class_t H5VL_native_cls_g = { + H5VL_NATIVE_VERSION, /* version */ + H5VL_NATIVE_VALUE, /* value */ + H5VL_NATIVE_NAME, /* name */ + NULL, /* initialize */ + NULL, /* terminate */ + (size_t)0, /* fapl size */ + NULL, /* fapl copy */ + NULL, /* fapl free */ + { /* attribute_cls */ + H5VL_native_attr_create, /* create */ + H5VL_native_attr_open, /* open */ + H5VL_native_attr_read, /* read */ + H5VL_native_attr_write, /* write */ + H5VL_native_attr_get, /* get */ + H5VL_native_attr_specific, /* specific */ + NULL, /* optional */ + H5VL_native_attr_close /* close */ + }, + { /* dataset_cls */ + H5VL_native_dataset_create, /* create */ + H5VL_native_dataset_open, /* open */ + H5VL_native_dataset_read, /* read */ + H5VL_native_dataset_write, /* write */ + H5VL_native_dataset_get, /* get */ + H5VL_native_dataset_specific, /* specific */ + H5VL_native_dataset_optional, /* optional */ + H5VL_native_dataset_close /* close */ + }, + { /* datatype_cls */ + H5VL_native_datatype_commit, /* commit */ + H5VL_native_datatype_open, /* open */ + H5VL_native_datatype_get, /* get */ + H5VL_native_datatype_specific, /* specific */ + NULL, /* optional */ + H5VL_native_datatype_close /* close */ + }, + { /* file_cls */ + H5VL_native_file_create, /* create */ + H5VL_native_file_open, /* open */ + H5VL_native_file_get, /* get */ + H5VL_native_file_specific, /* specific */ + H5VL_native_file_optional, /* optional */ + H5VL_native_file_close /* close */ + }, + { /* group_cls */ + H5VL_native_group_create, /* create */ + H5VL_native_group_open, /* open */ + H5VL_native_group_get, /* get */ + H5VL_native_group_specific, /* specific */ + NULL, /* optional */ + H5VL_native_group_close /* close */ + }, + { /* link_cls */ + H5VL_native_link_create, /* create */ + H5VL_native_link_copy, /* copy */ + H5VL_native_link_move, /* move */ + H5VL_native_link_get, /* get */ + H5VL_native_link_specific, /* specific */ + NULL /* optional */ + }, + { /* object_cls */ + H5VL_native_object_open, /* open */ + H5VL_native_object_copy, /* copy */ + H5VL_native_object_get, /* get */ + H5VL_native_object_specific, /* specific */ + H5VL_native_object_optional /* optional */ + }, + { /* async_cls */ + NULL, /* cancel */ + NULL, /* test */ + NULL /* wait */ + }, + NULL /* optional */ +}; + + +/*------------------------------------------------------------------------- + * Function: H5VL_native_init + * + * Purpose: Initialize this VOL driver by registering it with the + * library. + * + * Return: Success: The ID for the native driver + * Failure: H5I_INVALID_HID + * + *------------------------------------------------------------------------- + */ +hid_t +H5VL_native_init(void) +{ + hid_t ret_value = H5I_INVALID_HID; /* Return value */ + + FUNC_ENTER_NOAPI(H5I_INVALID_HID) + + /* Register the native VOL driver, if it isn't already */ + if(NULL == H5I_object_verify(H5VL_NATIVE_ID_g, H5I_VOL)) { + if((H5VL_NATIVE_ID_g = H5VL_register((const H5VL_class_t *)&H5VL_native_cls_g, + sizeof(H5VL_class_t), TRUE)) < 0) + HGOTO_ERROR(H5E_ATOM, H5E_CANTINSERT, H5I_INVALID_HID, "can't create ID for native VOL driver") + } + + /* Set return value */ + ret_value = H5VL_NATIVE_ID_g; + +done: + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5VL_native_init() */ + +/* XXX (VOL_MERGE): TEMPORARY */ +hid_t +H5VL_native_get_driver_id(void) +{ + return H5VL_NATIVE_ID_g; +} + + +/*--------------------------------------------------------------------------- + * Function: H5VL__native_term + * + * Purpose: Shut down the native VOL + * + * Returns: SUCCEED (Can't fail) + * + *--------------------------------------------------------------------------- + */ +static herr_t +H5VL__native_term(void) +{ + FUNC_ENTER_STATIC_NOERR + + /* Reset VFL ID */ + H5VL_NATIVE_ID_g = H5I_INVALID_HID; + + FUNC_LEAVE_NOAPI(SUCCEED) +} /* end H5VL__native_term() */ + + +/*------------------------------------------------------------------------- + * Function: H5Pset_fapl_native + * + * Purpose: Modify the file access property list to use the H5VL_NATIVE + * driver defined in this source file. + * + * Return: SUCCEED/FAIL + * + *------------------------------------------------------------------------- + */ +herr_t +H5Pset_fapl_native(hid_t fapl_id) +{ + H5P_genplist_t *plist; /* Property list pointer */ + herr_t ret_value; + + FUNC_ENTER_API(FAIL) + H5TRACE1("e", "i", fapl_id); + + if(NULL == (plist = H5P_object_verify(fapl_id, H5P_FILE_ACCESS))) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a file access property list") + + ret_value = H5P_set_vol(plist, H5VL_NATIVE_ID_g, NULL); + +done: + FUNC_LEAVE_API(ret_value) +} /* end H5Pset_fapl_native() */ + + +/*--------------------------------------------------------------------------- + * Function: H5VL_native_get_file + * + * Purpose: Utility routine to get file struct for an object via the + * native VOL driver. + * + * Returns: SUCCESS: A pointer to the H5F_t struct for the file + * associated with the object. + * FAILURE: NULL + * + *--------------------------------------------------------------------------- + */ +static H5F_t * +H5VL_native_get_file(void *obj, H5I_type_t type) +{ + H5F_t *ret_value = NULL; /* File pointer */ + H5O_loc_t *oloc = NULL; /* Object location for ID */ + + FUNC_ENTER_NOAPI_NOINIT + + switch(type) { + case H5I_FILE: + ret_value = (H5F_t *)obj; + break; + case H5I_GROUP: + { + H5G_t *grp; + grp = (H5G_t *)obj; + oloc = H5G_oloc(grp); + break; + } + case H5I_DATATYPE: + { + H5T_t *dt; + dt = (H5T_t *)obj; + oloc = H5T_oloc(dt); + break; + } + case H5I_DATASET: + { + H5D_t *dset; + dset = (H5D_t *)obj; + oloc = H5D_oloc(dset); + break; + } + + case H5I_ATTR: + { + H5A_t *attr; + attr = (H5A_t *)obj; + oloc = H5A_oloc(attr); + break; + } + case H5I_UNINIT: + case H5I_BADID: + case H5I_DATASPACE: + case H5I_REFERENCE: + case H5I_VFL: + case H5I_VOL: + case H5I_GENPROP_CLS: + case H5I_GENPROP_LST: + case H5I_ERROR_CLASS: + case H5I_ERROR_MSG: + case H5I_ERROR_STACK: + case H5I_NTYPES: + default: + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, NULL, "not a file or file object") + } + + if(!ret_value) { + if (!oloc) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, NULL, "object is not assocated with a file") + ret_value = oloc->file; + } + if(!ret_value) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, NULL, "object is not associated with a file") + +done: + FUNC_LEAVE_NOAPI(ret_value) +} /* H5VL_native_get_file */ + + +/*--------------------------------------------------------------------------- + * Function: H5VL_native_register + * + * Purpose: Utility routine to register an ID with the native VOL driver + * as an auxilary object. + * + * Returns: Success: An ID for the object + * Failure: H5I_INVALID_HID + * + *--------------------------------------------------------------------------- + */ +hid_t +H5VL_native_register(H5I_type_t type, void *obj, hbool_t app_ref) +{ + hid_t ret_value = H5I_INVALID_HID; + + FUNC_ENTER_NOAPI_NOINIT + + HDassert(obj); + + /* If the datatype is already VOL-managed, the datatype's vol_obj + * field will get clobbered later, so disallow this. + */ + if(type == H5I_DATATYPE) + if(((H5T_t *)obj)->vol_obj != NULL) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, H5I_INVALID_HID, "can only get an ID for an uncommitted datatype") + + /* Get an ID for the object */ + if((ret_value = H5VL_object_register(obj, type, H5VL_NATIVE_ID_g, app_ref)) < 0) + HGOTO_ERROR(H5E_ATOM, H5E_CANTREGISTER, H5I_INVALID_HID, "unable to get an ID for the object") + +done: + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5VL_native_register() */ + + +/*--------------------------------------------------------------------------- + * Function: H5VL_native_unregister + * + * Purpose: Utility routine to decrement ref count on Native VOL driver + * objects. + * + * Returns: SUCCEED/FAIL + * + *--------------------------------------------------------------------------- + */ +herr_t +H5VL_native_unregister(hid_t obj_id) +{ + H5VL_object_t *vol_obj = NULL; + herr_t ret_value = SUCCEED; + + FUNC_ENTER_NOAPI_NOINIT + + /* get the driver pointer */ + if(NULL == (vol_obj = (H5VL_object_t *)H5VL_get_object(obj_id))) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "invalid ID") + + /* free object */ + if(H5VL_free_object(vol_obj) < 0) + HGOTO_ERROR(H5E_FILE, H5E_CANTDEC, FAIL, "unable to free VOL object") + +done: + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5VL_native_unregister() */ + + +/*------------------------------------------------------------------------- + * Function: H5VL_native_attr_create + * + * Purpose: Creates an attribute on an object. + * + * Return: Success: attr id. + * Failure: NULL + * + *------------------------------------------------------------------------- + */ +static void * +H5VL_native_attr_create(void *obj, H5VL_loc_params_t loc_params, const char *attr_name, hid_t acpl_id, + hid_t H5_ATTR_UNUSED aapl_id, hid_t H5_ATTR_UNUSED dxpl_id, void H5_ATTR_UNUSED **req) +{ + H5G_loc_t loc; /* Object location */ + H5G_loc_t obj_loc; /* Location used to open group */ + hbool_t loc_found = FALSE; + H5P_genplist_t *plist; /* Property list pointer */ + hid_t type_id, space_id; + H5T_t *type, *dt; /* Datatype to use for attribute */ + H5S_t *space; /* Dataspace to use for attribute */ + H5A_t *attr = NULL; + void *ret_value = NULL; + + FUNC_ENTER_NOAPI_NOINIT + + /* Get the plist structure */ + if(NULL == (plist = (H5P_genplist_t *)H5I_object(acpl_id))) + HGOTO_ERROR(H5E_ATOM, H5E_BADATOM, NULL, "can't find object for ID") + + /* get creation properties */ + if(H5P_get(plist, H5VL_PROP_ATTR_TYPE_ID, &type_id) < 0) + HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, NULL, "can't get property value for datatype id") + if(H5P_get(plist, H5VL_PROP_ATTR_SPACE_ID, &space_id) < 0) + HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, NULL, "can't get property value for space id") + + if(H5G_loc_real(obj, loc_params.obj_type, &loc) < 0) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, NULL, "not a file or file object") + if(0 == (H5F_INTENT(loc.oloc->file) & H5F_ACC_RDWR)) + HGOTO_ERROR(H5E_ARGS, H5E_WRITEERROR, NULL, "no write intent on file") + + if(NULL == (dt = (H5T_t *)H5I_object_verify(type_id, H5I_DATATYPE))) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, NULL, "not a datatype") + /* If this is a named datatype, get the driver pointer to the datatype */ + type = H5T_get_actual_type(dt); + + if(NULL == (space = (H5S_t *)H5I_object_verify(space_id, H5I_DATASPACE))) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, NULL, "not a data space") + + if(loc_params.type == H5VL_OBJECT_BY_SELF) { + /* H5Acreate */ + /* Go do the real work for attaching the attribute to the dataset */ + if(NULL == (attr = H5A__create(&loc, attr_name, type, space, acpl_id))) + HGOTO_ERROR(H5E_ATTR, H5E_CANTINIT, NULL, "unable to create attribute") + } + else if(loc_params.type == H5VL_OBJECT_BY_NAME) { + /* H5Acreate_by_name */ + if(NULL == (attr = H5A__create_by_name(&loc, loc_params.loc_data.loc_by_name.name, attr_name, type, space, acpl_id))) + HGOTO_ERROR(H5E_ATTR, H5E_CANTINIT, NULL, "unable to create attribute") + } + else { + HGOTO_ERROR(H5E_VOL, H5E_UNSUPPORTED, NULL, "unknown attribute create parameters") + } + ret_value = (void *)attr; + +done: + /* Release resources */ + if(loc_found && H5G_loc_free(&obj_loc) < 0) + HDONE_ERROR(H5E_ATTR, H5E_CANTRELEASE, NULL, "can't free location") + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5VL_native_attr_create() */ + + +/*------------------------------------------------------------------------- + * Function: H5VL_native_attr_open + * + * Purpose: Opens a attr inside a native h5 file. + * + * Return: Success: attr id. + * Failure: NULL + * + * Programmer: Mohamad Chaarawi + * March, 2012 + * + *------------------------------------------------------------------------- + */ +static void * +H5VL_native_attr_open(void *obj, H5VL_loc_params_t loc_params, const char *attr_name, + hid_t H5_ATTR_UNUSED aapl_id, hid_t H5_ATTR_UNUSED dxpl_id, void H5_ATTR_UNUSED **req) +{ + H5G_loc_t loc; /* Object location */ + H5A_t *attr = NULL; /* Attribute opened */ + void *ret_value; + + FUNC_ENTER_NOAPI_NOINIT + + /* check arguments */ + if(H5G_loc_real(obj, loc_params.obj_type, &loc) < 0) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, NULL, "not a file or file object") + + if(loc_params.type == H5VL_OBJECT_BY_SELF) { + /* H5Aopen */ + /* Open the attribute */ + if(NULL == (attr = H5A__open(&loc, attr_name))) + HGOTO_ERROR(H5E_ATTR, H5E_CANTOPENOBJ, NULL, "unable to open attribute: '%s'", attr_name) + } + else if(loc_params.type == H5VL_OBJECT_BY_NAME) { + /* H5Aopen_by_name */ + /* Open the attribute on the object header */ + if(NULL == (attr = H5A__open_by_name(&loc, loc_params.loc_data.loc_by_name.name, attr_name))) + HGOTO_ERROR(H5E_ATTR, H5E_CANTOPENOBJ, NULL, "can't open attribute") + } + else if(loc_params.type == H5VL_OBJECT_BY_IDX) { + /* H5Aopen_by_idx */ + /* Open the attribute in the object header */ + if(NULL == (attr = H5A__open_by_idx(&loc, loc_params.loc_data.loc_by_idx.name, + loc_params.loc_data.loc_by_idx.idx_type, + loc_params.loc_data.loc_by_idx.order, + loc_params.loc_data.loc_by_idx.n))) + HGOTO_ERROR(H5E_ATTR, H5E_CANTOPENOBJ, NULL, "unable to open attribute") + } + else { + HGOTO_ERROR(H5E_VOL, H5E_UNSUPPORTED, NULL, "unknown attribute open parameters") + } + + ret_value = (void *)attr; + +done: + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5VL_native_attr_open() */ + + +/*------------------------------------------------------------------------- + * Function: H5VL_native_attr_read + * + * Purpose: Reads in data from attribute. + * + * Non-negative on success/Negative on failure + * + * Programmer: Mohamad Chaarawi + * March, 2012 + * + *------------------------------------------------------------------------- + */ +static herr_t +H5VL_native_attr_read(void *attr, hid_t dtype_id, void *buf, hid_t H5_ATTR_UNUSED dxpl_id, void H5_ATTR_UNUSED **req) +{ + H5T_t *mem_type; /* Memory datatype */ + herr_t ret_value; /* Return value */ + + FUNC_ENTER_NOAPI_NOINIT + + if(NULL == (mem_type = (H5T_t *)H5I_object_verify(dtype_id, H5I_DATATYPE))) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a datatype") + /* Go write the actual data to the attribute */ + if((ret_value = H5A__read((H5A_t*)attr, mem_type, buf)) < 0) + HGOTO_ERROR(H5E_ATTR, H5E_READERROR, FAIL, "unable to read attribute") + +done: + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5VL_native_attr_read() */ + + +/*------------------------------------------------------------------------- + * Function: H5VL_native_attr_write + * + * Purpose: Writes out data to attribute. + * + * Non-negative on success/Negative on failure + * + * Programmer: Mohamad Chaarawi + * March, 2012 + * + *------------------------------------------------------------------------- + */ +static herr_t +H5VL_native_attr_write(void *attr, hid_t dtype_id, const void *buf, hid_t H5_ATTR_UNUSED dxpl_id, void H5_ATTR_UNUSED **req) +{ + H5T_t *mem_type; /* Memory datatype */ + herr_t ret_value; /* Return value */ + + FUNC_ENTER_NOAPI_NOINIT + + if(NULL == (mem_type = (H5T_t *)H5I_object_verify(dtype_id, H5I_DATATYPE))) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a datatype") + /* Go write the actual data to the attribute */ + if((ret_value = H5A__write((H5A_t*)attr, mem_type, buf)) < 0) + HGOTO_ERROR(H5E_ATTR, H5E_WRITEERROR, FAIL, "unable to write attribute") + +done: + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5VL_native_attr_write() */ + + +/*------------------------------------------------------------------------- + * Function: H5VL_native_attr_get + * + * Purpose: Gets certain information about an attribute + * + * Return: Success: 0 + * Failure: -1 + * + * Programmer: Mohamad Chaarawi + * March, 2012 + * + *------------------------------------------------------------------------- + */ +static herr_t +H5VL_native_attr_get(void *obj, H5VL_attr_get_t get_type, hid_t H5_ATTR_UNUSED dxpl_id, void H5_ATTR_UNUSED **req, va_list arguments) +{ + herr_t ret_value = SUCCEED; /* Return value */ + + FUNC_ENTER_NOAPI_NOINIT + + switch(get_type) { + /* H5Aget_space */ + case H5VL_ATTR_GET_SPACE: + { + hid_t *ret_id = va_arg(arguments, hid_t *); + H5A_t *attr = (H5A_t *)obj; + + if((*ret_id = H5A_get_space(attr)) < 0) + HGOTO_ERROR(H5E_ARGS, H5E_CANTGET, FAIL, "can't get space ID of attribute") + break; + } + /* H5Aget_type */ + case H5VL_ATTR_GET_TYPE: + { + hid_t *ret_id = va_arg(arguments, hid_t *); + H5A_t *attr = (H5A_t *)obj; + + if((*ret_id = H5A__get_type(attr)) < 0) + HGOTO_ERROR(H5E_ARGS, H5E_CANTGET, FAIL, "can't get datatype ID of attribute") + break; + } + /* H5Aget_create_plist */ + case H5VL_ATTR_GET_ACPL: + { + hid_t *ret_id = va_arg(arguments, hid_t *); + H5A_t *attr = (H5A_t *)obj; + + if((*ret_id = H5A__get_create_plist(attr)) < 0) + HGOTO_ERROR(H5E_ARGS, H5E_CANTGET, FAIL, "can't get creation property list for attr") + + break; + } + /* H5Aget_name */ + case H5VL_ATTR_GET_NAME: + { + H5VL_loc_params_t loc_params = va_arg(arguments, H5VL_loc_params_t); + size_t buf_size = va_arg(arguments, size_t); + char *buf = va_arg(arguments, char *); + ssize_t *ret_val = va_arg(arguments, ssize_t *); + H5A_t *attr = NULL; + + if(H5VL_OBJECT_BY_SELF == loc_params.type) { + attr = (H5A_t *)obj; + /* Call private function in turn */ + if(0 > (*ret_val = H5A__get_name(attr, buf_size, buf))) + HGOTO_ERROR(H5E_ATTR, H5E_CANTGET, FAIL, "can't get attribute name") + } + else if(H5VL_OBJECT_BY_IDX == loc_params.type) { + H5G_loc_t loc; + + /* check arguments */ + if(H5G_loc_real(obj, loc_params.obj_type, &loc) < 0) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a file or file object") + + /* Open the attribute on the object header */ + if(NULL == (attr = H5A__open_by_idx(&loc, loc_params.loc_data.loc_by_idx.name, + loc_params.loc_data.loc_by_idx.idx_type, + loc_params.loc_data.loc_by_idx.order, + loc_params.loc_data.loc_by_idx.n))) + HGOTO_ERROR(H5E_ATTR, H5E_CANTOPENOBJ, FAIL, "can't open attribute") + + /* Get the length of the name */ + *ret_val = (ssize_t)HDstrlen(attr->shared->name); + + /* Copy the name into the user's buffer, if given */ + if(buf) { + HDstrncpy(buf, attr->shared->name, MIN((size_t)(*ret_val + 1), buf_size)); + if((size_t)(*ret_val) >= buf_size) + buf[buf_size - 1]='\0'; + } /* end if */ + + /* Release resources */ + if(attr && H5A__close(attr) < 0) + HDONE_ERROR(H5E_ATTR, H5E_CANTFREE, FAIL, "can't close attribute") + } + else + HGOTO_ERROR(H5E_SYM, H5E_CANTGET, FAIL, "can't get name of attr") + + break; + } + /* H5Aget_info */ + case H5VL_ATTR_GET_INFO: + { + H5VL_loc_params_t loc_params = va_arg(arguments, H5VL_loc_params_t); + H5A_info_t *ainfo = va_arg(arguments, H5A_info_t *); + H5A_t *attr = NULL; + + if(H5VL_OBJECT_BY_SELF == loc_params.type) { + attr = (H5A_t *)obj; + if(H5A__get_info(attr, ainfo) < 0) + HGOTO_ERROR(H5E_ARGS, H5E_CANTGET, FAIL, "can't get attribute info") + } + else if(H5VL_OBJECT_BY_NAME == loc_params.type) { + char *attr_name = va_arg(arguments, char *); + H5G_loc_t loc; + + /* check arguments */ + if(H5G_loc_real(obj, loc_params.obj_type, &loc) < 0) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a file or file object") + + /* Open the attribute on the object header */ + if(NULL == (attr = H5A__open_by_name(&loc, loc_params.loc_data.loc_by_name.name, + attr_name))) + HGOTO_ERROR(H5E_ATTR, H5E_CANTOPENOBJ, FAIL, "can't open attribute") + + /* Get the attribute information */ + if(H5A__get_info(attr, ainfo) < 0) + HGOTO_ERROR(H5E_ATTR, H5E_CANTGET, FAIL, "unable to get attribute info") + + /* Release resources */ + if(attr && H5A__close(attr) < 0) + HDONE_ERROR(H5E_ATTR, H5E_CANTFREE, FAIL, "can't close attribute") + } + else if(H5VL_OBJECT_BY_IDX == loc_params.type) { + H5G_loc_t loc; + + /* check arguments */ + if(H5G_loc_real(obj, loc_params.obj_type, &loc) < 0) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a file or file object") + + /* Open the attribute on the object header */ + if(NULL == (attr = H5A__open_by_idx(&loc, loc_params.loc_data.loc_by_idx.name, + loc_params.loc_data.loc_by_idx.idx_type, + loc_params.loc_data.loc_by_idx.order, + loc_params.loc_data.loc_by_idx.n))) + HGOTO_ERROR(H5E_ATTR, H5E_CANTOPENOBJ, FAIL, "can't open attribute") + + /* Get the attribute information */ + if(H5A__get_info(attr, ainfo) < 0) + HGOTO_ERROR(H5E_ATTR, H5E_CANTGET, FAIL, "unable to get attribute info") + + /* Release resources */ + if(attr && H5A__close(attr) < 0) + HDONE_ERROR(H5E_ATTR, H5E_CANTFREE, FAIL, "can't close attribute") + } + else + HGOTO_ERROR(H5E_SYM, H5E_CANTGET, FAIL, "can't get name of attr") + + break; + } + case H5VL_ATTR_GET_STORAGE_SIZE: + { + hsize_t *ret = va_arg(arguments, hsize_t *); + H5A_t *attr = (H5A_t *)obj; + + /* Set return value */ + *ret = attr->shared->data_size; + break; + } + default: + HGOTO_ERROR(H5E_VOL, H5E_CANTGET, FAIL, "can't get this type of information from attr") + } + +done: + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5VL_native_attr_get() */ + + +/*------------------------------------------------------------------------- + * Function: H5VL_native_attr_specific + * + * Purpose: Specific operations for attributes + * + * Return: Success: 0 + * Failure: -1 + * + * Programmer: Mohamad Chaarawi + * August, 2014 + * + *------------------------------------------------------------------------- + */ +static herr_t +H5VL_native_attr_specific(void *obj, H5VL_loc_params_t loc_params, H5VL_attr_specific_t specific_type, + hid_t H5_ATTR_UNUSED dxpl_id, void H5_ATTR_UNUSED **req, va_list arguments) +{ + H5G_loc_t loc; + herr_t ret_value = SUCCEED; /* Return value */ + + FUNC_ENTER_NOAPI_NOINIT + + /* Get location for passed-in object */ + if(H5G_loc_real(obj, loc_params.obj_type, &loc) < 0) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a file or file object") + /* XXX: Do I need to clean this up? */ + + switch(specific_type) { + case H5VL_ATTR_DELETE: + { + char *attr_name = va_arg(arguments, char *); + + if(H5VL_OBJECT_BY_SELF == loc_params.type) { + /* H5Adelete */ + /* Delete the attribute from the location */ + if(H5O__attr_remove(loc.oloc, attr_name) < 0) + HGOTO_ERROR(H5E_ATTR, H5E_CANTDELETE, FAIL, "unable to delete attribute") + } + else if(H5VL_OBJECT_BY_NAME == loc_params.type) { + /* H5Adelete_by_name */ + /* Delete the attribute */ + if(H5A__delete_by_name(&loc, loc_params.loc_data.loc_by_name.name, attr_name) < 0) + HGOTO_ERROR(H5E_ATTR, H5E_CANTDELETE, FAIL, "unable to delete attribute") + } + else if(H5VL_OBJECT_BY_IDX == loc_params.type) { + /* H5Adelete_by_idx */ + /* Delete the attribute from the location */ + if(H5A__delete_by_idx(&loc, loc_params.loc_data.loc_by_idx.name, loc_params.loc_data.loc_by_idx.idx_type, + loc_params.loc_data.loc_by_idx.order, loc_params.loc_data.loc_by_idx.n) < 0) + HGOTO_ERROR(H5E_ATTR, H5E_CANTDELETE, FAIL, "unable to delete attribute") + } + else + HGOTO_ERROR(H5E_VOL, H5E_UNSUPPORTED, FAIL, "unknown attribute remove parameters") + break; + } + case H5VL_ATTR_EXISTS: + { + const char *attr_name = va_arg(arguments, const char *); + htri_t *ret = va_arg(arguments, htri_t *); + + if(loc_params.type == H5VL_OBJECT_BY_SELF) { /* H5Aexists */ + /* Check if the attribute exists */ + if((*ret = H5O__attr_exists(loc.oloc, attr_name)) < 0) + HGOTO_ERROR(H5E_ATTR, H5E_CANTGET, FAIL, "unable to determine if attribute exists") + } + else if(loc_params.type == H5VL_OBJECT_BY_NAME) { /* H5Aexists_by_name */ + /* Check if the attribute exists */ + if((*ret = H5A__exists_by_name(loc, loc_params.loc_data.loc_by_name.name, attr_name)) < 0) + HGOTO_ERROR(H5E_ATTR, H5E_CANTGET, FAIL, "unable to determine if attribute exists") + } + else + HGOTO_ERROR(H5E_VOL, H5E_UNSUPPORTED, FAIL, "unknown parameters") + break; + } + case H5VL_ATTR_ITER: + { + H5_index_t idx_type = va_arg(arguments, H5_index_t); + H5_iter_order_t order = va_arg(arguments, H5_iter_order_t); + hsize_t *idx = va_arg(arguments, hsize_t *); + H5A_operator2_t op = va_arg(arguments, H5A_operator2_t); + void *op_data = va_arg(arguments, void *); + + if(loc_params.type == H5VL_OBJECT_BY_SELF) { /* H5Aiterate2 */ + + /* Iterate over attributes */ + if((ret_value = H5A__iterate(&loc, ".", idx_type, order, idx, op, op_data)) < 0) + HGOTO_ERROR(H5E_ATTR, H5E_BADITER, FAIL, "error iterating over attributes") + } + else if(loc_params.type == H5VL_OBJECT_BY_NAME) { /* H5Aiterate_by_name */ + + /* Iterate over attributes by name */ + if((ret_value = H5A__iterate(&loc, loc_params.loc_data.loc_by_name.name, idx_type, order, idx, op, op_data)) < 0) + HGOTO_ERROR(H5E_ATTR, H5E_BADITER, FAIL, "attribute iteration failed"); + } + else + HGOTO_ERROR(H5E_VOL, H5E_UNSUPPORTED, FAIL, "unknown parameters") + break; + } + /* H5Arename/rename_by_name */ + case H5VL_ATTR_RENAME: + { + const char *old_name = va_arg(arguments, const char *); + const char *new_name = va_arg(arguments, const char *); + + if(loc_params.type == H5VL_OBJECT_BY_SELF) { /* H5Arename */ + /* Call attribute rename routine */ + if(H5O__attr_rename(loc.oloc, old_name, new_name) < 0) + HGOTO_ERROR(H5E_ATTR, H5E_CANTRENAME, FAIL, "can't rename attribute") + } + else if(loc_params.type == H5VL_OBJECT_BY_NAME) { /* H5Arename_by_name */ + /* Call attribute rename routine */ + if(H5A__rename_by_name(loc, loc_params.loc_data.loc_by_name.name, old_name, new_name) < 0) + HGOTO_ERROR(H5E_ATTR, H5E_CANTRENAME, FAIL, "can't rename attribute") + } + else + HGOTO_ERROR(H5E_VOL, H5E_UNSUPPORTED, FAIL, "unknown attribute rename parameters") + break; + } + default: + HGOTO_ERROR(H5E_VOL, H5E_UNSUPPORTED, FAIL, "invalid specific operation") + } +done: + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5VL_native_attr_specific() */ + + +/*------------------------------------------------------------------------- + * Function: H5VL_native_attr_close + * + * Purpose: Closes an attribute. + * + * Return: Success: 0 + * Failure: -1, attr not closed. + * + * Programmer: Mohamad Chaarawi + * March, 2012 + * + *------------------------------------------------------------------------- + */ +static herr_t +H5VL_native_attr_close(void *attr, hid_t H5_ATTR_UNUSED dxpl_id, void H5_ATTR_UNUSED **req) +{ + herr_t ret_value = SUCCEED; /* Return value */ + + FUNC_ENTER_NOAPI_NOINIT + + if(H5A__close((H5A_t*)attr) < 0) + HGOTO_ERROR(H5E_SYM, H5E_CANTDEC, FAIL, "can't close attribute") + +done: + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5VL_native_attr_close() */ + + +/*------------------------------------------------------------------------- + * Function: H5VL_native_dataset_create + * + * Purpose: Creates a dataset in a native HDF5 file + * + * Return: Success: Pointer to a dataset struct + * Failure: NULL + * + *------------------------------------------------------------------------- + */ +static void * +H5VL_native_dataset_create(void *obj, H5VL_loc_params_t loc_params, const char *name, hid_t dcpl_id, + hid_t dapl_id, hid_t H5_ATTR_UNUSED dxpl_id, void H5_ATTR_UNUSED **req) +{ + H5P_genplist_t *plist; /* Property list pointer */ + H5G_loc_t loc; /* Object location to insert dataset into */ + hid_t type_id = H5I_INVALID_HID; + hid_t space_id = H5I_INVALID_HID; + hid_t lcpl_id = H5I_INVALID_HID; + H5D_t *dset = NULL; /* New dataset's info */ + const H5S_t *space; /* Dataspace for dataset */ + void *ret_value; + + FUNC_ENTER_NOAPI_NOINIT + + /* Get the plist structure */ + if(NULL == (plist = (H5P_genplist_t *)H5I_object(dcpl_id))) + HGOTO_ERROR(H5E_ATOM, H5E_BADATOM, NULL, "can't find object for ID") + + /* Get creation properties */ + if(H5P_get(plist, H5VL_PROP_DSET_TYPE_ID, &type_id) < 0) + HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, NULL, "can't get property value for datatype id") + if(H5P_get(plist, H5VL_PROP_DSET_SPACE_ID, &space_id) < 0) + HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, NULL, "can't get property value for space id") + if(H5P_get(plist, H5VL_PROP_DSET_LCPL_ID, &lcpl_id) < 0) + HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, NULL, "can't get property value for lcpl id") + + /* Check arguments */ + if(H5G_loc_real(obj, loc_params.obj_type, &loc) < 0) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, NULL, "not a file or file object") + if(H5I_DATATYPE != H5I_get_type(type_id)) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, NULL, "not a datatype ID") + if(NULL == (space = (const H5S_t *)H5I_object_verify(space_id, H5I_DATASPACE))) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, NULL, "not a dataspace ID") + + /* H5Dcreate_anon */ + if(NULL == name) { + /* build and open the new dataset */ + if(NULL == (dset = H5D__create(loc.oloc->file, type_id, space, dcpl_id, dapl_id))) + HGOTO_ERROR(H5E_DATASET, H5E_CANTINIT, NULL, "unable to create dataset") + } + /* H5Dcreate2 */ + else { + /* Create the new dataset & get its ID */ + if(NULL == (dset = H5D__create_named(&loc, name, type_id, space, lcpl_id, + dcpl_id, dapl_id))) + HGOTO_ERROR(H5E_DATASET, H5E_CANTINIT, NULL, "unable to create dataset") + } + ret_value = (void *)dset; + +done: + if(NULL == name) { + /* Release the dataset's object header, if it was created */ + if(dset) { + H5O_loc_t *oloc; /* Object location for dataset */ + + /* Get the new dataset's object location */ + if(NULL == (oloc = H5D_oloc(dset))) + HDONE_ERROR(H5E_DATASET, H5E_CANTGET, NULL, "unable to get object location of dataset") + + /* Decrement refcount on dataset's object header in memory */ + if(H5O_dec_rc_by_loc(oloc) < 0) + HDONE_ERROR(H5E_DATASET, H5E_CANTDEC, NULL, "unable to decrement refcount on newly created object") + } + } + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5VL_native_dataset_create() */ + + +/*------------------------------------------------------------------------- + * Function: H5VL_native_dataset_open + * + * Purpose: Opens a dataset in a native HDF5 file. + * + * Return: Success: Pointer to a dataset struct + * Failure: NULL + * + *------------------------------------------------------------------------- + */ +static void * +H5VL_native_dataset_open(void *obj, H5VL_loc_params_t loc_params, const char *name, + hid_t dapl_id, hid_t H5_ATTR_UNUSED dxpl_id, void H5_ATTR_UNUSED **req) +{ + H5D_t *dset = NULL; + H5G_loc_t loc; /* Object location of group */ + void *ret_value = NULL; + + FUNC_ENTER_NOAPI_NOINIT + + if(H5G_loc_real(obj, loc_params.obj_type, &loc) < 0) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, NULL, "not a file or file object") + + /* Open the dataset */ + if(NULL == (dset = H5D__open_name(&loc, name, dapl_id))) + HGOTO_ERROR(H5E_DATASET, H5E_CANTOPENOBJ, NULL, "unable to open dataset") + + ret_value = (void *)dset; + +done: + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5VL_native_dataset_open() */ + + +/*------------------------------------------------------------------------- + * Function: H5VL_native_dataset_read + * + * Purpose: Reads raw data from a dataset into a buffer. + * + * Return: SUCCEED/FAIL + * + *------------------------------------------------------------------------- + */ +static herr_t +H5VL_native_dataset_read(void *obj, hid_t mem_type_id, hid_t mem_space_id, + hid_t file_space_id, hid_t H5_ATTR_UNUSED dxpl_id, void *buf, void H5_ATTR_UNUSED **req) +{ + H5D_t *dset = (H5D_t *)obj; + const H5S_t *mem_space = NULL; + const H5S_t *file_space = NULL; + herr_t ret_value = SUCCEED; /* Return value */ + + FUNC_ENTER_NOAPI_NOINIT + + /* Check arguments */ + if(NULL == dset->oloc.file) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "dataset is not associated with a file") + + /* Get validated dataspace pointers */ + if(H5S_get_validated_dataspace(mem_space_id, &mem_space) < 0) + HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "could not get a validated dataspace from mem_space_id") + if(H5S_get_validated_dataspace(file_space_id, &file_space) < 0) + HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "could not get a validated dataspace from file_space_id") + + /* Read raw data */ + if(H5D__read(dset, mem_type_id, mem_space, file_space, buf/*out*/) < 0) + HGOTO_ERROR(H5E_DATASET, H5E_READERROR, FAIL, "can't read data") + +done: + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5VL_native_dataset_read() */ + + +/*------------------------------------------------------------------------- + * Function: H5VL_native_dataset_write + * + * Purpose: Writes raw data from a buffer into a dataset. + * + * Return: SUCCEED/FAIL + * + *------------------------------------------------------------------------- + */ +static herr_t +H5VL_native_dataset_write(void *obj, hid_t mem_type_id, hid_t mem_space_id, + hid_t file_space_id, hid_t H5_ATTR_UNUSED dxpl_id, const void *buf, void H5_ATTR_UNUSED **req) +{ + H5D_t *dset = (H5D_t *)obj; + const H5S_t *mem_space = NULL; + const H5S_t *file_space = NULL; + herr_t ret_value = SUCCEED; /* Return value */ + + FUNC_ENTER_NOAPI_NOINIT + + /* check arguments */ + if(NULL == dset->oloc.file) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "dataset is not associated with a file") + + /* Get validated dataspace pointers */ + if(H5S_get_validated_dataspace(mem_space_id, &mem_space) < 0) + HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "could not get a validated dataspace from mem_space_id") + if(H5S_get_validated_dataspace(file_space_id, &file_space) < 0) + HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "could not get a validated dataspace from file_space_id") + + /* Write the data */ + if(H5D__write(dset, mem_type_id, mem_space, file_space, buf) < 0) + HGOTO_ERROR(H5E_DATASET, H5E_WRITEERROR, FAIL, "can't write data") + +done: + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5VL_native_dataset_write() */ + + +/*------------------------------------------------------------------------- + * Function: H5VL_native_dataset_get + * + * Purpose: Gets certain information about a dataset + * + * Return: SUCCEED/FAIL + * + *------------------------------------------------------------------------- + */ +static herr_t +H5VL_native_dataset_get(void *obj, H5VL_dataset_get_t get_type, hid_t H5_ATTR_UNUSED dxpl_id, + void H5_ATTR_UNUSED **req, va_list arguments) +{ + H5D_t *dset = (H5D_t *)obj; + herr_t ret_value = SUCCEED; /* Return value */ + + FUNC_ENTER_NOAPI_NOINIT + + switch(get_type) { + /* H5Dget_space */ + case H5VL_DATASET_GET_SPACE: + { + hid_t *ret_id = va_arg(arguments, hid_t *); + + if((*ret_id = H5D__get_space(dset)) < 0) + HGOTO_ERROR(H5E_ARGS, H5E_CANTGET, FAIL, "can't get space ID of dataset") + + break; + } + /* H5Dget_space_statuc */ + case H5VL_DATASET_GET_SPACE_STATUS: + { + H5D_space_status_t *allocation = va_arg(arguments, H5D_space_status_t *); + + /* Read data space address and return */ + if(H5D__get_space_status(dset, allocation) < 0) + HGOTO_ERROR(H5E_DATASET, H5E_CANTINIT, FAIL, "unable to get space status") + + break; + } + /* H5Dget_type */ + case H5VL_DATASET_GET_TYPE: + { + hid_t *ret_id = va_arg(arguments, hid_t *); + + if((*ret_id = H5D__get_type(dset)) < 0) + HGOTO_ERROR(H5E_ARGS, H5E_CANTGET, FAIL, "can't get datatype ID of dataset") + + break; + } + /* H5Dget_create_plist */ + case H5VL_DATASET_GET_DCPL: + { + hid_t *ret_id = va_arg(arguments, hid_t *); + + if((*ret_id = H5D_get_create_plist(dset)) < 0) + HGOTO_ERROR(H5E_ARGS, H5E_CANTGET, FAIL, "can't get creation property list for dataset") + + break; + } + /* H5Dget_access_plist */ + case H5VL_DATASET_GET_DAPL: + { + hid_t *ret_id = va_arg(arguments, hid_t *); + + if((*ret_id = H5D_get_access_plist(dset)) < 0) + HGOTO_ERROR(H5E_ARGS, H5E_CANTGET, FAIL, "can't get access property list for dataset") + + break; + } + /* H5Dget_storage_size */ + case H5VL_DATASET_GET_STORAGE_SIZE: + { + hsize_t *ret = va_arg(arguments, hsize_t *); + + /* Set return value */ + if(H5D__get_storage_size(dset, ret) < 0) + HGOTO_ERROR(H5E_DATASET, H5E_CANTGET, FAIL, "can't get size of dataset's storage") + break; + } + /* H5Dget_offset */ + case H5VL_DATASET_GET_OFFSET: + { + haddr_t *ret = va_arg(arguments, haddr_t *); + + /* Set return value */ + *ret = H5D__get_offset(dset); + if(!H5F_addr_defined(*ret)) + *ret = HADDR_UNDEF; + break; + } + default: + HGOTO_ERROR(H5E_VOL, H5E_CANTGET, FAIL, "can't get this type of information from dataset") + } + +done: + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5VL_native_dataset_get() */ + + +/*------------------------------------------------------------------------- + * Function: H5VL_native_dataset_specific + * + * Purpose: Specific operations for datasets + * + * Return: SUCCEED/FAIL + * + *------------------------------------------------------------------------- + */ +static herr_t +H5VL_native_dataset_specific(void *obj, H5VL_dataset_specific_t specific_type, + hid_t H5_ATTR_UNUSED dxpl_id, void H5_ATTR_UNUSED **req, va_list arguments) +{ + H5D_t *dset = (H5D_t *)obj; + herr_t ret_value = SUCCEED; /* Return value */ + + FUNC_ENTER_NOAPI_NOINIT + + switch(specific_type) { + /* H5Dspecific_space */ + case H5VL_DATASET_SET_EXTENT: + { + const hsize_t *size = va_arg(arguments, const hsize_t *); + + if(H5D__set_extent(dset, size) < 0) + HGOTO_ERROR(H5E_DATASET, H5E_CANTINIT, FAIL, "unable to set extent of dataset") + break; + } + case H5VL_DATASET_FLUSH: + { + hid_t dset_id = va_arg(arguments, hid_t); + + /* Flush the dataset */ + if(H5D__flush(dset, dset_id) < 0) + HGOTO_ERROR(H5E_DATASET, H5E_CANTFLUSH, FAIL, "unable to flush dataset") + + break; + } + case H5VL_DATASET_REFRESH: + { + hid_t dset_id = va_arg(arguments, hid_t); + + /* Refresh the dataset */ + if((H5D__refresh(dset_id, dset)) < 0) + HGOTO_ERROR(H5E_DATASET, H5E_CANTLOAD, FAIL, "unable to refresh dataset") + + break; + } + default: + HGOTO_ERROR(H5E_VOL, H5E_UNSUPPORTED, FAIL, "invalid specific operation") + } + +done: + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5VL_native_dataset_specific() */ + + +/*------------------------------------------------------------------------- + * Function: H5VL_native_dataset_optional + * + * Purpose: Perform a driver specific operation on a native dataset + * + * Return: SUCCEED/FAIL + * + *------------------------------------------------------------------------- + */ +static herr_t +H5VL_native_dataset_optional(void *obj, hid_t H5_ATTR_UNUSED dxpl_id, void H5_ATTR_UNUSED **req, va_list arguments) +{ + H5D_t *dset = NULL; /* Dataset */ + H5VL_dataset_optional_t optional_type = va_arg(arguments, H5VL_dataset_optional_t); + herr_t ret_value = SUCCEED; /* Return value */ + + FUNC_ENTER_NOAPI_NOINIT + + switch(optional_type) { + case H5VL_DATASET_FORMAT_CONVERT: + { + dset = (H5D_t *)obj; + + switch(dset->shared->layout.type) { + case H5D_CHUNKED: + /* Convert the chunk indexing type to version 1 B-tree if not */ + if(dset->shared->layout.u.chunk.idx_type != H5D_CHUNK_IDX_BTREE) + if((H5D__format_convert(dset)) < 0) + HGOTO_ERROR(H5E_DATASET, H5E_CANTLOAD, FAIL, "unable to downgrade chunk indexing type for dataset") + break; + + case H5D_CONTIGUOUS: + case H5D_COMPACT: + /* Downgrade the layout version to 3 if greater than 3 */ + if(dset->shared->layout.version > H5O_LAYOUT_VERSION_DEFAULT) + if((H5D__format_convert(dset)) < 0) + HGOTO_ERROR(H5E_DATASET, H5E_CANTLOAD, FAIL, "unable to downgrade layout version for dataset") + break; + + case H5D_VIRTUAL: + /* Nothing to do even though layout is version 4 */ + break; + + case H5D_LAYOUT_ERROR: + case H5D_NLAYOUTS: + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "invalid dataset layout type") + + default: + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "unknown dataset layout type") + } /* end switch */ + + break; + } + case H5VL_DATASET_GET_CHUNK_INDEX_TYPE: + { + H5D_chunk_index_t *idx_type = va_arg(arguments, H5D_chunk_index_t *); + + dset = (H5D_t *)obj; + + /* Make sure the dataset is chunked */ + if(H5D_CHUNKED != dset->shared->layout.type) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a chunked dataset") + + /* Get the chunk indexing type */ + *idx_type = dset->shared->layout.u.chunk.idx_type; + + break; + } + case H5VL_DATASET_GET_CHUNK_STORAGE_SIZE: + { + hsize_t *offset = va_arg(arguments, hsize_t *); + hsize_t *chunk_nbytes = va_arg(arguments, hsize_t *); + + dset = (H5D_t *)obj; + + /* Make sure the dataset is chunked */ + if(H5D_CHUNKED != dset->shared->layout.type) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a chunked dataset") + + /* Call private function */ + if(H5D__get_chunk_storage_size(dset, offset, chunk_nbytes) < 0) + HGOTO_ERROR(H5E_DATASET, H5E_CANTGET, FAIL, "can't get storage size of chunk") + + break; + } + case H5VL_DATASET_CHUNK_READ: + { + const hsize_t *offset = va_arg(arguments, hsize_t *); + uint32_t *filters = va_arg(arguments, uint32_t *); + void *buf = va_arg(arguments, void *); + hsize_t offset_copy[H5O_LAYOUT_NDIMS]; /* Internal copy of chunk offset */ + + dset = (H5D_t *)obj; + + /* Check arguments */ + if(NULL == dset->oloc.file) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "dataset is not associated with a file") + if(H5D_CHUNKED != dset->shared->layout.type) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a chunked dataset") + + /* Copy the user's offset array so we can be sure it's terminated properly. + * (we don't want to mess with the user's buffer). + */ + if(H5D__get_offset_copy(dset, offset, offset_copy) < 0) + HGOTO_ERROR(H5E_DATASET, H5E_CANTALLOC, FAIL, "failure to copy offset array") + + /* Read the raw chunk */ + if(H5D__chunk_direct_read(dset, offset_copy, filters, buf) < 0) + HGOTO_ERROR(H5E_DATASET, H5E_READERROR, FAIL, "can't read unprocessed chunk data") + + break; + } + case H5VL_DATASET_CHUNK_WRITE: + { + uint32_t filters = va_arg(arguments, uint32_t); + const hsize_t *offset = va_arg(arguments, const hsize_t *); + uint32_t data_size_32 = va_arg(arguments, uint32_t); + const void *buf = va_arg(arguments, const void *); + hsize_t offset_copy[H5O_LAYOUT_NDIMS]; /* Internal copy of chunk offset */ + + dset = (H5D_t *)obj; + + /* Check arguments */ + if(NULL == dset->oloc.file) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "dataset is not associated with a file") + if(H5D_CHUNKED != dset->shared->layout.type) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a chunked dataset") + + /* Copy the user's offset array so we can be sure it's terminated properly. + * (we don't want to mess with the user's buffer). + */ + if(H5D__get_offset_copy(dset, offset, offset_copy) < 0) + HGOTO_ERROR(H5E_DATASET, H5E_CANTALLOC, FAIL, "failure to copy offset array") + + /* Write chunk */ + if(H5D__chunk_direct_write(dset, filters, offset_copy, data_size_32, buf) < 0) + HGOTO_ERROR(H5E_DATASET, H5E_WRITEERROR, FAIL, "can't write unprocessed chunk data") + + break; + } + default: + HGOTO_ERROR(H5E_VOL, H5E_UNSUPPORTED, FAIL, "invalid optional operation") + } + +done: + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5VL_native_dataset_optional() */ + + +/*------------------------------------------------------------------------- + * Function: H5VL_native_dataset_close + * + * Purpose: Closes a dataset. + * + * Return: Success: SUCCEED + * Failure: FAIL (dataset will not be closed) + * + *------------------------------------------------------------------------- + */ +static herr_t +H5VL_native_dataset_close(void *dset, hid_t H5_ATTR_UNUSED dxpl_id, void H5_ATTR_UNUSED **req) +{ + herr_t ret_value = SUCCEED; /* Return value */ + + FUNC_ENTER_NOAPI_NOINIT + + if(H5D_close((H5D_t*)dset) < 0) + HGOTO_ERROR(H5E_DATASET, H5E_CANTDEC, FAIL, "can't close dataset") + +done: + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5VL_native_dataset_close() */ + + +/*------------------------------------------------------------------------- + * Function: H5VL_native_file_create + * + * Purpose: Creates a file as a native HDF5 file. + * + * Return: Success: A pointer to an H5F_t file struct + * + * Failure: NULL + * + *------------------------------------------------------------------------- + */ +static void * +H5VL_native_file_create(const char *name, unsigned flags, hid_t fcpl_id, hid_t fapl_id, + hid_t H5_ATTR_UNUSED dxpl_id, void H5_ATTR_UNUSED **req) +{ + H5F_t *new_file = NULL; + void *ret_value = NULL; + + FUNC_ENTER_NOAPI_NOINIT + + /* Adjust bit flags by turning on the creation bit and making sure that + * the EXCL or TRUNC bit is set. All newly-created files are opened for + * reading and writing. + */ + if(0 == (flags & (H5F_ACC_EXCL|H5F_ACC_TRUNC))) + flags |= H5F_ACC_EXCL; /*default*/ + flags |= H5F_ACC_RDWR | H5F_ACC_CREAT; + + /* Create the file */ + if(NULL == (new_file = H5F_open(name, flags, fcpl_id, fapl_id))) + HGOTO_ERROR(H5E_FILE, H5E_CANTOPENFILE, NULL, "unable to create file") + + new_file->id_exists = TRUE; + ret_value = (void *)new_file; + +done: + if(NULL == ret_value && new_file) + if(H5F__close(new_file) < 0) + HDONE_ERROR(H5E_FILE, H5E_CANTCLOSEFILE, NULL, "problems closing file") + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5VL_native_file_create() */ + + +/*------------------------------------------------------------------------- + * Function: H5VL_native_file_open + * + * Purpose: Opens a file as a native HDF5 file. + * + * Return: Success: A pointer to an H5F_t file struct + * + * Failure: NULL + * + *------------------------------------------------------------------------- + */ +static void * +H5VL_native_file_open(const char *name, unsigned flags, hid_t fapl_id, hid_t H5_ATTR_UNUSED dxpl_id, void H5_ATTR_UNUSED **req) +{ + H5F_t *new_file = NULL; + void *ret_value = NULL; + + FUNC_ENTER_NOAPI_NOINIT + + /* Open the file */ + if(NULL == (new_file = H5F_open(name, flags, H5P_FILE_CREATE_DEFAULT, fapl_id))) + HGOTO_ERROR(H5E_FILE, H5E_CANTOPENFILE, NULL, "unable to open file") + + new_file->id_exists = TRUE; + ret_value = (void *)new_file; + +done: + if(NULL == ret_value && new_file && H5F_try_close(new_file, NULL) < 0) + HDONE_ERROR(H5E_FILE, H5E_CANTCLOSEFILE, NULL, "problems closing file") + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5VL_native_file_open() */ + + +/*------------------------------------------------------------------------- + * Function: H5VL_native_file_get + * + * Purpose: Gets certain data about a file + * + * Return: SUCCEED/FAIL + * + *------------------------------------------------------------------------- + */ +static herr_t +H5VL_native_file_get(void *obj, H5VL_file_get_t get_type, hid_t H5_ATTR_UNUSED dxpl_id, void H5_ATTR_UNUSED **req, va_list arguments) +{ + H5F_t *f = NULL; /* File struct */ + herr_t ret_value = SUCCEED; /* Return value */ + + FUNC_ENTER_NOAPI_NOINIT + + switch(get_type) { + /* H5Fget_access_plist */ + case H5VL_FILE_GET_FAPL: + { + H5P_genplist_t *new_plist; /* New property list */ + hid_t *plist_id = va_arg(arguments, hid_t *); + + f = (H5F_t *)obj; + + /* Retrieve the file's access property list */ + if((*plist_id = H5F_get_access_plist(f, TRUE)) < 0) + HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, FAIL, "can't get file access property list") + + if(NULL == (new_plist = (H5P_genplist_t *)H5I_object(*plist_id))) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a property list") + break; + } + /* H5Fget_create_plist */ + case H5VL_FILE_GET_FCPL: + { + H5P_genplist_t *plist; /* Property list */ + hid_t *plist_id = va_arg(arguments, hid_t *); + + f = (H5F_t *)obj; + if(NULL == (plist = (H5P_genplist_t *)H5I_object(f->shared->fcpl_id))) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a property list") + + /* Create the property list object to return */ + if((*plist_id = H5P_copy_plist(plist, TRUE)) < 0) + HGOTO_ERROR(H5E_PLIST, H5E_CANTINIT, FAIL, "unable to copy file creation properties") + + break; + } + /* H5Fget_obj_count */ + case H5VL_FILE_GET_OBJ_COUNT: + { + unsigned types = va_arg(arguments, unsigned); + ssize_t *ret = va_arg(arguments, ssize_t *); + size_t obj_count = 0; /* Number of opened objects */ + + f = (H5F_t *)obj; + /* Perform the query */ + if(H5F_get_obj_count(f, types, TRUE, &obj_count) < 0) + HGOTO_ERROR(H5E_FILE, H5E_BADITER, FAIL, "H5F_get_obj_count failed") + + /* Set the return value */ + *ret = (ssize_t)obj_count; + break; + } + /* H5Fget_obj_ids */ + case H5VL_FILE_GET_OBJ_IDS: + { + unsigned types = va_arg(arguments, unsigned); + size_t max_objs = va_arg(arguments, size_t); + hid_t *oid_list = va_arg(arguments, hid_t *); + ssize_t *ret = va_arg(arguments, ssize_t *); + size_t obj_count = 0; /* Number of opened objects */ + + f = (H5F_t *)obj; + /* Perform the query */ + if(H5F_get_obj_ids(f, types, max_objs, oid_list, TRUE, &obj_count) < 0) + HGOTO_ERROR(H5E_FILE, H5E_BADITER, FAIL, "H5F_get_obj_ids failed") + + /* Set the return value */ + *ret = (ssize_t)obj_count; + break; + } + /* H5Fget_intent */ + case H5VL_FILE_GET_INTENT: + { + unsigned *intent_flags = va_arg(arguments, unsigned *); + + f = (H5F_t *)obj; + + /* HDF5 uses some flags internally that users don't know about. + * Simplify things for them so that they only get either H5F_ACC_RDWR + * or H5F_ACC_RDONLY and any SWMR flags. + */ + if(H5F_INTENT(f) & H5F_ACC_RDWR) { + *intent_flags = H5F_ACC_RDWR; + + /* Check for SWMR write access on the file */ + if(H5F_INTENT(f) & H5F_ACC_SWMR_WRITE) + *intent_flags |= H5F_ACC_SWMR_WRITE; + } + else { + *intent_flags = H5F_ACC_RDONLY; + + /* Check for SWMR read access on the file */ + if(H5F_INTENT(f) & H5F_ACC_SWMR_READ) + *intent_flags |= H5F_ACC_SWMR_READ; + } + + break; + } + /* H5Fget_name */ + case H5VL_FILE_GET_NAME: + { + H5I_type_t type = va_arg(arguments, H5I_type_t); + size_t size = va_arg(arguments, size_t); + char *name = va_arg(arguments, char *); + ssize_t *ret = va_arg(arguments, ssize_t *); + size_t len; + + if(NULL == (f = H5VL_native_get_file(obj, type))) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a file or file object") + + len = HDstrlen(H5F_OPEN_NAME(f)); + + if(name) { + HDstrncpy(name, H5F_OPEN_NAME(f), MIN(len + 1,size)); + if(len >= size) + name[size-1]='\0'; + } + + /* Set the return value for the API call */ + *ret = (ssize_t)len; + break; + } + /* H5Iget_file_id */ + case H5VL_OBJECT_GET_FILE: + { + H5I_type_t type = va_arg(arguments, H5I_type_t); + void **ret = va_arg(arguments, void **); + + if(NULL == (f = H5VL_native_get_file(obj, type))) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a file or file object") + f->id_exists = TRUE; + *ret = (void*)f; + break; + } + default: + HGOTO_ERROR(H5E_VOL, H5E_CANTGET, FAIL, "can't get this type of information") + } /* end switch */ +done: + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5VL_native_file_get() */ + + +/*------------------------------------------------------------------------- + * Function: H5VL_native_file_specific + * + * Purpose: Perform an operation + * + * Return: SUCCEED/FAIL + * + *------------------------------------------------------------------------- + */ +static herr_t +H5VL_native_file_specific(void *obj, H5VL_file_specific_t specific_type, hid_t H5_ATTR_UNUSED dxpl_id, + void H5_ATTR_UNUSED **req, va_list arguments) +{ + herr_t ret_value = SUCCEED; /* Return value */ + + FUNC_ENTER_NOAPI_NOINIT + + switch(specific_type) { + /* H5Fflush */ + case H5VL_FILE_FLUSH: + { + H5I_type_t type = va_arg(arguments, H5I_type_t); + H5F_scope_t scope = va_arg(arguments, H5F_scope_t); + H5F_t *f = NULL; /* File to flush */ + + /* Get the file for the object */ + if(NULL == (f = H5VL_native_get_file(obj, type))) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a file or file object") + + /* Nothing to do if the file is read only. This determination is + * made at the shared open(2) flags level, implying that opening a + * file twice, once for read-only and once for read-write, and then + * calling H5Fflush() with the read-only handle, still causes data + * to be flushed. + */ + if(H5F_ACC_RDWR & H5F_INTENT(f)) { + /* Flush other files, depending on scope */ + if(H5F_SCOPE_GLOBAL == scope) { + /* Call the flush routine for mounted file hierarchies */ + if(H5F_flush_mounts(f) < 0) + HGOTO_ERROR(H5E_FILE, H5E_CANTFLUSH, FAIL, "unable to flush mounted file hierarchy") + } + else { + /* Call the flush routine, for this file */ + if(H5F__flush(f) < 0) + HGOTO_ERROR(H5E_FILE, H5E_CANTFLUSH, FAIL, "unable to flush file's cached information") + } + } + break; + } + /* H5Fmount */ + case H5VL_FILE_MOUNT: + { + H5I_type_t type = va_arg(arguments, H5I_type_t); + const char *name = va_arg(arguments, const char *); + H5F_t *child = va_arg(arguments, H5F_t *); + hid_t plist_id = va_arg(arguments, hid_t); + H5G_loc_t loc; + + if(H5G_loc_real(obj, type, &loc) < 0) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a file or file object") + + /* Do the mount */ + if(H5F__mount(&loc, name, child, plist_id) < 0) + HGOTO_ERROR(H5E_FILE, H5E_MOUNT, FAIL, "unable to mount file") + + break; + } + /* H5Funmount */ + case H5VL_FILE_UNMOUNT: + { + H5I_type_t type = va_arg(arguments, H5I_type_t); + const char *name = va_arg(arguments, const char *); + H5G_loc_t loc; + + if(H5G_loc_real(obj, type, &loc) < 0) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a file or file object") + + /* Unmount */ + if(H5F__unmount(&loc, name) < 0) + HGOTO_ERROR(H5E_FILE, H5E_MOUNT, FAIL, "unable to unmount file") + + break; + } + /* H5Fis_accessible */ + case H5VL_FILE_IS_ACCESSIBLE: + { + hid_t fapl_id = va_arg(arguments, hid_t); + const char *name = va_arg(arguments, const char *); + htri_t *ret = va_arg(arguments, htri_t *); + + /* Call private routine */ + if((*ret = H5F__is_hdf5(name, fapl_id)) < 0) + HGOTO_ERROR(H5E_IO, H5E_CANTINIT, FAIL, "error in HDF5 file check") + break; + } + default: + HGOTO_ERROR(H5E_VOL, H5E_UNSUPPORTED, FAIL, "invalid specific operation") + } + +done: + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5VL_native_file_specific() */ + + +/*------------------------------------------------------------------------- + * Function: H5VL_native_file_optional + * + * Purpose: Perform a driver specific operation on a native file + * + * Return: SUCCEED/FAIL + * + *------------------------------------------------------------------------- + */ +static herr_t +H5VL_native_file_optional(void *obj, hid_t H5_ATTR_UNUSED dxpl_id, void H5_ATTR_UNUSED **req, va_list arguments) +{ + H5F_t *f = NULL; /* File */ + H5VL_file_optional_t optional_type = va_arg(arguments, H5VL_file_optional_t); + herr_t ret_value = SUCCEED; /* Return value */ + + FUNC_ENTER_NOAPI_NOINIT + + switch(optional_type) { + /* H5Fget_filesize */ + case H5VL_FILE_GET_SIZE: + { + haddr_t max_eof_eoa; /* Maximum of the EOA & EOF */ + haddr_t base_addr; /* Base address for the file */ + hsize_t *size = va_arg(arguments, hsize_t *); + + f = (H5F_t *)obj; + + /* Go get the actual file size */ + if(H5F__get_max_eof_eoa(f, &max_eof_eoa) < 0) + HGOTO_ERROR(H5E_FILE, H5E_CANTGET, FAIL, "file can't get max eof/eoa ") + + base_addr = H5FD_get_base_addr(f->shared->lf); + + if(size) + *size = (hsize_t)(max_eof_eoa + base_addr); /* Convert relative base address for file to absolute address */ + + break; + } + /* H5Fget_file_image */ + case H5VL_FILE_GET_FILE_IMAGE: + { + void *buf_ptr = va_arg(arguments, void *); + ssize_t *ret = va_arg(arguments, ssize_t *); + size_t buf_len = va_arg(arguments, size_t ); + + f = (H5F_t *)obj; + /* Do the actual work */ + if((*ret = H5F__get_file_image(f, buf_ptr, buf_len)) < 0) + HGOTO_ERROR(H5E_FILE, H5E_CANTGET, FAIL, "get file image failed") + break; + } + /* H5Fget_freespace */ + case H5VL_FILE_GET_FREE_SPACE: + { + hsize_t tot_space; /* Amount of free space in the file */ + hssize_t *ret = va_arg(arguments, hssize_t *); + + f = (H5F_t *)obj; + /* Go get the actual amount of free space in the file */ + if(H5MF_get_freespace(f, &tot_space, NULL) < 0) + HGOTO_ERROR(H5E_FILE, H5E_CANTGET, FAIL, "unable to check free space for file") + *ret = (hssize_t)tot_space; + break; + } + case H5VL_FILE_GET_FREE_SECTIONS: + { + H5F_sect_info_t *sect_info = va_arg(arguments, H5F_sect_info_t *); + ssize_t *ret = va_arg(arguments, ssize_t *); + H5F_mem_t type = va_arg(arguments, H5F_mem_t); + size_t nsects = va_arg(arguments, size_t); + + f = (H5F_t *)obj; + /* Go get the free-space section information in the file */ + if((*ret = H5MF_get_free_sections(f, type, nsects, sect_info)) < 0) + HGOTO_ERROR(H5E_FILE, H5E_CANTGET, FAIL, "unable to check free space for file") + break; + } + /* H5Fget_info2 */ + case H5VL_FILE_GET_INFO: + { + H5I_type_t type = va_arg(arguments, H5I_type_t); + H5F_info2_t *finfo = va_arg(arguments, H5F_info2_t *); + + /* Get the file struct. This call is careful to not return the file pointer + * for the top file in a mount hierarchy. + */ + if(NULL == (f = H5VL_native_get_file(obj, type))) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "could not get a file struct") + + /* Get the file info */ + if(H5F__get_info(f, finfo) < 0) + HGOTO_ERROR(H5E_FILE, H5E_CANTGET, FAIL, "unable to retrieve file info") + + break; + } + /* H5Fget_mdc_config */ + case H5VL_FILE_GET_MDC_CONF: + { + H5AC_cache_config_t *config_ptr = va_arg(arguments, H5AC_cache_config_t *); + + f = (H5F_t *)obj; + /* Go get the resize configuration */ + if(H5AC_get_cache_auto_resize_config(f->shared->cache, config_ptr) < 0) + HGOTO_ERROR(H5E_CACHE, H5E_SYSTEM, FAIL, "H5AC_get_cache_auto_resize_config() failed.") + break; + } + /* H5Fget_mdc_hit_rate */ + case H5VL_FILE_GET_MDC_HR: + { + double *hit_rate_ptr = va_arg(arguments, double *); + + f = (H5F_t *)obj; + /* Go get the current hit rate */ + if(H5AC_get_cache_hit_rate(f->shared->cache, hit_rate_ptr) < 0) + HGOTO_ERROR(H5E_CACHE, H5E_SYSTEM, FAIL, "H5AC_get_cache_hit_rate() failed.") + break; + } + /* H5Fget_mdc_size */ + case H5VL_FILE_GET_MDC_SIZE: + { + size_t *max_size_ptr = va_arg(arguments, size_t *); + size_t *min_clean_size_ptr = va_arg(arguments, size_t *); + size_t *cur_size_ptr = va_arg(arguments, size_t *); + int *cur_num_entries_ptr = va_arg(arguments, int *); + uint32_t cur_num_entries; + + f = (H5F_t *)obj; + /* Go get the size data */ + if(H5AC_get_cache_size(f->shared->cache, max_size_ptr, min_clean_size_ptr, + cur_size_ptr, &cur_num_entries) < 0) + HGOTO_ERROR(H5E_CACHE, H5E_SYSTEM, FAIL, "H5AC_get_cache_size() failed.") + + if(cur_num_entries_ptr != NULL) + *cur_num_entries_ptr = (int)cur_num_entries; + break; + } + /* H5Fget_vfd_handle */ + case H5VL_FILE_GET_VFD_HANDLE: + { + void **file_handle = va_arg(arguments, void **); + hid_t fapl_id = va_arg(arguments, hid_t); + + f = (H5F_t *)obj; + + /* Retrieve the VFD handle for the file */ + if(H5F_get_vfd_handle(f, fapl_id, file_handle) < 0) + HGOTO_ERROR(H5E_FILE, H5E_CANTGET, FAIL, "can't retrieve VFD handle") + break; + } + /* H5Fclear_elink_file_cache */ + case H5VL_FILE_CLEAR_ELINK_CACHE: + { + f = (H5F_t *)obj; + + /* Release the EFC */ + if(f->shared->efc) + if(H5F__efc_release(f->shared->efc) < 0) + HGOTO_ERROR(H5E_FILE, H5E_CANTRELEASE, FAIL, "can't release external file cache") + break; + } + /* H5Freopen */ + case H5VL_FILE_REOPEN: + { + void **ret = va_arg(arguments, void **); + H5F_t *new_file = NULL; + + f = (H5F_t *)obj; + + /* Reopen the file through the VOL driver */ + if(NULL == (new_file = H5F__reopen(f))) + HGOTO_ERROR(H5E_FILE, H5E_CANTINIT, FAIL, "unable to reopen file") + + new_file->id_exists = TRUE; + + *ret = (void *)new_file; + break; + } + /* H5Freset_mdc_hit_rate_stats */ + case H5VL_FILE_RESET_MDC_HIT_RATE: + { + f = (H5F_t *)obj; + /* Reset the hit rate statistic */ + if(H5AC_reset_cache_hit_rate_stats(f->shared->cache) < 0) + HGOTO_ERROR(H5E_CACHE, H5E_SYSTEM, FAIL, "can't reset cache hit rate") + break; + } + case H5VL_FILE_SET_MDC_CONFIG: + { + H5AC_cache_config_t *config_ptr = va_arg(arguments, H5AC_cache_config_t *); + + f = (H5F_t *)obj; + /* set the resize configuration */ + if(H5AC_set_cache_auto_resize_config(f->shared->cache, config_ptr) < 0) + HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "H5AC_set_cache_auto_resize_config() failed") + break; + } + case H5VL_FILE_GET_METADATA_READ_RETRY_INFO: + { + H5F_retry_info_t *info = va_arg(arguments, H5F_retry_info_t *); + + f = (H5F_t *)obj; + + if(H5F_get_metadata_read_retry_info(f, info) < 0) + HGOTO_ERROR(H5E_CACHE, H5E_SYSTEM, FAIL, "can't get metadata read retry info") + + break; + } + case H5VL_FILE_START_SWMR_WRITE: + { + f = (H5F_t *)obj; + + if(H5F__start_swmr_write(f) < 0) + HGOTO_ERROR(H5E_CACHE, H5E_SYSTEM, FAIL, "can't start SWMR write") + + break; + } + case H5VL_FILE_START_MDC_LOGGING: + { + f = (H5F_t *)obj; + + /* Call mdc logging function */ + if(H5C_start_logging(f->shared->cache) < 0) + HGOTO_ERROR(H5E_FILE, H5E_LOGFAIL, FAIL, "unable to start mdc logging") + + break; + } + case H5VL_FILE_STOP_MDC_LOGGING: + { + f = (H5F_t *)obj; + + /* Call mdc logging function */ + if(H5C_stop_logging(f->shared->cache) < 0) + HGOTO_ERROR(H5E_FILE, H5E_LOGFAIL, FAIL, "unable to stop mdc logging") + + break; + } + case H5VL_FILE_GET_MDC_LOGGING_STATUS: + { + hbool_t *is_enabled = va_arg(arguments, hbool_t *); + hbool_t *is_currently_logging = va_arg(arguments, hbool_t *); + + f = (H5F_t *)obj; + + /* Call mdc logging function */ + if(H5C_get_logging_status(f->shared->cache, is_enabled, is_currently_logging) < 0) + HGOTO_ERROR(H5E_FILE, H5E_LOGFAIL, FAIL, "unable to get logging status") + + break; + } + case H5VL_FILE_SET_LATEST_FORMAT: + { + HGOTO_ERROR(H5E_VOL, H5E_UNSUPPORTED, FAIL, "invalid optional operation") + break; + } + case H5VL_FILE_FORMAT_CONVERT: + { + f = (H5F_t *)obj; + + /* Convert the format */ + if(H5F__format_convert(f) < 0) + HGOTO_ERROR(H5E_FILE, H5E_CANTCONVERT, FAIL, "can't convert file format") + + break; + } + case H5VL_FILE_RESET_PAGE_BUFFERING_STATS: + { + f = (H5F_t *)obj; + + /* Sanity check */ + if(NULL == f->shared->page_buf) + HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "page buffering not enabled on file") + + /* Reset the statistics */ + if (H5PB_reset_stats(f->shared->page_buf) < 0) + HGOTO_ERROR(H5E_FILE, H5E_CANTGET, FAIL, "can't reset stats for page buffering") + + break; + } + case H5VL_FILE_GET_PAGE_BUFFERING_STATS: + { + unsigned *accesses = va_arg(arguments, unsigned *); + unsigned *hits = va_arg(arguments, unsigned *); + unsigned *misses = va_arg(arguments, unsigned *); + unsigned *evictions = va_arg(arguments, unsigned *); + unsigned *bypasses = va_arg(arguments, unsigned *); + + f = (H5F_t *)obj; + + /* Sanity check */ + if(NULL == f->shared->page_buf) + HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "page buffering not enabled on file") + + /* Get the statistics */ + if(H5PB_get_stats(f->shared->page_buf, accesses, hits, misses, evictions, bypasses) < 0) + HGOTO_ERROR(H5E_FILE, H5E_CANTGET, FAIL, "can't retrieve stats for page buffering") + + break; + } + case H5VL_FILE_GET_MDC_IMAGE_INFO: + { + HGOTO_ERROR(H5E_VOL, H5E_UNSUPPORTED, FAIL, "invalid optional operation") + break; + } + + default: + HGOTO_ERROR(H5E_VOL, H5E_UNSUPPORTED, FAIL, "invalid optional operation") + } + +done: + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5VL_native_file_optional() */ + + +/*------------------------------------------------------------------------- + * Function: H5VL_native_file_close + * + * Purpose: Closes a file. + * + * Return: SUCCEED/FAIL (the file will not be closed on failure) + * + *------------------------------------------------------------------------- + */ +static herr_t +H5VL_native_file_close(void *file, hid_t H5_ATTR_UNUSED dxpl_id, void H5_ATTR_UNUSED **req) +{ + int nref; + H5F_t *f = (H5F_t *)file; + hid_t file_id = H5I_INVALID_HID; + herr_t ret_value = SUCCEED; /* Return value */ + + FUNC_ENTER_NOAPI_NOINIT + + /* This routine should only be called when a file ID's ref count drops to zero */ + HDassert(H5F_ID_EXISTS(f)); + + /* Flush file if this is the last reference to this id and we have write + * intent, unless it will be flushed by the "shared" file being closed. + * This is only necessary to replicate previous behaviour, and could be + * disabled by an option/property to improve performance. + */ + if((H5F_NREFS(f) > 1) && (H5F_INTENT(f) & H5F_ACC_RDWR)) { + /* Get the file ID corresponding to the H5F_t struct */ + if(H5I_find_id(f, H5I_FILE, &file_id) < 0 || H5I_INVALID_HID == file_id) + HGOTO_ERROR(H5E_ATOM, H5E_CANTGET, FAIL, "invalid atom") + /* Get the number of references outstanding for this file ID */ + if((nref = H5I_get_ref(file_id, FALSE)) < 0) + HGOTO_ERROR(H5E_ATOM, H5E_CANTGET, FAIL, "can't get ID ref count") + if(nref == 1) + if(H5F__flush(f) < 0) + HGOTO_ERROR(H5E_CACHE, H5E_CANTFLUSH, FAIL, "unable to flush cache") + } + + /* Close the file */ + if(H5F__close(f) < 0) + HGOTO_ERROR(H5E_FILE, H5E_CANTDEC, FAIL, "can't close file") + +done: + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5VL_native_file_close() */ + + +/*------------------------------------------------------------------------- + * Function: H5VL_native_group_create + * + * Purpose: Creates a group inside a native h5 file. + * + * Return: Success: Pointer to a group struct + * + * Failure: NULL + * + *------------------------------------------------------------------------- + */ +static void * +H5VL_native_group_create(void *obj, H5VL_loc_params_t loc_params, const char *name, hid_t gcpl_id, + hid_t H5_ATTR_UNUSED gapl_id, hid_t H5_ATTR_UNUSED dxpl_id, void H5_ATTR_UNUSED **req) +{ + H5P_genplist_t *plist; /* Property list pointer */ + H5G_loc_t loc; /* Location to create group */ + H5G_t *grp = NULL; /* New group created */ + hid_t lcpl_id; + void *ret_value; + + FUNC_ENTER_NOAPI_NOINIT + + /* Get the property list structure */ + if(NULL == (plist = (H5P_genplist_t *)H5I_object(gcpl_id))) + HGOTO_ERROR(H5E_ATOM, H5E_BADATOM, NULL, "can't find object for ID") + + /* Get creation properties */ + if(H5P_get(plist, H5VL_PROP_GRP_LCPL_ID, &lcpl_id) < 0) + HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, NULL, "can't get property value for lcpl id") + + /* Set up the location */ + if(H5G_loc_real(obj, loc_params.obj_type, &loc) < 0) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, NULL, "not a file or file object") + + /* if name is NULL then this is from H5Gcreate_anon */ + if(name == NULL) { + H5G_obj_create_t gcrt_info; /* Information for group creation */ + + /* Set up group creation info */ + gcrt_info.gcpl_id = gcpl_id; + gcrt_info.cache_type = H5G_NOTHING_CACHED; + HDmemset(&gcrt_info.cache, 0, sizeof(gcrt_info.cache)); + + /* Create the new group & get its ID */ + if(NULL == (grp = H5G__create(loc.oloc->file, &gcrt_info))) + HGOTO_ERROR(H5E_SYM, H5E_CANTINIT, NULL, "unable to create group") + } + /* otherwise it's from H5Gcreate */ + else { + /* Create the new group & get its ID */ + if(NULL == (grp = H5G__create_named(&loc, name, lcpl_id, gcpl_id))) + HGOTO_ERROR(H5E_SYM, H5E_CANTINIT, NULL, "unable to create group") + } + ret_value = (void *)grp; + +done: + if(name == NULL) { + /* Release the group's object header, if it was created */ + if(grp) { + H5O_loc_t *oloc; /* Object location for group */ + + /* Get the new group's object location */ + if(NULL == (oloc = H5G_oloc(grp))) + HDONE_ERROR(H5E_SYM, H5E_CANTGET, NULL, "unable to get object location of group") + + /* Decrement refcount on group's object header in memory */ + if(H5O_dec_rc_by_loc(oloc) < 0) + HDONE_ERROR(H5E_SYM, H5E_CANTDEC, NULL, "unable to decrement refcount on newly created object") + } + } + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5VL_native_group_create() */ + + +/*------------------------------------------------------------------------- + * Function: H5VL_native_group_open + * + * Purpose: Opens a group inside a native h5 file. + * + * Return: Success: Pointer to a group struct + * + * Failure: NULL + * + *------------------------------------------------------------------------- + */ +static void * +H5VL_native_group_open(void *obj, H5VL_loc_params_t loc_params, const char *name, + hid_t H5_ATTR_UNUSED gapl_id, hid_t H5_ATTR_UNUSED dxpl_id, void H5_ATTR_UNUSED **req) +{ + H5G_loc_t loc; /* Location to open group */ + H5G_t *grp = NULL; /* New group opend */ + void *ret_value; + + FUNC_ENTER_NOAPI_NOINIT + + /* Set up the location */ + if(H5G_loc_real(obj, loc_params.obj_type, &loc) < 0) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, NULL, "not a file or file object") + + /* Open the group */ + if((grp = H5G__open_name(&loc, name)) == NULL) + HGOTO_ERROR(H5E_SYM, H5E_CANTOPENOBJ, NULL, "unable to open group") + + ret_value = (void *)grp; + +done: + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5VL_native_group_open() */ + + +/*------------------------------------------------------------------------- + * Function: H5VL_native_group_get + * + * Purpose: Gets data about a group + * + * Return: SUCCEED/FAIL + * + *------------------------------------------------------------------------- + */ +static herr_t +H5VL_native_group_get(void *obj, H5VL_group_get_t get_type, hid_t H5_ATTR_UNUSED dxpl_id, void H5_ATTR_UNUSED **req, va_list arguments) +{ + herr_t ret_value = SUCCEED; /* Return value */ + + FUNC_ENTER_NOAPI_NOINIT + + switch(get_type) { + /* H5Gget_create_plist */ + case H5VL_GROUP_GET_GCPL: + { + hid_t *new_gcpl_id = va_arg(arguments, hid_t *); + H5G_t *grp = (H5G_t *)obj; + + if((*new_gcpl_id = H5G_get_create_plist(grp)) < 0) + HGOTO_ERROR(H5E_ARGS, H5E_CANTGET, FAIL, "can't get creation property list for group") + break; + } + /* H5Gget_info */ + case H5VL_GROUP_GET_INFO: + { + H5VL_loc_params_t loc_params = va_arg(arguments, H5VL_loc_params_t); + H5G_info_t *group_info = va_arg(arguments, H5G_info_t *); + H5G_loc_t loc; + + if(H5G_loc_real(obj, loc_params.obj_type, &loc) < 0) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a file or file object") + + if(loc_params.type == H5VL_OBJECT_BY_SELF) { + /* H5Gget_info */ + + /* Retrieve the group's information */ + if(H5G__obj_info(loc.oloc, group_info) < 0) + HGOTO_ERROR(H5E_SYM, H5E_CANTGET, FAIL, "can't retrieve group info") + } + else if (loc_params.type == H5VL_OBJECT_BY_NAME) { + /* H5Gget_info_by_name */ + + /* Retrieve the group's information */ + if(H5G__get_info_by_name(&loc, loc_params.loc_data.loc_by_name.name, group_info) < 0) + HGOTO_ERROR(H5E_SYM, H5E_CANTGET, FAIL, "can't retrieve group info") + } + else if(loc_params.type == H5VL_OBJECT_BY_IDX) { + /* H5Gget_info_by_idx */ + + /* Retrieve the group's information */ + if(H5G__get_info_by_idx(&loc, loc_params.loc_data.loc_by_idx.name, loc_params.loc_data.loc_by_idx.idx_type, + loc_params.loc_data.loc_by_idx.order, loc_params.loc_data.loc_by_idx.n, group_info) < 0) + HGOTO_ERROR(H5E_SYM, H5E_CANTGET, FAIL, "can't retrieve group info") + } + else { + HGOTO_ERROR(H5E_VOL, H5E_UNSUPPORTED, FAIL, "unknown get info parameters") + } + break; + } + default: + HGOTO_ERROR(H5E_VOL, H5E_CANTGET, FAIL, "can't get this type of information from group") + } + +done: + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5VL_native_group_get() */ + + +/*------------------------------------------------------------------------- + * Function: H5VL_native_group_specific + * + * Purpose: Specific operations for groups + * + * Return: SUCCEED/FAIL + * + *------------------------------------------------------------------------- + */ +static herr_t +H5VL_native_group_specific(void *obj, H5VL_group_specific_t specific_type, + hid_t H5_ATTR_UNUSED dxpl_id, void H5_ATTR_UNUSED **req, va_list arguments) +{ + H5G_t *grp = (H5G_t *)obj; + herr_t ret_value = SUCCEED; /* Return value */ + + FUNC_ENTER_NOAPI_NOINIT + + switch(specific_type) { + case H5VL_GROUP_FLUSH: + { + hid_t group_id = va_arg(arguments, hid_t); + + /* Flush object's metadata to file */ + if(H5O_flush_common(&grp->oloc, group_id) < 0) + HGOTO_ERROR(H5E_SYM, H5E_CANTFLUSH, FAIL, "unable to flush group") + + break; + } + case H5VL_GROUP_REFRESH: + { + hid_t group_id = va_arg(arguments, hid_t); + + /* Call private function to refresh group object */ + if((H5O_refresh_metadata(group_id, grp->oloc)) < 0) + HGOTO_ERROR(H5E_SYM, H5E_CANTLOAD, FAIL, "unable to refresh group") + + break; + } + default: + HGOTO_ERROR(H5E_VOL, H5E_UNSUPPORTED, FAIL, "invalid specific operation") + } + +done: + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5VL_native_group_specific() */ + + +/*------------------------------------------------------------------------- + * Function: H5VL_native_group_close + * + * Purpose: Closes a group. + * + * Return: SUCCEED/FAIL (the group will not be closed on failure) + * + *------------------------------------------------------------------------- + */ +static herr_t +H5VL_native_group_close(void *grp, hid_t H5_ATTR_UNUSED dxpl_id, void H5_ATTR_UNUSED **req) +{ + herr_t ret_value = SUCCEED; /* Return value */ + + FUNC_ENTER_NOAPI_NOINIT + + if(H5G_close((H5G_t *)grp) < 0) + HGOTO_ERROR(H5E_SYM, H5E_CLOSEERROR, FAIL, "can't close group") + +done: + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5VL_native_group_close() */ + + +/*------------------------------------------------------------------------- + * Function: H5VL_native_link_create + * + * Purpose: Creates an hard/soft/UD/external links. + * + * Return: Non-negative on success/Negative on failure + * + * Programmer: Mohamad Chaarawi + * April, 2012 + * + *------------------------------------------------------------------------- + */ +static herr_t +H5VL_native_link_create(H5VL_link_create_type_t create_type, void *obj, H5VL_loc_params_t loc_params, + hid_t lcpl_id, hid_t H5_ATTR_UNUSED lapl_id, hid_t H5_ATTR_UNUSED dxpl_id, void H5_ATTR_UNUSED **req) +{ + H5P_genplist_t *plist; /* Property list pointer */ + herr_t ret_value = SUCCEED; /* Return value */ + + FUNC_ENTER_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_LINK_CREATE_HARD: + { + H5G_loc_t cur_loc; + H5G_loc_t link_loc; + void *cur_obj; + H5VL_loc_params_t cur_params; + + if(H5P_get(plist, H5VL_PROP_LINK_TARGET, &cur_obj) < 0) + HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, FAIL, "can't get property value for current location id") + if(H5P_get(plist, H5VL_PROP_LINK_TARGET_LOC_PARAMS, &cur_params) < 0) + HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, FAIL, "can't get property value for current name") + + if(NULL != cur_obj && H5G_loc_real(cur_obj, cur_params.obj_type, &cur_loc) < 0) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a file or file object") + if(NULL != obj && H5G_loc_real(obj, loc_params.obj_type, &link_loc) < 0) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a file or file object") + + /* H5Lcreate_hard */ + if(H5VL_OBJECT_BY_NAME == cur_params.type) { + H5G_loc_t *cur_loc_p, *link_loc_p; + + /* Set up current & new location pointers */ + cur_loc_p = &cur_loc; + link_loc_p = &link_loc; + if(NULL == cur_obj) + cur_loc_p = link_loc_p; + else if(NULL == obj) + link_loc_p = cur_loc_p; + else if(cur_loc_p->oloc->file != link_loc_p->oloc->file) + HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "source and destination should be in the same file.") + + /* Create the link */ + if((ret_value = H5L_create_hard(cur_loc_p, cur_params.loc_data.loc_by_name.name, + link_loc_p, loc_params.loc_data.loc_by_name.name, lcpl_id)) < 0) + HGOTO_ERROR(H5E_LINK, H5E_CANTINIT, FAIL, "unable to create link") + } + else { /* H5Olink */ + /* Link to the object */ + if(H5L_link(&link_loc, loc_params.loc_data.loc_by_name.name, &cur_loc, lcpl_id) < 0) + HGOTO_ERROR(H5E_OHDR, H5E_CANTINIT, FAIL, "unable to create link") + } + break; + } + case H5VL_LINK_CREATE_SOFT: + { + char *target_name; + H5G_loc_t link_loc; /* Group location for new link */ + + if(H5G_loc_real(obj, loc_params.obj_type, &link_loc) < 0) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a file or file object") + + if(H5P_get(plist, H5VL_PROP_LINK_TARGET_NAME, &target_name) < 0) + HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, FAIL, "can't get property value for targe name") + + /* Create the link */ + if((ret_value = H5L_create_soft(target_name, &link_loc, loc_params.loc_data.loc_by_name.name, lcpl_id)) < 0) + HGOTO_ERROR(H5E_LINK, H5E_CANTINIT, FAIL, "unable to create link") + break; + } + case H5VL_LINK_CREATE_UD: + { + H5G_loc_t link_loc; /* Group location for new link */ + H5L_type_t link_type; + void *udata; + size_t udata_size; + + if(H5G_loc_real(obj, loc_params.obj_type, &link_loc) < 0) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a file or file object") + + if(H5P_get(plist, H5VL_PROP_LINK_TYPE, &link_type) < 0) + HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, FAIL, "can't get property value for link type") + if(H5P_get(plist, H5VL_PROP_LINK_UDATA, &udata) < 0) + HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, FAIL, "can't get property value for udata") + if(H5P_get(plist, H5VL_PROP_LINK_UDATA_SIZE, &udata_size) < 0) + HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, FAIL, "can't get property value for udata size") + + /* Create link */ + if(H5L__create_ud(&link_loc, loc_params.loc_data.loc_by_name.name, udata, udata_size, + link_type, lcpl_id) < 0) + HGOTO_ERROR(H5E_LINK, H5E_CANTINIT, FAIL, "unable to create link") + break; + } + default: + HGOTO_ERROR(H5E_LINK, H5E_CANTINIT, FAIL, "invalid link creation call") + } +done: + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5VL_native_link_create() */ + + +/*------------------------------------------------------------------------- + * Function: H5VL_native_link_copy + * + * Purpose: Renames an object within an HDF5 file and copies it to a new + * group. The original name SRC is unlinked from the group graph + * and then inserted with the new name DST (which can specify a + * new path for the object) as an atomic operation. The names + * are interpreted relative to SRC_LOC_ID and + * DST_LOC_ID, which are either file IDs or group ID. + * + * Return: Non-negative on success/Negative on failure + * + * Programmer: Mohamad Chaarawi + * April, 2012 + * + *------------------------------------------------------------------------- + */ +static herr_t +H5VL_native_link_copy(void *src_obj, H5VL_loc_params_t loc_params1, + void *dst_obj, H5VL_loc_params_t loc_params2, + hid_t lcpl_id, hid_t H5_ATTR_UNUSED lapl_id, hid_t H5_ATTR_UNUSED dxpl_id, void H5_ATTR_UNUSED **req) +{ + H5G_loc_t src_loc, *src_loc_p; + H5G_loc_t dst_loc, *dst_loc_p; + herr_t ret_value = SUCCEED; /* Return value */ + + FUNC_ENTER_NOAPI_NOINIT + + if(NULL != src_obj && H5G_loc_real(src_obj, loc_params1.obj_type, &src_loc) < 0) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a file or file object") + if(NULL != dst_obj && H5G_loc_real(dst_obj, loc_params2.obj_type, &dst_loc) < 0) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a file or file object") + + /* Set up src & dst location pointers */ + src_loc_p = &src_loc; + dst_loc_p = &dst_loc; + if(NULL == src_obj) + src_loc_p = dst_loc_p; + else if(NULL == dst_obj) + dst_loc_p = src_loc_p; + + /* Copy the link */ + if(H5L_move(src_loc_p, loc_params1.loc_data.loc_by_name.name, + dst_loc_p, loc_params2.loc_data.loc_by_name.name, + TRUE, lcpl_id) < 0) + HGOTO_ERROR(H5E_LINK, H5E_CANTCOPY, FAIL, "unable to copy link") + +done: + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5VL_native_link_copy() */ + + +/*------------------------------------------------------------------------- + * Function: H5VL_native_link_move + * + * Purpose: Renames an object within an HDF5 file and moves it to a new + * group. The original name SRC is unlinked from the group graph + * and then inserted with the new name DST (which can specify a + * new path for the object) as an atomic operation. The names + * are interpreted relative to SRC_LOC_ID and + * DST_LOC_ID, which are either file IDs or group ID. + * + * Return: Non-negative on success/Negative on failure + * + * Programmer: Mohamad Chaarawi + * April, 2012 + * + *------------------------------------------------------------------------- + */ +static herr_t +H5VL_native_link_move(void *src_obj, H5VL_loc_params_t loc_params1, + void *dst_obj, H5VL_loc_params_t loc_params2, + hid_t lcpl_id, hid_t H5_ATTR_UNUSED lapl_id, hid_t H5_ATTR_UNUSED dxpl_id, void H5_ATTR_UNUSED **req) +{ + H5G_loc_t src_loc, *src_loc_p; + H5G_loc_t dst_loc, *dst_loc_p; + herr_t ret_value = SUCCEED; /* Return value */ + + FUNC_ENTER_NOAPI_NOINIT + + if(NULL != src_obj && H5G_loc_real(src_obj, loc_params1.obj_type, &src_loc) < 0) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a file or file object") + if(NULL != dst_obj && H5G_loc_real(dst_obj, loc_params2.obj_type, &dst_loc) < 0) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a file or file object") + + /* Set up src & dst location pointers */ + src_loc_p = &src_loc; + dst_loc_p = &dst_loc; + if(NULL == src_obj) + src_loc_p = dst_loc_p; + else if(NULL == dst_obj) + dst_loc_p = src_loc_p; + + /* Move the link */ + if(H5L_move(src_loc_p, loc_params1.loc_data.loc_by_name.name, + dst_loc_p, loc_params2.loc_data.loc_by_name.name, + FALSE, lcpl_id) < 0) + HGOTO_ERROR(H5E_LINK, H5E_CANTMOVE, FAIL, "unable to move link") + +done: + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5VL_native_link_move() */ + + +/*------------------------------------------------------------------------- + * Function: H5VL_native_link_get + * + * Purpose: Gets certain data about a link + * + * Return: Success: 0 + * Failure: -1 + * + * Programmer: Mohamad Chaarawi + * April, 2012 + * + *------------------------------------------------------------------------- + */ +static herr_t +H5VL_native_link_get(void *obj, H5VL_loc_params_t loc_params, H5VL_link_get_t get_type, + hid_t H5_ATTR_UNUSED dxpl_id, void H5_ATTR_UNUSED **req, va_list arguments) +{ + H5G_loc_t loc; + herr_t ret_value = SUCCEED; /* Return value */ + + FUNC_ENTER_NOAPI_NOINIT + + if(H5G_loc_real(obj, loc_params.obj_type, &loc) < 0) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a file or file object") + + switch(get_type) { + /* H5Lget_info/H5Lget_info_by_idx */ + case H5VL_LINK_GET_INFO: + { + H5L_info_t *linfo = va_arg(arguments, H5L_info_t *); + + /* Get the link information */ + if(loc_params.type == H5VL_OBJECT_BY_NAME) { /* H5Lget_info */ + if(H5L_get_info(&loc, loc_params.loc_data.loc_by_name.name, linfo) < 0) + HGOTO_ERROR(H5E_LINK, H5E_NOTFOUND, FAIL, "unable to get link info") + } + else if(loc_params.type == H5VL_OBJECT_BY_IDX) { /* H5Lget_info_by_idx */ + + if(H5L_get_info_by_idx(&loc, loc_params.loc_data.loc_by_idx.name, loc_params.loc_data.loc_by_idx.idx_type, + loc_params.loc_data.loc_by_idx.order, loc_params.loc_data.loc_by_idx.n, linfo) < 0) + HGOTO_ERROR(H5E_LINK, H5E_NOTFOUND, FAIL, "unable to get link info") + } + else + HGOTO_ERROR(H5E_LINK, H5E_NOTFOUND, FAIL, "unable to get link info") + break; + } + /* H5Lget_name_by_idx */ + case H5VL_LINK_GET_NAME: + { + char *name = va_arg(arguments, char *); + size_t size = va_arg(arguments, size_t); + ssize_t *ret = va_arg(arguments, ssize_t *); + + /* Get the link name */ + if((*ret = H5L_get_name_by_idx(&loc, loc_params.loc_data.loc_by_idx.name, loc_params.loc_data.loc_by_idx.idx_type, + loc_params.loc_data.loc_by_idx.order, loc_params.loc_data.loc_by_idx.n, name, size)) < 0) + HGOTO_ERROR(H5E_LINK, H5E_NOTFOUND, FAIL, "unable to get link info") + + break; + } + /* H5Lget_val/H5Lget_val_by_idx */ + case H5VL_LINK_GET_VAL: + { + void *buf = va_arg(arguments, void *); + size_t size = va_arg(arguments, size_t); + + /* Get the link information */ + if(loc_params.type == H5VL_OBJECT_BY_NAME) { /* H5Lget_val */ + if(H5L_get_val(&loc, loc_params.loc_data.loc_by_name.name, buf, size) < 0) + HGOTO_ERROR(H5E_LINK, H5E_NOTFOUND, FAIL, "unable to get link value") + } + else if(loc_params.type == H5VL_OBJECT_BY_IDX) { /* H5Lget_val_by_idx */ + + if(H5L_get_val_by_idx(&loc, loc_params.loc_data.loc_by_idx.name, loc_params.loc_data.loc_by_idx.idx_type, + loc_params.loc_data.loc_by_idx.order, loc_params.loc_data.loc_by_idx.n, buf, size) < 0) + HGOTO_ERROR(H5E_LINK, H5E_NOTFOUND, FAIL, "unable to get link val") + } + else + HGOTO_ERROR(H5E_LINK, H5E_NOTFOUND, FAIL, "unable to get link val") + + break; + } + default: + HGOTO_ERROR(H5E_VOL, H5E_CANTGET, FAIL, "can't get this type of information from link") + } + +done: + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5VL_native_link_get() */ + + +/*------------------------------------------------------------------------- + * Function: H5VL_native_link_specific + * + * Purpose: Specific operations with links + * + * Return: Success: 0 + * Failure: -1 + * + * Programmer: Mohamad Chaarawi + * April, 2012 + * + *------------------------------------------------------------------------- + */ +static herr_t +H5VL_native_link_specific(void *obj, H5VL_loc_params_t loc_params, H5VL_link_specific_t specific_type, + hid_t H5_ATTR_UNUSED dxpl_id, void H5_ATTR_UNUSED **req, va_list arguments) +{ + herr_t ret_value = SUCCEED; /* Return value */ + + FUNC_ENTER_NOAPI_NOINIT + + switch(specific_type) { + case H5VL_LINK_EXISTS: + { + htri_t *ret = va_arg(arguments, htri_t *); + H5G_loc_t loc; + + if(H5G_loc_real(obj, loc_params.obj_type, &loc) < 0) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a file or file object") + + /* Check for the existence of the link */ + if((*ret = H5L_exists(&loc, loc_params.loc_data.loc_by_name.name)) < 0) + HGOTO_ERROR(H5E_LINK, H5E_NOTFOUND, FAIL, "unable to specific link info") + break; + } + case H5VL_LINK_ITER: + { + H5G_loc_t loc; + hbool_t recursive = va_arg(arguments, int); + H5_index_t idx_type = va_arg(arguments, H5_index_t); + H5_iter_order_t order = va_arg(arguments, H5_iter_order_t); + hsize_t *idx_p = va_arg(arguments, hsize_t *); + H5L_iterate_t op = va_arg(arguments, H5L_iterate_t); + void *op_data = va_arg(arguments, void *); + + /* Get the location */ + if(H5G_loc_real(obj, loc_params.obj_type, &loc) < 0) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a location") + + /* Visit or iterate over the links */ + if(loc_params.type == H5VL_OBJECT_BY_SELF) { + if(recursive) { + /* H5Lvisit */ + if((ret_value = H5G_visit(&loc, ".", idx_type, order, op, op_data)) < 0) + HGOTO_ERROR(H5E_LINK, H5E_BADITER, FAIL, "link visitation failed") + } + else { + /* H5Literate */ + if((ret_value = H5L_iterate(&loc, ".", idx_type, order, idx_p, op, op_data)) < 0) + HGOTO_ERROR(H5E_LINK, H5E_BADITER, FAIL, "error iterating over links") + } + } + else if(loc_params.type == H5VL_OBJECT_BY_NAME) { + if(recursive) { + /* H5Lvisit_by_name */ + if((ret_value = H5G_visit(&loc, loc_params.loc_data.loc_by_name.name, idx_type, order, op, op_data)) < 0) + HGOTO_ERROR(H5E_LINK, H5E_BADITER, FAIL, "link visitation failed") + } + else { + /* H5Literate_by_name */ + if((ret_value = H5L_iterate(&loc, loc_params.loc_data.loc_by_name.name, idx_type, order, idx_p, op, op_data)) < 0) + HGOTO_ERROR(H5E_LINK, H5E_BADITER, FAIL, "error iterating over links") + } + } + else{ + HGOTO_ERROR(H5E_LINK, H5E_UNSUPPORTED, FAIL, "unknown link iterate params") + } + + break; + } + case H5VL_LINK_DELETE: + { + H5G_loc_t loc; + + if(H5G_loc_real(obj, loc_params.obj_type, &loc) < 0) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a file or file object") + + /* Unlink */ + if(loc_params.type == H5VL_OBJECT_BY_NAME) { /* H5Ldelete */ + if(H5L_delete(&loc, loc_params.loc_data.loc_by_name.name) < 0) + HGOTO_ERROR(H5E_LINK, H5E_CANTDELETE, FAIL, "unable to delete link") + } + else if(loc_params.type == H5VL_OBJECT_BY_IDX) { /* H5Ldelete_by_idx */ + + if(H5L_delete_by_idx(&loc, loc_params.loc_data.loc_by_idx.name, loc_params.loc_data.loc_by_idx.idx_type, + loc_params.loc_data.loc_by_idx.order, loc_params.loc_data.loc_by_idx.n) < 0) + HGOTO_ERROR(H5E_LINK, H5E_CANTDELETE, FAIL, "unable to delete link") + } + else + HGOTO_ERROR(H5E_LINK, H5E_CANTDELETE, FAIL, "unable to delete link") + break; + } + default: + HGOTO_ERROR(H5E_VOL, H5E_UNSUPPORTED, FAIL, "invalid specific operation") + } + +done: + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5VL_native_link_specific() */ + + +/*------------------------------------------------------------------------- + * Function: H5VL_native_object_open + * + * Purpose: Opens a object inside a native h5 file. + * + * Return: Success: object id. + * Failure: NULL + * + * Programmer: Mohamad Chaarawi + * March, 2012 + * + *------------------------------------------------------------------------- + */ +static void * +H5VL_native_object_open(void *obj, H5VL_loc_params_t loc_params, H5I_type_t *opened_type, + hid_t H5_ATTR_UNUSED dxpl_id, void H5_ATTR_UNUSED **req) +{ + H5G_loc_t loc; + void *ret_value = NULL; + + FUNC_ENTER_NOAPI_NOINIT + + if(H5G_loc_real(obj, loc_params.obj_type, &loc) < 0) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, NULL, "not a file or file object") + + switch(loc_params.type) { + case H5VL_OBJECT_BY_NAME: + { + /* Open the object */ + if(NULL == (ret_value = H5O_open_name(&loc, loc_params.loc_data.loc_by_name.name, opened_type))) + HGOTO_ERROR(H5E_OHDR, H5E_CANTOPENOBJ, NULL, "unable to open object by name") + break; + } + case H5VL_OBJECT_BY_IDX: + { + /* Open the object */ + if(NULL == (ret_value = H5O_open_by_idx(&loc, loc_params.loc_data.loc_by_idx.name, loc_params.loc_data.loc_by_idx.idx_type, + loc_params.loc_data.loc_by_idx.order, loc_params.loc_data.loc_by_idx.n, opened_type))) + HGOTO_ERROR(H5E_OHDR, H5E_CANTOPENOBJ, NULL, "unable to open object by index") + break; + } + case H5VL_OBJECT_BY_ADDR: + { + /* Open the object */ + if(NULL == (ret_value = H5O_open_by_addr(&loc, loc_params.loc_data.loc_by_addr.addr, opened_type))) + HGOTO_ERROR(H5E_OHDR, H5E_CANTOPENOBJ, NULL, "unable to open object by address") + break; + } + case H5VL_OBJECT_BY_REF: + { + hid_t temp_id = H5I_INVALID_HID; + H5F_t *file = NULL; + + /* Get the file pointer from the entry */ + file = loc.oloc->file; + + /* Create reference */ + if((temp_id = H5R__dereference(file, loc_params.loc_data.loc_by_ref.lapl_id, + loc_params.loc_data.loc_by_ref.ref_type, + loc_params.loc_data.loc_by_ref._ref)) < 0) + HGOTO_ERROR(H5E_REFERENCE, H5E_CANTOPENOBJ, NULL, "unable to dereference object") + + *opened_type = H5I_get_type(temp_id); + if(NULL == (ret_value = H5I_remove(temp_id))) + HDONE_ERROR(H5E_SYM, H5E_CANTOPENOBJ, NULL, "unable to open object") + break; + } + case H5VL_OBJECT_BY_SELF: + default: + HGOTO_ERROR(H5E_VOL, H5E_UNSUPPORTED, NULL, "unknown open parameters") + } + +done: + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5VL_native_object_open() */ + + +/*------------------------------------------------------------------------- + * Function: H5VL_native_object_copy + * + * Purpose: Copys a object inside a native h5 file. + * + * Return: Success: object id. + * Failure: NULL + * + * Programmer: Mohamad Chaarawi + * March, 2012 + * + *------------------------------------------------------------------------- + */ +static herr_t +H5VL_native_object_copy(void *src_obj, H5VL_loc_params_t loc_params1, const char *src_name, + void *dst_obj, H5VL_loc_params_t loc_params2, const char *dst_name, + hid_t ocpypl_id, hid_t lcpl_id, hid_t H5_ATTR_UNUSED dxpl_id, void H5_ATTR_UNUSED **req) +{ + H5G_loc_t src_loc; /* Source object group location */ + H5G_loc_t dst_loc; /* Destination group location */ + herr_t ret_value = FAIL; + + FUNC_ENTER_NOAPI_NOINIT + + /* get location for objects */ + if(H5G_loc_real(src_obj, loc_params1.obj_type, &src_loc) < 0) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a file or file object") + if(H5G_loc_real(dst_obj, loc_params2.obj_type, &dst_loc) < 0) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a file or file object") + + /* Open the object */ + if((ret_value = H5O_copy(&src_loc, src_name, &dst_loc, dst_name, ocpypl_id, lcpl_id)) < 0) + HGOTO_ERROR(H5E_SYM, H5E_CANTCOPY, FAIL, "unable to copy object") +done: + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5VL_native_object_copy() */ + + +/*------------------------------------------------------------------------- + * Function: H5VL_native_object_get + * + * Purpose: Gets certain data about an object + * + * Return: SUCCEED/FAIL + * + * Programmer: Mohamad Chaarawi + * March, 2012 + * + *------------------------------------------------------------------------- + */ +static herr_t +H5VL_native_object_get(void *obj, H5VL_loc_params_t loc_params, H5VL_object_get_t get_type, + hid_t H5_ATTR_UNUSED dxpl_id, void H5_ATTR_UNUSED **req, va_list arguments) +{ + herr_t ret_value = SUCCEED; /* Return value */ + H5G_loc_t loc; /* Location of group */ + + FUNC_ENTER_NOAPI_NOINIT + + if(H5G_loc_real(obj, loc_params.obj_type, &loc) < 0) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a file or file object") + + switch(get_type) { + /* H5Rget_region */ + case H5VL_REF_GET_REGION: + { + hid_t *ret = va_arg(arguments, hid_t *); + H5R_type_t H5_ATTR_UNUSED ref_type = va_arg(arguments, H5R_type_t); + void *ref = va_arg(arguments, void *); + H5S_t *space = NULL; /* Dataspace object */ + + /* Get the dataspace with the correct region selected */ + if((space = H5R__get_region(loc.oloc->file, ref)) == NULL) + HGOTO_ERROR(H5E_REFERENCE, H5E_CANTGET, FAIL, "unable to retrieve region") + + /* Atomize */ + if((*ret = H5I_register(H5I_DATASPACE, space, TRUE)) < 0) + HGOTO_ERROR(H5E_ATOM, H5E_CANTREGISTER, FAIL, "unable to register dataspace atom") + + break; + } + /* H5Rget_obj_type2 */ + case H5VL_REF_GET_TYPE: + { + H5O_type_t *obj_type = va_arg(arguments, H5O_type_t *); + H5R_type_t ref_type = va_arg(arguments, H5R_type_t); + void *ref = va_arg(arguments, void *); + + /* Get the object information */ + if(H5R__get_obj_type(loc.oloc->file, ref_type, ref, obj_type) < 0) + HGOTO_ERROR(H5E_REFERENCE, H5E_CANTGET, FAIL, "unable to determine object type") + break; + } + /* H5Rget_name */ + case H5VL_REF_GET_NAME: + { + ssize_t *ret = va_arg(arguments, ssize_t *); + char *name = va_arg(arguments, char *); + size_t size = va_arg(arguments, size_t); + H5R_type_t ref_type = va_arg(arguments, H5R_type_t); + void *ref = va_arg(arguments, void *); + + /* Get name */ + if((*ret = H5R__get_name(loc.oloc->file, ref_type, ref, name, size)) < 0) + HGOTO_ERROR(H5E_REFERENCE, H5E_CANTGET, FAIL, "unable to determine object path") + break; + } + default: + HGOTO_ERROR(H5E_VOL, H5E_CANTGET, FAIL, "can't get this type of information from object") + } +done: + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5VL_native_object_get() */ + + +/*------------------------------------------------------------------------- + * Function: H5VL_native_object_specific + * + * Purpose: Perform a driver specific operation for an objectibute + * + * Return: SUCCEED/FAIL + * + *------------------------------------------------------------------------- + */ +static herr_t +H5VL_native_object_specific(void *obj, H5VL_loc_params_t loc_params, H5VL_object_specific_t specific_type, + hid_t H5_ATTR_UNUSED dxpl_id, void H5_ATTR_UNUSED **req, va_list arguments) +{ + H5G_loc_t loc; + herr_t ret_value = SUCCEED; /* Return value */ + + FUNC_ENTER_NOAPI_NOINIT + + if(H5G_loc_real(obj, loc_params.obj_type, &loc) < 0) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a file or file object") + + switch(specific_type) { + /* H5Oincr_refcount / H5Odecr_refcount */ + case H5VL_OBJECT_CHANGE_REF_COUNT: + { + int update_ref = va_arg(arguments, int); + H5O_loc_t *oloc = loc.oloc; + + if(H5O_link(oloc, update_ref) < 0) + HGOTO_ERROR(H5E_OHDR, H5E_LINKCOUNT, FAIL, "modifying object link count failed") + + break; + } + /* H5Oexists_by_name */ + case H5VL_OBJECT_EXISTS: + { + htri_t *ret = va_arg(arguments, htri_t *); + + if(loc_params.type == H5VL_OBJECT_BY_NAME) { + /* Check if the object exists */ + if((*ret = H5G_loc_exists(&loc, loc_params.loc_data.loc_by_name.name)) < 0) + HGOTO_ERROR(H5E_OHDR, H5E_CANTGET, FAIL, "unable to determine if '%s' exists", + loc_params.loc_data.loc_by_name.name) + } + else { + HGOTO_ERROR(H5E_VOL, H5E_UNSUPPORTED, FAIL, "unknown object exists parameters") + } + break; + } + case H5VL_OBJECT_VISIT: + { + H5_index_t idx_type = va_arg(arguments, H5_index_t); + H5_iter_order_t order = va_arg(arguments, H5_iter_order_t); + H5O_iterate_t op = va_arg(arguments, H5O_iterate_t); + void *op_data = va_arg(arguments, void *); + unsigned fields = va_arg(arguments, unsigned); + + /* Call internal object visitation routine */ + if(loc_params.type == H5VL_OBJECT_BY_SELF) { + /* H5Ovisit */ + if((ret_value = H5O__visit(&loc, ".", idx_type, order, op, op_data, fields)) < 0) + HGOTO_ERROR(H5E_OHDR, H5E_BADITER, FAIL, "object visitation failed") + } + else if(loc_params.type == H5VL_OBJECT_BY_NAME) { + /* H5Ovisit_by_name */ + if((ret_value = H5O__visit(&loc, loc_params.loc_data.loc_by_name.name, idx_type, order, op, op_data, fields)) < 0) + HGOTO_ERROR(H5E_OHDR, H5E_BADITER, FAIL, "object visitation failed") + } + else + HGOTO_ERROR(H5E_VOL, H5E_UNSUPPORTED, FAIL, "unknown object visit params"); + break; + } + case H5VL_OBJECT_FLUSH: + { + hid_t oid = va_arg(arguments, hid_t); + + /* Flush the object's metadata */ + if(H5O_flush(loc.oloc, oid) < 0) + HGOTO_ERROR(H5E_OHDR, H5E_CANTFLUSH, FAIL, "unable to flush object") + + break; + } + case H5VL_OBJECT_REFRESH: + { + hid_t oid = va_arg(arguments, hid_t); + H5O_loc_t *oloc = loc.oloc; + + /* Refresh the metadata */ + if(H5O_refresh_metadata(oid, *oloc) < 0) + HGOTO_ERROR(H5E_OHDR, H5E_CANTLOAD, FAIL, "unable to refresh object") + + break; + } + case H5VL_REF_CREATE: + { + void *ref = va_arg(arguments, void *); + const char *name = va_arg(arguments, char *); + H5R_type_t ref_type = va_arg(arguments, H5R_type_t); + hid_t space_id = va_arg(arguments, hid_t); + H5S_t *space = NULL; /* Pointer to dataspace containing region */ + + if(space_id != (-1) && (NULL == (space = (H5S_t *)H5I_object_verify(space_id, H5I_DATASPACE)))) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a dataspace") + + /* Create reference */ + if(H5R__create(ref, &loc, name, ref_type, space) < 0) + HGOTO_ERROR(H5E_REFERENCE, H5E_CANTCREATE, FAIL, "unable to create reference") + + break; + } + default: + HGOTO_ERROR(H5E_VOL, H5E_CANTGET, FAIL, "can't recognize this operation type") + } + +done: + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5VL_native_object_specific() */ + + +/*------------------------------------------------------------------------- + * Function: H5VL_native_object_optional + * + * Purpose: Perform a driver specific operation for an objectibute + * + * Return: Success: 0 + * Failure: -1 + * + * Programmer: Mohamad Chaarawi + * April, 2012 + * + *------------------------------------------------------------------------- + */ +static herr_t +H5VL_native_object_optional(void *obj, hid_t H5_ATTR_UNUSED dxpl_id, void H5_ATTR_UNUSED **req, va_list arguments) +{ + H5VL_object_optional_t optional_type = va_arg(arguments, H5VL_object_optional_t); + H5VL_loc_params_t loc_params = va_arg(arguments, H5VL_loc_params_t); + H5G_loc_t loc; /* Location of group */ + herr_t ret_value = SUCCEED; /* Return value */ + + FUNC_ENTER_NOAPI_NOINIT + + if(H5G_loc_real(obj, loc_params.obj_type, &loc) < 0) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a file or file object") + + switch(optional_type) { + /* H5Oget_info / H5Oget_info_by_name / H5Oget_info_by_idx */ + case H5VL_OBJECT_GET_INFO: + { + H5O_info_t *obj_info = va_arg(arguments, H5O_info_t *); + unsigned fields = va_arg(arguments, unsigned); + + if(loc_params.type == H5VL_OBJECT_BY_SELF) { /* H5Oget_info */ + /* Retrieve the object's information */ + if(H5G_loc_info(&loc, ".", obj_info, fields) < 0) + HGOTO_ERROR(H5E_OHDR, H5E_NOTFOUND, FAIL, "object not found") + } + else if(loc_params.type == H5VL_OBJECT_BY_NAME) { /* H5Oget_info_by_name */ + /* Retrieve the object's information */ + if(H5G_loc_info(&loc, loc_params.loc_data.loc_by_name.name, obj_info, fields) < 0) + HGOTO_ERROR(H5E_OHDR, H5E_NOTFOUND, FAIL, "object not found") + } + else if(loc_params.type == H5VL_OBJECT_BY_IDX) { /* H5Oget_info_by_idx */ + H5G_loc_t obj_loc; /* Location used to open group */ + H5G_name_t obj_path; /* Opened object group hier. path */ + H5O_loc_t obj_oloc; /* Opened object object location */ + + /* Set up opened group location to fill in */ + obj_loc.oloc = &obj_oloc; + obj_loc.path = &obj_path; + H5G_loc_reset(&obj_loc); + + /* Find the object's location, according to the order in the index */ + if(H5G_loc_find_by_idx(&loc, loc_params.loc_data.loc_by_idx.name, + loc_params.loc_data.loc_by_idx.idx_type, + loc_params.loc_data.loc_by_idx.order, + loc_params.loc_data.loc_by_idx.n, &obj_loc/*out*/) < 0) + HGOTO_ERROR(H5E_OHDR, H5E_NOTFOUND, FAIL, "group not found") + + /* Retrieve the object's information */ + if(H5O_get_info(obj_loc.oloc, obj_info, fields) < 0) { + H5G_loc_free(&obj_loc); + HGOTO_ERROR(H5E_OHDR, H5E_CANTGET, FAIL, "can't retrieve object info") + } + + /* Release the object location */ + if(H5G_loc_free(&obj_loc) < 0) + HDONE_ERROR(H5E_OHDR, H5E_CANTRELEASE, FAIL, "can't free location") + } + else { + HGOTO_ERROR(H5E_VOL, H5E_UNSUPPORTED, FAIL, "unknown get info parameters") + } + break; + } + /* H5Oget_comment / H5Oget_comment_by_name */ + case H5VL_OBJECT_GET_COMMENT: + { + char *comment = va_arg(arguments, char *); + size_t bufsize = va_arg(arguments, size_t); + ssize_t *ret = va_arg(arguments, ssize_t *); + + /* Retrieve the object's comment */ + if(loc_params.type == H5VL_OBJECT_BY_SELF) { /* H5Oget_comment */ + if((*ret = H5G_loc_get_comment(&loc, ".", comment/*out*/, bufsize)) < 0) + HGOTO_ERROR(H5E_OHDR, H5E_NOTFOUND, FAIL, "object not found") + } + else if(loc_params.type == H5VL_OBJECT_BY_NAME) { /* H5Oget_comment_by_name */ + if((*ret = H5G_loc_get_comment(&loc, loc_params.loc_data.loc_by_name.name, comment/*out*/, bufsize)) < 0) + HGOTO_ERROR(H5E_OHDR, H5E_NOTFOUND, FAIL, "object not found") + } + else { + HGOTO_ERROR(H5E_VOL, H5E_UNSUPPORTED, FAIL, "unknown set_coment parameters") + } + break; + } + /* H5Oset_comment */ + case H5VL_OBJECT_SET_COMMENT: + { + const char *comment = va_arg(arguments, char *); + + if(loc_params.type == H5VL_OBJECT_BY_SELF) { /* H5Oset_comment */ + /* (Re)set the object's comment */ + if(H5G_loc_set_comment(&loc, ".", comment) < 0) + HGOTO_ERROR(H5E_OHDR, H5E_NOTFOUND, FAIL, "object not found") + } + else if(loc_params.type == H5VL_OBJECT_BY_NAME) { /* H5Oset_comment_by_name */ + /* (Re)set the object's comment */ + if(H5G_loc_set_comment(&loc, loc_params.loc_data.loc_by_name.name, comment) < 0) + HGOTO_ERROR(H5E_OHDR, H5E_NOTFOUND, FAIL, "object not found") + } + else { + HGOTO_ERROR(H5E_VOL, H5E_UNSUPPORTED, FAIL, "unknown set_coment parameters") + } + break; + } + default: + HGOTO_ERROR(H5E_VOL, H5E_CANTGET, FAIL, "can't perform this operation on object"); + } + +done: + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5VL_native_object_optional() */ + + +/*------------------------------------------------------------------------- + * Function: H5VL_native_datatype_commit + * + * Purpose: Commits a datatype inside a native h5 file. + * + * Return: Success: datatype id. + * Failure: NULL + * + * Programmer: Mohamad Chaarawi + * March, 2012 + * + *------------------------------------------------------------------------- + */ +static void * +H5VL_native_datatype_commit(void *obj, H5VL_loc_params_t loc_params, const char *name, hid_t type_id, + hid_t lcpl_id, hid_t tcpl_id, hid_t H5_ATTR_UNUSED tapl_id, hid_t H5_ATTR_UNUSED dxpl_id, void H5_ATTR_UNUSED **req) +{ + H5G_loc_t loc; /* Location to commit datatype */ + H5T_t *dt; /* Datatype for ID */ + H5T_t *type = NULL; /* copy of the original type which will be committed */ + void *ret_value = NULL; /* Return value */ + + FUNC_ENTER_NOAPI_NOINIT + + /* check arguments */ + if(H5G_loc_real(obj, loc_params.obj_type, &loc) < 0) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, NULL, "not a file or file object") + + if(NULL == (dt = (H5T_t *)H5I_object_verify(type_id, H5I_DATATYPE))) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, NULL, "not a datatype") + + /* Check arguments. We cannot commit an immutable type because H5Tclose() + * normally fails on such types (try H5Tclose(H5T_NATIVE_INT)) but closing + * a named type should always succeed. + */ + if(H5T_STATE_NAMED == dt->shared->state || H5T_STATE_OPEN == dt->shared->state) + HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, NULL, "datatype is already committed") + if(H5T_STATE_IMMUTABLE == dt->shared->state) + HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, NULL, "datatype is immutable") + + /* Check for a "sensible" datatype to store on disk */ + if(H5T_is_sensible(dt) <= 0) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, NULL, "datatype is not sensible") + + /* Copy the datatype - the copied one will be the type that is + * committed, and attached to original datatype above the VOL + * layer + */ + if(NULL == (type = H5T_copy(dt, H5T_COPY_TRANSIENT))) + HGOTO_ERROR(H5E_DATATYPE, H5E_CANTINIT, NULL, "unable to copy"); + + /* Commit the datatype */ + if(NULL != name) { + /* H5Tcommit */ + if(H5T__commit_named(&loc, name, type, lcpl_id, tcpl_id) < 0) + HGOTO_ERROR(H5E_DATATYPE, H5E_CANTINIT, NULL, "unable to commit datatype") + } + else { + /* H5Tcommit_anon */ + if(H5T__commit_anon(loc.oloc->file, type, tcpl_id) < 0) + HGOTO_ERROR(H5E_DATATYPE, H5E_CANTINIT, NULL, "unable to commit datatype") + } + ret_value = (void *)type; + +done: + if(NULL == ret_value && type) + H5T_close(type); + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5VL_native_datatype_commit() */ + + +/*------------------------------------------------------------------------- + * Function: H5VL_native_datatype_open + * + * Purpose: Opens a named datatype inside a native h5 file. + * + * Return: Success: datatype pointer + * Failure: NULL + * + *------------------------------------------------------------------------- + */ +static void * +H5VL_native_datatype_open(void *obj, H5VL_loc_params_t loc_params, const char *name, + hid_t H5_ATTR_UNUSED tapl_id, hid_t H5_ATTR_UNUSED dxpl_id, void H5_ATTR_UNUSED **req) +{ + H5T_t *type = NULL; /* Datatype opened in file */ + H5G_loc_t loc; /* Group location of object to open */ + void *ret_value = NULL; + + FUNC_ENTER_NOAPI_NOINIT + + if(H5G_loc_real(obj, loc_params.obj_type, &loc) < 0) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, NULL, "not a file or file object") + + /* Open the datatype */ + if(NULL == (type = H5T__open_name(&loc, name))) + HGOTO_ERROR(H5E_DATATYPE, H5E_CANTOPENOBJ, NULL, "unable to open named datatype") + + type->vol_obj = NULL; + + ret_value = (void *)type; + +done: + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5VL_native_datatype_open() */ + + +/*------------------------------------------------------------------------- + * Function: H5VL_native_datatype_get + * + * Purpose: Gets certain information about a datatype + * + * Return: Success: 0 + * Failure: -1 + * + * Programmer: Mohamad Chaarawi + * June, 2013 + * + *------------------------------------------------------------------------- + */ +static herr_t +H5VL_native_datatype_get(void *obj, H5VL_datatype_get_t get_type, + hid_t H5_ATTR_UNUSED dxpl_id, void H5_ATTR_UNUSED **req, va_list arguments) +{ + H5T_t *dt = (H5T_t *)obj; + herr_t ret_value = SUCCEED; /* Return value */ + + FUNC_ENTER_NOAPI_NOINIT + + switch (get_type) { + case H5VL_DATATYPE_GET_BINARY: + { + ssize_t *nalloc = va_arg(arguments, ssize_t *); + void *buf = va_arg(arguments, void *); + size_t size = va_arg(arguments, size_t); + + if(H5T_encode(dt, (unsigned char *)buf, &size) < 0) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "can't determine serialized length of datatype") + + *nalloc = (ssize_t) size; + break; + } + /* H5Tget_create_plist */ + case H5VL_DATATYPE_GET_TCPL: + { + hid_t *ret_id = va_arg(arguments, hid_t *); + + if(H5I_INVALID_HID == (*ret_id = H5T__get_create_plist(dt))) + HGOTO_ERROR(H5E_DATATYPE, H5E_CANTGET, FAIL, "can't get object creation info"); + + break; + } + default: + HGOTO_ERROR(H5E_VOL, H5E_CANTGET, FAIL, "can't get this type of information from datatype") + } + +done: + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5VL_native_datatype_get() */ + + +/*------------------------------------------------------------------------- + * Function: H5VL_native_datatype_specific + * + * Purpose: Specific operations for datatype + * + * Return: SUCCEED/FAIL + * + *------------------------------------------------------------------------- + */ +static herr_t +H5VL_native_datatype_specific(void *obj, H5VL_datatype_specific_t specific_type, + hid_t H5_ATTR_UNUSED dxpl_id, void H5_ATTR_UNUSED **req, va_list arguments) +{ + H5T_t *dt = (H5T_t *)obj; + herr_t ret_value = SUCCEED; /* Return value */ + + FUNC_ENTER_NOAPI_NOINIT + + switch(specific_type) { + case H5VL_DATATYPE_FLUSH: + { + hid_t type_id = va_arg(arguments, hid_t); + + /* To flush metadata and invoke flush callback if there is */ + if (H5O_flush_common(&dt->oloc, type_id) < 0) + HGOTO_ERROR(H5E_DATATYPE, H5E_CANTFLUSH, FAIL, "unable to flush datatype") + + break; + } + case H5VL_DATATYPE_REFRESH: + { + hid_t type_id = va_arg(arguments, hid_t); + + /* Call private function to refresh datatype object */ + if ((H5O_refresh_metadata(type_id, dt->oloc)) < 0) + HGOTO_ERROR(H5E_DATATYPE, H5E_CANTLOAD, FAIL, "unable to refresh datatype") + + break; + } + default: + HGOTO_ERROR(H5E_VOL, H5E_UNSUPPORTED, FAIL, "invalid specific operation") + } + +done: + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5VL_native_datatype_specific() */ + + +/*------------------------------------------------------------------------- + * Function: H5VL_native_datatype_close + * + * Purpose: Closes an datatype. + * + * Return: Success: 0 + * Failure: -1, datatype not closed. + * + * Programmer: Mohamad Chaarawi + * March, 2012 + * + *------------------------------------------------------------------------- + */ +static herr_t +H5VL_native_datatype_close(void *dt, hid_t H5_ATTR_UNUSED dxpl_id, void H5_ATTR_UNUSED **req) +{ + herr_t ret_value = SUCCEED; /* Return value */ + + FUNC_ENTER_NOAPI_NOINIT + + if(H5T_close((H5T_t*)dt) < 0) + HGOTO_ERROR(H5E_SYM, H5E_CANTDEC, FAIL, "can't close datatype") + +done: + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5VL_native_datatype_close() */ + diff --git a/src/H5VLnative.h b/src/H5VLnative.h new file mode 100644 index 0000000..4e33e8a --- /dev/null +++ b/src/H5VLnative.h @@ -0,0 +1,44 @@ +/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * + * Copyright by The HDF Group. * + * All rights reserved. * + * * + * This file is part of HDF5. The full HDF5 copyright notice, including * + * terms governing use, modification, and redistribution, is contained in * + * the COPYING file, which can be found at the root of the source code * + * distribution tree, or in https://support.hdfgroup.org/ftp/HDF5/releases. * + * If you do not have access to either file, you may request a copy from * + * help@hdfgroup.org. * + * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ + +/* + * Purpose: The public header file for the native VOL driver. + */ + +#ifndef _H5VLnative_H +#define _H5VLnative_H + +/* Initializer function for native VOL driver */ +#define H5VL_NATIVE (H5VL_native_init()) + +/* Characteristics of the native VOL driver */ +#define H5VL_NATIVE_NAME "native" +#define H5VL_NATIVE_VALUE H5_VOL_NATIVE /* enum value */ +#define H5VL_NATIVE_VERSION 0 + + +#ifdef __cplusplus +extern "C" { +#endif + +/* XXX (VOL_MERGE): Poor separation of public and private functionality here */ +H5_DLL herr_t H5Pset_fapl_native(hid_t fapl_id); +H5_DLL hid_t H5VL_native_get_driver_id(void); +H5_DLL hid_t H5VL_native_init(void); +H5_DLL hid_t H5VL_native_register(H5I_type_t type, void *obj, hbool_t app_ref); +H5_DLL herr_t H5VL_native_unregister(hid_t obj_id); + +#ifdef __cplusplus +} +#endif + +#endif /* _H5VLnative_H */ diff --git a/src/H5VLpkg.h b/src/H5VLpkg.h new file mode 100644 index 0000000..bbdb0cc --- /dev/null +++ b/src/H5VLpkg.h @@ -0,0 +1,48 @@ +/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * + * Copyright by The HDF Group. * + * All rights reserved. * + * * + * This file is part of HDF5. The full HDF5 copyright notice, including * + * terms governing use, modification, and redistribution, is contained in * + * the COPYING file, which can be found at the root of the source code * + * distribution tree, or in https://support.hdfgroup.org/ftp/HDF5/releases. * + * If you do not have access to either file, you may request a copy from * + * help@hdfgroup.org. * + * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ + +/* + * Purpose: This file contains declarations which are visible only within + * the H5VL package. Source files outside the H5VL package should + * include H5VLprivate.h instead. + */ + +#if !(defined H5VL_FRIEND || defined H5VL_MODULE) +#error "Do not include this file outside the H5VL package!" +#endif + +#ifndef _H5VLpkg_H +#define _H5VLpkg_H + +/* Get package's private header */ +#include "H5VLprivate.h" /* Generic Functions */ + +/* Other private headers needed by this file */ + +/**************************/ +/* Package Private Macros */ +/**************************/ + +/****************************/ +/* Package Private Typedefs */ +/****************************/ + +/*****************************/ +/* Package Private Variables */ +/*****************************/ + +/******************************/ +/* Package Private Prototypes */ +/******************************/ + +#endif /* _H5VLpkg_H */ + diff --git a/src/H5VLprivate.h b/src/H5VLprivate.h new file mode 100644 index 0000000..98be308 --- /dev/null +++ b/src/H5VLprivate.h @@ -0,0 +1,132 @@ +/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * + * Copyright by The HDF Group. * + * All rights reserved. * + * * + * This file is part of HDF5. The full HDF5 copyright notice, including * + * terms governing use, modification, and redistribution, is contained in * + * the COPYING file, which can be found at the root of the source code * + * distribution tree, or in https://support.hdfgroup.org/ftp/HDF5/releases. * + * If you do not have access to either file, you may request a copy from * + * help@hdfgroup.org. * + * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ + +#ifndef _H5VLprivate_H +#define _H5VLprivate_H + +/* Include package's public header */ +#include "H5VLpublic.h" /* Generic Functions */ + +/* Private headers needed by this file */ + +/**************************/ +/* Library Private Macros */ +/**************************/ + +/****************************/ +/* Library Private Typedefs */ +/****************************/ + +/* Internal struct to track VOL driver information for objects */ +typedef struct H5VL_t { + const H5VL_class_t *cls; /* Pointer to driver class struct */ + int64_t nrefs; /* Number of references by objects using this struct */ + hid_t id; /* Identifier for the VOL driver */ +} H5VL_t; + +/* Internal vol object structure returned to the API */ +typedef struct H5VL_object_t { + void *data; /* Pointer to driver-managed data for this object */ + H5VL_t *driver; /* Pointer to VOL driver struct */ +} H5VL_object_t; + +/* Internal structure to hold the driver ID & info for FAPLs */ +typedef struct H5VL_driver_prop_t { + hid_t driver_id; /* VOL driver's ID */ + const void *driver_info; /* VOL driver info, for open callbacks */ +} H5VL_driver_prop_t; + +/*****************************/ +/* Library Private Variables */ +/*****************************/ + +/******************************/ +/* Library Private Prototypes */ +/******************************/ + +/* Common functions */ +H5_DLL herr_t H5VL_init(void); +H5_DLL hid_t H5VL_register_id(H5I_type_t type, void *object, H5VL_t *vol_driver, hbool_t app_ref); +H5_DLL herr_t H5VL_free_object(H5VL_object_t *obj); +H5_DLL hid_t H5VL_register(const void *cls, size_t size, hbool_t app_ref); +H5_DLL hid_t H5VL_object_register(void *obj, H5I_type_t obj_type, hid_t driver_id, hbool_t app_ref); +H5_DLL ssize_t H5VL_get_driver_name(hid_t id, char *name/*out*/, size_t size); +H5_DLL H5VL_object_t *H5VL_get_object(hid_t id); +H5_DLL void *H5VL_object(hid_t id); +H5_DLL void *H5VL_object_verify(hid_t id, H5I_type_t obj_type); +H5_DLL void *H5VL_driver_object(H5VL_object_t *obj); + +/* Attribute functions */ +H5_DLL void *H5VL_attr_create(void *obj, H5VL_loc_params_t loc_params, const H5VL_class_t *cls, const char *attr_name, hid_t acpl_id, hid_t aapl_id, hid_t dxpl_id, void **req); +H5_DLL void *H5VL_attr_open(void *obj, H5VL_loc_params_t loc_params, const H5VL_class_t *cls, const char *name, hid_t aapl_id, hid_t dxpl_id, void **req); +H5_DLL herr_t H5VL_attr_read(void *attr, const H5VL_class_t *cls, hid_t dtype_id, void *buf, hid_t dxpl_id, void **req); +H5_DLL herr_t H5VL_attr_write(void *attr, const H5VL_class_t *cls, hid_t dtype_id, const void *buf, hid_t dxpl_id, void **req); +H5_DLL herr_t H5VL_attr_get(void *obj, const H5VL_class_t *cls, H5VL_attr_get_t get_type, hid_t dxpl_id, void **req, ...); +H5_DLL herr_t H5VL_attr_specific(void *obj, H5VL_loc_params_t loc_params, const H5VL_class_t *cls, H5VL_attr_specific_t specific_type, hid_t dxpl_id, void **req, ...); +H5_DLL herr_t H5VL_attr_optional(void *obj, const H5VL_class_t *cls, hid_t dxpl_id, void **req, ...); +H5_DLL herr_t H5VL_attr_close(void *attr, const H5VL_class_t *cls, hid_t dxpl_id, void **req); + +/* Dataset functions */ +H5_DLL void *H5VL_dataset_create(void *obj, H5VL_loc_params_t loc_params, const H5VL_class_t *cls, const char *name, hid_t dcpl_id, hid_t dapl_id, hid_t dxpl_id, void **req); +H5_DLL void *H5VL_dataset_open(void *obj, H5VL_loc_params_t loc_params, const H5VL_class_t *cls, const char *name, hid_t dapl_id, hid_t dxpl_id, void **req); +H5_DLL herr_t H5VL_dataset_read(void *dset, const H5VL_class_t *cls, hid_t mem_type_id, hid_t mem_space_id, hid_t file_space_id, hid_t plist_id, void *buf, void **req); +H5_DLL herr_t H5VL_dataset_write(void *dset, const H5VL_class_t *cls, hid_t mem_type_id, hid_t mem_space_id, hid_t file_space_id, hid_t plist_id, const void *buf, void **req); +H5_DLL herr_t H5VL_dataset_get(void *dset, const H5VL_class_t *cls, H5VL_dataset_get_t get_type, hid_t dxpl_id, void **req, ...); +H5_DLL herr_t H5VL_dataset_specific(void *obj, const H5VL_class_t *cls, H5VL_dataset_specific_t specific_type, hid_t dxpl_id, void **req, ...); +H5_DLL herr_t H5VL_dataset_optional(void *obj, const H5VL_class_t *cls, hid_t dxpl_id, void **req, ...); +H5_DLL herr_t H5VL_dataset_close(void *dset, const H5VL_class_t *cls, hid_t dxpl_id, void **req); + +/* File functions */ +H5_DLL void *H5VL_file_create(const H5VL_class_t *cls, const char *name, unsigned flags, hid_t fcpl_id, hid_t fapl_id, hid_t dxpl_id, void **req); +H5_DLL void *H5VL_file_open(const H5VL_class_t *cls, const char *name, unsigned flags, hid_t fapl_id, hid_t dxpl_id, void **req); +H5_DLL herr_t H5VL_file_get(void *file, const H5VL_class_t *cls, H5VL_file_get_t get_type, hid_t dxpl_id, void **req, ...); +H5_DLL herr_t H5VL_file_specific(void *obj, const H5VL_class_t *cls, H5VL_file_specific_t specific_type, hid_t dxpl_id, void **req, ...); +H5_DLL herr_t H5VL_file_optional(void *obj, const H5VL_class_t *cls, hid_t dxpl_id, void **req, ...); +H5_DLL herr_t H5VL_file_close(void *file, const H5VL_class_t *cls, hid_t dxpl_id, void **req); + +/* Group functions */ +H5_DLL void *H5VL_group_create(void *obj, H5VL_loc_params_t loc_params, const H5VL_class_t *cls, const char *name, hid_t gcpl_id, hid_t gapl_id, hid_t dxpl_id, void **req); +H5_DLL void *H5VL_group_open(void *obj, H5VL_loc_params_t loc_params, const H5VL_class_t *cls, const char *name, hid_t gapl_id, hid_t dxpl_id, void **req); +H5_DLL herr_t H5VL_group_get(void *obj, const H5VL_class_t *cls, H5VL_group_get_t get_type, hid_t dxpl_id, void **req, ...); +H5_DLL herr_t H5VL_group_specific(void *obj, const H5VL_class_t *cls, H5VL_group_specific_t specific_type, hid_t dxpl_id, void **req, ...); +H5_DLL herr_t H5VL_group_optional(void *obj, const H5VL_class_t *cls, hid_t dxpl_id, void **req, ...); +H5_DLL herr_t H5VL_group_close(void *grp, const H5VL_class_t *cls, hid_t dxpl_id, void **req); + +/* Link functions */ +H5_DLL herr_t H5VL_link_create(H5VL_link_create_type_t create_type, void *obj, H5VL_loc_params_t loc_params, const H5VL_class_t *cls, hid_t lcpl_id, hid_t lapl_id, hid_t dxpl_id, void **req); +H5_DLL herr_t H5VL_link_copy(void *src_obj, H5VL_loc_params_t loc_params1, void *dst_obj, H5VL_loc_params_t loc_params2, const H5VL_class_t *cls, hid_t lcpl_id, hid_t lapl_id, hid_t dxpl_id, void **req); +H5_DLL herr_t H5VL_link_move(void *src_obj, H5VL_loc_params_t loc_params1, void *dst_obj, H5VL_loc_params_t loc_params2, const H5VL_class_t *cls, hid_t lcpl_id, hid_t lapl_id, hid_t dxpl_id, void **req); +H5_DLL herr_t H5VL_link_get(void *obj, H5VL_loc_params_t loc_params, const H5VL_class_t *cls, H5VL_link_get_t get_type, hid_t dxpl_id, void **req, ...); +H5_DLL herr_t H5VL_link_specific(void *obj, H5VL_loc_params_t loc_params, const H5VL_class_t *cls, H5VL_link_specific_t specific_type, hid_t dxpl_id, void **req, ...); +H5_DLL herr_t H5VL_link_optional(void *obj, const H5VL_class_t *cls, hid_t dxpl_id, void **req, ...); + +/* Object functions */ +H5_DLL void *H5VL_object_open(void *obj, H5VL_loc_params_t loc_params, const H5VL_class_t *cls, H5I_type_t *opened_type, hid_t dxpl_id, void **req); +H5_DLL herr_t H5VL_object_copy(void *src_obj, H5VL_loc_params_t loc_params1, const H5VL_class_t *cls1, const char *src_name, void *dst_obj, H5VL_loc_params_t loc_params2, const H5VL_class_t *cls2, const char *dst_name, hid_t ocpypl_id, hid_t lcpl_id, hid_t dxpl_id, void **req); +H5_DLL herr_t H5VL_object_get(void *obj, H5VL_loc_params_t loc_params, const H5VL_class_t *cls, H5VL_object_get_t get_type, hid_t dxpl_id, void **req, ...); +H5_DLL herr_t H5VL_object_specific(void *obj, H5VL_loc_params_t loc_params, const H5VL_class_t *cls, H5VL_object_specific_t specific_type, hid_t dxpl_id, void **req, ...); +H5_DLL herr_t H5VL_object_optional(void *obj, const H5VL_class_t *cls, hid_t dxpl_id, void **req, ...); + +/* Datatype functions */ +H5_DLL void *H5VL_datatype_commit(void *obj, H5VL_loc_params_t loc_params, const H5VL_class_t *cls, const char *name, hid_t type_id, hid_t lcpl_id, hid_t tcpl_id, hid_t tapl_id, hid_t dxpl_id, void **req); +H5_DLL void *H5VL_datatype_open(void *obj, H5VL_loc_params_t loc_params, const H5VL_class_t *cls, const char *name, hid_t tapl_id, hid_t dxpl_id, void **req); +H5_DLL herr_t H5VL_datatype_get(void *dt, const H5VL_class_t *cls, H5VL_datatype_get_t get_type, hid_t dxpl_id, void **req, ...); +H5_DLL herr_t H5VL_datatype_specific(void *obj, const H5VL_class_t *cls, H5VL_datatype_specific_t specific_type, hid_t dxpl_id, void **req, ...); +H5_DLL herr_t H5VL_datatype_optional(void *obj, const H5VL_class_t *cls, hid_t dxpl_id, void **req, ...); +H5_DLL herr_t H5VL_datatype_close(void *dt, const H5VL_class_t *cls, hid_t dxpl_id, void **req); + +/* Asynchronous functions */ +H5_DLL herr_t H5VL_request_cancel(void **req, const H5VL_class_t *cls, H5ES_status_t *status); +H5_DLL herr_t H5VL_request_test(void **req, const H5VL_class_t *cls, H5ES_status_t *status); +H5_DLL herr_t H5VL_request_wait(void **req, const H5VL_class_t *cls, H5ES_status_t *status); +#endif /* _H5VLprivate_H */ + diff --git a/src/H5VLpublic.h b/src/H5VLpublic.h new file mode 100644 index 0000000..d118bcc --- /dev/null +++ b/src/H5VLpublic.h @@ -0,0 +1,498 @@ +/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * + * Copyright by The HDF Group. * + * All rights reserved. * + * * + * This file is part of HDF5. The full HDF5 copyright notice, including * + * terms governing use, modification, and redistribution, is contained in * + * the COPYING file, which can be found at the root of the source code * + * distribution tree, or in https://support.hdfgroup.org/ftp/HDF5/releases. * + * If you do not have access to either file, you may request a copy from * + * help@hdfgroup.org. * + * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ + +/* + * This file contains public declarations for the H5VL (VOL) module. + */ + +#ifndef _H5VLpublic_H +#define _H5VLpublic_H + +/* Public headers needed by this file */ +#include "H5public.h" /* Generic Functions */ +#include "H5Apublic.h" /* Attributes */ +#include "H5ESpublic.h" /* Event Stack */ +#include "H5Fpublic.h" /* Files */ +#include "H5Lpublic.h" /* Links */ +#include "H5Opublic.h" /* Objects */ +#include "H5Rpublic.h" /* References */ + + +/*****************/ +/* Public Macros */ +/*****************/ + +/* Dataset creation property names */ +#define H5VL_PROP_DSET_TYPE_ID "dataset_type_id" +#define H5VL_PROP_DSET_SPACE_ID "dataset_space_id" +#define H5VL_PROP_DSET_LCPL_ID "dataset_lcpl_id" + +/* Attribute creation property names */ +#define H5VL_PROP_ATTR_TYPE_ID "attr_type_id" +#define H5VL_PROP_ATTR_SPACE_ID "attr_space_id" +#define H5VL_PROP_ATTR_LOC_PARAMS "attr_location" + +/* Link creation property names */ +#define H5VL_PROP_LINK_TARGET "target_location_object" +#define H5VL_PROP_LINK_TARGET_LOC_PARAMS "target_params" +#define H5VL_PROP_LINK_TARGET_NAME "target_name" +#define H5VL_PROP_LINK_TYPE "link type" +#define H5VL_PROP_LINK_UDATA "udata" +#define H5VL_PROP_LINK_UDATA_SIZE "udata size" + +/* Group creation property names */ +#define H5VL_PROP_GRP_LCPL_ID "group_lcpl_id" + +/* Default VOL driver value */ +#define H5VL_VOL_DEFAULT 0 + + +/*******************/ +/* Public Typedefs */ +/*******************/ + +/* types for attribute GET callback */ +typedef enum H5VL_attr_get_t { + H5VL_ATTR_GET_ACPL, /* creation property list */ + H5VL_ATTR_GET_INFO, /* info */ + H5VL_ATTR_GET_NAME, /* access property list */ + H5VL_ATTR_GET_SPACE, /* dataspace */ + H5VL_ATTR_GET_STORAGE_SIZE, /* storage size */ + H5VL_ATTR_GET_TYPE /* datatype */ +} H5VL_attr_get_t; + +/* types for attribute SPECFIC callback */ +typedef enum H5VL_attr_specific_t { + H5VL_ATTR_DELETE, /* H5Adelete(_by_name/idx) */ + H5VL_ATTR_EXISTS, /* H5Aexists(_by_name) */ + H5VL_ATTR_ITER, /* H5Aiterate(_by_name) */ + H5VL_ATTR_RENAME /* H5Arename(_by_name) */ +} H5VL_attr_specific_t; + +/* types for dataset GET callback */ +typedef enum H5VL_dataset_get_t { + H5VL_DATASET_GET_DAPL, /* access property list */ + H5VL_DATASET_GET_DCPL, /* creation property list */ + H5VL_DATASET_GET_OFFSET, /* offset */ + H5VL_DATASET_GET_SPACE, /* dataspace */ + H5VL_DATASET_GET_SPACE_STATUS, /* space status */ + H5VL_DATASET_GET_STORAGE_SIZE, /* storage size */ + H5VL_DATASET_GET_TYPE /* datatype */ +} H5VL_dataset_get_t; + +/* types for dataset SPECFIC callback */ +typedef enum H5VL_dataset_specific_t { + H5VL_DATASET_SET_EXTENT, /* H5Dset_extent */ + H5VL_DATASET_FLUSH, /* H5Dflush */ + H5VL_DATASET_REFRESH /* H5Drefresh */ +} H5VL_dataset_specific_t; + +/* types for datatype GET callback */ +typedef enum H5VL_datatype_get_t { + H5VL_DATATYPE_GET_BINARY, /* get serialized form of transient type */ + H5VL_DATATYPE_GET_TCPL /* datatype creation property list */ +} H5VL_datatype_get_t; + +/* types for datatype SPECFIC callback */ +typedef enum H5VL_datatype_specific_t { + H5VL_DATATYPE_FLUSH, + H5VL_DATATYPE_REFRESH +} H5VL_datatype_specific_t; + +/* types for file GET callback */ +typedef enum H5VL_file_get_t { + H5VL_FILE_GET_FAPL, /* file access property list */ + H5VL_FILE_GET_FCPL, /* file creation property list */ + H5VL_FILE_GET_INTENT, /* file intent */ + H5VL_FILE_GET_NAME, /* file name */ + H5VL_FILE_GET_OBJ_COUNT, /* object count in file */ + H5VL_FILE_GET_OBJ_IDS, /* object ids in file */ + H5VL_OBJECT_GET_FILE /* retrieve or resurrect file of object */ +} H5VL_file_get_t; + +/* types for file SPECIFIC callback */ +typedef enum H5VL_file_specific_t { + H5VL_FILE_FLUSH, /* Flush file */ + H5VL_FILE_IS_ACCESSIBLE, /* Check if a file is accessible */ + H5VL_FILE_MOUNT, /* Mount a file */ + H5VL_FILE_UNMOUNT /* Un-Mount a file */ +} H5VL_file_specific_t; + +/* types for group GET callback */ +typedef enum H5VL_group_get_t { + H5VL_GROUP_GET_GCPL, /* group creation property list */ + H5VL_GROUP_GET_INFO /* group info */ +} H5VL_group_get_t; + +/* types for group SPECFIC callback */ +typedef enum H5VL_group_specific_t { + H5VL_GROUP_FLUSH, + H5VL_GROUP_REFRESH +} H5VL_group_specific_t; + +/* link create types for VOL */ +typedef enum H5VL_link_create_type_t { + H5VL_LINK_CREATE_HARD, + H5VL_LINK_CREATE_SOFT, + H5VL_LINK_CREATE_UD +} H5VL_link_create_type_t; + +/* types for link GET callback */ +typedef enum H5VL_link_get_t { + H5VL_LINK_GET_INFO, /* link info */ + H5VL_LINK_GET_NAME, /* link name */ + H5VL_LINK_GET_VAL /* link value */ +} H5VL_link_get_t; + +/* types for link SPECIFIC callback */ +typedef enum H5VL_link_specific_t { + H5VL_LINK_DELETE, /* H5Ldelete(_by_idx) */ + H5VL_LINK_EXISTS, /* link existence */ + H5VL_LINK_ITER /* H5Literate/visit(_by_name) */ +} H5VL_link_specific_t; + +/* types for object GET callback */ +typedef enum H5VL_object_get_t { + H5VL_REF_GET_NAME, /* object name */ + H5VL_REF_GET_REGION, /* dataspace of region */ + H5VL_REF_GET_TYPE /* type of object */ +} H5VL_object_get_t; + +/* types for object SPECIFIC callback */ +typedef enum H5VL_object_specific_t { + H5VL_OBJECT_CHANGE_REF_COUNT, /* H5Oincr/decr_refcount */ + H5VL_OBJECT_EXISTS, /* H5Oexists_by_name */ + H5VL_OBJECT_VISIT, /* H5Ovisit(_by_name) */ + H5VL_REF_CREATE, /* H5Rcreate */ + H5VL_OBJECT_FLUSH, + H5VL_OBJECT_REFRESH +} H5VL_object_specific_t; + +/* types for different ways that objects are located in an HDF5 container */ +typedef enum H5VL_loc_type_t { + H5VL_OBJECT_BY_SELF, + H5VL_OBJECT_BY_NAME, + H5VL_OBJECT_BY_IDX, + H5VL_OBJECT_BY_ADDR, + H5VL_OBJECT_BY_REF +} H5VL_loc_type_t; + +struct H5VL_loc_by_name { + const char *name; + hid_t lapl_id; +}; + +struct H5VL_loc_by_idx { + const char *name; + H5_index_t idx_type; + H5_iter_order_t order; + hsize_t n; + hid_t lapl_id; +}; + +struct H5VL_loc_by_addr { + haddr_t addr; +}; + +struct H5VL_loc_by_ref { + H5R_type_t ref_type; + const void *_ref; + hid_t lapl_id; +}; + +/* Structure to hold parameters for object locations. + * either: BY_ADDR, BY_ID, BY_NAME, BY_IDX, BY_REF + * + * Note: Leave loc_by_addr as the first union member so we + * can perform the simplest initialization of the struct + * without raising warnings. + */ +typedef struct H5VL_loc_params_t { + H5I_type_t obj_type; + H5VL_loc_type_t type; + union{ + struct H5VL_loc_by_addr loc_by_addr; + struct H5VL_loc_by_name loc_by_name; + struct H5VL_loc_by_idx loc_by_idx; + struct H5VL_loc_by_ref loc_by_ref; + } loc_data; +} H5VL_loc_params_t; + +/* H5A routines */ +typedef struct H5VL_attr_class_t { + void *(*create)(void *obj, H5VL_loc_params_t loc_params, const char *attr_name, + hid_t acpl_id, hid_t aapl_id, hid_t dxpl_id, void **req); + void *(*open)(void *obj, H5VL_loc_params_t loc_params, const char *attr_name, + hid_t aapl_id, hid_t dxpl_id, void **req); + herr_t (*read)(void *attr, hid_t mem_type_id, void *buf, hid_t dxpl_id, void **req); + herr_t (*write)(void *attr, hid_t mem_type_id, const void *buf, hid_t dxpl_id, void **req); + herr_t (*get)(void *obj, H5VL_attr_get_t get_type, hid_t dxpl_id, void **req, va_list arguments); + herr_t (*specific)(void *obj, H5VL_loc_params_t loc_params, H5VL_attr_specific_t specific_type, + hid_t dxpl_id, void **req, va_list arguments); + herr_t (*optional)(void *obj, hid_t dxpl_id, void **req, va_list arguments); + herr_t (*close) (void *attr, hid_t dxpl_id, void **req); +} H5VL_attr_class_t; + +/* H5D routines */ +typedef struct H5VL_dataset_class_t { + void *(*create)(void *obj, H5VL_loc_params_t loc_params, const char *name, + hid_t dcpl_id, hid_t dapl_id, hid_t dxpl_id, void **req); + void *(*open)(void *obj, H5VL_loc_params_t loc_params, const char *name, + hid_t dapl_id, hid_t dxpl_id, void **req); + herr_t (*read)(void *dset, hid_t mem_type_id, hid_t mem_space_id, hid_t file_space_id, + hid_t xfer_plist_id, void * buf, void **req); + herr_t (*write)(void *dset, hid_t mem_type_id, hid_t mem_space_id, hid_t file_space_id, + hid_t xfer_plist_id, const void * buf, void **req); + herr_t (*get)(void *obj, H5VL_dataset_get_t get_type, hid_t dxpl_id, void **req, va_list arguments); + herr_t (*specific)(void *obj, H5VL_dataset_specific_t specific_type, + hid_t dxpl_id, void **req, va_list arguments); + herr_t (*optional)(void *obj, hid_t dxpl_id, void **req, va_list arguments); + herr_t (*close) (void *dset, hid_t dxpl_id, void **req); +} H5VL_dataset_class_t; + +/* H5T routines*/ +typedef struct H5VL_datatype_class_t { + void *(*commit)(void *obj, H5VL_loc_params_t loc_params, const char *name, hid_t type_id, + hid_t lcpl_id, hid_t tcpl_id, hid_t tapl_id, hid_t dxpl_id, void **req); + void *(*open)(void *obj, H5VL_loc_params_t loc_params, const char * name, + hid_t tapl_id, hid_t dxpl_id, void **req); + herr_t (*get) (void *obj, H5VL_datatype_get_t get_type, hid_t dxpl_id, void **req, va_list arguments); + herr_t (*specific)(void *obj, H5VL_datatype_specific_t specific_type, + hid_t dxpl_id, void **req, va_list arguments); + herr_t (*optional)(void *obj, hid_t dxpl_id, void **req, va_list arguments); + herr_t (*close) (void *dt, hid_t dxpl_id, void **req); +} H5VL_datatype_class_t; + +/* H5F routines */ +typedef struct H5VL_file_class_t { + void *(*create)(const char *name, unsigned flags, hid_t fcpl_id, + hid_t fapl_id, hid_t dxpl_id, void **req); + void *(*open)(const char *name, unsigned flags, hid_t fapl_id, hid_t dxpl_id, void **req); + herr_t (*get)(void *obj, H5VL_file_get_t get_type, hid_t dxpl_id, void **req, va_list arguments); + herr_t (*specific)(void *obj, H5VL_file_specific_t specific_type, + hid_t dxpl_id, void **req, va_list arguments); + herr_t (*optional)(void *obj, hid_t dxpl_id, void **req, va_list arguments); + herr_t (*close) (void *file, hid_t dxpl_id, void **req); +} H5VL_file_class_t; + +/* H5G routines */ +typedef struct H5VL_group_class_t { + void *(*create)(void *obj, H5VL_loc_params_t loc_params, const char *name, + hid_t gcpl_id, hid_t gapl_id, hid_t dxpl_id, void **req); + void *(*open)(void *obj, H5VL_loc_params_t loc_params, const char *name, + hid_t gapl_id, hid_t dxpl_id, void **req); + herr_t (*get)(void *obj, H5VL_group_get_t get_type, hid_t dxpl_id, void **req, va_list arguments); + herr_t (*specific)(void *obj, H5VL_group_specific_t specific_type, + hid_t dxpl_id, void **req, va_list arguments); + herr_t (*optional)(void *obj, hid_t dxpl_id, void **req, va_list arguments); + herr_t (*close) (void *grp, hid_t dxpl_id, void **req); +} H5VL_group_class_t; + +/* H5L routines */ +typedef struct H5VL_link_class_t { + herr_t (*create)(H5VL_link_create_type_t create_type, void *obj, H5VL_loc_params_t loc_params, + hid_t lcpl_id, hid_t lapl_id, hid_t dxpl_id, void **req); + herr_t (*copy)(void *src_obj, H5VL_loc_params_t loc_params1, + void *dst_obj, H5VL_loc_params_t loc_params2, + hid_t lcpl, hid_t lapl, hid_t dxpl_id, void **req); + herr_t (*move)(void *src_obj, H5VL_loc_params_t loc_params1, + void *dst_obj, H5VL_loc_params_t loc_params2, + hid_t lcpl, hid_t lapl, hid_t dxpl_id, void **req); + herr_t (*get)(void *obj, H5VL_loc_params_t loc_params, H5VL_link_get_t get_type, + hid_t dxpl_id, void **req, va_list arguments); + herr_t (*specific)(void *obj, H5VL_loc_params_t loc_params, H5VL_link_specific_t specific_type, + hid_t dxpl_id, void **req, va_list arguments); + herr_t (*optional)(void *obj, hid_t dxpl_id, void **req, va_list arguments); +} H5VL_link_class_t; + +/* H5O routines */ +typedef struct H5VL_object_class_t { + void *(*open)(void *obj, H5VL_loc_params_t loc_params, H5I_type_t *opened_type, + hid_t dxpl_id, void **req); + herr_t (*copy)(void *src_obj, H5VL_loc_params_t loc_params1, const char *src_name, + void *dst_obj, H5VL_loc_params_t loc_params2, const char *dst_name, + hid_t ocpypl_id, hid_t lcpl_id, hid_t dxpl_id, void **req); + herr_t (*get)(void *obj, H5VL_loc_params_t loc_params, H5VL_object_get_t get_type, + hid_t dxpl_id, void **req, va_list arguments); + herr_t (*specific)(void *obj, H5VL_loc_params_t loc_params, H5VL_object_specific_t specific_type, + hid_t dxpl_id, void **req, va_list arguments); + herr_t (*optional)(void *obj, hid_t dxpl_id, void **req, va_list arguments); +} H5VL_object_class_t; + +/* H5AO routines */ +typedef struct H5VL_async_class_t { + herr_t (*cancel)(void **, H5ES_status_t *); + herr_t (*test) (void **, H5ES_status_t *); + herr_t (*wait) (void **, H5ES_status_t *); +} H5VL_async_class_t; + +/* VOL category (internal, external, etc.) + * XXX: This is intended to replace the H5VL_class_value_t struct, which seems + * difficult to manage. It's currently unused so I don't break struct + * compatibility with existing VOLs. + */ +typedef enum H5VL_category_t { + H5VL_INTERNAL, /* Internal VOL driver */ + H5VL_EXTERNAL /* External VOL driver (plugin) */ +} H5VL_category_t; + +/* enum value to identify the class of a VOL driver (mostly for comparison purposes) */ +typedef enum H5VL_class_value_t { + H5_VOL_NATIVE = 0, /* This should be first */ + H5_VOL_MAX_LIB_VALUE = 128 /* This should be last */ +} H5VL_class_value_t; + +/* Class information for each VOL driver */ +/* XXX: We should consider adding a UUID/GUID field to this struct + * as well as a H5VLregister_by_uuid() API call for people who + * really care about getting a particular VOL driver. + * XXX: We should also consider adding enough information so that + * files can be opened without specifying the VOL driver. + * e.g.: If we stored a UUID and version, we could search for + * a matching VOL driver so a user did not have to make any + * H5VL calls. + */ +typedef struct H5VL_class_t { + /* XXX: How do we identify unique VOL drivers? + * This is unclear, but for now we'll keep + * all the ID fields from the original VOL + * branch. + */ + unsigned int version; /* VOL driver version # + * XXX: Is this supposed to be a VOL driver + * version number or a VOL API version + * number? Maybe we need both? + */ + H5VL_class_value_t value; /* value to identify driver */ + const char *name; /* Plugin name (MUST be unique!) */ + herr_t (*initialize)(hid_t vipl_id); /* Plugin initialization callback */ + herr_t (*terminate)(hid_t vtpl_id); /* Plugin termination callback */ + size_t fapl_size; /* size of the vol info in the fapl property */ + void * (*fapl_copy)(const void *info); /* callback to create a copy of the vol info */ + herr_t (*fapl_free)(void *info); /* callback to release the vol info copy */ + + /* Data Model */ + H5VL_attr_class_t attr_cls; /* attribute class callbacks */ + H5VL_dataset_class_t dataset_cls; /* dataset class callbacks */ + H5VL_datatype_class_t datatype_cls; /* datatype class callbacks */ + H5VL_file_class_t file_cls; /* file class callbacks */ + H5VL_group_class_t group_cls; /* group class callbacks */ + H5VL_link_class_t link_cls; /* link class callbacks */ + H5VL_object_class_t object_cls; /* object class callbacks */ + + /* Services */ + H5VL_async_class_t async_cls; /* asynchronous class callbacks */ + herr_t (*optional)(void *obj, hid_t dxpl_id, void **req, va_list arguments); /* Optional callback */ +} H5VL_class_t; + + +/********************/ +/* Public Variables */ +/********************/ + +/*********************/ +/* Public Prototypes */ +/*********************/ + +#ifdef __cplusplus +extern "C" { +#endif + +/* VOL Driver/Plugin Functionality */ +H5_DLL herr_t H5VLinitialize(hid_t driver_id, hid_t vipl_id); +H5_DLL herr_t H5VLterminate(hid_t driver_id, hid_t vtpl_id); +H5_DLL herr_t H5VLclose(hid_t driver_id); +H5_DLL hid_t H5VLregister(const H5VL_class_t *cls); +H5_DLL hid_t H5VLregister_by_name(const char *driver_name); +H5_DLL herr_t H5VLunregister(hid_t driver_id); +H5_DLL htri_t H5VLis_registered(const char *name); +H5_DLL hid_t H5VLget_driver_id(const char *name); +H5_DLL ssize_t H5VLget_driver_name(hid_t id, char *name/*out*/, size_t size); +H5_DLL hid_t H5VLobject_register(void *obj, H5I_type_t obj_type, hid_t driver_id); +H5_DLL void *H5VLobject(hid_t id); +H5_DLL herr_t H5VLget_object(hid_t obj_id, void **obj); + +/* Attributes */ +H5_DLL void *H5VLattr_create(void *obj, H5VL_loc_params_t loc_params, hid_t driver_id, const char *attr_name, hid_t acpl_id, hid_t aapl_id, hid_t dxpl_id, void **req); +H5_DLL void *H5VLattr_open(void *obj, H5VL_loc_params_t loc_params, hid_t driver_id, const char *name, hid_t aapl_id, hid_t dxpl_id, void **req); +H5_DLL herr_t H5VLattr_read(void *attr, hid_t driver_id, hid_t dtype_id, void *buf, hid_t dxpl_id, void **req); +H5_DLL herr_t H5VLattr_write(void *attr, hid_t driver_id, hid_t dtype_id, const void *buf, hid_t dxpl_id, void **req); +H5_DLL herr_t H5VLattr_get(void *obj, hid_t driver_id, H5VL_attr_get_t get_type, hid_t dxpl_id, void **req, va_list arguments); +H5_DLL herr_t H5VLattr_specific(void *obj, H5VL_loc_params_t loc_params, hid_t driver_id, H5VL_attr_specific_t specific_type, hid_t dxpl_id, void **req, va_list arguments); +H5_DLL herr_t H5VLattr_optional(void *obj, hid_t driver_id, hid_t dxpl_id, void **req, va_list arguments); +H5_DLL herr_t H5VLattr_close(void *attr, hid_t driver_id, hid_t dxpl_id, void **req); + +/* Datasets */ +H5_DLL void *H5VLdataset_create(void *obj, H5VL_loc_params_t loc_params, hid_t driver_id, const char *name, hid_t dcpl_id, hid_t dapl_id, hid_t dxpl_id, void **req); +H5_DLL void *H5VLdataset_open(void *obj, H5VL_loc_params_t loc_params, hid_t driver_id, const char *name, hid_t dapl_id, hid_t dxpl_id, void **req); +H5_DLL herr_t H5VLdataset_read(void *dset, hid_t driver_id, hid_t mem_type_id, hid_t mem_space_id, hid_t file_space_id, hid_t plist_id, void *buf, void **req); +H5_DLL herr_t H5VLdataset_write(void *dset, hid_t driver_id, hid_t mem_type_id, hid_t mem_space_id, hid_t file_space_id, hid_t plist_id, const void *buf, void **req); +H5_DLL herr_t H5VLdataset_get(void *dset, hid_t driver_id, H5VL_dataset_get_t get_type, hid_t dxpl_id, void **req, va_list arguments); +H5_DLL herr_t H5VLdataset_specific(void *obj, hid_t driver_id, H5VL_dataset_specific_t specific_type, hid_t dxpl_id, void **req, va_list arguments); +H5_DLL herr_t H5VLdataset_optional(void *obj, hid_t driver_id, hid_t dxpl_id, void **req, va_list arguments); +H5_DLL herr_t H5VLdataset_close(void *dset, hid_t driver_id, hid_t dxpl_id, void **req); + +/* Files */ +H5_DLL void *H5VLfile_create(const char *name, unsigned flags, hid_t fcpl_id, hid_t fapl_id, hid_t dxpl_id, void **req); +H5_DLL void *H5VLfile_open(const char *name, unsigned flags, hid_t fapl_id, hid_t dxpl_id, void **req); +H5_DLL herr_t H5VLfile_get(void *file, hid_t driver_id, H5VL_file_get_t get_type, hid_t dxpl_id, void **req, va_list arguments); +H5_DLL herr_t H5VLfile_specific(void *obj, hid_t driver_id, H5VL_file_specific_t specific_type, hid_t dxpl_id, void **req, va_list arguments); +H5_DLL herr_t H5VLfile_optional(void *obj, hid_t driver_id, hid_t dxpl_id, void **req, va_list arguments); +H5_DLL herr_t H5VLfile_close(void *file, hid_t driver_id, hid_t dxpl_id, void **req); + +/* Groups */ +H5_DLL void *H5VLgroup_create(void *obj, H5VL_loc_params_t loc_params, hid_t driver_id, const char *name, hid_t gcpl_id, hid_t gapl_id, hid_t dxpl_id, void **req); +H5_DLL void *H5VLgroup_open(void *obj, H5VL_loc_params_t loc_params, hid_t driver_id, const char *name, hid_t gapl_id, hid_t dxpl_id, void **req); +H5_DLL herr_t H5VLgroup_get(void *obj, hid_t driver_id, H5VL_group_get_t get_type, hid_t dxpl_id, void **req, va_list arguments); +H5_DLL herr_t H5VLgroup_specific(void *obj, hid_t driver_id, H5VL_group_specific_t specific_type, hid_t dxpl_id, void **req, va_list arguments); +H5_DLL herr_t H5VLgroup_optional(void *obj, hid_t driver_id, hid_t dxpl_id, void **req, va_list arguments); +H5_DLL herr_t H5VLgroup_close(void *grp, hid_t driver_id, hid_t dxpl_id, void **req); + +/* Links */ +H5_DLL herr_t H5VLlink_create(H5VL_link_create_type_t create_type, void *obj, H5VL_loc_params_t loc_params, hid_t driver_id, hid_t lcpl_id, hid_t lapl_id, hid_t dxpl_id, void **req); +H5_DLL herr_t H5VLlink_copy(void *src_obj, H5VL_loc_params_t loc_params1, + void *dst_obj, H5VL_loc_params_t loc_params2, hid_t driver_id, + hid_t lcpl_id, hid_t lapl_id, hid_t dxpl_id, void **req); +H5_DLL herr_t H5VLlink_move(void *src_obj, H5VL_loc_params_t loc_params1, + void *dst_obj, H5VL_loc_params_t loc_params2, hid_t driver_id, + hid_t lcpl_id, hid_t lapl_id, hid_t dxpl_id, void **req); +H5_DLL herr_t H5VLlink_get(void *obj, H5VL_loc_params_t loc_params, hid_t driver_id, H5VL_link_get_t get_type, hid_t dxpl_id, void **req, va_list arguments); +H5_DLL herr_t H5VLlink_specific(void *obj, H5VL_loc_params_t loc_params, hid_t driver_id, H5VL_link_specific_t specific_type, hid_t dxpl_id, void **req, va_list arguments); +H5_DLL herr_t H5VLlink_optional(void *obj, hid_t driver_id, hid_t dxpl_id, void **req, va_list arguments); + +/* Objects */ +H5_DLL void *H5VLobject_open(void *obj, H5VL_loc_params_t loc_params, hid_t driver_id, H5I_type_t *opened_type, hid_t dxpl_id, void **req); +H5_DLL herr_t H5VLobject_copy(void *src_obj, H5VL_loc_params_t loc_params1, hid_t driver_id1, const char *src_name, + void *dst_obj, H5VL_loc_params_t loc_params2, hid_t driver_id2, const char *dst_name, + hid_t ocpypl_id, hid_t lcpl_id, hid_t dxpl_id, void **req); +H5_DLL herr_t H5VLobject_get(void *obj, H5VL_loc_params_t loc_params, hid_t driver_id, H5VL_object_get_t get_type, hid_t dxpl_id, void **req, va_list arguments); +H5_DLL herr_t H5VLobject_specific(void *obj, H5VL_loc_params_t loc_params, hid_t driver_id, H5VL_object_specific_t specific_type, hid_t dxpl_id, void **req, va_list arguments); +H5_DLL herr_t H5VLobject_optional(void *obj, hid_t driver_id, hid_t dxpl_id, void **req, va_list arguments); + +/* Datatypes */ +H5_DLL void *H5VLdatatype_commit(void *obj, H5VL_loc_params_t loc_params, hid_t driver_id, const char *name, hid_t type_id, hid_t lcpl_id, hid_t tcpl_id, hid_t tapl_id, hid_t dxpl_id, void **req); +H5_DLL void *H5VLdatatype_open(void *obj, H5VL_loc_params_t loc_params, hid_t driver_id, const char *name, hid_t tapl_id, hid_t dxpl_id, void **req); +H5_DLL herr_t H5VLdatatype_get(void *dt, hid_t driver_id, H5VL_datatype_get_t get_type, hid_t dxpl_id, void **req, va_list arguments); +H5_DLL herr_t H5VLdatatype_specific(void *obj, hid_t driver_id, H5VL_datatype_specific_t specific_type, hid_t dxpl_id, void **req, va_list arguments); +H5_DLL herr_t H5VLdatatype_optional(void *obj, hid_t driver_id, hid_t dxpl_id, void **req, va_list arguments); +H5_DLL herr_t H5VLdatatype_close(void *dt, hid_t driver_id, hid_t dxpl_id, void **req); + +/* Asynchronous Requests */ +H5_DLL herr_t H5VLrequest_cancel(void **req, hid_t driver_id, H5ES_status_t *status); +H5_DLL herr_t H5VLrequest_test(void **req, hid_t driver_id, H5ES_status_t *status); +H5_DLL herr_t H5VLrequest_wait(void **req, hid_t driver_id, H5ES_status_t *status); + +#ifdef __cplusplus +} +#endif + +#endif /* _H5VLpublic_H */ diff --git a/src/H5err.txt b/src/H5err.txt index 19374cd..3965242 100644 --- a/src/H5err.txt +++ b/src/H5err.txt @@ -46,7 +46,7 @@ MAJOR, H5E_ARGS, Invalid arguments to routine MAJOR, H5E_RESOURCE, Resource unavailable MAJOR, H5E_INTERNAL, Internal error (too specific to document in detail) -MAJOR, H5E_FILE, File accessibilty +MAJOR, H5E_FILE, File accessibility MAJOR, H5E_IO, Low-level I/O MAJOR, H5E_FUNC, Function entry/exit MAJOR, H5E_ATOM, Object atom @@ -66,6 +66,7 @@ MAJOR, H5E_PLINE, Data filters MAJOR, H5E_EFL, External file list MAJOR, H5E_REFERENCE, References MAJOR, H5E_VFL, Virtual File Layer +MAJOR, H5E_VOL, Virtual Object Layer MAJOR, H5E_TST, Ternary Search Trees MAJOR, H5E_RS, Reference Counted Strings MAJOR, H5E_ERROR, Error API @@ -82,7 +83,7 @@ MAJOR, H5E_NONE_MAJOR, No error # Sections (for grouping minor errors) SECTION, ARGS, Argument errors SECTION, RESOURCE, Resource errors -SECTION, FILEACC, File accessibilty errors +SECTION, FILEACC, File accessibility errors SECTION, FILE, Generic low-level file I/O errors SECTION, FUNC, Function entry/exit interface errors SECTION, ATOM, Object atom related errors @@ -123,7 +124,7 @@ MINOR, RESOURCE, H5E_CANTGC, Unable to garbage collect MINOR, RESOURCE, H5E_CANTGETSIZE, Unable to compute size MINOR, RESOURCE, H5E_OBJOPEN, Object is already open -# File accessibilty errors +# File accessibility errors MINOR, FILEACC, H5E_FILEEXISTS, File already exists MINOR, FILEACC, H5E_FILEOPEN, File already open MINOR, FILEACC, H5E_CANTCREATE, Unable to create file diff --git a/src/H5private.h b/src/H5private.h index 2dff0f0..63f6858 100644 --- a/src/H5private.h +++ b/src/H5private.h @@ -169,6 +169,9 @@ */ #define H5_DEFAULT_VFD H5FD_SEC2 +/* Define the default VOL driver */ +#define H5_DEFAULT_VOL H5VL_NATIVE + #ifdef H5_HAVE_WIN32_API /* The following two defines must be before any windows headers are included */ #define WIN32_LEAN_AND_MEAN /* Exclude rarely-used stuff from Windows headers */ @@ -510,6 +513,11 @@ # define H5_INC_ENUM(TYPE,VAR) (VAR)=((TYPE)((VAR)+1)) #endif +/* Represents an empty asynchronous request handle. + * Used in the VOL code. + */ +#define H5_REQUEST_NULL NULL + /* * A macro to portably decrement enumerated types. */ @@ -1704,6 +1712,7 @@ typedef enum { H5_PKG_S, /* Dataspaces */ H5_PKG_T, /* Datatypes */ H5_PKG_V, /* Vector functions */ + H5_PKG_VL, /* VOL functions */ H5_PKG_Z, /* Raw data filters */ H5_NPKGS /* Must be last */ } H5_pkg_t; @@ -2620,6 +2629,7 @@ H5_DLL int H5S_top_term_package(void); H5_DLL int H5SL_term_package(void); H5_DLL int H5T_term_package(void); H5_DLL int H5T_top_term_package(void); +H5_DLL int H5VL_term_package(void); H5_DLL int H5Z_term_package(void); /* Checksum functions */ diff --git a/src/H5trace.c b/src/H5trace.c index eef268c..08db09a 100644 --- a/src/H5trace.c +++ b/src/H5trace.c @@ -36,6 +36,7 @@ #include "H5FDprivate.h" /* File drivers */ #include "H5Ipkg.h" /* IDs */ #include "H5MMprivate.h" /* Memory management */ +#include "H5VLprivate.h" /* Virtual Object Layer */ #ifdef H5_HAVE_PARALLEL /* datatypes of predefined drivers needed by H5_trace() */ @@ -813,6 +814,37 @@ H5_trace(const double *returning, const char *func, const char *type, ...) } /* end else */ break; + case 's': + if(ptr) { + if(vp) + HDfprintf(out, "0x%lx", (unsigned long)vp); + else + HDfprintf(out, "NULL"); + } /* end if */ + else { + H5ES_status_t status = (H5ES_status_t)va_arg(ap, int); + + switch(status) { + case H5ES_STATUS_IN_PROGRESS: + HDfprintf(out, "H5ES_STATUS_IN_PROGRESS"); + break; + case H5ES_STATUS_SUCCEED: + HDfprintf(out, "H5ES_STATUS_SUCCEED"); + break; + case H5ES_STATUS_FAIL: + HDfprintf(out, "H5ES_STATUS_FAIL"); + break; + case H5ES_STATUS_CANCEL: + HDfprintf(out, "H5ES_STATUS_CANCEL"); + break; + + default: + HDfprintf(out, "%ld", (long)status); + break; + } /* end switch */ + } /* end else */ + break; + case 't': if(ptr) { if(vp) @@ -1331,6 +1363,10 @@ H5_trace(const double *returning, const char *func, const char *type, ...) HDfprintf(out, "%ld (file driver)", (long)obj); break; + case H5I_VOL: + HDfprintf(out, "%ld (VOL plugin)", (long)obj); + break; + case H5I_GENPROP_CLS: HDfprintf(out, "%ld (genprop class)", (long)obj); break; @@ -1512,6 +1548,10 @@ H5_trace(const double *returning, const char *func, const char *type, ...) HDfprintf(out, "H5I_VFL"); break; + case H5I_VOL: + HDfprintf(out, "H5I_VOL"); + break; + case H5I_GENPROP_CLS: HDfprintf(out, "H5I_GENPROP_CLS"); break; @@ -2466,6 +2506,440 @@ H5_trace(const double *returning, const char *func, const char *type, ...) } /* end switch */ break; + case 'V': + switch(type[1]) { + case 'a': + if(ptr) { + if(vp) + HDfprintf (out, "0x%lx", (unsigned long)vp); + else + HDfprintf(out, "NULL"); + } /* end if */ + else { + H5VL_attr_get_t get = (H5VL_attr_get_t)va_arg(ap, int); + + switch(get) { + case H5VL_ATTR_GET_SPACE: + HDfprintf(out, "H5VL_ATTR_GET_SPACE"); + break; + case H5VL_ATTR_GET_TYPE: + HDfprintf(out, "H5VL_ATTR_GET_TYPE"); + break; + case H5VL_ATTR_GET_ACPL: + HDfprintf(out, "H5VL_ATTR_GET_ACPL"); + break; + case H5VL_ATTR_GET_NAME: + HDfprintf(out, "H5VL_ATTR_GET_NAME"); + break; + case H5VL_ATTR_GET_STORAGE_SIZE: + HDfprintf(out, "H5VL_ATTR_GET_STORAGE_SIZE"); + break; + case H5VL_ATTR_GET_INFO: + HDfprintf(out, "H5VL_ATTR_GET_INFO"); + break; + default: + HDfprintf(out, "%ld", (long)get); + break; + } /* end switch */ + } /* end else */ + break; + case 'b': + if(ptr) { + if(vp) + HDfprintf (out, "0x%lx", (unsigned long)vp); + else + HDfprintf(out, "NULL"); + } /* end if */ + else { + H5VL_attr_specific_t specific = (H5VL_attr_specific_t)va_arg(ap, int); + + switch(specific) { + case H5VL_ATTR_DELETE: + HDfprintf(out, "H5VL_ATTR_DELETE"); + break; + case H5VL_ATTR_EXISTS: + HDfprintf(out, "H5VL_ATTR_EXISTS"); + break; + case H5VL_ATTR_ITER: + HDfprintf(out, "H5VL_ATTR_ITER"); + break; + case H5VL_ATTR_RENAME: + HDfprintf(out, "H5VL_ATTR_RENAME"); + break; + default: + HDfprintf(out, "%ld", (long)specific); + break; + } /* end switch */ + } /* end else */ + break; + case 'c': + if(ptr) { + if(vp) + HDfprintf (out, "0x%lx", (unsigned long)vp); + else + HDfprintf(out, "NULL"); + } /* end if */ + else { + H5VL_dataset_get_t get = (H5VL_dataset_get_t)va_arg(ap, int); + + switch(get) { + case H5VL_DATASET_GET_SPACE: + HDfprintf(out, "H5VL_DATASET_GET_SPACE"); + break; + case H5VL_DATASET_GET_SPACE_STATUS: + HDfprintf(out, "H5VL_DATASET_GET_SPACE_STATUS"); + break; + case H5VL_DATASET_GET_TYPE: + HDfprintf(out, "H5VL_DATASET_GET_TYPE"); + break; + case H5VL_DATASET_GET_DCPL: + HDfprintf(out, "H5VL_DATASET_GET_DCPL"); + break; + case H5VL_DATASET_GET_DAPL: + HDfprintf(out, "H5VL_DATASET_GET_DAPL"); + break; + case H5VL_DATASET_GET_STORAGE_SIZE: + HDfprintf(out, "H5VL_DATASET_GET_STORAGE_SIZE"); + break; + case H5VL_DATASET_GET_OFFSET: + HDfprintf(out, "H5VL_DATASET_GET_OFFSET"); + break; + default: + HDfprintf(out, "%ld", (long)get); + break; + } /* end switch */ + } /* end else */ + break; + case 'd': + if(ptr) { + if(vp) + HDfprintf (out, "0x%lx", (unsigned long)vp); + else + HDfprintf(out, "NULL"); + } /* end if */ + else { + H5VL_dataset_specific_t specific = (H5VL_dataset_specific_t)va_arg(ap, int); + + switch(specific) { + case H5VL_DATASET_SET_EXTENT: + HDfprintf(out, "H5VL_DATASET_SET_EXTENT"); + break; + case H5VL_DATASET_FLUSH: + HDfprintf(out, "H5VL_DATASET_FLUSH"); + break; + case H5VL_DATASET_REFRESH: + HDfprintf(out, "H5VL_DATASET_REFRESH"); + break; + default: + HDfprintf(out, "%ld", (long)specific); + break; + } /* end switch */ + } /* end else */ + break; + case 'e': + if(ptr) { + if(vp) + HDfprintf (out, "0x%lx", (unsigned long)vp); + else + HDfprintf(out, "NULL"); + } /* end if */ + else { + H5VL_datatype_get_t get = (H5VL_datatype_get_t)va_arg(ap, int); + + switch(get) { + case H5VL_DATATYPE_GET_BINARY: + HDfprintf(out, "H5VL_DATATYPE_GET_BINARY"); + break; + case H5VL_DATATYPE_GET_TCPL: + HDfprintf(out, "H5VL_DATATYPE_GET_TCPL"); + break; + default: + HDfprintf(out, "%ld", (long)get); + break; + } /* end switch */ + } /* end else */ + break; + case 'f': + if(ptr) { + if(vp) + HDfprintf (out, "0x%lx", (unsigned long)vp); + else + HDfprintf(out, "NULL"); + } /* end if */ + else { + H5VL_datatype_specific_t specific = (H5VL_datatype_specific_t)va_arg(ap, int); + + switch(specific) { + case H5VL_DATATYPE_FLUSH: + HDfprintf(out, "H5VL_DATATYPE_FLUSH"); + break; + case H5VL_DATATYPE_REFRESH: + HDfprintf(out, "H5VL_DATATYPE_REFRESH"); + break; + default: + HDfprintf(out, "%ld", (long)specific); + break; + } /* end switch */ + } /* end else */ + break; + case 'g': + if(ptr) { + if(vp) + HDfprintf (out, "0x%lx", (unsigned long)vp); + else + HDfprintf(out, "NULL"); + } /* end if */ + else { + H5VL_file_get_t get = (H5VL_file_get_t)va_arg(ap, int); + + switch(get) { + case H5VL_FILE_GET_FAPL: + HDfprintf(out, "H5VL_FILE_GET_FAPL"); + break; + case H5VL_FILE_GET_FCPL: + HDfprintf(out, "H5VL_FILE_GET_FCPL"); + break; + case H5VL_FILE_GET_INTENT: + HDfprintf(out, "H5VL_FILE_GET_INTENT"); + break; + case H5VL_FILE_GET_NAME: + HDfprintf(out, "H5VL_FILE_GET_NAME"); + break; + case H5VL_FILE_GET_OBJ_COUNT: + HDfprintf(out, "H5VL_FILE_GET_OBJ_COUNT"); + break; + case H5VL_FILE_GET_OBJ_IDS: + HDfprintf(out, "H5VL_FILE_GET_OBJ_IDS"); + break; + case H5VL_OBJECT_GET_FILE: + HDfprintf(out, "H5VL_OBJECT_GET_FILE"); + break; + default: + HDfprintf(out, "%ld", (long)get); + break; + } /* end switch */ + } /* end else */ + break; + case 'h': + if(ptr) { + if(vp) + HDfprintf (out, "0x%lx", (unsigned long)vp); + else + HDfprintf(out, "NULL"); + } /* end if */ + else { + H5VL_file_specific_t specific = (H5VL_file_specific_t)va_arg(ap, int); + + switch(specific) { + case H5VL_FILE_FLUSH: + HDfprintf(out, "H5VL_FILE_FLUSH"); + break; + case H5VL_FILE_MOUNT: + HDfprintf(out, "H5VL_FILE_MOUNT"); + break; + case H5VL_FILE_UNMOUNT: + HDfprintf(out, "H5VL_FILE_UNMOUNT"); + break; + case H5VL_FILE_IS_ACCESSIBLE: + HDfprintf(out, "H5VL_FILE_IS_ACCESSIBLE"); + break; + default: + HDfprintf(out, "%ld", (long)specific); + break; + } /* end switch */ + } /* end else */ + break; + case 'i': + if(ptr) { + if(vp) + HDfprintf (out, "0x%lx", (unsigned long)vp); + else + HDfprintf(out, "NULL"); + } /* end if */ + else { + H5VL_group_get_t get = (H5VL_group_get_t)va_arg(ap, int); + + switch(get) { + case H5VL_GROUP_GET_GCPL: + HDfprintf(out, "H5VL_GROUP_GET_GCPL"); + break; + case H5VL_GROUP_GET_INFO: + HDfprintf(out, "H5VL_GROUP_GET_INFO"); + break; + default: + HDfprintf(out, "%ld", (long)get); + break; + } /* end switch */ + } /* end else */ + break; + case 'j': + if(ptr) { + if(vp) + HDfprintf (out, "0x%lx", (unsigned long)vp); + else + HDfprintf(out, "NULL"); + } /* end if */ + else { + H5VL_group_specific_t specific = (H5VL_group_specific_t)va_arg(ap, int); + + switch(specific) { + case H5VL_GROUP_FLUSH: + HDfprintf(out, "H5VL_GROUP_FLUSH"); + break; + case H5VL_GROUP_REFRESH: + HDfprintf(out, "H5VL_GROUP_REFRESH"); + break; + default: + HDfprintf(out, "%ld", (long)specific); + break; + } /* end switch */ + } /* end else */ + break; + case 'k': + if(ptr) { + if(vp) + HDfprintf (out, "0x%lx", (unsigned long)vp); + else + HDfprintf(out, "NULL"); + } /* end if */ + else { + H5VL_link_create_type_t create = (H5VL_link_create_type_t)va_arg(ap, int); + + switch(create) { + case H5VL_LINK_CREATE_HARD: + HDfprintf(out, "H5VL_LINK_CREATE_HARD"); + break; + case H5VL_LINK_CREATE_SOFT: + HDfprintf(out, "H5VL_LINK_CREATE_SOFT"); + break; + case H5VL_LINK_CREATE_UD: + HDfprintf(out, "H5VL_LINK_CREATE_UD"); + break; + default: + HDfprintf(out, "%ld", (long)create); + break; + } /* end switch */ + } /* end else */ + break; + case 'l': + if(ptr) { + if(vp) + HDfprintf (out, "0x%lx", (unsigned long)vp); + else + HDfprintf(out, "NULL"); + } /* end if */ + else { + H5VL_link_get_t get = (H5VL_link_get_t)va_arg(ap, int); + + switch(get) { + case H5VL_LINK_GET_INFO: + HDfprintf(out, "H5VL_LINK_GET_INFO"); + break; + case H5VL_LINK_GET_NAME: + HDfprintf(out, "H5VL_LINK_GET_NAME"); + break; + case H5VL_LINK_GET_VAL: + HDfprintf(out, "H5VL_LINK_GET_VAL"); + break; + default: + HDfprintf(out, "%ld", (long)get); + break; + } /* end switch */ + } /* end else */ + break; + case 'm': + if(ptr) { + if(vp) + HDfprintf (out, "0x%lx", (unsigned long)vp); + else + HDfprintf(out, "NULL"); + } /* end if */ + else { + H5VL_link_specific_t specific = (H5VL_link_specific_t)va_arg(ap, int); + + switch(specific) { + case H5VL_LINK_DELETE: + HDfprintf(out, "H5VL_LINK_DELETE"); + break; + case H5VL_LINK_EXISTS: + HDfprintf(out, "H5VL_LINK_EXISTS"); + break; + case H5VL_LINK_ITER: + HDfprintf(out, "H5VL_LINK_ITER"); + break; + default: + HDfprintf(out, "%ld", (long)specific); + break; + } /* end switch */ + } /* end else */ + break; + case 'n': + if(ptr) { + if(vp) + HDfprintf (out, "0x%lx", (unsigned long)vp); + else + HDfprintf(out, "NULL"); + } /* end if */ + else { + H5VL_object_get_t get = (H5VL_object_get_t)va_arg(ap, int); + + switch(get) { + case H5VL_REF_GET_REGION: + HDfprintf(out, "H5VL_REF_GET_REGION"); + break; + case H5VL_REF_GET_TYPE: + HDfprintf(out, "H5VL_REF_GET_TYPE"); + break; + case H5VL_REF_GET_NAME: + HDfprintf(out, "H5VL_REF_GET_NAME"); + break; + default: + HDfprintf(out, "%ld", (long)get); + break; + } /* end switch */ + } /* end else */ + break; + case 'o': + if(ptr) { + if(vp) + HDfprintf (out, "0x%lx", (unsigned long)vp); + else + HDfprintf(out, "NULL"); + } /* end if */ + else { + H5VL_object_specific_t specific = (H5VL_object_specific_t)va_arg(ap, int); + + switch(specific) { + case H5VL_OBJECT_CHANGE_REF_COUNT: + HDfprintf(out, "H5VL_OBJECT_CHANGE_REF_COUNT"); + break; + case H5VL_OBJECT_EXISTS: + HDfprintf(out, "H5VL_OBJECT_EXISTS"); + break; + case H5VL_OBJECT_VISIT: + HDfprintf(out, "H5VL_OBJECT_VISIT"); + break; + case H5VL_REF_CREATE: + HDfprintf(out, "H5VL_REF_CREATE"); + break; + case H5VL_OBJECT_FLUSH: + HDfprintf(out, "H5VL_OBJECT_FLUSH"); + break; + case H5VL_OBJECT_REFRESH: + HDfprintf(out, "H5VL_OBJECT_REFRESH"); + break; + default: + HDfprintf(out, "%ld", (long)specific); + break; + } /* end switch */ + } /* end else */ + break; + default: + HDfprintf(out, "BADTYPE(Z%c)", type[1]); + goto error; + } /* end switch */ + break; + case 'x': if(ptr) { if(vp) { diff --git a/src/Makefile.am b/src/Makefile.am index 472dfc6..7889e10 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -114,6 +114,7 @@ libhdf5_la_SOURCES= H5.c H5checksum.c H5dbg.c H5system.c H5timer.c H5trace.c \ H5Topaque.c \ H5Torder.c \ H5Tpad.c H5Tprecis.c H5Tstrpad.c H5Tvisit.c H5Tvlen.c H5TS.c \ + H5VL.c H5VLint.c H5VLnative.c \ H5VM.c H5WB.c H5Z.c \ H5Zdeflate.c H5Zfletcher32.c H5Znbit.c H5Zshuffle.c \ H5Zscaleoffset.c H5Zszip.c H5Ztrans.c @@ -132,7 +133,7 @@ endif include_HEADERS = hdf5.h H5api_adpt.h H5overflow.h H5pubconf.h H5public.h H5version.h \ H5Apublic.h H5ACpublic.h \ H5Cpublic.h H5Dpublic.h \ - H5Epubgen.h H5Epublic.h H5Fpublic.h \ + H5Epubgen.h H5Epublic.h H5ESpublic.h H5Fpublic.h \ H5FDpublic.h H5FDcore.h H5FDdirect.h \ H5FDfamily.h H5FDlog.h H5FDmpi.h H5FDmpio.h \ H5FDmulti.h H5FDsec2.h H5FDstdio.h \ @@ -140,7 +141,7 @@ include_HEADERS = hdf5.h H5api_adpt.h H5overflow.h H5pubconf.h H5public.h H5vers H5MMpublic.h H5Opublic.h H5Ppublic.h \ H5PLextern.h H5PLpublic.h \ H5Rpublic.h H5Spublic.h H5Tpublic.h \ - H5Zpublic.h + H5VLnative.h H5VLpublic.h H5Zpublic.h # install libhdf5.settings in lib directory settingsdir=$(libdir) @@ -36,6 +36,7 @@ #include "H5Rpublic.h" /* References */ #include "H5Spublic.h" /* Dataspaces */ #include "H5Tpublic.h" /* Datatypes */ +#include "H5VLpublic.h" /* Virtual Object Layer */ #include "H5Zpublic.h" /* Data filters */ /* Predefined file drivers */ |