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
use core::ops::Sub;
use super::message::UeventMessage;
use crate::{
events::IoEvents,
net::socket::{
netlink::{NetlinkSocketAddr, common::BoundNetlink},
util::{SendRecvFlags, datagram_common},
},
prelude::*,
util::{MultiRead, MultiWrite},
};
pub... | kernel/src/net/socket/netlink/kobject_uevent/bound.rs | null | null | null | null | null |
source | asterinas | // SPDX-License-Identifier: MPL-2.0
pub(super) use message::UeventMessage;
use crate::net::socket::netlink::{common::NetlinkSocket, table::NetlinkUeventProtocol};
mod bound;
mod message;
pub type NetlinkUeventSocket = NetlinkSocket<NetlinkUeventProtocol>; | kernel/src/net/socket/netlink/kobject_uevent/mod.rs | null | null | null | null | null |
source | asterinas | // SPDX-License-Identifier: MPL-2.0
#![cfg_attr(not(ktest), expect(dead_code))]
use uevent::Uevent;
use crate::{
net::socket::netlink::{
NetlinkSocketAddr, receiver::QueueableMessage, table::MulticastMessage,
},
prelude::*,
util::MultiWrite,
};
mod syn_uevent;
#[cfg(ktest)]
mod test;
mod uev... | kernel/src/net/socket/netlink/kobject_uevent/message/mod.rs | null | null | null | null | null |
source | asterinas | // SPDX-License-Identifier: MPL-2.0
//! The synthetic uevent.
//!
//! The event is triggered when someone writes some content to `/sys/.../uevent` file.
//! It differs from the event triggers by devices.
//!
//! Reference: <https://elixir.bootlin.com/linux/v6.0.9/source/Documentation/ABI/testing/sysfs-uevent>.
use al... | kernel/src/net/socket/netlink/kobject_uevent/message/syn_uevent.rs | null | null | null | null | null |
source | asterinas | // SPDX-License-Identifier: MPL-2.0
use alloc::vec;
use core::str::FromStr;
use ostd::{mm::VmWriter, prelude::*};
use crate::{
net::socket::{
Socket,
netlink::{
GroupIdSet, NetlinkSocketAddr, NetlinkUeventSocket,
kobject_uevent::{
UeventMessage,
... | kernel/src/net/socket/netlink/kobject_uevent/message/test.rs | null | null | null | null | null |
source | asterinas | // SPDX-License-Identifier: MPL-2.0
use core::{
fmt::Display,
str::FromStr,
sync::atomic::{AtomicU64, Ordering},
};
use super::syn_uevent::{SyntheticUevent, Uuid};
use crate::prelude::*;
/// `SysObj` action type.
///
/// Reference: <https://elixir.bootlin.com/linux/v6.14/source/include/linux/kobject.h#L5... | kernel/src/net/socket/netlink/kobject_uevent/message/uevent.rs | null | null | null | null | null |
source | asterinas | // SPDX-License-Identifier: MPL-2.0
//! Netlink message types for all netlink protocols.
//!
//! This module defines how to interpret messages sent from user space and how to write
//! kernel messages back to user space.
mod attr;
mod result;
mod segment;
pub(super) use attr::{Attribute, CAttrHeader, noattr::NoAttr}... | kernel/src/net/socket/netlink/message/mod.rs | null | null | null | null | null |
source | asterinas | // SPDX-License-Identifier: MPL-2.0
use crate::prelude::*;
/// A type that indicates we either parsed a valid value, or hit a recoverable condition and can
/// continue reading.
///
/// If a method returns `Skipped` or `SkippedErr(E)`, it is the callee's responsibility to consume
/// or skip the unreadable bytes so t... | kernel/src/net/socket/netlink/message/result.rs | null | null | null | null | null |
source | asterinas | // SPDX-License-Identifier: MPL-2.0
//! Netlink attributes.
//!
//! Netlink attributes provide additional information for each [`segment`].
//! Each netlink attribute consists of two components:
//! 1. Header: The attribute header is of type [`CAttrHeader`],
//! which specifies the type and length of the attribute.... | kernel/src/net/socket/netlink/message/attr/mod.rs | null | null | null | null | null |
source | asterinas | // SPDX-License-Identifier: MPL-2.0
use super::{Attribute, CAttrHeader};
use crate::{net::socket::netlink::message::ContinueRead, prelude::*, util::MultiRead};
/// A special type indicates that a segment cannot have attributes.
#[derive(Debug)]
pub enum NoAttr {}
impl Attribute for NoAttr {
fn type_(&self) -> u1... | kernel/src/net/socket/netlink/message/attr/noattr.rs | null | null | null | null | null |
source | asterinas | // SPDX-License-Identifier: MPL-2.0
//! This module defines segments that only appear in acknowledgment messages.
//!
//! An acknowledgment segment appears as the final segment in a response message from the kernel.
//! Netlink utilizes two classes of acknowledgment segments:
//! 1. Done Segment: Indicates the conclus... | kernel/src/net/socket/netlink/message/segment/ack.rs | null | null | null | null | null |
source | asterinas | // SPDX-License-Identifier: MPL-2.0
use super::{SegmentBody, header::CMsgSegHdr};
use crate::{
net::socket::netlink::message::{ContinueRead, attr::Attribute},
prelude::*,
util::{MultiRead, MultiWrite},
};
#[derive(Debug)]
pub struct SegmentCommon<Body, Attr> {
header: CMsgSegHdr,
body: Body,
a... | kernel/src/net/socket/netlink/message/segment/common.rs | null | null | null | null | null |
source | asterinas | // SPDX-License-Identifier: MPL-2.0
//! General netlink message types for all netlink protocols.
use align_ext::AlignExt;
use crate::{net::socket::netlink::message::NLMSG_ALIGN, prelude::*, util::MultiRead};
/// `nlmsghdr` in Linux.
///
/// Reference: <https://elixir.bootlin.com/linux/v6.13/source/include/uapi/linu... | kernel/src/net/socket/netlink/message/segment/header.rs | null | null | null | null | null |
source | asterinas | // SPDX-License-Identifier: MPL-2.0
use align_ext::AlignExt;
use header::CMsgSegHdr;
use super::{ContinueRead, NLMSG_ALIGN};
use crate::{
prelude::*,
util::{MultiRead, MultiWrite},
};
pub mod ack;
pub mod common;
pub mod header;
pub trait SegmentBody: Sized + Clone + Copy {
// The actual message body sh... | kernel/src/net/socket/netlink/message/segment/mod.rs | null | null | null | null | null |
source | asterinas | // SPDX-License-Identifier: MPL-2.0
use core::ops::Sub;
use super::message::{RtnlMessage, RtnlSegment};
use crate::{
events::IoEvents,
net::socket::{
netlink::{
NetlinkSocketAddr,
common::BoundNetlink,
message::{ContinueRead, ProtocolSegment},
route::ker... | kernel/src/net/socket/netlink/route/bound.rs | null | null | null | null | null |
source | asterinas | // SPDX-License-Identifier: MPL-2.0
//! Netlink Route Socket.
pub(super) use message::RtnlMessage;
use crate::net::socket::netlink::{common::NetlinkSocket, table::NetlinkRouteProtocol};
mod bound;
mod kernel;
mod message;
pub type NetlinkRouteSocket = NetlinkSocket<NetlinkRouteProtocol>; | kernel/src/net/socket/netlink/route/mod.rs | null | null | null | null | null |
source | asterinas | // SPDX-License-Identifier: MPL-2.0
//! Handle address-related requests.
use core::num::NonZeroU32;
use super::util::finish_response;
use crate::{
net::{
iface::{Iface, iter_all_ifaces},
socket::netlink::{
message::{CMsgSegHdr, CSegmentType, GetRequestFlags, SegHdrCommonFlags},
... | kernel/src/net/socket/netlink/route/kernel/addr.rs | null | null | null | null | null |
source | asterinas | // SPDX-License-Identifier: MPL-2.0
//! Handle link-related requests.
use core::num::NonZero;
use aster_bigtcp::iface::InterfaceType;
use super::util::finish_response;
use crate::{
net::{
iface::{Iface, iter_all_ifaces},
socket::netlink::{
message::{CMsgSegHdr, CSegmentType, GetReque... | kernel/src/net/socket/netlink/route/kernel/link.rs | null | null | null | null | null |
source | asterinas | // SPDX-License-Identifier: MPL-2.0
//! This module defines the kernel socket,
//! which is responsible for handling requests from user space.
use core::marker::PhantomData;
use super::message::{RtnlMessage, RtnlSegment};
use crate::{
net::socket::netlink::{
addr::PortNum,
message::{ErrorSegment,... | kernel/src/net/socket/netlink/route/kernel/mod.rs | null | null | null | null | null |
source | asterinas | // SPDX-License-Identifier: MPL-2.0
use crate::{
net::socket::netlink::{
message::{CMsgSegHdr, DoneSegment, ProtocolSegment, SegHdrCommonFlags},
route::message::RtnlSegment,
},
prelude::*,
};
/// Finishes a response message.
pub fn finish_response(
request_header: &CMsgSegHdr,
dump... | kernel/src/net/socket/netlink/route/kernel/util.rs | null | null | null | null | null |
source | asterinas | // SPDX-License-Identifier: MPL-2.0
//! Netlink message types for the netlink route protocol.
//!
//! This module defines how to interpret messages sent from user space and how to write
//! kernel messages back to user space.
mod attr;
mod segment;
pub(super) use attr::{addr::AddrAttr, link::LinkAttr};
pub(super) us... | kernel/src/net/socket/netlink/route/message/mod.rs | null | null | null | null | null |
source | asterinas | // SPDX-License-Identifier: MPL-2.0
use crate::{
net::socket::netlink::message::{Attribute, CAttrHeader, ContinueRead},
prelude::*,
util::MultiRead,
};
/// Address-related attributes.
///
/// Reference: <https://elixir.bootlin.com/linux/v6.13/source/include/uapi/linux/if_addr.h#L26>.
#[derive(Debug, Clone... | kernel/src/net/socket/netlink/route/message/attr/addr.rs | null | null | null | null | null |
source | asterinas | // SPDX-License-Identifier: MPL-2.0
use super::IFNAME_SIZE;
use crate::{
net::socket::netlink::message::{Attribute, CAttrHeader, ContinueRead},
prelude::*,
util::MultiRead,
};
/// Link-level attributes.
///
/// Reference: <https://elixir.bootlin.com/linux/v6.13/source/include/uapi/linux/if_link.h#L297>.
#... | kernel/src/net/socket/netlink/route/message/attr/link.rs | null | null | null | null | null |
source | asterinas | // SPDX-License-Identifier: MPL-2.0
pub mod addr;
pub mod link;
/// The size limit for interface names.
const IFNAME_SIZE: usize = 16; | kernel/src/net/socket/netlink/route/message/attr/mod.rs | null | null | null | null | null |
source | asterinas | // SPDX-License-Identifier: MPL-2.0
use core::num::NonZeroU32;
use super::legacy::CRtGenMsg;
use crate::{
net::socket::netlink::{
message::{SegmentBody, SegmentCommon},
route::message::attr::addr::AddrAttr,
},
prelude::*,
};
pub type AddrSegment = SegmentCommon<AddrSegmentBody, AddrAttr>;... | kernel/src/net/socket/netlink/route/message/segment/addr.rs | null | null | null | null | null |
source | asterinas | // SPDX-License-Identifier: MPL-2.0
use super::{addr::CIfaddrMsg, link::CIfinfoMsg};
use crate::prelude::*;
/// `rtgenmsg` in Linux.
///
/// Reference: <https://elixir.bootlin.com/linux/v6.13/source/include/uapi/linux/rtnetlink.h#L548>.
#[derive(Debug, Clone, Copy, Pod)]
#[repr(C)]
pub struct CRtGenMsg {
pub fami... | kernel/src/net/socket/netlink/route/message/segment/legacy.rs | null | null | null | null | null |
source | asterinas | // SPDX-License-Identifier: MPL-2.0
use core::num::NonZeroU32;
use aster_bigtcp::iface::{InterfaceFlags, InterfaceType};
use super::legacy::CRtGenMsg;
use crate::{
net::socket::netlink::{
message::{SegmentBody, SegmentCommon},
route::message::attr::link::LinkAttr,
},
prelude::*,
util:... | kernel/src/net/socket/netlink/route/message/segment/link.rs | null | null | null | null | null |
source | asterinas | // SPDX-License-Identifier: MPL-2.0
//! This module defines the message segment,
//! which is the basic unit of a netlink message.
//!
//! Typically, a segment will consist of three parts:
//!
//! 1. Header: The headers of all segments are of type [`CMsgSegHdr`],
//! which indicate the type and total length of the ... | kernel/src/net/socket/netlink/route/message/segment/mod.rs | null | null | null | null | null |
source | asterinas | // SPDX-License-Identifier: MPL-2.0
use crate::prelude::*;
/// `rtmsg` in Linux.
///
/// Reference: <https://elixir.bootlin.com/linux/v6.13/source/include/uapi/linux/rtnetlink.h#L237>.
#[repr(C)]
#[derive(Debug, Clone, Copy, Pod)]
#[expect(unused)]
pub(super) struct CRtMsg {
family: u8,
dst_len: u8,
src_l... | kernel/src/net/socket/netlink/route/message/segment/route.rs | null | null | null | null | null |
source | asterinas | // SPDX-License-Identifier: MPL-2.0
use multicast::MulticastGroup;
pub(super) use multicast::MulticastMessage;
use spin::Once;
use super::{
addr::{GroupIdSet, MAX_GROUPS, NetlinkProtocolId, NetlinkSocketAddr, PortNum},
receiver::QueueableMessage,
};
use crate::{
net::socket::netlink::{
addr::UNSPE... | kernel/src/net/socket/netlink/table/mod.rs | null | null | null | null | null |
source | asterinas | // SPDX-License-Identifier: MPL-2.0
use crate::{
net::socket::netlink::{addr::PortNum, receiver::QueueableMessage},
prelude::*,
};
/// A netlink multicast group.
///
/// A group can contain multiple sockets,
/// each identified by its bound port number.
pub struct MulticastGroup {
members: BTreeSet<PortNu... | kernel/src/net/socket/netlink/table/multicast.rs | null | null | null | null | null |
source | asterinas | // SPDX-License-Identifier: MPL-2.0
macro_rules! impl_socket_options {
($(
$(#[$outer:meta])*
pub struct $name: ident ( $value_ty:ty );
)*) => {
$(
$(#[$outer])*
#[derive(Debug)]
pub struct $name (Option<$value_ty>);
impl $name {
... | kernel/src/net/socket/options/macros.rs | null | null | null | null | null |
source | asterinas | // SPDX-License-Identifier: MPL-2.0
use macros::impl_socket_options;
use super::util::LingerOption;
use crate::{net::socket::unix::CUserCred, prelude::*, process::Gid};
pub(in crate::net) mod macros;
/// Socket options. This trait represents all options that can be set or got for a socket, including
/// socket leve... | kernel/src/net/socket/options/mod.rs | null | null | null | null | null |
source | asterinas | // SPDX-License-Identifier: MPL-2.0
use keyable_arc::KeyableArc;
use super::ns::{self, AbstractHandle};
use crate::{
fs::{path::Path, utils::Inode},
net::socket::util::SocketAddr,
prelude::*,
};
#[derive(Clone, Debug, PartialEq, Eq)]
pub enum UnixSocketAddr {
Unnamed,
Path(Arc<str>),
Abstract... | kernel/src/net/socket/unix/addr.rs | null | null | null | null | null |
source | asterinas | // SPDX-License-Identifier: MPL-2.0
use aster_rights::{Dup, Read, ReadDupOp, ReadOp, TRights};
use aster_rights_proc::require;
use crate::{
prelude::*,
process::{Credentials, Gid, Pid, Uid, posix_thread::AsPosixThread},
};
pub(super) struct SocketCred<R = ReadOp> {
pid: Pid,
cred: Credentials<R>,
}
... | kernel/src/net/socket/unix/cred.rs | null | null | null | null | null |
source | asterinas | // SPDX-License-Identifier: MPL-2.0
use core::fmt;
use aster_rights::ReadOp;
use ostd::task::Task;
use super::{CUserCred, UnixStreamSocket, cred::SocketCred};
use crate::{
fs::{
file_handle::FileLike,
file_table::{FdFlags, get_file_fast},
},
net::socket::util::{CControlHeader, ControlMess... | kernel/src/net/socket/unix/ctrl_msg.rs | null | null | null | null | null |
source | asterinas | // SPDX-License-Identifier: MPL-2.0
mod addr;
mod cred;
mod ctrl_msg;
mod datagram;
mod ns;
mod stream;
pub use addr::UnixSocketAddr;
pub use cred::CUserCred;
pub(super) use ctrl_msg::UnixControlMessage;
pub(super) use datagram::UNIX_DATAGRAM_DEFAULT_BUF_SIZE;
pub use datagram::UnixDatagramSocket;
pub(super) use stre... | kernel/src/net/socket/unix/mod.rs | null | null | null | null | null |
source | asterinas | // SPDX-License-Identifier: MPL-2.0
use alloc::{
collections::{btree_map::BTreeMap, vec_deque::VecDeque},
sync::Arc,
};
use core::sync::atomic::{AtomicBool, Ordering};
use ostd::sync::{RwLock, WaitQueue};
use spin::Once;
use crate::{
events::IoEvents,
net::socket::{
unix::{
UnixSo... | kernel/src/net/socket/unix/datagram/message.rs | null | null | null | null | null |
source | asterinas | // SPDX-License-Identifier: MPL-2.0
mod message;
mod socket;
pub(in crate::net) use message::UNIX_DATAGRAM_DEFAULT_BUF_SIZE;
pub use socket::UnixDatagramSocket; | kernel/src/net/socket/unix/datagram/mod.rs | null | null | null | null | null |
source | asterinas | // SPDX-License-Identifier: MPL-2.0
use core::sync::atomic::{AtomicBool, Ordering};
use aster_rights::ReadDupOp;
use super::message::{MessageQueue, MessageReceiver};
use crate::{
events::IoEvents,
fs::{path::Path, pseudofs::SockFs},
net::socket::{
Socket,
options::{Error as SocketError, P... | kernel/src/net/socket/unix/datagram/socket.rs | null | null | null | null | null |
source | asterinas | // SPDX-License-Identifier: MPL-2.0
use alloc::{collections::btree_map::Entry, format};
use keyable_arc::KeyableArc;
use crate::prelude::*;
#[derive(Debug, PartialEq, Eq, PartialOrd, Ord)]
pub struct AbstractHandle(KeyableArc<[u8]>);
impl AbstractHandle {
fn new(name: Arc<[u8]>) -> Self {
Self(KeyableA... | kernel/src/net/socket/unix/ns/abs.rs | null | null | null | null | null |
source | asterinas | // SPDX-License-Identifier: MPL-2.0
pub(super) use abs::{
AbstractHandle, alloc_ephemeral_abstract_name, create_abstract_name, lookup_abstract_name,
};
pub(super) use path::{create_socket_file, lookup_socket_file};
mod abs;
mod path; | kernel/src/net/socket/unix/ns/mod.rs | null | null | null | null | null |
source | asterinas | // SPDX-License-Identifier: MPL-2.0
use ostd::task::Task;
use crate::{
fs::{
path::{FsPath, Path, SplitPath},
utils::{InodeType, Permission, mkmod},
},
prelude::*,
};
pub fn lookup_socket_file(path: &str) -> Result<Path> {
let path = {
let current = Task::current().unwrap();
... | kernel/src/net/socket/unix/ns/path.rs | null | null | null | null | null |
source | asterinas | // SPDX-License-Identifier: MPL-2.0
use core::{
num::Wrapping,
sync::atomic::{AtomicBool, Ordering},
};
use spin::Once;
use crate::{
events::IoEvents,
fs::utils::{Endpoint, EndpointState},
net::socket::{
unix::{
UnixSocketAddr, addr::UnixSocketAddrBound, cred::SocketCred, ctrl... | kernel/src/net/socket/unix/stream/connected.rs | null | null | null | null | null |
source | asterinas | // SPDX-License-Identifier: MPL-2.0
use core::sync::atomic::{AtomicBool, Ordering};
use aster_rights::ReadOp;
use super::{
connected::Connected,
listener::Listener,
socket::{SHUT_READ_EVENTS, SHUT_WRITE_EVENTS},
};
use crate::{
events::IoEvents,
fs::utils::EndpointState,
net::socket::{
... | kernel/src/net/socket/unix/stream/init.rs | null | null | null | null | null |
source | asterinas | // SPDX-License-Identifier: MPL-2.0
use core::sync::atomic::{AtomicBool, AtomicUsize, Ordering};
use aster_rights::ReadDupOp;
use ostd::sync::WaitQueue;
use super::{
UnixStreamSocket,
connected::Connected,
init::Init,
socket::{SHUT_READ_EVENTS, SHUT_WRITE_EVENTS},
};
use crate::{
events::IoEvents... | kernel/src/net/socket/unix/stream/listener.rs | null | null | null | null | null |
source | asterinas | // SPDX-License-Identifier: MPL-2.0
mod connected;
mod init;
mod listener;
mod socket;
pub(in crate::net) use connected::UNIX_STREAM_DEFAULT_BUF_SIZE;
pub use socket::UnixStreamSocket; | kernel/src/net/socket/unix/stream/mod.rs | null | null | null | null | null |
source | asterinas | // SPDX-License-Identifier: MPL-2.0
use core::sync::atomic::{AtomicBool, Ordering};
use aster_rights::ReadDupOp;
use takeable::Takeable;
use super::{
connected::Connected,
init::Init,
listener::{Backlog, Listener, get_backlog},
};
use crate::{
events::IoEvents,
fs::{file_handle::FileLike, path::P... | kernel/src/net/socket/unix/stream/socket.rs | null | null | null | null | null |
source | asterinas | // SPDX-License-Identifier: MPL-2.0
use ostd::sync::RwMutex;
use super::SendRecvFlags;
use crate::{
events::IoEvents,
prelude::*,
process::signal::Pollee,
return_errno_with_message,
util::{MultiRead, MultiWrite},
};
pub trait Unbound {
type Endpoint;
type BindOptions;
type Bound;
... | kernel/src/net/socket/util/datagram_common.rs | null | null | null | null | null |
source | asterinas | // SPDX-License-Identifier: MPL-2.0
use core::time::Duration;
#[derive(Debug, Default, Clone, Copy)]
pub struct LingerOption {
is_on: bool,
timeout: Duration,
}
impl LingerOption {
pub fn new(is_on: bool, timeout: Duration) -> Self {
Self { is_on, timeout }
}
pub fn is_on(&self) -> bool ... | kernel/src/net/socket/util/linger_option.rs | null | null | null | null | null |
source | asterinas | // SPDX-License-Identifier: MPL-2.0
use align_ext::AlignExt;
use super::SocketAddr;
use crate::{net::socket::unix::UnixControlMessage, prelude::*, util::net::CSocketOptionLevel};
/// Message header used for sendmsg/recvmsg.
#[derive(Debug)]
pub struct MessageHeader {
pub(in crate::net) addr: Option<SocketAddr>,
... | kernel/src/net/socket/util/message_header.rs | null | null | null | null | null |
source | asterinas | // SPDX-License-Identifier: MPL-2.0
pub(super) mod datagram_common;
mod linger_option;
mod message_header;
pub(super) mod options;
mod send_recv_flags;
mod shutdown_cmd;
mod socket_addr;
pub use linger_option::LingerOption;
pub(super) use message_header::CControlHeader;
pub use message_header::{ControlMessage, Messag... | kernel/src/net/socket/util/mod.rs | null | null | null | null | null |
source | asterinas | // SPDX-License-Identifier: MPL-2.0
use core::ops::RangeInclusive;
use aster_bigtcp::socket::{
NeedIfacePoll, TCP_RECV_BUF_LEN, TCP_SEND_BUF_LEN, UDP_RECV_PAYLOAD_LEN, UDP_SEND_PAYLOAD_LEN,
};
use super::LingerOption;
use crate::{
net::socket::{
netlink::NETLINK_DEFAULT_BUF_SIZE,
options::{
... | kernel/src/net/socket/util/options.rs | null | null | null | null | null |
source | asterinas | // SPDX-License-Identifier: MPL-2.0
use crate::prelude::*;
bitflags! {
/// Flags used for send/recv.
/// The definition is from https://elixir.bootlin.com/linux/v6.0.9/source/include/linux/socket.h
#[repr(C)]
#[derive(Pod)]
pub struct SendRecvFlags: i32 {
const MSG_OOB = 1;
const M... | kernel/src/net/socket/util/send_recv_flags.rs | null | null | null | null | null |
source | asterinas | // SPDX-License-Identifier: MPL-2.0
use crate::prelude::*;
/// Shutdown types
/// From <https://elixir.bootlin.com/linux/v6.0.9/source/include/linux/net.h>
#[repr(i32)]
#[derive(Debug, Clone, Copy, PartialEq, Eq, TryFromInt)]
#[expect(non_camel_case_types)]
pub enum SockShutdownCmd {
/// Shutdown receptions
S... | kernel/src/net/socket/util/shutdown_cmd.rs | null | null | null | null | null |
source | asterinas | // SPDX-License-Identifier: MPL-2.0
use aster_bigtcp::wire::{Ipv4Address, PortNum};
use crate::{
net::socket::{netlink::NetlinkSocketAddr, unix::UnixSocketAddr, vsock::addr::VsockSocketAddr},
prelude::*,
};
#[derive(Debug, PartialEq, Eq)]
pub enum SocketAddr {
Unix(UnixSocketAddr),
IPv4(Ipv4Address, ... | kernel/src/net/socket/util/socket_addr.rs | null | null | null | null | null |
source | asterinas | // SPDX-License-Identifier: MPL-2.0
use aster_virtio::device::socket::header::VsockDeviceAddr;
use crate::{net::socket::util::SocketAddr, prelude::*};
#[derive(Copy, Clone, Debug, Default, PartialEq, Eq, PartialOrd, Ord)]
pub struct VsockSocketAddr {
pub cid: u32,
pub port: u32,
}
impl VsockSocketAddr {
... | kernel/src/net/socket/vsock/addr.rs | null | null | null | null | null |
source | asterinas | // SPDX-License-Identifier: MPL-2.0
use alloc::collections::BTreeSet;
use aster_virtio::device::socket::{
connect::{ConnectionInfo, VsockEvent, VsockEventType},
device::SocketDevice,
error::SocketError,
};
use ostd::sync::LocalIrqDisabled;
use super::{
addr::VsockSocketAddr,
stream::{
con... | kernel/src/net/socket/vsock/common.rs | null | null | null | null | null |
source | asterinas | // SPDX-License-Identifier: MPL-2.0
use alloc::sync::Arc;
use aster_virtio::device::socket::{DEVICE_NAME, get_device, register_recv_callback};
use common::VsockSpace;
use spin::Once;
pub mod addr;
pub mod common;
pub mod stream;
pub use addr::VsockSocketAddr;
pub use stream::VsockStreamSocket;
// init static driver... | kernel/src/net/socket/vsock/mod.rs | null | null | null | null | null |
source | asterinas | // SPDX-License-Identifier: MPL-2.0
use aster_virtio::device::socket::connect::{ConnectionInfo, VsockEvent};
use super::connecting::Connecting;
use crate::{
events::IoEvents,
net::socket::{
util::{SendRecvFlags, SockShutdownCmd},
vsock::{VSOCK_GLOBAL, addr::VsockSocketAddr},
},
prelude... | kernel/src/net/socket/vsock/stream/connected.rs | null | null | null | null | null |
source | asterinas | // SPDX-License-Identifier: MPL-2.0
use core::sync::atomic::{AtomicBool, Ordering};
use aster_virtio::device::socket::connect::{ConnectionInfo, VsockEvent};
use super::connected::ConnectionID;
use crate::{
events::IoEvents,
net::socket::vsock::{VSOCK_GLOBAL, addr::VsockSocketAddr},
prelude::*,
proces... | kernel/src/net/socket/vsock/stream/connecting.rs | null | null | null | null | null |
source | asterinas | // SPDX-License-Identifier: MPL-2.0
use crate::{
events::IoEvents,
net::socket::vsock::{
VSOCK_GLOBAL,
addr::{VMADDR_CID_ANY, VMADDR_PORT_ANY, VsockSocketAddr},
},
prelude::*,
process::signal::PollHandle,
};
pub struct Init {
bound_addr: Mutex<Option<VsockSocketAddr>>,
}
impl ... | kernel/src/net/socket/vsock/stream/init.rs | null | null | null | null | null |
source | asterinas | // SPDX-License-Identifier: MPL-2.0
use super::connected::Connected;
use crate::{
events::IoEvents,
net::socket::vsock::addr::VsockSocketAddr,
prelude::*,
process::signal::{PollHandle, Pollee},
};
pub struct Listen {
addr: VsockSocketAddr,
backlog: usize,
incoming_connection: SpinLock<VecDe... | kernel/src/net/socket/vsock/stream/listen.rs | null | null | null | null | null |
source | asterinas | // SPDX-License-Identifier: MPL-2.0
pub mod connected;
pub mod connecting;
pub mod init;
pub mod listen;
pub mod socket;
pub use socket::VsockStreamSocket; | kernel/src/net/socket/vsock/stream/mod.rs | null | null | null | null | null |
source | asterinas | // SPDX-License-Identifier: MPL-2.0
use core::sync::atomic::{AtomicBool, Ordering};
use super::{connected::Connected, connecting::Connecting, init::Init, listen::Listen};
use crate::{
events::IoEvents,
fs::{file_handle::FileLike, path::Path, pseudofs::SockFs},
net::socket::{
Socket,
privat... | kernel/src/net/socket/vsock/stream/socket.rs | null | null | null | null | null |
source | asterinas | // SPDX-License-Identifier: MPL-2.0
use alloc::borrow::Cow;
use core::{num::NonZeroU64, sync::atomic::Ordering};
use ostd::{
arch::cpu::context::UserContext, cpu::CpuId, mm::VmIo, sync::RwArc, task::Task,
user::UserContextApi,
};
use super::{
Credentials, Pid, Process,
posix_thread::{AsPosixThread, P... | kernel/src/process/clone.rs | null | null | null | null | null |
source | asterinas | // SPDX-License-Identifier: MPL-2.0
use aster_rights::ReadWriteOp;
use ostd::{
arch::cpu::context::{FpuContext, GeneralRegs, UserContext},
mm::VmIo,
sync::Waiter,
user::UserContextApi,
};
use super::process_vm::activate_vmar;
use crate::{
fs::{
path::{Path, PathResolver},
utils::In... | kernel/src/process/execve.rs | null | null | null | null | null |
source | asterinas | // SPDX-License-Identifier: MPL-2.0
use core::sync::atomic::Ordering;
use super::{Pid, Process, process_table};
use crate::{
events::IoEvents, fs::cgroupfs::CgroupMembership, prelude::*,
process::signal::signals::kernel::KernelSignal,
};
/// Exits the current POSIX process.
///
/// This is for internal use. ... | kernel/src/process/exit.rs | null | null | null | null | null |
source | asterinas | // SPDX-License-Identifier: MPL-2.0
use super::{
Pgid, Pid, Process,
posix_thread::{AsPosixThread, thread_table},
process_table,
signal::{constants::SIGCONT, sig_num::SigNum, signals::Signal},
};
use crate::{
prelude::*,
process::{credentials::capabilities::CapSet, posix_thread::PosixThread},
... | kernel/src/process/kill.rs | null | null | null | null | null |
source | asterinas | // SPDX-License-Identifier: MPL-2.0
mod clone;
pub mod credentials;
mod execve;
mod exit;
mod kill;
mod namespace;
mod pid_file;
pub mod posix_thread;
#[expect(clippy::module_inception)]
mod process;
mod process_filter;
pub mod process_table;
mod process_vm;
mod program_loader;
pub mod rlimit;
pub mod signal;
mod stat... | kernel/src/process/mod.rs | null | null | null | null | null |
source | asterinas | // SPDX-License-Identifier: MPL-2.0
use core::{
fmt::Display,
sync::atomic::{AtomicBool, Ordering},
};
use crate::{
events::IoEvents,
fs::{
file_handle::FileLike,
file_table::FdFlags,
path::Path,
pseudofs::PidfdFs,
utils::{CreationFlags, StatusFlags},
},
... | kernel/src/process/pid_file.rs | null | null | null | null | null |
source | asterinas | // SPDX-License-Identifier: MPL-2.0
use super::{Pgid, Pid};
use crate::{fs::file_table::get_file_fast, prelude::*, process::PidFile};
#[derive(Debug, Clone)]
pub enum ProcessFilter {
Any,
WithPid(Pid),
WithPgid(Pgid),
WithPidfd(Arc<PidFile>),
}
impl ProcessFilter {
// For `waitpid`.
pub fn fr... | kernel/src/process/process_filter.rs | null | null | null | null | null |
source | asterinas | // SPDX-License-Identifier: MPL-2.0
#![expect(dead_code)]
//! A global table stores the pid to process mapping.
//! This table can be used to get process with pid.
//! TODO: progress group, thread all need similar mapping
use alloc::collections::btree_map::Values;
use super::{Pgid, Pid, Process, ProcessGroup, Sessi... | kernel/src/process/process_table.rs | null | null | null | null | null |
source | asterinas | // SPDX-License-Identifier: MPL-2.0
// FIXME: The resource limits should be respected by the corresponding subsystems of the kernel.
use core::{
array,
sync::atomic::{AtomicU64, Ordering},
};
use super::process_vm::INIT_STACK_SIZE;
use crate::{
prelude::*,
process::{UserNamespace, credentials::capabil... | kernel/src/process/rlimit.rs | null | null | null | null | null |
source | asterinas | // SPDX-License-Identifier: MPL-2.0
use aster_util::per_cpu_counter::PerCpuCounter;
use spin::Once;
pub(super) static PROCESS_CREATION_COUNTER: Once<PerCpuCounter> = Once::new();
/// Counts the number of processes ever created across all CPUs.
pub fn collect_process_creation_count() -> usize {
PROCESS_CREATION_C... | kernel/src/process/stats.rs | null | null | null | null | null |
source | asterinas | // SPDX-License-Identifier: MPL-2.0
//! The process status.
use core::sync::atomic::{AtomicBool, AtomicU32, Ordering};
use ostd::sync::SpinLock;
use super::ExitCode;
use crate::process::{WaitOptions, signal::sig_num::SigNum};
/// The status of a process.
///
/// This maintains:
/// 1. Whether the process is a zomb... | kernel/src/process/status.rs | null | null | null | null | null |
source | asterinas | // SPDX-License-Identifier: MPL-2.0
//! Task sets.
use ostd::{
sync::Waker,
task::{CurrentTask, Task},
};
use super::Pid;
use crate::{
events::{Events, Observer, Subject},
prelude::*,
thread::Tid,
};
/// A task set that maintains all tasks in a POSIX process.
pub struct TaskSet {
tasks: Vec<... | kernel/src/process/task_set.rs | null | null | null | null | null |
source | asterinas | // SPDX-License-Identifier: MPL-2.0
use super::signal::sig_num::SigNum;
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
pub enum TermStatus {
Exited(u8),
Killed(SigNum),
}
impl TermStatus {
/// Return as a 32-bit integer encoded as specified in wait(2) man page.
pub fn as_u32(&self) -> u32 {
mat... | kernel/src/process/term_status.rs | null | null | null | null | null |
source | asterinas | // SPDX-License-Identifier: MPL-2.0
use super::{
ExitCode, Pid, Process,
process_filter::ProcessFilter,
signal::{constants::SIGCHLD, with_sigmask_changed},
};
use crate::{
prelude::*,
process::{
ReapedChildrenStats, Uid,
posix_thread::{AsPosixThread, thread_table},
process_t... | kernel/src/process/wait.rs | null | null | null | null | null |
source | asterinas | // SPDX-License-Identifier: MPL-2.0
use crate::{prelude::*, process::Pid};
/// `struct __user_cap_header_struct` in Linux.
///
/// Reference: <https://elixir.bootlin.com/linux/v6.18.6/source/include/uapi/linux/capability.h#L40>.
#[repr(C)]
#[derive(Debug, Clone, Copy, Pod)]
pub struct CUserCapHeader {
pub version... | kernel/src/process/credentials/c_types.rs | null | null | null | null | null |
source | asterinas | // SPDX-License-Identifier: MPL-2.0
use core::sync::atomic::{AtomicU64, Ordering};
use atomic_integer_wrapper::define_atomic_version_of_integer_like_type;
use bitflags::bitflags;
bitflags! {
/// Represents a set of Linux capabilities.
pub struct CapSet: u64 {
const CHOWN = 1 << 0;
const DAC_O... | kernel/src/process/credentials/capabilities.rs | null | null | null | null | null |
source | asterinas | // SPDX-License-Identifier: MPL-2.0
use core::sync::atomic::Ordering;
use ostd::sync::{PreemptDisabled, RwLockReadGuard, RwLockWriteGuard};
use super::{
Gid, SecureBits, Uid, group::AtomicGid, secure_bits::AtomicSecureBits, user::AtomicUid,
};
use crate::{
prelude::*,
process::credentials::{
AMBI... | kernel/src/process/credentials/credentials_.rs | null | null | null | null | null |
source | asterinas | // SPDX-License-Identifier: MPL-2.0
use core::sync::atomic::{AtomicU32, Ordering};
use atomic_integer_wrapper::define_atomic_version_of_integer_like_type;
use crate::prelude::*;
#[derive(Debug, Clone, Copy, Pod, Default, PartialEq, Eq, PartialOrd, Ord)]
#[repr(C)]
pub struct Gid(u32);
impl Gid {
/// The invali... | kernel/src/process/credentials/group.rs | null | null | null | null | null |
source | asterinas | // SPDX-License-Identifier: MPL-2.0
pub mod c_types;
pub mod capabilities;
mod credentials_;
mod group;
mod secure_bits;
mod static_cap;
mod user;
use aster_rights::FullOp;
use capabilities::CapSet;
use credentials_::Credentials_;
pub use group::Gid;
pub use secure_bits::SecureBits;
pub use user::Uid;
use crate::pre... | kernel/src/process/credentials/mod.rs | null | null | null | null | null |
source | asterinas | // SPDX-License-Identifier: MPL-2.0
use core::sync::atomic::{AtomicU16, Ordering};
use atomic_integer_wrapper::define_atomic_version_of_integer_like_type;
use bitflags::bitflags;
use crate::prelude::*;
bitflags! {
/// Represents the secure bits for a POSIX thread.
///
/// These flags control the behavio... | kernel/src/process/credentials/secure_bits.rs | null | null | null | null | null |
source | asterinas | // SPDX-License-Identifier: MPL-2.0
use aster_rights::{Dup, Read, TRights, Write};
use aster_rights_proc::require;
use ostd::sync::{PreemptDisabled, RwLockReadGuard, RwLockWriteGuard};
use super::{Credentials, Gid, SecureBits, Uid, capabilities::CapSet, credentials_::Credentials_};
use crate::prelude::*;
impl<R: TRi... | kernel/src/process/credentials/static_cap.rs | null | null | null | null | null |
source | asterinas | // SPDX-License-Identifier: MPL-2.0
use core::sync::atomic::{AtomicU32, Ordering};
use atomic_integer_wrapper::define_atomic_version_of_integer_like_type;
use crate::prelude::*;
#[derive(Debug, Clone, Copy, PartialEq, Eq, Pod)]
#[repr(C)]
pub struct Uid(u32);
const ROOT_UID: u32 = 0;
impl Uid {
/// The invali... | kernel/src/process/credentials/user.rs | null | null | null | null | null |
source | asterinas | // SPDX-License-Identifier: MPL-2.0
pub(super) mod nsproxy;
pub(super) mod unshare;
pub(super) mod user_ns; | kernel/src/process/namespace/mod.rs | null | null | null | null | null |
source | asterinas | // SPDX-License-Identifier: MPL-2.0
use spin::Once;
use crate::{
fs::path::MountNamespace,
net::uts_ns::UtsNamespace,
prelude::*,
process::{CloneFlags, UserNamespace, posix_thread::PosixThread},
};
/// A struct that acts as a per-thread proxy to give access to most namespaces.
///
/// Each `PosixThre... | kernel/src/process/namespace/nsproxy.rs | null | null | null | null | null |
source | asterinas | // SPDX-License-Identifier: MPL-2.0
use ostd::sync::RwArc;
use crate::{prelude::*, process::CloneFlags};
/// Provides administrative APIs for disassociating execution contexts.
pub trait ContextUnshareAdminApi {
/// Unshares the file table.
fn unshare_files(&self);
/// Unshares filesystem attributes.
... | kernel/src/process/namespace/unshare.rs | null | null | null | null | null |
source | asterinas | // SPDX-License-Identifier: MPL-2.0
use spin::Once;
use crate::{
prelude::*,
process::{credentials::capabilities::CapSet, posix_thread::PosixThread},
};
/// The user namespace.
pub struct UserNamespace {
_private: (),
}
impl UserNamespace {
/// Returns a reference to the singleton initial user names... | kernel/src/process/namespace/user_ns.rs | null | null | null | null | null |
source | asterinas | // SPDX-License-Identifier: MPL-2.0
use core::sync::atomic::{AtomicU32, AtomicU64};
use ostd::{
arch::cpu::context::{FpuContext, UserContext},
cpu::CpuSet,
sync::RwArc,
task::Task,
};
use super::{PosixThread, ThreadLocal, thread_table};
use crate::{
fs::{file_table::FileTable, thread_info::Thread... | kernel/src/process/posix_thread/builder.rs | null | null | null | null | null |
source | asterinas | // SPDX-License-Identifier: MPL-2.0
use ostd::{mm::VmIo, task::Task};
use super::{
AsPosixThread, AsThreadLocal, ThreadLocal, futex::futex_wake, robust_list::wake_robust_futex,
thread_table,
};
use crate::{
current_userspace,
prelude::*,
process::{
TermStatus,
exit::exit_process,
... | kernel/src/process/posix_thread/exit.rs | null | null | null | null | null |
source | asterinas | // SPDX-License-Identifier: MPL-2.0
use int_to_c_enum::TryFromInt;
use ostd::{
cpu::num_cpus,
sync::{PreemptDisabled, Waiter, Waker},
};
use spin::Once;
use crate::{
prelude::*, process::Pid, thread::exception::PageFaultInfo, time::wait::ManagedTimeout,
vm::perms::VmPerms,
};
type FutexBitSet = u32;
... | kernel/src/process/posix_thread/futex.rs | null | null | null | null | null |
source | asterinas | // SPDX-License-Identifier: MPL-2.0
use core::sync::atomic::{AtomicU32, AtomicU64, Ordering};
use aster_rights::{ReadDupOp, ReadOp, ReadWriteOp};
use ostd::{
sync::{RoArc, RwMutexReadGuard, Waker},
task::Task,
};
use super::{
Credentials, Process,
signal::{sig_mask::AtomicSigMask, sig_num::SigNum, si... | kernel/src/process/posix_thread/mod.rs | null | null | null | null | null |
source | asterinas | // SPDX-License-Identifier: MPL-2.0
use crate::prelude::*;
pub const MAX_THREAD_NAME_LEN: usize = 16;
#[derive(Debug, Clone)]
pub struct ThreadName([u8; MAX_THREAD_NAME_LEN]);
impl ThreadName {
fn new() -> Self {
ThreadName([0; MAX_THREAD_NAME_LEN])
}
pub fn new_from_executable_path(executable_... | kernel/src/process/posix_thread/name.rs | null | null | null | null | null |
source | asterinas | // SPDX-License-Identifier: MPL-2.0
use ostd::task::Task;
use super::PosixThread;
use crate::thread::{AsThread, Thread};
/// A trait to provide the `as_posix_thread` method for tasks and threads.
pub trait AsPosixThread {
/// Returns the associated [`PosixThread`].
fn as_posix_thread(&self) -> Option<&PosixT... | kernel/src/process/posix_thread/posix_thread_ext.rs | null | null | null | null | null |
source | asterinas | // SPDX-License-Identifier: MPL-2.0
//! The implementation of robust list is from occlum.
use ostd::{mm::VmIo, task::Task};
use crate::{current_userspace, prelude::*, process::posix_thread::futex::futex_wake, thread::Tid};
#[repr(C)]
#[derive(Clone, Copy, Debug, Pod)]
struct RobustList {
next: Vaddr, // *const ... | kernel/src/process/posix_thread/robust_list.rs | null | null | null | null | null |
source | asterinas | // SPDX-License-Identifier: MPL-2.0
use core::cell::{Cell, Ref, RefCell, RefMut};
use ostd::{arch::cpu::context::FpuContext, mm::Vaddr, sync::RwArc, task::CurrentTask};
use super::RobustListHead;
use crate::{
fs::{file_table::FileTable, thread_info::ThreadFsInfo},
prelude::*,
process::{NsProxy, UserNames... | kernel/src/process/posix_thread/thread_local.rs | null | null | null | null | null |
source | asterinas | // SPDX-License-Identifier: MPL-2.0
use super::{Thread, Tid};
use crate::{prelude::*, process::posix_thread::AsPosixThread};
static THREAD_TABLE: SpinLock<BTreeMap<Tid, Arc<Thread>>> = SpinLock::new(BTreeMap::new());
/// Adds a posix thread to global thread table
pub fn add_thread(tid: Tid, thread: Arc<Thread>) {
... | kernel/src/process/posix_thread/thread_table.rs | null | null | null | null | null |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.