Do not send zero-byte reads to the underlying device
This commit is contained in:
parent
5284fcd6d1
commit
cfb3fb0aca
@ -36,6 +36,9 @@ impl file_rpc::Server for Serv {
|
||||
fn read(&self, fd: u64, pos: u64, len: usize) -> Result<Vec<u8>, ()> {
|
||||
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();
|
||||
|
Loading…
Reference in New Issue
Block a user