diff options
Diffstat (limited to 'src/H5FDonion.c')
-rw-r--r-- | src/H5FDonion.c | 63 |
1 files changed, 63 insertions, 0 deletions
diff --git a/src/H5FDonion.c b/src/H5FDonion.c index f8ef824..a7a6fe8 100644 --- a/src/H5FDonion.c +++ b/src/H5FDonion.c @@ -147,6 +147,8 @@ H5FL_DEFINE_STATIC(H5FD_onion_t); /* 2^n for uint64_t types -- H5_EXP2 unsafe past 32 bits */ #define U64_EXP2(n) ((uint64_t)1 << (n)) +#define H5FD_CTL__GET_NUM_REVISIONS 20001 + /* Prototypes */ static herr_t H5FD__onion_close(H5FD_t *); static haddr_t H5FD__onion_get_eoa(const H5FD_t *, H5FD_mem_t); @@ -170,6 +172,7 @@ static herr_t H5FD__onion_sb_decode(H5FD_t *_file, const char *name, const unsi static hsize_t H5FD__onion_sb_size(H5FD_t *_file); static herr_t H5FD__onion_ctl(H5FD_t *_file, uint64_t op_code, uint64_t flags, const void H5_ATTR_UNUSED *input, void H5_ATTR_UNUSED **output); +static herr_t H5FD__get_onion_revision_count(H5FD_t *file, size_t *revision_count); static const H5FD_class_t H5FD_onion_g = { H5FD_CLASS_VERSION, /* struct version */ @@ -351,6 +354,66 @@ done: FUNC_LEAVE_API(ret_value) } /* end H5Pset_fapl_onion() */ +herr_t +H5FDget_onion_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) + + /* Check the file name */ + if (!filename || !HDstrcmp(filename, "")) + HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "not a valid file name") + + /* Make sure using the correct driver */ + if (NULL == (plist = H5P_object_verify(fapl_id, H5P_FILE_ACCESS))) + HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "not a valid FAPL ID") + + if (H5FD_ONION != H5P_peek_driver(plist)) + HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "not a Onion VFL driver") + + if (!revision_count) + HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "revision count can't be null") + + /* Open the file with the driver */ + if (NULL == (file_drv_ptr = H5FD_open(filename, H5F_ACC_RDONLY, fapl_id, HADDR_UNDEF))) + HGOTO_ERROR(H5E_VFL, H5E_CANTOPENFILE, FAIL, "unable to open file with onion driver") + + /* Call the private function */ + if (H5FD__get_onion_revision_count(file_drv_ptr, revision_count) < 0) + HGOTO_ERROR(H5E_VFL, H5E_CANTGET, FAIL, "failed to get the number of revisions") + + /* Close H5FD_t structure pointer */ + if (H5FD_close(file_drv_ptr) < 0) + HGOTO_ERROR(H5E_VFL, H5E_CANTCLOSEFILE, FAIL, "unable to close file") + + file_drv_ptr = NULL; + +done: + FUNC_LEAVE_API(ret_value) +} + +static herr_t +H5FD__get_onion_revision_count(H5FD_t *file, size_t *revision_count) +{ + herr_t ret_value = SUCCEED; + uint64_t op_code; + uint64_t flags; + + FUNC_ENTER_PACKAGE + + op_code = H5FD_CTL__GET_NUM_REVISIONS; + flags = H5FD_CTL__FAIL_IF_UNKNOWN_FLAG; + + /* Call private function */ + if (H5FD_ctl(file, op_code, flags, NULL, (void **)&revision_count) < 0) + HGOTO_ERROR(H5E_VFL, H5E_FCNTL, FAIL, "VFD ctl request failed") + +done: + FUNC_LEAVE_NOAPI(ret_value) +} + /*------------------------------------------------------------------------- * Function: H5FD__onion_sb_size * |