summaryrefslogtreecommitdiffstats
path: root/src/H5FD.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/H5FD.c')
-rw-r--r--src/H5FD.c219
1 files changed, 24 insertions, 195 deletions
diff --git a/src/H5FD.c b/src/H5FD.c
index bb2d729..bce6596 100644
--- a/src/H5FD.c
+++ b/src/H5FD.c
@@ -62,12 +62,7 @@
/********************/
/* Local Prototypes */
/********************/
-static herr_t H5FD_pl_copy(void *(*copy_func)(const void *), size_t pl_size,
- const void *old_pl, void **copied_pl);
-static herr_t H5FD_pl_close(hid_t driver_id, herr_t (*free_func)(void *),
- void *pl);
static herr_t H5FD_free_cls(H5FD_class_t *cls);
-static herr_t H5FD_fapl_copy(hid_t driver_id, const void *fapl, void **copied_fapl);
static int H5FD_query(const H5FD_t *f, unsigned long *flags/*out*/);
static int H5FD_driver_query(const H5FD_class_t *driver, unsigned long *flags/*out*/);
@@ -425,9 +420,11 @@ H5FD_get_class(hid_t id)
HGOTO_ERROR(H5E_ATOM, H5E_BADATOM, NULL, "can't find object for ID")
if(TRUE == H5P_isa_class(id, H5P_FILE_ACCESS)) {
- if(H5P_get(plist, H5F_ACS_FILE_DRV_ID_NAME, &driver_id) < 0)
- HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, NULL, "can't get driver ID")
- ret_value = H5FD_get_class(driver_id);
+ H5FD_driver_prop_t driver_prop; /* Property for driver ID & info */
+
+ if(H5P_peek(plist, H5F_ACS_FILE_DRV_NAME, &driver_prop) < 0)
+ HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, NULL, "can't get driver ID & info")
+ ret_value = H5FD_get_class(driver_prop.driver_id);
} /* end if */
else
HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, NULL, "not a driver id or file access property list")
@@ -582,96 +579,6 @@ done:
/*-------------------------------------------------------------------------
- * Function: H5FD_pl_copy
- *
- * Purpose: Copies the driver-specific part of the a property list.
- * This is common code, used by both the dataset transfer and
- * file access property list routines.
- *
- * Return: Success: non-negative
- *
- * Failure: negative
- *
- * Programmer: Quincey Koziol
- * Thursday, October 23, 2003
- *
- * Modifications:
- * Pedro Vicente Nunes, Wednesday, July 26, 2006
- * added a HGOTO_ERROR call in the case the copy function returns NULL
- *
- *-------------------------------------------------------------------------
- */
-static herr_t
-H5FD_pl_copy(void *(*copy_func)(const void *), size_t pl_size, const void *old_pl, void **copied_pl)
-{
- void *new_pl = NULL; /* Copy of property list */
- herr_t ret_value=SUCCEED; /* Return value */
-
- FUNC_ENTER_NOAPI_NOINIT
-
- /* Copy old pl, if one exists */
- if(old_pl) {
- /* Allow the driver to copy or do it ourselves */
- if(copy_func) {
- new_pl = (copy_func)(old_pl);
- if(new_pl==NULL)
- HGOTO_ERROR(H5E_VFL, H5E_NOSPACE, FAIL, "property list copy failed")
- } else if(pl_size>0) {
- if((new_pl = H5MM_malloc(pl_size))==NULL)
- HGOTO_ERROR(H5E_VFL, H5E_NOSPACE, FAIL, "property list allocation failed")
- HDmemcpy(new_pl, old_pl, pl_size);
- } else
- HGOTO_ERROR(H5E_VFL, H5E_UNSUPPORTED, FAIL, "no way to copy driver property list")
- } /* end if */
-
- /* Set copied value */
- *copied_pl=new_pl;
-
-done:
- FUNC_LEAVE_NOAPI(ret_value)
-} /* end H5FD_pl_copy() */
-
-
-/*-------------------------------------------------------------------------
- * Function: H5FD_pl_close
- *
- * Purpose: Closes a driver for a property list
- * This is common code, used by both the dataset transfer and
- * file access property list routines.
- *
- * Return: Success: non-negative
- * Failure: negative
- *
- * Programmer: Quincey Koziol
- * Thursday, October 23, 2003
- *
- *-------------------------------------------------------------------------
- */
-static herr_t
-H5FD_pl_close(hid_t driver_id, herr_t (*free_func)(void *), void *pl)
-{
- herr_t ret_value = SUCCEED; /* Return value */
-
- FUNC_ENTER_NOAPI_NOINIT
-
- /* Allow driver to free or do it ourselves */
- if(pl && free_func) {
- if((free_func)(pl) < 0)
- HGOTO_ERROR(H5E_VFL, H5E_CANTINIT, FAIL, "driver free request failed")
- } /* end if */
- else
- H5MM_xfree(pl);
-
- /* Decrement reference count for driver */
- if(H5I_dec_ref(driver_id) < 0)
- HGOTO_ERROR(H5E_VFL, H5E_CANTDEC, FAIL, "can't decrement reference count for driver")
-
-done:
- FUNC_LEAVE_NOAPI(ret_value)
-} /* end H5FD_pl_close() */
-
-
-/*-------------------------------------------------------------------------
* Function: H5FD_fapl_get
*
* Purpose: Gets the file access property list associated with a file.
@@ -693,8 +600,6 @@ done:
* Programmer: Robb Matzke
* Friday, August 13, 1999
*
- * Modifications:
- *
*-------------------------------------------------------------------------
*/
void *
@@ -715,88 +620,6 @@ done:
/*-------------------------------------------------------------------------
- * Function: H5FD_fapl_open
- *
- * Purpose: Mark a driver as used by a file access property list
- *
- * Return: Success: non-negative
- *
- * Failure: negative
- *
- * Programmer: Quincey Koziol
- * Thursday, October 23, 2003
- *
- * Modifications:
- *
- *-------------------------------------------------------------------------
- */
-herr_t
-H5FD_fapl_open(H5P_genplist_t *plist, hid_t driver_id, const void *driver_info)
-{
- void *copied_driver_info = NULL; /* Temporary VFL driver info */
- herr_t ret_value = SUCCEED; /* Return value */
-
- FUNC_ENTER_NOAPI(FAIL)
-
- /* Increment the reference count on driver and copy driver info */
- if(H5I_inc_ref(driver_id, FALSE) < 0)
- HGOTO_ERROR(H5E_FILE, H5E_CANTINC, FAIL, "unable to increment ref count on VFL driver")
- if(H5FD_fapl_copy(driver_id, driver_info, &copied_driver_info) < 0)
- HGOTO_ERROR(H5E_FILE, H5E_CANTCOPY, FAIL, "can't copy VFL driver info")
-
- /* Set the driver properties for the list */
- if(H5P_set(plist, H5F_ACS_FILE_DRV_ID_NAME, &driver_id) < 0)
- HGOTO_ERROR(H5E_FILE, H5E_CANTSET, FAIL, "can't set driver ID")
- if(H5P_set(plist, H5F_ACS_FILE_DRV_INFO_NAME, &copied_driver_info) < 0)
- HGOTO_ERROR(H5E_FILE, H5E_CANTSET, FAIL, "can't set driver info")
- copied_driver_info = NULL;
-
-done:
- if(ret_value < 0)
- if(copied_driver_info && H5FD_fapl_close(driver_id, copied_driver_info) < 0)
- HDONE_ERROR(H5E_FILE, H5E_CANTCLOSEOBJ, FAIL, "can't close copy of driver info")
-
- FUNC_LEAVE_NOAPI(ret_value)
-} /* end H5FD_fapl_open() */
-
-
-/*-------------------------------------------------------------------------
- * Function: H5FD_fapl_copy
- *
- * Purpose: Copies the driver-specific part of the file access property
- * list.
- *
- * Return: Success: non-negative
- *
- * Failure: negative
- *
- * Programmer: Robb Matzke
- * Tuesday, August 3, 1999
- *
- *-------------------------------------------------------------------------
- */
-static herr_t
-H5FD_fapl_copy(hid_t driver_id, const void *old_fapl, void **copied_fapl)
-{
- H5FD_class_t *driver;
- herr_t ret_value = SUCCEED; /* Return value */
-
- FUNC_ENTER_NOAPI_NOINIT
-
- /* Check args */
- if(NULL == (driver = (H5FD_class_t *)H5I_object(driver_id)))
- HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a driver ID")
-
- /* Copy the file access property list */
- if(H5FD_pl_copy(driver->fapl_copy, driver->fapl_size, old_fapl, copied_fapl) < 0)
- HGOTO_ERROR(H5E_VFL, H5E_UNSUPPORTED, FAIL, "can't copy driver file access property list")
-
-done:
- FUNC_LEAVE_NOAPI(ret_value)
-}
-
-
-/*-------------------------------------------------------------------------
* Function: H5FD_fapl_close
*
* Purpose: Closes a driver for a dataset transfer property list
@@ -807,26 +630,32 @@ done:
* Programmer: Robb Matzke
* Tuesday, August 3, 1999
*
- * Modifications:
- *
*-------------------------------------------------------------------------
*/
herr_t
-H5FD_fapl_close(hid_t driver_id, void *fapl)
+H5FD_fapl_close(hid_t driver_id, const void *driver_info)
{
- H5FD_class_t *driver = NULL;
herr_t ret_value = SUCCEED; /* Return value */
FUNC_ENTER_NOAPI(FAIL)
/* Check args */
if(driver_id > 0) {
+ H5FD_class_t *driver;
+
+ /* Retrieve the driver for the ID */
if(NULL == (driver = (H5FD_class_t *)H5I_object(driver_id)))
HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a driver ID")
- /* Close the driver for the property list */
- if(H5FD_pl_close(driver_id, driver->fapl_free, fapl) < 0)
- HGOTO_ERROR(H5E_VFL, H5E_CANTINIT, FAIL, "driver fapl_free request failed")
+ /* Allow driver to free info or do it ourselves */
+ if(driver_info) {
+ if(driver->fapl_free) {
+ if((driver->fapl_free)((void *)driver_info) < 0) /* Casting away const OK -QAK */
+ HGOTO_ERROR(H5E_VFL, H5E_CANTFREE, FAIL, "driver free request failed")
+ } /* end if */
+ else
+ H5MM_xfree((void *)driver_info); /* Casting away const OK -QAK */
+ } /* end if */
} /* end if */
done:
@@ -938,7 +767,7 @@ H5FD_open(const char *name, unsigned flags, hid_t fapl_id, haddr_t maxaddr)
{
H5FD_class_t *driver; /* VFD for file */
H5FD_t *file = NULL; /* VFD file struct */
- hid_t driver_id = -1; /* VFD ID */
+ H5FD_driver_prop_t driver_prop; /* Property for driver ID & info */
H5P_genplist_t *plist; /* Property list pointer */
unsigned long driver_flags = 0; /* File-inspecific driver feature flags */
H5FD_file_image_info_t file_image_info; /* Initial file image */
@@ -955,11 +784,11 @@ H5FD_open(const char *name, unsigned flags, hid_t fapl_id, haddr_t maxaddr)
HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, NULL, "not a file access property list")
/* Get the VFD to open the file with */
- if(H5P_get(plist, H5F_ACS_FILE_DRV_ID_NAME, &driver_id) < 0)
- HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, NULL, "can't get driver ID")
+ if(H5P_peek(plist, H5F_ACS_FILE_DRV_NAME, &driver_prop) < 0)
+ HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, NULL, "can't get driver ID & info")
/* Get driver info */
- if(NULL == (driver = (H5FD_class_t *)H5I_object(driver_id)))
+ if(NULL == (driver = (H5FD_class_t *)H5I_object(driver_prop.driver_id)))
HGOTO_ERROR(H5E_VFL, H5E_BADVALUE, NULL, "invalid driver ID in file access property list")
if(NULL == driver->open)
HGOTO_ERROR(H5E_VFL, H5E_UNSUPPORTED, NULL, "file driver has no `open' method")
@@ -968,7 +797,7 @@ H5FD_open(const char *name, unsigned flags, hid_t fapl_id, haddr_t maxaddr)
H5FD_driver_query(driver, &driver_flags);
/* Get initial file image info */
- if(H5P_get(plist, H5F_ACS_FILE_IMAGE_INFO_NAME, &file_image_info) < 0)
+ if(H5P_peek(plist, H5F_ACS_FILE_IMAGE_INFO_NAME, &file_image_info) < 0)
HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, NULL, "can't get file image info")
/* If an image is provided, make sure the driver supports this feature */
@@ -987,7 +816,7 @@ H5FD_open(const char *name, unsigned flags, hid_t fapl_id, haddr_t maxaddr)
* Fill in public fields. We must increment the reference count on the
* driver ID to prevent it from being freed while this file is open.
*/
- file->driver_id = driver_id;
+ file->driver_id = driver_prop.driver_id;
if(H5I_inc_ref(file->driver_id, FALSE) < 0)
HGOTO_ERROR(H5E_VFL, H5E_CANTINC, NULL, "unable to increment ref count on VFL driver")
file->cls = driver;