Skip to content

Commit

Permalink
Remove checks on directory binding for FUSE drivers
Browse files Browse the repository at this point in the history
  • Loading branch information
Raytwo committed Oct 29, 2022
1 parent 30d320f commit 5a7864b
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 11 deletions.
8 changes: 0 additions & 8 deletions src/criware/bind.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,6 @@ pub enum DirBindingError {
CriwareErrorCode(i32),
#[error("the path provided is not absolute: {0}")]
PathNotAbsolute(Utf8PathBuf),
#[error("the path provided is not a directory: {0}")]
NotADirectory(Utf8PathBuf),
#[error("the path provided does not exist on the mount point: {0}")]
DirectoryDoesNotExist(Utf8PathBuf)
}

pub type CriFnBinderHandle = u64;
Expand All @@ -28,10 +24,6 @@ pub fn bind_directory<P: AsRef<Utf8Path>>(binder_handle: CriFnBinderHandle, path

if !path.is_absolute() {
Err(DirBindingError::PathNotAbsolute(path.to_path_buf()))
} else if !path.is_dir() {
Err(DirBindingError::NotADirectory(path.to_path_buf()))
} else if !path.exists() {
Err(DirBindingError::DirectoryDoesNotExist(path.to_path_buf()))
} else {
let nullterm_path = format!("{}\0", path);

Expand Down
27 changes: 24 additions & 3 deletions src/fuse/mods.rs
Original file line number Diff line number Diff line change
@@ -1,17 +1,38 @@
use nn_fuse::{FAccessor, FsAccessor, FileSystemAccessor, FsEntryType, AccessorResult, DAccessor };
use camino::Utf8PathBuf;
use nn_fuse::{FAccessor, FsAccessor, FileSystemAccessor, FsEntryType, AccessorResult, DAccessor, FileAccessor };

pub struct ModFuse;
pub struct ModFileAccessor(Utf8PathBuf);

impl FileAccessor for ModFileAccessor {
fn read(&mut self, mut buffer: &mut [u8], offset: usize) -> Result<usize, AccessorResult> {
Err(AccessorResult::Unimplemented)
}

fn get_size(&mut self) -> Result<usize, AccessorResult> {
let size = 0;
Ok(size)
}
}

impl FileSystemAccessor for ModFuse {
fn get_entry_type(&self, path: &std::path::Path) -> Result<FsEntryType, AccessorResult> {
println!("GetEntryType: {}", path.display());
Ok(FsEntryType::File)
Err(AccessorResult::PathNotFound)
}

fn open_file(&self, path: &std::path::Path, mode: skyline::nn::fs::OpenMode) -> Result<*mut FAccessor, AccessorResult> {
println!("OpenFile: {}", path.display());

Err(AccessorResult::PathNotFound)
let read = mode & 1 != 0;
let write = mode >> 1 & 1 != 0;
let append = mode >> 2 & 1 != 0;

if write || append {
Err(AccessorResult::Unsupported)
} else {
Err(AccessorResult::PathNotFound)
}
}

fn open_directory(&self, path: &std::path::Path, mode: skyline::nn::fs::OpenDirectoryMode) -> Result<*mut DAccessor, AccessorResult> {
Expand Down

0 comments on commit 5a7864b

Please sign in to comment.