Kernel: Add inodes '.' and '..' to device manager
This commit is contained in:
parent
dcde2ae6b4
commit
8988ce2766
|
@ -87,6 +87,8 @@ namespace Kernel
|
||||||
BAN::ErrorOr<BAN::RefPtr<Inode>> DeviceManager::read_directory_inode(BAN::StringView name)
|
BAN::ErrorOr<BAN::RefPtr<Inode>> DeviceManager::read_directory_inode(BAN::StringView name)
|
||||||
{
|
{
|
||||||
LockGuard _(m_lock);
|
LockGuard _(m_lock);
|
||||||
|
if (name == "."sv || name == ".."sv)
|
||||||
|
return BAN::RefPtr<Inode>(this);
|
||||||
for (Device* device : m_devices)
|
for (Device* device : m_devices)
|
||||||
if (device->name() == name)
|
if (device->name() == name)
|
||||||
return BAN::RefPtr<Inode>(device);
|
return BAN::RefPtr<Inode>(device);
|
||||||
|
@ -100,9 +102,11 @@ namespace Kernel
|
||||||
return result;
|
return result;
|
||||||
|
|
||||||
LockGuard _(m_lock);
|
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)
|
for (Device* device : m_devices)
|
||||||
TRY(result.emplace_back(device->name()));
|
MUST(result.emplace_back(device->name()));
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue