[parted-devel] [PATCH] libparted: Use read only when probing devices on linux (#1245144)
Phil Susi
psusi at ubuntu.com
Mon Sep 21 19:41:21 UTC 2015
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.
More information about the parted-devel
mailing list