LinkInode.cpp 1.1 KB

12345678910111213141516171819202122232425262728293031323334353637
  1. /*
  2. * Copyright (c) 2021, Liav A. <liavalb@hotmail.co.il>
  3. *
  4. * SPDX-License-Identifier: BSD-2-Clause
  5. */
  6. #include <Kernel/FileSystem/SysFS/LinkInode.h>
  7. #include <Kernel/Time/TimeManagement.h>
  8. namespace Kernel {
  9. ErrorOr<NonnullLockRefPtr<SysFSLinkInode>> SysFSLinkInode::try_create(SysFS const& sysfs, SysFSComponent const& component)
  10. {
  11. return adopt_nonnull_lock_ref_or_enomem(new (nothrow) SysFSLinkInode(sysfs, component));
  12. }
  13. SysFSLinkInode::SysFSLinkInode(SysFS const& fs, SysFSComponent const& component)
  14. : SysFSInode(fs, component)
  15. {
  16. }
  17. SysFSLinkInode::~SysFSLinkInode() = default;
  18. InodeMetadata SysFSLinkInode::metadata() const
  19. {
  20. // NOTE: No locking required as m_associated_component or its component index will never change during our lifetime.
  21. InodeMetadata metadata;
  22. metadata.inode = { fsid(), m_associated_component->component_index() };
  23. metadata.mode = S_IFLNK | S_IRUSR | S_IRGRP | S_IROTH | S_IXOTH;
  24. metadata.uid = 0;
  25. metadata.gid = 0;
  26. metadata.size = 0;
  27. metadata.mtime = TimeManagement::boot_time();
  28. return metadata;
  29. }
  30. }