yggdrasil/src/io/mod.rs

57 lines
1.6 KiB
Rust

//! I/O control data structures
mod file;
mod terminal;
pub use file::{FileMode, FileType, OpenOptions};
pub use terminal::{
TerminalInputOptions, TerminalLineOptions, TerminalOptions, TerminalOutputOptions,
};
/// Raw file descriptor representation
#[derive(Clone, Copy, PartialEq, Debug, PartialOrd, Ord, Eq)]
#[repr(transparent)]
pub struct RawFd(pub u32);
/// Raw directory entry representation
#[derive(Clone, Copy, Debug)]
#[repr(C)]
pub struct DirectoryEntry {
/// Name of the entry
pub name: [u8; 256],
/// Type of the entry
pub ty: FileType,
}
/// Describes how a mount operation should be performed
#[derive(Clone, Debug)]
#[repr(C)]
pub struct MountOptions {
/// Block device to use as a mount source. May be empty when mounting virtual filesystems.
pub source: Option<&'static str>,
/// Filesystem to use when mounting. Empty means "deduce automatically" and source must be set.
pub filesystem: Option<&'static str>,
/// Path to a directory to mount the filesystem to
pub target: &'static str,
}
/// Describes how an unmount operation should be performed
#[derive(Clone, Debug)]
#[repr(C)]
pub struct UnmountOptions {
/// Path to the mountpoint to unmount
pub mountpoint: &'static str,
}
impl RawFd {
/// Default input descriptor of a process
pub const STDIN: Self = Self(0);
/// Default output descriptor of a process
pub const STDOUT: Self = Self(1);
/// Error output descriptor of a process
pub const STDERR: Self = Self(2);
/// Temporary hack to represent Option<RawFd>::None
pub const NONE: Self = Self(u32::MAX);
}