summaryrefslogtreecommitdiffstats
path: root/src/H5Gname.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/H5Gname.c')
-rw-r--r--src/H5Gname.c881
1 files changed, 385 insertions, 496 deletions
diff --git a/src/H5Gname.c b/src/H5Gname.c
index 62875dc..ccb5253 100644
--- a/src/H5Gname.c
+++ b/src/H5Gname.c
@@ -1,23 +1,20 @@
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
* Copyright by The HDF Group. *
- * Copyright by the Board of Trustees of the University of Illinois. *
* All rights reserved. *
* *
* This file is part of HDF5. The full HDF5 copyright notice, including *
* terms governing use, modification, and redistribution, is contained in *
- * the files COPYING and Copyright.html. COPYING can be found at the root *
- * of the source code distribution tree; Copyright.html can be found at the *
- * root level of an installed copy of the electronic HDF5 document set and *
- * is linked from the top-level documents page. It can also be found at *
- * http://hdfgroup.org/HDF5/doc/Copyright.html. If you do not have *
- * access to either file, you may request a copy from help@hdfgroup.org. *
+ * the COPYING file, which can be found at the root of the source code *
+ * distribution tree, or in https://www.hdfgroup.org/licenses. *
+ * If you do not have access to either file, you may request a copy from *
+ * help@hdfgroup.org. *
* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * */
/*-------------------------------------------------------------------------
*
* Created: H5Gname.c
* Sep 12 2005
- * Quincey Koziol <koziol@ncsa.uiuc.edu>
+ * Quincey Koziol
*
* Purpose: Functions for handling group hierarchy paths.
*
@@ -28,90 +25,75 @@
/* Module Setup */
/****************/
-#define H5G_PACKAGE /*suppress error about including H5Gpkg */
-
+#include "H5Gmodule.h" /* This source code file is part of the H5G module */
/***********/
/* Headers */
/***********/
-#include "H5private.h" /* Generic Functions */
-#include "H5Dprivate.h" /* Datasets */
-#include "H5Eprivate.h" /* Error handling */
-#include "H5Fprivate.h" /* File access */
-#include "H5FLprivate.h" /* Free Lists */
-#include "H5Gpkg.h" /* Groups */
-#include "H5Iprivate.h" /* IDs */
-#include "H5Lprivate.h" /* Links */
-#include "H5MMprivate.h" /* Memory wrappers */
-
+#include "H5private.h" /* Generic Functions */
+#include "H5Dprivate.h" /* Datasets */
+#include "H5Eprivate.h" /* Error handling */
+#include "H5Fprivate.h" /* File access */
+#include "H5FLprivate.h" /* Free Lists */
+#include "H5Gpkg.h" /* Groups */
+#include "H5Iprivate.h" /* IDs */
+#include "H5Lprivate.h" /* Links */
+#include "H5MMprivate.h" /* Memory wrappers */
+
+#include "H5VLnative_private.h" /* Native VOL connector */
/****************/
/* Local Macros */
/****************/
-
/******************/
/* Local Typedefs */
/******************/
/* Struct used by change name callback function */
typedef struct H5G_names_t {
- H5G_names_op_t op; /* Operation performed on file */
- H5F_t *src_file; /* Top file in src location's mounted file hier. */
- H5RS_str_t *src_full_path_r; /* Source location's full path */
- H5F_t *dst_file; /* Destination location's file */
- H5RS_str_t *dst_full_path_r; /* Destination location's full path */
+ H5G_names_op_t op; /* Operation performed on file */
+ H5F_t *src_file; /* Top file in src location's mounted file hier. */
+ H5RS_str_t *src_full_path_r; /* Source location's full path */
+ H5F_t *dst_file; /* Destination location's file */
+ H5RS_str_t *dst_full_path_r; /* Destination location's full path */
} H5G_names_t;
/* Info to pass to the iteration function when building name */
typedef struct H5G_gnba_iter_t {
/* In */
- const H5O_loc_t *loc; /* The location of the object we're looking for */
- hid_t lapl_id; /* LAPL for operations */
- hid_t dxpl_id; /* DXPL for operations */
+ const H5O_loc_t *loc; /* The location of the object we're looking for */
/* Out */
- char *path; /* Name of the object */
+ char *path; /* Name of the object */
} H5G_gnba_iter_t;
/********************/
/* Package Typedefs */
/********************/
-
/********************/
/* Local 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);
-
+static htri_t H5G__common_path(const H5RS_str_t *fullpath_r, const H5RS_str_t *prefix_r);
+static H5RS_str_t *H5G__build_fullpath(const char *prefix, const char *name);
+static 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);
/*********************/
/* Package Variables */
/*********************/
-/* Declare extern the PQ free list for the wrapped strings */
-H5FL_BLK_EXTERN(str_buf);
-
-
/*****************************/
/* Library Private Variables */
/*****************************/
-
/*******************/
/* Local Variables */
/*******************/
-
-
/*-------------------------------------------------------------------------
* Function: H5G__component
*
@@ -125,7 +107,6 @@ H5FL_BLK_EXTERN(str_buf);
* Failure: Ptr to the null terminator of NAME.
*
* Programmer: Robb Matzke
- * matzke@llnl.gov
* Aug 11 1997
*
*-------------------------------------------------------------------------
@@ -135,7 +116,7 @@ H5G__component(const char *name, size_t *size_p)
{
FUNC_ENTER_PACKAGE_NOERR
- assert(name);
+ HDassert(name);
while ('/' == *name)
name++;
@@ -145,7 +126,6 @@ H5G__component(const char *name, size_t *size_p)
FUNC_LEAVE_NOAPI(name)
} /* end H5G__component() */
-
/*-------------------------------------------------------------------------
* Function: H5G_normalize
*
@@ -163,10 +143,10 @@ H5G__component(const char *name, size_t *size_p)
char *
H5G_normalize(const char *name)
{
- char *norm; /* Pointer to the normalized string */
- size_t s,d; /* Positions within the strings */
- unsigned last_slash; /* Flag to indicate last character was a slash */
- char *ret_value; /* Return value */
+ char *norm; /* Pointer to the normalized string */
+ size_t s, d; /* Positions within the strings */
+ unsigned last_slash; /* Flag to indicate last character was a slash */
+ char *ret_value = NULL; /* Return value */
FUNC_ENTER_NOAPI_NOINIT
@@ -174,22 +154,22 @@ H5G_normalize(const char *name)
HDassert(name);
/* Duplicate the name, to return */
- if(NULL == (norm = H5MM_strdup(name)))
- HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, NULL, "memory allocation failed for normalized string")
+ if (NULL == (norm = H5MM_strdup(name)))
+ HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, NULL, "memory allocation failed for normalized string")
/* Walk through the characters, omitting duplicated '/'s */
- s = d = 0;
+ s = d = 0;
last_slash = 0;
- while(name[s] != '\0') {
- if(name[s] == '/')
- if(last_slash)
+ while (name[s] != '\0') {
+ if (name[s] == '/')
+ if (last_slash)
;
else {
- norm[d++] = name[s];
+ norm[d++] = name[s];
last_slash = 1;
} /* end else */
else {
- norm[d++] = name[s];
+ norm[d++] = name[s];
last_slash = 0;
} /* end else */
s++;
@@ -199,7 +179,7 @@ H5G_normalize(const char *name)
norm[d] = '\0';
/* Check for final '/' on normalized name & eliminate it */
- if(d > 1 && last_slash)
+ if (d > 1 && last_slash)
norm[d - 1] = '\0';
/* Set return value */
@@ -209,56 +189,55 @@ done:
FUNC_LEAVE_NOAPI(ret_value)
} /* end H5G_normalize() */
-
/*-------------------------------------------------------------------------
- * Function: H5G_common_path
+ * Function: H5G__common_path
*
* Purpose: Determine if one path is a valid prefix of another path
*
* Return: TRUE for valid prefix, FALSE for not a valid prefix, FAIL
* on error
*
- * Programmer: Quincey Koziol, koziol@ncsa.uiuc.edu
+ * Programmer: Quincey Koziol
*
* Date: September 24, 2002
*
*-------------------------------------------------------------------------
*/
static htri_t
-H5G_common_path(const H5RS_str_t *fullpath_r, const H5RS_str_t *prefix_r)
+H5G__common_path(const H5RS_str_t *fullpath_r, const H5RS_str_t *prefix_r)
{
- const char *fullpath; /* Pointer to actual fullpath string */
- const char *prefix; /* Pointer to actual prefix string */
- size_t nchars1,nchars2; /* Number of characters in components */
- htri_t ret_value=FALSE; /* Return value */
+ const char *fullpath; /* Pointer to actual fullpath string */
+ const char *prefix; /* Pointer to actual prefix string */
+ size_t nchars1, nchars2; /* Number of characters in components */
+ htri_t ret_value = FALSE; /* Return value */
- FUNC_ENTER_NOAPI_NOINIT_NOERR
+ FUNC_ENTER_PACKAGE_NOERR
/* Get component of each name */
- fullpath=H5RS_get_str(fullpath_r);
- assert(fullpath);
- fullpath=H5G__component(fullpath,&nchars1);
- assert(fullpath);
- prefix=H5RS_get_str(prefix_r);
- assert(prefix);
- prefix=H5G__component(prefix,&nchars2);
- assert(prefix);
+ fullpath = H5RS_get_str(fullpath_r);
+ HDassert(fullpath);
+ fullpath = H5G__component(fullpath, &nchars1);
+ HDassert(fullpath);
+ prefix = H5RS_get_str(prefix_r);
+ HDassert(prefix);
+ prefix = H5G__component(prefix, &nchars2);
+ HDassert(prefix);
/* Check if we have a real string for each component */
- while(*fullpath && *prefix) {
+ while (*fullpath && *prefix) {
/* Check that the components we found are the same length */
- if(nchars1==nchars2) {
+ if (nchars1 == nchars2) {
/* Check that the two components are equal */
- if(HDstrncmp(fullpath,prefix,nchars1)==0) {
+ if (HDstrncmp(fullpath, prefix, nchars1) == 0) {
/* Advance the pointers in the names */
- fullpath+=nchars1;
- prefix+=nchars2;
+ fullpath += nchars1;
+ prefix += nchars2;
/* Get next component of each name */
- fullpath=H5G__component(fullpath,&nchars1);
- assert(fullpath);
- prefix=H5G__component(prefix,&nchars2);
- assert(prefix);
+ fullpath = H5G__component(fullpath, &nchars1);
+ HDassert(fullpath);
+ prefix = H5G__component(prefix, &nchars2);
+ HDassert(prefix);
} /* end if */
else
HGOTO_DONE(FALSE)
@@ -268,72 +247,48 @@ H5G_common_path(const H5RS_str_t *fullpath_r, const H5RS_str_t *prefix_r)
} /* end while */
/* If we reached the end of the prefix path to check, it must be a valid prefix */
- if(*prefix=='\0')
- ret_value=TRUE;
+ if (*prefix == '\0')
+ ret_value = TRUE;
done:
FUNC_LEAVE_NOAPI(ret_value)
-} /* end H5G_common_path() */
+} /* end H5G__common_path() */
-
/*-------------------------------------------------------------------------
- * Function: H5G_build_fullpath
+ * Function: H5G__build_fullpath
*
* Purpose: Build a full path from a prefix & base pair of strings
*
* Return: Pointer to reference counted string on success, NULL on error
*
- * Programmer: Quincey Koziol, koziol@ncsa.uiuc.edu
+ * Programmer: Quincey Koziol
*
* Date: August 19, 2005
*
*-------------------------------------------------------------------------
*/
static H5RS_str_t *
-H5G_build_fullpath(const char *prefix, const char *name)
+H5G__build_fullpath(const char *prefix, const char *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 */
+ H5RS_str_t *ret_value = NULL; /* Return value */
- FUNC_ENTER_NOAPI_NOINIT
+ FUNC_ENTER_PACKAGE
/* Sanity check */
HDassert(prefix);
HDassert(name);
- /* 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;
-
- /* 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 = (char *)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 */
- if((ret_value = H5RS_own(full_path)) == NULL)
- HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, NULL, "memory allocation failed")
+ /* Create full path */
+ if (NULL == (ret_value = H5RS_create(prefix)))
+ HGOTO_ERROR(H5E_SYM, H5E_CANTCREATE, NULL, "can't create ref-counted string")
+ if (prefix[HDstrlen(prefix) - 1] != '/')
+ H5RS_aputc(ret_value, '/'); /* Add separator, if the prefix doesn't end in one */
+ H5RS_acat(ret_value, name);
done:
FUNC_LEAVE_NOAPI(ret_value)
-} /* end H5G_build_fullpath() */
+} /* end H5G__build_fullpath() */
-
/*-------------------------------------------------------------------------
* Function: H5G_build_fullpath_refstr_str
*
@@ -342,7 +297,7 @@ done:
* Return: Success: Non-NULL, combined path
* Failure: NULL
*
- * Programmer: Quincey Koziol, koziol@ncsa.uiuc.edu
+ * Programmer: Quincey Koziol
* Tuesday, October 11, 2005
*
*-------------------------------------------------------------------------
@@ -350,8 +305,8 @@ done:
H5RS_str_t *
H5G_build_fullpath_refstr_str(H5RS_str_t *prefix_r, const char *name)
{
- const char *prefix; /* Pointer to raw string for path */
- H5RS_str_t *ret_value;
+ const char *prefix; /* Pointer to raw string for path */
+ H5RS_str_t *ret_value = NULL; /* Return value */
FUNC_ENTER_NOAPI_NOINIT_NOERR
@@ -363,50 +318,11 @@ H5G_build_fullpath_refstr_str(H5RS_str_t *prefix_r, const char *name)
HDassert(prefix);
/* Create reference counted string for path */
- ret_value = H5G_build_fullpath(prefix, name);
+ ret_value = H5G__build_fullpath(prefix, name);
FUNC_LEAVE_NOAPI(ret_value)
} /* end H5G_build_fullpath_refstr_str() */
-#ifdef NOT_YET
-
-/*-------------------------------------------------------------------------
- * Function: H5G_name_build_refstr_refstr
- *
- * 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
- *
- *-------------------------------------------------------------------------
- */
-static H5RS_str_t *
-H5G_build_fullpath_refstr_refstr(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 */
- H5RS_str_t *ret_value; /* Return value */
-
- FUNC_ENTER_NOAPI_NOINIT_NOERR
-
- /* Get the pointer to the prefix */
- prefix = H5RS_get_str(prefix_r);
-
- /* Get the pointer to the raw src user path */
- name = H5RS_get_str(name_r);
-
- /* Create reference counted string for path */
- ret_value = H5G_build_fullpath(prefix, name);
-
- FUNC_LEAVE_NOAPI(ret_value)
-} /* end H5G_build_fullpath_refstr_refstr() */
-#endif /* NOT_YET */
-
-
/*-------------------------------------------------------------------------
* Function: H5G__name_init
*
@@ -423,7 +339,7 @@ H5G_build_fullpath_refstr_refstr(const H5RS_str_t *prefix_r, const H5RS_str_t *n
herr_t
H5G__name_init(H5G_name_t *name, const char *path)
{
- FUNC_ENTER_PACKAGE
+ FUNC_ENTER_PACKAGE_NOERR
/* Check arguments */
HDassert(name);
@@ -438,7 +354,6 @@ H5G__name_init(H5G_name_t *name, const char *path)
FUNC_LEAVE_NOAPI(SUCCEED)
} /* end H5G__name_init() */
-
/*-------------------------------------------------------------------------
* Function: H5G_name_set
*
@@ -447,7 +362,7 @@ H5G__name_init(H5G_name_t *name, const char *path)
* Return: Success: Non-negative
* Failure: Negative
*
- * Programmer: Pedro Vicente, pvn@ncsa.uiuc.edu
+ * Programmer: Pedro Vicente
* Thursday, August 22, 2002
*
*-------------------------------------------------------------------------
@@ -455,7 +370,7 @@ H5G__name_init(H5G_name_t *name, const char *path)
herr_t
H5G_name_set(const H5G_name_t *loc, H5G_name_t *obj, const char *name)
{
- herr_t ret_value = SUCCEED;
+ herr_t ret_value = SUCCEED;
FUNC_ENTER_NOAPI(FAIL)
@@ -467,16 +382,16 @@ H5G_name_set(const H5G_name_t *loc, H5G_name_t *obj, const char *name)
H5G_name_free(obj);
/* Create the object's full path, if a full path exists in the location */
- if(loc->full_path_r) {
+ if (loc->full_path_r) {
/* Go build the new full path */
- if((obj->full_path_r = H5G_build_fullpath_refstr_str(loc->full_path_r, name)) == NULL)
+ if ((obj->full_path_r = H5G_build_fullpath_refstr_str(loc->full_path_r, name)) == NULL)
HGOTO_ERROR(H5E_SYM, H5E_PATH, FAIL, "can't build user path name")
} /* end if */
/* Create the object's user path, if a user path exists in the location */
- if(loc->user_path_r) {
+ if (loc->user_path_r) {
/* Go build the new user path */
- if((obj->user_path_r = H5G_build_fullpath_refstr_str(loc->user_path_r, name)) == NULL)
+ if ((obj->user_path_r = H5G_build_fullpath_refstr_str(loc->user_path_r, name)) == NULL)
HGOTO_ERROR(H5E_SYM, H5E_PATH, FAIL, "can't build user path name")
} /* end if */
@@ -484,7 +399,6 @@ done:
FUNC_LEAVE_NOAPI(ret_value)
} /* end H5G_name_set() */
-
/*-------------------------------------------------------------------------
* Function: H5G_name_copy
*
@@ -523,21 +437,22 @@ H5G_name_copy(H5G_name_t *dst, const H5G_name_t *src, H5_copy_depth_t depth)
HDassert(depth == H5_COPY_SHALLOW || depth == H5_COPY_DEEP);
/* Copy the top level information */
- HDmemcpy(dst, src, sizeof(H5G_name_t));
+ H5MM_memcpy(dst, src, sizeof(H5G_name_t));
/* Deep copy the names */
- if(depth == H5_COPY_DEEP) {
+ if (depth == H5_COPY_DEEP) {
dst->full_path_r = H5RS_dup(src->full_path_r);
dst->user_path_r = H5RS_dup(src->user_path_r);
- } else {
- /* Discarding 'const' qualifier OK - QAK */
+ }
+ else {
+ H5_GCC_CLANG_DIAG_OFF("cast-qual")
H5G_name_reset((H5G_name_t *)src);
- } /* end if */
+ H5_GCC_CLANG_DIAG_ON("cast-qual")
+ }
FUNC_LEAVE_NOAPI(SUCCEED)
} /* end H5G_name_copy() */
-
/*-------------------------------------------------------------------------
* Function: H5G_get_name
*
@@ -551,18 +466,12 @@ H5G_name_copy(H5G_name_t *dst, const H5G_name_t *src, H5_copy_depth_t depth)
* Programmer: Quincey Koziol
* Tuesday, December 13, 2005
*
- * Modifications: Leon Arber
- * Oct. 18, 2006
- * Added functionality to get the name for a reference.
- *
*-------------------------------------------------------------------------
*/
-ssize_t
-H5G_get_name(const H5G_loc_t *loc, char *name/*out*/, size_t size,
- hbool_t *cached, hid_t lapl_id, hid_t dxpl_id)
+herr_t
+H5G_get_name(const H5G_loc_t *loc, char *name /*out*/, size_t size, size_t *name_len, hbool_t *cached)
{
- ssize_t len = 0; /* Length of object's name */
- ssize_t ret_value; /* Return value */
+ herr_t ret_value = SUCCEED; /* Return value */
FUNC_ENTER_NOAPI(FAIL)
@@ -570,51 +479,41 @@ H5G_get_name(const H5G_loc_t *loc, char *name/*out*/, size_t size,
HDassert(loc);
/* If the user path is available and it's not "hidden", use it */
- if(loc->path->user_path_r != NULL && loc->path->obj_hidden == 0) {
+ if (loc->path->user_path_r != NULL && loc->path->obj_hidden == 0) {
+ size_t len; /* Length of object's name */
+
len = H5RS_len(loc->path->user_path_r);
- if(name) {
- HDstrncpy(name, H5RS_get_str(loc->path->user_path_r), MIN((size_t)(len + 1), size));
- if((size_t)len >= size)
+ if (name) {
+ HDstrncpy(name, H5RS_get_str(loc->path->user_path_r), MIN((len + 1), size));
+ if (len >= size)
name[size - 1] = '\0';
} /* end if */
+ /* Set name length, if requested */
+ if (name_len)
+ *name_len = len;
+
/* Indicate that the name is cached, if requested */
/* (Currently only used for testing - QAK, 2010/07/26) */
- if(cached)
+ if (cached)
*cached = TRUE;
} /* end if */
- else if(!loc->path->obj_hidden) {
- hid_t file;
-
- /* Retrieve file ID for name search */
- if((file = H5F_get_id(loc->oloc->file, FALSE)) < 0)
- HGOTO_ERROR(H5E_SYM, H5E_CANTGET, FAIL, "can't get file ID")
-
+ else if (!loc->path->obj_hidden) {
/* Search for name of object */
- if((len = H5G_get_name_by_addr(file, lapl_id, dxpl_id, loc->oloc, name, size)) < 0) {
- H5I_dec_ref(file);
+ if (H5G_get_name_by_addr(loc->oloc->file, loc->oloc, name, size, name_len) < 0)
HGOTO_ERROR(H5E_SYM, H5E_CANTGET, FAIL, "can't determine name")
- } /* end if */
-
- /* Close file ID used for search */
- if(H5I_dec_ref(file) < 0)
- HGOTO_ERROR(H5E_SYM, H5E_CANTCLOSEFILE, FAIL, "can't determine name")
/* Indicate that the name is _not_ cached, if requested */
/* (Currently only used for testing - QAK, 2010/07/26) */
- if(cached)
+ if (cached)
*cached = FALSE;
} /* end else */
- /* Set return value */
- ret_value = len;
-
done:
FUNC_LEAVE_NOAPI(ret_value)
} /* end H5G_get_name() */
-
/*-------------------------------------------------------------------------
* Function: H5G_name_reset
*
@@ -642,7 +541,6 @@ H5G_name_reset(H5G_name_t *name)
FUNC_LEAVE_NOAPI(SUCCEED)
} /* end H5G_name_reset() */
-
/*-------------------------------------------------------------------------
* Function: H5G_name_free
*
@@ -650,7 +548,7 @@ H5G_name_reset(H5G_name_t *name)
*
* Return: Success
*
- * Programmer: Pedro Vicente, pvn@ncsa.uiuc.edu
+ * Programmer: Pedro Vicente
*
* Date: August 22, 2002
*
@@ -664,11 +562,11 @@ H5G_name_free(H5G_name_t *name)
/* Check args */
HDassert(name);
- if(name->full_path_r) {
+ if (name->full_path_r) {
H5RS_decr(name->full_path_r);
name->full_path_r = NULL;
} /* end if */
- if(name->user_path_r) {
+ if (name->user_path_r) {
H5RS_decr(name->user_path_r);
name->user_path_r = NULL;
} /* end if */
@@ -677,9 +575,8 @@ H5G_name_free(H5G_name_t *name)
FUNC_LEAVE_NOAPI(SUCCEED)
} /* end H5G_name_free() */
-
/*-------------------------------------------------------------------------
- * Function: H5G_name_move_path
+ * Function: H5G__name_move_path
*
* Purpose: Update a user or canonical path after an object moves
*
@@ -692,15 +589,15 @@ H5G_name_free(H5G_name_t *name)
*-------------------------------------------------------------------------
*/
static herr_t
-H5G_name_move_path(H5RS_str_t **path_r_ptr, const char *full_suffix, const char *src_path,
- const char *dst_path)
+H5G__name_move_path(H5RS_str_t **path_r_ptr, const char *full_suffix, const char *src_path,
+ const char *dst_path)
{
- const char *path; /* Path to update */
- size_t path_len; /* Length of path */
- size_t full_suffix_len; /* Length of full suffix */
- herr_t ret_value = SUCCEED; /* Return value */
+ const char *path; /* Path to update */
+ size_t path_len; /* Length of path */
+ size_t full_suffix_len; /* Length of full suffix */
+ herr_t ret_value = SUCCEED; /* Return value */
- FUNC_ENTER_NOAPI_NOINIT
+ FUNC_ENTER_PACKAGE
/* Check arguments */
HDassert(path_r_ptr && *path_r_ptr);
@@ -714,30 +611,26 @@ H5G_name_move_path(H5RS_str_t **path_r_ptr, const char *full_suffix, const char
/* Check if path needs to be updated */
full_suffix_len = HDstrlen(full_suffix);
- path_len = HDstrlen(path);
- if(full_suffix_len < path_len) {
- const char *dst_suffix; /* Destination suffix that changes */
- const char *src_suffix; /* Source suffix that changes */
- size_t path_prefix_len; /* Length of path prefix */
- const char *path_prefix2; /* 2nd prefix for path */
- size_t path_prefix2_len; /* Length of 2nd path prefix */
- const char *common_prefix; /* Common prefix for src & dst paths */
- size_t common_prefix_len; /* Length of common prefix */
- char *new_path; /* Pointer to new path */
- size_t new_path_len; /* Length of new path */
-
-
- /* Compute path prefix before full suffix*/
+ path_len = HDstrlen(path);
+ if (full_suffix_len < path_len) {
+ const char *dst_suffix; /* Destination suffix that changes */
+ const char *src_suffix; /* Source suffix that changes */
+ size_t path_prefix_len; /* Length of path prefix */
+ const char *path_prefix2; /* 2nd prefix for path */
+ size_t path_prefix2_len; /* Length of 2nd path prefix */
+ size_t common_prefix_len; /* Length of common prefix */
+ H5RS_str_t *rs; /* Ref-counted string for new path */
+
+ /* Compute path prefix before full suffix */
path_prefix_len = path_len - full_suffix_len;
/* Determine the common prefix for src & dst paths */
- common_prefix = src_path;
common_prefix_len = 0;
/* Find first character that is different */
- while(*(src_path + common_prefix_len) == *(dst_path + common_prefix_len))
+ while (*(src_path + common_prefix_len) == *(dst_path + common_prefix_len))
common_prefix_len++;
/* Back up to previous '/' */
- while(*(common_prefix + common_prefix_len) != '/')
+ while (*(src_path + common_prefix_len) != '/')
common_prefix_len--;
/* Include '/' */
common_prefix_len++;
@@ -748,97 +641,97 @@ H5G_name_move_path(H5RS_str_t **path_r_ptr, const char *full_suffix, const char
/* Determine destination suffix */
dst_suffix = dst_path + (common_prefix_len - 1);
- /* Compute path prefix before src suffix*/
- path_prefix2 = path;
+ /* Compute path prefix before src suffix */
+ path_prefix2 = path;
path_prefix2_len = path_prefix_len - HDstrlen(src_suffix);
- /* Allocate space for the new path */
- new_path_len = path_prefix2_len + HDstrlen(dst_suffix) + full_suffix_len;
- if(NULL == (new_path = (char *)H5FL_BLK_MALLOC(str_buf, new_path_len + 1)))
- HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, FAIL, "memory allocation failed")
+ /* Allocate new ref-counted string */
+ if (NULL == (rs = H5RS_create(NULL)))
+ HGOTO_ERROR(H5E_SYM, H5E_CANTCREATE, FAIL, "can't create ref-counted string")
/* Create the new path */
- if(path_prefix2_len > 0) {
- HDstrncpy(new_path, path_prefix2, path_prefix2_len);
- HDstrcpy(new_path + path_prefix2_len, dst_suffix);
- } /* end if */
- else
- HDstrcpy(new_path, dst_suffix);
- if(full_suffix_len > 0)
- HDstrcat(new_path, full_suffix);
+ if (path_prefix2_len > 0)
+ H5RS_ancat(rs, path_prefix2, path_prefix2_len);
+ H5RS_acat(rs, dst_suffix);
+ if (full_suffix_len > 0)
+ H5RS_acat(rs, full_suffix);
/* Release previous path */
H5RS_decr(*path_r_ptr);
/* Take ownership of the new full path */
- *path_r_ptr = H5RS_own(new_path);
+ *path_r_ptr = rs;
} /* end if */
done:
FUNC_LEAVE_NOAPI(ret_value)
-} /* end H5G_name_move_path() */
+} /* end H5G__name_move_path() */
-
/*-------------------------------------------------------------------------
- * Function: H5G_name_replace_cb
+ * Function: H5G__name_replace_cb
*
- * Purpose: H5I_search callback function to replace group entry names
+ * Purpose: H5I_iterate callback function to replace group entry names
*
* Return: Success: 0, Failure: -1
*
- * Programmer: Pedro Vicente, pvn@ncsa.uiuc.edu
+ * Programmer: Pedro Vicente
*
* Date: June 5, 2002
*
*-------------------------------------------------------------------------
*/
static int
-H5G_name_replace_cb(void *obj_ptr, hid_t obj_id, void *key)
+H5G__name_replace_cb(void *obj_ptr, hid_t obj_id, void *key)
{
- const H5G_names_t *names = (const H5G_names_t *)key; /* Get operation's information */
- H5O_loc_t *oloc; /* Object location for object that the ID refers to */
- H5G_name_t *obj_path; /* Pointer to group hier. path for obj */
- H5F_t *top_obj_file; /* Top file in object's mounted file hier. */
- hbool_t obj_in_child = FALSE; /* Flag to indicate that the object is in the child mount hier. */
- herr_t ret_value = SUCCEED; /* Return value */
+ const H5G_names_t *names = (const H5G_names_t *)key; /* Get operation's information */
+ H5O_loc_t *oloc; /* Object location for object that the ID refers to */
+ H5G_name_t *obj_path; /* Pointer to group hier. path for obj */
+ H5F_t *top_obj_file; /* Top file in object's mounted file hier. */
+ hbool_t obj_in_child = FALSE; /* Flag to indicate that the object is in the child mount hier. */
+ herr_t ret_value = SUCCEED; /* Return value */
- FUNC_ENTER_NOAPI_NOINIT
+ FUNC_ENTER_PACKAGE
HDassert(obj_ptr);
/* Get the symbol table entry */
- switch(H5I_get_type(obj_id)) {
+ switch (H5I_get_type(obj_id)) {
case H5I_GROUP:
- oloc = H5G_oloc((H5G_t *)obj_ptr);
+ oloc = H5G_oloc((H5G_t *)obj_ptr);
obj_path = H5G_nameof((H5G_t *)obj_ptr);
break;
case H5I_DATASET:
- oloc = H5D_oloc((H5D_t *)obj_ptr);
+ oloc = H5D_oloc((H5D_t *)obj_ptr);
obj_path = H5D_nameof((H5D_t *)obj_ptr);
break;
case H5I_DATATYPE:
/* Avoid non-named datatypes */
- if(!H5T_is_named((H5T_t *)obj_ptr))
- HGOTO_DONE(SUCCEED) /* Do not exit search over IDs */
+ if (!H5T_is_named((H5T_t *)obj_ptr))
+ HGOTO_DONE(SUCCEED) /* Do not exit search over IDs */
- oloc = H5T_oloc((H5T_t *)obj_ptr);
+ oloc = H5T_oloc((H5T_t *)obj_ptr);
obj_path = H5T_nameof((H5T_t *)obj_ptr);
break;
+ case H5I_MAP:
+ HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "maps not supported in native VOL connector")
+
case H5I_UNINIT:
case H5I_BADID:
case H5I_FILE:
case H5I_DATASPACE:
case H5I_ATTR:
- case H5I_REFERENCE:
case H5I_VFL:
+ case H5I_VOL:
case H5I_GENPROP_CLS:
case H5I_GENPROP_LST:
case H5I_ERROR_CLASS:
case H5I_ERROR_MSG:
case H5I_ERROR_STACK:
+ case H5I_SPACE_SEL_ITER:
+ case H5I_EVENTSET:
case H5I_NTYPES:
default:
HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "unknown data object")
@@ -847,80 +740,73 @@ H5G_name_replace_cb(void *obj_ptr, hid_t obj_id, void *key)
HDassert(obj_path);
/* Check if the object has a full path still */
- if(!obj_path->full_path_r)
- HGOTO_DONE(SUCCEED) /* No need to look at object, it's path is already invalid */
+ if (!obj_path->full_path_r)
+ HGOTO_DONE(SUCCEED) /* No need to look at object, it's path is already invalid */
/* Find the top file in object's mount hier. */
- if(H5F_PARENT(oloc->file)) {
+ if (H5F_PARENT(oloc->file)) {
/* Check if object is in child file (for mount & unmount operations) */
- if(names->dst_file && H5F_SAME_SHARED(oloc->file, names->dst_file))
+ if (names->dst_file && H5F_SAME_SHARED(oloc->file, names->dst_file))
obj_in_child = TRUE;
/* Find the "top" file in the chain of mounted files */
top_obj_file = H5F_PARENT(oloc->file);
- while(H5F_PARENT(top_obj_file) != NULL) {
+ while (H5F_PARENT(top_obj_file) != NULL) {
/* Check if object is in child mount hier. (for mount & unmount operations) */
- if(names->dst_file && H5F_SAME_SHARED(top_obj_file, names->dst_file))
+ if (names->dst_file && H5F_SAME_SHARED(top_obj_file, names->dst_file))
obj_in_child = TRUE;
top_obj_file = H5F_PARENT(top_obj_file);
} /* end while */
- } /* end if */
+ } /* end if */
else
top_obj_file = oloc->file;
/* Check if object is in top of child mount hier. (for mount & unmount operations) */
- if(names->dst_file && H5F_SAME_SHARED(top_obj_file, names->dst_file))
+ if (names->dst_file && H5F_SAME_SHARED(top_obj_file, names->dst_file))
obj_in_child = TRUE;
/* Check if the object is in same file mount hier. */
- if(!H5F_SAME_SHARED(top_obj_file, names->src_file))
- HGOTO_DONE(SUCCEED) /* No need to look at object, it's path is already invalid */
+ if (!H5F_SAME_SHARED(top_obj_file, names->src_file))
+ HGOTO_DONE(SUCCEED) /* No need to look at object, it's path is already invalid */
- switch(names->op) {
+ switch (names->op) {
/*-------------------------------------------------------------------------
* H5G_NAME_MOUNT
*-------------------------------------------------------------------------
*/
case H5G_NAME_MOUNT:
/* Check if object is in child mount hier. */
- if(obj_in_child) {
- const char *full_path; /* Full path of current object */
- const char *src_path; /* Full path of source object */
- char *new_full_path; /* New full path of object */
- size_t new_full_len; /* Length of new full path */
+ if (obj_in_child) {
+ const char *full_path; /* Full path of current object */
+ const char *src_path; /* Full path of source object */
+ H5RS_str_t *rs; /* Ref-counted string for new path */
/* Get pointers to paths of interest */
full_path = H5RS_get_str(obj_path->full_path_r);
- src_path = H5RS_get_str(names->src_full_path_r);
-
- /* Build new full path */
-
- /* Allocate space for the new full path */
- new_full_len = HDstrlen(src_path) + HDstrlen(full_path);
- if(NULL == (new_full_path = (char *)H5FL_BLK_MALLOC(str_buf, new_full_len + 1)))
- HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, FAIL, "memory allocation failed")
+ src_path = H5RS_get_str(names->src_full_path_r);
- /* Create the new full path */
- HDstrcpy(new_full_path, src_path);
- HDstrcat(new_full_path, full_path);
+ /* Create new full path */
+ if (NULL == (rs = H5RS_create(src_path)))
+ HGOTO_ERROR(H5E_SYM, H5E_CANTCREATE, FAIL, "can't create ref-counted string")
+ H5RS_acat(rs, full_path);
/* Release previous full path */
H5RS_decr(obj_path->full_path_r);
/* Take ownership of the new full path */
- obj_path->full_path_r = H5RS_own(new_full_path);
+ obj_path->full_path_r = rs;
} /* end if */
/* Object must be in parent mount file hier. */
else {
/* Check if the source is along the entry's path */
/* (But not actually the entry itself) */
- if(H5G_common_path(obj_path->full_path_r, names->src_full_path_r) &&
- H5RS_cmp(obj_path->full_path_r, names->src_full_path_r)) {
+ if (H5G__common_path(obj_path->full_path_r, names->src_full_path_r) &&
+ H5RS_cmp(obj_path->full_path_r, names->src_full_path_r)) {
/* Hide the user path */
(obj_path->obj_hidden)++;
} /* end if */
- } /* end else */
+ } /* end else */
break;
/*-------------------------------------------------------------------------
@@ -928,47 +814,44 @@ H5G_name_replace_cb(void *obj_ptr, hid_t obj_id, void *key)
*-------------------------------------------------------------------------
*/
case H5G_NAME_UNMOUNT:
- if(obj_in_child) {
- const char *full_path; /* Full path of current object */
- const char *full_suffix; /* Full path after source path */
- const char *src_path; /* Full path of source object */
- char *new_full_path; /* New full path of object */
+ if (obj_in_child) {
+ const char *full_path; /* Full path of current object */
+ const char *full_suffix; /* Full path after source path */
+ const char *src_path; /* Full path of source object */
+ H5RS_str_t *rs; /* Ref-counted string for new path */
/* Get pointers to paths of interest */
full_path = H5RS_get_str(obj_path->full_path_r);
- src_path = H5RS_get_str(names->src_full_path_r);
+ src_path = H5RS_get_str(names->src_full_path_r);
/* Construct full path suffix */
full_suffix = full_path + HDstrlen(src_path);
- /* Build new full path */
-
- /* Create the new full path */
- if(NULL == (new_full_path = (char *)H5FL_BLK_MALLOC(str_buf, HDstrlen(full_suffix) + 1)))
- HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, FAIL, "memory allocation failed")
- HDstrcpy(new_full_path, full_suffix);
+ /* Create new full path suffix */
+ if (NULL == (rs = H5RS_create(full_suffix)))
+ HGOTO_ERROR(H5E_SYM, H5E_CANTCREATE, FAIL, "can't create ref-counted string")
/* Release previous full path */
H5RS_decr(obj_path->full_path_r);
/* Take ownership of the new full path */
- obj_path->full_path_r = H5RS_own(new_full_path);
+ obj_path->full_path_r = rs;
/* Check if the object's user path should be invalidated */
- if(obj_path->user_path_r && HDstrlen(new_full_path) < (size_t)H5RS_len(obj_path->user_path_r)) {
+ if (obj_path->user_path_r && H5RS_len(rs) < H5RS_len(obj_path->user_path_r)) {
/* Free user path */
H5RS_decr(obj_path->user_path_r);
obj_path->user_path_r = NULL;
} /* end if */
- } /* end if */
+ } /* end if */
else {
/* Check if file being unmounted was hiding the object */
- if(H5G_common_path(obj_path->full_path_r, names->src_full_path_r) &&
- H5RS_cmp(obj_path->full_path_r, names->src_full_path_r)) {
+ if (H5G__common_path(obj_path->full_path_r, names->src_full_path_r) &&
+ H5RS_cmp(obj_path->full_path_r, names->src_full_path_r)) {
/* Un-hide the user path */
(obj_path->obj_hidden)--;
} /* end if */
- } /* end else */
+ } /* end else */
break;
/*-------------------------------------------------------------------------
@@ -977,7 +860,7 @@ H5G_name_replace_cb(void *obj_ptr, hid_t obj_id, void *key)
*/
case H5G_NAME_DELETE:
/* Check if the location being unlinked is in the path for the current object */
- if(H5G_common_path(obj_path->full_path_r, names->src_full_path_r)) {
+ if (H5G__common_path(obj_path->full_path_r, names->src_full_path_r)) {
/* Free paths for object */
H5G_name_free(obj_path);
} /* end if */
@@ -989,21 +872,20 @@ H5G_name_replace_cb(void *obj_ptr, hid_t obj_id, void *key)
*/
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)) {
- const char *full_path; /* Full path of current object */
- const char *full_suffix; /* Suffix of full path, after src_path */
- char *new_full_path; /* New full path of object */
- size_t new_full_len; /* Length of new full path */
- const char *src_path; /* Full path of source object */
- const char *dst_path; /* Full path of destination object */
+ if (H5G__common_path(obj_path->full_path_r, names->src_full_path_r)) {
+ const char *full_path; /* Full path of current object */
+ const char *full_suffix; /* Suffix of full path, after src_path */
+ const char *src_path; /* Full path of source object */
+ const char *dst_path; /* Full path of destination object */
+ H5RS_str_t *rs; /* Ref-counted string for new path */
/* Sanity check */
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(names->src_full_path_r);
- dst_path = H5RS_get_str(names->dst_full_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 == '/');
@@ -1013,26 +895,20 @@ H5G_name_replace_cb(void *obj_ptr, hid_t obj_id, void *key)
full_suffix = full_path + HDstrlen(src_path);
/* Update the user path, if one exists */
- if(obj_path->user_path_r)
- if(H5G_name_move_path(&(obj_path->user_path_r), full_suffix, src_path, dst_path) < 0)
+ if (obj_path->user_path_r)
+ if (H5G__name_move_path(&(obj_path->user_path_r), full_suffix, src_path, dst_path) < 0)
HGOTO_ERROR(H5E_SYM, H5E_PATH, FAIL, "can't build user path name")
- /* Build new full path */
-
- /* Allocate space for the new full path */
- new_full_len = HDstrlen(dst_path) + HDstrlen(full_suffix);
- if(NULL == (new_full_path = (char *)H5FL_BLK_MALLOC(str_buf, new_full_len + 1)))
- HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, FAIL, "memory allocation failed")
-
- /* Create the new full path */
- HDstrcpy(new_full_path, dst_path);
- HDstrcat(new_full_path, full_suffix);
+ /* Create new full path */
+ if (NULL == (rs = H5RS_create(dst_path)))
+ HGOTO_ERROR(H5E_SYM, H5E_CANTCREATE, FAIL, "can't create ref-counted string")
+ H5RS_acat(rs, full_suffix);
/* Release previous full path */
H5RS_decr(obj_path->full_path_r);
/* Take ownership of the new full path */
- obj_path->full_path_r = H5RS_own(new_full_path);
+ obj_path->full_path_r = rs;
} /* end if */
break;
@@ -1042,14 +918,13 @@ H5G_name_replace_cb(void *obj_ptr, hid_t obj_id, void *key)
done:
FUNC_LEAVE_NOAPI(ret_value);
-} /* end H5G_name_replace_cb() */
+} /* end H5G__name_replace_cb() */
-
/*-------------------------------------------------------------------------
* Function: H5G_name_replace
*
* Purpose: Search the list of open IDs and replace names according to a
- * particular operation. The operation occured on the
+ * particular operation. The operation occurred on the
* SRC_FILE/SRC_FULL_PATH_R object. The new name (if there is
* one) is NEW_NAME_R. Additional entry location information
* (currently only needed for the 'move' operation) is passed in
@@ -1057,16 +932,15 @@ done:
*
* Return: Success: 0, Failure: -1
*
- * Programmer: Pedro Vicente, pvn@ncsa.uiuc.edu
+ * Programmer: Pedro Vicente
*
* Date: June 11, 2002
*
*-------------------------------------------------------------------------
*/
herr_t
-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)
+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)
{
herr_t ret_value = SUCCEED;
@@ -1076,53 +950,56 @@ H5G_name_replace(const H5O_link_t *lnk, H5G_names_op_t op, H5F_t *src_file,
HDassert(src_file);
/* Check if the object we are manipulating has a path */
- if(src_full_path_r) {
- 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 */
+ if (src_full_path_r) {
+ 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) {
+ 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;
-
- case H5O_TYPE_UNKNOWN:
- case H5O_TYPE_NTYPES:
- /* Search and replace names through datatype IDs */
- default:
- HGOTO_ERROR(H5E_SYM, H5E_BADTYPE, FAIL, "not valid object type")
- } /* end switch */
- } /* end case */
- break;
+ 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) < 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;
+
+ case H5O_TYPE_MAP:
+ HGOTO_ERROR(H5E_SYM, H5E_BADTYPE, FAIL,
+ "maps not supported in native VOL connector")
+
+ case H5O_TYPE_UNKNOWN:
+ case H5O_TYPE_NTYPES:
+ /* Search and replace names through datatype IDs */
+ 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 */
@@ -1132,10 +1009,10 @@ H5G_name_replace(const H5O_link_t *lnk, H5G_names_op_t op, H5F_t *src_file,
case H5L_TYPE_ERROR:
case H5L_TYPE_EXTERNAL:
case H5L_TYPE_MAX:
- default: /* User-defined link */
+ 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")
+ 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),
@@ -1143,72 +1020,73 @@ H5G_name_replace(const H5O_link_t *lnk, H5G_names_op_t op, H5F_t *src_file,
*/
break;
} /* end switch */
- } /* end if */
+ } /* 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) {
- H5G_names_t names; /* Structure to hold operation information for callback */
+ if (search_group || search_dataset || search_datatype) {
+ H5G_names_t names; /* Structure to hold operation information for callback */
/* Find top file in src location's mount hierarchy */
- while(H5F_PARENT(src_file))
+ while (H5F_PARENT(src_file))
src_file = H5F_PARENT(src_file);
/* Set up common information for callback */
- names.src_file = src_file;
+ names.src_file = src_file;
names.src_full_path_r = src_full_path_r;
- names.dst_file = dst_file;
+ names.dst_file = dst_file;
names.dst_full_path_r = dst_full_path_r;
- names.op = op;
+ names.op = op;
/* Search through group IDs */
- if(search_group)
- H5I_search(H5I_GROUP, H5G_name_replace_cb, &names, FALSE);
+ if (search_group)
+ if (H5I_iterate(H5I_GROUP, H5G__name_replace_cb, &names, FALSE) < 0)
+ HGOTO_ERROR(H5E_SYM, H5E_BADITER, FAIL, "can't iterate over groups")
/* Search through dataset IDs */
- if(search_dataset)
- H5I_search(H5I_DATASET, H5G_name_replace_cb, &names, FALSE);
+ if (search_dataset)
+ if (H5I_iterate(H5I_DATASET, H5G__name_replace_cb, &names, FALSE) < 0)
+ HGOTO_ERROR(H5E_SYM, H5E_BADITER, FAIL, "can't iterate over datasets")
/* Search through datatype IDs */
- if(search_datatype)
- H5I_search(H5I_DATATYPE, H5G_name_replace_cb, &names, FALSE);
+ if (search_datatype)
+ if (H5I_iterate(H5I_DATATYPE, H5G__name_replace_cb, &names, FALSE) < 0)
+ HGOTO_ERROR(H5E_SYM, H5E_BADITER, FAIL, "can't iterate over datatypes")
} /* end if */
- } /* end if */
+ } /* end if */
done:
FUNC_LEAVE_NOAPI(ret_value)
} /* end H5G_name_replace() */
-
/*-------------------------------------------------------------------------
- * Function: H5G_get_name_by_addr_cb
+ * Function: H5G__get_name_by_addr_cb
*
* Purpose: Callback for retrieving object's name by address
*
* Return: Positive if path is for object desired
- * 0 if not correct object
- * negative on failure.
+ * 0 if not correct object
+ * negative on failure.
*
* Programmer: Quincey Koziol
- * November 4 2007
+ * November 4 2007
*
*-------------------------------------------------------------------------
*/
static herr_t
-H5G_get_name_by_addr_cb(hid_t gid, const char *path, const H5L_info_t *linfo,
- void *_udata)
+H5G__get_name_by_addr_cb(hid_t gid, const char *path, const H5L_info2_t *linfo, void *_udata)
{
H5G_gnba_iter_t *udata = (H5G_gnba_iter_t *)_udata; /* User data for iteration */
- H5G_loc_t obj_loc; /* Location of object */
- H5G_name_t obj_path; /* Object's group hier. path */
- H5O_loc_t obj_oloc; /* Object's object location */
- hbool_t obj_found = FALSE; /* Object at 'path' found */
- herr_t ret_value = H5_ITER_CONT; /* Return value */
+ H5G_loc_t obj_loc; /* Location of object */
+ H5G_name_t obj_path; /* Object's group hier. path */
+ H5O_loc_t obj_oloc; /* Object's object location */
+ hbool_t obj_found = FALSE; /* Object at 'path' found */
+ herr_t ret_value = H5_ITER_CONT; /* Return value */
- FUNC_ENTER_NOAPI_NOINIT
+ FUNC_ENTER_PACKAGE
/* Sanity check */
HDassert(path);
@@ -1217,115 +1095,126 @@ H5G_get_name_by_addr_cb(hid_t gid, const char *path, const H5L_info_t *linfo,
HDassert(udata->path == NULL);
/* Check for hard link with correct address */
- if(linfo->type == H5L_TYPE_HARD && udata->loc->addr == linfo->u.address) {
- H5G_loc_t grp_loc; /* Location of group */
-
- /* Get group's location */
- if(H5G_loc(gid, &grp_loc) < 0)
- HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, H5_ITER_ERROR, "bad group location")
-
- /* Set up opened object location to fill in */
- obj_loc.oloc = &obj_oloc;
- obj_loc.path = &obj_path;
- H5G_loc_reset(&obj_loc);
-
- /* Find the object */
- if(H5G_loc_find(&grp_loc, path, &obj_loc/*out*/, udata->lapl_id, udata->dxpl_id) < 0)
- HGOTO_ERROR(H5E_SYM, H5E_NOTFOUND, H5_ITER_ERROR, "object not found")
- obj_found = TRUE;
-
- /* Check for object in same file (handles mounted files) */
- /* (re-verify address, in case we traversed a file mount) */
- if(udata->loc->addr == obj_loc.oloc->addr && udata->loc->file == obj_loc.oloc->file) {
- if(NULL == (udata->path = H5MM_strdup(path)))
- HGOTO_ERROR(H5E_SYM, H5E_CANTALLOC, H5_ITER_ERROR, "can't duplicate path string")
-
- /* We found a match so we return immediately */
- HGOTO_DONE(H5_ITER_STOP)
- } /* end if */
- } /* end if */
+ if (linfo->type == H5L_TYPE_HARD) {
+ haddr_t link_addr;
+
+ /* Retrieve hard link address from VOL token */
+ if (H5VL_native_token_to_addr(udata->loc->file, H5I_FILE, linfo->u.token, &link_addr) < 0)
+ HGOTO_ERROR(H5E_SYM, H5E_CANTUNSERIALIZE, FAIL, "can't deserialize object token into address")
+
+ if (udata->loc->addr == link_addr) {
+ H5G_loc_t grp_loc; /* Location of group */
+
+ /* Get group's location */
+ if (H5G_loc(gid, &grp_loc) < 0)
+ HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, H5_ITER_ERROR, "bad group location")
+
+ /* Set up opened object location to fill in */
+ obj_loc.oloc = &obj_oloc;
+ obj_loc.path = &obj_path;
+ H5G_loc_reset(&obj_loc);
+
+ /* Find the object */
+ if (H5G_loc_find(&grp_loc, path, &obj_loc /*out*/) < 0)
+ HGOTO_ERROR(H5E_SYM, H5E_NOTFOUND, H5_ITER_ERROR, "object not found")
+ obj_found = TRUE;
+
+ /* Check for object in same file (handles mounted files) */
+ /* (re-verify address, in case we traversed a file mount) */
+ if (udata->loc->addr == obj_loc.oloc->addr && udata->loc->file == obj_loc.oloc->file) {
+ if (NULL == (udata->path = H5MM_strdup(path)))
+ HGOTO_ERROR(H5E_SYM, H5E_CANTALLOC, H5_ITER_ERROR, "can't duplicate path string")
+
+ /* We found a match so we return immediately */
+ HGOTO_DONE(H5_ITER_STOP)
+ } /* end if */
+ } /* end if */
+ } /* end if */
done:
- if(obj_found && H5G_loc_free(&obj_loc) < 0)
+ if (obj_found && H5G_loc_free(&obj_loc) < 0)
HDONE_ERROR(H5E_SYM, H5E_CANTRELEASE, H5_ITER_ERROR, "can't free location")
FUNC_LEAVE_NOAPI(ret_value)
-} /* end H5G_get_name_by_addr_cb() */
+} /* end H5G__get_name_by_addr_cb() */
-
/*-------------------------------------------------------------------------
* Function: H5G_get_name_by_addr
*
* Purpose: Tries to figure out the path to an object from it's address
*
- * Return: returns size of path name, and copies it into buffer
- * pointed to by name if that buffer is big enough.
- * 0 if it cannot find the path
- * negative on failure.
+ * Return: Success: Returns size of path name, and copies it into buffer
+ * pointed to by name if that buffer is big enough.
+ * 0 if it cannot find the path
+ *
+ * Failure: -1
*
* Programmer: Quincey Koziol
* November 4 2007
*
*-------------------------------------------------------------------------
*/
-ssize_t
-H5G_get_name_by_addr(hid_t file, hid_t lapl_id, hid_t dxpl_id, const H5O_loc_t *loc,
- char *name, size_t size)
+herr_t
+H5G_get_name_by_addr(H5F_t *f, const H5O_loc_t *loc, char *name, size_t size, size_t *name_len)
{
- H5G_gnba_iter_t udata; /* User data for iteration */
- H5G_loc_t root_loc; /* Root group's location */
- hbool_t found_obj = FALSE; /* If we found the object */
- herr_t status; /* Status from iteration */
- ssize_t ret_value; /* Return value */
+ H5G_gnba_iter_t udata; /* User data for iteration */
+ size_t len; /* Length of path name */
+ H5G_loc_t root_loc; /* Root group's location */
+ hbool_t found_obj = FALSE; /* If we found the object */
+ herr_t status; /* Status from iteration */
+ herr_t ret_value = SUCCEED; /* Return value */
/* Portably clear udata struct (before FUNC_ENTER) */
HDmemset(&udata, 0, sizeof(udata));
FUNC_ENTER_NOAPI(FAIL)
- /* Construct the link info for the file's root group */
- if(H5G_loc(file, &root_loc) < 0)
- HGOTO_ERROR(H5E_SYM, H5E_CANTGET, FAIL, "can't get root group's location")
+ /* Construct a group location for root group of the file */
+ if (H5G_root_loc(f, &root_loc) < 0)
+ HGOTO_ERROR(H5E_SYM, H5E_CANTGET, FAIL, "can't get root group's location")
/* Check for root group being the object looked for */
- if(root_loc.oloc->addr == loc->addr && root_loc.oloc->file == loc->file) {
- if(NULL == (udata.path = H5MM_strdup("")))
+ if (root_loc.oloc->addr == loc->addr && root_loc.oloc->file == loc->file) {
+ if (NULL == (udata.path = H5MM_strdup("")))
HGOTO_ERROR(H5E_SYM, H5E_CANTALLOC, FAIL, "can't duplicate path string")
found_obj = TRUE;
} /* end if */
else {
/* Set up user data for iterator */
- udata.loc = loc;
- udata.lapl_id = lapl_id;
- udata.dxpl_id = dxpl_id;
+ udata.loc = loc;
udata.path = NULL;
/* Visit all the links in the file */
- if((status = H5G_visit(file, "/", H5_INDEX_NAME, H5_ITER_NATIVE, H5G_get_name_by_addr_cb, &udata, lapl_id, dxpl_id)) < 0)
+ if ((status = H5G_visit(&root_loc, "/", H5_INDEX_NAME, H5_ITER_NATIVE, H5G__get_name_by_addr_cb,
+ &udata)) < 0)
HGOTO_ERROR(H5E_SYM, H5E_BADITER, FAIL, "group traversal failed while looking for object name")
- else if(status > 0)
+ else if (status > 0)
found_obj = TRUE;
} /* end else */
/* Check for finding the object */
- if(found_obj) {
+ if (found_obj) {
/* Set the length of the full path */
- ret_value = (ssize_t)(HDstrlen(udata.path) + 1); /* Length of path + 1 (for "/") */
+ len = HDstrlen(udata.path) + 1; /* Length of path + 1 (for "/") */
/* If there's a buffer provided, copy into it, up to the limit of its size */
- if(name) {
+ if (name) {
/* Copy the initial path separator */
- HDstrcpy(name, "/");
+ HDstrncpy(name, "/", (size_t)2);
/* Append the rest of the path */
/* (less one character, for the initial path separator) */
HDstrncat(name, udata.path, (size - 2));
- if((size_t)ret_value >= size)
+ if (len >= size)
name[size - 1] = '\0';
} /* end if */
- } /* end if */
+ } /* end if */
else
- ret_value = 0;
+ len = 0;
+
+ /* Set path name length, if given */
+ if (name_len)
+ *name_len = len;
done:
/* Release resources */