summaryrefslogtreecommitdiffstats
path: root/src/H5F.c
diff options
context:
space:
mode:
authorQuincey Koziol <koziol@hdfgroup.org>2003-08-14 12:22:01 (GMT)
committerQuincey Koziol <koziol@hdfgroup.org>2003-08-14 12:22:01 (GMT)
commite9f6bf020abe8c3ee01c5f5858bad35f8f67ba3e (patch)
treed8e80db65c23b12827508ccc6c3d8101edd977da /src/H5F.c
parentf4c720276227ba5c17097b9e36740bbef0fd1536 (diff)
downloadhdf5-e9f6bf020abe8c3ee01c5f5858bad35f8f67ba3e.zip
hdf5-e9f6bf020abe8c3ee01c5f5858bad35f8f67ba3e.tar.gz
hdf5-e9f6bf020abe8c3ee01c5f5858bad35f8f67ba3e.tar.bz2
[svn-r7363] Purpose:
Bug fix Description: Allow a user block to be "inserted" in front of a file (probably by writing a validly-sized userblock to a new file and then appending another HDF5 file to the new file). Platforms tested: FreeBSD 4.8 (sleipnir) h5committested
Diffstat (limited to 'src/H5F.c')
-rw-r--r--src/H5F.c15
1 files changed, 14 insertions, 1 deletions
diff --git a/src/H5F.c b/src/H5F.c
index cceea2f..dba1646 100644
--- a/src/H5F.c
+++ b/src/H5F.c
@@ -2124,6 +2124,19 @@ H5F_open(const char *name, unsigned flags, hid_t fcpl_id, hid_t fapl_id, hid_t d
if (H5G_ent_decode(file, &p, &root_ent/*out*/)<0)
HGOTO_ERROR(H5E_FILE, H5E_CANTOPENFILE, NULL, "unable to read root symbol entry");
+ /* Check if superblock address is different from base address and
+ * adjust base address and "end of address" address if so.
+ */
+ if(!H5F_addr_eq(shared->super_addr,shared->base_addr)) {
+ /* Check if the superblock moved earlier in the file */
+ if(H5F_addr_lt(shared->super_addr,shared->base_addr))
+ stored_eoa -= (shared->base_addr-shared->super_addr);
+ /* The superblock moved later in the file */
+ else
+ stored_eoa += (shared->super_addr-shared->base_addr);
+ shared->base_addr = shared->super_addr;
+ } /* end if */
+
/* Compute super block checksum */
assert(sizeof(chksum)==sizeof(shared->super_chksum));
for(q=(uint8_t *)&chksum, chksum=0, i=0; i<(fixed_size+variable_size); i++)
@@ -2196,7 +2209,7 @@ H5F_open(const char *name, unsigned flags, hid_t fcpl_id, hid_t fapl_id, hid_t d
/*
* Tell the file driver how much address space has already been
- * allocated so that it knows how to allocated additional memory.
+ * allocated so that it knows how to allocate additional memory.
*/
if (H5FD_set_eoa(lf, stored_eoa)<0)
HGOTO_ERROR(H5E_FILE, H5E_CANTOPENFILE, NULL, "unable to set end-of-address marker for file");