diff options
-rw-r--r-- | fortran/src/H5_f.c | 12 | ||||
-rw-r--r-- | fortran/src/H5f90global.f90 | 2 | ||||
-rw-r--r-- | fortran/test/tH5G.f90 | 1 | ||||
-rw-r--r-- | src/H5Fmount.c | 16 | ||||
-rw-r--r-- | src/H5G.c | 42 | ||||
-rw-r--r-- | src/H5Gcompact.c | 4 | ||||
-rw-r--r-- | src/H5Gdense.c | 4 | ||||
-rw-r--r-- | src/H5Gdeprec.c | 42 | ||||
-rw-r--r-- | src/H5Glink.c | 42 | ||||
-rw-r--r-- | src/H5Gname.c | 179 | ||||
-rw-r--r-- | src/H5Gnode.c | 54 | ||||
-rw-r--r-- | src/H5Gpkg.h | 3 | ||||
-rw-r--r-- | src/H5Gprivate.h | 9 | ||||
-rw-r--r-- | src/H5Gpublic.h | 43 | ||||
-rw-r--r-- | src/H5Gstab.c | 2 | ||||
-rw-r--r-- | src/H5L.c | 44 | ||||
-rw-r--r-- | src/H5O.c | 6 | ||||
-rw-r--r-- | src/H5Opkg.h | 6 | ||||
-rw-r--r-- | src/H5trace.c | 25 | ||||
-rw-r--r-- | test/titerate.c | 6 | ||||
-rw-r--r-- | tools/h5diff/h5diffgentest.c | 2 | ||||
-rw-r--r-- | tools/h5diff/ph5diff_main.c | 2 | ||||
-rw-r--r-- | tools/h5ls/h5ls.c | 6 | ||||
-rw-r--r-- | tools/h5repack/h5repack_copy.c | 134 | ||||
-rw-r--r-- | tools/h5repack/h5repack_refs.c | 4 | ||||
-rw-r--r-- | tools/h5repack/h5repack_verify.c | 30 | ||||
-rw-r--r-- | tools/h5stat/h5stat.c | 224 | ||||
-rw-r--r-- | tools/lib/h5diff.c | 19 | ||||
-rw-r--r-- | tools/lib/h5diff.h | 2 | ||||
-rw-r--r-- | tools/lib/h5diff_util.c | 31 | ||||
-rw-r--r-- | tools/lib/ph5diff.h | 2 |
31 files changed, 479 insertions, 519 deletions
diff --git a/fortran/src/H5_f.c b/fortran/src/H5_f.c index d96865f..5464786 100644 --- a/fortran/src/H5_f.c +++ b/fortran/src/H5_f.c @@ -298,11 +298,13 @@ nh5init_flags_c( int_f *h5d_flags, int_f *h5f_flags, * H5G flags */ - h5g_flags[0] = H5G_UNKNOWN; - h5g_flags[1] = H5G_GROUP; - h5g_flags[2] = H5G_DATASET; - h5g_flags[3] = H5G_TYPE; - h5g_flags[4] = H5G_LINK; + h5g_flags[0] = H5O_TYPE_UNKNOWN; + h5g_flags[1] = H5O_TYPE_GROUP; + h5g_flags[2] = H5O_TYPE_DATASET; + h5g_flags[3] = H5O_TYPE_NAMED_DATATYPE; +/* This value can no longer be returned and all these flags should be updated + * to reflect the refinements between links and objects. -QAK */ +/* h5g_flags[4] = H5G_LINK; */ h5g_flags[5] = H5L_TYPE_ERROR; h5g_flags[6] = H5L_TYPE_HARD; h5g_flags[7] = H5L_TYPE_SOFT; diff --git a/fortran/src/H5f90global.f90 b/fortran/src/H5f90global.f90 index 0cb0268..0b429e4 100644 --- a/fortran/src/H5f90global.f90 +++ b/fortran/src/H5f90global.f90 @@ -205,6 +205,7 @@ INTEGER :: H5G_GROUP_F INTEGER :: H5G_DATASET_F INTEGER :: H5G_TYPE_F +! XXX: Fix problems with H5G_LINK_F! - QAK INTEGER :: H5G_LINK_F INTEGER :: H5G_LINK_ERROR_F INTEGER :: H5G_LINK_HARD_F @@ -214,6 +215,7 @@ EQUIVALENCE(H5G_flags(2), H5G_GROUP_F) EQUIVALENCE(H5G_flags(3), H5G_DATASET_F) EQUIVALENCE(H5G_flags(4), H5G_TYPE_F) +! XXX: Fix problems with H5G_LINK_F! - QAK EQUIVALENCE(H5G_flags(5), H5G_LINK_F) EQUIVALENCE(H5G_flags(6), H5G_LINK_ERROR_F) EQUIVALENCE(H5G_flags(7), H5G_LINK_HARD_F) diff --git a/fortran/test/tH5G.f90 b/fortran/test/tH5G.f90 index 40263d6..437970f 100644 --- a/fortran/test/tH5G.f90 +++ b/fortran/test/tH5G.f90 @@ -151,6 +151,7 @@ ! ! CALL h5gget_obj_info_idx_f(file_id, linkname1, 2, name, obj_type, error) ! CALL check("h5gget_obj_info_idx_f", error, total_error) +! XXX: Fix problems with H5G_LINK_F! - QAK ! if (obj_type .ne. H5G_LINK_F) then ! write(*,*) "got object ", name, " type error ", obj_type ! total_error = total_error +1 diff --git a/src/H5Fmount.c b/src/H5Fmount.c index 538204c..470d323 100644 --- a/src/H5Fmount.c +++ b/src/H5Fmount.c @@ -235,8 +235,9 @@ 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.oloc->file, mp_loc.path->full_path_r, - NULL, root_loc.oloc->file, root_loc.path->full_path_r, H5G_NAME_MOUNT) < 0) + if(H5G_name_replace(NULL, H5G_NAME_MOUNT, mp_loc.oloc->file, + mp_loc.path->full_path_r, root_loc.oloc->file, root_loc.path->full_path_r, + dxpl_id) < 0) HGOTO_ERROR(H5E_FILE, H5E_MOUNT, FAIL, "unable to replace name") done: @@ -244,12 +245,12 @@ done: if(mount_point) { if(H5G_close(mount_point) < 0) HDONE_ERROR(H5E_FILE, H5E_CANTCLOSEOBJ, FAIL, "unable to close mounted group") - } + } /* end if */ else { if(H5G_loc_free(&mp_loc) < 0) HDONE_ERROR(H5E_SYM, H5E_CANTRELEASE, FAIL, "unable to free mount location") - } - } + } /* end else */ + } /* end if */ FUNC_LEAVE_NOAPI(ret_value) } /* end H5F_mount() */ @@ -369,8 +370,9 @@ 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.oloc->file, mp_loc.path->full_path_r, - NULL, root_loc.oloc->file, root_loc.path->full_path_r, H5G_NAME_UNMOUNT) < 0) + if(H5G_name_replace(NULL, H5G_NAME_UNMOUNT, mp_loc.oloc->file, + mp_loc.path->full_path_r, root_loc.oloc->file, root_loc.path->full_path_r, + dxpl_id) < 0) HGOTO_ERROR(H5E_SYM, H5E_CANTINIT, FAIL, "unable to replace name") /* Eliminate the mount point from the table */ @@ -1366,48 +1366,6 @@ H5G_fileof(H5G_t *grp) /*------------------------------------------------------------------------- - * Function: H5G_map_obj_type - * - * Purpose: Maps the object type to the older "group" object type - * - * Return: Object type (can't fail) - * - * Programmer: Quincey Koziol - * Tuesday, November 21, 2006 - * - *------------------------------------------------------------------------- - */ -H5G_obj_t -H5G_map_obj_type(H5O_type_t obj_type) -{ - H5G_obj_t ret_value; /* Return value */ - - /* Use FUNC_ENTER_NOAPI_NOINIT_NOFUNC here to avoid performance issues */ - FUNC_ENTER_NOAPI_NOINIT_NOFUNC(H5G_map_obj_type) - - /* Map object type to older "group" object type */ - switch(obj_type) { - case H5O_TYPE_GROUP: - ret_value = H5G_GROUP; - break; - - case H5O_TYPE_DATASET: - ret_value = H5G_DATASET; - break; - - case H5O_TYPE_NAMED_DATATYPE: - ret_value = H5G_TYPE; - break; - - default: - ret_value = H5G_UNKNOWN; - } /* end switch */ - - FUNC_LEAVE_NOAPI(ret_value) -} /* end H5G_map_obj_type() */ - - -/*------------------------------------------------------------------------- * Function: H5G_free_grp_name * * Purpose: Free the 'ID to name' buffers. diff --git a/src/H5Gcompact.c b/src/H5Gcompact.c index da19ee5..042d29a 100644 --- a/src/H5Gcompact.c +++ b/src/H5Gcompact.c @@ -288,8 +288,8 @@ H5G_compact_remove_common_cb(const void *_mesg, unsigned UNUSED idx, void *_udat /* 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_name_replace(udata->file, udata->dxpl_id, udata->grp_full_path_r, lnk->name, lnk->type, lnk->u.hard.addr) < 0) + /* Replace path names for link being removed */ + if(H5G_link_name_replace(udata->file, udata->dxpl_id, udata->grp_full_path_r, lnk) < 0) HGOTO_ERROR(H5E_SYM, H5E_CANTGET, H5_ITER_ERROR, "unable to get object type") /* Stop the iteration, we found the correct link */ diff --git a/src/H5Gdense.c b/src/H5Gdense.c index 5ce4475..2b7493b 100644 --- a/src/H5Gdense.c +++ b/src/H5Gdense.c @@ -1295,7 +1295,7 @@ H5G_dense_remove_fh_cb(const void *obj, size_t UNUSED obj_len, void *_udata) /* 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) + if(H5G_link_name_replace(udata->f, udata->dxpl_id, udata->grp_full_path_r, lnk) < 0) HGOTO_ERROR(H5E_SYM, H5E_CANTRENAME, FAIL, "unable to rename open objects") /* Perform the deletion action on the link, if requested */ @@ -1537,7 +1537,7 @@ H5G_dense_remove_by_idx_bt2_cb(const void *_record, void *_bt2_udata) } /* end if */ /* Replace open objects' names */ - if(H5G_link_name_replace(bt2_udata->f, bt2_udata->dxpl_id, bt2_udata->grp_full_path_r, fh_udata.lnk->name, fh_udata.lnk->type, fh_udata.lnk->u.hard.addr) < 0) + if(H5G_link_name_replace(bt2_udata->f, bt2_udata->dxpl_id, bt2_udata->grp_full_path_r, fh_udata.lnk) < 0) HGOTO_ERROR(H5E_SYM, H5E_CANTRENAME, FAIL, "unable to rename open objects") /* Perform the deletion action on the link */ diff --git a/src/H5Gdeprec.c b/src/H5Gdeprec.c index 65bea44..b71c509 100644 --- a/src/H5Gdeprec.c +++ b/src/H5Gdeprec.c @@ -129,6 +129,48 @@ H5G_init_deprec_interface(void) #ifndef H5_NO_DEPRECATED_SYMBOLS /*------------------------------------------------------------------------- + * Function: H5G_map_obj_type + * + * Purpose: Maps the object type to the older "group" object type + * + * Return: Object type (can't fail) + * + * Programmer: Quincey Koziol + * Tuesday, November 21, 2006 + * + *------------------------------------------------------------------------- + */ +H5G_obj_t +H5G_map_obj_type(H5O_type_t obj_type) +{ + H5G_obj_t ret_value; /* Return value */ + + /* Use FUNC_ENTER_NOAPI_NOINIT_NOFUNC here to avoid performance issues */ + FUNC_ENTER_NOAPI_NOINIT_NOFUNC(H5G_map_obj_type) + + /* Map object type to older "group" object type */ + switch(obj_type) { + case H5O_TYPE_GROUP: + ret_value = H5G_GROUP; + break; + + case H5O_TYPE_DATASET: + ret_value = H5G_DATASET; + break; + + case H5O_TYPE_NAMED_DATATYPE: + ret_value = H5G_TYPE; + break; + + default: + ret_value = H5G_UNKNOWN; + } /* end switch */ + + FUNC_LEAVE_NOAPI(ret_value) +} /* end H5G_map_obj_type() */ + + +/*------------------------------------------------------------------------- * Function: H5Gcreate1 * * Purpose: Creates a new group relative to LOC_ID and gives it the diff --git a/src/H5Glink.c b/src/H5Glink.c index bf01d34..7292245 100644 --- a/src/H5Glink.c +++ b/src/H5Glink.c @@ -720,10 +720,9 @@ done: */ 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) + const H5O_link_t *lnk) { H5RS_str_t *obj_path_r = NULL; /* Full path for link being removed */ - H5G_obj_t grp_obj_type; /* Type of link/object being deleted */ herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_NOAPI(H5G_link_name_replace, FAIL) @@ -731,45 +730,10 @@ H5G_link_name_replace(H5F_t *file, hid_t dxpl_id, H5RS_str_t *grp_full_path_r, /* check arguments */ HDassert(file); - /* 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 */ - H5O_type_t obj_type; /* Type of object at location */ - - /* Build temporary object location */ - tmp_oloc.file = file; - tmp_oloc.addr = lnk_addr; - - /* Get the type of the object */ - if(H5O_obj_type(&tmp_oloc, &obj_type, dxpl_id) < 0) - HGOTO_ERROR(H5E_SYM, H5E_CANTGET, H5G_UNKNOWN, "can't get object type") - - /* Map to group object type */ - if(H5G_UNKNOWN == (grp_obj_type = H5G_map_obj_type(obj_type))) - HGOTO_ERROR(H5E_SYM, H5E_BADTYPE, H5G_UNKNOWN, "can't determine object type") - } - break; - - case H5L_TYPE_SOFT: - /* Get the object's type */ - grp_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 */ - grp_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(grp_obj_type, file, obj_path_r, - NULL, NULL, NULL, H5G_NAME_DELETE) < 0) + obj_path_r = H5G_build_fullpath_refstr_str(grp_full_path_r, lnk->name); + if(H5G_name_replace(lnk, H5G_NAME_DELETE, file, obj_path_r, NULL, NULL, dxpl_id) < 0) HGOTO_ERROR(H5E_SYM, H5E_CANTDELETE, FAIL, "unable to replace name") } /* end if */ diff --git a/src/H5Gname.c b/src/H5Gname.c index db7ccbb..a041dcd 100644 --- a/src/H5Gname.c +++ b/src/H5Gname.c @@ -47,7 +47,6 @@ typedef struct H5G_names_t { 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 */ @@ -79,7 +78,9 @@ H5FL_DEFINE_STATIC(haddr_t); /* PRIVATE PROTOTYPES */ 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); +#ifdef NOT_YET static H5RS_str_t *H5G_build_fullpath_refstr_refstr(const H5RS_str_t *prefix_r, const H5RS_str_t *name_r); +#endif /* NOT_YET */ 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); @@ -246,6 +247,7 @@ H5G_build_fullpath_refstr_str(H5RS_str_t *prefix_r, const char *name) FUNC_LEAVE_NOAPI(ret_value) } /* end H5G_build_fullpath_refstr_str() */ +#ifdef NOT_YET /*------------------------------------------------------------------------- * Function: H5G_name_build_refstr_refstr @@ -281,6 +283,7 @@ H5G_build_fullpath_refstr_refstr(const H5RS_str_t *prefix_r, const H5RS_str_t *n FUNC_LEAVE_NOAPI(ret_value) } /* end H5G_build_fullpath_refstr_refstr() */ +#endif /* NOT_YET */ /*------------------------------------------------------------------------- @@ -735,9 +738,9 @@ H5G_name_replace_cb(void *obj_ptr, hid_t obj_id, void *key) switch(names->op) { /*------------------------------------------------------------------------- - * H5G_NAME_MOUNT - *------------------------------------------------------------------------- - */ + * H5G_NAME_MOUNT + *------------------------------------------------------------------------- + */ case H5G_NAME_MOUNT: /* Check if object is in child mount hier. */ if(obj_in_child) { @@ -780,9 +783,9 @@ H5G_name_replace_cb(void *obj_ptr, hid_t obj_id, void *key) break; /*------------------------------------------------------------------------- - * H5G_NAME_UNMOUNT - *------------------------------------------------------------------------- - */ + * H5G_NAME_UNMOUNT + *------------------------------------------------------------------------- + */ case H5G_NAME_UNMOUNT: if(obj_in_child) { const char *full_path; /* Full path of current object */ @@ -828,9 +831,9 @@ H5G_name_replace_cb(void *obj_ptr, hid_t obj_id, void *key) break; /*------------------------------------------------------------------------- - * H5G_NAME_DELETE - *------------------------------------------------------------------------- - */ + * H5G_NAME_DELETE + *------------------------------------------------------------------------- + */ 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->src_full_path_r)) { @@ -840,9 +843,9 @@ H5G_name_replace_cb(void *obj_ptr, hid_t obj_id, void *key) break; /*------------------------------------------------------------------------- - * H5G_NAME_MOVE - *------------------------------------------------------------------------- - */ + * H5G_NAME_MOVE + *------------------------------------------------------------------------- + */ case H5G_NAME_MOVE: /* Link move 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->src_full_path_r)) { @@ -850,30 +853,20 @@ H5G_name_replace_cb(void *obj_ptr, hid_t obj_id, void *key) const char *full_suffix; /* Suffix of full path, after src_path */ char *new_full_path; /* New full path of object */ size_t new_full_len; /* Length of new full path */ - H5RS_str_t *src_path_r; /* Full path of source name */ const char *src_path; /* Full path of source object */ - H5RS_str_t *dst_path_r; /* Full path of destination name */ const char *dst_path; /* Full path of destination object */ /* Sanity check */ - 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->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_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->new_name_r); + HDassert(names->dst_full_path_r); /* Get pointers to paths of interest */ full_path = H5RS_get_str(obj_path->full_path_r); - src_path = H5RS_get_str(src_path_r); - dst_path = H5RS_get_str(dst_path_r); + src_path = H5RS_get_str(names->src_full_path_r); + dst_path = H5RS_get_str(names->dst_full_path_r); + + /* Make certain that the source and destination names are full (not relative) paths */ + HDassert(*src_path == '/'); + HDassert(*dst_path == '/'); /* Get pointer to "full suffix" */ full_suffix = full_path + HDstrlen(src_path); @@ -899,10 +892,6 @@ H5G_name_replace_cb(void *obj_ptr, hid_t obj_id, void *key) /* Take ownership of the new full path */ obj_path->full_path_r = H5RS_own(new_full_path); - - /* Release source & destination full paths */ - H5RS_decr(src_path_r); - H5RS_decr(dst_path_r); } /* end if */ break; @@ -934,8 +923,9 @@ done: *------------------------------------------------------------------------- */ 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_r, H5F_t *dst_file, H5RS_str_t *dst_full_path_r, H5G_names_op_t op) +H5G_name_replace(const H5O_link_t *lnk, H5G_names_op_t op, H5F_t *src_file, + H5RS_str_t *src_full_path_r, H5F_t *dst_file, H5RS_str_t *dst_full_path_r, + hid_t dxpl_id) { herr_t ret_value = SUCCEED; @@ -946,55 +936,71 @@ H5G_name_replace(H5G_obj_t type, H5F_t *src_file, H5RS_str_t *src_full_path_r, /* Check if the object we are manipulating has a path */ 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 */ - - /* Determine which types of IDs need to be operated on */ - switch(type) { - /* Object is a group */ - case H5G_GROUP: - /* Search and replace names through group IDs */ - search_group = 1; - break; - - /* Object is a dataset */ - case H5G_DATASET: - /* Search and replace names through dataset IDs */ - search_dataset = 1; - break; - - /* Object is a named datatype */ - case H5G_TYPE: - /* Search and replace names through datatype IDs */ - search_datatype = 1; - break; - - case H5G_UNKNOWN: /* We pass H5G_UNKNOWN as object type when we need to search all IDs */ - case H5G_LINK: /* Symbolic links might resolve to any object, so we need to search all IDs */ - /* Check if we will need to search groups */ - if(H5I_nmembers(H5I_GROUP) > 0) - search_group = 1; - - /* Check if we will need to search datasets */ - if(H5I_nmembers(H5I_DATASET) > 0) - search_dataset = 1; - - /* Check if we will need to search datatypes */ - if(H5I_nmembers(H5I_DATATYPE) > 0) - search_datatype = 1; - break; - - case H5G_UDLINK: - /* User-defined links automatically wipe out names (because it - * would be too much work to track them), so there's no point - * in searching them. - */ - break; - - default: - HGOTO_ERROR(H5E_SYM, H5E_BADTYPE, FAIL, "not valid object type") - } /* end switch */ + hbool_t search_group = FALSE; /* Flag to indicate that groups are to be searched */ + hbool_t search_dataset = FALSE; /* Flag to indicate that datasets are to be searched */ + hbool_t search_datatype = FALSE; /* Flag to indicate that datatypes are to be searched */ + + /* Check for particular link to operate on */ + if(lnk) { + /* 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 */ + H5O_type_t obj_type; /* Type of object at location */ + + /* Build temporary object location */ + tmp_oloc.file = src_file; + tmp_oloc.addr = lnk->u.hard.addr; + + /* Get the type of the object */ + if(H5O_obj_type(&tmp_oloc, &obj_type, dxpl_id) < 0) + HGOTO_ERROR(H5E_SYM, H5E_CANTGET, FAIL, "can't get object type") + + /* Determine which type of objects to operate on */ + switch(obj_type) { + case H5O_TYPE_GROUP: + /* Search and replace names through group IDs */ + search_group = TRUE; + break; + + case H5O_TYPE_DATASET: + /* Search and replace names through dataset IDs */ + search_dataset = TRUE; + break; + + case H5O_TYPE_NAMED_DATATYPE: + /* Search and replace names through datatype IDs */ + search_datatype = TRUE; + break; + + default: + HGOTO_ERROR(H5E_SYM, H5E_BADTYPE, FAIL, "not valid object type") + } /* end switch */ + } /* end case */ + break; + + case H5L_TYPE_SOFT: + /* Symbolic links might resolve to any object, so we need to search all IDs */ + search_group = search_dataset = search_datatype = TRUE; + break; + + default: /* User-defined link */ + /* Check for unknown library-defined link type */ + if(lnk->type < H5L_TYPE_UD_MIN) + HGOTO_ERROR(H5E_SYM, H5E_BADVALUE, FAIL, "unknown link type") + + /* User-defined & external links automatically wipe out + * names (because it would be too much work to track them), + * so there's no point in searching them. + */ + break; + } /* end switch */ + } /* end if */ + else { + /* We pass NULL as link pointer when we need to search all IDs */ + search_group = search_dataset = search_datatype = TRUE; + } /* end else */ /* Check if we need to operate on the objects affected */ if(search_group || search_dataset || search_datatype) { @@ -1009,7 +1015,6 @@ H5G_name_replace(H5G_obj_t type, H5F_t *src_file, H5RS_str_t *src_full_path_r, 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 */ @@ -1114,7 +1119,7 @@ H5G_refname_iterator(hid_t group, const char *name, const H5L_info_t *link_info, } /* end if */ /* If it's a group, we recurse into it */ - if(oinfo.type == H5G_GROUP) { + if(oinfo.type == H5O_TYPE_GROUP) { H5G_link_iterate_t lnk_op; /* Link operator */ hsize_t last_obj; size_t len_needed; /* Length of container string needed */ diff --git a/src/H5Gnode.c b/src/H5Gnode.c index eaa426f..6cff5a0 100644 --- a/src/H5Gnode.c +++ b/src/H5Gnode.c @@ -1216,11 +1216,9 @@ 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) { - H5L_type_t lnk_type; /* Type of link being removed */ - haddr_t lnk_addr; /* Address of object (for hard link) */ + H5O_link_t lnk; /* Constructed link for replacement */ 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 */ base = H5HL_offset_into(f, udata->common.heap, (size_t)0); @@ -1228,6 +1226,8 @@ H5G_node_remove(H5F_t *f, hid_t dxpl_id, haddr_t addr, void *_lt_key/*in,out*/, /* Find the name with a binary search */ rt = sn->nsyms; while(lt < rt && cmp) { + const char *s; /* Pointer to string in local heap */ + idx = (lt + rt) / 2; s = base + sn->entry[idx].name_off; cmp = HDstrcmp(udata->common.name, s); @@ -1240,48 +1240,50 @@ H5G_node_remove(H5F_t *f, hid_t dxpl_id, haddr_t addr, void *_lt_key/*in,out*/, if(cmp) HGOTO_ERROR(H5E_SYM, H5E_NOTFOUND, H5B_INS_ERROR, "name not found") + /* Get a pointer to the name of the link */ + if(NULL == (lnk.name = H5HL_offset_into(f, udata->common.heap, sn->entry[idx].name_off))) + HGOTO_ERROR(H5E_SYM, H5E_CANTGET, FAIL, "unable to get link name") + + /* Set up rest of link structure */ + lnk.corder_valid = FALSE; + lnk.corder = 0; + lnk.cset = H5T_CSET_ASCII; if(sn->entry[idx].type == H5G_CACHED_SLINK) { - /* Set the type of the link removed */ - lnk_type = H5L_TYPE_SOFT; - lnk_addr = HADDR_UNDEF; - - /* Remove the soft link's value from the local heap */ - s = H5HL_offset_into(f, udata->common.heap, sn->entry[idx].cache.slink.lval_offset); - if(s) { - len = HDstrlen(s) + 1; - if(H5HL_remove(f, dxpl_id, udata->common.heap, sn->entry[idx].cache.slink.lval_offset, len) < 0) - HGOTO_ERROR(H5E_SYM, H5E_CANTDELETE, H5B_INS_ERROR, "unable to remove soft link from local heap") - } /* end if */ + lnk.type = H5L_TYPE_SOFT; + lnk.u.soft.name = H5HL_offset_into(f, udata->common.heap, sn->entry[idx].cache.slink.lval_offset); } /* end if */ else { - /* Set the link information */ - lnk_type = H5L_TYPE_HARD; + lnk.type = H5L_TYPE_HARD; HDassert(H5F_addr_defined(sn->entry[idx].header)); - lnk_addr = sn->entry[idx].header; + lnk.u.hard.addr = sn->entry[idx].header; } /* end else */ - /* Get a pointer to the name of the link */ - if(NULL == (s = H5HL_offset_into(f, udata->common.heap, sn->entry[idx].name_off))) - HGOTO_ERROR(H5E_SYM, H5E_CANTGET, FAIL, "unable to get link name") - - /* Get the object's type */ - if(H5G_link_name_replace(f, dxpl_id, udata->grp_full_path_r, s, lnk_type, lnk_addr) < 0) + /* Replace any object names */ + if(H5G_link_name_replace(f, dxpl_id, udata->grp_full_path_r, &lnk) < 0) HGOTO_ERROR(H5E_SYM, H5E_CANTGET, FAIL, "unable to get object type") /* Decrement the ref. count for hard links */ - if(lnk_type == H5L_TYPE_HARD) { + if(lnk.type == H5L_TYPE_HARD) { H5O_loc_t tmp_oloc; /* Temporary object location */ /* Build temporary object location */ tmp_oloc.file = f; - tmp_oloc.addr = lnk_addr; + tmp_oloc.addr = lnk.u.hard.addr; 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 { + /* Remove the soft link's value from the local heap */ + if(lnk.u.soft.name) { + len = HDstrlen(lnk.u.soft.name) + 1; + if(H5HL_remove(f, dxpl_id, udata->common.heap, sn->entry[idx].cache.slink.lval_offset, len) < 0) + HGOTO_ERROR(H5E_SYM, H5E_CANTDELETE, H5B_INS_ERROR, "unable to remove soft link from local heap") + } /* end if */ + } /* end else */ /* Remove the link's name from the local heap */ - len = HDstrlen(s) + 1; + len = HDstrlen(lnk.name) + 1; if(H5HL_remove(f, dxpl_id, udata->common.heap, sn->entry[idx].name_off, len) < 0) HGOTO_ERROR(H5E_SYM, H5E_CANTDELETE, H5B_INS_ERROR, "unable to remove link name from local heap") diff --git a/src/H5Gpkg.h b/src/H5Gpkg.h index aab9641..1200c52 100644 --- a/src/H5Gpkg.h +++ b/src/H5Gpkg.h @@ -448,8 +448,7 @@ H5_DLL herr_t H5G_link_iterate_table(const H5G_link_table_t *ltable, void *op_data); H5_DLL herr_t H5G_link_release_table(H5G_link_table_t *ltable); 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); + H5RS_str_t *grp_full_path_r, const H5O_link_t *lnk); /* Functions that understand "compact" link storage */ H5_DLL herr_t H5G_compact_insert(const H5O_loc_t *grp_oloc, H5O_link_t *obj_lnk, diff --git a/src/H5Gprivate.h b/src/H5Gprivate.h index 14e10ff..ccbb66e 100644 --- a/src/H5Gprivate.h +++ b/src/H5Gprivate.h @@ -128,6 +128,7 @@ typedef struct { /* Forward declarations (for prototypes & struct definitions) */ struct H5P_genplist_t; struct H5O_loc_t; +struct H5O_link_t; struct H5O_t; /* @@ -158,7 +159,9 @@ H5_DLL herr_t H5G_free_grp_name(H5G_t *grp); H5_DLL herr_t H5G_get_shared_count(H5G_t *grp); H5_DLL herr_t H5G_mount(H5G_t *grp); H5_DLL herr_t H5G_unmount(H5G_t *grp); +#ifndef H5_NO_DEPRECATED_SYMBOLS H5_DLL H5G_obj_t H5G_map_obj_type(H5O_type_t obj_type); +#endif /* H5_NO_DEPRECATED_SYMBOLS */ /* * These functions operate on symbol table nodes. @@ -178,9 +181,9 @@ H5_DLL herr_t H5G_obj_ent_encode(const H5F_t *f, uint8_t **pp, /* * These functions operate on group hierarchy names. */ -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_replace(const struct H5O_link_t *lnk, H5G_names_op_t op, + H5F_t *src_file, H5RS_str_t *src_full_path_r, H5F_t *dst_file, + H5RS_str_t *dst_full_path_r, hid_t dxpl_id); 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/H5Gpublic.h b/src/H5Gpublic.h index 97b281f..6162be3 100644 --- a/src/H5Gpublic.h +++ b/src/H5Gpublic.h @@ -83,30 +83,6 @@ H5_DLL herr_t H5Gget_info_by_idx(hid_t loc_id, const char *group_name, hid_t lapl_id); H5_DLL herr_t H5Gclose(hid_t group_id); -/* Functions and variables defined for compatibility with previous versions - * of the HDF5 API. - * - * Use of these functions and variables is deprecated. - */ -/* - * An object has a certain type. The first few numbers are reserved for use - * internally by HDF5. Users may add their own types with higher values. The - * values are never stored in the file -- they only exist while an - * application is running. An object may satisfy the `isa' function for more - * than one type. - */ -typedef enum H5G_obj_t { - H5G_UNKNOWN = -1, /* Unknown object type */ - H5G_GROUP, /* Object is a group */ - H5G_DATASET, /* Object is a dataset */ - H5G_TYPE, /* Object is a named data type */ - H5G_LINK, /* Object is a symbolic link */ - H5G_UDLINK, /* Object is a user-defined link */ - H5G_RESERVED_5, /* Reserved for future use */ - H5G_RESERVED_6, /* Reserved for future use */ - H5G_RESERVED_7 /* Reserved for future use */ -} H5G_obj_t; - /* Symbols defined for compatibility with previous versions of the HDF5 API. * * Use of these symbols is deprecated. @@ -131,6 +107,25 @@ typedef enum H5G_obj_t { /* Typedefs */ +/* + * An object has a certain type. The first few numbers are reserved for use + * internally by HDF5. Users may add their own types with higher values. The + * values are never stored in the file -- they only exist while an + * application is running. An object may satisfy the `isa' function for more + * than one type. + */ +typedef enum H5G_obj_t { + H5G_UNKNOWN = -1, /* Unknown object type */ + H5G_GROUP, /* Object is a group */ + H5G_DATASET, /* Object is a dataset */ + H5G_TYPE, /* Object is a named data type */ + H5G_LINK, /* Object is a symbolic link */ + H5G_UDLINK, /* Object is a user-defined link */ + H5G_RESERVED_5, /* Reserved for future use */ + H5G_RESERVED_6, /* Reserved for future use */ + H5G_RESERVED_7 /* Reserved for future use */ +} H5G_obj_t; + /* Prototype for H5Giterate() operator */ typedef herr_t (*H5G_iterate_t)(hid_t group, const char *name, void *op_data); diff --git a/src/H5Gstab.c b/src/H5Gstab.c index e84f5e1..1887943 100644 --- a/src/H5Gstab.c +++ b/src/H5Gstab.c @@ -51,6 +51,7 @@ typedef struct H5G_bt_it_gnbi_t { char *name; /*member name to be returned */ } H5G_bt_it_gnbi_t; +#ifndef H5_NO_DEPRECATED_SYMBOLS /* Data passed through B-tree iteration for looking up a type by index */ typedef struct H5G_bt_it_gtbi_t { /* downward */ @@ -60,6 +61,7 @@ typedef struct H5G_bt_it_gtbi_t { /* upward */ H5G_obj_t type; /*member type to be returned */ } H5G_bt_it_gtbi_t; +#endif /* H5_NO_DEPRECATED_SYMBOLS */ /* Data passed through B-tree iteration for looking up a link by index */ typedef struct H5G_bt_it_lbi_t { @@ -2363,7 +2363,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 */ 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 */ @@ -2378,29 +2377,6 @@ H5L_move_cb(H5G_loc_t *grp_loc/*in*/, const char *name, const H5O_link_t *lnk, if(lnk == NULL) HGOTO_ERROR(H5E_SYM, H5E_NOTFOUND, FAIL, "the name of a link must be supplied to move or copy") - /* Get object type */ - switch(lnk->type) { - case H5L_TYPE_HARD: - { - H5O_type_t obj_type; /* Type of object at location */ - - if(H5O_obj_type(obj_loc->oloc, &obj_type, udata->dxpl_id) < 0) - HGOTO_ERROR(H5E_SYM, H5E_CANTGET, FAIL, "can't get object type") - if(H5G_UNKNOWN == (type = H5G_map_obj_type(obj_type))) - HGOTO_ERROR(H5E_SYM, H5E_BADTYPE, FAIL, "unknown object type to move") - } - break; - - case H5L_TYPE_SOFT: - type = H5G_LINK; - break; - - default: - if(lnk->type < H5L_TYPE_UD_MIN) - HGOTO_ERROR(H5E_LINK, H5E_BADTYPE, FAIL, "unrecognized link type") - type = H5G_UDLINK; - } /* end switch */ - /* Set up user data for move_dest_cb */ if((udata_out.lnk = (H5O_link_t *)H5O_msg_copy(H5O_LINK_ID, lnk, NULL)) == NULL) HGOTO_ERROR(H5E_LINK, H5E_CANTCOPY, FAIL, "unable to copy link to be moved") @@ -2427,12 +2403,22 @@ H5L_move_cb(H5G_loc_t *grp_loc/*in*/, const char *name, const H5O_link_t *lnk, 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); + /* Make certain that the destination name is a full (not relative) path */ + if(*(udata->dst_name) != '/') { + HDassert(udata->dst_loc->path->full_path_r); + + /* Create reference counted string for full dst path */ + if((dst_name_r = H5G_build_fullpath_refstr_str(udata->dst_loc->path->full_path_r, + udata->dst_name)) == NULL) + HGOTO_ERROR(H5E_SYM, H5E_PATH, FAIL, "can't build destination path name") + } /* end if */ + else + dst_name_r = H5RS_wrap(udata->dst_name); HDassert(dst_name_r); - 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) { + + /* Fix names up */ + if(H5G_name_replace(lnk, H5G_NAME_MOVE, obj_loc->oloc->file, obj_loc->path->full_path_r, + udata->dst_loc->oloc->file, dst_name_r, udata->dxpl_id) < 0) { H5RS_decr(dst_name_r); HGOTO_ERROR(H5E_SYM, H5E_CANTINIT, FAIL, "unable to replace name") } /* end if */ @@ -114,9 +114,9 @@ const H5O_msg_class_t *const H5O_msg_class_g[] = { * datatype message is a datatype but only some of them are datasets. */ const H5O_obj_class_t *const H5O_obj_class_g[] = { - H5O_OBJ_DATATYPE, /* Datatype object (H5G_TYPE - 2) */ - H5O_OBJ_DATASET, /* Dataset object (H5G_DATASET - 1) */ - H5O_OBJ_GROUP, /* Group object (H5G_GROUP - 0) */ + H5O_OBJ_DATATYPE, /* Datatype object (H5O_TYPE_NAMED_DATATYPE - 2) */ + H5O_OBJ_DATASET, /* Dataset object (H5O_TYPE_DATASET - 1) */ + H5O_OBJ_GROUP, /* Group object (H5O_TYPE_GROUP - 0) */ }; /* Declare a free list to manage the H5O_t struct */ diff --git a/src/H5Opkg.h b/src/H5Opkg.h index ce60ce4..c90ff0a 100644 --- a/src/H5Opkg.h +++ b/src/H5Opkg.h @@ -439,13 +439,13 @@ H5_DLLVAR const H5O_msg_class_t H5O_MSG_UNKNOWN[1]; * Object header "object" types */ -/* Group Object. (H5G_GROUP - 0) */ +/* Group Object. (H5O_TYPE_GROUP - 0) */ H5_DLLVAR const H5O_obj_class_t H5O_OBJ_GROUP[1]; -/* Dataset Object. (H5G_DATASET - 1) */ +/* Dataset Object. (H5O_TYPE_DATASET - 1) */ H5_DLLVAR const H5O_obj_class_t H5O_OBJ_DATASET[1]; -/* Datatype Object. (H5G_TYPE - 2) */ +/* Datatype Object. (H5O_TYPE_NAMED_DATATYPE - 2) */ H5_DLLVAR const H5O_obj_class_t H5O_OBJ_DATATYPE[1]; diff --git a/src/H5trace.c b/src/H5trace.c index 1c3b89d..2ad8222 100644 --- a/src/H5trace.c +++ b/src/H5trace.c @@ -655,6 +655,7 @@ H5_trace (const double *returning, const char *func, const char *type, ...) case 'G': switch(type[1]) { +#ifndef H5_NO_DEPRECATED_SYMBOLS case 'o': if(ptr) { if(vp) @@ -668,34 +669,40 @@ H5_trace (const double *returning, const char *func, const char *type, ...) case H5G_UNKNOWN: fprintf(out, "H5G_UNKNOWN"); break; - case H5G_LINK: - fprintf(out, "H5G_LINK"); - break; - case H5G_UDLINK: - fprintf(out, "H5G_UDLINK"); - break; + case H5G_GROUP: fprintf(out, "H5G_GROUP"); break; + case H5G_DATASET: fprintf(out, "H5G_DATASET"); break; + case H5G_TYPE: fprintf(out, "H5G_TYPE"); break; + + case H5G_LINK: + fprintf(out, "H5G_LINK"); + break; + + case H5G_UDLINK: + fprintf(out, "H5G_UDLINK"); + break; + case H5G_RESERVED_5: case H5G_RESERVED_6: case H5G_RESERVED_7: fprintf(out, "H5G_RESERVED(%ld)",(long)obj_type); break; + default: fprintf(out, "%ld", (long)obj_type); break; - } - } + } /* end switch */ + } /* end else */ break; -#ifndef H5_NO_DEPRECATED_SYMBOLS case 's': if(ptr) { if(vp) diff --git a/test/titerate.c b/test/titerate.c index d38ecb2..a8e0f39 100644 --- a/test/titerate.c +++ b/test/titerate.c @@ -610,7 +610,7 @@ test_iter_group_large(hid_t fapl) /* Add the name to the list of objects in the root group */ HDstrcpy(names[i].name, gname); - names[i].type = H5G_GROUP; + names[i].type = H5O_TYPE_GROUP; /* Create a group */ group = H5Gcreate2(file, gname, H5P_DEFAULT, H5P_DEFAULT, H5P_DEFAULT); @@ -627,7 +627,7 @@ test_iter_group_large(hid_t fapl) /* Add the name to the list of objects in the root group */ HDstrcpy(names[ITER_NGROUPS].name, "Dataset1"); - names[ITER_NGROUPS].type = H5G_DATASET; + names[ITER_NGROUPS].type = H5O_TYPE_DATASET; /* Close Dataset */ ret = H5Dclose(dataset); @@ -657,7 +657,7 @@ test_iter_group_large(hid_t fapl) /* Add the name to the list of objects in the root group */ HDstrcpy(names[ITER_NGROUPS + 1].name, "Datatype1"); - names[ITER_NGROUPS + 1].type = H5G_TYPE; + names[ITER_NGROUPS + 1].type = H5O_TYPE_NAMED_DATATYPE; /* Close datatype */ ret = H5Tclose(tid); diff --git a/tools/h5diff/h5diffgentest.c b/tools/h5diff/h5diffgentest.c index 048c193..b50b985 100644 --- a/tools/h5diff/h5diffgentest.c +++ b/tools/h5diff/h5diffgentest.c @@ -297,7 +297,7 @@ out: /*------------------------------------------------------------------------- * Function: test_types * - * Purpose: Compare different HDF5 types (H5G_obj_t): + * Purpose: Compare different HDF5 object & link types: * H5G_DATASET, H5G_TYPE, H5G_GROUP, H5G_LINK, H5G_UDLINK * *------------------------------------------------------------------------- diff --git a/tools/h5diff/ph5diff_main.c b/tools/h5diff/ph5diff_main.c index 9cbc993..af2ab7f 100644 --- a/tools/h5diff/ph5diff_main.c +++ b/tools/h5diff/ph5diff_main.c @@ -168,7 +168,7 @@ ph5diff_worker(int nID) if(Status.MPI_TAG == MPI_TAG_ARGS) { /*Recv parameters for diff from manager task */ - MPI_Recv(&args, sizeof(struct diff_args), MPI_BYTE, 0, MPI_TAG_ARGS, MPI_COMM_WORLD, &Status); + MPI_Recv(&args, sizeof(args), MPI_BYTE, 0, MPI_TAG_ARGS, MPI_COMM_WORLD, &Status); /*Do the diff */ nfound = diff(file1_id, args.name, file2_id, args.name, &(args.options), args.type); diffs.nfound = nfound; diff --git a/tools/h5ls/h5ls.c b/tools/h5ls/h5ls.c index 3d8104c..4ea6bbc 100644 --- a/tools/h5ls/h5ls.c +++ b/tools/h5ls/h5ls.c @@ -2069,9 +2069,9 @@ main(int argc, const char *argv[]) h5tools_init(); /* Build object display table */ - DISPATCH(H5G_DATASET, "Dataset", H5Dopen2, H5Dclose, dataset_list1, dataset_list2); - DISPATCH(H5G_GROUP, "Group", H5Gopen2, H5Gclose, NULL, group_list2); - DISPATCH(H5G_TYPE, "Type", H5Topen2, H5Tclose, NULL, datatype_list2); + DISPATCH(H5O_TYPE_GROUP, "Group", H5Gopen2, H5Gclose, NULL, group_list2); + DISPATCH(H5O_TYPE_DATASET, "Dataset", H5Dopen2, H5Dclose, dataset_list1, dataset_list2); + DISPATCH(H5O_TYPE_NAMED_DATATYPE, "Type", H5Topen2, H5Tclose, NULL, datatype_list2); /* Default output width */ width_g = get_width(); diff --git a/tools/h5repack/h5repack_copy.c b/tools/h5repack/h5repack_copy.c index 42dca2a..542aaf8 100644 --- a/tools/h5repack/h5repack_copy.c +++ b/tools/h5repack/h5repack_copy.c @@ -324,18 +324,18 @@ int do_copy_objects(hid_t fidin, buf = NULL; switch ( travt->objs[i].type ) { /*------------------------------------------------------------------------- - * H5G_GROUP - *------------------------------------------------------------------------- - */ - case H5G_GROUP: + * H5TRAV_TYPE_GROUP + *------------------------------------------------------------------------- + */ + case H5TRAV_TYPE_GROUP: if (options->verbose) printf(FORMAT_OBJ,"group",travt->objs[i].name ); /*------------------------------------------------------------------------- - * the root is a special case, we get an ID for the root group - * and copy its attributes using that ID - *------------------------------------------------------------------------- - */ + * the root is a special case, we get an ID for the root group + * and copy its attributes using that ID + *------------------------------------------------------------------------- + */ if(HDstrcmp(travt->objs[i].name, "/") == 0) { if ((grp_out = H5Gopen2(fidout, "/", H5P_DEFAULT)) < 0) goto error; @@ -360,9 +360,9 @@ int do_copy_objects(hid_t fidin, goto error; /*------------------------------------------------------------------------- - * copy attrs - *------------------------------------------------------------------------- - */ + * copy attrs + *------------------------------------------------------------------------- + */ if (copy_attr(grp_in,grp_out,options)<0) goto error; @@ -378,10 +378,10 @@ int do_copy_objects(hid_t fidin, break; /*------------------------------------------------------------------------- - * H5G_DATASET - *------------------------------------------------------------------------- - */ - case H5G_DATASET: + * H5TRAV_TYPE_DATASET + *------------------------------------------------------------------------- + */ + case H5TRAV_TYPE_DATASET: has_filter = 0; @@ -399,11 +399,11 @@ int do_copy_objects(hid_t fidin, /*------------------------------------------------------------------------- - * check if we should use H5Ocopy or not - * if there is a request for filters/layout, we read/write the object - * otherwise we do a copy using H5Ocopy - *------------------------------------------------------------------------- - */ + * check if we should use H5Ocopy or not + * if there is a request for filters/layout, we read/write the object + * otherwise we do a copy using H5Ocopy + *------------------------------------------------------------------------- + */ if (options->op_tbl->nelems || options->all_filter==1 || options->all_layout==1 @@ -445,7 +445,7 @@ int do_copy_objects(hid_t fidin, * 1) the external filters GZIP and SZIP might not be available * 2) the internal filters might be turned off *------------------------------------------------------------------------- - */ + */ if (h5tools_canreadf((travt->objs[i].name),dcpl_id)==1) { apply_s=1; @@ -473,11 +473,11 @@ int do_copy_objects(hid_t fidin, } /*------------------------------------------------------------------------- - * create the output dataset; - * disable error checking in case the dataset cannot be created with the - * modified dcpl; in that case use the original instead - *------------------------------------------------------------------------- - */ + * create the output dataset; + * disable error checking in case the dataset cannot be created with the + * modified dcpl; in that case use the original instead + *------------------------------------------------------------------------- + */ H5E_BEGIN_TRY { dset_out=H5Dcreate(fidout,travt->objs[i].name,wtype_id,f_space_id,dcpl_out); } H5E_END_TRY; @@ -489,9 +489,9 @@ int do_copy_objects(hid_t fidin, } /*------------------------------------------------------------------------- - * read/write - *------------------------------------------------------------------------- - */ + * read/write + *------------------------------------------------------------------------- + */ if (nelmts) { size_t need = (size_t)(nelmts*msize); /* bytes needed */ @@ -532,9 +532,9 @@ int do_copy_objects(hid_t fidin, vl_data = TRUE; /* - * determine the strip mine size and allocate a buffer. The strip mine is - * a hyperslab whose size is manageable. - */ + * determine the strip mine size and allocate a buffer. The strip mine is + * a hyperslab whose size is manageable. + */ sm_nbytes = p_type_nbytes; for (k = rank; k > 0; --k) { @@ -606,9 +606,9 @@ int do_copy_objects(hid_t fidin, }/*nelmts*/ /*------------------------------------------------------------------------- - * amount of compression used - *------------------------------------------------------------------------- - */ + * amount of compression used + *------------------------------------------------------------------------- + */ if (options->verbose) { if (apply_s && apply_f) @@ -636,9 +636,9 @@ int do_copy_objects(hid_t fidin, } /* verbose */ /*------------------------------------------------------------------------- - * copy attrs - *------------------------------------------------------------------------- - */ + * copy attrs + *------------------------------------------------------------------------- + */ if (copy_attr(dset_in,dset_out,options)<0) goto error; @@ -651,9 +651,9 @@ int do_copy_objects(hid_t fidin, /*------------------------------------------------------------------------- - * close - *------------------------------------------------------------------------- - */ + * close + *------------------------------------------------------------------------- + */ if (H5Tclose(ftype_id)<0) goto error; if (H5Tclose(wtype_id)<0) @@ -669,9 +669,9 @@ int do_copy_objects(hid_t fidin, } /*------------------------------------------------------------------------- - * we do not have request for filter/chunking use H5Ocopy instead - *------------------------------------------------------------------------- - */ + * we do not have request for filter/chunking use H5Ocopy instead + *------------------------------------------------------------------------- + */ else { hid_t pid; @@ -685,9 +685,9 @@ int do_copy_objects(hid_t fidin, goto error; /*------------------------------------------------------------------------- - * do the copy - *------------------------------------------------------------------------- - */ + * do the copy + *------------------------------------------------------------------------- + */ if (H5Ocopy(fidin, /* Source file or group identifier */ travt->objs[i].name, /* Name of the source object to be copied */ @@ -703,9 +703,9 @@ int do_copy_objects(hid_t fidin, /*------------------------------------------------------------------------- - * copy attrs manually - *------------------------------------------------------------------------- - */ + * copy attrs manually + *------------------------------------------------------------------------- + */ if ((dset_in=H5Dopen(fidin,travt->objs[i].name))<0) goto error; if ((dset_out=H5Dopen(fidout,travt->objs[i].name))<0) @@ -723,10 +723,10 @@ int do_copy_objects(hid_t fidin, break; /*------------------------------------------------------------------------- - * H5G_TYPE - *------------------------------------------------------------------------- - */ - case H5G_TYPE: + * H5TRAV_TYPE_NAMED_DATATYPE + *------------------------------------------------------------------------- + */ + case H5TRAV_TYPE_NAMED_DATATYPE: if ((type_in = H5Topen (fidin,travt->objs[i].name))<0) goto error; @@ -738,9 +738,9 @@ int do_copy_objects(hid_t fidin, goto error; /*------------------------------------------------------------------------- - * copy attrs - *------------------------------------------------------------------------- - */ + * copy attrs + *------------------------------------------------------------------------- + */ if (copy_attr(type_in,type_out,options)<0) goto error; @@ -756,16 +756,16 @@ int do_copy_objects(hid_t fidin, /*------------------------------------------------------------------------- - * H5G_LINK - * H5G_UDLINK - * - * Only handles external links; H5Lcopy will fail for other UD link types - * since we don't have creation or copy callbacks for them. - *------------------------------------------------------------------------- - */ - - case H5G_LINK: - case H5G_UDLINK: + * H5TRAV_TYPE_LINK + * H5TRAV_TYPE_UDLINK + * + * Only handles external links; H5Lcopy will fail for other UD link types + * since we don't have creation or copy callbacks for them. + *------------------------------------------------------------------------- + */ + + case H5TRAV_TYPE_LINK: + case H5TRAV_TYPE_UDLINK: { if(H5Lcopy(fidin, travt->objs[i].name,fidout, travt->objs[i].name, H5P_DEFAULT, H5P_DEFAULT) < 0) goto error; diff --git a/tools/h5repack/h5repack_refs.c b/tools/h5repack/h5repack_refs.c index a29ae48..d3dff90 100644 --- a/tools/h5repack/h5repack_refs.c +++ b/tools/h5repack/h5repack_refs.c @@ -352,10 +352,10 @@ int do_copy_refobjs(hid_t fidin, break; /*------------------------------------------------------------------------- - * H5G_LINK + * H5TRAV_TYPE_LINK *------------------------------------------------------------------------- */ - case H5G_LINK: + case H5TRAV_TYPE_LINK: /*nothing to do */ break; diff --git a/tools/h5repack/h5repack_verify.c b/tools/h5repack/h5repack_verify.c index 6c02e92..04b856f 100644 --- a/tools/h5repack/h5repack_verify.c +++ b/tools/h5repack/h5repack_verify.c @@ -248,9 +248,7 @@ int h5repack_verify(const char *fname, { char* name=travt->objs[i].name; - switch ( travt->objs[i].type ) - { - case H5G_DATASET: + if ( travt->objs[i].type == H5TRAV_TYPE_DATASET) { /*------------------------------------------------------------------------- * open @@ -296,11 +294,7 @@ int h5repack_verify(const char *fname, goto error; if (H5Dclose(dset_id)<0) goto error; - - break; - default: - break; - } /* switch */ + } /* if */ } /* i */ @@ -402,20 +396,7 @@ int h5repack_cmpdcpl(const char *fname1, for ( i=0; i < travt1->nobjs; i++) { - switch ( travt1->objs[i].type ) - { -/*------------------------------------------------------------------------- - * nothing to do for groups, links and types - *------------------------------------------------------------------------- - */ - default: - break; - -/*------------------------------------------------------------------------- - * H5G_DATASET - *------------------------------------------------------------------------- - */ - case H5G_DATASET: + if ( travt1->objs[i].type == H5TRAV_TYPE_DATASET) { if ((dset1=H5Dopen(fid1,travt1->objs[i].name))<0) goto error; if ((dset2=H5Dopen(fid2,travt1->objs[i].name))<0) @@ -450,10 +431,7 @@ int h5repack_cmpdcpl(const char *fname1, goto error; if (H5Dclose(dset2)<0) goto error; - - break; - - } /*switch*/ + } /*if*/ } /*i*/ /*------------------------------------------------------------------------- diff --git a/tools/h5stat/h5stat.c b/tools/h5stat/h5stat.c index 54c517d..0f5f0a5 100644 --- a/tools/h5stat/h5stat.c +++ b/tools/h5stat/h5stat.c @@ -115,16 +115,11 @@ static int display_group = FALSE; static int display_dset_metadata = FALSE; static int display_dset = FALSE; static int display_dtype_metadata = FALSE; -/* Not used yet 11/17/06 EIP -static int display_dtype = FALSE; -*/ static int display_object = FALSE; static int display_attr = FALSE; /* a structure for handling the order command-line parameters come in */ struct handler_t { - void (*func)(void *); - int flag; char *obj; }; @@ -734,47 +729,58 @@ dataset_stats(hid_t group, const char *name, const H5O_info_t *oi, iter_t *iter) *------------------------------------------------------------------------- */ static herr_t -walk(hid_t group, const char *name, const H5L_info_t UNUSED *linfo, void *_iter) +walk(hid_t group, const char *name, const H5L_info_t *linfo, void *_iter) { iter_t *iter = (iter_t *)_iter; - H5O_info_t oi; char *fullname = NULL; - char *s; herr_t ret; /* Generic return value */ - /* Get the full object name */ - fullname = fix_name(iter->container, name); - - /* Get object information */ - ret = H5Oget_info(group, name, &oi, H5P_DEFAULT); - assert(ret >= 0); - - /* If the object has already been printed then just show the object ID - * and return. */ - if((s = sym_lookup(&oi))) { - printf("%s same as %s\n", name, s); - } else { - sym_insert(&oi, fullname); - - /* Gather some statistics about the object */ - if(oi.rc > iter->max_links) - iter->max_links = oi.rc; - - switch(oi.type) { - case H5G_GROUP: - group_stats(group, name, fullname, &oi, walk, iter); - break; + if(!linfo || linfo->type == H5L_TYPE_HARD) { + H5O_info_t oi; + char *s; + + /* Get object information */ + ret = H5Oget_info(group, name, &oi, H5P_DEFAULT); + assert(ret >= 0); + + /* If the object has already been printed then just show the object ID + * and return. */ + if((s = sym_lookup(&oi))) { + printf("%s same as %s\n", name, s); + } else { + /* Get the full object name */ + fullname = fix_name(iter->container, name); + sym_insert(&oi, fullname); + + /* Gather some statistics about the object */ + if(oi.rc > iter->max_links) + iter->max_links = oi.rc; + + switch(oi.type) { + case H5O_TYPE_GROUP: + group_stats(group, name, fullname, &oi, walk, iter); + break; - case H5G_DATASET: - dataset_stats(group, name, &oi, iter); - break; + case H5O_TYPE_DATASET: + dataset_stats(group, name, &oi, iter); + break; - case H5G_TYPE: - /* Gather statistics about this type of object */ - iter->uniq_types++; - break; + case H5O_TYPE_NAMED_DATATYPE: + /* Gather statistics about this type of object */ + iter->uniq_types++; + break; - case H5G_LINK: + default: + /* Gather statistics about this type of object */ + iter->uniq_others++; + break; + } /* end switch */ + } + } /* end if */ + else { + switch(linfo->type) { + case H5L_TYPE_SOFT: + case H5L_TYPE_EXTERNAL: /* Gather statistics about links and UD links */ iter->uniq_links++; break; @@ -783,8 +789,8 @@ walk(hid_t group, const char *name, const H5L_info_t UNUSED *linfo, void *_iter) /* Gather statistics about this type of object */ iter->uniq_others++; break; - } /* end switch */ - } + } /* end switch() */ + } /* end else */ if(fullname) free(fullname); @@ -823,66 +829,77 @@ parse_command_line(int argc, const char *argv[]) /* parse command line options */ while ((opt = get_option(argc, argv, s_opts, l_opts)) != EOF) { switch ((char)opt) { - case 'A': - display_all = FALSE; - display_attr = TRUE; - break; - case 'F': - display_all = FALSE; - display_file_metadata = TRUE; - break; - case 'f': - display_all = FALSE; - display_file = TRUE; - break; - case 'G': - display_all = FALSE; - display_group_metadata = TRUE; - break; - case 'g': - display_all = FALSE; - display_group = TRUE; - break; - case 'T': - display_all = FALSE; - display_dtype_metadata = TRUE; - break; - case 'D': - display_all = FALSE; - display_dset_metadata = TRUE; - break; - case 'd': - display_all = FALSE; - display_dset = TRUE; - break; - case 'h': - usage(progname); - leave(EXIT_SUCCESS); - case 'V': - print_version(progname); - leave(EXIT_SUCCESS); - break; - case 'O': - display_object = TRUE; - for (i = 0; i < argc; i++) - if (!hand[i].obj) { - hand[i].obj = HDstrdup(opt_arg); - hand[i].flag = 1; - break; - } - break; - default: - usage(progname); - leave(EXIT_FAILURE); - } - } + case 'A': + display_all = FALSE; + display_attr = TRUE; + break; + + case 'F': + display_all = FALSE; + display_file_metadata = TRUE; + break; + + case 'f': + display_all = FALSE; + display_file = TRUE; + break; + + case 'G': + display_all = FALSE; + display_group_metadata = TRUE; + break; + + case 'g': + display_all = FALSE; + display_group = TRUE; + break; + + case 'T': + display_all = FALSE; + display_dtype_metadata = TRUE; + break; + + case 'D': + display_all = FALSE; + display_dset_metadata = TRUE; + break; + + case 'd': + display_all = FALSE; + display_dset = TRUE; + break; + + case 'h': + usage(progname); + leave(EXIT_SUCCESS); + + case 'V': + print_version(progname); + leave(EXIT_SUCCESS); + break; + + case 'O': + display_object = TRUE; + for(i = 0; i < argc; i++) + if(!hand[i].obj) { + hand[i].obj = HDstrdup(opt_arg); + break; + } /* end if */ + break; + + default: + usage(progname); + leave(EXIT_FAILURE); + } /* end switch */ + } /* end while */ /* check for file name to be processed */ if (argc <= opt_ind) { error_msg(progname, "missing file name\n"); usage(progname); leave(EXIT_FAILURE); - } + } /* end if */ + return hand; } @@ -1322,9 +1339,8 @@ main(int argc, const char *argv[]) } fname = argv[opt_ind]; - hand[opt_ind].obj = root; - hand[opt_ind].flag = 1; - if (display_object) hand[opt_ind].flag = 0; + if(!display_object) + hand[0].obj = root; printf("Filename: %s\n", fname); @@ -1348,14 +1364,12 @@ main(int argc, const char *argv[]) } /* Walk the objects or all file */ - for(i = 0; i < argc; i++) { - if(hand[i].obj) { - if(hand[i].flag) { - walk(fid, hand[i].obj, NULL, &iter); - print_statistics(hand[i].obj, &iter); - } - } - } + i = 0; + while(hand[i].obj) { + walk(fid, hand[i].obj, NULL, &iter); + print_statistics(hand[i].obj, &iter); + i++; + } /* end while */ free(hand); diff --git a/tools/lib/h5diff.c b/tools/lib/h5diff.c index e0174b0..3edd6e8 100644 --- a/tools/lib/h5diff.c +++ b/tools/lib/h5diff.c @@ -453,14 +453,14 @@ hsize_t diff_match(hid_t file1_id, */ /*Set up args to pass to worker task. */ - if(strlen(table->objs[i].name) > 255) { + if(HDstrlen(table->objs[i].name) > 255) { printf("The parallel diff only supports object names up to 255 characters\n"); MPI_Abort(MPI_COMM_WORLD, 0); } /* end if */ HDstrcpy(args.name, table->objs[i].name); args.options = *options; - args.type= table->objs[i].type; + args.type = table->objs[i].type; h5diffdebug2("busyTasks=%d\n", busyTasks); /* if there are any outstanding print requests, let's handle one. */ @@ -516,7 +516,7 @@ hsize_t diff_match(hid_t file1_id, for(n = 1; (n < g_nTasks) && !workerFound; n++) { if(workerTasks[n-1]) { /* send file id's and names to first free worker */ - MPI_Send(&args, sizeof(struct diff_args), MPI_BYTE, n, MPI_TAG_ARGS, MPI_COMM_WORLD); + MPI_Send(&args, sizeof(args), MPI_BYTE, n, MPI_TAG_ARGS, MPI_COMM_WORLD); /* increment counter for total number of prints. */ busyTasks++; @@ -547,7 +547,7 @@ hsize_t diff_match(hid_t file1_id, nfound += nFoundbyWorker.nfound; options->not_cmp = options->not_cmp | nFoundbyWorker.not_cmp; /* send this task the work unit. */ - MPI_Send(&args, sizeof(struct diff_args), MPI_BYTE, Status.MPI_SOURCE, MPI_TAG_ARGS, MPI_COMM_WORLD); + MPI_Send(&args, sizeof(args), MPI_BYTE, Status.MPI_SOURCE, MPI_TAG_ARGS, MPI_COMM_WORLD); } /* end if */ } /* end while */ } /* end if */ @@ -560,7 +560,7 @@ hsize_t diff_match(hid_t file1_id, MPI_Recv(&nFoundbyWorker, sizeof(nFoundbyWorker), MPI_BYTE, Status.MPI_SOURCE, MPI_TAG_DONE, MPI_COMM_WORLD, &Status); nfound += nFoundbyWorker.nfound; options->not_cmp = options->not_cmp | nFoundbyWorker.not_cmp; - MPI_Send(&args, sizeof(struct diff_args), MPI_BYTE, Status.MPI_SOURCE, MPI_TAG_ARGS, MPI_COMM_WORLD); + MPI_Send(&args, sizeof(args), MPI_BYTE, Status.MPI_SOURCE, MPI_TAG_ARGS, MPI_COMM_WORLD); } /* end if */ else if(Status.MPI_TAG == MPI_TAG_TOK_REQUEST) { int incomingMessage; @@ -577,7 +577,7 @@ hsize_t diff_match(hid_t file1_id, MPI_Recv(&nFoundbyWorker, sizeof(nFoundbyWorker), MPI_BYTE, Status.MPI_SOURCE, MPI_TAG_TOK_RETURN, MPI_COMM_WORLD, &Status); nfound += nFoundbyWorker.nfound; options->not_cmp = options->not_cmp | nFoundbyWorker.not_cmp; - MPI_Send(&args, sizeof(struct diff_args), MPI_BYTE, Status.MPI_SOURCE, MPI_TAG_ARGS, MPI_COMM_WORLD); + MPI_Send(&args, sizeof(args), MPI_BYTE, Status.MPI_SOURCE, MPI_TAG_ARGS, MPI_COMM_WORLD); } /* end else-if */ else { printf("ERROR: Invalid tag (%d) received \n", Status.MPI_TAG); @@ -744,10 +744,9 @@ hsize_t diff_compare (hid_t file1_id, if (info1->paths[i].type != info2->paths[j].type) { if (options->m_verbose) - parallel_print - ("Comparison not possible: <%s> is of type %s and <%s> is of type %s\n", - obj1_name, get_type (info1->paths[i].type), obj2_name, - get_type (info2->paths[j].type)); + parallel_print("Comparison not possible: <%s> is of type %s and <%s> is of type %s\n", + obj1_name, get_type(info1->paths[i].type), obj2_name, + get_type(info2->paths[j].type)); options->not_cmp=1; return 0; } diff --git a/tools/lib/h5diff.h b/tools/lib/h5diff.h index 60e96b2..373eeed 100644 --- a/tools/lib/h5diff.h +++ b/tools/lib/h5diff.h @@ -150,7 +150,7 @@ void print_found(hsize_t nfound); void parallel_print(const char* format, ... ); void print_type(hid_t type); const char* diff_basename(const char *name); -const char* get_type(int type); +const char* get_type(h5trav_type_t type); const char* get_class(H5T_class_t tclass); const char* get_sign(H5T_sign_t sign); void print_dimensions (int rank, hsize_t *dims); diff --git a/tools/lib/h5diff_util.c b/tools/lib/h5diff_util.c index bd8207f..9e9c556 100644 --- a/tools/lib/h5diff_util.c +++ b/tools/lib/h5diff_util.c @@ -261,23 +261,22 @@ diff_basename(const char *name) *------------------------------------------------------------------------- */ const char* -get_type(int type) +get_type(h5trav_type_t type) { - switch (type) - { - case H5G_DATASET: - return("H5G_DATASET"); - case H5G_GROUP: - return("H5G_GROUP"); - case H5G_TYPE: - return("H5G_TYPE"); - case H5G_LINK: - return("H5G_LINK"); - case H5G_UDLINK: - return("H5G_UDLINK"); - default: - return("user defined type"); - } + switch(type) { + case H5TRAV_TYPE_DATASET: + return("H5G_DATASET"); + case H5TRAV_TYPE_GROUP: + return("H5G_GROUP"); + case H5TRAV_TYPE_NAMED_DATATYPE: + return("H5G_TYPE"); + case H5TRAV_TYPE_LINK: + return("H5G_LINK"); + case H5TRAV_TYPE_UDLINK: + return("H5G_UDLINK"); + default: + return("unknown type"); + } } /*------------------------------------------------------------------------- diff --git a/tools/lib/ph5diff.h b/tools/lib/ph5diff.h index d904095..3ad158f 100644 --- a/tools/lib/ph5diff.h +++ b/tools/lib/ph5diff.h @@ -41,7 +41,7 @@ extern FILE * overflow_file; struct diff_args { char name[256]; - H5G_obj_t type; + h5trav_type_t type; diff_opt_t options; }; |