summaryrefslogtreecommitdiffstats
path: root/src/H5Glink.c
diff options
context:
space:
mode:
authorQuincey Koziol <koziol@hdfgroup.org>2006-11-13 21:45:35 (GMT)
committerQuincey Koziol <koziol@hdfgroup.org>2006-11-13 21:45:35 (GMT)
commitf494ab7674dc39225deb4a06ba211f82f3e9df5e (patch)
tree55d6b6ace03aa2063c0569466d9ef474fcf66487 /src/H5Glink.c
parent3f7dc01ccc7f9702c3a4080afe0c2ddebf34c032 (diff)
downloadhdf5-f494ab7674dc39225deb4a06ba211f82f3e9df5e.zip
hdf5-f494ab7674dc39225deb4a06ba211f82f3e9df5e.tar.gz
hdf5-f494ab7674dc39225deb4a06ba211f82f3e9df5e.tar.bz2
[svn-r12906] Description:
Straighten out some convoluted code when links were being deleted, which could cause the "delete" callback for user-defined links to not get called when the group they were in was deleted. Had to compromise on the "delete" callback though - only calls the callback with the ID for the file the link is in, instead of the group, since the group is being held open upstream in the calling sequence during a group deletion and this prevents a group and its ID from being created. (This could possibly be worked around, but would cause a fair bit of havoc in the code and I'm not entirely certain it's worth it...) Tested on: Linux/32 2.6 (chicago)
Diffstat (limited to 'src/H5Glink.c')
-rw-r--r--src/H5Glink.c66
1 files changed, 66 insertions, 0 deletions
diff --git a/src/H5Glink.c b/src/H5Glink.c
index 0600e97..9144096 100644
--- a/src/H5Glink.c
+++ b/src/H5Glink.c
@@ -37,6 +37,9 @@
#include "H5Eprivate.h" /* Error handling */
#include "H5Gpkg.h" /* Groups */
#include "H5HLprivate.h" /* Local Heaps */
+#include "H5Iprivate.h" /* IDs */
+#include "H5Lprivate.h" /* Links */
+#include "H5MMprivate.h" /* Memory management */
/****************/
@@ -418,3 +421,66 @@ done:
FUNC_LEAVE_NOAPI(ret_value)
} /* end H5G_link_release_table() */
+
+/*-------------------------------------------------------------------------
+ * Function: H5G_link_obj_type
+ *
+ * Purpose: Determine the type of object referred to (for hard links) or
+ * the link type (for soft links and user-defined links).
+ *
+ * Return: Non-negative on success/Negative on failure
+ *
+ * Programmer: Quincey Koziol
+ * koziol@hdfgroup.org
+ * Nov 13 2006
+ *
+ *-------------------------------------------------------------------------
+ */
+herr_t
+H5G_link_obj_type(H5F_t *file, hid_t dxpl_id, const H5O_link_t *lnk,
+ H5G_obj_t *obj_type)
+{
+ herr_t ret_value = SUCCEED; /* Return value */
+
+ FUNC_ENTER_NOAPI(H5G_link_obj_type, FAIL)
+
+ /* check arguments */
+ HDassert(file);
+ HDassert(lnk);
+
+ /* Check if we are able to retrieve the object's type */
+ if(obj_type) {
+ /* Look up the object type for each type of link */
+ switch(lnk->type) {
+ case H5L_TYPE_HARD:
+ {
+ H5O_loc_t tmp_oloc; /* Temporary object location */
+
+ /* Build temporary object location */
+ tmp_oloc.file = file;
+ tmp_oloc.addr = lnk->u.hard.addr;
+
+ /* Get the type of the object */
+ /* Note: no way to check for error :-( */
+ *obj_type = H5O_obj_type(&tmp_oloc, dxpl_id);
+ }
+ break;
+
+ case H5L_TYPE_SOFT:
+ /* Get the object's type */
+ *obj_type = H5G_LINK;
+ break;
+
+ default: /* User-defined link */
+ if(lnk->type < H5L_TYPE_UD_MIN)
+ HGOTO_ERROR(H5E_SYM, H5E_BADVALUE, FAIL, "unknown link type")
+
+ /* Get the object's type */
+ *obj_type = H5G_UDLINK;
+ } /* end switch */
+ } /* end if */
+
+done:
+ FUNC_LEAVE_NOAPI(ret_value)
+} /* end H5G_link_obj_type() */
+