From f4696f75517e09f02f2d46e5864ff59eb95ea8c9 Mon Sep 17 00:00:00 2001 From: ryan Date: Wed, 16 Oct 2024 20:50:00 -0400 Subject: [PATCH] init: create mount points if they don't exist --- src/init/init.rs | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/init/init.rs b/src/init/init.rs index 01ce125..27ee6da 100644 --- a/src/init/init.rs +++ b/src/init/init.rs @@ -9,7 +9,6 @@ fn init_rootfs() { let no_dse = MS_NODEV | MS_NOSUID | MS_NOEXEC; let no_se = MS_NOSUID | MS_NOEXEC; let args = [ - ("devtmpfs", "/dev", "devtmpfs", no_se, "mode=0755"), ("devtmpfs", "/dev", "devtmpfs", no_se, "mode=0755"), ("devpts", "/dev/pts", "devpts", no_se, ""), ("shm", "/dev/shm", "tmpfs", no_dse, "mode=0755"), @@ -20,6 +19,12 @@ fn init_rootfs() { ("cgroup_root", "/sys/fs/cgroup", "tmpfs", no_dse, "mode=0755"), ]; for (src, target, fstype, flags, data) in args { + if std::fs::exists(target).unwrap_or(false) { + match std::fs::create_dir_all(target) { + Ok(()) => dmesg(format!("Created mount point {}", target)), + Err(e) => eprintln!("{}", e), + } + } match mount(src, target, fstype, flags, data) { Ok(())=> dmesg(format!("Mounted {}", target)), Err(e)=> eprintln!("{}", e),