From 1a5e7d821bb13b63132af16b74ab58876cbb6545 Mon Sep 17 00:00:00 2001 From: Dana Robinson Date: Tue, 5 Jun 2018 22:20:22 -0700 Subject: Normalization with the vol_integration branch. --- src/H5I.c | 469 ++++++++++++++++++++++++++++--------------------------- src/H5Iprivate.h | 4 +- src/H5Rint.c | 4 +- 3 files changed, 242 insertions(+), 235 deletions(-) diff --git a/src/H5I.c b/src/H5I.c index 66082de..4df7b7e 100644 --- a/src/H5I.c +++ b/src/H5I.c @@ -75,16 +75,16 @@ typedef struct { } H5I_id_type_t; typedef struct { - H5I_search_func_t app_cb; /* Application's callback routine */ - void *app_key; /* Application's "key" (user data) */ - void *ret_obj; /* Object to return */ + H5I_search_func_t app_cb; /* Application's callback routine */ + void *app_key; /* Application's "key" (user data) */ + void *ret_obj; /* Object to return */ } H5I_search_ud_t; /* User data for iterator callback for ID iteration */ typedef struct { - H5I_search_func_t user_func; /* 'User' function to invoke */ - void *user_udata; /* User data to pass to 'user' function */ - hbool_t app_ref; /* Whether this is an appl. ref. call */ + H5I_search_func_t user_func; /* 'User' function to invoke */ + void *user_udata; /* User data to pass to 'user' function */ + hbool_t app_ref; /* Whether this is an appl. ref. call */ } H5I_iterate_ud_t; /* User data for H5I__clear_type_cb */ @@ -126,26 +126,26 @@ static void *H5I__remove_verify(hid_t id, H5I_type_t id_type); static void *H5I__remove_common(H5I_id_type_t *type_ptr, hid_t id); static int H5I__inc_type_ref(H5I_type_t type); static int H5I__get_type_ref(H5I_type_t type); +static int H5I__search_cb(void *obj, hid_t id, void *_udata); static H5I_id_info_t *H5I__find_id(hid_t id); static ssize_t H5I__get_name(const H5G_loc_t *loc, char *name, size_t size); #ifdef H5I_DEBUG_OUTPUT +static int H5I__debug_cb(void *_item, void *_key, void *_udata); static herr_t H5I__debug(H5I_type_t type); #endif /* H5I_DEBUG_OUTPUT */ /*------------------------------------------------------------------------- - * Function: H5I_term_package + * Function: H5I_term_package * - * Purpose: Terminate the H5I interface: release all memory, reset all - * global variables to initial values. This only happens if all - * types have been destroyed from other interfaces. + * Purpose: Terminate the H5I interface: release all memory, reset all + * global variables to initial values. This only happens if all + * types have been destroyed from other interfaces. * - * Return: Success: Positive if any action was taken that might - * affect some other interface; zero otherwise. + * Return: Success: Positive if any action was taken that might + * affect some other interface; zero otherwise. * - * Failure: Negative. - * - * Programmer: Unknown + * Failure: Negative. * *------------------------------------------------------------------------- */ @@ -241,7 +241,7 @@ H5Iregister_type(size_t hash_size, unsigned reserved, H5I_free_t free_func) } /* end else */ /* Allocate new ID class */ - if(NULL == (cls = H5FL_MALLOC(H5I_class_t))) + if(NULL == (cls = H5FL_CALLOC(H5I_class_t))) HGOTO_ERROR(H5E_ATOM, H5E_CANTALLOC, H5I_BADID, "ID class allocation failed") /* Initialize class fields */ @@ -333,8 +333,7 @@ done: * Purpose: Query function to inform the user if a given type is * currently registered with the library. * - * Return: Success: 1 if the type is registered, 0 if it is not - * Failure: Negative + * Return: TRUE/FALSE/FAIL * *------------------------------------------------------------------------- */ @@ -358,15 +357,14 @@ done: /*------------------------------------------------------------------------- - * Function: H5Inmembers + * Function: H5Inmembers * - * Purpose: Returns the number of members in a type. Public interface to - * H5I_nmembers. The public interface throws an error if the + * Purpose: Returns the number of members in a type. Public interface to + * H5I_nmembers. The public interface throws an error if the * supplied type does not exist. This is different than the * private interface, which will just return 0. * - * Return: Success: Zero - * Failure: Negative + * Return: SUCCEED/FAIL * * Programmer: James Laird * Nathaniel Furrer @@ -409,14 +407,14 @@ done: /*------------------------------------------------------------------------- - * Function: H5I_nmembers + * Function: H5I_nmembers * - * Purpose: Returns the number of members in a type. + * Purpose: Returns the number of members in a type. * - * Return: Success: Number of members; zero if the type is empty - * or has been deleted. + * Return: Success: Number of members; zero if the type is empty + * or has been deleted. * - * Failure: Negative + * Failure: Negative * * Programmer: Robb Matzke * Wednesday, March 24, 1999 @@ -445,14 +443,13 @@ done: /*------------------------------------------------------------------------- - * Function: H5Iclear_type + * Function: H5Iclear_type * - * Purpose: Removes all objects from the type, calling the free - * function for each object regardless of the reference count. - * Public interface to H5I_clear_type. + * Purpose: Removes all objects from the type, calling the free + * function for each object regardless of the reference count. + * Public interface to H5I_clear_type. * - * Return: Success: Non-negative - * Failure: negative + * Return: SUCCEED/FAIL * * Programmer: James Laird * Nathaniel Furrer @@ -479,13 +476,12 @@ done: /*------------------------------------------------------------------------- - * Function: H5I_clear_type + * Function: H5I_clear_type * - * Purpose: Removes all objects from the type, calling the free - * function for each object regardless of the reference count. + * Purpose: Removes all objects from the type, calling the free + * function for each object regardless of the reference count. * - * Return: Success: Non-negative - * Failure: negative + * Return: SUCCEED/FAIL * * Programmer: Robb Matzke * Wednesday, March 24, 1999 @@ -523,11 +519,10 @@ done: /*------------------------------------------------------------------------- * Function: H5I__clear_type_cb * - * Purpose: Attempts to free the specified ID , calling the free + * Purpose: Attempts to free the specified ID, calling the free * function for the object. * - * Return: Success: Non-negative - * Failure: negative + * Return: TRUE/FALSE/FAIL * * Programmer: Neil Fortner * Friday, July 10, 2015 @@ -547,8 +542,7 @@ H5I__clear_type_cb(void *_id, void H5_ATTR_UNUSED *key, void *_udata) HDassert(udata); HDassert(udata->type_ptr); - /* - * Do nothing to the object if the reference count is larger than + /* Do nothing to the object if the reference count is larger than * one and forcing is off. */ if(udata->force || (id->count - (!udata->app_ref * id->app_count)) <= 1) { @@ -589,15 +583,15 @@ H5I__clear_type_cb(void *_id, void H5_ATTR_UNUSED *key, void *_udata) /*------------------------------------------------------------------------- - * Function: H5Idestroy_type + * Function: H5Idestroy_type * - * Purpose: Destroys a type along with all atoms in that type - * regardless of their reference counts. Destroying IDs - * involves calling the free-func for each ID's object and - * then adding the ID struct to the ID free list. Public - * interface to H5I__destroy_type. + * Purpose: Destroys a type along with all atoms in that type + * regardless of their reference counts. Destroying IDs + * involves calling the free-func for each ID's object and + * then adding the ID struct to the ID free list. Public + * interface to H5I__destroy_type. * - * Return: Zero on success/Negative on failure + * Return: SUCCEED/FAIL * * Programmer: Nathaniel Furrer * James Laird @@ -623,14 +617,14 @@ done: /*------------------------------------------------------------------------- - * Function: H5I__destroy_type + * Function: H5I__destroy_type * - * Purpose: Destroys a type along with all atoms in that type - * regardless of their reference counts. Destroying IDs - * involves calling the free-func for each ID's object and - * then adding the ID struct to the ID free list. + * Purpose: Destroys a type along with all atoms in that type + * regardless of their reference counts. Destroying IDs + * involves calling the free-func for each ID's object and + * then adding the ID struct to the ID free list. * - * Return: Zero on success/Negative on failure + * Return: SUCCEED/FAIL * * Programmer: Nathaniel Furrer * James Laird @@ -678,8 +672,8 @@ done: * * Purpose: Public interface to H5I_register. * - * Return: Success: New object id. - * Failure: Negative + * Return: Success: New object ID + * Failure: H5I_INVALID_HID * *------------------------------------------------------------------------- */ @@ -712,7 +706,7 @@ done: * for the type the ID is in and incorporating the type into * the ID which is returned to the user. * - * Return: Success: New object id + * Return: Success: New object ID * Failure: H5I_INVALID_HID * *------------------------------------------------------------------------- @@ -777,8 +771,8 @@ done: herr_t H5I_register_with_id(H5I_type_t type, const void *object, hbool_t app_ref, hid_t id) { - H5I_id_type_t *type_ptr; /* ptr to the type */ - H5I_id_info_t *id_ptr; /* ptr to the new ID information */ + H5I_id_type_t *type_ptr; /* ptr to the type */ + H5I_id_info_t *id_ptr; /* ptr to the new ID information */ herr_t ret_value = SUCCEED; /* return value */ FUNC_ENTER_NOAPI(FAIL) @@ -788,7 +782,7 @@ H5I_register_with_id(H5I_type_t type, const void *object, hbool_t app_ref, hid_t /* Make sure ID is not already in use */ if(NULL != (id_ptr = H5I__find_id(id))) - HGOTO_ERROR(H5E_ATOM, H5E_BADRANGE, FAIL, "ID already in use?!") + HGOTO_ERROR(H5E_ATOM, H5E_BADRANGE, FAIL, "ID already in use") /* Make sure type number is valid */ if(type <= H5I_BADID || type >= H5I_next_type) @@ -825,13 +819,13 @@ done: /*------------------------------------------------------------------------- - * Function: H5I_subst + * Function: H5I_subst * - * Purpose: Substitute a new object pointer for the specified ID. + * Purpose: Substitute a new object pointer for the specified ID. * - * Return: Success: Non-null previous object pointer associated - * with the specified ID. - * Failure: NULL + * Return: Success: Non-NULL previous object pointer associated + * with the specified ID. + * Failure: NULL * * Programmer: Quincey Koziol * Saturday, February 27, 2010 @@ -867,7 +861,7 @@ done: * * Purpose: Find an object pointer for the specified ID. * - * Return: Success: Non-null object pointer associated with the + * Return: Success: Non-NULL object pointer associated with the * specified ID * * Failure: NULL @@ -899,7 +893,7 @@ H5I_object(hid_t id) * its in a particular type. Public interface to * H5I_object_verify. * - * Return: Success: Non-null object pointer associated with the + * Return: Success: Non-NULL object pointer associated with the * specified ID. * Failure: NULL * @@ -932,7 +926,7 @@ done: * Purpose: Find an object pointer for the specified ID, verifying that * its in a particular type. * - * Return: Success: Non-null object pointer associated with the + * Return: Success: Non-NULL object pointer associated with the * specified ID. * Failure: NULL * @@ -962,15 +956,17 @@ H5I_object_verify(hid_t id, H5I_type_t id_type) /*------------------------------------------------------------------------- - * Function: H5I_get_type + * Function: H5I_get_type * - * Purpose: Given an object ID return the type to which it - * belongs. The ID need not be the ID of an object which - * currently exists because the type number is encoded - * in the object ID. + * Purpose: Given an object ID return the type to which it + * belongs. The ID need not be the ID of an object which + * currently exists because the type number is encoded + * in the object ID. * - * Return: Success: A valid type number - * Failure: H5I_BADID, a negative value. + * Return: Success: A positive integer (corresponding to an H5I_type_t + * enum value for library ID types, but not for user + * ID types). + * Failure: H5I_BADID * * Programmer: Robb Matzke * Friday, February 19, 1999 @@ -994,17 +990,17 @@ H5I_get_type(hid_t id) /*------------------------------------------------------------------------- - * Function: H5Iget_type - * - * Purpose: The public version of H5I_get_type(), obtains a type number - * when given an ID. The ID need not be the ID of an - * object which currently exists because the type number is - * encoded as part of the ID. + * Function: H5Iget_type * - * Return: Success: Type number - * Failure: H5I_BADID, a negative value + * Purpose: The public version of H5I_get_type(), obtains a type number + * when given an ID. The ID need not be the ID of an + * object which currently exists because the type number is + * encoded as part of the ID. * - * Programmer: Unknown + * Return: Success: A positive integer (corresponding to an H5I_type_t + * enum value for library ID types, but not for user + * ID types). + * Failure: H5I_BADID * *------------------------------------------------------------------------- */ @@ -1027,16 +1023,16 @@ done: /*------------------------------------------------------------------------- - * Function: H5Iremove_verify + * Function: H5Iremove_verify * - * Purpose: Removes the specified ID from its type, first checking that the - * type of the ID and the type type are the same. Public interface to - * H5I__remove_verify. + * Purpose: Removes the specified ID from its type, first checking that the + * type of the ID and the type type are the same. Public interface to + * H5I__remove_verify. * - * Return: Success: A pointer to the object that was removed, the - * same pointer which would have been found by - * calling H5I_object(). - * Failure: NULL + * Return: Success: A pointer to the object that was removed, the + * same pointer which would have been found by + * calling H5I_object(). + * Failure: NULL * * Programmer: James Laird * Nathaniel Furrer @@ -1063,15 +1059,15 @@ done: /*------------------------------------------------------------------------- - * Function: H5I__remove_verify + * Function: H5I__remove_verify * - * Purpose: Removes the specified ID from its type, first checking that - * the ID's type is the same as the ID type supplied as an argument + * Purpose: Removes the specified ID from its type, first checking that + * the ID's type is the same as the ID type supplied as an argument * - * Return: Success: A pointer to the object that was removed, the - * same pointer which would have been found by - * calling H5I_object(). - * Failure: NULL + * Return: Success: A pointer to the object that was removed, the + * same pointer which would have been found by + * calling H5I_object(). + * Failure: NULL * * Programmer: James Laird * Nat Furrer @@ -1096,14 +1092,14 @@ H5I__remove_verify(hid_t id, H5I_type_t id_type) /*------------------------------------------------------------------------- - * Function: H5I__remove_common + * Function: H5I__remove_common * - * Purpose: Common code to remove a specified ID from its type. + * Purpose: Common code to remove a specified ID from its type. * - * Return: Success: A pointer to the object that was removed, the - * same pointer which would have been found by - * calling H5I_object(). - * Failure: NULL + * Return: Success: A pointer to the object that was removed, the + * same pointer which would have been found by + * calling H5I_object(). + * Failure: NULL * * Programmer: Quincey Koziol * October 3, 2013 @@ -1138,14 +1134,14 @@ done: /*------------------------------------------------------------------------- - * Function: H5I_remove + * Function: H5I_remove * - * Purpose: Removes the specified ID from its type. + * Purpose: Removes the specified ID from its type. * - * Return: Success: A pointer to the object that was removed, the - * same pointer which would have been found by - * calling H5I_object(). - * Failure: NULL + * Return: Success: A pointer to the object that was removed, the + * same pointer which would have been found by + * calling H5I_object(). + * Failure: NULL * * Programmer: Unknown * @@ -1178,14 +1174,14 @@ done: /*------------------------------------------------------------------------- - * Function: H5Idec_ref + * Function: H5Idec_ref * - * Purpose: Decrements the number of references outstanding for an ID. + * Purpose: Decrements the number of references outstanding for an ID. * If the reference count for an ID reaches zero, the object * will be closed. * - * Return: Success: New reference count - * Failure: Negative + * Return: Success: New reference count + * Failure: -1 * * Programmer: Quincey Koziol * Dec 7, 2003 @@ -1197,16 +1193,16 @@ H5Idec_ref(hid_t id) { int ret_value = 0; /* Return value */ - FUNC_ENTER_API(FAIL) + FUNC_ENTER_API((-1)) H5TRACE1("Is", "i", id); /* Check arguments */ if(id < 0) - HGOTO_ERROR(H5E_ATOM, H5E_BADATOM, FAIL, "invalid ID") + HGOTO_ERROR(H5E_ATOM, H5E_BADATOM, (-1), "invalid ID") /* Do actual decrement operation */ if((ret_value = H5I_dec_app_ref(id)) < 0) - HGOTO_ERROR(H5E_ATOM, H5E_CANTDEC, FAIL, "can't decrement ID ref count") + HGOTO_ERROR(H5E_ATOM, H5E_CANTDEC, (-1), "can't decrement ID ref count") done: FUNC_LEAVE_API(ret_value) @@ -1214,19 +1210,17 @@ done: /*------------------------------------------------------------------------- - * Function: H5I_dec_ref + * Function: H5I_dec_ref * - * Purpose: Decrements the number of references outstanding for an ID. - * This will fail if the type is not a reference counted type. - * The ID type's 'free' function will be called for the ID - * if the reference count for the ID reaches 0 and a free - * function has been defined at type creation time. + * Purpose: Decrements the number of references outstanding for an ID. + * This will fail if the type is not a reference counted type. + * The ID type's 'free' function will be called for the ID + * if the reference count for the ID reaches 0 and a free + * function has been defined at type creation time. * - * Return: Success: New reference count. - * - * Failure: Negative + * Return: Success: New reference count * - * Programmer: Unknown + * Failure: -1 * *------------------------------------------------------------------------- */ @@ -1236,17 +1230,16 @@ H5I_dec_ref(hid_t id) H5I_id_info_t *id_ptr; /* Pointer to the new ID */ int ret_value = 0; /* Return value */ - FUNC_ENTER_NOAPI(FAIL) + FUNC_ENTER_NOAPI((-1)) /* Sanity check */ HDassert(id >= 0); /* General lookup of the ID */ if(NULL == (id_ptr = H5I__find_id(id))) - HGOTO_ERROR(H5E_ATOM, H5E_BADATOM, FAIL, "can't locate ID") + HGOTO_ERROR(H5E_ATOM, H5E_BADATOM, (-1), "can't locate ID") - /* - * If this is the last reference to the object then invoke the type's + /* If this is the last reference to the object then invoke the type's * free method on the object. If the free method is undefined or * successful then remove the object from the type; otherwise leave * the object in the type without decrementing the reference @@ -1270,11 +1263,11 @@ H5I_dec_ref(hid_t id) if(!type_ptr->cls->free_func || (type_ptr->cls->free_func)((void *)id_ptr->obj_ptr) >= 0) { /* Remove the node from the type */ if(NULL == H5I__remove_common(type_ptr, id)) - HGOTO_ERROR(H5E_ATOM, H5E_CANTDELETE, FAIL, "can't remove ID node") + HGOTO_ERROR(H5E_ATOM, H5E_CANTDELETE, (-1), "can't remove ID node") ret_value = 0; } /* end if */ else - ret_value = FAIL; + ret_value = -1; } /* end if */ else { --(id_ptr->count); @@ -1287,13 +1280,13 @@ done: /*------------------------------------------------------------------------- - * Function: H5I_dec_app_ref + * Function: H5I_dec_app_ref * - * Purpose: H5I_dec_ref wrapper for case of modifying the application ref. - * count for an ID as well as normal reference count. + * Purpose: H5I_dec_ref wrapper for case of modifying the application ref. + * count for an ID as well as normal reference count. * - * Return: Success: New app. reference count. - * Failure: Negative + * Return: Success: New app. reference count + * Failure: -1 * * Programmer: Quincey Koziol * Sept 16, 2010 @@ -1306,20 +1299,20 @@ H5I_dec_app_ref(hid_t id) H5I_id_info_t *id_ptr; /* Pointer to the new ID */ int ret_value = 0; /* Return value */ - FUNC_ENTER_NOAPI(FAIL) + FUNC_ENTER_NOAPI((-1)) /* Sanity check */ HDassert(id >= 0); /* Call regular decrement reference count routine */ if((ret_value = H5I_dec_ref(id)) < 0) - HGOTO_ERROR(H5E_ATOM, H5E_CANTDEC, FAIL, "can't decrement ID ref count") + HGOTO_ERROR(H5E_ATOM, H5E_CANTDEC, (-1), "can't decrement ID ref count") /* Check if the ID still exists */ if(ret_value > 0) { /* General lookup of the ID */ if(NULL == (id_ptr = H5I__find_id(id))) - HGOTO_ERROR(H5E_ATOM, H5E_BADATOM, FAIL, "can't locate ID") + HGOTO_ERROR(H5E_ATOM, H5E_BADATOM, (-1), "can't locate ID") /* Adjust app_ref */ --(id_ptr->app_count); @@ -1340,8 +1333,8 @@ done: * Purpose: H5I_dec_app_ref wrapper for case of always closing the ID, * even when the free routine fails * - * Return: Success: New app. reference count. - * Failure: Negative + * Return: Success: New app. reference count + * Failure: -1 * *------------------------------------------------------------------------- */ @@ -1350,7 +1343,7 @@ H5I_dec_app_ref_always_close(hid_t id) { int ret_value = 0; /* Return value */ - FUNC_ENTER_NOAPI(FAIL) + FUNC_ENTER_NOAPI((-1)) /* Sanity check */ HDassert(id >= 0); @@ -1368,7 +1361,7 @@ H5I_dec_app_ref_always_close(hid_t id) */ H5I_remove(id); - HGOTO_ERROR(H5E_ATOM, H5E_CANTDEC, FAIL, "can't decrement ID ref count") + HGOTO_ERROR(H5E_ATOM, H5E_CANTDEC, (-1), "can't decrement ID ref count") } done: @@ -1382,7 +1375,7 @@ done: * Purpose: Increments the number of references outstanding for an ID. * * Return: Success: New reference count - * Failure: Negative + * Failure: -1 * *------------------------------------------------------------------------- */ @@ -1391,16 +1384,16 @@ H5Iinc_ref(hid_t id) { int ret_value; /* Return value */ - FUNC_ENTER_API(FAIL) + FUNC_ENTER_API((-1)) H5TRACE1("Is", "i", id); /* Check arguments */ if (id < 0) - HGOTO_ERROR(H5E_ATOM, H5E_BADATOM, FAIL, "invalid ID") + HGOTO_ERROR(H5E_ATOM, H5E_BADATOM, (-1), "invalid ID") /* Do actual increment operation */ if ((ret_value = H5I_inc_ref(id, TRUE)) < 0) - HGOTO_ERROR(H5E_ATOM, H5E_CANTINC, FAIL, "can't increment ID ref count") + HGOTO_ERROR(H5E_ATOM, H5E_CANTINC, (-1), "can't increment ID ref count") done: FUNC_LEAVE_API(ret_value) @@ -1412,8 +1405,8 @@ done: * * Purpose: Increment the reference count for an object. * - * Return: Success: The new reference count. - * Failure: Negative + * Return: Success: The new reference count + * Failure: -1 * *------------------------------------------------------------------------- */ @@ -1423,14 +1416,14 @@ H5I_inc_ref(hid_t id, hbool_t app_ref) H5I_id_info_t *id_ptr; /* Pointer to the ID */ int ret_value = 0; /* Return value */ - FUNC_ENTER_NOAPI(FAIL) + FUNC_ENTER_NOAPI((-1)) /* Sanity check */ HDassert(id >= 0); /* General lookup of the ID */ if (NULL == (id_ptr = H5I__find_id(id))) - HGOTO_ERROR(H5E_ATOM, H5E_BADATOM, FAIL, "can't locate ID") + HGOTO_ERROR(H5E_ATOM, H5E_BADATOM, (-1), "can't locate ID") /* Adjust reference counts */ ++(id_ptr->count); @@ -1451,7 +1444,7 @@ done: * Purpose: Retrieves the number of references outstanding for an ID. * * Return: Success: Reference count - * Failure: Negative + * Failure: -1 * *------------------------------------------------------------------------- */ @@ -1460,16 +1453,16 @@ H5Iget_ref(hid_t id) { int ret_value; /* Return value */ - FUNC_ENTER_API(FAIL) + FUNC_ENTER_API((-1)) H5TRACE1("Is", "i", id); /* Check arguments */ if (id < 0) - HGOTO_ERROR(H5E_ATOM, H5E_BADATOM, FAIL, "invalid ID") + HGOTO_ERROR(H5E_ATOM, H5E_BADATOM, (-1), "invalid ID") /* Do actual retrieve operation */ if ((ret_value = H5I_get_ref(id, TRUE)) < 0) - HGOTO_ERROR(H5E_ATOM, H5E_CANTGET, FAIL, "can't get ID ref count") + HGOTO_ERROR(H5E_ATOM, H5E_CANTGET, (-1), "can't get ID ref count") done: FUNC_LEAVE_API(ret_value) @@ -1481,8 +1474,8 @@ done: * * Purpose: Retrieve the reference count for an object. * - * Return: Success: The reference count. - * Failure: Negative + * Return: Success: The reference count + * Failure: -1 * *------------------------------------------------------------------------- */ @@ -1492,14 +1485,14 @@ H5I_get_ref(hid_t id, hbool_t app_ref) H5I_id_info_t *id_ptr; /* Pointer to the ID */ int ret_value = 0; /* Return value */ - FUNC_ENTER_NOAPI(FAIL) + FUNC_ENTER_NOAPI((-1)) /* Sanity check */ HDassert(id >= 0); /* General lookup of the ID */ if (NULL == (id_ptr = H5I__find_id(id))) - HGOTO_ERROR(H5E_ATOM, H5E_BADATOM, FAIL, "can't locate ID") + HGOTO_ERROR(H5E_ATOM, H5E_BADATOM, (-1), "can't locate ID") /* Set return value */ ret_value = (int)(app_ref ? id_ptr->app_count : id_ptr->count); @@ -1515,7 +1508,7 @@ done: * Purpose: Increments the number of references outstanding for an ID type. * * Return: Success: New reference count - * Failure: Negative + * Failure: -1 * *------------------------------------------------------------------------- */ @@ -1524,19 +1517,19 @@ H5Iinc_type_ref(H5I_type_t type) { int ret_value; /* Return value */ - FUNC_ENTER_API(FAIL) + FUNC_ENTER_API((-1)) H5TRACE1("Is", "It", type); /* Check arguments */ if (type <= 0 || type >= H5I_next_type) - HGOTO_ERROR(H5E_ATOM, H5E_BADATOM, FAIL, "invalid ID type") + HGOTO_ERROR(H5E_ATOM, H5E_BADATOM, (-1), "invalid ID type") if (H5I_IS_LIB_TYPE(type)) - HGOTO_ERROR(H5E_ATOM, H5E_BADGROUP, FAIL, "cannot call public function on library type") + HGOTO_ERROR(H5E_ATOM, H5E_BADGROUP, (-1), "cannot call public function on library type") /* Do actual increment operation */ if ((ret_value = H5I__inc_type_ref(type)) < 0) - HGOTO_ERROR(H5E_ATOM, H5E_CANTINC, FAIL, "can't increment ID type ref count") + HGOTO_ERROR(H5E_ATOM, H5E_CANTINC, (-1), "can't increment ID type ref count") done: FUNC_LEAVE_API(ret_value) @@ -1549,7 +1542,7 @@ done: * Purpose: Increment the reference count for an ID type. * * Return: Success: The new reference count - * Failure: Negative + * Failure: -1 * *------------------------------------------------------------------------- */ @@ -1567,7 +1560,7 @@ H5I__inc_type_ref(H5I_type_t type) /* Check arguments */ type_ptr = H5I_id_type_list_g[type]; if (!type_ptr) - HGOTO_ERROR(H5E_ATOM, H5E_BADGROUP, FAIL, "invalid type") + HGOTO_ERROR(H5E_ATOM, H5E_BADGROUP, (-1), "invalid type") /* Set return value */ ret_value = (int)(++(type_ptr->init_count)); @@ -1597,20 +1590,20 @@ done: * release (DER). * * Return: Success: Number of references to type - * Failure: Negative + * Failure: -1 * *------------------------------------------------------------------------- */ herr_t H5Idec_type_ref(H5I_type_t type) { - herr_t ret_value; /* Return value */ + herr_t ret_value = 0; /* Return value */ - FUNC_ENTER_API(FAIL) + FUNC_ENTER_API((-1)) H5TRACE1("e", "It", type); if (H5I_IS_LIB_TYPE(type)) - HGOTO_ERROR(H5E_ATOM, H5E_BADGROUP, FAIL, "cannot call public function on library type") + HGOTO_ERROR(H5E_ATOM, H5E_BADGROUP, (-1), "cannot call public function on library type") ret_value = H5I_dec_type_ref(type); @@ -1634,24 +1627,24 @@ done: * be set to H5I_UNINIT). * * Return: Success: Number of references to type - * Failure: Negative + * Failure: -1 * *------------------------------------------------------------------------- */ -herr_t +int H5I_dec_type_ref(H5I_type_t type) { H5I_id_type_t *type_ptr; /* Pointer to the ID type */ - herr_t ret_value = SUCCEED; /* Return value */ + herr_t ret_value = 0; /* Return value */ - FUNC_ENTER_NOAPI(FAIL) + FUNC_ENTER_NOAPI((-1)) if (type <= H5I_BADID || type >= H5I_next_type) - HGOTO_ERROR(H5E_ARGS, H5E_BADRANGE, FAIL, "invalid type number") + HGOTO_ERROR(H5E_ARGS, H5E_BADRANGE, (-1), "invalid type number") type_ptr = H5I_id_type_list_g[type]; if (type_ptr == NULL || type_ptr->init_count <= 0) - HGOTO_ERROR(H5E_ATOM, H5E_BADGROUP, FAIL, "invalid type") + HGOTO_ERROR(H5E_ATOM, H5E_BADGROUP, (-1), "invalid type") /* Decrement the number of users of the atomic type. If this is the * last user of the type then release all atoms from the type and @@ -1678,7 +1671,7 @@ done: * Purpose: Retrieves the number of references outstanding for a type. * * Return: Success: Reference count - * Failure: Negative + * Failure: -1 * *------------------------------------------------------------------------- */ @@ -1687,19 +1680,19 @@ H5Iget_type_ref(H5I_type_t type) { int ret_value; /* Return value */ - FUNC_ENTER_API(FAIL) + FUNC_ENTER_API((-1)) H5TRACE1("Is", "It", type); /* Check arguments */ if (type <= 0 || type >= H5I_next_type) - HGOTO_ERROR(H5E_ATOM, H5E_BADATOM, FAIL, "invalid ID type") + HGOTO_ERROR(H5E_ATOM, H5E_BADATOM, (-1), "invalid ID type") if (H5I_IS_LIB_TYPE(type)) - HGOTO_ERROR(H5E_ATOM, H5E_BADGROUP, FAIL, "cannot call public function on library type") + HGOTO_ERROR(H5E_ATOM, H5E_BADGROUP, (-1), "cannot call public function on library type") /* Do actual retrieve operation */ if ((ret_value = H5I__get_type_ref(type)) < 0) - HGOTO_ERROR(H5E_ATOM, H5E_CANTGET, FAIL, "can't get ID type ref count") + HGOTO_ERROR(H5E_ATOM, H5E_CANTGET, (-1), "can't get ID type ref count") done: FUNC_LEAVE_API(ret_value) @@ -1711,9 +1704,9 @@ done: * * Purpose: Retrieve the reference count for an ID type. * - * Return: Success: The reference count. + * Return: Success: The reference count * - * Failure: Negative + * Failure: -1 * *------------------------------------------------------------------------- */ @@ -1747,9 +1740,7 @@ done: * Purpose: Check if the given id is valid. An id is valid if it is in * use and has an application reference count of at least 1. * - * Return: Success: TRUE if the id is valid, FALSE otherwise. - * - * Failure: Negative (never fails currently) + * Return: TRUE/FALSE/FAIL * *------------------------------------------------------------------------- */ @@ -1780,24 +1771,29 @@ done: * Calls "user" callback search function, and then sets return * value, based on the result of that callback. * - * Return: Success: The first object in the type for which FUNC - * returns non-zero. NULL if FUNC returned zero - * for every object in the type. - * Failure: NULL + * Return: Success: H5_ITER_CONT (0) or H5_ITER_STOP (1) + * Failure: H5_ITER_ERROR (-1) * *------------------------------------------------------------------------- */ static int H5I__search_cb(void *obj, hid_t id, void *_udata) { - H5I_search_ud_t *udata = (H5I_search_ud_t *)_udata; /* User data for callback */ - int ret_value = -1; /* Callback return value */ + H5I_search_ud_t *udata = (H5I_search_ud_t *)_udata; /* User data for callback */ + herr_t cb_ret_val; /* User callback return value */ + int ret_value = H5_ITER_ERROR; /* Callback return value */ FUNC_ENTER_STATIC_NOERR - ret_value = (*udata->app_cb)(obj, id, udata->app_key); - if (ret_value > 0) - udata->ret_obj = obj; + cb_ret_val = (*udata->app_cb)(obj, id, udata->app_key); + + /* Set the return value based on the callback's return value */ + if(cb_ret_val > 0) { + ret_value = H5_ITER_STOP; /* terminate iteration early */ + udata->ret_obj = obj; /* also set out parameter */ + } + else if(cb_ret_val < 0) + ret_value = H5_ITER_ERROR; /* indicate failure (which terminates iteration) */ FUNC_LEAVE_NOAPI(ret_value) } /* end H5I__search_cb() */ @@ -1875,17 +1871,21 @@ H5I__iterate_cb(void *_item, void H5_ATTR_UNUSED *_key, void *_udata) FUNC_ENTER_STATIC_NOERR - /* Don't make callback if app_ref is set and the appl. ref count is 0 */ + /* Only invoke the callback function if this ID is visible externally and + * its reference count is positive. + */ if((!udata->app_ref) || (item->app_count > 0)) { - herr_t cb_ret_val; + herr_t cb_ret_val; + + /* Invoke callback function */ + cb_ret_val = (*udata->user_func)((void *)item->obj_ptr, item->id, udata->user_udata); /* (Casting away const OK) */ - /* (Casting away const OK) */ - cb_ret_val = (*udata->user_func)((void *)item->obj_ptr, item->id, udata->user_udata); + /* Set the return value based on the callback's return value */ if(cb_ret_val > 0) ret_value = H5_ITER_STOP; /* terminate iteration early */ else if(cb_ret_val < 0) ret_value = H5_ITER_ERROR; /* indicate failure (which terminates iteration) */ - } /* end if */ + } FUNC_LEAVE_NOAPI(ret_value) } /* end H5I__iterate_cb() */ @@ -1997,11 +1997,11 @@ done: * Failure: -1 * * Comments: Public function - * If `name' is non-NULL then write up to `size' bytes into that + * If 'name' is non-NULL then write up to 'size' bytes into that * buffer and always return the length of the entry name. - * Otherwise `size' is ignored and the function does not store the name, + * Otherwise 'size' is ignored and the function does not store the name, * just returning the number of characters required to store the name. - * If an error occurs then the buffer pointed to by `name' (NULL or non-NULL) + * If an error occurs then the buffer pointed to by 'name' (NULL or non-NULL) * is unchanged and the function returns a negative value. * If a zero is returned for the name's length, then there is no name * associated with the ID. @@ -2080,13 +2080,22 @@ done: hid_t H5Iget_file_id(hid_t obj_id) { + H5I_type_t type; /* ID type */ hid_t ret_value = H5I_INVALID_HID; /* Return value */ FUNC_ENTER_API(FAIL) H5TRACE1("i", "i", obj_id); - if ((ret_value = H5I_get_file_id(obj_id, TRUE)) < 0) - HGOTO_ERROR(H5E_ATOM, H5E_CANTGET, H5I_INVALID_HID, "can't retrieve file ID") + /* Get object type */ + type = H5I_TYPE(obj_id); + + /* Call internal function */ + if (H5I_FILE == type || H5I_DATATYPE == type || H5I_GROUP == type || H5I_DATASET == type || H5I_ATTR == type) { + if ((ret_value = H5I_get_file_id(obj_id, type)) < 0) + HGOTO_ERROR(H5E_ATOM, H5E_CANTGET, H5I_INVALID_HID, "can't retrieve file ID") + } + else + HGOTO_ERROR(H5E_ARGS, H5E_BADRANGE, H5I_INVALID_HID, "not an ID of a file object") done: FUNC_LEAVE_API(ret_value) @@ -2100,30 +2109,27 @@ done: * ID given an object ID. * * Return: Success: The file ID associated with the object - * * Failure: H5I_INVALID_HID * *------------------------------------------------------------------------- */ hid_t -H5I_get_file_id(hid_t obj_id, hbool_t app_ref) +H5I_get_file_id(hid_t obj_id, H5I_type_t type) { - H5I_type_t type; /* ID type */ - hid_t ret_value = H5I_INVALID_HID; /* Return value */ + hid_t ret_value = H5I_INVALID_HID; /* Return value */ FUNC_ENTER_NOAPI_NOINIT - /* Get object type */ - type = H5I_TYPE(obj_id); + /* Process based on object type */ if (type == H5I_FILE) { /* Increment reference count on file ID */ - if(H5I_inc_ref(obj_id, app_ref) < 0) + if(H5I_inc_ref(obj_id, TRUE) < 0) HGOTO_ERROR(H5E_ATOM, H5E_CANTSET, H5I_INVALID_HID, "incrementing file ID failed") /* Set return value */ ret_value = obj_id; } - else if (type == H5I_DATATYPE || type == H5I_GROUP || type == H5I_DATASET || type == H5I_ATTR) { + else { H5G_loc_t loc; /* Location of object */ /* Get the object location information */ @@ -2131,11 +2137,9 @@ H5I_get_file_id(hid_t obj_id, hbool_t app_ref) HGOTO_ERROR(H5E_ATOM, H5E_CANTGET, H5I_INVALID_HID, "can't get object location") /* Get the file ID for the object */ - if((ret_value = H5F_get_id(loc.oloc->file, app_ref)) < 0) + if((ret_value = H5F_get_id(loc.oloc->file, TRUE)) < 0) HGOTO_ERROR(H5E_ATOM, H5E_CANTGET, H5I_INVALID_HID, "can't get file ID") } - else - HGOTO_ERROR(H5E_ARGS, H5E_BADRANGE, H5I_INVALID_HID, "invalid object ID") done: FUNC_LEAVE_NOAPI(ret_value) @@ -2148,16 +2152,16 @@ done: * * Purpose: Dump the contents of an ID to stderr for debugging. * - * Return: SUCCEED/FAIL + * Return: H5_ITER_CONT (always) * *------------------------------------------------------------------------- */ -static herr_t +static int H5I__debug_cb(void *_item, void H5_ATTR_UNUSED *_key, void *_udata) { - H5I_id_info_t *item = (H5I_id_info_t *)_item; /* Pointer to the ID node */ - H5I_type_t type = *(H5I_type_t *)_udata; /* User data */ - H5G_name_t *path = NULL; + H5I_id_info_t *item = (H5I_id_info_t *)_item; /* Pointer to the ID node */ + H5I_type_t type = *(H5I_type_t *)_udata; /* User data */ + H5G_name_t *path = NULL; /* Path to file object */ FUNC_ENTER_STATIC_NOERR @@ -2168,17 +2172,20 @@ H5I__debug_cb(void *_item, void H5_ATTR_UNUSED *_key, void *_udata) /* Get the group location, so we get get the name */ switch (type) { case H5I_GROUP: + { path = H5G_nameof((H5G_t*)item->obj_ptr); break; - + } case H5I_DATASET: + { path = H5D_nameof((H5D_t*)item->obj_ptr); break; - + } case H5I_DATATYPE: + { path = H5T_nameof((H5T_t*)item->obj_ptr); break; - + } case H5I_UNINIT: case H5I_BADID: case H5I_FILE: @@ -2203,7 +2210,7 @@ H5I__debug_cb(void *_item, void H5_ATTR_UNUSED *_key, void *_udata) HDfprintf(stderr, " full_path = %s\n", H5RS_get_str(path->full_path_r)); } - FUNC_LEAVE_NOAPI(SUCCEED) + FUNC_LEAVE_NOAPI(H5_ITER_CONT) } /* end H5I__debug_cb() */ diff --git a/src/H5Iprivate.h b/src/H5Iprivate.h index 25cea4f..3bfde93 100644 --- a/src/H5Iprivate.h +++ b/src/H5Iprivate.h @@ -72,7 +72,7 @@ H5_DLL void *H5I_subst(hid_t id, const void *new_object); H5_DLL void *H5I_object(hid_t id); H5_DLL void *H5I_object_verify(hid_t id, H5I_type_t id_type); H5_DLL H5I_type_t H5I_get_type(hid_t id); -H5_DLL hid_t H5I_get_file_id(hid_t obj_id, hbool_t app_ref); +H5_DLL hid_t H5I_get_file_id(hid_t obj_id, H5I_type_t id_type); H5_DLL void *H5I_remove(hid_t id); H5_DLL herr_t H5I_iterate(H5I_type_t type, H5I_search_func_t func, void *udata, hbool_t app_ref); H5_DLL int H5I_get_ref(hid_t id, hbool_t app_ref); @@ -80,7 +80,7 @@ H5_DLL int H5I_inc_ref(hid_t id, hbool_t app_ref); H5_DLL int H5I_dec_ref(hid_t id); H5_DLL int H5I_dec_app_ref(hid_t id); H5_DLL int H5I_dec_app_ref_always_close(hid_t id); -H5_DLL herr_t H5I_dec_type_ref(H5I_type_t type); +H5_DLL int H5I_dec_type_ref(H5I_type_t type); #endif /* _H5Iprivate_H */ diff --git a/src/H5Rint.c b/src/H5Rint.c index 761ba44..acf6b56 100644 --- a/src/H5Rint.c +++ b/src/H5Rint.c @@ -751,8 +751,8 @@ H5R__get_name(H5F_t *f, hid_t id, H5R_type_t ref_type, const void *_ref, } /* end switch */ /* Retrieve file ID for name search */ - if ((file_id = H5I_get_file_id(id, FALSE)) < 0) - HGOTO_ERROR(H5E_REFERENCE, H5E_CANTGET, (-1), "can't retrieve file ID") + if ((file_id = H5F_get_id(f, FALSE)) < 0) + HGOTO_ERROR(H5E_ATOM, H5E_CANTGET, (-1), "can't get file ID") /* Get name, length, etc. */ if ((ret_value = H5G_get_name_by_addr(file_id, &oloc, name, size)) < 0) -- cgit v0.12 From 91089de53ffe2b950ed309ee486590ed6d2272c2 Mon Sep 17 00:00:00 2001 From: Dana Robinson Date: Wed, 6 Jun 2018 21:34:11 -0700 Subject: Normalization with vol_integration branch. --- src/H5F.c | 2 +- src/H5Fefc.c | 25 +++--- src/H5Fint.c | 111 +++++++++++------------ src/H5Fmount.c | 270 +++++++++++++++++++++++++++---------------------------- src/H5Fpkg.h | 62 ++++++------- src/H5Fprivate.h | 14 ++- test/efc.c | 42 +++++---- 7 files changed, 256 insertions(+), 270 deletions(-) diff --git a/src/H5F.c b/src/H5F.c index 6d62c08..01fd7db 100644 --- a/src/H5F.c +++ b/src/H5F.c @@ -700,7 +700,7 @@ H5Freopen(hid_t file_id) HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a file") /* Get a new "top level" file struct, sharing the same "low level" file struct */ - if(NULL == (new_file = H5F_new(old_file->shared, 0, H5P_FILE_CREATE_DEFAULT, H5P_FILE_ACCESS_DEFAULT, NULL))) + if(NULL == (new_file = H5F__new(old_file->shared, 0, H5P_FILE_CREATE_DEFAULT, H5P_FILE_ACCESS_DEFAULT, NULL))) HGOTO_ERROR(H5E_FILE, H5E_CANTINIT, FAIL, "unable to reopen file") /* Duplicate old file's names */ diff --git a/src/H5Fefc.c b/src/H5Fefc.c index 487ed2f..07bb644 100644 --- a/src/H5Fefc.c +++ b/src/H5Fefc.c @@ -73,7 +73,7 @@ H5FL_DEFINE_STATIC(H5F_efc_t); /*------------------------------------------------------------------------- - * Function: H5F_efc_create + * Function: H5F__efc_create * * Purpose: Allocate and initialize a new external file cache object, * which can the be used to cache open external files. @@ -88,12 +88,12 @@ H5FL_DEFINE_STATIC(H5F_efc_t); *------------------------------------------------------------------------- */ H5F_efc_t * -H5F_efc_create(unsigned max_nfiles) +H5F__efc_create(unsigned max_nfiles) { H5F_efc_t *efc = NULL; /* EFC object */ H5F_efc_t *ret_value = NULL; /* Return value */ - FUNC_ENTER_NOAPI(NULL) + FUNC_ENTER_PACKAGE /* Sanity checks */ HDassert(max_nfiles > 0); @@ -116,7 +116,7 @@ done: efc = H5FL_FREE(H5F_efc_t, efc); FUNC_LEAVE_NOAPI(ret_value) -} /* end H5F_efc_create() */ +} /* end H5F__efc_create() */ /*------------------------------------------------------------------------- @@ -139,8 +139,7 @@ done: *------------------------------------------------------------------------- */ H5F_t * -H5F__efc_open(H5F_t *parent, const char *name, unsigned flags, hid_t fcpl_id, - hid_t fapl_id) +H5F__efc_open(H5F_t *parent, const char *name, unsigned flags, hid_t fcpl_id, hid_t fapl_id) { H5F_efc_t *efc = NULL; /* External file cache for parent file */ H5F_efc_ent_t *ent = NULL; /* Entry for target file in efc */ @@ -376,7 +375,7 @@ done: /*------------------------------------------------------------------------- - * Function: H5F_efc_max_nfiles + * Function: H5F__efc_max_nfiles * * Purpose: Returns the maximum number of files in the provided * external file cache. @@ -389,15 +388,15 @@ done: *------------------------------------------------------------------------- */ unsigned -H5F_efc_max_nfiles(H5F_efc_t *efc) +H5F__efc_max_nfiles(H5F_efc_t *efc) { - FUNC_ENTER_NOAPI_NOINIT_NOERR + FUNC_ENTER_PACKAGE_NOERR HDassert(efc); HDassert(efc->max_nfiles > 0); FUNC_LEAVE_NOAPI(efc->max_nfiles) -} /* end H5F_efc_max_nfiles */ +} /* end H5F__efc_max_nfiles */ /*------------------------------------------------------------------------- @@ -793,7 +792,7 @@ H5F__efc_try_close_tag2(H5F_file_t *sf, H5F_file_t **tail) * uncloseable file would be closed. * * The final pass exploits the H5F__efc_release_real()-> - * H5F_efc_remove_ent()->H5F_try_close()->H5F__efc_try_close() + * H5F__efc_remove_ent()->H5F_try_close()->H5F__efc_try_close() * calling chain to recursively close the tree, but only the * files that are still marked as closeable. All files * marked as closeable have their EFCs released, and will @@ -819,7 +818,7 @@ H5F__efc_try_close(H5F_t *f) H5F_file_t *next; /* Temporary file pointer */ herr_t ret_value = SUCCEED; /* Return value */ - FUNC_ENTER_NOAPI_NOINIT + FUNC_ENTER_PACKAGE /* Sanity checks */ HDassert(f); @@ -852,7 +851,7 @@ H5F__efc_try_close(H5F_t *f) /* If there are references that are not from an EFC or f, it will never * be possible to close the file. Just return. Note that this holds true * for the case that this file is being closed through H5F__efc_release_real() - * because that function (through H5F_efc_remove_ent()) decrements the EFC + * because that function (through H5F__efc_remove_ent()) decrements the EFC * reference count before it calls H5F_try_close(). This may occur if this * function is reentered. */ /* If the tag is H5F_EFC_TAG_DONTCLOSE, then we have definitely reentered diff --git a/src/H5Fint.c b/src/H5Fint.c index 7d71fbc..abc638a 100644 --- a/src/H5Fint.c +++ b/src/H5Fint.c @@ -21,22 +21,22 @@ /***********/ /* Headers */ /***********/ -#include "H5private.h" /* Generic Functions */ -#include "H5Aprivate.h" /* Attributes */ -#include "H5ACprivate.h" /* Metadata cache */ -#include "H5CXprivate.h" /* API Contexts */ -#include "H5Dprivate.h" /* Datasets */ -#include "H5Eprivate.h" /* Error handling */ -#include "H5Fpkg.h" /* File access */ -#include "H5FDprivate.h" /* File drivers */ -#include "H5Gprivate.h" /* Groups */ -#include "H5Iprivate.h" /* IDs */ -#include "H5Lprivate.h" /* Links */ -#include "H5MFprivate.h" /* File memory management */ -#include "H5MMprivate.h" /* Memory management */ -#include "H5Pprivate.h" /* Property lists */ -#include "H5SMprivate.h" /* Shared Object Header Messages */ -#include "H5Tprivate.h" /* Datatypes */ +#include "H5private.h" /* Generic Functions */ +#include "H5Aprivate.h" /* Attributes */ +#include "H5ACprivate.h" /* Metadata cache */ +#include "H5CXprivate.h" /* API Contexts */ +#include "H5Dprivate.h" /* Datasets */ +#include "H5Eprivate.h" /* Error handling */ +#include "H5Fpkg.h" /* File access */ +#include "H5FDprivate.h" /* File drivers */ +#include "H5Gprivate.h" /* Groups */ +#include "H5Iprivate.h" /* IDs */ +#include "H5Lprivate.h" /* Links */ +#include "H5MFprivate.h" /* File memory management */ +#include "H5MMprivate.h" /* Memory management */ +#include "H5Pprivate.h" /* Property lists */ +#include "H5SMprivate.h" /* Shared Object Header Messages */ +#include "H5Tprivate.h" /* Datatypes */ /****************/ @@ -74,11 +74,9 @@ typedef struct H5F_olist_t { /********************/ static int H5F_get_objects_cb(void *obj_ptr, hid_t obj_id, void *key); -static herr_t H5F__build_name(const char *prefix, const char *file_name, - char **full_name/*out*/); +static herr_t H5F__build_name(const char *prefix, const char *file_name, char **full_name/*out*/); static char *H5F__getenv_prefix_name(char **env_prefix/*in,out*/); -static herr_t H5F_build_actual_name(const H5F_t *f, const H5P_genplist_t *fapl, - const char *name, char ** /*out*/ actual_name);/* Declare a free list to manage the H5F_t struct */ +static herr_t H5F_build_actual_name(const H5F_t *f, const H5P_genplist_t *fapl, const char *name, char ** /*out*/ actual_name); static herr_t H5F__flush_phase1(H5F_t *f); static herr_t H5F__flush_phase2(H5F_t *f, hbool_t closing); @@ -175,7 +173,7 @@ H5F_get_access_plist(H5F_t *f, hbool_t app_ref) HGOTO_ERROR(H5E_PLIST, H5E_CANTSET, FAIL, "can't set object flush callback") if(f->shared->efc) - efc_size = H5F_efc_max_nfiles(f->shared->efc); + efc_size = H5F__efc_max_nfiles(f->shared->efc); if(H5P_set(new_plist, H5F_ACS_EFC_SIZE_NAME, &efc_size) < 0) HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, FAIL, "can't set elink file cache size") if(f->shared->page_buf != NULL) { @@ -486,11 +484,12 @@ done: /*-------------------------------------------------------------------------- - * Function: H5F__build_name + * Function: H5F__build_name * - * Purpose: Prepend PREFIX to FILE_NAME and store in FULL_NAME + * Purpose: Prepend PREFIX to FILE_NAME and store in FULL_NAME + * + * Return: SUCCEED/FAIL * - * Return: Non-negative on success/Negative on failure *--------------------------------------------------------------------------*/ static herr_t H5F__build_name(const char *prefix, const char *file_name, char **full_name/*out*/) @@ -818,34 +817,37 @@ done: /*------------------------------------------------------------------------- - * Function: H5F_new + * Function: H5F__new * - * Purpose: Creates a new file object and initializes it. The - * H5Fopen and H5Fcreate functions then fill in various fields. - * If SHARED is a non-null pointer then the shared info - * to which it points has the reference count incremented. - * Otherwise a new, empty shared info struct is created and - * initialized with the specified file access property list. + * Purpose: Creates a new file object and initializes it. The + * H5Fopen and H5Fcreate functions then fill in various fields. + * If SHARED is a non-null pointer then the shared info + * to which it points has the reference count incremented. + * Otherwise a new, empty shared info struct is created and + * initialized with the specified file access property list. + * + * Return: Success: Pointer to a new file struct + * + * Failure: NULL * - * Return: Success: Ptr to a new file struct. - * Failure: NULL *------------------------------------------------------------------------- */ H5F_t * -H5F_new(H5F_file_t *shared, unsigned flags, hid_t fcpl_id, hid_t fapl_id, H5FD_t *lf) +H5F__new(H5F_file_t *shared, unsigned flags, hid_t fcpl_id, hid_t fapl_id, H5FD_t *lf) { - H5F_t *f = NULL, *ret_value = NULL; + H5F_t *f = NULL; + H5F_t *ret_value = NULL; - FUNC_ENTER_NOAPI_NOINIT + FUNC_ENTER_PACKAGE if(NULL == (f = H5FL_CALLOC(H5F_t))) HGOTO_ERROR(H5E_FILE, H5E_NOSPACE, NULL, "can't allocate top file structure") - f->file_id = -1; + f->file_id = H5I_INVALID_HID; if(shared) { HDassert(lf == NULL); f->shared = shared; - } /* end if */ + } else { H5P_genplist_t *plist; /* Property list */ unsigned efc_size; /* External file cache size */ @@ -866,7 +868,7 @@ H5F_new(H5F_file_t *shared, unsigned flags, hid_t fcpl_id, hid_t fapl_id, H5FD_t f->shared->fs_state[u] = H5F_FS_STATE_CLOSED; f->shared->fs_addr[u] = HADDR_UNDEF; f->shared->fs_man[u] = NULL; - } /* end for */ + } f->shared->first_alloc_dealloc = FALSE; f->shared->eoa_pre_fsm_fsalloc = HADDR_UNDEF; f->shared->eoa_post_fsm_fsalloc = HADDR_UNDEF; @@ -878,9 +880,8 @@ H5F_new(H5F_file_t *shared, unsigned flags, hid_t fcpl_id, hid_t fapl_id, H5FD_t /* intialize point of no return */ f->shared->point_of_no_return = FALSE; - /* - * Copy the file creation and file access property lists into the - * new file handle. We do this early because some values might need + /* Copy the file creation and file access property lists into the + * new file handle. We do this early because some values might need * to change as the file is being opened. */ if(NULL == (plist = (H5P_genplist_t *)H5I_object(fcpl_id))) @@ -906,7 +907,8 @@ H5F_new(H5F_file_t *shared, unsigned flags, hid_t fcpl_id, hid_t fapl_id, H5FD_t HDassert(f->shared->fs_page_size >= H5F_FILE_SPACE_PAGE_SIZE_MIN); /* Temporary for multi/split drivers: fail file creation - when persisting free-space or using paged aggregation strategy */ + * when persisting free-space or using paged aggregation strategy. + */ if(H5F_HAS_FEATURE(f, H5FD_FEAT_PAGED_AGGR)) if(f->shared->fs_strategy == H5F_FSPACE_STRATEGY_PAGE || f->shared->fs_persist) HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, NULL, "can't open with this strategy or persistent fs") @@ -947,7 +949,7 @@ H5F_new(H5F_file_t *shared, unsigned flags, hid_t fcpl_id, hid_t fapl_id, H5FD_t if(H5P_get(plist, H5F_ACS_EFC_SIZE_NAME, &efc_size) < 0) HGOTO_ERROR(H5E_PLIST, H5E_CANTGET, NULL, "can't get elink file cache size") if(efc_size > 0) - if(NULL == (f->shared->efc = H5F_efc_create(efc_size))) + if(NULL == (f->shared->efc = H5F__efc_create(efc_size))) HGOTO_ERROR(H5E_FILE, H5E_CANTINIT, NULL, "can't create external file cache") #ifdef H5_HAVE_PARALLEL if(H5P_get(plist, H5_COLL_MD_READ_FLAG_NAME, &(f->coll_md_read)) < 0) @@ -1000,12 +1002,12 @@ H5F_new(H5F_file_t *shared, unsigned flags, hid_t fcpl_id, hid_t fapl_id, H5FD_t f->shared->feature_flags &= ~(unsigned)H5FD_FEAT_ACCUMULATE_METADATA; if(H5FD_set_feature_flags(f->shared->lf, f->shared->feature_flags) < 0) HGOTO_ERROR(H5E_FILE, H5E_CANTSET, NULL, "can't set feature_flags in VFD") - } /* end if */ + } else { /* If no value for read attempts has been set, use the default */ if(!f->shared->read_attempts) f->shared->read_attempts = H5F_METADATA_READ_ATTEMPTS; - } /* end else */ + } /* Determine the # of bins for metdata read retries */ if(H5F_set_retries(f) < 0) @@ -1031,8 +1033,7 @@ H5F_new(H5F_file_t *shared, unsigned flags, hid_t fcpl_id, hid_t fapl_id, H5FD_t if(H5P_get(plist, H5F_ACS_OBJECT_FLUSH_CB_NAME, &(f->shared->object_flush)) < 0) HGOTO_ERROR(H5E_FILE, H5E_CANTGET, NULL, "can't get object flush cb info") - /* - * Create a metadata cache with the specified number of elements. + /* Create a metadata cache with the specified number of elements. * The cache might be created with a different number of elements and * the access property list should be updated to reflect that. */ @@ -1069,12 +1070,12 @@ done: HDONE_ERROR(H5E_FILE, H5E_CANTDEC, NULL, "can't close property list") f->shared = H5FL_FREE(H5F_file_t, f->shared); - } /* end if */ + } f = H5FL_FREE(H5F_t, f); - } /* end if */ + } FUNC_LEAVE_NOAPI(ret_value) -} /* end H5F_new() */ +} /* end H5F__new() */ /*------------------------------------------------------------------------- @@ -1587,7 +1588,7 @@ H5F_open(const char *name, unsigned flags, hid_t fcpl_id, hid_t fapl_id) HGOTO_ERROR(H5E_FILE, H5E_CANTOPENFILE, NULL, "SWMR read access flag not the same for file that is already open") /* Allocate new "high-level" file struct */ - if((file = H5F_new(shared, flags, fcpl_id, fapl_id, NULL)) == NULL) + if((file = H5F__new(shared, flags, fcpl_id, fapl_id, NULL)) == NULL) HGOTO_ERROR(H5E_FILE, H5E_CANTOPENFILE, NULL, "unable to create new file object") } /* end if */ else { @@ -1615,7 +1616,7 @@ H5F_open(const char *name, unsigned flags, hid_t fcpl_id, hid_t fapl_id) } /* end if */ /* Create the 'top' file structure */ - if(NULL == (file = H5F_new(NULL, flags, fcpl_id, fapl_id, lf))) { + if(NULL == (file = H5F__new(NULL, flags, fcpl_id, fapl_id, lf))) { /* If this is the only time the file has been opened and the struct * returned is NULL, H5FD_close() will never be called via H5F_dest() * so we have to close lf here before heading to the error handling. @@ -2085,7 +2086,7 @@ H5F__close_cb(H5F_t *f) unsigned nopen_objs = 0; /* Number of open objects in file/mount hierarchy */ /* Get the number of open objects and open files on this file/mount hierarchy */ - if(H5F_mount_count_ids(f, &nopen_files, &nopen_objs) < 0) + if(H5F__mount_count_ids(f, &nopen_files, &nopen_objs) < 0) HGOTO_ERROR(H5E_SYM, H5E_MOUNT, FAIL, "problem checking mount hierarchy") /* If there are no other file IDs open on this file/mount hier., but @@ -2150,7 +2151,7 @@ H5F_try_close(H5F_t *f, hbool_t *was_closed /*out*/) } /* end if */ /* Get the number of open objects and open files on this file/mount hierarchy */ - if(H5F_mount_count_ids(f, &nopen_files, &nopen_objs) < 0) + if(H5F__mount_count_ids(f, &nopen_files, &nopen_objs) < 0) HGOTO_ERROR(H5E_SYM, H5E_MOUNT, FAIL, "problem checking mount hierarchy") /* diff --git a/src/H5Fmount.c b/src/H5Fmount.c index e3a92fd..e01ad55 100644 --- a/src/H5Fmount.c +++ b/src/H5Fmount.c @@ -15,21 +15,18 @@ /* Packages needed by this file... */ -#include "H5private.h" /* Generic Functions */ -#include "H5ACprivate.h" /* Metadata cache */ -#include "H5CXprivate.h" /* API Contexts */ -#include "H5Eprivate.h" /* Error handling */ -#include "H5Fpkg.h" /* File access */ -#include "H5Gprivate.h" /* Groups */ -#include "H5Iprivate.h" /* IDs */ -#include "H5Pprivate.h" /* Property lists */ -#include "H5MMprivate.h" /* Memory management */ +#include "H5private.h" /* Generic Functions */ +#include "H5ACprivate.h" /* Metadata cache */ +#include "H5CXprivate.h" /* API Contexts */ +#include "H5Eprivate.h" /* Error handling */ +#include "H5Fpkg.h" /* File access */ +#include "H5Gprivate.h" /* Groups */ +#include "H5Iprivate.h" /* IDs */ +#include "H5MMprivate.h" /* Memory management */ +#include "H5Pprivate.h" /* Property lists */ /* PRIVATE PROTOTYPES */ -static herr_t H5F__mount(H5G_loc_t *loc, const char *name, H5F_t *child, - hid_t plist_id); -static herr_t H5F__unmount(H5G_loc_t *loc, const char *name); -static void H5F_mount_count_ids_recurse(H5F_t *f, unsigned *nopen_files, unsigned *nopen_objs); +static void H5F__mount_count_ids_recurse(H5F_t *f, unsigned *nopen_files, unsigned *nopen_objs); /*------------------------------------------------------------------------- @@ -47,16 +44,17 @@ static void H5F_mount_count_ids_recurse(H5F_t *f, unsigned *nopen_files, unsigne herr_t H5F__close_mounts(H5F_t *f) { - unsigned u; /* Local index */ - herr_t ret_value=SUCCEED; /* Return value */ + unsigned u; /* Local index */ + herr_t ret_value = SUCCEED; /* Return value */ - FUNC_ENTER_NOAPI(FAIL) + FUNC_ENTER_PACKAGE HDassert(f); /* Unmount all child files. Loop backwards to avoid having to adjust u when * a file is unmounted. Note that we rely on unsigned u "wrapping around" - * to terminate the loop. */ + * to terminate the loop. + */ for (u = f->shared->mtab.nmounts - 1; u < f->shared->mtab.nmounts; u--) { /* Only unmount children mounted to this top level file structure */ if(f->shared->mtab.child[u].file->parent == f) { @@ -77,7 +75,7 @@ H5F__close_mounts(H5F_t *f) f->shared->mtab.nmounts--; f->nmounts--; } - } /* end if */ + } HDassert(f->nmounts == 0); @@ -100,7 +98,7 @@ done: * *------------------------------------------------------------------------- */ -static herr_t +herr_t H5F__mount(H5G_loc_t *loc, const char *name, H5F_t *child, hid_t H5_ATTR_UNUSED plist_id) { H5G_t *mount_point = NULL; /*mount point group */ @@ -112,9 +110,9 @@ H5F__mount(H5G_loc_t *loc, const char *name, H5F_t *child, hid_t H5_ATTR_UNUSED H5G_name_t mp_path; /* Mount point group hier. path */ H5O_loc_t mp_oloc; /* Mount point object location */ H5G_loc_t root_loc; /* Group location of root of file to mount */ - herr_t ret_value = SUCCEED; /*return value */ + herr_t ret_value = SUCCEED; /* Return value */ - FUNC_ENTER_STATIC_VOL + FUNC_ENTER_PACKAGE_VOL HDassert(loc); HDassert(name && *name); @@ -162,9 +160,9 @@ H5F__mount(H5G_loc_t *loc, const char *name, H5F_t *child, hid_t H5_ATTR_UNUSED mp_loc.path = H5G_nameof(mount_point); HDassert(mp_loc.path); for(ancestor = parent; ancestor; ancestor = ancestor->parent) { - if(ancestor->shared == child->shared) - HGOTO_ERROR(H5E_FILE, H5E_MOUNT, FAIL, "mount would introduce a cycle") - } /* end for */ + if(ancestor->shared == child->shared) + HGOTO_ERROR(H5E_FILE, H5E_MOUNT, FAIL, "mount would introduce a cycle") + } /* Make certain that the parent & child files have the same "file close degree" */ if(parent->shared->fc_degree != child->shared->fc_degree) @@ -181,29 +179,29 @@ H5F__mount(H5G_loc_t *loc, const char *name, H5F_t *child, hid_t H5_ATTR_UNUSED while(lt < rt && cmp) { H5O_loc_t *oloc; /*temporary symbol table entry */ - md = (lt + rt) / 2; - oloc = H5G_oloc(parent->shared->mtab.child[md].group); - cmp = H5F_addr_cmp(mp_loc.oloc->addr, oloc->addr); - if(cmp < 0) - rt = md; - else if(cmp > 0) - lt = md + 1; - } /* end while */ + md = (lt + rt) / 2; + oloc = H5G_oloc(parent->shared->mtab.child[md].group); + cmp = H5F_addr_cmp(mp_loc.oloc->addr, oloc->addr); + if(cmp < 0) + rt = md; + else if(cmp > 0) + lt = md + 1; + } if(cmp > 0) md++; if(!cmp) - HGOTO_ERROR(H5E_FILE, H5E_MOUNT, FAIL, "mount point is already in use") + HGOTO_ERROR(H5E_FILE, H5E_MOUNT, FAIL, "mount point is already in use") /* Make room in the table */ if(parent->shared->mtab.nmounts >= parent->shared->mtab.nalloc) { - unsigned n = MAX(16, 2 * parent->shared->mtab.nalloc); - H5F_mount_t *x = (H5F_mount_t *)H5MM_realloc(parent->shared->mtab.child, n * sizeof(parent->shared->mtab.child[0])); + unsigned n = MAX(16, 2 * parent->shared->mtab.nalloc); + H5F_mount_t *x = (H5F_mount_t *)H5MM_realloc(parent->shared->mtab.child, n * sizeof(parent->shared->mtab.child[0])); - if(!x) - HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, FAIL, "memory allocation failed for mount table") - parent->shared->mtab.child = x; - parent->shared->mtab.nalloc = n; - } /* end if */ + if(!x) + HGOTO_ERROR(H5E_RESOURCE, H5E_NOSPACE, FAIL, "memory allocation failed for mount table") + parent->shared->mtab.child = x; + parent->shared->mtab.nalloc = n; + } /* Insert into table */ HDmemmove(parent->shared->mtab.child + md + 1, parent->shared->mtab.child + md, @@ -228,19 +226,19 @@ H5F__mount(H5G_loc_t *loc, const char *name, H5F_t *child, hid_t H5_ATTR_UNUSED /* We pass H5G_UNKNOWN as object type; search all IDs */ 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) < 0) - HGOTO_ERROR(H5E_FILE, H5E_MOUNT, FAIL, "unable to replace name") + HGOTO_ERROR(H5E_FILE, H5E_MOUNT, FAIL, "unable to replace name") done: if(ret_value < 0) { 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_VOL(ret_value) } /* end H5F__mount() */ @@ -264,7 +262,7 @@ done: * *------------------------------------------------------------------------- */ -static herr_t +herr_t H5F__unmount(H5G_loc_t *loc, const char *name) { H5G_t *child_group = NULL; /* Child's group in parent mtab */ @@ -279,7 +277,7 @@ H5F__unmount(H5G_loc_t *loc, const char *name) int child_idx; /* Index of child in parent's mtab */ herr_t ret_value = SUCCEED; /*return value */ - FUNC_ENTER_STATIC_VOL + FUNC_ENTER_PACKAGE_VOL HDassert(loc); HDassert(name && *name); @@ -304,41 +302,43 @@ H5F__unmount(H5G_loc_t *loc, const char *name) if(child->parent && H5F_addr_eq(mp_oloc.addr, mnt_oloc->addr)) { unsigned u; /*counters */ - /* - * We've been given the root group of the child. We do a reverse - * lookup in the parent's mount table to find the correct entry. - */ - parent = child->parent; - for(u = 0; u < parent->shared->mtab.nmounts; u++) { - if(parent->shared->mtab.child[u].file->shared == child->shared) { + /* + * We've been given the root group of the child. We do a reverse + * lookup in the parent's mount table to find the correct entry. + */ + parent = child->parent; + for(u = 0; u < parent->shared->mtab.nmounts; u++) { + if(parent->shared->mtab.child[u].file->shared == child->shared) { /* Found the correct index */ child_idx = (int)u; break; - } /* end if */ - } /* end for */ - } else { + } + } + } + else { unsigned lt, rt, md = 0; /*binary search indices */ int cmp; /*binary search comparison value*/ - /* - * We've been given the mount point in the parent. We use a binary - * search in the parent to locate the mounted file, if any. - */ - parent = child; /*we guessed wrong*/ - lt = 0; - rt = parent->shared->mtab.nmounts; - cmp = -1; - while(lt < rt && cmp) { - md = (lt + rt) / 2; - mnt_oloc = H5G_oloc(parent->shared->mtab.child[md].group); - cmp = H5F_addr_cmp(mp_oloc.addr, mnt_oloc->addr); - if (cmp<0) - rt = md; - else - lt = md + 1; - } /* end while */ - if(cmp) - HGOTO_ERROR(H5E_FILE, H5E_MOUNT, FAIL, "not a mount point") + /* We've been given the mount point in the parent. We use a binary + * search in the parent to locate the mounted file, if any. + */ + parent = child; /*we guessed wrong*/ + lt = 0; + rt = parent->shared->mtab.nmounts; + cmp = -1; + + while(lt < rt && cmp) { + md = (lt + rt) / 2; + mnt_oloc = H5G_oloc(parent->shared->mtab.child[md].group); + cmp = H5F_addr_cmp(mp_oloc.addr, mnt_oloc->addr); + if (cmp<0) + rt = md; + else + lt = md + 1; + } + + if(cmp) + HGOTO_ERROR(H5E_FILE, H5E_MOUNT, FAIL, "not a mount point") /* Found the correct index, set the info about the child */ child_idx = (int)md; @@ -426,15 +426,12 @@ H5F_is_mount(const H5F_t *file) /*------------------------------------------------------------------------- - * Function: H5Fmount + * Function: H5Fmount * - * Purpose: Mount file CHILD_ID onto the group specified by LOC_ID and - * NAME using mount properties PLIST_ID. + * Purpose: Mount file CHILD_ID onto the group specified by LOC_ID and + * NAME using mount properties PLIST_ID. * - * Return: Non-negative on success/Negative on failure - * - * Programmer: Robb Matzke - * Tuesday, October 6, 1998 + * Return: SUCCEED/FAIL * *------------------------------------------------------------------------- */ @@ -443,18 +440,18 @@ H5Fmount(hid_t loc_id, const char *name, hid_t child_id, hid_t plist_id) { H5G_loc_t loc; H5F_t *child = NULL; - herr_t ret_value = SUCCEED; /* Return value */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_API(FAIL) H5TRACE4("e", "i*sii", loc_id, name, child_id, plist_id); /* Check arguments */ if(H5G_loc(loc_id, &loc) < 0) - HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a location") + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a location") if(!name || !*name) - HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "no name") + HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "no name") if(NULL == (child = (H5F_t *)H5I_object_verify(child_id, H5I_FILE))) - HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a file") + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a file") if(H5P_DEFAULT == plist_id) plist_id = H5P_FILE_MOUNT_DEFAULT; else @@ -465,9 +462,9 @@ H5Fmount(hid_t loc_id, const char *name, hid_t child_id, hid_t plist_id) if(H5CX_set_loc(loc_id) < 0) HGOTO_ERROR(H5E_FILE, H5E_CANTSET, FAIL, "can't set collective metadata read info") - /* Do the mount */ + /* Perform the mount operation */ if(H5F__mount(&loc, name, child, plist_id) < 0) - HGOTO_ERROR(H5E_FILE, H5E_MOUNT, FAIL, "unable to mount file") + HGOTO_ERROR(H5E_FILE, H5E_MOUNT, FAIL, "unable to mount file") done: FUNC_LEAVE_API(ret_value) @@ -475,21 +472,18 @@ done: /*------------------------------------------------------------------------- - * Function: H5Funmount - * - * Purpose: Given a mount point, dissassociate the mount point's file - * from the file mounted there. Do not close either file. + * Function: H5Funmount * - * The mount point can either be the group in the parent or the - * root group of the mounted file (both groups have the same - * name). If the mount point was opened before the mount then - * it's the group in the parent, but if it was opened after the - * mount then it's the root group of the child. + * Purpose: Given a mount point, dissassociate the mount point's file + * from the file mounted there. Do not close either file. * - * Return: Non-negative on success/Negative on failure + * The mount point can either be the group in the parent or the + * root group of the mounted file (both groups have the same + * name). If the mount point was opened before the mount then + * it's the group in the parent, but if it was opened after the + * mount then it's the root group of the child. * - * Programmer: Robb Matzke - * Tuesday, October 6, 1998 + * Return: SUCCEED/FAIL * *------------------------------------------------------------------------- */ @@ -497,16 +491,16 @@ herr_t H5Funmount(hid_t loc_id, const char *name) { H5G_loc_t loc; - herr_t ret_value=SUCCEED; /* Return value */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_API(FAIL) H5TRACE2("e", "i*s", loc_id, name); /* Check args */ if(H5G_loc(loc_id, &loc) < 0) - HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a location") + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a location") if(!name || !*name) - HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "no name") + HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "no name") /* Set up collective metadata if appropriate */ if(H5CX_set_loc(loc_id) < 0) @@ -514,7 +508,7 @@ H5Funmount(hid_t loc_id, const char *name) /* Unmount */ if(H5F__unmount(&loc, name) < 0) - HGOTO_ERROR(H5E_FILE, H5E_MOUNT, FAIL, "unable to unmount file") + HGOTO_ERROR(H5E_FILE, H5E_MOUNT, FAIL, "unable to unmount file") done: FUNC_LEAVE_API(ret_value) @@ -522,12 +516,12 @@ done: /*------------------------------------------------------------------------- - * Function: H5F_mount_count_ids_recurse + * Function: H5F__mount_count_ids_recurse * - * Purpose: Helper routine for counting number of open IDs in mount + * Purpose: Helper routine for counting number of open IDs in mount * hierarchy. * - * Return: + * Return: void * * Programmer: Quincey Koziol * Tuesday, July 19, 2005 @@ -535,11 +529,11 @@ done: *------------------------------------------------------------------------- */ static void -H5F_mount_count_ids_recurse(H5F_t *f, unsigned *nopen_files, unsigned *nopen_objs) +H5F__mount_count_ids_recurse(H5F_t *f, unsigned *nopen_files, unsigned *nopen_objs) { unsigned u; /* Local index value */ - FUNC_ENTER_NOAPI_NOINIT_NOERR + FUNC_ENTER_STATIC_NOERR /* Sanity check */ HDassert(f); @@ -564,20 +558,20 @@ H5F_mount_count_ids_recurse(H5F_t *f, unsigned *nopen_files, unsigned *nopen_obj if(H5G_get_shared_count(f->shared->mtab.child[u].group) > 1) *nopen_objs += 1; - H5F_mount_count_ids_recurse(f->shared->mtab.child[u].file, nopen_files, nopen_objs); + H5F__mount_count_ids_recurse(f->shared->mtab.child[u].file, nopen_files, nopen_objs); } - } /* end for */ + } FUNC_LEAVE_NOAPI_VOID -} /* end H5F_mount_count_ids_recurse() */ +} /* end H5F__mount_count_ids_recurse() */ /*------------------------------------------------------------------------- - * Function: H5F_mount_count_ids + * Function: H5F__mount_count_ids * - * Purpose: Count the number of open file & object IDs in a mount hierarchy + * Purpose: Count the number of open file & object IDs in a mount hierarchy * - * Return: SUCCEED/FAIL + * Return: SUCCEED/FAIL * * Programmer: Quincey Koziol * Tues, July 19, 2005 @@ -585,9 +579,9 @@ H5F_mount_count_ids_recurse(H5F_t *f, unsigned *nopen_files, unsigned *nopen_obj *------------------------------------------------------------------------- */ herr_t -H5F_mount_count_ids(H5F_t *f, unsigned *nopen_files, unsigned *nopen_objs) +H5F__mount_count_ids(H5F_t *f, unsigned *nopen_files, unsigned *nopen_objs) { - FUNC_ENTER_NOAPI_NOINIT_NOERR + FUNC_ENTER_PACKAGE_NOERR /* Sanity check */ HDassert(f); @@ -599,10 +593,10 @@ H5F_mount_count_ids(H5F_t *f, unsigned *nopen_files, unsigned *nopen_objs) f = f->parent; /* Count open IDs in the hierarchy */ - H5F_mount_count_ids_recurse(f, nopen_files, nopen_objs); + H5F__mount_count_ids_recurse(f, nopen_files, nopen_objs); FUNC_LEAVE_NOAPI(SUCCEED) -} /* end H5F_mount_count_ids() */ +} /* end H5F__mount_count_ids() */ /*------------------------------------------------------------------------- @@ -648,11 +642,11 @@ done: /*------------------------------------------------------------------------- - * Function: H5F_flush_mounts + * Function: H5F_flush_mounts * - * Purpose: Flush a mount hierarchy + * Purpose: Flush a mount hierarchy * - * Return: SUCCEED/FAIL + * Return: SUCCEED/FAIL * * Programmer: Quincey Koziol * Fri, August 21, 2009 @@ -715,22 +709,22 @@ H5F_traverse_mount(H5O_loc_t *oloc/*in,out*/) * of file2, which is mounted somewhere in file3. */ do { - /* - * Use a binary search to find the potential mount point in the mount - * table for the parent - */ - lt = 0; - rt = parent->shared->mtab.nmounts; - cmp = -1; - while(lt < rt && cmp) { - md = (lt + rt) / 2; - mnt_oloc = H5G_oloc(parent->shared->mtab.child[md].group); - cmp = H5F_addr_cmp(oloc->addr, mnt_oloc->addr); - if(cmp < 0) - rt = md; - else - lt = md + 1; - } /* end while */ + /* + * Use a binary search to find the potential mount point in the mount + * table for the parent + */ + lt = 0; + rt = parent->shared->mtab.nmounts; + cmp = -1; + while(lt < rt && cmp) { + md = (lt + rt) / 2; + mnt_oloc = H5G_oloc(parent->shared->mtab.child[md].group); + cmp = H5F_addr_cmp(oloc->addr, mnt_oloc->addr); + if(cmp < 0) + rt = md; + else + lt = md + 1; + } /* Copy root info over to ENT */ if(0 == cmp) { diff --git a/src/H5Fpkg.h b/src/H5Fpkg.h index 050e426..f815005 100644 --- a/src/H5Fpkg.h +++ b/src/H5Fpkg.h @@ -30,18 +30,18 @@ #include "H5Fprivate.h" /* Other public headers needed by this file */ -#include "H5Bpublic.h" /* B-tree header, for H5B_NUM_BTREE_ID */ +#include "H5Bpublic.h" /* B-tree header, for H5B_NUM_BTREE_ID */ /* Other private headers needed by this file */ -#include "H5private.h" /* Generic Functions */ -#include "H5ACprivate.h" /* Metadata cache */ -#include "H5FLprivate.h" /* Free Lists */ -#include "H5FOprivate.h" /* File objects */ -#include "H5FSprivate.h" /* File free space */ -#include "H5Gprivate.h" /* Groups */ -#include "H5Oprivate.h" /* Object header messages */ -#include "H5PBprivate.h" /* Page buffer */ -#include "H5UCprivate.h" /* Reference counted object functions */ +#include "H5private.h" /* Generic Functions */ +#include "H5ACprivate.h" /* Metadata cache */ +#include "H5FLprivate.h" /* Free Lists */ +#include "H5FOprivate.h" /* File objects */ +#include "H5FSprivate.h" /* File free space */ +#include "H5Gprivate.h" /* Groups */ +#include "H5Oprivate.h" /* Object header messages */ +#include "H5PBprivate.h" /* Page buffer */ +#include "H5UCprivate.h" /* Reference counted object functions */ /* @@ -394,13 +394,10 @@ H5FL_EXTERN(H5F_file_t); /******************************/ /* General routines */ -H5F_t *H5F_new(H5F_file_t *shared, unsigned flags, hid_t fcpl_id, - hid_t fapl_id, H5FD_t *lf); +H5_DLL H5F_t *H5F__new(H5F_file_t *shared, unsigned flags, hid_t fcpl_id, hid_t fapl_id, H5FD_t *lf); H5_DLL herr_t H5F__dest(H5F_t *f, hbool_t flush); -H5_DLL H5F_t *H5F__create(const char *filename, unsigned flags, hid_t fcpl_id, - hid_t fapl_id); -H5_DLL H5F_t * H5F__open(const char *filename, unsigned flags, hid_t fcpl_id, - hid_t fapl_id); +H5_DLL H5F_t *H5F__create(const char *filename, unsigned flags, hid_t fcpl_id, hid_t fapl_id); +H5_DLL H5F_t *H5F__open(const char *filename, unsigned flags, hid_t fcpl_id, hid_t fapl_id); H5_DLL herr_t H5F__flush(H5F_t *f, H5F_scope_t scope); H5_DLL herr_t H5F__flush_real(H5F_t *f); H5_DLL htri_t H5F__is_hdf5(const char *name); @@ -408,8 +405,7 @@ H5_DLL herr_t H5F_get_objects(const H5F_t *f, unsigned types, size_t max_index, H5_DLL herr_t H5F__get_freespace(H5F_t *f, hsize_t *tot_space); H5_DLL ssize_t H5F__get_file_image(H5F_t *f, void *buf_ptr, size_t buf_len); H5_DLL herr_t H5F__get_info(H5F_t *f, H5F_info2_t *finfo); -H5_DLL ssize_t H5F__get_free_sections(H5F_t *f, H5FD_mem_t type, - size_t nsects, H5F_sect_info_t *sect_info); +H5_DLL ssize_t H5F__get_free_sections(H5F_t *f, H5FD_mem_t type, size_t nsects, H5F_sect_info_t *sect_info); H5_DLL herr_t H5F__get_metadata_read_retry_info(H5F_t *file, H5F_retry_info_t *info); H5_DLL herr_t H5F__format_convert(H5F_t *f); H5_DLL herr_t H5F__start_swmr_write(H5F_t *f); @@ -418,9 +414,10 @@ H5_DLL herr_t H5F__close_cb(H5F_t *f); H5_DLL herr_t H5F__set_libver_bounds(H5F_t *f, H5F_libver_t low, H5F_libver_t high); /* File mount related routines */ +H5_DLL herr_t H5F__mount(H5G_loc_t *loc, const char *name, H5F_t *child, hid_t plist_id); +H5_DLL herr_t H5F__unmount(H5G_loc_t *loc, const char *name); H5_DLL herr_t H5F__close_mounts(H5F_t *f); -H5_DLL int H5F_term_unmount_cb(void *obj_ptr, hid_t obj_id, void *key); -H5_DLL herr_t H5F_mount_count_ids(H5F_t *f, unsigned *nopen_files, unsigned *nopen_objs); +H5_DLL herr_t H5F__mount_count_ids(H5F_t *f, unsigned *nopen_files, unsigned *nopen_objs); /* Superblock related routines */ H5_DLL herr_t H5F__super_init(H5F_t *f); @@ -430,18 +427,14 @@ H5_DLL herr_t H5F__super_free(H5F_super_t *sblock); /* Superblock extension related routines */ H5_DLL herr_t H5F_super_ext_open(H5F_t *f, haddr_t ext_addr, H5O_loc_t *ext_ptr); -H5_DLL herr_t H5F__super_ext_write_msg(H5F_t *f, unsigned id, void *mesg, - hbool_t may_create, unsigned mesg_flags); +H5_DLL herr_t H5F__super_ext_write_msg(H5F_t *f, unsigned id, void *mesg, hbool_t may_create, unsigned mesg_flags); H5_DLL herr_t H5F__super_ext_remove_msg(H5F_t *f, unsigned id); H5_DLL herr_t H5F__super_ext_close(H5F_t *f, H5O_loc_t *ext_ptr, hbool_t was_created); /* Metadata accumulator routines */ -H5_DLL herr_t H5F__accum_read(H5F_t *f, H5FD_mem_t type, haddr_t addr, - size_t size, void *buf); -H5_DLL herr_t H5F__accum_write(H5F_t *f, H5FD_mem_t type, haddr_t addr, - size_t size, const void *buf); -H5_DLL herr_t H5F__accum_free(H5F_t *f, H5FD_mem_t type, haddr_t addr, - hsize_t size); +H5_DLL herr_t H5F__accum_read(H5F_t *f, H5FD_mem_t type, haddr_t addr, size_t size, void *buf); +H5_DLL herr_t H5F__accum_write(H5F_t *f, H5FD_mem_t type, haddr_t addr, size_t size, const void *buf); +H5_DLL herr_t H5F__accum_free(H5F_t *f, H5FD_mem_t type, haddr_t addr, hsize_t size); H5_DLL herr_t H5F__accum_flush(H5F_t *f); H5_DLL herr_t H5F__accum_reset(H5F_t *f, hbool_t flush); @@ -451,10 +444,9 @@ H5_DLL H5F_file_t * H5F_sfile_search(H5FD_t *lf); H5_DLL herr_t H5F_sfile_remove(H5F_file_t *shared); /* External file cache routines */ -H5_DLL H5F_efc_t *H5F_efc_create(unsigned max_nfiles); -H5_DLL H5F_t *H5F__efc_open(H5F_t *parent, const char *name, unsigned flags, - hid_t fcpl_id, hid_t fapl_id); -H5_DLL unsigned H5F_efc_max_nfiles(H5F_efc_t *efc); +H5_DLL H5F_efc_t *H5F__efc_create(unsigned max_nfiles); +H5_DLL H5F_t *H5F__efc_open(H5F_t *parent, const char *name, unsigned flags, hid_t fcpl_id, hid_t fapl_id); +H5_DLL unsigned H5F__efc_max_nfiles(H5F_efc_t *efc); H5_DLL herr_t H5F__efc_release(H5F_efc_t *efc); H5_DLL herr_t H5F__efc_destroy(H5F_efc_t *efc); H5_DLL herr_t H5F__efc_try_close(H5F_t *f); @@ -462,8 +454,7 @@ H5_DLL herr_t H5F__efc_try_close(H5F_t *f); /* Space allocation routines */ H5_DLL haddr_t H5F__alloc(H5F_t *f, H5F_mem_t type, hsize_t size, haddr_t *frag_addr, hsize_t *frag_size); H5_DLL herr_t H5F__free(H5F_t *f, H5F_mem_t type, haddr_t addr, hsize_t size); -H5_DLL htri_t H5F__try_extend(H5F_t *f, H5FD_mem_t type, haddr_t blk_end, - hsize_t extra_requested); +H5_DLL htri_t H5F__try_extend(H5F_t *f, H5FD_mem_t type, haddr_t blk_end, hsize_t extra_requested); /* Functions that get/retrieve values from VFD layer */ H5_DLL herr_t H5F__set_eoa(const H5F_t *f, H5F_mem_t type, haddr_t addr); @@ -476,8 +467,7 @@ H5_DLL herr_t H5F__evict_cache_entries(H5F_t *f); /* Testing functions */ #ifdef H5F_TESTING -H5_DLL herr_t H5F_get_sohm_mesg_count_test(hid_t fid, unsigned type_id, - size_t *mesg_count); +H5_DLL herr_t H5F_get_sohm_mesg_count_test(hid_t fid, unsigned type_id, size_t *mesg_count); H5_DLL herr_t H5F_check_cached_stab_test(hid_t file_id); H5_DLL herr_t H5F_get_maxaddr_test(hid_t file_id, haddr_t *maxaddr); H5_DLL herr_t H5F_get_sbe_addr_test(hid_t file_id, haddr_t *sbe_addr); diff --git a/src/H5Fprivate.h b/src/H5Fprivate.h index 3e77700..f06d4d0 100644 --- a/src/H5Fprivate.h +++ b/src/H5Fprivate.h @@ -296,7 +296,7 @@ typedef struct H5F_t H5F_t; #define H5F_BASE_ADDR(F) ((F)->shared->sblock->base_addr) #define H5F_SYM_LEAF_K(F) ((F)->shared->sblock->sym_leaf_k) #define H5F_KVALUE(F,T) ((F)->shared->sblock->btree_k[(T)->id]) -#define H5F_NREFS(F) ((F)->shared->nrefs) +#define H5F_NREFS(F) ((F)->shared->nrefs) #define H5F_SIZEOF_ADDR(F) ((F)->shared->sizeof_addr) #define H5F_SIZEOF_SIZE(F) ((F)->shared->sizeof_size) #define H5F_SOHM_ADDR(F) ((F)->shared->sohm_addr) @@ -713,8 +713,7 @@ typedef enum H5F_prefix_open_t { /***************************************/ /* Private functions */ -H5_DLL H5F_t *H5F_open(const char *name, unsigned flags, hid_t fcpl_id, - hid_t fapl_id); +H5_DLL H5F_t *H5F_open(const char *name, unsigned flags, hid_t fcpl_id, hid_t fapl_id); H5_DLL herr_t H5F_try_close(H5F_t *f, hbool_t *was_closed/*out*/); H5_DLL herr_t H5F_start_swmr_write(H5F_t *file); @@ -795,10 +794,8 @@ H5_DLL herr_t H5F_traverse_mount(struct H5O_loc_t *oloc/*in,out*/); H5_DLL herr_t H5F_flush_mounts(H5F_t *f); /* Functions that operate on blocks of bytes wrt super block */ -H5_DLL herr_t H5F_block_read(H5F_t *f, H5FD_mem_t type, haddr_t addr, - size_t size, void *buf/*out*/); -H5_DLL herr_t H5F_block_write(H5F_t *f, H5FD_mem_t type, haddr_t addr, - size_t size, const void *buf); +H5_DLL herr_t H5F_block_read(H5F_t *f, H5FD_mem_t type, haddr_t addr, size_t size, void *buf/*out*/); +H5_DLL herr_t H5F_block_write(H5F_t *f, H5FD_mem_t type, haddr_t addr, size_t size, const void *buf); /* Functions that flush or evict */ H5_DLL herr_t H5F_flush_tagged_metadata(H5F_t *f, haddr_t tag); @@ -851,8 +848,7 @@ H5_DLL H5F_t *H5F_prefix_open_file(H5F_t *primary_file, H5F_prefix_open_t prefix /* Global heap CWFS routines */ H5_DLL herr_t H5F_cwfs_add(H5F_t *f, struct H5HG_heap_t *heap); H5_DLL herr_t H5F_cwfs_find_free_heap(H5F_t *f, size_t need, haddr_t *addr); -H5_DLL herr_t H5F_cwfs_advance_heap(H5F_t *f, struct H5HG_heap_t *heap, - hbool_t add_heap); +H5_DLL herr_t H5F_cwfs_advance_heap(H5F_t *f, struct H5HG_heap_t *heap, hbool_t add_heap); H5_DLL herr_t H5F_cwfs_remove_heap(H5F_file_t *shared, struct H5HG_heap_t *heap); /* Debugging functions */ diff --git a/test/efc.c b/test/efc.c index d40d4a2..5a946bb 100644 --- a/test/efc.c +++ b/test/efc.c @@ -36,8 +36,8 @@ static char filename[6][1024]; /* Global property lists - just copies of the defaults (necessary to use * internal functions */ -hid_t fcpl_id = -1; -hid_t fapl_id = -1; +hid_t fcpl_id = H5I_INVALID_HID; +hid_t fapl_id = H5I_INVALID_HID; /*------------------------------------------------------------------------- @@ -68,8 +68,9 @@ test_single(void) TESTING("single EFC"); - /* Set EFC size to 3. Do this instead of H5F_efc_create() so we can pass - * a file pointer to H5F__efc_open containing the EFC. */ + /* Set EFC size to 3. Do this instead of H5F__efc_create() so we can pass + * a file pointer to H5F__efc_open containing the EFC. + */ if(H5Pset_elink_file_cache_size(fapl_id, 3) < 0) TEST_ERROR @@ -84,8 +85,9 @@ test_single(void) /* Test 1: Open file 1 through EFC, close, then open normally, verify ref - * count = 2, release EFC, verify ref count = 1. Verifies a file can be - * held open by the EFC. */ + * count = 2, release EFC, verify ref count = 1. Verifies a file can be + * held open by the EFC. + */ if(NULL == (f1 = H5F__efc_open(f0, filename[1], H5F_ACC_RDWR | H5F_ACC_CREAT | H5F_ACC_TRUNC, fcpl_id, fapl_id))) FAIL_STACK_ERROR @@ -502,17 +504,19 @@ test_graph_nocycle(void) TESTING("graph of EFCs without cycles"); - /* Set EFC size to 8. Do this instead of H5F_efc_create() so we can pass - * a file pointer to H5F__efc_open containing the EFC. Set to a high number - * because we don't test the EFC becoming too large in this test. */ + /* Set EFC size to 8. Do this instead of H5F__efc_create() so we can pass + * a file pointer to H5F__efc_open containing the EFC. Set to a high number + * because we don't test the EFC becoming too large in this test. + */ if(H5Pset_elink_file_cache_size(fapl_id, 8) < 0) TEST_ERROR - /* Test 1: Simple 3 file chain. Open file 1 through file 0, then open file - * 2 through file 1. Release file 0's EFC and verify that file 2 gets its - * ref count reduced (implying file 1 was closed). Do the same with the - * opening order reversed. */ + /* Test 1: Simple 3 file chain. Open file 1 through file 0, then open file + * 2 through file 1. Release file 0's EFC and verify that file 2 gets its + * ref count reduced (implying file 1 was closed). Do the same with the + * opening order reversed. + */ if(NULL == (f0 = H5F_open(filename[0], H5F_ACC_RDWR | H5F_ACC_CREAT | H5F_ACC_TRUNC, fcpl_id, fapl_id))) FAIL_STACK_ERROR @@ -847,15 +851,17 @@ test_graph_cycle(void) TESTING("graph of EFCs with cycles"); - /* Set EFC size to 8. Do this instead of H5F_efc_create() so we can pass - * a file pointer to H5F__efc_open containing the EFC. Set to a high number - * because we don't test the EFC becoming too large in this test. */ + /* Set EFC size to 8. Do this instead of H5F__efc_create() so we can pass + * a file pointer to H5F__efc_open containing the EFC. Set to a high number + * because we don't test the EFC becoming too large in this test. + */ if(H5Pset_elink_file_cache_size(fapl_id, 8) < 0) TEST_ERROR - /* Test 1: File caches itself. Verify that closing the file causes it to be - * actually closed, and there is no other unexpected behavior. */ + /* Test 1: File caches itself. Verify that closing the file causes it to be + * actually closed, and there is no other unexpected behavior. + */ if(NULL == (f0 = H5F_open(filename[0], H5F_ACC_RDWR | H5F_ACC_CREAT | H5F_ACC_TRUNC, fcpl_id, fapl_id))) FAIL_STACK_ERROR -- cgit v0.12 From 18fbdebb977d7a4dbaa99ec6b153a49e3b4883d5 Mon Sep 17 00:00:00 2001 From: Dana Robinson Date: Wed, 6 Jun 2018 23:08:29 -0700 Subject: Cleaned up H5Fmount/unmount code. --- src/H5Fmount.c | 58 ++++++++++++++++++++++++++++++++++++++++------------------ 1 file changed, 40 insertions(+), 18 deletions(-) diff --git a/src/H5Fmount.c b/src/H5Fmount.c index e01ad55..4cd1edf 100644 --- a/src/H5Fmount.c +++ b/src/H5Fmount.c @@ -438,30 +438,44 @@ H5F_is_mount(const H5F_t *file) herr_t H5Fmount(hid_t loc_id, const char *name, hid_t child_id, hid_t plist_id) { - H5G_loc_t loc; - H5F_t *child = NULL; - herr_t ret_value = SUCCEED; /* Return value */ + H5G_loc_t loc; /* Parent location */ + H5F_t *child = NULL; /* Child object */ + H5I_type_t loc_type; /* ID type of location */ + H5I_type_t child_type; /* ID type of child */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_API(FAIL) H5TRACE4("e", "i*sii", loc_id, name, child_id, plist_id); /* Check arguments */ - if(H5G_loc(loc_id, &loc) < 0) - HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a location") - if(!name || !*name) - HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "no name") - if(NULL == (child = (H5F_t *)H5I_object_verify(child_id, H5I_FILE))) - HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a file") + loc_type = H5I_get_type(loc_id); + if(H5I_FILE != loc_type && H5I_GROUP != loc_type) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "loc_id parameter not a file or group ID") + if(!name) + HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "name parameter cannot be NULL") + if(!*name) + HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "name parameter cannot be the empty string") + child_type = H5I_get_type(child_id); + if(H5I_FILE != child_type) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "child_id parameter not a file ID") if(H5P_DEFAULT == plist_id) plist_id = H5P_FILE_MOUNT_DEFAULT; else if(TRUE != H5P_isa_class(plist_id, H5P_FILE_MOUNT)) - HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not property list") + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "plist_id is not a property list ID") /* Set up collective metadata if appropriate */ if(H5CX_set_loc(loc_id) < 0) HGOTO_ERROR(H5E_FILE, H5E_CANTSET, FAIL, "can't set collective metadata read info") + /* Get the location object */ + if(H5G_loc(loc_id, &loc) < 0) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "could not get location object") + + /* Get the child object */ + if(NULL == (child = (H5F_t *)H5I_object_verify(child_id, H5I_FILE))) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "could not get child object") + /* Perform the mount operation */ if(H5F__mount(&loc, name, child, plist_id) < 0) HGOTO_ERROR(H5E_FILE, H5E_MOUNT, FAIL, "unable to mount file") @@ -490,23 +504,31 @@ done: herr_t H5Funmount(hid_t loc_id, const char *name) { - H5G_loc_t loc; - herr_t ret_value = SUCCEED; /* Return value */ + H5G_loc_t loc; /* Parent location */ + H5I_type_t loc_type; /* ID type of location */ + herr_t ret_value = SUCCEED; /* Return value */ FUNC_ENTER_API(FAIL) H5TRACE2("e", "i*s", loc_id, name); - /* Check args */ - if(H5G_loc(loc_id, &loc) < 0) - HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a location") - if(!name || !*name) - HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "no name") + /* Check arguments */ + loc_type = H5I_get_type(loc_id); + if(H5I_FILE != loc_type && H5I_GROUP != loc_type) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "loc_id parameter not a file or group ID") + if(!name) + HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "name parameter cannot be NULL") + if(!*name) + HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "name parameter cannot be the empty string") /* Set up collective metadata if appropriate */ if(H5CX_set_loc(loc_id) < 0) HGOTO_ERROR(H5E_FILE, H5E_CANTSET, FAIL, "can't set collective metadata read info") - /* Unmount */ + /* Get the location object */ + if(H5G_loc(loc_id, &loc) < 0) + HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "could not get location object") + + /* Perform the unmount operation */ if(H5F__unmount(&loc, name) < 0) HGOTO_ERROR(H5E_FILE, H5E_MOUNT, FAIL, "unable to unmount file") -- cgit v0.12