[systemd-devel] Inhibiting plug and play

Lennart Poettering lennart at poettering.net
Tue Jul 16 10:23:29 PDT 2013

On Tue, 18.06.13 13:45, Phillip Susi (psusi at ubuntu.com) wrote:

> Hash: SHA1
> Various tools, but most notably partitioners, manipulate disks in such
> a way that they need to prevent the rest of the system from racing
> with them while they are in the middle of manipulating the disk.
> Presently this is done with a hodge podge of hacks that involve
> running some script or executable to temporarily hold off on some
> aspects ( typically only auto mounting ) of plug and play processing.
>  Which one depends on whether you are running hal, udisks, udisks2, or
> systemd.
> There really needs to be a proper way at a lower level, either udev,
> or maybe in the kernel, to inhibit processing events until the tool
> changing the device has finished completely.  The question is, should
> this be in the kernel, or in udev, and what should the interface be?

So, Kay suggested we should use BSD file locks for this. i.e. all tools
which want to turn off events for a device would take one on that
specific device fd. As long as it is taken udev would not generate
events. As soon as the BSD lock is released again it would recheck the

To me this sounds like a pretty clean thing to do. Locks usually suck,
but for this purpose they appear to do exactly what they should, and
most of the problematic things with them don't apply in this specific

Doing things way would be quite robust, as we have clean synchronization
and the kernel will release the locks automatically when the owner dies.



Lennart Poettering - Red Hat, Inc.

More information about the systemd-devel mailing list