On Fri, Jan 13, 2023 at 11:51:45AM +0300, Konstantin Kharlamov wrote: > Before this patch API like `ped_disk_new()` were unconditionally opening > the disk in O_RDWR mode. Now it may be opened in readonly mode by > setting `read_only = 1` field of `PedDevice` before calling the > function. > > This allows to avoid kernel/udev events like "remove/add" and "change" > in cases, where users are only interested in read-only functional, like > reading a partitions list.
I like this. Nice and simple, and minimal chance of breaking the parted command :) I've got a test written for this that I'll post in a sec... To answer your question in the other email -- no there is no way to open it read only. We changed the initial probe to be read only, but normal operation is still R/W because of how it parses the commands, it doesn't know ahead of time if it will need it to be writable. I looked at the lazy patch from Arvin, but I'm not too excited about re-opening things in the middle of it being used. Just seems dangerous, but I'll think about it some more. This patch is a good intermediate step though, thanks! Brian -- Brian C. Lane (PST8PDT) - weldr.io - lorax - parted - pykickstart
