diff options
author | Neil Fortner <nfortne2@hdfgroup.org> | 2008-10-07 14:54:26 (GMT) |
---|---|---|
committer | Neil Fortner <nfortne2@hdfgroup.org> | 2008-10-07 14:54:26 (GMT) |
commit | 698a6d8845964de3e8eb3d9de5569a9c88154e5e (patch) | |
tree | 5ec676c92adfaad56fbe90e851819fa409701d7c /tools/h5ls | |
parent | c05f2a85a3f2b892b77a8799219866605493e9aa (diff) | |
download | hdf5-698a6d8845964de3e8eb3d9de5569a9c88154e5e.zip hdf5-698a6d8845964de3e8eb3d9de5569a9c88154e5e.tar.gz hdf5-698a6d8845964de3e8eb3d9de5569a9c88154e5e.tar.bz2 |
[svn-r15804] Purpose: Add option to h5ls to enable external link traversal.
Description: Added -E option to h5ls. When set, this alows h5ls to enter
external files (currently only through an external link). The -r option by
itself will no longer allow h5ls to traverse external links.
Tested: kagiso, linew, smirom (h5committest)
Diffstat (limited to 'tools/h5ls')
-rw-r--r-- | tools/h5ls/h5ls.c | 24 | ||||
-rwxr-xr-x | tools/h5ls/testh5ls.sh | 10 |
2 files changed, 29 insertions, 5 deletions
diff --git a/tools/h5ls/h5ls.c b/tools/h5ls/h5ls.c index 7850a59..c5ff96e 100644 --- a/tools/h5ls/h5ls.c +++ b/tools/h5ls/h5ls.c @@ -61,6 +61,7 @@ static hbool_t label_g = FALSE; /* label compound values? */ static hbool_t string_g = FALSE; /* print 1-byte numbers as ASCII? */ static hbool_t fullname_g = FALSE; /* print full path names */ static hbool_t recursive_g = FALSE; /* recursive descent listing */ +static hbool_t follow_elink_g = FALSE; /* follow external links */ static hbool_t grp_literal_g = FALSE; /* list group, not contents */ static hbool_t hexdump_g = FALSE; /* show data as raw hexadecimal */ static hbool_t show_errors_g = FALSE; /* print HDF5 error messages */ @@ -115,6 +116,7 @@ usage: %s [OPTIONS] [OBJECTS...]\n\ -a, --address Print addresses for raw data\n\ -d, --data Print the values of datasets\n\ -e, --errors Show all HDF5 error reporting\n\ + -E, --external Allow traversal into external files\n\ -f, --full Print full path names instead of base names\n\ -g, --group Show information about a group, not its contents\n\ -l, --label Label members of compound datasets\n\ @@ -1906,10 +1908,14 @@ list_lnk(const char *name, const H5L_info_t *linfo, void *_iter) if(*path != '/') HDfputc('/', stdout); HDfputs(path, stdout); - HDfputs("} ", stdout); + HDfputc('}', stdout); /* Recurse through the external link */ - if(recursive_g) { + if(follow_elink_g) { + hbool_t orig_grp_literal = grp_literal_g; + + HDfputc(' ', stdout); + /* Check if we have already seen this elink */ if(elink_trav_visited(iter->elink_list, filename, path)) { HDfputs("{Already Visited}\n", stdout); @@ -1927,11 +1933,19 @@ list_lnk(const char *name, const H5L_info_t *linfo, void *_iter) * target of an external link */ iter->ext_target = TRUE; + /* Prevent recursive listing of external link target if + * recursive_g is off */ + if(!recursive_g) + grp_literal_g = TRUE; + /* Recurse through the external link */ if(visit_obj(iter->fid, name, iter) < 0) { HDfree(buf); + grp_literal_g = orig_grp_literal; goto done; } + + grp_literal_g = orig_grp_literal; } else HDfputc('\n', stdout); @@ -2174,6 +2188,8 @@ main(int argc, const char *argv[]) data_g = TRUE; } else if(!HDstrcmp(argv[argno], "--errors")) { show_errors_g = TRUE; + } else if(!HDstrcmp(argv[argno], "--external")) { + follow_elink_g = TRUE; } else if(!HDstrcmp(argv[argno], "--full")) { fullname_g = TRUE; } else if(!HDstrcmp(argv[argno], "--group")) { @@ -2255,6 +2271,10 @@ main(int argc, const char *argv[]) show_errors_g = TRUE; break; + case 'E': /* --external */ + follow_elink_g = TRUE; + break; + case 'f': /* --full */ fullname_g = TRUE; break; diff --git a/tools/h5ls/testh5ls.sh b/tools/h5ls/testh5ls.sh index 498384c..0bae60b 100755 --- a/tools/h5ls/testh5ls.sh +++ b/tools/h5ls/testh5ls.sh @@ -129,9 +129,13 @@ TOOLTEST tslink-1.ls 0 -w80 -r tslink.h5 # test for displaying external and user-defined links TOOLTEST textlink-1.ls 0 -w80 -r textlink.h5 -TOOLTEST textlinksrc-1.ls 0 -w80 -r textlinksrc.h5 -TOOLTEST textlinksrc-2.ls 0 -w80 -rv textlinksrc.h5/ext_link5 -TOOLTEST textlinksrc-3.ls 0 -w80 -r textlinksrc.h5/ext_link1 +TOOLTEST textlinksrc-1.ls 0 -w80 -Er textlinksrc.h5 +TOOLTEST textlinksrc-2.ls 0 -w80 -Erv textlinksrc.h5/ext_link5 +TOOLTEST textlinksrc-3.ls 0 -w80 -Er textlinksrc.h5/ext_link1 +TOOLTEST textlinksrc-4.ls 0 -w80 -r textlinksrc.h5 +TOOLTEST textlinksrc-5.ls 0 -w80 -r textlinksrc.h5/ext_link1 +TOOLTEST textlinksrc-6.ls 0 -w80 -E textlinksrc.h5 +TOOLTEST textlinksrc-7.ls 0 -w80 -E textlinksrc.h5/ext_link1 TOOLTEST tudlink-1.ls 0 -w80 -r tudlink.h5 # tests for hard links |