From 06c0777193ad8af2ca79fc84c2ff8b4010613598 Mon Sep 17 00:00:00 2001 From: Jonas 'Sortie' Termansen Date: Sun, 20 Nov 2011 17:07:34 +0100 Subject: [PATCH] Improvements to sortix/mount.cpp --- sortix/mount.cpp | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-) diff --git a/sortix/mount.cpp b/sortix/mount.cpp index 34a422b0..79d5438d 100644 --- a/sortix/mount.cpp +++ b/sortix/mount.cpp @@ -24,11 +24,14 @@ #include "platform.h" #include +#include #include "panic.h" #include "mount.h" #include "fs/ramfs.h" #include "fs/initfs.h" +using namespace Maxsi; + namespace Sortix { namespace Mount @@ -36,9 +39,23 @@ namespace Sortix DevFileSystem* initfs; 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) { - if ( path[0] == '/' && path[1] == 'b' && path[2] == 'i' && path[3] == 'n' && (path[4] == '/' || path[4] == 0) ) + if ( MatchesMountPath(path, "/bin") ) { *pathoffset = 4; return initfs;