summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorQuincey Koziol <koziol@hdfgroup.org>2005-08-20 16:32:55 (GMT)
committerQuincey Koziol <koziol@hdfgroup.org>2005-08-20 16:32:55 (GMT)
commita0530d368bc11e6ca492db47a7400150eadae377 (patch)
tree18e8ae0919eb895855b5567759c75f222c28a3b8
parenteec442a8f6d26f66eda16bc144d396e90dd06516 (diff)
downloadhdf5-a0530d368bc11e6ca492db47a7400150eadae377.zip
hdf5-a0530d368bc11e6ca492db47a7400150eadae377.tar.gz
hdf5-a0530d368bc11e6ca492db47a7400150eadae377.tar.bz2
[svn-r11277] Purpose:
Bug fix Description: Fix core dump when checking whether to invalidate the name of an object when unlinking an object in a group opened through an object reference. Solution: Check if names of various objects are valid before comparing them, etc. Platforms tested: FreeBSD 4.11 (sleipnir) Too minor to require h5committest
-rw-r--r--release_docs/RELEASE.txt2
-rw-r--r--src/H5Edefin.h2
-rw-r--r--src/H5Einit.h10
-rw-r--r--src/H5Epubgen.h4
-rw-r--r--src/H5Eterm.h246
-rw-r--r--src/H5G.c156
-rw-r--r--src/H5err.txt2
-rw-r--r--test/trefer.c33
8 files changed, 236 insertions, 219 deletions
diff --git a/release_docs/RELEASE.txt b/release_docs/RELEASE.txt
index f8350e7..e535b2c 100644
--- a/release_docs/RELEASE.txt
+++ b/release_docs/RELEASE.txt
@@ -345,7 +345,7 @@ Bug Fixes since HDF5-1.6.0 release
Library
-------
- - Corrected errors when querying information about a group opened
+ - Corrected errors when performing various operations on a group opened
by dereferencing an object reference. QAK - 2005/07/30
- Fixed a bug with named datatypes where a copy of a named datatype
used to create a dataset would accidentally use the original
diff --git a/src/H5Edefin.h b/src/H5Edefin.h
index 1a77f2d..a4acfbb 100644
--- a/src/H5Edefin.h
+++ b/src/H5Edefin.h
@@ -109,9 +109,9 @@ hid_t H5E_NOENCODER_g = FAIL; /* Filter present but encoding disabled
hid_t H5E_CANTOPENOBJ_g = FAIL; /* Can't open object */
hid_t H5E_CANTCLOSEOBJ_g = FAIL; /* Can't close object */
hid_t H5E_COMPLEN_g = FAIL; /* Name component is too long */
-hid_t H5E_CWG_g = FAIL; /* Problem with current working group */
hid_t H5E_LINK_g = FAIL; /* Link count failure */
hid_t H5E_SLINK_g = FAIL; /* Symbolic link error */
+hid_t H5E_PATH_g = FAIL; /* Problem with path to object */
/* File accessability errors */
hid_t H5E_FILEEXISTS_g = FAIL; /* File already exists */
diff --git a/src/H5Einit.h b/src/H5Einit.h
index 0378cb6..4190c58 100644
--- a/src/H5Einit.h
+++ b/src/H5Einit.h
@@ -383,11 +383,6 @@ if((msg = H5E_create_msg(cls, H5E_MINOR, "Name component is too long"))==NULL)
HGOTO_ERROR(H5E_ERROR, H5E_CANTINIT, FAIL, "error message initialization failed")
if((H5E_COMPLEN_g = H5I_register(H5I_ERROR_MSG, msg))<0)
HGOTO_ERROR(H5E_ERROR, H5E_CANTREGISTER, FAIL, "can't register error message")
-assert(H5E_CWG_g==(-1));
-if((msg = H5E_create_msg(cls, H5E_MINOR, "Problem with current working group"))==NULL)
- HGOTO_ERROR(H5E_ERROR, H5E_CANTINIT, FAIL, "error message initialization failed")
-if((H5E_CWG_g = H5I_register(H5I_ERROR_MSG, msg))<0)
- HGOTO_ERROR(H5E_ERROR, H5E_CANTREGISTER, FAIL, "can't register error message")
assert(H5E_LINK_g==(-1));
if((msg = H5E_create_msg(cls, H5E_MINOR, "Link count failure"))==NULL)
HGOTO_ERROR(H5E_ERROR, H5E_CANTINIT, FAIL, "error message initialization failed")
@@ -398,6 +393,11 @@ if((msg = H5E_create_msg(cls, H5E_MINOR, "Symbolic link error"))==NULL)
HGOTO_ERROR(H5E_ERROR, H5E_CANTINIT, FAIL, "error message initialization failed")
if((H5E_SLINK_g = H5I_register(H5I_ERROR_MSG, msg))<0)
HGOTO_ERROR(H5E_ERROR, H5E_CANTREGISTER, FAIL, "can't register error message")
+assert(H5E_PATH_g==(-1));
+if((msg = H5E_create_msg(cls, H5E_MINOR, "Problem with path to object"))==NULL)
+ HGOTO_ERROR(H5E_ERROR, H5E_CANTINIT, FAIL, "error message initialization failed")
+if((H5E_PATH_g = H5I_register(H5I_ERROR_MSG, msg))<0)
+ HGOTO_ERROR(H5E_ERROR, H5E_CANTREGISTER, FAIL, "can't register error message")
/* File accessability errors */
assert(H5E_FILEEXISTS_g==(-1));
diff --git a/src/H5Epubgen.h b/src/H5Epubgen.h
index b8143c7..2e8a0e7 100644
--- a/src/H5Epubgen.h
+++ b/src/H5Epubgen.h
@@ -178,15 +178,15 @@ H5_DLLVAR hid_t H5E_NOENCODER_g; /* Filter present but encoding disabled */
#define H5E_CANTOPENOBJ (H5OPEN H5E_CANTOPENOBJ_g)
#define H5E_CANTCLOSEOBJ (H5OPEN H5E_CANTCLOSEOBJ_g)
#define H5E_COMPLEN (H5OPEN H5E_COMPLEN_g)
-#define H5E_CWG (H5OPEN H5E_CWG_g)
#define H5E_LINK (H5OPEN H5E_LINK_g)
#define H5E_SLINK (H5OPEN H5E_SLINK_g)
+#define H5E_PATH (H5OPEN H5E_PATH_g)
H5_DLLVAR hid_t H5E_CANTOPENOBJ_g; /* Can't open object */
H5_DLLVAR hid_t H5E_CANTCLOSEOBJ_g; /* Can't close object */
H5_DLLVAR hid_t H5E_COMPLEN_g; /* Name component is too long */
-H5_DLLVAR hid_t H5E_CWG_g; /* Problem with current working group */
H5_DLLVAR hid_t H5E_LINK_g; /* Link count failure */
H5_DLLVAR hid_t H5E_SLINK_g; /* Symbolic link error */
+H5_DLLVAR hid_t H5E_PATH_g; /* Problem with path to object */
/* File accessability errors */
#define H5E_FILEEXISTS (H5OPEN H5E_FILEEXISTS_g)
diff --git a/src/H5Eterm.h b/src/H5Eterm.h
index 1d89d87..217a3c5 100644
--- a/src/H5Eterm.h
+++ b/src/H5Eterm.h
@@ -20,168 +20,168 @@
#define _H5Eterm_H
/* Reset major error IDs */
-
-H5E_DATASET_g=
-H5E_FUNC_g=
-H5E_STORAGE_g=
-H5E_FILE_g=
-H5E_FPHDF5_g=
-H5E_SYM_g=
-H5E_VFL_g=
-H5E_INTERNAL_g=
-H5E_BTREE_g=
-H5E_REFERENCE_g=
-H5E_DATASPACE_g=
-H5E_RESOURCE_g=
-H5E_PLIST_g=
-H5E_DATATYPE_g=
-H5E_RS_g=
-H5E_HEAP_g=
-H5E_OHDR_g=
-H5E_ATOM_g=
-H5E_ATTR_g=
-H5E_IO_g=
-H5E_BLKTRK_g=
-H5E_SLIST_g=
-H5E_EFL_g=
-H5E_TST_g=
-H5E_ARGS_g=
-H5E_ERROR_g=
-H5E_PLINE_g=
+
+H5E_DATASET_g=
+H5E_FUNC_g=
+H5E_STORAGE_g=
+H5E_FILE_g=
+H5E_FPHDF5_g=
+H5E_SYM_g=
+H5E_VFL_g=
+H5E_INTERNAL_g=
+H5E_BTREE_g=
+H5E_REFERENCE_g=
+H5E_DATASPACE_g=
+H5E_RESOURCE_g=
+H5E_PLIST_g=
+H5E_DATATYPE_g=
+H5E_RS_g=
+H5E_HEAP_g=
+H5E_OHDR_g=
+H5E_ATOM_g=
+H5E_ATTR_g=
+H5E_IO_g=
+H5E_BLKTRK_g=
+H5E_SLIST_g=
+H5E_EFL_g=
+H5E_TST_g=
+H5E_ARGS_g=
+H5E_ERROR_g=
+H5E_PLINE_g=
H5E_CACHE_g= (-1);
/* Reset minor error IDs */
-/* Generic low-level file I/O errors */
-H5E_SEEKERROR_g=
-H5E_READERROR_g=
-H5E_WRITEERROR_g=
-H5E_CLOSEERROR_g=
-H5E_OVERFLOW_g=
+/* Generic low-level file I/O errors */
+H5E_SEEKERROR_g=
+H5E_READERROR_g=
+H5E_WRITEERROR_g=
+H5E_CLOSEERROR_g=
+H5E_OVERFLOW_g=
H5E_FCNTL_g=
-/* Resource errors */
-H5E_NOSPACE_g=
-H5E_CANTCOPY_g=
-H5E_CANTFREE_g=
-H5E_ALREADYEXISTS_g=
-H5E_CANTLOCK_g=
-H5E_CANTUNLOCK_g=
-H5E_CANTGC_g=
+/* Resource errors */
+H5E_NOSPACE_g=
+H5E_CANTCOPY_g=
+H5E_CANTFREE_g=
+H5E_ALREADYEXISTS_g=
+H5E_CANTLOCK_g=
+H5E_CANTUNLOCK_g=
+H5E_CANTGC_g=
H5E_CANTGETSIZE_g=
-/* Heap errors */
+/* Heap errors */
H5E_CANTRESTORE_g=
-/* Function entry/exit interface errors */
-H5E_CANTINIT_g=
-H5E_ALREADYINIT_g=
+/* Function entry/exit interface errors */
+H5E_CANTINIT_g=
+H5E_ALREADYINIT_g=
H5E_CANTRELEASE_g=
-/* Property list errors */
-H5E_CANTGET_g=
-H5E_CANTSET_g=
+/* Property list errors */
+H5E_CANTGET_g=
+H5E_CANTSET_g=
H5E_DUPCLASS_g=
-/* Object header related errors */
-H5E_LINKCOUNT_g=
-H5E_VERSION_g=
-H5E_ALIGNMENT_g=
-H5E_BADMESG_g=
+/* Object header related errors */
+H5E_LINKCOUNT_g=
+H5E_VERSION_g=
+H5E_ALIGNMENT_g=
+H5E_BADMESG_g=
H5E_CANTDELETE_g=
-/* FPHDF5 errors */
-H5E_CANTRECV_g=
-H5E_CANTSENDMDATA_g=
-H5E_CANTCHANGE_g=
+/* FPHDF5 errors */
+H5E_CANTRECV_g=
+H5E_CANTSENDMDATA_g=
+H5E_CANTCHANGE_g=
H5E_CANTALLOC_g=
-/* System level errors */
+/* System level errors */
H5E_SYSERRSTR_g=
-/* I/O pipeline errors */
-H5E_NOFILTER_g=
-H5E_CALLBACK_g=
-H5E_CANAPPLY_g=
-H5E_SETLOCAL_g=
+/* I/O pipeline errors */
+H5E_NOFILTER_g=
+H5E_CALLBACK_g=
+H5E_CANAPPLY_g=
+H5E_SETLOCAL_g=
H5E_NOENCODER_g=
-/* Group related errors */
-H5E_CANTOPENOBJ_g=
-H5E_CANTCLOSEOBJ_g=
-H5E_COMPLEN_g=
-H5E_CWG_g=
-H5E_LINK_g=
-H5E_SLINK_g=
-
-/* File accessability errors */
-H5E_FILEEXISTS_g=
-H5E_FILEOPEN_g=
-H5E_CANTCREATE_g=
-H5E_CANTOPENFILE_g=
-H5E_CANTCLOSEFILE_g=
-H5E_NOTHDF5_g=
-H5E_BADFILE_g=
-H5E_TRUNCATED_g=
+/* Group related errors */
+H5E_CANTOPENOBJ_g=
+H5E_CANTCLOSEOBJ_g=
+H5E_COMPLEN_g=
+H5E_LINK_g=
+H5E_SLINK_g=
+H5E_PATH_g=
+
+/* File accessability errors */
+H5E_FILEEXISTS_g=
+H5E_FILEOPEN_g=
+H5E_CANTCREATE_g=
+H5E_CANTOPENFILE_g=
+H5E_CANTCLOSEFILE_g=
+H5E_NOTHDF5_g=
+H5E_BADFILE_g=
+H5E_TRUNCATED_g=
H5E_MOUNT_g=
-/* Object atom related errors */
-H5E_BADATOM_g=
-H5E_BADGROUP_g=
-H5E_CANTREGISTER_g=
-H5E_CANTINC_g=
-H5E_CANTDEC_g=
+/* Object atom related errors */
+H5E_BADATOM_g=
+H5E_BADGROUP_g=
+H5E_CANTREGISTER_g=
+H5E_CANTINC_g=
+H5E_CANTDEC_g=
H5E_NOIDS_g=
-/* Cache related errors */
-H5E_CANTFLUSH_g=
-H5E_CANTSERIALIZE_g=
-H5E_CANTLOAD_g=
-H5E_PROTECT_g=
-H5E_NOTCACHED_g=
-H5E_SYSTEM_g=
-H5E_CANTINS_g=
-H5E_CANTRENAME_g=
-H5E_CANTPROTECT_g=
+/* Cache related errors */
+H5E_CANTFLUSH_g=
+H5E_CANTSERIALIZE_g=
+H5E_CANTLOAD_g=
+H5E_PROTECT_g=
+H5E_NOTCACHED_g=
+H5E_SYSTEM_g=
+H5E_CANTINS_g=
+H5E_CANTRENAME_g=
+H5E_CANTPROTECT_g=
H5E_CANTUNPROTECT_g=
-/* Parallel MPI errors */
-H5E_MPI_g=
+/* Parallel MPI errors */
+H5E_MPI_g=
H5E_MPIERRSTR_g=
-/* Block tracker errors */
+/* Block tracker errors */
H5E_OVERLAPS_g=
-/* Dataspace errors */
-H5E_CANTCLIP_g=
-H5E_CANTCOUNT_g=
-H5E_CANTSELECT_g=
-H5E_CANTNEXT_g=
-H5E_BADSELECT_g=
+/* Dataspace errors */
+H5E_CANTCLIP_g=
+H5E_CANTCOUNT_g=
+H5E_CANTSELECT_g=
+H5E_CANTNEXT_g=
+H5E_BADSELECT_g=
H5E_CANTCOMPARE_g=
-/* B-tree related errors */
-H5E_NOTFOUND_g=
-H5E_EXISTS_g=
-H5E_CANTENCODE_g=
-H5E_CANTDECODE_g=
-H5E_CANTSPLIT_g=
-H5E_CANTREDISTRIBUTE_g=
-H5E_CANTSWAP_g=
-H5E_CANTINSERT_g=
-H5E_CANTLIST_g=
+/* B-tree related errors */
+H5E_NOTFOUND_g=
+H5E_EXISTS_g=
+H5E_CANTENCODE_g=
+H5E_CANTDECODE_g=
+H5E_CANTSPLIT_g=
+H5E_CANTREDISTRIBUTE_g=
+H5E_CANTSWAP_g=
+H5E_CANTINSERT_g=
+H5E_CANTLIST_g=
H5E_CANTMODIFY_g=
-/* Argument errors */
-H5E_UNINITIALIZED_g=
-H5E_UNSUPPORTED_g=
-H5E_BADTYPE_g=
-H5E_BADRANGE_g=
+/* Argument errors */
+H5E_UNINITIALIZED_g=
+H5E_UNSUPPORTED_g=
+H5E_BADTYPE_g=
+H5E_BADRANGE_g=
H5E_BADVALUE_g=
-/* Datatype conversion errors */
-H5E_CANTCONVERT_g=
+/* Datatype conversion errors */
+H5E_CANTCONVERT_g=
H5E_BADSIZE_g= (-1);
#endif /* H5Eterm_H */
diff --git a/src/H5G.c b/src/H5G.c
index b34bb68..07e61a7 100644
--- a/src/H5G.c
+++ b/src/H5G.c
@@ -200,6 +200,7 @@ static herr_t H5G_move(H5G_entry_t *src_loc, const char *src_name,
H5G_entry_t *dst_loc, const char *dst_name, hid_t dxpl_it);
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 H5RS_str_t *prefix_r, const H5RS_str_t *name_r);
static int H5G_replace_ent(void *obj_ptr, hid_t obj_id, void *key);
@@ -3202,7 +3203,6 @@ H5G_unlink(H5G_entry_t *loc, const char *name, hid_t dxpl_id)
const char *base=NULL;
char *norm_name = NULL; /* Pointer to normalized name */
H5G_stat_t statbuf; /* Info about object to unlink */
- H5RS_str_t *name_r; /* Ref-counted version of name */
herr_t ret_value=SUCCEED; /* Return value */
FUNC_ENTER_NOAPI_NOINIT(H5G_unlink);
@@ -3237,11 +3237,8 @@ H5G_unlink(H5G_entry_t *loc, const char *name, hid_t dxpl_id)
HGOTO_ERROR(H5E_SYM, H5E_CANTDELETE, FAIL, "unable to unlink name from symbol table");
/* Search the open IDs and replace names for unlinked object */
- name_r=H5RS_wrap(norm_name);
- assert(name_r);
- if (H5G_replace_name(statbuf.type, &obj_ent, name_r, NULL, NULL, NULL, OP_UNLINK )<0)
+ if (H5G_replace_name(statbuf.type, &obj_ent, NULL, NULL, NULL, NULL, OP_UNLINK )<0)
HGOTO_ERROR(H5E_SYM, H5E_CANTDELETE, FAIL, "unable to replace name");
- H5RS_decr(name_r);
done:
/* Free the ID to name buffers */
@@ -3676,6 +3673,72 @@ done:
/*-------------------------------------------------------------------------
+ * Function: H5G_build_fullpath
+ *
+ * Purpose: Build a full path from a prefix & base pair of reference counted
+ * strings
+ *
+ * Return: Pointer to reference counted string on success, NULL on error
+ *
+ * Programmer: Quincey Koziol, koziol@ncsa.uiuc.edu
+ *
+ * Date: August 19, 2005
+ *
+ * Comments:
+ *
+ * Modifications:
+ *
+ *-------------------------------------------------------------------------
+ */
+static H5RS_str_t *
+H5G_build_fullpath(const H5RS_str_t *prefix_r, const H5RS_str_t *name_r)
+{
+ const char *prefix; /* Pointer to raw string of prefix */
+ const char *name; /* Pointer to raw string of name */
+ char *full_path; /* Full user path built */
+ size_t path_len; /* Length of the path */
+ unsigned need_sep; /* Flag to indicate if separator is needed */
+ H5RS_str_t *ret_value; /* Return value */
+
+ FUNC_ENTER_NOAPI_NOINIT(H5G_build_fullpath)
+
+ /* Get the pointer to the prefix */
+ prefix=H5RS_get_str(prefix_r);
+
+ /* Get the length of the prefix */
+ path_len=HDstrlen(prefix);
+
+ /* Determine if there is a trailing separator in the name */
+ if(prefix[path_len-1]=='/')
+ need_sep=0;
+ else
+ need_sep=1;
+
+ /* Get the pointer to the raw src user path */
+ name=H5RS_get_str(name_r);
+
+ /* Add in the length needed for the '/' separator and the relative path */
+ path_len+=HDstrlen(name)+need_sep;
+
+ /* Allocate space for the path */
+ if(NULL==(full_path = H5FL_BLK_MALLOC(str_buf,path_len+1)))
+ HGOTO_ERROR (H5E_RESOURCE, H5E_NOSPACE, NULL, "memory allocation failed")
+
+ /* Build full path */
+ HDstrcpy(full_path,prefix);
+ if(need_sep)
+ HDstrcat(full_path,"/");
+ HDstrcat(full_path,name);
+
+ /* Create reference counted string for path */
+ ret_value=H5RS_own(full_path);
+
+done:
+ FUNC_LEAVE_NOAPI(ret_value)
+} /* end H5G_build_fullpath() */
+
+
+/*-------------------------------------------------------------------------
* Function: H5G_replace_ent
*
* Purpose: H5I_search callback function to replace group entry names
@@ -3806,7 +3869,8 @@ H5G_replace_ent(void *obj_ptr, hid_t obj_id, void *key)
*/
case OP_UNLINK:
/* If the ID's entry is not in the file we operated on, skip it */
- if(ent->file->shared == names->loc->file->shared && ent->user_path_r) {
+ if(ent->file->shared == names->loc->file->shared &&
+ names->loc->canon_path_r && ent->canon_path_r && ent->user_path_r) {
/* Check if we are referring to the same object */
if(H5F_addr_eq(ent->header, names->loc->header)) {
/* Check if the object was opened with the same canonical path as the one being moved */
@@ -3847,83 +3911,19 @@ H5G_replace_ent(void *obj_ptr, hid_t obj_id, void *key)
/* Make certain that the source and destination names are full (not relative) paths */
if(*(H5RS_get_str(names->src_name))!='/') {
- const char *src_name; /* Pointer to raw string of src_name */
- char *src_path; /* Full user path of source name */
- const char *src_user_path; /* Pointer to raw string of src path */
- size_t src_path_len; /* Length of the source path */
- unsigned need_sep; /* Flag to indicate if separator is needed */
-
- /* Get the pointer to the raw src user path */
- src_user_path=H5RS_get_str(names->src_loc->user_path_r);
-
- /* Get the length of the name for the source group's user path */
- src_path_len=HDstrlen(src_user_path);
-
- /* Determine if there is a trailing separator in the name */
- if(src_user_path[src_path_len-1]=='/')
- need_sep=0;
- else
- need_sep=1;
-
- /* Get the pointer to the raw src user path */
- src_name=H5RS_get_str(names->src_name);
-
- /* Add in the length needed for the '/' separator and the relative path */
- src_path_len+=HDstrlen(src_name)+need_sep;
-
- /* Allocate space for the path */
- if(NULL==(src_path = H5FL_BLK_MALLOC(str_buf,src_path_len+1)))
- HGOTO_ERROR (H5E_RESOURCE, H5E_NOSPACE, FAIL, "memory allocation failed");
-
- HDstrcpy(src_path,src_user_path);
- if(need_sep)
- HDstrcat(src_path,"/");
- HDstrcat(src_path,src_name);
-
- /* Create reference counted string for src path */
- src_path_r=H5RS_own(src_path);
+ /* Create reference counted string for full src path */
+ if((src_path_r = H5G_build_fullpath(names->src_loc->user_path_r, names->src_name)) == NULL)
+ HGOTO_ERROR (H5E_SYM, H5E_PATH, FAIL, "can't build source path name")
} /* end if */
else
- src_path_r=H5RS_dup(names->src_name);
+ src_path_r=H5RS_dup(names->src_name);
if(*(H5RS_get_str(names->dst_name))!='/') {
- const char *dst_name; /* Pointer to raw string of dst_name */
- char *dst_path; /* Full user path of destination name */
- const char *dst_user_path; /* Pointer to raw string of dst path */
- size_t dst_path_len; /* Length of the destination path */
- unsigned need_sep; /* Flag to indicate if separator is needed */
-
- /* Get the pointer to the raw dst user path */
- dst_user_path=H5RS_get_str(names->dst_loc->user_path_r);
-
- /* Get the length of the name for the destination group's user path */
- dst_path_len=HDstrlen(dst_user_path);
-
- /* Determine if there is a trailing separator in the name */
- if(dst_user_path[dst_path_len-1]=='/')
- need_sep=0;
- else
- need_sep=1;
-
- /* Get the pointer to the raw dst user path */
- dst_name=H5RS_get_str(names->dst_name);
-
- /* Add in the length needed for the '/' separator and the relative path */
- dst_path_len+=HDstrlen(dst_name)+need_sep;
-
- /* Allocate space for the path */
- if(NULL==(dst_path = H5FL_BLK_MALLOC(str_buf,dst_path_len+1)))
- HGOTO_ERROR (H5E_RESOURCE, H5E_NOSPACE, FAIL, "memory allocation failed");
-
- HDstrcpy(dst_path,dst_user_path);
- if(need_sep)
- HDstrcat(dst_path,"/");
- HDstrcat(dst_path,dst_name);
-
- /* Create reference counted string for dst path */
- dst_path_r=H5RS_own(dst_path);
+ /* Create reference counted string for full dst path */
+ if((dst_path_r = H5G_build_fullpath(names->dst_loc->user_path_r, names->dst_name)) == NULL)
+ HGOTO_ERROR (H5E_SYM, H5E_PATH, FAIL, "can't build destination path name")
} /* end if */
else
- dst_path_r=H5RS_dup(names->dst_name);
+ dst_path_r=H5RS_dup(names->dst_name);
/* Get the canonical parts of the source and destination names */
diff --git a/src/H5err.txt b/src/H5err.txt
index 59b03ce..17d981e 100644
--- a/src/H5err.txt
+++ b/src/H5err.txt
@@ -180,9 +180,9 @@ MINOR, OHDR, H5E_CANTDELETE, Can't delete message
MINOR, GROUP, H5E_CANTOPENOBJ, Can't open object
MINOR, GROUP, H5E_CANTCLOSEOBJ, Can't close object
MINOR, GROUP, H5E_COMPLEN, Name component is too long
-MINOR, GROUP, H5E_CWG, Problem with current working group
MINOR, GROUP, H5E_LINK, Link count failure
MINOR, GROUP, H5E_SLINK, Symbolic link error
+MINOR, GROUP, H5E_PATH, Problem with path to object
# Datatype conversion errors
MINOR, TYPECONV, H5E_CANTCONVERT, Can't convert datatypes
diff --git a/test/trefer.c b/test/trefer.c
index 66b7822..614539f 100644
--- a/test/trefer.c
+++ b/test/trefer.c
@@ -58,6 +58,7 @@ typedef struct s1_t {
#define GROUPNAME2 "group2"
#define GROUPNAME3 "group3"
#define DSETNAME "/dset"
+#define DSETNAME2 "dset2"
#define NAME_SIZE 16
@@ -928,12 +929,18 @@ test_deref_iter_op(hid_t UNUSED group, const char *name, void *op_data)
/* Simple check for correct names */
if(*count == 0) {
- if(HDstrcmp(name, GROUPNAME2) == 0)
+ if(HDstrcmp(name, DSETNAME2) == 0)
ret_value = 0;
else
ret_value = -1;
} /* end if */
else if(*count == 1) {
+ if(HDstrcmp(name, GROUPNAME2) == 0)
+ ret_value = 0;
+ else
+ ret_value = -1;
+ } /* end if */
+ else if(*count == 2) {
if(HDstrcmp(name, GROUPNAME3) == 0)
ret_value = 0;
else
@@ -972,6 +979,10 @@ test_reference_group(void)
fid = H5Fcreate(FILE1, H5F_ACC_TRUNC, H5P_DEFAULT, H5P_DEFAULT);
CHECK(fid, FAIL, "H5Fcreate");
+ /* Create dataspace to use for dataset */
+ sid = H5Screate(H5S_SCALAR);
+ CHECK(sid, FAIL, "H5Screate");
+
/* Create group to refer to */
gid = H5Gcreate(fid, GROUPNAME, (size_t)0);
CHECK(gid, FAIL, "H5Gcreate");
@@ -987,13 +998,15 @@ test_reference_group(void)
ret = H5Gclose(gid2);
CHECK(ret, FAIL, "H5Gclose");
+ /* Create bottom dataset */
+ did = H5Dcreate(gid, DSETNAME2, H5T_NATIVE_INT, sid, H5P_DEFAULT);
+ assert(did > 0);
+ ret = H5Dclose(did);
+ assert(ret >= 0);
+
ret = H5Gclose(gid);
CHECK(ret, FAIL, "H5Gclose");
- /* Create dataspace to use for dataset */
- sid = H5Screate(H5S_SCALAR);
- CHECK(sid, FAIL, "H5Screate");
-
/* Create dataset */
did = H5Dcreate(fid, DSETNAME, H5T_STD_REF_OBJ, sid, H5P_DEFAULT);
CHECK(did, FAIL, "H5Dcreate");
@@ -1039,20 +1052,24 @@ test_reference_group(void)
ret = H5Gget_num_objs(gid, &nobjs);
CHECK(ret, FAIL, "H5Gget_num_objs");
- VERIFY(nobjs, 2, "H5Gget_num_objs");
+ VERIFY(nobjs, 3, "H5Gget_num_objs");
ret = H5Gget_objname_by_idx(gid, (hsize_t)0, objname, NAME_SIZE);
CHECK(ret, FAIL, "H5Gget_objname_by_idx");
- VERIFY_STR(objname, GROUPNAME2, "H5Gget_objname_by_idx");
+ VERIFY_STR(objname, DSETNAME2, "H5Gget_objname_by_idx");
objtype = H5Gget_objtype_by_idx(gid, (hsize_t)0);
- VERIFY(objtype, H5G_GROUP, "H5Gget_objtype_by_idx");
+ VERIFY(objtype, H5G_DATASET, "H5Gget_objtype_by_idx");
/* Unlink one of the objects in the dereferenced group */
ret = H5Gunlink(gid, GROUPNAME2);
CHECK(ret, FAIL, "H5Gunlink");
+ /* Delete dataset object in dereferenced group (with other dataset still open) */
+ ret = H5Gunlink(gid, DSETNAME2);
+ assert(ret >= 0);
+
/* Close objects */
ret = H5Dclose(did);
CHECK(ret, FAIL, "H5Dclose");