Skip to content
Snippets Groups Projects
Unverified Commit 92d38e32 authored by Ian Douglas Scott's avatar Ian Douglas Scott
Browse files

fuse: Fix readdir when directory does not fit in buffer

parent e635648e
No related branches found
No related tags found
No related merge requests found
......@@ -197,20 +197,32 @@ impl Filesystem for Fuse {
let mut children = Vec::new();
match self.fs.child_nodes(&mut children, parent_block) {
Ok(()) => {
let mut i;
let skip;
if offset == 0 {
let mut i = 0;
skip = 0;
i = 0;
reply.add(parent_block - self.fs.header.0, i, FileType::Directory, ".");
i += 1;
reply.add(parent_block - self.fs.header.0, i, FileType::Directory, "..");
i += 1;
for child in children.iter() {
reply.add(child.0 - self.fs.header.0, i, if child.1.is_dir() {
FileType::Directory
} else {
FileType::RegularFile
}, child.1.name().unwrap());
i += 1;
} else {
i = offset + 1;
skip = offset as usize - 1;
}
for child in children.iter().skip(skip) {
let full = reply.add(child.0 - self.fs.header.0, i, if child.1.is_dir() {
FileType::Directory
} else {
FileType::RegularFile
}, child.1.name().unwrap());
if full {
break;
}
i += 1;
}
reply.ok();
},
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment