Rust support for `struct iov_iter`
Subsystems (3)
Alice Ryhl
reviewerv5 cover Rust support for `struct iov_iter`
This series adds support for the struct iov_iter type. This type represents an IO buffer for reading or writing, and can be configured for either direction of communication.
In Rust, we define separate types for reading and writing. This will ensure that you cannot mix them up and e.g. call copy_from_iter in a read_iter syscall.
To use the new abstractions, miscdevices are given new methods read_iter and write_iter that can be used to implement the read/write syscalls on a miscdevice. The miscdevice sample is updated to provide read/write operations.
Intended for Greg's miscdevice tree.
---
Changes in v5:
- Reword "struct invariants" to "type invariants"
- Reword inc_len safety comment.
- Split Kiocb into separate patch.
- Link to v4: https://lore.kernel.org/r/[email protected]
Changes in v4:
- Rebase on v6.17-rc1. No longer any dependencies.
- Adjust wording of revert safety comment.
- Adjust "deinitialize" wording to "write uninitialized".
- Adjust several comments' wording in rust/kernel/fs/kiocb.rs.
- Link to v3: https://lore.kernel.org/r/[email protected]
Changes in v3:
- Rebase on rust-next.
- Use ptr::from_mut to silence warning.
- Move Kiocb to rust::fs.
- Rename Kiocb::device() to Kiocb::file() as it's no longer miscdevice specific.
- Significant rewording of docs and safety comments, especially patch 1 and 2.
- Link to v2: https://lore.kernel.org/r/[email protected]
Changes in v2:
- Remove Send/Sync/Copy impls.
- Reword docs significantly.
- Rename Kiocb::private_data() to Kiocb::device().
- Rebase on v6.16-rc2.
- Link to v1: https://lore.kernel.org/r/[email protected]
---
Alice Ryhl (4):
rust: iov: add iov_iter abstractions for ITER_SOURCE
rust: iov: add iov_iter abstractions for ITER_DEST
rust: fs: add Kiocb struct
rust: miscdevice: Provide additional abstractions for iov_iter and kiocb structures
Lee Jones (1):
samples: rust_misc_device: Expand the sample to support read()ing from userspace
rust/kernel/fs.rs | 3 + rust/kernel/fs/kiocb.rs | 68 +++++++++ rust/kernel/iov.rs | 314 +++++++++++++++++++++++++++++++++++++++ rust/kernel/lib.rs | 1 + rust/kernel/miscdevice.rs | 63 +++++++- samples/rust/rust_misc_device.rs | 36 ++++- 6 files changed, 482 insertions(+), 3 deletions(-)
---
base-commit: 062b3e4a1f880f104a8d4b90b767788786aa7b78
change-id: 20250311-iov-iter-c984aea07d18
Best regards,
Signature · 1 line
Alice Ryhl <[email protected]>
Alice Ryhl
reviewerPATCH v5 1/5 rust: iov: add iov_iter abstractions for ITER_SOURCE
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.
--- rust/kernel/iov.rs | 171 +++++++++++++++++++++++++++++++++++++++++++++++++++++ rust/kernel/lib.rs | 1 + 2 files changed, 172 insertions(+)
rust/kernel/iov.rs new file +171 -0
@@ -0,0 +1,171 @@ +// SPDX-License-Identifier: GPL-2.0 + +// Copyright (C) 2025 Google LLC. + +//! IO vectors. +//! +//! C headers: [`include/linux/iov_iter.h`](srctree/include/linux/iov_iter.h), +//! [`include/linux/uio.h`](srctree/include/linux/uio.h) + +use crate ::{ + alloc::{Allocator ,Flags }, + bindings, + prelude::*, + types::Opaque , +}; +use core::{marker::PhantomData , mem::MaybeUninit , ptr, slice}; + +const ITER_SOURCE :bool = bindings::ITER_SOURCE !=0 ; + +/// An IO vector that acts as a source of data. +/// +/// The data may come from many different sources. This includes both things in kernel-space and +/// reading from userspace. It's not necessarily the case that the data source is immutable, so +/// rewinding the IO vector to read the same data twice is not guaranteed to result in the same +/// bytes. It's also possible that the data source is mapped in a thread-local manner using e.g. +/// `kmap_local_page()`, so this type is not `Send` to ensure that the mapping is read from the +/// right context in that scenario. +/// +/// # Invariants +/// +/// Must hold a valid `struct iov_iter` with `data_source` set to `ITER_SOURCE`. For the duration +/// of `'data`, it must be safe to read from this IO vector using the standard C methods for this +/// purpose. +#[repr(transparent)] +pub struct IovIterSource <'data> { + iov:Opaque <bindings::iov_iter >, +/// Represent to the type system that this value contains a pointer to readable data it does +/// not own. + _source:PhantomData <&'data [u8 ]>, +} + +impl <'data>IovIterSource <'data> { +/// Obtain an `IovIterSource` from a raw pointer. +/// +/// # Safety +/// +/// * The referenced `struct iov_iter` must be valid and must only be accessed through the +/// returned reference for the duration of `'iov`. +/// * The referenced `struct iov_iter` must have `data_source` set to `ITER_SOURCE`. +/// * For the duration of `'data`, it must be safe to read from this IO vector using the +/// standard C methods for this purpose. +#[track_caller] +#[inline] +pub unsafe fn from_raw <'iov>(ptr: *mut bindings::iov_iter ) -> &'iovmut IovIterSource <'data> { +// SAFETY: The caller ensures that `ptr` is valid. +let data_source =unsafe { (*ptr).data_source }; +assert_eq! (data_source,ITER_SOURCE ); + +// SAFETY: The caller ensures the type invariants for the right durations, and +// `IovIterSource` is layout compatible with `struct iov_iter`. +unsafe { &mut *ptr.cast ::<IovIterSource <'data>>() } + } + +/// Access this as a raw `struct iov_iter`. +#[inline] +pub fn as_raw (&mut self) -> *mut bindings::iov_iter { + self.iov.get () + } + +/// Returns the number of bytes available in this IO vector. +/// +/// Note that this may overestimate the number of bytes. For example, reading from userspace +/// memory could fail with `EFAULT`, which will be treated as the end of the IO vector. +#[inline] +pub fn len (&self) ->usize { +// SAFETY: We have shared access to this IO vector, so we can read its `count` field. +unsafe { + (*self.iov.get ()) + .__bindgen_anon_1 + .__bindgen_anon_1 + .as_ref () + .count + } + } + +/// Returns whether there are any bytes left in this IO vector. +/// +/// This may return `true` even if there are no more bytes available. For example, reading from +/// userspace memory could fail with `EFAULT`, which will be treated as the end of the IO vector. +#[inline] +pub fn is_empty (&self) ->bool { + self.len () ==0 + } + +/// Advance this IO vector by `bytes` bytes. +/// +/// If `bytes` is larger than the size of this IO vector, it is advanced to the end. +#[inline] +pub fn advance (&mut self, bytes:usize ) { +// SAFETY: By the type invariants, `self.iov` is a valid IO vector. +unsafe { bindings::iov_iter_advance (self.as_raw (), bytes) }; + } + +/// 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 type invariants, `self.iov` is a valid IO vector, and the caller +// ensures that `bytes` is in bounds. +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 write any uninitialized +// bytes in the provided buffer, so `out` is still a valid `u8` slice after this call. +let out =unsafe { &mut *(ptr::from_mut (out)as *mut [MaybeUninit <u8 >]) }; + + self.copy_from_iter_raw (out).len () + } + +/// Read data from this IO vector and append it to a vector. +/// +/// Returns the number of bytes that have been copied. +#[inline] +pub fn copy_from_iter_vec <A :Allocator >( + &mut self, + out: &mut Vec <u8 ,A >, + flags:Flags , + ) ->Result <usize > { + out.reserve (self.len (), flags)?; +let len = self.copy_from_iter_raw (out.spare_capacity_mut ()).len (); +// SAFETY: +// - `len` is the length of a subslice of the spare capacity, so `len` is at most the +// length of the spare capacity. +// - `Self::copy_from_iter_raw` guarantees that the first `len` bytes of the spare capacity +// have been initialized. +unsafe { out.inc_len (len) }; +Ok (len) + } + +/// Read data from this IO vector into potentially uninitialized memory. +/// +/// Returns the sub-slice of the output that has been initialized. If the returned slice is +/// shorter than the input buffer, then the entire IO vector has been read. +/// +/// This will never write uninitialized bytes to the provided buffer. +#[inline] +pub fn copy_from_iter_raw (&mut self, out: &mut [MaybeUninit <u8 >]) -> &mut [u8 ] { +let capacity = out.len (); +let out = out.as_mut_ptr ().cast ::<u8 >(); + +// GUARANTEES: The C API guarantees that it does not write uninitialized bytes to the +// provided buffer. +// SAFETY: +// * By the type invariants, it is still valid to read from this IO vector. +// * `out` is valid for writing for `capacity` bytes because it comes from a slice of +// that length. +let len =unsafe { bindings::_copy_from_iter (out.cast (), capacity, self.as_raw ()) }; + +// SAFETY: The underlying C api guarantees that initialized bytes have been written to the +// first `len` bytes of the spare capacity. +unsafe { slice::from_raw_parts_mut (out, len) } + } +}
rust/kernel/lib.rs +1 -0
@@ -92,6 +92,7 @@pub mod init;pub mod io;pub mod ioctl; +pub mod iov;pub mod jump_label;#[cfg( CONFIG_KUNIT )] pub mod kunit;
Signature · 1 line
2.51.0.rc2.233.g662b1ed5c5-goog
Alice Ryhl
reviewerPATCH v5 2/5 rust: iov: add iov_iter abstractions for ITER_DEST
In reply to Alice RyhlThis adds abstractions for the iov_iter type in the case where data_source is ITER_DEST. This will make Rust implementations of fops->read_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.
This patch adds an IovIterDest struct that is very similar to the IovIterSource from the previous patch. However, as the methods on the two structs have very little overlap (just getting the length and advance/revert), I do not think it is worth it to try and deduplicate this logic.
--- rust/kernel/iov.rs | 143 +++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 143 insertions(+)
rust/kernel/iov.rs +143 -0
@@ -16,6 +16,15 @@use core::{marker::PhantomData , mem::MaybeUninit , ptr, slice};const ITER_SOURCE :bool = bindings::ITER_SOURCE !=0 ; +const ITER_DEST :bool = bindings::ITER_DEST !=0 ; + +// Compile-time assertion for the above constants. +const _: () = { +build_assert! ( +ITER_SOURCE !=ITER_DEST , +"ITER_DEST and ITER_SOURCE should be different." + ); +};/// An IO vector that acts as a source of data. ///
@@ -169,3 +178,137 @@ pub fn copy_from_iter_raw(&mut self, out: &mut [MaybeUninit<u8>]) -> &mut [u8] {unsafe { slice::from_raw_parts_mut (out, len) } } } + +/// An IO vector that acts as a destination for data. +/// +/// IO vectors support many different types of destinations. This includes both buffers in +/// kernel-space and writing to userspace. It's possible that the destination buffer is mapped in a +/// thread-local manner using e.g. `kmap_local_page()`, so this type is not `Send` to ensure that +/// the mapping is written to the right context in that scenario. +/// +/// # Invariants +/// +/// Must hold a valid `struct iov_iter` with `data_source` set to `ITER_DEST`. For the duration of +/// `'data`, it must be safe to write to this IO vector using the standard C methods for this +/// purpose. +#[repr(transparent)] +pub struct IovIterDest <'data> { + iov:Opaque <bindings::iov_iter >, +/// Represent to the type system that this value contains a pointer to writable data it does +/// not own. + _source:PhantomData <&'datamut [u8 ]>, +} + +impl <'data>IovIterDest <'data> { +/// Obtain an `IovIterDest` from a raw pointer. +/// +/// # Safety +/// +/// * The referenced `struct iov_iter` must be valid and must only be accessed through the +/// returned reference for the duration of `'iov`. +/// * The referenced `struct iov_iter` must have `data_source` set to `ITER_DEST`. +/// * For the duration of `'data`, it must be safe to write to this IO vector using the +/// standard C methods for this purpose. +#[track_caller] +#[inline] +pub unsafe fn from_raw <'iov>(ptr: *mut bindings::iov_iter ) -> &'iovmut IovIterDest <'data> { +// SAFETY: The caller ensures that `ptr` is valid. +let data_source =unsafe { (*ptr).data_source }; +assert_eq! (data_source,ITER_DEST ); + +// SAFETY: The caller ensures the type invariants for the right durations, and +// `IovIterSource` is layout compatible with `struct iov_iter`. +unsafe { &mut *ptr.cast ::<IovIterDest <'data>>() } + } + +/// Access this as a raw `struct iov_iter`. +#[inline] +pub fn as_raw (&mut self) -> *mut bindings::iov_iter { + self.iov.get () + } + +/// Returns the number of bytes available in this IO vector. +/// +/// Note that this may overestimate the number of bytes. For example, reading from userspace +/// memory could fail with EFAULT, which will be treated as the end of the IO vector. +#[inline] +pub fn len (&self) ->usize { +// SAFETY: We have shared access to this IO vector, so we can read its `count` field. +unsafe { + (*self.iov.get ()) + .__bindgen_anon_1 + .__bindgen_anon_1 + .as_ref () + .count + } + } + +/// Returns whether there are any bytes left in this IO vector. +/// +/// This may return `true` even if there are no more bytes available. For example, reading from +/// userspace memory could fail with EFAULT, which will be treated as the end of the IO vector. +#[inline] +pub fn is_empty (&self) ->bool { + self.len () ==0 + } + +/// Advance this IO vector by `bytes` bytes. +/// +/// If `bytes` is larger than the size of this IO vector, it is advanced to the end. +#[inline] +pub fn advance (&mut self, bytes:usize ) { +// SAFETY: By the type invariants, `self.iov` is a valid IO vector. +unsafe { bindings::iov_iter_advance (self.as_raw (), bytes) }; + } + +/// 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 type invariants, `self.iov` is a valid IO vector, and the caller +// ensures that `bytes` is in bounds. +unsafe { bindings::iov_iter_revert (self.as_raw (), bytes) }; + } + +/// Write data to this IO vector. +/// +/// Returns the number of bytes that were written. If this is shorter than the provided slice, +/// then no more bytes can be written. +#[inline] +pub fn copy_to_iter (&mut self, input: &[u8 ]) ->usize { +// SAFETY: +// * By the type invariants, it is still valid to write to this IO vector. +// * `input` is valid for `input.len()` bytes. +unsafe { bindings::_copy_to_iter (input.as_ptr ().cast (), input.len (), self.as_raw ()) } + } + +/// Utility for implementing `read_iter` given the full contents of the file. +/// +/// The full contents of the file being read from is represented by `contents`. This call will +/// write the appropriate sub-slice of `contents` and update the file position in `ppos` so +/// that the file will appear to contain `contents` even if takes multiple reads to read the +/// entire file. +#[inline] +pub fn simple_read_from_buffer (&mut self, ppos: &mut i64 , contents: &[u8 ]) ->Result <usize > { +if *ppos <0 { +return Err (EINVAL ); + } +let Ok (pos) = usize::try_from (*ppos)else { +return Ok (0 ); + }; +if pos >= contents.len () { +return Ok (0 ); + } + +// BOUNDS: We just checked that `pos < contents.len()` above. +let num_written = self.copy_to_iter (&contents[pos..]); + +// OVERFLOW: `pos+num_written <= contents.len() <= isize::MAX <= i64::MAX`. + *ppos = (pos + num_written)as i64 ; + +Ok (num_written) + } +}
Signature · 1 line
2.51.0.rc2.233.g662b1ed5c5-goog
Alice Ryhl
reviewerPATCH v5 3/5 rust: fs: add Kiocb struct
In reply to Alice RyhlThis adds a very simple Kiocb struct that lets you access the inner file's private data and the file position. For now, nothing else is supported.
--- rust/kernel/fs.rs | 3 +++ rust/kernel/fs/kiocb.rs | 68 +++++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 71 insertions(+)
rust/kernel/fs.rs +3 -0
@@ -6,3 +6,6 @@pub mod file;pub use self::file::{File ,LocalFile }; + +mod kiocb; +pub use self::kiocb::Kiocb ;
rust/kernel/fs/kiocb.rs new file +68 -0
68 lines not on this page · raw message
Signature · 1 line
2.51.0.rc2.233.g662b1ed5c5-goog
Alice Ryhl
reviewerPATCH v5 4/5 rust: miscdevice: Provide additional abstractions for iov_iter and kiocb structures
In reply to Alice RyhlThese 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.
--- rust/kernel/miscdevice.rs | 63 ++++++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 62 insertions(+), 1 deletion(-)
rust/kernel/miscdevice.rs +62 -1
@@ -13,7 +13,8 @@ device::Device, error::{to_result, Error, Result, VTABLE_DEFAULT_ERROR}, ffi::{c_int, c_long, c_uint, c_ulong}, - fs::File, + fs::{File, Kiocb}, + iov::{IovIterDest, IovIterSource}, mm::virt::VmaNew, prelude::*, seq_file::SeqFile,
@@ -141,6 +142,16 @@ fn mmap(build_error! (VTABLE_DEFAULT_ERROR ) } +/// Read from this miscdevice. +fn read_iter (_kiocb:Kiocb <'_,Self ::Ptr >, _iov: &mut IovIterDest <'_>) ->Result <usize > { +build_error! (VTABLE_DEFAULT_ERROR ) + } + +/// Write to this miscdevice. +fn write_iter (_kiocb:Kiocb <'_,Self ::Ptr >, _iov: &mut IovIterSource <'_>) ->Result <usize > { +build_error! (VTABLE_DEFAULT_ERROR ) + } +/// Handler for ioctls. /// /// The `cmd` argument is usually manipulated using the utilities in [`kernel::ioctl`].
@@ -245,6 +256,46 @@ impl<T: MiscDevice> MiscdeviceVTable<T> {0 } +/// # Safety +/// +/// `kiocb` must be correspond to a valid file that is associated with a +/// `MiscDeviceRegistration<T>`. `iter` must be a valid `struct iov_iter` for writing. +unsafe extern "C" fn read_iter ( + kiocb: *mut bindings::kiocb , + iter: *mut bindings::iov_iter , + ) ->isize { +// SAFETY: The caller provides a valid `struct kiocb` associated with a +// `MiscDeviceRegistration<T>` file. +let kiocb =unsafe {Kiocb ::from_raw (kiocb) }; +// SAFETY: This is a valid `struct iov_iter` for writing. +let iov =unsafe {IovIterDest ::from_raw (iter) }; + +match T ::read_iter (kiocb, iov) { +Ok (res) => resas isize , +Err (err) => err.to_errno ()as isize , + } + } + +/// # Safety +/// +/// `kiocb` must be correspond to a valid file that is associated with a +/// `MiscDeviceRegistration<T>`. `iter` must be a valid `struct iov_iter` for writing. +unsafe extern "C" fn write_iter ( + kiocb: *mut bindings::kiocb , + iter: *mut bindings::iov_iter , + ) ->isize { +// SAFETY: The caller provides a valid `struct kiocb` associated with a +// `MiscDeviceRegistration<T>` file. +let kiocb =unsafe {Kiocb ::from_raw (kiocb) }; +// SAFETY: This is a valid `struct iov_iter` for reading. +let iov =unsafe {IovIterSource ::from_raw (iter) }; + +match T ::write_iter (kiocb, iov) { +Ok (res) => resas isize , +Err (err) => err.to_errno ()as isize , + } + } +/// # Safety /// /// `file` must be a valid file that is associated with a `MiscDeviceRegistration<T>`.
@@ -341,6 +392,16 @@ impl<T: MiscDevice> MiscdeviceVTable<T> { open: Some(Self::open), release: Some(Self::release), mmap: if T::HAS_MMAP { Some(Self::mmap) } else { None }, + read_iter: if T::HAS_READ_ITER { +Some (Self ::read_iter) + }else { +None + }, + write_iter: if T::HAS_WRITE_ITER { +Some (Self ::write_iter) + }else { +None + }, unlocked_ioctl: if T::HAS_IOCTL {Some (Self ::ioctl) }else {
Signature · 1 line
2.51.0.rc2.233.g662b1ed5c5-goog
Alice Ryhl
reviewerPATCH v5 5/5 samples: rust_misc_device: Expand the sample to support read()ing from userspace
In reply to Alice RyhlFrom: Lee Jones <[email protected]>
A userland application can now operate on the char device with read() in order to consume a locally held buffer. Memory for the buffer is to be provisioned and the buffer populated in its subsequently provided write() counterpart.
--- samples/rust/rust_misc_device.rs | 36 ++++++++++++++++++++++++++++++++++-- 1 file changed, 34 insertions(+), 2 deletions(-)
samples/rust/rust_misc_device.rs +34 -2
@@ -100,8 +100,9 @@use kernel::{ c_str, device::Device , - fs::File , + fs::{File ,Kiocb }, ioctl::{_IO, _IOC_SIZE, _IOR, _IOW}, + iov::{IovIterDest ,IovIterSource }, miscdevice::{MiscDevice ,MiscDeviceOptions ,MiscDeviceRegistration }, new_mutex, prelude::*,
@@ -144,6 +145,7 @@ fn init(_module: &'static ThisModule) -> impl PinInit<Self, Error> {struct Inner { value:i32 , + buffer:KVVec <u8 >, }#[pin_data( PinnedDrop )]
@@ -165,7 +167,10 @@ fn open(_file: &File, misc: &MiscDeviceRegistration<Self>) -> Result<Pin<KBox<SeKBox ::try_pin_init (try_pin_init! {RustMiscDevice { - inner <-new_mutex! (Inner { value:0_i32 } ), + inner <-new_mutex! (Inner { + value:0_i32 , + buffer:KVVec ::new (), + }), dev: dev, } },
@@ -173,6 +178,33 @@ fn open(_file: &File, misc: &MiscDeviceRegistration<Self>) -> Result<Pin<KBox<Se ) } +fn read_iter (mut kiocb:Kiocb <'_,Self ::Ptr >, iov: &mut IovIterDest <'_>) ->Result <usize > { +let me = kiocb.file (); +dev_info! (me.dev,"Reading from Rust Misc Device Sample\n" ); + +let inner = me.inner.lock (); +// Read the buffer contents, taking the file position into account. +let read = iov.simple_read_from_buffer (kiocb.ki_pos_mut (), &inner.buffer)?; + +Ok (read) + } + +fn write_iter (mut kiocb:Kiocb <'_,Self ::Ptr >, iov: &mut IovIterSource <'_>) ->Result <usize > { +let me = kiocb.file (); +dev_info! (me.dev,"Writing to Rust Misc Device Sample\n" ); + +let mut inner = me.inner.lock (); + +// Replace buffer contents. + inner.buffer.clear (); +let len = iov.copy_from_iter_vec (&mut inner.buffer,GFP_KERNEL )?; + +// Set position to zero so that future `read` calls will see the new contents. + *kiocb.ki_pos_mut () =0 ; + +Ok (len) + } +fn ioctl (me:Pin <&RustMiscDevice >, _file: &File , cmd:u32 , arg:usize ) ->Result <isize > {dev_info! (me.dev,"IOCTLing Rust Misc Device Sample\n" );
Signature · 1 line
2.51.0.rc2.233.g662b1ed5c5-goog
Greg Kroah-Hartman
maintainerQuoted 13 lines · Alice Ryhl
This series adds support for the
struct iov_itertype. This type represents an IO buffer for reading or writing, and can be configured for either direction of communication.In Rust, we define separate types for reading and writing. This will ensure that you cannot mix them up and e.g. call
copy_from_iterin aread_itersyscall.To use the new abstractions, miscdevices are given new methods
read_iterandwrite_iterthat can be used to implement the read/write syscalls on a miscdevice. The miscdevice sample is updated to provide read/write operations.
Quoted 4 lines
Intended for Greg's miscdevice tree.
Signed-off-by Alice Ryhl <[email protected]>---
Now queued up, thanks.
greg k-h