Re: [PATCH v2] usb: gadget: f_mass_storage: forced_eject attribute

From: Maxim Devaev
Date: Thu Jul 07 2022 - 13:10:16 EST


В Thu, 7 Jul 2022 10:57:42 -0400
Alan Stern <stern@xxxxxxxxxxxxxxxxxxx> wrote:

> On Wed, Jul 06, 2022 at 09:59:37PM +0300, Maxim Devaev wrote:
> > It allows to reset prevent_medium_removal flag and "eject" the image.
> >
> > The patch is a completely alternative implementation of the previously
> > proposed [1], the idea of which was born after the mentioned discussion.
>
> Generally quite good, but the documentation needs some improvement.

Thanks for your help, I've fixed it and submitted v3 patch.

> By the way, what does happen if someone writes to this attribute file
> before the function is active? Have you tested this?

Yes. This simply detaches the backing file, as if you had written an empty
string to the "file" attribute. This is literally the same code, just
resetting a flag that, with an inactive configuration, cannot even be set.

> Doesn't a zero-byte write also work?

No, the same as with the rest of the configfs attributes.