1 | #include "mount.hpp" |
---|---|
2 | |
3 | #include <mos/syscall/usermode.h> |
4 | |
5 | bool Mount::do_start() |
6 | { |
7 | if (syscall_vfs_mount(device: device.c_str(), mount_point: mount_point.c_str(), fs_type: fs_type.c_str(), options: options.c_str()) != 0) |
8 | { |
9 | m_error = strerror(errno); |
10 | return false; |
11 | } |
12 | |
13 | return true; |
14 | } |
15 | |
16 | bool Mount::do_stop() |
17 | { |
18 | std::cout << "stopping mount "<< id << std::endl; |
19 | return true; |
20 | } |
21 | |
22 | bool Mount::do_load(const toml::table &data) |
23 | { |
24 | const auto mount = data["mount"].as_table(); |
25 | if (!mount) |
26 | { |
27 | std::cerr << "bad mount table"<< std::endl; |
28 | return false; |
29 | } |
30 | |
31 | this->mount_point = (*mount)["mount_point"].value_or(default_value: "unknown"); |
32 | this->fs_type = (*mount)["fs_type"].value_or(default_value: "unknown"); |
33 | this->options = (*mount)["options"].value_or(default_value: "unknown"); |
34 | this->device = (*mount)["device"].value_or(default_value: "unknown"); |
35 | |
36 | return true; |
37 | } |
38 | |
39 | void Mount::do_print(std::ostream &os) const |
40 | { |
41 | os << " mount_point: "<< this->mount_point << std::endl; |
42 | os << " fs_type: "<< this->fs_type << std::endl; |
43 | os << " options: "<< this->options << std::endl; |
44 | os << " device: "<< this->device << std::endl; |
45 | } |
46 |