mirror of
https://github.com/SerenityOS/serenity
synced 2026-04-27 01:55:31 +02:00
Kernel/Devices: Remove the DeviceManagement singleton
This change has many improvements: - We don't use `LockRefPtr` to hold instances of many base devices as with the DeviceManagement class. Instead, we have a saner pattern of holding them in a `NonnullRefPtr<T> const`, in a small-text footprint class definition in the `Device.cpp` file. - The awkwardness of using `::the()` each time we need to get references to mostly-static objects (like the Event queue) in runtime is now gone in the migration to using the `Device` class. - Acquiring a device feel more obvious because we use now the Device class for this method. The method name is improved as well.
This commit is contained in:
@@ -14,7 +14,7 @@
|
||||
#include <Kernel/API/POSIX/errno.h>
|
||||
#include <Kernel/Debug.h>
|
||||
#include <Kernel/Devices/BlockDevice.h>
|
||||
#include <Kernel/Devices/DeviceManagement.h>
|
||||
#include <Kernel/Devices/Device.h>
|
||||
#include <Kernel/Devices/Loop/LoopDevice.h>
|
||||
#include <Kernel/FileSystem/Custody.h>
|
||||
#include <Kernel/FileSystem/FileBackedFileSystem.h>
|
||||
@@ -549,7 +549,7 @@ ErrorOr<NonnullRefPtr<OpenFileDescription>> VirtualFileSystem::open(Process cons
|
||||
if (custody.mount_flags() & MS_NODEV)
|
||||
return EACCES;
|
||||
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);
|
||||
auto device = Device::acquire_by_type_and_major_minor_numbers(device_type, metadata.major_device, metadata.minor_device);
|
||||
if (device == nullptr) {
|
||||
return ENODEV;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user