diff --git a/orbis-kernel/include/orbis/thread/types.hpp b/orbis-kernel/include/orbis/thread/types.hpp index 9985a6b2a..f867833e7 100644 --- a/orbis-kernel/include/orbis/thread/types.hpp +++ b/orbis-kernel/include/orbis/thread/types.hpp @@ -30,4 +30,22 @@ struct thr_param { ptr name; ptr spare[2]; }; + +static constexpr auto RFFDG = 1 << 2; // copy fd table +static constexpr auto RFPROC = 1 << 4; // change child (else changes curproc) +static constexpr auto RFMEM = 1 << 5; // share `address space' +static constexpr auto RFNOWAIT = 1 << 6; // give child to init +static constexpr auto RFCFDG = 1 << 12; // close all fds, zero fd table +static constexpr auto RFSIGSHARE = 1 << 14; // share signal handlers +static constexpr auto RFLINUXTHPN = + 1 << 16; // do linux clone exit parent notification +static constexpr auto RFTSIGZMB = + 1 << 19; // select signal for exit parent notification +static constexpr auto RFTSIGSHIFT = + 20; // selected signal number is in bits 20-27 +static constexpr auto RFTSIGMASK = 0xFF; +static constexpr auto RFPROCDESC = 1 << 28; // return a process descriptor +static constexpr auto RFPPWAIT = + 1 << 31; // parent sleeps until child exits (vfork) + } // namespace orbis diff --git a/orbis-kernel/src/sys/sys_fork.cpp b/orbis-kernel/src/sys/sys_fork.cpp index 4c70633e4..db2ab7693 100644 --- a/orbis-kernel/src/sys/sys_fork.cpp +++ b/orbis-kernel/src/sys/sys_fork.cpp @@ -5,7 +5,12 @@ #include #include -orbis::SysResult orbis::sys_fork(Thread *thread) { return ErrorCode::NOSYS; } +orbis::SysResult orbis::sys_fork(Thread *thread) { + if (auto fork = thread->tproc->ops->fork) { + return fork(thread, RFFDG | RFPROC); + } + return ErrorCode::NOSYS; +} orbis::SysResult orbis::sys_pdfork(Thread *thread, ptr fdp, sint flags) { return ErrorCode::NOSYS; } diff --git a/rpcsx-os/ops.cpp b/rpcsx-os/ops.cpp index c005ae6e4..89504509e 100644 --- a/rpcsx-os/ops.cpp +++ b/rpcsx-os/ops.cpp @@ -691,7 +691,7 @@ orbis::SysResult nmount(orbis::Thread *thread, orbis::ptr iovp, } if (fstype == "nullfs") { - ORBIS_RET_ON_ERROR(rx::vfs::unlink(fspath, thread)); + rx::vfs::unlinkAll(fspath, thread); return rx::vfs::createSymlink(target, fspath, thread); } @@ -788,7 +788,7 @@ SysResult fork(Thread *thread, slong flags) { } } - if (false) { + if (flags & RFFDG) { std::lock_guard lock(thread->tproc->fileDescriptors.mutex); for (auto [id, mod] : thread->tproc->fileDescriptors) { if (!process->fileDescriptors.insert(id, mod)) { @@ -827,6 +827,8 @@ SysResult fork(Thread *thread, slong flags) { dup2(logFd, 1); dup2(logFd, 2); + ::close(logFd); + return {}; }