From 002a1f9ea63f34c14e88bbfbd27e5d29a0ed8aad Mon Sep 17 00:00:00 2001 From: Jonas 'Sortie' Termansen Date: Sat, 19 Nov 2011 10:32:29 +0100 Subject: [PATCH] Hardcoded the PWD as '/'. --- sortix/filesystem.cpp | 20 ++++++++++++++++++-- 1 file changed, 18 insertions(+), 2 deletions(-) diff --git a/sortix/filesystem.cpp b/sortix/filesystem.cpp index e871cce7..b0f3c7a2 100644 --- a/sortix/filesystem.cpp +++ b/sortix/filesystem.cpp @@ -24,21 +24,37 @@ #include "platform.h" #include +#include #include "syscall.h" #include "process.h" #include "filesystem.h" #include "mount.h" +using namespace Maxsi; + namespace Sortix { namespace FileSystem { Device* Open(const char* path, int flags, mode_t mode) { + const char* workingdir = "/"; + char* fullpath = NULL; + if ( *path != '/' ) + { + size_t len = String::Length(workingdir) + String::Length(path); + fullpath = new char[len+1]; + if ( !fullpath ) { return NULL; } + String::Copy(fullpath, workingdir); + String::Cat(fullpath, path); + path = fullpath; + } size_t pathoffset = 0; DevFileSystem* fs = Mount::WhichFileSystem(path, &pathoffset); - if ( !fs ) { return NULL; } - return fs->Open(path + pathoffset, flags, mode); + if ( !fs ) { delete[] fullpath; return NULL; } + Device* result = fs->Open(path + pathoffset, flags, mode); + delete[] fullpath; + return result; } int SysOpen(const char* path, int flags, mode_t mode)