Skip to content

Conversation

mox692
Copy link
Member

@mox692 mox692 commented Sep 1, 2025

Add io-uring version of fs::write. I think the change itself is mostly straightforward. This PR might need to coordinate with #7547 regarding the usage of cfg.

Related issue: #7266

@mox692 mox692 added A-tokio Area: The main tokio crate M-fs Module: tokio/fs labels Sep 1, 2025
}

#[cfg(all(tokio_uring, feature = "rt", feature = "fs", target_os = "linux"))]
async fn write_uring(path: impl AsRef<Path>, mut buf: &[u8]) -> io::Result<()> {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would change both methods to take &Path and crate::util::as_ref::OwnedBuf, to avoid generics in the actual implementations.

Comment on lines +36 to +39
// SAFETY: `fd` and `buf` is valid until this future completes.
// If this operation is cancelled, drop of `Op` occurs before dropping
// `fd` or `buf`, ensuring the safety contract holds.
let op = unsafe { Op::new(sqe, Write) };
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This logic I don't buy. Using mem::forget on the future it's possible to cause UAF. Some form of ownership is required.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-tokio Area: The main tokio crate M-fs Module: tokio/fs
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants