use std::ffi::{OsStr, OsString};
use std::path::Path;
use std::time::{Duration, SystemTime};
#[derive(Clone, Copy, Debug)]
pub struct RequestInfo {
pub unique: u64,
pub uid: u32,
pub gid: u32,
pub pid: u32,
}
#[derive(Clone, Debug)]
pub struct DirectoryEntry {
pub name: OsString,
pub kind: crate::FileType,
}
#[derive(Clone, Copy, Debug)]
pub struct Statfs {
pub blocks: u64,
pub bfree: u64,
pub bavail: u64,
pub files: u64,
pub ffree: u64,
pub bsize: u32,
pub namelen: u32,
pub frsize: u32,
}
#[derive(Clone, Copy, Debug)]
pub struct FileAttr {
pub size: u64,
pub blocks: u64,
pub atime: SystemTime,
pub mtime: SystemTime,
pub ctime: SystemTime,
pub crtime: SystemTime,
pub kind: crate::FileType,
pub perm: u16,
pub nlink: u32,
pub uid: u32,
pub gid: u32,
pub rdev: u32,
pub flags: u32,
}
#[derive(Clone, Debug)]
pub struct CreatedEntry {
pub ttl: Duration,
pub attr: FileAttr,
pub fh: u64,
pub flags: u32,
}
#[derive(Clone, Debug)]
pub enum Xattr {
Size(u32),
Data(Vec<u8>),
}
#[cfg(target_os = "macos")]
#[derive(Clone, Debug)]
pub struct XTimes {
pub bkuptime: SystemTime,
pub crtime: SystemTime,
}
pub type ResultEmpty = Result<(), libc::c_int>;
pub type ResultEntry = Result<(Duration, FileAttr), libc::c_int>;
pub type ResultOpen = Result<(u64, u32), libc::c_int>;
pub type ResultReaddir = Result<Vec<DirectoryEntry>, libc::c_int>;
pub type ResultData = Result<Vec<u8>, libc::c_int>;
pub type ResultSlice<'a> = Result<&'a [u8], libc::c_int>;
pub type ResultWrite = Result<u32, libc::c_int>;
pub type ResultStatfs = Result<Statfs, libc::c_int>;
pub type ResultCreate = Result<CreatedEntry, libc::c_int>;
pub type ResultXattr = Result<Xattr, libc::c_int>;
#[cfg(target_os = "macos")]
pub type ResultXTimes = Result<XTimes, libc::c_int>;
#[deprecated(since = "0.3.0", note = "use ResultEntry instead")]
pub type ResultGetattr = ResultEntry;
pub struct CallbackResult {
pub(crate) _private: std::marker::PhantomData<()>,
}
pub trait FilesystemMT {
fn init(&self, _req: RequestInfo) -> ResultEmpty {
Ok(())
}
fn destroy(&self) {
}
fn getattr(&self, _req: RequestInfo, _path: &Path, _fh: Option<u64>) -> ResultEntry {
Err(libc::ENOSYS)
}
fn chmod(&self, _req: RequestInfo, _path: &Path, _fh: Option<u64>, _mode: u32) -> ResultEmpty {
Err(libc::ENOSYS)
}
fn chown(&self, _req: RequestInfo, _path: &Path, _fh: Option<u64>, _uid: Option<u32>, _gid: Option<u32>) -> ResultEmpty {
Err(libc::ENOSYS)
}
fn truncate(&self, _req: RequestInfo, _path: &Path, _fh: Option<u64>, _size: u64) -> ResultEmpty {
Err(libc::ENOSYS)
}
fn utimens(&self, _req: RequestInfo, _path: &Path, _fh: Option<u64>, _atime: Option<SystemTime>, _mtime: Option<SystemTime>) -> ResultEmpty {
Err(libc::ENOSYS)
}
#[allow(clippy::too_many_arguments)]
fn utimens_macos(&self, _req: RequestInfo, _path: &Path, _fh: Option<u64>, _crtime: Option<SystemTime>, _chgtime: Option<SystemTime>, _bkuptime: Option<SystemTime>, _flags: Option<u32>) -> ResultEmpty {
Err(libc::ENOSYS)
}
fn readlink(&self, _req: RequestInfo, _path: &Path) -> ResultData {
Err(libc::ENOSYS)
}
fn mknod(&self, _req: RequestInfo, _parent: &Path, _name: &OsStr, _mode: u32, _rdev: u32) -> ResultEntry {
Err(libc::ENOSYS)
}
fn mkdir(&self, _req: RequestInfo, _parent: &Path, _name: &OsStr, _mode: u32) -> ResultEntry {
Err(libc::ENOSYS)
}
fn unlink(&self, _req: RequestInfo, _parent: &Path, _name: &OsStr) -> ResultEmpty {
Err(libc::ENOSYS)
}
fn rmdir(&self, _req: RequestInfo, _parent: &Path, _name: &OsStr) -> ResultEmpty {
Err(libc::ENOSYS)
}
fn symlink(&self, _req: RequestInfo, _parent: &Path, _name: &OsStr, _target: &Path) -> ResultEntry {
Err(libc::ENOSYS)
}
fn rename(&self, _req: RequestInfo, _parent: &Path, _name: &OsStr, _newparent: &Path, _newname: &OsStr) -> ResultEmpty {
Err(libc::ENOSYS)
}
fn link(&self, _req: RequestInfo, _path: &Path, _newparent: &Path, _newname: &OsStr) -> ResultEntry {
Err(libc::ENOSYS)
}
fn open(&self, _req: RequestInfo, _path: &Path, _flags: u32) -> ResultOpen {
Err(libc::ENOSYS)
}
fn read(&self, _req: RequestInfo, _path: &Path, _fh: u64, _offset: u64, _size: u32, callback: impl FnOnce(ResultSlice<'_>) -> CallbackResult) -> CallbackResult {
callback(Err(libc::ENOSYS))
}
fn write(&self, _req: RequestInfo, _path: &Path, _fh: u64, _offset: u64, _data: Vec<u8>, _flags: u32) -> ResultWrite {
Err(libc::ENOSYS)
}
fn flush(&self, _req: RequestInfo, _path: &Path, _fh: u64, _lock_owner: u64) -> ResultEmpty {
Err(libc::ENOSYS)
}
fn release(&self, _req: RequestInfo, _path: &Path, _fh: u64, _flags: u32, _lock_owner: u64, _flush: bool) -> ResultEmpty {
Err(libc::ENOSYS)
}
fn fsync(&self, _req: RequestInfo, _path: &Path, _fh: u64, _datasync: bool) -> ResultEmpty {
Err(libc::ENOSYS)
}
fn opendir(&self, _req: RequestInfo, _path: &Path, _flags: u32) -> ResultOpen {
Err(libc::ENOSYS)
}
fn readdir(&self, _req: RequestInfo, _path: &Path, _fh: u64) -> ResultReaddir {
Err(libc::ENOSYS)
}
fn releasedir(&self, _req: RequestInfo, _path: &Path, _fh: u64, _flags: u32) -> ResultEmpty {
Err(libc::ENOSYS)
}
fn fsyncdir(&self, _req: RequestInfo, _path: &Path, _fh: u64, _datasync: bool) -> ResultEmpty {
Err(libc::ENOSYS)
}
fn statfs(&self, _req: RequestInfo, _path: &Path) -> ResultStatfs {
Err(libc::ENOSYS)
}
fn setxattr(&self, _req: RequestInfo, _path: &Path, _name: &OsStr, _value: &[u8], _flags: u32, _position: u32) -> ResultEmpty {
Err(libc::ENOSYS)
}
fn getxattr(&self, _req: RequestInfo, _path: &Path, _name: &OsStr, _size: u32) -> ResultXattr {
Err(libc::ENOSYS)
}
fn listxattr(&self, _req: RequestInfo, _path: &Path, _size: u32) -> ResultXattr {
Err(libc::ENOSYS)
}
fn removexattr(&self, _req: RequestInfo, _path: &Path, _name: &OsStr) -> ResultEmpty {
Err(libc::ENOSYS)
}
fn access(&self, _req: RequestInfo, _path: &Path, _mask: u32) -> ResultEmpty {
Err(libc::ENOSYS)
}
fn create(&self, _req: RequestInfo, _parent: &Path, _name: &OsStr, _mode: u32, _flags: u32) -> ResultCreate {
Err(libc::ENOSYS)
}
#[cfg(target_os = "macos")]
fn setvolname(&self, _req: RequestInfo, _name: &OsStr) -> ResultEmpty {
Err(libc::ENOSYS)
}
#[cfg(target_os = "macos")]
fn getxtimes(&self, _req: RequestInfo, _path: &Path) -> ResultXTimes {
Err(libc::ENOSYS)
}
}