removed generic from FatFs, made inner a dyn now
This commit is contained in:
parent
b3d87687dd
commit
a08a84c3e4
7 changed files with 270 additions and 78 deletions
|
|
@ -5,6 +5,7 @@ edition = "2024"
|
|||
|
||||
[dependencies]
|
||||
anyhow = "1.0.98"
|
||||
chrono = { version = "0.4.41", default-features = false, features = ["alloc", "clock", "std"] }
|
||||
fat-bits = { version = "0.1.0", path = "../fat-bits" }
|
||||
fuser = "0.15.1"
|
||||
libc = "0.2.174"
|
||||
|
|
|
|||
|
|
@ -1,52 +1,44 @@
|
|||
use std::ffi::c_int;
|
||||
mod inode;
|
||||
|
||||
use std::cell::RefCell;
|
||||
use std::collections::BTreeMap;
|
||||
use std::ffi::c_int;
|
||||
use std::rc::Rc;
|
||||
|
||||
use fat_bits::dir::DirEntry;
|
||||
use fat_bits::{FatFs, SliceLike};
|
||||
use fuser::{FileAttr, Filesystem};
|
||||
use fuser::Filesystem;
|
||||
use libc::{ENOSYS, EPERM};
|
||||
use log::{debug, warn};
|
||||
|
||||
#[allow(dead_code)]
|
||||
fn dir_entry_to_attr(dir_entry: &DirEntry, ino: u64) -> FileAttr {
|
||||
FileAttr {
|
||||
ino,
|
||||
size: dir_entry.file_size() as u64,
|
||||
blocks: todo!(),
|
||||
atime: todo!(),
|
||||
mtime: todo!(),
|
||||
ctime: todo!(),
|
||||
crtime: todo!(),
|
||||
kind: todo!(),
|
||||
perm: todo!(),
|
||||
nlink: todo!(),
|
||||
uid: todo!(),
|
||||
gid: todo!(),
|
||||
rdev: todo!(),
|
||||
blksize: todo!(),
|
||||
flags: todo!(),
|
||||
}
|
||||
}
|
||||
use crate::inode::Inode;
|
||||
|
||||
#[allow(dead_code)]
|
||||
pub struct FatFuse<S: SliceLike> {
|
||||
fat_fs: FatFs<S>,
|
||||
pub struct FatFuse {
|
||||
fat_fs: FatFs,
|
||||
|
||||
uid: u32,
|
||||
gid: u32,
|
||||
|
||||
inode_table: BTreeMap<u64, Inode>,
|
||||
}
|
||||
|
||||
impl<S: SliceLike> FatFuse<S> {
|
||||
pub fn new(data: S) -> anyhow::Result<FatFuse<S>> {
|
||||
impl FatFuse {
|
||||
pub fn new(data: Rc<RefCell<dyn SliceLike>>) -> anyhow::Result<FatFuse> {
|
||||
let uid = unsafe { libc::getuid() };
|
||||
let gid = unsafe { libc::getgid() };
|
||||
|
||||
let fat_fs = FatFs::load(data)?;
|
||||
|
||||
Ok(FatFuse { fat_fs, uid, gid })
|
||||
Ok(FatFuse {
|
||||
fat_fs,
|
||||
uid,
|
||||
gid,
|
||||
inode_table: BTreeMap::new(),
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
impl<S: SliceLike> Filesystem for FatFuse<S> {
|
||||
impl Filesystem for FatFuse {
|
||||
fn init(
|
||||
&mut self,
|
||||
_req: &fuser::Request<'_>,
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue