mirror of
https://github.com/asterinas/asterinas.git
synced 2025-06-21 16:33:24 +00:00
Implementation of uptime for sysinfo
This commit is contained in:
committed by
Tate, Hongliang Tian
parent
b4ebd6e87f
commit
4f653acfa3
@ -1,11 +1,34 @@
|
||||
// SPDX-License-Identifier: MPL-2.0
|
||||
|
||||
use super::SyscallReturn;
|
||||
use crate::prelude::*;
|
||||
use aster_time::read_monotonic_time;
|
||||
|
||||
#[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
|
||||
}
|
||||
|
||||
pub fn sys_sysinfo(
|
||||
sysinfo_addr: Vaddr,
|
||||
ctx: &Context,
|
||||
) -> Result<SyscallReturn> {
|
||||
unimplemented!("sysinfo implementation in process");
|
||||
Ok(SyscallReturn::Return(-1))
|
||||
}
|
||||
let info = sysinfo {
|
||||
uptime: read_monotonic_time().as_secs() as i64,
|
||||
..Default::default() // TODO: add other system information
|
||||
};
|
||||
ctx.user_space().write_val(sysinfo_addr, &info)?;
|
||||
Ok(SyscallReturn::Return(0))
|
||||
}
|
||||
|
@ -47,6 +47,7 @@ TESTS ?= \
|
||||
statfs_test \
|
||||
symlink_test \
|
||||
sync_test \
|
||||
sysinfo_test \
|
||||
timers_test \
|
||||
truncate_test \
|
||||
uidgid_test \
|
||||
|
4
test/syscall_test/blocklists/sysinfo_test
Normal file
4
test/syscall_test/blocklists/sysinfo_test
Normal file
@ -0,0 +1,4 @@
|
||||
SysinfoTest.TotalRamSaneValue
|
||||
SysinfoTest.MemunitSet
|
||||
SysinfoTest.FreeRamSaneValue
|
||||
SysinfoTest.NumProcsSaneValue
|
Reference in New Issue
Block a user