summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorQuincey Koziol <koziol@hdfgroup.org>2007-09-25 22:18:33 (GMT)
committerQuincey Koziol <koziol@hdfgroup.org>2007-09-25 22:18:33 (GMT)
commit68c01f91d94d1fa7a7cff198cb8daf6c89f05da7 (patch)
tree8035fe4ed2f2a10855575c91969e4107af382d46 /src
parent02296972ec8a90ad50d89786755d0e953e95b455 (diff)
downloadhdf5-68c01f91d94d1fa7a7cff198cb8daf6c89f05da7.zip
hdf5-68c01f91d94d1fa7a7cff198cb8daf6c89f05da7.tar.gz
hdf5-68c01f91d94d1fa7a7cff198cb8daf6c89f05da7.tar.bz2
[svn-r14154] Description:
Finish deprecating last H5G symbol (H5G_obj_t) - yay! Lots of misc. library fixes to remove confusion between links and objects. The tools could still use another pass, to remove h5trav_type_t type and make the correct distinction between links & objects. Tested on: FreeBSD/32 6.2 (duty) in debug mode FreeBSD/64 6.2 (liberty) w/C++ & FORTRAN, in debug mode Linux/32 2.6 (kagiso) w/PGI compilers, w/C++ & FORTRAN, w/threadsafe, in debug mode Linux/64 2.6 (smirom) w/default API=1.6.x, w/C++ & FORTRAN, in production mode Solaris/32 2.10 (linew) w/deprecated symbols disabled, w/C++ & FORTRAN, w/szip filter, in production mode AIX/32 5.3 (copper) w/FORTRAN, w/parallel, in production mode Mac OS X/32 10.4.10 (amazon) in debug mode
Diffstat (limited to 'src')
-rw-r--r--src/H5Fmount.c16
-rw-r--r--src/H5G.c42
-rw-r--r--src/H5Gcompact.c4
-rw-r--r--src/H5Gdense.c4
-rw-r--r--src/H5Gdeprec.c42
-rw-r--r--src/H5Glink.c42
-rw-r--r--src/H5Gname.c179
-rw-r--r--src/H5Gnode.c54
-rw-r--r--src/H5Gpkg.h3
-rw-r--r--src/H5Gprivate.h9
-rw-r--r--src/H5Gpublic.h43
-rw-r--r--src/H5Gstab.c2
-rw-r--r--src/H5L.c44
-rw-r--r--src/H5O.c6
-rw-r--r--src/H5Opkg.h6
-rw-r--r--src/H5trace.c25
16 files changed, 243 insertions, 278 deletions
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 */
diff --git a/src/H5G.c b/src/H5G.c
index 906e739..872d145 100644
--- a/src/H5G.c
+++ b/src/H5G.c
@@ -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 {
diff --git a/src/H5L.c b/src/H5L.c
index 51ff5db..49ef879 100644
--- a/src/H5L.c
+++ b/src/H5L.c
@@ -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 */
diff --git a/src/H5O.c b/src/H5O.c
index aa6b161..1122e45 100644
--- a/src/H5O.c
+++ b/src/H5O.c
@@ -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)