summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--src/H5O.c44
-rw-r--r--src/H5Ocopy_ref.c23
-rw-r--r--src/H5Rdeprec.c130
-rw-r--r--src/H5Rint.c119
-rw-r--r--src/H5Rpkg.h10
-rw-r--r--src/H5T.c2
-rw-r--r--src/H5Tref.c35
-rw-r--r--src/H5VLnative_object.c21
8 files changed, 226 insertions, 158 deletions
diff --git a/src/H5O.c b/src/H5O.c
index 0c999ba..ffb49d9 100644
--- a/src/H5O.c
+++ b/src/H5O.c
@@ -255,22 +255,48 @@ hid_t
H5Oopen_by_addr(hid_t loc_id, haddr_t addr)
{
H5VL_object_t *vol_obj; /* Object token of loc_id */
- H5I_type_t opened_type;
- void *opened_obj = NULL;
- H5VL_loc_params_t loc_params;
- hid_t ret_value = H5I_INVALID_HID; /* Return value */
+ H5I_type_t vol_obj_type = H5I_BADID;/* Object type of loc_id */
+ H5I_type_t opened_type; /* Opened object type */
+ void *opened_obj = NULL; /* Opened object */
+ H5VL_loc_params_t loc_params; /* Location parameters */
+ H5VL_token_t obj_token = {0}; /* Object token */
+ hid_t file_id = H5I_INVALID_HID; /* File ID */
+ void *vol_obj_file = NULL; /* Object token of file_id */
+ H5F_t *f = NULL;
+ uint8_t *p = NULL;
+ hid_t ret_value = H5I_INVALID_HID; /* Return value */
FUNC_ENTER_API(H5I_INVALID_HID)
H5TRACE2("i", "ia", loc_id, addr);
- loc_params.type = H5VL_OBJECT_BY_TOKEN;
- loc_params.loc_data.loc_by_token.token = &addr;
- loc_params.obj_type = H5I_get_type(loc_id);
-
/* Get the location object */
if(NULL == (vol_obj = (H5VL_object_t *)H5I_object(loc_id)))
HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, H5I_INVALID_HID, "invalid location identifier")
+ /* Get object type */
+ if((vol_obj_type = H5I_get_type(loc_id)) < 0)
+ HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, H5I_INVALID_HID, "invalid location identifier")
+
+ /* Get the file for the object */
+ if((file_id = H5F_get_file_id(loc_id, vol_obj_type, FALSE)) < 0)
+ HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, H5I_INVALID_HID, "not a file or file object")
+
+ /* Retrieve VOL object */
+ if(NULL == (vol_obj_file = H5VL_vol_object(file_id)))
+ HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, H5I_INVALID_HID, "invalid location identifier")
+
+ /* Retrieve file from VOL object */
+ if(NULL == (f = (H5F_t *)H5VL_object_data(vol_obj_file)))
+ HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, H5I_INVALID_HID, "invalid VOL object")
+
+ /* This is a native specific routine that requires serialization of the token */
+ p = obj_token;
+ H5F_addr_encode(f, &p, addr);
+
+ loc_params.type = H5VL_OBJECT_BY_TOKEN;
+ loc_params.loc_data.loc_by_token.token = obj_token;
+ loc_params.obj_type = vol_obj_type;
+
/* Open the object */
if(NULL == (opened_obj = H5VL_object_open(vol_obj, &loc_params, &opened_type, H5P_DATASET_XFER_DEFAULT, H5_REQUEST_NULL)))
HGOTO_ERROR(H5E_OHDR, H5E_CANTOPENOBJ, H5I_INVALID_HID, "unable to open object")
@@ -280,6 +306,8 @@ H5Oopen_by_addr(hid_t loc_id, haddr_t addr)
HGOTO_ERROR(H5E_OHDR, H5E_CANTREGISTER, H5I_INVALID_HID, "unable to atomize object handle")
done:
+ if(file_id != H5I_INVALID_HID && H5I_dec_ref(file_id) < 0)
+ HDONE_ERROR(H5E_REFERENCE, H5E_CANTDEC, H5I_INVALID_HID, "unable to decrement refcount on file")
FUNC_LEAVE_API(ret_value)
} /* end H5Oopen_by_addr() */
diff --git a/src/H5Ocopy_ref.c b/src/H5Ocopy_ref.c
index e8212d6bb..3b18073 100644
--- a/src/H5Ocopy_ref.c
+++ b/src/H5Ocopy_ref.c
@@ -165,6 +165,7 @@ H5O__copy_expand_ref_object1(H5O_loc_t *src_oloc, const void *buf_src,
const unsigned char zeros[H5R_OBJ_REF_BUF_SIZE] = { 0 };
size_t buf_size = H5R_OBJ_REF_BUF_SIZE;
size_t i; /* Local index variable */
+ size_t token_size = H5F_SIZEOF_ADDR(src_oloc->file);
herr_t ret_value = SUCCEED;
FUNC_ENTER_STATIC
@@ -173,6 +174,8 @@ H5O__copy_expand_ref_object1(H5O_loc_t *src_oloc, const void *buf_src,
for(i = 0; i < ref_count; i++) {
const unsigned char *src_buf = (const unsigned char *)&src_ref[i];
unsigned char *dst_buf = (unsigned char *)&dst_ref[i];
+ H5VL_token_t tmp_token = { 0 };
+ uint8_t *p;
/* If data is not initialized, copy zeros and skip */
if(0 == HDmemcmp(src_buf, zeros, buf_size)) {
@@ -181,8 +184,10 @@ H5O__copy_expand_ref_object1(H5O_loc_t *src_oloc, const void *buf_src,
}
/* Set up for the object copy for the reference */
- if(H5R__decode_addr_obj_compat(src_buf, &buf_size, &src_oloc->addr) < 0)
+ if(H5R__decode_token_obj_compat(src_buf, &buf_size, &tmp_token, token_size) < 0)
HGOTO_ERROR(H5E_OHDR, H5E_CANTDECODE, FAIL, "unable to decode src object address")
+ p = tmp_token;
+ H5F_addr_decode(src_oloc->file, (const uint8_t **)&p, &src_oloc->addr);
if(!H5F_addr_defined(src_oloc->addr) || src_oloc->addr == 0)
HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "undefined reference pointer")
dst_oloc->addr = HADDR_UNDEF;
@@ -192,7 +197,9 @@ H5O__copy_expand_ref_object1(H5O_loc_t *src_oloc, const void *buf_src,
HGOTO_ERROR(H5E_OHDR, H5E_CANTCOPY, FAIL, "unable to copy object")
/* Set the object reference info for the destination file */
- if(H5R__encode_addr_obj_compat(dst_oloc->addr, dst_buf, &buf_size) < 0)
+ p = tmp_token;
+ H5F_addr_encode(dst_oloc->file, &p, dst_oloc->addr);
+ if(H5R__encode_token_obj_compat((const H5VL_token_t *)&tmp_token, token_size, dst_buf, &buf_size) < 0)
HGOTO_ERROR(H5E_OHDR, H5E_CANTDECODE, FAIL, "unable to encode dst object address")
} /* end for */
@@ -306,6 +313,7 @@ H5O__copy_expand_ref_object2(H5O_loc_t *src_oloc, hid_t tid_src, H5T_t *dt_src,
void *reclaim_buf = NULL; /* Buffer for reclaiming data */
H5S_t *buf_space = NULL; /* Dataspace describing buffer */
hsize_t buf_dim[1] = {ref_count}; /* Dimension for buffer */
+ size_t token_size = H5F_SIZEOF_ADDR(src_oloc->file);
herr_t ret_value = SUCCEED;
FUNC_ENTER_STATIC
@@ -358,18 +366,23 @@ H5O__copy_expand_ref_object2(H5O_loc_t *src_oloc, hid_t tid_src, H5T_t *dt_src,
for(i = 0; i < ref_count; i++) {
H5R_ref_t *ref_ptr = (H5R_ref_t *)conv_buf;
H5R_ref_priv_t *ref = (H5R_ref_priv_t *)&ref_ptr[i];
- size_t token_size = sizeof(src_oloc->addr);
+ H5VL_token_t tmp_token = { 0 };
+ uint8_t *p;
/* Get src object address */
- if(H5R__get_obj_token(ref, (H5VL_token_t *)&src_oloc->addr, &token_size) < 0)
+ if(H5R__get_obj_token(ref, &tmp_token, &token_size) < 0)
HGOTO_ERROR(H5E_OHDR, H5E_CANTGET, FAIL, "unable to get object token")
+ p = tmp_token;
+ H5F_addr_decode(src_oloc->file, (const uint8_t **)&p, &src_oloc->addr);
/* Attempt to copy object from source to destination file */
if(H5O__copy_obj_by_ref(src_oloc, dst_oloc, dst_root_loc, cpy_info) < 0)
HGOTO_ERROR(H5E_OHDR, H5E_CANTCOPY, FAIL, "unable to copy object")
/* Set dst object address */
- if(H5R__set_obj_token(ref, (const H5VL_token_t *)&dst_oloc->addr, token_size) < 0)
+ p = tmp_token;
+ H5F_addr_encode(dst_oloc->file, &p, dst_oloc->addr);
+ if(H5R__set_obj_token(ref, (const H5VL_token_t *)&tmp_token, token_size) < 0)
HGOTO_ERROR(H5E_OHDR, H5E_CANTSET, FAIL, "unable to set object token")
if(H5R__set_loc_id(ref, dst_loc_id, TRUE) < 0)
HGOTO_ERROR(H5E_OHDR, H5E_CANTSET, FAIL, "unable to set destination loc id")
diff --git a/src/H5Rdeprec.c b/src/H5Rdeprec.c
index 4743c77..b9bdffa 100644
--- a/src/H5Rdeprec.c
+++ b/src/H5Rdeprec.c
@@ -100,7 +100,7 @@ H5Rget_obj_type1(hid_t id, H5R_type_t ref_type, const void *ref)
H5VL_object_t *vol_obj = NULL; /* Object token of loc_id */
H5I_type_t vol_obj_type = H5I_BADID;/* Object type of loc_id */
H5VL_loc_params_t loc_params; /* Location parameters */
- haddr_t obj_addr; /* Object address */
+ H5VL_token_t obj_token = {0}; /* Object token */
H5O_type_t obj_type; /* Object type */
const unsigned char *buf = (const unsigned char *)ref; /* Reference buffer */
H5G_obj_t ret_value; /* Return value */
@@ -118,20 +118,17 @@ H5Rget_obj_type1(hid_t id, H5R_type_t ref_type, const void *ref)
if(NULL == (vol_obj = H5VL_vol_object(id)))
HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, H5G_UNKNOWN, "invalid location identifier")
- /* Currently restrict API usage to native VOL
- * TODO check for terminal connector or use capability flag */
-
/* Get object type */
if((vol_obj_type = H5I_get_type(id)) < 0)
HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, H5G_UNKNOWN, "invalid location identifier")
- /* Get object address */
- if(H5R__decode_addr_compat(id, vol_obj_type, ref_type, buf, &obj_addr) < 0)
- HGOTO_ERROR(H5E_REFERENCE, H5E_CANTDECODE, H5G_UNKNOWN, "unable to get object address")
+ /* Get object token */
+ if(H5R__decode_token_compat(id, vol_obj_type, ref_type, buf, &obj_token) < 0)
+ HGOTO_ERROR(H5E_REFERENCE, H5E_CANTDECODE, H5G_UNKNOWN, "unable to get object token")
/* Set location parameters */
loc_params.type = H5VL_OBJECT_BY_TOKEN;
- loc_params.loc_data.loc_by_token.token = &obj_addr;
+ loc_params.loc_data.loc_by_token.token = obj_token;
loc_params.obj_type = vol_obj_type;
/* Retrieve object's type */
@@ -162,7 +159,7 @@ H5Rdereference1(hid_t obj_id, H5R_type_t ref_type, const void *ref)
H5VL_object_t *vol_obj = NULL; /* Object token of loc_id */
H5I_type_t vol_obj_type = H5I_BADID;/* Object type of loc_id */
H5VL_loc_params_t loc_params; /* Location parameters */
- haddr_t obj_addr; /* Object address */
+ H5VL_token_t obj_token = {0}; /* Object token */
H5I_type_t opened_type; /* Opened object type */
void *opened_obj = NULL; /* Opened object */
const unsigned char *buf = (const unsigned char *)ref; /* Reference buffer */
@@ -181,25 +178,22 @@ H5Rdereference1(hid_t obj_id, H5R_type_t ref_type, const void *ref)
if(NULL == (vol_obj = H5VL_vol_object(obj_id)))
HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, H5I_INVALID_HID, "invalid location identifier")
- /* Currently restrict API usage to native VOL
- * TODO check for terminal connector or use capability flag */
-
/* Get object type */
if((vol_obj_type = H5I_get_type(obj_id)) < 0)
HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, H5I_INVALID_HID, "invalid location identifier")
- /* Get object address */
- if(H5R__decode_addr_compat(obj_id, vol_obj_type, ref_type, buf, &obj_addr) < 0)
- HGOTO_ERROR(H5E_REFERENCE, H5E_CANTDECODE, H5I_INVALID_HID, "unable to get object address")
+ /* Get object token */
+ if(H5R__decode_token_compat(obj_id, vol_obj_type, ref_type, buf, &obj_token) < 0)
+ HGOTO_ERROR(H5E_REFERENCE, H5E_CANTDECODE, H5I_INVALID_HID, "unable to get object token")
/* Set location parameters */
loc_params.type = H5VL_OBJECT_BY_TOKEN;
- loc_params.loc_data.loc_by_token.token = &obj_addr;
+ loc_params.loc_data.loc_by_token.token = obj_token;
loc_params.obj_type = vol_obj_type;
/* Dereference */
if(NULL == (opened_obj = H5VL_object_open(vol_obj, &loc_params, &opened_type, H5P_DATASET_XFER_DEFAULT, H5_REQUEST_NULL)))
- HGOTO_ERROR(H5E_REFERENCE, H5E_CANTOPENOBJ, H5I_INVALID_HID, "unable to open object by address")
+ HGOTO_ERROR(H5E_REFERENCE, H5E_CANTOPENOBJ, H5I_INVALID_HID, "unable to open object by token")
/* Register object */
if((ret_value = H5VL_register(opened_type, opened_obj, vol_obj->connector, TRUE)) < 0)
@@ -231,8 +225,10 @@ H5Rcreate(void *ref, hid_t loc_id, const char *name, H5R_type_t ref_type,
H5VL_object_t *vol_obj = NULL; /* Object token of loc_id */
H5I_type_t vol_obj_type = H5I_BADID;/* Object type of loc_id */
H5VL_loc_params_t loc_params; /* Location parameters */
- haddr_t obj_addr; /* Object address */
+ H5VL_token_t obj_token = {0}; /* Object token */
+ H5VL_file_cont_info_t cont_info = {H5VL_CONTAINER_INFO_VERSION, 0, 0, 0};
hid_t file_id = H5I_INVALID_HID; /* File ID for region reference */
+ void *vol_obj_file = NULL;
unsigned char *buf = (unsigned char *)ref; /* Return reference pointer */
herr_t ret_value = SUCCEED; /* Return value */
@@ -255,9 +251,6 @@ H5Rcreate(void *ref, hid_t loc_id, const char *name, H5R_type_t ref_type,
if(NULL == (vol_obj = H5VL_vol_object(loc_id)))
HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "invalid location identifier")
- /* Currently restrict API usage to native VOL
- * TODO check for terminal connector or use capability flag */
-
/* Get object type */
if((vol_obj_type = H5I_get_type(loc_id)) < 0)
HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "invalid location identifier")
@@ -267,42 +260,48 @@ H5Rcreate(void *ref, hid_t loc_id, const char *name, H5R_type_t ref_type,
loc_params.loc_data.loc_by_name.name = name;
loc_params.obj_type = vol_obj_type;
- /* Get the object address */
- if(H5VL_object_specific(vol_obj, &loc_params, H5VL_OBJECT_LOOKUP, H5P_DATASET_XFER_DEFAULT, H5_REQUEST_NULL, &obj_addr) < 0)
- HGOTO_ERROR(H5E_REFERENCE, H5E_CANTGET, FAIL, "unable to retrieve object address")
+ /* Get the object token */
+ if(H5VL_object_specific(vol_obj, &loc_params, H5VL_OBJECT_LOOKUP, H5P_DATASET_XFER_DEFAULT, H5_REQUEST_NULL, obj_token) < 0)
+ HGOTO_ERROR(H5E_REFERENCE, H5E_CANTGET, FAIL, "unable to retrieve object token")
+
+ /* Get the file for the object */
+ if((file_id = H5F_get_file_id(loc_id, vol_obj_type, FALSE)) < 0)
+ HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a file or file object")
+
+ /* Retrieve VOL object */
+ if(NULL == (vol_obj_file = H5VL_vol_object(file_id)))
+ HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "invalid location identifier")
+
+ /* Get container info */
+ if(H5VL_file_get(vol_obj_file, H5VL_FILE_GET_CONT_INFO, H5P_DATASET_XFER_DEFAULT, H5_REQUEST_NULL, &cont_info) < 0)
+ HGOTO_ERROR(H5E_REFERENCE, H5E_CANTGET, FAIL, "unable to get container info")
/* Create reference */
if(ref_type == H5R_OBJECT1) {
size_t buf_size = H5R_OBJ_REF_BUF_SIZE;
- if((ret_value = H5R__encode_addr_obj_compat(obj_addr, buf, &buf_size)) < 0)
+ if((ret_value = H5R__encode_token_obj_compat((const H5VL_token_t *)&obj_token, cont_info.token_size, buf, &buf_size)) < 0)
HGOTO_ERROR(H5E_REFERENCE, H5E_CANTENCODE, FAIL, "unable to encode object reference")
} else {
- void *vol_obj_file = NULL;
H5F_t *f = NULL;
H5S_t *space = NULL; /* Pointer to dataspace containing region */
size_t buf_size = H5R_DSET_REG_REF_BUF_SIZE;
- /* Get the file for the object */
- if((file_id = H5F_get_file_id(loc_id, vol_obj_type, FALSE)) < 0)
- HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a file or file object")
-
- /* Retrieve VOL object */
- if(NULL == (vol_obj_file = H5VL_vol_object(file_id)))
- HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "invalid location identifier")
-
- /* Retrieve file from VOL object */
- if(NULL == (f = (H5F_t *)H5VL_object_data(vol_obj_file)))
- HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "invalid VOL object")
-
/* Retrieve space */
if(space_id == H5I_BADID)
HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "reference region dataspace id must be valid")
if(NULL == (space = (struct H5S_t *)H5I_object_verify(space_id, H5I_DATASPACE)))
HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a dataspace")
+ /* Currently restrict API usage to native VOL
+ * TODO check for terminal connector or use capability flag */
+
+ /* Retrieve file from VOL object */
+ if(NULL == (f = (H5F_t *)H5VL_object_data(vol_obj_file)))
+ HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "invalid VOL object")
+
/* Encode dataset region */
- if((ret_value = H5R__encode_addr_region_compat(f, obj_addr, space, buf, &buf_size)) < 0)
+ if((ret_value = H5R__encode_token_region_compat(f, (const H5VL_token_t *)&obj_token, cont_info.token_size, space, buf, &buf_size)) < 0)
HGOTO_ERROR(H5E_REFERENCE, H5E_CANTENCODE, FAIL, "unable to encode region reference")
}
@@ -330,7 +329,7 @@ H5Rget_obj_type2(hid_t id, H5R_type_t ref_type, const void *ref,
H5VL_object_t *vol_obj = NULL; /* Object token of loc_id */
H5I_type_t vol_obj_type = H5I_BADID;/* Object type of loc_id */
H5VL_loc_params_t loc_params; /* Location parameters */
- haddr_t obj_addr; /* Object address */
+ H5VL_token_t obj_token = {0}; /* Object token */
const unsigned char *buf = (const unsigned char *)ref; /* Reference pointer */
herr_t ret_value = SUCCEED; /* Return value */
@@ -347,20 +346,17 @@ H5Rget_obj_type2(hid_t id, H5R_type_t ref_type, const void *ref,
if(NULL == (vol_obj = H5VL_vol_object(id)))
HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "invalid location identifier")
- /* Currently restrict API usage to native VOL
- * TODO check for terminal connector or use capability flag */
-
/* Get object type */
if((vol_obj_type = H5I_get_type(id)) < 0)
HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "invalid location identifier")
- /* Get object address */
- if(H5R__decode_addr_compat(id, vol_obj_type, ref_type, buf, &obj_addr) < 0)
- HGOTO_ERROR(H5E_REFERENCE, H5E_CANTDECODE, FAIL, "unable to get object address")
+ /* Get object token */
+ if(H5R__decode_token_compat(id, vol_obj_type, ref_type, buf, &obj_token) < 0)
+ HGOTO_ERROR(H5E_REFERENCE, H5E_CANTDECODE, FAIL, "unable to get object token")
/* Set location parameters */
loc_params.type = H5VL_OBJECT_BY_TOKEN;
- loc_params.loc_data.loc_by_token.token = &obj_addr;
+ loc_params.loc_data.loc_by_token.token = obj_token;
loc_params.obj_type = vol_obj_type;
/* Retrieve object's type */
@@ -389,7 +385,7 @@ H5Rdereference2(hid_t obj_id, hid_t oapl_id, H5R_type_t ref_type,
H5VL_object_t *vol_obj = NULL; /* Object token of loc_id */
H5I_type_t vol_obj_type = H5I_BADID;/* Object type of loc_id */
H5VL_loc_params_t loc_params; /* Location parameters */
- haddr_t obj_addr; /* Object address */
+ H5VL_token_t obj_token = {0}; /* Object token */
H5I_type_t opened_type; /* Opened object type */
void *opened_obj = NULL; /* Opened object */
const unsigned char *buf = (const unsigned char *)ref; /* Reference pointer */
@@ -414,25 +410,22 @@ H5Rdereference2(hid_t obj_id, hid_t oapl_id, H5R_type_t ref_type,
if(NULL == (vol_obj = H5VL_vol_object(obj_id)))
HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, H5I_INVALID_HID, "invalid file identifier")
- /* Currently restrict API usage to native VOL
- * TODO check for terminal connector or use capability flag */
-
/* Get object type */
if((vol_obj_type = H5I_get_type(obj_id)) < 0)
HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, H5I_INVALID_HID, "invalid location identifier")
- /* Get object address */
- if(H5R__decode_addr_compat(obj_id, vol_obj_type, ref_type, buf, &obj_addr) < 0)
- HGOTO_ERROR(H5E_REFERENCE, H5E_CANTDECODE, H5I_INVALID_HID, "unable to get object address")
+ /* Get object token */
+ if(H5R__decode_token_compat(obj_id, vol_obj_type, ref_type, buf, &obj_token) < 0)
+ HGOTO_ERROR(H5E_REFERENCE, H5E_CANTDECODE, H5I_INVALID_HID, "unable to get object token")
/* Set location parameters */
loc_params.type = H5VL_OBJECT_BY_TOKEN;
- loc_params.loc_data.loc_by_token.token = &obj_addr;
+ loc_params.loc_data.loc_by_token.token = obj_token;
loc_params.obj_type = vol_obj_type;
- /* Open object by address */
+ /* Open object by token */
if(NULL == (opened_obj = H5VL_object_open(vol_obj, &loc_params, &opened_type, H5P_DATASET_XFER_DEFAULT, H5_REQUEST_NULL)))
- HGOTO_ERROR(H5E_REFERENCE, H5E_CANTOPENOBJ, H5I_INVALID_HID, "unable to open object by address")
+ HGOTO_ERROR(H5E_REFERENCE, H5E_CANTOPENOBJ, H5I_INVALID_HID, "unable to open object by token")
/* Register object */
if((ret_value = H5VL_register(opened_type, opened_obj, vol_obj->connector, TRUE)) < 0)
@@ -460,6 +453,7 @@ H5Rget_region(hid_t id, H5R_type_t ref_type, const void *ref)
H5VL_object_t *vol_obj = NULL; /* Object token of loc_id */
H5I_type_t vol_obj_type = H5I_BADID;/* Object type of loc_id */
void *vol_obj_file = NULL; /* VOL file */
+ H5VL_file_cont_info_t cont_info = {H5VL_CONTAINER_INFO_VERSION, 0, 0, 0};
H5F_t *f = NULL; /* Native file */
size_t buf_size = H5R_DSET_REG_REF_BUF_SIZE; /* Reference buffer size */
H5S_t *space = NULL; /* Dataspace object */
@@ -484,9 +478,6 @@ H5Rget_region(hid_t id, H5R_type_t ref_type, const void *ref)
if((vol_obj_type = H5I_get_type(id)) < 0)
HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, H5I_INVALID_HID, "invalid location identifier")
- /* Currently restrict API usage to native VOL
- * TODO check for terminal connector or use capability flag */
-
/* Get the file for the object */
if((file_id = H5F_get_file_id(id, vol_obj_type, FALSE)) < 0)
HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, H5I_INVALID_HID, "not a file or file object")
@@ -495,12 +486,16 @@ H5Rget_region(hid_t id, H5R_type_t ref_type, const void *ref)
if(NULL == (vol_obj_file = H5VL_vol_object(file_id)))
HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, H5I_INVALID_HID, "invalid location identifier")
+ /* Get container info */
+ if(H5VL_file_get(vol_obj_file, H5VL_FILE_GET_CONT_INFO, H5P_DATASET_XFER_DEFAULT, H5_REQUEST_NULL, &cont_info) < 0)
+ HGOTO_ERROR(H5E_REFERENCE, H5E_CANTGET, H5I_INVALID_HID, "unable to get container info")
+
/* Retrieve file from VOL object */
if(NULL == (f = (H5F_t *)H5VL_object_data(vol_obj_file)))
HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, H5I_INVALID_HID, "invalid VOL object")
/* Get the dataspace with the correct region selected */
- if(H5R__decode_addr_region_compat(f, buf, &buf_size, NULL, &space) < 0)
+ if(H5R__decode_token_region_compat(f, buf, &buf_size, NULL, cont_info.token_size, &space) < 0)
HGOTO_ERROR(H5E_REFERENCE, H5E_CANTGET, H5I_INVALID_HID, "unable to get dataspace")
/* Atomize */
@@ -531,7 +526,7 @@ H5Rget_name(hid_t id, H5R_type_t ref_type, const void *ref, char *name,
H5VL_object_t *vol_obj = NULL; /* Object token of loc_id */
H5I_type_t vol_obj_type = H5I_BADID;/* Object type of loc_id */
H5VL_loc_params_t loc_params; /* Location parameters */
- haddr_t obj_addr; /* Object address */
+ H5VL_token_t obj_token = {0}; /* Object token */
const unsigned char *buf = (const unsigned char *)ref; /* Reference pointer */
ssize_t ret_value = -1; /* Return value */
@@ -548,20 +543,17 @@ H5Rget_name(hid_t id, H5R_type_t ref_type, const void *ref, char *name,
if(NULL == (vol_obj = H5VL_vol_object(id)))
HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, (-1), "invalid file identifier")
- /* Currently restrict API usage to native VOL
- * TODO check for terminal connector or use capability flag */
-
/* Get object type */
if((vol_obj_type = H5I_get_type(id)) < 0)
HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, (-1), "invalid location identifier")
- /* Get object address */
- if(H5R__decode_addr_compat(id, vol_obj_type, ref_type, buf, &obj_addr) < 0)
- HGOTO_ERROR(H5E_REFERENCE, H5E_CANTDECODE, (-1), "unable to get object address")
+ /* Get object token */
+ if(H5R__decode_token_compat(id, vol_obj_type, ref_type, buf, &obj_token) < 0)
+ HGOTO_ERROR(H5E_REFERENCE, H5E_CANTDECODE, (-1), "unable to get object token")
/* Set location parameters */
loc_params.type = H5VL_OBJECT_BY_TOKEN;
- loc_params.loc_data.loc_by_token.token = &obj_addr;
+ loc_params.loc_data.loc_by_token.token = obj_token;
loc_params.obj_type = vol_obj_type;
/* Retrieve object's name */
diff --git a/src/H5Rint.c b/src/H5Rint.c
index e33eecb..443a245 100644
--- a/src/H5Rint.c
+++ b/src/H5Rint.c
@@ -1461,48 +1461,53 @@ done:
/*-------------------------------------------------------------------------
- * Function: H5R__decode_addr_compat
+ * Function: H5R__decode_token_compat
*
- * Purpose: Decode an object address. (native only)
+ * Purpose: Decode an object token. (native only)
*
* Return: Non-negative on success/Negative on failure
*
*-------------------------------------------------------------------------
*/
herr_t
-H5R__decode_addr_compat(hid_t id, H5I_type_t type, H5R_type_t ref_type,
- const unsigned char *buf, haddr_t *addr_ptr)
+H5R__decode_token_compat(hid_t id, H5I_type_t type, H5R_type_t ref_type,
+ const unsigned char *buf, H5VL_token_t *obj_token)
{
hid_t file_id = H5I_INVALID_HID; /* File ID for region reference */
+ void *vol_obj_file = NULL;
+ H5VL_file_cont_info_t cont_info = {H5VL_CONTAINER_INFO_VERSION, 0, 0, 0};
herr_t ret_value = SUCCEED;
FUNC_ENTER_PACKAGE
+ /* Get the file for the object */
+ if((file_id = H5F_get_file_id(id, type, FALSE)) < 0)
+ HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a file or file object")
+
+ /* Retrieve VOL object */
+ if(NULL == (vol_obj_file = H5VL_vol_object(file_id)))
+ HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "invalid location identifier")
+
+ /* Get container info */
+ if(H5VL_file_get(vol_obj_file, H5VL_FILE_GET_CONT_INFO, H5P_DATASET_XFER_DEFAULT, H5_REQUEST_NULL, &cont_info) < 0)
+ HGOTO_ERROR(H5E_REFERENCE, H5E_CANTGET, FAIL, "unable to get container info")
+
if(ref_type == H5R_OBJECT1) {
size_t buf_size = H5R_OBJ_REF_BUF_SIZE;
/* Get object address */
- if(H5R__decode_addr_obj_compat(buf, &buf_size, addr_ptr) < 0)
- HGOTO_ERROR(H5E_REFERENCE, H5E_CANTDECODE, FAIL, "unable to get object address")
+ if(H5R__decode_token_obj_compat(buf, &buf_size, obj_token, cont_info.token_size) < 0)
+ HGOTO_ERROR(H5E_REFERENCE, H5E_CANTDECODE, FAIL, "unable to get object token")
} else {
- void *vol_obj_file = NULL;
- H5F_t *f = NULL;
size_t buf_size = H5R_DSET_REG_REF_BUF_SIZE;
-
- /* Get the file for the object */
- if((file_id = H5F_get_file_id(id, type, FALSE)) < 0)
- HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a file or file object")
-
- /* Retrieve VOL object */
- if(NULL == (vol_obj_file = H5VL_vol_object(file_id)))
- HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "invalid location identifier")
+ H5F_t *f = NULL;
/* Retrieve file from VOL object */
if(NULL == (f = (H5F_t *)H5VL_object_data(vol_obj_file)))
HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "invalid VOL object")
/* Get object address */
- if(H5R__decode_addr_region_compat(f, buf, &buf_size, addr_ptr, NULL) < 0)
+ if(H5R__decode_token_region_compat(f, buf, &buf_size, obj_token, cont_info.token_size, NULL) < 0)
HGOTO_ERROR(H5E_REFERENCE, H5E_CANTDECODE, FAIL, "unable to get object address")
}
@@ -1510,48 +1515,52 @@ done:
if(file_id != H5I_INVALID_HID && H5I_dec_ref(file_id) < 0)
HDONE_ERROR(H5E_REFERENCE, H5E_CANTDEC, FAIL, "unable to decrement refcount on file")
FUNC_LEAVE_NOAPI(ret_value)
-}
+} /* end H5R__decode_token_compat() */
/*-------------------------------------------------------------------------
- * Function: H5R__encode_addr_obj_compat
+ * Function: H5R__encode_token_obj_compat
*
- * Purpose: Encode an object address. (native only)
+ * Purpose: Encode an object token. (native only)
*
* Return: Non-negative on success/Negative on failure
*
*-------------------------------------------------------------------------
*/
herr_t
-H5R__encode_addr_obj_compat(haddr_t addr, unsigned char *buf, size_t *nalloc)
+H5R__encode_token_obj_compat(const H5VL_token_t *obj_token, size_t token_size,
+ unsigned char *buf, size_t *nalloc)
{
herr_t ret_value = SUCCEED;
FUNC_ENTER_PACKAGE_NOERR
+ HDassert(obj_token);
+ HDassert(token_size);
HDassert(nalloc);
/* Don't encode if buffer size isn't big enough or buffer is empty */
- if(buf && *nalloc >= sizeof(addr))
- H5MM_memcpy(buf, &addr, sizeof(addr));
- *nalloc = sizeof(addr);
+ if(buf && *nalloc >= token_size)
+ H5MM_memcpy(buf, obj_token, token_size);
+
+ *nalloc = token_size;
FUNC_LEAVE_NOAPI(ret_value)
-} /* end H5R__encode_addr_obj_compat() */
+} /* end H5R__encode_token_obj_compat() */
/*-------------------------------------------------------------------------
- * Function: H5R__decode_addr_obj_compat
+ * Function: H5R__decode_token_obj_compat
*
- * Purpose: Decode an object address. (native only)
+ * Purpose: Decode an object token. (native only)
*
* Return: Non-negative on success/Negative on failure
*
*-------------------------------------------------------------------------
*/
herr_t
-H5R__decode_addr_obj_compat(const unsigned char *buf, size_t *nbytes,
- haddr_t *addr_ptr)
+H5R__decode_token_obj_compat(const unsigned char *buf, size_t *nbytes,
+ H5VL_token_t *obj_token, size_t token_size)
{
herr_t ret_value = SUCCEED;
@@ -1559,23 +1568,24 @@ H5R__decode_addr_obj_compat(const unsigned char *buf, size_t *nbytes,
HDassert(buf);
HDassert(nbytes);
- HDassert(addr_ptr);
+ HDassert(obj_token);
+ HDassert(token_size);
/* Don't decode if buffer size isn't big enough */
- if(*nbytes < sizeof(*addr_ptr))
+ if(*nbytes < token_size)
HGOTO_ERROR(H5E_REFERENCE, H5E_CANTDECODE, FAIL, "Buffer size is too small")
- H5MM_memcpy(addr_ptr, buf, sizeof(*addr_ptr));
+ H5MM_memcpy(obj_token, buf, token_size);
- *nbytes = sizeof(*addr_ptr);
+ *nbytes = token_size;
done:
FUNC_LEAVE_NOAPI(ret_value)
-} /* H5R__decode_addr_obj_compat() */
+} /* H5R__decode_token_obj_compat() */
/*-------------------------------------------------------------------------
- * Function: H5R__encode_addr_region_compat
+ * Function: H5R__encode_token_region_compat
*
* Purpose: Encode dataset selection and insert data into heap (native only).
*
@@ -1584,8 +1594,8 @@ done:
*-------------------------------------------------------------------------
*/
herr_t
-H5R__encode_addr_region_compat(H5F_t *f, haddr_t obj_addr, H5S_t *space,
- unsigned char *buf, size_t *nalloc)
+H5R__encode_token_region_compat(H5F_t *f, const H5VL_token_t *obj_token,
+ size_t token_size, H5S_t *space, unsigned char *buf, size_t *nalloc)
{
size_t buf_size;
unsigned char *data = NULL;
@@ -1594,6 +1604,8 @@ H5R__encode_addr_region_compat(H5F_t *f, haddr_t obj_addr, H5S_t *space,
FUNC_ENTER_PACKAGE
HDassert(f);
+ HDassert(obj_token);
+ HDassert(token_size);
HDassert(space);
HDassert(nalloc);
@@ -1618,8 +1630,8 @@ H5R__encode_addr_region_compat(H5F_t *f, haddr_t obj_addr, H5S_t *space,
if((data_size = H5S_SELECT_SERIAL_SIZE(space)) < 0)
HGOTO_ERROR(H5E_REFERENCE, H5E_CANTINIT, FAIL, "Invalid amount of space for serializing selection")
- /* Increase buffer size to allow for the dataset OID */
- data_size += (hssize_t)sizeof(haddr_t);
+ /* Increase buffer size to allow for the dataset token */
+ data_size += (hssize_t)token_size;
/* Allocate the space to store the serialized information */
H5_CHECK_OVERFLOW(data_size, hssize_t, size_t);
@@ -1628,7 +1640,8 @@ H5R__encode_addr_region_compat(H5F_t *f, haddr_t obj_addr, H5S_t *space,
/* Serialize information for dataset OID into heap buffer */
p = (uint8_t *)data;
- H5F_addr_encode(f, &p, obj_addr);
+ H5MM_memcpy(p, obj_token, token_size);
+ p += token_size;
/* Serialize the selection into heap buffer */
if(H5S_SELECT_SERIALIZE(space, &p) < 0)
@@ -1643,11 +1656,11 @@ H5R__encode_addr_region_compat(H5F_t *f, haddr_t obj_addr, H5S_t *space,
done:
H5MM_free(data);
FUNC_LEAVE_NOAPI(ret_value)
-} /* H5R__encode_addr_region_compat() */
+} /* H5R__encode_token_region_compat() */
/*-------------------------------------------------------------------------
- * Function: H5R__decode_obj_addr_compat
+ * Function: H5R__decode_token_region_compat
*
* Purpose: Decode dataset selection from data inserted into heap (native only).
*
@@ -1656,12 +1669,13 @@ done:
*-------------------------------------------------------------------------
*/
herr_t
-H5R__decode_addr_region_compat(H5F_t *f, const unsigned char *buf,
- size_t *nbytes, haddr_t *obj_addr_ptr, H5S_t **space_ptr)
+H5R__decode_token_region_compat(H5F_t *f, const unsigned char *buf,
+ size_t *nbytes, H5VL_token_t *obj_token, size_t token_size,
+ H5S_t **space_ptr)
{
unsigned char *data = NULL;
+ H5VL_token_t token = { 0 };
size_t data_size;
- haddr_t obj_addr;
const uint8_t *p;
herr_t ret_value = SUCCEED;
@@ -1670,6 +1684,7 @@ H5R__decode_addr_region_compat(H5F_t *f, const unsigned char *buf,
HDassert(f);
HDassert(buf);
HDassert(nbytes);
+ HDassert(token_size);
/* Read from heap */
if(H5R__decode_heap(f, buf, nbytes, &data, &data_size) < 0)
@@ -1677,18 +1692,18 @@ H5R__decode_addr_region_compat(H5F_t *f, const unsigned char *buf,
/* Get object address */
p = (const uint8_t *)data;
- H5F_addr_decode(f, &p, &obj_addr);
- if(!H5F_addr_defined(obj_addr) || obj_addr == 0)
- HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "Undefined reference pointer")
+ H5MM_memcpy(token, p, token_size);
+ p += token_size;
if(space_ptr) {
H5O_loc_t oloc; /* Object location */
H5S_t *space = NULL;
+ const uint8_t *q = token;
/* Initialize the object location */
H5O_loc_reset(&oloc);
oloc.file = f;
- oloc.addr = obj_addr;
+ H5F_addr_decode(f, &q, &oloc.addr);
/* Open and copy the dataset's dataspace */
if(NULL == (space = H5S_read(&oloc)))
@@ -1700,10 +1715,10 @@ H5R__decode_addr_region_compat(H5F_t *f, const unsigned char *buf,
*space_ptr = space;
}
- if(obj_addr_ptr)
- *obj_addr_ptr = obj_addr;
+ if(obj_token)
+ H5MM_memcpy(obj_token, token, token_size);
done:
H5MM_free(data);
FUNC_LEAVE_NOAPI(ret_value)
-} /* end H5R__decode_addr_region_compat() */
+} /* end H5R__decode_token_region_compat() */
diff --git a/src/H5Rpkg.h b/src/H5Rpkg.h
index 1843bcf..19f3115 100644
--- a/src/H5Rpkg.h
+++ b/src/H5Rpkg.h
@@ -118,13 +118,13 @@ H5_DLL herr_t H5R__encode_heap(H5F_t *f, unsigned char *buf, size_t *nalloc, c
H5_DLL herr_t H5R__decode_heap(H5F_t *f, const unsigned char *buf, size_t *nbytes, unsigned char **data_ptr, size_t *data_size);
H5_DLL herr_t H5R__free_heap(H5F_t *f, const unsigned char *buf, size_t nbytes);
-H5_DLL herr_t H5R__decode_addr_compat(hid_t id, H5I_type_t type, H5R_type_t ref_type, const unsigned char *buf, haddr_t *addr_ptr);
+H5_DLL herr_t H5R__decode_token_compat(hid_t id, H5I_type_t type, H5R_type_t ref_type, const unsigned char *buf, H5VL_token_t *obj_token);
-H5_DLL herr_t H5R__encode_addr_obj_compat(haddr_t obj_addr, unsigned char *buf, size_t *nalloc);
-H5_DLL herr_t H5R__decode_addr_obj_compat(const unsigned char *buf, size_t *nbytes, haddr_t *obj_addr_ptr);
+H5_DLL herr_t H5R__encode_token_obj_compat(const H5VL_token_t *obj_token, size_t token_size, unsigned char *buf, size_t *nalloc);
+H5_DLL herr_t H5R__decode_token_obj_compat(const unsigned char *buf, size_t *nbytes, H5VL_token_t *obj_token, size_t token_size);
-H5_DLL herr_t H5R__encode_addr_region_compat(H5F_t *f, haddr_t obj_addr, H5S_t *space, unsigned char *buf, size_t *nalloc);
-H5_DLL herr_t H5R__decode_addr_region_compat(H5F_t *f, const unsigned char *buf, size_t *nbytes, haddr_t *obj_addr_ptr, H5S_t **space_ptr);
+H5_DLL herr_t H5R__encode_token_region_compat(H5F_t *f, const H5VL_token_t *obj_token, size_t token_size, H5S_t *space, unsigned char *buf, size_t *nalloc);
+H5_DLL herr_t H5R__decode_token_region_compat(H5F_t *f, const unsigned char *buf, size_t *nbytes, H5VL_token_t *obj_token, size_t token_size, H5S_t **space_ptr);
#endif /* _H5Rpkg_H */
diff --git a/src/H5T.c b/src/H5T.c
index f368fdb..aafdd55 100644
--- a/src/H5T.c
+++ b/src/H5T.c
@@ -1060,7 +1060,7 @@ H5T__init_package(void)
status |= H5T__register_int(H5T_PERS_SOFT, "enum_f", enum_type, floatpt, H5T__conv_enum_numeric);
status |= H5T__register_int(H5T_PERS_SOFT, "vlen", vlen, vlen, H5T__conv_vlen);
status |= H5T__register_int(H5T_PERS_SOFT, "array", array, array, H5T__conv_array);
- status |= H5T__register_int(H5T_PERS_SOFT, "objref", objref, objref, H5T__conv_order_opt);
+ status |= H5T__register_int(H5T_PERS_SOFT, "objref", objref, objref, H5T__conv_noop);
status |= H5T__register_int(H5T_PERS_SOFT, "regref", regref, regref, H5T__conv_noop);
status |= H5T__register_int(H5T_PERS_SOFT, "ref", ref, ref, H5T__conv_ref);
status |= H5T__register_int(H5T_PERS_SOFT, "objref_ref", objref, ref, H5T__conv_ref);
diff --git a/src/H5Tref.c b/src/H5Tref.c
index 6f7bf90..5a3cb4f 100644
--- a/src/H5Tref.c
+++ b/src/H5Tref.c
@@ -44,7 +44,7 @@
/* For region compatibility support */
struct H5Tref_dsetreg {
- haddr_t obj_addr; /* Object address */
+ H5VL_token_t token; /* Object token */
H5S_t *space; /* Dataspace */
};
@@ -388,14 +388,17 @@ H5T__ref_mem_write(H5F_t *src_f, const void *src_buf, size_t src_size,
switch(src_type) {
case H5R_OBJECT1: {
- if(H5R__create_object((const H5VL_token_t *)src_buf, sizeof(haddr_t), dst_ref) < 0)
+ size_t token_size = H5F_SIZEOF_ADDR(src_f);
+
+ if(H5R__create_object((const H5VL_token_t *)src_buf, token_size, dst_ref) < 0)
HGOTO_ERROR(H5E_REFERENCE, H5E_CANTCREATE, FAIL, "unable to create object reference")
}
break;
case H5R_DATASET_REGION1: {
const struct H5Tref_dsetreg *src_reg = (const struct H5Tref_dsetreg *)src_buf;
+ size_t token_size = H5F_SIZEOF_ADDR(src_f);
- if(H5R__create_region((const H5VL_token_t *)&src_reg->obj_addr, sizeof(src_reg->obj_addr), src_reg->space, dst_ref) < 0)
+ if(H5R__create_region(&src_reg->token, token_size, src_reg->space, dst_ref) < 0)
HGOTO_ERROR(H5E_REFERENCE, H5E_CANTCREATE, FAIL, "unable to create region reference")
/* create_region creates its internal copy of the space */
if(H5S_close(src_reg->space) < 0)
@@ -626,17 +629,20 @@ done:
*-------------------------------------------------------------------------
*/
static size_t
-H5T__ref_obj_disk_getsize(H5F_t H5_ATTR_UNUSED *src_f,
- const void H5_ATTR_UNUSED *src_buf, size_t H5_ATTR_UNUSED src_size,
- H5F_t H5_ATTR_UNUSED *dst_f, hbool_t H5_ATTR_UNUSED *dst_copy)
+H5T__ref_obj_disk_getsize(H5F_t *src_f, const void H5_ATTR_UNUSED *src_buf,
+ size_t H5_ATTR_UNUSED src_size, H5F_t H5_ATTR_UNUSED *dst_f,
+ hbool_t H5_ATTR_UNUSED *dst_copy)
{
- size_t ret_value = sizeof(haddr_t);
+ size_t ret_value = 0;
FUNC_ENTER_STATIC_NOERR
+ HDassert(src_f);
HDassert(src_buf);
HDassert(src_size == H5T_REF_OBJ_DISK_SIZE(src_f));
+ ret_value = H5T_REF_OBJ_DISK_SIZE(src_f);
+
FUNC_LEAVE_NOAPI(ret_value)
} /* end H5T__ref_obj_disk_getsize() */
@@ -651,9 +657,8 @@ H5T__ref_obj_disk_getsize(H5F_t H5_ATTR_UNUSED *src_f,
*-------------------------------------------------------------------------
*/
static herr_t
-H5T__ref_obj_disk_read(H5F_t H5_ATTR_UNUSED *src_f, const void *src_buf,
- size_t src_size, H5F_t H5_ATTR_UNUSED *dst_f, void *dst_buf,
- size_t H5_ATTR_UNUSED dst_size)
+H5T__ref_obj_disk_read(H5F_t *src_f, const void *src_buf, size_t src_size,
+ H5F_t H5_ATTR_UNUSED *dst_f, void *dst_buf, size_t H5_ATTR_UNUSED dst_size)
{
herr_t ret_value = SUCCEED;
@@ -663,11 +668,12 @@ H5T__ref_obj_disk_read(H5F_t H5_ATTR_UNUSED *src_f, const void *src_buf,
HDassert(src_buf);
HDassert(src_size == H5T_REF_OBJ_DISK_SIZE(src_f));
HDassert(dst_buf);
- HDassert(dst_size == sizeof(haddr_t));
+ HDassert(dst_size == H5F_SIZEOF_ADDR(src_f));
/* Get object address */
- if(H5R__decode_addr_obj_compat((const unsigned char *)src_buf, &src_size, (haddr_t *)dst_buf) < 0)
- HGOTO_ERROR(H5E_REFERENCE, H5E_CANTDECODE, H5I_INVALID_HID, "unable to get object address")
+ if(H5R__decode_token_obj_compat((const unsigned char *)src_buf, &src_size,
+ dst_buf, H5F_SIZEOF_ADDR(src_f)) < 0)
+ HGOTO_ERROR(H5E_REFERENCE, H5E_CANTDECODE, FAIL, "unable to get object address")
done:
FUNC_LEAVE_NOAPI(ret_value)
@@ -724,7 +730,8 @@ H5T__ref_dsetreg_disk_read(H5F_t *src_f, const void *src_buf, size_t src_size,
HDassert(dst_size == sizeof(struct H5Tref_dsetreg));
/* Retrieve object address and space */
- if(H5R__decode_addr_region_compat(src_f, (const unsigned char *)src_buf, &src_size, &dst_reg->obj_addr, &dst_reg->space) < 0)
+ if(H5R__decode_token_region_compat(src_f, (const unsigned char *)src_buf,
+ &src_size, &dst_reg->token, H5F_SIZEOF_ADDR(src_f), &dst_reg->space) < 0)
HGOTO_ERROR(H5E_REFERENCE, H5E_CANTDECODE, FAIL, "unable to get object address")
done:
diff --git a/src/H5VLnative_object.c b/src/H5VLnative_object.c
index 64d3978..675d8cf 100644
--- a/src/H5VLnative_object.c
+++ b/src/H5VLnative_object.c
@@ -71,8 +71,14 @@ H5VL__native_object_open(void *obj, const H5VL_loc_params_t *loc_params, H5I_typ
case H5VL_OBJECT_BY_TOKEN:
{
+ const uint8_t *p = (const uint8_t *)loc_params->loc_data.loc_by_token.token;
+ haddr_t addr;
+
+ /* Decode token */
+ H5F_addr_decode(loc.oloc->file, &p, &addr);
+
/* Open the object */
- if(NULL == (ret_value = H5O_open_by_addr(&loc, *(haddr_t *)loc_params->loc_data.loc_by_token.token, opened_type)))
+ if(NULL == (ret_value = H5O_open_by_addr(&loc, addr, opened_type)))
HGOTO_ERROR(H5E_OHDR, H5E_CANTOPENOBJ, NULL, "unable to open object by address")
break;
}
@@ -158,11 +164,13 @@ H5VL__native_object_get(void *obj, const H5VL_loc_params_t *loc_params, H5VL_obj
} /* end if */
else if(loc_params->type == H5VL_OBJECT_BY_TOKEN) {
H5O_loc_t obj_oloc; /* Object location */
+ const uint8_t *p = (const uint8_t *)loc_params->loc_data.loc_by_token.token;
/* Initialize the object location */
H5O_loc_reset(&obj_oloc);
obj_oloc.file = loc.oloc->file;
- obj_oloc.addr = *(haddr_t *)loc_params->loc_data.loc_by_token.token;
+ /* Decode token */
+ H5F_addr_decode(obj_oloc.file, &p, &obj_oloc.addr);
/* Retrieve object's name */
if((*ret = H5G_get_name_by_addr(loc.oloc->file, &obj_oloc, name, size)) < 0)
@@ -181,11 +189,13 @@ H5VL__native_object_get(void *obj, const H5VL_loc_params_t *loc_params, H5VL_obj
if(loc_params->type == H5VL_OBJECT_BY_TOKEN) {
H5O_loc_t obj_oloc; /* Object location */
unsigned rc; /* Reference count of object */
+ const uint8_t *p = (const uint8_t *)loc_params->loc_data.loc_by_token.token;
/* Initialize the object location */
H5O_loc_reset(&obj_oloc);
obj_oloc.file = loc.oloc->file;
- obj_oloc.addr = *(haddr_t *)loc_params->loc_data.loc_by_token.token;
+ /* Decode token */
+ H5F_addr_decode(obj_oloc.file, &p, &obj_oloc.addr);
/* Get the # of links for object, and its type */
/* (To check to make certain that this object hasn't been deleted) */
@@ -265,6 +275,7 @@ H5VL__native_object_specific(void *obj, const H5VL_loc_params_t *loc_params, H5V
H5G_loc_t obj_loc; /* Group hier. location of object */
H5G_name_t obj_path; /* Object group hier. path */
H5O_loc_t obj_oloc; /* Object object location */
+ uint8_t *p = (uint8_t *)token; /* Pointer to token */
/* Set up opened group location to fill in */
obj_loc.oloc = &obj_oloc;
@@ -274,7 +285,9 @@ H5VL__native_object_specific(void *obj, const H5VL_loc_params_t *loc_params, H5V
/* Find the object */
if(H5G_loc_find(&loc, loc_params->loc_data.loc_by_name.name, &obj_loc) < 0)
HGOTO_ERROR(H5E_OHDR, H5E_NOTFOUND, FAIL, "object not found")
- *(haddr_t *)token = obj_loc.oloc->addr;
+
+ /* Encode token */
+ H5F_addr_encode(obj_oloc.file, &p, obj_loc.oloc->addr);
/* Release the object location */
if(H5G_loc_free(&obj_loc) < 0)