Add an initial script to mount several file systems
This commit is contained in:
parent
df69af324e
commit
749fe77591
|
|
@ -7,12 +7,9 @@ use libflate::gzip::Decoder as GZipDecoder;
|
|||
use spin::Once;
|
||||
|
||||
use super::{
|
||||
cgroupfs::{init as cgroupfs_init, singleton as cgroupfs_singleton},
|
||||
fs_resolver::{FsPath, FsResolver},
|
||||
path::MountNode,
|
||||
procfs::{self, ProcFS},
|
||||
ramfs::RamFS,
|
||||
sysfs::{init as sysfs_init, singleton as sysfs_singleton},
|
||||
utils::{FileSystem, InodeMode, InodeType},
|
||||
};
|
||||
use crate::{fs::path::is_dot, prelude::*};
|
||||
|
|
@ -108,22 +105,9 @@ pub fn init(initramfs_buf: &[u8]) -> Result<()> {
|
|||
}
|
||||
}
|
||||
}
|
||||
// Mount ProcFS
|
||||
let proc_dentry = fs.lookup(&FsPath::try_from("/proc")?)?;
|
||||
proc_dentry.mount(ProcFS::new())?;
|
||||
// Mount DevFS
|
||||
let dev_dentry = fs.lookup(&FsPath::try_from("/dev")?)?;
|
||||
dev_dentry.mount(RamFS::new())?;
|
||||
// Mount SysFS
|
||||
let sys_dentry = fs.lookup(&FsPath::try_from("/sys")?)?;
|
||||
sysfs_init();
|
||||
let sysfs: Arc<dyn FileSystem> = sysfs_singleton().clone();
|
||||
sys_dentry.mount(sysfs)?;
|
||||
// Mount CgroupFs
|
||||
cgroupfs_init();
|
||||
let cgroup_dentry = fs.lookup(&FsPath::try_from("/sys/fs/cgroup")?)?;
|
||||
let cgroupfs: Arc<dyn FileSystem> = cgroupfs_singleton().clone();
|
||||
cgroup_dentry.mount(cgroupfs)?;
|
||||
|
||||
println!("[kernel] rootfs is ready");
|
||||
Ok(())
|
||||
|
|
|
|||
|
|
@ -0,0 +1,9 @@
|
|||
#!/bin/sh
|
||||
|
||||
# SPDX-License-Identifier: MPL-2.0
|
||||
|
||||
# TODO: This script simulates the process of mounting filesystems as performed by
|
||||
# a generic init process. It should later be replaced by the actual init process.
|
||||
mount -t sysfs none /sys
|
||||
mount -t proc none /proc
|
||||
mount -t cgroup2 none /sys/fs/cgroup
|
||||
|
|
@ -0,0 +1,6 @@
|
|||
# FIXME: Mounting FSes via /etc/profile is fragile (risk of multiple mounts from
|
||||
# login shells). Throw away this operation when we have a proper initial process.
|
||||
|
||||
if [ -f /test/init.sh ]; then
|
||||
. /test/init.sh
|
||||
fi
|
||||
Loading…
Reference in New Issue