summaryrefslogtreecommitdiffstats
path: root/src/H5Pfapl.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/H5Pfapl.c')
-rw-r--r--src/H5Pfapl.c256
1 files changed, 244 insertions, 12 deletions
diff --git a/src/H5Pfapl.c b/src/H5Pfapl.c
index a416b00..b78df3d 100644
--- a/src/H5Pfapl.c
+++ b/src/H5Pfapl.c
@@ -29,7 +29,6 @@
/****************/
#define H5P_PACKAGE /*suppress error about including H5Ppkg */
-
/***********/
/* Headers */
/***********/
@@ -39,6 +38,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,11 +46,14 @@
/* 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
-
/****************/
/* Local Macros */
/****************/
@@ -154,6 +157,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_SIZE sizeof(void *)
+#define H5F_ACS_VOL_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
@@ -161,7 +172,6 @@
#define H5F_ACS_FILE_IMAGE_INFO_COPY H5P_file_image_info_copy
#define H5F_ACS_FILE_IMAGE_INFO_CLOSE H5P_file_image_info_close
-
/******************/
/* Local Typedefs */
/******************/
@@ -264,6 +274,8 @@ static const H5FD_file_image_info_t H5F_def_file_image_info_g = H5F_ACS_FILE_IMA
static herr_t
H5P_facc_reg_prop(H5P_genclass_t *pclass)
{
+ H5VL_class_t *vol_cls = H5F_ACS_VOL_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 */
@@ -390,6 +402,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_NAME, H5F_ACS_VOL_SIZE, &vol_cls,
+ 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,
@@ -423,6 +445,7 @@ static herr_t
H5P_facc_create(hid_t fapl_id, void UNUSED *copy_data)
{
hid_t driver_id;
+ H5VL_class_t *vol_cls;
H5P_genplist_t *plist; /* Property list */
herr_t ret_value = SUCCEED;
@@ -432,6 +455,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_NAME, &vol_cls) < 0)
+ HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, FAIL, "can't get vol plugin")
+
+ if(NULL != vol_cls) {
+ 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_cls, 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")
@@ -473,28 +511,44 @@ static herr_t
H5P_facc_copy(hid_t dst_fapl_id, hid_t src_fapl_id, void UNUSED *copy_data)
{
hid_t driver_id;
+ H5VL_class_t *vol_cls;
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_NAME, &vol_cls) < 0)
+ HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, FAIL, "can't get vol ID")
+ if(NULL != vol_cls) {
+ 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_cls, 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 */
@@ -523,9 +577,10 @@ done:
herr_t
H5P_facc_close(hid_t fapl_id, void UNUSED *close_data)
{
- hid_t driver_id;
+ hid_t driver_id;
+ H5VL_class_t *vol_cls;
H5P_genplist_t *plist; /* Property list */
- herr_t ret_value = SUCCEED;
+ herr_t ret_value = SUCCEED;
FUNC_ENTER_NOAPI(FAIL)
@@ -533,6 +588,19 @@ 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_NAME, &vol_cls) < 0)
+ HGOTO_DONE(FAIL) /* Can't return errors when library is shutting down */
+ if(NULL != vol_cls) {
+ 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_cls, 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 */
@@ -1950,6 +2018,171 @@ 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, H5VL_class_t *vol_cls, const void *vol_info)
+{
+ H5VL_class_t *old_vol_cls;
+ 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_NAME, &old_vol_cls) < 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_cls, 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_cls, 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 */
+ H5VL_class_t *vol_cls;
+ herr_t ret_value = SUCCEED; /* Return value */
+
+ FUNC_ENTER_API(FAIL)
+ H5TRACE2("e", "ii", plist_id, new_vol_id);
+
+ /* 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 == (vol_cls = (H5VL_class_t *)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, vol_cls, 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
@@ -2979,4 +3212,3 @@ H5P__facc_multi_type_dec(const void **_pp, void *_value)
FUNC_LEAVE_NOAPI(SUCCEED)
} /* end H5P__facc_multi_type_dec() */
-