2023-07-20 15:41:00 +03:00
|
|
|
//! I/O control data structures
|
|
|
|
|
|
|
|
mod file;
|
|
|
|
mod terminal;
|
|
|
|
|
2023-07-22 00:39:50 +03:00
|
|
|
pub use file::{FileMode, FileType, OpenOptions};
|
2023-07-20 15:41:00 +03:00
|
|
|
pub use terminal::{
|
|
|
|
TerminalInputOptions, TerminalLineOptions, TerminalOptions, TerminalOutputOptions,
|
|
|
|
};
|
|
|
|
|
2023-07-22 00:39:50 +03:00
|
|
|
/// 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,
|
|
|
|
}
|
|
|
|
|
2023-07-20 15:41:00 +03:00
|
|
|
/// 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 {
|
2023-07-20 18:13:47 +03:00
|
|
|
/// Default input descriptor of a process
|
|
|
|
pub const STDIN: Self = Self(0);
|
2023-07-20 15:41:00 +03:00
|
|
|
/// Default output descriptor of a process
|
|
|
|
pub const STDOUT: Self = Self(1);
|
|
|
|
/// Error output descriptor of a process
|
|
|
|
pub const STDERR: Self = Self(2);
|
2023-07-22 00:39:50 +03:00
|
|
|
|
|
|
|
/// Temporary hack to represent Option<RawFd>::None
|
|
|
|
pub const NONE: Self = Self(u32::MAX);
|
2023-07-20 15:41:00 +03:00
|
|
|
}
|