From c614ba6fccbd3e665d2bd91c23e7f129e01b8f27 Mon Sep 17 00:00:00 2001 From: Mohamad Chaarawi Date: Tue, 7 Feb 2012 17:06:25 -0500 Subject: [svn-r21915] starting to set up vol framework fopen, fclose, fcreate routed through native vol --- src/H5Edefin.h | 1 + src/H5Einit.h | 5 + src/H5Epubgen.h | 2 + src/H5F.c | 40 +++- src/H5Fpkg.h | 2 + src/H5Fprivate.h | 3 + src/H5Iprivate.h | 1 + src/H5Ipublic.h | 1 + src/H5Pfapl.c | 317 ++++++++++++++++++++++++- src/H5Pprivate.h | 4 + src/H5Ppublic.h | 5 + src/H5VL.c | 698 ++++++++++++++++++++++++++++++++++++++++++++++++++++++ src/H5VLnative.c | 304 ++++++++++++++++++++++++ src/H5VLnative.h | 38 +++ src/H5VLpkg.h | 65 +++++ src/H5VLprivate.h | 56 +++++ src/H5VLpublic.h | 136 +++++++++++ src/H5config.h.in | 3 + src/Makefile.am | 2 + src/Makefile.in | 16 +- 20 files changed, 1680 insertions(+), 19 deletions(-) create mode 100644 src/H5VL.c create mode 100644 src/H5VLnative.c create mode 100644 src/H5VLnative.h create mode 100644 src/H5VLpkg.h create mode 100644 src/H5VLprivate.h create mode 100644 src/H5VLpublic.h diff --git a/src/H5Edefin.h b/src/H5Edefin.h index 887c2bb..7fa8b12 100644 --- a/src/H5Edefin.h +++ b/src/H5Edefin.h @@ -26,6 +26,7 @@ hid_t H5E_FILE_g = FAIL; /* File accessability */ hid_t H5E_SOHM_g = FAIL; /* Shared Object Header Messages */ hid_t H5E_SYM_g = FAIL; /* Symbol table */ hid_t H5E_VFL_g = FAIL; /* Virtual File Layer */ +hid_t H5E_VOL_g = FAIL; /* Virtual Object Layer */ hid_t H5E_INTERNAL_g = FAIL; /* Internal error (too specific to document in detail) */ hid_t H5E_BTREE_g = FAIL; /* B-Tree node */ hid_t H5E_REFERENCE_g = FAIL; /* References */ diff --git a/src/H5Einit.h b/src/H5Einit.h index 802c94a..7022297 100644 --- a/src/H5Einit.h +++ b/src/H5Einit.h @@ -49,6 +49,11 @@ if((msg = H5E_create_msg(cls, H5E_MAJOR, "Virtual File Layer"))==NULL) HGOTO_ERROR(H5E_ERROR, H5E_CANTINIT, FAIL, "error message initialization failed") if((H5E_VFL_g = H5I_register(H5I_ERROR_MSG, msg, FALSE))<0) HGOTO_ERROR(H5E_ERROR, H5E_CANTREGISTER, FAIL, "can't register error message") +assert(H5E_VOL_g==(-1)); +if((msg = H5E_create_msg(cls, H5E_MAJOR, "Virtual Object Layer"))==NULL) + HGOTO_ERROR(H5E_ERROR, H5E_CANTINIT, FAIL, "error message initialization failed") +if((H5E_VOL_g = H5I_register(H5I_ERROR_MSG, msg, FALSE))<0) + HGOTO_ERROR(H5E_ERROR, H5E_CANTREGISTER, FAIL, "can't register error message") assert(H5E_INTERNAL_g==(-1)); if((msg = H5E_create_msg(cls, H5E_MAJOR, "Internal error (too specific to document in detail)"))==NULL) HGOTO_ERROR(H5E_ERROR, H5E_CANTINIT, FAIL, "error message initialization failed") diff --git a/src/H5Epubgen.h b/src/H5Epubgen.h index f6a20f2..12771b2 100644 --- a/src/H5Epubgen.h +++ b/src/H5Epubgen.h @@ -29,6 +29,7 @@ #define H5E_SOHM (H5OPEN H5E_SOHM_g) #define H5E_SYM (H5OPEN H5E_SYM_g) #define H5E_VFL (H5OPEN H5E_VFL_g) +#define H5E_VOL (H5OPEN H5E_VOL_g) #define H5E_INTERNAL (H5OPEN H5E_INTERNAL_g) #define H5E_BTREE (H5OPEN H5E_BTREE_g) #define H5E_REFERENCE (H5OPEN H5E_REFERENCE_g) @@ -61,6 +62,7 @@ H5_DLLVAR hid_t H5E_FILE_g; /* File accessability */ H5_DLLVAR hid_t H5E_SOHM_g; /* Shared Object Header Messages */ H5_DLLVAR hid_t H5E_SYM_g; /* Symbol table */ H5_DLLVAR hid_t H5E_VFL_g; /* Virtual File Layer */ +H5_DLLVAR hid_t H5E_VOL_g; /* Virtual Object Layer */ H5_DLLVAR hid_t H5E_INTERNAL_g; /* Internal error (too specific to document in detail) */ H5_DLLVAR hid_t H5E_BTREE_g; /* B-Tree node */ H5_DLLVAR hid_t H5E_REFERENCE_g; /* References */ diff --git a/src/H5F.c b/src/H5F.c index c8f68f8..b4eaf1c 100644 --- a/src/H5F.c +++ b/src/H5F.c @@ -27,6 +27,7 @@ #include "H5Eprivate.h" /* Error handling */ #include "H5Fpkg.h" /* File access */ #include "H5FDprivate.h" /* File drivers */ +#include "H5VLprivate.h" /* VOL plugins */ #include "H5Gprivate.h" /* Groups */ #include "H5Iprivate.h" /* IDs */ #include "H5MFprivate.h" /* File memory management */ @@ -59,7 +60,6 @@ static H5F_t *H5F_new(H5F_file_t *shared, hid_t fcpl_id, hid_t fapl_id, static herr_t H5F_build_actual_name(const H5F_t *f, const H5P_genplist_t *fapl, const char *name, char ** /*out*/ actual_name); static herr_t H5F_dest(H5F_t *f, hid_t dxpl_id, hbool_t flush); -static herr_t H5F_close(H5F_t *f); /* Declare a free list to manage the H5F_t struct */ H5FL_DEFINE(H5F_t); @@ -117,7 +117,7 @@ H5F_init_interface(void) /* * Initialize the atom group for the file IDs. */ - if(H5I_register_type(H5I_FILE, (size_t)H5I_FILEID_HASHSIZE, 0, (H5I_free_t)H5F_close)shared->lf->driver_id)) < 0) HGOTO_ERROR(H5E_PLIST, H5E_CANTSET, FAIL, "can't set file driver ID") + /* Increment the reference count on the VOL ID and insert it into the property list */ + if(H5I_inc_ref(f->vol_id, FALSE) < 0) + HGOTO_ERROR(H5E_FILE, H5E_CANTINC, FAIL, "unable to increment ref count on VOL") + if(H5P_set(new_plist, H5F_ACS_VOL_ID_NAME, &(f->vol_id)) < 0) + HGOTO_ERROR(H5E_PLIST, H5E_CANTSET, FAIL, "can't set file VOL ID") + /* Set the driver "info" in the property list */ driver_info = H5FD_fapl_get(f->shared->lf); if(driver_info != NULL && H5P_set(new_plist, H5F_ACS_FILE_DRV_INFO_NAME, &driver_info) < 0) HGOTO_ERROR(H5E_PLIST, H5E_CANTSET, FAIL, "can't set file driver info") + /* Set the vol "info" in the property list */ + /* MSC - can't do that yet + vol_info = H5VL_fapl_get(f); + if(vol_info != NULL && H5P_set(new_plist, H5F_ACS_VOL_INFO_NAME, &vol_info) < 0) + HGOTO_ERROR(H5E_PLIST, H5E_CANTSET, FAIL, "can't set vol info") + */ /* Set the file close degree appropriately */ if(f->shared->fc_degree == H5F_CLOSE_DEFAULT && H5P_set(new_plist, H5F_ACS_CLOSE_DEGREE_NAME, &(f->shared->lf->cls->fc_degree)) < 0) { HGOTO_ERROR(H5E_PLIST, H5E_CANTSET, FAIL, "can't set file close degree") @@ -661,6 +673,7 @@ H5F_get_objects_cb(void *obj_ptr, hid_t obj_id, void *key) case H5I_DATASPACE: case H5I_REFERENCE: case H5I_VFL: + case H5I_VOL: case H5I_GENPROP_CLS: case H5I_GENPROP_LST: case H5I_ERROR_CLASS: @@ -1429,9 +1442,12 @@ H5Fcreate(const char *filename, unsigned flags, hid_t fcpl_id, hid_t fapl_id) /* * Create a new file or truncate an existing file. */ + if(NULL == (new_file = H5VL_create(filename, flags, fcpl_id, fapl_id))) + HGOTO_ERROR(H5E_FILE, H5E_CANTOPENFILE, FAIL, "unable to create file") + /* if(NULL == (new_file = H5F_open(filename, flags, fcpl_id, fapl_id, H5AC_dxpl_id))) HGOTO_ERROR(H5E_FILE, H5E_CANTOPENFILE, FAIL, "unable to create file") - + */ /* Get an atom for the file */ if((ret_value = H5I_register(H5I_FILE, new_file, TRUE)) < 0) HGOTO_ERROR(H5E_ATOM, H5E_CANTREGISTER, FAIL, "unable to atomize file") @@ -1441,9 +1457,12 @@ H5Fcreate(const char *filename, unsigned flags, hid_t fcpl_id, hid_t fapl_id) done: if(ret_value < 0 && new_file) + if(H5VL_close(new_file) < 0) + HDONE_ERROR(H5E_FILE, H5E_CANTCLOSEFILE, FAIL, "problems closing file") + /* if(H5F_close(new_file) < 0) HDONE_ERROR(H5E_FILE, H5E_CANTCLOSEFILE, FAIL, "problems closing file") - + */ FUNC_LEAVE_API(ret_value) } /* end H5Fcreate() */ @@ -1491,8 +1510,8 @@ done: hid_t H5Fopen(const char *filename, unsigned flags, hid_t fapl_id) { - H5F_t *new_file = NULL; /*file struct for new file */ - hid_t ret_value; /*return value */ + H5F_t *new_file = NULL; /*file struct for new file */ + hid_t ret_value; /*return value */ FUNC_ENTER_API(H5Fopen, FAIL) H5TRACE3("i", "*sIui", filename, flags, fapl_id); @@ -1511,9 +1530,13 @@ H5Fopen(const char *filename, unsigned flags, hid_t fapl_id) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not file access property list") /* Open the file */ - if(NULL == (new_file = H5F_open(filename, flags, H5P_FILE_CREATE_DEFAULT, fapl_id, H5AC_dxpl_id))) + if(NULL == (new_file = H5VL_open(filename, flags, fapl_id))) HGOTO_ERROR(H5E_FILE, H5E_CANTOPENFILE, FAIL, "unable to open file") + /* Open the file + if(NULL == (new_file = H5F_open(filename, flags, H5P_FILE_CREATE_DEFAULT, fapl_id, H5AC_dxpl_id))) + HGOTO_ERROR(H5E_FILE, H5E_CANTOPENFILE, FAIL, "unable to open file") + */ /* Get an atom for the file */ if((ret_value = H5I_register(H5I_FILE, new_file, TRUE)) < 0) HGOTO_ERROR(H5E_ATOM, H5E_CANTREGISTER, FAIL, "unable to atomize file handle") @@ -1604,6 +1627,7 @@ H5Fflush(hid_t object_id, H5F_scope_t scope) case H5I_DATASPACE: case H5I_REFERENCE: case H5I_VFL: + case H5I_VOL: case H5I_GENPROP_CLS: case H5I_GENPROP_LST: case H5I_ERROR_CLASS: @@ -1731,7 +1755,7 @@ done: * *------------------------------------------------------------------------- */ -static herr_t +herr_t H5F_close(H5F_t *f) { herr_t ret_value = SUCCEED; /* Return value */ diff --git a/src/H5Fpkg.h b/src/H5Fpkg.h index 334879c..bb6cc4e 100644 --- a/src/H5Fpkg.h +++ b/src/H5Fpkg.h @@ -274,6 +274,8 @@ struct H5F_t { hbool_t closing; /* File is in the process of being closed */ struct H5F_t *parent; /* Parent file that this file is mounted to */ unsigned nmounts; /* Number of children mounted to this file */ + hid_t vol_id; /* id of the vol plugin used to open the file */ + //H5VL_class_t vol_cls; /* class of the VOL plugin */ }; diff --git a/src/H5Fprivate.h b/src/H5Fprivate.h index 868674f..776f349 100644 --- a/src/H5Fprivate.h +++ b/src/H5Fprivate.h @@ -408,7 +408,9 @@ typedef struct H5F_blk_aggr_t H5F_blk_aggr_t; #define H5F_ACS_SDATA_BLOCK_SIZE_NAME "sdata_block_size" /* Minimum "small data" allocation block size (when aggregating "small" raw data allocations) */ #define H5F_ACS_GARBG_COLCT_REF_NAME "gc_ref" /* Garbage-collect references */ #define H5F_ACS_FILE_DRV_ID_NAME "driver_id" /* File driver ID */ +#define H5F_ACS_VOL_ID_NAME "vol_id" /* File VOL ID */ #define H5F_ACS_FILE_DRV_INFO_NAME "driver_info" /* File driver info */ +#define H5F_ACS_VOL_INFO_NAME "vol_info" /* File VOL info */ #define H5F_ACS_CLOSE_DEGREE_NAME "close_degree" /* File close degree */ #define H5F_ACS_FAMILY_OFFSET_NAME "family_offset" /* Offset position in file for family file driver */ #define H5F_ACS_FAMILY_NEWSIZE_NAME "family_newsize" /* New member size of family driver. (private property only used by h5repart) */ @@ -511,6 +513,7 @@ struct H5HG_heap_t; /* Private functions */ H5_DLL H5F_t *H5F_open(const char *name, unsigned flags, hid_t fcpl_id, hid_t fapl_id, hid_t dxpl_id); +H5_DLL herr_t H5F_close(H5F_t *f); H5_DLL herr_t H5F_try_close(H5F_t *f); /* Functions than retrieve values from the file struct */ diff --git a/src/H5Iprivate.h b/src/H5Iprivate.h index 98423df..0695860 100644 --- a/src/H5Iprivate.h +++ b/src/H5Iprivate.h @@ -43,6 +43,7 @@ #define H5I_ATTRID_HASHSIZE 64 #define H5I_REFID_HASHSIZE 64 #define H5I_VFL_HASHSIZE 64 +#define H5I_VOL_HASHSIZE 64 #define H5I_GENPROPCLS_HASHSIZE 64 #define H5I_GENPROPOBJ_HASHSIZE 128 #define H5I_ERRCLS_HASHSIZE 64 diff --git a/src/H5Ipublic.h b/src/H5Ipublic.h index d630556..672e608 100644 --- a/src/H5Ipublic.h +++ b/src/H5Ipublic.h @@ -44,6 +44,7 @@ typedef enum H5I_type_t { H5I_ATTR, /*type ID for Attribute objects */ H5I_REFERENCE, /*type ID for Reference objects */ H5I_VFL, /*type ID for virtual file layer */ + H5I_VOL, /*type ID for virtual object layer */ H5I_GENPROP_CLS, /*type ID for generic property list classes */ H5I_GENPROP_LST, /*type ID for generic property lists */ H5I_ERROR_CLASS, /*type ID for error classes */ diff --git a/src/H5Pfapl.c b/src/H5Pfapl.c index 7dea0b2..f24d6b6 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(H5P_facc_reg_prop) @@ -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(H5P_set_vol, 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(H5P_get_vol, 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(H5P_get_vol_info, 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(H5Pset_vol, 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(H5Pget_vol_info, 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(H5Pget_vol, 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 diff --git a/src/H5Pprivate.h b/src/H5Pprivate.h index ab3f1d0..5fa35a7 100644 --- a/src/H5Pprivate.h +++ b/src/H5Pprivate.h @@ -74,6 +74,10 @@ H5_DLL hid_t H5P_get_driver(H5P_genplist_t *plist); H5_DLL void * H5P_get_driver_info(H5P_genplist_t *plist); H5_DLL herr_t H5P_set_driver(H5P_genplist_t *plist, hid_t new_driver_id, const void *new_driver_info); +H5_DLL hid_t H5P_get_vol(H5P_genplist_t *plist); +H5_DLL void * H5P_get_vol_info(H5P_genplist_t *plist); +H5_DLL herr_t H5P_set_vol(H5P_genplist_t *plist, hid_t new_driver_id, + const void *new_driver_info); H5_DLL herr_t H5P_set_vlen_mem_manager(H5P_genplist_t *plist, H5MM_allocate_t alloc_func, void *alloc_info, H5MM_free_t free_func, void *free_info); diff --git a/src/H5Ppublic.h b/src/H5Ppublic.h index d4441a3..4c812cc 100644 --- a/src/H5Ppublic.h +++ b/src/H5Ppublic.h @@ -290,6 +290,11 @@ H5_DLL herr_t H5Pset_driver(hid_t plist_id, hid_t driver_id, const void *driver_info); H5_DLL hid_t H5Pget_driver(hid_t plist_id); H5_DLL void *H5Pget_driver_info(hid_t plist_id); +/* +H5_DLL herr_t H5Pset_vol(hid_t plist_id, hid_t vol_id, const void *vol_info); +H5_DLL hid_t H5Pget_vol(hid_t plist_id); +H5_DLL void *H5Pget_vol_info(hid_t plist_id); +*/ H5_DLL herr_t H5Pset_family_offset(hid_t fapl_id, hsize_t offset); H5_DLL herr_t H5Pget_family_offset(hid_t fapl_id, hsize_t *offset); H5_DLL herr_t H5Pset_multi_type(hid_t fapl_id, H5FD_mem_t type); diff --git a/src/H5VL.c b/src/H5VL.c new file mode 100644 index 0000000..7fb6065 --- /dev/null +++ b/src/H5VL.c @@ -0,0 +1,698 @@ +/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * + * Copyright by The HDF Group. * + * Copyright by the Board of Trustees of the University of Illinois. * + * All rights reserved. * + * * + * This file is part of HDF5. The full HDF5 copyright notice, including * + * terms governing use, modification, and redistribution, is contained in * + * the files COPYING and Copyright.html. COPYING can be found at the root * + * of the source code distribution tree; Copyright.html can be found at the * + * root level of an installed copy of the electronic HDF5 document set and * + * is linked from the top-level documents page. It can also be found at * + * http://hdfgroup.org/HDF5/doc/Copyright.html. If you do not have * + * access to either file, you may request a copy from help@hdfgroup.org. * + * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ + +/* + * Programmer: Mohamad Chaarawi + * January, 2012 + * + * Purpose: The Virtual Object Layer as described in documentation. + * The pupose is to provide an abstraction on how to access the + * underlying HDF5 container, whether in a local file with + * a specific file format, or remotely on other machines, etc... + */ + +/****************/ +/* Module Setup */ +/****************/ + +#define H5F_PACKAGE /*suppress error about including H5Fpkg */ +#define H5VL_PACKAGE /*suppress error about including H5FDpkg */ + +/* Interface initialization */ +#define H5_INTERFACE_INIT_FUNC H5VL_init_interface + +/***********/ +/* Headers */ +/***********/ +#include "H5private.h" /* Generic Functions */ +#include "H5Dprivate.h" /* Datasets */ +#include "H5Eprivate.h" /* Error handling */ +#include "H5VLpkg.h" /* VOL package header */ +#include "H5VLprivate.h" /* VOL */ +#include "H5Fpkg.h" /* File access */ +#include "H5Iprivate.h" /* IDs */ +#include "H5MMprivate.h" /* Memory management */ +#include "H5Pprivate.h" /* Property lists */ + +/********************/ +/* Local Prototypes */ +/********************/ +static herr_t H5VL_free_cls(H5VL_class_t *cls); + + +/*------------------------------------------------------------------------- + * Function: H5VL_init + * + * Purpose: Initialize the interface from some other package. + * + * Return: Success: non-negative + * Failure: negative + * + * Programmer: Mohamad Chaarawi + * January, 2012 + * + *------------------------------------------------------------------------- + */ +herr_t +H5VL_init(void) +{ + herr_t ret_value = SUCCEED; /* Return value */ + + FUNC_ENTER_NOAPI(H5VL_init, FAIL) + /* FUNC_ENTER() does all the work */ + +done: + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5VL_init() */ + + +/*------------------------------------------------------------------------- + * Function: H5VL_init_interface + * + * Purpose: Initialize the virtual object layer. + * + * Return: Success: Non-negative + * + * Failure: Negative + * + * Programmer: Mohamad Chaarawi + * January, 2012 + * + * Modifications: + * + *------------------------------------------------------------------------- + */ +static herr_t +H5VL_init_interface(void) +{ + herr_t ret_value = SUCCEED; /* Return value */ + + FUNC_ENTER_NOAPI_NOINIT(H5VL_init_interface) + + if(H5I_register_type(H5I_VOL, (size_t)H5I_VOL_HASHSIZE, 0, (H5I_free_t)H5VL_free_cls)terminate && cls->terminate() < 0) + HGOTO_ERROR(H5E_VOL, H5E_CANTCLOSEOBJ, FAIL, "vol plugin '%s' did not terminate cleanly", cls->name) + + H5MM_xfree(cls); + +done: + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5VL_free_cls() */ + + +/*------------------------------------------------------------------------- + * Function: H5VLregister + * + * Purpose: Registers a new vol plugin as a member of the virtual object + * layer class. + * + * Return: Success: A vol plugin ID which is good until the + * library is closed or the plugin is + * unregistered. + * + * Failure: A negative value. + * + * Programmer: Mohamad Chaarawi + * January, 2012 + * + *------------------------------------------------------------------------- + */ +hid_t +H5VLregister(const H5VL_class_t *cls) +{ + hid_t ret_value; + + FUNC_ENTER_API(H5VLregister, FAIL) + H5TRACE1("i", "*x", cls); + + /* Check arguments */ + if(!cls) + HGOTO_ERROR(H5E_ARGS, H5E_UNINITIALIZED, FAIL, "null class pointer is disallowed") + /* MSC - check if required callback are defined */ + + /* Create the new class ID */ + if((ret_value=H5VL_register(cls, sizeof(H5VL_class_t), TRUE)) < 0) + HGOTO_ERROR(H5E_ATOM, H5E_CANTREGISTER, FAIL, "unable to register vol plugin ID") + +done: + FUNC_LEAVE_API(ret_value) +} /* end H5VLregister() */ + + +/*------------------------------------------------------------------------- + * Function: H5VL_register + * + * Purpose: Registers a new vol plugin as a member of the virtual object + * layer class. + * + * Return: Success: A vol plugin ID which is good until the + * library is closed or the driver is + * unregistered. + * + * Failure: A negative value. + * + * Programmer: Mohamad Chaarawi + * January, 2012 + *------------------------------------------------------------------------- + */ +hid_t +H5VL_register(const void *_cls, size_t size, hbool_t app_ref) +{ + const H5VL_class_t *cls = (const H5VL_class_t *)_cls; + H5VL_class_t *saved = NULL; + hid_t ret_value; + + FUNC_ENTER_NOAPI(H5VL_register, FAIL) + + /* Check arguments */ + HDassert(cls); + /*MSC - check required funciton pointers */ + + /* Copy the class structure so the caller can reuse or free it */ + if(NULL == (saved = (H5VL_class_t *)H5MM_malloc(size))) + HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, FAIL, + "memory allocation failed for vol plugin class struct") + HDmemcpy(saved, cls, size); + + /* Create the new class ID */ + if((ret_value = H5I_register(H5I_VFL, saved, app_ref)) < 0) + HGOTO_ERROR(H5E_ATOM, H5E_CANTREGISTER, FAIL, "unable to register vol plugin ID") + +done: + if(ret_value < 0) + if(saved) + H5MM_xfree(saved); + + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5VL_register() */ + + +/*------------------------------------------------------------------------- + * Function: H5VLunregister + * + * Purpose: Removes a vol plugin ID from the library. This in no way affects + * file access property lists which have been defined to use + * this vol plugin or files which are already opened under with + * this plugin. + * + * Return: Success: Non-negative + * + * Failure: Negative + * + * Programmer: Mohamad Chaarawi + * January, 2012 + * + *------------------------------------------------------------------------- + */ +herr_t +H5VLunregister(hid_t vol_id) +{ + herr_t ret_value = SUCCEED; /* Return value */ + + FUNC_ENTER_API(H5VLunregister, FAIL) + H5TRACE1("e", "i", vol_id); + + /* Check arguments */ + if(NULL == H5I_object_verify(vol_id, H5I_VFL)) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a vol plugin") + + /* The H5VL_class_t struct will be freed by this function */ + if(H5I_dec_app_ref(vol_id) < 0) + HGOTO_ERROR(H5E_VFL, H5E_CANTDEC, FAIL, "unable to unregister vol plugin") + +done: + FUNC_LEAVE_API(ret_value) +} /* end H5VLunregister() */ + + +/*------------------------------------------------------------------------- + * Function: H5VL_get_class + * + * Purpose: Obtains a pointer to the vol plugin struct containing all the + * callback pointers, etc. The PLIST_ID argument can be a file + * access property list or a vol plugin identifier. + * + * Return: Success: Ptr to the vol plugin information. The pointer is + * only valid as long as the vol plugin remains + * registered or some file or property list + * exists which references the vol plugin. + * + * Failure: NULL + * + * Programmer: Mohamad Chaarawi + * January, 2012 + * + *------------------------------------------------------------------------- + */ +H5VL_class_t * +H5VL_get_class(hid_t id) +{ + H5VL_class_t *ret_value = NULL; + + FUNC_ENTER_NOAPI(H5VL_get_class, NULL) + + if(H5I_VFL == H5I_get_type(id)) + ret_value = (H5VL_class_t *)H5I_object(id); + else { + H5P_genplist_t *plist; /* Property list pointer */ + hid_t vol_id = -1; + + /* Get the plist structure */ + if(NULL == (plist = (H5P_genplist_t *)H5I_object(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_VOL_ID_NAME, &vol_id) < 0) + HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, NULL, "can't get vol ID") + ret_value = H5VL_get_class(vol_id); + } else { + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, NULL, "not a vol plugin id, file access property list") + } + } /* end if */ + +done: + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5VL_get_class() */ + +#if 0 /* MSC not needed */ + +/*------------------------------------------------------------------------- + * Function: H5VL_sb_size + * + * Purpose: Obtains the number of bytes required to store the vol plugin + * file access data in the HDF5 superblock. + * + * Return: Success: Number of bytes required. + * + * Failure: 0 if an error occurs or if the vol plugin has no + * data to store in the superblock. + * + * Programmer: Mohamad Chaarawi + * January, 2012 + * + * Modifications: + * + *------------------------------------------------------------------------- + */ +hsize_t +H5VL_sb_size(H5F_t *file) +{ + hsize_t ret_value=0; + + FUNC_ENTER_NOAPI(H5VL_sb_size, 0) + + assert(file && file->cls); + + if(file->cls->sb_size) + ret_value = (file->cls->sb_size)(file); + +done: + FUNC_LEAVE_NOAPI(ret_value) +} +#endif + +/*------------------------------------------------------------------------- + * Function: H5VL_fapl_open + * + * Purpose: Mark a vol as used by a file access property list + * + * Return: Success: non-negative + * + * Failure: negative + * + * Programmer: Mohamad Chaarawi + * January, 2012 + * + * Modifications: + * + *------------------------------------------------------------------------- + */ +herr_t +H5VL_fapl_open(H5P_genplist_t *plist, hid_t vol_id, const void *vol_info) +{ + void *copied_vol_info = NULL; /* Temporary VFL vol info */ + herr_t ret_value = SUCCEED; /* Return value */ + + FUNC_ENTER_NOAPI(H5VL_fapl_open, FAIL) + + /* Increment the reference count on vol and copy vol info */ + if(H5I_inc_ref(vol_id, FALSE) < 0) + HGOTO_ERROR(H5E_FILE, H5E_CANTINC, FAIL, "unable to increment ref count on vol plugin") + if(H5VL_fapl_copy(vol_id, vol_info, &copied_vol_info) < 0) + HGOTO_ERROR(H5E_FILE, H5E_CANTCOPY, FAIL, "can't copy vol info") + + /* Set the vol properties for the list */ + if(H5P_set(plist, H5F_ACS_VOL_ID_NAME, &vol_id) < 0) + HGOTO_ERROR(H5E_FILE, H5E_CANTSET, FAIL, "can't set vol ID") + if(H5P_set(plist, H5F_ACS_VOL_INFO_NAME, &copied_vol_info) < 0) + HGOTO_ERROR(H5E_FILE, H5E_CANTSET, FAIL, "can't set vol info") + copied_vol_info = NULL; + +done: + if(ret_value < 0) + if(copied_vol_info && H5VL_fapl_close(vol_id, copied_vol_info) < 0) + HDONE_ERROR(H5E_FILE, H5E_CANTCLOSEOBJ, FAIL, "can't close copy of vol info") + + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5VL_fapl_open() */ + + +/*------------------------------------------------------------------------- + * Function: H5VL_fapl_copy + * + * Purpose: Copies the vol-specific part of the file access property + * list. + * + * Return: Success: non-negative + * + * Failure: negative + * + * Programmer: Mohamad Chaarawi + * January, 2012 + * + * Modifications: + * + *------------------------------------------------------------------------- + */ +herr_t +H5VL_fapl_copy(hid_t vol_id, const void *old_fapl, void **copied_fapl) +{ + H5VL_class_t *vol; + void *new_pl = NULL; /* Copy of property list */ + herr_t ret_value = SUCCEED; /* Return value */ + + FUNC_ENTER_NOAPI(H5VL_fapl_copy, FAIL) + + /* Check args */ + if(NULL == (vol = (H5VL_class_t *)H5I_object(vol_id))) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a vol ID") + + /* Copy the file access property list */ + if(old_fapl) { + if(vol->fapl_copy) { + new_pl = (vol->fapl_copy)(old_fapl); + if(new_pl==NULL) + HGOTO_ERROR(H5E_VOL, H5E_NOSPACE, FAIL, "property list copy failed") + } + else if(vol->fapl_size > 0) { + if((new_pl = H5MM_malloc(vol->fapl_size))==NULL) + HGOTO_ERROR(H5E_VOL, H5E_NOSPACE, FAIL, "property list allocation failed") + HDmemcpy(new_pl, old_fapl, vol->fapl_size); + } else + HGOTO_ERROR(H5E_VOL, H5E_UNSUPPORTED, FAIL, "no way to copy vol property list") + } /* end if */ + + /* Set copied value */ + *copied_fapl=new_pl; + +done: + FUNC_LEAVE_NOAPI(ret_value) +} + + +/*------------------------------------------------------------------------- + * Function: H5VL_fapl_close + * + * Purpose: Closes a vol for a property list + * + * Return: Success: non-negative + * Failure: negative + * + * Programmer: Mohamad Chaarawi + * January, 2012 + * + * Modifications: + * + *------------------------------------------------------------------------- + */ +herr_t +H5VL_fapl_close(hid_t vol_id, void *fapl) +{ + H5VL_class_t *vol = NULL; + herr_t ret_value = SUCCEED; /* Return value */ + + FUNC_ENTER_NOAPI(H5VL_fapl_close, FAIL) + + /* Check args */ + if(vol_id > 0) { + if(NULL == (vol = (H5VL_class_t *)H5I_object(vol_id))) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a vol ID") + + /* Allow driver to free or do it ourselves */ + if(fapl && vol->fapl_free) { + if((vol->fapl_free)(fapl) < 0) + HGOTO_ERROR(H5E_VOL, H5E_CANTINIT, FAIL, "driver free request failed") + } /* end if */ + else + H5MM_xfree(fapl); + + /* Decrement reference count for driver */ + if(H5I_dec_ref(vol_id) < 0) + HGOTO_ERROR(H5E_VOL, H5E_CANTDEC, FAIL, "can't decrement reference count for vol plugin") + } /* end if */ + +done: + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5VL_fapl_close() */ + + +/*------------------------------------------------------------------------- + * Function: H5VL_open + * + * Purpose: Private version of H5VLopen() + * + * Return: Success: Pointer to a new file struct + * + * Failure: NULL + * + * Programmer: Mohamad Chaarawi + * January, 2012 + * + *------------------------------------------------------------------------- + */ +H5F_t * +H5VL_open(const char *name, unsigned flags, hid_t fapl_id) +{ + H5VL_class_t *vol_plugin; /* VOL for file */ + H5F_t *file = NULL; /* VOL file struct */ + hid_t plugin_id = -1; /* VOL ID */ + H5P_genplist_t *plist; /* Property list pointer */ + H5F_t *ret_value; /* Return value */ + + FUNC_ENTER_NOAPI(H5VL_open, NULL) + + if(NULL == (plist = (H5P_genplist_t *)H5I_object(fapl_id))) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, NULL, "not a file access property list") + if(H5P_get(plist, H5F_ACS_VOL_ID_NAME, &plugin_id) < 0) + HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, NULL, "can't get vol plugin ID") + if(NULL == (vol_plugin = (H5VL_class_t *)H5I_object(plugin_id))) + HGOTO_ERROR(H5E_VOL, H5E_BADVALUE, NULL, "invalid vol plugin ID in file access property list") + + if(NULL == vol_plugin->file_cls.open) + HGOTO_ERROR(H5E_VOL, H5E_UNSUPPORTED, NULL, "vol plugin has no `file open' method") + if(NULL == (file = (vol_plugin->file_cls.open)(name, flags, fapl_id))) + HGOTO_ERROR(H5E_VOL, H5E_CANTINIT, NULL, "open failed") + + /* + * Fill in public fields. We must increment the reference count on the + * vol plugin ID to prevent it from being freed while this file is open. + */ + file->vol_id = plugin_id; + if(H5I_inc_ref(file->vol_id, FALSE) < 0) + HGOTO_ERROR(H5E_VOL, H5E_CANTINC, NULL, "unable to increment ref count on VOL plugin") + //file->vol_cls = vol_plugin; + + /* Set return value */ + ret_value = file; + +done: + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5VL_open() */ + + +/*------------------------------------------------------------------------- + * Function: H5VL_create + * + * Purpose: Private version of H5VLcreate() + * + * Return: Success: Pointer to a new file struct + * + * Failure: NULL + * + * Programmer: Mohamad Chaarawi + * January, 2012 + * + *------------------------------------------------------------------------- + */ +H5F_t * +H5VL_create(const char *name, unsigned flags, hid_t fcpl_id, hid_t fapl_id) +{ + H5VL_class_t *vol_plugin; /* VOL for file */ + H5F_t *file = NULL; /* VOL file struct */ + hid_t plugin_id = -1; /* VOL ID */ + H5P_genplist_t *plist; /* Property list pointer */ + H5F_t *ret_value; /* Return value */ + + FUNC_ENTER_NOAPI(H5VL_create, NULL) + + if(NULL == (plist = (H5P_genplist_t *)H5I_object(fapl_id))) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, NULL, "not a file access property list") + if(H5P_get(plist, H5F_ACS_VOL_ID_NAME, &plugin_id) < 0) + HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, NULL, "can't get vol plugin ID") + if(NULL == (vol_plugin = (H5VL_class_t *)H5I_object(plugin_id))) + HGOTO_ERROR(H5E_VOL, H5E_BADVALUE, NULL, "invalid vol plugin ID in file access property list") + + if(NULL == vol_plugin->file_cls.create) + HGOTO_ERROR(H5E_VOL, H5E_UNSUPPORTED, NULL, "vol plugin has no `file create' method") + if(NULL == (file = (vol_plugin->file_cls.create)(name, flags, fcpl_id, fapl_id))) + HGOTO_ERROR(H5E_VOL, H5E_CANTINIT, NULL, "create failed") + + /* + * Fill in public fields. We must increment the reference count on the + * vol plugin ID to prevent it from being freed while this file is open. + */ + file->vol_id = plugin_id; + //file->vol_cls = vol_plugin; + if(H5I_inc_ref(file->vol_id, FALSE) < 0) + HGOTO_ERROR(H5E_VOL, H5E_CANTINC, NULL, "unable to increment ref count on VOL plugin") + + /* Set return value */ + ret_value = file; + +done: + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5VL_create() */ + + +/*------------------------------------------------------------------------- + * Function: H5VL_close + * + * Purpose: Private version of H5VLclose() + * + * Return: Success: Pointer to a new file struct + * + * Failure: NULL + * + * Programmer: Mohamad Chaarawi + * January, 2012 + * + *------------------------------------------------------------------------- + */ +herr_t +H5VL_close(H5F_t *file) +{ + H5VL_class_t *vol_plugin; /* VOL for file */ + H5P_genplist_t *plist; /* Property list pointer */ + herr_t ret_value = SUCCEED; + + FUNC_ENTER_NOAPI(H5VL_close, FAIL) + + /* check args */ + HDassert(file); + + /* Prepare to close file by clearing all public fields */ + if(NULL == (vol_plugin = (H5VL_class_t *)H5I_object(file->vol_id))) + HGOTO_ERROR(H5E_VOL, H5E_BADVALUE, FAIL, "invalid vol plugin ID in file") + + if(H5I_dec_ref(file->vol_id) < 0) + HGOTO_ERROR(H5E_VFL, H5E_CANTDEC, FAIL, "can't close plugin ID") + + /* + * Dispatch to the driver for actual close. If the driver fails to + * close the file then the file will be in an unusable state. + */ + if(NULL == vol_plugin->file_cls.close) + HGOTO_ERROR(H5E_VOL, H5E_UNSUPPORTED, FAIL, "vol plugin has no `file close' method") + if((vol_plugin->file_cls.close)(file) < 0) + HGOTO_ERROR(H5E_VOL, H5E_CANTCLOSEFILE, FAIL, "close failed") + +done: + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5VL_close() */ diff --git a/src/H5VLnative.c b/src/H5VLnative.c new file mode 100644 index 0000000..a14e045 --- /dev/null +++ b/src/H5VLnative.c @@ -0,0 +1,304 @@ +/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * + * Copyright by The HDF Group. * + * Copyright by the Board of Trustees of the University of Illinois. * + * All rights reserved. * + * * + * This file is part of HDF5. The full HDF5 copyright notice, including * + * terms governing use, modification, and redistribution, is contained in * + * the files COPYING and Copyright.html. COPYING can be found at the root * + * of the source code distribution tree; Copyright.html can be found at the * + * root level of an installed copy of the electronic HDF5 document set and * + * is linked from the top-level documents page. It can also be found at * + * http://hdfgroup.org/HDF5/doc/Copyright.html. If you do not have * + * access to either file, you may request a copy from help@hdfgroup.org. * + * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ + +/* + * Programmer: Mohamad Chaarawi + * January, 2012 + * + * Purpose: The native VOL plugin where access is to a single HDF5 file + * using HDF5 VFDs. + */ + +/* Interface initialization */ +#define H5_INTERFACE_INIT_FUNC H5VL_native_init_interface + + +#include "H5private.h" /* Generic Functions */ +#include "H5Eprivate.h" /* Error handling */ +#include "H5Fprivate.h" /* File access */ +#include "H5VLprivate.h" /* VOL plugins */ +#include "H5VLnative.h" /* Native VOL plugin */ +#include "H5Iprivate.h" /* IDs */ +#include "H5MMprivate.h" /* Memory management */ +#include "H5Pprivate.h" /* Property lists */ + +/* The driver identification number, initialized at runtime */ +static hid_t H5VL_NATIVE_g = 0; + + +/* Prototypes */ +static H5F_t *H5VL_native_open(const char *name, unsigned flags, hid_t fapl_id); +static herr_t H5VL_native_close(H5F_t *f); +static H5F_t *H5VL_native_create(const char *name, unsigned flags, hid_t fcpl_id, hid_t fapl_id); +static herr_t H5VL_native_term(void); + +static const H5VL_class_t H5VL_native_g = { + "native", /* name */ + H5VL_native_term, /*terminate */ + 0, /*fapl_size */ + NULL, /*fapl_get */ + NULL, /*fapl_copy */ + NULL, /*fapl_free */ + { /* general_cls */ + NULL, /* open */ + NULL, /* create */ + NULL, /* exists */ + NULL /* close */ + }, + { /* file_cls */ + H5VL_native_open, /* open */ + H5VL_native_close, /* close */ + H5VL_native_create, /* create */ + NULL, /* flush */ + NULL, /* is_hdf5 */ + NULL, /* mount */ + NULL, /* unmount */ + NULL /* reopen */ + }, + { /* dataset_cls */ + NULL, /* read */ + NULL, /* write */ + NULL, /* set_extent */ + }, + { /* attribute_cls */ + NULL, /* create_by_name */ + NULL, /* delete */ + NULL, /* delete_by_idx */ + NULL, /* delete_by_name */ + NULL, /* open_by_idx */ + NULL, /* open_by_name */ + NULL, /* open_idx */ + NULL, /* read */ + NULL, /* write */ + NULL /* rename */ + }, + { /* datatype_cls */ + NULL, /* commit */ + }, + { /* link_cls */ + NULL, /* create */ + NULL, /* delete */ + NULL, /* move */ + NULL, /* copy */ + NULL, /* delete_by_idx */ + NULL, /* create_external */ + NULL /* create_ud */ + }, + { /* object_cls */ + NULL, /* set_comment */ + NULL, /* open_by_addr */ + NULL, /* open_by_idx */ + NULL, /* copy */ + NULL, /* incr_refcount */ + NULL /* decr_refcount */ + } +}; + + +/*-------------------------------------------------------------------------- +NAME + H5VL_native_init_interface -- Initialize interface-specific information +USAGE + herr_t H5VL_native_init_interface() + +RETURNS + Non-negative on success/Negative on failure +DESCRIPTION + Initializes any interface-specific data or routines. (Just calls + H5VL_native_init currently). + +--------------------------------------------------------------------------*/ +static herr_t +H5VL_native_init_interface(void) +{ + FUNC_ENTER_NOAPI_NOINIT_NOFUNC(H5VL_native_init_interface) + + FUNC_LEAVE_NOAPI(H5VL_native_init()) +} /* H5VL_native_init_interface() */ + + +/*------------------------------------------------------------------------- + * Function: H5VL_native_init + * + * Purpose: Initialize this vol plugin by registering the driver with the + * library. + * + * Return: Success: The ID for the native plugin. + * Failure: Negative. + * + * Programmer: Mohamad Chaarawi + * January, 2012 + * + *------------------------------------------------------------------------- + */ +hid_t +H5VL_native_init(void) +{ + hid_t ret_value; /* Return value */ + + FUNC_ENTER_NOAPI(H5VL_native_init, FAIL) + + if(H5I_VOL != H5I_get_type(H5VL_NATIVE_g)) + H5VL_NATIVE_g = H5VL_register(&H5VL_native_g, sizeof(H5VL_class_t), FALSE); + + /* Set return value */ + ret_value = H5VL_NATIVE_g; + +done: + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5VL_native_init() */ + + +/*--------------------------------------------------------------------------- + * Function: H5VL_native_term + * + * Purpose: Shut down the VOL plugin + * + * Returns: Non-negative on success or negative on failure + * + * Programmer: Mohamad Chaarawi + * January, 2012 + * + *--------------------------------------------------------------------------- + */ +static herr_t +H5VL_native_term(void) +{ + FUNC_ENTER_NOAPI_NOINIT_NOFUNC(H5VL_native_term) + + /* Reset VOL ID */ + H5VL_NATIVE_g = 0; + + FUNC_LEAVE_NOAPI(SUCCEED) +} /* end H5VL_native_term() */ + + +/*------------------------------------------------------------------------- + * Function: H5Pset_fapl_native + * + * Purpose: Modify the file access property list to use the H5VL_NATIVE + * plugin defined in this source file. + * + * Return: Non-negative on success/Negative on failure + * + * Programmer: Mohamad Chaarawi + * January, 2012 + * + *------------------------------------------------------------------------- + */ +herr_t +H5Pset_fapl_native(hid_t fapl_id) +{ + H5P_genplist_t *plist; /* Property list pointer */ + herr_t ret_value; + + FUNC_ENTER_API(H5Pset_fapl_native, FAIL) + H5TRACE1("e", "i", fapl_id); + + if(NULL == (plist = H5P_object_verify(fapl_id, H5P_FILE_ACCESS))) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a file access property list") + + ret_value = H5P_set_vol(plist, H5VL_NATIVE, NULL); + +done: + FUNC_LEAVE_API(ret_value) +} /* end H5Pset_fapl_native() */ + + +/*------------------------------------------------------------------------- + * Function: H5VL_native_open + * + * Purpose: Opens a file as a native HDF5 file. + * + * Return: Success: A pointer to a new file data structure. + * Failure: NULL + * + * Programmer: Mohamad Chaarawi + * January, 2012 + * + *------------------------------------------------------------------------- + */ +static H5F_t * +H5VL_native_open(const char *name, unsigned flags, hid_t fapl_id) +{ + H5F_t *ret_value = NULL; + + FUNC_ENTER_NOAPI_NOINIT(H5VL_native_open) + + /* Open the file */ + if(NULL == (ret_value = H5F_open(name, flags, H5P_FILE_CREATE_DEFAULT, fapl_id, H5AC_dxpl_id))) + HGOTO_ERROR(H5E_FILE, H5E_CANTOPENFILE, NULL, "unable to open file") + +done: + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5VL_native_open() */ + + +/*------------------------------------------------------------------------- + * Function: H5VL_native_create + * + * Purpose: Creates a file as a native HDF5 file. + * + * Return: Success: A pointer to a new file data structure. + * Failure: NULL + * + * Programmer: Mohamad Chaarawi + * January, 2012 + * + *------------------------------------------------------------------------- + */ +static H5F_t * +H5VL_native_create(const char *name, unsigned flags, hid_t fcpl_id, hid_t fapl_id) +{ + H5F_t *ret_value = NULL; + + FUNC_ENTER_NOAPI_NOINIT(H5VL_native_create) + + /* Create the file */ + if(NULL == (ret_value = H5F_open(name, flags, fcpl_id, fapl_id, H5AC_dxpl_id))) + HGOTO_ERROR(H5E_FILE, H5E_CANTOPENFILE, NULL, "unable to create file") + +done: + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5VL_native_create() */ + + +/*------------------------------------------------------------------------- + * Function: H5VL_native_close + * + * Purpose: Closes a file. + * + * Return: Success: 0 + * Failure: -1, file not closed. + * + * Programmer: Mohamad Chaarawi + * January, 2012 + * + *------------------------------------------------------------------------- + */ +static herr_t +H5VL_native_close(H5F_t *file) +{ + herr_t ret_value = SUCCEED; /* Return value */ + + FUNC_ENTER_NOAPI_NOINIT(H5VL_native_close) + + /* Close the file */ + if(H5F_close(file) < 0) + HGOTO_ERROR(H5E_VOL, H5E_CANTCLOSEFILE, FAIL, "unable to close file") + +done: + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5VL_native_close() */ diff --git a/src/H5VLnative.h b/src/H5VLnative.h new file mode 100644 index 0000000..36177ed --- /dev/null +++ b/src/H5VLnative.h @@ -0,0 +1,38 @@ +/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * + * Copyright by The HDF Group. * + * Copyright by the Board of Trustees of the University of Illinois. * + * All rights reserved. * + * * + * This file is part of HDF5. The full HDF5 copyright notice, including * + * terms governing use, modification, and redistribution, is contained in * + * the files COPYING and Copyright.html. COPYING can be found at the root * + * of the source code distribution tree; Copyright.html can be found at the * + * root level of an installed copy of the electronic HDF5 document set and * + * is linked from the top-level documents page. It can also be found at * + * http://hdfgroup.org/HDF5/doc/Copyright.html. If you do not have * + * access to either file, you may request a copy from help@hdfgroup.org. * + * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ + +/* + * Programmer: Mohamad Chaarawi + * January, 2012 + * + * Purpose: The public header file for the Native VOL plugin. + */ +#ifndef H5VLnative_H +#define H5VLnative_H + +#define H5VL_NATIVE (H5VL_native_init()) + +#ifdef __cplusplus +extern "C" { +#endif + +H5_DLL hid_t H5VL_native_init(void); +H5_DLL herr_t H5Pset_fapl_native(hid_t fapl_id); + +#ifdef __cplusplus +} +#endif + +#endif diff --git a/src/H5VLpkg.h b/src/H5VLpkg.h new file mode 100644 index 0000000..3739689 --- /dev/null +++ b/src/H5VLpkg.h @@ -0,0 +1,65 @@ +/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * + * Copyright by The HDF Group. * + * Copyright by the Board of Trustees of the University of Illinois. * + * All rights reserved. * + * * + * This file is part of HDF5. The full HDF5 copyright notice, including * + * terms governing use, modification, and redistribution, is contained in * + * the files COPYING and Copyright.html. COPYING can be found at the root * + * of the source code distribution tree; Copyright.html can be found at the * + * root level of an installed copy of the electronic HDF5 document set and * + * is linked from the top-level documents page. It can also be found at * + * http://hdfgroup.org/HDF5/doc/Copyright.html. If you do not have * + * access to either file, you may request a copy from help@hdfgroup.org. * + * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ + +/* + * Programmer: Mohamad Chaarawi + * January, 2012 + * + * Purpose: This file contains declarations which are visible only within + * the H5VL package. Source files outside the H5VL package should + * include H5VLprivate.h instead. + */ +#ifndef H5VL_PACKAGE +#error "Do not include this file outside the H5VL package!" +#endif + +#ifndef _H5VLpkg_H +#define _H5VLpkg_H + +/* Get package's private header */ +#include "H5VLprivate.h" /* File drivers */ + +/* Other private headers needed by this file */ +#include "H5FLprivate.h" /* Free lists */ + +/**************************/ +/* Package Private Macros */ +/**************************/ + + +/****************************/ +/* Package Private Typedefs */ +/****************************/ + + +/*****************************/ +/* Package Private Variables */ +/*****************************/ + + +/******************************/ +/* Package Private Prototypes */ +/******************************/ +H5_DLL herr_t H5VL_init(void); + +/* +H5_DLL haddr_t H5VL_alloc_real(H5VL_t *file, hid_t dxpl_id, H5VL_mem_t type, + hsize_t size, haddr_t *align_addr, hsize_t *align_size); +H5_DLL herr_t H5VL_free_real(H5VL_t *file, hid_t dxpl_id, H5VL_mem_t type, + haddr_t addr, hsize_t size); +*/ + +#endif /* _H5VLpkg_H */ + diff --git a/src/H5VLprivate.h b/src/H5VLprivate.h new file mode 100644 index 0000000..1063ae7 --- /dev/null +++ b/src/H5VLprivate.h @@ -0,0 +1,56 @@ +/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * + * Copyright by The HDF Group. * + * Copyright by the Board of Trustees of the University of Illinois. * + * All rights reserved. * + * * + * This file is part of HDF5. The full HDF5 copyright notice, including * + * terms governing use, modification, and redistribution, is contained in * + * the files COPYING and Copyright.html. COPYING can be found at the root * + * of the source code distribution tree; Copyright.html can be found at the * + * root level of an installed copy of the electronic HDF5 document set and * + * is linked from the top-level documents page. It can also be found at * + * http://hdfgroup.org/HDF5/doc/Copyright.html. If you do not have * + * access to either file, you may request a copy from help@hdfgroup.org. * + * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ + +/* + * Programmer: Mohamad Chaarawi + * January, 2011 + */ +#ifndef _H5VLprivate_H +#define _H5VLprivate_H + +#include "H5VLpublic.h" + +/**************************/ +/* Library Private Macros */ +/**************************/ + +/****************************/ +/* Library Private Typedefs */ +/****************************/ + +/*****************************/ +/* Library Private Variables */ +/*****************************/ + +/******************************/ +/* Library Private Prototypes */ +/******************************/ + +/* Forward declarations for prototype arguments */ +struct H5P_genplist_t; +struct H5F_t; + +H5_DLL int H5VL_term_interface(void); +H5_DLL H5VL_class_t *H5VL_get_class(hid_t id); +//H5_DLL hsize_t H5VL_sb_size(H5F_t *file); +H5_DLL hid_t H5VL_register(const void *cls, size_t size, hbool_t app_ref); +H5_DLL H5F_t *H5VL_open(const char *name, unsigned flags, hid_t fapl_id); +H5_DLL H5F_t *H5VL_create(const char *name, unsigned flags, hid_t fcpl_id, hid_t fapl_id); +H5_DLL herr_t H5VL_close(H5F_t *f); +H5_DLL herr_t H5VL_fapl_open(struct H5P_genplist_t *plist, hid_t vol_id, const void *vol_info); +H5_DLL herr_t H5VL_fapl_copy(hid_t vol_id, const void *fapl, void **copied_fapl); +H5_DLL herr_t H5VL_fapl_close(hid_t vol_id, void *fapl); + +#endif /* !_H5VLprivate_H */ diff --git a/src/H5VLpublic.h b/src/H5VLpublic.h new file mode 100644 index 0000000..62407d9 --- /dev/null +++ b/src/H5VLpublic.h @@ -0,0 +1,136 @@ +/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * + * Copyright by The HDF Group. * + * Copyright by the Board of Trustees of the University of Illinois. * + * All rights reserved. * + * * + * This file is part of HDF5. The full HDF5 copyright notice, including * + * terms governing use, modification, and redistribution, is contained in * + * the files COPYING and Copyright.html. COPYING can be found at the root * + * of the source code distribution tree; Copyright.html can be found at the * + * root level of an installed copy of the electronic HDF5 document set and * + * is linked from the top-level documents page. It can also be found at * + * http://hdfgroup.org/HDF5/doc/Copyright.html. If you do not have * + * access to either file, you may request a copy from help@hdfgroup.org. * + * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */ + +/* + * Programmer: Mohamad Chaarawi + * January 23, 2012 + */ +#ifndef _H5VLpublic_H +#define _H5VLpublic_H + +#include "H5public.h" +#include "H5Fpublic.h" +#include "H5Lpublic.h" + +#define H5VL_VOL_DEFAULT 0 /* Default VOL plugin value */ + +/* general routines common to all HDF5 objects */ +typedef struct H5VL_general_class_t { + hid_t (*open) (hid_t obj_id, const char * object_name, hid_t plist_id); + hid_t (*create) (hid_t obj_id, const char *object_name, hid_t type_id, size_t size_hint, hid_t space_id, + hid_t plist_id1, hid_t plist_id2, hid_t plist_id3); + htri_t (*exists) (hid_t id, const char *obj_name, const char *name, hid_t lapl_id); + herr_t (*close) (hid_t obj_id); +} H5VL_general_class_t; + +/* H5F routines */ +typedef struct H5VL_file_class_t { + H5F_t *(*open) (const char *name, unsigned flags, hid_t fapl_id); + herr_t (*close) (H5F_t *file); + H5F_t *(*create) (const char *name, unsigned flags, hid_t fcpl_id, hid_t fapl_id); + herr_t (*flush) (hid_t object_id, H5F_scope_t scope); + htri_t (*is_hdf5) (const char *name); + herr_t (*mount) (hid_t loc_id, const char *name, hid_t child_id, hid_t plist_id); + herr_t (*unmount) (hid_t loc_id, const char *name); + hid_t (*reopen) (hid_t file_id); +} H5VL_file_class_t; + +/* H5D routines */ +typedef struct H5VL_dataset_class_t { + herr_t (*read) (hid_t dataset_id, hid_t mem_type_id, hid_t mem_space_id, hid_t file_space_id, + hid_t xfer_plist_id, void * buf ); + herr_t (*write) (hid_t dataset_id, hid_t mem_type_id, hid_t mem_space_id, hid_t file_space_id, + hid_t xfer_plist_id, const void * buf ); + herr_t (*set_extent) (hid_t dset_id, const hsize_t size[] ); +} H5VL_dataset_class_t; + +/* H5A routines */ +typedef struct H5VL_attribute_class_t { + hid_t (*create_by_name) (hid_t loc_id, const char *obj_name, const char *attr_name, hid_t type_id, + hid_t space_id, hid_t acpl_id, hid_t aapl_id, hid_t lapl_id); + herr_t (*delete) (hid_t loc_id, const char *attr_name); + herr_t (*delete_by_idx) (hid_t loc_id, const char *obj_name, H5_index_t idx_type, + H5_iter_order_t order, hsize_t n, hid_t lapl_id ); + herr_t (*delete_by_name) (hid_t loc_id, const char *obj_name, const char *attr_name, hid_t lapl_id); + hid_t (*open_by_idx) (hid_t loc_id, const char *obj_name, H5_index_t idx_type, H5_iter_order_t order, + hsize_t n, hid_t aapl_id, hid_t lapl_id ); + hid_t (*open_by_name) (hid_t loc_id, const char *obj_name, const char *attr_name, + hid_t aapl_id, hid_t lapl_id ); + hid_t (*open_idx) (hid_t loc_id, unsigned int idx ); + herr_t (*read) (hid_t attr_id, hid_t mem_type_id, void *buf ); + herr_t (*write) (hid_t attr_id, hid_t mem_type_id, const void *buf ); + herr_t (*rename) (hid_t loc_id, const char *obj_name, const char *old_attr_name, + const char *new_attr_name, hid_t lapl_id); +} H5VL_attribute_class_t; + +/* H5T routines*/ +typedef struct H5VL_datatype_class_t { + hid_t (*commit) (hid_t loc_id, const char *name, hid_t type_id, + hid_t lcpl_id, hid_t tcpl_id, hid_t tapl_id); +}H5VL_datatype_class_t; + +/* H5L routines */ +typedef struct H5VL_link_class_t { + herr_t (*create) (hid_t obj_id, const char *name, hid_t loc_id, const char *link_name, + hid_t lcpl_id, hid_t lapl_id); + herr_t (*delete) (hid_t loc_id, const char *name, hid_t lapl_id); + herr_t (*move) (hid_t src_loc_id, const char *src_name, hid_t dst_loc_id, const char *dest_name, + hid_t lcpl, hid_t lapl); + herr_t (*copy) (hid_t src_loc_id, const char *src_name, hid_t dest_loc_id, const char *dest_name, + hid_t lcpl_id, hid_t lapl_id); + herr_t (*delete_by_idx) (hid_t loc_id, const char *group_name, H5_index_t index_field, + H5_iter_order_t order, hsize_t n, hid_t lapl_id); + herr_t (*create_external) (const char *target_file_name, const char *target_obj_name, + hid_t link_loc_id, const char *link_name, hid_t lcpl_id, hid_t lapl_id); + herr_t (*create_ud) (hid_t link_loc_id, const char *link_name, H5L_type_t link_type, + const char *udata, size_t udata_size, hid_t lcpl_id, hid_t lapl_id); + +} H5VL_link_class_t; + +/* H5O routines */ +typedef struct H5VL_object_class_t { + herr_t (*set_comment) (hid_t object_id, const char *name, const char *comment, hid_t lapl_id); + hid_t (*open_by_addr) (hid_t loc_id, haddr_t addr ); + hid_t (*open_by_idx) (hid_t loc_id, const char *group_name, H5_index_t index_type, + H5_iter_order_t order, hsize_t n, hid_t lapl_id ); + herr_t (*copy) (hid_t src_loc_id, const char *src_name, hid_t dst_loc_id, const char *dst_name, + hid_t ocpypl_id, hid_t lcpl_id ); + herr_t (*incr_refcount) (hid_t object_id ); + herr_t (*decr_refcount) (hid_t object_id ); +} H5VL_object_class_t; + +/* Class information for each VOL driver */ +typedef struct H5VL_class_t { + const char *name; + herr_t (*terminate)(void); + size_t fapl_size; + void * (*fapl_get)(H5F_t *file); + void * (*fapl_copy)(const void *fapl); + herr_t (*fapl_free)(void *fapl); + H5VL_general_class_t general_cls; + H5VL_file_class_t file_cls; + H5VL_dataset_class_t dataset_cls; + H5VL_attribute_class_t attribute_cls; + H5VL_datatype_class_t datatype_cls; + H5VL_link_class_t link_cls; + H5VL_object_class_t object_cls; +} H5VL_class_t; + + +/* Function prototypes */ +H5_DLL hid_t H5VLregister(const H5VL_class_t *cls); +H5_DLL herr_t H5VLunregister(hid_t driver_id); + +#endif diff --git a/src/H5config.h.in b/src/H5config.h.in index a2059f5..27d317c 100644 --- a/src/H5config.h.in +++ b/src/H5config.h.in @@ -20,6 +20,9 @@ /* Define the default virtual file driver to compile */ #undef DEFAULT_VFD +/* Define the default vol plugin to compile */ +#undef DEFAULT_VOL + /* Define if `dev_t' is a scalar */ #undef DEV_T_IS_SCALAR diff --git a/src/Makefile.am b/src/Makefile.am index d42af98..c751699 100755 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -59,6 +59,7 @@ libhdf5_la_SOURCES= H5.c H5checksum.c H5dbg.c H5system.c H5timer.c H5trace.c \ H5Fsfile.c H5Fsuper.c H5Fsuper_cache.c H5Ftest.c \ H5FA.c H5FAcache.c H5FAdbg.c H5FAdblock.c H5FAdblkpage.c H5FAhdr.c \ H5FAstat.c H5FAtest.c \ + H5VL.c H5VLnative.c \ H5FD.c H5FDcore.c \ H5FDdirect.c H5FDfamily.c H5FDint.c H5FDlog.c H5FDmpi.c H5FDmpio.c \ H5FDmpiposix.c H5FDmulti.c H5FDsec2.c H5FDspace.c H5FDstdio.c \ @@ -115,6 +116,7 @@ include_HEADERS = hdf5.h H5api_adpt.h H5overflow.h H5pubconf.h H5public.h H5vers H5Epubgen.h H5Epublic.h H5Fpublic.h H5FDpublic.h H5FDcore.h H5FDdirect.h \ H5FDfamily.h H5FDlog.h H5FDmpi.h H5FDmpio.h H5FDmpiposix.h \ H5FDmulti.h H5FDsec2.h H5FDstdio.h \ + H5VLpublic.h H5VLnative.h \ H5Gpublic.h H5Ipublic.h H5Lpublic.h \ H5MMpublic.h H5Opublic.h H5Ppublic.h H5Rpublic.h H5Spublic.h \ H5Tpublic.h H5Zpublic.h diff --git a/src/Makefile.in b/src/Makefile.in index c94c710..d9243b9 100644 --- a/src/Makefile.in +++ b/src/Makefile.in @@ -110,12 +110,12 @@ am_libhdf5_la_OBJECTS = H5.lo H5checksum.lo H5dbg.lo H5system.lo \ H5Ffake.lo H5Fio.lo H5Fmount.lo H5Fmpi.lo H5Fquery.lo \ H5Fsfile.lo H5Fsuper.lo H5Fsuper_cache.lo H5Ftest.lo H5FA.lo \ H5FAcache.lo H5FAdbg.lo H5FAdblock.lo H5FAdblkpage.lo \ - H5FAhdr.lo H5FAstat.lo H5FAtest.lo H5FD.lo H5FDcore.lo \ - H5FDdirect.lo H5FDfamily.lo H5FDint.lo H5FDlog.lo H5FDmpi.lo \ - H5FDmpio.lo H5FDmpiposix.lo H5FDmulti.lo H5FDsec2.lo \ - H5FDspace.lo H5FDstdio.lo H5FL.lo H5FO.lo H5FS.lo H5FScache.lo \ - H5FSdbg.lo H5FSsection.lo H5FSstat.lo H5FStest.lo H5G.lo \ - H5Gbtree2.lo H5Gcache.lo H5Gcompact.lo H5Gdense.lo \ + H5FAhdr.lo H5FAstat.lo H5FAtest.lo H5VL.lo H5VLnative.lo \ + H5FD.lo H5FDcore.lo H5FDdirect.lo H5FDfamily.lo H5FDint.lo \ + H5FDlog.lo H5FDmpi.lo H5FDmpio.lo H5FDmpiposix.lo H5FDmulti.lo \ + H5FDsec2.lo H5FDspace.lo H5FDstdio.lo H5FL.lo H5FO.lo H5FS.lo \ + H5FScache.lo H5FSdbg.lo H5FSsection.lo H5FSstat.lo H5FStest.lo \ + H5G.lo H5Gbtree2.lo H5Gcache.lo H5Gcompact.lo H5Gdense.lo \ H5Gdeprec.lo H5Gent.lo H5Gint.lo H5Glink.lo H5Gloc.lo \ H5Gname.lo H5Gnode.lo H5Gobj.lo H5Goh.lo H5Groot.lo H5Gstab.lo \ H5Gtest.lo H5Gtraverse.lo H5HF.lo H5HFbtree2.lo H5HFcache.lo \ @@ -518,6 +518,7 @@ libhdf5_la_SOURCES = H5.c H5checksum.c H5dbg.c H5system.c H5timer.c H5trace.c \ H5Fsfile.c H5Fsuper.c H5Fsuper_cache.c H5Ftest.c \ H5FA.c H5FAcache.c H5FAdbg.c H5FAdblock.c H5FAdblkpage.c H5FAhdr.c \ H5FAstat.c H5FAtest.c \ + H5VL.c H5VLnative.c \ H5FD.c H5FDcore.c \ H5FDdirect.c H5FDfamily.c H5FDint.c H5FDlog.c H5FDmpi.c H5FDmpio.c \ H5FDmpiposix.c H5FDmulti.c H5FDsec2.c H5FDspace.c H5FDstdio.c \ @@ -574,6 +575,7 @@ include_HEADERS = hdf5.h H5api_adpt.h H5overflow.h H5pubconf.h H5public.h H5vers H5Epubgen.h H5Epublic.h H5Fpublic.h H5FDpublic.h H5FDcore.h H5FDdirect.h \ H5FDfamily.h H5FDlog.h H5FDmpi.h H5FDmpio.h H5FDmpiposix.h \ H5FDmulti.h H5FDsec2.h H5FDstdio.h \ + H5VLpublic.h H5VLnative.h \ H5Gpublic.h H5Ipublic.h H5Lpublic.h \ H5MMpublic.h H5Opublic.h H5Ppublic.h H5Rpublic.h H5Spublic.h \ H5Tpublic.h H5Zpublic.h @@ -952,6 +954,8 @@ distclean-compile: @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/H5Tvisit.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/H5Tvlen.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/H5V.Plo@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/H5VL.Plo@am__quote@ +@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/H5VLnative.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/H5WB.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/H5Z.Plo@am__quote@ @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/H5Zdeflate.Plo@am__quote@ -- cgit v0.12