summaryrefslogtreecommitdiffstats
path: root/src/H5Tref.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/H5Tref.c')
-rw-r--r--src/H5Tref.c125
1 files changed, 93 insertions, 32 deletions
diff --git a/src/H5Tref.c b/src/H5Tref.c
index 1114c25..cac8cf6 100644
--- a/src/H5Tref.c
+++ b/src/H5Tref.c
@@ -289,12 +289,16 @@ H5T__ref_set_loc(H5T_t *dt, H5VL_object_t *file, H5T_loc_t loc)
} /* end else-if */
else {
H5VL_file_cont_info_t cont_info = {H5VL_CONTAINER_INFO_VERSION, 0, 0, 0};
+ H5VL_file_get_args_t vol_cb_args; /* Arguments to VOL callback */
size_t ref_encode_size;
H5R_ref_priv_t fixed_ref;
+ /* Set up VOL callback arguments */
+ vol_cb_args.op_type = H5VL_FILE_GET_CONT_INFO;
+ vol_cb_args.args.get_cont_info.info = &cont_info;
+
/* Get container info */
- if (H5VL_file_get(file, H5VL_FILE_GET_CONT_INFO, H5P_DATASET_XFER_DEFAULT, H5_REQUEST_NULL,
- &cont_info) < 0)
+ if (H5VL_file_get(file, &vol_cb_args, H5P_DATASET_XFER_DEFAULT, H5_REQUEST_NULL) < 0)
HGOTO_ERROR(H5E_DATATYPE, H5E_CANTGET, FAIL, "unable to get container info")
/* Retrieve min encode size (when references have no vlen part) */
@@ -434,8 +438,10 @@ H5T__ref_mem_getsize(H5VL_object_t H5_ATTR_UNUSED *src_file, const void *src_buf
/* Force re-calculating encoding size if any flags are set */
if (flags || !src_ref->encode_size) {
- char file_name_buf_static[256]; /* File name */
- ssize_t file_name_len; /* Size of file name buffer */
+ H5VL_file_get_args_t vol_cb_args; /* Arguments to VOL callback */
+ char * file_name = NULL; /* Actual file name */
+ char file_name_buf_static[256]; /* File name */
+ size_t file_name_len = 0; /* Length of file name */
/* Pass the correct encoding version for the selection depending on the
* file libver bounds, this is later retrieved in H5S hyper encode */
@@ -458,21 +464,38 @@ H5T__ref_mem_getsize(H5VL_object_t H5_ATTR_UNUSED *src_file, const void *src_buf
H5CX_set_libver_bounds(NULL);
} /* end if */
+ /* Set up VOL callback arguments */
+ vol_cb_args.op_type = H5VL_FILE_GET_NAME;
+ vol_cb_args.args.get_name.type = H5I_FILE;
+ vol_cb_args.args.get_name.buf_size = sizeof(file_name_buf_static);
+ vol_cb_args.args.get_name.buf = file_name_buf_static;
+ vol_cb_args.args.get_name.file_name_len = &file_name_len;
+
/* Get file name */
- if (H5VL_file_get(vol_obj, H5VL_FILE_GET_NAME, H5P_DATASET_XFER_DEFAULT, NULL, H5I_FILE,
- sizeof(file_name_buf_static), file_name_buf_static, &file_name_len) < 0)
+ if (H5VL_file_get(vol_obj, &vol_cb_args, H5P_DATASET_XFER_DEFAULT, NULL) < 0)
HGOTO_ERROR(H5E_REFERENCE, H5E_CANTGET, 0, "can't get file name")
- if (file_name_len >= (ssize_t)sizeof(file_name_buf_static)) {
- if (NULL == (file_name_buf_dyn = (char *)H5MM_malloc((size_t)file_name_len + 1)))
- HGOTO_ERROR(H5E_RESOURCE, H5E_CANTALLOC, 0, "can't allocate space for file name")
- if (H5VL_file_get(vol_obj, H5VL_FILE_GET_NAME, H5P_DATASET_XFER_DEFAULT, NULL, H5I_FILE,
- (size_t)file_name_len + 1, file_name_buf_dyn, &file_name_len) < 0)
+
+ /* Check if we need to allocate a buffer for the file name */
+ if (file_name_len >= sizeof(file_name_buf_static)) {
+ /* Allocate file name buffer */
+ if (NULL == (file_name_buf_dyn = H5MM_malloc(file_name_len + 1)))
+ HGOTO_ERROR(H5E_REFERENCE, H5E_CANTALLOC, 0, "can't allocate space for file name")
+
+ /* Update VOL callback arguments */
+ vol_cb_args.args.get_name.buf_size = file_name_len + 1;
+ vol_cb_args.args.get_name.buf = file_name_buf_dyn;
+
+ /* Get file name again */
+ if (H5VL_file_get(vol_obj, &vol_cb_args, H5P_DATASET_XFER_DEFAULT, NULL) < 0)
HGOTO_ERROR(H5E_REFERENCE, H5E_CANTGET, 0, "can't get file name")
+
+ file_name = file_name_buf_dyn;
} /* end if */
+ else
+ file_name = file_name_buf_static;
/* Determine encoding size */
- if (H5R__encode(file_name_buf_dyn ? file_name_buf_dyn : file_name_buf_static, src_ref, NULL,
- &ret_value, flags) < 0)
+ if (H5R__encode(file_name, src_ref, NULL, &ret_value, flags) < 0)
HGOTO_ERROR(H5E_REFERENCE, H5E_CANTENCODE, 0, "unable to determine encoding size")
} /* end if */
else {
@@ -506,10 +529,10 @@ H5T__ref_mem_read(H5VL_object_t H5_ATTR_UNUSED *src_file, const void *src_buf, s
H5VL_object_t * vol_obj; /* VOL object for src ref's location */
const H5R_ref_priv_t *src_ref = (const H5R_ref_priv_t *)src_buf;
hbool_t files_equal = TRUE; /* Whether src & dst references are in same file */
+ char * file_name = NULL; /* Actual file name */
char file_name_buf_static[256] = {'\0'}; /* File name */
char * file_name_buf_dyn =
NULL; /* Pointer to dynamically allocated buffer for file name, if static buffer is too small */
- ssize_t file_name_len; /* Size of file name buffer */
unsigned flags = 0; /* References flags */
herr_t ret_value = SUCCEED; /* Return value */
@@ -560,21 +583,42 @@ H5T__ref_mem_read(H5VL_object_t H5_ATTR_UNUSED *src_file, const void *src_buf, s
/* Get file name (if external reference) */
if (flags) {
- if (H5VL_file_get(vol_obj, H5VL_FILE_GET_NAME, H5P_DATASET_XFER_DEFAULT, NULL, H5I_FILE,
- sizeof(file_name_buf_static), file_name_buf_static, &file_name_len) < 0)
+ H5VL_file_get_args_t vol_cb_args; /* Arguments to VOL callback */
+ size_t file_name_len = 0; /* Length of file name */
+
+ /* Set up VOL callback arguments */
+ vol_cb_args.op_type = H5VL_FILE_GET_NAME;
+ vol_cb_args.args.get_name.type = H5I_FILE;
+ vol_cb_args.args.get_name.buf_size = sizeof(file_name_buf_static);
+ vol_cb_args.args.get_name.buf = file_name_buf_static;
+ vol_cb_args.args.get_name.file_name_len = &file_name_len;
+
+ /* Get file name */
+ if (H5VL_file_get(vol_obj, &vol_cb_args, H5P_DATASET_XFER_DEFAULT, NULL) < 0)
HGOTO_ERROR(H5E_REFERENCE, H5E_CANTGET, 0, "can't get file name")
- if (file_name_len >= (ssize_t)sizeof(file_name_buf_static)) {
- if (NULL == (file_name_buf_dyn = (char *)H5MM_malloc((size_t)file_name_len + 1)))
- HGOTO_ERROR(H5E_RESOURCE, H5E_CANTALLOC, 0, "can't allocate space for file name")
- if (H5VL_file_get(vol_obj, H5VL_FILE_GET_NAME, H5P_DATASET_XFER_DEFAULT, NULL, H5I_FILE,
- (size_t)file_name_len + 1, file_name_buf_dyn, &file_name_len) < 0)
+
+ /* Check if we need to allocate a buffer for the file name */
+ if (file_name_len >= sizeof(file_name_buf_static)) {
+ /* Allocate file name buffer */
+ if (NULL == (file_name_buf_dyn = H5MM_malloc(file_name_len + 1)))
+ HGOTO_ERROR(H5E_REFERENCE, H5E_CANTALLOC, 0, "can't allocate space for file name")
+
+ /* Update VOL callback arguments */
+ vol_cb_args.args.get_name.buf_size = file_name_len + 1;
+ vol_cb_args.args.get_name.buf = file_name_buf_dyn;
+
+ /* Get file name again */
+ if (H5VL_file_get(vol_obj, &vol_cb_args, H5P_DATASET_XFER_DEFAULT, NULL) < 0)
HGOTO_ERROR(H5E_REFERENCE, H5E_CANTGET, 0, "can't get file name")
+
+ file_name = file_name_buf_dyn;
} /* end if */
- } /* end if */
+ else
+ file_name = file_name_buf_static;
+ } /* end if */
/* Encode reference */
- if (H5R__encode(file_name_buf_dyn ? file_name_buf_dyn : file_name_buf_static, src_ref,
- (unsigned char *)dst_buf, &dst_size, flags) < 0)
+ if (H5R__encode(file_name, src_ref, (unsigned char *)dst_buf, &dst_size, flags) < 0)
HGOTO_ERROR(H5E_REFERENCE, H5E_CANTENCODE, FAIL, "Cannot encode reference")
done:
@@ -731,11 +775,17 @@ H5T__ref_disk_isnull(const H5VL_object_t *src_file, const void *src_buf, hbool_t
*isnull = FALSE;
}
else {
+ H5VL_blob_specific_args_t vol_cb_args; /* Arguments to VOL callback */
+
/* Skip the size / header */
p = (const uint8_t *)src_buf + H5R_ENCODE_HEADER_SIZE + H5_SIZEOF_UINT32_T;
+ /* Set up VOL callback arguments */
+ vol_cb_args.op_type = H5VL_BLOB_ISNULL;
+ vol_cb_args.args.is_null.isnull = isnull;
+
/* Check if blob ID is "nil" */
- if (H5VL_blob_specific(src_file, (void *)p, H5VL_BLOB_ISNULL, isnull) < 0)
+ if (H5VL_blob_specific(src_file, (void *)p, &vol_cb_args) < 0)
HGOTO_ERROR(H5E_DATATYPE, H5E_CANTGET, FAIL, "unable to check if a blob ID is 'nil'")
}
@@ -755,9 +805,10 @@ done:
static herr_t
H5T__ref_disk_setnull(H5VL_object_t *dst_file, void *dst_buf, void *bg_buf)
{
- uint8_t *q = (uint8_t *)dst_buf;
- uint8_t *p_bg = (uint8_t *)bg_buf;
- herr_t ret_value = SUCCEED;
+ H5VL_blob_specific_args_t vol_cb_args; /* Arguments to VOL callback */
+ uint8_t * q = (uint8_t *)dst_buf;
+ uint8_t * p_bg = (uint8_t *)bg_buf;
+ herr_t ret_value = SUCCEED;
FUNC_ENTER_STATIC
H5T_REF_LOG_DEBUG("");
@@ -770,8 +821,11 @@ H5T__ref_disk_setnull(H5VL_object_t *dst_file, void *dst_buf, void *bg_buf)
/* Skip the size / header */
p_bg += (H5_SIZEOF_UINT32_T + H5R_ENCODE_HEADER_SIZE);
+ /* Set up VOL callback arguments */
+ vol_cb_args.op_type = H5VL_BLOB_DELETE;
+
/* Remove blob for old data */
- if (H5VL_blob_specific(dst_file, (void *)p_bg, H5VL_BLOB_DELETE) < 0)
+ if (H5VL_blob_specific(dst_file, (void *)p_bg, &vol_cb_args) < 0)
HGOTO_ERROR(H5E_DATATYPE, H5E_CANTREMOVE, FAIL, "unable to delete blob")
} /* end if */
@@ -782,8 +836,11 @@ H5T__ref_disk_setnull(H5VL_object_t *dst_file, void *dst_buf, void *bg_buf)
/* Set the size */
UINT32ENCODE(q, 0);
+ /* Set up VOL callback arguments */
+ vol_cb_args.op_type = H5VL_BLOB_SETNULL;
+
/* Set blob ID to "nil" */
- if (H5VL_blob_specific(dst_file, q, H5VL_BLOB_SETNULL) < 0)
+ if (H5VL_blob_specific(dst_file, q, &vol_cb_args) < 0)
HGOTO_ERROR(H5E_DATATYPE, H5E_CANTSET, FAIL, "unable to set a blob ID to 'nil'")
done:
@@ -913,15 +970,19 @@ H5T__ref_disk_write(H5VL_object_t H5_ATTR_UNUSED *src_file, const void *src_buf,
/* TODO Should get rid of bg stuff */
if (p_bg) {
- size_t p_buf_size_left = dst_size;
+ H5VL_blob_specific_args_t vol_cb_args; /* Arguments to VOL callback */
+ size_t p_buf_size_left = dst_size;
/* Skip the size / header */
p_bg += (H5_SIZEOF_UINT32_T + H5R_ENCODE_HEADER_SIZE);
HDassert(p_buf_size_left > (H5_SIZEOF_UINT32_T + H5R_ENCODE_HEADER_SIZE));
p_buf_size_left -= (H5_SIZEOF_UINT32_T + H5R_ENCODE_HEADER_SIZE);
+ /* Set up VOL callback arguments */
+ vol_cb_args.op_type = H5VL_BLOB_DELETE;
+
/* Remove blob for old data */
- if (H5VL_blob_specific(dst_file, (void *)p_bg, H5VL_BLOB_DELETE) < 0)
+ if (H5VL_blob_specific(dst_file, (void *)p_bg, &vol_cb_args) < 0)
HGOTO_ERROR(H5E_DATATYPE, H5E_CANTREMOVE, FAIL, "unable to delete blob")
} /* end if */