mirror of
https://github.com/RPCSX/rpcsx.git
synced 2026-04-20 22:05:12 +00:00
[rpcsx-os] fork: implement vm and vfs fork
stub metadbg device implement notification device implement sys_pipe
This commit is contained in:
parent
39092c7f16
commit
525ef02e8a
22 changed files with 379 additions and 76 deletions
|
|
@ -1,6 +1,5 @@
|
|||
#include "KernelContext.hpp"
|
||||
#include "sys/sysproto.hpp"
|
||||
#include "utils/Logs.hpp"
|
||||
#include <cstdlib>
|
||||
#include <unistd.h>
|
||||
|
||||
|
|
@ -11,42 +10,8 @@ orbis::SysResult orbis::sys_pdfork(Thread *thread, ptr<sint> fdp, sint flags) {
|
|||
|
||||
orbis::SysResult orbis::sys_vfork(Thread *thread) { return ErrorCode::NOSYS; }
|
||||
orbis::SysResult orbis::sys_rfork(Thread *thread, sint flags) {
|
||||
ORBIS_LOG_TODO(__FUNCTION__, flags);
|
||||
|
||||
int hostPid = ::fork();
|
||||
if (hostPid) {
|
||||
thread->retval[0] = 10001;
|
||||
thread->retval[1] = 0;
|
||||
} else {
|
||||
auto process = g_context.createProcess(10001);
|
||||
std::lock_guard lock(thread->tproc->fileDescriptors.mutex);
|
||||
process->sysent = thread->tproc->sysent;
|
||||
process->onSysEnter = thread->tproc->onSysEnter;
|
||||
process->onSysExit = thread->tproc->onSysExit;
|
||||
process->ops = thread->tproc->ops;
|
||||
process->isSystem = thread->tproc->isSystem;
|
||||
for (auto [id, mod] : thread->tproc->modulesMap) {
|
||||
if (!process->modulesMap.insert(id, mod)) {
|
||||
std::abort();
|
||||
}
|
||||
}
|
||||
|
||||
for (auto [id, mod] : thread->tproc->fileDescriptors) {
|
||||
if (!process->fileDescriptors.insert(id, mod)) {
|
||||
std::abort();
|
||||
}
|
||||
}
|
||||
|
||||
auto [baseId, newThread] = process->threadsMap.emplace();
|
||||
newThread->tproc = process;
|
||||
newThread->tid = process->pid + baseId;
|
||||
newThread->state = orbis::ThreadState::RUNNING;
|
||||
newThread->context = thread->context;
|
||||
newThread->fsBase = thread->fsBase;
|
||||
|
||||
orbis::g_currentThread = newThread;
|
||||
newThread->retval[0] = 0;
|
||||
newThread->retval[1] = 1;
|
||||
if (auto fork = thread->tproc->ops->fork) {
|
||||
return fork(thread, flags);
|
||||
}
|
||||
return {};
|
||||
return ErrorCode::NOSYS;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,3 +1,9 @@
|
|||
#include "sys/sysproto.hpp"
|
||||
#include <pipe.hpp>
|
||||
|
||||
orbis::SysResult orbis::sys_pipe(Thread *thread) { return ErrorCode::NOSYS; }
|
||||
orbis::SysResult orbis::sys_pipe(Thread *thread) {
|
||||
auto pipe = createPipe();
|
||||
thread->retval[0] = thread->tproc->fileDescriptors.insert(pipe);
|
||||
thread->retval[1] = thread->tproc->fileDescriptors.insert(pipe);
|
||||
return {};
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue