2020-01-18 05:38:21 -03:00
|
|
|
/*
|
|
|
|
|
* Copyright (c) 2018-2020, Andreas Kling <kling@serenityos.org>
|
|
|
|
|
*
|
2021-04-22 05:24:48 -03:00
|
|
|
* SPDX-License-Identifier: BSD-2-Clause
|
2020-01-18 05:38:21 -03:00
|
|
|
*/
|
|
|
|
|
|
2019-04-03 07:36:40 -03:00
|
|
|
#include <Kernel/Devices/CharacterDevice.h>
|
2022-07-16 04:39:57 -03:00
|
|
|
#include <Kernel/FileSystem/SysFS/Subsystems/DeviceIdentifiers/CharacterDevicesDirectory.h>
|
2019-04-03 07:36:40 -03:00
|
|
|
|
2020-02-15 21:27:42 -03:00
|
|
|
namespace Kernel {
|
|
|
|
|
|
2022-03-16 16:15:15 -03:00
|
|
|
CharacterDevice::~CharacterDevice() = default;
|
2020-02-15 21:27:42 -03:00
|
|
|
|
2022-07-16 04: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-15 21:27:42 -03:00
|
|
|
}
|