diff options
-rw-r--r-- | src/H5Fmount.c | 12 | ||||
-rw-r--r-- | src/H5Gcompact.c | 16 | ||||
-rw-r--r-- | src/H5Gdense.c | 31 | ||||
-rw-r--r-- | src/H5Glink.c | 81 | ||||
-rw-r--r-- | src/H5Gloc.c | 69 | ||||
-rw-r--r-- | src/H5Gname.c | 87 | ||||
-rw-r--r-- | src/H5Gnode.c | 232 | ||||
-rw-r--r-- | src/H5Gobj.c | 9 | ||||
-rw-r--r-- | src/H5Gpkg.h | 27 | ||||
-rw-r--r-- | src/H5Gprivate.h | 5 | ||||
-rw-r--r-- | src/H5Gstab.c | 9 | ||||
-rw-r--r-- | src/H5HL.c | 67 | ||||
-rw-r--r-- | src/H5HLprivate.h | 7 | ||||
-rw-r--r-- | src/H5L.c | 33 | ||||
-rw-r--r-- | src/H5Oefl.c | 68 | ||||
-rw-r--r-- | src/H5Oshared.c | 96 | ||||
-rw-r--r-- | src/H5Ostab.c | 2 |
17 files changed, 379 insertions, 472 deletions
diff --git a/src/H5Fmount.c b/src/H5Fmount.c index 7727425..452cf28 100644 --- a/src/H5Fmount.c +++ b/src/H5Fmount.c @@ -204,11 +204,11 @@ H5F_mount(H5G_loc_t *loc, const char *name, H5F_t *child, HGOTO_ERROR(H5E_FILE, H5E_MOUNT, FAIL, "mount point is already in use") /* Make room in the table */ - if(parent->mtab.nmounts>=parent->mtab.nalloc) { - unsigned n = MAX(16, 2*parent->mtab.nalloc); + if(parent->mtab.nmounts >= parent->mtab.nalloc) { + unsigned n = MAX(16, 2 * parent->mtab.nalloc); H5F_mount_t *x = H5MM_realloc(parent->mtab.child, n * sizeof(parent->mtab.child[0])); - if (!x) + if(!x) HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, FAIL, "memory allocation failed for mount table") parent->mtab.child = x; parent->mtab.nalloc = n; @@ -234,7 +234,8 @@ H5F_mount(H5G_loc_t *loc, const char *name, H5F_t *child, /* Search the open IDs and replace names for mount operation */ /* We pass H5G_UNKNOWN as object type; search all IDs */ - if(H5G_name_replace(H5G_UNKNOWN, &mp_loc, NULL, &root_loc, H5G_NAME_MOUNT) < 0) + if(H5G_name_replace(H5G_UNKNOWN, mp_loc.oloc->file, mp_loc.path->full_path_r, + NULL, root_loc.oloc->file, root_loc.path->full_path_r, H5G_NAME_MOUNT) < 0) HGOTO_ERROR(H5E_FILE, H5E_MOUNT, FAIL, "unable to replace name") done: @@ -367,7 +368,8 @@ H5F_unmount(H5G_loc_t *loc, const char *name, hid_t dxpl_id) HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "unable to get path for root group") /* Search the open IDs replace names to reflect unmount operation */ - if(H5G_name_replace(H5G_UNKNOWN, &mp_loc, NULL, &root_loc, H5G_NAME_UNMOUNT) < 0) + if(H5G_name_replace(H5G_UNKNOWN, mp_loc.oloc->file, mp_loc.path->full_path_r, + NULL, root_loc.oloc->file, root_loc.path->full_path_r, H5G_NAME_UNMOUNT) < 0) HGOTO_ERROR(H5E_SYM, H5E_CANTINIT, FAIL, "unable to replace name") /* Eliminate the mount point from the table */ diff --git a/src/H5Gcompact.c b/src/H5Gcompact.c index 9dd9275..4f0f895 100644 --- a/src/H5Gcompact.c +++ b/src/H5Gcompact.c @@ -43,12 +43,10 @@ typedef struct { /* User data for deleting a link in the link messages */ typedef struct { /* downward */ - const char *name; /* Name to search for */ H5F_t *file; /* File that object header is located within */ hid_t dxpl_id; /* DXPL during insertion */ - - /* upward */ - H5G_obj_t *obj_type; /* Type of object deleted */ + H5RS_str_t *grp_full_path_r;/* Full path for group of link */ + const char *name; /* Link name to search for */ } H5G_iter_rm_t; /* User data for link message iteration when querying link info */ @@ -367,7 +365,7 @@ H5G_compact_remove_cb(const void *_mesg, unsigned UNUSED idx, void *_udata) /* If we've found the right link, get the object type */ if(HDstrcmp(lnk->name, udata->name) == 0) { /* Determine the object's type */ - if(H5G_link_obj_type(udata->file, udata->dxpl_id, lnk, udata->obj_type) < 0) + if(H5G_link_name_replace(udata->file, udata->dxpl_id, udata->grp_full_path_r, lnk->name, lnk->type, lnk->u.hard.addr) < 0) HGOTO_ERROR(H5E_SYM, H5E_CANTGET, H5O_ITER_ERROR, "unable to get object type") /* Stop the iteration, we found the correct link */ @@ -392,8 +390,8 @@ done: *------------------------------------------------------------------------- */ herr_t -H5G_compact_remove(const H5O_loc_t *oloc, const char *name, H5G_obj_t *obj_type, - hid_t dxpl_id) +H5G_compact_remove(const H5O_loc_t *oloc, hid_t dxpl_id, H5RS_str_t *grp_full_path_r, + const char *name) { H5G_iter_rm_t udata; /* Data to pass through OH iteration */ herr_t ret_value = SUCCEED; /* Return value */ @@ -404,10 +402,10 @@ H5G_compact_remove(const H5O_loc_t *oloc, const char *name, H5G_obj_t *obj_type, HDassert(name && *name); /* Initialize data to pass through object header iteration */ - udata.name = name; udata.file = oloc->file; udata.dxpl_id = dxpl_id; - udata.obj_type = obj_type; + udata.grp_full_path_r = grp_full_path_r; + udata.name = name; /* Iterate over the link messages to delete the right one */ if(H5O_remove_op(oloc, H5O_LINK_ID, H5O_FIRST, H5G_compact_remove_cb, &udata, TRUE, dxpl_id) < 0) diff --git a/src/H5Gdense.c b/src/H5Gdense.c index 4213076..c4cb814 100644 --- a/src/H5Gdense.c +++ b/src/H5Gdense.c @@ -123,9 +123,8 @@ typedef struct { hbool_t rem_from_fheap; /* Whether to remove the link from the fractal heap */ hbool_t rem_from_corder_index; /* Whether to remove the link from the creation order index */ haddr_t corder_bt2_addr; /* Address of v2 B-tree indexing creation order */ - - /* upward (for application) */ - H5G_obj_t *obj_type; /* Type of object being removed */ + H5RS_str_t *grp_full_path_r; /* Full path of group where link is removed */ + hbool_t replace_names; /* Whether to replace the names of open objects */ } H5G_bt2_ud_rem_t; /* @@ -139,9 +138,8 @@ typedef struct { hbool_t adj_link; /* Whether to adjust link count on object */ hbool_t rem_from_corder_index; /* Whether to remove the link from the creation order index */ haddr_t corder_bt2_addr; /* Address of v2 B-tree indexing creation order */ - - /* upward (for application) */ - H5G_obj_t *obj_type; /* Type of object being removed */ + H5RS_str_t *grp_full_path_r; /* Full path of group where link is removed */ + hbool_t replace_names; /* Whether to replace the names of open objects */ } H5G_fh_rem_ud1_t; /* @@ -1352,9 +1350,10 @@ H5G_dense_remove_fh_cb(const void *obj, size_t UNUSED obj_len, void *_udata) HGOTO_ERROR(H5E_SYM, H5E_CANTREMOVE, H5B2_ITER_ERROR, "unable to remove link from creation order index v2 B-tree") } /* end if */ - /* Determine the object's type */ - if(H5G_link_obj_type(udata->f, udata->dxpl_id, lnk, udata->obj_type) < 0) - HGOTO_ERROR(H5E_SYM, H5E_CANTGET, FAIL, "unable to get object type") + /* Replace open objects' names, if requested */ + if(udata->replace_names) + if(H5G_link_name_replace(udata->f, udata->dxpl_id, udata->grp_full_path_r, lnk->name, lnk->type, lnk->u.hard.addr) < 0) + HGOTO_ERROR(H5E_SYM, H5E_CANTGET, FAIL, "unable to get object type") /* Perform the deletion action on the link */ /* (call link message "delete" callback directly: *ick* - QAK) */ @@ -1370,7 +1369,7 @@ done: /*------------------------------------------------------------------------- - * Function: H5G_dense_remove_cb + * Function: H5G_dense_remove_bt2_cb * * Purpose: v2 B-tree callback for dense link storage record removal * @@ -1398,7 +1397,8 @@ H5G_dense_remove_bt2_cb(const void *_record, void *_bt2_udata) fh_udata.adj_link = bt2_udata->adj_link; fh_udata.rem_from_corder_index = bt2_udata->rem_from_corder_index; fh_udata.corder_bt2_addr = bt2_udata->corder_bt2_addr; - fh_udata.obj_type = bt2_udata->obj_type; + fh_udata.grp_full_path_r = bt2_udata->grp_full_path_r; + fh_udata.replace_names = bt2_udata->replace_names; /* Call fractal heap 'op' routine, to perform user callback */ if(H5HF_op(bt2_udata->common.fheap, bt2_udata->common.dxpl_id, record->id, @@ -1430,7 +1430,7 @@ done: */ herr_t H5G_dense_remove(H5F_t *f, hid_t dxpl_id, const H5O_linfo_t *linfo, - const char *name, H5G_obj_t *obj_type) + H5RS_str_t *grp_full_path_r, const char *name) { H5HF_t *fheap = NULL; /* Fractal heap handle */ H5G_bt2_ud_rem_t udata; /* User data for v2 B-tree record removal */ @@ -1444,7 +1444,6 @@ H5G_dense_remove(H5F_t *f, hid_t dxpl_id, const H5O_linfo_t *linfo, HDassert(f); HDassert(linfo); HDassert(name && *name); - HDassert(obj_type); /* Open the fractal heap */ if(NULL == (fheap = H5HF_open(f, dxpl_id, linfo->link_fheap_addr))) @@ -1462,7 +1461,8 @@ H5G_dense_remove(H5F_t *f, hid_t dxpl_id, const H5O_linfo_t *linfo, udata.rem_from_fheap = TRUE; udata.rem_from_corder_index = H5F_addr_defined(linfo->corder_bt2_addr); udata.corder_bt2_addr = linfo->corder_bt2_addr; - udata.obj_type = obj_type; + udata.grp_full_path_r = grp_full_path_r; + udata.replace_names = TRUE; /* Remove the record from the name index v2 B-tree */ if(H5B2_remove(f, dxpl_id, H5G_BT2_NAME, linfo->name_bt2_addr, @@ -1528,7 +1528,8 @@ H5G_dense_delete(H5F_t *f, hid_t dxpl_id, H5O_linfo_t *linfo, hbool_t adj_link) udata.adj_link = TRUE; udata.rem_from_fheap = FALSE; /* handled in "bulk" below by deleting entire heap */ udata.rem_from_corder_index = FALSE; - udata.obj_type = NULL; + udata.grp_full_path_r = NULL; + udata.replace_names = FALSE; /* Delete the name index, adjusting the ref. count on links removed */ if(H5B2_delete(f, dxpl_id, H5G_BT2_NAME, linfo->name_bt2_addr, H5G_dense_remove_bt2_cb, &udata) < 0) diff --git a/src/H5Glink.c b/src/H5Glink.c index 9144096..0bcf5b9 100644 --- a/src/H5Glink.c +++ b/src/H5Glink.c @@ -237,7 +237,7 @@ H5G_link_convert(H5F_t *f, hid_t dxpl_id, H5O_link_t *lnk, haddr_t lheap_addr, /* Object is a symbolic or hard link */ if(ent->type == H5G_CACHED_SLINK) { const char *s; /* Pointer to link value */ - const H5HL_t *heap; /* Pointer to local heap for group */ + H5HL_t *heap; /* Pointer to local heap for group */ /* Lock the local heap */ if(NULL == (heap = H5HL_protect(f, dxpl_id, lheap_addr))) @@ -437,50 +437,59 @@ done: *------------------------------------------------------------------------- */ herr_t -H5G_link_obj_type(H5F_t *file, hid_t dxpl_id, const H5O_link_t *lnk, - H5G_obj_t *obj_type) +H5G_link_name_replace(H5F_t *file, hid_t dxpl_id, H5RS_str_t *grp_full_path_r, + const char *lnk_name, H5L_type_t lnk_type, haddr_t lnk_addr) { + H5RS_str_t *obj_path_r = NULL; /* Full path for link being removed */ + H5G_obj_t obj_type; /* Type of link/object being deleted */ herr_t ret_value = SUCCEED; /* Return value */ - FUNC_ENTER_NOAPI(H5G_link_obj_type, FAIL) + FUNC_ENTER_NOAPI(H5G_link_name_replace, FAIL) /* check arguments */ HDassert(file); - HDassert(lnk); - /* Check if we are able to retrieve the object's type */ - if(obj_type) { - /* Look up the object type for each type of link */ - switch(lnk->type) { - case H5L_TYPE_HARD: - { - H5O_loc_t tmp_oloc; /* Temporary object location */ - - /* Build temporary object location */ - tmp_oloc.file = file; - tmp_oloc.addr = lnk->u.hard.addr; - - /* Get the type of the object */ - /* Note: no way to check for error :-( */ - *obj_type = H5O_obj_type(&tmp_oloc, dxpl_id); - } - break; - - case H5L_TYPE_SOFT: - /* Get the object's type */ - *obj_type = H5G_LINK; - break; - - default: /* User-defined link */ - if(lnk->type < H5L_TYPE_UD_MIN) - HGOTO_ERROR(H5E_SYM, H5E_BADVALUE, FAIL, "unknown link type") - - /* Get the object's type */ - *obj_type = H5G_UDLINK; - } /* end switch */ + /* Look up the object type for each type of link */ + switch(lnk_type) { + case H5L_TYPE_HARD: + { + H5O_loc_t tmp_oloc; /* Temporary object location */ + + /* Build temporary object location */ + tmp_oloc.file = file; + tmp_oloc.addr = lnk_addr; + + /* Get the type of the object */ + if(H5G_UNKNOWN == (obj_type = H5O_obj_type(&tmp_oloc, dxpl_id))) + HGOTO_ERROR(H5E_SYM, H5E_CANTGET, FAIL, "unable to determine object type") + } + break; + + case H5L_TYPE_SOFT: + /* Get the object's type */ + obj_type = H5G_LINK; + break; + + default: /* User-defined link */ + if(lnk_type < H5L_TYPE_UD_MIN) + HGOTO_ERROR(H5E_SYM, H5E_BADVALUE, FAIL, "unknown link type") + + /* Get the object's type */ + obj_type = H5G_UDLINK; + } /* end switch */ + + /* Search the open IDs and replace names for unlinked object */ + if(grp_full_path_r) { + obj_path_r = H5G_build_fullpath_refstr_str(grp_full_path_r, lnk_name); + if(H5G_name_replace(obj_type, file, obj_path_r, + NULL, NULL, NULL, H5G_NAME_DELETE) < 0) + HGOTO_ERROR(H5E_SYM, H5E_CANTDELETE, FAIL, "unable to replace name") } /* end if */ done: + if(obj_path_r) + H5RS_decr(obj_path_r); + FUNC_LEAVE_NOAPI(ret_value) -} /* end H5G_link_obj_type() */ +} /* end H5G_link_name_replace() */ diff --git a/src/H5Gloc.c b/src/H5Gloc.c index f33680a..3a94a79 100644 --- a/src/H5Gloc.c +++ b/src/H5Gloc.c @@ -397,72 +397,3 @@ done: FUNC_LEAVE_NOAPI(ret_value) } /* end H5G_loc_insert() */ - -/*------------------------------------------------------------------------- - * Function: H5G_loc_exists - * - * Purpose: Check if a symbol exists in a location - * - * Return: Non-negative if object exists/Negative if object doesn't exist - * - * Programmer: Quincey Koziol - * Monday, September 19, 2005 - * - *------------------------------------------------------------------------- - */ -herr_t -H5G_loc_exists(const H5G_loc_t *loc, const char *name, hid_t dxpl_id) -{ - herr_t ret_value = SUCCEED; /* Return value */ - - FUNC_ENTER_NOAPI(H5G_loc_exists, FAIL) - - /* Check args. */ - HDassert(loc); - HDassert(name && *name); - - /* Get information for object in current group */ - if(H5G_obj_lookup(loc->oloc, name, NULL, dxpl_id) < 0) - HGOTO_ERROR(H5E_SYM, H5E_NOTFOUND, FAIL, "component not found") - -done: - FUNC_LEAVE_NOAPI(ret_value) -} /* end H5G_loc_exists() */ - - -/*------------------------------------------------------------------------- - * Function: H5G_loc_remove - * - * Purpose: Remove a link from a group - * - * Return: Non-negative on success/Negative on failure - * - * Programmer: Quincey Koziol - * Monday, September 19, 2005 - * - *------------------------------------------------------------------------- - */ -herr_t -H5G_loc_remove(H5G_loc_t *grp_loc, const char *link_name, H5G_loc_t *obj_loc, hid_t dxpl_id) -{ - H5G_obj_t obj_type; /* Type of object removed */ - herr_t ret_value = SUCCEED; /* Return value */ - - FUNC_ENTER_NOAPI(H5G_loc_remove, FAIL) - - /* Check args. */ - HDassert(grp_loc); - HDassert(link_name && *link_name); - - /* Remove object from group */ - if(H5G_obj_remove(grp_loc->oloc, link_name, &obj_type, dxpl_id) < 0) - HGOTO_ERROR(H5E_SYM, H5E_NOTFOUND, FAIL, "component not found") - - /* Search the open IDs and replace names for unlinked object */ - if(H5G_name_replace(obj_type, obj_loc, NULL, NULL, H5G_NAME_DELETE) < 0) - HGOTO_ERROR(H5E_SYM, H5E_CANTDELETE, FAIL, "unable to replace name") - -done: - FUNC_LEAVE_NOAPI(ret_value) -} /* end H5G_loc_remove() */ - diff --git a/src/H5Gname.c b/src/H5Gname.c index 9b8eacf..9200241 100644 --- a/src/H5Gname.c +++ b/src/H5Gname.c @@ -41,10 +41,11 @@ /* Struct used by change name callback function */ typedef struct H5G_names_t { H5G_names_op_t op; /* Operation performed on file */ - H5G_loc_t *loc; /* [src] Location affected */ - H5F_t *top_loc_file; /* Top file in src location's mounted file hier. */ - H5G_loc_t *dst_loc; /* Destination location */ - H5RS_str_t *dst_name; /* Name of object relative to destination location */ + H5F_t *src_file; /* Top file in src location's mounted file hier. */ + H5RS_str_t *src_full_path_r; /* Source location's full path */ + H5F_t *dst_file; /* Destination location's file */ + H5RS_str_t *dst_full_path_r; /* Destination location's full path */ + H5RS_str_t *new_name_r; /* Name of object relative to destination location */ } H5G_names_t; /* Info to pass to the iteration function when building name */ @@ -77,7 +78,6 @@ H5FL_DEFINE_STATIC(haddr_t); static htri_t H5G_common_path(const H5RS_str_t *fullpath_r, const H5RS_str_t *prefix_r); static H5RS_str_t *H5G_build_fullpath(const char *prefix, const char *name); static H5RS_str_t *H5G_build_fullpath_refstr_refstr(const H5RS_str_t *prefix_r, const H5RS_str_t *name_r); -static H5RS_str_t *H5G_build_fullpath_refstr_str(H5RS_str_t *path_r, const char *name); static herr_t H5G_name_move_path(H5RS_str_t **path_r_ptr, const char *full_suffix, const char *src_path, const char *dst_path); static int H5G_name_replace_cb(void *obj_ptr, hid_t obj_id, void *key); @@ -222,7 +222,7 @@ done: * *------------------------------------------------------------------------- */ -static H5RS_str_t * +H5RS_str_t * H5G_build_fullpath_refstr_str(H5RS_str_t *prefix_r, const char *name) { const char *prefix; /* Pointer to raw string for path */ @@ -706,14 +706,14 @@ H5G_name_replace_cb(void *obj_ptr, hid_t obj_id, void *key) /* Find the top file in object's mount hier. */ if(oloc->file->mtab.parent) { /* Check if object is in child file (for mount & unmount operations) */ - if(names->dst_loc && oloc->file->shared == names->dst_loc->oloc->file->shared) + if(names->dst_file && oloc->file->shared == names->dst_file->shared) obj_in_child = TRUE; /* Find the "top" file in the chain of mounted files */ top_obj_file = oloc->file->mtab.parent; while(top_obj_file->mtab.parent != NULL) { /* Check if object is in child mount hier. (for mount & unmount operations) */ - if(names->dst_loc && top_obj_file->shared == names->dst_loc->oloc->file->shared) + if(names->dst_file && top_obj_file->shared == names->dst_file->shared) obj_in_child = TRUE; top_obj_file = top_obj_file->mtab.parent; @@ -723,11 +723,11 @@ H5G_name_replace_cb(void *obj_ptr, hid_t obj_id, void *key) top_obj_file = oloc->file; /* Check if object is in top of child mount hier. (for mount & unmount operations) */ - if(names->dst_loc && top_obj_file->shared == names->dst_loc->oloc->file->shared) + if(names->dst_file && top_obj_file->shared == names->dst_file->shared) obj_in_child = TRUE; /* Check if the object is in same file mount hier. */ - if(top_obj_file->shared != names->top_loc_file->shared) + if(top_obj_file->shared != names->src_file->shared) HGOTO_DONE(SUCCEED) /* No need to look at object, it's path is already invalid */ switch(names->op) { @@ -745,7 +745,7 @@ H5G_name_replace_cb(void *obj_ptr, hid_t obj_id, void *key) /* Get pointers to paths of interest */ full_path = H5RS_get_str(obj_path->full_path_r); - src_path = H5RS_get_str(names->loc->path->full_path_r); + src_path = H5RS_get_str(names->src_full_path_r); /* Build new full path */ @@ -768,8 +768,8 @@ H5G_name_replace_cb(void *obj_ptr, hid_t obj_id, void *key) else { /* Check if the source is along the entry's path */ /* (But not actually the entry itself) */ - if(H5G_common_path(obj_path->full_path_r, names->loc->path->full_path_r) && - H5RS_cmp(obj_path->full_path_r, names->loc->path->full_path_r)) { + if(H5G_common_path(obj_path->full_path_r, names->src_full_path_r) && + H5RS_cmp(obj_path->full_path_r, names->src_full_path_r)) { /* Hide the user path */ (obj_path->obj_hidden)++; } /* end if */ @@ -789,7 +789,7 @@ H5G_name_replace_cb(void *obj_ptr, hid_t obj_id, void *key) /* Get pointers to paths of interest */ full_path = H5RS_get_str(obj_path->full_path_r); - src_path = H5RS_get_str(names->loc->path->full_path_r); + src_path = H5RS_get_str(names->src_full_path_r); /* Construct full path suffix */ full_suffix = full_path + HDstrlen(src_path); @@ -816,8 +816,8 @@ H5G_name_replace_cb(void *obj_ptr, hid_t obj_id, void *key) } /* end if */ else { /* Check if file being unmounted was hiding the object */ - if(H5G_common_path(obj_path->full_path_r, names->loc->path->full_path_r) && - H5RS_cmp(obj_path->full_path_r, names->loc->path->full_path_r)) { + if(H5G_common_path(obj_path->full_path_r, names->src_full_path_r) && + H5RS_cmp(obj_path->full_path_r, names->src_full_path_r)) { /* Un-hide the user path */ (obj_path->obj_hidden)--; } /* end if */ @@ -830,7 +830,7 @@ H5G_name_replace_cb(void *obj_ptr, hid_t obj_id, void *key) */ case H5G_NAME_DELETE: /* Check if the location being unlinked is in the path for the current object */ - if(H5G_common_path(obj_path->full_path_r, names->loc->path->full_path_r)) { + if(H5G_common_path(obj_path->full_path_r, names->src_full_path_r)) { /* Free paths for object */ H5G_name_free(obj_path); } /* end if */ @@ -842,7 +842,7 @@ H5G_name_replace_cb(void *obj_ptr, hid_t obj_id, void *key) */ case H5G_NAME_MOVE: /* H5Gmove case, check for relative names case */ /* Check if the src object moved is in the current object's path */ - if(H5G_common_path(obj_path->full_path_r, names->loc->path->full_path_r)) { + if(H5G_common_path(obj_path->full_path_r, names->src_full_path_r)) { const char *full_path; /* Full path of current object */ const char *full_suffix; /* Suffix of full path, after src_path */ char *new_full_path; /* New full path of object */ @@ -853,19 +853,19 @@ H5G_name_replace_cb(void *obj_ptr, hid_t obj_id, void *key) const char *dst_path; /* Full path of destination object */ /* Sanity check */ - HDassert(*(H5RS_get_str(names->loc->path->full_path_r)) == '/'); - HDassert(names->dst_name); + HDassert(*(H5RS_get_str(names->src_full_path_r)) == '/'); + HDassert(names->new_name_r); /* Make certain that the source and destination names are full (not relative) paths */ - src_path_r = H5RS_dup(names->loc->path->full_path_r); - if(*(H5RS_get_str(names->dst_name)) != '/') { - HDassert(names->dst_loc && names->dst_loc->path); + src_path_r = H5RS_dup(names->src_full_path_r); + if(*(H5RS_get_str(names->new_name_r)) != '/') { + HDassert(names->dst_full_path_r); /* Create reference counted string for full dst path */ - if((dst_path_r = H5G_build_fullpath_refstr_refstr(names->dst_loc->path->full_path_r, names->dst_name)) == NULL) + if((dst_path_r = H5G_build_fullpath_refstr_refstr(names->dst_full_path_r, names->new_name_r)) == NULL) HGOTO_ERROR(H5E_SYM, H5E_PATH, FAIL, "can't build destination path name") } /* end if */ else - dst_path_r = H5RS_dup(names->dst_name); + dst_path_r = H5RS_dup(names->new_name_r); /* Get pointers to paths of interest */ full_path = H5RS_get_str(obj_path->full_path_r); @@ -916,10 +916,11 @@ done: * Function: H5G_name_replace * * Purpose: Search the list of open IDs and replace names according to a - * particular operation. The operation occured on the LOC - * entry. The new name (if there is one) is DST_NAME. - * Additional entry location information (currently only needed - * for the 'move' operation) is passed in DST_LOC. + * particular operation. The operation occured on the + * SRC_FILE/SRC_FULL_PATH_R object. The new name (if there is + * one) is NEW_NAME_R. Additional entry location information + * (currently only needed for the 'move' operation) is passed in + * DST_FILE/DST_FULL_PATH_R. * * Return: Success: 0, Failure: -1 * @@ -930,18 +931,18 @@ done: *------------------------------------------------------------------------- */ herr_t -H5G_name_replace(H5G_obj_t type, H5G_loc_t *loc, - H5RS_str_t *dst_name, H5G_loc_t *dst_loc, H5G_names_op_t op) +H5G_name_replace(H5G_obj_t type, H5F_t *src_file, H5RS_str_t *src_full_path_r, + H5RS_str_t *new_name_r, H5F_t *dst_file, H5RS_str_t *dst_full_path_r, H5G_names_op_t op) { herr_t ret_value = SUCCEED; FUNC_ENTER_NOAPI(H5G_name_replace, FAIL) /* Check arguments */ - HDassert(loc && loc->path); + HDassert(src_file); /* Check if the object we are manipulating has a path */ - if(loc->path->full_path_r) { + if(src_full_path_r) { unsigned search_group = 0; /* Flag to indicate that groups are to be searched */ unsigned search_dataset = 0; /* Flag to indicate that datasets are to be searched */ unsigned search_datatype = 0; /* Flag to indicate that datatypes are to be searched */ @@ -995,23 +996,17 @@ H5G_name_replace(H5G_obj_t type, H5G_loc_t *loc, /* Check if we need to operate on the objects affected */ if(search_group || search_dataset || search_datatype) { H5G_names_t names; /* Structure to hold operation information for callback */ - H5F_t *top_loc_file; /* Top file in src location's mounted file hier. */ /* Find top file in src location's mount hierarchy */ - if(loc->oloc->file->mtab.parent) { - /* Find the "top" file in the chain of mounted files for the location */ - top_loc_file = loc->oloc->file->mtab.parent; - while(top_loc_file->mtab.parent != NULL) - top_loc_file = top_loc_file->mtab.parent; - } /* end if */ - else - top_loc_file = loc->oloc->file; + while(src_file->mtab.parent) + src_file = src_file->mtab.parent; /* Set up common information for callback */ - names.loc = loc; - names.top_loc_file = top_loc_file; - names.dst_loc = dst_loc; - names.dst_name = dst_name; + names.src_file = src_file; + names.src_full_path_r = src_full_path_r; + names.dst_file = dst_file; + names.dst_full_path_r = dst_full_path_r; + names.new_name_r = new_name_r; names.op = op; /* Search through group IDs */ diff --git a/src/H5Gnode.c b/src/H5Gnode.c index 98123e8..5eb3660 100644 --- a/src/H5Gnode.c +++ b/src/H5Gnode.c @@ -268,33 +268,35 @@ H5G_node_debug_key(FILE *stream, H5F_t *f, hid_t dxpl_id, int indent, int fwidth { const H5G_node_key_t *key = (const H5G_node_key_t *) _key; const H5G_bt_ud0_t *udata = (const H5G_bt_ud0_t *) _udata; - const H5HL_t *heap = NULL; - const char *s; - herr_t ret_value=SUCCEED; /* Return value */ + herr_t ret_value = SUCCEED; /* Return value */ - FUNC_ENTER_NOAPI_NOINIT(H5G_node_debug_key); - assert (key); + FUNC_ENTER_NOAPI_NOINIT(H5G_node_debug_key) + + HDassert(key); HDfprintf(stream, "%*s%-*s %u\n", indent, "", fwidth, "Heap offset:", (unsigned)key->offset); if(udata->heap_addr != 0) { + H5HL_t *heap; + const char *s; + HDfprintf(stream, "%*s%-*s ", indent, "", fwidth, "Name:"); - if (NULL == (heap = H5HL_protect(f, dxpl_id, udata->heap_addr))) - HGOTO_ERROR(H5E_SYM, H5E_NOTFOUND, FAIL, "unable to protect symbol name"); + if(NULL == (heap = H5HL_protect(f, dxpl_id, udata->heap_addr))) + HGOTO_ERROR(H5E_SYM, H5E_NOTFOUND, FAIL, "unable to protect symbol name") s = H5HL_offset_into(f, heap, key->offset); - HDfprintf (stream, "%s\n", s); + HDfprintf(stream, "%s\n", s); - if (H5HL_unprotect(f, dxpl_id, heap, udata->heap_addr, H5AC__NO_FLAGS_SET) < 0) - HGOTO_ERROR(H5E_SYM, H5E_PROTECT, FAIL, "unable to unprotect symbol name"); + if(H5HL_unprotect(f, dxpl_id, heap, udata->heap_addr, H5AC__NO_FLAGS_SET) < 0) + HGOTO_ERROR(H5E_SYM, H5E_PROTECT, FAIL, "unable to unprotect symbol name") } /* end if */ else HDfprintf(stream, "%*s%-*s ", indent, "", fwidth, "Cannot get name; heap address not specified\n"); done: - FUNC_LEAVE_NOAPI(ret_value); + FUNC_LEAVE_NOAPI(ret_value) } /* end H5G_node_debug_key() */ @@ -779,16 +781,16 @@ H5G_node_cmp2(H5F_t *f, hid_t dxpl_id, void *_lt_key, void *_udata, void *_rt_ke H5G_bt_ud0_t *udata = (H5G_bt_ud0_t *) _udata; H5G_node_key_t *lt_key = (H5G_node_key_t *) _lt_key; H5G_node_key_t *rt_key = (H5G_node_key_t *) _rt_key; - const H5HL_t *heap = NULL; + H5HL_t *heap = NULL; const char *s1, *s2; const char *base; /* Base of heap */ - int ret_value; + int ret_value; - FUNC_ENTER_NOAPI_NOINIT(H5G_node_cmp2); + FUNC_ENTER_NOAPI_NOINIT(H5G_node_cmp2) - assert(udata); - assert(lt_key); - assert(rt_key); + HDassert(udata); + HDassert(lt_key); + HDassert(rt_key); /* Get base address of heap */ if(NULL == (heap = H5HL_protect(f, dxpl_id, udata->heap_addr))) @@ -808,7 +810,7 @@ done: HDONE_ERROR(H5E_SYM, H5E_PROTECT, FAIL, "unable to unprotect symbol name") FUNC_LEAVE_NOAPI(ret_value) -} +} /* H5G_node_cmp2() */ /*------------------------------------------------------------------------- @@ -844,35 +846,35 @@ H5G_node_cmp3(H5F_t *f, hid_t dxpl_id, void *_lt_key, void *_udata, void *_rt_ke H5G_bt_ud0_t *udata = (H5G_bt_ud0_t *) _udata; H5G_node_key_t *lt_key = (H5G_node_key_t *) _lt_key; H5G_node_key_t *rt_key = (H5G_node_key_t *) _rt_key; - const H5HL_t *heap = NULL; + H5HL_t *heap = NULL; const char *s; const char *base; /* Base of heap */ int ret_value=0; /* Return value */ - FUNC_ENTER_NOAPI_NOINIT(H5G_node_cmp3); + FUNC_ENTER_NOAPI_NOINIT(H5G_node_cmp3) /* Get base address of heap */ if(NULL == (heap = H5HL_protect(f, dxpl_id, udata->heap_addr))) - HGOTO_ERROR(H5E_SYM, H5E_NOTFOUND, FAIL, "unable to protect symbol name"); + HGOTO_ERROR(H5E_SYM, H5E_NOTFOUND, FAIL, "unable to protect symbol name") base = H5HL_offset_into(f, heap, (size_t)0); /* left side */ - s=base+lt_key->offset; - if (HDstrcmp(udata->name, s) <= 0) + s = base + lt_key->offset; + if(HDstrcmp(udata->name, s) <= 0) HGOTO_DONE(-1); /* right side */ - s=base+rt_key->offset; - if (HDstrcmp(udata->name, s) > 0) + s = base + rt_key->offset; + if(HDstrcmp(udata->name, s) > 0) HGOTO_DONE(1); done: - if (heap && H5HL_unprotect(f, dxpl_id, heap, udata->heap_addr, H5AC__NO_FLAGS_SET) < 0) - HDONE_ERROR(H5E_SYM, H5E_PROTECT, FAIL, "unable to unprotect symbol name"); + if(heap && H5HL_unprotect(f, dxpl_id, heap, udata->heap_addr, H5AC__NO_FLAGS_SET) < 0) + HDONE_ERROR(H5E_SYM, H5E_PROTECT, FAIL, "unable to unprotect symbol name") - FUNC_LEAVE_NOAPI(ret_value); -} + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5G_node_cmp3() */ /*------------------------------------------------------------------------- @@ -907,7 +909,7 @@ H5G_node_found(H5F_t *f, hid_t dxpl_id, haddr_t addr, const void UNUSED *_lt_key { H5G_bt_ud3_t *udata = (H5G_bt_ud3_t *) _udata; H5G_node_t *sn = NULL; - const H5HL_t *heap = NULL; + H5HL_t *heap = NULL; unsigned lt = 0, idx = 0, rt; int cmp = 1; const char *s; @@ -1015,7 +1017,7 @@ H5G_node_insert(H5F_t *f, hid_t dxpl_id, haddr_t addr, H5G_bt_ud1_t *udata = (H5G_bt_ud1_t *) _udata; H5G_node_t *sn = NULL, *snrt = NULL; unsigned sn_flags = H5AC__NO_FLAGS_SET, snrt_flags = H5AC__NO_FLAGS_SET; - const H5HL_t *heap = NULL; + H5HL_t *heap = NULL; const char *s; const char *base; /* Base of heap */ unsigned lt = 0, rt; /* Binary search cntrs */ @@ -1197,11 +1199,10 @@ H5G_node_remove(H5F_t *f, hid_t dxpl_id, haddr_t addr, void *_lt_key/*in,out*/, H5G_bt_ud2_t *udata = (H5G_bt_ud2_t *)_udata; H5G_node_t *sn = NULL; unsigned sn_flags = H5AC__NO_FLAGS_SET; - const H5HL_t *heap = NULL; + H5HL_t *heap = NULL; + unsigned heap_flags = H5AC__NO_FLAGS_SET; unsigned lt = 0, rt, idx = 0; int cmp = 1; - const char *s = NULL; - const char *base; /* Base of heap */ H5B_ins_t ret_value = H5B_INS_ERROR; FUNC_ENTER_NOAPI_NOINIT(H5G_node_remove) @@ -1219,13 +1220,17 @@ H5G_node_remove(H5F_t *f, hid_t dxpl_id, haddr_t addr, void *_lt_key/*in,out*/, /* "Normal" removal of a single entry from the symbol table node */ if(udata->common.name != NULL) { - size_t len = 0; - hbool_t found; /* Indicate that the string was found */ + H5L_type_t lnk_type; /* Type of link being removed */ + haddr_t lnk_addr; /* Address of object (for hard link) */ + size_t len; /* Length of string in local heap */ + const char *base; /* Base of heap */ + const char *s; /* Pointer to string in local heap */ - /* Get base address of heap */ + /* Lock the heap down */ if(NULL == (heap = H5HL_protect(f, dxpl_id, udata->common.heap_addr))) - HGOTO_ERROR(H5E_SYM, H5E_NOTFOUND, H5B_INS_ERROR, "unable to protect symbol name") + HGOTO_ERROR(H5E_SYM, H5E_CANTPROTECT, H5B_INS_ERROR, "unable to protect local heap") + /* Get base address of heap */ base = H5HL_offset_into(f, heap, (size_t)0); /* Find the name with a binary search */ @@ -1240,83 +1245,53 @@ H5G_node_remove(H5F_t *f, hid_t dxpl_id, haddr_t addr, void *_lt_key/*in,out*/, lt = idx + 1; } /* end while */ - if(H5HL_unprotect(f, dxpl_id, heap, udata->common.heap_addr, H5AC__NO_FLAGS_SET) < 0) - HGOTO_ERROR(H5E_SYM, H5E_PROTECT, H5B_INS_ERROR, "unable to unprotect symbol name") - heap = NULL; base = NULL; - if(cmp) - HGOTO_ERROR(H5E_SYM, H5E_NOTFOUND, H5B_INS_ERROR, "not found") + HGOTO_ERROR(H5E_SYM, H5E_NOTFOUND, H5B_INS_ERROR, "name not found") - switch(sn->entry[idx].type) - { - case H5G_CACHED_SLINK: + if(sn->entry[idx].type == H5G_CACHED_SLINK) { /* Set the type of the link removed */ - *(udata->obj_type) = H5G_LINK; - - /* Remove the symbolic link value */ - if(NULL == (heap = H5HL_protect(f, dxpl_id, udata->common.heap_addr))) - HGOTO_ERROR(H5E_SYM, H5E_NOTFOUND, H5B_INS_ERROR, "unable to protect symbol name") + lnk_type = H5L_TYPE_SOFT; + lnk_addr = HADDR_UNDEF; + /* Remove the soft link's value from the local heap */ s = H5HL_offset_into(f, heap, sn->entry[idx].cache.slink.lval_offset); if(s) { len = HDstrlen(s) + 1; - found = 1; + if(H5HL_remove(f, dxpl_id, heap, sn->entry[idx].cache.slink.lval_offset, len, &heap_flags) < 0) + HGOTO_ERROR(H5E_SYM, H5E_CANTDELETE, H5B_INS_ERROR, "unable to remove soft link from local heap") } /* end if */ - else - found = 0; - - if(H5HL_unprotect(f, dxpl_id, heap, udata->common.heap_addr, H5AC__NO_FLAGS_SET) < 0) - HGOTO_ERROR(H5E_SYM, H5E_PROTECT, H5B_INS_ERROR, "unable to unprotect symbol name") - heap = NULL; s = NULL; - - if(found) - H5HL_remove(f, dxpl_id, udata->common.heap_addr, sn->entry[idx].cache.slink.lval_offset, len); - - H5E_clear_stack(NULL); /* no big deal */ - break; - - default: - { - H5O_loc_t tmp_oloc; /* Temporary object location */ - - /* Build temporary object location */ - tmp_oloc.file = f; - HDassert(H5F_addr_defined(sn->entry[idx].header)); - tmp_oloc.addr = sn->entry[idx].header; + } /* end if */ + else { + /* Set the link information */ + lnk_type = H5L_TYPE_HARD; + HDassert(H5F_addr_defined(sn->entry[idx].header)); + lnk_addr = sn->entry[idx].header; + } /* end else */ - /* Get the type of the object */ - if((*(udata->obj_type) = H5O_obj_type(&tmp_oloc, dxpl_id)) == H5G_UNKNOWN) - HGOTO_ERROR(H5E_SYM, H5E_CANTGET, H5B_INS_ERROR, "unable to determine object type") + /* Get a pointer to the name of the link */ + if(NULL == (s = H5HL_offset_into(f, heap, sn->entry[idx].name_off))) + HGOTO_ERROR(H5E_SYM, H5E_CANTGET, FAIL, "unable to get link name") - /* Decrement the reference count, if requested */ - if(udata->adj_link) - if(H5O_link(&tmp_oloc, -1, dxpl_id) < 0) - HGOTO_ERROR(H5E_SYM, H5E_CANTINIT, H5B_INS_ERROR, "unable to decrement object link count") - break; - } - } /* end switch */ + /* Get the object's type */ + if(H5G_link_name_replace(f, dxpl_id, udata->grp_full_path_r, s, lnk_type, lnk_addr) < 0) + HGOTO_ERROR(H5E_SYM, H5E_CANTGET, FAIL, "unable to get object type") - /* Remove the name from the local heap */ - if(NULL == (heap = H5HL_protect(f, dxpl_id, udata->common.heap_addr))) - HGOTO_ERROR(H5E_SYM, H5E_NOTFOUND, H5B_INS_ERROR, "unable to protect symbol name") + /* Decrement the ref. count for hard links, if requested */ + if(lnk_type == H5L_TYPE_HARD && udata->adj_link) { + H5O_loc_t tmp_oloc; /* Temporary object location */ - s = H5HL_offset_into(f, heap, sn->entry[idx].name_off); + /* Build temporary object location */ + tmp_oloc.file = f; + tmp_oloc.addr = lnk_addr; - if(s) { - len = HDstrlen(s) + 1; - found = 1; + if(H5O_link(&tmp_oloc, -1, dxpl_id) < 0) + HGOTO_ERROR(H5E_SYM, H5E_CANTINIT, H5B_INS_ERROR, "unable to decrement object link count") } /* end if */ - else - found = 0; - - if(H5HL_unprotect(f, dxpl_id, heap, udata->common.heap_addr, H5AC__NO_FLAGS_SET) < 0) - HGOTO_ERROR(H5E_SYM, H5E_PROTECT, H5B_INS_ERROR, "unable to unprotect symbol name") - heap = NULL; s = NULL; - if(found) - H5HL_remove(f, dxpl_id, udata->common.heap_addr, sn->entry[idx].name_off, len); - - H5E_clear_stack(NULL); /* no big deal */ + /* Remove the link's name from the local heap */ + len = HDstrlen(s) + 1; + if(H5HL_remove(f, dxpl_id, heap, sn->entry[idx].name_off, len, &heap_flags) < 0) + HGOTO_ERROR(H5E_SYM, H5E_CANTDELETE, H5B_INS_ERROR, "unable to remove link name from local heap") /* Remove the entry from the symbol table node */ if(1 == sn->nsyms) { @@ -1415,7 +1390,10 @@ H5G_node_remove(H5F_t *f, hid_t dxpl_id, haddr_t addr, void *_lt_key/*in,out*/, done: if(sn && H5AC_unprotect(f, dxpl_id, H5AC_SNODE, addr, sn, sn_flags) < 0) - HDONE_ERROR(H5E_SYM, H5E_PROTECT, H5B_INS_ERROR, "unable to release symbol table node") + HDONE_ERROR(H5E_SYM, H5E_CANTUNPROTECT, H5B_INS_ERROR, "unable to release symbol table node") + + if(heap && H5HL_unprotect(f, dxpl_id, heap, udata->common.heap_addr, heap_flags) < 0) + HDONE_ERROR(H5E_SYM, H5E_CANTUNPROTECT, H5B_INS_ERROR, "unable to unprotect local heap") FUNC_LEAVE_NOAPI(ret_value) } /* end H5G_node_remove() */ @@ -1440,7 +1418,7 @@ H5G_node_iterate(H5F_t *f, hid_t dxpl_id, const void UNUSED *_lt_key, haddr_t ad { H5G_bt_it_ud1_t *udata = (H5G_bt_it_ud1_t *)_udata; H5G_node_t *sn = NULL; - const H5HL_t *heap = NULL; + H5HL_t *heap = NULL; unsigned nsyms; /* # of symbols in node */ H5G_entry_t *ents = NULL; /* Copy of entries in this node */ unsigned u; /* Local index variable */ @@ -1799,7 +1777,7 @@ H5G_node_copy(H5F_t *f, hid_t dxpl_id, const void UNUSED *_lt_key, haddr_t addr, H5G_bt_it_cpy_t *udata = (H5G_bt_it_cpy_t *)_udata; const H5O_loc_t *src_oloc = udata->src_oloc; H5O_copy_t *cpy_info = udata->cpy_info; - const H5HL_t *heap = NULL; + H5HL_t *heap = NULL; H5G_node_t *sn = NULL; unsigned int i; /* Local index variable */ int ret_value = H5B_ITER_CONT; @@ -1935,24 +1913,24 @@ done: */ herr_t H5G_node_debug(H5F_t *f, hid_t dxpl_id, haddr_t addr, FILE * stream, int indent, - int fwidth, haddr_t heap) + int fwidth, haddr_t heap_addr) { H5G_node_t *sn = NULL; const char *s; - const H5HL_t *heap_ptr = NULL; + H5HL_t *heap = NULL; unsigned u; - herr_t ret_value=SUCCEED; /* Return value */ + herr_t ret_value = SUCCEED; /* Return value */ - FUNC_ENTER_NOAPI(H5G_node_debug, FAIL); + FUNC_ENTER_NOAPI(H5G_node_debug, FAIL) /* * Check arguments. */ - assert(f); - assert(H5F_addr_defined(addr)); - assert(stream); - assert(indent >= 0); - assert(fwidth >= 0); + HDassert(f); + HDassert(H5F_addr_defined(addr)); + HDassert(stream); + HDassert(indent >= 0); + HDassert(fwidth >= 0); /* * If we couldn't load the symbol table node, then try loading the @@ -1962,7 +1940,7 @@ H5G_node_debug(H5F_t *f, hid_t dxpl_id, haddr_t addr, FILE * stream, int indent, H5G_bt_ud0_t udata; /*data to pass through B-tree */ H5E_clear_stack(NULL); /* discard that error */ - udata.heap_addr = heap; + udata.heap_addr = heap_addr; if ( H5B_debug(f, dxpl_id, addr, stream, indent, fwidth, H5B_SNODE, &udata) < 0) HGOTO_ERROR(H5E_SYM, H5E_CANTLOAD, FAIL, "unable to debug B-tree node"); HGOTO_DONE(SUCCEED); @@ -1979,31 +1957,31 @@ H5G_node_debug(H5F_t *f, hid_t dxpl_id, haddr_t addr, FILE * stream, int indent, indent += 3; fwidth = MAX(0, fwidth - 3); - for (u = 0; u < sn->nsyms; u++) { + for(u = 0; u < sn->nsyms; u++) { fprintf(stream, "%*sSymbol %u:\n", indent - 3, "", u); - if (heap>0 && H5F_addr_defined(heap)) { - if (NULL == (heap_ptr = H5HL_protect(f, dxpl_id, heap))) + if(heap_addr > 0 && H5F_addr_defined(heap_addr)) { + if(NULL == (heap = H5HL_protect(f, dxpl_id, heap_addr))) HGOTO_ERROR(H5E_SYM, H5E_NOTFOUND, FAIL, "unable to protect symbol name"); - s = H5HL_offset_into(f, heap_ptr, sn->entry[u].name_off); + s = H5HL_offset_into(f, heap, sn->entry[u].name_off); - if (s) + if(s) fprintf(stream, "%*s%-*s `%s'\n", indent, "", fwidth, "Name:", s); - if (H5HL_unprotect(f, dxpl_id, heap_ptr, heap, FALSE) < 0) - HGOTO_ERROR(H5E_SYM, H5E_PROTECT, FAIL, "unable to unprotect symbol name"); - heap_ptr=NULL; s=NULL; + if(H5HL_unprotect(f, dxpl_id, heap, heap_addr, FALSE) < 0) + HGOTO_ERROR(H5E_SYM, H5E_PROTECT, FAIL, "unable to unprotect symbol name") + heap = NULL; s = NULL; } else fprintf(stream, "%*s%-*s\n", indent, "", fwidth, "Warning: Invalid heap address given, name not displayed!"); - H5G_ent_debug(f, dxpl_id, sn->entry + u, stream, indent, fwidth, heap); - } + H5G_ent_debug(f, dxpl_id, sn->entry + u, stream, indent, fwidth, heap_addr); + } /* end for */ done: - if (sn && H5AC_unprotect(f, dxpl_id, H5AC_SNODE, addr, sn, H5AC__NO_FLAGS_SET) < 0) - HDONE_ERROR(H5E_SYM, H5E_PROTECT, FAIL, "unable to release symbol table node"); + if(sn && H5AC_unprotect(f, dxpl_id, H5AC_SNODE, addr, sn, H5AC__NO_FLAGS_SET) < 0) + HDONE_ERROR(H5E_SYM, H5E_PROTECT, FAIL, "unable to release symbol table node") - FUNC_LEAVE_NOAPI(ret_value); -} + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5G_node_debug() */ diff --git a/src/H5Gobj.c b/src/H5Gobj.c index c450e46..5e68d6b 100644 --- a/src/H5Gobj.c +++ b/src/H5Gobj.c @@ -823,7 +823,7 @@ done: *------------------------------------------------------------------------- */ herr_t -H5G_obj_remove(H5O_loc_t *oloc, const char *name, H5G_obj_t *obj_type, hid_t dxpl_id) +H5G_obj_remove(H5O_loc_t *oloc, H5RS_str_t *grp_full_path_r, const char *name, hid_t dxpl_id) { H5O_linfo_t linfo; /* Link info message */ hbool_t use_old_format; /* Whether to use 'old format' (symbol table) for deletion or not */ @@ -834,7 +834,6 @@ H5G_obj_remove(H5O_loc_t *oloc, const char *name, H5G_obj_t *obj_type, hid_t dxp /* Sanity check */ HDassert(oloc); HDassert(name && *name); - HDassert(obj_type); /* Attempt to get the link info for this group */ if(H5O_read(oloc, H5O_LINFO_ID, 0, &linfo, dxpl_id)) { @@ -844,12 +843,12 @@ H5G_obj_remove(H5O_loc_t *oloc, const char *name, H5G_obj_t *obj_type, hid_t dxp /* Check for dense or compact storage */ if(H5F_addr_defined(linfo.link_fheap_addr)) { /* Remove object from the dense link storage */ - if(H5G_dense_remove(oloc->file, dxpl_id, &linfo, name, obj_type) < 0) + if(H5G_dense_remove(oloc->file, dxpl_id, &linfo, grp_full_path_r, name) < 0) HGOTO_ERROR(H5E_SYM, H5E_NOTFOUND, FAIL, "can't remove object") } /* end if */ else { /* Remove object from the link messages */ - if(H5G_compact_remove(oloc, name, obj_type, dxpl_id) < 0) + if(H5G_compact_remove(oloc, dxpl_id, grp_full_path_r, name) < 0) HGOTO_ERROR(H5E_SYM, H5E_NOTFOUND, FAIL, "can't remove object") } /* end else */ } /* end if */ @@ -861,7 +860,7 @@ H5G_obj_remove(H5O_loc_t *oloc, const char *name, H5G_obj_t *obj_type, hid_t dxp use_old_format = TRUE; /* Remove object from the symbol table */ - if(H5G_stab_remove(oloc, name, obj_type, dxpl_id) < 0) + if(H5G_stab_remove(oloc, dxpl_id, grp_full_path_r, name) < 0) HGOTO_ERROR(H5E_SYM, H5E_NOTFOUND, FAIL, "can't remove object") } /* end else */ diff --git a/src/H5Gpkg.h b/src/H5Gpkg.h index 47342dd..6aabb33 100644 --- a/src/H5Gpkg.h +++ b/src/H5Gpkg.h @@ -174,9 +174,7 @@ typedef struct H5G_bt_ud2_t { /* downward */ H5G_bt_ud_common_t common; /* Common info for B-tree user data (must be first) */ hbool_t adj_link; /* Whether to adjust the link count on objects */ - - /* upward */ - H5G_obj_t *obj_type; /*member type to be returned */ + H5RS_str_t *grp_full_path_r; /* Full path of group where link is removed */ } H5G_bt_ud2_t; /* Typedef for B-tree 'find' operation */ @@ -379,8 +377,8 @@ H5_DLL ssize_t H5G_stab_get_name_by_idx(H5O_loc_t *oloc, H5_iter_order_t order, hsize_t n, char* name, size_t size, hid_t dxpl_id); H5_DLL H5G_obj_t H5G_stab_get_type_by_idx(H5O_loc_t *oloc, hsize_t idx, hid_t dxpl_id); -H5_DLL herr_t H5G_stab_remove(H5O_loc_t *oloc, const char *name, - H5G_obj_t *obj_type, hid_t dxpl_id); +H5_DLL herr_t H5G_stab_remove(H5O_loc_t *oloc, hid_t dxpl_id, + H5RS_str_t *grp_full_path_r, const char *name); H5_DLL herr_t H5G_stab_lookup(H5O_loc_t *grp_oloc, const char *name, H5O_link_t *lnk, hid_t dxpl_id); H5_DLL herr_t H5G_stab_lookup_by_idx(H5O_loc_t *grp_oloc, H5_iter_order_t order, @@ -423,8 +421,9 @@ H5_DLL herr_t H5G_link_copy_file(H5F_t *dst_file, hid_t dxpl_id, const H5O_link_t *_src_lnk, const H5O_loc_t *src_oloc, H5O_link_t *dst_lnk, H5O_copy_t *cpy_info); H5_DLL herr_t H5G_link_release_table(H5G_link_table_t *ltable); -H5_DLL herr_t H5G_link_obj_type(H5F_t *file, hid_t dxpl_id, const H5O_link_t *lnk, - H5G_obj_t *obj_type); +H5_DLL herr_t H5G_link_name_replace(H5F_t *file, hid_t dxpl_id, + H5RS_str_t *grp_full_path_r, const char *lnk_name, H5L_type_t lnk_type, + haddr_t lnk_addr); /* Functions that understand "compact" link storage */ H5_DLL herr_t H5G_compact_insert(H5O_loc_t *grp_oloc, H5O_link_t *obj_lnk, @@ -434,8 +433,8 @@ H5_DLL ssize_t H5G_compact_get_name_by_idx(H5O_loc_t *oloc, hid_t dxpl_id, hsize_t idx, char *name, size_t size); H5_DLL H5G_obj_t H5G_compact_get_type_by_idx(H5O_loc_t *oloc, hid_t dxpl_id, const H5O_linfo_t *linfo, hsize_t idx); -H5_DLL herr_t H5G_compact_remove(const H5O_loc_t *oloc, const char *name, - H5G_obj_t *obj_type, hid_t dxpl_id); +H5_DLL herr_t H5G_compact_remove(const H5O_loc_t *oloc, hid_t dxpl_id, + H5RS_str_t *grp_full_path_r, const char *name); H5_DLL herr_t H5G_compact_iterate(H5O_loc_t *oloc, hid_t dxpl_id, const H5O_linfo_t *linfo, H5_iter_order_t order, hid_t gid, hbool_t lib_internal, int skip, int *last_obj, H5G_link_iterate_t op, void *op_data); @@ -465,7 +464,7 @@ H5_DLL ssize_t H5G_dense_get_name_by_idx(H5F_t *f, hid_t dxpl_id, H5_DLL H5G_obj_t H5G_dense_get_type_by_idx(H5F_t *f, hid_t dxpl_id, H5O_linfo_t *linfo, hsize_t idx); H5_DLL herr_t H5G_dense_remove(H5F_t *f, hid_t dxpl_id, const H5O_linfo_t *linfo, - const char *name, H5G_obj_t *obj_type); + H5RS_str_t *grp_full_path_r, const char *name); H5_DLL herr_t H5G_dense_delete(H5F_t *f, hid_t dxpl_id, H5O_linfo_t *linfo, hbool_t adj_link); @@ -483,8 +482,8 @@ H5_DLL ssize_t H5G_obj_get_name_by_idx(H5O_loc_t *oloc, H5L_index_t idx_type, H5_iter_order_t order, hsize_t n, char* name, size_t size, hid_t dxpl_id); H5_DLL H5G_obj_t H5G_obj_get_type_by_idx(H5O_loc_t *oloc, hsize_t idx, hid_t dxpl_id); -H5_DLL herr_t H5G_obj_remove(H5O_loc_t *oloc, const char *name, - H5G_obj_t *obj_type, hid_t dxpl_id); +H5_DLL herr_t H5G_obj_remove(H5O_loc_t *oloc, H5RS_str_t *grp_full_path_r, + const char *name, hid_t dxpl_id); H5_DLL herr_t H5G_obj_lookup(H5O_loc_t *grp_oloc, const char *name, H5O_link_t *lnk, hid_t dxpl_id); H5_DLL herr_t H5G_obj_lookup_by_idx(H5O_loc_t *grp_oloc, H5L_index_t idx_type, @@ -495,6 +494,7 @@ H5_DLL herr_t H5G_obj_lookup_by_idx(H5O_loc_t *grp_oloc, H5L_index_t idx_type, */ H5_DLL herr_t H5G_name_init(H5G_name_t *name, const char *path); H5_DLL herr_t H5G_name_set(H5G_name_t *loc, H5G_name_t *obj, const char *name); +H5_DLL H5RS_str_t *H5G_build_fullpath_refstr_str(H5RS_str_t *path_r, const char *name); /* * These functions operate on group "locations" @@ -502,9 +502,6 @@ H5_DLL herr_t H5G_name_set(H5G_name_t *loc, H5G_name_t *obj, const char *name); H5_DLL herr_t H5G_loc_copy(H5G_loc_t *dst, H5G_loc_t *src, H5_copy_depth_t depth); H5_DLL herr_t H5G_loc_insert(H5G_loc_t *grp_loc, const char *name, H5G_loc_t *obj_loc, hid_t dxpl_id); -H5_DLL herr_t H5G_loc_exists(const H5G_loc_t *loc, const char *name, hid_t dxpl_id); -H5_DLL herr_t H5G_loc_remove(H5G_loc_t *grp_loc, const char *name, - H5G_loc_t *obj_loc, hid_t dxpl_id); /* Testing functions */ #ifdef H5G_TESTING diff --git a/src/H5Gprivate.h b/src/H5Gprivate.h index 6552177..69a448a 100644 --- a/src/H5Gprivate.h +++ b/src/H5Gprivate.h @@ -177,8 +177,9 @@ H5_DLL herr_t H5G_obj_ent_encode(H5F_t *f, uint8_t **pp, /* * These functions operate on group hierarchy names. */ -H5_DLL herr_t H5G_name_replace(H5G_obj_t type, H5G_loc_t *loc, - H5RS_str_t *dst_name, H5G_loc_t *dst_loc, H5G_names_op_t op); +H5_DLL herr_t H5G_name_replace(H5G_obj_t type, H5F_t *src_file, + H5RS_str_t *src_full_path_r, H5RS_str_t *new_name, H5F_t *dst_file, + H5RS_str_t *dst_full_path_r, H5G_names_op_t op); H5_DLL herr_t H5G_name_reset(H5G_name_t *name); H5_DLL herr_t H5G_name_copy(H5G_name_t *dst, const H5G_name_t *src, H5_copy_depth_t depth); H5_DLL herr_t H5G_name_free(H5G_name_t *name); diff --git a/src/H5Gstab.c b/src/H5Gstab.c index 4a0d46a..ec813d8 100644 --- a/src/H5Gstab.c +++ b/src/H5Gstab.c @@ -293,7 +293,8 @@ done: *------------------------------------------------------------------------- */ herr_t -H5G_stab_remove(H5O_loc_t *loc, const char *name, H5G_obj_t *obj_type, hid_t dxpl_id) +H5G_stab_remove(H5O_loc_t *loc, hid_t dxpl_id, H5RS_str_t *grp_full_path_r, + const char *name) { H5O_stab_t stab; /*symbol table message */ H5G_bt_ud2_t udata; /*data to pass through B-tree */ @@ -312,7 +313,7 @@ H5G_stab_remove(H5O_loc_t *loc, const char *name, H5G_obj_t *obj_type, hid_t dxp udata.common.name = name; udata.common.heap_addr = stab.heap_addr; udata.adj_link = TRUE; - udata.obj_type = obj_type; + udata.grp_full_path_r = grp_full_path_r; /* Remove from symbol table */ if(H5B_remove(loc->file, dxpl_id, H5B_SNODE, stab.btree_addr, &udata) < 0) @@ -485,7 +486,7 @@ static herr_t H5G_stab_get_name_by_idx_cb(const H5G_entry_t *ent, void *_udata) { H5G_bt_it_idx1_t *udata = (H5G_bt_it_idx1_t *)_udata; - const H5HL_t *heap = NULL; /* Pointer to local heap for group */ + H5HL_t *heap = NULL; /* Pointer to local heap for group */ size_t name_off; /* Offset of name in heap */ const char *name; /* Pointer to name string in heap */ herr_t ret_value = SUCCEED; /* Return value */ @@ -803,7 +804,7 @@ static herr_t H5G_stab_lookup_by_idx_cb(const H5G_entry_t *ent, void *_udata) { H5G_bt_it_idx3_t *udata = (H5G_bt_it_idx3_t *)_udata; - const H5HL_t *heap; /* Pointer to local heap for group */ + H5HL_t *heap; /* Pointer to local heap for group */ size_t name_off; /* Offset of name in heap */ const char *name; /* Pointer to name string in heap */ size_t name_len; /* Length of link name */ @@ -809,27 +809,25 @@ done: * wendling@ncsa.uiuc.edu * Sept. 17, 2003 * - * Modifications: - * *------------------------------------------------------------------------- */ -const H5HL_t * +H5HL_t * H5HL_protect(H5F_t *f, hid_t dxpl_id, haddr_t addr) { - H5HL_t *ret_value = NULL; + H5HL_t *ret_value; - FUNC_ENTER_NOAPI(H5HL_protect, NULL); + FUNC_ENTER_NOAPI(H5HL_protect, NULL) /* check arguments */ - assert(f); - assert(H5F_addr_defined(addr)); + HDassert(f); + HDassert(H5F_addr_defined(addr)); - if (NULL == (ret_value = H5AC_protect(f, dxpl_id, H5AC_LHEAP, addr, NULL, NULL, H5AC_READ))) - HGOTO_ERROR(H5E_HEAP, H5E_CANTLOAD, NULL, "unable to load heap"); + if(NULL == (ret_value = H5AC_protect(f, dxpl_id, H5AC_LHEAP, addr, NULL, NULL, H5AC_READ))) + HGOTO_ERROR(H5E_HEAP, H5E_CANTLOAD, NULL, "unable to load heap") done: - FUNC_LEAVE_NOAPI(ret_value); -} + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5HL_protect() */ /*------------------------------------------------------------------------- @@ -876,36 +874,26 @@ H5HL_offset_into(H5F_t *f, const H5HL_t *heap, size_t offset) * wendling@ncsa.uiuc.edu * Sept. 17, 2003 * - * Modifications: - * - * John Mainzer - 6/8/05/ - * Modified function to use the new dirtied parmeter of - * H5AC_unprotect(), which allows management of the is_dirty - * field of the cache info to be moved into the cache code. - * - * This required the addition of the heap_dirtied parameter - * to the function's parameter list. - * *------------------------------------------------------------------------- */ herr_t -H5HL_unprotect(H5F_t *f, hid_t dxpl_id, const H5HL_t *heap, haddr_t addr, unsigned heap_flags) +H5HL_unprotect(H5F_t *f, hid_t dxpl_id, H5HL_t *heap, haddr_t addr, unsigned heap_flags) { herr_t ret_value = SUCCEED; - FUNC_ENTER_NOAPI(H5HL_unprotect, FAIL); + FUNC_ENTER_NOAPI(H5HL_unprotect, FAIL) /* check arguments */ - assert(f); - assert(heap); - assert(H5F_addr_defined(addr)); + HDassert(f); + HDassert(heap); + HDassert(H5F_addr_defined(addr)); if(H5AC_unprotect(f, dxpl_id, H5AC_LHEAP, addr, (void *)heap, heap_flags) != SUCCEED) - HGOTO_ERROR(H5E_HEAP, H5E_PROTECT, FAIL, "unable to release object header"); + HGOTO_ERROR(H5E_HEAP, H5E_PROTECT, FAIL, "unable to release object header") done: - FUNC_LEAVE_NOAPI(ret_value); -} + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5HL_unprotect() */ /*------------------------------------------------------------------------- @@ -1276,34 +1264,30 @@ done: *------------------------------------------------------------------------- */ herr_t -H5HL_remove(H5F_t *f, hid_t dxpl_id, haddr_t addr, size_t offset, size_t size) +H5HL_remove(H5F_t *f, hid_t dxpl_id, H5HL_t *heap, size_t offset, size_t size, + unsigned *heap_flags) { - H5HL_t *heap = NULL; - unsigned heap_flags = H5AC__NO_FLAGS_SET; - H5HL_free_t *fl = NULL, *fl2 = NULL; + H5HL_free_t *fl = NULL; herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_NOAPI(H5HL_remove, FAIL); /* check arguments */ HDassert(f); - HDassert(H5F_addr_defined(addr)); + HDassert(heap); HDassert(size > 0); HDassert(offset == H5HL_ALIGN(offset)); if(0 == (f->intent & H5F_ACC_RDWR)) HGOTO_ERROR(H5E_HEAP, H5E_WRITEERROR, FAIL, "no write intent on file") - size = H5HL_ALIGN (size); - - if(NULL == (heap = H5AC_protect(f, dxpl_id, H5AC_LHEAP, addr, NULL, NULL, H5AC_WRITE))) - HGOTO_ERROR(H5E_HEAP, H5E_PROTECT, FAIL, "unable to load heap") + size = H5HL_ALIGN(size); HDassert(offset < heap->heap_alloc); HDassert(offset + size <= heap->heap_alloc); fl = heap->freelist; - heap_flags |= H5AC__DIRTIED_FLAG; + *heap_flags |= H5AC__DIRTIED_FLAG; /* * Check if this chunk can be prepended or appended to an already @@ -1311,6 +1295,8 @@ H5HL_remove(H5F_t *f, hid_t dxpl_id, haddr_t addr, size_t offset, size_t size) * that all three chunks can be combined into one. */ while(fl) { + H5HL_free_t *fl2 = NULL; + if((offset + size) == fl->offset) { fl->offset = offset; fl->size += size; @@ -1404,9 +1390,6 @@ H5HL_remove(H5F_t *f, hid_t dxpl_id, haddr_t addr, size_t offset, size_t size) } /* end if */ done: - if(heap && H5AC_unprotect(f, dxpl_id, H5AC_LHEAP, addr, heap, heap_flags) != SUCCEED) - HDONE_ERROR(H5E_HEAP, H5E_PROTECT, FAIL, "unable to release object header") - FUNC_LEAVE_NOAPI(ret_value); } /* end H5HL_remove() */ diff --git a/src/H5HLprivate.h b/src/H5HLprivate.h index 6adc2a5..13912ce 100644 --- a/src/H5HLprivate.h +++ b/src/H5HLprivate.h @@ -62,13 +62,14 @@ typedef struct H5HL_t H5HL_t; * Library prototypes... */ H5_DLL herr_t H5HL_create(H5F_t *f, hid_t dxpl_id, size_t size_hint, haddr_t *addr/*out*/); -H5_DLL const H5HL_t *H5HL_protect(H5F_t *f, hid_t dxpl_id, haddr_t addr); +H5_DLL H5HL_t *H5HL_protect(H5F_t *f, hid_t dxpl_id, haddr_t addr); H5_DLL void *H5HL_offset_into(H5F_t *f, const H5HL_t *heap, size_t offset); -H5_DLL herr_t H5HL_unprotect(H5F_t *f, hid_t dxpl_id, const H5HL_t *heap, +H5_DLL herr_t H5HL_remove(H5F_t *f, hid_t dxpl_id, H5HL_t *heap, size_t offset, + size_t size, unsigned *heap_flags); +H5_DLL herr_t H5HL_unprotect(H5F_t *f, hid_t dxpl_id, H5HL_t *heap, haddr_t addr, unsigned heap_flags); H5_DLL size_t H5HL_insert(H5F_t *f, hid_t dxpl_id, haddr_t addr, size_t size, const void *buf); -H5_DLL herr_t H5HL_remove(H5F_t *f, hid_t dxpl_id, haddr_t addr, size_t offset, size_t size); H5_DLL herr_t H5HL_delete(H5F_t *f, hid_t dxpl_id, haddr_t addr); H5_DLL herr_t H5HL_get_size(H5F_t *f, hid_t dxpl_id, haddr_t addr, size_t *size); @@ -1954,16 +1954,20 @@ done: *------------------------------------------------------------------------- */ static herr_t -H5L_delete_cb(H5G_loc_t *grp_loc/*in*/, const char *name, const H5O_link_t UNUSED *lnk, - H5G_loc_t *obj_loc, void *_udata/*in,out*/, H5G_own_loc_t *own_loc/*out*/) +H5L_delete_cb(H5G_loc_t *grp_loc/*in*/, const char *name, const H5O_link_t *lnk, + H5G_loc_t UNUSED *obj_loc, void *_udata/*in,out*/, H5G_own_loc_t *own_loc/*out*/) { H5L_trav_rm_t *udata = (H5L_trav_rm_t *)_udata; /* User data passed in */ herr_t ret_value = SUCCEED; FUNC_ENTER_NOAPI_NOINIT(H5L_delete_cb) + /* Check if the group resolved to a valid link */ + if(grp_loc == NULL) + HGOTO_ERROR(H5E_SYM, H5E_NOTFOUND, FAIL, "group doesn't exist") + /* Check if the name in this group resolved to a valid link */ - if(obj_loc == NULL) + if(name == NULL) HGOTO_ERROR(H5E_SYM, H5E_NOTFOUND, FAIL, "name doesn't exist") /* Check for removing '.' */ @@ -1971,7 +1975,7 @@ H5L_delete_cb(H5G_loc_t *grp_loc/*in*/, const char *name, const H5O_link_t UNUSE HGOTO_ERROR(H5E_SYM, H5E_CANTDELETE, FAIL, "can't delete self") /* Remove the link from the group */ - if(H5G_loc_remove(grp_loc, name, obj_loc, udata->dxpl_id) < 0) + if(H5G_obj_remove(grp_loc->oloc, grp_loc->path->full_path_r, name, udata->dxpl_id) < 0) HGOTO_ERROR(H5E_SYM, H5E_CANTDELETE, FAIL, "unable to remove link from group") done: @@ -2139,7 +2143,6 @@ H5L_move_dest_cb(H5G_loc_t *grp_loc/*in*/, const char *name, H5G_own_loc_t *own_loc/*out*/) { H5L_trav_mv2_t *udata = (H5L_trav_mv2_t *)_udata; /* User data passed in */ - H5RS_str_t *dst_name_r = NULL; /* Ref-counted version of dest name */ H5G_t *grp=NULL; /* H5G_t for this group, opened to pass to user callback */ hid_t grp_id = FAIL; /* Id for this group (passed to user callback */ H5G_loc_t temp_loc; /* For UD callback */ @@ -2230,8 +2233,6 @@ done: /* Indicate that this callback didn't take ownership of the group * * location for the object */ *own_loc = H5G_OWN_NONE; - if(dst_name_r) - H5RS_decr(dst_name_r); FUNC_LEAVE_NOAPI(ret_value) } /* end H5L_move_dest_cb() */ @@ -2258,7 +2259,6 @@ H5L_move_cb(H5G_loc_t *grp_loc/*in*/, const char *name, const H5O_link_t *lnk, H5L_trav_mv_t *udata = (H5L_trav_mv_t *)_udata; /* User data passed in */ H5L_trav_mv2_t udata_out; /* User data for H5L_move_dest_cb traversal */ H5G_obj_t type; /* Type of object being moved */ - H5RS_str_t *dst_name_r = NULL; /* Ref-counted version of dest name */ char * orig_name = NULL; /* The name of the link in this group */ hbool_t link_copied = FALSE; /* Has udata_out.lnk been allocated? */ herr_t ret_value = SUCCEED; /* Return value */ @@ -2305,7 +2305,7 @@ H5L_move_cb(H5G_loc_t *grp_loc/*in*/, const char *name, const H5O_link_t *lnk, udata_out.copy = udata->copy; udata_out.dxpl_id = udata->dxpl_id; - /* Remember the link's original name (in case it's changed by H5G_name_replace) */ + /* Keep a copy of link's name (it's "owned" by the H5G_traverse() routine) */ orig_name = H5MM_xstrdup(name); /* Insert the link into its new location */ @@ -2315,15 +2315,24 @@ H5L_move_cb(H5G_loc_t *grp_loc/*in*/, const char *name, const H5O_link_t *lnk, /* If this is a move and not a copy operation, change the object's name and remove the old link */ if(!udata->copy) { + H5RS_str_t *dst_name_r; /* Ref-counted version of dest name */ + /* Fix names up */ dst_name_r = H5RS_wrap(udata->dst_name); HDassert(dst_name_r); - if(H5G_name_replace(type, obj_loc, dst_name_r, udata->dst_loc, H5G_NAME_MOVE) < 0) - HGOTO_ERROR(H5E_SYM, H5E_CANTINIT, FAIL, "unable to replace name ") + if(H5G_name_replace(type, obj_loc->oloc->file, obj_loc->path->full_path_r, + dst_name_r, udata->dst_loc->oloc->file, udata->dst_loc->path->full_path_r, + H5G_NAME_MOVE) < 0) { + H5RS_decr(dst_name_r); + HGOTO_ERROR(H5E_SYM, H5E_CANTINIT, FAIL, "unable to replace name") + } /* end if */ /* Remove the old link */ - if(H5G_obj_remove(grp_loc->oloc, orig_name, &type, udata->dxpl_id) < 0) + if(H5G_obj_remove(grp_loc->oloc, grp_loc->path->full_path_r, orig_name, udata->dxpl_id) < 0) { + H5RS_decr(dst_name_r); HGOTO_ERROR(H5E_SYM, H5E_NOTFOUND, FAIL, "unable to remove old name") + } /* end if */ + H5RS_decr(dst_name_r); } /* end if */ diff --git a/src/H5Oefl.c b/src/H5Oefl.c index d222dde..bf7647c 100644 --- a/src/H5Oefl.c +++ b/src/H5Oefl.c @@ -88,23 +88,23 @@ H5O_efl_decode(H5F_t *f, hid_t dxpl_id, const uint8_t *p) H5O_efl_t *mesg = NULL; int version; const char *s = NULL; - const H5HL_t *heap; + H5HL_t *heap; size_t u; /* Local index variable */ void *ret_value; /* Return value */ - FUNC_ENTER_NOAPI_NOINIT(H5O_efl_decode); + FUNC_ENTER_NOAPI_NOINIT(H5O_efl_decode) /* Check args */ - assert(f); - assert(p); + HDassert(f); + HDassert(p); - if (NULL==(mesg = H5MM_calloc(sizeof(H5O_efl_t)))) - HGOTO_ERROR (H5E_RESOURCE, H5E_NOSPACE, NULL, "memory allocation failed"); + if(NULL == (mesg = H5MM_calloc(sizeof(H5O_efl_t)))) + HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, NULL, "memory allocation failed") /* Version */ version = *p++; - if (version!=H5O_EFL_VERSION) - HGOTO_ERROR(H5E_OHDR, H5E_CANTLOAD, NULL, "bad version number for external file list message"); + if(version != H5O_EFL_VERSION) + HGOTO_ERROR(H5E_OHDR, H5E_CANTLOAD, NULL, "bad version number for external file list message") /* Reserved */ p += 3; @@ -119,56 +119,58 @@ H5O_efl_decode(H5F_t *f, hid_t dxpl_id, const uint8_t *p) H5F_addr_decode(f, &p, &(mesg->heap_addr)); #ifndef NDEBUG - assert (H5F_addr_defined(mesg->heap_addr)); + HDassert(H5F_addr_defined(mesg->heap_addr)); - if (NULL == (heap = H5HL_protect(f, dxpl_id, mesg->heap_addr))) + if(NULL == (heap = H5HL_protect(f, dxpl_id, mesg->heap_addr))) HGOTO_ERROR(H5E_SYM, H5E_NOTFOUND, NULL, "unable to read protect link value") s = H5HL_offset_into(f, heap, 0); - assert (s && !*s); + HDassert(s && !*s); - if (H5HL_unprotect(f, dxpl_id, heap, mesg->heap_addr, H5AC__NO_FLAGS_SET) < 0) + if(H5HL_unprotect(f, dxpl_id, heap, mesg->heap_addr, H5AC__NO_FLAGS_SET) < 0) HGOTO_ERROR(H5E_SYM, H5E_NOTFOUND, NULL, "unable to read unprotect link value") + heap = NULL; #endif /* Decode the file list */ - mesg->slot = H5MM_calloc(mesg->nalloc*sizeof(H5O_efl_entry_t)); - if (NULL==mesg->slot) - HGOTO_ERROR (H5E_RESOURCE, H5E_NOSPACE, NULL, "memory allocation failed"); - for (u=0; u<mesg->nused; u++) { + mesg->slot = H5MM_calloc(mesg->nalloc * sizeof(H5O_efl_entry_t)); + if(NULL == mesg->slot) + HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, NULL, "memory allocation failed") + + if(NULL == (heap = H5HL_protect(f, dxpl_id, mesg->heap_addr))) + HGOTO_ERROR(H5E_SYM, H5E_NOTFOUND, NULL, "unable to read protect link value") + for(u = 0; u < mesg->nused; u++) { /* Name */ H5F_DECODE_LENGTH (f, p, mesg->slot[u].name_offset); - if (NULL == (heap = H5HL_protect(f, dxpl_id, mesg->heap_addr))) - HGOTO_ERROR(H5E_SYM, H5E_NOTFOUND, NULL, "unable to read protect link value") - s = H5HL_offset_into(f, heap, mesg->slot[u].name_offset); - assert (s && *s); + HDassert(s && *s); mesg->slot[u].name = H5MM_xstrdup (s); - assert(mesg->slot[u].name); - - if (H5HL_unprotect(f, dxpl_id, heap, mesg->heap_addr, H5AC__NO_FLAGS_SET) < 0) - HGOTO_ERROR(H5E_SYM, H5E_NOTFOUND, NULL, "unable to read unprotect link value") + HDassert(mesg->slot[u].name); /* File offset */ H5F_DECODE_LENGTH (f, p, mesg->slot[u].offset); /* Size */ H5F_DECODE_LENGTH (f, p, mesg->slot[u].size); - assert (mesg->slot[u].size>0); - } + HDassert(mesg->slot[u].size > 0); + } /* end for */ + + if(H5HL_unprotect(f, dxpl_id, heap, mesg->heap_addr, H5AC__NO_FLAGS_SET) < 0) + HGOTO_ERROR(H5E_SYM, H5E_NOTFOUND, NULL, "unable to read unprotect link value") + heap = NULL; /* Set return value */ - ret_value=mesg; + ret_value = mesg; done: - if(ret_value==NULL) { - if(mesg!=NULL) - H5MM_xfree (mesg); - } /* end if */ - FUNC_LEAVE_NOAPI(ret_value); -} + if(ret_value == NULL) + if(mesg != NULL) + H5MM_xfree(mesg); + + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5O_efl_decode() */ /*------------------------------------------------------------------------- diff --git a/src/H5Oshared.c b/src/H5Oshared.c index e90031d..00a1091 100644 --- a/src/H5Oshared.c +++ b/src/H5Oshared.c @@ -590,6 +590,54 @@ done: /*------------------------------------------------------------------------- + * Function: H5O_shared_pre_copy_file + * + * Purpose: Perform any necessary actions before copying message between + * files for shared messages. + * + * Return: Success: Non-negative + * + * Failure: Negative + * + * Programmer: Peter Cao + * Saturday, February 11, 2006 + * + *------------------------------------------------------------------------- + */ +static herr_t +H5O_shared_pre_copy_file(H5F_t *file_src, const H5O_msg_class_t *type, + void *native_src, hbool_t *deleted, const H5O_copy_t *cpy_info, + void *udata) +{ + H5O_shared_t *shared_src = (H5O_shared_t *)native_src; + void *mesg_native = NULL; + herr_t ret_value = SUCCEED; /* Return value */ + + FUNC_ENTER_NOAPI_NOINIT(H5O_shared_pre_copy_file) + + /* check args */ + HDassert(file_src); + HDassert(type); + + if(type->pre_copy_file) { + /* Go get the actual shared message */ + if(NULL == (mesg_native = H5O_shared_read(file_src, H5AC_dxpl_id, shared_src, type, NULL))) + HGOTO_ERROR(H5E_OHDR, H5E_READERROR, FAIL, "unable to load object header") + + /* Perform "pre copy" operation on messge */ + if((type->pre_copy_file)(file_src, type, mesg_native, deleted, cpy_info, udata) < 0) + HGOTO_ERROR(H5E_OHDR, H5E_CANTINIT, FAIL, "unable to perform 'pre copy' operation on message") + } /* end of if */ + +done: + if(mesg_native) + H5O_free_real(type, mesg_native); + + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5O_shared_pre_copy_file() */ + + +/*------------------------------------------------------------------------- * Function: H5O_shared_copy_file * * Purpose: Copies a message from _MESG to _DEST in file @@ -679,54 +727,6 @@ done: /*------------------------------------------------------------------------- - * Function: H5O_shared_pre_copy_file - * - * Purpose: Perform any necessary actions before copying message between - * files for shared messages. - * - * Return: Success: Non-negative - * - * Failure: Negative - * - * Programmer: Peter Cao - * Saturday, February 11, 2006 - * - *------------------------------------------------------------------------- - */ -static herr_t -H5O_shared_pre_copy_file(H5F_t *file_src, const H5O_msg_class_t *type, - void *native_src, hbool_t *deleted, const H5O_copy_t *cpy_info, - void *udata) -{ - H5O_shared_t *shared_src = (H5O_shared_t *)native_src; - void *mesg_native = NULL; - herr_t ret_value = SUCCEED; /* Return value */ - - FUNC_ENTER_NOAPI_NOINIT(H5O_shared_pre_copy_file) - - /* check args */ - HDassert(file_src); - HDassert(type); - - if(type->pre_copy_file) { - /* Go get the actual shared message */ - if(NULL == (mesg_native = H5O_shared_read(file_src, H5AC_dxpl_id, shared_src, type, NULL))) - HGOTO_ERROR(H5E_OHDR, H5E_READERROR, FAIL, "unable to load object header") - - /* Perform "pre copy" operation on messge */ - if((type->pre_copy_file)(file_src, type, mesg_native, deleted, cpy_info, udata) < 0) - HGOTO_ERROR(H5E_OHDR, H5E_CANTINIT, FAIL, "unable to perform 'pre copy' operation on message") - } /* end of if */ - -done: - if(mesg_native) - H5O_free_real(type, mesg_native); - - FUNC_LEAVE_NOAPI(ret_value) -} /* end H5O_shared_pre_copy_file() */ - - -/*------------------------------------------------------------------------- * Function: H5O_shared_debug * * Purpose: Prints debugging info for the message diff --git a/src/H5Ostab.c b/src/H5Ostab.c index 3582620..701667a 100644 --- a/src/H5Ostab.c +++ b/src/H5Ostab.c @@ -310,7 +310,7 @@ done: *------------------------------------------------------------------------- */ static void * -H5O_stab_copy_file(H5F_t *file_src, const H5O_msg_class_t *mesg_type, +H5O_stab_copy_file(H5F_t *file_src, const H5O_msg_class_t UNUSED *mesg_type, void *native_src, H5F_t *file_dst, hid_t dxpl_id, H5O_copy_t UNUSED *cpy_info, void UNUSED *udata) { |