Is it possible, perhaps in some hacky way, to access files opened with O_DIRECT
in tokio-uring
?
Yes, you can do this on Linux (the only platform where uring is available) using std::os::unix::fs::OpenOptionsExt . For example code using O_DIRECT
see this earlier discussion:
What platform (target) are you building? It is not present on MacOS as @parasyte said. Search for F_NOCACHE to see how to bypass the fs cache on MacOS (I haven't tried it).
Even on Linux it must be set in FileOptions using a platform specific OpenOptionsExt.
#[cfg(unix)]
pub mod file {
use std::fs::OpenOptions;
use std::os::unix::fs::OpenOptionsExt;
pub fn open_direct(opts: &mut OpenOptions) -> &mut OpenOptions {
opts.custom_flags(libc::O_DIRECT)
}
}
playground