Migrate existing code to use `VmIo`
This commit is contained in:
parent
9d5e889a93
commit
04ef99cb82
|
|
@ -5,7 +5,7 @@ use alloc::sync::Arc;
|
|||
use aster_framebuffer::{ColorMapEntry, FrameBuffer, PixelFormat, FRAMEBUFFER, MAX_CMAP_SIZE};
|
||||
use device_id::{DeviceId, MajorId, MinorId};
|
||||
use ostd::{
|
||||
mm::{io_util::HasVmReaderWriter, HasPaddr, HasSize},
|
||||
mm::{io_util::HasVmReaderWriter, HasPaddr, HasSize, VmIo},
|
||||
Pod,
|
||||
};
|
||||
|
||||
|
|
|
|||
|
|
@ -2,7 +2,7 @@
|
|||
|
||||
use alloc::format;
|
||||
|
||||
use ostd::task::Task;
|
||||
use ostd::{mm::VmIo, task::Task};
|
||||
|
||||
use super::{driver::PtyDriver, PtySlave};
|
||||
use crate::{
|
||||
|
|
|
|||
|
|
@ -6,7 +6,7 @@ use aster_console::{
|
|||
AnyConsoleDevice,
|
||||
};
|
||||
use device_id::{DeviceId, MajorId, MinorId};
|
||||
use ostd::sync::LocalIrqDisabled;
|
||||
use ostd::{mm::VmIo, sync::LocalIrqDisabled};
|
||||
|
||||
use self::{line_discipline::LineDiscipline, termio::CFontOp};
|
||||
use crate::{
|
||||
|
|
@ -214,7 +214,7 @@ impl<D: TtyDriver> Tty<D> {
|
|||
|
||||
let font_size = width.div_ceil(u8::BITS) * vpitch * charcount;
|
||||
let mut font_data = vec![0; font_size as usize];
|
||||
current_userspace!().read_bytes(*data as Vaddr, &mut (&mut font_data[..]).into())?;
|
||||
current_userspace!().read_bytes(*data as Vaddr, &mut font_data[..])?;
|
||||
|
||||
// In Linux, the most significant bit represents the first pixel, but `BitmapFont` requires
|
||||
// the least significant bit to represent the first pixel. So now we reverse the bits.
|
||||
|
|
|
|||
|
|
@ -14,7 +14,7 @@ use core::{
|
|||
use bitflags::bitflags;
|
||||
use hashbrown::HashMap;
|
||||
use ostd::{
|
||||
mm::VmWriter,
|
||||
mm::{VmIo, VmWriter},
|
||||
sync::{Mutex, SpinLock},
|
||||
};
|
||||
|
||||
|
|
|
|||
|
|
@ -4,7 +4,8 @@ use alloc::borrow::Cow;
|
|||
use core::{num::NonZeroU64, sync::atomic::Ordering};
|
||||
|
||||
use ostd::{
|
||||
arch::cpu::context::UserContext, cpu::CpuId, sync::RwArc, task::Task, user::UserContextApi,
|
||||
arch::cpu::context::UserContext, cpu::CpuId, mm::VmIo, sync::RwArc, task::Task,
|
||||
user::UserContextApi,
|
||||
};
|
||||
|
||||
use super::{
|
||||
|
|
@ -677,11 +678,11 @@ fn clone_pidfd(
|
|||
// FIXME: Should we remove the file from the file table if the write operation fails?
|
||||
match ctx.user_space().write_val(pidfd_addr, &fd) {
|
||||
Ok(()) => Ok(()),
|
||||
Err(e) => {
|
||||
Err(err) => {
|
||||
let file_table = ctx.thread_local.borrow_file_table();
|
||||
let mut file_table_locked = file_table.unwrap().write();
|
||||
file_table_locked.close_file(fd);
|
||||
Err(e)
|
||||
Err(err.into())
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -3,6 +3,7 @@
|
|||
use aster_rights::WriteOp;
|
||||
use ostd::{
|
||||
arch::cpu::context::{FpuContext, GeneralRegs, UserContext},
|
||||
mm::VmIo,
|
||||
sync::Waiter,
|
||||
user::UserContextApi,
|
||||
};
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
// SPDX-License-Identifier: MPL-2.0
|
||||
|
||||
use ostd::task::Task;
|
||||
use ostd::{mm::VmIo, task::Task};
|
||||
|
||||
use super::{
|
||||
futex::futex_wake, robust_list::wake_robust_futex, thread_table, AsPosixThread, AsThreadLocal,
|
||||
|
|
|
|||
|
|
@ -2,7 +2,7 @@
|
|||
|
||||
//! The implementation of robust list is from occlum.
|
||||
|
||||
use ostd::task::Task;
|
||||
use ostd::{mm::VmIo, task::Task};
|
||||
|
||||
use crate::{current_userspace, prelude::*, process::posix_thread::futex::futex_wake, thread::Tid};
|
||||
|
||||
|
|
|
|||
|
|
@ -2,6 +2,8 @@
|
|||
|
||||
use alloc::sync::Arc;
|
||||
|
||||
use ostd::mm::VmIo;
|
||||
|
||||
use super::{session::SessionGuard, JobControl, Pgid, Process, Session, Sid};
|
||||
use crate::{
|
||||
current_userspace,
|
||||
|
|
@ -44,7 +46,7 @@ impl dyn Terminal {
|
|||
self.is_control_and(¤t!(), |_, _| Ok(operate()))?
|
||||
};
|
||||
|
||||
current_userspace!().write_val::<Pgid>(arg, &pgid)
|
||||
Ok(current_userspace!().write_val::<Pgid>(arg, &pgid)?)
|
||||
}
|
||||
|
||||
// Commands about sessions
|
||||
|
|
@ -80,7 +82,7 @@ impl dyn Terminal {
|
|||
self.is_control_and(¤t!(), |session, _| Ok(session.sid()))?
|
||||
};
|
||||
|
||||
current_userspace!().write_val::<Sid>(arg, &sid)
|
||||
Ok(current_userspace!().write_val::<Sid>(arg, &sid)?)
|
||||
}
|
||||
|
||||
// Commands that are invalid or not supported
|
||||
|
|
|
|||
|
|
@ -20,6 +20,7 @@ use c_types::{siginfo_t, ucontext_t};
|
|||
use constants::SIGSEGV;
|
||||
use ostd::{
|
||||
arch::cpu::context::{FpuContext, UserContext},
|
||||
mm::VmIo,
|
||||
user::UserContextApi,
|
||||
};
|
||||
pub use pause::{with_sigmask_changed, Pause, PauseReason};
|
||||
|
|
@ -300,8 +301,7 @@ pub fn handle_user_signal(
|
|||
}
|
||||
}
|
||||
|
||||
let mut fpu_context_reader = VmReader::from(fpu_context_bytes);
|
||||
user_space.write_bytes(fpu_context_addr as _, &mut fpu_context_reader)?;
|
||||
user_space.write_bytes(fpu_context_addr as _, fpu_context_bytes)?;
|
||||
|
||||
user_space.write_val(ucontext_addr as _, &ucontext)?;
|
||||
// Store the ucontext addr in sig context of current thread.
|
||||
|
|
|
|||
|
|
@ -1,5 +1,7 @@
|
|||
// SPDX-License-Identifier: MPL-2.0
|
||||
|
||||
use ostd::mm::VmIo;
|
||||
|
||||
use super::SyscallReturn;
|
||||
use crate::{
|
||||
prelude::*,
|
||||
|
|
|
|||
|
|
@ -1,5 +1,7 @@
|
|||
// SPDX-License-Identifier: MPL-2.0
|
||||
|
||||
use ostd::mm::VmIo;
|
||||
|
||||
use super::SyscallReturn;
|
||||
use crate::{
|
||||
prelude::*,
|
||||
|
|
|
|||
|
|
@ -3,6 +3,7 @@
|
|||
use core::time::Duration;
|
||||
|
||||
use int_to_c_enum::TryFromInt;
|
||||
use ostd::mm::VmIo;
|
||||
|
||||
use super::SyscallReturn;
|
||||
use crate::{
|
||||
|
|
|
|||
|
|
@ -2,7 +2,7 @@
|
|||
|
||||
use core::num::NonZeroU64;
|
||||
|
||||
use ostd::arch::cpu::context::UserContext;
|
||||
use ostd::{arch::cpu::context::UserContext, mm::VmIo};
|
||||
|
||||
use super::SyscallReturn;
|
||||
use crate::{
|
||||
|
|
|
|||
|
|
@ -2,6 +2,8 @@
|
|||
|
||||
use core::{sync::atomic::Ordering, time::Duration};
|
||||
|
||||
use ostd::mm::VmIo;
|
||||
|
||||
use super::SyscallReturn;
|
||||
use crate::{
|
||||
events::IoEvents,
|
||||
|
|
|
|||
|
|
@ -1,5 +1,7 @@
|
|||
// SPDX-License-Identifier: MPL-2.0
|
||||
|
||||
use ostd::mm::VmIo;
|
||||
|
||||
use super::SyscallReturn;
|
||||
use crate::{
|
||||
fs::{
|
||||
|
|
|
|||
|
|
@ -2,6 +2,8 @@
|
|||
|
||||
use core::time::Duration;
|
||||
|
||||
use ostd::mm::VmIo;
|
||||
|
||||
use crate::{
|
||||
current_userspace,
|
||||
prelude::*,
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
// SPDX-License-Identifier: MPL-2.0
|
||||
|
||||
use ostd::cpu::CpuId;
|
||||
use ostd::{cpu::CpuId, mm::VmIo};
|
||||
|
||||
use super::SyscallReturn;
|
||||
use crate::prelude::*;
|
||||
|
|
|
|||
|
|
@ -1,5 +1,7 @@
|
|||
// SPDX-License-Identifier: MPL-2.0
|
||||
|
||||
use ostd::mm::VmIo;
|
||||
|
||||
use super::SyscallReturn;
|
||||
use crate::prelude::*;
|
||||
|
||||
|
|
@ -11,8 +13,7 @@ pub fn sys_getcwd(buf: Vaddr, len: usize, ctx: &Context) -> Result<SyscallReturn
|
|||
let cwd = CString::new(name)?;
|
||||
let bytes = cwd.as_bytes_with_nul();
|
||||
let write_len = len.min(bytes.len());
|
||||
ctx.user_space()
|
||||
.write_bytes(buf, &mut VmReader::from(&bytes[..write_len]))?;
|
||||
ctx.user_space().write_bytes(buf, &bytes[..write_len])?;
|
||||
|
||||
Ok(SyscallReturn::Return(write_len as _))
|
||||
}
|
||||
|
|
|
|||
|
|
@ -2,6 +2,8 @@
|
|||
|
||||
use core::marker::PhantomData;
|
||||
|
||||
use ostd::mm::VmIo;
|
||||
|
||||
use super::SyscallReturn;
|
||||
use crate::{
|
||||
fs,
|
||||
|
|
@ -34,7 +36,7 @@ pub fn sys_getdents(
|
|||
let _ = inode_handle.readdir(&mut reader)?;
|
||||
let read_len = reader.read_len();
|
||||
ctx.user_space()
|
||||
.write_bytes(buf_addr, &mut VmReader::from(&buffer[..read_len]))?;
|
||||
.write_bytes(buf_addr, &buffer[..read_len])?;
|
||||
fs::notify::on_access(&file);
|
||||
Ok(SyscallReturn::Return(read_len as _))
|
||||
}
|
||||
|
|
@ -61,7 +63,7 @@ pub fn sys_getdents64(
|
|||
let _ = inode_handle.readdir(&mut reader)?;
|
||||
let read_len = reader.read_len();
|
||||
ctx.user_space()
|
||||
.write_bytes(buf_addr, &mut VmReader::from(&buffer[..read_len]))?;
|
||||
.write_bytes(buf_addr, &buffer[..read_len])?;
|
||||
fs::notify::on_access(&file);
|
||||
Ok(SyscallReturn::Return(read_len as _))
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,5 +1,7 @@
|
|||
// SPDX-License-Identifier: MPL-2.0
|
||||
|
||||
use ostd::mm::VmIo;
|
||||
|
||||
use super::SyscallReturn;
|
||||
use crate::prelude::*;
|
||||
|
||||
|
|
|
|||
|
|
@ -1,5 +1,7 @@
|
|||
// SPDX-License-Identifier: MPL-2.0
|
||||
|
||||
use ostd::mm::VmIo;
|
||||
|
||||
use super::SyscallReturn;
|
||||
use crate::prelude::*;
|
||||
|
||||
|
|
|
|||
|
|
@ -1,5 +1,7 @@
|
|||
// SPDX-License-Identifier: MPL-2.0
|
||||
|
||||
use ostd::mm::VmIo;
|
||||
|
||||
use super::SyscallReturn;
|
||||
use crate::prelude::*;
|
||||
|
||||
|
|
|
|||
|
|
@ -1,6 +1,7 @@
|
|||
// SPDX-License-Identifier: MPL-2.0
|
||||
|
||||
use int_to_c_enum::TryFromInt;
|
||||
use ostd::mm::VmIo;
|
||||
|
||||
use super::SyscallReturn;
|
||||
use crate::{prelude::*, time::timeval_t};
|
||||
|
|
|
|||
|
|
@ -1,5 +1,7 @@
|
|||
// SPDX-License-Identifier: MPL-2.0
|
||||
|
||||
use ostd::mm::VmIo;
|
||||
|
||||
use super::SyscallReturn;
|
||||
use crate::{
|
||||
fs::file_table::{get_file_fast, FileDesc},
|
||||
|
|
|
|||
|
|
@ -1,5 +1,7 @@
|
|||
// SPDX-License-Identifier: MPL-2.0
|
||||
|
||||
use ostd::mm::VmIo;
|
||||
|
||||
use super::SyscallReturn;
|
||||
use crate::{
|
||||
prelude::*,
|
||||
|
|
|
|||
|
|
@ -1,5 +1,7 @@
|
|||
// SPDX-License-Identifier: MPL-2.0
|
||||
|
||||
use ostd::mm::VmIo;
|
||||
|
||||
use super::SyscallReturn;
|
||||
use crate::{
|
||||
fs::{
|
||||
|
|
|
|||
|
|
@ -1,6 +1,7 @@
|
|||
// SPDX-License-Identifier: MPL-2.0
|
||||
|
||||
use align_ext::AlignExt;
|
||||
use ostd::mm::VmIo;
|
||||
|
||||
use super::SyscallReturn;
|
||||
use crate::prelude::*;
|
||||
|
|
@ -38,8 +39,7 @@ pub fn sys_madvise(
|
|||
| MadviseBehavior::MADV_WILLNEED => {
|
||||
// perform a read at first
|
||||
let mut buffer = vec![0u8; len];
|
||||
ctx.user_space()
|
||||
.read_bytes(start, &mut VmWriter::from(buffer.as_mut_slice()))?;
|
||||
ctx.user_space().read_bytes(start, buffer.as_mut_slice())?;
|
||||
}
|
||||
MadviseBehavior::MADV_DONTNEED => {
|
||||
warn!("MADV_DONTNEED isn't implemented, do nothing for now.");
|
||||
|
|
|
|||
|
|
@ -2,7 +2,7 @@
|
|||
|
||||
use core::time::Duration;
|
||||
|
||||
use ostd::sync::Waiter;
|
||||
use ostd::{mm::VmIo, sync::Waiter};
|
||||
|
||||
use super::{clock_gettime::read_clock, ClockId, SyscallReturn};
|
||||
use crate::{
|
||||
|
|
|
|||
|
|
@ -1,5 +1,7 @@
|
|||
// SPDX-License-Identifier: MPL-2.0
|
||||
|
||||
use ostd::mm::VmIo;
|
||||
|
||||
use super::SyscallReturn;
|
||||
use crate::{
|
||||
fs::{
|
||||
|
|
@ -33,7 +35,7 @@ pub fn sys_pipe2(fds: Vaddr, flags: u32, ctx: &Context) -> Result<SyscallReturn>
|
|||
if let Err(err) = ctx.user_space().write_val(fds, &pipe_fds) {
|
||||
file_table_locked.close_file(pipe_fds.reader_fd).unwrap();
|
||||
file_table_locked.close_file(pipe_fds.writer_fd).unwrap();
|
||||
return Err(err);
|
||||
return Err(err.into());
|
||||
}
|
||||
|
||||
Ok(SyscallReturn::Return(0))
|
||||
|
|
|
|||
|
|
@ -2,6 +2,8 @@
|
|||
|
||||
use core::{cell::Cell, time::Duration};
|
||||
|
||||
use ostd::mm::VmIo;
|
||||
|
||||
use super::SyscallReturn;
|
||||
use crate::{
|
||||
events::IoEvents,
|
||||
|
|
|
|||
|
|
@ -2,6 +2,8 @@
|
|||
|
||||
use core::time::Duration;
|
||||
|
||||
use ostd::mm::VmIo;
|
||||
|
||||
use super::{poll::do_sys_poll, SyscallReturn};
|
||||
use crate::{
|
||||
prelude::*,
|
||||
|
|
|
|||
|
|
@ -1,5 +1,7 @@
|
|||
// SPDX-License-Identifier: MPL-2.0
|
||||
|
||||
use ostd::mm::VmIo;
|
||||
|
||||
use super::SyscallReturn;
|
||||
use crate::{
|
||||
prelude::*,
|
||||
|
|
@ -64,10 +66,8 @@ pub fn sys_prctl(
|
|||
}
|
||||
PrctlCmd::PR_GET_NAME(write_to_addr) => {
|
||||
let thread_name = ctx.posix_thread.thread_name().lock();
|
||||
ctx.user_space().write_bytes(
|
||||
write_to_addr,
|
||||
&mut VmReader::from(thread_name.name().to_bytes_with_nul()),
|
||||
)?;
|
||||
ctx.user_space()
|
||||
.write_bytes(write_to_addr, thread_name.name().to_bytes_with_nul())?;
|
||||
}
|
||||
PrctlCmd::PR_SET_NAME(read_addr) => {
|
||||
let new_thread_name = ctx
|
||||
|
|
|
|||
|
|
@ -1,5 +1,7 @@
|
|||
// SPDX-License-Identifier: MPL-2.0
|
||||
|
||||
use ostd::mm::VmIo;
|
||||
|
||||
use super::SyscallReturn;
|
||||
use crate::{
|
||||
prelude::*,
|
||||
|
|
|
|||
|
|
@ -2,6 +2,8 @@
|
|||
|
||||
use core::time::Duration;
|
||||
|
||||
use ostd::mm::VmIo;
|
||||
|
||||
use super::{select::do_sys_select, SyscallReturn};
|
||||
use crate::{
|
||||
fs::file_table::FileDesc,
|
||||
|
|
|
|||
|
|
@ -1,5 +1,7 @@
|
|||
// SPDX-License-Identifier: MPL-2.0
|
||||
|
||||
use ostd::mm::VmIo;
|
||||
|
||||
use super::SyscallReturn;
|
||||
use crate::{
|
||||
fs::{
|
||||
|
|
@ -37,7 +39,7 @@ pub fn sys_readlinkat(
|
|||
let linkpath = path.inode().read_link()?.to_string();
|
||||
let bytes = linkpath.as_bytes();
|
||||
let write_len = bytes.len().min(usr_buf_len);
|
||||
user_space.write_bytes(usr_buf_addr, &mut VmReader::from(&bytes[..write_len]))?;
|
||||
user_space.write_bytes(usr_buf_addr, &bytes[..write_len])?;
|
||||
Ok(SyscallReturn::Return(write_len as _))
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -1,5 +1,7 @@
|
|||
// SPDX-License-Identifier: MPL-2.0
|
||||
|
||||
use ostd::mm::VmIo;
|
||||
|
||||
use super::SyscallReturn;
|
||||
use crate::{
|
||||
fs::file_table::{get_file_fast, FileDesc},
|
||||
|
|
|
|||
|
|
@ -1,5 +1,7 @@
|
|||
// SPDX-License-Identifier: MPL-2.0
|
||||
|
||||
use ostd::mm::VmIo;
|
||||
|
||||
use super::SyscallReturn;
|
||||
use crate::{
|
||||
prelude::*,
|
||||
|
|
|
|||
|
|
@ -2,6 +2,8 @@
|
|||
|
||||
use core::sync::atomic::Ordering;
|
||||
|
||||
use ostd::mm::VmIo;
|
||||
|
||||
use super::SyscallReturn;
|
||||
use crate::{prelude::*, process::signal::HandlePendingSignal};
|
||||
|
||||
|
|
|
|||
|
|
@ -2,6 +2,8 @@
|
|||
|
||||
use core::sync::atomic::Ordering;
|
||||
|
||||
use ostd::mm::VmIo;
|
||||
|
||||
use super::SyscallReturn;
|
||||
use crate::{
|
||||
prelude::*,
|
||||
|
|
|
|||
|
|
@ -4,6 +4,7 @@ use core::sync::atomic::Ordering;
|
|||
|
||||
use ostd::{
|
||||
arch::cpu::context::{FpuContext, UserContext},
|
||||
mm::VmIo,
|
||||
user::UserContextApi,
|
||||
};
|
||||
|
||||
|
|
@ -59,9 +60,8 @@ pub fn sys_rt_sigreturn(ctx: &Context, user_ctx: &mut UserContext) -> Result<Sys
|
|||
}
|
||||
}
|
||||
let mut fpu_context = FpuContext::new();
|
||||
let mut fpu_context_writer = VmWriter::from(fpu_context.as_bytes_mut());
|
||||
ctx.user_space()
|
||||
.read_bytes(fpu_context_addr, &mut fpu_context_writer)?;
|
||||
.read_bytes(fpu_context_addr, fpu_context.as_bytes_mut())?;
|
||||
ctx.thread_local.fpu().set_context(fpu_context);
|
||||
|
||||
// unblock sig mask
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
// SPDX-License-Identifier: MPL-2.0
|
||||
|
||||
use ostd::sync::Waiter;
|
||||
use ostd::{mm::VmIo, sync::Waiter};
|
||||
|
||||
use super::SyscallReturn;
|
||||
use crate::{
|
||||
|
|
|
|||
|
|
@ -4,6 +4,7 @@ use core::{cmp, sync::atomic::Ordering};
|
|||
|
||||
use ostd::{
|
||||
cpu::{num_cpus, CpuId, CpuSet},
|
||||
mm::VmIo,
|
||||
util::id_set::Id,
|
||||
};
|
||||
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
// SPDX-License-Identifier: MPL-2.0
|
||||
|
||||
use ostd::const_assert;
|
||||
use ostd::{const_assert, mm::VmIo};
|
||||
|
||||
use super::{
|
||||
sched_get_priority_max::{rt_to_static, static_to_rt, SCHED_PRIORITY_RANGE},
|
||||
|
|
|
|||
|
|
@ -1,5 +1,7 @@
|
|||
// SPDX-License-Identifier: MPL-2.0
|
||||
|
||||
use ostd::mm::VmIo;
|
||||
|
||||
use super::{sched_getattr::access_sched_attr_with, SyscallReturn};
|
||||
use crate::{prelude::*, sched::SchedPolicy, thread::Tid};
|
||||
|
||||
|
|
|
|||
|
|
@ -1,5 +1,7 @@
|
|||
// SPDX-License-Identifier: MPL-2.0
|
||||
|
||||
use ostd::mm::VmIo;
|
||||
|
||||
use super::{sched_getattr::access_sched_attr_with, SyscallReturn};
|
||||
use crate::{prelude::*, sched::SchedPolicy, thread::Tid};
|
||||
|
||||
|
|
|
|||
|
|
@ -1,5 +1,7 @@
|
|||
// SPDX-License-Identifier: MPL-2.0
|
||||
|
||||
use ostd::mm::VmIo;
|
||||
|
||||
use super::{
|
||||
sched_getattr::{access_sched_attr_with, LinuxSchedAttr},
|
||||
SyscallReturn,
|
||||
|
|
|
|||
|
|
@ -2,6 +2,8 @@
|
|||
|
||||
use core::time::Duration;
|
||||
|
||||
use ostd::mm::VmIo;
|
||||
|
||||
use super::{
|
||||
poll::{do_poll, PollFd},
|
||||
SyscallReturn,
|
||||
|
|
|
|||
|
|
@ -1,5 +1,7 @@
|
|||
// SPDX-License-Identifier: MPL-2.0
|
||||
|
||||
use ostd::mm::VmIo;
|
||||
|
||||
use super::SyscallReturn;
|
||||
use crate::{
|
||||
ipc::{
|
||||
|
|
@ -95,7 +97,7 @@ pub fn sys_semctl(
|
|||
IpcControlCmd::IPC_STAT => {
|
||||
check_and_ctl(semid, PermissionMode::READ, |sem_set| {
|
||||
let semid_ds = sem_set.semid_ds();
|
||||
ctx.user_space().write_val(arg as Vaddr, &semid_ds)
|
||||
Ok(ctx.user_space().write_val(arg as Vaddr, &semid_ds)?)
|
||||
})?;
|
||||
}
|
||||
_ => todo!("Need to support {:?} in SYS_SEMCTL", cmd),
|
||||
|
|
|
|||
|
|
@ -2,6 +2,8 @@
|
|||
|
||||
use core::time::Duration;
|
||||
|
||||
use ostd::mm::VmIo;
|
||||
|
||||
use super::SyscallReturn;
|
||||
use crate::{
|
||||
ipc::semaphore::system_v::{
|
||||
|
|
|
|||
|
|
@ -1,5 +1,7 @@
|
|||
// SPDX-License-Identifier: MPL-2.0
|
||||
|
||||
use ostd::mm::VmIo;
|
||||
|
||||
use super::SyscallReturn;
|
||||
use crate::{
|
||||
fs,
|
||||
|
|
|
|||
|
|
@ -1,5 +1,7 @@
|
|||
// SPDX-License-Identifier: MPL-2.0
|
||||
|
||||
use ostd::mm::VmIo;
|
||||
|
||||
use crate::{
|
||||
fs::file_table::FileDesc,
|
||||
net::socket::{util::SendRecvFlags, Socket},
|
||||
|
|
|
|||
|
|
@ -1,5 +1,7 @@
|
|||
// SPDX-License-Identifier: MPL-2.0
|
||||
|
||||
use ostd::mm::VmIo;
|
||||
|
||||
use super::SyscallReturn;
|
||||
use crate::{
|
||||
fs::file_table::FileDesc,
|
||||
|
|
|
|||
|
|
@ -1,5 +1,7 @@
|
|||
// SPDX-License-Identifier: MPL-2.0
|
||||
|
||||
use ostd::mm::VmIo;
|
||||
|
||||
use super::SyscallReturn;
|
||||
use crate::{prelude::*, process::posix_thread::RobustListHead};
|
||||
|
||||
|
|
|
|||
|
|
@ -1,5 +1,7 @@
|
|||
// SPDX-License-Identifier: MPL-2.0
|
||||
|
||||
use ostd::mm::VmIo;
|
||||
|
||||
use super::SyscallReturn;
|
||||
use crate::{prelude::*, process::Gid};
|
||||
|
||||
|
|
|
|||
|
|
@ -2,6 +2,8 @@
|
|||
|
||||
use core::time::Duration;
|
||||
|
||||
use ostd::mm::VmIo;
|
||||
|
||||
use super::SyscallReturn;
|
||||
use crate::{
|
||||
prelude::*,
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
// SPDX-License-Identifier: MPL-2.0
|
||||
|
||||
use ostd::{arch::cpu::context::UserContext, user::UserContextApi};
|
||||
use ostd::{arch::cpu::context::UserContext, mm::VmIo, user::UserContextApi};
|
||||
|
||||
use super::SyscallReturn;
|
||||
use crate::{
|
||||
|
|
|
|||
|
|
@ -12,6 +12,7 @@ use core::{
|
|||
};
|
||||
|
||||
use bitflags::bitflags;
|
||||
use ostd::mm::VmIo;
|
||||
|
||||
use super::SyscallReturn;
|
||||
use crate::{
|
||||
|
|
|
|||
|
|
@ -1,5 +1,7 @@
|
|||
// SPDX-License-Identifier: MPL-2.0
|
||||
|
||||
use ostd::mm::VmIo;
|
||||
|
||||
use super::SyscallReturn;
|
||||
use crate::{
|
||||
fs::{
|
||||
|
|
|
|||
|
|
@ -1,5 +1,7 @@
|
|||
// SPDX-License-Identifier: MPL-2.0
|
||||
|
||||
use ostd::mm::VmIo;
|
||||
|
||||
use super::SyscallReturn;
|
||||
use crate::{
|
||||
fs::{
|
||||
|
|
|
|||
|
|
@ -1,5 +1,7 @@
|
|||
// SPDX-License-Identifier: MPL-2.0
|
||||
|
||||
use ostd::mm::VmIo;
|
||||
|
||||
use super::SyscallReturn;
|
||||
use crate::{
|
||||
fs::{
|
||||
|
|
|
|||
|
|
@ -2,6 +2,8 @@
|
|||
|
||||
use core::time::Duration;
|
||||
|
||||
use ostd::mm::VmIo;
|
||||
|
||||
use super::SyscallReturn;
|
||||
use crate::{
|
||||
fs::{file_table::FileDesc, fs_resolver::FsPath, path::Path},
|
||||
|
|
|
|||
|
|
@ -1,6 +1,7 @@
|
|||
// SPDX-License-Identifier: MPL-2.0
|
||||
|
||||
use aster_time::read_monotonic_time;
|
||||
use ostd::mm::VmIo;
|
||||
|
||||
use super::SyscallReturn;
|
||||
use crate::{prelude::*, process::process_table};
|
||||
|
|
|
|||
|
|
@ -1,5 +1,7 @@
|
|||
// SPDX-License-Identifier: MPL-2.0
|
||||
|
||||
use ostd::mm::VmIo;
|
||||
|
||||
use super::SyscallReturn;
|
||||
use crate::{prelude::*, time::SystemTime};
|
||||
|
||||
|
|
|
|||
|
|
@ -1,5 +1,7 @@
|
|||
// SPDX-License-Identifier: MPL-2.0
|
||||
|
||||
use ostd::mm::VmIo;
|
||||
|
||||
use super::{
|
||||
clock_gettime::{DynamicClockIdInfo, DynamicClockType},
|
||||
SyscallReturn,
|
||||
|
|
|
|||
|
|
@ -2,6 +2,8 @@
|
|||
|
||||
use core::time::Duration;
|
||||
|
||||
use ostd::mm::VmIo;
|
||||
|
||||
use super::SyscallReturn;
|
||||
use crate::{
|
||||
prelude::*,
|
||||
|
|
|
|||
|
|
@ -1,5 +1,7 @@
|
|||
// SPDX-License-Identifier: MPL-2.0
|
||||
|
||||
use ostd::mm::VmIo;
|
||||
|
||||
use super::SyscallReturn;
|
||||
use crate::{
|
||||
fs::file_table::FileDesc,
|
||||
|
|
|
|||
|
|
@ -2,6 +2,8 @@
|
|||
|
||||
use core::time::Duration;
|
||||
|
||||
use ostd::mm::VmIo;
|
||||
|
||||
use super::SyscallReturn;
|
||||
use crate::{
|
||||
fs::file_table::FileDesc,
|
||||
|
|
|
|||
|
|
@ -1,4 +1,6 @@
|
|||
// SPDX-License-Identifier: MPL-2.0
|
||||
use ostd::mm::VmIo;
|
||||
|
||||
use super::SyscallReturn;
|
||||
use crate::prelude::*;
|
||||
|
||||
|
|
|
|||
|
|
@ -2,6 +2,8 @@
|
|||
|
||||
use core::time::Duration;
|
||||
|
||||
use ostd::mm::VmIo;
|
||||
|
||||
use super::{constants::MAX_FILENAME_LEN, SyscallReturn};
|
||||
use crate::{
|
||||
fs,
|
||||
|
|
|
|||
|
|
@ -1,5 +1,7 @@
|
|||
// SPDX-License-Identifier: MPL-2.0
|
||||
|
||||
use ostd::mm::VmIo;
|
||||
|
||||
use super::{getrusage::rusage_t, SyscallReturn};
|
||||
use crate::{
|
||||
prelude::*,
|
||||
|
|
|
|||
|
|
@ -1,5 +1,7 @@
|
|||
// SPDX-License-Identifier: MPL-2.0
|
||||
|
||||
use ostd::mm::VmIo;
|
||||
|
||||
use super::SyscallReturn;
|
||||
use crate::{
|
||||
prelude::*,
|
||||
|
|
|
|||
|
|
@ -2,6 +2,7 @@
|
|||
|
||||
use ostd::{
|
||||
arch::cpu::context::UserContext,
|
||||
mm::VmIo,
|
||||
sync::Waiter,
|
||||
task::{Task, TaskOptions},
|
||||
user::{ReturnReason, UserContextApi, UserMode},
|
||||
|
|
|
|||
|
|
@ -2,7 +2,7 @@
|
|||
|
||||
use core::cmp::min;
|
||||
|
||||
use ostd::task::Task;
|
||||
use ostd::{mm::VmIo, task::Task};
|
||||
|
||||
use super::{ip::CSocketAddrInet, netlink::CSocketAddrNetlink, unix, vsock::CSocketAddrVm};
|
||||
use crate::{current_userspace, net::socket::util::SocketAddr, prelude::*};
|
||||
|
|
@ -145,10 +145,7 @@ pub fn read_socket_addr_from_user(addr: Vaddr, addr_len: usize) -> Result<Socket
|
|||
}
|
||||
|
||||
let mut storage = Storage::new_zeroed();
|
||||
current_userspace!().read_bytes(
|
||||
addr,
|
||||
&mut VmWriter::from(&mut storage.as_bytes_mut()[..addr_len]),
|
||||
)?;
|
||||
current_userspace!().read_bytes(addr, &mut storage.as_bytes_mut()[..addr_len])?;
|
||||
|
||||
let result = match CSocketAddrFamily::try_from(storage.sa_family as i32) {
|
||||
Ok(CSocketAddrFamily::AF_INET) => {
|
||||
|
|
@ -215,7 +212,7 @@ pub fn write_socket_addr_to_user(
|
|||
|
||||
let actual_len = write_socket_addr_with_max_len(socket_addr, dest, max_len)?;
|
||||
|
||||
user_space.write_val(max_len_ptr, &actual_len)
|
||||
Ok(user_space.write_val(max_len_ptr, &actual_len)?)
|
||||
}
|
||||
|
||||
/// Writes a socket address to the user space.
|
||||
|
|
@ -253,7 +250,7 @@ pub fn write_socket_addr_with_max_len(
|
|||
)?,
|
||||
SocketAddr::Unix(addr) => unix::into_c_bytes_and(addr, |bytes| {
|
||||
let written_len = min(bytes.len(), max_len as _);
|
||||
current_userspace!().write_bytes(dest, &mut VmReader::from(&bytes[..written_len]))?;
|
||||
current_userspace!().write_bytes(dest, &bytes[..written_len])?;
|
||||
Ok::<usize, Error>(bytes.len())
|
||||
})?,
|
||||
SocketAddr::Netlink(addr) => {
|
||||
|
|
@ -280,10 +277,7 @@ where
|
|||
let actual_len = size_of::<TCSockAddr>();
|
||||
let written_len = min(actual_len, max_len);
|
||||
|
||||
current_userspace!().write_bytes(
|
||||
dest,
|
||||
&mut VmReader::from(&c_socket_addr.as_bytes()[..written_len]),
|
||||
)?;
|
||||
current_userspace!().write_bytes(dest, &c_socket_addr.as_bytes()[..written_len])?;
|
||||
|
||||
Ok(actual_len)
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,5 +1,7 @@
|
|||
// SPDX-License-Identifier: MPL-2.0
|
||||
|
||||
use ostd::mm::VmIo;
|
||||
|
||||
use super::RawSocketOption;
|
||||
use crate::{
|
||||
current_userspace, impl_raw_sock_option_get_only, impl_raw_socket_option,
|
||||
|
|
|
|||
|
|
@ -2,6 +2,8 @@
|
|||
|
||||
use core::{num::NonZeroU8, time::Duration};
|
||||
|
||||
use ostd::mm::VmIo;
|
||||
|
||||
use crate::{
|
||||
current_userspace,
|
||||
net::socket::{
|
||||
|
|
@ -44,7 +46,7 @@ macro_rules! impl_read_write_for_32bit_type {
|
|||
if (max_len as usize) < size_of::<$pod_ty>() {
|
||||
return_errno_with_message!(Errno::EINVAL, "max_len is too short");
|
||||
}
|
||||
crate::current_userspace!().read_val::<$pod_ty>(addr)
|
||||
Ok(crate::current_userspace!().read_val::<$pod_ty>(addr)?)
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -174,11 +176,7 @@ impl ReadFromUser for CongestionControl {
|
|||
&mut bytes[..read_len]
|
||||
};
|
||||
|
||||
// Clippy warns that `dst.as_mut` is redundant. However, using `dst` directly
|
||||
// instead of `dst.as_mut` would take the ownership of `dst`. Consequently,
|
||||
// the subsequent code that constructs `name` from `dst` would fail to compile.
|
||||
#[expect(clippy::useless_asref)]
|
||||
current_userspace!().read_bytes(addr, &mut VmWriter::from(dst.as_mut()))?;
|
||||
current_userspace!().read_bytes(addr, dst.as_mut())?;
|
||||
|
||||
let name = core::str::from_utf8(dst)
|
||||
.map_err(|_| Error::with_message(Errno::ENOENT, "non-UTF8 congestion name"))?;
|
||||
|
|
@ -196,7 +194,7 @@ impl WriteToUser for CongestionControl {
|
|||
|
||||
let write_len = TCP_CONGESTION_NAME_MAX.min(max_len) as usize;
|
||||
|
||||
current_userspace!().write_bytes(addr, &mut VmReader::from(&bytes[..write_len]))?;
|
||||
current_userspace!().write_bytes(addr, &bytes[..write_len])?;
|
||||
|
||||
Ok(write_len)
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue