diff options
author | HimbeerserverDE <himbeerserverde@gmail.com> | 2023-02-20 19:15:22 +0100 |
---|---|---|
committer | HimbeerserverDE <himbeerserverde@gmail.com> | 2023-02-20 19:15:22 +0100 |
commit | 1ebed3cdd68f75bffe4bd4efeb172a15eb3d1cc3 (patch) | |
tree | 7f7e88d5d5e2cfd8bd1144d8dcc3dfab12587b00 | |
parent | 4ff1b3816194543aba53512f559e144979227f3d (diff) |
try multiple boot locations
-rw-r--r-- | src/main.rs | 47 |
1 files changed, 34 insertions, 13 deletions
diff --git a/src/main.rs b/src/main.rs index 1f0ec29..b94a548 100644 --- a/src/main.rs +++ b/src/main.rs @@ -48,29 +48,50 @@ fn start() -> anyhow::Result<()> { fn main() -> ExitCode { let mut stdout = StandardStream::stdout(ColorChoice::Always); - let _mount; - - match Mount::builder() - .fstype("vfat") - .mount("/dev/disk/by-partuuid/00000000-01", "/boot") - { - Ok(v) => _mount = v.into_unmount_drop(UnmountFlags::DETACH), - Err(e) => { + let mut mount = None; + let mut mount_err = None; + + let devs = ["/dev/mmcblk0p1", "/dev/sda1", "/dev/vda1"]; + + for dev in devs { + match Mount::builder().fstype("vfat").mount(dev, "/boot") { + Ok(v) => mount = Some(v.into_unmount_drop(UnmountFlags::DETACH)), + Err(e) => { + mount_err = Some(e); + } + }; + } + + if mount.is_none() { + if let Some(e) = mount_err { match stdout.set_color(ColorSpec::new().set_fg(Some(Color::Red))) { Ok(_) => match writeln!(&mut stdout, "[ ERROR ] Can't mount /boot: {}", e) { Ok(_) => {} Err(_) => println!("[ ERROR ] Can't mount /boot: {}", e), }, + Err(_) => println!("[ ERROR ] Can't mount /boot: {}", e), + } + } else { + match stdout.set_color(ColorSpec::new().set_fg(Some(Color::Red))) { + Ok(_) => match writeln!( + &mut stdout, + "[ ERROR ] Can't mount /boot: Unknown error (this shouldn't happen)" + ) { + Ok(_) => {} + Err(_) => println!( + "[ ERROR ] Can't mount /boot: Unknown error (this shouldn't happen)" + ), + }, Err(_) => { - println!("[ ERROR ] Can't mount /boot: {}", e); + println!("[ ERROR ] Can't mount /boot: Unknown error (this shouldn't happen)") } } + } - loop { - thread::sleep(Duration::MAX); - } + loop { + thread::sleep(Duration::MAX); } - }; + } if process::id() != 1 { match stdout.set_color(ColorSpec::new().set_fg(Some(Color::Red))) { |