feat(log): 将内核日志统一为新的logger (#814)

This commit is contained in:
曾俊
2024-05-16 17:25:23 +08:00
committed by GitHub
parent 92deae638b
commit 2eab6dd743
181 changed files with 1321 additions and 1261 deletions

View File

@ -5,6 +5,7 @@ use crate::{
};
use alloc::vec::Vec;
use core::cmp;
use log::warn;
use system_error::SystemError;
use super::{user_access::UserBufferWriter, Syscall};
@ -59,7 +60,7 @@ impl Syscall {
}
pub fn umask(_mask: u32) -> Result<usize, SystemError> {
kwarn!("SYS_UMASK has not yet been implemented\n");
warn!("SYS_UMASK has not yet been implemented\n");
return Ok(0o777);
}

View File

@ -20,6 +20,7 @@ use crate::{
syscall::user_access::check_and_clone_cstr,
};
use log::{info, warn};
use num_traits::FromPrimitive;
use system_error::SystemError;
@ -31,7 +32,6 @@ use crate::{
syscall::{ModeType, PosixKstat},
MAX_PATHLEN,
},
kinfo,
libs::align::page_align_up,
mm::{verify_area, MemoryManagementArch, VirtAddr},
net::syscall::SockAddr,
@ -69,9 +69,9 @@ impl Syscall {
if prev {
panic!("Cannot initialize syscall more than once!");
}
kinfo!("Initializing syscall...");
info!("Initializing syscall...");
let r = crate::arch::syscall::arch_syscall_init();
kinfo!("Syscall init successfully!");
info!("Syscall init successfully!");
return r;
}
@ -369,7 +369,7 @@ impl Syscall {
SYS_KILL => {
let pid = Pid::new(args[0]);
let sig = args[1] as c_int;
// kdebug!("KILL SYSCALL RECEIVED");
// debug!("KILL SYSCALL RECEIVED");
Self::kill(pid, sig)
}
@ -383,7 +383,7 @@ impl Syscall {
SYS_GETPID => Self::getpid().map(|pid| pid.into()),
SYS_SCHED => {
kwarn!("syscall sched");
warn!("syscall sched");
schedule(SchedMode::SM_NONE);
Ok(0)
}
@ -650,7 +650,7 @@ impl Syscall {
Err(SystemError::EINVAL)
};
// kdebug!("FCNTL: fd: {}, cmd: {:?}, arg: {}, res: {:?}", fd, cmd, arg, res);
// debug!("FCNTL: fd: {}, cmd: {:?}, arg: {}, res: {:?}", fd, cmd, arg, res);
res
}
@ -658,7 +658,7 @@ impl Syscall {
let fd = args[0] as i32;
let len = args[1];
let res = Self::ftruncate(fd, len);
// kdebug!("FTRUNCATE: fd: {}, len: {}, res: {:?}", fd, len, res);
// debug!("FTRUNCATE: fd: {}, len: {}, res: {:?}", fd, len, res);
res
}
@ -835,32 +835,32 @@ impl Syscall {
#[cfg(target_arch = "x86_64")]
SYS_POLL => {
kwarn!("SYS_POLL has not yet been implemented");
warn!("SYS_POLL has not yet been implemented");
Ok(0)
}
SYS_SETPGID => {
kwarn!("SYS_SETPGID has not yet been implemented");
warn!("SYS_SETPGID has not yet been implemented");
Ok(0)
}
SYS_RT_SIGPROCMASK => {
kwarn!("SYS_RT_SIGPROCMASK has not yet been implemented");
warn!("SYS_RT_SIGPROCMASK has not yet been implemented");
Ok(0)
}
SYS_TKILL => {
kwarn!("SYS_TKILL has not yet been implemented");
warn!("SYS_TKILL has not yet been implemented");
Ok(0)
}
SYS_SIGALTSTACK => {
kwarn!("SYS_SIGALTSTACK has not yet been implemented");
warn!("SYS_SIGALTSTACK has not yet been implemented");
Ok(0)
}
SYS_EXIT_GROUP => {
kwarn!("SYS_EXIT_GROUP has not yet been implemented");
warn!("SYS_EXIT_GROUP has not yet been implemented");
Ok(0)
}
@ -891,15 +891,15 @@ impl Syscall {
SYS_GETGID => Self::getgid(),
SYS_SETUID => {
kwarn!("SYS_SETUID has not yet been implemented");
warn!("SYS_SETUID has not yet been implemented");
Ok(0)
}
SYS_SETGID => {
kwarn!("SYS_SETGID has not yet been implemented");
warn!("SYS_SETGID has not yet been implemented");
Ok(0)
}
SYS_SETSID => {
kwarn!("SYS_SETSID has not yet been implemented");
warn!("SYS_SETSID has not yet been implemented");
Ok(0)
}
SYS_GETEUID => Self::geteuid(),
@ -975,17 +975,17 @@ impl Syscall {
}
SYS_FCHOWN => {
kwarn!("SYS_FCHOWN has not yet been implemented");
warn!("SYS_FCHOWN has not yet been implemented");
Ok(0)
}
SYS_FSYNC => {
kwarn!("SYS_FSYNC has not yet been implemented");
warn!("SYS_FSYNC has not yet been implemented");
Ok(0)
}
SYS_RSEQ => {
kwarn!("SYS_RSEQ has not yet been implemented");
warn!("SYS_RSEQ has not yet been implemented");
Ok(0)
}

View File

@ -116,7 +116,7 @@ pub fn check_and_clone_cstr_array(user: *const *const u8) -> Result<Vec<String>,
if user.is_null() {
Ok(Vec::new())
} else {
// kdebug!("check_and_clone_cstr_array: {:p}\n", user);
// debug!("check_and_clone_cstr_array: {:p}\n", user);
let mut buffer = Vec::new();
for i in 0.. {
let addr = unsafe { user.add(i) };
@ -129,7 +129,7 @@ pub fn check_and_clone_cstr_array(user: *const *const u8) -> Result<Vec<String>,
let dst = core::mem::transmute::<[u8; size_of::<usize>()], [usize; 1]>(dst);
str_ptr = dst[0] as *const u8;
// kdebug!("str_ptr: {:p}, addr:{addr:?}\n", str_ptr);
// debug!("str_ptr: {:p}, addr:{addr:?}\n", str_ptr);
}
if str_ptr.is_null() {