From cdcd2cecf2efae22173c4a26e5ee587c04303a9f Mon Sep 17 00:00:00 2001 From: James Laird Date: Wed, 24 Jan 2007 14:01:48 -0500 Subject: [svn-r13187] Fixed another issue with H5Ocopy when attributes had shared datatypes/ dataspaces that became un-shared in the destination. Tested on Windows, smirom, and kagiso. Need to extend objcopy test so that it checks that attributes are actually copied successfully. --- src/H5Oattr.c | 17 ++++++++++++++++- src/H5Ocopy.c | 10 +++++----- src/H5Odbg.c | 25 +++++++++++++------------ 3 files changed, 34 insertions(+), 18 deletions(-) diff --git a/src/H5Oattr.c b/src/H5Oattr.c index 35a4785..7ec3217 100644 --- a/src/H5Oattr.c +++ b/src/H5Oattr.c @@ -965,12 +965,27 @@ H5O_attr_copy_file(H5F_t *file_src, const H5O_msg_class_t UNUSED *mesg_type, /* Copy the shared object from source to destination */ if(H5O_copy_header_map(src_oloc, dst_oloc, dxpl_id, cpy_info, FALSE) < 0) HGOTO_ERROR(H5E_OHDR, H5E_CANTCOPY, NULL, "unable to copy object") - } /* end if */ + } else { + /* If the datatype is not named, it may have been shared in the + * source file's heap. Un-share it for now. We'll try to shared + * it in the destination file below. + */ + if(H5O_msg_reset_share(H5O_DTYPE_ID, attr_dst->dt) < 0) + HGOTO_ERROR(H5E_OHDR, H5E_CANTINIT, NULL, "unable to reset datatype sharing") + } + /* end if */ /* Copy the dataspace for the attribute */ attr_dst->ds = H5S_copy(attr_src->ds, FALSE); HDassert(attr_dst->ds); + /* Reset the dataspace's sharing in the source file before trying to share + * it in the destination. + */ + if(H5O_msg_reset_share(H5O_SDSPACE_ID, attr_dst->ds) < 0) + HGOTO_ERROR(H5E_OHDR, H5E_CANTINIT, NULL, "unable to reset dataspace sharing") + + /* Try to share both the datatype and dataset. This does nothing if the * datatype is committed or sharing is disabled. */ diff --git a/src/H5Ocopy.c b/src/H5Ocopy.c index d4a0aec..f88e9cf 100644 --- a/src/H5Ocopy.c +++ b/src/H5Ocopy.c @@ -585,12 +585,12 @@ H5O_copy_header_real(const H5O_loc_t *oloc_src, H5O_loc_t *oloc_dst /*out */, current_pos = oh_dst->chunk[0].image; - /* Copy the header. Most of this (number of messages, etc.) will be - * overwritten when the header is flushed to disk, but later versions have - * a magic number that isn't. + /* Write the magic number for versions > 1 and skip the rest of the + * header. This will be written when the header is flushed to disk. */ - HDmemcpy(current_pos, oh_src->chunk[0].image, - (size_t)(H5O_SIZEOF_HDR(oh_dst) - H5O_SIZEOF_CHKSUM_OH(oh_dst))); + if(oh_dst->version > H5O_VERSION_1) + HDmemcpy(current_pos, H5O_HDR_MAGIC, H5O_SIZEOF_MAGIC); + current_pos += H5O_SIZEOF_HDR(oh_dst) - H5O_SIZEOF_CHKSUM_OH(oh_dst); /* Copy each message that wasn't dirtied above */ diff --git a/src/H5Odbg.c b/src/H5Odbg.c index 5682957..13428cf 100644 --- a/src/H5Odbg.c +++ b/src/H5Odbg.c @@ -248,8 +248,7 @@ H5O_debug_real(H5F_t *f, hid_t dxpl_id, H5O_t *oh, haddr_t addr, FILE *stream, i unsigned i, chunkno; size_t mesg_total = 0, chunk_total = 0; int *sequence; - void *(*decode)(H5F_t*, hid_t, const uint8_t*); - herr_t (*debug)(H5F_t*, hid_t, const void*, FILE*, int, int)=NULL; + const H5O_msg_class_t *debug_type; /* Type of message to use for callbacks */ herr_t ret_value = SUCCEED; FUNC_ENTER_NOAPI(H5O_debug_real, FAIL) @@ -412,22 +411,18 @@ H5O_debug_real(H5F_t *f, hid_t dxpl_id, H5O_t *oh, haddr_t addr, FILE *stream, i /* decode the message */ if((oh->mesg[i].flags & H5O_MSG_FLAG_SHARED) && !H5O_NEW_SHARED(oh->mesg[i].type)) { - decode = H5O_MSG_SHARED->decode; - debug = H5O_MSG_SHARED->debug; + debug_type = H5O_MSG_SHARED; } else { - decode = oh->mesg[i].type->decode; - debug = oh->mesg[i].type->debug; + debug_type = oh->mesg[i].type; } /* end else */ - if(NULL==oh->mesg[i].native && decode) - oh->mesg[i].native = (decode)(f, dxpl_id, oh->mesg[i].raw); - if(NULL == oh->mesg[i].native) - debug = NULL; + if(NULL==oh->mesg[i].native && debug_type->decode) + oh->mesg[i].native = (debug_type->decode)(f, dxpl_id, oh->mesg[i].flags, oh->mesg[i].raw); /* print the message */ HDfprintf(stream, "%*s%-*s\n", indent + 3, "", MAX(0, fwidth - 3), "Message Information:"); - if(debug) - (debug)(f, dxpl_id, oh->mesg[i].native, stream, indent + 6, MAX(0, fwidth - 6)); + if(debug_type->debug && oh->mesg[i].native != NULL) + (debug_type->debug)(f, dxpl_id, oh->mesg[i].native, stream, indent + 6, MAX(0, fwidth - 6)); else HDfprintf(stream, "%*s\n", indent + 6, ""); @@ -444,6 +439,12 @@ H5O_debug_real(H5F_t *f, hid_t dxpl_id, H5O_t *oh, haddr_t addr, FILE *stream, i } /* end for */ sequence = H5MM_xfree(sequence); + /* Chunk 0 has header information. Count this in the size of the chunk + * when we check its size below. + */ + if(chunkno == 0) + mesg_total += H5O_SIZEOF_HDR(oh); + if(mesg_total != chunk_total) HDfprintf(stream, "*** TOTAL SIZE DOES NOT MATCH ALLOCATED SIZE!\n"); -- cgit v0.12