[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <871ppq9fve.fsf@kernel.org>
Date: Tue, 05 Aug 2025 13:17:57 +0200
From: Andreas Hindborg <a.hindborg@...nel.org>
To: Alice Ryhl <aliceryhl@...gle.com>, Greg Kroah-Hartman
<gregkh@...uxfoundation.org>, Alexander Viro <viro@...iv.linux.org.uk>,
Arnd Bergmann <arnd@...db.de>, Miguel Ojeda <ojeda@...nel.org>
Cc: Boqun Feng <boqun.feng@...il.com>, Gary Guo <gary@...yguo.net>,
Björn
Roy Baron <bjorn3_gh@...tonmail.com>, Trevor Gross <tmgross@...ch.edu>,
Danilo Krummrich <dakr@...nel.org>, Matthew Maurer <mmaurer@...gle.com>,
Lee Jones <lee@...nel.org>, linux-kernel@...r.kernel.org,
rust-for-linux@...r.kernel.org, Alice
Ryhl <aliceryhl@...gle.com>, Benno Lossin <lossin@...nel.org>
Subject: Re: [PATCH v3 1/4] rust: iov: add iov_iter abstractions for
ITER_SOURCE
"Alice Ryhl" <aliceryhl@...gle.com> writes:
> This adds abstractions for the iov_iter type in the case where
> data_source is ITER_SOURCE. This will make Rust implementations of
> fops->write_iter possible.
>
> This series only has support for using existing IO vectors created by C
> code. Additional abstractions will be needed to support the creation of
> IO vectors in Rust code.
>
> These abstractions make the assumption that `struct iov_iter` does not
> have internal self-references, which implies that it is valid to move it
> between different local variables.
>
> Signed-off-by: Alice Ryhl <aliceryhl@...gle.com>
> ---
..
> +
> + /// Advance this IO vector backwards by `bytes` bytes.
> + ///
> + /// # Safety
> + ///
> + /// The IO vector must not be reverted to before its beginning.
> + #[inline]
> + pub unsafe fn revert(&mut self, bytes: usize) {
> + // SAFETY: By the struct invariants, `self.iov` is a valid IO vector, and `bytes` is in
> + // bounds.
"... and by method safety requirements `bytes` is in bounds", right?
> + unsafe { bindings::iov_iter_revert(self.as_raw(), bytes) };
> + }
> +
> + /// Read data from this IO vector.
> + ///
> + /// Returns the number of bytes that have been copied.
> + #[inline]
> + pub fn copy_from_iter(&mut self, out: &mut [u8]) -> usize {
> + // SAFETY: `Self::copy_from_iter_raw` guarantees that it will not deinitialize any bytes in
> + // the provided buffer, so `out` is still a valid `u8` slice after this call.
I am curious if there is a particular reason you chose "deinitialize"
over "write uninitialized" for the wording throughout this patch? It's
an unfamiliar phrasing to me.
Reviewed-by: Andreas Hindborg <a.hindborg@...nel.org>
Best regards,
Andreas Hindborg
Powered by blists - more mailing lists