mirror of
https://github.com/asterinas/asterinas.git
synced 2025-06-21 08:26:30 +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))
|
||||
}
|
||||
|
Reference in New Issue
Block a user