|
@@ -5,6 +5,7 @@
|
|
|
*/
|
|
|
|
|
|
#include <Kernel/Devices/BlockDevice.h>
|
|
|
+#include <Kernel/FileSystem/SysFS/Subsystems/DeviceIdentifiers/BlockDevicesDirectory.h>
|
|
|
|
|
|
namespace Kernel {
|
|
|
|
|
@@ -26,6 +27,40 @@ void AsyncBlockDeviceRequest::start()
|
|
|
|
|
|
BlockDevice::~BlockDevice() = default;
|
|
|
|
|
|
+void BlockDevice::after_inserting_add_symlink_to_device_identifier_directory()
|
|
|
+{
|
|
|
+ VERIFY(m_symlink_sysfs_component);
|
|
|
+ SysFSBlockDevicesDirectory::the().devices_list({}).with([&](auto& list) -> void {
|
|
|
+ list.append(*m_symlink_sysfs_component);
|
|
|
+ });
|
|
|
+}
|
|
|
+
|
|
|
+void BlockDevice::before_will_be_destroyed_remove_symlink_from_device_identifier_directory()
|
|
|
+{
|
|
|
+ VERIFY(m_symlink_sysfs_component);
|
|
|
+ SysFSBlockDevicesDirectory::the().devices_list({}).with([&](auto& list) -> void {
|
|
|
+ list.remove(*m_symlink_sysfs_component);
|
|
|
+ });
|
|
|
+}
|
|
|
+
|
|
|
+// FIXME: This method will be eventually removed after all nodes in /sys/dev/block/ are symlinks
|
|
|
+void BlockDevice::after_inserting_add_to_device_identifier_directory()
|
|
|
+{
|
|
|
+ VERIFY(m_sysfs_component);
|
|
|
+ SysFSBlockDevicesDirectory::the().devices_list({}).with([&](auto& list) -> void {
|
|
|
+ list.append(*m_sysfs_component);
|
|
|
+ });
|
|
|
+}
|
|
|
+
|
|
|
+// FIXME: This method will be eventually removed after all nodes in /sys/dev/block/ are symlinks
|
|
|
+void BlockDevice::before_will_be_destroyed_remove_from_device_identifier_directory()
|
|
|
+{
|
|
|
+ VERIFY(m_sysfs_component);
|
|
|
+ SysFSBlockDevicesDirectory::the().devices_list({}).with([&](auto& list) -> void {
|
|
|
+ list.remove(*m_sysfs_component);
|
|
|
+ });
|
|
|
+}
|
|
|
+
|
|
|
bool BlockDevice::read_block(u64 index, UserOrKernelBuffer& buffer)
|
|
|
{
|
|
|
auto read_request_or_error = try_make_request<AsyncBlockDeviceRequest>(AsyncBlockDeviceRequest::Read, index, 1, buffer, m_block_size);
|