Use implicitly passed _caller_pid in syscalls
This commit is contained in:
@ -15,7 +15,8 @@ int32_t SYSCALL2(sys_dev_gethandle, dev1, devname1) {
|
|||||||
int32_t ret = E_OK;
|
int32_t ret = E_OK;
|
||||||
|
|
||||||
spinlock_acquire(&PROCS.spinlock);
|
spinlock_acquire(&PROCS.spinlock);
|
||||||
Proc *proc = PROCS.current;
|
Proc *proc = NULL;
|
||||||
|
LL_FINDPROP(PROCS.procs, proc, pid, _caller_pid);
|
||||||
spinlock_release(&PROCS.spinlock);
|
spinlock_release(&PROCS.spinlock);
|
||||||
|
|
||||||
char *ident = (char *)devname1;
|
char *ident = (char *)devname1;
|
||||||
@ -108,7 +109,8 @@ int32_t SYSCALL4(sys_dev_cmd, dev1, cmd1, argbuf1, len1) {
|
|||||||
int32_t ret = E_OK;
|
int32_t ret = E_OK;
|
||||||
|
|
||||||
spinlock_acquire(&PROCS.spinlock);
|
spinlock_acquire(&PROCS.spinlock);
|
||||||
Proc *proc = PROCS.current;
|
Proc *proc = NULL;
|
||||||
|
LL_FINDPROP(PROCS.procs, proc, pid, _caller_pid);
|
||||||
spinlock_release(&PROCS.spinlock);
|
spinlock_release(&PROCS.spinlock);
|
||||||
|
|
||||||
if (devh == NULL) {
|
if (devh == NULL) {
|
||||||
|
|||||||
@ -8,6 +8,7 @@
|
|||||||
#include "kprintf.h"
|
#include "kprintf.h"
|
||||||
#include "proc/proc.h"
|
#include "proc/proc.h"
|
||||||
#include "spinlock/spinlock.h"
|
#include "spinlock/spinlock.h"
|
||||||
|
#include "util/util.h"
|
||||||
|
|
||||||
#define _MP_MAX 0xff
|
#define _MP_MAX 0xff
|
||||||
#define _PATH_MAX VFS_PATH_MAX
|
#define _PATH_MAX VFS_PATH_MAX
|
||||||
@ -35,7 +36,8 @@ int32_t SYSCALL2(sys_fs_openf, opath1, oflags1) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
spinlock_acquire(&PROCS.spinlock);
|
spinlock_acquire(&PROCS.spinlock);
|
||||||
Proc *proc = PROCS.current;
|
Proc *proc = NULL;
|
||||||
|
LL_FINDPROP(PROCS.procs, proc, pid, _caller_pid);
|
||||||
spinlock_release(&PROCS.spinlock);
|
spinlock_release(&PROCS.spinlock);
|
||||||
|
|
||||||
for (size_t i = 0; i < PROC_VFSHANDLES_MAX; i++) {
|
for (size_t i = 0; i < PROC_VFSHANDLES_MAX; i++) {
|
||||||
@ -62,7 +64,8 @@ int32_t SYSCALL1(sys_fs_closef, fsh1) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
spinlock_acquire(&PROCS.spinlock);
|
spinlock_acquire(&PROCS.spinlock);
|
||||||
Proc *proc = PROCS.current;
|
Proc *proc = NULL;
|
||||||
|
LL_FINDPROP(PROCS.procs, proc, pid, _caller_pid);
|
||||||
spinlock_release(&PROCS.spinlock);
|
spinlock_release(&PROCS.spinlock);
|
||||||
|
|
||||||
VfsObj *vobj = proc->vobjs[fsh];
|
VfsObj *vobj = proc->vobjs[fsh];
|
||||||
@ -99,7 +102,8 @@ int32_t SYSCALL4(sys_fs_write, fsh1, buffer1, len1, off1) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
spinlock_acquire(&PROCS.spinlock);
|
spinlock_acquire(&PROCS.spinlock);
|
||||||
Proc *proc = PROCS.current;
|
Proc *proc = NULL;
|
||||||
|
LL_FINDPROP(PROCS.procs, proc, pid, _caller_pid);
|
||||||
spinlock_release(&PROCS.spinlock);
|
spinlock_release(&PROCS.spinlock);
|
||||||
|
|
||||||
VfsObj *vobj = proc->vobjs[fsh];
|
VfsObj *vobj = proc->vobjs[fsh];
|
||||||
@ -134,7 +138,8 @@ int32_t SYSCALL4(sys_fs_read, fsh1, buffer1, len1, off1) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
spinlock_acquire(&PROCS.spinlock);
|
spinlock_acquire(&PROCS.spinlock);
|
||||||
Proc *proc = PROCS.current;
|
Proc *proc = NULL;
|
||||||
|
LL_FINDPROP(PROCS.procs, proc, pid, _caller_pid);
|
||||||
spinlock_release(&PROCS.spinlock);
|
spinlock_release(&PROCS.spinlock);
|
||||||
|
|
||||||
VfsObj *vobj = proc->vobjs[fsh];
|
VfsObj *vobj = proc->vobjs[fsh];
|
||||||
|
|||||||
@ -15,9 +15,7 @@ int32_t SYSCALL4(sys_ipc_piperead, pid1, pipenum1, buffer1, len1) {
|
|||||||
int32_t ret = E_OK;
|
int32_t ret = E_OK;
|
||||||
|
|
||||||
if (pid == (uint64_t)-1) {
|
if (pid == (uint64_t)-1) {
|
||||||
spinlock_acquire(&PROCS.spinlock);
|
pid = _caller_pid;
|
||||||
pid = PROCS.current->pid;
|
|
||||||
spinlock_release(&PROCS.spinlock);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
spinlock_acquire(&PROCS.spinlock);
|
spinlock_acquire(&PROCS.spinlock);
|
||||||
@ -61,9 +59,7 @@ int32_t SYSCALL4(sys_ipc_pipewrite, pid1, pipenum1, buffer1, len1) {
|
|||||||
int32_t ret = E_OK;
|
int32_t ret = E_OK;
|
||||||
|
|
||||||
if (pid == (uint64_t)-1) {
|
if (pid == (uint64_t)-1) {
|
||||||
spinlock_acquire(&PROCS.spinlock);
|
pid = _caller_pid;
|
||||||
pid = PROCS.current->pid;
|
|
||||||
spinlock_release(&PROCS.spinlock);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
spinlock_acquire(&PROCS.spinlock);
|
spinlock_acquire(&PROCS.spinlock);
|
||||||
@ -106,7 +102,8 @@ int32_t SYSCALL1(sys_ipc_pipemake, pipenum1) {
|
|||||||
int32_t ret = E_OK;
|
int32_t ret = E_OK;
|
||||||
|
|
||||||
spinlock_acquire(&PROCS.spinlock);
|
spinlock_acquire(&PROCS.spinlock);
|
||||||
Proc *proc = PROCS.current;
|
Proc *proc = NULL;
|
||||||
|
LL_FINDPROP(PROCS.procs, proc, pid, _caller_pid);
|
||||||
spinlock_release(&PROCS.spinlock);
|
spinlock_release(&PROCS.spinlock);
|
||||||
|
|
||||||
if (pipenum >= PROC_PIPEHANDLES_MAX) {
|
if (pipenum >= PROC_PIPEHANDLES_MAX) {
|
||||||
@ -147,7 +144,8 @@ int32_t SYSCALL1(sys_ipc_pipedelete, pipenum1) {
|
|||||||
int32_t ret = E_OK;
|
int32_t ret = E_OK;
|
||||||
|
|
||||||
spinlock_acquire(&PROCS.spinlock);
|
spinlock_acquire(&PROCS.spinlock);
|
||||||
Proc *proc = PROCS.current;
|
Proc *proc = NULL;
|
||||||
|
LL_FINDPROP(PROCS.procs, proc, pid, _caller_pid);
|
||||||
spinlock_release(&PROCS.spinlock);
|
spinlock_release(&PROCS.spinlock);
|
||||||
|
|
||||||
if (pipenum >= PROC_PIPEHANDLES_MAX) {
|
if (pipenum >= PROC_PIPEHANDLES_MAX) {
|
||||||
@ -174,9 +172,7 @@ int32_t SYSCALL4(sys_ipc_pipeconnect, pid1, pipenum1, pid2, pipenum2) {
|
|||||||
int32_t ret = E_OK;
|
int32_t ret = E_OK;
|
||||||
|
|
||||||
if (pid == (uint64_t)-1) {
|
if (pid == (uint64_t)-1) {
|
||||||
spinlock_acquire(&PROCS.spinlock);
|
pid = _caller_pid;
|
||||||
pid = PROCS.current->pid;
|
|
||||||
spinlock_release(&PROCS.spinlock);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
spinlock_acquire(&PROCS.spinlock);
|
spinlock_acquire(&PROCS.spinlock);
|
||||||
|
|||||||
@ -31,7 +31,8 @@ int32_t SYSCALL5(sys_mman_map, addr1, size1, prot1, flags1, out1) {
|
|||||||
hal_memset(VIRT(phys), 0, pages * HAL_PAGE_SIZE);
|
hal_memset(VIRT(phys), 0, pages * HAL_PAGE_SIZE);
|
||||||
|
|
||||||
spinlock_acquire(&PROCS.spinlock);
|
spinlock_acquire(&PROCS.spinlock);
|
||||||
Proc *proc = PROCS.current;
|
Proc *proc = NULL;
|
||||||
|
LL_FINDPROP(PROCS.procs, proc, pid, _caller_pid);
|
||||||
spinlock_release(&PROCS.spinlock);
|
spinlock_release(&PROCS.spinlock);
|
||||||
|
|
||||||
uint8_t *virt = NULL;
|
uint8_t *virt = NULL;
|
||||||
@ -78,7 +79,8 @@ int32_t SYSCALL1(sys_mman_unmap, addr1) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
spinlock_acquire(&PROCS.spinlock);
|
spinlock_acquire(&PROCS.spinlock);
|
||||||
Proc *proc = PROCS.current;
|
Proc *proc = NULL;
|
||||||
|
LL_FINDPROP(PROCS.procs, proc, pid, _caller_pid);
|
||||||
spinlock_release(&PROCS.spinlock);
|
spinlock_release(&PROCS.spinlock);
|
||||||
|
|
||||||
VasRange *tofree = NULL;
|
VasRange *tofree = NULL;
|
||||||
|
|||||||
@ -20,7 +20,7 @@ int32_t SYSCALL1(sys_proc_kill, pid1) {
|
|||||||
int32_t ret = E_OK;
|
int32_t ret = E_OK;
|
||||||
|
|
||||||
if (pid == (uint64_t)-1) {
|
if (pid == (uint64_t)-1) {
|
||||||
pid = PROCS.current->pid;
|
pid = _caller_pid;
|
||||||
}
|
}
|
||||||
|
|
||||||
spinlock_acquire(&PROCS.spinlock);
|
spinlock_acquire(&PROCS.spinlock);
|
||||||
@ -38,7 +38,8 @@ int32_t SYSCALL3(sys_proc_spawn, opath1, args1, argslen1) {
|
|||||||
int32_t ret = E_OK;
|
int32_t ret = E_OK;
|
||||||
|
|
||||||
spinlock_acquire(&PROCS.spinlock);
|
spinlock_acquire(&PROCS.spinlock);
|
||||||
Proc *proc = PROCS.current;
|
Proc *proc = NULL;
|
||||||
|
LL_FINDPROP(PROCS.procs, proc, pid, _caller_pid);
|
||||||
spinlock_release(&PROCS.spinlock);
|
spinlock_release(&PROCS.spinlock);
|
||||||
|
|
||||||
const char *opath = (const char *)opath1;
|
const char *opath = (const char *)opath1;
|
||||||
@ -87,7 +88,7 @@ int32_t SYSCALL1(sys_proc_pollstate, pid1) {
|
|||||||
int32_t ret = E_OK;
|
int32_t ret = E_OK;
|
||||||
|
|
||||||
if (pid == (uint64_t)-1) {
|
if (pid == (uint64_t)-1) {
|
||||||
pid = PROCS.current->pid;
|
pid = _caller_pid;
|
||||||
}
|
}
|
||||||
|
|
||||||
spinlock_acquire(&PROCS.spinlock);
|
spinlock_acquire(&PROCS.spinlock);
|
||||||
@ -107,15 +108,7 @@ done:
|
|||||||
}
|
}
|
||||||
|
|
||||||
int32_t SYSCALL0(sys_proc_getpid) {
|
int32_t SYSCALL0(sys_proc_getpid) {
|
||||||
int32_t ret = E_OK;
|
return _caller_pid;
|
||||||
|
|
||||||
spinlock_acquire(&PROCS.spinlock);
|
|
||||||
Proc *proc = PROCS.current;
|
|
||||||
spinlock_release(&PROCS.spinlock);
|
|
||||||
|
|
||||||
ret = proc->pid;
|
|
||||||
|
|
||||||
return ret;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
int32_t SYSCALL1(sys_proc_run, pid1) {
|
int32_t SYSCALL1(sys_proc_run, pid1) {
|
||||||
@ -143,7 +136,7 @@ int32_t SYSCALL1(sys_proc_arglen, pid1) {
|
|||||||
int32_t ret = E_OK;
|
int32_t ret = E_OK;
|
||||||
|
|
||||||
if (pid == (uint64_t)-1) {
|
if (pid == (uint64_t)-1) {
|
||||||
pid = PROCS.current->pid;
|
pid = _caller_pid;
|
||||||
}
|
}
|
||||||
|
|
||||||
spinlock_acquire(&PROCS.spinlock);
|
spinlock_acquire(&PROCS.spinlock);
|
||||||
@ -160,7 +153,7 @@ int32_t SYSCALL4(sys_proc_argv, pid1, argslen1, argbuf1, maxargs1) {
|
|||||||
int32_t ret = E_OK;
|
int32_t ret = E_OK;
|
||||||
|
|
||||||
if (pid == (uint64_t)-1) {
|
if (pid == (uint64_t)-1) {
|
||||||
pid = PROCS.current->pid;
|
pid = _caller_pid;
|
||||||
}
|
}
|
||||||
|
|
||||||
spinlock_acquire(&PROCS.spinlock);
|
spinlock_acquire(&PROCS.spinlock);
|
||||||
|
|||||||
@ -11,6 +11,7 @@
|
|||||||
#include "dev/dev.h"
|
#include "dev/dev.h"
|
||||||
#include "proc/proc.h"
|
#include "proc/proc.h"
|
||||||
#include "storedev/storedev.h"
|
#include "storedev/storedev.h"
|
||||||
|
#include "util/util.h"
|
||||||
|
|
||||||
int32_t SYSCALL4(sys_vfsmount, mountpoint1, fstypestr1, devid1, format1) {
|
int32_t SYSCALL4(sys_vfsmount, mountpoint1, fstypestr1, devid1, format1) {
|
||||||
int32_t ret = E_OK;
|
int32_t ret = E_OK;
|
||||||
@ -35,7 +36,8 @@ int32_t SYSCALL4(sys_vfsmount, mountpoint1, fstypestr1, devid1, format1) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
spinlock_acquire(&PROCS.spinlock);
|
spinlock_acquire(&PROCS.spinlock);
|
||||||
Proc *proc = PROCS.current;
|
Proc *proc = NULL;
|
||||||
|
LL_FINDPROP(PROCS.procs, proc, pid, _caller_pid);
|
||||||
spinlock_release(&PROCS.spinlock);
|
spinlock_release(&PROCS.spinlock);
|
||||||
|
|
||||||
Dev *dp = proc->devs[*dev];
|
Dev *dp = proc->devs[*dev];
|
||||||
|
|||||||
Reference in New Issue
Block a user