diff --git a/sortix/fs/devfs.cpp b/sortix/fs/devfs.cpp index 95380c9d..dd60bfef 100644 --- a/sortix/fs/devfs.cpp +++ b/sortix/fs/devfs.cpp @@ -302,7 +302,7 @@ namespace Sortix int DevDevFSDir::Read(sortix_dirent* dirent, size_t available) { - const char* names[] = { "null", "tty", "video", "vga" }; + const char* names[] = { ".", "..", "null", "tty", "video", "vga" }; const char* name = NULL; if ( position < DeviceFS::GetNumDevices() ) { diff --git a/sortix/fs/initfs.cpp b/sortix/fs/initfs.cpp index 4b0d43b8..22ecd8f8 100644 --- a/sortix/fs/initfs.cpp +++ b/sortix/fs/initfs.cpp @@ -191,9 +191,6 @@ namespace Sortix size_t namelen = String::Length(name); size_t needed = sizeof(sortix_dirent) + namelen + 1; - // Oh right, the kernel is stupid and doesn't support dot and dotdot. - if ( name[0] == '.' ) { position++; return Read(dirent, available); } - if ( available < needed ) { dirent->d_namelen = needed; diff --git a/sortix/fs/ramfs.cpp b/sortix/fs/ramfs.cpp index a3da0adb..792bd6b1 100644 --- a/sortix/fs/ramfs.cpp +++ b/sortix/fs/ramfs.cpp @@ -341,22 +341,30 @@ namespace Sortix size_t DevRAMFS::GetNumFiles() { - size_t result = BINDEVHACK ? 2 : 0; + size_t result = 2 + (BINDEVHACK ? 2 : 0); if ( files ) { result += files->Length(); } return result; } const char* DevRAMFS::GetFilename(size_t index) { - switch ( BINDEVHACK ? index : 2 ) + switch ( index ) + { + case 0: return "."; + case 1: return ".."; + default: index -= 2; + } + if ( BINDEVHACK ) switch ( index ) { case 0: return "bin"; case 1: return "dev"; + default: index -= 2; } - size_t filesindex = BINDEVHACK ? index - 2 : index; - if ( !files ) { return NULL; } - if ( files->Length() <= filesindex ) { return NULL; } - DevRAMFSFile* file = files->Get(filesindex); + if ( !files ) + return NULL; + if ( files->Length() <= index ) + return NULL; + DevRAMFSFile* file = files->Get(index); return file->name; } } diff --git a/sortix/fs/videofs.cpp b/sortix/fs/videofs.cpp index ce538ea4..53b444fc 100644 --- a/sortix/fs/videofs.cpp +++ b/sortix/fs/videofs.cpp @@ -200,12 +200,24 @@ Device* MakeFB(int flags, mode_t /*mode*/) return new DevFrameBuffer(); } +Device* MakeDot(int /*flags*/, mode_t /*mode*/) +{ + return NULL; +} + +Device* MakeDotDot(int /*flags*/, mode_t /*mode*/) +{ + return NULL; +} + struct { const char* name; Device* (*factory)(int, mode_t); } nodes[] = { + { ".", MakeDot }, + { "..", MakeDotDot }, { "mode", MakeMode }, { "modes", MakeModes }, { "supports", MakeSupports }, diff --git a/utils/ls.cpp b/utils/ls.cpp index b8bcc959..949e9c2b 100644 --- a/utils/ls.cpp +++ b/utils/ls.cpp @@ -99,11 +99,6 @@ int ls(const char* path) DIR* dir = opendir(path); if ( !dir ) { finishoutput(); error(0, errno, "%s", path); return 2; } -#if defined(sortix) - handleentry(path, "."); - handleentry(path, ".."); -#endif - struct dirent* entry; while ( (entry = readdir(dir)) ) {