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:
parent
dc0f78f6b7
commit
cadac5ce2a
2 changed files with 13 additions and 7 deletions
|
@ -337,17 +337,26 @@ namespace Sortix
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const bool BINDEVHACK = false;
|
||||||
|
|
||||||
size_t DevRAMFS::GetNumFiles()
|
size_t DevRAMFS::GetNumFiles()
|
||||||
{
|
{
|
||||||
if ( !files ) { return 0; }
|
size_t result = BINDEVHACK ? 2 : 0;
|
||||||
return files->Length();
|
if ( files ) { result += files->Length(); }
|
||||||
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
const char* DevRAMFS::GetFilename(size_t index)
|
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 ) { return NULL; }
|
||||||
if ( files->Length() <= index ) { return NULL; }
|
if ( files->Length() <= filesindex ) { return NULL; }
|
||||||
DevRAMFSFile* file = files->Get(index);
|
DevRAMFSFile* file = files->Get(filesindex);
|
||||||
return file->name;
|
return file->name;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -36,9 +36,6 @@ int ls(const char* path)
|
||||||
DIR* dir = opendir(path);
|
DIR* dir = opendir(path);
|
||||||
if ( !dir ) { error(2, errno, "%s", path); return 2; }
|
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;
|
struct dirent* entry;
|
||||||
while ( (entry = readdir(dir)) )
|
while ( (entry = readdir(dir)) )
|
||||||
{
|
{
|
||||||
|
|
Loading…
Add table
Reference in a new issue