summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorFrank Willmore <Frank.Willmore@hdfgroup.org>2017-12-18 03:45:40 (GMT)
committerFrank Willmore <Frank.Willmore@hdfgroup.org>2017-12-18 03:45:40 (GMT)
commit40fd2ec5136d809eb9a53745fc877e230a42f777 (patch)
treed300d0ffbd3d20b92b422e7bbf6231951874e7b4
parent1cfaabba1e7a35c33a937c7a7e1b2224f8be6433 (diff)
parent191f23a20e12257395b047de88da94a0d0e9c731 (diff)
downloadhdf5-40fd2ec5136d809eb9a53745fc877e230a42f777.zip
hdf5-40fd2ec5136d809eb9a53745fc877e230a42f777.tar.gz
hdf5-40fd2ec5136d809eb9a53745fc877e230a42f777.tar.bz2
Merge branch 'vol_integration_api' into json-vol
-rw-r--r--src/H5A.c92
-rw-r--r--src/H5F.c14
-rw-r--r--src/H5Fpkg.h1
-rw-r--r--src/H5G.c85
-rw-r--r--src/H5I.c115
-rw-r--r--src/H5Iprivate.h1
-rw-r--r--src/H5L.c173
-rw-r--r--src/H5O.c196
-rw-r--r--src/H5Rint.c2
-rw-r--r--src/H5Tcommit.c245
-rw-r--r--src/H5VLnative.c2
-rw-r--r--src/H5Z.c79
-rw-r--r--test/fillval.c51
-rw-r--r--test/unregister.c242
-rw-r--r--test/vol.c91
15 files changed, 795 insertions, 594 deletions
diff --git a/src/H5A.c b/src/H5A.c
index 5f548ad..55d5e27 100644
--- a/src/H5A.c
+++ b/src/H5A.c
@@ -460,7 +460,7 @@ done:
const char *attr_name; IN: Name of attribute to locate and open
hid_t aapl_id; IN: Attribute access property list
RETURNS
- ID of attribute on success, negative on failure
+ ID of attribute on success, H5I_INVALID_HID on failure
DESCRIPTION
This function opens an existing attribute for access. The attribute
@@ -471,43 +471,49 @@ done:
hid_t
H5Aopen(hid_t loc_id, const char *attr_name, hid_t aapl_id)
{
- H5G_loc_t loc; /* Object location */
- H5A_t *attr = NULL; /* Attribute opened */
- hid_t dxpl_id = H5AC_ind_read_dxpl_id; /* dxpl used by library */
- hid_t ret_value;
+ void *attr = NULL; /* attr token from VOL plugin */
+ H5VL_object_t *obj = NULL; /* object token of loc_id */
+ H5VL_loc_params_t loc_params;
+ hid_t dxpl_id = H5AC_ind_read_dxpl_id; /* dxpl used by library */
+ hid_t ret_value = H5I_INVALID_HID;
- FUNC_ENTER_API(FAIL)
+ FUNC_ENTER_API(H5I_INVALID_HID)
H5TRACE3("i", "i*si", loc_id, attr_name, aapl_id);
- /* 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(!attr_name || !*attr_name)
- HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "no attribute name")
+ /* Check arguments */
+ if (H5I_ATTR == H5I_get_type(loc_id))
+ HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, H5I_INVALID_HID, "location is not valid for an attribute")
+ if (!attr_name)
+ HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, H5I_INVALID_HID, "name parameter cannot be NULL")
+ if (!*attr_name)
+ HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, H5I_INVALID_HID, "name parameter cannot be an empty string")
/* Verify access property list and get correct dxpl */
- if(H5P_verify_apl_and_dxpl(&aapl_id, H5P_CLS_AACC, &dxpl_id, loc_id, FALSE) < 0)
- HGOTO_ERROR(H5E_ATTR, H5E_CANTSET, FAIL, "can't set access and transfer property lists")
+ if (H5P_verify_apl_and_dxpl(&aapl_id, H5P_CLS_AACC, &dxpl_id, loc_id, FALSE) < 0)
+ HGOTO_ERROR(H5E_ATTR, H5E_CANTSET, H5I_INVALID_HID, "can't set access and transfer property lists")
- /* Read in attribute from object header */
- if(NULL == (attr = H5O_attr_open_by_name(loc.oloc, attr_name, dxpl_id)))
- HGOTO_ERROR(H5E_ATTR, H5E_CANTINIT, FAIL, "unable to load attribute info from object header for attribute: '%s'", attr_name)
+ /* Set location struct fields */
+ loc_params.type = H5VL_OBJECT_BY_SELF;
+ loc_params.obj_type = H5I_get_type(loc_id);
- /* Finish initializing attribute */
- if(H5A__open_common(&loc, attr) < 0)
- HGOTO_ERROR(H5E_ATTR, H5E_CANTINIT, FAIL, "unable to initialize attribute")
+ /* Get the location object */
+ if (NULL == (obj = H5VL_get_object(loc_id)))
+ HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, H5I_INVALID_HID, "invalid location identifier")
- /* 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")
+ /* Open the attribute through the VOL */
+ if (NULL == (attr = H5VL_attr_open(obj->vol_obj, loc_params, obj->vol_info->vol_cls,
+ attr_name, aapl_id, dxpl_id, H5_REQUEST_NULL)))
+ HGOTO_ERROR(H5E_SYM, H5E_CANTOPENOBJ, H5I_INVALID_HID, "unable to open attribute")
+
+ /* Get an atom for the attribute */
+ if ((ret_value = H5VL_register_id(H5I_ATTR, attr, obj->vol_info, TRUE)) < 0)
+ HGOTO_ERROR(H5E_ATOM, H5E_CANTREGISTER, H5I_INVALID_HID, "unable to atomize attribute handle")
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")
+ if (H5I_INVALID_HID == ret_value)
+ if (attr && H5VL_attr_close(attr, obj->vol_info->vol_cls, dxpl_id, H5_REQUEST_NULL) < 0)
+ HDONE_ERROR(H5E_ATTR, H5E_CLOSEERROR, H5I_INVALID_HID, "unable to release attr")
FUNC_LEAVE_API(ret_value)
} /* H5Aopen() */
@@ -1490,22 +1496,32 @@ done:
herr_t
H5Adelete(hid_t loc_id, const char *name)
{
- H5G_loc_t loc; /* Object location */
- herr_t ret_value = SUCCEED; /* Return value */
+ H5VL_object_t *obj = NULL;
+ H5VL_loc_params_t loc_params;
+ herr_t ret_value = SUCCEED; /* Return value */
FUNC_ENTER_API(FAIL)
H5TRACE2("e", "i*s", loc_id, name);
- /* 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(!name || !*name)
- HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "no name")
+ /* 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 (!name)
+ HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "name parameter cannot be NULL")
+ if (!*name)
+ HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "name parameter cannot be an empty string")
- /* Delete the attribute from the location */
- if(H5O_attr_remove(loc.oloc, name, H5AC_ind_read_dxpl_id) < 0)
+ /* Fill in location struct fields */
+ loc_params.type = H5VL_OBJECT_BY_SELF;
+ loc_params.obj_type = H5I_get_type(loc_id);
+
+ /* Get the object */
+ if (NULL == (obj = H5VL_get_object(loc_id)))
+ HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "invalid object identifier")
+
+ /* Delete the attribute through the VOL */
+ if ((ret_value = H5VL_attr_specific(obj->vol_obj, loc_params, obj->vol_info->vol_cls, H5VL_ATTR_DELETE,
+ H5AC_ind_read_dxpl_id, H5_REQUEST_NULL, name)) < 0)
HGOTO_ERROR(H5E_ATTR, H5E_CANTDELETE, FAIL, "unable to delete attribute")
done:
diff --git a/src/H5F.c b/src/H5F.c
index 860ed06..12285bb 100644
--- a/src/H5F.c
+++ b/src/H5F.c
@@ -1041,24 +1041,26 @@ done:
* Return: Success: Bytes copied / number of bytes needed
*
* Failure: -1
+ *
*-------------------------------------------------------------------------
*/
ssize_t
H5Fget_file_image(hid_t file_id, void *buf_ptr, size_t buf_len)
{
- H5F_t *file; /* File object for file ID */
- ssize_t ret_value; /* Return value */
+ H5VL_object_t *file; /* File object for file ID */
+ ssize_t ret_value; /* Return value */
FUNC_ENTER_API((-1))
H5TRACE3("Zs", "i*xz", file_id, buf_ptr, buf_len);
/* Check args */
- if (NULL == (file = (H5F_t *)H5I_object_verify(file_id, H5I_FILE)))
+ if (NULL == (file = (H5VL_object_t *)H5I_object_verify(file_id, H5I_FILE)))
HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, (-1), "not a file ID")
- /* call private get_file_image function */
- if ((ret_value = H5F_get_file_image(file, buf_ptr, buf_len, H5AC_ind_read_dxpl_id, H5AC_rawdata_dxpl_id)) < 0)
- HGOTO_ERROR(H5E_FILE, H5E_CANTGET, (-1), "unable to get file image")
+ /* Get image through the VOL */
+ if (H5VL_file_optional(file->vol_obj, file->vol_info->vol_cls, H5AC_ind_read_dxpl_id, H5_REQUEST_NULL,
+ H5VL_FILE_GET_FILE_IMAGE, buf_ptr, &ret_value, buf_len) < 0)
+ HGOTO_ERROR(H5E_INTERNAL, H5E_CANTGET, (-1), "unable to get file image")
done:
FUNC_LEAVE_API(ret_value)
diff --git a/src/H5Fpkg.h b/src/H5Fpkg.h
index 82b0997..0b72376 100644
--- a/src/H5Fpkg.h
+++ b/src/H5Fpkg.h
@@ -402,6 +402,7 @@ typedef struct {
} H5F_trav_obj_cnt_t;
/* User data for traversal routine to get ID lists */
+/* XXX: Type of obj_count and max_objs should be identical! */
typedef struct {
size_t max_objs;
hid_t *oid_list;
diff --git a/src/H5G.c b/src/H5G.c
index 74e2048..c2ba13b 100644
--- a/src/H5G.c
+++ b/src/H5G.c
@@ -384,9 +384,9 @@ done:
/*-------------------------------------------------------------------------
- * Function: H5Gcreate_anon
+ * Function: H5Gcreate_anon
*
- * Purpose: Creates a new group relative to LOC_ID, giving it the
+ * Purpose: Creates a new group relative to LOC_ID, giving it the
* specified creation property list GCPL_ID and access
* property list GAPL_ID.
*
@@ -402,78 +402,63 @@ done:
* hid_t gcpl_id; IN: Property list for group creation
* hid_t gapl_id; IN: Property list for group access
*
- * Example: To create missing groups "A" and "B01" along the given path "/A/B01/grp"
+ * Example: To create missing groups "A" and "B01" along the given path "/A/B01/grp"
* hid_t create_id = H5Pcreate(H5P_GROUP_CREATE);
* int status = H5Pset_create_intermediate_group(create_id, TRUE);
* hid_t gid = H5Gcreate_anon(file_id, "/A/B01/grp", create_id, H5P_DEFAULT);
*
- * Return: Success: The object ID of a new, empty group open for
- * writing. Call H5Gclose() when finished with
- * the group.
- *
- * Failure: FAIL
+ * Return: Success: The object ID of a new, empty group open for
+ * writing. Call H5Gclose() when finished with
+ * the group.
*
- * Programmer: Peter Cao
- * May 08, 2005
+ * Failure: H5I_INVALID_HID
*
*-------------------------------------------------------------------------
*/
hid_t
H5Gcreate_anon(hid_t loc_id, hid_t gcpl_id, hid_t gapl_id)
{
- H5G_loc_t loc;
- H5G_t *grp = NULL;
- H5G_obj_create_t gcrt_info; /* Information for group creation */
- hid_t dxpl_id = H5AC_ind_read_dxpl_id; /* dxpl used by library */
- hid_t ret_value;
+ void *grp = NULL; /* group token from VOL plugin */
+ H5VL_object_t *obj = NULL; /* object token of loc_id */
+ H5VL_loc_params_t loc_params;
+ hid_t dxpl_id = H5AC_ind_read_dxpl_id; /* dxpl used by library */
+ hid_t ret_value = H5I_INVALID_HID; /* Return value */
- FUNC_ENTER_API(FAIL)
+ FUNC_ENTER_API(H5I_INVALID_HID)
H5TRACE3("i", "iii", loc_id, gcpl_id, gapl_id);
- /* Check arguments */
- if(H5G_loc(loc_id, &loc) < 0)
- HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a location")
-
/* Check group creation property list */
- if(H5P_DEFAULT == gcpl_id)
+ if (H5P_DEFAULT == gcpl_id)
gcpl_id = H5P_GROUP_CREATE_DEFAULT;
else
- if(TRUE != H5P_isa_class(gcpl_id, H5P_GROUP_CREATE))
- HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not group create property list")
+ if (TRUE != H5P_isa_class(gcpl_id, H5P_GROUP_CREATE))
+ HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, H5I_INVALID_HID, "not group create property list")
/* Verify access property list and get correct dxpl */
- if(H5P_verify_apl_and_dxpl(&gapl_id, H5P_CLS_GACC, &dxpl_id, loc_id, TRUE) < 0)
- HGOTO_ERROR(H5E_SYM, H5E_CANTSET, FAIL, "can't set access and transfer property lists")
-
- /* Set up group creation info */
- gcrt_info.gcpl_id = gcpl_id;
- gcrt_info.cache_type = H5G_NOTHING_CACHED;
- HDmemset(&gcrt_info.cache, 0, sizeof(gcrt_info.cache));
+ if (H5P_verify_apl_and_dxpl(&gapl_id, H5P_CLS_GACC, &dxpl_id, loc_id, TRUE) < 0)
+ HGOTO_ERROR(H5E_SYM, H5E_CANTSET, H5I_INVALID_HID, "can't set access and transfer property lists")
- /* Create the new group & get its ID */
- if(NULL == (grp = H5G__create(loc.oloc->file, &gcrt_info, dxpl_id)))
- HGOTO_ERROR(H5E_SYM, H5E_CANTINIT, FAIL, "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")
+ /* Set location struct fields */
+ loc_params.type = H5VL_OBJECT_BY_SELF;
+ loc_params.obj_type = H5I_get_type(loc_id);
-done:
- /* Release the group's object header, if it was created */
- if(grp) {
- H5O_loc_t *oloc; /* Object location for group */
+ /* get the location object */
+ if (NULL == (obj = (H5VL_object_t *)H5I_object(loc_id)))
+ HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, H5I_INVALID_HID, "invalid location identifier")
- /* 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")
+ /* Create the group through the VOL */
+ if (NULL == (grp = H5VL_group_create(obj->vol_obj, loc_params, obj->vol_info->vol_cls, NULL,
+ gcpl_id, gapl_id, dxpl_id, H5_REQUEST_NULL)))
+ HGOTO_ERROR(H5E_SYM, H5E_CANTINIT, H5I_INVALID_HID, "unable to create group")
- /* Decrement refcount on group's object header in memory */
- if(H5O_dec_rc_by_loc(oloc, dxpl_id) < 0)
- HDONE_ERROR(H5E_SYM, H5E_CANTDEC, FAIL, "unable to decrement refcount on newly created object")
- } /* end if */
+ /* Get an atom for the group */
+ if ((ret_value = H5VL_register_id(H5I_GROUP, grp, obj->vol_info, TRUE)) < 0)
+ HGOTO_ERROR(H5E_ATOM, H5E_CANTREGISTER, H5I_INVALID_HID, "unable to atomize group handle")
- /* Cleanup on failure */
- if(ret_value < 0)
- if(grp && H5G_close(grp) < 0)
- HDONE_ERROR(H5E_SYM, H5E_CLOSEERROR, FAIL, "unable to release group")
+done:
+ if (H5I_INVALID_HID == ret_value)
+ if (grp && H5VL_group_close(grp, obj->vol_info->vol_cls, dxpl_id, H5_REQUEST_NULL) < 0)
+ HDONE_ERROR(H5E_SYM, H5E_CLOSEERROR, H5I_INVALID_HID, "unable to release group")
FUNC_LEAVE_API(ret_value)
} /* end H5Gcreate_anon() */
diff --git a/src/H5I.c b/src/H5I.c
index 448e3df..7f3274a 100644
--- a/src/H5I.c
+++ b/src/H5I.c
@@ -1886,7 +1886,7 @@ static herr_t
H5I__iterate_pub_cb(void H5_ATTR_UNUSED *obj, hid_t id, void *_udata)
{
H5I_iterate_pub_ud_t *udata = (H5I_iterate_pub_ud_t *)_udata; /* User data for callback */
- herr_t ret_value; /* Callback return value */
+ herr_t ret_value = FAIL; /* Callback return value */
FUNC_ENTER_NOAPI_NOINIT_NOERR
@@ -1965,16 +1965,24 @@ H5I__iterate_cb(void *_item, void H5_ATTR_UNUSED *_key, void *_udata)
FUNC_ENTER_STATIC_NOERR
/* Don't make callback if app_ref is set and the appl. ref count is 0 */
- if((!udata->app_ref) || (item->app_count > 0)) {
- herr_t cb_ret_val;
+ if ((!udata->app_ref) || (item->app_count > 0)) {
+ H5I_type_t type = udata->obj_type;
+ const void *obj_ptr = NULL;
+
+ if (H5I_FILE == type || H5I_GROUP == type || H5I_DATASET == type || H5I_ATTR == type) {
+ const H5VL_object_t *obj = (const H5VL_object_t *)item->obj_ptr;
+ obj_ptr = obj->vol_obj;
+ }
+ else if (H5I_DATATYPE == type) {
+ const H5T_t *dt = (const H5T_t *)item->obj_ptr;
+ obj_ptr = (void *)H5T_get_actual_type(dt);
+ }
+ else
+ obj_ptr = item->obj_ptr;
/* (Casting away const OK) */
- cb_ret_val = (*udata->user_func)((void *)item->obj_ptr, item->id, udata->user_udata);
- if(cb_ret_val > 0)
- ret_value = H5_ITER_STOP; /* terminate iteration early */
- else if(cb_ret_val < 0)
- ret_value = H5_ITER_ERROR; /* indicate failure (which terminates iteration) */
- } /* end if */
+ ret_value = (*udata->user_func)((void *)obj_ptr, item->id, udata->user_udata);
+ }
FUNC_LEAVE_NOAPI(ret_value)
} /* end H5I__iterate_cb() */
@@ -2008,8 +2016,8 @@ H5I__iterate_cb(void *_item, void H5_ATTR_UNUSED *_key, void *_udata)
herr_t
H5I_iterate(H5I_type_t type, H5I_search_func_t func, void *udata, hbool_t app_ref)
{
- H5I_id_type_t *type_ptr; /*ptr to the type */
- herr_t ret_value = SUCCEED; /*return value */
+ H5I_id_type_t *type_ptr; /* Pointer to the type */
+ herr_t ret_value = SUCCEED; /* Return value */
FUNC_ENTER_NOAPI(FAIL)
@@ -2024,9 +2032,9 @@ H5I_iterate(H5I_type_t type, H5I_search_func_t func, void *udata, hbool_t app_re
herr_t iter_status; /* Iteration status */
/* Set up iterator user data */
- iter_udata.user_func = func;
- iter_udata.user_udata = udata;
- iter_udata.app_ref = app_ref;
+ iter_udata.user_func = func;
+ iter_udata.user_udata = udata;
+ iter_udata.app_ref = app_ref;
/* Iterate over IDs */
if ((iter_status = H5SL_iterate(type_ptr->ids, H5I__iterate_cb, &iter_udata)) < 0)
@@ -2134,66 +2142,49 @@ done:
hid_t
H5Iget_file_id(hid_t obj_id)
{
- hid_t ret_value = H5I_INVALID_HID; /* Return value */
+ H5VL_object_t *obj;
+ void *file = NULL;
+ H5I_type_t type; /* ID type */
+ hid_t ret_value = H5I_INVALID_HID; /* Return value */
FUNC_ENTER_API(FAIL)
H5TRACE1("i", "i", obj_id);
- if ((ret_value = H5I_get_file_id(obj_id, TRUE)) < 0)
- HGOTO_ERROR(H5E_ATOM, H5E_CANTGET, H5I_INVALID_HID, "can't retrieve file ID")
-
-done:
- FUNC_LEAVE_API(ret_value)
-} /* end H5Iget_file_id() */
-
-
-/*-------------------------------------------------------------------------
- * Function: H5I_get_file_id
- *
- * Purpose: The private version of H5Iget_file_id(), obtains the file
- * ID given an object ID.
- *
- * Return: Success: The file ID associated with the object
- *
- * Failure: H5I_INVALID_HID
- *
- *-------------------------------------------------------------------------
- */
-hid_t
-H5I_get_file_id(hid_t obj_id, hbool_t app_ref)
-{
- H5I_type_t type; /* ID type */
- hid_t ret_value = H5I_INVALID_HID; /* Return value */
-
- FUNC_ENTER_NOAPI_NOINIT
-
/* Get object type */
type = H5I_TYPE(obj_id);
- if (type == H5I_FILE) {
- /* Increment reference count on file ID */
- if(H5I_inc_ref(obj_id, app_ref) < 0)
- HGOTO_ERROR(H5E_ATOM, H5E_CANTSET, H5I_INVALID_HID, "incrementing file ID failed")
-
- /* Set return value */
- ret_value = obj_id;
- }
- 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, H5I_INVALID_HID, "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, H5I_INVALID_HID, "can't get file ID")
+ if(H5I_FILE == type || H5I_DATATYPE == type || H5I_GROUP == type ||
+ H5I_DATASET == type || H5I_ATTR == type) {
+ /* Get the object pointer*/
+ if (NULL == (obj = H5VL_get_object(obj_id)))
+ HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, H5I_INVALID_HID, "invalid identifier")
+
+ /* Get the file through the VOL */
+ if (H5VL_file_get(obj->vol_obj, obj->vol_info->vol_cls, H5VL_OBJECT_GET_FILE,
+ H5AC_ind_read_dxpl_id, H5_REQUEST_NULL, type, &file) < 0)
+ HGOTO_ERROR(H5E_INTERNAL, H5E_CANTINIT, H5I_INVALID_HID, "unable to get file")
+
+ if (NULL == file)
+ HGOTO_ERROR(H5E_FILE, H5E_CANTINIT, H5I_INVALID_HID, "unable to reopen file")
+
+ /* Check if the ID already exists and procceed accordingly */
+ if (FAIL == (ret_value = H5I_get_id(file, H5I_FILE))) {
+ /* Get an atom for the file */
+ if ((ret_value = H5VL_register_id(H5I_FILE, file, obj->vol_info, TRUE)) < 0)
+ HGOTO_ERROR(H5E_ATOM, H5E_CANTREGISTER, H5I_INVALID_HID, "unable to atomize file handle")
+ }
+ else {
+ /* Increment ref count on existing ID */
+ if (H5I_inc_ref(ret_value, TRUE) < 0)
+ HGOTO_ERROR(H5E_ATOM, H5E_CANTSET, H5I_INVALID_HID, "incrementing file ID failed")
+ }
}
else
HGOTO_ERROR(H5E_ARGS, H5E_BADRANGE, H5I_INVALID_HID, "invalid object ID")
done:
- FUNC_LEAVE_NOAPI(ret_value)
-} /* end H5I_get_file_id() */
+ FUNC_LEAVE_API(ret_value)
+} /* end H5Iget_file_id() */
/*-------------------------------------------------------------------------
diff --git a/src/H5Iprivate.h b/src/H5Iprivate.h
index 04160aa..3d0d03a 100644
--- a/src/H5Iprivate.h
+++ b/src/H5Iprivate.h
@@ -72,7 +72,6 @@ H5_DLL void *H5I_subst(hid_t id, const void *new_object);
H5_DLL void *H5I_object(hid_t id);
H5_DLL void *H5I_object_verify(hid_t id, H5I_type_t id_type);
H5_DLL H5I_type_t H5I_get_type(hid_t id);
-H5_DLL hid_t H5I_get_file_id(hid_t obj_id, hbool_t app_ref);
H5_DLL void *H5I_remove(hid_t id);
H5_DLL herr_t H5I_iterate(H5I_type_t type, H5I_search_func_t func, void *udata, hbool_t app_ref);
H5_DLL int H5I_get_ref(hid_t id, hbool_t app_ref);
diff --git a/src/H5L.c b/src/H5L.c
index 4c2f225..5cae026 100644
--- a/src/H5L.c
+++ b/src/H5L.c
@@ -33,6 +33,7 @@
#include "H5Oprivate.h" /* File objects */
#include "H5Pprivate.h" /* Property lists */
#include "H5VLprivate.h" /* Virtual Object Layer */
+#include "H5VLnative.h" /* Virtual Object Layer (native) */
/****************/
@@ -264,19 +265,16 @@ H5L_term_package(void)
/*-------------------------------------------------------------------------
- * Function: H5Lmove
+ * Function: H5Lmove
*
- * Purpose: Renames an object within an HDF5 file and moves it to a new
+ * Purpose: Renames an object within an HDF5 file and moves it to a new
* group. The original name SRC is unlinked from the group graph
* and then inserted with the new name DST (which can specify a
* new path for the object) as an atomic operation. The names
- * are interpreted relative to SRC_LOC_ID and
- * DST_LOC_ID, which are either file IDs or group ID.
+ * are interpreted relative to SRC_LOC_ID and DST_LOC_ID,
+ * which are either file IDs or group ID.
*
- * Return: Non-negative on success/Negative on failure
- *
- * Programmer: James Laird
- * Wednesday, March 29, 2006
+ * Return: SUCCEED/FAIL
*
*-------------------------------------------------------------------------
*/
@@ -284,47 +282,72 @@ 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)
{
- H5G_loc_t src_loc, *src_loc_p;
- H5G_loc_t dst_loc, *dst_loc_p;
- hid_t dxpl_id = H5AC_ind_read_dxpl_id; /* dxpl used by library */
- herr_t ret_value=SUCCEED; /* Return value */
+ H5VL_object_t *obj1 = NULL; /* Object token of src_id */
+ H5VL_loc_params_t loc_params1;
+ H5VL_object_t *obj2 = NULL; /* Object token of dst_id */
+ H5VL_loc_params_t loc_params2;
+ hid_t dxpl_id = H5AC_ind_read_dxpl_id; /* dxpl used by library */
+ herr_t ret_value = SUCCEED; /* Return value */
FUNC_ENTER_API(FAIL)
H5TRACE6("e", "i*si*sii", src_loc_id, src_name, dst_loc_id, dst_name, lcpl_id,
lapl_id);
/* Check arguments */
- if(src_loc_id == H5L_SAME_LOC && dst_loc_id == H5L_SAME_LOC)
+ if (src_loc_id == H5L_SAME_LOC && dst_loc_id == H5L_SAME_LOC)
HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "source and destination should not both be H5L_SAME_LOC")
- 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(!src_name || !*src_name)
+ if (!src_name || !*src_name)
HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "no current name specified")
- if(!dst_name || !*dst_name)
+ if (!dst_name || !*dst_name)
HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "no destination name specified")
- if(lcpl_id != H5P_DEFAULT && (TRUE != H5P_isa_class(lcpl_id, H5P_LINK_CREATE)))
+ 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")
+ /* Check the link create property list */
+ if (H5P_DEFAULT == lcpl_id)
+ lcpl_id = H5P_LINK_CREATE_DEFAULT;
+
/* Verify access property list and get correct dxpl */
- if(H5P_verify_apl_and_dxpl(&lapl_id, H5P_CLS_LACC, &dxpl_id,
+ if (H5P_verify_apl_and_dxpl(&lapl_id, H5P_CLS_LACC, &dxpl_id,
((src_loc_id != H5L_SAME_LOC) ? src_loc_id : dst_loc_id),
TRUE) < 0)
HGOTO_ERROR(H5E_LINK, H5E_CANTSET, FAIL, "can't set access and transfer property lists")
- /* Set up src & dst location pointers */
- src_loc_p = &src_loc;
- dst_loc_p = &dst_loc;
- if(src_loc_id == H5L_SAME_LOC)
- src_loc_p = dst_loc_p;
- else if(dst_loc_id == H5L_SAME_LOC)
- dst_loc_p = src_loc_p;
+ /* 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.lapl_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.lapl_id = lapl_id;
+ loc_params2.obj_type = H5I_get_type(dst_loc_id);
- /* Move the link */
- if(H5L_move(src_loc_p, src_name, dst_loc_p, dst_name, FALSE, lcpl_id,
- lapl_id, dxpl_id) < 0)
- HGOTO_ERROR(H5E_LINK, H5E_CANTMOVE, FAIL, "unable to move link")
+ if (H5L_SAME_LOC != src_loc_id) {
+ /* Get the location object */
+ if (NULL == (obj1 = (H5VL_object_t *)H5I_object(src_loc_id)))
+ HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "invalid location identifier")
+ }
+ if (H5L_SAME_LOC != dst_loc_id) {
+ /* Get the location object */
+ if (NULL == (obj2 = (H5VL_object_t *)H5I_object(dst_loc_id)))
+ HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "invalid location identifier")
+ }
+
+ /* Make sure that the VOL plugins are the same */
+ if (obj1 && obj2) {
+ if (obj1->vol_info->vol_cls->value != obj2->vol_info->vol_cls->value)
+ 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 (H5VL_link_move((obj1 ? obj1->vol_obj : NULL), loc_params1,
+ (obj2 ? obj2->vol_obj : NULL), loc_params2,
+ (obj1 ? obj1->vol_info->vol_cls : obj2->vol_info->vol_cls),
+ lcpl_id, lapl_id, dxpl_id, H5_REQUEST_NULL) < 0)
+ HGOTO_ERROR(H5E_SYM, H5E_CANTINIT, FAIL, "unable to create link")
done:
FUNC_LEAVE_API(ret_value)
@@ -332,16 +355,13 @@ done:
/*-------------------------------------------------------------------------
- * Function: H5Lcopy
+ * Function: H5Lcopy
*
- * Purpose: Creates an identical copy of a link with the same creation
+ * Purpose: Creates an identical copy of a link with the same creation
* time and target. The new link can have a different name
* and be in a different location than the original.
*
- * Return: Non-negative on success/Negative on failure
- *
- * Programmer: James Laird
- * Wednesday, March 29, 2006
+ * Return: SUCCEED/FAIL
*
*-------------------------------------------------------------------------
*/
@@ -349,47 +369,72 @@ 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)
{
- H5G_loc_t src_loc, *src_loc_p;
- H5G_loc_t dst_loc, *dst_loc_p;
- hid_t dxpl_id = H5AC_ind_read_dxpl_id; /* dxpl used by library */
- herr_t ret_value=SUCCEED; /* Return value */
+ H5VL_object_t *obj1 = NULL; /* Object token of src_id */
+ H5VL_loc_params_t loc_params1;
+ H5VL_object_t *obj2 = NULL; /* Object token of dst_id */
+ H5VL_loc_params_t loc_params2;
+ hid_t dxpl_id = H5AC_ind_read_dxpl_id; /* dxpl used by library */
+ herr_t ret_value = SUCCEED; /* Return value */
FUNC_ENTER_API(FAIL)
H5TRACE6("e", "i*si*sii", src_loc_id, src_name, dst_loc_id, dst_name, lcpl_id,
lapl_id);
/* Check arguments */
- if(src_loc_id == H5L_SAME_LOC && dst_loc_id == H5L_SAME_LOC)
+ if (src_loc_id == H5L_SAME_LOC && dst_loc_id == H5L_SAME_LOC)
HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "source and destination should not both be H5L_SAME_LOC")
- 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(!src_name || !*src_name)
+ if (!src_name || !*src_name)
HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "no current name specified")
- if(!dst_name || !*dst_name)
+ if (!dst_name || !*dst_name)
HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "no destination name specified")
- if(lcpl_id != H5P_DEFAULT && (TRUE != H5P_isa_class(lcpl_id, H5P_LINK_CREATE)))
+ 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")
+ /* Check the link create property list */
+ if (H5P_DEFAULT == lcpl_id)
+ lcpl_id = H5P_LINK_CREATE_DEFAULT;
+
/* Verify access property list and get correct dxpl */
- if(H5P_verify_apl_and_dxpl(&lapl_id, H5P_CLS_LACC, &dxpl_id,
+ if (H5P_verify_apl_and_dxpl(&lapl_id, H5P_CLS_LACC, &dxpl_id,
((src_loc_id != H5L_SAME_LOC) ? src_loc_id : dst_loc_id),
TRUE) < 0)
HGOTO_ERROR(H5E_LINK, H5E_CANTSET, FAIL, "can't set access and transfer property lists")
- /* Set up src & dst location pointers */
- src_loc_p = &src_loc;
- dst_loc_p = &dst_loc;
- if(src_loc_id == H5L_SAME_LOC)
- src_loc_p = dst_loc_p;
- else if(dst_loc_id == H5L_SAME_LOC)
- dst_loc_p = src_loc_p;
+ /* 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.lapl_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.lapl_id = lapl_id;
+ loc_params2.obj_type = H5I_get_type(dst_loc_id);
- /* Copy the link */
- if(H5L_move(src_loc_p, src_name, dst_loc_p, dst_name, TRUE, lcpl_id,
- lapl_id, dxpl_id) < 0)
- HGOTO_ERROR(H5E_LINK, H5E_CANTMOVE, FAIL, "unable to move link")
+ if (H5L_SAME_LOC != src_loc_id) {
+ /* Get the location object */
+ if (NULL == (obj1 = (H5VL_object_t *)H5I_object(src_loc_id)))
+ HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "invalid location identifier")
+ }
+ if (H5L_SAME_LOC != dst_loc_id) {
+ /* Get the location object */
+ if (NULL == (obj2 = (H5VL_object_t *)H5I_object(dst_loc_id)))
+ HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "invalid location identifier")
+ }
+
+ /* Make sure that the VOL plugins are the same */
+ if (obj1 && obj2) {
+ if (obj1->vol_info->vol_cls->value != obj2->vol_info->vol_cls->value)
+ 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 (H5VL_link_copy((obj1 ? obj1->vol_obj : NULL), loc_params1,
+ (obj2 ? obj2->vol_obj : NULL), loc_params2,
+ (obj1 ? obj1->vol_info->vol_cls : obj2->vol_info->vol_cls),
+ lcpl_id, lapl_id, dxpl_id, H5_REQUEST_NULL) < 0)
+ HGOTO_ERROR(H5E_SYM, H5E_CANTINIT, FAIL, "unable to create link")
done:
FUNC_LEAVE_API(ret_value)
@@ -1842,7 +1887,7 @@ H5L_link_cb(H5G_loc_t *grp_loc/*in*/, const char *name, const H5O_link_t H5_ATTR
/* Set up location for user-defined callback */
if((grp = H5G_open(&temp_loc, udata->dxpl_id)) == NULL)
HGOTO_ERROR(H5E_SYM, H5E_CANTOPENOBJ, FAIL, "unable to open group")
- if((grp_id = H5I_register(H5I_GROUP, grp, TRUE)) < 0)
+ if((grp_id = H5VL_native_register(H5I_GROUP, grp, TRUE)) < 0)
HGOTO_ERROR(H5E_ATOM, H5E_CANTREGISTER, FAIL, "unable to register ID for group")
/* Make callback */
@@ -2553,7 +2598,7 @@ H5L_move_dest_cb(H5G_loc_t *grp_loc/*in*/, const char *name,
/* Set up location for user-defined callback */
if((grp = H5G_open(&temp_loc, udata->dxpl_id)) == NULL)
HGOTO_ERROR(H5E_SYM, H5E_CANTOPENOBJ, FAIL, "unable to open group")
- if((grp_id = H5I_register(H5I_GROUP, grp, TRUE)) < 0)
+ if((grp_id = H5VL_native_register(H5I_GROUP, grp, TRUE)) < 0)
HGOTO_ERROR(H5E_ATOM, H5E_CANTREGISTER, FAIL, "unable to register group ID")
if(udata->copy) {
diff --git a/src/H5O.c b/src/H5O.c
index d98be2f..525a115 100644
--- a/src/H5O.c
+++ b/src/H5O.c
@@ -75,9 +75,9 @@
/*-------------------------------------------------------------------------
- * Function: H5Oopen
+ * Function: H5Oopen
*
- * Purpose: Opens an object within an HDF5 file.
+ * Purpose: Opens an object within an HDF5 file.
*
* This function opens an object in the same way that H5Gopen2,
* H5Topen2, and H5Dopen2 do. However, H5Oopen doesn't require
@@ -88,38 +88,53 @@
* The opened object should be closed again with H5Oclose
* or H5Gclose, H5Tclose, or H5Dclose.
*
- * Return: Success: An open object identifier
- * Failure: Negative
+ * Return: Success: An open object identifier
*
- * Programmer: James Laird
- * July 14 2006
+ * Failure: H5I_INVALID_HID
*
*-------------------------------------------------------------------------
*/
hid_t
H5Oopen(hid_t loc_id, const char *name, hid_t lapl_id)
{
- H5G_loc_t loc;
- hid_t dxpl_id = H5AC_ind_read_dxpl_id; /* dxpl used by library */
- hid_t ret_value = FAIL;
-
- FUNC_ENTER_API(FAIL)
+ H5VL_object_t *obj = NULL; /* Object token of loc_id */
+ H5I_type_t opened_type;
+ void *opened_obj = NULL;
+ H5VL_loc_params_t loc_params;
+ hid_t dxpl_id = H5AC_ind_read_dxpl_id; /* dxpl used by library */
+ hid_t ret_value = H5I_INVALID_HID;
+
+ FUNC_ENTER_API(H5I_INVALID_HID)
H5TRACE3("i", "i*si", loc_id, name, lapl_id);
/* 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 (!name)
+ HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, H5I_INVALID_HID, "name parameter cannot be NULL")
+ if (!*name)
+ HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, H5I_INVALID_HID, "name parameter cannot be an empty string")
/* Verify access property list and get correct dxpl */
- if(H5P_verify_apl_and_dxpl(&lapl_id, H5P_CLS_LACC, &dxpl_id, loc_id, FALSE) < 0)
- HGOTO_ERROR(H5E_OHDR, H5E_CANTSET, FAIL, "can't set access and transfer property lists")
+ if (H5P_verify_apl_and_dxpl(&lapl_id, H5P_CLS_LACC, &dxpl_id, loc_id, FALSE) < 0)
+ HGOTO_ERROR(H5E_OHDR, H5E_CANTSET, H5I_INVALID_HID, "can't set access and transfer property lists")
- /* Open the object */
- if((ret_value = H5O_open_name(&loc, name, lapl_id, dxpl_id, TRUE)) < 0)
- HGOTO_ERROR(H5E_OHDR, H5E_CANTOPENOBJ, FAIL, "unable to open object")
+ /* Get the location object */
+ if (NULL == (obj = (H5VL_object_t *)H5I_object(loc_id)))
+ HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, H5I_INVALID_HID, "invalid location identifier")
+
+ /* Set location struct fields */
+ loc_params.type = H5VL_OBJECT_BY_NAME;
+ loc_params.loc_data.loc_by_name.name = name;
+ loc_params.loc_data.loc_by_name.lapl_id = lapl_id;
+ loc_params.obj_type = H5I_get_type(loc_id);
+
+ /* Open the object through the VOL */
+ if (NULL == (opened_obj = H5VL_object_open(obj->vol_obj, loc_params, obj->vol_info->vol_cls,
+ &opened_type, dxpl_id, H5_REQUEST_NULL)))
+ HGOTO_ERROR(H5E_OHDR, H5E_CANTOPENOBJ, H5I_INVALID_HID, "unable to open object")
+ /* Get an atom for the object */
+ if ((ret_value = H5VL_register_id(opened_type, opened_obj, obj->vol_info, TRUE)) < 0)
+ HGOTO_ERROR(H5E_ATOM, H5E_CANTREGISTER, H5I_INVALID_HID, "unable to atomize object handle")
done:
FUNC_LEAVE_API(ret_value)
} /* end H5Oopen() */
@@ -419,41 +434,50 @@ done:
/*-------------------------------------------------------------------------
- * Function: H5Oexists_by_name
- *
- * Purpose: Determine if a linked-to object exists
+ * Function: H5Oexists_by_name
*
- * Return: Success: TRUE/FALSE
- * Failure: Negative
+ * Purpose: Determine if a linked-to object exists
*
- * Programmer: Quincey Koziol
- * February 2 2010
+ * Return: Success: TRUE/FALSE
+ * Failure: -1
*
*-------------------------------------------------------------------------
*/
htri_t
H5Oexists_by_name(hid_t loc_id, const char *name, hid_t lapl_id)
{
- H5G_loc_t loc; /* Location info */
- hid_t dxpl_id = H5AC_ind_read_dxpl_id; /* dxpl used by library */
- htri_t ret_value = FAIL; /* Return value */
+ H5VL_object_t *obj = NULL; /* Object token of loc_id */
+ H5VL_loc_params_t loc_params;
+ hid_t dxpl_id = H5AC_ind_read_dxpl_id; /* dxpl used by library */
+ htri_t ret_value = -1; /* Return value */
- FUNC_ENTER_API(FAIL)
+ FUNC_ENTER_API((-1))
H5TRACE3("t", "i*si", loc_id, name, lapl_id);
/* 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 (!name)
+ HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, (-1), "name parameter cannot be NULL")
+ if (!*name)
+ HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, (-1), "name parameter cannot be an empty string")
/* Verify access property list and get correct dxpl */
- if(H5P_verify_apl_and_dxpl(&lapl_id, H5P_CLS_LACC, &dxpl_id, loc_id, FALSE) < 0)
- HGOTO_ERROR(H5E_OHDR, H5E_CANTSET, FAIL, "can't set access and transfer property lists")
+ if (H5P_verify_apl_and_dxpl(&lapl_id, H5P_CLS_LACC, &dxpl_id, loc_id, FALSE) < 0)
+ HGOTO_ERROR(H5E_OHDR, H5E_CANTSET, (-1), "can't set access and transfer property lists")
- /* Check if the object exists */
- if((ret_value = H5G_loc_exists(&loc, name, lapl_id, dxpl_id)) < 0)
- HGOTO_ERROR(H5E_OHDR, H5E_CANTGET, FAIL, "unable to determine if '%s' exists", name)
+ /* Get the location object */
+ if (NULL == (obj = H5VL_get_object(loc_id)))
+ HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, (-1), "invalid location identifier")
+
+ /* Set the location struct fields */
+ loc_params.type = H5VL_OBJECT_BY_NAME;
+ loc_params.loc_data.loc_by_name.name = name;
+ loc_params.loc_data.loc_by_name.lapl_id = lapl_id;
+ loc_params.obj_type = H5I_get_type(loc_id);
+
+ /* Check if the object exists via the VOL */
+ if (H5VL_object_specific(obj->vol_obj, loc_params, obj->vol_info->vol_cls, H5VL_OBJECT_EXISTS,
+ dxpl_id, H5_REQUEST_NULL, &ret_value) < 0)
+ HGOTO_ERROR(H5E_OHDR, H5E_CANTGET, (-1), "unable to determine if '%s' exists", name)
done:
FUNC_LEAVE_API(ret_value)
@@ -461,36 +485,40 @@ done:
/*-------------------------------------------------------------------------
- * Function: H5Oget_info
+ * Function: H5Oget_info
*
- * Purpose: Retrieve information about an object.
- *
- * Return: Success: Non-negative
- * Failure: Negative
+ * Purpose: Retrieve information about an object.
*
- * Programmer: Quincey Koziol
- * November 21 2006
+ * Return: SUCCEED/FAIL
*
*-------------------------------------------------------------------------
*/
herr_t
H5Oget_info(hid_t loc_id, H5O_info_t *oinfo)
{
- H5G_loc_t loc; /* Location of group */
- herr_t ret_value = SUCCEED; /* Return value */
+ H5VL_object_t *obj = NULL; /* Object token of loc_id */
+ H5VL_loc_params_t loc_params;
+ herr_t ret_value = SUCCEED; /* Return value */
FUNC_ENTER_API(FAIL)
H5TRACE2("e", "i*x", loc_id, oinfo);
/* Check args */
- if(H5G_loc(loc_id, &loc) < 0)
- HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a location")
- if(!oinfo)
- HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "no info struct")
+ if (!oinfo)
+ HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "oinfo parameter cannot be NULL")
- /* Retrieve the object's information */
- if(H5G_loc_info(&loc, ".", TRUE, oinfo/*out*/, H5P_LINK_ACCESS_DEFAULT, H5AC_ind_read_dxpl_id) < 0)
- HGOTO_ERROR(H5E_OHDR, H5E_NOTFOUND, FAIL, "object not found")
+ /* Set location struct fields */
+ loc_params.type = H5VL_OBJECT_BY_SELF;
+ loc_params.obj_type = H5I_get_type(loc_id);
+
+ /* Get the location object */
+ if (NULL == (obj = H5VL_get_object(loc_id)))
+ HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "invalid location identifier")
+
+ /* Get the group info through the VOL using the location token */
+ if (H5VL_object_optional(obj->vol_obj, obj->vol_info->vol_cls, H5AC_ind_read_dxpl_id,
+ H5_REQUEST_NULL, H5VL_OBJECT_GET_INFO, loc_params, oinfo) < 0)
+ HGOTO_ERROR(H5E_INTERNAL, H5E_CANTGET, FAIL, "unable to get group info")
done:
FUNC_LEAVE_API(ret_value)
@@ -498,22 +526,19 @@ done:
/*-------------------------------------------------------------------------
- * Function: H5Oget_info_by_name
+ * Function: H5Oget_info_by_name
*
- * Purpose: Retrieve information about an object.
+ * Purpose: Retrieve information about an object.
*
- * Return: Success: Non-negative
- * Failure: Negative
- *
- * Programmer: Quincey Koziol
- * November 21 2006
+ * Return: SUCCEED/FAIL
*
*-------------------------------------------------------------------------
*/
herr_t
H5Oget_info_by_name(hid_t loc_id, const char *name, H5O_info_t *oinfo, hid_t lapl_id)
{
- H5G_loc_t loc; /* Location of group */
+ H5VL_object_t *obj = NULL; /* object token of loc_id */
+ H5VL_loc_params_t loc_params;
hid_t dxpl_id = H5AC_ind_read_dxpl_id; /* dxpl used by library */
herr_t ret_value = SUCCEED; /* Return value */
@@ -521,20 +546,31 @@ H5Oget_info_by_name(hid_t loc_id, const char *name, H5O_info_t *oinfo, hid_t lap
H5TRACE4("e", "i*s*xi", loc_id, name, oinfo, lapl_id);
/* 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(!oinfo)
- HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "no info struct")
+ if (!name)
+ HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "name parameter cannot be NULL")
+ if (!*name)
+ HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "name parameter cannot be an empty string")
+ if (!oinfo)
+ HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "oinfo parameter cannot be NULL")
/* Verify access property list and get correct dxpl */
- if(H5P_verify_apl_and_dxpl(&lapl_id, H5P_CLS_LACC, &dxpl_id, loc_id, FALSE) < 0)
+ if (H5P_verify_apl_and_dxpl(&lapl_id, H5P_CLS_LACC, &dxpl_id, loc_id, FALSE) < 0)
HGOTO_ERROR(H5E_OHDR, H5E_CANTSET, FAIL, "can't set access and transfer property lists")
- /* Retrieve the object's information */
- if(H5G_loc_info(&loc, name, TRUE, oinfo/*out*/, lapl_id, dxpl_id) < 0)
- HGOTO_ERROR(H5E_OHDR, H5E_NOTFOUND, FAIL, "object not found")
+ /* Fill out location struct */
+ loc_params.type = H5VL_OBJECT_BY_NAME;
+ loc_params.loc_data.loc_by_name.name = name;
+ loc_params.loc_data.loc_by_name.lapl_id = lapl_id;
+ loc_params.obj_type = H5I_get_type(loc_id);
+
+ /* Get the location object */
+ if (NULL == (obj = H5VL_get_object(loc_id)))
+ HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "invalid location identifier")
+
+ /* Get the group info through the VOL using the location token */
+ if (H5VL_object_optional(obj->vol_obj, obj->vol_info->vol_cls, dxpl_id, H5_REQUEST_NULL,
+ H5VL_OBJECT_GET_INFO, loc_params, oinfo) < 0)
+ HGOTO_ERROR(H5E_INTERNAL, H5E_CANTGET, FAIL, "unable to get group info")
done:
FUNC_LEAVE_API(ret_value)
@@ -927,20 +963,16 @@ done:
/*-------------------------------------------------------------------------
- * Function: H5Oclose
+ * Function: H5Oclose
*
- * Purpose: Close an open file object.
+ * Purpose: Close an open file object.
*
* This is the companion to H5Oopen. It is used to close any
* open object in an HDF5 file (but not IDs are that not file
* objects, such as property lists and dataspaces). It has
* the same effect as calling H5Gclose, H5Dclose, or H5Tclose.
*
- * Return: Success: Non-negative
- * Failure: Negative
- *
- * Programmer: James Laird
- * July 14 2006
+ * Return: SUCCEED/FAIL
*
*-------------------------------------------------------------------------
*/
@@ -980,7 +1012,7 @@ H5Oclose(hid_t object_id)
default:
HGOTO_ERROR(H5E_ARGS, H5E_CANTRELEASE, FAIL, "not a valid file object ID (dataset, group, or datatype)")
break;
- } /* end switch */
+ }
done:
FUNC_LEAVE_API(ret_value)
diff --git a/src/H5Rint.c b/src/H5Rint.c
index 716a573..6855a36 100644
--- a/src/H5Rint.c
+++ b/src/H5Rint.c
@@ -750,7 +750,7 @@ 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)
+ if ((file_id = H5F_get_id(id, FALSE)) < 0)
HGOTO_ERROR(H5E_REFERENCE, H5E_CANTGET, FAIL, "can't retrieve file ID")
/* Get name, length, etc. */
diff --git a/src/H5Tcommit.c b/src/H5Tcommit.c
index ba5aacf..8f66ec0 100644
--- a/src/H5Tcommit.c
+++ b/src/H5Tcommit.c
@@ -36,6 +36,7 @@
#include "H5MMprivate.h" /* Memory Management */
#include "H5Pprivate.h" /* Property lists */
#include "H5Tpkg.h" /* Datatypes */
+#include "H5VLprivate.h" /* Virtual Object Layer */
/****************/
@@ -78,18 +79,21 @@ static H5T_t *H5T_open_oid(const H5G_loc_t *loc, hid_t dxpl_id);
/* Local Variables */
/*******************/
+/* Declare a free list to manage the H5VL_t struct */
+H5FL_EXTERN(H5VL_t);
+
+/* Declare a free list to manage the H5VL_object_t struct */
+H5FL_EXTERN(H5VL_object_t);
+
/*-------------------------------------------------------------------------
- * Function: H5Tcommit2
+ * Function: H5Tcommit2
*
- * Purpose: Save a transient datatype to a file and turn the type handle
- * into a "named", immutable type.
+ * Purpose: Save a transient datatype to a file and turn the type handle
+ * into a "named", immutable type.
*
- * Return: Non-negative on success/Negative on failure
- *
- * Programmer: Quincey Koziol
- * April 5, 2007
+ * Return: SUCCEED/FAIL
*
*-------------------------------------------------------------------------
*/
@@ -97,43 +101,68 @@ 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)
{
- H5G_loc_t loc; /* Location to create datatype */
- H5T_t *type; /* Datatype for ID */
- hid_t dxpl_id = H5AC_ind_read_dxpl_id; /* dxpl used by library */
- herr_t ret_value = SUCCEED; /* Return value */
+ void *dt = NULL; /* datatype object created by VOL plugin */
+ H5VL_object_t *new_obj = NULL; /* VOL object that holds the datatype object and the VOL info */
+ H5T_t *type = NULL; /* high level datatype object that wraps the VOL object */
+ H5VL_object_t *obj = NULL; /* object token of loc_id */
+ hid_t dxpl_id = H5AC_ind_read_dxpl_id; /* dxpl used by library */
+ H5VL_loc_params_t loc_params;
+ herr_t ret_value = SUCCEED; /* Return value */
FUNC_ENTER_API(FAIL)
H5TRACE6("e", "i*siiii", loc_id, name, type_id, lcpl_id, tcpl_id, tapl_id);
/* Check arguments */
- 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(NULL == (type = (H5T_t *)H5I_object_verify(type_id, H5I_DATATYPE)))
- HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a datatype")
+ if (!name)
+ HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "name parameter cannot be NULL")
+ if (!*name)
+ HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "name parameter cannot be an empty string")
+ if (NULL == (type = (H5T_t *)H5I_object_verify(type_id, H5I_DATATYPE)))
+ HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a datatype")
+ if (H5T_is_named(type))
+ HGOTO_ERROR(H5E_ARGS, H5E_CANTSET, FAIL, "datatype is already committed")
/* Get correct property list */
- if(H5P_DEFAULT == lcpl_id)
+ if (H5P_DEFAULT == lcpl_id)
lcpl_id = H5P_LINK_CREATE_DEFAULT;
else
- if(TRUE != H5P_isa_class(lcpl_id, H5P_LINK_CREATE))
+ if (TRUE != H5P_isa_class(lcpl_id, H5P_LINK_CREATE))
HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not link creation property list")
/* Get correct property list */
- if(H5P_DEFAULT == tcpl_id)
+ if (H5P_DEFAULT == tcpl_id)
tcpl_id = H5P_DATATYPE_CREATE_DEFAULT;
else
- if(TRUE != H5P_isa_class(tcpl_id, H5P_DATATYPE_CREATE))
+ if (TRUE != H5P_isa_class(tcpl_id, H5P_DATATYPE_CREATE))
HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not datatype creation property list")
/* Verify access property list and get correct dxpl */
- if(H5P_verify_apl_and_dxpl(&tapl_id, H5P_CLS_TACC, &dxpl_id, loc_id, TRUE) < 0)
+ if (H5P_verify_apl_and_dxpl(&tapl_id, H5P_CLS_TACC, &dxpl_id, loc_id, TRUE) < 0)
HGOTO_ERROR(H5E_DATATYPE, H5E_CANTSET, FAIL, "can't set access and transfer property lists")
- /* Commit the type */
- if(H5T__commit_named(&loc, name, type, lcpl_id, tcpl_id, tapl_id, dxpl_id) < 0)
- HGOTO_ERROR(H5E_DATATYPE, H5E_CANTINIT, FAIL, "unable to commit datatype")
+ /* Fill in location struct fields */
+ loc_params.type = H5VL_OBJECT_BY_SELF;
+ loc_params.obj_type = H5I_get_type(loc_id);
+
+ /* Get the object from the loc_id */
+ if (NULL == (obj = (H5VL_object_t *)H5I_object(loc_id)))
+ HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "invalid object identifier")
+
+ /* Commit the datatype through the VOL */
+ if (NULL == (dt = H5VL_datatype_commit(obj->vol_obj, loc_params, obj->vol_info->vol_cls,
+ name, type_id, lcpl_id, tcpl_id, tapl_id,
+ dxpl_id, H5_REQUEST_NULL)))
+ HGOTO_ERROR(H5E_SYM, H5E_CANTINIT, FAIL, "unable to commit datatype")
+
+ /* setup VOL object */
+ if (NULL == (new_obj = H5FL_CALLOC(H5VL_object_t)))
+ HGOTO_ERROR(H5E_VOL, H5E_NOSPACE, FAIL, "can't allocate top object structure")
+ new_obj->vol_info = obj->vol_info;
+ new_obj->vol_info->nrefs ++;
+ new_obj->vol_obj = dt;
+
+ /* set the committed type object to the VOL driver pointer in the H5T_t struct */
+ type->vol_obj = new_obj;
done:
FUNC_LEAVE_API(ret_value)
@@ -506,150 +535,118 @@ done:
/*-------------------------------------------------------------------------
- * Function: H5Topen2
+ * Function: H5Topen2
*
- * Purpose: Opens a named datatype using a Datatype Access Property
+ * Purpose: Opens a named datatype using a Datatype Access Property
* List.
*
- * Return: Success: Object ID of the named datatype.
- * Failure: Negative
+ * Return: Success: Object ID of the named datatype
*
- * Programmer: James Laird
- * Thursday July 27, 2006
+ * Failure: H5I_INVALID_HID
*
*-------------------------------------------------------------------------
*/
hid_t
H5Topen2(hid_t loc_id, const char *name, hid_t tapl_id)
{
- 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_ind_read_dxpl_id; /* dxpl to use to open datatype */
- hid_t ret_value = FAIL; /* Return value */
+ void *vol_dt = NULL; /* datatype token created by VOL plugin */
+ H5VL_object_t *obj = NULL; /* object token of loc_id */
+ H5VL_loc_params_t loc_params;
+ hid_t dxpl_id = H5AC_ind_read_dxpl_id; /* dxpl used by library */
+ hid_t ret_value = H5I_INVALID_HID; /* Return value */
- FUNC_ENTER_API(FAIL)
+ FUNC_ENTER_API(H5I_INVALID_HID)
H5TRACE3("i", "i*si", loc_id, name, tapl_id);
/* 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 (!name)
+ HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, H5I_INVALID_HID, "name parameter cannot be NULL")
+ if (!*name)
+ HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, H5I_INVALID_HID, "name parameter cannot be an empty string")
/* Verify access property list and get correct dxpl */
- if(H5P_verify_apl_and_dxpl(&tapl_id, H5P_CLS_TACC, &dxpl_id, loc_id, FALSE) < 0)
- HGOTO_ERROR(H5E_DATATYPE, H5E_CANTSET, FAIL, "can't set access and transfer property lists")
+ if (H5P_verify_apl_and_dxpl(&tapl_id, H5P_CLS_TACC, &dxpl_id, loc_id, FALSE) < 0)
+ HGOTO_ERROR(H5E_DATATYPE, H5E_CANTSET, H5I_INVALID_HID, "can't set access and transfer property lists")
- /* Set up datatype location to fill in */
- type_loc.oloc = &oloc;
- type_loc.path = &path;
- H5G_loc_reset(&type_loc);
+ /* Fill in location struct fields */
+ loc_params.type = H5VL_OBJECT_BY_SELF;
+ loc_params.obj_type = H5I_get_type(loc_id);
- /*
- * 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, FAIL, "not found")
- obj_found = TRUE;
+ /* get the location object */
+ if (NULL == (obj = (H5VL_object_t *)H5I_object(loc_id)))
+ HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, H5I_INVALID_HID, "invalid file identifier")
- /* 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, FAIL, "can't get object type")
- if(obj_type != H5O_TYPE_NAMED_DATATYPE)
- HGOTO_ERROR(H5E_DATATYPE, H5E_BADTYPE, FAIL, "not a named datatype")
+ /* Create the datatype through the VOL */
+ if (NULL == (vol_dt = H5VL_datatype_open(obj->vol_obj, loc_params, obj->vol_info->vol_cls,
+ name, tapl_id, dxpl_id, H5_REQUEST_NULL)))
+ HGOTO_ERROR(H5E_SYM, H5E_CANTOPENOBJ, H5I_INVALID_HID, "unable to open datatype")
- /* Open it */
- 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")
+ /* Get an atom for the datatype */
+ if ((ret_value = H5VL_register_id(H5I_DATATYPE, vol_dt, obj->vol_info, TRUE)) < 0)
+ HGOTO_ERROR(H5E_ATOM, H5E_CANTREGISTER, H5I_INVALID_HID, "unable to atomize datatype handle")
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 */
-
+ if (H5I_INVALID_HID == ret_value)
+ if (vol_dt && H5VL_datatype_close (vol_dt, obj->vol_info->vol_cls, dxpl_id, H5_REQUEST_NULL) < 0)
+ HDONE_ERROR(H5E_SYM, H5E_CLOSEERROR, H5I_INVALID_HID, "unable to release datatype")
FUNC_LEAVE_API(ret_value)
} /* end H5Topen2() */
/*-------------------------------------------------------------------------
- * Function: H5Tget_create_plist
+ * Function: H5Tget_create_plist
*
- * Purpose: Returns a copy of the datatype creation property list.
+ * Purpose: Returns a copy of the datatype creation property list.
*
- * Return: Success: ID for a copy of the datatype creation
- * property list. The property list ID should be
- * released by calling H5Pclose().
+ * Return: Success: ID for a copy of the datatype creation
+ * property list. The property list ID should be
+ * released by calling H5Pclose().
*
- * Failure: FAIL
- *
- * Programmer: Quincey Koziol
- * Tuesday, November 28, 2006
+ * Failure: H5I_INVALID_HID
*
*-------------------------------------------------------------------------
*/
hid_t
H5Tget_create_plist(hid_t dtype_id)
{
- H5T_t *type; /* Datatype object for ID */
- H5P_genplist_t *tcpl_plist; /* Existing datatype creation propertty list */
- hid_t new_tcpl_id = FAIL; /* New datatype creation property list */
- herr_t status; /* Generic status value */
- hid_t ret_value; /* Return value */
+ H5T_t *type = NULL; /* Datatype object for ID */
+ H5P_genplist_t *tcpl_plist = NULL; /* Existing datatype creation propertty list */
+ htri_t status; /* Generic status value */
+ hid_t ret_value = H5I_INVALID_HID; /* Return value */
- FUNC_ENTER_API(FAIL)
+ FUNC_ENTER_API(H5I_INVALID_HID)
H5TRACE1("i", "i", dtype_id);
/* Check arguments */
- if(NULL == (type = (H5T_t *)H5I_object_verify(dtype_id, H5I_DATATYPE)))
- HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a datatype")
-
- /* Copy the default datatype creation property list */
- if(NULL == (tcpl_plist = (H5P_genplist_t *)H5I_object(H5P_LST_DATATYPE_CREATE_ID_g)))
- HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "can't get default creation property list")
- if((new_tcpl_id = H5P_copy_plist(tcpl_plist, TRUE)) < 0)
- HGOTO_ERROR(H5E_DATATYPE, H5E_CANTGET, FAIL, "unable to copy the creation property list")
+ if (NULL == (type = (H5T_t *)H5I_object_verify(dtype_id, H5I_DATATYPE)))
+ HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, H5I_INVALID_HID, "not a datatype")
/* Check if the datatype is committed */
- if((status = H5T_committed(type)) < 0)
- HGOTO_ERROR(H5E_DATATYPE, H5E_CANTGET, FAIL, "can't check whether datatype is committed")
-
- /* Retrieve further information, if the datatype is committed */
- if(status > 0) {
- H5P_genplist_t *new_plist; /* New datatype creation property list */
-
- /* Get property list object for new TCPL */
- if(NULL == (new_plist = (H5P_genplist_t *)H5I_object(new_tcpl_id)))
- HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "can't get property list")
-
- /* Retrieve any object creation properties */
- if(H5O_get_create_plist(&type->oloc, H5AC_ind_read_dxpl_id, new_plist) < 0)
- HGOTO_ERROR(H5E_DATATYPE, H5E_CANTGET, FAIL, "can't get object creation info")
- } /* end if */
+ if ((status = H5T_is_named(type)) < 0)
+ HGOTO_ERROR(H5E_DATATYPE, H5E_CANTGET, H5I_INVALID_HID, "can't check whether datatype is committed")
+
+ /* If the datatype is not committed, just copy the default
+ creation property list and return that. */
+ if (FALSE == status) {
+ /* Copy the default datatype creation property list */
+ if (NULL == (tcpl_plist = (H5P_genplist_t *)H5I_object(H5P_LST_DATATYPE_CREATE_ID_g)))
+ HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, H5I_INVALID_HID, "can't get default creation property list")
+ if ((ret_value = H5P_copy_plist(tcpl_plist, TRUE)) < 0)
+ HGOTO_ERROR(H5E_DATATYPE, H5E_CANTGET, H5I_INVALID_HID, "unable to copy the creation property list")
+ }
+ /* If the datatype is committed, let the VOL create the creation
+ * property list ID.
+ */
+ else if (TRUE == status) {
+ H5VL_object_t *vol_dt = type->vol_obj;
- /* Set the return value */
- ret_value = new_tcpl_id;
+ /* get the rest of the plist through the VOL */
+ if (H5VL_datatype_get(vol_dt->vol_obj, vol_dt->vol_info->vol_cls, H5VL_DATATYPE_GET_TCPL,
+ H5AC_ind_read_dxpl_id, H5_REQUEST_NULL, &ret_value) < 0)
+ HGOTO_ERROR(H5E_INTERNAL, H5E_CANTGET, H5I_INVALID_HID, "unable to get datatype")
+ }
done:
- if(ret_value < 0)
- if(new_tcpl_id > 0)
- if(H5I_dec_app_ref(new_tcpl_id) < 0)
- HDONE_ERROR(H5E_DATATYPE, H5E_CANTDEC, FAIL, "unable to close temporary object")
-
FUNC_LEAVE_API(ret_value)
} /* end H5Tget_create_plist() */
diff --git a/src/H5VLnative.c b/src/H5VLnative.c
index e8b2725..d83d32e 100644
--- a/src/H5VLnative.c
+++ b/src/H5VLnative.c
@@ -1601,7 +1601,7 @@ H5VL_native_file_get(void *obj, H5VL_file_get_t get_type, hid_t H5_ATTR_UNUSED d
*ret = (ssize_t)len;
break;
}
- /* H5I_get_file_id */
+ /* H5Iget_file_id */
case H5VL_OBJECT_GET_FILE:
{
H5I_type_t type = va_arg(arguments, H5I_type_t);
diff --git a/src/H5Z.c b/src/H5Z.c
index 6f173b2..901e65b 100644
--- a/src/H5Z.c
+++ b/src/H5Z.c
@@ -335,12 +335,12 @@ done:
/*-------------------------------------------------------------------------
- * Function: H5Zunregister
+ * Function: H5Zunregister
*
- * Purpose: This function unregisters a filter.
+ * Purpose: This function unregisters a filter.
+ *
+ * Return: SUCCEED/FAIL
*
- * Return: Non-negative on success
- * Negative on failure
*-------------------------------------------------------------------------
*/
herr_t
@@ -367,13 +367,13 @@ done:
/*-------------------------------------------------------------------------
- * Function: H5Z_unregister
+ * Function: H5Z_unregister
*
- * Purpose: Same as the public version except this one allows filters
- * to be unset for predefined method numbers <H5Z_FILTER_RESERVED
+ * Purpose: Same as the public version except this one allows filters
+ * to be unset for predefined method numbers <H5Z_FILTER_RESERVED
+ *
+ * Return: SUCCEED/FAIL
*
- * Return: Non-negative on success
- * Negative on failure
*-------------------------------------------------------------------------
*/
herr_t
@@ -432,12 +432,14 @@ done:
/*-------------------------------------------------------------------------
- * Function: H5Z__check_unregister
+ * Function: H5Z__check_unregister
*
- * Purpose: Check if an object uses the filter to be unregistered.
+ * Purpose: Check if an object uses the filter to be unregistered.
+ *
+ * Return: TRUE if the object uses the filter
+ * FALSE if not
+ * NEGATIVE on error
*
- * Return: TRUE if the object uses the filter.
- * FALSE if not, NEGATIVE on error.
*-------------------------------------------------------------------------
*/
static htri_t
@@ -462,15 +464,17 @@ done:
/*-------------------------------------------------------------------------
- * Function: H5Z__check_unregister_group_cb
+ * Function: H5Z__check_unregister_group_cb
+ *
+ * Purpose: The callback function for H5Z_unregister. It iterates
+ * through all opened objects. If the object is a dataset
+ * or a group and it uses the filter to be unregistered, the
+ * function returns TRUE.
*
- * Purpose: The callback function for H5Z_unregister. It iterates
- * through all opened objects. If the object is a dataset
- * or a group and it uses the filter to be unregistered, the
- * function returns TRUE.
+ * Return: TRUE if the object uses the filter
+ * FALSE if not
+ * NEGATIVE on error
*
- * Return: TRUE if the object uses the filter.
- * FALSE otherwise.
*-------------------------------------------------------------------------
*/
static int
@@ -499,7 +503,7 @@ H5Z__check_unregister_group_cb(void *obj_ptr, hid_t H5_ATTR_UNUSED obj_id, void
if (filter_in_pline) {
object->found = TRUE;
ret_value = TRUE;
- } /* end if */
+ }
done:
if (ocpl_id > 0)
@@ -511,15 +515,17 @@ done:
/*-------------------------------------------------------------------------
- * Function: H5Z__check_unregister_dset_cb
+ * Function: H5Z__check_unregister_dset_cb
*
- * Purpose: The callback function for H5Z_unregister. It iterates
- * through all opened objects. If the object is a dataset
- * or a group and it uses the filter to be unregistered, the
- * function returns TRUE.
+ * Purpose: The callback function for H5Z_unregister. It iterates
+ * through all opened objects. If the object is a dataset
+ * or a group and it uses the filter to be unregistered, the
+ * function returns TRUE.
+ *
+ * Return: TRUE if the object uses the filter
+ * FALSE if not
+ * NEGATIVE on error
*
- * Return: TRUE if the object uses the filter.
- * FALSE otherwise.
*-------------------------------------------------------------------------
*/
static int
@@ -548,7 +554,7 @@ H5Z__check_unregister_dset_cb(void *obj_ptr, hid_t H5_ATTR_UNUSED obj_id, void *
if (filter_in_pline) {
object->found = TRUE;
ret_value = TRUE;
- } /* end if */
+ }
done:
if (ocpl_id > 0)
@@ -560,13 +566,13 @@ done:
/*-------------------------------------------------------------------------
- * Function: H5Z__flush_file_cb
+ * Function: H5Z__flush_file_cb
*
- * Purpose: The callback function for H5Z_unregister. It iterates
- * through all opened files and flush them.
+ * Purpose: The callback function for H5Z_unregister. It iterates
+ * through all opened files and flush them.
*
- * Return: FALSE if finishes flushing and moves on
- * FAIL if there is an error
+ * Return: FALSE if finishes flushing and moves on
+ * NEGATIVE if there is an error
*-------------------------------------------------------------------------
*/
static int
@@ -579,11 +585,12 @@ H5Z__flush_file_cb(void *obj_ptr, hid_t H5_ATTR_UNUSED obj_id, void H5_ATTR_UNUS
HDassert(obj_ptr);
/* Call the flush routine for mounted file hierarchies. Do a global flush
- * if the file is opened for write */
+ * if the file is opened for write.
+ */
if (H5F_ACC_RDWR & H5F_INTENT((H5F_t *)obj_ptr)) {
if (H5F_flush_mounts((H5F_t *)obj_ptr, H5AC_ind_read_dxpl_id, H5AC_rawdata_dxpl_id) < 0)
HGOTO_ERROR(H5E_PLINE, H5E_CANTFLUSH, FAIL, "unable to flush file hierarchy")
- } /* end if */
+ }
done:
FUNC_LEAVE_NOAPI(ret_value)
diff --git a/test/fillval.c b/test/fillval.c
index 8c8e902..f0182c2 100644
--- a/test/fillval.c
+++ b/test/fillval.c
@@ -762,15 +762,17 @@ test_rdwr_cases(hid_t file, hid_t dcpl, const char *dname, void *_fillval,
comp_datatype *buf_c=NULL;
H5D_space_status_t allocation;
- if(datatype==H5T_INTEGER)
+ if(datatype==H5T_INTEGER) {
fillval = *(int*)_fillval;
+ }
else if(datatype==H5T_COMPOUND) {
- fill_c.a=((comp_datatype*)_fillval)->a;
+ fill_c.a=((comp_datatype*)_fillval)->a;
fill_c.x=((comp_datatype*)_fillval)->x;
fill_c.y=((comp_datatype*)_fillval)->y;
fill_c.z=((comp_datatype*)_fillval)->z;
- } else {
- puts("Invalid type for test");
+ }
+ else {
+ HDputs("Invalid type for test");
goto error;
}
@@ -806,7 +808,8 @@ test_rdwr_cases(hid_t file, hid_t dcpl, const char *dname, void *_fillval,
goto error;
}
/* case for compound datatype */
- } else if(datatype==H5T_COMPOUND) {
+ }
+ else if(datatype==H5T_COMPOUND) {
if(H5Dread(dset2, ctype_id, mspace, fspace, H5P_DEFAULT,
&rd_c) < 0) goto error;
if(fill_time != H5D_FILL_TIME_NEVER && (!H5_FLT_ABS_EQUAL(rd_c.a, fill_c.a) ||
@@ -828,10 +831,10 @@ test_rdwr_cases(hid_t file, hid_t dcpl, const char *dname, void *_fillval,
/* Select all odd data locations in the file dataset */
for (i=0, nelmts=1; i<5; i++) {
- hs_size[i] = cur_size[i]/2;
- hs_offset[i] = 0;
- hs_stride[i] = 2;
- nelmts *= hs_size[i];
+ hs_size[i] = cur_size[i]/2;
+ hs_offset[i] = 0;
+ hs_stride[i] = 2;
+ nelmts *= hs_size[i];
}
if((mspace=H5Screate_simple(5, hs_size, hs_size)) < 0) goto error;
if(H5Sselect_hyperslab(fspace, H5S_SELECT_SET, hs_offset, hs_stride,
@@ -1092,14 +1095,20 @@ test_rdwr(hid_t fapl, const char *base_name, H5D_layout_t layout)
if((file=H5Fcreate(filename, H5F_ACC_TRUNC, H5P_DEFAULT, fapl)) < 0)
goto error;
- if((dcpl=H5Pcreate(H5P_DATASET_CREATE)) < 0) goto error;
+ if((dcpl=H5Pcreate(H5P_DATASET_CREATE)) < 0)
+ goto error;
+
if(H5D_CHUNKED==layout) {
- if(H5Pset_chunk(dcpl, 5, ch_size) < 0) goto error;
- } else if(H5D_COMPACT==layout) {
- if(H5Pset_layout(dcpl, H5D_COMPACT) < 0) goto error;
+ if(H5Pset_chunk(dcpl, 5, ch_size) < 0)
+ goto error;
+ }
+ else if(H5D_COMPACT==layout) {
+ if(H5Pset_layout(dcpl, H5D_COMPACT) < 0)
+ goto error;
}
- if((ctype_id=create_compound_type()) < 0) goto error;
+ if((ctype_id=create_compound_type()) < 0)
+ goto error;
/* I. Test H5D_ALLOC_TIME_LATE space allocation cases */
if(H5D_COMPACT != layout) {
@@ -2359,8 +2368,6 @@ test_partalloc(hid_t fapl, const char *base_name)
* Programmer: Robb Matzke
* Thursday, October 1, 1998
*
- * Modifications:
- *
*-------------------------------------------------------------------------
*/
int
@@ -2380,8 +2387,8 @@ main(int argc, char *argv[])
else if(!strcmp(argv[argno], "compact"))
test_compact =1;
else {
- fprintf(stderr, "usage: %s [contiguous] [chunked] [compact]\n", argv[0]);
- exit(EXIT_FAILURE);
+ HDfprintf(stderr, "usage: %s [contiguous] [chunked] [compact]\n", argv[0]);
+ HDexit(EXIT_FAILURE);
}
} /* end for */
} /* end if */
@@ -2444,15 +2451,15 @@ main(int argc, char *argv[])
if(nerrors)
goto error;
- puts("All fill value tests passed.");
+ HDputs("All fill value tests passed.");
if(h5_cleanup(FILENAME, fapl))
HDremove(FILE_NAME_RAW);
- return 0;
+ HDexit(EXIT_SUCCESS);
error:
- puts("***** FILL VALUE TESTS FAILED *****");
- return 1;
+ HDputs("***** FILL VALUE TESTS FAILED *****");
+ HDexit(EXIT_FAILURE);
}
diff --git a/test/unregister.c b/test/unregister.c
index a4bf24e..52f8a28 100644
--- a/test/unregister.c
+++ b/test/unregister.c
@@ -23,8 +23,8 @@ const char *FILENAME[] = {
NULL
};
-#define GROUP_NAME "group"
-#define DSET_NAME "dataset"
+#define GROUP_NAME "test_group"
+#define DSET_NAME "test_dataset"
#define FILENAME_BUF_SIZE 1024
#define DSET_DIM1 100
#define DSET_DIM2 200
@@ -34,39 +34,34 @@ const char *FILENAME[] = {
#define H5Z_FILTER_DUMMY 312
-static size_t filter_dummy(unsigned int flags, size_t cd_nelmts,
+static size_t do_nothing(unsigned int flags, size_t cd_nelmts,
const unsigned int *cd_values, size_t nbytes, size_t *buf_size, void **buf);
/* Dummy filter for test_unregister_filters only */
const H5Z_class2_t H5Z_DUMMY[1] = {{
- H5Z_CLASS_T_VERS, /* H5Z_class_t version */
- H5Z_FILTER_DUMMY, /* Filter id number */
- 1, 1, /* Encoding and decoding enabled */
- "dummy", /* Filter name for debugging */
- NULL, /* The "can apply" callback */
- NULL, /* The "set local" callback */
- filter_dummy, /* The actual filter function */
+ H5Z_CLASS_T_VERS, /* H5Z_class_t version */
+ H5Z_FILTER_DUMMY, /* Filter ID number */
+ 1, 1, /* Encoding and decoding enabled */
+ "dummy", /* Filter name for debugging */
+ NULL, /* The "can apply" callback */
+ NULL, /* The "set local" callback */
+ do_nothing, /* The actual filter function */
}};
/*-------------------------------------------------------------------------
- * Function: filter_dummy
+ * Function: do_nothing
*
- * Purpose: A dummy compression method that doesn't do anything. This
- * filter is only for test_unregister_filters. Please don't
+ * Purpose: A dummy compression method that doesn't do anything. This
+ * filter is only for test_unregister_filters. Please don't
* use it for other tests because it may mess up this test.
*
- * Return: Success: Data chunk size
- *
- * Failure: 0
- *
- * Programmer: Raymond Lu
- * April 24, 2013
+ * Return: Data chunk size
*
*-------------------------------------------------------------------------
*/
static size_t
-filter_dummy(unsigned int H5_ATTR_UNUSED flags, size_t H5_ATTR_UNUSED cd_nelmts,
+do_nothing(unsigned int H5_ATTR_UNUSED flags, size_t H5_ATTR_UNUSED cd_nelmts,
const unsigned int H5_ATTR_UNUSED *cd_values, size_t nbytes,
size_t H5_ATTR_UNUSED *buf_size, void H5_ATTR_UNUSED **buf)
{
@@ -74,181 +69,220 @@ filter_dummy(unsigned int H5_ATTR_UNUSED flags, size_t H5_ATTR_UNUSED cd_nelmts,
}
/*-------------------------------------------------------------------------
- * Function: test_unregister_filters
+ * Function: test_unregister_filters
*
- * Purpose: Tests unregistering filter before closing the file
+ * Purpose: Tests unregistering filter before closing the file
*
- * Return: Success: 0
- * Failure: -1
- *
- * Programmer: Raymond Lu
- * 11 April 2013
+ * Return: SUCCEED/FAIL
*
*-------------------------------------------------------------------------
*/
static herr_t
-test_unregister_filters(hid_t my_fapl)
+test_unregister_filters(hid_t fapl_id)
{
- hid_t file1, file2;
- hid_t dc;
- hid_t gcpl, gid, group;
- hid_t dataset, space;
- int i, j, n;
- char gname[256];
+ hid_t fid1 = H5I_INVALID_HID;
+ hid_t fid2 = H5I_INVALID_HID;
+ hid_t dcpl_id = H5I_INVALID_HID;
+ hid_t gcpl_id = H5I_INVALID_HID;
+ hid_t gid = H5I_INVALID_HID;
+ hid_t gid_loop = H5I_INVALID_HID;
+ hid_t did = H5I_INVALID_HID;
+ hid_t sid = H5I_INVALID_HID;
+ int i, j, n;
+ char group_name[32];
char filename[FILENAME_BUF_SIZE];
- const hsize_t chunk_size[2] = {FILTER_CHUNK_DIM1, FILTER_CHUNK_DIM2}; /* Chunk dimensions */
- hsize_t dims[2];
- int points[DSET_DIM1][DSET_DIM2];
+ const hsize_t chunk_dims[2] = {FILTER_CHUNK_DIM1, FILTER_CHUNK_DIM2}; /* Chunk dimensions */
+ hsize_t dims[2];
+ int data[DSET_DIM1][DSET_DIM2];
herr_t ret;
TESTING("Unregistering filter");
/* Create first file */
- h5_fixname(FILENAME[0], my_fapl, filename, sizeof filename);
- if((file1 = H5Fcreate(filename, H5F_ACC_TRUNC, H5P_DEFAULT, my_fapl)) < 0) goto error;
+ h5_fixname(FILENAME[0], fapl_id, filename, sizeof(filename));
+ if ((fid1 = H5Fcreate(filename, H5F_ACC_TRUNC, H5P_DEFAULT, fapl_id)) < 0)
+ goto error;
/* Create second file */
- h5_fixname(FILENAME[1], my_fapl, filename, sizeof filename);
- if((file2 = H5Fcreate(filename, H5F_ACC_TRUNC, H5P_DEFAULT, my_fapl)) < 0) goto error;
+ h5_fixname(FILENAME[1], fapl_id, filename, sizeof(filename));
+ if ((fid2 = H5Fcreate(filename, H5F_ACC_TRUNC, H5P_DEFAULT, fapl_id)) < 0)
+ goto error;
/* Register DUMMY filter */
- if(H5Zregister(H5Z_DUMMY) < 0) goto error;
-
- if(H5Zfilter_avail(H5Z_FILTER_DUMMY)!=TRUE) goto error;
+ if (H5Zregister(H5Z_DUMMY) < 0)
+ goto error;
+ if (H5Zfilter_avail(H5Z_FILTER_DUMMY) != TRUE)
+ goto error;
+
+ /*******************
+ * PART 1 - GROUPS *
+ *******************/
- if((gcpl = H5Pcreate(H5P_GROUP_CREATE)) < 0) goto error;
-
/* Use DUMMY filter for creating groups */
- if(H5Pset_filter (gcpl, H5Z_FILTER_DUMMY, H5Z_FLAG_MANDATORY, (size_t)0, NULL) < 0) goto error;
+ if ((gcpl_id = H5Pcreate(H5P_GROUP_CREATE)) < 0)
+ goto error;
+ if (H5Pset_filter(gcpl_id, H5Z_FILTER_DUMMY, H5Z_FLAG_MANDATORY, (size_t)0, NULL) < 0)
+ goto error;
/* Create a group using this filter */
- if((gid = H5Gcreate2(file1, GROUP_NAME, H5P_DEFAULT, gcpl, H5P_DEFAULT)) < 0) goto error;
+ if ((gid = H5Gcreate2(fid1, GROUP_NAME, H5P_DEFAULT, gcpl_id, H5P_DEFAULT)) < 0)
+ goto error;
/* Create multiple groups under the main group */
- for (i=0; i < GROUP_ITERATION; i++) {
- sprintf(gname, "group_%d", i);
- if((group = H5Gcreate2(gid, gname, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0) goto error;
- if(H5Gclose(group) < 0) goto error;
+ for (i = 0; i < GROUP_ITERATION; i++) {
+ HDsprintf(group_name, "group_%d", i);
+ if ((gid_loop = H5Gcreate2(gid, group_name, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0)
+ goto error;
+ if (H5Gclose(gid_loop) < 0)
+ goto error;
}
- if(H5Fflush(file1, H5F_SCOPE_GLOBAL) < 0) goto error;
+ /* Flush the file containing the groups */
+ if (H5Fflush(fid1, H5F_SCOPE_GLOBAL) < 0)
+ goto error;
/* Unregister the filter before closing the group. It should fail */
H5E_BEGIN_TRY {
ret = H5Zunregister(H5Z_FILTER_DUMMY);
} H5E_END_TRY;
- if(ret>=0) {
+ if (ret >= 0) {
H5_FAILED();
- printf(" Line %d: Should not be able to unregister filter\n", __LINE__);
+ HDprintf(" Line %d: Should not be able to unregister filter\n", __LINE__);
goto error;
- } /* end if */
+ }
/* Close the group */
- if(H5Gclose(gid) < 0) goto error;
+ if (H5Gclose(gid) < 0)
+ goto error;
/* Clean up objects used for this test */
- if(H5Pclose (gcpl) < 0) goto error;
+ if (H5Pclose (gcpl_id) < 0)
+ goto error;
- if((dc = H5Pcreate(H5P_DATASET_CREATE)) < 0) goto error;
- if(H5Pset_chunk (dc, 2, chunk_size) < 0) goto error;
+ /*********************
+ * PART 2 - DATASETS *
+ *********************/
- if(H5Pset_filter(dc, H5Z_FILTER_DUMMY, 0, (size_t)0, NULL) < 0) goto error;
+ /* Use DUMMY filter for creating datasets */
+ if ((dcpl_id = H5Pcreate(H5P_DATASET_CREATE)) < 0)
+ goto error;
+ if (H5Pset_chunk(dcpl_id, 2, chunk_dims) < 0)
+ goto error;
+ if(H5Pset_filter(dcpl_id, H5Z_FILTER_DUMMY, 0, (size_t)0, NULL) < 0)
+ goto error;
- /* Initialize the dataset */
- for(i = n = 0; i < DSET_DIM1; i++)
- for(j = 0; j < DSET_DIM2; j++)
- points[i][j] = n++;
+ /* Initialize the data for writing */
+ for (i = n = 0; i < DSET_DIM1; i++)
+ for (j = 0; j < DSET_DIM2; j++)
+ data[i][j] = n++;
- /* Create the data space */
+ /* Create the dataspace */
dims[0] = DSET_DIM1;
dims[1] = DSET_DIM2;
- if((space = H5Screate_simple(2, dims, NULL)) < 0) goto error;
+ if ((sid = H5Screate_simple(2, dims, NULL)) < 0)
+ goto error;
/* Create a dataset in the first file */
- if((dataset = H5Dcreate2(file1, DSET_NAME, H5T_NATIVE_INT, space,
- H5P_DEFAULT, dc, H5P_DEFAULT)) < 0) goto error;
+ if ((did = H5Dcreate2(fid1, DSET_NAME, H5T_NATIVE_INT, sid, H5P_DEFAULT, dcpl_id, H5P_DEFAULT)) < 0)
+ goto error;
/* Write the data to the dataset */
- if(H5Dwrite(dataset, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, H5P_DEFAULT, points) < 0)
+ if (H5Dwrite(did, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, H5P_DEFAULT, data) < 0)
goto error;
/* Unregister the filter before closing the dataset. It should fail */
H5E_BEGIN_TRY {
ret = H5Zunregister(H5Z_FILTER_DUMMY);
} H5E_END_TRY;
- if(ret>=0) {
+ if (ret >= 0) {
H5_FAILED();
- printf(" Line %d: Should not be able to unregister filter\n", __LINE__);
+ HDprintf(" Line %d: Should not be able to unregister filter\n", __LINE__);
goto error;
- } /* end if */
+ }
- if(H5Dclose(dataset) < 0) goto error;
+ /* Close the dataset */
+ if (H5Dclose(did) < 0)
+ goto error;
/* Create a dataset in the second file */
- if((dataset = H5Dcreate2(file2, DSET_NAME, H5T_NATIVE_INT, space,
- H5P_DEFAULT, dc, H5P_DEFAULT)) < 0) goto error;
+ if ((did = H5Dcreate2(fid2, DSET_NAME, H5T_NATIVE_INT, sid, H5P_DEFAULT, dcpl_id, H5P_DEFAULT)) < 0)
+ goto error;
/* Write the data to the dataset */
- if(H5Dwrite(dataset, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, H5P_DEFAULT, points) < 0)
+ if (H5Dwrite(did, H5T_NATIVE_INT, H5S_ALL, H5S_ALL, H5P_DEFAULT, data) < 0)
goto error;
- if(H5Dclose(dataset) < 0) goto error;
+ /* Close the dataset in the second file */
+ if (H5Dclose(did) < 0)
+ goto error;
/* Unregister the filter after closing all objects but before closing files.
- * It should flush all files. */
- if(H5Zunregister(H5Z_FILTER_DUMMY) < 0) goto error;
+ * It should flush all files.
+ */
+ if (H5Zunregister(H5Z_FILTER_DUMMY) < 0)
+ goto error;
/* Clean up objects used for this test */
- if(H5Pclose (dc) < 0) goto error;
- if(H5Fclose(file1) < 0) goto error;
- if(H5Fclose(file2) < 0) goto error;
+ if (H5Pclose(dcpl_id) < 0)
+ goto error;
+ if (H5Fclose(fid1) < 0)
+ goto error;
+ if (H5Fclose(fid2) < 0)
+ goto error;
PASSED();
- return 0;
+ return SUCCEED;
error:
- return -1;
+ H5E_BEGIN_TRY {
+ H5Fclose(fid1);
+ H5Fclose(fid2);
+ H5Pclose(dcpl_id);
+ H5Pclose(gcpl_id);
+ H5Gclose(gid);
+ H5Gclose(gid_loop);
+ H5Dclose(did);
+ H5Sclose(sid);
+ } H5E_END_TRY;
+
+ return FAIL;
}
/*-------------------------------------------------------------------------
- * Function: main
- *
- * Purpose: Tests unregistering filter with H5Zunregister
+ * Function: main
*
- * Return: Success: exit(EXIT_SUCCESS)
+ * Purpose: Tests unregistering filter with H5Zunregister
*
- * Failure: exit(EXIT_FAILURE)
- *
- * Programmer: Raymond Lu
- * 11 April 2013
+ * Return: EXIT_SUCCESS/EXIT_FAILURE
*
*-------------------------------------------------------------------------
*/
int
main(void)
{
- hid_t fapl;
- int nerrors = 0;
+ hid_t fapl_id = H5I_INVALID_HID;
+ int nerrors = 0;
/* Testing setup */
h5_reset();
- fapl = h5_fileaccess();
+ fapl_id = h5_fileaccess();
/* Test unregistering filter in its own file */
- nerrors += (test_unregister_filters(fapl) < 0 ? 1 : 0);
+ nerrors += (test_unregister_filters(fapl_id) < 0 ? 1 : 0);
- if(nerrors)
+ h5_cleanup(FILENAME, fapl_id);
+
+ if (nerrors)
goto error;
- printf("All filter unregistration tests passed.\n");
- h5_cleanup(FILENAME, fapl);
+ HDprintf("All filter unregistration tests passed.\n");
- return 0;
+ HDexit(EXIT_SUCCESS);
error:
nerrors = MAX(1, nerrors);
- printf("***** %d FILTER UNREGISTRATION TEST%s FAILED! *****\n",
+ HDprintf("***** %d FILTER UNREGISTRATION TEST%s FAILED! *****\n",
nerrors, 1 == nerrors ? "" : "S");
- return 1;
-}
+ HDexit(EXIT_FAILURE);
+} /* end main() */
diff --git a/test/vol.c b/test/vol.c
index bebe2bd..5f08df3 100644
--- a/test/vol.c
+++ b/test/vol.c
@@ -29,6 +29,9 @@
#define NATIVE_VOL_TEST_ATTRIBUTE_NAME "test_dataset"
#define NATIVE_VOL_TEST_HARD_LINK_NAME "test_hard_link"
#define NATIVE_VOL_TEST_SOFT_LINK_NAME "test_soft_link"
+#define NATIVE_VOL_TEST_MOVE_LINK_NAME "test_move_link"
+#define NATIVE_VOL_TEST_COPY_LINK_NAME "test_copy_link"
+#define NATIVE_VOL_TEST_DATATYPE_NAME "test_datatype"
#define N_ELEMENTS 10
@@ -334,6 +337,7 @@ test_basic_group_operation(void)
{
hid_t fid = H5I_INVALID_HID;
hid_t gid = H5I_INVALID_HID;
+ hid_t gid_a = H5I_INVALID_HID;
hid_t gcpl_id = H5I_INVALID_HID;
H5G_info_t info;
@@ -374,8 +378,14 @@ test_basic_group_operation(void)
if ((gid = H5Gopen2(fid, NATIVE_VOL_TEST_GROUP_NAME, H5P_DEFAULT)) < 0)
TEST_ERROR;
+ /* H5Gcreate_anon */
+ if ((gid_a = H5Gcreate_anon(fid, H5P_DEFAULT, H5P_DEFAULT)) < 0)
+ TEST_ERROR;
+
if (H5Gclose(gid) < 0)
TEST_ERROR;
+ if (H5Gclose(gid_a) < 0)
+ TEST_ERROR;
if (H5Fclose(fid) < 0)
TEST_ERROR;
@@ -606,6 +616,16 @@ test_basic_attribute_operation(void)
if (H5Aclose(aid) < 0)
TEST_ERROR;
+ /* H5Aopen */
+ if ((aid = H5Aopen(fid, NATIVE_VOL_TEST_ATTRIBUTE_NAME, H5P_DEFAULT)) < 0)
+ TEST_ERROR;
+ if (H5Aclose(aid) < 0)
+ TEST_ERROR;
+
+ /* H5Adelete */
+ if (H5Adelete(fid, NATIVE_VOL_TEST_ATTRIBUTE_NAME) < 0)
+ TEST_ERROR;
+
if (H5Fclose(fid) < 0)
TEST_ERROR;
@@ -639,14 +659,40 @@ static herr_t
test_basic_object_operation(void)
{
hid_t fid = H5I_INVALID_HID;
+ hid_t gid = H5I_INVALID_HID;
+ hid_t oid = H5I_INVALID_HID;
+
+ H5O_info_t object_info;
TESTING("Basic VOL object operations");
if ((fid = H5Fcreate(NATIVE_VOL_TEST_FILENAME, H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT)) < 0)
TEST_ERROR;
+ if ((gid = H5Gcreate2(fid, NATIVE_VOL_TEST_GROUP_NAME, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0)
+ TEST_ERROR;
+
+ /* H5Oget_info */
+ if (H5Oget_info(fid, &object_info) < 0)
+ TEST_ERROR;
+
+ /* H5Oget_info_by_name */
+ if (H5Oget_info_by_name(fid, NATIVE_VOL_TEST_GROUP_NAME, &object_info, H5P_DEFAULT) < 0)
+ TEST_ERROR;
+
+ /* H5Oexists_by_name */
+ if (H5Oexists_by_name(fid, NATIVE_VOL_TEST_GROUP_NAME, H5P_DEFAULT) != TRUE)
+ TEST_ERROR;
+
+ /* H5Oopen/close */
+ if ((oid = H5Oopen(fid, NATIVE_VOL_TEST_GROUP_NAME, H5P_DEFAULT)) < 0)
+ TEST_ERROR;
+ if (H5Oclose(oid) < 0)
+ TEST_ERROR;
if (H5Fclose(fid) < 0)
TEST_ERROR;
+ if (H5Gclose(gid) < 0)
+ TEST_ERROR;
HDremove(NATIVE_VOL_TEST_FILENAME);
@@ -656,6 +702,7 @@ test_basic_object_operation(void)
error:
H5E_BEGIN_TRY {
H5Fclose(fid);
+ H5Gclose(gid);
} H5E_END_TRY;
return FAIL;
@@ -676,28 +723,41 @@ static herr_t
test_basic_link_operation(void)
{
hid_t fid = H5I_INVALID_HID;
+ hid_t gid = H5I_INVALID_HID;
TESTING("Basic VOL link operations");
if ((fid = H5Fcreate(NATIVE_VOL_TEST_FILENAME, H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT)) < 0)
TEST_ERROR;
+ if ((gid = H5Gcreate2(fid, NATIVE_VOL_TEST_GROUP_NAME, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT)) < 0)
+ TEST_ERROR;
/* H5Lcreate_hard */
- if (H5Lcreate_hard(fid, "/", H5L_SAME_LOC, NATIVE_VOL_TEST_HARD_LINK_NAME, H5P_DEFAULT, H5P_DEFAULT) < 0)
+ if (H5Lcreate_hard(fid, "/", gid, NATIVE_VOL_TEST_HARD_LINK_NAME, H5P_DEFAULT, H5P_DEFAULT) < 0)
TEST_ERROR;
- /* H5Lcreate_soft */
+ /* H5Lcreate_soft (to itself) */
if (H5Lcreate_soft("/", fid, NATIVE_VOL_TEST_SOFT_LINK_NAME, H5P_DEFAULT, H5P_DEFAULT) < 0)
TEST_ERROR;
/* H5Lexists */
+ if (H5Lexists(gid, NATIVE_VOL_TEST_HARD_LINK_NAME, H5P_DEFAULT) < 0)
+ TEST_ERROR;
if (H5Lexists(fid, NATIVE_VOL_TEST_SOFT_LINK_NAME, H5P_DEFAULT) < 0)
TEST_ERROR;
- if (H5Lexists(fid, NATIVE_VOL_TEST_HARD_LINK_NAME, H5P_DEFAULT) < 0)
+
+ /* H5Lcopy */
+ if (H5Lcopy(gid, NATIVE_VOL_TEST_HARD_LINK_NAME, fid, NATIVE_VOL_TEST_COPY_LINK_NAME, H5P_DEFAULT, H5P_DEFAULT) < 0)
TEST_ERROR;
+ /* H5Lmove */
+// if (H5Lmove(fid, NATIVE_VOL_TEST_COPY_LINK_NAME, gid, NATIVE_VOL_TEST_MOVE_LINK_NAME, H5P_DEFAULT, H5P_DEFAULT) < 0)
+// TEST_ERROR;
+
if (H5Fclose(fid) < 0)
TEST_ERROR;
+ if (H5Gclose(gid) < 0)
+ TEST_ERROR;
HDremove(NATIVE_VOL_TEST_FILENAME);
@@ -707,6 +767,7 @@ test_basic_link_operation(void)
error:
H5E_BEGIN_TRY {
H5Fclose(fid);
+ H5Fclose(gid);
} H5E_END_TRY;
return FAIL;
@@ -727,12 +788,34 @@ static herr_t
test_basic_datatype_operation(void)
{
hid_t fid = H5I_INVALID_HID;
+ hid_t tid = H5I_INVALID_HID;
+ hid_t tcpl_id = H5I_INVALID_HID;
TESTING("Basic VOL datatype operations");
if ((fid = H5Fcreate(NATIVE_VOL_TEST_FILENAME, H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT)) < 0)
TEST_ERROR;
+ if ((tid = H5Tcopy(H5T_NATIVE_INT)) < 0)
+ TEST_ERROR;
+
+ /* H5Tcommit */
+ if (H5Tcommit2(fid, NATIVE_VOL_TEST_DATATYPE_NAME, tid, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT) < 0)
+ TEST_ERROR;
+ if (H5Tclose(tid) < 0)
+ TEST_ERROR;
+ /* H5Topen */
+ if ((tid = H5Topen2(fid, NATIVE_VOL_TEST_DATATYPE_NAME, H5P_DEFAULT)) < 0)
+ TEST_ERROR;
+
+ /* H5Tget_create_plist */
+ if ((tcpl_id = H5Tget_create_plist(tid)) < 0)
+ TEST_ERROR;
+
+ if (H5Pclose(tcpl_id) < 0)
+ TEST_ERROR;
+ if (H5Tclose(tid) < 0)
+ TEST_ERROR;
if (H5Fclose(fid) < 0)
TEST_ERROR;
@@ -743,7 +826,9 @@ test_basic_datatype_operation(void)
error:
H5E_BEGIN_TRY {
+ H5Pclose(tcpl_id);
H5Fclose(fid);
+ H5Tclose(tid);
} H5E_END_TRY;
return FAIL;