From 4af64e157a7bd1daf34a2ea838abe66de9904546 Mon Sep 17 00:00:00 2001 From: Wildan M Date: Tue, 23 Sep 2025 23:34:26 +0700 Subject: [PATCH] Allow partial result of getdents --- src/mount/redox/resource.rs | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/src/mount/redox/resource.rs b/src/mount/redox/resource.rs index 58f282944e..fc205cc1ed 100644 --- a/src/mount/redox/resource.rs +++ b/src/mount/redox/resource.rs @@ -251,9 +251,10 @@ impl Resource for DirResource { ) -> Result> { match &self.data { Some(data) => { - for (idx, entry) in data.iter().enumerate().skip(opaque_offset as usize) { + let opaque_offset = opaque_offset as usize; + for (idx, entry) in data.iter().enumerate().skip(opaque_offset) { let child = tx.read_tree(entry.node_ptr)?; - buf.entry(DirEntry { + let result = buf.entry(DirEntry { inode: child.id() as u64, next_opaque_id: idx as u64 + 1, name: &entry.name, @@ -264,7 +265,15 @@ impl Resource for DirResource { //TODO: more types? _ => DirentKind::Unspecified, }, - })?; + }); + if let Err(err) = result { + if err.errno == EINVAL && idx > opaque_offset { + // POSIX allows partial result of getdents + break; + } else { + return Err(err); + } + } } Ok(buf) }