Yet more stuff. Direct IO is not working at all.

This commit is contained in:
Cutieguwu
2025-12-31 20:48:51 -05:00
parent 2da0ab11e5
commit 7537107144
4 changed files with 31 additions and 17 deletions

View File

@@ -1,5 +1,6 @@
use std::fs::{File, OpenOptions};
use std::io::{self, Seek, SeekFrom};
use std::os::unix::fs::{FileExt, OpenOptionsExt};
use crate::cli::CONFIG;
@@ -22,8 +23,18 @@ pub fn get_stream_length<S: Seek>(stream: &mut S) -> io::Result<u64> {
pub fn load_input() -> anyhow::Result<File> {
OpenOptions::new()
.read(true)
//.custom_flags(libc::O_DIRECT)
.open(&CONFIG.input)
.with_context(|| format!("Failed to open input file: {}", &CONFIG.input.display()))
/*
use std::ffi::CString;
use std::os::fd::FromRawFd;
let path = CString::new(CONFIG.input.to_str().unwrap().to_owned()).unwrap();
let flags = libc::O_DIRECT | libc::O_RDONLY;
let f = unsafe { File::from_raw_fd(libc::open(path.as_ptr(), flags)) };
*/
}
pub fn load_output() -> anyhow::Result<File> {
@@ -40,16 +51,10 @@ pub fn load_output() -> anyhow::Result<File> {
})
}
pub fn load_map_read() -> anyhow::Result<File> {
pub fn load_map_read() -> std::io::Result<File> {
OpenOptions::new()
.read(true)
.open(crate::path::MAP_PATH.clone())
.with_context(|| {
format!(
"Failed to open/create mapping file at: {}",
crate::path::MAP_PATH.display()
)
})
}
pub fn load_map_write() -> anyhow::Result<File> {