summaryrefslogtreecommitdiffstats
path: root/src/H5Pfapl.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/H5Pfapl.c')
-rw-r--r--src/H5Pfapl.c317
1 files changed, 312 insertions, 5 deletions
diff --git a/src/H5Pfapl.c b/src/H5Pfapl.c
index c3371c9..cac1f35 100644
--- a/src/H5Pfapl.c
+++ b/src/H5Pfapl.c
@@ -29,7 +29,6 @@
/****************/
#define H5P_PACKAGE /*suppress error about including H5Ppkg */
-
/***********/
/* Headers */
/***********/
@@ -39,17 +38,18 @@
#include "H5Eprivate.h" /* Error handling */
#include "H5Fprivate.h" /* Files */
#include "H5FDprivate.h" /* File drivers */
+#include "H5VLprivate.h" /* VOL plugins */
#include "H5Iprivate.h" /* IDs */
#include "H5Ppkg.h" /* Property lists */
/* 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 */
+#include "H5VLnative.h" /* Native HDF5 VOL plugin */
#ifdef H5_HAVE_WINDOWS
#include "H5FDwindows.h" /* Windows buffered I/O */
#endif
-
/****************/
/* Local Macros */
/****************/
@@ -123,6 +123,12 @@
#define H5F_ACS_EFC_SIZE_SIZE sizeof(unsigned)
#define H5F_ACS_EFC_SIZE_DEF 0
+/* Definition for vol ID */
+#define H5F_ACS_VOL_ID_SIZE sizeof(hid_t)
+#define H5F_ACS_VOL_ID_DEF H5_DEFAULT_VOL
+/* Definition for vol info */
+#define H5F_ACS_VOL_INFO_SIZE sizeof(void*)
+#define H5F_ACS_VOL_INFO_DEF NULL
/******************/
/* Local Typedefs */
@@ -215,6 +221,8 @@ 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 */
+ hid_t vol_id = H5F_ACS_VOL_ID_DEF; /* Default VOL plugin ID */
+ void *vol_info = H5F_ACS_VOL_INFO_DEF; /* Default VOL plugin info */
herr_t ret_value = SUCCEED; /* Return value */
FUNC_ENTER_NOAPI_NOINIT
@@ -300,6 +308,14 @@ 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_ID_NAME, H5F_ACS_VOL_ID_SIZE, &vol_id, 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) < 0)
+ HGOTO_ERROR(H5E_PLIST, H5E_CANTINSERT, FAIL, "can't insert property into class")
+
done:
FUNC_LEAVE_NOAPI(ret_value)
} /* end H5P_facc_reg_prop() */
@@ -325,7 +341,7 @@ done:
static herr_t
H5P_facc_create(hid_t fapl_id, void UNUSED *copy_data)
{
- hid_t driver_id;
+ hid_t driver_id, vol_id;
H5P_genplist_t *plist; /* Property list */
herr_t ret_value = SUCCEED;
@@ -339,6 +355,9 @@ H5P_facc_create(hid_t fapl_id, void UNUSED *copy_data)
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")
+ if(H5P_get(plist, H5F_ACS_VOL_ID_NAME, &vol_id) < 0)
+ HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, FAIL, "can't get vol ID")
+
if(driver_id > 0) {
void *driver_info;
@@ -351,6 +370,18 @@ H5P_facc_create(hid_t fapl_id, void UNUSED *copy_data)
HGOTO_ERROR(H5E_PLIST, H5E_CANTSET, FAIL, "can't set driver")
} /* end if */
+ if(vol_id > 0) {
+ void *vol_info;
+
+ /* Retrieve driver 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")
+ } /* end if */
+
done:
FUNC_LEAVE_NOAPI(ret_value)
} /* end H5P_facc_create() */
@@ -375,7 +406,7 @@ done:
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 driver_id, vol_id;
H5P_genplist_t *src_plist; /* Source property list */
herr_t ret_value = SUCCEED;
@@ -386,6 +417,23 @@ H5P_facc_copy(hid_t dst_fapl_id, hid_t src_fapl_id, void UNUSED *copy_data)
HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "can't get 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(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) {
+ H5P_genplist_t *dst_plist; /* Destination property list */
+ void *vol_info;
+
+ /* Get vol info from source property list */
+ if(H5P_get(src_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(NULL == (dst_plist = (H5P_genplist_t *)H5I_object(dst_fapl_id)))
+ HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "can't get 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 */
if(driver_id > 0) {
H5P_genplist_t *dst_plist; /* Destination property list */
@@ -426,7 +474,7 @@ done:
herr_t
H5P_facc_close(hid_t fapl_id, void UNUSED *close_data)
{
- hid_t driver_id;
+ hid_t driver_id, vol_id;
H5P_genplist_t *plist; /* Property list */
herr_t ret_value = SUCCEED;
@@ -440,6 +488,22 @@ H5P_facc_close(hid_t fapl_id, void UNUSED *close_data)
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 */
+ /* Get vol ID property */
+ 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;
+
+ /* Get driver info property */
+ if(H5P_get(plist, H5F_ACS_VOL_INFO_NAME, &vol_info) < 0)
+ HGOTO_DONE(FAIL) /* Can't return errors when library is shutting down */
+
+ /* 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 */
+
if(driver_id > 0) {
void *driver_info;
@@ -2101,3 +2165,246 @@ done:
FUNC_LEAVE_API(ret_value)
} /* end H5Pget_elink_file_cache_size() */
+/* MSC Begin update */
+
+/*-------------------------------------------------------------------------
+ * 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, hid_t new_vol_id, const void *new_vol_info)
+{
+ hid_t vol_id; /* VFL vol ID */
+ void *vol_info; /* VFL vol info */
+ herr_t ret_value=SUCCEED; /* Return value */
+
+ FUNC_ENTER_NOAPI(FAIL)
+
+ if(NULL == H5I_object_verify(new_vol_id, H5I_VOL))
+ HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a file vol ID")
+
+ /* Get the current vol information */
+ if(H5P_get(plist, H5F_ACS_VOL_ID_NAME, &vol_id) < 0)
+ HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, FAIL, "can't get vol ID")
+ 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 vol for the property list */
+ if(H5VL_fapl_close(vol_id, 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, new_vol_id, new_vol_info)<0)
+ HGOTO_ERROR(H5E_PLIST, H5E_CANTSET, FAIL, "can't set vol")
+
+done:
+ FUNC_LEAVE_NOAPI(ret_value)
+} /* end H5P_set_vol() */
+
+
+/*-------------------------------------------------------------------------
+ * Function: H5P_get_vol
+ *
+ * Purpose: Return the ID of the vol plugin. PLIST_ID should
+ * be a file access property list.
+ *
+ * Return: Success: VOL ID
+ *
+ * Failure: Negative
+ *
+ * Programmer: Mohamad Chaarawi
+ * January, 2012
+ *
+ *-------------------------------------------------------------------------
+ */
+hid_t
+H5P_get_vol(H5P_genplist_t *plist)
+{
+ hid_t ret_value=FAIL; /* Return value */
+
+ FUNC_ENTER_NOAPI(FAIL);
+
+ /* Get the current vol ID */
+ if(TRUE == H5P_isa_class(plist->plist_id, H5P_FILE_ACCESS) ) {
+ if(H5P_get(plist, H5F_ACS_VOL_ID_NAME, &ret_value) < 0)
+ HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, FAIL, "can't get vol ID");
+ } else {
+ HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a file access or data transfer property list");
+ }
+
+ if (H5VL_VOL_DEFAULT==ret_value)
+ ret_value = H5_DEFAULT_VOL;
+
+done:
+ FUNC_LEAVE_NOAPI(ret_value);
+}
+
+
+/*-------------------------------------------------------------------------
+ * Function: H5P_get_vol_info
+ *
+ * Purpose: Returns a pointer directly to the vol-specific
+ * information of a fapl.
+ * 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
+ * January, 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() */
+
+#if 0
+
+/*-------------------------------------------------------------------------
+ * Function: H5Pset_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
+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_VFL))
+ HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a 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 info")
+
+done:
+ FUNC_LEAVE_API(ret_value)
+} /* end H5Pset_vol() */
+
+
+/*-------------------------------------------------------------------------
+ * Function: H5Pget_vol_info
+ *
+ * Purpose: Returns a pointer directly to the vol-specific
+ * information of a fapl.
+ * 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
+ * January, 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: H5Pget_vol
+ *
+ * Purpose: Return the ID of the vol plugin. PLIST_ID should
+ * be a file access property list.
+ *
+ * Return: Success: VOL ID
+ *
+ * Failure: Negative
+ *
+ * Programmer: Mohamad Chaarawi
+ * January, 2012
+ *
+ *-------------------------------------------------------------------------
+ */
+hid_t
+H5Pget_vol(hid_t plist_id)
+{
+ H5P_genplist_t *plist; /* Property list pointer */
+ hid_t ret_value; /* Return value */
+
+ FUNC_ENTER_API(FAIL)
+ H5TRACE1("i", "i", plist_id);
+
+ 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")
+
+ ret_value = H5P_get_vol(plist);
+
+done:
+ FUNC_LEAVE_API(ret_value)
+} /* end H5Pget_vol() */
+
+#endif