From 6916eb753729a885c2d2f870921fbe2a480ef035 Mon Sep 17 00:00:00 2001 From: Alex Date: Fri, 5 May 2023 20:04:22 +0300 Subject: [PATCH] Check if path is relative --- SystemCalls/Native.cpp | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/SystemCalls/Native.cpp b/SystemCalls/Native.cpp index edb0131..af97518 100644 --- a/SystemCalls/Native.cpp +++ b/SystemCalls/Native.cpp @@ -250,7 +250,13 @@ static int sys_ipc(SyscallsFrame *Frame, enum IPCCommand Command, enum IPCType T static uint64_t sys_file_open(SyscallsFrame *Frame, const char *Path, uint64_t Flags) { debug("(Path: %s, Flags: %#lx)", Path, Flags); - VirtualFileSystem::File KPObj = vfs->Open(Path, TaskManager->GetCurrentProcess()->CurrentWorkingDirectory); + VirtualFileSystem::Node *cwd = nullptr; + if (vfs->PathIsRelative(Path)) + cwd = TaskManager->GetCurrentProcess()->CurrentWorkingDirectory; + else + cwd = vfs->GetRootNode(); + + VirtualFileSystem::File KPObj = vfs->Open(Path, cwd); if (!KPObj.IsOK()) { debug("Failed to open file %s (%d)", Path, KPObj.Status); @@ -313,7 +319,9 @@ static uint64_t sys_file_seek(SyscallsFrame *Frame, void *KernelPrivate, uint64_ if (KPObj->node->Operator->Seek == nullptr) return SYSCALL_INTERNAL_ERROR; - return KPObj->node->Operator->Seek(KPObj->node, Offset, (uint8_t)Whence); + uint64_t ret = KPObj->node->Operator->Seek(KPObj->node, Offset, (uint8_t)Whence); + debug("Seek %s %ld", KPObj->Name, ret); + return ret; UNUSED(Frame); }