blob: fb2a40dc52180574069bf78ed7b38b4c1bf397f7 (
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
50
|
// Copyright 2024-2026, Amlal El Mahrouss (amlal@nekernel.org)
// Licensed under the Apache License, Version 2.0 (see LICENSE file)
// Official repository: https://github.com/nekernel-org/nekernel
#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() {
MUST_PASS(kMountedFilesystem && kMountedFilesystem->GetMounted());
return kMountedFilesystem;
}
/// @brief Unmount filesystem.
/// @return The unmounted filesystem.
_Output IFilesystemMgr* IFilesystemMgr::Unmount() {
if (kMountedFilesystem) {
auto mount = kMountedFilesystem;
MUST_PASS(mount->GetMounted());
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
|