summaryrefslogtreecommitdiffstats
path: root/src/H5Oint.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/H5Oint.c')
-rw-r--r--src/H5Oint.c129
1 files changed, 104 insertions, 25 deletions
diff --git a/src/H5Oint.c b/src/H5Oint.c
index a16102a..d5a3a71 100644
--- a/src/H5Oint.c
+++ b/src/H5Oint.c
@@ -43,6 +43,8 @@
#include "H5Opkg.h" /* Object headers */
#include "H5VLprivate.h" /* Virtual Object Layer */
+#include "H5VLnative_private.h" /* Native VOL connector */
+
/****************/
/* Local Macros */
@@ -58,7 +60,7 @@ typedef struct {
hid_t obj_id; /* The ID for the starting group */
H5G_loc_t *start_loc; /* Location of starting group */
H5SL_t *visited; /* Skip list for tracking visited nodes */
- H5O_iterate_t op; /* Application callback */
+ H5O_iterate2_t op; /* Application callback */
void *op_data; /* Application's op data */
unsigned fields; /* Selection of object info */
} H5O_iter_visit_ud_t;
@@ -78,9 +80,11 @@ static herr_t H5O__obj_type_real(const H5O_t *oh, H5O_type_t *obj_type);
static herr_t H5O__get_hdr_info_real(const H5O_t *oh, H5O_hdr_info_t *hdr);
static herr_t H5O__free_visit_visited(void *item, void *key,
void *operator_data/*in,out*/);
-static herr_t H5O__visit_cb(hid_t group, const char *name, const H5L_info_t *linfo,
+static herr_t H5O__visit_cb(hid_t group, const char *name, const H5L_info2_t *linfo,
void *_udata);
static const H5O_obj_class_t *H5O__obj_class_real(const H5O_t *oh);
+static herr_t H5O__reset_info2(H5O_info2_t *oinfo);
+
/*********************/
/* Package Variables */
@@ -151,6 +155,13 @@ H5FL_BLK_DEFINE(chunk_image);
/* Declare external the free list for H5O_cont_t sequences */
H5FL_SEQ_EXTERN(H5O_cont_t);
+/* The canonical 'undefined' token */
+const H5O_token_t H5O_TOKEN_UNDEF_g = {{
+ 255, 255, 255, 255,
+ 255, 255, 255, 255,
+ 255, 255, 255, 255,
+ 255, 255, 255, 255}};
+
/*****************************/
/* Library Private Variables */
@@ -2155,9 +2166,7 @@ H5O__get_hdr_info_real(const H5O_t *oh, H5O_hdr_info_t *hdr)
/*-------------------------------------------------------------------------
* Function: H5O_get_info
*
- * Purpose: Retrieve the information for an object
- *
- * Note: Add a parameter "fields" to indicate selection of object info.
+ * Purpose: Retrieve the data model information for an object
*
* Return: Success: Non-negative
* Failure: Negative
@@ -2168,7 +2177,7 @@ H5O__get_hdr_info_real(const H5O_t *oh, H5O_hdr_info_t *hdr)
*-------------------------------------------------------------------------
*/
herr_t
-H5O_get_info(const H5O_loc_t *loc, H5O_info_t *oinfo, unsigned fields)
+H5O_get_info(const H5O_loc_t *loc, H5O_info2_t *oinfo, unsigned fields)
{
const H5O_obj_class_t *obj_class; /* Class of object for header */
H5O_t *oh = NULL; /* Object header */
@@ -2189,15 +2198,17 @@ H5O_get_info(const H5O_loc_t *loc, H5O_info_t *oinfo, unsigned fields)
HGOTO_ERROR(H5E_OHDR, H5E_CANTGET, FAIL, "unable to determine object class")
/* Reset the object info structure */
- HDmemset(oinfo, 0, sizeof(*oinfo));
+ if(H5O__reset_info2(oinfo) < 0)
+ HGOTO_ERROR(H5E_OHDR, H5E_CANTSET, FAIL, "can't reset object data struct")
/* Get basic information, if requested */
if(fields & H5O_INFO_BASIC) {
/* Retrieve the file's fileno */
H5F_GET_FILENO(loc->file, oinfo->fileno);
- /* Set the object's address */
- oinfo->addr = loc->addr;
+ /* Set the object's address into the token */
+ if(H5VL_native_addr_to_token(loc->file, H5I_FILE, loc->addr, &oinfo->token) < 0)
+ HGOTO_ERROR(H5E_OHDR, H5E_CANTSERIALIZE, FAIL, "can't serialize address into object token")
/* Retrieve the type of the object */
oinfo->type = obj_class->type;
@@ -2249,18 +2260,63 @@ H5O_get_info(const H5O_loc_t *loc, H5O_info_t *oinfo, unsigned fields)
} /* end else */
} /* end if */
- /* Get the information for the object header, if requested */
- if(fields & H5O_INFO_HDR)
- if(H5O__get_hdr_info_real(oh, &oinfo->hdr) < 0)
- HGOTO_ERROR(H5E_OHDR, H5E_CANTGET, FAIL, "can't retrieve object header info")
-
/* Retrieve # of attributes */
if(fields & H5O_INFO_NUM_ATTRS)
if(H5O__attr_count_real(loc->file, oh, &oinfo->num_attrs) < 0)
HGOTO_ERROR(H5E_OHDR, H5E_CANTGET, FAIL, "can't retrieve attribute count")
+done:
+ if(oh && H5O_unprotect(loc, oh, H5AC__NO_FLAGS_SET) < 0)
+ HDONE_ERROR(H5E_OHDR, H5E_CANTUNPROTECT, FAIL, "unable to release object header")
+
+ FUNC_LEAVE_NOAPI_TAG(ret_value)
+} /* end H5O_get_info() */
+
+
+/*-------------------------------------------------------------------------
+ * Function: H5O_get_native_info
+ *
+ * Purpose: Retrieve the native file-format information for an object
+ *
+ * Return: Success: Non-negative
+ * Failure: Negative
+ *
+ * Programmer: Quincey Koziol
+ * November 21 2006
+ *
+ *-------------------------------------------------------------------------
+ */
+herr_t
+H5O_get_native_info(const H5O_loc_t *loc, H5O_native_info_t *oinfo, unsigned fields)
+{
+ const H5O_obj_class_t *obj_class; /* Class of object for header */
+ H5O_t *oh = NULL; /* Object header */
+ herr_t ret_value = SUCCEED; /* Return value */
+
+ FUNC_ENTER_NOAPI_TAG(loc->addr, FAIL)
+
+ /* Check args */
+ HDassert(loc);
+ HDassert(oinfo);
+
+ /* Get the object header */
+ if(NULL == (oh = H5O_protect(loc, H5AC__READ_ONLY_FLAG, FALSE)))
+ HGOTO_ERROR(H5E_OHDR, H5E_CANTPROTECT, FAIL, "unable to load object header")
+
+ /* Get class for object */
+ if(NULL == (obj_class = H5O__obj_class_real(oh)))
+ HGOTO_ERROR(H5E_OHDR, H5E_CANTGET, FAIL, "unable to determine object class")
+
+ /* Reset the object info structure */
+ HDmemset(oinfo, 0, sizeof(*oinfo));
+
+ /* Get the information for the object header, if requested */
+ if(fields & H5O_NATIVE_INFO_HDR)
+ if(H5O__get_hdr_info_real(oh, &oinfo->hdr) < 0)
+ HGOTO_ERROR(H5E_OHDR, H5E_CANTGET, FAIL, "can't retrieve object header info")
+
/* Get B-tree & heap metadata storage size, if requested */
- if(fields & H5O_INFO_META_SIZE) {
+ if(fields & H5O_NATIVE_INFO_META_SIZE) {
/* Check for 'bh_info' callback for this type of object */
if(obj_class->bh_info)
/* Call the object's class 'bh_info' routine */
@@ -2268,10 +2324,8 @@ H5O_get_info(const H5O_loc_t *loc, H5O_info_t *oinfo, unsigned fields)
HGOTO_ERROR(H5E_OHDR, H5E_CANTGET, FAIL, "can't retrieve object's btree & heap info")
/* Get B-tree & heap info for any attributes */
- if(!(fields & H5O_INFO_NUM_ATTRS) || oinfo->num_attrs > 0) {
- if(H5O__attr_bh_info(loc->file, oh, &oinfo->meta_size.attr) < 0)
- HGOTO_ERROR(H5E_OHDR, H5E_CANTGET, FAIL, "can't retrieve attribute btree & heap info")
- } /* end if */
+ if(H5O__attr_bh_info(loc->file, oh, &oinfo->meta_size.attr) < 0)
+ HGOTO_ERROR(H5E_OHDR, H5E_CANTGET, FAIL, "can't retrieve attribute btree & heap info")
} /* end if */
done:
@@ -2279,7 +2333,7 @@ done:
HDONE_ERROR(H5E_OHDR, H5E_CANTUNPROTECT, FAIL, "unable to release object header")
FUNC_LEAVE_NOAPI_TAG(ret_value)
-} /* end H5O_get_info() */
+} /* end H5O_get_native_info() */
/*-------------------------------------------------------------------------
@@ -2593,7 +2647,7 @@ H5O__free_visit_visited(void *item, void H5_ATTR_UNUSED *key, void H5_ATTR_UNUSE
*-------------------------------------------------------------------------
*/
static herr_t
-H5O__visit_cb(hid_t H5_ATTR_UNUSED group, const char *name, const H5L_info_t *linfo,
+H5O__visit_cb(hid_t H5_ATTR_UNUSED group, const char *name, const H5L_info2_t *linfo,
void *_udata)
{
H5O_iter_visit_ud_t *udata = (H5O_iter_visit_ud_t *)_udata; /* User data for callback */
@@ -2631,7 +2685,7 @@ H5O__visit_cb(hid_t H5_ATTR_UNUSED group, const char *name, const H5L_info_t *li
/* Check if we've seen the object the link references before */
if(NULL == H5SL_search(udata->visited, &obj_pos)) {
- H5O_info_t oinfo; /* Object info */
+ H5O_info2_t oinfo; /* Object info */
/* Get the object's info */
if(H5O_get_info(&obj_oloc, &oinfo, udata->fields) < 0)
@@ -2707,14 +2761,14 @@ done:
*/
herr_t
H5O__visit(H5G_loc_t *loc, const char *obj_name, H5_index_t idx_type,
- H5_iter_order_t order, H5O_iterate_t op, void *op_data, unsigned fields)
+ H5_iter_order_t order, H5O_iterate2_t op, void *op_data, unsigned fields)
{
H5O_iter_visit_ud_t udata; /* User data for callback */
H5G_loc_t obj_loc; /* Location used to open object */
H5G_name_t obj_path; /* Opened object group hier. path */
H5O_loc_t obj_oloc; /* Opened object object location */
hbool_t loc_found = FALSE; /* Entry at 'name' found */
- H5O_info_t oinfo; /* Object info struct */
+ H5O_info2_t oinfo; /* Object info struct */
void *obj = NULL; /* Object */
H5I_type_t opened_type; /* ID type of object */
hid_t obj_id = H5I_INVALID_HID; /* ID of object */
@@ -2790,7 +2844,10 @@ H5O__visit(H5G_loc_t *loc, const char *obj_name, H5_index_t idx_type,
/* Construct unique "position" for this object */
obj_pos->fileno = oinfo.fileno;
- obj_pos->addr = oinfo.addr;
+
+ /* De-serialize object token into an object address */
+ if(H5VL_native_token_to_addr(loc->oloc->file, H5I_FILE, oinfo.token, &(obj_pos->addr)) < 0)
+ HGOTO_ERROR(H5E_OHDR, H5E_CANTUNSERIALIZE, FAIL, "can't deserialize object token into address")
/* Add to list of visited objects */
if(H5SL_insert(udata.visited, obj_pos, obj_pos) < 0)
@@ -3027,3 +3084,25 @@ done:
FUNC_LEAVE_NOAPI(ret_value)
} /* end H5O__free() */
+/*-------------------------------------------------------------------------
+ * Function: H5O__reset_info2
+ *
+ * Purpose: Resets/initializes an H5O_info2_t struct.
+ *
+ * Return: SUCCEED/FAIL
+ *
+ *-------------------------------------------------------------------------
+ */
+static herr_t
+H5O__reset_info2(H5O_info2_t *oinfo)
+{
+ FUNC_ENTER_STATIC_NOERR;
+
+ /* Reset the passed-in info struct */
+ HDmemset(oinfo, 0, sizeof(H5O_info2_t));
+ oinfo->type = H5O_TYPE_UNKNOWN;
+ oinfo->token = H5O_TOKEN_UNDEF;
+
+ FUNC_LEAVE_NOAPI(SUCCEED);
+} /* end H5O__reset_info2() */
+