FileSystem.h 1002 B

1234567891011121314151617181920212223242526272829303132333435363738394041
  1. /*
  2. * Copyright (c) 2019-2020, Sergey Bugaev <bugaevc@serenityos.org>
  3. * Copyright (c) 2022-2023, Liav A. <liavalb@hotmail.co.il>
  4. *
  5. * SPDX-License-Identifier: BSD-2-Clause
  6. */
  7. #pragma once
  8. #include <Kernel/FileSystem/FileSystem.h>
  9. #include <Kernel/FileSystem/Inode.h>
  10. #include <Kernel/Forward.h>
  11. namespace Kernel {
  12. class RAMFS final : public FileSystem {
  13. friend class RAMFSInode;
  14. public:
  15. virtual ~RAMFS() override;
  16. static ErrorOr<NonnullLockRefPtr<FileSystem>> try_create();
  17. virtual ErrorOr<void> initialize() override;
  18. virtual StringView class_name() const override { return "RAMFS"sv; }
  19. virtual bool supports_watchers() const override { return true; }
  20. virtual Inode& root_inode() override;
  21. private:
  22. RAMFS();
  23. LockRefPtr<RAMFSInode> m_root_inode;
  24. // NOTE: We start by assigning InodeIndex of 2, because 0 is invalid and 1
  25. // is reserved for the root directory inode.
  26. unsigned m_next_inode_index { 2 };
  27. unsigned next_inode_index();
  28. };
  29. }