[orbis-kernel] implement sys_chdir & sys_chroot

This commit is contained in:
DH 2023-11-11 20:51:10 +03:00
parent d814b2b741
commit 05b7861999
4 changed files with 52 additions and 21 deletions

View file

@ -57,6 +57,10 @@ struct Process final {
const ProcessOps *ops = nullptr;
AppInfo appInfo{};
AuthInfo authInfo{};
kstring cwd;
kstring root = "/";
sint memoryContainer{1};
bool isInSandbox = false;
std::uint64_t nextTlsSlot = 1;
std::uint64_t lastTlsOffset = 0;

View file

@ -82,7 +82,7 @@ orbis::SysResult orbis::sys_regmgr_call(Thread *thread, uint32_t op,
return uwrite((ptr<uint>)value, 0u);
}
return{};
return {};
}
if (op == 4) {
@ -1028,7 +1028,8 @@ orbis::SysResult orbis::sys_suspend_system(Thread *thread /* TODO */) {
orbis::SysResult orbis::sys_ipmimgr_call(Thread *thread, uint op, uint kid,
ptr<uint> result, ptr<void> params,
uint64_t paramsSz) {
// ORBIS_LOG_TODO(__FUNCTION__, thread->tid, op, kid, result, params, paramsSz);
// ORBIS_LOG_TODO(__FUNCTION__, thread->tid, op, kid, result, params,
// paramsSz);
switch (op) {
case 0:

View file

@ -1,6 +1,7 @@
#include "stat.hpp"
#include "sys/sysproto.hpp"
#include "utils/Logs.hpp"
#include <filesystem>
orbis::SysResult orbis::sys_sync(Thread *thread) { return ErrorCode::NOSYS; }
orbis::SysResult orbis::sys_quotactl(Thread *thread, ptr<char> path, sint cmd,
@ -23,10 +24,14 @@ orbis::SysResult orbis::sys_fchdir(Thread *thread, sint fd) {
return ErrorCode::NOSYS;
}
orbis::SysResult orbis::sys_chdir(Thread *thread, ptr<char> path) {
return ErrorCode::NOSYS;
ORBIS_LOG_WARNING(__FUNCTION__, path);
thread->tproc->cwd = std::filesystem::path(path).lexically_normal().string();
return {};
}
orbis::SysResult orbis::sys_chroot(Thread *thread, ptr<char> path) {
return ErrorCode::NOSYS;
ORBIS_LOG_WARNING(__FUNCTION__, path);
thread->tproc->root = path;
return {};
}
orbis::SysResult orbis::sys_open(Thread *thread, ptr<char> path, sint flags,
sint mode) {