Compare commits

...

1 Commits

Author SHA1 Message Date
Ryan Heywood f4696f7551
init: create mount points if they don't exist 2024-10-16 20:50:00 -04:00
1 changed files with 6 additions and 1 deletions

View File

@ -9,7 +9,6 @@ fn init_rootfs() {
let no_dse = MS_NODEV | MS_NOSUID | MS_NOEXEC; let no_dse = MS_NODEV | MS_NOSUID | MS_NOEXEC;
let no_se = MS_NOSUID | MS_NOEXEC; let no_se = MS_NOSUID | MS_NOEXEC;
let args = [ let args = [
("devtmpfs", "/dev", "devtmpfs", no_se, "mode=0755"),
("devtmpfs", "/dev", "devtmpfs", no_se, "mode=0755"), ("devtmpfs", "/dev", "devtmpfs", no_se, "mode=0755"),
("devpts", "/dev/pts", "devpts", no_se, ""), ("devpts", "/dev/pts", "devpts", no_se, ""),
("shm", "/dev/shm", "tmpfs", no_dse, "mode=0755"), ("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"), ("cgroup_root", "/sys/fs/cgroup", "tmpfs", no_dse, "mode=0755"),
]; ];
for (src, target, fstype, flags, data) in args { 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) { match mount(src, target, fstype, flags, data) {
Ok(())=> dmesg(format!("Mounted {}", target)), Ok(())=> dmesg(format!("Mounted {}", target)),
Err(e)=> eprintln!("{}", e), Err(e)=> eprintln!("{}", e),