Hardcoded the PWD as '/'.

This commit is contained in:
Jonas 'Sortie' Termansen 2011-11-19 10:32:29 +01:00
parent 3d7e565d23
commit 002a1f9ea6
1 changed files with 18 additions and 2 deletions

View File

@ -24,21 +24,37 @@
#include "platform.h" #include "platform.h"
#include <libmaxsi/memory.h> #include <libmaxsi/memory.h>
#include <libmaxsi/string.h>
#include "syscall.h" #include "syscall.h"
#include "process.h" #include "process.h"
#include "filesystem.h" #include "filesystem.h"
#include "mount.h" #include "mount.h"
using namespace Maxsi;
namespace Sortix namespace Sortix
{ {
namespace FileSystem namespace FileSystem
{ {
Device* Open(const char* path, int flags, mode_t mode) 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; size_t pathoffset = 0;
DevFileSystem* fs = Mount::WhichFileSystem(path, &pathoffset); DevFileSystem* fs = Mount::WhichFileSystem(path, &pathoffset);
if ( !fs ) { return NULL; } if ( !fs ) { delete[] fullpath; return NULL; }
return fs->Open(path + pathoffset, flags, mode); Device* result = fs->Open(path + pathoffset, flags, mode);
delete[] fullpath;
return result;
} }
int SysOpen(const char* path, int flags, mode_t mode) int SysOpen(const char* path, int flags, mode_t mode)