test
This commit is contained in:
@@ -0,0 +1,48 @@
|
||||
#include <zinnia/errno.h>
|
||||
#include <zinnia/handle.h>
|
||||
#include <zinnia/namespace.h>
|
||||
#include <zinnia/percpu.h>
|
||||
#include <zinnia/rights.h>
|
||||
#include <zinnia/syscalls.h>
|
||||
#include <zinnia/usercopy.h>
|
||||
|
||||
errno_t syscall_handle_clone(struct arch_context* ctx) {
|
||||
zn_handle_t handle = ctx->ARCH_CTX_A0;
|
||||
zn_rights_t cloned_rights = ctx->ARCH_CTX_A1;
|
||||
__user zn_handle_t* cloned = (__user zn_handle_t*)ctx->ARCH_CTX_A2;
|
||||
|
||||
struct task* current = percpu_get()->sched.current;
|
||||
struct namespace* ns = current->namespace;
|
||||
|
||||
struct namespace_desc desc;
|
||||
errno_t status = namespace_get(ns, handle, &desc);
|
||||
if (status != 0)
|
||||
return status;
|
||||
|
||||
zn_handle_t new_handle;
|
||||
status = namespace_clone_desc(ns, &desc, cloned_rights, &new_handle);
|
||||
if (status != 0)
|
||||
return status;
|
||||
|
||||
if (!usercopy_write(cloned, &new_handle, sizeof(new_handle))) {
|
||||
namespace_del_desc(ns, new_handle);
|
||||
return ZN_ERR_BAD_BUFFER;
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
errno_t syscall_handle_drop(struct arch_context* ctx) {
|
||||
zn_handle_t handle = ctx->ARCH_CTX_A0;
|
||||
struct task* current = percpu_get()->sched.current;
|
||||
|
||||
return namespace_del_desc(current->namespace, handle);
|
||||
}
|
||||
|
||||
errno_t syscall_handle_validate(struct arch_context* ctx) {
|
||||
zn_handle_t handle = ctx->ARCH_CTX_A0;
|
||||
struct task* current = percpu_get()->sched.current;
|
||||
|
||||
struct namespace_desc desc;
|
||||
return namespace_get(current->namespace, handle, &desc);
|
||||
}
|
||||
Reference in New Issue
Block a user