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:
parent
728bde3bee
commit
06c0777193
1 changed files with 18 additions and 1 deletions
|
@ -24,11 +24,14 @@
|
|||
|
||||
#include "platform.h"
|
||||
#include <libmaxsi/memory.h>
|
||||
#include <libmaxsi/string.h>
|
||||
#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;
|
||||
|
|
Loading…
Reference in a new issue