From 8988ce2766a28aecb260579d0a826722c247963c Mon Sep 17 00:00:00 2001 From: Bananymous Date: Sat, 1 Apr 2023 01:33:04 +0300 Subject: [PATCH] Kernel: Add inodes '.' and '..' to device manager --- kernel/kernel/DeviceManager.cpp | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/kernel/kernel/DeviceManager.cpp b/kernel/kernel/DeviceManager.cpp index b5f0d592..fe8fdaf3 100644 --- a/kernel/kernel/DeviceManager.cpp +++ b/kernel/kernel/DeviceManager.cpp @@ -87,6 +87,8 @@ namespace Kernel BAN::ErrorOr> DeviceManager::read_directory_inode(BAN::StringView name) { LockGuard _(m_lock); + if (name == "."sv || name == ".."sv) + return BAN::RefPtr(this); for (Device* device : m_devices) if (device->name() == name) return BAN::RefPtr(device); @@ -100,9 +102,11 @@ namespace Kernel return result; LockGuard _(m_lock); - TRY(result.reserve(m_devices.size())); + TRY(result.reserve(m_devices.size() + 2)); + MUST(result.emplace_back("."sv)); + MUST(result.emplace_back(".."sv)); for (Device* device : m_devices) - TRY(result.emplace_back(device->name())); + MUST(result.emplace_back(device->name())); return result; }