summaryrefslogtreecommitdiffhomepage
path: root/dev/kernel/src/FileMgr.cc
blob: 88b17470f2c4f171778e57fee9a1a016761ca957 (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
44
45
46
47
48
49
/* ========================================

  Copyright (C) 2024-2025, Amlal El Mahrouss, licensed under the Apache 2.0 license.

======================================== */

#include <KernelKit/FileMgr.h>
#include <NeKit/Utils.h>

/***********************************************************************************/
/// @file FileMgr.cc
//! @brief File System Manager API.
///! @author Amlal El Mahrouss (amlal@nekernel.org)
/***********************************************************************************/

namespace Kernel {
STATIC IFilesystemMgr* kMountedFilesystem = nullptr;

/// @brief FilesystemMgr getter.
/// @return The mounted filesystem.
_Output IFilesystemMgr* IFilesystemMgr::GetMounted() {
  return kMountedFilesystem;
}

/// @brief Unmount filesystem.
/// @return The unmounted filesystem.
_Output IFilesystemMgr* IFilesystemMgr::Unmount() {
  if (kMountedFilesystem) {
    auto mount         = kMountedFilesystem;
    kMountedFilesystem = nullptr;

    return mount;
  }

  return nullptr;
}

/// @brief Mount filesystem.
/// @param mount_ptr The filesystem to mount.
/// @return if it succeeded true, otherwise false.
_Output Bool IFilesystemMgr::Mount(_Input IFilesystemMgr* mount_ptr) {
  if (mount_ptr != nullptr) {
    kMountedFilesystem = mount_ptr;
    return Yes;
  }

  return No;
}
}  // namespace Kernel