aboutsummaryrefslogtreecommitdiff
path: root/kernel/include/kernel/filesystem/rootfs/filesystem.hpp
blob: 0155c41752efa0dddf3c1567c89f71028b1c049c (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
#ifndef TEACH_OS_KERNEL_FILESYSTEM_ROOTFS_FILESYSTEM_HPP
#define TEACH_OS_KERNEL_FILESYSTEM_ROOTFS_FILESYSTEM_HPP

#include "kapi/devices/device.hpp"

#include "kernel/filesystem/filesystem.hpp"
#include "kernel/filesystem/inode.hpp"

#include <kstd/memory>
#include <kstd/string>
#include <kstd/vector>

#include <string_view>

namespace kernel::filesystem::rootfs
{
  /**
  @brief A filesystem for the root filesystem. This filesystem provides access to the root directory and its contents,
  which are typically populated by the init process during system startup. The rootfs filesystem serves as the top-level
  directory in the filesystem hierarchy. It is responsible for providing a stable and consistent interface to the root
  directory.
  */
  struct filesystem : kernel::filesystem::filesystem
  {
    /**
    @brief Initializes the rootfs filesystem with the given @p device.
    @param device The device to mount (not required by rootfs).
    @return The result of the mount operation.
    */
    auto mount(kstd::shared_ptr<kapi::devices::device> const & device) -> operation_result override;

    /**
    @brief Looks up an inode by @p name within a @p parent directory.
    @param parent The parent directory inode.
    @param name The name of the inode to look up.
    @return A pointer to the found inode, or a null pointer if not found.
    */
    auto lookup(kstd::shared_ptr<kernel::filesystem::inode> const & parent, std::string_view name)
        -> kstd::shared_ptr<kernel::filesystem::inode> override;
  };
}  // namespace kernel::filesystem::rootfs

#endif