Kernel: Register block and character devices in separate HashMaps

Instead of putting everything in one hash map, let's distinguish between
the devices based on their type.

This change makes the devices semantically separated, and is considered
a preparation before we could expose a comprehensive list of allocations
per major numbers and their purpose.
This commit is contained in:
Liav A.
2024-05-04 13:06:01 +03:00
committed by Nico Weber
parent fdff05cc97
commit 7f5a2c1466
7 changed files with 71 additions and 42 deletions

View File

@@ -10,6 +10,7 @@
#include <AK/RefPtr.h>
#include <AK/Singleton.h>
#include <AK/StringBuilder.h>
#include <Kernel/API/DeviceFileTypes.h>
#include <Kernel/API/POSIX/errno.h>
#include <Kernel/Debug.h>
#include <Kernel/Devices/BlockDevice.h>
@@ -531,7 +532,8 @@ ErrorOr<NonnullRefPtr<OpenFileDescription>> VirtualFileSystem::open(Process cons
if (metadata.is_device()) {
if (custody.mount_flags() & MS_NODEV)
return EACCES;
auto device = DeviceManagement::the().get_device(metadata.major_device, metadata.minor_device);
auto device_type = metadata.is_block_device() ? DeviceNodeType::Block : DeviceNodeType::Character;
auto device = DeviceManagement::the().get_device(device_type, metadata.major_device, metadata.minor_device);
if (device == nullptr) {
return ENODEV;
}