[parted-devel] [PATCH] libparted: Use read only when probing devices on linux (#1245144)
Brian C. Lane
bcl at redhat.com
Thu Sep 24 00:31:36 UTC 2015
On Mon, Sep 21, 2015 at 03:41:21PM -0400, Phil Susi wrote:
> On 8/6/2015 6:45 PM, Brian C. Lane wrote:
> > When a device is opened for RW closing it can trigger other actions,
> > like udev scanning it for partition changes. Use read only for the
> > init_* methods and RW for actual changes to the device.
> >
> > This adds _device_open which takes mode flags as an argument and turns
> > linux_open into a wrapper for it with RW_MODE.
> >
> > _device_open_ro is added to open the device with RD_MODE and increment
> > the open_counter. This is used in the init_* functions.
> >
> > _device_close is a wrapper around linux_close that decrements the
> > open_counter and is used in the init_* functions.
> >
> > All of these changes are self-contained with no external API changes.
> > The only visible change in behavior is that when a new PedDevice is
> > created the device is opened in RO_MODE instead of RW_MODE.
> >
> > Resolves: rhbz#1245144
>
> I like the idea in theory, but how can this work without changing the
> api? For instance, the print command invokes the filesystem probe code,
> which ends up calling linux_open(), and so that will result in a r/w
> open when it really only needs read access.
This doesn't try to make any commands use RO, it is making sure that
there is only 1 RW open/close instead of 2 of them. When linux_new is
called it calls the init_ functions which don't need to be RW so now we
have a RO open/close and then a RW open/close and udev only watches for
RW so it doesn't trigger the udev rules close together.
--
Brian C. Lane | Anaconda Team | IRC: bcl #anaconda | Port Orchard, WA (PST8PDT)
More information about the parted-devel
mailing list