readahead_file/
readahead_file.rs1use coreshift_core::fs::readahead;
2use std::fs::File;
3use std::io::{Error, ErrorKind};
4
5fn main() -> Result<(), Box<dyn std::error::Error>> {
6 let path = std::env::args()
7 .nth(1)
8 .ok_or_else(|| Error::new(ErrorKind::InvalidInput, "usage: readahead_file <path>"))?;
9 let file = File::open(&path)?;
10 let len = file.metadata()?.len().min(128 * 1024) as usize;
11
12 readahead(file, 0, len)?;
13 println!("Requested readahead for {} bytes from {}", len, path);
14
15 Ok(())
16}