summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-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