mirror of
https://github.com/HDFGroup/hdf5.git
synced 2025-03-01 16:28:09 +08:00
Refactor several cache clients to have only one copy of their deserialization
code.
This commit is contained in:
parent
5e26cd2d82
commit
eecc0a26ef
@ -91,6 +91,14 @@ static herr_t H5F__cache_drvrinfo_serialize(const H5F_t *f, void *image, size_t
|
||||
void *thing);
|
||||
static herr_t H5F__cache_drvrinfo_free_icr(void *thing);
|
||||
|
||||
/* Local encode/decode routines */
|
||||
static herr_t H5F__superblock_prefix_decode(H5F_super_t *sblock,
|
||||
const uint8_t **image_ref, const H5F_superblock_cache_ud_t *udata,
|
||||
hbool_t extend_eoa);
|
||||
static herr_t H5F__drvrinfo_prefix_decode(H5O_drvinfo_t *drvinfo, char *drv_name,
|
||||
const uint8_t **image_ref, H5F_drvrinfo_cache_ud_t *udata,
|
||||
hbool_t extend_eoa);
|
||||
|
||||
|
||||
/*********************/
|
||||
/* Package Variables */
|
||||
@ -146,6 +154,158 @@ H5FL_EXTERN(H5F_super_t);
|
||||
/*******************/
|
||||
|
||||
|
||||
|
||||
/*-------------------------------------------------------------------------
|
||||
* Function: H5F__superblock_prefix_decode
|
||||
*
|
||||
* Purpose: Decode a superblock prefix
|
||||
*
|
||||
* Return: Non-negative on success/Negative on failure
|
||||
*
|
||||
* Programmer: Quincey Koziol
|
||||
* December 15, 2016
|
||||
*
|
||||
*-------------------------------------------------------------------------
|
||||
*/
|
||||
static herr_t
|
||||
H5F__superblock_prefix_decode(H5F_super_t *sblock, const uint8_t **image_ref,
|
||||
const H5F_superblock_cache_ud_t *udata, hbool_t extend_eoa)
|
||||
{
|
||||
const uint8_t *image = (const uint8_t *)*image_ref; /* Pointer into raw data buffer */
|
||||
htri_t ret_value = SUCCEED; /* Return value */
|
||||
|
||||
FUNC_ENTER_STATIC
|
||||
|
||||
/* Check arguments */
|
||||
HDassert(sblock);
|
||||
HDassert(image_ref);
|
||||
HDassert(image);
|
||||
HDassert(udata);
|
||||
HDassert(udata->f);
|
||||
|
||||
/* Skip over signature (already checked when locating the superblock) */
|
||||
image += H5F_SIGNATURE_LEN;
|
||||
|
||||
/* Superblock version */
|
||||
sblock->super_vers = *image++;
|
||||
if(sblock->super_vers > HDF5_SUPERBLOCK_VERSION_LATEST)
|
||||
HGOTO_ERROR(H5E_FILE, H5E_BADVALUE, FAIL, "bad superblock version number")
|
||||
|
||||
/* Sanity check */
|
||||
HDassert(((size_t)(image - (const uint8_t *)*image_ref)) == H5F_SUPERBLOCK_FIXED_SIZE);
|
||||
|
||||
/* Determine the size of addresses & size of offsets, for computing the
|
||||
* variable-sized portion of the superblock.
|
||||
*/
|
||||
if(sblock->super_vers < HDF5_SUPERBLOCK_VERSION_2) {
|
||||
sblock->sizeof_addr = image[4];
|
||||
sblock->sizeof_size = image[5];
|
||||
} /* end if */
|
||||
else {
|
||||
sblock->sizeof_addr = image[0];
|
||||
sblock->sizeof_size = image[1];
|
||||
} /* end else */
|
||||
if(sblock->sizeof_addr != 2 && sblock->sizeof_addr != 4 &&
|
||||
sblock->sizeof_addr != 8 && sblock->sizeof_addr != 16 && sblock->sizeof_addr != 32)
|
||||
HGOTO_ERROR(H5E_FILE, H5E_BADVALUE, FAIL, "bad byte number in an address")
|
||||
if(sblock->sizeof_size != 2 && sblock->sizeof_size != 4 &&
|
||||
sblock->sizeof_size != 8 && sblock->sizeof_size != 16 && sblock->sizeof_size != 32)
|
||||
HGOTO_ERROR(H5E_FILE, H5E_BADVALUE, FAIL, "bad byte number for object size")
|
||||
|
||||
/* Check for extending the EOA for the file */
|
||||
if(extend_eoa) {
|
||||
size_t variable_size; /* Variable size of superblock */
|
||||
|
||||
/* Determine the size of the variable-length part of the superblock */
|
||||
variable_size = (size_t)H5F_SUPERBLOCK_VARLEN_SIZE(sblock->super_vers, sblock->sizeof_addr, sblock->sizeof_size);
|
||||
HDassert(variable_size > 0);
|
||||
|
||||
/* Make certain we can read the variable-sized portion of the superblock */
|
||||
if(H5F__set_eoa(udata->f, H5FD_MEM_SUPER, (haddr_t)(H5F_SUPERBLOCK_FIXED_SIZE + variable_size)) < 0)
|
||||
HGOTO_ERROR(H5E_FILE, H5E_CANTINIT, FAIL, "set end of space allocation request failed")
|
||||
} /* end if */
|
||||
|
||||
/* Update the image buffer pointer */
|
||||
*image_ref = image;
|
||||
|
||||
done:
|
||||
FUNC_LEAVE_NOAPI(ret_value)
|
||||
} /* end H5F__superblock_prefix_decode() */
|
||||
|
||||
|
||||
/*-------------------------------------------------------------------------
|
||||
* Function: H5F__drvrinfo_prefix_decode
|
||||
*
|
||||
* Purpose: Decode a driver info prefix
|
||||
*
|
||||
* Return: Non-negative on success/Negative on failure
|
||||
*
|
||||
* Programmer: Quincey Koziol
|
||||
* December 15, 2016
|
||||
*
|
||||
*-------------------------------------------------------------------------
|
||||
*/
|
||||
static herr_t
|
||||
H5F__drvrinfo_prefix_decode(H5O_drvinfo_t *drvrinfo, char *drv_name,
|
||||
const uint8_t **image_ref, H5F_drvrinfo_cache_ud_t *udata,
|
||||
hbool_t extend_eoa)
|
||||
{
|
||||
const uint8_t *image = (const uint8_t *)*image_ref; /* Pointer into raw data buffer */
|
||||
unsigned drv_vers; /* Version of driver info block */
|
||||
herr_t ret_value = SUCCEED; /* Return value */
|
||||
|
||||
FUNC_ENTER_STATIC
|
||||
|
||||
/* Sanity check */
|
||||
HDassert(drvrinfo);
|
||||
HDassert(image_ref);
|
||||
HDassert(image);
|
||||
HDassert(udata);
|
||||
HDassert(udata->f);
|
||||
|
||||
/* Version number */
|
||||
drv_vers = *image++;
|
||||
if(drv_vers != HDF5_DRIVERINFO_VERSION_0)
|
||||
HGOTO_ERROR(H5E_FILE, H5E_BADVALUE, FAIL, "bad driver information block version number")
|
||||
|
||||
image += 3; /* reserved bytes */
|
||||
|
||||
/* Driver info size */
|
||||
UINT32DECODE(image, drvrinfo->len);
|
||||
|
||||
/* Driver name and/or version */
|
||||
if(drv_name) {
|
||||
HDmemcpy(drv_name, (const char *)image, (size_t)8);
|
||||
drv_name[8] = '\0';
|
||||
image += 8; /* advance past name/version */
|
||||
} /* end if */
|
||||
|
||||
/* Extend the EOA if required so that we can read the complete driver info block */
|
||||
if(extend_eoa) {
|
||||
haddr_t eoa; /* Current EOA for the file */
|
||||
haddr_t min_eoa; /* Minimum EOA needed for reading the driver info */
|
||||
|
||||
/* Get current EOA... */
|
||||
eoa = H5FD_get_eoa(udata->f->shared->lf, H5FD_MEM_SUPER);
|
||||
if(!H5F_addr_defined(eoa))
|
||||
HGOTO_ERROR(H5E_FILE, H5E_CANTGET, FAIL, "driver get_eoa request failed")
|
||||
|
||||
/* ... if it is too small, extend it. */
|
||||
min_eoa = udata->driver_addr + H5F_DRVINFOBLOCK_HDR_SIZE + drvrinfo->len;
|
||||
|
||||
/* If it grew, set it */
|
||||
if(H5F_addr_gt(min_eoa, eoa))
|
||||
if(H5FD_set_eoa(udata->f->shared->lf, H5FD_MEM_SUPER, min_eoa) < 0)
|
||||
HGOTO_ERROR(H5E_FILE, H5E_CANTINIT, FAIL, "set end of space allocation request failed")
|
||||
} /* end if */
|
||||
|
||||
/* Update the image buffer pointer */
|
||||
*image_ref = image;
|
||||
|
||||
done:
|
||||
FUNC_LEAVE_NOAPI(ret_value)
|
||||
} /* end H5F__drvrinfo_prefix_decode() */
|
||||
|
||||
|
||||
/*-------------------------------------------------------------------------
|
||||
* Function: H5F__cache_superblock_get_initial_load_size
|
||||
@ -195,10 +355,7 @@ H5F__cache_superblock_get_final_load_size(const void *_image, size_t image_len,
|
||||
{
|
||||
const uint8_t *image = (const uint8_t *)_image; /* Pointer into raw data buffer */
|
||||
H5F_superblock_cache_ud_t *udata = (H5F_superblock_cache_ud_t *)_udata; /* User data */
|
||||
unsigned super_vers; /* Superblock version */
|
||||
uint8_t sizeof_addr; /* Size of offsets in the file (in bytes) */
|
||||
uint8_t sizeof_size; /* Size of lengths in the file (in bytes) */
|
||||
size_t variable_size; /* Variable size of superblock */
|
||||
H5F_super_t sblock; /* Temporary file superblock */
|
||||
htri_t ret_value = SUCCEED; /* Return value */
|
||||
|
||||
FUNC_ENTER_STATIC
|
||||
@ -206,56 +363,20 @@ H5F__cache_superblock_get_final_load_size(const void *_image, size_t image_len,
|
||||
/* Check arguments */
|
||||
HDassert(image);
|
||||
HDassert(udata);
|
||||
HDassert(udata->f);
|
||||
HDassert(actual_len);
|
||||
HDassert(*actual_len == image_len);
|
||||
|
||||
/* Skip over file signature */
|
||||
image += H5F_SIGNATURE_LEN;
|
||||
|
||||
/* Superblock version */
|
||||
super_vers = *image++;
|
||||
if(super_vers > HDF5_SUPERBLOCK_VERSION_LATEST)
|
||||
HGOTO_ERROR(H5E_FILE, H5E_BADVALUE, FAIL, "bad superblock version number")
|
||||
|
||||
/* Save the version to be used in verify_chksum callback */
|
||||
udata->super_vers = super_vers;
|
||||
|
||||
/* Sanity check */
|
||||
HDassert(((size_t)(image - (const uint8_t *)_image)) == H5F_SUPERBLOCK_FIXED_SIZE);
|
||||
HDassert(image_len >= H5F_SUPERBLOCK_FIXED_SIZE + 6);
|
||||
|
||||
/* Determine the size of addresses & size of offsets, for computing the
|
||||
* variable-sized portion of the superblock.
|
||||
*/
|
||||
if(super_vers < HDF5_SUPERBLOCK_VERSION_2) {
|
||||
sizeof_addr = image[4];
|
||||
sizeof_size = image[5];
|
||||
} /* end if */
|
||||
else {
|
||||
sizeof_addr = image[0];
|
||||
sizeof_size = image[1];
|
||||
} /* end else */
|
||||
if(sizeof_addr != 2 && sizeof_addr != 4 &&
|
||||
sizeof_addr != 8 && sizeof_addr != 16 && sizeof_addr != 32)
|
||||
HGOTO_ERROR(H5E_FILE, H5E_BADVALUE, FAIL, "bad byte number in an address")
|
||||
if(sizeof_size != 2 && sizeof_size != 4 &&
|
||||
sizeof_size != 8 && sizeof_size != 16 && sizeof_size != 32)
|
||||
HGOTO_ERROR(H5E_FILE, H5E_BADVALUE, FAIL, "bad byte number for object size")
|
||||
/* Deserialize the file superblock's prefix */
|
||||
if(H5F__superblock_prefix_decode(&sblock, &image, udata, TRUE) < 0)
|
||||
HGOTO_ERROR(H5E_FILE, H5E_CANTDECODE, FAIL, "can't decode file superblock prefix")
|
||||
|
||||
/* Determine the size of the variable-length part of the superblock */
|
||||
variable_size = (size_t)H5F_SUPERBLOCK_VARLEN_SIZE(super_vers, sizeof_addr, sizeof_size);
|
||||
HDassert(variable_size > 0);
|
||||
|
||||
/* Sanity check */
|
||||
HDassert(image_len == (H5F_SUPERBLOCK_FIXED_SIZE + H5F_SUPERBLOCK_MINIMAL_VARLEN_SIZE));
|
||||
|
||||
/* Make certain we can read the variable-sized portion of the superblock */
|
||||
if(H5F__set_eoa(udata->f, H5FD_MEM_SUPER, (haddr_t)(H5F_SUPERBLOCK_FIXED_SIZE + variable_size)) < 0)
|
||||
HGOTO_ERROR(H5E_FILE, H5E_CANTINIT, FAIL, "set end of space allocation request failed")
|
||||
/* Save the version to be used in verify_chksum callback */
|
||||
udata->super_vers = sblock.super_vers;
|
||||
|
||||
/* Set the final size for the cache image */
|
||||
*actual_len = H5F_SUPERBLOCK_FIXED_SIZE + variable_size;
|
||||
*actual_len = H5F_SUPERBLOCK_FIXED_SIZE +
|
||||
(size_t)H5F_SUPERBLOCK_VARLEN_SIZE(sblock.super_vers, sblock.sizeof_addr, sblock.sizeof_size);
|
||||
|
||||
done:
|
||||
FUNC_LEAVE_NOAPI(ret_value)
|
||||
@ -325,10 +446,6 @@ H5F__cache_superblock_deserialize(const void *_image, size_t len, void *_udata,
|
||||
H5F_super_t *sblock = NULL; /* File's superblock */
|
||||
H5F_superblock_cache_ud_t *udata = (H5F_superblock_cache_ud_t *)_udata; /* User data */
|
||||
const uint8_t *image = (const uint8_t *)_image; /* Pointer into raw data buffer */
|
||||
size_t variable_size; /* Variable size of superblock */
|
||||
unsigned super_vers; /* Superblock version */
|
||||
uint8_t sizeof_addr; /* Size of offsets in the file (in bytes) */
|
||||
uint8_t sizeof_size; /* Size of lengths in the file (in bytes) */
|
||||
H5F_super_t *ret_value = NULL; /* Return value */
|
||||
|
||||
FUNC_ENTER_STATIC
|
||||
@ -337,54 +454,18 @@ H5F__cache_superblock_deserialize(const void *_image, size_t len, void *_udata,
|
||||
HDassert(image);
|
||||
HDassert(udata);
|
||||
HDassert(udata->f);
|
||||
HDassert(len >= H5F_SUPERBLOCK_FIXED_SIZE + 6);
|
||||
|
||||
/* Allocate space for the superblock */
|
||||
if(NULL == (sblock = H5FL_CALLOC(H5F_super_t)))
|
||||
HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, NULL, "memory allocation failed")
|
||||
|
||||
/* Skip over signature (already checked when locating the superblock) */
|
||||
image += H5F_SIGNATURE_LEN;
|
||||
|
||||
/* Superblock version */
|
||||
super_vers = *image++;
|
||||
if(super_vers > HDF5_SUPERBLOCK_VERSION_LATEST)
|
||||
HGOTO_ERROR(H5E_FILE, H5E_BADVALUE, NULL, "bad superblock version number")
|
||||
|
||||
/* Record the superblock version */
|
||||
sblock->super_vers = super_vers;
|
||||
|
||||
/* Sanity check */
|
||||
HDassert(((size_t)(image - (const uint8_t *)_image)) == H5F_SUPERBLOCK_FIXED_SIZE);
|
||||
HDassert(len >= H5F_SUPERBLOCK_FIXED_SIZE + 6);
|
||||
|
||||
/* Determine the size of addresses & size of offsets, for computing the
|
||||
* variable-sized portion of the superblock.
|
||||
*/
|
||||
if(super_vers < HDF5_SUPERBLOCK_VERSION_2) {
|
||||
sizeof_addr = image[4];
|
||||
sizeof_size = image[5];
|
||||
} /* end if */
|
||||
else {
|
||||
sizeof_addr = image[0];
|
||||
sizeof_size = image[1];
|
||||
} /* end else */
|
||||
if(sizeof_addr != 2 && sizeof_addr != 4 &&
|
||||
sizeof_addr != 8 && sizeof_addr != 16 && sizeof_addr != 32)
|
||||
HGOTO_ERROR(H5E_FILE, H5E_BADVALUE, NULL, "bad byte number in an address")
|
||||
if(sizeof_size != 2 && sizeof_size != 4 &&
|
||||
sizeof_size != 8 && sizeof_size != 16 && sizeof_size != 32)
|
||||
HGOTO_ERROR(H5E_FILE, H5E_BADVALUE, NULL, "bad byte number for object size")
|
||||
sblock->sizeof_addr = sizeof_addr;
|
||||
sblock->sizeof_size = sizeof_size;
|
||||
|
||||
/* Determine the size of the variable-length part of the superblock */
|
||||
variable_size = (size_t)H5F_SUPERBLOCK_VARLEN_SIZE(super_vers, sizeof_addr, sizeof_size);
|
||||
HDassert(variable_size > 0);
|
||||
|
||||
HDassert(len == (H5F_SUPERBLOCK_FIXED_SIZE + variable_size));
|
||||
/* Deserialize the file superblock's prefix */
|
||||
if(H5F__superblock_prefix_decode(sblock, &image, udata, FALSE) < 0)
|
||||
HGOTO_ERROR(H5E_FILE, H5E_CANTDECODE, NULL, "can't decode file superblock prefix")
|
||||
|
||||
/* Check for older version of superblock format */
|
||||
if(super_vers < HDF5_SUPERBLOCK_VERSION_2) {
|
||||
if(sblock->super_vers < HDF5_SUPERBLOCK_VERSION_2) {
|
||||
uint32_t status_flags; /* File status flags */
|
||||
unsigned sym_leaf_k; /* Symbol table leaf node's 'K' value */
|
||||
unsigned snode_btree_k; /* B-tree symbol table internal node 'K' value */
|
||||
@ -405,21 +486,13 @@ H5F__cache_superblock_deserialize(const void *_image, size_t len, void *_udata,
|
||||
if(HDF5_SHAREDHEADER_VERSION != *image++)
|
||||
HGOTO_ERROR(H5E_FILE, H5E_BADVALUE, NULL, "bad shared-header format version number")
|
||||
|
||||
/* Size of file addresses */
|
||||
sizeof_addr = *image++;
|
||||
if(sizeof_addr != 2 && sizeof_addr != 4 &&
|
||||
sizeof_addr != 8 && sizeof_addr != 16 && sizeof_addr != 32)
|
||||
HGOTO_ERROR(H5E_FILE, H5E_BADVALUE, NULL, "bad byte number in an address")
|
||||
sblock->sizeof_addr = sizeof_addr;
|
||||
udata->f->shared->sizeof_addr = sizeof_addr; /* Keep a local copy also */
|
||||
/* Skip over size of file addresses (already decoded) */
|
||||
image++;
|
||||
udata->f->shared->sizeof_addr = sblock->sizeof_addr; /* Keep a local copy also */
|
||||
|
||||
/* Size of file sizes */
|
||||
sizeof_size = *image++;
|
||||
if(sizeof_size != 2 && sizeof_size != 4 &&
|
||||
sizeof_size != 8 && sizeof_size != 16 && sizeof_size != 32)
|
||||
HGOTO_ERROR(H5E_FILE, H5E_BADVALUE, NULL, "bad byte number for object size")
|
||||
sblock->sizeof_size = sizeof_size;
|
||||
udata->f->shared->sizeof_size = sizeof_size; /* Keep a local copy also */
|
||||
/* Skip over size of file sizes (already decoded) */
|
||||
image++;
|
||||
udata->f->shared->sizeof_size = sblock->sizeof_size; /* Keep a local copy also */
|
||||
|
||||
/* Skip over reserved byte */
|
||||
image++;
|
||||
@ -452,11 +525,11 @@ H5F__cache_superblock_deserialize(const void *_image, size_t len, void *_udata,
|
||||
* If the superblock version # is greater than 0, read in the indexed
|
||||
* storage B-tree internal 'K' value
|
||||
*/
|
||||
if(super_vers > HDF5_SUPERBLOCK_VERSION_DEF) {
|
||||
if(sblock->super_vers > HDF5_SUPERBLOCK_VERSION_DEF) {
|
||||
UINT16DECODE(image, chunk_btree_k);
|
||||
|
||||
/* Reserved bytes are present only in version 1 */
|
||||
if(super_vers == HDF5_SUPERBLOCK_VERSION_1)
|
||||
if(sblock->super_vers == HDF5_SUPERBLOCK_VERSION_1)
|
||||
image += 2; /* reserved */
|
||||
} /* end if */
|
||||
else
|
||||
@ -498,21 +571,13 @@ H5F__cache_superblock_deserialize(const void *_image, size_t len, void *_udata,
|
||||
else {
|
||||
uint32_t read_chksum; /* Checksum read from file */
|
||||
|
||||
/* Size of file addresses */
|
||||
sizeof_addr = *image++;
|
||||
if(sizeof_addr != 2 && sizeof_addr != 4 &&
|
||||
sizeof_addr != 8 && sizeof_addr != 16 && sizeof_addr != 32)
|
||||
HGOTO_ERROR(H5E_FILE, H5E_BADVALUE, NULL, "bad byte number in an address")
|
||||
sblock->sizeof_addr = sizeof_addr;
|
||||
udata->f->shared->sizeof_addr = sizeof_addr; /* Keep a local copy also */
|
||||
/* Skip over size of file addresses (already decoded) */
|
||||
image++;
|
||||
udata->f->shared->sizeof_addr = sblock->sizeof_addr; /* Keep a local copy also */
|
||||
|
||||
/* Size of file sizes */
|
||||
sizeof_size = *image++;
|
||||
if(sizeof_size != 2 && sizeof_size != 4 &&
|
||||
sizeof_size != 8 && sizeof_size != 16 && sizeof_size != 32)
|
||||
HGOTO_ERROR(H5E_FILE, H5E_BADVALUE, NULL, "bad byte number for object size")
|
||||
sblock->sizeof_size = sizeof_size;
|
||||
udata->f->shared->sizeof_size = sizeof_size; /* Keep a local copy also */
|
||||
/* Skip over size of file sizes (already decoded) */
|
||||
image++;
|
||||
udata->f->shared->sizeof_size = sblock->sizeof_size; /* Keep a local copy also */
|
||||
|
||||
/* File status flags (not really used yet) */
|
||||
sblock->status_flags = *image++;
|
||||
@ -588,7 +653,7 @@ H5F__cache_superblock_image_len(const void *_thing, size_t *image_len)
|
||||
|
||||
|
||||
/*-------------------------------------------------------------------------
|
||||
* Function: H5FS__cache_hdf_pre_serialize
|
||||
* Function: H5FS__cache_superblock_pre_serialize
|
||||
*
|
||||
* Purpose: The current use of this function is a cludge to repair an
|
||||
* oversight in the conversion of the superblock code to use the
|
||||
@ -927,50 +992,24 @@ H5F__cache_drvrinfo_get_final_load_size(const void *_image, size_t image_len,
|
||||
{
|
||||
const uint8_t *image = (const uint8_t *)_image; /* Pointer into raw data buffer */
|
||||
H5F_drvrinfo_cache_ud_t *udata = (H5F_drvrinfo_cache_ud_t *)_udata; /* User data */
|
||||
unsigned drv_vers; /* Version of driver info block */
|
||||
size_t drvinfo_len; /* Length of encoded buffer */
|
||||
haddr_t eoa; /* Current EOA for the file */
|
||||
haddr_t min_eoa; /* Minimum EOA needed for reading the driver info */
|
||||
htri_t ret_value = SUCCEED; /* Return value */
|
||||
H5O_drvinfo_t drvrinfo; /* Driver info */
|
||||
herr_t ret_value = SUCCEED; /* Return value */
|
||||
|
||||
FUNC_ENTER_STATIC
|
||||
|
||||
/* Check arguments */
|
||||
HDassert(image);
|
||||
HDassert(udata);
|
||||
HDassert(udata->f);
|
||||
HDassert(actual_len);
|
||||
HDassert(*actual_len == image_len);
|
||||
|
||||
/* Version number */
|
||||
drv_vers = *image++;
|
||||
if(drv_vers != HDF5_DRIVERINFO_VERSION_0)
|
||||
HGOTO_ERROR(H5E_FILE, H5E_BADVALUE, FAIL, "bad driver information block version number")
|
||||
|
||||
image += 3; /* reserved bytes */
|
||||
|
||||
/* Driver info size */
|
||||
UINT32DECODE(image, drvinfo_len);
|
||||
|
||||
/* Sanity check */
|
||||
HDassert(image_len == H5F_DRVINFOBLOCK_HDR_SIZE);
|
||||
|
||||
/* Extend the EOA if required so that we can read the complete driver info block */
|
||||
|
||||
/* Get current EOA... */
|
||||
if((eoa = H5FD_get_eoa(udata->f->shared->lf, H5FD_MEM_SUPER)) == HADDR_UNDEF)
|
||||
HGOTO_ERROR(H5E_FILE, H5E_CANTGET, FAIL, "driver get_eoa request failed")
|
||||
|
||||
/* ... if it is too small, extend it. */
|
||||
min_eoa = udata->driver_addr + H5F_DRVINFOBLOCK_HDR_SIZE + drvinfo_len;
|
||||
|
||||
/* If it grew, set it */
|
||||
if(H5F_addr_gt(min_eoa, eoa))
|
||||
if(H5FD_set_eoa(udata->f->shared->lf, H5FD_MEM_SUPER, min_eoa) < 0)
|
||||
HGOTO_ERROR(H5E_FILE, H5E_CANTINIT, FAIL, "set end of space allocation request failed")
|
||||
/* Deserialize the file driver info's prefix */
|
||||
if(H5F__drvrinfo_prefix_decode(&drvrinfo, NULL, &image, udata, TRUE) < 0)
|
||||
HGOTO_ERROR(H5E_FILE, H5E_CANTDECODE, FAIL, "can't decode file driver info prefix")
|
||||
|
||||
/* Set the final size for the cache image */
|
||||
*actual_len = H5F_DRVINFOBLOCK_HDR_SIZE + drvinfo_len;
|
||||
*actual_len = H5F_DRVINFOBLOCK_HDR_SIZE + drvrinfo.len;
|
||||
|
||||
done:
|
||||
FUNC_LEAVE_NOAPI(ret_value)
|
||||
@ -999,7 +1038,6 @@ H5F__cache_drvrinfo_deserialize(const void *_image, size_t len, void *_udata,
|
||||
H5F_drvrinfo_cache_ud_t *udata = (H5F_drvrinfo_cache_ud_t *)_udata; /* User data */
|
||||
const uint8_t *image = (const uint8_t *)_image; /* Pointer into raw data buffer */
|
||||
char drv_name[9]; /* Name of driver */
|
||||
unsigned drv_vers; /* Version of driver info block */
|
||||
H5O_drvinfo_t *ret_value = NULL; /* Return value */
|
||||
|
||||
FUNC_ENTER_STATIC
|
||||
@ -1014,21 +1052,11 @@ H5F__cache_drvrinfo_deserialize(const void *_image, size_t len, void *_udata,
|
||||
if(NULL == (drvinfo = (H5O_drvinfo_t *)H5MM_calloc(sizeof(H5O_drvinfo_t))))
|
||||
HGOTO_ERROR(H5E_FILE, H5E_CANTALLOC, NULL, "memory allocation failed for driver info message")
|
||||
|
||||
/* Version number */
|
||||
drv_vers = *image++;
|
||||
if(drv_vers != HDF5_DRIVERINFO_VERSION_0)
|
||||
HGOTO_ERROR(H5E_FILE, H5E_BADVALUE, NULL, "bad driver information block version number")
|
||||
|
||||
image += 3; /* reserved bytes */
|
||||
|
||||
/* Driver info size */
|
||||
UINT32DECODE(image, drvinfo->len);
|
||||
|
||||
/* Driver name and/or version */
|
||||
HDstrncpy(drv_name, (const char *)image, (size_t)8);
|
||||
drv_name[8] = '\0';
|
||||
image += 8; /* advance past name/version */
|
||||
/* Deserialize the file driver info's prefix */
|
||||
if(H5F__drvrinfo_prefix_decode(drvinfo, drv_name, &image, udata, FALSE) < 0)
|
||||
HGOTO_ERROR(H5E_FILE, H5E_CANTDECODE, NULL, "can't decode file driver info prefix")
|
||||
|
||||
/* Sanity check */
|
||||
HDassert(len == (H5F_DRVINFOBLOCK_HDR_SIZE + drvinfo->len));
|
||||
|
||||
/* Validate and decode driver information */
|
||||
|
@ -69,6 +69,7 @@
|
||||
/********************/
|
||||
|
||||
/* Local encode/decode routines */
|
||||
static herr_t H5HF__hdr_prefix_decode(H5HF_hdr_t *hdr, const uint8_t **image_ref);
|
||||
static herr_t H5HF__dtable_encode(H5F_t *f, uint8_t **pp, const H5HF_dtable_t *dtable);
|
||||
static herr_t H5HF__dtable_decode(H5F_t *f, const uint8_t **pp, H5HF_dtable_t *dtable);
|
||||
|
||||
@ -198,6 +199,52 @@ const H5AC_class_t H5AC_FHEAP_DBLOCK[1] = {{
|
||||
H5FL_BLK_DEFINE(direct_block);
|
||||
|
||||
|
||||
|
||||
/*-------------------------------------------------------------------------
|
||||
* Function: H5HF__hdr_prefix_decode()
|
||||
*
|
||||
* Purpose: Decode a fractal heap header's prefix
|
||||
*
|
||||
* Return: Success: SUCCEED
|
||||
* Failure: FAIL
|
||||
*
|
||||
* Programmer: Quincey Koziol
|
||||
* December 15, 2016
|
||||
*
|
||||
*-------------------------------------------------------------------------
|
||||
*/
|
||||
static herr_t
|
||||
H5HF__hdr_prefix_decode(H5HF_hdr_t *hdr, const uint8_t **image_ref)
|
||||
{
|
||||
const uint8_t *image = *image_ref; /* Pointer into into supplied image */
|
||||
herr_t ret_value = SUCCEED; /* Return value */
|
||||
|
||||
FUNC_ENTER_STATIC
|
||||
|
||||
/* Sanity checks */
|
||||
HDassert(hdr);
|
||||
HDassert(image);
|
||||
|
||||
/* Magic number */
|
||||
if(HDmemcmp(image, H5HF_HDR_MAGIC, (size_t)H5_SIZEOF_MAGIC))
|
||||
HGOTO_ERROR(H5E_HEAP, H5E_BADVALUE, FAIL, "wrong fractal heap header signature")
|
||||
image += H5_SIZEOF_MAGIC;
|
||||
|
||||
/* Version */
|
||||
if(*image++ != H5HF_HDR_VERSION)
|
||||
HGOTO_ERROR(H5E_HEAP, H5E_VERSION, FAIL, "wrong fractal heap header version")
|
||||
|
||||
/* General heap information */
|
||||
UINT16DECODE(image, hdr->id_len); /* Heap ID length */
|
||||
UINT16DECODE(image, hdr->filter_len); /* I/O filters' encoded length */
|
||||
|
||||
/* Update the image buffer pointer */
|
||||
*image_ref = image;
|
||||
|
||||
done:
|
||||
FUNC_LEAVE_NOAPI(ret_value)
|
||||
} /* end H5HF__hdr_prefix_decode() */
|
||||
|
||||
|
||||
/*-------------------------------------------------------------------------
|
||||
* Function: H5HF__dtable_decode
|
||||
@ -360,10 +407,10 @@ static herr_t
|
||||
H5HF__cache_hdr_get_final_load_size(const void *_image, size_t image_len,
|
||||
void *_udata, size_t *actual_len)
|
||||
{
|
||||
const uint8_t *image = (const uint8_t *)_image; /* Pointer into raw data buffer */
|
||||
H5HF_hdr_cache_ud_t *udata = (H5HF_hdr_cache_ud_t *)_udata; /* pointer to user data */
|
||||
unsigned filter_len; /* Size of I/O filter information (in bytes) */
|
||||
htri_t ret_value = SUCCEED; /* Return value */
|
||||
H5HF_hdr_t hdr; /* Temporary fractal heap header */
|
||||
const uint8_t *image = (const uint8_t *)_image; /* Pointer into into supplied image */
|
||||
H5HF_hdr_cache_ud_t *udata = (H5HF_hdr_cache_ud_t *)_udata; /* User data for callback */
|
||||
herr_t ret_value = SUCCEED; /* Return value */
|
||||
|
||||
FUNC_ENTER_STATIC
|
||||
|
||||
@ -373,25 +420,16 @@ H5HF__cache_hdr_get_final_load_size(const void *_image, size_t image_len,
|
||||
HDassert(actual_len);
|
||||
HDassert(*actual_len == image_len);
|
||||
|
||||
/* Magic number */
|
||||
if(HDmemcmp(image, H5HF_HDR_MAGIC, (size_t)H5_SIZEOF_MAGIC))
|
||||
HGOTO_ERROR(H5E_HEAP, H5E_BADVALUE, FAIL, "wrong fractal heap header signature")
|
||||
image += H5_SIZEOF_MAGIC;
|
||||
|
||||
/* Version */
|
||||
if(*image++ != H5HF_HDR_VERSION)
|
||||
HGOTO_ERROR(H5E_HEAP, H5E_VERSION, FAIL, "wrong fractal heap header version")
|
||||
|
||||
/* General heap information */
|
||||
image += 2; /* Heap ID length */
|
||||
UINT16DECODE(image, filter_len); /* I/O filters' encoded length */
|
||||
/* Deserialize the fractal heap header's prefix */
|
||||
if(H5HF__hdr_prefix_decode(&hdr, &image) < 0)
|
||||
HGOTO_ERROR(H5E_HEAP, H5E_CANTDECODE, FAIL, "can't decode fractal heap header prefix")
|
||||
|
||||
/* Check for I/O filter info on this heap */
|
||||
if(filter_len > 0)
|
||||
if(hdr.filter_len > 0)
|
||||
/* Compute the extra heap header size */
|
||||
*actual_len += (size_t)(H5F_SIZEOF_SIZE(udata->f) /* Size of size for filtered root direct block */
|
||||
+ (unsigned)4 /* Size of filter mask for filtered root direct block */
|
||||
+ filter_len); /* Size of encoded I/O filter info */
|
||||
+ hdr.filter_len); /* Size of encoded I/O filter info */
|
||||
|
||||
done:
|
||||
FUNC_LEAVE_NOAPI(ret_value)
|
||||
@ -473,18 +511,9 @@ H5HF__cache_hdr_deserialize(const void *_image, size_t len, void *_udata,
|
||||
if(NULL == (hdr = H5HF_hdr_alloc(udata->f)))
|
||||
HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, NULL, "memory allocation failed")
|
||||
|
||||
/* Magic number */
|
||||
if(HDmemcmp(image, H5HF_HDR_MAGIC, (size_t)H5_SIZEOF_MAGIC))
|
||||
HGOTO_ERROR(H5E_HEAP, H5E_BADVALUE, NULL, "wrong fractal heap header signature")
|
||||
image += H5_SIZEOF_MAGIC;
|
||||
|
||||
/* Version */
|
||||
if(*image++ != H5HF_HDR_VERSION)
|
||||
HGOTO_ERROR(H5E_HEAP, H5E_VERSION, NULL, "wrong fractal heap header version")
|
||||
|
||||
/* General heap information */
|
||||
UINT16DECODE(image, hdr->id_len); /* Heap ID length */
|
||||
UINT16DECODE(image, hdr->filter_len); /* I/O filters' encoded length */
|
||||
/* Deserialize the fractal heap header's prefix */
|
||||
if(H5HF__hdr_prefix_decode(hdr, &image) < 0)
|
||||
HGOTO_ERROR(H5E_HEAP, H5E_CANTDECODE, NULL, "can't decode fractal heap header prefix")
|
||||
|
||||
/* Heap status flags */
|
||||
/* (bit 0: "huge" object IDs have wrapped) */
|
||||
@ -1618,10 +1647,6 @@ H5HF__cache_dblock_verify_chksum(const void *_image, size_t len, void *_udata)
|
||||
hdr = par_info->hdr;
|
||||
HDassert(hdr);
|
||||
|
||||
/* Reset callback context info */
|
||||
udata->decompressed = FALSE;
|
||||
udata->dblk = NULL;
|
||||
|
||||
/* Get out if data block is not checksummed */
|
||||
if(!(hdr->checksum_dblocks))
|
||||
HGOTO_DONE(TRUE);
|
||||
@ -1728,7 +1753,7 @@ H5HF__cache_dblock_deserialize(const void *_image, size_t len, void *_udata,
|
||||
H5HF_dblock_cache_ud_t *udata = (H5HF_dblock_cache_ud_t *)_udata; /* User data for callback */
|
||||
H5HF_parent_t *par_info; /* Pointer to parent information */
|
||||
H5HF_direct_t *dblock = NULL; /* Direct block info */
|
||||
const uint8_t *image = _image;/* Pointer into raw data buffer */
|
||||
const uint8_t *image = (const uint8_t *)_image;/* Pointer into raw data buffer */
|
||||
void *read_buf = NULL; /* Pointer to buffer to decompress */
|
||||
haddr_t heap_addr; /* Address of heap header in the file */
|
||||
void * ret_value = NULL; /* Return value */
|
||||
|
@ -493,6 +493,10 @@ H5HF_man_dblock_protect(H5HF_hdr_t *hdr, hid_t dxpl_id, haddr_t dblock_addr,
|
||||
udata.filter_mask = 0;
|
||||
} /* end else */
|
||||
|
||||
/* Reset compression context info */
|
||||
udata.decompressed = FALSE;
|
||||
udata.dblk = NULL;
|
||||
|
||||
/* Protect the direct block */
|
||||
if(NULL == (dblock = (H5HF_direct_t *)H5AC_protect(hdr->f, dxpl_id, H5AC_FHEAP_DBLOCK, dblock_addr, &udata, flags)))
|
||||
HGOTO_ERROR(H5E_HEAP, H5E_CANTPROTECT, NULL, "unable to protect fractal heap direct block")
|
||||
|
108
src/H5HGcache.c
108
src/H5HGcache.c
@ -72,6 +72,10 @@ static herr_t H5HG__cache_heap_serialize(const H5F_t *f, void *image,
|
||||
size_t len, void *thing);
|
||||
static herr_t H5HG__cache_heap_free_icr(void *thing);
|
||||
|
||||
/* Prefix deserialization */
|
||||
static herr_t H5HG__hdr_deserialize(H5HG_heap_t *heap, const uint8_t *image,
|
||||
const H5F_t *f);
|
||||
|
||||
|
||||
/*********************/
|
||||
/* Package Variables */
|
||||
@ -106,6 +110,52 @@ const H5AC_class_t H5AC_GHEAP[1] = {{
|
||||
/*******************/
|
||||
|
||||
|
||||
|
||||
/*-------------------------------------------------------------------------
|
||||
* Function: H5HG__hdr_deserialize()
|
||||
*
|
||||
* Purpose: Decode a global heap's header
|
||||
*
|
||||
* Return: Success: SUCCEED
|
||||
* Failure: FAIL
|
||||
*
|
||||
* Programmer: Quincey Koziol
|
||||
* December 15, 2016
|
||||
*
|
||||
*-------------------------------------------------------------------------
|
||||
*/
|
||||
static herr_t
|
||||
H5HG__hdr_deserialize(H5HG_heap_t *heap, const uint8_t *image, const H5F_t *f)
|
||||
{
|
||||
herr_t ret_value = SUCCEED; /* Return value */
|
||||
|
||||
FUNC_ENTER_STATIC
|
||||
|
||||
/* Sanity check */
|
||||
HDassert(heap);
|
||||
HDassert(image);
|
||||
HDassert(f);
|
||||
|
||||
/* Magic number */
|
||||
if(HDmemcmp(image, H5HG_MAGIC, (size_t)H5_SIZEOF_MAGIC))
|
||||
HGOTO_ERROR(H5E_HEAP, H5E_BADVALUE, FAIL, "bad global heap collection signature")
|
||||
image += H5_SIZEOF_MAGIC;
|
||||
|
||||
/* Version */
|
||||
if(H5HG_VERSION != *image++)
|
||||
HGOTO_ERROR(H5E_HEAP, H5E_VERSION, FAIL, "wrong version number in global heap")
|
||||
|
||||
/* Reserved */
|
||||
image += 3;
|
||||
|
||||
/* Size */
|
||||
H5F_DECODE_LENGTH(f, image, heap->size);
|
||||
HDassert(heap->size >= H5HG_MINSIZE);
|
||||
|
||||
done:
|
||||
FUNC_LEAVE_NOAPI(ret_value)
|
||||
} /* end H5HG__hdr_deserialize() */
|
||||
|
||||
|
||||
/*-------------------------------------------------------------------------
|
||||
* Function: H5HG__cache_heap_get_initial_load_size()
|
||||
@ -154,41 +204,27 @@ H5HG__cache_heap_get_initial_load_size(void H5_ATTR_UNUSED *_udata, size_t *imag
|
||||
*-------------------------------------------------------------------------
|
||||
*/
|
||||
static herr_t
|
||||
H5HG__cache_heap_get_final_load_size(const void *_image, size_t image_len,
|
||||
void *_udata, size_t *actual_len)
|
||||
H5HG__cache_heap_get_final_load_size(const void *image, size_t image_len,
|
||||
void *udata, size_t *actual_len)
|
||||
{
|
||||
const uint8_t *image = (const uint8_t *)_image; /* Pointer into raw data buffer */
|
||||
H5F_t *f = (H5F_t *)_udata; /* File pointer -- obtained from user data */
|
||||
size_t heap_size = 0; /* Total size of collection */
|
||||
herr_t ret_value = SUCCEED; /* Return value */
|
||||
H5HG_heap_t heap; /* Global heap */
|
||||
herr_t ret_value = SUCCEED; /* Return value */
|
||||
|
||||
FUNC_ENTER_STATIC
|
||||
|
||||
/* Sanity check */
|
||||
HDassert(image);
|
||||
HDassert(f);
|
||||
HDassert(udata);
|
||||
HDassert(actual_len);
|
||||
HDassert(*actual_len == image_len);
|
||||
|
||||
/* Magic number */
|
||||
if(HDmemcmp(image, H5HG_MAGIC, (size_t)H5_SIZEOF_MAGIC))
|
||||
HGOTO_ERROR(H5E_HEAP, H5E_BADVALUE, FAIL, "bad global heap collection signature")
|
||||
image += H5_SIZEOF_MAGIC;
|
||||
|
||||
/* Version */
|
||||
if(H5HG_VERSION != *image++)
|
||||
HGOTO_ERROR(H5E_HEAP, H5E_VERSION, FAIL, "wrong version number in global heap")
|
||||
|
||||
/* Reserved */
|
||||
image += 3;
|
||||
|
||||
/* Size */
|
||||
H5F_DECODE_LENGTH(f, image, heap_size);
|
||||
HDassert(heap_size >= H5HG_MINSIZE);
|
||||
HDassert(image_len == H5HG_MINSIZE);
|
||||
|
||||
/* Deserialize the heap's header */
|
||||
if(H5HG__hdr_deserialize(&heap, (const uint8_t *)image, (const H5F_t *)udata) < 0)
|
||||
HGOTO_ERROR(H5E_HEAP, H5E_CANTDECODE, FAIL, "can't decode global heap prefix")
|
||||
|
||||
/* Set the final size for the cache image */
|
||||
*actual_len = heap_size;
|
||||
*actual_len = heap.size;
|
||||
|
||||
done:
|
||||
FUNC_LEAVE_NOAPI(ret_value)
|
||||
@ -236,29 +272,13 @@ H5HG__cache_heap_deserialize(const void *_image, size_t len, void *_udata,
|
||||
if(NULL == (heap->chunk = H5FL_BLK_MALLOC(gheap_chunk, len)))
|
||||
HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, NULL, "memory allocation failed")
|
||||
|
||||
/* copy the image buffer into the newly allocate chunk */
|
||||
/* Copy the image buffer into the newly allocate chunk */
|
||||
HDmemcpy(heap->chunk, _image, len);
|
||||
|
||||
image = heap->chunk;
|
||||
/* Deserialize the heap's header */
|
||||
if(H5HG__hdr_deserialize(heap, (const uint8_t *)heap->chunk, f) < 0)
|
||||
HGOTO_ERROR(H5E_HEAP, H5E_CANTDECODE, NULL, "can't decode global heap header")
|
||||
|
||||
/* Magic number */
|
||||
if(HDmemcmp(image, H5HG_MAGIC, (size_t)H5_SIZEOF_MAGIC))
|
||||
HGOTO_ERROR(H5E_HEAP, H5E_CANTLOAD, NULL, "bad global heap collection signature")
|
||||
image += H5_SIZEOF_MAGIC;
|
||||
|
||||
/* Version */
|
||||
if(H5HG_VERSION != *image++)
|
||||
HGOTO_ERROR(H5E_HEAP, H5E_CANTLOAD, NULL, "wrong version number in global heap")
|
||||
|
||||
/* Reserved */
|
||||
image += 3;
|
||||
|
||||
/* Size */
|
||||
H5F_DECODE_LENGTH(f, image, heap->size);
|
||||
HDassert(heap->size >= H5HG_MINSIZE);
|
||||
HDassert((len == H5HG_MINSIZE) /* first try */ ||
|
||||
((len == heap->size) && (len > H5HG_MINSIZE))); /* second try */
|
||||
|
||||
/* Decode each object */
|
||||
image = heap->chunk + H5HG_SIZEOF_HDR(f);
|
||||
nalloc = H5HG_NOBJS(f, heap->size);
|
||||
|
122
src/H5HLcache.c
122
src/H5HLcache.c
@ -91,6 +91,10 @@ static herr_t H5HL__cache_datablock_serialize(const H5F_t *f, void *image,
|
||||
static herr_t H5HL__cache_datablock_notify(H5C_notify_action_t action, void *_thing);
|
||||
static herr_t H5HL__cache_datablock_free_icr(void *thing);
|
||||
|
||||
/* Header deserialization */
|
||||
static herr_t H5HL__hdr_deserialize(H5HL_t *heap, const uint8_t *image,
|
||||
H5HL_cache_prfx_ud_t *udata);
|
||||
|
||||
/* Free list de/serialization */
|
||||
static herr_t H5HL__fl_deserialize(H5HL_t *heap);
|
||||
static void H5HL__fl_serialize(const H5HL_t *heap);
|
||||
@ -145,6 +149,64 @@ const H5AC_class_t H5AC_LHEAP_DBLK[1] = {{
|
||||
/*******************/
|
||||
|
||||
|
||||
|
||||
/*-------------------------------------------------------------------------
|
||||
* Function: H5HL__hdr_deserialize()
|
||||
*
|
||||
* Purpose: Decode a local heap's header
|
||||
*
|
||||
* Return: Success: SUCCEED
|
||||
* Failure: FAIL
|
||||
*
|
||||
* Programmer: Quincey Koziol
|
||||
* December 15, 2016
|
||||
*
|
||||
*-------------------------------------------------------------------------
|
||||
*/
|
||||
static herr_t
|
||||
H5HL__hdr_deserialize( H5HL_t *heap, const uint8_t *image,
|
||||
H5HL_cache_prfx_ud_t *udata)
|
||||
{
|
||||
herr_t ret_value = SUCCEED; /* Return value */
|
||||
|
||||
FUNC_ENTER_STATIC
|
||||
|
||||
/* Sanity checks */
|
||||
HDassert(heap);
|
||||
HDassert(image);
|
||||
HDassert(udata);
|
||||
|
||||
/* Check magic number */
|
||||
if(HDmemcmp(image, H5HL_MAGIC, (size_t)H5_SIZEOF_MAGIC))
|
||||
HGOTO_ERROR(H5E_HEAP, H5E_BADVALUE, FAIL, "bad local heap signature")
|
||||
image += H5_SIZEOF_MAGIC;
|
||||
|
||||
/* Version */
|
||||
if(H5HL_VERSION != *image++)
|
||||
HGOTO_ERROR(H5E_HEAP, H5E_VERSION, FAIL, "wrong version number in local heap")
|
||||
|
||||
/* Reserved */
|
||||
image += 3;
|
||||
|
||||
/* Store the prefix's address & length */
|
||||
heap->prfx_addr = udata->prfx_addr;
|
||||
heap->prfx_size = udata->sizeof_prfx;
|
||||
|
||||
/* Heap data size */
|
||||
H5F_DECODE_LENGTH_LEN(image, heap->dblk_size, udata->sizeof_size);
|
||||
|
||||
/* Free list head */
|
||||
H5F_DECODE_LENGTH_LEN(image, heap->free_block, udata->sizeof_size);
|
||||
if(heap->free_block != H5HL_FREE_NULL && heap->free_block >= heap->dblk_size)
|
||||
HGOTO_ERROR(H5E_HEAP, H5E_BADVALUE, FAIL, "bad heap free list")
|
||||
|
||||
/* Heap data address */
|
||||
H5F_addr_decode_len(udata->sizeof_addr, &image, &(heap->dblk_addr));
|
||||
|
||||
done:
|
||||
FUNC_LEAVE_NOAPI(ret_value)
|
||||
} /* end H5HL__hdr_deserialize() */
|
||||
|
||||
|
||||
/*-------------------------------------------------------------------------
|
||||
* Function: H5HL__fl_deserialize
|
||||
@ -319,32 +381,9 @@ H5HL__cache_prefix_get_final_load_size(const void *_image, size_t image_len,
|
||||
HDassert(actual_len);
|
||||
HDassert(*actual_len == image_len);
|
||||
|
||||
/* Check magic number */
|
||||
if(HDmemcmp(image, H5HL_MAGIC, (size_t)H5_SIZEOF_MAGIC))
|
||||
HGOTO_ERROR(H5E_HEAP, H5E_BADVALUE, FAIL, "bad local heap signature")
|
||||
image += H5_SIZEOF_MAGIC;
|
||||
|
||||
/* Version */
|
||||
if(H5HL_VERSION != *image++)
|
||||
HGOTO_ERROR(H5E_HEAP, H5E_VERSION, FAIL, "wrong version number in local heap")
|
||||
|
||||
/* Reserved */
|
||||
image += 3;
|
||||
|
||||
/* Store the prefix's address & length */
|
||||
heap.prfx_addr = udata->prfx_addr; /* NEED */
|
||||
heap.prfx_size = udata->sizeof_prfx; /* NEED */
|
||||
|
||||
/* Heap data size */
|
||||
H5F_DECODE_LENGTH_LEN(image, heap.dblk_size, udata->sizeof_size); /* NEED */
|
||||
|
||||
/* Free list head */
|
||||
H5F_DECODE_LENGTH_LEN(image, heap.free_block, udata->sizeof_size);
|
||||
if(heap.free_block != H5HL_FREE_NULL && heap.free_block >= heap.dblk_size)
|
||||
HGOTO_ERROR(H5E_HEAP, H5E_BADVALUE, FAIL, "bad heap free list");
|
||||
|
||||
/* Heap data address */
|
||||
H5F_addr_decode_len(udata->sizeof_addr, &image, &(heap.dblk_addr)); /* NEED */
|
||||
/* Deserialize the heap's header */
|
||||
if(H5HL__hdr_deserialize(&heap, (const uint8_t *)image, udata) < 0)
|
||||
HGOTO_ERROR(H5E_HEAP, H5E_CANTDECODE, FAIL, "can't decode local heap header")
|
||||
|
||||
/* Set the final size for the cache image */
|
||||
*actual_len = heap.prfx_size;
|
||||
@ -398,41 +437,18 @@ H5HL__cache_prefix_deserialize(const void *_image, size_t len, void *_udata,
|
||||
HDassert(H5F_addr_defined(udata->prfx_addr));
|
||||
HDassert(dirty);
|
||||
|
||||
/* Check magic number */
|
||||
if(HDmemcmp(image, H5HL_MAGIC, (size_t)H5_SIZEOF_MAGIC))
|
||||
HGOTO_ERROR(H5E_HEAP, H5E_BADVALUE, NULL, "bad local heap signature")
|
||||
image += H5_SIZEOF_MAGIC;
|
||||
|
||||
/* Version */
|
||||
if(H5HL_VERSION != *image++)
|
||||
HGOTO_ERROR(H5E_HEAP, H5E_BADVALUE, NULL, "wrong version number in local heap")
|
||||
|
||||
/* Reserved */
|
||||
image += 3;
|
||||
|
||||
/* Allocate space in memory for the heap */
|
||||
if(NULL == (heap = H5HL__new(udata->sizeof_size, udata->sizeof_addr, udata->sizeof_prfx)))
|
||||
HGOTO_ERROR(H5E_HEAP, H5E_CANTALLOC, NULL, "can't allocate local heap structure");
|
||||
|
||||
/* Deserialize the heap's header */
|
||||
if(H5HL__hdr_deserialize(heap, (const uint8_t *)image, udata) < 0)
|
||||
HGOTO_ERROR(H5E_HEAP, H5E_CANTDECODE, NULL, "can't decode local heap header")
|
||||
|
||||
/* Allocate the heap prefix */
|
||||
if(NULL == (prfx = H5HL__prfx_new(heap)))
|
||||
HGOTO_ERROR(H5E_HEAP, H5E_CANTALLOC, NULL, "can't allocate local heap prefix");
|
||||
|
||||
/* Store the prefix's address & length */
|
||||
heap->prfx_addr = udata->prfx_addr;
|
||||
heap->prfx_size = udata->sizeof_prfx;
|
||||
|
||||
/* Heap data size */
|
||||
H5F_DECODE_LENGTH_LEN(image, heap->dblk_size, udata->sizeof_size);
|
||||
|
||||
/* Free list head */
|
||||
H5F_DECODE_LENGTH_LEN(image, heap->free_block, udata->sizeof_size);
|
||||
if((heap->free_block != H5HL_FREE_NULL) && (heap->free_block >= heap->dblk_size))
|
||||
HGOTO_ERROR(H5E_HEAP, H5E_BADVALUE, NULL, "bad heap free list")
|
||||
|
||||
/* Heap data address */
|
||||
H5F_addr_decode_len(udata->sizeof_addr, &image, &(heap->dblk_addr));
|
||||
|
||||
/* Check if heap block exists */
|
||||
if(heap->dblk_size) {
|
||||
/* Check if heap data block is contiguous with header */
|
||||
|
324
src/H5Ocache.c
324
src/H5Ocache.c
@ -84,6 +84,10 @@ static herr_t H5O__cache_chk_serialize(const H5F_t *f, void *image, size_t len,
|
||||
static herr_t H5O__cache_chk_notify(H5AC_notify_action_t action, void *_thing);
|
||||
static herr_t H5O__cache_chk_free_icr(void *thing);
|
||||
|
||||
/* Prefix routines */
|
||||
static herr_t H5O__prefix_deserialize(const uint8_t *image,
|
||||
H5O_cache_ud_t *udata);
|
||||
|
||||
/* Chunk routines */
|
||||
static herr_t H5O__chunk_deserialize(H5O_t *oh, haddr_t addr, size_t len,
|
||||
const uint8_t *image, H5O_common_cache_ud_t *udata, hbool_t *dirty);
|
||||
@ -198,13 +202,11 @@ H5O__cache_get_initial_load_size(void H5_ATTR_UNUSED *_udata, size_t *image_len)
|
||||
*-------------------------------------------------------------------------
|
||||
*/
|
||||
static herr_t
|
||||
H5O__cache_get_final_load_size(const void *_image, size_t image_len,
|
||||
H5O__cache_get_final_load_size(const void *image, size_t image_len,
|
||||
void *_udata, size_t *actual_len)
|
||||
{
|
||||
const uint8_t *image = (const uint8_t *)_image; /* Pointer into raw data buffer */
|
||||
H5O_cache_ud_t *udata = (H5O_cache_ud_t *)_udata; /* User data for callback */
|
||||
H5O_t *oh = NULL; /* Object header read in */
|
||||
htri_t ret_value = SUCCEED; /* Return value */
|
||||
herr_t ret_value = SUCCEED; /* Return value */
|
||||
|
||||
FUNC_ENTER_STATIC
|
||||
|
||||
@ -214,136 +216,17 @@ H5O__cache_get_final_load_size(const void *_image, size_t image_len,
|
||||
HDassert(actual_len);
|
||||
HDassert(*actual_len == image_len);
|
||||
|
||||
/* Allocate space for the new object header data structure */
|
||||
if(NULL == (oh = H5FL_CALLOC(H5O_t)))
|
||||
HGOTO_ERROR(H5E_OHDR, H5E_CANTALLOC, FAIL, "memory allocation failed")
|
||||
/* Deserialize the object header prefix */
|
||||
if(H5O__prefix_deserialize((const uint8_t *)image, udata) < 0)
|
||||
HGOTO_ERROR(H5E_OHDR, H5E_CANTDECODE, FAIL, "can't deserialize object header prefix")
|
||||
|
||||
/* File-specific, non-stored information */
|
||||
oh->sizeof_size = H5F_SIZEOF_SIZE(udata->common.f);
|
||||
oh->sizeof_addr = H5F_SIZEOF_ADDR(udata->common.f);
|
||||
|
||||
/* Check for presence of magic number */
|
||||
/* (indicates version 2 or later) */
|
||||
if(!HDmemcmp(image, H5O_HDR_MAGIC, (size_t)H5_SIZEOF_MAGIC)) {
|
||||
/* Magic number */
|
||||
image += H5_SIZEOF_MAGIC;
|
||||
|
||||
/* Version */
|
||||
oh->version = *image++;
|
||||
if(H5O_VERSION_2 != oh->version)
|
||||
HGOTO_ERROR(H5E_OHDR, H5E_VERSION, FAIL, "bad object header version number")
|
||||
|
||||
/* Flags */
|
||||
oh->flags = *image++;
|
||||
if(oh->flags & ~H5O_HDR_ALL_FLAGS)
|
||||
HGOTO_ERROR(H5E_OHDR, H5E_BADVALUE, FAIL, "unknown object header status flag(s)")
|
||||
|
||||
/* Number of links to object (unless overridden by refcount message) */
|
||||
oh->nlink = 1;
|
||||
|
||||
/* Time fields */
|
||||
if(oh->flags & H5O_HDR_STORE_TIMES) {
|
||||
uint32_t tmp; /* Temporary value */
|
||||
|
||||
UINT32DECODE(image, tmp);
|
||||
oh->atime = (time_t)tmp;
|
||||
UINT32DECODE(image, tmp);
|
||||
oh->mtime = (time_t)tmp;
|
||||
UINT32DECODE(image, tmp);
|
||||
oh->ctime = (time_t)tmp;
|
||||
UINT32DECODE(image, tmp);
|
||||
oh->btime = (time_t)tmp;
|
||||
} /* end if */
|
||||
else
|
||||
oh->atime = oh->mtime = oh->ctime = oh->btime = 0;
|
||||
|
||||
/* Attribute fields */
|
||||
if(oh->flags & H5O_HDR_ATTR_STORE_PHASE_CHANGE) {
|
||||
UINT16DECODE(image, oh->max_compact);
|
||||
UINT16DECODE(image, oh->min_dense);
|
||||
if(oh->max_compact < oh->min_dense)
|
||||
HGOTO_ERROR(H5E_OHDR, H5E_BADVALUE, FAIL, "bad object header attribute phase change values")
|
||||
} /* end if */
|
||||
else {
|
||||
oh->max_compact = H5O_CRT_ATTR_MAX_COMPACT_DEF;
|
||||
oh->min_dense = H5O_CRT_ATTR_MIN_DENSE_DEF;
|
||||
} /* end else */
|
||||
|
||||
/* First chunk size */
|
||||
switch(oh->flags & H5O_HDR_CHUNK0_SIZE) {
|
||||
case 0: /* 1 byte size */
|
||||
udata->chunk0_size = *image++;
|
||||
break;
|
||||
|
||||
case 1: /* 2 byte size */
|
||||
UINT16DECODE(image, udata->chunk0_size);
|
||||
break;
|
||||
|
||||
case 2: /* 4 byte size */
|
||||
UINT32DECODE(image, udata->chunk0_size);
|
||||
break;
|
||||
|
||||
case 3: /* 8 byte size */
|
||||
UINT64DECODE(image, udata->chunk0_size);
|
||||
break;
|
||||
|
||||
default:
|
||||
HGOTO_ERROR(H5E_OHDR, H5E_BADVALUE, FAIL, "bad size for chunk 0")
|
||||
} /* end switch */
|
||||
if(udata->chunk0_size > 0 && udata->chunk0_size < H5O_SIZEOF_MSGHDR_OH(oh))
|
||||
HGOTO_ERROR(H5E_OHDR, H5E_BADVALUE, FAIL, "bad object header chunk size")
|
||||
} /* end if */
|
||||
else {
|
||||
/* Version */
|
||||
oh->version = *image++;
|
||||
if(H5O_VERSION_1 != oh->version)
|
||||
HGOTO_ERROR(H5E_OHDR, H5E_VERSION, FAIL, "bad object header version number")
|
||||
|
||||
/* Flags */
|
||||
oh->flags = H5O_CRT_OHDR_FLAGS_DEF;
|
||||
|
||||
/* Reserved */
|
||||
image++;
|
||||
|
||||
/* Number of messages */
|
||||
UINT16DECODE(image, udata->v1_pfx_nmesgs);
|
||||
|
||||
/* Link count */
|
||||
UINT32DECODE(image, oh->nlink);
|
||||
|
||||
/* Reset unused time fields */
|
||||
oh->atime = oh->mtime = oh->ctime = oh->btime = 0;
|
||||
|
||||
/* Reset unused attribute fields */
|
||||
oh->max_compact = 0;
|
||||
oh->min_dense = 0;
|
||||
|
||||
/* First chunk size */
|
||||
UINT32DECODE(image, udata->chunk0_size);
|
||||
if((udata->v1_pfx_nmesgs > 0 && udata->chunk0_size < H5O_SIZEOF_MSGHDR_OH(oh)) ||
|
||||
(udata->v1_pfx_nmesgs == 0 && udata->chunk0_size > 0))
|
||||
HGOTO_ERROR(H5E_OHDR, H5E_BADVALUE, FAIL, "bad object header chunk size")
|
||||
|
||||
/* Reserved, in version 1 (for 8-byte alignment padding) */
|
||||
image += 4;
|
||||
} /* end else */
|
||||
|
||||
/* Determine object header prefix length */
|
||||
HDassert((size_t)((const uint8_t *)image - (const uint8_t *)_image) == (size_t)(H5O_SIZEOF_HDR(oh) - H5O_SIZEOF_CHKSUM_OH(oh)));
|
||||
/* Sanity check */
|
||||
HDassert(udata->oh);
|
||||
|
||||
/* Set the final size for the cache image */
|
||||
*actual_len = udata->chunk0_size + (size_t)H5O_SIZEOF_HDR(oh);
|
||||
|
||||
/* Save the object header for later use in 'deserialize' callback */
|
||||
udata->oh = oh;
|
||||
oh = NULL;
|
||||
*actual_len = udata->chunk0_size + (size_t)H5O_SIZEOF_HDR(udata->oh);
|
||||
|
||||
done:
|
||||
/* Release the [possibly partially initialized] object header on errors */
|
||||
if(ret_value < 0 && oh)
|
||||
if(H5O__free(oh) < 0)
|
||||
HDONE_ERROR(H5E_OHDR, H5E_CANTRELEASE, FAIL, "unable to destroy object header data")
|
||||
|
||||
FUNC_LEAVE_NOAPI(ret_value)
|
||||
} /* end H5O__cache_get_final_load_size() */
|
||||
|
||||
@ -413,12 +296,11 @@ H5O__cache_verify_chksum(const void *_image, size_t len, void *_udata)
|
||||
*-------------------------------------------------------------------------
|
||||
*/
|
||||
static void *
|
||||
H5O__cache_deserialize(const void *_image, size_t len, void *_udata,
|
||||
H5O__cache_deserialize(const void *image, size_t len, void *_udata,
|
||||
hbool_t *dirty)
|
||||
{
|
||||
H5O_t *oh; /* Object header read in */
|
||||
H5O_t *oh = NULL; /* Object header read in */
|
||||
H5O_cache_ud_t *udata = (H5O_cache_ud_t *)_udata; /* User data for callback */
|
||||
const uint8_t *image = (const uint8_t *)_image; /* Pointer into buffer to decode */
|
||||
void * ret_value = NULL; /* Return value */
|
||||
|
||||
FUNC_ENTER_STATIC
|
||||
@ -427,11 +309,24 @@ H5O__cache_deserialize(const void *_image, size_t len, void *_udata,
|
||||
HDassert(image);
|
||||
HDassert(len > 0);
|
||||
HDassert(udata);
|
||||
HDassert(udata->oh);
|
||||
HDassert(udata->common.f);
|
||||
HDassert(udata->common.cont_msg_info);
|
||||
HDassert(dirty);
|
||||
|
||||
/* Check for partially deserialized object header */
|
||||
/* (Object header prefix will be deserialized if the object header came
|
||||
* through the 'get_final_load_size' callback and not deserialized if
|
||||
* the object header is coming from a cache image - QAK, 2016/12/14)
|
||||
*/
|
||||
if(NULL == udata->oh) {
|
||||
/* Deserialize the object header prefix */
|
||||
if(H5O__prefix_deserialize((const uint8_t *)image, udata) < 0)
|
||||
HGOTO_ERROR(H5E_OHDR, H5E_CANTDECODE, NULL, "can't deserialize object header prefix")
|
||||
|
||||
/* Sanity check */
|
||||
HDassert(udata->oh);
|
||||
} /* end if */
|
||||
|
||||
/* Retrieve partially deserialized object header from user data */
|
||||
oh = udata->oh;
|
||||
|
||||
@ -448,7 +343,7 @@ H5O__cache_deserialize(const void *_image, size_t len, void *_udata,
|
||||
oh->proxy = NULL;
|
||||
|
||||
/* Parse the first chunk */
|
||||
if(H5O__chunk_deserialize(oh, udata->common.addr, udata->chunk0_size, (const uint8_t *)_image, &(udata->common), dirty) < 0)
|
||||
if(H5O__chunk_deserialize(oh, udata->common.addr, udata->chunk0_size, (const uint8_t *)image, &(udata->common), dirty) < 0)
|
||||
HGOTO_ERROR(H5E_OHDR, H5E_CANTINIT, NULL, "can't deserialize first object header chunk")
|
||||
|
||||
/* Note that we've loaded the object header from the file */
|
||||
@ -717,11 +612,7 @@ H5O__cache_notify(H5AC_notify_action_t action, void *_thing)
|
||||
break;
|
||||
|
||||
default:
|
||||
#ifdef NDEBUG
|
||||
HGOTO_ERROR(H5E_OHDR, H5E_BADVALUE, FAIL, "unknown action from metadata cache")
|
||||
#else /* NDEBUG */
|
||||
HDassert(0 && "Unknown action?!?");
|
||||
#endif /* NDEBUG */
|
||||
} /* end switch */
|
||||
|
||||
done:
|
||||
@ -1226,6 +1117,163 @@ done:
|
||||
FUNC_LEAVE_NOAPI(ret_value)
|
||||
} /* H5O__add_cont_msg() */
|
||||
|
||||
|
||||
/*-------------------------------------------------------------------------
|
||||
* Function: H5O__prefix_deserialize()
|
||||
*
|
||||
* Purpose: Deserialize an object header prefix
|
||||
*
|
||||
* Return: Success: SUCCEED
|
||||
* Failure: FAIL
|
||||
*
|
||||
* Programmer: Quincey Koziol
|
||||
* December 14, 2016
|
||||
*
|
||||
*-------------------------------------------------------------------------
|
||||
*/
|
||||
static herr_t
|
||||
H5O__prefix_deserialize(const uint8_t *_image, H5O_cache_ud_t *udata)
|
||||
{
|
||||
const uint8_t *image = (const uint8_t *)_image; /* Pointer into raw data buffer */
|
||||
H5O_t *oh = NULL; /* Object header read in */
|
||||
herr_t ret_value = SUCCEED; /* Return value */
|
||||
|
||||
FUNC_ENTER_STATIC
|
||||
|
||||
/* Check arguments */
|
||||
HDassert(image);
|
||||
HDassert(udata);
|
||||
|
||||
/* Allocate space for the new object header data structure */
|
||||
if(NULL == (oh = H5FL_CALLOC(H5O_t)))
|
||||
HGOTO_ERROR(H5E_OHDR, H5E_CANTALLOC, FAIL, "memory allocation failed")
|
||||
|
||||
/* File-specific, non-stored information */
|
||||
oh->sizeof_size = H5F_SIZEOF_SIZE(udata->common.f);
|
||||
oh->sizeof_addr = H5F_SIZEOF_ADDR(udata->common.f);
|
||||
|
||||
/* Check for presence of magic number */
|
||||
/* (indicates version 2 or later) */
|
||||
if(!HDmemcmp(image, H5O_HDR_MAGIC, (size_t)H5_SIZEOF_MAGIC)) {
|
||||
/* Magic number */
|
||||
image += H5_SIZEOF_MAGIC;
|
||||
|
||||
/* Version */
|
||||
oh->version = *image++;
|
||||
if(H5O_VERSION_2 != oh->version)
|
||||
HGOTO_ERROR(H5E_OHDR, H5E_VERSION, FAIL, "bad object header version number")
|
||||
|
||||
/* Flags */
|
||||
oh->flags = *image++;
|
||||
if(oh->flags & ~H5O_HDR_ALL_FLAGS)
|
||||
HGOTO_ERROR(H5E_OHDR, H5E_BADVALUE, FAIL, "unknown object header status flag(s)")
|
||||
|
||||
/* Number of links to object (unless overridden by refcount message) */
|
||||
oh->nlink = 1;
|
||||
|
||||
/* Time fields */
|
||||
if(oh->flags & H5O_HDR_STORE_TIMES) {
|
||||
uint32_t tmp; /* Temporary value */
|
||||
|
||||
UINT32DECODE(image, tmp);
|
||||
oh->atime = (time_t)tmp;
|
||||
UINT32DECODE(image, tmp);
|
||||
oh->mtime = (time_t)tmp;
|
||||
UINT32DECODE(image, tmp);
|
||||
oh->ctime = (time_t)tmp;
|
||||
UINT32DECODE(image, tmp);
|
||||
oh->btime = (time_t)tmp;
|
||||
} /* end if */
|
||||
else
|
||||
oh->atime = oh->mtime = oh->ctime = oh->btime = 0;
|
||||
|
||||
/* Attribute fields */
|
||||
if(oh->flags & H5O_HDR_ATTR_STORE_PHASE_CHANGE) {
|
||||
UINT16DECODE(image, oh->max_compact);
|
||||
UINT16DECODE(image, oh->min_dense);
|
||||
if(oh->max_compact < oh->min_dense)
|
||||
HGOTO_ERROR(H5E_OHDR, H5E_BADVALUE, FAIL, "bad object header attribute phase change values")
|
||||
} /* end if */
|
||||
else {
|
||||
oh->max_compact = H5O_CRT_ATTR_MAX_COMPACT_DEF;
|
||||
oh->min_dense = H5O_CRT_ATTR_MIN_DENSE_DEF;
|
||||
} /* end else */
|
||||
|
||||
/* First chunk size */
|
||||
switch(oh->flags & H5O_HDR_CHUNK0_SIZE) {
|
||||
case 0: /* 1 byte size */
|
||||
udata->chunk0_size = *image++;
|
||||
break;
|
||||
|
||||
case 1: /* 2 byte size */
|
||||
UINT16DECODE(image, udata->chunk0_size);
|
||||
break;
|
||||
|
||||
case 2: /* 4 byte size */
|
||||
UINT32DECODE(image, udata->chunk0_size);
|
||||
break;
|
||||
|
||||
case 3: /* 8 byte size */
|
||||
UINT64DECODE(image, udata->chunk0_size);
|
||||
break;
|
||||
|
||||
default:
|
||||
HGOTO_ERROR(H5E_OHDR, H5E_BADVALUE, FAIL, "bad size for chunk 0")
|
||||
} /* end switch */
|
||||
if(udata->chunk0_size > 0 && udata->chunk0_size < H5O_SIZEOF_MSGHDR_OH(oh))
|
||||
HGOTO_ERROR(H5E_OHDR, H5E_BADVALUE, FAIL, "bad object header chunk size")
|
||||
} /* end if */
|
||||
else {
|
||||
/* Version */
|
||||
oh->version = *image++;
|
||||
if(H5O_VERSION_1 != oh->version)
|
||||
HGOTO_ERROR(H5E_OHDR, H5E_VERSION, FAIL, "bad object header version number")
|
||||
|
||||
/* Flags */
|
||||
oh->flags = H5O_CRT_OHDR_FLAGS_DEF;
|
||||
|
||||
/* Reserved */
|
||||
image++;
|
||||
|
||||
/* Number of messages */
|
||||
UINT16DECODE(image, udata->v1_pfx_nmesgs);
|
||||
|
||||
/* Link count */
|
||||
UINT32DECODE(image, oh->nlink);
|
||||
|
||||
/* Reset unused time fields */
|
||||
oh->atime = oh->mtime = oh->ctime = oh->btime = 0;
|
||||
|
||||
/* Reset unused attribute fields */
|
||||
oh->max_compact = 0;
|
||||
oh->min_dense = 0;
|
||||
|
||||
/* First chunk size */
|
||||
UINT32DECODE(image, udata->chunk0_size);
|
||||
if((udata->v1_pfx_nmesgs > 0 && udata->chunk0_size < H5O_SIZEOF_MSGHDR_OH(oh)) ||
|
||||
(udata->v1_pfx_nmesgs == 0 && udata->chunk0_size > 0))
|
||||
HGOTO_ERROR(H5E_OHDR, H5E_BADVALUE, FAIL, "bad object header chunk size")
|
||||
|
||||
/* Reserved, in version 1 (for 8-byte alignment padding) */
|
||||
image += 4;
|
||||
} /* end else */
|
||||
|
||||
/* Verify object header prefix length */
|
||||
HDassert((size_t)(image - _image) == (size_t)(H5O_SIZEOF_HDR(oh) - H5O_SIZEOF_CHKSUM_OH(oh)));
|
||||
|
||||
/* Save the object header for later use in 'deserialize' callback */
|
||||
udata->oh = oh;
|
||||
oh = NULL;
|
||||
|
||||
done:
|
||||
/* Release the [possibly partially initialized] object header on errors */
|
||||
if(ret_value < 0 && oh)
|
||||
if(H5O__free(oh) < 0)
|
||||
HDONE_ERROR(H5E_OHDR, H5E_CANTRELEASE, FAIL, "unable to destroy object header data")
|
||||
|
||||
FUNC_LEAVE_NOAPI(ret_value)
|
||||
} /* end H5O__prefix_deserialize() */
|
||||
|
||||
|
||||
/*-------------------------------------------------------------------------
|
||||
* Function: H5O__chunk_deserialize
|
||||
|
Loading…
Reference in New Issue
Block a user