Skip to content

Commit 427e66c

Browse files
committed
hook write
1 parent b5b85a0 commit 427e66c

1 file changed

Lines changed: 6 additions & 5 deletions

File tree

core/src/syscall/unix/write.rs

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@ impl<I: WriteSyscall> WriteSyscall for WriteSyscallFacade<I> {
3939
len: size_t,
4040
) -> ssize_t {
4141
let syscall = crate::common::constants::SyscallName::write;
42+
crate::info!("enter syscall {}", syscall);
4243
if let Some(co) = crate::scheduler::SchedulableCoroutine::current() {
4344
let new_state = crate::common::constants::SyscallState::Executing;
4445
if co.syscall((), syscall, new_state).is_err() {
@@ -47,11 +48,11 @@ impl<I: WriteSyscall> WriteSyscall for WriteSyscallFacade<I> {
4748
);
4849
}
4950
}
50-
if fd == libc::STDOUT_FILENO || fd == libc::STDERR_FILENO {
51-
return RawWriteSyscall::default().write(fn_ptr, fd, buf, len);
52-
}
53-
crate::info!("enter syscall {}", syscall);
54-
let r = self.inner.write(fn_ptr, fd, buf, len);
51+
let r = if fd == libc::STDOUT_FILENO || fd == libc::STDERR_FILENO {
52+
RawWriteSyscall::default().write(fn_ptr, fd, buf, len)
53+
} else {
54+
self.inner.write(fn_ptr, fd, buf, len)
55+
};
5556
if let Some(co) = crate::scheduler::SchedulableCoroutine::current() {
5657
if co.running().is_err() {
5758
crate::error!("{} change to running state failed !", co.name());

0 commit comments

Comments
 (0)