diff options
Diffstat (limited to 'src/H5Pfapl.c')
-rw-r--r-- | src/H5Pfapl.c | 108 |
1 files changed, 96 insertions, 12 deletions
diff --git a/src/H5Pfapl.c b/src/H5Pfapl.c index 7f72c85..2d46ec7 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 */ /****************/ @@ -123,6 +126,11 @@ /* Definition for external file cache size */ #define H5F_ACS_EFC_SIZE_SIZE sizeof(unsigned) #define H5F_ACS_EFC_SIZE_DEF 0 + +/* Definition for VOL plugin */ +#define H5F_ACS_VOL_SIZE sizeof(void *) +#define H5F_ACS_VOL_DEF H5VL_NATIVE + /* 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 @@ -130,7 +138,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 */ /******************/ @@ -226,6 +233,7 @@ H5P_facc_reg_prop(H5P_genclass_t *pclass) hbool_t latest_format = H5F_ACS_LATEST_FORMAT_DEF; /* Default setting for "use the latest version of the format" flag */ hbool_t want_posix_fd = H5F_ACS_WANT_POSIX_FD_DEF; /* Default setting for retrieving 'handle' from core VFD */ unsigned efc_size = H5F_ACS_EFC_SIZE_DEF; /* Default external file cache size */ + H5VL_class_t *vol_cls = H5F_ACS_VOL_DEF; /* Default VOL plugin */ H5FD_file_image_info_t file_image_info = H5F_ACS_FILE_IMAGE_INFO_DEF; /* Default file image info and callbacks */ herr_t ret_value = SUCCEED; /* Return value */ @@ -312,6 +320,10 @@ H5P_facc_reg_prop(H5P_genclass_t *pclass) if(H5P_register_real(pclass, H5F_ACS_EFC_SIZE_NAME, H5F_ACS_EFC_SIZE_SIZE, &efc_size, 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 ID */ + if(H5P_register_real(pclass, H5F_ACS_VOL_NAME, H5F_ACS_VOL_SIZE, &vol_cls, 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 */ if(H5P_register_real(pclass, H5F_ACS_FILE_IMAGE_INFO_NAME, H5F_ACS_FILE_IMAGE_INFO_SIZE, &file_image_info, NULL, NULL, NULL, H5F_ACS_FILE_IMAGE_INFO_DEL, H5F_ACS_FILE_IMAGE_INFO_COPY, NULL, H5F_ACS_FILE_IMAGE_INFO_CLOSE) < 0) HGOTO_ERROR(H5E_PLIST, H5E_CANTINSERT, FAIL, "can't insert property into class") @@ -342,6 +354,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; @@ -351,6 +364,14 @@ 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") + + /* Set the vol for the property list */ + if(H5VL_fapl_open(plist, vol_cls) < 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") @@ -392,28 +413,38 @@ 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) { + /* Set the vp; for the destination property list */ + if(H5VL_fapl_open(dst_plist, vol_cls) < 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 */ @@ -442,9 +473,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) @@ -452,6 +484,15 @@ 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) { + /* Close the driver for the property list */ + if(H5VL_fapl_close(vol_cls) < 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 */ @@ -2119,6 +2160,50 @@ done: /*------------------------------------------------------------------------- + * Function: H5P_set_vol + * + * Purpose: Set the file vol (VOL_ID) for a file access property list + * (PLIST_ID) and supply an optional struct containing the + * vol-specific properites (VOL_INFO). The vol properties will + * be copied into the property list and the reference count on + * the vol will be incremented, allowing the caller to close the + * vol ID but still use the property list. + * + * 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) +{ + H5VL_class_t *old_vol_cls; + herr_t ret_value=SUCCEED; /* Return value */ + + FUNC_ENTER_NOAPI(FAIL) + + /* 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 ID") + + /* Close the vol for the property list */ + if(H5VL_fapl_close(old_vol_cls)<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)<0) + HGOTO_ERROR(H5E_PLIST, H5E_CANTSET, FAIL, "can't set vol") + +done: + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5P_set_vol() */ + + +/*------------------------------------------------------------------------- * Function: H5Pset_file_image * * Purpose: Sets the initial file image. Some file drivers can initialize @@ -2597,4 +2682,3 @@ H5P_file_image_info_close(const char UNUSED *name, size_t UNUSED size, void *val done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5P_file_image_info_close() */ - |