rust-for-linux.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* File operations
@ 2020-12-09 21:47 Wedson Almeida Filho
  2020-12-09 23:18 ` Miguel Ojeda
  0 siblings, 1 reply; 8+ messages in thread
From: Wedson Almeida Filho @ 2020-12-09 21:47 UTC (permalink / raw)
  To: rust-for-linux

Hello,

I'm looking to implement a FileOperations trait for a driver and am
finding it cumbersome. For example, to implement read, one needs to
declare the following (copied from example):

impl file_operations::FileOperations for CycleFile {
    const READ: file_operations::ReadFn<Self> = Some(
        |_this: &Self,
         _file: &file_operations::File,
         _buf: &mut user_ptr::UserSlicePtrWriter,
         _offset: u64|
         -> KernelResult<()> {
         ...
       },
    );
}

I couldn't find a way to simplify this to just implementing the
desired functions, but I can get it down to implementing just the
desired functions plus one annotation for the impl block, for example
(note the [#build_fileops] annotation at the top):

[#build_fileops]
impl file_operations::FileOperations for CycleFile {
    fn read(
        &self,
        _file: &file_operations::File,
        _buf: &mut user_ptr::UserSlicePtrWriter,
        _offset: u64,
    ) -> KernelResult() {
        ...
    }
}

How do you all feel about this? I think it is an improvement but would
like to hear what you think before spending more time on this.

Thanks,
-Wedson

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

end of thread, other threads:[~2020-12-18  3:59 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2020-12-09 21:47 File operations Wedson Almeida Filho
2020-12-09 23:18 ` Miguel Ojeda
2020-12-13  0:01   ` Wedson Almeida Filho
2020-12-13  0:50     ` Miguel Ojeda
2020-12-13  2:12       ` Wedson Almeida Filho
2020-12-13  3:33         ` Miguel Ojeda
2020-12-14  2:02           ` Wedson Almeida Filho
2020-12-18  3:58             ` Miguel Ojeda

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).