Skip to content

Commit

Permalink
Added the support to get the revision count for the onion file into t…
Browse files Browse the repository at this point in the history
…he 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>
  • Loading branch information
6 people authored May 5, 2022
1 parent 93f65cc commit 0566def
Show file tree
Hide file tree
Showing 5 changed files with 36 additions and 19 deletions.
3 changes: 2 additions & 1 deletion src/H5FDonion.c
Original file line number Diff line number Diff line change
Expand Up @@ -355,12 +355,13 @@ H5Pset_fapl_onion(hid_t fapl_id, const H5FD_onion_fapl_info_t *fa)
} /* 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, ""))
Expand Down
4 changes: 2 additions & 2 deletions src/H5FDonion.h
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
Expand Down
2 changes: 1 addition & 1 deletion test/onion.c
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
44 changes: 29 additions & 15 deletions tools/src/h5dump/h5dump.c
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down Expand Up @@ -1315,16 +1317,18 @@ parse_command_line(int argc, const char *const *argv)
/* 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 */

Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -1635,10 +1653,6 @@ main(int argc, char *argv[])
/* 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);
Expand Down
2 changes: 2 additions & 0 deletions tools/test/h5dump/testh5dump.sh.in
Original file line number Diff line number Diff line change
Expand Up @@ -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="
Expand Down Expand Up @@ -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
Expand Down

0 comments on commit 0566def

Please sign in to comment.