2023-06-20 15:03:33 -07:00
|
|
|
#include "syscall/capability.h"
|
|
|
|
|
2023-06-21 18:28:54 -07:00
|
|
|
#include <glacier/status/error.h>
|
|
|
|
|
2023-06-20 15:03:33 -07:00
|
|
|
#include "scheduler/scheduler.h"
|
|
|
|
|
|
|
|
z_err_t CapDuplicate(ZCapDuplicateReq* req) {
|
|
|
|
auto& proc = gScheduler->CurrentProcess();
|
|
|
|
auto cap = proc.GetCapability(req->cap_in);
|
|
|
|
if (!cap) {
|
2023-06-21 18:28:54 -07:00
|
|
|
return glcr::CAP_NOT_FOUND;
|
2023-06-20 15:03:33 -07:00
|
|
|
}
|
2023-08-01 18:30:24 -07:00
|
|
|
if (!(cap->permissions() & kZionPerm_Duplicate)) {
|
|
|
|
return glcr::CAP_PERMISSION_DENIED;
|
|
|
|
}
|
2023-06-20 15:03:33 -07:00
|
|
|
*req->cap_out = proc.AddExistingCapability(cap);
|
2023-06-21 18:28:54 -07:00
|
|
|
return glcr::OK;
|
2023-06-20 15:03:33 -07:00
|
|
|
}
|