summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMohamad Chaarawi <chaarawi@hdfgroup.org>2012-06-28 19:51:46 (GMT)
committerMohamad Chaarawi <chaarawi@hdfgroup.org>2012-06-28 19:51:46 (GMT)
commit5f34b5703d93fd795f136054a191008affb80011 (patch)
tree2360311955cb5ad8090ebdaeff28e02adc2418c2
parentdf961a00414a440b8967983f62281b6205b9627c (diff)
downloadhdf5-5f34b5703d93fd795f136054a191008affb80011.zip
hdf5-5f34b5703d93fd795f136054a191008affb80011.tar.gz
hdf5-5f34b5703d93fd795f136054a191008affb80011.tar.bz2
[svn-r22501] change the interface callbacks for the VOL to use objects pointers and public VL structure instead of IDs.
tests will fail now because of named datatypes.
-rw-r--r--src/H5A.c560
-rw-r--r--src/H5Adeprec.c122
-rw-r--r--src/H5Aint.c117
-rw-r--r--src/H5Apkg.h4
-rw-r--r--src/H5D.c277
-rw-r--r--src/H5Ddeprec.c67
-rw-r--r--src/H5Dint.c4
-rw-r--r--src/H5Dio.c22
-rw-r--r--src/H5F.c428
-rw-r--r--src/H5Fint.c67
-rw-r--r--src/H5Fmount.c57
-rw-r--r--src/H5Fprivate.h3
-rw-r--r--src/H5G.c203
-rw-r--r--src/H5Gdeprec.c307
-rw-r--r--src/H5Gint.c32
-rw-r--r--src/H5Gprivate.h4
-rw-r--r--src/H5I.c120
-rw-r--r--src/H5Iprivate.h2
-rw-r--r--src/H5Ipublic.h4
-rw-r--r--src/H5L.c485
-rw-r--r--src/H5Lprivate.h47
-rw-r--r--src/H5O.c335
-rw-r--r--src/H5Ocopy.c27
-rw-r--r--src/H5Opkg.h2
-rw-r--r--src/H5Pacpl.c4
-rw-r--r--src/H5Plcpl.c17
-rw-r--r--src/H5R.c87
-rw-r--r--src/H5Rdeprec.c28
-rw-r--r--src/H5Rpkg.h6
-rw-r--r--src/H5T.c31
-rw-r--r--src/H5Tcommit.c196
-rw-r--r--src/H5Toh.c14
-rw-r--r--src/H5Tpkg.h1
-rw-r--r--src/H5Tprivate.h4
-rw-r--r--src/H5VL.c73
-rw-r--r--src/H5VLint.c924
-rw-r--r--src/H5VLnative.c1789
-rw-r--r--src/H5VLnative.h1
-rw-r--r--src/H5VLprivate.h117
-rw-r--r--src/H5VLpublic.h245
40 files changed, 4863 insertions, 1970 deletions
diff --git a/src/H5A.c b/src/H5A.c
index df22e16..793be98 100644
--- a/src/H5A.c
+++ b/src/H5A.c
@@ -140,7 +140,7 @@ H5A_init_interface(void)
/*
* Create attribute ID type.
*/
- if(H5I_register_type(H5I_ATTR, (size_t)H5I_ATTRID_HASHSIZE, H5A_RESERVED_ATOMS, (H5I_free_t)H5A_close) < H5I_FILE)
+ if(H5I_register_type(H5I_ATTR, (size_t)H5I_ATTRID_HASHSIZE, H5A_RESERVED_ATOMS, NULL) < H5I_FILE)
HGOTO_ERROR(H5E_INTERNAL, H5E_CANTINIT, FAIL, "unable to initialize interface")
done:
@@ -217,8 +217,11 @@ hid_t
H5Acreate2(hid_t loc_id, const char *attr_name, hid_t type_id, hid_t space_id,
hid_t acpl_id, hid_t UNUSED aapl_id)
{
+ void *attr = NULL; /* attr token from VOL plugin */
+ void *obj = NULL; /* object token of loc_id */
+ H5VL_t *vol_plugin; /* VOL plugin information */
H5P_genplist_t *plist; /* Property list pointer */
- H5VL_loc_params_t loc_params;
+ H5VL_loc_params_t loc_params;
hid_t ret_value; /* Return value */
FUNC_ENTER_API(FAIL)
@@ -234,9 +237,6 @@ H5Acreate2(hid_t loc_id, const char *attr_name, hid_t type_id, hid_t space_id,
if(H5P_DEFAULT == acpl_id)
acpl_id = H5P_ATTRIBUTE_CREATE_DEFAULT;
- loc_params.type = H5VL_OBJECT_BY_ID;
- loc_params.loc_data.loc_by_id.id = loc_id;
-
/* Get the plist structure */
if(NULL == (plist = (H5P_genplist_t *)H5I_object(acpl_id)))
HGOTO_ERROR(H5E_ATOM, H5E_BADATOM, FAIL, "can't find object for ID")
@@ -246,14 +246,37 @@ H5Acreate2(hid_t loc_id, const char *attr_name, hid_t type_id, hid_t space_id,
HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, FAIL, "can't set property value for datatype id")
if(H5P_set(plist, H5VL_ATTR_SPACE_ID, &space_id) < 0)
HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, FAIL, "can't set property value for space id")
- if(H5P_set(plist, H5VL_ATTR_LOC_PARAMS, &loc_params) < 0)
- HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, FAIL, "can't set property value for location")
+ //if(H5P_set(plist, H5VL_ATTR_LOC_PARAMS, &loc_params) < 0)
+ //HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, FAIL, "can't set property value for location")
+
+ loc_params.type = H5VL_OBJECT_BY_SELF;
+ loc_params.obj_type = H5I_get_type(loc_id);
+
+ /* get the file object */
+ if(NULL == (obj = (void *)H5I_object(loc_id)))
+ HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "invalid file identifier")
+ /* get the plugin pointer */
+ if (NULL == (vol_plugin = (H5VL_t *)H5I_get_aux(loc_id)))
+ HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "ID does not contain VOL information")
/* Create the attribute through the VOL */
- if((ret_value = H5VL_attr_create(loc_id, attr_name, acpl_id, aapl_id, H5_REQUEST_NULL)) < 0)
+ if(NULL == (attr = H5VL_attr_create(obj, loc_params, vol_plugin, attr_name, acpl_id, aapl_id, H5_REQUEST_NULL)))
HGOTO_ERROR(H5E_SYM, H5E_CANTINIT, FAIL, "unable to create attribute")
+ /* Get an atom for the attribute */
+ if((ret_value = H5I_register(H5I_ATTR, attr, TRUE)) < 0)
+ HGOTO_ERROR(H5E_ATOM, H5E_CANTREGISTER, FAIL, "unable to atomize attribute handle")
+
+ /* attach VOL information to the ID */
+ if (H5I_register_aux(ret_value, vol_plugin, (H5I_free2_t)H5A_close_attr) < 0)
+ HGOTO_ERROR(H5E_VOL, H5E_CANTINIT, FAIL, "can't attach vol info to ID")
+
+ vol_plugin->nrefs ++;
+
done:
+ if (ret_value < 0 && attr)
+ if(H5VL_attr_close (attr, vol_plugin, H5_REQUEST_NULL) < 0)
+ HDONE_ERROR(H5E_DATASET, H5E_CLOSEERROR, FAIL, "unable to release dataset")
FUNC_LEAVE_API(ret_value)
} /* H5Acreate2() */
@@ -294,6 +317,9 @@ H5Acreate_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)
{
+ void *attr = NULL; /* attr token from VOL plugin */
+ void *obj = NULL; /* object token of loc_id */
+ H5VL_t *vol_plugin; /* VOL plugin information */
H5P_genplist_t *plist; /* Property list pointer */
H5VL_loc_params_t loc_params;
hid_t ret_value; /* Return value */
@@ -314,10 +340,6 @@ H5Acreate_by_name(hid_t loc_id, const char *obj_name, const char *attr_name,
if(H5P_DEFAULT == acpl_id)
acpl_id = H5P_ATTRIBUTE_CREATE_DEFAULT;
- loc_params.type = H5VL_OBJECT_BY_NAME;
- loc_params.loc_data.loc_by_name.name = obj_name;
- loc_params.loc_data.loc_by_name.plist_id = lapl_id;
-
/* Get the plist structure */
if(NULL == (plist = (H5P_genplist_t *)H5I_object(acpl_id)))
HGOTO_ERROR(H5E_ATOM, H5E_BADATOM, FAIL, "can't find object for ID")
@@ -327,14 +349,38 @@ H5Acreate_by_name(hid_t loc_id, const char *obj_name, const char *attr_name,
HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, FAIL, "can't set property value for datatype id")
if(H5P_set(plist, H5VL_ATTR_SPACE_ID, &space_id) < 0)
HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, FAIL, "can't set property value for space id")
- if(H5P_set(plist, H5VL_ATTR_LOC_PARAMS, &loc_params) < 0)
- HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, FAIL, "can't set property value for location")
+
+ loc_params.type = H5VL_OBJECT_BY_NAME;
+ loc_params.obj_type = H5I_get_type(loc_id);
+ loc_params.loc_data.loc_by_name.name = obj_name;
+ loc_params.loc_data.loc_by_name.plist_id = lapl_id;
+
+ /* get the file object */
+ if(NULL == (obj = (void *)H5I_object(loc_id)))
+ HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "invalid file identifier")
+
+ /* get the plugin pointer */
+ if (NULL == (vol_plugin = (H5VL_t *)H5I_get_aux(loc_id)))
+ HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "ID does not contain VOL information")
/* Create the attribute through the VOL */
- if((ret_value = H5VL_attr_create(loc_id, attr_name, acpl_id, aapl_id, H5_REQUEST_NULL)) < 0)
+ if(NULL == (attr = H5VL_attr_create(obj, loc_params, vol_plugin, attr_name, acpl_id, aapl_id, H5_REQUEST_NULL)))
HGOTO_ERROR(H5E_SYM, H5E_CANTINIT, FAIL, "unable to create attribute")
+ /* Get an atom for the attribute */
+ if((ret_value = H5I_register(H5I_ATTR, attr, TRUE)) < 0)
+ HGOTO_ERROR(H5E_ATOM, H5E_CANTREGISTER, FAIL, "unable to atomize attribute handle")
+
+ /* attach VOL information to the ID */
+ if (H5I_register_aux(ret_value, vol_plugin, (H5I_free2_t)H5A_close_attr) < 0)
+ HGOTO_ERROR(H5E_VOL, H5E_CANTINIT, FAIL, "can't attach vol info to ID")
+
+ vol_plugin->nrefs ++;
+
done:
+ if (ret_value < 0 && attr)
+ if(H5VL_attr_close (attr, vol_plugin, H5_REQUEST_NULL) < 0)
+ HDONE_ERROR(H5E_DATASET, H5E_CLOSEERROR, FAIL, "unable to release dataset")
FUNC_LEAVE_API(ret_value)
} /* H5Acreate_by_name() */
@@ -361,6 +407,9 @@ done:
hid_t
H5Aopen(hid_t loc_id, const char *attr_name, hid_t aapl_id)
{
+ void *attr = NULL; /* attr token from VOL plugin */
+ void *obj = NULL; /* object token of loc_id */
+ H5VL_t *vol_plugin; /* VOL plugin information */
H5VL_loc_params_t loc_params;
hid_t ret_value;
@@ -373,14 +422,35 @@ H5Aopen(hid_t loc_id, const char *attr_name, hid_t aapl_id)
if(!attr_name || !*attr_name)
HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "no attribute name")
- loc_params.type = H5VL_OBJECT_BY_ID;
- loc_params.loc_data.loc_by_id.id = loc_id;
+ loc_params.type = H5VL_OBJECT_BY_SELF;
+ loc_params.obj_type = H5I_get_type(loc_id);
- /* Open the attribute through the VOL */
- if((ret_value = H5VL_attr_open(loc_id, loc_params, attr_name, aapl_id, H5_REQUEST_NULL)) < 0)
- HGOTO_ERROR(H5E_ATTR, H5E_CANTINIT, FAIL, "unable to open attribute")
+ /* get the file object */
+ if(NULL == (obj = (void *)H5I_object(loc_id)))
+ HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "invalid file identifier")
+
+ /* get the plugin pointer */
+ if (NULL == (vol_plugin = (H5VL_t *)H5I_get_aux(loc_id)))
+ HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "ID does not contain VOL information")
+
+ /* Create the attribute through the VOL */
+ if(NULL == (attr = H5VL_attr_open(obj, loc_params, vol_plugin, attr_name, aapl_id, H5_REQUEST_NULL)))
+ HGOTO_ERROR(H5E_SYM, H5E_CANTINIT, FAIL, "unable to open attribute")
+
+ /* Get an atom for the attribute */
+ if((ret_value = H5I_register(H5I_ATTR, attr, TRUE)) < 0)
+ HGOTO_ERROR(H5E_ATOM, H5E_CANTREGISTER, FAIL, "unable to atomize attribute handle")
+
+ /* attach VOL information to the ID */
+ if (H5I_register_aux(ret_value, vol_plugin, (H5I_free2_t)H5A_close_attr) < 0)
+ HGOTO_ERROR(H5E_VOL, H5E_CANTINIT, FAIL, "can't attach vol info to ID")
+
+ vol_plugin->nrefs ++;
done:
+ if (ret_value < 0 && attr)
+ if(H5VL_attr_close (attr, vol_plugin, H5_REQUEST_NULL) < 0)
+ HDONE_ERROR(H5E_DATASET, H5E_CLOSEERROR, FAIL, "unable to release dataset")
FUNC_LEAVE_API(ret_value)
} /* H5Aopen() */
@@ -410,6 +480,9 @@ hid_t
H5Aopen_by_name(hid_t loc_id, const char *obj_name, const char *attr_name,
hid_t aapl_id, hid_t lapl_id)
{
+ void *attr = NULL; /* attr token from VOL plugin */
+ void *obj = NULL; /* object token of loc_id */
+ H5VL_t *vol_plugin; /* VOL plugin information */
H5VL_loc_params_t loc_params;
hid_t ret_value;
@@ -432,12 +505,34 @@ H5Aopen_by_name(hid_t loc_id, const char *obj_name, const char *attr_name,
loc_params.type = H5VL_OBJECT_BY_NAME;
loc_params.loc_data.loc_by_name.name = obj_name;
loc_params.loc_data.loc_by_name.plist_id = lapl_id;
+ loc_params.obj_type = H5I_get_type(loc_id);
- /* Open the attribute through the VOL */
- if((ret_value = H5VL_attr_open(loc_id, loc_params, attr_name, aapl_id, H5_REQUEST_NULL)) < 0)
- HGOTO_ERROR(H5E_ATTR, H5E_CANTINIT, FAIL, "unable to open attribute")
+ /* get the file object */
+ if(NULL == (obj = (void *)H5I_object(loc_id)))
+ HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "invalid file identifier")
+
+ /* get the plugin pointer */
+ if (NULL == (vol_plugin = (H5VL_t *)H5I_get_aux(loc_id)))
+ HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "ID does not contain VOL information")
+
+ /* Create the attribute through the VOL */
+ if(NULL == (attr = H5VL_attr_open(obj, loc_params, vol_plugin, attr_name, aapl_id, H5_REQUEST_NULL)))
+ HGOTO_ERROR(H5E_SYM, H5E_CANTINIT, FAIL, "unable to open attribute")
+
+ /* Get an atom for the attribute */
+ if((ret_value = H5I_register(H5I_ATTR, attr, TRUE)) < 0)
+ HGOTO_ERROR(H5E_ATOM, H5E_CANTREGISTER, FAIL, "unable to atomize attribute handle")
+
+ /* attach VOL information to the ID */
+ if (H5I_register_aux(ret_value, vol_plugin, (H5I_free2_t)H5A_close_attr) < 0)
+ HGOTO_ERROR(H5E_VOL, H5E_CANTINIT, FAIL, "can't attach vol info to ID")
+
+ vol_plugin->nrefs ++;
done:
+ if (ret_value < 0 && attr)
+ if(H5VL_attr_close (attr, vol_plugin, H5_REQUEST_NULL) < 0)
+ HDONE_ERROR(H5E_DATASET, H5E_CLOSEERROR, FAIL, "unable to release dataset")
FUNC_LEAVE_API(ret_value)
} /* H5Aopen_by_name() */
@@ -468,8 +563,12 @@ done:
--------------------------------------------------------------------------*/
hid_t
H5Aopen_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 UNUSED aapl_id, hid_t lapl_id)
+ H5_iter_order_t order, hsize_t n, hid_t aapl_id, hid_t lapl_id)
{
+ void *attr = NULL; /* attr token from VOL plugin */
+ void *obj = NULL; /* object token of loc_id */
+ H5VL_t *vol_plugin; /* VOL plugin information */
+ H5VL_loc_params_t loc_params;
hid_t ret_value; /* Return value */
FUNC_ENTER_API(FAIL)
@@ -491,11 +590,40 @@ H5Aopen_by_idx(hid_t loc_id, const char *obj_name, H5_index_t idx_type,
if(TRUE != H5P_isa_class(lapl_id, H5P_LINK_ACCESS))
HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not link access property list ID")
- if(H5VL_object_misc(loc_id, H5VL_ATTR_OPEN_BY_IDX, H5_REQUEST_NULL, &ret_value,
- obj_name, idx_type, order, n, aapl_id, lapl_id) < 0)
- HGOTO_ERROR(H5E_INTERNAL, H5E_CANTINIT, FAIL, "unable to open attribute")
+ loc_params.type = H5VL_OBJECT_BY_IDX;
+ loc_params.loc_data.loc_by_idx.name = obj_name;
+ loc_params.loc_data.loc_by_idx.idx_type = idx_type;
+ loc_params.loc_data.loc_by_idx.order = order;
+ loc_params.loc_data.loc_by_idx.n = n;
+ loc_params.loc_data.loc_by_idx.plist_id = lapl_id;
+ loc_params.obj_type = H5I_get_type(loc_id);
+
+ /* get the file object */
+ if(NULL == (obj = (void *)H5I_object(loc_id)))
+ HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "invalid file identifier")
+
+ /* get the plugin pointer */
+ if (NULL == (vol_plugin = (H5VL_t *)H5I_get_aux(loc_id)))
+ HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "ID does not contain VOL information")
+
+ /* Create the attribute through the VOL */
+ if(NULL == (attr = H5VL_attr_open(obj, loc_params, vol_plugin, NULL, aapl_id, H5_REQUEST_NULL)))
+ HGOTO_ERROR(H5E_SYM, H5E_CANTINIT, FAIL, "unable to open attribute")
+
+ /* Get an atom for the attribute */
+ if((ret_value = H5I_register(H5I_ATTR, attr, TRUE)) < 0)
+ HGOTO_ERROR(H5E_ATOM, H5E_CANTREGISTER, FAIL, "unable to atomize attribute handle")
+
+ /* attach VOL information to the ID */
+ if (H5I_register_aux(ret_value, vol_plugin, (H5I_free2_t)H5A_close_attr) < 0)
+ HGOTO_ERROR(H5E_VOL, H5E_CANTINIT, FAIL, "can't attach vol info to ID")
+
+ vol_plugin->nrefs ++;
done:
+ if (ret_value < 0 && attr)
+ if(H5VL_attr_close (attr, vol_plugin, H5_REQUEST_NULL) < 0)
+ HDONE_ERROR(H5E_DATASET, H5E_CLOSEERROR, FAIL, "unable to release dataset")
FUNC_LEAVE_API(ret_value)
} /* H5Aopen_by_idx() */
@@ -519,6 +647,8 @@ done:
herr_t
H5Awrite(hid_t attr_id, hid_t dtype_id, const void *buf)
{
+ H5VL_t *vol_plugin;
+ void *attr;
herr_t ret_value; /* Return value */
FUNC_ENTER_API(FAIL)
@@ -528,8 +658,15 @@ H5Awrite(hid_t attr_id, hid_t dtype_id, const void *buf)
if(NULL == buf)
HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "null attribute buffer")
+ /* get the plugin pointer */
+ if (NULL == (vol_plugin = (H5VL_t *)H5I_get_aux(attr_id)))
+ HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "ID does not contain VOL information")
+ /* get the dataset object */
+ if(NULL == (attr = (void *)H5I_object(attr_id)))
+ HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "invalid attribute identifier")
+
/* write the data through the VOL */
- if((ret_value = H5VL_attr_write(attr_id, dtype_id, buf, H5_REQUEST_NULL)) < 0)
+ if((ret_value = H5VL_attr_write(attr, vol_plugin, dtype_id, buf, H5_REQUEST_NULL)) < 0)
HGOTO_ERROR(H5E_ATTR, H5E_READERROR, FAIL, "can't read data")
done:
@@ -556,6 +693,8 @@ done:
herr_t
H5Aread(hid_t attr_id, hid_t dtype_id, void *buf)
{
+ H5VL_t *vol_plugin;
+ void *attr;
herr_t ret_value; /* Return value */
FUNC_ENTER_API(FAIL)
@@ -565,8 +704,15 @@ H5Aread(hid_t attr_id, hid_t dtype_id, void *buf)
if(NULL == buf)
HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "null attribute buffer")
+ /* get the plugin pointer */
+ if (NULL == (vol_plugin = (H5VL_t *)H5I_get_aux(attr_id)))
+ HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "ID does not contain VOL information")
+ /* get the dataset object */
+ if(NULL == (attr = (void *)H5I_object(attr_id)))
+ HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "invalid attribute identifier")
+
/* Read the data through the VOL */
- if((ret_value = H5VL_attr_read(attr_id, dtype_id, buf, H5_REQUEST_NULL)) < 0)
+ if((ret_value = H5VL_attr_read(attr, vol_plugin, dtype_id, buf, H5_REQUEST_NULL)) < 0)
HGOTO_ERROR(H5E_ATTR, H5E_READERROR, FAIL, "can't read data")
done:
@@ -593,13 +739,22 @@ done:
hid_t
H5Aget_space(hid_t attr_id)
{
+ H5VL_t *vol_plugin;
+ void *attr;
hid_t ret_value;
FUNC_ENTER_API(FAIL)
H5TRACE1("i", "i", attr_id);
+ /* get the plugin pointer */
+ if (NULL == (vol_plugin = (H5VL_t *)H5I_get_aux(attr_id)))
+ HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "ID does not contain VOL information")
+ /* get the dataset object */
+ if(NULL == (attr = (void *)H5I_object(attr_id)))
+ HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "invalid attribute identifier")
+
/* get the dataspace through the VOL */
- if(H5VL_attr_get(attr_id, H5VL_ATTR_GET_SPACE, H5_REQUEST_NULL, &ret_value) < 0)
+ if(H5VL_attr_get(attr, vol_plugin, H5VL_ATTR_GET_SPACE, H5_REQUEST_NULL, &ret_value) < 0)
HGOTO_ERROR(H5E_INTERNAL, H5E_CANTGET, FAIL, "unable to get data space")
done:
@@ -626,13 +781,22 @@ done:
hid_t
H5Aget_type(hid_t attr_id)
{
+ H5VL_t *vol_plugin;
+ void *attr;
hid_t ret_value; /* Return value */
FUNC_ENTER_API(FAIL)
H5TRACE1("i", "i", attr_id);
+ /* get the plugin pointer */
+ if (NULL == (vol_plugin = (H5VL_t *)H5I_get_aux(attr_id)))
+ HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "ID does not contain VOL information")
+ /* get the dataset object */
+ if(NULL == (attr = (void *)H5I_object(attr_id)))
+ HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "invalid attribute identifier")
+
/* get the datatype through the VOL */
- if(H5VL_attr_get(attr_id, H5VL_ATTR_GET_TYPE, H5_REQUEST_NULL, &ret_value) < 0)
+ if(H5VL_attr_get(attr, vol_plugin, H5VL_ATTR_GET_TYPE, H5_REQUEST_NULL, &ret_value) < 0)
HGOTO_ERROR(H5E_INTERNAL, H5E_CANTGET, FAIL, "unable to get type")
done:
@@ -662,15 +826,24 @@ done:
hid_t
H5Aget_create_plist(hid_t attr_id)
{
- hid_t ret_value;
+ H5VL_t *vol_plugin;
+ void *attr;
+ hid_t ret_value;
FUNC_ENTER_API(FAIL)
H5TRACE1("i", "i", attr_id);
HDassert(H5P_LST_ATTRIBUTE_CREATE_g != -1);
+ /* get the plugin pointer */
+ if (NULL == (vol_plugin = (H5VL_t *)H5I_get_aux(attr_id)))
+ HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "ID does not contain VOL information")
+ /* get the dataset object */
+ if(NULL == (attr = (void *)H5I_object(attr_id)))
+ HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "invalid attribute identifier")
+
/* get the acpl through the VOL */
- if(H5VL_attr_get(attr_id, H5VL_ATTR_GET_ACPL, H5_REQUEST_NULL, &ret_value) < 0)
+ if(H5VL_attr_get(attr, vol_plugin, H5VL_ATTR_GET_ACPL, H5_REQUEST_NULL, &ret_value) < 0)
HGOTO_ERROR(H5E_INTERNAL, H5E_CANTGET, FAIL, "unable to get acpl")
done:
@@ -702,7 +875,10 @@ done:
ssize_t
H5Aget_name(hid_t attr_id, size_t buf_size, char *buf)
{
- ssize_t ret_value;
+ H5VL_t *vol_plugin;
+ void *attr;
+ H5VL_loc_params_t loc_params;
+ ssize_t ret_value;
FUNC_ENTER_API(FAIL)
H5TRACE3("Zs", "iz*s", attr_id, buf_size, buf);
@@ -711,8 +887,18 @@ H5Aget_name(hid_t attr_id, size_t buf_size, char *buf)
if(!buf && buf_size)
HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "invalid buffer")
+ loc_params.type = H5VL_OBJECT_BY_SELF;
+ loc_params.obj_type = H5I_get_type(attr_id);
+
+ /* get the plugin pointer */
+ if (NULL == (vol_plugin = (H5VL_t *)H5I_get_aux(attr_id)))
+ HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "ID does not contain VOL information")
+ /* get the dataset object */
+ if(NULL == (attr = (void *)H5I_object(attr_id)))
+ HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "invalid attribute identifier")
+
/* get the name through the VOL */
- if(H5VL_attr_get(attr_id, H5VL_ATTR_GET_NAME, H5_REQUEST_NULL, &ret_value, buf_size, buf) < 0)
+ if(H5VL_attr_get(attr, vol_plugin, H5VL_ATTR_GET_NAME, H5_REQUEST_NULL, loc_params, buf_size, buf, &ret_value) < 0)
HGOTO_ERROR(H5E_INTERNAL, H5E_CANTGET, FAIL, "unable to get name")
done:
@@ -742,7 +928,9 @@ H5Aget_name_by_idx(hid_t loc_id, const char *obj_name, H5_index_t idx_type,
H5_iter_order_t order, hsize_t n, char *name /*out*/, size_t size,
hid_t lapl_id)
{
- hid_t attr_id = -1;
+ H5VL_t *vol_plugin;
+ void *obj;
+ H5VL_loc_params_t loc_params;
ssize_t ret_value; /* Return value */
FUNC_ENTER_API(FAIL)
@@ -764,6 +952,26 @@ H5Aget_name_by_idx(hid_t loc_id, const char *obj_name, H5_index_t idx_type,
if(TRUE != H5P_isa_class(lapl_id, H5P_LINK_ACCESS))
HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not link access property list ID")
+ /* get the plugin pointer */
+ if (NULL == (vol_plugin = (H5VL_t *)H5I_get_aux(loc_id)))
+ HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "ID does not contain VOL information")
+ /* get the dataset object */
+ if(NULL == (obj = (void *)H5I_object(loc_id)))
+ HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "invalid object identifier")
+
+ loc_params.type = H5VL_OBJECT_BY_IDX;
+ loc_params.loc_data.loc_by_idx.name = obj_name;
+ loc_params.loc_data.loc_by_idx.idx_type = idx_type;
+ loc_params.loc_data.loc_by_idx.order = order;
+ loc_params.loc_data.loc_by_idx.n = n;
+ loc_params.loc_data.loc_by_idx.plist_id = lapl_id;
+ loc_params.obj_type = H5I_get_type(loc_id);
+
+ /* get the name through the VOL */
+ if(H5VL_attr_get(obj, vol_plugin, H5VL_ATTR_GET_NAME, H5_REQUEST_NULL, loc_params, size, name, &ret_value) < 0)
+ HGOTO_ERROR(H5E_INTERNAL, H5E_CANTGET, FAIL, "unable to get name")
+
+#if 0
if(H5VL_object_misc(loc_id, H5VL_ATTR_OPEN_BY_IDX, H5_REQUEST_NULL, &attr_id,
obj_name, idx_type, order, n, H5P_DEFAULT, lapl_id) < 0)
HGOTO_ERROR(H5E_INTERNAL, H5E_CANTINIT, FAIL, "unable to open attribute")
@@ -771,28 +979,9 @@ H5Aget_name_by_idx(hid_t loc_id, const char *obj_name, H5_index_t idx_type,
/* get the name through the VOL */
if(H5VL_attr_get(attr_id, H5VL_ATTR_GET_NAME, H5_REQUEST_NULL, &ret_value, size, name) < 0)
HGOTO_ERROR(H5E_INTERNAL, H5E_CANTGET, FAIL, "unable to get name")
-
-#if 0
- /* Open the attribute on the object header */
- if(NULL == (attr = H5A_open_by_idx(&loc, obj_name, idx_type, order, n, lapl_id, H5AC_ind_dxpl_id)))
- HGOTO_ERROR(H5E_ATTR, H5E_CANTOPENOBJ, FAIL, "can't open attribute")
-
- /* Get the length of the name */
- ret_value = (ssize_t)HDstrlen(attr->shared->name);
-
- /* Copy the name into the user's buffer, if given */
- if(name) {
- HDstrncpy(name, attr->shared->name, MIN((size_t)(ret_value + 1), size));
- if((size_t)ret_value >= size)
- name[size - 1]='\0';
- } /* end if */
#endif
done:
- /* Release resources */
- if(attr_id > 0 && H5VL_attr_close(attr_id, H5_REQUEST_NULL) < 0)
- HDONE_ERROR(H5E_ATTR, H5E_CANTFREE, FAIL, "can't close attribute")
-
FUNC_LEAVE_API(ret_value)
} /* end H5Aget_name_by_idx() */
@@ -817,13 +1006,22 @@ done:
hsize_t
H5Aget_storage_size(hid_t attr_id)
{
+ H5VL_t *vol_plugin;
+ void *attr;
hsize_t ret_value; /* Return value */
FUNC_ENTER_API(0)
H5TRACE1("h", "i", attr_id);
+ /* get the plugin pointer */
+ if (NULL == (vol_plugin = (H5VL_t *)H5I_get_aux(attr_id)))
+ HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, 0, "ID does not contain VOL information")
+ /* get the dataset object */
+ if(NULL == (attr = (void *)H5I_object(attr_id)))
+ HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, 0, "invalid attribute identifier")
+
/* get the storage size through the VOL */
- if(H5VL_attr_get(attr_id, H5VL_ATTR_GET_STORAGE_SIZE, H5_REQUEST_NULL, &ret_value) < 0)
+ if(H5VL_attr_get(attr, vol_plugin, H5VL_ATTR_GET_STORAGE_SIZE, H5_REQUEST_NULL, &ret_value) < 0)
HGOTO_ERROR(H5E_INTERNAL, H5E_CANTGET, 0, "unable to get acpl")
done:
@@ -847,13 +1045,26 @@ done:
herr_t
H5Aget_info(hid_t attr_id, H5A_info_t *ainfo)
{
+ H5VL_t *vol_plugin;
+ void *attr;
+ H5VL_loc_params_t loc_params;
herr_t ret_value = SUCCEED; /* Return value */
FUNC_ENTER_API(FAIL)
H5TRACE2("e", "i*x", attr_id, ainfo);
+ /* get the plugin pointer */
+ if (NULL == (vol_plugin = (H5VL_t *)H5I_get_aux(attr_id)))
+ HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "ID does not contain VOL information")
+ /* get the dataset object */
+ if(NULL == (attr = (void *)H5I_object(attr_id)))
+ HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "invalid attribute identifier")
+
+ loc_params.type = H5VL_OBJECT_BY_SELF;
+ loc_params.obj_type = H5I_get_type(attr_id);
+
/* get the attribute info through the VOL */
- if(H5VL_attr_get(attr_id, H5VL_ATTR_GET_INFO, H5_REQUEST_NULL, ainfo) < 0)
+ if(H5VL_attr_get(attr, vol_plugin, H5VL_ATTR_GET_INFO, H5_REQUEST_NULL, loc_params, ainfo) < 0)
HGOTO_ERROR(H5E_INTERNAL, H5E_CANTGET, FAIL, "unable to get attribute info")
done:
@@ -878,8 +1089,9 @@ herr_t
H5Aget_info_by_name(hid_t loc_id, const char *obj_name, const char *attr_name,
H5A_info_t *ainfo, hid_t lapl_id)
{
+ H5VL_t *vol_plugin;
+ void *obj;
H5VL_loc_params_t loc_params;
- hid_t attr_id = -1;
herr_t ret_value = SUCCEED; /* Return value */
FUNC_ENTER_API(FAIL)
@@ -903,7 +1115,20 @@ H5Aget_info_by_name(hid_t loc_id, const char *obj_name, const char *attr_name,
loc_params.type = H5VL_OBJECT_BY_NAME;
loc_params.loc_data.loc_by_name.name = obj_name;
loc_params.loc_data.loc_by_name.plist_id = lapl_id;
+ loc_params.obj_type = H5I_get_type(loc_id);
+
+ /* get the plugin pointer */
+ if (NULL == (vol_plugin = (H5VL_t *)H5I_get_aux(loc_id)))
+ HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "ID does not contain VOL information")
+ /* get the dataset object */
+ if(NULL == (obj = (void *)H5I_object(loc_id)))
+ HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "invalid object identifier")
+ /* get the attribute info through the VOL */
+ if(H5VL_attr_get(obj, vol_plugin, H5VL_ATTR_GET_INFO, H5_REQUEST_NULL, loc_params, ainfo, attr_name) < 0)
+ HGOTO_ERROR(H5E_INTERNAL, H5E_CANTGET, FAIL, "unable to get attribute info")
+
+#if 0
/* Open the attribute through the VOL */
if((attr_id = H5VL_attr_open(loc_id, loc_params, attr_name, H5P_DEFAULT, H5_REQUEST_NULL)) < 0)
HGOTO_ERROR(H5E_ATTR, H5E_CANTINIT, FAIL, "unable to open attribute")
@@ -911,11 +1136,14 @@ H5Aget_info_by_name(hid_t loc_id, const char *obj_name, const char *attr_name,
/* get the attribute info through the VOL */
if(H5VL_attr_get(attr_id, H5VL_ATTR_GET_INFO, H5_REQUEST_NULL, ainfo) < 0)
HGOTO_ERROR(H5E_INTERNAL, H5E_CANTGET, FAIL, "unable to get attribute info")
-done:
+
/* release resources */
if(attr_id > 0 && H5VL_attr_close(attr_id, H5_REQUEST_NULL) < 0)
HDONE_ERROR(H5E_ATTR, H5E_CANTFREE, FAIL, "can't close attribute")
+#endif
+
+done:
FUNC_LEAVE_API(ret_value)
} /* end H5Aget_info_by_name() */
@@ -938,7 +1166,9 @@ herr_t
H5Aget_info_by_idx(hid_t loc_id, const char *obj_name, H5_index_t idx_type,
H5_iter_order_t order, hsize_t n, H5A_info_t *ainfo, hid_t lapl_id)
{
- hid_t attr_id = FAIL;
+ H5VL_t *vol_plugin;
+ void *obj;
+ H5VL_loc_params_t loc_params;
herr_t ret_value = SUCCEED; /* Return value */
FUNC_ENTER_API(FAIL)
@@ -962,6 +1192,26 @@ H5Aget_info_by_idx(hid_t loc_id, const char *obj_name, H5_index_t idx_type,
if(TRUE != H5P_isa_class(lapl_id, H5P_LINK_ACCESS))
HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not link access property list ID")
+ loc_params.type = H5VL_OBJECT_BY_IDX;
+ loc_params.loc_data.loc_by_idx.name = obj_name;
+ loc_params.loc_data.loc_by_idx.idx_type = idx_type;
+ loc_params.loc_data.loc_by_idx.order = order;
+ loc_params.loc_data.loc_by_idx.n = n;
+ loc_params.loc_data.loc_by_idx.plist_id = lapl_id;
+ loc_params.obj_type = H5I_get_type(loc_id);
+
+ /* get the plugin pointer */
+ if (NULL == (vol_plugin = (H5VL_t *)H5I_get_aux(loc_id)))
+ HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "ID does not contain VOL information")
+ /* get the dataset object */
+ if(NULL == (obj = (void *)H5I_object(loc_id)))
+ HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "invalid object identifier")
+
+ /* get the attribute info through the VOL */
+ if(H5VL_attr_get(obj, vol_plugin, H5VL_ATTR_GET_INFO, H5_REQUEST_NULL,
+ loc_params, ainfo) < 0)
+ HGOTO_ERROR(H5E_INTERNAL, H5E_CANTGET, FAIL, "unable to get attribute info")
+
#if 0
/* Open the attribute on the object header */
if(NULL == (attr = H5A_open_by_idx(&loc, obj_name, idx_type, order, n, lapl_id, H5AC_ind_dxpl_id)))
@@ -970,7 +1220,6 @@ H5Aget_info_by_idx(hid_t loc_id, const char *obj_name, H5_index_t idx_type,
/* Get the attribute information */
if(H5A_get_info(attr, ainfo) < 0)
HGOTO_ERROR(H5E_ATTR, H5E_CANTGET, FAIL, "unable to get attribute info")
-#endif
/* open the attribute through the VOL */
if(H5VL_object_misc(loc_id, H5VL_ATTR_OPEN_BY_IDX, H5_REQUEST_NULL, &attr_id,
@@ -981,11 +1230,12 @@ H5Aget_info_by_idx(hid_t loc_id, const char *obj_name, H5_index_t idx_type,
if(H5VL_attr_get(attr_id, H5VL_ATTR_GET_INFO, H5_REQUEST_NULL, ainfo) < 0)
HGOTO_ERROR(H5E_INTERNAL, H5E_CANTGET, FAIL, "unable to get attribute info")
-done:
/* Release resources */
if(attr_id && H5VL_attr_close(attr_id, H5_REQUEST_NULL) < 0)
HDONE_ERROR(H5E_ATTR, H5E_CANTFREE, FAIL, "can't close attribute")
+#endif
+done:
FUNC_LEAVE_API(ret_value)
} /* end H5Aget_info_by_idx() */
@@ -1019,13 +1269,23 @@ H5Arename(hid_t loc_id, const char *old_name, const char *new_name)
/* Avoid thrashing things if the names are the same */
if(HDstrcmp(old_name, new_name)) {
+ H5VL_t *vol_plugin;
+ void *obj;
H5VL_loc_params_t loc_params;
- loc_params.type = H5VL_OBJECT_BY_ID;
- loc_params.loc_data.loc_by_id.id = loc_id;
+ loc_params.type = H5VL_OBJECT_BY_SELF;
+ loc_params.obj_type = H5I_get_type(loc_id);
+
+ /* get the file object */
+ if(NULL == (obj = (void *)H5I_object(loc_id)))
+ HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "invalid file identifier")
+ /* get the plugin pointer */
+ if (NULL == (vol_plugin = (H5VL_t *)H5I_get_aux(loc_id)))
+ HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "ID does not contain VOL information")
/* rename the attribute info through the VOL */
- if(H5VL_object_misc(loc_id, H5VL_ATTR_RENAME, H5_REQUEST_NULL, loc_params, old_name, new_name) < 0)
+ if(H5VL_object_misc(obj, loc_params, vol_plugin, H5VL_ATTR_RENAME, H5_REQUEST_NULL,
+ old_name, new_name) < 0)
HGOTO_ERROR(H5E_ATTR, H5E_CANTRENAME, FAIL, "can't rename attribute")
}
done:
@@ -1073,15 +1333,26 @@ H5Arename_by_name(hid_t loc_id, const char *obj_name, const char *old_attr_name,
/* Avoid thrashing things if the names are the same */
if(HDstrcmp(old_attr_name, new_attr_name)) {
+ H5VL_t *vol_plugin;
+ void *obj;
H5VL_loc_params_t loc_params;
loc_params.type = H5VL_OBJECT_BY_NAME;
loc_params.loc_data.loc_by_name.name = obj_name;
loc_params.loc_data.loc_by_name.plist_id = lapl_id;
+ loc_params.obj_type = H5I_get_type(loc_id);
+
+ /* get the file object */
+ if(NULL == (obj = (void *)H5I_object(loc_id)))
+ HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "invalid file identifier")
+ /* get the plugin pointer */
+ if (NULL == (vol_plugin = (H5VL_t *)H5I_get_aux(loc_id)))
+ HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "ID does not contain VOL information")
- /* get the attribute info through the VOL */
- if(H5VL_object_misc(loc_id, H5VL_ATTR_RENAME, H5_REQUEST_NULL, loc_params, old_attr_name, new_attr_name) < 0)
- HGOTO_ERROR(H5E_INTERNAL, H5E_CANTGET, FAIL, "unable to get attribute info")
+ /* rename the attribute info through the VOL */
+ if(H5VL_object_misc(obj, loc_params, vol_plugin, H5VL_ATTR_RENAME, H5_REQUEST_NULL,
+ old_attr_name, new_attr_name) < 0)
+ HGOTO_ERROR(H5E_ATTR, H5E_CANTRENAME, FAIL, "can't rename attribute")
} /* end if */
done:
@@ -1216,11 +1487,15 @@ H5Aiterate_by_name(hid_t loc_id, const char *obj_name, H5_index_t idx_type,
H5_iter_order_t order, hsize_t *idx, H5A_operator2_t op, void *op_data,
hid_t lapl_id)
{
+ H5G_loc_t loc; /* Object location */
+ H5G_loc_t obj_loc; /* Location used to open group */
+ H5G_name_t obj_path; /* Opened object group hier. path */
+ H5O_loc_t obj_oloc; /* Opened object object location */
+ hbool_t loc_found = FALSE; /* Entry at 'obj_name' found */
hid_t obj_loc_id = (-1); /* ID for object located */
H5A_attr_iter_op_t attr_op; /* Attribute operator */
hsize_t start_idx; /* Index of attribute to start iterating at */
hsize_t last_attr; /* Index of last attribute examined */
- H5VL_loc_params_t loc_params;
herr_t ret_value; /* Return value */
FUNC_ENTER_API(FAIL)
@@ -1230,6 +1505,8 @@ H5Aiterate_by_name(hid_t loc_id, const char *obj_name, H5_index_t idx_type,
/* check arguments */
if(H5I_ATTR == H5I_get_type(loc_id))
HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "location is not valid for an attribute")
+ if(H5G_loc(loc_id, &loc) < 0)
+ HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a location")
if(!obj_name || !*obj_name)
HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "no object name")
if(idx_type <= H5_INDEX_UNKNOWN || idx_type >= H5_INDEX_N)
@@ -1242,13 +1519,19 @@ H5Aiterate_by_name(hid_t loc_id, const char *obj_name, H5_index_t idx_type,
if(TRUE != H5P_isa_class(lapl_id, H5P_LINK_ACCESS))
HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not link access property list ID")
- loc_params.type = H5VL_OBJECT_BY_NAME;
- loc_params.loc_data.loc_by_name.name = obj_name;
- loc_params.loc_data.loc_by_name.plist_id = lapl_id;
+ /* Set up opened group location to fill in */
+ obj_loc.oloc = &obj_oloc;
+ obj_loc.path = &obj_path;
+ H5G_loc_reset(&obj_loc);
- /* Open the object through the VOL */
- if((obj_loc_id = H5VL_object_open(loc_id, loc_params, H5_REQUEST_NULL)) < 0)
- HGOTO_ERROR(H5E_SYM, H5E_CANTINIT, FAIL, "unable to open object")
+ /* Find the object's location */
+ if(H5G_loc_find(&loc, obj_name, &obj_loc/*out*/, lapl_id, H5AC_ind_dxpl_id) < 0)
+ HGOTO_ERROR(H5E_ATTR, H5E_NOTFOUND, FAIL, "object not found")
+ loc_found = TRUE;
+
+ /* Open the object */
+ if((obj_loc_id = H5O_open_by_loc(&obj_loc, lapl_id, H5AC_ind_dxpl_id, TRUE)) < 0)
+ HGOTO_ERROR(H5E_ATTR, H5E_CANTOPENOBJ, FAIL, "unable to open object")
/* Build attribute operator info */
attr_op.op_type = H5A_ATTR_OP_APP2;
@@ -1269,6 +1552,8 @@ done:
if(H5I_dec_app_ref(obj_loc_id) < 0)
HDONE_ERROR(H5E_ATTR, H5E_CANTDEC, FAIL, "unable to close temporary object")
} /* end if */
+ else if(loc_found && H5G_loc_free(&obj_loc) < 0)
+ HDONE_ERROR(H5E_ATTR, H5E_CANTRELEASE, FAIL, "can't free location")
FUNC_LEAVE_API(ret_value)
} /* H5Aiterate_by_name() */
@@ -1291,6 +1576,8 @@ done:
herr_t
H5Adelete(hid_t loc_id, const char *name)
{
+ H5VL_t *vol_plugin;
+ void *obj;
H5VL_loc_params_t loc_params;
herr_t ret_value = SUCCEED; /* Return value */
@@ -1303,11 +1590,18 @@ H5Adelete(hid_t loc_id, const char *name)
if(!name || !*name)
HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "no name")
- loc_params.type = H5VL_OBJECT_BY_ID;
- loc_params.loc_data.loc_by_id.id = loc_id;
+ loc_params.type = H5VL_OBJECT_BY_SELF;
+ loc_params.obj_type = H5I_get_type(loc_id);
+
+ /* get the plugin pointer */
+ if (NULL == (vol_plugin = (H5VL_t *)H5I_get_aux(loc_id)))
+ HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "ID does not contain VOL information")
+ /* get the dataset object */
+ if(NULL == (obj = (void *)H5I_object(loc_id)))
+ HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "invalid object identifier")
/* Open the attribute through the VOL */
- if(H5VL_attr_remove(loc_id, loc_params, name, H5_REQUEST_NULL) < 0)
+ if(H5VL_attr_remove(obj, loc_params, vol_plugin, name, H5_REQUEST_NULL) < 0)
HGOTO_ERROR(H5E_ATTR, H5E_CANTDELETE, FAIL, "unable to delete attribute")
done:
@@ -1335,6 +1629,8 @@ herr_t
H5Adelete_by_name(hid_t loc_id, const char *obj_name, const char *attr_name,
hid_t lapl_id)
{
+ H5VL_t *vol_plugin;
+ void *obj;
H5VL_loc_params_t loc_params;
herr_t ret_value = SUCCEED; /* Return value */
@@ -1357,9 +1653,17 @@ H5Adelete_by_name(hid_t loc_id, const char *obj_name, const char *attr_name,
loc_params.type = H5VL_OBJECT_BY_NAME;
loc_params.loc_data.loc_by_name.name = obj_name;
loc_params.loc_data.loc_by_name.plist_id = lapl_id;
+ loc_params.obj_type = H5I_get_type(loc_id);
+
+ /* get the plugin pointer */
+ if (NULL == (vol_plugin = (H5VL_t *)H5I_get_aux(loc_id)))
+ HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "ID does not contain VOL information")
+ /* get the dataset object */
+ if(NULL == (obj = (void *)H5I_object(loc_id)))
+ HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "invalid object identifier")
/* Open the attribute through the VOL */
- if(H5VL_attr_remove(loc_id, loc_params, attr_name, H5_REQUEST_NULL) < 0)
+ if(H5VL_attr_remove(obj, loc_params, vol_plugin, attr_name, H5_REQUEST_NULL) < 0)
HGOTO_ERROR(H5E_ATTR, H5E_CANTDELETE, FAIL, "unable to delete attribute")
done:
@@ -1395,6 +1699,8 @@ herr_t
H5Adelete_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)
{
+ H5VL_t *vol_plugin;
+ void *obj;
H5VL_loc_params_t loc_params;
herr_t ret_value = SUCCEED; /* Return value */
@@ -1416,6 +1722,26 @@ H5Adelete_by_idx(hid_t loc_id, const char *obj_name, H5_index_t idx_type,
if(TRUE != H5P_isa_class(lapl_id, H5P_LINK_ACCESS))
HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not link access property list ID")
+ loc_params.type = H5VL_OBJECT_BY_IDX;
+ loc_params.loc_data.loc_by_idx.name = obj_name;
+ loc_params.loc_data.loc_by_idx.idx_type = idx_type;
+ loc_params.loc_data.loc_by_idx.order = order;
+ loc_params.loc_data.loc_by_idx.n = n;
+ loc_params.loc_data.loc_by_idx.plist_id = lapl_id;
+ loc_params.obj_type = H5I_get_type(loc_id);
+
+ /* get the plugin pointer */
+ if (NULL == (vol_plugin = (H5VL_t *)H5I_get_aux(loc_id)))
+ HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "ID does not contain VOL information")
+ /* get the dataset object */
+ if(NULL == (obj = (void *)H5I_object(loc_id)))
+ HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "invalid object identifier")
+
+ /* Open the attribute through the VOL */
+ if(H5VL_attr_remove(obj, loc_params, vol_plugin, NULL, H5_REQUEST_NULL) < 0)
+ HGOTO_ERROR(H5E_ATTR, H5E_CANTDELETE, FAIL, "unable to delete attribute")
+
+#if 0
loc_params.type = H5VL_OBJECT_BY_NAME;
loc_params.loc_data.loc_by_name.name = obj_name;
loc_params.loc_data.loc_by_name.plist_id = lapl_id;
@@ -1424,6 +1750,7 @@ H5Adelete_by_idx(hid_t loc_id, const char *obj_name, H5_index_t idx_type,
if(H5VL_object_misc(loc_id, H5VL_ATTR_DELETE_BY_IDX, H5_REQUEST_NULL, loc_params,
idx_type, order, n) < 0)
HGOTO_ERROR(H5E_INTERNAL, H5E_CANTGET, FAIL, "unable to get attribute info")
+#endif
done:
FUNC_LEAVE_API(ret_value)
@@ -1453,9 +1780,13 @@ H5Aclose(hid_t attr_id)
FUNC_ENTER_API(FAIL)
H5TRACE1("e", "i", attr_id);
- /* Close the attribute through the VOL */
- if((ret_value = H5VL_attr_close(attr_id, H5_REQUEST_NULL)) < 0)
- HGOTO_ERROR(H5E_ATTR, H5E_CANTRELEASE, FAIL, "unable to close attribute")
+ /* check arguments */
+ if(NULL == H5I_object_verify(attr_id, H5I_ATTR))
+ HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not an attribute")
+
+ /* Decrement references to that atom (and close it) */
+ if(H5I_dec_app_ref(attr_id) < 0)
+ HGOTO_ERROR(H5E_ATTR, H5E_CANTDEC, FAIL, "can't close attribute")
done:
FUNC_LEAVE_API(ret_value)
@@ -1479,6 +1810,8 @@ done:
htri_t
H5Aexists(hid_t obj_id, const char *attr_name)
{
+ H5VL_t *vol_plugin;
+ void *obj;
H5VL_loc_params_t loc_params;
htri_t ret_value; /* Return value */
@@ -1491,11 +1824,18 @@ H5Aexists(hid_t obj_id, const char *attr_name)
if(!attr_name || !*attr_name)
HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "no attribute name")
- loc_params.type = H5VL_OBJECT_BY_ID;
- loc_params.loc_data.loc_by_id.id = obj_id;
+ /* get the plugin pointer */
+ if (NULL == (vol_plugin = (H5VL_t *)H5I_get_aux(obj_id)))
+ HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "ID does not contain VOL information")
+ /* get the dataset object */
+ if(NULL == (obj = (void *)H5I_object(obj_id)))
+ HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "invalid object identifier")
+
+ loc_params.type = H5VL_OBJECT_BY_SELF;
+ loc_params.obj_type = H5I_get_type(obj_id);
/* get the attribute info through the VOL */
- if(H5VL_attr_get(obj_id, H5VL_ATTR_EXISTS, H5_REQUEST_NULL, attr_name, loc_params, &ret_value) < 0)
+ if(H5VL_attr_get(obj, vol_plugin, H5VL_ATTR_EXISTS, H5_REQUEST_NULL, loc_params, attr_name, &ret_value) < 0)
HGOTO_ERROR(H5E_INTERNAL, H5E_CANTGET, FAIL, "unable to get attribute info")
done:
@@ -1520,6 +1860,8 @@ htri_t
H5Aexists_by_name(hid_t loc_id, const char *obj_name, const char *attr_name,
hid_t lapl_id)
{
+ H5VL_t *vol_plugin;
+ void *obj;
H5VL_loc_params_t loc_params;
htri_t ret_value; /* Return value */
@@ -1539,14 +1881,60 @@ H5Aexists_by_name(hid_t loc_id, const char *obj_name, const char *attr_name,
if(TRUE != H5P_isa_class(lapl_id, H5P_LINK_ACCESS))
HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not link access property list ID")
+ /* get the plugin pointer */
+ if (NULL == (vol_plugin = (H5VL_t *)H5I_get_aux(loc_id)))
+ HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "ID does not contain VOL information")
+ /* get the dataset object */
+ if(NULL == (obj = (void *)H5I_object(loc_id)))
+ HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "invalid object identifier")
+
loc_params.type = H5VL_OBJECT_BY_NAME;
loc_params.loc_data.loc_by_name.name = obj_name;
loc_params.loc_data.loc_by_name.plist_id = lapl_id;
+ loc_params.obj_type = H5I_get_type(loc_id);
/* get the attribute info through the VOL */
- if(H5VL_attr_get(loc_id, H5VL_ATTR_EXISTS, H5_REQUEST_NULL, attr_name, loc_params, &ret_value) < 0)
+ if(H5VL_attr_get(obj, vol_plugin, H5VL_ATTR_EXISTS, H5_REQUEST_NULL, loc_params, attr_name, &ret_value) < 0)
HGOTO_ERROR(H5E_INTERNAL, H5E_CANTGET, FAIL, "unable to get attribute info")
done:
FUNC_LEAVE_API(ret_value)
} /* H5Aexists_by_name() */
+
+
+/*-------------------------------------------------------------------------
+ * Function: H5A_close_attr
+ *
+ * Purpose: Called when the ref count reaches zero on the attr_id
+ *
+ * Return: Success: Non-negative
+ *
+ * Failure: Negative
+ *
+ * Programmer: Mohamad Chaarawi
+ * June 2012
+ *
+ *-------------------------------------------------------------------------
+ */
+herr_t
+H5A_close_attr(void *attr, H5VL_t *vol_plugin)
+{
+ herr_t ret_value = SUCCEED; /* Return value */
+
+ FUNC_ENTER_NOAPI_NOINIT
+
+ /* Close the attr through the VOL*/
+ if((ret_value = H5VL_attr_close(attr, vol_plugin, H5_REQUEST_NULL)) < 0)
+ HGOTO_ERROR(H5E_ATTR, H5E_CLOSEERROR, FAIL, "unable to close attribute")
+
+ vol_plugin->nrefs --;
+ if (0 == vol_plugin->nrefs) {
+ if (NULL != vol_plugin->container_name)
+ H5MM_xfree(vol_plugin->container_name);
+ if (NULL != vol_plugin)
+ H5MM_free(vol_plugin);
+ }
+
+done:
+ FUNC_LEAVE_NOAPI(ret_value)
+} /* end H5A_close_attr() */
diff --git a/src/H5Adeprec.c b/src/H5Adeprec.c
index 1fbc1ae..13debcf 100644
--- a/src/H5Adeprec.c
+++ b/src/H5Adeprec.c
@@ -139,6 +139,9 @@ hid_t
H5Acreate1(hid_t loc_id, const char *name, hid_t type_id, hid_t space_id,
hid_t plist_id)
{
+ void *attr = NULL; /* attr token from VOL plugin */
+ void *obj = NULL; /* object token of loc_id */
+ H5VL_t *vol_plugin; /* VOL plugin information */
H5VL_loc_params_t loc_params;
H5P_genplist_t *plist; /* Property list pointer */
hid_t ret_value; /* Return value */
@@ -156,9 +159,6 @@ H5Acreate1(hid_t loc_id, const char *name, hid_t type_id, hid_t space_id,
if(H5P_DEFAULT == plist_id)
plist_id = H5P_ATTRIBUTE_CREATE_DEFAULT;
- loc_params.type = H5VL_OBJECT_BY_ID;
- loc_params.loc_data.loc_by_id.id = loc_id;
-
/* Get the plist structure */
if(NULL == (plist = (H5P_genplist_t *)H5I_object(plist_id)))
HGOTO_ERROR(H5E_ATOM, H5E_BADATOM, FAIL, "can't find object for ID")
@@ -168,14 +168,36 @@ H5Acreate1(hid_t loc_id, const char *name, hid_t type_id, hid_t space_id,
HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, FAIL, "can't set property value for datatype id")
if(H5P_set(plist, H5VL_ATTR_SPACE_ID, &space_id) < 0)
HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, FAIL, "can't set property value for space id")
- if(H5P_set(plist, H5VL_ATTR_LOC_PARAMS, &loc_params) < 0)
- HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, FAIL, "can't set property value for location")
+
+ loc_params.type = H5VL_OBJECT_BY_SELF;
+ loc_params.obj_type = H5I_get_type(loc_id);
+
+ /* get the file object */
+ if(NULL == (obj = (void *)H5I_object(loc_id)))
+ HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "invalid file identifier")
+
+ /* get the plugin pointer */
+ if (NULL == (vol_plugin = (H5VL_t *)H5I_get_aux(loc_id)))
+ HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "ID does not contain VOL information")
/* Create the attribute through the VOL */
- if((ret_value = H5VL_attr_create(loc_id, name, plist_id, H5P_DEFAULT, H5_REQUEST_NULL)) < 0)
+ if(NULL == (attr = H5VL_attr_create(obj, loc_params, vol_plugin, name, plist_id, H5P_DEFAULT, H5_REQUEST_NULL)))
HGOTO_ERROR(H5E_SYM, H5E_CANTINIT, FAIL, "unable to create attribute")
+ /* Get an atom for the attribute */
+ if((ret_value = H5I_register(H5I_ATTR, attr, TRUE)) < 0)
+ HGOTO_ERROR(H5E_ATOM, H5E_CANTREGISTER, FAIL, "unable to atomize attribute handle")
+
+ /* attach VOL information to the ID */
+ if (H5I_register_aux(ret_value, vol_plugin, (H5I_free2_t)H5A_close_attr) < 0)
+ HGOTO_ERROR(H5E_VOL, H5E_CANTINIT, FAIL, "can't attach vol info to ID")
+
+ vol_plugin->nrefs ++;
+
done:
+ if (ret_value < 0 && attr)
+ if(H5VL_attr_close (attr, vol_plugin, H5_REQUEST_NULL) < 0)
+ HDONE_ERROR(H5E_DATASET, H5E_CLOSEERROR, FAIL, "unable to release dataset")
FUNC_LEAVE_API(ret_value)
} /* H5Acreate1() */
@@ -205,6 +227,9 @@ done:
hid_t
H5Aopen_name(hid_t loc_id, const char *name)
{
+ void *attr = NULL; /* attr token from VOL plugin */
+ void *obj = NULL; /* object token of loc_id */
+ H5VL_t *vol_plugin; /* VOL plugin information */
H5VL_loc_params_t loc_params;
hid_t ret_value;
@@ -217,14 +242,35 @@ H5Aopen_name(hid_t loc_id, const char *name)
if(!name || !*name)
HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "no name")
- loc_params.type = H5VL_OBJECT_BY_ID;
- loc_params.loc_data.loc_by_id.id = loc_id;
+ loc_params.type = H5VL_OBJECT_BY_SELF;
+ loc_params.obj_type = H5I_get_type(loc_id);
+
+ /* get the file object */
+ if(NULL == (obj = (void *)H5I_object(loc_id)))
+ HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "invalid file identifier")
+
+ /* get the plugin pointer */
+ if (NULL == (vol_plugin = (H5VL_t *)H5I_get_aux(loc_id)))
+ HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "ID does not contain VOL information")
+
+ /* Create the attribute through the VOL */
+ if(NULL == (attr = H5VL_attr_open(obj, loc_params, vol_plugin, name, H5P_DEFAULT, H5_REQUEST_NULL)))
+ HGOTO_ERROR(H5E_SYM, H5E_CANTINIT, FAIL, "unable to open attribute")
- /* Open the attribute through the VOL */
- if((ret_value = H5VL_attr_open(loc_id, loc_params, name, H5P_DEFAULT, H5_REQUEST_NULL)) < 0)
- HGOTO_ERROR(H5E_ATTR, H5E_CANTINIT, FAIL, "unable to open attribute")
+ /* Get an atom for the attribute */
+ if((ret_value = H5I_register(H5I_ATTR, attr, TRUE)) < 0)
+ HGOTO_ERROR(H5E_ATOM, H5E_CANTREGISTER, FAIL, "unable to atomize attribute handle")
+
+ /* attach VOL information to the ID */
+ if (H5I_register_aux(ret_value, vol_plugin, (H5I_free2_t)H5A_close_attr) < 0)
+ HGOTO_ERROR(H5E_VOL, H5E_CANTINIT, FAIL, "can't attach vol info to ID")
+
+ vol_plugin->nrefs ++;
done:
+ if (ret_value < 0 && attr)
+ if(H5VL_attr_close (attr, vol_plugin, H5_REQUEST_NULL) < 0)
+ HDONE_ERROR(H5E_DATASET, H5E_CLOSEERROR, FAIL, "unable to release dataset")
FUNC_LEAVE_API(ret_value)
} /* H5Aopen_name() */
@@ -254,6 +300,10 @@ done:
hid_t
H5Aopen_idx(hid_t loc_id, unsigned idx)
{
+ void *attr = NULL; /* attr token from VOL plugin */
+ void *obj = NULL; /* object token of loc_id */
+ H5VL_t *vol_plugin; /* VOL plugin information */
+ H5VL_loc_params_t loc_params;
hid_t ret_value;
FUNC_ENTER_API(FAIL)
@@ -263,11 +313,39 @@ H5Aopen_idx(hid_t loc_id, unsigned idx)
if(H5I_ATTR == H5I_get_type(loc_id))
HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "location is not valid for an attribute")
- if(H5VL_object_misc(loc_id, H5VL_ATTR_OPEN_BY_IDX, H5_REQUEST_NULL, &ret_value, ".", H5_INDEX_CRT_ORDER,
- H5_ITER_INC, (hsize_t)idx, H5P_DEFAULT, H5P_LINK_ACCESS_DEFAULT) < 0)
- HGOTO_ERROR(H5E_INTERNAL, H5E_CANTGET, FAIL, "unable to get dataset access properties")
+ loc_params.type = H5VL_OBJECT_BY_IDX;
+ loc_params.loc_data.loc_by_idx.name = ".";
+ loc_params.loc_data.loc_by_idx.idx_type = H5_INDEX_CRT_ORDER;
+ loc_params.loc_data.loc_by_idx.order = H5_ITER_INC;
+ loc_params.loc_data.loc_by_idx.n = (hsize_t)idx;
+ loc_params.loc_data.loc_by_idx.plist_id = H5P_LINK_ACCESS_DEFAULT;
+ loc_params.obj_type = H5I_get_type(loc_id);
+
+ /* get the file object */
+ if(NULL == (obj = (void *)H5I_object(loc_id)))
+ HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "invalid file identifier")
+ /* get the plugin pointer */
+ if (NULL == (vol_plugin = (H5VL_t *)H5I_get_aux(loc_id)))
+ HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "ID does not contain VOL information")
+
+ /* Create the attribute through the VOL */
+ if(NULL == (attr = H5VL_attr_open(obj, loc_params, vol_plugin, NULL, H5P_DEFAULT, H5_REQUEST_NULL)))
+ HGOTO_ERROR(H5E_SYM, H5E_CANTINIT, FAIL, "unable to open attribute")
+
+ /* Get an atom for the attribute */
+ if((ret_value = H5I_register(H5I_ATTR, attr, TRUE)) < 0)
+ HGOTO_ERROR(H5E_ATOM, H5E_CANTREGISTER, FAIL, "unable to atomize attribute handle")
+
+ /* attach VOL information to the ID */
+ if (H5I_register_aux(ret_value, vol_plugin, (H5I_free2_t)H5A_close_attr) < 0)
+ HGOTO_ERROR(H5E_VOL, H5E_CANTINIT, FAIL, "can't attach vol info to ID")
+
+ vol_plugin->nrefs ++;
done:
+ if (ret_value < 0 && attr)
+ if(H5VL_attr_close (attr, vol_plugin, H5_REQUEST_NULL) < 0)
+ HDONE_ERROR(H5E_DATASET, H5E_CLOSEERROR, FAIL, "unable to release dataset")
FUNC_LEAVE_API(ret_value)
} /* H5Aopen_idx() */
@@ -293,14 +371,28 @@ done:
int
H5Aget_num_attrs(hid_t loc_id)
{
+ H5VL_t *vol_plugin;
+ void *obj;
+ H5VL_loc_params_t loc_params;
H5O_info_t oinfo;
int ret_value;
FUNC_ENTER_API(FAIL)
H5TRACE1("Is", "i", loc_id);
+ loc_params.type = H5VL_OBJECT_BY_SELF;
+ loc_params.obj_type = H5I_get_type(loc_id);
+
+ /* get the file object */
+ if(NULL == (obj = (void *)H5I_object(loc_id)))
+ HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "invalid file identifier")
+ /* get the plugin pointer */
+ if (NULL == (vol_plugin = (H5VL_t *)H5I_get_aux(loc_id)))
+ HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "ID does not contain VOL information")
+
/* Get the group info through the VOL using the location token */
- if(H5VL_object_get(loc_id, H5VL_OBJECT_GET_INFO, H5_REQUEST_NULL, &oinfo, NULL) < 0)
+ if(H5VL_object_get(obj, loc_params, vol_plugin, H5VL_OBJECT_GET_INFO,
+ H5_REQUEST_NULL, &oinfo) < 0)
HGOTO_ERROR(H5E_INTERNAL, H5E_CANTGET, FAIL, "unable to get group info")
ret_value = oinfo.num_attrs;
diff --git a/src/H5Aint.c b/src/H5Aint.c
index 3cc0cc0..3a4bfd4 100644
--- a/src/H5Aint.c
+++ b/src/H5Aint.c
@@ -131,24 +131,27 @@ H5FL_SEQ_DEFINE(H5A_t_ptr);
* H5S_t *space; IN: Dataspace of attribute
* hid_t acpl_id IN: Attribute creation property list
*
- * Return: Non-negative on success/Negative on failure
+ * Return: attribute structure on success, NULL on Failuer
*
* Programmer: Quincey Koziol
* April 2, 1998
*
+ * Modified: Mohamad Chaarawi
+ * June 2012
+ * Retuen H5A_t* instead of hid_t
+ *
*-------------------------------------------------------------------------
*/
-hid_t
+H5A_t *
H5A_create(const H5G_loc_t *loc, const char *name, const H5T_t *type,
const H5S_t *space, hid_t acpl_id, hid_t dxpl_id)
{
- H5A_t *attr = NULL; /* Attribute created */
hssize_t snelmts; /* elements in attribute */
size_t nelmts; /* elements in attribute */
htri_t tri_ret; /* htri_t return value */
- hid_t ret_value; /* Return value */
+ H5A_t *ret_value = NULL; /* Attribute created */
- FUNC_ENTER_NOAPI_NOINIT_TAG(dxpl_id, loc->oloc->addr, FAIL)
+ FUNC_ENTER_NOAPI_NOINIT_TAG(dxpl_id, loc->oloc->addr, NULL)
/* check args */
HDassert(loc);
@@ -162,128 +165,120 @@ H5A_create(const H5G_loc_t *loc, const char *name, const H5T_t *type,
* failure, so just check first, for now - QAK)
*/
if((tri_ret = H5O_attr_exists(loc->oloc, name, H5AC_ind_dxpl_id)) < 0)
- HGOTO_ERROR(H5E_ATTR, H5E_NOTFOUND, FAIL, "error checking attributes")
+ HGOTO_ERROR(H5E_ATTR, H5E_NOTFOUND, NULL, "error checking attributes")
else if(tri_ret > 0)
- HGOTO_ERROR(H5E_ATTR, H5E_ALREADYEXISTS, FAIL, "attribute already exists")
+ HGOTO_ERROR(H5E_ATTR, H5E_ALREADYEXISTS, NULL, "attribute already exists")
/* Check if the dataspace has an extent set (or is NULL) */
if(!(H5S_has_extent(space)))
- HGOTO_ERROR(H5E_ATTR, H5E_BADVALUE, FAIL, "dataspace extent has not been set")
+ HGOTO_ERROR(H5E_ATTR, H5E_BADVALUE, NULL, "dataspace extent has not been set")
/* Check if the datatype is "sensible" for use in a dataset */
if(H5T_is_sensible(type) != TRUE)
- HGOTO_ERROR(H5E_ATTR, H5E_BADTYPE, FAIL, "datatype is not sensible")
+ HGOTO_ERROR(H5E_ATTR, H5E_BADTYPE, NULL, "datatype is not sensible")
/* Build the attribute information */
- if(NULL == (attr = H5FL_CALLOC(H5A_t)))
- HGOTO_ERROR(H5E_ATTR, H5E_CANTALLOC, FAIL, "memory allocation failed for attribute info")
+ if(NULL == (ret_value = H5FL_CALLOC(H5A_t)))
+ HGOTO_ERROR(H5E_ATTR, H5E_CANTALLOC, NULL, "memory allocation failed for attribute info")
- if(NULL == (attr->shared = H5FL_CALLOC(H5A_shared_t)))
- HGOTO_ERROR(H5E_ATTR, H5E_CANTALLOC, FAIL, "can't allocate shared attr structure")
+ if(NULL == (ret_value->shared = H5FL_CALLOC(H5A_shared_t)))
+ HGOTO_ERROR(H5E_ATTR, H5E_CANTALLOC, NULL, "can't allocate shared attr structure")
/* If the creation property list is H5P_DEFAULT, use the default character encoding */
if(acpl_id == H5P_DEFAULT)
- attr->shared->encoding = H5F_DEFAULT_CSET;
+ ret_value->shared->encoding = H5F_DEFAULT_CSET;
else {
H5P_genplist_t *ac_plist; /* ACPL Property list */
/* Get a local copy of the attribute creation property list */
if(NULL == (ac_plist = (H5P_genplist_t *)H5I_object(acpl_id)))
- HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a property list")
+ HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, NULL, "not a property list")
- if(H5P_get(ac_plist, H5P_STRCRT_CHAR_ENCODING_NAME, &(attr->shared->encoding)) < 0)
- HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, FAIL, "can't get character encoding flag")
+ if(H5P_get(ac_plist, H5P_STRCRT_CHAR_ENCODING_NAME, &(ret_value->shared->encoding)) < 0)
+ HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, NULL, "can't get character encoding flag")
} /* end else */
/* Copy the attribute name */
- attr->shared->name = H5MM_xstrdup(name);
+ ret_value->shared->name = H5MM_xstrdup(name);
/* Copy datatype */
- if(NULL == (attr->shared->dt = H5T_copy(type, H5T_COPY_ALL)))
- HGOTO_ERROR(H5E_ATTR, H5E_CANTGET, FAIL, "can't get shared datatype info")
+ if(NULL == (ret_value->shared->dt = H5T_copy(type, H5T_COPY_ALL)))
+ HGOTO_ERROR(H5E_ATTR, H5E_CANTGET, NULL, "can't get shared datatype info")
/* Mark datatype as being on disk now */
- if(H5T_set_loc(attr->shared->dt, loc->oloc->file, H5T_LOC_DISK) < 0)
- HGOTO_ERROR(H5E_DATATYPE, H5E_CANTINIT, FAIL, "invalid datatype location")
+ if(H5T_set_loc(ret_value->shared->dt, loc->oloc->file, H5T_LOC_DISK) < 0)
+ HGOTO_ERROR(H5E_DATATYPE, H5E_CANTINIT, NULL, "invalid datatype location")
/* Set the latest format for datatype, if requested */
if(H5F_USE_LATEST_FORMAT(loc->oloc->file))
- if(H5T_set_latest_version(attr->shared->dt) < 0)
- HGOTO_ERROR(H5E_DATASET, H5E_CANTSET, FAIL, "can't set latest version of datatype")
+ if(H5T_set_latest_version(ret_value->shared->dt) < 0)
+ HGOTO_ERROR(H5E_DATASET, H5E_CANTSET, NULL, "can't set latest version of datatype")
/* Copy the dataspace for the attribute */
- attr->shared->ds = H5S_copy(space, FALSE, TRUE);
+ ret_value->shared->ds = H5S_copy(space, FALSE, TRUE);
/* Set the latest format for dataspace, if requested */
if(H5F_USE_LATEST_FORMAT(loc->oloc->file))
- if(H5S_set_latest_version(attr->shared->ds) < 0)
- HGOTO_ERROR(H5E_DATASET, H5E_CANTSET, FAIL, "can't set latest version of dataspace")
+ if(H5S_set_latest_version(ret_value->shared->ds) < 0)
+ HGOTO_ERROR(H5E_DATASET, H5E_CANTSET, NULL, "can't set latest version of dataspace")
/* Copy the object header information */
- if(H5O_loc_copy(&(attr->oloc), loc->oloc, H5_COPY_DEEP) < 0)
- HGOTO_ERROR(H5E_ATTR, H5E_CANTOPENOBJ, FAIL, "unable to copy entry")
+ if(H5O_loc_copy(&(ret_value->oloc), loc->oloc, H5_COPY_DEEP) < 0)
+ HGOTO_ERROR(H5E_ATTR, H5E_CANTOPENOBJ, NULL, "unable to copy entry")
/* Deep copy of the group hierarchy path */
- if(H5G_name_copy(&(attr->path), loc->path, H5_COPY_DEEP) < 0)
- HGOTO_ERROR(H5E_ATTR, H5E_CANTCOPY, FAIL, "unable to copy path")
+ if(H5G_name_copy(&(ret_value->path), loc->path, H5_COPY_DEEP) < 0)
+ HGOTO_ERROR(H5E_ATTR, H5E_CANTCOPY, NULL, "unable to copy path")
/* Check if any of the pieces should be (or are already) shared in the
* SOHM table
*/
- if(H5SM_try_share(attr->oloc.file, dxpl_id, NULL, 0, H5O_DTYPE_ID, attr->shared->dt, NULL) < 0)
- HGOTO_ERROR(H5E_OHDR, H5E_BADMESG, FAIL, "trying to share datatype failed")
- if(H5SM_try_share(attr->oloc.file, dxpl_id, NULL, 0, H5O_SDSPACE_ID, attr->shared->ds, NULL) < 0)
- HGOTO_ERROR(H5E_OHDR, H5E_BADMESG, FAIL, "trying to share dataspace failed")
+ if(H5SM_try_share(ret_value->oloc.file, dxpl_id, NULL, 0, H5O_DTYPE_ID, ret_value->shared->dt, NULL) < 0)
+ HGOTO_ERROR(H5E_OHDR, H5E_BADMESG, NULL, "trying to share datatype failed")
+ if(H5SM_try_share(ret_value->oloc.file, dxpl_id, NULL, 0, H5O_SDSPACE_ID, ret_value->shared->ds, NULL) < 0)
+ HGOTO_ERROR(H5E_OHDR, H5E_BADMESG, NULL, "trying to share dataspace failed")
/* Check whether datatype is committed & increment ref count
* (to maintain ref. count incr/decr similarity with "shared message"
* type of datatype sharing)
*/
- if(H5T_committed(attr->shared->dt)) {
+ if(H5T_committed(ret_value->shared->dt)) {
/* Increment the reference count on the shared datatype */
- if(H5T_link(attr->shared->dt, 1, dxpl_id) < 0)
- HGOTO_ERROR(H5E_OHDR, H5E_LINKCOUNT, FAIL, "unable to adjust shared datatype link count")
+ if(H5T_link(ret_value->shared->dt, 1, dxpl_id) < 0)
+ HGOTO_ERROR(H5E_OHDR, H5E_LINKCOUNT, NULL, "unable to adjust shared datatype link count")
} /* end if */
/* Compute the size of pieces on disk. This is either the size of the
* datatype and dataspace messages themselves, or the size of the "shared"
* messages if either or both of them are shared.
*/
- attr->shared->dt_size = H5O_msg_raw_size(attr->oloc.file, H5O_DTYPE_ID, FALSE, attr->shared->dt);
- attr->shared->ds_size = H5O_msg_raw_size(attr->oloc.file, H5O_SDSPACE_ID, FALSE, attr->shared->ds);
+ ret_value->shared->dt_size = H5O_msg_raw_size(ret_value->oloc.file, H5O_DTYPE_ID, FALSE, ret_value->shared->dt);
+ ret_value->shared->ds_size = H5O_msg_raw_size(ret_value->oloc.file, H5O_SDSPACE_ID, FALSE, ret_value->shared->ds);
/* Get # of elements for attribute's dataspace */
- if((snelmts = H5S_GET_EXTENT_NPOINTS(attr->shared->ds)) < 0)
- HGOTO_ERROR(H5E_ATTR, H5E_CANTCOUNT, FAIL, "dataspace is invalid")
+ if((snelmts = H5S_GET_EXTENT_NPOINTS(ret_value->shared->ds)) < 0)
+ HGOTO_ERROR(H5E_ATTR, H5E_CANTCOUNT, NULL, "dataspace is invalid")
H5_ASSIGN_OVERFLOW(nelmts, snelmts, hssize_t, size_t);
- HDassert(attr->shared->dt_size > 0);
- HDassert(attr->shared->ds_size > 0);
- attr->shared->data_size = nelmts * H5T_GET_SIZE(attr->shared->dt);
+ HDassert(ret_value->shared->dt_size > 0);
+ HDassert(ret_value->shared->ds_size > 0);
+ ret_value->shared->data_size = nelmts * H5T_GET_SIZE(ret_value->shared->dt);
/* Hold the symbol table entry (and file) open */
- if(H5O_open(&(attr->oloc)) < 0)
- HGOTO_ERROR(H5E_ATTR, H5E_CANTOPENOBJ, FAIL, "unable to open")
- attr->obj_opened = TRUE;
+ if(H5O_open(&(ret_value->oloc)) < 0)
+ HGOTO_ERROR(H5E_ATTR, H5E_CANTOPENOBJ, NULL, "unable to open")
+ ret_value->obj_opened = TRUE;
/* Set the version to encode the attribute with */
- if(H5A_set_version(attr->oloc.file, attr) < 0)
- HGOTO_ERROR(H5E_ATTR, H5E_CANTSET, FAIL, "unable to update attribute version")
+ if(H5A_set_version(ret_value->oloc.file, ret_value) < 0)
+ HGOTO_ERROR(H5E_ATTR, H5E_CANTSET, NULL, "unable to update attribute version")
/* Insert the attribute into the object header */
- if(H5O_attr_create(&(attr->oloc), dxpl_id, attr) < 0)
- HGOTO_ERROR(H5E_ATTR, H5E_CANTINSERT, FAIL, "unable to create attribute in object header")
-
- /* Register the new attribute and get an ID for it */
- if((ret_value = H5I_register(H5I_ATTR, attr, TRUE)) < 0)
- HGOTO_ERROR(H5E_ATOM, H5E_CANTREGISTER, FAIL, "unable to register attribute for ID")
+ if(H5O_attr_create(&(ret_value->oloc), dxpl_id, ret_value) < 0)
+ HGOTO_ERROR(H5E_ATTR, H5E_CANTINSERT, NULL, "unable to create attribute in object header")
done:
- /* Cleanup on failure */
- if(ret_value < 0 && attr && H5A_close(attr) < 0)
- HDONE_ERROR(H5E_ATTR, H5E_CANTFREE, FAIL, "can't close attribute")
-
- FUNC_LEAVE_NOAPI_TAG(ret_value, FAIL)
+ FUNC_LEAVE_NOAPI_TAG(ret_value, NULL)
} /* H5A_create() */
diff --git a/src/H5Apkg.h b/src/H5Apkg.h
index 5257171..c9411d5 100644
--- a/src/H5Apkg.h
+++ b/src/H5Apkg.h
@@ -185,9 +185,9 @@ H5_DLLVAR const H5B2_class_t H5A_BT2_CORDER[1];
/* Function prototypes for H5A package scope */
H5_DLL herr_t H5A_init(void);
-H5_DLL hid_t H5A_create(const H5G_loc_t *loc, const char *name,
+H5_DLL H5A_t *H5A_create(const H5G_loc_t *loc, const char *name,
const H5T_t *type, const H5S_t *space, hid_t acpl_id, hid_t dxpl_id);
-H5_DLL H5A_t * H5A_open_by_name(const H5G_loc_t *loc, const char *obj_name,
+H5_DLL H5A_t *H5A_open_by_name(const H5G_loc_t *loc, const char *obj_name,
const char *attr_name, hid_t lapl_id, hid_t dxpl_id);
H5_DLL H5A_t *H5A_open_by_idx(const H5G_loc_t *loc, const char *obj_name,
H5_index_t idx_type, H5_iter_order_t order, hsize_t n, hid_t lapl_id, hid_t dxpl_id);
diff --git a/src/H5D.c b/src/H5D.c
index 22c020f..3cd3e86 100644
--- a/src/H5D.c
+++ b/src/H5D.c
@@ -31,6 +31,7 @@
#include "H5Eprivate.h" /* Error handling */
#include "H5FLprivate.h" /* Free lists */
#include "H5Iprivate.h" /* IDs */
+#include "H5MMprivate.h" /* Memory management */
#include "H5VLprivate.h" /* VOL plugins */
/****************/
@@ -49,7 +50,6 @@
static herr_t H5D__init_pub_interface(void);
-
/*********************/
/* Package Variables */
/*********************/
@@ -86,9 +86,16 @@ DESCRIPTION
static herr_t
H5D__init_pub_interface(void)
{
- FUNC_ENTER_STATIC_NOERR
+ herr_t ret_value = SUCCEED; /* Return value */
+ FUNC_ENTER_STATIC
+
+ /* Initialize the atom group for the dataset IDs */
+ if(H5I_register_type(H5I_DATASET, (size_t)H5I_DATASETID_HASHSIZE, H5D_RESERVED_ATOMS, NULL)<H5I_FILE_PRIVATE)
+ HGOTO_ERROR(H5E_DATASET, H5E_CANTINIT, FAIL, "unable to initialize interface")
- FUNC_LEAVE_NOAPI(H5D_init())
+ ret_value = H5D_init();
+done:
+ FUNC_LEAVE_NOAPI(ret_value)
} /* H5D__init_pub_interface() */
@@ -125,8 +132,12 @@ hid_t
H5Dcreate2(hid_t loc_id, const char *name, hid_t type_id, hid_t space_id,
hid_t lcpl_id, hid_t dcpl_id, hid_t dapl_id)
{
- H5P_genplist_t *plist; /* Property list pointer */
- hid_t ret_value; /* Return value */
+ void *dset = NULL; /* dset token from VOL plugin */
+ void *obj = NULL; /* object token of loc_id */
+ H5VL_t *vol_plugin; /* VOL plugin information */
+ H5VL_loc_params_t loc_params;
+ H5P_genplist_t *plist; /* Property list pointer */
+ hid_t ret_value = FAIL; /* Return value */
FUNC_ENTER_API(FAIL)
H5TRACE7("i", "i*siiiii", loc_id, name, type_id, space_id, lcpl_id, dcpl_id,
@@ -168,12 +179,35 @@ H5Dcreate2(hid_t loc_id, const char *name, hid_t type_id, hid_t space_id,
if(H5P_set(plist, H5VL_DSET_LCPL_ID, &lcpl_id) < 0)
HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, FAIL, "can't set property value for lcpl id")
+ loc_params.type = H5VL_OBJECT_BY_SELF;
+ loc_params.obj_type = H5I_get_type(loc_id);
+
+ /* get the file object */
+ if(NULL == (obj = (void *)H5I_object(loc_id)))
+ HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "invalid file identifier")
+
+ /* get the plugin pointer */
+ if (NULL == (vol_plugin = (H5VL_t *)H5I_get_aux(loc_id)))
+ HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "ID does not contain VOL information")
+
/* Create the dataset through the VOL */
- if((ret_value = H5VL_dataset_create(loc_id, name, dcpl_id, dapl_id, H5_REQUEST_NULL)) < 0)
+ if(NULL == (dset = H5VL_dataset_create(obj, loc_params, vol_plugin, name, dcpl_id, dapl_id, H5_REQUEST_NULL)))
HGOTO_ERROR(H5E_DATASET, H5E_CANTINIT, FAIL, "unable to create dataset")
-done:
+ /* Get an atom for the dataset */
+ if((ret_value = H5I_register(H5I_DATASET, dset, TRUE)) < 0)
+ HGOTO_ERROR(H5E_ATOM, H5E_CANTREGISTER, FAIL, "unable to atomize dataset handle")
+
+ /* attach VOL information to the ID */
+ if (H5I_register_aux(ret_value, vol_plugin, (H5I_free2_t)H5D_close_dataset) < 0)
+ HGOTO_ERROR(H5E_VOL, H5E_CANTINIT, FAIL, "can't attach vol info to ID")
+
+ vol_plugin->nrefs ++;
+done:
+ if (ret_value < 0 && dset)
+ if(H5VL_dataset_close (dset, vol_plugin, H5_REQUEST_NULL) < 0)
+ HDONE_ERROR(H5E_DATASET, H5E_CLOSEERROR, FAIL, "unable to release dataset")
FUNC_LEAVE_API(ret_value)
} /* end H5Dcreate2() */
@@ -217,6 +251,10 @@ hid_t
H5Dcreate_anon(hid_t loc_id, hid_t type_id, hid_t space_id, hid_t dcpl_id,
hid_t dapl_id)
{
+ void *dset = NULL; /* dset token from VOL plugin */
+ void *obj = NULL; /* object token of loc_id */
+ H5VL_t *vol_plugin; /* VOL plugin information */
+ H5VL_loc_params_t loc_params;
H5P_genplist_t *plist; /* Property list pointer */
hid_t ret_value; /* Return value */
@@ -247,11 +285,35 @@ H5Dcreate_anon(hid_t loc_id, hid_t type_id, hid_t space_id, hid_t dcpl_id,
if(H5P_set(plist, H5VL_DSET_SPACE_ID, &space_id) < 0)
HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, FAIL, "can't set property value for space id")
+ loc_params.type = H5VL_OBJECT_BY_SELF;
+ loc_params.obj_type = H5I_get_type(loc_id);
+
+ /* get the file object */
+ if(NULL == (obj = (void *)H5I_object(loc_id)))
+ HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "invalid file identifier")
+
+ /* get the plugin pointer */
+ if (NULL == (vol_plugin = (H5VL_t *)H5I_get_aux(loc_id)))
+ HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "ID does not contain VOL information")
+
/* Create the dataset through the VOL */
- if((ret_value = H5VL_dataset_create(loc_id, NULL, dcpl_id, dapl_id, H5_REQUEST_NULL)) < 0)
+ if(NULL == (dset = H5VL_dataset_create(obj, loc_params, vol_plugin, NULL, dcpl_id, dapl_id, H5_REQUEST_NULL)))
HGOTO_ERROR(H5E_DATASET, H5E_CANTINIT, FAIL, "unable to create dataset")
-done:
+ /* Get an atom for the dataset */
+ if((ret_value = H5I_register(H5I_DATASET, dset, TRUE)) < 0)
+ HGOTO_ERROR(H5E_ATOM, H5E_CANTREGISTER, FAIL, "unable to atomize dataset handle")
+
+ /* attach VOL information to the ID */
+ if (H5I_register_aux(ret_value, vol_plugin, (H5I_free2_t)H5D_close_dataset) < 0)
+ HGOTO_ERROR(H5E_VOL, H5E_CANTINIT, FAIL, "can't attach vol info to ID")
+
+ vol_plugin->nrefs ++;
+
+done:
+ if (ret_value < 0 && dset)
+ if(H5VL_dataset_close (dset, vol_plugin, H5_REQUEST_NULL) < 0)
+ HDONE_ERROR(H5E_DATASET, H5E_CLOSEERROR, FAIL, "unable to release dataset")
FUNC_LEAVE_API(ret_value)
} /* end H5Dcreate_anon() */
@@ -276,6 +338,10 @@ done:
hid_t
H5Dopen2(hid_t loc_id, const char *name, hid_t dapl_id)
{
+ void *dset = NULL; /* dset token from VOL plugin */
+ void *obj = NULL; /* object token of loc_id */
+ H5VL_t *vol_plugin; /* VOL plugin information */
+ H5VL_loc_params_t loc_params;
hid_t ret_value;
FUNC_ENTER_API(FAIL)
@@ -292,11 +358,35 @@ H5Dopen2(hid_t loc_id, const char *name, hid_t dapl_id)
if(TRUE != H5P_isa_class(dapl_id, H5P_DATASET_ACCESS))
HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not dataset access property list")
- /* Open the dataset through the VOL */
- if((ret_value = H5VL_dataset_open(loc_id, name, dapl_id, H5_REQUEST_NULL)) < 0)
- HGOTO_ERROR(H5E_DATASET, H5E_CANTINIT, FAIL, "unable to open dataset")
-done:
+ loc_params.type = H5VL_OBJECT_BY_SELF;
+ loc_params.obj_type = H5I_get_type(loc_id);
+
+ /* get the file object */
+ if(NULL == (obj = (void *)H5I_object(loc_id)))
+ HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "invalid file identifier")
+
+ /* get the plugin pointer */
+ if (NULL == (vol_plugin = (H5VL_t *)H5I_get_aux(loc_id)))
+ HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "ID does not contain VOL information")
+
+ /* Create the dataset through the VOL */
+ if(NULL == (dset = H5VL_dataset_open(obj, loc_params, vol_plugin, name, dapl_id, H5_REQUEST_NULL)))
+ HGOTO_ERROR(H5E_DATASET, H5E_CANTINIT, FAIL, "unable to create dataset")
+
+ /* Get an atom for the dataset */
+ if((ret_value = H5I_register(H5I_DATASET, dset, TRUE)) < 0)
+ HGOTO_ERROR(H5E_ATOM, H5E_CANTREGISTER, FAIL, "unable to atomize dataset handle")
+ /* attach VOL information to the ID */
+ if (H5I_register_aux(ret_value, vol_plugin, (H5I_free2_t)H5D_close_dataset) < 0)
+ HGOTO_ERROR(H5E_VOL, H5E_CANTINIT, FAIL, "can't attach vol info to ID")
+
+ vol_plugin->nrefs ++;
+
+done:
+ if (ret_value < 0 && dset)
+ if(H5VL_dataset_close (dset, vol_plugin, H5_REQUEST_NULL) < 0)
+ HDONE_ERROR(H5E_DATASET, H5E_CLOSEERROR, FAIL, "unable to release dataset")
FUNC_LEAVE_API(ret_value)
} /* end H5Dopen2() */
@@ -323,9 +413,26 @@ H5Dclose(hid_t dset_id)
FUNC_ENTER_API(FAIL)
H5TRACE1("e", "i", dset_id);
+ /* Check/fix arguments. */
+ if(H5I_DATASET != H5I_get_type(dset_id))
+ HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a dataset ID")
+
+ /*
+ * Decrement the counter on the dataset. It will be freed if the count
+ * reaches zero.
+ *
+ * Pass in TRUE for the 3rd parameter to tell the function to remove
+ * dataset's ID even though the freeing function might fail. Please
+ * see the comments in H5I_dec_ref for details. (SLU - 2010/9/7)
+ */
+ if(H5I_dec_app_ref_always_close(dset_id) < 0)
+ HGOTO_ERROR(H5E_DATASET, H5E_CANTDEC, FAIL, "can't decrement count on dataset ID")
+
+#if 0
/* Close the dataset through the VOL */
if((ret_value = H5VL_dataset_close(dset_id, H5_REQUEST_NULL)) < 0)
HGOTO_ERROR(H5E_DATASET, H5E_CANTRELEASE, FAIL, "unable to close dataset")
+#endif
done:
FUNC_LEAVE_API(ret_value)
@@ -351,13 +458,22 @@ done:
hid_t
H5Dget_space(hid_t dset_id)
{
+ H5VL_t *vol_plugin;
+ void *dset;
hid_t ret_value = FAIL;
FUNC_ENTER_API(FAIL)
H5TRACE1("i", "i", dset_id);
+ /* get the plugin pointer */
+ if (NULL == (vol_plugin = (H5VL_t *)H5I_get_aux(dset_id)))
+ HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "ID does not contain VOL information")
+ /* get the dataset object */
+ if(NULL == (dset = (void *)H5I_object(dset_id)))
+ HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "invalid dataset identifier")
+
/* get the dataspace through the VOL */
- if(H5VL_dataset_get(dset_id, H5VL_DATASET_GET_SPACE, H5_REQUEST_NULL, &ret_value) < 0)
+ if(H5VL_dataset_get(dset, vol_plugin, H5VL_DATASET_GET_SPACE, H5_REQUEST_NULL, &ret_value) < 0)
HGOTO_ERROR(H5E_INTERNAL, H5E_CANTGET, FAIL, "unable to get data space")
done:
FUNC_LEAVE_API(ret_value)
@@ -381,13 +497,22 @@ done:
herr_t
H5Dget_space_status(hid_t dset_id, H5D_space_status_t *allocation)
{
+ H5VL_t *vol_plugin;
+ void *dset;
herr_t ret_value = SUCCEED;
FUNC_ENTER_API(FAIL)
H5TRACE2("e", "i*Ds", dset_id, allocation);
+ /* get the plugin pointer */
+ if (NULL == (vol_plugin = (H5VL_t *)H5I_get_aux(dset_id)))
+ HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "ID does not contain VOL information")
+ /* get the dataset object */
+ if(NULL == (dset = (void *)H5I_object(dset_id)))
+ HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "invalid dataset identifier")
+
/* Read data space address through the VOL and return */
- if((ret_value=H5VL_dataset_get(dset_id, H5VL_DATASET_GET_SPACE_STATUS, H5_REQUEST_NULL, allocation)) < 0)
+ if((ret_value=H5VL_dataset_get(dset, vol_plugin, H5VL_DATASET_GET_SPACE_STATUS, H5_REQUEST_NULL, allocation)) < 0)
HGOTO_ERROR(H5E_INTERNAL, H5E_CANTGET, FAIL, "unable to get space status")
done:
@@ -414,13 +539,22 @@ done:
hid_t
H5Dget_type(hid_t dset_id)
{
+ H5VL_t *vol_plugin;
+ void *dset;
hid_t ret_value = FAIL; /* Return value */
FUNC_ENTER_API(FAIL)
H5TRACE1("i", "i", dset_id);
+ /* get the plugin pointer */
+ if (NULL == (vol_plugin = (H5VL_t *)H5I_get_aux(dset_id)))
+ HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "ID does not contain VOL information")
+ /* get the dataset object */
+ if(NULL == (dset = (void *)H5I_object(dset_id)))
+ HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "invalid dataset identifier")
+
/* get the datatype through the VOL */
- if(H5VL_dataset_get(dset_id, H5VL_DATASET_GET_TYPE, H5_REQUEST_NULL, &ret_value) < 0)
+ if(H5VL_dataset_get(dset, vol_plugin, H5VL_DATASET_GET_TYPE, H5_REQUEST_NULL, &ret_value) < 0)
HGOTO_ERROR(H5E_INTERNAL, H5E_CANTGET, FAIL, "unable to get datatype")
done:
@@ -447,12 +581,21 @@ done:
hid_t
H5Dget_create_plist(hid_t dset_id)
{
+ H5VL_t *vol_plugin;
+ void *dset;
hid_t ret_value = FAIL; /* Return value */
FUNC_ENTER_API(FAIL)
H5TRACE1("i", "i", dset_id);
- if(H5VL_dataset_get(dset_id, H5VL_DATASET_GET_DCPL, H5_REQUEST_NULL, &ret_value) < 0)
+ /* get the plugin pointer */
+ if (NULL == (vol_plugin = (H5VL_t *)H5I_get_aux(dset_id)))
+ HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "ID does not contain VOL information")
+ /* get the dataset object */
+ if(NULL == (dset = (void *)H5I_object(dset_id)))
+ HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "invalid dataset identifier")
+
+ if(H5VL_dataset_get(dset, vol_plugin, H5VL_DATASET_GET_DCPL, H5_REQUEST_NULL, &ret_value) < 0)
HGOTO_ERROR(H5E_INTERNAL, H5E_CANTGET, FAIL, "unable to get dataset creation properties")
done:
@@ -496,12 +639,21 @@ done:
hid_t
H5Dget_access_plist(hid_t dset_id)
{
+ H5VL_t *vol_plugin;
+ void *dset;
hid_t ret_value = FAIL; /* Return value */
FUNC_ENTER_API(FAIL)
H5TRACE1("i", "i", dset_id);
- if(H5VL_dataset_get(dset_id, H5VL_DATASET_GET_DAPL, H5_REQUEST_NULL, &ret_value) < 0)
+ /* get the plugin pointer */
+ if (NULL == (vol_plugin = (H5VL_t *)H5I_get_aux(dset_id)))
+ HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "ID does not contain VOL information")
+ /* get the dataset object */
+ if(NULL == (dset = (void *)H5I_object(dset_id)))
+ HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "invalid dataset identifier")
+
+ if(H5VL_dataset_get(dset, vol_plugin, H5VL_DATASET_GET_DAPL, H5_REQUEST_NULL, &ret_value) < 0)
HGOTO_ERROR(H5E_INTERNAL, H5E_CANTGET, FAIL, "unable to get dataset access properties")
done:
@@ -530,13 +682,22 @@ done:
hsize_t
H5Dget_storage_size(hid_t dset_id)
{
+ H5VL_t *vol_plugin;
+ void *dset;
hsize_t ret_value; /* Return value */
FUNC_ENTER_API(0)
H5TRACE1("h", "i", dset_id);
+ /* get the plugin pointer */
+ if (NULL == (vol_plugin = (H5VL_t *)H5I_get_aux(dset_id)))
+ HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, 0, "ID does not contain VOL information")
+ /* get the dataset object */
+ if(NULL == (dset = (void *)H5I_object(dset_id)))
+ HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, 0, "invalid dataset identifier")
+
/* get storage size through the VOL */
- if(H5VL_dataset_get(dset_id, H5VL_DATASET_GET_STORAGE_SIZE, H5_REQUEST_NULL, &ret_value) < 0)
+ if(H5VL_dataset_get(dset, vol_plugin, H5VL_DATASET_GET_STORAGE_SIZE, H5_REQUEST_NULL, &ret_value) < 0)
HGOTO_ERROR(H5E_INTERNAL, H5E_CANTGET, 0, "unable to get storage size")
done:
@@ -561,13 +722,22 @@ done:
haddr_t
H5Dget_offset(hid_t dset_id)
{
+ H5VL_t *vol_plugin;
+ void *dset;
haddr_t ret_value; /* Return value */
FUNC_ENTER_API(HADDR_UNDEF)
H5TRACE1("a", "i", dset_id);
+ /* get the plugin pointer */
+ if (NULL == (vol_plugin = (H5VL_t *)H5I_get_aux(dset_id)))
+ HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, HADDR_UNDEF, "ID does not contain VOL information")
+ /* get the dataset object */
+ if(NULL == (dset = (void *)H5I_object(dset_id)))
+ HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, HADDR_UNDEF, "invalid dataset identifier")
+
/* get offset through the VOL */
- if(H5VL_dataset_get(dset_id, H5VL_DATASET_GET_OFFSET, H5_REQUEST_NULL, &ret_value) < 0)
+ if(H5VL_dataset_get(dset, vol_plugin, H5VL_DATASET_GET_OFFSET, H5_REQUEST_NULL, &ret_value) < 0)
HGOTO_ERROR(H5E_INTERNAL, H5E_CANTGET, HADDR_UNDEF, "unable to get offset")
done:
@@ -761,10 +931,23 @@ H5Dvlen_get_buf_size(hid_t dataset_id, hid_t type_id, hid_t space_id,
/* Save the dataset ID */
vlen_bufsize.dataset_id = dataset_id;
- /* Get a copy of the dataspace ID */
- if(H5VL_dataset_get(dataset_id, H5VL_DATASET_GET_SPACE, H5_REQUEST_NULL, &(vlen_bufsize.fspace_id)) < 0)
- //if((vlen_bufsize.fspace_id = H5Dget_space(dataset_id)) < 0)
+ if((vlen_bufsize.fspace_id = H5Dget_space(dataset_id)) < 0)
HGOTO_ERROR(H5E_DATASPACE, H5E_CANTCOPY, FAIL, "can't copy dataspace")
+#if 0
+ {
+ H5VL_t *vol_plugin;
+ void *dset;
+ /* get the plugin pointer */
+ if (NULL == (vol_plugin = (H5VL_t *)H5I_get_aux(dataset_id)))
+ HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "ID does not contain VOL information")
+ /* get the dataset object */
+ if(NULL == (dset = (void *)H5I_object(dataset_id)))
+ HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "invalid dataset identifier")
+ /* Get a copy of the dataspace ID */
+ if(H5VL_dataset_get(dset, vol_plugin, H5VL_DATASET_GET_SPACE, H5_REQUEST_NULL, &(vlen_bufsize.fspace_id)) < 0)
+ HGOTO_ERROR(H5E_DATASPACE, H5E_CANTCOPY, FAIL, "can't copy dataspace")
+ }
+#endif
/* Create a scalar for the memory dataspace */
if((vlen_bufsize.mspace_id = H5Screate(H5S_SCALAR)) < 0)
@@ -834,6 +1017,8 @@ done:
herr_t
H5Dset_extent(hid_t dset_id, const hsize_t size[])
{
+ H5VL_t *vol_plugin;
+ void *dset;
herr_t ret_value = SUCCEED; /* Return value */
FUNC_ENTER_API(FAIL)
@@ -842,11 +1027,55 @@ H5Dset_extent(hid_t dset_id, const hsize_t size[])
if(!size)
HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "no size specified")
+ /* get the plugin pointer */
+ if (NULL == (vol_plugin = (H5VL_t *)H5I_get_aux(dset_id)))
+ HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "ID does not contain VOL information")
+ /* get the dataset object */
+ if(NULL == (dset = (void *)H5I_object(dset_id)))
+ HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "invalid dataset identifier")
+
/* set the extent through the VOL */
- if((ret_value = H5VL_dataset_set_extent(dset_id, size, H5_REQUEST_NULL)) < 0)
+ if((ret_value = H5VL_dataset_set_extent(dset, vol_plugin, size, H5_REQUEST_NULL)) < 0)
HGOTO_ERROR(H5E_DATASET, H5E_CANTINIT, FAIL, "unable to set extent of dataset")
done:
FUNC_LEAVE_API(ret_value)
} /* end H5Dset_extent() */
+
+/*-------------------------------------------------------------------------
+ * Function: H5D_close_dataset
+ *
+ * Purpose: Called when the ref count reaches zero on the dataset_id
+ *
+ * Return: Success: Non-negative
+ *
+ * Failure: Negative
+ *
+ * Programmer: Mohamad Chaarawi
+ * June 2012
+ *
+ *-------------------------------------------------------------------------
+ */
+herr_t
+H5D_close_dataset(void *dset, H5VL_t *vol_plugin)
+{
+ herr_t ret_value = SUCCEED; /* Return value */
+
+ FUNC_ENTER_NOAPI_NOINIT
+
+ /* Close the dataset through the VOL*/
+ if((ret_value = H5VL_dataset_close(dset, vol_plugin, H5_REQUEST_NULL)) < 0)
+ HGOTO_ERROR(H5E_DATASET, H5E_CLOSEERROR, FAIL, "unable to close dataset")
+
+ vol_plugin->nrefs --;
+ if (0 == vol_plugin->nrefs) {
+ if (NULL != vol_plugin->container_name)
+ H5MM_xfree(vol_plugin->container_name);
+ if (NULL != vol_plugin)
+ H5MM_free(vol_plugin);
+ }
+
+done:
+ FUNC_LEAVE_NOAPI(ret_value)
+} /* end H5D_close_dataset() */
diff --git a/src/H5Ddeprec.c b/src/H5Ddeprec.c
index f03b914..cab261a 100644
--- a/src/H5Ddeprec.c
+++ b/src/H5Ddeprec.c
@@ -141,6 +141,10 @@ hid_t
H5Dcreate1(hid_t loc_id, const char *name, hid_t type_id, hid_t space_id,
hid_t dcpl_id)
{
+ void *dset = NULL; /* dset token from VOL plugin */
+ void *obj = NULL; /* object token of loc_id */
+ H5VL_t *vol_plugin; /* VOL plugin information */
+ H5VL_loc_params_t loc_params;
H5P_genplist_t *plist; /* Property list pointer */
hid_t lcpl_id = H5P_LINK_CREATE_DEFAULT;
hid_t ret_value; /* Return value */
@@ -166,12 +170,36 @@ H5Dcreate1(hid_t loc_id, const char *name, hid_t type_id, hid_t space_id,
if(H5P_set(plist, H5VL_DSET_LCPL_ID, &lcpl_id) < 0)
HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, FAIL, "can't set property value for lcpl id")
+ loc_params.type = H5VL_OBJECT_BY_SELF;
+ loc_params.obj_type = H5I_get_type(loc_id);
+
+ /* get the file object */
+ if(NULL == (obj = (void *)H5I_object(loc_id)))
+ HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "invalid file identifier")
+
+ /* get the plugin pointer */
+ if (NULL == (vol_plugin = (H5VL_t *)H5I_get_aux(loc_id)))
+ HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "ID does not contain VOL information")
+
/* Create the dataset through the VOL */
- if((ret_value = H5VL_dataset_create(loc_id, name, dcpl_id, H5P_DATASET_ACCESS_DEFAULT, -1)) < 0)
+ if(NULL == (dset = H5VL_dataset_create(obj, loc_params, vol_plugin, name, dcpl_id,
+ H5P_DATASET_ACCESS_DEFAULT, H5_REQUEST_NULL)))
HGOTO_ERROR(H5E_DATASET, H5E_CANTINIT, FAIL, "unable to create dataset")
-done:
+ /* Get an atom for the file */
+ if((ret_value = H5I_register(H5I_DATASET, dset, TRUE)) < 0)
+ HGOTO_ERROR(H5E_ATOM, H5E_CANTREGISTER, FAIL, "unable to atomize dataset handle")
+ /* attach VOL information to the ID */
+ if (H5I_register_aux(ret_value, vol_plugin, (H5I_free2_t)H5D_close_dataset) < 0)
+ HGOTO_ERROR(H5E_VOL, H5E_CANTINIT, FAIL, "can't attach vol info to ID")
+
+ vol_plugin->nrefs ++;
+
+done:
+ if (ret_value < 0 && dset)
+ if(H5VL_dataset_close (dset, vol_plugin, H5_REQUEST_NULL) < 0)
+ HDONE_ERROR(H5E_DATASET, H5E_CLOSEERROR, FAIL, "unable to release dataset")
FUNC_LEAVE_API(ret_value)
} /* end H5Dcreate1() */
@@ -196,6 +224,10 @@ done:
hid_t
H5Dopen1(hid_t loc_id, const char *name)
{
+ void *dset = NULL; /* dset token from VOL plugin */
+ void *obj = NULL; /* object token of loc_id */
+ H5VL_t *vol_plugin; /* VOL plugin information */
+ H5VL_loc_params_t loc_params;
hid_t dapl_id = H5P_DATASET_ACCESS_DEFAULT; /* dapl to use to open dataset */
hid_t ret_value;
@@ -206,12 +238,35 @@ H5Dopen1(hid_t loc_id, const char *name)
if(!name || !*name)
HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "no name")
- /* Open the dataset through the VOL */
- if((ret_value = H5VL_dataset_open(loc_id, name, dapl_id, -1)) < 0)
- HGOTO_ERROR(H5E_DATASET, H5E_CANTINIT, FAIL, "unable to open dataset")
+ loc_params.type = H5VL_OBJECT_BY_SELF;
+ loc_params.obj_type = H5I_get_type(loc_id);
-done:
+ /* get the file object */
+ if(NULL == (obj = (void *)H5I_object(loc_id)))
+ HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "invalid file identifier")
+ /* get the plugin pointer */
+ if (NULL == (vol_plugin = (H5VL_t *)H5I_get_aux(loc_id)))
+ HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "ID does not contain VOL information")
+
+ /* Create the dataset through the VOL */
+ if(NULL == (dset = H5VL_dataset_open(obj, loc_params, vol_plugin, name, dapl_id, H5_REQUEST_NULL)))
+ HGOTO_ERROR(H5E_DATASET, H5E_CANTINIT, FAIL, "unable to create dataset")
+
+ /* Get an atom for the file */
+ if((ret_value = H5I_register(H5I_DATASET, dset, TRUE)) < 0)
+ HGOTO_ERROR(H5E_ATOM, H5E_CANTREGISTER, FAIL, "unable to atomize dataset handle")
+
+ /* attach VOL information to the ID */
+ if (H5I_register_aux(ret_value, vol_plugin, (H5I_free2_t)H5D_close_dataset) < 0)
+ HGOTO_ERROR(H5E_VOL, H5E_CANTINIT, FAIL, "can't attach vol info to ID")
+
+ vol_plugin->nrefs ++;
+
+done:
+ if (ret_value < 0 && dset)
+ if(H5VL_dataset_close (dset, vol_plugin, H5_REQUEST_NULL) < 0)
+ HDONE_ERROR(H5E_DATASET, H5E_CLOSEERROR, FAIL, "unable to release dataset")
FUNC_LEAVE_API(ret_value)
} /* end H5Dopen1() */
diff --git a/src/H5Dint.c b/src/H5Dint.c
index b1bf39d..77e6ebd 100644
--- a/src/H5Dint.c
+++ b/src/H5Dint.c
@@ -161,10 +161,6 @@ H5D__init_interface(void)
FUNC_ENTER_STATIC
- /* Initialize the atom group for the dataset IDs */
- if(H5I_register_type(H5I_DATASET, (size_t)H5I_DATASETID_HASHSIZE, H5D_RESERVED_ATOMS, (H5I_free_t)H5D_close)<H5I_FILE)
- HGOTO_ERROR(H5E_DATASET, H5E_CANTINIT, FAIL, "unable to initialize interface")
-
/* Reset the "default dataset" information */
HDmemset(&H5D_def_dset, 0, sizeof(H5D_shared_t));
diff --git a/src/H5Dio.c b/src/H5Dio.c
index 2a1029e..f6c7d56 100644
--- a/src/H5Dio.c
+++ b/src/H5Dio.c
@@ -114,6 +114,8 @@ herr_t
H5Dread(hid_t dset_id, hid_t mem_type_id, hid_t mem_space_id,
hid_t file_space_id, hid_t plist_id, void *buf/*out*/)
{
+ H5VL_t *vol_plugin;
+ void *dset;
herr_t ret_value = SUCCEED; /* Return value */
FUNC_ENTER_API(FAIL)
@@ -127,8 +129,15 @@ H5Dread(hid_t dset_id, hid_t mem_type_id, hid_t mem_space_id,
if(TRUE != H5P_isa_class(plist_id, H5P_DATASET_XFER))
HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not xfer parms")
+ /* get the plugin pointer */
+ if (NULL == (vol_plugin = (H5VL_t *)H5I_get_aux(dset_id)))
+ HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "ID does not contain VOL information")
+ /* get the dataset object */
+ if(NULL == (dset = (void *)H5I_object(dset_id)))
+ HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "invalid dataset identifier")
+
/* Read the data through the VOL */
- if((ret_value = H5VL_dataset_read(dset_id, mem_type_id, mem_space_id,
+ if((ret_value = H5VL_dataset_read(dset, vol_plugin, mem_type_id, mem_space_id,
file_space_id, plist_id, buf, H5_REQUEST_NULL)) < 0)
HGOTO_ERROR(H5E_DATASET, H5E_READERROR, FAIL, "can't read data")
@@ -173,6 +182,8 @@ herr_t
H5Dwrite(hid_t dset_id, hid_t mem_type_id, hid_t mem_space_id,
hid_t file_space_id, hid_t dxpl_id, const void *buf)
{
+ H5VL_t *vol_plugin;
+ void *dset;
herr_t ret_value = SUCCEED; /* Return value */
FUNC_ENTER_API(FAIL)
@@ -188,8 +199,15 @@ H5Dwrite(hid_t dset_id, hid_t mem_type_id, hid_t mem_space_id,
if(TRUE != H5P_isa_class(dxpl_id, H5P_DATASET_XFER))
HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not xfer parms")
+ /* get the plugin pointer */
+ if (NULL == (vol_plugin = (H5VL_t *)H5I_get_aux(dset_id)))
+ HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "ID does not contain VOL information")
+ /* get the dataset object */
+ if(NULL == (dset = (void *)H5I_object(dset_id)))
+ HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "invalid dataset identifier")
+
/* Write the data through the VOL */
- if((ret_value = H5VL_dataset_write(dset_id, mem_type_id, mem_space_id,
+ if((ret_value = H5VL_dataset_write(dset, vol_plugin, mem_type_id, mem_space_id,
file_space_id, dxpl_id, buf, H5_REQUEST_NULL)) < 0)
HGOTO_ERROR(H5E_DATASET, H5E_WRITEERROR, FAIL, "can't write data")
diff --git a/src/H5F.c b/src/H5F.c
index e8ac4cf..3d434b8 100644
--- a/src/H5F.c
+++ b/src/H5F.c
@@ -24,6 +24,7 @@
#include "H5Eprivate.h" /* Error handling */
#include "H5Fpkg.h" /* File access */
#include "H5Iprivate.h" /* IDs */
+#include "H5MMprivate.h" /* Memory management */
#include "H5Pprivate.h" /* Property lists */
#include "H5VLprivate.h" /* VOL plugins */
@@ -41,7 +42,6 @@
static herr_t H5F__init_pub_interface(void);
-
/*********************/
/* Package Variables */
/*********************/
@@ -70,9 +70,18 @@ DESCRIPTION
static herr_t
H5F__init_pub_interface(void)
{
- FUNC_ENTER_STATIC_NOERR
+ herr_t ret_value = SUCCEED; /* Return value */
+ FUNC_ENTER_STATIC
+
+ /*
+ * Initialize the atom group for the file IDs.
+ */
+ if(H5I_register_type(H5I_FILE, (size_t)H5I_FILEID_HASHSIZE, 0, NULL)<H5I_FILE_PRIVATE)
+ HGOTO_ERROR(H5E_FILE, H5E_CANTINIT, FAIL, "unable to initialize interface")
- FUNC_LEAVE_NOAPI(H5F_init())
+ ret_value = H5F_init();
+done:
+ FUNC_LEAVE_NOAPI(ret_value)
} /* H5F__init_pub_interface() */
@@ -94,12 +103,21 @@ H5F__init_pub_interface(void)
hid_t
H5Fget_create_plist(hid_t file_id)
{
+ H5VL_t *vol_plugin;
+ void *obj;
hid_t ret_value; /* Return value */
FUNC_ENTER_API(FAIL)
H5TRACE1("i", "i", file_id);
- if(H5VL_file_get(file_id, H5VL_FILE_GET_FCPL, H5_REQUEST_NULL, &ret_value) < 0)
+ /* get the plugin pointer */
+ if (NULL == (vol_plugin = (H5VL_t *)H5I_get_aux(file_id)))
+ HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "ID does not contain VOL information")
+ /* get the file object */
+ if(NULL == (obj = (void *)H5I_object(file_id)))
+ HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "invalid file identifier")
+
+ if(H5VL_file_get(obj, vol_plugin, H5VL_FILE_GET_FCPL, H5_REQUEST_NULL, &ret_value) < 0)
HGOTO_ERROR(H5E_INTERNAL, H5E_CANTGET, FAIL, "unable to get file creation properties")
done:
@@ -131,12 +149,22 @@ done:
hid_t
H5Fget_access_plist(hid_t file_id)
{
+ H5VL_t *vol_plugin;
+ void *obj;
hid_t ret_value; /* Return value */
FUNC_ENTER_API(FAIL)
H5TRACE1("i", "i", file_id);
- if(H5VL_file_get(file_id, H5VL_FILE_GET_FAPL, H5_REQUEST_NULL, &ret_value) < 0)
+ /* get the plugin pointer */
+ if (NULL == (vol_plugin = (H5VL_t *)H5I_get_aux(file_id)))
+ HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "ID does not contain VOL information")
+
+ /* get the file object */
+ if(NULL == (obj = (void *)H5I_object(file_id)))
+ HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "invalid file identifier")
+
+ if(H5VL_file_get(obj, vol_plugin, H5VL_FILE_GET_FAPL, H5_REQUEST_NULL, &ret_value) < 0)
HGOTO_ERROR(H5E_INTERNAL, H5E_CANTGET, FAIL, "unable to get file creation properties")
done:
@@ -169,7 +197,18 @@ H5Fget_obj_count(hid_t file_id, unsigned types)
HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "not an object type")
if(file_id != (hid_t)H5F_OBJ_ALL) {
- if(H5VL_file_get(file_id, H5VL_FILE_GET_OBJ_COUNT, H5_REQUEST_NULL, &ret_value, types) < 0)
+ H5VL_t *vol_plugin;
+ void *obj;
+
+ /* get the plugin pointer */
+ if (NULL == (vol_plugin = (H5VL_t *)H5I_get_aux(file_id)))
+ HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "ID does not contain VOL information")
+
+ /* get the file object */
+ if(NULL == (obj = (void *)H5I_object(file_id)))
+ HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "invalid file identifier")
+
+ if(H5VL_file_get(obj, vol_plugin, H5VL_FILE_GET_OBJ_COUNT, H5_REQUEST_NULL, &ret_value, types) < 0)
HGOTO_ERROR(H5E_INTERNAL, H5E_CANTGET, FAIL, "unable to get object count in file(s)")
}
/* iterate over all open files and get the obj count for each */
@@ -220,7 +259,16 @@ H5Fget_obj_ids(hid_t file_id, unsigned types, size_t max_objs, hid_t *oid_list)
/* Check arguments */
if(file_id != (hid_t)H5F_OBJ_ALL) {
- if(H5VL_file_get(file_id, H5VL_FILE_GET_OBJ_IDS, H5_REQUEST_NULL,
+ H5VL_t *vol_plugin;
+ void *obj;
+ /* get the plugin pointer */
+ if (NULL == (vol_plugin = (H5VL_t *)H5I_get_aux(file_id)))
+ HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "ID does not contain VOL information")
+ /* get the file object */
+ if(NULL == (obj = (void *)H5I_object(file_id)))
+ HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "invalid file identifier")
+
+ if(H5VL_file_get(obj, vol_plugin, H5VL_FILE_GET_OBJ_IDS, H5_REQUEST_NULL,
types, max_objs, oid_list, &ret_value) < 0)
HGOTO_ERROR(H5E_INTERNAL, H5E_CANTGET, FAIL, "unable to get object count in file(s)")
}
@@ -259,7 +307,9 @@ done:
herr_t
H5Fget_vfd_handle(hid_t file_id, hid_t fapl, void **file_handle)
{
- herr_t ret_value = SUCCEED; /* Return value */
+ H5VL_t *vol_plugin;
+ void *obj;
+ herr_t ret_value = SUCCEED; /* Return value */
FUNC_ENTER_API(FAIL)
H5TRACE3("e", "ii**x", file_id, fapl, file_handle);
@@ -268,7 +318,16 @@ H5Fget_vfd_handle(hid_t file_id, hid_t fapl, void **file_handle)
if(!file_handle)
HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "invalid file handle pointer")
- if((ret_value = H5VL_file_optional(file_id, H5VL_FILE_GET_VFD_HANDLE, H5_REQUEST_NULL, file_handle, fapl)) < 0)
+ /* get the plugin pointer */
+ if (NULL == (vol_plugin = (H5VL_t *)H5I_get_aux(file_id)))
+ HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "ID does not contain VOL information")
+
+ /* get the file object */
+ if(NULL == (obj = (void *)H5I_object(file_id)))
+ HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "invalid file identifier")
+
+ if((ret_value = H5VL_file_optional(obj, vol_plugin, H5VL_FILE_GET_VFD_HANDLE,
+ H5_REQUEST_NULL, file_handle, fapl)) < 0)
HGOTO_ERROR(H5E_INTERNAL, H5E_CANTGET, FAIL, "unable to get file handle")
done:
@@ -301,7 +360,8 @@ H5Fis_accessible(const char *name, hid_t fapl_id)
if(!name || !*name)
HGOTO_ERROR(H5E_ARGS, H5E_BADRANGE, FAIL, "no file name specified")
- if(H5VL_file_misc(fapl_id, H5VL_FILE_IS_ACCESSIBLE, &ret_value, name) < 0)
+ if(H5VL_file_misc(NULL, NULL, H5VL_FILE_IS_ACCESSIBLE, H5_REQUEST_NULL,
+ fapl_id, name, &ret_value) < 0)
HGOTO_ERROR(H5E_INTERNAL, H5E_CANTGET, FAIL, "unable to get file handle")
done:
@@ -339,7 +399,9 @@ done:
hid_t
H5Fcreate(const char *filename, unsigned flags, hid_t fcpl_id, hid_t fapl_id)
{
- hid_t ret_value; /*return value */
+ void *file; /*file token from VOL plugin */
+ H5VL_t *vol_plugin; /* VOL plugin information */
+ hid_t ret_value; /*return value */
FUNC_ENTER_API(FAIL)
H5TRACE4("i", "*sIuii", filename, flags, fcpl_id, fapl_id);
@@ -370,12 +432,24 @@ H5Fcreate(const char *filename, unsigned flags, hid_t fcpl_id, hid_t fapl_id)
if(TRUE != H5P_isa_class(fapl_id, H5P_FILE_ACCESS))
HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not file access property list")
- /*
- * Create a new file or truncate an existing file.
- */
- if((ret_value = H5VL_file_create(filename, flags, fcpl_id, fapl_id, H5_REQUEST_NULL)) < 0)
+ /* Build the vol plugin struct */
+ if(NULL == (vol_plugin = (H5VL_t *)H5MM_calloc(sizeof(H5VL_t))))
+ HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, FAIL, "memory allocation failed")
+
+ vol_plugin->nrefs = 1;
+
+ /* create a new file or truncate an existing file through the VOL */
+ if(NULL == (file = H5VL_file_create(vol_plugin, filename, flags, fcpl_id, fapl_id, H5_REQUEST_NULL)))
HGOTO_ERROR(H5E_FILE, H5E_CANTOPENFILE, FAIL, "unable to create file")
+ /* Get an atom for the file */
+ if((ret_value = H5I_register(H5I_FILE, file, TRUE)) < 0)
+ HGOTO_ERROR(H5E_ATOM, H5E_CANTREGISTER, FAIL, "unable to atomize file handle")
+
+ /* attach VOL information to the ID */
+ if (H5I_register_aux(ret_value, vol_plugin, (H5I_free2_t)H5F_close_file) < 0)
+ HGOTO_ERROR(H5E_VOL, H5E_CANTINIT, FAIL, "can't attach vol info to ID")
+
done:
FUNC_LEAVE_API(ret_value)
} /* end H5Fcreate() */
@@ -424,6 +498,8 @@ done:
hid_t
H5Fopen(const char *filename, unsigned flags, hid_t fapl_id)
{
+ void *file; /*file token from VOL plugin */
+ H5VL_t *vol_plugin; /* VOL plugin information */
hid_t ret_value; /*return value */
FUNC_ENTER_API(FAIL)
@@ -442,9 +518,23 @@ H5Fopen(const char *filename, unsigned flags, hid_t fapl_id)
if(TRUE != H5P_isa_class(fapl_id, H5P_FILE_ACCESS))
HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not file access property list")
- /* Open the file */
- if((ret_value = H5VL_file_open(filename, flags, fapl_id, H5_REQUEST_NULL))<0)
- HGOTO_ERROR(H5E_FILE, H5E_CANTOPENFILE, FAIL, "unable to open file")
+ /* Build the vol plugin struct */
+ if(NULL == (vol_plugin = (H5VL_t *)H5MM_calloc(sizeof(H5VL_t))))
+ HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, FAIL, "memory allocation failed")
+
+ vol_plugin->nrefs = 1;
+
+ /* Open the file through the VOL layer */
+ if(NULL == (file = H5VL_file_open(vol_plugin, filename, flags, fapl_id, H5_REQUEST_NULL)))
+ HGOTO_ERROR(H5E_FILE, H5E_CANTOPENFILE, FAIL, "unable to create file")
+
+ /* Get an atom for the file */
+ if((ret_value = H5I_register(H5I_FILE, file, TRUE)) < 0)
+ HGOTO_ERROR(H5E_ATOM, H5E_CANTREGISTER, FAIL, "unable to atomize file handle")
+
+ /* attach VOL information to the ID */
+ if (H5I_register_aux(ret_value, vol_plugin, (H5I_free2_t)H5F_close_file) < 0)
+ HGOTO_ERROR(H5E_VOL, H5E_CANTINIT, FAIL, "can't attach vol info to ID")
done:
FUNC_LEAVE_API(ret_value)
@@ -468,12 +558,33 @@ done:
herr_t
H5Fflush(hid_t object_id, H5F_scope_t scope)
{
+ H5VL_t *vol_plugin;
+ void *obj;
+ H5I_type_t obj_type;
+ H5VL_loc_params_t loc_params;
herr_t ret_value = SUCCEED; /* Return value */
FUNC_ENTER_API(FAIL)
H5TRACE2("e", "iFs", object_id, scope);
- if((ret_value = H5VL_file_flush(object_id, scope, H5_REQUEST_NULL)) < 0)
+ obj_type = H5I_get_type(object_id);
+ if(H5I_FILE != obj_type && H5I_GROUP != obj_type && H5I_DATATYPE != obj_type &&
+ H5I_DATASET != obj_type && H5I_ATTR != obj_type) {
+ HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a file or file object")
+ }
+
+ /* get the plugin pointer */
+ if (NULL == (vol_plugin = (H5VL_t *)H5I_get_aux(object_id)))
+ HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "ID does not contain VOL information")
+
+ /* get the file object */
+ if(NULL == (obj = (void *)H5I_object(object_id)))
+ HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "invalid file identifier")
+
+ loc_params.type = H5VL_OBJECT_BY_SELF;
+ loc_params.obj_type = obj_type;
+
+ if((ret_value = H5VL_file_flush(obj, loc_params, vol_plugin, scope, H5_REQUEST_NULL)) < 0)
HGOTO_ERROR(H5E_FILE, H5E_CANTFLUSH, FAIL, "unable to flush file")
done:
@@ -505,21 +616,81 @@ done:
herr_t
H5Fclose(hid_t file_id)
{
- herr_t ret_value = SUCCEED;
+ herr_t ret_value = SUCCEED;
FUNC_ENTER_API(FAIL)
H5TRACE1("e", "i", file_id);
- /* Close the file */
- if((ret_value = H5VL_file_close(file_id, H5_REQUEST_NULL)) < 0)
+ /* Check/fix arguments. */
+ if(H5I_FILE != H5I_get_type(file_id))
+ HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a file ID")
+
+ /* Decrement reference count on atom. When it reaches zero the file will be closed. */
+ if(H5I_dec_app_ref(file_id) < 0)
+ HGOTO_ERROR(H5E_ATOM, H5E_CANTCLOSEFILE, FAIL, "decrementing file ID failed")
+
+#if 0
+ void *file; /*file token from VOL plugin */
+ H5VL_t *vol_plugin; /* VOL plugin information */
+ /* get the plugin pointer */
+ if (NULL == (vol_plugin = (H5VL_t *)H5I_get_aux(file_id)))
+ HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "ID does not contain VOL information")
+
+ /* get the file object */
+ if(NULL == (file = (void *)H5I_object(file_id)))
+ HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "invalid file identifier")
+
+ /* Close the file through the VOL*/
+ if((ret_value = H5VL_file_close(file, vol_plugin, H5_REQUEST_NULL)) < 0)
HGOTO_ERROR(H5E_FILE, H5E_CANTCLOSEFILE, FAIL, "unable to close file")
+ H5MM_free(vol_plugin);
+#endif
+
done:
FUNC_LEAVE_API(ret_value)
} /* end H5Fclose() */
/*-------------------------------------------------------------------------
+ * Function: H5F_close_file
+ *
+ * Purpose: Called when the ref count reaches zero on the file_id
+ *
+ * Return: Success: Non-negative
+ *
+ * Failure: Negative
+ *
+ * Programmer: Mohamad Chaarawi
+ * June 2012
+ *
+ *-------------------------------------------------------------------------
+ */
+herr_t
+H5F_close_file(void *file, H5VL_t *vol_plugin)
+{
+ herr_t ret_value = SUCCEED; /* Return value */
+
+ FUNC_ENTER_NOAPI_NOINIT
+
+ /* Close the file through the VOL*/
+ if((ret_value = H5VL_file_close(file, vol_plugin, H5_REQUEST_NULL)) < 0)
+ HGOTO_ERROR(H5E_FILE, H5E_CANTCLOSEFILE, FAIL, "unable to close file")
+
+ vol_plugin->nrefs --;
+ if (0 == vol_plugin->nrefs) {
+ if (NULL != vol_plugin->container_name)
+ H5MM_xfree(vol_plugin->container_name);
+ if (NULL != vol_plugin)
+ H5MM_free(vol_plugin);
+ }
+
+done:
+ FUNC_LEAVE_NOAPI(ret_value)
+} /* end H5F_close_file() */
+
+
+/*-------------------------------------------------------------------------
* Function: H5Freopen
*
* Purpose: Reopen a file. The new file handle which is returned points
@@ -544,14 +715,38 @@ done:
hid_t
H5Freopen(hid_t file_id)
{
+ H5VL_t *vol_plugin;
+ void *obj;
+ void *file; /*file token from VOL plugin */
hid_t ret_value;
FUNC_ENTER_API(FAIL)
H5TRACE1("i", "i", file_id);
- if(H5VL_file_optional(file_id, H5VL_FILE_REOPEN, H5_REQUEST_NULL, &ret_value) < 0)
+ /* get the plugin pointer */
+ if (NULL == (vol_plugin = (H5VL_t *)H5I_get_aux(file_id)))
+ HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "ID does not contain VOL information")
+
+ /* get the file object */
+ if(NULL == (obj = (void *)H5I_object(file_id)))
+ HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "invalid file identifier")
+
+ if(H5VL_file_optional(obj, vol_plugin, H5VL_FILE_REOPEN, H5_REQUEST_NULL, &file) < 0)
HGOTO_ERROR(H5E_FILE, H5E_CANTINIT, FAIL, "unable to reopen file")
+ if (NULL == file)
+ HGOTO_ERROR(H5E_FILE, H5E_CANTINIT, FAIL, "unable to reopen file")
+
+ /* Get an atom for the file */
+ if((ret_value = H5I_register(H5I_FILE, file, TRUE)) < 0)
+ HGOTO_ERROR(H5E_ATOM, H5E_CANTREGISTER, FAIL, "unable to atomize file handle")
+
+ /* attach VOL information to the ID */
+ if (H5I_register_aux(ret_value, vol_plugin, (H5I_free2_t)H5F_close_file) < 0)
+ HGOTO_ERROR(H5E_VOL, H5E_CANTINIT, FAIL, "can't attach vol info to ID")
+
+ vol_plugin->nrefs ++;
+
done:
FUNC_LEAVE_API(ret_value)
} /* end H5Freopen() */
@@ -580,7 +775,18 @@ H5Fget_intent(hid_t file_id, unsigned *intent_flags)
/* If no intent flags were passed in, exit quietly */
if(intent_flags) {
- if((ret_value = H5VL_file_get(file_id, H5VL_FILE_GET_INTENT, H5_REQUEST_NULL, intent_flags)) < 0)
+ H5VL_t *vol_plugin;
+ void *obj;
+
+ /* get the plugin pointer */
+ if (NULL == (vol_plugin = (H5VL_t *)H5I_get_aux(file_id)))
+ HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "ID does not contain VOL information")
+
+ /* get the file object */
+ if(NULL == (obj = (void *)H5I_object(file_id)))
+ HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "invalid file identifier")
+
+ if((ret_value = H5VL_file_get(obj, vol_plugin, H5VL_FILE_GET_INTENT, H5_REQUEST_NULL, intent_flags)) < 0)
HGOTO_ERROR(H5E_INTERNAL, H5E_CANTGET, FAIL, "unable to get file intent")
}
@@ -606,12 +812,22 @@ done:
hssize_t
H5Fget_freespace(hid_t file_id)
{
+ H5VL_t *vol_plugin;
+ void *obj;
hssize_t ret_value; /* Return value */
FUNC_ENTER_API(FAIL)
H5TRACE1("Hs", "i", file_id);
- if(H5VL_file_optional(file_id, H5VL_FILE_GET_FREE_SPACE, H5_REQUEST_NULL, &ret_value) < 0)
+ /* get the plugin pointer */
+ if (NULL == (vol_plugin = (H5VL_t *)H5I_get_aux(file_id)))
+ HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "ID does not contain VOL information")
+
+ /* get the file object */
+ if(NULL == (obj = (void *)H5I_object(file_id)))
+ HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "invalid file identifier")
+
+ if(H5VL_file_optional(obj, vol_plugin, H5VL_FILE_GET_FREE_SPACE, H5_REQUEST_NULL, &ret_value) < 0)
HGOTO_ERROR(H5E_INTERNAL, H5E_CANTGET, FAIL, "unable to get file free space")
done:
@@ -640,12 +856,22 @@ done:
herr_t
H5Fget_filesize(hid_t file_id, hsize_t *size)
{
+ H5VL_t *vol_plugin;
+ void *obj;
herr_t ret_value = SUCCEED; /* Return value */
FUNC_ENTER_API(FAIL)
H5TRACE2("e", "i*h", file_id, size);
- if((ret_value = H5VL_file_optional(file_id, H5VL_FILE_GET_SIZE, H5_REQUEST_NULL, size)) < 0)
+ /* get the plugin pointer */
+ if (NULL == (vol_plugin = (H5VL_t *)H5I_get_aux(file_id)))
+ HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "ID does not contain VOL information")
+
+ /* get the file object */
+ if(NULL == (obj = (void *)H5I_object(file_id)))
+ HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "invalid file identifier")
+
+ if((ret_value = H5VL_file_optional(obj, vol_plugin, H5VL_FILE_GET_SIZE, H5_REQUEST_NULL, size)) < 0)
HGOTO_ERROR(H5E_INTERNAL, H5E_CANTGET, FAIL, "unable to get file size")
done:
@@ -697,6 +923,8 @@ done:
ssize_t
H5Fget_file_image(hid_t file_id, void *buf_ptr, size_t buf_len)
{
+ H5VL_t *vol_plugin;
+ void *obj;
ssize_t ret_value; /* Return value */
FUNC_ENTER_API(FAIL)
@@ -706,8 +934,16 @@ H5Fget_file_image(hid_t file_id, void *buf_ptr, size_t buf_len)
if(H5I_FILE != H5I_get_type(file_id))
HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a file")
+ /* get the plugin pointer */
+ if (NULL == (vol_plugin = (H5VL_t *)H5I_get_aux(file_id)))
+ HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "ID does not contain VOL information")
+
+ /* get the file object */
+ if(NULL == (obj = (void *)H5I_object(file_id)))
+ HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "invalid file identifier")
+
/* get image through the VOL */
- if(H5VL_file_optional(file_id, H5VL_FILE_GET_FILE_IMAGE, H5_REQUEST_NULL,
+ if(H5VL_file_optional(obj, vol_plugin, H5VL_FILE_GET_FILE_IMAGE, H5_REQUEST_NULL,
buf_ptr, &ret_value, buf_len) < 0)
HGOTO_ERROR(H5E_INTERNAL, H5E_CANTGET, FAIL, "unable to get file image")
@@ -737,6 +973,8 @@ done:
herr_t
H5Fget_mdc_config(hid_t file_id, H5AC_cache_config_t *config_ptr)
{
+ H5VL_t *vol_plugin;
+ void *obj;
herr_t ret_value = SUCCEED; /* Return value */
FUNC_ENTER_API(FAIL)
@@ -746,7 +984,15 @@ H5Fget_mdc_config(hid_t file_id, H5AC_cache_config_t *config_ptr)
if((NULL == config_ptr) || (config_ptr->version != H5AC__CURR_CACHE_CONFIG_VERSION))
HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "Bad config_ptr")
- if((ret_value = H5VL_file_optional(file_id, H5VL_FILE_GET_MDC_CONF, H5_REQUEST_NULL,
+ /* get the plugin pointer */
+ if (NULL == (vol_plugin = (H5VL_t *)H5I_get_aux(file_id)))
+ HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "ID does not contain VOL information")
+
+ /* get the file object */
+ if(NULL == (obj = (void *)H5I_object(file_id)))
+ HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "invalid file identifier")
+
+ if((ret_value = H5VL_file_optional(obj, vol_plugin, H5VL_FILE_GET_MDC_CONF, H5_REQUEST_NULL,
config_ptr)) < 0)
HGOTO_ERROR(H5E_INTERNAL, H5E_CANTGET, FAIL, "unable to get mdc configuration")
@@ -773,12 +1019,22 @@ done:
herr_t
H5Fset_mdc_config(hid_t file_id, H5AC_cache_config_t *config_ptr)
{
+ H5VL_t *vol_plugin;
+ void *obj;
herr_t ret_value = SUCCEED; /* Return value */
FUNC_ENTER_API(FAIL)
H5TRACE2("e", "i*x", file_id, config_ptr);
- if(H5VL_file_optional(file_id, H5VL_FILE_RESET_MDC_HIT_RATE, H5_REQUEST_NULL, config_ptr) < 0)
+ /* get the plugin pointer */
+ if (NULL == (vol_plugin = (H5VL_t *)H5I_get_aux(file_id)))
+ HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "ID does not contain VOL information")
+
+ /* get the file object */
+ if(NULL == (obj = (void *)H5I_object(file_id)))
+ HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "invalid file identifier")
+
+ if(H5VL_file_optional(obj, vol_plugin, H5VL_FILE_RESET_MDC_HIT_RATE, H5_REQUEST_NULL, config_ptr) < 0)
HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "uanvle to set MDC configuration")
done:
@@ -805,6 +1061,8 @@ done:
herr_t
H5Fget_mdc_hit_rate(hid_t file_id, double *hit_rate_ptr)
{
+ H5VL_t *vol_plugin;
+ void *obj;
herr_t ret_value = SUCCEED; /* Return value */
FUNC_ENTER_API(FAIL)
@@ -813,7 +1071,15 @@ H5Fget_mdc_hit_rate(hid_t file_id, double *hit_rate_ptr)
if(NULL == hit_rate_ptr)
HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "NULL hit rate pointer")
- if((ret_value = H5VL_file_optional(file_id, H5VL_FILE_GET_MDC_HR, H5_REQUEST_NULL,
+ /* get the plugin pointer */
+ if (NULL == (vol_plugin = (H5VL_t *)H5I_get_aux(file_id)))
+ HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "ID does not contain VOL information")
+
+ /* get the file object */
+ if(NULL == (obj = (void *)H5I_object(file_id)))
+ HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "invalid file identifier")
+
+ if((ret_value = H5VL_file_optional(obj, vol_plugin, H5VL_FILE_GET_MDC_HR, H5_REQUEST_NULL,
hit_rate_ptr)) < 0)
HGOTO_ERROR(H5E_INTERNAL, H5E_CANTGET, FAIL, "unable to get MDC hit rate")
@@ -843,13 +1109,23 @@ herr_t
H5Fget_mdc_size(hid_t file_id, size_t *max_size_ptr, size_t *min_clean_size_ptr,
size_t *cur_size_ptr, int *cur_num_entries_ptr)
{
+ H5VL_t *vol_plugin;
+ void *obj;
herr_t ret_value = SUCCEED; /* Return value */
FUNC_ENTER_API(FAIL)
H5TRACE5("e", "i*z*z*z*Is", file_id, max_size_ptr, min_clean_size_ptr,
cur_size_ptr, cur_num_entries_ptr);
- if((ret_value = H5VL_file_optional(file_id, H5VL_FILE_GET_MDC_SIZE, H5_REQUEST_NULL, max_size_ptr,
+ /* get the plugin pointer */
+ if (NULL == (vol_plugin = (H5VL_t *)H5I_get_aux(file_id)))
+ HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "ID does not contain VOL information")
+
+ /* get the file object */
+ if(NULL == (obj = (void *)H5I_object(file_id)))
+ HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "invalid file identifier")
+
+ if((ret_value = H5VL_file_optional(obj, vol_plugin, H5VL_FILE_GET_MDC_SIZE, H5_REQUEST_NULL, max_size_ptr,
min_clean_size_ptr, cur_size_ptr, cur_num_entries_ptr)) < 0)
HGOTO_ERROR(H5E_INTERNAL, H5E_CANTGET, FAIL, "unable to get MDC size")
@@ -881,12 +1157,22 @@ done:
herr_t
H5Freset_mdc_hit_rate_stats(hid_t file_id)
{
+ H5VL_t *vol_plugin;
+ void *obj;
herr_t ret_value = SUCCEED; /* Return value */
FUNC_ENTER_API(FAIL)
H5TRACE1("e", "i", file_id);
- if(H5VL_file_optional(file_id, H5VL_FILE_RESET_MDC_HIT_RATE, H5_REQUEST_NULL) < 0)
+ /* get the plugin pointer */
+ if (NULL == (vol_plugin = (H5VL_t *)H5I_get_aux(file_id)))
+ HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "ID does not contain VOL information")
+
+ /* get the file object */
+ if(NULL == (obj = (void *)H5I_object(file_id)))
+ HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "invalid file identifier")
+
+ if(H5VL_file_optional(obj, vol_plugin, H5VL_FILE_RESET_MDC_HIT_RATE, H5_REQUEST_NULL) < 0)
HGOTO_ERROR(H5E_CACHE, H5E_SYSTEM, FAIL, "can't reset cache hit rate")
done:
@@ -917,14 +1203,32 @@ done:
*-------------------------------------------------------------------------
*/
ssize_t
-H5Fget_name(hid_t file_id, char *name/*out*/, size_t size)
+H5Fget_name(hid_t obj_id, char *name/*out*/, size_t size)
{
- ssize_t ret_value;
+ H5VL_t *vol_plugin = NULL;
+ void *obj = NULL;
+ ssize_t ret_value;
+ H5I_type_t type;
FUNC_ENTER_API(FAIL)
- H5TRACE3("Zs", "ixz", file_id, name, size);
+ H5TRACE3("Zs", "ixz", obj_id, name, size);
- if(H5VL_file_get(file_id, H5VL_FILE_GET_NAME, H5_REQUEST_NULL,name, &ret_value, size) < 0)
+ type = H5I_get_type(obj_id);
+ if(H5I_FILE != type && H5I_GROUP != type && H5I_DATATYPE != type &&
+ H5I_DATASET != type && H5I_ATTR != type) {
+ HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a file or file object")
+ }
+
+ /* get the plugin pointer */
+ if (NULL == (vol_plugin = (H5VL_t *)H5I_get_aux(obj_id)))
+ HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "ID does not contain VOL information")
+
+ /* get the file object */
+ if(NULL == (obj = (void *)H5I_object(obj_id)))
+ HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "invalid file identifier")
+
+ if(H5VL_file_get(obj, vol_plugin, H5VL_FILE_GET_NAME, H5_REQUEST_NULL,
+ type, size, name, &ret_value) < 0)
HGOTO_ERROR(H5E_INTERNAL, H5E_CANTGET, FAIL, "unable to get file name")
done:
@@ -950,18 +1254,36 @@ done:
*-------------------------------------------------------------------------
*/
herr_t
-H5Fget_info2(hid_t file_id, H5F_info2_t *finfo)
+H5Fget_info2(hid_t obj_id, H5F_info2_t *finfo)
{
- herr_t ret_value = SUCCEED; /* Return value */
+ H5VL_t *vol_plugin;
+ void *obj;
+ H5I_type_t type;
+ herr_t ret_value = SUCCEED; /* Return value */
FUNC_ENTER_API(FAIL)
- H5TRACE2("e", "i*x", file_id, finfo);
+ H5TRACE2("e", "i*x", obj_id, finfo);
/* Check args */
if(!finfo)
HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "no info struct")
- if((ret_value = H5VL_file_optional(file_id, H5VL_FILE_GET_INFO, H5_REQUEST_NULL, finfo)) < 0)
+ type = H5I_get_type(obj_id);
+ if(H5I_FILE != type && H5I_GROUP != type && H5I_DATATYPE != type &&
+ H5I_DATASET != type && H5I_ATTR != type) {
+ HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a file or file object")
+ }
+
+ /* get the plugin pointer */
+ if (NULL == (vol_plugin = (H5VL_t *)H5I_get_aux(obj_id)))
+ HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "ID does not contain VOL information")
+
+ /* get the file object */
+ if(NULL == (obj = (void *)H5I_object(obj_id)))
+ HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "invalid file identifier")
+
+ if((ret_value = H5VL_file_optional(obj, vol_plugin, H5VL_FILE_GET_INFO, H5_REQUEST_NULL,
+ type, finfo)) < 0)
HGOTO_ERROR(H5E_INTERNAL, H5E_CANTGET, FAIL, "unable to get file info")
done:
FUNC_LEAVE_API(ret_value)
@@ -987,7 +1309,9 @@ ssize_t
H5Fget_free_sections(hid_t file_id, H5F_mem_t type, size_t nsects,
H5F_sect_info_t *sect_info/*out*/)
{
- ssize_t ret_value; /* Return value */
+ H5VL_t *vol_plugin;
+ void *obj;
+ ssize_t ret_value; /* Return value */
FUNC_ENTER_API(FAIL)
H5TRACE4("Zs", "iFmzx", file_id, type, nsects, sect_info);
@@ -996,7 +1320,15 @@ H5Fget_free_sections(hid_t file_id, H5F_mem_t type, size_t nsects,
if(sect_info && nsects == 0)
HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "nsects must be > 0")
- if(H5VL_file_optional(file_id, H5VL_FILE_GET_FREE_SECTIONS, H5_REQUEST_NULL, sect_info,
+ /* get the plugin pointer */
+ if (NULL == (vol_plugin = (H5VL_t *)H5I_get_aux(file_id)))
+ HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "ID does not contain VOL information")
+
+ /* get the file object */
+ if(NULL == (obj = (void *)H5I_object(file_id)))
+ HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "invalid file identifier")
+
+ if(H5VL_file_optional(obj, vol_plugin, H5VL_FILE_GET_FREE_SECTIONS, H5_REQUEST_NULL, sect_info,
&ret_value, type, nsects) < 0)
HGOTO_ERROR(H5E_INTERNAL, H5E_CANTGET, FAIL, "unable to get file free sections")
done:
@@ -1021,12 +1353,22 @@ done:
herr_t
H5Fclear_elink_file_cache(hid_t file_id)
{
+ H5VL_t *vol_plugin;
+ void *obj;
herr_t ret_value = SUCCEED; /* Return value */
FUNC_ENTER_API(FAIL)
H5TRACE1("e", "i", file_id);
- if(H5VL_file_optional(file_id, H5VL_FILE_CLEAR_ELINK_CACHE, H5_REQUEST_NULL) < 0)
+ /* get the plugin pointer */
+ if (NULL == (vol_plugin = (H5VL_t *)H5I_get_aux(file_id)))
+ HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "ID does not contain VOL information")
+
+ /* get the file object */
+ if(NULL == (obj = (void *)H5I_object(file_id)))
+ HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "invalid file identifier")
+
+ if(H5VL_file_optional(obj, vol_plugin, H5VL_FILE_CLEAR_ELINK_CACHE, H5_REQUEST_NULL) < 0)
HGOTO_ERROR(H5E_FILE, H5E_CANTRELEASE, FAIL, "can't release external file cache")
done:
diff --git a/src/H5Fint.c b/src/H5Fint.c
index ae93989..5edb2b5 100644
--- a/src/H5Fint.c
+++ b/src/H5Fint.c
@@ -114,7 +114,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)<H5I_FILE)
+ if(H5I_register_type(H5I_FILE_PRIVATE, (size_t)H5I_FILEID_HASHSIZE, 0, (H5I_free_t)H5F_close)<H5I_FILE_PRIVATE)
HGOTO_ERROR(H5E_FILE, H5E_CANTINIT, FAIL, "unable to initialize interface")
done:
@@ -148,13 +148,13 @@ H5F_term_interface(void)
FUNC_ENTER_NOAPI_NOINIT_NOERR
if(H5_interface_initialize_g) {
- if((n = H5I_nmembers(H5I_FILE)) != 0) {
- H5I_clear_type(H5I_FILE, FALSE, FALSE);
+ if((n = H5I_nmembers(H5I_FILE_PRIVATE)) != 0) {
+ H5I_clear_type(H5I_FILE_PRIVATE, FALSE, FALSE);
} else {
/* Make certain we've cleaned up all the shared file objects */
H5F_sfile_assert_num(0);
- H5I_dec_type_ref(H5I_FILE);
+ H5I_dec_type_ref(H5I_FILE_PRIVATE);
H5_interface_initialize_g = 0;
n = 1; /*H5I*/
} /* end else */
@@ -291,11 +291,22 @@ H5F_get_obj_count_cb(void UNUSED *obj_ptr, hid_t obj_id, void *key)
{
H5F_trav_obj_cnt_t *udata = (H5F_trav_obj_cnt_t *)key;
ssize_t obj_count = 0;
+ H5VL_t *vol_plugin;
+ void *obj;
int ret_value = H5_ITER_CONT; /* Return value */
FUNC_ENTER_NOAPI_NOINIT
- if(H5VL_file_get(obj_id, H5VL_FILE_GET_OBJ_COUNT, H5_REQUEST_NULL, &obj_count, udata->types) < 0)
+ /* get the plugin pointer */
+ if (NULL == (vol_plugin = (H5VL_t *)H5I_get_aux(obj_id)))
+ HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "ID does not contain VOL information")
+
+ /* get the file object */
+ if(NULL == (obj = (void *)H5I_object(obj_id)))
+ HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "invalid file identifier")
+
+ if(H5VL_file_get(obj, vol_plugin, H5VL_FILE_GET_OBJ_COUNT, H5_REQUEST_NULL,
+ &obj_count, udata->types) < 0)
HGOTO_ERROR(H5E_INTERNAL, H5E_CANTGET, H5_ITER_ERROR, "unable to get object count in file(s)")
*(udata->obj_count) += obj_count;
@@ -355,12 +366,22 @@ int
H5F_get_obj_ids_cb(void UNUSED *obj_ptr, hid_t obj_id, void *key)
{
H5F_trav_obj_ids_t *udata = (H5F_trav_obj_ids_t *)key;
+ H5VL_t *vol_plugin;
+ void *obj;
ssize_t obj_count = 0;
int ret_value = H5_ITER_CONT; /* Return value */
FUNC_ENTER_NOAPI_NOINIT
- if(H5VL_file_get(obj_id, H5VL_FILE_GET_OBJ_IDS, H5_REQUEST_NULL, udata->types,
+ /* get the plugin pointer */
+ if (NULL == (vol_plugin = (H5VL_t *)H5I_get_aux(obj_id)))
+ HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "ID does not contain VOL information")
+
+ /* get the file object */
+ if(NULL == (obj = (void *)H5I_object(obj_id)))
+ HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "invalid file identifier")
+
+ if(H5VL_file_get(obj, vol_plugin, H5VL_FILE_GET_OBJ_IDS, H5_REQUEST_NULL, udata->types,
udata->max_objs, udata->oid_list, &obj_count) < 0)
HGOTO_ERROR(H5E_INTERNAL, H5E_CANTGET, H5_ITER_ERROR, "unable to get object count in file(s)")
@@ -1536,35 +1557,31 @@ done:
*
*-------------------------------------------------------------------------
*/
-hid_t
+H5F_t *
H5F_reopen(H5F_t *f)
{
- H5F_t *new_file = NULL;
- hid_t ret_value;
+ H5F_t *ret_value = NULL;
FUNC_ENTER_NOAPI_NOINIT
/* Get a new "top level" file struct, sharing the same "low level" file struct */
- if(NULL == (new_file = H5F_new(f->shared, H5P_FILE_CREATE_DEFAULT,
+ if(NULL == (ret_value = H5F_new(f->shared, H5P_FILE_CREATE_DEFAULT,
H5P_FILE_ACCESS_DEFAULT, NULL)))
- HGOTO_ERROR(H5E_FILE, H5E_CANTINIT, FAIL, "unable to reopen file")
+ HGOTO_ERROR(H5E_FILE, H5E_CANTINIT, NULL, "unable to reopen file")
/* Keep old file's read/write intent in new file */
- new_file->intent = f->intent;
+ ret_value->intent = f->intent;
/* Duplicate old file's names */
- new_file->open_name = H5MM_xstrdup(f->open_name);
- new_file->actual_name = H5MM_xstrdup(f->actual_name);
+ ret_value->open_name = H5MM_xstrdup(f->open_name);
+ ret_value->actual_name = H5MM_xstrdup(f->actual_name);
- if((ret_value = H5I_register(H5I_FILE, new_file, TRUE)) < 0)
- HGOTO_ERROR(H5E_ATOM, H5E_CANTREGISTER, FAIL, "unable to atomize file handle")
-
- /* Keep this ID in file object structure */
- new_file->file_id = ret_value;
+ if((ret_value->file_id = H5I_register(H5I_FILE_PRIVATE, ret_value, TRUE)) < 0)
+ HGOTO_ERROR(H5E_ATOM, H5E_CANTREGISTER, NULL, "unable to atomize file handle")
done:
- if(ret_value < 0 && new_file)
- if(H5F_dest(new_file, H5AC_dxpl_id, FALSE) < 0)
- HDONE_ERROR(H5E_FILE, H5E_CANTCLOSEFILE, FAIL, "can't close file")
+ if(ret_value->file_id < 0 && ret_value)
+ if(H5F_dest(ret_value, H5AC_dxpl_id, FALSE) < 0)
+ HDONE_ERROR(H5E_FILE, H5E_CANTCLOSEFILE, NULL, "can't close file")
FUNC_LEAVE_NOAPI(ret_value)
} /* end H5F_reopen() */
@@ -1594,12 +1611,8 @@ H5F_get_id(H5F_t *file, hbool_t app_ref)
if(file->file_id == -1) {
/* Get an atom for the file */
- if((file->file_id = H5I_register(H5I_FILE, file, app_ref)) < 0)
+ if((file->file_id = H5I_register(H5I_FILE_PRIVATE, file, app_ref)) < 0)
HGOTO_ERROR(H5E_ATOM, H5E_CANTREGISTER, FAIL, "unable to atomize file")
-
- /* attach VOL information to the ID */
- if (H5I_register_aux(file->file_id, file->vol_cls, (H5I_free_t)H5VL_close) < 0)
- HGOTO_ERROR(H5E_VOL, H5E_CANTINIT, FAIL, "can't attach vol info to ID")
} else {
/* Increment reference count on atom. */
if(H5I_inc_ref(file->file_id, app_ref) < 0)
diff --git a/src/H5Fmount.c b/src/H5Fmount.c
index 18dd601..6a08921 100644
--- a/src/H5Fmount.c
+++ b/src/H5Fmount.c
@@ -468,9 +468,12 @@ H5F_is_mount(const H5F_t *file)
herr_t
H5Fmount(hid_t loc_id, const char *name, hid_t child_id, hid_t plist_id)
{
- H5VL_class_t *vol_plugin1; /* VOL structure attached to loc_id */
- H5VL_class_t *vol_plugin2; /* VOL structure attached to child_id */
- herr_t ret_value = SUCCEED; /* Return value */
+ void *obj;
+ void *file;
+ H5VL_t *vol_plugin1; /* VOL structure attached to loc_id */
+ H5VL_t *vol_plugin2; /* VOL structure attached to child_id */
+ H5I_type_t type;
+ herr_t ret_value = SUCCEED; /* Return value */
FUNC_ENTER_API(FAIL)
H5TRACE4("e", "i*sii", loc_id, name, child_id, plist_id);
@@ -484,17 +487,30 @@ H5Fmount(hid_t loc_id, const char *name, hid_t child_id, hid_t plist_id)
if(TRUE != H5P_isa_class(plist_id, H5P_FILE_MOUNT))
HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not property list")
- if (NULL == (vol_plugin1 = (H5VL_class_t *)H5I_get_aux(loc_id)))
- HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "loc_id does not contain VOL information")
- if (NULL == (vol_plugin2 = (H5VL_class_t *)H5I_get_aux(child_id)))
- HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "child_id does not contain VOL information")
+ type = H5I_get_type(loc_id);
+ if(H5I_FILE != type && H5I_GROUP != type) {
+ HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a file or group object")
+ }
+
+ /* get the plugin pointers */
+ if (NULL == (vol_plugin1 = (H5VL_t *)H5I_get_aux(loc_id)))
+ HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "ID does not contain VOL information")
+ if (NULL == (vol_plugin2 = (H5VL_t *)H5I_get_aux(child_id)))
+ HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "ID does not contain VOL information")
/* check if both objects are associated with the same VOL plugin */
- if (vol_plugin1 != vol_plugin2)
+ if (vol_plugin1->cls != vol_plugin2->cls)
HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "Can't mount file onto object from different VOL plugin")
- if((ret_value = H5VL_file_misc(loc_id, H5VL_FILE_MOUNT, H5_REQUEST_NULL,
- name, child_id, plist_id)) < 0)
+ /* get the group/file object */
+ if(NULL == (obj = (void *)H5I_object(loc_id)))
+ HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "invalid file identifier")
+ /* get the file object */
+ if(NULL == (file = (void *)H5I_object(child_id)))
+ HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "invalid file identifier")
+
+ if((ret_value = H5VL_file_misc(obj, vol_plugin1, H5VL_FILE_MOUNT, H5_REQUEST_NULL,
+ type, name, file, plist_id)) < 0)
HGOTO_ERROR(H5E_FILE, H5E_MOUNT, FAIL, "unable to mount file")
done:
@@ -524,19 +540,32 @@ done:
herr_t
H5Funmount(hid_t loc_id, const char *name)
{
- H5G_loc_t loc;
+ void *obj;
+ H5VL_t *vol_plugin; /* VOL structure attached to loc_id */
+ H5I_type_t type;
herr_t ret_value=SUCCEED; /* Return value */
FUNC_ENTER_API(FAIL)
H5TRACE2("e", "i*s", loc_id, name);
/* Check args */
- if(H5G_loc(loc_id, &loc) < 0)
- HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a location")
if(!name || !*name)
HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "no name")
- if((ret_value = H5VL_file_misc(loc_id, H5VL_FILE_UNMOUNT, H5_REQUEST_NULL, name)) < 0)
+ type = H5I_get_type(loc_id);
+ if(H5I_FILE != type && H5I_GROUP != type) {
+ HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a file or group object")
+ }
+
+ /* get the plugin pointers */
+ if (NULL == (vol_plugin = (H5VL_t *)H5I_get_aux(loc_id)))
+ HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "ID does not contain VOL information")
+
+ /* get the group/file object */
+ if(NULL == (obj = (void *)H5I_object(loc_id)))
+ HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "invalid file identifier")
+
+ if((ret_value = H5VL_file_misc(obj, vol_plugin, H5VL_FILE_UNMOUNT, H5_REQUEST_NULL, type, name)) < 0)
HGOTO_ERROR(H5E_FILE, H5E_MOUNT, FAIL, "unable to unmount file")
done:
diff --git a/src/H5Fprivate.h b/src/H5Fprivate.h
index 53698a7..e196bd2 100644
--- a/src/H5Fprivate.h
+++ b/src/H5Fprivate.h
@@ -529,14 +529,13 @@ 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);
-H5_DLL hid_t H5F_reopen(H5F_t *f);
+H5_DLL H5F_t *H5F_reopen(H5F_t *f);
H5_DLL htri_t H5F_is_hdf5(const char *name);
H5_DLL herr_t H5F_get_objects(const H5F_t *f, unsigned types, size_t max_index, hid_t *obj_id_list, hbool_t app_ref, size_t *obj_id_count_ptr);
H5_DLL int H5F_get_objects_cb(void *obj_ptr, hid_t obj_id, void *key);
H5_DLL int H5F_get_obj_count_cb(void *obj_ptr, hid_t obj_id, void *key);
H5_DLL int H5F_get_obj_ids_cb(void *obj_ptr, hid_t obj_id, void *key);
-
/* Functions than retrieve values from the file struct */
H5_DLL unsigned H5F_get_intent(const H5F_t *f);
H5_DLL char *H5F_get_open_name(const H5F_t *f);
diff --git a/src/H5G.c b/src/H5G.c
index 6c8ee53..03e4ca3 100644
--- a/src/H5G.c
+++ b/src/H5G.c
@@ -93,6 +93,7 @@
#include "H5Eprivate.h" /* Error handling */
#include "H5Gpkg.h" /* Groups */
#include "H5Iprivate.h" /* IDs */
+#include "H5MMprivate.h" /* Memory management */
#include "H5Pprivate.h" /* Property lists */
#include "H5VLprivate.h" /* VOL plugins */
@@ -187,7 +188,7 @@ H5G_init_interface(void)
FUNC_ENTER_NOAPI_NOINIT
/* Initialize the atom group for the group IDs */
- if(H5I_register_type(H5I_GROUP, (size_t)H5I_GROUPID_HASHSIZE, H5G_RESERVED_ATOMS, (H5I_free_t)H5G_close) < 0)
+ if(H5I_register_type(H5I_GROUP, (size_t)H5I_GROUPID_HASHSIZE, H5G_RESERVED_ATOMS, NULL) < 0)
HGOTO_ERROR(H5E_SYM, H5E_CANTINIT, FAIL, "unable to initialize interface")
done:
@@ -263,6 +264,10 @@ H5G_term_interface(void)
hid_t
H5Gcreate2(hid_t loc_id, const char *name, hid_t lcpl_id, hid_t gcpl_id, hid_t gapl_id)
{
+ void *grp = NULL; /* dset token from VOL plugin */
+ void *obj = NULL; /* object token of loc_id */
+ H5VL_t *vol_plugin; /* VOL plugin information */
+ H5VL_loc_params_t loc_params;
H5P_genplist_t *plist; /* Property list pointer */
hid_t ret_value; /* Return value */
@@ -301,11 +306,35 @@ H5Gcreate2(hid_t loc_id, const char *name, hid_t lcpl_id, hid_t gcpl_id, hid_t g
if(H5P_set(plist, H5VL_GRP_LCPL_ID, &lcpl_id) < 0)
HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, FAIL, "can't set property value for lcpl id")
+ loc_params.type = H5VL_OBJECT_BY_SELF;
+ loc_params.obj_type = H5I_get_type(loc_id);
+
+ /* get the file object */
+ if(NULL == (obj = (void *)H5I_object(loc_id)))
+ HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "invalid file identifier")
+
+ /* get the plugin pointer */
+ if (NULL == (vol_plugin = (H5VL_t *)H5I_get_aux(loc_id)))
+ HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "ID does not contain VOL information")
+
/* Create the group through the VOL */
- if((ret_value = H5VL_group_create(loc_id, name, gcpl_id, gapl_id, H5_REQUEST_NULL)) < 0)
+ if(NULL == (grp = H5VL_group_create(obj, loc_params, vol_plugin, name, gcpl_id, gapl_id, H5_REQUEST_NULL)))
HGOTO_ERROR(H5E_SYM, H5E_CANTINIT, FAIL, "unable to create group")
+ /* Get an atom for the group */
+ if((ret_value = H5I_register(H5I_GROUP, grp, TRUE)) < 0)
+ HGOTO_ERROR(H5E_ATOM, H5E_CANTREGISTER, FAIL, "unable to atomize group handle")
+
+ /* attach VOL information to the ID */
+ if (H5I_register_aux(ret_value, vol_plugin, (H5I_free2_t)H5G_close_group) < 0)
+ HGOTO_ERROR(H5E_VOL, H5E_CANTINIT, FAIL, "can't attach vol info to ID")
+
+ vol_plugin->nrefs ++;
+
done:
+ if (ret_value < 0 && grp)
+ if(H5VL_group_close (grp, vol_plugin, H5_REQUEST_NULL) < 0)
+ HDONE_ERROR(H5E_SYM, H5E_CLOSEERROR, FAIL, "unable to release group")
FUNC_LEAVE_API(ret_value)
} /* end H5Gcreate2() */
@@ -348,6 +377,10 @@ done:
hid_t
H5Gcreate_anon(hid_t loc_id, hid_t gcpl_id, hid_t gapl_id)
{
+ void *grp = NULL; /* dset token from VOL plugin */
+ void *obj = NULL; /* object token of loc_id */
+ H5VL_t *vol_plugin; /* VOL plugin information */
+ H5VL_loc_params_t loc_params;
hid_t ret_value;
FUNC_ENTER_API(FAIL)
@@ -367,11 +400,35 @@ H5Gcreate_anon(hid_t loc_id, hid_t gcpl_id, hid_t gapl_id)
if(TRUE != H5P_isa_class(gapl_id, H5P_GROUP_ACCESS))
HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not group access property list")
+ loc_params.type = H5VL_OBJECT_BY_SELF;
+ loc_params.obj_type = H5I_get_type(loc_id);
+
+ /* get the file object */
+ if(NULL == (obj = (void *)H5I_object(loc_id)))
+ HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "invalid file identifier")
+
+ /* get the plugin pointer */
+ if (NULL == (vol_plugin = (H5VL_t *)H5I_get_aux(loc_id)))
+ HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "ID does not contain VOL information")
+
/* Create the group through the VOL */
- if((ret_value = H5VL_group_create(loc_id, NULL, gcpl_id, gapl_id, H5_REQUEST_NULL)) < 0)
+ if(NULL == (grp = H5VL_group_create(obj, loc_params, vol_plugin, NULL, gcpl_id, gapl_id, H5_REQUEST_NULL)))
HGOTO_ERROR(H5E_SYM, H5E_CANTINIT, FAIL, "unable to create group")
+ /* Get an atom for the group */
+ if((ret_value = H5I_register(H5I_GROUP, grp, TRUE)) < 0)
+ HGOTO_ERROR(H5E_ATOM, H5E_CANTREGISTER, FAIL, "unable to atomize group handle")
+
+ /* attach VOL information to the ID */
+ if (H5I_register_aux(ret_value, vol_plugin, (H5I_free2_t)H5G_close_group) < 0)
+ HGOTO_ERROR(H5E_VOL, H5E_CANTINIT, FAIL, "can't attach vol info to ID")
+
+ vol_plugin->nrefs ++;
+
done:
+ if (ret_value < 0 && grp)
+ if(H5VL_group_close (grp, vol_plugin, H5_REQUEST_NULL) < 0)
+ HDONE_ERROR(H5E_SYM, H5E_CLOSEERROR, FAIL, "unable to release group")
FUNC_LEAVE_API(ret_value)
} /* end H5Gcreate_anon() */
@@ -396,6 +453,10 @@ done:
hid_t
H5Gopen2(hid_t loc_id, const char *name, hid_t gapl_id)
{
+ void *grp = NULL; /* dset token from VOL plugin */
+ void *obj = NULL; /* object token of loc_id */
+ H5VL_t *vol_plugin; /* VOL plugin information */
+ H5VL_loc_params_t loc_params;
hid_t ret_value; /* Return value */
FUNC_ENTER_API(FAIL)
@@ -412,11 +473,35 @@ H5Gopen2(hid_t loc_id, const char *name, hid_t gapl_id)
if(TRUE != H5P_isa_class(gapl_id, H5P_GROUP_ACCESS))
HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not group access property list")
- /* Open the group through the VOL */
- if((ret_value = H5VL_group_open(loc_id, name, gapl_id, H5_REQUEST_NULL)) < 0)
- HGOTO_ERROR(H5E_SYM, H5E_CANTINIT, FAIL, "unable to open group")
+ loc_params.type = H5VL_OBJECT_BY_SELF;
+ loc_params.obj_type = H5I_get_type(loc_id);
+
+ /* get the file object */
+ if(NULL == (obj = (void *)H5I_object(loc_id)))
+ HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "invalid file identifier")
+
+ /* get the plugin pointer */
+ if (NULL == (vol_plugin = (H5VL_t *)H5I_get_aux(loc_id)))
+ HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "ID does not contain VOL information")
+
+ /* Create the group through the VOL */
+ if(NULL == (grp = H5VL_group_open(obj, loc_params, vol_plugin, name, gapl_id, H5_REQUEST_NULL)))
+ HGOTO_ERROR(H5E_SYM, H5E_CANTINIT, FAIL, "unable to create group")
+
+ /* Get an atom for the group */
+ if((ret_value = H5I_register(H5I_GROUP, grp, TRUE)) < 0)
+ HGOTO_ERROR(H5E_ATOM, H5E_CANTREGISTER, FAIL, "unable to atomize group handle")
+
+ /* attach VOL information to the ID */
+ if (H5I_register_aux(ret_value, vol_plugin, (H5I_free2_t)H5G_close_group) < 0)
+ HGOTO_ERROR(H5E_VOL, H5E_CANTINIT, FAIL, "can't attach vol info to ID")
+
+ vol_plugin->nrefs ++;
done:
+ if (ret_value < 0 && grp)
+ if(H5VL_group_close (grp, vol_plugin, H5_REQUEST_NULL) < 0)
+ HDONE_ERROR(H5E_SYM, H5E_CLOSEERROR, FAIL, "unable to release group")
FUNC_LEAVE_API(ret_value)
} /* end H5Gopen2() */
@@ -438,14 +523,23 @@ done:
*-------------------------------------------------------------------------
*/
hid_t
-H5Gget_create_plist(hid_t uid)
+H5Gget_create_plist(hid_t grp_id)
{
- hid_t ret_value = FAIL;
+ H5VL_t *vol_plugin;
+ void *grp;
+ hid_t ret_value = FAIL;
FUNC_ENTER_API(FAIL)
- H5TRACE1("i", "i", uid);
+ H5TRACE1("i", "i", grp_id);
+
+ /* get the plugin pointer */
+ if (NULL == (vol_plugin = (H5VL_t *)H5I_get_aux(grp_id)))
+ HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "ID does not contain VOL information")
+ /* get the dataset object */
+ if(NULL == (grp = (void *)H5I_object(grp_id)))
+ HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "invalid group identifier")
- if(H5VL_group_get(uid, H5VL_GROUP_GET_GCPL, H5_REQUEST_NULL, &ret_value) < 0)
+ if(H5VL_group_get(grp, vol_plugin, H5VL_GROUP_GET_GCPL, H5_REQUEST_NULL, &ret_value) < 0)
HGOTO_ERROR(H5E_INTERNAL, H5E_CANTGET, FAIL, "unable to get group creation properties")
done:
@@ -469,6 +563,8 @@ done:
herr_t
H5Gget_info(hid_t loc_id, H5G_info_t *grp_info)
{
+ H5VL_t *vol_plugin;
+ void *obj;
H5I_type_t id_type; /* Type of ID */
H5VL_loc_params_t loc_params;
herr_t ret_value = SUCCEED; /* Return value */
@@ -483,11 +579,19 @@ H5Gget_info(hid_t loc_id, H5G_info_t *grp_info)
if(!grp_info)
HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "no info struct")
- loc_params.type = H5VL_OBJECT_BY_ID;
- loc_params.loc_data.loc_by_id.id = loc_id;
+ /* get the plugin pointer */
+ if (NULL == (vol_plugin = (H5VL_t *)H5I_get_aux(loc_id)))
+ HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "ID does not contain VOL information")
+ /* get the dataset object */
+ if(NULL == (obj = (void *)H5I_object(loc_id)))
+ HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "invalid group identifier")
+
+ loc_params.type = H5VL_OBJECT_BY_SELF;
+ loc_params.obj_type = id_type;
/* Get the group info through the VOL using the location token */
- if((ret_value = H5VL_group_get(loc_id, H5VL_GROUP_GET_INFO, H5_REQUEST_NULL, grp_info, loc_params)) < 0)
+ if((ret_value = H5VL_group_get(obj, vol_plugin, H5VL_GROUP_GET_INFO, H5_REQUEST_NULL,
+ loc_params, grp_info)) < 0)
HGOTO_ERROR(H5E_INTERNAL, H5E_CANTGET, FAIL, "unable to get group info")
done:
@@ -512,6 +616,8 @@ herr_t
H5Gget_info_by_name(hid_t loc_id, const char *name, H5G_info_t *grp_info,
hid_t lapl_id)
{
+ H5VL_t *vol_plugin;
+ void *obj;
H5VL_loc_params_t loc_params;
herr_t ret_value = SUCCEED; /* Return value */
@@ -532,9 +638,17 @@ H5Gget_info_by_name(hid_t loc_id, const char *name, H5G_info_t *grp_info,
loc_params.type = H5VL_OBJECT_BY_NAME;
loc_params.loc_data.loc_by_name.name = name;
loc_params.loc_data.loc_by_name.plist_id = lapl_id;
+ loc_params.obj_type = H5I_get_type(loc_id);
+
+ /* get the plugin pointer */
+ if (NULL == (vol_plugin = (H5VL_t *)H5I_get_aux(loc_id)))
+ HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "ID does not contain VOL information")
+ /* get the dataset object */
+ if(NULL == (obj = (void *)H5I_object(loc_id)))
+ HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "invalid group identifier")
/* Get the group info through the VOL using the location token */
- if((ret_value = H5VL_group_get(loc_id, H5VL_GROUP_GET_INFO, H5_REQUEST_NULL,
+ if((ret_value = H5VL_group_get(obj, vol_plugin, H5VL_GROUP_GET_INFO, H5_REQUEST_NULL,
grp_info, loc_params)) < 0)
HGOTO_ERROR(H5E_INTERNAL, H5E_CANTGET, FAIL, "unable to get group info")
@@ -561,6 +675,8 @@ herr_t
H5Gget_info_by_idx(hid_t loc_id, const char *group_name, H5_index_t idx_type,
H5_iter_order_t order, hsize_t n, H5G_info_t *grp_info, hid_t lapl_id)
{
+ H5VL_t *vol_plugin;
+ void *obj;
H5VL_loc_params_t loc_params;
herr_t ret_value = SUCCEED; /* Return value */
@@ -589,9 +705,17 @@ H5Gget_info_by_idx(hid_t loc_id, const char *group_name, H5_index_t idx_type,
loc_params.loc_data.loc_by_idx.order = order;
loc_params.loc_data.loc_by_idx.n = n;
loc_params.loc_data.loc_by_idx.plist_id = lapl_id;
+ loc_params.obj_type = H5I_get_type(loc_id);
+
+ /* get the plugin pointer */
+ if (NULL == (vol_plugin = (H5VL_t *)H5I_get_aux(loc_id)))
+ HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "ID does not contain VOL information")
+ /* get the dataset object */
+ if(NULL == (obj = (void *)H5I_object(loc_id)))
+ HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "invalid group identifier")
/* Get the group info through the VOL using the location token */
- if((ret_value = H5VL_group_get(loc_id, H5VL_GROUP_GET_INFO, H5_REQUEST_NULL,
+ if((ret_value = H5VL_group_get(obj, vol_plugin, H5VL_GROUP_GET_INFO, H5_REQUEST_NULL,
grp_info, loc_params)) < 0)
HGOTO_ERROR(H5E_INTERNAL, H5E_CANTGET, FAIL, "unable to get group info")
@@ -621,11 +745,60 @@ H5Gclose(hid_t group_id)
FUNC_ENTER_API(FAIL)
H5TRACE1("e", "i", group_id);
+ /* Check args */
+ if(NULL == H5I_object_verify(group_id,H5I_GROUP))
+ HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a group")
+
+ /*
+ * Decrement the counter on the group atom. It will be freed if the count
+ * reaches zero.
+ */
+ if(H5I_dec_app_ref(group_id) < 0)
+ HGOTO_ERROR(H5E_SYM, H5E_CANTRELEASE, FAIL, "unable to close group")
+#if 0
/* Close the group through the VOL */
if(H5VL_group_close(group_id, H5_REQUEST_NULL) < 0)
HGOTO_ERROR(H5E_SYM, H5E_CANTRELEASE, FAIL, "unable to close group")
+#endif
done:
FUNC_LEAVE_API(ret_value)
} /* end H5Gclose() */
+
+/*-------------------------------------------------------------------------
+ * Function: H5G_close_group
+ *
+ * Purpose: Called when the ref count reaches zero on the group_id
+ *
+ * Return: Success: Non-negative
+ *
+ * Failure: Negative
+ *
+ * Programmer: Mohamad Chaarawi
+ * June 2012
+ *
+ *-------------------------------------------------------------------------
+ */
+herr_t
+H5G_close_group(void *dset, H5VL_t *vol_plugin)
+{
+ herr_t ret_value = SUCCEED; /* Return value */
+
+ FUNC_ENTER_NOAPI_NOINIT
+
+ /* Close the group through the VOL*/
+ if((ret_value = H5VL_group_close(dset, vol_plugin, H5_REQUEST_NULL)) < 0)
+ HGOTO_ERROR(H5E_SYM, H5E_CLOSEERROR, FAIL, "unable to close group")
+
+ vol_plugin->nrefs --;
+ if (0 == vol_plugin->nrefs) {
+ if (NULL != vol_plugin->container_name)
+ H5MM_xfree(vol_plugin->container_name);
+ if (NULL != vol_plugin)
+ H5MM_free(vol_plugin);
+ }
+
+done:
+ FUNC_LEAVE_NOAPI(ret_value)
+} /* end H5G_close_group() */
diff --git a/src/H5Gdeprec.c b/src/H5Gdeprec.c
index 8c23c7c..ba3f284 100644
--- a/src/H5Gdeprec.c
+++ b/src/H5Gdeprec.c
@@ -197,6 +197,10 @@ H5G_map_obj_type(H5O_type_t obj_type)
hid_t
H5Gcreate1(hid_t loc_id, const char *name, size_t size_hint)
{
+ void *grp = NULL; /* dset token from VOL plugin */
+ void *obj = NULL; /* object token of loc_id */
+ H5VL_t *vol_plugin; /* VOL plugin information */
+ H5VL_loc_params_t loc_params;
hid_t tmp_gcpl = (-1); /* Temporary group creation property list */
hid_t lcpl_id = H5P_LINK_CREATE_DEFAULT;
H5P_genplist_t *plist;
@@ -246,14 +250,39 @@ H5Gcreate1(hid_t loc_id, const char *name, size_t size_hint)
if(H5P_set(plist, H5VL_GRP_LCPL_ID, &lcpl_id) < 0)
HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, FAIL, "can't get property value for lcpl id")
+ loc_params.type = H5VL_OBJECT_BY_SELF;
+ loc_params.obj_type = H5I_get_type(loc_id);
+
+ /* get the file object */
+ if(NULL == (obj = (void *)H5I_object(loc_id)))
+ HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "invalid file identifier")
+
+ /* get the plugin pointer */
+ if (NULL == (vol_plugin = (H5VL_t *)H5I_get_aux(loc_id)))
+ HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "ID does not contain VOL information")
+
/* Create the group through the VOL */
- if((ret_value = H5VL_group_create(loc_id, name, tmp_gcpl, H5P_GROUP_ACCESS_DEFAULT, H5_REQUEST_NULL)) < 0)
+ if(NULL == (grp = H5VL_group_create(obj, loc_params, vol_plugin, name, tmp_gcpl,
+ H5P_GROUP_ACCESS_DEFAULT, H5_REQUEST_NULL)))
HGOTO_ERROR(H5E_SYM, H5E_CANTINIT, FAIL, "unable to create group")
+ /* Get an atom for the group */
+ if((ret_value = H5I_register(H5I_GROUP, grp, TRUE)) < 0)
+ HGOTO_ERROR(H5E_ATOM, H5E_CANTREGISTER, FAIL, "unable to atomize group handle")
+
+ /* attach VOL information to the ID */
+ if (H5I_register_aux(ret_value, vol_plugin, (H5I_free2_t)H5G_close_group) < 0)
+ HGOTO_ERROR(H5E_VOL, H5E_CANTINIT, FAIL, "can't attach vol info to ID")
+
+ vol_plugin->nrefs ++;
+
done:
if(tmp_gcpl > 0 && tmp_gcpl != H5P_GROUP_CREATE_DEFAULT)
if(H5I_dec_ref(tmp_gcpl) < 0)
HDONE_ERROR(H5E_SYM, H5E_CLOSEERROR, FAIL, "unable to release property list")
+ if (ret_value < 0 && grp)
+ if(H5VL_group_close (grp, vol_plugin, H5_REQUEST_NULL) < 0)
+ HDONE_ERROR(H5E_SYM, H5E_CLOSEERROR, FAIL, "unable to release group")
FUNC_LEAVE_API(ret_value)
} /* end H5Gcreate1() */
@@ -279,6 +308,10 @@ done:
hid_t
H5Gopen1(hid_t loc_id, const char *name)
{
+ void *grp = NULL; /* dset token from VOL plugin */
+ void *obj = NULL; /* object token of loc_id */
+ H5VL_t *vol_plugin; /* VOL plugin information */
+ H5VL_loc_params_t loc_params;
hid_t ret_value; /* Return value */
FUNC_ENTER_API(FAIL)
@@ -288,11 +321,35 @@ H5Gopen1(hid_t loc_id, const char *name)
if(!name || !*name)
HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "no name")
- /* Open the group through the VOL */
- if((ret_value = H5VL_group_open(loc_id, name, H5P_DEFAULT, H5_REQUEST_NULL)) < 0)
+ loc_params.type = H5VL_OBJECT_BY_SELF;
+ loc_params.obj_type = H5I_get_type(loc_id);
+
+ /* get the file object */
+ if(NULL == (obj = (void *)H5I_object(loc_id)))
+ HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "invalid file identifier")
+
+ /* get the plugin pointer */
+ if (NULL == (vol_plugin = (H5VL_t *)H5I_get_aux(loc_id)))
+ HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "ID does not contain VOL information")
+
+ /* Create the group through the VOL */
+ if(NULL == (grp = H5VL_group_open(obj, loc_params, vol_plugin, name, H5P_DEFAULT, H5_REQUEST_NULL)))
HGOTO_ERROR(H5E_SYM, H5E_CANTINIT, FAIL, "unable to create group")
+ /* Get an atom for the group */
+ if((ret_value = H5I_register(H5I_GROUP, grp, TRUE)) < 0)
+ HGOTO_ERROR(H5E_ATOM, H5E_CANTREGISTER, FAIL, "unable to atomize group handle")
+
+ /* attach VOL information to the ID */
+ if (H5I_register_aux(ret_value, vol_plugin, (H5I_free2_t)H5G_close_group) < 0)
+ HGOTO_ERROR(H5E_VOL, H5E_CANTINIT, FAIL, "can't attach vol info to ID")
+
+ vol_plugin->nrefs ++;
+
done:
+ if (ret_value < 0 && grp)
+ if(H5VL_group_close (grp, vol_plugin, H5_REQUEST_NULL) < 0)
+ HDONE_ERROR(H5E_SYM, H5E_CLOSEERROR, FAIL, "unable to release group")
FUNC_LEAVE_API(ret_value)
} /* end H5Gopen1() */
@@ -326,24 +383,61 @@ H5Glink(hid_t cur_loc_id, H5G_link_t type, const char *cur_name, const char *new
HGOTO_ERROR(H5E_ATOM, H5E_BADATOM, FAIL, "can't find object for ID")
if(type == H5L_TYPE_HARD) {
+ void *obj = NULL; /* object token of loc_id */
+ H5VL_t *vol_plugin = NULL; /* VOL plugin information */
+ H5VL_loc_params_t loc_params1;
+ H5VL_loc_params_t loc_params2;
+
+ loc_params1.type = H5VL_OBJECT_BY_NAME;
+ loc_params1.obj_type = H5I_get_type(cur_loc_id);
+ loc_params1.loc_data.loc_by_name.name = cur_name;
+ loc_params1.loc_data.loc_by_name.plist_id = H5P_DEFAULT;
+
+ loc_params2.type = H5VL_OBJECT_BY_NAME;
+ loc_params2.loc_data.loc_by_name.name = new_name;
+ loc_params2.loc_data.loc_by_name.plist_id = H5P_DEFAULT;
+
+ /* get the file object */
+ if(NULL == (obj = (void *)H5I_object(cur_loc_id)))
+ HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "invalid file identifier")
+ /* get the plugin pointer */
+ if (NULL == (vol_plugin = (H5VL_t *)H5I_get_aux(cur_loc_id)))
+ HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "ID does not contain VOL information")
+
/* set creation properties */
- if(H5P_set(plist, H5VL_LINK_TARGET_ID, &cur_loc_id) < 0)
- HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, FAIL, "can't set property value for target id")
- if(H5P_set(plist, H5VL_LINK_TARGET_NAME, &cur_name) < 0)
- HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, FAIL, "can't set property value for target name")
+ if(H5P_set(plist, H5VL_LINK_TARGET, &obj) < 0)
+ HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, FAIL, "can't set property value for target")
+ if(H5P_set(plist, H5VL_LINK_TARGET_LOC_PARAMS, &loc_params1) < 0)
+ HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, FAIL, "can't set property value for target loc params")
/* Create the link through the VOL */
- if((ret_value = H5VL_link_create(H5VL_LINK_CREATE_HARD, H5L_SAME_LOC, new_name,
+ if((ret_value = H5VL_link_create(H5VL_LINK_CREATE_HARD, NULL, loc_params2, vol_plugin,
lcpl_id, H5P_DEFAULT, H5_REQUEST_NULL)) < 0)
HGOTO_ERROR(H5E_SYM, H5E_CANTINIT, FAIL, "unable to create link")
} /* end if */
else if(type == H5L_TYPE_SOFT) {
+ void *obj = NULL; /* object token of loc_id */
+ H5VL_t *vol_plugin = NULL; /* VOL plugin information */
+ H5VL_loc_params_t loc_params;
+
+ loc_params.type = H5VL_OBJECT_BY_NAME;
+ loc_params.loc_data.loc_by_name.name = new_name;
+ loc_params.loc_data.loc_by_name.plist_id = H5P_DEFAULT;
+ loc_params.obj_type = H5I_get_type(cur_loc_id);
+
+ /* get the file object */
+ if(NULL == (obj = (void *)H5I_object(cur_loc_id)))
+ HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "invalid file identifier")
+ /* get the plugin pointer */
+ if (NULL == (vol_plugin = (H5VL_t *)H5I_get_aux(cur_loc_id)))
+ HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "ID does not contain VOL information")
+
/* set creation properties */
if(H5P_set(plist, H5VL_LINK_TARGET_NAME, &cur_name) < 0)
HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, FAIL, "can't get property value for target name")
/* Create the link through the VOL */
- if((ret_value = H5VL_link_create(H5VL_LINK_CREATE_SOFT, cur_loc_id, new_name,
+ if((ret_value = H5VL_link_create(H5VL_LINK_CREATE_SOFT, obj, loc_params, vol_plugin,
lcpl_id, H5P_DEFAULT, H5_REQUEST_NULL)) < 0)
HGOTO_ERROR(H5E_SYM, H5E_CANTINIT, FAIL, "unable to create link")
} /* end else if */
@@ -385,29 +479,77 @@ H5Glink2(hid_t cur_loc_id, const char *cur_name, H5G_link_t type,
HGOTO_ERROR(H5E_ATOM, H5E_BADATOM, FAIL, "can't find object for ID")
if(type == H5L_TYPE_HARD) {
+ void *obj1 = NULL; /* object token of loc_id */
+ void *obj2 = NULL; /* object token of loc_id */
+ H5VL_t *vol_plugin1 = NULL; /* VOL plugin information */
+ H5VL_t *vol_plugin2 = NULL; /* VOL plugin information */
+ H5VL_loc_params_t loc_params1;
+ H5VL_loc_params_t loc_params2;
+
+ loc_params1.type = H5VL_OBJECT_BY_NAME;
+ loc_params1.obj_type = H5I_get_type(cur_loc_id);
+ loc_params1.loc_data.loc_by_name.name = cur_name;
+ loc_params1.loc_data.loc_by_name.plist_id = H5P_DEFAULT;
+
+ loc_params2.type = H5VL_OBJECT_BY_NAME;
+ loc_params2.obj_type = H5I_get_type(new_loc_id);
+ loc_params2.loc_data.loc_by_name.name = new_name;
+ loc_params2.loc_data.loc_by_name.plist_id = H5P_DEFAULT;
+
+ /* get the file object */
+ if(NULL == (obj1 = (void *)H5I_object(cur_loc_id)))
+ HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "invalid file identifier")
+ /* get the plugin pointer */
+ if (NULL == (vol_plugin1 = (H5VL_t *)H5I_get_aux(cur_loc_id)))
+ HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "ID does not contain VOL information")
+
+ /* get the file object */
+ if(NULL == (obj2 = (void *)H5I_object(new_loc_id)))
+ HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "invalid file identifier")
+ /* get the plugin pointer */
+ if (NULL == (vol_plugin2 = (H5VL_t *)H5I_get_aux(new_loc_id)))
+ HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "ID does not contain VOL information")
+
/* set creation properties */
- if(H5P_set(plist, H5VL_LINK_TARGET_ID, &cur_loc_id) < 0)
+ if(H5P_set(plist, H5VL_LINK_TARGET, &obj1) < 0)
HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, FAIL, "can't set property value for target id")
- if(H5P_set(plist, H5VL_LINK_TARGET_NAME, &cur_name) < 0)
+ if(H5P_set(plist, H5VL_LINK_TARGET_LOC_PARAMS, &loc_params1) < 0)
HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, FAIL, "can't set property value for target name")
/* Create the link through the VOL */
- if((ret_value = H5VL_link_create(H5VL_LINK_CREATE_HARD, new_loc_id, new_name,
+ if((ret_value = H5VL_link_create(H5VL_LINK_CREATE_HARD, obj2, loc_params2,
+ (vol_plugin1!=NULL ? vol_plugin1 : vol_plugin2),
lcpl_id, H5P_DEFAULT, H5_REQUEST_NULL)) < 0)
HGOTO_ERROR(H5E_SYM, H5E_CANTINIT, FAIL, "unable to create link")
} /* end if */
else if(type == H5L_TYPE_SOFT) {
+ void *obj = NULL; /* object token of loc_id */
+ H5VL_t *vol_plugin; /* VOL plugin information */
+ H5VL_loc_params_t loc_params;
+
/* Soft links only need one location, the new_loc_id, but it's possible that
* new_loc_id is H5L_SAME_LOC */
if(new_loc_id == H5L_SAME_LOC)
new_loc_id = cur_loc_id;
+ loc_params.type = H5VL_OBJECT_BY_NAME;
+ loc_params.loc_data.loc_by_name.name = new_name;
+ loc_params.loc_data.loc_by_name.plist_id = H5P_DEFAULT;
+ loc_params.obj_type = H5I_get_type(new_loc_id);
+
+ /* get the file object */
+ if(NULL == (obj = (void *)H5I_object(new_loc_id)))
+ HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "invalid file identifier")
+ /* get the plugin pointer */
+ if (NULL == (vol_plugin = (H5VL_t *)H5I_get_aux(new_loc_id)))
+ HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "ID does not contain VOL information")
+
/* set creation properties */
if(H5P_set(plist, H5VL_LINK_TARGET_NAME, &cur_name) < 0)
HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, FAIL, "can't get property value for target name")
/* Create the link through the VOL */
- if((ret_value = H5VL_link_create(H5VL_LINK_CREATE_SOFT, new_loc_id, new_name,
+ if((ret_value = H5VL_link_create(H5VL_LINK_CREATE_SOFT, obj, loc_params, vol_plugin,
lcpl_id, H5P_DEFAULT, H5_REQUEST_NULL)) < 0)
HGOTO_ERROR(H5E_SYM, H5E_CANTINIT, FAIL, "unable to create link")
} /* end else if */
@@ -429,13 +571,33 @@ done:
herr_t
H5Gmove(hid_t src_loc_id, const char *src_name, const char *dst_name)
{
+ void *obj = NULL; /* object token of loc_id */
+ H5VL_t *vol_plugin = NULL; /* VOL plugin information */
+ H5VL_loc_params_t loc_params1;
+ H5VL_loc_params_t loc_params2;
herr_t ret_value = SUCCEED; /* Return value */
FUNC_ENTER_API(FAIL)
H5TRACE3("e", "i*s*s", src_loc_id, src_name, dst_name);
+ loc_params1.type = H5VL_OBJECT_BY_NAME;
+ loc_params1.obj_type = H5I_get_type(src_loc_id);
+ loc_params1.loc_data.loc_by_name.name = src_name;
+ loc_params1.loc_data.loc_by_name.plist_id = H5P_DEFAULT;
+
+ loc_params2.type = H5VL_OBJECT_BY_NAME;
+ loc_params2.loc_data.loc_by_name.name = dst_name;
+ loc_params2.loc_data.loc_by_name.plist_id = H5P_DEFAULT;
+
+ /* get the file object */
+ if(NULL == (obj = (void *)H5I_object(src_loc_id)))
+ HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "invalid file identifier")
+ /* get the plugin pointer */
+ if (NULL == (vol_plugin = (H5VL_t *)H5I_get_aux(src_loc_id)))
+ HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "ID does not contain VOL information")
+
/* Create the link through the VOL */
- if((ret_value = H5VL_link_move(src_loc_id, src_name, H5L_SAME_LOC, dst_name,
+ if((ret_value = H5VL_link_move(obj, loc_params1, NULL, loc_params2, vol_plugin,
FALSE, H5P_DEFAULT, H5P_DEFAULT, H5_REQUEST_NULL)) < 0)
HGOTO_ERROR(H5E_SYM, H5E_CANTINIT, FAIL, "unable to create link")
@@ -455,13 +617,53 @@ herr_t
H5Gmove2(hid_t src_loc_id, const char *src_name, hid_t dst_loc_id,
const char *dst_name)
{
+ void *obj1 = NULL; /* object token of src_id */
+ H5VL_t *vol_plugin1; /* VOL plugin information */
+ H5VL_loc_params_t loc_params1;
+ void *obj2 = NULL; /* object token of dst_id */
+ H5VL_t *vol_plugin2; /* VOL plugin information */
+ H5VL_loc_params_t loc_params2;
herr_t ret_value = SUCCEED; /* Return value */
FUNC_ENTER_API(FAIL)
H5TRACE4("e", "i*si*s", src_loc_id, src_name, dst_loc_id, dst_name);
- /* Create the link through the VOL */
- if((ret_value = H5VL_link_move(src_loc_id, src_name, dst_loc_id, dst_name,
+ /* set location paramter for source object */
+ loc_params1.type = H5VL_OBJECT_BY_NAME;
+ loc_params1.loc_data.loc_by_name.name = src_name;
+ loc_params1.loc_data.loc_by_name.plist_id = H5P_DEFAULT;
+ loc_params1.obj_type = H5I_get_type(src_loc_id);
+ /* set location paramter for destination object */
+ loc_params2.type = H5VL_OBJECT_BY_NAME;
+ loc_params2.loc_data.loc_by_name.name = dst_name;
+ loc_params2.loc_data.loc_by_name.plist_id = H5P_DEFAULT;
+ loc_params2.obj_type = H5I_get_type(dst_loc_id);
+
+ if(H5L_SAME_LOC != src_loc_id) {
+ /* get the file object */
+ if(NULL == (obj1 = (void *)H5I_object(src_loc_id)))
+ HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "invalid file identifier")
+ /* get the plugin pointer */
+ if (NULL == (vol_plugin1 = (H5VL_t *)H5I_get_aux(src_loc_id)))
+ HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "ID does not contain VOL information")
+ }
+ if(H5L_SAME_LOC != dst_loc_id) {
+ /* get the file object */
+ if(NULL == (obj2 = (void *)H5I_object(dst_loc_id)))
+ HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "invalid file identifier")
+ /* get the plugin pointer */
+ if (NULL == (vol_plugin2 = (H5VL_t *)H5I_get_aux(dst_loc_id)))
+ HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "ID does not contain VOL information")
+ }
+ /* Make sure that the VOL plugins are the same */
+ if(H5L_SAME_LOC != dst_loc_id && H5L_SAME_LOC != src_loc_id) {
+ if (vol_plugin1 != vol_plugin2)
+ HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "Objects are accessed through different VOL plugins and can't be linked")
+ }
+
+ /* Move the link through the VOL */
+ if((ret_value = H5VL_link_move(obj1, loc_params1, obj2, loc_params2,
+ (vol_plugin1!=NULL ? vol_plugin1 : vol_plugin2),
FALSE, H5P_DEFAULT, H5P_DEFAULT, H5_REQUEST_NULL)) < 0)
HGOTO_ERROR(H5E_SYM, H5E_CANTINIT, FAIL, "unable to create link")
@@ -480,6 +682,9 @@ done:
herr_t
H5Gunlink(hid_t loc_id, const char *name)
{
+ void *obj = NULL; /* object token of loc_id */
+ H5VL_t *vol_plugin; /* VOL plugin information */
+ H5VL_loc_params_t loc_params;
herr_t ret_value = SUCCEED; /* Return value */
FUNC_ENTER_API(FAIL)
@@ -488,8 +693,20 @@ H5Gunlink(hid_t loc_id, const char *name)
if(!name || !*name)
HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "no name")
+ loc_params.type = H5VL_OBJECT_BY_NAME;
+ loc_params.obj_type = H5I_get_type(loc_id);
+ loc_params.loc_data.loc_by_name.name = name;
+ loc_params.loc_data.loc_by_name.plist_id = H5P_LINK_ACCESS_DEFAULT;
+
+ /* get the file object */
+ if(NULL == (obj = (void *)H5I_object(loc_id)))
+ HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "invalid file identifier")
+ /* get the plugin pointer */
+ if (NULL == (vol_plugin = (H5VL_t *)H5I_get_aux(loc_id)))
+ HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "ID does not contain VOL information")
+
/* Delete the link through the VOL */
- if((ret_value = H5VL_link_remove(loc_id, name, NULL, H5P_DEFAULT, H5_REQUEST_NULL)) < 0)
+ if((ret_value = H5VL_link_remove(obj, loc_params, vol_plugin, H5_REQUEST_NULL)) < 0)
HGOTO_ERROR(H5E_SYM, H5E_CANTINIT, FAIL, "unable to create link")
done:
@@ -508,6 +725,9 @@ done:
herr_t
H5Gget_linkval(hid_t loc_id, const char *name, size_t size, char *buf/*out*/)
{
+ void *obj = NULL; /* object token of loc_id */
+ H5VL_t *vol_plugin; /* VOL plugin information */
+ H5VL_loc_params_t loc_params;
herr_t ret_value = SUCCEED; /* Return value */
FUNC_ENTER_API(FAIL)
@@ -517,9 +737,21 @@ H5Gget_linkval(hid_t loc_id, const char *name, size_t size, char *buf/*out*/)
if(!name || !*name)
HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "no name specified")
+ loc_params.type = H5VL_OBJECT_BY_NAME;
+ loc_params.obj_type = H5I_get_type(loc_id);
+ loc_params.loc_data.loc_by_name.name = name;
+ loc_params.loc_data.loc_by_name.plist_id = H5P_LINK_ACCESS_DEFAULT;
+
+ /* get the file object */
+ if(NULL == (obj = (void *)H5I_object(loc_id)))
+ HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "invalid file identifier")
+ /* get the plugin pointer */
+ if (NULL == (vol_plugin = (H5VL_t *)H5I_get_aux(loc_id)))
+ HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "ID does not contain VOL information")
+
/* Get the link info through the VOL */
- if((ret_value = H5VL_link_get(loc_id, H5VL_LINK_GET_VAL, H5_REQUEST_NULL, name, buf,
- size, NULL, H5P_LINK_ACCESS_DEFAULT)) < 0)
+ if((ret_value = H5VL_link_get(obj, loc_params, vol_plugin, H5VL_LINK_GET_VAL,
+ H5_REQUEST_NULL, buf, size)) < 0)
HGOTO_ERROR(H5E_INTERNAL, H5E_CANTGET, FAIL, "unable to get link value")
done:
@@ -547,6 +779,9 @@ done:
herr_t
H5Gset_comment(hid_t loc_id, const char *name, const char *comment)
{
+ void *obj = NULL; /* object token of loc_id */
+ H5VL_t *vol_plugin; /* VOL plugin information */
+ H5VL_loc_params_t loc_params;
herr_t ret_value = SUCCEED; /* Return value */
FUNC_ENTER_API(FAIL)
@@ -555,9 +790,20 @@ H5Gset_comment(hid_t loc_id, const char *name, const char *comment)
if(!name || !*name)
HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "no name specified")
+ loc_params.type = H5VL_OBJECT_BY_NAME;
+ loc_params.loc_data.loc_by_name.name = name;
+ loc_params.loc_data.loc_by_name.plist_id = H5P_LINK_ACCESS_DEFAULT;
+ loc_params.obj_type = H5I_get_type(loc_id);
+
+ /* get the file object */
+ if(NULL == (obj = (void *)H5I_object(loc_id)))
+ HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "invalid file identifier")
+ /* get the plugin pointer */
+ if (NULL == (vol_plugin = (H5VL_t *)H5I_get_aux(loc_id)))
+ HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "ID does not contain VOL information")
+
/* set comment on object through the VOL */
- if(H5VL_object_misc(loc_id, H5VL_OBJECT_SET_COMMENT, H5_REQUEST_NULL,
- name, comment, H5P_LINK_ACCESS_DEFAULT) < 0)
+ if(H5VL_object_misc(obj, loc_params, vol_plugin, H5VL_OBJECT_SET_COMMENT, H5_REQUEST_NULL, comment) < 0)
HGOTO_ERROR(H5E_SYM, H5E_CANTINIT, FAIL, "unable to set comment value")
done:
@@ -591,6 +837,9 @@ done:
int
H5Gget_comment(hid_t loc_id, const char *name, size_t bufsize, char *buf)
{
+ void *obj = NULL; /* object token of loc_id */
+ H5VL_t *vol_plugin; /* VOL plugin information */
+ H5VL_loc_params_t loc_params;
ssize_t size;
int ret_value;
@@ -602,8 +851,20 @@ H5Gget_comment(hid_t loc_id, const char *name, size_t bufsize, char *buf)
if(bufsize > 0 && !buf)
HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "no buffer specified")
- if(H5VL_object_get(loc_id, H5VL_OBJECT_GET_COMMENT, H5_REQUEST_NULL,
- &size, buf, bufsize, name, H5P_LINK_ACCESS_DEFAULT) < 0)
+ loc_params.type = H5VL_OBJECT_BY_NAME;
+ loc_params.loc_data.loc_by_name.name = name;
+ loc_params.loc_data.loc_by_name.plist_id = H5P_LINK_ACCESS_DEFAULT;
+ loc_params.obj_type = H5I_get_type(loc_id);
+
+ /* get the file object */
+ if(NULL == (obj = (void *)H5I_object(loc_id)))
+ HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "invalid file identifier")
+ /* get the plugin pointer */
+ if (NULL == (vol_plugin = (H5VL_t *)H5I_get_aux(loc_id)))
+ HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "ID does not contain VOL information")
+
+ if(H5VL_object_get(obj, loc_params, vol_plugin, H5VL_OBJECT_GET_COMMENT, H5_REQUEST_NULL,
+ buf, bufsize, &size) < 0)
HGOTO_ERROR(H5E_INTERNAL, H5E_CANTGET, FAIL, "unable to get object comment")
ret_value = (int)size;
diff --git a/src/H5Gint.c b/src/H5Gint.c
index 5e220ed..87c0aa8 100644
--- a/src/H5Gint.c
+++ b/src/H5Gint.c
@@ -806,15 +806,13 @@ done:
*-------------------------------------------------------------------------
*/
herr_t
-H5G_iterate(hid_t loc_id, const char *group_name,
+H5G_iterate(H5G_loc_t *loc, const char *group_name,
H5_index_t idx_type, H5_iter_order_t order, hsize_t skip, hsize_t *last_lnk,
const H5G_link_iterate_t *lnk_op, void *op_data, hid_t lapl_id, hid_t dxpl_id)
{
- H5G_loc_t loc; /* Location of parent for group */
hid_t gid = -1; /* ID of group to iterate over */
H5G_t *grp = NULL; /* Pointer to group data structure to iterate over */
H5G_iter_appcall_ud_t udata; /* User data for callback */
- H5VL_class_t *vol_plugin; /* VOL structure attached to id */
herr_t ret_value; /* Return value */
FUNC_ENTER_NOAPI(FAIL)
@@ -828,17 +826,12 @@ H5G_iterate(hid_t loc_id, const char *group_name,
* Open the group on which to operate. We also create a group ID which
* we can pass to the application-defined operator.
*/
- if(H5G_loc(loc_id, &loc) < 0)
- HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a location")
- if(NULL == (grp = H5G__open_name(&loc, group_name, lapl_id, dxpl_id)))
+ if(NULL == (grp = H5G__open_name(loc, group_name, lapl_id, dxpl_id)))
HGOTO_ERROR(H5E_SYM, H5E_CANTOPENOBJ, FAIL, "unable to open group")
if((gid = H5I_register(H5I_GROUP, grp, TRUE)) < 0)
HGOTO_ERROR(H5E_ATOM, H5E_CANTREGISTER, FAIL, "unable to register group")
-
- /* attach VOL information to the ID */
- vol_plugin = H5F_get_vol_cls(loc.oloc->file);
- if (H5I_register_aux(gid, vol_plugin, (H5I_free_t)H5VL_close) < 0)
- HGOTO_ERROR(H5E_VOL, H5E_CANTINIT, FAIL, "can't attach vol info to ID")
+ if(H5VL_native_register_aux(gid) < 0)
+ HGOTO_ERROR(H5E_VOL, H5E_CANTINIT, FAIL, "can't attach native vol info to ID")
/* Set up user data for callback */
udata.gid = gid;
@@ -1078,7 +1071,7 @@ done:
*-------------------------------------------------------------------------
*/
herr_t
-H5G_visit(hid_t loc_id, const char *group_name, H5_index_t idx_type,
+H5G_visit(H5G_loc_t *loc, const char *group_name, H5_index_t idx_type,
H5_iter_order_t order, H5L_iterate_t op, void *op_data, hid_t lapl_id,
hid_t dxpl_id)
{
@@ -1087,10 +1080,8 @@ H5G_visit(hid_t loc_id, const char *group_name, H5_index_t idx_type,
htri_t linfo_exists; /* Whether the link info message exists */
hid_t gid = (-1); /* Group ID */
H5G_t *grp = NULL; /* Group opened */
- H5G_loc_t loc; /* Location of group passed in */
H5G_loc_t start_loc; /* Location of starting group */
unsigned rc; /* Reference count of object */
- H5VL_class_t *vol_plugin; /* VOL structure attached to id */
herr_t ret_value; /* Return value */
/* Portably clear udata struct (before FUNC_ENTER) */
@@ -1098,27 +1089,20 @@ H5G_visit(hid_t loc_id, const char *group_name, H5_index_t idx_type,
FUNC_ENTER_NOAPI(FAIL)
- /* Check args */
- if(H5G_loc(loc_id, &loc) < 0)
- HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a location")
-
/* Open the group to begin visiting within */
- if((grp = H5G__open_name(&loc, group_name, lapl_id, dxpl_id)) == NULL)
+ if((grp = H5G__open_name(loc, group_name, lapl_id, dxpl_id)) == NULL)
HGOTO_ERROR(H5E_SYM, H5E_CANTOPENOBJ, FAIL, "unable to open group")
/* Register an ID for the starting group */
if((gid = H5I_register(H5I_GROUP, grp, TRUE)) < 0)
HGOTO_ERROR(H5E_ATOM, H5E_CANTREGISTER, FAIL, "unable to register group")
+ if(H5VL_native_register_aux(gid) < 0)
+ HGOTO_ERROR(H5E_VOL, H5E_CANTINIT, FAIL, "can't attach native vol info to ID")
/* Get the location of the starting group */
if(H5G_loc(gid, &start_loc) < 0)
HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a location")
- /* attach VOL information to the ID */
- vol_plugin = H5F_get_vol_cls(loc.oloc->file);
- if (H5I_register_aux(gid, vol_plugin, (H5I_free_t)H5VL_close) < 0)
- HGOTO_ERROR(H5E_VOL, H5E_CANTINIT, FAIL, "can't attach vol info to ID")
-
/* Set up user data */
udata.gid = gid;
udata.curr_loc = &start_loc;
diff --git a/src/H5Gprivate.h b/src/H5Gprivate.h
index cacd947..371d096 100644
--- a/src/H5Gprivate.h
+++ b/src/H5Gprivate.h
@@ -218,10 +218,10 @@ H5_DLL char *H5G_normalize(const char *name);
H5_DLL herr_t H5G_traverse(const H5G_loc_t *loc, const char *name,
unsigned target, H5G_traverse_t op, void *op_data, hid_t lapl_id,
hid_t dxpl_id);
-H5_DLL herr_t H5G_iterate(hid_t loc_id, const char *group_name,
+H5_DLL herr_t H5G_iterate(H5G_loc_t *loc, const char *group_name,
H5_index_t idx_type, H5_iter_order_t order, hsize_t skip, hsize_t *last_lnk,
const H5G_link_iterate_t *lnk_op, void *op_data, hid_t lapl_id, hid_t dxpl_id);
-H5_DLL herr_t H5G_visit(hid_t loc_id, const char *group_name,
+H5_DLL herr_t H5G_visit(H5G_loc_t *loc, const char *group_name,
H5_index_t idx_type, H5_iter_order_t order, H5L_iterate_t op, void *op_data,
hid_t lapl_id, hid_t dxpl_id);
diff --git a/src/H5I.c b/src/H5I.c
index 51823f3..e8df636 100644
--- a/src/H5I.c
+++ b/src/H5I.c
@@ -48,6 +48,7 @@
#include "H5Ipkg.h" /* IDs */
#include "H5MMprivate.h" /* Memory management */
#include "H5Oprivate.h" /* Object headers */
+#include "H5Tprivate.h" /* Datatypes */
#include "H5VLprivate.h" /* Virtual Object Layer */
/* Define this to compile in support for dumping ID information */
@@ -95,7 +96,7 @@ typedef struct H5I_id_info_t {
unsigned app_count; /* ref. count of application visible atoms */
const void *obj_ptr; /* pointer associated with the atom */
const void *aux_ptr; /* auxilary pointer associated with the atom */
- H5I_free_t free_aux; /*release auxilary structure method */
+ H5I_free2_t free_aux; /*release auxilary structure method */
struct H5I_id_info_t *next; /* link to next atom (in case of hash-clash)*/
} H5I_id_info_t;
@@ -136,6 +137,7 @@ H5FL_DEFINE_STATIC(H5I_id_info_t);
/*--------------------- Local function prototypes ---------------------------*/
static H5I_id_info_t *H5I_find_id(hid_t id);
static int H5I_search_cb(void *obj, hid_t id, void *udata);
+static hid_t H5VL_get_id(void *object, H5I_type_t type);
#ifdef H5I_DEBUG_OUTPUT
static herr_t H5I_debug(H5I_type_t type);
#endif /* H5I_DEBUG_OUTPUT */
@@ -588,7 +590,9 @@ H5I_clear_type(H5I_type_t type, hbool_t force, hbool_t app_ref)
/* Check for a 'free' function and call it, if it exists */
/* (Casting away const OK -QAK) */
- if(type_ptr->free_func && (type_ptr->free_func)((void *)cur->obj_ptr) < 0) {
+ if((cur->free_aux && (cur->free_aux)((void *)cur->obj_ptr, (void *)cur->aux_ptr) < 0) ||
+ (type_ptr->free_func && (type_ptr->free_func)((void *)cur->obj_ptr) < 0)) {
+ //if(type_ptr->free_func && (type_ptr->free_func)((void *)cur->obj_ptr) < 0) {
if(force) {
#ifdef H5I_DEBUG
if(H5DEBUG(I)) {
@@ -960,7 +964,6 @@ H5I_object(hid_t id)
/* (Casting away const OK -QAK) */
ret_value = (void *)id_ptr->obj_ptr;
} /* end if */
-
done:
FUNC_LEAVE_NOAPI(ret_value)
} /* end if */
@@ -1342,8 +1345,8 @@ H5I_dec_ref(hid_t id)
*/
if(1 == id_ptr->count) {
/* (Casting away const OK -QAK) */
- if((!type_ptr->free_func || (type_ptr->free_func)((void *)id_ptr->obj_ptr) >= 0) &&
- (!id_ptr->free_aux || (id_ptr->free_aux)((void *)id_ptr->aux_ptr) >= 0)) {
+ if((!id_ptr->free_aux || (id_ptr->free_aux)((void *)id_ptr->obj_ptr, (void *)id_ptr->aux_ptr) >= 0) &&
+ (!type_ptr->free_func || (type_ptr->free_func)((void *)id_ptr->obj_ptr) >= 0)) {
H5I_remove(id);
ret_value = 0;
} /* end if */
@@ -2241,15 +2244,13 @@ hid_t
H5I_get_file_id(hid_t obj_id, hbool_t app_ref)
{
H5I_type_t type; /* ID type */
- H5I_type_t id_type;
- hid_t ret_value; /* Return value */
+ hid_t ret_value = FAIL; /* Return value */
FUNC_ENTER_NOAPI_NOINIT
- id_type = H5I_get_type(obj_id);
-
/* Get object type */
type = H5I_TYPE(obj_id);
+#if 0
if(H5I_FILE == type) {
/* Increment reference count on file ID */
if(H5I_inc_ref(obj_id, app_ref) < 0)
@@ -2258,17 +2259,45 @@ H5I_get_file_id(hid_t obj_id, hbool_t app_ref)
/* Set return value */
ret_value = obj_id;
} /* end if */
- else if(type == H5I_DATATYPE || type == H5I_GROUP ||
- type == H5I_DATASET || type == H5I_ATTR) {
- H5G_loc_t loc; /* Location of object */
-
- /* Get the object location information */
- if(H5G_loc(obj_id, &loc) < 0)
- HGOTO_ERROR(H5E_ATOM, H5E_CANTGET, FAIL, "can't get object location")
-
- /* Get the file ID for the object */
- if((ret_value = H5F_get_id(loc.oloc->file, app_ref)) < 0)
- HGOTO_ERROR(H5E_ATOM, H5E_CANTGET, FAIL, "can't get file ID")
+ else
+#endif
+ if(H5I_FILE == type || H5I_DATATYPE == type || H5I_GROUP == type ||
+ H5I_DATASET == type || H5I_ATTR == type) {
+ H5VL_t *vol_plugin;
+ void *obj;
+ void *file = NULL;
+
+ /* get the file object */
+ if(NULL == (obj = (void *)H5I_object(obj_id)))
+ HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "invalid file identifier")
+
+ /* get the plugin pointer */
+ if (NULL == (vol_plugin = (H5VL_t *)H5I_get_aux(obj_id)))
+ HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "ID does not contain VOL information")
+
+ /* Get the file through the VOL */
+ if(H5VL_file_get(obj, vol_plugin, H5VL_OBJECT_GET_FILE, H5_REQUEST_NULL,
+ type, app_ref, &file) < 0)
+ HGOTO_ERROR(H5E_INTERNAL, H5E_CANTINIT, FAIL, "unable to get file")
+
+ if (NULL == file)
+ HGOTO_ERROR(H5E_FILE, H5E_CANTINIT, FAIL, "unable to reopen file")
+
+ if (FAIL == (ret_value = H5VL_get_id(file, H5I_FILE))) {
+ /* Get an atom for the dataset */
+ if((ret_value = H5I_register(H5I_FILE, file, TRUE)) < 0)
+ HGOTO_ERROR(H5E_ATOM, H5E_CANTREGISTER, FAIL, "unable to atomize file handle")
+
+ /* attach VOL information to the ID */
+ if (H5I_register_aux(ret_value, vol_plugin, (H5I_free2_t)H5F_close_file) < 0)
+ HGOTO_ERROR(H5E_VOL, H5E_CANTINIT, FAIL, "can't attach vol info to ID")
+
+ vol_plugin->nrefs ++;
+ }
+ else {
+ if(H5I_inc_ref(ret_value, app_ref) < 0)
+ HGOTO_ERROR(H5E_ATOM, H5E_CANTSET, FAIL, "incrementing file ID failed")
+ }
} /* end if */
else
HGOTO_ERROR(H5E_ARGS, H5E_BADRANGE, FAIL, "invalid object ID")
@@ -2292,7 +2321,7 @@ done:
*-------------------------------------------------------------------------
*/
herr_t
-H5I_register_aux(hid_t id, void *aux_ptr, H5I_free_t free_func)
+H5I_register_aux(hid_t id, void *aux_ptr, H5I_free2_t free_func)
{
H5I_id_info_t *id_ptr = NULL; /*ptr to the new atom */
herr_t ret_value = SUCCEED; /*return value */
@@ -2305,7 +2334,6 @@ H5I_register_aux(hid_t id, void *aux_ptr, H5I_free_t free_func)
id_ptr->aux_ptr = aux_ptr;
id_ptr->free_aux = free_func;
-
done:
FUNC_LEAVE_NOAPI(ret_value)
} /* end H5I_register_aux() */
@@ -2343,6 +2371,54 @@ done:
/*-------------------------------------------------------------------------
+ * Function: H5VL_get_id
+ *
+ * Purpose: return ID of vol object
+ *
+ * Return: Success: id of object
+ * Failure: FAIL
+ *
+ * Programmer: Mohamad Chaarawi
+ * June 2012
+ *
+ *-------------------------------------------------------------------------
+ */
+static hid_t
+H5VL_get_id(void *object, H5I_type_t type)
+{
+ hid_t ret_value = FAIL; /* Return value */
+ H5I_id_type_t *type_ptr; /*ptr to the type */
+
+ FUNC_ENTER_NOAPI(FAIL)
+
+ type_ptr = H5I_id_type_list_g[type];
+
+ if(type_ptr == NULL || type_ptr->count <= 0)
+ HGOTO_ERROR(H5E_ATOM, H5E_BADGROUP, FAIL, "invalid type")
+
+ /* Only iterate through hash table if there are IDs in group */
+ if(type_ptr->ids > 0) {
+ H5I_id_info_t *id_ptr; /*ptr to the new ID */
+ unsigned i; /*counter */
+
+ /* Start at the beginning of the array */
+ for(i = 0; i < type_ptr->hash_size; i++) {
+ id_ptr = type_ptr->id_list[i];
+ while(id_ptr) {
+ if (id_ptr->obj_ptr == object) {
+ HGOTO_DONE(id_ptr->id);
+ }
+ id_ptr = id_ptr->next;
+ } /* end while */
+ } /* end for */
+ } /* end if */
+
+done:
+ FUNC_LEAVE_NOAPI(ret_value)
+} /* end H5VL_get_id() */
+
+
+/*-------------------------------------------------------------------------
* Function: H5I_debug
*
* Purpose: Dump the contents of a type to stderr for debugging.
diff --git a/src/H5Iprivate.h b/src/H5Iprivate.h
index faa91f9..e15ea9c 100644
--- a/src/H5Iprivate.h
+++ b/src/H5Iprivate.h
@@ -74,7 +74,7 @@ H5_DLL int H5I_dec_app_ref_always_close(hid_t id);
H5_DLL int H5I_inc_type_ref(H5I_type_t type);
H5_DLL herr_t H5I_dec_type_ref(H5I_type_t type);
H5_DLL int H5I_get_type_ref(H5I_type_t type);
-H5_DLL herr_t H5I_register_aux(hid_t id, void *aux_ptr, H5I_free_t free_func);
+H5_DLL herr_t H5I_register_aux(hid_t id, void *aux_ptr, H5I_free2_t free_func);
H5_DLL void *H5I_get_aux(hid_t id);
#endif /* _H5Iprivate_H */
diff --git a/src/H5Ipublic.h b/src/H5Ipublic.h
index a1b483d..cded866 100644
--- a/src/H5Ipublic.h
+++ b/src/H5Ipublic.h
@@ -36,7 +36,8 @@
typedef enum H5I_type_t {
H5I_UNINIT = (-2), /*uninitialized type */
H5I_BADID = (-1), /*invalid Type */
- H5I_FILE = 1, /*type ID for File objects */
+ H5I_FILE_PRIVATE = 1, /*type ID for File objects */
+ H5I_FILE, /*type ID for File objects */
H5I_GROUP, /*type ID for Group objects */
H5I_DATATYPE, /*type ID for Datatype objects */
H5I_DATASPACE, /*type ID for Dataspace objects */
@@ -68,6 +69,7 @@ typedef int hid_t;
* (failure) then the object will remain in the ID type.
*/
typedef herr_t (*H5I_free_t)(void*);
+typedef herr_t (*H5I_free2_t)(void*,void*);
/* Type of the function to compare objects & keys */
typedef int (*H5I_search_func_t)(void *obj, hid_t id, void *key);
diff --git a/src/H5L.c b/src/H5L.c
index ec88fd5..47e49af 100644
--- a/src/H5L.c
+++ b/src/H5L.c
@@ -36,6 +36,7 @@
#include "H5MMprivate.h" /* Memory management */
#include "H5Oprivate.h" /* File objects */
#include "H5Pprivate.h" /* Property lists */
+#include "H5VLnative.h" /* Native Plugin */
#include "H5VLprivate.h" /* Virtual Object Layer */
/****************/
@@ -55,18 +56,6 @@ typedef struct {
hid_t dxpl_id; /* DXPL to use in callback */
} H5L_trav_gi_t;
-/* User data for path traversal routine for getting link info by index */
-typedef struct {
- /* In */
- H5_index_t idx_type; /* Index to use */
- H5_iter_order_t order; /* Order to iterate in index */
- hsize_t n; /* Offset of link within index */
- hid_t dxpl_id; /* DXPL to use in callback */
-
- /* Out */
- H5L_info_t *linfo; /* Buffer to return to user */
-} H5L_trav_gibi_t;
-
/* User data for path traversal callback to creating a link */
typedef struct {
H5F_t *file; /* Pointer to the file */
@@ -102,47 +91,11 @@ typedef struct {
void *buf; /* User buffer */
} H5L_trav_gv_t;
-/* User data for path traversal routine for getting link value by index */
-typedef struct {
- /* In */
- H5_index_t idx_type; /* Index to use */
- H5_iter_order_t order; /* Order to iterate in index */
- hsize_t n; /* Offset of link within index */
- hid_t dxpl_id; /* DXPL to use in callback */
- size_t size; /* Size of user buffer */
-
- /* Out */
- void *buf; /* User buffer */
-} H5L_trav_gvbi_t;
-
/* User data for path traversal routine for removing link */
typedef struct {
hid_t dxpl_id; /* DXPL to use in callback */
} H5L_trav_rm_t;
-/* User data for path traversal routine for removing link by index */
-typedef struct {
- /* In */
- H5_index_t idx_type; /* Index to use */
- H5_iter_order_t order; /* Order to iterate in index */
- hsize_t n; /* Offset of link within index */
- hid_t dxpl_id; /* DXPL to use in callback */
-} H5L_trav_rmbi_t;
-
-/* User data for path traversal routine for getting name by index */
-typedef struct {
- /* In */
- H5_index_t idx_type; /* Index to use */
- H5_iter_order_t order; /* Order to iterate in index */
- hsize_t n; /* Offset of link within index */
- size_t size; /* Size of name buffer */
- hid_t dxpl_id; /* DXPL to use in callback */
-
- /* Out */
- char *name; /* Buffer to return name to user */
- ssize_t name_len; /* Length of full name */
-} H5L_trav_gnbi_t;
-
/********************/
/* Local Prototypes */
/********************/
@@ -312,6 +265,12 @@ herr_t
H5Lmove(hid_t src_loc_id, const char *src_name, hid_t dst_loc_id,
const char *dst_name, hid_t lcpl_id, hid_t lapl_id)
{
+ void *obj1 = NULL; /* object token of src_id */
+ H5VL_t *vol_plugin1; /* VOL plugin information */
+ H5VL_loc_params_t loc_params1;
+ void *obj2 = NULL; /* object token of dst_id */
+ H5VL_t *vol_plugin2; /* VOL plugin information */
+ H5VL_loc_params_t loc_params2;
herr_t ret_value=SUCCEED; /* Return value */
FUNC_ENTER_API(FAIL)
@@ -328,8 +287,42 @@ H5Lmove(hid_t src_loc_id, const char *src_name, hid_t dst_loc_id,
if(lcpl_id != H5P_DEFAULT && (TRUE != H5P_isa_class(lcpl_id, H5P_LINK_CREATE)))
HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a link creation property list")
- /* Create the link through the VOL */
- if((ret_value = H5VL_link_move(src_loc_id, src_name, dst_loc_id, dst_name,
+ /* set location paramter for source object */
+ loc_params1.type = H5VL_OBJECT_BY_NAME;
+ loc_params1.loc_data.loc_by_name.name = src_name;
+ loc_params1.loc_data.loc_by_name.plist_id = lapl_id;
+ loc_params1.obj_type = H5I_get_type(src_loc_id);
+ /* set location paramter for destination object */
+ loc_params2.type = H5VL_OBJECT_BY_NAME;
+ loc_params2.loc_data.loc_by_name.name = dst_name;
+ loc_params2.loc_data.loc_by_name.plist_id = lapl_id;
+ loc_params2.obj_type = H5I_get_type(dst_loc_id);
+
+ if(H5L_SAME_LOC != src_loc_id) {
+ /* get the file object */
+ if(NULL == (obj1 = (void *)H5I_object(src_loc_id)))
+ HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "invalid file identifier")
+ /* get the plugin pointer */
+ if (NULL == (vol_plugin1 = (H5VL_t *)H5I_get_aux(src_loc_id)))
+ HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "ID does not contain VOL information")
+ }
+ if(H5L_SAME_LOC != dst_loc_id) {
+ /* get the file object */
+ if(NULL == (obj2 = (void *)H5I_object(dst_loc_id)))
+ HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "invalid file identifier")
+ /* get the plugin pointer */
+ if (NULL == (vol_plugin2 = (H5VL_t *)H5I_get_aux(dst_loc_id)))
+ HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "ID does not contain VOL information")
+ }
+ /* Make sure that the VOL plugins are the same */
+ if(H5L_SAME_LOC != dst_loc_id && H5L_SAME_LOC != src_loc_id) {
+ if (vol_plugin1 != vol_plugin2)
+ HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "Objects are accessed through different VOL plugins and can't be linked")
+ }
+
+ /* Move the link through the VOL */
+ if((ret_value = H5VL_link_move(obj1, loc_params1, obj2, loc_params2,
+ (vol_plugin1!=NULL ? vol_plugin1 : vol_plugin2),
FALSE, lcpl_id, lapl_id, H5_REQUEST_NULL)) < 0)
HGOTO_ERROR(H5E_SYM, H5E_CANTINIT, FAIL, "unable to create link")
@@ -356,6 +349,12 @@ herr_t
H5Lcopy(hid_t src_loc_id, const char *src_name, hid_t dst_loc_id,
const char *dst_name, hid_t lcpl_id, hid_t lapl_id)
{
+ void *obj1 = NULL; /* object token of src_id */
+ H5VL_t *vol_plugin1; /* VOL plugin information */
+ H5VL_loc_params_t loc_params1;
+ void *obj2 = NULL; /* object token of dst_id */
+ H5VL_t *vol_plugin2; /* VOL plugin information */
+ H5VL_loc_params_t loc_params2;
herr_t ret_value=SUCCEED; /* Return value */
FUNC_ENTER_API(FAIL)
@@ -372,11 +371,44 @@ H5Lcopy(hid_t src_loc_id, const char *src_name, hid_t dst_loc_id,
if(lcpl_id != H5P_DEFAULT && (TRUE != H5P_isa_class(lcpl_id, H5P_LINK_CREATE)))
HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a link creation property list")
- /* Create the link through the VOL */
- if((ret_value = H5VL_link_move(src_loc_id, src_name, dst_loc_id, dst_name,
+ /* set location paramter for source object */
+ loc_params1.type = H5VL_OBJECT_BY_NAME;
+ loc_params1.loc_data.loc_by_name.name = src_name;
+ loc_params1.loc_data.loc_by_name.plist_id = lapl_id;
+ loc_params1.obj_type = H5I_get_type(src_loc_id);
+ /* set location paramter for destination object */
+ loc_params2.type = H5VL_OBJECT_BY_NAME;
+ loc_params2.loc_data.loc_by_name.name = dst_name;
+ loc_params2.loc_data.loc_by_name.plist_id = lapl_id;
+ loc_params2.obj_type = H5I_get_type(dst_loc_id);
+
+ if(H5L_SAME_LOC != src_loc_id) {
+ /* get the file object */
+ if(NULL == (obj1 = (void *)H5I_object(src_loc_id)))
+ HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "invalid file identifier")
+ /* get the plugin pointer */
+ if (NULL == (vol_plugin1 = (H5VL_t *)H5I_get_aux(src_loc_id)))
+ HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "ID does not contain VOL information")
+ }
+ if(H5L_SAME_LOC != dst_loc_id) {
+ /* get the file object */
+ if(NULL == (obj2 = (void *)H5I_object(dst_loc_id)))
+ HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "invalid file identifier")
+ /* get the plugin pointer */
+ if (NULL == (vol_plugin2 = (H5VL_t *)H5I_get_aux(dst_loc_id)))
+ HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "ID does not contain VOL information")
+ }
+ /* Make sure that the VOL plugins are the same */
+ if(H5L_SAME_LOC != dst_loc_id && H5L_SAME_LOC != src_loc_id) {
+ if (vol_plugin1 != vol_plugin2)
+ HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "Objects are accessed through different VOL plugins and can't be linked")
+ }
+
+ /* Move the link through the VOL */
+ if((ret_value = H5VL_link_move(obj1, loc_params1, obj2, loc_params2,
+ (vol_plugin1!=NULL ? vol_plugin1 : vol_plugin2),
TRUE, lcpl_id, lapl_id, H5_REQUEST_NULL)) < 0)
HGOTO_ERROR(H5E_SYM, H5E_CANTINIT, FAIL, "unable to create link")
-
done:
FUNC_LEAVE_API(ret_value)
} /* end H5Lcopy() */
@@ -404,6 +436,9 @@ herr_t
H5Lcreate_soft(const char *link_target,
hid_t link_loc_id, const char *link_name, hid_t lcpl_id, hid_t lapl_id)
{
+ void *obj = NULL; /* object token of loc_id */
+ H5VL_t *vol_plugin; /* VOL plugin information */
+ H5VL_loc_params_t loc_params;
H5P_genplist_t *plist; /* Property list pointer */
herr_t ret_value = SUCCEED; /* Return value */
@@ -424,6 +459,18 @@ H5Lcreate_soft(const char *link_target,
if(H5P_DEFAULT == lcpl_id)
lcpl_id = H5P_LINK_CREATE_DEFAULT;
+ loc_params.type = H5VL_OBJECT_BY_NAME;
+ loc_params.loc_data.loc_by_name.name = link_name;
+ loc_params.loc_data.loc_by_name.plist_id = lapl_id;
+ loc_params.obj_type = H5I_get_type(link_loc_id);
+
+ /* get the file object */
+ if(NULL == (obj = (void *)H5I_object(link_loc_id)))
+ HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "invalid file identifier")
+ /* get the plugin pointer */
+ if (NULL == (vol_plugin = (H5VL_t *)H5I_get_aux(link_loc_id)))
+ HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "ID does not contain VOL information")
+
/* Get the plist structure */
if(NULL == (plist = (H5P_genplist_t *)H5I_object(lcpl_id)))
HGOTO_ERROR(H5E_ATOM, H5E_BADATOM, FAIL, "can't find object for ID")
@@ -433,7 +480,7 @@ H5Lcreate_soft(const char *link_target,
HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, FAIL, "can't get property value for target name")
/* Create the link through the VOL */
- if((ret_value = H5VL_link_create(H5VL_LINK_CREATE_SOFT, link_loc_id, link_name,
+ if((ret_value = H5VL_link_create(H5VL_LINK_CREATE_SOFT, obj, loc_params, vol_plugin,
lcpl_id, lapl_id, H5_REQUEST_NULL)) < 0)
HGOTO_ERROR(H5E_SYM, H5E_CANTINIT, FAIL, "unable to create link")
@@ -462,8 +509,14 @@ herr_t
H5Lcreate_hard(hid_t cur_loc_id, const char *cur_name,
hid_t new_loc_id, const char *new_name, hid_t lcpl_id, hid_t lapl_id)
{
+ void *obj1 = NULL; /* object token of loc_id */
+ void *obj2 = NULL; /* object token of loc_id */
+ H5VL_t *vol_plugin1 = NULL; /* VOL plugin information */
+ H5VL_t *vol_plugin2 = NULL; /* VOL plugin information */
+ H5VL_loc_params_t loc_params1;
+ H5VL_loc_params_t loc_params2;
H5P_genplist_t *plist; /* Property list pointer */
- herr_t ret_value = SUCCEED; /* Return value */
+ herr_t ret_value = SUCCEED; /* Return value */
FUNC_ENTER_API(FAIL)
H5TRACE6("e", "i*si*sii", cur_loc_id, cur_name, new_loc_id, new_name, lcpl_id,
@@ -483,18 +536,51 @@ H5Lcreate_hard(hid_t cur_loc_id, const char *cur_name,
if(H5P_DEFAULT == lcpl_id)
lcpl_id = H5P_LINK_CREATE_DEFAULT;
+ loc_params1.type = H5VL_OBJECT_BY_NAME;
+ loc_params1.obj_type = H5I_get_type(cur_loc_id);
+ loc_params1.loc_data.loc_by_name.name = cur_name;
+ loc_params1.loc_data.loc_by_name.plist_id = lapl_id;
+
+ loc_params2.type = H5VL_OBJECT_BY_NAME;
+ loc_params2.obj_type = H5I_get_type(new_loc_id);
+ loc_params2.loc_data.loc_by_name.name = new_name;
+ loc_params2.loc_data.loc_by_name.plist_id = lapl_id;
+
+ if(H5L_SAME_LOC != cur_loc_id) {
+ /* get the file object */
+ if(NULL == (obj1 = (void *)H5I_object(cur_loc_id)))
+ HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "invalid file identifier")
+ /* get the plugin pointer */
+ if (NULL == (vol_plugin1 = (H5VL_t *)H5I_get_aux(cur_loc_id)))
+ HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "ID does not contain VOL information")
+ }
+ if(H5L_SAME_LOC != new_loc_id) {
+ /* get the file object */
+ if(NULL == (obj2 = (void *)H5I_object(new_loc_id)))
+ HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "invalid file identifier")
+ /* get the plugin pointer */
+ if (NULL == (vol_plugin2 = (H5VL_t *)H5I_get_aux(new_loc_id)))
+ HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "ID does not contain VOL information")
+ }
+ /* Make sure that the VOL plugins are the same */
+ if(H5L_SAME_LOC != new_loc_id && H5L_SAME_LOC != cur_loc_id) {
+ if (vol_plugin1 != vol_plugin2)
+ HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "Objects are accessed through different VOL plugins and can't be linked")
+ }
+
/* Get the plist structure */
if(NULL == (plist = (H5P_genplist_t *)H5I_object(lcpl_id)))
HGOTO_ERROR(H5E_ATOM, H5E_BADATOM, FAIL, "can't find object for ID")
/* set creation properties */
- if(H5P_set(plist, H5VL_LINK_TARGET_ID, &cur_loc_id) < 0)
+ if(H5P_set(plist, H5VL_LINK_TARGET, &obj1) < 0)
HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, FAIL, "can't set property value for target id")
- if(H5P_set(plist, H5VL_LINK_TARGET_NAME, &cur_name) < 0)
+ if(H5P_set(plist, H5VL_LINK_TARGET_LOC_PARAMS, &loc_params1) < 0)
HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, FAIL, "can't set property value for target name")
/* Create the link through the VOL */
- if((ret_value = H5VL_link_create(H5VL_LINK_CREATE_HARD, new_loc_id, new_name,
+ if((ret_value = H5VL_link_create(H5VL_LINK_CREATE_HARD, obj2, loc_params2,
+ (vol_plugin1!=NULL ? vol_plugin1 : vol_plugin2),
lcpl_id, lapl_id, H5_REQUEST_NULL)) < 0)
HGOTO_ERROR(H5E_SYM, H5E_CANTINIT, FAIL, "unable to create link")
@@ -531,6 +617,9 @@ herr_t
H5Lcreate_ud(hid_t link_loc_id, const char *link_name, H5L_type_t link_type,
const void *udata, size_t udata_size, hid_t lcpl_id, hid_t lapl_id)
{
+ void *obj = NULL; /* object token of loc_id */
+ H5VL_t *vol_plugin; /* VOL plugin information */
+ H5VL_loc_params_t loc_params;
H5P_genplist_t *plist; /* Property list pointer */
herr_t ret_value = SUCCEED; /* Return value */
@@ -548,6 +637,18 @@ H5Lcreate_ud(hid_t link_loc_id, const char *link_name, H5L_type_t link_type,
if(H5P_DEFAULT == lcpl_id)
lcpl_id = H5P_LINK_CREATE_DEFAULT;
+ loc_params.type = H5VL_OBJECT_BY_NAME;
+ loc_params.loc_data.loc_by_name.name = link_name;
+ loc_params.loc_data.loc_by_name.plist_id = lapl_id;
+ loc_params.obj_type = H5I_get_type(link_loc_id);
+
+ /* get the file object */
+ if(NULL == (obj = (void *)H5I_object(link_loc_id)))
+ HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "invalid file identifier")
+ /* get the plugin pointer */
+ if (NULL == (vol_plugin = (H5VL_t *)H5I_get_aux(link_loc_id)))
+ HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "ID does not contain VOL information")
+
/* Get the plist structure */
if(NULL == (plist = (H5P_genplist_t *)H5I_object(lcpl_id)))
HGOTO_ERROR(H5E_ATOM, H5E_BADATOM, FAIL, "can't find object for ID")
@@ -561,7 +662,7 @@ H5Lcreate_ud(hid_t link_loc_id, const char *link_name, H5L_type_t link_type,
HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, FAIL, "can't get property value from plist")
/* Create the link through the VOL */
- if((ret_value = H5VL_link_create(H5VL_LINK_CREATE_UD, link_loc_id, link_name,
+ if((ret_value = H5VL_link_create(H5VL_LINK_CREATE_UD, obj, loc_params, vol_plugin,
lcpl_id, lapl_id, H5_REQUEST_NULL)) < 0)
HGOTO_ERROR(H5E_SYM, H5E_CANTINIT, FAIL, "unable to create link")
@@ -590,6 +691,9 @@ done:
herr_t
H5Ldelete(hid_t loc_id, const char *name, hid_t lapl_id)
{
+ void *obj = NULL; /* object token of loc_id */
+ H5VL_t *vol_plugin; /* VOL plugin information */
+ H5VL_loc_params_t loc_params;
herr_t ret_value = SUCCEED; /* Return value */
FUNC_ENTER_API(FAIL)
@@ -599,8 +703,20 @@ H5Ldelete(hid_t loc_id, const char *name, hid_t lapl_id)
if(!name || !*name)
HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "no name")
+ loc_params.type = H5VL_OBJECT_BY_NAME;
+ loc_params.obj_type = H5I_get_type(loc_id);
+ loc_params.loc_data.loc_by_name.name = name;
+ loc_params.loc_data.loc_by_name.plist_id = lapl_id;
+
+ /* get the file object */
+ if(NULL == (obj = (void *)H5I_object(loc_id)))
+ HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "invalid file identifier")
+ /* get the plugin pointer */
+ if (NULL == (vol_plugin = (H5VL_t *)H5I_get_aux(loc_id)))
+ HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "ID does not contain VOL information")
+
/* Delete the link through the VOL */
- if((ret_value = H5VL_link_remove(loc_id, name, NULL, lapl_id, H5_REQUEST_NULL)) < 0)
+ if((ret_value = H5VL_link_remove(obj, loc_params, vol_plugin, H5_REQUEST_NULL)) < 0)
HGOTO_ERROR(H5E_SYM, H5E_CANTINIT, FAIL, "unable to create link")
done:
@@ -631,7 +747,9 @@ herr_t
H5Ldelete_by_idx(hid_t loc_id, const char *group_name,
H5_index_t idx_type, H5_iter_order_t order, hsize_t n, hid_t lapl_id)
{
- H5L_trav_rmbi_t udata; /* User data for callback */
+ void *obj = NULL; /* object token of loc_id */
+ H5VL_t *vol_plugin; /* VOL plugin information */
+ H5VL_loc_params_t loc_params;
herr_t ret_value = SUCCEED; /* Return value */
FUNC_ENTER_API(FAIL)
@@ -650,14 +768,23 @@ H5Ldelete_by_idx(hid_t loc_id, const char *group_name,
if(TRUE != H5P_isa_class(lapl_id, H5P_LINK_ACCESS))
HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not link access property list ID")
- /* Set up user data for unlink operation */
- udata.idx_type = idx_type;
- udata.order = order;
- udata.n = n;
- udata.dxpl_id = H5AC_dxpl_id;
+ loc_params.type = H5VL_OBJECT_BY_IDX;
+ loc_params.loc_data.loc_by_idx.name = group_name;
+ loc_params.loc_data.loc_by_idx.idx_type = idx_type;
+ loc_params.loc_data.loc_by_idx.order = order;
+ loc_params.loc_data.loc_by_idx.n = n;
+ loc_params.loc_data.loc_by_idx.plist_id = lapl_id;
+ loc_params.obj_type = H5I_get_type(loc_id);
+
+ /* get the file object */
+ if(NULL == (obj = (void *)H5I_object(loc_id)))
+ HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "invalid file identifier")
+ /* get the plugin pointer */
+ if (NULL == (vol_plugin = (H5VL_t *)H5I_get_aux(loc_id)))
+ HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "ID does not contain VOL information")
/* Delete the link through the VOL */
- if((ret_value = H5VL_link_remove(loc_id, group_name, &udata, lapl_id, H5_REQUEST_NULL)) < 0)
+ if((ret_value = H5VL_link_remove(obj, loc_params, vol_plugin, H5_REQUEST_NULL)) < 0)
HGOTO_ERROR(H5E_SYM, H5E_CANTINIT, FAIL, "unable to create link")
done:
@@ -688,6 +815,9 @@ herr_t
H5Lget_val(hid_t loc_id, const char *name, void *buf/*out*/, size_t size,
hid_t lapl_id)
{
+ void *obj = NULL; /* object token of loc_id */
+ H5VL_t *vol_plugin; /* VOL plugin information */
+ H5VL_loc_params_t loc_params;
herr_t ret_value = SUCCEED; /* Return value */
FUNC_ENTER_API(FAIL)
@@ -702,9 +832,21 @@ H5Lget_val(hid_t loc_id, const char *name, void *buf/*out*/, size_t size,
if(TRUE != H5P_isa_class(lapl_id, H5P_LINK_ACCESS))
HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not link access property list ID")
+ loc_params.type = H5VL_OBJECT_BY_NAME;
+ loc_params.obj_type = H5I_get_type(loc_id);
+ loc_params.loc_data.loc_by_name.name = name;
+ loc_params.loc_data.loc_by_name.plist_id = lapl_id;
+
+ /* get the file object */
+ if(NULL == (obj = (void *)H5I_object(loc_id)))
+ HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "invalid file identifier")
+ /* get the plugin pointer */
+ if (NULL == (vol_plugin = (H5VL_t *)H5I_get_aux(loc_id)))
+ HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "ID does not contain VOL information")
+
/* Get the link info through the VOL */
- if((ret_value = H5VL_link_get(loc_id, H5VL_LINK_GET_VAL, H5_REQUEST_NULL, name, buf,
- size, NULL, lapl_id)) < 0)
+ if((ret_value = H5VL_link_get(obj, loc_params, vol_plugin, H5VL_LINK_GET_VAL,
+ H5_REQUEST_NULL, buf, size)) < 0)
HGOTO_ERROR(H5E_INTERNAL, H5E_CANTGET, FAIL, "unable to get link value")
done:
@@ -735,7 +877,9 @@ H5Lget_val_by_idx(hid_t loc_id, const char *group_name, H5_index_t idx_type,
H5_iter_order_t order, hsize_t n, void *buf/*out*/, size_t size,
hid_t lapl_id)
{
- H5L_trav_gvbi_t udata; /* User data for callback */
+ void *obj = NULL; /* object token of loc_id */
+ H5VL_t *vol_plugin; /* VOL plugin information */
+ H5VL_loc_params_t loc_params;
herr_t ret_value = SUCCEED; /* Return value */
FUNC_ENTER_API(FAIL)
@@ -755,17 +899,25 @@ H5Lget_val_by_idx(hid_t loc_id, const char *group_name, H5_index_t idx_type,
if(TRUE != H5P_isa_class(lapl_id, H5P_LINK_ACCESS))
HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not link access property list ID")
- /* Set up user data for retrieving information */
- udata.idx_type = idx_type;
- udata.order = order;
- udata.n = n;
- udata.dxpl_id = H5AC_ind_dxpl_id;
- udata.buf = buf;
- udata.size = size;
+ loc_params.type = H5VL_OBJECT_BY_IDX;
+ loc_params.loc_data.loc_by_idx.name = group_name;
+ loc_params.loc_data.loc_by_idx.idx_type = idx_type;
+ loc_params.loc_data.loc_by_idx.order = order;
+ loc_params.loc_data.loc_by_idx.n = n;
+ loc_params.loc_data.loc_by_idx.plist_id = lapl_id;
+ loc_params.obj_type = H5I_get_type(loc_id);
+
+ /* get the file object */
+ if(NULL == (obj = (void *)H5I_object(loc_id)))
+ HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "invalid file identifier")
+ /* get the plugin pointer */
+ if (NULL == (vol_plugin = (H5VL_t *)H5I_get_aux(loc_id)))
+ HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "ID does not contain VOL information")
/* Get the link info through the VOL */
- if((ret_value = H5VL_link_get(loc_id, H5VL_LINK_GET_VAL, H5_REQUEST_NULL, group_name, buf, size, &udata, lapl_id)) < 0)
- HGOTO_ERROR(H5E_INTERNAL, H5E_CANTGET, FAIL, "unable to get link val")
+ if((ret_value = H5VL_link_get(obj, loc_params, vol_plugin, H5VL_LINK_GET_VAL,
+ H5_REQUEST_NULL, buf, size)) < 0)
+ HGOTO_ERROR(H5E_INTERNAL, H5E_CANTGET, FAIL, "unable to get link value")
done:
FUNC_LEAVE_API(ret_value)
@@ -788,6 +940,9 @@ done:
htri_t
H5Lexists(hid_t loc_id, const char *name, hid_t lapl_id)
{
+ void *obj = NULL; /* object token of loc_id */
+ H5VL_t *vol_plugin; /* VOL plugin information */
+ H5VL_loc_params_t loc_params;
htri_t ret_value;
FUNC_ENTER_API(FAIL)
@@ -802,8 +957,20 @@ H5Lexists(hid_t loc_id, const char *name, hid_t lapl_id)
if(TRUE != H5P_isa_class(lapl_id, H5P_LINK_ACCESS))
HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not link access property list ID")
+ loc_params.type = H5VL_OBJECT_BY_NAME;
+ loc_params.obj_type = H5I_get_type(loc_id);
+ loc_params.loc_data.loc_by_name.name = name;
+ loc_params.loc_data.loc_by_name.plist_id = lapl_id;
+
+ /* get the file object */
+ if(NULL == (obj = (void *)H5I_object(loc_id)))
+ HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "invalid file identifier")
+ /* get the plugin pointer */
+ if (NULL == (vol_plugin = (H5VL_t *)H5I_get_aux(loc_id)))
+ HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "ID does not contain VOL information")
+
/* check link existence through the VOL */
- if(H5VL_link_get(loc_id, H5VL_LINK_EXISTS, H5_REQUEST_NULL, name, &ret_value, lapl_id) < 0)
+ if(H5VL_link_get(obj, loc_params, vol_plugin, H5VL_LINK_EXISTS, H5_REQUEST_NULL, &ret_value) < 0)
HGOTO_ERROR(H5E_INTERNAL, H5E_CANTGET, FAIL, "unable to get link info")
done:
@@ -829,6 +996,9 @@ herr_t
H5Lget_info(hid_t loc_id, const char *name, H5L_info_t *linfo /*out*/,
hid_t lapl_id)
{
+ void *obj = NULL; /* object token of loc_id */
+ H5VL_t *vol_plugin; /* VOL plugin information */
+ H5VL_loc_params_t loc_params;
herr_t ret_value = SUCCEED;
FUNC_ENTER_API(FAIL)
@@ -842,8 +1012,21 @@ H5Lget_info(hid_t loc_id, const char *name, H5L_info_t *linfo /*out*/,
if(TRUE != H5P_isa_class(lapl_id, H5P_LINK_ACCESS))
HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not link access property list ID")
+ loc_params.type = H5VL_OBJECT_BY_NAME;
+ loc_params.obj_type = H5I_get_type(loc_id);
+ loc_params.loc_data.loc_by_name.name = name;
+ loc_params.loc_data.loc_by_name.plist_id = lapl_id;
+
+ /* get the file object */
+ if(NULL == (obj = (void *)H5I_object(loc_id)))
+ HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "invalid file identifier")
+ /* get the plugin pointer */
+ if (NULL == (vol_plugin = (H5VL_t *)H5I_get_aux(loc_id)))
+ HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "ID does not contain VOL information")
+
/* Get the link info through the VOL */
- if((ret_value = H5VL_link_get(loc_id, H5VL_LINK_GET_INFO, H5_REQUEST_NULL, name, linfo, NULL, lapl_id)) < 0)
+ if((ret_value = H5VL_link_get(obj, loc_params, vol_plugin, H5VL_LINK_GET_INFO,
+ H5_REQUEST_NULL, linfo)) < 0)
HGOTO_ERROR(H5E_INTERNAL, H5E_CANTGET, FAIL, "unable to get group info")
done:
@@ -870,7 +1053,9 @@ H5Lget_info_by_idx(hid_t loc_id, const char *group_name,
H5_index_t idx_type, H5_iter_order_t order, hsize_t n,
H5L_info_t *linfo /*out*/, hid_t lapl_id)
{
- H5L_trav_gibi_t udata; /* User data for callback */
+ void *obj = NULL; /* object token of loc_id */
+ H5VL_t *vol_plugin; /* VOL plugin information */
+ H5VL_loc_params_t loc_params;
herr_t ret_value = SUCCEED; /* Return value */
FUNC_ENTER_API(FAIL)
@@ -890,16 +1075,24 @@ H5Lget_info_by_idx(hid_t loc_id, const char *group_name,
if(TRUE != H5P_isa_class(lapl_id, H5P_LINK_ACCESS))
HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not link access property list ID")
- /* Set up user data for callback */
- udata.idx_type = idx_type;
- udata.order = order;
- udata.n = n;
- udata.dxpl_id = H5AC_ind_dxpl_id;
- udata.linfo = linfo;
+ loc_params.type = H5VL_OBJECT_BY_IDX;
+ loc_params.loc_data.loc_by_idx.name = group_name;
+ loc_params.loc_data.loc_by_idx.idx_type = idx_type;
+ loc_params.loc_data.loc_by_idx.order = order;
+ loc_params.loc_data.loc_by_idx.n = n;
+ loc_params.loc_data.loc_by_idx.plist_id = lapl_id;
+ loc_params.obj_type = H5I_get_type(loc_id);
+
+ /* get the file object */
+ if(NULL == (obj = (void *)H5I_object(loc_id)))
+ HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "invalid file identifier")
+ /* get the plugin pointer */
+ if (NULL == (vol_plugin = (H5VL_t *)H5I_get_aux(loc_id)))
+ HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "ID does not contain VOL information")
/* Get the link info through the VOL */
- if((ret_value = H5VL_link_get(loc_id, H5VL_LINK_GET_INFO, H5_REQUEST_NULL, group_name,
- linfo, &udata, lapl_id)) < 0)
+ if((ret_value = H5VL_link_get(obj, loc_params, vol_plugin, H5VL_LINK_GET_INFO, H5_REQUEST_NULL,
+ linfo)) < 0)
HGOTO_ERROR(H5E_INTERNAL, H5E_CANTGET, FAIL, "unable to get group info")
done:
@@ -1056,7 +1249,9 @@ H5Lget_name_by_idx(hid_t loc_id, const char *group_name,
H5_index_t idx_type, H5_iter_order_t order, hsize_t n,
char *name /*out*/, size_t size, hid_t lapl_id)
{
- H5L_trav_gnbi_t udata; /* User data for callback */
+ void *obj = NULL; /* object token of loc_id */
+ H5VL_t *vol_plugin; /* VOL plugin information */
+ H5VL_loc_params_t loc_params;
ssize_t ret_value; /* Return value */
FUNC_ENTER_API(FAIL)
@@ -1076,22 +1271,26 @@ H5Lget_name_by_idx(hid_t loc_id, const char *group_name,
if(TRUE != H5P_isa_class(lapl_id, H5P_LINK_ACCESS))
HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not link access property list ID")
- /* Set up user data for callback */
- udata.idx_type = idx_type;
- udata.order = order;
- udata.n = n;
- udata.dxpl_id = H5AC_ind_dxpl_id;
- udata.name = name;
- udata.size = size;
- udata.name_len = -1;
+ loc_params.type = H5VL_OBJECT_BY_IDX;
+ loc_params.loc_data.loc_by_idx.name = group_name;
+ loc_params.loc_data.loc_by_idx.idx_type = idx_type;
+ loc_params.loc_data.loc_by_idx.order = order;
+ loc_params.loc_data.loc_by_idx.n = n;
+ loc_params.loc_data.loc_by_idx.plist_id = lapl_id;
+ loc_params.obj_type = H5I_get_type(loc_id);
+
+ /* get the file object */
+ if(NULL == (obj = (void *)H5I_object(loc_id)))
+ HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "invalid file identifier")
+ /* get the plugin pointer */
+ if (NULL == (vol_plugin = (H5VL_t *)H5I_get_aux(loc_id)))
+ HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "ID does not contain VOL information")
/* Get the link info through the VOL */
- if((ret_value = H5VL_link_get(loc_id, H5VL_LINK_GET_NAME, H5_REQUEST_NULL, group_name, &udata, lapl_id)) < 0)
+ if((H5VL_link_get(obj, loc_params, vol_plugin, H5VL_LINK_GET_NAME, H5_REQUEST_NULL,
+ name, size, &ret_value)) < 0)
HGOTO_ERROR(H5E_INTERNAL, H5E_CANTGET, FAIL, "unable to get link name")
- /* Set the return value */
- ret_value = udata.name_len;
-
done:
FUNC_LEAVE_API(ret_value)
} /* end H5Lget_name_by_idx() */
@@ -1123,6 +1322,9 @@ herr_t
H5Literate(hid_t id, H5_index_t idx_type, H5_iter_order_t order,
hsize_t *idx_p, H5L_iterate_t op, void *op_data)
{
+ void *obj = NULL; /* object token of loc_id */
+ H5VL_t *vol_plugin; /* VOL plugin information */
+ H5VL_loc_params_t loc_params;
H5I_type_t id_type; /* Type of ID */
herr_t ret_value; /* Return value */
@@ -1140,9 +1342,19 @@ H5Literate(hid_t id, H5_index_t idx_type, H5_iter_order_t order,
if(!op)
HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "no operator specified")
+ loc_params.type = H5VL_OBJECT_BY_SELF;
+ loc_params.obj_type = H5I_get_type(id);
+
+ /* get the file object */
+ if(NULL == (obj = (void *)H5I_object(id)))
+ HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "invalid file identifier")
+ /* get the plugin pointer */
+ if (NULL == (vol_plugin = (H5VL_t *)H5I_get_aux(id)))
+ HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "ID does not contain VOL information")
+
/* iterate over the links through the VOL */
- if((ret_value = H5VL_link_iterate(id, ".", FALSE, idx_type, order, idx_p,
- op, op_data, H5P_LINK_ACCESS_DEFAULT)) < 0)
+ if((ret_value = H5VL_link_iterate(obj, loc_params, vol_plugin, FALSE, idx_type, order, idx_p,
+ op, op_data, H5_REQUEST_NULL)) < 0)
HGOTO_ERROR(H5E_SYM, H5E_BADITER, FAIL, "link iteration failed")
done:
@@ -1177,6 +1389,9 @@ H5Literate_by_name(hid_t loc_id, const char *group_name,
H5_index_t idx_type, H5_iter_order_t order, hsize_t *idx_p,
H5L_iterate_t op, void *op_data, hid_t lapl_id)
{
+ void *obj = NULL; /* object token of loc_id */
+ H5VL_t *vol_plugin; /* VOL plugin information */
+ H5VL_loc_params_t loc_params;
herr_t ret_value; /* Return value */
FUNC_ENTER_API(FAIL)
@@ -1198,9 +1413,21 @@ H5Literate_by_name(hid_t loc_id, const char *group_name,
if(TRUE != H5P_isa_class(lapl_id, H5P_LINK_ACCESS))
HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not link access property list ID")
+ loc_params.type = H5VL_OBJECT_BY_NAME;
+ loc_params.obj_type = H5I_get_type(loc_id);
+ loc_params.loc_data.loc_by_name.name = group_name;
+ loc_params.loc_data.loc_by_name.plist_id = lapl_id;
+
+ /* get the file object */
+ if(NULL == (obj = (void *)H5I_object(loc_id)))
+ HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "invalid file identifier")
+ /* get the plugin pointer */
+ if (NULL == (vol_plugin = (H5VL_t *)H5I_get_aux(loc_id)))
+ HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "ID does not contain VOL information")
+
/* iterate over the links through the VOL */
- if((ret_value = H5VL_link_iterate(loc_id, group_name, FALSE, idx_type, order, idx_p,
- op, op_data, lapl_id)) < 0)
+ if((ret_value = H5VL_link_iterate(obj, loc_params, vol_plugin, FALSE, idx_type, order, idx_p,
+ op, op_data, H5_REQUEST_NULL)) < 0)
HGOTO_ERROR(H5E_SYM, H5E_BADITER, FAIL, "link iteration failed")
done:
@@ -1240,6 +1467,9 @@ herr_t
H5Lvisit(hid_t grp_id, H5_index_t idx_type, H5_iter_order_t order,
H5L_iterate_t op, void *op_data)
{
+ void *obj = NULL; /* object token of loc_id */
+ H5VL_t *vol_plugin; /* VOL plugin information */
+ H5VL_loc_params_t loc_params;
H5I_type_t id_type; /* Type of ID */
herr_t ret_value; /* Return value */
@@ -1258,9 +1488,19 @@ H5Lvisit(hid_t grp_id, H5_index_t idx_type, H5_iter_order_t order,
if(!op)
HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "no callback operator specified")
+ loc_params.type = H5VL_OBJECT_BY_SELF;
+ loc_params.obj_type = H5I_get_type(grp_id);
+
+ /* get the file object */
+ if(NULL == (obj = (void *)H5I_object(grp_id)))
+ HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "invalid file identifier")
+ /* get the plugin pointer */
+ if (NULL == (vol_plugin = (H5VL_t *)H5I_get_aux(grp_id)))
+ HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "ID does not contain VOL information")
+
/* iterate over the links through the VOL */
- if((ret_value = H5VL_link_iterate(grp_id, ".", TRUE, idx_type, order, NULL,
- op, op_data, H5P_LINK_ACCESS_DEFAULT)) < 0)
+ if((ret_value = H5VL_link_iterate(obj, loc_params, vol_plugin, TRUE, idx_type, order, NULL,
+ op, op_data, H5_REQUEST_NULL)) < 0)
HGOTO_ERROR(H5E_SYM, H5E_BADITER, FAIL, "link iteration failed")
done:
@@ -1300,6 +1540,9 @@ herr_t
H5Lvisit_by_name(hid_t loc_id, const char *group_name, H5_index_t idx_type,
H5_iter_order_t order, H5L_iterate_t op, void *op_data, hid_t lapl_id)
{
+ void *obj = NULL; /* object token of loc_id */
+ H5VL_t *vol_plugin; /* VOL plugin information */
+ H5VL_loc_params_t loc_params;
herr_t ret_value; /* Return value */
FUNC_ENTER_API(FAIL)
@@ -1321,9 +1564,21 @@ H5Lvisit_by_name(hid_t loc_id, const char *group_name, H5_index_t idx_type,
if(TRUE != H5P_isa_class(lapl_id, H5P_LINK_ACCESS))
HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not link access property list ID")
+ loc_params.type = H5VL_OBJECT_BY_NAME;
+ loc_params.obj_type = H5I_get_type(loc_id);
+ loc_params.loc_data.loc_by_name.name = group_name;
+ loc_params.loc_data.loc_by_name.plist_id = lapl_id;
+
+ /* get the file object */
+ if(NULL == (obj = (void *)H5I_object(loc_id)))
+ HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "invalid file identifier")
+ /* get the plugin pointer */
+ if (NULL == (vol_plugin = (H5VL_t *)H5I_get_aux(loc_id)))
+ HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "ID does not contain VOL information")
+
/* visit the links through the VOL */
- if((ret_value = H5VL_link_iterate(loc_id, group_name, TRUE, idx_type, order, NULL,
- op, op_data, lapl_id)) < 0)
+ if((ret_value = H5VL_link_iterate(obj, loc_params, vol_plugin, TRUE, idx_type, order, NULL,
+ op, op_data, H5_REQUEST_NULL)) < 0)
HGOTO_ERROR(H5E_SYM, H5E_BADITER, FAIL, "link iteration failed")
done:
@@ -1612,7 +1867,6 @@ H5L_link_cb(H5G_loc_t *grp_loc/*in*/, const char *name, const H5O_link_t UNUSED
H5G_loc_t temp_loc; /* For UD callback */
hbool_t temp_loc_init = FALSE; /* Temporary location for UD callback (temp_loc) has been initialized */
hbool_t obj_created = FALSE; /* Whether an object was created (through a hard link) */
- H5VL_class_t *vol_plugin; /* VOL structure attached to id */
herr_t ret_value = SUCCEED; /* Return value */
FUNC_ENTER_NOAPI_NOINIT
@@ -1706,11 +1960,8 @@ H5L_link_cb(H5G_loc_t *grp_loc/*in*/, const char *name, const H5O_link_t UNUSED
HGOTO_ERROR(H5E_SYM, H5E_CANTOPENOBJ, FAIL, "unable to open group")
if((grp_id = H5I_register(H5I_GROUP, grp, TRUE)) < 0)
HGOTO_ERROR(H5E_ATOM, H5E_CANTREGISTER, FAIL, "unable to register ID for group")
-
- /* attach VOL information to the ID */
- vol_plugin = H5F_get_vol_cls(grp_loc->oloc->file);
- if (H5I_register_aux(grp_id, vol_plugin, (H5I_free_t)H5VL_close) < 0)
- HGOTO_ERROR(H5E_VOL, H5E_CANTINIT, FAIL, "can't attach vol info to ID")
+ if(H5VL_native_register_aux(grp_id) < 0)
+ HGOTO_ERROR(H5E_VOL, H5E_CANTINIT, FAIL, "can't attach native vol info to ID")
/* Make callback */
if((link_class->create_func)(name, grp_id, udata->lnk->u.ud.udata, udata->lnk->u.ud.size, H5P_DEFAULT) < 0)
diff --git a/src/H5Lprivate.h b/src/H5Lprivate.h
index 8e4120e..e4cb328 100644
--- a/src/H5Lprivate.h
+++ b/src/H5Lprivate.h
@@ -49,6 +49,53 @@
/****************************/
/* Library Private Typedefs */
/****************************/
+/* User data for path traversal routine for getting link value by index */
+typedef struct {
+ /* In */
+ H5_index_t idx_type; /* Index to use */
+ H5_iter_order_t order; /* Order to iterate in index */
+ hsize_t n; /* Offset of link within index */
+ hid_t dxpl_id; /* DXPL to use in callback */
+ size_t size; /* Size of user buffer */
+
+ /* Out */
+ void *buf; /* User buffer */
+} H5L_trav_gvbi_t;
+
+/* User data for path traversal routine for getting link info by index */
+typedef struct {
+ /* In */
+ H5_index_t idx_type; /* Index to use */
+ H5_iter_order_t order; /* Order to iterate in index */
+ hsize_t n; /* Offset of link within index */
+ hid_t dxpl_id; /* DXPL to use in callback */
+
+ /* Out */
+ H5L_info_t *linfo; /* Buffer to return to user */
+} H5L_trav_gibi_t;
+
+/* User data for path traversal routine for getting name by index */
+typedef struct {
+ /* In */
+ H5_index_t idx_type; /* Index to use */
+ H5_iter_order_t order; /* Order to iterate in index */
+ hsize_t n; /* Offset of link within index */
+ size_t size; /* Size of name buffer */
+ hid_t dxpl_id; /* DXPL to use in callback */
+
+ /* Out */
+ char *name; /* Buffer to return name to user */
+ ssize_t name_len; /* Length of full name */
+} H5L_trav_gnbi_t;
+
+/* User data for path traversal routine for removing link by index */
+typedef struct {
+ /* In */
+ H5_index_t idx_type; /* Index to use */
+ H5_iter_order_t order; /* Order to iterate in index */
+ hsize_t n; /* Offset of link within index */
+ hid_t dxpl_id; /* DXPL to use in callback */
+} H5L_trav_rmbi_t;
/* Structure for external link traversal callback property */
typedef struct H5L_elink_cb_t {
diff --git a/src/H5O.c b/src/H5O.c
index 29af042..8a20d21 100644
--- a/src/H5O.c
+++ b/src/H5O.c
@@ -46,6 +46,7 @@
#include "H5MFprivate.h" /* File memory management */
#include "H5Opkg.h" /* Object headers */
#include "H5SMprivate.h" /* Shared object header messages */
+#include "H5VLnative.h" /* Native Plugin */
#include "H5VLprivate.h" /* Virtual Object Layer */
/****************/
@@ -227,6 +228,10 @@ H5O_init_interface(void)
hid_t
H5Oopen(hid_t loc_id, const char *name, hid_t lapl_id)
{
+ void *obj = NULL; /* object token of loc_id */
+ H5VL_t *vol_plugin; /* VOL plugin information */
+ H5I_type_t opened_type;
+ void *opened_obj = NULL;
H5VL_loc_params_t loc_params;
hid_t ret_value = FAIL;
@@ -239,11 +244,23 @@ H5Oopen(hid_t loc_id, const char *name, hid_t lapl_id)
loc_params.type = H5VL_OBJECT_BY_NAME;
loc_params.loc_data.loc_by_name.name = name;
loc_params.loc_data.loc_by_name.plist_id = lapl_id;
+ loc_params.obj_type = H5I_get_type(loc_id);
+
+ /* get the file object */
+ if(NULL == (obj = (void *)H5I_object(loc_id)))
+ HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "invalid file identifier")
+ /* get the plugin pointer */
+ if (NULL == (vol_plugin = (H5VL_t *)H5I_get_aux(loc_id)))
+ HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "ID does not contain VOL information")
/* Open the object through the VOL */
- if((ret_value = H5VL_object_open(loc_id, loc_params, H5_REQUEST_NULL)) < 0)
+ if(NULL == (opened_obj = H5VL_object_open(obj, loc_params, vol_plugin, &opened_type, H5_REQUEST_NULL)))
HGOTO_ERROR(H5E_SYM, H5E_CANTINIT, FAIL, "unable to open object")
+ /* Get an atom for the object */
+ if ((ret_value = H5VL_object_register(opened_obj, opened_type, vol_plugin)) < 0)
+ HGOTO_ERROR(H5E_ATOM, H5E_CANTREGISTER, FAIL, "unable to atomize dataset handle")
+
done:
FUNC_LEAVE_API(ret_value)
} /* end H5Oopen() */
@@ -276,6 +293,10 @@ hid_t
H5Oopen_by_idx(hid_t loc_id, const char *group_name, H5_index_t idx_type,
H5_iter_order_t order, hsize_t n, hid_t lapl_id)
{
+ void *obj = NULL; /* object token of loc_id */
+ H5VL_t *vol_plugin; /* VOL plugin information */
+ H5I_type_t opened_type;
+ void *opened_obj = NULL;
H5VL_loc_params_t loc_params;
hid_t ret_value = FAIL;
@@ -301,11 +322,23 @@ H5Oopen_by_idx(hid_t loc_id, const char *group_name, H5_index_t idx_type,
loc_params.loc_data.loc_by_idx.order = order;
loc_params.loc_data.loc_by_idx.n = n;
loc_params.loc_data.loc_by_idx.plist_id = lapl_id;
+ loc_params.obj_type = H5I_get_type(loc_id);
+
+ /* get the file object */
+ if(NULL == (obj = (void *)H5I_object(loc_id)))
+ HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "invalid file identifier")
+ /* get the plugin pointer */
+ if (NULL == (vol_plugin = (H5VL_t *)H5I_get_aux(loc_id)))
+ HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "ID does not contain VOL information")
/* Open the object through the VOL */
- if((ret_value = H5VL_object_open(loc_id, loc_params, H5_REQUEST_NULL)) < 0)
+ if(NULL == (opened_obj = H5VL_object_open(obj, loc_params, vol_plugin, &opened_type, H5_REQUEST_NULL)))
HGOTO_ERROR(H5E_SYM, H5E_CANTINIT, FAIL, "unable to open object")
+ /* Get an atom for the object */
+ if ((ret_value = H5VL_object_register(opened_obj, opened_type, vol_plugin)) < 0)
+ HGOTO_ERROR(H5E_ATOM, H5E_CANTREGISTER, FAIL, "unable to atomize dataset handle")
+
done:
FUNC_LEAVE_API(ret_value)
} /* end H5Oopen_by_idx() */
@@ -349,6 +382,10 @@ done:
hid_t
H5Oopen_by_addr(hid_t loc_id, haddr_t addr)
{
+ void *obj = NULL; /* object token of loc_id */
+ H5VL_t *vol_plugin; /* VOL plugin information */
+ H5I_type_t opened_type;
+ void *opened_obj = NULL;
H5VL_loc_params_t loc_params;
hid_t ret_value = FAIL;
@@ -357,11 +394,23 @@ H5Oopen_by_addr(hid_t loc_id, haddr_t addr)
loc_params.type = H5VL_OBJECT_BY_ADDR;
loc_params.loc_data.loc_by_addr.addr = addr;
+ loc_params.obj_type = H5I_get_type(loc_id);
+
+ /* get the file object */
+ if(NULL == (obj = (void *)H5I_object(loc_id)))
+ HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "invalid file identifier")
+ /* get the plugin pointer */
+ if (NULL == (vol_plugin = (H5VL_t *)H5I_get_aux(loc_id)))
+ HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "ID does not contain VOL information")
/* Open the object through the VOL */
- if((ret_value = H5VL_object_open(loc_id, loc_params, H5_REQUEST_NULL)) < 0)
+ if(NULL == (opened_obj = H5VL_object_open(obj, loc_params, vol_plugin, &opened_type, H5_REQUEST_NULL)))
HGOTO_ERROR(H5E_SYM, H5E_CANTINIT, FAIL, "unable to open object")
+ /* Get an atom for the object */
+ if ((ret_value = H5VL_object_register(opened_obj, opened_type, vol_plugin)) < 0)
+ HGOTO_ERROR(H5E_ATOM, H5E_CANTREGISTER, FAIL, "unable to atomize dataset handle")
+
done:
FUNC_LEAVE_API(ret_value)
} /* end H5Oopen_by_addr() */
@@ -392,8 +441,13 @@ herr_t
H5Olink(hid_t obj_id, hid_t new_loc_id, const char *new_name, hid_t lcpl_id,
hid_t lapl_id)
{
+ void *obj1 = NULL; /* object token of loc_id */
+ void *obj2 = NULL; /* object token of loc_id */
+ H5VL_t *vol_plugin1 = NULL; /* VOL plugin information */
+ H5VL_t *vol_plugin2 = NULL; /* VOL plugin information */
+ H5VL_loc_params_t loc_params1;
+ H5VL_loc_params_t loc_params2;
H5P_genplist_t *plist; /* Property list pointer */
- char *name = NULL;
herr_t ret_value = SUCCEED; /* Return value */
FUNC_ENTER_API(FAIL)
@@ -416,18 +470,49 @@ H5Olink(hid_t obj_id, hid_t new_loc_id, const char *new_name, hid_t lcpl_id,
if(H5P_DEFAULT == lcpl_id)
lcpl_id = H5P_LINK_CREATE_DEFAULT;
+ loc_params1.type = H5VL_OBJECT_BY_SELF;
+ loc_params1.obj_type = H5I_get_type(obj_id);
+
+ loc_params2.type = H5VL_OBJECT_BY_NAME;
+ loc_params2.obj_type = H5I_get_type(new_loc_id);
+ loc_params2.loc_data.loc_by_name.name = new_name;
+ loc_params2.loc_data.loc_by_name.plist_id = lapl_id;
+
+ if(H5L_SAME_LOC != obj_id) {
+ /* get the file object */
+ if(NULL == (obj1 = (void *)H5I_object(obj_id)))
+ HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "invalid file identifier")
+ /* get the plugin pointer */
+ if (NULL == (vol_plugin1 = (H5VL_t *)H5I_get_aux(obj_id)))
+ HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "ID does not contain VOL information")
+ }
+ if(H5L_SAME_LOC != new_loc_id) {
+ /* get the file object */
+ if(NULL == (obj2 = (void *)H5I_object(new_loc_id)))
+ HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "invalid file identifier")
+ /* get the plugin pointer */
+ if (NULL == (vol_plugin2 = (H5VL_t *)H5I_get_aux(new_loc_id)))
+ HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "ID does not contain VOL information")
+ }
+ /* Make sure that the VOL plugins are the same */
+ if(H5L_SAME_LOC != new_loc_id && H5L_SAME_LOC != obj_id) {
+ if (vol_plugin1 != vol_plugin2)
+ HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "Objects are accessed through different VOL plugins and can't be linked")
+ }
+
/* Get the plist structure */
if(NULL == (plist = (H5P_genplist_t *)H5I_object(lcpl_id)))
HGOTO_ERROR(H5E_ATOM, H5E_BADATOM, FAIL, "can't find object for ID")
/* set creation properties */
- if(H5P_set(plist, H5VL_LINK_TARGET_ID, &obj_id) < 0)
+ if(H5P_set(plist, H5VL_LINK_TARGET, &obj1) < 0)
HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, FAIL, "can't set property value for target id")
- if(H5P_set(plist, H5VL_LINK_TARGET_NAME, &name) < 0)
+ if(H5P_set(plist, H5VL_LINK_TARGET_LOC_PARAMS, &loc_params1) < 0)
HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, FAIL, "can't set property value for target id")
/* Create the link through the VOL */
- if((ret_value = H5VL_link_create(H5VL_LINK_CREATE_HARD, new_loc_id, new_name,
+ if((ret_value = H5VL_link_create(H5VL_LINK_CREATE_HARD, obj2, loc_params2,
+ (vol_plugin1!=NULL ? vol_plugin1 : vol_plugin2),
lcpl_id, lapl_id, H5_REQUEST_NULL)) < 0)
HGOTO_ERROR(H5E_SYM, H5E_CANTINIT, FAIL, "unable to create link")
@@ -459,13 +544,27 @@ done:
herr_t
H5Oincr_refcount(hid_t object_id)
{
+ void *obj = NULL; /* object token of loc_id */
+ H5VL_t *vol_plugin; /* VOL plugin information */
+ H5VL_loc_params_t loc_params;
herr_t ret_value = SUCCEED;
FUNC_ENTER_API(FAIL)
H5TRACE1("e", "i", object_id);
+ loc_params.type = H5VL_OBJECT_BY_SELF;
+ loc_params.obj_type = H5I_get_type(object_id);
+
+ /* get the file object */
+ if(NULL == (obj = (void *)H5I_object(object_id)))
+ HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "invalid file identifier")
+ /* get the plugin pointer */
+ if (NULL == (vol_plugin = (H5VL_t *)H5I_get_aux(object_id)))
+ HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "ID does not contain VOL information")
+
/* change the ref count through the VOL */
- if(H5VL_object_misc(object_id, H5VL_OBJECT_CHANGE_REF_COUNT, H5_REQUEST_NULL, 1) < 0)
+ if(H5VL_object_misc(obj, loc_params, vol_plugin, H5VL_OBJECT_CHANGE_REF_COUNT,
+ H5_REQUEST_NULL, 1) < 0)
HGOTO_ERROR(H5E_OHDR, H5E_LINKCOUNT, FAIL, "modifying object link count failed")
done:
@@ -496,13 +595,26 @@ done:
herr_t
H5Odecr_refcount(hid_t object_id)
{
+ void *obj = NULL; /* object token of loc_id */
+ H5VL_t *vol_plugin; /* VOL plugin information */
+ H5VL_loc_params_t loc_params;
herr_t ret_value = SUCCEED;
FUNC_ENTER_API(FAIL)
H5TRACE1("e", "i", object_id);
+ loc_params.type = H5VL_OBJECT_BY_SELF;
+ loc_params.obj_type = H5I_get_type(object_id);
+
+ /* get the file object */
+ if(NULL == (obj = (void *)H5I_object(object_id)))
+ HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "invalid file identifier")
+ /* get the plugin pointer */
+ if (NULL == (vol_plugin = (H5VL_t *)H5I_get_aux(object_id)))
+ HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "ID does not contain VOL information")
+
/* change the ref count through the VOL */
- if(H5VL_object_misc(object_id, H5VL_OBJECT_CHANGE_REF_COUNT, H5_REQUEST_NULL, H5_REQUEST_NULL) < 0)
+ if(H5VL_object_misc(obj, loc_params, vol_plugin, H5VL_OBJECT_CHANGE_REF_COUNT, H5_REQUEST_NULL, -1) < 0)
HGOTO_ERROR(H5E_OHDR, H5E_LINKCOUNT, FAIL, "modifying object link count failed")
done:
@@ -526,6 +638,9 @@ done:
htri_t
H5Oexists_by_name(hid_t loc_id, const char *name, hid_t lapl_id)
{
+ void *obj = NULL; /* object token of loc_id */
+ H5VL_t *vol_plugin; /* VOL plugin information */
+ H5VL_loc_params_t loc_params;
hid_t ret_value = FAIL; /* Return value */
FUNC_ENTER_API(FAIL)
@@ -540,8 +655,20 @@ H5Oexists_by_name(hid_t loc_id, const char *name, hid_t lapl_id)
if(TRUE != H5P_isa_class(lapl_id, H5P_LINK_ACCESS))
HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not link access property list ID")
+ loc_params.type = H5VL_OBJECT_BY_NAME;
+ loc_params.loc_data.loc_by_name.name = name;
+ loc_params.loc_data.loc_by_name.plist_id = lapl_id;
+ loc_params.obj_type = H5I_get_type(loc_id);
+
+ /* get the file object */
+ if(NULL == (obj = (void *)H5I_object(loc_id)))
+ HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "invalid file identifier")
+ /* get the plugin pointer */
+ if (NULL == (vol_plugin = (H5VL_t *)H5I_get_aux(loc_id)))
+ HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "ID does not contain VOL information")
+
/* change the ref count through the VOL */
- if(H5VL_object_get(loc_id, H5VL_OBJECT_EXISTS, H5_REQUEST_NULL, name, lapl_id, &ret_value) < 0)
+ if(H5VL_object_get(obj, loc_params, vol_plugin, H5VL_OBJECT_EXISTS, H5_REQUEST_NULL, &ret_value) < 0)
HGOTO_ERROR(H5E_OHDR, H5E_CANTGET, FAIL, "unable to determine if '%s' exists", name)
done:
@@ -565,6 +692,8 @@ done:
herr_t
H5Oget_info(hid_t loc_id, H5O_info_t *oinfo)
{
+ void *obj = NULL; /* object token of loc_id */
+ H5VL_t *vol_plugin; /* VOL plugin information */
H5VL_loc_params_t loc_params;
herr_t ret_value = SUCCEED; /* Return value */
@@ -575,11 +704,19 @@ H5Oget_info(hid_t loc_id, H5O_info_t *oinfo)
if(!oinfo)
HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "no info struct")
- loc_params.type = H5VL_OBJECT_BY_ID;
- loc_params.loc_data.loc_by_id.id = loc_id;
+ loc_params.type = H5VL_OBJECT_BY_SELF;
+ loc_params.obj_type = H5I_get_type(loc_id);
+
+ /* get the file object */
+ if(NULL == (obj = (void *)H5I_object(loc_id)))
+ HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "invalid file identifier")
+ /* get the plugin pointer */
+ if (NULL == (vol_plugin = (H5VL_t *)H5I_get_aux(loc_id)))
+ HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "ID does not contain VOL information")
/* Get the group info through the VOL using the location token */
- if((ret_value = H5VL_object_get(loc_id, H5VL_OBJECT_GET_INFO, H5_REQUEST_NULL, oinfo, loc_params)) < 0)
+ if((ret_value = H5VL_object_get(obj, loc_params, vol_plugin, H5VL_OBJECT_GET_INFO,
+ H5_REQUEST_NULL, oinfo)) < 0)
HGOTO_ERROR(H5E_INTERNAL, H5E_CANTGET, FAIL, "unable to get group info")
done:
@@ -603,6 +740,8 @@ done:
herr_t
H5Oget_info_by_name(hid_t loc_id, const char *name, H5O_info_t *oinfo, hid_t lapl_id)
{
+ void *obj = NULL; /* object token of loc_id */
+ H5VL_t *vol_plugin; /* VOL plugin information */
H5VL_loc_params_t loc_params;
herr_t ret_value = SUCCEED; /* Return value */
@@ -623,9 +762,19 @@ H5Oget_info_by_name(hid_t loc_id, const char *name, H5O_info_t *oinfo, hid_t lap
loc_params.type = H5VL_OBJECT_BY_NAME;
loc_params.loc_data.loc_by_name.name = name;
loc_params.loc_data.loc_by_name.plist_id = lapl_id;
+ loc_params.obj_type = H5I_get_type(loc_id);
+
+ /* get the file object */
+ if(NULL == (obj = (void *)H5I_object(loc_id)))
+ HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "invalid file identifier")
+
+ /* get the plugin pointer */
+ if (NULL == (vol_plugin = (H5VL_t *)H5I_get_aux(loc_id)))
+ HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "ID does not contain VOL information")
/* Get the group info through the VOL using the location token */
- if((ret_value = H5VL_object_get(loc_id, H5VL_OBJECT_GET_INFO, H5_REQUEST_NULL, oinfo, loc_params)) < 0)
+ if((ret_value = H5VL_object_get(obj, loc_params, vol_plugin, H5VL_OBJECT_GET_INFO,
+ H5_REQUEST_NULL, oinfo)) < 0)
HGOTO_ERROR(H5E_INTERNAL, H5E_CANTGET, FAIL, "unable to get group info")
done:
@@ -651,6 +800,8 @@ herr_t
H5Oget_info_by_idx(hid_t loc_id, const char *group_name, H5_index_t idx_type,
H5_iter_order_t order, hsize_t n, H5O_info_t *oinfo, hid_t lapl_id)
{
+ void *obj = NULL; /* object token of loc_id */
+ H5VL_t *vol_plugin; /* VOL plugin information */
H5VL_loc_params_t loc_params;
herr_t ret_value = SUCCEED; /* Return value */
@@ -679,9 +830,18 @@ H5Oget_info_by_idx(hid_t loc_id, const char *group_name, H5_index_t idx_type,
loc_params.loc_data.loc_by_idx.order = order;
loc_params.loc_data.loc_by_idx.n = n;
loc_params.loc_data.loc_by_idx.plist_id = lapl_id;
+ loc_params.obj_type = H5I_get_type(loc_id);
+
+ /* get the file object */
+ if(NULL == (obj = (void *)H5I_object(loc_id)))
+ HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "invalid file identifier")
+ /* get the plugin pointer */
+ if (NULL == (vol_plugin = (H5VL_t *)H5I_get_aux(loc_id)))
+ HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "ID does not contain VOL information")
/* Get the group info through the VOL using the location token */
- if((ret_value = H5VL_object_get(loc_id, H5VL_OBJECT_GET_INFO, H5_REQUEST_NULL, oinfo, loc_params)) < 0)
+ if((ret_value = H5VL_object_get(obj, loc_params, vol_plugin, H5VL_OBJECT_GET_INFO,
+ H5_REQUEST_NULL, oinfo)) < 0)
HGOTO_ERROR(H5E_INTERNAL, H5E_CANTGET, FAIL, "unable to get group info")
done:
@@ -709,13 +869,26 @@ done:
herr_t
H5Oset_comment(hid_t obj_id, const char *comment)
{
+ void *obj = NULL; /* object token of loc_id */
+ H5VL_t *vol_plugin; /* VOL plugin information */
+ H5VL_loc_params_t loc_params;
herr_t ret_value = SUCCEED; /* Return value */
FUNC_ENTER_API(FAIL)
H5TRACE2("e", "i*s", obj_id, comment);
+ loc_params.type = H5VL_OBJECT_BY_SELF;
+ loc_params.obj_type = H5I_get_type(obj_id);
+
+ /* get the file object */
+ if(NULL == (obj = (void *)H5I_object(obj_id)))
+ HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "invalid file identifier")
+ /* get the plugin pointer */
+ if (NULL == (vol_plugin = (H5VL_t *)H5I_get_aux(obj_id)))
+ HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "ID does not contain VOL information")
+
/* set comment on object through the VOL */
- if(H5VL_object_misc(obj_id, H5VL_OBJECT_SET_COMMENT, H5_REQUEST_NULL, ".", comment, H5P_LINK_ACCESS_DEFAULT) < 0)
+ if(H5VL_object_misc(obj, loc_params, vol_plugin, H5VL_OBJECT_SET_COMMENT, H5_REQUEST_NULL, comment) < 0)
HGOTO_ERROR(H5E_SYM, H5E_CANTINIT, FAIL, "unable to set comment value")
done:
@@ -744,6 +917,9 @@ herr_t
H5Oset_comment_by_name(hid_t loc_id, const char *name, const char *comment,
hid_t lapl_id)
{
+ void *obj = NULL; /* object token of loc_id */
+ H5VL_t *vol_plugin; /* VOL plugin information */
+ H5VL_loc_params_t loc_params;
herr_t ret_value = SUCCEED; /* Return value */
FUNC_ENTER_API(FAIL)
@@ -758,8 +934,20 @@ H5Oset_comment_by_name(hid_t loc_id, const char *name, const char *comment,
if(TRUE != H5P_isa_class(lapl_id, H5P_LINK_ACCESS))
HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not link access property list ID")
+ loc_params.type = H5VL_OBJECT_BY_NAME;
+ loc_params.loc_data.loc_by_name.name = name;
+ loc_params.loc_data.loc_by_name.plist_id = lapl_id;
+ loc_params.obj_type = H5I_get_type(loc_id);
+
+ /* get the file object */
+ if(NULL == (obj = (void *)H5I_object(loc_id)))
+ HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "invalid file identifier")
+ /* get the plugin pointer */
+ if (NULL == (vol_plugin = (H5VL_t *)H5I_get_aux(loc_id)))
+ HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "ID does not contain VOL information")
+
/* set comment on object through the VOL */
- if(H5VL_object_misc(loc_id, H5VL_OBJECT_SET_COMMENT, H5_REQUEST_NULL, name, comment, lapl_id) < 0)
+ if(H5VL_object_misc(obj, loc_params, vol_plugin, H5VL_OBJECT_SET_COMMENT, H5_REQUEST_NULL, comment) < 0)
HGOTO_ERROR(H5E_SYM, H5E_CANTINIT, FAIL, "unable to set comment value")
done:
@@ -786,13 +974,26 @@ done:
ssize_t
H5Oget_comment(hid_t loc_id, char *comment, size_t bufsize)
{
+ void *obj = NULL; /* object token of loc_id */
+ H5VL_t *vol_plugin; /* VOL plugin information */
+ H5VL_loc_params_t loc_params;
ssize_t ret_value; /* Return value */
FUNC_ENTER_API(FAIL)
H5TRACE3("Zs", "i*sz", loc_id, comment, bufsize);
- if(H5VL_object_get(loc_id, H5VL_OBJECT_GET_COMMENT, H5_REQUEST_NULL, &ret_value, comment, bufsize,
- ".", H5P_LINK_ACCESS_DEFAULT) < 0)
+ loc_params.type = H5VL_OBJECT_BY_SELF;
+ loc_params.obj_type = H5I_get_type(loc_id);
+
+ /* get the file object */
+ if(NULL == (obj = (void *)H5I_object(loc_id)))
+ HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "invalid file identifier")
+ /* get the plugin pointer */
+ if (NULL == (vol_plugin = (H5VL_t *)H5I_get_aux(loc_id)))
+ HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "ID does not contain VOL information")
+
+ if(H5VL_object_get(obj, loc_params, vol_plugin, H5VL_OBJECT_GET_COMMENT, H5_REQUEST_NULL,
+ comment, bufsize, &ret_value) < 0)
HGOTO_ERROR(H5E_INTERNAL, H5E_CANTGET, FAIL, "unable to get object comment")
done:
@@ -820,6 +1021,9 @@ ssize_t
H5Oget_comment_by_name(hid_t loc_id, const char *name, char *comment, size_t bufsize,
hid_t lapl_id)
{
+ void *obj = NULL; /* object token of loc_id */
+ H5VL_t *vol_plugin; /* VOL plugin information */
+ H5VL_loc_params_t loc_params;
ssize_t ret_value; /* Return value */
FUNC_ENTER_API(FAIL)
@@ -834,8 +1038,20 @@ H5Oget_comment_by_name(hid_t loc_id, const char *name, char *comment, size_t buf
if(TRUE != H5P_isa_class(lapl_id, H5P_LINK_ACCESS))
HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not link access property list ID")
- if(H5VL_object_get(loc_id, H5VL_OBJECT_GET_COMMENT, H5_REQUEST_NULL, &ret_value, comment, bufsize,
- name, lapl_id) < 0)
+ loc_params.type = H5VL_OBJECT_BY_NAME;
+ loc_params.loc_data.loc_by_name.name = name;
+ loc_params.loc_data.loc_by_name.plist_id = lapl_id;
+ loc_params.obj_type = H5I_get_type(loc_id);
+
+ /* get the file object */
+ if(NULL == (obj = (void *)H5I_object(loc_id)))
+ HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "invalid file identifier")
+ /* get the plugin pointer */
+ if (NULL == (vol_plugin = (H5VL_t *)H5I_get_aux(loc_id)))
+ HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "ID does not contain VOL information")
+
+ if(H5VL_object_get(obj, loc_params, vol_plugin, H5VL_OBJECT_GET_COMMENT, H5_REQUEST_NULL,
+ comment, bufsize, &ret_value) < 0)
HGOTO_ERROR(H5E_INTERNAL, H5E_CANTGET, FAIL, "unable to get object info")
done:
@@ -879,6 +1095,9 @@ herr_t
H5Ovisit(hid_t obj_id, H5_index_t idx_type, H5_iter_order_t order,
H5O_iterate_t op, void *op_data)
{
+ void *obj = NULL; /* object token of loc_id */
+ H5VL_t *vol_plugin; /* VOL plugin information */
+ H5VL_loc_params_t loc_params;
herr_t ret_value; /* Return value */
FUNC_ENTER_API(FAIL)
@@ -892,8 +1111,19 @@ H5Ovisit(hid_t obj_id, H5_index_t idx_type, H5_iter_order_t order,
if(!op)
HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "no callback operator specified")
+ loc_params.type = H5VL_OBJECT_BY_SELF;
+ loc_params.obj_type = H5I_get_type(obj_id);
+
+ /* get the file object */
+ if(NULL == (obj = (void *)H5I_object(obj_id)))
+ HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "invalid file identifier")
+ /* get the plugin pointer */
+ if (NULL == (vol_plugin = (H5VL_t *)H5I_get_aux(obj_id)))
+ HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "ID does not contain VOL information")
+
/* iterate over the objects through the VOL */
- if((ret_value = H5VL_object_visit(obj_id, ".", idx_type, order, op, op_data, H5P_LINK_ACCESS_DEFAULT)) < 0)
+ if((ret_value = H5VL_object_visit(obj, loc_params, vol_plugin, idx_type, order, op, op_data,
+ H5_REQUEST_NULL)) < 0)
HGOTO_ERROR(H5E_SYM, H5E_BADITER, FAIL, "link iteration failed")
done:
@@ -937,6 +1167,9 @@ herr_t
H5Ovisit_by_name(hid_t loc_id, const char *obj_name, H5_index_t idx_type,
H5_iter_order_t order, H5O_iterate_t op, void *op_data, hid_t lapl_id)
{
+ void *obj = NULL; /* object token of loc_id */
+ H5VL_t *vol_plugin; /* VOL plugin information */
+ H5VL_loc_params_t loc_params;
herr_t ret_value; /* Return value */
FUNC_ENTER_API(FAIL)
@@ -958,8 +1191,21 @@ H5Ovisit_by_name(hid_t loc_id, const char *obj_name, H5_index_t idx_type,
if(TRUE != H5P_isa_class(lapl_id, H5P_LINK_ACCESS))
HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not link access property list ID")
+ loc_params.type = H5VL_OBJECT_BY_NAME;
+ loc_params.loc_data.loc_by_name.name = obj_name;
+ loc_params.loc_data.loc_by_name.plist_id = lapl_id;
+ loc_params.obj_type = H5I_get_type(loc_id);
+
+ /* get the file object */
+ if(NULL == (obj = (void *)H5I_object(loc_id)))
+ HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "invalid file identifier")
+ /* get the plugin pointer */
+ if (NULL == (vol_plugin = (H5VL_t *)H5I_get_aux(loc_id)))
+ HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "ID does not contain VOL information")
+
/* iterate over the objects through the VOL */
- if((ret_value = H5VL_object_visit(loc_id, obj_name, idx_type, order, op, op_data, lapl_id)) < 0)
+ if((ret_value = H5VL_object_visit(obj, loc_params, vol_plugin, idx_type, order, op,
+ op_data, H5_REQUEST_NULL)) < 0)
HGOTO_ERROR(H5E_SYM, H5E_BADITER, FAIL, "link iteration failed")
done:
@@ -993,9 +1239,40 @@ H5Oclose(hid_t object_id)
FUNC_ENTER_API(FAIL)
H5TRACE1("e", "i", object_id);
+ /* Get the type of the object and close it in the correct way */
+ switch(H5I_get_type(object_id)) {
+ case H5I_GROUP:
+ case H5I_DATATYPE:
+ case H5I_DATASET:
+ if(H5I_object(object_id) == NULL)
+ HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "not a valid object")
+ if(H5I_dec_app_ref(object_id) < 0)
+ HGOTO_ERROR(H5E_OHDR, H5E_CANTRELEASE, FAIL, "unable to close object")
+ break;
+
+ case H5I_UNINIT:
+ case H5I_BADID:
+ case H5I_FILE:
+ case H5I_DATASPACE:
+ case H5I_ATTR:
+ case H5I_REFERENCE:
+ case H5I_VFL:
+ case H5I_GENPROP_CLS:
+ case H5I_GENPROP_LST:
+ case H5I_ERROR_CLASS:
+ case H5I_ERROR_MSG:
+ case H5I_ERROR_STACK:
+ case H5I_NTYPES:
+ default:
+ HGOTO_ERROR(H5E_ARGS, H5E_CANTRELEASE, FAIL, "not a valid file object ID (dataset, group, or datatype)")
+ break;
+ } /* end switch */
+
+#if 0
/* Close the object through the VOL */
if(H5VL_object_close(object_id, H5_REQUEST_NULL) < 0)
HGOTO_ERROR(H5E_SYM, H5E_CANTRELEASE, FAIL, "unable to close object")
+#endif
done:
FUNC_LEAVE_API(ret_value)
@@ -3174,12 +3451,11 @@ done:
*-------------------------------------------------------------------------
*/
herr_t
-H5O_visit(hid_t loc_id, const char *obj_name, H5_index_t idx_type,
+H5O_visit(H5G_loc_t *loc, const char *obj_name, H5_index_t idx_type,
H5_iter_order_t order, H5O_iterate_t op, void *op_data, hid_t lapl_id,
hid_t dxpl_id)
{
H5O_iter_visit_ud_t udata; /* User data for callback */
- H5G_loc_t loc; /* Location of reference object */
H5G_loc_t obj_loc; /* Location used to open object */
H5G_name_t obj_path; /* Opened object group hier. path */
H5O_loc_t obj_oloc; /* Opened object object location */
@@ -3193,17 +3469,13 @@ H5O_visit(hid_t loc_id, const char *obj_name, H5_index_t idx_type,
/* Portably initialize user data struct to zeros */
HDmemset(&udata, 0, sizeof(udata));
- /* Check args */
- if(H5G_loc(loc_id, &loc) < 0)
- HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a location")
-
/* Set up opened group location to fill in */
obj_loc.oloc = &obj_oloc;
obj_loc.path = &obj_path;
H5G_loc_reset(&obj_loc);
/* Find the object's location */
- if(H5G_loc_find(&loc, obj_name, &obj_loc/*out*/, lapl_id, dxpl_id) < 0)
+ if(H5G_loc_find(loc, obj_name, &obj_loc/*out*/, lapl_id, dxpl_id) < 0)
HGOTO_ERROR(H5E_OHDR, H5E_NOTFOUND, FAIL, "object not found")
loc_found = TRUE;
@@ -3216,6 +3488,9 @@ H5O_visit(hid_t loc_id, const char *obj_name, H5_index_t idx_type,
if((obj_id = H5O_open_by_loc(&obj_loc, lapl_id, dxpl_id, TRUE)) < 0)
HGOTO_ERROR(H5E_OHDR, H5E_CANTOPENOBJ, FAIL, "unable to open object")
+ if(H5VL_native_register_aux(obj_id) < 0)
+ HGOTO_ERROR(H5E_VOL, H5E_CANTINIT, FAIL, "can't attach native vol info to ID")
+
/* Make callback for starting object */
if((ret_value = op(obj_id, ".", &oinfo, op_data)) < 0)
HGOTO_ERROR(H5E_OHDR, H5E_BADITER, FAIL, "can't visit objects")
diff --git a/src/H5Ocopy.c b/src/H5Ocopy.c
index c4451de..482f1ba 100644
--- a/src/H5Ocopy.c
+++ b/src/H5Ocopy.c
@@ -205,6 +205,12 @@ herr_t
H5Ocopy(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)
{
+ void *obj1 = NULL; /* object token of src_id */
+ H5VL_t *vol_plugin1; /* VOL plugin information */
+ H5VL_loc_params_t loc_params1;
+ void *obj2 = NULL; /* object token of dst_id */
+ H5VL_t *vol_plugin2; /* VOL plugin information */
+ H5VL_loc_params_t loc_params2;
herr_t ret_value = SUCCEED; /* Return value */
FUNC_ENTER_API(FAIL)
@@ -227,8 +233,27 @@ H5Ocopy(hid_t src_loc_id, const char *src_name, hid_t dst_loc_id,
if(TRUE != H5P_isa_class(ocpypl_id, H5P_OBJECT_COPY))
HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not object copy property list")
+ /* get the object */
+ if(NULL == (obj1 = (void *)H5I_object(src_loc_id)))
+ HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "invalid location identifier")
+ /* get the plugin pointer */
+ if (NULL == (vol_plugin1 = (H5VL_t *)H5I_get_aux(src_loc_id)))
+ HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "src ID does not contain VOL information")
+ loc_params1.type = H5VL_OBJECT_BY_SELF;
+ loc_params1.obj_type = H5I_get_type(src_loc_id);
+
+ /* get the object */
+ if(NULL == (obj2 = (void *)H5I_object(dst_loc_id)))
+ HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "invalid location identifier")
+ /* get the plugin pointer */
+ if (NULL == (vol_plugin2 = (H5VL_t *)H5I_get_aux(dst_loc_id)))
+ HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "dst ID does not contain VOL information")
+ loc_params2.type = H5VL_OBJECT_BY_SELF;
+ loc_params2.obj_type = H5I_get_type(dst_loc_id);
+
/* Open the object through the VOL */
- if((ret_value = H5VL_object_copy(src_loc_id, src_name, dst_loc_id, dst_name,
+ if((ret_value = H5VL_object_copy(obj1, loc_params1, vol_plugin1, src_name,
+ obj2, loc_params2, vol_plugin2, dst_name,
ocpypl_id, lcpl_id, H5_REQUEST_NULL)) < 0)
HGOTO_ERROR(H5E_SYM, H5E_CANTINIT, FAIL, "unable to open object")
done:
diff --git a/src/H5Opkg.h b/src/H5Opkg.h
index 1a3f5c7..b7cca64 100644
--- a/src/H5Opkg.h
+++ b/src/H5Opkg.h
@@ -533,7 +533,7 @@ H5_DLL int H5O_link_oh(H5F_t *f, int adjust, hid_t dxpl_id, H5O_t *oh, hbool_t *
H5_DLL herr_t H5O_inc_rc(H5O_t *oh);
H5_DLL herr_t H5O_dec_rc(H5O_t *oh);
H5_DLL herr_t H5O_free(H5O_t *oh);
-H5_DLL herr_t H5O_visit(hid_t loc_id, const char *obj_name, H5_index_t idx_type,
+H5_DLL herr_t H5O_visit(H5G_loc_t *loc, const char *obj_name, H5_index_t idx_type,
H5_iter_order_t order, H5O_iterate_t op, void *op_data, hid_t lapl_id,
hid_t dxpl_id);
diff --git a/src/H5Pacpl.c b/src/H5Pacpl.c
index 0786cb1..be61bfc 100644
--- a/src/H5Pacpl.c
+++ b/src/H5Pacpl.c
@@ -43,9 +43,9 @@
/* Local Macros */
/****************/
-/* Definitions for UDATA */
+/* Definitions for locations parameters */
#define H5A_CRT_LOCATION_SIZE sizeof(H5VL_loc_params_t)
-#define H5A_CRT_LOCATION_DEF {H5VL_OBJECT_BY_ID, {{FAIL}}}
+#define H5A_CRT_LOCATION_DEF {H5I_BADID}
/******************/
/* Local Typedefs */
diff --git a/src/H5Plcpl.c b/src/H5Plcpl.c
index 4c22749..0129f39 100644
--- a/src/H5Plcpl.c
+++ b/src/H5Plcpl.c
@@ -50,8 +50,12 @@
#define H5L_CRT_INTERMEDIATE_GROUP_DEF 0
/* Definitions for target object ID */
-#define H5L_CRT_TARGET_ID_SIZE sizeof(hid_t)
-#define H5L_CRT_TARGET_ID_DEF 0
+#define H5L_CRT_TARGET_SIZE sizeof(void *)
+#define H5L_CRT_TARGET_DEF NULL
+
+/* Definitions for Location params */
+#define H5L_CRT_LOCATION_SIZE sizeof(H5VL_loc_params_t)
+#define H5L_CRT_LOCATION_DEF {H5I_BADID}
/* Definitions for target object NAME */
#define H5L_CRT_TARGET_NAME_SIZE sizeof(char *)
@@ -133,7 +137,8 @@ herr_t
H5P_lcrt_reg_prop(H5P_genclass_t *pclass)
{
unsigned intmd_group = H5L_CRT_INTERMEDIATE_GROUP_DEF; /* Default setting for creating intermediate groups */
- hid_t target_id = H5L_CRT_TARGET_ID_DEF;
+ void* target = H5L_CRT_TARGET_DEF;
+ H5VL_loc_params_t loc_params = H5L_CRT_LOCATION_DEF;
char *target_name = H5L_CRT_TARGET_NAME_DEF;
H5L_type_t link_type = H5L_CRT_LINK_TYPE_DEF;
void *udata = H5L_CRT_UDATA_DEF;
@@ -146,7 +151,11 @@ H5P_lcrt_reg_prop(H5P_genclass_t *pclass)
if(H5P_register_real(pclass, H5L_CRT_INTERMEDIATE_GROUP_NAME, H5L_CRT_INTERMEDIATE_GROUP_SIZE, &intmd_group, NULL, NULL, NULL, NULL, NULL, NULL, NULL) < 0)
HGOTO_ERROR(H5E_PLIST, H5E_CANTINSERT, FAIL, "can't insert property into class")
- if(H5P_register_real(pclass, H5VL_LINK_TARGET_ID, H5L_CRT_TARGET_ID_SIZE, &target_id,
+ if(H5P_register_real(pclass, H5VL_LINK_TARGET, H5L_CRT_TARGET_SIZE, &target,
+ NULL, NULL, NULL, NULL, NULL, NULL, NULL) < 0)
+ HGOTO_ERROR(H5E_PLIST, H5E_CANTINSERT, FAIL, "can't insert property into class")
+
+ if(H5P_register_real(pclass, H5VL_LINK_TARGET_LOC_PARAMS, H5L_CRT_LOCATION_SIZE, &loc_params,
NULL, NULL, NULL, NULL, NULL, NULL, NULL) < 0)
HGOTO_ERROR(H5E_PLIST, H5E_CANTINSERT, FAIL, "can't insert property into class")
diff --git a/src/H5R.c b/src/H5R.c
index d30cf90..d736e09 100644
--- a/src/H5R.c
+++ b/src/H5R.c
@@ -300,6 +300,9 @@ done:
herr_t
H5Rcreate(void *ref, hid_t loc_id, const char *name, H5R_type_t ref_type, hid_t space_id)
{
+ void *obj = NULL; /* object token of loc_id */
+ H5VL_t *vol_plugin; /* VOL plugin information */
+ H5VL_loc_params_t loc_params;
herr_t ret_value; /* Return value */
FUNC_ENTER_API(FAIL)
@@ -317,8 +320,19 @@ H5Rcreate(void *ref, hid_t loc_id, const char *name, H5R_type_t ref_type, hid_t
if(space_id == (-1) && ref_type == H5R_DATASET_REGION)
HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "reference region dataspace id must be valid")
+ loc_params.type = H5VL_OBJECT_BY_SELF;
+ loc_params.obj_type = H5I_get_type(loc_id);
+
+ /* get the file object */
+ if(NULL == (obj = (void *)H5I_object(loc_id)))
+ HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "invalid file identifier")
+ /* get the plugin pointer */
+ if (NULL == (vol_plugin = (H5VL_t *)H5I_get_aux(loc_id)))
+ HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "ID does not contain VOL information")
+
/* create the ref through the VOL */
- if(H5VL_object_misc(loc_id, H5VL_REF_CREATE, H5_REQUEST_NULL, ref, name, ref_type, space_id) < 0)
+ if(H5VL_object_misc(obj, loc_params, vol_plugin, H5VL_REF_CREATE, H5_REQUEST_NULL,
+ ref, name, ref_type, space_id) < 0)
HGOTO_ERROR(H5E_OHDR, H5E_LINKCOUNT, FAIL, "modifying object link count failed")
done:
@@ -511,6 +525,10 @@ done:
hid_t
H5Rdereference2(hid_t obj_id, hid_t oapl_id, H5R_type_t ref_type, const void *_ref)
{
+ void *obj = NULL; /* object token of loc_id */
+ H5VL_t *vol_plugin; /* VOL plugin information */
+ H5I_type_t opened_type;
+ void *opened_obj = NULL;
H5VL_loc_params_t loc_params;
hid_t ret_value;
@@ -529,11 +547,14 @@ H5Rdereference2(hid_t obj_id, hid_t oapl_id, H5R_type_t ref_type, const void *_r
loc_params.loc_data.loc_by_ref.ref_type = ref_type;
loc_params.loc_data.loc_by_ref._ref = _ref;
loc_params.loc_data.loc_by_ref.plist_id = oapl_id;
+ loc_params.obj_type = H5I_get_type(obj_id);
/* Open the object through the VOL */
- if((ret_value = H5VL_object_open(obj_id, loc_params, H5_REQUEST_NULL)) < 0)
+ if(NULL == (opened_obj = H5VL_object_open(obj, loc_params, vol_plugin, &opened_type, H5_REQUEST_NULL)))
HGOTO_ERROR(H5E_SYM, H5E_CANTINIT, FAIL, "unable to open object")
-
+ /* Get an atom for the object */
+ if ((ret_value = H5VL_object_register(opened_obj, opened_type, vol_plugin)) < 0)
+ HGOTO_ERROR(H5E_ATOM, H5E_CANTREGISTER, FAIL, "unable to atomize dataset handle")
#if 0
/* Create reference */
if((ret_value = H5R_dereference(file, oapl_id, H5AC_dxpl_id, ref_type, _ref, TRUE)) < 0)
@@ -640,6 +661,9 @@ done:
hid_t
H5Rget_region(hid_t id, H5R_type_t ref_type, const void *ref)
{
+ void *obj = NULL; /* object token of loc_id */
+ H5VL_t *vol_plugin; /* VOL plugin information */
+ H5VL_loc_params_t loc_params;
hid_t ret_value;
FUNC_ENTER_API(FAIL)
@@ -651,8 +675,19 @@ H5Rget_region(hid_t id, H5R_type_t ref_type, const void *ref)
if(ref == NULL)
HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "invalid reference pointer")
+ loc_params.type = H5VL_OBJECT_BY_SELF;
+ loc_params.obj_type = H5I_get_type(id);
+
+ /* get the file object */
+ if(NULL == (obj = (void *)H5I_object(id)))
+ HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "invalid file identifier")
+ /* get the plugin pointer */
+ if (NULL == (vol_plugin = (H5VL_t *)H5I_get_aux(id)))
+ HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "ID does not contain VOL information")
+
/* Get the space id through the VOL */
- if(H5VL_object_get(id, H5VL_REF_GET_REGION, H5_REQUEST_NULL, &ret_value, ref_type, ref) < 0)
+ if(H5VL_object_get(obj, loc_params, vol_plugin, H5VL_REF_GET_REGION, H5_REQUEST_NULL,
+ &ret_value, ref_type, ref) < 0)
HGOTO_ERROR(H5E_INTERNAL, H5E_CANTGET, FAIL, "unable to get group info")
done:
@@ -773,6 +808,9 @@ herr_t
H5Rget_obj_type2(hid_t id, H5R_type_t ref_type, const void *ref,
H5O_type_t *obj_type)
{
+ void *obj = NULL; /* object token of loc_id */
+ H5VL_t *vol_plugin; /* VOL plugin information */
+ H5VL_loc_params_t loc_params;
herr_t ret_value = SUCCEED; /* Return value */
FUNC_ENTER_API(FAIL)
@@ -784,8 +822,19 @@ H5Rget_obj_type2(hid_t id, H5R_type_t ref_type, const void *ref,
if(ref == NULL)
HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "invalid reference pointer")
+ loc_params.type = H5VL_OBJECT_BY_SELF;
+ loc_params.obj_type = H5I_get_type(id);
+
+ /* get the file object */
+ if(NULL == (obj = (void *)H5I_object(id)))
+ HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "invalid file identifier")
+ /* get the plugin pointer */
+ if (NULL == (vol_plugin = (H5VL_t *)H5I_get_aux(id)))
+ HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "ID does not contain VOL information")
+
/* get the object type through the VOL */
- if((ret_value = H5VL_object_get(id, H5VL_REF_GET_TYPE, H5_REQUEST_NULL, obj_type, ref_type, ref)) < 0)
+ if((ret_value = H5VL_object_get(obj, loc_params, vol_plugin, H5VL_REF_GET_TYPE,
+ H5_REQUEST_NULL, obj_type, ref_type, ref)) < 0)
HGOTO_ERROR(H5E_INTERNAL, H5E_CANTGET, FAIL, "unable to get group info")
done:
@@ -822,9 +871,10 @@ done:
REVISION LOG
--------------------------------------------------------------------------*/
ssize_t
-H5R_get_name(H5F_t *f, hid_t lapl_id, hid_t dxpl_id, hid_t id, H5R_type_t ref_type,
+H5R_get_name(H5G_loc_t *loc, hid_t lapl_id, hid_t dxpl_id, H5R_type_t ref_type,
const void *_ref, char *name, size_t size)
{
+ H5F_t *f;
hid_t file_id = (-1); /* ID for file that the reference is in */
H5O_loc_t oloc; /* Object location describing object for reference */
ssize_t ret_value; /* Return value */
@@ -836,6 +886,9 @@ H5R_get_name(H5F_t *f, hid_t lapl_id, hid_t dxpl_id, hid_t id, H5R_type_t ref_ty
HDassert(_ref);
HDassert(name);
+ /* Get the file pointer from the entry */
+ f = loc->oloc->file;
+
/* Initialize the object location */
H5O_loc_reset(&oloc);
oloc.file = f;
@@ -878,8 +931,10 @@ H5R_get_name(H5F_t *f, hid_t lapl_id, hid_t dxpl_id, hid_t id, H5R_type_t ref_ty
} /* end switch */
/* Retrieve file ID for name search */
- if((file_id = H5I_get_file_id(id, FALSE)) < 0)
- HGOTO_ERROR(H5E_REFERENCE, H5E_CANTGET, FAIL, "can't retrieve file ID")
+ if((file_id = H5F_get_id(f, FALSE)) < 0)
+ HGOTO_ERROR(H5E_ATOM, H5E_CANTGET, FAIL, "can't get file ID")
+ //if((file_id = H5I_get_file_id(id, FALSE)) < 0)
+ //HGOTO_ERROR(H5E_REFERENCE, H5E_CANTGET, FAIL, "can't retrieve file ID")
/* Get name, length, etc. */
if((ret_value = H5G_get_name_by_addr(file_id, lapl_id, dxpl_id, &oloc, name, size)) < 0)
@@ -923,6 +978,9 @@ ssize_t
H5Rget_name(hid_t id, H5R_type_t ref_type, const void *_ref, char *name,
size_t size)
{
+ void *obj = NULL; /* object token of loc_id */
+ H5VL_t *vol_plugin; /* VOL plugin information */
+ H5VL_loc_params_t loc_params;
ssize_t ret_value; /* Return value */
FUNC_ENTER_API(FAIL)
@@ -934,8 +992,19 @@ H5Rget_name(hid_t id, H5R_type_t ref_type, const void *_ref, char *name,
if(_ref == NULL)
HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "invalid reference pointer")
+ loc_params.type = H5VL_OBJECT_BY_SELF;
+ loc_params.obj_type = H5I_get_type(id);
+
+ /* get the file object */
+ if(NULL == (obj = (void *)H5I_object(id)))
+ HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "invalid file identifier")
+ /* get the plugin pointer */
+ if (NULL == (vol_plugin = (H5VL_t *)H5I_get_aux(id)))
+ HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "ID does not contain VOL information")
+
/* get the object type through the VOL */
- if(H5VL_object_get(id, H5VL_REF_GET_NAME, H5_REQUEST_NULL, &ret_value, name, size, ref_type, _ref) < 0)
+ if(H5VL_object_get(obj, loc_params, vol_plugin, H5VL_REF_GET_NAME, H5_REQUEST_NULL,
+ &ret_value, name, size, ref_type, _ref) < 0)
HGOTO_ERROR(H5E_INTERNAL, H5E_CANTGET, FAIL, "unable to get group info")
done:
FUNC_LEAVE_API(ret_value)
diff --git a/src/H5Rdeprec.c b/src/H5Rdeprec.c
index eb9e09f..e6850b2 100644
--- a/src/H5Rdeprec.c
+++ b/src/H5Rdeprec.c
@@ -44,6 +44,7 @@
#include "H5ACprivate.h" /* Metadata cache */
#include "H5Eprivate.h" /* Error handling */
#include "H5Gprivate.h" /* Groups */
+#include "H5Iprivate.h" /* IDs */
#include "H5Oprivate.h" /* Object headers */
#include "H5Rpkg.h" /* References */
#include "H5Ppublic.h" /* for using H5P_DATASET_ACCESS_DEFAULT */
@@ -133,6 +134,9 @@ H5R_init_deprec_interface(void)
H5G_obj_t
H5Rget_obj_type1(hid_t id, H5R_type_t ref_type, const void *ref)
{
+ void *obj = NULL; /* object token of loc_id */
+ H5VL_t *vol_plugin; /* VOL plugin information */
+ H5VL_loc_params_t loc_params;
H5O_type_t obj_type; /* Object type */
H5G_obj_t ret_value; /* Return value */
@@ -145,8 +149,19 @@ H5Rget_obj_type1(hid_t id, H5R_type_t ref_type, const void *ref)
if(ref == NULL)
HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, H5G_UNKNOWN, "invalid reference pointer")
+ loc_params.type = H5VL_OBJECT_BY_SELF;
+ loc_params.obj_type = H5I_get_type(id);
+
+ /* get the file object */
+ if(NULL == (obj = (void *)H5I_object(id)))
+ HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "invalid file identifier")
+ /* get the plugin pointer */
+ if (NULL == (vol_plugin = (H5VL_t *)H5I_get_aux(id)))
+ HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "ID does not contain VOL information")
+
/* get the object type through the VOL */
- if((ret_value = H5VL_object_get(id, H5VL_REF_GET_TYPE, H5_REQUEST_NULL, &obj_type, ref_type, ref)) < 0)
+ if((ret_value = H5VL_object_get(obj, loc_params, vol_plugin, H5VL_REF_GET_TYPE,
+ H5_REQUEST_NULL, &obj_type, ref_type, ref)) < 0)
HGOTO_ERROR(H5E_INTERNAL, H5E_CANTGET, FAIL, "unable to get group info")
/* Set return value */
@@ -182,6 +197,10 @@ done:
hid_t
H5Rdereference1(hid_t obj_id, H5R_type_t ref_type, const void *_ref)
{
+ void *obj = NULL; /* object token of loc_id */
+ H5VL_t *vol_plugin; /* VOL plugin information */
+ H5I_type_t opened_type;
+ void *opened_obj = NULL;
H5VL_loc_params_t loc_params;
hid_t ret_value;
@@ -198,11 +217,16 @@ H5Rdereference1(hid_t obj_id, H5R_type_t ref_type, const void *_ref)
loc_params.loc_data.loc_by_ref.ref_type = ref_type;
loc_params.loc_data.loc_by_ref._ref = _ref;
loc_params.loc_data.loc_by_ref.plist_id = H5P_DATASET_ACCESS_DEFAULT;
+ loc_params.obj_type = H5I_get_type(obj_id);
/* Open the object through the VOL */
- if((ret_value = H5VL_object_open(obj_id, loc_params, H5_REQUEST_NULL)) < 0)
+ if(NULL == (opened_obj = H5VL_object_open(obj, loc_params, vol_plugin, &opened_type, H5_REQUEST_NULL)))
HGOTO_ERROR(H5E_SYM, H5E_CANTINIT, FAIL, "unable to open object")
+ /* Get an atom for the object */
+ if ((ret_value = H5VL_object_register(opened_obj, opened_type, vol_plugin)) < 0)
+ HGOTO_ERROR(H5E_ATOM, H5E_CANTREGISTER, FAIL, "unable to atomize dataset handle")
+
done:
FUNC_LEAVE_API(ret_value)
} /* end H5Rdereference1() */
diff --git a/src/H5Rpkg.h b/src/H5Rpkg.h
index 23de6b6..26a2d02 100644
--- a/src/H5Rpkg.h
+++ b/src/H5Rpkg.h
@@ -63,8 +63,10 @@ H5_DLL hid_t H5R_dereference(H5F_t *file, hid_t dapl_id, hid_t dxpl_id, H5R_type
H5_DLL herr_t H5R_create(void *ref, H5G_loc_t *loc, const char *name,
H5R_type_t ref_type, H5S_t *space, hid_t dxpl_id);
H5_DLL H5S_t * H5R_get_region(H5F_t *file, hid_t dxpl_id, const void *_ref);
-H5_DLL ssize_t H5R_get_name(H5F_t *file, hid_t lapl_id, hid_t dxpl_id, hid_t id,
- H5R_type_t ref_type, const void *_ref, char *name, size_t size);
+H5_DLL ssize_t H5R_get_name(H5G_loc_t *loc, hid_t lapl_id, hid_t dxpl_id, H5R_type_t ref_type,
+ const void *_ref, char *name, size_t size);
+//H5_DLL ssize_t H5R_get_name(H5F_t *file, hid_t lapl_id, hid_t dxpl_id, hid_t id,
+// H5R_type_t ref_type, const void *_ref, char *name, size_t size);
#endif /* _H5Rpkg_H */
diff --git a/src/H5T.c b/src/H5T.c
index 5442098..ef75d41 100644
--- a/src/H5T.c
+++ b/src/H5T.c
@@ -274,8 +274,6 @@ static herr_t H5T_unregister(H5T_pers_t pers, const char *name, H5T_t *src,
static herr_t H5T_register(H5T_pers_t pers, const char *name, H5T_t *src,
H5T_t *dst, H5T_conv_t func, hid_t dxpl_id, hbool_t api_call);
static htri_t H5T_compiler_conv(H5T_t *src, H5T_t *dst);
-static herr_t H5T_encode(H5T_t *obj, unsigned char *buf, size_t *nalloc);
-static H5T_t *H5T_decode(const unsigned char *buf);
static herr_t H5T_set_size(H5T_t *dt, size_t size);
/* Local macro definitions */
@@ -1718,24 +1716,25 @@ H5Tclose(hid_t type_id)
FUNC_ENTER_API(FAIL)
H5TRACE1("e", "i", type_id);
-
+#if 0
/* if this is a named datatype, go through the VOL layer */
-
if(NULL != H5I_get_aux(type_id)) {
if(H5VL_datatype_close(type_id, H5_REQUEST_NULL) < 0)
HGOTO_ERROR(H5E_SYM, H5E_CANTINIT, FAIL, "unable to free datatype")
}
else {
- /* Check args */
- if(NULL == (dt = (H5T_t *)H5I_object_verify(type_id, H5I_DATATYPE)))
- HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a datatype")
- if(H5T_STATE_IMMUTABLE == dt->shared->state)
- HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "immutable datatype")
-
- /* When the reference count reaches zero the resources are freed */
- if(H5I_dec_app_ref(type_id) < 0)
- HGOTO_ERROR(H5E_ATOM, H5E_BADATOM, FAIL, "problem freeing id")
- }
+#endif
+
+ /* Check args */
+ if(NULL == (dt = (H5T_t *)H5I_object_verify(type_id, H5I_DATATYPE)))
+ HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a datatype")
+ if(H5T_STATE_IMMUTABLE == dt->shared->state)
+ HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "immutable datatype")
+
+ /* When the reference count reaches zero the resources are freed */
+ if(H5I_dec_app_ref(type_id) < 0)
+ HGOTO_ERROR(H5E_ATOM, H5E_BADATOM, FAIL, "problem freeing id")
+
done:
FUNC_LEAVE_API(ret_value)
} /* end H5Tclose() */
@@ -2869,7 +2868,7 @@ done:
*
*-------------------------------------------------------------------------
*/
-static herr_t
+herr_t
H5T_encode(H5T_t *obj, unsigned char *buf, size_t *nalloc)
{
size_t buf_size; /* Encoded size of datatype */
@@ -2926,7 +2925,7 @@ done:
*
*-------------------------------------------------------------------------
*/
-static H5T_t *
+H5T_t *
H5T_decode(const unsigned char *buf)
{
H5F_t *f = NULL; /* Fake file structure*/
diff --git a/src/H5Tcommit.c b/src/H5Tcommit.c
index cd4701c..d30cb15 100644
--- a/src/H5Tcommit.c
+++ b/src/H5Tcommit.c
@@ -37,6 +37,7 @@
#include "H5FOprivate.h" /* File objects */
#include "H5Iprivate.h" /* IDs */
#include "H5Lprivate.h" /* Links */
+#include "H5MMprivate.h" /* Memory management */
#include "H5Pprivate.h" /* Property lists */
#include "H5Tpkg.h" /* Datatypes */
#include "H5VLprivate.h" /* VOL plugins */
@@ -122,6 +123,11 @@ herr_t
H5Tcommit2(hid_t loc_id, const char *name, hid_t type_id, hid_t lcpl_id,
hid_t tcpl_id, hid_t tapl_id)
{
+ void *dt = NULL;
+ H5T_t *type = NULL;
+ void *obj = NULL; /* object token of loc_id */
+ H5VL_t *vol_plugin; /* VOL plugin information */
+ H5VL_loc_params_t loc_params;
herr_t ret_value = SUCCEED; /* Return value */
FUNC_ENTER_API(FAIL)
@@ -152,9 +158,34 @@ H5Tcommit2(hid_t loc_id, const char *name, hid_t type_id, hid_t lcpl_id,
if(TRUE != H5P_isa_class(tapl_id, H5P_DATATYPE_ACCESS))
HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not datatype access property list")
- /* commite the datatype through the VOL */
- if((ret_value = H5VL_datatype_commit(loc_id, name, type_id, lcpl_id, tcpl_id, tapl_id, H5_REQUEST_NULL)) < 0)
- HGOTO_ERROR(H5E_SYM, H5E_CANTINIT, FAIL, "unable to commit datatype")
+ loc_params.type = H5VL_OBJECT_BY_SELF;
+ loc_params.obj_type = H5I_get_type(loc_id);
+
+ /* get the file object */
+ if(NULL == (obj = (void *)H5I_object(loc_id)))
+ HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "invalid object identifier")
+ /* get the plugin pointer */
+ if (NULL == (vol_plugin = (H5VL_t *)H5I_get_aux(loc_id)))
+ HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "ID does not contain VOL information")
+
+ /* commit the datatype through the VOL */
+ if (NULL == (dt = H5VL_datatype_commit(obj, loc_params, vol_plugin, name, type_id, lcpl_id,
+ tcpl_id, tapl_id, H5_REQUEST_NULL)))
+ HGOTO_ERROR(H5E_SYM, H5E_CANTINIT, FAIL, "unable to commit datatype")
+
+ /* attach the vol object created using the commit call to the
+ library datatype structure */
+ if(NULL == (type = (H5T_t *)H5I_object_verify(type_id, H5I_DATATYPE)))
+ HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a datatype")
+
+ /* set the committed type object to the VOL pluging pointer in the H5T_t struct */
+ type->vol_obj = dt;
+
+ /* attach VOL information to the ID */
+ if (H5I_register_aux(type_id, vol_plugin, (H5I_free2_t)H5T_close_datatype) < 0)
+ HGOTO_ERROR(H5E_VOL, H5E_CANTINIT, FAIL, "can't attach vol info to ID")
+ vol_plugin->nrefs ++;
+
done:
FUNC_LEAVE_API(ret_value)
} /* end H5Tcommit2() */
@@ -264,8 +295,11 @@ done:
herr_t
H5Tcommit_anon(hid_t loc_id, hid_t type_id, hid_t tcpl_id, hid_t tapl_id)
{
- H5G_loc_t loc; /* Group location for location */
- H5T_t *type = NULL; /* Datatype created */
+ void *dt = NULL;
+ H5T_t *type = NULL;
+ void *obj = NULL; /* object token of loc_id */
+ H5VL_t *vol_plugin; /* VOL plugin information */
+ H5VL_loc_params_t loc_params;
herr_t ret_value = SUCCEED; /* Return value */
FUNC_ENTER_API(FAIL)
@@ -285,10 +319,33 @@ H5Tcommit_anon(hid_t loc_id, hid_t type_id, hid_t tcpl_id, hid_t tapl_id)
if(TRUE != H5P_isa_class(tapl_id, H5P_DATATYPE_ACCESS))
HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not datatype access property list")
+ loc_params.type = H5VL_OBJECT_BY_SELF;
+ loc_params.obj_type = H5I_get_type(loc_id);
+
+ /* get the file object */
+ if(NULL == (obj = (void *)H5I_object(loc_id)))
+ HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "invalid file identifier")
+ /* get the plugin pointer */
+ if (NULL == (vol_plugin = (H5VL_t *)H5I_get_aux(loc_id)))
+ HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "ID does not contain VOL information")
+
/* commite the datatype through the VOL */
- if((ret_value = H5VL_datatype_commit(loc_id, NULL, type_id, 0, tcpl_id, tapl_id,
- H5_REQUEST_NULL)) < 0)
- HGOTO_ERROR(H5E_SYM, H5E_CANTINIT, FAIL, "unable to commit datatype")
+ if (NULL == (dt = H5VL_datatype_commit(obj, loc_params, vol_plugin, NULL, type_id, H5P_DEFAULT,
+ tcpl_id, tapl_id, H5_REQUEST_NULL)))
+ HGOTO_ERROR(H5E_SYM, H5E_CANTINIT, FAIL, "unable to commit datatype")
+
+ /* attach the vol object created using the commit call to the
+ library datatype structure */
+ if(NULL == (type = (H5T_t *)H5I_object_verify(type_id, H5I_DATATYPE)))
+ HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a datatype")
+
+ /* set the committed type object to the VOL pluging pointer in the H5T_t struct */
+ type->vol_obj = dt;
+
+ /* attach VOL information to the ID */
+ if (H5I_register_aux(type_id, vol_plugin, (H5I_free2_t)H5T_close_datatype) < 0)
+ HGOTO_ERROR(H5E_VOL, H5E_CANTINIT, FAIL, "can't attach vol info to ID")
+ vol_plugin->nrefs ++;
done:
FUNC_LEAVE_API(ret_value)
@@ -444,8 +501,12 @@ H5Tcommitted(hid_t type_id)
if(NULL == (type = (H5T_t *)H5I_object_verify(type_id, H5I_DATATYPE)))
HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a datatype")
+ if (NULL == type->vol_obj)
+ ret_value = FALSE;
+ else
+ ret_value = TRUE;
/* Set return value */
- ret_value = H5T_committed(type);
+ //ret_value = H5T_committed(type);
done:
FUNC_LEAVE_API(ret_value)
@@ -526,7 +587,14 @@ done:
hid_t
H5Topen2(hid_t loc_id, const char *name, hid_t tapl_id)
{
- hid_t ret_value = FAIL; /* Return value */
+ void *dt = NULL; /* datatype token from VOL plugin */
+ void *obj = NULL; /* object token of loc_id */
+ H5VL_t *vol_plugin; /* VOL plugin information */
+ H5T_t *type = NULL;
+ H5VL_loc_params_t loc_params;
+ ssize_t nalloc;
+ unsigned char *buf = NULL;
+ hid_t ret_value = FAIL; /* Return value */
FUNC_ENTER_API(FAIL)
H5TRACE3("i", "i*si", loc_id, name, tapl_id);
@@ -542,11 +610,47 @@ H5Topen2(hid_t loc_id, const char *name, hid_t tapl_id)
if(TRUE != H5P_isa_class(tapl_id, H5P_DATATYPE_ACCESS))
HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not datatype access property list")
- /* Open the datatype through the VOL */
- if((ret_value = H5VL_datatype_open(loc_id, name, tapl_id, H5_REQUEST_NULL)) < 0)
+ loc_params.type = H5VL_OBJECT_BY_SELF;
+ loc_params.obj_type = H5I_get_type(loc_id);
+
+ /* get the file object */
+ if(NULL == (obj = (void *)H5I_object(loc_id)))
+ HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "invalid file identifier")
+ /* get the plugin pointer */
+ if (NULL == (vol_plugin = (H5VL_t *)H5I_get_aux(loc_id)))
+ HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "ID does not contain VOL information")
+
+ /* get required buf size for encoding the datatype */
+ if((nalloc = H5VL_datatype_get_size(obj, loc_params, vol_plugin, name, tapl_id, H5_REQUEST_NULL)) < 0)
+ HGOTO_ERROR(H5E_SYM, H5E_CANTINIT, FAIL, "unable to get datatype size")
+
+ buf = (unsigned char *) H5MM_malloc ((size_t)nalloc);
+
+ /* Create the datatype through the VOL */
+ if(NULL == (dt = H5VL_datatype_open(obj, loc_params, vol_plugin, name,
+ buf, (size_t)nalloc, tapl_id,H5_REQUEST_NULL)))
HGOTO_ERROR(H5E_SYM, H5E_CANTINIT, FAIL, "unable to open datatype")
+ if(NULL == (type = H5T_decode(buf)))
+ HGOTO_ERROR(H5E_SYM, H5E_CANTINIT, FAIL, "can't decode datatype")
+ type->vol_obj = dt;
+
+ H5MM_free(buf);
+
+ /* Get an atom for the datatype */
+ if((ret_value = H5I_register(H5I_DATATYPE, type, TRUE)) < 0)
+ HGOTO_ERROR(H5E_ATOM, H5E_CANTREGISTER, FAIL, "unable to atomize datatype handle")
+
+ /* attach VOL information to the ID */
+ if (H5I_register_aux(ret_value, vol_plugin, (H5I_free2_t)H5T_close_datatype) < 0)
+ HGOTO_ERROR(H5E_VOL, H5E_CANTINIT, FAIL, "can't attach vol info to ID")
+
+ vol_plugin->nrefs ++;
+
done:
+ if (ret_value < 0 && dt)
+ if(H5VL_datatype_close (dt, vol_plugin, H5_REQUEST_NULL) < 0)
+ HDONE_ERROR(H5E_SYM, H5E_CLOSEERROR, FAIL, "unable to release dataset")
FUNC_LEAVE_API(ret_value)
} /* end H5Topen2() */
@@ -819,3 +923,71 @@ H5T_update_shared(H5T_t *dt)
FUNC_LEAVE_NOAPI(SUCCEED)
} /* H5T_update_shared() */
+
+/*-------------------------------------------------------------------------
+ * Function: H5T_get_named_type
+ *
+ * Purpose: returns the VOL object or the named datatype structure
+ * if it exists
+ *
+ * Return: Success: Non-negative
+ *
+ * Failure: Negative
+ *
+ * Programmer: Mohamad Chaarawi
+ * June 2012
+ *
+ *-------------------------------------------------------------------------
+ */
+void *
+H5T_get_named_type(H5T_t *dt)
+{
+ void *ret_value = NULL; /* Return value */
+
+ FUNC_ENTER_NOAPI_NOINIT_NOERR
+
+ if(NULL != dt->vol_obj)
+ ret_value = dt->vol_obj;
+
+ FUNC_LEAVE_NOAPI(ret_value)
+} /* end H5T_get_named_type() */
+
+
+/*-------------------------------------------------------------------------
+ * Function: H5T_close_datatype
+ *
+ * Purpose: Called when the ref count reaches zero on the datatype_id
+ *
+ * Return: Success: Non-negative
+ *
+ * Failure: Negative
+ *
+ * Programmer: Mohamad Chaarawi
+ * June 2012
+ *
+ *-------------------------------------------------------------------------
+ */
+herr_t
+H5T_close_datatype(void *type, H5VL_t *vol_plugin)
+{
+ H5T_t *dt = (H5T_t *)type;
+ herr_t ret_value = SUCCEED; /* Return value */
+
+ FUNC_ENTER_NOAPI_NOINIT
+
+ /* Close the datatype through the VOL*/
+ if (NULL != dt->vol_obj)
+ if((ret_value = H5VL_datatype_close(dt->vol_obj, vol_plugin, H5_REQUEST_NULL)) < 0)
+ HGOTO_ERROR(H5E_DATATYPE, H5E_CLOSEERROR, FAIL, "unable to close datatypeibute")
+
+ vol_plugin->nrefs --;
+ if (0 == vol_plugin->nrefs) {
+ if (NULL != vol_plugin->container_name)
+ H5MM_xfree(vol_plugin->container_name);
+ if (NULL != vol_plugin)
+ H5MM_free(vol_plugin);
+ }
+
+done:
+ FUNC_LEAVE_NOAPI(ret_value)
+} /* end H5T_close_datatype() */
diff --git a/src/H5Toh.c b/src/H5Toh.c
index 7961706..e76070f 100644
--- a/src/H5Toh.c
+++ b/src/H5Toh.c
@@ -27,6 +27,7 @@
#include "H5private.h" /* Generic Functions */
#include "H5Eprivate.h" /* Error handling */
#include "H5Iprivate.h" /* IDs */
+#include "H5MMprivate.h" /* Memory management */
#include "H5Opkg.h" /* Object headers */
#include "H5Tpkg.h" /* Datatypes */
@@ -132,6 +133,9 @@ done:
static hid_t
H5O_dtype_open(const H5G_loc_t *obj_loc, hid_t UNUSED lapl_id, hid_t dxpl_id, hbool_t app_ref)
{
+ size_t nalloc;
+ unsigned char *buf = NULL;
+ void *dt = NULL; /* datatype token from VOL plugin */
H5T_t *type = NULL; /* Datatype opened */
hid_t ret_value; /* Return value */
@@ -143,6 +147,16 @@ H5O_dtype_open(const H5G_loc_t *obj_loc, hid_t UNUSED lapl_id, hid_t dxpl_id, hb
if(NULL == (type = H5T_open(obj_loc, dxpl_id)))
HGOTO_ERROR(H5E_DATATYPE, H5E_CANTOPENOBJ, FAIL, "unable to open datatype")
+ if(H5T_encode(type, NULL, &nalloc) < 0)
+ HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "can't determine serialized length of datatype")
+ buf = (unsigned char *) H5MM_malloc (nalloc);
+ if(H5T_encode(type, buf, &nalloc) < 0)
+ HGOTO_ERROR(H5E_DATATYPE, H5E_BADTYPE, FAIL, "can't serialize datatype")
+ if(NULL == (dt = H5T_decode(buf)))
+ HGOTO_ERROR(H5E_SYM, H5E_CANTINIT, FAIL, "can't decode datatype")
+ type->vol_obj = dt;
+ H5MM_free(buf);
+
/* Register an ID for the datatype */
if((ret_value = H5I_register(H5I_DATATYPE, type, app_ref)) < 0)
HGOTO_ERROR(H5E_ATOM, H5E_CANTREGISTER, FAIL, "unable to register datatype")
diff --git a/src/H5Tpkg.h b/src/H5Tpkg.h
index 6736920..662ce59 100644
--- a/src/H5Tpkg.h
+++ b/src/H5Tpkg.h
@@ -396,6 +396,7 @@ struct H5T_t {
H5T_shared_t *shared; /* all other information */
H5O_loc_t oloc; /* Object location, if the type is a named type */
H5G_name_t path; /* group hier. path if the type is a named type */
+ void *vol_obj;
};
/* The master list of soft conversion functions */
diff --git a/src/H5Tprivate.h b/src/H5Tprivate.h
index 0c96896..5902bca 100644
--- a/src/H5Tprivate.h
+++ b/src/H5Tprivate.h
@@ -137,7 +137,9 @@ H5_DLL uint32_t H5T_hash(H5F_t * file, const H5T_t *dt);
H5_DLL herr_t H5T_set_latest_version(H5T_t *dt);
H5_DLL herr_t H5T_patch_file(H5T_t *dt, H5F_t *f);
H5_DLL htri_t H5T_is_variable_str(const H5T_t *dt);
-
+H5_DLL herr_t H5T_encode(H5T_t *obj, unsigned char *buf, size_t *nalloc);
+H5_DLL H5T_t *H5T_decode(const unsigned char *buf);
+H5_DLL void * H5T_get_named_type(H5T_t *dt);
/* Reference specific functions */
H5_DLL H5R_type_t H5T_get_ref_type(const H5T_t *dt);
diff --git a/src/H5VL.c b/src/H5VL.c
index 2d7823f..4a1bfa6 100644
--- a/src/H5VL.c
+++ b/src/H5VL.c
@@ -38,6 +38,7 @@
#include "H5private.h" /* Generic Functions */
#include "H5Eprivate.h" /* Error handling */
#include "H5Iprivate.h" /* IDs */
+#include "H5MMprivate.h" /* Memory management */
#include "H5VLpkg.h" /* VOL package header */
#include "H5VLprivate.h" /* VOL */
@@ -326,3 +327,75 @@ H5VLget_plugin_name(hid_t id, char *name/*out*/, size_t size)
done:
FUNC_LEAVE_API(ret_value)
} /* end H5VLget_plugin_name() */
+
+
+/*---------------------------------------------------------------------------
+ * Function: H5VLregister_object
+ *
+ * Purpose: utility routine to register the native VOL plugin to an ID
+ *
+ * Returns: Non-negative on success or negative on failure
+ *
+ * Programmer: Mohamad Chaarawi
+ * June, 2012
+ *
+ *---------------------------------------------------------------------------
+ */
+hid_t
+H5VLregister_object(void *obj, H5I_type_t obj_type, const H5VL_class_t *cls)
+{
+ H5VL_t *vol_plugin; /* VOL plugin information */
+ hid_t ret_value = FAIL;
+
+ FUNC_ENTER_NOAPI_NOINIT
+
+ /* Get an atom for the object */
+ if((ret_value = H5I_register(obj_type, obj, TRUE)) < 0)
+ HGOTO_ERROR(H5E_ATOM, H5E_CANTREGISTER, FAIL, "unable to atomize object")
+
+ /* Build the vol plugin struct */
+ if(NULL == (vol_plugin = (H5VL_t *)H5MM_calloc(sizeof(H5VL_t))))
+ HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, FAIL, "memory allocation failed")
+ vol_plugin->cls = cls;
+ vol_plugin->nrefs = 1;
+
+ switch(obj_type) {
+ case H5I_FILE:
+ if (H5I_register_aux(ret_value, vol_plugin, (H5I_free2_t)H5F_close_file) < 0)
+ HGOTO_ERROR(H5E_VOL, H5E_CANTINIT, FAIL, "can't attach vol info to ID")
+ break;
+ case H5I_GROUP:
+ if (H5I_register_aux(ret_value, vol_plugin, (H5I_free2_t)H5G_close_group) < 0)
+ HGOTO_ERROR(H5E_VOL, H5E_CANTINIT, FAIL, "can't attach vol info to ID")
+ break;
+ case H5I_DATATYPE:
+ if (H5I_register_aux(ret_value, vol_plugin, (H5I_free2_t)H5T_close_datatype) < 0)
+ HGOTO_ERROR(H5E_VOL, H5E_CANTINIT, FAIL, "can't attach vol info to ID")
+ break;
+ case H5I_DATASET:
+ if (H5I_register_aux(ret_value, vol_plugin, (H5I_free2_t)H5D_close_dataset) < 0)
+ HGOTO_ERROR(H5E_VOL, H5E_CANTINIT, FAIL, "can't attach vol info to ID")
+ break;
+ case H5I_ATTR:
+ if (H5I_register_aux(ret_value, vol_plugin, (H5I_free2_t)H5A_close_attr) < 0)
+ HGOTO_ERROR(H5E_VOL, H5E_CANTINIT, FAIL, "can't attach vol info to ID")
+ break;
+ case H5I_FILE_PRIVATE:
+ case H5I_UNINIT:
+ case H5I_BADID:
+ case H5I_DATASPACE:
+ case H5I_REFERENCE:
+ case H5I_VFL:
+ case H5I_VOL:
+ case H5I_GENPROP_CLS:
+ case H5I_GENPROP_LST:
+ case H5I_ERROR_CLASS:
+ case H5I_ERROR_MSG:
+ case H5I_ERROR_STACK:
+ case H5I_NTYPES:
+ default:
+ HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a file or file object")
+ } /* end switch */
+done:
+ FUNC_LEAVE_NOAPI(ret_value)
+} /* H5VLregister_object */
diff --git a/src/H5VLint.c b/src/H5VLint.c
index 879de95..9f5fd91 100644
--- a/src/H5VLint.c
+++ b/src/H5VLint.c
@@ -217,7 +217,7 @@ done:
*-------------------------------------------------------------------------
*/
herr_t
-H5VL_fapl_close(H5VL_class_t *vol_cls, const void *vol_info)
+H5VL_fapl_close(H5VL_class_t UNUSED *vol_cls, const void UNUSED *vol_info)
{
herr_t ret_value = SUCCEED; /* Return value */
@@ -242,7 +242,7 @@ done:
*-------------------------------------------------------------------------
*/
herr_t
-H5VL_close(H5VL_class_t *vol_plugin)
+H5VL_close(H5VL_class_t UNUSED *vol_plugin)
{
herr_t ret_value = SUCCEED;
@@ -269,19 +269,19 @@ done:
ssize_t
H5VL_get_plugin_name(hid_t id, char *name/*out*/, size_t size)
{
- H5VL_class_t *vol_plugin; /* VOL structure attached to id */
- size_t len;
- ssize_t ret_value;
+ H5VL_t *vol_plugin; /* VOL structure attached to id */
+ size_t len;
+ ssize_t ret_value;
FUNC_ENTER_NOAPI(FAIL)
- if (NULL == (vol_plugin = (H5VL_class_t *)H5I_get_aux (id)))
+ if (NULL == (vol_plugin = (H5VL_t *)H5I_get_aux (id)))
HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "Object/File does not contain VOL information")
- len = HDstrlen(vol_plugin->name);
+ len = HDstrlen(vol_plugin->cls->name);
if(name) {
- HDstrncpy(name, vol_plugin->name, MIN(len + 1,size));
+ HDstrncpy(name, vol_plugin->cls->name, MIN(len + 1,size));
if(len >= size)
name[size-1]='\0';
} /* end if */
@@ -295,41 +295,100 @@ done:
/*-------------------------------------------------------------------------
+ * Function: H5VL_object_register
+ *
+ * Purpose: utility function to create a user id for an object created
+ * or opened through the VOL
+ *
+ * Return: Success: registered ID
+ * Failure: FAIL
+ *
+ * Programmer: Mohamad Chaarawi
+ * June, 2012
+ *
+ *-------------------------------------------------------------------------
+ */
+hid_t
+H5VL_object_register(void *obj, H5I_type_t obj_type, H5VL_t *vol_plugin)
+{
+ hid_t ret_value = FAIL;
+
+ FUNC_ENTER_NOAPI(FAIL)
+
+ /* Get an atom for the object */
+ if((ret_value = H5I_register(obj_type, obj, TRUE)) < 0)
+ HGOTO_ERROR(H5E_ATOM, H5E_CANTREGISTER, FAIL, "unable to atomize object")
+
+ /* attach VOL information and free function to the ID */
+ switch(obj_type) {
+ case H5I_GROUP:
+ if (H5I_register_aux(ret_value, vol_plugin, (H5I_free2_t)H5G_close_group) < 0)
+ HGOTO_ERROR(H5E_VOL, H5E_CANTINIT, FAIL, "can't attach vol info to ID")
+ break;
+
+ case H5I_DATASET:
+ if (H5I_register_aux(ret_value, vol_plugin, (H5I_free2_t)H5D_close_dataset) < 0)
+ HGOTO_ERROR(H5E_VOL, H5E_CANTINIT, FAIL, "can't attach vol info to ID")
+ break;
+
+ case H5I_DATATYPE:
+ if (H5I_register_aux(ret_value, vol_plugin, (H5I_free2_t)H5T_close_datatype) < 0)
+ HGOTO_ERROR(H5E_VOL, H5E_CANTINIT, FAIL, "can't attach vol info to ID")
+ break;
+
+ case H5I_FILE_PRIVATE:
+ case H5I_UNINIT:
+ case H5I_BADID:
+ case H5I_FILE:
+ case H5I_DATASPACE:
+ case H5I_ATTR:
+ case H5I_REFERENCE:
+ case H5I_VFL:
+ case H5I_VOL:
+ case H5I_GENPROP_CLS:
+ case H5I_GENPROP_LST:
+ case H5I_ERROR_CLASS:
+ case H5I_ERROR_MSG:
+ case H5I_ERROR_STACK:
+ case H5I_NTYPES:
+ default:
+ HGOTO_ERROR(H5E_OHDR, H5E_BADTYPE, FAIL, "invalid object type")
+ } /* end switch */
+
+ vol_plugin->nrefs ++;
+done:
+ FUNC_LEAVE_NOAPI(ret_value)
+} /* end H5VL_object_register() */
+
+
+/*-------------------------------------------------------------------------
* Function: H5VL_attr_create
*
* Purpose: Creates an attribute through the VOL
*
- * Return: Success: User ID of the new attr.
+ * Return: Success: pointer to the new attr.
*
- * Failure: FAIL
+ * Failure: NULL
*
* Programmer: Mohamad Chaarawi
* April, 2012
*
*-------------------------------------------------------------------------
*/
-hid_t
-H5VL_attr_create(hid_t id, const char *name, hid_t acpl_id, hid_t aapl_id, hid_t req)
+void *
+H5VL_attr_create(void *obj, H5VL_loc_params_t loc_params, H5VL_t *vol_plugin, const char *name,
+ hid_t acpl_id, hid_t aapl_id, hid_t req)
{
- H5VL_class_t *vol_plugin; /* VOL structure attached to id */
- hid_t ret_value; /* Return value */
+ void *ret_value; /* Return value */
- FUNC_ENTER_NOAPI(FAIL)
-
- if (NULL == (vol_plugin = (H5VL_class_t *)H5I_get_aux (id)))
- HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "ID does not contain VOL information")
+ FUNC_ENTER_NOAPI(NULL)
/* check if the corresponding VOL create callback exists */
- if(NULL == vol_plugin->attr_cls.create)
- HGOTO_ERROR(H5E_VOL, H5E_UNSUPPORTED, FAIL, "vol plugin has no `attr create' method")
-
+ if(NULL == vol_plugin->cls->attr_cls.create)
+ HGOTO_ERROR(H5E_VOL, H5E_UNSUPPORTED, NULL, "vol plugin has no `attr create' method")
/* call the corresponding VOL create callback */
- if((ret_value = (vol_plugin->attr_cls.create) (id, name, acpl_id, aapl_id, req)) < 0)
- HGOTO_ERROR(H5E_VOL, H5E_CANTINIT, FAIL, "create failed")
-
- /* attach VOL information to the ID */
- if (H5I_register_aux(ret_value, vol_plugin, (H5I_free_t)H5VL_close) < 0)
- HGOTO_ERROR(H5E_VOL, H5E_CANTINIT, FAIL, "can't attach vol info to ID")
+ if(NULL == (ret_value = (vol_plugin->cls->attr_cls.create) (obj, loc_params, name, acpl_id, aapl_id, req)))
+ HGOTO_ERROR(H5E_VOL, H5E_CANTINIT, NULL, "create failed")
done:
FUNC_LEAVE_NOAPI(ret_value)
@@ -341,38 +400,28 @@ done:
*
* Purpose: Opens an attribute through the VOL
*
- * Return: Success: User ID of the new attr.
+ * Return: Success: pointer to the new attr.
*
- * Failure: FAIL
+ * Failure: NULL
*
* Programmer: Mohamad Chaarawi
* March, 2012
*
*-------------------------------------------------------------------------
*/
-hid_t
-H5VL_attr_open(hid_t id, H5VL_loc_params_t loc_params, const char *name, hid_t aapl_id, hid_t req)
+void *
+H5VL_attr_open(void *obj, H5VL_loc_params_t loc_params, H5VL_t *vol_plugin, const char *name, hid_t aapl_id, hid_t req)
{
- H5VL_class_t *vol_plugin; /* VOL structure attached to id */
- hid_t ret_value; /* Return value */
+ void *ret_value; /* Return value */
- FUNC_ENTER_NOAPI(FAIL)
-
- if (NULL == (vol_plugin = (H5VL_class_t *)H5I_get_aux (id)))
- HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "ID does not contain VOL information")
+ FUNC_ENTER_NOAPI(NULL)
/* check if the type specific corresponding VOL open callback exists */
- if(NULL == vol_plugin->attr_cls.open) {
- HGOTO_ERROR(H5E_VOL, H5E_UNSUPPORTED, FAIL, "vol plugin has no `attr open' method")
- }
-
+ if(NULL == vol_plugin->cls->attr_cls.open)
+ HGOTO_ERROR(H5E_VOL, H5E_UNSUPPORTED, NULL, "vol plugin has no `attr open' method")
/* call the corresponding VOL open callback */
- if((ret_value = (vol_plugin->attr_cls.open) (id, loc_params, name, aapl_id, req)) < 0)
- HGOTO_ERROR(H5E_VOL, H5E_CANTINIT, FAIL, "open failed")
-
- /* attach VOL information to the ID */
- if (H5I_register_aux(ret_value, vol_plugin, (H5I_free_t)H5VL_close) < 0)
- HGOTO_ERROR(H5E_VOL, H5E_CANTINIT, FAIL, "can't attach vol info to ID")
+ if(NULL == (ret_value = (vol_plugin->cls->attr_cls.open) (obj, loc_params, name, aapl_id, req)))
+ HGOTO_ERROR(H5E_VOL, H5E_CANTINIT, NULL, "attribute open failed")
done:
FUNC_LEAVE_NOAPI(ret_value)
@@ -393,19 +442,15 @@ done:
*
*-------------------------------------------------------------------------
*/
-herr_t H5VL_attr_read(hid_t id, hid_t mem_type_id, void *buf, hid_t req)
+herr_t H5VL_attr_read(void *attr, H5VL_t *vol_plugin, hid_t mem_type_id, void *buf, hid_t req)
{
- H5VL_class_t *vol_plugin; /* VOL structure attached to id */
herr_t ret_value = SUCCEED;
FUNC_ENTER_NOAPI(FAIL)
- if (NULL == (vol_plugin = (H5VL_class_t *)H5I_get_aux (id)))
- HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "ID does not contain VOL information")
-
- if(NULL == vol_plugin->attr_cls.read)
+ if(NULL == vol_plugin->cls->attr_cls.read)
HGOTO_ERROR(H5E_VOL, H5E_UNSUPPORTED, FAIL, "vol plugin has no `attr read' method")
- if((ret_value = (vol_plugin->attr_cls.read)(id, mem_type_id, buf, req)) < 0)
+ if((ret_value = (vol_plugin->cls->attr_cls.read)(attr, mem_type_id, buf, req)) < 0)
HGOTO_ERROR(H5E_VOL, H5E_CANTRELEASE, FAIL, "read failed")
done:
@@ -427,19 +472,15 @@ done:
*
*-------------------------------------------------------------------------
*/
-herr_t H5VL_attr_write(hid_t id, hid_t mem_type_id, const void *buf, hid_t req)
+herr_t H5VL_attr_write(void *attr, H5VL_t *vol_plugin, hid_t mem_type_id, const void *buf, hid_t req)
{
- H5VL_class_t *vol_plugin; /* VOL structure attached to id */
herr_t ret_value = SUCCEED;
FUNC_ENTER_NOAPI(FAIL)
- if (NULL == (vol_plugin = (H5VL_class_t *)H5I_get_aux (id)))
- HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "ID does not contain VOL information")
-
- if(NULL == vol_plugin->attr_cls.write)
+ if(NULL == vol_plugin->cls->attr_cls.write)
HGOTO_ERROR(H5E_VOL, H5E_UNSUPPORTED, FAIL, "vol plugin has no `attr write' method")
- if((ret_value = (vol_plugin->attr_cls.write)(id, mem_type_id, buf, req)) < 0)
+ if((ret_value = (vol_plugin->cls->attr_cls.write)(attr, mem_type_id, buf, req)) < 0)
HGOTO_ERROR(H5E_VOL, H5E_CANTRELEASE, FAIL, "write failed")
done:
@@ -462,25 +503,20 @@ done:
*-------------------------------------------------------------------------
*/
herr_t
-H5VL_attr_get(hid_t id, H5VL_attr_get_t get_type, hid_t req, ...)
+H5VL_attr_get(void *obj, H5VL_t *vol_plugin, H5VL_attr_get_t get_type, hid_t req, ...)
{
va_list arguments; /* argument list passed from the API call */
- H5VL_class_t *vol_plugin; /* VOL structure attached to id */
herr_t ret_value = SUCCEED;
FUNC_ENTER_NOAPI(FAIL)
- if (NULL == (vol_plugin = (H5VL_class_t *)H5I_get_aux (id)))
- HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "ID does not contain VOL information")
-
- if(NULL == vol_plugin->attr_cls.get)
+ if(NULL == vol_plugin->cls->attr_cls.get)
HGOTO_ERROR(H5E_VOL, H5E_UNSUPPORTED, FAIL, "vol plugin has no `attr get' method")
-
va_start (arguments, req);
- if((ret_value = (vol_plugin->attr_cls.get)(id, get_type, req, arguments)) < 0)
+ if((ret_value = (vol_plugin->cls->attr_cls.get)(obj, get_type, req, arguments)) < 0)
HGOTO_ERROR(H5E_VOL, H5E_CANTGET, FAIL, "get failed")
va_end (arguments);
-
+#if 0
/* if the get_type is a named datatype, attach the vol info to it */
if(H5VL_ATTR_GET_TYPE == get_type) {
hid_t *ret_id;
@@ -495,7 +531,7 @@ H5VL_attr_get(hid_t id, H5VL_attr_get_t get_type, hid_t req, ...)
}
va_end (arguments);
}
-
+#endif
done:
FUNC_LEAVE_NOAPI(ret_value)
} /* end H5VL_attr_get() */
@@ -516,17 +552,16 @@ done:
*-------------------------------------------------------------------------
*/
herr_t
-H5VL_attr_remove(hid_t id, H5VL_loc_params_t loc_params, const char *attr_name, hid_t req)
+H5VL_attr_remove(void *obj, H5VL_loc_params_t loc_params, H5VL_t *vol_plugin,
+ const char *attr_name, hid_t req)
{
- H5VL_class_t *vol_plugin; /* VOL structure attached to id */
herr_t ret_value = SUCCEED;
FUNC_ENTER_NOAPI(FAIL)
- if (NULL == (vol_plugin = (H5VL_class_t *)H5I_get_aux (id)))
- HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "ID does not contain VOL information")
-
- if((ret_value = (vol_plugin->attr_cls.remove)(id, loc_params, attr_name, req)) < 0)
+ if(NULL == vol_plugin->cls->attr_cls.remove)
+ HGOTO_ERROR(H5E_VOL, H5E_UNSUPPORTED, FAIL, "vol plugin has no `attr remove' method")
+ if((ret_value = (vol_plugin->cls->attr_cls.remove)(obj, loc_params, attr_name, req)) < 0)
HGOTO_ERROR(H5E_VOL, H5E_CANTDELETE, FAIL, "remove failed")
done:
@@ -549,26 +584,23 @@ done:
*-------------------------------------------------------------------------
*/
herr_t
-H5VL_attr_close(hid_t id, hid_t req)
+H5VL_attr_close(void *attr, H5VL_t *vol_plugin, hid_t req)
{
- H5VL_class_t *vol_plugin; /* VOL structure attached to id */
herr_t ret_value = SUCCEED;
FUNC_ENTER_NOAPI(FAIL)
-
- if (NULL == (vol_plugin = (H5VL_class_t *)H5I_get_aux(id)))
- HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "ID does not contain VOL information")
/* if the VOL class does not implement a specific attr close
callback, try the object close */
- if(NULL == vol_plugin->attr_cls.close){
+ if(NULL == vol_plugin->cls->attr_cls.close){
+ HGOTO_ERROR(H5E_VOL, H5E_UNSUPPORTED, FAIL, "vol plugin has no `attr close' method")
+ /*
if(H5VL_object_close(id, req) < 0)
HGOTO_ERROR(H5E_SYM, H5E_CANTRELEASE, FAIL, "unable to close object")
+ */
}
- else {
- if((ret_value = (vol_plugin->attr_cls.close)(id, req)) < 0)
- HGOTO_ERROR(H5E_VOL, H5E_CANTRELEASE, FAIL, "close failed")
- }
+ else if((ret_value = (vol_plugin->cls->attr_cls.close)(attr, req)) < 0)
+ HGOTO_ERROR(H5E_VOL, H5E_CANTRELEASE, FAIL, "close failed")
done:
FUNC_LEAVE_NOAPI(ret_value)
} /* end H5VL_attr_close() */
@@ -588,29 +620,22 @@ done:
*
*-------------------------------------------------------------------------
*/
-herr_t
-H5VL_datatype_commit(hid_t id, const char *name, hid_t type_id, hid_t lcpl_id,
- hid_t tcpl_id, hid_t tapl_id, hid_t req)
+void *
+H5VL_datatype_commit(void *obj, H5VL_loc_params_t loc_params, H5VL_t *vol_plugin, const char *name,
+ hid_t type_id, hid_t lcpl_id, hid_t tcpl_id, hid_t tapl_id, hid_t req)
{
- H5VL_class_t *vol_plugin; /* VOL structure attached to id */
- herr_t ret_value = SUCCEED; /* Return value */
-
- FUNC_ENTER_NOAPI(FAIL)
+ void *ret_value = NULL; /* Return value */
- if (NULL == (vol_plugin = (H5VL_class_t *)H5I_get_aux(id)))
- HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "ID does not contain VOL information")
+ FUNC_ENTER_NOAPI(NULL)
/* check if the corresponding VOL commit callback exists */
- if(NULL == vol_plugin->datatype_cls.commit)
- HGOTO_ERROR(H5E_VOL, H5E_UNSUPPORTED, FAIL, "vol plugin has no `datatype commit' method")
+ if(NULL == vol_plugin->cls->datatype_cls.commit)
+ HGOTO_ERROR(H5E_VOL, H5E_UNSUPPORTED, NULL, "vol plugin has no `datatype commit' method")
/* call the corresponding VOL commit callback */
- if((ret_value = (vol_plugin->datatype_cls.commit)
- (id, name, type_id, lcpl_id, tcpl_id, tapl_id, req)) < 0)
- HGOTO_ERROR(H5E_VOL, H5E_CANTINIT, FAIL, "commit failed")
-
- if (H5I_register_aux(type_id, vol_plugin, (H5I_free_t)H5VL_close) < 0)
- HGOTO_ERROR(H5E_VOL, H5E_CANTINIT, FAIL, "can't attach vol info to ID")
+ if(NULL == (ret_value = (vol_plugin->cls->datatype_cls.commit)
+ (obj, loc_params, name, type_id, lcpl_id, tcpl_id, tapl_id, req)))
+ HGOTO_ERROR(H5E_VOL, H5E_CANTINIT, NULL, "commit failed")
done:
FUNC_LEAVE_NOAPI(ret_value)
@@ -624,26 +649,25 @@ done:
*
* Return: Success: User ID of the datatype.
*
- * Failure: FAIL
+ * Failure: NULL
*
* Programmer: Mohamad Chaarawi
* March, 2012
*
*-------------------------------------------------------------------------
*/
-hid_t
-H5VL_datatype_open(hid_t id, const char *name, hid_t tapl_id, hid_t req)
+void *
+H5VL_datatype_open(void *obj, H5VL_loc_params_t loc_params, H5VL_t *vol_plugin, const char *name,
+ unsigned char *buf, size_t nalloc, hid_t tapl_id, hid_t req)
{
- H5VL_class_t *vol_plugin; /* VOL structure attached to id */
- hid_t ret_value; /* Return value */
-
- FUNC_ENTER_NOAPI(FAIL)
+ void *ret_value = NULL; /* Return value */
- if (NULL == (vol_plugin = (H5VL_class_t *)H5I_get_aux(id)))
- HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "ID does not contain VOL information")
+ FUNC_ENTER_NOAPI(NULL)
/* check if the type specific corresponding VOL open callback exists */
- if(NULL == vol_plugin->datatype_cls.open) {
+ if(NULL == vol_plugin->cls->datatype_cls.open)
+ HGOTO_ERROR(H5E_VOL, H5E_CANTINIT, NULL, "no datatype open callback");
+#if 0
H5VL_loc_params_t loc_params;
loc_params.type = H5VL_OBJECT_BY_NAME;
@@ -652,23 +676,50 @@ H5VL_datatype_open(hid_t id, const char *name, hid_t tapl_id, hid_t req)
/* Open the object class */
if((ret_value = H5VL_object_open(id, loc_params, H5_REQUEST_NULL)) < 0)
- HGOTO_ERROR(H5E_SYM, H5E_CANTINIT, FAIL, "unable to open object")
- }
- else {
- /* call the corresponding VOL open callback */
- if((ret_value = (vol_plugin->datatype_cls.open)(id, name, tapl_id, req)) < 0)
- HGOTO_ERROR(H5E_VOL, H5E_CANTINIT, FAIL, "open failed")
-
- /* attach VOL information to the ID */
- if (H5I_register_aux(ret_value, vol_plugin, (H5I_free_t)H5VL_close) < 0)
- HGOTO_ERROR(H5E_VOL, H5E_CANTINIT, FAIL, "can't attach vol info to ID")
- }
+ HGOTO_ERROR(H5E_SYM, H5E_CANTINIT, NULL, "unable to open object")
+#endif
+ /* call the corresponding VOL open callback */
+ if(NULL == (ret_value = (vol_plugin->cls->datatype_cls.open)(obj, loc_params, name, buf, nalloc, tapl_id, req)))
+ HGOTO_ERROR(H5E_VOL, H5E_CANTINIT, NULL, "open failed")
done:
FUNC_LEAVE_NOAPI(ret_value)
} /* end H5VL_datatype_open() */
/*-------------------------------------------------------------------------
+ * Function: H5VL_datatype_get_size
+ *
+ * Purpose: gets required size to serialize datatype description
+ *
+ * Return: Success: size needed
+ *
+ * Failure: negative
+ *
+ * Programmer: Mohamad Chaarawi
+ * March, 2012
+ *
+ *-------------------------------------------------------------------------
+ */
+ssize_t
+H5VL_datatype_get_size(void *obj, H5VL_loc_params_t loc_params, H5VL_t *vol_plugin,
+ const char *name, hid_t tapl_id, hid_t req)
+{
+ ssize_t ret_value = FAIL;
+
+ FUNC_ENTER_NOAPI(FAIL)
+
+ /* check if the type specific corresponding VOL open callback exists */
+ if(NULL == vol_plugin->cls->datatype_cls.get_size)
+ HGOTO_ERROR(H5E_VOL, H5E_CANTINIT, FAIL, "no datatype open callback");
+ /* call the corresponding VOL open callback */
+ if((ret_value = (vol_plugin->cls->datatype_cls.get_size)(obj, loc_params, name, tapl_id, req)) < 0)
+ HGOTO_ERROR(H5E_VOL, H5E_CANTINIT, FAIL, "open failed")
+done:
+ FUNC_LEAVE_NOAPI(ret_value)
+} /* end H5VL_datatype_get_size() */
+
+
+/*-------------------------------------------------------------------------
* Function: H5VL_datatype_close
*
* Purpose: Closes a datatype through the VOL
@@ -682,22 +733,18 @@ done:
*-------------------------------------------------------------------------
*/
herr_t
-H5VL_datatype_close(hid_t id, hid_t req)
+H5VL_datatype_close(void *dt, H5VL_t *vol_plugin, hid_t req)
{
- H5VL_class_t *vol_plugin; /* VOL structure attached to id */
herr_t ret_value = SUCCEED; /* Return value */
FUNC_ENTER_NOAPI(FAIL)
- if (NULL == (vol_plugin = (H5VL_class_t *)H5I_get_aux(id)))
- HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "ID does not contain VOL information")
-
/* check if the corresponding VOL close callback exists */
- if(NULL == vol_plugin->datatype_cls.close)
+ if(NULL == vol_plugin->cls->datatype_cls.close)
HGOTO_ERROR(H5E_VOL, H5E_UNSUPPORTED, FAIL, "vol plugin has no `datatype close' method")
/* call the corresponding VOL close callback */
- if((ret_value = (vol_plugin->datatype_cls.close)(id, req)) < 0)
+ if((ret_value = (vol_plugin->cls->datatype_cls.close)(dt, req)) < 0)
HGOTO_ERROR(H5E_VOL, H5E_CANTRELEASE, FAIL, "close failed")
done:
@@ -710,37 +757,29 @@ done:
*
* Purpose: Creates a dataset through the VOL
*
- * Return: Success: User ID of the new dataset.
+ * Return: Success: pointer to dataset
*
- * Failure: FAIL
+ * Failure: NULL
*
* Programmer: Mohamad Chaarawi
* March, 2012
*
*-------------------------------------------------------------------------
*/
-hid_t
-H5VL_dataset_create(hid_t id, const char *name, hid_t dcpl_id, hid_t dapl_id, hid_t req)
+void *
+H5VL_dataset_create(void *obj, H5VL_loc_params_t loc_params, H5VL_t *vol_plugin, const char *name,
+ hid_t dcpl_id, hid_t dapl_id, hid_t req)
{
- H5VL_class_t *vol_plugin; /* VOL structure attached to id */
- hid_t ret_value; /* Return value */
+ void *ret_value; /* Return value */
- FUNC_ENTER_NOAPI(FAIL)
-
- if (NULL == (vol_plugin = (H5VL_class_t *)H5I_get_aux(id)))
- HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "ID does not contain VOL information")
+ FUNC_ENTER_NOAPI(NULL)
/* check if the corresponding VOL create callback exists */
- if(NULL == vol_plugin->dataset_cls.create)
- HGOTO_ERROR(H5E_VOL, H5E_UNSUPPORTED, FAIL, "vol plugin has no `dataset create' method")
-
+ if(NULL == vol_plugin->cls->dataset_cls.create)
+ HGOTO_ERROR(H5E_VOL, H5E_UNSUPPORTED, NULL, "vol plugin has no `dataset create' method")
/* call the corresponding VOL create callback */
- if((ret_value = (vol_plugin->dataset_cls.create)(id, name, dcpl_id, dapl_id, req)) < 0)
- HGOTO_ERROR(H5E_VOL, H5E_CANTINIT, FAIL, "create failed")
-
- /* attach VOL information to the ID */
- if (H5I_register_aux(ret_value, vol_plugin, (H5I_free_t)H5VL_close) < 0)
- HGOTO_ERROR(H5E_VOL, H5E_CANTINIT, FAIL, "can't attach vol info to ID")
+ if(NULL == (ret_value = (vol_plugin->cls->dataset_cls.create)(obj, loc_params, name, dcpl_id, dapl_id, req)))
+ HGOTO_ERROR(H5E_VOL, H5E_CANTINIT, NULL, "create failed")
done:
FUNC_LEAVE_NOAPI(ret_value)
@@ -752,46 +791,36 @@ done:
*
* Purpose: Opens a dataset through the VOL
*
- * Return: Success: User ID of the new dataset.
+ * Return: Success: pointer to dataset
*
- * Failure: FAIL
+ * Failure: NULL
*
* Programmer: Mohamad Chaarawi
* March, 2012
*
*-------------------------------------------------------------------------
*/
-hid_t
-H5VL_dataset_open(hid_t id, const char *name, hid_t dapl_id, hid_t req)
+void *
+H5VL_dataset_open(void *obj, H5VL_loc_params_t loc_params, H5VL_t *vol_plugin, const char *name,
+ hid_t dapl_id, hid_t req)
{
- H5VL_class_t *vol_plugin; /* VOL structure attached to id */
- hid_t ret_value; /* Return value */
-
- FUNC_ENTER_NOAPI(FAIL)
+ void *ret_value; /* Return value */
- if (NULL == (vol_plugin = (H5VL_class_t *)H5I_get_aux(id)))
- HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "ID does not contain VOL information")
+ FUNC_ENTER_NOAPI(NULL)
/* check if the type specific corresponding VOL open callback exists */
- if(NULL == vol_plugin->dataset_cls.open) {
- H5VL_loc_params_t loc_params;
-
- loc_params.type = H5VL_OBJECT_BY_NAME;
- loc_params.loc_data.loc_by_name.name = name;
- loc_params.loc_data.loc_by_name.plist_id = dapl_id;
-
+ if(NULL == vol_plugin->cls->dataset_cls.open) {
+ ;
+#if 0
/* Open the object class */
if((ret_value = H5VL_object_open(id, loc_params, H5_REQUEST_NULL)) < 0)
- HGOTO_ERROR(H5E_SYM, H5E_CANTINIT, FAIL, "unable to open object")
+ HGOTO_ERROR(H5E_SYM, H5E_CANTINIT, NULL, "unable to open object")
+#endif
}
else {
/* call the corresponding VOL open callback */
- if((ret_value = (vol_plugin->dataset_cls.open)(id, name, dapl_id, req)) < 0)
- HGOTO_ERROR(H5E_VOL, H5E_CANTINIT, FAIL, "open failed")
-
- /* attach VOL information to the ID */
- if (H5I_register_aux(ret_value, vol_plugin, (H5I_free_t)H5VL_close) < 0)
- HGOTO_ERROR(H5E_VOL, H5E_CANTINIT, FAIL, "can't attach vol info to ID")
+ if(NULL == (ret_value = (vol_plugin->cls->dataset_cls.open)(obj, loc_params, name, dapl_id, req)))
+ HGOTO_ERROR(H5E_VOL, H5E_CANTINIT, NULL, "open failed")
}
done:
FUNC_LEAVE_NOAPI(ret_value)
@@ -802,7 +831,7 @@ done:
* Function: H5VL_dataset_read
*
* Purpose: Reads data from dataset through the VOL
- *
+*
* Return: Success: Non Negative
*
* Failure: Negative
@@ -812,22 +841,18 @@ done:
*
*-------------------------------------------------------------------------
*/
-herr_t H5VL_dataset_read(hid_t id, hid_t mem_type_id, hid_t mem_space_id,
- hid_t file_space_id, hid_t plist_id, void *buf, hid_t req)
+herr_t
+H5VL_dataset_read(void *dset, H5VL_t *vol_plugin, hid_t mem_type_id, hid_t mem_space_id,
+ hid_t file_space_id, hid_t plist_id, void *buf, hid_t req)
{
- H5VL_class_t *vol_plugin; /* VOL structure attached to id */
herr_t ret_value = SUCCEED;
FUNC_ENTER_NOAPI(FAIL)
- if (NULL == (vol_plugin = (H5VL_class_t *)H5I_get_aux(id)))
- HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "ID does not contain VOL information")
-
- if(NULL == vol_plugin->dataset_cls.read)
+ if(NULL == vol_plugin->cls->dataset_cls.read)
HGOTO_ERROR(H5E_VOL, H5E_UNSUPPORTED, FAIL, "vol plugin has no `dataset read' method")
-
- if((ret_value = (vol_plugin->dataset_cls.read)
- (id, mem_type_id, mem_space_id, file_space_id, plist_id, buf, req)) < 0)
+ if((ret_value = (vol_plugin->cls->dataset_cls.read)
+ (dset, mem_type_id, mem_space_id, file_space_id, plist_id, buf, req)) < 0)
HGOTO_ERROR(H5E_VOL, H5E_READERROR, FAIL, "read failed")
done:
@@ -849,22 +874,18 @@ done:
*
*-------------------------------------------------------------------------
*/
-herr_t H5VL_dataset_write(hid_t id, hid_t mem_type_id, hid_t mem_space_id,
- hid_t file_space_id, hid_t plist_id, const void *buf, hid_t req)
+herr_t
+H5VL_dataset_write(void *dset, H5VL_t *vol_plugin, hid_t mem_type_id, hid_t mem_space_id,
+ hid_t file_space_id, hid_t plist_id, const void *buf, hid_t req)
{
- H5VL_class_t *vol_plugin; /* VOL structure attached to id */
herr_t ret_value = SUCCEED;
FUNC_ENTER_NOAPI(FAIL)
- if (NULL == (vol_plugin = (H5VL_class_t *)H5I_get_aux(id)))
- HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "ID does not contain VOL information")
-
- if(NULL == vol_plugin->dataset_cls.write)
+ if(NULL == vol_plugin->cls->dataset_cls.write)
HGOTO_ERROR(H5E_VOL, H5E_UNSUPPORTED, FAIL, "vol plugin has no `dataset write' method")
-
- if((ret_value = (vol_plugin->dataset_cls.write)
- (id, mem_type_id, mem_space_id, file_space_id, plist_id, buf, req)) < 0)
+ if((ret_value = (vol_plugin->cls->dataset_cls.write)
+ (dset, mem_type_id, mem_space_id, file_space_id, plist_id, buf, req)) < 0)
HGOTO_ERROR(H5E_VOL, H5E_WRITEERROR, FAIL, "write failed")
done:
@@ -886,20 +907,16 @@ done:
*
*-------------------------------------------------------------------------
*/
-herr_t H5VL_dataset_set_extent(hid_t id, const hsize_t size[], hid_t req)
+herr_t
+H5VL_dataset_set_extent(void *dset, H5VL_t *vol_plugin, const hsize_t size[], hid_t req)
{
- H5VL_class_t *vol_plugin; /* VOL structure attached to id */
herr_t ret_value = SUCCEED;
FUNC_ENTER_NOAPI(FAIL)
- if (NULL == (vol_plugin = (H5VL_class_t *)H5I_get_aux(id)))
- HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "ID does not contain VOL information")
-
- if(NULL == vol_plugin->dataset_cls.set_extent)
+ if(NULL == vol_plugin->cls->dataset_cls.set_extent)
HGOTO_ERROR(H5E_VOL, H5E_UNSUPPORTED, FAIL, "vol plugin has no `dataset set_extent' method")
-
- if((ret_value = (vol_plugin->dataset_cls.set_extent)(id, size, req)) < 0)
+ if((ret_value = (vol_plugin->cls->dataset_cls.set_extent)(dset, size, req)) < 0)
HGOTO_ERROR(H5E_VOL, H5E_CANTINIT, FAIL, "set_extent failed")
done:
@@ -922,25 +939,22 @@ done:
*-------------------------------------------------------------------------
*/
herr_t
-H5VL_dataset_get(hid_t id, H5VL_dataset_get_t get_type, hid_t req, ...)
+H5VL_dataset_get(void *dset, H5VL_t *vol_plugin, H5VL_dataset_get_t get_type, hid_t req, ...)
{
va_list arguments; /* argument list passed from the API call */
- H5VL_class_t *vol_plugin; /* VOL structure attached to id */
herr_t ret_value = SUCCEED;
FUNC_ENTER_NOAPI(FAIL)
- if (NULL == (vol_plugin = (H5VL_class_t *)H5I_get_aux(id)))
- HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "ID does not contain VOL information")
-
- if(NULL == vol_plugin->dataset_cls.get)
+ if(NULL == vol_plugin->cls->dataset_cls.get)
HGOTO_ERROR(H5E_VOL, H5E_UNSUPPORTED, FAIL, "vol plugin has no `dataset get' method")
va_start (arguments, req);
- if((ret_value = (vol_plugin->dataset_cls.get)(id, get_type, req, arguments)) < 0)
+ if((ret_value = (vol_plugin->cls->dataset_cls.get)(dset, get_type, req, arguments)) < 0)
HGOTO_ERROR(H5E_VOL, H5E_CANTGET, FAIL, "get failed")
va_end (arguments);
+#if 0
/* if the get_type is a named datatype, create a wrapper for it */
if(H5VL_DATASET_GET_TYPE == get_type) {
hid_t *ret_id;
@@ -955,6 +969,7 @@ H5VL_dataset_get(hid_t id, H5VL_dataset_get_t get_type, hid_t req, ...)
}
va_end (arguments);
}
+#endif
done:
FUNC_LEAVE_NOAPI(ret_value)
@@ -976,24 +991,23 @@ done:
*-------------------------------------------------------------------------
*/
herr_t
-H5VL_dataset_close(hid_t id, hid_t req)
+H5VL_dataset_close(void *dset, H5VL_t *vol_plugin, hid_t req)
{
- H5VL_class_t *vol_plugin; /* VOL structure attached to id */
herr_t ret_value = SUCCEED;
FUNC_ENTER_NOAPI(FAIL)
- if (NULL == (vol_plugin = (H5VL_class_t *)H5I_get_aux(id)))
- HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "ID does not contain VOL information")
-
/* if the VOL class does not implement a specific dataset close
callback, try the object close */
- if(NULL == vol_plugin->dataset_cls.close){
+ if(NULL == vol_plugin->cls->dataset_cls.close){
+ ;
+#if 0
if(H5VL_object_close(id, req) < 0)
HGOTO_ERROR(H5E_SYM, H5E_CANTRELEASE, FAIL, "unable to close object")
+#endif
}
else {
- if((ret_value = (vol_plugin->dataset_cls.close)(id, req)) < 0)
+ if((ret_value = (vol_plugin->cls->dataset_cls.close)(dset, req)) < 0)
HGOTO_ERROR(H5E_VOL, H5E_CANTRELEASE, FAIL, "close failed")
}
done:
@@ -1002,93 +1016,94 @@ done:
/*-------------------------------------------------------------------------
- * Function: H5VL_file_open
+ * Function: H5VL_file_create
*
- * Purpose: Opens a file through the VOL.
+ * Purpose: Creates a file through the VOL
*
- * Return: Success: User ID of the new file.
+ * Return: Success: pointer to file.
*
- * Failure: FAIL
+ * Failure: NULL
*
* Programmer: Mohamad Chaarawi
* January, 2012
*
*-------------------------------------------------------------------------
*/
-hid_t
-H5VL_file_open(const char *name, unsigned flags, hid_t fapl_id, hid_t req)
+void *
+H5VL_file_create(H5VL_t *vol_plugin, const char *name, unsigned flags, hid_t fcpl_id,
+ hid_t fapl_id, hid_t req)
{
H5P_genplist_t *plist; /* Property list pointer */
- H5VL_class_t *vol_plugin; /* VOL structure attached to id */
- hid_t ret_value; /* Return value */
+ H5VL_class_t *vol_cls; /* VOL class attached to fapl_id */
+ void *ret_value; /* Return value */
- FUNC_ENTER_NOAPI(FAIL)
+ FUNC_ENTER_NOAPI(NULL)
/* get the VOL info from the fapl */
if(NULL == (plist = (H5P_genplist_t *)H5I_object(fapl_id)))
- HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a file access property list")
- if(H5P_get(plist, H5F_ACS_VOL_NAME, &vol_plugin) < 0)
- HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, FAIL, "can't get vol plugin")
+ HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, NULL, "not a file access property list")
+ if(H5P_get(plist, H5F_ACS_VOL_NAME, &vol_cls) < 0)
+ HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, NULL, "can't get vol plugin ID")
- /* check if the corresponding VOL open callback exists */
- if(NULL == vol_plugin->file_cls.open)
- HGOTO_ERROR(H5E_VOL, H5E_UNSUPPORTED, FAIL, "vol plugin has no `file open' method")
- /* call the corresponding VOL open callback */
- if((ret_value = (vol_plugin->file_cls.open)(name, flags, fapl_id, req)) < 0)
- HGOTO_ERROR(H5E_VOL, H5E_CANTINIT, FAIL, "open failed")
+ /* check if the corresponding VOL create callback exists */
+ if(NULL == vol_cls->file_cls.create)
+ HGOTO_ERROR(H5E_VOL, H5E_UNSUPPORTED, NULL, "vol plugin has no `file create' method")
+ /* call the corresponding VOL create callback */
+ if(NULL == (ret_value = (vol_cls->file_cls.create)(name, flags, fcpl_id, fapl_id, req)))
+ HGOTO_ERROR(H5E_VOL, H5E_CANTINIT, NULL, "create failed")
- /* attach VOL information to the ID */
- if (H5I_register_aux(ret_value, vol_plugin, (H5I_free_t)H5VL_close) < 0)
- HGOTO_ERROR(H5E_VOL, H5E_CANTINIT, FAIL, "can't attach vol info to ID")
+ vol_plugin->cls = vol_cls;
+ if((vol_plugin->container_name = H5MM_xstrdup(name)) == NULL)
+ HGOTO_ERROR(H5E_RESOURCE,H5E_NOSPACE,NULL,"memory allocation failed")
done:
FUNC_LEAVE_NOAPI(ret_value)
-} /* end H5VL_file_open() */
+} /* end H5VL_file_create() */
/*-------------------------------------------------------------------------
- * Function: H5VL_file_create
+ * Function: H5VL_file_open
*
- * Purpose: Creates a file through the VOL
+ * Purpose: Opens a file through the VOL.
*
- * Return: Success: User ID of the new file.
+ * Return: Success: pointer to file.
*
- * Failure: FAIL
+ * Failure: NULL
*
* Programmer: Mohamad Chaarawi
* January, 2012
*
*-------------------------------------------------------------------------
*/
-hid_t
-H5VL_file_create(const char *name, unsigned flags, hid_t fcpl_id, hid_t fapl_id, hid_t req)
+void *
+H5VL_file_open(H5VL_t *vol_plugin, const char *name, unsigned flags, hid_t fapl_id, hid_t req)
{
H5P_genplist_t *plist; /* Property list pointer */
- H5VL_class_t *vol_plugin; /* VOL structure attached to id */
- hid_t ret_value; /* Return value */
+ H5VL_class_t *vol_cls; /* VOL class attached to fapl_id */
+ void *ret_value; /* Return value */
- FUNC_ENTER_NOAPI(FAIL)
+ FUNC_ENTER_NOAPI(NULL)
/* get the VOL info from the fapl */
if(NULL == (plist = (H5P_genplist_t *)H5I_object(fapl_id)))
- HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a file access property list")
- if(H5P_get(plist, H5F_ACS_VOL_NAME, &vol_plugin) < 0)
- HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, FAIL, "can't get vol plugin ID")
+ HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, NULL, "not a file access property list")
+ if(H5P_get(plist, H5F_ACS_VOL_NAME, &vol_cls) < 0)
+ HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, NULL, "can't get vol plugin ID")
/* check if the corresponding VOL create callback exists */
- if(NULL == vol_plugin->file_cls.create)
- HGOTO_ERROR(H5E_VOL, H5E_UNSUPPORTED, FAIL, "vol plugin has no `file create' method")
+ if(NULL == vol_cls->file_cls.open)
+ HGOTO_ERROR(H5E_VOL, H5E_UNSUPPORTED, NULL, "vol plugin has no `file open' method")
/* call the corresponding VOL create callback */
- if((ret_value = (vol_plugin->file_cls.create)(name, flags, fcpl_id, fapl_id, req)) < 0)
- HGOTO_ERROR(H5E_VOL, H5E_CANTINIT, FAIL, "create failed")
+ if(NULL == (ret_value = (vol_cls->file_cls.open)(name, flags, fapl_id, req)))
+ HGOTO_ERROR(H5E_VOL, H5E_CANTINIT, NULL, "open failed")
- /* attach VOL information to the ID */
- if (H5I_register_aux(ret_value, vol_plugin, (H5I_free_t)H5VL_close) < 0)
- HGOTO_ERROR(H5E_VOL, H5E_CANTINIT, FAIL, "can't attach vol info to ID")
+ vol_plugin->cls = vol_cls;
+ if((vol_plugin->container_name = H5MM_xstrdup(name)) == NULL)
+ HGOTO_ERROR(H5E_RESOURCE,H5E_NOSPACE,NULL,"memory allocation failed")
done:
FUNC_LEAVE_NOAPI(ret_value)
-} /* end H5VL_file_create() */
+} /* end H5VL_file_open() */
/*-------------------------------------------------------------------------
@@ -1106,19 +1121,15 @@ done:
*-------------------------------------------------------------------------
*/
herr_t
-H5VL_file_flush(hid_t id, H5F_scope_t scope, hid_t req)
+H5VL_file_flush(void *obj, H5VL_loc_params_t loc_params, H5VL_t *vol_plugin, H5F_scope_t scope, hid_t req)
{
- H5VL_class_t *vol_plugin; /* VOL structure attached to id */
herr_t ret_value = SUCCEED;
FUNC_ENTER_NOAPI(FAIL)
- if (NULL == (vol_plugin = (H5VL_class_t *)H5I_get_aux(id)))
- HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "ID does not contain VOL information")
-
- if(NULL == vol_plugin->file_cls.flush)
+ if(NULL == vol_plugin->cls->file_cls.flush)
HGOTO_ERROR(H5E_VOL, H5E_UNSUPPORTED, FAIL, "vol plugin has no `file flush' method")
- if((ret_value = (vol_plugin->file_cls.flush)(id, scope, req)) < 0)
+ if((ret_value = (vol_plugin->cls->file_cls.flush)(obj, loc_params, scope, req)) < 0)
HGOTO_ERROR(H5E_VOL, H5E_CANTFLUSH, FAIL, "flush failed")
done:
@@ -1141,22 +1152,18 @@ done:
*-------------------------------------------------------------------------
*/
herr_t
-H5VL_file_get(hid_t id, H5VL_file_get_t get_type, hid_t req, ...)
+H5VL_file_get(void *file, H5VL_t *vol_plugin, H5VL_file_get_t get_type, hid_t req, ...)
{
va_list arguments; /* argument list passed from the API call */
- H5VL_class_t *vol_plugin; /* VOL structure attached to id */
herr_t ret_value = SUCCEED;
FUNC_ENTER_NOAPI(FAIL)
- if (NULL == (vol_plugin = (H5VL_class_t *)H5I_get_aux(id)))
- HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "ID does not contain VOL information")
-
- if(NULL == vol_plugin->file_cls.get)
+ if(NULL == vol_plugin->cls->file_cls.get)
HGOTO_ERROR(H5E_VOL, H5E_UNSUPPORTED, FAIL, "vol plugin has no `file get' method")
va_start(arguments, req);
- if((ret_value = (vol_plugin->file_cls.get)(id, get_type, req, arguments)) < 0)
+ if((ret_value = (vol_plugin->cls->file_cls.get)(file, get_type, req, arguments)) < 0)
HGOTO_ERROR(H5E_VOL, H5E_CANTGET, FAIL, "get failed")
va_end(arguments);
@@ -1179,32 +1186,43 @@ done:
*-------------------------------------------------------------------------
*/
herr_t
-H5VL_file_misc(hid_t id, H5VL_file_misc_t misc_type, hid_t req, ...)
+H5VL_file_misc(void *file, H5VL_t *vol_plugin, H5VL_file_misc_t misc_type, hid_t req, ...)
{
va_list arguments; /* argument list passed from the API call */
- H5VL_class_t *vol_plugin; /* VOL structure attached to id */
herr_t ret_value = SUCCEED;
FUNC_ENTER_NOAPI(FAIL)
if (misc_type == H5VL_FILE_IS_ACCESSIBLE) {
- H5P_genplist_t *plist; /* Property list pointer */
+ H5P_genplist_t *plist; /* Property list pointer */
+ H5VL_class_t *vol_cls; /* VOL class attached to fapl_id */
+ va_list tmp_args; /* argument list passed from the API call */
+ hid_t fapl_id;
+
+ va_start (tmp_args, req);
+ fapl_id = va_arg (tmp_args, hid_t);
+ va_end (tmp_args);
+
/* get the VOL info from the fapl */
- if(NULL == (plist = (H5P_genplist_t *)H5I_object(id)))
+ if(NULL == (plist = (H5P_genplist_t *)H5I_object(fapl_id)))
HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a file access property list")
- if(H5P_get(plist, H5F_ACS_VOL_NAME, &vol_plugin) < 0)
+ if(H5P_get(plist, H5F_ACS_VOL_NAME, &vol_cls) < 0)
HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, FAIL, "can't get vol plugin")
- }
- else if (NULL == (vol_plugin = (H5VL_class_t *)H5I_get_aux(id)))
- HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "ID does not contain VOL information")
- if(NULL == vol_plugin->file_cls.misc)
- HGOTO_ERROR(H5E_VOL, H5E_UNSUPPORTED, FAIL, "vol plugin has no `file misc' method")
+ va_start (arguments, req);
+ if((ret_value = (vol_cls->file_cls.misc)(file, misc_type, req, arguments)) < 0)
+ HGOTO_ERROR(H5E_VOL, H5E_CANTGET, FAIL, "misc failed")
+ va_end (arguments);
+ }
+ else {
+ if(NULL == vol_plugin->cls->file_cls.misc)
+ HGOTO_ERROR(H5E_VOL, H5E_UNSUPPORTED, FAIL, "vol plugin has no `file misc' method")
- va_start (arguments, req);
- if((ret_value = (vol_plugin->file_cls.misc)(id, misc_type, req, arguments)) < 0)
- HGOTO_ERROR(H5E_VOL, H5E_CANTGET, FAIL, "misc failed")
- va_end (arguments);
+ va_start (arguments, req);
+ if((ret_value = (vol_plugin->cls->file_cls.misc)(file, misc_type, req, arguments)) < 0)
+ HGOTO_ERROR(H5E_VOL, H5E_CANTGET, FAIL, "misc failed")
+ va_end (arguments);
+ }
done:
FUNC_LEAVE_NOAPI(ret_value)
@@ -1225,38 +1243,21 @@ done:
*-------------------------------------------------------------------------
*/
herr_t
-H5VL_file_optional(hid_t id, H5VL_file_optional_t optional_type, hid_t req, ...)
+H5VL_file_optional(void *file, H5VL_t *vol_plugin, H5VL_file_optional_t optional_type, hid_t req, ...)
{
va_list arguments; /* argument list passed from the API call */
- H5VL_class_t *vol_plugin; /* VOL structure attached to id */
herr_t ret_value = SUCCEED;
FUNC_ENTER_NOAPI(FAIL)
- if (NULL == (vol_plugin = (H5VL_class_t *)H5I_get_aux(id)))
- HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "ID does not contain VOL information")
-
- if(NULL == vol_plugin->file_cls.optional)
+ if(NULL == vol_plugin->cls->file_cls.optional)
HGOTO_ERROR(H5E_VOL, H5E_UNSUPPORTED, FAIL, "vol plugin has no `file optional' method")
va_start (arguments, req);
- if((ret_value = (vol_plugin->file_cls.optional)(id, optional_type, req, arguments)) < 0)
+ if((ret_value = (vol_plugin->cls->file_cls.optional)(file, optional_type, req, arguments)) < 0)
HGOTO_ERROR(H5E_VOL, H5E_CANTGET, FAIL, "optional failed")
va_end (arguments);
- /* if we are re-opening the file ,attach the VOL info to the new id */
- if(H5VL_FILE_REOPEN == optional_type) {
- hid_t *ret_id;
-
- va_start (arguments, req);
- ret_id = va_arg (arguments, hid_t *);
-
- /* attach VOL information to the ID */
- if (H5I_register_aux(*ret_id, vol_plugin, (H5I_free_t)H5VL_close) < 0)
- HGOTO_ERROR(H5E_VOL, H5E_CANTINIT, FAIL, "can't attach vol info to ID")
- va_end (arguments);
- }
-
done:
FUNC_LEAVE_NOAPI(ret_value)
} /* end H5VL_file_optional() */
@@ -1277,19 +1278,15 @@ done:
*-------------------------------------------------------------------------
*/
herr_t
-H5VL_file_close(hid_t id, hid_t req)
+H5VL_file_close(void *file, H5VL_t *vol_plugin, hid_t req)
{
- H5VL_class_t *vol_plugin; /* VOL structure attached to id */
herr_t ret_value = SUCCEED;
FUNC_ENTER_NOAPI(FAIL)
- if (NULL == (vol_plugin = (H5VL_class_t *)H5I_get_aux(id)))
- HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "ID does not contain VOL information")
-
- if(NULL == vol_plugin->file_cls.close)
+ if(NULL == vol_plugin->cls->file_cls.close)
HGOTO_ERROR(H5E_VOL, H5E_UNSUPPORTED, FAIL, "vol plugin has no `file close' method")
- if((ret_value = (vol_plugin->file_cls.close)(id, req)) < 0)
+ if((ret_value = (vol_plugin->cls->file_cls.close)(file, req)) < 0)
HGOTO_ERROR(H5E_VOL, H5E_CANTCLOSEFILE, FAIL, "close failed")
done:
@@ -1302,37 +1299,29 @@ done:
*
* Purpose: Creates a group through the VOL
*
- * Return: Success: User ID of the new group.
+ * Return: Success: pointer to new group.
*
- * Failure: FAIL
+ * Failure: NULL
*
* Programmer: Mohamad Chaarawi
* March, 2012
*
*-------------------------------------------------------------------------
*/
-hid_t
-H5VL_group_create(hid_t id, const char *name, hid_t gcpl_id, hid_t gapl_id, hid_t req)
+void *
+H5VL_group_create(void *obj, H5VL_loc_params_t loc_params, H5VL_t *vol_plugin, const char *name,
+ hid_t gcpl_id, hid_t gapl_id, hid_t req)
{
- H5VL_class_t *vol_plugin; /* VOL structure attached to id */
- hid_t ret_value; /* Return value */
-
- FUNC_ENTER_NOAPI(FAIL)
+ void *ret_value = NULL; /* Return value */
- if (NULL == (vol_plugin = (H5VL_class_t *)H5I_get_aux(id)))
- HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "ID does not contain VOL information")
+ FUNC_ENTER_NOAPI(NULL)
/* check if the corresponding VOL create callback exists */
- if(NULL == vol_plugin->group_cls.create)
- HGOTO_ERROR(H5E_VOL, H5E_UNSUPPORTED, FAIL, "vol plugin has no `group create' method")
-
+ if(NULL == vol_plugin->cls->group_cls.create)
+ HGOTO_ERROR(H5E_VOL, H5E_UNSUPPORTED, NULL, "vol plugin has no `group create' method")
/* call the corresponding VOL create callback */
- if((ret_value = (vol_plugin->group_cls.create)(id, name, gcpl_id, gapl_id, req)) < 0)
- HGOTO_ERROR(H5E_VOL, H5E_CANTINIT, FAIL, "create failed")
-
- /* attach VOL information to the ID */
- if (H5I_register_aux(ret_value, vol_plugin, (H5I_free_t)H5VL_close) < 0)
- HGOTO_ERROR(H5E_VOL, H5E_CANTINIT, FAIL, "can't attach vol info to ID")
+ if(NULL == (ret_value = (vol_plugin->cls->group_cls.create)(obj, loc_params, name, gcpl_id, gapl_id, req)))
+ HGOTO_ERROR(H5E_VOL, H5E_CANTINIT, NULL, "create failed")
done:
FUNC_LEAVE_NOAPI(ret_value)
@@ -1344,46 +1333,36 @@ done:
*
* Purpose: Opens a group through the VOL
*
- * Return: Success: User ID of the new group.
+ * Return: Success: pointer to new group.
*
- * Failure: FAIL
+ * Failure: NULL
*
* Programmer: Mohamad Chaarawi
* March, 2012
*
*-------------------------------------------------------------------------
*/
-hid_t
-H5VL_group_open(hid_t id, const char *name, hid_t gapl_id, hid_t req)
+void *
+H5VL_group_open(void *obj, H5VL_loc_params_t loc_params, H5VL_t *vol_plugin, const char *name,
+ hid_t gapl_id, hid_t req)
{
- H5VL_class_t *vol_plugin; /* VOL structure attached to id */
- hid_t ret_value; /* Return value */
-
- FUNC_ENTER_NOAPI(FAIL)
+ void *ret_value; /* Return value */
- if (NULL == (vol_plugin = (H5VL_class_t *)H5I_get_aux(id)))
- HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "ID does not contain VOL information")
+ FUNC_ENTER_NOAPI(NULL)
/* check if the type specific corresponding VOL open callback exists */
- if(NULL == vol_plugin->group_cls.open) {
- H5VL_loc_params_t loc_params;
-
- loc_params.type = H5VL_OBJECT_BY_NAME;
- loc_params.loc_data.loc_by_name.name = name;
- loc_params.loc_data.loc_by_name.plist_id = gapl_id;
-
+ if(NULL == vol_plugin->cls->group_cls.open) {
+ ;
+#if 0
/* Open the object class */
if((ret_value = H5VL_object_open(id, loc_params, H5_REQUEST_NULL)) < 0)
- HGOTO_ERROR(H5E_SYM, H5E_CANTINIT, FAIL, "unable to open object")
+ HGOTO_ERROR(H5E_SYM, H5E_CANTINIT, NULL, "unable to open object")
+#endif
}
else {
/* call the corresponding VOL open callback */
- if((ret_value = (vol_plugin->group_cls.open)(id, name, gapl_id, req)) < 0)
- HGOTO_ERROR(H5E_VOL, H5E_CANTINIT, FAIL, "open failed")
-
- /* attach VOL information to the ID */
- if (H5I_register_aux(ret_value, vol_plugin, (H5I_free_t)H5VL_close) < 0)
- HGOTO_ERROR(H5E_VOL, H5E_CANTINIT, FAIL, "can't attach vol info to ID")
+ if(NULL == (ret_value = (vol_plugin->cls->group_cls.open)(obj, loc_params, name, gapl_id, req)))
+ HGOTO_ERROR(H5E_VOL, H5E_CANTINIT, NULL, "open failed")
}
done:
FUNC_LEAVE_NOAPI(ret_value)
@@ -1405,22 +1384,17 @@ done:
*-------------------------------------------------------------------------
*/
herr_t
-H5VL_group_get(hid_t id, H5VL_group_get_t get_type, hid_t req, ...)
+H5VL_group_get(void *obj, H5VL_t *vol_plugin, H5VL_group_get_t get_type, hid_t req, ...)
{
va_list arguments; /* argument list passed from the API call */
- H5VL_class_t *vol_plugin; /* VOL structure attached to id */
herr_t ret_value = SUCCEED;
FUNC_ENTER_NOAPI(FAIL)
- if (NULL == (vol_plugin = (H5VL_class_t *)H5I_get_aux(id)))
- HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "ID does not contain VOL information")
-
- if(NULL == vol_plugin->group_cls.get)
+ if(NULL == vol_plugin->cls->group_cls.get)
HGOTO_ERROR(H5E_VOL, H5E_UNSUPPORTED, FAIL, "vol plugin has no `group get' method")
-
va_start (arguments, req);
- if((ret_value = (vol_plugin->group_cls.get)(id, get_type, req, arguments)) < 0)
+ if((ret_value = (vol_plugin->cls->group_cls.get)(obj, get_type, req, arguments)) < 0)
HGOTO_ERROR(H5E_VOL, H5E_CANTGET, FAIL, "get failed")
va_end (arguments);
@@ -1444,24 +1418,23 @@ done:
*-------------------------------------------------------------------------
*/
herr_t
-H5VL_group_close(hid_t id, hid_t req)
+H5VL_group_close(void *grp, H5VL_t *vol_plugin, hid_t req)
{
- H5VL_class_t *vol_plugin; /* VOL structure attached to id */
herr_t ret_value = SUCCEED;
FUNC_ENTER_NOAPI(FAIL)
- if (NULL == (vol_plugin = (H5VL_class_t *)H5I_get_aux(id)))
- HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "ID does not contain VOL information")
-
/* if the VOL class does not implement a specific group close
callback, try the object close */
- if(NULL == vol_plugin->group_cls.close) {
+ if(NULL == vol_plugin->cls->group_cls.close) {
+ ;
+#if 0
if(H5VL_object_close(id, req) < 0)
HGOTO_ERROR(H5E_SYM, H5E_CANTRELEASE, FAIL, "unable to close object")
+#endif
}
else {
- if((ret_value = (vol_plugin->group_cls.close)(id, req)) < 0)
+ if((ret_value = (vol_plugin->cls->group_cls.close)(grp, req)) < 0)
HGOTO_ERROR(H5E_VOL, H5E_CANTRELEASE, FAIL, "close failed")
}
done:
@@ -1482,44 +1455,19 @@ done:
*-------------------------------------------------------------------------
*/
herr_t
-H5VL_link_create(H5VL_link_create_type_t create_type, hid_t id, const char *new_name,
- hid_t lcpl_id, hid_t lapl_id, hid_t req)
+H5VL_link_create(H5VL_link_create_type_t create_type, void *obj, H5VL_loc_params_t loc_params,
+ H5VL_t *vol_plugin, hid_t lcpl_id, hid_t lapl_id, hid_t req)
{
- H5VL_class_t *vol_plugin = NULL; /* VOL structure attached to id */
herr_t ret_value = SUCCEED; /* Return value */
FUNC_ENTER_NOAPI(FAIL)
- /* get VOL plugin */
- if(H5L_SAME_LOC != id) {
- if (NULL == (vol_plugin = (H5VL_class_t *)H5I_get_aux(id)))
- HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "ID does not contain VOL information")
- }
- else if(H5VL_LINK_CREATE_HARD == create_type && NULL == vol_plugin) {
- H5P_genplist_t *plist; /* Property list pointer */
- hid_t cur_id;
-
- /* Get the plist structure */
- if(NULL == (plist = (H5P_genplist_t *)H5I_object(lcpl_id)))
- HGOTO_ERROR(H5E_ATOM, H5E_BADATOM, FAIL, "can't find object for ID")
-
- if(H5P_get(plist, H5VL_LINK_TARGET_ID, &cur_id) < 0)
- HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, FAIL, "can't get property value for current location id")
-
- if (NULL == (vol_plugin = (H5VL_class_t *)H5I_get_aux(cur_id)))
- HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "ID does not contain VOL information")
- }
- else {
- HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "ID does not contain VOL information")
- }
-
/* check if the corresponding VOL create callback exists */
- if(NULL == vol_plugin->link_cls.create)
+ if(NULL == vol_plugin->cls->link_cls.create)
HGOTO_ERROR(H5E_VOL, H5E_UNSUPPORTED, FAIL, "vol plugin has no `link create' method")
-
/* call the corresponding VOL create callback */
- if((ret_value = (vol_plugin->link_cls.create)
- (create_type, id, new_name, lcpl_id, lapl_id, req)) < 0)
+ if((ret_value = (vol_plugin->cls->link_cls.create)
+ (create_type, obj, loc_params, lcpl_id, lapl_id, req)) < 0)
HGOTO_ERROR(H5E_VOL, H5E_CANTINIT, FAIL, "link create failed")
done:
@@ -1539,35 +1487,20 @@ done:
*
*-------------------------------------------------------------------------
*/
-H5_DLL herr_t H5VL_link_move(hid_t src_loc_id, const char *src_name, hid_t dst_loc_id,
- const char *dst_name, hbool_t copy_flag,
- hid_t lcpl_id, hid_t lapl_id, hid_t req)
+H5_DLL herr_t H5VL_link_move(void *src_obj, H5VL_loc_params_t loc_params1, void *dst_obj,
+ H5VL_loc_params_t loc_params2, H5VL_t *vol_plugin,
+ hbool_t copy_flag, hid_t lcpl_id, hid_t lapl_id, hid_t req)
{
- H5VL_class_t *vol_plugin = NULL; /* VOL plugin */
herr_t ret_value = SUCCEED; /* Return value */
FUNC_ENTER_NOAPI(FAIL)
- /* unwrap the higher level user ids. */
- if(H5L_SAME_LOC != src_loc_id) {
- if (NULL == (vol_plugin = (H5VL_class_t *)H5I_get_aux(src_loc_id)))
- HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "ID does not contain VOL information")
- }
- else if(H5L_SAME_LOC != dst_loc_id) {
- if (NULL == (vol_plugin = (H5VL_class_t *)H5I_get_aux(dst_loc_id)))
- HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "ID does not contain VOL information")
- }
- else {
- HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "ID does not contain VOL information")
- }
-
/* check if the corresponding VOL move callback exists */
- if(NULL == vol_plugin->link_cls.move)
+ if(NULL == vol_plugin->cls->link_cls.move)
HGOTO_ERROR(H5E_VOL, H5E_UNSUPPORTED, FAIL, "vol plugin has no `link move' method")
-
/* call the corresponding VOL move callback */
- if((ret_value = (vol_plugin->link_cls.move)
- (src_loc_id, src_name, dst_loc_id, dst_name, copy_flag, lcpl_id, lapl_id, req)) < 0)
+ if((ret_value = (vol_plugin->cls->link_cls.move)
+ (src_obj, loc_params1, dst_obj, loc_params2, copy_flag, lcpl_id, lapl_id, req)) < 0)
HGOTO_ERROR(H5E_VOL, H5E_CANTINIT, FAIL, "link move failed")
done:
@@ -1588,23 +1521,18 @@ done:
*
*-------------------------------------------------------------------------
*/
-herr_t H5VL_link_iterate(hid_t loc_id, const char *name, hbool_t recursive,
- H5_index_t idx_type, H5_iter_order_t order, hsize_t *idx,
- H5L_iterate_t op, void *op_data, hid_t lapl_id)
+herr_t H5VL_link_iterate(void *obj, H5VL_loc_params_t loc_params, H5VL_t *vol_plugin,
+ hbool_t recursive, H5_index_t idx_type, H5_iter_order_t order, hsize_t *idx,
+ H5L_iterate_t op, void *op_data, hid_t req)
{
- H5VL_class_t *vol_plugin; /* VOL structure attached to id */
herr_t ret_value = SUCCEED;
FUNC_ENTER_NOAPI(FAIL)
- if (NULL == (vol_plugin = (H5VL_class_t *)H5I_get_aux(loc_id)))
- HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "ID does not contain VOL information")
-
- if(NULL == vol_plugin->link_cls.iterate)
+ if(NULL == vol_plugin->cls->link_cls.iterate)
HGOTO_ERROR(H5E_VOL, H5E_UNSUPPORTED, FAIL, "vol plugin has no `link iterate' method")
-
- if((ret_value = (vol_plugin->link_cls.iterate)(loc_id, name, recursive, idx_type,
- order, idx, op, op_data, lapl_id)) < 0)
+ if((ret_value = (vol_plugin->cls->link_cls.iterate)(obj, loc_params, recursive, idx_type,
+ order, idx, op, op_data, req)) < 0)
HGOTO_ERROR(H5E_VOL, H5E_BADITER, FAIL, "iteration failed")
done:
@@ -1627,22 +1555,18 @@ done:
*-------------------------------------------------------------------------
*/
herr_t
-H5VL_link_get(hid_t id, H5VL_link_get_t get_type, hid_t req, ...)
+H5VL_link_get(void *obj, H5VL_loc_params_t loc_params, H5VL_t *vol_plugin, H5VL_link_get_t get_type,
+ hid_t req, ...)
{
va_list arguments; /* argument list passed from the API call */
- H5VL_class_t *vol_plugin; /* VOL structure attached to id */
herr_t ret_value = SUCCEED;
FUNC_ENTER_NOAPI(FAIL)
- if (NULL == (vol_plugin = (H5VL_class_t *)H5I_get_aux(id)))
- HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "ID does not contain VOL information")
-
- if(NULL == vol_plugin->link_cls.get)
+ if(NULL == vol_plugin->cls->link_cls.get)
HGOTO_ERROR(H5E_VOL, H5E_UNSUPPORTED, FAIL, "vol plugin has no `link get' method")
-
va_start (arguments, req);
- if((ret_value = (vol_plugin->link_cls.get)(id, get_type, req, arguments)) < 0)
+ if((ret_value = (vol_plugin->cls->link_cls.get)(obj, loc_params, get_type, req, arguments)) < 0)
HGOTO_ERROR(H5E_VOL, H5E_CANTGET, FAIL, "get failed")
va_end (arguments);
@@ -1663,22 +1587,17 @@ done:
*
*-------------------------------------------------------------------------
*/
-H5_DLL herr_t H5VL_link_remove(hid_t id, const char *name, void *udata, hid_t lapl_id, hid_t req)
+H5_DLL herr_t H5VL_link_remove(void *obj, H5VL_loc_params_t loc_params, H5VL_t *vol_plugin, hid_t req)
{
- H5VL_class_t *vol_plugin; /* VOL structure attached to id */
herr_t ret_value = SUCCEED; /* Return value */
FUNC_ENTER_NOAPI(FAIL)
- if (NULL == (vol_plugin = (H5VL_class_t *)H5I_get_aux(id)))
- HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "ID does not contain VOL information")
-
/* check if the corresponding VOL remove callback exists */
- if(NULL == vol_plugin->link_cls.remove)
+ if(NULL == vol_plugin->cls->link_cls.remove)
HGOTO_ERROR(H5E_VOL, H5E_UNSUPPORTED, FAIL, "vol plugin has no `link remove' method")
-
/* call the corresponding VOL remove callback */
- if((ret_value = (vol_plugin->link_cls.remove)(id, name, udata, lapl_id, req)) < 0)
+ if((ret_value = (vol_plugin->cls->link_cls.remove)(obj, loc_params, req)) < 0)
HGOTO_ERROR(H5E_VOL, H5E_CANTINIT, FAIL, "link remove failed")
done:
@@ -1693,35 +1612,28 @@ done:
*
* Return: Success: User ID of the new object.
*
- * Failure: FAIL
+ * Failure: NULL
*
* Programmer: Mohamad Chaarawi
* March, 2012
*
*-------------------------------------------------------------------------
*/
-hid_t
-H5VL_object_open(hid_t id, H5VL_loc_params_t params, hid_t req)
+void *
+H5VL_object_open(void *obj, H5VL_loc_params_t params, H5VL_t *vol_plugin, H5I_type_t *opened_type,
+ hid_t req)
{
- H5VL_class_t *vol_plugin; /* VOL structure attached to id */
- hid_t ret_value; /* Return value */
-
- FUNC_ENTER_NOAPI(FAIL)
+ void *ret_value; /* Return value */
- if (NULL == (vol_plugin = (H5VL_class_t *)H5I_get_aux(id)))
- HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "ID does not contain VOL information")
+ FUNC_ENTER_NOAPI(NULL)
/* check if the corresponding VOL open callback exists */
- if(NULL == vol_plugin->object_cls.open)
- HGOTO_ERROR(H5E_VOL, H5E_UNSUPPORTED, FAIL, "vol plugin has no `object open' method")
+ if(NULL == vol_plugin->cls->object_cls.open)
+ HGOTO_ERROR(H5E_VOL, H5E_UNSUPPORTED, NULL, "vol plugin has no `object open' method")
/* call the corresponding VOL open callback */
- if((ret_value = (vol_plugin->object_cls.open)(id, params, req)) < 0)
- HGOTO_ERROR(H5E_VOL, H5E_CANTINIT, FAIL, "open failed")
-
- /* attach VOL information to the ID */
- if (H5I_register_aux(ret_value, vol_plugin, (H5I_free_t)H5VL_close) < 0)
- HGOTO_ERROR(H5E_VOL, H5E_CANTINIT, FAIL, "can't attach vol info to ID")
+ if(NULL == (ret_value = (vol_plugin->cls->object_cls.open)(obj, params, opened_type, req)))
+ HGOTO_ERROR(H5E_VOL, H5E_CANTINIT, NULL, "open failed")
done:
FUNC_LEAVE_NOAPI(ret_value)
@@ -1742,28 +1654,22 @@ done:
*-------------------------------------------------------------------------
*/
herr_t
-H5VL_object_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, hid_t req)
+H5VL_object_copy(void *src_obj, H5VL_loc_params_t loc_params1, H5VL_t *vol_plugin1, const char *src_name,
+ void *dst_obj, H5VL_loc_params_t loc_params2, H5VL_t *vol_plugin2, const char *dst_name,
+ hid_t ocpypl_id, hid_t lcpl_id, hid_t req)
{
- H5VL_class_t *vol_plugin1; /* VOL structure attached to src id */
- H5VL_class_t *vol_plugin2; /* VOL structure attached to dest id */
herr_t ret_value = SUCCEED;
FUNC_ENTER_NOAPI(FAIL)
- if (NULL == (vol_plugin1 = (H5VL_class_t *)H5I_get_aux(src_loc_id)))
- HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "ID does not contain VOL information")
- if (NULL == (vol_plugin2 = (H5VL_class_t *)H5I_get_aux(dst_loc_id)))
- HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "ID does not contain VOL information")
-
/* check if both objects are associated with the same VOL plugin */
if (vol_plugin1 != vol_plugin2)
HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "Objects are accessed through different VOL plugins and can't be copied")
- if(NULL == vol_plugin1->object_cls.copy)
+ if(NULL == vol_plugin1->cls->object_cls.copy)
HGOTO_ERROR(H5E_VOL, H5E_UNSUPPORTED, FAIL, "vol plugin has no `object copy' method")
- if((ret_value = (vol_plugin1->object_cls.copy)
- (src_loc_id, src_name, dst_loc_id, dst_name, ocpypl_id, lcpl_id, req)) < 0)
+ if((ret_value = (vol_plugin1->cls->object_cls.copy)
+ (src_obj, loc_params1, src_name, dst_obj, loc_params2, dst_name, ocpypl_id, lcpl_id, req)) < 0)
HGOTO_ERROR(H5E_VOL, H5E_CANTRELEASE, FAIL, "copy failed")
done:
@@ -1784,28 +1690,25 @@ done:
*
*-------------------------------------------------------------------------
*/
-herr_t H5VL_object_visit(hid_t loc_id, const char *obj_name, H5_index_t idx_type,
- H5_iter_order_t order, H5O_iterate_t op, void *op_data, hid_t lapl_id)
+herr_t H5VL_object_visit(void *obj, H5VL_loc_params_t loc_params, H5VL_t *vol_plugin, H5_index_t idx_type,
+ H5_iter_order_t order, H5O_iterate_t op, void *op_data, hid_t req)
{
- H5VL_class_t *vol_plugin; /* VOL structure attached to id */
herr_t ret_value = SUCCEED;
FUNC_ENTER_NOAPI(FAIL)
- if (NULL == (vol_plugin = (H5VL_class_t *)H5I_get_aux(loc_id)))
- HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "ID does not contain VOL information")
+ if(NULL == vol_plugin->cls->object_cls.visit)
+ HGOTO_ERROR(H5E_VOL, H5E_UNSUPPORTED, FAIL, "vol plugin has no `object visit' method")
- if(NULL == vol_plugin->object_cls.visit)
- HGOTO_ERROR(H5E_VOL, H5E_UNSUPPORTED, FAIL, "vol plugin has no `link iterate' method")
-
- if((ret_value = (vol_plugin->object_cls.visit)(loc_id, obj_name, idx_type, order, op,
- op_data, lapl_id)) < 0)
+ if((ret_value = (vol_plugin->cls->object_cls.visit)(obj, loc_params, idx_type, order, op,
+ op_data, req)) < 0)
HGOTO_ERROR(H5E_VOL, H5E_BADITER, FAIL, "object visitation failed")
done:
FUNC_LEAVE_NOAPI(ret_value)
} /* end H5VL_object_visit() */
+#if 0
/*-------------------------------------------------------------------------
* Function: H5VL_object_lookup
@@ -1878,6 +1781,7 @@ H5VL_object_free_loc(hid_t id, void *location, hid_t req)
done:
FUNC_LEAVE_NOAPI(ret_value)
} /* end H5VL_object_free_loc() */
+#endif
/*-------------------------------------------------------------------------
@@ -1895,22 +1799,18 @@ done:
*-------------------------------------------------------------------------
*/
herr_t
-H5VL_object_get(hid_t id, H5VL_object_get_t get_type, hid_t req, ...)
+H5VL_object_get(void *obj, H5VL_loc_params_t loc_params, H5VL_t *vol_plugin, H5VL_object_get_t get_type, hid_t req, ...)
{
va_list arguments; /* argument list passed from the API call */
- H5VL_class_t *vol_plugin; /* VOL structure attached to id */
herr_t ret_value = SUCCEED;
FUNC_ENTER_NOAPI(FAIL)
- if (NULL == (vol_plugin = (H5VL_class_t *)H5I_get_aux(id)))
- HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "ID does not contain VOL information")
-
- if(NULL == vol_plugin->object_cls.get)
+ if(NULL == vol_plugin->cls->object_cls.get)
HGOTO_ERROR(H5E_VOL, H5E_UNSUPPORTED, FAIL, "vol plugin has no `object get' method")
va_start (arguments, req);
- if((ret_value = (vol_plugin->object_cls.get)(id, get_type, req, arguments)) < 0)
+ if((ret_value = (vol_plugin->cls->object_cls.get)(obj, loc_params, get_type, req, arguments)) < 0)
HGOTO_ERROR(H5E_VOL, H5E_CANTGET, FAIL, "get failed")
va_end (arguments);
done:
@@ -1932,35 +1832,21 @@ done:
*-------------------------------------------------------------------------
*/
herr_t
-H5VL_object_misc(hid_t id, H5VL_object_misc_t misc_type, hid_t req, ...)
+H5VL_object_misc(void *obj, H5VL_loc_params_t loc_params, H5VL_t *vol_plugin, H5VL_object_misc_t misc_type, hid_t req, ...)
{
va_list arguments; /* argument list passed from the API call */
- H5VL_class_t *vol_plugin; /* VOL structure attached to id */
herr_t ret_value = SUCCEED;
FUNC_ENTER_NOAPI(FAIL)
- if (NULL == (vol_plugin = (H5VL_class_t *)H5I_get_aux(id)))
- HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "ID does not contain VOL information")
-
- if(NULL == vol_plugin->object_cls.misc)
+ if(NULL == vol_plugin->cls->object_cls.misc)
HGOTO_ERROR(H5E_VOL, H5E_UNSUPPORTED, FAIL, "vol plugin has no `object misc' method")
va_start (arguments, req);
- if((ret_value = (vol_plugin->object_cls.misc)(id, misc_type, req, arguments)) < 0)
+ if((ret_value = (vol_plugin->cls->object_cls.misc)(obj, loc_params, misc_type, req, arguments)) < 0)
HGOTO_ERROR(H5E_VOL, H5E_CANTGET, FAIL, "misc failed")
va_end (arguments);
- if(H5VL_ATTR_OPEN_BY_IDX == misc_type) {
- hid_t *ret_id;
-
- va_start (arguments, req);
- ret_id = va_arg (arguments, hid_t *);
- /* attach VOL information to the ID */
- if (H5I_register_aux(*ret_id, vol_plugin, (H5I_free_t)H5VL_close) < 0)
- HGOTO_ERROR(H5E_VOL, H5E_CANTINIT, FAIL, "can't attach vol info to ID")
- va_end (arguments);
- }
done:
FUNC_LEAVE_NOAPI(ret_value)
} /* end H5VL_object_misc() */
@@ -1981,19 +1867,15 @@ done:
*-------------------------------------------------------------------------
*/
herr_t
-H5VL_object_close(hid_t id, hid_t req)
+H5VL_object_close(void *obj, H5VL_loc_params_t loc_params, H5VL_t *vol_plugin, hid_t req)
{
- H5VL_class_t *vol_plugin; /* VOL structure attached to id */
herr_t ret_value = SUCCEED;
FUNC_ENTER_NOAPI(FAIL)
- if (NULL == (vol_plugin = (H5VL_class_t *)H5I_get_aux(id)))
- HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "ID does not contain VOL information")
-
- if(NULL == vol_plugin->object_cls.close)
+ if(NULL == vol_plugin->cls->object_cls.close)
HGOTO_ERROR(H5E_VOL, H5E_UNSUPPORTED, FAIL, "vol plugin has no `object close' method")
- if((ret_value = (vol_plugin->object_cls.close)(id, req)) < 0)
+ if((ret_value = (vol_plugin->cls->object_cls.close)(obj, loc_params, req)) < 0)
HGOTO_ERROR(H5E_VOL, H5E_CANTRELEASE, FAIL, "close failed")
done:
diff --git a/src/H5VLnative.c b/src/H5VLnative.c
index 49dd760..f56809f 100644
--- a/src/H5VLnative.c
+++ b/src/H5VLnative.c
@@ -54,73 +54,87 @@
#include "H5Rpkg.h" /* References */
#include "H5SMprivate.h" /* Shared Object Header Messages */
#include "H5Tpkg.h" /* Datatypes */
+#include "H5Tprivate.h" /* Datatypes */
#include "H5VLprivate.h" /* VOL plugins */
#include "H5VLnative.h" /* Native VOL plugin */
/* The driver identification number, initialized at runtime */
static hid_t H5VL_NATIVE_g = 0;
-
/* Prototypes */
+static H5F_t *H5VL_native_get_file(void *obj, H5I_type_t type);
+static herr_t H5VL_native_get_loc(void *obj, H5I_type_t type, H5G_loc_t *loc);
static herr_t H5VL_native_term(void);
-static hid_t H5VL_native_attr_create(hid_t loc_id, const char *attr_name, hid_t acpl_id, hid_t aapl_id, hid_t req);
-static hid_t H5VL_native_attr_open(hid_t loc_id, H5VL_loc_params_t loc_params, const char *attr_name, hid_t aapl_id, hid_t req);
-static herr_t H5VL_native_attr_read(hid_t attr_id, hid_t dtype_id, void *buf, hid_t req);
-static herr_t H5VL_native_attr_write(hid_t attr_id, hid_t dtype_id, const void *buf, hid_t req);
-static herr_t H5VL_native_attr_get(hid_t id, H5VL_attr_get_t get_type, hid_t req, va_list arguments);
-static herr_t H5VL_native_attr_remove(hid_t loc_id, H5VL_loc_params_t loc_params, const char *attr_name, hid_t req);
-static herr_t H5VL_native_attr_close(hid_t attr_id, hid_t req);
-
-static herr_t H5VL_native_datatype_commit(hid_t loc_id, const char *name, hid_t type_id,
- hid_t lcpl_id, hid_t tcpl_id, hid_t tapl_id, hid_t req);
-static hid_t H5VL_native_datatype_open(hid_t loc_id, const char *name, hid_t tapl_id, hid_t req);
-
-static hid_t H5VL_native_dataset_create(hid_t loc_id, const char *name, hid_t dcpl_id, hid_t dapl_id, hid_t req);
-static hid_t H5VL_native_dataset_open(hid_t loc_id, const char *name, hid_t dapl_id, hid_t req);
-static herr_t H5VL_native_dataset_read(hid_t dset_id, hid_t mem_type_id, hid_t mem_space_id,
+/* Atrribute callbacks */
+static void *H5VL_native_attr_create(void *obj, H5VL_loc_params_t loc_params, const char *attr_name, hid_t acpl_id, hid_t aapl_id, hid_t req);
+static void *H5VL_native_attr_open(void *obj, H5VL_loc_params_t loc_params, const char *attr_name, hid_t aapl_id, hid_t req);
+static herr_t H5VL_native_attr_read(void *attr, hid_t dtype_id, void *buf, hid_t req);
+static herr_t H5VL_native_attr_write(void *attr, hid_t dtype_id, const void *buf, hid_t req);
+static herr_t H5VL_native_attr_get(void *obj, H5VL_attr_get_t get_type, hid_t req, va_list arguments);
+static herr_t H5VL_native_attr_remove(void *obj, H5VL_loc_params_t loc_params, const char *attr_name, hid_t req);
+static herr_t H5VL_native_attr_close(void *attr, hid_t req);
+
+/* Datatype callbacks */
+static void *H5VL_native_datatype_commit(void *obj, H5VL_loc_params_t loc_params, const char *name,
+ hid_t type_id, hid_t lcpl_id, hid_t tcpl_id, hid_t tapl_id, hid_t req);
+static void *H5VL_native_datatype_open(void *obj, H5VL_loc_params_t loc_params, const char *name,
+ unsigned char *buf, size_t nalloc, hid_t tapl_id, hid_t req);
+static ssize_t H5VL_native_datatype_get_size(void *obj, H5VL_loc_params_t loc_params, const char *name,
+ hid_t tapl_id, hid_t req);
+static herr_t H5VL_native_datatype_close(void *dt, hid_t req);
+
+/* Dataset callbacks */
+static void *H5VL_native_dataset_create(void *obj, H5VL_loc_params_t loc_params, const char *name, hid_t dcpl_id, hid_t dapl_id, hid_t req);
+static void *H5VL_native_dataset_open(void *obj, H5VL_loc_params_t loc_params, const char *name, hid_t dapl_id, hid_t req);
+static herr_t H5VL_native_dataset_read(void *dset, hid_t mem_type_id, hid_t mem_space_id,
hid_t file_space_id, hid_t plist_id, void *buf, hid_t req);
-static herr_t H5VL_native_dataset_write(hid_t dset_id, hid_t mem_type_id, hid_t mem_space_id,
+static herr_t H5VL_native_dataset_write(void *dset, hid_t mem_type_id, hid_t mem_space_id,
hid_t file_space_id, hid_t plist_id, const void *buf, hid_t req);
-static herr_t H5VL_native_dataset_set_extent(hid_t dset_id, const hsize_t size[], hid_t req);
-static herr_t H5VL_native_dataset_get(hid_t id, H5VL_dataset_get_t get_type, hid_t req, va_list arguments);
-static herr_t H5VL_native_dataset_close(hid_t dataset_id, hid_t req);
-
-static hid_t H5VL_native_file_create(const char *name, unsigned flags, hid_t fcpl_id, hid_t fapl_id, hid_t req);
-static hid_t H5VL_native_file_open(const char *name, unsigned flags, hid_t fapl_id, hid_t req);
-static herr_t H5VL_native_file_flush(hid_t fid, H5F_scope_t scope, hid_t req);
-static herr_t H5VL_native_file_get(hid_t file_id, H5VL_file_get_t get_type, hid_t req, va_list arguments);
-static herr_t H5VL_native_file_misc(hid_t loc_id, H5VL_file_misc_t misc_type, hid_t req, va_list arguments);
-static herr_t H5VL_native_file_optional(hid_t loc_id, H5VL_file_optional_t optional_type, hid_t req, va_list arguments);
-static herr_t H5VL_native_file_close(hid_t fid, hid_t req);
-
-static hid_t H5VL_native_group_create(hid_t loc_id, const char *name, hid_t gcpl_id, hid_t gapl_id, hid_t req);
-static hid_t H5VL_native_group_open(hid_t loc_id, const char *name, hid_t gapl_id, hid_t req);
-static herr_t H5VL_native_group_get(hid_t obj_id, H5VL_group_get_t get_type, hid_t req, va_list arguments);
-static herr_t H5VL_native_group_close(hid_t group_id, hid_t req);
-
-static herr_t H5VL_native_link_create(H5VL_link_create_type_t create_type, hid_t loc_id,
- const char *link_name, hid_t lcpl_id, hid_t lapl_id, hid_t req);
-static herr_t H5VL_native_link_move(hid_t src_loc_id, const char *src_name, hid_t dst_loc_id,
- const char *dst_name, hbool_t copy_flag, hid_t lcpl_id, hid_t lapl_id, hid_t req);
-static herr_t H5VL_native_link_iterate(hid_t loc_id, const char *name, hbool_t recursive,
+static herr_t H5VL_native_dataset_set_extent(void *dset, const hsize_t size[], hid_t req);
+static herr_t H5VL_native_dataset_get(void *dset, H5VL_dataset_get_t get_type, hid_t req, va_list arguments);
+static herr_t H5VL_native_dataset_close(void *dset, hid_t req);
+
+/* File callbacks */
+static void *H5VL_native_file_create(const char *name, unsigned flags, hid_t fcpl_id, hid_t fapl_id, hid_t req);
+static void *H5VL_native_file_open(const char *name, unsigned flags, hid_t fapl_id, hid_t req);
+static herr_t H5VL_native_file_flush(void *obj, H5VL_loc_params_t loc_params, H5F_scope_t scope, hid_t req);
+static herr_t H5VL_native_file_get(void *file, H5VL_file_get_t get_type, hid_t req, va_list arguments);
+static herr_t H5VL_native_file_misc(void *file, H5VL_file_misc_t misc_type, hid_t req, va_list arguments);
+static herr_t H5VL_native_file_optional(void *file, H5VL_file_optional_t optional_type, hid_t req, va_list arguments);
+static herr_t H5VL_native_file_close(void *file, hid_t req);
+
+/* Group callbacks */
+static void *H5VL_native_group_create(void *obj, H5VL_loc_params_t loc_params, const char *name, hid_t gcpl_id, hid_t gapl_id, hid_t req);
+static void *H5VL_native_group_open(void *obj, H5VL_loc_params_t loc_params, const char *name, hid_t gapl_id, hid_t req);
+static herr_t H5VL_native_group_get(void *obj, H5VL_group_get_t get_type, hid_t req, va_list arguments);
+static herr_t H5VL_native_group_close(void *grp, hid_t req);
+
+/* Link callbacks */
+static herr_t H5VL_native_link_create(H5VL_link_create_type_t create_type, void *obj,
+ H5VL_loc_params_t loc_params, hid_t lcpl_id, hid_t lapl_id, hid_t req);
+static herr_t H5VL_native_link_move(void *src_obj, H5VL_loc_params_t loc_params1,
+ void *dst_obj, H5VL_loc_params_t loc_params2,
+ hbool_t copy_flag, hid_t lcpl_id, hid_t lapl_id, hid_t req);
+static herr_t H5VL_native_link_iterate(void *obj, H5VL_loc_params_t loc_params, hbool_t recursive,
H5_index_t idx_type, H5_iter_order_t order, hsize_t *idx,
- H5L_iterate_t op, void *op_data, hid_t lapl_id);
-static herr_t H5VL_native_link_get(hid_t loc_id, H5VL_link_get_t get_type, hid_t req, va_list arguments);
-static herr_t H5VL_native_link_remove(hid_t loc_id, const char *name, void *udata, hid_t lapl_id, hid_t req);
-
-static hid_t H5VL_native_object_open(hid_t loc_id, H5VL_loc_params_t params, hid_t req);
-static herr_t H5VL_native_object_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, hid_t req);
-static herr_t H5VL_native_object_visit(hid_t loc_id, const char *obj_name, H5_index_t idx_type,
- H5_iter_order_t order, H5O_iterate_t op, void *op_data,
- hid_t lapl_id);
-static herr_t H5VL_native_object_lookup(hid_t loc_id, H5VL_loc_type_t lookup_type, void **location, hid_t req, va_list arguments);
-static herr_t H5VL_native_object_free_loc(void *location, hid_t req);
-static herr_t H5VL_native_object_get(hid_t id, H5VL_object_get_t get_type, hid_t req, va_list arguments);
-static herr_t H5VL_native_object_misc(hid_t id, H5VL_object_misc_t misc_type, hid_t req, va_list arguments);
-static herr_t H5VL_native_object_optional(hid_t id, H5VL_object_optional_t optional_type, hid_t req, va_list arguments);
-static herr_t H5VL_native_object_close(hid_t object_id, hid_t req);
+ H5L_iterate_t op, void *op_data, hid_t req);
+static herr_t H5VL_native_link_get(void *obj, H5VL_loc_params_t loc_params, H5VL_link_get_t get_type, hid_t req, va_list arguments);
+static herr_t H5VL_native_link_remove(void *obj, H5VL_loc_params_t loc_params, hid_t req);
+
+/* Object callbacks */
+static void *H5VL_native_object_open(void *obj, H5VL_loc_params_t loc_params, H5I_type_t *opened_type, hid_t req);
+static herr_t H5VL_native_object_copy(void *src_obj, H5VL_loc_params_t loc_params1, const char *src_name,
+ void *dst_obj, H5VL_loc_params_t loc_params2, const char *dst_name,
+ hid_t ocpypl_id, hid_t lcpl_id, hid_t req);
+static herr_t H5VL_native_object_visit(void *obj, H5VL_loc_params_t loc_params, H5_index_t idx_type,
+ H5_iter_order_t order, H5O_iterate_t op, void *op_data, hid_t req);
+//static herr_t H5VL_native_object_lookup(hid_t loc_id, H5VL_loc_type_t lookup_type, void **location, hid_t req, va_list arguments);
+//static herr_t H5VL_native_object_free_loc(void *location, hid_t req);
+static herr_t H5VL_native_object_get(void *obj, H5VL_loc_params_t loc_params, H5VL_object_get_t get_type, hid_t req, va_list arguments);
+static herr_t H5VL_native_object_misc(void *obj, H5VL_loc_params_t loc_params, H5VL_object_misc_t misc_type, hid_t req, va_list arguments);
+static herr_t H5VL_native_object_optional(void *obj, H5VL_loc_params_t loc_params, H5VL_object_optional_t optional_type, hid_t req, va_list arguments);
+static herr_t H5VL_native_object_close(void *obj, H5VL_loc_params_t loc_params, hid_t req);
static H5VL_class_t H5VL_native_g = {
"native", /* name */
@@ -138,7 +152,8 @@ static H5VL_class_t H5VL_native_g = {
{ /* datatype_cls */
H5VL_native_datatype_commit, /* commit */
H5VL_native_datatype_open, /* open */
- H5VL_native_object_close /* close */
+ H5VL_native_datatype_get_size, /* get_size */
+ H5VL_native_datatype_close /* close */
},
{ /* dataset_cls */
H5VL_native_dataset_create, /* create */
@@ -175,8 +190,8 @@ static H5VL_class_t H5VL_native_g = {
H5VL_native_object_open, /* open */
H5VL_native_object_copy, /* copy */
H5VL_native_object_visit, /* visit */
- H5VL_native_object_lookup, /* lookup */
- H5VL_native_object_free_loc, /* free location */
+ //H5VL_native_object_lookup, /* lookup */
+ //H5VL_native_object_free_loc, /* free location */
H5VL_native_object_get, /* get */
H5VL_native_object_misc, /* misc */
H5VL_native_object_optional, /* optional */
@@ -259,6 +274,235 @@ H5VL_native_term(void)
} /* end H5VL_native_term() */
+/*---------------------------------------------------------------------------
+ * Function: H5VL_native_get_loc
+ *
+ * Purpose: utility routine to get object location
+ *
+ * Returns: Non-negative on success or negative on failure
+ *
+ * Programmer: Mohamad Chaarawi
+ * June, 2012
+ *
+ *---------------------------------------------------------------------------
+ */
+static herr_t
+H5VL_native_get_loc(void *obj, H5I_type_t type, H5G_loc_t *loc)
+{
+ herr_t ret_value = SUCCEED;
+
+ FUNC_ENTER_NOAPI_NOINIT
+
+ switch(type) {
+ case H5I_FILE:
+ /* Construct a group location for root group of the file */
+ if(H5G_root_loc((H5F_t *)obj, loc) < 0)
+ HGOTO_ERROR(H5E_SYM, H5E_BADVALUE, FAIL, "unable to create location for file")
+ break;
+ case H5I_GROUP:
+ if(NULL == (loc->oloc = H5G_oloc((H5G_t *)obj)))
+ HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "unable to get object location of group")
+ if(NULL == (loc->path = H5G_nameof((H5G_t *)obj)))
+ HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "unable to get path of group")
+ break;
+ case H5I_DATATYPE:
+ if(NULL == (loc->oloc = H5T_oloc((H5T_t *)obj)))
+ HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "unable to get object location of datatype")
+ if(NULL == (loc->path = H5T_nameof((H5T_t *)obj)))
+ HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "unable to get path of datatype")
+#if 0
+ H5T_t *tmp_dt = (H5T_t *)obj;
+ H5T_t *dt = (H5T_t *)(tmp_dt->vol_obj);
+ if(NULL == (loc->oloc = H5T_oloc(dt)))
+ HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "unable to get object location of datatype")
+ if(NULL == (loc->path = H5T_nameof(dt)))
+ HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "unable to get path of datatype")
+#endif
+ break;
+ case H5I_DATASET:
+ if(NULL == (loc->oloc = H5D_oloc((H5D_t *)obj)))
+ HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "unable to get object location of dataset")
+ if(NULL == (loc->path = H5D_nameof((H5D_t *)obj)))
+ HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "unable to get path of dataset")
+ break;
+ case H5I_ATTR:
+ if(NULL == (loc->oloc = H5A_oloc((H5A_t *)obj)))
+ HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "unable to get object location of attribute")
+ if(NULL == (loc->path = H5A_nameof((H5A_t *)obj)))
+ HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "unable to get path of attribute")
+ break;
+ case H5I_FILE_PRIVATE:
+ case H5I_UNINIT:
+ case H5I_BADID:
+ case H5I_DATASPACE:
+ case H5I_REFERENCE:
+ case H5I_VFL:
+ case H5I_VOL:
+ case H5I_GENPROP_CLS:
+ case H5I_GENPROP_LST:
+ case H5I_ERROR_CLASS:
+ case H5I_ERROR_MSG:
+ case H5I_ERROR_STACK:
+ case H5I_NTYPES:
+ default:
+ HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a file or file object")
+ } /* end switch */
+done:
+ FUNC_LEAVE_NOAPI(ret_value)
+} /* H5VL_native_get_loc */
+
+
+/*---------------------------------------------------------------------------
+ * Function: H5VL_native_get_file
+ *
+ * Purpose: utility routine to get file object
+ *
+ * Returns: Non-negative on success or negative on failure
+ *
+ * Programmer: Mohamad Chaarawi
+ * June, 2012
+ *
+ *---------------------------------------------------------------------------
+ */
+static H5F_t *
+H5VL_native_get_file(void *obj, H5I_type_t type)
+{
+ H5F_t *ret_value = NULL; /* File to flush */
+ H5O_loc_t *oloc = NULL; /* Object location for ID */
+
+ FUNC_ENTER_NOAPI_NOINIT
+
+ switch(type) {
+ case H5I_FILE:
+ ret_value = (H5F_t *) obj;
+ break;
+ case H5I_GROUP:
+ {
+ H5G_t *grp;
+ grp = (H5G_t *)obj;
+ oloc = H5G_oloc(grp);
+ break;
+ }
+ case H5I_DATATYPE:
+ {
+ H5T_t *dt;
+ dt = (H5T_t *)obj;
+ oloc = H5T_oloc(dt);
+ break;
+ }
+ case H5I_DATASET:
+ {
+ H5D_t *dset;
+ dset = (H5D_t *)obj;
+ oloc = H5D_oloc(dset);
+ break;
+ }
+
+ case H5I_ATTR:
+ {
+ H5A_t *attr;
+ attr = (H5A_t *)obj;
+ oloc = H5A_oloc(attr);
+ break;
+ }
+ case H5I_FILE_PRIVATE:
+ case H5I_UNINIT:
+ case H5I_BADID:
+ case H5I_DATASPACE:
+ case H5I_REFERENCE:
+ case H5I_VFL:
+ case H5I_VOL:
+ case H5I_GENPROP_CLS:
+ case H5I_GENPROP_LST:
+ case H5I_ERROR_CLASS:
+ case H5I_ERROR_MSG:
+ case H5I_ERROR_STACK:
+ case H5I_NTYPES:
+ default:
+ HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, NULL, "not a file or file object")
+ } /* end switch */
+
+ if(!ret_value) {
+ if(!oloc)
+ HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, NULL, "object is not assocated with a file")
+ ret_value = oloc->file;
+ } /* end if */
+ if(!ret_value)
+ HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, NULL, "object is not associated with a file")
+
+done:
+ FUNC_LEAVE_NOAPI(ret_value)
+}/* H5VL_native_get_file */
+
+
+/*---------------------------------------------------------------------------
+ * Function: H5VL_native_register_aux
+ *
+ * Purpose: utility routine to register the native VOL plugin to an ID
+ *
+ * Returns: Non-negative on success or negative on failure
+ *
+ * Programmer: Mohamad Chaarawi
+ * June, 2012
+ *
+ *---------------------------------------------------------------------------
+ */
+herr_t
+H5VL_native_register_aux(hid_t obj_id)
+{
+ H5VL_t *vol_plugin; /* VOL plugin information */
+ herr_t ret_value = SUCCEED;
+
+ FUNC_ENTER_NOAPI_NOINIT
+
+ /* Build the vol plugin struct */
+ if(NULL == (vol_plugin = (H5VL_t *)H5MM_calloc(sizeof(H5VL_t))))
+ HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, FAIL, "memory allocation failed")
+ vol_plugin->cls = &H5VL_native_g;
+ vol_plugin->nrefs = 1;
+
+ switch(H5I_get_type(obj_id)) {
+ case H5I_FILE:
+ if (H5I_register_aux(obj_id, vol_plugin, (H5I_free2_t)H5F_close_file) < 0)
+ HGOTO_ERROR(H5E_VOL, H5E_CANTINIT, FAIL, "can't attach vol info to ID")
+ break;
+ case H5I_GROUP:
+ if (H5I_register_aux(obj_id, vol_plugin, (H5I_free2_t)H5G_close_group) < 0)
+ HGOTO_ERROR(H5E_VOL, H5E_CANTINIT, FAIL, "can't attach vol info to ID")
+ break;
+ case H5I_DATATYPE:
+ if (H5I_register_aux(obj_id, vol_plugin, (H5I_free2_t)H5T_close_datatype) < 0)
+ HGOTO_ERROR(H5E_VOL, H5E_CANTINIT, FAIL, "can't attach vol info to ID")
+ break;
+ case H5I_DATASET:
+ if (H5I_register_aux(obj_id, vol_plugin, (H5I_free2_t)H5D_close_dataset) < 0)
+ HGOTO_ERROR(H5E_VOL, H5E_CANTINIT, FAIL, "can't attach vol info to ID")
+ break;
+ case H5I_ATTR:
+ if (H5I_register_aux(obj_id, vol_plugin, (H5I_free2_t)H5A_close_attr) < 0)
+ HGOTO_ERROR(H5E_VOL, H5E_CANTINIT, FAIL, "can't attach vol info to ID")
+ break;
+ case H5I_FILE_PRIVATE:
+ case H5I_UNINIT:
+ case H5I_BADID:
+ case H5I_DATASPACE:
+ case H5I_REFERENCE:
+ case H5I_VFL:
+ case H5I_VOL:
+ case H5I_GENPROP_CLS:
+ case H5I_GENPROP_LST:
+ case H5I_ERROR_CLASS:
+ case H5I_ERROR_MSG:
+ case H5I_ERROR_STACK:
+ case H5I_NTYPES:
+ default:
+ HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a file or file object")
+ } /* end switch */
+done:
+ FUNC_LEAVE_NOAPI(ret_value)
+} /* H5VL_native_register_aux */
+
+
/*-------------------------------------------------------------------------
* Function: H5Pset_fapl_native
*
@@ -304,8 +548,9 @@ done:
*
*-------------------------------------------------------------------------
*/
-static hid_t
-H5VL_native_attr_create(hid_t loc_id, const char *attr_name, hid_t acpl_id, hid_t UNUSED aapl_id, hid_t UNUSED req)
+static void *
+H5VL_native_attr_create(void *obj, H5VL_loc_params_t loc_params, const char *attr_name, hid_t acpl_id,
+ hid_t UNUSED aapl_id, hid_t UNUSED req)
{
H5G_loc_t loc; /* Object location */
H5G_loc_t obj_loc; /* Location used to open group */
@@ -314,36 +559,34 @@ H5VL_native_attr_create(hid_t loc_id, const char *attr_name, hid_t acpl_id, hid_
hid_t type_id, space_id;
H5T_t *type; /* Datatype to use for attribute */
H5S_t *space; /* Dataspace to use for attribute */
- H5VL_loc_params_t loc_params;
- hid_t ret_value;
+ H5A_t *attr = NULL;
+ void *ret_value = NULL;
FUNC_ENTER_NOAPI_NOINIT
/* Get the plist structure */
if(NULL == (plist = (H5P_genplist_t *)H5I_object(acpl_id)))
- HGOTO_ERROR(H5E_ATOM, H5E_BADATOM, FAIL, "can't find object for ID")
+ HGOTO_ERROR(H5E_ATOM, H5E_BADATOM, NULL, "can't find object for ID")
/* get creation properties */
if(H5P_get(plist, H5VL_ATTR_TYPE_ID, &type_id) < 0)
- HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, FAIL, "can't get property value for datatype id")
+ HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, NULL, "can't get property value for datatype id")
if(H5P_get(plist, H5VL_ATTR_SPACE_ID, &space_id) < 0)
- HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, FAIL, "can't get property value for space id")
- if(H5P_get(plist, H5VL_ATTR_LOC_PARAMS, &loc_params) < 0)
- HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, FAIL, "can't get property value for lcpl id")
+ HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, NULL, "can't get property value for space id")
- if(H5G_loc(loc_id, &loc) < 0)
- HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a location")
+ if (H5VL_native_get_loc(obj, loc_params.obj_type, &loc) < 0)
+ HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, NULL, "not a file or file object")
if(0 == (H5F_INTENT(loc.oloc->file) & H5F_ACC_RDWR))
- HGOTO_ERROR(H5E_ARGS, H5E_WRITEERROR, FAIL, "no write intent on file")
+ HGOTO_ERROR(H5E_ARGS, H5E_WRITEERROR, NULL, "no write intent on file")
if(NULL == (type = (H5T_t *)H5I_object_verify(type_id, H5I_DATATYPE)))
- HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a type")
+ HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, NULL, "not a type")
if(NULL == (space = (H5S_t *)H5I_object_verify(space_id, H5I_DATASPACE)))
- HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a data space")
+ HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, NULL, "not a data space")
- if(loc_params.type == H5VL_OBJECT_BY_ID) { /* H5Acreate */
+ if(loc_params.type == H5VL_OBJECT_BY_SELF) { /* H5Acreate */
/* Go do the real work for attaching the attribute to the dataset */
- if((ret_value = H5A_create(&loc, attr_name, type, space, acpl_id, H5AC_dxpl_id)) < 0)
- HGOTO_ERROR(H5E_ATTR, H5E_CANTINIT, FAIL, "unable to create attribute")
+ if(NULL == (attr = H5A_create(&loc, attr_name, type, space, acpl_id, H5AC_dxpl_id)))
+ HGOTO_ERROR(H5E_ATTR, H5E_CANTINIT, NULL, "unable to create attribute")
}
else if (loc_params.type == H5VL_OBJECT_BY_NAME) { /* H5Acreate_by_name */
H5G_name_t obj_path; /* Opened object group hier. path */
@@ -357,20 +600,23 @@ H5VL_native_attr_create(hid_t loc_id, const char *attr_name, hid_t acpl_id, hid_
/* Find the object's location */
if(H5G_loc_find(&loc, loc_params.loc_data.loc_by_name.name, &obj_loc/*out*/,
loc_params.loc_data.loc_by_name.plist_id, H5AC_ind_dxpl_id) < 0)
- HGOTO_ERROR(H5E_ATTR, H5E_NOTFOUND, FAIL, "object not found")
+ HGOTO_ERROR(H5E_ATTR, H5E_NOTFOUND, NULL, "object not found")
loc_found = TRUE;
/* Go do the real work for attaching the attribute to the dataset */
- if((ret_value = H5A_create(&obj_loc, attr_name, type, space, acpl_id, H5AC_dxpl_id)) < 0)
- HGOTO_ERROR(H5E_ATTR, H5E_CANTINIT, FAIL, "unable to create attribute")
+ if(NULL == (attr = H5A_create(&obj_loc, attr_name, type, space, acpl_id, H5AC_dxpl_id)))
+ HGOTO_ERROR(H5E_ATTR, H5E_CANTINIT, NULL, "unable to create attribute")
}
else {
- HGOTO_ERROR(H5E_VOL, H5E_UNSUPPORTED, FAIL, "unknown attribute create parameters")
+ HGOTO_ERROR(H5E_VOL, H5E_UNSUPPORTED, NULL, "unknown attribute create parameters")
}
+
+ ret_value = (void *)attr;
+
done:
/* Release resources */
if(loc_found && H5G_loc_free(&obj_loc) < 0)
- HDONE_ERROR(H5E_ATTR, H5E_CANTRELEASE, FAIL, "can't free location")
+ HDONE_ERROR(H5E_ATTR, H5E_CANTRELEASE, NULL, "can't free location")
FUNC_LEAVE_NOAPI(ret_value)
} /* end H5VL_native_attr_create() */
@@ -388,52 +634,51 @@ done:
*
*-------------------------------------------------------------------------
*/
-static hid_t
-H5VL_native_attr_open(hid_t loc_id, H5VL_loc_params_t loc_params, const char *attr_name,
+static void *
+H5VL_native_attr_open(void *obj, H5VL_loc_params_t loc_params, const char *attr_name,
hid_t UNUSED aapl_id, hid_t UNUSED req)
{
H5G_loc_t loc; /* Object location */
H5A_t *attr = NULL; /* Attribute opened */
- hid_t ret_value;
+ void *ret_value;
FUNC_ENTER_NOAPI_NOINIT
/* check arguments */
- if(H5I_ATTR == H5I_get_type(loc_id))
- HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "location is not valid for an attribute")
- if(H5G_loc(loc_id, &loc) < 0)
- HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a location")
+ if (H5VL_native_get_loc(obj, loc_params.obj_type, &loc) < 0)
+ HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, NULL, "not a file or file object")
- if(loc_params.type == H5VL_OBJECT_BY_ID) { /* H5Aopen */
+ if(loc_params.type == H5VL_OBJECT_BY_SELF) { /* H5Aopen */
/* Read in attribute from object header */
if(NULL == (attr = H5O_attr_open_by_name(loc.oloc, attr_name, H5AC_ind_dxpl_id)))
- HGOTO_ERROR(H5E_ATTR, H5E_CANTINIT, FAIL, "unable to load attribute info from object header for attribute: '%s'", attr_name)
+ HGOTO_ERROR(H5E_ATTR, H5E_CANTINIT, NULL, "unable to load attribute info from object header for attribute: '%s'", attr_name)
/* Finish initializing attribute */
if(H5A_open_common(&loc, attr) < 0)
- HGOTO_ERROR(H5E_ATTR, H5E_CANTINIT, FAIL, "unable to initialize attribute")
+ HGOTO_ERROR(H5E_ATTR, H5E_CANTINIT, NULL, "unable to initialize attribute")
}
else if(loc_params.type == H5VL_OBJECT_BY_NAME) { /* H5Aopen_by_name */
/* Open the attribute on the object header */
if(NULL == (attr = H5A_open_by_name(&loc, loc_params.loc_data.loc_by_name.name, attr_name,
loc_params.loc_data.loc_by_name.plist_id, H5AC_ind_dxpl_id)))
- HGOTO_ERROR(H5E_ATTR, H5E_CANTOPENOBJ, FAIL, "can't open attribute")
+ HGOTO_ERROR(H5E_ATTR, H5E_CANTOPENOBJ, NULL, "can't open attribute")
+ }
+ else if(loc_params.type == H5VL_OBJECT_BY_IDX) { /* H5Aopen_by_idx */
+ /* Open the attribute in the object header */
+ if(NULL == (attr = H5A_open_by_idx(&loc, loc_params.loc_data.loc_by_idx.name,
+ loc_params.loc_data.loc_by_idx.idx_type,
+ loc_params.loc_data.loc_by_idx.order,
+ loc_params.loc_data.loc_by_idx.n,
+ loc_params.loc_data.loc_by_idx.plist_id, H5AC_ind_dxpl_id)))
+ HGOTO_ERROR(H5E_ATTR, H5E_CANTOPENOBJ, NULL, "unable to open attribute")
}
else {
- HGOTO_ERROR(H5E_VOL, H5E_UNSUPPORTED, FAIL, "unknown attribute open parameters")
+ HGOTO_ERROR(H5E_VOL, H5E_UNSUPPORTED, NULL, "unknown attribute open parameters")
}
- /* Register the attribute and get an ID for it */
- if((ret_value = H5I_register(H5I_ATTR, attr, TRUE)) < 0)
- HGOTO_ERROR(H5E_ATOM, H5E_CANTREGISTER, FAIL, "unable to register attribute for ID")
+ ret_value = (void *)attr;
done:
- /* Cleanup on failure */
- if(ret_value < 0)
- if(attr && H5A_close(attr) < 0)
- HDONE_ERROR(H5E_ATTR, H5E_CANTFREE, FAIL, "can't close attribute")
-
FUNC_LEAVE_NOAPI(ret_value)
-
} /* end H5VL_native_attr_open() */
@@ -450,21 +695,17 @@ done:
*-------------------------------------------------------------------------
*/
static herr_t
-H5VL_native_attr_read(hid_t attr_id, hid_t dtype_id, void *buf, hid_t UNUSED req)
+H5VL_native_attr_read(void *attr, hid_t dtype_id, void *buf, hid_t UNUSED req)
{
- H5A_t *attr; /* Attribute object for ID */
H5T_t *mem_type; /* Memory datatype */
herr_t ret_value; /* Return value */
FUNC_ENTER_NOAPI_NOINIT
- if(NULL == (attr = (H5A_t *)H5I_object_verify(attr_id, H5I_ATTR)))
- HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not an attribute")
if(NULL == (mem_type = (H5T_t *)H5I_object_verify(dtype_id, H5I_DATATYPE)))
HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a datatype")
-
/* Go write the actual data to the attribute */
- if((ret_value = H5A_read(attr, mem_type, buf, H5AC_dxpl_id)) < 0)
+ if((ret_value = H5A_read((H5A_t*)attr, mem_type, buf, H5AC_dxpl_id)) < 0)
HGOTO_ERROR(H5E_ATTR, H5E_READERROR, FAIL, "unable to read attribute")
done:
@@ -485,21 +726,17 @@ done:
*-------------------------------------------------------------------------
*/
static herr_t
-H5VL_native_attr_write(hid_t attr_id, hid_t dtype_id, const void *buf, hid_t UNUSED req)
+H5VL_native_attr_write(void *attr, hid_t dtype_id, const void *buf, hid_t UNUSED req)
{
- H5A_t *attr; /* Attribute object for ID */
H5T_t *mem_type; /* Memory datatype */
herr_t ret_value; /* Return value */
FUNC_ENTER_NOAPI_NOINIT
- if(NULL == (attr = (H5A_t *)H5I_object_verify(attr_id, H5I_ATTR)))
- HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not an attribute")
if(NULL == (mem_type = (H5T_t *)H5I_object_verify(dtype_id, H5I_DATATYPE)))
HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a datatype")
-
/* Go write the actual data to the attribute */
- if((ret_value = H5A_write(attr, mem_type, buf, H5AC_dxpl_id)) < 0)
+ if((ret_value = H5A_write((H5A_t*)attr, mem_type, buf, H5AC_dxpl_id)) < 0)
HGOTO_ERROR(H5E_ATTR, H5E_WRITEERROR, FAIL, "unable to write attribute")
done:
@@ -521,9 +758,8 @@ done:
*-------------------------------------------------------------------------
*/
static herr_t
-H5VL_native_attr_get(hid_t id, H5VL_attr_get_t get_type, hid_t UNUSED req, va_list arguments)
+H5VL_native_attr_get(void *obj, H5VL_attr_get_t get_type, hid_t UNUSED req, va_list arguments)
{
- H5A_t *attr;
herr_t ret_value = SUCCEED; /* Return value */
FUNC_ENTER_NOAPI_NOINIT
@@ -532,23 +768,25 @@ H5VL_native_attr_get(hid_t id, H5VL_attr_get_t get_type, hid_t UNUSED req, va_li
/* H5Aexists/exists_by_name */
case H5VL_ATTR_EXISTS:
{
- char *name = va_arg (arguments, char *);
H5VL_loc_params_t loc_params = va_arg (arguments, H5VL_loc_params_t);
+ char *attr_name = va_arg (arguments, char *);
htri_t *ret = va_arg (arguments, htri_t *);
- H5G_loc_t loc;
+ H5G_loc_t loc;
- if(H5G_loc(id, &loc) < 0)
- HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a location")
+ /* check arguments */
+ if (H5VL_native_get_loc(obj, loc_params.obj_type, &loc) < 0)
+ HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a file or file object")
- if(loc_params.type == H5VL_OBJECT_BY_ID) { /* H5Aexists */
+ if(loc_params.type == H5VL_OBJECT_BY_SELF) { /* H5Aexists */
/* Check if the attribute exists */
- if((*ret = H5O_attr_exists(loc.oloc, name, H5AC_ind_dxpl_id)) < 0)
+ if((*ret = H5O_attr_exists(loc.oloc, attr_name, H5AC_ind_dxpl_id)) < 0)
HGOTO_ERROR(H5E_ATTR, H5E_CANTGET, FAIL, "unable to determine if attribute exists")
}
else if(loc_params.type == H5VL_OBJECT_BY_NAME) { /* H5Aopen_by_name */
/* Check if the attribute exists */
if((*ret = H5A_exists_by_name(loc, loc_params.loc_data.loc_by_name.name,
- name, loc_params.loc_data.loc_by_name.plist_id)) < 0)
+ attr_name,
+ loc_params.loc_data.loc_by_name.plist_id)) < 0)
HGOTO_ERROR(H5E_ATTR, H5E_CANTGET, FAIL, "unable to determine if attribute exists")
}
else {
@@ -560,10 +798,7 @@ H5VL_native_attr_get(hid_t id, H5VL_attr_get_t get_type, hid_t UNUSED req, va_li
case H5VL_ATTR_GET_SPACE:
{
hid_t *ret_id = va_arg (arguments, hid_t *);
-
- /* check arguments */
- if(NULL == (attr = (H5A_t *)H5I_object_verify(id, H5I_ATTR)))
- HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not an attribute")
+ H5A_t *attr = (H5A_t *)obj;
if((*ret_id = H5A_get_space(attr)) < 0)
HGOTO_ERROR(H5E_ARGS, H5E_CANTGET, FAIL, "can't get space ID of attribute")
@@ -573,10 +808,7 @@ H5VL_native_attr_get(hid_t id, H5VL_attr_get_t get_type, hid_t UNUSED req, va_li
case H5VL_ATTR_GET_TYPE:
{
hid_t *ret_id = va_arg (arguments, hid_t *);
-
- /* check arguments */
- if(NULL == (attr = (H5A_t *)H5I_object_verify(id, H5I_ATTR)))
- HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not an attribute")
+ H5A_t *attr = (H5A_t *)obj;
if((*ret_id = H5A_get_type(attr)) < 0)
HGOTO_ERROR(H5E_ARGS, H5E_CANTGET, FAIL, "can't get datatype ID of attribute")
@@ -586,10 +818,7 @@ H5VL_native_attr_get(hid_t id, H5VL_attr_get_t get_type, hid_t UNUSED req, va_li
case H5VL_ATTR_GET_ACPL:
{
hid_t *ret_id = va_arg (arguments, hid_t *);
-
- /* check arguments */
- if(NULL == (attr = (H5A_t *)H5I_object_verify(id, H5I_ATTR)))
- HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not an attribute")
+ H5A_t *attr = (H5A_t *)obj;
if((*ret_id = H5A_get_create_plist(attr)) < 0)
HGOTO_ERROR(H5E_ARGS, H5E_CANTGET, FAIL, "can't get creation property list for attr")
@@ -599,41 +828,121 @@ H5VL_native_attr_get(hid_t id, H5VL_attr_get_t get_type, hid_t UNUSED req, va_li
/* H5Aget_name */
case H5VL_ATTR_GET_NAME:
{
- ssize_t *ret_val = va_arg (arguments, ssize_t *);
+ H5VL_loc_params_t loc_params = va_arg (arguments, H5VL_loc_params_t);
size_t buf_size = va_arg (arguments, size_t);
char *buf = va_arg (arguments, char *);
+ ssize_t *ret_val = va_arg (arguments, ssize_t *);
+ H5A_t *attr = NULL;
- /* check arguments */
- if(NULL == (attr = (H5A_t *)H5I_object_verify(id, H5I_ATTR)))
- HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not an attribute")
-
- /* Call private function in turn */
- if(0 > (*ret_val = H5A_get_name(attr, buf_size, buf)))
- HGOTO_ERROR(H5E_ATTR, H5E_CANTGET, FAIL, "can't get attribute name")
+ if(H5VL_OBJECT_BY_SELF == loc_params.type) {
+ attr = (H5A_t *)obj;
+ /* Call private function in turn */
+ if(0 > (*ret_val = H5A_get_name(attr, buf_size, buf)))
+ HGOTO_ERROR(H5E_ATTR, H5E_CANTGET, FAIL, "can't get attribute name")
+ }
+ else if(H5VL_OBJECT_BY_IDX == loc_params.type) {
+ H5G_loc_t loc;
+
+ /* check arguments */
+ if (H5VL_native_get_loc(obj, loc_params.obj_type, &loc) < 0)
+ HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a file or file object")
+
+ /* Open the attribute on the object header */
+ if(NULL == (attr = H5A_open_by_idx(&loc, loc_params.loc_data.loc_by_idx.name,
+ loc_params.loc_data.loc_by_idx.idx_type,
+ loc_params.loc_data.loc_by_idx.order,
+ loc_params.loc_data.loc_by_idx.n,
+ loc_params.loc_data.loc_by_idx.plist_id,
+ H5AC_ind_dxpl_id)))
+ HGOTO_ERROR(H5E_ATTR, H5E_CANTOPENOBJ, FAIL, "can't open attribute")
+
+ /* Get the length of the name */
+ *ret_val = (ssize_t)HDstrlen(attr->shared->name);
+
+ /* Copy the name into the user's buffer, if given */
+ if(buf) {
+ HDstrncpy(buf, attr->shared->name, MIN((size_t)(ret_value + 1), buf_size));
+ if((size_t)ret_value >= buf_size)
+ buf[buf_size - 1]='\0';
+ } /* end if */
+
+ /* Release resources */
+ if(attr && H5A_close(attr) < 0)
+ HDONE_ERROR(H5E_ATTR, H5E_CANTFREE, FAIL, "can't close attribute")
+ }
+ else
+ HGOTO_ERROR(H5E_SYM, H5E_CANTGET, FAIL, "can't get name of attr")
break;
}
/* H5Aget_info */
case H5VL_ATTR_GET_INFO:
{
+ H5VL_loc_params_t loc_params = va_arg (arguments, H5VL_loc_params_t);
H5A_info_t *ainfo = va_arg (arguments, H5A_info_t *);
+ H5A_t *attr = NULL;
- /* check arguments */
- if(NULL == (attr = (H5A_t *)H5I_object_verify(id, H5I_ATTR)))
- HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not an attribute")
-
- if(H5A_get_info(attr, ainfo) < 0)
- HGOTO_ERROR(H5E_ARGS, H5E_CANTGET, FAIL, "can't get attribute info")
+ if(H5VL_OBJECT_BY_SELF == loc_params.type) {
+ attr = (H5A_t *)obj;
+ if(H5A_get_info(attr, ainfo) < 0)
+ HGOTO_ERROR(H5E_ARGS, H5E_CANTGET, FAIL, "can't get attribute info")
+ }
+ else if(H5VL_OBJECT_BY_NAME == loc_params.type) {
+ char *attr_name = va_arg (arguments, char *);
+ H5G_loc_t loc;
+
+ /* check arguments */
+ if (H5VL_native_get_loc(obj, loc_params.obj_type, &loc) < 0)
+ HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a file or file object")
+
+ /* Open the attribute on the object header */
+ if(NULL == (attr = H5A_open_by_name(&loc, loc_params.loc_data.loc_by_name.name,
+ attr_name,
+ loc_params.loc_data.loc_by_name.plist_id,
+ H5AC_ind_dxpl_id)))
+ HGOTO_ERROR(H5E_ATTR, H5E_CANTOPENOBJ, FAIL, "can't open attribute")
+
+ /* Get the attribute information */
+ if(H5A_get_info(attr, ainfo) < 0)
+ HGOTO_ERROR(H5E_ATTR, H5E_CANTGET, FAIL, "unable to get attribute info")
+
+ /* Release resources */
+ if(attr && H5A_close(attr) < 0)
+ HDONE_ERROR(H5E_ATTR, H5E_CANTFREE, FAIL, "can't close attribute")
+ }
+ else if(H5VL_OBJECT_BY_IDX == loc_params.type) {
+ H5G_loc_t loc;
+
+ /* check arguments */
+ if (H5VL_native_get_loc(obj, loc_params.obj_type, &loc) < 0)
+ HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a file or file object")
+
+ /* Open the attribute on the object header */
+ if(NULL == (attr = H5A_open_by_idx(&loc, loc_params.loc_data.loc_by_idx.name,
+ loc_params.loc_data.loc_by_idx.idx_type,
+ loc_params.loc_data.loc_by_idx.order,
+ loc_params.loc_data.loc_by_idx.n,
+ loc_params.loc_data.loc_by_idx.plist_id,
+ H5AC_ind_dxpl_id)))
+ HGOTO_ERROR(H5E_ATTR, H5E_CANTOPENOBJ, FAIL, "can't open attribute")
+
+ /* Get the attribute information */
+ if(H5A_get_info(attr, ainfo) < 0)
+ HGOTO_ERROR(H5E_ATTR, H5E_CANTGET, FAIL, "unable to get attribute info")
+
+ /* Release resources */
+ if(attr && H5A_close(attr) < 0)
+ HDONE_ERROR(H5E_ATTR, H5E_CANTFREE, FAIL, "can't close attribute")
+ }
+ else
+ HGOTO_ERROR(H5E_SYM, H5E_CANTGET, FAIL, "can't get name of attr")
break;
}
case H5VL_ATTR_GET_STORAGE_SIZE:
{
hsize_t *ret = va_arg (arguments, hsize_t *);
-
- /* check arguments */
- if(NULL == (attr = (H5A_t *)H5I_object_verify(id, H5I_ATTR)))
- HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not an attribute")
+ H5A_t *attr = (H5A_t *)obj;
/* Set return value */
*ret = attr->shared->data_size;
@@ -662,28 +971,28 @@ done:
*-------------------------------------------------------------------------
*/
static herr_t
-H5VL_native_attr_remove(hid_t loc_id, H5VL_loc_params_t loc_params, const char *attr_name,
+H5VL_native_attr_remove(void *obj, H5VL_loc_params_t loc_params, const char *attr_name,
hid_t UNUSED req)
{
H5G_loc_t loc; /* Object location */
H5G_loc_t obj_loc; /* Location used to open group */
+ H5G_name_t obj_path; /* Opened object group hier. path */
+ H5O_loc_t obj_oloc; /* Opened object object location */
hbool_t loc_found = FALSE; /* Entry at 'obj_name' found */
herr_t ret_value = SUCCEED; /* Return value */
FUNC_ENTER_NOAPI_NOINIT
- if(H5G_loc(loc_id, &loc) < 0)
- HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a location")
+ /* check arguments */
+ if (H5VL_native_get_loc(obj, loc_params.obj_type, &loc) < 0)
+ HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a file or file object")
- if(loc_params.type == H5VL_OBJECT_BY_ID) { /* H5Adelete */
+ if(loc_params.type == H5VL_OBJECT_BY_SELF) { /* H5Adelete */
/* Delete the attribute from the location */
if(H5O_attr_remove(loc.oloc, attr_name, H5AC_dxpl_id) < 0)
HGOTO_ERROR(H5E_ATTR, H5E_CANTDELETE, FAIL, "unable to delete attribute")
}
else if (loc_params.type == H5VL_OBJECT_BY_NAME) { /* H5Adelete_by_name */
- H5G_name_t obj_path; /* Opened object group hier. path */
- H5O_loc_t obj_oloc; /* Opened object object location */
-
/* Set up opened group location to fill in */
obj_loc.oloc = &obj_oloc;
obj_loc.path = &obj_path;
@@ -699,6 +1008,24 @@ H5VL_native_attr_remove(hid_t loc_id, H5VL_loc_params_t loc_params, const char *
if(H5O_attr_remove(obj_loc.oloc, attr_name, H5AC_dxpl_id) < 0)
HGOTO_ERROR(H5E_ATTR, H5E_CANTDELETE, FAIL, "unable to delete attribute")
}
+ if(loc_params.type == H5VL_OBJECT_BY_IDX) { /* H5Adelete_by_idx */
+ /* Set up opened group location to fill in */
+ obj_loc.oloc = &obj_oloc;
+ obj_loc.path = &obj_path;
+ H5G_loc_reset(&obj_loc);
+
+ /* Find the object's location */
+ if(H5G_loc_find(&loc, loc_params.loc_data.loc_by_idx.name, &obj_loc/*out*/,
+ loc_params.loc_data.loc_by_idx.plist_id, H5AC_dxpl_id) < 0)
+ HGOTO_ERROR(H5E_ATTR, H5E_NOTFOUND, FAIL, "object not found")
+ loc_found = TRUE;
+
+ /* Delete the attribute from the location */
+ if(H5O_attr_remove_by_idx(obj_loc.oloc, loc_params.loc_data.loc_by_idx.idx_type,
+ loc_params.loc_data.loc_by_idx.order,
+ loc_params.loc_data.loc_by_idx.n, H5AC_dxpl_id) < 0)
+ HGOTO_ERROR(H5E_ATTR, H5E_CANTDELETE, FAIL, "unable to delete attribute")
+ }
else {
HGOTO_ERROR(H5E_VOL, H5E_UNSUPPORTED, FAIL, "unknown attribute remove parameters")
}
@@ -726,19 +1053,14 @@ done:
*-------------------------------------------------------------------------
*/
static herr_t
-H5VL_native_attr_close(hid_t attr_id, hid_t UNUSED req)
+H5VL_native_attr_close(void *attr, hid_t UNUSED req)
{
herr_t ret_value = SUCCEED; /* Return value */
FUNC_ENTER_NOAPI_NOINIT
- /* check arguments */
- if(NULL == H5I_object_verify(attr_id, H5I_ATTR))
- HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not an attribute")
-
- /* Decrement references to that atom (and close it) */
- if(H5I_dec_app_ref(attr_id) < 0)
- HGOTO_ERROR(H5E_ATTR, H5E_CANTDEC, FAIL, "can't close attribute")
+ if(H5A_close((H5A_t*)attr) < 0)
+ HGOTO_ERROR(H5E_SYM, H5E_CANTDEC, FAIL, "can't close attribute")
done:
FUNC_LEAVE_NOAPI(ret_value)
@@ -758,31 +1080,39 @@ done:
*
*-------------------------------------------------------------------------
*/
-static herr_t
-H5VL_native_datatype_commit(hid_t loc_id, const char *name, hid_t type_id, hid_t lcpl_id,
- hid_t tcpl_id, hid_t tapl_id, hid_t UNUSED req)
+static void *
+H5VL_native_datatype_commit(void *obj, H5VL_loc_params_t loc_params, const char *name, hid_t type_id,
+ hid_t lcpl_id, hid_t tcpl_id, hid_t tapl_id, hid_t UNUSED req)
{
H5G_loc_t loc; /* Location to commit datatype */
- H5T_t *type; /* Datatype for ID */
- herr_t ret_value = SUCCEED; /* Return value */
+ H5T_t *dt; /* Datatype for ID */
+ H5T_t *type; /* copy of the original type which will be committed */
+ void *ret_value = NULL; /* Return value */
FUNC_ENTER_NOAPI_NOINIT
- if(H5G_loc(loc_id, &loc) < 0)
- HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a location")
+ /* check arguments */
+ if (H5VL_native_get_loc(obj, loc_params.obj_type, &loc) < 0)
+ HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, NULL, "not a file or file object")
- if(NULL == (type = (H5T_t *)H5I_object_verify(type_id, H5I_DATATYPE)))
- HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a datatype")
+ if(NULL == (dt = (H5T_t *)H5I_object_verify(type_id, H5I_DATATYPE)))
+ HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, NULL, "not a datatype")
+
+ /* Copy the datatype - the copied one will be the type that is
+ committed, and attached to original datatype above the VOL
+ layer*/
+ if(NULL == (type = H5T_copy(dt, H5T_COPY_TRANSIENT)))
+ HGOTO_ERROR(H5E_DATATYPE, H5E_CANTINIT, NULL, "unable to copy");
if (NULL != name) { /* H5Tcommit */
/* Commit the type */
if(H5T__commit_named(&loc, name, type, lcpl_id, tcpl_id, tapl_id, H5AC_dxpl_id) < 0)
- HGOTO_ERROR(H5E_DATATYPE, H5E_CANTINIT, FAIL, "unable to commit datatype")
+ HGOTO_ERROR(H5E_DATATYPE, H5E_CANTINIT, NULL, "unable to commit datatype")
}
else { /* H5Tcommit_anon */
/* Commit the type */
if(H5T__commit(loc.oloc->file, type, tcpl_id, H5AC_dxpl_id) < 0)
- HGOTO_ERROR(H5E_DATATYPE, H5E_CANTINIT, FAIL, "unable to commit datatype")
+ HGOTO_ERROR(H5E_DATATYPE, H5E_CANTINIT, NULL, "unable to commit datatype")
/* Release the datatype's object header */
{
@@ -790,16 +1120,20 @@ H5VL_native_datatype_commit(hid_t loc_id, const char *name, hid_t type_id, hid_t
/* Get the new committed datatype's object location */
if(NULL == (oloc = H5T_oloc(type)))
- HGOTO_ERROR(H5E_DATATYPE, H5E_CANTGET, FAIL, "unable to get object location of committed datatype")
+ HGOTO_ERROR(H5E_DATATYPE, H5E_CANTGET, NULL, "unable to get object location of committed datatype")
/* Decrement refcount on committed datatype's object header in memory */
if(H5O_dec_rc_by_loc(oloc, H5AC_dxpl_id) < 0)
- HGOTO_ERROR(H5E_DATATYPE, H5E_CANTDEC, FAIL, "unable to decrement refcount on newly created object")
+ HGOTO_ERROR(H5E_DATATYPE, H5E_CANTDEC, NULL, "unable to decrement refcount on newly created object")
} /* end if */
}
-
+ ret_value = (void *)type;
+ /* Increment reference count on atom because the commit callback in the native implementation
+ return the same object as the type ID itself
+ if(H5I_inc_ref(type_id, TRUE) < 0)
+ HGOTO_ERROR(H5E_ATOM, H5E_CANTSET, FAIL, "incrementing type ID failed")
+ */
done:
-
FUNC_LEAVE_NOAPI(ret_value)
} /* end H5VL_native_datatype_commit() */
@@ -817,10 +1151,11 @@ done:
*
*-------------------------------------------------------------------------
*/
-static hid_t
-H5VL_native_datatype_open(hid_t loc_id, const char *name, hid_t tapl_id, hid_t UNUSED req)
+static void *
+H5VL_native_datatype_open(void *obj, H5VL_loc_params_t loc_params, const char *name,
+ unsigned char *buf, size_t nalloc, hid_t tapl_id, hid_t UNUSED req)
{
- H5T_t *type = NULL; /* Datatype opened in file */
+ H5T_t *type = NULL; /* Datatype opened in file */
H5G_loc_t loc; /* Group location of object to open */
H5G_name_t path; /* Datatype group hier. path */
H5O_loc_t oloc; /* Datatype object location */
@@ -828,12 +1163,80 @@ H5VL_native_datatype_open(hid_t loc_id, const char *name, hid_t tapl_id, hid_t U
H5G_loc_t type_loc; /* Group object for datatype */
hbool_t obj_found = FALSE; /* Object at 'name' found */
hid_t dxpl_id = H5AC_dxpl_id; /* dxpl to use to open datatype */
- hid_t ret_value = FAIL;
+ void *ret_value = NULL;
FUNC_ENTER_NOAPI_NOINIT
- if(H5G_loc(loc_id, &loc) < 0)
- HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a location")
+ if (H5VL_native_get_loc(obj, loc_params.obj_type, &loc) < 0)
+ HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, NULL, "not a file or file object")
+
+ /* Set up datatype location to fill in */
+ type_loc.oloc = &oloc;
+ type_loc.path = &path;
+ H5G_loc_reset(&type_loc);
+
+ /*
+ * Find the named datatype object header and read the datatype message
+ * from it.
+ */
+ if(H5G_loc_find(&loc, name, &type_loc/*out*/, tapl_id, dxpl_id) < 0)
+ HGOTO_ERROR(H5E_DATATYPE, H5E_NOTFOUND, NULL, "not found")
+ obj_found = TRUE;
+
+ /* Check that the object found is the correct type */
+ if(H5O_obj_type(&oloc, &obj_type, dxpl_id) < 0)
+ HGOTO_ERROR(H5E_DATATYPE, H5E_CANTGET, NULL, "can't get object type")
+ if(obj_type != H5O_TYPE_NAMED_DATATYPE)
+ HGOTO_ERROR(H5E_DATATYPE, H5E_BADTYPE, NULL, "not a named datatype")
+
+ /* Open it */
+ if(NULL == (type = H5T_open(&type_loc, dxpl_id)))
+ HGOTO_ERROR(H5E_DATATYPE, H5E_CANTOPENOBJ, NULL, "unable to open named datatype")
+
+ if(H5T_encode(type, buf, &nalloc) < 0)
+ HGOTO_ERROR(H5E_DATATYPE, H5E_BADTYPE, NULL, "can't serialize datatype")
+
+ ret_value = (void *)type;
+done:
+ if(NULL == type)
+ if(obj_found && H5F_addr_defined(type_loc.oloc->addr))
+ H5G_loc_free(&type_loc);
+ FUNC_LEAVE_NOAPI(ret_value)
+} /* end H5VL_native_datatype_open() */
+
+
+/*-------------------------------------------------------------------------
+ * Function: H5VL_native_datatype_get_size
+ *
+ * Purpose: gets size required to encode the datatype
+ *
+ * Return: Success: datatype id.
+ * Failure: -1
+ *
+ * Programmer: Mohamad Chaarawi
+ * March, 2012
+ *
+ *-------------------------------------------------------------------------
+ */
+static ssize_t
+H5VL_native_datatype_get_size(void *obj, H5VL_loc_params_t loc_params, const char *name,
+ hid_t tapl_id, hid_t UNUSED req)
+{
+ H5T_t *type = NULL; /* Datatype opened in file */
+ H5G_loc_t loc; /* Group location of object to open */
+ H5G_name_t path; /* Datatype group hier. path */
+ H5O_loc_t oloc; /* Datatype object location */
+ H5O_type_t obj_type; /* Type of object at location */
+ H5G_loc_t type_loc; /* Group object for datatype */
+ hbool_t obj_found = FALSE; /* Object at 'name' found */
+ hid_t dxpl_id = H5AC_dxpl_id; /* dxpl to use to open datatype */
+ size_t nalloc;
+ ssize_t ret_value = FAIL;
+
+ FUNC_ENTER_NOAPI_NOINIT
+
+ if (H5VL_native_get_loc(obj, loc_params.obj_type, &loc) < 0)
+ HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a file or file object")
/* Set up datatype location to fill in */
type_loc.oloc = &oloc;
@@ -858,21 +1261,44 @@ H5VL_native_datatype_open(hid_t loc_id, const char *name, hid_t tapl_id, hid_t U
if(NULL == (type = H5T_open(&type_loc, dxpl_id)))
HGOTO_ERROR(H5E_DATATYPE, H5E_CANTOPENOBJ, FAIL, "unable to open named datatype")
- /* Register the type and return the ID */
- if((ret_value = H5I_register(H5I_DATATYPE, type, TRUE)) < 0)
- HGOTO_ERROR(H5E_DATATYPE, H5E_CANTREGISTER, FAIL, "unable to register named datatype")
+ if(H5T_encode(type, NULL, &nalloc) < 0)
+ HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "can't determine serialized length of datatype")
+ ret_value = (ssize_t) nalloc;
done:
- if(ret_value < 0) {
- if(type != NULL)
- H5T_close(type);
- else {
- if(obj_found && H5F_addr_defined(type_loc.oloc->addr))
- H5G_loc_free(&type_loc);
- } /* end else */
- } /* end if */
+ /* Close the datatype */
+ if(NULL != type && H5T_close(type) < 0)
+ HGOTO_ERROR(H5E_DATATYPE, H5E_CANTOPENOBJ, FAIL, "unable to close Datatype")
FUNC_LEAVE_NOAPI(ret_value)
-} /* end H5VL_native_datatype_open() */
+} /* end H5VL_native_datatype_get_size() */
+
+
+/*-------------------------------------------------------------------------
+ * Function: H5VL_native_datatype_close
+ *
+ * Purpose: Closes an datatype.
+ *
+ * Return: Success: 0
+ * Failure: -1, datatype not closed.
+ *
+ * Programmer: Mohamad Chaarawi
+ * March, 2012
+ *
+ *-------------------------------------------------------------------------
+ */
+static herr_t
+H5VL_native_datatype_close(void *dt, hid_t UNUSED req)
+{
+ herr_t ret_value = SUCCEED; /* Return value */
+
+ FUNC_ENTER_NOAPI_NOINIT
+
+ if(H5T_close((H5T_t*)dt) < 0)
+ HGOTO_ERROR(H5E_SYM, H5E_CANTDEC, FAIL, "can't close datatype")
+
+done:
+ FUNC_LEAVE_NOAPI(ret_value)
+} /* end H5VL_native_datatype_close() */
/*-------------------------------------------------------------------------
@@ -888,57 +1314,54 @@ done:
*
*-------------------------------------------------------------------------
*/
-static hid_t
-H5VL_native_dataset_create(hid_t loc_id, const char *name, hid_t dcpl_id, hid_t dapl_id, hid_t UNUSED req)
+static void *
+H5VL_native_dataset_create(void *obj, H5VL_loc_params_t loc_params, const char *name, hid_t dcpl_id,
+ hid_t dapl_id, hid_t UNUSED req)
{
H5P_genplist_t *plist; /* Property list pointer */
H5G_loc_t loc; /* Object location to insert dataset into */
hid_t type_id, space_id, lcpl_id;
H5D_t *dset = NULL; /* New dataset's info */
const H5S_t *space; /* Dataspace for dataset */
- hid_t ret_value;
+ void *ret_value;
FUNC_ENTER_NOAPI_NOINIT
/* Get the plist structure */
if(NULL == (plist = (H5P_genplist_t *)H5I_object(dcpl_id)))
- HGOTO_ERROR(H5E_ATOM, H5E_BADATOM, FAIL, "can't find object for ID")
+ HGOTO_ERROR(H5E_ATOM, H5E_BADATOM, NULL, "can't find object for ID")
/* get creation properties */
if(H5P_get(plist, H5VL_DSET_TYPE_ID, &type_id) < 0)
- HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, FAIL, "can't get property value for datatype id")
+ HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, NULL, "can't get property value for datatype id")
if(H5P_get(plist, H5VL_DSET_SPACE_ID, &space_id) < 0)
- HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, FAIL, "can't get property value for space id")
+ HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, NULL, "can't get property value for space id")
if(H5P_get(plist, H5VL_DSET_LCPL_ID, &lcpl_id) < 0)
- HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, FAIL, "can't get property value for lcpl id")
+ HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, NULL, "can't get property value for lcpl id")
/* Check arguments */
- if(H5G_loc(loc_id, &loc) < 0)
- HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a location ID")
+ if (H5VL_native_get_loc(obj, loc_params.obj_type, &loc) < 0)
+ HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, NULL, "not a file or file object")
if(H5I_DATATYPE != H5I_get_type(type_id))
- HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a datatype ID")
+ HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, NULL, "not a datatype ID")
if(NULL == (space = (const H5S_t *)H5I_object_verify(space_id, H5I_DATASPACE)))
- HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a dataspace ID")
+ HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, NULL, "not a dataspace ID")
/* H5Dcreate_anon */
if (NULL == name) {
/* build and open the new dataset */
if(NULL == (dset = H5D__create(loc.oloc->file, type_id, space, dcpl_id, dapl_id, H5AC_dxpl_id)))
- HGOTO_ERROR(H5E_DATASET, H5E_CANTINIT, FAIL, "unable to create dataset")
-
- /* Register the new dataset to get an ID for it */
- if((ret_value = H5I_register(H5I_DATASET, dset, TRUE)) < 0)
- HGOTO_ERROR(H5E_DATASET, H5E_CANTREGISTER, FAIL, "unable to register dataset")
+ HGOTO_ERROR(H5E_DATASET, H5E_CANTINIT, NULL, "unable to create dataset")
}
/* H5Dcreate2 */
else {
/* Create the new dataset & get its ID */
if(NULL == (dset = H5D__create_named(&loc, name, type_id, space, lcpl_id,
dcpl_id, dapl_id, H5AC_dxpl_id)))
- HGOTO_ERROR(H5E_DATASET, H5E_CANTINIT, FAIL, "unable to create dataset")
- if((ret_value = H5I_register(H5I_DATASET, dset, TRUE)) < 0)
- HGOTO_ERROR(H5E_DATASET, H5E_CANTREGISTER, FAIL, "unable to register dataset")
+ HGOTO_ERROR(H5E_DATASET, H5E_CANTINIT, NULL, "unable to create dataset")
}
+ ret_value = (void *)dset;
+
done:
if(NULL == name) {
/* Release the dataset's object header, if it was created */
@@ -947,17 +1370,13 @@ done:
/* Get the new dataset's object location */
if(NULL == (oloc = H5D_oloc(dset)))
- HDONE_ERROR(H5E_DATASET, H5E_CANTGET, FAIL, "unable to get object location of dataset")
+ HDONE_ERROR(H5E_DATASET, H5E_CANTGET, NULL, "unable to get object location of dataset")
/* Decrement refcount on dataset's object header in memory */
if(H5O_dec_rc_by_loc(oloc, H5AC_dxpl_id) < 0)
- HDONE_ERROR(H5E_DATASET, H5E_CANTDEC, FAIL, "unable to decrement refcount on newly created object")
+ HDONE_ERROR(H5E_DATASET, H5E_CANTDEC, NULL, "unable to decrement refcount on newly created object")
} /* end if */
}
- if(ret_value < 0)
- if(dset && H5D_close(dset) < 0)
- HDONE_ERROR(H5E_DATASET, H5E_CLOSEERROR, FAIL, "unable to release dataset")
-
FUNC_LEAVE_NOAPI(ret_value)
} /* end H5VL_native_dataset_create() */
@@ -975,8 +1394,9 @@ done:
*
*-------------------------------------------------------------------------
*/
-static hid_t
-H5VL_native_dataset_open(hid_t loc_id, const char *name, hid_t dapl_id, hid_t UNUSED req)
+static void *
+H5VL_native_dataset_open(void *obj, H5VL_loc_params_t loc_params, const char *name,
+ hid_t dapl_id, hid_t UNUSED req)
{
H5D_t *dset = NULL;
H5G_loc_t loc; /* Object location of group */
@@ -986,12 +1406,12 @@ H5VL_native_dataset_open(hid_t loc_id, const char *name, hid_t dapl_id, hid_t UN
H5O_type_t obj_type; /* Type of object at location */
hbool_t loc_found = FALSE; /* Location at 'name' found */
hid_t dxpl_id = H5AC_dxpl_id; /* dxpl to use to open datset */
- hid_t ret_value;
+ void *ret_value = NULL;
FUNC_ENTER_NOAPI_NOINIT
- if(H5G_loc(loc_id, &loc) < 0)
- HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a location")
+ if (H5VL_native_get_loc(obj, loc_params.obj_type, &loc) < 0)
+ HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, NULL, "not a file or file object")
/* Set up dataset location to fill in */
dset_loc.oloc = &oloc;
@@ -1000,35 +1420,24 @@ H5VL_native_dataset_open(hid_t loc_id, const char *name, hid_t dapl_id, hid_t UN
/* Find the dataset object */
if(H5G_loc_find(&loc, name, &dset_loc, dapl_id, dxpl_id) < 0)
- HGOTO_ERROR(H5E_DATASET, H5E_NOTFOUND, FAIL, "not found")
+ HGOTO_ERROR(H5E_DATASET, H5E_NOTFOUND, NULL, "not found")
loc_found = TRUE;
/* Check that the object found is the correct type */
if(H5O_obj_type(&oloc, &obj_type, dxpl_id) < 0)
- HGOTO_ERROR(H5E_DATASET, H5E_CANTGET, FAIL, "can't get object type")
+ HGOTO_ERROR(H5E_DATASET, H5E_CANTGET, NULL, "can't get object type")
if(obj_type != H5O_TYPE_DATASET)
- HGOTO_ERROR(H5E_DATASET, H5E_BADTYPE, FAIL, "not a dataset")
+ HGOTO_ERROR(H5E_DATASET, H5E_BADTYPE, NULL, "not a dataset")
/* Open the dataset */
if(NULL == (dset = H5D_open(&dset_loc, dapl_id, dxpl_id)))
- HGOTO_ERROR(H5E_DATASET, H5E_CANTINIT, FAIL, "can't open dataset")
+ HGOTO_ERROR(H5E_DATASET, H5E_CANTINIT, NULL, "can't open dataset")
- /* Register an atom for the dataset */
- if((ret_value = H5I_register(H5I_DATASET, dset, TRUE)) < 0)
- HGOTO_ERROR(H5E_ATOM, H5E_CANTREGISTER, FAIL, "can't register dataset atom")
+ ret_value = (void *)dset;
done:
- if(ret_value < 0) {
- if(dset) {
- if(H5D_close(dset) < 0)
- HDONE_ERROR(H5E_DATASET, H5E_CLOSEERROR, FAIL, "unable to release dataset")
- } /* end if */
- else {
- if(loc_found && H5G_loc_free(&dset_loc) < 0)
- HDONE_ERROR(H5E_DATASET, H5E_CANTRELEASE, FAIL, "can't free location")
- } /* end else */
- } /* end if */
-
+ if(NULL == dset && loc_found && H5G_loc_free(&dset_loc) < 0)
+ HDONE_ERROR(H5E_DATASET, H5E_CANTRELEASE, NULL, "can't free location")
FUNC_LEAVE_NOAPI(ret_value)
} /* end H5VL_native_dataset_open() */
@@ -1047,10 +1456,10 @@ done:
*-------------------------------------------------------------------------
*/
static herr_t
-H5VL_native_dataset_read(hid_t dset_id, hid_t mem_type_id, hid_t mem_space_id,
+H5VL_native_dataset_read(void *obj, hid_t mem_type_id, hid_t mem_space_id,
hid_t file_space_id, hid_t plist_id, void *buf, hid_t UNUSED req)
{
- H5D_t *dset = NULL;
+ H5D_t *dset = (H5D_t *)obj;
const H5S_t *mem_space = NULL;
const H5S_t *file_space = NULL;
char fake_char;
@@ -1059,8 +1468,6 @@ H5VL_native_dataset_read(hid_t dset_id, hid_t mem_type_id, hid_t mem_space_id,
FUNC_ENTER_NOAPI_NOINIT
/* check arguments */
- if(NULL == (dset = (H5D_t *)H5I_object_verify(dset_id, H5I_DATASET)))
- HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a dataset")
if(NULL == dset->oloc.file)
HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a dataset")
if(H5S_ALL != mem_space_id) {
@@ -1113,10 +1520,10 @@ done:
*-------------------------------------------------------------------------
*/
static herr_t
-H5VL_native_dataset_write(hid_t dset_id, hid_t mem_type_id, hid_t mem_space_id,
+H5VL_native_dataset_write(void *obj, hid_t mem_type_id, hid_t mem_space_id,
hid_t file_space_id, hid_t dxpl_id, const void *buf, hid_t UNUSED req)
{
- H5D_t *dset = NULL;
+ H5D_t *dset = (H5D_t *)obj;
const H5S_t *mem_space = NULL;
const H5S_t *file_space = NULL;
char fake_char;
@@ -1125,8 +1532,6 @@ H5VL_native_dataset_write(hid_t dset_id, hid_t mem_type_id, hid_t mem_space_id,
FUNC_ENTER_NOAPI_NOINIT
/* check arguments */
- if(NULL == (dset = (H5D_t *)H5I_object_verify(dset_id, H5I_DATASET)))
- HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a dataset")
if(NULL == dset->oloc.file)
HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a dataset")
if(H5S_ALL != mem_space_id) {
@@ -1179,17 +1584,13 @@ done:
*-------------------------------------------------------------------------
*/
static herr_t
-H5VL_native_dataset_set_extent(hid_t dset_id, const hsize_t size[], hid_t UNUSED req)
+H5VL_native_dataset_set_extent(void *obj, const hsize_t size[], hid_t UNUSED req)
{
- H5D_t *dset = NULL;
+ H5D_t *dset = (H5D_t *)obj;
herr_t ret_value = SUCCEED; /* Return value */
FUNC_ENTER_NOAPI_NOINIT
- /* Check args */
- if(NULL == (dset = (H5D_t *)H5I_object_verify(dset_id, H5I_DATASET)))
- HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a dataset")
-
/* Private function */
if(H5D__set_extent(dset, size, H5AC_dxpl_id) < 0)
HGOTO_ERROR(H5E_DATASET, H5E_CANTINIT, FAIL, "unable to set extend dataset")
@@ -1213,17 +1614,13 @@ done:
*-------------------------------------------------------------------------
*/
static herr_t
-H5VL_native_dataset_get(hid_t id, H5VL_dataset_get_t get_type, hid_t UNUSED req, va_list arguments)
+H5VL_native_dataset_get(void *obj, H5VL_dataset_get_t get_type, hid_t UNUSED req, va_list arguments)
{
- H5D_t *dset = NULL;
+ H5D_t *dset = (H5D_t *)obj;
herr_t ret_value = SUCCEED; /* Return value */
FUNC_ENTER_NOAPI_NOINIT
- /* Check args */
- if(NULL == (dset = (H5D_t *)H5I_object_verify(id, H5I_DATASET)))
- HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a dataset")
-
switch (get_type) {
/* H5Dget_space */
case H5VL_DATASET_GET_SPACE:
@@ -1320,26 +1717,14 @@ done:
*-------------------------------------------------------------------------
*/
static herr_t
-H5VL_native_dataset_close(hid_t dset_id, hid_t UNUSED req)
+H5VL_native_dataset_close(void *dset, hid_t UNUSED req)
{
herr_t ret_value = SUCCEED; /* Return value */
FUNC_ENTER_NOAPI_NOINIT
- /* Check args */
- if(NULL == H5I_object_verify(dset_id, H5I_DATASET))
- HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a dataset")
-
- /*
- * Decrement the counter on the dataset. It will be freed if the count
- * reaches zero.
- *
- * Pass in TRUE for the 3rd parameter to tell the function to remove
- * dataset's ID even though the freeing function might fail. Please
- * see the comments in H5I_dec_ref for details. (SLU - 2010/9/7)
- */
- if(H5I_dec_app_ref_always_close(dset_id) < 0)
- HGOTO_ERROR(H5E_DATASET, H5E_CANTDEC, FAIL, "can't decrement count on dataset ID")
+ if(H5D_close((H5D_t*)dset) < 0)
+ HGOTO_ERROR(H5E_DATASET, H5E_CANTDEC, FAIL, "can't close dataset")
done:
FUNC_LEAVE_NOAPI(ret_value)
@@ -1359,11 +1744,12 @@ done:
*
*-------------------------------------------------------------------------
*/
-static hid_t
+static void *
H5VL_native_file_create(const char *name, unsigned flags, hid_t fcpl_id, hid_t fapl_id, hid_t UNUSED req)
{
- H5F_t *new_file; /* file struct */
- hid_t ret_value;
+ H5F_t *new_file = NULL;
+ hid_t file_id = FAIL;
+ void *ret_value;
FUNC_ENTER_NOAPI_NOINIT
@@ -1378,21 +1764,19 @@ H5VL_native_file_create(const char *name, unsigned flags, hid_t fcpl_id, hid_t f
/* Create the file */
if(NULL == (new_file = H5F_open(name, flags, fcpl_id, fapl_id, H5AC_dxpl_id)))
- HGOTO_ERROR(H5E_FILE, H5E_CANTOPENFILE, FAIL, "unable to create file")
-
+ HGOTO_ERROR(H5E_FILE, H5E_CANTOPENFILE, NULL, "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 handle")
-
+ if((file_id = H5I_register(H5I_FILE_PRIVATE, new_file, TRUE)) < 0)
+ HGOTO_ERROR(H5E_ATOM, H5E_CANTREGISTER, NULL, "unable to atomize file handle")
/* store a pointer to the VOL class in the file structure */
new_file->vol_cls = &H5VL_native_g;
+ new_file->file_id = file_id;
- /* Keep this ID in file object structure */
- new_file->file_id = ret_value;
+ ret_value = (void *)new_file;
done:
- if(ret_value < 0 && new_file && H5F_try_close(new_file) < 0)
- HDONE_ERROR(H5E_FILE, H5E_CANTCLOSEFILE, FAIL, "problems closing file")
+ if(file_id < 0 && new_file && H5F_try_close(new_file) < 0)
+ HDONE_ERROR(H5E_FILE, H5E_CANTCLOSEFILE, NULL, "problems closing file")
FUNC_LEAVE_NOAPI(ret_value)
} /* end H5VL_native_file_create() */
@@ -1411,32 +1795,30 @@ done:
*
*-------------------------------------------------------------------------
*/
-static hid_t
+static void *
H5VL_native_file_open(const char *name, unsigned flags, hid_t fapl_id, hid_t UNUSED req)
{
- H5F_t *new_file; /* file struct */
- hid_t ret_value;
+ H5F_t *new_file = NULL;
+ hid_t file_id = FAIL;
+ void *ret_value;
FUNC_ENTER_NOAPI_NOINIT
/* Open the file */
if(NULL == (new_file = H5F_open(name, flags, H5P_FILE_CREATE_DEFAULT, fapl_id, H5AC_dxpl_id)))
- HGOTO_ERROR(H5E_FILE, H5E_CANTOPENFILE, FAIL, "unable to open file")
-
+ HGOTO_ERROR(H5E_FILE, H5E_CANTOPENFILE, NULL, "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")
-
+ if((file_id = H5I_register(H5I_FILE_PRIVATE, new_file, TRUE)) < 0)
+ HGOTO_ERROR(H5E_ATOM, H5E_CANTREGISTER, NULL, "unable to atomize file handle")
/* store a pointer to the VOL class in the file structure */
new_file->vol_cls = &H5VL_native_g;
+ new_file->file_id = file_id;
- /* Keep this ID in file object structure */
- new_file->file_id = ret_value;
+ ret_value = (void *)new_file;
done:
- if(ret_value < 0 && new_file && H5F_try_close(new_file) < 0)
- HDONE_ERROR(H5E_FILE, H5E_CANTCLOSEFILE, FAIL, "problems closing file")
-
+ if(file_id < 0 && new_file && H5F_try_close(new_file) < 0)
+ HDONE_ERROR(H5E_FILE, H5E_CANTCLOSEFILE, NULL, "problems closing file")
FUNC_LEAVE_NOAPI(ret_value)
} /* end H5VL_native_file_open() */
@@ -1455,79 +1837,16 @@ done:
*-------------------------------------------------------------------------
*/
static herr_t
-H5VL_native_file_flush(hid_t object_id, H5F_scope_t scope, hid_t UNUSED req)
+H5VL_native_file_flush(void *obj, H5VL_loc_params_t loc_params, H5F_scope_t scope, hid_t UNUSED req)
{
H5F_t *f = NULL; /* File to flush */
- H5O_loc_t *oloc = NULL; /* Object location for ID */
herr_t ret_value = SUCCEED; /* Return value */
FUNC_ENTER_NOAPI_NOINIT
- switch(H5I_get_type(object_id)) {
- case H5I_FILE:
- if(NULL == (f = (H5F_t *)H5I_object(object_id)))
- HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "invalid file identifier")
- break;
- case H5I_GROUP:
- {
- H5G_t *grp;
-
- if(NULL == (grp = (H5G_t *)H5I_object(object_id)))
- HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "invalid group identifier")
- oloc = H5G_oloc(grp);
- break;
- }
- case H5I_DATATYPE:
- {
- H5T_t *type;
-
- if(NULL == (type = (H5T_t *)H5I_object(object_id)))
- HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "invalid type identifier")
- oloc = H5T_oloc(type);
- break;
- }
- case H5I_DATASET:
- {
- H5D_t *dset;
-
- if(NULL == (dset = (H5D_t *)H5I_object(object_id)))
- HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "invalid dataset identifier")
- oloc = H5D_oloc(dset);
- break;
- }
-
- case H5I_ATTR:
- {
- H5A_t *attr;
-
- if(NULL == (attr = (H5A_t *)H5I_object(object_id)))
- HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "invalid attribute identifier")
- oloc = H5A_oloc(attr);
- break;
- }
- case H5I_UNINIT:
- case H5I_BADID:
- case H5I_DATASPACE:
- case H5I_REFERENCE:
- case H5I_VFL:
- case H5I_VOL:
- case H5I_GENPROP_CLS:
- case H5I_GENPROP_LST:
- case H5I_ERROR_CLASS:
- case H5I_ERROR_MSG:
- case H5I_ERROR_STACK:
- case H5I_NTYPES:
- default:
- HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a file or file object")
- } /* end switch */
-
- if(!f) {
- if(!oloc)
- HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "object is not assocated with a file")
- f = oloc->file;
- } /* end if */
- if(!f)
- HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "object is not associated with a file")
+ if (NULL == (f = H5VL_native_get_file(obj, loc_params.obj_type))) {
+ HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a file or file object")
+ }
/* Flush the file */
/*
@@ -1570,32 +1889,20 @@ done:
*-------------------------------------------------------------------------
*/
static herr_t
-H5VL_native_file_get(hid_t obj_id, H5VL_file_get_t get_type, hid_t UNUSED req, va_list arguments)
+H5VL_native_file_get(void *obj, H5VL_file_get_t get_type, hid_t UNUSED req, va_list arguments)
{
- H5F_t *f = NULL; /* File struct */
+ H5F_t *f = NULL; /* File struct */
herr_t ret_value = SUCCEED; /* Return value */
FUNC_ENTER_NOAPI_NOINIT
- /* Check/fix arguments. */
- if(H5I_FILE == H5I_get_type(obj_id)) {
- if(NULL == (f = (H5F_t *)H5I_object(obj_id)))
- HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a file")
- } /* end if */
- else {
- H5G_loc_t loc; /* Object location */
- /* Get symbol table entry */
- if(H5G_loc(obj_id, &loc) < 0)
- HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "not a valid object ID")
- f = loc.oloc->file;
- } /* end else */
-
switch (get_type) {
/* H5Fget_access_plist */
case H5VL_FILE_GET_FAPL:
{
hid_t *plist_id = va_arg (arguments, hid_t *);
+ f = (H5F_t *)obj;
/* Retrieve the file's access property list */
if((*plist_id = H5F_get_access_plist(f, TRUE)) < 0)
HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, FAIL, "can't get file access property list")
@@ -1607,6 +1914,7 @@ H5VL_native_file_get(hid_t obj_id, H5VL_file_get_t get_type, hid_t UNUSED req, v
H5P_genplist_t *plist; /* Property list */
hid_t *plist_id = va_arg (arguments, hid_t *);
+ f = (H5F_t *)obj;
if(NULL == (plist = (H5P_genplist_t *)H5I_object(f->shared->fcpl_id)))
HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a property list")
@@ -1623,6 +1931,7 @@ H5VL_native_file_get(hid_t obj_id, H5VL_file_get_t get_type, hid_t UNUSED req, v
unsigned types = va_arg (arguments, unsigned);
size_t obj_count = 0; /* Number of opened objects */
+ f = (H5F_t *)obj;
/* Perform the query */
if(H5F_get_obj_count(f, types, TRUE, &obj_count) < 0)
HGOTO_ERROR(H5E_INTERNAL, H5E_BADITER, FAIL, "H5F_get_obj_count failed")
@@ -1640,6 +1949,7 @@ H5VL_native_file_get(hid_t obj_id, H5VL_file_get_t get_type, hid_t UNUSED req, v
ssize_t *ret = va_arg (arguments, ssize_t *);
size_t obj_count = 0; /* Number of opened objects */
+ f = (H5F_t *)obj;
/* Perform the query */
if(H5F_get_obj_ids(f, types, max_objs, oid_list, TRUE, &obj_count) < 0)
HGOTO_ERROR(H5E_INTERNAL, H5E_BADITER, FAIL, "H5F_get_obj_ids failed")
@@ -1653,6 +1963,7 @@ H5VL_native_file_get(hid_t obj_id, H5VL_file_get_t get_type, hid_t UNUSED req, v
{
unsigned *ret = va_arg (arguments, unsigned *);
+ f = (H5F_t *)obj;
/* HDF5 uses some flags internally that users don't know about.
* Simplify things for them so that they only get either H5F_ACC_RDWR
* or H5F_ACC_RDONLY.
@@ -1666,11 +1977,16 @@ H5VL_native_file_get(hid_t obj_id, H5VL_file_get_t get_type, hid_t UNUSED req, v
/* H5Fget_name */
case H5VL_FILE_GET_NAME:
{
+ H5I_type_t type = va_arg (arguments, H5I_type_t);
+ size_t size = va_arg (arguments, size_t);
char *name = va_arg (arguments, char *);
ssize_t *ret = va_arg (arguments, ssize_t *);
- size_t size = va_arg (arguments, size_t);
size_t len;
+ if (NULL == (f = H5VL_native_get_file(obj, type))) {
+ HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a file or file object")
+ }
+
len = HDstrlen(H5F_OPEN_NAME(f));
if(name) {
@@ -1683,6 +1999,29 @@ H5VL_native_file_get(hid_t obj_id, H5VL_file_get_t get_type, hid_t UNUSED req, v
*ret = (ssize_t)len;
break;
}
+ /* H5I_get_file_id */
+ case H5VL_OBJECT_GET_FILE:
+ {
+ H5I_type_t type = va_arg (arguments, H5I_type_t);
+ hbool_t app_ref = va_arg (arguments, hbool_t);
+ void **ret = va_arg (arguments, void **);
+ H5F_t *file = NULL;
+ hid_t file_id;
+ H5G_loc_t loc; /* Location of object */
+
+ if (H5VL_native_get_loc(obj, type, &loc) < 0) {
+ HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a file or file object")
+ }
+ /* Get the file ID for the object */
+ if((file_id = H5F_get_id(loc.oloc->file, app_ref)) < 0)
+ HGOTO_ERROR(H5E_ATOM, H5E_CANTGET, FAIL, "can't get file ID")
+
+ /* return the file object */
+ if(NULL == (file = (H5F_t *)H5I_object(file_id)))
+ HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "invalid file identifier")
+ *ret = (void*)file;
+ break;
+ }
default:
HGOTO_ERROR(H5E_VOL, H5E_CANTGET, FAIL, "can't get this type of information")
} /* end switch */
@@ -1705,7 +2044,7 @@ done:
*-------------------------------------------------------------------------
*/
static herr_t
-H5VL_native_file_misc(hid_t id, H5VL_file_misc_t misc_type, hid_t UNUSED req, va_list arguments)
+H5VL_native_file_misc(void *obj, H5VL_file_misc_t misc_type, hid_t UNUSED req, va_list arguments)
{
herr_t ret_value = SUCCEED; /* Return value */
@@ -1715,18 +2054,15 @@ H5VL_native_file_misc(hid_t id, H5VL_file_misc_t misc_type, hid_t UNUSED req, va
/* H5Fmount */
case H5VL_FILE_MOUNT:
{
+ H5I_type_t type = va_arg (arguments, H5I_type_t);
const char *name = va_arg (arguments, const char *);
- hid_t child_id = va_arg (arguments, hid_t);
+ H5F_t *child = va_arg (arguments, H5F_t *);
hid_t plist_id = va_arg (arguments, hid_t);
H5G_loc_t loc;
- H5F_t *child = NULL;
-
- /* Check arguments */
- if(H5G_loc(id, &loc) < 0)
- HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a location")
- if(NULL == (child = (H5F_t *)H5I_object_verify(child_id, H5I_FILE)))
- HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a file")
+ if (H5VL_native_get_loc(obj, type, &loc) < 0) {
+ HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a file or file object")
+ }
/* Do the mount */
if(H5F_mount(&loc, name, child, plist_id, H5AC_dxpl_id) < 0)
HGOTO_ERROR(H5E_FILE, H5E_MOUNT, FAIL, "unable to mount file")
@@ -1736,13 +2072,13 @@ H5VL_native_file_misc(hid_t id, H5VL_file_misc_t misc_type, hid_t UNUSED req, va
/* H5Fmount */
case H5VL_FILE_UNMOUNT:
{
+ H5I_type_t type = va_arg (arguments, H5I_type_t);
const char *name = va_arg (arguments, const char *);
H5G_loc_t loc;
- /* Check arguments */
- if(H5G_loc(id, &loc) < 0)
- HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a location")
-
+ if (H5VL_native_get_loc(obj, type, &loc) < 0) {
+ HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a file or file object")
+ }
/* Unmount */
if (H5F_unmount(&loc, name, H5AC_dxpl_id) < 0)
HGOTO_ERROR(H5E_FILE, H5E_MOUNT, FAIL, "unable to unmount file")
@@ -1752,8 +2088,9 @@ H5VL_native_file_misc(hid_t id, H5VL_file_misc_t misc_type, hid_t UNUSED req, va
/* H5Fis_accessible */
case H5VL_FILE_IS_ACCESSIBLE:
{
- htri_t *ret = va_arg (arguments, htri_t *);
- const char *name = va_arg (arguments, const char *);
+ hid_t UNUSED fapl_id = va_arg (arguments, hid_t);
+ const char *name = va_arg (arguments, const char *);
+ htri_t *ret = va_arg (arguments, htri_t *);
/* Call private routine */
if((*ret = H5F_is_hdf5(name)) < 0)
@@ -1783,26 +2120,13 @@ done:
*-------------------------------------------------------------------------
*/
static herr_t
-H5VL_native_file_optional(hid_t id, H5VL_file_optional_t optional_type, hid_t UNUSED req, va_list arguments)
+H5VL_native_file_optional(void *obj, H5VL_file_optional_t optional_type, hid_t UNUSED req, va_list arguments)
{
H5F_t *f = NULL; /* File */
herr_t ret_value = SUCCEED; /* Return value */
FUNC_ENTER_NOAPI_NOINIT
- /* Check/fix arguments. */
- if(H5I_FILE == H5I_get_type(id)) {
- if(NULL == (f = (H5F_t *)H5I_object(id)))
- HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a file")
- } /* end if */
- else {
- H5G_loc_t loc; /* Object location */
- /* Get symbol table entry */
- if(H5G_loc(id, &loc) < 0)
- HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "not a valid object ID")
- f = loc.oloc->file;
- } /* end else */
-
switch (optional_type) {
/* H5Fget_filesize */
case H5VL_FILE_GET_SIZE:
@@ -1810,6 +2134,7 @@ H5VL_native_file_optional(hid_t id, H5VL_file_optional_t optional_type, hid_t UN
haddr_t eof; /* End of file address */
hsize_t *ret = va_arg (arguments, hsize_t *);
+ f = (H5F_t *)obj;
/* Go get the actual file size */
if(HADDR_UNDEF == (eof = H5FDget_eof(f->shared->lf)))
HGOTO_ERROR(H5E_FILE, H5E_CANTGET, FAIL, "unable to get file size")
@@ -1823,6 +2148,7 @@ H5VL_native_file_optional(hid_t id, H5VL_file_optional_t optional_type, hid_t UN
ssize_t *ret = va_arg (arguments, ssize_t *);
size_t buf_len = va_arg (arguments, size_t );
+ f = (H5F_t *)obj;
/* Do the actual work */
if((*ret = H5F_get_file_image(f, buf_ptr, buf_len)) < 0)
HGOTO_ERROR(H5E_FILE, H5E_CANTGET, FAIL, "get file image failed")
@@ -1834,6 +2160,7 @@ H5VL_native_file_optional(hid_t id, H5VL_file_optional_t optional_type, hid_t UN
hsize_t tot_space; /* Amount of free space in the file */
hssize_t *ret = va_arg (arguments, hssize_t *);
+ f = (H5F_t *)obj;
/* Go get the actual amount of free space in the file */
if(H5MF_get_freespace(f, H5AC_ind_dxpl_id, &tot_space, NULL) < 0)
HGOTO_ERROR(H5E_FILE, H5E_CANTGET, FAIL, "unable to check free space for file")
@@ -1847,6 +2174,7 @@ H5VL_native_file_optional(hid_t id, H5VL_file_optional_t optional_type, hid_t UN
H5F_mem_t type = va_arg (arguments, H5F_mem_t);
size_t nsects = va_arg (arguments, size_t);
+ f = (H5F_t *)obj;
/* Go get the free-space section information in the file */
if((*ret = H5MF_get_free_sections(f, H5AC_ind_dxpl_id,
type, nsects, sect_info)) < 0)
@@ -1856,8 +2184,13 @@ H5VL_native_file_optional(hid_t id, H5VL_file_optional_t optional_type, hid_t UN
/* H5Fget_info2 */
case H5VL_FILE_GET_INFO:
{
+ H5I_type_t type = va_arg (arguments, H5I_type_t);
H5F_info2_t *finfo = va_arg (arguments, H5F_info2_t *);
+ if (NULL == (f = H5VL_native_get_file(obj, type))) {
+ HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a file or file object")
+ }
+
/* For file IDs, get the file object directly */
/* (This prevents the H5G_loc() call from returning the file pointer for
* the top file in a mount hierarchy)
@@ -1893,6 +2226,7 @@ H5VL_native_file_optional(hid_t id, H5VL_file_optional_t optional_type, hid_t UN
{
H5AC_cache_config_t *config_ptr = va_arg (arguments, H5AC_cache_config_t *);
+ f = (H5F_t *)obj;
/* Go get the resize configuration */
if(H5AC_get_cache_auto_resize_config(f->shared->cache, config_ptr) < 0)
HGOTO_ERROR(H5E_CACHE, H5E_SYSTEM, FAIL, "H5AC_get_cache_auto_resize_config() failed.")
@@ -1903,6 +2237,7 @@ H5VL_native_file_optional(hid_t id, H5VL_file_optional_t optional_type, hid_t UN
{
double *hit_rate_ptr = va_arg (arguments, double *);
+ f = (H5F_t *)obj;
/* Go get the current hit rate */
if(H5AC_get_cache_hit_rate(f->shared->cache, hit_rate_ptr) < 0)
HGOTO_ERROR(H5E_CACHE, H5E_SYSTEM, FAIL, "H5AC_get_cache_hit_rate() failed.")
@@ -1917,6 +2252,7 @@ H5VL_native_file_optional(hid_t id, H5VL_file_optional_t optional_type, hid_t UN
int *cur_num_entries_ptr = va_arg (arguments, int *);
int32_t cur_num_entries;
+ f = (H5F_t *)obj;
/* Go get the size data */
if(H5AC_get_cache_size(f->shared->cache, max_size_ptr, min_clean_size_ptr,
cur_size_ptr, &cur_num_entries) < 0)
@@ -1932,6 +2268,7 @@ H5VL_native_file_optional(hid_t id, H5VL_file_optional_t optional_type, hid_t UN
void **file_handle = va_arg (arguments, void **);
hid_t fapl = va_arg (arguments, hid_t);
+ f = (H5F_t *)obj;
/* Retrieve the VFD handle for the file */
if(H5F_get_vfd_handle(f, fapl, file_handle) < 0)
HGOTO_ERROR(H5E_FILE, H5E_CANTGET, FAIL, "can't retrieve VFD handle")
@@ -1940,6 +2277,7 @@ H5VL_native_file_optional(hid_t id, H5VL_file_optional_t optional_type, hid_t UN
/* H5Fclear_elink_file_cache */
case H5VL_FILE_CLEAR_ELINK_CACHE:
{
+ f = (H5F_t *)obj;
/* Release the EFC */
if(f->shared->efc)
if(H5F_efc_release(f->shared->efc) < 0)
@@ -1949,15 +2287,20 @@ H5VL_native_file_optional(hid_t id, H5VL_file_optional_t optional_type, hid_t UN
/* H5Freopen */
case H5VL_FILE_REOPEN:
{
- hid_t *ret_id = va_arg (arguments, hid_t *);
+ void **ret = va_arg (arguments, void **);
+ H5F_t *new_file = NULL;
- if((*ret_id = H5F_reopen(f)) < 0)
+ f = (H5F_t *)obj;
+ if(NULL == (new_file = H5F_reopen(f)))
HGOTO_ERROR(H5E_FILE, H5E_CANTINIT, FAIL, "unable to reopen file")
+ new_file->vol_cls = &H5VL_native_g;
+ *ret = (void *)new_file;
break;
}
/* H5Freset_mdc_hit_rate_stats */
case H5VL_FILE_RESET_MDC_HIT_RATE:
{
+ f = (H5F_t *)obj;
/* Reset the hit rate statistic */
if(H5AC_reset_cache_hit_rate_stats(f->shared->cache) < 0)
HGOTO_ERROR(H5E_CACHE, H5E_SYSTEM, FAIL, "can't reset cache hit rate")
@@ -1967,6 +2310,7 @@ H5VL_native_file_optional(hid_t id, H5VL_file_optional_t optional_type, hid_t UN
{
H5AC_cache_config_t *config_ptr = va_arg (arguments, H5AC_cache_config_t *);
+ f = (H5F_t *)obj;
/* set the resize configuration */
if(H5AC_set_cache_auto_resize_config(f->shared->cache, config_ptr) < 0)
HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "H5AC_set_cache_auto_resize_config() failed.")
@@ -1995,22 +2339,14 @@ done:
*-------------------------------------------------------------------------
*/
static herr_t
-H5VL_native_file_close(hid_t file_id, hid_t UNUSED req)
+H5VL_native_file_close(void *file, hid_t UNUSED req)
{
int nref;
- H5F_t *f;
+ H5F_t *f = (H5F_t *)file;
herr_t ret_value = SUCCEED; /* Return value */
FUNC_ENTER_NOAPI_NOINIT
- /* Check/fix arguments. */
- if(H5I_FILE != H5I_get_type(file_id))
- HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a file ID")
-
- /* get the file struct */
- if(NULL == (f = (H5F_t *)H5I_object(file_id)))
- HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "invalid file identifier")
-
/* Flush file if this is the last reference to this id and we have write
* intent, unless it will be flushed by the "shared" file being closed.
* This is only necessary to replicate previous behaviour, and could be
@@ -2022,6 +2358,7 @@ H5VL_native_file_close(hid_t file_id, hid_t UNUSED req)
if(H5F_flush(f, H5AC_dxpl_id, FALSE) < 0)
HGOTO_ERROR(H5E_CACHE, H5E_CANTFLUSH, FAIL, "unable to flush cache")
} /* end if */
+
/*
* Decrement reference count on atom. When it reaches zero the file will
* be closed.
@@ -2047,27 +2384,28 @@ done:
*
*-------------------------------------------------------------------------
*/
-static hid_t
-H5VL_native_group_create(hid_t loc_id, const char *name, hid_t gcpl_id, hid_t gapl_id, hid_t UNUSED req)
+static void *
+H5VL_native_group_create(void *obj, H5VL_loc_params_t loc_params, const char *name, hid_t gcpl_id,
+ hid_t gapl_id, hid_t UNUSED req)
{
H5P_genplist_t *plist; /* Property list pointer */
H5G_loc_t loc; /* Location to create group */
H5G_t *grp = NULL; /* New group created */
hid_t lcpl_id;
- hid_t ret_value;
+ void *ret_value;
FUNC_ENTER_NOAPI_NOINIT
/* Get the plist structure */
if(NULL == (plist = (H5P_genplist_t *)H5I_object(gcpl_id)))
- HGOTO_ERROR(H5E_ATOM, H5E_BADATOM, FAIL, "can't find object for ID")
+ HGOTO_ERROR(H5E_ATOM, H5E_BADATOM, NULL, "can't find object for ID")
/* get creation properties */
if(H5P_get(plist, H5VL_GRP_LCPL_ID, &lcpl_id) < 0)
- HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, FAIL, "can't get property value for lcpl id")
+ HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, NULL, "can't get property value for lcpl id")
- if(H5G_loc(loc_id, &loc) < 0)
- HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a location")
+ if (H5VL_native_get_loc(obj, loc_params.obj_type, &loc) < 0)
+ HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, NULL, "not a file or file object")
/* if name is NULL then this is from H5Gcreate_anon */
if (name == NULL) {
@@ -2079,17 +2417,15 @@ H5VL_native_group_create(hid_t loc_id, const char *name, hid_t gcpl_id, hid_t ga
/* Create the new group & get its ID */
if(NULL == (grp = H5G__create(loc.oloc->file, &gcrt_info, H5AC_dxpl_id)))
- HGOTO_ERROR(H5E_SYM, H5E_CANTINIT, FAIL, "unable to create group")
+ HGOTO_ERROR(H5E_SYM, H5E_CANTINIT, NULL, "unable to create group")
}
/* otherwise it's from H5Gcreate */
else {
/* Create the new group & get its ID */
if(NULL == (grp = H5G__create_named(&loc, name, lcpl_id, gcpl_id, gapl_id, H5AC_dxpl_id)))
- HGOTO_ERROR(H5E_SYM, H5E_CANTINIT, FAIL, "unable to create group")
+ HGOTO_ERROR(H5E_SYM, H5E_CANTINIT, NULL, "unable to create group")
}
-
- if((ret_value = H5I_register(H5I_GROUP, grp, TRUE)) < 0)
- HGOTO_ERROR(H5E_ATOM, H5E_CANTREGISTER, FAIL, "unable to register group")
+ ret_value = (void *)grp;
done:
if (name == NULL) {
@@ -2099,18 +2435,13 @@ done:
/* Get the new group's object location */
if(NULL == (oloc = H5G_oloc(grp)))
- HDONE_ERROR(H5E_SYM, H5E_CANTGET, FAIL, "unable to get object location of group")
+ HDONE_ERROR(H5E_SYM, H5E_CANTGET, NULL, "unable to get object location of group")
/* Decrement refcount on group's object header in memory */
if(H5O_dec_rc_by_loc(oloc, H5AC_dxpl_id) < 0)
- HDONE_ERROR(H5E_SYM, H5E_CANTDEC, FAIL, "unable to decrement refcount on newly created object")
+ HDONE_ERROR(H5E_SYM, H5E_CANTDEC, NULL, "unable to decrement refcount on newly created object")
} /* end if */
}
-
- if(ret_value < 0)
- if(grp && H5G_close(grp) < 0)
- HDONE_ERROR(H5E_SYM, H5E_CLOSEERROR, FAIL, "unable to release group")
-
FUNC_LEAVE_NOAPI(ret_value)
} /* end H5VL_native_group_create() */
@@ -2128,31 +2459,25 @@ done:
*
*-------------------------------------------------------------------------
*/
-static hid_t
-H5VL_native_group_open(hid_t loc_id, const char *name, hid_t gapl_id, hid_t UNUSED req)
+static void *
+H5VL_native_group_open(void *obj, H5VL_loc_params_t loc_params, const char *name, hid_t gapl_id, hid_t UNUSED req)
{
H5G_loc_t loc; /* Location to open group */
H5G_t *grp = NULL; /* New group opend */
- hid_t ret_value;
+ void *ret_value;
FUNC_ENTER_NOAPI_NOINIT
- if(H5G_loc(loc_id, &loc) < 0)
- HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a location")
+ if (H5VL_native_get_loc(obj, loc_params.obj_type, &loc) < 0)
+ HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, NULL, "not a file or file object")
/* Open the group */
if((grp = H5G__open_name(&loc, name, gapl_id, H5AC_dxpl_id)) == NULL)
- HGOTO_ERROR(H5E_SYM, H5E_CANTOPENOBJ, FAIL, "unable to open group")
+ HGOTO_ERROR(H5E_SYM, H5E_CANTOPENOBJ, NULL, "unable to open group")
- /* Register an ID for the group */
- if((ret_value = H5I_register(H5I_GROUP, grp, TRUE)) < 0)
- HGOTO_ERROR(H5E_ATOM, H5E_CANTREGISTER, FAIL, "unable to register group")
+ ret_value = (void *)grp;
done:
- if(ret_value < 0)
- if(grp && H5G_close(grp) < 0)
- HDONE_ERROR(H5E_SYM, H5E_CLOSEERROR, FAIL, "unable to release group")
-
FUNC_LEAVE_NOAPI(ret_value)
} /* end H5VL_native_group_open() */
@@ -2171,7 +2496,7 @@ done:
*-------------------------------------------------------------------------
*/
static herr_t
-H5VL_native_group_get(hid_t obj_id, H5VL_group_get_t get_type, hid_t UNUSED req, va_list arguments)
+H5VL_native_group_get(void *obj, H5VL_group_get_t get_type, hid_t UNUSED req, va_list arguments)
{
herr_t ret_value = SUCCEED; /* Return value */
@@ -2181,14 +2506,8 @@ H5VL_native_group_get(hid_t obj_id, H5VL_group_get_t get_type, hid_t UNUSED req,
/* H5Gget_create_plist */
case H5VL_GROUP_GET_GCPL:
{
- hid_t *new_gcpl_id;
- H5G_t *grp = NULL;
-
- /* Check args */
- if(NULL == (grp = (H5G_t *)H5I_object_verify(obj_id, H5I_GROUP)))
- HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a group")
-
- new_gcpl_id = va_arg (arguments, hid_t *);
+ hid_t *new_gcpl_id = va_arg (arguments, hid_t *);
+ H5G_t *grp = (H5G_t *)obj;
if((*new_gcpl_id = H5G_get_create_plist(grp)) < 0)
HGOTO_ERROR(H5E_ARGS, H5E_CANTGET, FAIL, "can't get creation property list for group")
@@ -2197,14 +2516,14 @@ H5VL_native_group_get(hid_t obj_id, H5VL_group_get_t get_type, hid_t UNUSED req,
/* H5Gget_info */
case H5VL_GROUP_GET_INFO:
{
- H5G_info_t *grp_info = va_arg (arguments, H5G_info_t *);
H5VL_loc_params_t loc_params = va_arg (arguments, H5VL_loc_params_t);
+ H5G_info_t *grp_info = va_arg (arguments, H5G_info_t *);
H5G_loc_t loc;
- if(H5G_loc(obj_id, &loc) < 0)
- HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a location")
+ if (H5VL_native_get_loc(obj, loc_params.obj_type, &loc) < 0)
+ HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a file or file object")
- if(loc_params.type == H5VL_OBJECT_BY_ID) { /* H5Gget_info */
+ if(loc_params.type == H5VL_OBJECT_BY_SELF) { /* H5Gget_info */
/* Retrieve the group's information */
if(H5G__obj_info(loc.oloc, grp_info, H5AC_ind_dxpl_id) < 0)
HGOTO_ERROR(H5E_SYM, H5E_CANTGET, FAIL, "can't retrieve group info")
@@ -2291,22 +2610,14 @@ done:
*-------------------------------------------------------------------------
*/
static herr_t
-H5VL_native_group_close(hid_t group_id, hid_t UNUSED req)
+H5VL_native_group_close(void *grp, hid_t UNUSED req)
{
herr_t ret_value = SUCCEED; /* Return value */
FUNC_ENTER_NOAPI_NOINIT
- /* Check args */
- if(NULL == H5I_object_verify(group_id,H5I_GROUP))
- HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a group")
-
- /*
- * Decrement the counter on the group atom. It will be freed if the count
- * reaches zero.
- */
- if(H5I_dec_app_ref(group_id) < 0)
- HGOTO_ERROR(H5E_SYM, H5E_CANTRELEASE, FAIL, "unable to close group")
+ if(H5G_close((H5G_t *)grp) < 0)
+ HGOTO_ERROR(H5E_SYM, H5E_CLOSEERROR, FAIL, "can't close group")
done:
FUNC_LEAVE_NOAPI(ret_value)
@@ -2326,10 +2637,9 @@ done:
*-------------------------------------------------------------------------
*/
static herr_t
-H5VL_native_link_create(H5VL_link_create_type_t create_type, hid_t loc_id, const char *link_name,
+H5VL_native_link_create(H5VL_link_create_type_t create_type, void *obj, H5VL_loc_params_t loc_params,
hid_t lcpl_id, hid_t lapl_id, hid_t UNUSED req)
{
-
H5P_genplist_t *plist; /* Property list pointer */
herr_t ret_value = SUCCEED; /* Return value */
@@ -2344,41 +2654,43 @@ H5VL_native_link_create(H5VL_link_create_type_t create_type, hid_t loc_id, const
{
H5G_loc_t cur_loc;
H5G_loc_t link_loc;
- hid_t cur_loc_id;
- char *cur_name = NULL;
+ void *cur_obj;
+ H5VL_loc_params_t cur_params;
- if(H5P_get(plist, H5VL_LINK_TARGET_ID, &cur_loc_id) < 0)
+ if(H5P_get(plist, H5VL_LINK_TARGET, &cur_obj) < 0)
HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, FAIL, "can't get property value for current location id")
- if(H5P_get(plist, H5VL_LINK_TARGET_NAME, &cur_name) < 0)
+ if(H5P_get(plist, H5VL_LINK_TARGET_LOC_PARAMS, &cur_params) < 0)
HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, FAIL, "can't get property value for current name")
- if(cur_loc_id != H5L_SAME_LOC && H5G_loc(cur_loc_id, &cur_loc) < 0)
- HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a location")
- if(loc_id != H5L_SAME_LOC && H5G_loc(loc_id, &link_loc) < 0)
- HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a location")
+ if (NULL != cur_obj && H5VL_native_get_loc(cur_obj, cur_params.obj_type, &cur_loc) < 0)
+ HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a file or file object")
+ if (NULL != obj && H5VL_native_get_loc(obj, loc_params.obj_type, &link_loc) < 0)
+ HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a file or file object")
/* H5Lcreate_hard */
- if (NULL != cur_name) {
+ if (H5VL_OBJECT_BY_NAME == cur_params.type) {
H5G_loc_t *cur_loc_p, *link_loc_p;
/* Set up current & new location pointers */
cur_loc_p = &cur_loc;
link_loc_p = &link_loc;
- if(cur_loc_id == H5L_SAME_LOC)
+ if(NULL == cur_obj)
cur_loc_p = link_loc_p;
- else if(loc_id == H5L_SAME_LOC)
+ else if(NULL == obj)
link_loc_p = cur_loc_p;
else if(cur_loc_p->oloc->file != link_loc_p->oloc->file)
HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "source and destination should be in the same file.")
/* Create the link */
- if((ret_value = H5L_create_hard(cur_loc_p, cur_name, link_loc_p, link_name,
+ if((ret_value = H5L_create_hard(cur_loc_p, cur_params.loc_data.loc_by_name.name,
+ link_loc_p, loc_params.loc_data.loc_by_name.name,
lcpl_id, lapl_id, H5AC_dxpl_id)) < 0)
HGOTO_ERROR(H5E_LINK, H5E_CANTINIT, FAIL, "unable to create link")
}
else { /* H5Olink */
/* Link to the object */
- if(H5L_link(&link_loc, link_name, &cur_loc, lcpl_id, lapl_id, H5AC_dxpl_id) < 0)
+ if(H5L_link(&link_loc, loc_params.loc_data.loc_by_name.name, &cur_loc, lcpl_id,
+ lapl_id, H5AC_dxpl_id) < 0)
HGOTO_ERROR(H5E_LINK, H5E_CANTINIT, FAIL, "unable to create link")
}
break;
@@ -2388,14 +2700,14 @@ H5VL_native_link_create(H5VL_link_create_type_t create_type, hid_t loc_id, const
char *target_name;
H5G_loc_t link_loc; /* Group location for new link */
- if(H5G_loc(loc_id, &link_loc) < 0)
- HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a location")
+ if (H5VL_native_get_loc(obj, loc_params.obj_type, &link_loc) < 0)
+ HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a file or file object")
if(H5P_get(plist, H5VL_LINK_TARGET_NAME, &target_name) < 0)
HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, FAIL, "can't get property value for targe name")
/* Create the link */
- if((ret_value = H5L_create_soft(target_name, &link_loc, link_name,
+ if((ret_value = H5L_create_soft(target_name, &link_loc, loc_params.loc_data.loc_by_name.name,
lcpl_id, lapl_id, H5AC_dxpl_id)) < 0)
HGOTO_ERROR(H5E_LINK, H5E_CANTINIT, FAIL, "unable to create link")
break;
@@ -2407,8 +2719,8 @@ H5VL_native_link_create(H5VL_link_create_type_t create_type, hid_t loc_id, const
void *udata;
size_t udata_size;
- if(H5G_loc(loc_id, &link_loc) < 0)
- HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a location")
+ if (H5VL_native_get_loc(obj, loc_params.obj_type, &link_loc) < 0)
+ HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a file or file object")
if(H5P_get(plist, H5VL_LINK_TYPE, &link_type) < 0)
HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, FAIL, "can't get property value for link type")
@@ -2418,7 +2730,8 @@ H5VL_native_link_create(H5VL_link_create_type_t create_type, hid_t loc_id, const
HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, FAIL, "can't get property value for udata size")
/* Create link */
- if(H5L_create_ud(&link_loc, link_name, udata, udata_size, link_type, lcpl_id, lapl_id, H5AC_dxpl_id) < 0)
+ if(H5L_create_ud(&link_loc, loc_params.loc_data.loc_by_name.name, udata, udata_size,
+ link_type, lcpl_id, lapl_id, H5AC_dxpl_id) < 0)
HGOTO_ERROR(H5E_LINK, H5E_CANTINIT, FAIL, "unable to create link")
break;
}
@@ -2448,8 +2761,9 @@ done:
*-------------------------------------------------------------------------
*/
static herr_t
-H5VL_native_link_move(hid_t src_loc_id, const char *src_name, hid_t dst_loc_id,
- const char *dst_name, hbool_t copy_flag, hid_t lcpl_id, hid_t lapl_id, hid_t UNUSED req)
+H5VL_native_link_move(void *src_obj, H5VL_loc_params_t loc_params1,
+ void *dst_obj, H5VL_loc_params_t loc_params2,
+ hbool_t copy_flag, hid_t lcpl_id, hid_t lapl_id, hid_t UNUSED req)
{
H5G_loc_t src_loc, *src_loc_p;
H5G_loc_t dst_loc, *dst_loc_p;
@@ -2457,22 +2771,23 @@ H5VL_native_link_move(hid_t src_loc_id, const char *src_name, hid_t dst_loc_id,
FUNC_ENTER_NOAPI_NOINIT
- if(src_loc_id != H5L_SAME_LOC && H5G_loc(src_loc_id, &src_loc) < 0)
- HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a location")
- if(dst_loc_id != H5L_SAME_LOC && H5G_loc(dst_loc_id, &dst_loc) < 0)
- HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a location")
+ if (NULL != src_obj && H5VL_native_get_loc(src_obj, loc_params1.obj_type, &src_loc) < 0)
+ HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a file or file object")
+ if (NULL != dst_obj && H5VL_native_get_loc(dst_obj, loc_params2.obj_type, &dst_loc) < 0)
+ HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a file or file object")
/* Set up src & dst location pointers */
src_loc_p = &src_loc;
dst_loc_p = &dst_loc;
- if(src_loc_id == H5L_SAME_LOC)
+ if(NULL == src_obj)
src_loc_p = dst_loc_p;
- else if(dst_loc_id == H5L_SAME_LOC)
+ else if(NULL == dst_obj)
dst_loc_p = src_loc_p;
/* Move/Copy the link */
- if(H5L_move(src_loc_p, src_name, dst_loc_p, dst_name, copy_flag, lcpl_id,
- lapl_id, H5AC_dxpl_id) < 0)
+ if(H5L_move(src_loc_p, loc_params1.loc_data.loc_by_name.name,
+ dst_loc_p, loc_params2.loc_data.loc_by_name.name,
+ copy_flag, lcpl_id, lapl_id, H5AC_dxpl_id) < 0)
HGOTO_ERROR(H5E_LINK, H5E_CANTMOVE, FAIL, "unable to move link")
done:
@@ -2493,14 +2808,18 @@ done:
*
*-------------------------------------------------------------------------
*/
-static herr_t H5VL_native_link_iterate(hid_t loc_id, const char *name, hbool_t recursive,
+static herr_t H5VL_native_link_iterate(void *obj, H5VL_loc_params_t loc_params, hbool_t recursive,
H5_index_t idx_type, H5_iter_order_t order, hsize_t *idx_p,
- H5L_iterate_t op, void *op_data, hid_t lapl_id)
+ H5L_iterate_t op, void *op_data, hid_t UNUSED req)
{
+ H5G_loc_t loc;
herr_t ret_value; /* Return value */
FUNC_ENTER_NOAPI_NOINIT
+ if (H5VL_native_get_loc(obj, loc_params.obj_type, &loc) < 0)
+ HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a file or file object")
+
if (!recursive) {
H5G_link_iterate_t lnk_op; /* Link operator */
hsize_t last_lnk; /* Index of last object looked at */
@@ -2515,9 +2834,20 @@ static herr_t H5VL_native_link_iterate(hid_t loc_id, const char *name, hbool_t r
lnk_op.op_func.op_new = op;
/* Iterate over the links */
- if((ret_value = H5G_iterate(loc_id, name, idx_type, order, idx, &last_lnk, &lnk_op,
- op_data, lapl_id, H5AC_ind_dxpl_id)) < 0)
- HGOTO_ERROR(H5E_SYM, H5E_BADITER, FAIL, "link iteration failed")
+ if(loc_params.type == H5VL_OBJECT_BY_SELF) {
+ if((ret_value = H5G_iterate(&loc, ".", idx_type, order, idx, &last_lnk, &lnk_op, op_data,
+ H5P_LINK_ACCESS_DEFAULT, H5AC_ind_dxpl_id)) < 0)
+ HGOTO_ERROR(H5E_SYM, H5E_BADITER, FAIL, "link iteration failed")
+ }
+ else if(loc_params.type == H5VL_OBJECT_BY_NAME) {
+ if((ret_value = H5G_iterate(&loc, loc_params.loc_data.loc_by_name.name,
+ idx_type, order, idx, &last_lnk, &lnk_op, op_data,
+ loc_params.loc_data.loc_by_name.plist_id, H5AC_ind_dxpl_id)) < 0)
+ HGOTO_ERROR(H5E_SYM, H5E_BADITER, FAIL, "link iteration failed")
+ }
+ else {
+ HGOTO_ERROR(H5E_VOL, H5E_UNSUPPORTED, FAIL, "unknown link iterate params")
+ }
/* Set the index we stopped at */
if(idx_p)
@@ -2525,9 +2855,20 @@ static herr_t H5VL_native_link_iterate(hid_t loc_id, const char *name, hbool_t r
}
else {
/* Call internal group visitation routine */
- if((ret_value = H5G_visit(loc_id, name, idx_type, order, op, op_data,
- lapl_id, H5AC_ind_dxpl_id)) < 0)
- HGOTO_ERROR(H5E_SYM, H5E_BADITER, FAIL, "link visitation failed")
+ if(loc_params.type == H5VL_OBJECT_BY_SELF) {
+ if((ret_value = H5G_visit(&loc, ".", idx_type, order, op, op_data,
+ H5P_LINK_ACCESS_DEFAULT, H5AC_ind_dxpl_id)) < 0)
+ HGOTO_ERROR(H5E_SYM, H5E_BADITER, FAIL, "link visitation failed")
+ }
+ else if(loc_params.type == H5VL_OBJECT_BY_NAME) {
+ if((ret_value = H5G_visit(&loc, loc_params.loc_data.loc_by_name.name,
+ idx_type, order, op, op_data,
+ loc_params.loc_data.loc_by_name.plist_id, H5AC_ind_dxpl_id)) < 0)
+ HGOTO_ERROR(H5E_SYM, H5E_BADITER, FAIL, "link visitation failed")
+ }
+ else {
+ HGOTO_ERROR(H5E_VOL, H5E_UNSUPPORTED, FAIL, "unknown link visit params")
+ }
}
done:
@@ -2549,82 +2890,112 @@ done:
*-------------------------------------------------------------------------
*/
static herr_t
-H5VL_native_link_get(hid_t loc_id, H5VL_link_get_t get_type, hid_t UNUSED req, va_list arguments)
+H5VL_native_link_get(void *obj, H5VL_loc_params_t loc_params, H5VL_link_get_t get_type,
+ hid_t UNUSED req, va_list arguments)
{
H5G_loc_t loc;
herr_t ret_value = SUCCEED; /* Return value */
FUNC_ENTER_NOAPI_NOINIT
- /* Check arguments */
- if(H5G_loc(loc_id, &loc))
- HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a location")
+ if (H5VL_native_get_loc(obj, loc_params.obj_type, &loc) < 0)
+ HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a file or file object")
switch (get_type) {
/* H5Lexists */
case H5VL_LINK_EXISTS:
{
- char *name = va_arg (arguments, char *);
htri_t *ret = va_arg (arguments, htri_t *);
- hid_t lapl_id = va_arg (arguments, hid_t);
/* Check for the existence of the link */
- if((*ret = H5L_exists(&loc, name, lapl_id, H5AC_ind_dxpl_id)) < 0)
+ if((*ret = H5L_exists(&loc, loc_params.loc_data.loc_by_name.name,
+ loc_params.loc_data.loc_by_name.plist_id, H5AC_ind_dxpl_id)) < 0)
HGOTO_ERROR(H5E_SYM, H5E_NOTFOUND, FAIL, "unable to get link info")
break;
}
/* H5Lget_info/H5Lget_info_by_idx */
case H5VL_LINK_GET_INFO:
{
- char *name = va_arg (arguments, char *);
H5L_info_t *linfo = va_arg (arguments, H5L_info_t *);
- void *udata = va_arg (arguments, void *);
- hid_t lapl_id = va_arg (arguments, hid_t);
- if(NULL == udata) { /* H5Lget_info */
- /* Get the link information */
- if(H5L_get_info(&loc, name, linfo, lapl_id, H5AC_ind_dxpl_id) < 0)
+ /* Get the link information */
+ if(loc_params.type == H5VL_OBJECT_BY_NAME) { /* H5Lget_info */
+ if(H5L_get_info(&loc, loc_params.loc_data.loc_by_name.name, linfo,
+ loc_params.loc_data.loc_by_name.plist_id, H5AC_ind_dxpl_id) < 0)
HGOTO_ERROR(H5E_SYM, H5E_NOTFOUND, FAIL, "unable to get link info")
}
- else { /* H5Lget_info_by_idx */
- /* Get the link information */
- if(H5L_get_info_by_idx(&loc, name, udata, lapl_id, H5AC_ind_dxpl_id) < 0)
+ else if(loc_params.type == H5VL_OBJECT_BY_IDX) { /* H5Lget_info_by_idx */
+ H5L_trav_gibi_t udata; /* User data for callback */
+
+ /* Set up user data for retrieving information */
+ udata.idx_type = loc_params.loc_data.loc_by_idx.idx_type;
+ udata.order = loc_params.loc_data.loc_by_idx.order;
+ udata.n = loc_params.loc_data.loc_by_idx.n;
+ udata.dxpl_id = H5AC_ind_dxpl_id;
+ udata.linfo = linfo;
+ if(H5L_get_info_by_idx(&loc, loc_params.loc_data.loc_by_idx.name, &udata,
+ loc_params.loc_data.loc_by_idx.plist_id, H5AC_ind_dxpl_id) < 0)
HGOTO_ERROR(H5E_SYM, H5E_NOTFOUND, FAIL, "unable to get link info")
}
+ else
+ HGOTO_ERROR(H5E_SYM, H5E_NOTFOUND, FAIL, "unable to get link info")
break;
}
/* H5Lget_name_by_idx */
case H5VL_LINK_GET_NAME:
{
char *name = va_arg (arguments, char *);
- void *udata = va_arg (arguments, void *);
- hid_t lapl_id = va_arg (arguments, hid_t);
+ size_t size = va_arg (arguments, size_t);
+ ssize_t *ret = va_arg (arguments, ssize_t *);
+ H5L_trav_gnbi_t udata; /* User data for callback */
+
+ /* Set up user data for callback */
+ udata.idx_type = loc_params.loc_data.loc_by_idx.idx_type;
+ udata.order = loc_params.loc_data.loc_by_idx.order;
+ udata.n = loc_params.loc_data.loc_by_idx.n;
+ udata.dxpl_id = H5AC_ind_dxpl_id;
+ udata.name = name;
+ udata.size = size;
+ udata.name_len = -1;
/* Get the link name */
- if(H5L_get_name_by_idx(&loc, name, udata, lapl_id, H5AC_ind_dxpl_id) < 0)
+ if(H5L_get_name_by_idx(&loc, loc_params.loc_data.loc_by_idx.name, &udata,
+ loc_params.loc_data.loc_by_idx.plist_id, H5AC_ind_dxpl_id) < 0)
HGOTO_ERROR(H5E_SYM, H5E_NOTFOUND, FAIL, "unable to get link info")
+
+ *ret = udata.name_len;
break;
}
/* H5Lget_val/H5Lget_val_by_idx */
case H5VL_LINK_GET_VAL:
{
- char *name = va_arg (arguments, char *);
void *buf = va_arg (arguments, void *);
size_t size = va_arg (arguments, size_t);
- void *udata = va_arg (arguments, void *);
- hid_t lapl_id = va_arg (arguments, hid_t);
-
- if(NULL == udata) { /* H5Lget_val */
- /* Get the link value */
- if(H5L_get_val(&loc, name, buf, size, lapl_id, H5AC_ind_dxpl_id) < 0)
- HGOTO_ERROR(H5E_SYM, H5E_NOTFOUND, FAIL,
- "unable to get link value for '%s'", name)
+
+ /* Get the link information */
+ if(loc_params.type == H5VL_OBJECT_BY_NAME) { /* H5Lget_val */
+ if(H5L_get_val(&loc, loc_params.loc_data.loc_by_name.name, buf, size,
+ loc_params.loc_data.loc_by_name.plist_id, H5AC_ind_dxpl_id) < 0)
+ HGOTO_ERROR(H5E_SYM, H5E_NOTFOUND, FAIL, "unable to get link value")
}
- else { /* H5Lget_val_by_idx */
- /* Get the link information */
- if(H5L_get_val_by_idx(&loc, name, udata, lapl_id, H5AC_ind_dxpl_id) < 0)
- HGOTO_ERROR(H5E_SYM, H5E_NOTFOUND, FAIL, "unable to get link val")
+ else if(loc_params.type == H5VL_OBJECT_BY_IDX) { /* H5Lget_val_by_idx */
+ H5L_trav_gvbi_t udata; /* User data for callback */
+
+ /* Set up user data for retrieving information */
+ udata.idx_type = loc_params.loc_data.loc_by_idx.idx_type;
+ udata.order = loc_params.loc_data.loc_by_idx.order;
+ udata.n = loc_params.loc_data.loc_by_idx.n;
+ udata.dxpl_id = H5AC_ind_dxpl_id;
+ udata.buf = buf;
+ udata.size = size;
+
+ if(H5L_get_val_by_idx(&loc, loc_params.loc_data.loc_by_idx.name, &udata,
+ loc_params.loc_data.loc_by_idx.plist_id, H5AC_ind_dxpl_id) < 0)
+ HGOTO_ERROR(H5E_SYM, H5E_NOTFOUND, FAIL, "unable to get link val")
}
+ else
+ HGOTO_ERROR(H5E_SYM, H5E_NOTFOUND, FAIL, "unable to get link val")
+
break;
}
default:
@@ -2654,26 +3025,37 @@ done:
*-------------------------------------------------------------------------
*/
static herr_t
-H5VL_native_link_remove(hid_t loc_id, const char *name, void *udata, hid_t lapl_id, hid_t UNUSED req)
+H5VL_native_link_remove(void *obj, H5VL_loc_params_t loc_params, hid_t UNUSED req)
{
H5G_loc_t loc; /* Object location */
herr_t ret_value = SUCCEED;
FUNC_ENTER_NOAPI_NOINIT
- if(H5G_loc(loc_id, &loc) < 0)
- HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a location")
+ if (H5VL_native_get_loc(obj, loc_params.obj_type, &loc) < 0)
+ HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a file or file object")
- if(NULL == udata) { /* H5Ldelete */
- /* Unlink */
- if(H5L_delete(&loc, name, lapl_id, H5AC_dxpl_id) < 0)
+ /* Unlink */
+ if(loc_params.type == H5VL_OBJECT_BY_NAME) { /* H5Ldelete */
+ if(H5L_delete(&loc, loc_params.loc_data.loc_by_name.name,
+ loc_params.loc_data.loc_by_name.plist_id, H5AC_dxpl_id) < 0)
HGOTO_ERROR(H5E_LINK, H5E_CANTDELETE, FAIL, "unable to delete link")
}
- else { /* H5Ldelete_by_idx */
- /* Unlink */
- if(H5L_delete_by_idx(&loc, name, udata, lapl_id, H5AC_dxpl_id) < 0)
+ else if(loc_params.type == H5VL_OBJECT_BY_IDX) { /* H5Ldelete_by_idx */
+ H5L_trav_rmbi_t udata; /* User data for callback */
+
+ /* Set up user data for unlink operation */
+ udata.idx_type = loc_params.loc_data.loc_by_idx.idx_type;
+ udata.order = loc_params.loc_data.loc_by_idx.order;
+ udata.n = loc_params.loc_data.loc_by_idx.n;
+ udata.dxpl_id = H5AC_dxpl_id;
+
+ if(H5L_delete_by_idx(&loc, loc_params.loc_data.loc_by_idx.name, &udata,
+ loc_params.loc_data.loc_by_idx.plist_id, H5AC_dxpl_id) < 0)
HGOTO_ERROR(H5E_LINK, H5E_CANTDELETE, FAIL, "unable to delete link")
}
+ else
+ HGOTO_ERROR(H5E_LINK, H5E_CANTDELETE, FAIL, "unable to delete link")
done:
FUNC_LEAVE_NOAPI(ret_value)
} /* end H5VL_native_link_remove() */
@@ -2692,28 +3074,30 @@ done:
*
*-------------------------------------------------------------------------
*/
-static hid_t
-H5VL_native_object_open(hid_t loc_id, H5VL_loc_params_t params, hid_t UNUSED req)
+static void *
+H5VL_native_object_open(void *obj, H5VL_loc_params_t loc_params, H5I_type_t *opened_type,
+ hid_t UNUSED req)
{
H5G_loc_t loc;
H5G_loc_t obj_loc; /* Location used to open group */
H5G_name_t obj_path; /* Opened object group hier. path */
H5O_loc_t obj_oloc; /* Opened object object location */
hbool_t loc_found = FALSE; /* Entry at 'name' found */
- hid_t ret_value = FAIL;
+ hid_t temp_id = FAIL;
+ void *ret_value = NULL;
FUNC_ENTER_NOAPI_NOINIT
- if(H5G_loc(loc_id, &loc) < 0)
- HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a location")
+ if (H5VL_native_get_loc(obj, loc_params.obj_type, &loc) < 0)
+ HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, NULL, "not a file or file object")
- switch (params.type) {
+ switch (loc_params.type) {
case H5VL_OBJECT_BY_NAME:
{
/* Open the object */
- if((ret_value = H5O_open_name(&loc, params.loc_data.loc_by_name.name,
- params.loc_data.loc_by_name.plist_id, TRUE)) < 0)
- HGOTO_ERROR(H5E_SYM, H5E_CANTOPENOBJ, FAIL, "unable to open object")
+ if((temp_id = H5O_open_name(&loc, loc_params.loc_data.loc_by_name.name,
+ loc_params.loc_data.loc_by_name.plist_id, TRUE)) < 0)
+ HGOTO_ERROR(H5E_SYM, H5E_CANTOPENOBJ, NULL, "unable to open object")
break;
}
case H5VL_OBJECT_BY_IDX:
@@ -2724,37 +3108,37 @@ H5VL_native_object_open(hid_t loc_id, H5VL_loc_params_t params, hid_t UNUSED req
H5G_loc_reset(&obj_loc);
/* Find the object's location, according to the order in the index */
- if(H5G_loc_find_by_idx(&loc, params.loc_data.loc_by_idx.name,
- params.loc_data.loc_by_idx.idx_type,
- params.loc_data.loc_by_idx.order, params.loc_data.loc_by_idx.n,
- &obj_loc/*out*/, params.loc_data.loc_by_idx.plist_id,
+ if(H5G_loc_find_by_idx(&loc, loc_params.loc_data.loc_by_idx.name,
+ loc_params.loc_data.loc_by_idx.idx_type,
+ loc_params.loc_data.loc_by_idx.order, loc_params.loc_data.loc_by_idx.n,
+ &obj_loc/*out*/, loc_params.loc_data.loc_by_idx.plist_id,
H5AC_dxpl_id) < 0)
- HGOTO_ERROR(H5E_SYM, H5E_NOTFOUND, FAIL, "group not found")
+ HGOTO_ERROR(H5E_SYM, H5E_NOTFOUND, NULL, "group not found")
loc_found = TRUE;
/* Open the object */
- if((ret_value = H5O_open_by_loc(&obj_loc, params.loc_data.loc_by_name.plist_id,
+ if((temp_id = H5O_open_by_loc(&obj_loc, loc_params.loc_data.loc_by_name.plist_id,
H5AC_dxpl_id, TRUE)) < 0)
- HGOTO_ERROR(H5E_SYM, H5E_CANTOPENOBJ, FAIL, "unable to open object")
+ HGOTO_ERROR(H5E_SYM, H5E_CANTOPENOBJ, NULL, "unable to open object")
break;
}
case H5VL_OBJECT_BY_ADDR:
{
- if(!H5F_addr_defined(params.loc_data.loc_by_addr.addr))
- HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "no address supplied")
+ if(!H5F_addr_defined(loc_params.loc_data.loc_by_addr.addr))
+ HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, NULL, "no address supplied")
/* Set up opened group location to fill in */
obj_loc.oloc = &obj_oloc;
obj_loc.path = &obj_path;
H5G_loc_reset(&obj_loc);
- obj_loc.oloc->addr = params.loc_data.loc_by_addr.addr;
+ obj_loc.oloc->addr = loc_params.loc_data.loc_by_addr.addr;
obj_loc.oloc->file = loc.oloc->file;
H5G_name_reset(obj_loc.path); /* objects opened through this routine don't have a path name */
/* Open the object */
- if((ret_value = H5O_open_by_loc(&obj_loc, H5P_LINK_ACCESS_DEFAULT,
+ if((temp_id = H5O_open_by_loc(&obj_loc, H5P_LINK_ACCESS_DEFAULT,
H5AC_dxpl_id, TRUE)) < 0)
- HGOTO_ERROR(H5E_SYM, H5E_CANTOPENOBJ, FAIL, "unable to open object")
+ HGOTO_ERROR(H5E_SYM, H5E_CANTOPENOBJ, NULL, "unable to open object")
break;
}
case H5VL_OBJECT_BY_REF:
@@ -2765,23 +3149,28 @@ H5VL_native_object_open(hid_t loc_id, H5VL_loc_params_t params, hid_t UNUSED req
file = loc.oloc->file;
/* Create reference */
- if((ret_value = H5R_dereference(file, params.loc_data.loc_by_ref.plist_id,
+ if((temp_id = H5R_dereference(file, loc_params.loc_data.loc_by_ref.plist_id,
H5AC_dxpl_id,
- params.loc_data.loc_by_ref.ref_type,
- params.loc_data.loc_by_ref._ref,
+ loc_params.loc_data.loc_by_ref.ref_type,
+ loc_params.loc_data.loc_by_ref._ref,
TRUE)) < 0)
- HGOTO_ERROR(H5E_REFERENCE, H5E_CANTINIT, FAIL, "unable to dereference object")
+ HGOTO_ERROR(H5E_REFERENCE, H5E_CANTINIT, NULL, "unable to dereference object")
break;
}
+ case H5VL_OBJECT_BY_SELF:
default:
- HGOTO_ERROR(H5E_VOL, H5E_UNSUPPORTED, FAIL, "unknown open parameters")
+ HGOTO_ERROR(H5E_VOL, H5E_UNSUPPORTED, NULL, "unknown open parameters")
}
+ *opened_type = H5I_get_type (temp_id);
+ if (NULL == (ret_value = H5I_remove(temp_id))) {
+ HDONE_ERROR(H5E_SYM, H5E_CANTOPENOBJ, NULL, "unable to open object")
+ }
done:
/* Release the object location if we failed after copying it */
- if(ret_value < 0 && loc_found)
+ if(temp_id < 0 && loc_found)
if(H5G_loc_free(&obj_loc) < 0)
- HDONE_ERROR(H5E_SYM, H5E_CANTRELEASE, FAIL, "can't free location")
+ HDONE_ERROR(H5E_SYM, H5E_CANTRELEASE, NULL, "can't free location")
FUNC_LEAVE_NOAPI(ret_value)
} /* end H5VL_native_object_open() */
@@ -2800,8 +3189,9 @@ done:
*-------------------------------------------------------------------------
*/
static herr_t
-H5VL_native_object_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, hid_t UNUSED req)
+H5VL_native_object_copy(void *src_obj, H5VL_loc_params_t loc_params1, const char *src_name,
+ void *dst_obj, H5VL_loc_params_t loc_params2, const char *dst_name,
+ hid_t ocpypl_id, hid_t lcpl_id, hid_t UNUSED req)
{
H5G_loc_t src_loc; /* Source object group location */
H5G_loc_t dst_loc; /* Destination group location */
@@ -2809,11 +3199,11 @@ H5VL_native_object_copy(hid_t src_loc_id, const char *src_name, hid_t dst_loc_id
FUNC_ENTER_NOAPI_NOINIT
- /* Check arguments */
- if(H5G_loc(src_loc_id, &src_loc) < 0)
- HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a location")
- if(H5G_loc(dst_loc_id, &dst_loc) < 0)
- HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a location")
+ /* get location for objects */
+ if (H5VL_native_get_loc(src_obj, loc_params1.obj_type, &src_loc) < 0)
+ HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a file or file object")
+ if (H5VL_native_get_loc(dst_obj, loc_params2.obj_type, &dst_loc) < 0)
+ HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a file or file object")
/* Open the object */
if((ret_value = H5O_copy(&src_loc, src_name, &dst_loc, dst_name, ocpypl_id, lcpl_id)) < 0)
@@ -2838,24 +3228,37 @@ done:
*
*-------------------------------------------------------------------------
*/
-static herr_t H5VL_native_object_visit(hid_t loc_id, const char *obj_name, H5_index_t idx_type,
- H5_iter_order_t order, H5O_iterate_t op, void *op_data,
- hid_t lapl_id)
+static herr_t H5VL_native_object_visit(void *obj, H5VL_loc_params_t loc_params, H5_index_t idx_type,
+ H5_iter_order_t order, H5O_iterate_t op, void *op_data, hid_t UNUSED req)
{
+ H5G_loc_t loc;
herr_t ret_value; /* Return value */
FUNC_ENTER_NOAPI_NOINIT
+ if (H5VL_native_get_loc(obj, loc_params.obj_type, &loc) < 0)
+ HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a file or file object")
+
/* Call internal object visitation routine */
- if((ret_value = H5O_visit(loc_id, obj_name, idx_type, order, op, op_data,
- lapl_id, H5AC_ind_dxpl_id)) < 0)
+ if(loc_params.type == H5VL_OBJECT_BY_SELF) { /* H5Ovisit */
+ if((ret_value = H5O_visit(&loc, ".", idx_type, order, op, op_data,
+ H5P_LINK_ACCESS_DEFAULT, H5AC_ind_dxpl_id)) < 0)
HGOTO_ERROR(H5E_SYM, H5E_BADITER, FAIL, "object visitation failed")
+ }
+ else if(loc_params.type == H5VL_OBJECT_BY_NAME) { /* H5Ovisit_by_name */
+ if((ret_value = H5O_visit(&loc, loc_params.loc_data.loc_by_name.name, idx_type, order,
+ op, op_data, loc_params.loc_data.loc_by_name.plist_id, H5AC_ind_dxpl_id)) < 0)
+ HGOTO_ERROR(H5E_SYM, H5E_BADITER, FAIL, "object visitation failed")
+ }
+ else {
+ HGOTO_ERROR(H5E_VOL, H5E_UNSUPPORTED, FAIL, "unknown object visit params")
+ }
done:
FUNC_LEAVE_NOAPI(ret_value)
} /* end H5VL_native_object_visit() */
-
+#if 0
/*-------------------------------------------------------------------------
* Function: H5VL_native_object_lookup
@@ -2893,7 +3296,7 @@ H5VL_native_object_lookup(hid_t loc_id, H5VL_loc_type_t lookup_type, void **loc_
H5G_loc_reset(obj_loc);
switch (lookup_type) {
- case H5VL_OBJECT_BY_ID:
+ case H5VL_OBJECT_BY_SELF:
obj_loc->oloc->addr = loc.oloc->addr;
obj_loc->oloc->file = loc.oloc->file;
obj_loc->oloc->holding_file = loc.oloc->holding_file;
@@ -3032,6 +3435,7 @@ H5VL_native_object_free_loc(void *location, hid_t UNUSED req)
done:
FUNC_LEAVE_NOAPI(ret_value)
} /* end H5VL_native_object_free_loc() */
+#endif
/*-------------------------------------------------------------------------
@@ -3048,71 +3452,25 @@ done:
*-------------------------------------------------------------------------
*/
static herr_t
-H5VL_native_object_misc(hid_t loc_id, H5VL_object_misc_t misc_type, hid_t UNUSED req, va_list arguments)
+H5VL_native_object_misc(void *obj, H5VL_loc_params_t loc_params, H5VL_object_misc_t misc_type,
+ hid_t UNUSED req, va_list arguments)
{
+ H5G_loc_t loc;
herr_t ret_value = SUCCEED; /* Return value */
- H5A_t *attr = NULL; /* Attribute opened */
FUNC_ENTER_NOAPI_NOINIT
- switch (misc_type) {
- /* H5Adelete_by_idx */
- case H5VL_ATTR_DELETE_BY_IDX:
- {
- H5VL_loc_params_t loc_params = va_arg (arguments, H5VL_loc_params_t);
- H5_index_t idx_type = va_arg (arguments, H5_index_t);
- H5_iter_order_t order = va_arg (arguments, H5_iter_order_t);
- hsize_t n = va_arg (arguments, hsize_t);
- H5G_loc_t loc; /* Object location */
+ if (H5VL_native_get_loc(obj, loc_params.obj_type, &loc) < 0)
+ HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a file or file object")
- HDassert(loc_params.type == H5VL_OBJECT_BY_NAME);
-
- if(H5G_loc(loc_id, &loc) < 0)
- HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a location")
-
- /* Call attribute delete routine */
- if(H5A_delete_by_idx(loc, loc_params.loc_data.loc_by_name.name, idx_type,
- order, n, loc_params.loc_data.loc_by_name.plist_id) < 0)
- HGOTO_ERROR(H5E_ATTR, H5E_CANTRENAME, FAIL, "can't delete attribute")
-
- break;
- }
- /* H5Aopen_by_idx */
- case H5VL_ATTR_OPEN_BY_IDX:
- {
- hid_t *ret_id = va_arg (arguments, hid_t *);
- char *obj_name = va_arg (arguments, char *);
- H5_index_t idx_type = va_arg (arguments, H5_index_t);
- H5_iter_order_t order = va_arg (arguments, H5_iter_order_t);
- hsize_t n = va_arg (arguments, hsize_t);
- hid_t aapl_id = va_arg (arguments, hid_t);
- hid_t lapl_id = va_arg (arguments, hid_t);
- H5G_loc_t loc; /* Object location */
-
- if(H5G_loc(loc_id, &loc) < 0)
- HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a location")
-
- /* Open the attribute in the object header */
- if(NULL == (attr = H5A_open_by_idx(&loc, obj_name, idx_type, order, n, lapl_id, H5AC_ind_dxpl_id)))
- HGOTO_ERROR(H5E_ATTR, H5E_CANTOPENOBJ, FAIL, "unable to open attribute")
-
- /* Register the attribute and get an ID for it */
- if((*ret_id = H5I_register(H5I_ATTR, attr, TRUE)) < 0)
- HGOTO_ERROR(H5E_ATOM, H5E_CANTREGISTER, FAIL, "unable to register attribute for ID")
- break;
- }
+ switch (misc_type) {
/* H5Arename/rename_by_name */
case H5VL_ATTR_RENAME:
{
- H5VL_loc_params_t loc_params = va_arg (arguments, H5VL_loc_params_t);
const char *old_name = va_arg (arguments, const char *);
const char *new_name = va_arg (arguments, const char *);
- H5G_loc_t loc;
-
- if(H5G_loc(loc_id, &loc) < 0)
- HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a location")
- if(loc_params.type == H5VL_OBJECT_BY_ID) { /* H5Arename */
+ if(loc_params.type == H5VL_OBJECT_BY_SELF) { /* H5Arename */
/* Call attribute rename routine */
if(H5O_attr_rename(loc.oloc, H5AC_dxpl_id, old_name, new_name) < 0)
HGOTO_ERROR(H5E_ATTR, H5E_CANTRENAME, FAIL, "can't rename attribute")
@@ -3132,11 +3490,12 @@ H5VL_native_object_misc(hid_t loc_id, H5VL_object_misc_t misc_type, hid_t UNUSED
case H5VL_OBJECT_CHANGE_REF_COUNT:
{
int update_ref = va_arg (arguments, int);
- H5O_loc_t *oloc;
+ H5O_loc_t *oloc = loc.oloc;
- /* Get the object's oloc so we can adjust its link count */
+ /* Get the object's oloc so we can adjust its link count
if((oloc = H5O_get_loc(loc_id)) == NULL)
HGOTO_ERROR(H5E_ATOM, H5E_BADVALUE, FAIL, "unable to get object location from ID")
+ */
if(H5O_link(oloc, update_ref, H5AC_dxpl_id) < 0)
HGOTO_ERROR(H5E_OHDR, H5E_LINKCOUNT, FAIL, "modifying object link count failed")
@@ -3146,17 +3505,22 @@ H5VL_native_object_misc(hid_t loc_id, H5VL_object_misc_t misc_type, hid_t UNUSED
/* H5Oset_comment */
case H5VL_OBJECT_SET_COMMENT:
{
- const char *name = va_arg (arguments, char *);
const char *comment = va_arg (arguments, char *);
- hid_t lapl_id = va_arg (arguments, hid_t);
- H5G_loc_t loc;
- if(H5G_loc(loc_id, &loc) < 0)
- HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a location")
-
- /* (Re)set the object's comment */
- if(H5G_loc_set_comment(&loc, name, comment, lapl_id, H5AC_ind_dxpl_id) < 0)
- HGOTO_ERROR(H5E_SYM, H5E_NOTFOUND, FAIL, "object not found")
+ if(loc_params.type == H5VL_OBJECT_BY_SELF) { /* H5Oset_comment */
+ /* (Re)set the object's comment */
+ if(H5G_loc_set_comment(&loc, ".", comment, H5P_LINK_ACCESS_DEFAULT, H5AC_ind_dxpl_id) < 0)
+ HGOTO_ERROR(H5E_SYM, H5E_NOTFOUND, FAIL, "object not found")
+ }
+ else if(loc_params.type == H5VL_OBJECT_BY_NAME) { /* H5Oset_comment_by_name */
+ /* (Re)set the object's comment */
+ if(H5G_loc_set_comment(&loc, loc_params.loc_data.loc_by_name.name, comment,
+ loc_params.loc_data.loc_by_name.plist_id, H5AC_ind_dxpl_id) < 0)
+ HGOTO_ERROR(H5E_SYM, H5E_NOTFOUND, FAIL, "object not found")
+ }
+ else {
+ HGOTO_ERROR(H5E_VOL, H5E_UNSUPPORTED, FAIL, "unknown set_coment parameters")
+ }
break;
}
case H5VL_REF_CREATE:
@@ -3165,11 +3529,8 @@ H5VL_native_object_misc(hid_t loc_id, H5VL_object_misc_t misc_type, hid_t UNUSED
const char *name = va_arg (arguments, char *);
H5R_type_t ref_type = va_arg (arguments, H5R_type_t);
hid_t space_id = va_arg (arguments, hid_t);
- H5G_loc_t loc; /* File location */
H5S_t *space = NULL; /* Pointer to dataspace containing region */
- if(H5G_loc(loc_id, &loc) < 0)
- HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a location")
if(space_id != (-1) && (NULL == (space = (H5S_t *)H5I_object_verify(space_id, H5I_DATASPACE))))
HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a dataspace")
@@ -3184,10 +3545,6 @@ H5VL_native_object_misc(hid_t loc_id, H5VL_object_misc_t misc_type, hid_t UNUSED
}
done:
- /* Cleanup on failure */
- if(H5VL_ATTR_OPEN_BY_IDX == misc_type && ret_value < 0)
- if(attr && H5A_close(attr) < 0)
- HDONE_ERROR(H5E_ATTR, H5E_CANTFREE, FAIL, "can't close attribute")
FUNC_LEAVE_NOAPI(ret_value)
} /* end H5VL_native_object_misc() */
@@ -3206,13 +3563,15 @@ done:
*-------------------------------------------------------------------------
*/
static herr_t
-H5VL_native_object_optional(hid_t loc_id, H5VL_object_optional_t optional_type, hid_t UNUSED req, va_list arguments)
+H5VL_native_object_optional(void UNUSED *obj, H5VL_loc_params_t UNUSED loc_params,
+ H5VL_object_optional_t optional_type, hid_t UNUSED req, va_list UNUSED arguments)
{
herr_t ret_value = SUCCEED; /* Return value */
FUNC_ENTER_NOAPI_NOINIT
switch (optional_type) {
+ case H5VL_OPTIONAL:
default:
HGOTO_ERROR(H5E_VOL, H5E_CANTGET, FAIL, "can't perform this operation on object");
}
@@ -3236,36 +3595,41 @@ done:
*-------------------------------------------------------------------------
*/
static herr_t
-H5VL_native_object_get(hid_t id, H5VL_object_get_t get_type, hid_t UNUSED req, va_list arguments)
+H5VL_native_object_get(void *obj, H5VL_loc_params_t loc_params, H5VL_object_get_t get_type,
+ hid_t UNUSED req, va_list arguments)
{
herr_t ret_value = SUCCEED; /* Return value */
H5G_loc_t loc; /* Location of group */
FUNC_ENTER_NOAPI_NOINIT
- if(H5G_loc(id, &loc) < 0)
- HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a location")
+ if (H5VL_native_get_loc(obj, loc_params.obj_type, &loc) < 0)
+ HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a file or file object")
switch (get_type) {
/* H5Oexists_by_name */
case H5VL_OBJECT_EXISTS:
{
- char *name = va_arg (arguments, char *);
- hid_t lapl_id = va_arg (arguments, hid_t);
htri_t *ret = va_arg (arguments, htri_t *);
- /* Check if the object exists */
- if((*ret = H5G_loc_exists(&loc, name, lapl_id, H5AC_dxpl_id)) < 0)
- HGOTO_ERROR(H5E_OHDR, H5E_CANTGET, FAIL, "unable to determine if '%s' exists", name)
+ if (loc_params.type == H5VL_OBJECT_BY_NAME) {
+ /* Check if the object exists */
+ if((*ret = H5G_loc_exists(&loc, loc_params.loc_data.loc_by_name.name,
+ loc_params.loc_data.loc_by_name.plist_id, H5AC_dxpl_id)) < 0)
+ HGOTO_ERROR(H5E_OHDR, H5E_CANTGET, FAIL, "unable to determine if '%s' exists",
+ loc_params.loc_data.loc_by_name.name)
+ }
+ else {
+ HGOTO_ERROR(H5E_VOL, H5E_UNSUPPORTED, FAIL, "unknown object exists parameters")
+ }
break;
}
/* H5Oget_info / H5Oget_info_by_name / H5Oget_info_by_idx */
case H5VL_OBJECT_GET_INFO:
{
H5O_info_t *obj_info = va_arg (arguments, H5O_info_t *);
- H5VL_loc_params_t loc_params = va_arg (arguments, H5VL_loc_params_t);
- if(loc_params.type == H5VL_OBJECT_BY_ID) { /* H5Oget_info */
+ if(loc_params.type == H5VL_OBJECT_BY_SELF) { /* H5Oget_info */
/* Retrieve the object's information */
if(H5G_loc_info(&loc, ".", TRUE, obj_info, H5P_LINK_ACCESS_DEFAULT,
H5AC_ind_dxpl_id) < 0)
@@ -3314,24 +3678,31 @@ H5VL_native_object_get(hid_t id, H5VL_object_get_t get_type, hid_t UNUSED req, v
/* H5Oget_comment / H5Oget_comment_by_name */
case H5VL_OBJECT_GET_COMMENT:
{
- ssize_t *ret = va_arg (arguments, ssize_t *);
char *comment = va_arg (arguments, char *);
size_t bufsize = va_arg (arguments, size_t);
- char *name = va_arg (arguments, char *);
- hid_t lapl_id = va_arg (arguments, hid_t);
+ ssize_t *ret = va_arg (arguments, ssize_t *);
/* Retrieve the object's comment */
- if((*ret = H5G_loc_get_comment(&loc, name, comment/*out*/, bufsize,
- lapl_id, H5AC_ind_dxpl_id)) < 0)
- HGOTO_ERROR(H5E_SYM, H5E_NOTFOUND, FAIL, "object not found")
-
+ if(loc_params.type == H5VL_OBJECT_BY_SELF) { /* H5Oget_comment */
+ if((*ret = H5G_loc_get_comment(&loc, ".", comment/*out*/, bufsize,
+ H5P_LINK_ACCESS_DEFAULT, H5AC_ind_dxpl_id)) < 0)
+ HGOTO_ERROR(H5E_SYM, H5E_NOTFOUND, FAIL, "object not found")
+ }
+ else if(loc_params.type == H5VL_OBJECT_BY_NAME) { /* H5Oget_comment_by_name */
+ if((*ret = H5G_loc_get_comment(&loc, loc_params.loc_data.loc_by_name.name, comment/*out*/, bufsize,
+ loc_params.loc_data.loc_by_name.plist_id, H5AC_ind_dxpl_id)) < 0)
+ HGOTO_ERROR(H5E_SYM, H5E_NOTFOUND, FAIL, "object not found")
+ }
+ else {
+ HGOTO_ERROR(H5E_VOL, H5E_UNSUPPORTED, FAIL, "unknown set_coment parameters")
+ }
break;
}
/* H5Rget_region */
case H5VL_REF_GET_REGION:
{
hid_t *ret = va_arg (arguments, hid_t *);
- H5R_type_t ref_type = va_arg (arguments, H5R_type_t);
+ H5R_type_t UNUSED ref_type = va_arg (arguments, H5R_type_t);
void *ref = va_arg (arguments, void *);
H5S_t *space = NULL; /* Dataspace object */
@@ -3365,13 +3736,13 @@ H5VL_native_object_get(hid_t id, H5VL_object_get_t get_type, hid_t UNUSED req, v
size_t size = va_arg (arguments, size_t);
H5R_type_t ref_type = va_arg (arguments, H5R_type_t);
void *ref = va_arg (arguments, void *);
- H5F_t *file; /* File object */
+ //H5F_t *file; /* File object */
- /* Get the file pointer from the entry */
+ /* Get the file pointer from the entry
file = loc.oloc->file;
-
+ */
/* Get name */
- if((*ret = H5R_get_name(file, H5P_DEFAULT, H5AC_dxpl_id, id, ref_type, ref, name, size)) < 0)
+ if((*ret = H5R_get_name(&loc, H5P_DEFAULT, H5AC_dxpl_id, ref_type, ref, name, size)) < 0)
HGOTO_ERROR(H5E_REFERENCE, H5E_CANTINIT, FAIL, "unable to determine object path")
break;
}
@@ -3397,23 +3768,19 @@ done:
*-------------------------------------------------------------------------
*/
static herr_t
-H5VL_native_object_close(hid_t object_id, hid_t UNUSED req)
+H5VL_native_object_close(void UNUSED *obj, H5VL_loc_params_t loc_params, hid_t UNUSED req)
{
herr_t ret_value = SUCCEED; /* Return value */
FUNC_ENTER_NOAPI_NOINIT
/* Get the type of the object and close it in the correct way */
- switch(H5I_get_type(object_id)) {
+ switch(loc_params.obj_type) {
case H5I_GROUP:
case H5I_DATATYPE:
case H5I_DATASET:
- if(H5I_object(object_id) == NULL)
- HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "not a valid object")
- if(H5I_dec_app_ref(object_id) < 0)
- HGOTO_ERROR(H5E_OHDR, H5E_CANTRELEASE, FAIL, "unable to close object")
break;
-
+ case H5I_FILE_PRIVATE:
case H5I_UNINIT:
case H5I_BADID:
case H5I_FILE:
diff --git a/src/H5VLnative.h b/src/H5VLnative.h
index 75ff687..c65e837 100644
--- a/src/H5VLnative.h
+++ b/src/H5VLnative.h
@@ -30,6 +30,7 @@ extern "C" {
H5_DLL H5VL_class_t *H5VL_native_init(void);
H5_DLL herr_t H5Pset_fapl_native(hid_t fapl_id);
+H5_DLL herr_t H5VL_native_register_aux(hid_t obj_id);
#ifdef __cplusplus
}
diff --git a/src/H5VLprivate.h b/src/H5VLprivate.h
index 814901c..fc9193e 100644
--- a/src/H5VLprivate.h
+++ b/src/H5VLprivate.h
@@ -46,65 +46,74 @@ struct H5F_t;
H5_DLL int H5VL_term_interface(void);
H5_DLL H5VL_class_t *H5VL_get_class(hid_t id);
H5_DLL hid_t H5VL_register(const void *cls, size_t size, hbool_t app_ref);
+H5_DLL hid_t H5VL_object_register(void *obj, H5I_type_t obj_type, H5VL_t *vol_plugin);
H5_DLL ssize_t H5VL_get_plugin_name(hid_t id, char *name/*out*/, size_t size);
H5_DLL herr_t H5VL_close(H5VL_class_t *vol_plugin);
-H5_DLL hid_t H5VL_attr_create(hid_t loc_id, const char *attr_name, hid_t acpl_id, hid_t aapl_id, hid_t req);
-H5_DLL hid_t H5VL_attr_open(hid_t loc_id, H5VL_loc_params_t loc_params, const char *name, hid_t aapl_id, hid_t req);
-H5_DLL herr_t H5VL_attr_read(hid_t attr_id, hid_t dtype_id, void *buf, hid_t req);
-H5_DLL herr_t H5VL_attr_write(hid_t attr_id, hid_t dtype_id, const void *buf, hid_t req);
-H5_DLL herr_t H5VL_attr_get(hid_t id, H5VL_attr_get_t get_type, hid_t req, ...);
-H5_DLL herr_t H5VL_attr_remove(hid_t loc_id, H5VL_loc_params_t loc_params, const char *attr_name, hid_t req);
-H5_DLL herr_t H5VL_attr_close(hid_t attr_id, hid_t req);
-
-H5_DLL hid_t H5VL_dataset_create(hid_t uid, const char *name, hid_t dcpl_id, hid_t dapl_id, hid_t req);
-H5_DLL hid_t H5VL_dataset_open(hid_t uid, const char *name, hid_t dapl_id, hid_t req);
-H5_DLL herr_t H5VL_dataset_close(hid_t uid, hid_t req);
-H5_DLL herr_t H5VL_dataset_read(hid_t dset_id, hid_t mem_type_id, hid_t mem_space_id, hid_t file_space_id, hid_t plist_id, void *buf, hid_t req);
-H5_DLL herr_t H5VL_dataset_write(hid_t dset_id, hid_t mem_type_id, hid_t mem_space_id, hid_t file_space_id, hid_t plist_id, const void *buf, hid_t req);
-H5_DLL herr_t H5VL_dataset_set_extent(hid_t uid, const hsize_t size[], hid_t req);
-H5_DLL herr_t H5VL_dataset_get(hid_t uid, H5VL_dataset_get_t get_type, hid_t req, ...);
-
-H5_DLL herr_t H5VL_datatype_commit(hid_t loc_id, const char *name, hid_t type_id, hid_t lcpl_id, hid_t tcpl_id, hid_t tapl_id, hid_t req);
-H5_DLL hid_t H5VL_datatype_open(hid_t loc_id, const char *name, hid_t tapl_id, hid_t req);
-H5_DLL herr_t H5VL_datatype_close(hid_t type_id, hid_t req);
-
-H5_DLL hid_t H5VL_file_open(const char *name, unsigned flags, hid_t fapl_id, hid_t req);
-H5_DLL hid_t H5VL_file_create(const char *name, unsigned flags, hid_t fcpl_id, hid_t fapl_id, hid_t req);
-H5_DLL herr_t H5VL_file_close(hid_t file_id, hid_t req);
-H5_DLL herr_t H5VL_file_flush(hid_t file_id, H5F_scope_t scope, hid_t req);
-H5_DLL herr_t H5VL_file_misc(hid_t loc_id, H5VL_file_misc_t misc_type, hid_t req, ...);
-H5_DLL herr_t H5VL_file_optional(hid_t loc_id, H5VL_file_optional_t optional_type, hid_t req, ...);
-H5_DLL herr_t H5VL_file_get(hid_t uid, H5VL_file_get_t get_type, hid_t req, ...);
-
-H5_DLL hid_t H5VL_group_create(hid_t uid, const char *name, hid_t gcpl_id, hid_t gapl_id, hid_t req);
-H5_DLL hid_t H5VL_group_open(hid_t uid, const char *name, hid_t gapl_id, hid_t req);
-H5_DLL herr_t H5VL_group_close(hid_t uid, hid_t req);
-H5_DLL herr_t H5VL_group_get(hid_t uid, H5VL_group_get_t get_type, hid_t req, ...);
-
-H5_DLL herr_t H5VL_link_create(H5VL_link_create_type_t create_type, hid_t loc_id,
- const char *link_name, hid_t lcpl_id, hid_t lapl_id, hid_t req);
-H5_DLL herr_t H5VL_link_move(hid_t src_loc_id, const char *src_name, hid_t dst_loc_id,
- const char *dst_name, hbool_t copy_flag, hid_t lcpl_id, hid_t lapl_id, hid_t req);
-H5_DLL herr_t H5VL_link_iterate(hid_t loc_id, const char *name, hbool_t recursive,
- H5_index_t idx_type, H5_iter_order_t order, hsize_t *idx,
- H5L_iterate_t op, void *op_data, hid_t lapl_id);
-H5_DLL herr_t H5VL_link_get(hid_t loc_id, H5VL_link_get_t get_type, hid_t req, ...);
-H5_DLL herr_t H5VL_link_remove(hid_t loc_id, const char *name, void *udata, hid_t lapl_id, hid_t req);
-
-H5_DLL hid_t H5VL_object_open(hid_t loc_id, H5VL_loc_params_t params, hid_t req);
-H5_DLL herr_t H5VL_object_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, hid_t req);
-H5_DLL herr_t H5VL_object_visit(hid_t loc_id, const char *obj_name, H5_index_t idx_type,
- H5_iter_order_t order, H5O_iterate_t op, void *op_data, hid_t lapl_id);
-H5_DLL herr_t H5VL_object_get(hid_t uid, H5VL_object_get_t get_type, hid_t req, ...);
-H5_DLL herr_t H5VL_object_misc(hid_t id, H5VL_object_misc_t misc_type, hid_t req, ...);
-H5_DLL herr_t H5VL_object_optional(hid_t id, H5VL_object_misc_t optional_type, hid_t req, ...);
-H5_DLL herr_t H5VL_object_lookup(hid_t uid, H5VL_loc_type_t lookup_type, void **location, hid_t req, ...);
-H5_DLL herr_t H5VL_object_free_loc(hid_t loc_id, void *location, hid_t req);
-H5_DLL herr_t H5VL_object_close(hid_t uid, hid_t req);
+H5_DLL void *H5VL_attr_create(void *obj, H5VL_loc_params_t loc_params, H5VL_t *vol_plugin, const char *attr_name, hid_t acpl_id, hid_t aapl_id, hid_t req);
+H5_DLL void *H5VL_attr_open(void *obj, H5VL_loc_params_t loc_params, H5VL_t *vol_plugin, const char *name, hid_t aapl_id, hid_t req);
+H5_DLL herr_t H5VL_attr_read(void *attr, H5VL_t *vol_plugin, hid_t dtype_id, void *buf, hid_t req);
+H5_DLL herr_t H5VL_attr_write(void *attr, H5VL_t *vol_plugin, hid_t dtype_id, const void *buf, hid_t req);
+H5_DLL herr_t H5VL_attr_get(void *attr, H5VL_t *vol_plugin, H5VL_attr_get_t get_type, hid_t req, ...);
+H5_DLL herr_t H5VL_attr_remove(void *obj, H5VL_loc_params_t loc_params, H5VL_t *vol_plugin, const char *attr_name, hid_t req);
+H5_DLL herr_t H5VL_attr_close(void *attr, H5VL_t *vol_plugin, hid_t req);
+
+H5_DLL void *H5VL_dataset_create(void *obj, H5VL_loc_params_t loc_params, H5VL_t *vol_plugin, const char *name, hid_t dcpl_id, hid_t dapl_id, hid_t req);
+H5_DLL void *H5VL_dataset_open(void *obj, H5VL_loc_params_t loc_params, H5VL_t *vol_plugin, const char *name, hid_t dapl_id, hid_t req);
+H5_DLL herr_t H5VL_dataset_read(void *dset, H5VL_t *vol_plugin, hid_t mem_type_id, hid_t mem_space_id, hid_t file_space_id, hid_t plist_id, void *buf, hid_t req);
+H5_DLL herr_t H5VL_dataset_write(void *dset, H5VL_t *vol_plugin, hid_t mem_type_id, hid_t mem_space_id, hid_t file_space_id, hid_t plist_id, const void *buf, hid_t req);
+H5_DLL herr_t H5VL_dataset_set_extent(void *dset, H5VL_t *vol_plugin, const hsize_t size[], hid_t req);
+H5_DLL herr_t H5VL_dataset_get(void *dset, H5VL_t *vol_plugin, H5VL_dataset_get_t get_type, hid_t req, ...);
+H5_DLL herr_t H5VL_dataset_close(void *dset, H5VL_t *vol_plugin, hid_t req);
+
+H5_DLL void *H5VL_datatype_commit(void *obj, H5VL_loc_params_t loc_params, H5VL_t *vol_plugin, const char *name, hid_t type_id, hid_t lcpl_id, hid_t tcpl_id, hid_t tapl_id, hid_t req);
+H5_DLL void *H5VL_datatype_open(void *obj, H5VL_loc_params_t loc_params, H5VL_t *vol_plugin, const char *name, unsigned char *buf, size_t nalloc, hid_t tapl_id, hid_t req);
+H5_DLL ssize_t H5VL_datatype_get_size(void *obj, H5VL_loc_params_t loc_params, H5VL_t *vol_plugin,
+ const char *name, hid_t tapl_id, hid_t req);
+H5_DLL herr_t H5VL_datatype_close(void *dt, H5VL_t *vol_plugin, hid_t req);
+
+H5_DLL void *H5VL_file_create(H5VL_t *vol_plugin, const char *name, unsigned flags, hid_t fcpl_id, hid_t fapl_id, hid_t req);
+H5_DLL void *H5VL_file_open(H5VL_t *vol_plugin, const char *name, unsigned flags, hid_t fapl_id, hid_t req);
+H5_DLL herr_t H5VL_file_flush(void *obj, H5VL_loc_params_t loc_params, H5VL_t *vol_plugin, H5F_scope_t scope, hid_t req);
+H5_DLL herr_t H5VL_file_misc(void *file, H5VL_t *vol_plugin, H5VL_file_misc_t misc_type, hid_t req, ...);
+H5_DLL herr_t H5VL_file_optional(void *file, H5VL_t *vol_plugin, H5VL_file_optional_t optional_type, hid_t req, ...);
+H5_DLL herr_t H5VL_file_get(void *file, H5VL_t *vol_plugin, H5VL_file_get_t get_type, hid_t req, ...);
+H5_DLL herr_t H5VL_file_close(void *file, H5VL_t *vol_plugin, hid_t req);
+
+H5_DLL void *H5VL_group_create(void *obj, H5VL_loc_params_t loc_params, H5VL_t *vol_plugin, const char *name, hid_t gcpl_id, hid_t gapl_id, hid_t req);
+H5_DLL void *H5VL_group_open(void *obj, H5VL_loc_params_t loc_params, H5VL_t *vol_plugin, const char *name, hid_t gapl_id, hid_t req);
+H5_DLL herr_t H5VL_group_close(void *grp, H5VL_t *vol_plugin, hid_t req);
+H5_DLL herr_t H5VL_group_get(void *obj, H5VL_t *vol_plugin, H5VL_group_get_t get_type, hid_t req, ...);
+
+H5_DLL herr_t H5VL_link_create(H5VL_link_create_type_t create_type, void *obj, H5VL_loc_params_t loc_params, H5VL_t *vol_plugin, hid_t lcpl_id, hid_t lapl_id, hid_t req);
+H5_DLL herr_t H5VL_link_move(void *src_obj, H5VL_loc_params_t loc_params1,
+ void *dst_obj, H5VL_loc_params_t loc_params2, H5VL_t *vol_plugin,
+ hbool_t copy_flag, hid_t lcpl_id, hid_t lapl_id, hid_t req);
+H5_DLL herr_t H5VL_link_iterate(void *obj, H5VL_loc_params_t loc_params, H5VL_t *vol_plugin,
+ hbool_t recursive, H5_index_t idx_type, H5_iter_order_t order,
+ hsize_t *idx, H5L_iterate_t op, void *op_data, hid_t req);
+H5_DLL herr_t H5VL_link_get(void *obj, H5VL_loc_params_t loc_params, H5VL_t *vol_plugin, H5VL_link_get_t get_type, hid_t req, ...);
+H5_DLL herr_t H5VL_link_remove(void *obj, H5VL_loc_params_t loc_params, H5VL_t *vol_plugin, hid_t req);
+
+H5_DLL void *H5VL_object_open(void *obj, H5VL_loc_params_t loc_params, H5VL_t *vol_plugin, H5I_type_t *opened_type, hid_t req);
+H5_DLL herr_t H5VL_object_copy(void *src_obj, H5VL_loc_params_t loc_params1, H5VL_t *vol_plugin1, const char *src_name,
+ void *dst_obj, H5VL_loc_params_t loc_params2, H5VL_t *vol_plugin2, const char *dst_name,
+ hid_t ocpypl_id, hid_t lcpl_id, hid_t req);
+H5_DLL herr_t H5VL_object_visit(void *obj, H5VL_loc_params_t loc_params, H5VL_t *vol_plugin, H5_index_t idx_type, H5_iter_order_t order, H5O_iterate_t op, void *op_data, hid_t req);
+H5_DLL herr_t H5VL_object_get(void *obj, H5VL_loc_params_t loc_params, H5VL_t *vol_plugin, H5VL_object_get_t get_type, hid_t req, ...);
+H5_DLL herr_t H5VL_object_misc(void *obj, H5VL_loc_params_t loc_params, H5VL_t *vol_plugin, H5VL_object_misc_t misc_type, hid_t req, ...);
+H5_DLL herr_t H5VL_object_optional(void *obj, H5VL_loc_params_t loc_params, H5VL_t *vol_plugin, H5VL_object_misc_t optional_type, hid_t req, ...);
+//H5_DLL herr_t H5VL_object_lookup(hid_t uid, H5VL_loc_type_t lookup_type, void **location, hid_t req, ...);
+//H5_DLL herr_t H5VL_object_free_loc(hid_t loc_id, void *location, hid_t req);
+H5_DLL herr_t H5VL_object_close(void *obj, H5VL_loc_params_t loc_params, H5VL_t *vol_plugin, hid_t req);
H5_DLL herr_t H5VL_fapl_open(struct H5P_genplist_t *plist, H5VL_class_t *vol_cls, const void *vol_info);
H5_DLL herr_t H5VL_fapl_close(H5VL_class_t *vol_cls, const void *vol_info);
+H5_DLL herr_t H5F_close_file(void *file, H5VL_t *vol_plugin);
+H5_DLL herr_t H5A_close_attr(void *attr, H5VL_t *vol_plugin);
+H5_DLL herr_t H5D_close_dataset(void *dset, H5VL_t *vol_plugin);
+H5_DLL herr_t H5G_close_group(void *grp, H5VL_t *vol_plugin);
+H5_DLL herr_t H5T_close_datatype(void *dt, H5VL_t *vol_plugin);
+
#endif /* _H5VLprivate_H */
diff --git a/src/H5VLpublic.h b/src/H5VLpublic.h
index e0b25b4..cb9ceac 100644
--- a/src/H5VLpublic.h
+++ b/src/H5VLpublic.h
@@ -39,11 +39,12 @@
#define H5VL_ATTR_LOC_PARAMS "attr_location"
/* Link creation property names */
-#define H5VL_LINK_TARGET_ID "target location id"
-#define H5VL_LINK_TARGET_NAME "target name"
-#define H5VL_LINK_TYPE "link type"
-#define H5VL_LINK_UDATA "udata"
-#define H5VL_LINK_UDATA_SIZE "udata size"
+#define H5VL_LINK_TARGET "target_location_object"
+#define H5VL_LINK_TARGET_LOC_PARAMS "target_params"
+#define H5VL_LINK_TARGET_NAME "target_name"
+#define H5VL_LINK_TYPE "link type"
+#define H5VL_LINK_UDATA "udata"
+#define H5VL_LINK_UDATA_SIZE "udata size"
/* Group creation property names */
#define H5VL_GRP_LCPL_ID "group_lcpl_id"
@@ -78,6 +79,7 @@ typedef enum H5VL_file_get_t {
H5VL_FILE_GET_NAME = 3, /*file name */
H5VL_FILE_GET_OBJ_COUNT = 4, /*object count in file */
H5VL_FILE_GET_OBJ_IDS = 5, /*object ids in file */
+ H5VL_OBJECT_GET_FILE = 6
} H5VL_file_get_t;
/* types for all file misc operations */
@@ -127,12 +129,10 @@ typedef enum H5VL_link_get_t {
/* types for all object general operations */
typedef enum H5VL_object_misc_t {
- H5VL_ATTR_DELETE_BY_IDX = 0, /* H5Adelete_by_idx */
- H5VL_ATTR_OPEN_BY_IDX = 1, /* H5Aopen_by_idx */
- H5VL_ATTR_RENAME = 2, /* H5Arename */
- H5VL_OBJECT_CHANGE_REF_COUNT = 3, /* H5Oincr/decr_refcount */
- H5VL_OBJECT_SET_COMMENT = 4, /* H5Oset_comment(_by_name) */
- H5VL_REF_CREATE = 5 /* H5Rcreate */
+ H5VL_ATTR_RENAME = 0, /* H5Arename */
+ H5VL_OBJECT_CHANGE_REF_COUNT = 1, /* H5Oincr/decr_refcount */
+ H5VL_OBJECT_SET_COMMENT = 2, /* H5Oset_comment(_by_name) */
+ H5VL_REF_CREATE = 3 /* H5Rcreate */
} H5VL_object_misc_t;
/* types for all object general operations */
@@ -152,17 +152,13 @@ typedef enum H5VL_object_get_t {
/* types for different ways that objects are located in an HDF5 container */
typedef enum H5VL_loc_type_t {
- H5VL_OBJECT_BY_ID = 0,
+ H5VL_OBJECT_BY_SELF = 0,
H5VL_OBJECT_BY_NAME = 1,
H5VL_OBJECT_BY_IDX = 2,
H5VL_OBJECT_BY_ADDR = 3,
H5VL_OBJECT_BY_REF = 4
} H5VL_loc_type_t;
-struct H5VL_loc_by_id {
- hid_t id;
-};
-
struct H5VL_loc_by_name {
const char *name;
hid_t plist_id;
@@ -189,9 +185,9 @@ struct H5VL_loc_by_ref {
/* Structure to hold parameters for object locations.
either: BY_ID, BY_NAME, BY_IDX, BY_ADDR, BY_REF */
typedef struct H5VL_loc_params_t {
+ H5I_type_t obj_type;
H5VL_loc_type_t type;
union{
- struct H5VL_loc_by_id loc_by_id;
struct H5VL_loc_by_name loc_by_name;
struct H5VL_loc_by_idx loc_by_idx;
struct H5VL_loc_by_addr loc_by_addr;
@@ -206,83 +202,87 @@ typedef struct H5VL_t H5VL_t;
/* H5A routines */
typedef struct H5VL_attr_class_t {
- hid_t (*create)(hid_t loc_id, const char *attr_name, hid_t acpl_id,
- hid_t aapl_id, hid_t req);
- hid_t (*open) (hid_t loc_id, H5VL_loc_params_t loc_params, const char *attr_name, hid_t aapl_id, hid_t req);
- herr_t (*read) (hid_t attr_id, hid_t mem_type_id, void *buf, hid_t req);
- herr_t (*write) (hid_t attr_id, hid_t mem_type_id, const void *buf, hid_t req);
- herr_t (*get) (hid_t loc_id, H5VL_attr_get_t get_type, hid_t req, va_list arguments);
- herr_t (*remove)(hid_t loc_id, H5VL_loc_params_t loc_params, const char *attr_name, hid_t req);
- herr_t (*close) (hid_t attr_id, hid_t req);
+ void *(*create)(void *obj, H5VL_loc_params_t loc_params, const char *attr_name, hid_t acpl_id, hid_t aapl_id, hid_t req);
+ void *(*open) (void *obj, H5VL_loc_params_t loc_params, const char *attr_name, hid_t aapl_id, hid_t req);
+ herr_t (*read) (void *attr, hid_t mem_type_id, void *buf, hid_t req);
+ herr_t (*write) (void *attr, hid_t mem_type_id, const void *buf, hid_t req);
+ herr_t (*get) (void *attr, H5VL_attr_get_t get_type, hid_t req, va_list arguments);
+ herr_t (*remove)(void *obj, H5VL_loc_params_t loc_params, const char *attr_name, hid_t req);
+ herr_t (*close) (void *attr, hid_t req);
} H5VL_attr_class_t;
/* H5T routines*/
typedef struct H5VL_datatype_class_t {
- herr_t (*commit)(hid_t loc_id, const char *name, hid_t type_id,
+ void *(*commit)(void *obj, H5VL_loc_params_t loc_params, const char *name, hid_t type_id,
hid_t lcpl_id, hid_t tcpl_id, hid_t tapl_id, hid_t req);
- hid_t (*open) (hid_t loc_id, const char * name, hid_t tapl_id, hid_t req);
- herr_t (*close) (hid_t type_id, hid_t req);
+ void *(*open) (void *obj, H5VL_loc_params_t loc_params, const char * name,
+ unsigned char *buf, size_t nalloc, hid_t tapl_id, hid_t req);
+ ssize_t (*get_size) (void *obj, H5VL_loc_params_t loc_params, const char *name,
+ hid_t tapl_id, hid_t req);
+ herr_t (*close) (void *dt, hid_t req);
}H5VL_datatype_class_t;
/* H5D routines */
typedef struct H5VL_dataset_class_t {
- hid_t (*create)(hid_t loc_id, const char *name, hid_t dcpl_id, hid_t dapl_id, hid_t req);
- hid_t (*open) (hid_t loc_id, const char *name, hid_t dapl_id, hid_t req);
- herr_t (*read) (hid_t dataset_id, hid_t mem_type_id, hid_t mem_space_id, hid_t file_space_id,
+ void *(*create)(void *obj, H5VL_loc_params_t loc_params, const char *name, hid_t dcpl_id, hid_t dapl_id, hid_t req);
+ void *(*open) (void *obj, H5VL_loc_params_t loc_params, const char *name, hid_t dapl_id, hid_t req);
+ herr_t (*read) (void *dset, hid_t mem_type_id, hid_t mem_space_id, hid_t file_space_id,
hid_t xfer_plist_id, void * buf, hid_t req);
- herr_t (*write) (hid_t dataset_id, hid_t mem_type_id, hid_t mem_space_id, hid_t file_space_id,
+ herr_t (*write) (void *dset, hid_t mem_type_id, hid_t mem_space_id, hid_t file_space_id,
hid_t xfer_plist_id, const void * buf, hid_t req);
- herr_t (*set_extent) (hid_t loc_id, const hsize_t size[], hid_t req);
- herr_t (*get) (hid_t file_id, H5VL_dataset_get_t get_type, hid_t req, va_list arguments);
- herr_t (*close) (hid_t dataset_id, hid_t req);
+ herr_t (*set_extent) (void *dset, const hsize_t size[], hid_t req);
+ herr_t (*get) (void *dset, H5VL_dataset_get_t get_type, hid_t req, va_list arguments);
+ herr_t (*close) (void *dset, hid_t req);
} H5VL_dataset_class_t;
/* H5F routines */
typedef struct H5VL_file_class_t {
- hid_t (*create)(const char *name, unsigned flags, hid_t fcpl_id,
+ void *(*create)(const char *name, unsigned flags, hid_t fcpl_id,
hid_t fapl_id, hid_t req);
- hid_t (*open) (const char *name, unsigned flags, hid_t fapl_id, hid_t req);
- herr_t (*flush) (hid_t file_id, H5F_scope_t scope, hid_t req);
- herr_t (*get) (hid_t file_id, H5VL_file_get_t get_type, hid_t req, va_list arguments);
- herr_t (*misc)(hid_t loc_id, H5VL_file_misc_t misc_type, hid_t req, va_list arguments);
- herr_t (*optional)(hid_t id, H5VL_file_optional_t op_type, hid_t req, va_list arguments);
- herr_t (*close) (hid_t file_id, hid_t req);
+ void *(*open) (const char *name, unsigned flags, hid_t fapl_id, hid_t req);
+ herr_t (*flush) (void *obj, H5VL_loc_params_t loc_params, H5F_scope_t scope, hid_t req);
+ herr_t (*get) (void *file, H5VL_file_get_t get_type, hid_t req, va_list arguments);
+ herr_t (*misc) (void *file, H5VL_file_misc_t misc_type, hid_t req, va_list arguments);
+ herr_t (*optional)(void *file, H5VL_file_optional_t op_type, hid_t req, va_list arguments);
+ herr_t (*close) (void *file, hid_t req);
} H5VL_file_class_t;
/* H5G routines */
typedef struct H5VL_group_class_t {
- hid_t (*create)(hid_t loc_id, const char *name, hid_t gcpl_id, hid_t gapl_id, hid_t req);
- hid_t (*open) (hid_t loc_id, const char *name, hid_t gapl_id, hid_t req);
- herr_t (*get) (hid_t file_id, H5VL_group_get_t get_type, hid_t req, va_list arguments);
- herr_t (*close) (hid_t group_id, hid_t req);
+ void *(*create)(void *obj, H5VL_loc_params_t loc_params, const char *name, hid_t gcpl_id, hid_t gapl_id, hid_t req);
+ void *(*open) (void *obj, H5VL_loc_params_t loc_params, const char *name, hid_t gapl_id, hid_t req);
+ herr_t (*get) (void *obj, H5VL_group_get_t get_type, hid_t req, va_list arguments);
+ herr_t (*close) (void *grp, hid_t req);
} H5VL_group_class_t;
/* H5L routines */
typedef struct H5VL_link_class_t {
- herr_t (*create)(H5VL_link_create_type_t create_type, hid_t link_loc_id, const char *link_name,
+ herr_t (*create)(H5VL_link_create_type_t create_type, void *obj, H5VL_loc_params_t loc_params,
hid_t lcpl_id, hid_t lapl_id, hid_t req);
- herr_t (*move) (hid_t src_loc_id, const char *src_name, hid_t dst_loc_id,
- const char *dest_name, hbool_t copy_flag, hid_t lcpl, hid_t lapl, hid_t req);
- herr_t (*iterate) (hid_t loc_id, const char *name, hbool_t recursive,
+ herr_t (*move) (void *src_obj, H5VL_loc_params_t loc_params1,
+ void *dst_obj, H5VL_loc_params_t loc_params2,
+ hbool_t copy_flag, hid_t lcpl, hid_t lapl, hid_t req);
+ herr_t (*iterate) (void *obj, H5VL_loc_params_t loc_params, hbool_t recursive,
H5_index_t idx_type, H5_iter_order_t order, hsize_t *idx,
- H5L_iterate_t op, void *op_data, hid_t lapl_id);
- herr_t (*get) (hid_t loc_id, H5VL_link_get_t get_type, hid_t req, va_list arguments);
- herr_t (*remove)(hid_t loc_id, const char *name, void *udata, hid_t lapl_id, hid_t req);
+ H5L_iterate_t op, void *op_data, hid_t req);
+ herr_t (*get) (void *obj, H5VL_loc_params_t loc_params, H5VL_link_get_t get_type, hid_t req, va_list arguments);
+ herr_t (*remove)(void *obj, H5VL_loc_params_t loc_params, hid_t req);
} H5VL_link_class_t;
/* H5O routines */
typedef struct H5VL_object_class_t {
- hid_t (*open) (hid_t id, H5VL_loc_params_t params, hid_t req);
- herr_t (*copy) (hid_t src_loc_id, const char *src_name, hid_t dst_loc_id, const char *dst_name,
+ void *(*open) (void *obj, H5VL_loc_params_t loc_params, H5I_type_t *opened_type, hid_t req);
+ herr_t (*copy) (void *src_obj, H5VL_loc_params_t loc_params1, const char *src_name,
+ void *dst_obj, H5VL_loc_params_t loc_params2, const char *dst_name,
hid_t ocpypl_id, hid_t lcpl_id, hid_t req);
- herr_t (*visit) (hid_t loc_id, const char *obj_name, H5_index_t idx_type, H5_iter_order_t order,
- H5O_iterate_t op, void *op_data, hid_t lapl_id);
- herr_t (*lookup)(hid_t loc_id, H5VL_loc_type_t lookup_type, void **location, hid_t req, va_list arguments);
- herr_t (*free_loc)(void *location, hid_t req);
- herr_t (*get) (hid_t loc_id, H5VL_object_get_t get_type, hid_t req, va_list arguments);
- herr_t (*misc) (hid_t id, H5VL_object_misc_t misc_type, hid_t req, va_list arguments);
- herr_t (*optional)(hid_t id, H5VL_object_optional_t op_type, hid_t req, va_list arguments);
- herr_t (*close) (hid_t obj_id, hid_t req);
+ herr_t (*visit) (void *obj, H5VL_loc_params_t loc_params, H5_index_t idx_type,
+ H5_iter_order_t order, H5O_iterate_t op, void *op_data, hid_t req);
+ //herr_t (*lookup)(hid_t loc_id, H5VL_loc_type_t lookup_type, void **location, hid_t req, va_list arguments);
+ //herr_t (*free_loc)(void *location, hid_t req);
+ herr_t (*get) (void *obj, H5VL_loc_params_t loc_params, H5VL_object_get_t get_type, hid_t req, va_list arguments);
+ herr_t (*misc) (void *obj, H5VL_loc_params_t loc_params, H5VL_object_misc_t misc_type, hid_t req, va_list arguments);
+ herr_t (*optional)(void *obj, H5VL_loc_params_t loc_params, H5VL_object_optional_t op_type, hid_t req, va_list arguments);
+ herr_t (*close) (void *obj, H5VL_loc_params_t loc_params, hid_t req);
} H5VL_object_class_t;
/* Class information for each VOL driver */
@@ -298,7 +298,7 @@ typedef struct H5VL_class_t {
H5VL_link_class_t link_cls;
H5VL_object_class_t object_cls;
} H5VL_class_t;
-#if 0
+
/*
* The main datatype for each plugin. Public fields common to all
* plugins are declared here and the plugin appends private fields in
@@ -308,57 +308,75 @@ struct H5VL_t {
const H5VL_class_t *cls; /*constant class info */
const char *container_name; /* name of the underlying storage container */
unsigned long feature_flags; /* VOL Driver feature Flags */
- void *object; /* actual object that the underlying plugin creates/uses */
+ int nrefs; /* number of references by objects using this struct */
};
-H5_DLL H5VL_t *H5VLattr_create(H5VL_t *obj, const char *attr_name, hid_t acpl, hid_t aapl, hid_t req);
-H5_DLL H5VL_t *H5VLattr_open(H5VL_t *obj, H5VL_loc_params_t loc_params, const char *name, hid_t aapl, hid_t req);
-H5_DLL herr_t H5VLattr_read(H5VL_t *obj, hid_t dtype_id, void *buf, hid_t req);
-H5_DLL herr_t H5VLattr_write(H5VL_t *obj, hid_t dtype_id, const void *buf, hid_t req);
-H5_DLL herr_t H5VLattr_get(H5VL_t *obj, H5VL_attr_get_t get_type, hid_t req, ...);
-H5_DLL herr_t H5VLattr_remove(H5VL_t *obj, H5VL_loc_params_t loc_params, const char *attr_name, hid_t req);
-H5_DLL herr_t H5VLattr_close(H5VL_t *obj, hid_t req);
-
-H5_DLL H5VL_t *H5VLdataset_create(H5VL_t *obj, const char *name, hid_t dcpl_id, hid_t dapl_id, hid_t req);
-H5_DLL H5VL_t *H5VLdataset_open(H5VL_t *obj, const char *name, hid_t dapl_id, hid_t req);
-H5_DLL herr_t H5VLdataset_read(H5VL_t *obj, hid_t mem_type_id, hid_t mem_space_id, hid_t file_space_id, hid_t plist_id, void *buf, hid_t req);
-H5_DLL herr_t H5VLdataset_write(H5VL_t *obj, hid_t mem_type_id, hid_t mem_space_id, hid_t file_space_id, hid_t plist_id, const void *buf, hid_t req);
-H5_DLL herr_t H5VLdataset_set_extent(H5VL_t *obj, const hsize_t size[], hid_t req);
-H5_DLL herr_t H5VLdataset_get(H5VL_t *obj, H5VL_dataset_get_t get_type, hid_t req, ...);
-H5_DLL herr_t H5VLdataset_close(H5VL_t *obj, hid_t req);
-
-H5_DLL herr_t H5VLdatatype_commit(H5VL_t *obj, const char *name, hid_t type_id, hid_t lcpl_id, hid_t tcpl_id, hid_t tapl_id, hid_t req);
-H5_DLL H5VL_t *H5VLdatatype_open(H5VL_t *obj, const char *name, hid_t tapl_id, hid_t req);
-H5_DLL herr_t H5VLdatatype_close(H5VL_t *obj, hid_t req);
-
-H5_DLL H5VL_t *H5VLfile_open(const char *name, unsigned flags, hid_t fapl_id, hid_t req);
-H5_DLL H5VL_t *H5VLfile_create(const char *name, unsigned flags, hid_t fcpl_id, hid_t fapl_id, hid_t req);
-H5_DLL herr_t H5VLfile_flush(H5VL_t *obj, H5F_scope_t scope, hid_t req);
-H5_DLL herr_t H5VLfile_misc(H5VL_t *obj, H5VL_file_misc_t misc_type, hid_t req, ...);
-H5_DLL herr_t H5VLfile_optional(H5VL_t *obj, H5VL_file_optional_t optional_type, hid_t req, ...);
-H5_DLL herr_t H5VLfile_get(H5VL_t *obj, H5VL_file_get_t get_type, hid_t req, ...);
-H5_DLL herr_t H5VLfile_close(H5VL_t *obj, hid_t req);
-
-H5_DLL H5VL_t *H5VLgroup_create(H5VL_t *obj, const char *name, hid_t gcpl_id, hid_t gapl_id, hid_t req);
-H5_DLL H5VL_t *H5VLgroup_open(H5VL_t *obj, const char *name, hid_t gapl_id, hid_t req);
-H5_DLL herr_t H5VLgroup_get(H5VL_t *obj, H5VL_group_get_t get_type, hid_t req, ...);
-H5_DLL herr_t H5VLgroup_close(H5VL_t *obj, hid_t req);
-
-H5_DLL herr_t H5VLlink_create(H5VL_link_create_type_t create_type, H5VL_t *obj, const char *link_name, hid_t lcpl_id, hid_t lapl_id, hid_t req);
-H5_DLL herr_t H5VLlink_move(H5VL_t *src_obj, const char *src_name, H5VL_t *dst_obj, const char *dst_name, hbool_t copy_flag, hid_t lcpl_id, hid_t lapl_id, hid_t req);
-H5_DLL herr_t H5VLlink_iterate(H5VL_t *obj, const char *name, hbool_t recursive, H5_index_t idx_type, H5_iter_order_t order, hsize_t *idx, H5L_iterate_t op, void *op_data, hid_t lapl_id);
-H5_DLL herr_t H5VLlink_get(H5VL_t *obj, H5VL_link_get_t get_type, hid_t req, ...);
-H5_DLL herr_t H5VLlink_remove(H5VL_t *obj, const char *name, void *udata, hid_t lapl_id, hid_t req);
-
-H5_DLL H5VL_t *H5VLobject_open(H5VL_t *obj, H5VL_loc_params_t params, hid_t req);
-H5_DLL herr_t H5VLobject_copy(H5VL_t *src_obj, const char *src_name, H5VL_t *dst_obj, const char *dst_name, hid_t ocpypl_id, hid_t lcpl_id, hid_t req);
-H5_DLL herr_t H5VLobject_visit(H5VL_t *obj, const char *obj_name, H5_index_t idx_type, H5_iter_order_t order, H5O_iterate_t op, void *op_data, hid_t lapl_id);
-H5_DLL herr_t H5VLobject_get(H5VL_t *obj, H5VL_object_get_t get_type, hid_t req, ...);
-H5_DLL herr_t H5VLobject_misc(H5VL_t *obj, H5VL_object_misc_t misc_type, hid_t req, ...);
-H5_DLL herr_t H5VLobject_optional(H5VL_t *obj, H5VL_object_misc_t optional_type, hid_t req, ...);
-H5_DLL herr_t H5VLobject_lookup(H5VL_t *obj, H5VL_loc_type_t lookup_type, void **location, hid_t req, ...);
-H5_DLL herr_t H5VLobject_free_loc(H5VL_t *obj, void *location, hid_t req);
-H5_DLL herr_t H5VLobject_close(H5VL_t *obj, hid_t req);
+#if 0
+
+/* FILE OBJECT ROUTINES */
+H5_DLL void *H5VLfile_create(H5VL_t *vol_plugin, const char *name, unsigned flags, hid_t fcpl_id, hid_t fapl_id, hid_t req);
+H5_DLL void *H5VLfile_open(H5VL_t *vol_plugin, const char *name, unsigned flags, hid_t fapl_id, hid_t req);
+H5_DLL herr_t H5VLfile_flush(void *file, H5VL_t *vol_plugin, H5F_scope_t scope, hid_t req);
+H5_DLL herr_t H5VLfile_misc(void *file, H5VL_t *vol_plugin, H5VL_file_misc_t misc_type, hid_t req, ...);
+H5_DLL herr_t H5VLfile_optional(void *file, H5VL_t *vol_plugin, H5VL_file_optional_t optional_type, hid_t req, ...);
+H5_DLL herr_t H5VLfile_get(void *file, H5VL_t *vol_plugin, H5VL_file_get_t get_type, hid_t req, ...);
+H5_DLL herr_t H5VLfile_close(void *file, H5VL_t *vol_plugin, hid_t req);
+
+/* ATTRIBUTE OBJECT ROUTINES */
+H5_DLL void *H5VLattr_create(void *obj, H5VL_t *vol_plugin, const char *attr_name, hid_t acpl, hid_t aapl, hid_t req);
+H5_DLL void *H5VLattr_open(void *obj, H5VL_t *vol_plugin, H5VL_loc_params_t loc_params, const char *name, hid_t aapl, hid_t req);
+H5_DLL herr_t H5VLattr_read(void *obj, H5VL_t *vol_plugin, hid_t dtype_id, void *buf, hid_t req);
+H5_DLL herr_t H5VLattr_write(void *obj, H5VL_t *vol_plugin, hid_t dtype_id, const void *buf, hid_t req);
+H5_DLL herr_t H5VLattr_get(void *obj, H5VL_t *vol_plugin, H5VL_attr_get_t get_type, hid_t req, ...);
+H5_DLL herr_t H5VLattr_remove(void *obj, H5VL_t *vol_plugin, H5VL_loc_params_t loc_params, const char *attr_name, hid_t req);
+H5_DLL herr_t H5VLattr_close(void *obj, H5VL_t *vol_plugin, hid_t req);
+
+/* DATASET OBJECT ROUTINES */
+H5_DLL void *H5VLdataset_create(void *obj, H5VL_t *vol_plugin, const char *name, hid_t dcpl_id, hid_t dapl_id, hid_t req);
+H5_DLL void *H5VLdataset_open(void *obj, H5VL_t *vol_plugin, const char *name, hid_t dapl_id, hid_t req);
+H5_DLL herr_t H5VLdataset_read(void *obj, H5VL_t *vol_plugin, hid_t mem_type_id, hid_t mem_space_id, hid_t file_space_id, hid_t plist_id, void *buf, hid_t req);
+H5_DLL herr_t H5VLdataset_write(void *obj, H5VL_t *vol_plugin, hid_t mem_type_id, hid_t mem_space_id, hid_t file_space_id, hid_t plist_id, const void *buf, hid_t req);
+H5_DLL herr_t H5VLdataset_set_extent(void *obj, H5VL_t *vol_plugin, const hsize_t size[], hid_t req);
+H5_DLL herr_t H5VLdataset_get(void *obj, H5VL_t *vol_plugin, H5VL_dataset_get_t get_type, hid_t req, ...);
+H5_DLL herr_t H5VLdataset_close(void *obj, H5VL_t *vol_plugin, hid_t req);
+
+/* DATATYPE OBJECT ROUTINES */
+H5_DLL void *H5VLdatatype_commit(void *obj, H5VL_t *vol_plugin, const char *name, hid_t type_id, hid_t lcpl_id, hid_t tcpl_id, hid_t tapl_id, hid_t req);
+H5_DLL size_t H5VLdatatype_get_serial_size(void *obj, H5VL_t *vol_plugin, const char *name, hid_t tapl_id, hid_t req);
+H5_DLL void *H5VLdatatype_open(void *obj, H5VL_t *vol_plugin, void *serialized_type, const char *name, hid_t tapl_id, hid_t req);
+H5_DLL herr_t H5VLdatatype_close(void *obj, H5VL_t *vol_plugin, hid_t req);
+
+/* GROUP OBJECT ROUTINES */
+H5_DLL H5VL_t *H5VLgroup_create(void *obj, H5VL_t *vol_plugin, const char *name, hid_t gcpl_id, hid_t gapl_id, hid_t req);
+H5_DLL H5VL_t *H5VLgroup_open(void *obj, H5VL_t *vol_plugin, const char *name, hid_t gapl_id, hid_t req);
+H5_DLL herr_t H5VLgroup_get(void *obj, H5VL_t *vol_plugin, H5VL_group_get_t get_type, hid_t req, ...);
+H5_DLL herr_t H5VLgroup_close(void *obj, H5VL_t *vol_plugin, hid_t req);
+
+/* LINK ROUTINES */
+H5_DLL herr_t H5VLlink_create(H5VL_link_create_type_t create_type, void *obj, H5VL_t *vol_plugin, const char *link_name, hid_t lcpl_id, hid_t lapl_id, hid_t req);
+H5_DLL herr_t H5VLlink_move(void *src_obj, H5VL_t *src_plugin, const char *src_name,
+ void *dst_obj, H5VL_t *dst_plugin, const char *dst_name,
+ hbool_t copy_flag, hid_t lcpl_id, hid_t lapl_id, hid_t req);
+H5_DLL herr_t H5VLlink_iterate(void *obj, H5VL_t *vol_plugin, const char *name, hbool_t recursive, H5_index_t idx_type,
+ H5_iter_order_t order, hsize_t *idx, H5L_iterate_t op, void *op_data,
+ hid_t lapl_id);
+H5_DLL herr_t H5VLlink_get(void *obj, H5VL_t *vol_plugin, H5VL_link_get_t get_type, hid_t req, ...);
+H5_DLL herr_t H5VLlink_remove(void *obj, H5VL_t *vol_plugin, const char *name, void *udata, hid_t lapl_id, hid_t req);
+
+/* OBJECT ROUTINES */
+H5_DLL void *H5VLobject_open(void *obj, H5VL_t *vol_plugin, H5VL_loc_params_t params, hid_t req);
+H5_DLL herr_t H5VLobject_copy(void *src_obj, H5VL_t *src_plugin, const char *src_name,
+ void *dst_obj, H5VL_t *dst_plugin, const char *dst_name,
+ hid_t ocpypl_id, hid_t lcpl_id, hid_t req);
+H5_DLL herr_t H5VLobject_visit(void *obj, H5VL_t *vol_plugin, const char *obj_name, H5_index_t idx_type, H5_iter_order_t order, H5O_iterate_t op, void *op_data, hid_t lapl_id);
+H5_DLL herr_t H5VLobject_get(void *obj, H5VL_t *vol_plugin, H5VL_object_get_t get_type, hid_t req, ...);
+H5_DLL herr_t H5VLobject_misc(void *obj, H5VL_t *vol_plugin, H5VL_object_misc_t misc_type, hid_t req, ...);
+H5_DLL herr_t H5VLobject_optional(void *obj, H5VL_t *vol_plugin, H5VL_object_misc_t optional_type, hid_t req, ...);
+H5_DLL herr_t H5VLobject_close(void *obj, H5VL_t *vol_plugin, hid_t req);
+/*
+H5_DLL herr_t H5VLobject_lookup(void *obj, H5VL_t *vol_plugin, H5VL_loc_type_t lookup_type, void **location, hid_t req, ...);
+H5_DLL herr_t H5VLobject_free_loc(void *obj, H5VL_t *vol_plugin, void *location, hid_t req);
+*/
#endif
@@ -371,6 +389,7 @@ H5_DLL hid_t H5VLregister(const H5VL_class_t *cls);
H5_DLL herr_t H5VLunregister(hid_t plugin_id);
H5_DLL htri_t H5VLis_registered(hid_t id);
H5_DLL ssize_t H5VLget_plugin_name(hid_t id, char *name/*out*/, size_t size);
+H5_DLL hid_t H5VLregister_object(void *obj, H5I_type_t obj_type, const H5VL_class_t *cls);
#ifdef __cplusplus
}