diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/H5Oattr.c | 27 | ||||
-rw-r--r-- | src/H5Odtype.c | 13 | ||||
-rw-r--r-- | src/H5Oefl.c | 56 | ||||
-rw-r--r-- | src/H5Olayout.c | 33 | ||||
-rw-r--r-- | src/H5Osdspace.c | 36 | ||||
-rw-r--r-- | src/H5Oshared.c | 24 |
6 files changed, 150 insertions, 39 deletions
diff --git a/src/H5Oattr.c b/src/H5Oattr.c index 6021802..99551ee 100644 --- a/src/H5Oattr.c +++ b/src/H5Oattr.c @@ -51,6 +51,8 @@ const H5O_class_t H5O_ATTR[1] = {{ H5O_attr_debug, /* debug the message */ }}; +#define H5O_ATTR_VERSION 1 + /* Interface initialization */ static hbool_t interface_initialize_g = FALSE; #define INTERFACE_INIT NULL @@ -76,6 +78,9 @@ static hbool_t interface_initialize_g = FALSE; * Modifications: * Robb Matzke, 17 Jul 1998 * Added padding for alignment. + * + * Robb Matzke, 20 Jul 1998 + * Added a version number at the beginning. --------------------------------------------------------------------------*/ static void * H5O_attr_decode(H5F_t *f, const uint8 *p, H5O_shared_t __unused__ *sh) @@ -83,6 +88,7 @@ H5O_attr_decode(H5F_t *f, const uint8 *p, H5O_shared_t __unused__ *sh) H5A_t *attr = NULL; H5S_simple_t *simple; /*simple dimensionality information */ size_t name_len; /*attribute name length */ + intn version; /*message version number*/ FUNC_ENTER(H5O_attr_decode, NULL); @@ -95,6 +101,16 @@ H5O_attr_decode(H5F_t *f, const uint8 *p, H5O_shared_t __unused__ *sh) "memory allocation failed"); } + /* Version number */ + version = *p++; + if (version!=H5O_ATTR_VERSION) { + HRETURN_ERROR(H5E_OHDR, H5E_CANTLOAD, NULL, + "bad version number for attribute message"); + } + + /* Reserved */ + p++; + /* * Decode the sizes of the parts of the attribute. The sizes stored in * the file are exact but the parts are aligned on 8-byte boundaries. @@ -102,7 +118,6 @@ H5O_attr_decode(H5F_t *f, const uint8 *p, H5O_shared_t __unused__ *sh) UINT16DECODE(p, name_len); /*including null*/ UINT16DECODE(p, attr->dt_size); UINT16DECODE(p, attr->ds_size); - p += 2; /*reserved*/ /* Decode and store the name */ if (NULL==(attr->name=H5MM_malloc(name_len))) { @@ -175,6 +190,9 @@ H5O_attr_decode(H5F_t *f, const uint8 *p, H5O_shared_t __unused__ *sh) * Modifications: * Robb Matzke, 17 Jul 1998 * Added padding for alignment. + * + * Robb Matzke, 20 Jul 1998 + * Added a version number at the beginning. --------------------------------------------------------------------------*/ static herr_t H5O_attr_encode(H5F_t *f, uint8 *p, const void *mesg) @@ -189,6 +207,12 @@ H5O_attr_encode(H5F_t *f, uint8 *p, const void *mesg) assert(p); assert(attr); + /* Version */ + *p++ = H5O_ATTR_VERSION; + + /* Reserved */ + *p++ = 0; + /* * Encode the lengths of the various parts of the attribute message. The * encoded lengths are exact but we pad each part except the data to be a @@ -198,7 +222,6 @@ H5O_attr_encode(H5F_t *f, uint8 *p, const void *mesg) UINT16ENCODE(p, name_len); UINT16ENCODE(p, attr->dt_size); UINT16ENCODE(p, attr->ds_size); - UINT16ENCODE(p, 0); /*reserved*/ /* * Write the name including null terminator padded to the correct number diff --git a/src/H5Odtype.c b/src/H5Odtype.c index c890a03..8e44223 100644 --- a/src/H5Odtype.c +++ b/src/H5Odtype.c @@ -55,6 +55,8 @@ const H5O_class_t H5O_DTYPE[1] = {{ H5O_dtype_debug, /* debug the message */ }}; +#define H5O_DTYPE_VERSION 1 + /* Interface initialization */ static hbool_t interface_initialize_g = FALSE; #define INTERFACE_INIT NULL @@ -78,7 +80,7 @@ static hbool_t interface_initialize_g = FALSE; static herr_t H5O_dtype_decode_helper(const uint8 **pp, H5T_t *dt) { - uintn flags, perm_word; + uintn flags, perm_word, version; intn i, j; FUNC_ENTER(H5O_dtype_decode_helper, FAIL); @@ -89,7 +91,12 @@ H5O_dtype_decode_helper(const uint8 **pp, H5T_t *dt) /* decode */ UINT32DECODE(*pp, flags); - dt->type = (H5T_class_t)(flags & 0xff); + version = (flags>>4) & 0x0f; + if (version!=H5O_DTYPE_VERSION) { + HRETURN_ERROR(H5E_DATATYPE, H5E_CANTLOAD, FAIL, + "bad version number for data type message"); + } + dt->type = (H5T_class_t)(flags & 0x0f); flags >>= 8; UINT32DECODE(*pp, dt->size); @@ -455,7 +462,7 @@ H5O_dtype_encode_helper(uint8 **pp, const H5T_t *dt) break; } - *hdr++ = dt->type; + *hdr++ = ((uintn)(dt->type) & 0x0f) | (H5O_DTYPE_VERSION<<4); *hdr++ = (flags >> 0) & 0xff; *hdr++ = (flags >> 8) & 0xff; *hdr++ = (flags >> 16) & 0xff; diff --git a/src/H5Oefl.c b/src/H5Oefl.c index 94e2650..442b7b4 100644 --- a/src/H5Oefl.c +++ b/src/H5Oefl.c @@ -37,6 +37,8 @@ const H5O_class_t H5O_EFL[1] = {{ H5O_efl_debug, /*debug the message */ }}; +#define H5O_EFL_VERSION 1 + /* Interface initialization */ static hbool_t interface_initialize_g = FALSE; #define INTERFACE_INIT NULL @@ -56,14 +58,16 @@ static hbool_t interface_initialize_g = FALSE; * Tuesday, November 25, 1997 * * Modifications: - * + * Robb Matzke, 1998-07-20 + * Rearranged the message to add a version number near the beginning. + * *------------------------------------------------------------------------- */ static void * H5O_efl_decode(H5F_t *f, const uint8 *p, H5O_shared_t __unused__ *sh) { H5O_efl_t *mesg = NULL; - int i; + intn i, version; const char *s = NULL; FUNC_ENTER(H5O_efl_decode, NULL); @@ -73,22 +77,34 @@ H5O_efl_decode(H5F_t *f, const uint8 *p, H5O_shared_t __unused__ *sh) assert(p); assert (!sh); - /* Decode the header */ if (NULL==(mesg = H5MM_calloc(sizeof(H5O_efl_t)))) { HRETURN_ERROR (H5E_RESOURCE, H5E_NOSPACE, NULL, "memory allocation failed"); } + + /* Version */ + version = *p++; + if (version!=H5O_EFL_VERSION) { + HRETURN_ERROR(H5E_OHDR, H5E_CANTLOAD, NULL, + "bad version number for external file list message"); + } + + /* Reserved */ + p += 3; + + /* Number of slots */ + UINT16DECODE(p, mesg->nalloc); + assert(mesg->nalloc>0); + UINT16DECODE(p, mesg->nused); + assert(mesg->nused <= mesg->nalloc); + + /* Heap address */ H5F_addr_decode(f, &p, &(mesg->heap_addr)); #ifndef NDEBUG assert (H5F_addr_defined (&(mesg->heap_addr))); s = H5HL_peek (f, &(mesg->heap_addr), 0); assert (s && !*s); #endif - UINT16DECODE(p, mesg->nalloc); - assert(mesg->nalloc>0); - UINT16DECODE(p, mesg->nused); - assert(mesg->nused <= mesg->nalloc); - p += 4; /*reserved*/ /* Decode the file list */ mesg->slot = H5MM_calloc(mesg->nalloc*sizeof(H5O_efl_entry_t)); @@ -128,7 +144,9 @@ H5O_efl_decode(H5F_t *f, const uint8 *p, H5O_shared_t __unused__ *sh) * Tuesday, November 25, 1997 * * Modifications: - * + * Robb Matzke, 1998-07-20 + * Rearranged the message to add a version number near the beginning. + * *------------------------------------------------------------------------- */ static herr_t @@ -146,17 +164,23 @@ H5O_efl_encode(H5F_t *f, uint8 *p, const void *_mesg) assert(mesg); assert(p); - /* Encode header */ - assert (H5F_addr_defined (&(mesg->heap_addr))); - H5F_addr_encode(f, &p, &(mesg->heap_addr)); + /* Version */ + *p++ = H5O_EFL_VERSION; + + /* Reserved */ + *p++ = 0; + *p++ = 0; + *p++ = 0; + + /* Number of slots */ assert (mesg->nalloc>0); UINT16ENCODE(p, mesg->nused); /*yes, twice*/ assert (mesg->nused>0 && mesg->nused<=mesg->nalloc); UINT16ENCODE(p, mesg->nused); - *p++ = 0; - *p++ = 0; - *p++ = 0; - *p++ = 0; + + /* Heap address */ + assert (H5F_addr_defined (&(mesg->heap_addr))); + H5F_addr_encode(f, &p, &(mesg->heap_addr)); /* Encode file list */ for (i=0; i<mesg->nused; i++) { diff --git a/src/H5Olayout.c b/src/H5Olayout.c index 3c534fa..f6ca222 100644 --- a/src/H5Olayout.c +++ b/src/H5Olayout.c @@ -36,6 +36,8 @@ const H5O_class_t H5O_LAYOUT[1] = {{ H5O_layout_debug, /*debug the message */ }}; +#define H5O_LAYOUT_VERSION 1 + /* Interface initialization */ #define PABLO_MASK H5O_layout_mask static hbool_t interface_initialize_g = FALSE; @@ -56,6 +58,8 @@ static hbool_t interface_initialize_g = FALSE; * Wednesday, October 8, 1997 * * Modifications: + * Robb Matzke, 1998-07-20 + * Rearranged the message to add a version number at the beginning. * *------------------------------------------------------------------------- */ @@ -63,7 +67,7 @@ static void * H5O_layout_decode(H5F_t *f, const uint8 *p, H5O_shared_t __unused__ *sh) { H5O_layout_t *mesg = NULL; - intn i; + intn i, version; FUNC_ENTER(H5O_layout_decode, NULL); @@ -77,7 +81,15 @@ H5O_layout_decode(H5F_t *f, const uint8 *p, H5O_shared_t __unused__ *sh) HRETURN_ERROR (H5E_RESOURCE, H5E_NOSPACE, NULL, "memory allocation failed"); } - H5F_addr_decode(f, &p, &(mesg->addr)); + + /* Version */ + version = *p++; + if (version!=H5O_LAYOUT_VERSION) { + HRETURN_ERROR(H5E_OHDR, H5E_CANTLOAD, NULL, + "bad version number for layout message"); + } + + /* Dimensionality */ mesg->ndims = *p++; /* Layout class */ @@ -85,7 +97,10 @@ H5O_layout_decode(H5F_t *f, const uint8 *p, H5O_shared_t __unused__ *sh) assert(H5D_CONTIGUOUS == mesg->type || H5D_CHUNKED == mesg->type); /* Reserved bytes */ - p += 6; + p += 5; + + /* Address */ + H5F_addr_decode(f, &p, &(mesg->addr)); /* Read the size */ for (i = 0; i < mesg->ndims; i++) { @@ -108,6 +123,8 @@ H5O_layout_decode(H5F_t *f, const uint8 *p, H5O_shared_t __unused__ *sh) * Wednesday, October 8, 1997 * * Modifications: + * Robb Matzke, 1998-07-20 + * Rearranged the message to add a version number at the beginning. * *------------------------------------------------------------------------- */ @@ -125,8 +142,8 @@ H5O_layout_encode(H5F_t *f, uint8 *p, const void *_mesg) assert(mesg->ndims > 0 && mesg->ndims <= H5O_LAYOUT_NDIMS); assert(p); - /* data or B-tree address */ - H5F_addr_encode(f, &p, &(mesg->addr)); + /* Version */ + *p++ = H5O_LAYOUT_VERSION; /* number of dimensions */ *p++ = mesg->ndims; @@ -135,8 +152,10 @@ H5O_layout_encode(H5F_t *f, uint8 *p, const void *_mesg) *p++ = mesg->type; /* reserved bytes should be zero */ - for (i = 0; i < 6; i++) - *p++ = 0; + for (i=0; i<5; i++) *p++ = 0; + + /* data or B-tree address */ + H5F_addr_encode(f, &p, &(mesg->addr)); /* dimension size */ for (i = 0; i < mesg->ndims; i++) { diff --git a/src/H5Osdspace.c b/src/H5Osdspace.c index 117dcf3..d7727ef 100644 --- a/src/H5Osdspace.c +++ b/src/H5Osdspace.c @@ -48,6 +48,8 @@ const H5O_class_t H5O_SDSPACE[1] = {{ H5O_sdspace_debug, /* debug the message */ }}; +#define H5O_SDSPACE_VERSION 1 + /* Is the interface initialized? */ static hbool_t interface_initialize_g = FALSE; #define INTERFACE_INIT NULL @@ -74,13 +76,16 @@ static hbool_t interface_initialize_g = FALSE; Robb Matzke, 1998-04-09 The current and maximum dimensions are now H5F_SIZEOF_SIZET bytes instead of just four bytes. + + Robb Matzke, 1998-07-20 + Added a version number and reformatted the message for aligment. --------------------------------------------------------------------------*/ static void * H5O_sdspace_decode(H5F_t *f, const uint8 *p, H5O_shared_t __unused__ *sh) { H5S_simple_t *sdim = NULL;/* New simple dimensionality structure */ intn u; /* local counting variable */ - uintn flags; + uintn flags, version; FUNC_ENTER(H5O_sdspace_decode, NULL); @@ -91,8 +96,15 @@ H5O_sdspace_decode(H5F_t *f, const uint8 *p, H5O_shared_t __unused__ *sh) /* decode */ if ((sdim = H5MM_calloc(sizeof(H5S_simple_t))) != NULL) { - UINT32DECODE(p, sdim->rank); - UINT32DECODE(p, flags); + version = *p++; + if (version!=H5O_SDSPACE_VERSION) { + HRETURN_ERROR(H5E_OHDR, H5E_CANTINIT, NULL, + "wrong version number in data space message"); + } + sdim->rank = *p++; + flags = *p++; + p += 5; /*reserved*/ + if (sdim->rank > 0) { if (NULL==(sdim->size=H5MM_malloc(sizeof(sdim->size[0])* sdim->rank))) { @@ -157,6 +169,9 @@ H5O_sdspace_decode(H5F_t *f, const uint8 *p, H5O_shared_t __unused__ *sh) Robb Matzke, 1998-04-09 The current and maximum dimensions are now H5F_SIZEOF_SIZET bytes instead of just four bytes. + + Robb Matzke, 1998-07-20 + Added a version number and reformatted the message for aligment. --------------------------------------------------------------------------*/ static herr_t H5O_sdspace_encode(H5F_t *f, uint8 *p, const void *mesg) @@ -179,8 +194,15 @@ H5O_sdspace_encode(H5F_t *f, uint8 *p, const void *mesg) #endif /* encode */ - UINT32ENCODE(p, sdim->rank); - UINT32ENCODE(p, flags); + *p++ = H5O_SDSPACE_VERSION; + *p++ = sdim->rank; + *p++ = flags; + *p++ = 0; /*reserved*/ + *p++ = 0; /*reserved*/ + *p++ = 0; /*reserved*/ + *p++ = 0; /*reserved*/ + *p++ = 0; /*reserved*/ + if (sdim->rank > 0) { for (u = 0; u < sdim->rank; u++) { H5F_encode_length (f, p, sdim->size[u]); @@ -317,9 +339,9 @@ static size_t H5O_sdspace_size(H5F_t *f, const void *mesg) { const H5S_simple_t *sdim = (const H5S_simple_t *) mesg; + /* - * all dimensionality messages are at least 8 bytes long (four bytes for - * rank and four bytes for flags) + * All dimensionality messages are at least 8 bytes long. */ size_t ret_value = 8; diff --git a/src/H5Oshared.c b/src/H5Oshared.c index f485143..198466b 100644 --- a/src/H5Oshared.c +++ b/src/H5Oshared.c @@ -38,6 +38,8 @@ const H5O_class_t H5O_SHARED[1] = {{ H5O_shared_debug, /*debug method */ }}; +#define H5O_SHARED_VERSION 1 + /* Interface initialization */ #define PABLO_MASK H5O_shared_mask static hbool_t interface_initialize_g = FALSE; @@ -57,14 +59,15 @@ static hbool_t interface_initialize_g = FALSE; * Thursday, April 2, 1998 * * Modifications: - * + * Robb Matzke, 1998-07-20 + * Added a version number to the beginning of the message. *------------------------------------------------------------------------- */ static void * H5O_shared_decode (H5F_t *f, const uint8 *buf, H5O_shared_t __unused__ *sh) { H5O_shared_t *mesg; - uintn flags; + uintn flags, version; FUNC_ENTER (H5O_shared_decode, NULL); @@ -79,10 +82,21 @@ H5O_shared_decode (H5F_t *f, const uint8 *buf, H5O_shared_t __unused__ *sh) "memory allocation failed"); } + /* Version */ + version = *buf++; + if (version!=H5O_SHARED_VERSION) { + HRETURN_ERROR(H5E_OHDR, H5E_CANTLOAD, NULL, + "bad version number for shared object message"); + } + + /* Flags */ flags = *buf++; mesg->in_gh = (flags & 0x01); - buf += 7; /*reserved*/ + /* Reserved */ + buf += 6; + + /* Body */ if (mesg->in_gh) { H5F_addr_decode (f, &buf, &(mesg->u.gh.addr)); INT32DECODE (buf, mesg->u.gh.idx); @@ -107,6 +121,8 @@ H5O_shared_decode (H5F_t *f, const uint8 *buf, H5O_shared_t __unused__ *sh) * Thursday, April 2, 1998 * * Modifications: + * Robb Matzke, 1998-07-20 + * Added a version number to the beginning of the message. * *------------------------------------------------------------------------- */ @@ -124,6 +140,7 @@ H5O_shared_encode (H5F_t *f, uint8 *buf/*out*/, const void *_mesg) assert (mesg); /* Encode */ + *buf++ = H5O_SHARED_VERSION; flags = mesg->in_gh ? 0x01 : 0x00; *buf++ = flags; *buf++ = 0; /*reserved 1*/ @@ -132,7 +149,6 @@ H5O_shared_encode (H5F_t *f, uint8 *buf/*out*/, const void *_mesg) *buf++ = 0; /*reserved 4*/ *buf++ = 0; /*reserved 5*/ *buf++ = 0; /*reserved 6*/ - *buf++ = 0; /*reserved 7*/ if (mesg->in_gh) { H5F_addr_encode (f, &buf, &(mesg->u.gh.addr)); |