summaryrefslogtreecommitdiffstats
path: root/src/H5Fint.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/H5Fint.c')
-rw-r--r--src/H5Fint.c125
1 files changed, 96 insertions, 29 deletions
diff --git a/src/H5Fint.c b/src/H5Fint.c
index df8e886..fd22977 100644
--- a/src/H5Fint.c
+++ b/src/H5Fint.c
@@ -40,6 +40,7 @@
#include "H5Pprivate.h" /* Property lists */
#include "H5SMprivate.h" /* Shared Object Header Messages */
#include "H5Tprivate.h" /* Datatypes */
+#include "H5VLprivate.h" /* VOL plugins */
/****************/
@@ -76,9 +77,12 @@ typedef struct H5F_olist_t {
/* Local Prototypes */
/********************/
-static int H5F_get_objects_cb(void *obj_ptr, hid_t obj_id, void *key);
+/* private prototypes */
+static H5F_t *H5F_new(H5F_file_t *shared, unsigned flags, hid_t fcpl_id,
+ hid_t fapl_id, H5FD_t *lf);
static herr_t H5F_build_actual_name(const H5F_t *f, const H5P_genplist_t *fapl,
- const char *name, char ** /*out*/ actual_name);/* Declare a free list to manage the H5F_t struct */
+ const char *name, char ** /*out*/ actual_name);
+static herr_t H5F_dest(H5F_t *f, hid_t dxpl_id, hbool_t flush);
/*********************/
@@ -156,6 +160,7 @@ H5F_get_access_plist(H5F_t *f, hbool_t app_ref)
H5P_genplist_t *old_plist; /* Old property list */
void *driver_info=NULL;
unsigned efc_size = 0;
+ hid_t driver_id;
hid_t ret_value = SUCCEED;
FUNC_ENTER_NOAPI(FAIL)
@@ -203,8 +208,19 @@ H5F_get_access_plist(H5F_t *f, hbool_t app_ref)
* Since we're resetting the driver ID and info, close them if they
* exist in this new property list.
*/
- if(H5P_facc_close(ret_value, NULL) < 0)
- HGOTO_ERROR(H5E_PLIST, H5E_CANTFREE, FAIL, "can't free the old driver information")
+ /* Get driver ID property */
+ if(H5P_get(new_plist, H5F_ACS_FILE_DRV_ID_NAME, &driver_id) < 0)
+ HGOTO_DONE(FAIL) /* Can't return errors when library is shutting down */
+
+ if(driver_id > 0) {
+ /* Get driver info property */
+ if(H5P_get(new_plist, H5F_ACS_FILE_DRV_INFO_NAME, &driver_info) < 0)
+ HGOTO_DONE(FAIL) /* Can't return errors when library is shutting down */
+
+ /* Close the driver for the property list */
+ if(H5FD_fapl_close(driver_id, driver_info) < 0)
+ HGOTO_DONE(FAIL) /* Can't return errors when library is shutting down */
+ } /* end if */
/* Increment the reference count on the driver ID and insert it into the property list */
if(H5I_inc_ref(f->shared->lf->driver_id, FALSE) < 0)
@@ -306,7 +322,8 @@ done:
*---------------------------------------------------------------------------
*/
herr_t
-H5F_get_objects(const H5F_t *f, unsigned types, size_t max_nobjs, hid_t *obj_id_list, hbool_t app_ref, size_t *obj_id_count_ptr)
+H5F_get_objects(const H5F_t *f, unsigned types, size_t max_nobjs, hid_t *obj_id_list,
+ hbool_t app_ref, size_t *obj_id_count_ptr)
{
size_t obj_id_count=0; /* Number of open IDs */
H5F_olist_t olist; /* Structure to hold search results */
@@ -412,7 +429,7 @@ done:
*
*-------------------------------------------------------------------------
*/
-static int
+int
H5F_get_objects_cb(void *obj_ptr, hid_t obj_id, void *key)
{
H5F_olist_t *olist = (H5F_olist_t *)key; /* Alias for search info */
@@ -462,6 +479,7 @@ H5F_get_objects_cb(void *obj_ptr, hid_t obj_id, void *key)
case H5I_DATASPACE:
case H5I_REFERENCE:
case H5I_VFL:
+ case H5I_VOL:
case H5I_GENPROP_CLS:
case H5I_GENPROP_LST:
case H5I_ERROR_CLASS:
@@ -529,28 +547,34 @@ done:
*-------------------------------------------------------------------------
*/
htri_t
-H5F_is_hdf5(const char *name)
+H5F_is_hdf5(const char *name, hid_t fapl_id)
{
- H5FD_t *file = NULL; /* Low-level file struct */
+ H5F_t *file = NULL; /* Low-level file struct */
haddr_t sig_addr; /* Addess of hdf5 file signature */
htri_t ret_value; /* Return value */
FUNC_ENTER_NOAPI_NOINIT
/* Open the file at the virtual file layer */
- if(NULL == (file = H5FD_open(name, H5F_ACC_RDONLY, H5P_FILE_ACCESS_DEFAULT, HADDR_UNDEF)))
- HGOTO_ERROR(H5E_IO, H5E_CANTINIT, FAIL, "unable to open file")
+ //if(NULL == (file = H5FD_open(name, H5F_ACC_RDONLY, fapl_id, HADDR_UNDEF)))
+ //HGOTO_ERROR(H5E_IO, H5E_CANTINIT, FAIL, "unable to open file")
+
+ /* Open the file */
+ if(NULL == (file = H5F_open(name, H5F_ACC_RDONLY, H5P_FILE_CREATE_DEFAULT,
+ fapl_id, H5AC_ind_dxpl_id)))
+ HGOTO_ERROR(H5E_FILE, H5E_CANTINIT, FALSE, "unable to open file")
/* The file is an hdf5 file if the hdf5 file signature can be found */
- if(H5FD_locate_signature(file, H5AC_ind_dxpl_g, &sig_addr) < 0)
- HGOTO_ERROR(H5E_FILE, H5E_NOTHDF5, FAIL, "unable to locate file signature")
+ if(H5FD_locate_signature(file->shared->lf, H5AC_ind_dxpl_g, &sig_addr) < 0)
+ HGOTO_ERROR(H5E_FILE, H5E_NOTHDF5, FALSE, "unable to locate file signature")
ret_value = (HADDR_UNDEF != sig_addr);
done:
/* Close the file */
if(file)
- if(H5FD_close(file) < 0 && ret_value >= 0)
- HDONE_ERROR(H5E_IO, H5E_CANTCLOSEFILE, FAIL, "unable to close file")
+ //if(H5FD_close(file) < 0 && ret_value >= 0)
+ if(H5F_close(file) < 0 && ret_value >= 0)
+ HDONE_ERROR(H5E_FILE, H5E_CANTCLOSEFILE, FAIL, "unable to close file")
FUNC_LEAVE_NOAPI(ret_value)
} /* end H5F_is_hdf5() */
@@ -578,7 +602,7 @@ done:
*
*-------------------------------------------------------------------------
*/
-H5F_t *
+static H5F_t *
H5F_new(H5F_file_t *shared, unsigned flags, hid_t fcpl_id, hid_t fapl_id, H5FD_t *lf)
{
H5F_t *f = NULL, *ret_value;
@@ -587,7 +611,7 @@ H5F_new(H5F_file_t *shared, unsigned flags, hid_t fcpl_id, hid_t fapl_id, H5FD_t
if(NULL == (f = H5FL_CALLOC(H5F_t)))
HGOTO_ERROR(H5E_FILE, H5E_NOSPACE, NULL, "can't allocate top file structure")
- f->file_id = -1;
+ f->id_exists = FALSE;
if(shared) {
HDassert(lf == NULL);
@@ -749,7 +773,7 @@ done:
*
*-------------------------------------------------------------------------
*/
-herr_t
+static herr_t
H5F_dest(H5F_t *f, hid_t dxpl_id, hbool_t flush)
{
herr_t ret_value = SUCCEED; /* Return value */
@@ -1236,7 +1260,6 @@ H5F_close(H5F_t *f)
/* Sanity check */
HDassert(f);
- HDassert(f->file_id > 0); /* This routine should only be called when a file ID's ref count drops to zero */
/* Perform checks for "semi" file close degree here, since closing the
* file is not allowed if there are objects still open */
@@ -1257,7 +1280,7 @@ H5F_close(H5F_t *f)
} /* end if */
/* Reset the file ID for this file */
- f->file_id = -1;
+ f->id_exists = FALSE;
/* Attempt to close the file/mount hierarchy */
if(H5F_try_close(f) < 0)
@@ -1431,6 +1454,50 @@ done:
/*-------------------------------------------------------------------------
+ * Function: H5F_reopen
+ *
+ * Purpose: Reopen a file. The new file handle which is returned points
+ * to the same file as the specified file handle. Both handles
+ * share caches and other information. The only difference
+ * between the handles is that the new handle is not mounted
+ * anywhere and no files are mounted on it.
+ *
+ * Return: Success: New file ID
+ *
+ * Failure: FAIL
+ *
+ * Programmer: Robb Matzke
+ * Friday, October 16, 1998
+ *
+ * Modifications:
+ * Quincey Koziol, May 14, 2002
+ * Keep old file's read/write intent in reopened file.
+ *
+ *-------------------------------------------------------------------------
+ */
+H5F_t *
+H5F_reopen(H5F_t *f)
+{
+ H5F_t *ret_value = NULL;
+
+ FUNC_ENTER_NOAPI_NOINIT
+
+ /* Get a new "top level" file struct, sharing the same "low level" file struct */
+ /* Get a new "top level" file struct, sharing the same "low level" file struct */
+ if(NULL == (ret_value = H5F_new(f->shared, 0, H5P_FILE_CREATE_DEFAULT,
+ H5P_FILE_ACCESS_DEFAULT, NULL)))
+ HGOTO_ERROR(H5E_FILE, H5E_CANTINIT, NULL, "unable to reopen file")
+
+ /* Duplicate old file's names */
+ ret_value->open_name = H5MM_xstrdup(f->open_name);
+ ret_value->actual_name = H5MM_xstrdup(f->actual_name);
+
+done:
+ FUNC_LEAVE_NOAPI(ret_value)
+} /* end H5F_reopen() */
+
+
+/*-------------------------------------------------------------------------
* Function: H5F_get_id
*
* Purpose: Get the file ID, incrementing it, or "resurrecting" it as
@@ -1452,17 +1519,17 @@ H5F_get_id(H5F_t *file, hbool_t app_ref)
HDassert(file);
- if(file->file_id == -1) {
- /* Get an atom for the file */
- if((file->file_id = H5I_register(H5I_FILE, file, app_ref)) < 0)
- HGOTO_ERROR(H5E_ATOM, H5E_CANTREGISTER, FAIL, "unable to atomize file")
- } else {
- /* Increment reference count on atom. */
- if(H5I_inc_ref(file->file_id, app_ref) < 0)
+ if (FAIL == (ret_value = H5I_get_id(file, H5I_FILE))) {
+ /* resurrect the ID - Register an ID with the native plugin */
+ if((ret_value = H5VL_native_register(H5I_FILE, file, app_ref)) < 0)
+ HGOTO_ERROR(H5E_ATOM, H5E_CANTREGISTER, FAIL, "unable to register group")
+ file->id_exists = TRUE;
+ }
+ else {
+ /* Increment ref count on existing ID */
+ if(H5I_inc_ref(ret_value, app_ref) < 0)
HGOTO_ERROR(H5E_ATOM, H5E_CANTSET, FAIL, "incrementing file ID failed")
- } /* end else */
-
- ret_value = file->file_id;
+ }
done:
FUNC_LEAVE_NOAPI(ret_value)