Spinlock save cpu flags
This commit is contained in:
@@ -31,18 +31,20 @@
|
||||
#define SYSRESULT(x) ((uintptr_t)(x))
|
||||
|
||||
static void* sys_get_user_buffer (struct proc* proc, uintptr_t uvaddr, size_t size) {
|
||||
uint64_t fpg;
|
||||
|
||||
struct limine_hhdm_response* hhdm = limine_hhdm_request.response;
|
||||
|
||||
spin_lock (&proc->procgroup->lock);
|
||||
spin_lock (&proc->procgroup->lock, &fpg);
|
||||
|
||||
if (!mm_validate_buffer (&proc->procgroup->pd, (uintptr_t)uvaddr, size)) {
|
||||
spin_unlock (&proc->procgroup->lock);
|
||||
spin_unlock (&proc->procgroup->lock, fpg);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
uintptr_t out_paddr = mm_v2p (&proc->procgroup->pd, uvaddr);
|
||||
|
||||
spin_unlock (&proc->procgroup->lock);
|
||||
spin_unlock (&proc->procgroup->lock, fpg);
|
||||
|
||||
uintptr_t out_kvaddr = (uintptr_t)hhdm->offset + out_paddr;
|
||||
|
||||
@@ -107,9 +109,11 @@ DEFINE_SYSCALL (sys_clone) {
|
||||
|
||||
/* void* argument_ptr (void) */
|
||||
DEFINE_SYSCALL (sys_argument_ptr) {
|
||||
spin_lock (&proc->lock);
|
||||
uint64_t fp;
|
||||
|
||||
spin_lock (&proc->lock, &fp);
|
||||
uintptr_t p = proc->uvaddr_argument;
|
||||
spin_unlock (&proc->lock);
|
||||
spin_unlock (&proc->lock, fp);
|
||||
|
||||
return p;
|
||||
}
|
||||
@@ -122,14 +126,16 @@ DEFINE_SYSCALL (sys_sched) {
|
||||
|
||||
/* int mutex_create (void) */
|
||||
DEFINE_SYSCALL (sys_mutex_create) {
|
||||
uint64_t fr;
|
||||
|
||||
struct proc_resource* mutex_resource = proc_create_resource_mutex (proc->procgroup);
|
||||
|
||||
if (mutex_resource == NULL)
|
||||
return SYSRESULT (-ST_OOM_ERROR);
|
||||
|
||||
spin_lock (&mutex_resource->lock);
|
||||
spin_lock (&mutex_resource->lock, &fr);
|
||||
int rid = mutex_resource->rid;
|
||||
spin_unlock (&mutex_resource->lock);
|
||||
spin_unlock (&mutex_resource->lock, fr);
|
||||
|
||||
return SYSRESULT (rid);
|
||||
}
|
||||
@@ -224,6 +230,8 @@ DEFINE_SYSCALL (sys_mail_receive) {
|
||||
|
||||
/* int device_do (int device_id, int cmd, void* a1, void* a2, void* a3, void* a4) */
|
||||
DEFINE_SYSCALL (sys_device_do) {
|
||||
uint64_t fpg, fd;
|
||||
|
||||
struct limine_hhdm_response* hhdm = limine_hhdm_request.response;
|
||||
|
||||
uintptr_t uvaddr_key = a1;
|
||||
@@ -237,12 +245,12 @@ DEFINE_SYSCALL (sys_device_do) {
|
||||
if (!(cmd >= 0 && cmd < (int)fieldlengthof (struct device, ops)))
|
||||
return SYSRESULT (-ST_BAD_DEVICE_OP);
|
||||
|
||||
spin_lock (&proc->procgroup->lock);
|
||||
spin_lock (&proc->procgroup->lock, &fpg);
|
||||
|
||||
out_paddr = mm_v2p (&proc->procgroup->pd, uvaddr_key);
|
||||
|
||||
if (out_paddr == 0) {
|
||||
spin_unlock (&proc->procgroup->lock);
|
||||
spin_unlock (&proc->procgroup->lock, fpg);
|
||||
return SYSRESULT (-ST_BAD_ADDRESS_SPACE);
|
||||
}
|
||||
|
||||
@@ -264,29 +272,31 @@ DEFINE_SYSCALL (sys_device_do) {
|
||||
if (out_paddr != 0)
|
||||
ka4 = (uintptr_t)hhdm->offset + out_paddr;
|
||||
|
||||
spin_unlock (&proc->procgroup->lock);
|
||||
spin_unlock (&proc->procgroup->lock, fpg);
|
||||
|
||||
struct device* device = device_find (key);
|
||||
|
||||
if (device == NULL)
|
||||
return SYSRESULT (-ST_NOT_FOUND);
|
||||
|
||||
spin_lock (&device->lock);
|
||||
spin_lock (&device->lock, &fd);
|
||||
|
||||
if (device->ops[cmd] == NULL) {
|
||||
spin_unlock (&device->lock);
|
||||
spin_unlock (&device->lock, fd);
|
||||
return SYSRESULT (-ST_NOT_FOUND);
|
||||
}
|
||||
|
||||
int ret = device_op (device, cmd, proc, rctx, ka1, ka2, ka3, ka4);
|
||||
|
||||
spin_unlock (&device->lock);
|
||||
spin_unlock (&device->lock, fd);
|
||||
|
||||
return SYSRESULT (ret);
|
||||
}
|
||||
|
||||
/* int exec (char* volume, char* path) */
|
||||
DEFINE_SYSCALL (sys_exec) {
|
||||
uint64_t fpg;
|
||||
|
||||
uintptr_t uvaddr_volume = a1;
|
||||
uintptr_t uvaddr_path = a2;
|
||||
|
||||
@@ -294,18 +304,18 @@ DEFINE_SYSCALL (sys_exec) {
|
||||
|
||||
uintptr_t out_paddr;
|
||||
|
||||
spin_lock (&proc->procgroup->lock);
|
||||
spin_lock (&proc->procgroup->lock, &fpg);
|
||||
out_paddr = mm_v2p (&proc->procgroup->pd, uvaddr_path);
|
||||
spin_unlock (&proc->procgroup->lock);
|
||||
spin_unlock (&proc->procgroup->lock, fpg);
|
||||
|
||||
if (out_paddr == 0)
|
||||
return SYSRESULT (-ST_BAD_ADDRESS_SPACE);
|
||||
|
||||
const char* path = (const char*)((uintptr_t)hhdm->offset + out_paddr);
|
||||
|
||||
spin_lock (&proc->procgroup->lock);
|
||||
spin_lock (&proc->procgroup->lock, &fpg);
|
||||
out_paddr = mm_v2p (&proc->procgroup->pd, uvaddr_volume);
|
||||
spin_unlock (&proc->procgroup->lock);
|
||||
spin_unlock (&proc->procgroup->lock, fpg);
|
||||
|
||||
if (out_paddr == 0)
|
||||
return SYSRESULT (-ST_BAD_ADDRESS_SPACE);
|
||||
@@ -327,15 +337,17 @@ DEFINE_SYSCALL (sys_exec) {
|
||||
|
||||
/* int volume_open (char* volume) */
|
||||
DEFINE_SYSCALL (sys_volume_open) {
|
||||
uint64_t fpg, fp;
|
||||
|
||||
uintptr_t uvaddr_volume = a1;
|
||||
|
||||
struct limine_hhdm_response* hhdm = limine_hhdm_request.response;
|
||||
|
||||
uintptr_t out_paddr;
|
||||
|
||||
spin_lock (&proc->procgroup->lock);
|
||||
spin_lock (&proc->procgroup->lock, &fpg);
|
||||
out_paddr = mm_v2p (&proc->procgroup->pd, uvaddr_volume);
|
||||
spin_unlock (&proc->procgroup->lock);
|
||||
spin_unlock (&proc->procgroup->lock, fpg);
|
||||
|
||||
if (out_paddr == 0)
|
||||
return SYSRESULT (-ST_BAD_ADDRESS_SPACE);
|
||||
@@ -347,26 +359,28 @@ DEFINE_SYSCALL (sys_volume_open) {
|
||||
if (ret < 0)
|
||||
return SYSRESULT (ret);
|
||||
|
||||
spin_lock (&proc->lock);
|
||||
spin_lock (&proc->lock, &fp);
|
||||
strncpy (proc->cwv, volume, VOLUME_MAX);
|
||||
spin_unlock (&proc->lock);
|
||||
spin_unlock (&proc->lock, fp);
|
||||
|
||||
return SYSRESULT (ST_OK);
|
||||
}
|
||||
|
||||
/* int volume_close (void) */
|
||||
DEFINE_SYSCALL (sys_volume_close) {
|
||||
uint64_t fp;
|
||||
|
||||
char cwv[VOLUME_MAX];
|
||||
spin_lock (&proc->lock);
|
||||
spin_lock (&proc->lock, &fp);
|
||||
memcpy (cwv, proc->cwv, sizeof (proc->cwv));
|
||||
spin_unlock (&proc->lock);
|
||||
spin_unlock (&proc->lock, fp);
|
||||
|
||||
int ret = vfs_volume_close (proc, cwv, rctx);
|
||||
|
||||
if (ret == ST_OK) {
|
||||
spin_lock (&proc->lock);
|
||||
spin_lock (&proc->lock, &fp);
|
||||
memset (proc->cwv, 0, sizeof (proc->cwv));
|
||||
spin_unlock (&proc->lock);
|
||||
spin_unlock (&proc->lock, fp);
|
||||
}
|
||||
|
||||
return SYSRESULT (ret);
|
||||
@@ -374,6 +388,8 @@ DEFINE_SYSCALL (sys_volume_close) {
|
||||
|
||||
/* int read_file (char* path, size_t off, uint8_t* buffer, size_t size) */
|
||||
DEFINE_SYSCALL (sys_read_file) {
|
||||
uint64_t fpg, fp;
|
||||
|
||||
uintptr_t uvaddr_path = a1;
|
||||
size_t off = (size_t)a2;
|
||||
uintptr_t uvaddr_buffer = a3;
|
||||
@@ -383,9 +399,9 @@ DEFINE_SYSCALL (sys_read_file) {
|
||||
|
||||
uintptr_t out_paddr;
|
||||
|
||||
spin_lock (&proc->procgroup->lock);
|
||||
spin_lock (&proc->procgroup->lock, &fpg);
|
||||
out_paddr = mm_v2p (&proc->procgroup->pd, uvaddr_path);
|
||||
spin_unlock (&proc->procgroup->lock);
|
||||
spin_unlock (&proc->procgroup->lock, fpg);
|
||||
|
||||
if (out_paddr == 0)
|
||||
return SYSRESULT (-ST_BAD_ADDRESS_SPACE);
|
||||
@@ -398,9 +414,9 @@ DEFINE_SYSCALL (sys_read_file) {
|
||||
return SYSRESULT (-ST_BAD_ADDRESS_SPACE);
|
||||
|
||||
char cwv[VOLUME_MAX];
|
||||
spin_lock (&proc->lock);
|
||||
spin_lock (&proc->lock, &fp);
|
||||
memcpy (cwv, proc->cwv, sizeof (proc->cwv));
|
||||
spin_unlock (&proc->lock);
|
||||
spin_unlock (&proc->lock, fp);
|
||||
|
||||
int ret = vfs_read_file (proc, rctx, cwv, path, buffer, off, size);
|
||||
|
||||
@@ -409,6 +425,8 @@ DEFINE_SYSCALL (sys_read_file) {
|
||||
|
||||
/* int describe (char* path, struct desc* desc) */
|
||||
DEFINE_SYSCALL (sys_describe) {
|
||||
uint64_t fpg, fp;
|
||||
|
||||
uintptr_t uvaddr_path = a1;
|
||||
uintptr_t uvaddr_desc = a2;
|
||||
|
||||
@@ -416,9 +434,9 @@ DEFINE_SYSCALL (sys_describe) {
|
||||
|
||||
uintptr_t out_paddr;
|
||||
|
||||
spin_lock (&proc->procgroup->lock);
|
||||
spin_lock (&proc->procgroup->lock, &fpg);
|
||||
out_paddr = mm_v2p (&proc->procgroup->pd, uvaddr_path);
|
||||
spin_unlock (&proc->procgroup->lock);
|
||||
spin_unlock (&proc->procgroup->lock, fpg);
|
||||
|
||||
if (out_paddr == 0)
|
||||
return SYSRESULT (-ST_BAD_ADDRESS_SPACE);
|
||||
@@ -429,11 +447,11 @@ DEFINE_SYSCALL (sys_describe) {
|
||||
|
||||
if (desc == NULL)
|
||||
return SYSRESULT (-ST_BAD_ADDRESS_SPACE);
|
||||
|
||||
|
||||
char cwv[VOLUME_MAX];
|
||||
spin_lock (&proc->lock);
|
||||
spin_lock (&proc->lock, &fp);
|
||||
memcpy (cwv, proc->cwv, sizeof (proc->cwv));
|
||||
spin_unlock (&proc->lock);
|
||||
spin_unlock (&proc->lock, fp);
|
||||
|
||||
int ret = vfs_describe (proc, rctx, cwv, path, desc);
|
||||
|
||||
@@ -442,6 +460,8 @@ DEFINE_SYSCALL (sys_describe) {
|
||||
|
||||
/* int get_procgroup (int pid) */
|
||||
DEFINE_SYSCALL (sys_get_procgroup) {
|
||||
uint64_t fp;
|
||||
|
||||
int pid = (int)a1;
|
||||
|
||||
struct proc* target_proc = proc_find_pid (pid);
|
||||
@@ -449,22 +469,24 @@ DEFINE_SYSCALL (sys_get_procgroup) {
|
||||
if (target_proc == NULL)
|
||||
return SYSRESULT (-ST_NOT_FOUND);
|
||||
|
||||
spin_lock (&target_proc->lock);
|
||||
spin_lock (&target_proc->lock, &fp);
|
||||
|
||||
if (target_proc->state == PROC_DEAD) {
|
||||
spin_unlock (&target_proc->lock);
|
||||
spin_unlock (&target_proc->lock, fp);
|
||||
return SYSRESULT (-ST_NOT_FOUND);
|
||||
}
|
||||
|
||||
int pgid = target_proc->procgroup->pgid;
|
||||
|
||||
spin_unlock (&target_proc->lock);
|
||||
spin_unlock (&target_proc->lock, fp);
|
||||
|
||||
return SYSRESULT (pgid);
|
||||
}
|
||||
|
||||
/* int read_dir_entry (char* path, struct dir_entry* entry, size_t entry_num) */
|
||||
DEFINE_SYSCALL (sys_read_dir_entry) {
|
||||
uint64_t fpg, fp;
|
||||
|
||||
uintptr_t uvaddr_path = a1;
|
||||
uintptr_t uvaddr_entry = a2;
|
||||
size_t entry_num = (size_t)a3;
|
||||
@@ -473,9 +495,9 @@ DEFINE_SYSCALL (sys_read_dir_entry) {
|
||||
|
||||
uintptr_t out_paddr;
|
||||
|
||||
spin_lock (&proc->procgroup->lock);
|
||||
spin_lock (&proc->procgroup->lock, &fpg);
|
||||
out_paddr = mm_v2p (&proc->procgroup->pd, uvaddr_path);
|
||||
spin_unlock (&proc->procgroup->lock);
|
||||
spin_unlock (&proc->procgroup->lock, fpg);
|
||||
|
||||
if (out_paddr == 0)
|
||||
return SYSRESULT (-ST_BAD_ADDRESS_SPACE);
|
||||
@@ -486,11 +508,11 @@ DEFINE_SYSCALL (sys_read_dir_entry) {
|
||||
|
||||
if (entry == NULL)
|
||||
return SYSRESULT (-ST_BAD_ADDRESS_SPACE);
|
||||
|
||||
|
||||
char cwv[VOLUME_MAX];
|
||||
spin_lock (&proc->lock);
|
||||
spin_lock (&proc->lock, &fp);
|
||||
memcpy (cwv, proc->cwv, sizeof (proc->cwv));
|
||||
spin_unlock (&proc->lock);
|
||||
spin_unlock (&proc->lock, fp);
|
||||
|
||||
int ret = vfs_read_dir_entry (proc, rctx, cwv, path, entry, entry_num);
|
||||
|
||||
@@ -499,25 +521,27 @@ DEFINE_SYSCALL (sys_read_dir_entry) {
|
||||
|
||||
/* int create_file (char* path) */
|
||||
DEFINE_SYSCALL (sys_create_file) {
|
||||
uint64_t fpg, fp;
|
||||
|
||||
uintptr_t uvaddr_path = a1;
|
||||
|
||||
struct limine_hhdm_response* hhdm = limine_hhdm_request.response;
|
||||
|
||||
uintptr_t out_paddr;
|
||||
|
||||
spin_lock (&proc->procgroup->lock);
|
||||
spin_lock (&proc->procgroup->lock, &fpg);
|
||||
out_paddr = mm_v2p (&proc->procgroup->pd, uvaddr_path);
|
||||
spin_unlock (&proc->procgroup->lock);
|
||||
spin_unlock (&proc->procgroup->lock, fpg);
|
||||
|
||||
if (out_paddr == 0)
|
||||
return SYSRESULT (-ST_BAD_ADDRESS_SPACE);
|
||||
|
||||
const char* path = (const char*)((uintptr_t)hhdm->offset + out_paddr);
|
||||
|
||||
|
||||
char cwv[VOLUME_MAX];
|
||||
spin_lock (&proc->lock);
|
||||
spin_lock (&proc->lock, &fp);
|
||||
memcpy (cwv, proc->cwv, sizeof (proc->cwv));
|
||||
spin_unlock (&proc->lock);
|
||||
spin_unlock (&proc->lock, fp);
|
||||
|
||||
int ret = vfs_create_file (proc, rctx, cwv, path);
|
||||
|
||||
@@ -526,6 +550,8 @@ DEFINE_SYSCALL (sys_create_file) {
|
||||
|
||||
/* int write_file (char* path, size_t off, uint8_t* buffer, size_t size, uint32_t flags) */
|
||||
DEFINE_SYSCALL (sys_write_file) {
|
||||
uint64_t fpg, fp;
|
||||
|
||||
uintptr_t uvaddr_path = a1;
|
||||
size_t off = (size_t)a2;
|
||||
uintptr_t uvaddr_buffer = a3;
|
||||
@@ -536,9 +562,9 @@ DEFINE_SYSCALL (sys_write_file) {
|
||||
|
||||
uintptr_t out_paddr;
|
||||
|
||||
spin_lock (&proc->procgroup->lock);
|
||||
spin_lock (&proc->procgroup->lock, &fpg);
|
||||
out_paddr = mm_v2p (&proc->procgroup->pd, uvaddr_path);
|
||||
spin_unlock (&proc->procgroup->lock);
|
||||
spin_unlock (&proc->procgroup->lock, fpg);
|
||||
|
||||
if (out_paddr == 0)
|
||||
return SYSRESULT (-ST_BAD_ADDRESS_SPACE);
|
||||
@@ -549,11 +575,11 @@ DEFINE_SYSCALL (sys_write_file) {
|
||||
|
||||
if (buffer == NULL)
|
||||
return SYSRESULT (-ST_BAD_ADDRESS_SPACE);
|
||||
|
||||
|
||||
char cwv[VOLUME_MAX];
|
||||
spin_lock (&proc->lock);
|
||||
spin_lock (&proc->lock, &fp);
|
||||
memcpy (cwv, proc->cwv, sizeof (proc->cwv));
|
||||
spin_unlock (&proc->lock);
|
||||
spin_unlock (&proc->lock, fp);
|
||||
|
||||
int ret = vfs_write_file (proc, rctx, cwv, path, buffer, off, size, flags);
|
||||
|
||||
@@ -562,15 +588,19 @@ DEFINE_SYSCALL (sys_write_file) {
|
||||
|
||||
/* int get_exec_pid (void) */
|
||||
DEFINE_SYSCALL (sys_get_exec_pid) {
|
||||
spin_lock (&proc->lock);
|
||||
uint64_t fp;
|
||||
|
||||
spin_lock (&proc->lock, &fp);
|
||||
int exec_pid = proc->exec_pid;
|
||||
spin_unlock (&proc->lock);
|
||||
spin_unlock (&proc->lock, fp);
|
||||
|
||||
return SYSRESULT (exec_pid);
|
||||
}
|
||||
|
||||
/* wait_for_pid (int pid) */
|
||||
DEFINE_SYSCALL (sys_wait_for_pid) {
|
||||
uint64_t fp;
|
||||
|
||||
int pid = (int)a1;
|
||||
|
||||
struct proc* wait_proc = proc_find_pid (pid);
|
||||
@@ -578,14 +608,14 @@ DEFINE_SYSCALL (sys_wait_for_pid) {
|
||||
if (wait_proc == NULL)
|
||||
return SYSRESULT (-ST_NOT_FOUND);
|
||||
|
||||
spin_lock (&wait_proc->lock);
|
||||
spin_lock (&wait_proc->lock, &fp);
|
||||
|
||||
if (wait_proc->state == PROC_DEAD) {
|
||||
spin_unlock (&wait_proc->lock);
|
||||
spin_unlock (&wait_proc->lock, fp);
|
||||
return SYSRESULT (-ST_NOT_FOUND);
|
||||
}
|
||||
|
||||
spin_unlock (&wait_proc->lock);
|
||||
spin_unlock (&wait_proc->lock, fp);
|
||||
|
||||
proc_wait_for (proc, rctx, wait_proc);
|
||||
|
||||
@@ -595,6 +625,8 @@ DEFINE_SYSCALL (sys_wait_for_pid) {
|
||||
/* int kill (int pid) */
|
||||
|
||||
DEFINE_SYSCALL (sys_kill) {
|
||||
uint64_t fp;
|
||||
|
||||
int pid = (int)a1;
|
||||
|
||||
struct proc* target_proc = proc_find_pid (pid);
|
||||
@@ -602,14 +634,14 @@ DEFINE_SYSCALL (sys_kill) {
|
||||
if (target_proc == NULL)
|
||||
return SYSRESULT (-ST_NOT_FOUND);
|
||||
|
||||
spin_lock (&target_proc->lock);
|
||||
spin_lock (&target_proc->lock, &fp);
|
||||
|
||||
if (target_proc->state == PROC_DEAD) {
|
||||
spin_unlock (&target_proc->lock);
|
||||
spin_unlock (&target_proc->lock, fp);
|
||||
return SYSRESULT (-ST_NOT_FOUND);
|
||||
}
|
||||
|
||||
spin_unlock (&target_proc->lock);
|
||||
spin_unlock (&target_proc->lock, fp);
|
||||
|
||||
proc_kill (target_proc, rctx);
|
||||
|
||||
@@ -618,25 +650,27 @@ DEFINE_SYSCALL (sys_kill) {
|
||||
|
||||
/* int create_dir (char* path) */
|
||||
DEFINE_SYSCALL (sys_create_dir) {
|
||||
uint64_t fpg, fp;
|
||||
|
||||
uintptr_t uvaddr_path = a1;
|
||||
|
||||
struct limine_hhdm_response* hhdm = limine_hhdm_request.response;
|
||||
|
||||
uintptr_t out_paddr;
|
||||
|
||||
spin_lock (&proc->procgroup->lock);
|
||||
spin_lock (&proc->procgroup->lock, &fpg);
|
||||
out_paddr = mm_v2p (&proc->procgroup->pd, uvaddr_path);
|
||||
spin_unlock (&proc->procgroup->lock);
|
||||
spin_unlock (&proc->procgroup->lock, fpg);
|
||||
|
||||
if (out_paddr == 0)
|
||||
return SYSRESULT (-ST_BAD_ADDRESS_SPACE);
|
||||
|
||||
const char* path = (const char*)((uintptr_t)hhdm->offset + out_paddr);
|
||||
|
||||
|
||||
char cwv[VOLUME_MAX];
|
||||
spin_lock (&proc->lock);
|
||||
spin_lock (&proc->lock, &fp);
|
||||
memcpy (cwv, proc->cwv, sizeof (proc->cwv));
|
||||
spin_unlock (&proc->lock);
|
||||
spin_unlock (&proc->lock, fp);
|
||||
|
||||
int ret = vfs_create_dir (proc, rctx, cwv, path);
|
||||
|
||||
@@ -645,25 +679,27 @@ DEFINE_SYSCALL (sys_create_dir) {
|
||||
|
||||
/* int remove (char* path) */
|
||||
DEFINE_SYSCALL (sys_remove) {
|
||||
uint64_t fpg, fp;
|
||||
|
||||
uintptr_t uvaddr_path = a1;
|
||||
|
||||
struct limine_hhdm_response* hhdm = limine_hhdm_request.response;
|
||||
|
||||
uintptr_t out_paddr;
|
||||
|
||||
spin_lock (&proc->procgroup->lock);
|
||||
spin_lock (&proc->procgroup->lock, &fpg);
|
||||
out_paddr = mm_v2p (&proc->procgroup->pd, uvaddr_path);
|
||||
spin_unlock (&proc->procgroup->lock);
|
||||
spin_unlock (&proc->procgroup->lock, fpg);
|
||||
|
||||
if (out_paddr == 0)
|
||||
return SYSRESULT (-ST_BAD_ADDRESS_SPACE);
|
||||
|
||||
const char* path = (const char*)((uintptr_t)hhdm->offset + out_paddr);
|
||||
|
||||
|
||||
char cwv[VOLUME_MAX];
|
||||
spin_lock (&proc->lock);
|
||||
spin_lock (&proc->lock, &fp);
|
||||
memcpy (cwv, proc->cwv, sizeof (proc->cwv));
|
||||
spin_unlock (&proc->lock);
|
||||
spin_unlock (&proc->lock, fp);
|
||||
|
||||
int ret = vfs_remove (proc, rctx, cwv, path);
|
||||
|
||||
@@ -672,6 +708,8 @@ DEFINE_SYSCALL (sys_remove) {
|
||||
|
||||
/* int create_volume (char* key, int fs_type, char* device_key) */
|
||||
DEFINE_SYSCALL (sys_create_volume) {
|
||||
uint64_t fpg;
|
||||
|
||||
uintptr_t uvaddr_key = a1;
|
||||
int type = (int)a2;
|
||||
uintptr_t uvaddr_device_key = a3;
|
||||
@@ -680,12 +718,12 @@ DEFINE_SYSCALL (sys_create_volume) {
|
||||
|
||||
uintptr_t out_paddr;
|
||||
|
||||
spin_lock (&proc->procgroup->lock);
|
||||
spin_lock (&proc->procgroup->lock, &fpg);
|
||||
|
||||
out_paddr = mm_v2p (&proc->procgroup->pd, uvaddr_key);
|
||||
|
||||
if (out_paddr == 0) {
|
||||
spin_unlock (&proc->procgroup->lock);
|
||||
spin_unlock (&proc->procgroup->lock, fpg);
|
||||
return SYSRESULT (-ST_BAD_ADDRESS_SPACE);
|
||||
}
|
||||
|
||||
@@ -694,13 +732,13 @@ DEFINE_SYSCALL (sys_create_volume) {
|
||||
out_paddr = mm_v2p (&proc->procgroup->pd, uvaddr_device_key);
|
||||
|
||||
if (out_paddr == 0) {
|
||||
spin_unlock (&proc->procgroup->lock);
|
||||
spin_unlock (&proc->procgroup->lock, fpg);
|
||||
return SYSRESULT (-ST_BAD_ADDRESS_SPACE);
|
||||
}
|
||||
|
||||
const char* device_key = (const char*)((uintptr_t)hhdm->offset + out_paddr);
|
||||
|
||||
spin_unlock (&proc->procgroup->lock);
|
||||
spin_unlock (&proc->procgroup->lock, fpg);
|
||||
|
||||
struct device* device = device_find (device_key);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user