Re: [PATCH 3/3] rust: miscdevice: adjust the rust_misc_device sample to use RegistrationData.
From: Alice Ryhl
Date: Fri Jan 24 2025 - 04:43:19 EST
On Fri, Jan 24, 2025 at 9:06 AM Greg Kroah-Hartman
<gregkh@xxxxxxxxxxxxxxxxxxx> wrote:
>
> On Fri, Jan 24, 2025 at 08:29:38AM +0100, Alice Ryhl wrote:
> > On Thu, Jan 23, 2025 at 6:57 PM Christian Schrefl
> > <chrisi.schrefl@xxxxxxxxx> wrote:
> > >
> > > Hi Alice
> > >
> > > On 21.01.25 4:40 PM, Alice Ryhl wrote:
> > > > On Sun, Jan 19, 2025 at 11:11 PM Christian Schrefl
> > > > <chrisi.schrefl@xxxxxxxxx> wrote:
> > > >>
> > > >> Share the mutex stored in RustMiscDevice between all instances using an Arc
> > > >> and the RegistrationData of MiscDeviceRegistration.
> > > >>
> > > >> This is mostly to Demonstrate the capability to share data in this way.
> > > >>
> > > >> Signed-off-by: Christian Schrefl <chrisi.schrefl@xxxxxxxxx>
> > > >
> > > > This change causes all open files to share the same value, instead of
> > > > it being per-fd.
> > >
> > > I know, if that is unwanted I'm fine with dropping this patch,
> > > it is mostly here to show how patch 2 can be used.
> >
> > Perhaps instead of changing the per-fd value, we could add a new
> > shared value? E.g., it could have a counter for the number of open
> > files.
>
> Counters don't work, sorry (think about dup() for file handles), please,
> either make it per-file handle, or a "global" thing for the specific
> object, don't attempt to count open/release calls, the vfs does this for
> us already.
I mean, it's just for an example, shrug. It could also be another
ioctl that updates the shared value.
Alice