use std::io;
pub mod devfs;
#[cfg(feature = "fstool")]
pub mod fstoolfs;
pub mod mount;
pub mod overlay;
#[cfg(unix)]
pub mod passthrough;
pub mod procfs;
pub mod sysfs;
pub mod tar;
pub mod tmpfs;
pub use devfs::DevFs;
#[cfg(feature = "fstool")]
pub use fstoolfs::FsToolMount;
pub use mount::MountTable;
pub use overlay::Overlay;
#[cfg(unix)]
pub use passthrough::Passthrough;
pub use procfs::ProcFs;
pub use sysfs::SysFs;
pub use tmpfs::TmpFs;
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
pub enum NodeKind {
File,
Dir,
Symlink,
CharDevice,
BlockDevice,
Fifo,
Socket,
}
#[derive(Debug, Clone)]
pub struct Attrs {
pub kind: NodeKind,
pub size: u64,
pub mode: u32,
pub uid: u32,
pub gid: u32,
pub mtime: i64,
pub inode: u64,
pub nlink: u32,
pub rdev: u64,
}
#[derive(Debug, Clone)]
pub struct DirEntry {
pub name: String,
pub kind: NodeKind,
pub inode: u64,
}
pub trait MountFs: std::fmt::Debug {
fn stat(&mut self, rel: &str) -> Option<Attrs>;
fn read_at(&mut self, rel: &str, off: u64, buf: &mut [u8]) -> io::Result<usize>;
fn readdir(&mut self, rel: &str) -> io::Result<Vec<DirEntry>>;
fn read_only(&self) -> bool {
true
}
fn write_at(&mut self, _rel: &str, _off: u64, _buf: &[u8]) -> io::Result<usize> {
Err(erofs())
}
fn create(&mut self, _rel: &str, _mode: u32) -> io::Result<()> {
Err(erofs())
}
fn mkdir(&mut self, _rel: &str, _mode: u32) -> io::Result<()> {
Err(erofs())
}
fn unlink(&mut self, _rel: &str) -> io::Result<()> {
Err(erofs())
}
fn rmdir(&mut self, _rel: &str) -> io::Result<()> {
Err(erofs())
}
fn truncate(&mut self, _rel: &str, _len: u64) -> io::Result<()> {
Err(erofs())
}
fn symlink(&mut self, _target: &str, _linkpath: &str) -> io::Result<()> {
Err(erofs())
}
fn readlink(&mut self, _rel: &str) -> io::Result<String> {
Err(io::Error::from_raw_os_error(22)) }
fn rename(&mut self, _from: &str, _to: &str) -> io::Result<()> {
Err(erofs())
}
}
fn erofs() -> io::Error {
io::Error::from_raw_os_error(30) }