summaryrefslogtreecommitdiffstats
path: root/tools
diff options
context:
space:
mode:
authorraylu-hdf <60487644+raylu-hdf@users.noreply.github.com>2022-05-05 20:33:47 (GMT)
committerGitHub <noreply@github.com>2022-05-05 20:33:47 (GMT)
commit0566defd2c7b48fd3b07e5d626f8069c1131f917 (patch)
tree41a14d8c85fba9608020bbbd7209126c2db56d22 /tools
parent93f65cc6130a21c84860eeb77819671254533ae4 (diff)
downloadhdf5-0566defd2c7b48fd3b07e5d626f8069c1131f917.zip
hdf5-0566defd2c7b48fd3b07e5d626f8069c1131f917.tar.gz
hdf5-0566defd2c7b48fd3b07e5d626f8069c1131f917.tar.bz2
Added the support to get the revision count for the onion file into the h5dump. (#1726)
* Removes unused definitions from module headers (#1624) * Fix these Doxygen warnings #1581 (#1589) * Fixes a typo in H5.c (#1639) * free MPI_Group/MPI_Comm/MPI_Datatype objects (#1638) * free MPI_Group/MPI_Comm/MPI_Datatype objects * fix clang-format style * Adds build and license shields to README.md (#1641) * First stab at a Github status bar * Adds a .tokeignore file for counting lines of code accurately * Yanks lines of code calculation since it wildly overcounts * not depend on doIO to free an MPI_Comm object (#1642) * free MPI datatypes previously created (#1637) * Retrieve MPI-IO hints used by MPI library after file open (#1636) H5Pget_fapl_mpio() should return an MPI info object containing all the MPI-IO hints used by the MPI library underneath, after the file is opened. Some hints, such as cb_nodes (number of I/O aggregators), are useful for HDF5 applications and I/O libraries built on top of HDF5. * OESS-168: Remove clang warnings. (#1309) * OESS-168: Remove clang warnings. * OESS-168: Address @lrknox review. * OESS-168: Remove clang warnings. (#1376) * Added the support to get the revision count for the onion file into the h5dump. * Committing clang-format changes * Changed the function from H5FDget_onion_revision_count to H5FDonion_get_revision_count for better name. * Fixed compiler warnings. Co-authored-by: Dana Robinson <43805+derobins@users.noreply.github.com> Co-authored-by: Allen Byrne <50328838+byrnHDF@users.noreply.github.com> Co-authored-by: Wei-keng Liao <wkliao@users.noreply.github.com> Co-authored-by: H. Joe Lee <hyoklee@hdfgroup.org> Co-authored-by: github-actions <41898282+github-actions[bot]@users.noreply.github.com>
Diffstat (limited to 'tools')
-rw-r--r--tools/src/h5dump/h5dump.c44
-rw-r--r--tools/test/h5dump/testh5dump.sh.in2
2 files changed, 31 insertions, 15 deletions
diff --git a/tools/src/h5dump/h5dump.c b/tools/src/h5dump/h5dump.c
index 29e2158..a82dbb2 100644
--- a/tools/src/h5dump/h5dump.c
+++ b/tools/src/h5dump/h5dump.c
@@ -23,8 +23,10 @@ static hbool_t doxml_g = FALSE;
static hbool_t useschema_g = TRUE;
static const char *xml_dtd_uri_g = NULL;
-static hbool_t use_custom_vol_g = FALSE;
-static hbool_t use_custom_vfd_g = FALSE;
+static hbool_t use_custom_vol_g = FALSE;
+static hbool_t use_custom_vfd_g = FALSE;
+static hbool_t get_onion_revision_count = FALSE;
+
static h5tools_vol_info_t vol_info_g;
static h5tools_vfd_info_t vfd_info_g;
@@ -1315,16 +1317,18 @@ end_collect:
/* Copy the VFD driver info for the input file if it's the onion file */
if (vfd_info_g.u.name) {
if (!HDstrcmp(vfd_info_g.u.name, "onion")) {
- if (vfd_info_g.info)
- onion_fa_g.revision_num = HDatoi((char *)(vfd_info_g.info));
- else
- onion_fa_g.revision_num = 0;
+ onion_fa_g.revision_num = 0;
- HDprintf("Using revision %" PRIu64 "\n", onion_fa_g.revision_num);
+ if (vfd_info_g.info) {
+ if (!HDstrcmp(vfd_info_g.info, "revision_count"))
+ get_onion_revision_count = TRUE;
+ else {
+ onion_fa_g.revision_num = HDstrtoull((const char *)(vfd_info_g.info), NULL, 0);
+ HDprintf("Using revision %" PRIu64 "\n", onion_fa_g.revision_num);
+ }
+ }
- /* Need to free this memory */
- vfd_info_g.info = HDmalloc(sizeof(H5FD_onion_fapl_info_t));
- HDmemcpy(vfd_info_g.info, &onion_fa_g, sizeof(H5FD_onion_fapl_info_t));
+ vfd_info_g.info = &onion_fa_g;
}
} /* driver name defined */
@@ -1447,7 +1451,21 @@ main(int argc, char *argv[])
while (H5_optind < argc) {
fname = HDstrdup(argv[H5_optind++]);
- fid = h5tools_fopen(fname, H5F_ACC_RDONLY, fapl_id, (fapl_id != H5P_DEFAULT), NULL, 0);
+ /* A short cut to get the revision count of an onion file without opening the file */
+ if (get_onion_revision_count && H5FD_ONION == H5Pget_driver(fapl_id)) {
+ size_t revision_count = 0;
+
+ if (H5FDonion_get_revision_count(fname, fapl_id, &revision_count) < 0) {
+ error_msg("unable to create FAPL for file access\n");
+ h5tools_setstatus(EXIT_FAILURE);
+ goto done;
+ }
+
+ printf("The number of revisions for the onion file is %lu\n", revision_count);
+ goto done;
+ }
+ else
+ fid = h5tools_fopen(fname, H5F_ACC_RDONLY, fapl_id, (fapl_id != H5P_DEFAULT), NULL, 0);
if (fid < 0) {
error_msg("unable to open file \"%s\"\n", fname);
@@ -1635,10 +1653,6 @@ done:
/* Free tables for objects */
table_list_free();
- /* Free the VFD info */
- if (vfd_info_g.info)
- HDfree(vfd_info_g.info);
-
if (fapl_id != H5P_DEFAULT && 0 < H5Pclose(fapl_id)) {
error_msg("Can't close fapl entry\n");
h5tools_setstatus(EXIT_FAILURE);
diff --git a/tools/test/h5dump/testh5dump.sh.in b/tools/test/h5dump/testh5dump.sh.in
index a9d7b6a..ce7f643 100644
--- a/tools/test/h5dump/testh5dump.sh.in
+++ b/tools/test/h5dump/testh5dump.sh.in
@@ -381,6 +381,7 @@ $SRC_H5DUMP_TESTFILES/err_attr_dspace.ddl
$SRC_H5DUMP_TESTFILES/tst_onion_objs.ddl
$SRC_H5DUMP_TESTFILES/tst_onion_dset_ext.ddl
$SRC_H5DUMP_TESTFILES/tst_onion_dset_1d.ddl
+$SRC_H5DUMP_TESTFILES/tst_onion_revision_count.ddl
"
LIST_ERROR_TEST_FILES="
@@ -1499,6 +1500,7 @@ TOOLTEST_FAIL tCVE_2018_11206_fill_new.h5
TOOLTEST tst_onion_objs.ddl --enable-error-stack --vfd-name onion --vfd-info 3 tst_onion_objs.h5
TOOLTEST tst_onion_dset_ext.ddl --enable-error-stack --vfd-name onion --vfd-info 1 tst_onion_dset_ext.h5
TOOLTEST tst_onion_dset_1d.ddl --enable-error-stack --vfd-name onion --vfd-info 1 tst_onion_dset_1d.h5
+TOOLTEST tst_onion_revision_count.ddl --enable-error-stack --vfd-name onion --vfd-info revision_count tst_onion_objs.h5
# Clean up temporary files/directories
CLEAN_TESTFILES_AND_TESTDIR