summaryrefslogtreecommitdiffstats
path: root/src/H5Olayout.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/H5Olayout.c')
-rw-r--r--src/H5Olayout.c62
1 files changed, 53 insertions, 9 deletions
diff --git a/src/H5Olayout.c b/src/H5Olayout.c
index 1a21926..2c4c4ce 100644
--- a/src/H5Olayout.c
+++ b/src/H5Olayout.c
@@ -39,7 +39,7 @@
/* PRIVATE PROTOTYPES */
static void *H5O__layout_decode(H5F_t *f, hid_t dxpl_id, H5O_t *open_oh,
- unsigned mesg_flags, unsigned *ioflags, const uint8_t *p);
+ unsigned mesg_flags, unsigned *ioflags, size_t p_size, const uint8_t *p);
static herr_t H5O__layout_encode(H5F_t *f, hbool_t disable_shared, uint8_t *p, const void *_mesg);
static void *H5O__layout_copy(const void *_mesg, void *_dest);
static size_t H5O__layout_size(const H5F_t *f, hbool_t disable_shared, const void *_mesg);
@@ -47,6 +47,8 @@ static herr_t H5O__layout_reset(void *_mesg);
static herr_t H5O__layout_free(void *_mesg);
static herr_t H5O__layout_delete(H5F_t *f, hid_t dxpl_id, H5O_t *open_oh,
void *_mesg);
+static herr_t H5O__layout_pre_copy_file(H5F_t *file_src, const void *mesg_src,
+ hbool_t *deleted, const H5O_copy_t *cpy_info, void *udata);
static void *H5O__layout_copy_file(H5F_t *file_src, void *mesg_src,
H5F_t *file_dst, hbool_t *recompute_size, unsigned *mesg_flags,
H5O_copy_t *cpy_info, void *udata, hid_t dxpl_id);
@@ -69,7 +71,7 @@ const H5O_msg_class_t H5O_MSG_LAYOUT[1] = {{
NULL, /* link method */
NULL, /* set share method */
NULL, /* can share method */
- NULL, /* pre copy native value to file */
+ H5O__layout_pre_copy_file, /* pre copy native value to file */
H5O__layout_copy_file, /* copy native value to file */
NULL, /* post copy native value to file */
NULL, /* get creation index */
@@ -99,7 +101,8 @@ H5FL_DEFINE(H5O_layout_t);
*/
static void *
H5O__layout_decode(H5F_t *f, hid_t H5_ATTR_UNUSED dxpl_id, H5O_t H5_ATTR_UNUSED *open_oh,
- unsigned H5_ATTR_UNUSED mesg_flags, unsigned H5_ATTR_UNUSED *ioflags, const uint8_t *p)
+ unsigned H5_ATTR_UNUSED mesg_flags, unsigned H5_ATTR_UNUSED *ioflags,
+ size_t H5_ATTR_UNUSED p_size, const uint8_t *p)
{
H5O_layout_t *mesg = NULL;
uint8_t *heap_block = NULL;
@@ -549,11 +552,11 @@ done:
static herr_t
H5O__layout_encode(H5F_t *f, hbool_t H5_ATTR_UNUSED disable_shared, uint8_t *p, const void *_mesg)
{
- const H5O_layout_t *mesg = (const H5O_layout_t *) _mesg;
- uint8_t *heap_block = NULL;
+ const H5O_layout_t *mesg = (const H5O_layout_t *) _mesg;
+ uint8_t *heap_block = NULL;
size_t *str_size = NULL;
- unsigned u;
- unsigned saved_latest_flags = H5F_GET_LATEST_FLAGS(f);
+ unsigned u;
+ H5F_libver_t saved_low, saved_high;
herr_t ret_value = SUCCEED; /* Return value */
FUNC_ENTER_STATIC
@@ -570,6 +573,9 @@ H5O__layout_encode(H5F_t *f, hbool_t H5_ATTR_UNUSED disable_shared, uint8_t *p,
/* Layout class */
*p++ = mesg->type;
+ saved_low = H5F_LOW_BOUND(f);
+ saved_high = H5F_HIGH_BOUND(f);
+
/* Write out layout class specific information */
switch(mesg->type) {
case H5D_COMPACT:
@@ -691,7 +697,8 @@ H5O__layout_encode(H5F_t *f, hbool_t H5_ATTR_UNUSED disable_shared, uint8_t *p,
uint32_t chksum;
size_t i;
- H5F_SET_LATEST_FLAGS(f, H5F_LATEST_ALL_FLAGS);
+ if(H5F_set_libver_bounds(f, H5F_LIBVER_V110, H5F_LIBVER_V110) < 0)
+ HGOTO_ERROR(H5E_OHDR, H5E_CANTSET, FAIL, "cannot set low/high bounds")
/* Allocate array for caching results of strlen */
if(NULL == (str_size = (size_t *)H5MM_malloc(2 * mesg->storage.u.virt.list_nused *sizeof(size_t))))
@@ -789,7 +796,8 @@ H5O__layout_encode(H5F_t *f, hbool_t H5_ATTR_UNUSED disable_shared, uint8_t *p,
} /* end switch */
done:
- H5F_SET_LATEST_FLAGS(f, saved_latest_flags);
+ if(H5F_set_libver_bounds(f, saved_low, saved_high) < 0)
+ HDONE_ERROR(H5E_OHDR, H5E_CANTSET, FAIL, "cannot reset low/high bounds")
heap_block = (uint8_t *)H5MM_xfree(heap_block);
str_size = (size_t *)H5MM_xfree(str_size);
@@ -1051,6 +1059,42 @@ done:
/*-------------------------------------------------------------------------
+ * Function: H5O__layout_pre_copy_file
+ *
+ * Purpose: Perform any necessary actions before copying message between
+ * files.
+ *
+ * Return: Success: Non-negative
+ * Failure: Negative
+ *
+ * Programmer: Vailin Choi; Dec 2017
+ *
+ *-------------------------------------------------------------------------
+ */
+static herr_t
+H5O__layout_pre_copy_file(H5F_t H5_ATTR_UNUSED *file_src, const void *mesg_src,
+ hbool_t H5_ATTR_UNUSED *deleted, const H5O_copy_t *cpy_info, void H5_ATTR_UNUSED *udata)
+{
+ const H5O_layout_t *layout_src = (const H5O_layout_t *)mesg_src; /* Source layout */
+ herr_t ret_value = SUCCEED; /* Return value */
+
+ FUNC_ENTER_NOAPI_NOINIT
+
+ /* check args */
+ HDassert(cpy_info);
+ HDassert(cpy_info->file_dst);
+
+ /* Check to ensure that the version of the message to be copied does not exceed
+ the message version allowed by the destination file's high bound */
+ if(layout_src->version > H5O_layout_ver_bounds[H5F_HIGH_BOUND(cpy_info->file_dst)])
+ HGOTO_ERROR(H5E_OHDR, H5E_BADRANGE, FAIL, "layout message version out of bounds")
+
+done:
+ FUNC_LEAVE_NOAPI(ret_value)
+} /* end H5O__layout_pre_copy_file() */
+
+
+/*-------------------------------------------------------------------------
* Function: H5O__layout_copy_file
*
* Purpose: Copies a message from _MESG to _DEST in file