summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--src/H5Fsuper.c60
-rw-r--r--src/H5Ofsinfo.c86
-rw-r--r--src/H5Oprivate.h4
3 files changed, 93 insertions, 57 deletions
diff --git a/src/H5Fsuper.c b/src/H5Fsuper.c
index 7685384..5334c51 100644
--- a/src/H5Fsuper.c
+++ b/src/H5Fsuper.c
@@ -80,15 +80,6 @@ static const unsigned HDF5_superblock_ver_bounds[] = {
HDF5_SUPERBLOCK_VERSION_LATEST /* H5F_LIBVER_LATEST */
};
-/* Format version bounds for fsinfo message */
-/* This message exists starting library release v1.10 */
-static const unsigned H5O_fsinfo_ver_bounds[] = {
- H5O_INVALID_VERSION, /* H5F_LIBVER_EARLIEST */
- H5O_INVALID_VERSION, /* H5F_LIBVER_V18 */
- H5O_FSINFO_VERSION_1, /* H5F_LIBVER_V110 */
- H5O_FSINFO_VERSION_LATEST /* H5F_LIBVER_LATEST */
-};
-
/*-------------------------------------------------------------------------
* Function: H5F__super_ext_create
@@ -790,15 +781,13 @@ H5F__super_read(H5F_t *f, H5P_genplist_t *fa_plist, hbool_t initial_read)
if(NULL == H5O_msg_read(&ext_loc, H5O_FSINFO_ID, &fsinfo))
HGOTO_ERROR(H5E_FILE, H5E_CANTGET, FAIL, "unable to get free-space manager info message")
- /* Update changed values */
-
/* Version bounds check */
- if(H5O_fsinfo_ver_bounds[H5F_HIGH_BOUND(f)] == H5O_INVALID_VERSION ||
- fsinfo.version > H5O_fsinfo_ver_bounds[H5F_HIGH_BOUND(f)])
+ if(H5O_fsinfo_check_version(H5F_HIGH_BOUND(f), &fsinfo) < 0)
HGOTO_ERROR(H5E_FILE, H5E_BADRANGE, FAIL, "File space info message's version out of bounds")
+
+ /* Update changed values */
if(f->shared->fs_version != fsinfo.version)
f->shared->fs_version = fsinfo.version;
-
if(f->shared->fs_strategy != fsinfo.strategy) {
f->shared->fs_strategy = fsinfo.strategy;
@@ -1400,7 +1389,7 @@ H5F__super_init(H5F_t *f)
fsinfo.mapped = FALSE;
/* Set the version for the fsinfo message */
- if(H5O__fsinfo_set_version(f, &fsinfo) < 0)
+ if(H5O_fsinfo_set_version(H5F_LOW_BOUND(f), H5F_HIGH_BOUND(f), &fsinfo) < 0)
HGOTO_ERROR(H5E_FILE, H5E_CANTSET, FAIL, "can't set version of fsinfo")
f->shared->fs_version = fsinfo.version;
@@ -1830,44 +1819,3 @@ done:
FUNC_LEAVE_NOAPI(ret_value)
} /* H5F__super_ext_remove_msg() */
-
-/*-------------------------------------------------------------------------
- * Function: H5O__fsinfo_set_version
- *
- * Purpose: Set the version to encode the fsinfo message with.
- *
- * Return: Non-negative on success/Negative on failure
- *
- * Programmer: Vailin Choi; June 2019
- *
- *-------------------------------------------------------------------------
- */
-herr_t
-H5O__fsinfo_set_version(H5F_t *f, H5O_fsinfo_t *fsinfo)
-{
- unsigned version; /* Message version */
- herr_t ret_value = SUCCEED; /* Return value */
-
- FUNC_ENTER_NOAPI(FAIL)
-
- /* Sanity check */
- HDassert(f);
- HDassert(fsinfo);
-
- version = H5O_FSINFO_VERSION_1;
-
- /* Upgrade to the version indicated by the file's low bound if higher */
- if(H5O_fsinfo_ver_bounds[H5F_LOW_BOUND(f)] != H5O_INVALID_VERSION)
- version = MAX(version, H5O_fsinfo_ver_bounds[H5F_LOW_BOUND(f)]);
-
- /* Version bounds check */
- if(H5O_fsinfo_ver_bounds[H5F_HIGH_BOUND(f)] == H5O_INVALID_VERSION ||
- version > H5O_fsinfo_ver_bounds[H5F_HIGH_BOUND(f)])
- HGOTO_ERROR(H5E_DATASET, H5E_BADRANGE, FAIL, "File space info message's version out of bounds")
-
- /* Set the message version */
- fsinfo->version = version;
-
-done:
- FUNC_LEAVE_NOAPI(ret_value)
-} /* end H5O__fsinfo_set_version() */
diff --git a/src/H5Ofsinfo.c b/src/H5Ofsinfo.c
index ec2328c..52a7802 100644
--- a/src/H5Ofsinfo.c
+++ b/src/H5Ofsinfo.c
@@ -65,6 +65,16 @@ const H5O_msg_class_t H5O_MSG_FSINFO[1] = {{
H5O__fsinfo_debug /* debug the message */
}};
+/* Format version bounds for fsinfo message */
+/* This message exists starting library release v1.10 */
+static const unsigned H5O_fsinfo_ver_bounds[] = {
+ H5O_INVALID_VERSION, /* H5F_LIBVER_EARLIEST */
+ H5O_INVALID_VERSION, /* H5F_LIBVER_V18 */
+ H5O_FSINFO_VERSION_1, /* H5F_LIBVER_V110 */
+ H5O_FSINFO_VERSION_LATEST /* H5F_LIBVER_LATEST */
+};
+#define N_FSINFO_VERSION_BOUNDS 4
+
/* Declare a free list to manage the H5O_fsinfo_t struct */
H5FL_DEFINE_STATIC(H5O_fsinfo_t);
@@ -257,7 +267,7 @@ H5O_fsinfo_copy(const void *_mesg, void *_dest)
/* check args */
HDassert(fsinfo);
if(!dest && NULL == (dest = H5FL_CALLOC(H5O_fsinfo_t)))
- HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, NULL, "memory allocation failed")
+ HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, NULL, "memory allocation failed")
/* copy */
*dest = *fsinfo;
@@ -331,6 +341,80 @@ H5O__fsinfo_free(void *mesg)
/*-------------------------------------------------------------------------
+ * Function: H5O_fsinfo_set_version
+ *
+ * Purpose: Set the version to encode the fsinfo message with.
+ *
+ * Return: SUCCEED/FAIL
+ *
+ * Programmer: Vailin Choi; June 2019
+ *
+ *-------------------------------------------------------------------------
+ */
+herr_t
+H5O_fsinfo_set_version(H5F_libver_t low, H5F_libver_t high, H5O_fsinfo_t *fsinfo)
+{
+ unsigned version; /* Message version */
+ herr_t ret_value = SUCCEED; /* Return value */
+
+ FUNC_ENTER_NOAPI(FAIL)
+
+ /* Sanity check */
+ HDcompile_assert(N_FSINFO_VERSION_BOUNDS == H5F_LIBVER_NBOUNDS);
+ HDassert(fsinfo);
+
+ version = H5O_FSINFO_VERSION_1;
+
+ /* Upgrade to the version indicated by the file's low bound if higher */
+ if(H5O_fsinfo_ver_bounds[low] != H5O_INVALID_VERSION)
+ version = MAX(version, H5O_fsinfo_ver_bounds[low]);
+
+ /* Version bounds check */
+ if(H5O_fsinfo_ver_bounds[high] == H5O_INVALID_VERSION ||
+ version > H5O_fsinfo_ver_bounds[high])
+ HGOTO_ERROR(H5E_OHDR, H5E_BADRANGE, FAIL, "File space info message's version out of bounds")
+
+ /* Set the message version */
+ fsinfo->version = version;
+
+done:
+ FUNC_LEAVE_NOAPI(ret_value)
+} /* end H5O_fsinfo_set_version() */
+
+
+/*-------------------------------------------------------------------------
+ * Function: H5O_fsinfo_check_version
+ *
+ * Purpose: Validate the fsinfo message version
+ *
+ * Return: SUCCEED/FAIL
+ *
+ * Programmer: Dana Robinson
+ * Summer 2019
+ *
+ *-------------------------------------------------------------------------
+ */
+herr_t
+H5O_fsinfo_check_version(H5F_libver_t high, H5O_fsinfo_t *fsinfo)
+{
+ herr_t ret_value = SUCCEED; /* Return value */
+
+ FUNC_ENTER_NOAPI(FAIL)
+
+ /* Sanity check */
+ HDcompile_assert(N_FSINFO_VERSION_BOUNDS == H5F_LIBVER_NBOUNDS);
+ HDassert(fsinfo);
+
+ /* Check the version */
+ if(H5O_fsinfo_ver_bounds[high] == H5O_INVALID_VERSION || fsinfo->version > H5O_fsinfo_ver_bounds[high])
+ HGOTO_ERROR(H5E_OHDR, H5E_BADRANGE, FAIL, "File space info message's version out of bounds")
+
+done:
+ FUNC_LEAVE_NOAPI(ret_value)
+} /* end H5O_fsinfo_check_version() */
+
+
+/*-------------------------------------------------------------------------
* Function: H5O__fsinfo_debug
*
* Purpose: Prints debugging info for a message.
diff --git a/src/H5Oprivate.h b/src/H5Oprivate.h
index d143f31..354a00b 100644
--- a/src/H5Oprivate.h
+++ b/src/H5Oprivate.h
@@ -997,6 +997,10 @@ H5_DLL H5O_loc_t *H5O_get_loc(hid_t id);
/* EFL operators */
H5_DLL hsize_t H5O_efl_total_size(H5O_efl_t *efl);
+/* File space info routines */
+H5_DLL herr_t H5O_fsinfo_set_version(H5F_libver_t low, H5F_libver_t high, H5O_fsinfo_t *fsinfo);
+H5_DLL herr_t H5O_fsinfo_check_version(H5F_libver_t high, H5O_fsinfo_t *fsinfo);
+
/* Fill value operators */
H5_DLL herr_t H5O_fill_reset_dyn(H5O_fill_t *fill);
H5_DLL herr_t H5O_fill_convert(H5O_fill_t *fill, H5T_t *type, hbool_t *fill_changed);