summaryrefslogtreecommitdiffstats
path: root/src/H5Pfapl.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/H5Pfapl.c')
-rw-r--r--src/H5Pfapl.c253
1 files changed, 246 insertions, 7 deletions
diff --git a/src/H5Pfapl.c b/src/H5Pfapl.c
index 7a44e86..ca8f398 100644
--- a/src/H5Pfapl.c
+++ b/src/H5Pfapl.c
@@ -39,6 +39,7 @@
#include "H5Eprivate.h" /* Error handling */
#include "H5Fprivate.h" /* Files */
#include "H5FDprivate.h" /* File drivers */
+#include "H5VLprivate.h" /* VOL plugins */
#include "H5Iprivate.h" /* IDs */
#include "H5MMprivate.h" /* Memory Management */
#include "H5Ppkg.h" /* Property lists */
@@ -46,6 +47,10 @@
/* Includes needed to set as default file driver */
#include "H5FDsec2.h" /* Posix unbuffered I/O file driver */
#include "H5FDstdio.h" /* Standard C buffered I/O */
+
+/* Includes needed to set as default VOL driver */
+#include "H5VLnative.h" /* Native H5 VOL plugin */
+
#ifdef H5_HAVE_WINDOWS
#include "H5FDwindows.h" /* Windows buffered I/O */
#endif
@@ -154,6 +159,14 @@
#define H5F_ACS_EFC_SIZE_DEF 0
#define H5F_ACS_EFC_SIZE_ENC H5P__encode_unsigned
#define H5F_ACS_EFC_SIZE_DEC H5P__decode_unsigned
+
+/* Definition for VOL plugin */
+#define H5F_ACS_VOL_ID_SIZE sizeof(hid_t)
+#define H5F_ACS_VOL_ID_DEF H5VL_NATIVE
+/* Definition for vol info */
+#define H5F_ACS_VOL_INFO_SIZE sizeof(void*)
+#define H5F_ACS_VOL_INFO_DEF NULL
+
/* Definition of pointer to initial file image info */
#define H5F_ACS_FILE_IMAGE_INFO_SIZE sizeof(H5FD_file_image_info_t)
#define H5F_ACS_FILE_IMAGE_INFO_DEF H5FD_DEFAULT_FILE_IMAGE_INFO
@@ -277,6 +290,8 @@ static const size_t H5F_def_core_write_tracking_page_size_g = H5F_ACS_CORE_WRITE
static herr_t
H5P_facc_reg_prop(H5P_genclass_t *pclass)
{
+ const hid_t def_vol_id = H5F_ACS_VOL_ID_DEF; /* Default VOL plugin */
+ void *vol_info = H5F_ACS_VOL_INFO_DEF; /* Default VOL plugin information*/
const hid_t def_driver_id = H5F_ACS_FILE_DRV_ID_DEF; /* Default VFL driver ID (initialized from a variable) */
herr_t ret_value = SUCCEED; /* Return value */
@@ -403,6 +418,16 @@ H5P_facc_reg_prop(H5P_genclass_t *pclass)
NULL, NULL, NULL, NULL) < 0)
HGOTO_ERROR(H5E_PLIST, H5E_CANTINSERT, FAIL, "can't insert property into class")
+ /* Register the file VOL ID */
+ if(H5P_register_real(pclass, H5F_ACS_VOL_ID_NAME, H5F_ACS_VOL_ID_SIZE, &def_vol_id,
+ NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL) < 0)
+ HGOTO_ERROR(H5E_PLIST, H5E_CANTINSERT, FAIL, "can't insert property into class")
+
+ /* Register the file VOL INFO */
+ if(H5P_register_real(pclass, H5F_ACS_VOL_INFO_NAME, H5F_ACS_VOL_INFO_SIZE, &vol_info,
+ NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL) < 0)
+ HGOTO_ERROR(H5E_PLIST, H5E_CANTINSERT, FAIL, "can't insert property into class")
+
/* Register the initial file image info */
/* (Note: this property should not have an encode/decode callback -QAK) */
if(H5P_register_real(pclass, H5F_ACS_FILE_IMAGE_INFO_NAME, H5F_ACS_FILE_IMAGE_INFO_SIZE, &H5F_def_file_image_info_g,
@@ -448,6 +473,7 @@ static herr_t
H5P_facc_create(hid_t fapl_id, void UNUSED *copy_data)
{
hid_t driver_id;
+ hid_t vol_id;
H5P_genplist_t *plist; /* Property list */
herr_t ret_value = SUCCEED;
@@ -457,6 +483,21 @@ H5P_facc_create(hid_t fapl_id, void UNUSED *copy_data)
if(NULL == (plist = (H5P_genplist_t *)H5I_object(fapl_id)))
HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a property list")
+ /* Retrieve VOL plugin property */
+ if(H5P_get(plist, H5F_ACS_VOL_ID_NAME, &vol_id) < 0)
+ HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, FAIL, "can't get vol plugin")
+
+ if(vol_id > 0) {
+ void *vol_info;
+
+ /* Retrieve VOL plugin info property */
+ if(H5P_get(plist, H5F_ACS_VOL_INFO_NAME, &vol_info) < 0)
+ HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, FAIL, "can't get vol info")
+ /* Set the vol for the property list */
+ if(H5VL_fapl_open(plist, vol_id, vol_info) < 0)
+ HGOTO_ERROR(H5E_PLIST, H5E_CANTSET, FAIL, "can't set vol")
+ }
+
/* Retrieve driver ID property */
if(H5P_get(plist, H5F_ACS_FILE_DRV_ID_NAME, &driver_id) < 0)
HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, FAIL, "can't get driver ID")
@@ -498,28 +539,45 @@ static herr_t
H5P_facc_copy(hid_t dst_fapl_id, hid_t src_fapl_id, void UNUSED *copy_data)
{
hid_t driver_id;
+ hid_t vol_id;
H5P_genplist_t *src_plist; /* Source property list */
+ H5P_genplist_t *dst_plist; /* Destination property list */
herr_t ret_value = SUCCEED;
FUNC_ENTER_NOAPI_NOINIT
- /* Get driver ID from source property list */
if(NULL == (src_plist = (H5P_genplist_t *)H5I_object(src_fapl_id)))
HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "can't get property list")
+ if(NULL == (dst_plist = (H5P_genplist_t *)H5I_object(dst_fapl_id)))
+ HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "can't get property list")
+
+ /* get VOL plugin from source property list */
+ if(H5P_get(src_plist, H5F_ACS_VOL_ID_NAME, &vol_id) < 0)
+ HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, FAIL, "can't get vol ID")
+
+ if(vol_id > 0) {
+ void *vol_info;
+
+ /* Retrieve VOL plugin property */
+ if(H5P_get(dst_plist, H5F_ACS_VOL_INFO_NAME, &vol_info) < 0)
+ HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, FAIL, "can't get vol info")
+
+ /* Set the vp; for the destination property list */
+ if(H5VL_fapl_open(dst_plist, vol_id, vol_info) < 0)
+ HGOTO_ERROR(H5E_PLIST, H5E_CANTSET, FAIL, "can't set vol")
+ } /* end if */
+
+ /* Get driver ID from source property list */
if(H5P_get(src_plist, H5F_ACS_FILE_DRV_ID_NAME, &driver_id) < 0)
HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, FAIL, "can't get driver ID")
if(driver_id > 0) {
- H5P_genplist_t *dst_plist; /* Destination property list */
void *driver_info;
/* Get driver info from source property list */
if(H5P_get(src_plist, H5F_ACS_FILE_DRV_INFO_NAME, &driver_info) < 0)
HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, FAIL, "can't get driver info")
- /* Set the driver for the destination property list */
- if(NULL == (dst_plist = (H5P_genplist_t *)H5I_object(dst_fapl_id)))
- HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "can't get property list")
if(H5FD_fapl_open(dst_plist, driver_id, driver_info) < 0)
HGOTO_ERROR(H5E_PLIST, H5E_CANTSET, FAIL, "can't set driver")
} /* end if */
@@ -548,9 +606,10 @@ done:
herr_t
H5P_facc_close(hid_t fapl_id, void UNUSED *close_data)
{
- hid_t driver_id;
+ hid_t driver_id;
+ hid_t vol_id;
H5P_genplist_t *plist; /* Property list */
- herr_t ret_value = SUCCEED;
+ herr_t ret_value = SUCCEED;
FUNC_ENTER_NOAPI(FAIL)
@@ -558,6 +617,22 @@ H5P_facc_close(hid_t fapl_id, void UNUSED *close_data)
if(NULL == (plist = (H5P_genplist_t *)H5I_object(fapl_id)))
HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a property list")
+ /* Get vol plugin */
+ if(H5P_get(plist, H5F_ACS_VOL_ID_NAME, &vol_id) < 0)
+ HGOTO_DONE(FAIL) /* Can't return errors when library is shutting down */
+
+ if(vol_id > 0) {
+ void *vol_info;
+
+ /* Retrieve VOL plugin info property */
+ if(H5P_get(plist, H5F_ACS_VOL_INFO_NAME, &vol_info) < 0)
+ HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, FAIL, "can't get vol info")
+
+ /* Close the driver for the property list */
+ if(H5VL_fapl_close(vol_id, vol_info) < 0)
+ HGOTO_DONE(FAIL) /* Can't return errors when library is shutting down */
+ } /* end if */
+
/* Get driver ID property */
if(H5P_get(plist, H5F_ACS_FILE_DRV_ID_NAME, &driver_id) < 0)
HGOTO_DONE(FAIL) /* Can't return errors when library is shutting down */
@@ -1976,6 +2051,170 @@ done:
/*-------------------------------------------------------------------------
+ * Function: H5P_set_vol
+ *
+ * Purpose: Set the vol plugin for a file access property list
+ * (PLIST_ID). The vol properties will
+ * be copied into the property list and the reference count on
+ * the vol will be incremented.
+ *
+ * Return: Success: Non-negative
+ * Failure: Negative
+ *
+ * Programmer: Mohamad Chaarawi
+ * January, 2012
+ *
+ *-------------------------------------------------------------------------
+ */
+herr_t
+H5P_set_vol(H5P_genplist_t *plist, hid_t vol_id, const void *vol_info)
+{
+ hid_t old_vol_id;
+ void *old_vol_info;
+ herr_t ret_value=SUCCEED; /* Return value */
+
+ FUNC_ENTER_NOAPI(FAIL)
+
+ if(TRUE == H5P_isa_class(plist->plist_id, H5P_FILE_ACCESS)) {
+ /* Get the current vol information */
+ if(H5P_get(plist, H5F_ACS_VOL_ID_NAME, &old_vol_id) < 0)
+ HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, FAIL, "can't get vol class")
+ if(H5P_get(plist, H5F_ACS_VOL_INFO_NAME, &old_vol_info) < 0)
+ HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, FAIL, "can't get vol info")
+
+ /* Close the vol for the property list */
+ if(H5VL_fapl_close(old_vol_id, old_vol_info)<0)
+ HGOTO_ERROR(H5E_PLIST, H5E_CANTSET, FAIL, "can't reset vol")
+
+ /* Set the vol for the property list */
+ if(H5VL_fapl_open(plist, vol_id, vol_info)<0)
+ HGOTO_ERROR(H5E_PLIST, H5E_CANTSET, FAIL, "can't set vol")
+ }
+ else
+ HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a file access property list");
+
+done:
+ FUNC_LEAVE_NOAPI(ret_value)
+} /* end H5P_set_vol() */
+
+
+/*-------------------------------------------------------------------------
+ * Function: H5Pset_vol
+ *
+ * Purpose: Set the file vol plugin (VOL_ID) for a file access
+ * property list (PLIST_ID)
+ *
+ * Return: Success: Non-negative
+ *
+ * Failure: Negative
+ *
+ * Programmer: Mohamad Chaarawi
+ * April, 2012
+ *
+ *-------------------------------------------------------------------------
+ */
+herr_t
+H5Pset_vol(hid_t plist_id, hid_t new_vol_id, const void *new_vol_info)
+{
+ H5P_genplist_t *plist; /* Property list pointer */
+ herr_t ret_value = SUCCEED; /* Return value */
+
+ FUNC_ENTER_API(FAIL)
+ H5TRACE3("e", "ii*x", plist_id, new_vol_id, new_vol_info);
+
+ /* Check arguments */
+ if(NULL == (plist = (H5P_genplist_t *)H5I_object_verify(plist_id, H5I_GENPROP_LST)))
+ HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a property list")
+ if(NULL == H5I_object_verify(new_vol_id, H5I_VOL))
+ HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a file vol ID")
+
+ /* Set the vol */
+ if(H5P_set_vol(plist, new_vol_id, new_vol_info) < 0)
+ HGOTO_ERROR(H5E_PLIST, H5E_CANTSET, FAIL, "can't set vol")
+
+done:
+ FUNC_LEAVE_API(ret_value)
+} /* end H5Pset_vol() */
+
+
+/*-------------------------------------------------------------------------
+ * Function: H5P_get_vol_info
+ *
+ * Purpose: Returns a pointer directly to the file vol-specific
+ * information of a file access property list.
+ *
+ * Return: Success: Ptr to *uncopied* vol specific data
+ * structure if any.
+ *
+ * Failure: NULL. Null is also returned if the vol has
+ * not registered any vol-specific properties
+ * although no error is pushed on the stack in
+ * this case.
+ *
+ * Programmer: Mohamad Chaarawi
+ * July, 2012
+ *
+ *-------------------------------------------------------------------------
+ */
+void *
+H5P_get_vol_info(H5P_genplist_t *plist)
+{
+ void *ret_value=NULL;
+
+ FUNC_ENTER_NOAPI(NULL)
+
+ /* Get the current vol info */
+ if( TRUE == H5P_isa_class(plist->plist_id, H5P_FILE_ACCESS) ) {
+ if(H5P_get(plist, H5F_ACS_VOL_INFO_NAME, &ret_value) < 0)
+ HGOTO_ERROR(H5E_PLIST, H5E_CANTGET,NULL,"can't get vol info");
+ } else {
+ HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, NULL, "not a file access property list");
+ }
+
+done:
+ FUNC_LEAVE_NOAPI(ret_value)
+} /* end H5P_get_vol_info() */
+
+
+/*-------------------------------------------------------------------------
+ * Function: H5Pget_vol_info
+ *
+ * Purpose: Returns a pointer directly to the file vol-specific
+ * information of a file access property list.
+ *
+ * Return: Success: Ptr to *uncopied* vol specific data
+ * structure if any.
+ *
+ * Failure: NULL. Null is also returned if the vol has
+ * not registered any vol-specific properties
+ * although no error is pushed on the stack in
+ * this case.
+ *
+ * Programmer: Mohamad Chaarawi
+ * July 2012
+ *
+ *-------------------------------------------------------------------------
+ */
+void *
+H5Pget_vol_info(hid_t plist_id)
+{
+ H5P_genplist_t *plist; /* Property list pointer */
+ void *ret_value; /* Return value */
+
+ FUNC_ENTER_API(NULL)
+
+ if(NULL == (plist = (H5P_genplist_t *)H5I_object_verify(plist_id, H5I_GENPROP_LST)))
+ HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, NULL, "not a property list")
+
+ if(NULL == (ret_value = H5P_get_vol_info(plist)))
+ HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, NULL, "can't get vol info")
+
+done:
+ FUNC_LEAVE_API(ret_value)
+} /* end H5Pget_vol_info() */
+
+
+/*-------------------------------------------------------------------------
* Function: H5Pset_file_image
*
* Purpose: Sets the initial file image. Some file drivers can initialize