From 89cca34b9763e12a73a86164306d5ffbede28f64 Mon Sep 17 00:00:00 2001 From: Pedro Vicente Nunes Date: Wed, 8 Nov 2006 16:24:41 -0500 Subject: [svn-r12883] h5dump bug 701. Symptom: The creation of a hardlink pointing to the root group "/" causes h5dump to display it as a link pointing to itself. Cure: the root group was not being inserted in the table that keeps track of object names and links. Added a test for this in the test generation program, the creation of a hardlink to the root --- tools/h5dump/h5dumpgentest.c | 3 +++ tools/lib/h5tools_utils.c | 20 ++++++++++++++++++++ tools/testfiles/thlink-1.ddl | 3 +++ tools/testfiles/thlink-1.ls | 1 + tools/testfiles/thlink.h5 | Bin 3332 -> 5536 bytes tools/testfiles/thlink.h5.xml | 23 +++++++++++++---------- 6 files changed, 40 insertions(+), 10 deletions(-) diff --git a/tools/h5dump/h5dumpgentest.c b/tools/h5dump/h5dumpgentest.c index e6454a8..463f718 100644 --- a/tools/h5dump/h5dumpgentest.c +++ b/tools/h5dump/h5dumpgentest.c @@ -474,6 +474,9 @@ static void gent_hardlink(void) group = H5Gopen(fid, "/g1"); H5Glink (group, H5L_TYPE_HARD, "/g2", "g1.1"); H5Gclose(group); + + /* create a link to the root group */ + H5Glink (fid, H5L_TYPE_HARD, "/", "g3"); H5Fclose(fid); } diff --git a/tools/lib/h5tools_utils.c b/tools/lib/h5tools_utils.c index c1fa292..3dbafa5 100644 --- a/tools/lib/h5tools_utils.c +++ b/tools/lib/h5tools_utils.c @@ -600,6 +600,26 @@ init_objs(hid_t fid, find_objs_t *info, table_t **group_table, info->type_table = *type_table; info->dset_table = *dset_table; + { + /* add the root group as an object, it may have hard links to it */ + + H5G_stat_t statbuf; + haddr_t objno; /* compact form of object's location */ + char* tmp; + + if(H5Gget_objinfo(fid, "/", FALSE, &statbuf) < 0) + return FAIL; + else + { + objno = (haddr_t)statbuf.objno[0] | ((haddr_t)statbuf.objno[1] << (8 * sizeof(long))); + /* call with an empty string, it appends group separator */ + tmp = build_obj_path_name(info->prefix, ""); + add_obj(info->group_table, objno, tmp, TRUE); + } + } + + + /* Find all shared objects */ return(H5Giterate(fid, "/", NULL, find_objs_cb, (void *)info)); } diff --git a/tools/testfiles/thlink-1.ddl b/tools/testfiles/thlink-1.ddl index 4f50e80..c913201 100644 --- a/tools/testfiles/thlink-1.ddl +++ b/tools/testfiles/thlink-1.ddl @@ -23,5 +23,8 @@ GROUP "/" { GROUP "g2" { HARDLINK "/g1/g1.1" } + GROUP "g3" { + HARDLINK "/" + } } } diff --git a/tools/testfiles/thlink-1.ls b/tools/testfiles/thlink-1.ls index 5c9d408..01839bf 100644 --- a/tools/testfiles/thlink-1.ls +++ b/tools/testfiles/thlink-1.ls @@ -4,3 +4,4 @@ dset1 Dataset {5} g1 Group g2 Group +g3 Group, same as / diff --git a/tools/testfiles/thlink.h5 b/tools/testfiles/thlink.h5 index 678446e..6e0e7e1 100644 Binary files a/tools/testfiles/thlink.h5 and b/tools/testfiles/thlink.h5 differ diff --git a/tools/testfiles/thlink.h5.xml b/tools/testfiles/thlink.h5.xml index 4455d1b..ded8716 100644 --- a/tools/testfiles/thlink.h5.xml +++ b/tools/testfiles/thlink.h5.xml @@ -3,8 +3,8 @@ Expected output for 'h5dump --xml thlink.h5' ############################# - - + + @@ -29,18 +29,21 @@ Expected output for 'h5dump --xml thlink.h5' - - - + + + - - - + + + - - + + + + + -- cgit v0.12