mirror of
https://github.com/RGBCube/serenity
synced 2025-05-22 13:25:07 +00:00

It is starting to get a little messy with how each device can try to add or remove itself to either /sys/dev/block or /sys/dev/char directories. To better do this, we introduce 4 virtual methods to take care of that, so until we ensure all nodes in /sys/dev/block and /sys/dev/char are actual symlinks, we allow the Device base class to call virtual methods upon insertion or before being destroying, so it add itself elegantly to either of these directories or remove itself when needed. For special cases where we need to create symlinks, we have two virtual methods to be called otherwise to do almost the same thing mentioned before, but to use symlinks instead.
30 lines
860 B
C++
30 lines
860 B
C++
/*
|
|
* Copyright (c) 2022, Liav A. <liavalb@hotmail.co.il>
|
|
*
|
|
* SPDX-License-Identifier: BSD-2-Clause
|
|
*/
|
|
|
|
#pragma once
|
|
|
|
#include <Kernel/FileSystem/SysFS/Component.h>
|
|
#include <Kernel/FileSystem/SysFS/Subsystems/DeviceIdentifiers/DeviceComponent.h>
|
|
#include <Kernel/FileSystem/SysFS/Subsystems/DeviceIdentifiers/Directory.h>
|
|
|
|
namespace Kernel {
|
|
|
|
class CharacterDevice;
|
|
class SysFSCharacterDevicesDirectory final : public SysFSDirectory {
|
|
|
|
public:
|
|
virtual StringView name() const override { return "char"sv; }
|
|
static NonnullRefPtr<SysFSCharacterDevicesDirectory> must_create(SysFSDeviceIdentifiersDirectory const&);
|
|
|
|
static SysFSCharacterDevicesDirectory& the();
|
|
|
|
ChildList& devices_list(Badge<CharacterDevice>) { return m_child_components; }
|
|
|
|
private:
|
|
explicit SysFSCharacterDevicesDirectory(SysFSDeviceIdentifiersDirectory const&);
|
|
};
|
|
|
|
}
|