summaryrefslogtreecommitdiffstats
path: root/src/H5Fmount.c
diff options
context:
space:
mode:
authorJames Laird <jlaird@hdfgroup.org>2006-08-18 20:48:54 (GMT)
committerJames Laird <jlaird@hdfgroup.org>2006-08-18 20:48:54 (GMT)
commit75d22ed839a6b7a5e048ac52708d04eb4ad590d3 (patch)
tree6a564780972e92f08cd4f8fd633945dd10180401 /src/H5Fmount.c
parente8c1fdd5545240b47ea996be3db3fa9e27fb42a0 (diff)
downloadhdf5-75d22ed839a6b7a5e048ac52708d04eb4ad590d3.zip
hdf5-75d22ed839a6b7a5e048ac52708d04eb4ad590d3.tar.gz
hdf5-75d22ed839a6b7a5e048ac52708d04eb4ad590d3.tar.bz2
[svn-r12596] Refactored how external files are opened and closed.
Object header locations (H5O_loc_t's) can now "hold open" a file and decrement its open object count when they close. This means that locations (H5O_loc_t's and H5G_loc_t's) should always be freed. Added more thorough tests to ensure that external files are closed.
Diffstat (limited to 'src/H5Fmount.c')
-rw-r--r--src/H5Fmount.c22
1 files changed, 19 insertions, 3 deletions
diff --git a/src/H5Fmount.c b/src/H5Fmount.c
index 75af431..20950d0 100644
--- a/src/H5Fmount.c
+++ b/src/H5Fmount.c
@@ -141,6 +141,7 @@ H5F_mount(H5G_loc_t *loc, const char *name, H5F_t *child,
/*
* Check that the child isn't mounted, that the mount point exists, that
+ * the mount point wasn't reached via external link, that
* the parent & child files have the same file close degree, and
* that the mount wouldn't introduce a cycle in the mount tree.
*/
@@ -148,6 +149,14 @@ H5F_mount(H5G_loc_t *loc, const char *name, H5F_t *child,
HGOTO_ERROR(H5E_FILE, H5E_MOUNT, FAIL, "file is already mounted")
if(H5G_loc_find(loc, name, &mp_loc/*out*/, H5P_DEFAULT, dxpl_id) < 0)
HGOTO_ERROR(H5E_SYM, H5E_NOTFOUND, FAIL, "group not found")
+ /* If the mount location is holding its file open, that file will close
+ * and remove the mount as soon as we exit this function. Prevent the
+ * user from doing this.
+ */
+ if(mp_loc.oloc->holding_file != FALSE)
+ HGOTO_ERROR(H5E_FILE, H5E_MOUNT, FAIL, "mount path cannot contain links to external files")
+
+ /* Open the mount point group */
if(NULL == (mount_point = H5G_open(&mp_loc, dxpl_id)))
HGOTO_ERROR(H5E_FILE, H5E_MOUNT, FAIL, "mount point not found")
@@ -229,9 +238,16 @@ H5F_mount(H5G_loc_t *loc, const char *name, H5F_t *child,
HGOTO_ERROR(H5E_FILE, H5E_MOUNT, FAIL, "unable to replace name")
done:
- if(ret_value < 0 && mount_point)
- if(H5G_close(mount_point) < 0)
- HDONE_ERROR(H5E_FILE, H5E_CANTCLOSEOBJ, FAIL, "unable to close mounted group")
+ if(ret_value < 0) {
+ if(mount_point) {
+ if(H5G_close(mount_point) < 0)
+ HDONE_ERROR(H5E_FILE, H5E_CANTCLOSEOBJ, FAIL, "unable to close mounted group")
+ }
+ else {
+ if(H5G_loc_free(&mp_loc) < 0)
+ HDONE_ERROR(H5E_SYM, H5E_CANTRELEASE, FAIL, "unable to free mount location")
+ }
+ }
FUNC_LEAVE_NOAPI(ret_value)
} /* end H5F_mount() */