summaryrefslogtreecommitdiffstats
path: root/src/H5F.c
diff options
context:
space:
mode:
authorJames Laird <jlaird@hdfgroup.org>2004-09-28 19:04:19 (GMT)
committerJames Laird <jlaird@hdfgroup.org>2004-09-28 19:04:19 (GMT)
commit5c0011a71384223791d18028968382db43f08a6f (patch)
tree113cc1dd6c8d0ecd1996ddb8f0e9f7693f470e95 /src/H5F.c
parenta841ea35292de8097b429f98af48b29f21c97893 (diff)
downloadhdf5-5c0011a71384223791d18028968382db43f08a6f.zip
hdf5-5c0011a71384223791d18028968382db43f08a6f.tar.gz
hdf5-5c0011a71384223791d18028968382db43f08a6f.tar.bz2
[svn-r9329]
Purpose: Feature Description: Datatypes and groups now use H5FO "file object" code that was previously only used by datasets. These objects will hold a file open if the file is closed but they have not yet been closed. If these objects are unlinked then relinked, they will not be destroyed. If they are opened twice (even by two different names), both IDs will "see" changes made to the object using the other ID. When an object is opened using two different names (e.g., if a dataset was opened under one name, then mounted and opened under its new name), calling H5Iget_name() on a given hid_t will return the name used to open that hid_t, not the current name of the object (this is a feature, and a change from the previous behavior of datasets). Solution: Used H5FO code that was already in place for datasets. Broke H5D_t's, H5T_t's, and H5G_t's into a "shared" struct and a private struct. The shared structs (H5D_shared_t, etc.) hold the object's information and are used by all IDs that point to a given object in the file. The private structs are pointed to by the hid_t and contain the object's group entry information (including its name) and a pointer to the shared struct for that object. This changed the naming of structs throughout the library (e.g., datatype->size is now datatype->shared->size). I added an updated H5Tinit.c to windows.zip. Platforms tested: Visual Studio 7, sleipnir, arabica, verbena Misc. update:
Diffstat (limited to 'src/H5F.c')
-rw-r--r--src/H5F.c58
1 files changed, 32 insertions, 26 deletions
diff --git a/src/H5F.c b/src/H5F.c
index 8ee1e94..9eee843 100644
--- a/src/H5F.c
+++ b/src/H5F.c
@@ -1564,7 +1564,7 @@ H5F_dest(H5F_t *f, hid_t dxpl_id)
} /* end if */
/* Free the memory for the root group */
- H5FL_FREE(H5G_t,f->shared->root_grp);
+ H5G_free(f->shared->root_grp);
f->shared->root_grp=NULL;
}
if (H5AC_dest(f, dxpl_id)) {
@@ -3401,6 +3401,7 @@ H5F_mount(H5G_entry_t *loc, const char *name, H5F_t *child,
unsigned lt, rt, md; /*binary search indices */
int cmp; /*binary search comparison value*/
H5G_entry_t *ent = NULL; /*temporary symbol table entry */
+ H5G_entry_t mp_open_ent; /* entry of moint point to be opened */
H5RS_str_t *name_r; /* Ref-counted version of name */
herr_t ret_value = SUCCEED; /*return value */
@@ -3416,15 +3417,17 @@ H5F_mount(H5G_entry_t *loc, const char *name, H5F_t *child,
* that the mount wouldn't introduce a cycle in the mount tree.
*/
if (child->mtab.parent)
- HGOTO_ERROR(H5E_FILE, H5E_MOUNT, FAIL, "file is already mounted")
- if (NULL==(mount_point=H5G_open(loc, name, dxpl_id)))
- HGOTO_ERROR(H5E_FILE, H5E_MOUNT, FAIL, "mount point not found")
+ HGOTO_ERROR(H5E_FILE, H5E_MOUNT, FAIL, "file is already mounted")
+ if (H5G_find(loc, name, NULL, &mp_open_ent/*out*/, H5AC_dxpl_id) < 0)
+ HGOTO_ERROR(H5E_SYM, H5E_NOTFOUND, FAIL, "group not found");
+ if (NULL==(mount_point=H5G_open(&mp_open_ent, dxpl_id)))
+ HGOTO_ERROR(H5E_FILE, H5E_MOUNT, FAIL, "mount point not found")
parent = H5G_fileof(mount_point);
mp_ent = H5G_entof(mount_point);
for (ancestor=parent; ancestor; ancestor=ancestor->mtab.parent) {
- if (ancestor==child)
- HGOTO_ERROR(H5E_FILE, H5E_MOUNT, FAIL, "mount would introduce a cycle")
+ if (ancestor==child)
+ HGOTO_ERROR(H5E_FILE, H5E_MOUNT, FAIL, "mount would introduce a cycle")
}
/*
@@ -3436,29 +3439,29 @@ H5F_mount(H5G_entry_t *loc, const char *name, H5F_t *child,
rt=parent->mtab.nmounts;
cmp = -1;
while (lt<rt && cmp) {
- md = (lt+rt)/2;
- ent = H5G_entof(parent->mtab.child[md].group);
- cmp = H5F_addr_cmp(mp_ent->header, ent->header);
- if (cmp<0) {
- rt = md;
- } else if (cmp>0) {
- lt = md+1;
- }
+ md = (lt+rt)/2;
+ ent = H5G_entof(parent->mtab.child[md].group);
+ cmp = H5F_addr_cmp(mp_ent->header, ent->header);
+ if (cmp<0) {
+ rt = md;
+ } else if (cmp>0) {
+ lt = md+1;
+ }
}
if (cmp>0)
md++;
if (!cmp)
- HGOTO_ERROR(H5E_FILE, H5E_MOUNT, FAIL, "mount point is already in use")
+ HGOTO_ERROR(H5E_FILE, H5E_MOUNT, FAIL, "mount point is already in use")
/* Make room in the table */
if (parent->mtab.nmounts>=parent->mtab.nalloc) {
- unsigned n = MAX(16, 2*parent->mtab.nalloc);
- H5F_mount_t *x = H5MM_realloc(parent->mtab.child,
+ unsigned n = MAX(16, 2*parent->mtab.nalloc);
+ H5F_mount_t *x = H5MM_realloc(parent->mtab.child,
n*sizeof(parent->mtab.child[0]));
- if (!x)
- HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, FAIL, "memory allocation failed for mount table")
- parent->mtab.child = x;
- parent->mtab.nalloc = n;
+ if (!x)
+ HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, FAIL, "memory allocation failed for mount table")
+ parent->mtab.child = x;
+ parent->mtab.nalloc = n;
}
/* Insert into table */
@@ -3475,9 +3478,9 @@ H5F_mount(H5G_entry_t *loc, const char *name, H5F_t *child,
name_r=H5RS_wrap(name);
assert(name_r);
if (H5G_replace_name( H5G_UNKNOWN, loc, name_r, NULL, NULL, NULL, OP_MOUNT )<0)
- HGOTO_ERROR(H5E_FILE, H5E_MOUNT, FAIL, "unable to replace name")
+ HGOTO_ERROR(H5E_FILE, H5E_MOUNT, FAIL, "unable to replace name")
if(H5RS_decr(name_r)<0)
- HGOTO_ERROR(H5E_FILE, H5E_CANTDEC, FAIL, "unable to decrement name string")
+ HGOTO_ERROR(H5E_FILE, H5E_CANTDEC, FAIL, "unable to decrement name string")
done:
if (ret_value<0 && mount_point)
@@ -3522,6 +3525,7 @@ H5F_unmount(H5G_entry_t *loc, const char *name, hid_t dxpl_id)
H5F_t *child = NULL; /*mounted file */
H5F_t *parent = NULL; /*file where mounted */
H5G_entry_t *ent = NULL; /*temporary symbol table entry */
+ H5G_entry_t mnt_open_ent; /* entry used to open mount point*/
herr_t ret_value = FAIL; /*return value */
unsigned i; /*coutners */
unsigned lt, rt, md=0; /*binary search indices */
@@ -3537,14 +3541,16 @@ H5F_unmount(H5G_entry_t *loc, const char *name, hid_t dxpl_id)
* If we get the root group and the file has a parent in the mount tree,
* then we must have found the mount point.
*/
- if (NULL==(mounted=H5G_open(loc, name, dxpl_id)))
- HGOTO_ERROR(H5E_FILE, H5E_MOUNT, FAIL, "mount point not found")
+ if (H5G_find(loc, name, NULL, &mnt_open_ent/*out*/, H5AC_dxpl_id) < 0)
+ HGOTO_ERROR(H5E_SYM, H5E_NOTFOUND, FAIL, "group not found");
+ if (NULL==(mounted=H5G_open(&mnt_open_ent, dxpl_id)))
+ HGOTO_ERROR(H5E_FILE, H5E_MOUNT, FAIL, "mount point not found")
child = H5G_fileof(mounted);
mnt_ent = H5G_entof(mounted);
ent = H5G_entof(child->shared->root_grp);
if (child->mtab.parent &&
- H5F_addr_eq(mnt_ent->header, ent->header)) {
+ H5F_addr_eq(mnt_ent->header, ent->header)) {
/*
* We've been given the root group of the child. We do a reverse
* lookup in the parent's mount table to find the correct entry.