From 7bf851d9e42b795a7fdb8a8a4f8911b72ed20d24 Mon Sep 17 00:00:00 2001 From: HimbeerserverDE Date: Mon, 13 Nov 2023 19:53:40 +0100 Subject: move pid check to top of main --- src/main.rs | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/src/main.rs b/src/main.rs index 0b0ff19..bf254c1 100644 --- a/src/main.rs +++ b/src/main.rs @@ -224,6 +224,11 @@ fn mount_or_halt(part_id: u8, mount_point: &str, fs: &str) -> UnmountDrop } fn main() -> ExitCode { + if process::id() != 1 { + log!(Color::Red, "[ ERROR ] must be run as PID 1"); + halt!(); + } + let _boot_handle = mount_or_halt(1, "/boot", "vfat"); let _data_handle = mount_or_halt(4, "/data", "ext4"); let _proc_handle = Mount::builder() @@ -239,11 +244,6 @@ fn main() -> ExitCode { .mount("tmpfs", "/run") .expect("can't mount /run tmpfs"); - if process::id() != 1 { - log!(Color::Red, "[ ERROR ] must be run as PID 1"); - halt!(); - } - match start() { Ok(_) => {} Err(e) => log!(Color::Red, "[ ERROR ] {}", e), -- cgit v1.2.3