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 <libmaxsi/memory.h>
#include <libmaxsi/string.h>
#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)