From cfb3fb0aca584f62e756133d2df9a76cc092db84 Mon Sep 17 00:00:00 2001 From: pjht Date: Tue, 18 Jun 2024 20:55:58 -0500 Subject: [PATCH] Do not send zero-byte reads to the underlying device --- src/main.rs | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/main.rs b/src/main.rs index b0b90a9..6fbeade 100644 --- a/src/main.rs +++ b/src/main.rs @@ -36,6 +36,9 @@ impl file_rpc::Server for Serv { fn read(&self, fd: u64, pos: u64, len: usize) -> Result, ()> { let (mount_id, file_offset, size) = self.files.read()[fd as usize]; let read_len = usize::min(len, size - (pos as usize)); + if read_len == 0 { + return Ok(Vec::new()); + }; let mounts = self.mounts.read(); let mount = &mounts[mount_id as usize]; (&mount.0).seek(std::io::SeekFrom::Start(file_offset + pos)).unwrap();