blob: e944424a5acd019b989777deeebd5796c9c397ed (
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
|
mod mounts;
mod pid_one;
use crate::mounts::fstab::FstabEntry;
use crate::mounts::rescue;
use crate::pid_one::check_pid;
// RULE: I will not use .expect() and .unwrap() in this project. This causes panic,
// which will affect stability.
fn main() -> Result<(), Box<dyn std::error::Error>> {
println!("Initializing your system.");
check_pid().expect("\x1b[31m * \x1b[0m Runned not as first process. init/src/pid_one.rs:8:8");
match FstabEntry::parse_fstab("/etc/fstab") {
Ok(entries) => {
println!("\x1b[32m * \x1b[0m Sucessfully parsed /etc/fstab.");
for entry in &entries {
let _ = entry.mount();
}
},
Err(error) => {
println!("\x1b[33m * \x1b[0m Looks like fstab broken. Mounting all without reading /etc/fstab.");
println!("\x1b[33m * \x1b[0m Error:\n {}", error);
let _ = rescue::mount_system();
// Minimal mounts without fstab, because /etc/fstab needs fixes :)
// Btw it should be used if fstab broken or has syntax-errors
// TODO: If fstab contains syntax errors, mount everything else that does not contain them through it anyway.
}
}
Ok(())
}
|