Support for Read/OpenDirectory
This commit is contained in:
parent
6b2350f266
commit
34f1c2ccf7
@ -1,4 +1,4 @@
|
|||||||
use crate::bitflags;
|
use crate::{bitflags, primitive_enum};
|
||||||
|
|
||||||
bitflags! {
|
bitflags! {
|
||||||
#[doc = "Defines the access mode of the file"]
|
#[doc = "Defines the access mode of the file"]
|
||||||
@ -47,6 +47,22 @@ bitflags! {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
primitive_enum!(
|
||||||
|
#[doc = "Defines a type of a file"]
|
||||||
|
pub enum FileType: u32 {
|
||||||
|
#[doc = "Regular file"]
|
||||||
|
File = 0,
|
||||||
|
#[doc = "Directory"]
|
||||||
|
Directory = 1,
|
||||||
|
#[doc = "Not yet implemented"]
|
||||||
|
Symlink = 2,
|
||||||
|
#[doc = "Block device"]
|
||||||
|
Block = 3,
|
||||||
|
#[doc = "Character device (e.g. terminal)"]
|
||||||
|
Char = 4,
|
||||||
|
}
|
||||||
|
);
|
||||||
|
|
||||||
impl FileMode {
|
impl FileMode {
|
||||||
/// File mode with all access bits set
|
/// File mode with all access bits set
|
||||||
pub const fn all() -> Self {
|
pub const fn all() -> Self {
|
||||||
|
@ -1,17 +1,27 @@
|
|||||||
//! I/O control data structures
|
//! 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
|
/// Raw file descriptor representation
|
||||||
#[derive(Clone, Copy, PartialEq, Debug, PartialOrd, Ord, Eq)]
|
#[derive(Clone, Copy, PartialEq, Debug, PartialOrd, Ord, Eq)]
|
||||||
#[repr(transparent)]
|
#[repr(transparent)]
|
||||||
pub struct RawFd(pub u32);
|
pub struct RawFd(pub u32);
|
||||||
|
|
||||||
mod file;
|
/// Raw directory entry representation
|
||||||
mod terminal;
|
#[derive(Clone, Copy, Debug)]
|
||||||
|
#[repr(C)]
|
||||||
pub use file::{FileMode, OpenOptions};
|
pub struct DirectoryEntry {
|
||||||
pub use terminal::{
|
/// Name of the entry
|
||||||
TerminalInputOptions, TerminalLineOptions, TerminalOptions, TerminalOutputOptions,
|
pub name: [u8; 256],
|
||||||
};
|
/// Type of the entry
|
||||||
|
pub ty: FileType,
|
||||||
|
}
|
||||||
|
|
||||||
/// Describes how a mount operation should be performed
|
/// Describes how a mount operation should be performed
|
||||||
#[derive(Clone, Debug)]
|
#[derive(Clone, Debug)]
|
||||||
@ -40,4 +50,7 @@ impl RawFd {
|
|||||||
pub const STDOUT: Self = Self(1);
|
pub const STDOUT: Self = Self(1);
|
||||||
/// Error output descriptor of a process
|
/// Error output descriptor of a process
|
||||||
pub const STDERR: Self = Self(2);
|
pub const STDERR: Self = Self(2);
|
||||||
|
|
||||||
|
/// Temporary hack to represent Option<RawFd>::None
|
||||||
|
pub const NONE: Self = Self(u32::MAX);
|
||||||
}
|
}
|
||||||
|
@ -4,7 +4,7 @@ macro_rules! primitive_enum {
|
|||||||
($(#[doc = $enum_doc:expr])? $vis:vis enum $name:ident: $repr:ty {
|
($(#[doc = $enum_doc:expr])? $vis:vis enum $name:ident: $repr:ty {
|
||||||
$( $(#[doc = $doc:expr])? $variant:ident = $discriminant:literal, )+
|
$( $(#[doc = $doc:expr])? $variant:ident = $discriminant:literal, )+
|
||||||
}) => {
|
}) => {
|
||||||
#[derive(Clone, Copy, Debug, PartialEq)]
|
#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash)]
|
||||||
#[repr($repr)]
|
#[repr($repr)]
|
||||||
$(#[doc = $enum_doc])?
|
$(#[doc = $enum_doc])?
|
||||||
$vis enum $name {
|
$vis enum $name {
|
||||||
|
@ -20,6 +20,10 @@ primitive_enum!(
|
|||||||
Open = 7,
|
Open = 7,
|
||||||
#[doc = "Close a file descriptor"]
|
#[doc = "Close a file descriptor"]
|
||||||
Close = 8,
|
Close = 8,
|
||||||
|
#[doc = "Open a directory for reading"]
|
||||||
|
OpenDirectory = 9,
|
||||||
|
#[doc = "Read entries from a directory descriptor"]
|
||||||
|
ReadDirectory = 10,
|
||||||
|
|
||||||
#[doc = "Mount a filesystem"]
|
#[doc = "Mount a filesystem"]
|
||||||
Mount = 101,
|
Mount = 101,
|
||||||
|
Loading…
x
Reference in New Issue
Block a user