summaryrefslogtreecommitdiffstats
path: root/src/H5F.c
diff options
context:
space:
mode:
authorQuincey Koziol <koziol@hdfgroup.org>2003-08-14 12:18:34 (GMT)
committerQuincey Koziol <koziol@hdfgroup.org>2003-08-14 12:18:34 (GMT)
commitf29e3e10975ee2164ca1ad1c0964108f3dc117d0 (patch)
treeaf4af98e9ba8f166f29429a5eeb9aaa0c8283ac3 /src/H5F.c
parent374ad0ef30754b2a4a78c5ab3a16acd8e5c4c6fc (diff)
downloadhdf5-f29e3e10975ee2164ca1ad1c0964108f3dc117d0.zip
hdf5-f29e3e10975ee2164ca1ad1c0964108f3dc117d0.tar.gz
hdf5-f29e3e10975ee2164ca1ad1c0964108f3dc117d0.tar.bz2
[svn-r7362] 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 6600196..097093d 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");