[PATCH 04/11] discover: Fix dead code in udev_handle_cdrom_events()

Sam Mendoza-Jonas sam.mj at au1.ibm.com
Fri Dec 18 11:13:06 AEDT 2015


On Fri, Dec 18, 2015 at 10:43:02AM +1100, Sam Mendoza-Jonas wrote:
> On Thu, Nov 12, 2015 at 03:34:34PM +1100, Samuel Mendoza-Jonas wrote:
> > The check against ddev->mounted to cause an eject action is logically
> > impossible. Change it so a cdrom_eject() is called properly.
> > Change the return value to 'true' for any action caused by
> > DISK_EJECT_REQUEST - no further action is appropriate in this case
> > 
> > Signed-off-by: Samuel Mendoza-Jonas <sam.mj at au1.ibm.com>
> > ---
> >  discover/udev.c | 9 ++-------
> >  1 file changed, 2 insertions(+), 7 deletions(-)
> > 
> > diff --git a/discover/udev.c b/discover/udev.c
> > index 6cc718e..fe3b21e 100644
> > --- a/discover/udev.c
> > +++ b/discover/udev.c
> > @@ -250,22 +250,17 @@ static bool udev_handle_cdrom_events(struct pb_udev *udev,
> >  
> >  	/* handle CDROM eject requests */
> >  	if (udev_device_get_property_value(dev, "DISK_EJECT_REQUEST")) {
> > -		bool eject = false;
> > -
> >  		pb_debug("udev: eject request\n");
> >  
> >  		/* If the device is mounted, cdrom_id's own eject request may
> >  		 * have failed. So, we'll need to do our own here.
> >  		 */
> >  		if (ddev) {
> > -			eject = ddev->mounted;
> > +			if (ddev->mounted)
> > +				cdrom_eject(node);
> >  			udev_handle_dev_remove(udev, dev);
> > -			return false;
> 
> On review the eject should happen *after* the call to
> udev_handle_dev_remove so we properly unmount everything first. I'll
> fix this up before merging.
> 

And now that the coffee has taken effect this actually needs to be of the form:

               if (ddev) {
                        eject = ddev->mounted;
                        udev_handle_dev_remove(udev, dev);
                }
 
                if (eject)
                        cdrom_eject(node);

Otherwise we'll forget to eject the disk at all since ddev->mounted will
be false after calling udev_handle_dev_remove().

> >  		}
> >  
> > -		if (eject)
> > -			cdrom_eject(node);
> > -
> >  		return true;
> >  	}
> >  
> > -- 
> > 2.6.2
> > 
> 
> _______________________________________________
> Petitboot mailing list
> Petitboot at lists.ozlabs.org
> https://lists.ozlabs.org/listinfo/petitboot



More information about the Petitboot mailing list