mirror of
https://github.com/asterinas/asterinas.git
synced 2025-06-29 14:33:25 +00:00
Write time to user only if addr is not zero
This commit is contained in:
committed by
Tate, Hongliang Tian
parent
8f51259a10
commit
a18fc9eb25
@ -6,8 +6,15 @@ use crate::{log_syscall_entry, prelude::*, time::SystemTime, util::write_val_to_
|
|||||||
pub fn sys_time(tloc: Vaddr) -> Result<SyscallReturn> {
|
pub fn sys_time(tloc: Vaddr) -> Result<SyscallReturn> {
|
||||||
log_syscall_entry!(SYS_TIME);
|
log_syscall_entry!(SYS_TIME);
|
||||||
debug!("tloc = 0x{tloc:x}");
|
debug!("tloc = 0x{tloc:x}");
|
||||||
let now = SystemTime::now();
|
|
||||||
let now_as_secs = now.duration_since(&SystemTime::UNIX_EPOCH)?.as_secs();
|
let now_as_secs = {
|
||||||
write_val_to_user(tloc, &now_as_secs)?;
|
let now = SystemTime::now();
|
||||||
Ok(SyscallReturn::Return(0))
|
now.duration_since(&SystemTime::UNIX_EPOCH)?.as_secs()
|
||||||
|
};
|
||||||
|
|
||||||
|
if tloc != 0 {
|
||||||
|
write_val_to_user(tloc, &now_as_secs)?;
|
||||||
|
}
|
||||||
|
|
||||||
|
Ok(SyscallReturn::Return(now_as_secs as _))
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user