2020-01-18 09:38:21 +01:00
|
|
|
/*
|
|
|
|
|
* Copyright (c) 2018-2020, Andreas Kling <kling@serenityos.org>
|
|
|
|
|
*
|
2021-04-22 01:24:48 -07:00
|
|
|
* SPDX-License-Identifier: BSD-2-Clause
|
2020-01-18 09:38:21 +01:00
|
|
|
*/
|
|
|
|
|
|
2019-04-03 12:36:40 +02:00
|
|
|
#include <Kernel/Devices/CharacterDevice.h>
|
2022-07-16 10:39:57 +03:00
|
|
|
#include <Kernel/FileSystem/SysFS/Subsystems/DeviceIdentifiers/CharacterDevicesDirectory.h>
|
2019-04-03 12:36:40 +02:00
|
|
|
|
2020-02-16 01:27:42 +01:00
|
|
|
namespace Kernel {
|
|
|
|
|
|
2022-03-16 13:15:15 -06:00
|
|
|
CharacterDevice::~CharacterDevice() = default;
|
2020-02-16 01:27:42 +01:00
|
|
|
|
2022-07-16 10:39:57 +03:00
|
|
|
void CharacterDevice::after_inserting_add_symlink_to_device_identifier_directory()
|
|
|
|
|
{
|
|
|
|
|
VERIFY(m_symlink_sysfs_component);
|
|
|
|
|
SysFSCharacterDevicesDirectory::the().devices_list({}).with([&](auto& list) -> void {
|
|
|
|
|
list.append(*m_symlink_sysfs_component);
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void CharacterDevice::before_will_be_destroyed_remove_symlink_from_device_identifier_directory()
|
|
|
|
|
{
|
|
|
|
|
VERIFY(m_symlink_sysfs_component);
|
|
|
|
|
SysFSCharacterDevicesDirectory::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/char/ are symlinks
|
|
|
|
|
void CharacterDevice::after_inserting_add_to_device_identifier_directory()
|
|
|
|
|
{
|
|
|
|
|
VERIFY(m_sysfs_component);
|
|
|
|
|
SysFSCharacterDevicesDirectory::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/char/ are symlinks
|
|
|
|
|
void CharacterDevice::before_will_be_destroyed_remove_from_device_identifier_directory()
|
|
|
|
|
{
|
|
|
|
|
VERIFY(m_sysfs_component);
|
|
|
|
|
SysFSCharacterDevicesDirectory::the().devices_list({}).with([&](auto& list) -> void {
|
|
|
|
|
list.remove(*m_sysfs_component);
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
|
2020-02-16 01:27:42 +01:00
|
|
|
}
|