current status
This commit is contained in:
parent
9cb6ee6446
commit
b9d588f8ba
3 changed files with 22 additions and 23 deletions
|
|
@ -71,9 +71,9 @@ pub struct DirEntry {
|
||||||
file_size: u32,
|
file_size: u32,
|
||||||
|
|
||||||
checksum: u8,
|
checksum: u8,
|
||||||
long_name: Option<CompactString>,
|
|
||||||
|
|
||||||
n_longname_slots: u8,
|
long_name: Option<CompactString>,
|
||||||
|
n_slots: u8,
|
||||||
|
|
||||||
offset: u64,
|
offset: u64,
|
||||||
}
|
}
|
||||||
|
|
@ -154,13 +154,13 @@ impl DirEntry {
|
||||||
write_date,
|
write_date,
|
||||||
file_size,
|
file_size,
|
||||||
long_name: None,
|
long_name: None,
|
||||||
n_longname_slots: 0,
|
n_slots: 0,
|
||||||
checksum: Self::checksum(&bytes[..11]),
|
checksum: Self::checksum(&bytes[..11]),
|
||||||
offset,
|
offset,
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn create(_name: &str, attr: Attr) -> anyhow::Result<Self> {
|
pub fn create(name: &str, attr: Attr) -> anyhow::Result<Self> {
|
||||||
// TODO
|
// TODO
|
||||||
let now: DateTime<Local> = SystemTime::now().into();
|
let now: DateTime<Local> = SystemTime::now().into();
|
||||||
|
|
||||||
|
|
@ -168,7 +168,7 @@ impl DirEntry {
|
||||||
let create_time = Time::from_datetime(now)?;
|
let create_time = Time::from_datetime(now)?;
|
||||||
let create_time_tenths = (now.time().nanosecond() / 100_000_000) as u8;
|
let create_time_tenths = (now.time().nanosecond() / 100_000_000) as u8;
|
||||||
|
|
||||||
let name = [0; 11];
|
let mut name = [0; 11];
|
||||||
|
|
||||||
Ok(DirEntry {
|
Ok(DirEntry {
|
||||||
name,
|
name,
|
||||||
|
|
@ -183,12 +183,14 @@ impl DirEntry {
|
||||||
file_size: 0,
|
file_size: 0,
|
||||||
checksum: Self::checksum(&name),
|
checksum: Self::checksum(&name),
|
||||||
long_name: None,
|
long_name: None,
|
||||||
n_longname_slots: 0,
|
n_slots: 0,
|
||||||
offset: !0,
|
offset: !0,
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
fn write(&self, mut writer: impl Write) -> std::io::Result<()> {
|
fn write(&self, mut writer: impl Write) -> std::io::Result<()> {
|
||||||
|
assert_ne!(self.offset, !0);
|
||||||
|
|
||||||
let mut buf = [0; 32];
|
let mut buf = [0; 32];
|
||||||
|
|
||||||
buf[..11].copy_from_slice(self.name());
|
buf[..11].copy_from_slice(self.name());
|
||||||
|
|
@ -360,9 +362,8 @@ impl DirEntry {
|
||||||
self.long_name.as_deref()
|
self.long_name.as_deref()
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn set_long_name(&mut self, long_name: CompactString, n_slots: u8) {
|
pub fn set_long_name(&mut self, long_name: CompactString) {
|
||||||
self.long_name = Some(long_name);
|
self.long_name = Some(long_name);
|
||||||
self.n_longname_slots = n_slots;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn attr(&self) -> Attr {
|
pub fn attr(&self) -> Attr {
|
||||||
|
|
@ -712,7 +713,8 @@ impl Iterator for DirIter<'_> {
|
||||||
let long_filename: CompactString =
|
let long_filename: CompactString =
|
||||||
char::decode_utf16(iter).filter_map(|x| x.ok()).collect();
|
char::decode_utf16(iter).filter_map(|x| x.ok()).collect();
|
||||||
|
|
||||||
dir_entry.set_long_name(long_filename, n_slots);
|
dir_entry.set_long_name(long_filename);
|
||||||
|
dir_entry.n_slots = n_slots;
|
||||||
}
|
}
|
||||||
|
|
||||||
me.long_filename_buf.reset();
|
me.long_filename_buf.reset();
|
||||||
|
|
|
||||||
|
|
@ -173,7 +173,7 @@ impl<'a> ClusterChainWriter<'a> {
|
||||||
|
|
||||||
debug!("next cluster: {next_cluster}");
|
debug!("next cluster: {next_cluster}");
|
||||||
|
|
||||||
self.fat_fs.cluster_as_subslice_mut(next_cluster);
|
self.sub_slice = self.fat_fs.cluster_as_subslice_mut(next_cluster);
|
||||||
self.cur_cluster = next_cluster;
|
self.cur_cluster = next_cluster;
|
||||||
|
|
||||||
true
|
true
|
||||||
|
|
@ -207,13 +207,19 @@ impl<'a> ClusterChainWriter<'a> {
|
||||||
|
|
||||||
impl Write for ClusterChainWriter<'_> {
|
impl Write for ClusterChainWriter<'_> {
|
||||||
fn write(&mut self, buf: &[u8]) -> std::io::Result<usize> {
|
fn write(&mut self, buf: &[u8]) -> std::io::Result<usize> {
|
||||||
|
debug!("ClusterChainWriter: trying to write {} bytes...", buf.len());
|
||||||
|
|
||||||
if self.sub_slice.is_empty() {
|
if self.sub_slice.is_empty() {
|
||||||
|
debug!("sub_slice is empty, trying to advance...");
|
||||||
|
|
||||||
if !(self.move_to_next_cluster()) {
|
if !(self.move_to_next_cluster()) {
|
||||||
|
debug!("failed to move to next cluster, returning Ok(0)");
|
||||||
|
|
||||||
return Ok(0);
|
return Ok(0);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
self.sub_slice.write(buf)
|
dbg!(self.sub_slice.write(buf))
|
||||||
}
|
}
|
||||||
|
|
||||||
fn flush(&mut self) -> std::io::Result<()> {
|
fn flush(&mut self) -> std::io::Result<()> {
|
||||||
|
|
|
||||||
|
|
@ -355,8 +355,6 @@ impl Filesystem for FatFuse {
|
||||||
|
|
||||||
let flags = OpenFlags::from_bits_truncate(flags);
|
let flags = OpenFlags::from_bits_truncate(flags);
|
||||||
|
|
||||||
debug!("flags: {flags:?}");
|
|
||||||
|
|
||||||
let Some(inode) = self.get_inode(ino).cloned() else {
|
let Some(inode) = self.get_inode(ino).cloned() else {
|
||||||
debug!("inode {ino} not found");
|
debug!("inode {ino} not found");
|
||||||
|
|
||||||
|
|
@ -379,8 +377,6 @@ impl Filesystem for FatFuse {
|
||||||
debug!("fh {} was associated with ino {}, now with ino {}", fh, old_ino, ino);
|
debug!("fh {} was associated with ino {}, now with ino {}", fh, old_ino, ino);
|
||||||
}
|
}
|
||||||
|
|
||||||
debug!("opened inode {}: fh {}", ino, fh);
|
|
||||||
|
|
||||||
if flags.contains(OpenFlags::Truncate) {
|
if flags.contains(OpenFlags::Truncate) {
|
||||||
inode.update_size(0);
|
inode.update_size(0);
|
||||||
inode.update_mtime(SystemTime::now());
|
inode.update_mtime(SystemTime::now());
|
||||||
|
|
@ -443,8 +439,6 @@ impl Filesystem for FatFuse {
|
||||||
|
|
||||||
let file_size = inode.size();
|
let file_size = inode.size();
|
||||||
|
|
||||||
debug!("file_size: {}", file_size);
|
|
||||||
|
|
||||||
if offset > file_size {
|
if offset > file_size {
|
||||||
debug!("tried to read after EOF");
|
debug!("tried to read after EOF");
|
||||||
|
|
||||||
|
|
@ -480,7 +474,7 @@ impl Filesystem for FatFuse {
|
||||||
|
|
||||||
let mut buf = vec![0; size as usize];
|
let mut buf = vec![0; size as usize];
|
||||||
|
|
||||||
let bytes_read = match reader.read(&mut buf) {
|
match reader.read_exact(&mut buf) {
|
||||||
Ok(n) => n,
|
Ok(n) => n,
|
||||||
Err(err) => {
|
Err(err) => {
|
||||||
error!("error while reading: {err}");
|
error!("error while reading: {err}");
|
||||||
|
|
@ -489,13 +483,10 @@ impl Filesystem for FatFuse {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
if bytes_read != size as usize {
|
|
||||||
debug!("expected to read {size} bytes, but only read {bytes_read}");
|
|
||||||
}
|
|
||||||
|
|
||||||
inode.update_atime(SystemTime::now());
|
inode.update_atime(SystemTime::now());
|
||||||
|
|
||||||
reply.data(&buf[..bytes_read]);
|
reply.data(&buf);
|
||||||
|
|
||||||
// TODO: update access time
|
// TODO: update access time
|
||||||
}
|
}
|
||||||
|
|
@ -512,7 +503,7 @@ impl Filesystem for FatFuse {
|
||||||
_lock_owner: Option<u64>,
|
_lock_owner: Option<u64>,
|
||||||
reply: fuser::ReplyWrite,
|
reply: fuser::ReplyWrite,
|
||||||
) {
|
) {
|
||||||
debug!("new write request: ino={ino} fh={fh} offset={offset} data={data:?}");
|
debug!("new write request: ino={ino} fh={fh} offset={offset}"); // data={data:?}
|
||||||
|
|
||||||
if offset < 0 {
|
if offset < 0 {
|
||||||
debug!("tried to write with negative offset {offset}");
|
debug!("tried to write with negative offset {offset}");
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue