SymbolicLinkDeviceComponent.h 1.8 KB

123456789101112131415161718192021222324252627282930313233343536373839
  1. /*
  2. * Copyright (c) 2022, Liav A. <liavalb@hotmail.co.il>
  3. *
  4. * SPDX-License-Identifier: BSD-2-Clause
  5. */
  6. #pragma once
  7. #include <AK/IntrusiveList.h>
  8. #include <Kernel/FileSystem/SysFS/Component.h>
  9. #include <Kernel/FileSystem/SysFS/Subsystems/DeviceIdentifiers/BlockDevicesDirectory.h>
  10. #include <Kernel/FileSystem/SysFS/Subsystems/DeviceIdentifiers/CharacterDevicesDirectory.h>
  11. #include <Kernel/KString.h>
  12. namespace Kernel {
  13. class SysFSDeviceIdentifiersDirectory;
  14. class SysFSSymbolicLinkDeviceComponent final
  15. : public SysFSSymbolicLink
  16. , public LockWeakable<SysFSSymbolicLinkDeviceComponent> {
  17. friend class SysFSComponentRegistry;
  18. public:
  19. static ErrorOr<NonnullRefPtr<SysFSSymbolicLinkDeviceComponent>> try_create(SysFSCharacterDevicesDirectory const& parent_directory, Device const& device, SysFSComponent const& pointed_component);
  20. static ErrorOr<NonnullRefPtr<SysFSSymbolicLinkDeviceComponent>> try_create(SysFSBlockDevicesDirectory const& parent_directory, Device const& device, SysFSComponent const& pointed_component);
  21. virtual StringView name() const override { return m_major_minor_formatted_device_name->view(); }
  22. bool is_block_device() const { return m_block_device; }
  23. private:
  24. SysFSSymbolicLinkDeviceComponent(SysFSCharacterDevicesDirectory const& parent_directory, NonnullOwnPtr<KString> major_minor_formatted_device_name, Device const&, SysFSComponent const& pointed_component);
  25. SysFSSymbolicLinkDeviceComponent(SysFSBlockDevicesDirectory const& parent_directory, NonnullOwnPtr<KString> major_minor_formatted_device_name, Device const&, SysFSComponent const& pointed_component);
  26. IntrusiveListNode<SysFSSymbolicLinkDeviceComponent, NonnullRefPtr<SysFSSymbolicLinkDeviceComponent>> m_list_node;
  27. bool const m_block_device { false };
  28. NonnullOwnPtr<KString> m_major_minor_formatted_device_name;
  29. };
  30. }