diff options
author | Pedro Vicente Nunes <pvn@hdfgroup.org> | 2006-11-08 21:24:41 (GMT) |
---|---|---|
committer | Pedro Vicente Nunes <pvn@hdfgroup.org> | 2006-11-08 21:24:41 (GMT) |
commit | 89cca34b9763e12a73a86164306d5ffbede28f64 (patch) | |
tree | 1822cc905222f9e4dd557ae4ac0de1608dcd33f5 | |
parent | a9350e86f0a04cc1f6aba59849063d4acfa1be7b (diff) | |
download | hdf5-89cca34b9763e12a73a86164306d5ffbede28f64.zip hdf5-89cca34b9763e12a73a86164306d5ffbede28f64.tar.gz hdf5-89cca34b9763e12a73a86164306d5ffbede28f64.tar.bz2 |
[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
-rw-r--r-- | tools/h5dump/h5dumpgentest.c | 3 | ||||
-rw-r--r-- | tools/lib/h5tools_utils.c | 20 | ||||
-rw-r--r-- | tools/testfiles/thlink-1.ddl | 3 | ||||
-rw-r--r-- | tools/testfiles/thlink-1.ls | 1 | ||||
-rw-r--r-- | tools/testfiles/thlink.h5 | bin | 3332 -> 5536 bytes | |||
-rw-r--r-- | 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 Binary files differindex 678446e..6e0e7e1 100644 --- a/tools/testfiles/thlink.h5 +++ b/tools/testfiles/thlink.h5 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' ############################# <?xml version="1.0" encoding="UTF-8"?> <hdf5:HDF5-File xmlns:hdf5="http://hdf.ncsa.uiuc.edu/DTDs/HDF5-File" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://hdf.ncsa.uiuc.edu/DTDs/HDF5File http://hdf.ncsa.uiuc.edu/DTDs/HDF5-File.xsd"> -<hdf5:RootGroup OBJ-XID="xid_696" H5Path="/"> - <hdf5:Dataset Name="dset1" OBJ-XID="xid_744" H5Path= "/dset1" Parents="xid_696" H5ParentPaths="/"> +<hdf5:RootGroup OBJ-XID="xid_96" H5Path="/"> + <hdf5:Dataset Name="dset1" OBJ-XID="xid_808" H5Path= "/dset1" Parents="xid_96" H5ParentPaths="/"> <hdf5:StorageLayout> <hdf5:ContiguousLayout/> </hdf5:StorageLayout> @@ -29,18 +29,21 @@ Expected output for 'h5dump --xml thlink.h5' </hdf5:DataFromFile> </hdf5:Data> </hdf5:Dataset> - <hdf5:Group Name="g1" OBJ-XID="xid_1804" H5Path="/g1" Parents="xid_696" H5ParentPaths="/" > - <hdf5:Dataset Name="dset2" OBJ-XID="xid_744-1" H5Path="/g1/dset2" Parents="xid_1804" H5ParentPaths="/g1"> - <hdf5:DatasetPtr OBJ-XID="xid_744" H5Path="/g1/dset2"/> + <hdf5:Group Name="g1" OBJ-XID="xid_1408" H5Path="/g1" Parents="xid_96" H5ParentPaths="/" > + <hdf5:Dataset Name="dset2" OBJ-XID="xid_808-1" H5Path="/g1/dset2" Parents="xid_1408" H5ParentPaths="/g1"> + <hdf5:DatasetPtr OBJ-XID="xid_808" H5Path="/g1/dset2"/> </hdf5:Dataset> - <hdf5:Group Name="g1.1" OBJ-XID="xid_2780" H5Path="/g1/g1.1" Parents="xid_1804" H5ParentPaths="/g1" > - <hdf5:Dataset Name="dset3" OBJ-XID="xid_744-2" H5Path="/g1/g1.1/dset3" Parents="xid_2780" H5ParentPaths="/g1/g1.1"> - <hdf5:DatasetPtr OBJ-XID="xid_744" H5Path="/g1/g1.1/dset3"/> + <hdf5:Group Name="g1.1" OBJ-XID="xid_2000" H5Path="/g1/g1.1" Parents="xid_1408" H5ParentPaths="/g1" > + <hdf5:Dataset Name="dset3" OBJ-XID="xid_808-2" H5Path="/g1/g1.1/dset3" Parents="xid_2000" H5ParentPaths="/g1/g1.1"> + <hdf5:DatasetPtr OBJ-XID="xid_808" H5Path="/g1/g1.1/dset3"/> </hdf5:Dataset> </hdf5:Group> </hdf5:Group> - <hdf5:Group Name="g2" OBJ-XID="xid_2780-3" H5Path="/g1/g1.1" Parents="xid_696" H5ParentPaths="/"> - <hdf5:GroupPtr OBJ-XID="xid_2780" H5Path="/g1/g1.1" Parents="xid_696" H5ParentPaths="/" /> + <hdf5:Group Name="g2" OBJ-XID="xid_2000-3" H5Path="/g1/g1.1" Parents="xid_96" H5ParentPaths="/"> + <hdf5:GroupPtr OBJ-XID="xid_2000" H5Path="/g1/g1.1" Parents="xid_96" H5ParentPaths="/" /> + </hdf5:Group> + <hdf5:Group Name="g3" OBJ-XID="xid_96-4" H5Path="/" Parents="xid_96" H5ParentPaths="/"> + <hdf5:GroupPtr OBJ-XID="xid_96" H5Path="/" Parents="xid_96" H5ParentPaths="/" /> </hdf5:Group> </hdf5:RootGroup> </hdf5:HDF5-File> |