summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--src/H5L.c39
-rw-r--r--src/H5VL.c38
-rw-r--r--src/H5VLnative.c46
-rw-r--r--src/H5VLprivate.h1
4 files changed, 116 insertions, 8 deletions
diff --git a/src/H5L.c b/src/H5L.c
index fd86258..095271b 100644
--- a/src/H5L.c
+++ b/src/H5L.c
@@ -592,21 +592,18 @@ done:
herr_t
H5Ldelete(hid_t loc_id, const char *name, hid_t lapl_id)
{
- H5G_loc_t loc; /* Group's location */
herr_t ret_value = SUCCEED; /* Return value */
FUNC_ENTER_API(FAIL)
H5TRACE3("e", "i*si", loc_id, name, lapl_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")
- /* Unlink */
- if(H5L_delete(&loc, name, lapl_id, H5AC_dxpl_id) < 0)
- HGOTO_ERROR(H5E_LINK, H5E_CANTDELETE, FAIL, "unable to delete link")
+ /* Delete the link through the VOL */
+ if((ret_value = H5VL_link_delete(loc_id, name, lapl_id)) < 0)
+ HGOTO_ERROR(H5E_SYM, H5E_CANTINIT, FAIL, "unable to create link")
done:
FUNC_LEAVE_API(ret_value)
@@ -667,7 +664,36 @@ H5Ldelete_by_idx(hid_t loc_id, const char *group_name,
/* Traverse the group hierarchy to remove the link */
if(H5G_traverse(&loc, group_name, H5G_TARGET_SLINK|H5G_TARGET_UDLINK|H5G_TARGET_MOUNT, H5L_delete_by_idx_cb, &udata, lapl_id, H5AC_dxpl_id) < 0)
HGOTO_ERROR(H5E_SYM, H5E_EXISTS, FAIL, "name doesn't exist")
+#if 0
+ H5L_trav_rmbi_t udata; /* User data for callback */
+ herr_t ret_value = SUCCEED; /* Return value */
+
+ FUNC_ENTER_API(FAIL)
+ H5TRACE6("e", "i*sIiIohi", loc_id, group_name, idx_type, order, n, lapl_id);
+
+ /* Check arguments */
+ if(!group_name || !*group_name)
+ HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "no name specified")
+ if(idx_type <= H5_INDEX_UNKNOWN || idx_type >= H5_INDEX_N)
+ HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "invalid index type specified")
+ if(order <= H5_ITER_UNKNOWN || order >= H5_ITER_N)
+ HGOTO_ERROR(H5E_ARGS, H5E_BADVALUE, FAIL, "invalid iteration order specified")
+ if(H5P_DEFAULT == lapl_id)
+ lapl_id = H5P_LINK_ACCESS_DEFAULT;
+ else
+ if(TRUE != H5P_isa_class(lapl_id, H5P_LINK_ACCESS))
+ HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not link access property list ID")
+
+ /* Set up user data for unlink operation */
+ udata.idx_type = idx_type;
+ udata.order = order;
+ udata.n = n;
+ udata.dxpl_id = H5AC_dxpl_id;
+ /* Delete the link through the VOL */
+ if((ret_value = H5VL_link_delete(loc_id, group_name, H5L_delete_by_idx_cb, &udata, lapl_id)) < 0)
+ HGOTO_ERROR(H5E_SYM, H5E_CANTINIT, FAIL, "unable to create link")
+#endif
done:
FUNC_LEAVE_API(ret_value)
} /* end H5Ldelete_by_idx() */
@@ -2381,6 +2407,7 @@ H5L_delete(H5G_loc_t *loc, const char *name, hid_t lapl_id, hid_t dxpl_id)
/* Set up user data for unlink operation */
udata.dxpl_id = dxpl_id;
+
if(H5G_traverse(loc, norm_name, H5G_TARGET_SLINK|H5G_TARGET_UDLINK|H5G_TARGET_MOUNT, H5L_delete_cb, &udata, lapl_id, dxpl_id) < 0)
HGOTO_ERROR(H5E_SYM, H5E_CANTREMOVE, FAIL, "can't unlink object")
diff --git a/src/H5VL.c b/src/H5VL.c
index 19125e9..293711f 100644
--- a/src/H5VL.c
+++ b/src/H5VL.c
@@ -1795,7 +1795,7 @@ done:
/*-------------------------------------------------------------------------
- * Function: H5VL_link_create
+ * Function: H5VL_link_move
*
* Purpose: Copy or move a link from src to dst.
*
@@ -1856,6 +1856,42 @@ done:
/*-------------------------------------------------------------------------
+ * Function: H5VL_link_delete
+ *
+ * Purpose: Copy or delete a link from src to dst.
+ *
+ * Return: Non-negative on success/Negative on failure
+ *
+ * Programmer: Mohamad Chaarawi
+ * April, 2012
+ *
+ *-------------------------------------------------------------------------
+ */
+H5_DLL herr_t H5VL_link_delete(hid_t loc_id, const char *name, hid_t lapl_id)
+{
+ H5VL_id_wrapper_t *id_wrapper;
+ herr_t ret_value = SUCCEED; /* Return value */
+
+ FUNC_ENTER_NOAPI(FAIL)
+
+ if(NULL == (id_wrapper = (H5VL_id_wrapper_t *)H5I_object(loc_id)))
+ HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "invalid user identifier")
+
+ /* check if the corresponding VOL delete callback exists */
+ if(NULL == id_wrapper->vol_plugin->link_cls.delete)
+ HGOTO_ERROR(H5E_VOL, H5E_UNSUPPORTED, FAIL, "vol plugin has no `link delete' method")
+
+ /* call the corresponding VOL delete callback */
+ if((ret_value = (id_wrapper->vol_plugin->link_cls.delete)
+ (id_wrapper->obj_id, name, lapl_id)) < 0)
+ HGOTO_ERROR(H5E_VOL, H5E_CANTINIT, FAIL, "link delete failed")
+
+done:
+ FUNC_LEAVE_NOAPI(ret_value)
+} /* end H5VL_link_delete() */
+
+
+/*-------------------------------------------------------------------------
* Function: H5VL_attr_create
*
* Purpose: Creates an attribute through the VOL
diff --git a/src/H5VLnative.c b/src/H5VLnative.c
index 366f771..a6d21ed7 100644
--- a/src/H5VLnative.c
+++ b/src/H5VLnative.c
@@ -99,6 +99,8 @@ static herr_t H5VL_native_link_create(H5VL_link_create_type_t create_type, hid_t
const char *link_name, hid_t lcpl_id, hid_t lapl_id);
static herr_t H5VL_native_link_move(hid_t src_loc_id, const char *src_name, hid_t dst_loc_id,
const char *dst_name, hbool_t copy_flag, hid_t lcpl_id, hid_t lapl_id);
+//static herr_t H5VL_native_link_delete(hid_t loc_id, char *name, H5G_traverse_t op, void *udata, hid_t lapl_id);
+static herr_t H5VL_native_link_delete(hid_t loc_id, const char *name, hid_t lapl_id);
static hid_t H5VL_native_object_open(hid_t loc_id, void *location, hid_t lapl_id);
static herr_t H5VL_native_object_get(hid_t id, H5VL_object_get_t get_type, va_list arguments);
@@ -149,7 +151,7 @@ H5VL_class_t H5VL_native_g = {
H5VL_native_link_create, /* create */
H5VL_native_link_move, /* move */
NULL, /* get */
- NULL /* delete */
+ H5VL_native_link_delete /* delete */
},
{ /* object_cls */
H5VL_native_object_open, /* open */
@@ -2039,6 +2041,48 @@ done:
/*-------------------------------------------------------------------------
+ * Function: H5VL_native_link_delete
+ *
+ * Purpose: Removes the specified NAME from the group graph and
+ * decrements the link count for the object to which NAME
+ * points. If the link count reaches zero then all file-space
+ * associated with the object will be reclaimed (but if the
+ * object is open, then the reclamation of the file space is
+ * delayed until all handles to the object are closed).
+ *
+ * Return: Non-negative on success/Negative on failure
+ *
+ * Programmer: Mohamad Chaarawi
+ * April, 2012
+ *
+ *-------------------------------------------------------------------------
+ */
+static herr_t
+H5VL_native_link_delete(hid_t loc_id, const char *name, hid_t lapl_id)
+{
+ H5G_loc_t loc; /* Object location */
+ herr_t ret_value = SUCCEED;
+
+ FUNC_ENTER_NOAPI_NOINIT
+
+ if(H5G_loc(loc_id, &loc) < 0)
+ HGOTO_ERROR(H5E_ARGS, H5E_BADTYPE, FAIL, "not a location")
+
+ /* Unlink */
+ if(H5L_delete(&loc, name, lapl_id, H5AC_dxpl_id) < 0)
+ HGOTO_ERROR(H5E_LINK, H5E_CANTDELETE, FAIL, "unable to delete link")
+
+ /* Traverse the group hierarchy to remove the link
+ if(H5G_traverse(&loc, name, H5G_TARGET_SLINK|H5G_TARGET_UDLINK|H5G_TARGET_MOUNT,
+ op, (H5L_trav_rm_t *)udata, lapl_id, H5AC_dxpl_id) < 0)
+ HGOTO_ERROR(H5E_SYM, H5E_EXISTS, FAIL, "name doesn't exist")
+ */
+done:
+ FUNC_LEAVE_NOAPI(ret_value)
+} /* end H5VL_native_link_delete() */
+
+
+/*-------------------------------------------------------------------------
* Function: H5VL_native_attr_create
*
* Purpose: Creates an attribute on an object.
diff --git a/src/H5VLprivate.h b/src/H5VLprivate.h
index e509b6c..fc5d7d5 100644
--- a/src/H5VLprivate.h
+++ b/src/H5VLprivate.h
@@ -89,6 +89,7 @@ H5_DLL herr_t H5VL_link_create(H5VL_link_create_type_t create_type, hid_t loc_id
const char *link_name, hid_t lcpl_id, hid_t lapl_id);
H5_DLL herr_t H5VL_link_move(hid_t src_loc_id, const char *src_name, hid_t dst_loc_id,
const char *dst_name, hbool_t copy_flag, hid_t lcpl_id, hid_t lapl_id);
+H5_DLL herr_t H5VL_link_delete(hid_t loc_id, const char *name, hid_t lapl_id);
H5_DLL hid_t H5VL_object_open_by_loc(hid_t uid, void *obj_loc, hid_t lapl_id);
H5_DLL herr_t H5VL_object_close(hid_t uid);