summaryrefslogtreecommitdiffstats
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
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>
-rw-r--r--src/H5FDonion.c3
-rw-r--r--src/H5FDonion.h4
-rw-r--r--test/onion.c2
-rw-r--r--tools/src/h5dump/h5dump.c44
-rw-r--r--tools/test/h5dump/testh5dump.sh.in2
5 files changed, 36 insertions, 19 deletions
diff --git a/src/H5FDonion.c b/src/H5FDonion.c
index a7a6fe8..3270b82 100644
--- a/src/H5FDonion.c
+++ b/src/H5FDonion.c
@@ -355,12 +355,13 @@ done:
} /* end H5Pset_fapl_onion() */
herr_t
-H5FDget_onion_revision_count(const char *filename, hid_t fapl_id, size_t *revision_count)
+H5FDonion_get_revision_count(const char *filename, hid_t fapl_id, size_t *revision_count)
{
H5P_genplist_t *plist = NULL;
herr_t ret_value = SUCCEED;
H5FD_t * file_drv_ptr = NULL;
FUNC_ENTER_API(FAIL)
+ H5TRACE3("e", "*si*z", filename, fapl_id, revision_count);
/* Check the file name */
if (!filename || !HDstrcmp(filename, ""))
diff --git a/src/H5FDonion.h b/src/H5FDonion.h
index bca6526..c91010c 100644
--- a/src/H5FDonion.h
+++ b/src/H5FDonion.h
@@ -176,12 +176,12 @@ H5_DLL herr_t H5Pset_fapl_onion(hid_t fapl_id, const H5FD_onion_fapl_info_t *fa)
*
* \return \herr_t
*
- * \details H5FDget_onion_revision_count() returns the number of revisions
+ * \details H5FDonion_get_revision_count() returns the number of revisions
* for an onion file. It takes the file name and file access property
* list that is set for the onion VFD driver.
*
*/
-H5_DLL herr_t H5FDget_onion_revision_count(const char *filename, hid_t fapl_id, size_t *revision_count);
+H5_DLL herr_t H5FDonion_get_revision_count(const char *filename, hid_t fapl_id, size_t *revision_count);
#ifdef __cplusplus
}
diff --git a/test/onion.c b/test/onion.c
index 6722191..c06b574 100644
--- a/test/onion.c
+++ b/test/onion.c
@@ -4185,7 +4185,7 @@ test_integration_ctl(void)
* Start to verify the number of revisions
*----------------------------------------------------------------------
*/
- if (H5FDget_onion_revision_count(basename, fapl_id, &revision_count) < 0)
+ if (H5FDonion_get_revision_count(basename, fapl_id, &revision_count) < 0)
TEST_ERROR
if (2 != revision_count)
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