Commit b4b196b0 authored by Josh Kunz's avatar Josh Kunz

Expose a few internal methods that take cnodes

parent 31189cfb
Pipeline #1362 passed with stage
......@@ -1271,6 +1271,18 @@ int cap_derive(struct cspace *cspacesrc, cptr_t c_src,
"cap_derive", __cap_try_derive);
}
int cap_derive_cnode(struct cnode * ca, struct cnode *cb,
void * callback_payload) {
int ret = 0;
while (! ret) {
ret = __cap_try_derive(ca, cb, NULL, callback_payload);
if (ret < 0) { return ret; }
}
return 0;
}
int cap_grant(struct cspace *cspacesrc, cptr_t c_src,
struct cspace *cspacedst, cptr_t c_dst,
void * callback_payload,
......@@ -1284,6 +1296,14 @@ void cap_delete(struct cspace *cspace, cptr_t c, void * callback_payload) {
__cap_cnode_unop(cspace, c, NULL, callback_payload, "cap_delete", __cap_try_delete);
}
void cap_delete_cnode(struct cnode * cnode, void * callback_payload) {
int ret = 0;
while (! ret) {
ret = __cap_try_delete(cnode, NULL, callback_payload);
if (ret < 0) { return; }
}
}
static bool __always_false(__attribute__((unused)) struct cnode *cnode) {
return false;
}
......@@ -1295,6 +1315,15 @@ int cap_revoke(struct cspace *cspace, cptr_t c, void * callback_payload) {
"cap_revoke", __cap_try_revoke);
}
int cap_revoke_cnode(struct cnode * cnode, void * callback_payload) {
int ret = 0;
while (! ret) {
ret = __cap_try_revoke(cnode, (void *) __always_false, callback_payload);
if (ret < 0) { return ret; }
}
return 0;
}
int cap_revoke_till(struct cspace *cspace, cptr_t c, cap_revoke_till_f func,
void * callback_payload) {
return __cap_cnode_unop(cspace, c,
......@@ -1302,6 +1331,16 @@ int cap_revoke_till(struct cspace *cspace, cptr_t c, cap_revoke_till_f func,
"cap_revoke_till", __cap_try_revoke);
}
int cap_revoke_till_cnode(struct cnode * cnode, cap_revoke_till_f func,
void * callback_payload) {
int ret = 0;
while (! ret) {
ret = __cap_try_revoke(cnode, (void *) func, callback_payload);
if (ret < 0) { return ret; }
}
return 0;
}
static void __cap_cnode_tear_down(struct cnode *cnode, struct cspace *cspace)
{
......
......@@ -377,6 +377,7 @@ struct cap_type_system* cap_cspace_get_type_system(struct cspace *cspace);
int cap_insert(struct cspace *cspace, cptr_t c,
void *object, cap_type_t type,
void *callback_payload);
/**
* cap_delete -- Deletes object data from cspace at cnode pointed at by c
* @cspace: the cspace to delete capability from
......@@ -394,6 +395,7 @@ int cap_insert(struct cspace *cspace, cptr_t c,
* delete callback for the capability's type will be invoked.
*/
void cap_delete(struct cspace *cspace, cptr_t c, void * callback_payload);
void cap_delete_cnode(struct cnode *cnode, void * callback_payload);
/**
* Add the cnode 'c_dest' in 'cspacedest' to the cnode 'c_src's CDT. This is
......@@ -403,6 +405,8 @@ void cap_delete(struct cspace *cspace, cptr_t c, void * callback_payload);
int cap_derive(struct cspace *cspacesrc, cptr_t c_src,
struct cspace *cspacedest, cptr_t c_dest,
void * callback_payload);
int cap_derive_cnode(struct cnode * ca, struct cnode *cb,
void * callback_payload);
/**
* cap_grant -- Grant capability from source to destination cspace
......@@ -441,6 +445,7 @@ int cap_grant(struct cspace *cspacesrc, cptr_t c_src,
* the metadata field will start out as NULL).
*/
int cap_revoke(struct cspace *cspace, cptr_t c, void * callback_payload);
int cap_revoke_cnode(struct cnode * cnode, void * callback_payload);
typedef bool (*cap_revoke_till_f)(struct cnode *);
......@@ -450,6 +455,8 @@ typedef bool (*cap_revoke_till_f)(struct cnode *);
* false is equivalent to calling `cap_revoke` */
int cap_revoke_till(struct cspace *cspace, cptr_t c, cap_revoke_till_f func,
void * callback_payload);
int cap_reovke_till_cnode(struct cnode * cnode, cap_revoke_till_f func,
void * callback_payload);
/**
* cap_cnode_get -- Return the cnode that this cptr points to in cspace
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment