data_type
large_stringclasses
3 values
source
large_stringclasses
29 values
code
large_stringlengths
98
49.4M
filepath
large_stringlengths
5
161
message
large_stringclasses
234 values
commit
large_stringclasses
234 values
subject
large_stringclasses
418 values
critique
large_stringlengths
101
1.26M
metadata
dict
source
asterinas
// SPDX-License-Identifier: MPL-2.0 //! This module defines functions related to spawning the init process. use ostd::{arch::cpu::context::UserContext, task::Task, user::UserContextApi}; use super::Process; use crate::{ fs::{ path::{FsPath, MountNamespace, Path}, thread_info::ThreadFsInfo, },...
kernel/src/process/process/init_proc.rs
null
null
null
null
null
source
asterinas
// SPDX-License-Identifier: MPL-2.0 use ostd::sync::{LocalIrqDisabled, WaitQueue}; use super::{ProcessGroup, Session}; use crate::prelude::*; /// The job control for terminals like TTY and pty. /// /// This structure is used to support the shell job control, allowing users to /// run commands in the foreground or in...
kernel/src/process/process/job_control.rs
null
null
null
null
null
source
asterinas
// SPDX-License-Identifier: MPL-2.0 use core::{ sync::atomic::{AtomicBool, AtomicI16, AtomicU32, Ordering}, time::Duration, }; use self::timer_manager::PosixTimerManager; use super::{ posix_thread::AsPosixThread, process_table, process_vm::ProcessVmarGuard, rlimit::ResourceLimits, signal::...
kernel/src/process/process/mod.rs
null
null
null
null
null
source
asterinas
// SPDX-License-Identifier: MPL-2.0 use alloc::collections::btree_map::Values; use super::{Pgid, Pid, Process, Session}; use crate::{prelude::*, process::signal::signals::Signal}; /// A process group. /// /// A process group represents a set of processes, /// which has a unique identifier PGID (i.e., [`Pgid`]). pub ...
kernel/src/process/process/process_group.rs
null
null
null
null
null
source
asterinas
// SPDX-License-Identifier: MPL-2.0 use super::{Pgid, Process, ProcessGroup, Sid, Terminal}; use crate::prelude::*; /// A session. /// /// A session is a collection of related process groups, which has a unique identifier SID (i.e., /// [`Sid`]). Process groups and sessions form a two-level hierarchical relationship ...
kernel/src/process/process/session.rs
null
null
null
null
null
source
asterinas
// SPDX-License-Identifier: MPL-2.0 use alloc::sync::Arc; use super::{JobControl, Pgid, Process, Session, session::SessionGuard}; use crate::{ fs::device::Device, prelude::{Errno, Error, Result, current, return_errno_with_message, warn}, process::process_table, util::ioctl::{RawIoctl, dispatch_ioctl},...
kernel/src/process/process/terminal.rs
null
null
null
null
null
source
asterinas
// SPDX-License-Identifier: MPL-2.0 use alloc::{ boxed::Box, sync::{Arc, Weak}, vec::Vec, }; use id_alloc::IdAlloc; use ostd::{cpu::PrivilegeLevel, irq::InterruptLevel, sync::Mutex, timer}; use super::Process; use crate::{ process::{ posix_thread::AsPosixThread, signal::{constants::SI...
kernel/src/process/process/timer_manager.rs
null
null
null
null
null
source
asterinas
// SPDX-License-Identifier: MPL-2.0 use core::ops::Range; use align_ext::AlignExt; use crate::{ prelude::*, process::ResourceType, util::random::getrandom, vm::{ perms::VmPerms, vmar::{VMAR_CAP_ADDR, Vmar}, }, }; #[derive(Debug)] pub struct Heap { inner: Mutex<Option<HeapInne...
kernel/src/process/process_vm/heap.rs
null
null
null
null
null
source
asterinas
// SPDX-License-Identifier: MPL-2.0 //! This module defines struct `ProcessVm` //! to represent the layout of user space process virtual memory. //! //! The `ProcessVm` struct contains `Vmar`, //! which stores all existing memory mappings. //! The `Vm` also contains //! the basic info of process level vm segments, //!...
kernel/src/process/process_vm/mod.rs
null
null
null
null
null
source
asterinas
// SPDX-License-Identifier: MPL-2.0 use crate::prelude::*; /// Auxiliary Vector. /// /// # What is Auxiliary Vector? /// /// Here is a concise description of Auxiliary Vector from GNU's manual: /// /// > When a program is executed, it receives information from the operating system /// > about the environment in whi...
kernel/src/process/process_vm/init_stack/aux_vec.rs
null
null
null
null
null
source
asterinas
// SPDX-License-Identifier: MPL-2.0 //! The init stack for the process. //! //! The init stack is used to store `argv`, `envp`, and auxiliary vectors. //! We can read `argv` and `envp` of a process from the init stack. //! Usually, the lowest address of the init stack is //! the highest address of the user stack of th...
kernel/src/process/process_vm/init_stack/mod.rs
null
null
null
null
null
source
asterinas
// SPDX-License-Identifier: MPL-2.0 pub(super) mod elf; mod shebang; use self::{ elf::{ElfHeaders, ElfLoadInfo, load_elf_to_vmar}, shebang::parse_shebang_line, }; use crate::{ fs::{ path::{FsPath, Path, PathResolver}, utils::{Inode, InodeType, Permission}, }, prelude::*, vm::vm...
kernel/src/process/program_loader/mod.rs
null
null
null
null
null
source
asterinas
// SPDX-License-Identifier: MPL-2.0 use crate::prelude::*; /// Tries to parse a buffer as a shebang line. /// /// If the buffer starts with `#!` and its header is a valid shebang sequence, /// then the function returns `Ok(Some(parts))`, where `parts` is a `Vec` that /// contains the path of and the arguments for the...
kernel/src/process/program_loader/shebang.rs
null
null
null
null
null
source
asterinas
// SPDX-License-Identifier: MPL-2.0 use core::ops::Range; use xmas_elf::{ header::{self, Header, HeaderPt1, HeaderPt2, HeaderPt2_, Machine_, Type_}, program::{self, ProgramHeader64}, }; use crate::{ fs::utils::{Inode, PATH_MAX}, prelude::*, vm::{perms::VmPerms, vmar::VMAR_CAP_ADDR}, }; /// A wra...
kernel/src/process/program_loader/elf/elf_file.rs
null
null
null
null
null
source
asterinas
// SPDX-License-Identifier: MPL-2.0 //! ELF file parser. use align_ext::AlignExt; use super::{ elf_file::{ElfHeaders, LoadablePhdr}, relocate::RelocatedRange, }; use crate::{ fs::path::{FsPath, Path, PathResolver}, prelude::*, process::{ process_vm::{AuxKey, AuxVec}, program_loade...
kernel/src/process/program_loader/elf/load_elf.rs
null
null
null
null
null
source
asterinas
// SPDX-License-Identifier: MPL-2.0 mod elf_file; mod load_elf; mod relocate; pub(super) use elf_file::ElfHeaders; pub(in crate::process) use load_elf::ElfLoadInfo; pub(super) use load_elf::load_elf_to_vmar;
kernel/src/process/program_loader/elf/mod.rs
null
null
null
null
null
source
asterinas
// SPDX-License-Identifier: MPL-2.0 use core::ops::Range; use ostd::mm::Vaddr; /// A virtual range and its relocated address. pub(super) struct RelocatedRange { original_range: Range<Vaddr>, relocated_start: Vaddr, } impl RelocatedRange { /// Creates a new `RelocatedRange`. /// /// If the reloca...
kernel/src/process/program_loader/elf/relocate.rs
null
null
null
null
null
source
asterinas
// SPDX-License-Identifier: MPL-2.0 #![expect(dead_code)] #![expect(non_camel_case_types)] use inherit_methods_macro::inherit_methods; use ostd::arch::cpu::context::UserContext; use super::sig_num::SigNum; use crate::{ arch::cpu::SigContext, prelude::*, process::{Pid, Uid}, }; pub type sigset_t = u64; /...
kernel/src/process/signal/c_types.rs
null
null
null
null
null
source
asterinas
// SPDX-License-Identifier: MPL-2.0 #![expect(dead_code)] /// Standard signals pub(super) const MIN_STD_SIG_NUM: u8 = 1; pub(super) const MAX_STD_SIG_NUM: u8 = 31; // inclusive /// Real-time signals pub(super) const MIN_RT_SIG_NUM: u8 = 32; pub(super) const MAX_RT_SIG_NUM: u8 = 64; // inclusive /// Count the number o...
kernel/src/process/signal/constants.rs
null
null
null
null
null
source
asterinas
// SPDX-License-Identifier: MPL-2.0 pub mod c_types; pub mod constants; mod pause; mod pending; mod poll; pub mod sig_action; pub mod sig_disposition; pub mod sig_mask; pub mod sig_num; pub mod sig_queues; mod sig_stack; pub mod signals; use core::sync::atomic::Ordering; use align_ext::AlignExt; use c_types::{siginf...
kernel/src/process/signal/mod.rs
null
null
null
null
null
source
asterinas
// SPDX-License-Identifier: MPL-2.0 use core::sync::atomic::Ordering; use ostd::sync::{WaitQueue, Waiter}; use super::sig_mask::SigMask; use crate::{ prelude::*, process::{posix_thread::AsPosixThread, signal::HandlePendingSignal}, thread::AsThread, time::{ timer::TimerGuard, wait::{Ma...
kernel/src/process/signal/pause.rs
null
null
null
null
null
source
asterinas
// SPDX-License-Identifier: MPL-2.0 use core::sync::atomic::Ordering; use crate::{ prelude::*, process::{ Process, posix_thread::PosixThread, signal::{ constants::SIGKILL, sig_mask::{SigMask, SigSet}, signals::Signal, }, }, }; /// Trait ...
kernel/src/process/signal/pending.rs
null
null
null
null
null
source
asterinas
// SPDX-License-Identifier: MPL-2.0 use core::{ sync::atomic::{AtomicIsize, Ordering}, time::Duration, }; use ostd::{ sync::{Waiter, Waker}, task::Task, }; use crate::{ events::{IoEvents, Observer, SyncSubject}, prelude::*, time::wait::TimeoutExt, }; /// A pollee represents any I/O objec...
kernel/src/process/signal/poll.rs
null
null
null
null
null
source
asterinas
// SPDX-License-Identifier: MPL-2.0 use bitflags::bitflags; use super::{ c_types::sigaction_t, constants::*, sig_mask::{SigMask, SigSet}, sig_num::SigNum, }; use crate::prelude::*; #[derive(Debug, Copy, Clone, PartialEq, Eq, Default)] pub enum SigAction { #[default] Dfl, // Default action ...
kernel/src/process/signal/sig_action.rs
null
null
null
null
null
source
asterinas
// SPDX-License-Identifier: MPL-2.0 use super::{constants::*, sig_action::SigAction, sig_num::SigNum}; use crate::{ prelude::*, process::signal::{sig_action::SigActionFlags, signals::Signal}, }; #[derive(Copy, Clone)] pub struct SigDispositions { // SigNum -> SigAction map: [SigAction; COUNT_ALL_SIGS]...
kernel/src/process/signal/sig_disposition.rs
null
null
null
null
null
source
asterinas
// SPDX-License-Identifier: MPL-2.0 //! Signal sets and atomic masks. //! //! A signal set is a bit-set of signals. A signal mask is a set of signals //! that are blocked from delivery to a thread. An atomic signal mask //! implementation is provided for shared access to signal masks. use core::{ fmt::LowerHex, ...
kernel/src/process/signal/sig_mask.rs
null
null
null
null
null
source
asterinas
// SPDX-License-Identifier: MPL-2.0 #![expect(dead_code)] use core::sync::atomic::{AtomicU8, Ordering}; use super::constants::*; use crate::prelude::*; #[derive(Debug, Clone, Copy, PartialEq, Eq)] pub struct SigNum { sig_num: u8, } impl TryFrom<u8> for SigNum { type Error = Error; fn try_from(sig_num:...
kernel/src/process/signal/sig_num.rs
null
null
null
null
null
source
asterinas
// SPDX-License-Identifier: MPL-2.0 use core::sync::atomic::{AtomicUsize, Ordering}; use super::{ constants::*, sig_mask::{SigMask, SigSet}, sig_num::SigNum, signals::Signal, }; use crate::{ events::IoEvents, prelude::*, process::signal::{PollHandle, Pollee, sig_disposition::SigDisposition...
kernel/src/process/signal/sig_queues.rs
null
null
null
null
null
source
asterinas
// SPDX-License-Identifier: MPL-2.0 use crate::{prelude::*, process::signal::c_types::stack_t}; /// User-provided signal stack. /// /// Signal stack is per-thread, and each thread can have at most one signal stack. /// If one signal handler specifying the `SA_ONSTACK` flag, /// the handler should be executed on the s...
kernel/src/process/signal/sig_stack.rs
null
null
null
null
null
source
asterinas
// SPDX-License-Identifier: MPL-2.0 #![cfg_attr(target_arch = "loongarch64", expect(dead_code))] use super::Signal; use crate::{ prelude::*, process::signal::{c_types::siginfo_t, sig_num::SigNum}, }; #[derive(Debug, Clone, Copy, PartialEq)] pub struct FaultSignal { num: SigNum, code: i32, addr: O...
kernel/src/process/signal/signals/fault.rs
null
null
null
null
null
source
asterinas
// SPDX-License-Identifier: MPL-2.0 use super::Signal; use crate::process::signal::{c_types::siginfo_t, constants::SI_KERNEL, sig_num::SigNum}; #[derive(Debug, Clone, Copy, PartialEq)] pub struct KernelSignal { num: SigNum, } impl KernelSignal { pub const fn new(num: SigNum) -> Self { Self { num } ...
kernel/src/process/signal/signals/kernel.rs
null
null
null
null
null
source
asterinas
// SPDX-License-Identifier: MPL-2.0 pub mod fault; pub mod kernel; pub mod raw; pub mod user; use core::{any::Any, fmt::Debug}; use super::{c_types::siginfo_t, sig_num::SigNum}; pub trait Signal: Send + Sync + Debug + Any { /// Returns the number of the signal. fn num(&self) -> SigNum; /// Returns the s...
kernel/src/process/signal/signals/mod.rs
null
null
null
null
null
source
asterinas
// SPDX-License-Identifier: MPL-2.0 use core::fmt::Debug; use crate::process::signal::{c_types::siginfo_t, sig_num::SigNum, signals::Signal}; /// A signal that carries raw [`siginfo_t`] information. #[derive(Clone, Copy)] pub struct RawSignal { info: siginfo_t, } impl Debug for RawSignal { fn fmt(&self, f: ...
kernel/src/process/signal/signals/raw.rs
null
null
null
null
null
source
asterinas
// SPDX-License-Identifier: MPL-2.0 #![expect(dead_code)] use super::Signal; use crate::{ context::Context, process::{ Pid, Uid, signal::{ c_types::siginfo_t, constants::{SI_QUEUE, SI_TKILL, SI_USER}, sig_num::SigNum, }, }, }; #[derive(Debug, Cl...
kernel/src/process/signal/signals/user.rs
null
null
null
null
null
source
asterinas
// SPDX-License-Identifier: MPL-2.0 #![expect(dead_code)] #![expect(unused_variables)] use alloc::sync::Arc; use core::time::Duration; use ostd::sync::{MutexGuard, SpinLock, WaitQueue}; use crate::time::wait::WaitTimeout; /// Represents potential errors during lock operations on synchronization primitives, /// spe...
kernel/src/process/sync/condvar.rs
null
null
null
null
null
source
asterinas
// SPDX-License-Identifier: MPL-2.0 mod condvar; #[expect(unused_imports)] pub use self::condvar::{Condvar, LockErr};
kernel/src/process/sync/mod.rs
null
null
null
null
null
source
asterinas
// SPDX-License-Identifier: MPL-2.0 mod nice; mod sched_class; mod stats; pub use self::{ nice::{AtomicNice, Nice}, sched_class::{ RealTimePolicy, RealTimePriority, SchedAttr, SchedPolicy, init, init_on_each_cpu, }, stats::{loadavg, nr_queued_and_running}, };
kernel/src/sched/mod.rs
null
null
null
null
null
source
asterinas
// SPDX-License-Identifier: MPL-2.0 use core::sync::atomic::AtomicI8; use aster_util::ranged_integer::RangedI8; use atomic_integer_wrapper::define_atomic_version_of_integer_like_type; /// The process scheduling nice value. /// /// It is an integer in the range of [-20, 19]. Process with a smaller nice /// value is m...
kernel/src/sched/nice.rs
null
null
null
null
null
source
asterinas
// SPDX-License-Identifier: MPL-2.0 use alloc::{collections::BinaryHeap, sync::Arc}; use core::{ cmp::{self, Reverse}, sync::atomic::{AtomicU64, Ordering}, }; use ostd::{ cpu::{CpuId, num_cpus}, task::{ Task, scheduler::{EnqueueFlags, UpdateFlags}, }, }; use super::{ CurrentRu...
kernel/src/sched/sched_class/fair.rs
null
null
null
null
null
source
asterinas
// SPDX-License-Identifier: MPL-2.0 use alloc::sync::Arc; use ostd::task::{ Task, scheduler::{EnqueueFlags, UpdateFlags}, }; use super::{CurrentRuntime, SchedAttr, SchedClassRq}; /// The per-cpu run queue for the IDLE scheduling class. /// /// This run queue is used for the per-cpu idle entity, if any. pub(...
kernel/src/sched/sched_class/idle.rs
null
null
null
null
null
source
asterinas
// SPDX-License-Identifier: MPL-2.0 //! Completely Fair Scheduler (CFS). #![warn(unused)] use alloc::{boxed::Box, sync::Arc}; use core::{fmt, ops::Bound, sync::atomic::Ordering}; use ostd::{ arch::read_tsc as sched_clock, cpu::{CpuId, CpuSet, PinCurrentCpu, all_cpus}, irq::disable_local, sync::{Loca...
kernel/src/sched/sched_class/mod.rs
null
null
null
null
null
source
asterinas
// SPDX-License-Identifier: MPL-2.0 use core::sync::atomic::{AtomicU8, Ordering::Relaxed}; use atomic_integer_wrapper::define_atomic_version_of_integer_like_type; use int_to_c_enum::TryFromInt; use ostd::sync::SpinLock; pub use super::real_time::{RealTimePolicy, RealTimePriority}; use crate::sched::nice::Nice; /// ...
kernel/src/sched/sched_class/policy.rs
null
null
null
null
null
source
asterinas
// SPDX-License-Identifier: MPL-2.0 use alloc::{collections::VecDeque, sync::Arc}; use core::{ array, num::NonZero, sync::atomic::{AtomicU8, AtomicU64, Ordering::Relaxed}, }; use aster_util::ranged_integer::RangedU8; use bitvec::{BitArr, bitarr}; use ostd::{ cpu::CpuId, task::{ Task, ...
kernel/src/sched/sched_class/real_time.rs
null
null
null
null
null
source
asterinas
// SPDX-License-Identifier: MPL-2.0 use alloc::sync::Arc; use ostd::task::{ Task, scheduler::{EnqueueFlags, UpdateFlags}, }; use super::{CurrentRuntime, SchedAttr, SchedClassRq}; /// The per-cpu run queue for the STOP scheduling class. /// /// This is a singleton class, meaning that only one thread can be i...
kernel/src/sched/sched_class/stop.rs
null
null
null
null
null
source
asterinas
// SPDX-License-Identifier: MPL-2.0 use core::mem; use spin::Once; /// Returns the numerator and denominator of the ratio R: /// /// R = 10^9 (ns in a sec) / TSC clock frequency fn tsc_factors() -> (u64, u64) { static FACTORS: Once<(u64, u64)> = Once::new(); *FACTORS.call_once(|| { let freq = ost...
kernel/src/sched/sched_class/time.rs
null
null
null
null
null
source
asterinas
// SPDX-License-Identifier: MPL-2.0 //! This module implements the CPU load average calculation. //! //! Reference: <https://github.com/torvalds/linux/blob/46132e3/kernel/sched/loadavg.c> use core::sync::atomic::{AtomicU64, Ordering::Relaxed}; use aster_util::fixed_point::FixedU32; use ostd::{ sync::RwLock, ...
kernel/src/sched/stats/loadavg.rs
null
null
null
null
null
source
asterinas
// SPDX-License-Identifier: MPL-2.0 pub mod loadavg; mod scheduler_stats; pub use scheduler_stats::{SchedulerStats, nr_queued_and_running, set_stats_from_scheduler};
kernel/src/sched/stats/mod.rs
null
null
null
null
null
source
asterinas
// SPDX-License-Identifier: MPL-2.0 use ostd::timer; use spin::Once; use super::loadavg; /// The global scheduler statistic singleton static SCHEDULER_STATS: Once<&'static dyn SchedulerStats> = Once::new(); /// Set the global scheduler statistics singleton. /// /// This function should be called once to set the sch...
kernel/src/sched/stats/scheduler_stats.rs
null
null
null
null
null
source
asterinas
// SPDX-License-Identifier: MPL-2.0 #[cfg(all(target_arch = "x86_64", feature = "cvm_guest"))] mod tsm; pub(super) fn init() { #[cfg(all(target_arch = "x86_64", feature = "cvm_guest"))] tsm::init(); }
kernel/src/security/mod.rs
null
null
null
null
null
source
asterinas
// SPDX-License-Identifier: MPL-2.0 //! Trusted Security Manager (TSM). //! //! This module provides a cross-vendor ConfigFS interface //! for generating confidential-computing attestation reports. //! Userspace writes a request blob under `/sys/kernel/config/tsm/report/$name/inblob` //! and reads back the signed repo...
kernel/src/security/tsm.rs
null
null
null
null
null
source
asterinas
// SPDX-License-Identifier: MPL-2.0 use super::SyscallReturn; use crate::{ fs::{ file_table::{FdFlags, FileDesc, get_file_fast}, utils::{CreationFlags, StatusFlags}, }, prelude::*, util::net::write_socket_addr_to_user, }; pub fn sys_accept( sockfd: FileDesc, sockaddr_ptr: Vaddr...
kernel/src/syscall/accept.rs
null
null
null
null
null
source
asterinas
// SPDX-License-Identifier: MPL-2.0 use super::SyscallReturn; use crate::{ fs::{ file_table::FileDesc, path::{AT_FDCWD, FsPath}, utils::{PATH_MAX, Permission}, }, prelude::*, }; pub fn sys_faccessat( dirfd: FileDesc, path_ptr: Vaddr, mode: u16, ctx: &Context, ) -> R...
kernel/src/syscall/access.rs
null
null
null
null
null
source
asterinas
// SPDX-License-Identifier: MPL-2.0 use core::time::Duration; use super::SyscallReturn; use crate::{prelude::*, time::timer::Timeout}; pub fn sys_alarm(seconds: u32, ctx: &Context) -> Result<SyscallReturn> { debug!("seconds = {}", seconds); let alarm_timer = ctx.process.timer_manager().alarm_timer(); le...
kernel/src/syscall/alarm.rs
null
null
null
null
null
source
asterinas
// SPDX-License-Identifier: MPL-2.0 use ostd::arch::cpu::context::UserContext; use super::SyscallReturn; use crate::prelude::*; #[expect(non_camel_case_types)] #[repr(u64)] #[derive(Debug, TryFromInt)] enum ArchPrctlCode { ARCH_SET_GS = 0x1001, ARCH_SET_FS = 0x1002, ARCH_GET_FS = 0x1003, ARCH_GET_GS ...
kernel/src/syscall/arch_prctl.rs
null
null
null
null
null
source
asterinas
// SPDX-License-Identifier: MPL-2.0 use super::SyscallReturn; use crate::{ fs::file_table::{FileDesc, get_file_fast}, prelude::*, util::net::read_socket_addr_from_user, }; pub fn sys_bind( sockfd: FileDesc, sockaddr_ptr: Vaddr, addrlen: u32, ctx: &Context, ) -> Result<SyscallReturn> { ...
kernel/src/syscall/bind.rs
null
null
null
null
null
source
asterinas
// SPDX-License-Identifier: MPL-2.0 use crate::{prelude::*, syscall::SyscallReturn}; /// expand the user heap to new heap end, returns the new heap end if expansion succeeds. pub fn sys_brk(heap_end: u64, ctx: &Context) -> Result<SyscallReturn> { let new_heap_end = if heap_end == 0 { None } else { ...
kernel/src/syscall/brk.rs
null
null
null
null
null
source
asterinas
// SPDX-License-Identifier: MPL-2.0 use ostd::mm::VmIo; use super::SyscallReturn; use crate::{ prelude::*, process::{ credentials::c_types::{CUserCapData, CUserCapHeader, LINUX_CAPABILITY_VERSION_3}, posix_thread::{AsPosixThread, thread_table}, }, }; pub fn sys_capget( cap_user_header...
kernel/src/syscall/capget.rs
null
null
null
null
null
source
asterinas
// SPDX-License-Identifier: MPL-2.0 use ostd::mm::VmIo; use super::SyscallReturn; use crate::{ prelude::*, process::credentials::{ BOUNDING_CAPSET, c_types::{CUserCapData, CUserCapHeader, LINUX_CAPABILITY_VERSION_3}, capabilities::CapSet, }, }; pub fn sys_capset( cap_user_head...
kernel/src/syscall/capset.rs
null
null
null
null
null
source
asterinas
// SPDX-License-Identifier: MPL-2.0 use super::SyscallReturn; use crate::{ fs::{ file_table::{FileDesc, get_file_fast}, path::FsPath, utils::InodeType, }, prelude::*, syscall::constants::MAX_FILENAME_LEN, }; pub fn sys_chdir(path_ptr: Vaddr, ctx: &Context) -> Result<SyscallRetu...
kernel/src/syscall/chdir.rs
null
null
null
null
null
source
asterinas
// SPDX-License-Identifier: MPL-2.0 use super::SyscallReturn; use crate::{ fs, fs::{ file_table::{FileDesc, get_file_fast}, path::{AT_FDCWD, FsPath}, utils::{InodeMode, PATH_MAX}, }, prelude::*, }; pub fn sys_fchmod(fd: FileDesc, mode: u16, ctx: &Context) -> Result<SyscallRetur...
kernel/src/syscall/chmod.rs
null
null
null
null
null
source
asterinas
// SPDX-License-Identifier: MPL-2.0 use super::SyscallReturn; use crate::{ fs::{ file_table::{FileDesc, get_file_fast}, path::{AT_FDCWD, FsPath}, utils::PATH_MAX, }, prelude::*, process::{Gid, Uid}, }; pub fn sys_fchown(fd: FileDesc, uid: i32, gid: i32, ctx: &Context) -> Result...
kernel/src/syscall/chown.rs
null
null
null
null
null
source
asterinas
// SPDX-License-Identifier: MPL-2.0 use super::SyscallReturn; use crate::{ fs::{path::FsPath, utils::InodeType}, prelude::*, syscall::constants::MAX_FILENAME_LEN, }; pub fn sys_chroot(path_ptr: Vaddr, ctx: &Context) -> Result<SyscallReturn> { let path_name = ctx.user_space().read_cstring(path_ptr, MAX...
kernel/src/syscall/chroot.rs
null
null
null
null
null
source
asterinas
// SPDX-License-Identifier: MPL-2.0 use core::time::Duration; use int_to_c_enum::TryFromInt; use ostd::mm::VmIo; use super::SyscallReturn; use crate::{ prelude::*, process::{ posix_thread::{AsPosixThread, thread_table}, process_table, }, time::{ Clock, clockid_t, clock...
kernel/src/syscall/clock_gettime.rs
null
null
null
null
null
source
asterinas
// SPDX-License-Identifier: MPL-2.0 use core::num::NonZeroU64; use ostd::{arch::cpu::context::UserContext, mm::VmIo}; use super::SyscallReturn; use crate::{ prelude::*, process::{CloneArgs, CloneFlags, clone_child, signal::sig_num::SigNum}, vm::vmar::is_userspace_vaddr, }; // The order of arguments for ...
kernel/src/syscall/clone.rs
null
null
null
null
null
source
asterinas
// SPDX-License-Identifier: MPL-2.0 use bitflags::bitflags; use super::SyscallReturn; use crate::{ fs, fs::file_table::{FdFlags, FileDesc}, prelude::*, process::ContextUnshareAdminApi, }; bitflags! { struct CloseRangeFlags: u32 { const UNSHARE = 1 << 1; const CLOEXEC = 1 << 2; ...
kernel/src/syscall/close.rs
null
null
null
null
null
source
asterinas
// SPDX-License-Identifier: MPL-2.0 use super::SyscallReturn; use crate::{ fs::file_table::{FileDesc, get_file_fast}, prelude::*, util::net::read_socket_addr_from_user, }; pub fn sys_connect( sockfd: FileDesc, sockaddr_ptr: Vaddr, addr_len: u32, ctx: &Context, ) -> Result<SyscallReturn> { ...
kernel/src/syscall/connect.rs
null
null
null
null
null
source
asterinas
// SPDX-License-Identifier: MPL-2.0 //! constants used in syscall /// LONGEST ALLOWED FILENAME pub const MAX_FILENAME_LEN: usize = 4096;
kernel/src/syscall/constants.rs
null
null
null
null
null
source
asterinas
// SPDX-License-Identifier: MPL-2.0 use super::SyscallReturn; use crate::{ fs::file_table::{FdFlags, FileDesc, get_file_fast}, prelude::*, process::ResourceType, }; pub fn sys_dup(old_fd: FileDesc, ctx: &Context) -> Result<SyscallReturn> { debug!("old_fd = {}", old_fd); let file_table = ctx.threa...
kernel/src/syscall/dup.rs
null
null
null
null
null
source
asterinas
// SPDX-License-Identifier: MPL-2.0 use core::{sync::atomic::Ordering, time::Duration}; use ostd::mm::VmIo; use super::SyscallReturn; use crate::{ events::IoEvents, fs::{ epoll::{EpollCtl, EpollEvent, EpollFile, EpollFlags}, file_table::{FdFlags, FileDesc, get_file_fast}, utils::Creat...
kernel/src/syscall/epoll.rs
null
null
null
null
null
source
asterinas
// SPDX-License-Identifier: MPL-2.0 //! `eventfd()` creates an "eventfd object" (we name it as `EventFile`) //! which serves as a mechanism for event wait/notify. //! //! `EventFile` holds a u64 integer counter. //! Writing to `EventFile` increments the counter by the written value. //! Reading from `EventFile` return...
kernel/src/syscall/eventfd.rs
null
null
null
null
null
source
asterinas
// SPDX-License-Identifier: MPL-2.0 use ostd::arch::cpu::context::UserContext; use super::{SyscallReturn, constants::*}; use crate::{ fs::{ file_table::FileDesc, path::{AT_FDCWD, FsPath, Path}, }, prelude::*, process::do_execve, }; pub fn sys_execve( filename_ptr: Vaddr, argv_...
kernel/src/syscall/execve.rs
null
null
null
null
null
source
asterinas
// SPDX-License-Identifier: MPL-2.0 use crate::{ prelude::*, process::{TermStatus, posix_thread::do_exit}, syscall::SyscallReturn, }; pub fn sys_exit(exit_code: i32, _ctx: &Context) -> Result<SyscallReturn> { debug!("exid code = {}", exit_code); let term_status = TermStatus::Exited(exit_code as _...
kernel/src/syscall/exit.rs
null
null
null
null
null
source
asterinas
// SPDX-License-Identifier: MPL-2.0 use crate::{ prelude::*, process::{TermStatus, posix_thread::do_exit_group}, syscall::SyscallReturn, }; /// Exit all thread in a process. pub fn sys_exit_group(exit_code: u64, _ctx: &Context) -> Result<SyscallReturn> { // Exit all thread in current process let t...
kernel/src/syscall/exit_group.rs
null
null
null
null
null
source
asterinas
// SPDX-License-Identifier: MPL-2.0 use super::SyscallReturn; use crate::{fs::file_table::get_file_fast, prelude::*}; #[repr(i32)] #[derive(Debug, TryFromInt)] enum FadviseBehavior { Normal = 0, Random = 1, Sequential = 2, Willneed = 3, Dontneed = 4, Noreuse = 5, } pub fn sys_fadvise64( f...
kernel/src/syscall/fadvise64.rs
null
null
null
null
null
source
asterinas
// SPDX-License-Identifier: MPL-2.0 use super::SyscallReturn; use crate::{ fs, fs::{ file_table::{FileDesc, get_file_fast}, utils::FallocMode, }, prelude::*, process::ResourceType, }; pub fn sys_fallocate( fd: FileDesc, mode: u64, offset: i64, len: i64, ctx: &Co...
kernel/src/syscall/fallocate.rs
null
null
null
null
null
source
asterinas
// SPDX-License-Identifier: MPL-2.0 use ostd::mm::VmIo; use super::SyscallReturn; use crate::{ fs::{ file_handle::FileLike, file_table::{FdFlags, FileDesc, WithFileTable, get_file_fast}, ramfs::memfd::{FileSeals, MemfdInodeHandle}, utils::{FileRange, OFFSET_MAX, RangeLockItem, Rang...
kernel/src/syscall/fcntl.rs
null
null
null
null
null
source
asterinas
// SPDX-License-Identifier: MPL-2.0 use super::SyscallReturn; use crate::{ fs::{ file_table::{FileDesc, get_file_fast}, utils::{FlockItem, FlockType}, }, prelude::*, }; pub fn sys_flock(fd: FileDesc, ops: i32, ctx: &Context) -> Result<SyscallReturn> { debug!("flock: fd: {}, ops: {:?}",...
kernel/src/syscall/flock.rs
null
null
null
null
null
source
asterinas
// SPDX-License-Identifier: MPL-2.0 use ostd::arch::cpu::context::UserContext; use super::SyscallReturn; use crate::{ prelude::*, process::{CloneArgs, clone_child}, }; pub fn sys_fork(ctx: &Context, parent_context: &UserContext) -> Result<SyscallReturn> { let clone_args = CloneArgs::for_fork(); let c...
kernel/src/syscall/fork.rs
null
null
null
null
null
source
asterinas
// SPDX-License-Identifier: MPL-2.0 use super::SyscallReturn; use crate::{ fs::file_table::{FileDesc, get_file_fast}, prelude::*, }; pub fn sys_fsync(fd: FileDesc, ctx: &Context) -> Result<SyscallReturn> { debug!("fd = {}", fd); let mut file_table = ctx.thread_local.borrow_file_table_mut(); let f...
kernel/src/syscall/fsync.rs
null
null
null
null
null
source
asterinas
// SPDX-License-Identifier: MPL-2.0 use core::time::Duration; use ostd::mm::VmIo; use crate::{ current_userspace, prelude::*, process::posix_thread::futex::{ FutexFlags, FutexOp, futex_op_and_flags_from_u32, futex_requeue, futex_wait, futex_wait_bitset, futex_wake, futex_wake_bitset, fute...
kernel/src/syscall/futex.rs
null
null
null
null
null
source
asterinas
// SPDX-License-Identifier: MPL-2.0 use alloc::{sync::Arc, vec::Vec}; use core::sync::atomic::Ordering; use super::SyscallReturn; use crate::{ prelude::*, process::{ProcessGroup, posix_thread::AsPosixThread}, thread::Thread, }; #[expect(dead_code)] pub(super) enum IoPrioWho { Thread(Arc<Thread>), ...
kernel/src/syscall/get_ioprio.rs
null
null
null
null
null
source
asterinas
// SPDX-License-Identifier: MPL-2.0 use core::sync::atomic::Ordering; use super::SyscallReturn; use crate::{ prelude::*, process::{Pgid, Pid, Process, Uid, posix_thread::AsPosixThread, process_table}, sched::Nice, }; pub fn sys_get_priority(which: i32, who: u32, ctx: &Context) -> Result<SyscallReturn> { ...
kernel/src/syscall/get_priority.rs
null
null
null
null
null
source
asterinas
// SPDX-License-Identifier: MPL-2.0 use ostd::{cpu::CpuId, mm::VmIo}; use super::SyscallReturn; use crate::prelude::*; pub fn sys_getcpu(cpu: Vaddr, node: Vaddr, _tcache: Vaddr, ctx: &Context) -> Result<SyscallReturn> { // The third argument `tcache` is unused since Linux 2.6.24, so we ignore it. // The sys...
kernel/src/syscall/getcpu.rs
null
null
null
null
null
source
asterinas
// SPDX-License-Identifier: MPL-2.0 use ostd::mm::VmIo; use super::SyscallReturn; use crate::{fs::path::AbsPathResult, prelude::*}; pub fn sys_getcwd(buf: Vaddr, len: usize, ctx: &Context) -> Result<SyscallReturn> { let abs_path = { let fs_ref = ctx.thread_local.borrow_fs(); let path_resolver = f...
kernel/src/syscall/getcwd.rs
null
null
null
null
null
source
asterinas
// SPDX-License-Identifier: MPL-2.0 use core::marker::PhantomData; use align_ext::AlignExt; use super::SyscallReturn; use crate::{ fs, fs::{ file_table::{FileDesc, get_file_fast}, utils::{DirentVisitor, InodeType}, }, prelude::*, }; pub fn sys_getdents( fd: FileDesc, buf_addr...
kernel/src/syscall/getdents64.rs
null
null
null
null
null
source
asterinas
// SPDX-License-Identifier: MPL-2.0 use super::SyscallReturn; use crate::{prelude::*, process::Gid}; pub fn sys_getegid(ctx: &Context) -> Result<SyscallReturn> { let egid = ctx.posix_thread.credentials().egid(); Ok(SyscallReturn::Return(<Gid as Into<u32>>::into(egid) as _)) }
kernel/src/syscall/getegid.rs
null
null
null
null
null
source
asterinas
// SPDX-License-Identifier: MPL-2.0 use super::SyscallReturn; use crate::{prelude::*, process::Uid}; pub fn sys_geteuid(ctx: &Context) -> Result<SyscallReturn> { let euid = ctx.posix_thread.credentials().euid(); Ok(SyscallReturn::Return(<Uid as Into<u32>>::into(euid) as _)) }
kernel/src/syscall/geteuid.rs
null
null
null
null
null
source
asterinas
// SPDX-License-Identifier: MPL-2.0 use super::SyscallReturn; use crate::{prelude::*, process::Gid}; pub fn sys_getgid(ctx: &Context) -> Result<SyscallReturn> { let gid = ctx.posix_thread.credentials().rgid(); Ok(SyscallReturn::Return(<Gid as Into<u32>>::into(gid) as _)) }
kernel/src/syscall/getgid.rs
null
null
null
null
null
source
asterinas
// SPDX-License-Identifier: MPL-2.0 use ostd::mm::VmIo; use super::SyscallReturn; use crate::prelude::*; pub fn sys_getgroups(size: i32, group_list_addr: Vaddr, ctx: &Context) -> Result<SyscallReturn> { debug!("size = {}, group_list_addr = 0x{:x}", size, group_list_addr); if size < 0 { return_errno_...
kernel/src/syscall/getgroups.rs
null
null
null
null
null
source
asterinas
// SPDX-License-Identifier: MPL-2.0 use super::SyscallReturn; use crate::{ fs::file_table::{FileDesc, get_file_fast}, prelude::*, util::net::write_socket_addr_to_user, }; pub fn sys_getpeername( sockfd: FileDesc, addr: Vaddr, addrlen_ptr: Vaddr, ctx: &Context, ) -> Result<SyscallReturn> { ...
kernel/src/syscall/getpeername.rs
null
null
null
null
null
source
asterinas
// SPDX-License-Identifier: MPL-2.0 use super::SyscallReturn; use crate::{ prelude::*, process::{Pid, process_table}, }; pub fn sys_getpgid(pid: Pid, ctx: &Context) -> Result<SyscallReturn> { debug!("pid = {}", pid); // The documentation quoted below is from // <https://www.man7.org/linux/man-pag...
kernel/src/syscall/getpgid.rs
null
null
null
null
null
source
asterinas
// SPDX-License-Identifier: MPL-2.0 use super::SyscallReturn; use crate::prelude::*; pub fn sys_getpgrp(ctx: &Context) -> Result<SyscallReturn> { Ok(SyscallReturn::Return(ctx.process.pgid() as _)) }
kernel/src/syscall/getpgrp.rs
null
null
null
null
null
source
asterinas
// SPDX-License-Identifier: MPL-2.0 use super::SyscallReturn; use crate::prelude::*; pub fn sys_getpid(ctx: &Context) -> Result<SyscallReturn> { let pid = ctx.process.pid(); debug!("[sys_getpid]: pid = {}", pid); Ok(SyscallReturn::Return(pid as _)) }
kernel/src/syscall/getpid.rs
null
null
null
null
null
source
asterinas
// SPDX-License-Identifier: MPL-2.0 use super::SyscallReturn; use crate::prelude::*; pub fn sys_getppid(ctx: &Context) -> Result<SyscallReturn> { Ok(SyscallReturn::Return(ctx.process.parent().pid() as _)) }
kernel/src/syscall/getppid.rs
null
null
null
null
null
source
asterinas
// SPDX-License-Identifier: MPL-2.0 use super::SyscallReturn; use crate::{device, prelude::*}; pub fn sys_getrandom(buf: Vaddr, count: usize, flags: u32, ctx: &Context) -> Result<SyscallReturn> { let flags = GetRandomFlags::from_bits(flags) .ok_or_else(|| Error::with_message(Errno::EINVAL, "invalid flags"...
kernel/src/syscall/getrandom.rs
null
null
null
null
null
source
asterinas
// SPDX-License-Identifier: MPL-2.0 use ostd::mm::VmIo; use super::SyscallReturn; use crate::prelude::*; pub fn sys_getresgid( rgid_ptr: Vaddr, egid_ptr: Vaddr, sgid_ptr: Vaddr, ctx: &Context, ) -> Result<SyscallReturn> { debug!("rgid_ptr = 0x{rgid_ptr:x}, egid_ptr = 0x{egid_ptr:x}, sgid_ptr = 0x...
kernel/src/syscall/getresgid.rs
null
null
null
null
null
source
asterinas
// SPDX-License-Identifier: MPL-2.0 use ostd::mm::VmIo; use super::SyscallReturn; use crate::prelude::*; pub fn sys_getresuid( ruid_ptr: Vaddr, euid_ptr: Vaddr, suid_ptr: Vaddr, ctx: &Context, ) -> Result<SyscallReturn> { debug!("ruid_ptr = 0x{ruid_ptr:x}, euid_ptr = 0x{euid_ptr:x}, suid_ptr = 0x...
kernel/src/syscall/getresuid.rs
null
null
null
null
null
source
asterinas
// 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}; #[derive(Debug, Copy, Clone, TryFromInt, PartialEq)] #[repr(i32)] enum RusageTarget { ForSelf = 0, Children = -1, Thread = 1, } pub fn sys_getrusage(...
kernel/src/syscall/getrusage.rs
null
null
null
null
null
source
asterinas
// SPDX-License-Identifier: MPL-2.0 use super::SyscallReturn; use crate::{ prelude::*, process::{Pid, process_table}, }; pub fn sys_getsid(pid: Pid, ctx: &Context) -> Result<SyscallReturn> { debug!("pid = {}", pid); // The documentation quoted below is from // <https://www.man7.org/linux/man-page...
kernel/src/syscall/getsid.rs
null
null
null
null
null
source
asterinas
// SPDX-License-Identifier: MPL-2.0 use super::SyscallReturn; use crate::{ fs::file_table::{FileDesc, get_file_fast}, prelude::*, util::net::write_socket_addr_to_user, }; pub fn sys_getsockname( sockfd: FileDesc, addr: Vaddr, addrlen_ptr: Vaddr, ctx: &Context, ) -> Result<SyscallReturn> { ...
kernel/src/syscall/getsockname.rs
null
null
null
null
null