diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/H5Dint.c | 10 | ||||
-rw-r--r-- | src/H5Fpkg.h | 2 | ||||
-rw-r--r-- | src/H5Fsuper.c | 6 | ||||
-rw-r--r-- | src/H5MF.c | 4 | ||||
-rw-r--r-- | src/H5O.c | 24 | ||||
-rw-r--r-- | src/H5Obogus.c | 30 | ||||
-rw-r--r-- | src/H5Ocache.c | 13 | ||||
-rw-r--r-- | src/H5Opkg.h | 8 | ||||
-rw-r--r-- | src/H5Oprivate.h | 11 |
9 files changed, 81 insertions, 27 deletions
diff --git a/src/H5Dint.c b/src/H5Dint.c index fe34718..733ffe7 100644 --- a/src/H5Dint.c +++ b/src/H5Dint.c @@ -945,15 +945,21 @@ H5D__update_oh_info(H5F_t *file, hid_t dxpl_id, H5D_t *dset, hid_t dapl_id) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "can't get dataset creation property list") /* Check whether to add a "bogus" message */ - if(H5P_exist_plist(dc_plist, H5O_BOGUS_MSG_FLAGS_NAME) > 0) { + if( (H5P_exist_plist(dc_plist, H5O_BOGUS_MSG_FLAGS_NAME) > 0) && + (H5P_exist_plist(dc_plist, H5O_BOGUS_MSG_ID_NAME) > 0) ) { + uint8_t bogus_flags = 0; /* Flags for creating "bogus" message */ + unsigned bogus_id; /* "bogus" ID */ + /* Retrieve "bogus" message ID */ + if(H5P_get(dc_plist, H5O_BOGUS_MSG_ID_NAME, &bogus_id) < 0) + HGOTO_ERROR(H5E_DATASET, H5E_CANTGET, FAIL, "can't get bogus ID options") /* Retrieve "bogus" message flags */ if(H5P_get(dc_plist, H5O_BOGUS_MSG_FLAGS_NAME, &bogus_flags) < 0) HGOTO_ERROR(H5E_DATASET, H5E_CANTGET, FAIL, "can't get bogus message options") /* Add a "bogus" message (for error testing). */ - if(H5O_bogus_oh(file, dxpl_id, oh, (unsigned)bogus_flags) < 0) + if(H5O_bogus_oh(file, dxpl_id, oh, bogus_id, (unsigned)bogus_flags) < 0) HGOTO_ERROR(H5E_DATASET, H5E_CANTINIT, FAIL, "unable to create 'bogus' message") } /* end if */ } diff --git a/src/H5Fpkg.h b/src/H5Fpkg.h index be324d0..ab2ef9e 100644 --- a/src/H5Fpkg.h +++ b/src/H5Fpkg.h @@ -359,7 +359,7 @@ H5_DLL herr_t H5F__super_free(H5F_super_t *sblock); /* Superblock extension related routines */ H5_DLL herr_t H5F_super_ext_open(H5F_t *f, haddr_t ext_addr, H5O_loc_t *ext_ptr); -H5_DLL herr_t H5F_super_ext_write_msg(H5F_t *f, hid_t dxpl_id, void *mesg, unsigned id, hbool_t may_create); +H5_DLL herr_t H5F_super_ext_write_msg(H5F_t *f, hid_t dxpl_id, unsigned id, void *mesg, hbool_t may_create); H5_DLL herr_t H5F_super_ext_remove_msg(H5F_t *f, hid_t dxpl_id, unsigned id); H5_DLL herr_t H5F_super_ext_close(H5F_t *f, H5O_loc_t *ext_ptr, hid_t dxpl_id, hbool_t was_created); diff --git a/src/H5Fsuper.c b/src/H5Fsuper.c index 332dfa6..6b4613d 100644 --- a/src/H5Fsuper.c +++ b/src/H5Fsuper.c @@ -622,7 +622,7 @@ H5F__super_read(H5F_t *f, hid_t dxpl_id) f->shared->sblock = sblock; #endif /* JRM */ - if(H5F_super_ext_write_msg(f, dxpl_id, &drvinfo, H5O_DRVINFO_ID, FALSE) < 0) + if(H5F_super_ext_write_msg(f, dxpl_id, H5O_DRVINFO_ID, &drvinfo, FALSE) < 0) HGOTO_ERROR(H5E_FILE, H5E_WRITEERROR, FAIL, "error in writing message to superblock extension") #if 1 /* bug fix test code -- tidy this up if all goes well */ /* JRM */ @@ -959,7 +959,7 @@ H5F__super_init(H5F_t *f, hid_t dxpl_id) for(type = H5FD_MEM_SUPER; type < H5FD_MEM_NTYPES; H5_INC_ENUM(H5FD_mem_t, type)) fsinfo.fs_addr[type-1] = HADDR_UNDEF; - if(H5O_msg_create(&ext_loc, H5O_FSINFO_ID, H5O_MSG_FLAG_DONTSHARE, H5O_UPDATE_TIME, &fsinfo, dxpl_id) < 0) + if(H5O_msg_create(&ext_loc, H5O_FSINFO_ID, H5O_MSG_FLAG_DONTSHARE, H5O_UPDATE_TIME, &fsinfo, dxpl_id) < 0) HGOTO_ERROR(H5E_FILE, H5E_CANTINIT, FAIL, "unable to update free-space info header message") } /* end if */ } /* end if */ @@ -1197,7 +1197,7 @@ done: *------------------------------------------------------------------------- */ herr_t -H5F_super_ext_write_msg(H5F_t *f, hid_t dxpl_id, void *mesg, unsigned id, hbool_t may_create) +H5F_super_ext_write_msg(H5F_t *f, hid_t dxpl_id, unsigned id, void *mesg, hbool_t may_create) { H5P_genplist_t *dxpl = NULL; /* DXPL for setting ring */ H5AC_ring_t orig_ring = H5AC_RING_INV; /* Original ring value */ @@ -1237,7 +1237,7 @@ HDfprintf(stderr, "%s: Entering\n", FUNC); /* Write free-space manager info message to superblock extension object header */ /* Create the superblock extension object header in advance if needed */ - if(H5F_super_ext_write_msg(f, dxpl_id, &fsinfo, H5O_FSINFO_ID, TRUE) < 0) + if(H5F_super_ext_write_msg(f, dxpl_id, H5O_FSINFO_ID, &fsinfo, TRUE) < 0) HGOTO_ERROR(H5E_RESOURCE, H5E_WRITEERROR, FAIL, "error in writing message to superblock extension") /* Re-allocate free-space manager header and/or section info header */ @@ -1272,7 +1272,7 @@ HDfprintf(stderr, "%s: Entering\n", FUNC); /* Update the free space manager info message in superblock extension object header */ if(update) - if(H5F_super_ext_write_msg(f, dxpl_id, &fsinfo, H5O_FSINFO_ID, FALSE) < 0) + if(H5F_super_ext_write_msg(f, dxpl_id, H5O_FSINFO_ID, &fsinfo, FALSE) < 0) HGOTO_ERROR(H5E_RESOURCE, H5E_WRITEERROR, FAIL, "error in writing message to superblock extension") /* Final close of free-space managers */ @@ -112,9 +112,9 @@ const H5O_msg_class_t *const H5O_msg_class_g[] = { H5O_MSG_EFL, /*0x0007 Data storage -- external data files */ H5O_MSG_LAYOUT, /*0x0008 Data Layout */ #ifdef H5O_ENABLE_BOGUS - H5O_MSG_BOGUS, /*0x0009 "Bogus" (for testing) */ + H5O_MSG_BOGUS_VALID, /*0x0009 "Bogus valid" (for testing) */ #else /* H5O_ENABLE_BOGUS */ - NULL, /*0x0009 "Bogus" (for testing) */ + NULL, /*0x0009 "Bogus valid" (for testing) */ #endif /* H5O_ENABLE_BOGUS */ H5O_MSG_GINFO, /*0x000A Group information */ H5O_MSG_PLINE, /*0x000B Data storage -- filter pipeline */ @@ -131,6 +131,11 @@ const H5O_msg_class_t *const H5O_msg_class_g[] = { H5O_MSG_REFCOUNT, /*0x0016 Object's ref. count */ H5O_MSG_FSINFO, /*0x0017 Free-space manager info message */ H5O_MSG_UNKNOWN, /*0x0018 Placeholder for unknown message */ +#ifdef H5O_ENABLE_BOGUS + H5O_MSG_BOGUS_INVALID, /*0x0019 "Bogus invalid" (for testing) */ +#else /* H5O_ENABLE_BOGUS */ + NULL, /*0x0019 "Bogus invalid" (for testing) */ +#endif /* H5O_ENABLE_BOGUS */ }; /* Declare a free list to manage the H5O_t struct */ @@ -2141,9 +2146,10 @@ done: *------------------------------------------------------------------------- */ herr_t -H5O_bogus_oh(H5F_t *f, hid_t dxpl_id, H5O_t *oh, unsigned mesg_flags) +H5O_bogus_oh(H5F_t *f, hid_t dxpl_id, H5O_t *oh, unsigned bogus_id, unsigned mesg_flags) { size_t idx; /* Local index variable */ + H5O_msg_class_t *type; /* Message class type */ herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_NOAPI(FAIL) @@ -2153,7 +2159,8 @@ H5O_bogus_oh(H5F_t *f, hid_t dxpl_id, H5O_t *oh, unsigned mesg_flags) /* Look for existing message */ for(idx = 0; idx < oh->nmesgs; idx++) - if(H5O_MSG_BOGUS == oh->mesg[idx].type) + if(H5O_MSG_BOGUS_VALID == oh->mesg[idx].type || + H5O_MSG_BOGUS_INVALID == oh->mesg[idx].type) break; /* Create a new message */ @@ -2167,8 +2174,15 @@ H5O_bogus_oh(H5F_t *f, hid_t dxpl_id, H5O_t *oh, unsigned mesg_flags) /* Update the native value */ bogus->u = H5O_BOGUS_VALUE; + if(bogus_id == H5O_BOGUS_VALID_ID) + type = H5O_MSG_BOGUS_VALID; + else if(bogus_id == H5O_BOGUS_INVALID_ID) + type = H5O_MSG_BOGUS_INVALID; + else + HGOTO_ERROR(H5E_ATOM, H5E_BADATOM, FAIL, "invalid ID for 'bogus' message") + /* Allocate space in the object header for bogus message */ - if(H5O_msg_alloc(f, dxpl_id, oh, H5O_MSG_BOGUS, &mesg_flags, bogus, &idx) < 0) + if(H5O_msg_alloc(f, dxpl_id, oh, type, &mesg_flags, bogus, &idx) < 0) HGOTO_ERROR(H5E_OHDR, H5E_CANTINIT, FAIL, "unable to allocate space for 'bogus' message") /* Point to "bogus" information (take it over) */ diff --git a/src/H5Obogus.c b/src/H5Obogus.c index de205f6..d1085c8 100644 --- a/src/H5Obogus.c +++ b/src/H5Obogus.c @@ -47,9 +47,9 @@ static herr_t H5O_bogus_debug(H5F_t *f, hid_t dxpl_id, const void *_mesg, FILE * int indent, int fwidth); /* This message derives from H5O message class */ -const H5O_msg_class_t H5O_MSG_BOGUS[1] = {{ - H5O_BOGUS_ID, /*message id number */ - "bogus", /*message name for debugging */ +const H5O_msg_class_t H5O_MSG_BOGUS_VALID[1] = {{ + H5O_BOGUS_VALID_ID, /*message id number */ + "bogus valid", /*message name for debugging */ 0, /*native message size */ 0, /* messages are sharable? */ H5O_bogus_decode, /*decode message */ @@ -70,6 +70,30 @@ const H5O_msg_class_t H5O_MSG_BOGUS[1] = {{ H5O_bogus_debug /*debug the message */ }}; +/* This message derives from H5O message class */ +const H5O_msg_class_t H5O_MSG_BOGUS_INVALID[1] = {{ + H5O_BOGUS_INVALID_ID, /*message id number */ + "bogus invalid", /*message name for debugging */ + 0, /*native message size */ + 0, /* messages are sharable? */ + H5O_bogus_decode, /*decode message */ + H5O_bogus_encode, /*encode message */ + NULL, /*copy the native value */ + H5O_bogus_size, /*raw message size */ + NULL, /*free internal memory */ + NULL, /*free method */ + NULL, /* file delete method */ + NULL, /* link method */ + NULL, /*set share method */ + NULL, /*can share method */ + NULL, /* pre copy native value to file */ + NULL, /* copy native value to file */ + NULL, /* post copy native value to file */ + NULL, /* get creation index */ + NULL, /* set creation index */ + H5O_bogus_debug /*debug the message */ +}}; + /*------------------------------------------------------------------------- * Function: H5O_bogus_decode diff --git a/src/H5Ocache.c b/src/H5Ocache.c index 945d12e..f74966e 100644 --- a/src/H5Ocache.c +++ b/src/H5Ocache.c @@ -1149,10 +1149,6 @@ H5O__chunk_deserialize(H5O_t *oh, haddr_t addr, size_t len, const uint8_t *image else id = *chunk_image++; - /* Check for unknown message ID getting encoded in file */ - if(id >= H5O_UNKNOWN_ID) - HGOTO_ERROR(H5E_OHDR, H5E_CANTLOAD, FAIL, "'unknown' message ID encoded in file?!?") - /* Message size */ UINT16DECODE(chunk_image, mesg_size); HDassert(mesg_size == H5O_ALIGN_OH(oh, mesg_size)); @@ -1222,8 +1218,13 @@ H5O__chunk_deserialize(H5O_t *oh, haddr_t addr, size_t len, const uint8_t *image /* Point unknown messages at 'unknown' message class */ /* (Usually from future versions of the library) */ - if(id >= NELMTS(H5O_msg_class_g) || NULL == H5O_msg_class_g[id]) { - H5O_unknown_t *unknown; /* Pointer to "unknown" message info */ + if(id >= H5O_UNKNOWN_ID || +#ifdef H5O_ENABLE_BOGUS + id == H5O_BOGUS_VALID_ID || +#endif + NULL == H5O_msg_class_g[id]) { + + H5O_unknown_t *unknown; /* Pointer to "unknown" message info */ /* Allocate "unknown" message info */ if(NULL == (unknown = H5FL_MALLOC(H5O_unknown_t))) diff --git a/src/H5Opkg.h b/src/H5Opkg.h index 642e938..cc1b289 100644 --- a/src/H5Opkg.h +++ b/src/H5Opkg.h @@ -31,7 +31,7 @@ #define H5O_NMESGS 8 /*initial number of messages */ #define H5O_NCHUNKS 2 /*initial number of chunks */ #define H5O_MIN_SIZE 22 /* Min. obj header data size (must be big enough for a message prefix and a continuation message) */ -#define H5O_MSG_TYPES 25 /* # of types of messages */ +#define H5O_MSG_TYPES 26 /* # of types of messages */ #define H5O_MAX_CRT_ORDER_IDX 65535 /* Max. creation order index value */ /* Versions of object header structure */ @@ -440,11 +440,13 @@ H5_DLLVAR const H5O_msg_class_t H5O_MSG_EFL[1]; H5_DLLVAR const H5O_msg_class_t H5O_MSG_LAYOUT[1]; #ifdef H5O_ENABLE_BOGUS -/* "Bogus" Message. (0x0009) */ +/* "Bogus valid" Message. (0x0009) */ +/* "Bogus invalid" Message. (0x0019) */ /* * Used for debugging - should never be found in valid HDF5 file. */ -H5_DLLVAR const H5O_msg_class_t H5O_MSG_BOGUS[1]; +H5_DLLVAR const H5O_msg_class_t H5O_MSG_BOGUS_VALID[1]; +H5_DLLVAR const H5O_msg_class_t H5O_MSG_BOGUS_INVALID[1]; #endif /* H5O_ENABLE_BOGUS */ /* Group Information Message. (0x000a) */ diff --git a/src/H5Oprivate.h b/src/H5Oprivate.h index 4ce8e59..77b2b51 100644 --- a/src/H5Oprivate.h +++ b/src/H5Oprivate.h @@ -98,7 +98,13 @@ typedef struct H5O_t H5O_t; #ifdef H5O_ENABLE_BOGUS #define H5O_BOGUS_MSG_FLAGS_NAME "bogus msg flags" /* Flags for 'bogus' message */ #define H5O_BOGUS_MSG_FLAGS_SIZE sizeof(uint8_t) + +/* bogus ID can be either (a) H5O_BOGUS_VALID_ID 0x0009 or (b) H5O_BOGUS_INVALID_ID 0x0019 */ +#define H5O_BOGUS_MSG_ID_NAME "bogus msg id" /* ID for 'bogus' message */ +#define H5O_BOGUS_MSG_ID_SIZE sizeof(unsigned) + #endif /* H5O_ENABLE_BOGUS */ + #ifdef H5O_ENABLE_BAD_MESG_COUNT #define H5O_BAD_MESG_COUNT_NAME "bad message count" /* Flag setting bad message count */ #define H5O_BAD_MESG_COUNT_SIZE sizeof(hbool_t) @@ -183,7 +189,7 @@ typedef struct H5O_copy_t { #define H5O_LINK_ID 0x0006 /* Link Message. */ #define H5O_EFL_ID 0x0007 /* External File List Message */ #define H5O_LAYOUT_ID 0x0008 /* Data Layout Message. */ -#define H5O_BOGUS_ID 0x0009 /* "Bogus" Message. */ +#define H5O_BOGUS_VALID_ID 0x0009 /* "Bogus valid" Message. */ #define H5O_GINFO_ID 0x000a /* Group info Message. */ #define H5O_PLINE_ID 0x000b /* Filter pipeline message. */ #define H5O_ATTR_ID 0x000c /* Attribute Message. */ @@ -200,6 +206,7 @@ typedef struct H5O_copy_t { #define H5O_FSINFO_ID 0x0017 /* Free-space manager info message. */ #define H5O_UNKNOWN_ID 0x0018 /* Placeholder message ID for unknown message. */ /* (this should never exist in a file) */ +#define H5O_BOGUS_INVALID_ID 0x0019 /* "Bogus invalid" Message. */ /* Shared object message types. * Shared objects can be committed, in which case the shared message contains @@ -755,7 +762,7 @@ H5_DLL herr_t H5O_touch(const H5O_loc_t *loc, hbool_t force, hid_t dxpl_id); H5_DLL herr_t H5O_touch_oh(H5F_t *f, hid_t dxpl_id, H5O_t *oh, hbool_t force); #ifdef H5O_ENABLE_BOGUS -H5_DLL herr_t H5O_bogus_oh(H5F_t *f, hid_t dxpl_id, H5O_t *oh, unsigned mesg_flags); +H5_DLL herr_t H5O_bogus_oh(H5F_t *f, hid_t dxpl_id, H5O_t *oh, unsigned mesg_id, unsigned mesg_flags); #endif /* H5O_ENABLE_BOGUS */ H5_DLL herr_t H5O_delete(H5F_t *f, hid_t dxpl_id, haddr_t addr); H5_DLL herr_t H5O_get_hdr_info(const H5O_loc_t *oloc, hid_t dxpl_id, H5O_hdr_info_t *hdr); |