diff options
author | Quincey Koziol <koziol@lbl.gov> | 2020-11-30 19:54:44 (GMT) |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-11-30 19:54:44 (GMT) |
commit | cadd6db431e2664e6dd3f2460639a27d21c6c8a9 (patch) | |
tree | 79bad4f1b2615f8662499a6d986e89514894acf8 /src | |
parent | c256612e0950f3389249aa3a151d66ce01704d89 (diff) | |
download | hdf5-cadd6db431e2664e6dd3f2460639a27d21c6c8a9.zip hdf5-cadd6db431e2664e6dd3f2460639a27d21c6c8a9.tar.gz hdf5-cadd6db431e2664e6dd3f2460639a27d21c6c8a9.tar.bz2 |
Move API routines for VOL objects to main source file. (#133)
Diffstat (limited to 'src')
-rw-r--r-- | src/H5D.c | 480 | ||||
-rw-r--r-- | src/H5Dfill.c | 52 | ||||
-rw-r--r-- | src/H5Dio.c | 230 | ||||
-rw-r--r-- | src/H5Dscatgath.c | 196 | ||||
-rw-r--r-- | src/H5F.c | 115 | ||||
-rw-r--r-- | src/H5Fmount.c | 115 | ||||
-rw-r--r-- | src/H5L.c | 179 | ||||
-rw-r--r-- | src/H5Lexternal.c | 185 | ||||
-rw-r--r-- | src/H5Lpkg.h | 6 | ||||
-rw-r--r-- | src/H5O.c | 219 | ||||
-rw-r--r-- | src/H5Ocopy.c | 133 | ||||
-rw-r--r-- | src/H5Oflush.c | 86 |
12 files changed, 1000 insertions, 996 deletions
@@ -53,6 +53,9 @@ hbool_t H5_PKG_INIT_VAR = FALSE; /* Library Private Variables */ /*****************************/ +/* Declare extern free list to manage the H5S_sel_iter_t struct */ +H5FL_EXTERN(H5S_sel_iter_t); + /* Declare extern the free list to manage blocks of type conversion data */ H5FL_BLK_EXTERN(type_conv); @@ -594,6 +597,483 @@ done: } /* end H5Dget_offset() */ /*------------------------------------------------------------------------- + * Function: H5Dread + * + * Purpose: Reads (part of) a DSET from the file into application + * memory BUF. The part of the dataset to read is defined with + * MEM_SPACE_ID and FILE_SPACE_ID. The data points are + * converted from their file type to the MEM_TYPE_ID specified. + * Additional miscellaneous data transfer properties can be + * passed to this function with the PLIST_ID argument. + * + * The FILE_SPACE_ID can be the constant H5S_ALL which indicates + * that the entire file dataspace is to be referenced. + * + * The MEM_SPACE_ID can be the constant H5S_ALL in which case + * the memory dataspace is the same as the file dataspace + * defined when the dataset was created. + * + * The number of elements in the memory dataspace must match + * the number of elements in the file dataspace. + * + * The PLIST_ID can be the constant H5P_DEFAULT in which + * case the default data transfer properties are used. + * + * Return: Non-negative on success/Negative on failure + * + * Programmer: Robb Matzke + * Thursday, December 4, 1997 + * + *------------------------------------------------------------------------- + */ +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*/) +{ + 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 == (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") + + /* Get the default dataset transfer property list if the user didn't provide one */ + if (H5P_DEFAULT == dxpl_id) + dxpl_id = H5P_DATASET_XFER_DEFAULT; + else if (TRUE != H5P_isa_class(dxpl_id, H5P_DATASET_XFER)) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not xfer parms") + + /* Read the data */ + if ((ret_value = H5VL_dataset_read(vol_obj, 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: + FUNC_LEAVE_API(ret_value) +} /* end H5Dread() */ + +/*------------------------------------------------------------------------- + * Function: H5Dread_chunk + * + * Purpose: Reads an entire chunk from the file directly. + * + * Return: Non-negative on success/Negative on failure + * + * Programmer: Matthew Strong (GE Healthcare) + * 14 February 2016 + * + *--------------------------------------------------------------------------- + */ +herr_t +H5Dread_chunk(hid_t dset_id, hid_t dxpl_id, const hsize_t *offset, uint32_t *filters, void *buf) +{ + 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 == (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 (!buf) + HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "buf cannot be NULL") + if (!offset) + HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "offset cannot be NULL") + if (!filters) + HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "filters cannot be NULL") + + /* Get the default dataset transfer property list if the user didn't provide one */ + if (H5P_DEFAULT == dxpl_id) + dxpl_id = H5P_DATASET_XFER_DEFAULT; + else if (TRUE != H5P_isa_class(dxpl_id, H5P_DATASET_XFER)) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "dxpl_id is not a dataset transfer property list ID") + + /* Read the raw chunk */ + if (H5VL_dataset_optional(vol_obj, H5VL_NATIVE_DATASET_CHUNK_READ, dxpl_id, H5_REQUEST_NULL, offset, + filters, buf) < 0) + HGOTO_ERROR(H5E_DATASET, H5E_READERROR, FAIL, "can't read unprocessed chunk data") + +done: + FUNC_LEAVE_API(ret_value) +} /* end H5Dread_chunk() */ + +/*------------------------------------------------------------------------- + * Function: H5Dwrite + * + * Purpose: Writes (part of) a DSET from application memory BUF to the + * file. The part of the dataset to write is defined with the + * MEM_SPACE_ID and FILE_SPACE_ID arguments. The data points + * are converted from their current type (MEM_TYPE_ID) to their + * file datatype. Additional miscellaneous data transfer + * properties can be passed to this function with the + * PLIST_ID argument. + * + * The FILE_SPACE_ID can be the constant H5S_ALL which indicates + * that the entire file dataspace is to be referenced. + * + * The MEM_SPACE_ID can be the constant H5S_ALL in which case + * the memory dataspace is the same as the file dataspace + * defined when the dataset was created. + * + * The number of elements in the memory dataspace must match + * the number of elements in the file dataspace. + * + * The PLIST_ID can be the constant H5P_DEFAULT in which + * case the default data transfer properties are used. + * + * Return: Non-negative on success/Negative on failure + * + * Programmer: Robb Matzke + * Thursday, December 4, 1997 + * + *------------------------------------------------------------------------- + */ +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) +{ + 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 == (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") + + /* Get the default dataset transfer property list if the user didn't provide one */ + if (H5P_DEFAULT == dxpl_id) + dxpl_id = H5P_DATASET_XFER_DEFAULT; + else if (TRUE != H5P_isa_class(dxpl_id, H5P_DATASET_XFER)) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not xfer parms") + + /* Write the data */ + if ((ret_value = H5VL_dataset_write(vol_obj, 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: + FUNC_LEAVE_API(ret_value) +} /* end H5Dwrite() */ + +/*------------------------------------------------------------------------- + * Function: H5Dwrite_chunk + * + * Purpose: Writes an entire chunk to the file directly. + * + * Return: Non-negative on success/Negative on failure + * + * Programmer: Raymond Lu + * 30 July 2012 + * + *------------------------------------------------------------------------- + */ +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) +{ + 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 */ + + FUNC_ENTER_API(FAIL) + H5TRACE6("e", "iiIu*hz*x", dset_id, dxpl_id, filters, offset, data_size, buf); + + /* Check arguments */ + 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 (!buf) + HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "buf cannot be NULL") + if (!offset) + HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "offset cannot be NULL") + if (0 == data_size) + HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "data_size cannot be zero") + + /* Make sure data size is less than 4 GiB */ + data_size_32 = (uint32_t)data_size; + if (data_size != (size_t)data_size_32) + HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "invalid data_size - chunks cannot be > 4 GiB") + + /* Get the default dataset transfer property list if the user didn't provide one */ + if (H5P_DEFAULT == dxpl_id) + dxpl_id = H5P_DATASET_XFER_DEFAULT; + else if (TRUE != H5P_isa_class(dxpl_id, H5P_DATASET_XFER)) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "dxpl_id is not a dataset transfer property list ID") + + /* Write chunk */ + if (H5VL_dataset_optional(vol_obj, H5VL_NATIVE_DATASET_CHUNK_WRITE, dxpl_id, H5_REQUEST_NULL, filters, + offset, data_size_32, buf) < 0) + HGOTO_ERROR(H5E_DATASET, H5E_WRITEERROR, FAIL, "can't write unprocessed chunk data") + +done: + FUNC_LEAVE_API(ret_value) +} /* end H5Dwrite_chunk() */ + +/*------------------------------------------------------------------------- + * Function: H5Dscatter + * + * Purpose: Scatters data provided by the callback op to the + * destination buffer dst_buf, where the dimensions of + * dst_buf and the selection to be scattered to are specified + * by the dataspace dst_space_id. The type of the data to be + * scattered is specified by type_id. + * + * Return: Non-negative on success/Negative on failure + * + * Programmer: Neil Fortner + * 14 Jan 2013 + * + *------------------------------------------------------------------------- + */ +herr_t +H5Dscatter(H5D_scatter_func_t op, void *op_data, hid_t type_id, hid_t dst_space_id, void *dst_buf /*out*/) +{ + H5T_t * type; /* Datatype */ + H5S_t * dst_space; /* Dataspace */ + H5S_sel_iter_t *iter = NULL; /* Selection iteration info*/ + hbool_t iter_init = FALSE; /* Selection iteration info has been initialized */ + const void * src_buf = NULL; /* Source (contiguous) data buffer */ + size_t src_buf_nbytes = 0; /* Size of src_buf */ + size_t type_size; /* Datatype element size */ + hssize_t nelmts; /* Number of remaining elements in selection */ + size_t nelmts_scatter = 0; /* Number of elements to scatter to dst_buf */ + herr_t ret_value = SUCCEED; /* Return value */ + + FUNC_ENTER_API(FAIL) + H5TRACE5("e", "DS*xiix", op, op_data, type_id, dst_space_id, dst_buf); + + /* Check args */ + if (op == NULL) + HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "invalid callback function pointer") + if (NULL == (type = (H5T_t *)H5I_object_verify(type_id, H5I_DATATYPE))) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a datatype") + if (NULL == (dst_space = (H5S_t *)H5I_object_verify(dst_space_id, H5I_DATASPACE))) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a dataspace") + if (dst_buf == NULL) + HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "no destination buffer provided") + + /* Get datatype element size */ + if (0 == (type_size = H5T_GET_SIZE(type))) + HGOTO_ERROR(H5E_DATASET, H5E_CANTGET, FAIL, "can't get datatype size") + + /* Get number of elements in dataspace */ + if ((nelmts = (hssize_t)H5S_GET_SELECT_NPOINTS(dst_space)) < 0) + HGOTO_ERROR(H5E_DATASET, H5E_CANTCOUNT, FAIL, "unable to get number of elements in selection") + + /* Allocate the selection iterator */ + if (NULL == (iter = H5FL_MALLOC(H5S_sel_iter_t))) + HGOTO_ERROR(H5E_DATASET, H5E_CANTALLOC, FAIL, "can't allocate selection iterator") + + /* Initialize selection iterator */ + if (H5S_select_iter_init(iter, dst_space, type_size, 0) < 0) + HGOTO_ERROR(H5E_DATASET, H5E_CANTINIT, FAIL, "unable to initialize selection iterator information") + iter_init = TRUE; + + /* Loop until all data has been scattered */ + while (nelmts > 0) { + /* Make callback to retrieve data */ + if (op(&src_buf, &src_buf_nbytes, op_data) < 0) + HGOTO_ERROR(H5E_DATASET, H5E_CALLBACK, FAIL, "callback operator returned failure") + + /* Calculate number of elements */ + nelmts_scatter = src_buf_nbytes / type_size; + + /* Check callback results */ + if (!src_buf) + HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "callback did not return a buffer") + if (src_buf_nbytes == 0) + HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "callback returned a buffer size of 0") + if (src_buf_nbytes % type_size) + HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "buffer size is not a multiple of datatype size") + if (nelmts_scatter > (size_t)nelmts) + HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "callback returned more elements than in selection") + + /* Scatter data */ + if (H5D__scatter_mem(src_buf, iter, nelmts_scatter, dst_buf) < 0) + HGOTO_ERROR(H5E_DATASET, H5E_CANTCOPY, FAIL, "scatter failed") + + nelmts -= (hssize_t)nelmts_scatter; + } /* end while */ + +done: + /* Release selection iterator */ + if (iter_init && H5S_SELECT_ITER_RELEASE(iter) < 0) + HDONE_ERROR(H5E_DATASET, H5E_CANTFREE, FAIL, "Can't release selection iterator") + if (iter) + iter = H5FL_FREE(H5S_sel_iter_t, iter); + + FUNC_LEAVE_API(ret_value) +} /* H5Dscatter() */ + +/*------------------------------------------------------------------------- + * Function: H5Dgather + * + * Purpose: Gathers data provided from the source buffer src_buf to + * contiguous buffer dst_buf, then calls the callback op. + * The dimensions of src_buf and the selection to be gathered + * are specified by the dataspace src_space_id. The type of + * the data to be gathered is specified by type_id. + * + * Return: Non-negative on success/Negative on failure + * + * Programmer: Neil Fortner + * 16 Jan 2013 + * + *------------------------------------------------------------------------- + */ +herr_t +H5Dgather(hid_t src_space_id, const void *src_buf, hid_t type_id, size_t dst_buf_size, void *dst_buf /*out*/, + H5D_gather_func_t op, void *op_data) +{ + H5T_t * type; /* Datatype */ + H5S_t * src_space; /* Dataspace */ + H5S_sel_iter_t *iter = NULL; /* Selection iteration info*/ + hbool_t iter_init = FALSE; /* Selection iteration info has been initialized */ + size_t type_size; /* Datatype element size */ + hssize_t nelmts; /* Number of remaining elements in selection */ + size_t dst_buf_nelmts; /* Number of elements that can fit in dst_buf */ + size_t nelmts_gathered; /* Number of elements gathered from src_buf */ + herr_t ret_value = SUCCEED; /* Return value */ + + FUNC_ENTER_API(FAIL) + H5TRACE7("e", "i*xizxDg*x", src_space_id, src_buf, type_id, dst_buf_size, dst_buf, op, op_data); + + /* Check args */ + if (NULL == (src_space = (H5S_t *)H5I_object_verify(src_space_id, H5I_DATASPACE))) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a dataspace") + if (src_buf == NULL) + HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "no source buffer provided") + if (NULL == (type = (H5T_t *)H5I_object_verify(type_id, H5I_DATATYPE))) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a datatype") + if (dst_buf_size == 0) + HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "destination buffer size is 0") + if (dst_buf == NULL) + HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "no destination buffer provided") + + /* Get datatype element size */ + if (0 == (type_size = H5T_GET_SIZE(type))) + HGOTO_ERROR(H5E_DATASET, H5E_CANTGET, FAIL, "can't get datatype size") + + /* Get number of elements in dst_buf_size */ + dst_buf_nelmts = dst_buf_size / type_size; + if (dst_buf_nelmts == 0) + HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, + "destination buffer is not large enough to hold one element") + + /* Get number of elements in dataspace */ + if ((nelmts = (hssize_t)H5S_GET_SELECT_NPOINTS(src_space)) < 0) + HGOTO_ERROR(H5E_DATASET, H5E_CANTCOUNT, FAIL, "unable to get number of elements in selection") + + /* If dst_buf is not large enough to hold all the elements, make sure there + * is a callback */ + if (((size_t)nelmts > dst_buf_nelmts) && (op == NULL)) + HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "no callback supplied and destination buffer too small") + + /* Allocate the selection iterator */ + if (NULL == (iter = H5FL_MALLOC(H5S_sel_iter_t))) + HGOTO_ERROR(H5E_DATASET, H5E_CANTALLOC, FAIL, "can't allocate selection iterator") + + /* Initialize selection iterator */ + if (H5S_select_iter_init(iter, src_space, type_size, 0) < 0) + HGOTO_ERROR(H5E_DATASET, H5E_CANTINIT, FAIL, "unable to initialize selection iterator information") + iter_init = TRUE; + + /* Loop until all data has been scattered */ + while (nelmts > 0) { + /* Gather data */ + if (0 == + (nelmts_gathered = H5D__gather_mem(src_buf, iter, MIN(dst_buf_nelmts, (size_t)nelmts), dst_buf))) + HGOTO_ERROR(H5E_IO, H5E_CANTCOPY, FAIL, "gather failed") + HDassert(nelmts_gathered == MIN(dst_buf_nelmts, (size_t)nelmts)); + + /* Make callback to process dst_buf */ + if (op && op(dst_buf, nelmts_gathered * type_size, op_data) < 0) + HGOTO_ERROR(H5E_DATASET, H5E_CALLBACK, FAIL, "callback operator returned failure") + + nelmts -= (hssize_t)nelmts_gathered; + HDassert(op || (nelmts == 0)); + } /* end while */ + +done: + /* Release selection iterator */ + if (iter_init && H5S_SELECT_ITER_RELEASE(iter) < 0) + HDONE_ERROR(H5E_DATASET, H5E_CANTFREE, FAIL, "Can't release selection iterator") + if (iter) + iter = H5FL_FREE(H5S_sel_iter_t, iter); + + FUNC_LEAVE_API(ret_value) +} /* H5Dgather() */ + +/*-------------------------------------------------------------------------- + NAME + H5Dfill + PURPOSE + Fill a selection in memory with a value + USAGE + herr_t H5Dfill(fill, fill_type, space, buf, buf_type) + const void *fill; IN: Pointer to fill value to use + hid_t fill_type_id; IN: Datatype of the fill value + void *buf; IN/OUT: Memory buffer to fill selection within + hid_t buf_type_id; IN: Datatype of the elements in buffer + hid_t space_id; IN: Dataspace describing memory buffer & + containing selection to use. + RETURNS + Non-negative on success/Negative on failure. + DESCRIPTION + Use the selection in the dataspace to fill elements in a memory buffer. + GLOBAL VARIABLES + COMMENTS, BUGS, ASSUMPTIONS + If "fill" parameter is NULL, use all zeros as fill value + EXAMPLES + REVISION LOG +--------------------------------------------------------------------------*/ +herr_t +H5Dfill(const void *fill, hid_t fill_type_id, void *buf, hid_t buf_type_id, hid_t space_id) +{ + H5S_t *space; /* Dataspace */ + H5T_t *fill_type; /* Fill-value datatype */ + H5T_t *buf_type; /* Buffer datatype */ + herr_t ret_value = SUCCEED; /* Return value */ + + FUNC_ENTER_API(FAIL) + H5TRACE5("e", "*xi*xii", fill, fill_type_id, buf, buf_type_id, space_id); + + /* Check args */ + if (buf == NULL) + HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "invalid buffer") + if (NULL == (space = (H5S_t *)H5I_object_verify(space_id, H5I_DATASPACE))) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, 0, "not a dataspace") + if (NULL == (fill_type = (H5T_t *)H5I_object_verify(fill_type_id, H5I_DATATYPE))) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, 0, "not a datatype") + if (NULL == (buf_type = (H5T_t *)H5I_object_verify(buf_type_id, H5I_DATATYPE))) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, 0, "not a datatype") + + /* Fill the selection in the memory buffer */ + if (H5D__fill(fill, fill_type, buf, buf_type, space) < 0) + HGOTO_ERROR(H5E_DATASET, H5E_CANTENCODE, FAIL, "filling selection failed") + +done: + FUNC_LEAVE_API(ret_value) +} /* H5Dfill() */ + +/*------------------------------------------------------------------------- * Function: H5Diterate * * Purpose: This routine iterates over all the elements selected in a memory diff --git a/src/H5Dfill.c b/src/H5Dfill.c index 03a128d8..939a425 100644 --- a/src/H5Dfill.c +++ b/src/H5Dfill.c @@ -85,58 +85,6 @@ H5FL_EXTERN(H5S_sel_iter_t); /*-------------------------------------------------------------------------- NAME - H5Dfill - PURPOSE - Fill a selection in memory with a value - USAGE - herr_t H5Dfill(fill, fill_type, space, buf, buf_type) - const void *fill; IN: Pointer to fill value to use - hid_t fill_type_id; IN: Datatype of the fill value - void *buf; IN/OUT: Memory buffer to fill selection within - hid_t buf_type_id; IN: Datatype of the elements in buffer - hid_t space_id; IN: Dataspace describing memory buffer & - containing selection to use. - RETURNS - Non-negative on success/Negative on failure. - DESCRIPTION - Use the selection in the dataspace to fill elements in a memory buffer. - GLOBAL VARIABLES - COMMENTS, BUGS, ASSUMPTIONS - If "fill" parameter is NULL, use all zeros as fill value - EXAMPLES - REVISION LOG ---------------------------------------------------------------------------*/ -herr_t -H5Dfill(const void *fill, hid_t fill_type_id, void *buf, hid_t buf_type_id, hid_t space_id) -{ - H5S_t *space; /* Dataspace */ - H5T_t *fill_type; /* Fill-value datatype */ - H5T_t *buf_type; /* Buffer datatype */ - herr_t ret_value = SUCCEED; /* Return value */ - - FUNC_ENTER_API(FAIL) - H5TRACE5("e", "*xi*xii", fill, fill_type_id, buf, buf_type_id, space_id); - - /* Check args */ - if (buf == NULL) - HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "invalid buffer") - if (NULL == (space = (H5S_t *)H5I_object_verify(space_id, H5I_DATASPACE))) - HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, 0, "not a dataspace") - if (NULL == (fill_type = (H5T_t *)H5I_object_verify(fill_type_id, H5I_DATATYPE))) - HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, 0, "not a datatype") - if (NULL == (buf_type = (H5T_t *)H5I_object_verify(buf_type_id, H5I_DATATYPE))) - HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, 0, "not a datatype") - - /* Fill the selection in the memory buffer */ - if (H5D__fill(fill, fill_type, buf, buf_type, space) < 0) - HGOTO_ERROR(H5E_DATASET, H5E_CANTENCODE, FAIL, "filling selection failed") - -done: - FUNC_LEAVE_API(ret_value) -} /* H5Dfill() */ - -/*-------------------------------------------------------------------------- - NAME H5D__fill PURPOSE Fill a selection in memory with a value (internal version) diff --git a/src/H5Dio.c b/src/H5Dio.c index 2c84857..ef31f31 100644 --- a/src/H5Dio.c +++ b/src/H5Dio.c @@ -118,236 +118,6 @@ done: } /* end H5D__get_offset_copy() */ /*------------------------------------------------------------------------- - * Function: H5Dread - * - * Purpose: Reads (part of) a DSET from the file into application - * memory BUF. The part of the dataset to read is defined with - * MEM_SPACE_ID and FILE_SPACE_ID. The data points are - * converted from their file type to the MEM_TYPE_ID specified. - * Additional miscellaneous data transfer properties can be - * passed to this function with the PLIST_ID argument. - * - * The FILE_SPACE_ID can be the constant H5S_ALL which indicates - * that the entire file dataspace is to be referenced. - * - * The MEM_SPACE_ID can be the constant H5S_ALL in which case - * the memory dataspace is the same as the file dataspace - * defined when the dataset was created. - * - * The number of elements in the memory dataspace must match - * the number of elements in the file dataspace. - * - * The PLIST_ID can be the constant H5P_DEFAULT in which - * case the default data transfer properties are used. - * - * Return: Non-negative on success/Negative on failure - * - * Programmer: Robb Matzke - * Thursday, December 4, 1997 - * - *------------------------------------------------------------------------- - */ -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*/) -{ - 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 == (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") - - /* Get the default dataset transfer property list if the user didn't provide one */ - if (H5P_DEFAULT == dxpl_id) - dxpl_id = H5P_DATASET_XFER_DEFAULT; - else if (TRUE != H5P_isa_class(dxpl_id, H5P_DATASET_XFER)) - HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not xfer parms") - - /* Read the data */ - if ((ret_value = H5VL_dataset_read(vol_obj, 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: - FUNC_LEAVE_API(ret_value) -} /* end H5Dread() */ - -/*------------------------------------------------------------------------- - * Function: H5Dread_chunk - * - * Purpose: Reads an entire chunk from the file directly. - * - * Return: Non-negative on success/Negative on failure - * - * Programmer: Matthew Strong (GE Healthcare) - * 14 February 2016 - * - *--------------------------------------------------------------------------- - */ -herr_t -H5Dread_chunk(hid_t dset_id, hid_t dxpl_id, const hsize_t *offset, uint32_t *filters, void *buf) -{ - 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 == (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 (!buf) - HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "buf cannot be NULL") - if (!offset) - HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "offset cannot be NULL") - if (!filters) - HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "filters cannot be NULL") - - /* Get the default dataset transfer property list if the user didn't provide one */ - if (H5P_DEFAULT == dxpl_id) - dxpl_id = H5P_DATASET_XFER_DEFAULT; - else if (TRUE != H5P_isa_class(dxpl_id, H5P_DATASET_XFER)) - HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "dxpl_id is not a dataset transfer property list ID") - - /* Read the raw chunk */ - if (H5VL_dataset_optional(vol_obj, H5VL_NATIVE_DATASET_CHUNK_READ, dxpl_id, H5_REQUEST_NULL, offset, - filters, buf) < 0) - HGOTO_ERROR(H5E_DATASET, H5E_READERROR, FAIL, "can't read unprocessed chunk data") - -done: - FUNC_LEAVE_API(ret_value) -} /* end H5Dread_chunk() */ - -/*------------------------------------------------------------------------- - * Function: H5Dwrite - * - * Purpose: Writes (part of) a DSET from application memory BUF to the - * file. The part of the dataset to write is defined with the - * MEM_SPACE_ID and FILE_SPACE_ID arguments. The data points - * are converted from their current type (MEM_TYPE_ID) to their - * file datatype. Additional miscellaneous data transfer - * properties can be passed to this function with the - * PLIST_ID argument. - * - * The FILE_SPACE_ID can be the constant H5S_ALL which indicates - * that the entire file dataspace is to be referenced. - * - * The MEM_SPACE_ID can be the constant H5S_ALL in which case - * the memory dataspace is the same as the file dataspace - * defined when the dataset was created. - * - * The number of elements in the memory dataspace must match - * the number of elements in the file dataspace. - * - * The PLIST_ID can be the constant H5P_DEFAULT in which - * case the default data transfer properties are used. - * - * Return: Non-negative on success/Negative on failure - * - * Programmer: Robb Matzke - * Thursday, December 4, 1997 - * - *------------------------------------------------------------------------- - */ -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) -{ - 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 == (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") - - /* Get the default dataset transfer property list if the user didn't provide one */ - if (H5P_DEFAULT == dxpl_id) - dxpl_id = H5P_DATASET_XFER_DEFAULT; - else if (TRUE != H5P_isa_class(dxpl_id, H5P_DATASET_XFER)) - HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not xfer parms") - - /* Write the data */ - if ((ret_value = H5VL_dataset_write(vol_obj, 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: - FUNC_LEAVE_API(ret_value) -} /* end H5Dwrite() */ - -/*------------------------------------------------------------------------- - * Function: H5Dwrite_chunk - * - * Purpose: Writes an entire chunk to the file directly. - * - * Return: Non-negative on success/Negative on failure - * - * Programmer: Raymond Lu - * 30 July 2012 - * - *------------------------------------------------------------------------- - */ -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) -{ - 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 */ - - FUNC_ENTER_API(FAIL) - H5TRACE6("e", "iiIu*hz*x", dset_id, dxpl_id, filters, offset, data_size, buf); - - /* Check arguments */ - 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 (!buf) - HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "buf cannot be NULL") - if (!offset) - HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "offset cannot be NULL") - if (0 == data_size) - HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "data_size cannot be zero") - - /* Make sure data size is less than 4 GiB */ - data_size_32 = (uint32_t)data_size; - if (data_size != (size_t)data_size_32) - HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "invalid data_size - chunks cannot be > 4 GiB") - - /* Get the default dataset transfer property list if the user didn't provide one */ - if (H5P_DEFAULT == dxpl_id) - dxpl_id = H5P_DATASET_XFER_DEFAULT; - else if (TRUE != H5P_isa_class(dxpl_id, H5P_DATASET_XFER)) - HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "dxpl_id is not a dataset transfer property list ID") - - /* Write chunk */ - if (H5VL_dataset_optional(vol_obj, H5VL_NATIVE_DATASET_CHUNK_WRITE, dxpl_id, H5_REQUEST_NULL, filters, - offset, data_size_32, buf) < 0) - HGOTO_ERROR(H5E_DATASET, H5E_WRITEERROR, FAIL, "can't write unprocessed chunk data") - -done: - FUNC_LEAVE_API(ret_value) -} /* end H5Dwrite_chunk() */ - -/*------------------------------------------------------------------------- * Function: H5D__read * * Purpose: Reads (part of) a DATASET into application memory BUF. See diff --git a/src/H5Dscatgath.c b/src/H5Dscatgath.c index ee3fce8..65bc28a 100644 --- a/src/H5Dscatgath.c +++ b/src/H5Dscatgath.c @@ -370,7 +370,7 @@ H5D__gather_mem(const void *_buf, H5S_sel_iter_t *iter, size_t nelmts, void *_tg size_t vec_size; /* Vector length */ size_t ret_value = nelmts; /* Number of elements gathered */ - FUNC_ENTER_STATIC + FUNC_ENTER_PACKAGE /* Check args */ HDassert(buf); @@ -899,197 +899,3 @@ H5D__compound_opt_write(size_t nelmts, const H5D_type_info_t *type_info) FUNC_LEAVE_NOAPI(SUCCEED) } /* end H5D__compound_opt_write() */ -/*------------------------------------------------------------------------- - * Function: H5Dscatter - * - * Purpose: Scatters data provided by the callback op to the - * destination buffer dst_buf, where the dimensions of - * dst_buf and the selection to be scattered to are specified - * by the dataspace dst_space_id. The type of the data to be - * scattered is specified by type_id. - * - * Return: Non-negative on success/Negative on failure - * - * Programmer: Neil Fortner - * 14 Jan 2013 - * - *------------------------------------------------------------------------- - */ -herr_t -H5Dscatter(H5D_scatter_func_t op, void *op_data, hid_t type_id, hid_t dst_space_id, void *dst_buf /*out*/) -{ - H5T_t * type; /* Datatype */ - H5S_t * dst_space; /* Dataspace */ - H5S_sel_iter_t *iter = NULL; /* Selection iteration info*/ - hbool_t iter_init = FALSE; /* Selection iteration info has been initialized */ - const void * src_buf = NULL; /* Source (contiguous) data buffer */ - size_t src_buf_nbytes = 0; /* Size of src_buf */ - size_t type_size; /* Datatype element size */ - hssize_t nelmts; /* Number of remaining elements in selection */ - size_t nelmts_scatter = 0; /* Number of elements to scatter to dst_buf */ - herr_t ret_value = SUCCEED; /* Return value */ - - FUNC_ENTER_API(FAIL) - H5TRACE5("e", "DS*xiix", op, op_data, type_id, dst_space_id, dst_buf); - - /* Check args */ - if (op == NULL) - HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "invalid callback function pointer") - if (NULL == (type = (H5T_t *)H5I_object_verify(type_id, H5I_DATATYPE))) - HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a datatype") - if (NULL == (dst_space = (H5S_t *)H5I_object_verify(dst_space_id, H5I_DATASPACE))) - HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a dataspace") - if (dst_buf == NULL) - HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "no destination buffer provided") - - /* Get datatype element size */ - if (0 == (type_size = H5T_GET_SIZE(type))) - HGOTO_ERROR(H5E_DATASET, H5E_CANTGET, FAIL, "can't get datatype size") - - /* Get number of elements in dataspace */ - if ((nelmts = (hssize_t)H5S_GET_SELECT_NPOINTS(dst_space)) < 0) - HGOTO_ERROR(H5E_DATASET, H5E_CANTCOUNT, FAIL, "unable to get number of elements in selection") - - /* Allocate the selection iterator */ - if (NULL == (iter = H5FL_MALLOC(H5S_sel_iter_t))) - HGOTO_ERROR(H5E_DATASET, H5E_CANTALLOC, FAIL, "can't allocate selection iterator") - - /* Initialize selection iterator */ - if (H5S_select_iter_init(iter, dst_space, type_size, 0) < 0) - HGOTO_ERROR(H5E_DATASET, H5E_CANTINIT, FAIL, "unable to initialize selection iterator information") - iter_init = TRUE; - - /* Loop until all data has been scattered */ - while (nelmts > 0) { - /* Make callback to retrieve data */ - if (op(&src_buf, &src_buf_nbytes, op_data) < 0) - HGOTO_ERROR(H5E_DATASET, H5E_CALLBACK, FAIL, "callback operator returned failure") - - /* Calculate number of elements */ - nelmts_scatter = src_buf_nbytes / type_size; - - /* Check callback results */ - if (!src_buf) - HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "callback did not return a buffer") - if (src_buf_nbytes == 0) - HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "callback returned a buffer size of 0") - if (src_buf_nbytes % type_size) - HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "buffer size is not a multiple of datatype size") - if (nelmts_scatter > (size_t)nelmts) - HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "callback returned more elements than in selection") - - /* Scatter data */ - if (H5D__scatter_mem(src_buf, iter, nelmts_scatter, dst_buf) < 0) - HGOTO_ERROR(H5E_DATASET, H5E_CANTCOPY, FAIL, "scatter failed") - - nelmts -= (hssize_t)nelmts_scatter; - } /* end while */ - -done: - /* Release selection iterator */ - if (iter_init && H5S_SELECT_ITER_RELEASE(iter) < 0) - HDONE_ERROR(H5E_DATASET, H5E_CANTFREE, FAIL, "Can't release selection iterator") - if (iter) - iter = H5FL_FREE(H5S_sel_iter_t, iter); - - FUNC_LEAVE_API(ret_value) -} /* H5Dscatter() */ - -/*------------------------------------------------------------------------- - * Function: H5Dgather - * - * Purpose: Gathers data provided from the source buffer src_buf to - * contiguous buffer dst_buf, then calls the callback op. - * The dimensions of src_buf and the selection to be gathered - * are specified by the dataspace src_space_id. The type of - * the data to be gathered is specified by type_id. - * - * Return: Non-negative on success/Negative on failure - * - * Programmer: Neil Fortner - * 16 Jan 2013 - * - *------------------------------------------------------------------------- - */ -herr_t -H5Dgather(hid_t src_space_id, const void *src_buf, hid_t type_id, size_t dst_buf_size, void *dst_buf /*out*/, - H5D_gather_func_t op, void *op_data) -{ - H5T_t * type; /* Datatype */ - H5S_t * src_space; /* Dataspace */ - H5S_sel_iter_t *iter = NULL; /* Selection iteration info*/ - hbool_t iter_init = FALSE; /* Selection iteration info has been initialized */ - size_t type_size; /* Datatype element size */ - hssize_t nelmts; /* Number of remaining elements in selection */ - size_t dst_buf_nelmts; /* Number of elements that can fit in dst_buf */ - size_t nelmts_gathered; /* Number of elements gathered from src_buf */ - herr_t ret_value = SUCCEED; /* Return value */ - - FUNC_ENTER_API(FAIL) - H5TRACE7("e", "i*xizxDg*x", src_space_id, src_buf, type_id, dst_buf_size, dst_buf, op, op_data); - - /* Check args */ - if (NULL == (src_space = (H5S_t *)H5I_object_verify(src_space_id, H5I_DATASPACE))) - HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a dataspace") - if (src_buf == NULL) - HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "no source buffer provided") - if (NULL == (type = (H5T_t *)H5I_object_verify(type_id, H5I_DATATYPE))) - HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a datatype") - if (dst_buf_size == 0) - HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "destination buffer size is 0") - if (dst_buf == NULL) - HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "no destination buffer provided") - - /* Get datatype element size */ - if (0 == (type_size = H5T_GET_SIZE(type))) - HGOTO_ERROR(H5E_DATASET, H5E_CANTGET, FAIL, "can't get datatype size") - - /* Get number of elements in dst_buf_size */ - dst_buf_nelmts = dst_buf_size / type_size; - if (dst_buf_nelmts == 0) - HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, - "destination buffer is not large enough to hold one element") - - /* Get number of elements in dataspace */ - if ((nelmts = (hssize_t)H5S_GET_SELECT_NPOINTS(src_space)) < 0) - HGOTO_ERROR(H5E_DATASET, H5E_CANTCOUNT, FAIL, "unable to get number of elements in selection") - - /* If dst_buf is not large enough to hold all the elements, make sure there - * is a callback */ - if (((size_t)nelmts > dst_buf_nelmts) && (op == NULL)) - HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "no callback supplied and destination buffer too small") - - /* Allocate the selection iterator */ - if (NULL == (iter = H5FL_MALLOC(H5S_sel_iter_t))) - HGOTO_ERROR(H5E_DATASET, H5E_CANTALLOC, FAIL, "can't allocate selection iterator") - - /* Initialize selection iterator */ - if (H5S_select_iter_init(iter, src_space, type_size, 0) < 0) - HGOTO_ERROR(H5E_DATASET, H5E_CANTINIT, FAIL, "unable to initialize selection iterator information") - iter_init = TRUE; - - /* Loop until all data has been scattered */ - while (nelmts > 0) { - /* Gather data */ - if (0 == - (nelmts_gathered = H5D__gather_mem(src_buf, iter, MIN(dst_buf_nelmts, (size_t)nelmts), dst_buf))) - HGOTO_ERROR(H5E_IO, H5E_CANTCOPY, FAIL, "gather failed") - HDassert(nelmts_gathered == MIN(dst_buf_nelmts, (size_t)nelmts)); - - /* Make callback to process dst_buf */ - if (op && op(dst_buf, nelmts_gathered * type_size, op_data) < 0) - HGOTO_ERROR(H5E_DATASET, H5E_CALLBACK, FAIL, "callback operator returned failure") - - nelmts -= (hssize_t)nelmts_gathered; - HDassert(op || (nelmts == 0)); - } /* end while */ - -done: - /* Release selection iterator */ - if (iter_init && H5S_SELECT_ITER_RELEASE(iter) < 0) - HDONE_ERROR(H5E_DATASET, H5E_CANTFREE, FAIL, "Can't release selection iterator") - if (iter) - iter = H5FL_FREE(H5S_sel_iter_t, iter); - - FUNC_LEAVE_API(ret_value) -} /* H5Dgather() */ @@ -771,6 +771,121 @@ done: } /* end H5Fdelete() */ /*------------------------------------------------------------------------- + * Function: H5Fmount + * + * Purpose: Mount file CHILD_ID onto the group specified by LOC_ID and + * NAME using mount properties PLIST_ID. + * + * Return: SUCCEED/FAIL + * + *------------------------------------------------------------------------- + */ +herr_t +H5Fmount(hid_t loc_id, const char *name, hid_t child_id, hid_t plist_id) +{ + 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 */ + + FUNC_ENTER_API(FAIL) + H5TRACE4("e", "i*sii", loc_id, name, child_id, plist_id); + + /* Check arguments */ + loc_type = H5I_get_type(loc_id); + if (H5I_FILE != loc_type && H5I_GROUP != loc_type) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "loc_id parameter not a file or group ID") + 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 the empty string") + child_type = H5I_get_type(child_id); + if (H5I_FILE != child_type) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "child_id parameter not a file ID") + if (H5P_DEFAULT == plist_id) + plist_id = H5P_FILE_MOUNT_DEFAULT; + else if (TRUE != H5P_isa_class(plist_id, H5P_FILE_MOUNT)) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "plist_id is not a file mount property list ID") + + /* Set up collective metadata if appropriate */ + if (H5CX_set_loc(loc_id) < 0) + HGOTO_ERROR(H5E_FILE, H5E_CANTSET, FAIL, "can't set collective metadata read info") + + /* Get the location object */ + 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_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 connector */ + if (loc_vol_obj->connector->cls->value != child_vol_obj->connector->cls->value) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "Can't mount file onto object from different VOL connector") + + /* Perform the mount operation */ + if (H5VL_file_specific(loc_vol_obj, H5VL_FILE_MOUNT, H5P_DATASET_XFER_DEFAULT, H5_REQUEST_NULL, + (int)loc_type, name, child_vol_obj->data, plist_id) < 0) + HGOTO_ERROR(H5E_FILE, H5E_MOUNT, FAIL, "unable to mount file") + +done: + FUNC_LEAVE_API(ret_value) +} /* end H5Fmount() */ + +/*------------------------------------------------------------------------- + * Function: H5Funmount + * + * Purpose: Given a mount point, dissassociate the mount point's file + * from the file mounted there. Do not close either file. + * + * The mount point can either be the group in the parent or the + * root group of the mounted file (both groups have the same + * name). If the mount point was opened before the mount then + * it's the group in the parent, but if it was opened after the + * mount then it's the root group of the child. + * + * Return: SUCCEED/FAIL + * + *------------------------------------------------------------------------- + */ +herr_t +H5Funmount(hid_t loc_id, const char *name) +{ + H5VL_object_t *vol_obj = NULL; /* Parent object */ + H5I_type_t loc_type; /* ID type of location */ + herr_t ret_value = SUCCEED; /* Return value */ + + FUNC_ENTER_API(FAIL) + H5TRACE2("e", "i*s", loc_id, name); + + /* Check arguments */ + loc_type = H5I_get_type(loc_id); + if (H5I_FILE != loc_type && H5I_GROUP != loc_type) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "loc_id parameter not a file or group ID") + 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 the empty string") + + /* Set up collective metadata if appropriate */ + if (H5CX_set_loc(loc_id) < 0) + HGOTO_ERROR(H5E_FILE, H5E_CANTSET, FAIL, "can't set collective metadata read info") + + /* Get the location object */ + 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 (H5VL_file_specific(vol_obj, H5VL_FILE_UNMOUNT, H5P_DATASET_XFER_DEFAULT, H5_REQUEST_NULL, + (int)loc_type, name) < 0) + HGOTO_ERROR(H5E_FILE, H5E_MOUNT, FAIL, "unable to unmount file") + +done: + FUNC_LEAVE_API(ret_value) +} /* end H5Funmount() */ + +/*------------------------------------------------------------------------- * Function: H5Freopen * * Purpose: Reopen a file. The new file handle which is returned points diff --git a/src/H5Fmount.c b/src/H5Fmount.c index 20c243e..340bf5d 100644 --- a/src/H5Fmount.c +++ b/src/H5Fmount.c @@ -424,121 +424,6 @@ H5F_is_mount(const H5F_t *file) } /* end H5F_is_mount() */ /*------------------------------------------------------------------------- - * Function: H5Fmount - * - * Purpose: Mount file CHILD_ID onto the group specified by LOC_ID and - * NAME using mount properties PLIST_ID. - * - * Return: SUCCEED/FAIL - * - *------------------------------------------------------------------------- - */ -herr_t -H5Fmount(hid_t loc_id, const char *name, hid_t child_id, hid_t plist_id) -{ - 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 */ - - FUNC_ENTER_API(FAIL) - H5TRACE4("e", "i*sii", loc_id, name, child_id, plist_id); - - /* Check arguments */ - loc_type = H5I_get_type(loc_id); - if (H5I_FILE != loc_type && H5I_GROUP != loc_type) - HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "loc_id parameter not a file or group ID") - 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 the empty string") - child_type = H5I_get_type(child_id); - if (H5I_FILE != child_type) - HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "child_id parameter not a file ID") - if (H5P_DEFAULT == plist_id) - plist_id = H5P_FILE_MOUNT_DEFAULT; - else if (TRUE != H5P_isa_class(plist_id, H5P_FILE_MOUNT)) - HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "plist_id is not a file mount property list ID") - - /* Set up collective metadata if appropriate */ - if (H5CX_set_loc(loc_id) < 0) - HGOTO_ERROR(H5E_FILE, H5E_CANTSET, FAIL, "can't set collective metadata read info") - - /* Get the location object */ - 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_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 connector */ - if (loc_vol_obj->connector->cls->value != child_vol_obj->connector->cls->value) - HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "Can't mount file onto object from different VOL connector") - - /* Perform the mount operation */ - if (H5VL_file_specific(loc_vol_obj, H5VL_FILE_MOUNT, H5P_DATASET_XFER_DEFAULT, H5_REQUEST_NULL, - (int)loc_type, name, child_vol_obj->data, plist_id) < 0) - HGOTO_ERROR(H5E_FILE, H5E_MOUNT, FAIL, "unable to mount file") - -done: - FUNC_LEAVE_API(ret_value) -} /* end H5Fmount() */ - -/*------------------------------------------------------------------------- - * Function: H5Funmount - * - * Purpose: Given a mount point, dissassociate the mount point's file - * from the file mounted there. Do not close either file. - * - * The mount point can either be the group in the parent or the - * root group of the mounted file (both groups have the same - * name). If the mount point was opened before the mount then - * it's the group in the parent, but if it was opened after the - * mount then it's the root group of the child. - * - * Return: SUCCEED/FAIL - * - *------------------------------------------------------------------------- - */ -herr_t -H5Funmount(hid_t loc_id, const char *name) -{ - H5VL_object_t *vol_obj = NULL; /* Parent object */ - H5I_type_t loc_type; /* ID type of location */ - herr_t ret_value = SUCCEED; /* Return value */ - - FUNC_ENTER_API(FAIL) - H5TRACE2("e", "i*s", loc_id, name); - - /* Check arguments */ - loc_type = H5I_get_type(loc_id); - if (H5I_FILE != loc_type && H5I_GROUP != loc_type) - HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "loc_id parameter not a file or group ID") - 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 the empty string") - - /* Set up collective metadata if appropriate */ - if (H5CX_set_loc(loc_id) < 0) - HGOTO_ERROR(H5E_FILE, H5E_CANTSET, FAIL, "can't set collective metadata read info") - - /* Get the location object */ - 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 (H5VL_file_specific(vol_obj, H5VL_FILE_UNMOUNT, H5P_DATASET_XFER_DEFAULT, H5_REQUEST_NULL, - (int)loc_type, name) < 0) - HGOTO_ERROR(H5E_FILE, H5E_MOUNT, FAIL, "unable to unmount file") - -done: - FUNC_LEAVE_API(ret_value) -} /* end H5Funmount() */ - -/*------------------------------------------------------------------------- * Function: H5F__mount_count_ids_recurse * * Purpose: Helper routine for counting number of open IDs in mount @@ -590,6 +590,103 @@ done: } /* end H5Lcreate_hard() */ /*------------------------------------------------------------------------- + * Function: H5Lcreate_external + * + * Purpose: Creates an external link from LINK_NAME to OBJ_NAME. + * + * External links are links to objects in other HDF5 files. They + * are allowed to "dangle" like soft links internal to a file. + * FILE_NAME is the name of the file that OBJ_NAME is is contained + * within. If OBJ_NAME is given as a relative path name, the + * path will be relative to the root group of FILE_NAME. + * LINK_NAME is interpreted relative to LINK_LOC_ID, which is + * either a file ID or a group ID. + * + * Return: Non-negative on success/Negative on failure + * + * Programmer: Quincey Koziol + * Wednesday, May 18, 2005 + * + *------------------------------------------------------------------------- + */ +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) +{ + H5VL_object_t * vol_obj = NULL; /* Object 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 */ + H5L_type_t link_type = H5L_TYPE_EXTERNAL; + herr_t ret_value = SUCCEED; /* Return value */ + + FUNC_ENTER_API(FAIL) + H5TRACE6("e", "*s*si*sii", file_name, obj_name, link_loc_id, link_name, lcpl_id, lapl_id); + + /* Check arguments */ + if (!file_name || !*file_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 (!link_name || !*link_name) + HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "no link name specified") + + /* Get the link creation property list */ + if (H5P_DEFAULT == lcpl_id) + lcpl_id = H5P_LINK_CREATE_DEFAULT; + + /* Set the LCPL for the API context */ + H5CX_set_lcpl(lcpl_id); + + /* 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") + + /* 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") + + /* Combine the filename and link name into a single buffer to give to the UD link */ + file_name_len = HDstrlen(file_name) + 1; + norm_obj_name_len = HDstrlen(norm_obj_name) + 1; + buf_size = 1 + file_name_len + norm_obj_name_len; + if (NULL == (ext_link_buf = H5MM_malloc(buf_size))) + HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, FAIL, "unable to allocate udata buffer") + + /* Encode the external link information */ + p = (uint8_t *)ext_link_buf; + *p++ = (H5L_EXT_VERSION << 4) | H5L_EXT_FLAGS_ALL; /* External link version & flags */ + HDstrncpy((char *)p, file_name, buf_size - 1); /* Name of file containing external link's object */ + p += file_name_len; + HDstrncpy((char *)p, norm_obj_name, buf_size - (file_name_len + 1)); /* External link's object */ + + loc_params.type = H5VL_OBJECT_BY_NAME; + loc_params.loc_data.loc_by_name.name = link_name; + loc_params.loc_data.loc_by_name.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") + + /* Create an external link */ + if (H5VL_link_create(H5VL_LINK_CREATE_UD, vol_obj, &loc_params, lcpl_id, lapl_id, + H5P_DATASET_XFER_DEFAULT, H5_REQUEST_NULL, (int)link_type, ext_link_buf, + buf_size) < 0) + HGOTO_ERROR(H5E_LINK, H5E_CANTINIT, FAIL, "unable to create external link") + +done: + H5MM_xfree(ext_link_buf); + H5MM_xfree(norm_obj_name); + + FUNC_LEAVE_API(ret_value) +} /* end H5Lcreate_external() */ + +/*------------------------------------------------------------------------- * Function: H5Lcreate_ud * * Purpose: Creates a user-defined link of type LINK_TYPE named LINK_NAME @@ -1519,6 +1616,88 @@ done: FUNC_LEAVE_API(ret_value) } /* end H5Lvisit_by_name2() */ +/*------------------------------------------------------------------------- + * Function: H5Lunpack_elink_val + * + * Purpose: Given a buffer holding the "link value" from an external link, + * gets pointers to the information within the link value buffer. + * + * External link link values contain some flags and + * two NULL-terminated strings, one after the other. + * + * The FLAGS value will be filled in and FILENAME and + * OBJ_PATH will be set to pointers within ext_linkval (unless + * any of these values is NULL). + * + * Using this function on strings that aren't external link + * udata buffers can result in segmentation faults. + * + * Return: Non-negative on success/ Negative on failure + * + * Programmer: James Laird + * Monday, July 17, 2006 + * + *------------------------------------------------------------------------- + */ +herr_t +H5Lunpack_elink_val(const void *_ext_linkval, size_t link_size, unsigned *flags, const char **filename, + const char **obj_path) +{ + const uint8_t *ext_linkval = (const uint8_t *)_ext_linkval; /* Pointer to the link value */ + unsigned lnk_version; /* External link format version */ + unsigned lnk_flags; /* External link flags */ + size_t len; /* Length of the filename in the linkval*/ + herr_t ret_value = SUCCEED; /* Return value */ + + FUNC_ENTER_API(FAIL) + H5TRACE5("e", "*xz*Iu**s**s", _ext_linkval, link_size, flags, filename, obj_path); + + /* Sanity check external link buffer */ + if (ext_linkval == NULL) + HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "not an external link linkval buffer") + lnk_version = (*ext_linkval >> 4) & 0x0F; + lnk_flags = *ext_linkval & 0x0F; + if (lnk_version > H5L_EXT_VERSION) + HGOTO_ERROR(H5E_LINK, H5E_CANTDECODE, FAIL, "bad version number for external link") + if (lnk_flags & (unsigned)~H5L_EXT_FLAGS_ALL) + HGOTO_ERROR(H5E_LINK, H5E_CANTDECODE, FAIL, "bad flags for external link") + if (link_size <= 2) + HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "not a valid external link buffer") + + /* Try to do some error checking. If the last character in the linkval + * (the last character of obj_path) isn't NULL, then something's wrong. + */ + if (ext_linkval[link_size - 1] != '\0') + HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "linkval buffer is not NULL-terminated") + + /* We're now guaranteed that HDstrlen won't segfault, since the buffer has + * at least one NULL in it. + */ + len = HDstrlen((const char *)ext_linkval + 1); + + /* If the first NULL we found was at the very end of the buffer, then + * this external link value has no object name and is invalid. + */ + if ((len + 1) >= (link_size - 1)) + HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "linkval buffer doesn't contain an object path") + + /* If we got here then the buffer contains (at least) two strings packed + * in the correct way. Assume it's correct and return pointers to the + * filename and object path. + */ + if (filename) + *filename = (const char *)ext_linkval + 1; + if (obj_path) + *obj_path = ((const char *)ext_linkval + 1) + len + 1; /* Add one for NULL terminator */ + + /* Set the flags to return */ + if (flags) + *flags = lnk_flags; + +done: + FUNC_LEAVE_API(ret_value) +} /* end H5Lunpack_elink_val() */ + /* *------------------------------------------------------------------------- *------------------------------------------------------------------------- diff --git a/src/H5Lexternal.c b/src/H5Lexternal.c index 028cfcf..1081c85 100644 --- a/src/H5Lexternal.c +++ b/src/H5Lexternal.c @@ -38,12 +38,6 @@ /* Local Macros */ /****************/ -/* Version of external link format */ -#define H5L_EXT_VERSION 0 - -/* Valid flags for external links */ -#define H5L_EXT_FLAGS_ALL 0 - /* Size of local link name buffer for traversing external links */ #define H5L_EXT_TRAVERSE_BUF_SIZE 256 @@ -314,103 +308,6 @@ done: } /* end H5L__extern_query() */ /*------------------------------------------------------------------------- - * Function: H5Lcreate_external - * - * Purpose: Creates an external link from LINK_NAME to OBJ_NAME. - * - * External links are links to objects in other HDF5 files. They - * are allowed to "dangle" like soft links internal to a file. - * FILE_NAME is the name of the file that OBJ_NAME is is contained - * within. If OBJ_NAME is given as a relative path name, the - * path will be relative to the root group of FILE_NAME. - * LINK_NAME is interpreted relative to LINK_LOC_ID, which is - * either a file ID or a group ID. - * - * Return: Non-negative on success/Negative on failure - * - * Programmer: Quincey Koziol - * Wednesday, May 18, 2005 - * - *------------------------------------------------------------------------- - */ -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) -{ - H5VL_object_t * vol_obj = NULL; /* Object 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 */ - H5L_type_t link_type = H5L_TYPE_EXTERNAL; - herr_t ret_value = SUCCEED; /* Return value */ - - FUNC_ENTER_API(FAIL) - H5TRACE6("e", "*s*si*sii", file_name, obj_name, link_loc_id, link_name, lcpl_id, lapl_id); - - /* Check arguments */ - if (!file_name || !*file_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 (!link_name || !*link_name) - HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "no link name specified") - - /* Get the link creation property list */ - if (H5P_DEFAULT == lcpl_id) - lcpl_id = H5P_LINK_CREATE_DEFAULT; - - /* Set the LCPL for the API context */ - H5CX_set_lcpl(lcpl_id); - - /* 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") - - /* 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") - - /* Combine the filename and link name into a single buffer to give to the UD link */ - file_name_len = HDstrlen(file_name) + 1; - norm_obj_name_len = HDstrlen(norm_obj_name) + 1; - buf_size = 1 + file_name_len + norm_obj_name_len; - if (NULL == (ext_link_buf = H5MM_malloc(buf_size))) - HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, FAIL, "unable to allocate udata buffer") - - /* Encode the external link information */ - p = (uint8_t *)ext_link_buf; - *p++ = (H5L_EXT_VERSION << 4) | H5L_EXT_FLAGS_ALL; /* External link version & flags */ - HDstrncpy((char *)p, file_name, buf_size - 1); /* Name of file containing external link's object */ - p += file_name_len; - HDstrncpy((char *)p, norm_obj_name, buf_size - (file_name_len + 1)); /* External link's object */ - - loc_params.type = H5VL_OBJECT_BY_NAME; - loc_params.loc_data.loc_by_name.name = link_name; - loc_params.loc_data.loc_by_name.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") - - /* Create an external link */ - if (H5VL_link_create(H5VL_LINK_CREATE_UD, vol_obj, &loc_params, lcpl_id, lapl_id, - H5P_DATASET_XFER_DEFAULT, H5_REQUEST_NULL, (int)link_type, ext_link_buf, - buf_size) < 0) - HGOTO_ERROR(H5E_LINK, H5E_CANTINIT, FAIL, "unable to create external link") - -done: - H5MM_xfree(ext_link_buf); - H5MM_xfree(norm_obj_name); - - FUNC_LEAVE_API(ret_value) -} /* end H5Lcreate_external() */ - -/*------------------------------------------------------------------------- * Function: H5L_register_external * * Purpose: Registers default "External Link" link class. @@ -437,85 +334,3 @@ H5L_register_external(void) done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5L_register_external() */ - -/*------------------------------------------------------------------------- - * Function: H5Lunpack_elink_val - * - * Purpose: Given a buffer holding the "link value" from an external link, - * gets pointers to the information within the link value buffer. - * - * External link link values contain some flags and - * two NULL-terminated strings, one after the other. - * - * The FLAGS value will be filled in and FILENAME and - * OBJ_PATH will be set to pointers within ext_linkval (unless - * any of these values is NULL). - * - * Using this function on strings that aren't external link - * udata buffers can result in segmentation faults. - * - * Return: Non-negative on success/ Negative on failure - * - * Programmer: James Laird - * Monday, July 17, 2006 - * - *------------------------------------------------------------------------- - */ -herr_t -H5Lunpack_elink_val(const void *_ext_linkval, size_t link_size, unsigned *flags, const char **filename, - const char **obj_path) -{ - const uint8_t *ext_linkval = (const uint8_t *)_ext_linkval; /* Pointer to the link value */ - unsigned lnk_version; /* External link format version */ - unsigned lnk_flags; /* External link flags */ - size_t len; /* Length of the filename in the linkval*/ - herr_t ret_value = SUCCEED; /* Return value */ - - FUNC_ENTER_API(FAIL) - H5TRACE5("e", "*xz*Iu**s**s", _ext_linkval, link_size, flags, filename, obj_path); - - /* Sanity check external link buffer */ - if (ext_linkval == NULL) - HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "not an external link linkval buffer") - lnk_version = (*ext_linkval >> 4) & 0x0F; - lnk_flags = *ext_linkval & 0x0F; - if (lnk_version > H5L_EXT_VERSION) - HGOTO_ERROR(H5E_LINK, H5E_CANTDECODE, FAIL, "bad version number for external link") - if (lnk_flags & (unsigned)~H5L_EXT_FLAGS_ALL) - HGOTO_ERROR(H5E_LINK, H5E_CANTDECODE, FAIL, "bad flags for external link") - if (link_size <= 2) - HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "not a valid external link buffer") - - /* Try to do some error checking. If the last character in the linkval - * (the last character of obj_path) isn't NULL, then something's wrong. - */ - if (ext_linkval[link_size - 1] != '\0') - HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "linkval buffer is not NULL-terminated") - - /* We're now guaranteed that HDstrlen won't segfault, since the buffer has - * at least one NULL in it. - */ - len = HDstrlen((const char *)ext_linkval + 1); - - /* If the first NULL we found was at the very end of the buffer, then - * this external link value has no object name and is invalid. - */ - if ((len + 1) >= (link_size - 1)) - HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "linkval buffer doesn't contain an object path") - - /* If we got here then the buffer contains (at least) two strings packed - * in the correct way. Assume it's correct and return pointers to the - * filename and object path. - */ - if (filename) - *filename = (const char *)ext_linkval + 1; - if (obj_path) - *obj_path = ((const char *)ext_linkval + 1) + len + 1; /* Add one for NULL terminator */ - - /* Set the flags to return */ - if (flags) - *flags = lnk_flags; - -done: - FUNC_LEAVE_API(ret_value) -} /* end H5Lunpack_elink_val() */ diff --git a/src/H5Lpkg.h b/src/H5Lpkg.h index 45c6618..fe08ea4 100644 --- a/src/H5Lpkg.h +++ b/src/H5Lpkg.h @@ -35,6 +35,12 @@ /* Package Private Macros */ /**************************/ +/* Version of external link format */ +#define H5L_EXT_VERSION 0 + +/* Valid flags for external links */ +#define H5L_EXT_FLAGS_ALL 0 + /****************************/ /* Package Private Typedefs */ /****************************/ @@ -263,6 +263,225 @@ done: } /* end H5Oopen_by_token() */ /*------------------------------------------------------------------------- + * Function: H5Ocopy + * + * Purpose: Copy an object (group or dataset) to destination location + * within a file or cross files. PLIST_ID is a property list + * which is used to pass user options and properties to the + * copy. The name, dst_name, must not already be taken by some + * other object in the destination group. + * + * H5Ocopy() will fail if the name of the destination object + * exists in the destination group. For example, + * H5Ocopy(fid_src, "/dset", fid_dst, "/dset", ...) + * will fail if "/dset" exists in the destination file + * + * OPTIONS THAT HAVE BEEN IMPLEMENTED. + * H5O_COPY_SHALLOW_HIERARCHY_FLAG + * If this flag is specified, only immediate members of + * the group are copied. Otherwise (default), it will + * recursively copy all objects below the group + * H5O_COPY_EXPAND_SOFT_LINK_FLAG + * If this flag is specified, it will copy the objects + * pointed by the soft links. Otherwise (default), it + * will copy the soft link as they are + * H5O_COPY_WITHOUT_ATTR_FLAG + * If this flag is specified, it will copy object without + * copying attributes. Otherwise (default), it will + * copy object along with all its attributes + * H5O_COPY_EXPAND_REFERENCE_FLAG + * 1) Copy object between two different files: + * When this flag is specified, it will copy objects that + * are pointed by the references and update the values of + * references in the destination file. Otherwise (default) + * the values of references in the destination will set to + * zero + * The current implementation does not handle references + * inside of other datatype structure. For example, if + * a member of compound datatype is reference, H5Ocopy() + * will copy that field as it is. It will not set the + * value to zero as default is used nor copy the object + * pointed by that field the flag is set + * 2) Copy object within the same file: + * This flag does not have any effect to the H5Ocopy(). + * Datasets or attributes of references are copied as they + * are, i.e. values of references of the destination object + * are the same as the values of the source object + * + * OPTIONS THAT MAY APPLY TO COPY IN THE FUTURE. + * H5O_COPY_EXPAND_EXT_LINK_FLAG + * If this flag is specified, it will expand the external links + * into new objects, Otherwise (default), it will keep external + * links as they are (default) + * + * PROPERTIES THAT MAY APPLY TO COPY IN FUTURE + * Change data layout such as chunk size + * Add filter such as data compression. + * Add an attribute to the copied object(s) that say the date/time + * for the copy or other information about the source file. + * + * The intermediate group creation property should be passed in + * using the lcpl instead of the ocpypl. + * + * Usage: H5Ocopy(src_loc_id, src_name, dst_loc_id, dst_name, ocpypl_id, lcpl_id) + * hid_t src_loc_id IN: Source file or group identifier. + * const char *src_name IN: Name of the source object to be copied + * hid_t dst_loc_id IN: Destination file or group identifier + * const char *dst_name IN: Name of the destination object + * hid_t ocpypl_id IN: Properties which apply to the copy + * hid_t lcpl_id IN: Properties which apply to the new hard link + * + * + * Return: SUCCEED/FAIL + * + *------------------------------------------------------------------------- + */ +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) +{ + H5VL_object_t * vol_obj1 = NULL; /* object of src_id */ + H5VL_loc_params_t loc_params1; + H5VL_object_t * vol_obj2 = NULL; /* object of dst_id */ + H5VL_loc_params_t loc_params2; + herr_t ret_value = SUCCEED; /* Return value */ + + FUNC_ENTER_API(FAIL) + H5TRACE6("e", "i*si*sii", src_loc_id, src_name, dst_loc_id, dst_name, ocpypl_id, lcpl_id); + + /* Check arguments */ + if (!src_name || !*src_name) + HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "no source name specified") + if (!dst_name || !*dst_name) + HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "no destination name specified") + + /* Get correct property lists */ + if (H5P_DEFAULT == lcpl_id) + lcpl_id = H5P_LINK_CREATE_DEFAULT; + else if (TRUE != H5P_isa_class(lcpl_id, H5P_LINK_CREATE)) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not link creation property list") + + /* Get object copy property list */ + if (H5P_DEFAULT == ocpypl_id) + ocpypl_id = H5P_OBJECT_COPY_DEFAULT; + else if (TRUE != H5P_isa_class(ocpypl_id, H5P_OBJECT_COPY)) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not object copy property list") + + /* Set the LCPL for the API context */ + H5CX_set_lcpl(lcpl_id); + + /* Set up collective metadata if appropriate */ + 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 (H5VL_object_copy(vol_obj1, &loc_params1, src_name, vol_obj2, &loc_params2, 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: + FUNC_LEAVE_API(ret_value) +} /* end H5Ocopy() */ + +/*------------------------------------------------------------------------- + * Function: H5Oflush + * + * Purpose: Flushes all buffers associated with an object to disk. + * + * Return: Non-negative on success, negative on failure + * + * Programmer: Mike McGreevy + * May 19, 2010 + * + *------------------------------------------------------------------------- + */ +herr_t +H5Oflush(hid_t obj_id) +{ + H5VL_object_t * vol_obj = NULL; /* Object of obj_id */ + 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 == (vol_obj = H5VL_vol_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_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(obj_id); + + /* Flush the object */ + if (H5VL_object_specific(vol_obj, &loc_params, 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: + FUNC_LEAVE_API(ret_value) +} /* end H5Oflush() */ + +/*------------------------------------------------------------------------- + * Function: H5Orefresh + * + * Purpose: Refreshes all buffers associated with an object. + * + * Return: Non-negative on success, negative on failure + * + * Programmer: Mike McGreevy + * July 28, 2010 + * + *------------------------------------------------------------------------- + */ +herr_t +H5Orefresh(hid_t oid) +{ + H5VL_object_t * vol_obj = NULL; /* Object of oid */ + 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 == (vol_obj = H5VL_vol_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 (H5VL_object_specific(vol_obj, &loc_params, H5VL_OBJECT_REFRESH, H5P_DATASET_XFER_DEFAULT, + H5_REQUEST_NULL, oid) < 0) + HGOTO_ERROR(H5E_OHDR, H5E_CANTLOAD, FAIL, "unable to refresh object") + +done: + FUNC_LEAVE_API(ret_value) +} /* end H5Orefresh() */ + +/*------------------------------------------------------------------------- * Function: H5Olink * * Purpose: Creates a hard link from NEW_NAME to the object specified diff --git a/src/H5Ocopy.c b/src/H5Ocopy.c index 54a41c0..c6f54d7 100644 --- a/src/H5Ocopy.c +++ b/src/H5Ocopy.c @@ -111,139 +111,6 @@ H5FL_DEFINE(haddr_t); /*******************/ /*------------------------------------------------------------------------- - * Function: H5Ocopy - * - * Purpose: Copy an object (group or dataset) to destination location - * within a file or cross files. PLIST_ID is a property list - * which is used to pass user options and properties to the - * copy. The name, dst_name, must not already be taken by some - * other object in the destination group. - * - * H5Ocopy() will fail if the name of the destination object - * exists in the destination group. For example, - * H5Ocopy(fid_src, "/dset", fid_dst, "/dset", ...) - * will fail if "/dset" exists in the destination file - * - * OPTIONS THAT HAVE BEEN IMPLEMENTED. - * H5O_COPY_SHALLOW_HIERARCHY_FLAG - * If this flag is specified, only immediate members of - * the group are copied. Otherwise (default), it will - * recursively copy all objects below the group - * H5O_COPY_EXPAND_SOFT_LINK_FLAG - * If this flag is specified, it will copy the objects - * pointed by the soft links. Otherwise (default), it - * will copy the soft link as they are - * H5O_COPY_WITHOUT_ATTR_FLAG - * If this flag is specified, it will copy object without - * copying attributes. Otherwise (default), it will - * copy object along with all its attributes - * H5O_COPY_EXPAND_REFERENCE_FLAG - * 1) Copy object between two different files: - * When this flag is specified, it will copy objects that - * are pointed by the references and update the values of - * references in the destination file. Otherwise (default) - * the values of references in the destination will set to - * zero - * The current implementation does not handle references - * inside of other datatype structure. For example, if - * a member of compound datatype is reference, H5Ocopy() - * will copy that field as it is. It will not set the - * value to zero as default is used nor copy the object - * pointed by that field the flag is set - * 2) Copy object within the same file: - * This flag does not have any effect to the H5Ocopy(). - * Datasets or attributes of references are copied as they - * are, i.e. values of references of the destination object - * are the same as the values of the source object - * - * OPTIONS THAT MAY APPLY TO COPY IN THE FUTURE. - * H5O_COPY_EXPAND_EXT_LINK_FLAG - * If this flag is specified, it will expand the external links - * into new objects, Otherwise (default), it will keep external - * links as they are (default) - * - * PROPERTIES THAT MAY APPLY TO COPY IN FUTURE - * Change data layout such as chunk size - * Add filter such as data compression. - * Add an attribute to the copied object(s) that say the date/time - * for the copy or other information about the source file. - * - * The intermediate group creation property should be passed in - * using the lcpl instead of the ocpypl. - * - * Usage: H5Ocopy(src_loc_id, src_name, dst_loc_id, dst_name, ocpypl_id, lcpl_id) - * hid_t src_loc_id IN: Source file or group identifier. - * const char *src_name IN: Name of the source object to be copied - * hid_t dst_loc_id IN: Destination file or group identifier - * const char *dst_name IN: Name of the destination object - * hid_t ocpypl_id IN: Properties which apply to the copy - * hid_t lcpl_id IN: Properties which apply to the new hard link - * - * - * Return: SUCCEED/FAIL - * - *------------------------------------------------------------------------- - */ -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) -{ - H5VL_object_t * vol_obj1 = NULL; /* object of src_id */ - H5VL_loc_params_t loc_params1; - H5VL_object_t * vol_obj2 = NULL; /* object of dst_id */ - H5VL_loc_params_t loc_params2; - herr_t ret_value = SUCCEED; /* Return value */ - - FUNC_ENTER_API(FAIL) - H5TRACE6("e", "i*si*sii", src_loc_id, src_name, dst_loc_id, dst_name, ocpypl_id, lcpl_id); - - /* Check arguments */ - if (!src_name || !*src_name) - HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "no source name specified") - if (!dst_name || !*dst_name) - HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "no destination name specified") - - /* Get correct property lists */ - if (H5P_DEFAULT == lcpl_id) - lcpl_id = H5P_LINK_CREATE_DEFAULT; - else if (TRUE != H5P_isa_class(lcpl_id, H5P_LINK_CREATE)) - HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not link creation property list") - - /* Get object copy property list */ - if (H5P_DEFAULT == ocpypl_id) - ocpypl_id = H5P_OBJECT_COPY_DEFAULT; - else if (TRUE != H5P_isa_class(ocpypl_id, H5P_OBJECT_COPY)) - HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not object copy property list") - - /* Set the LCPL for the API context */ - H5CX_set_lcpl(lcpl_id); - - /* Set up collective metadata if appropriate */ - 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 (H5VL_object_copy(vol_obj1, &loc_params1, src_name, vol_obj2, &loc_params2, 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: - FUNC_LEAVE_API(ret_value) -} /* end H5Ocopy() */ - -/*------------------------------------------------------------------------- * Function: H5O__copy * * Purpose: Private version of H5Ocopy diff --git a/src/H5Oflush.c b/src/H5Oflush.c index 19e231d..adbe4fa 100644 --- a/src/H5Oflush.c +++ b/src/H5Oflush.c @@ -54,49 +54,6 @@ static herr_t H5O__refresh_metadata_close(hid_t oid, H5O_loc_t oloc, H5G_loc_t * /*************/ /*------------------------------------------------------------------------- - * Function: H5Oflush - * - * Purpose: Flushes all buffers associated with an object to disk. - * - * Return: Non-negative on success, negative on failure - * - * Programmer: Mike McGreevy - * May 19, 2010 - * - *------------------------------------------------------------------------- - */ -herr_t -H5Oflush(hid_t obj_id) -{ - H5VL_object_t * vol_obj = NULL; /* Object of obj_id */ - 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 == (vol_obj = H5VL_vol_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_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(obj_id); - - /* Flush the object */ - if (H5VL_object_specific(vol_obj, &loc_params, 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: - FUNC_LEAVE_API(ret_value) -} /* end H5Oflush() */ - -/*------------------------------------------------------------------------- * Function: H5O_flush * * Purpose: Internal routine to flush an object @@ -215,49 +172,6 @@ done: } /* end H5O__oh_tag() */ /*------------------------------------------------------------------------- - * Function: H5Orefresh - * - * Purpose: Refreshes all buffers associated with an object. - * - * Return: Non-negative on success, negative on failure - * - * Programmer: Mike McGreevy - * July 28, 2010 - * - *------------------------------------------------------------------------- - */ -herr_t -H5Orefresh(hid_t oid) -{ - H5VL_object_t * vol_obj = NULL; /* Object of oid */ - 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 == (vol_obj = H5VL_vol_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 (H5VL_object_specific(vol_obj, &loc_params, H5VL_OBJECT_REFRESH, H5P_DATASET_XFER_DEFAULT, - H5_REQUEST_NULL, oid) < 0) - HGOTO_ERROR(H5E_OHDR, H5E_CANTLOAD, FAIL, "unable to refresh object") - -done: - FUNC_LEAVE_API(ret_value) -} /* end H5Orefresh() */ - -/*------------------------------------------------------------------------- * Function: H5O_refresh_metadata * * Purpose: Refreshes all buffers associated with an object. |