On Tue, Sep 23, 2025 at 06:47:25PM +0200, Fabio wrote:
Hello,
brand-new kernel newbie here. I'm interested in the Rust side of the kernel. To get acquainted, I'm following the Linux Driver Development book, 3rd edition, also integrating it with modern documentation and best practices (or at least I hope so).
I'm developing the scull module on top of the `kernel::miscdevice::MiscDevice` trait. Where I'm stuck at is the lack of the `kernel::file::Operations` trait [1], that most online resources refer to. I need such trait to implement read and write operations for the misc device. AFAIU, this trait used to exist but it's no longer in the mainline codebase [2]. Also, `kernel::miscdevice::MiscdeviceVTable` is private inside the miscdevice module, so there's no way I can somehow extend it.
Is there any workaround for what I want to achieve, or is ioctl the only allowed interface to misc devices in Rust?
Please see the rust sample misc driver that is right now in linux-next, it shows how to use the read and write iter functions, which should be all that you need. Specifically look at commit e5b0d7da941a ("samples: rust_misc_device: Expand the sample to support read()ing from userspace"), which shows how this can be done. Yes, this is a bit different than the traditional "read/write" callbacks, as documented in the device driver's book, but things have moved on in the decades since we wrote that :) The changes for this will be showing up in the next kernel release (i.e. 6.18). hope this helps, greg k-h