Mount.cpp 1.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051
  1. /*
  2. * Copyright (c) 2018-2021, Andreas Kling <kling@serenityos.org>
  3. *
  4. * SPDX-License-Identifier: BSD-2-Clause
  5. */
  6. #include <Kernel/FileSystem/Custody.h>
  7. #include <Kernel/FileSystem/FileSystem.h>
  8. #include <Kernel/FileSystem/Inode.h>
  9. #include <Kernel/FileSystem/Mount.h>
  10. namespace Kernel {
  11. Mount::Mount(FileSystem& guest_fs, Custody* host_custody, int flags)
  12. : m_guest(guest_fs.root_inode())
  13. , m_guest_fs(guest_fs)
  14. , m_host_custody(host_custody)
  15. , m_flags(flags)
  16. {
  17. }
  18. Mount::Mount(Inode& source, Custody& host_custody, int flags)
  19. : m_guest(source)
  20. , m_guest_fs(source.fs())
  21. , m_host_custody(host_custody)
  22. , m_flags(flags)
  23. {
  24. }
  25. String Mount::absolute_path() const
  26. {
  27. if (!m_host_custody)
  28. return "/";
  29. return m_host_custody->absolute_path();
  30. }
  31. Inode* Mount::host()
  32. {
  33. if (!m_host_custody)
  34. return nullptr;
  35. return &m_host_custody->inode();
  36. }
  37. Inode const* Mount::host() const
  38. {
  39. if (!m_host_custody)
  40. return nullptr;
  41. return &m_host_custody->inode();
  42. }
  43. }