From 0f7fcaad25171bd5d4eb8f822d88b5770d9b235d Mon Sep 17 00:00:00 2001 From: Robb Matzke Date: Wed, 24 Sep 1997 11:30:22 -0500 Subject: [svn-r111] Changed hdf5_file_t to H5F_t, split data struct ito two halves, fixed problems when opening the same file more than once. --- src/H5AC.c | 189 +++++---- src/H5ACprivate.h | 31 +- src/H5B.c | 44 +-- src/H5Bprivate.h | 31 +- src/H5D.c | 6 +- src/H5F.c | 1120 ++++++++++++++++++++++++++++++++--------------------- src/H5Fprivate.h | 82 ++-- src/H5G.c | 78 ++-- src/H5Gent.c | 10 +- src/H5Gnode.c | 64 +-- src/H5Gpkg.h | 50 ++- src/H5Gprivate.h | 24 +- src/H5Gshad.c | 100 +++-- src/H5Gstab.c | 8 +- src/H5H.c | 52 ++- src/H5Hprivate.h | 15 +- src/H5MF.c | 10 +- src/H5MFprivate.h | 4 +- src/H5O.c | 41 +- src/H5Ocont.c | 12 +- src/H5Oname.c | 16 +- src/H5Oprivate.h | 22 +- src/H5Osdim.c | 26 +- src/H5Osdtyp.c | 24 +- src/H5Ostab.c | 18 +- src/H5Ostdst.c | 24 +- src/debug.c | 4 +- test/tfile.c | 4 +- test/theap.c | 2 +- test/tohdr.c | 2 +- test/tstab.c | 12 +- 31 files changed, 1210 insertions(+), 915 deletions(-) diff --git a/src/H5AC.c b/src/H5AC.c index d82cb6f..dda2fc2 100644 --- a/src/H5AC.c +++ b/src/H5AC.c @@ -29,7 +29,7 @@ * Sorting the cache by address before flushing is sometimes faster * than flushing in cache order. */ -/* #define SORT_BY_ADDR */ +/* #define H5AC_SORT_BY_ADDR */ /* * Debug H5AC_protect() and H5AC_unprotect() by insuring that nothing @@ -44,7 +44,7 @@ #define PABLO_MASK H5AC_mask static int interface_initialize_g = FALSE; /*initialized?*/ -#ifdef SORT_BY_ADDR +#ifdef H5AC_SORT_BY_ADDR static H5AC_t *current_cache_g = NULL; /*for sorting */ #endif @@ -70,17 +70,18 @@ static H5AC_t *current_cache_g = NULL; /*for sorting */ *------------------------------------------------------------------------- */ herr_t -H5AC_new (hdf5_file_t *f, intn size_hint) +H5AC_new (H5F_t *f, intn size_hint) { + H5AC_t *cache = NULL; FUNC_ENTER (H5AC_new, NULL, FAIL); assert (f); - assert (NULL==f->cache); + assert (NULL==f->shared->cache); if (size_hint<1) size_hint = H5AC_NSLOTS; - f->cache = H5MM_xcalloc (1, sizeof (H5AC_t)); - f->cache->nslots = size_hint; - f->cache->slot = H5MM_xcalloc (f->cache->nslots, sizeof (H5AC_slot_t)); + f->shared->cache = cache = H5MM_xcalloc (1, sizeof (H5AC_t)); + cache->nslots = size_hint; + cache->slot = H5MM_xcalloc (cache->nslots, sizeof (H5AC_slot_t)); FUNC_LEAVE (SUCCEED); } @@ -106,12 +107,14 @@ H5AC_new (hdf5_file_t *f, intn size_hint) *------------------------------------------------------------------------- */ herr_t -H5AC_dest (hdf5_file_t *f) +H5AC_dest (H5F_t *f) { + H5AC_t *cache = NULL; FUNC_ENTER (H5AC_dest, NULL, FAIL); assert (f); - assert (f->cache); + assert (f->shared->cache); + cache = f->shared->cache; if (H5AC_flush (f, NULL, 0, TRUE)<0) { HRETURN_ERROR (H5E_CACHE, H5E_CANTFLUSH, FAIL); @@ -120,17 +123,17 @@ H5AC_dest (hdf5_file_t *f) #if defined(H5AC_DEBUG_PROTECT) && !defined(NDEBUG) { intn i; - for (i=0; icache->nslots; i++) { - f->cache->slot[i].prot = H5MM_xfree (f->cache->slot[i].prot); - f->cache->slot[i].aprots = 0; - f->cache->slot[i].nprots = 0; + for (i=0; inslots; i++) { + cache->slot[i].prot = H5MM_xfree (cache->slot[i].prot); + cache->slot[i].aprots = 0; + cache->slot[i].nprots = 0; } } #endif - f->cache->slot = H5MM_xfree (f->cache->slot); - f->cache->nslots = 0; - f->cache = H5MM_xfree (f->cache); + cache->slot = H5MM_xfree (cache->slot); + cache->nslots = 0; + f->shared->cache = cache = H5MM_xfree (cache); FUNC_LEAVE (SUCCEED); } @@ -172,24 +175,25 @@ H5AC_dest (hdf5_file_t *f) *------------------------------------------------------------------------- */ void * -H5AC_find_f (hdf5_file_t *f, const H5AC_class_t *type, haddr_t addr, - void *udata) +H5AC_find_f (H5F_t *f, const H5AC_class_t *type, haddr_t addr, void *udata) { unsigned idx; herr_t status; void *thing = NULL; - herr_t (*flush)(hdf5_file_t*,hbool_t,haddr_t,void*)=NULL; + herr_t (*flush)(H5F_t*,hbool_t,haddr_t,void*)=NULL; H5AC_slot_t *slot = NULL; + H5AC_t *cache = NULL; FUNC_ENTER (H5AC_find, NULL, NULL); assert (f); - assert (f->cache); + assert (f->shared->cache); assert (type); assert (type->load); assert (type->flush); idx = H5AC_HASH (f, addr); - slot = f->cache->slot + idx; + cache = f->shared->cache; + slot = cache->slot + idx; /* * Return right away if the item is in the cache. @@ -275,7 +279,7 @@ H5AC_find_f (hdf5_file_t *f, const H5AC_class_t *type, haddr_t addr, * *------------------------------------------------------------------------- */ -#ifdef SORT_BY_ADDR +#ifdef H5AC_SORT_BY_ADDR static int H5AC_compare (const void *_a, const void *_b) { @@ -284,11 +288,19 @@ H5AC_compare (const void *_a, const void *_b) assert (current_cache_g); - if (NULL==current_cache_g.slot[a].type) return 1; - if (NULL==current_cache_g.slot[b].type) return -1; - - if (current_cache_g.slot[a].addr < current_cache_g.slot[b].addr) return -1; - if (current_cache_g.slot[a].addr > current_cache_g.slot[b].addr) return 1; + if (NULL==current_cache_g->slot[a].type) { + if (NULL==current_cache_g->slot[b].type) { + return 0; + } else { + return -1; + } + } else if (NULL==current_cache_g->slot[b].type) { + return 1; + } else if (current_cache_g->slot[a].addr < current_cache_g->slot[b].addr) { + return -1; + } else if (current_cache_g->slot[a].addr > current_cache_g->slot[b].addr) { + return 1; + } return 0; } #endif @@ -322,45 +334,56 @@ H5AC_compare (const void *_a, const void *_b) *------------------------------------------------------------------------- */ herr_t -H5AC_flush (hdf5_file_t *f, const H5AC_class_t *type, haddr_t addr, - hbool_t destroy) +H5AC_flush (H5F_t *f, const H5AC_class_t *type, haddr_t addr, hbool_t destroy) { uintn i; herr_t status; - herr_t (*flush)(hdf5_file_t*,hbool_t,haddr_t,void*)=NULL; + herr_t (*flush)(H5F_t*,hbool_t,haddr_t,void*)=NULL; H5AC_slot_t *slot; intn *map=NULL; + intn nslots; + H5AC_t *cache=NULL; FUNC_ENTER (H5AC_flush, NULL, FAIL); assert (f); - assert (f->cache); + assert (f->shared->cache); i = H5AC_HASH (f, addr); + cache = f->shared->cache; if (0==addr) { -#ifdef SORT_BY_ADDR +#ifdef H5AC_SORT_BY_ADDR /* * Sort the cache entries by address since flushing them in * ascending order by address may be much more efficient. */ - map = H5MM_xmalloc (f->cache->nslots * sizeof(intn)); - for (i=0; icache->nslots; i++) map[i] = i; + map = H5MM_xmalloc (cache->nslots * sizeof(intn)); + for (i=nslots=0; inslots; i++) { + if (cache->slot[i].type) map[nslots++] = i; + } assert (NULL==current_cache_g); - current_cache_g = f->cache; - HDqsort (map, f->cache->nslots, sizeof(intn), H5AC_compare); + current_cache_g = cache; + HDqsort (map, nslots, sizeof(intn), H5AC_compare); current_cache_g = NULL; +#ifdef NDEBUG + for (i=1; islot[i-1].addr < cache->slot[i].addr); + } +#endif +#else + nslots = cache->nslots; #endif /* * Look at all cache entries. */ - for (i=0; icache->nslots; i++) { -#ifdef SORT_BY_ADDR - slot = f->cache->slot + map[i]; + for (i=0; islot + map[i]; if (NULL==slot->type) break; /*the rest are empty*/ #else - slot = f->cache->slot + i; + slot = cache->slot + i; if (NULL==slot->type) continue; #endif if (!type || type==slot->type) { @@ -379,22 +402,22 @@ H5AC_flush (hdf5_file_t *f, const H5AC_class_t *type, haddr_t addr, * If there are protected object then fail. However, everything * else should have been flushed. */ - if (f->cache->nprots>0) { + if (cache->nprots>0) { HRETURN_ERROR (H5E_CACHE, H5E_PROTECT, FAIL); } - } else if ((!type || f->cache->slot[i].type==type) && - f->cache->slot[i].addr==addr) { + } else if ((!type || cache->slot[i].type==type) && + cache->slot[i].addr==addr) { /* * Flush just this entry. */ - flush = f->cache->slot[i].type->flush; - status = (flush) (f, destroy, f->cache->slot[i].addr, - f->cache->slot[i].thing); + flush = cache->slot[i].type->flush; + status = (flush) (f, destroy, cache->slot[i].addr, + cache->slot[i].thing); if (status<0) { HRETURN_ERROR (H5E_CACHE, H5E_CANTFLUSH, FAIL); } - if (destroy) f->cache->slot[i].type = NULL; + if (destroy) cache->slot[i].type = NULL; } @@ -425,23 +448,25 @@ H5AC_flush (hdf5_file_t *f, const H5AC_class_t *type, haddr_t addr, *------------------------------------------------------------------------- */ herr_t -H5AC_set (hdf5_file_t *f, const H5AC_class_t *type, haddr_t addr, void *thing) +H5AC_set (H5F_t *f, const H5AC_class_t *type, haddr_t addr, void *thing) { herr_t status; uintn idx; - herr_t (*flush)(hdf5_file_t*,hbool_t,haddr_t,void*)=NULL; + herr_t (*flush)(H5F_t*,hbool_t,haddr_t,void*)=NULL; H5AC_slot_t *slot = NULL; + H5AC_t *cache=NULL; FUNC_ENTER (H5AC_set, NULL, FAIL); assert (f); - assert (f->cache); + assert (f->shared->cache); assert (type); assert (type->flush); assert (addr>=0); assert (thing); idx = H5AC_HASH (f, addr); - slot = f->cache->slot + idx; + cache = f->shared->cache; + slot =cache->slot + idx; #if defined(H5AC_DEBUG_PROTECT) && !defined(NDEBUG) { @@ -491,32 +516,34 @@ H5AC_set (hdf5_file_t *f, const H5AC_class_t *type, haddr_t addr, void *thing) *------------------------------------------------------------------------- */ herr_t -H5AC_rename (hdf5_file_t *f, const H5AC_class_t *type, +H5AC_rename (H5F_t *f, const H5AC_class_t *type, haddr_t old_addr, haddr_t new_addr) { uintn old_idx, new_idx; - herr_t (*flush)(hdf5_file_t*, hbool_t, haddr_t, void*); + herr_t (*flush)(H5F_t*, hbool_t, haddr_t, void*); herr_t status; + H5AC_t *cache=NULL; FUNC_ENTER (H5AC_rename, NULL, FAIL); assert (f); - assert (f->cache); + assert (f->shared->cache); assert (type); assert (old_addr>=0); assert (new_addr>=0); old_idx = H5AC_HASH (f, old_addr); new_idx = H5AC_HASH (f, new_addr); + cache = f->shared->cache; #if defined(H5AC_DEBUG_PROTECT) && !defined(NDEBUG) { int i; - for (i=0; icache->slot[old_idx].nprots; i++) { - assert (old_addr!=f->cache->slot[old_idx].prot[i].addr); + for (i=0; islot[old_idx].nprots; i++) { + assert (old_addr!=cache->slot[old_idx].prot[i].addr); } - for (i=0; icache->slot[new_idx].nprots; i++) { - assert (new_addr!=f->cache->slot[new_idx].prot[i].addr); + for (i=0; islot[new_idx].nprots; i++) { + assert (new_addr!=cache->slot[new_idx].prot[i].addr); } } #endif @@ -525,22 +552,22 @@ H5AC_rename (hdf5_file_t *f, const H5AC_class_t *type, * We don't need to do anything if the object isn't cached or if the * new hash value is the same as the old one. */ - if (f->cache->slot[old_idx].type!=type || - f->cache->slot[old_idx].addr!=old_addr) { + if (cache->slot[old_idx].type!=type || + cache->slot[old_idx].addr!=old_addr) { HRETURN (SUCCEED); } if (old_idx==new_idx) { - f->cache->slot[old_idx].addr = new_addr; + cache->slot[old_idx].addr = new_addr; HRETURN (SUCCEED); } /* * Free the item from the destination cache line. */ - if (f->cache->slot[new_idx].type) { - flush = f->cache->slot[new_idx].type->flush; - status = (flush)(f, TRUE, f->cache->slot[new_idx].addr, - f->cache->slot[new_idx].thing); + if (cache->slot[new_idx].type) { + flush = cache->slot[new_idx].type->flush; + status = (flush)(f, TRUE, cache->slot[new_idx].addr, + cache->slot[new_idx].thing); if (status<0) { HRETURN_ERROR (H5E_CACHE, H5E_CANTFLUSH, FAIL); } @@ -549,10 +576,10 @@ H5AC_rename (hdf5_file_t *f, const H5AC_class_t *type, /* * Move the source to the destination (it might not be cached) */ - f->cache->slot[new_idx].type = f->cache->slot[old_idx].type; - f->cache->slot[new_idx].addr = new_addr; - f->cache->slot[new_idx].thing = f->cache->slot[old_idx].thing; - f->cache->slot[old_idx].type = NULL; + cache->slot[new_idx].type = cache->slot[old_idx].type; + cache->slot[new_idx].addr = new_addr; + cache->slot[new_idx].thing = cache->slot[old_idx].thing; + cache->slot[old_idx].type = NULL; FUNC_LEAVE (SUCCEED); } @@ -585,23 +612,24 @@ H5AC_rename (hdf5_file_t *f, const H5AC_class_t *type, *------------------------------------------------------------------------- */ void * -H5AC_protect (hdf5_file_t *f, const H5AC_class_t *type, haddr_t addr, - void *udata) +H5AC_protect (H5F_t *f, const H5AC_class_t *type, haddr_t addr, void *udata) { int idx; void *thing = NULL; + H5AC_t *cache = NULL; H5AC_slot_t *slot = NULL; FUNC_ENTER (H5AC_protect, NULL, NULL); /* check args */ assert (f); - assert (f->cache); + assert (f->shared->cache); assert (type); assert (type->load); assert (type->flush); idx = H5AC_HASH (f, addr); - slot = f->cache->slot+idx; + cache = f->shared->cache; + slot = cache->slot+idx; if (slot->type==type && slot->addr==addr) { /* @@ -656,7 +684,7 @@ H5AC_protect (hdf5_file_t *f, const H5AC_class_t *type, haddr_t addr, slot->nprots += 1; #endif - f->cache->nprots += 1; + cache->nprots += 1; FUNC_LEAVE (thing); } @@ -686,25 +714,26 @@ H5AC_protect (hdf5_file_t *f, const H5AC_class_t *type, haddr_t addr, *------------------------------------------------------------------------- */ herr_t -H5AC_unprotect (hdf5_file_t *f, const H5AC_class_t *type, haddr_t addr, - void *thing) +H5AC_unprotect (H5F_t *f, const H5AC_class_t *type, haddr_t addr, void *thing) { herr_t status; uintn idx; - herr_t (*flush)(hdf5_file_t*,hbool_t,haddr_t,void*)=NULL; + herr_t (*flush)(H5F_t*,hbool_t,haddr_t,void*)=NULL; + H5AC_t *cache = NULL; H5AC_slot_t *slot = NULL; FUNC_ENTER (H5AC_unprotect, NULL, FAIL); /* check args */ assert (f); - assert (f->cache); + assert (f->shared->cache); assert (type); assert (type->flush); assert (addr>=0); assert (thing); idx = H5AC_HASH (f, addr); - slot = f->cache->slot + idx; + cache = f->shared->cache; + slot = cache->slot + idx; /* * Flush any object already in the cache at that location. It had @@ -745,7 +774,7 @@ H5AC_unprotect (hdf5_file_t *f, const H5AC_class_t *type, haddr_t addr, slot->type = type; slot->addr = addr; slot->thing = thing; - f->cache->nprots -= 1; + cache->nprots -= 1; FUNC_LEAVE (SUCCEED); } diff --git a/src/H5ACprivate.h b/src/H5ACprivate.h index 83a1b38..a028d9c 100644 --- a/src/H5ACprivate.h +++ b/src/H5ACprivate.h @@ -39,9 +39,8 @@ * by the LOAD method if the DEST argument is non-zero. */ typedef struct H5AC_class_t { - void *(*load)(hdf5_file_t*, haddr_t addr, void *udata); - herr_t (*flush)(hdf5_file_t*, hbool_t dest, haddr_t addr, - void *thing); + void *(*load)(H5F_t*, haddr_t addr, void *udata); + herr_t (*flush)(H5F_t*, hbool_t dest, haddr_t addr, void *thing); } H5AC_class_t; /* @@ -50,7 +49,7 @@ typedef struct H5AC_class_t { * own cache, an array of slots. */ #define H5AC_NSLOTS 10330 /*prime number tend to work best */ -#define H5AC_HASH(F,ADDR) ((unsigned)(ADDR) % (F)->cache->nslots) +#define H5AC_HASH(F,ADDR) ((unsigned)(ADDR) % (F)->shared->cache->nslots) typedef struct H5AC_prot_t { const H5AC_class_t *type; /*type of protected thing */ @@ -77,25 +76,25 @@ typedef struct H5AC_t { /* * Library prototypes. */ -herr_t H5AC_dest (hdf5_file_t *f); -void *H5AC_find_f (hdf5_file_t *f, const H5AC_class_t *type, haddr_t addr, +herr_t H5AC_dest (H5F_t *f); +void *H5AC_find_f (H5F_t *f, const H5AC_class_t *type, haddr_t addr, void *udata); -void * H5AC_protect (hdf5_file_t *f, const H5AC_class_t *type, haddr_t addr, +void * H5AC_protect (H5F_t *f, const H5AC_class_t *type, haddr_t addr, void *udata); -herr_t H5AC_unprotect (hdf5_file_t *f, const H5AC_class_t *type, haddr_t addr, +herr_t H5AC_unprotect (H5F_t *f, const H5AC_class_t *type, haddr_t addr, void *thing); -herr_t H5AC_flush (hdf5_file_t *f, const H5AC_class_t *type, haddr_t addr, +herr_t H5AC_flush (H5F_t *f, const H5AC_class_t *type, haddr_t addr, hbool_t destroy); -herr_t H5AC_new (hdf5_file_t *f, intn size_hint); -herr_t H5AC_rename (hdf5_file_t *f, const H5AC_class_t *type, - haddr_t old, haddr_t new); -herr_t H5AC_set (hdf5_file_t *f, const H5AC_class_t *type, haddr_t addr, +herr_t H5AC_new (H5F_t *f, intn size_hint); +herr_t H5AC_rename (H5F_t *f, const H5AC_class_t *type, haddr_t old, + haddr_t new); +herr_t H5AC_set (H5F_t *f, const H5AC_class_t *type, haddr_t addr, void *thing); #define H5AC_find(F,TYPE,ADDR,UDATA) \ - (((F)->cache->slot[H5AC_HASH(F,ADDR)].type==(TYPE) && \ - (F)->cache->slot[H5AC_HASH(F,ADDR)].addr==(ADDR)) ? \ - (F)->cache->slot[H5AC_HASH(F,ADDR)].thing : \ + (((F)->shared->cache->slot[H5AC_HASH(F,ADDR)].type==(TYPE) && \ + (F)->shared->cache->slot[H5AC_HASH(F,ADDR)].addr==(ADDR)) ? \ + (F)->shared->cache->slot[H5AC_HASH(F,ADDR)].thing : \ H5AC_find_f (F, TYPE, ADDR, UDATA)) diff --git a/src/H5B.c b/src/H5B.c index 8fe6790..cb3d2bb 100644 --- a/src/H5B.c +++ b/src/H5B.c @@ -99,25 +99,23 @@ #define BOUND(MIN,X,MAX) ((X)<(MIN)?(MIN):((X)>(MAX)?(MAX):(X))) /* PRIVATE PROTOTYPES */ -static haddr_t H5B_insert_helper (hdf5_file_t *f, haddr_t addr, - H5B_class_t *type, +static haddr_t H5B_insert_helper (H5F_t *f, haddr_t addr, H5B_class_t *type, uint8 *lt_key, hbool_t *lt_key_changed, uint8 *md_key, void *udata, uint8 *rt_key, hbool_t *rt_key_changed); -static herr_t H5B_insert_child (hdf5_file_t *f, const H5B_class_t *type, +static herr_t H5B_insert_child (H5F_t *f, const H5B_class_t *type, H5B_t *bt, intn idx, haddr_t child, intn anchor, void *md_key); -static herr_t H5B_flush (hdf5_file_t *f, hbool_t destroy, haddr_t addr, - H5B_t *b); -static H5B_t *H5B_load (hdf5_file_t *f, haddr_t addr, void *_data); -static herr_t H5B_decode_key (hdf5_file_t *f, H5B_t *bt, intn idx); -static size_t H5B_nodesize (hdf5_file_t *f, const H5B_class_t *type, +static herr_t H5B_flush (H5F_t *f, hbool_t destroy, haddr_t addr, H5B_t *b); +static H5B_t *H5B_load (H5F_t *f, haddr_t addr, void *_data); +static herr_t H5B_decode_key (H5F_t *f, H5B_t *bt, intn idx); +static size_t H5B_nodesize (H5F_t *f, const H5B_class_t *type, size_t *total_nkey_size, size_t sizeof_rkey); /* H5B inherits cache-like properties from H5AC */ static const H5AC_class_t H5AC_BT[1] = {{ - (void*(*)(hdf5_file_t*,haddr_t,void*))H5B_load, - (herr_t(*)(hdf5_file_t*,hbool_t,haddr_t,void*))H5B_flush, + (void*(*)(H5F_t*,haddr_t,void*))H5B_load, + (herr_t(*)(H5F_t*,hbool_t,haddr_t,void*))H5B_flush, }}; /* Is the H5B interface initialized? */ @@ -142,7 +140,7 @@ static interface_initialize_g = FALSE; *------------------------------------------------------------------------- */ haddr_t -H5B_new (hdf5_file_t *f, const H5B_class_t *type) +H5B_new (H5F_t *f, const H5B_class_t *type) { H5B_t *bt=NULL; haddr_t addr; @@ -231,7 +229,7 @@ H5B_new (hdf5_file_t *f, const H5B_class_t *type) *------------------------------------------------------------------------- */ static H5B_t * -H5B_load (hdf5_file_t *f, haddr_t addr, void *_data) +H5B_load (H5F_t *f, haddr_t addr, void *_data) { const H5B_class_t *type = (H5B_class_t *)_data; size_t size, total_nkey_size; @@ -334,7 +332,7 @@ H5B_load (hdf5_file_t *f, haddr_t addr, void *_data) *------------------------------------------------------------------------- */ static herr_t -H5B_flush (hdf5_file_t *f, hbool_t destroy, haddr_t addr, H5B_t *bt) +H5B_flush (H5F_t *f, hbool_t destroy, haddr_t addr, H5B_t *bt) { intn i; size_t size = 0; @@ -444,7 +442,7 @@ H5B_flush (hdf5_file_t *f, hbool_t destroy, haddr_t addr, H5B_t *bt) *------------------------------------------------------------------------- */ herr_t -H5B_find (hdf5_file_t *f, H5B_class_t *type, haddr_t addr, void *udata) +H5B_find (H5F_t *f, H5B_class_t *type, haddr_t addr, void *udata) { H5B_t *bt=NULL; intn idx=-1, lt=0, rt, cmp=1; @@ -544,8 +542,8 @@ done: *------------------------------------------------------------------------- */ static haddr_t -H5B_split (hdf5_file_t *f, H5B_class_t *type, H5B_t *old_bt, - haddr_t old_addr, intn anchor) +H5B_split (H5F_t *f, H5B_class_t *type, H5B_t *old_bt, haddr_t old_addr, + intn anchor) { H5B_t *new_bt=NULL, *tmp_bt=NULL; haddr_t ret_value=FAIL, new_addr=FAIL; @@ -699,7 +697,7 @@ done: *------------------------------------------------------------------------- */ static herr_t -H5B_decode_key (hdf5_file_t *f, H5B_t *bt, intn idx) +H5B_decode_key (H5F_t *f, H5B_t *bt, intn idx) { FUNC_ENTER (H5B_decode_key, NULL, FAIL); @@ -733,7 +731,7 @@ H5B_decode_key (hdf5_file_t *f, H5B_t *bt, intn idx) *------------------------------------------------------------------------- */ haddr_t -H5B_insert (hdf5_file_t *f, H5B_class_t *type, haddr_t addr, void *udata) +H5B_insert (H5F_t *f, H5B_class_t *type, haddr_t addr, void *udata) { uint8 lt_key[256], md_key[256], rt_key[256]; hbool_t lt_key_changed=FALSE, rt_key_changed=FALSE; @@ -878,7 +876,7 @@ H5B_insert (hdf5_file_t *f, H5B_class_t *type, haddr_t addr, void *udata) *------------------------------------------------------------------------- */ static herr_t -H5B_insert_child (hdf5_file_t *f, const H5B_class_t *type, H5B_t *bt, +H5B_insert_child (H5F_t *f, const H5B_class_t *type, H5B_t *bt, intn idx, haddr_t child, intn anchor, void *md_key) { size_t recsize; @@ -986,7 +984,7 @@ H5B_insert_child (hdf5_file_t *f, const H5B_class_t *type, H5B_t *bt, *------------------------------------------------------------------------- */ static haddr_t -H5B_insert_helper (hdf5_file_t *f, haddr_t addr, H5B_class_t *type, +H5B_insert_helper (H5F_t *f, haddr_t addr, H5B_class_t *type, uint8 *lt_key, hbool_t *lt_key_changed, uint8 *md_key, void *udata, uint8 *rt_key, hbool_t *rt_key_changed) @@ -1225,7 +1223,7 @@ done: *------------------------------------------------------------------------- */ herr_t -H5B_list (hdf5_file_t *f, H5B_class_t *type, haddr_t addr, void *udata) +H5B_list (H5F_t *f, H5B_class_t *type, haddr_t addr, void *udata) { H5B_t *bt=NULL; haddr_t next_addr; @@ -1307,7 +1305,7 @@ done: *------------------------------------------------------------------------- */ static size_t -H5B_nodesize (hdf5_file_t *f, const H5B_class_t *type, +H5B_nodesize (H5F_t *f, const H5B_class_t *type, size_t *total_nkey_size, size_t sizeof_rkey) { size_t size; @@ -1357,7 +1355,7 @@ H5B_nodesize (hdf5_file_t *f, const H5B_class_t *type, *------------------------------------------------------------------------- */ herr_t -H5B_debug (hdf5_file_t *f, haddr_t addr, FILE *stream, intn indent, +H5B_debug (H5F_t *f, haddr_t addr, FILE *stream, intn indent, intn fwidth, H5B_class_t *type) { H5B_t *bt = NULL; diff --git a/src/H5Bprivate.h b/src/H5Bprivate.h index f7c3e50..7814eeb 100644 --- a/src/H5Bprivate.h +++ b/src/H5Bprivate.h @@ -31,7 +31,7 @@ 2*H5F_SIZEOF_OFFSET(F)) /*left and right sibling addresses */ #define H5B_K(F,TYPE) /*K value given file and Btree subclass */ \ - ((F)->file_create_parms.btree_k[(TYPE)->id]) + ((F)->shared->file_create_parms.btree_k[(TYPE)->id]) #define H5B_ANCHOR_LT 0 /* left node is anchored, right is new */ #define H5B_ANCHOR_RT 1 /* right node is anchored, left is new */ @@ -51,15 +51,15 @@ typedef enum H5B_subid_t { typedef struct H5B_class_t { H5B_subid_t id; /*id as found in file */ size_t sizeof_nkey; /*size of native (memory) key */ - size_t (*get_sizeof_rkey)(hdf5_file_t*); - haddr_t (*new)(hdf5_file_t*,void*,void*,void*); - intn (*cmp)(hdf5_file_t*,void*,void*,void*); - herr_t (*found)(hdf5_file_t*,haddr_t,const void*,void*,const void*); - haddr_t (*insert)(hdf5_file_t*,haddr_t,int*,void*,hbool_t*,void*,void*, + size_t (*get_sizeof_rkey)(H5F_t*); + haddr_t (*new)(H5F_t*,void*,void*,void*); + intn (*cmp)(H5F_t*,void*,void*,void*); + herr_t (*found)(H5F_t*,haddr_t,const void*,void*,const void*); + haddr_t (*insert)(H5F_t*,haddr_t,int*,void*,hbool_t*,void*,void*, void*,hbool_t*); - herr_t (*list)(hdf5_file_t*,haddr_t,void*); - herr_t (*decode)(hdf5_file_t*,uint8*,void*); - herr_t (*encode)(hdf5_file_t*,uint8*,void*); + herr_t (*list)(H5F_t*,haddr_t,void*); + herr_t (*decode)(H5F_t*,uint8*,void*); + herr_t (*encode)(H5F_t*,uint8*,void*); } H5B_class_t; /* @@ -90,15 +90,12 @@ typedef struct H5B_t { /* * Library prototypes. */ -herr_t H5B_debug (hdf5_file_t *f, haddr_t addr, FILE *stream, intn indent, +herr_t H5B_debug (H5F_t *f, haddr_t addr, FILE *stream, intn indent, intn fwidth, H5B_class_t *type); -haddr_t H5B_new (hdf5_file_t *f, const H5B_class_t *type); -herr_t H5B_find (hdf5_file_t *f, H5B_class_t *type, haddr_t addr, - void *udata); -haddr_t H5B_insert (hdf5_file_t *f, H5B_class_t *type, haddr_t addr, - void *udata); -herr_t H5B_list (hdf5_file_t *f, H5B_class_t *type, haddr_t addr, - void *udata); +haddr_t H5B_new (H5F_t *f, const H5B_class_t *type); +herr_t H5B_find (H5F_t *f, H5B_class_t *type, haddr_t addr, void *udata); +haddr_t H5B_insert (H5F_t *f, H5B_class_t *type, haddr_t addr, void *udata); +herr_t H5B_list (H5F_t *f, H5B_class_t *type, haddr_t addr, void *udata); #endif diff --git a/src/H5D.c b/src/H5D.c index 4ed1fa6..86072e1 100644 --- a/src/H5D.c +++ b/src/H5D.c @@ -49,7 +49,7 @@ static char RcsId[] = "@(#)$Revision$"; * A dataset is the following struct. */ typedef struct H5D_t { - hdf5_file_t *file; /* File store for this object */ + H5F_t *file; /* File store for this object */ H5G_entry_t *ent; /* Cached object header stuff */ h5_datatype_t *type; /* Datatype of this dataset */ H5P_dim_t *dim; /* Dimensionality of this dataset */ @@ -129,7 +129,7 @@ hid_t H5D_create(hid_t owner_id, hobjtype_t type, const char *name) { H5D_t *new_dset; /* new dataset object to create */ hid_t ret_value = SUCCEED; - hdf5_file_t *file = NULL; + H5F_t *file = NULL; FUNC_ENTER(H5D_create, H5D_init_interface, FAIL); @@ -190,7 +190,7 @@ done: --------------------------------------------------------------------------*/ hid_t H5D_find_name(hid_t grp_id, hobjtype_t type, const char *name) { - hdf5_file_t *file; /* Pointer to the file-store of this object */ + H5F_t *file; /* Pointer to the file-store of this object */ H5D_t *dset = NULL; /* The dataset */ hid_t ret_value = SUCCEED; H5O_std_store_t store; diff --git a/src/H5F.c b/src/H5F.c index d2979fa..8b66d9b 100644 --- a/src/H5F.c +++ b/src/H5F.c @@ -46,6 +46,10 @@ static char RcsId[] = "@(#)$Revision$"; #include /*meta data */ #include /*core memory management */ +#include +#include + + #define PABLO_MASK H5F_mask /*--------------------- Locally scoped variables -----------------------------*/ @@ -55,9 +59,10 @@ static intn interface_initialize_g = FALSE; /*--------------------- Local function prototypes ----------------------------*/ static herr_t H5F_init_interface(void); -static hdf5_file_t *H5F_new (void); -static hdf5_file_t *H5F_dest (hdf5_file_t *f); -static herr_t H5F_flush (hdf5_file_t *f, hbool_t invalidate); +static H5F_t *H5F_new (H5F_file_t *shared); +static H5F_t *H5F_dest (H5F_t *f); +static herr_t H5F_flush (H5F_t *f, hbool_t invalidate); +static herr_t H5F_close (H5F_t *f); /*-------------------------------------------------------------------------- NAME @@ -118,7 +123,7 @@ void H5F_term_interface (void) H5F_encode_length_unusual -- encode an unusual length size USAGE void H5F_encode_length_unusual(f, p, l) - const hdf5_file_t *f; IN: pointer to the file record + const H5F_t *f; IN: pointer to the file record uint8 **p; IN: pointer to buffer pointer to encode length in uint8 *l; IN: pointer to length to encode @@ -129,15 +134,18 @@ void H5F_term_interface (void) DESCRIPTION Encode non-standard (i.e. not 2, 4 or 8-byte) lengths in file meta-data. --------------------------------------------------------------------------*/ -void H5F_encode_length_unusual(const hdf5_file_t *f, uint8 **p, uint8 *l) +void H5F_encode_length_unusual(const H5F_t *f, uint8 **p, uint8 *l) { intn i = H5F_SIZEOF_SIZE (f); -/* For non-little-endian platforms, encode each byte in memory backwards */ -#if ((DF_MT&0xFFF0)!=0x4440) +#ifdef WORDS_BIGENDIAN + /* + * For non-little-endian platforms, encode each byte in memory backwards. + */ for(; i>=0; i--,(*p)++) *(*p)=*(l+i); -#else /* platform has little-endian integers */ +#else + /* platform has little-endian integers */ for(; i>=0; i--,(*p)++) *(*p)=*l; #endif @@ -159,7 +167,7 @@ done: H5F_encode_offset_unusual -- encode an unusual offset size USAGE void H5F_encode_offset_unusual(f, p, o) - const hdf5_file_t *f; IN: pointer to the file record + const H5F_t *f; IN: pointer to the file record uint8 **p; IN: pointer to buffer pointer to encode offset in uint8 *o; IN: pointer to offset to encode @@ -170,15 +178,18 @@ ERRORS DESCRIPTION Encode non-standard (i.e. not 2, 4 or 8-byte) offsets in file meta-data. --------------------------------------------------------------------------*/ -void H5F_encode_offset_unusual(const hdf5_file_t *f, uint8 **p, uint8 *o) +void H5F_encode_offset_unusual(const H5F_t *f, uint8 **p, uint8 *o) { intn i = H5F_SIZEOF_OFFSET(f); -/* For non-little-endian platforms, encode each byte in memory backwards */ -#if ((DF_MT&0xFFF0)!=0x4440) +#ifdef WORDS_BIGENDIAN + /* + * For non-little-endian platforms, encode each byte in memory backwards. + */ for(; i>=0; i--,(*p)++) *(*p)=*(o+i); -#else /* platform has little-endian integers */ +#else + /* platform has little-endian integers */ for(; i>=0; i--,(*p)++) *(*p)=*o; #endif @@ -198,11 +209,11 @@ done: /*-------------------------------------------------------------------------- NAME - H5F_compare_filename -- compare file objects for the atom API + H5F_compare_files -- compare file objects for the atom API USAGE intn HPcompare_filename(obj, key) const VOIDP obj; IN: pointer to the file record - const VOIDP key; IN: pointer to the name of file + const VOIDP key; IN: pointer to the search key ERRORS @@ -210,21 +221,22 @@ done: TRUE if the key matches the obj, FALSE otherwise DESCRIPTION Look inside the file record for the atom API and compare the the - filenames. + keys. --------------------------------------------------------------------------*/ -intn -H5F_compare_filename (const VOIDP _obj, const VOIDP _key) +static intn +H5F_compare_files (const VOIDP _obj, const VOIDP _key) { - const hdf5_file_t *obj = (const hdf5_file_t *)_obj; - const char *key = (const char *)_key; + const H5F_t *obj = (const H5F_t *)_obj; + const H5F_search_t *key = (const H5F_search_t *)_key; int ret_value = FALSE; - FUNC_ENTER (H5F_compare_filename, NULL, FALSE); + FUNC_ENTER (H5F_compare_files, NULL, FALSE); - ret_value = !HDstrcmp (obj->filename, key); + ret_value = (obj->shared->key.dev == key->dev && + obj->shared->key.ino == key->ino); FUNC_LEAVE (ret_value); -} /* H5F_compare_filename */ +} /*-------------------------------------------------------------------------- NAME @@ -251,7 +263,7 @@ H5F_compare_filename (const VOIDP _obj, const VOIDP _key) --------------------------------------------------------------------------*/ hid_t H5Fget_create_template(hid_t fid) { - hdf5_file_t *file=NULL; /* file struct for file to close */ + H5F_t *file=NULL; /* file struct for file to close */ hid_t ret_value = FAIL; FUNC_ENTER(H5Fget_create_template, H5F_init_interface, FAIL); @@ -267,7 +279,7 @@ hid_t H5Fget_create_template(hid_t fid) if((ret_value=H5Mcreate(fid,H5_TEMPLATE,NULL))==FAIL) HGOTO_ERROR(H5E_FUNC, H5E_CANTCREATE, FAIL); /*can't create template*/ - if(H5C_init(ret_value,&(file->file_create_parms))==FAIL) + if(H5C_init(ret_value,&(file->shared->file_create_parms))==FAIL) HGOTO_ERROR(H5E_FUNC, H5E_CANTINIT, FAIL); /*can't init template*/ done: @@ -351,22 +363,13 @@ hbool_t H5Fis_hdf5(const char *filename) else curr_off*=2; } /* end while */ - H5F_CLOSE(f_handle); /* close the file we opened */ -done: - if(ret_value == BFAIL) - { /* Error condition cleanup */ - - /* Check if we left a dangling file handle */ - if(f_handle!=H5F_INVALID_FILE) - H5F_CLOSE(f_handle); /* close the file we opened */ - - } /* end if */ - - /* Normal function cleanup */ + done: + if(f_handle!=H5F_INVALID_FILE) + H5F_CLOSE(f_handle); /* close the file we opened */ FUNC_LEAVE(ret_value); -} /* end H5Fis_hdf5() */ +} /*------------------------------------------------------------------------- @@ -374,7 +377,9 @@ done: * * Purpose: Creates a new file object and initializes it. The * H5Fopen and H5Fcreate functions then fill in various - * fields. + * fields. If SHARED is a non-null pointer then the shared info + * to which it points has the reference count incremented. + * Otherwise a new, empty shared info struct is created. * * Errors: * @@ -390,22 +395,33 @@ done: * *------------------------------------------------------------------------- */ -static hdf5_file_t * -H5F_new (void) +static H5F_t * +H5F_new (H5F_file_t *shared) { - hdf5_file_t *f = H5MM_xcalloc (1, sizeof(hdf5_file_t)); + H5F_t *f = NULL; + FUNC_ENTER (H5F_new, H5F_init_interface, NULL); - /* Create a main cache */ - H5AC_new (f, H5AC_NSLOTS); + f = H5MM_xcalloc (1, sizeof(H5F_t)); + f->shared = shared; + + if (!f->shared) { + f->shared = H5MM_xcalloc (1, sizeof(H5F_file_t)); - /* Create the shadow hash table */ - f->nshadows = H5G_NSHADOWS; - f->shadow = H5MM_xcalloc (f->nshadows, sizeof(struct H5G_hash_t*)); + /* Create a main cache */ + H5AC_new (f, H5AC_NSLOTS); - /* Create a root symbol slot */ - f->root_sym = H5G_ent_calloc (); - - return f; + /* Create the shadow hash table */ + f->shared->nshadows = H5G_NSHADOWS; + f->shared->shadow = H5MM_xcalloc (f->shared->nshadows, + sizeof(struct H5G_hash_t*)); + + /* Create a root symbol slot */ + f->shared->root_sym = H5G_ent_calloc (); + } + + f->shared->nrefs++; + + FUNC_LEAVE (f); } @@ -414,7 +430,8 @@ H5F_new (void) * * Purpose: Destroys a file structure. This function does not flush * the cache or anything else; it only frees memory associated - * with the file struct. + * with the file struct. The shared info for the file is freed + * only when its reference count reaches zero. * * Errors: * @@ -430,19 +447,384 @@ H5F_new (void) * *------------------------------------------------------------------------- */ -static hdf5_file_t * -H5F_dest (hdf5_file_t *f) +static H5F_t * +H5F_dest (H5F_t *f) { + FUNC_ENTER (H5F_dest, H5F_init_interface, NULL); + if (f) { - H5AC_dest (f); - f->dir = H5MM_xfree (f->dir); - f->filename = H5MM_xfree (f->filename); - f->root_sym = H5MM_xfree (f->root_sym); - f->nshadows = 0; - f->shadow = H5MM_xfree (f->shadow); + if (0 == --(f->shared->nrefs)) { + H5AC_dest (f); + f->shared->root_sym = H5MM_xfree (f->shared->root_sym); + f->shared->nshadows = 0; + f->shared->shadow = H5MM_xfree (f->shared->shadow); + f->shared = H5MM_xfree (f->shared); + } + f->name = H5MM_xfree (f->name); H5MM_xfree (f); } - return NULL; + + FUNC_LEAVE (NULL); +} + + + +/*------------------------------------------------------------------------- + * Function: H5F_open + * + * Purpose: Opens (or creates) a file. This function understands the + * following flags which are similar in nature to the Posix + * open(2) flags. + * + * H5F_ACC_WRITE: Open with read/write access. If the file is + * currently open for read-only access then it + * will be reopened. Absence of this flag + * implies read-only access. + * + * H5F_ACC_CREAT: Create a new file if it doesn't exist yet. + * The permissions are 0666 bit-wise AND with + * the current umask. H5F_ACC_WRITE must also + * be specified. + * + * H5F_ACC_EXCL: This flag causes H5F_open() to fail if the + * file already exists. + * + * H5F_ACC_TRUNC: The file is truncated and a new HDF5 boot + * block is written. This operation will fail + * if the file is already open. + * + * Unlinking the file name from the directory hierarchy while + * the file is opened causes the file to continue to exist but + * one will not be able to upgrade the file from read-only + * access to read-write access by reopening it. Disk resources + * for the file are released when all handles to the file are + * closed. NOTE: This paragraph probably only applies to Unix; + * deleting the file name in other OS's has undefined results. + * + * Errors: + * FILE BADVALUE Can't create file without write + * intent. + * FILE BADVALUE Can't truncate without write intent. + * FILE CANTCREATE Can't create file. + * FILE CANTCREATE Can't stat file. + * FILE CANTCREATE Can't truncate file. + * FILE CANTINIT Can't write file boot block. + * FILE CANTINIT Cannot determine file size. + * FILE CANTOPENFILE Bad boot block version number. + * FILE CANTOPENFILE Bad free space version number. + * FILE CANTOPENFILE Bad length size. + * FILE CANTOPENFILE Bad object dir version number. + * FILE CANTOPENFILE Bad offset size. + * FILE CANTOPENFILE Bad shared header version number. + * FILE CANTOPENFILE Bad small object heap version number. + * FILE CANTOPENFILE Bad symbol table internal node 1/2 + * rank. + * FILE CANTOPENFILE Bad symbol table leaf node 1/2 rank. + * FILE CANTOPENFILE Can't read root symbol entry. + * FILE CANTOPENFILE Cannot open existing file. + * FILE CANTOPENFILE File cannot be reopened with write + * access. + * FILE CANTOPENFILE File does not exist. + * FILE FILEEXISTS File already exists - CREAT EXCL + * failed. + * FILE FILEOPEN File already open - TRUNC failed. + * FILE NOTHDF5 Can't read boot block. + * FILE READERROR File is not readable. + * FILE WRITEERROR File is not writable. + * + * Return: Success: Ptr to the file pointer. + * + * Failure: NULL + * + * Programmer: Robb Matzke + * Tuesday, September 23, 1997 + * + * Modifications: + * + *------------------------------------------------------------------------- + */ +static H5F_t * +H5F_open (const char *name, uintn flags, + const file_create_temp_t *create_parms) +{ + H5F_t *f = NULL; /*return value */ + H5F_t *ret_value = NULL; /*a copy of `f' */ + H5F_t *old = NULL; /*a file already opened */ + struct stat sb; /*file stat info */ + H5F_search_t search; /*file search key */ + hdf_file_t fd = H5F_INVALID_FILE; /*low level file desc */ + hbool_t empty_file = FALSE; /*is file empty? */ + hbool_t file_exists = FALSE; /*file already exists */ + uint8 buf[256], *p=NULL; /*I/O buffer and ptr into it */ + size_t fixed_size = 24; /*size of fixed part of boot blk*/ + size_t variable_size; /*variable part of boot block */ + intn i; + file_create_temp_t *cp=NULL; /*file creation parameters */ + + FUNC_ENTER (H5F_open, H5F_init_interface, NULL); + + assert (name && *name); + + /* + * Does the file exist? If so, get the device and i-node values so we can + * compare them with other files already open. On Unix (and other systems + * with hard or soft links) it doesn't work to compare files based only on + * their full path name. + */ + file_exists = (stat (name, &sb)>=0); + + /* + * Open the low-level file (if necessary) and create an H5F_t struct that + * points to an H5F_file_t struct. + */ + if (file_exists) { + if (flags & H5F_ACC_EXCL) { + /* File already exists - CREAT EXCL failed */ + HRETURN_ERROR (H5E_FILE, H5E_FILEEXISTS, NULL); + } + if (access (name, R_OK)<0) { + /* File is not readable */ + HRETURN_ERROR (H5E_FILE, H5E_READERROR, NULL); + } + if ((flags & H5F_ACC_WRITE) && access (name, W_OK)<0) { + /* File is not writable */ + HRETURN_ERROR (H5E_FILE, H5E_WRITEERROR, NULL); + } + + search.dev = sb.st_dev; + search.ino = sb.st_ino; + if ((old=H5Asearch_atom (H5_FILE, H5F_compare_files, &search))) { + if (flags & H5F_ACC_TRUNC) { + /* File already open - TRUNC failed */ + HRETURN_ERROR (H5E_FILE, H5E_FILEOPEN, NULL); + } + if ((flags & H5F_ACC_WRITE) && + 0==(old->shared->flags & H5F_ACC_WRITE)) { + if (H5F_INVALID_FILE==(fd = H5F_OPEN (name, H5ACC_WRITE))) { + /* File cannot be reopened with write access */ + HRETURN_ERROR (H5E_FILE, H5E_CANTOPENFILE, NULL); + } + H5F_CLOSE (old->shared->file_handle); + old->shared->file_handle = fd; + old->shared->flags |= H5F_ACC_WRITE; + fd = H5F_INVALID_FILE; /*so we don't close it during error*/ + } + f = H5F_new (old->shared); + + } else if (flags & H5F_ACC_TRUNC) { + /* Truncate existing file */ + if (0==(flags & H5F_ACC_WRITE)) { + /* Can't truncate without write intent */ + HRETURN_ERROR (H5E_FILE, H5E_BADVALUE, NULL); + } + if (H5F_INVALID_FILE==(fd=H5F_CREATE (name))) { + /* Can't truncate file */ + HRETURN_ERROR (H5E_FILE, H5E_CANTCREATE, NULL); + } + f = H5F_new (NULL); + f->shared->key.dev = sb.st_dev; + f->shared->key.ino = sb.st_ino; + f->shared->flags = flags; + f->shared->file_handle = fd; + empty_file = TRUE; + + } else { + fd = H5F_OPEN (name, (flags & H5F_ACC_WRITE)?H5ACC_WRITE : 0); + if (H5F_INVALID_FILE==fd) { + /* Cannot open existing file */ + HRETURN_ERROR (H5E_FILE, H5E_CANTOPENFILE, NULL); + } + f = H5F_new (NULL); + f->shared->key = search; + f->shared->flags = flags; + f->shared->file_handle = fd; + } + + } else if (flags & H5F_ACC_CREAT) { + if (0==(flags & H5F_ACC_WRITE)) { + /* Can't create file without write intent */ + HRETURN_ERROR (H5E_FILE, H5E_BADVALUE, NULL); + } + if (H5F_INVALID_FILE==(fd=H5F_CREATE (name))) { + /* Can't create file */ + HRETURN_ERROR (H5E_FILE, H5E_CANTCREATE, NULL); + } + if (stat (name, &sb)<0) { + /* Can't stat file */ + HRETURN_ERROR (H5E_FILE, H5E_CANTCREATE, NULL); + } + f = H5F_new (NULL); + f->shared->key.dev = sb.st_dev; + f->shared->key.ino = sb.st_ino; + f->shared->flags = flags; + f->shared->file_handle = fd; + empty_file = TRUE; + + } else { + /* File does not exist */ + HRETURN_ERROR (H5E_FILE, H5E_CANTOPENFILE, NULL); + } + assert (f); + + /* + * The intent at the top level file struct are not necessarily the same as + * the flags at the bottom. The top level describes how the file can be + * accessed through the HDF5 library. The bottom level describes how the + * file can be accessed through the C library. + */ + f->intent = flags; + f->name = H5MM_xstrdup (name); + + /* + * Update the file creation parameters with default values if this is the + * first time this file is opened. + */ + if (1==f->shared->nrefs) { + HDmemcpy (&(f->shared->file_create_parms), + create_parms, + sizeof(file_create_temp_t)); + } + cp = &(f->shared->file_create_parms); + + /* + * Read or write the file boot block. + */ + if (empty_file) { + /* For new files we must write the boot block. */ + f->shared->consist_flags = 0x03; + if (H5F_flush (f, FALSE)<0) { + /* Can't write file boot block */ + HGOTO_ERROR (H5E_FILE, H5E_CANTINIT, NULL); + } + } else if (1==f->shared->nrefs) { + /* For existing files we must read the boot block. */ + assert (fixed_size <= sizeof buf); + for (i=8; i<32*sizeof(haddr_t); i++) { + cp->userblock_size = (8==i ? 0 : 1<bootblock_ver = *p++; + if (cp->bootblock_ver != HDF5_BOOTBLOCK_VERSION) { + /* Bad boot block version number */ + HGOTO_ERROR (H5E_FILE, H5E_CANTOPENFILE, NULL); + } + + cp->smallobject_ver = *p++; + if (cp->smallobject_ver != HDF5_SMALLOBJECT_VERSION) { + /* Bad small object heap version number */ + HGOTO_ERROR (H5E_FILE, H5E_CANTOPENFILE, NULL); + } + + cp->freespace_ver = *p++; + if (cp->freespace_ver != HDF5_FREESPACE_VERSION) { + /* Bad free space version number */ + HGOTO_ERROR (H5E_FILE, H5E_CANTOPENFILE, NULL); + } + + cp->objectdir_ver = *p++; + if (cp->objectdir_ver != HDF5_OBJECTDIR_VERSION) { + /* Bad object dir version number */ + HGOTO_ERROR (H5E_FILE, H5E_CANTOPENFILE, NULL); + } + + cp->sharedheader_ver = *p++; + if (cp->sharedheader_ver != HDF5_SHAREDHEADER_VERSION) { + /* Bad shared header version number */ + HGOTO_ERROR (H5E_FILE, H5E_CANTOPENFILE, NULL); + } + + cp->offset_size = *p++; + if (cp->offset_size!=2 && + cp->offset_size!=4 && + cp->offset_size!=8) { + /* Bad offset size */ + HGOTO_ERROR (H5E_FILE, H5E_CANTOPENFILE, NULL); + } + + cp->length_size = *p++; + if (cp->length_size!=2 && + cp->length_size!=4 && + cp->length_size!=8) { + /* Bad length size */ + HGOTO_ERROR (H5E_FILE, H5E_CANTOPENFILE, NULL); + } + + /* Reserved byte */ + p++; + + UINT16DECODE (p, cp->sym_leaf_k); + if (cp->sym_leaf_k<1) { + /* Bad symbol table leaf node 1/2 rank */ + HGOTO_ERROR (H5E_FILE, H5E_CANTOPENFILE, NULL); + } + + UINT16DECODE (p, cp->btree_k[H5B_SNODE_ID]); + if (cp->btree_k[H5B_SNODE_ID]<1) { + /* Bad symbol table internal node 1/2 rank */ + HGOTO_ERROR (H5E_FILE, H5E_CANTOPENFILE, NULL); + } + + UINT32DECODE (p, f->shared->consist_flags); + /* nothing to check for consistency flags */ + + assert (p-buf == fixed_size); + + /* Read the variable length part of the boot block... */ + variable_size = H5F_SIZEOF_OFFSET (f) + /*global small obj heap*/ + H5F_SIZEOF_OFFSET (f) + /*global free list addr*/ + H5F_SIZEOF_SIZE (f) + /*logical file size*/ + H5G_SIZEOF_ENTRY (f); + assert (variable_size <= sizeof buf); + if (H5F_block_read (f, fixed_size, variable_size, buf)<0) { + /*can't read boot block*/ + HGOTO_ERROR (H5E_FILE, H5E_NOTHDF5, NULL); + } + + p = buf; + H5F_decode_offset (f, p, f->shared->smallobj_off); + H5F_decode_offset (f, p, f->shared->freespace_off); + H5F_decode_length (f, p, f->shared->logical_len); + if (H5G_ent_decode (f, &p, f->shared->root_sym)<0) { + /*can't read root symbol entry*/ + HGOTO_ERROR (H5E_FILE, H5E_CANTOPENFILE, NULL); + } + break; + } + } + + /* What is the current size of the file? */ + if (H5F_SEEKEND (f->shared->file_handle)<0) { + /* Cannot determine file size */ + HGOTO_ERROR (H5E_FILE, H5E_CANTINIT, NULL); + } + f->shared->logical_len = H5F_TELL (f->shared->file_handle); + + + + /* Success! */ + ret_value = f; + + done: + if (!ret_value) { + if (f) H5F_dest (f); + if (H5F_INVALID_FILE!=fd) H5F_CLOSE (fd); + } + + FUNC_LEAVE (ret_value); } /*-------------------------------------------------------------------------- @@ -462,16 +844,9 @@ H5F_dest (hdf5_file_t *f) ERRORS ARGS BADVALUE Invalid file name. ARGS BADVALUE Invalid flags. - ATOM BADATOM Can't atomize template. ATOM BADATOM Can't unatomize template. ATOM CANTREGISTER Can't atomize file. - FILE CANTCREATE Unable to create the file due to low level create - failure. - FILE FILEEXISTS File already exists but overwrite permission - was not given. - FILE FILEOPEN File already open. - IO CANTINIT Can't write file boot block. - RESOURCE NOSPACE H5F_new() failed. + FILE CANTOPENFILE Can't create file. RETURNS Returns file ID on success, FAIL on failure @@ -483,8 +858,9 @@ H5F_dest (hdf5_file_t *f) may be combined with the "||" (logical OR operator) to change the behavior of the file open call. The flags currently defined: - H5ACC_OVERWRITE - Truncate file, if it already exists. The file will - be truncated, erasing all data previously stored in the file. + H5ACC_OVERWRITE - Truncate file, if it already exists. The file + will be truncated, erasing all data previously stored in the + file. The more complex behaviors of a file's creation and access are controlled through the file-creation and file-access templates. The value of 0 for a template value indicates that the library should use the default @@ -499,104 +875,62 @@ H5F_dest (hdf5_file_t *f) Robb Matzke, 29 Aug 1997 Moved creation of the boot block to H5F_flush(). + + Robb Matzke, 23 Sep 1997 + Most of the work is now done by H5F_open() since H5Fcreate() and H5Fopen() + originally contained almost identical code. --------------------------------------------------------------------------*/ -hid_t H5Fcreate(const char *filename, uintn flags, hid_t create_temp, hid_t access_temp) +hid_t H5Fcreate(const char *filename, uintn flags, hid_t create_temp, + hid_t access_temp) { - hdf5_file_t *new_file=NULL; /* file struct for new file */ - hdf_file_t f_handle=H5F_INVALID_FILE; /* file handle */ - const file_create_temp_t *f_create_parms; /* pointer to the parameters to use when creating the file */ - intn file_exists=0; /* flag to indicate that file exists already */ - hid_t ret_value = FAIL; + H5F_t *new_file=NULL; /* file struct for new file */ + const file_create_temp_t *create_parms; /* pointer to the parameters to + * use when creating the file + */ + hid_t ret_value = FAIL; FUNC_ENTER(H5Fcreate, H5F_init_interface, FAIL); - - /* Clear errors and check args and all the boring stuff. */ H5ECLEAR; - if(filename==NULL) - HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL); /*invalid file name*/ - if((flags&~H5ACC_OVERWRITE)!=0) - HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL); /*invalid flags*/ - - /* See if this file is already open */ - if(H5Asearch_atom(H5_FILE,H5F_compare_filename,(const VOIDP)filename)!=NULL) - HGOTO_ERROR(H5E_FILE, H5E_FILEOPEN, FAIL); /*file already open*/ - - /* Check if the file already exists */ - f_handle=H5F_OPEN(filename,0); - if(!H5F_OPENERR(f_handle)) - { - file_exists=1; /* set the flag to indicate that the file already exists */ - H5F_CLOSE(f_handle); /* close the file we opened */ - f_handle=H5F_INVALID_FILE; - } /* end if */ - - if((flags&H5ACC_OVERWRITE)==0 && file_exists) { - /* File already exists but overwrite permission was not given */ - HGOTO_ERROR(H5E_FILE, H5E_FILEEXISTS, FAIL); - } - - /* OK to create/overwrite the file */ - f_handle=H5F_CREATE(filename); - if(H5F_OPENERR(f_handle)) { - /* Unable to create the file due to low level create failure */ - HGOTO_ERROR(H5E_FILE, H5E_CANTCREATE, FAIL); - } - - /* Create the file node */ - if (NULL==(new_file=H5F_new())) - HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, FAIL); /*H5F_new() failed*/ - - /* Set the non-zero elements of the file structure */ - new_file->dir=HDgetcwd(NULL,0); /* get the directory we just created the file within */ - new_file->filename=HDstrdup(filename); /* make a copy of the filename */ - new_file->acc_perm=H5ACC_WRITE; /* all new files we create have write permission */ - new_file->file_handle=f_handle; /* keep the file handle we just opened */ - new_file->ref_count=1; /* only 1 fid handed out so far */ - new_file->consist_flags=0x03; /* Set file-consistency flags: write-access and "file is consistent" */ - new_file->smallobj_off=0; /* Set the offset of the small-object heap */ - new_file->freespace_off=0; /* Set the offset of the free-space info */ - /* Get the file-creation template & record it */ - if(create_temp==0) - create_temp=H5C_get_default_atom(H5_TEMPLATE); - if((f_create_parms=H5Aatom_object(create_temp))==NULL) - HGOTO_ERROR(H5E_ATOM, H5E_BADATOM, FAIL); /*can't atomize template*/ - HDmemcpy(&new_file->file_create_parms,f_create_parms,sizeof(file_create_temp_t)); + /* Check/fix arguments */ + if (!filename || !*filename) + HGOTO_ERROR (H5E_ARGS, H5E_BADVALUE, FAIL); /*invalid file name*/ + if (flags & ~H5ACC_OVERWRITE) + HGOTO_ERROR (H5E_ARGS, H5E_BADVALUE, FAIL); /*invalid flags*/ + flags = (H5F_ACC_WRITE | H5F_ACC_CREAT) | + (H5ACC_OVERWRITE==flags ? H5F_ACC_TRUNC : H5F_ACC_EXCL); + if (0==create_temp) + create_temp = H5C_get_default_atom (H5_TEMPLATE); + if (NULL==(create_parms=H5Aatom_object(create_temp))) + HGOTO_ERROR(H5E_ATOM, H5E_BADATOM, FAIL); /*can't unatomize template*/ #ifdef LATER - /* Get the file-access template & record it */ - if(access_temp==0) - access_temp=H5CPget_default_atom(H5_TEMPLATE); - if((f_access_parms=H5Aatom_object(access_temp))==NULL) + if (0==access_temp) + access_temp = H5CPget_default_atom(H5_TEMPLATE); + if (NULL==(access_parms=H5Aatom_object(access_temp))) HGOTO_ERROR(H5E_ATOM, H5E_BADATOM, FAIL); /*can't unatomize template*/ - HDmemcpy(&new_file->file_access_parms,f_access_parms,sizeof(file_access_temp_t)); -#endif /* LATER */ - - /* Flush the file signature and boot block */ - if (H5F_flush (new_file, FALSE)<0) { - HGOTO_ERROR (H5E_IO, H5E_CANTINIT, FAIL); /*can't write file boot block*/ +#endif + + /* + * Create a new file or truncate an existing file. + */ + if (NULL==(new_file = H5F_open (filename, flags, create_parms))) { + HGOTO_ERROR (H5E_FILE, H5E_CANTOPENFILE, FAIL); /*can't create file */ } /* Get an atom for the file */ - if((ret_value=H5Aregister_atom(H5_FILE, new_file))==FAIL) + if ((ret_value=H5Aregister_atom (H5_FILE, new_file))<0) HGOTO_ERROR(H5E_ATOM, H5E_CANTREGISTER, FAIL); /*can't atomize file*/ -done: - if(ret_value == FAIL) - { /* Error condition cleanup */ - - /* Check if we left a dangling file handle */ - if(f_handle!=H5F_INVALID_FILE) - H5F_CLOSE(f_handle); /* close the file we opened */ - - /* Check if we left a dangling file struct */ - if (new_file) - H5F_dest (new_file); + done: + if (ret_value<0 && new_file) { + /* Error condition cleanup */ + H5F_close (new_file); } /* Normal function cleanup */ FUNC_LEAVE(ret_value); -} /* end H5Fcreate() */ +} /*-------------------------------------------------------------------------- @@ -614,29 +948,18 @@ done: ERRORS ARGS BADRANGE Invalid file name. - ATOM BADATOM Can't atomize template. ATOM BADATOM Can't unatomize template. ATOM CANTREGISTER Can't atomize file. - ATOM CANTREGISTER Can't register new_file atom. - FILE CANTOPEN File doesn't exist. - FILE NOTHDF5 Not an HDF5 file. - FILE NOTHDF5 The file exists but doesn't appear to be an - HDF5 file. - IO READERROR Can't decode root symbol table entry. - IO READERROR Read boot block failed. - IO READERROR Read boot block signature failed. - IO READERROR Seek to boot block failed. - IO SEEKERROR Seek failed. - RESOURCE NOSPACE H5F_new() failed. + FILE CANTOPENFILE Cant open file. RETURNS Returns file ID on success, FAIL on failure DESCRIPTION This is the primary function for accessing existing HDF5 files. The - flags parameter determines whether writing to an existing file will be allowed - or not. All flags may be combined with the "||" (logical OR operator) to - change the behavior of the file open call. + flags parameter determines whether writing to an existing file will be + allowed or not. All flags may be combined with the "||" (logical OR + operator) to change the behavior of the file open call. The flags currently defined: H5ACC_WRITE - Allow writing to the file. The more complex behaviors of a file's access are controlled through @@ -646,168 +969,147 @@ done: Robb Matzke, 18 Jul 1997 File struct creation and destruction is through H5F_new() H5F_dest(). Reading the root symbol table entry is done with H5G_decode(). + + Robb Matzke, 23 Sep 1997 + Most of the work is now done by H5F_open() since H5Fcreate() and H5Fopen() + originally contained almost identical code. --------------------------------------------------------------------------*/ hid_t H5Fopen(const char *filename, uintn flags, hid_t access_temp) { - hdf5_file_t *new_file=NULL; /* file struct for new file */ - hdf_file_t f_handle=H5F_INVALID_FILE; /* file handle */ - hid_t create_temp; /* file-creation template ID */ - const file_create_temp_t *f_create_parms; /* pointer to the parameters to use when creating the file */ - uint8 temp_buf[2048], *p; /* temporary buffer for encoding header */ - haddr_t curr_off=0; /* The current offset to check in the file */ - size_t file_len=0; /* The length of the file we are checking */ - hid_t ret_value = FAIL; - size_t variable_size; /*size of the variable part of the bb */ + H5F_t *new_file=NULL; /* file struct for new file */ + hid_t create_temp; /* file-creation template ID */ + const file_create_temp_t *f_create_parms; /* pointer to the parameters + * to use when creating the + * file + */ + hid_t ret_value = FAIL; FUNC_ENTER(H5Fopen, H5F_init_interface, FAIL); - - /* Clear errors and check args and all the boring stuff. */ H5ECLEAR; - if(filename==NULL) - HGOTO_ERROR(H5E_ARGS, H5E_BADRANGE, FAIL);/*invalid file name*/ - - /* See if this file is already open */ - new_file=H5Asearch_atom(H5_FILE,H5F_compare_filename,(const VOIDP)filename); - /* If the file is already open, check the access permissions and go ahead with it */ - if(new_file!=NULL && new_file->acc_perm==flags) - { - /* Get an atom for the file */ - new_file->ref_count++; /* increment the reference count for the file */ - if((ret_value=H5Aregister_atom(H5_FILE, new_file))==FAIL) { - /* Can't register new_file atom */ - HGOTO_ERROR(H5E_ATOM, H5E_CANTREGISTER, FAIL); - } - HGOTO_DONE(ret_value); - } /* end if */ - - /* - * If the file exists but has different permissions or if it's a new file, - * start a new file handle for it, etc. - */ - if(H5Fis_hdf5(filename)==BFALSE) { - /* The file exists but doesn't appear to be an HDF5 file */ - HGOTO_ERROR(H5E_FILE, H5E_NOTHDF5, FAIL); - } + /* Check/fix arguments. */ + if (!filename || !*filename) + HGOTO_ERROR (H5E_ARGS, H5E_BADRANGE, FAIL);/*invalid file name*/ + flags = flags & H5ACC_WRITE ? H5F_ACC_WRITE : 0; - /* Check if the file already exists */ - f_handle=H5F_OPEN(filename,flags); - if(H5F_OPENERR(f_handle)) - HGOTO_ERROR(H5E_FILE, H5E_CANTOPENFILE, FAIL);/*file doesn't exist*/ - - /* Create the file node */ - if (NULL==(new_file=H5F_new())) - HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, FAIL);/*H5F_new() failed*/ - - /* Set the non-zero elements of the file structure */ - new_file->dir=HDgetcwd(NULL,0); /* get the directory we just created the file within */ - new_file->filename=HDstrdup(filename); /* make a copy of the filename */ - new_file->acc_perm=flags; /* set the access permissions */ - new_file->file_handle=f_handle; /* keep the file handle we just opened */ - new_file->ref_count=1; /* only 1 fid handed out so far */ - create_temp=H5C_get_default_atom(H5_TEMPLATE); - if((f_create_parms=H5Aatom_object(create_temp))==NULL) - HGOTO_ERROR(H5E_ATOM, H5E_BADATOM, FAIL);/*can't unatomize template*/ - HDmemcpy(&new_file->file_create_parms,f_create_parms,sizeof(file_create_temp_t)); + create_temp = H5C_get_default_atom (H5_TEMPLATE); + if (NULL==(f_create_parms=H5Aatom_object(create_temp))) + HGOTO_ERROR (H5E_ATOM, H5E_BADATOM, FAIL);/*can't unatomize template*/ #ifdef LATER - if(access_temp<=0) - access_temp=H5CPget_default_atom(H5_TEMPLATE); - if((f_access_parms=H5Aatom_object(access_temp))==NULL) - HGOTO_ERROR(H5E_ATOM, H5E_BADATOM, FAIL);/*can't atomize template*/ - HDmemcpy(&new_file->file_access_parms,f_access_parms,sizeof(file_access_temp_t)); -#endif /* LATER */ - - /* Read the basic skeleton of the file */ - - /* Seek to the correct offset to read in the file signature & boot-block */ - /* Get the length of the file */ - if(H5F_SEEKEND(new_file->file_handle)==FAIL) - HGOTO_ERROR(H5E_IO, H5E_SEEKERROR, BFAIL);/*seek failed*/ - file_len=H5F_TELL(new_file->file_handle); + if (access_temp<=0) + access_temp = H5CPget_default_atom (H5_TEMPLATE); + if (NULL==(f_access_parms=H5Aatom_object (access_temp))) + HGOTO_ERROR (H5E_ATOM, H5E_BADATOM, FAIL);/*can't unatomize template*/ +#endif - /* Check the offsets where the file signature is possible */ - while(curr_offfile_handle,curr_off)==FAIL) { - /*seek to boot block failed*/ - HGOTO_ERROR(H5E_IO, H5E_READERROR, BFAIL); - } - if(H5F_READ(new_file->file_handle,temp_buf, H5F_SIGNATURE_LEN)==FAIL) { - /*read boot block signature failed*/ - HGOTO_ERROR(H5E_IO, H5E_READERROR, BFAIL); - } - if(HDmemcmp(temp_buf,H5F_SIGNATURE,H5F_SIGNATURE_LEN)==0) - { - new_file->file_create_parms.userblock_size=curr_off; - break; - } /* end if */ - if(curr_off==0) - curr_off=512; - else - curr_off*=2; - } /* end while */ - if(curr_off>file_len) /* Why didn't H5Fis_hdf5 catch this? */ - HGOTO_ERROR(H5E_FILE, H5E_NOTHDF5, FAIL); /*not an HDF5 file*/ - - /* Read in the fixed-size part of the boot-block */ - if(H5F_READ(new_file->file_handle,temp_buf,16)==FAIL) - HGOTO_ERROR(H5E_IO, H5E_READERROR, FAIL); /*read boot block failed*/ - - /* Decode fixed-size part of the boot block */ - p=temp_buf; - new_file->file_create_parms.bootblock_ver=*p++; /* Decode Boot-block version # */ - new_file->file_create_parms.smallobject_ver=*p++; /* Decode Small-Object Heap version # */ - new_file->file_create_parms.freespace_ver=*p++; /* Decode Free-Space Info version # */ - new_file->file_create_parms.objectdir_ver=*p++; /* Decode Object Directory Format version # */ - new_file->file_create_parms.sharedheader_ver=*p++; /* Decode Shared-Header Info version # */ - new_file->file_create_parms.offset_size=*p++; /* Decode the number of bytes for the offset */ - new_file->file_create_parms.length_size=*p++; /* Decode the number of bytes for the length */ - p++; /* Decode the reserved byte :-) */ - UINT16DECODE (p, new_file->file_create_parms.sym_leaf_k); /*stab leaf 1/2 rank*/ - UINT16DECODE (p, new_file->file_create_parms.btree_k[H5B_SNODE_ID]); /*stab internal 1/2 rank*/ - UINT32DECODE(p,new_file->consist_flags); /* Decode File-Consistancy flags */ - - /* Read the variable-size part of the boot-block */ - variable_size = H5F_SIZEOF_OFFSET(new_file) + /*offset of global small-object heap*/ - H5F_SIZEOF_OFFSET(new_file) + /*offset of global free list*/ - H5F_SIZEOF_SIZE(new_file) + /*logical size of HDF5 file*/ - H5G_SIZEOF_ENTRY(new_file); /*root symbol table entry*/ - if (H5F_READ(new_file->file_handle, temp_buf, variable_size)<0) - HGOTO_ERROR (H5E_IO, H5E_READERROR, FAIL); /*read boot block failed*/ - - /* Decode the variable-size part of the boot block */ - p = temp_buf; - H5F_decode_offset(new_file,p,new_file->smallobj_off); /* Decode offset of global small-object heap */ - H5F_decode_offset(new_file,p,new_file->freespace_off); /* Decode offset of global free-space heap */ - H5F_decode_length(new_file,p,new_file->logical_len); /* Decode logical length of file */ - - /* Decode the root symbol table entry */ - if (H5G_ent_decode (new_file, &p, new_file->root_sym)<0) { - /*can't decode root symbol table entry */ - HGOTO_ERROR (H5E_IO, H5E_READERROR, FAIL); + /* Open the file */ + if (NULL==(new_file=H5F_open (filename, flags, f_create_parms))) { + HGOTO_ERROR (H5E_FILE, H5E_CANTOPENFILE, FAIL); /*cant open file*/ } /* Get an atom for the file */ - if((ret_value=H5Aregister_atom(H5_FILE, new_file))==FAIL) + if ((ret_value = H5Aregister_atom (H5_FILE, new_file))<0) HGOTO_ERROR(H5E_ATOM, H5E_CANTREGISTER, FAIL);/*can't atomize file*/ -done: - if(ret_value == FAIL) - { /* Error condition cleanup */ - - /* Check if we left a dangling file handle */ - if(f_handle!=H5F_INVALID_FILE) - H5F_CLOSE(f_handle); /* close the file we opened */ - - /* Check if we left a dangling file struct */ - if(new_file) HDfree(new_file); + done: + if (ret_value<0 && new_file) { + H5F_close (new_file); } /* Normal function cleanup */ FUNC_LEAVE(ret_value); -} /* end H5Fopen() */ +} + + +/*------------------------------------------------------------------------- + * Function: H5F_flush + * + * Purpose: Flushes (and optionally invalidates) cached data plus the + * file boot block. If the logical file size field is zero + * then it is updated to be the length of the boot block. + * + * Errors: + * CACHE CANTFLUSH Can't flush cache. + * IO WRITEERROR Can't write header. + * + * Return: Success: SUCCEED + * + * Failure: FAIL + * -2 if the there are open objects and + * INVALIDATE was non-zero. + * + * Programmer: Robb Matzke + * robb@maya.nuance.com + * Aug 29 1997 + * + * Modifications: + * + *------------------------------------------------------------------------- + */ +static herr_t +H5F_flush (H5F_t *f, hbool_t invalidate) +{ + uint8 buf[2048], *p=buf; + herr_t shadow_flush; + + FUNC_ENTER (H5F_flush, H5F_init_interface, FAIL); + + /* + * Nothing to do if the file is read only. This determination is made at + * the shared open(2) flags level, implying that opening a file twice, + * once for read-only and once for read-write, and then calling + * H5F_flush() with the read-only handle, still causes data to be flushed. + */ + if (0==(H5F_ACC_WRITE & f->shared->flags)) HRETURN (SUCCEED); + + /* + * Flush all open object info. If this fails just remember it and return + * failure at the end. At least that way we get a consistent file. + */ + shadow_flush = H5G_shadow_flush (f, invalidate); + + /* flush (and invalidate) the entire cache */ + if (H5AC_flush (f, NULL, 0, invalidate)<0) { + HRETURN_ERROR (H5E_CACHE, H5E_CANTFLUSH, FAIL); /*can't flush cache*/ + } + + /* encode the file boot block */ + HDmemcpy (p, H5F_SIGNATURE, H5F_SIGNATURE_LEN); + p += H5F_SIGNATURE_LEN; + + *p++ = f->shared->file_create_parms.bootblock_ver; + *p++ = f->shared->file_create_parms.smallobject_ver; + *p++ = f->shared->file_create_parms.freespace_ver; + *p++ = f->shared->file_create_parms.objectdir_ver; + *p++ = f->shared->file_create_parms.sharedheader_ver; + *p++ = H5F_SIZEOF_OFFSET (f); + *p++ = H5F_SIZEOF_SIZE (f); + *p++ = 0; /*reserved*/ + UINT16ENCODE (p, f->shared->file_create_parms.sym_leaf_k); + UINT16ENCODE (p, f->shared->file_create_parms.btree_k[H5B_SNODE_ID]); + UINT32ENCODE (p, f->shared->consist_flags); + H5F_encode_offset (f, p, f->shared->smallobj_off); + H5F_encode_offset (f, p, f->shared->freespace_off); + H5F_encode_length (f, p, f->shared->logical_len); + H5G_ent_encode (f, &p, f->shared->root_sym); + + /* write the boot block to disk */ + if (H5F_block_write (f, 0, p-buf, buf)<0) { + HRETURN_ERROR (H5E_IO, H5E_WRITEERROR, FAIL); /*can't write header*/ + } + + /* update file length if necessary */ + if (f->shared->logical_len<=0) f->shared->logical_len = p-buf; + + /* Did shadow flush fail above? */ + if (shadow_flush<0) { + HRETURN_ERROR (H5E_CACHE, H5E_CANTFLUSH, -2);/*object are still open*/ + } + + FUNC_LEAVE (SUCCEED); +} /*-------------------------------------------------------------------------- NAME @@ -840,7 +1142,7 @@ done: herr_t H5Fflush (hid_t fid, hbool_t invalidate) { - hdf5_file_t *file = NULL; + H5F_t *file = NULL; FUNC_ENTER (H5Fflush, H5F_init_interface, FAIL); H5ECLEAR; @@ -863,86 +1165,44 @@ H5Fflush (hid_t fid, hbool_t invalidate) /*------------------------------------------------------------------------- - * Function: H5F_flush - * - * Purpose: Flushes (and optionally invalidates) cached data plus the - * file boot block. If the logical file size field is zero - * then it is updated to be the length of the boot block. + * Function: H5F_close * - * Errors: - * CACHE CANTFLUSH Can't flush cache. - * IO WRITEERROR Can't write header. + * Purpose: Closes an open HDF5 file. * * Return: Success: SUCCEED * - * Failure: FAIL - * -2 if the there are open objects and - * INVALIDATE was non-zero. + * Failure: FAIL, or -2 if the failure is due to objects + * still being open. * * Programmer: Robb Matzke - * robb@maya.nuance.com - * Aug 29 1997 + * Tuesday, September 23, 1997 * * Modifications: * *------------------------------------------------------------------------- */ static herr_t -H5F_flush (hdf5_file_t *f, hbool_t invalidate) +H5F_close (H5F_t *f) { - uint8 buf[2048], *p=buf; - herr_t shadow_flush; - - FUNC_ENTER (H5F_flush, H5F_init_interface, FAIL); - - /* nothing to do if the file is read only */ - if (0==(H5ACC_WRITE & f->acc_perm)) HRETURN (SUCCEED); - - /* - * Flush all open object info. If this fails just remember it and return - * failure at the end. At least that way we get a consistent file. - */ - shadow_flush = H5G_shadow_flush (f, invalidate); - - /* flush (and invalidate) the entire cache */ - if (H5AC_flush (f, NULL, 0, invalidate)<0) { - HRETURN_ERROR (H5E_CACHE, H5E_CANTFLUSH, FAIL); /*can't flush cache*/ - } + herr_t ret_value = FAIL; - /* encode the file boot block */ - HDmemcpy (p, H5F_SIGNATURE, H5F_SIGNATURE_LEN); - p += H5F_SIGNATURE_LEN; + FUNC_ENTER (H5F_close, H5F_init_interface, FAIL); - *p++ = f->file_create_parms.bootblock_ver; - *p++ = f->file_create_parms.smallobject_ver; - *p++ = f->file_create_parms.freespace_ver; - *p++ = f->file_create_parms.objectdir_ver; - *p++ = f->file_create_parms.sharedheader_ver; - *p++ = H5F_SIZEOF_OFFSET (f); - *p++ = H5F_SIZEOF_SIZE (f); - *p++ = 0; /*reserved*/ - UINT16ENCODE (p, f->file_create_parms.sym_leaf_k); - UINT16ENCODE (p, f->file_create_parms.btree_k[H5B_SNODE_ID]); - UINT32ENCODE (p, f->consist_flags); - H5F_encode_offset (f, p, f->smallobj_off); - H5F_encode_offset (f, p, f->freespace_off); - H5F_encode_length (f, p, f->logical_len); - H5G_ent_encode (f, &p, f->root_sym); - - /* write the boot block to disk */ - if (H5F_block_write (f, 0, p-buf, buf)<0) { - HRETURN_ERROR (H5E_IO, H5E_WRITEERROR, FAIL); /*can't write header*/ + if (-2==(ret_value=H5F_flush (f, TRUE))) { + /*objects are still open, but don't fail yet*/ + } else if (ret_value<0) { + /*can't flush cache*/ + HRETURN_ERROR (H5E_CACHE, H5E_CANTFLUSH, FAIL); } + H5F_CLOSE(f->shared->file_handle); + H5F_dest (f); - /* update file length if necessary */ - if (f->logical_len<=0) f->logical_len = p-buf; - - /* Did shadow flush fail above? */ - if (shadow_flush<0) { - HRETURN_ERROR (H5E_CACHE, H5E_CANTFLUSH, -2);/*object are still open*/ + /* Did the H5F_flush() fail because of open objects? */ + if (ret_value<0) { + HRETURN_ERROR (H5E_SYM, H5E_CANTFLUSH, ret_value); } - - FUNC_LEAVE (SUCCEED); + + FUNC_LEAVE (ret_value); } /*-------------------------------------------------------------------------- @@ -980,52 +1240,29 @@ H5F_flush (hdf5_file_t *f, hbool_t invalidate) --------------------------------------------------------------------------*/ herr_t H5Fclose(hid_t fid) { - hdf5_file_t *file=NULL; /* file struct for file to close */ - herr_t ret_value = SUCCEED; + H5F_t *file=NULL; /* file struct for file to close */ + herr_t ret_value = SUCCEED; FUNC_ENTER(H5Fclose, H5F_init_interface, FAIL); - - /* Clear errors and check args and all the boring stuff. */ H5ECLEAR; - if(H5Aatom_group(fid)!=H5_FILE) - HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL);/*not a file atom*/ - /* Get the file handle to close */ - if((file=H5Aatom_object(fid))==NULL) - HGOTO_ERROR(H5E_ATOM, H5E_BADATOM, FAIL);/*can't unatomize file*/ + /* Check/fix arguments. */ + if (H5_FILE!=H5Aatom_group (fid)) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL);/*not a file atom*/ + if (NULL==(file=H5Aatom_object (fid))) + HGOTO_ERROR(H5E_ATOM, H5E_BADATOM, FAIL);/*can't unatomize file*/ - /* Decrement the ref. count and recycle the file structure */ - if((--file->ref_count)==0) - { - if(file->file_handle!=H5F_INVALID_FILE) { - if (-2==(ret_value=H5F_flush (file, TRUE))) { - /*objects are still open*/ - } else if (ret_value<0) { - /*can't flush cache*/ - HGOTO_ERROR (H5E_CACHE, H5E_CANTFLUSH, FAIL); - } - H5F_CLOSE(file->file_handle); - } - H5F_dest (file); - if(H5Aremove_atom(fid)==NULL) { - HGOTO_ERROR(H5E_ATOM, H5E_BADATOM, FAIL);/*can't remove atom*/ - } - } /* end if */ + /* Close the file */ + ret_value = H5F_close (file); + + /* Remove the file atom */ + if (NULL==H5Aremove_atom(fid)) { + HGOTO_ERROR(H5E_ATOM, H5E_BADATOM, FAIL);/*can't remove atom*/ + } - /* Did the H5F_flush() fail because of open objects? */ - if (ret_value<0) { - HGOTO_ERROR (H5E_SYM, H5E_CANTFLUSH, FAIL); - } - done: - if(ret_value == FAIL) - { /* Error condition cleanup */ - - } /* end if */ - - /* Normal function cleanup */ - FUNC_LEAVE(ret_value); -} /* end H5Fclose() */ + FUNC_LEAVE (ret_value<0?FAIL:SUCCEED); +} /*------------------------------------------------------------------------- @@ -1051,18 +1288,18 @@ done: *------------------------------------------------------------------------- */ herr_t -H5F_block_read (hdf5_file_t *f, haddr_t addr, size_t size, void *buf) +H5F_block_read (H5F_t *f, haddr_t addr, size_t size, void *buf) { FUNC_ENTER (H5F_block_read, H5F_init_interface, FAIL); if (0==size) return 0; - addr += f->file_create_parms.userblock_size; + addr += f->shared->file_create_parms.userblock_size; - if (H5F_SEEK (f->file_handle, addr)<0) { + if (H5F_SEEK (f->shared->file_handle, addr)<0) { /* low-level seek failure */ HRETURN_ERROR (H5E_IO, H5E_SEEKERROR, FAIL); } - if (H5F_READ (f->file_handle, buf, size)<0) { + if (H5F_READ (f->shared->file_handle, buf, size)<0) { /* low-level read failure */ HRETURN_ERROR (H5E_IO, H5E_READERROR, FAIL); } @@ -1080,6 +1317,7 @@ H5F_block_read (hdf5_file_t *f, haddr_t addr, size_t size, void *buf) * Errors: * IO SEEKERROR Low-level seek failure. * IO WRITEERROR Low-level write failure. + * IO WRITEERROR No write intent. * * Return: Success: SUCCEED * @@ -1094,18 +1332,22 @@ H5F_block_read (hdf5_file_t *f, haddr_t addr, size_t size, void *buf) *------------------------------------------------------------------------- */ herr_t -H5F_block_write (hdf5_file_t *f, haddr_t addr, size_t size, void *buf) +H5F_block_write (H5F_t *f, haddr_t addr, size_t size, void *buf) { FUNC_ENTER (H5F_block_write, H5F_init_interface, FAIL); if (0==size) return 0; - addr += f->file_create_parms.userblock_size; + addr += f->shared->file_create_parms.userblock_size; - if (H5F_SEEK (f->file_handle, addr)<0) { + if (0==(f->intent & H5F_ACC_WRITE)) { + /* no write intent */ + HRETURN_ERROR (H5E_IO, H5E_WRITEERROR, FAIL); + } + if (H5F_SEEK (f->shared->file_handle, addr)<0) { /* low-level seek failure */ HRETURN_ERROR (H5E_IO, H5E_SEEKERROR, FAIL); } - if (H5F_WRITE (f->file_handle, buf, size)<0) { + if (H5F_WRITE (f->shared->file_handle, buf, size)<0) { /* low-level write failure */ HRETURN_ERROR (H5E_IO, H5E_WRITEERROR, FAIL); } @@ -1136,8 +1378,7 @@ H5F_block_write (hdf5_file_t *f, haddr_t addr, size_t size, void *buf) *------------------------------------------------------------------------- */ herr_t -H5F_debug (hdf5_file_t *f, haddr_t addr, FILE *stream, intn indent, - intn fwidth) +H5F_debug (H5F_t *f, haddr_t addr, FILE *stream, intn indent, intn fwidth) { FUNC_ENTER (H5F_debug, H5F_init_interface, FAIL); @@ -1152,62 +1393,59 @@ H5F_debug (hdf5_file_t *f, haddr_t addr, FILE *stream, intn indent, fprintf (stream, "%*sFile Boot Block...\n", indent, ""); fprintf (stream, "%*s%-*s %s\n", indent, "", fwidth, - "Directory:", - f->dir); - fprintf (stream, "%*s%-*s %s\n", indent, "", fwidth, "File name:", - f->filename); + f->name); fprintf (stream, "%*s%-*s 0x%08x\n", indent, "", fwidth, - "Permissions", - (unsigned)(f->acc_perm)); + "Flags", + (unsigned)(f->shared->flags)); fprintf (stream, "%*s%-*s %u\n", indent, "", fwidth, "Reference count:", - (unsigned)(f->ref_count)); + (unsigned)(f->shared->nrefs)); fprintf (stream, "%*s%-*s 0x%08lx\n", indent, "", fwidth, "Consistency flags:", - (unsigned long)(f->consist_flags)); + (unsigned long)(f->shared->consist_flags)); fprintf (stream, "%*s%-*s %ld\n", indent, "", fwidth, "Small object heap address:", - (long)(f->smallobj_off)); + (long)(f->shared->smallobj_off)); fprintf (stream, "%*s%-*s %ld\n", indent, "", fwidth, "Free list address:", - (long)(f->freespace_off)); + (long)(f->shared->freespace_off)); fprintf (stream, "%*s%-*s %lu\n", indent, "", fwidth, "Logical file length:", - (unsigned long)(f->logical_len)); + (unsigned long)(f->shared->logical_len)); fprintf (stream, "%*s%-*s %lu\n", indent, "", fwidth, "Size of user block:", - (unsigned long)(f->file_create_parms.userblock_size)); + (unsigned long)(f->shared->file_create_parms.userblock_size)); fprintf (stream, "%*s%-*s %u\n", indent, "", fwidth, "Size of file size_t type:", - (unsigned)(f->file_create_parms.offset_size)); + (unsigned)(f->shared->file_create_parms.offset_size)); fprintf (stream, "%*s%-*s %u\n", indent, "", fwidth, "Size of file off_t type:", - (unsigned)(f->file_create_parms.length_size)); + (unsigned)(f->shared->file_create_parms.length_size)); fprintf (stream, "%*s%-*s %u\n", indent, "", fwidth, "Symbol table leaf node 1/2 rank:", - (unsigned)(f->file_create_parms.sym_leaf_k)); + (unsigned)(f->shared->file_create_parms.sym_leaf_k)); fprintf (stream, "%*s%-*s %u\n", indent, "", fwidth, "Symbol table internal node 1/2 rank:", - (unsigned)(f->file_create_parms.btree_k[H5B_SNODE_ID])); + (unsigned)(f->shared->file_create_parms.btree_k[H5B_SNODE_ID])); fprintf (stream, "%*s%-*s %u\n", indent, "", fwidth, "Boot block version number:", - (unsigned)(f->file_create_parms.bootblock_ver)); + (unsigned)(f->shared->file_create_parms.bootblock_ver)); fprintf (stream, "%*s%-*s %u\n", indent, "", fwidth, "Small object heap version number:", - (unsigned)(f->file_create_parms.smallobject_ver)); + (unsigned)(f->shared->file_create_parms.smallobject_ver)); fprintf (stream, "%*s%-*s %u\n", indent, "", fwidth, "Free list version number:", - (unsigned)(f->file_create_parms.freespace_ver)); + (unsigned)(f->shared->file_create_parms.freespace_ver)); fprintf (stream, "%*s%-*s %u\n", indent, "", fwidth, "Object directory version number:", - (unsigned)(f->file_create_parms.objectdir_ver)); + (unsigned)(f->shared->file_create_parms.objectdir_ver)); fprintf (stream, "%*s%-*s %u\n", indent, "", fwidth, "Shared header version number:", - (unsigned)(f->file_create_parms.sharedheader_ver)); + (unsigned)(f->shared->file_create_parms.sharedheader_ver)); fprintf (stream, "%*sRoot symbol table entry:\n", indent, ""); - H5G_ent_debug (f, f->root_sym, stream, indent+3, MAX(0, fwidth-3)); + H5G_ent_debug (f, f->shared->root_sym, stream, indent+3, MAX(0, fwidth-3)); FUNC_LEAVE (SUCCEED); } diff --git a/src/H5Fprivate.h b/src/H5Fprivate.h index 08cfd8f..4165b1e 100644 --- a/src/H5Fprivate.h +++ b/src/H5Fprivate.h @@ -31,8 +31,16 @@ #define H5F_SIGNATURE_LEN 8 /* size of size_t and off_t as they exist on disk */ -#define H5F_SIZEOF_OFFSET(F) ((F)->file_create_parms.offset_size) -#define H5F_SIZEOF_SIZE(F) ((F)->file_create_parms.length_size) +#define H5F_SIZEOF_OFFSET(F) ((F)->shared->file_create_parms.offset_size) +#define H5F_SIZEOF_SIZE(F) ((F)->shared->file_create_parms.length_size) + +/* + * File open flags. + */ +#define H5F_ACC_WRITE 0x0001 /* Open file for read/write access */ +#define H5F_ACC_CREAT 0x0002 /* Create non-existing files */ +#define H5F_ACC_EXCL 0x0004 /* Fail if file exists */ +#define H5F_ACC_TRUNC 0x0008 /* Truncate existing file */ /* * Define the low-level file interface. @@ -335,26 +343,49 @@ typedef struct { uint8 sharedheader_ver; /* Version # of the shared header format */ } file_create_temp_t; -/* Define the structure to store the file information for HDF5 files */ -typedef struct { - char *dir; /* Directory the file is located within */ - char *filename; /* Filename of file */ - uintn acc_perm; /* Access Permissions for file */ - hdf_file_t file_handle; /* File handle for actual I/O */ - uintn ref_count; /* Ref count for times file is opened */ - uint32 consist_flags; /* File Consistency Flags */ - haddr_t smallobj_off; /* Offset of small-obj heap within the file */ - haddr_t freespace_off; /* Offset of free-space info within the file */ - size_t logical_len; /* Logical length of file */ - struct H5AC_t *cache; /* The object cache */ - file_create_temp_t file_create_parms; /* File-creation template */ +/* + * These things make a file unique. + */ +typedef struct H5F_search_t { + dev_t dev; /* Device number containing file */ + ino_t ino; /* Unique file number on device */ +} H5F_search_t; + +/* + * Define the structure to store the file information for HDF5 files. One of + * these structures is allocated per file, not per H5Fopen(). + */ +typedef struct H5F_file_t { + H5F_search_t key; /* The key for looking up files */ + uintn flags; /* Access Permissions for file */ + hdf_file_t file_handle; /* File handle for actual I/O */ + uintn nrefs; /* Ref count for times file is opened */ + uint32 consist_flags; /* File Consistency Flags */ + haddr_t smallobj_off; /* Offset of small-obj heap within the file */ + haddr_t freespace_off; /* Offset of free-space info within the file */ + size_t logical_len; /* Logical length of file */ + struct H5AC_t *cache; /* The object cache */ + file_create_temp_t file_create_parms; /* File-creation template */ #ifdef LATER - file_access_temp_t file_access_parms; /* File-access template */ + file_access_temp_t file_access_parms; /* File-access template */ #endif - struct H5G_entry_t *root_sym; /* Root symbol table entry */ - uintn nshadows; /* Size of shadow hash table */ - struct H5G_hash_t **shadow; /* The shadow hash table */ - } hdf5_file_t; + struct H5G_entry_t *root_sym; /* Root symbol table entry */ + uintn nshadows; /* Size of shadow hash table */ + struct H5G_hash_t **shadow; /* The shadow hash table */ +} H5F_file_t; + +/* + * This is the top-level file descriptor. One of these structures is + * allocated every time H5Fopen() is called although they may contain + * pointers to shared H5F_file_t structs. + */ +typedef struct H5F_t { + uintn intent; /* The flags passed to H5F_open() */ + char *name; /* Name used to open file */ + H5F_file_t *shared; /* The shared file info */ +} H5F_t; + + #ifdef NOT_YET @@ -403,12 +434,11 @@ typedef struct { /* Private functions, not part of the publicly documented API */ -void H5F_encode_length_unusual(const hdf5_file_t *f, uint8 **p, uint8 *l); -void H5F_encode_offset_unusual(const hdf5_file_t *f, uint8 **p, uint8 *o); -intn H5F_compare_filename(const VOIDP obj, const VOIDP key); -herr_t H5F_block_read (hdf5_file_t *f, haddr_t addr, size_t size, void *buf); -herr_t H5F_block_write (hdf5_file_t *f, haddr_t addr, size_t size, void *buf); -herr_t H5F_debug (hdf5_file_t *f, haddr_t addr, FILE *stream, intn indent, +void H5F_encode_length_unusual(const H5F_t *f, uint8 **p, uint8 *l); +void H5F_encode_offset_unusual(const H5F_t *f, uint8 **p, uint8 *o); +herr_t H5F_block_read (H5F_t *f, haddr_t addr, size_t size, void *buf); +herr_t H5F_block_write (H5F_t *f, haddr_t addr, size_t size, void *buf); +herr_t H5F_debug (H5F_t *f, haddr_t addr, FILE *stream, intn indent, intn fwidth); #endif diff --git a/src/H5G.c b/src/H5G.c index 0c38a00..efb7389 100644 --- a/src/H5G.c +++ b/src/H5G.c @@ -197,7 +197,7 @@ H5G_basename (const char *name, size_t *size_p) *------------------------------------------------------------------------- */ static H5G_entry_t * -H5G_namei (hdf5_file_t *f, H5G_entry_t *cwd, const char *name, +H5G_namei (H5F_t *f, H5G_entry_t *cwd, const char *name, const char **rest, H5G_entry_t *dir_ent) { H5G_entry_t dir; /*entry for current directory */ @@ -214,17 +214,17 @@ H5G_namei (hdf5_file_t *f, H5G_entry_t *cwd, const char *name, /* check args */ assert (f); - assert (f->root_sym); + assert (f->shared->root_sym); assert (name && *name); assert (cwd || '/'==*name); /* starting point */ if ('/'==*name) { - if (f->root_sym->header<=0) { + if (f->shared->root_sym->header<=0) { HRETURN_ERROR (H5E_DIRECTORY, H5E_NOTFOUND, NULL); } - ret_value = f->root_sym; - dir = *(f->root_sym); + ret_value = f->shared->root_sym; + dir = *(f->shared->root_sym); } else { ret_value = cwd; dir = *cwd; @@ -266,11 +266,11 @@ H5G_namei (hdf5_file_t *f, H5G_entry_t *cwd, const char *name, * the name `foo'. */ H5O_name_t mesg={0}; - if (!aside && dir.header==f->root_sym->header && + if (!aside && dir.header==f->shared->root_sym->header && H5O_read (f, dir.header, &dir, H5O_NAME, 0, &mesg) && !HDstrcmp (mesg.s, comp)) { H5O_reset (H5O_NAME, &mesg); - ret_value = f->root_sym; + ret_value = f->shared->root_sym; aside = TRUE; } else { /* component not found */ @@ -287,7 +287,7 @@ H5G_namei (hdf5_file_t *f, H5G_entry_t *cwd, const char *name, /* output parameters */ if (rest) *rest = name; /*final null*/ if (dir_ent) { - if (ret_value->header == f->root_sym->header) { + if (ret_value->header == f->shared->root_sym->header) { HDmemset (dir_ent, 0, sizeof(H5G_entry_t)); /*root has no parent*/ } else { *dir_ent = dir; @@ -337,7 +337,7 @@ H5G_namei (hdf5_file_t *f, H5G_entry_t *cwd, const char *name, *------------------------------------------------------------------------- */ static herr_t -H5G_mkroot (hdf5_file_t *f, size_t size_hint) +H5G_mkroot (H5F_t *f, size_t size_hint) { H5G_entry_t *handle=NULL; /*handle to open object */ herr_t ret_value=FAIL; /*return value */ @@ -352,7 +352,7 @@ H5G_mkroot (hdf5_file_t *f, size_t size_hint) * Make sure that the file descriptor has the latest info -- someone might * have the root object open. */ - H5G_shadow_sync (f->root_sym); + H5G_shadow_sync (f->shared->root_sym); /* * If we already have a root object, then open it and get it's name. The @@ -363,11 +363,11 @@ H5G_mkroot (hdf5_file_t *f, size_t size_hint) * re-inserted back into the directory hierarchy. We might leak file * memory, but at least we don't loose the original root object. */ - if (f->root_sym->header>0) { - if (H5O_read (f, NO_ADDR, f->root_sym, H5O_STAB, 0, &stab)) { + if (f->shared->root_sym->header>0) { + if (H5O_read (f, NO_ADDR, f->shared->root_sym, H5O_STAB, 0, &stab)) { /* root directory already exists */ HGOTO_ERROR (H5E_DIRECTORY, H5E_EXISTS, -2); - } else if (NULL==(handle=H5G_shadow_open (f, NULL, f->root_sym))) { + } else if (NULL==(handle=H5G_shadow_open (f, NULL, f->shared->root_sym))) { /* can't open root object */ HGOTO_ERROR (H5E_DIRECTORY, H5E_CANTINIT, FAIL); } else if (NULL==H5O_read (f, NO_ADDR, handle, H5O_NAME, 0, &name)) { @@ -383,10 +383,10 @@ H5G_mkroot (hdf5_file_t *f, size_t size_hint) * something goes wrong at this step, closing the `handle' will rewrite * info back into f->root_sym because we set the dirty bit. */ - if (H5G_stab_new (f, f->root_sym, size_hint)<0) { + if (H5G_stab_new (f, f->shared->root_sym, size_hint)<0) { HGOTO_ERROR (H5E_DIRECTORY, H5E_CANTINIT, FAIL); /*cant create root*/ } - if (1!=H5O_link (f, f->root_sym, 1)) { + if (1!=H5O_link (f, f->shared->root_sym, 1)) { HGOTO_ERROR (H5E_DIRECTORY, H5E_LINK, FAIL); } @@ -399,7 +399,7 @@ H5G_mkroot (hdf5_file_t *f, size_t size_hint) if (1!=H5O_link (f, handle, 0)) { HGOTO_ERROR (H5E_DIRECTORY, H5E_LINK, FAIL); } - if (NULL==(ent_ptr=H5G_stab_insert (f, f->root_sym, obj_name, + if (NULL==(ent_ptr=H5G_stab_insert (f, f->shared->root_sym, obj_name, handle))) { HGOTO_ERROR (H5E_DIRECTORY, H5E_CANTINIT, FAIL); } @@ -464,7 +464,7 @@ H5G_mkroot (hdf5_file_t *f, size_t size_hint) *------------------------------------------------------------------------- */ H5G_entry_t * -H5G_mkdir (hdf5_file_t *f, const char *name, size_t size_hint) +H5G_mkdir (H5F_t *f, const char *name, size_t size_hint) { const char *rest=NULL; /*the base name */ H5G_entry_t *cwd=NULL; /*current working directory */ @@ -483,8 +483,8 @@ H5G_mkdir (hdf5_file_t *f, const char *name, size_t size_hint) assert (name && *name); #ifndef LATER /* Get current working directory */ - H5G_shadow_sync (f->root_sym); - cwd = f->root_sym; + H5G_shadow_sync (f->shared->root_sym); + cwd = f->shared->root_sym; #endif assert (cwd || '/'==*name); @@ -558,7 +558,7 @@ H5G_mkdir (hdf5_file_t *f, const char *name, size_t size_hint) *------------------------------------------------------------------------- */ herr_t -H5G_pushd (hdf5_file_t *f, const char *name) +H5G_pushd (H5F_t *f, const char *name) { FUNC_ENTER (H5G_pushd, NULL, FAIL); @@ -592,7 +592,7 @@ H5G_pushd (hdf5_file_t *f, const char *name) *------------------------------------------------------------------------- */ herr_t -H5G_popd (hdf5_file_t *f) +H5G_popd (H5F_t *f) { FUNC_ENTER (H5G_popd, NULL, FAIL); @@ -625,7 +625,7 @@ H5G_popd (hdf5_file_t *f) *------------------------------------------------------------------------- */ H5G_entry_t * -H5G_create (hdf5_file_t *f, const char *name, size_t ohdr_hint) +H5G_create (H5F_t *f, const char *name, size_t ohdr_hint) { H5G_entry_t ent; /*entry data for the new object */ H5G_entry_t *ent_ptr; /*ptr into symbol node for entry*/ @@ -647,8 +647,8 @@ H5G_create (hdf5_file_t *f, const char *name, size_t ohdr_hint) * Get the current working directory. */ #ifndef LATER - H5G_shadow_sync (f->root_sym); - cwd = f->root_sym; + H5G_shadow_sync (f->shared->root_sym); + cwd = f->shared->root_sym; #endif /* @@ -666,7 +666,7 @@ H5G_create (hdf5_file_t *f, const char *name, size_t ohdr_hint) * doesn't have a name or we shouldn't interfere with the name * it already has as a message. */ - if (f->root_sym->header>0) { + if (f->shared->root_sym->header>0) { HRETURN_ERROR (H5E_DIRECTORY, H5E_EXISTS, NULL); /*root exists*/ } if ((ent.header = H5O_new (f, 0, ohdr_hint))<0) { @@ -676,8 +676,8 @@ H5G_create (hdf5_file_t *f, const char *name, size_t ohdr_hint) if (1!=H5O_link (f, &ent, 1)) { HRETURN_ERROR (H5E_DIRECTORY, H5E_LINK, NULL); /*bad link count*/ } - *(f->root_sym) = ent; - if (NULL==(ret_value=H5G_shadow_open (f, &dir, f->root_sym))) { + *(f->shared->root_sym) = ent; + if (NULL==(ret_value=H5G_shadow_open (f, &dir, f->shared->root_sym))) { HRETURN_ERROR (H5E_DIRECTORY, H5E_CANTINIT, NULL); } HRETURN (ret_value); @@ -710,7 +710,7 @@ H5G_create (hdf5_file_t *f, const char *name, size_t ohdr_hint) } - if (f->root_sym->header<=0) { + if (f->shared->root_sym->header<=0) { /* * This will be the only object in the file. Insert it as the root * object and add a name messaage to the object header (or modify @@ -726,8 +726,8 @@ H5G_create (hdf5_file_t *f, const char *name, size_t ohdr_hint) if (1!=H5O_link (f, &ent, 1)) { HRETURN_ERROR (H5E_DIRECTORY, H5E_LINK, NULL); /*bad link count*/ } - *(f->root_sym) = ent; - if (NULL==(ret_value=H5G_shadow_open (f, &dir, f->root_sym))) { + *(f->shared->root_sym) = ent; + if (NULL==(ret_value=H5G_shadow_open (f, &dir, f->shared->root_sym))) { HRETURN_ERROR (H5E_DIRECTORY, H5E_CANTINIT, NULL); } HRETURN (ret_value); @@ -736,13 +736,13 @@ H5G_create (hdf5_file_t *f, const char *name, size_t ohdr_hint) * Make sure the root directory exists. Ignore the failure if it's * because the directory already exists. */ - hbool_t update_dir = (dir.header==f->root_sym->header); + hbool_t update_dir = (dir.header==f->shared->root_sym->header); herr_t status = H5G_mkroot (f, H5G_SIZE_HINT); if (status<0 && -2!=status) { HRETURN_ERROR (H5E_DIRECTORY, H5E_CANTINIT, NULL); } H5ECLEAR; - if (update_dir) dir = *(f->root_sym); + if (update_dir) dir = *(f->shared->root_sym); } /* @@ -788,7 +788,7 @@ H5G_create (hdf5_file_t *f, const char *name, size_t ohdr_hint) *------------------------------------------------------------------------- */ H5G_entry_t * -H5G_open (hdf5_file_t *f, const char *name) +H5G_open (H5F_t *f, const char *name) { H5G_entry_t *ent=NULL; H5G_entry_t *ret_value=NULL; @@ -805,12 +805,12 @@ H5G_open (hdf5_file_t *f, const char *name) /* Get CWD */ #ifndef LATER - H5G_shadow_sync (f->root_sym); - cwd = f->root_sym; + H5G_shadow_sync (f->shared->root_sym); + cwd = f->shared->root_sym; #endif assert (cwd || '/'==*name); - if (f->root_sym->header<=0) { + if (f->shared->root_sym->header<=0) { HRETURN_ERROR (H5E_DIRECTORY, H5E_NOTFOUND, NULL); /*object not found*/ } if (NULL==(ent=H5G_namei (f, cwd, name, NULL, &dir))) { @@ -842,7 +842,7 @@ H5G_open (hdf5_file_t *f, const char *name) *------------------------------------------------------------------------- */ herr_t -H5G_close (hdf5_file_t *f, H5G_entry_t *ent) +H5G_close (H5F_t *f, H5G_entry_t *ent) { FUNC_ENTER (H5G_close, NULL, FAIL); @@ -896,7 +896,7 @@ H5G_close (hdf5_file_t *f, H5G_entry_t *ent) *------------------------------------------------------------------------- */ herr_t -H5G_find (hdf5_file_t *f, H5G_entry_t *cwd, H5G_entry_t *dir_ent, +H5G_find (H5F_t *f, H5G_entry_t *cwd, H5G_entry_t *dir_ent, const char *name, H5G_entry_t *ent) { H5G_entry_t *ent_p = NULL; @@ -907,7 +907,7 @@ H5G_find (hdf5_file_t *f, H5G_entry_t *cwd, H5G_entry_t *dir_ent, assert (name && *name); assert (cwd || '/'==*name); - if (f->root_sym->header<=0) { + if (f->shared->root_sym->header<=0) { HRETURN_ERROR (H5E_DIRECTORY, H5E_NOTFOUND, FAIL); /*object not found*/ } diff --git a/src/H5Gent.c b/src/H5Gent.c index bc54161..f9ca290 100644 --- a/src/H5Gent.c +++ b/src/H5Gent.c @@ -186,7 +186,7 @@ H5G_ent_modified (H5G_entry_t *ent, H5G_type_t cache_type) *------------------------------------------------------------------------- */ herr_t -H5G_ent_decode_vec (hdf5_file_t *f, uint8 **pp, H5G_entry_t *ent, intn n) +H5G_ent_decode_vec (H5F_t *f, uint8 **pp, H5G_entry_t *ent, intn n) { intn i; @@ -230,7 +230,7 @@ H5G_ent_decode_vec (hdf5_file_t *f, uint8 **pp, H5G_entry_t *ent, intn n) *------------------------------------------------------------------------- */ herr_t -H5G_ent_decode (hdf5_file_t *f, uint8 **pp, H5G_entry_t *ent) +H5G_ent_decode (H5F_t *f, uint8 **pp, H5G_entry_t *ent) { uint8 *p_ret = *pp; @@ -299,7 +299,7 @@ H5G_ent_decode (hdf5_file_t *f, uint8 **pp, H5G_entry_t *ent) *------------------------------------------------------------------------- */ herr_t -H5G_ent_encode_vec (hdf5_file_t *f, uint8 **pp, H5G_entry_t *ent, intn n) +H5G_ent_encode_vec (H5F_t *f, uint8 **pp, H5G_entry_t *ent, intn n) { intn i; @@ -349,7 +349,7 @@ H5G_ent_encode_vec (hdf5_file_t *f, uint8 **pp, H5G_entry_t *ent, intn n) *------------------------------------------------------------------------- */ herr_t -H5G_ent_encode (hdf5_file_t *f, uint8 **pp, H5G_entry_t *ent) +H5G_ent_encode (H5F_t *f, uint8 **pp, H5G_entry_t *ent) { uint8 *p_ret = *pp + H5G_SIZEOF_ENTRY(f); @@ -418,7 +418,7 @@ H5G_ent_encode (hdf5_file_t *f, uint8 **pp, H5G_entry_t *ent) *------------------------------------------------------------------------- */ herr_t -H5G_ent_debug (hdf5_file_t *f, H5G_entry_t *ent, FILE *stream, intn indent, +H5G_ent_debug (H5F_t *f, H5G_entry_t *ent, FILE *stream, intn indent, intn fwidth) { int i; diff --git a/src/H5Gnode.c b/src/H5Gnode.c index ffa1f86..84dc0e5 100644 --- a/src/H5Gnode.c +++ b/src/H5Gnode.c @@ -39,30 +39,30 @@ #define PABLO_MASK H5G_node_mask /* PRIVATE PROTOTYPES */ -static herr_t H5G_node_decode_key (hdf5_file_t *f, uint8 *raw, void *_key); -static herr_t H5G_node_encode_key (hdf5_file_t *f, uint8 *raw, void *_key); -static size_t H5G_node_size (hdf5_file_t *f); -static haddr_t H5G_node_new (hdf5_file_t *f, void *_lt_key, void *_udata, +static herr_t H5G_node_decode_key (H5F_t *f, uint8 *raw, void *_key); +static herr_t H5G_node_encode_key (H5F_t *f, uint8 *raw, void *_key); +static size_t H5G_node_size (H5F_t *f); +static haddr_t H5G_node_new (H5F_t *f, void *_lt_key, void *_udata, void *_rt_key); -static herr_t H5G_node_flush (hdf5_file_t *f, hbool_t destroy, haddr_t addr, +static herr_t H5G_node_flush (H5F_t *f, hbool_t destroy, haddr_t addr, H5G_node_t *sym); -static H5G_node_t *H5G_node_load (hdf5_file_t *f, haddr_t addr, void *_data); -static intn H5G_node_cmp (hdf5_file_t *f, void *_lt_key, void *_udata, +static H5G_node_t *H5G_node_load (H5F_t *f, haddr_t addr, void *_data); +static intn H5G_node_cmp (H5F_t *f, void *_lt_key, void *_udata, void *_rt_key); -static herr_t H5G_node_found (hdf5_file_t *f, haddr_t addr, +static herr_t H5G_node_found (H5F_t *f, haddr_t addr, const void *_lt_key, void *_udata, const void *_rt_key); -static haddr_t H5G_node_insert (hdf5_file_t *f, haddr_t addr, intn *anchor, +static haddr_t H5G_node_insert (H5F_t *f, haddr_t addr, intn *anchor, void *_lt_key, hbool_t *lt_key_changed, void *_md_key, void *_udata, void *_rt_key, hbool_t *rt_key_changed); -static herr_t H5G_node_list (hdf5_file_t *f, haddr_t addr, void *_udata); -static size_t H5G_node_sizeof_rkey (hdf5_file_t *f); +static herr_t H5G_node_list (H5F_t *f, haddr_t addr, void *_udata); +static size_t H5G_node_sizeof_rkey (H5F_t *f); /* H5G inherits cache-like properties from H5AC */ const H5AC_class_t H5AC_SNODE[1] = {{ - (void*(*)(hdf5_file_t*,haddr_t,void*))H5G_node_load, - (herr_t(*)(hdf5_file_t*,hbool_t,haddr_t,void*))H5G_node_flush, + (void*(*)(H5F_t*,haddr_t,void*))H5G_node_load, + (herr_t(*)(H5F_t*,hbool_t,haddr_t,void*))H5G_node_flush, }}; /* H5G inherits B-tree like properties from H5B */ @@ -102,7 +102,7 @@ static intn interface_initialize_g = FALSE; *------------------------------------------------------------------------- */ static size_t -H5G_node_sizeof_rkey (hdf5_file_t *f) +H5G_node_sizeof_rkey (H5F_t *f) { return H5F_SIZEOF_OFFSET(f); } @@ -126,7 +126,7 @@ H5G_node_sizeof_rkey (hdf5_file_t *f) *------------------------------------------------------------------------- */ static herr_t -H5G_node_decode_key (hdf5_file_t *f, uint8 *raw, void *_key) +H5G_node_decode_key (H5F_t *f, uint8 *raw, void *_key) { H5G_node_key_t *key = (H5G_node_key_t *)_key; @@ -160,7 +160,7 @@ H5G_node_decode_key (hdf5_file_t *f, uint8 *raw, void *_key) *------------------------------------------------------------------------- */ static herr_t -H5G_node_encode_key (hdf5_file_t *f, uint8 *raw, void *_key) +H5G_node_encode_key (H5F_t *f, uint8 *raw, void *_key) { H5G_node_key_t *key = (H5G_node_key_t *)_key; @@ -194,7 +194,7 @@ H5G_node_encode_key (hdf5_file_t *f, uint8 *raw, void *_key) *------------------------------------------------------------------------- */ static size_t -H5G_node_size (hdf5_file_t *f) +H5G_node_size (H5F_t *f) { return H5G_NODE_SIZEOF_HDR(f) + (2*H5G_NODE_K(f)) * H5G_SIZEOF_ENTRY(f); @@ -222,7 +222,7 @@ H5G_node_size (hdf5_file_t *f) *------------------------------------------------------------------------- */ static haddr_t -H5G_node_new (hdf5_file_t *f, void *_lt_key, void *_udata, void *_rt_key) +H5G_node_new (H5F_t *f, void *_lt_key, void *_udata, void *_rt_key) { H5G_node_key_t *lt_key = (H5G_node_key_t*)_lt_key; H5G_node_key_t *rt_key = (H5G_node_key_t*)_rt_key; @@ -244,7 +244,7 @@ H5G_node_new (hdf5_file_t *f, void *_lt_key, void *_udata, void *_rt_key) HRETURN_ERROR (H5E_SYM, H5E_CANTINIT, FAIL); } - sym->dirty = 1; + sym->dirty = TRUE; sym->entry = H5MM_xcalloc (2 * H5G_NODE_K(f), sizeof(H5G_entry_t)); if (H5AC_set (f, H5AC_SNODE, addr, sym)<0) { H5MM_xfree (sym->entry); @@ -286,7 +286,7 @@ H5G_node_new (hdf5_file_t *f, void *_lt_key, void *_udata, void *_rt_key) *------------------------------------------------------------------------- */ static herr_t -H5G_node_flush (hdf5_file_t *f, hbool_t destroy, haddr_t addr, H5G_node_t *sym) +H5G_node_flush (H5F_t *f, hbool_t destroy, haddr_t addr, H5G_node_t *sym) { uint8 *buf=NULL, *p=NULL; size_t size; @@ -304,7 +304,7 @@ H5G_node_flush (hdf5_file_t *f, hbool_t destroy, haddr_t addr, H5G_node_t *sym) /* * Synchronize all entries with their corresponding shadow if they have - * one. + * one. Also look for dirty entries and set the node dirty flag. */ for (i=0; insyms; i++) { if (H5G_shadow_sync (sym->entry+i)<0) { @@ -378,7 +378,7 @@ H5G_node_flush (hdf5_file_t *f, hbool_t destroy, haddr_t addr, H5G_node_t *sym) *------------------------------------------------------------------------- */ static H5G_node_t * -H5G_node_load (hdf5_file_t *f, haddr_t addr, void *_udata) +H5G_node_load (H5F_t *f, haddr_t addr, void *_udata) { H5G_node_t *sym = NULL; size_t size = 0; @@ -478,7 +478,7 @@ H5G_node_load (hdf5_file_t *f, haddr_t addr, void *_udata) *------------------------------------------------------------------------- */ static intn -H5G_node_cmp (hdf5_file_t *f, void *_lt_key, void *_udata, void *_rt_key) +H5G_node_cmp (H5F_t *f, void *_lt_key, void *_udata, void *_rt_key) { H5G_bt_ud1_t *udata = (H5G_bt_ud1_t *)_udata; H5G_node_key_t *lt_key = (H5G_node_key_t *)_lt_key; @@ -532,7 +532,7 @@ H5G_node_cmp (hdf5_file_t *f, void *_lt_key, void *_udata, void *_rt_key) *------------------------------------------------------------------------- */ static herr_t -H5G_node_found (hdf5_file_t *f, haddr_t addr, const void *_lt_key, +H5G_node_found (H5F_t *f, haddr_t addr, const void *_lt_key, void *_udata, const void *_rt_key) { H5G_bt_ud1_t *bt_udata = (H5G_bt_ud1_t *)_udata; @@ -656,7 +656,7 @@ done: *------------------------------------------------------------------------- */ static haddr_t -H5G_node_insert (hdf5_file_t *f, haddr_t addr, intn *anchor, +H5G_node_insert (H5F_t *f, haddr_t addr, intn *anchor, void *_lt_key, hbool_t *lt_key_changed, void *_md_key, void *_udata, void *_rt_key, hbool_t *rt_key_changed) @@ -757,7 +757,7 @@ H5G_node_insert (hdf5_file_t *f, haddr_t addr, intn *anchor, HDmemcpy (snrt->entry, sn->entry + H5G_NODE_K(f), H5G_NODE_K(f) * sizeof(H5G_entry_t)); snrt->nsyms = H5G_NODE_K(f); - snrt->dirty += 1; + snrt->dirty = TRUE; /* Right shadows */ for (i=0; ientry + H5G_NODE_K(f), 0, H5G_NODE_K(f) * sizeof(H5G_entry_t)); sn->nsyms = H5G_NODE_K (f); - sn->dirty += 1; + sn->dirty = TRUE; /* The middle key */ md_key->offset = sn->entry[sn->nsyms-1].name_off; @@ -789,7 +789,7 @@ H5G_node_insert (hdf5_file_t *f, haddr_t addr, intn *anchor, } else { /* Where to insert the new entry? */ - sn->dirty += 1; + sn->dirty = TRUE; insert_into = sn; insert_addr = addr; if (idx==sn->nsyms) { @@ -868,7 +868,7 @@ done: *------------------------------------------------------------------------- */ static herr_t -H5G_node_list (hdf5_file_t *f, haddr_t addr, void *_udata) +H5G_node_list (H5F_t *f, haddr_t addr, void *_udata) { H5G_bt_ud2_t *bt_udata = (H5G_bt_ud2_t *)_udata; H5G_node_t *sn = NULL; @@ -954,7 +954,7 @@ done: *------------------------------------------------------------------------- */ herr_t -H5G_node_debug (hdf5_file_t *f, haddr_t addr, FILE *stream, intn indent, +H5G_node_debug (H5F_t *f, haddr_t addr, FILE *stream, intn indent, intn fwidth, haddr_t heap) { int i, acc; @@ -999,9 +999,9 @@ H5G_node_debug (hdf5_file_t *f, haddr_t addr, FILE *stream, intn indent, fprintf (stream, "%*sSymbol Table Node...\n", indent, ""); - fprintf (stream, "%*s%-*s %d\n", indent, "", fwidth, + fprintf (stream, "%*s%-*s %s\n", indent, "", fwidth, "Dirty:", - sn->dirty); + sn->dirty?"Yes":"No"); fprintf (stream, "%*s%-*s %d of %d\n", indent, "", fwidth, "Number of Symbols:", sn->nsyms, 2*H5G_NODE_K(f)); diff --git a/src/H5Gpkg.h b/src/H5Gpkg.h index 74881f7..e0d6f8d 100644 --- a/src/H5Gpkg.h +++ b/src/H5Gpkg.h @@ -21,7 +21,7 @@ #define H5G_NODE_VERS 1 /*symbol table node version number */ #define H5G_SIZE_HINT 1024 /*default root dir size hint */ -#define H5G_NODE_K(F) ((F)->file_create_parms.sym_leaf_k) +#define H5G_NODE_K(F) ((F)->shared->file_create_parms.sym_leaf_k) #define H5G_NODE_SIZEOF_HDR(F) (H5G_NODE_SIZEOF_MAGIC + 4) #define H5G_DEFAULT_ROOT_SIZE 32 @@ -41,6 +41,18 @@ struct H5G_entry_t { }; /* + * A symbol table node is a collection of symbol table entries. It can + * be thought of as the lowest level of the B-link tree that points to + * a collection of symbol table entries that belong to a specific symbol + * table or directory. + */ +typedef struct H5G_node_t { + hbool_t dirty; /*has cache been modified? */ + int nsyms; /*number of symbols */ + H5G_entry_t *entry; /*array of symbol table entries */ +} H5G_node_t; + +/* * A shadow is a copy of a symbol table entry which corresponds to an * `open' object. Shadows are necessary because normal symbol table * entries can be preempted from the main cache. The `shadow' field @@ -58,18 +70,6 @@ struct H5G_shadow_t { }; /* - * A symbol table node is a collection of symbol table entries. It can - * be thought of as the lowest level of the B-link tree that points to - * a collection of symbol table entries that belong to a specific symbol - * table or directory. - */ -typedef struct H5G_node_t { - int dirty; /*has cache been modified? */ - int nsyms; /*number of symbols */ - H5G_entry_t *entry; /*array of symbol table entries */ -} H5G_node_t; - -/* * Each key field of the B-link tree that points to symbol table * nodes consists of this structure... */ @@ -148,36 +148,34 @@ extern const H5AC_class_t H5AC_SNODE[1]; * functions that understand directories are exported to the rest of * the library and appear in H5Gprivate.h. */ -haddr_t H5G_stab_new (hdf5_file_t *f, H5G_entry_t *self, size_t init); -H5G_entry_t *H5G_stab_find (hdf5_file_t *f, haddr_t addr, H5G_entry_t *self, +haddr_t H5G_stab_new (H5F_t *f, H5G_entry_t *self, size_t init); +H5G_entry_t *H5G_stab_find (H5F_t *f, haddr_t addr, H5G_entry_t *self, const char *name); -H5G_entry_t *H5G_stab_insert (hdf5_file_t *f, H5G_entry_t *self, +H5G_entry_t *H5G_stab_insert (H5F_t *f, H5G_entry_t *self, const char *name, H5G_entry_t *ent); -intn H5G_stab_list (hdf5_file_t *f, H5G_entry_t *self, intn maxentries, +intn H5G_stab_list (H5F_t *f, H5G_entry_t *self, intn maxentries, char *names[], H5G_entry_t entries[]); /* * Functions that understand shadow entries. */ herr_t H5G_shadow_sync (H5G_entry_t *ent); -H5G_entry_t *H5G_shadow_open (hdf5_file_t *f, H5G_entry_t *dir, +H5G_entry_t *H5G_shadow_open (H5F_t *f, H5G_entry_t *dir, H5G_entry_t *ent); -herr_t H5G_shadow_close (hdf5_file_t *f, H5G_entry_t *ent); +herr_t H5G_shadow_close (H5F_t *f, H5G_entry_t *ent); hbool_t H5G_shadow_p (H5G_entry_t *ent); herr_t H5G_shadow_dissociate (H5G_entry_t *ent); -herr_t H5G_shadow_assoc_node (hdf5_file_t *f, H5G_node_t *sym, +herr_t H5G_shadow_assoc_node (H5F_t *f, H5G_node_t *sym, H5G_ac_ud1_t *ac_udata); -H5G_shadow_t *H5G_shadow_list (hdf5_file_t *f, haddr_t stab_header_addr); -herr_t H5G_shadow_move (hdf5_file_t *f, H5G_shadow_t *shadow, +H5G_shadow_t *H5G_shadow_list (H5F_t *f, haddr_t stab_header_addr); +herr_t H5G_shadow_move (H5F_t *f, H5G_shadow_t *shadow, const char *new_name, H5G_entry_t *new_entry, haddr_t dir_addr); /* * Functions that understand symbol table entries. */ -herr_t H5G_ent_decode_vec (hdf5_file_t *f, uint8 **pp, H5G_entry_t *ent, - intn n); -herr_t H5G_ent_encode_vec (hdf5_file_t *f, uint8 **pp, H5G_entry_t *ent, - intn n); +herr_t H5G_ent_decode_vec (H5F_t *f, uint8 **pp, H5G_entry_t *ent, intn n); +herr_t H5G_ent_encode_vec (H5F_t *f, uint8 **pp, H5G_entry_t *ent, intn n); #endif diff --git a/src/H5Gprivate.h b/src/H5Gprivate.h index 97355c2..79666e7 100644 --- a/src/H5Gprivate.h +++ b/src/H5Gprivate.h @@ -82,27 +82,27 @@ typedef struct H5G_entry_t H5G_entry_t; * Library prototypes... These are the ones that other packages routinely * call. */ -H5G_entry_t *H5G_mkdir (hdf5_file_t *f, const char *name, size_t size_hint); -herr_t H5G_pushd (hdf5_file_t *f, const char *name); -herr_t H5G_popd (hdf5_file_t *f); -H5G_entry_t *H5G_create (hdf5_file_t *f, const char *name, size_t ohdr_hint); -H5G_entry_t *H5G_open (hdf5_file_t *f, const char *name); -herr_t H5G_close (hdf5_file_t *f, H5G_entry_t *ent); -herr_t H5G_find (hdf5_file_t *f, H5G_entry_t *cwd, H5G_entry_t *dir_ent, +H5G_entry_t *H5G_mkdir (H5F_t *f, const char *name, size_t size_hint); +herr_t H5G_pushd (H5F_t *f, const char *name); +herr_t H5G_popd (H5F_t *f); +H5G_entry_t *H5G_create (H5F_t *f, const char *name, size_t ohdr_hint); +H5G_entry_t *H5G_open (H5F_t *f, const char *name); +herr_t H5G_close (H5F_t *f, H5G_entry_t *ent); +herr_t H5G_find (H5F_t *f, H5G_entry_t *cwd, H5G_entry_t *dir_ent, const char *name, H5G_entry_t *ent); -herr_t H5G_ent_encode (hdf5_file_t *f, uint8 **pp, H5G_entry_t *ent); -herr_t H5G_ent_decode (hdf5_file_t *f, uint8 **pp, H5G_entry_t *ent); +herr_t H5G_ent_encode (H5F_t *f, uint8 **pp, H5G_entry_t *ent); +herr_t H5G_ent_decode (H5F_t *f, uint8 **pp, H5G_entry_t *ent); /* * These functions operate on symbol table nodes. */ -herr_t H5G_node_debug (hdf5_file_t *f, haddr_t addr, FILE *stream, intn indent, +herr_t H5G_node_debug (H5F_t *f, haddr_t addr, FILE *stream, intn indent, intn fwidth, haddr_t heap); /* * These functions operate on shadow entries. */ -herr_t H5G_shadow_flush (hdf5_file_t *f, hbool_t invalidate); +herr_t H5G_shadow_flush (H5F_t *f, hbool_t invalidate); /* * These functions operate on symbol table entries. They're used primarily @@ -114,7 +114,7 @@ herr_t H5G_ent_invalidate (H5G_entry_t *ent); haddr_t H5G_ent_addr (H5G_entry_t *ent); H5G_cache_t *H5G_ent_cache (H5G_entry_t *ent, H5G_type_t *cache_type); herr_t H5G_ent_modified (H5G_entry_t *ent, H5G_type_t cache_type); -herr_t H5G_ent_debug (hdf5_file_t *f, H5G_entry_t *ent, FILE *stream, +herr_t H5G_ent_debug (H5F_t *f, H5G_entry_t *ent, FILE *stream, intn indent, intn fwidth); #endif diff --git a/src/H5Gshad.c b/src/H5Gshad.c index 315abed..9bf80d8 100644 --- a/src/H5Gshad.c +++ b/src/H5Gshad.c @@ -14,8 +14,16 @@ #include /*memory management */ #include /*object header messages */ +/* + * FEATURE: If this macro is defined then H5G_shadow_check() is occassionally + * (actually, quite often) called to check the consistency of the + * shadow table. If there's something wrong with the table then + * abort() is called. Shadow table checking is a rather expensive + * operation. + */ +/* #define H5G_DEBUG_SHADOWS */ + #define PABLO_MASK H5G_shadow_mask -#undef DEBUG_SHADOWS /* Is the interface initialized? */ static hbool_t interface_initialize_g = FALSE; @@ -43,9 +51,9 @@ typedef struct H5G_hash_t { * *------------------------------------------------------------------------- */ -#ifdef DEBUG_SHADOWS +#ifdef H5G_DEBUG_SHADOWS void -H5G_shadow_check (hdf5_file_t *f) +H5G_shadow_check (H5F_t *f) { H5G_hash_t *hash=NULL; H5G_shadow_t *shadow=NULL, *prev_shadow=NULL; @@ -253,14 +261,14 @@ H5G_shadow_sync (H5G_entry_t *ent) *------------------------------------------------------------------------- */ H5G_shadow_t * -H5G_shadow_list (hdf5_file_t *f, haddr_t dir_addr) +H5G_shadow_list (H5F_t *f, haddr_t dir_addr) { - uintn idx = dir_addr % f->nshadows; + uintn idx = dir_addr % f->shared->nshadows; H5G_hash_t *bucket = NULL; FUNC_ENTER (H5G_shadows, NULL, NULL); - for (bucket=f->shadow[idx]; bucket; bucket=bucket->next) { + for (bucket=f->shared->shadow[idx]; bucket; bucket=bucket->next) { if (bucket->dir_addr==dir_addr) { HRETURN (bucket->head); } @@ -291,7 +299,7 @@ H5G_shadow_list (hdf5_file_t *f, haddr_t dir_addr) *------------------------------------------------------------------------- */ herr_t -H5G_shadow_assoc_node (hdf5_file_t *f, H5G_node_t *sym, H5G_ac_ud1_t *ac_udata) +H5G_shadow_assoc_node (H5F_t *f, H5G_node_t *sym, H5G_ac_ud1_t *ac_udata) { H5G_shadow_t *shadow = NULL; const char *s = NULL; @@ -305,7 +313,7 @@ H5G_shadow_assoc_node (hdf5_file_t *f, H5G_node_t *sym, H5G_ac_ud1_t *ac_udata) assert (sym); /* The symbol table node */ assert (ac_udata); /* The symbol table header info */ -#ifdef DEBUG_SHADOWS +#ifdef H5G_DEBUG_SHADOWS H5G_shadow_check (f); #endif @@ -358,7 +366,7 @@ H5G_shadow_assoc_node (hdf5_file_t *f, H5G_node_t *sym, H5G_ac_ud1_t *ac_udata) *------------------------------------------------------------------------- */ H5G_entry_t * -H5G_shadow_open (hdf5_file_t *f, H5G_entry_t *dir, H5G_entry_t *ent) +H5G_shadow_open (H5F_t *f, H5G_entry_t *dir, H5G_entry_t *ent) { H5G_shadow_t *shadow = NULL; H5O_stab_t stab; @@ -374,7 +382,7 @@ H5G_shadow_open (hdf5_file_t *f, H5G_entry_t *dir, H5G_entry_t *ent) /* check args */ assert (f); - assert (ent==f->root_sym || dir); + assert (ent==f->shared->root_sym || dir); assert (ent); dir_addr = dir ? dir->header : 0; @@ -388,7 +396,7 @@ H5G_shadow_open (hdf5_file_t *f, H5G_entry_t *dir, H5G_entry_t *ent) shadow = H5MM_xcalloc (1, sizeof(H5G_shadow_t)); - if (ent==f->root_sym && 0==dir_addr) { + if (ent==f->shared->root_sym && 0==dir_addr) { /* * We're opening the root entry. */ @@ -425,15 +433,15 @@ H5G_shadow_open (hdf5_file_t *f, H5G_entry_t *dir, H5G_entry_t *ent) /* * Link it into the shadow heap */ - idx = dir_addr % f->nshadows; - for (hash=f->shadow[idx]; hash; hash=hash->next) { + idx = dir_addr % f->shared->nshadows; + for (hash=f->shared->shadow[idx]; hash; hash=hash->next) { if (hash->dir_addr==dir_addr) break; } if (!hash) { hash = H5MM_xcalloc (1, sizeof(H5G_hash_t)); hash->dir_addr = dir_addr; - hash->next = f->shadow[idx]; - f->shadow[idx] = hash; + hash->next = f->shared->shadow[idx]; + f->shared->shadow[idx] = hash; if (hash->next) hash->next->prev = hash; } if (hash->head) { @@ -463,7 +471,7 @@ H5G_shadow_open (hdf5_file_t *f, H5G_entry_t *dir, H5G_entry_t *ent) hash->head = shadow; } -#ifdef DEBUG_SHADOWS +#ifdef H5G_DEBUG_SHADOWS H5G_shadow_check (f); #endif @@ -499,7 +507,7 @@ H5G_shadow_open (hdf5_file_t *f, H5G_entry_t *dir, H5G_entry_t *ent) *------------------------------------------------------------------------- */ herr_t -H5G_shadow_close (hdf5_file_t *f, H5G_entry_t *ent) +H5G_shadow_close (H5F_t *f, H5G_entry_t *ent) { uintn idx; H5G_hash_t *hash=NULL; @@ -532,8 +540,8 @@ H5G_shadow_close (hdf5_file_t *f, H5G_entry_t *ent) H5G_shadow_dissociate (ent); /* find symtabs shadow list */ - idx = shadow->dir_addr % f->nshadows; - for (hash=f->shadow[idx]; hash; hash=hash->next) { + idx = shadow->dir_addr % f->shared->nshadows; + for (hash=f->shared->shadow[idx]; hash; hash=hash->next) { if (hash->dir_addr==shadow->dir_addr) break; } assert (hash); @@ -554,7 +562,7 @@ H5G_shadow_close (hdf5_file_t *f, H5G_entry_t *ent) /* remove symtab's shadow list if empty */ if (!hash->head) { if (hash->prev) hash->prev->next = hash->next; - else f->shadow[idx] = hash->next; + else f->shared->shadow[idx] = hash->next; if (hash->next) hash->next->prev = hash->prev; H5MM_xfree (hash); } @@ -584,7 +592,7 @@ H5G_shadow_close (hdf5_file_t *f, H5G_entry_t *ent) *------------------------------------------------------------------------- */ herr_t -H5G_shadow_move (hdf5_file_t *f, H5G_shadow_t *shadow, const char *new_name, +H5G_shadow_move (H5F_t *f, H5G_shadow_t *shadow, const char *new_name, H5G_entry_t *new_entry, haddr_t dir_addr) { H5G_hash_t *hash; @@ -602,17 +610,17 @@ H5G_shadow_move (hdf5_file_t *f, H5G_shadow_t *shadow, const char *new_name, * greatly since it implies that this is the only shadow currently * defined for the entire file. */ - idx = dir_addr % f->nshadows; - assert (NULL==f->shadow[idx]); /*Nothing at new idx... */ - hash = f->shadow[0]; + idx = dir_addr % f->shared->nshadows; + assert (NULL==f->shared->shadow[idx]); /*Nothing at new idx... */ + hash = f->shared->shadow[0]; assert (hash); /*..but root idx has something. */ assert (0==hash->dir_addr); /*..and it's the root something */ assert (NULL==hash->next); /*..and just that */ assert (hash->head==shadow); /*..and exactly that */ /* Move root entry to new hash bucket */ - f->shadow[idx] = hash; - f->shadow[0] = NULL; + f->shared->shadow[idx] = hash; + f->shared->shadow[0] = NULL; hash->dir_addr = dir_addr; /* Associate SHADOW with NEW_ENTRY */ @@ -656,7 +664,7 @@ H5G_shadow_move (hdf5_file_t *f, H5G_shadow_t *shadow, const char *new_name, *------------------------------------------------------------------------- */ herr_t -H5G_shadow_flush (hdf5_file_t *f, hbool_t invalidate) +H5G_shadow_flush (H5F_t *f, hbool_t invalidate) { uintn idx; H5G_hash_t *hash = NULL; @@ -665,26 +673,32 @@ H5G_shadow_flush (hdf5_file_t *f, hbool_t invalidate) FUNC_ENTER (H5G_shadow_flush, NULL, FAIL); - for (idx=0; idxnshadows; idx++) { - for (hash=f->shadow[idx]; hash; hash=hash->next) { + for (idx=0; idxshared->nshadows; idx++) { + for (hash=f->shared->shadow[idx]; hash; hash=hash->next) { for (shadow=hash->head; shadow; shadow=shadow->next) { - if (!shadow->main && - NULL==H5G_stab_find (f, shadow->dir_addr, NULL, - shadow->name)) { - HRETURN_ERROR (H5E_SYM, H5E_NOTFOUND, FAIL); + /* + * If the shadow is dirty, then transfer the shadow info to the + * symbol table node. + */ + if (shadow->entry.dirty) { + if (!shadow->main && + NULL==H5G_stab_find (f, shadow->dir_addr, NULL, + shadow->name)) { + HRETURN_ERROR (H5E_SYM, H5E_NOTFOUND, FAIL); + } + assert (shadow->main); + *(shadow->main) = shadow->entry; + shadow->entry.dirty = FALSE; + nfound++; + } - assert (shadow->main); - *(shadow->main) = shadow->entry; - shadow->entry.dirty = FALSE; - nfound++; - #ifndef NDEBUG /* - * This is usually a bad thing--an hdf5 programmer forgot to - * close some object before closing the file. Since this is hard - * to debug, we'll be nice and print the names here. We don't - * know the full name, but we'll print the file address (relative - * to the boot block) of the object header for the directory that + * This is usually a bad thing--an hdf5 programmer forgot to close + * some object before closing the file. Since this is hard to + * debug, we'll be nice and print the names here. We don't know + * the full name, but we'll print the file address (relative to + * the boot block) of the object header for the directory that * contains the open object. */ if (invalidate) { diff --git a/src/H5Gstab.c b/src/H5Gstab.c index 209cbc4..b600e90 100644 --- a/src/H5Gstab.c +++ b/src/H5Gstab.c @@ -57,7 +57,7 @@ static hbool_t interface_initialize_g = FALSE; *------------------------------------------------------------------------- */ haddr_t -H5G_stab_new (hdf5_file_t *f, H5G_entry_t *self, size_t init) +H5G_stab_new (H5F_t *f, H5G_entry_t *self, size_t init) { off_t name; /*offset of "" name */ haddr_t addr; /*object header address */ @@ -144,7 +144,7 @@ H5G_stab_new (hdf5_file_t *f, H5G_entry_t *self, size_t init) *------------------------------------------------------------------------- */ H5G_entry_t * -H5G_stab_find (hdf5_file_t *f, haddr_t addr, H5G_entry_t *self, +H5G_stab_find (H5F_t *f, haddr_t addr, H5G_entry_t *self, const char *name) { H5G_bt_ud1_t udata; /*data to pass through B-tree */ @@ -223,7 +223,7 @@ H5G_stab_find (hdf5_file_t *f, haddr_t addr, H5G_entry_t *self, *------------------------------------------------------------------------- */ H5G_entry_t * -H5G_stab_insert (hdf5_file_t *f, H5G_entry_t *self, const char *name, +H5G_stab_insert (H5F_t *f, H5G_entry_t *self, const char *name, H5G_entry_t *ent) { H5O_stab_t stab; /*symbol table message */ @@ -306,7 +306,7 @@ H5G_stab_insert (hdf5_file_t *f, H5G_entry_t *self, const char *name, *------------------------------------------------------------------------- */ intn -H5G_stab_list (hdf5_file_t *f, H5G_entry_t *self, intn maxentries, +H5G_stab_list (H5F_t *f, H5G_entry_t *self, intn maxentries, char *names[], H5G_entry_t entries[]) { H5G_bt_ud2_t udata; diff --git a/src/H5H.c b/src/H5H.c index 8afcea4..7724045 100644 --- a/src/H5H.c +++ b/src/H5H.c @@ -45,16 +45,15 @@ typedef struct H5H_t { } H5H_t; /* PRIVATE PROTOTYPES */ -static H5H_t *H5H_load (hdf5_file_t *f, haddr_t addr, void *udata); -static herr_t H5H_flush (hdf5_file_t *f, hbool_t dest, haddr_t addr, - H5H_t *heap); +static H5H_t *H5H_load (H5F_t *f, haddr_t addr, void *udata); +static herr_t H5H_flush (H5F_t *f, hbool_t dest, haddr_t addr, H5H_t *heap); /* * H5H inherits cache-like properties from H5AC */ static const H5AC_class_t H5AC_HEAP[1] = {{ - (void*(*)(hdf5_file_t*,haddr_t,void*))H5H_load, - (herr_t(*)(hdf5_file_t*,hbool_t,haddr_t,void*))H5H_flush, + (void*(*)(H5F_t*,haddr_t,void*))H5H_load, + (herr_t(*)(H5F_t*,hbool_t,haddr_t,void*))H5H_flush, }}; /* Is the interface initialized? */ @@ -88,7 +87,7 @@ static intn interface_initialize_g = FALSE; *------------------------------------------------------------------------- */ haddr_t -H5H_new (hdf5_file_t *f, H5H_type_t heap_type, size_t size_hint) +H5H_new (H5F_t *f, H5H_type_t heap_type, size_t size_hint) { H5H_t *heap = NULL; size_t total_size; /*total heap size on disk */ @@ -162,7 +161,7 @@ H5H_new (hdf5_file_t *f, H5H_type_t heap_type, size_t size_hint) *------------------------------------------------------------------------- */ static H5H_t * -H5H_load (hdf5_file_t *f, haddr_t addr, void *udata) +H5H_load (H5F_t *f, haddr_t addr, void *udata) { uint8 hdr[20], *p; H5H_t *heap=NULL; @@ -266,7 +265,7 @@ H5H_load (hdf5_file_t *f, haddr_t addr, void *udata) *------------------------------------------------------------------------- */ static herr_t -H5H_flush (hdf5_file_t *f, hbool_t destroy, haddr_t addr, H5H_t *heap) +H5H_flush (H5F_t *f, hbool_t destroy, haddr_t addr, H5H_t *heap) { uint8 *p = heap->chunk; H5H_free_t *fl = heap->freelist; @@ -369,7 +368,7 @@ H5H_flush (hdf5_file_t *f, hbool_t destroy, haddr_t addr, H5H_t *heap) * function to fail. * * If the heap address ADDR is the constant H5H_GLOBAL then - * the address comes from the hdf5_file_t global heap field. + * the address comes from the H5F_t global heap field. * * Return: Success: BUF (or the allocated buffer) * @@ -384,7 +383,7 @@ H5H_flush (hdf5_file_t *f, hbool_t destroy, haddr_t addr, H5H_t *heap) *------------------------------------------------------------------------- */ void * -H5H_read (hdf5_file_t *f, haddr_t addr, off_t offset, size_t size, void *buf) +H5H_read (H5F_t *f, haddr_t addr, off_t offset, size_t size, void *buf) { H5H_t *heap = NULL; @@ -392,7 +391,7 @@ H5H_read (hdf5_file_t *f, haddr_t addr, off_t offset, size_t size, void *buf) /* check arguments */ assert (f); - if (H5H_GLOBAL==addr) addr = f->smallobj_off; + if (H5H_GLOBAL==addr) addr = f->shared->smallobj_off; assert (addr>0); assert (offset>=0); @@ -423,7 +422,7 @@ H5H_read (hdf5_file_t *f, haddr_t addr, off_t offset, size_t size, void *buf) * may include an offset into the interior of the object. * * If the heap address ADDR is the constant H5H_GLOBAL then - * the address comes from the hdf5_file_t global heap field. + * the address comes from the H5F_t global heap field. * * Return: Success: Ptr to the object. The pointer points to * a chunk of memory large enough to hold the @@ -443,7 +442,7 @@ H5H_read (hdf5_file_t *f, haddr_t addr, off_t offset, size_t size, void *buf) *------------------------------------------------------------------------- */ const void * -H5H_peek (hdf5_file_t *f, haddr_t addr, off_t offset) +H5H_peek (H5F_t *f, haddr_t addr, off_t offset) { H5H_t *heap = NULL; const void *retval = NULL; @@ -452,7 +451,7 @@ H5H_peek (hdf5_file_t *f, haddr_t addr, off_t offset) /* check arguments */ assert (f); - if (H5H_GLOBAL==addr) addr = f->smallobj_off; + if (H5H_GLOBAL==addr) addr = f->shared->smallobj_off; assert (addr>0); assert (offset>=0); @@ -499,7 +498,7 @@ H5H_remove_free (H5H_t *heap, H5H_free_t *fl) * Purpose: Inserts a new item into the heap. * * If the heap address ADDR is the constant H5H_GLOBAL then - * the address comes from the hdf5_file_t global heap field. + * the address comes from the H5F_t global heap field. * * Return: Success: Offset of new item within heap. * @@ -514,7 +513,7 @@ H5H_remove_free (H5H_t *heap, H5H_free_t *fl) *------------------------------------------------------------------------- */ off_t -H5H_insert (hdf5_file_t *f, haddr_t addr, size_t buf_size, const void *buf) +H5H_insert (H5F_t *f, haddr_t addr, size_t buf_size, const void *buf) { H5H_t *heap=NULL; H5H_free_t *fl=NULL, *max_fl=NULL; @@ -528,7 +527,7 @@ H5H_insert (hdf5_file_t *f, haddr_t addr, size_t buf_size, const void *buf) /* check arguments */ assert (f); - if (H5H_GLOBAL==addr) addr = f->smallobj_off; + if (H5H_GLOBAL==addr) addr = f->shared->smallobj_off; assert (addr>0); assert (buf_size>0); assert (buf); @@ -658,7 +657,7 @@ H5H_insert (hdf5_file_t *f, haddr_t addr, size_t buf_size, const void *buf) * write for an object must be for the entire object. * * If the heap address ADDR is the constant H5H_GLOBAL then - * the address comes from the hdf5_file_t global heap field. + * the address comes from the H5F_t global heap field. * * Return: Success: SUCCEED * @@ -673,7 +672,7 @@ H5H_insert (hdf5_file_t *f, haddr_t addr, size_t buf_size, const void *buf) *------------------------------------------------------------------------- */ herr_t -H5H_write (hdf5_file_t *f, haddr_t addr, off_t offset, size_t size, +H5H_write (H5F_t *f, haddr_t addr, off_t offset, size_t size, const void *buf) { H5H_t *heap = NULL; @@ -682,7 +681,7 @@ H5H_write (hdf5_file_t *f, haddr_t addr, off_t offset, size_t size, /* check arguments */ assert (f); - if (H5H_GLOBAL==addr) addr = f->smallobj_off; + if (H5H_GLOBAL==addr) addr = f->shared->smallobj_off; assert (addr>0); assert (offset>=0); assert (buf); @@ -717,7 +716,7 @@ H5H_write (hdf5_file_t *f, haddr_t addr, off_t offset, size_t size, * one at the first offset past the removed portion. * * If the heap address ADDR is the constant H5H_GLOBAL then - * the address comes from the hdf5_file_t global heap field. + * the address comes from the H5F_t global heap field. * * Return: Success: SUCCEED * @@ -732,7 +731,7 @@ H5H_write (hdf5_file_t *f, haddr_t addr, off_t offset, size_t size, *------------------------------------------------------------------------- */ herr_t -H5H_remove (hdf5_file_t *f, haddr_t addr, off_t offset, size_t size) +H5H_remove (H5F_t *f, haddr_t addr, off_t offset, size_t size) { H5H_t *heap = NULL; H5H_free_t *fl = heap->freelist, *fl2 = NULL; @@ -744,7 +743,7 @@ H5H_remove (hdf5_file_t *f, haddr_t addr, off_t offset, size_t size) /* check arguments */ assert (f); - if (H5H_GLOBAL==addr) addr = f->smallobj_off; + if (H5H_GLOBAL==addr) addr = f->shared->smallobj_off; assert (addr>0); assert (offset>=0); assert (size>0); @@ -831,7 +830,7 @@ H5H_remove (hdf5_file_t *f, haddr_t addr, off_t offset, size_t size) * Purpose: Prints debugging information about a heap. * * If the heap address ADDR is the constant H5H_GLOBAL then - * the address comes from the hdf5_file_t global heap field. + * the address comes from the H5F_t global heap field. * * Return: Success: SUCCEED * @@ -846,8 +845,7 @@ H5H_remove (hdf5_file_t *f, haddr_t addr, off_t offset, size_t size) *------------------------------------------------------------------------- */ herr_t -H5H_debug (hdf5_file_t *f, haddr_t addr, FILE *stream, intn indent, - intn fwidth) +H5H_debug (H5F_t *f, haddr_t addr, FILE *stream, intn indent, intn fwidth) { H5H_t *h = NULL; int i, j, overlap; @@ -860,7 +858,7 @@ H5H_debug (hdf5_file_t *f, haddr_t addr, FILE *stream, intn indent, /* check arguments */ assert (f); - if (H5H_GLOBAL==addr) addr = f->smallobj_off; + if (H5H_GLOBAL==addr) addr = f->shared->smallobj_off; assert (addr>0); assert (stream); assert (indent>=0); diff --git a/src/H5Hprivate.h b/src/H5Hprivate.h index 99e8e8f..1fa194b 100644 --- a/src/H5Hprivate.h +++ b/src/H5Hprivate.h @@ -45,15 +45,14 @@ typedef enum H5H_type_t { /* * Library prototypes... */ -haddr_t H5H_new (hdf5_file_t *f, H5H_type_t type, size_t size_hint); -void *H5H_read (hdf5_file_t *f, haddr_t addr, off_t offset, size_t size, - void *buf); -const void *H5H_peek (hdf5_file_t *f, haddr_t addr, off_t offset); -off_t H5H_insert (hdf5_file_t *f, haddr_t addr, size_t size, const void *buf); -herr_t H5H_write (hdf5_file_t *f, haddr_t addr, off_t offset, size_t size, +haddr_t H5H_new (H5F_t *f, H5H_type_t type, size_t size_hint); +void *H5H_read (H5F_t *f, haddr_t addr, off_t offset, size_t size, void *buf); +const void *H5H_peek (H5F_t *f, haddr_t addr, off_t offset); +off_t H5H_insert (H5F_t *f, haddr_t addr, size_t size, const void *buf); +herr_t H5H_write (H5F_t *f, haddr_t addr, off_t offset, size_t size, const void *buf); -herr_t H5H_remove (hdf5_file_t *f, haddr_t addr, off_t offset, size_t size); -herr_t H5H_debug (hdf5_file_t *f, haddr_t addr, FILE *stream, intn indent, +herr_t H5H_remove (H5F_t *f, haddr_t addr, off_t offset, size_t size); +herr_t H5H_debug (H5F_t *f, haddr_t addr, FILE *stream, intn indent, intn fwidth); #endif diff --git a/src/H5MF.c b/src/H5MF.c index d45a0d0..b32e093 100644 --- a/src/H5MF.c +++ b/src/H5MF.c @@ -48,7 +48,7 @@ static intn interface_initialize_g = FALSE; *------------------------------------------------------------------------- */ haddr_t -H5MF_alloc (hdf5_file_t *f, size_t size) +H5MF_alloc (H5F_t *f, size_t size) { haddr_t addr; @@ -56,12 +56,12 @@ H5MF_alloc (hdf5_file_t *f, size_t size) /* check arguments */ assert (f); - assert (f->logical_len>0); + assert (f->shared->logical_len>0); assert (size>0); /* reserve space from the end of the file */ - addr = f->logical_len; - f->logical_len += size; + addr = f->shared->logical_len; + f->shared->logical_len += size; FUNC_LEAVE (addr); } @@ -88,7 +88,7 @@ H5MF_alloc (hdf5_file_t *f, size_t size) *------------------------------------------------------------------------- */ herr_t -H5MF_free (hdf5_file_t *f, haddr_t addr, size_t size) +H5MF_free (H5F_t *f, haddr_t addr, size_t size) { FUNC_ENTER (H5MF_free, NULL, FAIL); diff --git a/src/H5MFprivate.h b/src/H5MFprivate.h index 7537300..3bb7205 100644 --- a/src/H5MFprivate.h +++ b/src/H5MFprivate.h @@ -25,7 +25,7 @@ /* * Library prototypes... */ -haddr_t H5MF_alloc (hdf5_file_t *f, size_t size); -herr_t H5MF_free (hdf5_file_t *f, haddr_t addr, size_t size); +haddr_t H5MF_alloc (H5F_t *f, size_t size); +herr_t H5MF_free (H5F_t *f, haddr_t addr, size_t size); #endif diff --git a/src/H5O.c b/src/H5O.c index 96a9063..24edf84 100644 --- a/src/H5O.c +++ b/src/H5O.c @@ -25,20 +25,19 @@ #define PABLO_MASK H5O_mask /* PRIVATE PROTOTYPES */ -static herr_t H5O_flush (hdf5_file_t *f, hbool_t destroy, haddr_t addr, - H5O_t *oh); -static H5O_t *H5O_load (hdf5_file_t *f, haddr_t addr, void *_data); -static intn H5O_find_in_ohdr (hdf5_file_t *f, haddr_t addr, +static herr_t H5O_flush (H5F_t *f, hbool_t destroy, haddr_t addr, H5O_t *oh); +static H5O_t *H5O_load (H5F_t *f, haddr_t addr, void *_data); +static intn H5O_find_in_ohdr (H5F_t *f, haddr_t addr, const H5O_class_t **type_p, intn sequence); -static intn H5O_alloc (hdf5_file_t *f, H5O_t *oh, const H5O_class_t *type, +static intn H5O_alloc (H5F_t *f, H5O_t *oh, const H5O_class_t *type, size_t size); static intn H5O_alloc_extend_chunk (H5O_t *oh, intn chunkno, size_t size); -static intn H5O_alloc_new_chunk (hdf5_file_t *f, H5O_t *oh, size_t size); +static intn H5O_alloc_new_chunk (H5F_t *f, H5O_t *oh, size_t size); /* H5O inherits cache-like properties from H5AC */ static const H5AC_class_t H5AC_OHDR[1] = {{ - (void*(*)(hdf5_file_t*,haddr_t,void*))H5O_load, - (herr_t(*)(hdf5_file_t*,hbool_t,haddr_t,void*))H5O_flush, + (void*(*)(H5F_t*,haddr_t,void*))H5O_load, + (herr_t(*)(H5F_t*,hbool_t,haddr_t,void*))H5O_flush, }}; /* Is the interface initialized? */ @@ -86,7 +85,7 @@ static const H5O_class_t *const message_type_g[] = { *------------------------------------------------------------------------- */ haddr_t -H5O_new (hdf5_file_t *f, intn nlink, size_t size_hint) +H5O_new (H5F_t *f, intn nlink, size_t size_hint) { size_t size; /*total size of object header */ haddr_t addr = FAIL; /*address of object header */ @@ -166,7 +165,7 @@ H5O_new (hdf5_file_t *f, intn nlink, size_t size_hint) *------------------------------------------------------------------------- */ static H5O_t * -H5O_load (hdf5_file_t *f, haddr_t addr, void *_data) +H5O_load (H5F_t *f, haddr_t addr, void *_data) { H5O_t *oh = NULL; H5O_t *ret_value = (void*)1; /*kludge for HGOTO_ERROR*/ @@ -328,7 +327,7 @@ done: *------------------------------------------------------------------------- */ static herr_t -H5O_flush (hdf5_file_t *f, hbool_t destroy, haddr_t addr, H5O_t *oh) +H5O_flush (H5F_t *f, hbool_t destroy, haddr_t addr, H5O_t *oh) { uint8 buf[16], *p; int i; @@ -501,7 +500,7 @@ H5O_reset (const H5O_class_t *type, void *native) *------------------------------------------------------------------------- */ intn -H5O_link (hdf5_file_t *f, H5G_entry_t *ent, intn adjust) +H5O_link (H5F_t *f, H5G_entry_t *ent, intn adjust) { H5O_t *oh = NULL; haddr_t addr; @@ -560,7 +559,7 @@ H5O_link (hdf5_file_t *f, H5G_entry_t *ent, intn adjust) *------------------------------------------------------------------------- */ void * -H5O_read (hdf5_file_t *f, haddr_t addr, H5G_entry_t *ent, +H5O_read (H5F_t *f, haddr_t addr, H5G_entry_t *ent, const H5O_class_t *type, intn sequence, void *mesg) { H5O_t *oh = NULL; @@ -630,7 +629,7 @@ H5O_read (hdf5_file_t *f, haddr_t addr, H5G_entry_t *ent, *------------------------------------------------------------------------- */ static intn -H5O_find_in_ohdr (hdf5_file_t *f, haddr_t addr, const H5O_class_t **type_p, +H5O_find_in_ohdr (H5F_t *f, haddr_t addr, const H5O_class_t **type_p, intn sequence) { H5O_t *oh = NULL; @@ -697,8 +696,7 @@ H5O_find_in_ohdr (hdf5_file_t *f, haddr_t addr, const H5O_class_t **type_p, *------------------------------------------------------------------------- */ const void * -H5O_peek (hdf5_file_t *f, haddr_t addr, const H5O_class_t *type, - intn sequence) +H5O_peek (H5F_t *f, haddr_t addr, const H5O_class_t *type, intn sequence) { intn idx; H5O_t *oh = NULL; @@ -753,7 +751,7 @@ H5O_peek (hdf5_file_t *f, haddr_t addr, const H5O_class_t *type, *------------------------------------------------------------------------- */ intn -H5O_modify (hdf5_file_t *f, haddr_t addr, H5G_entry_t *ent, +H5O_modify (H5F_t *f, haddr_t addr, H5G_entry_t *ent, const H5O_class_t *type, intn overwrite, const void *mesg) { H5O_t *oh = NULL; @@ -852,7 +850,7 @@ H5O_modify (hdf5_file_t *f, haddr_t addr, H5G_entry_t *ent, *------------------------------------------------------------------------- */ herr_t -H5O_remove (hdf5_file_t *f, haddr_t addr, H5G_entry_t *ent, +H5O_remove (H5F_t *f, haddr_t addr, H5G_entry_t *ent, const H5O_class_t *type, intn sequence) { H5O_t *oh = NULL; @@ -1035,7 +1033,7 @@ H5O_alloc_extend_chunk (H5O_t *oh, intn chunkno, size_t size) *------------------------------------------------------------------------- */ static intn -H5O_alloc_new_chunk (hdf5_file_t *f, H5O_t *oh, size_t size) +H5O_alloc_new_chunk (H5F_t *f, H5O_t *oh, size_t size) { size_t cont_size; /*continuation message size */ intn found_null=(-1); /*best fit null message */ @@ -1196,7 +1194,7 @@ H5O_alloc_new_chunk (hdf5_file_t *f, H5O_t *oh, size_t size) *------------------------------------------------------------------------- */ static intn -H5O_alloc (hdf5_file_t *f, H5O_t *oh, const H5O_class_t *type, size_t size) +H5O_alloc (H5F_t *f, H5O_t *oh, const H5O_class_t *type, size_t size) { intn chunkno; intn idx; @@ -1295,8 +1293,7 @@ H5O_alloc (hdf5_file_t *f, H5O_t *oh, const H5O_class_t *type, size_t size) *------------------------------------------------------------------------- */ herr_t -H5O_debug (hdf5_file_t *f, haddr_t addr, FILE *stream, - intn indent, intn fwidth) +H5O_debug (H5F_t *f, haddr_t addr, FILE *stream, intn indent, intn fwidth) { H5O_t *oh = NULL; intn i, chunkno; diff --git a/src/H5Ocont.c b/src/H5Ocont.c index 2b01838..88f5a46 100644 --- a/src/H5Ocont.c +++ b/src/H5Ocont.c @@ -25,10 +25,10 @@ #define PABLO_MASK H5O_cont_mask /* PRIVATE PROTOTYPES */ -static void *H5O_cont_decode (hdf5_file_t *f, size_t raw_size, const uint8 *p); -static herr_t H5O_cont_encode (hdf5_file_t *f, size_t size, uint8 *p, +static void *H5O_cont_decode (H5F_t *f, size_t raw_size, const uint8 *p); +static herr_t H5O_cont_encode (H5F_t *f, size_t size, uint8 *p, const void *_mesg); -static herr_t H5O_cont_debug (hdf5_file_t *f, const void *_mesg, FILE *stream, +static herr_t H5O_cont_debug (H5F_t *f, const void *_mesg, FILE *stream, intn indent, intn fwidth); /* This message derives from H5O */ @@ -69,7 +69,7 @@ static intn interface_initialize_g = FALSE; *------------------------------------------------------------------------- */ static void * -H5O_cont_decode (hdf5_file_t *f, size_t raw_size, const uint8 *p) +H5O_cont_decode (H5F_t *f, size_t raw_size, const uint8 *p) { H5O_cont_t *cont = NULL; @@ -107,7 +107,7 @@ H5O_cont_decode (hdf5_file_t *f, size_t raw_size, const uint8 *p) *------------------------------------------------------------------------- */ static herr_t -H5O_cont_encode (hdf5_file_t *f, size_t size, uint8 *p, const void *_mesg) +H5O_cont_encode (H5F_t *f, size_t size, uint8 *p, const void *_mesg) { const H5O_cont_t *cont = (const H5O_cont_t *)_mesg; @@ -145,7 +145,7 @@ H5O_cont_encode (hdf5_file_t *f, size_t size, uint8 *p, const void *_mesg) *------------------------------------------------------------------------- */ static herr_t -H5O_cont_debug (hdf5_file_t *f, const void *_mesg, FILE *stream, +H5O_cont_debug (H5F_t *f, const void *_mesg, FILE *stream, intn indent, intn fwidth) { const H5O_cont_t *cont = (const H5O_cont_t *)_mesg; diff --git a/src/H5Oname.c b/src/H5Oname.c index 6224401..7d76fa5 100644 --- a/src/H5Oname.c +++ b/src/H5Oname.c @@ -22,13 +22,13 @@ #define PABLO_MASK H5O_name_mask /* PRIVATE PROTOTYPES */ -static void *H5O_name_decode (hdf5_file_t *f, size_t raw_size, const uint8 *p); -static herr_t H5O_name_encode (hdf5_file_t *f, size_t raw_size, uint8 *p, +static void *H5O_name_decode (H5F_t *f, size_t raw_size, const uint8 *p); +static herr_t H5O_name_encode (H5F_t *f, size_t raw_size, uint8 *p, const void *_mesg); static void *H5O_name_copy (const void *_mesg, void *_dest); -static size_t H5O_name_size (hdf5_file_t *f, const void *_mesg); +static size_t H5O_name_size (H5F_t *f, const void *_mesg); static herr_t H5O_name_reset (void *_mesg); -static herr_t H5O_name_debug (hdf5_file_t *f, const void *_mesg, FILE *stream, +static herr_t H5O_name_debug (H5F_t *f, const void *_mesg, FILE *stream, intn indent, intn fwidth); /* This message derives from H5O */ @@ -70,7 +70,7 @@ static hbool_t interface_initialize_g = FALSE; *------------------------------------------------------------------------- */ static void * -H5O_name_decode (hdf5_file_t *f, size_t raw_size, const uint8 *p) +H5O_name_decode (H5F_t *f, size_t raw_size, const uint8 *p) { H5O_name_t *mesg; char *s; @@ -109,7 +109,7 @@ H5O_name_decode (hdf5_file_t *f, size_t raw_size, const uint8 *p) *------------------------------------------------------------------------- */ static herr_t -H5O_name_encode (hdf5_file_t *f, size_t raw_size, uint8 *p, const void *_mesg) +H5O_name_encode (H5F_t *f, size_t raw_size, uint8 *p, const void *_mesg) { const H5O_name_t *mesg = (const H5O_name_t *)_mesg; size_t size; @@ -192,7 +192,7 @@ H5O_name_copy (const void *_mesg, void *_dest) *------------------------------------------------------------------------- */ static size_t -H5O_name_size (hdf5_file_t *f, const void *_mesg) +H5O_name_size (H5F_t *f, const void *_mesg) { const H5O_name_t *mesg = (const H5O_name_t *)_mesg; size_t size; @@ -261,7 +261,7 @@ H5O_name_reset (void *_mesg) *------------------------------------------------------------------------- */ static herr_t -H5O_name_debug (hdf5_file_t *f, const void *_mesg, FILE *stream, +H5O_name_debug (H5F_t *f, const void *_mesg, FILE *stream, intn indent, intn fwidth) { const H5O_name_t *mesg = (const H5O_name_t *)_mesg; diff --git a/src/H5Oprivate.h b/src/H5Oprivate.h index d5666eb..94dd764 100644 --- a/src/H5Oprivate.h +++ b/src/H5Oprivate.h @@ -48,14 +48,14 @@ typedef struct H5O_class_t { const char *name; /*message name for debugging */ size_t native_size; /*size of native message */ H5G_type_t cache_type; /*type field in symbol table */ - void *(*decode)(hdf5_file_t*,size_t,const uint8*); - herr_t (*encode)(hdf5_file_t*,size_t,uint8*,const void*); + void *(*decode)(H5F_t*,size_t,const uint8*); + herr_t (*encode)(H5F_t*,size_t,uint8*,const void*); void *(*fast)(const H5G_cache_t*, void*);/*get from of entry */ hbool_t (*cache)(H5G_type_t*, H5G_cache_t*,const void*); /*into entry*/ void *(*copy)(const void*,void*); /*copy native value */ - size_t (*raw_size)(hdf5_file_t*,const void*); /*sizeof raw val */ + size_t (*raw_size)(H5F_t*,const void*); /*sizeof raw val */ herr_t (*reset)(void*); /*free nested data structures */ - herr_t (*debug)(hdf5_file_t*,const void*, FILE*, intn, intn); + herr_t (*debug)(H5F_t*,const void*, FILE*, intn, intn); } H5O_class_t; typedef struct H5O_mesg_t { @@ -157,18 +157,18 @@ typedef struct H5O_stab_t { -haddr_t H5O_new (hdf5_file_t *f, intn nlink, size_t size_hint); -intn H5O_link (hdf5_file_t *f, H5G_entry_t *ent, intn adjust); -void *H5O_read (hdf5_file_t *f, haddr_t addr, H5G_entry_t *ent, +haddr_t H5O_new (H5F_t *f, intn nlink, size_t size_hint); +intn H5O_link (H5F_t *f, H5G_entry_t *ent, intn adjust); +void *H5O_read (H5F_t *f, haddr_t addr, H5G_entry_t *ent, const H5O_class_t *type, intn sequence, void *mesg); -const void *H5O_peek (hdf5_file_t *f, haddr_t addr, const H5O_class_t *type, +const void *H5O_peek (H5F_t *f, haddr_t addr, const H5O_class_t *type, intn sequence); -intn H5O_modify (hdf5_file_t *f, haddr_t addr, H5G_entry_t *ent, +intn H5O_modify (H5F_t *f, haddr_t addr, H5G_entry_t *ent, const H5O_class_t *type, intn overwrite, const void *mesg); -herr_t H5O_remove (hdf5_file_t *f, haddr_t addr, H5G_entry_t *ent, +herr_t H5O_remove (H5F_t *f, haddr_t addr, H5G_entry_t *ent, const H5O_class_t *type, intn sequence); herr_t H5O_reset (const H5O_class_t *type, void *native); -herr_t H5O_debug (hdf5_file_t *f, haddr_t addr, FILE *stream, +herr_t H5O_debug (H5F_t *f, haddr_t addr, FILE *stream, intn indent, intn fwidth); #endif diff --git a/src/H5Osdim.c b/src/H5Osdim.c index 312249b..ffd9743 100644 --- a/src/H5Osdim.c +++ b/src/H5Osdim.c @@ -38,16 +38,16 @@ static char RcsId[] = "@(#)$Revision$"; #define PABLO_MASK H5O_sim_dim_mask /* PRIVATE PROTOTYPES */ -static void *H5O_sim_dim_decode (hdf5_file_t *f, size_t raw_size, const uint8 *p); -static herr_t H5O_sim_dim_encode (hdf5_file_t *f, size_t size, uint8 *p, +static void *H5O_sim_dim_decode (H5F_t *f, size_t raw_size, const uint8 *p); +static herr_t H5O_sim_dim_encode (H5F_t *f, size_t size, uint8 *p, const void *_mesg); static void *H5O_sim_dim_fast (const H5G_cache_t *cache, void *_mesg); static hbool_t H5O_sim_dim_cache (H5G_type_t *cache_type, H5G_cache_t *cache, const void *_mesg); static void *H5O_sim_dim_copy (const void *_mesg, void *_dest); -static size_t H5O_sim_dim_size (hdf5_file_t *f, const void *_mesg); -static herr_t H5O_sim_dim_debug (hdf5_file_t *f, const void *_mesg, - FILE *stream, intn indent, intn fwidth); +static size_t H5O_sim_dim_size (H5F_t *f, const void *_mesg); +static herr_t H5O_sim_dim_debug (H5F_t *f, const void *_mesg, + FILE *stream, intn indent, intn fwidth); /* This message derives from H5O */ const H5O_class_t H5O_SIM_DIM[1] = {{ @@ -76,7 +76,7 @@ static hbool_t interface_initialize_g = FALSE; struct with the decoded information USAGE void *H5O_sim_dim_decode(f, raw_size, p) - hdf5_file_t *f; IN: pointer to the HDF5 file struct + H5F_t *f; IN: pointer to the HDF5 file struct size_t raw_size; IN: size of the raw information buffer const uint8 *p; IN: the raw information buffer RETURNS @@ -87,7 +87,7 @@ static hbool_t interface_initialize_g = FALSE; within this function using malloc() and is returned to the caller. --------------------------------------------------------------------------*/ static void * -H5O_sim_dim_decode (hdf5_file_t *f, size_t raw_size, const uint8 *p) +H5O_sim_dim_decode (H5F_t *f, size_t raw_size, const uint8 *p) { H5O_sim_dim_t *sdim=NULL; /* New simple dimensionality structure */ uintn u; /* local counting variable */ @@ -144,7 +144,7 @@ done: Encode a simple dimensionality message USAGE herr_t H5O_sim_dim_encode(f, raw_size, p, mesg) - hdf5_file_t *f; IN: pointer to the HDF5 file struct + H5F_t *f; IN: pointer to the HDF5 file struct size_t raw_size; IN: size of the raw information buffer const uint8 *p; IN: the raw information buffer const void *mesg; IN: Pointer to the simple dimensionality struct @@ -155,7 +155,7 @@ done: dimensionality message in the "raw" disk form. --------------------------------------------------------------------------*/ static herr_t -H5O_sim_dim_encode (hdf5_file_t *f, size_t raw_size, uint8 *p, const void *mesg) +H5O_sim_dim_encode (H5F_t *f, size_t raw_size, uint8 *p, const void *mesg) { const H5O_sim_dim_t *sdim = (const H5O_sim_dim_t *)mesg; uintn u; /* Local counting variable */ @@ -361,7 +361,7 @@ H5O_sim_dim_copy (const void *mesg, void *dest) Return the raw message size in bytes USAGE void *H5O_sim_dim_copy(f, mesg) - hdf5_file_t *f; IN: pointer to the HDF5 file struct + H5F_t *f; IN: pointer to the HDF5 file struct const void *mesg; IN: Pointer to the source simple dimensionality struct RETURNS Size of message on success, FAIL on failure @@ -371,7 +371,7 @@ H5O_sim_dim_copy (const void *mesg, void *dest) portion of the message). It doesn't take into account alignment. --------------------------------------------------------------------------*/ static size_t -H5O_sim_dim_size (hdf5_file_t *f, const void *mesg) +H5O_sim_dim_size (H5F_t *f, const void *mesg) { const H5O_sim_dim_t *sdim = (const H5O_sim_dim_t *)mesg; size_t ret_value=8; /* all dimensionality messages are at least 8 bytes long (rank and flags) */ @@ -392,7 +392,7 @@ H5O_sim_dim_size (hdf5_file_t *f, const void *mesg) Prints debugging information for a simple dimensionality message USAGE void *H5O_sim_dim_debug(f, mesg, stream, indent, fwidth) - hdf5_file_t *f; IN: pointer to the HDF5 file struct + H5F_t *f; IN: pointer to the HDF5 file struct const void *mesg; IN: Pointer to the source simple dimensionality struct FILE *stream; IN: Pointer to the stream for output data intn indent; IN: Amount to indent information by @@ -404,7 +404,7 @@ H5O_sim_dim_size (hdf5_file_t *f, const void *mesg) parameter. --------------------------------------------------------------------------*/ static herr_t -H5O_sim_dim_debug (hdf5_file_t *f, const void *mesg, FILE *stream, +H5O_sim_dim_debug (H5F_t *f, const void *mesg, FILE *stream, intn indent, intn fwidth) { const H5O_sim_dim_t *sdim = (const H5O_sim_dim_t *)mesg; diff --git a/src/H5Osdtyp.c b/src/H5Osdtyp.c index 08fbba4..367af17 100644 --- a/src/H5Osdtyp.c +++ b/src/H5Osdtyp.c @@ -38,15 +38,15 @@ static char RcsId[] = "@(#)$Revision$"; #define PABLO_MASK H5O_sim_dtype_mask /* PRIVATE PROTOTYPES */ -static void *H5O_sim_dtype_decode (hdf5_file_t *f, size_t raw_size, const uint8 *p); -static herr_t H5O_sim_dtype_encode (hdf5_file_t *f, size_t size, uint8 *p, +static void *H5O_sim_dtype_decode (H5F_t *f, size_t raw_size, const uint8 *p); +static herr_t H5O_sim_dtype_encode (H5F_t *f, size_t size, uint8 *p, const void *_mesg); static void *H5O_sim_dtype_fast (const H5G_cache_t *cache, void *_mesg); static hbool_t H5O_sim_dtype_cache (H5G_type_t *cache_type, H5G_cache_t *cache, const void *_mesg); static void *H5O_sim_dtype_copy (const void *_mesg, void *_dest); -static size_t H5O_sim_dtype_size (hdf5_file_t *f, const void *_mesg); -static herr_t H5O_sim_dtype_debug (hdf5_file_t *f, const void *_mesg, +static size_t H5O_sim_dtype_size (H5F_t *f, const void *_mesg); +static herr_t H5O_sim_dtype_debug (H5F_t *f, const void *_mesg, FILE *stream, intn indent, intn fwidth); /* This message derives from H5O */ @@ -76,7 +76,7 @@ static hbool_t interface_initialize_g = FALSE; with the decoded information USAGE void *H5O_sim_dtype_decode(f, raw_size, p) - hdf5_file_t *f; IN: pointer to the HDF5 file struct + H5F_t *f; IN: pointer to the HDF5 file struct size_t raw_size; IN: size of the raw information buffer const uint8 *p; IN: the raw information buffer RETURNS @@ -87,7 +87,7 @@ static hbool_t interface_initialize_g = FALSE; function using malloc() and is returned to the caller. --------------------------------------------------------------------------*/ static void * -H5O_sim_dtype_decode (hdf5_file_t *f, size_t raw_size, const uint8 *p) +H5O_sim_dtype_decode (H5F_t *f, size_t raw_size, const uint8 *p) { H5O_sim_dtype_t *sdtype; @@ -117,7 +117,7 @@ H5O_sim_dtype_decode (hdf5_file_t *f, size_t raw_size, const uint8 *p) Encode a simple datatype message USAGE herr_t H5O_sim_dtype_encode(f, raw_size, p, mesg) - hdf5_file_t *f; IN: pointer to the HDF5 file struct + H5F_t *f; IN: pointer to the HDF5 file struct size_t raw_size; IN: size of the raw information buffer const uint8 *p; IN: the raw information buffer const void *mesg; IN: Pointer to the simple datatype struct @@ -128,7 +128,7 @@ H5O_sim_dtype_decode (hdf5_file_t *f, size_t raw_size, const uint8 *p) message in the "raw" disk form. --------------------------------------------------------------------------*/ static herr_t -H5O_sim_dtype_encode (hdf5_file_t *f, size_t raw_size, uint8 *p, const void *mesg) +H5O_sim_dtype_encode (H5F_t *f, size_t raw_size, uint8 *p, const void *mesg) { const H5O_sim_dtype_t *sdtype = (const H5O_sim_dtype_t *)mesg; @@ -292,7 +292,7 @@ H5O_sim_dtype_copy (const void *mesg, void *dest) Return the raw message size in bytes USAGE void *H5O_sim_dtype_copy(f, mesg) - hdf5_file_t *f; IN: pointer to the HDF5 file struct + H5F_t *f; IN: pointer to the HDF5 file struct const void *mesg; IN: Pointer to the source simple datatype struct RETURNS Size of message on success, FAIL on failure @@ -302,7 +302,7 @@ H5O_sim_dtype_copy (const void *mesg, void *dest) portion of the message). It doesn't take into account alignment. --------------------------------------------------------------------------*/ static size_t -H5O_sim_dtype_size (hdf5_file_t *f, const void *mesg) +H5O_sim_dtype_size (H5F_t *f, const void *mesg) { FUNC_ENTER (H5O_sim_dtype_size, NULL, FAIL); FUNC_LEAVE (4); @@ -315,7 +315,7 @@ H5O_sim_dtype_size (hdf5_file_t *f, const void *mesg) Prints debugging information for a simple datatype message USAGE void *H5O_sim_dtype_debug(f, mesg, stream, indent, fwidth) - hdf5_file_t *f; IN: pointer to the HDF5 file struct + H5F_t *f; IN: pointer to the HDF5 file struct const void *mesg; IN: Pointer to the source simple datatype struct FILE *stream; IN: Pointer to the stream for output data intn indent; IN: Amount to indent information by @@ -327,7 +327,7 @@ H5O_sim_dtype_size (hdf5_file_t *f, const void *mesg) parameter. --------------------------------------------------------------------------*/ static herr_t -H5O_sim_dtype_debug (hdf5_file_t *f, const void *mesg, FILE *stream, +H5O_sim_dtype_debug (H5F_t *f, const void *mesg, FILE *stream, intn indent, intn fwidth) { const H5O_sim_dtype_t *sdtype = (const H5O_sim_dtype_t *)mesg; diff --git a/src/H5Ostab.c b/src/H5Ostab.c index c4bb67c..cd8b708 100644 --- a/src/H5Ostab.c +++ b/src/H5Ostab.c @@ -23,15 +23,15 @@ #define PABLO_MASK H5O_stab_mask /* PRIVATE PROTOTYPES */ -static void *H5O_stab_decode (hdf5_file_t *f, size_t raw_size, const uint8 *p); -static herr_t H5O_stab_encode (hdf5_file_t *f, size_t size, uint8 *p, +static void *H5O_stab_decode (H5F_t *f, size_t raw_size, const uint8 *p); +static herr_t H5O_stab_encode (H5F_t *f, size_t size, uint8 *p, const void *_mesg); static void *H5O_stab_fast (const H5G_cache_t *cache, void *_mesg); static hbool_t H5O_stab_cache (H5G_type_t *cache_type, H5G_cache_t *cache, const void *_mesg); static void *H5O_stab_copy (const void *_mesg, void *_dest); -static size_t H5O_stab_size (hdf5_file_t *f, const void *_mesg); -static herr_t H5O_stab_debug (hdf5_file_t *f, const void *_mesg, +static size_t H5O_stab_size (H5F_t *f, const void *_mesg); +static herr_t H5O_stab_debug (H5F_t *f, const void *_mesg, FILE *stream, intn indent, intn fwidth); /* This message derives from H5O */ @@ -73,7 +73,7 @@ static hbool_t interface_initialize_g = FALSE; *------------------------------------------------------------------------- */ static void * -H5O_stab_decode (hdf5_file_t *f, size_t raw_size, const uint8 *p) +H5O_stab_decode (H5F_t *f, size_t raw_size, const uint8 *p) { H5O_stab_t *stab; @@ -111,7 +111,7 @@ H5O_stab_decode (hdf5_file_t *f, size_t raw_size, const uint8 *p) *------------------------------------------------------------------------- */ static herr_t -H5O_stab_encode (hdf5_file_t *f, size_t raw_size, uint8 *p, const void *_mesg) +H5O_stab_encode (H5F_t *f, size_t raw_size, uint8 *p, const void *_mesg) { const H5O_stab_t *stab = (const H5O_stab_t *)_mesg; @@ -279,7 +279,7 @@ H5O_stab_copy (const void *_mesg, void *_dest) *------------------------------------------------------------------------- */ static size_t -H5O_stab_size (hdf5_file_t *f, const void *_mesg) +H5O_stab_size (H5F_t *f, const void *_mesg) { FUNC_ENTER (H5O_stab_size, NULL, FAIL); FUNC_LEAVE (2 * H5F_SIZEOF_OFFSET(f)); @@ -304,8 +304,8 @@ H5O_stab_size (hdf5_file_t *f, const void *_mesg) *------------------------------------------------------------------------- */ static herr_t -H5O_stab_debug (hdf5_file_t *f, const void *_mesg, FILE *stream, - intn indent, intn fwidth) +H5O_stab_debug (H5F_t *f, const void *_mesg, FILE *stream, intn indent, + intn fwidth) { const H5O_stab_t *stab = (const H5O_stab_t *)_mesg; diff --git a/src/H5Ostdst.c b/src/H5Ostdst.c index 0186b44..48c8c97 100644 --- a/src/H5Ostdst.c +++ b/src/H5Ostdst.c @@ -38,12 +38,12 @@ static char RcsId[] = "@(#)$Revision$"; #define PABLO_MASK H5O_std_store_mask /* PRIVATE PROTOTYPES */ -static void *H5O_std_store_decode (hdf5_file_t *f, size_t raw_size, const uint8 *p); -static herr_t H5O_std_store_encode (hdf5_file_t *f, size_t size, uint8 *p, +static void *H5O_std_store_decode (H5F_t *f, size_t raw_size, const uint8 *p); +static herr_t H5O_std_store_encode (H5F_t *f, size_t size, uint8 *p, const void *_mesg); static void *H5O_std_store_copy (const void *_mesg, void *_dest); -static size_t H5O_std_store_size (hdf5_file_t *f, const void *_mesg); -static herr_t H5O_std_store_debug (hdf5_file_t *f, const void *_mesg, +static size_t H5O_std_store_size (H5F_t *f, const void *_mesg); +static herr_t H5O_std_store_debug (H5F_t *f, const void *_mesg, FILE *stream, intn indent, intn fwidth); /* This message derives from H5O */ @@ -73,7 +73,7 @@ static hbool_t interface_initialize_g = FALSE; struct with the decoded information USAGE void *H5O_std_store_decode(f, raw_size, p) - hdf5_file_t *f; IN: pointer to the HDF5 file struct + H5F_t *f; IN: pointer to the HDF5 file struct size_t raw_size; IN: size of the raw information buffer const uint8 *p; IN: the raw information buffer RETURNS @@ -84,7 +84,7 @@ static hbool_t interface_initialize_g = FALSE; within this function using malloc() and is returned to the caller. --------------------------------------------------------------------------*/ static void * -H5O_std_store_decode (hdf5_file_t *f, size_t raw_size, const uint8 *p) +H5O_std_store_decode (H5F_t *f, size_t raw_size, const uint8 *p) { H5O_std_store_t *store=NULL; /* New standard storage structure */ @@ -122,7 +122,7 @@ done: Encode a standard data storage message USAGE herr_t H5O_std_store_encode(f, raw_size, p, mesg) - hdf5_file_t *f; IN: pointer to the HDF5 file struct + H5F_t *f; IN: pointer to the HDF5 file struct size_t raw_size; IN: size of the raw information buffer const uint8 *p; IN: the raw information buffer const void *mesg; IN: Pointer to the standard storage struct @@ -133,7 +133,7 @@ done: storage message in the "raw" disk form. --------------------------------------------------------------------------*/ static herr_t -H5O_std_store_encode (hdf5_file_t *f, size_t raw_size, uint8 *p, const void *mesg) +H5O_std_store_encode (H5F_t *f, size_t raw_size, uint8 *p, const void *mesg) { const H5O_std_store_t *store = (const H5O_std_store_t *)mesg; @@ -193,7 +193,7 @@ H5O_std_store_copy (const void *mesg, void *dest) Return the raw message size in bytes USAGE void *H5O_std_store_copy(f, mesg) - hdf5_file_t *f; IN: pointer to the HDF5 file struct + H5F_t *f; IN: pointer to the HDF5 file struct const void *mesg; IN: Pointer to the source standard storage struct RETURNS Size of message on success, FAIL on failure @@ -203,7 +203,7 @@ H5O_std_store_copy (const void *mesg, void *dest) portion of the message). It doesn't take into account alignment. --------------------------------------------------------------------------*/ static size_t -H5O_std_store_size (hdf5_file_t *f, const void *mesg) +H5O_std_store_size (H5F_t *f, const void *mesg) { size_t ret_value; @@ -222,7 +222,7 @@ H5O_std_store_size (hdf5_file_t *f, const void *mesg) Prints debugging information for a standard storage message USAGE void *H5O_std_store_debug(f, mesg, stream, indent, fwidth) - hdf5_file_t *f; IN: pointer to the HDF5 file struct + H5F_t *f; IN: pointer to the HDF5 file struct const void *mesg; IN: Pointer to the source standard storage struct FILE *stream; IN: Pointer to the stream for output data intn indent; IN: Amount to indent information by @@ -234,7 +234,7 @@ H5O_std_store_size (hdf5_file_t *f, const void *mesg) parameter. --------------------------------------------------------------------------*/ static herr_t -H5O_std_store_debug (hdf5_file_t *f, const void *mesg, FILE *stream, +H5O_std_store_debug (H5F_t *f, const void *mesg, FILE *stream, intn indent, intn fwidth) { const H5O_std_store_t *store = (const H5O_std_store_t *)mesg; diff --git a/src/debug.c b/src/debug.c index 48e423c..016eaf9 100644 --- a/src/debug.c +++ b/src/debug.c @@ -46,7 +46,7 @@ int main (int argc, char *argv[]) { hid_t fid; - hdf5_file_t *f; + H5F_t *f; haddr_t addr = 0; uint8 sig[16]; intn i; @@ -72,7 +72,7 @@ main (int argc, char *argv[]) HDexit (1); } if (NULL==(f=H5Aatom_object (fid))) { - fprintf (stderr, "cannot obtain hdf5_file_t pointer\n"); + fprintf (stderr, "cannot obtain H5F_t pointer\n"); HDexit (2); } diff --git a/test/tfile.c b/test/tfile.c index 5d32925..d7ba2d6 100644 --- a/test/tfile.c +++ b/test/tfile.c @@ -249,9 +249,9 @@ static void test_file_open(void) /* Output message about test being performed */ MESSAGE(5, ("Testing Low-Level File Opening I/O\n")); - /* Open second file */ + /* Open first file */ fid1=H5Fopen(FILE2,H5ACC_WRITE,0); - CHECK(fid1,FAIL,"H5Fooen"); + CHECK(fid1,FAIL,"H5Fopen"); /* Get the file-creation template */ tmpl1=H5Fget_create_template(fid1); diff --git a/test/theap.c b/test/theap.c index fd2467b..1dc38e1 100644 --- a/test/theap.c +++ b/test/theap.c @@ -44,7 +44,7 @@ test_heap (void) { int i, j; hid_t fid; - hdf5_file_t *f; + H5F_t *f; off_t heap; char buf[NOBJS+8]; const char *s; diff --git a/test/tohdr.c b/test/tohdr.c index 890b307..c8da399 100644 --- a/test/tohdr.c +++ b/test/tohdr.c @@ -48,7 +48,7 @@ void test_ohdr (void) { hid_t fid; - hdf5_file_t *f; + H5F_t *f; haddr_t oh; H5O_stab_t stab, ro; herr_t status; diff --git a/test/tstab.c b/test/tstab.c index 945f0cf..652029f 100644 --- a/test/tstab.c +++ b/test/tstab.c @@ -50,7 +50,7 @@ static void test_1 (void) { hid_t fid; - hdf5_file_t *f; + H5F_t *f; H5G_entry_t *obj1=NULL, *obj2=NULL; H5G_entry_t ent1, dir_ent; herr_t status; @@ -91,7 +91,7 @@ test_1 (void) /* is it really the root symbol? */ VERIFY (dir_ent.header, 0, "H5G_insert"); - VERIFY (obj1->header, f->root_sym->header, "H5G_insert"); + VERIFY (obj1->header, f->shared->root_sym->header, "H5G_insert"); @@ -158,7 +158,7 @@ test_1 (void) /* is it really the root symbol? */ VERIFY (dir_ent.header, 0, "H5G_insert"); - VERIFY (obj1->header, f->root_sym->header, "H5G_insert"); + VERIFY (obj1->header, f->shared->root_sym->header, "H5G_insert"); /* now as `/foo' */ HDmemset (&dir_ent, 0, sizeof(H5G_entry_t)); @@ -170,7 +170,7 @@ test_1 (void) /* is it really the root symbol? */ VERIFY (dir_ent.header, 0, "H5G_insert"); - VERIFY (obj1->header, f->root_sym->header, "H5G_insert"); + VERIFY (obj1->header, f->shared->root_sym->header, "H5G_insert"); @@ -224,11 +224,9 @@ static void test_2 (void) { hid_t fid; - hdf5_file_t *f; - H5G_entry_t cwd, sub; + H5F_t *f; H5G_entry_t *obj1=NULL; int i; - haddr_t addr; char name[256]; herr_t status; int nsyms = 5000; -- cgit v0.12