mirror of
https://github.com/asterinas/asterinas.git
synced 2025-06-08 21:06:48 +00:00
Remove the lazy_static
dependency
This commit is contained in:
parent
5313689d6f
commit
f762eb8913
4
Cargo.lock
generated
4
Cargo.lock
generated
@ -85,7 +85,6 @@ dependencies = [
|
||||
"bitflags 1.3.2",
|
||||
"component",
|
||||
"int-to-c-enum",
|
||||
"lazy_static",
|
||||
"log",
|
||||
"ostd",
|
||||
"spin 0.9.8",
|
||||
@ -125,7 +124,6 @@ dependencies = [
|
||||
"bitflags 1.3.2",
|
||||
"component",
|
||||
"int-to-c-enum",
|
||||
"lazy_static",
|
||||
"log",
|
||||
"ostd",
|
||||
"spin 0.9.8",
|
||||
@ -182,7 +180,6 @@ dependencies = [
|
||||
"int-to-c-enum",
|
||||
"intrusive-collections",
|
||||
"keyable-arc",
|
||||
"lazy_static",
|
||||
"lending-iterator",
|
||||
"libflate",
|
||||
"log",
|
||||
@ -1146,7 +1143,6 @@ dependencies = [
|
||||
"inherit-methods-macro",
|
||||
"int-to-c-enum",
|
||||
"intrusive-collections",
|
||||
"lazy_static",
|
||||
"linux-boot-params",
|
||||
"log",
|
||||
"multiboot2",
|
||||
|
@ -65,10 +65,6 @@ fixed = "1.28.0"
|
||||
[target.riscv64gc-unknown-none-elf.dependencies]
|
||||
riscv = { version = "0.11.1", features = ["s-mode"] }
|
||||
|
||||
[dependencies.lazy_static]
|
||||
version = "1.0"
|
||||
features = ["spin_no_std"]
|
||||
|
||||
[features]
|
||||
all = ["cvm_guest"]
|
||||
|
||||
|
@ -17,7 +17,3 @@ log = "0.4"
|
||||
static_assertions = "1.1.0"
|
||||
|
||||
[features]
|
||||
|
||||
[dependencies.lazy_static]
|
||||
version = "1.0"
|
||||
features = ["spin_no_std"]
|
||||
|
@ -17,7 +17,3 @@ log = "0.4"
|
||||
ascii = { version = "1.1", default-features = false, features = ["alloc"] }
|
||||
|
||||
[features]
|
||||
|
||||
[dependencies.lazy_static]
|
||||
version = "1.0"
|
||||
features = ["spin_no_std"]
|
||||
|
@ -2,6 +2,8 @@
|
||||
|
||||
use alloc::format;
|
||||
|
||||
use spin::Once;
|
||||
|
||||
use crate::{
|
||||
fs::{
|
||||
procfs::template::{FileOps, ProcFileBuilder},
|
||||
@ -22,7 +24,7 @@ impl FileSystemsFileOps {
|
||||
impl FileOps for FileSystemsFileOps {
|
||||
fn data(&self) -> Result<Vec<u8>> {
|
||||
let mut result = String::new();
|
||||
for fs in FILESYSTEM_TYPES.iter() {
|
||||
for fs in FILESYSTEM_TYPES.get().unwrap().iter() {
|
||||
if fs.is_nodev {
|
||||
result.push_str(&format!("nodev\t{}\n", fs.name));
|
||||
} else {
|
||||
@ -33,25 +35,15 @@ impl FileOps for FileSystemsFileOps {
|
||||
}
|
||||
}
|
||||
|
||||
lazy_static! {
|
||||
static ref FILESYSTEM_TYPES: Vec<FileSystemType> = {
|
||||
vec![
|
||||
FileSystemType::new("proc", true),
|
||||
FileSystemType::new("ramfs", true),
|
||||
FileSystemType::new("devpts", true),
|
||||
FileSystemType::new("ext2", false),
|
||||
FileSystemType::new("exfat", false),
|
||||
]
|
||||
};
|
||||
}
|
||||
pub(super) static FILESYSTEM_TYPES: Once<Vec<FileSystemType>> = Once::new();
|
||||
|
||||
struct FileSystemType {
|
||||
pub(super) struct FileSystemType {
|
||||
name: String,
|
||||
is_nodev: bool,
|
||||
}
|
||||
|
||||
impl FileSystemType {
|
||||
fn new(name: &str, is_nodev: bool) -> Self {
|
||||
pub(super) fn new(name: &str, is_nodev: bool) -> Self {
|
||||
FileSystemType {
|
||||
name: name.to_string(),
|
||||
is_nodev,
|
||||
|
@ -2,6 +2,7 @@
|
||||
|
||||
use core::sync::atomic::{AtomicU64, Ordering};
|
||||
|
||||
use filesystems::{FileSystemType, FILESYSTEM_TYPES};
|
||||
use loadavg::LoadAvgFileOps;
|
||||
use sys::SysDirOps;
|
||||
|
||||
@ -31,6 +32,18 @@ mod self_;
|
||||
mod sys;
|
||||
mod template;
|
||||
|
||||
pub(super) fn init() {
|
||||
FILESYSTEM_TYPES.call_once(|| {
|
||||
vec![
|
||||
FileSystemType::new("proc", true),
|
||||
FileSystemType::new("ramfs", true),
|
||||
FileSystemType::new("devpts", true),
|
||||
FileSystemType::new("ext2", false),
|
||||
FileSystemType::new("exfat", false),
|
||||
]
|
||||
});
|
||||
}
|
||||
|
||||
/// Magic number.
|
||||
const PROC_MAGIC: u64 = 0x9fa0;
|
||||
/// Root Inode ID.
|
||||
|
@ -8,7 +8,7 @@ use spin::Once;
|
||||
use super::{
|
||||
fs_resolver::{FsPath, FsResolver},
|
||||
path::MountNode,
|
||||
procfs::ProcFS,
|
||||
procfs::{self, ProcFS},
|
||||
ramfs::RamFS,
|
||||
utils::{FileSystem, InodeMode, InodeType},
|
||||
};
|
||||
@ -17,6 +17,7 @@ use crate::prelude::*;
|
||||
/// Unpack and prepare the rootfs from the initramfs CPIO buffer.
|
||||
pub fn init(initramfs_buf: &[u8]) -> Result<()> {
|
||||
init_root_mount();
|
||||
procfs::init();
|
||||
|
||||
println!("[kernel] unpacking the initramfs.cpio.gz to rootfs ...");
|
||||
let fs = FsResolver::new();
|
||||
|
@ -100,6 +100,7 @@ pub fn init() {
|
||||
sched::init();
|
||||
fs::rootfs::init(boot::initramfs()).unwrap();
|
||||
device::init().unwrap();
|
||||
syscall::init();
|
||||
vdso::init();
|
||||
process::init();
|
||||
}
|
||||
|
@ -47,8 +47,6 @@ macro_rules! current_thread {
|
||||
};
|
||||
}
|
||||
|
||||
pub(crate) use lazy_static::lazy_static;
|
||||
|
||||
pub(crate) use crate::{
|
||||
context::{Context, CurrentUserSpace, ReadCString},
|
||||
current, current_thread,
|
||||
|
@ -360,3 +360,7 @@ macro_rules! log_syscall_entry {
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
pub(super) fn init() {
|
||||
uname::init();
|
||||
}
|
||||
|
@ -1,29 +1,13 @@
|
||||
// SPDX-License-Identifier: MPL-2.0
|
||||
|
||||
use spin::Once;
|
||||
|
||||
use super::SyscallReturn;
|
||||
use crate::prelude::*;
|
||||
|
||||
// We don't use the real name and version of our os here. Instead, we pick up fake values witch is the same as the ones of linux.
|
||||
// The values are used to fool glibc since glibc will check the version and os name.
|
||||
lazy_static! {
|
||||
/// used to fool glibc
|
||||
static ref SYS_NAME: CString = CString::new("Linux").unwrap();
|
||||
static ref NODE_NAME: CString = CString::new("WHITLEY").unwrap();
|
||||
static ref RELEASE: CString = CString::new("5.13.0").unwrap();
|
||||
static ref VERSION: CString = CString::new("5.13.0").unwrap();
|
||||
static ref MACHINE: CString = CString::new("x86_64").unwrap();
|
||||
static ref DOMAIN_NAME: CString = CString::new("").unwrap();
|
||||
static ref UTS_NAME: UtsName = {
|
||||
let mut uts_name = UtsName::new();
|
||||
copy_cstring_to_u8_slice(&SYS_NAME, &mut uts_name.sysname);
|
||||
copy_cstring_to_u8_slice(&NODE_NAME, &mut uts_name.nodename);
|
||||
copy_cstring_to_u8_slice(&RELEASE, &mut uts_name.release);
|
||||
copy_cstring_to_u8_slice(&VERSION, &mut uts_name.version);
|
||||
copy_cstring_to_u8_slice(&MACHINE, &mut uts_name.machine);
|
||||
copy_cstring_to_u8_slice(&DOMAIN_NAME, &mut uts_name.domainname);
|
||||
uts_name
|
||||
};
|
||||
}
|
||||
static UTS_NAME: Once<UtsName> = Once::new();
|
||||
|
||||
const UTS_FIELD_LEN: usize = 65;
|
||||
|
||||
@ -51,14 +35,28 @@ impl UtsName {
|
||||
}
|
||||
}
|
||||
|
||||
fn copy_cstring_to_u8_slice(src: &CStr, dst: &mut [u8]) {
|
||||
let src = src.to_bytes_with_nul();
|
||||
let len = src.len().min(dst.len());
|
||||
dst[..len].copy_from_slice(&src[..len]);
|
||||
pub(super) fn init() {
|
||||
UTS_NAME.call_once(|| {
|
||||
let copy_slice = |src: &[u8], dst: &mut [u8]| {
|
||||
let len = src.len().min(dst.len());
|
||||
dst[..len].copy_from_slice(&src[..len]);
|
||||
};
|
||||
|
||||
let mut uts_name = UtsName::new();
|
||||
copy_slice(b"Linux", &mut uts_name.sysname);
|
||||
copy_slice(b"WHITLEY", &mut uts_name.nodename);
|
||||
copy_slice(b"5.13.0", &mut uts_name.release);
|
||||
copy_slice(b"5.13.0", &mut uts_name.version);
|
||||
copy_slice(b"x86_64", &mut uts_name.machine);
|
||||
copy_slice(b"", &mut uts_name.domainname);
|
||||
|
||||
uts_name
|
||||
});
|
||||
}
|
||||
|
||||
pub fn sys_uname(old_uname_addr: Vaddr, ctx: &Context) -> Result<SyscallReturn> {
|
||||
debug!("old uname addr = 0x{:x}", old_uname_addr);
|
||||
ctx.user_space().write_val(old_uname_addr, &*UTS_NAME)?;
|
||||
ctx.user_space()
|
||||
.write_val(old_uname_addr, UTS_NAME.get().unwrap())?;
|
||||
Ok(SyscallReturn::Return(0))
|
||||
}
|
||||
|
@ -17,7 +17,6 @@ env_logger = "0.11.0"
|
||||
inferno = "0.11.21"
|
||||
indexmap = "2.2.1"
|
||||
indicatif = "0.17.8" # For a commandline progress bar
|
||||
lazy_static = "1.4.0"
|
||||
log = "0.4.20"
|
||||
quote = "1.0.35"
|
||||
regex = "1.10.4"
|
||||
|
@ -27,7 +27,6 @@ id-alloc = { path = "libs/id-alloc", version = "0.1.0" }
|
||||
inherit-methods-macro = { git = "https://github.com/asterinas/inherit-methods-macro", rev = "98f7e3e", version = "0.1.0" }
|
||||
int-to-c-enum = { path = "../kernel/libs/int-to-c-enum", version = "0.1.0" }
|
||||
intrusive-collections = { version = "0.9.6", features = ["nightly"] }
|
||||
lazy_static = { version = "1.0", features = ["spin_no_std"] }
|
||||
linux-boot-params = { version = "0.9.4", path = "libs/linux-bzimage/boot-params" }
|
||||
log = "0.4"
|
||||
num = { version = "0.4", default-features = false }
|
||||
|
Loading…
x
Reference in New Issue
Block a user