From 443b3c8f0b99086ead83f96c87d161341d05aa45 Mon Sep 17 00:00:00 2001 From: Joe Thornber Date: Wed, 2 Dec 2020 15:20:14 +0000 Subject: [PATCH] [io_engine (rust)] get_nr_blocks() wasn't handling block devices. Now calls file_utils::file_size() --- src/io_engine.rs | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/io_engine.rs b/src/io_engine.rs index 45f0d77..baecae2 100644 --- a/src/io_engine.rs +++ b/src/io_engine.rs @@ -11,6 +11,8 @@ use std::os::unix::io::{AsRawFd, RawFd}; use std::path::Path; use std::sync::{Arc, Condvar, Mutex}; +use crate::file_utils; + //------------------------------------------ pub const BLOCK_SIZE: usize = 4096; @@ -62,8 +64,7 @@ pub trait IoEngine { } fn get_nr_blocks(path: &Path) -> io::Result { - let metadata = std::fs::metadata(path)?; - Ok(metadata.len() / (BLOCK_SIZE as u64)) + Ok(file_utils::file_size(path)? / (BLOCK_SIZE as u64)) } //------------------------------------------