summaryrefslogtreecommitdiffstats
path: root/src/H5Gdeprec.c
diff options
context:
space:
mode:
authorQuincey Koziol <koziol@hdfgroup.org>2018-11-10 17:54:20 (GMT)
committerQuincey Koziol <koziol@hdfgroup.org>2018-11-10 17:54:20 (GMT)
commitca1b9025fe8be1eab6bd76d58ab78bb9450c41f1 (patch)
tree905e707406ac64775824fe4c43627fb9e0cf2b46 /src/H5Gdeprec.c
parent140f72b74847822e50bd10bb7051049b77f59abb (diff)
downloadhdf5-ca1b9025fe8be1eab6bd76d58ab78bb9450c41f1.zip
hdf5-ca1b9025fe8be1eab6bd76d58ab78bb9450c41f1.tar.gz
hdf5-ca1b9025fe8be1eab6bd76d58ab78bb9450c41f1.tar.bz2
Switch switch remainder of API routines to use VOL callbacks.
Diffstat (limited to 'src/H5Gdeprec.c')
-rw-r--r--src/H5Gdeprec.c369
1 files changed, 181 insertions, 188 deletions
diff --git a/src/H5Gdeprec.c b/src/H5Gdeprec.c
index 8aae2a1..6ed5344 100644
--- a/src/H5Gdeprec.c
+++ b/src/H5Gdeprec.c
@@ -72,13 +72,9 @@ typedef struct {
/********************/
/* Local Prototypes */
/********************/
-
static herr_t H5G__get_objinfo_cb(H5G_loc_t *grp_loc/*in*/, const char *name,
const H5O_link_t *lnk, H5G_loc_t *obj_loc, void *_udata/*in,out*/,
H5G_own_loc_t *own_loc/*out*/);
-static herr_t H5G__get_objinfo(const H5G_loc_t *loc, const char *name,
- hbool_t follow_link, H5G_stat_t *statbuf/*out*/);
-static H5G_obj_t H5G__obj_get_type_by_idx(H5O_loc_t *oloc, hsize_t idx);
#endif /* H5_NO_DEPRECATED_SYMBOLS */
@@ -172,7 +168,7 @@ hid_t
H5Gcreate1(hid_t loc_id, const char *name, size_t size_hint)
{
void *grp = NULL; /* New group created */
- H5VL_object_t *vol_obj = NULL; /* object token of loc_id */
+ H5VL_object_t *vol_obj; /* Object token of loc_id */
H5VL_loc_params_t loc_params;
H5P_genplist_t *plist; /* Property list pointer */
hid_t tmp_gcpl = H5I_INVALID_HID; /* Temporary group creation property list */
@@ -227,6 +223,7 @@ H5Gcreate1(hid_t loc_id, const char *name, size_t size_hint)
if(H5P_set(plist, H5VL_PROP_GRP_LCPL_ID, &lcpl_id) < 0)
HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, H5I_INVALID_HID, "can't get property value for lcpl id")
+ /* Set location parameters */
loc_params.type = H5VL_OBJECT_BY_SELF;
loc_params.obj_type = H5I_get_type(loc_id);
@@ -275,10 +272,10 @@ done:
hid_t
H5Gopen1(hid_t loc_id, const char *name)
{
- void *grp = NULL; /* Group opened */
- H5VL_object_t *vol_obj = NULL; /* object token of loc_id */
+ void *grp = NULL; /* Group opened */
+ H5VL_object_t *vol_obj = NULL; /* Object token of loc_id */
H5VL_loc_params_t loc_params;
- hid_t ret_value = H5I_INVALID_HID; /* Return value */
+ hid_t ret_value = H5I_INVALID_HID; /* Return value */
FUNC_ENTER_API(H5I_INVALID_HID)
H5TRACE2("i", "i*s", loc_id, name);
@@ -346,7 +343,7 @@ H5Glink(hid_t cur_loc_id, H5G_link_t type, const char *cur_name, const char *new
/* Create link */
if(type == H5L_TYPE_HARD) {
- H5VL_object_t *vol_obj = NULL; /* object token of loc_id */
+ H5VL_object_t *vol_obj; /* Object token of loc_id */
H5VL_loc_params_t loc_params1;
H5VL_loc_params_t loc_params2;
H5VL_object_t tmp_vol_obj; /* Temporary object token of */
@@ -379,7 +376,7 @@ H5Glink(hid_t cur_loc_id, H5G_link_t type, const char *cur_name, const char *new
HGOTO_ERROR(H5E_SYM, H5E_CANTINIT, FAIL, "unable to create link")
} /* end if */
else if(type == H5L_TYPE_SOFT) {
- H5VL_object_t *vol_obj = NULL; /* object token of loc_id */
+ H5VL_object_t *vol_obj; /* Object token of loc_id */
H5VL_loc_params_t loc_params;
loc_params.type = H5VL_OBJECT_BY_NAME;
@@ -442,8 +439,8 @@ H5Glink2(hid_t cur_loc_id, const char *cur_name, H5G_link_t type,
/* Create the appropriate kind of link */
if(type == H5L_TYPE_HARD) {
- H5VL_object_t *vol_obj1 = NULL; /* object token of loc_id */
- H5VL_object_t *vol_obj2 = NULL; /* object token of loc_id */
+ H5VL_object_t *vol_obj1; /* Object token of loc_id */
+ H5VL_object_t *vol_obj2; /* Object token of loc_id */
H5VL_loc_params_t loc_params1;
H5VL_loc_params_t loc_params2;
@@ -474,7 +471,7 @@ H5Glink2(hid_t cur_loc_id, const char *cur_name, H5G_link_t type,
HGOTO_ERROR(H5E_SYM, H5E_CANTINIT, FAIL, "unable to create link")
} /* end if */
else if(type == H5L_TYPE_SOFT) {
- H5VL_object_t *vol_obj = NULL; /* object token of loc_id */
+ H5VL_object_t *vol_obj; /* Object token of loc_id */
H5VL_loc_params_t loc_params;
/* Soft links only need one location, the new_loc_id, but it's possible that
@@ -517,10 +514,10 @@ done:
herr_t
H5Gmove(hid_t src_loc_id, const char *src_name, const char *dst_name)
{
- H5VL_object_t *vol_obj = NULL; /* object token of loc_id */
+ H5VL_object_t *vol_obj; /* Object token of loc_id */
H5VL_loc_params_t loc_params1;
H5VL_loc_params_t loc_params2;
- herr_t ret_value = SUCCEED; /* Return value */
+ herr_t ret_value = SUCCEED; /* Return value */
FUNC_ENTER_API(FAIL)
H5TRACE3("e", "i*s*s", src_loc_id, src_name, dst_name);
@@ -562,9 +559,9 @@ herr_t
H5Gmove2(hid_t src_loc_id, const char *src_name, hid_t dst_loc_id,
const char *dst_name)
{
- H5VL_object_t *vol_obj1 = NULL; /* object token of src_id */
+ H5VL_object_t *vol_obj1 = NULL; /* Object token of src_id */
H5VL_loc_params_t loc_params1;
- H5VL_object_t *vol_obj2 = NULL; /* object token of dst_id */
+ H5VL_object_t *vol_obj2 = NULL; /* Object token of dst_id */
H5VL_loc_params_t loc_params2;
herr_t ret_value = SUCCEED; /* Return value */
@@ -615,7 +612,7 @@ done:
herr_t
H5Gunlink(hid_t loc_id, const char *name)
{
- H5VL_object_t *vol_obj = NULL; /* object token of loc_id */
+ H5VL_object_t *vol_obj; /* Object token of loc_id */
H5VL_loc_params_t loc_params;
herr_t ret_value = SUCCEED; /* Return value */
@@ -659,7 +656,7 @@ done:
herr_t
H5Gget_linkval(hid_t loc_id, const char *name, size_t size, char *buf/*out*/)
{
- H5VL_object_t *vol_obj = NULL; /* object token of loc_id */
+ H5VL_object_t *vol_obj; /* Object token of loc_id */
H5VL_loc_params_t loc_params;
herr_t ret_value = SUCCEED; /* Return value */
@@ -712,14 +709,13 @@ done:
herr_t
H5Gset_comment(hid_t loc_id, const char *name, const char *comment)
{
- H5G_loc_t loc; /* Group's location */
- herr_t ret_value = SUCCEED; /* Return value */
+ H5VL_object_t *vol_obj; /* Object token of loc_id */
+ H5VL_loc_params_t loc_params;
+ herr_t ret_value = SUCCEED; /* Return value */
FUNC_ENTER_API(FAIL)
H5TRACE3("e", "i*s*s", loc_id, name, comment);
- 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 specified")
@@ -727,8 +723,18 @@ H5Gset_comment(hid_t loc_id, const char *name, const char *comment)
if(H5CX_set_loc(loc_id) < 0)
HGOTO_ERROR(H5E_SYM, H5E_CANTSET, FAIL, "can't set collective metadata read info")
+ /* Fill in 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 = H5P_LINK_ACCESS_DEFAULT;
+ loc_params.obj_type = H5I_get_type(loc_id);
+
+ /* Get the location object */
+ if(NULL == (vol_obj = H5VL_vol_object(loc_id)))
+ HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "invalid location identifier")
+
/* Set the comment */
- if(H5G_loc_set_comment(&loc, name, comment) < 0)
+ if(H5VL_object_optional(vol_obj, H5P_DATASET_XFER_DEFAULT, H5_REQUEST_NULL, H5VL_OBJECT_SET_COMMENT, loc_params, comment) < 0)
HGOTO_ERROR(H5E_SYM, H5E_CANTSET, FAIL, "unable to set comment value")
done:
@@ -762,14 +768,13 @@ done:
int
H5Gget_comment(hid_t loc_id, const char *name, size_t bufsize, char *buf)
{
- H5G_loc_t loc; /* Group's location */
+ H5VL_object_t *vol_obj; /* Object token of loc_id */
+ H5VL_loc_params_t loc_params;
int ret_value; /* Return value */
FUNC_ENTER_API(FAIL)
H5TRACE4("Is", "i*sz*s", loc_id, name, bufsize, buf);
- 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 specified")
if(bufsize > 0 && !buf)
@@ -779,8 +784,18 @@ H5Gget_comment(hid_t loc_id, const char *name, size_t bufsize, char *buf)
if(H5CX_set_loc(loc_id) < 0)
HGOTO_ERROR(H5E_SYM, H5E_CANTSET, FAIL, "can't set collective metadata read info")
+ /* Fill in 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 = H5P_LINK_ACCESS_DEFAULT;
+ loc_params.obj_type = H5I_get_type(loc_id);
+
+ /* Get the location object */
+ if(NULL == (vol_obj = H5VL_vol_object(loc_id)))
+ HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "invalid location identifier")
+
/* Get the comment */
- if((ret_value = (int)H5G_loc_get_comment(&loc, name, buf, bufsize)) < 0)
+ if(H5VL_object_optional(vol_obj, H5P_DATASET_XFER_DEFAULT, H5_REQUEST_NULL, H5VL_OBJECT_GET_COMMENT, loc_params, buf, bufsize, &ret_value) < 0)
HGOTO_ERROR(H5E_SYM, H5E_CANTGET, FAIL, "unable to get comment value")
done:
@@ -816,20 +831,17 @@ herr_t
H5Giterate(hid_t loc_id, const char *name, int *idx_p, H5G_iterate_t op,
void *op_data)
{
- H5G_loc_t loc; /* Location of object */
+ H5VL_object_t *vol_obj; /* Object token of loc_id */
+ H5VL_loc_params_t loc_params;
H5G_link_iterate_t lnk_op; /* Link operator */
- H5VL_object_t *vol_obj;
hsize_t last_obj; /* Index of last object looked at */
- hsize_t idx; /* Internal location to hold index */
- hbool_t vol_wrapper_set = FALSE; /* Whether the VOL object wrapping context was set up */
+ hsize_t idx; /* Internal location to hold index */
herr_t ret_value; /* Return value */
FUNC_ENTER_API(FAIL)
H5TRACE5("e", "i*s*Isx*x", loc_id, name, idx_p, op, op_data);
/* Check args */
- if(H5G_loc(loc_id, &loc) < 0)
- HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a location ID")
if(!name || !*name)
HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "no name specified")
if(idx_p && *idx_p < 0)
@@ -845,28 +857,25 @@ H5Giterate(hid_t loc_id, const char *name, int *idx_p, H5G_iterate_t op,
lnk_op.op_type = H5G_LINK_OP_OLD;
lnk_op.op_func.op_old = op;
+ /* 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 = H5P_LINK_ACCESS_DEFAULT;
+ loc_params.obj_type = H5I_get_type(loc_id);
+
/* Get the object pointer */
if(NULL == (vol_obj = H5VL_vol_object(loc_id)))
HGOTO_ERROR(H5E_ATOM, H5E_BADTYPE, (-1), "invalid identifier")
- /* Set wrapper info in API context */
- if(H5VL_set_vol_wrapper(vol_obj->data, vol_obj->connector) < 0)
- HGOTO_ERROR(H5E_ATOM, H5E_CANTSET, (-1), "can't set VOL wrapper info")
- vol_wrapper_set = TRUE;
-
- /* Call private function */
- if((ret_value = H5G_iterate(&loc, name, H5_INDEX_NAME, H5_ITER_INC, idx, &last_obj, &lnk_op, op_data)) < 0)
- HGOTO_ERROR(H5E_SYM, H5E_BADITER, FAIL, "group iteration failed")
+ /* Call private iteration function, through VOL callback */
+ if((ret_value = H5VL_group_optional(vol_obj, H5P_DATASET_XFER_DEFAULT, H5_REQUEST_NULL, H5VL_GROUP_ITERATE_OLD, loc_params, idx, &last_obj, &lnk_op, op_data)) < 0)
+ HERROR(H5E_SYM, H5E_BADITER, "error iterating over group's links");
/* Set the index we stopped at */
if(idx_p)
*idx_p = (int)last_obj;
done:
- /* Reset object wrapping info in API context */
- if(vol_wrapper_set && H5VL_reset_vol_wrapper() < 0)
- HDONE_ERROR(H5E_SYM, H5E_CANTSET, H5I_INVALID_HID, "can't reset VOL wrapper info")
-
FUNC_LEAVE_API(ret_value)
} /* end H5Giterate() */
@@ -890,29 +899,35 @@ done:
herr_t
H5Gget_num_objs(hid_t loc_id, hsize_t *num_objs)
{
- H5G_loc_t loc; /* Location of object */
+ H5VL_object_t *vol_obj; /* Object token of loc_id */
+ H5I_type_t id_type; /* Type of ID */
+ H5VL_loc_params_t loc_params;
H5G_info_t grp_info; /* Group information */
- H5O_type_t obj_type; /* Type of object at location */
- herr_t ret_value = SUCCEED;
+ herr_t ret_value = SUCCEED; /* Return value */
FUNC_ENTER_API(FAIL)
H5TRACE2("e", "i*h", loc_id, num_objs);
/* Check args */
- if(H5G_loc(loc_id, &loc) < 0)
- HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a location ID")
- if(H5O_obj_type(loc.oloc, &obj_type) < 0)
- HGOTO_ERROR(H5E_ARGS, H5E_CANTGET, FAIL, "can't get object type")
- if(obj_type != H5O_TYPE_GROUP)
- HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a group")
+ id_type = H5I_get_type(loc_id);
+ if(!(H5I_GROUP == id_type || H5I_FILE == id_type))
+ HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "invalid group (or file) ID")
if(!num_objs)
HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "bad pointer to # of objects")
- /* Retrieve information about the group */
- if(H5G__obj_info(loc.oloc, &grp_info) < 0)
- HGOTO_ERROR(H5E_SYM, H5E_CANTCOUNT, FAIL, "can't determine # of objects")
+ /* Fill in location struct fields */
+ loc_params.type = H5VL_OBJECT_BY_SELF;
+ loc_params.obj_type = id_type;
+
+ /* Get group location */
+ if(NULL == (vol_obj = (H5VL_object_t *)H5I_object(loc_id)))
+ HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "invalid location identifier")
+
+ /* Retrieve the group's information */
+ if(H5VL_group_get(vol_obj, H5VL_GROUP_GET_INFO, H5P_DATASET_XFER_DEFAULT, H5_REQUEST_NULL, loc_params, &grp_info) < 0)
+ HGOTO_ERROR(H5E_SYM, H5E_CANTGET, FAIL, "unable to get group info")
- /* Set the number of objects [sic: links] in the group */
+ /* Set the number of objects [i.e. links] in the group */
*num_objs = grp_info.nlinks;
done:
@@ -939,23 +954,40 @@ done:
*/
herr_t
H5Gget_objinfo(hid_t loc_id, const char *name, hbool_t follow_link,
- H5G_stat_t *statbuf/*out*/)
+ H5G_stat_t *statbuf/*out*/)
{
- H5G_loc_t loc; /* Group's location */
- herr_t ret_value = SUCCEED; /* Return value */
+ herr_t ret_value = SUCCEED; /* Return value */
FUNC_ENTER_API(FAIL)
H5TRACE4("e", "i*sbx", loc_id, name, follow_link, statbuf);
/* 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 specified")
- /* Get info */
- if(H5G__get_objinfo(&loc, name, follow_link, statbuf) < 0)
- HGOTO_ERROR(H5E_SYM, H5E_CANTGET, FAIL, "cannot stat object")
+ /* Set up collective metadata if appropriate */
+ if(H5CX_set_loc(loc_id) < 0)
+ HGOTO_ERROR(H5E_SYM, H5E_CANTSET, FAIL, "can't set collective metadata read info")
+
+ /* Retrieve object info, if pointer to struct is given */
+ if(statbuf) {
+ H5VL_object_t *vol_obj; /* Object token of loc_id */
+ H5VL_loc_params_t loc_params;
+
+ /* 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 = H5P_LINK_ACCESS_DEFAULT;
+ loc_params.obj_type = H5I_get_type(loc_id);
+
+ /* Get the location object */
+ if(NULL == (vol_obj = H5VL_vol_object(loc_id)))
+ HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "invalid location identifier")
+
+ /* Retrieve the object's information */
+ if(H5VL_group_optional(vol_obj, H5P_DATASET_XFER_DEFAULT, H5_REQUEST_NULL, H5VL_GROUP_GET_OBJINFO, loc_params, (unsigned)follow_link, statbuf) < 0)
+ HGOTO_ERROR(H5E_SYM, H5E_CANTGET, FAIL, "can't get info for object: '%s'", name)
+ } /* end if */
done:
FUNC_LEAVE_API(ret_value)
@@ -980,6 +1012,7 @@ H5G__get_objinfo_cb(H5G_loc_t H5_ATTR_UNUSED *grp_loc/*in*/, const char *name, c
H5G_loc_t *obj_loc, void *_udata/*in,out*/, H5G_own_loc_t *own_loc/*out*/)
{
H5G_trav_goi_t *udata = (H5G_trav_goi_t *)_udata; /* User data passed in */
+ H5G_stat_t *statbuf = udata->statbuf; /* Convenience pointer for statbuf */
herr_t ret_value = SUCCEED; /* Return value */
FUNC_ENTER_STATIC
@@ -988,48 +1021,43 @@ H5G__get_objinfo_cb(H5G_loc_t H5_ATTR_UNUSED *grp_loc/*in*/, const char *name, c
if(lnk == NULL && obj_loc == NULL)
HGOTO_ERROR(H5E_SYM, H5E_NOTFOUND, FAIL, "'%s' doesn't exist", name)
- /* Only modify user's buffer if it's available */
- if(udata->statbuf) {
- H5G_stat_t *statbuf = udata->statbuf; /* Convenience pointer for statbuf */
-
- /* Common code to retrieve the file's fileno */
- if(H5F_get_fileno((obj_loc ? obj_loc : grp_loc)->oloc->file, &statbuf->fileno[0]) < 0)
- HGOTO_ERROR(H5E_FILE, H5E_BADVALUE, FAIL, "unable to read fileno")
+ /* Common code to retrieve the file's fileno */
+ if(H5F_get_fileno((obj_loc ? obj_loc : grp_loc)->oloc->file, &statbuf->fileno[0]) < 0)
+ HGOTO_ERROR(H5E_FILE, H5E_BADVALUE, FAIL, "unable to read fileno")
- /* Info for soft and UD links is gotten by H5L_get_info. If we have
- * a hard link, follow it and get info on the object
- */
- if(udata->follow_link || !lnk || (lnk->type == H5L_TYPE_HARD)) {
- H5O_info_t oinfo; /* Object information */
+ /* Info for soft and UD links is gotten by H5L_get_info. If we have
+ * a hard link, follow it and get info on the object
+ */
+ if(udata->follow_link || !lnk || (lnk->type == H5L_TYPE_HARD)) {
+ H5O_info_t oinfo; /* Object information */
- /* Go retrieve the object information */
- /* (don't need index & heap info) */
- HDassert(obj_loc);
- if(H5O_get_info(obj_loc->oloc, &oinfo, H5O_INFO_BASIC|H5O_INFO_TIME|H5O_INFO_HDR) < 0)
- HGOTO_ERROR(H5E_OHDR, H5E_CANTGET, FAIL, "unable to get object info")
+ /* Go retrieve the object information */
+ /* (don't need index & heap info) */
+ HDassert(obj_loc);
+ if(H5O_get_info(obj_loc->oloc, &oinfo, H5O_INFO_BASIC|H5O_INFO_TIME|H5O_INFO_HDR) < 0)
+ HGOTO_ERROR(H5E_OHDR, H5E_CANTGET, FAIL, "unable to get object info")
- /* Get mapped object type */
- statbuf->type = H5G_map_obj_type(oinfo.type);
+ /* Get mapped object type */
+ statbuf->type = H5G_map_obj_type(oinfo.type);
- /* Get object number (i.e. address) for object */
- statbuf->objno[0] = (unsigned long)(oinfo.addr);
+ /* Get object number (i.e. address) for object */
+ statbuf->objno[0] = (unsigned long)(oinfo.addr);
#if H5_SIZEOF_UINT64_T > H5_SIZEOF_LONG
- statbuf->objno[1] = (unsigned long)(oinfo.addr >> 8 * sizeof(long));
+ statbuf->objno[1] = (unsigned long)(oinfo.addr >> 8 * sizeof(long));
#else
- statbuf->objno[1] = 0;
+ statbuf->objno[1] = 0;
#endif
- /* Get # of hard links pointing to object */
- statbuf->nlink = oinfo.rc;
+ /* Get # of hard links pointing to object */
+ statbuf->nlink = oinfo.rc;
- /* Get modification time for object */
- statbuf->mtime = oinfo.ctime;
+ /* Get modification time for object */
+ statbuf->mtime = oinfo.ctime;
- /* Retrieve the object header information */
- statbuf->ohdr.size = oinfo.hdr.space.total;
- statbuf->ohdr.free = oinfo.hdr.space.free;
- statbuf->ohdr.nmesgs = oinfo.hdr.nmesgs;
- statbuf->ohdr.nchunks = oinfo.hdr.nchunks;
- } /* end if */
+ /* Retrieve the object header information */
+ statbuf->ohdr.size = oinfo.hdr.space.total;
+ statbuf->ohdr.free = oinfo.hdr.space.free;
+ statbuf->ohdr.nmesgs = oinfo.hdr.nmesgs;
+ statbuf->ohdr.nchunks = oinfo.hdr.nchunks;
} /* end if */
done:
@@ -1057,22 +1085,22 @@ done:
*
*-------------------------------------------------------------------------
*/
-static herr_t
+herr_t
H5G__get_objinfo(const H5G_loc_t *loc, const char *name, hbool_t follow_link,
H5G_stat_t *statbuf/*out*/)
{
H5G_trav_goi_t udata; /* User data for callback */
herr_t ret_value = SUCCEED; /* Return value */
- FUNC_ENTER_STATIC
+ FUNC_ENTER_PACKAGE
/* Sanity checks */
HDassert(loc);
HDassert(name && *name);
+ HDassert(statbuf);
- /* Reset stat buffer, if one was given */
- if(statbuf)
- HDmemset(statbuf, 0, sizeof(H5G_stat_t));
+ /* Reset stat buffer */
+ HDmemset(statbuf, 0, sizeof(H5G_stat_t));
/* Set up user data for retrieving information */
udata.statbuf = statbuf;
@@ -1080,12 +1108,11 @@ H5G__get_objinfo(const H5G_loc_t *loc, const char *name, hbool_t follow_link,
udata.loc_file = loc->oloc->file;
/* Traverse the group hierarchy to locate the object to get info about */
- if(H5G_traverse(loc, name, (unsigned)(follow_link ? H5G_TARGET_NORMAL : H5G_TARGET_SLINK|H5G_TARGET_UDLINK),
- H5G__get_objinfo_cb, &udata) < 0)
+ if(H5G_traverse(loc, name, (unsigned)(follow_link ? H5G_TARGET_NORMAL : (H5G_TARGET_SLINK | H5G_TARGET_UDLINK)), H5G__get_objinfo_cb, &udata) < 0)
HGOTO_ERROR(H5E_SYM, H5E_EXISTS, FAIL, "name doesn't exist")
/* If we're pointing at a soft or UD link, get the real link length and type */
- if(statbuf && follow_link == 0) {
+ if(follow_link == 0) {
H5L_info_t linfo; /* Link information buffer */
herr_t ret;
@@ -1137,24 +1164,33 @@ done:
ssize_t
H5Gget_objname_by_idx(hid_t loc_id, hsize_t idx, char *name, size_t size)
{
- H5G_loc_t loc; /* Object location */
- H5O_type_t obj_type; /* Type of object at location */
- ssize_t ret_value;
+ H5VL_object_t *vol_obj; /* Object token of loc_id */
+ H5VL_loc_params_t loc_params;
+ ssize_t ret_value; /* Return value */
FUNC_ENTER_API(FAIL)
H5TRACE4("Zs", "ih*sz", loc_id, idx, name, size);
- /* Check args */
- if(H5G_loc(loc_id, &loc) < 0)
- HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a location ID")
- if(H5O_obj_type(loc.oloc, &obj_type) < 0)
- HGOTO_ERROR(H5E_ARGS, H5E_CANTGET, FAIL, "can't get object type")
- if(obj_type != H5O_TYPE_GROUP)
- HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a group")
+ /* Set up collective metadata if appropriate */
+ if(H5CX_set_loc(loc_id) < 0)
+ HGOTO_ERROR(H5E_SYM, H5E_CANTSET, (-1), "can't set collective metadata read info")
+
+ /* Fill in location struct fields */
+ 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_NAME;
+ loc_params.loc_data.loc_by_idx.order = H5_ITER_INC;
+ loc_params.loc_data.loc_by_idx.n = idx;
+ loc_params.loc_data.loc_by_idx.lapl_id = H5P_LINK_ACCESS_DEFAULT;
+ loc_params.obj_type = H5I_get_type(loc_id);
+
+ /* Get the location object */
+ if(NULL == (vol_obj = (H5VL_object_t *)H5I_object(loc_id)))
+ HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, (-1), "invalid location identifier")
/* Call internal function */
- if((ret_value = H5G_obj_get_name_by_idx(loc.oloc, H5_INDEX_NAME, H5_ITER_INC, idx, name, size)) < 0)
- HGOTO_ERROR(H5E_SYM, H5E_CANTGET, FAIL, "can't get object name")
+ if(H5VL_link_get(vol_obj, loc_params, H5VL_LINK_GET_NAME, H5P_DATASET_XFER_DEFAULT, H5_REQUEST_NULL, name, size, &ret_value) < 0)
+ HGOTO_ERROR(H5E_SYM, H5E_CANTGET, (-1), "can't get object name")
done:
FUNC_LEAVE_API(ret_value)
@@ -1179,82 +1215,39 @@ done:
H5G_obj_t
H5Gget_objtype_by_idx(hid_t loc_id, hsize_t idx)
{
- H5G_loc_t loc; /* Object location */
- H5G_obj_t ret_value;
+ H5VL_object_t *vol_obj; /* Object token of loc_id */
+ H5VL_loc_params_t loc_params;
+ H5O_info_t oinfo; /* Object info (contains object type) */
+ unsigned fields; /* Which fields in object info to populate */
+ H5G_obj_t ret_value; /* Return value */
FUNC_ENTER_API(H5G_UNKNOWN)
H5TRACE2("Go", "ih", loc_id, idx);
- /* Check args */
- if(H5G_loc(loc_id, &loc) < 0)
- HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, H5G_UNKNOWN, "not a location ID")
-
- /* Call internal function*/
- if(H5G_UNKNOWN == (ret_value = H5G__obj_get_type_by_idx(loc.oloc, idx)))
- HGOTO_ERROR(H5E_SYM, H5E_BADTYPE, H5G_UNKNOWN, "can't get object type")
-
-done:
- FUNC_LEAVE_API(ret_value)
-} /* end H5Gget_objtype_by_idx() */
-
-
-/*-------------------------------------------------------------------------
- * Function: H5G__obj_get_type_by_idx
- *
- * Purpose: Private function for H5Gget_objtype_by_idx.
- * Returns the type of objects in the group by giving index.
- *
- * Return: Success: H5G_GROUP(1), H5G_DATASET(2), H5G_TYPE(3)
- *
- * Failure: Negative
- *
- * Programmer: Raymond Lu
- * Nov 20, 2002
- *
- *-------------------------------------------------------------------------
- */
-static H5G_obj_t
-H5G__obj_get_type_by_idx(H5O_loc_t *oloc, hsize_t idx)
-{
- H5O_linfo_t linfo; /* Link info message */
- htri_t linfo_exists; /* Whether the link info message exists */
- H5O_type_t obj_type; /* Type of object at location */
- H5G_obj_t ret_value = H5G_UNKNOWN; /* Return value */
+ /* Set location parameters */
+ 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_NAME;
+ loc_params.loc_data.loc_by_idx.order = H5_ITER_INC;
+ loc_params.loc_data.loc_by_idx.n = idx;
+ loc_params.loc_data.loc_by_idx.lapl_id = H5P_LINK_ACCESS_DEFAULT;
+ loc_params.obj_type = H5I_get_type(loc_id);
- FUNC_ENTER_STATIC_TAG(oloc->addr)
+ /* Get the location object */
+ if(NULL == (vol_obj = H5VL_vol_object(loc_id)))
+ HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, H5G_UNKNOWN, "invalid location identifier")
- /* Sanity check */
- HDassert(oloc);
+ /* Retrieve the object's basic information (which includes its type) */
+ fields = H5O_INFO_BASIC;
+ if(H5VL_object_optional(vol_obj, H5P_DATASET_XFER_DEFAULT, H5_REQUEST_NULL, H5VL_OBJECT_GET_INFO, loc_params, &oinfo, fields) < 0)
+ HGOTO_ERROR(H5E_SYM, H5E_BADTYPE, H5G_UNKNOWN, "can't get object info")
- /* Check args */
- if(H5O_obj_type(oloc, &obj_type) < 0)
- HGOTO_ERROR(H5E_SYM, H5E_CANTGET, H5G_UNKNOWN, "can't get object type")
- if(obj_type != H5O_TYPE_GROUP)
- HGOTO_ERROR(H5E_SYM, H5E_BADTYPE, H5G_UNKNOWN, "not a group")
-
- /* Attempt to get the link info for this group */
- if((linfo_exists = H5G__obj_get_linfo(oloc, &linfo)) < 0)
- HGOTO_ERROR(H5E_SYM, H5E_CANTGET, H5G_UNKNOWN, "can't check for link info message")
- if(linfo_exists) {
- if(H5F_addr_defined(linfo.fheap_addr)) {
- /* Get the object's name from the dense link storage */
- if((ret_value = H5G__dense_get_type_by_idx(oloc->file, &linfo, idx)) < 0)
- HGOTO_ERROR(H5E_SYM, H5E_NOTFOUND, H5G_UNKNOWN, "can't locate type")
- } /* end if */
- else {
- /* Get the object's type from the link messages */
- if((ret_value = H5G__compact_get_type_by_idx(oloc, &linfo, idx)) < 0)
- HGOTO_ERROR(H5E_SYM, H5E_NOTFOUND, H5G_UNKNOWN, "can't locate type")
- } /* end else */
- } /* end if */
- else {
- /* Get the object's type from the symbol table */
- if((ret_value = H5G__stab_get_type_by_idx(oloc, idx)) < 0)
- HGOTO_ERROR(H5E_SYM, H5E_NOTFOUND, H5G_UNKNOWN, "can't locate type")
- } /* end else */
+ /* Map to group object type */
+ if(H5G_UNKNOWN == (ret_value = H5G_map_obj_type(oinfo.type)))
+ HGOTO_ERROR(H5E_SYM, H5E_BADTYPE, H5G_UNKNOWN, "can't determine object type")
done:
- FUNC_LEAVE_NOAPI_TAG(ret_value)
-} /* end H5G__obj_get_type_by_idx() */
+ FUNC_LEAVE_API(ret_value)
+} /* end H5Gget_objtype_by_idx() */
#endif /* H5_NO_DEPRECATED_SYMBOLS */