diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/H5O.c | 8 | ||||
-rw-r--r-- | src/H5Ocache.c | 22 | ||||
-rw-r--r-- | src/H5Opkg.h | 6 | ||||
-rw-r--r-- | src/H5Oprivate.h | 4 | ||||
-rw-r--r-- | src/H5config.h.in | 3 | ||||
-rw-r--r-- | src/Makefile.in | 1 |
6 files changed, 43 insertions, 1 deletions
@@ -1077,6 +1077,14 @@ H5O_create(H5F_t *f, hid_t dxpl_id, size_t size_hint, hid_t ocpl_id, oh->version = H5O_VERSION_1; oh->sizeof_size = H5F_SIZEOF_SIZE(f); oh->sizeof_addr = H5F_SIZEOF_ADDR(f); +#ifdef H5O_ENABLE_BAD_MESG_COUNT + /* Check whether the "bad message count" property is set */ + if(H5P_exist_plist(oc_plist, H5O_BAD_MESG_COUNT_NAME) > 0) { + /* Retrieve bad message count flag */ + if(H5P_get(oc_plist, H5O_BAD_MESG_COUNT_NAME, &oh->store_bad_mesg_count) < 0) + HGOTO_ERROR(H5E_OHDR, H5E_CANTGET, FAIL, "can't get bad message count flag") + } /* end if */ +#endif /* H5O_ENABLE_BAD_MESG_COUNT */ /* Set initial status flags */ oh->flags = oh_flags; diff --git a/src/H5Ocache.c b/src/H5Ocache.c index b5c8c7d..0d5765e 100644 --- a/src/H5Ocache.c +++ b/src/H5Ocache.c @@ -580,10 +580,25 @@ H5O_load(H5F_t *f, hid_t dxpl_id, haddr_t addr, const void UNUSED * _udata1, if(merged_null_msgs) oh->cache_info.is_dirty = TRUE; +/* Don't check for the incorrect # of object header messages bug unless we've + * enabled strict format checking. This allows for older files, created with + * a version of the library that had a bug in tracking the correct # of header + * messages to be read in without the library fussing about things. -QAK + */ +#ifdef H5_STRICT_FORMAT_CHECKS /* Sanity check for the correct # of messages in object header */ if(oh->version == H5O_VERSION_1) if((oh->nmesgs + merged_null_msgs) != nmesgs) HGOTO_ERROR(H5E_OHDR, H5E_CANTLOAD, NULL, "corrupt object header - too few messages") +#else /* H5_STRICT_FORMAT_CHECKS */ + /* Check for incorrect # of messages in object header and if we have write + * access on the file, flag the object header as dirty, so it gets fixed. + */ + if(oh->version == H5O_VERSION_1) + if((oh->nmesgs + merged_null_msgs) != nmesgs && + (H5F_get_intent(f) & H5F_ACC_RDWR)) + oh->cache_info.is_dirty = TRUE; +#endif /* H5_STRICT_FORMAT_CHECKS */ #ifdef H5O_DEBUG H5O_assert(oh); @@ -710,7 +725,12 @@ H5O_assert(oh); *p++ = 0; /* Number of messages */ - UINT16ENCODE(p, oh->nmesgs); +#ifdef H5O_ENABLE_BAD_MESG_COUNT + if(oh->store_bad_mesg_count) + UINT16ENCODE(p, (oh->nmesgs - 1)) + else +#endif /* H5O_ENABLE_BAD_MESG_COUNT */ + UINT16ENCODE(p, oh->nmesgs); /* Link count */ UINT32ENCODE(p, oh->nlink); diff --git a/src/H5Opkg.h b/src/H5Opkg.h index c90ff0a..e2c5661 100644 --- a/src/H5Opkg.h +++ b/src/H5Opkg.h @@ -253,6 +253,12 @@ struct H5O_t { /* File-specific information (not stored) */ size_t sizeof_size; /* Size of file sizes */ size_t sizeof_addr; /* Size of file addresses */ +#ifdef H5O_ENABLE_BAD_MESG_COUNT + hbool_t store_bad_mesg_count; /* Flag to indicate that a bad message count should be stored */ + /* (This is to simulate a bug in earlier + * versions of the library) + */ +#endif /* H5O_ENABLE_BAD_MESG_COUNT */ /* Object information (stored) */ hbool_t has_refcount_msg; /* Whether the object has a ref. count message */ diff --git a/src/H5Oprivate.h b/src/H5Oprivate.h index 72d9e2d..4a55ac2 100644 --- a/src/H5Oprivate.h +++ b/src/H5Oprivate.h @@ -91,6 +91,10 @@ typedef struct H5O_t H5O_t; #define H5O_BOGUS_MSG_FLAGS_NAME "bogus msg flags" /* Flags for 'bogus' message */ #define H5O_BOGUS_MSG_FLAGS_SIZE sizeof(uint8_t) #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) +#endif /* H5O_ENABLE_BAD_MESG_COUNT */ /* ========= Object Copy properties ============ */ #define H5O_CPY_OPTION_NAME "copy object" /* Copy options */ diff --git a/src/H5config.h.in b/src/H5config.h.in index 0c89e98..5c767ef 100644 --- a/src/H5config.h.in +++ b/src/H5config.h.in @@ -570,6 +570,9 @@ /* Define to 1 if you have the ANSI C header files. */ #undef STDC_HEADERS +/* Define if strict file format checks are enabled */ +#undef STRICT_FORMAT_CHECKS + /* Define if your system supports pthread_attr_setscope(&attribute, PTHREAD_SCOPE_SYSTEM) call. */ #undef SYSTEM_SCOPE_THREADS diff --git a/src/Makefile.in b/src/Makefile.in index 44bc4e7..e733039 100644 --- a/src/Makefile.in +++ b/src/Makefile.in @@ -269,6 +269,7 @@ SET_MAKE = @SET_MAKE@ SHELL = /bin/sh SIZE_T = @SIZE_T@ STATIC_SHARED = @STATIC_SHARED@ +STRICT_FORMAT_CHECKS = @STRICT_FORMAT_CHECKS@ STRIP = @STRIP@ TESTPARALLEL = @TESTPARALLEL@ TIME = @TIME@ |