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

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)) )
{