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
//! Event device (evdev) support.
//!
//! Character device with major number 13. The minor numbers are dynamically allocated.
//! Devices appear as `/dev/input/eventX` where X is the minor number.
//!
//! Reference: <https://elixir.bootlin.com/linux/v6.17/source/include/uapi/linux/m... | kernel/src/device/evdev/mod.rs | null | null | null | null | null |
source | asterinas | // SPDX-License-Identifier: MPL-2.0
use alloc::vec;
use ostd::mm::{FallibleVmWrite, VmReader, VmWriter};
use crate::{
error::Errno,
events::IoEvents,
fs::{
inode_handle::FileIo,
utils::{InodeIo, StatusFlags},
},
prelude::Result,
process::signal::{PollHandle, Pollable},
ret... | kernel/src/device/mem/file.rs | null | null | null | null | null |
source | asterinas | // SPDX-License-Identifier: MPL-2.0
//! Memory devices.
//!
//! Character device with major number 1. The minor numbers are mapped as follows:
//! - 1 = /dev/mem Physical memory access
//! - 2 = /dev/kmem OBSOLETE - replaced by /proc/kcore
//! - 3 = /dev/null Null device
//! - 4 = /dev/port I/O port a... | kernel/src/device/mem/mod.rs | null | null | null | null | null |
source | asterinas | // SPDX-License-Identifier: MPL-2.0
//! Misc devices.
//!
//! Character device with major number 10.
use device_id::MajorId;
use spin::Once;
use super::registry::char::{MajorIdOwner, acquire_major};
#[cfg(all(target_arch = "x86_64", feature = "cvm_guest"))]
pub mod tdxguest;
static MISC_MAJOR: Once<MajorIdOwner> =... | kernel/src/device/misc/mod.rs | null | null | null | null | null |
source | asterinas | // SPDX-License-Identifier: MPL-2.0
use alloc::sync::Arc;
use core::{
mem::{offset_of, size_of},
time::Duration,
};
use aster_util::{field_ptr, safe_ptr::SafePtr};
use device_id::{DeviceId, MinorId};
use ostd::{
const_assert,
mm::{FrameAllocOptions, HasPaddr, HasSize, PAGE_SIZE, USegment, VmIo, dma::D... | kernel/src/device/misc/tdxguest.rs | null | null | null | null | null |
source | asterinas | // SPDX-License-Identifier: MPL-2.0
use aster_console::AnyConsoleDevice;
use ostd::sync::SpinLock;
use super::file::PtySlaveFile;
use crate::{
device::{
pty::packet::{PacketCtrl, PacketStatus},
tty::{
Tty, TtyDriver, TtyFlags,
termio::{CCtrlCharId, CInputFlags, CLocalFlags,... | kernel/src/device/pty/driver.rs | null | null | null | null | null |
source | asterinas | // SPDX-License-Identifier: MPL-2.0
use inherit_methods_macro::inherit_methods;
use crate::{
device::PtySlave,
events::IoEvents,
fs::{
inode_handle::FileIo,
utils::{InodeIo, StatusFlags},
},
prelude::*,
process::signal::{PollHandle, Pollable},
util::ioctl::RawIoctl,
};
///... | kernel/src/device/pty/file.rs | null | null | null | null | null |
source | asterinas | // SPDX-License-Identifier: MPL-2.0
use alloc::format;
use ostd::task::Task;
use super::{PtySlave, driver::PtyDriver};
use crate::{
device::tty::TtyFlags,
events::IoEvents,
fs::{
devpts::Ptmx,
file_table::FdFlags,
inode_handle::FileIo,
path::FsPath,
utils::{AccessM... | kernel/src/device/pty/master.rs | null | null | null | null | null |
source | asterinas | // SPDX-License-Identifier: MPL-2.0
use crate::{
fs::{
devpts::{DevPts, Ptmx},
path::{FsPath, Path, PathResolver, PerMountFlags},
utils::{InodeType, mkmod},
},
prelude::*,
};
mod driver;
mod file;
mod master;
mod packet;
pub use driver::PtySlave;
pub use master::PtyMaster;
use spi... | kernel/src/device/pty/mod.rs | null | null | null | null | null |
source | asterinas | // SPDX-License-Identifier: MPL-2.0
use core::sync::atomic::{AtomicBool, Ordering};
use crate::prelude::*;
/// Control states related to packet mode.
///
/// Reference: <https://man7.org/linux/man-pages/man2/TIOCPKT.2const.html>.
pub(super) struct PacketCtrl {
mode: AtomicBool,
status: SpinLock<PacketStatus>... | kernel/src/device/pty/packet.rs | null | null | null | null | null |
source | asterinas | // SPDX-License-Identifier: MPL-2.0
use aster_block::{BlockDevice, SECTOR_SIZE};
use aster_virtio::device::block::device::BlockDevice as VirtIoBlockDevice;
use device_id::DeviceId;
use ostd::mm::VmIo;
use crate::{
events::IoEvents,
fs::{
device::{Device, DeviceType, add_node},
inode_handle::Fi... | kernel/src/device/registry/block.rs | null | null | null | null | null |
source | asterinas | // SPDX-License-Identifier: MPL-2.0
//! A subsystem for character devices (or char devices for short).
use core::ops::Range;
use device_id::{DeviceId, MajorId};
use crate::{
fs::{
device::{Device, DeviceType, add_node},
path::PathResolver,
},
prelude::*,
};
static DEVICE_REGISTRY: Mutex... | kernel/src/device/registry/char.rs | null | null | null | null | null |
source | asterinas | // SPDX-License-Identifier: MPL-2.0
use device_id::DeviceId;
use crate::{
fs::{
device::{Device, DeviceType},
path::PathResolver,
},
prelude::*,
};
mod block;
pub(super) mod char;
pub(super) fn init_in_first_kthread() {
block::init_in_first_kthread();
}
pub(super) fn init_in_first_p... | kernel/src/device/registry/mod.rs | null | null | null | null | null |
source | asterinas | // SPDX-License-Identifier: MPL-2.0
//! TTY devices.
//!
//! This module implements TTY devices such as `/dev/tty0`, `/dev/tty`, and `/dev/console`.
//!
//! Reference: <https://www.kernel.org/doc/html/latest/admin-guide/devices.html>
use aster_cmdline::KCMDLINE;
use device_id::{DeviceId, MajorId, MinorId};
use spin::... | kernel/src/device/tty/device.rs | null | null | null | null | null |
source | asterinas | // SPDX-License-Identifier: MPL-2.0
use aster_console::AnyConsoleDevice;
use crate::{
device::tty::{Tty, termio::CTermios},
fs::inode_handle::FileIo,
prelude::*,
};
/// A TTY driver.
///
/// A driver exposes some device-specific behavior to [`Tty`]. For example, a device provides
/// methods to write to ... | kernel/src/device/tty/driver.rs | null | null | null | null | null |
source | asterinas | // SPDX-License-Identifier: MPL-2.0
use core::sync::atomic::{AtomicBool, Ordering};
/// TTY flags.
//
// Reference: <https://elixir.bootlin.com/linux/v6.17/source/include/linux/tty.h#L306>.
pub struct TtyFlags {
is_other_closed: AtomicBool,
is_pty_locked: AtomicBool,
}
impl TtyFlags {
pub fn new() -> Sel... | kernel/src/device/tty/flags.rs | null | null | null | null | null |
source | asterinas | // SPDX-License-Identifier: MPL-2.0
use super::{
CFontOp,
termio::{CTermios, CWinSize},
};
use crate::util::ioctl::{InData, OutData, PassByVal, ioc};
// Reference: <https://elixir.bootlin.com/linux/v6.18/source/include/uapi/asm-generic/ioctls.h>
pub type GetTermios = ioc!(TCGETS, 0x5401, OutData... | kernel/src/device/tty/ioctl_defs.rs | null | null | null | null | null |
source | asterinas | // SPDX-License-Identifier: MPL-2.0
use ostd::const_assert;
use super::termio::{CCtrlCharId, CTermios, CWinSize};
use crate::{
device::tty::termio::{CInputFlags, CLocalFlags},
prelude::*,
process::signal::{
constants::{SIGINT, SIGQUIT},
sig_num::SigNum,
},
util::ring_buffer::RingBu... | kernel/src/device/tty/line_discipline.rs | null | null | null | null | null |
source | asterinas | // SPDX-License-Identifier: MPL-2.0
use aster_console::{
AnyConsoleDevice,
font::BitmapFont,
mode::{ConsoleMode, KeyboardMode},
};
use device_id::{DeviceId, MajorId, MinorId};
use ostd::{mm::VmIo, sync::LocalIrqDisabled};
use self::{line_discipline::LineDiscipline, termio::CFontOp};
use crate::{
curre... | kernel/src/device/tty/mod.rs | null | null | null | null | null |
source | asterinas | // SPDX-License-Identifier: MPL-2.0
use alloc::{boxed::Box, format, sync::Arc};
use aster_console::AnyConsoleDevice;
use aster_framebuffer::DummyFramebufferConsole;
use inherit_methods_macro::inherit_methods;
use ostd::mm::{Infallible, VmReader, VmWriter};
use spin::Once;
use super::{Tty, TtyDriver};
use crate::{
... | kernel/src/device/tty/n_tty.rs | null | null | null | null | null |
source | asterinas | // SPDX-License-Identifier: MPL-2.0
use crate::prelude::*;
/// A control character; the `cc_t` type in Linux.
///
/// Reference: <https://elixir.bootlin.com/linux/v6.0.9/source/include/uapi/asm-generic/termbits-common.h#L5>.
type CCtrlChar = u8;
bitflags! {
/// The input flags; `c_iflags` bits in Linux.
#[de... | kernel/src/device/tty/termio.rs | null | null | null | null | null |
source | asterinas | // SPDX-License-Identifier: MPL-2.0
use alloc::string::ToString;
use aster_framebuffer::{CONSOLE_NAME, FRAMEBUFFER_CONSOLE};
use log::info;
pub fn init() {
for device in aster_input::all_devices() {
info!("Found an input device, name:{}", device.name());
}
// FIXME: Currently, we have to do this... | kernel/src/driver/mod.rs | null | null | null | null | null |
source | asterinas | // SPDX-License-Identifier: MPL-2.0
/// A trait to represent any events.
///
/// # The unit event
///
/// The unit type `()` can serve as a unit event.
/// It can be used if there is only one kind of event
/// and the event carries no additional information.
pub trait Events: Copy + Clone + Send + Sync + 'static {}
i... | kernel/src/events/events.rs | null | null | null | null | null |
source | asterinas | // SPDX-License-Identifier: MPL-2.0
use super::{Events, EventsFilter};
use crate::prelude::*;
bitflags! {
pub struct IoEvents: u32 {
const IN = 0x0001;
const PRI = 0x0002;
const OUT = 0x0004;
const ERR = 0x0008;
const HUP = 0x0010;
const NVAL = 0x0... | kernel/src/events/io_events.rs | null | null | null | null | null |
source | asterinas | // SPDX-License-Identifier: MPL-2.0
#[expect(clippy::module_inception)]
mod events;
mod io_events;
mod observer;
mod subject;
pub use self::{
events::{Events, EventsFilter},
io_events::IoEvents,
observer::Observer,
subject::{Subject, SyncSubject},
}; | kernel/src/events/mod.rs | null | null | null | null | null |
source | asterinas | // SPDX-License-Identifier: MPL-2.0
use super::Events;
/// An observer for events.
///
/// In a sense, event observers are just a fancy form of callback functions.
/// An observer's `on_events` methods are supposed to be called when
/// some events that are interesting to the observer happen.
///
/// # The no-op obse... | kernel/src/events/observer.rs | null | null | null | null | null |
source | asterinas | // SPDX-License-Identifier: MPL-2.0
use core::sync::atomic::{AtomicUsize, Ordering};
use keyable_arc::KeyableWeak;
use ostd::sync::LocalIrqDisabled;
use super::{Events, EventsFilter, Observer};
use crate::prelude::*;
/// A subject that notifies interesting events to registered observers.
///
/// This type does not ... | kernel/src/events/subject.rs | null | null | null | null | null |
source | asterinas | // SPDX-License-Identifier: MPL-2.0
use device_id::DeviceId;
use super::inode_handle::FileIo;
use crate::{
fs::{
path::{FsPath, Path, PathResolver},
utils::{InodeType, MknodType, mkmod},
},
prelude::*,
};
/// The abstraction of a device.
pub trait Device: Send + Sync + 'static {
/// R... | kernel/src/fs/device.rs | null | null | null | null | null |
source | asterinas | // SPDX-License-Identifier: MPL-2.0
#![expect(unused_variables)]
//! Opened File Handle
use core::fmt::Display;
use ostd::io::IoMem;
use super::{inode_handle::InodeHandle, path::Path};
use crate::{
fs::{
file_table::FdFlags,
utils::{AccessMode, FallocMode, SeekFrom, StatusFlags},
},
net... | kernel/src/fs/file_handle.rs | null | null | null | null | null |
source | asterinas | // SPDX-License-Identifier: MPL-2.0
use core::sync::atomic::{AtomicU8, Ordering};
use aster_util::slot_vec::SlotVec;
use super::file_handle::FileLike;
use crate::{
events::{IoEvents, Observer},
fs::utils::StatusFlags,
prelude::*,
process::{
Pid, Process,
posix_thread::FileTableRefMut,... | kernel/src/fs/file_table.rs | null | null | null | null | null |
source | asterinas | // SPDX-License-Identifier: MPL-2.0
//! Opened Inode-backed File Handle
use core::{fmt::Display, sync::atomic::Ordering};
use aster_rights::Rights;
use super::utils::{InodeExt, InodeIo};
use crate::{
events::IoEvents,
fs::{
file_handle::{FileLike, Mappable},
file_table::FdFlags,
path... | kernel/src/fs/inode_handle.rs | null | null | null | null | null |
source | asterinas | // SPDX-License-Identifier: MPL-2.0
pub mod cgroupfs;
pub mod configfs;
pub mod device;
pub mod devpts;
pub mod epoll;
pub mod exfat;
pub mod ext2;
pub mod file_handle;
pub mod file_table;
pub mod inode_handle;
pub mod notify;
pub mod overlayfs;
pub mod path;
pub mod pipe;
pub mod procfs;
pub mod pseudofs;
pub mod ram... | kernel/src/fs/mod.rs | null | null | null | null | null |
source | asterinas | // SPDX-License-Identifier: MPL-2.0
use alloc::format;
use core::{
sync::atomic::{AtomicU64, Ordering},
time::Duration,
};
use spin::Once;
use super::utils::{Extension, InodeIo, StatusFlags};
use crate::{
fs::{
inode_handle::FileIo,
path::{Mount, Path},
pipe::AnonPipeInode,
... | kernel/src/fs/pseudofs.rs | null | null | null | null | null |
source | asterinas | // SPDX-License-Identifier: MPL-2.0
use aster_block::BlockDevice;
use aster_systree::{
AttrLessBranchNodeFields, SysNode, SysObj, SysPerms, SysStr, inherit_sys_branch_node,
};
use spin::Once;
use crate::{
fs::{
sysfs,
utils::{FileSystem, FsFlags},
},
prelude::*,
};
/// A type of file ... | kernel/src/fs/registry.rs | null | null | null | null | null |
source | asterinas | // SPDX-License-Identifier: MPL-2.0
use core2::io::{Cursor, Read};
use cpio_decoder::{CpioDecoder, FileType};
use lending_iterator::LendingIterator;
use libflate::gzip::Decoder as GZipDecoder;
use ostd::boot::boot_info;
use super::{
path::{FsPath, PathResolver},
utils::{InodeMode, InodeType},
};
use crate::{f... | kernel/src/fs/rootfs.rs | null | null | null | null | null |
source | asterinas | // SPDX-License-Identifier: MPL-2.0
use core::sync::atomic::Ordering;
use ostd::sync::RwMutex;
use super::{path::PathResolver, utils::AtomicFileCreationMask};
use crate::fs::utils::FileCreationMask;
/// FS information for a POSIX thread.
pub struct ThreadFsInfo {
resolver: RwMutex<PathResolver>,
umask: Atom... | kernel/src/fs/thread_info.rs | null | null | null | null | null |
source | asterinas | // SPDX-License-Identifier: MPL-2.0
use alloc::sync::Arc;
use aster_block::BlockDevice;
use aster_systree::EmptyNode;
use spin::Once;
use super::inode::CgroupInode;
use crate::{
fs::{
Result,
cgroupfs::systree_node::CgroupSystem,
registry::{FsProperties, FsType},
utils::{
... | kernel/src/fs/cgroupfs/fs.rs | null | null | null | null | null |
source | asterinas | // SPDX-License-Identifier: MPL-2.0
use alloc::sync::{Arc, Weak};
use ostd::sync::RwLock;
use super::fs::CgroupFs;
use crate::{
fs::{
cgroupfs::CgroupNode,
path::{is_dot, is_dotdot},
utils::{
Extension, FileSystem, Inode, InodeMode, Metadata,
systree_inode::{SysTre... | kernel/src/fs/cgroupfs/inode.rs | null | null | null | null | null |
source | asterinas | // SPDX-License-Identifier: MPL-2.0
use fs::CgroupFsType;
pub use systree_node::{CgroupMembership, CgroupNode};
mod controller;
mod fs;
mod inode;
mod systree_node;
// This method should be called during kernel file system initialization,
// _after_ `aster_systree::init`.
pub(super) fn init() {
super::registry::... | kernel/src/fs/cgroupfs/mod.rs | null | null | null | null | null |
source | asterinas | // SPDX-License-Identifier: MPL-2.0
//! Implements the cgroup nodes for the unified cgroup hierarchy (cgroup v2).
//!
//! This module defines the structures for cgroup nodes ([`CgroupNode`]) and the cgroup
//! root ([`CgroupSystem`]), integrating them into the `systree`. It handles process
//! management within cgroup... | kernel/src/fs/cgroupfs/systree_node.rs | null | null | null | null | null |
source | asterinas | // SPDX-License-Identifier: MPL-2.0
use alloc::sync::Arc;
use aster_systree::{Error, Result, SysAttrSetBuilder, SysPerms, SysStr};
use aster_util::printer::VmPrinter;
use ostd::{
cpu::num_cpus,
mm::{VmReader, VmWriter},
};
/// A sub-controller responsible for CPU resource management in the cgroup subsystem.
... | kernel/src/fs/cgroupfs/controller/cpuset.rs | null | null | null | null | null |
source | asterinas | // SPDX-License-Identifier: MPL-2.0
use alloc::sync::Arc;
use aster_systree::{Error, Result, SysAttrSetBuilder, SysPerms, SysStr};
use ostd::mm::{VmReader, VmWriter};
/// A sub-controller responsible for memory resource management in the cgroup subsystem.
///
/// Note that even if the controller is inactive, it stil... | kernel/src/fs/cgroupfs/controller/memory.rs | null | null | null | null | null |
source | asterinas | // SPDX-License-Identifier: MPL-2.0
use alloc::{collections::vec_deque::VecDeque, sync::Arc};
use core::{fmt::Display, str::FromStr};
use aster_systree::{Error, Result, SysAttrSetBuilder, SysBranchNode, SysObj};
use bitflags::bitflags;
use ostd::{
mm::{VmReader, VmWriter},
sync::{Mutex, MutexGuard, Rcu},
};
... | kernel/src/fs/cgroupfs/controller/mod.rs | null | null | null | null | null |
source | asterinas | // SPDX-License-Identifier: MPL-2.0
use alloc::sync::Arc;
use core::sync::atomic::{AtomicU32, Ordering};
use aster_systree::{Error, MAX_ATTR_SIZE, Result, SysAttrSetBuilder, SysPerms, SysStr};
use aster_util::printer::VmPrinter;
use ostd::mm::{VmReader, VmWriter};
use crate::{process::posix_thread::PID_MAX, util::Re... | kernel/src/fs/cgroupfs/controller/pids.rs | null | null | null | null | null |
source | asterinas | // SPDX-License-Identifier: MPL-2.0
use alloc::sync::Arc;
use aster_block::BlockDevice;
use aster_systree::SysNode;
use spin::Once;
use super::inode::ConfigInode;
use crate::{
fs::{
Result,
configfs::systree_node::ConfigRootNode,
registry::{FsProperties, FsType},
utils::{
... | kernel/src/fs/configfs/fs.rs | null | null | null | null | null |
source | asterinas | // SPDX-License-Identifier: MPL-2.0
use alloc::sync::{Arc, Weak};
use ostd::sync::RwLock;
use crate::{
fs::{
configfs::fs::ConfigFs,
utils::{
Extension, FileSystem, Inode, InodeMode, Metadata,
systree_inode::{SysTreeInodeTy, SysTreeNodeKind},
},
},
prelude:... | kernel/src/fs/configfs/inode.rs | null | null | null | null | null |
source | asterinas | // SPDX-License-Identifier: MPL-2.0
use alloc::sync::Arc;
use aster_systree::{EmptyNode, SysBranchNode};
use systree_node::ConfigRootNode;
use crate::{fs::configfs::fs::ConfigFsType, prelude::*};
mod fs;
mod inode;
mod systree_node;
#[cfg(ktest)]
mod test;
// This method should be called during kernel file system ... | kernel/src/fs/configfs/mod.rs | null | null | null | null | null |
source | asterinas | // SPDX-License-Identifier: MPL-2.0
use alloc::sync::{Arc, Weak};
use core::fmt::Debug;
use aster_systree::{
BranchNodeFields, Result, SysAttrSet, SysBranchNode, SysObj, SysPerms, SysStr,
inherit_sys_branch_node,
};
use inherit_methods_macro::inherit_methods;
use spin::Once;
/// The `SysTree` node that repre... | kernel/src/fs/configfs/systree_node.rs | null | null | null | null | null |
source | asterinas | // SPDX-License-Identifier: MPL-2.0
//! Testing configfs by adding to it a top-level directory called `demo_set`,
//! whose structure is illustrated as follows:
//!
//! ```
//! configfs/
//! demo_set/
//! demo_foo/
//! attr_a
//! attr_b
//! demo_bar/
//! attr_... | kernel/src/fs/configfs/test.rs | null | null | null | null | null |
source | asterinas | // SPDX-License-Identifier: MPL-2.0
#![expect(unused_variables)]
use core::time::Duration;
use aster_util::slot_vec::SlotVec;
use id_alloc::IdAlloc;
pub use self::ptmx::Ptmx;
use self::slave::PtySlaveInode;
use super::utils::{Extension, MknodType, StatusFlags};
use crate::{
device::PtyMaster,
fs::{
... | kernel/src/fs/devpts/mod.rs | null | null | null | null | null |
source | asterinas | // SPDX-License-Identifier: MPL-2.0
use device_id::{DeviceId, MajorId, MinorId};
use super::*;
use crate::fs::{
inode_handle::FileIo,
utils::{AccessMode, Extension, InodeIo, StatusFlags},
};
/// Same major number with Linux.
const PTMX_MAJOR_NUM: u16 = 5;
/// Same minor number with Linux.
const PTMX_MINOR_NU... | kernel/src/fs/devpts/ptmx.rs | null | null | null | null | null |
source | asterinas | // SPDX-License-Identifier: MPL-2.0
#![expect(dead_code)]
#![expect(unused_variables)]
use super::*;
use crate::{
device::PtySlave,
fs::{
inode_handle::FileIo,
utils::{AccessMode, InodeIo, StatusFlags},
},
};
/// Same major number with Linux, the minor number is the index of slave.
const ... | kernel/src/fs/devpts/slave.rs | null | null | null | null | null |
source | asterinas | // SPDX-License-Identifier: MPL-2.0
use alloc::{
collections::vec_deque::VecDeque,
sync::{Arc, Weak},
};
use core::{
fmt::Display,
sync::atomic::{AtomicBool, Ordering},
};
use keyable_arc::{KeyableArc, KeyableWeak};
use ostd::sync::{LocalIrqDisabled, Mutex, MutexGuard, SpinLock, SpinLockGuard};
use s... | kernel/src/fs/epoll/entry.rs | null | null | null | null | null |
source | asterinas | // SPDX-License-Identifier: MPL-2.0
use alloc::{collections::btree_set::BTreeSet, sync::Arc};
use core::{borrow::Borrow, fmt::Display, time::Duration};
use keyable_arc::KeyableWeak;
use ostd::sync::Mutex;
use super::{
EpollCtl, EpollEvent, EpollFlags,
entry::{Entry, EntryKey, ReadySet},
};
use crate::{
e... | kernel/src/fs/epoll/file.rs | null | null | null | null | null |
source | asterinas | // SPDX-License-Identifier: MPL-2.0
use super::file_table::FileDesc;
use crate::{events::IoEvents, prelude::*};
mod entry;
mod file;
pub use file::EpollFile;
/// An epoll control command.
#[derive(Copy, Clone, Debug, PartialEq)]
pub enum EpollCtl {
Add(FileDesc, EpollEvent, EpollFlags),
Del(FileDesc),
M... | kernel/src/fs/epoll/mod.rs | null | null | null | null | null |
source | asterinas | // SPDX-License-Identifier: MPL-2.0
#![expect(dead_code)]
#![expect(unused_variables)]
use core::ops::Range;
use align_ext::AlignExt;
use bitvec::prelude::*;
use super::{
constants::EXFAT_RESERVED_CLUSTERS,
dentry::{ExfatBitmapDentry, ExfatDentry, ExfatDentryIterator},
fat::{ClusterID, ExfatChain},
... | kernel/src/fs/exfat/bitmap.rs | null | null | null | null | null |
source | asterinas | // SPDX-License-Identifier: MPL-2.0
#![expect(dead_code)]
pub(super) const ROOT_INODE_HASH: usize = 0;
// Other pub(super) constants
pub(super) const MAX_CHARSET_SIZE: usize = 6;
pub(super) const MAX_NAME_LENGTH: usize = 255;
pub(super) const MAX_VFSNAME_BUF_SIZE: usize = (MAX_NAME_LENGTH + 1) * MAX_CHARSET_SIZE;
pu... | kernel/src/fs/exfat/constants.rs | null | null | null | null | null |
source | asterinas | // SPDX-License-Identifier: MPL-2.0
use core::{fmt::Display, ops::Range};
use ostd::mm::VmIo;
use super::{
constants::{EXFAT_FILE_NAME_LEN, MAX_NAME_LENGTH},
fat::FatChainFlags,
fs::ExfatFs,
inode::FatAttr,
upcase_table::ExfatUpcaseTable,
utils::{DosTimestamp, calc_checksum_16},
};
use crate:... | kernel/src/fs/exfat/dentry.rs | null | null | null | null | null |
source | asterinas | // SPDX-License-Identifier: MPL-2.0
use super::{
bitmap::ExfatBitmap,
constants::{EXFAT_FIRST_CLUSTER, EXFAT_RESERVED_CLUSTERS},
fs::ExfatFs,
};
use crate::prelude::*;
pub type ClusterID = u32;
pub(super) const FAT_ENTRY_SIZE: usize = size_of::<ClusterID>();
#[derive(Copy, Clone, Eq, PartialEq, Debug)]
p... | kernel/src/fs/exfat/fat.rs | null | null | null | null | null |
source | asterinas | // SPDX-License-Identifier: MPL-2.0
#![expect(dead_code)]
#![expect(unused_variables)]
use core::{num::NonZeroUsize, ops::Range, sync::atomic::AtomicU64};
use aster_block::{
BlockDevice,
bio::{BioDirection, BioSegment, BioWaiter},
id::BlockId,
};
use hashbrown::HashMap;
use lru::LruCache;
use ostd::mm::S... | kernel/src/fs/exfat/fs.rs | null | null | null | null | null |
source | asterinas | // SPDX-License-Identifier: MPL-2.0
#![expect(dead_code)]
#![expect(unused_variables)]
use alloc::string::String;
use core::{cmp::Ordering, time::Duration};
pub(super) use align_ext::AlignExt;
use aster_block::{
BLOCK_SIZE,
bio::{BioDirection, BioSegment, BioWaiter},
id::{Bid, BlockId},
};
use ostd::mm::... | kernel/src/fs/exfat/inode.rs | null | null | null | null | null |
source | asterinas | // SPDX-License-Identifier: MPL-2.0
mod bitmap;
mod constants;
mod dentry;
mod fat;
mod fs;
mod inode;
mod super_block;
mod upcase_table;
mod utils;
use crate::fs::exfat::fs::ExfatType;
pub(super) fn init() {
super::registry::register(&ExfatType).unwrap();
}
#[cfg(ktest)]
mod test {
use alloc::fmt::Debug;
... | kernel/src/fs/exfat/mod.rs | null | null | null | null | null |
source | asterinas | // SPDX-License-Identifier: MPL-2.0
use super::constants::{EXFAT_FIRST_CLUSTER, EXFAT_RESERVED_CLUSTERS, MEDIA_FAILURE, VOLUME_DIRTY};
use crate::prelude::*;
#[repr(C, packed)]
#[derive(Clone, Copy, Debug, Default)]
// The in-memory superblock info
pub struct ExfatSuperBlock {
/// num of sectors in volume
pub... | kernel/src/fs/exfat/super_block.rs | null | null | null | null | null |
source | asterinas | // SPDX-License-Identifier: MPL-2.0
#![expect(dead_code)]
#![expect(unused_variables)]
use align_ext::AlignExt;
use super::{
constants::UNICODE_SIZE,
dentry::{ExfatDentry, ExfatDentryIterator, ExfatUpcaseDentry, UTF16Char},
fat::ExfatChain,
fs::ExfatFs,
utils::calc_checksum_32,
};
use crate::{fs:... | kernel/src/fs/exfat/upcase_table.rs | null | null | null | null | null |
source | asterinas | // SPDX-License-Identifier: MPL-2.0
use core::{ops::Range, time::Duration};
use time::{OffsetDateTime, PrimitiveDateTime, Time};
use super::fat::ClusterID;
use crate::prelude::*;
pub fn make_hash_index(cluster: ClusterID, offset: u32) -> usize {
((cluster as usize) << 32usize) | (offset as usize & 0xffffffffusi... | kernel/src/fs/exfat/utils.rs | null | null | null | null | null |
source | asterinas | // SPDX-License-Identifier: MPL-2.0
use ostd::{const_assert, mm::io_util::HasVmReaderWriter};
use super::{
block_ptr::Ext2Bid,
fs::Ext2,
inode::{Inode, InodeDesc, RawInode},
prelude::*,
super_block::SuperBlock,
};
use crate::fs::utils::IdBitmap;
/// Blocks are clustered into block groups in order... | kernel/src/fs/ext2/block_group.rs | null | null | null | null | null |
source | asterinas | // SPDX-License-Identifier: MPL-2.0
use super::prelude::*;
pub type Ext2Bid = u32;
/// The pointers to blocks for an inode.
#[repr(C)]
#[derive(Clone, Copy, Default, Debug, Pod)]
pub struct BlockPtrs {
inner: [Ext2Bid; MAX_BLOCK_PTRS],
}
impl BlockPtrs {
/// Returns the direct block ID.
///
/// # Pa... | kernel/src/fs/ext2/block_ptr.rs | null | null | null | null | null |
source | asterinas | // SPDX-License-Identifier: MPL-2.0
#![expect(dead_code)]
use super::{inode::MAX_FNAME_LEN, prelude::*};
/// The data structure in a directory's data block. It is stored in a linked list.
///
/// Each entry contains the name of the entry, the inode number, the file type,
/// and the distance within the directory fil... | kernel/src/fs/ext2/dir.rs | null | null | null | null | null |
source | asterinas | // SPDX-License-Identifier: MPL-2.0
#![expect(dead_code)]
use super::{
block_group::{BlockGroup, RawGroupDescriptor},
block_ptr::Ext2Bid,
inode::{FilePerm, Inode, InodeDesc, RawInode},
prelude::*,
super_block::{RawSuperBlock, SUPER_BLOCK_OFFSET, SuperBlock},
};
use crate::fs::{
registry::{FsPr... | kernel/src/fs/ext2/fs.rs | null | null | null | null | null |
source | asterinas | // SPDX-License-Identifier: MPL-2.0
use lru::LruCache;
use super::{
block_ptr::{BID_SIZE, Ext2Bid},
fs::Ext2,
prelude::*,
};
/// `IndirectBlockCache` is a caching structure that stores `IndirectBlock` objects for Ext2.
///
/// This cache uses an `LruCache` to manage the indirect blocks, ensuring that fre... | kernel/src/fs/ext2/indirect_block_cache.rs | null | null | null | null | null |
source | asterinas | // SPDX-License-Identifier: MPL-2.0
#![expect(dead_code)]
#![expect(unused_variables)]
use alloc::{borrow::ToOwned, rc::Rc};
use core::sync::atomic::{AtomicUsize, Ordering};
use inherit_methods_macro::inherit_methods;
use ostd::{const_assert, mm::io_util::HasVmReaderWriter};
use super::{
block_ptr::{BID_SIZE, B... | kernel/src/fs/ext2/inode.rs | null | null | null | null | null |
source | asterinas | // SPDX-License-Identifier: MPL-2.0
//! A safe Rust Ext2 filesystem.
//!
//! The Second Extended File System(Ext2) is a major rewrite of the Ext filesystem.
//! It is the predominant filesystem in use by Linux from the early 1990s to the early 2000s.
//! The structures of Ext3 and Ext4 are based on Ext2 and add some a... | kernel/src/fs/ext2/mod.rs | null | null | null | null | null |
source | asterinas | // SPDX-License-Identifier: MPL-2.0
pub(super) use core::{
ops::{Deref, DerefMut, Range},
time::Duration,
};
pub(super) use align_ext::AlignExt;
pub(super) use aster_block::{
BLOCK_SIZE, BlockDevice, SECTOR_SIZE,
bio::{BioDirection, BioSegment, BioStatus, BioWaiter},
id::Bid,
};
pub(super) use ost... | kernel/src/fs/ext2/prelude.rs | null | null | null | null | null |
source | asterinas | // SPDX-License-Identifier: MPL-2.0
use ostd::const_assert;
use super::{inode::RawInode, prelude::*};
/// The magic number of Ext2.
pub const MAGIC_NUM: u16 = 0xef53;
/// The main superblock is located at byte 1024 from the beginning of the device.
pub const SUPER_BLOCK_OFFSET: usize = 1024;
const SUPER_BLOCK_SIZE... | kernel/src/fs/ext2/super_block.rs | null | null | null | null | null |
source | asterinas | // SPDX-License-Identifier: MPL-2.0
use core::ops::MulAssign;
use super::prelude::*;
/// Returns the current time.
pub fn now() -> Duration {
crate::time::clocks::RealTimeCoarseClock::get().read_time()
}
pub trait IsPowerOf: Copy + Sized + MulAssign + PartialOrd {
/// Returns true if and only if `self == x^... | kernel/src/fs/ext2/utils.rs | null | null | null | null | null |
source | asterinas | // SPDX-License-Identifier: MPL-2.0
use ostd::mm::{HasSize, io_util::HasVmReaderWriter};
use super::{Ext2, Inode, block_ptr::Ext2Bid, prelude::*};
use crate::fs::utils::{XATTR_NAME_MAX_LEN, XattrName, XattrNamespace, XattrSetFlags};
const EXT2_XATTR_MAGIC: u32 = 0xEA020000;
/// The xattr header of an ext2 inode, or... | kernel/src/fs/ext2/xattr.rs | null | null | null | null | null |
source | asterinas | // SPDX-License-Identifier: MPL-2.0
use ostd::sync::RwMutexReadGuard;
use crate::{
fs::{
ext2::{Ext2, MAGIC_NUM as EXT2_MAGIC, SuperBlock as Ext2SuperBlock, utils::Dirty},
utils::{FileSystem, FsEventSubscriberStats, Inode, NAME_MAX, SuperBlock},
},
prelude::*,
};
impl FileSystem for Ext2 ... | kernel/src/fs/ext2/impl_for_vfs/fs.rs | null | null | null | null | null |
source | asterinas | // SPDX-License-Identifier: MPL-2.0
use core::time::Duration;
use device_id::DeviceId;
use crate::{
device,
fs::{
ext2::{FilePerm, Inode as Ext2Inode},
inode_handle::FileIo,
utils::{
AccessMode, DirentVisitor, Extension, FallocMode, FileSystem, Inode, InodeIo,
... | kernel/src/fs/ext2/impl_for_vfs/inode.rs | null | null | null | null | null |
source | asterinas | // SPDX-License-Identifier: MPL-2.0
use alloc::{
collections::VecDeque,
string::String,
sync::{Arc, Weak},
};
use core::{
fmt::Display,
sync::atomic::{AtomicBool, AtomicU32, AtomicU64, Ordering},
};
use align_ext::AlignExt;
use bitflags::bitflags;
use hashbrown::HashMap;
use ostd::{mm::VmWriter, s... | kernel/src/fs/notify/inotify.rs | null | null | null | null | null |
source | asterinas | // SPDX-License-Identifier: MPL-2.0
use alloc::{sync::Arc, vec::Vec};
use core::{
any::Any,
sync::atomic::{AtomicBool, AtomicU32, Ordering},
};
use atomic_integer_wrapper::define_atomic_version_of_integer_like_type;
use bitflags::bitflags;
use ostd::sync::RwLock;
use crate::{
fs::{file_handle::FileLike, ... | kernel/src/fs/notify/mod.rs | null | null | null | null | null |
source | asterinas | // SPDX-License-Identifier: MPL-2.0
#![expect(dead_code)]
use alloc::format;
use core::{
sync::atomic::{AtomicU64, Ordering},
time::Duration,
};
use align_ext::AlignExt;
use aster_block::BLOCK_SIZE;
use hashbrown::HashSet;
use inherit_methods_macro::inherit_methods;
use ostd::{
mm::{FrameAllocOptions, io... | kernel/src/fs/overlayfs/fs.rs | null | null | null | null | null |
source | asterinas | // SPDX-License-Identifier: MPL-2.0
use fs::OverlayFsType;
mod fs;
pub(super) fn init() {
super::registry::register(&OverlayFsType).unwrap();
} | kernel/src/fs/overlayfs/mod.rs | null | null | null | null | null |
source | asterinas | // SPDX-License-Identifier: MPL-2.0
use core::{
ops::Deref,
sync::atomic::{AtomicU32, Ordering},
};
use hashbrown::HashMap;
use ostd::sync::RwMutexWriteGuard;
use super::{is_dot, is_dot_or_dotdot, is_dotdot};
use crate::{
fs::{
self,
utils::{Inode, InodeExt, InodeMode, InodeType, MknodTyp... | kernel/src/fs/path/dentry.rs | null | null | null | null | null |
source | asterinas | // SPDX-License-Identifier: MPL-2.0
//! Form file paths within and across FSes with dentries and mount points.
use core::time::Duration;
use inherit_methods_macro::inherit_methods;
pub use mount::{Mount, MountPropType, PerMountFlags};
pub use mount_namespace::MountNamespace;
pub use resolver::{AT_FDCWD, AbsPathResul... | kernel/src/fs/path/mod.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 hashbrown::HashMap;
use id_alloc::IdAlloc;
use spin::Once;
use crate::{
fs::{
path::{
Path,
dentry::{Dentry, DentryKey},
... | kernel/src/fs/path/mount.rs | null | null | null | null | null |
source | asterinas | // SPDX-License-Identifier: MPL-2.0
use spin::Once;
use crate::{
fs::{
path::{Mount, Path, PathResolver},
ramfs::RamFs,
},
prelude::*,
process::{UserNamespace, credentials::capabilities::CapSet, posix_thread::PosixThread},
};
/// Represents a mount namespace, which encapsulates a moun... | kernel/src/fs/path/mount_namespace.rs | null | null | null | null | null |
source | asterinas | // SPDX-License-Identifier: MPL-2.0
use alloc::str;
use ostd::task::Task;
use super::{Mount, Path};
use crate::{
fs::{
file_table::{FileDesc, get_file_fast},
path::MountNamespace,
utils::{InodeType, NAME_MAX, PATH_MAX, Permission, SYMLINKS_MAX, SymbolicLink},
},
prelude::*,
pr... | kernel/src/fs/path/resolver.rs | null | null | null | null | null |
source | asterinas | // SPDX-License-Identifier: MPL-2.0
use core::time::Duration;
use inherit_methods_macro::inherit_methods;
use crate::{
fs::{
inode_handle::{FileIo, InodeHandle},
pipe::Pipe,
pseudofs::{PipeFs, PseudoInode, PseudoInodeType},
utils::{
AccessMode, Extension, FileSystem, I... | kernel/src/fs/pipe/anon_pipe.rs | null | null | null | null | null |
source | asterinas | // SPDX-License-Identifier: MPL-2.0
use core::{
num::Wrapping,
sync::atomic::{AtomicUsize, Ordering},
};
use ostd::sync::WaitQueue;
use crate::{
events::IoEvents,
fs::{
inode_handle::FileIo,
utils::{AccessMode, Endpoint, EndpointState, InodeIo, StatusFlags},
},
prelude::*,
... | kernel/src/fs/pipe/common.rs | null | null | null | null | null |
source | asterinas | // SPDX-License-Identifier: MPL-2.0
//! Pipes implementation.
//!
//! This module provides both anonymous and named pipes for inter-process communication.
pub(super) use anon_pipe::AnonPipeInode;
pub use anon_pipe::new_file_pair;
pub(super) use common::{Pipe, PipeHandle, check_status_flags};
mod anon_pipe;
mod commo... | kernel/src/fs/pipe/mod.rs | null | null | null | null | null |
source | asterinas | // SPDX-License-Identifier: MPL-2.0
//! This module offers `/proc/cmdline` file support, which provides
//! information about arguments passed to the kernel at boot time.
//!
//! Reference: <https://man7.org/linux/man-pages/man5/proc_cmdline.5.html>
use aster_util::printer::VmPrinter;
use ostd::boot::boot_info;
use ... | kernel/src/fs/procfs/cmdline.rs | null | null | null | null | null |
source | asterinas | // SPDX-License-Identifier: MPL-2.0
//! This module offers `/proc/cpuinfo` file support, which provides
//! information about the CPU architecture, cores, and other details.
//!
//! Reference: <https://man7.org/linux/man-pages/man5/proc_cpuinfo.5.html>
use aster_util::printer::VmPrinter;
use ostd::{
cpu::{PinCurr... | kernel/src/fs/procfs/cpuinfo.rs | null | null | null | null | null |
source | asterinas | // SPDX-License-Identifier: MPL-2.0
use aster_util::printer::{VmPrinter, VmPrinterError};
use crate::{
fs::{
procfs::template::{FileOps, ProcFileBuilder},
registry::FsProperties,
utils::{Inode, mkmod},
},
prelude::*,
};
/// Represents the inode at /proc/filesystems.
pub struct Fil... | kernel/src/fs/procfs/filesystems.rs | null | null | null | null | null |
source | asterinas | // SPDX-License-Identifier: MPL-2.0
//! This module offers `/proc/loadavg` file support, which tells the user space
//! about the cpu load average for the last 1, 5, and 15 minutes.
//!
//! Reference: <https://www.man7.org/linux/man-pages/man5/proc_loadavg.5.html>
use aster_util::printer::VmPrinter;
use crate::{
... | kernel/src/fs/procfs/loadavg.rs | null | null | null | null | null |
source | asterinas | // SPDX-License-Identifier: MPL-2.0
//! This module offers `/proc/meminfo` file support, which tells the user space
//! about the memory statistics in the entire system. The definition of the
//! fields are similar to that of Linux's but there exist differences.
//!
//! Reference: <https://man7.org/linux/man-pages/man... | kernel/src/fs/procfs/meminfo.rs | null | null | null | null | null |
source | asterinas | // SPDX-License-Identifier: MPL-2.0
use core::sync::atomic::{AtomicU64, Ordering};
use aster_util::slot_vec::SlotVec;
use ostd::sync::RwMutexUpgradeableGuard;
use template::{lookup_child_from_table, populate_children_from_table};
use self::{
cmdline::CmdLineFileOps,
cpuinfo::CpuInfoFileOps,
loadavg::Load... | kernel/src/fs/procfs/mod.rs | null | null | null | null | null |
source | asterinas | // SPDX-License-Identifier: MPL-2.0
use crate::{
fs::{
procfs::{ProcSymBuilder, SymOps},
utils::{Inode, SymbolicLink, mkmod},
},
prelude::*,
};
/// Represents the inode at `/proc/mounts`.
pub struct MountsSymOps;
impl MountsSymOps {
pub fn new_inode(parent: Weak<dyn Inode>) -> Arc<dyn... | kernel/src/fs/procfs/mounts.rs | null | null | null | null | null |
source | asterinas | // SPDX-License-Identifier: MPL-2.0
use crate::{
fs::{
procfs::{ProcSymBuilder, SymOps},
utils::{Inode, SymbolicLink, mkmod},
},
prelude::*,
};
/// Represents the inode at `/proc/self`.
pub struct SelfSymOps;
impl SelfSymOps {
pub fn new_inode(parent: Weak<dyn Inode>) -> Arc<dyn Inode... | kernel/src/fs/procfs/self_.rs | null | null | null | null | null |
source | asterinas | // SPDX-License-Identifier: MPL-2.0
//! This module offers `/proc/stat` file support, which provides
//! information about kernel system statistics.
//!
//! Reference: <https://man7.org/linux/man-pages/man5/proc_stat.5.html>
use aster_softirq::{
iter_irq_counts_across_all_cpus, iter_softirq_counts_across_all_cpus... | kernel/src/fs/procfs/stat.rs | null | null | null | null | null |
source | asterinas | // SPDX-License-Identifier: MPL-2.0
use alloc::format;
use crate::{
fs::{
procfs::{ProcSymBuilder, SymOps},
utils::{Inode, SymbolicLink, mkmod},
},
prelude::*,
process::posix_thread::AsPosixThread,
};
/// Represents the inode at `/proc/self-thread`.
pub struct ThreadSelfSymOps;
impl ... | kernel/src/fs/procfs/thread_self.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.