1
0
Fork 0
mirror of https://gitlab.com/sortix/sortix.git synced 2023-02-13 20:55:38 -05:00

Improvements to sortix/mount.cpp

This commit is contained in:
Jonas 'Sortie' Termansen 2011-11-20 17:07:34 +01:00
parent 728bde3bee
commit 06c0777193

View file

@ -24,11 +24,14 @@
#include "platform.h" #include "platform.h"
#include <libmaxsi/memory.h> #include <libmaxsi/memory.h>
#include <libmaxsi/string.h>
#include "panic.h" #include "panic.h"
#include "mount.h" #include "mount.h"
#include "fs/ramfs.h" #include "fs/ramfs.h"
#include "fs/initfs.h" #include "fs/initfs.h"
using namespace Maxsi;
namespace Sortix namespace Sortix
{ {
namespace Mount namespace Mount
@ -36,9 +39,23 @@ namespace Sortix
DevFileSystem* initfs; DevFileSystem* initfs;
DevFileSystem* rootfs; DevFileSystem* rootfs;
bool MatchesMountPath(const char* path, const char* mount)
{
size_t mountlen = String::Length(mount);
if ( !String::StartsWith(path, mount) ) { return false; }
switch ( path[mountlen] )
{
case '\0':
case '/':
return true;
default:
return false;
}
}
DevFileSystem* WhichFileSystem(const char* path, size_t* pathoffset) DevFileSystem* WhichFileSystem(const char* path, size_t* pathoffset)
{ {
if ( path[0] == '/' && path[1] == 'b' && path[2] == 'i' && path[3] == 'n' && (path[4] == '/' || path[4] == 0) ) if ( MatchesMountPath(path, "/bin") )
{ {
*pathoffset = 4; *pathoffset = 4;
return initfs; return initfs;