xref: /DragonOS/user/apps/test-blockcache/src/main.rs (revision 4b0170bd6bb374d0e9699a0076cc23b976ad6db7)
1 use std::fs::File;
2 use std::io::{BufReader, Read, Seek, SeekFrom, Write};
3 
4 fn main() -> std::io::Result<()> {
5     let file_size_bytes: u64 = 512;
6     let mut file = File::create("large_file")?;
7     file.seek(std::io::SeekFrom::Start(file_size_bytes - 1))?;
8     file.write_all(&[0])?;
9     let mut file = File::open("large_file")?;
10     // let mut reader = BufReader::new(file);
11     let mut buffer = [0; 512];
12     let mut count = 0;
13     loop {
14         count += 1;
15         file.seek(SeekFrom::Start(0))?;
16         let bytes_read = file.read_exact(&mut buffer)?;
17         if count > 10000 {
18             break;
19         }
20     }
21     Ok(())
22 }
23