rust-for-linux.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH rust-next 0/2] Add llseek support to miscdevice and samples
@ 2025-08-18 13:58 Ryosuke Yasuoka
  2025-08-18 13:58 ` [PATCH rust-next 1/2] rust: miscdevice: add llseek support Ryosuke Yasuoka
                   ` (2 more replies)
  0 siblings, 3 replies; 11+ messages in thread
From: Ryosuke Yasuoka @ 2025-08-18 13:58 UTC (permalink / raw)
  To: arnd, gregkh, ojeda, alex.gaynor, boqun.feng, gary, bjorn3_gh,
	lossin, a.hindborg, aliceryhl, tmgross, dakr, lee
  Cc: Ryosuke Yasuoka, rust-for-linux, linux-kernel

This patch series introduces support for the llseek file operation to
the Rust miscdevice abstraction.

The first patch, rust: miscdevice: add llseek support, extends the
MiscDevice trait with a new llseek method.

The second patch, rust: samples: miscdevice: add lseek samples, add a
simple example of how to use the new llseek feature. As currently the
MiscDevice trait does not support any read/write file operation yet, the
sample is fundamental one. 

Ryosuke Yasuoka (2):
  rust: miscdevice: add llseek support
  rust: samples: miscdevice: add lseek samples

 rust/kernel/miscdevice.rs        | 36 +++++++++++++++++
 samples/rust/rust_misc_device.rs | 68 ++++++++++++++++++++++++++++++++
 2 files changed, 104 insertions(+)


base-commit: 8f5ae30d69d7543eee0d70083daf4de8fe15d585
-- 
2.50.1


^ permalink raw reply	[flat|nested] 11+ messages in thread

* [PATCH rust-next 1/2] rust: miscdevice: add llseek support
  2025-08-18 13:58 [PATCH rust-next 0/2] Add llseek support to miscdevice and samples Ryosuke Yasuoka
@ 2025-08-18 13:58 ` Ryosuke Yasuoka
  2025-08-18 14:17   ` Greg KH
  2025-08-18 13:58 ` [PATCH rust-next 2/2] rust: samples: miscdevice: add lseek samples Ryosuke Yasuoka
  2025-08-18 14:18 ` [PATCH rust-next 0/2] Add llseek support to miscdevice and samples Greg KH
  2 siblings, 1 reply; 11+ messages in thread
From: Ryosuke Yasuoka @ 2025-08-18 13:58 UTC (permalink / raw)
  To: arnd, gregkh, ojeda, alex.gaynor, boqun.feng, gary, bjorn3_gh,
	lossin, a.hindborg, aliceryhl, tmgross, dakr, lee
  Cc: Ryosuke Yasuoka, rust-for-linux, linux-kernel

Add the ability to write a file_operations->llseek hook in Rust when
using the miscdevice abstraction.

Signed-off-by: Ryosuke Yasuoka <ryasuoka@redhat.com>
---
 rust/kernel/miscdevice.rs | 36 ++++++++++++++++++++++++++++++++++++
 1 file changed, 36 insertions(+)

diff --git a/rust/kernel/miscdevice.rs b/rust/kernel/miscdevice.rs
index 6373fe183b27..597e7b66e493 100644
--- a/rust/kernel/miscdevice.rs
+++ b/rust/kernel/miscdevice.rs
@@ -125,6 +125,16 @@ fn release(device: Self::Ptr, _file: &File) {
         drop(device);
     }
 
+    /// Handler for llseek.
+    fn llseek(
+        _device: <Self::Ptr as ForeignOwnable>::Borrowed<'_>,
+        _file: &File,
+        _offset: i64,
+        _whence: i32,
+    ) -> Result<isize> {
+        build_error!(VTABLE_DEFAULT_ERROR)
+    }
+
     /// Handle for mmap.
     ///
     /// This function is invoked when a user space process invokes the `mmap` system call on
@@ -245,6 +255,27 @@ impl<T: MiscDevice> MiscdeviceVTable<T> {
         0
     }
 
+    /// # Safety
+    ///
+    /// `file` must be a valid file that is associated with a `MiscDeviceRegistration<T>`.
+    unsafe extern "C" fn llseek(file: *mut bindings::file, offset: i64, whence: c_int) -> i64 {
+        // SAFETY: The llseek call of a file can access the private data.
+        let private = unsafe { (*file).private_data };
+        // SAFETY: This is a Rust Miscdevice, so we call `into_foreign` in `open` and
+        // `from_foreign` in `release`, and `fops_llseek` is guaranteed to be called between those
+        // two operations.
+        let device = unsafe { <T::Ptr as ForeignOwnable>::borrow(private) };
+        // SAFETY:
+        // * The file is valid for the duration of this call.
+        // * There is no active fdget_pos region on the file on this thread.
+        let file = unsafe { File::from_raw_file(file) };
+
+        match T::llseek(device, file, offset, whence) {
+            Ok(res) => res as i64,
+            Err(err) => i64::from(err.to_errno()),
+        }
+    }
+
     /// # Safety
     ///
     /// `file` must be a valid file that is associated with a `MiscDeviceRegistration<T>`.
@@ -340,6 +371,11 @@ impl<T: MiscDevice> MiscdeviceVTable<T> {
     const VTABLE: bindings::file_operations = bindings::file_operations {
         open: Some(Self::open),
         release: Some(Self::release),
+        llseek: if T::HAS_LLSEEK {
+            Some(Self::llseek)
+        } else {
+            None
+        },
         mmap: if T::HAS_MMAP { Some(Self::mmap) } else { None },
         unlocked_ioctl: if T::HAS_IOCTL {
             Some(Self::ioctl)
-- 
2.50.1


^ permalink raw reply related	[flat|nested] 11+ messages in thread

* [PATCH rust-next 2/2] rust: samples: miscdevice: add lseek samples
  2025-08-18 13:58 [PATCH rust-next 0/2] Add llseek support to miscdevice and samples Ryosuke Yasuoka
  2025-08-18 13:58 ` [PATCH rust-next 1/2] rust: miscdevice: add llseek support Ryosuke Yasuoka
@ 2025-08-18 13:58 ` Ryosuke Yasuoka
  2025-08-18 22:05   ` Benno Lossin
  2025-08-18 14:18 ` [PATCH rust-next 0/2] Add llseek support to miscdevice and samples Greg KH
  2 siblings, 1 reply; 11+ messages in thread
From: Ryosuke Yasuoka @ 2025-08-18 13:58 UTC (permalink / raw)
  To: arnd, gregkh, ojeda, alex.gaynor, boqun.feng, gary, bjorn3_gh,
	lossin, a.hindborg, aliceryhl, tmgross, dakr, lee
  Cc: Ryosuke Yasuoka, rust-for-linux, linux-kernel

Add lseek samples in Rust MiscDevice samples

Signed-off-by: Ryosuke Yasuoka <ryasuoka@redhat.com>
---
 samples/rust/rust_misc_device.rs | 68 ++++++++++++++++++++++++++++++++
 1 file changed, 68 insertions(+)

diff --git a/samples/rust/rust_misc_device.rs b/samples/rust/rust_misc_device.rs
index e7ab77448f75..991a59a3ea16 100644
--- a/samples/rust/rust_misc_device.rs
+++ b/samples/rust/rust_misc_device.rs
@@ -86,6 +86,33 @@
 //!     return -1;
 //!   }
 //!
+//!   // Set a file offset
+//!   printf("Call lseek SEEK_SET\n");
+//!   ret = lseek(fd, 10, SEEK_SET);
+//!   if (ret == 10)
+//!     printf("lseek: Succeed to SEEK_SET\n");
+//!   else
+//!     printf("lseek: Failed to SEEK_SET\n");
+//!
+//!   // Change the file offset from the initial value
+//!   printf("Call lseek SEEK_CUR\n");
+//!   ret = lseek(fd, 10, SEEK_CUR);
+//!   if (ret == 20)
+//!     printf("lseek: Succeed to SEEK_CUR\n");
+//!   else
+//!     printf("lseek: Failed to SEEK_CUR\n");
+//!
+//!   // i_size is 0. So the following task always should fail.
+//!   printf("Call lseek SEEK_END\n");
+//!   ret = lseek(fd, -10, SEEK_END);
+//!   if (ret < 0)
+//!     perror("lseek: Succeeded to fail - this was expected");
+//!   else {
+//!     printf("lseek: Failed to fail SEEK_END\n");
+//!     close(fd);
+//!     return -1;
+//!   }
+//!
 //!   // Close the device file
 //!   printf("Closing /dev/rust-misc-device\n");
 //!   close(fd);
@@ -114,6 +141,10 @@
 const RUST_MISC_DEV_GET_VALUE: u32 = _IOR::<i32>('|' as u32, 0x81);
 const RUST_MISC_DEV_SET_VALUE: u32 = _IOW::<i32>('|' as u32, 0x82);
 
+const SEEK_SET: i32 = 0;
+const SEEK_CUR: i32 = 1;
+const SEEK_END: i32 = 2;
+
 module! {
     type: RustMiscDeviceModule,
     name: "rust_misc_device",
@@ -173,6 +204,43 @@ fn open(_file: &File, misc: &MiscDeviceRegistration<Self>) -> Result<Pin<KBox<Se
         )
     }
 
+    fn llseek(me: Pin<&RustMiscDevice>, file: &File, offset: i64, whence: i32) -> Result<isize> {
+        dev_info!(me.dev, "LLSEEK Rust Misc Device Sample\n");
+        let pos: i64;
+        let eof: i64;
+
+        // SAFETY:
+        // * The file is valid for the duration of this call.
+        // * f_inode must be valid while the file is valid.
+        unsafe {
+            pos = (*file.as_ptr()).f_pos;
+            eof = (*(*file.as_ptr()).f_inode).i_size;
+        }
+
+        let new_pos = match whence {
+            SEEK_SET => offset,
+            SEEK_CUR => pos + offset,
+            SEEK_END => eof + offset,
+            _ => {
+                dev_err!(me.dev, "LLSEEK does not recognised: {}.\n", whence);
+                return Err(EINVAL);
+            }
+        };
+
+        if new_pos < 0 {
+            dev_err!(me.dev, "The file offset becomes negative: {}.\n", new_pos);
+            return Err(EINVAL);
+        }
+
+        // SAFETY: The file is valid for the duration of this call.
+        let ret: isize = unsafe {
+            (*file.as_ptr()).f_pos = new_pos;
+            new_pos as isize
+        };
+
+        Ok(ret)
+    }
+
     fn ioctl(me: Pin<&RustMiscDevice>, _file: &File, cmd: u32, arg: usize) -> Result<isize> {
         dev_info!(me.dev, "IOCTLing Rust Misc Device Sample\n");
 
-- 
2.50.1


^ permalink raw reply related	[flat|nested] 11+ messages in thread

* Re: [PATCH rust-next 1/2] rust: miscdevice: add llseek support
  2025-08-18 13:58 ` [PATCH rust-next 1/2] rust: miscdevice: add llseek support Ryosuke Yasuoka
@ 2025-08-18 14:17   ` Greg KH
  2025-08-19  5:10     ` Ryosuke Yasuoka
  0 siblings, 1 reply; 11+ messages in thread
From: Greg KH @ 2025-08-18 14:17 UTC (permalink / raw)
  To: Ryosuke Yasuoka
  Cc: arnd, ojeda, alex.gaynor, boqun.feng, gary, bjorn3_gh, lossin,
	a.hindborg, aliceryhl, tmgross, dakr, lee, rust-for-linux,
	linux-kernel

On Mon, Aug 18, 2025 at 10:58:38PM +0900, Ryosuke Yasuoka wrote:
> Add the ability to write a file_operations->llseek hook in Rust when
> using the miscdevice abstraction.
> 
> Signed-off-by: Ryosuke Yasuoka <ryasuoka@redhat.com>
> ---
>  rust/kernel/miscdevice.rs | 36 ++++++++++++++++++++++++++++++++++++
>  1 file changed, 36 insertions(+)

What misc device driver needs any real llseek function?  The ones I see
in the tree are only using generic_llseek or noop_llseek.

Do you have a specific misc driver that you want to write in rust that
needs this call?

thanks,

greg k-h

^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: [PATCH rust-next 0/2] Add llseek support to miscdevice and samples
  2025-08-18 13:58 [PATCH rust-next 0/2] Add llseek support to miscdevice and samples Ryosuke Yasuoka
  2025-08-18 13:58 ` [PATCH rust-next 1/2] rust: miscdevice: add llseek support Ryosuke Yasuoka
  2025-08-18 13:58 ` [PATCH rust-next 2/2] rust: samples: miscdevice: add lseek samples Ryosuke Yasuoka
@ 2025-08-18 14:18 ` Greg KH
  2 siblings, 0 replies; 11+ messages in thread
From: Greg KH @ 2025-08-18 14:18 UTC (permalink / raw)
  To: Ryosuke Yasuoka
  Cc: arnd, ojeda, alex.gaynor, boqun.feng, gary, bjorn3_gh, lossin,
	a.hindborg, aliceryhl, tmgross, dakr, lee, rust-for-linux,
	linux-kernel

On Mon, Aug 18, 2025 at 10:58:37PM +0900, Ryosuke Yasuoka wrote:
> This patch series introduces support for the llseek file operation to
> the Rust miscdevice abstraction.
> 
> The first patch, rust: miscdevice: add llseek support, extends the
> MiscDevice trait with a new llseek method.
> 
> The second patch, rust: samples: miscdevice: add lseek samples, add a
> simple example of how to use the new llseek feature. As currently the
> MiscDevice trait does not support any read/write file operation yet, the
> sample is fundamental one.

As read/write isn't there yet, why is llseek needed just yet?

thanks,

greg k-h

^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: [PATCH rust-next 2/2] rust: samples: miscdevice: add lseek samples
  2025-08-18 13:58 ` [PATCH rust-next 2/2] rust: samples: miscdevice: add lseek samples Ryosuke Yasuoka
@ 2025-08-18 22:05   ` Benno Lossin
  2025-08-19  5:18     ` Ryosuke Yasuoka
  0 siblings, 1 reply; 11+ messages in thread
From: Benno Lossin @ 2025-08-18 22:05 UTC (permalink / raw)
  To: Ryosuke Yasuoka, arnd, gregkh, ojeda, alex.gaynor, boqun.feng,
	gary, bjorn3_gh, a.hindborg, aliceryhl, tmgross, dakr, lee
  Cc: rust-for-linux, linux-kernel

On Mon Aug 18, 2025 at 3:58 PM CEST, Ryosuke Yasuoka wrote:
> +    fn llseek(me: Pin<&RustMiscDevice>, file: &File, offset: i64, whence: i32) -> Result<isize> {
> +        dev_info!(me.dev, "LLSEEK Rust Misc Device Sample\n");
> +        let pos: i64;
> +        let eof: i64;
> +
> +        // SAFETY:
> +        // * The file is valid for the duration of this call.
> +        // * f_inode must be valid while the file is valid.
> +        unsafe {
> +            pos = (*file.as_ptr()).f_pos;
> +            eof = (*(*file.as_ptr()).f_inode).i_size;
> +        }

Please include abstractions for writing & reading the file position
instead of using `unsafe`.

---
Cheers,
Benno

> +
> +        let new_pos = match whence {
> +            SEEK_SET => offset,
> +            SEEK_CUR => pos + offset,
> +            SEEK_END => eof + offset,
> +            _ => {
> +                dev_err!(me.dev, "LLSEEK does not recognised: {}.\n", whence);
> +                return Err(EINVAL);
> +            }
> +        };
> +
> +        if new_pos < 0 {
> +            dev_err!(me.dev, "The file offset becomes negative: {}.\n", new_pos);
> +            return Err(EINVAL);
> +        }
> +
> +        // SAFETY: The file is valid for the duration of this call.
> +        let ret: isize = unsafe {
> +            (*file.as_ptr()).f_pos = new_pos;
> +            new_pos as isize
> +        };
> +
> +        Ok(ret)
> +    }
> +
>      fn ioctl(me: Pin<&RustMiscDevice>, _file: &File, cmd: u32, arg: usize) -> Result<isize> {
>          dev_info!(me.dev, "IOCTLing Rust Misc Device Sample\n");
>  


^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: [PATCH rust-next 1/2] rust: miscdevice: add llseek support
  2025-08-18 14:17   ` Greg KH
@ 2025-08-19  5:10     ` Ryosuke Yasuoka
  2025-08-19  6:04       ` Greg KH
  0 siblings, 1 reply; 11+ messages in thread
From: Ryosuke Yasuoka @ 2025-08-19  5:10 UTC (permalink / raw)
  To: Greg KH
  Cc: arnd, ojeda, alex.gaynor, boqun.feng, gary, bjorn3_gh, lossin,
	a.hindborg, aliceryhl, tmgross, dakr, lee, rust-for-linux,
	linux-kernel

On Mon, Aug 18, 2025 at 04:17:40PM +0200, Greg KH wrote:
> On Mon, Aug 18, 2025 at 10:58:38PM +0900, Ryosuke Yasuoka wrote:
> > Add the ability to write a file_operations->llseek hook in Rust when
> > using the miscdevice abstraction.
> > 
> > Signed-off-by: Ryosuke Yasuoka <ryasuoka@redhat.com>
> > ---
> >  rust/kernel/miscdevice.rs | 36 ++++++++++++++++++++++++++++++++++++
> >  1 file changed, 36 insertions(+)
> 
> What misc device driver needs any real llseek function?  The ones I see
> in the tree are only using generic_llseek or noop_llseek.
> 
> Do you have a specific misc driver that you want to write in rust that
> needs this call?

No, I'm not actually writing a practical misc driver. I'm just creating
a toy misc driver to use for testing.

In my toy driver, I need read, write, lseek, and ioctl to verify the
basic functionality of the device driver. I saw the Jones and Alice were
already working on read/write functions [1] and I believe they will
propose their patch soon. So I propose implementing lseek which
anyone does not work on currently. This is the background of my patch.

As you mentioned, lseek by itself probably doesn't have much meaning.
Should I wait for their read/write implementation to be finalized before
proceeding this?

[1] https://rust-for-linux.zulipchat.com/#narrow/channel/288089-General/topic/.E2.9C.94.20Miscdevice.20read.2Fwrite.20abstraction.3F/with/497953296

Thank you very much for your comment.
Ryosuke

> 
> thanks,
> 
> greg k-h
> 


^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: [PATCH rust-next 2/2] rust: samples: miscdevice: add lseek samples
  2025-08-18 22:05   ` Benno Lossin
@ 2025-08-19  5:18     ` Ryosuke Yasuoka
  0 siblings, 0 replies; 11+ messages in thread
From: Ryosuke Yasuoka @ 2025-08-19  5:18 UTC (permalink / raw)
  To: Benno Lossin
  Cc: arnd, gregkh, ojeda, alex.gaynor, boqun.feng, gary, bjorn3_gh,
	a.hindborg, aliceryhl, tmgross, dakr, lee, rust-for-linux,
	linux-kernel

On Tue, Aug 19, 2025 at 12:05:41AM +0200, Benno Lossin wrote:
> On Mon Aug 18, 2025 at 3:58 PM CEST, Ryosuke Yasuoka wrote:
> > +    fn llseek(me: Pin<&RustMiscDevice>, file: &File, offset: i64, whence: i32) -> Result<isize> {
> > +        dev_info!(me.dev, "LLSEEK Rust Misc Device Sample\n");
> > +        let pos: i64;
> > +        let eof: i64;
> > +
> > +        // SAFETY:
> > +        // * The file is valid for the duration of this call.
> > +        // * f_inode must be valid while the file is valid.
> > +        unsafe {
> > +            pos = (*file.as_ptr()).f_pos;
> > +            eof = (*(*file.as_ptr()).f_inode).i_size;
> > +        }
> 
> Please include abstractions for writing & reading the file position
> instead of using `unsafe`.

OK. I believe I probably need to modify on the kernel:fs::file::File to
add abstraction for writing & reading. I'll re-consider and send them in
v2 patch.

Thank you very much for your comment.

> ---
> Cheers,
> Benno
> 
> > +
> > +        let new_pos = match whence {
> > +            SEEK_SET => offset,
> > +            SEEK_CUR => pos + offset,
> > +            SEEK_END => eof + offset,
> > +            _ => {
> > +                dev_err!(me.dev, "LLSEEK does not recognised: {}.\n", whence);
> > +                return Err(EINVAL);
> > +            }
> > +        };
> > +
> > +        if new_pos < 0 {
> > +            dev_err!(me.dev, "The file offset becomes negative: {}.\n", new_pos);
> > +            return Err(EINVAL);
> > +        }
> > +
> > +        // SAFETY: The file is valid for the duration of this call.
> > +        let ret: isize = unsafe {
> > +            (*file.as_ptr()).f_pos = new_pos;
> > +            new_pos as isize
> > +        };
> > +
> > +        Ok(ret)
> > +    }
> > +
> >      fn ioctl(me: Pin<&RustMiscDevice>, _file: &File, cmd: u32, arg: usize) -> Result<isize> {
> >          dev_info!(me.dev, "IOCTLing Rust Misc Device Sample\n");
> >  
> 


^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: [PATCH rust-next 1/2] rust: miscdevice: add llseek support
  2025-08-19  5:10     ` Ryosuke Yasuoka
@ 2025-08-19  6:04       ` Greg KH
  2025-08-19 14:12         ` Ryosuke Yasuoka
  0 siblings, 1 reply; 11+ messages in thread
From: Greg KH @ 2025-08-19  6:04 UTC (permalink / raw)
  To: Ryosuke Yasuoka
  Cc: arnd, ojeda, alex.gaynor, boqun.feng, gary, bjorn3_gh, lossin,
	a.hindborg, aliceryhl, tmgross, dakr, lee, rust-for-linux,
	linux-kernel

On Tue, Aug 19, 2025 at 02:10:27PM +0900, Ryosuke Yasuoka wrote:
> On Mon, Aug 18, 2025 at 04:17:40PM +0200, Greg KH wrote:
> > On Mon, Aug 18, 2025 at 10:58:38PM +0900, Ryosuke Yasuoka wrote:
> > > Add the ability to write a file_operations->llseek hook in Rust when
> > > using the miscdevice abstraction.
> > > 
> > > Signed-off-by: Ryosuke Yasuoka <ryasuoka@redhat.com>
> > > ---
> > >  rust/kernel/miscdevice.rs | 36 ++++++++++++++++++++++++++++++++++++
> > >  1 file changed, 36 insertions(+)
> > 
> > What misc device driver needs any real llseek function?  The ones I see
> > in the tree are only using generic_llseek or noop_llseek.
> > 
> > Do you have a specific misc driver that you want to write in rust that
> > needs this call?
> 
> No, I'm not actually writing a practical misc driver. I'm just creating
> a toy misc driver to use for testing.
> 
> In my toy driver, I need read, write, lseek, and ioctl to verify the
> basic functionality of the device driver. I saw the Jones and Alice were
> already working on read/write functions [1] and I believe they will
> propose their patch soon. So I propose implementing lseek which
> anyone does not work on currently. This is the background of my patch.
> 
> As you mentioned, lseek by itself probably doesn't have much meaning.
> Should I wait for their read/write implementation to be finalized before
> proceeding this?
> 
> [1] https://rust-for-linux.zulipchat.com/#narrow/channel/288089-General/topic/.E2.9C.94.20Miscdevice.20read.2Fwrite.20abstraction.3F/with/497953296

Yes, that would probably be best, because as-is, this patch can not
really do anything :(

Also, we really want an in-tree user for the new functionality (not just
in the sample driver), if at all possible going forward.

thanks,

greg k-h

^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: [PATCH rust-next 1/2] rust: miscdevice: add llseek support
  2025-08-19  6:04       ` Greg KH
@ 2025-08-19 14:12         ` Ryosuke Yasuoka
  2025-08-21 14:48           ` Miguel Ojeda
  0 siblings, 1 reply; 11+ messages in thread
From: Ryosuke Yasuoka @ 2025-08-19 14:12 UTC (permalink / raw)
  To: Greg KH
  Cc: arnd, ojeda, alex.gaynor, boqun.feng, gary, bjorn3_gh, lossin,
	a.hindborg, aliceryhl, tmgross, dakr, lee, rust-for-linux,
	linux-kernel

On Tue, Aug 19, 2025 at 08:04:32AM +0200, Greg KH wrote:
> On Tue, Aug 19, 2025 at 02:10:27PM +0900, Ryosuke Yasuoka wrote:
> > On Mon, Aug 18, 2025 at 04:17:40PM +0200, Greg KH wrote:
> > > On Mon, Aug 18, 2025 at 10:58:38PM +0900, Ryosuke Yasuoka wrote:
> > > > Add the ability to write a file_operations->llseek hook in Rust when
> > > > using the miscdevice abstraction.
> > > > 
> > > > Signed-off-by: Ryosuke Yasuoka <ryasuoka@redhat.com>
> > > > ---
> > > >  rust/kernel/miscdevice.rs | 36 ++++++++++++++++++++++++++++++++++++
> > > >  1 file changed, 36 insertions(+)
> > > 
> > > What misc device driver needs any real llseek function?  The ones I see
> > > in the tree are only using generic_llseek or noop_llseek.
> > > 
> > > Do you have a specific misc driver that you want to write in rust that
> > > needs this call?
> > 
> > No, I'm not actually writing a practical misc driver. I'm just creating
> > a toy misc driver to use for testing.
> > 
> > In my toy driver, I need read, write, lseek, and ioctl to verify the
> > basic functionality of the device driver. I saw the Jones and Alice were
> > already working on read/write functions [1] and I believe they will
> > propose their patch soon. So I propose implementing lseek which
> > anyone does not work on currently. This is the background of my patch.
> > 
> > As you mentioned, lseek by itself probably doesn't have much meaning.
> > Should I wait for their read/write implementation to be finalized before
> > proceeding this?
> > 
> > [1] https://rust-for-linux.zulipchat.com/#narrow/channel/288089-General/topic/.E2.9C.94.20Miscdevice.20read.2Fwrite.20abstraction.3F/with/497953296
> 
> Yes, that would probably be best, because as-is, this patch can not
> really do anything :(
> 
> Also, we really want an in-tree user for the new functionality (not just
> in the sample driver), if at all possible going forward.

Got it. I'll try to include an in-tree user for it next time.

Thank you.
Ryosuke

> thanks,
> 
> greg k-h
> 


^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: [PATCH rust-next 1/2] rust: miscdevice: add llseek support
  2025-08-19 14:12         ` Ryosuke Yasuoka
@ 2025-08-21 14:48           ` Miguel Ojeda
  0 siblings, 0 replies; 11+ messages in thread
From: Miguel Ojeda @ 2025-08-21 14:48 UTC (permalink / raw)
  To: Ryosuke Yasuoka
  Cc: Greg KH, arnd, ojeda, alex.gaynor, boqun.feng, gary, bjorn3_gh,
	lossin, a.hindborg, aliceryhl, tmgross, dakr, lee, rust-for-linux,
	linux-kernel

On Tue, Aug 19, 2025 at 4:12 PM Ryosuke Yasuoka <ryasuoka@redhat.com> wrote:
>
> Got it. I'll try to include an in-tree user for it next time.

Thanks! Yeah, please see:

    https://rust-for-linux.com/contributing#submitting-new-abstractions-and-modules

for some more context on the "in-tree user" rule and ideas on how to
possibly provide one.

I hope that helps.

Cheers,
Miguel

^ permalink raw reply	[flat|nested] 11+ messages in thread

end of thread, other threads:[~2025-08-21 14:48 UTC | newest]

Thread overview: 11+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-08-18 13:58 [PATCH rust-next 0/2] Add llseek support to miscdevice and samples Ryosuke Yasuoka
2025-08-18 13:58 ` [PATCH rust-next 1/2] rust: miscdevice: add llseek support Ryosuke Yasuoka
2025-08-18 14:17   ` Greg KH
2025-08-19  5:10     ` Ryosuke Yasuoka
2025-08-19  6:04       ` Greg KH
2025-08-19 14:12         ` Ryosuke Yasuoka
2025-08-21 14:48           ` Miguel Ojeda
2025-08-18 13:58 ` [PATCH rust-next 2/2] rust: samples: miscdevice: add lseek samples Ryosuke Yasuoka
2025-08-18 22:05   ` Benno Lossin
2025-08-19  5:18     ` Ryosuke Yasuoka
2025-08-18 14:18 ` [PATCH rust-next 0/2] Add llseek support to miscdevice and samples Greg KH

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).