summaryrefslogtreecommitdiffstats
path: root/tools/lib
diff options
context:
space:
mode:
Diffstat (limited to 'tools/lib')
-rw-r--r--tools/lib/h5diff.c46
-rw-r--r--tools/lib/h5diff_array.c24
-rw-r--r--tools/lib/h5diff_attr.c11
-rw-r--r--tools/lib/h5tools.c22
-rw-r--r--tools/lib/h5tools_dump.c23
-rw-r--r--tools/lib/h5tools_ref.c148
-rw-r--r--tools/lib/h5tools_ref.h8
-rw-r--r--tools/lib/h5tools_str.c46
-rw-r--r--tools/lib/h5tools_str.h2
-rw-r--r--tools/lib/h5tools_utils.c73
-rw-r--r--tools/lib/h5tools_utils.h15
-rw-r--r--tools/lib/h5trav.c117
-rw-r--r--tools/lib/h5trav.h15
13 files changed, 338 insertions, 212 deletions
diff --git a/tools/lib/h5diff.c b/tools/lib/h5diff.c
index d7fc991..870c256 100644
--- a/tools/lib/h5diff.c
+++ b/tools/lib/h5diff.c
@@ -276,7 +276,7 @@ build_match_list (const char *objname1, trav_info_t *info1, const char *objname2
H5TOOLS_DEBUG("build_match_list start - errstat:%d", opts->err_stat);
/* init */
- trav_table_init(&table);
+ trav_table_init(info1->fid, &table);
if (table == NULL) {
H5TOOLS_INFO("Cannot create traverse table");
H5TOOLS_GOTO_DONE_NO_RET();
@@ -314,10 +314,20 @@ build_match_list (const char *objname1, trav_info_t *info1, const char *objname2
trav_table_addflags(infile, path1_lp, info1->paths[curr1].type, table);
/* if the two point to the same target object,
* mark that in table */
- if (info1->paths[curr1].fileno == info2->paths[curr2].fileno &&
- info1->paths[curr1].objno == info2->paths[curr2].objno) {
- idx = table->nobjs - 1;
- table->objs[idx].is_same_trgobj = 1;
+ if(info1->paths[curr1].fileno == info2->paths[curr2].fileno) {
+ int token_cmp;
+
+ if(H5Otoken_cmp(info1->fid, &info1->paths[curr1].obj_token,
+ &info2->paths[curr2].obj_token, &token_cmp) < 0) {
+ H5TOOLS_INFO("Failed to compare object tokens");
+ opts->err_stat = H5DIFF_ERR;
+ H5TOOLS_GOTO_DONE_NO_RET();
+ }
+
+ if(!token_cmp) {
+ idx = table->nobjs - 1;
+ table->objs[idx].is_same_trgobj = 1;
+ }
}
}
curr1++;
@@ -382,7 +392,7 @@ done:
* Purpose: Call back function from h5trav_visit().
*------------------------------------------------------------------------*/
static herr_t
-trav_grp_objs(const char *path, const H5O_info_t *oinfo,
+trav_grp_objs(const char *path, const H5O_info2_t *oinfo,
const char *already_visited, void *udata)
{
trav_info_visit_obj(path, oinfo, already_visited, udata);
@@ -397,7 +407,7 @@ trav_grp_objs(const char *path, const H5O_info_t *oinfo,
* Track and extra checkings while visiting all symbolic-links.
*------------------------------------------------------------------------*/
static herr_t
-trav_grp_symlinks(const char *path, const H5L_info_t *linfo, void *udata)
+trav_grp_symlinks(const char *path, const H5L_info2_t *linfo, void *udata)
{
trav_info_t *tinfo = (trav_info_t *)udata;
diff_opt_t *opts = (diff_opt_t *)tinfo->opts;
@@ -523,7 +533,7 @@ h5diff(const char *fname1,
h5trav_type_t obj1type = H5TRAV_TYPE_GROUP;
h5trav_type_t obj2type = H5TRAV_TYPE_GROUP;
/* for single object */
- H5O_info_t oinfo1, oinfo2; /* object info */
+ H5O_info2_t oinfo1, oinfo2; /* object info */
trav_info_t *info1_obj = NULL;
trav_info_t *info2_obj = NULL;
/* for group object */
@@ -533,8 +543,8 @@ h5diff(const char *fname1,
trav_info_t *info1_lp = NULL;
trav_info_t *info2_lp = NULL;
/* link info from specified object */
- H5L_info_t src_linfo1;
- H5L_info_t src_linfo2;
+ H5L_info2_t src_linfo1;
+ H5L_info2_t src_linfo2;
/* link info from member object */
h5tool_link_info_t trg_linfo1;
h5tool_link_info_t trg_linfo2;
@@ -635,7 +645,7 @@ h5diff(const char *fname1,
H5TOOLS_GOTO_ERROR(H5DIFF_ERR, "Error: Object could not be found");
}
/* get info from link */
- if(H5Lget_info(file1_id, obj1fullname, &src_linfo1, H5P_DEFAULT) < 0) {
+ if(H5Lget_info2(file1_id, obj1fullname, &src_linfo1, H5P_DEFAULT) < 0) {
parallel_print("Unable to get link info from <%s>\n", obj1fullname);
H5TOOLS_GOTO_ERROR(H5DIFF_ERR, "H5Lget_info failed");
}
@@ -651,14 +661,14 @@ h5diff(const char *fname1,
/* optional data pass */
info1_obj->opts = (diff_opt_t*)opts;
- if(H5Oget_info_by_name2(file1_id, obj1fullname, &oinfo1, H5O_INFO_BASIC, H5P_DEFAULT) < 0) {
+ if(H5Oget_info_by_name3(file1_id, obj1fullname, &oinfo1, H5O_INFO_BASIC, H5P_DEFAULT) < 0) {
parallel_print("Error: Could not get file contents\n");
H5TOOLS_GOTO_ERROR(H5DIFF_ERR, "Error: Could not get file contents");
}
obj1type = (h5trav_type_t)oinfo1.type;
trav_info_add(info1_obj, obj1fullname, obj1type);
idx = info1_obj->nused - 1;
- info1_obj->paths[idx].objno = oinfo1.addr;
+ HDmemcpy(&info1_obj->paths[idx].obj_token, &oinfo1.token, sizeof(H5O_token_t));
info1_obj->paths[idx].fileno = oinfo1.fileno;
}
else if (src_linfo1.type == H5L_TYPE_SOFT) {
@@ -685,7 +695,7 @@ h5diff(const char *fname1,
H5TOOLS_GOTO_ERROR(H5DIFF_ERR, "Error: Object could not be found");
}
/* get info from link */
- if(H5Lget_info(file2_id, obj2fullname, &src_linfo2, H5P_DEFAULT) < 0) {
+ if(H5Lget_info2(file2_id, obj2fullname, &src_linfo2, H5P_DEFAULT) < 0) {
parallel_print("Unable to get link info from <%s>\n", obj2fullname);
H5TOOLS_GOTO_ERROR(H5DIFF_ERR, "H5Lget_info failed");
}
@@ -701,14 +711,14 @@ h5diff(const char *fname1,
/* optional data pass */
info2_obj->opts = (diff_opt_t*)opts;
- if(H5Oget_info_by_name2(file2_id, obj2fullname, &oinfo2, H5O_INFO_BASIC, H5P_DEFAULT) < 0) {
+ if(H5Oget_info_by_name3(file2_id, obj2fullname, &oinfo2, H5O_INFO_BASIC, H5P_DEFAULT) < 0) {
parallel_print("Error: Could not get file contents\n");
H5TOOLS_GOTO_ERROR(H5DIFF_ERR, "Error: Could not get file contents");
}
obj2type = (h5trav_type_t)oinfo2.type;
trav_info_add(info2_obj, obj2fullname, obj2type);
idx = info2_obj->nused - 1;
- info2_obj->paths[idx].objno = oinfo2.addr;
+ HDmemcpy(&info2_obj->paths[idx].obj_token, &oinfo2.token, sizeof(H5O_token_t));
info2_obj->paths[idx].fileno = oinfo2.fileno;
}
else if (src_linfo2.type == H5L_TYPE_SOFT) {
@@ -778,8 +788,8 @@ h5diff(const char *fname1,
size_t idx = info1_lp->nused - 1;
H5TOOLS_DEBUG("h5diff ... ... ... info1_obj not null");
+ HDmemcpy(&info1_lp->paths[idx].obj_token, &trg_linfo1.obj_token, sizeof(H5O_token_t));
info1_lp->paths[idx].type = (h5trav_type_t)trg_linfo1.trg_type;
- info1_lp->paths[idx].objno = trg_linfo1.objno;
info1_lp->paths[idx].fileno = trg_linfo1.fileno;
}
H5TOOLS_DEBUG("h5diff check symbolic link (object1) finished");
@@ -818,8 +828,8 @@ h5diff(const char *fname1,
size_t idx = info2_lp->nused - 1;
H5TOOLS_DEBUG("h5diff ... ... ... info2_obj not null");
+ HDmemcpy(&info2_lp->paths[idx].obj_token, &trg_linfo2.obj_token, sizeof(H5O_token_t));
info2_lp->paths[idx].type = (h5trav_type_t)trg_linfo2.trg_type;
- info2_lp->paths[idx].objno = trg_linfo2.objno;
info2_lp->paths[idx].fileno = trg_linfo2.fileno;
}
H5TOOLS_DEBUG("h5diff check symbolic link (object1) finished");
diff --git a/tools/lib/h5diff_array.c b/tools/lib/h5diff_array.c
index f671b06..8321a98 100644
--- a/tools/lib/h5diff_array.c
+++ b/tools/lib/h5diff_array.c
@@ -746,8 +746,8 @@ static hsize_t diff_datum(
/* if (type_size == H5R_STD_REF_SIZE) */
hid_t region1_id = H5I_INVALID_HID;
hid_t region2_id = H5I_INVALID_HID;
- H5R_ref_t *ref1_buf = (const H5R_ref_t *)_mem1;
- H5R_ref_t *ref2_buf = (const H5R_ref_t *)_mem2;
+ H5R_ref_t *ref1_buf = (H5R_ref_t *)_mem1;
+ H5R_ref_t *ref2_buf = (H5R_ref_t *)_mem2;
H5O_type_t obj1_type = -1; /* Object type */
H5O_type_t obj2_type = -1; /* Object type */
H5R_type_t ref_type; /* Reference type */
@@ -920,7 +920,7 @@ static hsize_t diff_datum(
/* if (obj_id < 0) - could mean that no reference was written do not throw failure */
obj1_id = H5Ropen_object(ref1_buf, H5P_DEFAULT, H5P_DEFAULT);
obj2_id = H5Ropen_object(ref2_buf, H5P_DEFAULT, H5P_DEFAULT);
- if((obj1_id < 0) || (obj1_id < 0)) {
+ if((obj1_id < 0) || (obj2_id < 0)) {
H5TOOLS_INFO("H5Ropen_object H5R_DATASET_REGION2 failed");
}
else {
@@ -979,7 +979,7 @@ static hsize_t diff_datum(
H5TOOLS_INFO("H5Ropen_attr object 2 failed");
}
- if((obj1_id < 0) || (obj1_id < 0)) {
+ if((obj1_id < 0) || (obj2_id < 0)) {
H5TOOLS_INFO("H5Ropen_attr H5R_ATTR failed");
}
else {
@@ -2394,14 +2394,22 @@ static hsize_t diff_region(hid_t obj1_id, hid_t obj2_id, hid_t region1_id, hid_t
/* print differences if found */
if (nfound_b && opts->m_verbose) {
- H5O_info_t oi1, oi2;
+ H5O_info2_t oi1, oi2;
+ char *obj1_str = NULL, *obj2_str = NULL;
- H5Oget_info2(obj1_id, &oi1, H5O_INFO_BASIC);
- H5Oget_info2(obj2_id, &oi2, H5O_INFO_BASIC);
+ H5Oget_info3(obj1_id, &oi1, H5O_INFO_BASIC);
+ H5Oget_info3(obj2_id, &oi2, H5O_INFO_BASIC);
- parallel_print("Referenced dataset %lu %lu\n", (unsigned long) oi1.addr, (unsigned long) oi2.addr);
+ /* Convert object tokens into printable output */
+ H5Otoken_to_str(obj1_id, &oi1.token, &obj1_str);
+ H5Otoken_to_str(obj2_id, &oi2.token, &obj2_str);
+
+ parallel_print("Referenced dataset %s %s\n", obj1_str, obj2_str);
parallel_print( "------------------------------------------------------------\n");
+ H5free_memory(obj1_str);
+ H5free_memory(obj2_str);
+
parallel_print("Region blocks\n");
for (i = 0; i < nblocks1; i++) {
parallel_print("block #%d", i);
diff --git a/tools/lib/h5diff_attr.c b/tools/lib/h5diff_attr.c
index e92e141..d1b4697 100644
--- a/tools/lib/h5diff_attr.c
+++ b/tools/lib/h5diff_attr.c
@@ -140,7 +140,7 @@ static void table_attr_mark_exist(unsigned *exist, char *name, table_attrs_t *ta
static herr_t build_match_list_attrs(hid_t loc1_id, hid_t loc2_id, table_attrs_t ** table_out, diff_opt_t *opts)
{
table_attrs_t *table_lp = NULL;
- H5O_info_t oinfo1, oinfo2; /* Object info */
+ H5O_info2_t oinfo1, oinfo2; /* Object info */
hid_t attr1_id = H5I_INVALID_HID; /* attr ID */
hid_t attr2_id = H5I_INVALID_HID; /* attr ID */
size_t curr1 = 0;
@@ -155,14 +155,14 @@ static herr_t build_match_list_attrs(hid_t loc1_id, hid_t loc2_id, table_attrs_t
H5TOOLS_DEBUG("build_match_list_attrs start - errstat:%d", opts->err_stat);
- if(H5Oget_info2(loc1_id, &oinfo1, H5O_INFO_NUM_ATTRS) < 0) {
+ if(H5Oget_info3(loc1_id, &oinfo1, H5O_INFO_NUM_ATTRS) < 0) {
H5TOOLS_GOTO_ERROR(FAIL, "H5Oget_info first object failed");
}
- H5TOOLS_DEBUG("H5Oget_info2 loc1id=%d", oinfo1.num_attrs);
- if(H5Oget_info2(loc2_id, &oinfo2, H5O_INFO_NUM_ATTRS) < 0) {
+ H5TOOLS_DEBUG("H5Oget_info3 loc1id=%d", oinfo1.num_attrs);
+ if(H5Oget_info3(loc2_id, &oinfo2, H5O_INFO_NUM_ATTRS) < 0) {
H5TOOLS_GOTO_ERROR(FAIL, "H5Oget_info second object failed");
}
- H5TOOLS_DEBUG("H5Oget_info2 loc2id=%d", oinfo2.num_attrs);
+ H5TOOLS_DEBUG("H5Oget_info3 loc2id=%d", oinfo2.num_attrs);
table_attrs_init(&table_lp);
if (table_lp == NULL)
@@ -336,7 +336,6 @@ hsize_t diff_attr_data(hid_t attr1_id, hid_t attr2_id, const char *name1, const
hsize_t dims2[H5S_MAX_RANK]; /* dimensions of dataset */
char np1[512];
char np2[512];
- unsigned u; /* Local index variable */
hsize_t nfound = 0;
int j;
diff_err_t ret_value = opts->err_stat;
diff --git a/tools/lib/h5tools.c b/tools/lib/h5tools.c
index 7aa2419..cb9b92c 100644
--- a/tools/lib/h5tools.c
+++ b/tools/lib/h5tools.c
@@ -1480,8 +1480,6 @@ render_bin_output(FILE *stream, hid_t container, hid_t tid, void *_mem, hsize_t
break;
} /* end switch */
-done:
-
CATCH
H5TOOLS_ENDDEBUG("exit");
return ret_value;
@@ -1806,21 +1804,27 @@ hbool_t
h5tools_is_obj_same(hid_t loc_id1, const char *name1,
hid_t loc_id2, const char *name2)
{
- H5O_info_t oinfo1, oinfo2;
+ H5O_info2_t oinfo1, oinfo2;
hbool_t ret_val = FALSE;
if ( name1 && HDstrcmp(name1, "."))
- H5Oget_info_by_name2(loc_id1, name1, &oinfo1, H5O_INFO_BASIC, H5P_DEFAULT);
+ H5Oget_info_by_name3(loc_id1, name1, &oinfo1, H5O_INFO_BASIC, H5P_DEFAULT);
else
- H5Oget_info2(loc_id1, &oinfo1, H5O_INFO_BASIC);
+ H5Oget_info3(loc_id1, &oinfo1, H5O_INFO_BASIC);
if ( name2 && HDstrcmp(name2, "."))
- H5Oget_info_by_name2(loc_id2, name2, &oinfo2, H5O_INFO_BASIC, H5P_DEFAULT);
+ H5Oget_info_by_name3(loc_id2, name2, &oinfo2, H5O_INFO_BASIC, H5P_DEFAULT);
else
- H5Oget_info2(loc_id2, &oinfo2, H5O_INFO_BASIC);
+ H5Oget_info3(loc_id2, &oinfo2, H5O_INFO_BASIC);
+
+ if (oinfo1.fileno == oinfo2.fileno) {
+ int token_cmp_val;
- if (oinfo1.fileno == oinfo2.fileno && oinfo1.addr==oinfo2.addr)
- ret_val = TRUE;
+ H5Otoken_cmp(loc_id1, &oinfo1.token, &oinfo2.token, &token_cmp_val);
+
+ if(!token_cmp_val)
+ ret_val = TRUE;
+ }
return ret_val;
}
diff --git a/tools/lib/h5tools_dump.c b/tools/lib/h5tools_dump.c
index 3af2bd8..79802c3 100644
--- a/tools/lib/h5tools_dump.c
+++ b/tools/lib/h5tools_dump.c
@@ -2088,15 +2088,20 @@ h5tools_print_datatype(FILE *stream, h5tools_str_t *buffer, const h5tool_format_
if((type_class = H5Tget_class(type)) < 0)
H5TOOLS_THROW((-1), "H5Tget_class failed");
if (object_search && H5Tcommitted(type) > 0) {
- H5O_info_t oinfo;
- obj_t *obj = NULL; /* Found object */
+ H5O_info2_t oinfo;
+ obj_t *obj = NULL; /* Found object */
- H5Oget_info2(type, &oinfo, H5O_INFO_BASIC);
- obj = search_obj(h5dump_type_table, oinfo.addr);
+ H5Oget_info3(type, &oinfo, H5O_INFO_BASIC);
+ obj = search_obj(h5dump_type_table, &oinfo.token);
if(obj) {
- if(!obj->recorded)
- h5tools_str_append(buffer,"\"/#"H5_PRINTF_HADDR_FMT"\"", obj->objno);
+ if(!obj->recorded) {
+ char *obj_addr_str = NULL;
+
+ H5Otoken_to_str(type, &oinfo.token, &obj_addr_str);
+ h5tools_str_append(buffer,"\"/#%s\"", obj_addr_str);
+ H5free_memory(obj_addr_str);
+ }
else
h5tools_str_append(buffer, "\"%s\"", obj->objname);
}
@@ -2629,8 +2634,6 @@ h5tools_print_datatype(FILE *stream, h5tools_str_t *buffer, const h5tool_format_
break;
}
-done:
-
CATCH
H5TOOLS_ENDDEBUG("exit");
return ret_value;
@@ -4052,7 +4055,7 @@ h5tools_dump_data(FILE *stream, const h5tool_format_t *info, h5tools_context_t *
init_acc_pos(&datactx, total_size);
datactx.need_prefix = TRUE;
- if (NULL != (ref_buf = (H5R_ref_t *)HDcalloc(MAX(sizeof(unsigned), sizeof(H5R_ref_t)), ndims))) {
+ if (NULL != (ref_buf = (H5R_ref_t *)HDcalloc(MAX(sizeof(unsigned), sizeof(H5R_ref_t)), (size_t)ndims))) {
if(obj_data) {
if(H5Dread(obj_id, H5T_STD_REF, H5S_ALL, H5S_ALL, H5P_DEFAULT, ref_buf) < 0) {
HDfree(ref_buf);
@@ -4067,7 +4070,7 @@ h5tools_dump_data(FILE *stream, const h5tool_format_t *info, h5tools_context_t *
H5TOOLS_GOTO_DONE_NO_RET();
}
}
- for(i = 0; i < ndims; i++, datactx.cur_elmt++, elmt_counter++) {
+ for(i = 0; i < (size_t)ndims; i++, datactx.cur_elmt++, elmt_counter++) {
H5O_type_t obj_type = -1; /* Object type */
H5R_type_t ref_type; /* Reference type */
diff --git a/tools/lib/h5tools_ref.c b/tools/lib/h5tools_ref.c
index e98a8e2..0e1fa03 100644
--- a/tools/lib/h5tools_ref.c
+++ b/tools/lib/h5tools_ref.c
@@ -17,6 +17,7 @@
#include "h5tools.h"
#include "h5tools_utils.h"
#include "h5trav.h"
+#include "H5VLnative_private.h"
/*
@@ -34,14 +35,14 @@
*/
typedef struct {
- haddr_t objno; /* Object ID (i.e. address) */
- char *path; /* Object path */
+ H5O_token_t obj_token; /* Object token */
+ char *path; /* Object path */
} ref_path_node_t;
static H5SL_t *ref_path_table = NULL; /* the "table" (implemented with a skip list) */
static hid_t thefile = (-1);
-static int ref_path_table_put(const char *, haddr_t objno);
+static int ref_path_table_put(const char *, const H5O_token_t *token);
/*-------------------------------------------------------------------------
* Function: free_ref_path_info
@@ -80,19 +81,47 @@ free_ref_path_info(void *item, void H5_ATTR_UNUSED *key, void H5_ATTR_UNUSED *op
*-------------------------------------------------------------------------
*/
static herr_t
-init_ref_path_cb(const char *obj_name, const H5O_info_t *oinfo,
+init_ref_path_cb(const char *obj_name, const H5O_info2_t *oinfo,
const char *already_seen, void H5_ATTR_UNUSED *_udata)
{
/* Check if the object is already in the path table */
if(NULL == already_seen) {
/* Insert the object into the path table */
- ref_path_table_put(obj_name, oinfo->addr);
+ ref_path_table_put(obj_name, &oinfo->token);
} /* end if */
return 0;
}
/*-------------------------------------------------------------------------
+ * Function: ref_path_table_cmp
+ *
+ * Purpose: Skip list key comparison function which compares two
+ * H5O_token_t objects.
+ *
+ * Return: Negative (if token2 is greater than token1)
+ * 0 (if tokens are equal)
+ * or
+ * Positive (if token1 is greater than token2)
+ *
+ *-------------------------------------------------------------------------
+ */
+static int
+ref_path_table_cmp(const void *key1, const void *key2)
+{
+ const H5O_token_t *token1 = (const H5O_token_t *)key1;
+ const H5O_token_t *token2 = (const H5O_token_t *)key2;
+ int cmp_value = 0;
+
+ if(thefile > 0)
+ H5Otoken_cmp(thefile, token1, token2, &cmp_value);
+ else
+ cmp_value = HDmemcmp(token1, token2, sizeof(H5O_token_t));
+
+ return cmp_value;
+}
+
+/*-------------------------------------------------------------------------
* Function: init_ref_path_table
*
* Purpose: Initalize the reference path table
@@ -109,7 +138,7 @@ init_ref_path_table(void)
/* Sanity check */
if(thefile > 0) {
/* Create skip list to store reference path information */
- if((ref_path_table = H5SL_create(H5SL_TYPE_HADDR, NULL))==NULL)
+ if((ref_path_table = H5SL_create(H5SL_TYPE_GENERIC, ref_path_table_cmp)) == NULL)
return (-1);
/* Iterate over objects in this file */
@@ -153,8 +182,10 @@ term_ref_path_table(void)
* Purpose: Looks up a table entry given a path name.
* Used during construction of the table.
*
- * Return: The table entre (pte) or NULL if not in the
- * table.
+ * Return: Negative on failure, Non-negative on success. The object
+ * token for the table entry is returned through the token
+ * parameter if the table entry is found by the given path
+ * name.
*
* Programmer: REMcG
*
@@ -162,33 +193,35 @@ term_ref_path_table(void)
*
*-------------------------------------------------------------------------
*/
-haddr_t
-ref_path_table_lookup(const char *thepath)
+int
+ref_path_table_lookup(const char *thepath, H5O_token_t *token)
{
- H5O_info_t oi;
+ H5O_info2_t oi;
if((thepath == NULL) || (HDstrlen(thepath) == 0))
- return HADDR_UNDEF;
+ return -1;
/* Allow lookups on the root group, even though it doesn't have any link info */
if(HDstrcmp(thepath, "/")) {
- H5L_info_t li;
+ H5L_info2_t li;
/* Check for external link first, so we don't return the OID of an object in another file */
- if(H5Lget_info(thefile, thepath, &li, H5P_DEFAULT) < 0)
- return HADDR_UNDEF;
+ if(H5Lget_info2(thefile, thepath, &li, H5P_DEFAULT) < 0)
+ return -1;
/* UD links can't be followed, so they always "dangle" like soft links. */
if(li.type >= H5L_TYPE_UD_MIN)
- return HADDR_UNDEF;
+ return -1;
} /* end if */
/* Get the object info now */
/* (returns failure for dangling soft links) */
- if(H5Oget_info_by_name2(thefile, thepath, &oi, H5O_INFO_BASIC, H5P_DEFAULT) < 0)
- return HADDR_UNDEF;
+ if(H5Oget_info_by_name3(thefile, thepath, &oi, H5O_INFO_BASIC, H5P_DEFAULT) < 0)
+ return -1;
- /* Return OID */
- return(oi.addr);
+ /* Return object token through parameter */
+ HDmemcpy(token, &oi.token, sizeof(H5O_token_t));
+
+ return 0;
}
/*-------------------------------------------------------------------------
@@ -211,7 +244,7 @@ ref_path_table_lookup(const char *thepath)
*-------------------------------------------------------------------------
*/
static int
-ref_path_table_put(const char *path, haddr_t objno)
+ref_path_table_put(const char *path, const H5O_token_t *token)
{
ref_path_node_t *new_node;
@@ -219,10 +252,10 @@ ref_path_table_put(const char *path, haddr_t objno)
if((new_node = (ref_path_node_t *)HDmalloc(sizeof(ref_path_node_t))) == NULL)
return(-1);
- new_node->objno = objno;
+ HDmemcpy(&new_node->obj_token, token, sizeof(H5O_token_t));
new_node->path = HDstrdup(path);
- return(H5SL_insert(ref_path_table, new_node, &(new_node->objno)));
+ return(H5SL_insert(ref_path_table, new_node, &(new_node->obj_token)));
}
else
return (-1);
@@ -239,46 +272,50 @@ int get_next_xid(void) {
/*
* This counter is used to create fake object ID's
- * The idea is to set it to the largest possible offest, which
+ * The idea is to set it to the largest possible offset, which
* minimizes the chance of collision with a real object id.
*
*/
haddr_t fake_xid = HADDR_MAX;
-haddr_t
-get_fake_xid (void) {
- return (fake_xid--);
+
+void
+get_fake_token(H5O_token_t *token) {
+ if(thefile > 0) {
+ /* TODO: potential for this to be called with non-native connector objects */
+ if(H5VLnative_addr_to_token(thefile, fake_xid, token) < 0)
+ *token = H5O_TOKEN_UNDEF;
+ fake_xid--;
+ }
+ else
+ *token = H5O_TOKEN_UNDEF;
}
/*
- * for an object that does not have an object id (e.g., soft link),
- * create a table entry with a fake object id as the key.
+ * for an object that does not have an object token (e.g., soft link),
+ * create a table entry with a fake object token as the key.
*
* Assumes 'path' is for an object that is not in the table.
*
*/
-haddr_t
-ref_path_table_gen_fake(const char *path)
+void
+ref_path_table_gen_fake(const char *path, H5O_token_t *token)
{
- haddr_t fake_objno;
-
- /* Generate fake ID for string */
- fake_objno = get_fake_xid();
+ /* Generate fake object token for string */
+ get_fake_token(token);
/* Create ref path table, if it hasn't already been created */
if(ref_path_table == NULL)
init_ref_path_table();
/* Insert "fake" object into table */
- ref_path_table_put(path, fake_objno);
-
- return(fake_objno);
+ ref_path_table_put(path, token);
}
/*-------------------------------------------------------------------------
* Function: lookup_ref_path
*
- * Purpose: Lookup the path to the object with refernce 'ref'.
+ * Purpose: Lookup the path to the object with the reference 'refbuf'.
*
* Return: Return a path to the object, or NULL if not found.
*
@@ -289,19 +326,48 @@ ref_path_table_gen_fake(const char *path)
*-------------------------------------------------------------------------
*/
const char *
-lookup_ref_path(haddr_t ref)
+lookup_ref_path(H5R_ref_t refbuf)
{
+ H5O_info2_t oinfo;
+ H5R_type_t ref_type;
+ hid_t ref_object;
ref_path_node_t *node;
/* Be safer for h5ls */
if(thefile < 0)
return(NULL);
+ /* Retrieve reference type */
+ if(H5R_BADTYPE == (ref_type = H5Rget_type(&refbuf)))
+ return(NULL);
+
+ /* Open the referenced object */
+ switch (ref_type) {
+ case H5R_OBJECT1:
+ case H5R_OBJECT2:
+ if((ref_object = H5Ropen_object(&refbuf, H5P_DEFAULT, H5P_DEFAULT)) < 0)
+ return(NULL);
+ break;
+
+ /* Invalid referenced object type */
+ case H5R_DATASET_REGION1:
+ case H5R_DATASET_REGION2:
+ case H5R_ATTR:
+ case H5R_MAXTYPE:
+ case H5R_BADTYPE:
+ default:
+ return(NULL);
+ }
+
+ /* Retrieve info about the referenced object */
+ if(H5Oget_info3(ref_object, &oinfo, H5O_INFO_ALL) < 0)
+ return(NULL);
+
/* Create ref path table, if it hasn't already been created */
if(ref_path_table == NULL)
init_ref_path_table();
- node = (ref_path_node_t *)H5SL_search(ref_path_table, &ref);
+ node = (ref_path_node_t *)H5SL_search(ref_path_table, &oinfo.token);
return(node ? node->path : NULL);
}
diff --git a/tools/lib/h5tools_ref.h b/tools/lib/h5tools_ref.h
index b7bd9a3..debbea1 100644
--- a/tools/lib/h5tools_ref.h
+++ b/tools/lib/h5tools_ref.h
@@ -21,11 +21,11 @@ extern "C" {
#endif
H5TOOLS_DLL herr_t fill_ref_path_table(hid_t fid);
-H5TOOLS_DLL const char *lookup_ref_path(haddr_t ref);
+H5TOOLS_DLL const char *lookup_ref_path(H5R_ref_t refbuf);
H5TOOLS_DLL int get_next_xid(void);
-H5TOOLS_DLL haddr_t get_fake_xid(void);
-H5TOOLS_DLL haddr_t ref_path_table_lookup(const char *);
-H5TOOLS_DLL haddr_t ref_path_table_gen_fake(const char *);
+H5TOOLS_DLL void get_fake_token(H5O_token_t *token);
+H5TOOLS_DLL int ref_path_table_lookup(const char *thepath, H5O_token_t *token);
+H5TOOLS_DLL void ref_path_table_gen_fake(const char *path, H5O_token_t *token);
H5TOOLS_DLL int term_ref_path_table(void);
#ifdef __cplusplus
diff --git a/tools/lib/h5tools_str.c b/tools/lib/h5tools_str.c
index 0aa5152..c9e7e94 100644
--- a/tools/lib/h5tools_str.c
+++ b/tools/lib/h5tools_str.c
@@ -1091,7 +1091,7 @@ h5tools_str_sprint(h5tools_str_t *str, const h5tool_format_t *info, hid_t contai
if (H5Tequal(type, H5T_STD_REF)) {
H5O_type_t obj_type = -1; /* Object type */
H5R_type_t ref_type; /* Reference type */
- const H5R_ref_t *ref_vp = (const H5R_ref_t *)vp;
+ H5R_ref_t *ref_vp = (H5R_ref_t *)vp;
H5TOOLS_DEBUG("H5T_REFERENCE:H5T_STD_REF");
ref_type = H5Rget_type(ref_vp);
@@ -1100,13 +1100,13 @@ h5tools_str_sprint(h5tools_str_t *str, const h5tool_format_t *info, hid_t contai
case H5R_OBJECT1:
{
/* Object references -- show the type and OID of the referenced object. */
- H5O_info_t oi;
+ H5O_info2_t oi;
+ char *obj_addr_str = NULL;
H5TOOLS_DEBUG("ref_type is H5R_OBJECT1");
if((obj = H5Ropen_object(ref_vp, H5P_DEFAULT, H5P_DEFAULT)) >= 0) {
- H5Oget_info2(obj, &oi, H5O_INFO_BASIC);
- if(H5Oclose(obj) < 0)
- H5TOOLS_ERROR(NULL, "H5Oclose H5R_OBJECT1 failed");
+ H5Oget_info3(obj, &oi, H5O_INFO_BASIC);
+ H5Otoken_to_str(obj, &oi.token, &obj_addr_str);
}
else
H5TOOLS_ERROR(NULL, "H5Ropen_object H5R_OBJECT1 failed");
@@ -1132,20 +1132,30 @@ h5tools_str_sprint(h5tools_str_t *str, const h5tool_format_t *info, hid_t contai
h5tools_str_append(str, "%u-%s", (unsigned) oi.type, H5_TOOLS_UNKNOWN);
break;
} /* end switch */
- H5Oclose(obj);
- h5tools_str_sprint_reference(str, info, container, ref_vp);
+
+ h5tools_str_sprint_reference(str, ref_vp);
/* Print OID */
if(info->obj_hidefileno)
- h5tools_str_append(str, info->obj_format, oi.addr);
+ h5tools_str_append(str, info->obj_format, obj_addr_str);
else
- h5tools_str_append(str, info->obj_format, oi.fileno, oi.addr);
+ h5tools_str_append(str, info->obj_format, oi.fileno, obj_addr_str);
+
+ if(obj_addr_str) {
+ H5free_memory(obj_addr_str);
+ obj_addr_str = NULL;
}
+
+ if(obj >= 0)
+ if(H5Oclose(obj) < 0)
+ H5TOOLS_ERROR(NULL, "H5Oclose H5R_OBJECT1 failed");
+ }
+
break;
case H5R_DATASET_REGION1:
H5TOOLS_DEBUG("ref_type is H5R_DATASET_REGION1");
h5tools_str_append(str, H5_TOOLS_DATASET);
- h5tools_str_sprint_reference(str, info, container, ref_vp);
+ h5tools_str_sprint_reference(str, ref_vp);
break;
case H5R_OBJECT2:
H5TOOLS_DEBUG("ref_type is H5R_OBJECT2");
@@ -1169,17 +1179,17 @@ h5tools_str_sprint(h5tools_str_t *str, const h5tool_format_t *info, hid_t contai
h5tools_str_append(str, H5_TOOLS_UNKNOWN);
break;
} /* end switch */
- h5tools_str_sprint_reference(str, info, container, ref_vp);
+ h5tools_str_sprint_reference(str, ref_vp);
break;
case H5R_DATASET_REGION2:
H5TOOLS_DEBUG("ref_type is H5R_DATASET_REGION2");
h5tools_str_append(str, H5_TOOLS_DATASET);
- h5tools_str_sprint_reference(str, info, container, ref_vp);
+ h5tools_str_sprint_reference(str, ref_vp);
break;
case H5R_ATTR:
H5TOOLS_DEBUG("ref_type is H5R_ATTR");
h5tools_str_append(str, H5_TOOLS_ATTRIBUTE);
- h5tools_str_sprint_reference(str, info, container, ref_vp);
+ h5tools_str_sprint_reference(str, ref_vp);
break;
case H5R_BADTYPE:
case H5R_MAXTYPE:
@@ -1334,7 +1344,6 @@ h5tools_str_sprint(h5tools_str_t *str, const h5tool_format_t *info, hid_t contai
} /* end switch */
}
-done:
ret_value = h5tools_str_fmt(str, start, OPT(info->elmt_fmt, "%s"));
H5TOOLS_ENDDEBUG("exit with %s", ret_value);
@@ -1351,8 +1360,7 @@ done:
*-------------------------------------------------------------------------
*/
void
-h5tools_str_sprint_reference(h5tools_str_t *str, const h5tool_format_t *info,
- hid_t container, H5R_ref_t *ref_vp)
+h5tools_str_sprint_reference(h5tools_str_t *str, H5R_ref_t *ref_vp)
{
ssize_t buf_size;
@@ -1363,7 +1371,7 @@ h5tools_str_sprint_reference(h5tools_str_t *str, const h5tool_format_t *info,
H5TOOLS_DEBUG("buf_size=%ld", buf_size);
if (buf_size) {
char *file_name = (char *)HDmalloc(sizeof(char) * (size_t)buf_size + 1);
- if (H5Rget_file_name(ref_vp, file_name, buf_size + 1) >= 0) {
+ if (H5Rget_file_name(ref_vp, file_name, (size_t)buf_size + 1) >= 0) {
file_name[buf_size] = '\0';
H5TOOLS_DEBUG("name=%s", file_name);
h5tools_str_append(str, "%s", file_name);
@@ -1375,7 +1383,7 @@ h5tools_str_sprint_reference(h5tools_str_t *str, const h5tool_format_t *info,
H5TOOLS_DEBUG("buf_size=%ld", buf_size);
if (buf_size) {
char *obj_name = (char *)HDmalloc(sizeof(char) * (size_t)buf_size + 1);
- if (H5Rget_obj_name(ref_vp, H5P_DEFAULT, obj_name, buf_size + 1) >= 0) {
+ if (H5Rget_obj_name(ref_vp, H5P_DEFAULT, obj_name, (size_t)buf_size + 1) >= 0) {
obj_name[buf_size] = '\0';
H5TOOLS_DEBUG("name=%s", obj_name);
h5tools_str_append(str, "%s", obj_name);
@@ -1388,7 +1396,7 @@ h5tools_str_sprint_reference(h5tools_str_t *str, const h5tool_format_t *info,
H5TOOLS_DEBUG("buf_size=%ld", buf_size);
if (buf_size) {
char *attr_name = (char *)HDmalloc(sizeof(char) * (size_t)buf_size + 1);
- if (H5Rget_attr_name(ref_vp, attr_name, buf_size + 1) >= 0) {
+ if (H5Rget_attr_name(ref_vp, attr_name, (size_t)buf_size + 1) >= 0) {
attr_name[buf_size] = '\0';
H5TOOLS_DEBUG("name=%s", attr_name);
h5tools_str_append(str, "/%s", attr_name);
diff --git a/tools/lib/h5tools_str.h b/tools/lib/h5tools_str.h
index 6fdf36a..02bfe40 100644
--- a/tools/lib/h5tools_str.h
+++ b/tools/lib/h5tools_str.h
@@ -41,7 +41,7 @@ H5TOOLS_DLL char *h5tools_str_region_prefix(h5tools_str_t *str, const h5tool_
H5TOOLS_DLL void h5tools_str_dump_space_slabs(h5tools_str_t *, hid_t, const h5tool_format_t *, h5tools_context_t *ctx);
H5TOOLS_DLL void h5tools_str_dump_space_blocks(h5tools_str_t *, hid_t, const h5tool_format_t *);
H5TOOLS_DLL void h5tools_str_dump_space_points(h5tools_str_t *, hid_t, const h5tool_format_t *);
-H5TOOLS_DLL void h5tools_str_sprint_reference(h5tools_str_t *str, const h5tool_format_t *info, hid_t container, H5R_ref_t *vp);
+H5TOOLS_DLL void h5tools_str_sprint_reference(h5tools_str_t *str, H5R_ref_t *vp);
H5TOOLS_DLL char *h5tools_str_sprint(h5tools_str_t *str, const h5tool_format_t *info,
hid_t container, hid_t type, void *vp,
h5tools_context_t *ctx);
diff --git a/tools/lib/h5tools_utils.c b/tools/lib/h5tools_utils.c
index 323c9b3..45e436c 100644
--- a/tools/lib/h5tools_utils.c
+++ b/tools/lib/h5tools_utils.c
@@ -53,11 +53,11 @@ unsigned outBuffOffset;
FILE* overflow_file = NULL;
/* local functions */
-static void init_table(table_t **tbl);
+static void init_table(hid_t fid, table_t **tbl);
#ifdef H5DUMP_DEBUG
-static void dump_table(char* tablename, table_t *table);
+static void dump_table(hid_t fid, char* tablename, table_t *table);
#endif /* H5DUMP_DEBUG */
-static void add_obj(table_t *table, haddr_t objno, const char *objname, hbool_t recorded);
+static void add_obj(table_t *table, const H5O_token_t *obj_token, const char *objname, hbool_t recorded);
/*-------------------------------------------------------------------------
* Function: parallel_print
@@ -599,10 +599,11 @@ print_version(const char *progname)
*-------------------------------------------------------------------------
*/
static void
-init_table(table_t **tbl)
+init_table(hid_t fid, table_t **tbl)
{
table_t *table = (table_t *)HDmalloc(sizeof(table_t));
+ table->fid = fid;
table->size = 20;
table->nobjs = 0;
table->objs = (obj_t *)HDmalloc(table->size * sizeof(obj_t));
@@ -644,15 +645,21 @@ free_table(table_t *table)
*-------------------------------------------------------------------------
*/
static void
-dump_table(char* tablename, table_t *table)
+dump_table(hid_t fid, char* tablename, table_t *table)
{
unsigned u;
+ char *obj_addr_str = NULL;
PRINTSTREAM(rawoutstream,"%s: # of entries = %d\n", tablename,table->nobjs);
- for (u = 0; u < table->nobjs; u++)
- PRINTSTREAM(rawoutstream,"%a %s %d %d\n", table->objs[u].objno,
+ for (u = 0; u < table->nobjs; u++) {
+ H5VLconnector_token_to_str(fid, table->objs[u].obj_token, &obj_addr_str);
+
+ PRINTSTREAM(rawoutstream,"%s %s %d %d\n", obj_addr_str,
table->objs[u].objname,
table->objs[u].displayed, table->objs[u].recorded);
+
+ H5VLfree_token_str(fid, obj_addr_str);
+ }
}
@@ -667,9 +674,9 @@ dump_table(char* tablename, table_t *table)
void
dump_tables(find_objs_t *info)
{
- dump_table("group_table", info->group_table);
- dump_table("dset_table", info->dset_table);
- dump_table("type_table", info->type_table);
+ dump_table(info->fid, "group_table", info->group_table);
+ dump_table(info->fid, "dset_table", info->dset_table);
+ dump_table(info->fid, "type_table", info->type_table);
}
#endif /* H5DUMP_DEBUG */
@@ -685,13 +692,17 @@ dump_tables(find_objs_t *info)
*-------------------------------------------------------------------------
*/
H5_ATTR_PURE obj_t *
-search_obj(table_t *table, haddr_t objno)
+search_obj(table_t *table, const H5O_token_t *obj_token)
{
unsigned u;
+ int token_cmp;
- for(u = 0; u < table->nobjs; u++)
- if(table->objs[u].objno == objno)
+ for(u = 0; u < table->nobjs; u++) {
+ if(H5Otoken_cmp(table->fid, &table->objs[u].obj_token, obj_token, &token_cmp) < 0)
+ return NULL;
+ if(!token_cmp)
return &(table->objs[u]);
+ }
return NULL;
}
@@ -708,7 +719,7 @@ search_obj(table_t *table, haddr_t objno)
*-------------------------------------------------------------------------
*/
static herr_t
-find_objs_cb(const char *name, const H5O_info_t *oinfo, const char *already_seen, void *op_data)
+find_objs_cb(const char *name, const H5O_info2_t *oinfo, const char *already_seen, void *op_data)
{
find_objs_t *info = (find_objs_t*)op_data;
herr_t ret_value = 0;
@@ -716,7 +727,7 @@ find_objs_cb(const char *name, const H5O_info_t *oinfo, const char *already_seen
switch(oinfo->type) {
case H5O_TYPE_GROUP:
if(NULL == already_seen)
- add_obj(info->group_table, oinfo->addr, name, TRUE);
+ add_obj(info->group_table, &oinfo->token, name, TRUE);
break;
case H5O_TYPE_DATASET:
@@ -724,18 +735,18 @@ find_objs_cb(const char *name, const H5O_info_t *oinfo, const char *already_seen
hid_t dset = H5I_INVALID_HID;
/* Add the dataset to the list of objects */
- add_obj(info->dset_table, oinfo->addr, name, TRUE);
+ add_obj(info->dset_table, &oinfo->token, name, TRUE);
/* Check for a dataset that uses a named datatype */
if((dset = H5Dopen2(info->fid, name, H5P_DEFAULT)) >= 0) {
hid_t type = H5Dget_type(dset);
if(H5Tcommitted(type) > 0) {
- H5O_info_t type_oinfo;
+ H5O_info2_t type_oinfo;
- H5Oget_info2(type, &type_oinfo, H5O_INFO_BASIC);
- if(search_obj(info->type_table, type_oinfo.addr) == NULL)
- add_obj(info->type_table, type_oinfo.addr, name, FALSE);
+ H5Oget_info3(type, &type_oinfo, H5O_INFO_BASIC);
+ if(search_obj(info->type_table, &type_oinfo.token) == NULL)
+ add_obj(info->type_table, &type_oinfo.token, name, FALSE);
} /* end if */
H5Tclose(type);
@@ -750,8 +761,8 @@ find_objs_cb(const char *name, const H5O_info_t *oinfo, const char *already_seen
if(NULL == already_seen) {
obj_t *found_obj;
- if((found_obj = search_obj(info->type_table, oinfo->addr)) == NULL)
- add_obj(info->type_table, oinfo->addr, name, TRUE);
+ if((found_obj = search_obj(info->type_table, &oinfo->token)) == NULL)
+ add_obj(info->type_table, &oinfo->token, name, TRUE);
else {
/* Use latest version of name */
HDfree(found_obj->objname);
@@ -791,9 +802,9 @@ init_objs(hid_t fid, find_objs_t *info, table_t **group_table,
herr_t ret_value = SUCCEED;
/* Initialize the tables */
- init_table(group_table);
- init_table(dset_table);
- init_table(type_table);
+ init_table(fid, group_table);
+ init_table(fid, dset_table);
+ init_table(fid, type_table);
/* Init the find_objs_t */
info->fid = fid;
@@ -829,7 +840,7 @@ done:
*-------------------------------------------------------------------------
*/
static void
-add_obj(table_t *table, haddr_t objno, const char *objname, hbool_t record)
+add_obj(table_t *table, const H5O_token_t *obj_token, const char *objname, hbool_t record)
{
size_t u;
@@ -843,7 +854,7 @@ add_obj(table_t *table, haddr_t objno, const char *objname, hbool_t record)
u = table->nobjs++;
/* Set information about object */
- table->objs[u].objno = objno;
+ HDmemcpy(&table->objs[u].obj_token, obj_token, sizeof(H5O_token_t));
table->objs[u].objname = HDstrdup(objname);
table->objs[u].recorded = record;
table->objs[u].displayed = 0;
@@ -893,7 +904,7 @@ int
H5tools_get_symlink_info(hid_t file_id, const char * linkpath, h5tool_link_info_t *link_info, hbool_t get_obj_type)
{
htri_t l_ret;
- H5O_info_t trg_oinfo;
+ H5O_info2_t trg_oinfo;
hid_t fapl = H5P_DEFAULT;
hid_t lapl = H5P_DEFAULT;
int ret_value = -1; /* init to fail */
@@ -915,7 +926,7 @@ H5tools_get_symlink_info(hid_t file_id, const char * linkpath, h5tool_link_info_
} /* end if */
/* get info from link */
- if(H5Lget_info(file_id, linkpath, &(link_info->linfo), H5P_DEFAULT) < 0) {
+ if(H5Lget_info2(file_id, linkpath, &(link_info->linfo), H5P_DEFAULT) < 0) {
if(link_info->opt.msg_mode == 1)
parallel_print("Warning: unable to get link info from <%s>\n",linkpath);
H5TOOLS_GOTO_DONE(FAIL);
@@ -971,7 +982,7 @@ H5tools_get_symlink_info(hid_t file_id, const char * linkpath, h5tool_link_info_
}
/* get target object info */
- if(H5Oget_info_by_name2(file_id, linkpath, &trg_oinfo, H5O_INFO_BASIC, lapl) < 0) {
+ if(H5Oget_info_by_name3(file_id, linkpath, &trg_oinfo, H5O_INFO_BASIC, lapl) < 0) {
if(link_info->opt.msg_mode == 1)
parallel_print("Warning: unable to get object information for <%s>\n", linkpath);
H5TOOLS_GOTO_DONE(FAIL);
@@ -985,8 +996,8 @@ H5tools_get_symlink_info(hid_t file_id, const char * linkpath, h5tool_link_info_
} /* end if */
/* set target obj type to return */
+ HDmemcpy(&link_info->obj_token, &trg_oinfo.token, sizeof(H5O_token_t));
link_info->trg_type = trg_oinfo.type;
- link_info->objno = trg_oinfo.addr;
link_info->fileno = trg_oinfo.fileno;
} /* end if */
else
diff --git a/tools/lib/h5tools_utils.h b/tools/lib/h5tools_utils.h
index 17c16bf..366800a 100644
--- a/tools/lib/h5tools_utils.h
+++ b/tools/lib/h5tools_utils.h
@@ -95,14 +95,15 @@ H5TOOLS_DLL int get_option(int argc, const char **argv, const char *opt, const s
/*struct taken from the dumper. needed in table struct*/
typedef struct obj_t {
- haddr_t objno;
- char *objname;
- hbool_t displayed; /* Flag to indicate that the object has been displayed */
- hbool_t recorded; /* Flag for named datatypes to indicate they were found in the group hierarchy */
+ H5O_token_t obj_token;
+ char *objname;
+ hbool_t displayed; /* Flag to indicate that the object has been displayed */
+ hbool_t recorded; /* Flag for named datatypes to indicate they were found in the group hierarchy */
} obj_t;
/*struct for the tables that the find_objs function uses*/
typedef struct table_t {
+ hid_t fid;
size_t size;
size_t nobjs;
obj_t *objs;
@@ -131,7 +132,7 @@ H5TOOLS_DLL void free_table(table_t *table);
H5TOOLS_DLL void dump_tables(find_objs_t *info)
#endif /* H5DUMP_DEBUG */
H5TOOLS_DLL herr_t init_objs(hid_t fid, find_objs_t *info, table_t **group_table, table_t **dset_table, table_t **type_table);
-H5TOOLS_DLL obj_t *search_obj(table_t *temp, haddr_t objno);
+H5TOOLS_DLL obj_t *search_obj(table_t *temp, const H5O_token_t *obj_token);
#ifndef H5_HAVE_TMPFILE
H5TOOLS_DLL FILE *tmpfile(void);
#endif
@@ -158,9 +159,9 @@ typedef struct {
H5O_type_t trg_type; /* OUT: target type */
char *trg_path; /* OUT: target obj path. This must be freed
* when used with H5tools_get_symlink_info() */
- haddr_t objno; /* OUT: target object address */
+ H5O_token_t obj_token; /* OUT: target object token */
unsigned long fileno; /* OUT: File number that target object is located in */
- H5L_info_t linfo; /* OUT: link info */
+ H5L_info2_t linfo; /* OUT: link info */
h5tool_opt_t opt; /* IN: options */
} h5tool_link_info_t;
diff --git a/tools/lib/h5trav.c b/tools/lib/h5trav.c
index fb768a4..dc7e27d 100644
--- a/tools/lib/h5trav.c
+++ b/tools/lib/h5trav.c
@@ -21,7 +21,7 @@
*-------------------------------------------------------------------------
*/
typedef struct trav_addr_path_t {
- haddr_t addr;
+ H5O_token_t token;
char *path;
} trav_addr_path_t;
@@ -43,7 +43,7 @@ typedef struct {
hbool_t is_absolute; /* Whether the traversal has absolute paths */
const char *base_grp_name; /* Name of the group that serves as the base
* for iteration */
- unsigned fields; /* Fields needed in H5O_info_t struct */
+ unsigned fields; /* Fields needed in H5O_info2_t struct */
} trav_ud_traverse_t;
typedef struct {
@@ -65,10 +65,10 @@ typedef struct trav_path_op_data_t {
*/
static void trav_table_add(trav_table_t *table,
const char *objname,
- const H5O_info_t *oinfo);
+ const H5O_info2_t *oinfo);
static void trav_table_addlink(trav_table_t *table,
- haddr_t objno,
+ const H5O_token_t *obj_token,
const char *path);
/*-------------------------------------------------------------------------
@@ -116,15 +116,15 @@ h5trav_set_verbose(int print_verbose)
/*-------------------------------------------------------------------------
- * Function: trav_addr_add
+ * Function: trav_token_add
*
- * Purpose: Add a hardlink address to visited data structure
+ * Purpose: Add an object token to visited data structure
*
* Return: void
*-------------------------------------------------------------------------
*/
static void
-trav_addr_add(trav_addr_t *visited, haddr_t addr, const char *path)
+trav_token_add(trav_addr_t *visited, H5O_token_t *token, const char *path)
{
size_t idx; /* Index of address to use */
@@ -136,33 +136,37 @@ trav_addr_add(trav_addr_t *visited, haddr_t addr, const char *path)
/* Append it */
idx = visited->nused++;
- visited->objs[idx].addr = addr;
+ HDmemcpy(&visited->objs[idx].token, token, sizeof(H5O_token_t));
visited->objs[idx].path = HDstrdup(path);
-} /* end trav_addr_add() */
+} /* end trav_token_add() */
/*-------------------------------------------------------------------------
- * Function: trav_addr_visited
+ * Function: trav_token_visited
*
- * Purpose: Check if an address has already been visited
+ * Purpose: Check if an object token has already been seen
*
* Return: TRUE/FALSE
*-------------------------------------------------------------------------
*/
H5_ATTR_PURE static const char *
-trav_addr_visited(trav_addr_t *visited, haddr_t addr)
+trav_token_visited(hid_t loc_id, trav_addr_t *visited, H5O_token_t *token)
{
size_t u; /* Local index variable */
+ int token_cmp;
/* Look for address */
- for(u = 0; u < visited->nused; u++)
+ for(u = 0; u < visited->nused; u++) {
/* Check for address already in array */
- if(visited->objs[u].addr == addr)
+ if(H5Otoken_cmp(loc_id, &visited->objs[u].token, token, &token_cmp) < 0)
+ return NULL;
+ if(!token_cmp)
return(visited->objs[u].path);
+ }
- /* Didn't find address */
+ /* Didn't find object token */
return(NULL);
-} /* end trav_addr_visited() */
+} /* end trav_token_visited() */
/*-------------------------------------------------------------------------
@@ -172,7 +176,7 @@ trav_addr_visited(trav_addr_t *visited, haddr_t addr)
*-------------------------------------------------------------------------
*/
static herr_t
-traverse_cb(hid_t loc_id, const char *path, const H5L_info_t *linfo,
+traverse_cb(hid_t loc_id, const char *path, const H5L_info2_t *linfo,
void *_udata)
{
trav_ud_traverse_t *udata = (trav_ud_traverse_t *)_udata; /* User data */
@@ -199,10 +203,10 @@ traverse_cb(hid_t loc_id, const char *path, const H5L_info_t *linfo,
/* Perform the correct action for different types of links */
if(linfo->type == H5L_TYPE_HARD) {
- H5O_info_t oinfo;
+ H5O_info2_t oinfo;
/* Get information about the object */
- if(H5Oget_info_by_name2(loc_id, path, &oinfo, udata->fields, H5P_DEFAULT) < 0) {
+ if(H5Oget_info_by_name3(loc_id, path, &oinfo, udata->fields, H5P_DEFAULT) < 0) {
if(new_name)
HDfree(new_name);
return(H5_ITER_ERROR);
@@ -212,8 +216,8 @@ traverse_cb(hid_t loc_id, const char *path, const H5L_info_t *linfo,
* already visited, if it isn't there already
*/
if(oinfo.rc > 1)
- if(NULL == (already_visited = trav_addr_visited(udata->seen, oinfo.addr)))
- trav_addr_add(udata->seen, oinfo.addr, full_name);
+ if(NULL == (already_visited = trav_token_visited(loc_id, udata->seen, &oinfo.token)))
+ trav_token_add(udata->seen, &oinfo.token, full_name);
/* Make 'visit object' callback */
if(udata->visitor->visit_obj)
@@ -254,11 +258,11 @@ static int
traverse(hid_t file_id, const char *grp_name, hbool_t visit_start,
hbool_t recurse, const trav_visitor_t *visitor, unsigned fields)
{
- H5O_info_t oinfo; /* Object info for starting group */
+ H5O_info2_t oinfo; /* Object info for starting group */
int ret_value = 0;
/* Get info for starting object */
- if(H5Oget_info_by_name2(file_id, grp_name, &oinfo, fields, H5P_DEFAULT) < 0)
+ if(H5Oget_info_by_name3(file_id, grp_name, &oinfo, fields, H5P_DEFAULT) < 0)
H5TOOLS_GOTO_ERROR((-1), "H5Oget_info_by_name failed");
/* Visit the starting object */
@@ -276,7 +280,7 @@ traverse(hid_t file_id, const char *grp_name, hbool_t visit_start,
/* Check for multiple links to top group */
if(oinfo.rc > 1)
- trav_addr_add(&seen, oinfo.addr, grp_name);
+ trav_token_add(&seen, &oinfo.token, grp_name);
/* Set up user data structure */
udata.seen = &seen;
@@ -288,12 +292,12 @@ traverse(hid_t file_id, const char *grp_name, hbool_t visit_start,
/* Check for iteration of links vs. visiting all links recursively */
if(recurse) {
/* Visit all links in group, recursively */
- if(H5Lvisit_by_name(file_id, grp_name, trav_index_by, trav_index_order, traverse_cb, &udata, H5P_DEFAULT) < 0)
+ if(H5Lvisit_by_name2(file_id, grp_name, trav_index_by, trav_index_order, traverse_cb, &udata, H5P_DEFAULT) < 0)
H5TOOLS_GOTO_ERROR((-1), "H5Lvisit_by_name failed");
} /* end if */
else {
/* Iterate over links in group */
- if(H5Literate_by_name(file_id, grp_name, trav_index_by, trav_index_order, NULL, traverse_cb, &udata, H5P_DEFAULT) < 0)
+ if(H5Literate_by_name2(file_id, grp_name, trav_index_by, trav_index_order, NULL, traverse_cb, &udata, H5P_DEFAULT) < 0)
H5TOOLS_GOTO_ERROR((-1), "H5Literate_by_name failed");
} /* end else */
@@ -338,7 +342,9 @@ trav_info_add(trav_info_t *info, const char *path, h5trav_type_t obj_type)
info->paths[idx].path = HDstrdup(path);
info->paths[idx].type = obj_type;
info->paths[idx].fileno = 0;
- info->paths[idx].objno = HADDR_UNDEF;
+
+ /* Set token to 'undefined' values */
+ info->paths[idx].obj_token = H5O_TOKEN_UNDEF;
}
} /* end trav_info_add() */
@@ -354,15 +360,15 @@ trav_info_add(trav_info_t *info, const char *path, h5trav_type_t obj_type)
void
trav_fileinfo_add(trav_info_t *info, hid_t loc_id)
{
- H5O_info_t oinfo;
+ H5O_info2_t oinfo;
size_t idx = info->nused - 1;
- if ( info->paths[idx].path && HDstrcmp(info->paths[idx].path, "."))
- H5Oget_info_by_name2(loc_id, info->paths[idx].path, &oinfo, H5O_INFO_BASIC, H5P_DEFAULT);
+ if(info->paths[idx].path && HDstrcmp(info->paths[idx].path, "."))
+ H5Oget_info_by_name3(loc_id, info->paths[idx].path, &oinfo, H5O_INFO_BASIC, H5P_DEFAULT);
else
- H5Oget_info2(loc_id, &oinfo, H5O_INFO_BASIC);
+ H5Oget_info3(loc_id, &oinfo, H5O_INFO_BASIC);
- info->paths[idx].objno = oinfo.addr;
+ HDmemcpy(&info->paths[idx].obj_token, &oinfo.token, sizeof(H5O_token_t));
info->paths[idx].fileno = oinfo.fileno;
} /* end trav_fileinfo_add() */
@@ -377,7 +383,7 @@ trav_fileinfo_add(trav_info_t *info, hid_t loc_id)
*-------------------------------------------------------------------------
*/
int
-trav_info_visit_obj(const char *path, const H5O_info_t *oinfo,
+trav_info_visit_obj(const char *path, const H5O_info2_t *oinfo,
const char H5_ATTR_UNUSED *already_visited, void *udata)
{
size_t idx;
@@ -390,7 +396,7 @@ trav_info_visit_obj(const char *path, const H5O_info_t *oinfo,
/* set object addr and fileno. These are for checking same object */
info_p = (trav_info_t *) udata;
idx = info_p->nused - 1;
- info_p->paths[idx].objno = oinfo->addr;
+ HDmemcpy(&info_p->paths[idx].obj_token, &oinfo->token, sizeof(H5O_token_t));
info_p->paths[idx].fileno = oinfo->fileno;
return(0);
@@ -407,7 +413,7 @@ trav_info_visit_obj(const char *path, const H5O_info_t *oinfo,
*-------------------------------------------------------------------------
*/
int
-trav_info_visit_lnk(const char *path, const H5L_info_t *linfo, void *udata)
+trav_info_visit_lnk(const char *path, const H5L_info2_t *linfo, void *udata)
{
/* Add the link to the 'info' struct */
trav_info_add((trav_info_t *)udata, path, ((linfo->type == H5L_TYPE_SOFT) ? H5TRAV_TYPE_LINK : H5TRAV_TYPE_UDLINK));
@@ -547,7 +553,7 @@ trav_info_free(trav_info_t *info)
*-------------------------------------------------------------------------
*/
static int
-trav_table_visit_obj(const char *path, const H5O_info_t *oinfo,
+trav_table_visit_obj(const char *path, const H5O_info2_t *oinfo,
const char *already_visited, void *udata)
{
trav_table_t *table = (trav_table_t *)udata;
@@ -558,7 +564,7 @@ trav_table_visit_obj(const char *path, const H5O_info_t *oinfo,
trav_table_add(table, path, oinfo);
else
/* Add alias for object to table */
- trav_table_addlink(table, oinfo->addr, path);
+ trav_table_addlink(table, &oinfo->token, path);
return 0;
} /* end trav_table_visit_obj() */
@@ -574,7 +580,7 @@ trav_table_visit_obj(const char *path, const H5O_info_t *oinfo,
*-------------------------------------------------------------------------
*/
static int
-trav_table_visit_lnk(const char *path, const H5L_info_t H5_ATTR_UNUSED *linfo, void *udata)
+trav_table_visit_lnk(const char *path, const H5L_info2_t H5_ATTR_UNUSED *linfo, void *udata)
{
/* Add the link to the 'table' struct */
trav_table_add((trav_table_t *)udata, path, NULL);
@@ -663,9 +669,7 @@ h5trav_getindext(const char *name, const trav_table_t *table)
*-------------------------------------------------------------------------
*/
static void
-trav_table_add(trav_table_t *table,
- const char *path,
- const H5O_info_t *oinfo)
+trav_table_add(trav_table_t *table, const char *path, const H5O_info2_t *oinfo)
{
size_t new_obj;
@@ -676,7 +680,11 @@ trav_table_add(trav_table_t *table,
} /* end if */
new_obj = table->nobjs++;
- table->objs[new_obj].objno = oinfo ? oinfo->addr : HADDR_UNDEF;
+ if(oinfo)
+ HDmemcpy(&table->objs[new_obj].obj_token, &oinfo->token, sizeof(H5O_token_t));
+ else
+ /* Set token to 'undefined' values */
+ table->objs[new_obj].obj_token = H5O_TOKEN_UNDEF;
table->objs[new_obj].flags[0] = table->objs[new_obj].flags[1] = 0;
table->objs[new_obj].is_same_trgobj = 0;
table->objs[new_obj].name = (char *)HDstrdup(path);
@@ -696,13 +704,16 @@ trav_table_add(trav_table_t *table,
*-------------------------------------------------------------------------
*/
static void
-trav_table_addlink(trav_table_t *table, haddr_t objno, const char *path)
+trav_table_addlink(trav_table_t *table, const H5O_token_t *obj_token, const char *path)
{
size_t i; /* Local index variable */
+ int token_cmp;
if(table) {
for(i = 0; i < table->nobjs; i++) {
- if(table->objs[i].objno == objno) {
+ if(H5Otoken_cmp(table->fid, &table->objs[i].obj_token, obj_token, &token_cmp) < 0)
+ return;
+ if(!token_cmp) {
size_t n;
/* already inserted? */
@@ -720,9 +731,9 @@ trav_table_addlink(trav_table_t *table, haddr_t objno, const char *path)
table->objs[i].links[n].new_name = (char *)HDstrdup(path);
return;
- } /* end for */
+ } /* end if */
} /* end for */
- }
+ } /* end if */
}
@@ -748,7 +759,10 @@ void trav_table_addflags(unsigned *flags,
} /* end if */
new_obj = table->nobjs++;
- table->objs[new_obj].objno = 0;
+
+ /* Set token to 'undefined' values */
+ table->objs[new_obj].obj_token = H5O_TOKEN_UNDEF;
+
table->objs[new_obj].flags[0] = flags[0];
table->objs[new_obj].flags[1] = flags[1];
table->objs[new_obj].is_same_trgobj = 0;
@@ -769,10 +783,11 @@ void trav_table_addflags(unsigned *flags,
* Return: void
*-------------------------------------------------------------------------
*/
-void trav_table_init(trav_table_t **tbl)
+void trav_table_init(hid_t fid, trav_table_t **tbl)
{
trav_table_t* table = (trav_table_t*) HDmalloc(sizeof(trav_table_t));
if(table) {
+ table->fid = fid;
table->size = 0;
table->nobjs = 0;
table->objs = NULL;
@@ -893,8 +908,8 @@ trav_attr(hid_t
*-------------------------------------------------------------------------
*/
static int
-trav_print_visit_obj(const char *path, const H5O_info_t *oinfo,
- const char *already_visited, void *udata)
+trav_print_visit_obj(const char *path, const H5O_info2_t *oinfo,
+ const char *already_visited, void *udata)
{
trav_print_udata_t *print_udata = (trav_print_udata_t *)udata;
/* Print the name of the object */
@@ -951,7 +966,7 @@ trav_print_visit_obj(const char *path, const H5O_info_t *oinfo,
*-------------------------------------------------------------------------
*/
static int
-trav_print_visit_lnk(const char *path, const H5L_info_t *linfo, void *udata)
+trav_print_visit_lnk(const char *path, const H5L_info2_t *linfo, void *udata)
{
trav_print_udata_t *print_udata = (trav_print_udata_t *)udata;
diff --git a/tools/lib/h5trav.h b/tools/lib/h5trav.h
index a1d33b7..88473ad 100644
--- a/tools/lib/h5trav.h
+++ b/tools/lib/h5trav.h
@@ -17,9 +17,9 @@
#include "hdf5.h"
/* Typedefs for visiting objects */
-typedef herr_t (*h5trav_obj_func_t)(const char *path_name, const H5O_info_t *oinfo,
+typedef herr_t (*h5trav_obj_func_t)(const char *path_name, const H5O_info2_t *oinfo,
const char *first_seen, void *udata);
-typedef herr_t (*h5trav_lnk_func_t)(const char *path_name, const H5L_info_t *linfo,
+typedef herr_t (*h5trav_lnk_func_t)(const char *path_name, const H5L_info2_t *linfo,
void *udata);
/*-------------------------------------------------------------------------
@@ -65,7 +65,7 @@ typedef struct symlink_trav_t {
typedef struct trav_path_t {
char *path;
h5trav_type_t type;
- haddr_t objno; /* object address */
+ H5O_token_t obj_token; /* object token */
unsigned long fileno; /* File number that object is located in */
} trav_path_t;
@@ -95,7 +95,7 @@ typedef struct trav_link_t {
*/
typedef struct trav_obj_t {
- haddr_t objno; /* object address */
+ H5O_token_t obj_token; /* object token */
unsigned flags[2]; /* h5diff.object is present or not in both files*/
hbool_t is_same_trgobj; /* same target object? no need to compare */
char *name; /* name */
@@ -112,6 +112,7 @@ typedef struct trav_obj_t {
*/
typedef struct trav_table_t {
+ hid_t fid;
size_t size;
size_t nobjs;
trav_obj_t *objs;
@@ -144,8 +145,8 @@ H5TOOLS_DLL hbool_t symlink_is_visited(symlink_trav_t *visited, H5L_type_t type,
*/
H5TOOLS_DLL int h5trav_getinfo(hid_t file_id, trav_info_t *info);
H5TOOLS_DLL ssize_t h5trav_getindex(const trav_info_t *info, const char *obj);
-H5TOOLS_DLL int trav_info_visit_obj (const char *path, const H5O_info_t *oinfo, const char *already_visited, void *udata);
-H5TOOLS_DLL int trav_info_visit_lnk (const char *path, const H5L_info_t *linfo, void *udata);
+H5TOOLS_DLL int trav_info_visit_obj(const char *path, const H5O_info2_t *oinfo, const char *already_visited, void *udata);
+H5TOOLS_DLL int trav_info_visit_lnk(const char *path, const H5L_info2_t *linfo, void *udata);
/*-------------------------------------------------------------------------
* "h5trav table" public functions
@@ -184,7 +185,7 @@ H5TOOLS_DLL void trav_fileinfo_add(trav_info_t *info, hid_t loc_id);
*-------------------------------------------------------------------------
*/
-H5TOOLS_DLL void trav_table_init(trav_table_t **table);
+H5TOOLS_DLL void trav_table_init(hid_t fid, trav_table_t **table);
H5TOOLS_DLL void trav_table_free(trav_table_t *table);