[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <8734f8g4is.fsf@kernel.org>
Date: Wed, 19 Mar 2025 21:16:27 +0100
From: Andreas Hindborg <a.hindborg@...nel.org>
To: "Alice Ryhl" <aliceryhl@...gle.com>
Cc: "Greg Kroah-Hartman" <gregkh@...uxfoundation.org>, "Alexander Viro"
<viro@...iv.linux.org.uk>, "Arnd Bergmann" <arnd@...db.de>, "Miguel
Ojeda" <ojeda@...nel.org>, "Boqun Feng" <boqun.feng@...il.com>, "Gary
Guo" <gary@...yguo.net>, Björn Roy Baron
<bjorn3_gh@...tonmail.com>,
"Benno Lossin" <benno.lossin@...ton.me>, "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>
Subject: Re: [PATCH 3/5] rust: miscdevice: Provide additional abstractions
for iov_iter and kiocb structures
"Alice Ryhl" <aliceryhl@...gle.com> writes:
> These will be used for the read_iter() and write_iter() callbacks, which
> are now the preferred back-ends for when a user operates on a char device
> with read() and write() respectively.
>
> Co-developed-by: Lee Jones <lee@...nel.org>
> Signed-off-by: Lee Jones <lee@...nel.org>
> Signed-off-by: Alice Ryhl <aliceryhl@...gle.com>
[...]
> +impl<'a, T: ForeignOwnable> Kiocb<'a, T> {
> + /// Get the private data in this kiocb.
> + pub fn private_data(&self) -> <T as ForeignOwnable>::Borrowed<'a> {
> + // SAFETY: The `kiocb` lets us access the private data.
> + let private = unsafe { (*(*self.inner.as_ptr()).ki_filp).private_data };
> + // SAFETY: The kiocb has shared access to the private data.
> + unsafe { <T as ForeignOwnable>::borrow(private) }
> + }
Another quick observation: `kiocb` has a `void *private` field that is
used in the same way that `struct file` `private_data` field is used.
The naming of this function is misleading, since it does not return the
`kiocb` private data.
Either rename this function or exchange it for an access method for the
associated file.
Best regards,
Andreas Hindborg
Powered by blists - more mailing lists