init: create mount points if they don't exist
This commit is contained in:
parent
393df3f98f
commit
f4696f7551
|
@ -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),
|
||||||
|
|
Loading…
Reference in New Issue