Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-04-18 09:16:02

0001 /* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
0002  * Copyright by The HDF Group.                                               *
0003  * All rights reserved.                                                      *
0004  *                                                                           *
0005  * This file is part of HDF5.  The full HDF5 copyright notice, including     *
0006  * terms governing use, modification, and redistribution, is contained in    *
0007  * the COPYING file, which can be found at the root of the source code       *
0008  * distribution tree, or in https://www.hdfgroup.org/licenses.               *
0009  * If you do not have access to either file, you may request a copy from     *
0010  * help@hdfgroup.org.                                                        *
0011  * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
0012 
0013 /*
0014  * Purpose: The public header file for the onion virtual file driver (VFD)
0015  */
0016 #ifndef H5FDonion_H
0017 #define H5FDonion_H
0018 
0019 /** Initializer for the onion VFD */
0020 #define H5FD_ONION (H5FDperform_init(H5FD_onion_init))
0021 
0022 /** Identifier for the onion VFD */
0023 #define H5FD_ONION_VALUE H5_VFD_ONION
0024 
0025 /** Current version of the onion VFD fapl info struct */
0026 #define H5FD_ONION_FAPL_INFO_VERSION_CURR 1
0027 
0028 #define H5FD_ONION_FAPL_INFO_CREATE_FLAG_ENABLE_PAGE_ALIGNMENT                                               \
0029     (0x0001u) /**<                                                                                           \
0030                * Onion history metadata will align to page_size.                                             \
0031                * Partial pages of unused space will occur in the file,                                       \
0032                * but may improve read performance from the backing store                                     \
0033                * on some systems.                                                                            \
0034                * If disabled (0), padding will not be inserted to align                                      \
0035                * to page boundaries.                                                                         \
0036                */
0037 
0038 /**
0039  * Max length of a comment.
0040  * The buffer is defined to be this size + 1 to handle the NUL.
0041  */
0042 #define H5FD_ONION_FAPL_INFO_COMMENT_MAX_LEN 255
0043 
0044 /**
0045  * Indicates that you want the latest revision.
0046  */
0047 #define H5FD_ONION_FAPL_INFO_REVISION_ID_LATEST UINT64_MAX
0048 
0049 /**
0050  * Indicates how the new onion data will be stored.
0051  */
0052 typedef enum H5FD_onion_target_file_constant_t {
0053     H5FD_ONION_STORE_TARGET_ONION, /**<
0054                                     * Onion history is stored in a single, separate "onion
0055                                     * file". Shares filename and path as hdf5 file (if any),
0056                                     * with only a different filename extension.
0057                                     */
0058 } H5FD_onion_target_file_constant_t;
0059 
0060 /**
0061  * Stores fapl information for creating onion VFD files.
0062  */
0063 typedef struct H5FD_onion_fapl_info_t {
0064     uint8_t version;                                /**<
0065                                                      * Future-proofing identifier. Informs struct membership.
0066                                                      * Must equal H5FD_ONION_FAPL_VERSION_CURR to be considered valid.
0067                                                      */
0068     hid_t backing_fapl_id;                          /**<
0069                                                      * Backing or 'child' FAPL ID to handle I/O with the
0070                                                      * underlying backing store. It must use the same backing driver as the
0071                                                      * original file.
0072                                                      */
0073     uint32_t page_size;                             /**<
0074                                                      * page_size:   Size of the amended data pages. If opening an existing file,
0075                                                      *              must equal the existing page size or zero. If creating a new
0076                                                      *              file or an initial revision of an existing file, must be a
0077                                                      *              power of 2.
0078                                                      *
0079                                                      */
0080     H5FD_onion_target_file_constant_t store_target; /**<
0081                                                      * Identifies where the history data is stored.
0082                                                      */
0083     uint64_t revision_num;                          /**<
0084                                                      * Which revision to open. Valid values are 0 (the original file) or the
0085                                                      *              revision number of an existing revision.
0086                                                      *              H5FD_ONION_FAPL_INFO_REVISION_ID_LATEST refers to the most
0087                                                      *              recently-created revision in the history.
0088                                                      */
0089     uint8_t force_write_open;                       /**<
0090                                                      *              Flag to ignore the write-lock flag in the onion data
0091                                                      *              and attempt to open the file write-only anyway.
0092                                                      *              This may be relevant if, for example, the library crashed
0093                                                      *              while the file was open in write mode and the write-lock
0094                                                      *              flag was not cleared.
0095                                                      *              Must equal H5FD_ONION_FAPL_FLAG_FORCE_OPEN to enable.
0096                                                      *
0097                                                      */
0098     uint8_t creation_flags;                         /**<
0099                                                      * Flag used only when instantiating an onion file.
0100                                                      * If the relevant bit is set to a nonzero value, its feature
0101                                                      * will be enabled.
0102                                                      */
0103     char comment[H5FD_ONION_FAPL_INFO_COMMENT_MAX_LEN +
0104                  1]; /**<
0105                       * User-supplied NULL-terminated comment for a revision to be
0106                       * written.
0107                       * Cannot be longer than H5FD_ONION_FAPL_COMMENT_MAX_LEN.
0108                       * Ignored if part of a FAPL used to open in read mode.
0109                       */
0110 } H5FD_onion_fapl_info_t;
0111 
0112 #ifdef __cplusplus
0113 extern "C" {
0114 #endif
0115 
0116 /** @private
0117  *
0118  * \brief Private initializer for the onion VFD
0119  */
0120 H5_DLL hid_t H5FD_onion_init(void);
0121 
0122 /**
0123  * --------------------------------------------------------------------------
0124  * \ingroup FAPL
0125  *
0126  * \brief get the onion info from the file access property list
0127  *
0128  * \fapl_id
0129  * \param[out] fa_out The pointer to the structure H5FD_onion_fapl_info_t
0130  *
0131  * \return \herr_t
0132  *
0133  * \details H5Pget_fapl_onion() retrieves the structure H5FD_onion_fapl_info_t
0134  *          from the file access property list that is set for the onion VFD
0135  *          driver.
0136  *
0137  * \since 1.14.0
0138  */
0139 H5_DLL herr_t H5Pget_fapl_onion(hid_t fapl_id, H5FD_onion_fapl_info_t *fa_out);
0140 
0141 /**
0142  * --------------------------------------------------------------------------
0143  * \ingroup FAPL
0144  *
0145  * \brief set the onion info for the file access property list
0146  *
0147  * \fapl_id
0148  * \param[in] fa The pointer to the structure H5FD_onion_fapl_info_t
0149  *
0150  * \return \herr_t
0151  *
0152  * \details H5Pset_fapl_onion() sets the structure H5FD_onion_fapl_info_t
0153  *          for the file access property list that is set for the onion VFD
0154  *          driver.
0155  *
0156  * \since 1.14.0
0157  */
0158 H5_DLL herr_t H5Pset_fapl_onion(hid_t fapl_id, const H5FD_onion_fapl_info_t *fa);
0159 
0160 /**
0161  * --------------------------------------------------------------------------
0162  * \ingroup H5FD
0163  *
0164  * \brief get the number of revisions
0165  *
0166  * \param[in] filename The name of the onion file
0167  * \param[in] fapl_id The ID of the file access property list
0168  * \param[out] revision_count The number of revisions
0169  *
0170  * \return \herr_t
0171  *
0172  * \details H5FDonion_get_revision_count() returns the number of revisions
0173  *          for an onion file. It takes the file name and file access property
0174  *          list that is set for the onion VFD driver.
0175  *
0176  *
0177  * \since 1.14.0
0178  */
0179 H5_DLL herr_t H5FDonion_get_revision_count(const char *filename, hid_t fapl_id, uint64_t *revision_count);
0180 
0181 #ifdef __cplusplus
0182 }
0183 #endif
0184 
0185 #endif /* H5FDonion_H */