moved the Rc<RefCell<>> back into FatFs
This commit is contained in:
parent
8b55d8d13c
commit
f708ab0b50
5 changed files with 15 additions and 4 deletions
|
|
@ -236,6 +236,7 @@ impl Bpb {
|
|||
if self.fat_type() == FatType::Fat32 {
|
||||
return None;
|
||||
}
|
||||
|
||||
Some(self.fat_offset() + self.sector_to_offset(self.num_fats() as u32 * self.fat_size()))
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -98,8 +98,15 @@ pub struct FatFs {
|
|||
fat: fat::Fat,
|
||||
}
|
||||
|
||||
unsafe impl Send for FatFs {}
|
||||
|
||||
impl FatFs {
|
||||
pub fn load(data: Rc<RefCell<dyn SliceLike>>) -> anyhow::Result<FatFs> {
|
||||
pub fn load<S>(data: S) -> anyhow::Result<FatFs>
|
||||
where
|
||||
S: SliceLike + Send + 'static,
|
||||
{
|
||||
let data = Rc::new(RefCell::new(data));
|
||||
|
||||
let mut bpb_bytes = [0; 512];
|
||||
|
||||
data.borrow_mut().read_at_offset(0, &mut bpb_bytes)?;
|
||||
|
|
|
|||
|
|
@ -22,7 +22,7 @@ pub fn main() -> anyhow::Result<()> {
|
|||
|
||||
// println!("{}", bpb);
|
||||
|
||||
let fat_fs = FatFs::load(Rc::new(RefCell::new(file)))?;
|
||||
let fat_fs = FatFs::load(file)?;
|
||||
|
||||
println!("{}", fat_fs.bpb());
|
||||
println!();
|
||||
|
|
|
|||
|
|
@ -26,7 +26,10 @@ pub struct FatFuse {
|
|||
}
|
||||
|
||||
impl FatFuse {
|
||||
pub fn new(data: Rc<RefCell<dyn SliceLike>>) -> anyhow::Result<FatFuse> {
|
||||
pub fn new<S>(data: S) -> anyhow::Result<FatFuse>
|
||||
where
|
||||
S: SliceLike + Send + 'static,
|
||||
{
|
||||
let uid = unsafe { libc::getuid() };
|
||||
let gid = unsafe { libc::getgid() };
|
||||
|
||||
|
|
|
|||
|
|
@ -15,7 +15,7 @@ fn main() -> anyhow::Result<()> {
|
|||
|
||||
let file = File::open(path)?;
|
||||
|
||||
let fat_fuse = FatFuse::new(Rc::new(RefCell::new(file)))?;
|
||||
let fat_fuse = FatFuse::new(file)?;
|
||||
|
||||
let options = vec![
|
||||
MountOption::RO,
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue