acadia/zion/syscall/capability.cpp

19 lines
458 B
C++
Raw Normal View History

#include "syscall/capability.h"
2023-06-21 18:28:54 -07:00
#include <glacier/status/error.h>
#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;
}
if (!(cap->permissions() & kZionPerm_Duplicate)) {
return glcr::CAP_PERMISSION_DENIED;
}
*req->cap_out = proc.AddExistingCapability(cap);
2023-06-21 18:28:54 -07:00
return glcr::OK;
}