Re: [PATCH v2 2/2] rust: miscdevice: add base miscdevice abstraction

From: Christian Brauner
Date: Thu Oct 03 2024 - 04:34:04 EST


On Wed, Oct 02, 2024 at 04:24:58PM GMT, Alice Ryhl wrote:
> On Wed, Oct 2, 2024 at 4:06 PM Christian Brauner <brauner@xxxxxxxxxx> wrote:
> >
> > On Tue, Oct 01, 2024 at 08:22:22AM GMT, Alice Ryhl wrote:
> > > +unsafe extern "C" fn fops_open<T: MiscDevice>(
> > > + inode: *mut bindings::inode,
> > > + file: *mut bindings::file,
> > > +) -> c_int {
> > > + // SAFETY: The pointers are valid and for a file being opened.
> > > + let ret = unsafe { bindings::generic_file_open(inode, file) };
> > > + if ret != 0 {
> > > + return ret;
> > > + }
> >
> > Do you have code where that function is used? Because this looks wrong
> > or at least I don't understand from just a glance whether that
> > generic_file_open() call makes sense.
> >
> > Illustrating how we get from opening /dev/binder to this call would
> > help.
>
> Hmm. I wrote this by comparing with the ashmem open callback. Now that
> you mention it you are right that Binder does not call
> generic_file_open ... I have to admit that I don't know what
> generic_file_open does.

It's irrelevant for binder.