Compare commits
1 commit
d20fe4cf2d
...
28a3b39ca1
| Author | SHA1 | Date | |
|---|---|---|---|
| 28a3b39ca1 |
4 changed files with 8 additions and 45 deletions
4
Cargo.lock
generated
4
Cargo.lock
generated
|
|
@ -150,6 +150,10 @@ dependencies = [
|
|||
"thiserror",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "fat-mount"
|
||||
version = "0.1.0"
|
||||
|
||||
[[package]]
|
||||
name = "fuser"
|
||||
version = "0.15.1"
|
||||
|
|
|
|||
|
|
@ -65,7 +65,6 @@ pub struct DirEntry {
|
|||
|
||||
file_size: u32,
|
||||
|
||||
checksum: u8,
|
||||
long_name: Option<CompactString>,
|
||||
}
|
||||
|
||||
|
|
@ -91,7 +90,7 @@ impl Display for DirEntry {
|
|||
}
|
||||
|
||||
impl DirEntry {
|
||||
fn load_name(bytes: [u8; 11], attr: &Attr) -> [u8; 13] {
|
||||
fn load_name(bytes: [u8; 13], attr: &Attr) -> [u8; 13] {
|
||||
let mut name = [0; 13];
|
||||
|
||||
let mut iter = name.iter_mut();
|
||||
|
|
@ -195,7 +194,6 @@ impl DirEntry {
|
|||
write_date,
|
||||
file_size,
|
||||
long_name: None,
|
||||
checksum: Self::checksum(&bytes[..11]),
|
||||
})
|
||||
}
|
||||
|
||||
|
|
@ -336,10 +334,10 @@ impl DirEntry {
|
|||
self.file_size
|
||||
}
|
||||
|
||||
pub fn checksum(name: &[u8]) -> u8 {
|
||||
pub fn checksum(&self) -> u8 {
|
||||
let mut checksum: u8 = 0;
|
||||
|
||||
for &x in name {
|
||||
for &x in self.name() {
|
||||
checksum = checksum.rotate_right(1).wrapping_add(x);
|
||||
}
|
||||
|
||||
|
|
@ -579,7 +577,7 @@ impl<R: Read> DirIter<R> {
|
|||
|
||||
if let Some(iter) = self
|
||||
.long_filename_buf
|
||||
.get_buf(dir_entry.checksum)
|
||||
.get_buf(dir_entry.checksum())
|
||||
.map_err(|e| {
|
||||
anyhow::anyhow!(
|
||||
"failed to get long filename for {}: {}",
|
||||
|
|
|
|||
|
|
@ -1,10 +0,0 @@
|
|||
[package]
|
||||
name = "fat-mount"
|
||||
version = "0.1.0"
|
||||
edition = "2024"
|
||||
|
||||
[dependencies]
|
||||
anyhow = "1.0.98"
|
||||
env_logger = "0.11.8"
|
||||
fat-fuse = { version = "0.1.0", path = "../fat-fuse" }
|
||||
fuser = "0.15.1"
|
||||
|
|
@ -1,29 +0,0 @@
|
|||
use std::cell::RefCell;
|
||||
use std::fs::File;
|
||||
use std::rc::Rc;
|
||||
|
||||
use fat_fuse::FatFuse;
|
||||
use fuser::MountOption;
|
||||
|
||||
fn main() -> anyhow::Result<()> {
|
||||
env_logger::init();
|
||||
|
||||
let mut args = std::env::args();
|
||||
|
||||
let path = args.next().ok_or(anyhow::anyhow!("missing fs path"))?;
|
||||
let mountpoint = args.next().ok_or(anyhow::anyhow!("missing mount point"))?;
|
||||
|
||||
let file = File::open(path)?;
|
||||
|
||||
let fat_fuse = FatFuse::new(Rc::new(RefCell::new(file)))?;
|
||||
|
||||
let options = vec![
|
||||
MountOption::RO,
|
||||
MountOption::FSName("fat-fuse".to_owned()),
|
||||
MountOption::AutoUnmount,
|
||||
];
|
||||
|
||||
fuser::mount2(fat_fuse, mountpoint, &options).unwrap();
|
||||
|
||||
Ok(())
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue