diff --git a/kernel/src/syscall/sysinfo.rs b/kernel/src/syscall/sysinfo.rs index 989c122ef..ef4c8eed2 100644 --- a/kernel/src/syscall/sysinfo.rs +++ b/kernel/src/syscall/sysinfo.rs @@ -1,6 +1,7 @@ // SPDX-License-Identifier: MPL-2.0 use aster_time::read_monotonic_time; +use ostd::mm::stat::{mem_total, mem_available}; use super::SyscallReturn; use crate::prelude::*; @@ -8,23 +9,25 @@ use crate::prelude::*; #[derive(Debug, Default, Clone, Copy, Pod)] #[repr(C)] pub struct sysinfo { - uptime: i64, - loads: [u64; 3], - totalram: u64, - freeram: u64, - sharedram: u64, - bufferram: u64, - totalswap: u64, - freeswap: u64, - procs: u16, - totalhigh: u64, - freehigh: u64, - mem_unit: u32, + uptime: i64, /* Seconds since boot */ + loads: [u64; 3], /* 1, 5, and 15 minute load averages */ + totalram: u64, /* Total usable main memory size */ + freeram: u64, /* Available memory size */ + sharedram: u64, /* Amount of shared memory */ + bufferram: u64, /* Memory used by buffers */ + totalswap: u64, /* Total swap space size */ + freeswap: u64, /* swap space still available */ + procs: u16, /* Number of current processes */ + totalhigh: u64, /* Total high memory size */ + freehigh: u64, /* Available high memory size */ + mem_unit: u32, /* Memory unit size in bytes */ } pub fn sys_sysinfo(sysinfo_addr: Vaddr, ctx: &Context) -> Result { let info = sysinfo { uptime: read_monotonic_time().as_secs() as i64, + totalram: mem_total() as u64, + freeram: mem_available() as u64, ..Default::default() // TODO: add other system information }; ctx.user_space().write_val(sysinfo_addr, &info)?; diff --git a/test/syscall_test/blocklists/sysinfo_test b/test/syscall_test/blocklists/sysinfo_test index 772d881a2..a5f258fa6 100644 --- a/test/syscall_test/blocklists/sysinfo_test +++ b/test/syscall_test/blocklists/sysinfo_test @@ -1,4 +1,2 @@ -SysinfoTest.TotalRamSaneValue SysinfoTest.MemunitSet -SysinfoTest.FreeRamSaneValue SysinfoTest.NumProcsSaneValue \ No newline at end of file