rustubs/
fs.rs

1//! simple in memory fs that is statically linked into the kernel image
2
3// symbols provided by linker
4pub mod ustar;
5use crate::defs::ExternSyms::{___RAMFS_END__, ___RAMFS_START__};
6use crate::proc::loader;
7use core::slice;
8use core::str;
9pub use ustar::iter;
10pub use ustar::UstarFile as File;
11
12/// get an raw archive of the fstar fs slice
13pub fn get_archive<'a>() -> &'a [u8] {
14	let len = ___RAMFS_END__ as usize - ___RAMFS_START__ as usize;
15	let ramfs: &[u8] =
16		unsafe { slice::from_raw_parts_mut(___RAMFS_START__ as *mut u8, len) };
17	ramfs
18}
19
20pub fn cat(f: &File) {
21	match str::from_utf8(f.file) {
22		Ok(s) => println!("{}", s),
23		_ => loader::cat_elf(f),
24	}
25}