Moved the /bin and /dev hack into the kernel.

This makes ls seem less hacky.
This commit is contained in:
Jonas 'Sortie' Termansen 2012-03-11 17:25:32 +01:00
parent dc0f78f6b7
commit cadac5ce2a
2 changed files with 13 additions and 7 deletions

View File

@ -337,17 +337,26 @@ namespace Sortix
return true;
}
const bool BINDEVHACK = false;
size_t DevRAMFS::GetNumFiles()
{
if ( !files ) { return 0; }
return files->Length();
size_t result = BINDEVHACK ? 2 : 0;
if ( files ) { result += files->Length(); }
return result;
}
const char* DevRAMFS::GetFilename(size_t index)
{
switch ( BINDEVHACK ? index : 2 )
{
case 0: return "bin";
case 1: return "dev";
}
size_t filesindex = BINDEVHACK ? index - 2 : index;
if ( !files ) { return NULL; }
if ( files->Length() <= index ) { return NULL; }
DevRAMFSFile* file = files->Get(index);
if ( files->Length() <= filesindex ) { return NULL; }
DevRAMFSFile* file = files->Get(filesindex);
return file->name;
}
}

View File

@ -36,9 +36,6 @@ int ls(const char* path)
DIR* dir = opendir(path);
if ( !dir ) { error(2, errno, "%s", path); return 2; }
// TODO: Hack until mountpoints work correctly.
if ( strcmp(path, "/") == 0 ) { printf("bin\ndev\n"); }
struct dirent* entry;
while ( (entry = readdir(dir)) )
{