summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--.vscode/launch.json58
-rw-r--r--README.md42
-rw-r--r--init/src/main.rs2
-rw-r--r--init/src/mounts/fstab.rs13
-rw-r--r--init/src/mounts/mod.rs4
-rw-r--r--init/src/mounts/rescue.rs2
-rw-r--r--init/src/pid_one.rs2
7 files changed, 94 insertions, 29 deletions
diff --git a/.vscode/launch.json b/.vscode/launch.json
new file mode 100644
index 0000000..2519d97
--- /dev/null
+++ b/.vscode/launch.json
@@ -0,0 +1,58 @@
+{
+ // Use IntelliSense to learn about possible attributes.
+ // Hover to view descriptions of existing attributes.
+ // For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387
+ "version": "0.2.0",
+ "configurations": [
+ {
+ "name": "Debug executable 'init'",
+ "type": "lldb",
+ "request": "launch",
+ "cargo": {
+ "args": [
+ "run",
+ "--bin=init",
+ "--package=init"
+ ]
+ },
+ "args": []
+ },
+ {
+ "name": "Debug unit tests in executable 'init'",
+ "type": "lldb",
+ "request": "launch",
+ "cargo": {
+ "args": [
+ "test",
+ "--bin=init",
+ "--package=init"
+ ]
+ }
+ },
+ {
+ "name": "Debug executable 'vegilctl'",
+ "type": "lldb",
+ "request": "launch",
+ "cargo": {
+ "args": [
+ "run",
+ "--bin=vegilctl",
+ "--package=vegilctl"
+ ]
+ },
+ "args": []
+ },
+ {
+ "name": "Debug unit tests in executable 'vegilctl'",
+ "type": "lldb",
+ "request": "launch",
+ "cargo": {
+ "args": [
+ "test",
+ "--bin=vegilctl",
+ "--package=vegilctl"
+ ]
+ }
+ }
+ ]
+} \ No newline at end of file
diff --git a/README.md b/README.md
index eb1b156..820e3dd 100644
--- a/README.md
+++ b/README.md
@@ -1,18 +1,24 @@
-# Vigil
-Vigil is an init system (PID 1) developed for the Antrhill distribution and licensed under GPL2.0-only.
-
-The development is based on the Unix philosophy:
-- **"Make each program do one thing well."**
- - Doug McIlroy
-
-- **"Write programs that do one thing and do it well. Write programs to work together."**
- - Peter H. Salus, summarizing Unix philosophy
-
-- **"The UNIX system is characterized by: [...] A unified view of I/O, and a hierarchical file system. A small number of kernel primitives, augmented by a rich set of user-level tools."**
- - Ritchie & Thompson, «The UNIX Time-Sharing System»
-
-`vegil` strives to be indestructible, something that even in the case of most errors will boot you into the system. If not, then go to rescue mode with all the tools installed.
-
-# Development
-This repo contains the source code of the `init` executable itself and `vegilctl`, for managing the initialization system.
-At the moment, the init binary itself is a priority for development. \ No newline at end of file
+# Vigil
+Vigil is an init system (PID 1) developed for the Antrhill distribution and licensed under GPL2.0-only.
+
+The development is based on the Unix philosophy:
+- **"Make each program do one thing well."**
+ - Doug McIlroy
+
+- **"Write programs that do one thing and do it well. Write programs to work together."**
+ - Peter H. Salus, summarizing Unix philosophy
+
+- **"The UNIX system is characterized by: [...] A unified view of I/O, and a hierarchical file system. A small number of kernel primitives, augmented by a rich set of user-level tools."**
+ - Ritchie & Thompson, «The UNIX Time-Sharing System»
+
+`vegil` strives to be indestructible, something that even in the case of most errors will boot you into the system. If not, then go to rescue mode with all the tools installed.
+
+# Development
+This repo contains the source code of the `init` executable itself and `vegilctl`, for managing the initialization system.
+At the moment, the init binary itself is a priority for development.
+
+# Usage
+All operations are logged and start with `*` and looks like `* <Operation> <Data>`, it has three colors:
+- Red (`\x1b[31m`) - This means that a mission-critical operation has failed, and you will most likely go into rescue mode.
+- Yellow (`\x1b[33m`) - It means that the operation specified by the user in the configuration or not critical has failed, the system will start, but it is better to pay attention to this.
+- Green (`\x1b[32m`) - Everything is in order. \ No newline at end of file
diff --git a/init/src/main.rs b/init/src/main.rs
index bfcef87..1138ccf 100644
--- a/init/src/main.rs
+++ b/init/src/main.rs
@@ -5,6 +5,6 @@ use crate::pid_one::check_pid;
fn main() -> Result<(), Box<dyn std::error::Error>> {
println!("Initializing your system.");
- check_pid().expect("Runned not as PID 1.");
+ check_pid().expect("\x1b[31m * \x1b[0m Runned not as first process. init/src/pid_one.rs:8:8");
Ok(())
}
diff --git a/init/src/mounts/fstab.rs b/init/src/mounts/fstab.rs
index 4c43eac..0765cfd 100644
--- a/init/src/mounts/fstab.rs
+++ b/init/src/mounts/fstab.rs
@@ -47,9 +47,6 @@ fn parse_mount_options(
Ok((flags, data))
}
-
-
-
pub fn mount_from_fstab(entries: &[FstabEntry]) -> Result<(), Box<dyn std::error::Error>> {
for entry in entries {
if entry.fstype == "swap" {
@@ -62,7 +59,7 @@ pub fn mount_from_fstab(entries: &[FstabEntry]) -> Result<(), Box<dyn std::error
}
if entry.options.contains("noauto") {
- continue;
+ continue;
}
let (flags, data) = parse_mount_options(&entry.options)?;
@@ -88,9 +85,13 @@ pub fn mount_from_fstab(entries: &[FstabEntry]) -> Result<(), Box<dyn std::error
};
if ret != 0 {
- eprintln!("Failed to mount {}: {}", entry.mountpoint, std::io::Error::last_os_error());
+ eprintln!(
+ "\x1b[31m * \x1b[0m Failed to mount {}: {}",
+ entry.mountpoint,
+ std::io::Error::last_os_error()
+ );
} else {
- println!("Mounted {}", entry.mountpoint);
+ println!("\x1b[32m * \x1b[0m Mounted {}", entry.mountpoint);
}
}
Ok(())
diff --git a/init/src/mounts/mod.rs b/init/src/mounts/mod.rs
index bdaab24..0de3baf 100644
--- a/init/src/mounts/mod.rs
+++ b/init/src/mounts/mod.rs
@@ -1,2 +1,2 @@
-pub mod fstab;
-pub mod rescue; \ No newline at end of file
+pub mod fstab;
+pub mod rescue;
diff --git a/init/src/mounts/rescue.rs b/init/src/mounts/rescue.rs
index 84a8df1..11fa8fe 100644
--- a/init/src/mounts/rescue.rs
+++ b/init/src/mounts/rescue.rs
@@ -39,7 +39,7 @@ pub fn mount_system() -> Result<(), Box<dyn std::error::Error>> {
)
.into());
}
- println!("\x1b[32m * \x1b[0m Mounting {}...", target );
+ println!("\x1b[32m * \x1b[0m Mounting {}...", target);
}
}
diff --git a/init/src/pid_one.rs b/init/src/pid_one.rs
index 84cca47..e4034ad 100644
--- a/init/src/pid_one.rs
+++ b/init/src/pid_one.rs
@@ -5,6 +5,6 @@ pub fn check_pid() -> Result<(), Box<dyn std::error::Error>> {
match pid {
1 => Ok(()),
- _ => Err("Runned not as first process.".into()),
+ _ => Err(format!("Current PID: {}", pid).into()),
}
}